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