Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
timonson committed Oct 12, 2023
1 parent df1eaf6 commit 2ae01e7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
28 changes: 17 additions & 11 deletions middlewares/jwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,27 @@ import {

export type PayloadState = { payload: Payload };

export function curriedVerify(input: CryptoKeyOrUpdateInput) {
const verifyJwtCurried = verifyJwt(input);
return (options: VerifyOptions = {}) => {
return async <C extends Context<PayloadState>>(ctx: C): Promise<C> => {
try {
const jwt = getJwtFromBearer(ctx.request.headers);
const payload = await verifyJwtCurried(jwt, options);
ctx.state.payload = payload;
return ctx;
} catch (error) {
throw isHttpError(error) ? error : createUnauthorizedError(error);
}
};
};
}

export function verify(
input: CryptoKeyOrUpdateInput,
options?: VerifyOptions,
) {
const verifyJwtCurried = verifyJwt(input);
return async <C extends Context<PayloadState>>(ctx: C): Promise<C> => {
try {
const jwt = getJwtFromBearer(ctx.request.headers);
const payload = await verifyJwtCurried(jwt, options);
ctx.state.payload = payload;
return ctx;
} catch (error) {
throw isHttpError(error) ? error : createUnauthorizedError(error);
}
};
return curriedVerify(input)(options);
}

export function create(
Expand Down
4 changes: 3 additions & 1 deletion middlewares/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { type JsonObject } from "../functions/json.ts";
import { getDirectoriesFromRepo, pullOrClone } from "../functions/git.ts";
import { type WebhooksState } from "./webhook.ts";

type PayloadForCreateEvent = {
export type PayloadForCreateEvent = {
repository: {
name: string;
owner: Record<string, JsonObject> & { login: string };
Expand Down Expand Up @@ -148,6 +148,8 @@ function ensureDirAndSymlink(containerPath: string) {
`Creating a symlink from ${parentContainer} to ${containerPath}.`,
);
} catch {
// It needs the `--unstable` flag at the moment:
// Deno.umask(0);
Deno.mkdirSync(parentContainer, { recursive: true });
Deno.symlinkSync(parentContainer, containerPath);
console.log(
Expand Down

0 comments on commit 2ae01e7

Please sign in to comment.