@venizia/ignis 0.2.0-5 → 0.2.0-7

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 (72) hide show
  1. package/dist/components/auth/authenticate/services/service/verifier.service.d.ts.map +1 -1
  2. package/dist/components/auth/authenticate/services/service/verifier.service.js +10 -6
  3. package/dist/components/auth/authenticate/services/service/verifier.service.js.map +1 -1
  4. package/dist/components/auth/authorize/adapters/base-filtered.d.ts.map +1 -1
  5. package/dist/components/auth/authorize/adapters/base-filtered.js +5 -8
  6. package/dist/components/auth/authorize/adapters/base-filtered.js.map +1 -1
  7. package/dist/components/auth/authorize/adapters/connector.d.ts +10 -0
  8. package/dist/components/auth/authorize/adapters/connector.d.ts.map +1 -0
  9. package/dist/components/auth/authorize/adapters/connector.js +20 -0
  10. package/dist/components/auth/authorize/adapters/connector.js.map +1 -0
  11. package/dist/components/auth/authorize/adapters/custom-grant-expander.d.ts +52 -0
  12. package/dist/components/auth/authorize/adapters/custom-grant-expander.d.ts.map +1 -0
  13. package/dist/components/auth/authorize/adapters/custom-grant-expander.js +111 -0
  14. package/dist/components/auth/authorize/adapters/custom-grant-expander.js.map +1 -0
  15. package/dist/components/auth/authorize/adapters/index.d.ts +2 -0
  16. package/dist/components/auth/authorize/adapters/index.d.ts.map +1 -1
  17. package/dist/components/auth/authorize/adapters/index.js +2 -0
  18. package/dist/components/auth/authorize/adapters/index.js.map +1 -1
  19. package/dist/components/auth/authorize/adapters/scoped-casbin.adapter.d.ts +53 -37
  20. package/dist/components/auth/authorize/adapters/scoped-casbin.adapter.d.ts.map +1 -1
  21. package/dist/components/auth/authorize/adapters/scoped-casbin.adapter.js +69 -76
  22. package/dist/components/auth/authorize/adapters/scoped-casbin.adapter.js.map +1 -1
  23. package/dist/components/auth/authorize/component.d.ts.map +1 -1
  24. package/dist/components/auth/authorize/component.js +3 -0
  25. package/dist/components/auth/authorize/component.js.map +1 -1
  26. package/dist/components/auth/authorize/enforcers/casbin.enforcer.d.ts +7 -36
  27. package/dist/components/auth/authorize/enforcers/casbin.enforcer.d.ts.map +1 -1
  28. package/dist/components/auth/authorize/enforcers/casbin.enforcer.js +48 -117
  29. package/dist/components/auth/authorize/enforcers/casbin.enforcer.js.map +1 -1
  30. package/dist/components/auth/authorize/enforcers/index.d.ts +2 -1
  31. package/dist/components/auth/authorize/enforcers/index.d.ts.map +1 -1
  32. package/dist/components/auth/authorize/enforcers/index.js +2 -1
  33. package/dist/components/auth/authorize/enforcers/index.js.map +1 -1
  34. package/dist/components/auth/authorize/enforcers/policy-line-codec.d.ts +26 -0
  35. package/dist/components/auth/authorize/enforcers/policy-line-codec.d.ts.map +1 -0
  36. package/dist/components/auth/authorize/enforcers/policy-line-codec.js +57 -0
  37. package/dist/components/auth/authorize/enforcers/policy-line-codec.js.map +1 -0
  38. package/dist/components/auth/authorize/enforcers/user-policy-line-cache.d.ts +46 -0
  39. package/dist/components/auth/authorize/enforcers/user-policy-line-cache.d.ts.map +1 -0
  40. package/dist/components/auth/authorize/enforcers/user-policy-line-cache.js +98 -0
  41. package/dist/components/auth/authorize/enforcers/user-policy-line-cache.js.map +1 -0
  42. package/dist/components/auth/authorize/index.d.ts +1 -0
  43. package/dist/components/auth/authorize/index.d.ts.map +1 -1
  44. package/dist/components/auth/authorize/index.js +1 -0
  45. package/dist/components/auth/authorize/index.js.map +1 -1
  46. package/dist/components/auth/authorize/role-managers/base.d.ts +34 -0
  47. package/dist/components/auth/authorize/role-managers/base.d.ts.map +1 -0
  48. package/dist/components/auth/authorize/role-managers/base.js +76 -0
  49. package/dist/components/auth/authorize/role-managers/base.js.map +1 -0
  50. package/dist/components/auth/authorize/role-managers/domain-hierarchy.d.ts +28 -0
  51. package/dist/components/auth/authorize/role-managers/domain-hierarchy.d.ts.map +1 -0
  52. package/dist/components/auth/authorize/role-managers/domain-hierarchy.js +77 -0
  53. package/dist/components/auth/authorize/role-managers/domain-hierarchy.js.map +1 -0
  54. package/dist/components/auth/authorize/role-managers/index.d.ts +5 -0
  55. package/dist/components/auth/authorize/role-managers/index.d.ts.map +1 -0
  56. package/dist/components/auth/authorize/role-managers/index.js +21 -0
  57. package/dist/components/auth/authorize/role-managers/index.js.map +1 -0
  58. package/dist/components/auth/authorize/role-managers/membership.d.ts +21 -0
  59. package/dist/components/auth/authorize/role-managers/membership.d.ts.map +1 -0
  60. package/dist/components/auth/authorize/role-managers/membership.js +69 -0
  61. package/dist/components/auth/authorize/role-managers/membership.js.map +1 -0
  62. package/dist/components/auth/authorize/{enforcers/resource-role-manager.d.ts → role-managers/resource.d.ts} +3 -9
  63. package/dist/components/auth/authorize/role-managers/resource.d.ts.map +1 -0
  64. package/dist/components/auth/authorize/{enforcers/resource-role-manager.js → role-managers/resource.js} +9 -21
  65. package/dist/components/auth/authorize/role-managers/resource.js.map +1 -0
  66. package/dist/components/auth/models/entities/policy-definition.model.d.ts +28 -14
  67. package/dist/components/auth/models/entities/policy-definition.model.d.ts.map +1 -1
  68. package/dist/components/auth/models/entities/policy-definition.model.js +18 -10
  69. package/dist/components/auth/models/entities/policy-definition.model.js.map +1 -1
  70. package/package.json +8 -8
  71. package/dist/components/auth/authorize/enforcers/resource-role-manager.d.ts.map +0 -1
  72. package/dist/components/auth/authorize/enforcers/resource-role-manager.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"verifier.service.d.ts","sourceRoot":"","sources":["../../../../../../src/components/auth/authenticate/services/service/verifier.service.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,WAAW,EAEZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAA2B,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAM1F;;;;;;;;GAQG;AACH,qBAAa,+BAAgC,SAAQ,WAAW;IAS5D,OAAO,CAAC,QAAQ,CAAC,OAAO;IAR1B,2FAA2F;IAC3F,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoC;IAE5D,oEAAoE;IACpE,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA6B;gBAIxC,OAAO,EAAE,mBAAmB;IAK/C;;;OAGG;IACG,MAAM,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAYhG;;;;OAIG;IACH,OAAO,CAAC,UAAU;IAgBlB,OAAO,CAAC,aAAa;YAyCP,SAAS;IAuDvB,OAAO,CAAC,oBAAoB;CAoB7B"}
1
+ {"version":3,"file":"verifier.service.d.ts","sourceRoot":"","sources":["../../../../../../src/components/auth/authenticate/services/service/verifier.service.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,WAAW,EAEZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAA2B,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAM1F;;;;;;;;GAQG;AACH,qBAAa,+BAAgC,SAAQ,WAAW;IAS5D,OAAO,CAAC,QAAQ,CAAC,OAAO;IAR1B,2FAA2F;IAC3F,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoC;IAE5D,oEAAoE;IACpE,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA6B;gBAIxC,OAAO,EAAE,mBAAmB;IAK/C;;;OAGG;IACG,MAAM,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAYhG;;;;OAIG;IACH,OAAO,CAAC,UAAU;IAqBlB,OAAO,CAAC,aAAa;YAyCP,SAAS;IAuDvB,OAAO,CAAC,oBAAoB;CAoB7B"}
@@ -54,18 +54,22 @@ let ServiceAssertionVerifierService = ServiceAssertionVerifierService_1 = class
54
54
  * set that will reject it.
55
55
  */
56
56
  readIssuer(opts) {
57
+ let issuer;
57
58
  try {
58
- const { iss } = (0, jose_1.decodeJwt)(opts.token);
59
- // Typed, not merely present: a numeric `iss` would index the caller map by coercion.
60
- if (typeof iss !== 'string' || iss.length === 0) {
61
- throw new Error('missing or non-string iss');
62
- }
63
- return iss;
59
+ ({ iss: issuer } = (0, jose_1.decodeJwt)(opts.token));
64
60
  }
65
61
  catch (error) {
66
62
  this.logger.for(this.readIssuer.name).warn('Undecodable assertion | error: %s', error);
67
63
  throw (0, core_1.getError)({ error: ignis_kernel_1.AuthenticationErrors.ASSERTION_INVALID });
68
64
  }
65
+ // Typed, not merely present: a numeric `iss` would index the caller map by coercion.
66
+ if (typeof issuer !== 'string' || issuer.length === 0) {
67
+ this.logger
68
+ .for(this.readIssuer.name)
69
+ .warn('Undecodable assertion | iss is missing or not a string');
70
+ throw (0, core_1.getError)({ error: ignis_kernel_1.AuthenticationErrors.ASSERTION_INVALID });
71
+ }
72
+ return issuer;
69
73
  }
70
74
  resolveKeySet(opts) {
71
75
  const { issuer } = opts;
@@ -1 +1 @@
1
- {"version":3,"file":"verifier.service.js","sourceRoot":"","sources":["../../../../../../src/components/auth/authenticate/services/service/verifier.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAAyC;AACzC,wDAK+B;AAE/B,sDAAuD;AACvD,+BAAgE;AAIhE;;;;;;;;GAQG;AACH,IAAa,+BAA+B,uCAA5C,MAAa,+BAAgC,SAAQ,0BAAW;IAO9D,YAEE,OAA6C;QAE7C,KAAK,CAAC,EAAE,KAAK,EAAE,iCAA+B,CAAC,IAAI,EAAE,CAAC,CAAC;QAFtC,YAAO,GAAP,OAAO,CAAqB;QAR/C,2FAA2F;QAC1E,YAAO,GAAG,IAAI,GAAG,EAAyB,CAAC;QAE5D,oEAAoE;QACnD,kBAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;IAO3D,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,IAAqD;QAChE,MAAM,E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AAC;YAC9D,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,iCAAiC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;YAE7F,MAAM,IAAA,eAAQ,EAAC,EAAE,KAAK,EAAE,mCAAoB,CAAC,iBAAiB,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QAClF,CAAC;IACH,CAAC;IAEO,oBAAoB,CAAC,IAI5B;QACC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QAEvC,MAAM,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAC/C,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC;QAEjD,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;YACtB,OAAO;QACT,CAAC;QAED,IAAI,CAAC,MAAM;aACR,GAAG,CAAC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC;aACnC,IAAI,CAAC,oDAAoD,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAE9E,MAAM,IAAA,eAAQ,EAAC,EAAE,KAAK,EAAE,mCAAoB,CAAC,wBAAwB,EAAE,CAAC,CAAC;IAC3E,CAAC;CACF,CAAA;AAvKY,0EAA+B;0CAA/B,+BAA+B;IAQvC,WAAA,IAAA,iBAAM,EAAC,EAAE,GAAG,EAAE,sCAAuB,CAAC,eAAe,EAAE,CAAC,CAAA;;GARhD,+BAA+B,CAuK3C"}
1
+ {"version":3,"file":"verifier.service.js","sourceRoot":"","sources":["../../../../../../src/components/auth/authenticate/services/service/verifier.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAAyC;AACzC,wDAK+B;AAE/B,sDAAuD;AACvD,+BAAgE;AAIhE;;;;;;;;GAQG;AACH,IAAa,+BAA+B,u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QAAQ,CAAC,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAEzE,UAAU,IAAI,OAAO;IAKf,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAC3B,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAG9B,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAC1B,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAC7B,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAE3C,+FAA+F;cAC/E,SAAS,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAMlF"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseFilteredAdapter = void 0;
4
4
  const utilities_1 = require("../../../../utilities");
5
5
  const core_1 = require("@venizia/ignis-helpers/core");
6
+ const connector_1 = require("./connector");
6
7
  /** Read-only base for casbin FilteredAdapters backed by a datasource - owns connector plumbing and no-op write methods; subclasses implement {@link loadFilteredPolicy} per principal. */
7
8
  class BaseFilteredAdapter extends core_1.BaseHelper {
8
9
  constructor(opts) {
@@ -10,14 +11,10 @@ class BaseFilteredAdapter extends core_1.BaseHelper {
10
11
  this.dataSource = opts.dataSource;
11
12
  }
12
13
  get connector() {
13
- const source = this.dataSource;
14
- const resolved = source.getConnector?.() ?? source.connector;
15
- if (!resolved) {
16
- throw (0, core_1.getError)({
17
- message: '[BaseFilteredAdapter] datasource exposes neither a getConnector() accessor nor a wired connector - pass a datasource whose getConnector() lazily wires the driver.',
18
- });
19
- }
20
- return resolved;
14
+ return connector_1.PolicyConnectorResolver.resolve({
15
+ source: this.dataSource,
16
+ caller: 'BaseFilteredAdapter',
17
+ });
21
18
  }
22
19
  /** Runs a raw statement and returns its rows. Drizzle's `execute()` shape differs per driver (node-postgres `{ rows }`, postgres-js the row list itself) - never read `.rows` directly. */
23
20
  async query(opts) {
@@ -1 +1 @@
1
- {"version":3,"file":"base-filtered.js","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/adapters/base-filtered.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAC7C,sDAAmE;AAKnE,0LAA0L;AAC1L,MAAsB,mBACpB,SAAQ,iBAAU;IAKlB,YAAY,IAAwD;QAClE,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;IACpC,CAAC;IAED,IAAc,SAAS;QACrB,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC;QAC/B,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,EAAE,EAAE,IAAI,MAAM,CAAC,SAAS,CAAC;QAE7D,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAA,eAAQ,EAAC;gBACb,OAAO,EACL,oKAAoK;aACvK,CAAC,CAAC;QACL,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,2LAA2L;IACjL,KAAK,CAAC,KAAK,CAAO,IAAwB;QAClD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC5D,OAAO,IAAA,0BAAc,EAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IAC1C,CAAC;IAKD,UAAU;QACR,OAAO,IAAI,CAAC;IACd,CAAC;IAED,4DAA4D;IAC5D,KAAK,CAAC,UAAU,KAAmB,CAAC;IACpC,KAAK,CAAC,UAAU;QACd,OAAO,IAAI,CAAC;IACd,CAAC;IACD,KAAK,CAAC,SAAS,KAAmB,CAAC;IACnC,KAAK,CAAC,YAAY,KAAmB,CAAC;IACtC,KAAK,CAAC,oBAAoB,KAAmB,CAAC;IAE9C,+FAA+F;IACrF,KAAK,CAAC,SAAS,CAAC,IAAuC;QAC/D,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC1C,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;CACF;AAtDD,kDAsDC"}
1
+ {"version":3,"file":"base-filtered.js","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/adapters/base-filtered.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAC7C,sDAAyD;AAGzD,2CAAsD;AAGtD,0LAA0L;AAC1L,MAAsB,mBACpB,SAAQ,iBAAU;IAKlB,YAAY,IAAwD;QAClE,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;IACpC,CAAC;IAED,IAAc,SAAS;QACrB,OAAO,mCAAuB,CAAC,OAAO,CAAC;YACrC,MAAM,EAAE,IAAI,CAAC,UAAU;YACvB,MAAM,EAAE,qBAAqB;SAC9B,CAAC,CAAC;IACL,CAAC;IAED,2LAA2L;IACjL,KAAK,CAAC,KAAK,CAAO,IAAwB;QAClD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC5D,OAAO,IAAA,0BAAc,EAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IAC1C,CAAC;IAKD,UAAU;QACR,OAAO,IAAI,CAAC;IACd,CAAC;IAED,4DAA4D;IAC5D,KAAK,CAAC,UAAU,KAAmB,CAAC;IACpC,KAAK,CAAC,UAAU;QACd,OAAO,IAAI,CAAC;IACd,CAAC;IACD,KAAK,CAAC,SAAS,KAAmB,CAAC;IACnC,KAAK,CAAC,YAAY,KAAmB,CAAC;IACtC,KAAK,CAAC,oBAAoB,KAAmB,CAAC;IAE9C,+FAA+F;IACrF,KAAK,CAAC,SAAS,CAAC,IAAuC;QAC/D,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC1C,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;CACF;AA/CD,kDA+CC"}
@@ -0,0 +1,10 @@
1
+ import type { ICasbinPolicySource, TCasbinPolicyConnector } from './types';
2
+ /** Connector-resolution logic shared by every adapter/loader reading the casbin policy store. */
3
+ export declare class PolicyConnectorResolver {
4
+ /** Resolve the wired connector off a policy datasource. */
5
+ static resolve(opts: {
6
+ source: ICasbinPolicySource;
7
+ caller: string;
8
+ }): TCasbinPolicyConnector;
9
+ }
10
+ //# sourceMappingURL=connector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/adapters/connector.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAE3E,iGAAiG;AACjG,qBAAa,uBAAuB;IAClC,2DAA2D;IAC3D,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,mBAAmB,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,sBAAsB;CAY9F"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PolicyConnectorResolver = void 0;
4
+ const core_1 = require("@venizia/ignis-helpers/core");
5
+ /** Connector-resolution logic shared by every adapter/loader reading the casbin policy store. */
6
+ class PolicyConnectorResolver {
7
+ /** Resolve the wired connector off a policy datasource. */
8
+ static resolve(opts) {
9
+ const { source, caller } = opts;
10
+ const resolved = source.getConnector?.() ?? source.connector;
11
+ if (!resolved) {
12
+ throw (0, core_1.getError)({
13
+ message: `[${caller}] datasource exposes neither a getConnector() accessor nor a wired connector - pass a datasource whose getConnector() lazily wires the driver.`,
14
+ });
15
+ }
16
+ return resolved;
17
+ }
18
+ }
19
+ exports.PolicyConnectorResolver = PolicyConnectorResolver;
20
+ //# sourceMappingURL=connector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connector.js","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/adapters/connector.ts"],"names":[],"mappings":";;;AAAA,sDAAuD;AAGvD,iGAAiG;AACjG,MAAa,uBAAuB;IAClC,2DAA2D;IAC3D,MAAM,CAAC,OAAO,CAAC,IAAqD;QAClE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAChC,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,EAAE,EAAE,IAAI,MAAM,CAAC,SAAS,CAAC;QAE7D,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAA,eAAQ,EAAC;gBACb,OAAO,EAAE,IAAI,MAAM,gJAAgJ;aACpK,CAAC,CAAC;QACL,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAdD,0DAcC"}
@@ -0,0 +1,52 @@
1
+ import type { IdType } from '../../../../base';
2
+ import { BaseHelper } from '@venizia/ignis-helpers/core';
3
+ import { type TCustomGrantMetadata } from '@venizia/ignis-kernel';
4
+ import type { ICasbinPolicySource, IScopedCasbinEntities } from './types';
5
+ /** A custom row that survived {@link CustomGrantExpander.rejectCustomRow}, ready for op-to-catalog resolution. */
6
+ export type TCustomGrantRow = {
7
+ subjectId: IdType;
8
+ objectSubject: string;
9
+ ops: string[];
10
+ domain: string;
11
+ effect: string;
12
+ };
13
+ /**
14
+ * Expands "custom" operation-subset grants (`metadata.ops`) into one casbin line per catalogued
15
+ * operation. Isolated from the filtered-policy loader on purpose: it owns its own SQL
16
+ * (`queryOperationCatalog`) and error vocabulary, and never reaches back into ScopedCasbinAdapter.
17
+ */
18
+ export declare class CustomGrantExpander extends BaseHelper {
19
+ protected readonly dataSource: ICasbinPolicySource;
20
+ protected readonly permission: IScopedCasbinEntities['permission'];
21
+ protected readonly softDelete: IScopedCasbinEntities['softDelete'];
22
+ constructor(opts: {
23
+ dataSource: ICasbinPolicySource;
24
+ entities: Pick<IScopedCasbinEntities, 'permission' | 'softDelete'>;
25
+ });
26
+ /** Why a custom-looking grant row cannot be honoured, or null when it is well formed. */
27
+ rejectCustomRow(opts: {
28
+ row: {
29
+ subjectId: IdType;
30
+ objectCode: string;
31
+ objectMethod: string;
32
+ };
33
+ parsed: TCustomGrantMetadata | null;
34
+ isCustomAction: boolean;
35
+ metadataColumnName?: string;
36
+ }): string | null;
37
+ /** Resolve every custom row's ops in one catalog query, then emit one line per resolved operation. Unresolvable ops come back as `rejections` rather than being logged here - the caller owns the logger the tests swap. */
38
+ expandCustomGrants(opts: {
39
+ subjectType: string;
40
+ customRows: TCustomGrantRow[];
41
+ }): Promise<{
42
+ lines: string[];
43
+ rejections: string[];
44
+ }>;
45
+ /** Schema-qualified table reference (`"<schema>"."<table>"`) for use after FROM/JOIN with an alias. */
46
+ private qualifiedTable;
47
+ /** `AND <alias>.<col> IS NULL` when soft-delete is on, else empty. The alias is emitted raw to match the unquoted FROM alias - quoting folds it to a different case and breaks the join. */
48
+ private softDeleteClause;
49
+ /** Resolve `(subject, method)` pairs to catalogued operations. One query for the whole extraction. */
50
+ private queryOperationCatalog;
51
+ }
52
+ //# sourceMappingURL=custom-grant-expander.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-grant-expander.d.ts","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/adapters/custom-grant-expander.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,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E,CAAC;QAAC,UAAU,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAoDtD,uGAAuG;IACvG,OAAO,CAAC,cAAc;IAMtB,4LAA4L;IAC5L,OAAO,CAAC,gBAAgB;IASxB,sGAAsG;YACxF,qBAAqB;CA6BpC"}
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CustomGrantExpander = void 0;
4
+ const utilities_1 = require("../../../../utilities");
5
+ const core_1 = require("@venizia/ignis-helpers/core");
6
+ const ignis_kernel_1 = require("@venizia/ignis-kernel");
7
+ const drizzle_orm_1 = require("drizzle-orm");
8
+ const connector_1 = require("./connector");
9
+ const DEFAULT_SCHEMA = 'public';
10
+ /**
11
+ * Expands "custom" operation-subset grants (`metadata.ops`) into one casbin line per catalogued
12
+ * operation. Isolated from the filtered-policy loader on purpose: it owns its own SQL
13
+ * (`queryOperationCatalog`) and error vocabulary, and never reaches back into ScopedCasbinAdapter.
14
+ */
15
+ class CustomGrantExpander extends core_1.BaseHelper {
16
+ constructor(opts) {
17
+ super({ scope: CustomGrantExpander.name });
18
+ this.dataSource = opts.dataSource;
19
+ this.permission = opts.entities.permission;
20
+ this.softDelete = opts.entities.softDelete;
21
+ }
22
+ /** Why a custom-looking grant row cannot be honoured, or null when it is well formed. */
23
+ rejectCustomRow(opts) {
24
+ const { row, parsed, isCustomAction, metadataColumnName } = opts;
25
+ if (isCustomAction && !metadataColumnName) {
26
+ return `Skipping custom grant - entities.policyDefinition.metadata.columnName is not mapped, so metadata.ops cannot be read | subject id: ${row.subjectId} | object: ${row.objectCode}`;
27
+ }
28
+ if (isCustomAction && !parsed) {
29
+ return `Skipping custom grant - metadata.ops is missing, empty, or not an array of non-empty strings | subject id: ${row.subjectId} | object: ${row.objectCode}`;
30
+ }
31
+ if (!isCustomAction && parsed) {
32
+ return `Skipping grant - metadata.ops is present but action is not "${ignis_kernel_1.AuthorizationActions.CUSTOM}", so the intent is ambiguous | subject id: ${row.subjectId} | object: ${row.objectCode}`;
33
+ }
34
+ if (row.objectMethod !== ignis_kernel_1.AuthorizationPermissionBuilder.RESOURCE_NODE_METHOD) {
35
+ return `Skipping custom grant - the target must be a subject-level resource node | subject id: ${row.subjectId} | object: ${row.objectCode}`;
36
+ }
37
+ return null;
38
+ }
39
+ /** Resolve every custom row's ops in one catalog query, then emit one line per resolved operation. Unresolvable ops come back as `rejections` rather than being logged here - the caller owns the logger the tests swap. */
40
+ async expandCustomGrants(opts) {
41
+ if (!opts.customRows.length) {
42
+ return { lines: [], rejections: [] };
43
+ }
44
+ const seen = new Set();
45
+ const pairs = [];
46
+ const candidates = opts.customRows.flatMap(row => row.ops.map(op => ({ subject: row.objectSubject, method: op })));
47
+ for (const candidate of candidates) {
48
+ const key = `${candidate.subject}.${candidate.method}`;
49
+ if (seen.has(key)) {
50
+ continue;
51
+ }
52
+ seen.add(key);
53
+ pairs.push(candidate);
54
+ }
55
+ const catalog = await this.queryOperationCatalog({ pairs });
56
+ const byKey = new Map(catalog.map(entry => [`${entry.subject}.${entry.method}`, entry]));
57
+ const lines = [];
58
+ const rejections = [];
59
+ for (const row of opts.customRows) {
60
+ const { valid, unknown } = ignis_kernel_1.GrantBuilder.getInstance().validateCustomGrantOps({
61
+ ops: row.ops,
62
+ subject: row.objectSubject,
63
+ catalog,
64
+ });
65
+ if (unknown.length) {
66
+ rejections.push(`Skipping unresolvable operations in a custom grant | subject id: ${row.subjectId} | resource: ${row.objectSubject} | unknown: ${unknown.join(', ')}`);
67
+ }
68
+ for (const op of valid) {
69
+ const entry = byKey.get(`${row.objectSubject}.${op}`);
70
+ lines.push(`${ignis_kernel_1.AuthorizationPolicyVariants.GRANT.rule}, ${opts.subjectType}_${row.subjectId}, ${row.domain}, ${entry.code}, ${entry.action}, ${row.effect}`);
71
+ }
72
+ }
73
+ return { lines, rejections };
74
+ }
75
+ /** Schema-qualified table reference (`"<schema>"."<table>"`) for use after FROM/JOIN with an alias. */
76
+ qualifiedTable(opts) {
77
+ const { table } = opts;
78
+ const schema = table.schemaName ?? DEFAULT_SCHEMA;
79
+ return (0, drizzle_orm_1.sql) `${drizzle_orm_1.sql.identifier(schema)}.${drizzle_orm_1.sql.identifier(table.tableName)}`;
80
+ }
81
+ /** `AND <alias>.<col> IS NULL` when soft-delete is on, else empty. The alias is emitted raw to match the unquoted FROM alias - quoting folds it to a different case and breaks the join. */
82
+ softDeleteClause(opts) {
83
+ const sd = this.softDelete;
84
+ if (!sd?.use) {
85
+ return drizzle_orm_1.sql.empty();
86
+ }
87
+ return (0, drizzle_orm_1.sql) ` AND ${drizzle_orm_1.sql.raw(opts.alias)}.${drizzle_orm_1.sql.identifier(sd.columnName)} IS NULL`;
88
+ }
89
+ /** Resolve `(subject, method)` pairs to catalogued operations. One query for the whole extraction. */
90
+ async queryOperationCatalog(opts) {
91
+ if (!opts.pairs.length) {
92
+ return [];
93
+ }
94
+ const permissionTable = this.qualifiedTable({ table: this.permission });
95
+ const connector = connector_1.PolicyConnectorResolver.resolve({
96
+ source: this.dataSource,
97
+ caller: CustomGrantExpander.name,
98
+ });
99
+ const result = await connector.execute((0, drizzle_orm_1.sql) `
100
+ SELECT permission.subject, permission.method, permission.code, permission.action
101
+ FROM ${permissionTable} permission
102
+ WHERE (permission.subject, permission.method) IN (${drizzle_orm_1.sql.join(opts.pairs.map(pair => (0, drizzle_orm_1.sql) `(${pair.subject}, ${pair.method})`), (0, drizzle_orm_1.sql) `, `)})
103
+ AND permission.method <> ${ignis_kernel_1.AuthorizationPermissionBuilder.RESOURCE_NODE_METHOD}${this.softDeleteClause({ alias: 'permission' })}
104
+ `);
105
+ return (0, utilities_1.readResultRows)({
106
+ result,
107
+ });
108
+ }
109
+ }
110
+ exports.CustomGrantExpander = CustomGrantExpander;
111
+ //# sourceMappingURL=custom-grant-expander.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-grant-expander.js","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/adapters/custom-grant-expander.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@@ -1,4 +1,6 @@
1
1
  export * from './base-filtered';
2
+ export * from './connector';
3
+ export * from './custom-grant-expander';
2
4
  export * from './scoped-casbin.adapter';
3
5
  export * from './types';
4
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/adapters/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/adapters/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,SAAS,CAAC"}
@@ -15,6 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./base-filtered"), exports);
18
+ __exportStar(require("./connector"), exports);
19
+ __exportStar(require("./custom-grant-expander"), exports);
18
20
  __exportStar(require("./scoped-casbin.adapter"), exports);
19
21
  __exportStar(require("./types"), exports);
20
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/adapters/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,0DAAwC;AACxC,0CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/adapters/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,8CAA4B;AAC5B,0DAAwC;AACxC,0DAAwC;AACxC,0CAAwB"}
@@ -2,9 +2,13 @@ import type { IdType } from '../../../../base';
2
2
  import type { TConstValue, TNullable } from '@venizia/ignis-helpers/common';
3
3
  import { type Model } from 'casbin';
4
4
  import { type SQL } from 'drizzle-orm';
5
- import { type TCustomGrantMetadata } from '@venizia/ignis-kernel';
6
5
  import { BaseFilteredAdapter } from './base-filtered';
6
+ import { CustomGrantExpander } from './custom-grant-expander';
7
7
  import type { ICasbinPolicySource, IScopedCasbinEntities } from './types';
8
+ export type TDomainHierarchyEdge = {
9
+ child: string;
10
+ parent: string;
11
+ };
8
12
  export interface IScopedCasbinPolicyFilter {
9
13
  principal: {
10
14
  type: string;
@@ -35,14 +39,46 @@ export type TPrincipalPolicyRow = TGrantRow & {
35
39
  targetType: TNullable<string>;
36
40
  targetId: IdType;
37
41
  };
38
- /** Filtered casbin adapter for the scoped RBAC model: loads ONE principal's edges (role assignments, memberships, grants) plus the shared structural hierarchy trees as casbin lines. Read-only. */
42
+ /**
43
+ * Per-principal domain edges sourced from business data the app already owns (e.g. a tenant
44
+ * foreign key) - read live on every cache miss, never duplicated into `domain_inherits`. An app
45
+ * whose hierarchy genuinely lives in `domain_inherits` rows does not need this hook at all: the
46
+ * DOMAIN_EDGE branch above already emits those as `g3` lines. `domains` is the principal's own
47
+ * domain closure, already `<Type>_<id>` tokens; the returned edges must be too - neither side
48
+ * re-formats them.
49
+ */
50
+ export type TResolveDomainEdgesFn = (opts: {
51
+ principal: {
52
+ type: string;
53
+ id: IdType;
54
+ };
55
+ domains: string[];
56
+ }) => Promise<TDomainHierarchyEdge[]>;
57
+ /**
58
+ * Filtered casbin adapter for the scoped RBAC model: loads ONE principal's edges (role assignments,
59
+ * memberships, grants) plus the shared structural hierarchy trees as casbin lines. Read-only.
60
+ *
61
+ * EVERY branch below must select by `variant = <known value>` or `variant IN (<known values>)`.
62
+ * Never `variant NOT IN (...)`, and never a bare select that classifies afterwards. Applications
63
+ * store their own edge kinds in this same table (declared via `extraVariants`), and an exclusion
64
+ * filter would sweep those unknown rows into a branch that has no idea what they mean. The current
65
+ * shape makes an undeclared variant inert, which is what makes sharing the table safe.
66
+ */
39
67
  export declare class ScopedCasbinAdapter extends BaseFilteredAdapter<IScopedCasbinPolicyFilter> {
40
68
  protected readonly entities: IScopedCasbinEntities;
69
+ protected readonly customGrantExpander: CustomGrantExpander;
70
+ protected readonly resolveDomainEdges?: TResolveDomainEdgesFn;
41
71
  constructor(opts: {
42
72
  dataSource: ICasbinPolicySource;
43
73
  entities: IScopedCasbinEntities;
74
+ resolveDomainEdges?: TResolveDomainEdgesFn;
44
75
  });
45
- /** One wave: the principal-scoped CTE and the merged structural-edges query are issued together - the role closure resolves in SQL, so neither waits on the other. */
76
+ /**
77
+ * One wave: the principal-scoped CTE and the merged structural-edges query are issued together -
78
+ * the role closure resolves in SQL, so neither waits on the other. `resolveDomainEdges` cannot
79
+ * join that wave - it needs the domain closure the principal-scoped CTE produces - but it does
80
+ * not wait for the structural-edges query either: both run concurrently once the closure is known.
81
+ */
46
82
  loadFilteredPolicy(model: Model, filter: IScopedCasbinPolicyFilter): Promise<void>;
47
83
  /** Route one `direct` row to its casbin line, or to the grant batch. */
48
84
  protected collectDirectRow(opts: {
@@ -54,6 +90,20 @@ export declare class ScopedCasbinAdapter extends BaseFilteredAdapter<IScopedCasb
54
90
  lines: string[];
55
91
  directGrants: TGrantRow[];
56
92
  }): void;
93
+ /**
94
+ * Calls the `resolveDomainEdges` hook, if supplied, and turns its edges into `g3` lines using
95
+ * the same shape the DOMAIN_EDGE branch emits. A throwing hook is logged and treated as no
96
+ * edges - the rows already gathered for this principal still load. This is the safe direction:
97
+ * a missing hierarchy edge can only narrow what `g`/`g2`/`g3` reach, never widen it, so the
98
+ * failure degrades to less access rather than either an outage or excess access.
99
+ */
100
+ protected resolveDomainEdgeLines(opts: {
101
+ principal: {
102
+ type: string;
103
+ id: IdType;
104
+ };
105
+ domains: string[];
106
+ }): Promise<string[]>;
57
107
  /** Schema for a table, defaulting to `public`. */
58
108
  protected schemaOf(table: {
59
109
  schemaName?: string;
@@ -81,40 +131,6 @@ export declare class ScopedCasbinAdapter extends BaseFilteredAdapter<IScopedCasb
81
131
  subjectType: string;
82
132
  rows: TGrantRow[];
83
133
  }): Promise<string[]>;
84
- /** Why a custom-looking grant row cannot be honoured, or null when it is well formed. */
85
- protected rejectCustomRow(opts: {
86
- row: {
87
- subjectId: IdType;
88
- objectCode: string;
89
- objectMethod: string;
90
- };
91
- parsed: TCustomGrantMetadata | null;
92
- isCustomAction: boolean;
93
- metadataColumnName?: string;
94
- }): string | null;
95
- /** Resolve every custom row's ops in one catalog query, then emit one line per resolved operation. */
96
- protected expandCustomGrants(opts: {
97
- subjectType: string;
98
- customRows: Array<{
99
- subjectId: IdType;
100
- objectSubject: string;
101
- ops: string[];
102
- domain: string;
103
- effect: string;
104
- }>;
105
- }): Promise<string[]>;
106
- /** Resolve `(subject, method)` pairs to catalogued operations. One query for the whole extraction. */
107
- protected queryOperationCatalog(opts: {
108
- pairs: Array<{
109
- subject: string;
110
- method: string;
111
- }>;
112
- }): Promise<Array<{
113
- subject: string;
114
- method: string;
115
- code: string;
116
- action: string;
117
- }>>;
118
134
  /** The two code-fixed structural trees only (`g4` resource, `g5` action) - constant regardless of tenant count. Domain edges (`g3`) grow with the domain count, so they are principal-scoped in {@link queryPrincipalPolicies} instead. */
119
135
  protected queryEdgePolicies(): Promise<string[]>;
120
136
  }
@@ -1 +1 @@
1
- {"version":3,"file":"scoped-casbin.adapter.d.ts","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/adapters/scoped-casbin.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAO,KAAK,GAAG,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAKL,KAAK,oBAAoB,EAC1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EA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e,CAAC,IAAI,EAAE;QAC9B,GAAG,EAAE;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,UAAU,EAAE,MAAM,CAAC;YAAC,YAAY,EAAE,MAAM,CAAA;SAAE,CAAC;QACrE,MAAM,EAAE,oBAAoB,GAAG,IAAI,CAAC;QACpC,cAAc,EAAE,OAAO,CAAC;QACxB,kBAAkB,CAAC,EAAE,MAAM,CAAC;KAC7B,GAAG,MAAM,GAAG,IAAI;IAsBjB,sGAAsG;cACtF,kBAAkB,CAAC,IAAI,EAAE;QACvC,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,KAAK,CAAC;YAChB,SAAS,EAAE,MAAM,CAAC;YAClB,aAAa,EAAE,MAAM,CAAC;YACtB,GAAG,EAAE,MAAM,EAAE,CAAC;YACd,MAAM,EAAE,MAAM,CAAC;YACf,MAAM,EAAE,MAAM,CAAC;SAChB,CAAC,CAAC;KACJ,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAwDrB,sGAAsG;cACtF,qBAAqB,CAAC,IAAI,EAAE;QAC1C,KAAK,EAAE,KAAK,CAAC;YAAE,OAAO,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KACnD,GAAG,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAsBrF,2OAA2O;cAC3N,iBAAiB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CA6BvD"}
1
+ {"version":3,"file":"scoped-casbin.adapter.d.ts","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/adapters/scoped-casbin.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EA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