@ubiquity-os/plugin-sdk 2.0.4 → 2.0.6

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.
package/dist/index.js CHANGED
@@ -106,7 +106,7 @@ function getPluginOptions(options) {
106
106
  return {
107
107
  // Important to use || and not ?? to not consider empty strings
108
108
  kernelPublicKey: options?.kernelPublicKey || KERNEL_PUBLIC_KEY,
109
- logLevel: options?.logLevel ?? import_ubiquity_os_logger.LOG_LEVEL.INFO,
109
+ logLevel: options?.logLevel || import_ubiquity_os_logger.LOG_LEVEL.INFO,
110
110
  postCommentOnError: options?.postCommentOnError ?? true,
111
111
  settingsSchema: options?.settingsSchema,
112
112
  envSchema: options?.envSchema,
@@ -304,7 +304,7 @@ function createPlugin(handler, manifest, options) {
304
304
  const body = await ctx.req.json();
305
305
  const inputSchemaErrors = [...import_value2.Value.Errors(inputSchema, body)];
306
306
  if (inputSchemaErrors.length) {
307
- console.log(inputSchemaErrors, { depth: null });
307
+ console.dir(inputSchemaErrors, { depth: null });
308
308
  throw new import_http_exception.HTTPException(400, { message: "Invalid body" });
309
309
  }
310
310
  const signature = body.signature;
@@ -317,7 +317,7 @@ function createPlugin(handler, manifest, options) {
317
317
  try {
318
318
  config2 = import_value2.Value.Decode(pluginOptions.settingsSchema, import_value2.Value.Default(pluginOptions.settingsSchema, inputs.settings));
319
319
  } catch (e) {
320
- console.log(...import_value2.Value.Errors(pluginOptions.settingsSchema, inputs.settings), { depth: null });
320
+ console.dir(...import_value2.Value.Errors(pluginOptions.settingsSchema, inputs.settings), { depth: null });
321
321
  throw e;
322
322
  }
323
323
  } else {
@@ -329,7 +329,7 @@ function createPlugin(handler, manifest, options) {
329
329
  try {
330
330
  env = import_value2.Value.Decode(pluginOptions.envSchema, import_value2.Value.Default(pluginOptions.envSchema, honoEnvironment));
331
331
  } catch (e) {
332
- console.log(...import_value2.Value.Errors(pluginOptions.envSchema, honoEnvironment), { depth: null });
332
+ console.dir(...import_value2.Value.Errors(pluginOptions.envSchema, honoEnvironment), { depth: null });
333
333
  throw e;
334
334
  }
335
335
  } else {
@@ -392,19 +392,18 @@ async function createActionsPlugin(handler, options) {
392
392
  return;
393
393
  }
394
394
  const body = github2.context.payload.inputs;
395
- const signature = body.signature;
396
- if (!pluginOptions.bypassSignatureVerification && !await verifySignature(pluginOptions.kernelPublicKey, body, signature)) {
397
- core.setFailed(`Error: Invalid signature`);
398
- return;
399
- }
400
- const inputPayload = github2.context.payload.inputs;
401
- const inputSchemaErrors = [...import_value3.Value.Errors(inputSchema, inputPayload)];
395
+ const inputSchemaErrors = [...import_value3.Value.Errors(inputSchema, body)];
402
396
  if (inputSchemaErrors.length) {
403
397
  console.dir(inputSchemaErrors, { depth: null });
404
398
  core.setFailed(`Error: Invalid inputs payload: ${inputSchemaErrors.join(",")}`);
405
399
  return;
406
400
  }
407
- const inputs = import_value3.Value.Decode(inputSchema, inputPayload);
401
+ const signature = body.signature;
402
+ if (!pluginOptions.bypassSignatureVerification && !await verifySignature(pluginOptions.kernelPublicKey, body, signature)) {
403
+ core.setFailed(`Error: Invalid signature`);
404
+ return;
405
+ }
406
+ const inputs = import_value3.Value.Decode(inputSchema, body);
408
407
  let config2;
409
408
  if (pluginOptions.settingsSchema) {
410
409
  try {
package/dist/index.mjs CHANGED
@@ -68,7 +68,7 @@ function getPluginOptions(options) {
68
68
  return {
69
69
  // Important to use || and not ?? to not consider empty strings
70
70
  kernelPublicKey: options?.kernelPublicKey || KERNEL_PUBLIC_KEY,
71
- logLevel: options?.logLevel ?? LOG_LEVEL.INFO,
71
+ logLevel: options?.logLevel || LOG_LEVEL.INFO,
72
72
  postCommentOnError: options?.postCommentOnError ?? true,
73
73
  settingsSchema: options?.settingsSchema,
74
74
  envSchema: options?.envSchema,
@@ -266,7 +266,7 @@ function createPlugin(handler, manifest, options) {
266
266
  const body = await ctx.req.json();
267
267
  const inputSchemaErrors = [...Value2.Errors(inputSchema, body)];
268
268
  if (inputSchemaErrors.length) {
269
- console.log(inputSchemaErrors, { depth: null });
269
+ console.dir(inputSchemaErrors, { depth: null });
270
270
  throw new HTTPException(400, { message: "Invalid body" });
271
271
  }
272
272
  const signature = body.signature;
@@ -279,7 +279,7 @@ function createPlugin(handler, manifest, options) {
279
279
  try {
280
280
  config2 = Value2.Decode(pluginOptions.settingsSchema, Value2.Default(pluginOptions.settingsSchema, inputs.settings));
281
281
  } catch (e) {
282
- console.log(...Value2.Errors(pluginOptions.settingsSchema, inputs.settings), { depth: null });
282
+ console.dir(...Value2.Errors(pluginOptions.settingsSchema, inputs.settings), { depth: null });
283
283
  throw e;
284
284
  }
285
285
  } else {
@@ -291,7 +291,7 @@ function createPlugin(handler, manifest, options) {
291
291
  try {
292
292
  env = Value2.Decode(pluginOptions.envSchema, Value2.Default(pluginOptions.envSchema, honoEnvironment));
293
293
  } catch (e) {
294
- console.log(...Value2.Errors(pluginOptions.envSchema, honoEnvironment), { depth: null });
294
+ console.dir(...Value2.Errors(pluginOptions.envSchema, honoEnvironment), { depth: null });
295
295
  throw e;
296
296
  }
297
297
  } else {
@@ -354,19 +354,18 @@ async function createActionsPlugin(handler, options) {
354
354
  return;
355
355
  }
356
356
  const body = github2.context.payload.inputs;
357
- const signature = body.signature;
358
- if (!pluginOptions.bypassSignatureVerification && !await verifySignature(pluginOptions.kernelPublicKey, body, signature)) {
359
- core.setFailed(`Error: Invalid signature`);
360
- return;
361
- }
362
- const inputPayload = github2.context.payload.inputs;
363
- const inputSchemaErrors = [...Value3.Errors(inputSchema, inputPayload)];
357
+ const inputSchemaErrors = [...Value3.Errors(inputSchema, body)];
364
358
  if (inputSchemaErrors.length) {
365
359
  console.dir(inputSchemaErrors, { depth: null });
366
360
  core.setFailed(`Error: Invalid inputs payload: ${inputSchemaErrors.join(",")}`);
367
361
  return;
368
362
  }
369
- const inputs = Value3.Decode(inputSchema, inputPayload);
363
+ const signature = body.signature;
364
+ if (!pluginOptions.bypassSignatureVerification && !await verifySignature(pluginOptions.kernelPublicKey, body, signature)) {
365
+ core.setFailed(`Error: Invalid signature`);
366
+ return;
367
+ }
368
+ const inputs = Value3.Decode(inputSchema, body);
370
369
  let config2;
371
370
  if (pluginOptions.settingsSchema) {
372
371
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ubiquity-os/plugin-sdk",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "description": "SDK for plugin support.",
5
5
  "author": "Ubiquity DAO",
6
6
  "license": "MIT",