@venizia/ignis 0.4.8-0 → 0.4.8-10

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 (275) hide show
  1. package/README.md +7 -14
  2. package/dist/esm/base/applications/base.d.ts +19 -0
  3. package/dist/esm/base/applications/base.js +19 -0
  4. package/dist/esm/base/applications/base.js.map +1 -1
  5. package/dist/esm/base/applications/boot-steps.d.ts +1 -0
  6. package/dist/esm/base/applications/boot-steps.js.map +1 -1
  7. package/dist/esm/base/applications/common/types.d.ts +21 -4
  8. package/dist/esm/base/applications/common/types.js.map +1 -1
  9. package/dist/esm/base/applications/server.d.ts +12 -0
  10. package/dist/esm/base/applications/server.js +11 -0
  11. package/dist/esm/base/applications/server.js.map +1 -1
  12. package/dist/esm/base/metadata/request-context.d.ts +1 -0
  13. package/dist/esm/base/metadata/request-context.js +1 -0
  14. package/dist/esm/base/metadata/request-context.js.map +1 -1
  15. package/dist/esm/base/middlewares/request-spy/request-spy.middleware.d.ts +1 -0
  16. package/dist/esm/base/middlewares/request-spy/request-spy.middleware.js +9 -2
  17. package/dist/esm/base/middlewares/request-spy/request-spy.middleware.js.map +1 -1
  18. package/dist/esm/components/api-reference/common/constants.d.ts +1 -0
  19. package/dist/esm/components/api-reference/common/constants.js +1 -0
  20. package/dist/esm/components/api-reference/common/constants.js.map +1 -1
  21. package/dist/esm/components/api-reference/common/keys.d.ts +1 -0
  22. package/dist/esm/components/api-reference/common/keys.js +1 -0
  23. package/dist/esm/components/api-reference/common/keys.js.map +1 -1
  24. package/dist/esm/components/api-reference/common/types.d.ts +18 -1
  25. package/dist/esm/components/api-reference/common/types.js.map +1 -1
  26. package/dist/esm/components/api-reference/component.d.ts +14 -0
  27. package/dist/esm/components/api-reference/component.js +14 -0
  28. package/dist/esm/components/api-reference/component.js.map +1 -1
  29. package/dist/esm/components/api-reference/ui/factory.d.ts +1 -0
  30. package/dist/esm/components/api-reference/ui/factory.js +1 -0
  31. package/dist/esm/components/api-reference/ui/factory.js.map +1 -1
  32. package/dist/esm/components/api-reference/ui/scalar.d.ts +1 -0
  33. package/dist/esm/components/api-reference/ui/scalar.js +1 -0
  34. package/dist/esm/components/api-reference/ui/scalar.js.map +1 -1
  35. package/dist/esm/components/api-reference/ui/swagger.d.ts +1 -0
  36. package/dist/esm/components/api-reference/ui/swagger.js +1 -0
  37. package/dist/esm/components/api-reference/ui/swagger.js.map +1 -1
  38. package/dist/esm/components/auth/authenticate/component.d.ts +1 -0
  39. package/dist/esm/components/auth/authenticate/component.js +38 -1
  40. package/dist/esm/components/auth/authenticate/component.js.map +1 -1
  41. package/dist/esm/components/auth/authenticate/controllers/factory.d.ts +2 -0
  42. package/dist/esm/components/auth/authenticate/controllers/factory.js +1 -0
  43. package/dist/esm/components/auth/authenticate/controllers/factory.js.map +1 -1
  44. package/dist/esm/components/auth/authenticate/controllers/jwks/controller.d.ts +1 -0
  45. package/dist/esm/components/auth/authenticate/controllers/jwks/controller.js +1 -0
  46. package/dist/esm/components/auth/authenticate/controllers/jwks/controller.js.map +1 -1
  47. package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.d.ts +56 -5
  48. package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js +115 -11
  49. package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js.map +1 -1
  50. package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.d.ts +1 -0
  51. package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.js +3 -2
  52. package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.js.map +1 -1
  53. package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.d.ts +1 -0
  54. package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.js +11 -3
  55. package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.js.map +1 -1
  56. package/dist/esm/components/auth/authenticate/services/bearer/jws.service.d.ts +11 -0
  57. package/dist/esm/components/auth/authenticate/services/bearer/jws.service.js +25 -3
  58. package/dist/esm/components/auth/authenticate/services/bearer/jws.service.js.map +1 -1
  59. package/dist/esm/components/auth/authenticate/services/index.d.ts +1 -0
  60. package/dist/esm/components/auth/authenticate/services/index.js +1 -0
  61. package/dist/esm/components/auth/authenticate/services/index.js.map +1 -1
  62. package/dist/esm/components/auth/authenticate/services/jwks-url-policy.d.ts +42 -0
  63. package/dist/esm/components/auth/authenticate/services/jwks-url-policy.js +162 -0
  64. package/dist/esm/components/auth/authenticate/services/jwks-url-policy.js.map +1 -0
  65. package/dist/esm/components/auth/authenticate/services/service/verifier.service.js +7 -1
  66. package/dist/esm/components/auth/authenticate/services/service/verifier.service.js.map +1 -1
  67. package/dist/esm/components/auth/authenticate/strategies/jwks/issuer.d.ts +1 -0
  68. package/dist/esm/components/auth/authenticate/strategies/jwks/issuer.js +1 -0
  69. package/dist/esm/components/auth/authenticate/strategies/jwks/issuer.js.map +1 -1
  70. package/dist/esm/components/auth/authenticate/strategies/jwks/verifier.d.ts +1 -0
  71. package/dist/esm/components/auth/authenticate/strategies/jwks/verifier.js +1 -0
  72. package/dist/esm/components/auth/authenticate/strategies/jwks/verifier.js.map +1 -1
  73. package/dist/esm/components/auth/authenticate/strategies/jws.strategy.d.ts +1 -0
  74. package/dist/esm/components/auth/authenticate/strategies/jws.strategy.js +1 -0
  75. package/dist/esm/components/auth/authenticate/strategies/jws.strategy.js.map +1 -1
  76. package/dist/esm/components/auth/authenticate/strategies/service.strategy.js +2 -4
  77. package/dist/esm/components/auth/authenticate/strategies/service.strategy.js.map +1 -1
  78. package/dist/esm/components/auth/authorize/adapters/base-filtered.d.ts +1 -1
  79. package/dist/esm/components/auth/authorize/adapters/base-filtered.js +3 -2
  80. package/dist/esm/components/auth/authorize/adapters/base-filtered.js.map +1 -1
  81. package/dist/esm/components/auth/authorize/adapters/common/types.d.ts +2 -0
  82. package/dist/esm/components/auth/authorize/adapters/common/types.js.map +1 -1
  83. package/dist/esm/components/auth/authorize/adapters/connector.d.ts +2 -2
  84. package/dist/esm/components/auth/authorize/adapters/connector.js +3 -2
  85. package/dist/esm/components/auth/authorize/adapters/connector.js.map +1 -1
  86. package/dist/esm/components/auth/authorize/adapters/custom-grant-expander.js +1 -1
  87. package/dist/esm/components/auth/authorize/adapters/custom-grant-expander.js.map +1 -1
  88. package/dist/esm/components/auth/authorize/adapters/scoped-casbin/common/types.d.ts +2 -0
  89. package/dist/esm/components/auth/authorize/adapters/scoped-casbin/common/types.js.map +1 -1
  90. package/dist/esm/components/auth/authorize/adapters/scoped-casbin/policy-edges.d.ts +1 -0
  91. package/dist/esm/components/auth/authorize/adapters/scoped-casbin/policy-edges.js +1 -0
  92. package/dist/esm/components/auth/authorize/adapters/scoped-casbin/policy-edges.js.map +1 -1
  93. package/dist/esm/components/auth/authorize/component.d.ts +1 -0
  94. package/dist/esm/components/auth/authorize/component.js +1 -0
  95. package/dist/esm/components/auth/authorize/component.js.map +1 -1
  96. package/dist/esm/components/auth/authorize/enforcers/casbin.enforcer.d.ts +1 -0
  97. package/dist/esm/components/auth/authorize/enforcers/casbin.enforcer.js +1 -0
  98. package/dist/esm/components/auth/authorize/enforcers/casbin.enforcer.js.map +1 -1
  99. package/dist/esm/components/auth/models/entities/columns.d.ts +1 -0
  100. package/dist/esm/components/auth/models/entities/columns.js.map +1 -1
  101. package/dist/esm/components/auth/models/entities/permission.model.d.ts +2 -0
  102. package/dist/esm/components/auth/models/entities/permission.model.js.map +1 -1
  103. package/dist/esm/components/auth/models/entities/policy-definition.model.d.ts +1 -0
  104. package/dist/esm/components/auth/models/entities/policy-definition.model.js.map +1 -1
  105. package/dist/esm/components/controller/grpc/common/types.d.ts +2 -0
  106. package/dist/esm/components/controller/grpc/common/types.js +1 -0
  107. package/dist/esm/components/controller/grpc/common/types.js.map +1 -1
  108. package/dist/esm/components/controller/grpc/grpc.component.d.ts +1 -0
  109. package/dist/esm/components/controller/grpc/grpc.component.js +1 -0
  110. package/dist/esm/components/controller/grpc/grpc.component.js.map +1 -1
  111. package/dist/esm/components/health-check/common/constants.d.ts +1 -0
  112. package/dist/esm/components/health-check/common/constants.js +1 -0
  113. package/dist/esm/components/health-check/common/constants.js.map +1 -1
  114. package/dist/esm/components/health-check/common/keys.d.ts +1 -0
  115. package/dist/esm/components/health-check/common/keys.js +1 -0
  116. package/dist/esm/components/health-check/common/keys.js.map +1 -1
  117. package/dist/esm/components/health-check/common/rest-paths.d.ts +1 -0
  118. package/dist/esm/components/health-check/common/rest-paths.js +1 -0
  119. package/dist/esm/components/health-check/common/rest-paths.js.map +1 -1
  120. package/dist/esm/components/health-check/common/types.d.ts +24 -3
  121. package/dist/esm/components/health-check/common/types.js.map +1 -1
  122. package/dist/esm/components/health-check/component.d.ts +15 -0
  123. package/dist/esm/components/health-check/component.js +15 -0
  124. package/dist/esm/components/health-check/component.js.map +1 -1
  125. package/dist/esm/components/health-check/controller.d.ts +1 -0
  126. package/dist/esm/components/health-check/controller.js +1 -0
  127. package/dist/esm/components/health-check/controller.js.map +1 -1
  128. package/dist/esm/components/health-check/reporter.js +2 -2
  129. package/dist/esm/components/health-check/reporter.js.map +1 -1
  130. package/dist/esm/components/index.d.ts +1 -0
  131. package/dist/esm/components/index.js +1 -0
  132. package/dist/esm/components/index.js.map +1 -1
  133. package/dist/esm/components/mail/common/constants.d.ts +6 -0
  134. package/dist/esm/components/mail/common/constants.js +5 -0
  135. package/dist/esm/components/mail/common/constants.js.map +1 -1
  136. package/dist/esm/components/mail/common/keys.d.ts +1 -0
  137. package/dist/esm/components/mail/common/keys.js +1 -0
  138. package/dist/esm/components/mail/common/keys.js.map +1 -1
  139. package/dist/esm/components/mail/common/types/message.d.ts +10 -0
  140. package/dist/esm/components/mail/common/types/message.js.map +1 -1
  141. package/dist/esm/components/mail/common/types/options.d.ts +22 -1
  142. package/dist/esm/components/mail/common/types/options.js.map +1 -1
  143. package/dist/esm/components/mail/common/types/queue.d.ts +7 -0
  144. package/dist/esm/components/mail/common/types/queue.js.map +1 -1
  145. package/dist/esm/components/mail/common/types/template.d.ts +2 -0
  146. package/dist/esm/components/mail/common/types/template.js.map +1 -1
  147. package/dist/esm/components/mail/common/types/verification.d.ts +6 -0
  148. package/dist/esm/components/mail/common/types/verification.js.map +1 -1
  149. package/dist/esm/components/mail/component.d.ts +1 -0
  150. package/dist/esm/components/mail/component.js +1 -0
  151. package/dist/esm/components/mail/component.js.map +1 -1
  152. package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.d.ts +1 -0
  153. package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.js +1 -0
  154. package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.js.map +1 -1
  155. package/dist/esm/components/mail/helpers/executors/direct-executor.helper.d.ts +1 -0
  156. package/dist/esm/components/mail/helpers/executors/direct-executor.helper.js +1 -0
  157. package/dist/esm/components/mail/helpers/executors/direct-executor.helper.js.map +1 -1
  158. package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.d.ts +1 -0
  159. package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.js +1 -0
  160. package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.js.map +1 -1
  161. package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.d.ts +1 -0
  162. package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.js +1 -0
  163. package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.js.map +1 -1
  164. package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.d.ts +1 -0
  165. package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.js +1 -0
  166. package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.js.map +1 -1
  167. package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.d.ts +1 -0
  168. package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.js +1 -0
  169. package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.js.map +1 -1
  170. package/dist/esm/components/mail/providers/mail-queue-executor.provider.d.ts +2 -0
  171. package/dist/esm/components/mail/providers/mail-queue-executor.provider.js +1 -0
  172. package/dist/esm/components/mail/providers/mail-queue-executor.provider.js.map +1 -1
  173. package/dist/esm/components/mail/providers/mail-transporter.provider.d.ts +2 -0
  174. package/dist/esm/components/mail/providers/mail-transporter.provider.js +1 -0
  175. package/dist/esm/components/mail/providers/mail-transporter.provider.js.map +1 -1
  176. package/dist/esm/components/mail/services/generators/numeric-code.d.ts +1 -5
  177. package/dist/esm/components/mail/services/generators/numeric-code.js +3 -30
  178. package/dist/esm/components/mail/services/generators/numeric-code.js.map +1 -1
  179. package/dist/esm/components/mail/services/generators/random-token.d.ts +4 -0
  180. package/dist/esm/components/mail/services/generators/random-token.js +9 -5
  181. package/dist/esm/components/mail/services/generators/random-token.js.map +1 -1
  182. package/dist/esm/components/mail/services/generators/verification-data.d.ts +1 -0
  183. package/dist/esm/components/mail/services/generators/verification-data.js +1 -0
  184. package/dist/esm/components/mail/services/generators/verification-data.js.map +1 -1
  185. package/dist/esm/components/mail/services/mail.service.d.ts +1 -0
  186. package/dist/esm/components/mail/services/mail.service.js +1 -0
  187. package/dist/esm/components/mail/services/mail.service.js.map +1 -1
  188. package/dist/esm/components/mail/services/template.service.d.ts +1 -0
  189. package/dist/esm/components/mail/services/template.service.js +1 -0
  190. package/dist/esm/components/mail/services/template.service.js.map +1 -1
  191. package/dist/esm/components/mail/utilities/address.utility.d.ts +1 -0
  192. package/dist/esm/components/mail/utilities/address.utility.js +1 -0
  193. package/dist/esm/components/mail/utilities/address.utility.js.map +1 -1
  194. package/dist/esm/components/mail/utilities/mime.utility.d.ts +1 -0
  195. package/dist/esm/components/mail/utilities/mime.utility.js +5 -4
  196. package/dist/esm/components/mail/utilities/mime.utility.js.map +1 -1
  197. package/dist/esm/components/mail/utilities/verification.utility.d.ts +1 -0
  198. package/dist/esm/components/mail/utilities/verification.utility.js +1 -0
  199. package/dist/esm/components/mail/utilities/verification.utility.js.map +1 -1
  200. package/dist/esm/components/request-tracker/component.d.ts +1 -0
  201. package/dist/esm/components/request-tracker/component.js +1 -0
  202. package/dist/esm/components/request-tracker/component.js.map +1 -1
  203. package/dist/esm/components/server-info/common/constants.d.ts +6 -0
  204. package/dist/esm/components/server-info/common/constants.js +6 -0
  205. package/dist/esm/components/server-info/common/constants.js.map +1 -0
  206. package/dist/esm/components/server-info/common/index.d.ts +5 -0
  207. package/dist/esm/components/server-info/common/index.js +5 -0
  208. package/dist/esm/components/server-info/common/index.js.map +1 -0
  209. package/dist/esm/components/server-info/common/keys.d.ts +5 -0
  210. package/dist/esm/components/server-info/common/keys.js +5 -0
  211. package/dist/esm/components/server-info/common/keys.js.map +1 -0
  212. package/dist/esm/components/server-info/common/rest-paths.d.ts +5 -0
  213. package/dist/esm/components/server-info/common/rest-paths.js +5 -0
  214. package/dist/esm/components/server-info/common/rest-paths.js.map +1 -0
  215. package/dist/esm/components/server-info/common/types.d.ts +68 -0
  216. package/dist/esm/components/server-info/common/types.js +2 -0
  217. package/dist/esm/components/server-info/common/types.js.map +1 -0
  218. package/dist/esm/components/server-info/component.d.ts +31 -0
  219. package/dist/esm/components/server-info/component.js +87 -0
  220. package/dist/esm/components/server-info/component.js.map +1 -0
  221. package/dist/esm/components/server-info/controller.d.ts +14 -0
  222. package/dist/esm/components/server-info/controller.js +68 -0
  223. package/dist/esm/components/server-info/controller.js.map +1 -0
  224. package/dist/esm/components/server-info/index.d.ts +5 -0
  225. package/dist/esm/components/server-info/index.js +5 -0
  226. package/dist/esm/components/server-info/index.js.map +1 -0
  227. package/dist/esm/components/server-info/reporter.d.ts +25 -0
  228. package/dist/esm/components/server-info/reporter.js +68 -0
  229. package/dist/esm/components/server-info/reporter.js.map +1 -0
  230. package/dist/esm/components/socket-io/common/keys.d.ts +1 -0
  231. package/dist/esm/components/socket-io/common/keys.js +1 -0
  232. package/dist/esm/components/socket-io/common/keys.js.map +1 -1
  233. package/dist/esm/components/socket-io/component.d.ts +1 -0
  234. package/dist/esm/components/socket-io/component.js +1 -0
  235. package/dist/esm/components/socket-io/component.js.map +1 -1
  236. package/dist/esm/components/static-asset/common/constants.d.ts +5 -0
  237. package/dist/esm/components/static-asset/common/constants.js +3 -0
  238. package/dist/esm/components/static-asset/common/constants.js.map +1 -1
  239. package/dist/esm/components/static-asset/common/keys.d.ts +1 -0
  240. package/dist/esm/components/static-asset/common/keys.js +1 -0
  241. package/dist/esm/components/static-asset/common/keys.js.map +1 -1
  242. package/dist/esm/components/static-asset/common/types.d.ts +48 -6
  243. package/dist/esm/components/static-asset/common/types.js.map +1 -1
  244. package/dist/esm/components/static-asset/controller/base.definition.d.ts +2 -0
  245. package/dist/esm/components/static-asset/controller/base.definition.js +6 -4
  246. package/dist/esm/components/static-asset/controller/base.definition.js.map +1 -1
  247. package/dist/esm/components/static-asset/controller/factory.d.ts +3 -0
  248. package/dist/esm/components/static-asset/controller/factory.js +18 -9
  249. package/dist/esm/components/static-asset/controller/factory.js.map +1 -1
  250. package/dist/esm/components/static-asset/controller/meta-link.js +1 -1
  251. package/dist/esm/components/static-asset/controller/meta-link.js.map +1 -1
  252. package/dist/esm/components/static-asset/controller/route-options.d.ts +9 -0
  253. package/dist/esm/components/static-asset/controller/route-options.js +16 -3
  254. package/dist/esm/components/static-asset/controller/route-options.js.map +1 -1
  255. package/dist/esm/components/static-asset/ingest.d.ts +7 -3
  256. package/dist/esm/components/static-asset/ingest.js +2 -2
  257. package/dist/esm/components/static-asset/ingest.js.map +1 -1
  258. package/dist/esm/components/static-asset/models/base.model.d.ts +2 -0
  259. package/dist/esm/components/static-asset/models/base.model.js.map +1 -1
  260. package/dist/esm/components/websocket/common/keys.d.ts +1 -0
  261. package/dist/esm/components/websocket/common/keys.js +1 -0
  262. package/dist/esm/components/websocket/common/keys.js.map +1 -1
  263. package/dist/esm/components/websocket/component.d.ts +1 -0
  264. package/dist/esm/components/websocket/component.js +1 -0
  265. package/dist/esm/components/websocket/component.js.map +1 -1
  266. package/dist/esm/testing/assert-application-boots.d.ts +48 -8
  267. package/dist/esm/testing/assert-application-boots.js +25 -1
  268. package/dist/esm/testing/assert-application-boots.js.map +1 -1
  269. package/dist/esm/utilities/drizzle-result.utility.d.ts +1 -0
  270. package/dist/esm/utilities/drizzle-result.utility.js +1 -0
  271. package/dist/esm/utilities/drizzle-result.utility.js.map +1 -1
  272. package/dist/presets/app/preset.json +4 -4
  273. package/dist/presets/lib/preset.json +3 -3
  274. package/dist/presets/shared/preset.json +1 -1
  275. package/package.json +8 -8
@@ -1 +1 @@
1
- {"version":3,"file":"casbin.enforcer.js","sourceRoot":"","sources":["../../../../../../src/components/auth/authorize/enforcers/casbin.enforcer.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAQnF,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,EAC1B,2BAA2B,EAC3B,oBAAoB,EACpB,6BAA6B,EAC7B,0BAA0B,EAC1B,kBAAkB,GAQnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAe/D,sMAAsM;AAEtM,IAAa,2BAA2B,mCAAxC,MAAa,2BAKX,SAAQ,UAAU;IAclB,YAEE,OAA8D;QAE9D,KAAK,CAAC,EAAE,KAAK,EAAE,6BAA2B,CAAC,IAAI,E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AAC,CAAC;IACL,CAAC;IAED,2BAA2B;IAE3B,gNAAgN;IACtM,KAAK,CAAC,gBAAgB,CAAC,IAAkC;QACjE,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,CAAC;QACzC,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QAEvE,OAAO,eAAe,CAAC,gBAAgB,CAAC;YACtC,MAAM;YACN,KAAK;YACL,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;YAC7B,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;IAED,oJAAoJ;IAC1I,KAAK,CAAC,wBAAwB,CAAC,IAGxC;QACC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,oEAAoE;aAC9E,CAAC,CAAC;QACL,CAAC;QAED,MAAM,eAAe,CAAC,kBAAkB,CAAC;YACvC,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAhbY,2BAA2B;IAoBnC,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,oBAAoB,CAAC,eAAe,CAAC,0BAA0B,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;;GApBhF,2BAA2B,CAgbvC","sourcesContent":["import { type TContext } from '@venizia/ignis-kernel';\nimport { inject } from '@venizia/ignis-kernel';\nimport { BaseHelper, BasePoolHelper, getError } from '@venizia/ignis-helpers/core';\nimport { type TNullable } from '@venizia/ignis-helpers/common';\nimport type {\n Enforcer as CasbinEnforcerType,\n Helper as CasbinHelperType,\n RoleManager as CasbinRoleManagerType,\n} from 'casbin';\nimport { type Env } from 'hono';\nimport { AuthorizationPermissionBuilder } from '@venizia/ignis-kernel';\nimport {\n AuthorizationDecisions,\n AuthorizationDomainScopes,\n AuthorizationEnforcerTypes,\n AuthorizationPolicyVariants,\n AuthorizeBindingKeys,\n CasbinDomainMatchingFunctions,\n CasbinEnforcerModelDrivers,\n CasbinRuleVariants,\n type IAuthorizationEnforcer,\n type IAuthorizationUser,\n type ICasbinEnforcerOptions,\n type ICasbinRules,\n type IAuthorizationRequest,\n type TAuthorizationDecision,\n type TCasbinDomainMatchingFunction,\n} from '@venizia/ignis-kernel';\nimport { DomainHierarchyRoleManager } from '../role-managers/domain-hierarchy';\nimport { CasbinModule } from './casbin-module';\nimport { MembershipRoleManager } from '../role-managers/membership';\nimport { ResourceRoleManager } from '../role-managers/resource';\nimport { PolicyLineCodec } from './policy-line-codec';\nimport { UserPolicyLineCache } from './user-policy-line-cache';\n\n/** Payload shape for the scoped/custom path, matching defaultScopedPayloadFn(). */\ntype TNormalizePayloadFn<E extends Env, TAction, TResource> = (opts: {\n user: IAuthorizationUser;\n action: TAction;\n resource: TResource;\n context: TContext<E, string>;\n}) => { subject: string; resource: string; action: string; domain?: string };\n\n/** `addDomainHierarchy` lives on casbin's `DefaultRoleManager`, not on the `RoleManager` interface or the `Enforcer` facade - feature-detect it on whatever `getNamedRoleManager` returns. */\ninterface ICasbinRoleManagerWithDomainHierarchy {\n addDomainHierarchy?(rm: CasbinRoleManagerType): Promise<void>;\n}\n\n// Wraps casbin (optional peer dep). Each request borrows its own pooled enforcer; any error during use destroys it (fail-closed). Pooled enforcers carry no adapter - only extractUserLines uses one.\n\nexport class CasbinAuthorizationEnforcer<\n E extends Env = Env,\n TAction extends string = string,\n TResource extends string = string,\n>\n extends BaseHelper\n implements IAuthorizationEnforcer<E, TAction, TResource, ICasbinRules>\n{\n name = CasbinAuthorizationEnforcer.name;\n private readonly MIN_EXPIRES_IN = 10_000;\n\n private pool: TNullable<BasePoolHelper<CasbinEnforcerType>> = null;\n private helper: TNullable<typeof CasbinHelperType> = null;\n // Lazily created on first cache use (see requireRedisCache) - one instance for the enforcer's lifetime so its single-flight de-dup map actually dedupes.\n private userPolicyLineCache: TNullable<UserPolicyLineCache> = null;\n\n // Memoized in configure() (options are fixed after) to avoid rebuilding this closure on every evaluate() (hot path).\n private resolvedPayloadFn: TNullable<TNormalizePayloadFn<E, TAction, TResource>> = null;\n\n constructor(\n @inject({ key: AuthorizeBindingKeys.enforcerOptions(AuthorizationEnforcerTypes.CASBIN) })\n private options: ICasbinEnforcerOptions<E, TAction, TResource>,\n ) {\n super({ scope: CasbinAuthorizationEnforcer.name });\n }\n\n // Lifecycle\n\n async configure(): Promise<void> {\n const casbin = await CasbinModule.load();\n\n if (!this.options.model) {\n throw getError({\n message: '[CasbinAuthorizationEnforcer] options.model is required.',\n });\n }\n\n this.helper = casbin.Helper;\n\n this.resolvedPayloadFn = this.options.normalizePayloadFn ?? this.defaultScopedPayloadFn();\n\n const { cached } = this.options;\n\n if (cached.use) {\n this.validateExpiresIn({ expiresIn: cached.options.expiresIn });\n }\n\n this.pool = new BasePoolHelper<CasbinEnforcerType>({\n scope: `${CasbinAuthorizationEnforcer.name}.Pool`,\n size: this.options.poolSize ?? 16,\n acquireTimeoutMs: this.options.poolAcquireTimeoutMs ?? 5000,\n create: async () => {\n const model = this.resolveModel({ casbin, model: this.options.model });\n\n const enforcer = await casbin.newEnforcer(model);\n await this.registerMatchers({ enforcer, casbin });\n this.assertMatcherCompilesSync({ enforcer });\n\n return enforcer;\n },\n });\n await this.pool.warmup();\n\n this.logger\n .for(this.configure.name)\n .info(\n 'Casbin enforcer pool ready (size: %s, cached: %s)',\n this.options.poolSize ?? 16,\n cached.use ? cached.driver : 'none',\n );\n }\n\n destroy(): void {\n this.pool?.destroy().catch((error) => {\n this.logger.for(this.destroy.name).warn('Pool destroy failed: %s', error);\n });\n }\n\n /** casbin compiles the matcher lazily (first enforce, not newEnforcer/buildRoleLinks); this dummy enforceSync forces the compile at warmup so syntax / unregistered-function / arity errors fail boot. */\n protected assertMatcherCompilesSync(opts: { enforcer: CasbinEnforcerType }) {\n try {\n if (this.options.isScoped || this.options.normalizePayloadFn) {\n opts.enforcer.enforceSync('::warmup', '::warmup', '::warmup', '::warmup');\n\n return;\n }\n\n opts.enforcer.enforceSync('::warmup', '::warmup', '::warmup');\n } catch (error) {\n throw getError({\n message: `[CasbinAuthorizationEnforcer] Matcher smoke test failed at warmup - the model matcher did not compile (check matcher syntax, that every referenced function is registered, and the request arity). ${String(error)}`,\n });\n }\n }\n\n // IAuthorizationEnforcer - public API\n\n async buildRules(opts: {\n user: IAuthorizationUser;\n context: TContext<E, string>;\n }): Promise<ICasbinRules> {\n const { user } = opts;\n const cached = this.options.cached;\n\n let lines: string[];\n\n if (cached.use) {\n const fetched = await this.requireRedisCache().fetch({ user });\n lines = fetched;\n } else {\n const extracted = await this.extractUserLines({ user });\n lines = extracted;\n }\n\n return { user, lines };\n }\n\n async evaluate(opts: {\n rules: ICasbinRules;\n request: IAuthorizationRequest<TAction, TResource>;\n context: TContext<E, string>;\n }): Promise<TAuthorizationDecision> {\n if (!this.pool) {\n throw getError({\n message: '[CasbinAuthorizationEnforcer] Not configured. Call configure() first.',\n });\n }\n\n if (!opts.request?.action || !opts.request?.resource) {\n throw getError({\n message: '[CasbinAuthorizationEnforcer] request.action and request.resource are required.',\n });\n }\n\n const { rules, request, context } = opts;\n const { user, lines } = rules;\n\n return this.pool.use({\n execution: async (enforcer) => {\n await this.loadPolicyLinesIntoModel({ enforcer, lines });\n\n const normalizePayloadFn = this.resolvedPayloadFn;\n\n if (!normalizePayloadFn) {\n const subject = `${user.principalType}_${user.userId}`;\n const isAllowed = this.enforceWithExplain({\n enforcer,\n vals: [subject, String(request.resource), String(request.action)],\n });\n\n return isAllowed ? AuthorizationDecisions.ALLOW : AuthorizationDecisions.DENY;\n }\n\n const normalized = normalizePayloadFn({\n user,\n action: request.action,\n resource: request.resource,\n context,\n });\n\n // Scoped model is 4-token (sub, dom, obj, act): a request with no resolvable domain still needs one - default SYSTEM_WIDE, never the 3-arg path, which misaligns args and silently misjudges.\n const domain =\n normalized.domain ??\n request.domain ??\n (this.options.isScoped ? AuthorizationDomainScopes.SYSTEM_WIDE : undefined);\n\n const vals = domain\n ? [normalized.subject, domain, normalized.resource, normalized.action]\n : [normalized.subject, normalized.resource, normalized.action];\n const isAllowed = this.enforceWithExplain({ enforcer, vals });\n\n return isAllowed ? AuthorizationDecisions.ALLOW : AuthorizationDecisions.DENY;\n },\n });\n }\n\n /** On DENY, logs the deciding policy rule; matchedPolicy is `[]` when nothing matched (default-deny). */\n protected enforceWithExplain(opts: { enforcer: CasbinEnforcerType; vals: string[] }): boolean {\n const [isAllowed, matchedPolicy] = opts.enforcer.enforceExSync(...opts.vals);\n\n if (!isAllowed) {\n this.logger\n .for(this.evaluate.name)\n .info(\n 'DENY | request: [%s] | matchedPolicy: %s',\n opts.vals.join(', '),\n matchedPolicy.length ? matchedPolicy.join(', ') : '<none - default-deny>',\n );\n }\n\n return isAllowed;\n }\n\n // Cache management - optional IAuthorizationEnforcer members (on-demand)\n async invalidateUserCache(opts: {\n user: IAuthorizationUser;\n }): Promise<{ invalidatedKeys: number }> {\n const { cacheKey, invalidatedKeys } = await this.requireRedisCache().invalidate({\n user: opts.user,\n });\n\n this.logger\n .for(this.invalidateUserCache.name)\n .info(\n 'Invalidated authz cache | user: %s | key: %s | deleted: %s',\n opts.user.userId,\n cacheKey,\n invalidatedKeys,\n );\n\n return { invalidatedKeys };\n }\n\n async rebuildUserCache(opts: {\n user: IAuthorizationUser;\n }): Promise<{ cacheKey: string; lineCount: number }> {\n // Extraction runs on an isolated throwaway enforcer (not a serving model), so a concurrent request cannot make us cache another user's policies under this key.\n const { cacheKey, lines } = await this.requireRedisCache().rebuild({ user: opts.user });\n\n this.logger\n .for(this.rebuildUserCache.name)\n .info(\n 'Rebuilt authz cache | user: %s | key: %s | lines: %s',\n opts.user.userId,\n cacheKey,\n lines.length,\n );\n\n return { cacheKey, lineCount: lines.length };\n }\n\n /** Narrow `options.cached` to the redis variant and lazily create the per-user line cache - memoized so its single-flight de-dup map is shared across calls rather than reset on every access. */\n protected requireRedisCache(): UserPolicyLineCache {\n const { cached } = this.options;\n\n if (!cached.use) {\n throw getError({\n message:\n '[CasbinAuthorizationEnforcer] Cache management requires the redis cache driver, but caching is disabled.',\n });\n }\n\n return (this.userPolicyLineCache ??= new UserPolicyLineCache({\n cached,\n loadLines: (opts) => this.extractUserLines(opts),\n }));\n }\n\n // Matchers & model resolvers\n\n protected async registerMatchers(opts: {\n enforcer: CasbinEnforcerType;\n casbin: typeof import('casbin');\n }): Promise<void> {\n const { enforcer, casbin } = opts;\n const { domainMatching, isScoped } = this.options;\n\n if (domainMatching) {\n if (!enforcer.getNamedRoleManager(domainMatching.roleDefinition)) {\n throw getError({\n message: `[registerMatchers] Role definition \"${domainMatching.roleDefinition}\" is not declared in the Casbin model. Declare it under [role_definition] (e.g. \\`g = _, _, _\\`) before enabling domainMatching.`,\n });\n }\n\n const matchFn = this.resolveDomainMatchingFn({ casbin, name: domainMatching.fn });\n await enforcer.addNamedDomainMatchingFunc(domainMatching.roleDefinition, matchFn);\n }\n\n if (isScoped) {\n await enforcer.addNamedDomainMatchingFunc(CasbinRuleVariants.G, casbin.Util.keyMatchFunc);\n await enforcer.addFunction('objectMatch', AuthorizationPermissionBuilder.objectMatch);\n\n // A dedicated role manager for the resource axis, NOT addNamedMatchingFunc: a matching func sets casbin's `hasPattern`, which makes every hasLink rebuild the whole g4 graph.\n enforcer.setNamedRoleManager(\n AuthorizationPolicyVariants.RESOURCE_INHERITS.rule,\n new ResourceRoleManager(),\n );\n\n // Shared across g2, g3, and the reversed `g` instance below: casbin never puts the\n // `g`-axis hierarchy manager in rmMap, so it never receives addLink and would miss\n // per-request g3 edges - g2 needs the same freshness for a just-created child domain.\n // This is a per-REQUEST overlay: `clear()` empties it every buildRoleLinks cycle, and it is\n // repopulated from whatever `g3` lines this principal's own policy line set carries.\n const domainHierarchyOverlay = new Map<string, Set<string>>();\n\n // g2 (membership) and g3 (domain nesting, request-domain-first) sit on their own axes.\n enforcer.setNamedRoleManager(\n CasbinRuleVariants.G2,\n new MembershipRoleManager({ overlay: domainHierarchyOverlay }),\n );\n\n enforcer.setNamedRoleManager(\n CasbinRuleVariants.G3,\n new DomainHierarchyRoleManager({ overlay: domainHierarchyOverlay }),\n );\n\n // addNamedDomainMatchingFunc(G, keyMatchFunc) above must stay: generateTempRoles ORs\n // hasDomainPattern with hasDomainHierarchy, and role_inherits `*` rides the keyMatch path.\n const gRoleManager = enforcer.getNamedRoleManager(CasbinRuleVariants.G) as\n | (CasbinRoleManagerType & ICasbinRoleManagerWithDomainHierarchy)\n | undefined;\n\n if (!gRoleManager?.addDomainHierarchy) {\n throw getError({\n message:\n '[registerMatchers] The \"g\" role manager does not expose addDomainHierarchy() - the scoped model requires casbin\\'s DefaultRoleManager on the g axis (present in casbin ^5.51.1, this package\\'s pinned range). Upgrade casbin, or check that a custom role manager was not substituted for \"g\".',\n });\n }\n\n await gRoleManager.addDomainHierarchy(\n new DomainHierarchyRoleManager({ reversed: true, overlay: domainHierarchyOverlay }),\n );\n }\n\n await enforcer.buildRoleLinks();\n }\n\n /** Map a CasbinDomainMatchingFunctions value to casbin's Util.*Func matcher. */\n protected resolveDomainMatchingFn(opts: {\n casbin: typeof import('casbin');\n name: TCasbinDomainMatchingFunction;\n }): (arg1: string, arg2: string) => boolean {\n // casbin Util built-ins: (requestValue, policyValue) => match. keyMatchFunc only special-cases `*` (never splits on `/` or `:`), so it cannot pattern-match a `Merchant_<uuid>`; see CasbinDomainMatchingFunctions for per-function semantics.\n const { Util } = opts.casbin;\n\n switch (opts.name) {\n case CasbinDomainMatchingFunctions.KEY_MATCH: {\n return Util.keyMatchFunc;\n }\n case CasbinDomainMatchingFunctions.KEY_MATCH_2: {\n return Util.keyMatch2Func;\n }\n case CasbinDomainMatchingFunctions.KEY_MATCH_3: {\n return Util.keyMatch3Func;\n }\n case CasbinDomainMatchingFunctions.KEY_MATCH_4: {\n return Util.keyMatch4Func;\n }\n case CasbinDomainMatchingFunctions.REGEX_MATCH: {\n return Util.regexMatchFunc;\n }\n default: {\n throw getError({\n message: `[resolveDomainMatchingFn] Unsupported func: ${opts.name} | Valids: [${[...CasbinDomainMatchingFunctions.SCHEME_SET].join(', ')}]`,\n });\n }\n }\n }\n\n /** Default (sub,dom,obj,act) payload for the scoped model; domain comes from request.domain. */\n protected defaultScopedPayloadFn(): TNormalizePayloadFn<E, TAction, TResource> | undefined {\n if (!this.options.isScoped) {\n return undefined;\n }\n\n return (opts: {\n user: IAuthorizationUser;\n action: TAction;\n resource: TResource;\n }): { subject: string; resource: string; action: string; domain?: string } => {\n // No domain here - evaluate() fills it from request.domain (set by the provider).\n return {\n subject: `${opts.user.principalType}_${opts.user.userId}`,\n resource: String(opts.resource),\n action: String(opts.action),\n };\n };\n }\n\n protected resolveModel(opts: {\n casbin: typeof import('casbin');\n model: ICasbinEnforcerOptions['model'];\n }) {\n const { casbin, model } = opts;\n\n switch (model.driver) {\n case CasbinEnforcerModelDrivers.FILE: {\n return casbin.newModelFromFile(model.definition);\n }\n case CasbinEnforcerModelDrivers.TEXT: {\n return casbin.newModelFromString(model.definition);\n }\n default: {\n throw getError({\n message: `[resolveModel] Invalid model.driver | Valids: [${CasbinEnforcerModelDrivers.FILE}, ${CasbinEnforcerModelDrivers.TEXT}]`,\n });\n }\n }\n }\n\n protected validateExpiresIn(opts: { expiresIn: number }): void {\n if (opts.expiresIn >= this.MIN_EXPIRES_IN) {\n return;\n }\n\n throw getError({\n message: `[CasbinAuthorizationEnforcer] cached.options.expiresIn must be >= ${this.MIN_EXPIRES_IN} (ms) | Received: ${opts.expiresIn}`,\n });\n }\n\n // Policy loading internals\n\n /** Resolves this enforcer's model, then delegates the isolated-enforcer extraction (own model + adapter, never a pooled serving one, so concurrent requests cannot change what we cache) to PolicyLineCodec. */\n protected async extractUserLines(opts: { user: IAuthorizationUser }): Promise<string[]> {\n const casbin = await CasbinModule.load();\n const model = this.resolveModel({ casbin, model: this.options.model });\n\n return PolicyLineCodec.extractUserLines({\n casbin,\n model,\n adapter: this.options.adapter,\n user: opts.user,\n });\n }\n\n /** Requires configure() to have resolved the casbin Helper; the clearPolicy + loadPolicyLine + buildRoleLinks ordering lives in PolicyLineCodec. */\n protected async loadPolicyLinesIntoModel(opts: {\n enforcer: CasbinEnforcerType;\n lines: string[];\n }): Promise<void> {\n if (!this.helper) {\n throw getError({\n message: '[loadPolicyLinesIntoModel] Not configured. Call configure() first.',\n });\n }\n\n await PolicyLineCodec.loadLinesIntoModel({\n enforcer: opts.enforcer,\n lines: opts.lines,\n helper: this.helper,\n });\n }\n}\n"]}
1
+ {"version":3,"file":"casbin.enforcer.js","sourceRoot":"","sources":["../../../../../../src/components/auth/authorize/enforcers/casbin.enforcer.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAQnF,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,EAC1B,2BAA2B,EAC3B,oBAAoB,EACpB,6BAA6B,EAC7B,0BAA0B,EAC1B,kBAAkB,GAQnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAe/D,sMAAsM;AAEtM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EAAE,CAAC;YAC1C,OAAO;QACT,CAAC;QAED,MAAM,QAAQ,CAAC;YACb,OAAO,EAAE,qEAAqE,IAAI,CAAC,cAAc,qBAAqB,IAAI,CAAC,SAAS,EAAE;SACvI,CAAC,CAAC;IACL,CAAC;IAED,2BAA2B;IAE3B,gNAAgN;IACtM,KAAK,CAAC,gBAAgB,CAAC,IAAkC;QACjE,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,CAAC;QACzC,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QAEvE,OAAO,eAAe,CAAC,gBAAgB,CAAC;YACtC,MAAM;YACN,KAAK;YACL,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;YAC7B,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;IAED,oJAAoJ;IAC1I,KAAK,CAAC,wBAAwB,CAAC,IAGxC;QACC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,oEAAoE;aAC9E,CAAC,CAAC;QACL,CAAC;QAED,MAAM,eAAe,CAAC,kBAAkB,CAAC;YACvC,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAhbY,2BAA2B;IAoBnC,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,oBAAoB,CAAC,eAAe,CAAC,0BAA0B,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;;GApBhF,2BAA2B,CAgbvC","sourcesContent":["import { type TContext } from '@venizia/ignis-kernel';\nimport { inject } from '@venizia/ignis-kernel';\nimport { BaseHelper, BasePoolHelper, getError } from '@venizia/ignis-helpers/core';\nimport { type TNullable } from '@venizia/ignis-helpers/common';\nimport type {\n Enforcer as CasbinEnforcerType,\n Helper as CasbinHelperType,\n RoleManager as CasbinRoleManagerType,\n} from 'casbin';\nimport { type Env } from 'hono';\nimport { AuthorizationPermissionBuilder } from '@venizia/ignis-kernel';\nimport {\n AuthorizationDecisions,\n AuthorizationDomainScopes,\n AuthorizationEnforcerTypes,\n AuthorizationPolicyVariants,\n AuthorizeBindingKeys,\n CasbinDomainMatchingFunctions,\n CasbinEnforcerModelDrivers,\n CasbinRuleVariants,\n type IAuthorizationEnforcer,\n type IAuthorizationUser,\n type ICasbinEnforcerOptions,\n type ICasbinRules,\n type IAuthorizationRequest,\n type TAuthorizationDecision,\n type TCasbinDomainMatchingFunction,\n} from '@venizia/ignis-kernel';\nimport { DomainHierarchyRoleManager } from '../role-managers/domain-hierarchy';\nimport { CasbinModule } from './casbin-module';\nimport { MembershipRoleManager } from '../role-managers/membership';\nimport { ResourceRoleManager } from '../role-managers/resource';\nimport { PolicyLineCodec } from './policy-line-codec';\nimport { UserPolicyLineCache } from './user-policy-line-cache';\n\n/** Payload shape for the scoped/custom path, matching defaultScopedPayloadFn(). */\ntype TNormalizePayloadFn<E extends Env, TAction, TResource> = (opts: {\n user: IAuthorizationUser;\n action: TAction;\n resource: TResource;\n context: TContext<E, string>;\n}) => { subject: string; resource: string; action: string; domain?: string };\n\n/** `addDomainHierarchy` lives on casbin's `DefaultRoleManager`, not on the `RoleManager` interface or the `Enforcer` facade - feature-detect it on whatever `getNamedRoleManager` returns. */\ninterface ICasbinRoleManagerWithDomainHierarchy {\n addDomainHierarchy?(rm: CasbinRoleManagerType): Promise<void>;\n}\n\n// Wraps casbin (optional peer dep). Each request borrows its own pooled enforcer; any error during use destroys it (fail-closed). Pooled enforcers carry no adapter - only extractUserLines uses one.\n\n/** Authorization enforcer backed by casbin (an optional peer dependency); `configure()` throws when `options.model` is missing. */\nexport class CasbinAuthorizationEnforcer<\n E extends Env = Env,\n TAction extends string = string,\n TResource extends string = string,\n>\n extends BaseHelper\n implements IAuthorizationEnforcer<E, TAction, TResource, ICasbinRules>\n{\n name = CasbinAuthorizationEnforcer.name;\n private readonly MIN_EXPIRES_IN = 10_000;\n\n private pool: TNullable<BasePoolHelper<CasbinEnforcerType>> = null;\n private helper: TNullable<typeof CasbinHelperType> = null;\n // Lazily created on first cache use (see requireRedisCache) - one instance for the enforcer's lifetime so its single-flight de-dup map actually dedupes.\n private userPolicyLineCache: TNullable<UserPolicyLineCache> = null;\n\n // Memoized in configure() (options are fixed after) to avoid rebuilding this closure on every evaluate() (hot path).\n private resolvedPayloadFn: TNullable<TNormalizePayloadFn<E, TAction, TResource>> = null;\n\n constructor(\n @inject({ key: AuthorizeBindingKeys.enforcerOptions(AuthorizationEnforcerTypes.CASBIN) })\n private options: ICasbinEnforcerOptions<E, TAction, TResource>,\n ) {\n super({ scope: CasbinAuthorizationEnforcer.name });\n }\n\n // Lifecycle\n\n async configure(): Promise<void> {\n const casbin = await CasbinModule.load();\n\n if (!this.options.model) {\n throw getError({\n message: '[CasbinAuthorizationEnforcer] options.model is required.',\n });\n }\n\n this.helper = casbin.Helper;\n\n this.resolvedPayloadFn = this.options.normalizePayloadFn ?? this.defaultScopedPayloadFn();\n\n const { cached } = this.options;\n\n if (cached.use) {\n this.validateExpiresIn({ expiresIn: cached.options.expiresIn });\n }\n\n this.pool = new BasePoolHelper<CasbinEnforcerType>({\n scope: `${CasbinAuthorizationEnforcer.name}.Pool`,\n size: this.options.poolSize ?? 16,\n acquireTimeoutMs: this.options.poolAcquireTimeoutMs ?? 5000,\n create: async () => {\n const model = this.resolveModel({ casbin, model: this.options.model });\n\n const enforcer = await casbin.newEnforcer(model);\n await this.registerMatchers({ enforcer, casbin });\n this.assertMatcherCompilesSync({ enforcer });\n\n return enforcer;\n },\n });\n await this.pool.warmup();\n\n this.logger\n .for(this.configure.name)\n .info(\n 'Casbin enforcer pool ready (size: %s, cached: %s)',\n this.options.poolSize ?? 16,\n cached.use ? cached.driver : 'none',\n );\n }\n\n destroy(): void {\n this.pool?.destroy().catch((error) => {\n this.logger.for(this.destroy.name).warn('Pool destroy failed: %s', error);\n });\n }\n\n /** casbin compiles the matcher lazily (first enforce, not newEnforcer/buildRoleLinks); this dummy enforceSync forces the compile at warmup so syntax / unregistered-function / arity errors fail boot. */\n protected assertMatcherCompilesSync(opts: { enforcer: CasbinEnforcerType }) {\n try {\n if (this.options.isScoped || this.options.normalizePayloadFn) {\n opts.enforcer.enforceSync('::warmup', '::warmup', '::warmup', '::warmup');\n\n return;\n }\n\n opts.enforcer.enforceSync('::warmup', '::warmup', '::warmup');\n } catch (error) {\n throw getError({\n message: `[CasbinAuthorizationEnforcer] Matcher smoke test failed at warmup - the model matcher did not compile (check matcher syntax, that every referenced function is registered, and the request arity). ${String(error)}`,\n });\n }\n }\n\n // IAuthorizationEnforcer - public API\n\n async buildRules(opts: {\n user: IAuthorizationUser;\n context: TContext<E, string>;\n }): Promise<ICasbinRules> {\n const { user } = opts;\n const cached = this.options.cached;\n\n let lines: string[];\n\n if (cached.use) {\n const fetched = await this.requireRedisCache().fetch({ user });\n lines = fetched;\n } else {\n const extracted = await this.extractUserLines({ user });\n lines = extracted;\n }\n\n return { user, lines };\n }\n\n async evaluate(opts: {\n rules: ICasbinRules;\n request: IAuthorizationRequest<TAction, TResource>;\n context: TContext<E, string>;\n }): Promise<TAuthorizationDecision> {\n if (!this.pool) {\n throw getError({\n message: '[CasbinAuthorizationEnforcer] Not configured. Call configure() first.',\n });\n }\n\n if (!opts.request?.action || !opts.request?.resource) {\n throw getError({\n message: '[CasbinAuthorizationEnforcer] request.action and request.resource are required.',\n });\n }\n\n const { rules, request, context } = opts;\n const { user, lines } = rules;\n\n return this.pool.use({\n execution: async (enforcer) => {\n await this.loadPolicyLinesIntoModel({ enforcer, lines });\n\n const normalizePayloadFn = this.resolvedPayloadFn;\n\n if (!normalizePayloadFn) {\n const subject = `${user.principalType}_${user.userId}`;\n const isAllowed = this.enforceWithExplain({\n enforcer,\n vals: [subject, String(request.resource), String(request.action)],\n });\n\n return isAllowed ? AuthorizationDecisions.ALLOW : AuthorizationDecisions.DENY;\n }\n\n const normalized = normalizePayloadFn({\n user,\n action: request.action,\n resource: request.resource,\n context,\n });\n\n // Scoped model is 4-token (sub, dom, obj, act): a request with no resolvable domain still needs one - default SYSTEM_WIDE, never the 3-arg path, which misaligns args and silently misjudges.\n const domain =\n normalized.domain ??\n request.domain ??\n (this.options.isScoped ? AuthorizationDomainScopes.SYSTEM_WIDE : undefined);\n\n const vals = domain\n ? [normalized.subject, domain, normalized.resource, normalized.action]\n : [normalized.subject, normalized.resource, normalized.action];\n const isAllowed = this.enforceWithExplain({ enforcer, vals });\n\n return isAllowed ? AuthorizationDecisions.ALLOW : AuthorizationDecisions.DENY;\n },\n });\n }\n\n /** On DENY, logs the deciding policy rule; matchedPolicy is `[]` when nothing matched (default-deny). */\n protected enforceWithExplain(opts: { enforcer: CasbinEnforcerType; vals: string[] }): boolean {\n const [isAllowed, matchedPolicy] = opts.enforcer.enforceExSync(...opts.vals);\n\n if (!isAllowed) {\n this.logger\n .for(this.evaluate.name)\n .info(\n 'DENY | request: [%s] | matchedPolicy: %s',\n opts.vals.join(', '),\n matchedPolicy.length ? matchedPolicy.join(', ') : '<none - default-deny>',\n );\n }\n\n return isAllowed;\n }\n\n // Cache management - optional IAuthorizationEnforcer members (on-demand)\n async invalidateUserCache(opts: {\n user: IAuthorizationUser;\n }): Promise<{ invalidatedKeys: number }> {\n const { cacheKey, invalidatedKeys } = await this.requireRedisCache().invalidate({\n user: opts.user,\n });\n\n this.logger\n .for(this.invalidateUserCache.name)\n .info(\n 'Invalidated authz cache | user: %s | key: %s | deleted: %s',\n opts.user.userId,\n cacheKey,\n invalidatedKeys,\n );\n\n return { invalidatedKeys };\n }\n\n async rebuildUserCache(opts: {\n user: IAuthorizationUser;\n }): Promise<{ cacheKey: string; lineCount: number }> {\n // Extraction runs on an isolated throwaway enforcer (not a serving model), so a concurrent request cannot make us cache another user's policies under this key.\n const { cacheKey, lines } = await this.requireRedisCache().rebuild({ user: opts.user });\n\n this.logger\n .for(this.rebuildUserCache.name)\n .info(\n 'Rebuilt authz cache | user: %s | key: %s | lines: %s',\n opts.user.userId,\n cacheKey,\n lines.length,\n );\n\n return { cacheKey, lineCount: lines.length };\n }\n\n /** Narrow `options.cached` to the redis variant and lazily create the per-user line cache - memoized so its single-flight de-dup map is shared across calls rather than reset on every access. */\n protected requireRedisCache(): UserPolicyLineCache {\n const { cached } = this.options;\n\n if (!cached.use) {\n throw getError({\n message:\n '[CasbinAuthorizationEnforcer] Cache management requires the redis cache driver, but caching is disabled.',\n });\n }\n\n return (this.userPolicyLineCache ??= new UserPolicyLineCache({\n cached,\n loadLines: (opts) => this.extractUserLines(opts),\n }));\n }\n\n // Matchers & model resolvers\n\n protected async registerMatchers(opts: {\n enforcer: CasbinEnforcerType;\n casbin: typeof import('casbin');\n }): Promise<void> {\n const { enforcer, casbin } = opts;\n const { domainMatching, isScoped } = this.options;\n\n if (domainMatching) {\n if (!enforcer.getNamedRoleManager(domainMatching.roleDefinition)) {\n throw getError({\n message: `[registerMatchers] Role definition \"${domainMatching.roleDefinition}\" is not declared in the Casbin model. Declare it under [role_definition] (e.g. \\`g = _, _, _\\`) before enabling domainMatching.`,\n });\n }\n\n const matchFn = this.resolveDomainMatchingFn({ casbin, name: domainMatching.fn });\n await enforcer.addNamedDomainMatchingFunc(domainMatching.roleDefinition, matchFn);\n }\n\n if (isScoped) {\n await enforcer.addNamedDomainMatchingFunc(CasbinRuleVariants.G, casbin.Util.keyMatchFunc);\n await enforcer.addFunction('objectMatch', AuthorizationPermissionBuilder.objectMatch);\n\n // A dedicated role manager for the resource axis, NOT addNamedMatchingFunc: a matching func sets casbin's `hasPattern`, which makes every hasLink rebuild the whole g4 graph.\n enforcer.setNamedRoleManager(\n AuthorizationPolicyVariants.RESOURCE_INHERITS.rule,\n new ResourceRoleManager(),\n );\n\n // Shared across g2, g3, and the reversed `g` instance below: casbin never puts the\n // `g`-axis hierarchy manager in rmMap, so it never receives addLink and would miss\n // per-request g3 edges - g2 needs the same freshness for a just-created child domain.\n // This is a per-REQUEST overlay: `clear()` empties it every buildRoleLinks cycle, and it is\n // repopulated from whatever `g3` lines this principal's own policy line set carries.\n const domainHierarchyOverlay = new Map<string, Set<string>>();\n\n // g2 (membership) and g3 (domain nesting, request-domain-first) sit on their own axes.\n enforcer.setNamedRoleManager(\n CasbinRuleVariants.G2,\n new MembershipRoleManager({ overlay: domainHierarchyOverlay }),\n );\n\n enforcer.setNamedRoleManager(\n CasbinRuleVariants.G3,\n new DomainHierarchyRoleManager({ overlay: domainHierarchyOverlay }),\n );\n\n // addNamedDomainMatchingFunc(G, keyMatchFunc) above must stay: generateTempRoles ORs\n // hasDomainPattern with hasDomainHierarchy, and role_inherits `*` rides the keyMatch path.\n const gRoleManager = enforcer.getNamedRoleManager(CasbinRuleVariants.G) as\n | (CasbinRoleManagerType & ICasbinRoleManagerWithDomainHierarchy)\n | undefined;\n\n if (!gRoleManager?.addDomainHierarchy) {\n throw getError({\n message:\n '[registerMatchers] The \"g\" role manager does not expose addDomainHierarchy() - the scoped model requires casbin\\'s DefaultRoleManager on the g axis (present in casbin ^5.51.1, this package\\'s pinned range). Upgrade casbin, or check that a custom role manager was not substituted for \"g\".',\n });\n }\n\n await gRoleManager.addDomainHierarchy(\n new DomainHierarchyRoleManager({ reversed: true, overlay: domainHierarchyOverlay }),\n );\n }\n\n await enforcer.buildRoleLinks();\n }\n\n /** Map a CasbinDomainMatchingFunctions value to casbin's Util.*Func matcher. */\n protected resolveDomainMatchingFn(opts: {\n casbin: typeof import('casbin');\n name: TCasbinDomainMatchingFunction;\n }): (arg1: string, arg2: string) => boolean {\n // casbin Util built-ins: (requestValue, policyValue) => match. keyMatchFunc only special-cases `*` (never splits on `/` or `:`), so it cannot pattern-match a `Merchant_<uuid>`; see CasbinDomainMatchingFunctions for per-function semantics.\n const { Util } = opts.casbin;\n\n switch (opts.name) {\n case CasbinDomainMatchingFunctions.KEY_MATCH: {\n return Util.keyMatchFunc;\n }\n case CasbinDomainMatchingFunctions.KEY_MATCH_2: {\n return Util.keyMatch2Func;\n }\n case CasbinDomainMatchingFunctions.KEY_MATCH_3: {\n return Util.keyMatch3Func;\n }\n case CasbinDomainMatchingFunctions.KEY_MATCH_4: {\n return Util.keyMatch4Func;\n }\n case CasbinDomainMatchingFunctions.REGEX_MATCH: {\n return Util.regexMatchFunc;\n }\n default: {\n throw getError({\n message: `[resolveDomainMatchingFn] Unsupported func: ${opts.name} | Valids: [${[...CasbinDomainMatchingFunctions.SCHEME_SET].join(', ')}]`,\n });\n }\n }\n }\n\n /** Default (sub,dom,obj,act) payload for the scoped model; domain comes from request.domain. */\n protected defaultScopedPayloadFn(): TNormalizePayloadFn<E, TAction, TResource> | undefined {\n if (!this.options.isScoped) {\n return undefined;\n }\n\n return (opts: {\n user: IAuthorizationUser;\n action: TAction;\n resource: TResource;\n }): { subject: string; resource: string; action: string; domain?: string } => {\n // No domain here - evaluate() fills it from request.domain (set by the provider).\n return {\n subject: `${opts.user.principalType}_${opts.user.userId}`,\n resource: String(opts.resource),\n action: String(opts.action),\n };\n };\n }\n\n protected resolveModel(opts: {\n casbin: typeof import('casbin');\n model: ICasbinEnforcerOptions['model'];\n }) {\n const { casbin, model } = opts;\n\n switch (model.driver) {\n case CasbinEnforcerModelDrivers.FILE: {\n return casbin.newModelFromFile(model.definition);\n }\n case CasbinEnforcerModelDrivers.TEXT: {\n return casbin.newModelFromString(model.definition);\n }\n default: {\n throw getError({\n message: `[resolveModel] Invalid model.driver | Valids: [${CasbinEnforcerModelDrivers.FILE}, ${CasbinEnforcerModelDrivers.TEXT}]`,\n });\n }\n }\n }\n\n protected validateExpiresIn(opts: { expiresIn: number }): void {\n if (opts.expiresIn >= this.MIN_EXPIRES_IN) {\n return;\n }\n\n throw getError({\n message: `[CasbinAuthorizationEnforcer] cached.options.expiresIn must be >= ${this.MIN_EXPIRES_IN} (ms) | Received: ${opts.expiresIn}`,\n });\n }\n\n // Policy loading internals\n\n /** Resolves this enforcer's model, then delegates the isolated-enforcer extraction (own model + adapter, never a pooled serving one, so concurrent requests cannot change what we cache) to PolicyLineCodec. */\n protected async extractUserLines(opts: { user: IAuthorizationUser }): Promise<string[]> {\n const casbin = await CasbinModule.load();\n const model = this.resolveModel({ casbin, model: this.options.model });\n\n return PolicyLineCodec.extractUserLines({\n casbin,\n model,\n adapter: this.options.adapter,\n user: opts.user,\n });\n }\n\n /** Requires configure() to have resolved the casbin Helper; the clearPolicy + loadPolicyLine + buildRoleLinks ordering lives in PolicyLineCodec. */\n protected async loadPolicyLinesIntoModel(opts: {\n enforcer: CasbinEnforcerType;\n lines: string[];\n }): Promise<void> {\n if (!this.helper) {\n throw getError({\n message: '[loadPolicyLinesIntoModel] Not configured. Call configure() first.',\n });\n }\n\n await PolicyLineCodec.loadLinesIntoModel({\n enforcer: opts.enforcer,\n lines: opts.lines,\n helper: this.helper,\n });\n }\n}\n"]}
@@ -28,6 +28,7 @@ declare const buildCommonPolicyDefinitionColumns: <ExtraVariant extends string =
28
28
  action: PgTextBuilderInitial<"action", [string, ...string[]]>;
29
29
  effect: import("drizzle-orm").$Type<PgTextBuilderInitial<"effect", [string, ...string[]]>, TAuthorizationDecision>;
30
30
  };
31
+ /** Drizzle column set shared by every policy-definition table; `ExtraVariant` widens the allowed `variant` values and `Metadata` types the `metadata` column. */
31
32
  export type TPolicyDefinitionCommonColumns<ExtraVariant extends string = never, Metadata extends object = TSubsetGrantMetadata> = ReturnType<typeof buildCommonPolicyDefinitionColumns<ExtraVariant, Metadata>>;
32
33
  type TPolicyDefinitionColumnDef<Opts extends TPolicyDefinitionOptions<string> | undefined = undefined, Metadata extends object = TSubsetGrantMetadata> = Opts extends {
33
34
  idType: 'string';
@@ -1 +1 @@
1
- {"version":3,"file":"columns.js","sourceRoot":"","sources":["../../../../../../src/components/auth/models/entities/columns.ts"],"names":[],"mappings":"AAAA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AC,OAAO,EAAE;oBACxC,QAAQ,EAAE,OAAO,CAAC,WAAW,CAAC;iBACe,CAAC;YAClD,CAAC;YACD,KAAK,QAAQ,CAAC,CAAC,CAAC;gBACd,OAAO;oBACL,GAAG,MAAM;oBACT,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;oBACvC,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE;oBACrC,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC;iBACkB,CAAC;YAClD,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACR,MAAM,QAAQ,CAAC;oBACb,OAAO,EAAE,qEAAqE,MAAM,EAAE;iBACvF,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,qCAAqC,CAAC,IAG5C;QACC,MAAM,EAAE,gBAAgB,GAAG,aAAa,EAAE,cAAc,GAAG,WAAW,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC;QACtF,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,yBAAyB,CAAC;QAE9D,OAAO;YACL,IAAI,gBAAgB,gBAAgB,cAAc,WAAW;YAC7D,OAAO,gBAAgB,OAAO,WAAW,SAAS,cAAc,WAAW;YAC3E;QACE,gBAAgB;YACZ,gBAAgB,aAAa,UAAU,OAAO,WAAW;YACzD,cAAc;MACpB;SACD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;CACF","sourcesContent":["import { isoTimestamp } from '@venizia/ignis-connectors/postgres';\nimport type { TConstValue } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport {\n AuthorizationDomainScopes,\n RoleStatuses,\n UserStatuses,\n UserTypes,\n} from '@venizia/ignis-kernel';\nimport type {\n TAuthorizationDecision,\n TAuthorizationPolicyVariant,\n TIdSchemaType,\n TSubsetGrantMetadata,\n} from '@venizia/ignis-kernel';\nimport type { PgIntegerBuilderInitial, PgTextBuilderInitial } from 'drizzle-orm/pg-core';\nimport { integer, jsonb, text } from 'drizzle-orm/pg-core';\nimport type { TPermissionCommonColumns, TPermissionOptions } from './permission.model';\nimport type { TPolicyDefinitionOptions } from './policy-definition.model';\n\ntype TPermissionColumnDef<Opts extends TPermissionOptions | undefined = undefined> = Opts extends {\n idType: infer IdType;\n}\n ? IdType extends 'string'\n ? TPermissionCommonColumns & {\n parentId: PgTextBuilderInitial<string, [string, ...string[]]>;\n }\n : TPermissionCommonColumns & {\n parentId: PgIntegerBuilderInitial<string>;\n }\n : TPermissionCommonColumns & {\n parentId: PgIntegerBuilderInitial<string>;\n };\n\n/** Extracts the app-declared extra variants from `Opts`, or `never` when none were declared. */\ntype TExtraPolicyVariantOf<Opts> = Opts extends {\n extraVariants?: ReadonlyArray<infer ExtraVariant extends string>;\n}\n ? ExtraVariant\n : never;\n\n/** Column shape is inferred, never hand-declared, so it can never drift from the `$type<>()` narrowing below. */\nconst buildCommonPolicyDefinitionColumns = <\n ExtraVariant extends string = never,\n Metadata extends object = TSubsetGrantMetadata,\n>() => ({\n metadata: jsonb('metadata').$type<Metadata>(),\n variant: text('variant').$type<TAuthorizationPolicyVariant | ExtraVariant>().notNull(),\n\n subjectType: text('subject_type').notNull(),\n targetType: text('target_type').notNull(),\n\n // `null` IS `ANY_MEMBER`, not \"unknown\"; the literal is refused by `AuthModelColumns.buildPolicyDefinitionDomainShapeCheck`.\n domainType: text('domain_type'),\n\n action: text('action'),\n effect: text('effect').$type<TAuthorizationDecision>(),\n});\n\nexport type TPolicyDefinitionCommonColumns<\n ExtraVariant extends string = never,\n Metadata extends object = TSubsetGrantMetadata,\n> = ReturnType<typeof buildCommonPolicyDefinitionColumns<ExtraVariant, Metadata>>;\n\ntype TPolicyDefinitionColumnDef<\n Opts extends TPolicyDefinitionOptions<string> | undefined = undefined,\n Metadata extends object = TSubsetGrantMetadata,\n> = Opts extends { idType: 'string' }\n ? TPolicyDefinitionCommonColumns<TExtraPolicyVariantOf<Opts>, Metadata> & {\n subjectId: ReturnType<typeof text>;\n targetId: ReturnType<typeof text>;\n domainId: ReturnType<typeof text>;\n }\n : TPolicyDefinitionCommonColumns<TExtraPolicyVariantOf<Opts>, Metadata> & {\n subjectId: ReturnType<typeof integer>;\n targetId: ReturnType<typeof integer>;\n domainId: ReturnType<typeof integer>;\n };\n\n/** The Drizzle column sets of the auth tables, spread into a table the application declares (`...AuthModelColumns.buildUser()`). */\nexport class AuthModelColumns {\n static buildUser(opts?: { idType: TIdSchemaType }) {\n return {\n realm: text('realm').default(''),\n status: text('status')\n .$type<TConstValue<typeof UserStatuses>>()\n .notNull()\n .default(UserStatuses.UNKNOWN),\n type: text('type').$type<TConstValue<typeof UserTypes>>().notNull().default(UserTypes.SYSTEM),\n activatedAt: isoTimestamp('activated_at', { withTimezone: true }),\n lastLoginAt: isoTimestamp('last_login_at', { withTimezone: true }),\n parentId: opts?.idType === 'string' ? text('parent_id') : integer('parent_id'),\n };\n }\n\n static buildRole() {\n return {\n identifier: text('identifier').unique().notNull(),\n name: text('name').notNull(),\n description: text('description'),\n priority: integer('priority').notNull(),\n status: text('status')\n .$type<TConstValue<typeof RoleStatuses>>()\n .notNull()\n .default(RoleStatuses.ACTIVATED),\n };\n }\n\n static buildPermission<Opts extends TPermissionOptions | undefined>(\n opts?: Opts,\n ): TPermissionColumnDef<Opts> {\n const { idType = 'number' } = opts ?? {};\n\n switch (idType) {\n case 'number': {\n return {\n code: text('code').unique().notNull(),\n name: text('name').notNull(),\n subject: text('subject').notNull(),\n method: text('method').notNull(),\n action: text('action').notNull(),\n scope: text('scope').notNull(),\n description: text('description'),\n parentId: integer('parent_id'),\n } as TPermissionColumnDef<Opts>;\n }\n case 'string': {\n return {\n code: text('code').unique().notNull(),\n name: text('name').notNull(),\n subject: text('subject').notNull(),\n method: text('method').notNull(),\n action: text('action').notNull(),\n scope: text('scope').notNull(),\n description: text('description'),\n parentId: text('parent_id'),\n } as TPermissionColumnDef<Opts>;\n }\n default: {\n throw getError({\n message: `[AuthModelColumns.buildPermission] Invalid idType | idType: ${idType}`,\n });\n }\n }\n }\n\n /**\n * `Metadata` is a type parameter, not an `opts` field: unlike `extraVariants` there is no runtime\n * value to infer from, so supplying it means spelling `Opts` too (no partial inference):\n * `AuthModelColumns.buildPolicyDefinition<{ idType: 'string' }, IMyMetadata>({ idType: 'string' })`.\n * Keep `ops` in a custom shape if the app also issues subset grants - `customGrant` writes it.\n */\n static buildPolicyDefinition<\n const Opts extends TPolicyDefinitionOptions<string> | undefined = undefined,\n Metadata extends object = TSubsetGrantMetadata,\n >(opts?: Opts): TPolicyDefinitionColumnDef<Opts, Metadata> {\n const { idType = 'number' } = opts ?? {};\n\n const common = buildCommonPolicyDefinitionColumns<TExtraPolicyVariantOf<Opts>, Metadata>();\n\n switch (idType) {\n case 'number': {\n return {\n ...common,\n subjectId: integer('subject_id').notNull(),\n targetId: integer('target_id').notNull(),\n domainId: integer('domain_id'),\n } as TPolicyDefinitionColumnDef<Opts, Metadata>;\n }\n case 'string': {\n return {\n ...common,\n subjectId: text('subject_id').notNull(),\n targetId: text('target_id').notNull(),\n domainId: text('domain_id'),\n } as TPolicyDefinitionColumnDef<Opts, Metadata>;\n }\n default: {\n throw getError({\n message: `[AuthModelColumns.buildPolicyDefinition] Invalid idType | idType: ${idType}`,\n });\n }\n }\n }\n\n /**\n * The three legal `(domain_type, domain_id)` pairs, as CHECK predicate TEXT for a migration - text,\n * not a Drizzle `SQL`, because a column ref in a `sql` template renders schema-qualified, which a\n * table-level CHECK rejects.\n *\n * The `IS NOT NULL` guard on the last branch looks redundant next to `NOT IN` and is not: a NULL\n * `domain_type` makes `NOT IN` evaluate to NULL, and a CHECK rejects only on FALSE - without it an id\n * with no type passes.\n */\n static buildPolicyDefinitionDomainShapeCheck(opts?: {\n domainTypeColumn?: string;\n domainIdColumn?: string;\n }): string {\n const { domainTypeColumn = 'domain_type', domainIdColumn = 'domain_id' } = opts ?? {};\n const { ANY_MEMBER, SYSTEM_WIDE } = AuthorizationDomainScopes;\n\n return [\n `(${domainTypeColumn} IS NULL AND ${domainIdColumn} IS NULL)`,\n `OR (${domainTypeColumn} = '${SYSTEM_WIDE}' AND ${domainIdColumn} IS NULL)`,\n `OR (\n ${domainTypeColumn} IS NOT NULL\n AND ${domainTypeColumn} NOT IN ('${ANY_MEMBER}', '${SYSTEM_WIDE}')\n AND ${domainIdColumn} IS NOT NULL\n )`,\n ].join('\\n');\n }\n}\n"]}
1
+ {"version":3,"file":"columns.js","sourceRoot":"","sources":["../../../../../../src/components/auth/models/entities/columns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAElE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EACL,yBAAyB,EACzB,YAAY,EACZ,YAAY,EACZ,SAAS,GACV,MAAM,uBAAuB,CAAC;AAQ/B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAyB3D,iHAAiH;AACjH,MAAM,kCAAkC,GAAG,GAGvC,EAAE,CAAC,CAAC;IACN,QAAQ,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAY;IAC7C,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,EAA8C,CAAC,OAAO,EAAE;IAEtF,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE;IAC3C,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE;IAEzC,6HAA6H;IAC7H,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC;IAE/B,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC;IACtB,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,EAA0B;CACvD,CAAC,CAAC;AAuBH,oIAAoI;AACpI,MAAM,OAAO,gBAAgB;IAC3B,MAAM,C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,gBAAgB,aAAa,UAAU,OAAO,WAAW;YACzD,cAAc;MACpB;SACD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;CACF","sourcesContent":["import { isoTimestamp } from '@venizia/ignis-connectors/postgres';\nimport type { TConstValue } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport {\n AuthorizationDomainScopes,\n RoleStatuses,\n UserStatuses,\n UserTypes,\n} from '@venizia/ignis-kernel';\nimport type {\n TAuthorizationDecision,\n TAuthorizationPolicyVariant,\n TIdSchemaType,\n TSubsetGrantMetadata,\n} from '@venizia/ignis-kernel';\nimport type { PgIntegerBuilderInitial, PgTextBuilderInitial } from 'drizzle-orm/pg-core';\nimport { integer, jsonb, text } from 'drizzle-orm/pg-core';\nimport type { TPermissionCommonColumns, TPermissionOptions } from './permission.model';\nimport type { TPolicyDefinitionOptions } from './policy-definition.model';\n\ntype TPermissionColumnDef<Opts extends TPermissionOptions | undefined = undefined> = Opts extends {\n idType: infer IdType;\n}\n ? IdType extends 'string'\n ? TPermissionCommonColumns & {\n parentId: PgTextBuilderInitial<string, [string, ...string[]]>;\n }\n : TPermissionCommonColumns & {\n parentId: PgIntegerBuilderInitial<string>;\n }\n : TPermissionCommonColumns & {\n parentId: PgIntegerBuilderInitial<string>;\n };\n\n/** Extracts the app-declared extra variants from `Opts`, or `never` when none were declared. */\ntype TExtraPolicyVariantOf<Opts> = Opts extends {\n extraVariants?: ReadonlyArray<infer ExtraVariant extends string>;\n}\n ? ExtraVariant\n : never;\n\n/** Column shape is inferred, never hand-declared, so it can never drift from the `$type<>()` narrowing below. */\nconst buildCommonPolicyDefinitionColumns = <\n ExtraVariant extends string = never,\n Metadata extends object = TSubsetGrantMetadata,\n>() => ({\n metadata: jsonb('metadata').$type<Metadata>(),\n variant: text('variant').$type<TAuthorizationPolicyVariant | ExtraVariant>().notNull(),\n\n subjectType: text('subject_type').notNull(),\n targetType: text('target_type').notNull(),\n\n // `null` IS `ANY_MEMBER`, not \"unknown\"; the literal is refused by `AuthModelColumns.buildPolicyDefinitionDomainShapeCheck`.\n domainType: text('domain_type'),\n\n action: text('action'),\n effect: text('effect').$type<TAuthorizationDecision>(),\n});\n\n/** Drizzle column set shared by every policy-definition table; `ExtraVariant` widens the allowed `variant` values and `Metadata` types the `metadata` column. */\nexport type TPolicyDefinitionCommonColumns<\n ExtraVariant extends string = never,\n Metadata extends object = TSubsetGrantMetadata,\n> = ReturnType<typeof buildCommonPolicyDefinitionColumns<ExtraVariant, Metadata>>;\n\ntype TPolicyDefinitionColumnDef<\n Opts extends TPolicyDefinitionOptions<string> | undefined = undefined,\n Metadata extends object = TSubsetGrantMetadata,\n> = Opts extends { idType: 'string' }\n ? TPolicyDefinitionCommonColumns<TExtraPolicyVariantOf<Opts>, Metadata> & {\n subjectId: ReturnType<typeof text>;\n targetId: ReturnType<typeof text>;\n domainId: ReturnType<typeof text>;\n }\n : TPolicyDefinitionCommonColumns<TExtraPolicyVariantOf<Opts>, Metadata> & {\n subjectId: ReturnType<typeof integer>;\n targetId: ReturnType<typeof integer>;\n domainId: ReturnType<typeof integer>;\n };\n\n/** The Drizzle column sets of the auth tables, spread into a table the application declares (`...AuthModelColumns.buildUser()`). */\nexport class AuthModelColumns {\n static buildUser(opts?: { idType: TIdSchemaType }) {\n return {\n realm: text('realm').default(''),\n status: text('status')\n .$type<TConstValue<typeof UserStatuses>>()\n .notNull()\n .default(UserStatuses.UNKNOWN),\n type: text('type').$type<TConstValue<typeof UserTypes>>().notNull().default(UserTypes.SYSTEM),\n activatedAt: isoTimestamp('activated_at', { withTimezone: true }),\n lastLoginAt: isoTimestamp('last_login_at', { withTimezone: true }),\n parentId: opts?.idType === 'string' ? text('parent_id') : integer('parent_id'),\n };\n }\n\n static buildRole() {\n return {\n identifier: text('identifier').unique().notNull(),\n name: text('name').notNull(),\n description: text('description'),\n priority: integer('priority').notNull(),\n status: text('status')\n .$type<TConstValue<typeof RoleStatuses>>()\n .notNull()\n .default(RoleStatuses.ACTIVATED),\n };\n }\n\n static buildPermission<Opts extends TPermissionOptions | undefined>(\n opts?: Opts,\n ): TPermissionColumnDef<Opts> {\n const { idType = 'number' } = opts ?? {};\n\n switch (idType) {\n case 'number': {\n return {\n code: text('code').unique().notNull(),\n name: text('name').notNull(),\n subject: text('subject').notNull(),\n method: text('method').notNull(),\n action: text('action').notNull(),\n scope: text('scope').notNull(),\n description: text('description'),\n parentId: integer('parent_id'),\n } as TPermissionColumnDef<Opts>;\n }\n case 'string': {\n return {\n code: text('code').unique().notNull(),\n name: text('name').notNull(),\n subject: text('subject').notNull(),\n method: text('method').notNull(),\n action: text('action').notNull(),\n scope: text('scope').notNull(),\n description: text('description'),\n parentId: text('parent_id'),\n } as TPermissionColumnDef<Opts>;\n }\n default: {\n throw getError({\n message: `[AuthModelColumns.buildPermission] Invalid idType | idType: ${idType}`,\n });\n }\n }\n }\n\n /**\n * `Metadata` is a type parameter, not an `opts` field: unlike `extraVariants` there is no runtime\n * value to infer from, so supplying it means spelling `Opts` too (no partial inference):\n * `AuthModelColumns.buildPolicyDefinition<{ idType: 'string' }, IMyMetadata>({ idType: 'string' })`.\n * Keep `ops` in a custom shape if the app also issues subset grants - `customGrant` writes it.\n */\n static buildPolicyDefinition<\n const Opts extends TPolicyDefinitionOptions<string> | undefined = undefined,\n Metadata extends object = TSubsetGrantMetadata,\n >(opts?: Opts): TPolicyDefinitionColumnDef<Opts, Metadata> {\n const { idType = 'number' } = opts ?? {};\n\n const common = buildCommonPolicyDefinitionColumns<TExtraPolicyVariantOf<Opts>, Metadata>();\n\n switch (idType) {\n case 'number': {\n return {\n ...common,\n subjectId: integer('subject_id').notNull(),\n targetId: integer('target_id').notNull(),\n domainId: integer('domain_id'),\n } as TPolicyDefinitionColumnDef<Opts, Metadata>;\n }\n case 'string': {\n return {\n ...common,\n subjectId: text('subject_id').notNull(),\n targetId: text('target_id').notNull(),\n domainId: text('domain_id'),\n } as TPolicyDefinitionColumnDef<Opts, Metadata>;\n }\n default: {\n throw getError({\n message: `[AuthModelColumns.buildPolicyDefinition] Invalid idType | idType: ${idType}`,\n });\n }\n }\n }\n\n /**\n * The three legal `(domain_type, domain_id)` pairs, as CHECK predicate TEXT for a migration - text,\n * not a Drizzle `SQL`, because a column ref in a `sql` template renders schema-qualified, which a\n * table-level CHECK rejects.\n *\n * The `IS NOT NULL` guard on the last branch looks redundant next to `NOT IN` and is not: a NULL\n * `domain_type` makes `NOT IN` evaluate to NULL, and a CHECK rejects only on FALSE - without it an id\n * with no type passes.\n */\n static buildPolicyDefinitionDomainShapeCheck(opts?: {\n domainTypeColumn?: string;\n domainIdColumn?: string;\n }): string {\n const { domainTypeColumn = 'domain_type', domainIdColumn = 'domain_id' } = opts ?? {};\n const { ANY_MEMBER, SYSTEM_WIDE } = AuthorizationDomainScopes;\n\n return [\n `(${domainTypeColumn} IS NULL AND ${domainIdColumn} IS NULL)`,\n `OR (${domainTypeColumn} = '${SYSTEM_WIDE}' AND ${domainIdColumn} IS NULL)`,\n `OR (\n ${domainTypeColumn} IS NOT NULL\n AND ${domainTypeColumn} NOT IN ('${ANY_MEMBER}', '${SYSTEM_WIDE}')\n AND ${domainIdColumn} IS NOT NULL\n )`,\n ].join('\\n');\n }\n}\n"]}
@@ -1,9 +1,11 @@
1
1
  import type { TIdSchemaType } from '@venizia/ignis-kernel';
2
2
  import type { NotNull } from 'drizzle-orm';
3
3
  import type { PgTextBuilderInitial } from 'drizzle-orm/pg-core';
4
+ /** Options of the permission table builder; `idType` selects the primary key type. */
4
5
  export type TPermissionOptions = {
5
6
  idType?: TIdSchemaType;
6
7
  };
8
+ /** Drizzle column set of the permission table: text `code`, `name`, `method`, `subject`, `action`, `scope` (all not null) and a nullable `description`. */
7
9
  export type TPermissionCommonColumns = {
8
10
  code: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;
9
11
  name: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;
@@ -1 +1 @@
1
- {"version":3,"file":"permission.model.js","sourceRoot":"","sources":["../../../../../../src/components/auth/models/entities/permission.model.ts"],"names":[],"mappings":"","sourcesContent":["import type { TIdSchemaType } from '@venizia/ignis-kernel';\nimport type { NotNull } from 'drizzle-orm';\nimport type { PgTextBuilderInitial } from 'drizzle-orm/pg-core';\n\nexport type TPermissionOptions = {\n idType?: TIdSchemaType;\n};\n\nexport type TPermissionCommonColumns = {\n code: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;\n name: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;\n method: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;\n subject: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;\n action: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;\n scope: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;\n description: PgTextBuilderInitial<string, [string, ...string[]]>;\n};\n"]}
1
+ {"version":3,"file":"permission.model.js","sourceRoot":"","sources":["../../../../../../src/components/auth/models/entities/permission.model.ts"],"names":[],"mappings":"","sourcesContent":["import type { TIdSchemaType } from '@venizia/ignis-kernel';\nimport type { NotNull } from 'drizzle-orm';\nimport type { PgTextBuilderInitial } from 'drizzle-orm/pg-core';\n\n/** Options of the permission table builder; `idType` selects the primary key type. */\nexport type TPermissionOptions = {\n idType?: TIdSchemaType;\n};\n\n/** Drizzle column set of the permission table: text `code`, `name`, `method`, `subject`, `action`, `scope` (all not null) and a nullable `description`. */\nexport type TPermissionCommonColumns = {\n code: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;\n name: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;\n method: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;\n subject: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;\n action: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;\n scope: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;\n description: PgTextBuilderInitial<string, [string, ...string[]]>;\n};\n"]}
@@ -1,4 +1,5 @@
1
1
  import type { TIdSchemaType } from '@venizia/ignis-kernel';
2
+ /** Options of the policy-definition table builder; `idType` selects the key type and `extraVariants` declares app-defined variants. */
2
3
  export type TPolicyDefinitionOptions<ExtraVariant extends string = never> = {
3
4
  idType?: TIdSchemaType;
4
5
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"policy-definition.model.js","sourceRoot":"","sources":["../../../../../../src/components/auth/models/entities/policy-definition.model.ts"],"names":[],"mappings":"","sourcesContent":["import type { TIdSchemaType } from '@venizia/ignis-kernel';\n\nexport type TPolicyDefinitionOptions<ExtraVariant extends string = never> = {\n idType?: TIdSchemaType;\n /**\n * App-only edge kinds stored in this same table alongside IGNIS's seven (e.g. `merchant_role`).\n * `ScopedCasbinAdapter` never selects an undeclared variant - it is purely the consumer's data.\n * Pass as an inline array literal; the `const` type parameter below infers the literal union\n * from it without needing `as const`.\n */\n extraVariants?: ReadonlyArray<ExtraVariant>;\n};\n"]}
1
+ {"version":3,"file":"policy-definition.model.js","sourceRoot":"","sources":["../../../../../../src/components/auth/models/entities/policy-definition.model.ts"],"names":[],"mappings":"","sourcesContent":["import type { TIdSchemaType } from '@venizia/ignis-kernel';\n\n/** Options of the policy-definition table builder; `idType` selects the key type and `extraVariants` declares app-defined variants. */\nexport type TPolicyDefinitionOptions<ExtraVariant extends string = never> = {\n idType?: TIdSchemaType;\n /**\n * App-only edge kinds stored in this same table alongside IGNIS's seven (e.g. `merchant_role`).\n * `ScopedCasbinAdapter` never selects an undeclared variant - it is purely the consumer's data.\n * Pass as an inline array literal; the `const` type parameter below infers the literal union\n * from it without needing `as const`.\n */\n extraVariants?: ReadonlyArray<ExtraVariant>;\n};\n"]}
@@ -1,10 +1,12 @@
1
1
  import type { IConnectRpcModule } from '../../../../base/controllers/grpc/common/types.js';
2
2
  export type { IConnectRpcModule };
3
+ /** Options of `GrpcComponent`, bound at `GrpcBindingKeys.GRPC_COMPONENT_OPTIONS`. */
3
4
  export interface IGrpcComponentConfig {
4
5
  interceptors?: unknown[];
5
6
  /** The ConnectRPC peer, for a compiled binary that has no `node_modules` to resolve it from. */
6
7
  module?: IConnectRpcModule;
7
8
  }
9
+ /** Container keys of the gRPC component. */
8
10
  export declare class GrpcBindingKeys {
9
11
  static readonly GRPC_COMPONENT_OPTIONS = "@app/grpc/options";
10
12
  }
@@ -1,3 +1,4 @@
1
+ /** Container keys of the gRPC component. */
1
2
  export class GrpcBindingKeys {
2
3
  static { this.GRPC_COMPONENT_OPTIONS = '@app/grpc/options'; }
3
4
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/components/controller/grpc/common/types.ts"],"names":[],"mappings":"AAWA,MAAM,OAAO,eAAe;aACV,2BAAsB,GAAG,mBAAmB,CAAC","sourcesContent":["import type { IConnectRpcModule } from '@/base/controllers/grpc/common/types';\n\n// Re-exported so an application can name the type without reaching into the base barrel.\nexport type { IConnectRpcModule };\n\nexport interface IGrpcComponentConfig {\n interceptors?: unknown[];\n /** The ConnectRPC peer, for a compiled binary that has no `node_modules` to resolve it from. */\n module?: IConnectRpcModule;\n}\n\nexport class GrpcBindingKeys {\n static readonly GRPC_COMPONENT_OPTIONS = '@app/grpc/options';\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/components/controller/grpc/common/types.ts"],"names":[],"mappings":"AAYA,4CAA4C;AAC5C,MAAM,OAAO,eAAe;aACV,2BAAsB,GAAG,mBAAmB,CAAC","sourcesContent":["import type { IConnectRpcModule } from '@/base/controllers/grpc/common/types';\n\n// Re-exported so an application can name the type without reaching into the base barrel.\nexport type { IConnectRpcModule };\n\n/** Options of `GrpcComponent`, bound at `GrpcBindingKeys.GRPC_COMPONENT_OPTIONS`. */\nexport interface IGrpcComponentConfig {\n interceptors?: unknown[];\n /** The ConnectRPC peer, for a compiled binary that has no `node_modules` to resolve it from. */\n module?: IConnectRpcModule;\n}\n\n/** Container keys of the gRPC component. */\nexport class GrpcBindingKeys {\n static readonly GRPC_COMPONENT_OPTIONS = '@app/grpc/options';\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  import type { BaseApplication } from '../../../base/applications/index.js';
2
2
  import { BaseComponent } from '@venizia/ignis-kernel';
3
+ /** Mounts every controller declared with the gRPC transport onto the root router at its metadata `path`, and hands each the `IGrpcComponentConfig` interceptors and ConnectRPC module. A gRPC controller without a service definition is skipped with a warning. */
3
4
  export declare class GrpcComponent extends BaseComponent {
4
5
  private application;
5
6
  constructor(application: BaseApplication);
@@ -6,6 +6,7 @@ import { getError } from '@venizia/ignis-helpers/core';
6
6
  import { HTTP, ObjectUtility } from '@venizia/ignis-helpers/common';
7
7
  import { GrpcBindingKeys } from './common/types.js';
8
8
  const DEFAULT_OPTIONS = {};
9
+ /** Mounts every controller declared with the gRPC transport onto the root router at its metadata `path`, and hands each the `IGrpcComponentConfig` interceptors and ConnectRPC module. A gRPC controller without a service definition is skipped with a warning. */
9
10
  export class GrpcComponent extends BaseComponent {
10
11
  constructor(application) {
11
12
  super({
@@ -1 +1 @@
1
- {"version":3,"file":"grpc.component.js","sourceRoot":"","sources":["../../../../../src/components/controller/grpc/grpc.component.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,eAAe,GAAyB,EAAE,CAAC;AAEjD,MAAM,OAAO,aAAc,SAAQ,aAAa;IAC9C,YAAoB,WAA4B;QAC9C,KA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,SAAS;gBACX,CAAC;gBAED,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,iBAAiB,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;gBACnE,QAAQ,CAAC,gBAAgB,GAAG,OAAO,EAAE,MAAM,CAAC;gBAC5C,QAAQ,CAAC,YAAY,GAAG,OAAO,EAAE,YAAY,CAAC;gBAC9C,MAAM,QAAQ,CAAC,SAAS,EAAE,CAAC;gBAE3B,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;gBAClD,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;gBAE5B,MAAM,CAAC,IAAI,CAAC,iDAAiD,EAAE,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC7F,CAAC;YAED,iFAAiF;YACjF,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC;gBACpC,GAAG,EAAE,iBAAiB,CAAC,UAAU;gBACjC,OAAO,EAAE,UAAU;aACpB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF","sourcesContent":["import type { BaseApplication } from '@/base/applications';\nimport { BaseComponent } from '@venizia/ignis-kernel';\nimport { ControllerTransports } from '@venizia/ignis-kernel';\nimport type { AbstractGrpcController } from '@/base/controllers/grpc';\nimport { BindingNamespaces } from '@venizia/ignis-kernel';\nimport { Binding, BindingValueTypes, MetadataRegistry } from '@venizia/ignis-kernel';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { HTTP, ObjectUtility } from '@venizia/ignis-helpers/common';\nimport type { IGrpcComponentConfig } from './common/types';\nimport { GrpcBindingKeys } from './common/types';\n\nconst DEFAULT_OPTIONS: IGrpcComponentConfig = {};\n\nexport class GrpcComponent extends BaseComponent {\n constructor(private application: BaseApplication) {\n super({\n scope: GrpcComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [GrpcBindingKeys.GRPC_COMPONENT_OPTIONS]: Binding.bind<IGrpcComponentConfig>({\n key: GrpcBindingKeys.GRPC_COMPONENT_OPTIONS,\n }).toValue(DEFAULT_OPTIONS),\n },\n });\n }\n\n override async binding(): Promise<void> {\n const logger = this.logger.for(this.binding.name);\n const router = this.application.getRootRouter();\n\n const options = this.application.get<IGrpcComponentConfig>({\n key: GrpcBindingKeys.GRPC_COMPONENT_OPTIONS,\n isOptional: true,\n });\n\n // Batch drained before re-scanning - see `RestApplication.registerDynamicBindings` for why.\n const configured = new Set<string>();\n\n let bindings = this.application.findByTag({\n tag: BindingNamespaces.CONTROLLER,\n exclude: configured,\n });\n\n while (bindings.length > 0) {\n for (const binding of bindings) {\n if (configured.has(binding.key)) {\n continue;\n }\n\n const target = binding.getBindingMeta({ type: BindingValueTypes.CLASS });\n\n if (!target) {\n configured.add(binding.key);\n continue;\n }\n\n const metadata = MetadataRegistry.getInstance().getControllerMetadata({ target });\n\n // Skip non-gRPC controllers — they are configured by RestComponent\n if (metadata?.transport !== ControllerTransports.GRPC) {\n configured.add(binding.key);\n continue;\n }\n\n if (!metadata?.path || ObjectUtility.isEmpty({ value: metadata.path })) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[registerControllers] key: '${binding.key}' | Invalid controller metadata, 'path' is required for gRPC controller metadata`,\n });\n }\n\n const instance = this.application.get<AbstractGrpcController>({\n key: binding.key,\n isOptional: false,\n });\n\n if (!instance) {\n logger.debug('No binding instance | key: %s', binding.key);\n configured.add(binding.key);\n continue;\n }\n\n if (!instance.service) {\n logger.warn('gRPC controller has no service definition, skipping | key: %s', binding.key);\n configured.add(binding.key);\n continue;\n }\n\n instance.basePath = this.application.getProjectConfigs().path.base;\n instance.connectRpcModule = options?.module;\n instance.interceptors = options?.interceptors;\n await instance.configure();\n\n router.route(metadata.path, instance.getRouter());\n configured.add(binding.key);\n\n logger.info('Configured gRPC controller | key: %s | path: %s', binding.key, metadata.path);\n }\n\n // Re-fetch excluding already configured — picks up dynamically added controllers\n bindings = this.application.findByTag({\n tag: BindingNamespaces.CONTROLLER,\n exclude: configured,\n });\n }\n }\n}\n"]}
1
+ {"version":3,"file":"grpc.component.js","sourceRoot":"","sources":["../../../../../src/components/controller/grpc/grpc.component.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,eAAe,GAAyB,EAAE,CAAC;AAEjD,oQAAoQ;AACpQ,MAAM,OAAO,aAAc,SAAQ,aAAa;IAC9C,YAAoB,WAA4B;QAC9C,KAAK,CAAC;YACJ,KAAK,EAAE,aAAa,CAAC,IAAI;YACzB,WAAW,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE;YACrD,QAAQ,EAAE;gBACR,CAAC,eAAe,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAC,IAAI,CAAuB;oBAC3E,GAAG,EAAE,eAAe,CAAC,sBAAsB;iBAC5C,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC;aAC5B;SACF,CAAC,CAAC;QATe,gBAAW,GAAX,WAAW,CAAiB;IAUhD,CAAC;IAEQ,KAAK,CAAC,OAAO;QACpB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAClD,MAAM,MAAM,GAAG,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AQ,CAAC,IAAI,CAAC,CAAC;YAC7F,CAAC;YAED,iFAAiF;YACjF,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC;gBACpC,GAAG,EAAE,iBAAiB,CAAC,UAAU;gBACjC,OAAO,EAAE,UAAU;aACpB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF","sourcesContent":["import type { BaseApplication } from '@/base/applications';\nimport { BaseComponent } from '@venizia/ignis-kernel';\nimport { ControllerTransports } from '@venizia/ignis-kernel';\nimport type { AbstractGrpcController } from '@/base/controllers/grpc';\nimport { BindingNamespaces } from '@venizia/ignis-kernel';\nimport { Binding, BindingValueTypes, MetadataRegistry } from '@venizia/ignis-kernel';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { HTTP, ObjectUtility } from '@venizia/ignis-helpers/common';\nimport type { IGrpcComponentConfig } from './common/types';\nimport { GrpcBindingKeys } from './common/types';\n\nconst DEFAULT_OPTIONS: IGrpcComponentConfig = {};\n\n/** Mounts every controller declared with the gRPC transport onto the root router at its metadata `path`, and hands each the `IGrpcComponentConfig` interceptors and ConnectRPC module. A gRPC controller without a service definition is skipped with a warning. */\nexport class GrpcComponent extends BaseComponent {\n constructor(private application: BaseApplication) {\n super({\n scope: GrpcComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [GrpcBindingKeys.GRPC_COMPONENT_OPTIONS]: Binding.bind<IGrpcComponentConfig>({\n key: GrpcBindingKeys.GRPC_COMPONENT_OPTIONS,\n }).toValue(DEFAULT_OPTIONS),\n },\n });\n }\n\n override async binding(): Promise<void> {\n const logger = this.logger.for(this.binding.name);\n const router = this.application.getRootRouter();\n\n const options = this.application.get<IGrpcComponentConfig>({\n key: GrpcBindingKeys.GRPC_COMPONENT_OPTIONS,\n isOptional: true,\n });\n\n // Batch drained before re-scanning - see `RestApplication.registerDynamicBindings` for why.\n const configured = new Set<string>();\n\n let bindings = this.application.findByTag({\n tag: BindingNamespaces.CONTROLLER,\n exclude: configured,\n });\n\n while (bindings.length > 0) {\n for (const binding of bindings) {\n if (configured.has(binding.key)) {\n continue;\n }\n\n const target = binding.getBindingMeta({ type: BindingValueTypes.CLASS });\n\n if (!target) {\n configured.add(binding.key);\n continue;\n }\n\n const metadata = MetadataRegistry.getInstance().getControllerMetadata({ target });\n\n // Skip non-gRPC controllers — they are configured by RestComponent\n if (metadata?.transport !== ControllerTransports.GRPC) {\n configured.add(binding.key);\n continue;\n }\n\n if (!metadata?.path || ObjectUtility.isEmpty({ value: metadata.path })) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[registerControllers] key: '${binding.key}' | Invalid controller metadata, 'path' is required for gRPC controller metadata`,\n });\n }\n\n const instance = this.application.get<AbstractGrpcController>({\n key: binding.key,\n isOptional: false,\n });\n\n if (!instance) {\n logger.debug('No binding instance | key: %s', binding.key);\n configured.add(binding.key);\n continue;\n }\n\n if (!instance.service) {\n logger.warn('gRPC controller has no service definition, skipping | key: %s', binding.key);\n configured.add(binding.key);\n continue;\n }\n\n instance.basePath = this.application.getProjectConfigs().path.base;\n instance.connectRpcModule = options?.module;\n instance.interceptors = options?.interceptors;\n await instance.configure();\n\n router.route(metadata.path, instance.getRouter());\n configured.add(binding.key);\n\n logger.info('Configured gRPC controller | key: %s | path: %s', binding.key, metadata.path);\n }\n\n // Re-fetch excluding already configured — picks up dynamically added controllers\n bindings = this.application.findByTag({\n tag: BindingNamespaces.CONTROLLER,\n exclude: configured,\n });\n }\n }\n}\n"]}
@@ -1,3 +1,4 @@
1
+ /** Request headers the health check controller reads. */
1
2
  export declare class HealthCheckHeaders {
2
3
  /** Where a gated stats request carries its key; lowercase because Hono normalises header names. */
3
4
  static readonly SECRET_KEY = "x-health-key";
@@ -1,3 +1,4 @@
1
+ /** Request headers the health check controller reads. */
1
2
  export class HealthCheckHeaders {
2
3
  /** Where a gated stats request carries its key; lowercase because Hono normalises header names. */
3
4
  static { this.SECRET_KEY = 'x-health-key'; }
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/components/health-check/common/constants.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,kBAAkB;IAC7B,mGAAmG;aACnF,eAAU,GAAG,cAAc,CAAC","sourcesContent":["export class HealthCheckHeaders {\n /** Where a gated stats request carries its key; lowercase because Hono normalises header names. */\n static readonly SECRET_KEY = 'x-health-key';\n}\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/components/health-check/common/constants.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,MAAM,OAAO,kBAAkB;IAC7B,mGAAmG;aACnF,eAAU,GAAG,cAAc,CAAC","sourcesContent":["/** Request headers the health check controller reads. */\nexport class HealthCheckHeaders {\n /** Where a gated stats request carries its key; lowercase because Hono normalises header names. */\n static readonly SECRET_KEY = 'x-health-key';\n}\n"]}
@@ -1,3 +1,4 @@
1
+ /** Container keys of the health check component. */
1
2
  export declare class HealthCheckBindingKeys {
2
3
  static readonly HEALTH_CHECK_OPTIONS = "@app/health-check/options";
3
4
  /** The component resolves `getAppInfo()` once (it is async) and binds the result for the controller. */
@@ -1,3 +1,4 @@
1
+ /** Container keys of the health check component. */
1
2
  export class HealthCheckBindingKeys {
2
3
  static { this.HEALTH_CHECK_OPTIONS = '@app/health-check/options'; }
3
4
  /** The component resolves `getAppInfo()` once (it is async) and binds the result for the controller. */
@@ -1 +1 @@
1
- {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/health-check/common/keys.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,sBAAsB;aACjB,yBAAoB,GAAG,2BAA2B,CAAC;IACnE,wGAAwG;aACxF,qBAAgB,GAAG,oCAAoC,CAAC","sourcesContent":["export class HealthCheckBindingKeys {\n static readonly HEALTH_CHECK_OPTIONS = '@app/health-check/options';\n /** The component resolves `getAppInfo()` once (it is async) and binds the result for the controller. */\n static readonly APPLICATION_INFO = '@app/health-check/application-info';\n}\n"]}
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/health-check/common/keys.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,OAAO,sBAAsB;aACjB,yBAAoB,GAAG,2BAA2B,CAAC;IACnE,wGAAwG;aACxF,qBAAgB,GAAG,oCAAoC,CAAC","sourcesContent":["/** Container keys of the health check component. */\nexport class HealthCheckBindingKeys {\n static readonly HEALTH_CHECK_OPTIONS = '@app/health-check/options';\n /** The component resolves `getAppInfo()` once (it is async) and binds the result for the controller. */\n static readonly APPLICATION_INFO = '@app/health-check/application-info';\n}\n"]}
@@ -1,3 +1,4 @@
1
+ /** Routes of the health check controller, relative to the configured base path. */
1
2
  export declare class HealthCheckRestPaths {
2
3
  static readonly ROOT = "/";
3
4
  static readonly PING = "/ping";
@@ -1,3 +1,4 @@
1
+ /** Routes of the health check controller, relative to the configured base path. */
1
2
  export class HealthCheckRestPaths {
2
3
  static { this.ROOT = '/'; }
3
4
  static { this.PING = '/ping'; }
@@ -1 +1 @@
1
- {"version":3,"file":"rest-paths.js","sourceRoot":"","sources":["../../../../../src/components/health-check/common/rest-paths.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,oBAAoB;aACf,SAAI,GAAG,GAAG,CAAC;aACX,SAAI,GAAG,OAAO,CAAC;aACf,UAAK,GAAG,QAAQ,CAAC","sourcesContent":["export class HealthCheckRestPaths {\n static readonly ROOT = '/';\n static readonly PING = '/ping';\n static readonly STATS = '/stats';\n}\n"]}
1
+ {"version":3,"file":"rest-paths.js","sourceRoot":"","sources":["../../../../../src/components/health-check/common/rest-paths.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,MAAM,OAAO,oBAAoB;aACf,SAAI,GAAG,GAAG,CAAC;aACX,SAAI,GAAG,OAAO,CAAC;aACf,UAAK,GAAG,QAAQ,CAAC","sourcesContent":["/** Routes of the health check controller, relative to the configured base path. */\nexport class HealthCheckRestPaths {\n static readonly ROOT = '/';\n static readonly PING = '/ping';\n static readonly STATS = '/stats';\n}\n"]}
@@ -1,7 +1,26 @@
1
1
  import type { IBuildInfo } from '@venizia/ignis-helpers/core';
2
+ /**
3
+ * Options of `HealthCheckComponent`, bound at `HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS`.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * import { HealthCheckBindingKeys, type BaseApplication, type IHealthCheckOptions } from '@venizia/ignis';
8
+ *
9
+ * export const bindHealth = (application: BaseApplication) => {
10
+ * application
11
+ * .bind<IHealthCheckOptions>({ key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS })
12
+ * .toValue({ restOptions: { path: '/status' }, stats: { secretKey: 'change-me' } });
13
+ * };
14
+ * ```
15
+ */
2
16
  export interface IHealthCheckOptions {
3
17
  /** Partially-filled bindings are accepted; every missing field falls back to its default. */
4
18
  restOptions?: {
19
+ /**
20
+ * Base path the health routes mount under.
21
+ *
22
+ * @default '/health'
23
+ */
5
24
  path?: string;
6
25
  };
7
26
  /**
@@ -11,9 +30,11 @@ export interface IHealthCheckOptions {
11
30
  */
12
31
  stats?: {
13
32
  /**
14
- * Default: open only when `NODE_ENV` names a development environment
15
- * (`Environment.DEVELOPMENT_ENVS`). `staging`, `uat`, `production`, an unrecognised name and an
16
- * unset `NODE_ENV` all keep the route closed.
33
+ * Whether the route is mounted. Left out, it is open only when `NODE_ENV` names a development
34
+ * environment (`Environment.DEVELOPMENT_ENVS`); `staging`, `uat`, `production`, an unrecognised
35
+ * name and an unset `NODE_ENV` all keep it closed.
36
+ *
37
+ * @default true in a development environment, false otherwise
17
38
  */
18
39
  enable?: boolean;
19
40
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/components/health-check/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { IBuildInfo } from '@venizia/ignis-helpers/core';\n\nexport interface IHealthCheckOptions {\n /** Partially-filled bindings are accepted; every missing field falls back to its default. */\n restOptions?: { path?: string };\n /**\n * `GET <path>/stats`: build stamp, process and memory. The runtime and version it reports are\n * exactly what an attacker needs to pick an exploit, so the default is CLOSED on every host that\n * is not provably a development one.\n */\n stats?: {\n /**\n * Default: open only when `NODE_ENV` names a development environment\n * (`Environment.DEVELOPMENT_ENVS`). `staging`, `uat`, `production`, an unrecognised name and an\n * unset `NODE_ENV` all keep the route closed.\n */\n enable?: boolean;\n /**\n * When set, the route answers only for a request carrying this value in `X-Health-Key`, and a\n * refusal is indistinguishable from an unmounted route. A blank value fails closed.\n * Without the field the route is open to anything that can reach the port.\n */\n secretKey?: string;\n /** Wins over {@link BuildInfoRegistry}; a host that stamps its own build passes it here. */\n buildInfo?: IBuildInfo;\n };\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/components/health-check/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { IBuildInfo } from '@venizia/ignis-helpers/core';\n\n/**\n * Options of `HealthCheckComponent`, bound at `HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS`.\n *\n * @example\n * ```typescript\n * import { HealthCheckBindingKeys, type BaseApplication, type IHealthCheckOptions } from '@venizia/ignis';\n *\n * export const bindHealth = (application: BaseApplication) => {\n * application\n * .bind<IHealthCheckOptions>({ key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS })\n * .toValue({ restOptions: { path: '/status' }, stats: { secretKey: 'change-me' } });\n * };\n * ```\n */\nexport interface IHealthCheckOptions {\n /** Partially-filled bindings are accepted; every missing field falls back to its default. */\n restOptions?: {\n /**\n * Base path the health routes mount under.\n *\n * @default '/health'\n */\n path?: string;\n };\n /**\n * `GET <path>/stats`: build stamp, process and memory. The runtime and version it reports are\n * exactly what an attacker needs to pick an exploit, so the default is CLOSED on every host that\n * is not provably a development one.\n */\n stats?: {\n /**\n * Whether the route is mounted. Left out, it is open only when `NODE_ENV` names a development\n * environment (`Environment.DEVELOPMENT_ENVS`); `staging`, `uat`, `production`, an unrecognised\n * name and an unset `NODE_ENV` all keep it closed.\n *\n * @default true in a development environment, false otherwise\n */\n enable?: boolean;\n /**\n * When set, the route answers only for a request carrying this value in `X-Health-Key`, and a\n * refusal is indistinguishable from an unmounted route. A blank value fails closed.\n * Without the field the route is open to anything that can reach the port.\n */\n secretKey?: string;\n /** Wins over {@link BuildInfoRegistry}; a host that stamps its own build passes it here. */\n buildInfo?: IBuildInfo;\n };\n}\n"]}
@@ -1,6 +1,21 @@
1
1
  import { type BaseApplication } from '../../base/applications/index.js';
2
2
  import { BaseComponent } from '@venizia/ignis-kernel';
3
3
  import { type IHealthCheckOptions } from './common/index.js';
4
+ /**
5
+ * Mounts the health check controller (liveness root, `/ping`, and the gated `/stats`).
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { BaseApplication, HealthCheckComponent, type IHealthCheckOptions } from '@venizia/ignis';
10
+ *
11
+ * abstract class App extends BaseApplication {
12
+ * preConfigure(): void {
13
+ * const options: IHealthCheckOptions = { restOptions: { path: '/status' } };
14
+ * this.component(HealthCheckComponent, { options });
15
+ * }
16
+ * }
17
+ * ```
18
+ */
4
19
  export declare class HealthCheckComponent extends BaseComponent<IHealthCheckOptions> {
5
20
  private application;
6
21
  constructor(application: BaseApplication);
@@ -23,6 +23,21 @@ const DEFAULT_REST_PATH = '/health';
23
23
  const DEFAULT_OPTIONS = {
24
24
  restOptions: { path: DEFAULT_REST_PATH },
25
25
  };
26
+ /**
27
+ * Mounts the health check controller (liveness root, `/ping`, and the gated `/stats`).
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * import { BaseApplication, HealthCheckComponent, type IHealthCheckOptions } from '@venizia/ignis';
32
+ *
33
+ * abstract class App extends BaseApplication {
34
+ * preConfigure(): void {
35
+ * const options: IHealthCheckOptions = { restOptions: { path: '/status' } };
36
+ * this.component(HealthCheckComponent, { options });
37
+ * }
38
+ * }
39
+ * ```
40
+ */
26
41
  let HealthCheckComponent = HealthCheckComponent_1 = class HealthCheckComponent extends BaseComponent {
27
42
  constructor(application) {
28
43
  super({
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/components/health-check/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAA4B,MAAM,UAAU,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAGhD,MAAM,iBAAiB,GAAG,SAAS,CAAC;AACpC,MAAM,eAAe,GAAwB;IAC3C,WAAW,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE;CACzC,CAAC;AAEF,IAAa,oBAAoB,4BAAjC,MAAa,oBAAqB,SAAQ,aAAkC;IAC1E,YAC8D,WAA4B;QAExF,KAAK,CAAC;YACJ,KAAK,EAAE,sBAAoB,CAAC,IAAI;YAChC,WAAW,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE;YACrD,QAAQ,EAAE;gBACR,CAAC,sBAAsB,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC,IAAI,CAAsB;oBAC/E,GAAG,EAAE,sBAAsB,CAAC,oBAAoB;iBACjD,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC;aAC5B;SACF,CAAC,CAAC;QAVyD,gBAAW,GAAX,WAAW,CAAiB;IAW1F,CAAC;IAED;;;;OAIG;IACM,KAAK,CAAC,SAAS,CAAC,IAA0B;QACjD,0FAA0F;QAC1F,8DAA8D;QAC9D,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,OAAO;QACT,CAAC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AAI,EAAE,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC;QAChE,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC;IACrD,CAAC;CACF,CAAA;AAzEY,oBAAoB;IAE5B,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAA;;GAF1C,oBAAoB,CAyEhC","sourcesContent":["import { type BaseApplication } from '@/base/applications';\nimport { BaseComponent } from '@venizia/ignis-kernel';\nimport { controller, inject } from '@/base/metadata';\nimport { CoreBindings } from '@venizia/ignis-kernel';\nimport { HealthCheckBindingKeys, type IHealthCheckOptions } from './common';\nimport { HealthCheckController } from './controller';\nimport { HealthCheckReporter } from './reporter';\nimport { Environment } from '@venizia/ignis-helpers';\nimport { Binding } from '@venizia/ignis-kernel';\nimport type { IApplicationInfo } from '@venizia/ignis-kernel';\n\nconst DEFAULT_REST_PATH = '/health';\nconst DEFAULT_OPTIONS: IHealthCheckOptions = {\n restOptions: { path: DEFAULT_REST_PATH },\n};\n\nexport class HealthCheckComponent extends BaseComponent<IHealthCheckOptions> {\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: HealthCheckComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS]: Binding.bind<IHealthCheckOptions>({\n key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS,\n }).toValue(DEFAULT_OPTIONS),\n },\n });\n }\n\n /**\n * `application.component(HealthCheckComponent, { options })` lands here. Options given at the\n * call site are the most explicit statement of intent, so they take the binding over anything\n * bound earlier; `initDefaultBindings` then finds the key taken and leaves the default aside.\n */\n override async configure(opts?: IHealthCheckOptions): Promise<void> {\n // The base short-circuits a second call; binding before that check would swap the options\n // under routes that were already mounted from the first ones.\n if (this.isConfigured) {\n return;\n }\n\n if (opts !== undefined) {\n this.application\n .bind<IHealthCheckOptions>({ key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS })\n .toValue(opts);\n }\n\n await super.configure(opts);\n }\n\n override async binding(): Promise<void> {\n const healthOptions = this.application.get<IHealthCheckOptions>({\n key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS,\n isOptional: true,\n });\n\n // A partially filled options binding (env/config driven) must not take the app down at boot.\n const path = healthOptions?.restOptions?.path ?? DEFAULT_REST_PATH;\n\n // Legal, occasionally correct, and silent until now: `stats.enable: true` bypasses the\n // environment gate, so the same code that opened the route for a local run opens it in\n // production. Warn rather than refuse - only the operator knows whether the port is reachable.\n if (healthOptions && HealthCheckReporter.isStatsUnguarded({ options: healthOptions })) {\n this.logger\n .for(this.binding.name)\n .warn(\n 'GET %s/stats is ENABLED with no secretKey on env \"%s\" - build stamp, runtime version and memory are readable by anything that reaches this port. Set stats.secretKey, or drop stats.enable and let the environment decide.',\n path,\n Environment.ambient ?? 'unset',\n );\n }\n\n // `getAppInfo()` is async while the container builds the controller synchronously, so the\n // resolved value is bound here rather than resolved inside the controller.\n const binding = this.application.bind<IApplicationInfo>({\n key: HealthCheckBindingKeys.APPLICATION_INFO,\n });\n const appInfo = await this.application.getAppInfo();\n binding.toValue(appInfo);\n\n // The gate and the app identity are per container, but `@controller` writes the PATH onto this\n // one shared class in the process-wide MetadataRegistry, and `RestComponent` reads it back at\n // step 8. Two applications booted one after another are safe; two booted CONCURRENTLY with\n // different `restOptions.path` would race here, and nothing in this component prevents that.\n Reflect.decorate([controller({ path })], HealthCheckController);\n this.application.controller(HealthCheckController);\n }\n}\n"]}
1
+ {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/components/health-check/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CA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AAE,CAAC,CAAA;;GAF1C,oBAAoB,CAyEhC","sourcesContent":["import { type BaseApplication } from '@/base/applications';\nimport { BaseComponent } from '@venizia/ignis-kernel';\nimport { controller, inject } from '@/base/metadata';\nimport { CoreBindings } from '@venizia/ignis-kernel';\nimport { HealthCheckBindingKeys, type IHealthCheckOptions } from './common';\nimport { HealthCheckController } from './controller';\nimport { HealthCheckReporter } from './reporter';\nimport { Environment } from '@venizia/ignis-helpers';\nimport { Binding } from '@venizia/ignis-kernel';\nimport type { IApplicationInfo } from '@venizia/ignis-kernel';\n\nconst DEFAULT_REST_PATH = '/health';\nconst DEFAULT_OPTIONS: IHealthCheckOptions = {\n restOptions: { path: DEFAULT_REST_PATH },\n};\n\n/**\n * Mounts the health check controller (liveness root, `/ping`, and the gated `/stats`).\n *\n * @example\n * ```typescript\n * import { BaseApplication, HealthCheckComponent, type IHealthCheckOptions } from '@venizia/ignis';\n *\n * abstract class App extends BaseApplication {\n * preConfigure(): void {\n * const options: IHealthCheckOptions = { restOptions: { path: '/status' } };\n * this.component(HealthCheckComponent, { options });\n * }\n * }\n * ```\n */\nexport class HealthCheckComponent extends BaseComponent<IHealthCheckOptions> {\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: HealthCheckComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS]: Binding.bind<IHealthCheckOptions>({\n key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS,\n }).toValue(DEFAULT_OPTIONS),\n },\n });\n }\n\n /**\n * `application.component(HealthCheckComponent, { options })` lands here. Options given at the\n * call site are the most explicit statement of intent, so they take the binding over anything\n * bound earlier; `initDefaultBindings` then finds the key taken and leaves the default aside.\n */\n override async configure(opts?: IHealthCheckOptions): Promise<void> {\n // The base short-circuits a second call; binding before that check would swap the options\n // under routes that were already mounted from the first ones.\n if (this.isConfigured) {\n return;\n }\n\n if (opts !== undefined) {\n this.application\n .bind<IHealthCheckOptions>({ key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS })\n .toValue(opts);\n }\n\n await super.configure(opts);\n }\n\n override async binding(): Promise<void> {\n const healthOptions = this.application.get<IHealthCheckOptions>({\n key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS,\n isOptional: true,\n });\n\n // A partially filled options binding (env/config driven) must not take the app down at boot.\n const path = healthOptions?.restOptions?.path ?? DEFAULT_REST_PATH;\n\n // Legal, occasionally correct, and silent until now: `stats.enable: true` bypasses the\n // environment gate, so the same code that opened the route for a local run opens it in\n // production. Warn rather than refuse - only the operator knows whether the port is reachable.\n if (healthOptions && HealthCheckReporter.isStatsUnguarded({ options: healthOptions })) {\n this.logger\n .for(this.binding.name)\n .warn(\n 'GET %s/stats is ENABLED with no secretKey on env \"%s\" - build stamp, runtime version and memory are readable by anything that reaches this port. Set stats.secretKey, or drop stats.enable and let the environment decide.',\n path,\n Environment.ambient ?? 'unset',\n );\n }\n\n // `getAppInfo()` is async while the container builds the controller synchronously, so the\n // resolved value is bound here rather than resolved inside the controller.\n const binding = this.application.bind<IApplicationInfo>({\n key: HealthCheckBindingKeys.APPLICATION_INFO,\n });\n const appInfo = await this.application.getAppInfo();\n binding.toValue(appInfo);\n\n // The gate and the app identity are per container, but `@controller` writes the PATH onto this\n // one shared class in the process-wide MetadataRegistry, and `RestComponent` reads it back at\n // step 8. Two applications booted one after another are safe; two booted CONCURRENTLY with\n // different `restOptions.path` would race here, and nothing in this component prevents that.\n Reflect.decorate([controller({ path })], HealthCheckController);\n this.application.controller(HealthCheckController);\n }\n}\n"]}
@@ -2,6 +2,7 @@ import { BaseRestController, type TRouteContext } from '../../base/controllers/i
2
2
  import type { IApplicationInfo } from '@venizia/ignis-kernel';
3
3
  import { type ValueOrPromise } from '@venizia/ignis-helpers/common';
4
4
  import { type IHealthCheckOptions } from './common/index.js';
5
+ /** Serves the health routes: the root summary and `/ping` always, `/stats` only when `IHealthCheckOptions.stats` allows it and the request is authorized. */
5
6
  export declare class HealthCheckController extends BaseRestController {
6
7
  private readonly healthOptions;
7
8
  private readonly appInfo?;
@@ -92,6 +92,7 @@ const RouteConfigs = {
92
92
  }),
93
93
  },
94
94
  };
95
+ /** Serves the health routes: the root summary and `/ping` always, `/stats` only when `IHealthCheckOptions.stats` allows it and the request is authorized. */
95
96
  let HealthCheckController = HealthCheckController_1 = class HealthCheckController extends BaseRestController {
96
97
  /**
97
98
  * Both dependencies arrive through the container, so two applications in one process each get