@ubiquity-os/plugin-sdk 1.0.10 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/octokit.ts
21
+ var octokit_exports = {};
22
+ __export(octokit_exports, {
23
+ customOctokit: () => customOctokit
24
+ });
25
+ module.exports = __toCommonJS(octokit_exports);
26
+ var import_core = require("@octokit/core");
27
+ var import_plugin_paginate_rest = require("@octokit/plugin-paginate-rest");
28
+ var import_plugin_rest_endpoint_methods = require("@octokit/plugin-rest-endpoint-methods");
29
+ var import_plugin_retry = require("@octokit/plugin-retry");
30
+ var import_plugin_throttling = require("@octokit/plugin-throttling");
31
+ var import_plugin_paginate_graphql = require("@octokit/plugin-paginate-graphql");
32
+ var defaultOptions = {
33
+ throttle: {
34
+ onAbuseLimit: (retryAfter, options, octokit) => {
35
+ octokit.log.warn(`Abuse limit hit with "${options.method} ${options.url}", retrying in ${retryAfter} seconds.`);
36
+ return true;
37
+ },
38
+ onRateLimit: (retryAfter, options, octokit) => {
39
+ octokit.log.warn(`Rate limit hit with "${options.method} ${options.url}", retrying in ${retryAfter} seconds.`);
40
+ return true;
41
+ },
42
+ onSecondaryRateLimit: (retryAfter, options, octokit) => {
43
+ octokit.log.warn(`Secondary rate limit hit with "${options.method} ${options.url}", retrying in ${retryAfter} seconds.`);
44
+ return true;
45
+ }
46
+ }
47
+ };
48
+ var customOctokit = import_core.Octokit.plugin(import_plugin_throttling.throttling, import_plugin_retry.retry, import_plugin_paginate_rest.paginateRest, import_plugin_rest_endpoint_methods.restEndpointMethods, import_plugin_paginate_graphql.paginateGraphQL).defaults((instanceOptions) => {
49
+ return { ...defaultOptions, ...instanceOptions };
50
+ });
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ customOctokit
54
+ });
@@ -0,0 +1,29 @@
1
+ // src/octokit.ts
2
+ import { Octokit } from "@octokit/core";
3
+ import { paginateRest } from "@octokit/plugin-paginate-rest";
4
+ import { restEndpointMethods } from "@octokit/plugin-rest-endpoint-methods";
5
+ import { retry } from "@octokit/plugin-retry";
6
+ import { throttling } from "@octokit/plugin-throttling";
7
+ import { paginateGraphQL } from "@octokit/plugin-paginate-graphql";
8
+ var defaultOptions = {
9
+ throttle: {
10
+ onAbuseLimit: (retryAfter, options, octokit) => {
11
+ octokit.log.warn(`Abuse limit hit with "${options.method} ${options.url}", retrying in ${retryAfter} seconds.`);
12
+ return true;
13
+ },
14
+ onRateLimit: (retryAfter, options, octokit) => {
15
+ octokit.log.warn(`Rate limit hit with "${options.method} ${options.url}", retrying in ${retryAfter} seconds.`);
16
+ return true;
17
+ },
18
+ onSecondaryRateLimit: (retryAfter, options, octokit) => {
19
+ octokit.log.warn(`Secondary rate limit hit with "${options.method} ${options.url}", retrying in ${retryAfter} seconds.`);
20
+ return true;
21
+ }
22
+ }
23
+ };
24
+ var customOctokit = Octokit.plugin(throttling, retry, paginateRest, restEndpointMethods, paginateGraphQL).defaults((instanceOptions) => {
25
+ return { ...defaultOptions, ...instanceOptions };
26
+ });
27
+ export {
28
+ customOctokit
29
+ };
@@ -5,6 +5,7 @@ interface Inputs {
5
5
  authToken: unknown;
6
6
  settings: unknown;
7
7
  ref: unknown;
8
+ command: unknown;
8
9
  }
9
10
  declare function verifySignature(publicKeyPem: string, inputs: Inputs, signature: string): Promise<boolean>;
10
11
  declare function signPayload(payload: string, privateKey: string): Promise<string>;
@@ -5,6 +5,7 @@ interface Inputs {
5
5
  authToken: unknown;
6
6
  settings: unknown;
7
7
  ref: unknown;
8
+ command: unknown;
8
9
  }
9
10
  declare function verifySignature(publicKeyPem: string, inputs: Inputs, signature: string): Promise<boolean>;
10
11
  declare function signPayload(payload: string, privateKey: string): Promise<string>;
package/dist/signature.js CHANGED
@@ -1,4 +1,29 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
1
20
  // src/signature.ts
21
+ var signature_exports = {};
22
+ __export(signature_exports, {
23
+ signPayload: () => signPayload,
24
+ verifySignature: () => verifySignature
25
+ });
26
+ module.exports = __toCommonJS(signature_exports);
2
27
  async function verifySignature(publicKeyPem, inputs, signature) {
3
28
  try {
4
29
  const inputsOrdered = {
@@ -7,7 +32,8 @@ async function verifySignature(publicKeyPem, inputs, signature) {
7
32
  eventPayload: inputs.eventPayload,
8
33
  settings: inputs.settings,
9
34
  authToken: inputs.authToken,
10
- ref: inputs.ref
35
+ ref: inputs.ref,
36
+ command: inputs.command
11
37
  };
12
38
  const pemContents = publicKeyPem.replace("-----BEGIN PUBLIC KEY-----", "").replace("-----END PUBLIC KEY-----", "").trim();
13
39
  const binaryDer = Uint8Array.from(atob(pemContents), (c) => c.charCodeAt(0));
@@ -49,7 +75,8 @@ async function signPayload(payload, privateKey) {
49
75
  const signature = await crypto.subtle.sign("RSASSA-PKCS1-v1_5", _privateKey, data);
50
76
  return btoa(String.fromCharCode(...new Uint8Array(signature)));
51
77
  }
52
- export {
78
+ // Annotate the CommonJS export names for ESM import in node:
79
+ 0 && (module.exports = {
53
80
  signPayload,
54
81
  verifySignature
55
- };
82
+ });
@@ -1,29 +1,4 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
1
  // src/signature.ts
21
- var signature_exports = {};
22
- __export(signature_exports, {
23
- signPayload: () => signPayload,
24
- verifySignature: () => verifySignature
25
- });
26
- module.exports = __toCommonJS(signature_exports);
27
2
  async function verifySignature(publicKeyPem, inputs, signature) {
28
3
  try {
29
4
  const inputsOrdered = {
@@ -32,7 +7,8 @@ async function verifySignature(publicKeyPem, inputs, signature) {
32
7
  eventPayload: inputs.eventPayload,
33
8
  settings: inputs.settings,
34
9
  authToken: inputs.authToken,
35
- ref: inputs.ref
10
+ ref: inputs.ref,
11
+ command: inputs.command
36
12
  };
37
13
  const pemContents = publicKeyPem.replace("-----BEGIN PUBLIC KEY-----", "").replace("-----END PUBLIC KEY-----", "").trim();
38
14
  const binaryDer = Uint8Array.from(atob(pemContents), (c) => c.charCodeAt(0));
@@ -74,8 +50,7 @@ async function signPayload(payload, privateKey) {
74
50
  const signature = await crypto.subtle.sign("RSASSA-PKCS1-v1_5", _privateKey, data);
75
51
  return btoa(String.fromCharCode(...new Uint8Array(signature)));
76
52
  }
77
- // Annotate the CommonJS export names for ESM import in node:
78
- 0 && (module.exports = {
53
+ export {
79
54
  signPayload,
80
55
  verifySignature
81
- });
56
+ };
package/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "@ubiquity-os/plugin-sdk",
3
- "version": "1.0.10",
3
+ "version": "1.1.0",
4
4
  "description": "SDK for plugin support.",
5
5
  "author": "Ubiquity DAO",
6
6
  "license": "MIT",
7
7
  "engines": {
8
8
  "node": ">=20.10.0"
9
9
  },
10
- "type": "module",
11
10
  "module": "dist/index.mjs",
12
11
  "main": "dist/index.js",
13
12
  "typings": "dist/index.d.ts",
@@ -22,6 +21,9 @@
22
21
  ],
23
22
  "signature": [
24
23
  "dist/signature.d.ts"
24
+ ],
25
+ "octokit": [
26
+ "dist/octokit.d.ts"
25
27
  ]
26
28
  }
27
29
  },
@@ -45,6 +47,11 @@
45
47
  "types": "./dist/signature.d.ts",
46
48
  "import": "./dist/signature.mjs",
47
49
  "require": "./dist/signature.js"
50
+ },
51
+ "./octokit": {
52
+ "types": "./dist/octokit.d.ts",
53
+ "import": "./dist/octokit.mjs",
54
+ "require": "./dist/octokit.js"
48
55
  }
49
56
  },
50
57
  "files": [
@@ -80,11 +87,13 @@
80
87
  "@octokit/rest": "^21.0.2",
81
88
  "@octokit/types": "^13.6.1",
82
89
  "@octokit/webhooks": "^13.3.0",
83
- "@sinclair/typebox": "^0.33.21",
84
90
  "@ubiquity-os/ubiquity-os-logger": "^1.3.2",
85
91
  "dotenv": "^16.4.5",
86
92
  "hono": "^4.6.9"
87
93
  },
94
+ "peerDependencies": {
95
+ "@sinclair/typebox": "0.34.3"
96
+ },
88
97
  "devDependencies": {
89
98
  "@commitlint/cli": "^18.6.1",
90
99
  "@commitlint/config-conventional": "^18.6.2",
@@ -1,58 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/constants.ts
21
- var constants_exports = {};
22
- __export(constants_exports, {
23
- BOT_USER_ID: () => BOT_USER_ID,
24
- CONFIG_FULL_PATH: () => CONFIG_FULL_PATH,
25
- CONFIG_ORG_REPO: () => CONFIG_ORG_REPO,
26
- DEV_CONFIG_FULL_PATH: () => DEV_CONFIG_FULL_PATH,
27
- KERNEL_APP_ID: () => KERNEL_APP_ID,
28
- KERNEL_PUBLIC_KEY: () => KERNEL_PUBLIC_KEY
29
- });
30
- module.exports = __toCommonJS(constants_exports);
31
-
32
- // src/types/config.ts
33
- var CONFIG_FULL_PATH = ".github/.ubiquity-os.config.yml";
34
- var DEV_CONFIG_FULL_PATH = ".github/.ubiquity-os.config.dev.yml";
35
- var CONFIG_ORG_REPO = ".ubiquity-os";
36
-
37
- // src/constants.ts
38
- var KERNEL_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
39
- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs96DOU+JqM8SyNXOB6u3
40
- uBKIFiyrcST/LZTYN6y7LeJlyCuGPqSDrWCfjU9Ph5PLf9TWiNmeM8DGaOpwEFC7
41
- U3NRxOSglo4plnQ5zRwIHHXvxyK400sQP2oISXymISuBQWjEIqkC9DybQrKwNzf+
42
- I0JHWPqmwMIw26UvVOtXGOOWBqTkk+N2+/9f8eDIJP5QQVwwszc8s1rXOsLMlVIf
43
- wShw7GO4E2jyK8TSJKpyjV8eb1JJMDwFhPiRrtZfQJUtDf2mV/67shQww61BH2Y/
44
- Plnalo58kWIbkqZoq1yJrL5sFb73osM5+vADTXVn79bkvea7W19nSkdMiarYt4Hq
45
- JQIDAQAB
46
- -----END PUBLIC KEY-----
47
- `;
48
- var KERNEL_APP_ID = 975031;
49
- var BOT_USER_ID = 178941584;
50
- // Annotate the CommonJS export names for ESM import in node:
51
- 0 && (module.exports = {
52
- BOT_USER_ID,
53
- CONFIG_FULL_PATH,
54
- CONFIG_ORG_REPO,
55
- DEV_CONFIG_FULL_PATH,
56
- KERNEL_APP_ID,
57
- KERNEL_PUBLIC_KEY
58
- });
package/dist/index.d.cts DELETED
@@ -1,57 +0,0 @@
1
- import * as hono_types from 'hono/types';
2
- import { EmitterWebhookEventName, EmitterWebhookEvent } from '@octokit/webhooks';
3
- import { TAnySchema } from '@sinclair/typebox';
4
- import { Logs, LogLevel, LogReturn } from '@ubiquity-os/ubiquity-os-logger';
5
- import { Hono } from 'hono';
6
- import * as _octokit_core_dist_types_types from '@octokit/core/dist-types/types';
7
- import * as _octokit_plugin_paginate_graphql from '@octokit/plugin-paginate-graphql';
8
- import * as _octokit_plugin_rest_endpoint_methods from '@octokit/plugin-rest-endpoint-methods';
9
- import * as _octokit_plugin_paginate_rest from '@octokit/plugin-paginate-rest';
10
- import * as _octokit_request_error from '@octokit/request-error';
11
- import { Octokit } from '@octokit/core';
12
- import { Manifest } from './manifest.cjs';
13
-
14
- declare const customOctokit: typeof Octokit & _octokit_core_dist_types_types.Constructor<{
15
- retry: {
16
- retryRequest: (error: _octokit_request_error.RequestError, retries: number, retryAfter: number) => _octokit_request_error.RequestError;
17
- };
18
- } & {
19
- paginate: _octokit_plugin_paginate_rest.PaginateInterface;
20
- } & _octokit_plugin_rest_endpoint_methods.Api & _octokit_plugin_paginate_graphql.paginateGraphQLInterface>;
21
-
22
- interface Context<TConfig = unknown, TEnv = unknown, TSupportedEvents extends EmitterWebhookEventName = EmitterWebhookEventName> {
23
- eventName: TSupportedEvents;
24
- payload: {
25
- [K in TSupportedEvents]: K extends EmitterWebhookEventName ? EmitterWebhookEvent<K> : never;
26
- }[TSupportedEvents]["payload"];
27
- octokit: InstanceType<typeof customOctokit>;
28
- config: TConfig;
29
- env: TEnv;
30
- logger: Logs;
31
- }
32
-
33
- interface Options$1 {
34
- kernelPublicKey?: string;
35
- logLevel?: LogLevel;
36
- postCommentOnError?: boolean;
37
- settingsSchema?: TAnySchema;
38
- envSchema?: TAnySchema;
39
- bypassSignatureVerification?: boolean;
40
- }
41
- declare function createPlugin<TConfig = unknown, TEnv = unknown, TSupportedEvents extends EmitterWebhookEventName = EmitterWebhookEventName>(handler: (context: Context<TConfig, TEnv, TSupportedEvents>) => Promise<Record<string, unknown> | undefined>, manifest: Manifest, options?: Options$1): Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/">;
42
-
43
- interface Options {
44
- logLevel?: LogLevel;
45
- postCommentOnError?: boolean;
46
- settingsSchema?: TAnySchema;
47
- envSchema?: TAnySchema;
48
- kernelPublicKey?: string;
49
- }
50
- declare function createActionsPlugin<TConfig = unknown, TEnv = unknown, TSupportedEvents extends EmitterWebhookEventName = EmitterWebhookEventName>(handler: (context: Context<TConfig, TEnv, TSupportedEvents>) => Promise<Record<string, unknown> | undefined>, options?: Options): Promise<void>;
51
-
52
- /**
53
- * Posts a comment on a GitHub issue if the issue exists in the context payload, embedding structured metadata to it.
54
- */
55
- declare function postComment(context: Context, message: LogReturn): Promise<void>;
56
-
57
- export { type Context, createActionsPlugin, createPlugin, postComment };
package/dist/manifest.cjs DELETED
@@ -1,47 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/types/manifest.ts
21
- var manifest_exports = {};
22
- __export(manifest_exports, {
23
- commandSchema: () => commandSchema,
24
- manifestSchema: () => manifestSchema,
25
- runEvent: () => runEvent
26
- });
27
- module.exports = __toCommonJS(manifest_exports);
28
- var import_typebox = require("@sinclair/typebox");
29
- var import_webhooks = require("@octokit/webhooks");
30
- var runEvent = import_typebox.Type.Union(import_webhooks.emitterEventNames.map((o) => import_typebox.Type.Literal(o)));
31
- var commandSchema = import_typebox.Type.Object({
32
- description: import_typebox.Type.String({ minLength: 1 }),
33
- "ubiquity:example": import_typebox.Type.String({ minLength: 1 })
34
- });
35
- var manifestSchema = import_typebox.Type.Object({
36
- name: import_typebox.Type.String({ minLength: 1 }),
37
- description: import_typebox.Type.Optional(import_typebox.Type.String({ default: "" })),
38
- commands: import_typebox.Type.Optional(import_typebox.Type.Record(import_typebox.Type.String(), commandSchema, { default: {} })),
39
- "ubiquity:listeners": import_typebox.Type.Optional(import_typebox.Type.Array(runEvent, { default: [] })),
40
- configuration: import_typebox.Type.Optional(import_typebox.Type.Record(import_typebox.Type.String(), import_typebox.Type.Any(), { default: {} }))
41
- });
42
- // Annotate the CommonJS export names for ESM import in node:
43
- 0 && (module.exports = {
44
- commandSchema,
45
- manifestSchema,
46
- runEvent
47
- });
File without changes