From f71043e7f1fe0277591e0682e2ff3340e206e0b9 Mon Sep 17 00:00:00 2001 From: Mentlegen <9807008+gentlementlegen@users.noreply.github.com> Date: Tue, 9 Jul 2024 08:13:52 +0900 Subject: [PATCH 01/12] fix!: renamed PRIVATE_KEY to APP_PRIVATE_KEY, WEBHOOK_SECRET optional and removed WEBHOOK_PROXY_URL --- .github/workflows/build.yml | 6 ++---- .github/workflows/bun-testing.yml | 2 +- README.md | 10 +++++----- src/github/github-event-handler.ts | 10 +++++----- src/github/types/env.ts | 10 +++++++--- src/worker.ts | 2 +- tests/main.test.ts | 4 ++-- 7 files changed, 23 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fbba345..4c70441 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,12 +38,10 @@ jobs: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} secrets: | - WEBHOOK_PROXY_URL WEBHOOK_SECRET APP_ID - PRIVATE_KEY + APP_PRIVATE_KEY env: - WEBHOOK_PROXY_URL: ${{ secrets.WEBHOOK_PROXY_URL }} WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }} APP_ID: ${{ secrets.APP_ID }} - PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }} + APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }} diff --git a/.github/workflows/bun-testing.yml b/.github/workflows/bun-testing.yml index 45a6e5a..b3a27e3 100644 --- a/.github/workflows/bun-testing.yml +++ b/.github/workflows/bun-testing.yml @@ -8,7 +8,7 @@ env: NODE_ENV: "test" WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }} APP_ID: ${{ secrets.APP_ID }} - PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }} + APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }} jobs: testing: diff --git a/README.md b/README.md index ad390e2..91075a6 100644 --- a/README.md +++ b/README.md @@ -7,14 +7,14 @@ The kernel is designed to: ## Environment Variables -- **`PRIVATE_KEY`** +- **`APP_PRIVATE_KEY`** Obtain a private key from your GitHub App settings and convert it to the Public-Key Cryptography Standards #8 (PKCS#8) format. Use the following command to perform this conversion and append the result to your `.dev.vars` file: ```sh - echo "PRIVATE_KEY=\"$(openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in YOUR_PRIVATE_KEY.PEM | awk 'BEGIN{ORS="\\n"} 1')\"" >> .dev.vars + echo "APP_PRIVATE_KEY=\"$(openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in YOUR_APP_PRIVATE_KEY.PEM | awk 'BEGIN{ORS="\\n"} 1')\"" >> .dev.vars ``` - **Note:** Replace `YOUR_PRIVATE_KEY.PEM` with the path to your actual PEM file when running the command. + **Note:** Replace `YOUR_APP_PRIVATE_KEY.PEM` with the path to your actual PEM file when running the command. - **`WEBHOOK_SECRET`** Set this value in both your GitHub App settings and here. @@ -70,10 +70,10 @@ bun dev 5. **Manage Secrets:** - Add (env) secrets using `npx wrangler secret put --env dev`. - - For the private key, execute the following (replace `YOUR_PRIVATE_KEY.PEM` with the actual PEM file path): + - For the private key, execute the following (replace `YOUR_APP_PRIVATE_KEY.PEM` with the actual PEM file path): ```sh - echo $(openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in YOUR_PRIVATE_KEY.PEM) | npx wrangler secret put PRIVATE_KEY --env dev + echo $(openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in YOUR_APP_PRIVATE_KEY.PEM) | npx wrangler secret put APP_PRIVATE_KEY --env dev ``` 6. **Deploy the Kernel:** diff --git a/src/github/github-event-handler.ts b/src/github/github-event-handler.ts index 4f7895e..a51d4e5 100644 --- a/src/github/github-event-handler.ts +++ b/src/github/github-event-handler.ts @@ -6,7 +6,7 @@ import { CloudflareKv } from "./utils/cloudflare-kv"; import { PluginChainState } from "./types/plugin"; export type Options = { - webhookSecret: string; + webhookSecret: string | undefined; appId: string | number; privateKey: string; pluginChainState: CloudflareKv; @@ -19,9 +19,9 @@ export class GitHubEventHandler { public onError: Webhooks["onError"]; public pluginChainState: CloudflareKv; - private _webhookSecret: string; - private _privateKey: string; - private _appId: number; + private readonly _webhookSecret: string | undefined; + private readonly _privateKey: string; + private readonly _appId: number; constructor(options: Options) { this._privateKey = options.privateKey; @@ -30,7 +30,7 @@ export class GitHubEventHandler { this.pluginChainState = options.pluginChainState; this.webhooks = new Webhooks({ - secret: this._webhookSecret, + secret: this._webhookSecret || "", transform: (event) => this.transformEvent(event), // it is important to use an arrow function here to keep the context of `this` }); diff --git a/src/github/types/env.ts b/src/github/types/env.ts index 29ec19e..ecc8e7f 100644 --- a/src/github/types/env.ts +++ b/src/github/types/env.ts @@ -1,6 +1,10 @@ import { Type as T, type Static } from "@sinclair/typebox"; -export const envSchema = T.Object({ WEBHOOK_SECRET: T.String({ minLength: 1 }), APP_ID: T.String({ minLength: 1 }), PRIVATE_KEY: T.String({ minLength: 1 }) }); +export const envSchema = T.Object({ + WEBHOOK_SECRET: T.Optional(T.String({ minLength: 1 })), + APP_ID: T.String({ minLength: 1 }), + APP_PRIVATE_KEY: T.String({ minLength: 1 }), +}); export type Env = Static & { PLUGIN_CHAIN_STATE: KVNamespace; @@ -11,8 +15,8 @@ declare global { namespace NodeJS { interface ProcessEnv { APP_ID: string; - WEBHOOK_SECRET: string; - PRIVATE_KEY: string; + WEBHOOK_SECRET: string | undefined; + APP_PRIVATE_KEY: string; } } } diff --git a/src/worker.ts b/src/worker.ts index 2fc7a63..6f6e4ec 100644 --- a/src/worker.ts +++ b/src/worker.ts @@ -16,7 +16,7 @@ export default { const eventHandler = new GitHubEventHandler({ webhookSecret: env.WEBHOOK_SECRET, appId: env.APP_ID, - privateKey: env.PRIVATE_KEY, + privateKey: env.APP_PRIVATE_KEY, pluginChainState: new CloudflareKv(env.PLUGIN_CHAIN_STATE), }); bindHandlers(eventHandler); diff --git a/tests/main.test.ts b/tests/main.test.ts index 63365fb..b49a6e0 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -33,7 +33,7 @@ describe("Worker tests", () => { const res = await worker.fetch(req, { WEBHOOK_SECRET: "", APP_ID: "", - PRIVATE_KEY: "", + APP_PRIVATE_KEY: "", PLUGIN_CHAIN_STATE: {} as KVNamespace, }); expect(res.status).toEqual(500); @@ -51,7 +51,7 @@ describe("Worker tests", () => { const res = await worker.fetch(req, { WEBHOOK_SECRET: "webhook-secret", APP_ID: "app-id", - PRIVATE_KEY: "private-key", + APP_PRIVATE_KEY: "private-key", PLUGIN_CHAIN_STATE: {} as KVNamespace, }); expect(res.status).toEqual(200); From 94c49b39d798e29eb40f3b52afdbea9df0da3293 Mon Sep 17 00:00:00 2001 From: Mentlegen <9807008+gentlementlegen@users.noreply.github.com> Date: Tue, 9 Jul 2024 08:23:08 +0900 Subject: [PATCH 02/12] chore: set default to WEBHOOK_SECRET --- .github/workflows/build.yml | 4 ++-- .github/workflows/bun-testing.yml | 2 +- src/github/types/env.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4c70441..503f3de 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,7 +34,7 @@ jobs: - uses: cloudflare/wrangler-action@v3 with: - wranglerVersion: "3.57.0" + wranglerVersion: "3.63.1" apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} secrets: | @@ -42,6 +42,6 @@ jobs: APP_ID APP_PRIVATE_KEY env: - WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }} + WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET || '' }} APP_ID: ${{ secrets.APP_ID }} APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }} diff --git a/.github/workflows/bun-testing.yml b/.github/workflows/bun-testing.yml index b3a27e3..f2b444f 100644 --- a/.github/workflows/bun-testing.yml +++ b/.github/workflows/bun-testing.yml @@ -6,7 +6,7 @@ on: env: NODE_ENV: "test" - WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }} + WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET || '' }} APP_ID: ${{ secrets.APP_ID }} APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }} diff --git a/src/github/types/env.ts b/src/github/types/env.ts index ecc8e7f..65201cb 100644 --- a/src/github/types/env.ts +++ b/src/github/types/env.ts @@ -1,7 +1,7 @@ import { Type as T, type Static } from "@sinclair/typebox"; export const envSchema = T.Object({ - WEBHOOK_SECRET: T.Optional(T.String({ minLength: 1 })), + WEBHOOK_SECRET: T.String({ minLength: 1 }), APP_ID: T.String({ minLength: 1 }), APP_PRIVATE_KEY: T.String({ minLength: 1 }), }); @@ -15,7 +15,7 @@ declare global { namespace NodeJS { interface ProcessEnv { APP_ID: string; - WEBHOOK_SECRET: string | undefined; + WEBHOOK_SECRET: string; APP_PRIVATE_KEY: string; } } From 131a1347008d5e511fdc3eb9f8af9cae99eae852 Mon Sep 17 00:00:00 2001 From: Mentlegen <9807008+gentlementlegen@users.noreply.github.com> Date: Tue, 9 Jul 2024 08:26:08 +0900 Subject: [PATCH 03/12] chore: set default to WEBHOOK_SECRET --- .github/workflows/build.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 503f3de..dd7d6ad 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,6 +32,9 @@ jobs: CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + - name: Set default WEBHOOK_SECRET + run: echo "WEBHOOK_SECRET=${{ secrets.WEBHOOK_SECRET || '' }}" >> $GITHUB_ENV + - uses: cloudflare/wrangler-action@v3 with: wranglerVersion: "3.63.1" @@ -42,6 +45,6 @@ jobs: APP_ID APP_PRIVATE_KEY env: - WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET || '' }} + WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }} APP_ID: ${{ secrets.APP_ID }} APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }} From 8693b777692fb584298af49bccb99d2a549ddcbb Mon Sep 17 00:00:00 2001 From: Mentlegen <9807008+gentlementlegen@users.noreply.github.com> Date: Tue, 9 Jul 2024 08:29:48 +0900 Subject: [PATCH 04/12] chore: set default to WEBHOOK_SECRET --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dd7d6ad..5423cea 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,6 +45,6 @@ jobs: APP_ID APP_PRIVATE_KEY env: - WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }} + WEBHOOK_SECRET: ${{ env.WEBHOOK_SECRET }} APP_ID: ${{ secrets.APP_ID }} APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }} From 1e384a8e4a9245cdf5f956407b98aa12b3593747 Mon Sep 17 00:00:00 2001 From: Mentlegen <9807008+gentlementlegen@users.noreply.github.com> Date: Tue, 9 Jul 2024 08:33:49 +0900 Subject: [PATCH 05/12] chore: set default to WEBHOOK_SECRET --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5423cea..6352953 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,7 +33,7 @@ jobs: CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - name: Set default WEBHOOK_SECRET - run: echo "WEBHOOK_SECRET=${{ secrets.WEBHOOK_SECRET || '' }}" >> $GITHUB_ENV + run: echo "WEBHOOK_SECRET=${{ secrets.WEBHOOK_SECRET || ' ' }}" >> $GITHUB_ENV - uses: cloudflare/wrangler-action@v3 with: From 704fcc1d376fc09e464c8898fc0d672e238cdff3 Mon Sep 17 00:00:00 2001 From: Mentlegen <9807008+gentlementlegen@users.noreply.github.com> Date: Tue, 9 Jul 2024 08:35:18 +0900 Subject: [PATCH 06/12] chore: set default to WEBHOOK_SECRET --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6352953..3d79444 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,7 +33,7 @@ jobs: CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - name: Set default WEBHOOK_SECRET - run: echo "WEBHOOK_SECRET=${{ secrets.WEBHOOK_SECRET || ' ' }}" >> $GITHUB_ENV + run: echo "WEBHOOK_SECRET=""" >> $GITHUB_ENV - uses: cloudflare/wrangler-action@v3 with: From f50c3c5f43edac67a86591d8feee5afa07140770 Mon Sep 17 00:00:00 2001 From: Mentlegen <9807008+gentlementlegen@users.noreply.github.com> Date: Tue, 9 Jul 2024 08:39:42 +0900 Subject: [PATCH 07/12] chore: set default to WEBHOOK_SECRET --- .github/workflows/build.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3d79444..f2ea2c0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,19 +32,23 @@ jobs: CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - - name: Set default WEBHOOK_SECRET - run: echo "WEBHOOK_SECRET=""" >> $GITHUB_ENV + - name: Set secrets for Wrangler + id: set-secrets + run: | + echo "secrets_list=''" >> $GITHUB_ENV + if [ ! -z "${{ secrets.WEBHOOK_SECRET }}" ]; then + echo "secrets_list='WEBHOOK_SECRET=${{ secrets.WEBHOOK_SECRET }}\n'" >> $GITHUB_ENV + fi + echo "secrets_list='\${secrets_list}APP_ID=${{ secrets.APP_ID }}\n'" >> $GITHUB_ENV + echo "secrets_list='\${secrets_list}APP_PRIVATE_KEY=${{ secrets.APP_PRIVATE_KEY }}\n'" >> $GITHUB_ENV - uses: cloudflare/wrangler-action@v3 with: wranglerVersion: "3.63.1" apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - secrets: | - WEBHOOK_SECRET - APP_ID - APP_PRIVATE_KEY + secrets: ${{ env.secrets_list }} env: - WEBHOOK_SECRET: ${{ env.WEBHOOK_SECRET }} + WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }} APP_ID: ${{ secrets.APP_ID }} APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }} From f40b309646b83a99f704a73befaa890aef4a9e5b Mon Sep 17 00:00:00 2001 From: Mentlegen <9807008+gentlementlegen@users.noreply.github.com> Date: Tue, 9 Jul 2024 08:41:44 +0900 Subject: [PATCH 08/12] chore: set default to WEBHOOK_SECRET --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f2ea2c0..ecddd55 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,10 +37,10 @@ jobs: run: | echo "secrets_list=''" >> $GITHUB_ENV if [ ! -z "${{ secrets.WEBHOOK_SECRET }}" ]; then - echo "secrets_list='WEBHOOK_SECRET=${{ secrets.WEBHOOK_SECRET }}\n'" >> $GITHUB_ENV + echo "secrets_list='WEBHOOK_SECRET\n'" >> $GITHUB_ENV fi - echo "secrets_list='\${secrets_list}APP_ID=${{ secrets.APP_ID }}\n'" >> $GITHUB_ENV - echo "secrets_list='\${secrets_list}APP_PRIVATE_KEY=${{ secrets.APP_PRIVATE_KEY }}\n'" >> $GITHUB_ENV + echo "secrets_list='\${secrets_list}APP_ID\n'" >> $GITHUB_ENV + echo "secrets_list='\${secrets_list}APP_PRIVATE_KEY\n'" >> $GITHUB_ENV - uses: cloudflare/wrangler-action@v3 with: From 0054dbbab3f0ea0ec5842f58333aa762db6dbb63 Mon Sep 17 00:00:00 2001 From: Mentlegen <9807008+gentlementlegen@users.noreply.github.com> Date: Tue, 9 Jul 2024 08:45:33 +0900 Subject: [PATCH 09/12] chore: set default to WEBHOOK_SECRET --- .github/workflows/build.yml | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ecddd55..68c2c00 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,23 +32,16 @@ jobs: CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - - name: Set secrets for Wrangler - id: set-secrets - run: | - echo "secrets_list=''" >> $GITHUB_ENV - if [ ! -z "${{ secrets.WEBHOOK_SECRET }}" ]; then - echo "secrets_list='WEBHOOK_SECRET\n'" >> $GITHUB_ENV - fi - echo "secrets_list='\${secrets_list}APP_ID\n'" >> $GITHUB_ENV - echo "secrets_list='\${secrets_list}APP_PRIVATE_KEY\n'" >> $GITHUB_ENV - - uses: cloudflare/wrangler-action@v3 with: wranglerVersion: "3.63.1" apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - secrets: ${{ env.secrets_list }} + secrets: | + APP_ID + APP_PRIVATE_KEY + WEBHOOK_SECRET env: - WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }} + WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET || ' ' }} APP_ID: ${{ secrets.APP_ID }} APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }} From 38149f8be160a4462e08cf8546deaa3df9c30234 Mon Sep 17 00:00:00 2001 From: Mentlegen <9807008+gentlementlegen@users.noreply.github.com> Date: Tue, 9 Jul 2024 08:51:24 +0900 Subject: [PATCH 10/12] chore: removed default to WEBHOOK_SECRET --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 68c2c00..cd6daf0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,6 +42,6 @@ jobs: APP_PRIVATE_KEY WEBHOOK_SECRET env: - WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET || ' ' }} + WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }} APP_ID: ${{ secrets.APP_ID }} APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }} From bed0bfd3ff30517db9b9d6a16b6bcbd9c42f4a70 Mon Sep 17 00:00:00 2001 From: Mentlegen <9807008+gentlementlegen@users.noreply.github.com> Date: Tue, 9 Jul 2024 08:55:28 +0900 Subject: [PATCH 11/12] chore: removed default to WEBHOOK_SECRET --- .github/workflows/bun-testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bun-testing.yml b/.github/workflows/bun-testing.yml index f2b444f..b3a27e3 100644 --- a/.github/workflows/bun-testing.yml +++ b/.github/workflows/bun-testing.yml @@ -6,7 +6,7 @@ on: env: NODE_ENV: "test" - WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET || '' }} + WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }} APP_ID: ${{ secrets.APP_ID }} APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }} From afc96262f402f62e6dc611142b9a02c7eac8942c Mon Sep 17 00:00:00 2001 From: Mentlegen <9807008+gentlementlegen@users.noreply.github.com> Date: Tue, 9 Jul 2024 08:56:47 +0900 Subject: [PATCH 12/12] chore: removed default to WEBHOOK_SECRET --- src/github/github-event-handler.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/github/github-event-handler.ts b/src/github/github-event-handler.ts index a51d4e5..e78985b 100644 --- a/src/github/github-event-handler.ts +++ b/src/github/github-event-handler.ts @@ -6,7 +6,7 @@ import { CloudflareKv } from "./utils/cloudflare-kv"; import { PluginChainState } from "./types/plugin"; export type Options = { - webhookSecret: string | undefined; + webhookSecret: string; appId: string | number; privateKey: string; pluginChainState: CloudflareKv; @@ -19,7 +19,7 @@ export class GitHubEventHandler { public onError: Webhooks["onError"]; public pluginChainState: CloudflareKv; - private readonly _webhookSecret: string | undefined; + private readonly _webhookSecret: string; private readonly _privateKey: string; private readonly _appId: number; @@ -30,7 +30,7 @@ export class GitHubEventHandler { this.pluginChainState = options.pluginChainState; this.webhooks = new Webhooks({ - secret: this._webhookSecret || "", + secret: this._webhookSecret, transform: (event) => this.transformEvent(event), // it is important to use an arrow function here to keep the context of `this` });