From 2ae01e7be3244462af4699a7631f0caed9aabbdb Mon Sep 17 00:00:00 2001 From: timonson Date: Thu, 12 Oct 2023 23:19:28 +0200 Subject: [PATCH] Update --- middlewares/jwt.ts | 28 +++++++++++++++++----------- middlewares/repository.ts | 4 +++- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/middlewares/jwt.ts b/middlewares/jwt.ts index a9112e4..df558d2 100644 --- a/middlewares/jwt.ts +++ b/middlewares/jwt.ts @@ -15,21 +15,27 @@ import { export type PayloadState = { payload: Payload }; +export function curriedVerify(input: CryptoKeyOrUpdateInput) { + const verifyJwtCurried = verifyJwt(input); + return (options: VerifyOptions = {}) => { + return async >(ctx: C): Promise => { + 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 >(ctx: C): Promise => { - 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( diff --git a/middlewares/repository.ts b/middlewares/repository.ts index d1a425f..389629c 100644 --- a/middlewares/repository.ts +++ b/middlewares/repository.ts @@ -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 & { login: string }; @@ -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(