Skip to content

Commit

Permalink
Merge pull request #196 from ubiquity-os/development
Browse files Browse the repository at this point in the history
Merge development into main
  • Loading branch information
rndquu authored Nov 13, 2024
2 parents 56d4935 + a65c27a commit ea685c7
Show file tree
Hide file tree
Showing 18 changed files with 16 additions and 868 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.
27 changes: 7 additions & 20 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,12 +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",
"smee-client": "2.0.1",
"ts-node": "^10.9.2",
"typebox-validators": "0.3.5",
"yaml": "2.4.5"
},
Expand Down Expand Up @@ -100,13 +86,14 @@
"lint-staged": "15.2.7",
"npm-run-all": "4.1.5",
"prettier": "3.3.3",
"smee-client": "^2.0.4",
"toml": "3.0.0",
"tomlify-j0.4": "3.0.0",
"tsup": "8.1.0",
"ts-node": "^10.9.2",
"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
22 changes: 2 additions & 20 deletions src/github/github-event-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { GitHubContext, SimplifiedContext } from "./github-context";
import { createAppAuth } from "@octokit/auth-app";
import { KvStore } from "./utils/kv-store";
import { PluginChainState } from "./types/plugin";
import { signPayload } from "@ubiquity-os/plugin-sdk/signature";

export type Options = {
environment: "production" | "development";
Expand Down Expand Up @@ -49,27 +50,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
10 changes: 5 additions & 5 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.");
}
const defaultManifest = Value.Default(manifestSchema, manifest);
return defaultManifest as Manifest;
}
145 changes: 0 additions & 145 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.

14 changes: 0 additions & 14 deletions src/sdk/context.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/sdk/index.ts

This file was deleted.

Loading

0 comments on commit ea685c7

Please sign in to comment.