@shushed/helpers 0.0.154 → 0.0.155

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.
Files changed (2) hide show
  1. package/dist/index.js +17 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -106559,13 +106559,13 @@ var getIdentityToken = async (expectedAudience) => {
106559
106559
  if (!res.ok) {
106560
106560
  throw new Error(`metadata token http ${res.status}`);
106561
106561
  }
106562
- const json = await res.json();
106563
- if (!json.access_token) {
106562
+ const accessToken = await res.text();
106563
+ if (!accessToken) {
106564
106564
  throw new Error("missing access_token in metadata response");
106565
106565
  }
106566
- return json.access_token;
106566
+ return accessToken;
106567
106567
  } catch (err) {
106568
- throw new Error(`Failed to obtain access token. Error: ${err.message}`);
106568
+ throw new Error(`Failed to obtain identity token. Error: ${err.message}`);
106569
106569
  }
106570
106570
  };
106571
106571
 
@@ -109431,7 +109431,19 @@ var TriggerHelper = class {
109431
109431
  if (action.actionOptions.routingConditions?.api?.roles) {
109432
109432
  const apiKeyHasWildcard = matchingAPIKeysDetails.roles.includes("*");
109433
109433
  if (!apiKeyHasWildcard) {
109434
- const matchingRoles = action.actionOptions.routingConditions.api.roles.some((x) => matchingAPIKeysDetails.roles.includes(x));
109434
+ const normalizedRoles = action.actionOptions.routingConditions.api.roles.map((x) => {
109435
+ let name = x;
109436
+ if (x.indexOf("process.env.") === 0) {
109437
+ const envName = name.slice("process.env.".length);
109438
+ name = action.resolveEnvName(envName);
109439
+ if (name === envName) {
109440
+ options.logging.log(`The role ${x} is not specified in the environment variables. Ignoring it from the role check.`);
109441
+ return null;
109442
+ }
109443
+ }
109444
+ return name;
109445
+ }).filter(Boolean);
109446
+ const matchingRoles = normalizedRoles.some((x) => matchingAPIKeysDetails.roles.includes(x));
109435
109447
  if (!matchingRoles) {
109436
109448
  return optionsEnchanced.req.throw(401, `API does not allow the key due to the roles configuration`);
109437
109449
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shushed/helpers",
3
- "version": "0.0.154",
3
+ "version": "0.0.155",
4
4
  "author": "",
5
5
  "license": "UNLICENSED",
6
6
  "description": "",