@venizia/ignis 0.0.9-2 → 0.0.9-20

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 (203) hide show
  1. package/dist/base/metadata/persistents.d.ts.map +1 -1
  2. package/dist/base/metadata/persistents.js +6 -0
  3. package/dist/base/metadata/persistents.js.map +1 -1
  4. package/dist/base/middlewares/app-error/app-error.middleware.d.ts +15 -0
  5. package/dist/base/middlewares/app-error/app-error.middleware.d.ts.map +1 -0
  6. package/dist/base/middlewares/app-error/app-error.middleware.js +81 -0
  7. package/dist/base/middlewares/app-error/app-error.middleware.js.map +1 -0
  8. package/dist/base/middlewares/app-error/database.handler.d.ts +20 -0
  9. package/dist/base/middlewares/app-error/database.handler.d.ts.map +1 -0
  10. package/dist/base/middlewares/app-error/database.handler.js +55 -0
  11. package/dist/base/middlewares/app-error/database.handler.js.map +1 -0
  12. package/dist/base/middlewares/app-error/definition.d.ts +59 -0
  13. package/dist/base/middlewares/app-error/definition.d.ts.map +1 -0
  14. package/dist/base/middlewares/app-error/definition.js +98 -0
  15. package/dist/base/middlewares/app-error/definition.js.map +1 -0
  16. package/dist/base/middlewares/app-error/index.d.ts +2 -0
  17. package/dist/base/middlewares/app-error/index.d.ts.map +1 -0
  18. package/dist/{components/auth/authorize/models/abilities → base/middlewares/app-error}/index.js +1 -2
  19. package/dist/base/middlewares/app-error/index.js.map +1 -0
  20. package/dist/base/middlewares/app-error/types.d.ts +18 -0
  21. package/dist/base/middlewares/app-error/types.d.ts.map +1 -0
  22. package/dist/base/middlewares/app-error/types.js +3 -0
  23. package/dist/base/middlewares/app-error/types.js.map +1 -0
  24. package/dist/base/middlewares/app-error/zod.handler.d.ts +28 -0
  25. package/dist/base/middlewares/app-error/zod.handler.d.ts.map +1 -0
  26. package/dist/base/middlewares/app-error/zod.handler.js +64 -0
  27. package/dist/base/middlewares/app-error/zod.handler.js.map +1 -0
  28. package/dist/base/middlewares/emoji-favicon/emoji-favicon.middleware.d.ts.map +1 -0
  29. package/dist/base/middlewares/emoji-favicon/emoji-favicon.middleware.js.map +1 -0
  30. package/dist/base/middlewares/emoji-favicon/index.d.ts +2 -0
  31. package/dist/base/middlewares/emoji-favicon/index.d.ts.map +1 -0
  32. package/dist/base/middlewares/emoji-favicon/index.js +18 -0
  33. package/dist/base/middlewares/emoji-favicon/index.js.map +1 -0
  34. package/dist/base/middlewares/index.d.ts +4 -4
  35. package/dist/base/middlewares/index.d.ts.map +1 -1
  36. package/dist/base/middlewares/index.js +4 -4
  37. package/dist/base/middlewares/index.js.map +1 -1
  38. package/dist/base/middlewares/not-found/index.d.ts +2 -0
  39. package/dist/base/middlewares/not-found/index.d.ts.map +1 -0
  40. package/dist/base/middlewares/not-found/index.js +18 -0
  41. package/dist/base/middlewares/not-found/index.js.map +1 -0
  42. package/dist/base/middlewares/{not-found.middleware.d.ts → not-found/not-found.middleware.d.ts} +0 -1
  43. package/dist/base/middlewares/not-found/not-found.middleware.d.ts.map +1 -0
  44. package/dist/base/middlewares/{not-found.middleware.js → not-found/not-found.middleware.js} +2 -3
  45. package/dist/base/middlewares/{not-found.middleware.js.map → not-found/not-found.middleware.js.map} +1 -1
  46. package/dist/base/middlewares/request-spy/index.d.ts +2 -0
  47. package/dist/base/middlewares/request-spy/index.d.ts.map +1 -0
  48. package/dist/base/middlewares/request-spy/index.js +18 -0
  49. package/dist/base/middlewares/request-spy/index.js.map +1 -0
  50. package/dist/base/middlewares/{request-spy.middleware.d.ts → request-spy/request-spy.middleware.d.ts} +1 -1
  51. package/dist/base/middlewares/request-spy/request-spy.middleware.d.ts.map +1 -0
  52. package/dist/base/middlewares/{request-spy.middleware.js → request-spy/request-spy.middleware.js} +1 -1
  53. package/dist/base/middlewares/request-spy/request-spy.middleware.js.map +1 -0
  54. package/dist/base/models/common/columns.d.ts +22 -0
  55. package/dist/base/models/common/columns.d.ts.map +1 -0
  56. package/dist/base/models/common/columns.js +43 -0
  57. package/dist/base/models/common/columns.js.map +1 -0
  58. package/dist/base/models/common/index.d.ts +1 -0
  59. package/dist/base/models/common/index.d.ts.map +1 -1
  60. package/dist/base/models/common/index.js +1 -0
  61. package/dist/base/models/common/index.js.map +1 -1
  62. package/dist/base/models/enrichers/principal.enricher.d.ts +6 -5
  63. package/dist/base/models/enrichers/principal.enricher.d.ts.map +1 -1
  64. package/dist/base/models/enrichers/principal.enricher.js +8 -3
  65. package/dist/base/models/enrichers/principal.enricher.js.map +1 -1
  66. package/dist/base/models/enrichers/tz.enricher.d.ts +9 -8
  67. package/dist/base/models/enrichers/tz.enricher.d.ts.map +1 -1
  68. package/dist/base/models/enrichers/tz.enricher.js +10 -10
  69. package/dist/base/models/enrichers/tz.enricher.js.map +1 -1
  70. package/dist/base/repositories/common/types.d.ts +6 -2
  71. package/dist/base/repositories/common/types.d.ts.map +1 -1
  72. package/dist/base/repositories/common/types.js +6 -4
  73. package/dist/base/repositories/common/types.js.map +1 -1
  74. package/dist/base/repositories/core/abstract.d.ts +2 -0
  75. package/dist/base/repositories/core/abstract.d.ts.map +1 -1
  76. package/dist/base/repositories/core/persistable.d.ts +6 -1
  77. package/dist/base/repositories/core/persistable.d.ts.map +1 -1
  78. package/dist/base/repositories/core/persistable.js +18 -6
  79. package/dist/base/repositories/core/persistable.js.map +1 -1
  80. package/dist/base/repositories/core/readable.d.ts.map +1 -1
  81. package/dist/base/repositories/core/readable.js +21 -5
  82. package/dist/base/repositories/core/readable.js.map +1 -1
  83. package/dist/base/repositories/core/soft-deletable.d.ts +1 -1
  84. package/dist/base/repositories/core/soft-deletable.d.ts.map +1 -1
  85. package/dist/base/repositories/mixins/default-filter.d.ts +3 -0
  86. package/dist/base/repositories/mixins/default-filter.d.ts.map +1 -1
  87. package/dist/base/repositories/mixins/default-filter.js +11 -0
  88. package/dist/base/repositories/mixins/default-filter.js.map +1 -1
  89. package/dist/base/repositories/operators/filter.d.ts +4 -0
  90. package/dist/base/repositories/operators/filter.d.ts.map +1 -1
  91. package/dist/base/repositories/operators/filter.js +23 -2
  92. package/dist/base/repositories/operators/filter.js.map +1 -1
  93. package/dist/components/auth/authorize/adapters/base-filtered.d.ts +26 -56
  94. package/dist/components/auth/authorize/adapters/base-filtered.d.ts.map +1 -1
  95. package/dist/components/auth/authorize/adapters/base-filtered.js +23 -70
  96. package/dist/components/auth/authorize/adapters/base-filtered.js.map +1 -1
  97. package/dist/components/auth/authorize/adapters/index.d.ts +2 -1
  98. package/dist/components/auth/authorize/adapters/index.d.ts.map +1 -1
  99. package/dist/components/auth/authorize/adapters/index.js +2 -1
  100. package/dist/components/auth/authorize/adapters/index.js.map +1 -1
  101. package/dist/components/auth/authorize/adapters/scoped-casbin.adapter.d.ts +138 -0
  102. package/dist/components/auth/authorize/adapters/scoped-casbin.adapter.d.ts.map +1 -0
  103. package/dist/components/auth/authorize/adapters/scoped-casbin.adapter.js +300 -0
  104. package/dist/components/auth/authorize/adapters/scoped-casbin.adapter.js.map +1 -0
  105. package/dist/components/auth/authorize/adapters/types.d.ts +31 -0
  106. package/dist/components/auth/authorize/adapters/types.d.ts.map +1 -0
  107. package/dist/components/auth/authorize/adapters/types.js +3 -0
  108. package/dist/components/auth/authorize/adapters/types.js.map +1 -0
  109. package/dist/components/auth/authorize/common/constants.d.ts +144 -8
  110. package/dist/components/auth/authorize/common/constants.d.ts.map +1 -1
  111. package/dist/components/auth/authorize/common/constants.js +171 -13
  112. package/dist/components/auth/authorize/common/constants.js.map +1 -1
  113. package/dist/components/auth/authorize/common/index.d.ts +4 -0
  114. package/dist/components/auth/authorize/common/index.d.ts.map +1 -1
  115. package/dist/components/auth/authorize/common/index.js +4 -0
  116. package/dist/components/auth/authorize/common/index.js.map +1 -1
  117. package/dist/components/auth/authorize/common/object-match.d.ts +21 -0
  118. package/dist/components/auth/authorize/common/object-match.d.ts.map +1 -0
  119. package/dist/components/auth/authorize/common/object-match.js +33 -0
  120. package/dist/components/auth/authorize/common/object-match.js.map +1 -0
  121. package/dist/components/auth/authorize/common/permission-builder.d.ts +92 -0
  122. package/dist/components/auth/authorize/common/permission-builder.d.ts.map +1 -0
  123. package/dist/components/auth/authorize/common/permission-builder.js +99 -0
  124. package/dist/components/auth/authorize/common/permission-builder.js.map +1 -0
  125. package/dist/components/auth/authorize/common/policy-builder.d.ts +183 -0
  126. package/dist/components/auth/authorize/common/policy-builder.d.ts.map +1 -0
  127. package/dist/components/auth/authorize/common/policy-builder.js +130 -0
  128. package/dist/components/auth/authorize/common/policy-builder.js.map +1 -0
  129. package/dist/components/auth/authorize/common/resolve-request-domain.d.ts +20 -0
  130. package/dist/components/auth/authorize/common/resolve-request-domain.d.ts.map +1 -0
  131. package/dist/components/auth/authorize/common/resolve-request-domain.js +59 -0
  132. package/dist/components/auth/authorize/common/resolve-request-domain.js.map +1 -0
  133. package/dist/components/auth/authorize/common/types.d.ts +70 -23
  134. package/dist/components/auth/authorize/common/types.d.ts.map +1 -1
  135. package/dist/components/auth/authorize/enforcers/casbin.enforcer.d.ts +120 -28
  136. package/dist/components/auth/authorize/enforcers/casbin.enforcer.d.ts.map +1 -1
  137. package/dist/components/auth/authorize/enforcers/casbin.enforcer.js +324 -124
  138. package/dist/components/auth/authorize/enforcers/casbin.enforcer.js.map +1 -1
  139. package/dist/components/auth/authorize/enforcers/enforcer-registry.d.ts +19 -1
  140. package/dist/components/auth/authorize/enforcers/enforcer-registry.d.ts.map +1 -1
  141. package/dist/components/auth/authorize/enforcers/enforcer-registry.js +23 -0
  142. package/dist/components/auth/authorize/enforcers/enforcer-registry.js.map +1 -1
  143. package/dist/components/auth/authorize/enforcers/index.d.ts +1 -0
  144. package/dist/components/auth/authorize/enforcers/index.d.ts.map +1 -1
  145. package/dist/components/auth/authorize/enforcers/index.js +1 -0
  146. package/dist/components/auth/authorize/enforcers/index.js.map +1 -1
  147. package/dist/components/auth/authorize/enforcers/models/index.d.ts +2 -0
  148. package/dist/components/auth/authorize/enforcers/models/index.d.ts.map +1 -0
  149. package/dist/components/auth/authorize/enforcers/models/index.js +18 -0
  150. package/dist/components/auth/authorize/enforcers/models/index.js.map +1 -0
  151. package/dist/components/auth/authorize/enforcers/models/rbac-domain.model.d.ts +32 -0
  152. package/dist/components/auth/authorize/enforcers/models/rbac-domain.model.d.ts.map +1 -0
  153. package/dist/components/auth/authorize/enforcers/models/rbac-domain.model.js +54 -0
  154. package/dist/components/auth/authorize/enforcers/models/rbac-domain.model.js.map +1 -0
  155. package/dist/components/auth/authorize/models/index.d.ts +0 -1
  156. package/dist/components/auth/authorize/models/index.d.ts.map +1 -1
  157. package/dist/components/auth/authorize/models/index.js +0 -1
  158. package/dist/components/auth/authorize/models/index.js.map +1 -1
  159. package/dist/components/auth/authorize/providers/authorization.provider.d.ts.map +1 -1
  160. package/dist/components/auth/authorize/providers/authorization.provider.js +12 -0
  161. package/dist/components/auth/authorize/providers/authorization.provider.js.map +1 -1
  162. package/dist/components/auth/models/entities/permission.model.d.ts +2 -0
  163. package/dist/components/auth/models/entities/permission.model.d.ts.map +1 -1
  164. package/dist/components/auth/models/entities/permission.model.js +4 -0
  165. package/dist/components/auth/models/entities/permission.model.js.map +1 -1
  166. package/dist/components/auth/models/entities/user.model.d.ts +16 -2
  167. package/dist/components/auth/models/entities/user.model.d.ts.map +1 -1
  168. package/dist/components/auth/models/entities/user.model.js +3 -2
  169. package/dist/components/auth/models/entities/user.model.js.map +1 -1
  170. package/dist/components/mail/helpers/executors/internal-queue-executor.helper.d.ts.map +1 -1
  171. package/dist/components/mail/helpers/executors/internal-queue-executor.helper.js +1 -1
  172. package/dist/components/mail/helpers/executors/internal-queue-executor.helper.js.map +1 -1
  173. package/dist/components/static-asset/models/base.model.d.ts +24 -16
  174. package/dist/components/static-asset/models/base.model.d.ts.map +1 -1
  175. package/dist/helpers/inversion/common/types.d.ts +2 -0
  176. package/dist/helpers/inversion/common/types.d.ts.map +1 -1
  177. package/package.json +28 -27
  178. package/dist/base/middlewares/app-error.middleware.d.ts +0 -8
  179. package/dist/base/middlewares/app-error.middleware.d.ts.map +0 -1
  180. package/dist/base/middlewares/app-error.middleware.js +0 -138
  181. package/dist/base/middlewares/app-error.middleware.js.map +0 -1
  182. package/dist/base/middlewares/emoji-favicon.middleware.d.ts.map +0 -1
  183. package/dist/base/middlewares/emoji-favicon.middleware.js.map +0 -1
  184. package/dist/base/middlewares/not-found.middleware.d.ts.map +0 -1
  185. package/dist/base/middlewares/request-spy.middleware.d.ts.map +0 -1
  186. package/dist/base/middlewares/request-spy.middleware.js.map +0 -1
  187. package/dist/components/auth/authorize/adapters/drizzle-casbin.d.ts +0 -40
  188. package/dist/components/auth/authorize/adapters/drizzle-casbin.d.ts.map +0 -1
  189. package/dist/components/auth/authorize/adapters/drizzle-casbin.js +0 -99
  190. package/dist/components/auth/authorize/adapters/drizzle-casbin.js.map +0 -1
  191. package/dist/components/auth/authorize/models/abilities/index.d.ts +0 -3
  192. package/dist/components/auth/authorize/models/abilities/index.d.ts.map +0 -1
  193. package/dist/components/auth/authorize/models/abilities/index.js.map +0 -1
  194. package/dist/components/auth/authorize/models/abilities/string-action.model.d.ts +0 -14
  195. package/dist/components/auth/authorize/models/abilities/string-action.model.d.ts.map +0 -1
  196. package/dist/components/auth/authorize/models/abilities/string-action.model.js +0 -23
  197. package/dist/components/auth/authorize/models/abilities/string-action.model.js.map +0 -1
  198. package/dist/components/auth/authorize/models/abilities/string-resource.model.d.ts +0 -13
  199. package/dist/components/auth/authorize/models/abilities/string-resource.model.d.ts.map +0 -1
  200. package/dist/components/auth/authorize/models/abilities/string-resource.model.js +0 -19
  201. package/dist/components/auth/authorize/models/abilities/string-resource.model.js.map +0 -1
  202. /package/dist/base/middlewares/{emoji-favicon.middleware.d.ts → emoji-favicon/emoji-favicon.middleware.d.ts} +0 -0
  203. /package/dist/base/middlewares/{emoji-favicon.middleware.js → emoji-favicon/emoji-favicon.middleware.js} +0 -0
@@ -0,0 +1,183 @@
1
+ import { IdType } from '../../../../base';
2
+ import { TNullable } from '../../../../helpers';
3
+ import { TAuthorizationAction, TAuthorizationDecision } from './constants';
4
+ /** A grant/assignment domain: a scope literal (`SYSTEM_WIDE`/`ANY_MEMBER`) or a typed domain entity. */
5
+ export type TPolicyDomainInput = string | {
6
+ type: string;
7
+ id: IdType;
8
+ };
9
+ export declare class AuthorizationPolicyBuilder {
10
+ static readonly ACTION_PRINCIPAL = "Action";
11
+ /**
12
+ * Serialize a domain to the casbin token the matcher compares against {@link resolveRequestDomain}'s
13
+ * output: a scope literal (`SYSTEM_WIDE`/`ANY_MEMBER`) passes through unchanged; a typed domain becomes
14
+ * `<type>_<id>` so `g3(r.dom, p.dom)` cascades; null ⇒ null (the adapter then defaults grants to `ANY_MEMBER`).
15
+ */
16
+ private static serializeDomain;
17
+ /**
18
+ * A grant (casbin `p`): role/user → permission, carrying action + effect + domain.
19
+ * `domain` null ⇒ `ANY_MEMBER` (adapter default). Pass a scope literal or a typed `{ type, id }` domain.
20
+ */
21
+ static grant(opts: {
22
+ subject: {
23
+ type: string;
24
+ id: IdType;
25
+ };
26
+ permission: {
27
+ type: string;
28
+ id: IdType;
29
+ };
30
+ action: string;
31
+ domain?: TNullable<TPolicyDomainInput>;
32
+ effect: TAuthorizationDecision;
33
+ }): {
34
+ variant: "grant";
35
+ subjectType: string;
36
+ subjectId: IdType;
37
+ targetType: string;
38
+ targetId: IdType;
39
+ action: string;
40
+ effect: string;
41
+ domain: TNullable<string>;
42
+ };
43
+ /** Assign a role to a user (casbin `g`). `domain` null ⇒ `*` (every domain). */
44
+ static assignRole(opts: {
45
+ user: {
46
+ type: string;
47
+ id: IdType;
48
+ };
49
+ role: {
50
+ type: string;
51
+ id: IdType;
52
+ };
53
+ domain?: TNullable<TPolicyDomainInput>;
54
+ }): {
55
+ variant: "assign_role";
56
+ subjectType: string;
57
+ subjectId: IdType;
58
+ targetType: string;
59
+ targetId: IdType;
60
+ domain: TNullable<string>;
61
+ };
62
+ /** A user joins a domain (casbin `g2`) — backs the `ANY_MEMBER` grant scope. */
63
+ static joinDomain(opts: {
64
+ user: {
65
+ type: string;
66
+ id: IdType;
67
+ };
68
+ domain: {
69
+ type: string;
70
+ id: IdType;
71
+ };
72
+ }): {
73
+ variant: "join_domain";
74
+ subjectType: string;
75
+ subjectId: IdType;
76
+ targetType: string;
77
+ targetId: IdType;
78
+ };
79
+ /** A role inherits another role (casbin `g`, shared relation with assign_role). */
80
+ static roleInherits(opts: {
81
+ child: {
82
+ type: string;
83
+ id: IdType;
84
+ };
85
+ parent: {
86
+ type: string;
87
+ id: IdType;
88
+ };
89
+ }): {
90
+ variant: "role_inherits";
91
+ subjectType: string;
92
+ subjectId: IdType;
93
+ targetType: string;
94
+ targetId: IdType;
95
+ };
96
+ /**
97
+ * A resource inherits another (casbin `g4`): a grant on the PARENT covers the CHILD.
98
+ * e.g. `{ child: SaleOrder, parent: Sale }` — grant on module `Sale` covers subject `SaleOrder`.
99
+ * Many-to-many: a subject may inherit several module parents (add one edge each).
100
+ */
101
+ static resourceInherits(opts: {
102
+ child: {
103
+ type: string;
104
+ id: IdType;
105
+ };
106
+ parent: {
107
+ type: string;
108
+ id: IdType;
109
+ };
110
+ }): {
111
+ variant: "resource_inherits";
112
+ subjectType: string;
113
+ subjectId: IdType;
114
+ targetType: string;
115
+ targetId: IdType;
116
+ };
117
+ /** An action inherits another (casbin `g5`): the child action is implied by the parent, e.g. read ⊂ manage. */
118
+ static actionInherits(opts: {
119
+ child: TAuthorizationAction;
120
+ parent: TAuthorizationAction;
121
+ }): {
122
+ variant: "action_inherits";
123
+ subjectType: string;
124
+ subjectId: string;
125
+ targetType: string;
126
+ targetId: string;
127
+ };
128
+ /** All `action_inherits` rows for the standard {@link AuthorizationActions.LATTICE}. Seed once, idempotently. */
129
+ static actionLattice(): {
130
+ variant: "action_inherits";
131
+ subjectType: string;
132
+ subjectId: string;
133
+ targetType: string;
134
+ targetId: string;
135
+ }[];
136
+ /** A domain inherits another (casbin `g3`): a grant in the parent domain cascades to the child. e.g. Merchant ⊂ Organizer. */
137
+ static domainInherits(opts: {
138
+ child: {
139
+ type: string;
140
+ id: IdType;
141
+ };
142
+ parent: {
143
+ type: string;
144
+ id: IdType;
145
+ };
146
+ }): {
147
+ variant: "domain_inherits";
148
+ subjectType: string;
149
+ subjectId: IdType;
150
+ targetType: string;
151
+ targetId: IdType;
152
+ };
153
+ /**
154
+ * Build a role's coarse grant rows from resolved permission ids. The caller resolves each
155
+ * `resourceCode` (subject/module) to a `Permission` and supplies the lookup; unresolved codes are skipped.
156
+ */
157
+ static roleGrants(opts: {
158
+ role: {
159
+ type: string;
160
+ id: IdType;
161
+ };
162
+ permission: {
163
+ type: string;
164
+ idByCode: ReadonlyMap<string, string>;
165
+ };
166
+ grants: ReadonlyArray<{
167
+ resourceCode: string;
168
+ action: string;
169
+ domain?: TNullable<TPolicyDomainInput>;
170
+ effect: TAuthorizationDecision;
171
+ }>;
172
+ }): {
173
+ variant: "grant";
174
+ subjectType: string;
175
+ subjectId: IdType;
176
+ targetType: string;
177
+ targetId: IdType;
178
+ action: string;
179
+ effect: string;
180
+ domain: TNullable<string>;
181
+ }[];
182
+ }
183
+ //# sourceMappingURL=policy-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy-builder.d.ts","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/common/policy-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAGL,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAErB,wGAAwG;AACxG,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvE,qBAAa,0BAA0B;IACrC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,YAAY;IAE5C;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;IAY9B;;;OAGG;IACH,MAA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E;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,EAAE,EAAE,MAAM,CAAA;SAAE,CAAC;QACpC,MAAM,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,EAAE,EAAE,MAAM,CAAA;SAAE,CAAC;KACtC;;;;;;;IAUD,+GAA+G;IAC/G,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,oBAAoB,CAAC;QAAC,MAAM,EAAE,oBAAoB,CAAA;KAAE;;;;;;;IAUzF,iHAAiH;IACjH,MAAM,CAAC,aAAa;;;;;;;IAIpB,8HAA8H;IAC9H,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE;QAC1B,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,EAAE,EAAE,MAAM,CAAA;SAAE,CAAC;QACpC,MAAM,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,EAAE,EAAE,MAAM,CAAA;SAAE,CAAC;KACtC;;;;;;;IAUD;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE;QACtB,IAAI,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,EAAE,EAAE,MAAM,CAAA;SAAE,CAAC;QACnC,UAAU,EAAE;YACV,IAAI,EAAE,MAAM,CAAC;YACb,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;SACvC,CAAC;QAEF,MAAM,EAAE,aAAa,CAAC;YACpB,YAAY,EAAE,MAAM,CAAC;YACrB,MAAM,EAAE,MAAM,CAAC;YACf,MAAM,CAAC,EAAE,SAAS,CAAC,kBAAkB,CAAC,CAAC;YACvC,MAAM,EAAE,sBAAsB,CAAC;SAChC,CAAC,CAAC;KACJ;;;;;;;;;;CAsBF"}
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthorizationPolicyBuilder = void 0;
4
+ const constants_1 = require("./constants");
5
+ class AuthorizationPolicyBuilder {
6
+ static { this.ACTION_PRINCIPAL = 'Action'; }
7
+ /**
8
+ * Serialize a domain to the casbin token the matcher compares against {@link resolveRequestDomain}'s
9
+ * output: a scope literal (`SYSTEM_WIDE`/`ANY_MEMBER`) passes through unchanged; a typed domain becomes
10
+ * `<type>_<id>` so `g3(r.dom, p.dom)` cascades; null ⇒ null (the adapter then defaults grants to `ANY_MEMBER`).
11
+ */
12
+ static serializeDomain(domain) {
13
+ if (domain == null) {
14
+ return null;
15
+ }
16
+ if (typeof domain === 'string') {
17
+ return domain;
18
+ }
19
+ return [domain.type, domain.id].join('_');
20
+ }
21
+ /**
22
+ * A grant (casbin `p`): role/user → permission, carrying action + effect + domain.
23
+ * `domain` null ⇒ `ANY_MEMBER` (adapter default). Pass a scope literal or a typed `{ type, id }` domain.
24
+ */
25
+ static grant(opts) {
26
+ return {
27
+ variant: constants_1.AuthorizationPolicyVariants.GRANT.action,
28
+ subjectType: opts.subject.type,
29
+ subjectId: opts.subject.id,
30
+ targetType: opts.permission.type,
31
+ targetId: opts.permission.id,
32
+ action: opts.action,
33
+ effect: opts.effect,
34
+ domain: AuthorizationPolicyBuilder.serializeDomain(opts.domain),
35
+ };
36
+ }
37
+ /** Assign a role to a user (casbin `g`). `domain` null ⇒ `*` (every domain). */
38
+ static assignRole(opts) {
39
+ return {
40
+ variant: constants_1.AuthorizationPolicyVariants.ASSIGN_ROLE.action,
41
+ subjectType: opts.user.type,
42
+ subjectId: opts.user.id,
43
+ targetType: opts.role.type,
44
+ targetId: opts.role.id,
45
+ domain: AuthorizationPolicyBuilder.serializeDomain(opts.domain),
46
+ };
47
+ }
48
+ /** A user joins a domain (casbin `g2`) — backs the `ANY_MEMBER` grant scope. */
49
+ static joinDomain(opts) {
50
+ return {
51
+ variant: constants_1.AuthorizationPolicyVariants.JOIN_DOMAIN.action,
52
+ subjectType: opts.user.type,
53
+ subjectId: opts.user.id,
54
+ targetType: opts.domain.type,
55
+ targetId: opts.domain.id,
56
+ };
57
+ }
58
+ /** A role inherits another role (casbin `g`, shared relation with assign_role). */
59
+ static roleInherits(opts) {
60
+ return {
61
+ variant: constants_1.AuthorizationPolicyVariants.ROLE_INHERITS.action,
62
+ subjectType: opts.child.type,
63
+ subjectId: opts.child.id,
64
+ targetType: opts.parent.type,
65
+ targetId: opts.parent.id,
66
+ };
67
+ }
68
+ /**
69
+ * A resource inherits another (casbin `g4`): a grant on the PARENT covers the CHILD.
70
+ * e.g. `{ child: SaleOrder, parent: Sale }` — grant on module `Sale` covers subject `SaleOrder`.
71
+ * Many-to-many: a subject may inherit several module parents (add one edge each).
72
+ */
73
+ static resourceInherits(opts) {
74
+ return {
75
+ variant: constants_1.AuthorizationPolicyVariants.RESOURCE_INHERITS.action,
76
+ subjectType: opts.child.type,
77
+ subjectId: opts.child.id,
78
+ targetType: opts.parent.type,
79
+ targetId: opts.parent.id,
80
+ };
81
+ }
82
+ /** An action inherits another (casbin `g5`): the child action is implied by the parent, e.g. read ⊂ manage. */
83
+ static actionInherits(opts) {
84
+ return {
85
+ variant: constants_1.AuthorizationPolicyVariants.ACTION_INHERITS.action,
86
+ subjectType: this.ACTION_PRINCIPAL,
87
+ subjectId: opts.child,
88
+ targetType: this.ACTION_PRINCIPAL,
89
+ targetId: opts.parent,
90
+ };
91
+ }
92
+ /** All `action_inherits` rows for the standard {@link AuthorizationActions.LATTICE}. Seed once, idempotently. */
93
+ static actionLattice() {
94
+ return constants_1.AuthorizationActions.LATTICE.map(action => this.actionInherits(action));
95
+ }
96
+ /** A domain inherits another (casbin `g3`): a grant in the parent domain cascades to the child. e.g. Merchant ⊂ Organizer. */
97
+ static domainInherits(opts) {
98
+ return {
99
+ variant: constants_1.AuthorizationPolicyVariants.DOMAIN_INHERITS.action,
100
+ subjectType: opts.child.type,
101
+ subjectId: opts.child.id,
102
+ targetType: opts.parent.type,
103
+ targetId: opts.parent.id,
104
+ };
105
+ }
106
+ /**
107
+ * Build a role's coarse grant rows from resolved permission ids. The caller resolves each
108
+ * `resourceCode` (subject/module) to a `Permission` and supplies the lookup; unresolved codes are skipped.
109
+ */
110
+ static roleGrants(opts) {
111
+ const rows = [];
112
+ for (const grant of opts.grants) {
113
+ const permissionId = opts.permission.idByCode.get(grant.resourceCode);
114
+ if (!permissionId) {
115
+ continue;
116
+ }
117
+ const policy = AuthorizationPolicyBuilder.grant({
118
+ subject: { type: opts.role.type, id: opts.role.id },
119
+ permission: { type: opts.permission.type, id: permissionId },
120
+ action: grant.action,
121
+ domain: grant.domain,
122
+ effect: grant.effect,
123
+ });
124
+ rows.push(policy);
125
+ }
126
+ return rows;
127
+ }
128
+ }
129
+ exports.AuthorizationPolicyBuilder = AuthorizationPolicyBuilder;
130
+ //# sourceMappingURL=policy-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy-builder.js","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/common/policy-builder.ts"],"names":[],"mappings":";;;AAEA,2CAKqB;AAKrB,MAAa,0BAA0B;aACrB,qBAAgB,GAAG,QAAQ,CAAC;IAE5C;;;;OAIG;IACK,MAAM,CAAC,eAAe,CAAC,MAAsC;QACnE,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5C,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,IAMZ;QACC,OAAO;YACL,OAAO,EAAE,uCAA2B,CAAC,KAAK,CAAC,MAAM;YACjD,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;YAC9B,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE;YAC1B,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI;YAChC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AI,GAA+D,EAAE,CAAC;QAE5E,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChC,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;YACtE,IAAI,CAAC,YAAY,EAAE,CAAC;gBAClB,SAAS;YACX,CAAC;YAED,MAAM,MAAM,GAAG,0BAA0B,CAAC,KAAK,CAAC;gBAC9C,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE;gBACnD,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,EAAE,YAAY,EAAE;gBAC5D,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,MAAM,EAAE,KAAK,CAAC,MAAM;aACrB,CAAC,CAAC;YAEH,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACpB,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;;AA7KH,gEA8KC"}
@@ -0,0 +1,20 @@
1
+ import { TContext } from '../../../../base/controllers/common/types';
2
+ import { TNullable } from '@venizia/ignis-helpers';
3
+ import { Env } from 'hono';
4
+ import { IAuthorizationDomainSource, IAuthorizationSpec, IAuthorizeOptions } from './types';
5
+ /** Read a domain value from a declarative source on the Hono context. */
6
+ export declare const readDeclarative: (opts: {
7
+ source: IAuthorizationDomainSource;
8
+ context: TContext<Env, string>;
9
+ }) => TNullable<string>;
10
+ /**
11
+ * Resolve the request domain scope with precedence:
12
+ * spec.domain (method | declarative) → options.domainResolver → SYSTEM_WIDE.
13
+ * Returns a casbin domain string ("<type>_<id>") or the SYSTEM_WIDE sentinel.
14
+ */
15
+ export declare const resolveRequestDomain: (opts: {
16
+ spec: IAuthorizationSpec;
17
+ context: TContext<Env, string>;
18
+ options: TNullable<IAuthorizeOptions>;
19
+ }) => Promise<string>;
20
+ //# sourceMappingURL=resolve-request-domain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-request-domain.d.ts","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/common/resolve-request-domain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAE3B,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5F,yEAAyE;AACzE,eAAO,MAAM,eAAe,GAAI,MAAM;IACpC,MAAM,EAAE,0BAA0B,CAAC;IACnC,OAAO,EAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;CAChC,KAAG,SAAS,CAAC,MAAM,CAoBnB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAU,MAAM;IAC/C,IAAI,EAAE,kBAAkB,CAAC;IACzB,OAAO,EAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC/B,OAAO,EAAE,SAAS,CAAC,iBAAiB,CAAC,CAAC;CACvC,KAAG,OAAO,CAAC,MAAM,CA4BjB,CAAC"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveRequestDomain = exports.readDeclarative = void 0;
4
+ const constants_1 = require("./constants");
5
+ /** Read a domain value from a declarative source on the Hono context. */
6
+ const readDeclarative = (opts) => {
7
+ const { source, context } = opts;
8
+ switch (source.from) {
9
+ case 'param': {
10
+ return context.req.param(source.key) ?? null;
11
+ }
12
+ case 'header': {
13
+ return context.req.header(source.key) ?? null;
14
+ }
15
+ case 'query': {
16
+ return context.req.query(source.key) ?? null;
17
+ }
18
+ case 'context': {
19
+ const value = context.get(source.key);
20
+ return value == null ? null : String(value);
21
+ }
22
+ default: {
23
+ return null;
24
+ }
25
+ }
26
+ };
27
+ exports.readDeclarative = readDeclarative;
28
+ /**
29
+ * Resolve the request domain scope with precedence:
30
+ * spec.domain (method | declarative) → options.domainResolver → SYSTEM_WIDE.
31
+ * Returns a casbin domain string ("<type>_<id>") or the SYSTEM_WIDE sentinel.
32
+ */
33
+ const resolveRequestDomain = async (opts) => {
34
+ const { spec, context, options } = opts;
35
+ // (1) spec.domain as a method
36
+ if (typeof spec.domain === 'function') {
37
+ const resolved = await spec.domain({ context });
38
+ return resolved
39
+ ? [resolved.type, resolved.id].join('_')
40
+ : constants_1.AuthorizationDomainScopes.SYSTEM_WIDE;
41
+ }
42
+ // (2) spec.domain as declarative
43
+ if (spec.domain) {
44
+ const id = (0, exports.readDeclarative)({ source: spec.domain, context });
45
+ return id ? [spec.domain.type, id].join('_') : constants_1.AuthorizationDomainScopes.SYSTEM_WIDE;
46
+ }
47
+ // (3) global resolver
48
+ const globalResolver = options?.domainResolver ?? null;
49
+ if (globalResolver) {
50
+ const resolved = await globalResolver({ context });
51
+ return resolved
52
+ ? [resolved.type, resolved.id].join('_')
53
+ : constants_1.AuthorizationDomainScopes.SYSTEM_WIDE;
54
+ }
55
+ // (4) nothing → SYSTEM_WIDE
56
+ return constants_1.AuthorizationDomainScopes.SYSTEM_WIDE;
57
+ };
58
+ exports.resolveRequestDomain = resolveRequestDomain;
59
+ //# sourceMappingURL=resolve-request-domain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-request-domain.js","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/common/resolve-request-domain.ts"],"names":[],"mappings":";;;AAGA,2CAAwD;AAGxD,yEAAyE;AAClE,MAAM,eAAe,GAAG,CAAC,IAG/B,EAAqB,EAAE;IACtB,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACjC,QAAQ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C,CAAC,qCAAyB,CAAC,WAAW,CAAC;IAC5C,CAAC;IAED,iCAAiC;IACjC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,MAAM,EAAE,GAAG,IAAA,uBAAe,EAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;QAC7D,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,qCAAyB,CAAC,WAAW,CAAC;IACvF,CAAC;IAED,sBAAsB;IACtB,MAAM,cAAc,GAAG,OAAO,EAAE,cAAc,IAAI,IAAI,CAAC;IACvD,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;QACnD,OAAO,QAAQ;YACb,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;YACxC,CAAC,CAAC,qCAAyB,CAAC,WAAW,CAAC;IAC5C,CAAC;IAED,4BAA4B;IAC5B,OAAO,qCAAyB,CAAC,WAAW,CAAC;AAC/C,CAAC,CAAC;AAhCW,QAAA,oBAAoB,wBAgC/B"}
@@ -1,9 +1,10 @@
1
+ import { IdType } from '../../../../base';
1
2
  import { TContext } from '../../../../base/controllers/common/types';
2
- import { type DefaultRedisHelper, type ValueOrPromise } from '@venizia/ignis-helpers';
3
+ import { type DefaultRedisHelper, type TNullable, type ValueOrPromise } from '@venizia/ignis-helpers';
3
4
  import { type Adapter } from 'casbin';
4
5
  import { Env, type MiddlewareHandler } from 'hono';
5
6
  import { IAuthUser } from '../../authenticate';
6
- import { CasbinEnforcerCachedDrivers, CasbinEnforcerModelDrivers, TAuthorizationDecision } from './constants';
7
+ import { CasbinEnforcerCachedDrivers, CasbinEnforcerModelDrivers, TAuthorizationDecision, TCasbinDomainMatchingFunction } from './constants';
7
8
  export interface IAuthorizationRole {
8
9
  readonly name: string;
9
10
  readonly priority: number;
@@ -11,24 +12,49 @@ export interface IAuthorizationRole {
11
12
  }
12
13
  /** Key-value conditions for attribute-based access control. Values compared with strict equality. */
13
14
  export type TAuthorizationConditions<KeyType extends string | symbol = string | symbol, ValueType = string | number | boolean | null> = Record<KeyType, ValueType>;
14
- export interface IAuthorizationComparable<TElement = string, TCompareResult = number> {
15
- value: TElement;
16
- compare(other: TElement): TCompareResult;
17
- isEqual(other: TElement): boolean;
18
- }
19
15
  export interface IAuthorizationRequest<TAction = string, TResource = string> {
20
16
  action: TAction;
21
17
  resource: TResource;
22
18
  conditions?: TAuthorizationConditions;
19
+ /**
20
+ * Resolved domain scope for this request, as a casbin domain string `"<DomainType>_<id>"`
21
+ * (e.g. `"Merchant_7"`), or the `"SYSTEM_WIDE"` sentinel to enforce across all domains.
22
+ */
23
+ domain?: string;
24
+ }
25
+ export interface IAuthorizationUser extends IAuthUser {
26
+ principalType: string;
27
+ }
28
+ /** What CasbinAuthorizationEnforcer.buildRules returns and evaluate consumes. */
29
+ export interface ICasbinRules {
30
+ user: IAuthorizationUser;
31
+ lines: string[];
23
32
  }
24
- /** Authorization enforcer that builds rules and evaluates authorization requests. */
33
+ /** Declarative description of where to read the request domain from. */
34
+ export interface IAuthorizationDomainSource {
35
+ from: 'param' | 'header' | 'query' | 'context';
36
+ key: string;
37
+ type: string;
38
+ }
39
+ /** Returns the current request domain; null = no domain (→ SYSTEM_WIDE). */
40
+ export type TAuthorizationDomainResolver<E extends Env = Env> = (opts: {
41
+ context: TContext<E, string>;
42
+ }) => ValueOrPromise<TNullable<{
43
+ type: string;
44
+ id: IdType;
45
+ }>>;
46
+ /**
47
+ * Authorization enforcer: builds rules and evaluates requests.
48
+ *
49
+ * Cache management (`invalidateUserCache`/`rebuildUserCache`) is OPTIONAL — present only on enforcers
50
+ * that cache per-user policies (e.g. the Casbin enforcer with the Redis driver). The registry
51
+ * feature-detects them at runtime before invoking.
52
+ */
25
53
  export interface IAuthorizationEnforcer<E extends Env = Env, TAction = string, TResource = string, TRules = unknown, TBuildRulesReturn = ValueOrPromise<TRules>, TEvaluateReturn = ValueOrPromise<TAuthorizationDecision>> {
26
54
  name: string;
27
55
  configure(): ValueOrPromise<void>;
28
56
  buildRules(opts: {
29
- user: {
30
- principalType: string;
31
- } & IAuthUser;
57
+ user: IAuthorizationUser;
32
58
  context: TContext<E, string>;
33
59
  }): TBuildRulesReturn;
34
60
  evaluate(opts: {
@@ -36,6 +62,19 @@ export interface IAuthorizationEnforcer<E extends Env = Env, TAction = string, T
36
62
  request: IAuthorizationRequest<TAction, TResource>;
37
63
  context: TContext<E, string>;
38
64
  }): TEvaluateReturn;
65
+ /** Drop a user's cached policies. Implemented only by caching enforcers. */
66
+ invalidateUserCache?(opts: {
67
+ user: IAuthorizationUser;
68
+ }): Promise<{
69
+ invalidatedKeys: number;
70
+ }>;
71
+ /** Drop + rebuild a user's cached policies. Implemented only by caching enforcers. */
72
+ rebuildUserCache?(opts: {
73
+ user: IAuthorizationUser;
74
+ }): Promise<{
75
+ cacheKey: string;
76
+ lineCount: number;
77
+ }>;
39
78
  }
40
79
  export type TAuthorizationVoter<E extends Env = Env, TAction = string, TResource = string> = (opts: {
41
80
  user: IAuthUser;
@@ -49,26 +88,20 @@ export interface IAuthorizationSpec<E extends Env = Env, TAction = string, TReso
49
88
  conditions?: TAuthorizationConditions;
50
89
  allowedRoles?: string[];
51
90
  voters?: TAuthorizationVoter<E, TAction, TResource>[];
91
+ /** Optional per-route domain: declarative source OR a resolver method. Omitted → global resolver. */
92
+ domain?: IAuthorizationDomainSource | TAuthorizationDomainResolver<E>;
52
93
  }
53
94
  export type TAuthorizeFn<E extends Env = Env, TAction = string, TResource = string> = (opts: {
54
95
  spec: IAuthorizationSpec<E, TAction, TResource>;
55
96
  enforcerName?: string;
56
97
  }) => MiddlewareHandler;
57
- export interface ICasbinEnforcerCachedMemory {
58
- driver: typeof CasbinEnforcerCachedDrivers.IN_MEMORY;
59
- options: {
60
- expiresIn: number;
61
- };
62
- }
63
98
  export interface ICasbinEnforcerCachedRedis {
64
99
  driver: typeof CasbinEnforcerCachedDrivers.REDIS;
65
100
  options: {
66
101
  connection: DefaultRedisHelper;
67
102
  expiresIn: number;
68
103
  keyFn: (opts: {
69
- user: {
70
- principalType: string;
71
- } & IAuthUser;
104
+ user: IAuthorizationUser;
72
105
  }) => ValueOrPromise<string>;
73
106
  };
74
107
  }
@@ -82,12 +115,14 @@ export interface ICasbinEnforcerOptions<E extends Env = Env, TAction = string, T
82
115
  };
83
116
  cached: {
84
117
  use: false;
85
- } | (ICasbinEnforcerCachedMemory & {
86
- use: true;
87
- }) | (ICasbinEnforcerCachedRedis & {
118
+ } | (ICasbinEnforcerCachedRedis & {
88
119
  use: true;
89
120
  });
90
121
  adapter?: TAdapter;
122
+ domainMatching?: {
123
+ roleDefinition: string;
124
+ fn: TCasbinDomainMatchingFunction;
125
+ };
91
126
  normalizePayloadFn?(opts: {
92
127
  user: IAuthUser;
93
128
  action: TAction;
@@ -99,9 +134,21 @@ export interface ICasbinEnforcerOptions<E extends Env = Env, TAction = string, T
99
134
  action: string;
100
135
  domain?: string;
101
136
  };
137
+ /**
138
+ * Turn on the domain-scoped RBAC model. Requests become 4-token `(subject, domain, object, action)`
139
+ * instead of 3-token, and the enforcer registers the domain matcher (`keyMatch` on `g`) and the
140
+ * resource matcher (`objectMatch`) needed by that model.
141
+ */
142
+ isScoped?: boolean;
143
+ /** Number of pooled enforcers (each request enforces on its own). Default 16. */
144
+ poolSize?: number;
145
+ /** Max ms to wait for a free pooled enforcer before failing closed. Default 5000. */
146
+ poolAcquireTimeoutMs?: number;
102
147
  }
103
148
  export interface IAuthorizeOptions {
104
149
  defaultDecision: TAuthorizationDecision;
105
150
  alwaysAllowRoles?: string[];
151
+ /** Fallback domain resolver used when a route's spec has no `domain`. */
152
+ domainResolver?: TAuthorizationDomainResolver;
106
153
  }
107
154
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/common/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,KAAK,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC1B,sBAAsB,EACvB,MAAM,aAAa,CAAC;AACrB,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,qGAAqG;AACrG,MAAM,MAAM,wBAAwB,CAClC,OAAO,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,EACjD,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,IAC1C,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AAE/B,MAAM,WAAW,wBAAwB,CAAC,QAAQ,GAAG,MAAM,EAAE,cAAc,GAAG,MAAM;IAClF,KAAK,EAAE,QAAQ,CAAC;IAChB,OAAO,CAAC,KAAK,EAAE,QAAQ,GAAG,cAAc,CAAC;IACzC,OAAO,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC;CACnC;AAED,MAAM,WAAW,qBAAqB,CAAC,OAAO,GAAG,MAAM,EAAE,SAAS,GAAG,MAAM;IACzE,MAAM,EAAE,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