Skip to content

Commit

Permalink
chore: merge
Browse files Browse the repository at this point in the history
  • Loading branch information
whilefoo committed Nov 10, 2024
2 parents fcb4078 + a65c27a commit aed0974
Show file tree
Hide file tree
Showing 18 changed files with 18 additions and 918 deletions.
19 changes: 1 addition & 18 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,5 @@ jobs:
- uses: googleapis/release-please-action@v4
id: release
with:
release-type: node
release-type: simple
target-branch: main
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20.10.0"
registry-url: https://registry.npmjs.org/

- uses: oven-sh/setup-bun@v1

- name: Build
run: |
bun install --frozen-lockfile
bun sdk:build
if: ${{ steps.release.outputs.release_created }}
- run: bun publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
if: ${{ steps.release.outputs.release_created }}
2 changes: 1 addition & 1 deletion .github/workflows/worker-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- uses: cloudflare/wrangler-action@v3
id: wrangler_deploy
with:
wranglerVersion: "3.79.0"
wranglerVersion: "3.86.0"
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
secrets: |
Expand Down
Binary file modified bun.lockb
Binary file not shown.
23 changes: 5 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@
"module": "dist/index.mjs",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.js",
"import": "./dist/index.mjs"
}
},
"files": [
"dist"
],
Expand All @@ -37,8 +30,7 @@
"knip-ci": "knip --no-exit-code --reporter json --config .github/knip.ts",
"jest:test": "jest --coverage",
"plugin:hello-world": "tsx tests/__mocks__/hello-world-plugin.ts",
"setup-kv": "bun --env-file=.dev.vars deploy/setup-kv-namespace.ts",
"sdk:build": "tsup"
"setup-kv": "bun --env-file=.dev.vars deploy/setup-kv-namespace.ts"
},
"keywords": [
"typescript",
Expand All @@ -48,12 +40,9 @@
"open-source"
],
"dependencies": {
"@actions/core": "1.10.1",
"@actions/github": "6.0.0",
"@cfworker/json-schema": "2.0.1",
"@octokit/auth-app": "7.1.0",
"@octokit/core": "6.1.2",
"@octokit/plugin-paginate-graphql": "^5.2.4",
"@octokit/plugin-paginate-rest": "11.3.3",
"@octokit/plugin-rest-endpoint-methods": "13.2.4",
"@octokit/plugin-retry": "7.1.1",
Expand All @@ -62,10 +51,9 @@
"@octokit/types": "^13.5.0",
"@octokit/webhooks": "13.3.0",
"@octokit/webhooks-types": "7.5.1",
"@sinclair/typebox": "^0.33.17",
"@ubiquity-os/ubiquity-os-logger": "^1.3.2",
"@sinclair/typebox": "^0.33.20",
"@ubiquity-os/plugin-sdk": "^1.0.11",
"dotenv": "16.4.5",
"hono": "4.4.13",
"openai": "^4.70.2",
"typebox-validators": "0.3.5",
"yaml": "2.4.5"
Expand Down Expand Up @@ -103,11 +91,10 @@
"toml": "3.0.0",
"tomlify-j0.4": "3.0.0",
"ts-node": "^10.9.2",
"tsup": "8.1.0",
"tsx": "4.16.2",
"typescript": "5.6.2",
"typescript": "5.6.3",
"typescript-eslint": "7.16.0",
"wrangler": "3.79.0"
"wrangler": "^3.86.0"
},
"lint-staged": {
"*.ts": [
Expand Down
27 changes: 5 additions & 22 deletions src/github/github-event-handler.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { EmitterWebhookEvent, Webhooks } from "@octokit/webhooks";
import { createAppAuth } from "@octokit/auth-app";
import { signPayload } from "@ubiquity-os/plugin-sdk/signature";
import OpenAI from "openai";

import { customOctokit } from "./github-client";
import { GitHubContext, SimplifiedContext } from "./github-context";
import { createAppAuth } from "@octokit/auth-app";
import { KvStore } from "./utils/kv-store";
import { PluginChainState } from "./types/plugin";
import OpenAI from "openai";

export type Options = {
environment: "production" | "development";
Expand Down Expand Up @@ -53,27 +55,8 @@ export class GitHubEventHandler {
});
}

async importRsaPrivateKey(pem: string) {
const pemContents = pem.replace("-----BEGIN PRIVATE KEY-----", "").replace("-----END PRIVATE KEY-----", "").trim();
const binaryDer = Uint8Array.from(atob(pemContents), (c) => c.charCodeAt(0));

return await crypto.subtle.importKey(
"pkcs8",
binaryDer.buffer as ArrayBuffer,
{
name: "RSASSA-PKCS1-v1_5",
hash: "SHA-256",
},
true,
["sign"]
);
}

async signPayload(payload: string) {
const data = new TextEncoder().encode(payload);
const privateKey = await this.importRsaPrivateKey(this._privateKey);
const signature = await crypto.subtle.sign("RSASSA-PKCS1-v1_5", privateKey, data);
return btoa(String.fromCharCode(...new Uint8Array(signature)));
return signPayload(payload, this._privateKey);
}

transformEvent(event: EmitterWebhookEvent) {
Expand Down
12 changes: 6 additions & 6 deletions src/github/utils/plugins.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GithubPlugin, isGithubPlugin, PluginConfiguration } from "../types/plugin-configuration";
import { EmitterWebhookEventName } from "@octokit/webhooks";
import { GitHubContext } from "../github-context";
import { Manifest, manifestSchema, manifestValidator } from "../../types/manifest";
import { Manifest, manifestSchema } from "@ubiquity-os/plugin-sdk/manifest";
import { Buffer } from "node:buffer";
import { Value } from "@sinclair/typebox/value";

Expand Down Expand Up @@ -58,13 +58,13 @@ async function fetchWorkerManifest(url: string): Promise<Manifest | null> {
}

function decodeManifest(manifest: unknown) {
const defaultManifest = Value.Default(manifestSchema, manifest);
const errors = manifestValidator.testReturningErrors(manifest as Readonly<unknown>);
if (errors !== null) {
const errors = [...Value.Errors(manifestSchema, manifest)];
if (errors.length) {
for (const error of errors) {
console.error(error);
console.dir(error, { depth: null });
}
throw new Error("Manifest is invalid.");
}
return Value.Decode(manifestSchema, defaultManifest);
const defaultManifest = Value.Default(manifestSchema, manifest);
return defaultManifest as Manifest;
}
153 changes: 0 additions & 153 deletions src/sdk/actions.ts

This file was deleted.

48 changes: 0 additions & 48 deletions src/sdk/comment.ts

This file was deleted.

13 changes: 0 additions & 13 deletions src/sdk/constants.ts

This file was deleted.

Loading

0 comments on commit aed0974

Please sign in to comment.