@shushed/helpers 0.0.176 → 0.0.177

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 +21 -19
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -109524,27 +109524,29 @@ var TriggerHelper = class {
109524
109524
  for (const action of this.actions) {
109525
109525
  if (action.isApplicableToRequest(message, optionsEnchanced)) {
109526
109526
  atLeastOneHandlerMatched = true;
109527
- if (!matchingAPIKeysDetails.roles.length && (action.actionOptions.routingConditions || {}).api?.havingApiKey) {
109528
- return optionsEnchanced.req.throw(401, `No roles associated to API key`);
109529
- }
109530
- if (action.actionOptions.routingConditions?.api?.roles) {
109531
- const apiKeyHasWildcard = matchingAPIKeysDetails.roles.includes("*");
109532
- if (!apiKeyHasWildcard) {
109533
- const normalizedRoles = action.actionOptions.routingConditions.api.roles.map((x) => {
109534
- let name = x;
109535
- if (x.indexOf("process.env.") === 0) {
109536
- const envName = name.slice("process.env.".length);
109537
- name = envEngine.resolveEnvName(envName);
109538
- if (name === envName) {
109539
- options.logging.log(`The role ${x} is not specified in the environment variables. Ignoring it from the role check.`);
109540
- return null;
109527
+ if (!reqIsPubSub && !reqIsRespectfulNudge && !reqIsScheduler && !reqIsCloudTask) {
109528
+ if (!matchingAPIKeysDetails.roles.length && (action.actionOptions.routingConditions || {}).api?.havingApiKey) {
109529
+ return optionsEnchanced.req.throw(401, `No roles associated to API key`);
109530
+ }
109531
+ if (action.actionOptions.routingConditions?.api?.roles) {
109532
+ const apiKeyHasWildcard = matchingAPIKeysDetails.roles.includes("*");
109533
+ if (!apiKeyHasWildcard) {
109534
+ const normalizedRoles = action.actionOptions.routingConditions.api.roles.map((x) => {
109535
+ let name = x;
109536
+ if (x.indexOf("process.env.") === 0) {
109537
+ const envName = name.slice("process.env.".length);
109538
+ name = envEngine.resolveEnvName(envName);
109539
+ if (name === envName) {
109540
+ options.logging.log(`The role ${x} is not specified in the environment variables. Ignoring it from the role check.`);
109541
+ return null;
109542
+ }
109541
109543
  }
109544
+ return name;
109545
+ }).filter(Boolean);
109546
+ const matchingRoles = normalizedRoles.some((x) => matchingAPIKeysDetails.roles.includes(x));
109547
+ if (!matchingRoles) {
109548
+ return optionsEnchanced.req.throw(401, `API does not allow the key due to the roles configuration`);
109542
109549
  }
109543
- return name;
109544
- }).filter(Boolean);
109545
- const matchingRoles = normalizedRoles.some((x) => matchingAPIKeysDetails.roles.includes(x));
109546
- if (!matchingRoles) {
109547
- return optionsEnchanced.req.throw(401, `API does not allow the key due to the roles configuration`);
109548
109550
  }
109549
109551
  }
109550
109552
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shushed/helpers",
3
- "version": "0.0.176",
3
+ "version": "0.0.177",
4
4
  "author": "",
5
5
  "license": "UNLICENSED",
6
6
  "description": "",