@shushed/helpers 0.0.25 → 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 +1 -10
- package/dist/index.js +4 -25
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -28827,12 +28827,6 @@ 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>;
|
|
28835
|
-
|
|
28836
28830
|
type TriggerOnExecuteOptions = {
|
|
28837
28831
|
req: {
|
|
28838
28832
|
status?: number;
|
|
@@ -28993,14 +28987,11 @@ type index_Secrets = Secrets;
|
|
|
28993
28987
|
declare const index_Secrets: typeof Secrets;
|
|
28994
28988
|
type index_TriggerOnCreateOptions = TriggerOnCreateOptions;
|
|
28995
28989
|
type index_TriggerOnExecuteOptions = TriggerOnExecuteOptions;
|
|
28996
|
-
declare const index_isCronMessage: typeof isCronMessage;
|
|
28997
|
-
declare const index_isPubSubRequest: typeof isPubSubRequest;
|
|
28998
28990
|
declare const index_sanitize: typeof sanitize;
|
|
28999
28991
|
declare const index_sanitizeToString: typeof sanitizeToString;
|
|
29000
28992
|
declare const index_validate: typeof validate;
|
|
29001
|
-
declare const index_validateGoogleAuth: typeof validateGoogleAuth;
|
|
29002
28993
|
declare namespace index {
|
|
29003
|
-
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,
|
|
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 };
|
|
29004
28995
|
}
|
|
29005
28996
|
|
|
29006
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(`
|
|
384
|
-
workflow: firestore?.doc(
|
|
385
|
-
trigger: firestore?.doc(
|
|
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,
|