@shushed/helpers 0.0.24 → 0.0.26

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.d.ts CHANGED
@@ -28827,11 +28827,151 @@ declare class JWKSHelper extends Runtime {
28827
28827
  private fetchJWKS;
28828
28828
  }
28829
28829
 
28830
- declare const isPubSubRequest: (headers: Record<string, string>) => boolean;
28831
- declare const isCronMessage: (headers: Record<string, string>) => boolean;
28832
- declare const validateGoogleAuth: (opts: Opts & {
28833
- serviceAccount?: string | null;
28834
- }, headers: Record<string, string>, firestore: Firestore) => Promise<void>;
28830
+ type TriggerOnExecuteOptions = {
28831
+ req: {
28832
+ status?: number;
28833
+ body?: string;
28834
+ throw: (status: number, body: string) => void;
28835
+ };
28836
+ request: {
28837
+ headers: Record<string, string>;
28838
+ method: 'POST' | 'GET' | 'PUT' | 'PATCH';
28839
+ body: undefined;
28840
+ path: string;
28841
+ query: Record<string, string>;
28842
+ host: string;
28843
+ hostname: string;
28844
+ originalUrl: string;
28845
+ ip: string;
28846
+ ips: [];
28847
+ querystring: string;
28848
+ subdomains: Array<string>;
28849
+ secure: boolean;
28850
+ protocol: 'http' | 'https';
28851
+ params: undefined;
28852
+ };
28853
+ nodeReq: Request;
28854
+ state: Record<string, string>;
28855
+ root: {
28856
+ state: Record<string, string>;
28857
+ };
28858
+ workflowExecutionId: string;
28859
+ logging: {
28860
+ log: (...x: Array<any>) => void;
28861
+ warn: (...x: Array<any>) => void;
28862
+ error: (...x: Array<any>) => void;
28863
+ };
28864
+ terminate: (status: number, message: string) => void;
28865
+ env: {
28866
+ set: (args: {
28867
+ name: string;
28868
+ value: string;
28869
+ }[], level: 'workflow' | 'project') => Promise<void>;
28870
+ get: (name: string, level: 'workflow' | 'project') => string | null;
28871
+ triggerEnv: any;
28872
+ workflowId: string;
28873
+ };
28874
+ auth: {
28875
+ getToken: (forceRefresh: boolean) => any;
28876
+ getKey: (options: {
28877
+ ignoreMissingKey?: boolean;
28878
+ }) => any;
28879
+ };
28880
+ getBuildShipFile: (x: any) => any;
28881
+ trigger: {
28882
+ meta: {
28883
+ fileUploadLimit: boolean;
28884
+ name: string;
28885
+ description: string;
28886
+ id: string;
28887
+ payloadLimit: boolean;
28888
+ icon: {
28889
+ type: 'SVG';
28890
+ };
28891
+ };
28892
+ script: string;
28893
+ defaultValues: {
28894
+ path: string;
28895
+ inputs: string;
28896
+ };
28897
+ lifeCycleFunctions: Array<'onExecution' | 'onCreate' | 'onResponse' | 'onUpdate' | 'getData'>;
28898
+ id: string;
28899
+ _libRef: {
28900
+ integrity: string;
28901
+ libNodeRefId: string;
28902
+ libType: string;
28903
+ isDirty: boolean;
28904
+ version: string;
28905
+ src: string;
28906
+ };
28907
+ label: string;
28908
+ description: string;
28909
+ envs: Record<string, any>;
28910
+ env: any;
28911
+ };
28912
+ workflow: {
28913
+ id: string;
28914
+ };
28915
+ };
28916
+ type TriggerOnCreateOptions = {
28917
+ runtimeUrl: string;
28918
+ workflowId: string;
28919
+ auth: {
28920
+ getToken: (forceRefresh: boolean) => any;
28921
+ getKey: (options: {
28922
+ ignoreMissingKey?: boolean;
28923
+ }) => any;
28924
+ };
28925
+ trigger: {
28926
+ meta: {
28927
+ fileUploadLimit: boolean;
28928
+ name: string;
28929
+ description: string;
28930
+ id: string;
28931
+ payloadLimit: boolean;
28932
+ icon: {
28933
+ type: 'SVG';
28934
+ };
28935
+ };
28936
+ script: string;
28937
+ response: any;
28938
+ dependencies: Record<string, string>;
28939
+ type: string;
28940
+ data: any;
28941
+ config: any;
28942
+ usage: string;
28943
+ defaultValues: {
28944
+ path: string;
28945
+ inputs: string;
28946
+ };
28947
+ lifeCycleFunctions: Array<'onExecution' | 'onCreate' | 'onResponse' | 'onUpdate' | 'getData'>;
28948
+ id: string;
28949
+ _libRef: {
28950
+ integrity: string;
28951
+ libNodeRefId: string;
28952
+ libType: string;
28953
+ isDirty: boolean;
28954
+ version: string;
28955
+ src: string;
28956
+ };
28957
+ label: string;
28958
+ description: string;
28959
+ envs: Record<string, any>;
28960
+ env: any;
28961
+ };
28962
+ workflow: {
28963
+ id: string;
28964
+ };
28965
+ env: {
28966
+ set: (args: {
28967
+ name: string;
28968
+ value: string;
28969
+ }[], level: 'workflow' | 'project') => Promise<void>;
28970
+ get: (name: string, level: 'workflow' | 'project') => string | null;
28971
+ triggerEnv: any;
28972
+ workflowId: string;
28973
+ };
28974
+ };
28835
28975
 
28836
28976
  type index_EnvEngine = EnvEngine;
28837
28977
  declare const index_EnvEngine: typeof EnvEngine;
@@ -28845,14 +28985,13 @@ type index_SchedulerHelper = SchedulerHelper;
28845
28985
  declare const index_SchedulerHelper: typeof SchedulerHelper;
28846
28986
  type index_Secrets = Secrets;
28847
28987
  declare const index_Secrets: typeof Secrets;
28848
- declare const index_isCronMessage: typeof isCronMessage;
28849
- declare const index_isPubSubRequest: typeof isPubSubRequest;
28988
+ type index_TriggerOnCreateOptions = TriggerOnCreateOptions;
28989
+ type index_TriggerOnExecuteOptions = TriggerOnExecuteOptions;
28850
28990
  declare const index_sanitize: typeof sanitize;
28851
28991
  declare const index_sanitizeToString: typeof sanitizeToString;
28852
28992
  declare const index_validate: typeof validate;
28853
- declare const index_validateGoogleAuth: typeof validateGoogleAuth;
28854
28993
  declare namespace index {
28855
- export { index_EnvEngine as EnvEngine, index_JWKSHelper as JWKSHelper, index_PubSubHelper as PubSubHelper, index_Runtime as Runtime, index_SchedulerHelper as SchedulerHelper, index_Secrets as Secrets, index_isCronMessage as isCronMessage, index_isPubSubRequest as isPubSubRequest, index_sanitize as sanitize, index_sanitizeToString as sanitizeToString, index_validate as validate, index_validateGoogleAuth as validateGoogleAuth };
28994
+ export { index_EnvEngine as EnvEngine, index_JWKSHelper as JWKSHelper, index_PubSubHelper as PubSubHelper, index_Runtime as Runtime, index_SchedulerHelper as SchedulerHelper, index_Secrets as Secrets, type index_TriggerOnCreateOptions as TriggerOnCreateOptions, type index_TriggerOnExecuteOptions as TriggerOnExecuteOptions, index_sanitize as sanitize, index_sanitizeToString as sanitizeToString, index_validate as validate };
28856
28995
  }
28857
28996
 
28858
28997
  export { index as lib, index$9 as schema, index$1 as types };
package/dist/index.js CHANGED
@@ -286,12 +286,9 @@ __export(src_public_exports, {
286
286
  Runtime: () => Runtime,
287
287
  SchedulerHelper: () => scheduler_default,
288
288
  Secrets: () => secret_default,
289
- isCronMessage: () => isCronMessage,
290
- isPubSubRequest: () => isPubSubRequest,
291
289
  sanitize: () => sanitize,
292
290
  sanitizeToString: () => sanitizeToString,
293
- validate: () => validate,
294
- validateGoogleAuth: () => validateGoogleAuth
291
+ validate: () => validate
295
292
  });
296
293
 
297
294
  // src-public/validate.ts
@@ -380,9 +377,9 @@ var EnvEngine = class extends Runtime {
380
377
  constructor(opts, firestore) {
381
378
  super(opts);
382
379
  this.docRef = {
383
- env: firestore?.doc(`0/0/${this.envName}`),
384
- workflow: firestore?.doc(`${this.workflowId}/0/${this.envName}`),
385
- trigger: firestore?.doc(`${this.workflowId}/${this.triggerId}/${this.envName}`)
380
+ env: firestore?.doc(`hush-${this.envName}/0-0`),
381
+ workflow: firestore?.doc(`hush-${this.envName}/${this.workflowId}-0`),
382
+ trigger: firestore?.doc(`hush-${this.envName}/${this.workflowId}-${this.triggerId}`)
386
383
  };
387
384
  this.store = {
388
385
  env: null,
@@ -924,24 +921,6 @@ var JWKSHelper = class extends Runtime {
924
921
  }
925
922
  };
926
923
  var jwks_default = JWKSHelper;
927
-
928
- // src-public/utils.ts
929
- var isPubSubRequest = (headers) => (headers["User-Agent"] || headers["user-agent"]) === "CloudPubSub-Google" || (headers["User-Agent"] || headers["user-agent"] || "").indexOf("APIs-Google") !== -1;
930
- var isCronMessage = (headers) => (headers["User-Agent"] || headers["user-agent"]) === "Google-Cloud-Scheduler";
931
- var validateGoogleAuth = async (opts, headers, firestore) => {
932
- const token = headers.authorization?.split(" ")[1];
933
- if (!token) {
934
- throw new Error(
935
- "Missing authorization header or invalid format, needs to be in format: Bearer <IdToken>"
936
- );
937
- }
938
- try {
939
- const jwksHelper = new jwks_default(opts, firestore);
940
- await jwksHelper.validateAuthorizationHeader(token, opts.serviceAccount || null);
941
- } catch (err) {
942
- throw new Error("Invalid authorization header " + err.message);
943
- }
944
- };
945
924
  // Annotate the CommonJS export names for ESM import in node:
946
925
  0 && (module.exports = {
947
926
  lib,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shushed/helpers",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "author": "",
5
5
  "license": "UNLICENSED",
6
6
  "description": "",