@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":"request-spy.middleware.js","sourceRoot":"","sources":["../../../../../src/base/middlewares/request-spy/request-spy.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACrF,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAErD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAiB,MAAM,uBAAuB,CAAC;AAErF,MAAM,wBAAwB,GAAG,OAAO,CAAC;AAEzC,mPAAmP;AACnP,MAAM,OAAO,oBAAqB,SAAQ,UAAU;aAClC,mBAAc,GAAG,cAAc,CAAC;IAIhD;;;;;;;;;OASG;IACH;QACE,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;QAC1B,MAAM,GAAG,GAAG,WAAW,CAAC,OAAO,EAAE,WAAW,EAAE,CAAC;QAC/C,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,GAAG,IAAI,gBAAgB,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzE,CAAC;IAED,8PAA8P;IAC9P,KAAK,CAAC,SAAS,CAAC,IAA8B;QAC5C,MAAM,WAAW,GA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AEhC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;gBACrB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;gBAC3C,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,2CAA2C,EAC3C,SAAS,EACT,QAAQ,EACR,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,EACrB,IAAI,EACJ,KAAK,EACL,IAAI,CACL,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,4FAA4F;gBAC5F,yFAAyF;gBACzF,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,EAAE,CAAC;oBACxF,MAAM,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;gBAChC,CAAC;gBAED,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,gCAAgC,EAChC,SAAS,EACT,QAAQ,EACR,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,EACrB,IAAI,EACJ,KAAK,CACN,CAAC;YACJ,CAAC;YAED,MAAM,IAAI,EAAE,CAAC;YAEb,MAAM,QAAQ,GAAG,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YACpD,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,oCAAoC,EACpC,SAAS,EACT,QAAQ,EACR,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,EACrB,IAAI,EACJ,QAAQ,CACT,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC","sourcesContent":["import { NetworkUtility } from '@/utilities/network.utility';\nimport { Environment } from '@venizia/ignis-helpers';\nimport { BaseHelper, EnvironmentNames, getError } from '@venizia/ignis-helpers/core';\nimport { HTTP } from '@venizia/ignis-helpers/common';\nimport type { IProvider } from '@venizia/ignis-inversion';\nimport { createMiddleware } from 'hono/factory';\nimport type { MiddlewareHandler } from 'hono/types';\nimport { REQUEST_ID_KEY, RequestErrors, type TContext } from '@venizia/ignis-kernel';\n\nconst TEXT_CONTENT_TYPE_PREFIX = 'text/';\n\n/** Logs incoming/outgoing request details. The BODY is parsed and logged only in a recognised development environment - see the constructor for why that test is fail-closed; elsewhere only a JSON body is parsed, for its malformed-body 400. */\nexport class RequestSpyMiddleware extends BaseHelper implements IProvider<MiddlewareHandler> {\n static readonly REQUEST_ID_KEY = REQUEST_ID_KEY;\n\n private isDebugMode: boolean;\n\n /**\n * Fail-CLOSED, matching {@link BaseAppErrorMiddleware.isProduction}: only an environment this\n * framework recognises as a development one enables body logging.\n *\n * The previous test was `env !== 'production'`, which enabled it for an unset `NODE_ENV` and for\n * every pre-production name that carries real user data - `staging`, `uat`, `alpha`, `beta`, and\n * the abbreviation `prod`. `development-envs.test.ts` pins those as NOT development for exactly\n * that reason. Redaction is no defence here: it masks secret-SHAPED keys, so `nationalId`,\n * `cardNumber` and `ssn` were written verbatim.\n */\n constructor() {\n super({ scope: 'SpyMW' });\n const env = Environment.ambient?.toLowerCase();\n this.isDebugMode = !!env && EnvironmentNames.DEVELOPMENT_ENVS.has(env);\n }\n\n /** Parses the body by Content-Type without draining it for the handler: JSON and form bodies go through the request cache, `text/*` is read from a clone (from the cache once something read it), and any other type is described by its size, never read. */\n async parseBody(opts: { req: TContext['req'] }): Promise<unknown> {\n const contentType = opts.req.header(HTTP.Headers.CONTENT_TYPE);\n\n if (!contentType) {\n return null;\n }\n\n // Only an explicit zero short-circuits: a CHUNKED request carries no Content-Length, so gating on the header's presence would skip every streamed body and let a malformed one detonate deeper as a 500.\n const contentLength = opts.req.header(HTTP.Headers.CONTENT_LENGTH);\n\n if (contentLength === '0' || !opts.req.raw.body) {\n return null;\n }\n\n try {\n if (contentType.includes(HTTP.HeaderValues.APPLICATION_JSON)) {\n const rs = await opts.req.json();\n\n return rs;\n }\n\n if (\n contentType.includes(HTTP.HeaderValues.MULTIPART_FORM_DATA) ||\n contentType.includes(HTTP.HeaderValues.APPLICATION_FORM_URLENCODED)\n ) {\n const rs = await opts.req.parseBody();\n\n return rs;\n }\n\n if (contentType === HTTP.HeaderValues.APPLICATION_OCTET_STREAM) {\n return opts.req.raw.body;\n }\n\n // Anything else is read, if at all, from a clone: a handler may stream `req.raw.body` on (an upload proxy), and reading the request itself would drain it and mangle binary bytes.\n // A body an earlier middleware read cannot be cloned; Hono's cache serves it instead.\n if (contentType.startsWith(TEXT_CONTENT_TYPE_PREFIX)) {\n let rs: string;\n\n if (opts.req.raw.bodyUsed) {\n const cached = await opts.req.text();\n rs = cached;\n } else {\n const cloned = await opts.req.raw.clone().text();\n rs = cloned;\n }\n\n return rs;\n }\n\n return `<${contentLength ?? 'unknown'} bytes, ${contentType}>`;\n } catch {\n throw getError({\n error: RequestErrors.BODY_MALFORMED,\n message: 'Malformed Body Payload',\n });\n }\n }\n\n /** Returns a Hono middleware that logs request details and duration. */\n value() {\n return createMiddleware(async (context, next) => {\n const t = performance.now();\n const { req } = context;\n\n const requestId = context.get(RequestSpyMiddleware.REQUEST_ID_KEY);\n const incomingIp = NetworkUtility.getIncomingIp(context);\n const forwardedIp = req.header('x-real-ip') ?? req.header('x-forwarded-for') ?? null;\n\n const method = req.method;\n const path = req.path ?? '/';\n\n // Best-effort, never fatal: a unix socket, some proxies and any in-process call yield no connection info - refusing to serve because the client IP is unknown turns a logging gap into an outage.\n const clientIp = incomingIp ?? forwardedIp ?? 'unknown';\n const query = req.query() ?? {};\n\n if (this.isDebugMode) {\n const body = await this.parseBody({ req });\n this.logger.info(\n '[%s][%s][=>] %s %s | query: %j | body: %j',\n requestId,\n clientIp,\n method.padEnd(8, ' '),\n path,\n query,\n body,\n );\n } else {\n // Only JSON is parsed here: its clean 400 on a malformed body is a contract. Any other body\n // would be read for a log line that never prints it, before the route's own size checks.\n if (req.header(HTTP.Headers.CONTENT_TYPE)?.includes(HTTP.HeaderValues.APPLICATION_JSON)) {\n await this.parseBody({ req });\n }\n\n this.logger.info(\n '[%s][%s][=>] %s %s | query: %j',\n requestId,\n clientIp,\n method.padEnd(8, ' '),\n path,\n query,\n );\n }\n\n await next();\n\n const duration = (performance.now() - t).toFixed(2);\n this.logger.info(\n '[%s][%s][<=] %s %s | Took: %s (ms)',\n requestId,\n clientIp,\n method.padEnd(8, ' '),\n path,\n duration,\n );\n });\n }\n}\n"]}
1
+ {"version":3,"file":"request-spy.middleware.js","sourceRoot":"","sources":["../../../../../src/base/middlewares/request-spy/request-spy.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACrF,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAiB,MAAM,uBAAuB,CAAC;AAErF,MAAM,wBAAwB,GAAG,OAAO,CAAC;AAEzC,mPAAmP;AACnP,MAAM,OAAO,oBAAqB,SAAQ,UAAU;aAClC,mBAAc,GAAG,cAAc,CAAC;aACxB,wBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAIzE;;;;;;;;;OASG;IACH;QACE,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;QAC1B,MAAM,GAAG,GAAG,WAAW,CAAC,OAAO,EAAE,WAAW,EAAE,CAAC;QAC/C,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,GAAG,IAAI,gBAAgB,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC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,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YACpD,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,oCAAoC,EACpC,SAAS,EACT,QAAQ,EACR,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,EACrB,IAAI,EACJ,QAAQ,CACT,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC","sourcesContent":["import { NetworkUtility } from '@/utilities/network.utility';\nimport { Environment } from '@venizia/ignis-helpers';\nimport { BaseHelper, EnvironmentNames, getError } from '@venizia/ignis-helpers/core';\nimport { HTTP, REDACTED } from '@venizia/ignis-helpers/common';\nimport type { IProvider } from '@venizia/ignis-inversion';\nimport { createMiddleware } from 'hono/factory';\nimport type { MiddlewareHandler } from 'hono/types';\nimport { REQUEST_ID_KEY, RequestErrors, type TContext } from '@venizia/ignis-kernel';\n\nconst TEXT_CONTENT_TYPE_PREFIX = 'text/';\n\n/** Logs incoming/outgoing request details. The BODY is parsed and logged only in a recognised development environment - see the constructor for why that test is fail-closed; elsewhere only a JSON body is parsed, for its malformed-body 400. */\nexport class RequestSpyMiddleware extends BaseHelper implements IProvider<MiddlewareHandler> {\n static readonly REQUEST_ID_KEY = REQUEST_ID_KEY;\n private static readonly CALLBACK_PARAMETERS = new Set(['code', 'state']);\n\n private isDebugMode: boolean;\n\n /**\n * Fail-CLOSED, matching {@link BaseAppErrorMiddleware.isProduction}: only an environment this\n * framework recognises as a development one enables body logging.\n *\n * The previous test was `env !== 'production'`, which enabled it for an unset `NODE_ENV` and for\n * every pre-production name that carries real user data - `staging`, `uat`, `alpha`, `beta`, and\n * the abbreviation `prod`. `development-envs.test.ts` pins those as NOT development for exactly\n * that reason. Redaction is no defence here: it masks secret-SHAPED keys, so `nationalId`,\n * `cardNumber` and `ssn` were written verbatim.\n */\n constructor() {\n super({ scope: 'SpyMW' });\n const env = Environment.ambient?.toLowerCase();\n this.isDebugMode = !!env && EnvironmentNames.DEVELOPMENT_ENVS.has(env);\n }\n\n /** Parses the body by Content-Type without draining it for the handler: JSON and form bodies go through the request cache, `text/*` is read from a clone (from the cache once something read it), and any other type is described by its size, never read. */\n async parseBody(opts: { req: TContext['req'] }): Promise<unknown> {\n const contentType = opts.req.header(HTTP.Headers.CONTENT_TYPE);\n\n if (!contentType) {\n return null;\n }\n\n // Only an explicit zero short-circuits: a CHUNKED request carries no Content-Length, so gating on the header's presence would skip every streamed body and let a malformed one detonate deeper as a 500.\n const contentLength = opts.req.header(HTTP.Headers.CONTENT_LENGTH);\n\n if (contentLength === '0' || !opts.req.raw.body) {\n return null;\n }\n\n try {\n if (contentType.includes(HTTP.HeaderValues.APPLICATION_JSON)) {\n const rs = await opts.req.json();\n\n return rs;\n }\n\n if (\n contentType.includes(HTTP.HeaderValues.MULTIPART_FORM_DATA) ||\n contentType.includes(HTTP.HeaderValues.APPLICATION_FORM_URLENCODED)\n ) {\n const rs = await opts.req.parseBody();\n\n return rs;\n }\n\n if (contentType === HTTP.HeaderValues.APPLICATION_OCTET_STREAM) {\n return opts.req.raw.body;\n }\n\n // Anything else is read, if at all, from a clone: a handler may stream `req.raw.body` on (an upload proxy), and reading the request itself would drain it and mangle binary bytes.\n // A body an earlier middleware read cannot be cloned; Hono's cache serves it instead.\n if (contentType.startsWith(TEXT_CONTENT_TYPE_PREFIX)) {\n let rs: string;\n\n if (opts.req.raw.bodyUsed) {\n const cached = await opts.req.text();\n rs = cached;\n } else {\n const cloned = await opts.req.raw.clone().text();\n rs = cloned;\n }\n\n return rs;\n }\n\n return `<${contentLength ?? 'unknown'} bytes, ${contentType}>`;\n } catch {\n throw getError({\n error: RequestErrors.BODY_MALFORMED,\n message: 'Malformed Body Payload',\n });\n }\n }\n\n /** Returns a Hono middleware that logs request details and duration. */\n value() {\n return createMiddleware(async (context, next) => {\n const t = performance.now();\n const { req } = context;\n\n const requestId = context.get(RequestSpyMiddleware.REQUEST_ID_KEY);\n const incomingIp = NetworkUtility.getIncomingIp(context);\n const forwardedIp = req.header('x-real-ip') ?? req.header('x-forwarded-for') ?? null;\n\n const method = req.method;\n const path = req.path ?? '/';\n\n // Best-effort, never fatal: a unix socket, some proxies and any in-process call yield no connection info - refusing to serve because the client IP is unknown turns a logging gap into an outage.\n const clientIp = incomingIp ?? forwardedIp ?? 'unknown';\n // `code` and `state` are credentials in an OAuth callback and too common as plain names to mask everywhere.\n const query = Object.fromEntries(\n Object.entries(req.query() ?? {}).map(([key, value]) => {\n return [\n key,\n RequestSpyMiddleware.CALLBACK_PARAMETERS.has(key.toLowerCase()) ? REDACTED : value,\n ];\n }),\n );\n\n if (this.isDebugMode) {\n const body = await this.parseBody({ req });\n this.logger.info(\n '[%s][%s][=>] %s %s | query: %j | body: %j',\n requestId,\n clientIp,\n method.padEnd(8, ' '),\n path,\n query,\n body,\n );\n } else {\n // Only JSON is parsed here: its clean 400 on a malformed body is a contract. Any other body\n // would be read for a log line that never prints it, before the route's own size checks.\n if (req.header(HTTP.Headers.CONTENT_TYPE)?.includes(HTTP.HeaderValues.APPLICATION_JSON)) {\n await this.parseBody({ req });\n }\n\n this.logger.info(\n '[%s][%s][=>] %s %s | query: %j',\n requestId,\n clientIp,\n method.padEnd(8, ' '),\n path,\n query,\n );\n }\n\n await next();\n\n const duration = (performance.now() - t).toFixed(2);\n this.logger.info(\n '[%s][%s][<=] %s %s | Took: %s (ms)',\n requestId,\n clientIp,\n method.padEnd(8, ' '),\n path,\n duration,\n );\n });\n }\n}\n"]}
@@ -1,3 +1,4 @@
1
+ /** The document UI implementations the API reference can render. `isValid` checks a string against them. */
1
2
  export declare class DocumentUITypes {
2
3
  static readonly SWAGGER = "swagger";
3
4
  static readonly SCALAR = "scalar";
@@ -1,3 +1,4 @@
1
+ /** The document UI implementations the API reference can render. `isValid` checks a string against them. */
1
2
  export class DocumentUITypes {
2
3
  static { this.SWAGGER = 'swagger'; }
3
4
  static { this.SCALAR = 'scalar'; }
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/components/api-reference/common/constants.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,eAAe;aACV,YAAO,GAAG,SAAS,CAAC;aACpB,WAAM,GAAG,QAAQ,CAAC;aAElB,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAElE,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC","sourcesContent":["export class DocumentUITypes {\n static readonly SWAGGER = 'swagger';\n static readonly SCALAR = 'scalar';\n\n static readonly SCHEME_SET = new Set([this.SWAGGER, this.SCALAR]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/components/api-reference/common/constants.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,MAAM,OAAO,eAAe;aACV,YAAO,GAAG,SAAS,CAAC;aACpB,WAAM,GAAG,QAAQ,CAAC;aAElB,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAElE,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC","sourcesContent":["/** The document UI implementations the API reference can render. `isValid` checks a string against them. */\nexport class DocumentUITypes {\n static readonly SWAGGER = 'swagger';\n static readonly SCALAR = 'scalar';\n\n static readonly SCHEME_SET = new Set([this.SWAGGER, this.SCALAR]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n"]}
@@ -1,3 +1,4 @@
1
+ /** Container keys of the API reference component. */
1
2
  export declare class ApiReferenceBindingKeys {
2
3
  static readonly API_REFERENCE_OPTIONS = "@app/api-reference/options";
3
4
  }
@@ -1,3 +1,4 @@
1
+ /** Container keys of the API reference component. */
1
2
  export class ApiReferenceBindingKeys {
2
3
  static { this.API_REFERENCE_OPTIONS = '@app/api-reference/options'; }
3
4
  }
@@ -1 +1 @@
1
- {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/api-reference/common/keys.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,uBAAuB;aAClB,0BAAqB,GAAG,4BAA4B,CAAC","sourcesContent":["export class ApiReferenceBindingKeys {\n static readonly API_REFERENCE_OPTIONS = '@app/api-reference/options';\n}\n"]}
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/api-reference/common/keys.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,MAAM,OAAO,uBAAuB;aAClB,0BAAqB,GAAG,4BAA4B,CAAC","sourcesContent":["/** Container keys of the API reference component. */\nexport class ApiReferenceBindingKeys {\n static readonly API_REFERENCE_OPTIONS = '@app/api-reference/options';\n}\n"]}
@@ -1,8 +1,22 @@
1
1
  import type { Context, Next } from 'hono';
2
2
  import type { DocumentUITypes } from './constants.js';
3
3
  import type { TConstValue } from '@venizia/ignis-helpers/common';
4
+ /** One of the `DocumentUITypes` values. */
4
5
  export type TDocumentUIType = TConstValue<typeof DocumentUITypes>;
5
- /** Every field is optional: a partially-filled binding falls back to the component defaults. */
6
+ /**
7
+ * Every field is optional: a partially-filled binding falls back to the component defaults.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { ApiReferenceBindingKeys, type BaseApplication, type IApiReferenceOptions } from '@venizia/ignis';
12
+ *
13
+ * export const bindApiReference = (application: BaseApplication) => {
14
+ * application
15
+ * .bind<IApiReferenceOptions>({ key: ApiReferenceBindingKeys.API_REFERENCE_OPTIONS })
16
+ * .toValue({ restOptions: { base: { path: '/docs' }, ui: { type: 'swagger' } } });
17
+ * };
18
+ * ```
19
+ */
6
20
  export interface IApiReferenceOptions {
7
21
  restOptions?: {
8
22
  base?: {
@@ -35,14 +49,17 @@ export interface IApiReferenceOptions {
35
49
  uiConfig?: Record<string, any>;
36
50
  securitySchemes?: Record<string, Record<string, any>>;
37
51
  }
52
+ /** Renders the interactive API documentation page for the OpenAPI document. Register an implementation on `UIProviderFactory` to serve a custom UI. */
38
53
  export interface IUIProvider {
39
54
  render(context: Context, config: IUIConfig, next: Next): Promise<Response | void>;
40
55
  }
56
+ /** Input of `IUIProvider.render`. Fields beyond `title` and `url` are passed through to the underlying UI library. */
41
57
  export interface IUIConfig {
42
58
  title: string;
43
59
  url: string;
44
60
  [key: string]: any;
45
61
  }
62
+ /** Selects a registered UI provider by its type name. */
46
63
  export interface IGetProviderParams {
47
64
  type: string;
48
65
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/components/api-reference/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Context, Next } from 'hono';\nimport type { DocumentUITypes } from './constants';\nimport type { TConstValue } from '@venizia/ignis-helpers/common';\n\nexport type TDocumentUIType = TConstValue<typeof DocumentUITypes>;\n\n/** Every field is optional: a partially-filled binding falls back to the component defaults. */\nexport interface IApiReferenceOptions {\n restOptions?: {\n base?: { path?: string };\n doc?: { path?: string };\n ui?: { path?: string; type?: TDocumentUIType };\n };\n explorer?: {\n openapi?: string;\n info?: {\n title: string;\n version: string;\n description: string;\n contact?: { name: string; email: string };\n };\n servers?: Array<{\n url: string;\n description?: string;\n }>;\n };\n uiConfig?: Record<string, any>;\n securitySchemes?: Record<string, Record<string, any>>;\n}\n\nexport interface IUIProvider {\n render(context: Context, config: IUIConfig, next: Next): Promise<Response | void>;\n}\n\nexport interface IUIConfig {\n title: string;\n url: string;\n [key: string]: any;\n}\n\nexport interface IGetProviderParams {\n type: string;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/components/api-reference/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Context, Next } from 'hono';\nimport type { DocumentUITypes } from './constants';\nimport type { TConstValue } from '@venizia/ignis-helpers/common';\n\n/** One of the `DocumentUITypes` values. */\nexport type TDocumentUIType = TConstValue<typeof DocumentUITypes>;\n\n/**\n * Every field is optional: a partially-filled binding falls back to the component defaults.\n *\n * @example\n * ```typescript\n * import { ApiReferenceBindingKeys, type BaseApplication, type IApiReferenceOptions } from '@venizia/ignis';\n *\n * export const bindApiReference = (application: BaseApplication) => {\n * application\n * .bind<IApiReferenceOptions>({ key: ApiReferenceBindingKeys.API_REFERENCE_OPTIONS })\n * .toValue({ restOptions: { base: { path: '/docs' }, ui: { type: 'swagger' } } });\n * };\n * ```\n */\nexport interface IApiReferenceOptions {\n restOptions?: {\n base?: { path?: string };\n doc?: { path?: string };\n ui?: { path?: string; type?: TDocumentUIType };\n };\n explorer?: {\n openapi?: string;\n info?: {\n title: string;\n version: string;\n description: string;\n contact?: { name: string; email: string };\n };\n servers?: Array<{\n url: string;\n description?: string;\n }>;\n };\n uiConfig?: Record<string, any>;\n securitySchemes?: Record<string, Record<string, any>>;\n}\n\n/** Renders the interactive API documentation page for the OpenAPI document. Register an implementation on `UIProviderFactory` to serve a custom UI. */\nexport interface IUIProvider {\n render(context: Context, config: IUIConfig, next: Next): Promise<Response | void>;\n}\n\n/** Input of `IUIProvider.render`. Fields beyond `title` and `url` are passed through to the underlying UI library. */\nexport interface IUIConfig {\n title: string;\n url: string;\n [key: string]: any;\n}\n\n/** Selects a registered UI provider by its type name. */\nexport interface IGetProviderParams {\n type: string;\n}\n"]}
@@ -1,5 +1,19 @@
1
1
  import { type BaseApplication } from '../../base/applications/index.js';
2
2
  import { BaseComponent } from '@venizia/ignis-kernel';
3
+ /**
4
+ * Serves the OpenAPI document and an interactive UI for it. Paths and UI type come from `IApiReferenceOptions` bound at `ApiReferenceBindingKeys.API_REFERENCE_OPTIONS`; `info` is always taken from the application info.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { ApiReferenceComponent, BaseApplication } from '@venizia/ignis';
9
+ *
10
+ * abstract class App extends BaseApplication {
11
+ * preConfigure(): void {
12
+ * this.component(ApiReferenceComponent);
13
+ * }
14
+ * }
15
+ * ```
16
+ */
3
17
  export declare class ApiReferenceComponent extends BaseComponent {
4
18
  private application;
5
19
  constructor(application: BaseApplication);
@@ -42,6 +42,20 @@ const joinRestPath = (segments) => {
42
42
  .replace(/\/$/, '');
43
43
  return joined.startsWith('/') ? joined : `/${joined}`;
44
44
  };
45
+ /**
46
+ * Serves the OpenAPI document and an interactive UI for it. Paths and UI type come from `IApiReferenceOptions` bound at `ApiReferenceBindingKeys.API_REFERENCE_OPTIONS`; `info` is always taken from the application info.
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * import { ApiReferenceComponent, BaseApplication } from '@venizia/ignis';
51
+ *
52
+ * abstract class App extends BaseApplication {
53
+ * preConfigure(): void {
54
+ * this.component(ApiReferenceComponent);
55
+ * }
56
+ * }
57
+ * ```
58
+ */
45
59
  let ApiReferenceComponent = ApiReferenceComponent_1 = class ApiReferenceComponent extends BaseComponent {
46
60
  constructor(application) {
47
61
  super({
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/components/api-reference/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGzC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE7E,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAA6B,MAAM,UAAU,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAEzC,MAAM,6BAA6B,GAAyB;IAC1D,WAAW,EAAE;QACX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type BaseApplication } from '@/base/applications';\nimport { inject } from '@/base/metadata';\nimport { type OpenAPIObjectConfigure } from '@hono/zod-openapi';\nimport type { AnyType } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { BaseComponent, Binding, CoreBindings } from '@venizia/ignis-kernel';\nimport type { Context, Next } from 'hono';\nimport { Authentication } from '../auth';\nimport { ServiceAssertion } from '@venizia/ignis-kernel';\nimport { ApiReferenceBindingKeys, DocumentUITypes, type IApiReferenceOptions } from './common';\nimport { UIProviderFactory } from './ui';\n\nconst DEFAULT_API_REFERENCE_OPTIONS: IApiReferenceOptions = {\n restOptions: {\n base: { path: '/doc' },\n doc: { path: '/openapi.json' },\n ui: { path: '/explorer', type: 'scalar' },\n },\n explorer: {\n openapi: '3.0.0',\n info: {\n title: 'API Documentation',\n version: '1.0.0',\n description: 'API documentation for your service',\n },\n },\n};\n\n/** Joins rest path segments into a single absolute path (no empty or duplicated separators). */\nconst joinRestPath = (segments: Array<string | undefined>): string => {\n const joined = segments\n .filter((segment): segment is string => Boolean(segment))\n .join('/')\n .replace(/\\/+/g, '/')\n .replace(/\\/$/, '');\n\n return joined.startsWith('/') ? joined : `/${joined}`;\n};\n\nexport class ApiReferenceComponent extends BaseComponent {\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: ApiReferenceComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [ApiReferenceBindingKeys.API_REFERENCE_OPTIONS]: Binding.bind<IApiReferenceOptions>({\n key: ApiReferenceBindingKeys.API_REFERENCE_OPTIONS,\n }).toValue(DEFAULT_API_REFERENCE_OPTIONS),\n },\n });\n }\n\n override async binding() {\n const boundOptions = this.application.get<IApiReferenceOptions>({\n key: ApiReferenceBindingKeys.API_REFERENCE_OPTIONS,\n isOptional: true,\n });\n\n const defaultRestOptions = DEFAULT_API_REFERENCE_OPTIONS.restOptions!;\n const restOptions = {\n base: { ...defaultRestOptions.base, ...boundOptions?.restOptions?.base },\n doc: { ...defaultRestOptions.doc, ...boundOptions?.restOptions?.doc },\n ui: { ...defaultRestOptions.ui, ...boundOptions?.restOptions?.ui },\n };\n\n // A fresh explorer object per application: mutating the bound one (or the module default) leaks this application's info/servers into every later application in the process.\n const explorer: NonNullable<IApiReferenceOptions['explorer']> = {\n ...DEFAULT_API_REFERENCE_OPTIONS.explorer,\n ...boundOptions?.explorer,\n };\n\n const rootRouter = this.application.getRootRouter();\n const configs = this.application.getProjectConfigs();\n\n const appInfo = await this.application.getAppInfo();\n explorer.info = {\n title: appInfo.name,\n version: appInfo.version,\n description: appInfo.description,\n contact: appInfo.author,\n };\n\n if (!explorer.servers?.length) {\n explorer.servers = [\n {\n url: ['http://', this.application.getServerAddress(), configs.path.base ?? ''].join(''),\n description: 'Local Application Server URL',\n },\n ];\n }\n\n const docPath = joinRestPath([restOptions.base.path, restOptions.doc.path]);\n const uiPath = joinRestPath([restOptions.base.path, restOptions.ui.path]);\n\n rootRouter.doc(docPath, explorer as OpenAPIObjectConfigure<any, string>);\n\n const uiType = restOptions.ui.type ?? DocumentUITypes.SWAGGER;\n const uiProviderFactory = UIProviderFactory.getInstance();\n\n // A custom provider registered on the factory is honoured; only unknown types are rejected.\n if (!uiProviderFactory.isBound(uiType)) {\n if (!DocumentUITypes.isValid(uiType)) {\n throw getError({\n message: `[binding] Invalid document UI Type | uiType: ${uiType} | valids: ${[...DocumentUITypes.SCHEME_SET]}`,\n });\n }\n\n uiProviderFactory.register({ type: uiType });\n }\n\n const docUrl = joinRestPath([configs.path.base, docPath]);\n const uiProvider = uiProviderFactory.getProvider({ type: uiType });\n\n rootRouter.get(uiPath, async (context: Context, next: Next) => {\n return uiProvider.render(\n context,\n {\n title: appInfo.name,\n url: docUrl,\n ...(boundOptions?.uiConfig ?? {}),\n },\n next,\n );\n });\n\n rootRouter.openAPIRegistry.registerComponent('securitySchemes', Authentication.STRATEGY_JWT, {\n type: 'http',\n scheme: 'bearer',\n bearerFormat: 'JWT',\n });\n\n rootRouter.openAPIRegistry.registerComponent('securitySchemes', Authentication.STRATEGY_BASIC, {\n type: 'http',\n scheme: 'basic',\n });\n\n rootRouter.openAPIRegistry.registerComponent(\n 'securitySchemes',\n Authentication.STRATEGY_SERVICE,\n { type: 'apiKey', in: 'header', name: ServiceAssertion.HEADER },\n );\n\n const securitySchemes = boundOptions?.securitySchemes ?? {};\n const securitySchemesEntries = Object.entries(securitySchemes);\n\n for (const [name, scheme] of securitySchemesEntries) {\n rootRouter.openAPIRegistry.registerComponent('securitySchemes', name, scheme as AnyType);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/components/api-reference/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGzC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE7E,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAA6B,MAAM,UAAU,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAEzC,MAAM,6BAA6B,GAAyB;IAC1D,WAAW,EAAE;QACX,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;QACtB,GAAG,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE;QAC9B,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE;KAC1C;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE;YACJ,KAAK,EAAE,mBAAmB;YAC1B,OAAO,EAAE,OAAO;YAChB,WAAW,EAAE,oCAAoC;SAClD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iBAAiB,EAAE,cAAc,CAAC,YAAY,EAAE;YAC3F,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,QAAQ;YAChB,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;QAEH,UAAU,CAAC,eAAe,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,cAAc,CAAC,cAAc,EAAE;YAC7F,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,OAAO;SAChB,CAAC,CAAC;QAEH,UAAU,CAAC,eAAe,CAAC,iBAAiB,CAC1C,iBAAiB,EACjB,cAAc,CAAC,gBAAgB,EAC/B,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,gBAAgB,CAAC,MAAM,EAAE,CAChE,CAAC;QAEF,MAAM,eAAe,GAAG,YAAY,EAAE,eAAe,IAAI,EAAE,CAAC;QAC5D,MAAM,sBAAsB,GAAG,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;QAE/D,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,sBAAsB,EAAE,CAAC;YACpD,UAAU,CAAC,eAAe,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,IAAI,EAAE,MAAiB,CAAC,CAAC;QAC3F,CAAC;IACH,CAAC;CACF,CAAA;AAhHY,qBAAqB;IAE7B,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAA;;GAF1C,qBAAqB,CAgHjC","sourcesContent":["import { type BaseApplication } from '@/base/applications';\nimport { inject } from '@/base/metadata';\nimport { type OpenAPIObjectConfigure } from '@hono/zod-openapi';\nimport type { AnyType } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { BaseComponent, Binding, CoreBindings } from '@venizia/ignis-kernel';\nimport type { Context, Next } from 'hono';\nimport { Authentication } from '../auth';\nimport { ServiceAssertion } from '@venizia/ignis-kernel';\nimport { ApiReferenceBindingKeys, DocumentUITypes, type IApiReferenceOptions } from './common';\nimport { UIProviderFactory } from './ui';\n\nconst DEFAULT_API_REFERENCE_OPTIONS: IApiReferenceOptions = {\n restOptions: {\n base: { path: '/doc' },\n doc: { path: '/openapi.json' },\n ui: { path: '/explorer', type: 'scalar' },\n },\n explorer: {\n openapi: '3.0.0',\n info: {\n title: 'API Documentation',\n version: '1.0.0',\n description: 'API documentation for your service',\n },\n },\n};\n\n/** Joins rest path segments into a single absolute path (no empty or duplicated separators). */\nconst joinRestPath = (segments: Array<string | undefined>): string => {\n const joined = segments\n .filter((segment): segment is string => Boolean(segment))\n .join('/')\n .replace(/\\/+/g, '/')\n .replace(/\\/$/, '');\n\n return joined.startsWith('/') ? joined : `/${joined}`;\n};\n\n/**\n * Serves the OpenAPI document and an interactive UI for it. Paths and UI type come from `IApiReferenceOptions` bound at `ApiReferenceBindingKeys.API_REFERENCE_OPTIONS`; `info` is always taken from the application info.\n *\n * @example\n * ```typescript\n * import { ApiReferenceComponent, BaseApplication } from '@venizia/ignis';\n *\n * abstract class App extends BaseApplication {\n * preConfigure(): void {\n * this.component(ApiReferenceComponent);\n * }\n * }\n * ```\n */\nexport class ApiReferenceComponent extends BaseComponent {\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: ApiReferenceComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [ApiReferenceBindingKeys.API_REFERENCE_OPTIONS]: Binding.bind<IApiReferenceOptions>({\n key: ApiReferenceBindingKeys.API_REFERENCE_OPTIONS,\n }).toValue(DEFAULT_API_REFERENCE_OPTIONS),\n },\n });\n }\n\n override async binding() {\n const boundOptions = this.application.get<IApiReferenceOptions>({\n key: ApiReferenceBindingKeys.API_REFERENCE_OPTIONS,\n isOptional: true,\n });\n\n const defaultRestOptions = DEFAULT_API_REFERENCE_OPTIONS.restOptions!;\n const restOptions = {\n base: { ...defaultRestOptions.base, ...boundOptions?.restOptions?.base },\n doc: { ...defaultRestOptions.doc, ...boundOptions?.restOptions?.doc },\n ui: { ...defaultRestOptions.ui, ...boundOptions?.restOptions?.ui },\n };\n\n // A fresh explorer object per application: mutating the bound one (or the module default) leaks this application's info/servers into every later application in the process.\n const explorer: NonNullable<IApiReferenceOptions['explorer']> = {\n ...DEFAULT_API_REFERENCE_OPTIONS.explorer,\n ...boundOptions?.explorer,\n };\n\n const rootRouter = this.application.getRootRouter();\n const configs = this.application.getProjectConfigs();\n\n const appInfo = await this.application.getAppInfo();\n explorer.info = {\n title: appInfo.name,\n version: appInfo.version,\n description: appInfo.description,\n contact: appInfo.author,\n };\n\n if (!explorer.servers?.length) {\n explorer.servers = [\n {\n url: ['http://', this.application.getServerAddress(), configs.path.base ?? ''].join(''),\n description: 'Local Application Server URL',\n },\n ];\n }\n\n const docPath = joinRestPath([restOptions.base.path, restOptions.doc.path]);\n const uiPath = joinRestPath([restOptions.base.path, restOptions.ui.path]);\n\n rootRouter.doc(docPath, explorer as OpenAPIObjectConfigure<any, string>);\n\n const uiType = restOptions.ui.type ?? DocumentUITypes.SWAGGER;\n const uiProviderFactory = UIProviderFactory.getInstance();\n\n // A custom provider registered on the factory is honoured; only unknown types are rejected.\n if (!uiProviderFactory.isBound(uiType)) {\n if (!DocumentUITypes.isValid(uiType)) {\n throw getError({\n message: `[binding] Invalid document UI Type | uiType: ${uiType} | valids: ${[...DocumentUITypes.SCHEME_SET]}`,\n });\n }\n\n uiProviderFactory.register({ type: uiType });\n }\n\n const docUrl = joinRestPath([configs.path.base, docPath]);\n const uiProvider = uiProviderFactory.getProvider({ type: uiType });\n\n rootRouter.get(uiPath, async (context: Context, next: Next) => {\n return uiProvider.render(\n context,\n {\n title: appInfo.name,\n url: docUrl,\n ...(boundOptions?.uiConfig ?? {}),\n },\n next,\n );\n });\n\n rootRouter.openAPIRegistry.registerComponent('securitySchemes', Authentication.STRATEGY_JWT, {\n type: 'http',\n scheme: 'bearer',\n bearerFormat: 'JWT',\n });\n\n rootRouter.openAPIRegistry.registerComponent('securitySchemes', Authentication.STRATEGY_BASIC, {\n type: 'http',\n scheme: 'basic',\n });\n\n rootRouter.openAPIRegistry.registerComponent(\n 'securitySchemes',\n Authentication.STRATEGY_SERVICE,\n { type: 'apiKey', in: 'header', name: ServiceAssertion.HEADER },\n );\n\n const securitySchemes = boundOptions?.securitySchemes ?? {};\n const securitySchemesEntries = Object.entries(securitySchemes);\n\n for (const [name, scheme] of securitySchemesEntries) {\n rootRouter.openAPIRegistry.registerComponent('securitySchemes', name, scheme as AnyType);\n }\n }\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  import type { IGetProviderParams, IUIProvider } from '../common/index.js';
2
2
  import { MemoryStorageHelper } from '@venizia/ignis-helpers';
3
+ /** Process-wide registry of UI providers by type; obtain it with `getInstance()`. `register` creates the built-in `swagger` and `scalar` providers and throws for any other type. */
3
4
  export declare class UIProviderFactory extends MemoryStorageHelper<{
4
5
  [key: string | symbol]: IUIProvider;
5
6
  }> {
@@ -3,6 +3,7 @@ import { getError } from '@venizia/ignis-helpers/core';
3
3
  import { MemoryStorageHelper } from '@venizia/ignis-helpers';
4
4
  import { ScalarUIProvider } from './scalar.js';
5
5
  import { SwaggerUIProvider } from './swagger.js';
6
+ /** Process-wide registry of UI providers by type; obtain it with `getInstance()`. `register` creates the built-in `swagger` and `scalar` providers and throws for any other type. */
6
7
  export class UIProviderFactory extends MemoryStorageHelper {
7
8
  static getInstance() {
8
9
  if (!UIProviderFactory.instance) {
@@ -1 +1 @@
1
- {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../../../src/components/api-reference/ui/factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,i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C,OAAO;YACT,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACR,MAAM,QAAQ,CAAC;oBACb,OAAO,EAAE,iDAAiD,IAAI,CAAC,IAAI,cAAc,CAAC,GAAG,eAAe,CAAC,UAAU,CAAC,EAAE;iBACnH,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,sBAAsB;QACpB,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;CACF","sourcesContent":["import type { IGetProviderParams, IUIProvider } from '../common';\nimport { DocumentUITypes } from '../common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { MemoryStorageHelper } from '@venizia/ignis-helpers';\nimport { ScalarUIProvider } from './scalar';\nimport { SwaggerUIProvider } from './swagger';\n\nexport class UIProviderFactory extends MemoryStorageHelper<{\n [key: string | symbol]: IUIProvider;\n}> {\n private static instance: UIProviderFactory;\n\n static getInstance() {\n if (!UIProviderFactory.instance) {\n UIProviderFactory.instance = new UIProviderFactory();\n }\n\n return UIProviderFactory.instance;\n }\n\n // One lookup, not a `isBound` probe followed by a second `get` of the same key.\n getProvider({ type }: IGetProviderParams): IUIProvider {\n const provider = this.get(type);\n\n if (!provider) {\n throw getError({\n message: `[UIProviderFactory][getProvider] Unknown UI Provider | type: ${type} | available: ${this.keys().join(', ')}`,\n });\n }\n\n return provider;\n }\n\n register(opts: { type: string }): void {\n if (this.isBound(opts.type)) {\n this.logger\n .for(this.register.name)\n .warn('Skip registering BOUNDED Document UI | type: %s', opts.type);\n\n return;\n }\n\n switch (opts.type) {\n case DocumentUITypes.SWAGGER: {\n this.set(opts.type, new SwaggerUIProvider());\n\n return;\n }\n case DocumentUITypes.SCALAR: {\n this.set(opts.type, new ScalarUIProvider());\n\n return;\n }\n default: {\n throw getError({\n message: `[register] Invalid document UI Type | uiType: ${opts.type} | valids: ${[...DocumentUITypes.SCHEME_SET]}`,\n });\n }\n }\n }\n\n getRegisteredProviders() {\n return this.keys();\n }\n}\n"]}
1
+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AAE,CAAC;YAClB,KAAK,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC;gBAC7B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,iBAAiB,EAAE,CAAC,CAAC;gBAE7C,OAAO;YACT,CAAC;YACD,KAAK,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC5B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,gBAAgB,EAAE,CAAC,CAAC;gBAE5C,OAAO;YACT,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACR,MAAM,QAAQ,CAAC;oBACb,OAAO,EAAE,iDAAiD,IAAI,CAAC,IAAI,cAAc,CAAC,GAAG,eAAe,CAAC,UAAU,CAAC,EAAE;iBACnH,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,sBAAsB;QACpB,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;CACF","sourcesContent":["import type { IGetProviderParams, IUIProvider } from '../common';\nimport { DocumentUITypes } from '../common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { MemoryStorageHelper } from '@venizia/ignis-helpers';\nimport { ScalarUIProvider } from './scalar';\nimport { SwaggerUIProvider } from './swagger';\n\n/** Process-wide registry of UI providers by type; obtain it with `getInstance()`. `register` creates the built-in `swagger` and `scalar` providers and throws for any other type. */\nexport class UIProviderFactory extends MemoryStorageHelper<{\n [key: string | symbol]: IUIProvider;\n}> {\n private static instance: UIProviderFactory;\n\n static getInstance() {\n if (!UIProviderFactory.instance) {\n UIProviderFactory.instance = new UIProviderFactory();\n }\n\n return UIProviderFactory.instance;\n }\n\n // One lookup, not a `isBound` probe followed by a second `get` of the same key.\n getProvider({ type }: IGetProviderParams): IUIProvider {\n const provider = this.get(type);\n\n if (!provider) {\n throw getError({\n message: `[UIProviderFactory][getProvider] Unknown UI Provider | type: ${type} | available: ${this.keys().join(', ')}`,\n });\n }\n\n return provider;\n }\n\n register(opts: { type: string }): void {\n if (this.isBound(opts.type)) {\n this.logger\n .for(this.register.name)\n .warn('Skip registering BOUNDED Document UI | type: %s', opts.type);\n\n return;\n }\n\n switch (opts.type) {\n case DocumentUITypes.SWAGGER: {\n this.set(opts.type, new SwaggerUIProvider());\n\n return;\n }\n case DocumentUITypes.SCALAR: {\n this.set(opts.type, new ScalarUIProvider());\n\n return;\n }\n default: {\n throw getError({\n message: `[register] Invalid document UI Type | uiType: ${opts.type} | valids: ${[...DocumentUITypes.SCHEME_SET]}`,\n });\n }\n }\n }\n\n getRegisteredProviders() {\n return this.keys();\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import type { Context, Next } from 'hono';
2
2
  import type { IUIConfig, IUIProvider } from '../common/index.js';
3
3
  import { BaseHelper } from '@venizia/ignis-helpers/core';
4
+ /** Renders the Scalar UI. Needs the optional `@scalar/hono-api-reference` package, and throws on render when it is not installed. */
4
5
  export declare class ScalarUIProvider extends BaseHelper implements IUIProvider {
5
6
  constructor();
6
7
  render(context: Context, config: IUIConfig, next: Next): Promise<Response | void>;
@@ -1,4 +1,5 @@
1
1
  import { BaseHelper, getError } from '@venizia/ignis-helpers/core';
2
+ /** Renders the Scalar UI. Needs the optional `@scalar/hono-api-reference` package, and throws on render when it is not installed. */
2
3
  export class ScalarUIProvider extends BaseHelper {
3
4
  constructor() {
4
5
  super({ scope: ScalarUIProvider.name });
@@ -1 +1 @@
1
- {"version":3,"file":"scalar.js","sourceRoot":"","sources":["../../../../../src/components/api-reference/ui/scalar.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEnE,MAAM,OAAO,gBAAiB,SAAQ,UAAU;IAC9C;QACE,KAAK,CAAC,EAAE,KAAK,EAAE,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAgB,EAAE,MAAiB,EAAE,IAAU;QAC1D,IAAI,YAAyD,CAAC;QAE9D,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,4BAA4B,CAAC,CAAC;YAC1D,YAAY,GAAG,MAAM,CAAC;QACxB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM;iBACR,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;iBACrB,KAAK,CAAC,yDAAyD,EAAE,KAAK,CAAC,CAAC;YAE3E,MAAM,QAAQ,CAAC;gBACb,OAAO,EACL,gHAAgH;aACnH,CAAC,CAAC;QACL,CAAC;QAED,MAAM,EAAE,MAAM,EAAE,GAAG,YAAY,CAAC;QAChC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,YAAY,EAAE,GAAG,MAAM,CAAC;QAE/C,OAAO,MAAM,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,YAAY,EAAE,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC3E,CAAC;CACF","sourcesContent":["import type { Context, Next } from 'hono';\nimport type { IUIConfig, IUIProvider } from '../common';\nimport { BaseHelper, getError } from '@venizia/ignis-helpers/core';\n\nexport class ScalarUIProvider extends BaseHelper implements IUIProvider {\n constructor() {\n super({ scope: ScalarUIProvider.name });\n }\n\n async render(context: Context, config: IUIConfig, next: Next): Promise<Response | void> {\n let scalarModule: typeof import('@scalar/hono-api-reference');\n\n try {\n const result = await import('@scalar/hono-api-reference');\n scalarModule = result;\n } catch (error) {\n this.logger\n .for(this.render.name)\n .error(\"Failed to load '@scalar/hono-api-reference' | Error: %s\", error);\n\n throw getError({\n message:\n \"[ScalarUIProvider][render] '@scalar/hono-api-reference' is required to render the Scalar UI. Please install it\",\n });\n }\n\n const { Scalar } = scalarModule;\n const { title, url, ...customConfig } = config;\n\n return Scalar({ url, pageTitle: title, ...customConfig })(context, next);\n }\n}\n"]}
1
+ {"version":3,"file":"scalar.js","sourceRoot":"","sources":["../../../../../src/components/api-reference/ui/scalar.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEnE,qIAAqI;AACrI,MAAM,OAAO,gBAAiB,SAAQ,UAAU;IAC9C;QACE,KAAK,CAAC,EAAE,KAAK,EAAE,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAgB,EAAE,MAAiB,EAAE,IAAU;QAC1D,IAAI,YAAyD,CAAC;QAE9D,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,4BAA4B,CAAC,CAAC;YAC1D,YAAY,GAAG,MAAM,CAAC;QACxB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM;iBACR,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;iBACrB,KAAK,CAAC,yDAAyD,EAAE,KAAK,CAAC,CAAC;YAE3E,MAAM,QAAQ,CAAC;gBACb,OAAO,EACL,gHAAgH;aACnH,CAAC,CAAC;QACL,CAAC;QAED,MAAM,EAAE,MAAM,EAAE,GAAG,YAAY,CAAC;QAChC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,YAAY,EAAE,GAAG,MAAM,CAAC;QAE/C,OAAO,MAAM,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,YAAY,EAAE,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC3E,CAAC;CACF","sourcesContent":["import type { Context, Next } from 'hono';\nimport type { IUIConfig, IUIProvider } from '../common';\nimport { BaseHelper, getError } from '@venizia/ignis-helpers/core';\n\n/** Renders the Scalar UI. Needs the optional `@scalar/hono-api-reference` package, and throws on render when it is not installed. */\nexport class ScalarUIProvider extends BaseHelper implements IUIProvider {\n constructor() {\n super({ scope: ScalarUIProvider.name });\n }\n\n async render(context: Context, config: IUIConfig, next: Next): Promise<Response | void> {\n let scalarModule: typeof import('@scalar/hono-api-reference');\n\n try {\n const result = await import('@scalar/hono-api-reference');\n scalarModule = result;\n } catch (error) {\n this.logger\n .for(this.render.name)\n .error(\"Failed to load '@scalar/hono-api-reference' | Error: %s\", error);\n\n throw getError({\n message:\n \"[ScalarUIProvider][render] '@scalar/hono-api-reference' is required to render the Scalar UI. Please install it\",\n });\n }\n\n const { Scalar } = scalarModule;\n const { title, url, ...customConfig } = config;\n\n return Scalar({ url, pageTitle: title, ...customConfig })(context, next);\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import type { Context, Next } from 'hono';
2
2
  import type { IUIConfig, IUIProvider } from '../common/index.js';
3
3
  import { BaseHelper } from '@venizia/ignis-helpers/core';
4
+ /** Renders the Swagger UI. Needs the optional `@hono/swagger-ui` package, and throws on render when it is not installed. */
4
5
  export declare class SwaggerUIProvider extends BaseHelper implements IUIProvider {
5
6
  constructor();
6
7
  render(context: Context, config: IUIConfig, next: Next): Promise<Response | void>;
@@ -1,4 +1,5 @@
1
1
  import { BaseHelper, getError } from '@venizia/ignis-helpers/core';
2
+ /** Renders the Swagger UI. Needs the optional `@hono/swagger-ui` package, and throws on render when it is not installed. */
2
3
  export class SwaggerUIProvider extends BaseHelper {
3
4
  constructor() {
4
5
  super({ scope: SwaggerUIProvider.name });
@@ -1 +1 @@
1
- {"version":3,"file":"swagger.js","sourceRoot":"","sources":["../../../../../src/components/api-reference/ui/swagger.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEnE,MAAM,OAAO,iBAAkB,SAAQ,UAAU;IAC/C;QACE,KAAK,CAAC,EAAE,KAAK,EAAE,iBAAiB,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAgB,EAAE,MAAiB,EAAE,IAAU;QAC1D,IAAI,aAAgD,CAAC;QAErD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;YAChD,aAAa,GAAG,MAAM,CAAC;QACzB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM;iBACR,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;iBACrB,KAAK,CAAC,+CAA+C,EAAE,KAAK,CAAC,CAAC;YAEjE,MAAM,QAAQ,CAAC;gBACb,OAAO,EACL,wGAAwG;aAC3G,CAAC,CAAC;QACL,CAAC;QAED,MAAM,EAAE,SAAS,EAAE,GAAG,aAAa,CAAC;QACpC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,YAAY,EAAE,GAAG,MAAM,CAAC;QAE/C,OAAO,SAAS,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,YAAY,EAAE,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACnE,CAAC;CACF","sourcesContent":["import type { Context, Next } from 'hono';\nimport type { IUIConfig, IUIProvider } from '../common';\nimport { BaseHelper, getError } from '@venizia/ignis-helpers/core';\n\nexport class SwaggerUIProvider extends BaseHelper implements IUIProvider {\n constructor() {\n super({ scope: SwaggerUIProvider.name });\n }\n\n async render(context: Context, config: IUIConfig, next: Next): Promise<Response | void> {\n let swaggerModule: typeof import('@hono/swagger-ui');\n\n try {\n const result = await import('@hono/swagger-ui');\n swaggerModule = result;\n } catch (error) {\n this.logger\n .for(this.render.name)\n .error(\"Failed to load '@hono/swagger-ui' | Error: %s\", error);\n\n throw getError({\n message:\n \"[SwaggerUIProvider][render] '@hono/swagger-ui' is required to render the Swagger UI. Please install it\",\n });\n }\n\n const { swaggerUI } = swaggerModule;\n const { title, url, ...customConfig } = config;\n\n return swaggerUI({ title, url, ...customConfig })(context, next);\n }\n}\n"]}
1
+ {"version":3,"file":"swagger.js","sourceRoot":"","sources":["../../../../../src/components/api-reference/ui/swagger.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEnE,4HAA4H;AAC5H,MAAM,OAAO,iBAAkB,SAAQ,UAAU;IAC/C;QACE,KAAK,CAAC,EAAE,KAAK,EAAE,iBAAiB,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAgB,EAAE,MAAiB,EAAE,IAAU;QAC1D,IAAI,aAAgD,CAAC;QAErD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;YAChD,aAAa,GAAG,MAAM,CAAC;QACzB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM;iBACR,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;iBACrB,KAAK,CAAC,+CAA+C,EAAE,KAAK,CAAC,CAAC;YAEjE,MAAM,QAAQ,CAAC;gBACb,OAAO,EACL,wGAAwG;aAC3G,CAAC,CAAC;QACL,CAAC;QAED,MAAM,EAAE,SAAS,EAAE,GAAG,aAAa,CAAC;QACpC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,YAAY,EAAE,GAAG,MAAM,CAAC;QAE/C,OAAO,SAAS,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,YAAY,EAAE,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACnE,CAAC;CACF","sourcesContent":["import type { Context, Next } from 'hono';\nimport type { IUIConfig, IUIProvider } from '../common';\nimport { BaseHelper, getError } from '@venizia/ignis-helpers/core';\n\n/** Renders the Swagger UI. Needs the optional `@hono/swagger-ui` package, and throws on render when it is not installed. */\nexport class SwaggerUIProvider extends BaseHelper implements IUIProvider {\n constructor() {\n super({ scope: SwaggerUIProvider.name });\n }\n\n async render(context: Context, config: IUIConfig, next: Next): Promise<Response | void> {\n let swaggerModule: typeof import('@hono/swagger-ui');\n\n try {\n const result = await import('@hono/swagger-ui');\n swaggerModule = result;\n } catch (error) {\n this.logger\n .for(this.render.name)\n .error(\"Failed to load '@hono/swagger-ui' | Error: %s\", error);\n\n throw getError({\n message:\n \"[SwaggerUIProvider][render] '@hono/swagger-ui' is required to render the Swagger UI. Please install it\",\n });\n }\n\n const { swaggerUI } = swaggerModule;\n const { title, url, ...customConfig } = config;\n\n return swaggerUI({ title, url, ...customConfig })(context, next);\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import type { BaseApplication } from '../../../base/applications/base.js';
2
2
  import { type ValueOrPromise } from '@venizia/ignis-helpers/common';
3
3
  import { BaseComponent } from '@venizia/ignis-kernel';
4
+ /** Registers the authentication services and strategies from the options bound under `AuthenticateBindingKeys`. Throws at binding time unless JWT, basic or service options are provided. */
4
5
  export declare class AuthenticateComponent extends BaseComponent {
5
6
  private application;
6
7
  constructor(application: BaseApplication);
@@ -16,12 +16,14 @@ import { Binding } from '@venizia/ignis-inversion';
16
16
  import { AuthenticateBindingKeys, Authentication, AuthenticationStrategyRegistry, BaseComponent, controller, CoreBindings, inject, JOSEStandards, JWKSKeyFormats, JWKSModes, ServiceAssertion, } from '@venizia/ignis-kernel';
17
17
  import { AuthControllerFactory, JWKSController } from './controllers/index.js';
18
18
  import { ServiceCertsController } from './controllers/service-certs/index.js';
19
- import { BasicTokenService, JWKSIssuerTokenService, JWKSVerifierTokenService, JWSTokenService, } from './services/index.js';
19
+ import { AbstractBearerTokenService, BasicTokenService, JWKSIssuerTokenService, JWKSVerifierTokenService, JWSTokenService, } from './services/index.js';
20
20
  import { JoseLoader } from './services/jose-loader.js';
21
+ import { JWKSUrlPolicy } from './services/jwks-url-policy.js';
21
22
  import { ServiceAssertionSignerService } from './services/service/signer.service.js';
22
23
  import { ServiceAssertionVerifierService } from './services/service/verifier.service.js';
23
24
  import { ServiceAuthenticationStrategy } from './strategies/service.strategy.js';
24
25
  const DEFAULT_SECRET = 'unknown_secret';
26
+ /** Registers the authentication services and strategies from the options bound under `AuthenticateBindingKeys`. Throws at binding time unless JWT, basic or service options are provided. */
25
27
  let AuthenticateComponent = AuthenticateComponent_1 = class AuthenticateComponent extends BaseComponent {
26
28
  constructor(application) {
27
29
  super({
@@ -117,6 +119,13 @@ let AuthenticateComponent = AuthenticateComponent_1 = class AuthenticateComponen
117
119
  message: '[defineJWSAuth] getTokenExpiresFn is required',
118
120
  });
119
121
  }
122
+ // The boot refuses a configuration without claims, and a service refuses the same when built.
123
+ AbstractBearerTokenService.resolveClaimsConfig({
124
+ scope: 'defineJWSAuth',
125
+ options: jwsOptions,
126
+ pinnedAlgorithms: [jwsOptions.headerAlgorithm ?? 'HS256'],
127
+ });
128
+ JWSTokenService.assertSecretStrength({ scope: 'defineJWSAuth', secret: jwtSecret });
120
129
  this.application
121
130
  .bind({ key: AuthenticateBindingKeys.JWT_OPTIONS })
122
131
  .toValue(jwsOptions);
@@ -146,6 +155,11 @@ let AuthenticateComponent = AuthenticateComponent_1 = class AuthenticateComponen
146
155
  message: '[defineJWKSAuth] getTokenExpiresFn is required for issuer mode',
147
156
  });
148
157
  }
158
+ AbstractBearerTokenService.resolveClaimsConfig({
159
+ scope: 'defineJWKSAuth',
160
+ options: issuerOpts,
161
+ pinnedAlgorithms: [issuerOpts.algorithm],
162
+ });
149
163
  this.application
150
164
  .bind({ key: AuthenticateBindingKeys.JWKS_OPTIONS })
151
165
  .toValue(issuerOpts);
@@ -163,6 +177,16 @@ let AuthenticateComponent = AuthenticateComponent_1 = class AuthenticateComponen
163
177
  if (!verifierOpts.jwksUrl) {
164
178
  throw getError({ message: '[defineJWKSAuth] jwksUrl is required for verifier mode' });
165
179
  }
180
+ AbstractBearerTokenService.resolveClaimsConfig({
181
+ scope: 'defineJWKSAuth',
182
+ options: verifierOpts,
183
+ });
184
+ JWKSUrlPolicy.assertUrl({
185
+ scope: 'defineJWKSAuth',
186
+ label: 'jwksUrl',
187
+ url: verifierOpts.jwksUrl,
188
+ hosts: verifierOpts.jwks?.hosts?.http,
189
+ });
166
190
  this.application
167
191
  .bind({ key: AuthenticateBindingKeys.JWKS_OPTIONS })
168
192
  .toValue(verifierOpts);
@@ -204,6 +228,19 @@ let AuthenticateComponent = AuthenticateComponent_1 = class AuthenticateComponen
204
228
  message: '[defineServiceAuth] resolvePrincipal is required | the framework proves WHICH SERVICE called, the application decides who that acts as',
205
229
  });
206
230
  }
231
+ // A caller's key set decides who may call: https, loopback, or a host listed in jwks.hosts.http. Checked at boot, so a bad URL never waits for its first request.
232
+ JWKSUrlPolicy.resolveHttpHosts({
233
+ scope: 'defineServiceAuth',
234
+ hosts: serviceOptions.jwks?.hosts?.http,
235
+ });
236
+ for (const [caller, entry] of Object.entries(serviceOptions.callers ?? {})) {
237
+ JWKSUrlPolicy.assertUrl({
238
+ scope: 'defineServiceAuth',
239
+ label: `callers[${JSON.stringify(caller)}].jwksUrl`,
240
+ url: typeof entry === 'string' ? entry : entry.jwksUrl,
241
+ hosts: serviceOptions.jwks?.hosts?.http,
242
+ });
243
+ }
207
244
  this.application.service(ServiceAssertionVerifierService);
208
245
  if (serviceOptions.keys) {
209
246
  this.application.service(ServiceAssertionSignerService);
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../../src/components/auth/authenticate/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,8BAA8B,EAC9B,aAAa,EACb,UAAU,EACV,YAAY,EAKZ,MAAM,EAEN,aAAa,EACb,cAAc,EACd,SAAS,EACT,gBAAgB,GAKjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO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,GAAG,IAAI,CAAC,OAAO,CAAC;QAEjD,IAAI,CAAC,WAAW,EAAE,iBAAiB,EAAE,CAAC;YACpC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;YAE/E,OAAO;QACT,CAAC;QAED,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,0EAA0E;aACpF,CAAC,CAAC;QACL,CAAC;QAED,MAAM,cAAc,GAAG,qBAAqB,CAAC,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;QAChF,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;QAE5C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;IAClF,CAAC;IAED,YAAY;QACV,wBAAwB;IAC1B,CAAC;CACF,CAAA;AAnTY,qBAAqB;IAE7B,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAA;;GAF1C,qBAAqB,CAmTjC","sourcesContent":["import type { BaseApplication } from '@/base/applications/base';\nimport { type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { Binding } from '@venizia/ignis-inversion';\nimport {\n AuthenticateBindingKeys,\n Authentication,\n AuthenticationStrategyRegistry,\n BaseComponent,\n controller,\n CoreBindings,\n type IAuthenticateOptions,\n type IJWKSIssuerOptions,\n type IJWKSVerifierOptions,\n type IJWSTokenServiceOptions,\n inject,\n type IServiceAuthOptions,\n JOSEStandards,\n JWKSKeyFormats,\n JWKSModes,\n ServiceAssertion,\n type TAuthenticationRestOptions,\n type TBasicTokenServiceOptions,\n type TJWKSTokenServiceOptions,\n type TJWTTokenServiceOptions,\n} from '@venizia/ignis-kernel';\nimport { AuthControllerFactory, JWKSController } from './controllers';\nimport { ServiceCertsController } from './controllers/service-certs';\nimport {\n BasicTokenService,\n JWKSIssuerTokenService,\n JWKSVerifierTokenService,\n JWSTokenService,\n} from './services';\nimport { JoseLoader } from './services/jose-loader';\nimport { ServiceAssertionSignerService } from './services/service/signer.service';\nimport { ServiceAssertionVerifierService } from './services/service/verifier.service';\nimport { ServiceAuthenticationStrategy } from './strategies/service.strategy';\n\nconst DEFAULT_SECRET = 'unknown_secret';\n\nexport class AuthenticateComponent extends BaseComponent {\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: AuthenticateComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [AuthenticateBindingKeys.REST_OPTIONS]: Binding.bind<TAuthenticationRestOptions>({\n key: AuthenticateBindingKeys.REST_OPTIONS,\n }).toValue({ useAuthController: false }),\n },\n });\n }\n\n override binding(): ValueOrPromise<void> {\n const jwtOptions = this.application.get<TJWTTokenServiceOptions>({\n key: AuthenticateBindingKeys.JWT_OPTIONS,\n isOptional: true,\n });\n const basicOptions = this.application.get<TBasicTokenServiceOptions>({\n key: AuthenticateBindingKeys.BASIC_OPTIONS,\n isOptional: true,\n });\n const restOptions = this.application.get<TAuthenticationRestOptions>({\n key: AuthenticateBindingKeys.REST_OPTIONS,\n isOptional: true,\n });\n const serviceOptions = this.application.get<IServiceAuthOptions>({\n key: AuthenticateBindingKeys.SERVICE_OPTIONS,\n isOptional: true,\n });\n\n // A service that only VERIFIES assertions needs neither jwt nor basic - and that application,\n // an IGNIS app consuming no user tokens at all, is exactly what the service strategy is for.\n if (!jwtOptions && !basicOptions && !serviceOptions) {\n throw getError({\n message:\n '[AuthenticateComponent] At least one of jwtOptions, basicOptions or serviceOptions must be provided',\n });\n }\n\n const options: IAuthenticateOptions = { restOptions, jwtOptions, basicOptions, serviceOptions };\n\n if (jwtOptions) {\n switch (jwtOptions.standard) {\n case JOSEStandards.JWS: {\n this.defineJWSAuth({ options: jwtOptions.options });\n break;\n }\n case JOSEStandards.JWKS: {\n this.defineJWKSAuth({ options: jwtOptions.options });\n break;\n }\n default: {\n throw getError({\n message: `[AuthenticateComponent] Unknown JOSE standard: ${(jwtOptions as any).standard}`,\n });\n }\n }\n }\n\n this.defineBasicAuth({ basicOptions });\n this.defineServiceAuth({ serviceOptions });\n\n this.defineControllers({ options });\n\n this.defineOAuth2();\n\n return this.preloadJose({ options });\n }\n\n /**\n * Loads `jose` at boot when a configured service signs or verifies with it, so a missing or broken\n * install fails the boot instead of answering every token check with a 401.\n */\n private async preloadJose(opts: { options: IAuthenticateOptions }): Promise<void> {\n const { jwtOptions, serviceOptions } = opts.options;\n\n if (!jwtOptions && !serviceOptions) {\n return;\n }\n\n try {\n await JoseLoader.load();\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n this.logger.for(this.preloadJose.name).error(\"Failed to load 'jose' | Error: %s\", reason);\n\n throw getError({\n message: `[AuthenticateComponent] Cannot load 'jose', which JWT and service authentication need. Please install it | Error: ${reason}`,\n cause: error,\n });\n }\n }\n\n private defineJWSAuth(opts: { options: IJWSTokenServiceOptions }): void {\n const { options: jwsOptions } = opts;\n\n const { jwtSecret, getTokenExpiresFn } = jwsOptions;\n\n if (!jwtSecret || jwtSecret === DEFAULT_SECRET) {\n throw getError({\n message: `[defineJWSAuth] Invalid jwtSecret | Provided: ${jwtSecret}`,\n });\n }\n\n if (!getTokenExpiresFn) {\n throw getError({\n message: '[defineJWSAuth] getTokenExpiresFn is required',\n });\n }\n\n this.application\n .bind<IJWSTokenServiceOptions>({ key: AuthenticateBindingKeys.JWT_OPTIONS })\n .toValue(jwsOptions);\n this.application.service(JWSTokenService);\n\n this.logger.for(this.defineJWSAuth.name).info('JWS authentication configured');\n }\n\n private defineJWKSAuth(opts: { options: TJWKSTokenServiceOptions }): void {\n const { options: jwksOptions } = opts;\n\n switch (jwksOptions.mode) {\n case JWKSModes.ISSUER: {\n const issuerOpts = jwksOptions;\n\n if (!issuerOpts.keys?.private || !issuerOpts.keys?.public) {\n throw getError({\n message: '[defineJWKSAuth] keys.private and keys.public are required for issuer mode',\n });\n }\n\n if (!issuerOpts.keys?.format || !JWKSKeyFormats.isValid(issuerOpts.keys.format)) {\n throw getError({\n message: `[defineJWKSAuth] keys.format is required and must be one of: ${[...JWKSKeyFormats.SCHEME_SET].join(', ')}`,\n });\n }\n\n if (!issuerOpts.kid) {\n throw getError({ message: '[defineJWKSAuth] kid is required for issuer mode' });\n }\n\n if (!issuerOpts.getTokenExpiresFn) {\n throw getError({\n message: '[defineJWKSAuth] getTokenExpiresFn is required for issuer mode',\n });\n }\n\n this.application\n .bind<IJWKSIssuerOptions>({ key: AuthenticateBindingKeys.JWKS_OPTIONS })\n .toValue(issuerOpts);\n this.application.service(JWKSIssuerTokenService);\n\n // Path depends on a runtime option, so @controller can't be applied statically — decorate here instead.\n Reflect.decorate(\n [controller({ path: issuerOpts?.rest?.path ?? '/certs' })],\n JWKSController,\n );\n this.application.controller(JWKSController);\n\n this.logger\n .for(this.defineJWKSAuth.name)\n .info('JWKS issuer configured with /certs endpoint');\n break;\n }\n\n case JWKSModes.VERIFIER: {\n const verifierOpts = jwksOptions;\n\n if (!verifierOpts.jwksUrl) {\n throw getError({ message: '[defineJWKSAuth] jwksUrl is required for verifier mode' });\n }\n\n this.application\n .bind<IJWKSVerifierOptions>({ key: AuthenticateBindingKeys.JWKS_OPTIONS })\n .toValue(verifierOpts);\n this.application.service(JWKSVerifierTokenService);\n\n this.logger.for(this.defineJWKSAuth.name).info('JWKS verifier configured');\n break;\n }\n\n default: {\n // Same exhaustive-switch-narrows-to-never situation as the JOSE standard default above.\n throw getError({\n message: `[defineJWKSAuth] Invalid JWKS mode: ${(jwksOptions as { mode?: unknown }).mode}`,\n });\n }\n }\n }\n\n /**\n * Service-to-service authentication. Absent options mean no strategy is registered and no route is\n * mounted, so an application that never sets them is byte-identical to today.\n *\n * The certs route is mounted only when SIGNING keys are present. Most services are called and\n * never call; publishing a key set for a service that signs nothing advertises a capability it\n * does not have.\n */\n private defineServiceAuth(opts: { serviceOptions?: IServiceAuthOptions }): void {\n const { serviceOptions } = opts;\n\n if (!serviceOptions) {\n this.logger\n .for(this.defineServiceAuth.name)\n .debug('serviceOptions not provided, skipping service authentication');\n\n return;\n }\n\n if (!serviceOptions.name) {\n throw getError({\n message:\n '[defineServiceAuth] name is required | it is the issuer this service stamps and the audience it demands',\n });\n }\n\n if (!serviceOptions.resolvePrincipal) {\n throw getError({\n message:\n '[defineServiceAuth] resolvePrincipal is required | the framework proves WHICH SERVICE called, the application decides who that acts as',\n });\n }\n\n this.application.service(ServiceAssertionVerifierService);\n\n if (serviceOptions.keys) {\n this.application.service(ServiceAssertionSignerService);\n\n const restPath = serviceOptions.rest?.path ?? ServiceAssertion.DEFAULT_REST_PATH;\n this.application\n .bind<string>({ key: AuthenticateBindingKeys.SERVICE_CERTS_PATH })\n .toValue(restPath);\n\n // Path depends on a runtime option, so @controller cannot be applied statically.\n Reflect.decorate([controller({ path: restPath })], ServiceCertsController);\n this.application.controller(ServiceCertsController);\n }\n\n AuthenticationStrategyRegistry.getInstance().register({\n container: this.application,\n strategies: [\n { name: Authentication.STRATEGY_SERVICE, strategy: ServiceAuthenticationStrategy },\n ],\n });\n\n this.logger\n .for(this.defineServiceAuth.name)\n .info(\n 'Service authentication configured | name: %s | signs: %s | callers: %s',\n serviceOptions.name,\n Boolean(serviceOptions.keys),\n Object.keys(serviceOptions.callers ?? {}).join(', ') || 'none',\n );\n }\n\n private defineBasicAuth(opts: { basicOptions?: TBasicTokenServiceOptions }): void {\n const { basicOptions } = opts;\n\n if (!basicOptions) {\n this.logger\n .for(this.defineBasicAuth.name)\n .debug('basicOptions not provided, skipping Basic configuration');\n\n return;\n }\n\n if (!basicOptions.verifyCredentials) {\n throw getError({\n message: '[defineBasicAuth] verifyCredentials function is required',\n });\n }\n\n this.application\n .bind<TBasicTokenServiceOptions>({ key: AuthenticateBindingKeys.BASIC_OPTIONS })\n .toValue(basicOptions);\n this.application.service(BasicTokenService);\n\n this.logger.for(this.defineBasicAuth.name).info('Basic authentication configured');\n }\n\n private defineControllers(opts: { options: IAuthenticateOptions }): void {\n const { restOptions, jwtOptions } = opts.options;\n\n if (!restOptions?.useAuthController) {\n this.logger.for(this.defineControllers.name).debug('Auth controller disabled');\n\n return;\n }\n\n if (!jwtOptions) {\n throw getError({\n message: '[defineControllers] Auth controller requires jwtOptions to be configured',\n });\n }\n\n const AuthController = AuthControllerFactory.define(restOptions.controllerOpts);\n this.application.controller(AuthController);\n\n this.logger.for(this.defineControllers.name).info('Auth controller registered');\n }\n\n defineOAuth2() {\n // TODO Implement OAuth2\n }\n}\n"]}
1
+ {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../../src/components/auth/authenticate/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,8BAA8B,EAC9B,aAAa,EACb,UAAU,EACV,YAAY,EAKZ,MAAM,EAEN,aAAa,EACb,cAAc,EACd,SAAS,EACT,gBAAgB,GAKjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,0BAA0B,EAC1B,iBAAiB,EACjB,sBAAsB,EACtB,wBAAwB,EACxB,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAE,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,iBAAiB,EAAE,CAAC;YACpC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;YAE/E,OAAO;QACT,CAAC;QAED,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,0EAA0E;aACpF,CAAC,CAAC;QACL,CAAC;QAED,MAAM,cAAc,GAAG,qBAAqB,CAAC,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;QAChF,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;QAE5C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;IAClF,CAAC;IAED,YAAY;QACV,wBAAwB;IAC1B,CAAC;CACF,CAAA;AA7VY,qBAAqB;IAE7B,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAA;;GAF1C,qBAAqB,CA6VjC","sourcesContent":["import type { BaseApplication } from '@/base/applications/base';\nimport { type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { Binding } from '@venizia/ignis-inversion';\nimport {\n AuthenticateBindingKeys,\n Authentication,\n AuthenticationStrategyRegistry,\n BaseComponent,\n controller,\n CoreBindings,\n type IAuthenticateOptions,\n type IJWKSIssuerOptions,\n type IJWKSVerifierOptions,\n type IJWSTokenServiceOptions,\n inject,\n type IServiceAuthOptions,\n JOSEStandards,\n JWKSKeyFormats,\n JWKSModes,\n ServiceAssertion,\n type TAuthenticationRestOptions,\n type TBasicTokenServiceOptions,\n type TJWKSTokenServiceOptions,\n type TJWTTokenServiceOptions,\n} from '@venizia/ignis-kernel';\nimport { AuthControllerFactory, JWKSController } from './controllers';\nimport { ServiceCertsController } from './controllers/service-certs';\nimport {\n AbstractBearerTokenService,\n BasicTokenService,\n JWKSIssuerTokenService,\n JWKSVerifierTokenService,\n JWSTokenService,\n} from './services';\nimport { JoseLoader } from './services/jose-loader';\nimport { JWKSUrlPolicy } from './services/jwks-url-policy';\nimport { ServiceAssertionSignerService } from './services/service/signer.service';\nimport { ServiceAssertionVerifierService } from './services/service/verifier.service';\nimport { ServiceAuthenticationStrategy } from './strategies/service.strategy';\n\nconst DEFAULT_SECRET = 'unknown_secret';\n\n/** Registers the authentication services and strategies from the options bound under `AuthenticateBindingKeys`. Throws at binding time unless JWT, basic or service options are provided. */\nexport class AuthenticateComponent extends BaseComponent {\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: AuthenticateComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [AuthenticateBindingKeys.REST_OPTIONS]: Binding.bind<TAuthenticationRestOptions>({\n key: AuthenticateBindingKeys.REST_OPTIONS,\n }).toValue({ useAuthController: false }),\n },\n });\n }\n\n override binding(): ValueOrPromise<void> {\n const jwtOptions = this.application.get<TJWTTokenServiceOptions>({\n key: AuthenticateBindingKeys.JWT_OPTIONS,\n isOptional: true,\n });\n const basicOptions = this.application.get<TBasicTokenServiceOptions>({\n key: AuthenticateBindingKeys.BASIC_OPTIONS,\n isOptional: true,\n });\n const restOptions = this.application.get<TAuthenticationRestOptions>({\n key: AuthenticateBindingKeys.REST_OPTIONS,\n isOptional: true,\n });\n const serviceOptions = this.application.get<IServiceAuthOptions>({\n key: AuthenticateBindingKeys.SERVICE_OPTIONS,\n isOptional: true,\n });\n\n // A service that only VERIFIES assertions needs neither jwt nor basic - and that application,\n // an IGNIS app consuming no user tokens at all, is exactly what the service strategy is for.\n if (!jwtOptions && !basicOptions && !serviceOptions) {\n throw getError({\n message:\n '[AuthenticateComponent] At least one of jwtOptions, basicOptions or serviceOptions must be provided',\n });\n }\n\n const options: IAuthenticateOptions = { restOptions, jwtOptions, basicOptions, serviceOptions };\n\n if (jwtOptions) {\n switch (jwtOptions.standard) {\n case JOSEStandards.JWS: {\n this.defineJWSAuth({ options: jwtOptions.options });\n break;\n }\n case JOSEStandards.JWKS: {\n this.defineJWKSAuth({ options: jwtOptions.options });\n break;\n }\n default: {\n throw getError({\n message: `[AuthenticateComponent] Unknown JOSE standard: ${(jwtOptions as any).standard}`,\n });\n }\n }\n }\n\n this.defineBasicAuth({ basicOptions });\n this.defineServiceAuth({ serviceOptions });\n\n this.defineControllers({ options });\n\n this.defineOAuth2();\n\n return this.preloadJose({ options });\n }\n\n /**\n * Loads `jose` at boot when a configured service signs or verifies with it, so a missing or broken\n * install fails the boot instead of answering every token check with a 401.\n */\n private async preloadJose(opts: { options: IAuthenticateOptions }): Promise<void> {\n const { jwtOptions, serviceOptions } = opts.options;\n\n if (!jwtOptions && !serviceOptions) {\n return;\n }\n\n try {\n await JoseLoader.load();\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n this.logger.for(this.preloadJose.name).error(\"Failed to load 'jose' | Error: %s\", reason);\n\n throw getError({\n message: `[AuthenticateComponent] Cannot load 'jose', which JWT and service authentication need. Please install it | Error: ${reason}`,\n cause: error,\n });\n }\n }\n\n private defineJWSAuth(opts: { options: IJWSTokenServiceOptions }): void {\n const { options: jwsOptions } = opts;\n\n const { jwtSecret, getTokenExpiresFn } = jwsOptions;\n\n if (!jwtSecret || jwtSecret === DEFAULT_SECRET) {\n throw getError({\n message: `[defineJWSAuth] Invalid jwtSecret | Provided: ${jwtSecret}`,\n });\n }\n\n if (!getTokenExpiresFn) {\n throw getError({\n message: '[defineJWSAuth] getTokenExpiresFn is required',\n });\n }\n\n // The boot refuses a configuration without claims, and a service refuses the same when built.\n AbstractBearerTokenService.resolveClaimsConfig({\n scope: 'defineJWSAuth',\n options: jwsOptions,\n pinnedAlgorithms: [jwsOptions.headerAlgorithm ?? 'HS256'],\n });\n\n JWSTokenService.assertSecretStrength({ scope: 'defineJWSAuth', secret: jwtSecret });\n\n this.application\n .bind<IJWSTokenServiceOptions>({ key: AuthenticateBindingKeys.JWT_OPTIONS })\n .toValue(jwsOptions);\n this.application.service(JWSTokenService);\n\n this.logger.for(this.defineJWSAuth.name).info('JWS authentication configured');\n }\n\n private defineJWKSAuth(opts: { options: TJWKSTokenServiceOptions }): void {\n const { options: jwksOptions } = opts;\n\n switch (jwksOptions.mode) {\n case JWKSModes.ISSUER: {\n const issuerOpts = jwksOptions;\n\n if (!issuerOpts.keys?.private || !issuerOpts.keys?.public) {\n throw getError({\n message: '[defineJWKSAuth] keys.private and keys.public are required for issuer mode',\n });\n }\n\n if (!issuerOpts.keys?.format || !JWKSKeyFormats.isValid(issuerOpts.keys.format)) {\n throw getError({\n message: `[defineJWKSAuth] keys.format is required and must be one of: ${[...JWKSKeyFormats.SCHEME_SET].join(', ')}`,\n });\n }\n\n if (!issuerOpts.kid) {\n throw getError({ message: '[defineJWKSAuth] kid is required for issuer mode' });\n }\n\n if (!issuerOpts.getTokenExpiresFn) {\n throw getError({\n message: '[defineJWKSAuth] getTokenExpiresFn is required for issuer mode',\n });\n }\n\n AbstractBearerTokenService.resolveClaimsConfig({\n scope: 'defineJWKSAuth',\n options: issuerOpts,\n pinnedAlgorithms: [issuerOpts.algorithm],\n });\n\n this.application\n .bind<IJWKSIssuerOptions>({ key: AuthenticateBindingKeys.JWKS_OPTIONS })\n .toValue(issuerOpts);\n this.application.service(JWKSIssuerTokenService);\n\n // Path depends on a runtime option, so @controller can't be applied statically — decorate here instead.\n Reflect.decorate(\n [controller({ path: issuerOpts?.rest?.path ?? '/certs' })],\n JWKSController,\n );\n this.application.controller(JWKSController);\n\n this.logger\n .for(this.defineJWKSAuth.name)\n .info('JWKS issuer configured with /certs endpoint');\n break;\n }\n\n case JWKSModes.VERIFIER: {\n const verifierOpts = jwksOptions;\n\n if (!verifierOpts.jwksUrl) {\n throw getError({ message: '[defineJWKSAuth] jwksUrl is required for verifier mode' });\n }\n\n AbstractBearerTokenService.resolveClaimsConfig({\n scope: 'defineJWKSAuth',\n options: verifierOpts,\n });\n\n JWKSUrlPolicy.assertUrl({\n scope: 'defineJWKSAuth',\n label: 'jwksUrl',\n url: verifierOpts.jwksUrl,\n hosts: verifierOpts.jwks?.hosts?.http,\n });\n\n this.application\n .bind<IJWKSVerifierOptions>({ key: AuthenticateBindingKeys.JWKS_OPTIONS })\n .toValue(verifierOpts);\n this.application.service(JWKSVerifierTokenService);\n\n this.logger.for(this.defineJWKSAuth.name).info('JWKS verifier configured');\n break;\n }\n\n default: {\n // Same exhaustive-switch-narrows-to-never situation as the JOSE standard default above.\n throw getError({\n message: `[defineJWKSAuth] Invalid JWKS mode: ${(jwksOptions as { mode?: unknown }).mode}`,\n });\n }\n }\n }\n\n /**\n * Service-to-service authentication. Absent options mean no strategy is registered and no route is\n * mounted, so an application that never sets them is byte-identical to today.\n *\n * The certs route is mounted only when SIGNING keys are present. Most services are called and\n * never call; publishing a key set for a service that signs nothing advertises a capability it\n * does not have.\n */\n private defineServiceAuth(opts: { serviceOptions?: IServiceAuthOptions }): void {\n const { serviceOptions } = opts;\n\n if (!serviceOptions) {\n this.logger\n .for(this.defineServiceAuth.name)\n .debug('serviceOptions not provided, skipping service authentication');\n\n return;\n }\n\n if (!serviceOptions.name) {\n throw getError({\n message:\n '[defineServiceAuth] name is required | it is the issuer this service stamps and the audience it demands',\n });\n }\n\n if (!serviceOptions.resolvePrincipal) {\n throw getError({\n message:\n '[defineServiceAuth] resolvePrincipal is required | the framework proves WHICH SERVICE called, the application decides who that acts as',\n });\n }\n\n // A caller's key set decides who may call: https, loopback, or a host listed in jwks.hosts.http. Checked at boot, so a bad URL never waits for its first request.\n JWKSUrlPolicy.resolveHttpHosts({\n scope: 'defineServiceAuth',\n hosts: serviceOptions.jwks?.hosts?.http,\n });\n\n for (const [caller, entry] of Object.entries(serviceOptions.callers ?? {})) {\n JWKSUrlPolicy.assertUrl({\n scope: 'defineServiceAuth',\n label: `callers[${JSON.stringify(caller)}].jwksUrl`,\n url: typeof entry === 'string' ? entry : entry.jwksUrl,\n hosts: serviceOptions.jwks?.hosts?.http,\n });\n }\n\n this.application.service(ServiceAssertionVerifierService);\n\n if (serviceOptions.keys) {\n this.application.service(ServiceAssertionSignerService);\n\n const restPath = serviceOptions.rest?.path ?? ServiceAssertion.DEFAULT_REST_PATH;\n this.application\n .bind<string>({ key: AuthenticateBindingKeys.SERVICE_CERTS_PATH })\n .toValue(restPath);\n\n // Path depends on a runtime option, so @controller cannot be applied statically.\n Reflect.decorate([controller({ path: restPath })], ServiceCertsController);\n this.application.controller(ServiceCertsController);\n }\n\n AuthenticationStrategyRegistry.getInstance().register({\n container: this.application,\n strategies: [\n { name: Authentication.STRATEGY_SERVICE, strategy: ServiceAuthenticationStrategy },\n ],\n });\n\n this.logger\n .for(this.defineServiceAuth.name)\n .info(\n 'Service authentication configured | name: %s | signs: %s | callers: %s',\n serviceOptions.name,\n Boolean(serviceOptions.keys),\n Object.keys(serviceOptions.callers ?? {}).join(', ') || 'none',\n );\n }\n\n private defineBasicAuth(opts: { basicOptions?: TBasicTokenServiceOptions }): void {\n const { basicOptions } = opts;\n\n if (!basicOptions) {\n this.logger\n .for(this.defineBasicAuth.name)\n .debug('basicOptions not provided, skipping Basic configuration');\n\n return;\n }\n\n if (!basicOptions.verifyCredentials) {\n throw getError({\n message: '[defineBasicAuth] verifyCredentials function is required',\n });\n }\n\n this.application\n .bind<TBasicTokenServiceOptions>({ key: AuthenticateBindingKeys.BASIC_OPTIONS })\n .toValue(basicOptions);\n this.application.service(BasicTokenService);\n\n this.logger.for(this.defineBasicAuth.name).info('Basic authentication configured');\n }\n\n private defineControllers(opts: { options: IAuthenticateOptions }): void {\n const { restOptions, jwtOptions } = opts.options;\n\n if (!restOptions?.useAuthController) {\n this.logger.for(this.defineControllers.name).debug('Auth controller disabled');\n\n return;\n }\n\n if (!jwtOptions) {\n throw getError({\n message: '[defineControllers] Auth controller requires jwtOptions to be configured',\n });\n }\n\n const AuthController = AuthControllerFactory.define(restOptions.controllerOpts);\n this.application.controller(AuthController);\n\n this.logger.for(this.defineControllers.name).info('Auth controller registered');\n }\n\n defineOAuth2() {\n // TODO Implement OAuth2\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { z } from '@hono/zod-openapi';
2
2
  import { type ValueOrPromise } from '@venizia/ignis-helpers/common';
3
3
  import { type IAuthService, type TDefineAuthControllerOpts } from '@venizia/ignis-kernel';
4
+ /** Zod schema of the JWT payload: `userId`, the `roles` (id, identifier, integer priority) and optional `clientId`, `provider` and `email`. */
4
5
  export declare const JWTTokenPayloadSchema: z.ZodObject<{
5
6
  userId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
6
7
  roles: z.ZodArray<z.ZodObject<{
@@ -152,6 +153,7 @@ export declare class AuthControllerFactory {
152
153
  }): RouteConfig & {
153
154
  getRoutingPath(): RouteConfig["path"] extends infer T ? T extends RouteConfig["path"] ? T extends `${infer Start}/{${infer Param}}${infer Rest}` ? `${Start}/:${Param}${Rest extends `${infer Start_1}/{${infer Param_1}}${infer Rest_1}` ? `${Start_1}/:${Param_1}${Rest_1 extends `${infer Start_2}/{${infer Param_2}}${infer Rest_2}` ? `${Start_2}/:${Param_2}${Rest_2 extends `${infer Start_3}/{${infer Param_3}}${infer Rest_3}` ? `${Start_3}/:${Param_3}${Rest_3 extends `${infer Start_4}/{${infer Param_4}}${infer Rest_4}` ? `${Start_4}/:${Param_4}${Rest_4 extends `${infer Start_5}/{${infer Param_5}}${infer Rest_5}` ? `${Start_5}/:${Param_5}${Rest_5 extends `${infer Start_6}/{${infer Param_6}}${infer Rest_6}` ? `${Start_6}/:${Param_6}${Rest_6 extends `${infer Start_7}/{${infer Param_7}}${infer Rest_7}` ? `${Start_7}/:${Param_7}${Rest_7 extends `${infer Start_8}/{${infer Param_8}}${infer Rest_8}` ? `${Start_8}/:${Param_8}${Rest_8 extends `${infer Start_9}/{${infer Param_9}}${infer Rest_9}` ? `${Start_9}/:${Param_9}${Rest_9 extends `${infer Start_10}/{${infer Param_10}}${infer Rest_10}` ? `${Start_10}/:${Param_10}${any}` : Rest_9}` : Rest_8}` : Rest_7}` : Rest_6}` : Rest_5}` : Rest_4}` : Rest_3}` : Rest_2}` : Rest_1}` : Rest}` : T : never : never;
154
155
  };
156
+ bindDefaultRoutes(): ValueOrPromise<void>;
155
157
  scope: string;
156
158
  identifier: string;
157
159
  get logger(): import("@venizia/ignis-helpers").ILogger;
@@ -19,6 +19,7 @@ import { getError } from '@venizia/ignis-helpers/core';
19
19
  import { HTTP } from '@venizia/ignis-helpers/common';
20
20
  import { ChangePasswordRequestSchema, SignInRequestSchema, SignUpRequestSchema, } from '@venizia/ignis-kernel';
21
21
  import { Authentication, } from '@venizia/ignis-kernel';
22
+ /** Zod schema of the JWT payload: `userId`, the `roles` (id, identifier, integer priority) and optional `clientId`, `provider` and `email`. */
22
23
  export const JWTTokenPayloadSchema = z.object({
23
24
  userId: z.string().or(z.number()),
24
25
  roles: z.array(z.object({