@nxgt/shared-graphql 1.4.1 → 1.4.2

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.
@@ -7,7 +7,7 @@ import {
7
7
  import { zDecision } from "stx-sdk/auth";
8
8
  async function evaluateFromRules(rules, input) {
9
9
  const policy = compilePolicy(rules);
10
- const result = input.type === "rest" ? await evaluateRest(policy, input) : evaluateGraphql(policy, input);
10
+ const result = input.type === "rest" ? await evaluateRest(policy, input) : await evaluateGraphql(policy, input);
11
11
  return {
12
12
  decision: result.decision === "ALLOW" ? zDecision.enum.ALLOW : result.decision === "DENY" ? zDecision.enum.DENY : zDecision.enum.NOT_APPLICABLE,
13
13
  reason: result.reason
@@ -24,5 +24,5 @@ export {
24
24
  PolicyEvaluationService
25
25
  };
26
26
 
27
- //# debugId=0D01B626C899866764756E2164756E21
27
+ //# debugId=16E293F2064765FC64756E2164756E21
28
28
  //# sourceMappingURL=index.js.map
@@ -2,10 +2,10 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/security/policies/exaluation.utils.ts", "../src/security/policies/evaluation.service.ts"],
4
4
  "sourcesContent": [
5
- "import {\n\tcompilePolicy,\n\tevaluateGraphql,\n\tevaluateRest,\n\ttype GraphqlEvaluateInput,\n\ttype RestEvaluateInput,\n\ttype Rules,\n} from '@nxgt/security/policy';\nimport { zDecision } from 'stx-sdk/auth';\nimport type { EvaluateResponse } from './policy.types';\n\nexport async function evaluateFromRules(\n\trules: Rules,\n\tinput: RestEvaluateInput | GraphqlEvaluateInput,\n): Promise<EvaluateResponse> {\n\t// `@nxgt/security`'s evaluators take a compiled policy — the rules with\n\t// their path patterns and expressions already built — where the copy this\n\t// replaced took the raw document and compiled on every request.\n\tconst policy = compilePolicy(rules);\n\t// `evaluateRest` is async since @nxgt/security 2.0.0 — a rule may carry a\n\t// Keto term, which is a remote question. This dry-run path supplies no\n\t// permission evaluator, so a rules document that carries one throws here\n\t// rather than being reported as an allow.\n\tconst result =\n\t\tinput.type === 'rest'\n\t\t\t? await evaluateRest(policy, input)\n\t\t\t: evaluateGraphql(policy, input);\n\n\treturn {\n\t\tdecision:\n\t\t\tresult.decision === 'ALLOW'\n\t\t\t\t? zDecision.enum.ALLOW\n\t\t\t\t: result.decision === 'DENY'\n\t\t\t\t\t? zDecision.enum.DENY\n\t\t\t\t\t: zDecision.enum.NOT_APPLICABLE,\n\t\treason: result.reason,\n\t};\n}\n",
5
+ "import {\n\tcompilePolicy,\n\tevaluateGraphql,\n\tevaluateRest,\n\ttype GraphqlEvaluateInput,\n\ttype RestEvaluateInput,\n\ttype Rules,\n} from '@nxgt/security/policy';\nimport { zDecision } from 'stx-sdk/auth';\nimport type { EvaluateResponse } from './policy.types';\n\nexport async function evaluateFromRules(\n\trules: Rules,\n\tinput: RestEvaluateInput | GraphqlEvaluateInput,\n): Promise<EvaluateResponse> {\n\t// `@nxgt/security`'s evaluators take a compiled policy — the rules with\n\t// their path patterns and expressions already built — where the copy this\n\t// replaced took the raw document and compiled on every request.\n\tconst policy = compilePolicy(rules);\n\t// Both evaluators are async since @nxgt/security 3.0.0 — a rule may carry a\n\t// Keto term, which is a remote question. This dry-run path supplies no\n\t// permission evaluator, so a rules document that carries one throws here\n\t// rather than being reported as an allow.\n\tconst result =\n\t\tinput.type === 'rest'\n\t\t\t? await evaluateRest(policy, input)\n\t\t\t: await evaluateGraphql(policy, input);\n\n\treturn {\n\t\tdecision:\n\t\t\tresult.decision === 'ALLOW'\n\t\t\t\t? zDecision.enum.ALLOW\n\t\t\t\t: result.decision === 'DENY'\n\t\t\t\t\t? zDecision.enum.DENY\n\t\t\t\t\t: zDecision.enum.NOT_APPLICABLE,\n\t\treason: result.reason,\n\t};\n}\n",
6
6
  "import type {\n\tGraphqlEvaluateInput,\n\tRestEvaluateInput,\n\tRules,\n} from '@nxgt/security/policy';\nimport { evaluateFromRules } from './exaluation.utils';\nimport type { EvaluateResponse } from './policy.types';\n\nexport class PolicyEvaluationService {\n\t/**\n\t * Evaluate a REST or GraphQL request against the static `rules.yaml`.\n\t */\n\tasync evaluateFromRules(\n\t\trules: Rules,\n\t\tinput: RestEvaluateInput | GraphqlEvaluateInput,\n\t): Promise<EvaluateResponse> {\n\t\treturn evaluateFromRules(rules, input);\n\t}\n}\n"
7
7
  ],
8
- "mappings": ";AAAA;AAAA;AAAA;AAAA;AAAA;AAQA;AAGA,eAAsB,iBAAiB,CACtC,OACA,OAC4B;AAAA,EAI5B,MAAM,SAAS,cAAc,KAAK;AAAA,EAKlC,MAAM,SACL,MAAM,SAAS,SACZ,MAAM,aAAa,QAAQ,KAAK,IAChC,gBAAgB,QAAQ,KAAK;AAAA,EAEjC,OAAO;AAAA,IACN,UACC,OAAO,aAAa,UACjB,UAAU,KAAK,QACf,OAAO,aAAa,SACnB,UAAU,KAAK,OACf,UAAU,KAAK;AAAA,IACpB,QAAQ,OAAO;AAAA,EAChB;AAAA;;;AC5BM,MAAM,wBAAwB;AAAA,OAI9B,kBAAiB,CACtB,OACA,OAC4B;AAAA,IAC5B,OAAO,kBAAkB,OAAO,KAAK;AAAA;AAEvC;",
9
- "debugId": "0D01B626C899866764756E2164756E21",
8
+ "mappings": ";AAAA;AAAA;AAAA;AAAA;AAAA;AAQA;AAGA,eAAsB,iBAAiB,CACtC,OACA,OAC4B;AAAA,EAI5B,MAAM,SAAS,cAAc,KAAK;AAAA,EAKlC,MAAM,SACL,MAAM,SAAS,SACZ,MAAM,aAAa,QAAQ,KAAK,IAChC,MAAM,gBAAgB,QAAQ,KAAK;AAAA,EAEvC,OAAO;AAAA,IACN,UACC,OAAO,aAAa,UACjB,UAAU,KAAK,QACf,OAAO,aAAa,SACnB,UAAU,KAAK,OACf,UAAU,KAAK;AAAA,IACpB,QAAQ,OAAO;AAAA,EAChB;AAAA;;;AC5BM,MAAM,wBAAwB;AAAA,OAI9B,kBAAiB,CACtB,OACA,OAC4B;AAAA,IAC5B,OAAO,kBAAkB,OAAO,KAAK;AAAA;AAEvC;",
9
+ "debugId": "16E293F2064765FC64756E2164756E21",
10
10
  "names": []
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxgt/shared-graphql",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "license": "UNLICENSED",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",