@shushed/helpers 0.0.164 → 0.0.165
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 +12 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -106548,6 +106548,7 @@ var getAccessToken = async () => {
|
|
|
106548
106548
|
}
|
|
106549
106549
|
};
|
|
106550
106550
|
var getIdentityToken = async (expectedAudience) => {
|
|
106551
|
+
console.log("JDEBUG 1 IDT " + JSON.stringify(expectedAudience));
|
|
106551
106552
|
const metadataUrl = "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/identity?" + new URLSearchParams({
|
|
106552
106553
|
audience: expectedAudience,
|
|
106553
106554
|
format: "full"
|
|
@@ -106563,8 +106564,10 @@ var getIdentityToken = async (expectedAudience) => {
|
|
|
106563
106564
|
if (!accessToken) {
|
|
106564
106565
|
throw new Error("missing access_token in metadata response");
|
|
106565
106566
|
}
|
|
106567
|
+
console.log("JDEBUG 1 TOK " + JSON.stringify(accessToken));
|
|
106566
106568
|
return accessToken;
|
|
106567
106569
|
} catch (err) {
|
|
106570
|
+
console.log("JDEBUG 1 IDT ERR " + JSON.stringify(err));
|
|
106568
106571
|
throw new Error(`Failed to obtain identity token. Error: ${err.message}`);
|
|
106569
106572
|
}
|
|
106570
106573
|
};
|
|
@@ -106860,6 +106863,7 @@ var EnvEngine = class extends Runtime {
|
|
|
106860
106863
|
triggerId: audience ? audience.triggerId || this.triggerId : null
|
|
106861
106864
|
};
|
|
106862
106865
|
const expectedAudience = [process.env.GCLOUD_PROJECT, audienceNorm.workflowId, audienceNorm.triggerId].filter((x) => x !== null).join("-");
|
|
106866
|
+
console.log("JDEBUG 0 " + JSON.stringify(expectedAudience));
|
|
106863
106867
|
return this.with(`google_identity_token_${expectedAudience}`, "env", { encrypted: true, ephemeralMs: 10 * 60 * 1e3, fetch: () => getIdentityToken(expectedAudience) });
|
|
106864
106868
|
}
|
|
106865
106869
|
async checkGoogleIdentiyToken(accessToken, audience, allowedServiceAccounts = [`runtime@${process.env.GCLOUD_PROJECT}.iam.gserviceaccount.com`]) {
|
|
@@ -106962,19 +106966,23 @@ var EnvEngine = class extends Runtime {
|
|
|
106962
106966
|
}
|
|
106963
106967
|
with(key, level = "trigger", options) {
|
|
106964
106968
|
return async (fn) => {
|
|
106969
|
+
console.log("JDEBUG 2 WITH " + JSON.stringify(key));
|
|
106965
106970
|
let lastError;
|
|
106966
106971
|
let lastResult;
|
|
106967
106972
|
let valueFoundAndWorking = false;
|
|
106968
106973
|
const injectedFunction = async (value) => {
|
|
106974
|
+
console.log("JDEBUG 2 INJECTED " + JSON.stringify(value));
|
|
106969
106975
|
let nextValueFoundAndWorking = true;
|
|
106970
106976
|
const requestCacheRefresh = () => {
|
|
106971
106977
|
nextValueFoundAndWorking = false;
|
|
106972
106978
|
};
|
|
106973
106979
|
try {
|
|
106974
106980
|
const result = await fn(value, requestCacheRefresh);
|
|
106981
|
+
console.log("JDEBUG 3 EXECUTED " + JSON.stringify(result));
|
|
106975
106982
|
lastResult = result;
|
|
106976
106983
|
lastError = void 0;
|
|
106977
106984
|
} catch (err) {
|
|
106985
|
+
console.log("JDEBUG 4 ERROR " + JSON.stringify(err.message));
|
|
106978
106986
|
lastError = err;
|
|
106979
106987
|
lastResult = void 0;
|
|
106980
106988
|
requestCacheRefresh();
|
|
@@ -106992,14 +107000,17 @@ var EnvEngine = class extends Runtime {
|
|
|
106992
107000
|
const checkedStores = [];
|
|
106993
107001
|
for (let i = 0; i < stores.length; i++) {
|
|
106994
107002
|
const store = stores[i];
|
|
107003
|
+
console.log("JDEBUG 2 CHECKING " + JSON.stringify(store));
|
|
106995
107004
|
checkedStores.push(store);
|
|
106996
107005
|
const value = await this._get([key], level, { ...options, store, isEphemeral: true });
|
|
107006
|
+
console.log("JDEBUG 2 CHECKED " + JSON.stringify(store));
|
|
106997
107007
|
if (value[key].valid) {
|
|
106998
107008
|
possibleValue = Object.assign({}, value[key], {
|
|
106999
107009
|
checkedStores
|
|
107000
107010
|
});
|
|
107001
107011
|
if (await injectedFunction(value[key].value)) {
|
|
107002
107012
|
if (store === "redis") {
|
|
107013
|
+
console.log("JDEBUG 2 SET FROM redis" + JSON.stringify(value[key].value));
|
|
107003
107014
|
this.set(
|
|
107004
107015
|
[{
|
|
107005
107016
|
name: key,
|
|
@@ -107023,6 +107034,7 @@ var EnvEngine = class extends Runtime {
|
|
|
107023
107034
|
expiresAt: Date.now() + (options?.ephemeralMs || 0)
|
|
107024
107035
|
};
|
|
107025
107036
|
await injectedFunction(value);
|
|
107037
|
+
console.log("JDEBUG 2 SET TO REDIS FROM FETCH" + JSON.stringify(value));
|
|
107026
107038
|
this.set(
|
|
107027
107039
|
[{
|
|
107028
107040
|
name: key,
|