@venizia/ignis 0.4.8-9 → 0.5.0-0

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 (265) hide show
  1. package/dist/esm/base/applications/base.js +5 -2
  2. package/dist/esm/base/applications/base.js.map +1 -1
  3. package/dist/esm/base/middlewares/request-spy/request-spy.middleware.js +1 -1
  4. package/dist/esm/base/middlewares/request-spy/request-spy.middleware.js.map +1 -1
  5. package/dist/esm/components/api-reference/common/keys.d.ts +2 -1
  6. package/dist/esm/components/api-reference/common/keys.js +4 -1
  7. package/dist/esm/components/api-reference/common/keys.js.map +1 -1
  8. package/dist/esm/components/api-reference/common/types.d.ts +7 -4
  9. package/dist/esm/components/api-reference/common/types.js.map +1 -1
  10. package/dist/esm/components/api-reference/component.js +8 -3
  11. package/dist/esm/components/api-reference/component.js.map +1 -1
  12. package/dist/esm/components/auth/authenticate/component.js +13 -18
  13. package/dist/esm/components/auth/authenticate/component.js.map +1 -1
  14. package/dist/esm/components/auth/authenticate/controllers/factory.d.ts +3 -3
  15. package/dist/esm/components/auth/authenticate/controllers/factory.js +1 -1
  16. package/dist/esm/components/auth/authenticate/controllers/factory.js.map +1 -1
  17. package/dist/esm/components/auth/authenticate/controllers/jwks/controller.js.map +1 -1
  18. package/dist/esm/components/auth/authenticate/controllers/jwks/definitions.d.ts +2 -2
  19. package/dist/esm/components/auth/authenticate/controllers/service-certs/controller.js.map +1 -1
  20. package/dist/esm/components/auth/authenticate/controllers/service-certs/definitions.d.ts +2 -2
  21. package/dist/esm/components/auth/authenticate/services/basic/service.js +1 -1
  22. package/dist/esm/components/auth/authenticate/services/basic/service.js.map +1 -1
  23. package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.d.ts +5 -3
  24. package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js +19 -2
  25. package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js.map +1 -1
  26. package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.d.ts +3 -3
  27. package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.js +1 -1
  28. package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.js.map +1 -1
  29. package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.d.ts +3 -3
  30. package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.js +2 -2
  31. package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.js.map +1 -1
  32. package/dist/esm/components/auth/authenticate/services/bearer/jws.service.d.ts +3 -3
  33. package/dist/esm/components/auth/authenticate/services/bearer/jws.service.js +1 -1
  34. package/dist/esm/components/auth/authenticate/services/bearer/jws.service.js.map +1 -1
  35. package/dist/esm/components/auth/authenticate/services/jwks-url-policy.d.ts +10 -22
  36. package/dist/esm/components/auth/authenticate/services/jwks-url-policy.js +16 -112
  37. package/dist/esm/components/auth/authenticate/services/jwks-url-policy.js.map +1 -1
  38. package/dist/esm/components/auth/authenticate/services/service/signer.service.d.ts +11 -0
  39. package/dist/esm/components/auth/authenticate/services/service/signer.service.js +18 -0
  40. package/dist/esm/components/auth/authenticate/services/service/signer.service.js.map +1 -1
  41. package/dist/esm/components/auth/authenticate/services/service/verifier.service.js +1 -1
  42. package/dist/esm/components/auth/authenticate/services/service/verifier.service.js.map +1 -1
  43. package/dist/esm/components/auth/authenticate/strategies/basic.strategy.js.map +1 -1
  44. package/dist/esm/components/auth/authenticate/strategies/jwks/issuer.js.map +1 -1
  45. package/dist/esm/components/auth/authenticate/strategies/jwks/verifier.js.map +1 -1
  46. package/dist/esm/components/auth/authenticate/strategies/jws.strategy.js.map +1 -1
  47. package/dist/esm/components/auth/authenticate/strategies/service.strategy.js.map +1 -1
  48. package/dist/esm/components/auth/authorize/adapters/common/types.d.ts +1 -2
  49. package/dist/esm/components/auth/authorize/adapters/common/types.js.map +1 -1
  50. package/dist/esm/components/auth/authorize/component.js.map +1 -1
  51. package/dist/esm/components/controller/grpc/common/types.d.ts +1 -1
  52. package/dist/esm/components/controller/grpc/common/types.js +4 -1
  53. package/dist/esm/components/controller/grpc/common/types.js.map +1 -1
  54. package/dist/esm/components/controller/grpc/grpc.component.js.map +1 -1
  55. package/dist/esm/components/health-check/common/keys.d.ts +4 -2
  56. package/dist/esm/components/health-check/common/keys.js +7 -2
  57. package/dist/esm/components/health-check/common/keys.js.map +1 -1
  58. package/dist/esm/components/health-check/common/types.d.ts +1 -1
  59. package/dist/esm/components/health-check/common/types.js.map +1 -1
  60. package/dist/esm/components/health-check/component.js +1 -3
  61. package/dist/esm/components/health-check/component.js.map +1 -1
  62. package/dist/esm/components/mail/common/constants.d.ts +32 -14
  63. package/dist/esm/components/mail/common/constants.js +25 -32
  64. package/dist/esm/components/mail/common/constants.js.map +1 -1
  65. package/dist/esm/components/mail/common/errors.d.ts +19 -1
  66. package/dist/esm/components/mail/common/errors.js +13 -1
  67. package/dist/esm/components/mail/common/errors.js.map +1 -1
  68. package/dist/esm/components/mail/common/keys.d.ts +14 -11
  69. package/dist/esm/components/mail/common/keys.js +34 -11
  70. package/dist/esm/components/mail/common/keys.js.map +1 -1
  71. package/dist/esm/components/mail/common/types/message.d.ts +7 -4
  72. package/dist/esm/components/mail/common/types/message.js.map +1 -1
  73. package/dist/esm/components/mail/common/types/options.d.ts +54 -10
  74. package/dist/esm/components/mail/common/types/options.js.map +1 -1
  75. package/dist/esm/components/mail/common/types/queue.d.ts +25 -12
  76. package/dist/esm/components/mail/common/types/queue.js.map +1 -1
  77. package/dist/esm/components/mail/common/types/template.d.ts +8 -4
  78. package/dist/esm/components/mail/common/types/template.js.map +1 -1
  79. package/dist/esm/components/mail/common/types/verification.d.ts +1 -0
  80. package/dist/esm/components/mail/common/types/verification.js.map +1 -1
  81. package/dist/esm/components/mail/component.js +11 -2
  82. package/dist/esm/components/mail/component.js.map +1 -1
  83. package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.d.ts +3 -1
  84. package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.js +27 -33
  85. package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.js.map +1 -1
  86. package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.d.ts +2 -0
  87. package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.js +17 -10
  88. package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.js.map +1 -1
  89. package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.js +11 -6
  90. package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.js.map +1 -1
  91. package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.d.ts +2 -3
  92. package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.js +15 -6
  93. package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.js.map +1 -1
  94. package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.d.ts +2 -3
  95. package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.js +2 -2
  96. package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.js.map +1 -1
  97. package/dist/esm/components/mail/providers/mail-queue-executor.provider.d.ts +2 -2
  98. package/dist/esm/components/mail/providers/mail-queue-executor.provider.js +7 -9
  99. package/dist/esm/components/mail/providers/mail-queue-executor.provider.js.map +1 -1
  100. package/dist/esm/components/mail/providers/mail-transporter.provider.js +7 -7
  101. package/dist/esm/components/mail/providers/mail-transporter.provider.js.map +1 -1
  102. package/dist/esm/components/mail/services/generators/numeric-code.d.ts +1 -6
  103. package/dist/esm/components/mail/services/generators/numeric-code.js +3 -31
  104. package/dist/esm/components/mail/services/generators/numeric-code.js.map +1 -1
  105. package/dist/esm/components/mail/services/generators/random-token.d.ts +4 -1
  106. package/dist/esm/components/mail/services/generators/random-token.js +9 -6
  107. package/dist/esm/components/mail/services/generators/random-token.js.map +1 -1
  108. package/dist/esm/components/mail/services/mail.service.d.ts +1 -2
  109. package/dist/esm/components/mail/services/mail.service.js +22 -19
  110. package/dist/esm/components/mail/services/mail.service.js.map +1 -1
  111. package/dist/esm/components/mail/services/template.service.d.ts +8 -6
  112. package/dist/esm/components/mail/services/template.service.js +34 -33
  113. package/dist/esm/components/mail/services/template.service.js.map +1 -1
  114. package/dist/esm/components/mail/utilities/attachment.utility.js +8 -6
  115. package/dist/esm/components/mail/utilities/attachment.utility.js.map +1 -1
  116. package/dist/esm/components/mail/utilities/header.utility.d.ts +14 -0
  117. package/dist/esm/components/mail/utilities/header.utility.js +44 -0
  118. package/dist/esm/components/mail/utilities/header.utility.js.map +1 -0
  119. package/dist/esm/components/mail/utilities/index.d.ts +2 -0
  120. package/dist/esm/components/mail/utilities/index.js +2 -0
  121. package/dist/esm/components/mail/utilities/index.js.map +1 -1
  122. package/dist/esm/components/mail/utilities/mime.utility.d.ts +5 -1
  123. package/dist/esm/components/mail/utilities/mime.utility.js +12 -58
  124. package/dist/esm/components/mail/utilities/mime.utility.js.map +1 -1
  125. package/dist/esm/components/mail/utilities/template-renderer.utility.d.ts +31 -0
  126. package/dist/esm/components/mail/utilities/template-renderer.utility.js +184 -0
  127. package/dist/esm/components/mail/utilities/template-renderer.utility.js.map +1 -0
  128. package/dist/esm/components/mail/utilities/type.utility.d.ts +2 -3
  129. package/dist/esm/components/mail/utilities/type.utility.js +6 -7
  130. package/dist/esm/components/mail/utilities/type.utility.js.map +1 -1
  131. package/dist/esm/components/request-tracker/component.d.ts +2 -1
  132. package/dist/esm/components/request-tracker/component.js +5 -5
  133. package/dist/esm/components/request-tracker/component.js.map +1 -1
  134. package/dist/esm/components/server-info/common/keys.d.ts +2 -1
  135. package/dist/esm/components/server-info/common/keys.js +4 -1
  136. package/dist/esm/components/server-info/common/keys.js.map +1 -1
  137. package/dist/esm/components/server-info/common/types.d.ts +1 -1
  138. package/dist/esm/components/server-info/common/types.js.map +1 -1
  139. package/dist/esm/components/server-info/component.js +1 -3
  140. package/dist/esm/components/server-info/component.js.map +1 -1
  141. package/dist/esm/components/socket-io/common/keys.d.ts +9 -6
  142. package/dist/esm/components/socket-io/common/keys.js +19 -6
  143. package/dist/esm/components/socket-io/common/keys.js.map +1 -1
  144. package/dist/esm/components/socket-io/component.js +1 -1
  145. package/dist/esm/components/socket-io/component.js.map +1 -1
  146. package/dist/esm/components/socket-io/handlers/bun.handler.d.ts +13 -3
  147. package/dist/esm/components/socket-io/handlers/bun.handler.js.map +1 -1
  148. package/dist/esm/components/static-asset/common/constants.d.ts +51 -24
  149. package/dist/esm/components/static-asset/common/constants.js +75 -47
  150. package/dist/esm/components/static-asset/common/constants.js.map +1 -1
  151. package/dist/esm/components/static-asset/common/errors.d.ts +30 -35
  152. package/dist/esm/components/static-asset/common/errors.js +31 -33
  153. package/dist/esm/components/static-asset/common/errors.js.map +1 -1
  154. package/dist/esm/components/static-asset/common/index.d.ts +1 -1
  155. package/dist/esm/components/static-asset/common/index.js +1 -1
  156. package/dist/esm/components/static-asset/common/index.js.map +1 -1
  157. package/dist/esm/components/static-asset/common/keys.d.ts +14 -2
  158. package/dist/esm/components/static-asset/common/keys.js +17 -2
  159. package/dist/esm/components/static-asset/common/keys.js.map +1 -1
  160. package/dist/esm/components/static-asset/common/types.d.ts +267 -147
  161. package/dist/esm/components/static-asset/common/types.js.map +1 -1
  162. package/dist/esm/components/static-asset/common/validation.d.ts +10 -0
  163. package/dist/esm/components/static-asset/common/validation.js +8 -0
  164. package/dist/esm/components/static-asset/common/validation.js.map +1 -0
  165. package/dist/esm/components/static-asset/component.d.ts +4 -2
  166. package/dist/esm/components/static-asset/component.js +27 -31
  167. package/dist/esm/components/static-asset/component.js.map +1 -1
  168. package/dist/esm/components/static-asset/controller/factory.d.ts +37 -79
  169. package/dist/esm/components/static-asset/controller/factory.js +26 -917
  170. package/dist/esm/components/static-asset/controller/factory.js.map +1 -1
  171. package/dist/esm/components/static-asset/controller/index.d.ts +1 -0
  172. package/dist/esm/components/static-asset/controller/index.js +1 -0
  173. package/dist/esm/components/static-asset/controller/index.js.map +1 -1
  174. package/dist/esm/components/static-asset/controller/routes/context.d.ts +62 -0
  175. package/dist/esm/components/static-asset/controller/routes/context.js +45 -0
  176. package/dist/esm/components/static-asset/controller/routes/context.js.map +1 -0
  177. package/dist/esm/components/static-asset/controller/routes/definition.d.ts +40 -0
  178. package/dist/esm/components/static-asset/controller/routes/definition.js +83 -0
  179. package/dist/esm/components/static-asset/controller/routes/definition.js.map +1 -0
  180. package/dist/esm/components/static-asset/controller/routes/direct-upload.d.ts +3 -0
  181. package/dist/esm/components/static-asset/controller/routes/direct-upload.js +153 -0
  182. package/dist/esm/components/static-asset/controller/routes/direct-upload.js.map +1 -0
  183. package/dist/esm/components/static-asset/controller/routes/labels.d.ts +16 -0
  184. package/dist/esm/components/static-asset/controller/routes/labels.js +19 -0
  185. package/dist/esm/components/static-asset/controller/routes/labels.js.map +1 -0
  186. package/dist/esm/components/static-asset/controller/routes/objects.d.ts +7 -0
  187. package/dist/esm/components/static-asset/controller/routes/objects.js +193 -0
  188. package/dist/esm/components/static-asset/controller/routes/objects.js.map +1 -0
  189. package/dist/esm/components/static-asset/controller/routes/serve.d.ts +29 -0
  190. package/dist/esm/components/static-asset/controller/routes/serve.js +152 -0
  191. package/dist/esm/components/static-asset/controller/routes/serve.js.map +1 -0
  192. package/dist/esm/components/static-asset/controller/routes/table.d.ts +12 -0
  193. package/dist/esm/components/static-asset/controller/routes/table.js +52 -0
  194. package/dist/esm/components/static-asset/controller/routes/table.js.map +1 -0
  195. package/dist/esm/components/static-asset/controller/routes/upload.d.ts +10 -0
  196. package/dist/esm/components/static-asset/controller/routes/upload.js +175 -0
  197. package/dist/esm/components/static-asset/controller/routes/upload.js.map +1 -0
  198. package/dist/esm/components/static-asset/index.d.ts +2 -1
  199. package/dist/esm/components/static-asset/index.js +2 -1
  200. package/dist/esm/components/static-asset/index.js.map +1 -1
  201. package/dist/esm/components/static-asset/models/base.model.d.ts +4 -4
  202. package/dist/esm/components/static-asset/models/base.model.js.map +1 -1
  203. package/dist/esm/components/static-asset/services/commitment.service.d.ts +103 -0
  204. package/dist/esm/components/static-asset/services/commitment.service.js +252 -0
  205. package/dist/esm/components/static-asset/services/commitment.service.js.map +1 -0
  206. package/dist/esm/components/static-asset/services/index.d.ts +3 -0
  207. package/dist/esm/components/static-asset/services/index.js +3 -0
  208. package/dist/esm/components/static-asset/services/index.js.map +1 -0
  209. package/dist/esm/components/static-asset/services/policy.service.d.ts +45 -0
  210. package/dist/esm/components/static-asset/services/policy.service.js +104 -0
  211. package/dist/esm/components/static-asset/services/policy.service.js.map +1 -0
  212. package/dist/esm/components/static-asset/utilities/commit-token.utility.d.ts +28 -0
  213. package/dist/esm/components/static-asset/utilities/commit-token.utility.js +112 -0
  214. package/dist/esm/components/static-asset/utilities/commit-token.utility.js.map +1 -0
  215. package/dist/esm/components/static-asset/utilities/entry.utility.d.ts +69 -0
  216. package/dist/esm/components/static-asset/utilities/entry.utility.js +160 -0
  217. package/dist/esm/components/static-asset/utilities/entry.utility.js.map +1 -0
  218. package/dist/esm/components/static-asset/utilities/index.d.ts +6 -0
  219. package/dist/esm/components/static-asset/utilities/index.js +6 -0
  220. package/dist/esm/components/static-asset/utilities/index.js.map +1 -0
  221. package/dist/esm/components/static-asset/{ingest.d.ts → utilities/ingest.utility.d.ts} +8 -8
  222. package/dist/esm/components/static-asset/{ingest.js → utilities/ingest.utility.js} +21 -23
  223. package/dist/esm/components/static-asset/utilities/ingest.utility.js.map +1 -0
  224. package/dist/esm/components/static-asset/{controller/key-scope.d.ts → utilities/key-scope.utility.d.ts} +21 -2
  225. package/dist/esm/components/static-asset/utilities/key-scope.utility.js +74 -0
  226. package/dist/esm/components/static-asset/utilities/key-scope.utility.js.map +1 -0
  227. package/dist/esm/components/static-asset/{controller/meta-link.d.ts → utilities/meta-link.utility.d.ts} +9 -9
  228. package/dist/esm/components/static-asset/{controller/meta-link.js → utilities/meta-link.utility.js} +10 -10
  229. package/dist/esm/components/static-asset/utilities/meta-link.utility.js.map +1 -0
  230. package/dist/esm/components/static-asset/utilities/object-link.utility.d.ts +16 -0
  231. package/dist/esm/components/static-asset/utilities/object-link.utility.js +20 -0
  232. package/dist/esm/components/static-asset/utilities/object-link.utility.js.map +1 -0
  233. package/dist/esm/components/static-asset/utilities/pinned-file.utility.d.ts +39 -0
  234. package/dist/esm/components/static-asset/utilities/pinned-file.utility.js +53 -0
  235. package/dist/esm/components/static-asset/utilities/pinned-file.utility.js.map +1 -0
  236. package/dist/esm/components/static-asset/utilities/route-options.utility.d.ts +43 -0
  237. package/dist/esm/components/static-asset/utilities/route-options.utility.js +71 -0
  238. package/dist/esm/components/static-asset/utilities/route-options.utility.js.map +1 -0
  239. package/dist/esm/components/static-asset/utilities/toggle.utility.d.ts +5 -0
  240. package/dist/esm/components/static-asset/utilities/toggle.utility.js +5 -0
  241. package/dist/esm/components/static-asset/utilities/toggle.utility.js.map +1 -0
  242. package/dist/esm/components/websocket/common/keys.d.ts +12 -10
  243. package/dist/esm/components/websocket/common/keys.js +31 -10
  244. package/dist/esm/components/websocket/common/keys.js.map +1 -1
  245. package/dist/esm/components/websocket/component.js.map +1 -1
  246. package/dist/esm/testing/assert-application-boots.d.ts +2 -2
  247. package/dist/esm/testing/assert-application-boots.js +6 -2
  248. package/dist/esm/testing/assert-application-boots.js.map +1 -1
  249. package/dist/presets/app/preset.json +4 -4
  250. package/dist/presets/lib/preset.json +3 -3
  251. package/dist/presets/shared/preset.json +1 -1
  252. package/package.json +8 -8
  253. package/dist/esm/components/static-asset/common/commit-token.d.ts +0 -28
  254. package/dist/esm/components/static-asset/common/commit-token.js +0 -48
  255. package/dist/esm/components/static-asset/common/commit-token.js.map +0 -1
  256. package/dist/esm/components/static-asset/controller/base.definition.d.ts +0 -30
  257. package/dist/esm/components/static-asset/controller/base.definition.js +0 -307
  258. package/dist/esm/components/static-asset/controller/base.definition.js.map +0 -1
  259. package/dist/esm/components/static-asset/controller/key-scope.js +0 -41
  260. package/dist/esm/components/static-asset/controller/key-scope.js.map +0 -1
  261. package/dist/esm/components/static-asset/controller/meta-link.js.map +0 -1
  262. package/dist/esm/components/static-asset/controller/route-options.d.ts +0 -29
  263. package/dist/esm/components/static-asset/controller/route-options.js +0 -47
  264. package/dist/esm/components/static-asset/controller/route-options.js.map +0 -1
  265. package/dist/esm/components/static-asset/ingest.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { ScopeFilterUtility } from '@venizia/ignis-connectors';
2
2
  import { ControllerTransports } from '@venizia/ignis-kernel';
3
- import { BindingNamespaces, CoreBindings } from '@venizia/ignis-kernel';
3
+ import { BindingKeys, BindingNamespaces, CoreBindings } from '@venizia/ignis-kernel';
4
4
  import { EnvironmentKeys } from '../../common/environments.js';
5
5
  import { RequestTrackerComponent } from '../../components/index.js';
6
6
  import { GrpcComponent } from '../../components/controller/grpc/index.js';
@@ -205,7 +205,10 @@ export class BaseApplication extends ServerApplication {
205
205
  return;
206
206
  }
207
207
  for (const entry of registration.lease) {
208
- const instance = this.get({ key: entry.key, isOptional: true });
208
+ const instance = this.get({
209
+ key: BindingKeys.build({ key: entry.key }),
210
+ isOptional: true,
211
+ });
209
212
  if (instance && typeof instance.onSecretRotated === 'function') {
210
213
  provider.registerRotatable({ key: entry.key, target: instance });
211
214
  logger.info('Wired rotatable | key: %s', entry.key);
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../src/base/applications/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,gBAAgB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AA4B;gBAClD,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,0BAA0B,EAAE;aAC7C;YACD,GAAG,KAAK,CAAC,eAAe,EAAE;SAC3B,CAAC;QAEF,MAAM,WAAW,GAAG,YAAY,CAAC,WAAW,CAAC;YAC3C,KAAK;YACL,MAAM,EAAE,eAAe,CAAC,aAAa;YACrC,IAAI,EAAE,EAAE,IAAI,EAAE,eAAe,CAAC,eAAe,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE;SAClF,CAAC,CAAC;QAEH,+FAA+F;QAC/F,iGAAiG;QACjG,MAAM,cAAc,GAAG,YAAY,CAAC,WAAW,CAAC;YAC9C,KAAK,EAAE,WAAW;YAClB,MAAM,EAAE,eAAe,CAAC,iCAAiC;YACzD,IAAI,EAAE;gBACJ,IAAI,EAAE,eAAe,CAAC,sBAAsB;gBAC5C,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,oBAAoB,EAAE;aACvC;SACF,CAAC,CAAC;QAEH,OAAO;YACL,GAAG,cAAc;YACjB,6DAA6D;YAC7D;gBACE,IAAI,EAAE,eAAe,CAAC,6BAA6B;gBACnD,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,0BAA0B,EAAE;aAC7C;SACF,CAAC;IACJ,CAAC;IAED;;;OAGG;IACO,0BAA0B;QAClC,kBAAkB,CAAC,0BAA0B,CAAC;YAC5C,mBAAmB,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,IAAI,KAAK;YAC/D,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { ScopeFilterUtility } from '@venizia/ignis-connectors';\nimport { ControllerTransports } from '@venizia/ignis-kernel';\nimport { BindingNamespaces, CoreBindings } from '@venizia/ignis-kernel';\nimport { EnvironmentKeys } from '@/common/environments';\nimport { RequestTrackerComponent } from '@/components';\nimport { GrpcComponent } from '@/components/controller/grpc';\nimport {\n BindingScopes,\n BindingValueTypes,\n BootSequence,\n MetadataRegistry,\n RequestContextRegistry,\n} from '@venizia/ignis-kernel';\nimport type { ILogger } from '@venizia/ignis-helpers/core';\nimport type { ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport type {\n ISecretHydrateEntry,\n ISecretRotatable,\n ISecretsHelper,\n ISecretsRegistration,\n} from '@venizia/ignis-helpers';\nimport { ParseUtility, getError } from '@venizia/ignis-helpers/core';\nimport { HTTP, ObjectUtility } from '@venizia/ignis-helpers/common';\nimport { DEFAULT_TEMPORAL_TZ } from '@venizia/ignis-helpers/temporal';\nimport {\n applicationEnvironment,\n SecretsHelperFactory,\n PerformanceUtility,\n Environment,\n SecretProviders,\n} from '@venizia/ignis-helpers';\nimport { contextStorage, tryGetContext } from 'hono/context-storage';\nimport { AppErrorMiddleware, EmojiFaviconMiddleware } from '../middlewares';\nimport { serveStatic } from 'hono/bun';\nimport { ServerLoggerStartup } from './common';\nimport { ServerBootSteps } from './boot-steps';\nimport { ServerApplication } from './server';\nimport type { IRestApplication } from '@venizia/ignis-kernel';\nimport type { IBootSequenceStep } from '@venizia/ignis-kernel';\n\n/** Maps a secret bundle to env names: the explicit `keys` mapping when present, otherwise every bundle key under `prefix`. */\nconst selectSecretEnvKeys = (opts: {\n bundle: Record<string, string>;\n entry: ISecretHydrateEntry;\n}): Record<string, string> => {\n const { bundle, entry } = opts;\n const merged: Record<string, string> = {};\n\n if (!entry.keys) {\n const bundleEntries = Object.entries(bundle);\n\n for (const [rawKey, value] of bundleEntries) {\n merged[`${entry.prefix ?? ''}${rawKey}`] = value;\n }\n\n return merged;\n }\n\n const entryKeysEntries = Object.entries(entry.keys);\n\n for (const [rawKey, envKey] of entryKeysEntries) {\n const value = bundle[rawKey];\n\n if (value === undefined) {\n continue;\n }\n\n merged[envKey] = value;\n }\n\n return merged;\n};\n\n/**\n * The IGNIS server application: a `ServerApplication` that adds secrets hydration, env validation, start-up info and the gRPC controller branch. Extend it to build an application.\n *\n * @example\n * ```typescript\n * import { BaseApplication, type IApplicationInfo } from '@venizia/ignis';\n *\n * class App extends BaseApplication {\n * getAppInfo(): IApplicationInfo { return { name: 'app', version: '1.0.0', description: 'Demo' }; }\n * staticConfigure(): void {}\n * preConfigure(): void {}\n * postConfigure(): void {}\n * setupMiddlewares(): void {}\n * }\n * const app = new App({ scope: 'App', config: { host: '0.0.0.0', port: 3000, path: { base: '/api', isStrict: true } } });\n * app.init();\n * await app.start();\n * ```\n */\nexport abstract class BaseApplication extends ServerApplication implements IRestApplication {\n protected secretsProvider?: ISecretsHelper;\n protected secretsRegistration?: ISecretsRegistration;\n\n protected normalizePath(...segments: string[]): string {\n const joined = segments.join('/').replace(/\\/+/g, '/').replace(/\\/$/, '');\n\n return joined || '/';\n }\n\n /** Adds the gRPC branch the kernel cannot own: `GrpcComponent` needs `AbstractGrpcController`, core-only code that reaches `node:module`. */\n override async registerControllers(): Promise<void> {\n await super.registerControllers();\n\n await PerformanceUtility.executeWithMeasure({\n logger: this.logger,\n description: 'Register application gRPC controllers',\n scope: this.registerControllers.name,\n task: async () => {\n const transports = this.configs.transports ?? [ControllerTransports.REST];\n\n for (const transport of transports) {\n if (transport === ControllerTransports.REST) {\n continue;\n }\n\n if (transport !== ControllerTransports.GRPC) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[registerControllers] Unsupported transport: '${transport}'`,\n });\n }\n\n const grpcComponent = new GrpcComponent(this);\n await grpcComponent.configure();\n }\n\n // Warn if gRPC controllers exist but gRPC transport is not enabled\n if (transports.includes(ControllerTransports.GRPC)) {\n return;\n }\n\n const allBindings = this.findByTag({ tag: BindingNamespaces.CONTROLLER });\n\n for (const binding of allBindings) {\n const target = binding.getBindingMeta({ type: BindingValueTypes.CLASS });\n\n if (!target) {\n continue;\n }\n\n const metadata = MetadataRegistry.getInstance().getControllerMetadata({ target });\n\n if (metadata?.transport !== ControllerTransports.GRPC) {\n continue;\n }\n\n this.logger\n .for(this.registerControllers.name)\n .error(\n 'gRPC controller \"%s\" discovered but gRPC transport is not enabled. Add \"%s\" to transports config.',\n binding.key,\n ControllerTransports.GRPC,\n );\n }\n },\n });\n }\n\n registerSecrets(): ValueOrPromise<ISecretsRegistration> {\n return { provider: SecretProviders.SYSTEM_ENVS };\n }\n\n async hydrateSecrets(): Promise<void> {\n const logger = this.logger.for(this.hydrateSecrets.name);\n const registration = await this.registerSecrets();\n\n let provider: ISecretsHelper | undefined;\n const emptyHydrations: string[] = [];\n\n try {\n const result = await SecretsHelperFactory.create({ ...registration, identifier: 'app' });\n provider = result;\n await provider.configure();\n\n await this.hydrateSecretEntries({ provider, registration, emptyHydrations, logger });\n\n const registrationLease = registration.lease ?? [];\n\n for (const entry of registrationLease) {\n await provider.lease({ path: entry.path, key: entry.key });\n }\n } catch (error) {\n const env = Environment.current;\n\n if (!Environment.DEVELOPMENT_ENVS.has(env.toLowerCase())) {\n throw getError({\n message: `[hydrateSecrets] Secret provider failed in non-development environment | env: ${env}`,\n });\n }\n\n logger.warn(\n 'Secret provider failed; falling back to system-envs | env: %s | error: %s',\n env,\n error,\n );\n\n if (provider) {\n try {\n await provider.shutdown();\n } catch (shutdownError) {\n logger.error(\n 'Failed to shut down partially-built provider during fallback | error: %s',\n shutdownError,\n );\n }\n }\n\n const result2 = await SecretsHelperFactory.create({\n provider: SecretProviders.SYSTEM_ENVS,\n identifier: 'app',\n });\n provider = result2;\n }\n\n if (!provider) {\n throw getError({ message: '[hydrateSecrets] No secrets provider resolved' });\n }\n\n if (emptyHydrations.length > 0) {\n const env = Environment.current;\n\n if (!Environment.DEVELOPMENT_ENVS.has(env.toLowerCase())) {\n throw getError({\n message: `[hydrateSecrets] Hydrate entries resolved to an empty secret bundle in non-development environment | env: ${env} | paths: ${emptyHydrations.join(', ')}`,\n });\n }\n\n logger.warn(\n 'Hydrate entries resolved to an empty secret bundle; continuing in development | env: %s | paths: %s',\n env,\n emptyHydrations.join(', '),\n );\n }\n\n this.bind<ISecretsHelper>({ key: CoreBindings.APPLICATION_CONFIG })\n .toProvider(() => provider)\n .setScope(BindingScopes.SINGLETON);\n\n this.registerPostStopHook({ identifier: 'secrets.shutdown', hook: () => provider.shutdown() });\n this.secretsProvider = provider;\n this.secretsRegistration = registration;\n }\n\n /** Applies each hydrate entry in declaration order; paths that resolve empty while declaring an expectation are collected in `emptyHydrations` rather than failing here. */\n protected async hydrateSecretEntries(opts: {\n provider: ISecretsHelper;\n registration: ISecretsRegistration;\n emptyHydrations: string[];\n logger: ILogger;\n }): Promise<void> {\n const { provider, registration, emptyHydrations, logger } = opts;\n\n const registrationHydrate = registration.hydrate ?? [];\n\n for (const entry of registrationHydrate) {\n const bundle = await provider.getBundle({ path: entry.path });\n const merged = this.mergeSecretsIntoEnv({ bundle, entry });\n\n if (Object.keys(merged).length > 0) {\n continue;\n }\n\n if (this.hydrateEntryDeclaresExpectation({ entry })) {\n emptyHydrations.push(entry.path);\n continue;\n }\n\n logger.warn(\n 'Hydrate entry resolved to an empty bundle and declares no expected keys | path: %s',\n entry.path,\n );\n }\n }\n\n protected mergeSecretsIntoEnv(opts: {\n bundle: Record<string, string>;\n entry: ISecretHydrateEntry;\n }): Record<string, string> {\n const { bundle, entry } = opts;\n const merged = selectSecretEnvKeys({ bundle, entry });\n\n const mergedEntries = Object.entries(merged);\n\n for (const [key, value] of mergedEntries) {\n process.env[key] = value;\n }\n\n applicationEnvironment.merge({ envs: merged });\n\n return merged;\n }\n\n /** A hydrate entry declares an expectation only via explicit `keys` or a non-empty `prefix`; such an entry resolving to zero env values is a misconfiguration boot must not silently absorb. */\n protected hydrateEntryDeclaresExpectation(opts: { entry: ISecretHydrateEntry }): boolean {\n const { entry } = opts;\n\n if (entry.keys && Object.keys(entry.keys).length > 0) {\n return true;\n }\n\n return typeof entry.prefix === 'string' && entry.prefix.length > 0;\n }\n\n async wireSecretRotatables(): Promise<void> {\n const logger = this.logger.for(this.wireSecretRotatables.name);\n const provider = this.secretsProvider;\n const registration = this.secretsRegistration;\n\n if (!provider || !registration?.lease?.length) {\n return;\n }\n\n for (const entry of registration.lease) {\n const instance = this.get<ISecretRotatable>({ key: entry.key, isOptional: true });\n\n if (instance && typeof instance.onSecretRotated === 'function') {\n provider.registerRotatable({ key: entry.key, target: instance });\n logger.info('Wired rotatable | key: %s', entry.key);\n continue;\n }\n\n logger.debug('Lease key has no rotatable consumer | key: %s', entry.key);\n }\n }\n\n static(opts: { restPath?: string; folderPath: string }) {\n const { restPath = '*', folderPath } = opts;\n const server = this.getServer();\n\n server.use(restPath, serveStatic({ root: folderPath }));\n\n this.logger\n .for(this.static.name)\n .debug(\n 'Registered static files | runtime: %s | path: %s | folder: %s',\n this.runtime,\n restPath,\n folderPath,\n );\n\n return this;\n }\n\n /**\n * Every value is read HERE, not destructured at module load: an application that loads its\n * `.env` in its own entrypoint does so after this module is imported, and a module-load snapshot\n * would print the defaults for a host that configured everything correctly.\n */\n protected printStartUpInfo(opts: { scope: string }) {\n const { scope } = opts;\n const read = (key: string, fallback: string): string =>\n ParseUtility.blankToUndefined({ input: process.env[key] }) ?? fallback;\n const divider = '------------------------------------------------------------------------';\n\n this.logger.for(scope).info(divider);\n this.logger\n .for(scope)\n .info(\n 'Starting application... | Name: %s | Env: %s | Runtime: %s',\n read(EnvironmentKeys.APP_ENV_APPLICATION_NAME, 'PNT'),\n Environment.ambient,\n this.runtime,\n );\n this.logger\n .for(scope)\n .info(\n 'AllowEmptyEnv: %s | Prefix: %s',\n read('ALLOW_EMPTY_ENV_VALUE', 'true'),\n read('APPLICATION_ENV_PREFIX', 'APP_ENV'),\n );\n this.logger.for(scope).info('RunMode: %s', process.env.RUN_MODE);\n this.logger\n .for(scope)\n .info(\n 'Timezone: %s',\n read(EnvironmentKeys.APP_ENV_APPLICATION_TIMEZONE, DEFAULT_TEMPORAL_TZ),\n );\n this.logger\n .for(scope)\n .info('LogPath: %s', read(EnvironmentKeys.APP_ENV_LOGGER_FOLDER_PATH, './'));\n this.logger.for(scope).info(divider);\n }\n\n /** Swaps in the `ErrorPrettier`-backed formatter - `node:util`, so the kernel cannot build it. */\n protected override buildErrorMiddleware(): AppErrorMiddleware {\n return new AppErrorMiddleware({\n logger: this.logger,\n rootKey: this.configs.error?.rootKey ?? undefined,\n });\n }\n\n /** Adds what only a listening server has, on top of the kernel's three - which stay in `RestApplication` so a browser Worker answers with the same envelope. */\n protected override async registerDefaultMiddlewares() {\n await PerformanceUtility.executeWithMeasure({\n logger: this.logger,\n scope: this.registerDefaultMiddlewares.name,\n description: 'Register default application server handler',\n task: async () => {\n const server = this.getServer();\n\n await super.registerDefaultMiddlewares();\n\n // Always installed, not only under `asyncContext.enable`: `tryGetContext()` answers \"no context\"\n // without a store, and a `contextStorage()` the application registered itself stays visible to\n // the enrichers. Inside a method body because every package declares `sideEffects: false`.\n RequestContextRegistry.setResolver({ resolver: () => tryGetContext() });\n\n if (this.configs.asyncContext?.enable) {\n server.use(contextStorage());\n }\n\n // Request-body parsing and the access log; the request id it reads is already installed\n // above (also works around the Bun + Hono body-parsing bug: https://github.com/honojs/middleware/issues/81).\n this.component(RequestTrackerComponent);\n\n server.use(EmojiFaviconMiddleware.create({ icon: this.configs.favicon ?? '🔥' }));\n },\n });\n }\n\n /** Lives here rather than on `AbstractApplication` - `applicationEnvironment` reads `process.env` at module load, so a kernel-pure ancestor cannot carry it; this is the layer that already depends on it. */\n protected validateEnvs() {\n const t = performance.now();\n const envKeys = applicationEnvironment.keys();\n\n // Permissive by DEFAULT: a name a host leaves empty is the host's business, and an empty value\n // already falls back to `defaultValue` at read time, so refusing to boot over one fights the\n // reader rather than helping it. Set ALLOW_EMPTY_ENV_VALUE to `false` or `0` to turn the check\n // on. Read once rather than per key, and a blank value reads as unset - the same rule every\n // other env read follows.\n const configured = ParseUtility.blankToUndefined({ input: process.env.ALLOW_EMPTY_ENV_VALUE });\n const allowsEmpty = configured === undefined || ParseUtility.toBoolean({ input: configured });\n\n this.logger\n .for(this.initialize.name)\n .info(\n 'Envs: %s | START Validating application environments | Empty values: %s',\n envKeys.length,\n allowsEmpty ? 'ALLOWED (default)' : 'REJECTED',\n );\n\n if (allowsEmpty) {\n this.logger\n .for(this.validateEnvs.name)\n .info(\n 'Envs: %s | SKIPPED - set ALLOW_EMPTY_ENV_VALUE=false to reject empty values',\n envKeys.length,\n );\n\n return;\n }\n\n for (const argKey of envKeys) {\n const argValue = applicationEnvironment.get<string | number>(argKey);\n\n if (!ObjectUtility.isEmpty({ value: argValue })) {\n continue;\n }\n\n throw getError({\n message: `[validateEnvs] Invalid Application Environment! Key: ${argKey} | Value: ${argValue}`,\n });\n }\n\n this.logger\n .for(this.validateEnvs.name)\n .info(\n 'Envs: %s | DONE Validating application environments | Took: %s (ms)',\n envKeys.length,\n performance.now() - t,\n );\n }\n\n /**\n * Version tripwire, body identical to `RestApplication.initialize()`: a stale kernel without\n * `getBootSequence()`/`runBootSequence()` throws here before any socket binds.\n */\n override async initialize(): Promise<void> {\n await ServerLoggerStartup.selectDefault();\n await this.runBootSequence({ steps: this.getBootSequence() });\n }\n\n protected override getBootSequence(): IBootSequenceStep[] {\n const steps: IBootSequenceStep[] = [\n {\n name: ServerBootSteps.PRINT_START_UP_INFO,\n run: () => this.printStartUpInfo({ scope: this.initialize.name }),\n },\n { name: ServerBootSteps.VALIDATE_ENVS, run: () => this.validateEnvs() },\n {\n name: ServerBootSteps.REGISTER_DEFAULT_MIDDLEWARES,\n run: () => this.registerDefaultMiddlewares(),\n },\n ...super.getBootSequence(),\n ];\n\n const withHydrate = BootSequence.insertAfter({\n steps,\n target: ServerBootSteps.PRE_CONFIGURE,\n step: { name: ServerBootSteps.HYDRATE_SECRETS, run: () => this.hydrateSecrets() },\n });\n\n // Components can contribute datasources, so wire rotatables only after the contributed sweep -\n // a lease key pointing at a component-contributed datasource would otherwise resolve to nothing.\n const withRotatables = BootSequence.insertAfter({\n steps: withHydrate,\n target: ServerBootSteps.REGISTER_CONTRIBUTED_DATA_SOURCES,\n step: {\n name: ServerBootSteps.WIRE_SECRET_ROTATABLES,\n run: () => this.wireSecretRotatables(),\n },\n });\n\n return [\n ...withRotatables,\n // Last, so a model registered by a component is covered too.\n {\n name: ServerBootSteps.VALIDATE_SCOPE_FILTER_SUPPORT,\n run: () => this.validateScopeFilterSupport(),\n },\n ];\n }\n\n /**\n * Refuses to start when a model's `settings.access` cannot take effect. Both failures are\n * silent at runtime and opposite: a search-backed model returns too many rows, a context-less one none.\n */\n protected validateScopeFilterSupport(): void {\n ScopeFilterUtility.assertScopeFilterSupported({\n asyncContextEnabled: this.configs.asyncContext?.enable ?? false,\n logger: this.logger,\n });\n }\n}\n"]}
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../src/base/applications/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAS/B,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,WAAW,EACX,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,aAAa,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,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE;SAClF,CAAC,CAAC;QAEH,+FAA+F;QAC/F,iGAAiG;QACjG,MAAM,cAAc,GAAG,YAAY,CAAC,WAAW,CAAC;YAC9C,KAAK,EAAE,WAAW;YAClB,MAAM,EAAE,eAAe,CAAC,iCAAiC;YACzD,IAAI,EAAE;gBACJ,IAAI,EAAE,eAAe,CAAC,sBAAsB;gBAC5C,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,oBAAoB,EAAE;aACvC;SACF,CAAC,CAAC;QAEH,OAAO;YACL,GAAG,cAAc;YACjB,6DAA6D;YAC7D;gBACE,IAAI,EAAE,eAAe,CAAC,6BAA6B;gBACnD,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,0BAA0B,EAAE;aAC7C;SACF,CAAC;IACJ,CAAC;IAED;;;OAGG;IACO,0BAA0B;QAClC,kBAAkB,CAAC,0BAA0B,CAAC;YAC5C,mBAAmB,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,IAAI,KAAK;YAC/D,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { ScopeFilterUtility } from '@venizia/ignis-connectors';\nimport { ControllerTransports } from '@venizia/ignis-kernel';\nimport { BindingKeys, BindingNamespaces, CoreBindings } from '@venizia/ignis-kernel';\nimport { EnvironmentKeys } from '@/common/environments';\nimport { RequestTrackerComponent } from '@/components';\nimport { GrpcComponent } from '@/components/controller/grpc';\nimport {\n BindingScopes,\n BindingValueTypes,\n BootSequence,\n MetadataRegistry,\n RequestContextRegistry,\n} from '@venizia/ignis-kernel';\nimport type { ILogger } from '@venizia/ignis-helpers/core';\nimport type { ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport type {\n ISecretHydrateEntry,\n ISecretRotatable,\n ISecretsHelper,\n ISecretsRegistration,\n} from '@venizia/ignis-helpers';\nimport { ParseUtility, getError } from '@venizia/ignis-helpers/core';\nimport { HTTP, ObjectUtility } from '@venizia/ignis-helpers/common';\nimport { DEFAULT_TEMPORAL_TZ } from '@venizia/ignis-helpers/temporal';\nimport {\n applicationEnvironment,\n SecretsHelperFactory,\n PerformanceUtility,\n Environment,\n SecretProviders,\n} from '@venizia/ignis-helpers';\nimport { contextStorage, tryGetContext } from 'hono/context-storage';\nimport { AppErrorMiddleware, EmojiFaviconMiddleware } from '../middlewares';\nimport { serveStatic } from 'hono/bun';\nimport { ServerLoggerStartup } from './common';\nimport { ServerBootSteps } from './boot-steps';\nimport { ServerApplication } from './server';\nimport type { IRestApplication } from '@venizia/ignis-kernel';\nimport type { IBootSequenceStep } from '@venizia/ignis-kernel';\n\n/** Maps a secret bundle to env names: the explicit `keys` mapping when present, otherwise every bundle key under `prefix`. */\nconst selectSecretEnvKeys = (opts: {\n bundle: Record<string, string>;\n entry: ISecretHydrateEntry;\n}): Record<string, string> => {\n const { bundle, entry } = opts;\n const merged: Record<string, string> = {};\n\n if (!entry.keys) {\n const bundleEntries = Object.entries(bundle);\n\n for (const [rawKey, value] of bundleEntries) {\n merged[`${entry.prefix ?? ''}${rawKey}`] = value;\n }\n\n return merged;\n }\n\n const entryKeysEntries = Object.entries(entry.keys);\n\n for (const [rawKey, envKey] of entryKeysEntries) {\n const value = bundle[rawKey];\n\n if (value === undefined) {\n continue;\n }\n\n merged[envKey] = value;\n }\n\n return merged;\n};\n\n/**\n * The IGNIS server application: a `ServerApplication` that adds secrets hydration, env validation, start-up info and the gRPC controller branch. Extend it to build an application.\n *\n * @example\n * ```typescript\n * import { BaseApplication, type IApplicationInfo } from '@venizia/ignis';\n *\n * class App extends BaseApplication {\n * getAppInfo(): IApplicationInfo { return { name: 'app', version: '1.0.0', description: 'Demo' }; }\n * staticConfigure(): void {}\n * preConfigure(): void {}\n * postConfigure(): void {}\n * setupMiddlewares(): void {}\n * }\n * const app = new App({ scope: 'App', config: { host: '0.0.0.0', port: 3000, path: { base: '/api', isStrict: true } } });\n * app.init();\n * await app.start();\n * ```\n */\nexport abstract class BaseApplication extends ServerApplication implements IRestApplication {\n protected secretsProvider?: ISecretsHelper;\n protected secretsRegistration?: ISecretsRegistration;\n\n protected normalizePath(...segments: string[]): string {\n const joined = segments.join('/').replace(/\\/+/g, '/').replace(/\\/$/, '');\n\n return joined || '/';\n }\n\n /** Adds the gRPC branch the kernel cannot own: `GrpcComponent` needs `AbstractGrpcController`, core-only code that reaches `node:module`. */\n override async registerControllers(): Promise<void> {\n await super.registerControllers();\n\n await PerformanceUtility.executeWithMeasure({\n logger: this.logger,\n description: 'Register application gRPC controllers',\n scope: this.registerControllers.name,\n task: async () => {\n const transports = this.configs.transports ?? [ControllerTransports.REST];\n\n for (const transport of transports) {\n if (transport === ControllerTransports.REST) {\n continue;\n }\n\n if (transport !== ControllerTransports.GRPC) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[registerControllers] Unsupported transport: '${transport}'`,\n });\n }\n\n const grpcComponent = new GrpcComponent(this);\n await grpcComponent.configure();\n }\n\n // Warn if gRPC controllers exist but gRPC transport is not enabled\n if (transports.includes(ControllerTransports.GRPC)) {\n return;\n }\n\n const allBindings = this.findByTag({ tag: BindingNamespaces.CONTROLLER });\n\n for (const binding of allBindings) {\n const target = binding.getBindingMeta({ type: BindingValueTypes.CLASS });\n\n if (!target) {\n continue;\n }\n\n const metadata = MetadataRegistry.getInstance().getControllerMetadata({ target });\n\n if (metadata?.transport !== ControllerTransports.GRPC) {\n continue;\n }\n\n this.logger\n .for(this.registerControllers.name)\n .error(\n 'gRPC controller \"%s\" discovered but gRPC transport is not enabled. Add \"%s\" to transports config.',\n binding.key,\n ControllerTransports.GRPC,\n );\n }\n },\n });\n }\n\n registerSecrets(): ValueOrPromise<ISecretsRegistration> {\n return { provider: SecretProviders.SYSTEM_ENVS };\n }\n\n async hydrateSecrets(): Promise<void> {\n const logger = this.logger.for(this.hydrateSecrets.name);\n const registration = await this.registerSecrets();\n\n let provider: ISecretsHelper | undefined;\n const emptyHydrations: string[] = [];\n\n try {\n const result = await SecretsHelperFactory.create({ ...registration, identifier: 'app' });\n provider = result;\n await provider.configure();\n\n await this.hydrateSecretEntries({ provider, registration, emptyHydrations, logger });\n\n const registrationLease = registration.lease ?? [];\n\n for (const entry of registrationLease) {\n await provider.lease({ path: entry.path, key: entry.key });\n }\n } catch (error) {\n const env = Environment.current;\n\n if (!Environment.DEVELOPMENT_ENVS.has(env.toLowerCase())) {\n throw getError({\n message: `[hydrateSecrets] Secret provider failed in non-development environment | env: ${env}`,\n });\n }\n\n logger.warn(\n 'Secret provider failed; falling back to system-envs | env: %s | error: %s',\n env,\n error,\n );\n\n if (provider) {\n try {\n await provider.shutdown();\n } catch (shutdownError) {\n logger.error(\n 'Failed to shut down partially-built provider during fallback | error: %s',\n shutdownError,\n );\n }\n }\n\n const result2 = await SecretsHelperFactory.create({\n provider: SecretProviders.SYSTEM_ENVS,\n identifier: 'app',\n });\n provider = result2;\n }\n\n if (!provider) {\n throw getError({ message: '[hydrateSecrets] No secrets provider resolved' });\n }\n\n if (emptyHydrations.length > 0) {\n const env = Environment.current;\n\n if (!Environment.DEVELOPMENT_ENVS.has(env.toLowerCase())) {\n throw getError({\n message: `[hydrateSecrets] Hydrate entries resolved to an empty secret bundle in non-development environment | env: ${env} | paths: ${emptyHydrations.join(', ')}`,\n });\n }\n\n logger.warn(\n 'Hydrate entries resolved to an empty secret bundle; continuing in development | env: %s | paths: %s',\n env,\n emptyHydrations.join(', '),\n );\n }\n\n this.bind<ISecretsHelper>({ key: CoreBindings.APPLICATION_CONFIG })\n .toProvider(() => provider)\n .setScope(BindingScopes.SINGLETON);\n\n this.registerPostStopHook({ identifier: 'secrets.shutdown', hook: () => provider.shutdown() });\n this.secretsProvider = provider;\n this.secretsRegistration = registration;\n }\n\n /** Applies each hydrate entry in declaration order; paths that resolve empty while declaring an expectation are collected in `emptyHydrations` rather than failing here. */\n protected async hydrateSecretEntries(opts: {\n provider: ISecretsHelper;\n registration: ISecretsRegistration;\n emptyHydrations: string[];\n logger: ILogger;\n }): Promise<void> {\n const { provider, registration, emptyHydrations, logger } = opts;\n\n const registrationHydrate = registration.hydrate ?? [];\n\n for (const entry of registrationHydrate) {\n const bundle = await provider.getBundle({ path: entry.path });\n const merged = this.mergeSecretsIntoEnv({ bundle, entry });\n\n if (Object.keys(merged).length > 0) {\n continue;\n }\n\n if (this.hydrateEntryDeclaresExpectation({ entry })) {\n emptyHydrations.push(entry.path);\n continue;\n }\n\n logger.warn(\n 'Hydrate entry resolved to an empty bundle and declares no expected keys | path: %s',\n entry.path,\n );\n }\n }\n\n protected mergeSecretsIntoEnv(opts: {\n bundle: Record<string, string>;\n entry: ISecretHydrateEntry;\n }): Record<string, string> {\n const { bundle, entry } = opts;\n const merged = selectSecretEnvKeys({ bundle, entry });\n\n const mergedEntries = Object.entries(merged);\n\n for (const [key, value] of mergedEntries) {\n process.env[key] = value;\n }\n\n applicationEnvironment.merge({ envs: merged });\n\n return merged;\n }\n\n /** A hydrate entry declares an expectation only via explicit `keys` or a non-empty `prefix`; such an entry resolving to zero env values is a misconfiguration boot must not silently absorb. */\n protected hydrateEntryDeclaresExpectation(opts: { entry: ISecretHydrateEntry }): boolean {\n const { entry } = opts;\n\n if (entry.keys && Object.keys(entry.keys).length > 0) {\n return true;\n }\n\n return typeof entry.prefix === 'string' && entry.prefix.length > 0;\n }\n\n async wireSecretRotatables(): Promise<void> {\n const logger = this.logger.for(this.wireSecretRotatables.name);\n const provider = this.secretsProvider;\n const registration = this.secretsRegistration;\n\n if (!provider || !registration?.lease?.length) {\n return;\n }\n\n for (const entry of registration.lease) {\n const instance = this.get({\n key: BindingKeys.build<ISecretRotatable>({ key: entry.key }),\n isOptional: true,\n });\n\n if (instance && typeof instance.onSecretRotated === 'function') {\n provider.registerRotatable({ key: entry.key, target: instance });\n logger.info('Wired rotatable | key: %s', entry.key);\n continue;\n }\n\n logger.debug('Lease key has no rotatable consumer | key: %s', entry.key);\n }\n }\n\n static(opts: { restPath?: string; folderPath: string }) {\n const { restPath = '*', folderPath } = opts;\n const server = this.getServer();\n\n server.use(restPath, serveStatic({ root: folderPath }));\n\n this.logger\n .for(this.static.name)\n .debug(\n 'Registered static files | runtime: %s | path: %s | folder: %s',\n this.runtime,\n restPath,\n folderPath,\n );\n\n return this;\n }\n\n /**\n * Every value is read HERE, not destructured at module load: an application that loads its\n * `.env` in its own entrypoint does so after this module is imported, and a module-load snapshot\n * would print the defaults for a host that configured everything correctly.\n */\n protected printStartUpInfo(opts: { scope: string }) {\n const { scope } = opts;\n const read = (key: string, fallback: string): string =>\n ParseUtility.blankToUndefined({ input: process.env[key] }) ?? fallback;\n const divider = '------------------------------------------------------------------------';\n\n this.logger.for(scope).info(divider);\n this.logger\n .for(scope)\n .info(\n 'Starting application... | Name: %s | Env: %s | Runtime: %s',\n read(EnvironmentKeys.APP_ENV_APPLICATION_NAME, 'PNT'),\n Environment.ambient,\n this.runtime,\n );\n this.logger\n .for(scope)\n .info(\n 'AllowEmptyEnv: %s | Prefix: %s',\n read('ALLOW_EMPTY_ENV_VALUE', 'true'),\n read('APPLICATION_ENV_PREFIX', 'APP_ENV'),\n );\n this.logger.for(scope).info('RunMode: %s', process.env.RUN_MODE);\n this.logger\n .for(scope)\n .info(\n 'Timezone: %s',\n read(EnvironmentKeys.APP_ENV_APPLICATION_TIMEZONE, DEFAULT_TEMPORAL_TZ),\n );\n this.logger\n .for(scope)\n .info('LogPath: %s', read(EnvironmentKeys.APP_ENV_LOGGER_FOLDER_PATH, './'));\n this.logger.for(scope).info(divider);\n }\n\n /** Swaps in the `ErrorPrettier`-backed formatter - `node:util`, so the kernel cannot build it. */\n protected override buildErrorMiddleware(): AppErrorMiddleware {\n return new AppErrorMiddleware({\n logger: this.logger,\n rootKey: this.configs.error?.rootKey ?? undefined,\n });\n }\n\n /** Adds what only a listening server has, on top of the kernel's three - which stay in `RestApplication` so a browser Worker answers with the same envelope. */\n protected override async registerDefaultMiddlewares() {\n await PerformanceUtility.executeWithMeasure({\n logger: this.logger,\n scope: this.registerDefaultMiddlewares.name,\n description: 'Register default application server handler',\n task: async () => {\n const server = this.getServer();\n\n await super.registerDefaultMiddlewares();\n\n // Always installed, not only under `asyncContext.enable`: `tryGetContext()` answers \"no context\"\n // without a store, and a `contextStorage()` the application registered itself stays visible to\n // the enrichers. Inside a method body because every package declares `sideEffects: false`.\n RequestContextRegistry.setResolver({ resolver: () => tryGetContext() });\n\n if (this.configs.asyncContext?.enable) {\n server.use(contextStorage());\n }\n\n // Request-body parsing and the access log; the request id it reads is already installed\n // above (also works around the Bun + Hono body-parsing bug: https://github.com/honojs/middleware/issues/81).\n this.component(RequestTrackerComponent);\n\n server.use(EmojiFaviconMiddleware.create({ icon: this.configs.favicon ?? '🔥' }));\n },\n });\n }\n\n /** Lives here rather than on `AbstractApplication` - `applicationEnvironment` reads `process.env` at module load, so a kernel-pure ancestor cannot carry it; this is the layer that already depends on it. */\n protected validateEnvs() {\n const t = performance.now();\n const envKeys = applicationEnvironment.keys();\n\n // Permissive by DEFAULT: a name a host leaves empty is the host's business, and an empty value\n // already falls back to `defaultValue` at read time, so refusing to boot over one fights the\n // reader rather than helping it. Set ALLOW_EMPTY_ENV_VALUE to `false` or `0` to turn the check\n // on. Read once rather than per key, and a blank value reads as unset - the same rule every\n // other env read follows.\n const configured = ParseUtility.blankToUndefined({ input: process.env.ALLOW_EMPTY_ENV_VALUE });\n const allowsEmpty = configured === undefined || ParseUtility.toBoolean({ input: configured });\n\n this.logger\n .for(this.initialize.name)\n .info(\n 'Envs: %s | START Validating application environments | Empty values: %s',\n envKeys.length,\n allowsEmpty ? 'ALLOWED (default)' : 'REJECTED',\n );\n\n if (allowsEmpty) {\n this.logger\n .for(this.validateEnvs.name)\n .info(\n 'Envs: %s | SKIPPED - set ALLOW_EMPTY_ENV_VALUE=false to reject empty values',\n envKeys.length,\n );\n\n return;\n }\n\n for (const argKey of envKeys) {\n const argValue = applicationEnvironment.get(argKey);\n\n if (!ObjectUtility.isEmpty({ value: argValue })) {\n continue;\n }\n\n throw getError({\n message: `[validateEnvs] Invalid Application Environment! Key: ${argKey} | Value: ${argValue}`,\n });\n }\n\n this.logger\n .for(this.validateEnvs.name)\n .info(\n 'Envs: %s | DONE Validating application environments | Took: %s (ms)',\n envKeys.length,\n performance.now() - t,\n );\n }\n\n /**\n * Version tripwire, body identical to `RestApplication.initialize()`: a stale kernel without\n * `getBootSequence()`/`runBootSequence()` throws here before any socket binds.\n */\n override async initialize(): Promise<void> {\n await ServerLoggerStartup.selectDefault();\n await this.runBootSequence({ steps: this.getBootSequence() });\n }\n\n protected override getBootSequence(): IBootSequenceStep[] {\n const steps: IBootSequenceStep[] = [\n {\n name: ServerBootSteps.PRINT_START_UP_INFO,\n run: () => this.printStartUpInfo({ scope: this.initialize.name }),\n },\n { name: ServerBootSteps.VALIDATE_ENVS, run: () => this.validateEnvs() },\n {\n name: ServerBootSteps.REGISTER_DEFAULT_MIDDLEWARES,\n run: () => this.registerDefaultMiddlewares(),\n },\n ...super.getBootSequence(),\n ];\n\n const withHydrate = BootSequence.insertAfter({\n steps,\n target: ServerBootSteps.PRE_CONFIGURE,\n step: { name: ServerBootSteps.HYDRATE_SECRETS, run: () => this.hydrateSecrets() },\n });\n\n // Components can contribute datasources, so wire rotatables only after the contributed sweep -\n // a lease key pointing at a component-contributed datasource would otherwise resolve to nothing.\n const withRotatables = BootSequence.insertAfter({\n steps: withHydrate,\n target: ServerBootSteps.REGISTER_CONTRIBUTED_DATA_SOURCES,\n step: {\n name: ServerBootSteps.WIRE_SECRET_ROTATABLES,\n run: () => this.wireSecretRotatables(),\n },\n });\n\n return [\n ...withRotatables,\n // Last, so a model registered by a component is covered too.\n {\n name: ServerBootSteps.VALIDATE_SCOPE_FILTER_SUPPORT,\n run: () => this.validateScopeFilterSupport(),\n },\n ];\n }\n\n /**\n * Refuses to start when a model's `settings.access` cannot take effect. Both failures are\n * silent at runtime and opposite: a search-backed model returns too many rows, a context-less one none.\n */\n protected validateScopeFilterSupport(): void {\n ScopeFilterUtility.assertScopeFilterSupported({\n asyncContextEnabled: this.configs.asyncContext?.enable ?? false,\n logger: this.logger,\n });\n }\n}\n"]}
@@ -78,7 +78,7 @@ export class RequestSpyMiddleware extends BaseHelper {
78
78
  const { req } = context;
79
79
  const requestId = context.get(RequestSpyMiddleware.REQUEST_ID_KEY);
80
80
  const incomingIp = NetworkUtility.getIncomingIp(context);
81
- const forwardedIp = req.header('x-real-ip') ?? req.header('x-forwarded-for') ?? null;
81
+ const forwardedIp = req.header(HTTP.Headers.X_REAL_IP) ?? req.header(HTTP.Headers.X_FORWARDED_FOR) ?? null;
82
82
  const method = req.method;
83
83
  const path = req.path ?? '/';
84
84
  // 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.
@@ -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,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,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ED,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, 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
+ {"version":3,"file":"request-spy.middleware.js","sourceRoot":"","sources":["../../../../../src/base/middlewares/request-spy/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ia/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 =\n req.header(HTTP.Headers.X_REAL_IP) ?? req.header(HTTP.Headers.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,5 +1,6 @@
1
+ import type { IApiReferenceOptions } from './types.js';
1
2
  /** Container keys of the API reference component. */
2
3
  export declare class ApiReferenceBindingKeys {
3
- static readonly API_REFERENCE_OPTIONS = "@app/api-reference/options";
4
+ static readonly API_REFERENCE_OPTIONS: import("@venizia/ignis-inversion").TBindingKey<IApiReferenceOptions>;
4
5
  }
5
6
  //# sourceMappingURL=keys.d.ts.map
@@ -1,5 +1,8 @@
1
+ import { BindingKeys } from '@venizia/ignis-inversion';
1
2
  /** Container keys of the API reference component. */
2
3
  export class ApiReferenceBindingKeys {
3
- static { this.API_REFERENCE_OPTIONS = '@app/api-reference/options'; }
4
+ static { this.API_REFERENCE_OPTIONS = BindingKeys.build({
5
+ key: '@app/api-reference/options',
6
+ }); }
4
7
  }
5
8
  //# sourceMappingURL=keys.js.map
@@ -1 +1 @@
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
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/api-reference/common/keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,qDAAqD;AACrD,MAAM,OAAO,uBAAuB;aAClB,0BAAqB,GAAG,WAAW,CAAC,KAAK,CAAuB;QAC9E,GAAG,EAAE,4BAA4B;KAClC,CAAC,CAAC","sourcesContent":["import { BindingKeys } from '@venizia/ignis-inversion';\nimport type { IApiReferenceOptions } from './types';\n\n/** Container keys of the API reference component. */\nexport class ApiReferenceBindingKeys {\n static readonly API_REFERENCE_OPTIONS = BindingKeys.build<IApiReferenceOptions>({\n key: '@app/api-reference/options',\n });\n}\n"]}
@@ -1,6 +1,9 @@
1
+ import type { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
1
2
  import type { Context, Next } from 'hono';
2
3
  import type { DocumentUITypes } from './constants.js';
3
4
  import type { TConstValue } from '@venizia/ignis-helpers/common';
5
+ /** An OpenAPI security scheme (`apiKey`, `http`, `oauth2`, `openIdConnect`) or a reference to one, as the document registry takes it. */
6
+ export type TApiReferenceSecurityScheme = Parameters<typeof OpenAPIRegistry.prototype.registerComponent<'securitySchemes'>>[2];
4
7
  /** One of the `DocumentUITypes` values. */
5
8
  export type TDocumentUIType = TConstValue<typeof DocumentUITypes>;
6
9
  /**
@@ -12,7 +15,7 @@ export type TDocumentUIType = TConstValue<typeof DocumentUITypes>;
12
15
  *
13
16
  * export const bindApiReference = (application: BaseApplication) => {
14
17
  * application
15
- * .bind<IApiReferenceOptions>({ key: ApiReferenceBindingKeys.API_REFERENCE_OPTIONS })
18
+ * .bind({ key: ApiReferenceBindingKeys.API_REFERENCE_OPTIONS })
16
19
  * .toValue({ restOptions: { base: { path: '/docs' }, ui: { type: 'swagger' } } });
17
20
  * };
18
21
  * ```
@@ -46,8 +49,8 @@ export interface IApiReferenceOptions {
46
49
  description?: string;
47
50
  }>;
48
51
  };
49
- uiConfig?: Record<string, any>;
50
- securitySchemes?: Record<string, Record<string, any>>;
52
+ uiConfig?: Record<string, unknown>;
53
+ securitySchemes?: Record<string, TApiReferenceSecurityScheme>;
51
54
  }
52
55
  /** Renders the interactive API documentation page for the OpenAPI document. Register an implementation on `UIProviderFactory` to serve a custom UI. */
53
56
  export interface IUIProvider {
@@ -57,7 +60,7 @@ export interface IUIProvider {
57
60
  export interface IUIConfig {
58
61
  title: string;
59
62
  url: string;
60
- [key: string]: any;
63
+ [key: string]: unknown;
61
64
  }
62
65
  /** Selects a registered UI provider by its type name. */
63
66
  export interface IGetProviderParams {
@@ -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\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
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/components/api-reference/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';\nimport type { Context, Next } from 'hono';\nimport type { DocumentUITypes } from './constants';\nimport type { TConstValue } from '@venizia/ignis-helpers/common';\n\n/** An OpenAPI security scheme (`apiKey`, `http`, `oauth2`, `openIdConnect`) or a reference to one, as the document registry takes it. */\nexport type TApiReferenceSecurityScheme = Parameters<\n typeof OpenAPIRegistry.prototype.registerComponent<'securitySchemes'>\n>[2];\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({ 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, unknown>;\n securitySchemes?: Record<string, TApiReferenceSecurityScheme>;\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]: unknown;\n}\n\n/** Selects a registered UI provider by its type name. */\nexport interface IGetProviderParams {\n type: string;\n}\n"]}
@@ -18,6 +18,7 @@ import { Authentication } from '../auth/index.js';
18
18
  import { ServiceAssertion } from '@venizia/ignis-kernel';
19
19
  import { ApiReferenceBindingKeys, DocumentUITypes } from './common/index.js';
20
20
  import { UIProviderFactory } from './ui/index.js';
21
+ const DEFAULT_OPENAPI_VERSION = '3.0.0';
21
22
  const DEFAULT_API_REFERENCE_OPTIONS = {
22
23
  restOptions: {
23
24
  base: { path: '/doc' },
@@ -25,7 +26,7 @@ const DEFAULT_API_REFERENCE_OPTIONS = {
25
26
  ui: { path: '/explorer', type: 'scalar' },
26
27
  },
27
28
  explorer: {
28
- openapi: '3.0.0',
29
+ openapi: DEFAULT_OPENAPI_VERSION,
29
30
  info: {
30
31
  title: 'API Documentation',
31
32
  version: '1.0.0',
@@ -88,7 +89,7 @@ let ApiReferenceComponent = ApiReferenceComponent_1 = class ApiReferenceComponen
88
89
  const rootRouter = this.application.getRootRouter();
89
90
  const configs = this.application.getProjectConfigs();
90
91
  const appInfo = await this.application.getAppInfo();
91
- explorer.info = {
92
+ const info = {
92
93
  title: appInfo.name,
93
94
  version: appInfo.version,
94
95
  description: appInfo.description,
@@ -104,7 +105,11 @@ let ApiReferenceComponent = ApiReferenceComponent_1 = class ApiReferenceComponen
104
105
  }
105
106
  const docPath = joinRestPath([restOptions.base.path, restOptions.doc.path]);
106
107
  const uiPath = joinRestPath([restOptions.base.path, restOptions.ui.path]);
107
- rootRouter.doc(docPath, explorer);
108
+ rootRouter.doc(docPath, {
109
+ ...explorer,
110
+ openapi: explorer.openapi ?? DEFAULT_OPENAPI_VERSION,
111
+ info,
112
+ });
108
113
  const uiType = restOptions.ui.type ?? DocumentUITypes.SWAGGER;
109
114
  const uiProviderFactory = UIProviderFactory.getInstance();
110
115
  // A custom provider registered on the factory is honoured; only unknown types are rejected.
@@ -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,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;KACF;CACF,CAAC;AAEF,gGAAgG;AAChG,MAAM,YAAY,GAAG,CAAC,QAAmC,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,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
+ {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/components/api-reference/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,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,uBAAuB,GAAG,OAAO,CAAC;AAExC,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,uBAAuB;QAChC,IAAI,EAAE;YACJ,KAAK,EAAE,mBAAmB;YAC1B,OAAO,EAAE,OAAO;YAChB,WAAW,EAAE,oCAAoC;SAClD;KACF;CACF,CAAC;AAEF,gGAAgG;AAChG,MAAM,YAAY,GAAG,CAAC,QA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AAC,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,MAAM,CAAC,CAAC;QAChF,CAAC;IACH,CAAC;CACF,CAAA;AApHY,qBAAqB;IAE7B,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAA;;GAF1C,qBAAqB,CAoHjC","sourcesContent":["import { type BaseApplication } from '@/base/applications';\nimport { inject } from '@/base/metadata';\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_OPENAPI_VERSION = '3.0.0';\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: DEFAULT_OPENAPI_VERSION,\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({\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({\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 const 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, {\n ...explorer,\n openapi: explorer.openapi ?? DEFAULT_OPENAPI_VERSION,\n info,\n });\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);\n }\n }\n}\n"]}
@@ -63,6 +63,7 @@ let AuthenticateComponent = AuthenticateComponent_1 = class AuthenticateComponen
63
63
  }
64
64
  const options = { restOptions, jwtOptions, basicOptions, serviceOptions };
65
65
  if (jwtOptions) {
66
+ const standard = jwtOptions.standard;
66
67
  switch (jwtOptions.standard) {
67
68
  case JOSEStandards.JWS: {
68
69
  this.defineJWSAuth({ options: jwtOptions.options });
@@ -74,7 +75,7 @@ let AuthenticateComponent = AuthenticateComponent_1 = class AuthenticateComponen
74
75
  }
75
76
  default: {
76
77
  throw getError({
77
- message: `[AuthenticateComponent] Unknown JOSE standard: ${jwtOptions.standard}`,
78
+ message: `[AuthenticateComponent] Unknown JOSE standard: ${standard}`,
78
79
  });
79
80
  }
80
81
  }
@@ -126,9 +127,7 @@ let AuthenticateComponent = AuthenticateComponent_1 = class AuthenticateComponen
126
127
  pinnedAlgorithms: [jwsOptions.headerAlgorithm ?? 'HS256'],
127
128
  });
128
129
  JWSTokenService.assertSecretStrength({ scope: 'defineJWSAuth', secret: jwtSecret });
129
- this.application
130
- .bind({ key: AuthenticateBindingKeys.JWT_OPTIONS })
131
- .toValue(jwsOptions);
130
+ this.application.bind({ key: AuthenticateBindingKeys.JWS_OPTIONS }).toValue(jwsOptions);
132
131
  this.application.service(JWSTokenService);
133
132
  this.logger.for(this.defineJWSAuth.name).info('JWS authentication configured');
134
133
  }
@@ -161,7 +160,7 @@ let AuthenticateComponent = AuthenticateComponent_1 = class AuthenticateComponen
161
160
  pinnedAlgorithms: [issuerOpts.algorithm],
162
161
  });
163
162
  this.application
164
- .bind({ key: AuthenticateBindingKeys.JWKS_OPTIONS })
163
+ .bind({ key: AuthenticateBindingKeys.JWKS_ISSUER_OPTIONS })
165
164
  .toValue(issuerOpts);
166
165
  this.application.service(JWKSIssuerTokenService);
167
166
  // Path depends on a runtime option, so @controller can't be applied statically — decorate here instead.
@@ -185,10 +184,10 @@ let AuthenticateComponent = AuthenticateComponent_1 = class AuthenticateComponen
185
184
  scope: 'defineJWKSAuth',
186
185
  label: 'jwksUrl',
187
186
  url: verifierOpts.jwksUrl,
188
- hosts: verifierOpts.jwks?.hosts?.http,
187
+ trusted: verifierOpts.jwks?.trusted,
189
188
  });
190
189
  this.application
191
- .bind({ key: AuthenticateBindingKeys.JWKS_OPTIONS })
190
+ .bind({ key: AuthenticateBindingKeys.JWKS_VERIFIER_OPTIONS })
192
191
  .toValue(verifierOpts);
193
192
  this.application.service(JWKSVerifierTokenService);
194
193
  this.logger.for(this.defineJWKSAuth.name).info('JWKS verifier configured');
@@ -228,26 +227,24 @@ let AuthenticateComponent = AuthenticateComponent_1 = class AuthenticateComponen
228
227
  message: '[defineServiceAuth] resolvePrincipal is required | the framework proves WHICH SERVICE called, the application decides who that acts as',
229
228
  });
230
229
  }
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({
230
+ // A caller's key set decides who may call: https, loopback, or an origin listed in jwks.trusted. Checked at boot, so a bad URL never waits for its first request.
231
+ JWKSUrlPolicy.resolveTrustedOrigins({
233
232
  scope: 'defineServiceAuth',
234
- hosts: serviceOptions.jwks?.hosts?.http,
233
+ trusted: serviceOptions.jwks?.trusted,
235
234
  });
236
235
  for (const [caller, entry] of Object.entries(serviceOptions.callers ?? {})) {
237
236
  JWKSUrlPolicy.assertUrl({
238
237
  scope: 'defineServiceAuth',
239
238
  label: `callers[${JSON.stringify(caller)}].jwksUrl`,
240
239
  url: typeof entry === 'string' ? entry : entry.jwksUrl,
241
- hosts: serviceOptions.jwks?.hosts?.http,
240
+ trusted: serviceOptions.jwks?.trusted,
242
241
  });
243
242
  }
244
243
  this.application.service(ServiceAssertionVerifierService);
245
244
  if (serviceOptions.keys) {
246
245
  this.application.service(ServiceAssertionSignerService);
247
246
  const restPath = serviceOptions.rest?.path ?? ServiceAssertion.DEFAULT_REST_PATH;
248
- this.application
249
- .bind({ key: AuthenticateBindingKeys.SERVICE_CERTS_PATH })
250
- .toValue(restPath);
247
+ this.application.bind({ key: AuthenticateBindingKeys.SERVICE_CERTS_PATH }).toValue(restPath);
251
248
  // Path depends on a runtime option, so @controller cannot be applied statically.
252
249
  Reflect.decorate([controller({ path: restPath })], ServiceCertsController);
253
250
  this.application.controller(ServiceCertsController);
@@ -275,9 +272,7 @@ let AuthenticateComponent = AuthenticateComponent_1 = class AuthenticateComponen
275
272
  message: '[defineBasicAuth] verifyCredentials function is required',
276
273
  });
277
274
  }
278
- this.application
279
- .bind({ key: AuthenticateBindingKeys.BASIC_OPTIONS })
280
- .toValue(basicOptions);
275
+ this.application.bind({ key: AuthenticateBindingKeys.BASIC_OPTIONS }).toValue(basicOptions);
281
276
  this.application.service(BasicTokenService);
282
277
  this.logger.for(this.defineBasicAuth.name).info('Basic authentication configured');
283
278
  }
@@ -292,7 +287,7 @@ let AuthenticateComponent = AuthenticateComponent_1 = class AuthenticateComponen
292
287
  message: '[defineControllers] Auth controller requires jwtOptions to be configured',
293
288
  });
294
289
  }
295
- const AuthController = AuthControllerFactory.define(restOptions.controllerOpts);
290
+ const AuthController = AuthControllerFactory.build(restOptions.controllerOpts);
296
291
  this.application.controller(AuthController);
297
292
  this.logger.for(this.defineControllers.name).info('Auth controller registered');
298
293
  }