@venizia/ignis 0.0.9-8 → 0.0.9

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 (196) hide show
  1. package/README.md +15 -15
  2. package/dist/base/metadata/persistents.d.ts.map +1 -1
  3. package/dist/base/metadata/persistents.js +6 -0
  4. package/dist/base/metadata/persistents.js.map +1 -1
  5. package/dist/base/middlewares/app-error/app-error.middleware.d.ts +15 -0
  6. package/dist/base/middlewares/app-error/app-error.middleware.d.ts.map +1 -0
  7. package/dist/base/middlewares/app-error/app-error.middleware.js +81 -0
  8. package/dist/base/middlewares/app-error/app-error.middleware.js.map +1 -0
  9. package/dist/base/middlewares/app-error/database.handler.d.ts +20 -0
  10. package/dist/base/middlewares/app-error/database.handler.d.ts.map +1 -0
  11. package/dist/base/middlewares/app-error/database.handler.js +55 -0
  12. package/dist/base/middlewares/app-error/database.handler.js.map +1 -0
  13. package/dist/base/middlewares/app-error/definition.d.ts +59 -0
  14. package/dist/base/middlewares/app-error/definition.d.ts.map +1 -0
  15. package/dist/base/middlewares/app-error/definition.js +98 -0
  16. package/dist/base/middlewares/app-error/definition.js.map +1 -0
  17. package/dist/base/middlewares/app-error/index.d.ts +2 -0
  18. package/dist/base/middlewares/app-error/index.d.ts.map +1 -0
  19. package/dist/{components/auth/authorize/models/abilities → base/middlewares/app-error}/index.js +1 -2
  20. package/dist/base/middlewares/app-error/index.js.map +1 -0
  21. package/dist/base/middlewares/app-error/types.d.ts +18 -0
  22. package/dist/base/middlewares/app-error/types.d.ts.map +1 -0
  23. package/dist/base/middlewares/app-error/types.js +3 -0
  24. package/dist/base/middlewares/app-error/types.js.map +1 -0
  25. package/dist/base/middlewares/app-error/zod.handler.d.ts +28 -0
  26. package/dist/base/middlewares/app-error/zod.handler.d.ts.map +1 -0
  27. package/dist/base/middlewares/app-error/zod.handler.js +64 -0
  28. package/dist/base/middlewares/app-error/zod.handler.js.map +1 -0
  29. package/dist/base/middlewares/emoji-favicon/emoji-favicon.middleware.d.ts.map +1 -0
  30. package/dist/base/middlewares/emoji-favicon/emoji-favicon.middleware.js.map +1 -0
  31. package/dist/base/middlewares/emoji-favicon/index.d.ts +2 -0
  32. package/dist/base/middlewares/emoji-favicon/index.d.ts.map +1 -0
  33. package/dist/base/middlewares/emoji-favicon/index.js +18 -0
  34. package/dist/base/middlewares/emoji-favicon/index.js.map +1 -0
  35. package/dist/base/middlewares/index.d.ts +4 -4
  36. package/dist/base/middlewares/index.d.ts.map +1 -1
  37. package/dist/base/middlewares/index.js +4 -4
  38. package/dist/base/middlewares/index.js.map +1 -1
  39. package/dist/base/middlewares/not-found/index.d.ts +2 -0
  40. package/dist/base/middlewares/not-found/index.d.ts.map +1 -0
  41. package/dist/base/middlewares/not-found/index.js +18 -0
  42. package/dist/base/middlewares/not-found/index.js.map +1 -0
  43. package/dist/base/middlewares/{not-found.middleware.d.ts → not-found/not-found.middleware.d.ts} +0 -1
  44. package/dist/base/middlewares/not-found/not-found.middleware.d.ts.map +1 -0
  45. package/dist/base/middlewares/{not-found.middleware.js → not-found/not-found.middleware.js} +2 -3
  46. package/dist/base/middlewares/{not-found.middleware.js.map → not-found/not-found.middleware.js.map} +1 -1
  47. package/dist/base/middlewares/request-spy/index.d.ts +2 -0
  48. package/dist/base/middlewares/request-spy/index.d.ts.map +1 -0
  49. package/dist/base/middlewares/request-spy/index.js +18 -0
  50. package/dist/base/middlewares/request-spy/index.js.map +1 -0
  51. package/dist/base/middlewares/{request-spy.middleware.d.ts → request-spy/request-spy.middleware.d.ts} +1 -1
  52. package/dist/base/middlewares/request-spy/request-spy.middleware.d.ts.map +1 -0
  53. package/dist/base/middlewares/{request-spy.middleware.js → request-spy/request-spy.middleware.js} +1 -1
  54. package/dist/base/middlewares/request-spy/request-spy.middleware.js.map +1 -0
  55. package/dist/base/models/common/columns.d.ts +22 -0
  56. package/dist/base/models/common/columns.d.ts.map +1 -0
  57. package/dist/base/models/common/columns.js +43 -0
  58. package/dist/base/models/common/columns.js.map +1 -0
  59. package/dist/base/models/common/index.d.ts +1 -0
  60. package/dist/base/models/common/index.d.ts.map +1 -1
  61. package/dist/base/models/common/index.js +1 -0
  62. package/dist/base/models/common/index.js.map +1 -1
  63. package/dist/base/models/enrichers/principal.enricher.d.ts +6 -5
  64. package/dist/base/models/enrichers/principal.enricher.d.ts.map +1 -1
  65. package/dist/base/models/enrichers/principal.enricher.js +8 -3
  66. package/dist/base/models/enrichers/principal.enricher.js.map +1 -1
  67. package/dist/base/models/enrichers/tz.enricher.d.ts +9 -8
  68. package/dist/base/models/enrichers/tz.enricher.d.ts.map +1 -1
  69. package/dist/base/models/enrichers/tz.enricher.js +10 -10
  70. package/dist/base/models/enrichers/tz.enricher.js.map +1 -1
  71. package/dist/base/repositories/core/abstract.d.ts +2 -0
  72. package/dist/base/repositories/core/abstract.d.ts.map +1 -1
  73. package/dist/base/repositories/core/readable.d.ts.map +1 -1
  74. package/dist/base/repositories/core/readable.js +17 -5
  75. package/dist/base/repositories/core/readable.js.map +1 -1
  76. package/dist/base/repositories/core/soft-deletable.d.ts +1 -1
  77. package/dist/base/repositories/core/soft-deletable.d.ts.map +1 -1
  78. package/dist/base/repositories/mixins/default-filter.d.ts +3 -0
  79. package/dist/base/repositories/mixins/default-filter.d.ts.map +1 -1
  80. package/dist/base/repositories/mixins/default-filter.js +11 -0
  81. package/dist/base/repositories/mixins/default-filter.js.map +1 -1
  82. package/dist/base/repositories/operators/filter.d.ts +4 -0
  83. package/dist/base/repositories/operators/filter.d.ts.map +1 -1
  84. package/dist/base/repositories/operators/filter.js +19 -1
  85. package/dist/base/repositories/operators/filter.js.map +1 -1
  86. package/dist/components/auth/authorize/adapters/base-filtered.d.ts +26 -56
  87. package/dist/components/auth/authorize/adapters/base-filtered.d.ts.map +1 -1
  88. package/dist/components/auth/authorize/adapters/base-filtered.js +23 -70
  89. package/dist/components/auth/authorize/adapters/base-filtered.js.map +1 -1
  90. package/dist/components/auth/authorize/adapters/index.d.ts +2 -1
  91. package/dist/components/auth/authorize/adapters/index.d.ts.map +1 -1
  92. package/dist/components/auth/authorize/adapters/index.js +2 -1
  93. package/dist/components/auth/authorize/adapters/index.js.map +1 -1
  94. package/dist/components/auth/authorize/adapters/scoped-casbin.adapter.d.ts +138 -0
  95. package/dist/components/auth/authorize/adapters/scoped-casbin.adapter.d.ts.map +1 -0
  96. package/dist/components/auth/authorize/adapters/scoped-casbin.adapter.js +300 -0
  97. package/dist/components/auth/authorize/adapters/scoped-casbin.adapter.js.map +1 -0
  98. package/dist/components/auth/authorize/adapters/types.d.ts +31 -0
  99. package/dist/components/auth/authorize/adapters/types.d.ts.map +1 -0
  100. package/dist/components/auth/authorize/adapters/types.js +3 -0
  101. package/dist/components/auth/authorize/adapters/types.js.map +1 -0
  102. package/dist/components/auth/authorize/common/constants.d.ts +144 -8
  103. package/dist/components/auth/authorize/common/constants.d.ts.map +1 -1
  104. package/dist/components/auth/authorize/common/constants.js +171 -13
  105. package/dist/components/auth/authorize/common/constants.js.map +1 -1
  106. package/dist/components/auth/authorize/common/index.d.ts +4 -0
  107. package/dist/components/auth/authorize/common/index.d.ts.map +1 -1
  108. package/dist/components/auth/authorize/common/index.js +4 -0
  109. package/dist/components/auth/authorize/common/index.js.map +1 -1
  110. package/dist/components/auth/authorize/common/object-match.d.ts +21 -0
  111. package/dist/components/auth/authorize/common/object-match.d.ts.map +1 -0
  112. package/dist/components/auth/authorize/common/object-match.js +33 -0
  113. package/dist/components/auth/authorize/common/object-match.js.map +1 -0
  114. package/dist/components/auth/authorize/common/permission-builder.d.ts +92 -0
  115. package/dist/components/auth/authorize/common/permission-builder.d.ts.map +1 -0
  116. package/dist/components/auth/authorize/common/permission-builder.js +99 -0
  117. package/dist/components/auth/authorize/common/permission-builder.js.map +1 -0
  118. package/dist/components/auth/authorize/common/policy-builder.d.ts +183 -0
  119. package/dist/components/auth/authorize/common/policy-builder.d.ts.map +1 -0
  120. package/dist/components/auth/authorize/common/policy-builder.js +130 -0
  121. package/dist/components/auth/authorize/common/policy-builder.js.map +1 -0
  122. package/dist/components/auth/authorize/common/resolve-request-domain.d.ts +20 -0
  123. package/dist/components/auth/authorize/common/resolve-request-domain.d.ts.map +1 -0
  124. package/dist/components/auth/authorize/common/resolve-request-domain.js +59 -0
  125. package/dist/components/auth/authorize/common/resolve-request-domain.js.map +1 -0
  126. package/dist/components/auth/authorize/common/types.d.ts +70 -23
  127. package/dist/components/auth/authorize/common/types.d.ts.map +1 -1
  128. package/dist/components/auth/authorize/enforcers/casbin.enforcer.d.ts +120 -28
  129. package/dist/components/auth/authorize/enforcers/casbin.enforcer.d.ts.map +1 -1
  130. package/dist/components/auth/authorize/enforcers/casbin.enforcer.js +324 -124
  131. package/dist/components/auth/authorize/enforcers/casbin.enforcer.js.map +1 -1
  132. package/dist/components/auth/authorize/enforcers/enforcer-registry.d.ts +19 -1
  133. package/dist/components/auth/authorize/enforcers/enforcer-registry.d.ts.map +1 -1
  134. package/dist/components/auth/authorize/enforcers/enforcer-registry.js +23 -0
  135. package/dist/components/auth/authorize/enforcers/enforcer-registry.js.map +1 -1
  136. package/dist/components/auth/authorize/enforcers/index.d.ts +1 -0
  137. package/dist/components/auth/authorize/enforcers/index.d.ts.map +1 -1
  138. package/dist/components/auth/authorize/enforcers/index.js +1 -0
  139. package/dist/components/auth/authorize/enforcers/index.js.map +1 -1
  140. package/dist/components/auth/authorize/enforcers/models/index.d.ts +2 -0
  141. package/dist/components/auth/authorize/enforcers/models/index.d.ts.map +1 -0
  142. package/dist/components/auth/authorize/enforcers/models/index.js +18 -0
  143. package/dist/components/auth/authorize/enforcers/models/index.js.map +1 -0
  144. package/dist/components/auth/authorize/enforcers/models/rbac-domain.model.d.ts +32 -0
  145. package/dist/components/auth/authorize/enforcers/models/rbac-domain.model.d.ts.map +1 -0
  146. package/dist/components/auth/authorize/enforcers/models/rbac-domain.model.js +54 -0
  147. package/dist/components/auth/authorize/enforcers/models/rbac-domain.model.js.map +1 -0
  148. package/dist/components/auth/authorize/models/index.d.ts +0 -1
  149. package/dist/components/auth/authorize/models/index.d.ts.map +1 -1
  150. package/dist/components/auth/authorize/models/index.js +0 -1
  151. package/dist/components/auth/authorize/models/index.js.map +1 -1
  152. package/dist/components/auth/authorize/providers/authorization.provider.d.ts.map +1 -1
  153. package/dist/components/auth/authorize/providers/authorization.provider.js +12 -0
  154. package/dist/components/auth/authorize/providers/authorization.provider.js.map +1 -1
  155. package/dist/components/auth/models/entities/permission.model.d.ts +2 -0
  156. package/dist/components/auth/models/entities/permission.model.d.ts.map +1 -1
  157. package/dist/components/auth/models/entities/permission.model.js +4 -0
  158. package/dist/components/auth/models/entities/permission.model.js.map +1 -1
  159. package/dist/components/auth/models/entities/user.model.d.ts +16 -2
  160. package/dist/components/auth/models/entities/user.model.d.ts.map +1 -1
  161. package/dist/components/auth/models/entities/user.model.js +3 -2
  162. package/dist/components/auth/models/entities/user.model.js.map +1 -1
  163. package/dist/components/mail/helpers/executors/internal-queue-executor.helper.d.ts.map +1 -1
  164. package/dist/components/mail/helpers/executors/internal-queue-executor.helper.js +1 -1
  165. package/dist/components/mail/helpers/executors/internal-queue-executor.helper.js.map +1 -1
  166. package/dist/components/static-asset/models/base.model.d.ts +24 -16
  167. package/dist/components/static-asset/models/base.model.d.ts.map +1 -1
  168. package/dist/helpers/inversion/common/types.d.ts +2 -0
  169. package/dist/helpers/inversion/common/types.d.ts.map +1 -1
  170. package/package.json +6 -5
  171. package/dist/base/middlewares/app-error.middleware.d.ts +0 -8
  172. package/dist/base/middlewares/app-error.middleware.d.ts.map +0 -1
  173. package/dist/base/middlewares/app-error.middleware.js +0 -138
  174. package/dist/base/middlewares/app-error.middleware.js.map +0 -1
  175. package/dist/base/middlewares/emoji-favicon.middleware.d.ts.map +0 -1
  176. package/dist/base/middlewares/emoji-favicon.middleware.js.map +0 -1
  177. package/dist/base/middlewares/not-found.middleware.d.ts.map +0 -1
  178. package/dist/base/middlewares/request-spy.middleware.d.ts.map +0 -1
  179. package/dist/base/middlewares/request-spy.middleware.js.map +0 -1
  180. package/dist/components/auth/authorize/adapters/drizzle-casbin.d.ts +0 -46
  181. package/dist/components/auth/authorize/adapters/drizzle-casbin.d.ts.map +0 -1
  182. package/dist/components/auth/authorize/adapters/drizzle-casbin.js +0 -104
  183. package/dist/components/auth/authorize/adapters/drizzle-casbin.js.map +0 -1
  184. package/dist/components/auth/authorize/models/abilities/index.d.ts +0 -3
  185. package/dist/components/auth/authorize/models/abilities/index.d.ts.map +0 -1
  186. package/dist/components/auth/authorize/models/abilities/index.js.map +0 -1
  187. package/dist/components/auth/authorize/models/abilities/string-action.model.d.ts +0 -14
  188. package/dist/components/auth/authorize/models/abilities/string-action.model.d.ts.map +0 -1
  189. package/dist/components/auth/authorize/models/abilities/string-action.model.js +0 -23
  190. package/dist/components/auth/authorize/models/abilities/string-action.model.js.map +0 -1
  191. package/dist/components/auth/authorize/models/abilities/string-resource.model.d.ts +0 -13
  192. package/dist/components/auth/authorize/models/abilities/string-resource.model.d.ts.map +0 -1
  193. package/dist/components/auth/authorize/models/abilities/string-resource.model.js +0 -19
  194. package/dist/components/auth/authorize/models/abilities/string-resource.model.js.map +0 -1
  195. /package/dist/base/middlewares/{emoji-favicon.middleware.d.ts → emoji-favicon/emoji-favicon.middleware.d.ts} +0 -0
  196. /package/dist/base/middlewares/{emoji-favicon.middleware.js → emoji-favicon/emoji-favicon.middleware.js} +0 -0
@@ -4,14 +4,21 @@ export declare class Authorization {
4
4
  static readonly RULES = "authorization.rules";
5
5
  static readonly SKIP_AUTHORIZATION = "authorization.skip";
6
6
  static readonly ENFORCER = "authorization.enforcer";
7
+ static readonly DOMAIN = "authorization.domain";
7
8
  }
8
9
  export declare class AuthorizationActions {
9
10
  static readonly CREATE = "create";
10
- static readonly READ = "read";
11
11
  static readonly UPDATE = "update";
12
12
  static readonly DELETE = "delete";
13
13
  static readonly EXECUTE = "execute";
14
+ static readonly READ = "read";
15
+ static readonly WRITE = "write";
16
+ static readonly MANAGE = "manage";
14
17
  static readonly SCHEME_SET: Set<string>;
18
+ static readonly LATTICE: ReadonlyArray<{
19
+ child: TAuthorizationAction;
20
+ parent: TAuthorizationAction;
21
+ }>;
15
22
  static isValid(input: string): boolean;
16
23
  }
17
24
  export type TAuthorizationAction = TConstValue<typeof AuthorizationActions>;
@@ -43,7 +50,6 @@ export declare class AuthorizationEnforcerTypes {
43
50
  }
44
51
  export type TAuthorizationEnforcerType = TConstValue<typeof AuthorizationEnforcerTypes>;
45
52
  export declare class CasbinEnforcerCachedDrivers {
46
- static readonly IN_MEMORY = "in-memory";
47
53
  static readonly REDIS = "redis";
48
54
  static readonly SCHEME_SET: Set<string>;
49
55
  static isValid(input: string): boolean;
@@ -56,15 +62,145 @@ export declare class CasbinEnforcerModelDrivers {
56
62
  static isValid(input: string): boolean;
57
63
  }
58
64
  export type TCasbinEnforcerModelDriver = TConstValue<typeof CasbinEnforcerModelDrivers>;
65
+ export declare class CasbinDomainMatchingFunctions {
66
+ /** `*` is the only wildcard; exact compare otherwise. Safest for `Merchant_<uuid>` domains. */
67
+ static readonly KEY_MATCH = "keyMatch";
68
+ /** Adds URL-path `:param` segment matching. */
69
+ static readonly KEY_MATCH_2 = "keyMatch2";
70
+ /** Adds `{param}` segment matching. */
71
+ static readonly KEY_MATCH_3 = "keyMatch3";
72
+ /** `{param}` matching with repeated-name equality checks. */
73
+ static readonly KEY_MATCH_4 = "keyMatch4";
74
+ /** Treats the stored/policy value as a full regular expression. */
75
+ static readonly REGEX_MATCH = "regexMatch";
76
+ static readonly SCHEME_SET: Set<string>;
77
+ static isValid(input: string): boolean;
78
+ }
79
+ export type TCasbinDomainMatchingFunction = TConstValue<typeof CasbinDomainMatchingFunctions>;
80
+ export declare class AuthorizationDomainScopes {
81
+ /** Grant applies in EVERY domain the subject is a member of (checked via join_domain / g2). */
82
+ static readonly ANY_MEMBER = "ANY_MEMBER";
83
+ /** Grant applies system-wide, bypassing membership — super-admin only. */
84
+ static readonly SYSTEM_WIDE = "SYSTEM_WIDE";
85
+ static readonly SCHEME_SET: Set<string>;
86
+ static isValid(input: string): boolean;
87
+ }
88
+ export type TAuthorizationDomainScope = TConstValue<typeof AuthorizationDomainScopes>;
89
+ /**
90
+ * Engine-level vocabulary: the relation prefixes the Casbin MODEL declares — `p` for permission
91
+ * policies and `g`/`g2`…`g5` for grouping relations. This is the low-level building block that
92
+ * {@link AuthorizationPolicyVariants} maps onto (many app edge-types → one rule, e.g. both
93
+ * `assign_role` and `role_inherits` use `g`). Keep these in sync with the model's `[role_definition]`.
94
+ */
59
95
  export declare class CasbinRuleVariants {
60
- static readonly POLICY = "policy";
61
- static readonly GROUP = "group";
62
- /** Casbin line prefix for policy rules. */
96
+ /** Permission policy line. */
63
97
  static readonly P = "p";
64
- /** Casbin line prefix for grouping rules. */
98
+ /**
99
+ * Numbered in request-tuple order (`sub → dom → obj → act`) so the matcher reads left-to-right:
100
+ * g (sub), g2/g3 (dom), g4 (obj), g5 (act).
101
+ */
102
+ /** Grouping #1 — role membership + role inheritance (user→role, role→role). The `sub` axis. */
65
103
  static readonly G = "g";
66
- static readonly SCHEME_SET: Set<string>;
67
- static isValid(input: string): boolean;
104
+ /** Grouping #2 — user→domain membership (join_domain). The `dom` axis (membership). */
105
+ static readonly G2 = "g2";
106
+ /** Grouping #3 — domain hierarchy. The `dom` axis (nesting). */
107
+ static readonly G3 = "g3";
108
+ /** Grouping #4 — resource hierarchy. The `obj` axis. */
109
+ static readonly G4 = "g4";
110
+ /** Grouping #5 — action hierarchy. The `act` axis. */
111
+ static readonly G5 = "g5";
68
112
  }
69
113
  export type TCasbinRuleVariant = TConstValue<typeof CasbinRuleVariants>;
114
+ /**
115
+ * The kinds of "edge" stored in the single `PolicyDefinition` table. Every row links a `subject`
116
+ * (type + id) to a `target` (type + id); the `variant` column says WHAT kind of link it is.
117
+ *
118
+ * Picture the whole RBAC state as a graph — nodes are User / Role / Permission / Domain, and each
119
+ * PolicyDefinition row is one edge. `ScopedCasbinAdapter` reads these rows and emits one casbin line
120
+ * per edge. Each entry below carries:
121
+ * - `action` — the value stored in the DB `variant` column (what the adapter filters on).
122
+ * - `rule` — the casbin grouping/policy prefix the adapter emits for that edge (`p`, `g`, `g2`…).
123
+ *
124
+ * Per-USER edges (differ per user): GRANT, ASSIGN_ROLE, JOIN_DOMAIN.
125
+ * Shared HIERARCHY edges (same for everyone — describe the org structure, not a user):
126
+ * ROLE_INHERITS, RESOURCE_INHERITS, ACTION_INHERITS, DOMAIN_INHERITS.
127
+ */
128
+ export declare class AuthorizationPolicyVariants {
129
+ /**
130
+ * Give a Permission to a User or Role (the grant row also carries action / effect / domain).
131
+ * casbin `p`: `p, <Role|User>_<id>, <domain>, <permissionCode>, <action>, <allow|deny>`
132
+ * e.g. `p, Role_5, ANY_MEMBER, Order, read, allow` — "Role 5 may read Order in any joined domain".
133
+ */
134
+ static readonly GRANT: {
135
+ readonly action: "grant";
136
+ readonly rule: "p";
137
+ };
138
+ /**
139
+ * Give a User a Role (optionally scoped to a domain; no domain → `*` = every domain).
140
+ * casbin `g`: `g, User_<id>, Role_<id>, <domain|*>`
141
+ * e.g. `g, User_42, Role_5, *` — "User 42 holds Role 5 everywhere".
142
+ */
143
+ static readonly ASSIGN_ROLE: {
144
+ readonly action: "assign_role";
145
+ readonly rule: "g";
146
+ };
147
+ /**
148
+ * A Role inherits another Role (DAG). Shares the `g` relation with ASSIGN_ROLE so a
149
+ * user → role → parent-role chain resolves in one lookup. Emitted with domain `*`.
150
+ * casbin `g`: `g, Role_<child>, Role_<parent>, *`
151
+ * e.g. `g, Role_5, Role_9, *` — "Role 5 inherits everything Role 9 has".
152
+ */
153
+ static readonly ROLE_INHERITS: {
154
+ readonly action: "role_inherits";
155
+ readonly rule: "g";
156
+ };
157
+ /**
158
+ * A User is a member of a Domain. Powers the `ANY_MEMBER` grant scope — a grant with domain
159
+ * `ANY_MEMBER` applies in every domain the user joined. Matcher uses `g2(r.sub, r.dom)`.
160
+ * casbin `g2`: `g2, User_<id>, <Type>_<domainId>`
161
+ * e.g. `g2, User_42, Merchant_7` — "User 42 is a member of Merchant 7".
162
+ */
163
+ static readonly JOIN_DOMAIN: {
164
+ readonly action: "join_domain";
165
+ readonly rule: "g2";
166
+ };
167
+ /**
168
+ * DOMAIN axis (the `dom` of a request). One domain is nested under a parent domain.
169
+ * Matcher: `g3(r.dom, p.dom)` (+ self-link, so an exact domain always matches itself).
170
+ * casbin `g3`: `g3, <Type>_<childId>, <Type>_<parentId>`
171
+ * e.g. `g3, Branch_1, Company_9` — "a grant scoped to Company 9 also applies in Branch 1".
172
+ */
173
+ static readonly DOMAIN_INHERITS: {
174
+ readonly action: "domain_inherits";
175
+ readonly rule: "g3";
176
+ };
177
+ /**
178
+ * RESOURCE axis (the `obj` of a request). One resource is nested under a broader one — for
179
+ * NON-standard nesting only; dotted nesting (`Order.findById ⊂ Order`) is handled by `objectMatch`
180
+ * WITHOUT an edge. Matcher: `objectMatch(r.obj, p.obj) || g4(r.obj, p.obj)`.
181
+ * casbin `g4`: `g4, <childCode>, <parentCode>`
182
+ * e.g. `g4, OrderItem, Order` — "a grant on Order also covers OrderItem".
183
+ */
184
+ static readonly RESOURCE_INHERITS: {
185
+ readonly action: "resource_inherits";
186
+ readonly rule: "g4";
187
+ };
188
+ /**
189
+ * ACTION axis (the `act` of a request) — SAME shape as RESOURCE_INHERITS but a DIFFERENT axis: a
190
+ * narrow action is covered by a broader one. No dotted shortcut — needs an explicit edge.
191
+ * Matcher: `g5(r.act, p.act)`.
192
+ * casbin `g5`: `g5, <childAction>, <parentAction>`
193
+ * e.g. `g5, read, manage` — "a grant of manage also allows read".
194
+ * (g4 + g5 combine multiplicatively: a `manage Order` grant covers a `read OrderItem` request.)
195
+ */
196
+ static readonly ACTION_INHERITS: {
197
+ readonly action: "action_inherits";
198
+ readonly rule: "g5";
199
+ };
200
+ static readonly ACTION_SCHEME_SET: Set<string>;
201
+ static readonly RULE_SCHEME_SET: Set<string>;
202
+ static isValidAction(input: string): boolean;
203
+ static isValidRule(input: string): boolean;
204
+ }
205
+ export type TAuthorizationPolicyVariant = TConstValue<typeof AuthorizationPolicyVariants>;
70
206
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/common/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAEvE,qBAAa,aAAa;IACxB,MAAM,CAAC,QAAQ,CAAC,KAAK,yBAAyB;IAC9C,MAAM,CAAC,QAAQ,CAAC,kBAAkB,wBAAwB;IAC1D,MAAM,CAAC,QAAQ,CAAC,QAAQ,4BAA4B;CACrD;AAED,qBAAa,oBAAoB;IAC/B,MAAM,CAAC,QAAQ,CAAC,MAAM,YAAY;IAClC,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAU;IAC9B,MAAM,CAAC,QAAQ,CAAC,MAAM,YAAY;IAClC,MAAM,CAAC,QAAQ,CAAC,MAAM,YAAY;IAClC,MAAM,CAAC,QAAQ,CAAC,OAAO,aAAa;IAEpC,MAAM,CAAC,QAAQ,CAAC,UAAU,cAMvB;IAEH,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;CAGvC;AACD,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAE5E,qBAAa,sBAAsB;IACjC,MAAM,CAAC,QAAQ,CAAC,KAAK,WAAW;IAChC,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAU;IAC9B,MAAM,CAAC,QAAQ,CAAC,OAAO,aAAa;IAEpC,MAAM,CAAC,QAAQ,CAAC,UAAU,cAAkD;IAE5E,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAItC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,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C,WAAW;;;MAAkE;IAE7F;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CAAC,aAAa;;;MAAoE;IAEjG;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CAAC,WAAW;;;MAAmE;IAE9F;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CAAC,eAAe;;;MAGpB;IAEX;;;;;;OAMG;IACH,MAAM,CAAC,QAAQ,CAAC,iBAAiB;;;MAGtB;IAEX;;;;;;;OAOG;IACH,MAAM,CAAC,QAAQ,CAAC,eAAe;;;MAGpB;IAEX,MAAM,CAAC,QAAQ,CAAC,iBAAiB,cAQ9B;IAEH,MAAM,CAAC,QAAQ,CAAC,eAAe,cAQ5B;IAEH,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAI5C,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;CAG3C;AACD,MAAM,MAAM,2BAA2B,GAAG,WAAW,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
@@ -1,26 +1,39 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CasbinRuleVariants = exports.CasbinEnforcerModelDrivers = exports.CasbinEnforcerCachedDrivers = exports.AuthorizationEnforcerTypes = exports.AuthorizationRoles = exports.AuthorizationDecisions = exports.AuthorizationActions = exports.Authorization = void 0;
3
+ exports.AuthorizationPolicyVariants = exports.CasbinRuleVariants = exports.AuthorizationDomainScopes = exports.CasbinDomainMatchingFunctions = exports.CasbinEnforcerModelDrivers = exports.CasbinEnforcerCachedDrivers = exports.AuthorizationEnforcerTypes = exports.AuthorizationRoles = exports.AuthorizationDecisions = exports.AuthorizationActions = exports.Authorization = void 0;
4
4
  const authorization_role_model_1 = require("../models/authorization-role.model");
5
5
  class Authorization {
6
6
  static { this.RULES = 'authorization.rules'; }
7
7
  static { this.SKIP_AUTHORIZATION = 'authorization.skip'; }
8
8
  static { this.ENFORCER = 'authorization.enforcer'; }
9
+ static { this.DOMAIN = 'authorization.domain'; }
9
10
  }
10
11
  exports.Authorization = Authorization;
11
12
  class AuthorizationActions {
12
13
  static { this.CREATE = 'create'; }
13
- static { this.READ = 'read'; }
14
14
  static { this.UPDATE = 'update'; }
15
15
  static { this.DELETE = 'delete'; }
16
16
  static { this.EXECUTE = 'execute'; }
17
+ static { this.READ = 'read'; }
18
+ static { this.WRITE = 'write'; }
19
+ static { this.MANAGE = 'manage'; }
17
20
  static { this.SCHEME_SET = new Set([
18
21
  this.CREATE,
19
- this.READ,
20
22
  this.UPDATE,
21
23
  this.DELETE,
22
24
  this.EXECUTE,
25
+ this.READ,
26
+ this.WRITE,
27
+ this.MANAGE,
23
28
  ]); }
29
+ static { this.LATTICE = [
30
+ { child: this.READ, parent: this.MANAGE },
31
+ { child: this.WRITE, parent: this.MANAGE },
32
+ { child: this.EXECUTE, parent: this.MANAGE },
33
+ { child: this.CREATE, parent: this.WRITE },
34
+ { child: this.UPDATE, parent: this.WRITE },
35
+ { child: this.DELETE, parent: this.WRITE },
36
+ ]; }
24
37
  static isValid(input) {
25
38
  return this.SCHEME_SET.has(input);
26
39
  }
@@ -97,9 +110,8 @@ class AuthorizationEnforcerTypes {
97
110
  }
98
111
  exports.AuthorizationEnforcerTypes = AuthorizationEnforcerTypes;
99
112
  class CasbinEnforcerCachedDrivers {
100
- static { this.IN_MEMORY = 'in-memory'; }
101
113
  static { this.REDIS = 'redis'; }
102
- static { this.SCHEME_SET = new Set([this.IN_MEMORY, this.REDIS]); }
114
+ static { this.SCHEME_SET = new Set([this.REDIS]); }
103
115
  static isValid(input) {
104
116
  return this.SCHEME_SET.has(input);
105
117
  }
@@ -114,17 +126,163 @@ class CasbinEnforcerModelDrivers {
114
126
  }
115
127
  }
116
128
  exports.CasbinEnforcerModelDrivers = CasbinEnforcerModelDrivers;
117
- class CasbinRuleVariants {
118
- static { this.POLICY = 'policy'; }
119
- static { this.GROUP = 'group'; }
120
- /** Casbin line prefix for policy rules. */
121
- static { this.P = 'p'; }
122
- /** Casbin line prefix for grouping rules. */
123
- static { this.G = 'g'; }
124
- static { this.SCHEME_SET = new Set([this.POLICY, this.GROUP]); }
129
+ class CasbinDomainMatchingFunctions {
130
+ /** `*` is the only wildcard; exact compare otherwise. Safest for `Merchant_<uuid>` domains. */
131
+ static { this.KEY_MATCH = 'keyMatch'; }
132
+ /** Adds URL-path `:param` segment matching. */
133
+ static { this.KEY_MATCH_2 = 'keyMatch2'; }
134
+ /** Adds `{param}` segment matching. */
135
+ static { this.KEY_MATCH_3 = 'keyMatch3'; }
136
+ /** `{param}` matching with repeated-name equality checks. */
137
+ static { this.KEY_MATCH_4 = 'keyMatch4'; }
138
+ /** Treats the stored/policy value as a full regular expression. */
139
+ static { this.REGEX_MATCH = 'regexMatch'; }
140
+ static { this.SCHEME_SET = new Set([
141
+ this.KEY_MATCH,
142
+ this.KEY_MATCH_2,
143
+ this.KEY_MATCH_3,
144
+ this.KEY_MATCH_4,
145
+ this.REGEX_MATCH,
146
+ ]); }
147
+ static isValid(input) {
148
+ return this.SCHEME_SET.has(input);
149
+ }
150
+ }
151
+ exports.CasbinDomainMatchingFunctions = CasbinDomainMatchingFunctions;
152
+ class AuthorizationDomainScopes {
153
+ /** Grant applies in EVERY domain the subject is a member of (checked via join_domain / g2). */
154
+ static { this.ANY_MEMBER = 'ANY_MEMBER'; }
155
+ /** Grant applies system-wide, bypassing membership — super-admin only. */
156
+ static { this.SYSTEM_WIDE = 'SYSTEM_WIDE'; }
157
+ static { this.SCHEME_SET = new Set([this.ANY_MEMBER, this.SYSTEM_WIDE]); }
125
158
  static isValid(input) {
126
159
  return this.SCHEME_SET.has(input);
127
160
  }
128
161
  }
162
+ exports.AuthorizationDomainScopes = AuthorizationDomainScopes;
163
+ /**
164
+ * Engine-level vocabulary: the relation prefixes the Casbin MODEL declares — `p` for permission
165
+ * policies and `g`/`g2`…`g5` for grouping relations. This is the low-level building block that
166
+ * {@link AuthorizationPolicyVariants} maps onto (many app edge-types → one rule, e.g. both
167
+ * `assign_role` and `role_inherits` use `g`). Keep these in sync with the model's `[role_definition]`.
168
+ */
169
+ class CasbinRuleVariants {
170
+ /** Permission policy line. */
171
+ static { this.P = 'p'; }
172
+ /**
173
+ * Numbered in request-tuple order (`sub → dom → obj → act`) so the matcher reads left-to-right:
174
+ * g (sub), g2/g3 (dom), g4 (obj), g5 (act).
175
+ */
176
+ /** Grouping #1 — role membership + role inheritance (user→role, role→role). The `sub` axis. */
177
+ static { this.G = 'g'; }
178
+ /** Grouping #2 — user→domain membership (join_domain). The `dom` axis (membership). */
179
+ static { this.G2 = 'g2'; }
180
+ /** Grouping #3 — domain hierarchy. The `dom` axis (nesting). */
181
+ static { this.G3 = 'g3'; }
182
+ /** Grouping #4 — resource hierarchy. The `obj` axis. */
183
+ static { this.G4 = 'g4'; }
184
+ /** Grouping #5 — action hierarchy. The `act` axis. */
185
+ static { this.G5 = 'g5'; }
186
+ }
129
187
  exports.CasbinRuleVariants = CasbinRuleVariants;
188
+ /**
189
+ * The kinds of "edge" stored in the single `PolicyDefinition` table. Every row links a `subject`
190
+ * (type + id) to a `target` (type + id); the `variant` column says WHAT kind of link it is.
191
+ *
192
+ * Picture the whole RBAC state as a graph — nodes are User / Role / Permission / Domain, and each
193
+ * PolicyDefinition row is one edge. `ScopedCasbinAdapter` reads these rows and emits one casbin line
194
+ * per edge. Each entry below carries:
195
+ * - `action` — the value stored in the DB `variant` column (what the adapter filters on).
196
+ * - `rule` — the casbin grouping/policy prefix the adapter emits for that edge (`p`, `g`, `g2`…).
197
+ *
198
+ * Per-USER edges (differ per user): GRANT, ASSIGN_ROLE, JOIN_DOMAIN.
199
+ * Shared HIERARCHY edges (same for everyone — describe the org structure, not a user):
200
+ * ROLE_INHERITS, RESOURCE_INHERITS, ACTION_INHERITS, DOMAIN_INHERITS.
201
+ */
202
+ class AuthorizationPolicyVariants {
203
+ /**
204
+ * Give a Permission to a User or Role (the grant row also carries action / effect / domain).
205
+ * casbin `p`: `p, <Role|User>_<id>, <domain>, <permissionCode>, <action>, <allow|deny>`
206
+ * e.g. `p, Role_5, ANY_MEMBER, Order, read, allow` — "Role 5 may read Order in any joined domain".
207
+ */
208
+ static { this.GRANT = { action: 'grant', rule: CasbinRuleVariants.P }; }
209
+ /**
210
+ * Give a User a Role (optionally scoped to a domain; no domain → `*` = every domain).
211
+ * casbin `g`: `g, User_<id>, Role_<id>, <domain|*>`
212
+ * e.g. `g, User_42, Role_5, *` — "User 42 holds Role 5 everywhere".
213
+ */
214
+ static { this.ASSIGN_ROLE = { action: 'assign_role', rule: CasbinRuleVariants.G }; }
215
+ /**
216
+ * A Role inherits another Role (DAG). Shares the `g` relation with ASSIGN_ROLE so a
217
+ * user → role → parent-role chain resolves in one lookup. Emitted with domain `*`.
218
+ * casbin `g`: `g, Role_<child>, Role_<parent>, *`
219
+ * e.g. `g, Role_5, Role_9, *` — "Role 5 inherits everything Role 9 has".
220
+ */
221
+ static { this.ROLE_INHERITS = { action: 'role_inherits', rule: CasbinRuleVariants.G }; }
222
+ /**
223
+ * A User is a member of a Domain. Powers the `ANY_MEMBER` grant scope — a grant with domain
224
+ * `ANY_MEMBER` applies in every domain the user joined. Matcher uses `g2(r.sub, r.dom)`.
225
+ * casbin `g2`: `g2, User_<id>, <Type>_<domainId>`
226
+ * e.g. `g2, User_42, Merchant_7` — "User 42 is a member of Merchant 7".
227
+ */
228
+ static { this.JOIN_DOMAIN = { action: 'join_domain', rule: CasbinRuleVariants.G2 }; }
229
+ /**
230
+ * DOMAIN axis (the `dom` of a request). One domain is nested under a parent domain.
231
+ * Matcher: `g3(r.dom, p.dom)` (+ self-link, so an exact domain always matches itself).
232
+ * casbin `g3`: `g3, <Type>_<childId>, <Type>_<parentId>`
233
+ * e.g. `g3, Branch_1, Company_9` — "a grant scoped to Company 9 also applies in Branch 1".
234
+ */
235
+ static { this.DOMAIN_INHERITS = {
236
+ action: 'domain_inherits',
237
+ rule: CasbinRuleVariants.G3,
238
+ }; }
239
+ /**
240
+ * RESOURCE axis (the `obj` of a request). One resource is nested under a broader one — for
241
+ * NON-standard nesting only; dotted nesting (`Order.findById ⊂ Order`) is handled by `objectMatch`
242
+ * WITHOUT an edge. Matcher: `objectMatch(r.obj, p.obj) || g4(r.obj, p.obj)`.
243
+ * casbin `g4`: `g4, <childCode>, <parentCode>`
244
+ * e.g. `g4, OrderItem, Order` — "a grant on Order also covers OrderItem".
245
+ */
246
+ static { this.RESOURCE_INHERITS = {
247
+ action: 'resource_inherits',
248
+ rule: CasbinRuleVariants.G4,
249
+ }; }
250
+ /**
251
+ * ACTION axis (the `act` of a request) — SAME shape as RESOURCE_INHERITS but a DIFFERENT axis: a
252
+ * narrow action is covered by a broader one. No dotted shortcut — needs an explicit edge.
253
+ * Matcher: `g5(r.act, p.act)`.
254
+ * casbin `g5`: `g5, <childAction>, <parentAction>`
255
+ * e.g. `g5, read, manage` — "a grant of manage also allows read".
256
+ * (g4 + g5 combine multiplicatively: a `manage Order` grant covers a `read OrderItem` request.)
257
+ */
258
+ static { this.ACTION_INHERITS = {
259
+ action: 'action_inherits',
260
+ rule: CasbinRuleVariants.G5,
261
+ }; }
262
+ static { this.ACTION_SCHEME_SET = new Set([
263
+ this.GRANT.action.toString(),
264
+ this.ASSIGN_ROLE.action.toString(),
265
+ this.ROLE_INHERITS.action.toString(),
266
+ this.JOIN_DOMAIN.action.toString(),
267
+ this.DOMAIN_INHERITS.action.toString(),
268
+ this.RESOURCE_INHERITS.action.toString(),
269
+ this.ACTION_INHERITS.action.toString(),
270
+ ]); }
271
+ static { this.RULE_SCHEME_SET = new Set([
272
+ this.GRANT.rule.toString(),
273
+ this.ASSIGN_ROLE.rule.toString(),
274
+ this.ROLE_INHERITS.rule.toString(),
275
+ this.JOIN_DOMAIN.rule.toString(),
276
+ this.DOMAIN_INHERITS.rule.toString(),
277
+ this.RESOURCE_INHERITS.rule.toString(),
278
+ this.ACTION_INHERITS.rule.toString(),
279
+ ]); }
280
+ static isValidAction(input) {
281
+ return this.ACTION_SCHEME_SET.has(input);
282
+ }
283
+ static isValidRule(input) {
284
+ return this.RULE_SCHEME_SET.has(input);
285
+ }
286
+ }
287
+ exports.AuthorizationPolicyVariants = AuthorizationPolicyVariants;
130
288
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/common/constants.ts"],"names":[],"mappings":";;;AACA,iFAAuE;AAEvE,MAAa,aAAa;aACR,UAAK,GAAG,qBAAqB,CAAC;aAC9B,uBAAkB,GAAG,oBAAoB,CAAC;aAC1C,aAAQ,GAAG,wBAAwB,CAAC;;AAHtD,sCAIC;AAED,MAAa,oBAAoB;aACf,WAAM,GAAG,QAAQ,CAAC;aAClB,SAAI,GAAG,MAAM,CAAC;aACd,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAClB,YAAO,GAAG,SAAS,CAAC;aAEpB,eAAU,GAAG,IAAI,GAAG,CAAC;QACnC,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,OAAO;KACb,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAjBH,oDAkBC;AAGD,MAAa,sBAAsB;aACjB,UAAK,GAAG,OAAO,CAAC;aAChB,SAAI,GAAG,MAAM,CAAC;aACd,YAAO,GAAG,SAAS,CAAC;aAEpB,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAE5E,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,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AI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AARH,gEASC;AAID,MAAa,kBAAkB;aACb,WAAM,GAAG,QAAQ,CAAC;aAClB,UAAK,GAAG,OAAO,CAAC;IAEhC,2CAA2C;aAC3B,MAAC,GAAG,GAAG,CAAC;IACxB,6CAA6C;aAC7B,MAAC,GAAG,GAAG,CAAC;aAER,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAEhE,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAbH,gDAcC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/common/constants.ts"],"names":[],"mappings":";;;AACA,iFAAuE;AAEvE,MAAa,aAAa;aACR,UAAK,GAAG,qBAAqB,CAAC;aAC9B,uBAAkB,GAAG,oBAAoB,CAAC;aAC1C,aAAQ,GAAG,wBAAwB,CAAC;aACpC,WAAM,GAAG,sBAAsB,CAAC;;AAJlD,sCAKC;AAED,MAAa,oBAAoB;aACf,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAClB,YAAO,GAAG,SAAS,CAAC;aAEpB,SAAI,GAAG,MAAM,CAAC;aACd,UAAK,GAAG,OAAO,CAAC;aAChB,WAAM,GAAG,QAAQ,CAAC;aAElB,eAAU,GAAG,IAAI,GAAG,CAAC;QACnC,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,OAAO;QAEZ,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,MAAM;KACZ,CAAC,CAAC;aAEa,YAAO,GAGlB;QACH,EAAE,K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AI,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE;QAClC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE;QAChC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,EAAE;QACpC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,EAAE;QACtC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,EAAE;KACrC,CAAC,CAAC;IAEH,MAAM,CAAC,aAAa,CAAC,KAAa;QAChC,OAAO,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,KAAa;QAC9B,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;;AA7FH,kEA8FC"}
@@ -1,4 +1,8 @@
1
1
  export * from './constants';
2
2
  export * from './keys';
3
+ export * from './object-match';
4
+ export * from './permission-builder';
5
+ export * from './policy-builder';
6
+ export * from './resolve-request-domain';
3
7
  export * from './types';
4
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,SAAS,CAAC"}
@@ -16,5 +16,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./constants"), exports);
18
18
  __exportStar(require("./keys"), exports);
19
+ __exportStar(require("./object-match"), exports);
20
+ __exportStar(require("./permission-builder"), exports);
21
+ __exportStar(require("./policy-builder"), exports);
22
+ __exportStar(require("./resolve-request-domain"), exports);
19
23
  __exportStar(require("./types"), exports);
20
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,yCAAuB;AACvB,0CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,yCAAuB;AACvB,iDAA+B;AAC/B,uDAAqC;AACrC,mDAAiC;AACjC,2DAAyC;AACzC,0CAAwB"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Resource-hierarchy matcher for casbin `g4`. Decides whether a requested resource node
3
+ * falls under a granted resource node WITHOUT storing the "standard" edges
4
+ * (endpoint ⊂ subject ⊂ *), which are derivable from the dotted `code`.
5
+ *
6
+ * Non-standard edges (e.g. `OrderItem ⊂ Order`) are NOT covered here — those are stored as
7
+ * explicit `resource_inherits` (g4) links and resolved by casbin's role manager.
8
+ *
9
+ * Registered in TWO ways by the enforcer (both required):
10
+ * 1. `enforcer.addFunction('objectMatch', objectMatch)` — lets the matcher call
11
+ * `objectMatch(r.obj, p.obj)` directly for "graph-free" prefix/wildcard matching. casbin's
12
+ * role-manager `hasLink` only traverses stored nodes, so a `g4(...)`-only call can't match
13
+ * `p.obj = '*'` or a subject that isn't a stored g4 vertex — the direct call covers those.
14
+ * 2. `enforcer.addNamedMatchingFunc('g4', objectMatch)` — applies the same semantics when
15
+ * traversing explicit stored `resource_inherits` (g4) edges.
16
+ *
17
+ * @param requested the resource on the request (r.obj), e.g. `Activation.findById`
18
+ * @param granted the resource on the policy (p.obj), e.g. `Activation` or `*`
19
+ */
20
+ export declare const objectMatch: (requested: string, granted: string) => boolean;
21
+ //# sourceMappingURL=object-match.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object-match.d.ts","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/common/object-match.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,WAAW,GAAI,WAAW,MAAM,EAAE,SAAS,MAAM,KAAG,OAUhE,CAAC"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.objectMatch = void 0;
4
+ /**
5
+ * Resource-hierarchy matcher for casbin `g4`. Decides whether a requested resource node
6
+ * falls under a granted resource node WITHOUT storing the "standard" edges
7
+ * (endpoint ⊂ subject ⊂ *), which are derivable from the dotted `code`.
8
+ *
9
+ * Non-standard edges (e.g. `OrderItem ⊂ Order`) are NOT covered here — those are stored as
10
+ * explicit `resource_inherits` (g4) links and resolved by casbin's role manager.
11
+ *
12
+ * Registered in TWO ways by the enforcer (both required):
13
+ * 1. `enforcer.addFunction('objectMatch', objectMatch)` — lets the matcher call
14
+ * `objectMatch(r.obj, p.obj)` directly for "graph-free" prefix/wildcard matching. casbin's
15
+ * role-manager `hasLink` only traverses stored nodes, so a `g4(...)`-only call can't match
16
+ * `p.obj = '*'` or a subject that isn't a stored g4 vertex — the direct call covers those.
17
+ * 2. `enforcer.addNamedMatchingFunc('g4', objectMatch)` — applies the same semantics when
18
+ * traversing explicit stored `resource_inherits` (g4) edges.
19
+ *
20
+ * @param requested the resource on the request (r.obj), e.g. `Activation.findById`
21
+ * @param granted the resource on the policy (p.obj), e.g. `Activation` or `*`
22
+ */
23
+ const objectMatch = (requested, granted) => {
24
+ if (granted === '*') {
25
+ return true;
26
+ }
27
+ if (requested === granted) {
28
+ return true;
29
+ }
30
+ return requested.startsWith(`${granted}.`);
31
+ };
32
+ exports.objectMatch = objectMatch;
33
+ //# sourceMappingURL=object-match.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object-match.js","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/common/object-match.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACI,MAAM,WAAW,GAAG,CAAC,SAAiB,EAAE,OAAe,EAAW,EAAE;IACzE,IAAI,OAAO,KAAK,GAAG,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,SAAS,CAAC,UAAU,CAAC,GAAG,OAAO,GAAG,CAAC,CAAC;AAC7C,CAAC,CAAC;AAVW,QAAA,WAAW,eAUtB"}
@@ -0,0 +1,92 @@
1
+ import { IdType } from '../../../../base';
2
+ import { TNullable } from '../../../../helpers';
3
+ import { TAuthorizationAction } from './constants';
4
+ /**
5
+ * Builders for `Permission` catalog rows (the `obj` axis the scoped matcher resolves).
6
+ *
7
+ * Generic over the name/description type (`TName`) so an app with i18n `name`/`description` columns and
8
+ * one with plain-text names both fit. Produces the framework-owned columns
9
+ * (code/subject/method/action/scope/description/parentId); `description` defaults to `null`.
10
+ * App-specific columns are added by the caller.
11
+ */
12
+ export declare class AuthorizationPermissionBuilder {
13
+ /** Sentinel `method` for a coarse resource node (a grant target that is not a route). */
14
+ static readonly RESOURCE_NODE_METHOD = "*";
15
+ /** Standard repository method → base action. Unlisted methods (custom ops, aggregates) resolve to `execute`. */
16
+ static readonly METHOD_ACTIONS: Readonly<Record<string, TAuthorizationAction>>;
17
+ /** The CRUD methods {@link crud} generates by default. */
18
+ static readonly DEFAULT_CRUD_METHODS: ReadonlyArray<string>;
19
+ /** Base action for a method: a known CRUD method maps to read/create/update/delete; anything else → `execute`. */
20
+ static actionForMethod(method: string): TAuthorizationAction;
21
+ /** One operation-level permission, `code = <subject>.<method>`. `action` defaults to {@link actionForMethod}. */
22
+ static operation<TName>(opts: {
23
+ subject: string;
24
+ method: string;
25
+ scope: string;
26
+ name: TName;
27
+ description?: TNullable<TName>;
28
+ action?: TAuthorizationAction;
29
+ parentId?: TNullable<IdType>;
30
+ }): {
31
+ code: string;
32
+ subject: string;
33
+ method: string;
34
+ action: string;
35
+ scope: string;
36
+ description: NonNullable<TName> | null;
37
+ parentId: IdType | null;
38
+ name: TName;
39
+ };
40
+ /**
41
+ * A coarse resource node (module or subject) used as a grant target, e.g. `Sale` or `SaleOrder`.
42
+ * `code` is the bare name (no dotted method); `method` is the {@link RESOURCE_NODE_METHOD} sentinel.
43
+ * `action` defaults to `manage` (the broadest), though the grant on this node carries its own action.
44
+ */
45
+ static resourceNode<TName>(opts: {
46
+ code: string;
47
+ subject?: string;
48
+ scope: string;
49
+ name: TName;
50
+ description?: TNullable<TName>;
51
+ action?: TAuthorizationAction;
52
+ parentId?: TNullable<IdType>;
53
+ }): {
54
+ code: string;
55
+ subject: string;
56
+ method: string;
57
+ action: string;
58
+ scope: string;
59
+ description: NonNullable<TName> | null;
60
+ parentId: IdType | null;
61
+ name: TName;
62
+ };
63
+ /**
64
+ * The CRUD permission set for a subject. `name` (and optional `description`) are per-method formatters,
65
+ * so the app supplies its own labels/i18n; the framework only owns the method→action map and code shape.
66
+ */
67
+ static crud<TName>(opts: {
68
+ subject: string;
69
+ scope: string;
70
+ name: (ctx: {
71
+ subject: string;
72
+ method: string;
73
+ action: TAuthorizationAction;
74
+ }) => TName;
75
+ description?: (ctx: {
76
+ subject: string;
77
+ method: string;
78
+ action: TAuthorizationAction;
79
+ }) => TNullable<TName>;
80
+ methods?: ReadonlyArray<string>;
81
+ }): {
82
+ code: string;
83
+ subject: string;
84
+ method: string;
85
+ action: string;
86
+ scope: string;
87
+ description: NonNullable<TName> | null;
88
+ parentId: IdType | null;
89
+ name: TName;
90
+ }[];
91
+ }
92
+ //# sourceMappingURL=permission-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permission-builder.d.ts","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/common/permission-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAwB,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEzE;;;;;;;GAOG;AACH,qBAAa,8BAA8B;IACzC,yFAAyF;IACzF,MAAM,CAAC,QAAQ,CAAC,oBAAoB,OAAO;IAE3C,gHAAgH;IAChH,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAU5E;IAEF,0DAA0D;IAC1D,MAAM,CAAC,QAAQ,CAAC,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAAC,CAUzD;IAEF,kHAAkH;IAClH,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB;IAI5D,iHAAiH;IACjH,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE;QAC5B,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,KAAK,CAAC;QACZ,WAAW,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC;QAC/B,MAAM,CAAC,EAAE,oBAAoB,CAAC;QAC9B,QAAQ,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;KAC9B;;;;;;;;;;IAaD;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE;QAC/B,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,KAAK,CAAC;QACZ,WAAW,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,C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