Skip to content

Commit

Permalink
Merge pull request ubiquity-os#115 from 0x4007/chore/rename-webhook-s…
Browse files Browse the repository at this point in the history
…ecret
  • Loading branch information
0x4007 authored Sep 26, 2024
2 parents d2c75cd + 73a5d69 commit e8249ed
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .dev.vars.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
WEBHOOK_PROXY_URL=https://smee.io/new
WEBHOOK_SECRET=xxxxxx
APP_WEBHOOK_SECRET=xxxxxx
APP_ID=123456
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ jobs:
secrets: |
APP_ID
APP_PRIVATE_KEY
WEBHOOK_SECRET
APP_WEBHOOK_SECRET
env:
WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }}
APP_WEBHOOK_SECRET: ${{ secrets.APP_WEBHOOK_SECRET }}
APP_ID: ${{ secrets.APP_ID }}
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bun-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

env:
NODE_ENV: "test"
WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }}
APP_WEBHOOK_SECRET: ${{ secrets.APP_WEBHOOK_SECRET }}
APP_ID: ${{ secrets.APP_ID }}
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}

Expand Down
192 changes: 192 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The kernel is designed to:

**Note:** Replace `YOUR_APP_PRIVATE_KEY.PEM` with the path to your actual PEM file when running the command.

- **`WEBHOOK_SECRET`**
- **`APP_WEBHOOK_SECRET`**
Set this value in both your GitHub App settings and here.

- **`APP_ID`**
Expand Down
Binary file modified bun.lockb
Binary file not shown.
4 changes: 2 additions & 2 deletions src/github/types/env.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Type as T, type Static } from "@sinclair/typebox";

export const envSchema = T.Object({
WEBHOOK_SECRET: T.String({ minLength: 1 }),
APP_WEBHOOK_SECRET: T.String({ minLength: 1 }),
APP_ID: T.String({ minLength: 1 }),
APP_PRIVATE_KEY: T.String({ minLength: 1 }),
});
Expand All @@ -15,7 +15,7 @@ declare global {
namespace NodeJS {
interface ProcessEnv {
APP_ID: string;
WEBHOOK_SECRET: string;
APP_WEBHOOK_SECRET: string;
APP_PRIVATE_KEY: string;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default {
const signatureSha256 = getSignature(request);
const id = getId(request);
const eventHandler = new GitHubEventHandler({
webhookSecret: env.WEBHOOK_SECRET,
webhookSecret: env.APP_WEBHOOK_SECRET,
appId: env.APP_ID,
privateKey: env.APP_PRIVATE_KEY,
pluginChainState: new CloudflareKv(env.PLUGIN_CHAIN_STATE),
Expand Down
4 changes: 2 additions & 2 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe("Worker tests", () => {
const req = new Request("http://localhost:8080");
const consoleSpy = jest.spyOn(console, "error").mockImplementation(() => jest.fn());
const res = await worker.fetch(req, {
WEBHOOK_SECRET: "",
APP_WEBHOOK_SECRET: "",
APP_ID: "",
APP_PRIVATE_KEY: "",
PLUGIN_CHAIN_STATE: {} as KVNamespace,
Expand All @@ -76,7 +76,7 @@ describe("Worker tests", () => {
},
});
const res = await worker.fetch(req, {
WEBHOOK_SECRET: "webhook-secret",
APP_WEBHOOK_SECRET: "webhook-secret",
APP_ID: "app-id",
APP_PRIVATE_KEY: "private-key",
PLUGIN_CHAIN_STATE: {} as KVNamespace,
Expand Down

0 comments on commit e8249ed

Please sign in to comment.