@o3co/auth.policy-verifier.builtins 0.14.0 → 0.16.0

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 (85) hide show
  1. package/README.ja.md +45 -7
  2. package/README.md +47 -8
  3. package/dist/collectors/DelegationRangeCollector.d.mts +29 -0
  4. package/dist/collectors/DelegationRangeCollector.d.mts.map +1 -0
  5. package/dist/collectors/DelegationRangeCollector.mjs +29 -0
  6. package/dist/collectors/PayloadClaimAttributeCollector.d.mts +24 -39
  7. package/dist/collectors/PayloadClaimAttributeCollector.d.mts.map +1 -1
  8. package/dist/collectors/PayloadClaimAttributeCollector.mjs +26 -41
  9. package/dist/collectors/PayloadScopeCollector.d.mts +1 -1
  10. package/dist/collectors/PayloadSubjectIdCollector.d.mts +1 -1
  11. package/dist/collectors/PayloadSubjectIdCollector.mjs +1 -1
  12. package/dist/collectors/RequestContextAttributeCollector.d.mts +24 -62
  13. package/dist/collectors/RequestContextAttributeCollector.d.mts.map +1 -1
  14. package/dist/collectors/RequestContextAttributeCollector.mjs +33 -74
  15. package/dist/collectors/StaticPermissionCollector.d.mts +7 -9
  16. package/dist/collectors/StaticPermissionCollector.d.mts.map +1 -1
  17. package/dist/collectors/StaticPermissionCollector.mjs +7 -9
  18. package/dist/collectors/StaticRoleCollector.d.mts +9 -10
  19. package/dist/collectors/StaticRoleCollector.d.mts.map +1 -1
  20. package/dist/collectors/StaticRoleCollector.mjs +10 -11
  21. package/dist/collectors/_attributeMapping.d.mts +1 -0
  22. package/dist/collectors/_attributeMapping.d.mts.map +1 -1
  23. package/dist/collectors/_attributeMapping.mjs +3 -0
  24. package/dist/collectors/_claims.d.mts +2 -3
  25. package/dist/collectors/_claims.d.mts.map +1 -1
  26. package/dist/collectors/_claims.mjs +3 -4
  27. package/dist/delegation/range.d.mts +48 -0
  28. package/dist/delegation/range.d.mts.map +1 -0
  29. package/dist/delegation/range.mjs +108 -0
  30. package/dist/index.d.mts +5 -0
  31. package/dist/index.d.mts.map +1 -1
  32. package/dist/index.mjs +7 -0
  33. package/dist/keys.d.mts +9 -0
  34. package/dist/keys.d.mts.map +1 -0
  35. package/dist/keys.mjs +31 -0
  36. package/dist/module.d.mts.map +1 -1
  37. package/dist/module.mjs +4 -0
  38. package/dist/resource/DotNotationResourceParser.d.mts +16 -19
  39. package/dist/resource/DotNotationResourceParser.d.mts.map +1 -1
  40. package/dist/resource/DotNotationResourceParser.mjs +20 -25
  41. package/dist/rules/AttrLiteralCompare.d.mts +3 -5
  42. package/dist/rules/AttrLiteralCompare.d.mts.map +1 -1
  43. package/dist/rules/AttrLiteralCompare.mjs +3 -5
  44. package/dist/rules/AttrLiteralEqual.d.mts +3 -5
  45. package/dist/rules/AttrLiteralEqual.d.mts.map +1 -1
  46. package/dist/rules/AttrLiteralEqual.mjs +3 -5
  47. package/dist/rules/AttrLiteralIn.d.mts +3 -5
  48. package/dist/rules/AttrLiteralIn.d.mts.map +1 -1
  49. package/dist/rules/AttrLiteralIn.mjs +3 -5
  50. package/dist/rules/AttrLiteralNotEqual.d.mts +6 -8
  51. package/dist/rules/AttrLiteralNotEqual.d.mts.map +1 -1
  52. package/dist/rules/AttrLiteralNotEqual.mjs +6 -8
  53. package/dist/rules/AttrLiteralNotIn.d.mts +4 -6
  54. package/dist/rules/AttrLiteralNotIn.d.mts.map +1 -1
  55. package/dist/rules/AttrLiteralNotIn.mjs +4 -6
  56. package/dist/rules/AttrMatchRule.d.mts +1 -1
  57. package/dist/rules/AttrMatchRule.mjs +1 -1
  58. package/dist/rules/AttrPairCompare.d.mts +3 -5
  59. package/dist/rules/AttrPairCompare.d.mts.map +1 -1
  60. package/dist/rules/AttrPairCompare.mjs +3 -5
  61. package/dist/rules/AttrPairEqual.d.mts +6 -9
  62. package/dist/rules/AttrPairEqual.d.mts.map +1 -1
  63. package/dist/rules/AttrPairEqual.mjs +6 -9
  64. package/dist/rules/AttrPairNotEqual.d.mts +3 -5
  65. package/dist/rules/AttrPairNotEqual.d.mts.map +1 -1
  66. package/dist/rules/AttrPairNotEqual.mjs +3 -5
  67. package/dist/rules/HasPermission.d.mts +9 -10
  68. package/dist/rules/HasPermission.d.mts.map +1 -1
  69. package/dist/rules/HasPermission.mjs +16 -20
  70. package/dist/rules/HasScope.d.mts +11 -14
  71. package/dist/rules/HasScope.d.mts.map +1 -1
  72. package/dist/rules/HasScope.mjs +8 -11
  73. package/dist/rules/WithinDelegationRange.d.mts +22 -0
  74. package/dist/rules/WithinDelegationRange.d.mts.map +1 -0
  75. package/dist/rules/WithinDelegationRange.mjs +38 -0
  76. package/dist/rules/_sharedValidation.d.mts +12 -19
  77. package/dist/rules/_sharedValidation.d.mts.map +1 -1
  78. package/dist/rules/_sharedValidation.mjs +17 -25
  79. package/dist/rules/collectors/DelegationRangeRuleCollector.d.mts +36 -0
  80. package/dist/rules/collectors/DelegationRangeRuleCollector.d.mts.map +1 -0
  81. package/dist/rules/collectors/DelegationRangeRuleCollector.mjs +36 -0
  82. package/dist/rules/collectors/ResourceActionScopeRuleCollector.d.mts +19 -28
  83. package/dist/rules/collectors/ResourceActionScopeRuleCollector.d.mts.map +1 -1
  84. package/dist/rules/collectors/ResourceActionScopeRuleCollector.mjs +21 -30
  85. package/package.json +5 -5
@@ -16,7 +16,7 @@ export interface ResourceActionScopeRuleCollectorConfig {
16
16
  */
17
17
  allowBareScopeRewrite?: boolean;
18
18
  /**
19
- * The claim whose presence says the token asserted scopes (#219). Defaults
19
+ * The claim whose presence says the token asserted scopes. Defaults
20
20
  * to `scope`; set it to what `PayloadScopeCollector` reads (`scp` for Okta)
21
21
  * so the two look at the same claim — each keeps its own option, and
22
22
  * nothing checks that both were given the same name. Only presence is
@@ -32,36 +32,27 @@ export interface ResourceActionScopeRuleCollectorConfig {
32
32
  * ## Scope as capability ceiling
33
33
  *
34
34
  * The JWT `scope` claim represents what the session **can request** — a
35
- * capability ceiling — not what the session **has been granted**. Whether the
36
- * operation is ultimately permitted is determined by the full rule pipeline
37
- * (other collectors, resource-owner policy, etc.). This collector enforces the
38
- * ceiling only: it produces a `HasScope` rule for the requested
39
- * `{action}:{resourceType}`, which must be satisfied by the token's scopes.
35
+ * capability ceiling — not what the session **has been granted**; the full
36
+ * rule pipeline decides the latter. This collector enforces the ceiling only:
37
+ * it produces a `HasScope` rule for the requested `{action}:{resourceType}`,
38
+ * which the token's scopes must satisfy, compared exactly and case-sensitively.
39
+ * An issuer that emits bare resource names (`project` rather than
40
+ * `read:project`) must opt in with `{ allowBareScopeRewrite: true }`.
40
41
  *
41
- * ## Matching
42
+ * ## Scopeless tokens
42
43
  *
43
- * The emitted `HasScope` compares scopes exactly and case-sensitively. An
44
- * issuer that emits bare resource names (`project` rather than `read:project`)
45
- * must opt in with `{ allowBareScopeRewrite: true }`; without it a bare scope
46
- * satisfies nothing of the `{action}:{resourceType}` form.
44
+ * By default the rule is emitted whether or not the token carries the scope
45
+ * claim, so a scopeless token fails it. Dropping the rule instead would remove
46
+ * the scope group from AND-evaluation, and in a scope-only pipeline that turns
47
+ * "the token asserts no capability" into "every capability is allowed".
47
48
  *
48
- * ## Behavior for scopeless tokens
49
- *
50
- * By default the rule is emitted regardless of whether the token carries a
51
- * `scope` claim, so a scopeless token fails it. Dropping the rule instead would
52
- * remove the scope group from AND-evaluation, and in a scope-only pipeline that
53
- * turns "the token asserts no capability" into "every capability is allowed".
54
- *
55
- * Flows where the IdP does not issue a `scope` claim (e.g. DID-grant tokens)
56
- * must opt out explicitly with `{ scopeless: "skip" }`, and only in a pipeline
57
- * where another rule group authorizes the request — otherwise the request is
58
- * left with no applicable rule, which the evaluator denies.
59
- *
60
- * For pipelines that exclusively serve scopeless flows, prefer collectors that
61
- * derive rules from identity claims (e.g. DID, `sub`, role) instead.
62
- *
63
- * See https://github.com/o3co/auth.provider/issues/56 for background on why
64
- * the IdP asserts identity, not permissions.
49
+ * Flows where the IdP issues no scope claim (e.g. DID-grant tokens) must opt
50
+ * out explicitly with `{ scopeless: "skip" }`, and only in a pipeline where
51
+ * another granting rule group authorizes the request — otherwise the request
52
+ * is left with no applicable rule, which the evaluator denies by default and
53
+ * allows under `onEmptyRuleSet: "allow"`. A restricting rule, such as the
54
+ * delegation range, authorizes nothing. A pipeline that serves only scopeless
55
+ * flows should derive rules from identity claims (DID, `sub`, role) instead.
65
56
  */
66
57
  export declare class ResourceActionScopeRuleCollector implements RuleCollector {
67
58
  private readonly scopeless;
@@ -1 +1 @@
1
- {"version":3,"file":"ResourceActionScopeRuleCollector.d.mts","sourceRoot":"","sources":["../../../src/rules/collectors/ResourceActionScopeRuleCollector.mts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAI7F,yGAAyG;AACzG,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,CAAC;AAI9C,mEAAmE;AACnE,MAAM,WAAW,sCAAsC;IACtD;;;;OAIG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;;;;;;OAQG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,qBAAa,gCAAiC,YAAW,aAAa;IACrE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkB;IAC5C,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAU;IAChD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;gBAEnB,MAAM,CAAC,EAAE,sCAAsC;IA0BrD,OAAO,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;CAOzD"}
1
+ {"version":3,"file":"ResourceActionScopeRuleCollector.d.mts","sourceRoot":"","sources":["../../../src/rules/collectors/ResourceActionScopeRuleCollector.mts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAI7F,yGAAyG;AACzG,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,CAAC;AAI9C,mEAAmE;AACnE,MAAM,WAAW,sCAAsC;IACtD;;;;OAIG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;;;;;;OAQG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,gCAAiC,YAAW,aAAa;IACrE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkB;IAC5C,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAU;IAChD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;gBAEnB,MAAM,CAAC,EAAE,sCAAsC;IA0BrD,OAAO,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;CAOzD"}
@@ -9,36 +9,27 @@ const SCOPELESS_POLICIES = ["deny", "skip"];
9
9
  * ## Scope as capability ceiling
10
10
  *
11
11
  * The JWT `scope` claim represents what the session **can request** — a
12
- * capability ceiling — not what the session **has been granted**. Whether the
13
- * operation is ultimately permitted is determined by the full rule pipeline
14
- * (other collectors, resource-owner policy, etc.). This collector enforces the
15
- * ceiling only: it produces a `HasScope` rule for the requested
16
- * `{action}:{resourceType}`, which must be satisfied by the token's scopes.
17
- *
18
- * ## Matching
19
- *
20
- * The emitted `HasScope` compares scopes exactly and case-sensitively. An
21
- * issuer that emits bare resource names (`project` rather than `read:project`)
22
- * must opt in with `{ allowBareScopeRewrite: true }`; without it a bare scope
23
- * satisfies nothing of the `{action}:{resourceType}` form.
24
- *
25
- * ## Behavior for scopeless tokens
26
- *
27
- * By default the rule is emitted regardless of whether the token carries a
28
- * `scope` claim, so a scopeless token fails it. Dropping the rule instead would
29
- * remove the scope group from AND-evaluation, and in a scope-only pipeline that
30
- * turns "the token asserts no capability" into "every capability is allowed".
31
- *
32
- * Flows where the IdP does not issue a `scope` claim (e.g. DID-grant tokens)
33
- * must opt out explicitly with `{ scopeless: "skip" }`, and only in a pipeline
34
- * where another rule group authorizes the request — otherwise the request is
35
- * left with no applicable rule, which the evaluator denies.
36
- *
37
- * For pipelines that exclusively serve scopeless flows, prefer collectors that
38
- * derive rules from identity claims (e.g. DID, `sub`, role) instead.
39
- *
40
- * See https://github.com/o3co/auth.provider/issues/56 for background on why
41
- * the IdP asserts identity, not permissions.
12
+ * capability ceiling — not what the session **has been granted**; the full
13
+ * rule pipeline decides the latter. This collector enforces the ceiling only:
14
+ * it produces a `HasScope` rule for the requested `{action}:{resourceType}`,
15
+ * which the token's scopes must satisfy, compared exactly and case-sensitively.
16
+ * An issuer that emits bare resource names (`project` rather than
17
+ * `read:project`) must opt in with `{ allowBareScopeRewrite: true }`.
18
+ *
19
+ * ## Scopeless tokens
20
+ *
21
+ * By default the rule is emitted whether or not the token carries the scope
22
+ * claim, so a scopeless token fails it. Dropping the rule instead would remove
23
+ * the scope group from AND-evaluation, and in a scope-only pipeline that turns
24
+ * "the token asserts no capability" into "every capability is allowed".
25
+ *
26
+ * Flows where the IdP issues no scope claim (e.g. DID-grant tokens) must opt
27
+ * out explicitly with `{ scopeless: "skip" }`, and only in a pipeline where
28
+ * another granting rule group authorizes the request — otherwise the request
29
+ * is left with no applicable rule, which the evaluator denies by default and
30
+ * allows under `onEmptyRuleSet: "allow"`. A restricting rule, such as the
31
+ * delegation range, authorizes nothing. A pipeline that serves only scopeless
32
+ * flows should derive rules from identity claims (DID, `sub`, role) instead.
42
33
  */
43
34
  export class ResourceActionScopeRuleCollector {
44
35
  scopeless;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o3co/auth.policy-verifier.builtins",
3
- "version": "0.14.0",
3
+ "version": "0.16.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "engines": {
@@ -31,12 +31,12 @@
31
31
  }
32
32
  },
33
33
  "dependencies": {
34
- "@o3co/auth.policy-verifier.core": "0.14.0"
34
+ "@o3co/auth.policy-verifier.core": "0.16.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@types/node": "^26.6.2",
38
- "@vitest/coverage-v8": "^5.0.1",
39
- "vitest": "^5.0.1"
37
+ "@types/node": "^26.6.3",
38
+ "@vitest/coverage-v8": "^5.0.2",
39
+ "vitest": "^5.0.2"
40
40
  },
41
41
  "scripts": {
42
42
  "prebuild": "rimraf dist",