@venizia/ignis 0.4.7-8 → 0.4.8-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 +3 -1
  2. package/dist/esm/base/applications/base.js.map +1 -1
  3. package/dist/esm/base/applications/server.js.map +1 -1
  4. package/dist/esm/base/controllers/grpc/abstract.js.map +1 -1
  5. package/dist/esm/base/controllers/grpc/adapter.js.map +1 -1
  6. package/dist/esm/base/controllers/grpc/base.js.map +1 -1
  7. package/dist/esm/base/middlewares/request-spy/request-spy.middleware.js.map +1 -1
  8. package/dist/esm/components/api-reference/component.js.map +1 -1
  9. package/dist/esm/components/api-reference/ui/factory.js.map +1 -1
  10. package/dist/esm/components/api-reference/ui/scalar.js.map +1 -1
  11. package/dist/esm/components/api-reference/ui/swagger.js.map +1 -1
  12. package/dist/esm/components/auth/authenticate/component.js.map +1 -1
  13. package/dist/esm/components/auth/authenticate/controllers/factory.js.map +1 -1
  14. package/dist/esm/components/auth/authenticate/controllers/jwks/controller.js.map +1 -1
  15. package/dist/esm/components/auth/authenticate/controllers/service-certs/controller.js.map +1 -1
  16. package/dist/esm/components/auth/authenticate/services/basic/service.js.map +1 -1
  17. package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js.map +1 -1
  18. package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.js.map +1 -1
  19. package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.js.map +1 -1
  20. package/dist/esm/components/auth/authenticate/services/bearer/jws.service.js.map +1 -1
  21. package/dist/esm/components/auth/authenticate/services/jose-loader.js.map +1 -1
  22. package/dist/esm/components/auth/authenticate/services/service/signer.service.js.map +1 -1
  23. package/dist/esm/components/auth/authenticate/services/service/verifier.service.js.map +1 -1
  24. package/dist/esm/components/auth/authenticate/strategies/basic.strategy.js.map +1 -1
  25. package/dist/esm/components/auth/authenticate/strategies/jwks/issuer.js.map +1 -1
  26. package/dist/esm/components/auth/authenticate/strategies/jwks/verifier.js.map +1 -1
  27. package/dist/esm/components/auth/authenticate/strategies/jws.strategy.js.map +1 -1
  28. package/dist/esm/components/auth/authenticate/strategies/service.strategy.js.map +1 -1
  29. package/dist/esm/components/auth/authorize/adapters/base-filtered.js.map +1 -1
  30. package/dist/esm/components/auth/authorize/adapters/custom-grant-expander.js.map +1 -1
  31. package/dist/esm/components/auth/authorize/adapters/scoped-casbin/adapter.js.map +1 -1
  32. package/dist/esm/components/auth/authorize/enforcers/casbin-module.js.map +1 -1
  33. package/dist/esm/components/auth/authorize/enforcers/casbin.enforcer.js.map +1 -1
  34. package/dist/esm/components/auth/authorize/enforcers/policy-line-codec.js.map +1 -1
  35. package/dist/esm/components/auth/authorize/enforcers/user-policy-line-cache.js.map +1 -1
  36. package/dist/esm/components/auth/authorize/role-managers/base.js.map +1 -1
  37. package/dist/esm/components/auth/authorize/role-managers/domain-hierarchy.js.map +1 -1
  38. package/dist/esm/components/auth/authorize/role-managers/membership.js.map +1 -1
  39. package/dist/esm/components/auth/authorize/role-managers/resource.js.map +1 -1
  40. package/dist/esm/components/controller/grpc/grpc.component.js.map +1 -1
  41. package/dist/esm/components/health-check/controller.js.map +1 -1
  42. package/dist/esm/components/health-check/reporter.js.map +1 -1
  43. package/dist/esm/components/mail/common/constants.js.map +1 -1
  44. package/dist/esm/components/mail/common/keys.js.map +1 -1
  45. package/dist/esm/components/mail/component.js.map +1 -1
  46. package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.js.map +1 -1
  47. package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.js.map +1 -1
  48. package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.js.map +1 -1
  49. package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.js.map +1 -1
  50. package/dist/esm/components/mail/providers/mail-queue-executor.provider.js.map +1 -1
  51. package/dist/esm/components/mail/providers/mail-transporter.provider.js.map +1 -1
  52. package/dist/esm/components/mail/services/generators/numeric-code.js.map +1 -1
  53. package/dist/esm/components/mail/services/mail.service.js.map +1 -1
  54. package/dist/esm/components/mail/services/template.service.js.map +1 -1
  55. package/dist/esm/components/mail/utilities/address.utility.js.map +1 -1
  56. package/dist/esm/components/mail/utilities/attachment.utility.js.map +1 -1
  57. package/dist/esm/components/mail/utilities/mime.utility.js.map +1 -1
  58. package/dist/esm/components/socket-io/component.js.map +1 -1
  59. package/dist/esm/components/static-asset/common/commit-token.js.map +1 -1
  60. package/dist/esm/components/static-asset/component.js.map +1 -1
  61. package/dist/esm/components/static-asset/controller/factory.js.map +1 -1
  62. package/dist/esm/components/static-asset/controller/meta-link.js.map +1 -1
  63. package/dist/esm/components/static-asset/controller/route-options.js.map +1 -1
  64. package/dist/esm/components/websocket/component.js.map +1 -1
  65. package/dist/esm/testing/assert-application-boots.js.map +1 -1
  66. package/dist/presets/app/files/.configs/builders/compile.ts +3 -1
  67. package/dist/presets/app/files/_env.example +1 -1
  68. package/dist/presets/app/files/src/smoke.test.ts +14 -8
  69. package/dist/presets/app/preset.json +4 -4
  70. package/dist/presets/lib/preset.json +3 -3
  71. package/dist/presets/shared/preset.json +1 -1
  72. package/package.json +10 -10
  73. package/dist/esm/base/applications/base.d.ts.map +0 -1
  74. package/dist/esm/base/applications/boot-steps.d.ts.map +0 -1
  75. package/dist/esm/base/applications/common/index.d.ts.map +0 -1
  76. package/dist/esm/base/applications/common/logger-startup.d.ts.map +0 -1
  77. package/dist/esm/base/applications/common/types.d.ts.map +0 -1
  78. package/dist/esm/base/applications/index.d.ts.map +0 -1
  79. package/dist/esm/base/applications/server.d.ts.map +0 -1
  80. package/dist/esm/base/controllers/grpc/abstract.d.ts.map +0 -1
  81. package/dist/esm/base/controllers/grpc/adapter.d.ts.map +0 -1
  82. package/dist/esm/base/controllers/grpc/base.d.ts.map +0 -1
  83. package/dist/esm/base/controllers/grpc/common/index.d.ts.map +0 -1
  84. package/dist/esm/base/controllers/grpc/common/types.d.ts.map +0 -1
  85. package/dist/esm/base/controllers/grpc/index.d.ts.map +0 -1
  86. package/dist/esm/base/controllers/index.d.ts.map +0 -1
  87. package/dist/esm/base/index.d.ts.map +0 -1
  88. package/dist/esm/base/metadata/index.d.ts.map +0 -1
  89. package/dist/esm/base/metadata/request-context.d.ts.map +0 -1
  90. package/dist/esm/base/middlewares/app-error/app-error.middleware.d.ts.map +0 -1
  91. package/dist/esm/base/middlewares/app-error/index.d.ts.map +0 -1
  92. package/dist/esm/base/middlewares/index.d.ts.map +0 -1
  93. package/dist/esm/base/middlewares/request-spy/index.d.ts.map +0 -1
  94. package/dist/esm/base/middlewares/request-spy/request-spy.middleware.d.ts.map +0 -1
  95. package/dist/esm/common/environments.d.ts.map +0 -1
  96. package/dist/esm/common/index.d.ts.map +0 -1
  97. package/dist/esm/components/api-reference/common/constants.d.ts.map +0 -1
  98. package/dist/esm/components/api-reference/common/index.d.ts.map +0 -1
  99. package/dist/esm/components/api-reference/common/keys.d.ts.map +0 -1
  100. package/dist/esm/components/api-reference/common/types.d.ts.map +0 -1
  101. package/dist/esm/components/api-reference/component.d.ts.map +0 -1
  102. package/dist/esm/components/api-reference/index.d.ts.map +0 -1
  103. package/dist/esm/components/api-reference/ui/factory.d.ts.map +0 -1
  104. package/dist/esm/components/api-reference/ui/index.d.ts.map +0 -1
  105. package/dist/esm/components/api-reference/ui/scalar.d.ts.map +0 -1
  106. package/dist/esm/components/api-reference/ui/swagger.d.ts.map +0 -1
  107. package/dist/esm/components/auth/authenticate/component.d.ts.map +0 -1
  108. package/dist/esm/components/auth/authenticate/controllers/factory.d.ts.map +0 -1
  109. package/dist/esm/components/auth/authenticate/controllers/index.d.ts.map +0 -1
  110. package/dist/esm/components/auth/authenticate/controllers/jwks/controller.d.ts.map +0 -1
  111. package/dist/esm/components/auth/authenticate/controllers/jwks/definitions.d.ts.map +0 -1
  112. package/dist/esm/components/auth/authenticate/controllers/jwks/index.d.ts.map +0 -1
  113. package/dist/esm/components/auth/authenticate/controllers/service-certs/controller.d.ts.map +0 -1
  114. package/dist/esm/components/auth/authenticate/controllers/service-certs/definitions.d.ts.map +0 -1
  115. package/dist/esm/components/auth/authenticate/controllers/service-certs/index.d.ts.map +0 -1
  116. package/dist/esm/components/auth/authenticate/index.d.ts.map +0 -1
  117. package/dist/esm/components/auth/authenticate/services/basic/index.d.ts.map +0 -1
  118. package/dist/esm/components/auth/authenticate/services/basic/service.d.ts.map +0 -1
  119. package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.d.ts.map +0 -1
  120. package/dist/esm/components/auth/authenticate/services/bearer/index.d.ts.map +0 -1
  121. package/dist/esm/components/auth/authenticate/services/bearer/jwks/abstract.service.d.ts.map +0 -1
  122. package/dist/esm/components/auth/authenticate/services/bearer/jwks/index.d.ts.map +0 -1
  123. package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.d.ts.map +0 -1
  124. package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.d.ts.map +0 -1
  125. package/dist/esm/components/auth/authenticate/services/bearer/jws.service.d.ts.map +0 -1
  126. package/dist/esm/components/auth/authenticate/services/index.d.ts.map +0 -1
  127. package/dist/esm/components/auth/authenticate/services/jose-loader.d.ts.map +0 -1
  128. package/dist/esm/components/auth/authenticate/services/service/index.d.ts.map +0 -1
  129. package/dist/esm/components/auth/authenticate/services/service/signer.service.d.ts.map +0 -1
  130. package/dist/esm/components/auth/authenticate/services/service/verifier.service.d.ts.map +0 -1
  131. package/dist/esm/components/auth/authenticate/strategies/basic.strategy.d.ts.map +0 -1
  132. package/dist/esm/components/auth/authenticate/strategies/index.d.ts.map +0 -1
  133. package/dist/esm/components/auth/authenticate/strategies/jwks/index.d.ts.map +0 -1
  134. package/dist/esm/components/auth/authenticate/strategies/jwks/issuer.d.ts.map +0 -1
  135. package/dist/esm/components/auth/authenticate/strategies/jwks/verifier.d.ts.map +0 -1
  136. package/dist/esm/components/auth/authenticate/strategies/jws.strategy.d.ts.map +0 -1
  137. package/dist/esm/components/auth/authenticate/strategies/service.strategy.d.ts.map +0 -1
  138. package/dist/esm/components/auth/authorize/adapters/base-filtered.d.ts.map +0 -1
  139. package/dist/esm/components/auth/authorize/adapters/common/index.d.ts.map +0 -1
  140. package/dist/esm/components/auth/authorize/adapters/common/types.d.ts.map +0 -1
  141. package/dist/esm/components/auth/authorize/adapters/connector.d.ts.map +0 -1
  142. package/dist/esm/components/auth/authorize/adapters/custom-grant-expander.d.ts.map +0 -1
  143. package/dist/esm/components/auth/authorize/adapters/index.d.ts.map +0 -1
  144. package/dist/esm/components/auth/authorize/adapters/scoped-casbin/adapter.d.ts.map +0 -1
  145. package/dist/esm/components/auth/authorize/adapters/scoped-casbin/common/constants.d.ts.map +0 -1
  146. package/dist/esm/components/auth/authorize/adapters/scoped-casbin/common/index.d.ts.map +0 -1
  147. package/dist/esm/components/auth/authorize/adapters/scoped-casbin/common/types.d.ts.map +0 -1
  148. package/dist/esm/components/auth/authorize/adapters/scoped-casbin/index.d.ts.map +0 -1
  149. package/dist/esm/components/auth/authorize/adapters/scoped-casbin/policy-edges.d.ts.map +0 -1
  150. package/dist/esm/components/auth/authorize/component.d.ts.map +0 -1
  151. package/dist/esm/components/auth/authorize/enforcers/casbin-module.d.ts.map +0 -1
  152. package/dist/esm/components/auth/authorize/enforcers/casbin.enforcer.d.ts.map +0 -1
  153. package/dist/esm/components/auth/authorize/enforcers/index.d.ts.map +0 -1
  154. package/dist/esm/components/auth/authorize/enforcers/models/index.d.ts.map +0 -1
  155. package/dist/esm/components/auth/authorize/enforcers/models/rbac-domain.model.d.ts.map +0 -1
  156. package/dist/esm/components/auth/authorize/enforcers/policy-line-codec.d.ts.map +0 -1
  157. package/dist/esm/components/auth/authorize/enforcers/user-policy-line-cache.d.ts.map +0 -1
  158. package/dist/esm/components/auth/authorize/index.d.ts.map +0 -1
  159. package/dist/esm/components/auth/authorize/role-managers/base.d.ts.map +0 -1
  160. package/dist/esm/components/auth/authorize/role-managers/domain-hierarchy.d.ts.map +0 -1
  161. package/dist/esm/components/auth/authorize/role-managers/index.d.ts.map +0 -1
  162. package/dist/esm/components/auth/authorize/role-managers/membership.d.ts.map +0 -1
  163. package/dist/esm/components/auth/authorize/role-managers/resource.d.ts.map +0 -1
  164. package/dist/esm/components/auth/index.d.ts.map +0 -1
  165. package/dist/esm/components/auth/models/entities/columns.d.ts.map +0 -1
  166. package/dist/esm/components/auth/models/entities/index.d.ts.map +0 -1
  167. package/dist/esm/components/auth/models/entities/permission.model.d.ts.map +0 -1
  168. package/dist/esm/components/auth/models/entities/policy-definition.model.d.ts.map +0 -1
  169. package/dist/esm/components/auth/models/index.d.ts.map +0 -1
  170. package/dist/esm/components/controller/grpc/common/index.d.ts.map +0 -1
  171. package/dist/esm/components/controller/grpc/common/types.d.ts.map +0 -1
  172. package/dist/esm/components/controller/grpc/grpc.component.d.ts.map +0 -1
  173. package/dist/esm/components/controller/grpc/index.d.ts.map +0 -1
  174. package/dist/esm/components/health-check/common/constants.d.ts.map +0 -1
  175. package/dist/esm/components/health-check/common/index.d.ts.map +0 -1
  176. package/dist/esm/components/health-check/common/keys.d.ts.map +0 -1
  177. package/dist/esm/components/health-check/common/rest-paths.d.ts.map +0 -1
  178. package/dist/esm/components/health-check/common/types.d.ts.map +0 -1
  179. package/dist/esm/components/health-check/component.d.ts.map +0 -1
  180. package/dist/esm/components/health-check/controller.d.ts.map +0 -1
  181. package/dist/esm/components/health-check/index.d.ts.map +0 -1
  182. package/dist/esm/components/health-check/reporter.d.ts.map +0 -1
  183. package/dist/esm/components/index.d.ts.map +0 -1
  184. package/dist/esm/components/mail/common/constants.d.ts.map +0 -1
  185. package/dist/esm/components/mail/common/errors.d.ts.map +0 -1
  186. package/dist/esm/components/mail/common/index.d.ts.map +0 -1
  187. package/dist/esm/components/mail/common/keys.d.ts.map +0 -1
  188. package/dist/esm/components/mail/common/types/index.d.ts.map +0 -1
  189. package/dist/esm/components/mail/common/types/message.d.ts.map +0 -1
  190. package/dist/esm/components/mail/common/types/options.d.ts.map +0 -1
  191. package/dist/esm/components/mail/common/types/queue.d.ts.map +0 -1
  192. package/dist/esm/components/mail/common/types/template.d.ts.map +0 -1
  193. package/dist/esm/components/mail/common/types/verification.d.ts.map +0 -1
  194. package/dist/esm/components/mail/component.d.ts.map +0 -1
  195. package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.d.ts.map +0 -1
  196. package/dist/esm/components/mail/helpers/executors/direct-executor.helper.d.ts.map +0 -1
  197. package/dist/esm/components/mail/helpers/executors/index.d.ts.map +0 -1
  198. package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.d.ts.map +0 -1
  199. package/dist/esm/components/mail/helpers/index.d.ts.map +0 -1
  200. package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.d.ts.map +0 -1
  201. package/dist/esm/components/mail/helpers/transporters/index.d.ts.map +0 -1
  202. package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.d.ts.map +0 -1
  203. package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.d.ts.map +0 -1
  204. package/dist/esm/components/mail/index.d.ts.map +0 -1
  205. package/dist/esm/components/mail/providers/index.d.ts.map +0 -1
  206. package/dist/esm/components/mail/providers/mail-queue-executor.provider.d.ts.map +0 -1
  207. package/dist/esm/components/mail/providers/mail-transporter.provider.d.ts.map +0 -1
  208. package/dist/esm/components/mail/services/generators/index.d.ts.map +0 -1
  209. package/dist/esm/components/mail/services/generators/numeric-code.d.ts.map +0 -1
  210. package/dist/esm/components/mail/services/generators/random-token.d.ts.map +0 -1
  211. package/dist/esm/components/mail/services/generators/verification-data.d.ts.map +0 -1
  212. package/dist/esm/components/mail/services/index.d.ts.map +0 -1
  213. package/dist/esm/components/mail/services/mail.service.d.ts.map +0 -1
  214. package/dist/esm/components/mail/services/template.service.d.ts.map +0 -1
  215. package/dist/esm/components/mail/utilities/address.utility.d.ts.map +0 -1
  216. package/dist/esm/components/mail/utilities/attachment.utility.d.ts.map +0 -1
  217. package/dist/esm/components/mail/utilities/body.utility.d.ts.map +0 -1
  218. package/dist/esm/components/mail/utilities/index.d.ts.map +0 -1
  219. package/dist/esm/components/mail/utilities/mime.utility.d.ts.map +0 -1
  220. package/dist/esm/components/mail/utilities/type.utility.d.ts.map +0 -1
  221. package/dist/esm/components/mail/utilities/verification.utility.d.ts.map +0 -1
  222. package/dist/esm/components/request-tracker/component.d.ts.map +0 -1
  223. package/dist/esm/components/request-tracker/index.d.ts.map +0 -1
  224. package/dist/esm/components/socket-io/common/index.d.ts.map +0 -1
  225. package/dist/esm/components/socket-io/common/keys.d.ts.map +0 -1
  226. package/dist/esm/components/socket-io/common/types.d.ts.map +0 -1
  227. package/dist/esm/components/socket-io/component.d.ts.map +0 -1
  228. package/dist/esm/components/socket-io/handlers/bun.handler.d.ts.map +0 -1
  229. package/dist/esm/components/socket-io/handlers/index.d.ts.map +0 -1
  230. package/dist/esm/components/socket-io/index.d.ts.map +0 -1
  231. package/dist/esm/components/static-asset/common/commit-token.d.ts.map +0 -1
  232. package/dist/esm/components/static-asset/common/constants.d.ts.map +0 -1
  233. package/dist/esm/components/static-asset/common/errors.d.ts.map +0 -1
  234. package/dist/esm/components/static-asset/common/index.d.ts.map +0 -1
  235. package/dist/esm/components/static-asset/common/keys.d.ts.map +0 -1
  236. package/dist/esm/components/static-asset/common/types.d.ts.map +0 -1
  237. package/dist/esm/components/static-asset/component.d.ts.map +0 -1
  238. package/dist/esm/components/static-asset/controller/base.definition.d.ts.map +0 -1
  239. package/dist/esm/components/static-asset/controller/factory.d.ts.map +0 -1
  240. package/dist/esm/components/static-asset/controller/index.d.ts.map +0 -1
  241. package/dist/esm/components/static-asset/controller/key-scope.d.ts.map +0 -1
  242. package/dist/esm/components/static-asset/controller/meta-link.d.ts.map +0 -1
  243. package/dist/esm/components/static-asset/controller/route-options.d.ts.map +0 -1
  244. package/dist/esm/components/static-asset/index.d.ts.map +0 -1
  245. package/dist/esm/components/static-asset/ingest.d.ts.map +0 -1
  246. package/dist/esm/components/static-asset/models/base.model.d.ts.map +0 -1
  247. package/dist/esm/components/static-asset/models/index.d.ts.map +0 -1
  248. package/dist/esm/components/static-asset/repositories/base.repository.d.ts.map +0 -1
  249. package/dist/esm/components/static-asset/repositories/index.d.ts.map +0 -1
  250. package/dist/esm/components/websocket/common/index.d.ts.map +0 -1
  251. package/dist/esm/components/websocket/common/keys.d.ts.map +0 -1
  252. package/dist/esm/components/websocket/common/types.d.ts.map +0 -1
  253. package/dist/esm/components/websocket/component.d.ts.map +0 -1
  254. package/dist/esm/components/websocket/handlers/bun.handler.d.ts.map +0 -1
  255. package/dist/esm/components/websocket/handlers/index.d.ts.map +0 -1
  256. package/dist/esm/components/websocket/index.d.ts.map +0 -1
  257. package/dist/esm/connectors/index.d.ts.map +0 -1
  258. package/dist/esm/helpers/base-helper.d.ts.map +0 -1
  259. package/dist/esm/helpers/index.d.ts.map +0 -1
  260. package/dist/esm/index.d.ts.map +0 -1
  261. package/dist/esm/testing/assert-application-boots.d.ts.map +0 -1
  262. package/dist/esm/testing/index.d.ts.map +0 -1
  263. package/dist/esm/utilities/drizzle-result.utility.d.ts.map +0 -1
  264. package/dist/esm/utilities/index.d.ts.map +0 -1
  265. package/dist/esm/utilities/network.utility.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"mime.utility.js","sourceRoot":"","sources":["../../../../../src/components/mail/utilities/mime.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,cAAc,EAA2C,MAAM,WAAW,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,MAAM,IAAI,GAAG,MAAM,CAAC;AACpB,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B;;2FAE2F;AAC3F,MAAM,sBAAsB,G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AI,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;QAC7E,CAAC;QAED,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;QAC3C,OAAO,CAAC,IAAI,CAAC,4CAA4C,aAAa,GAAG,CAAC,CAAC;QAE3E,MAAM,SAAS,GAAa,EAAE,CAAC;QAE/B,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACjC,MAAM,OAAO,GAAG,MAAM,gBAAgB,CAAC,aAAa,CAAC,CAAC;YACtD,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1B,CAAC;aAAM,CAAC;YACN,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;QAC1C,CAAC;QAED,KAAK,MAAM,UAAU,IAAI,eAAe,EAAE,CAAC;YACzC,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;YAChE,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1B,CAAC;QAED,SAAS,CAAC,IAAI,CAAC,KAAK,aAAa,IAAI,CAAC,CAAC;QAEvC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,EAAE,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;IACjF,CAAC;CACF","sourcesContent":["import { HTTP } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { MailErrorCodes, type IMailAttachment, type IMailMessage } from '../common';\nimport { MailAddressUtility } from './address.utility';\nimport { MailAttachmentUtility } from './attachment.utility';\n\nconst CRLF = '\\r\\n';\nconst BASE64_LINE_LENGTH = 76;\n/** RFC 5322 recommends folding well under its own 998-byte hard limit; 78 matches common MTA\n * practice. This is a *soft* preferred width, not a hard requirement - {@link foldHeaderLine}\n * only forces a line break past it when a natural whitespace break point exists nearby. */\nconst MAX_HEADER_LINE_LENGTH = 78;\n/** The real hard requirement: SES rejects any raw-message physical line at or over 1000 bytes.\n * A 10-byte margin below that, and comfortably under RFC 5322's own 998-octet hard limit. Only\n * an unbroken token that would itself cross this line forces {@link foldHeaderLine}'s\n * content-altering hard-wrap fallback - below it, one long line is safer than corrupting an\n * atomic value (a single very long address, an unbroken encoded-word) by splitting it. */\nconst MAX_HEADER_HARD_LIMIT = 990;\n/** RFC 2047 caps one encoded-word (`=?charset?B?...?=` included) at 75 characters. */\nconst ENCODED_WORD_MAX_LENGTH = 75;\n\n/** `bytes` random bytes as lowercase hex, from the platform CSPRNG. */\nfunction generateRandomHex(opts: { bytes: number }): string {\n return Buffer.from(crypto.getRandomValues(new Uint8Array(opts.bytes))).toString('hex');\n}\n\nfunction isAscii(value: string): boolean {\n for (let index = 0; index < value.length; index++) {\n if (value.charCodeAt(index) > 127) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * RFC 2047 §5(3) requires each encoded-word to carry whole characters - a multi-byte UTF-8\n * sequence split across two encoded-words decodes to mojibake or invalid UTF-8 on either side of\n * the cut. `bytesPerChunk` is a fixed byte budget, not a character-aligned one, so after slicing\n * at that budget we walk the boundary back over any UTF-8 continuation bytes (`10xxxxxx`, i.e.\n * `byte & 0xC0 === 0x80`) until it lands on the leading byte of a character. `bytesPerChunk` is\n * always far larger than the longest UTF-8 sequence (4 bytes), so this walk-back can never\n * consume the whole chunk. Words are joined with a single space - the required separator between\n * adjacent encoded-words, and also a valid header-folding point.\n */\nfunction encodeWord(text: string): string {\n const prefix = '=?UTF-8?B?';\n const suffix = '?=';\n const maxPayloadChars = ENCODED_WORD_MAX_LENGTH - prefix.length - suffix.length;\n const bytesPerChunk = Math.floor(maxPayloadChars / 4) * 3;\n const bytes = Buffer.from(text, 'utf-8');\n const words: string[] = [];\n let offset = 0;\n\n while (offset < bytes.length) {\n let end = Math.min(offset + bytesPerChunk, bytes.length);\n\n while (end < bytes.length && (bytes[end] & 0xc0) === 0x80) {\n end--;\n }\n\n const chunk = bytes.subarray(offset, end);\n words.push(`${prefix}${chunk.toString('base64')}${suffix}`);\n offset = end;\n }\n\n return words.join(' ');\n}\n\n/** Only non-ASCII values pay for RFC 2047 encoding, so a plain-English subject or custom header\n * stays byte-for-byte readable. */\nfunction encodeHeaderValue(value: string): string {\n return isAscii(value) ? value : encodeWord(value);\n}\n\n/**\n * Encodes only the *display-name* portion of `\"Name\" <addr@x.com>` (or bare `Name <addr@x.com>`).\n * The `<addr-spec>` must stay 7-bit ASCII per RFC 5321/5322 and per the SES raw-message\n * requirements - only the free-text name may become an RFC 2047 encoded-word. A bare address with\n * no display name is returned unchanged.\n */\nfunction encodeAddress(address: string): string {\n const match = /^(.*)<([^<>]+)>\\s*$/.exec(address);\n\n if (!match) {\n return address;\n }\n\n const [, rawName, addr] = match;\n const name = rawName.trim().replace(/^\"|\"$/g, '');\n\n if (name.length === 0 || isAscii(name)) {\n return rawName.trim().length > 0 ? `${rawName.trim()} <${addr}>` : `<${addr}>`;\n }\n\n return `${encodeWord(name)} <${addr}>`;\n}\n\n/** The body of `MailMimeUtility.formatAddressHeader`, callable from the header builder. */\nfunction formatAddressList(value: string | string[]): string {\n return MailAddressUtility.splitList({ value }).map(encodeAddress).join(', ');\n}\n\n/**\n * RFC 5322 §2.2.3 header folding: inserting CRLF immediately before an existing whitespace\n * character splits one logical header value across physical lines without changing its content\n * (the folded whitespace is still there, just after a line break). SES enforces a 1000-byte\n * ceiling per raw-message line; folding at {@link MAX_HEADER_LINE_LENGTH} keeps arbitrarily long\n * recipient lists, subjects, or encoded display names deliverable regardless of how many\n * addresses or how much non-ASCII text a caller supplies - purely by adding more physical\n * lines, never by dropping or truncating anything (verified: rejoining every folded line always\n * reproduces the original value exactly).\n *\n * The one value-altering fallback is deliberately gated on the *hard* limit, not the soft one:\n * an unbroken token (a single very long address, an encoded-word with no adjacent break) that\n * fits under {@link MAX_HEADER_HARD_LIMIT} is left on one long physical line rather than\n * force-broken at the soft width - forcing a break through the middle of an atomic token (an\n * email address has no internal whitespace) would insert a space that was never there,\n * corrupting it. Only a token that would itself violate the real transport limit gets the\n * content-altering hard-wrap - a case that essentially never occurs with real-world input.\n */\nfunction foldHeaderLine(line: string): string {\n const lines: string[] = [];\n let remaining = line;\n\n while (remaining.length > MAX_HEADER_LINE_LENGTH) {\n let breakAt = remaining.lastIndexOf(' ', MAX_HEADER_LINE_LENGTH);\n\n if (breakAt <= 0) {\n // No break within the soft width - look further ahead instead of forcing one through an\n // atomic token. Still bounded by the hard limit, so the physical line this produces can\n // never violate the real transport constraint.\n const nextBreak = remaining.indexOf(' ', MAX_HEADER_LINE_LENGTH);\n breakAt = nextBreak > 0 && nextBreak <= MAX_HEADER_HARD_LIMIT ? nextBreak : -1;\n }\n\n if (breakAt > 0) {\n lines.push(remaining.slice(0, breakAt));\n remaining = remaining.slice(breakAt);\n continue;\n }\n\n if (remaining.length <= MAX_HEADER_HARD_LIMIT) {\n break;\n }\n\n // Truly no natural break within the hard limit - an unbroken token that would itself\n // violate the transport line cap. This is the only path that can alter the value.\n lines.push(remaining.slice(0, MAX_HEADER_HARD_LIMIT));\n remaining = ` ${remaining.slice(MAX_HEADER_HARD_LIMIT)}`;\n }\n\n lines.push(remaining);\n return lines.join(CRLF);\n}\n\n/** MIME requires encoded body lines capped well under the RFC 5322 998-byte hard limit. */\nfunction foldBase64(base64: string): string {\n const lines: string[] = [];\n\n for (let index = 0; index < base64.length; index += BASE64_LINE_LENGTH) {\n lines.push(base64.slice(index, index + BASE64_LINE_LENGTH));\n }\n\n return lines.join(CRLF);\n}\n\n/** UTF-8 text (`text`/`html` bodies) must be encoded before folding - unlike {@link encodeBufferBase64}, which folds bytes that are already final. Two names instead of one so the caller can never feed raw bytes through the wrong path and silently double-encode them. */\nfunction encodeTextBase64(text: string): string {\n return foldBase64(Buffer.from(text, 'utf-8').toString('base64'));\n}\n\n/** Attachment bytes are already final binary content - only folding applies, no UTF-8 re-encode. */\nfunction encodeBufferBase64(buffer: Buffer): string {\n return foldBase64(buffer.toString('base64'));\n}\n\n/** A literal CR/LF/NUL inside a header-bound value would let it break out of its own header line and forge additional headers or smuggle body content - classic email header injection. Every value spliced into a raw header line is checked here first, so an attempt fails loudly instead of silently reaching the wire.\n *\n * `value` is `unknown`, not `string`: `IMailMessage`/`IMailAttachment` both end in\n * `[key: string]: any`, so nothing at the type layer stops a caller (e.g. a controller\n * forwarding a request body) from putting a non-string - notably an array - where a string is\n * declared. `Array.prototype.includes('\\r')` checks element *equality*, not substring, so\n * `['x\\r\\nBcc: evil'].includes('\\r')` is `false` and a naive string-only check would wave a\n * forged header straight through once it is later stringified by a template literal. Requiring\n * `typeof value === 'string'` up front closes that gap for every field that flows through here. */\nfunction assertNoHeaderInjection(opts: { field: string; value: unknown }): void {\n const { field, value } = opts;\n\n if (typeof value !== 'string') {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n messageCode: MailErrorCodes.INVALID_CONFIGURATION,\n message: `Invalid Amazon SES message | ${field} must be a string`,\n });\n }\n\n if (!value.includes('\\r') && !value.includes('\\n') && !value.includes('\\0')) {\n return;\n }\n\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n messageCode: MailErrorCodes.INVALID_CONFIGURATION,\n message: `Invalid Amazon SES message | ${field} contains illegal control characters`,\n });\n}\n\n/** Same guard as {@link assertNoHeaderInjection}, applied to every address in a `to`/`cc`/`bcc`\n * field individually - a string field only, not `[key: string]: any`; validating the raw\n * caller-provided value (before splitting/joining) both types and content-checks each entry. */\nfunction assertNoAddressListInjection(opts: { field: string; value: string | string[] }): void {\n const { field, value } = opts;\n const list = Array.isArray(value) ? value : [value];\n\n for (const item of list) {\n assertNoHeaderInjection({ field, value: item });\n }\n}\n\nfunction extractDomain(address: string | undefined): string {\n const match = address ? /@([^@>\\s]+)>?\\s*$/.exec(address) : null;\n return match ? match[1] : 'localhost';\n}\n\nfunction buildHeaders(message: IMailMessage): string[] {\n const headers: string[] = [];\n\n if (message.from) {\n assertNoAddressListInjection({ field: 'from', value: message.from });\n headers.push(foldHeaderLine(`From: ${formatAddressList(message.from)}`));\n }\n\n if (message.to) {\n assertNoAddressListInjection({ field: 'to', value: message.to });\n headers.push(foldHeaderLine(`To: ${formatAddressList(message.to)}`));\n }\n\n if (message.cc) {\n assertNoAddressListInjection({ field: 'cc', value: message.cc });\n headers.push(foldHeaderLine(`Cc: ${formatAddressList(message.cc)}`));\n }\n\n if (message.replyTo) {\n assertNoAddressListInjection({ field: 'replyTo', value: message.replyTo });\n headers.push(foldHeaderLine(`Reply-To: ${formatAddressList(message.replyTo)}`));\n }\n\n // Checked, never emitted: a `Bcc:` header would disclose the blind recipients, so they travel as\n // `Destination.BccAddresses`. Without this, `bcc` is the one address field that fails at AWS.\n if (message.bcc) {\n assertNoAddressListInjection({ field: 'bcc', value: message.bcc });\n }\n\n assertNoHeaderInjection({ field: 'subject', value: message.subject });\n headers.push(foldHeaderLine(`Subject: ${encodeHeaderValue(message.subject)}`));\n // RFC 5322 requires both on every message; SES's raw-message parser does not synthesize them,\n // so an omission here is an omission on the wire (some receiving MTAs reject a `Date`-less\n // message outright, and a missing `Message-ID` breaks threading and dedup).\n headers.push(`Date: ${new Date().toUTCString()}`);\n headers.push(`Message-ID: <${generateRandomHex({ bytes: 16 })}@${extractDomain(message.from)}>`);\n headers.push('MIME-Version: 1.0');\n\n if (message.headers) {\n const messageHeadersEntries = Object.entries(message.headers);\n for (const [key, value] of messageHeadersEntries) {\n assertNoHeaderInjection({ field: `headers.${key}`, value: key });\n assertNoHeaderInjection({ field: `headers.${key}`, value });\n headers.push(foldHeaderLine(`${key}: ${encodeHeaderValue(value)}`));\n }\n }\n\n return headers;\n}\n\n/** One text/plain or text/html MIME part. `boundary` omitted only for the single-part, no-attachment case, where the content type belongs on the top-level headers instead of a nested part. */\nfunction textPart(\n boundary: string,\n contentType: 'text/plain' | 'text/html',\n content: string,\n): string {\n return [\n `--${boundary}`,\n `Content-Type: ${contentType}; charset=UTF-8`,\n 'Content-Transfer-Encoding: base64',\n '',\n encodeTextBase64(content),\n ].join(CRLF);\n}\n\nfunction escapeQuotedString(value: string): string {\n return value.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"');\n}\n\n/** RFC 2231 percent-encoding for the `filename*=`/`name*=` extended parameter form. */\nfunction encodeRfc2231(value: string): string {\n return encodeURIComponent(value).replace(\n /[!'()*]/g,\n (char) => `%${char.charCodeAt(0).toString(16).toUpperCase()}`,\n );\n}\n\n/**\n * Builds the `; name=\"...\"`/`; filename=\"...\"` (and, for non-ASCII names, the RFC 2231\n * `; filename*=UTF-8''...` extended form) suffix for a Content-Type/Content-Disposition line.\n * ASCII names are still quoted-string escaped - an unescaped `\"` or `\\` in a filename would\n * terminate the quoted string early and let the rest of the value merge into a sibling MIME\n * parameter, corrupting the part header for every downstream reader.\n */\nfunction attachmentNameParams(attribute: 'name' | 'filename', value: string): string {\n if (isAscii(value)) {\n return `; ${attribute}=\"${escapeQuotedString(value)}\"`;\n }\n\n const asciiFallback = value.replace(/[^\\x20-\\x7E]/g, '_');\n return (\n `; ${attribute}=\"${escapeQuotedString(asciiFallback)}\"` +\n `; ${attribute}*=UTF-8''${encodeRfc2231(value)}`\n );\n}\n\nasync function attachmentPart(attachment: IMailAttachment, boundary: string): Promise<string> {\n // No root here: a `path` that did not go through `MailAttachmentUtility.resolve` is refused, never read.\n const content = await MailAttachmentUtility.readContent({ attachment });\n const contentType = attachment.contentType ?? 'application/octet-stream';\n assertNoHeaderInjection({ field: 'attachment.contentType', value: contentType });\n\n if (attachment.filename) {\n assertNoHeaderInjection({ field: 'attachment.filename', value: attachment.filename });\n }\n\n if (attachment.cid) {\n assertNoHeaderInjection({ field: 'attachment.cid', value: attachment.cid });\n }\n\n const nameAttribute = attachment.filename\n ? attachmentNameParams('name', attachment.filename)\n : '';\n const filenameAttribute = attachment.filename\n ? attachmentNameParams('filename', attachment.filename)\n : '';\n const disposition = attachment.cid ? 'inline' : 'attachment';\n\n const headerLines = [\n `--${boundary}`,\n foldHeaderLine(`Content-Type: ${contentType}${nameAttribute}`),\n 'Content-Transfer-Encoding: base64',\n foldHeaderLine(`Content-Disposition: ${disposition}${filenameAttribute}`),\n ];\n\n if (attachment.cid) {\n headerLines.push(`Content-ID: <${attachment.cid}>`);\n }\n\n return [...headerLines, '', encodeBufferBase64(content)].join(CRLF);\n}\n\n/** Every boundary is generated the same way - a fixed prefix plus random hex - so no two nested multipart sections in one message can ever collide. */\nfunction newBoundary(label: string): string {\n return `----=_${label}_${generateRandomHex({ bytes: 12 })}`;\n}\n\nexport class MailMimeUtility {\n /** Formats a `to`/`cc`/`from`/`replyTo` field as one RFC 5322 address list: splits a\n * comma-separated string or array into individual mailboxes, RFC 2047-encodes each display name,\n * and rejoins with `, ` - the same shape whether the caller passed a string or an array. */\n static formatAddressHeader(opts: { value: string | string[] }): string {\n return formatAddressList(opts.value);\n }\n\n /**\n * Builds a raw RFC 822 message with zero external dependencies - Amazon SES's `SendEmailCommand`\n * `Content.Simple` shape has no attachment field, so attachments require a raw MIME body. Written\n * by hand instead of depending on `nodemailer`'s `MailComposer` so the `ses` provider never needs\n * the `nodemailer` peer installed at all.\n *\n * Inline (`cid`) attachments nest under `multipart/related` next to the body - a mail client\n * only renders `cid:` references inline when they share a `multipart/related` parent with the\n * body; under `multipart/mixed` they show up as ordinary downloadable attachments instead. Plain\n * file attachments (no `cid`) stay under `multipart/mixed`, alongside the body or the\n * `multipart/related` group when both kinds are present.\n */\n static async buildRawMessage(opts: { message: IMailMessage }): Promise<Buffer> {\n const { message } = opts;\n const headers = buildHeaders(message);\n const attachments = message.attachments ?? [];\n const inlineAttachments = attachments.filter((attachment) => Boolean(attachment.cid));\n const fileAttachments = attachments.filter((attachment) => !attachment.cid);\n const hasBothBodies = Boolean(message.text) && Boolean(message.html);\n const singleContentType = message.html ? ('text/html' as const) : ('text/plain' as const);\n const singleContent = message.html ?? message.text ?? '';\n\n const bodyPart = (boundary: string): string => {\n if (!hasBothBodies) {\n return textPart(boundary, singleContentType, singleContent);\n }\n\n const altBoundary = newBoundary('Alt');\n return [\n `--${boundary}`,\n `Content-Type: multipart/alternative; boundary=\"${altBoundary}\"`,\n '',\n [\n textPart(altBoundary, 'text/plain', message.text ?? ''),\n textPart(altBoundary, 'text/html', message.html ?? ''),\n `--${altBoundary}--`,\n ].join(CRLF),\n ].join(CRLF);\n };\n\n if (attachments.length === 0 && !hasBothBodies) {\n headers.push(`Content-Type: ${singleContentType}; charset=UTF-8`);\n headers.push('Content-Transfer-Encoding: base64');\n return Buffer.from([...headers, '', encodeTextBase64(singleContent)].join(CRLF), 'utf-8');\n }\n\n if (attachments.length === 0) {\n const boundary = newBoundary('Alt');\n headers.push(`Content-Type: multipart/alternative; boundary=\"${boundary}\"`);\n const parts = [\n textPart(boundary, 'text/plain', message.text ?? ''),\n textPart(boundary, 'text/html', message.html ?? ''),\n `--${boundary}--`,\n ];\n return Buffer.from([...headers, '', parts.join(CRLF)].join(CRLF), 'utf-8');\n }\n\n const buildRelatedPart = async (parentBoundary: string): Promise<string> => {\n const relatedBoundary = newBoundary('Related');\n const parts = [bodyPart(relatedBoundary)];\n\n for (const attachment of inlineAttachments) {\n const result = await attachmentPart(attachment, relatedBoundary);\n parts.push(result);\n }\n\n parts.push(`--${relatedBoundary}--`);\n\n return [\n `--${parentBoundary}`,\n `Content-Type: multipart/related; boundary=\"${relatedBoundary}\"`,\n '',\n parts.join(CRLF),\n ].join(CRLF);\n };\n\n if (inlineAttachments.length > 0 && fileAttachments.length === 0) {\n const relatedBoundary = newBoundary('Related');\n const parts = [bodyPart(relatedBoundary)];\n\n for (const attachment of inlineAttachments) {\n const result = await attachmentPart(attachment, relatedBoundary);\n parts.push(result);\n }\n\n parts.push(`--${relatedBoundary}--`);\n headers.push(`Content-Type: multipart/related; boundary=\"${relatedBoundary}\"`);\n return Buffer.from([...headers, '', parts.join(CRLF)].join(CRLF), 'utf-8');\n }\n\n const mixedBoundary = newBoundary('Mixed');\n headers.push(`Content-Type: multipart/mixed; boundary=\"${mixedBoundary}\"`);\n\n const bodyParts: string[] = [];\n\n if (inlineAttachments.length > 0) {\n const result2 = await buildRelatedPart(mixedBoundary);\n bodyParts.push(result2);\n } else {\n bodyParts.push(bodyPart(mixedBoundary));\n }\n\n for (const attachment of fileAttachments) {\n const result3 = await attachmentPart(attachment, mixedBoundary);\n bodyParts.push(result3);\n }\n\n bodyParts.push(`--${mixedBoundary}--`);\n\n return Buffer.from([...headers, '', bodyParts.join(CRLF)].join(CRLF), 'utf-8');\n }\n}\n"]}
1
+ {"version":3,"file":"mime.utility.js","sourceRoot":"","sources":["../../../../../src/components/mail/utilities/mime.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,cAAc,EAA2C,MAAM,WAAW,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,MAAM,IAAI,GAAG,MAAM,CAAC;AACpB,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B;;2FAE2F;AAC3F,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC;;;;0FAI0F;AAC1F,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAClC,sFAAsF;AACtF,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAEnC,uEAAuE;AACvE,SAAS,iBAAiB,CAAC,IAAuB;IAChD,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACzF,CAAC;AAED,SAAS,OAAO,CAAC,KAAa;IAC5B,KAAK,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AC;QAC1B,CAAC;aAAM,CAAC;YACN,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;QAC1C,CAAC;QAED,KAAK,MAAM,UAAU,IAAI,eAAe,EAAE,CAAC;YACzC,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;YAChE,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1B,CAAC;QAED,SAAS,CAAC,IAAI,CAAC,KAAK,aAAa,IAAI,CAAC,CAAC;QAEvC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,EAAE,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;IACjF,CAAC;CACF","sourcesContent":["import { HTTP } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { MailErrorCodes, type IMailAttachment, type IMailMessage } from '../common';\nimport { MailAddressUtility } from './address.utility';\nimport { MailAttachmentUtility } from './attachment.utility';\n\nconst CRLF = '\\r\\n';\nconst BASE64_LINE_LENGTH = 76;\n/** RFC 5322 recommends folding well under its own 998-byte hard limit; 78 matches common MTA\n * practice. This is a *soft* preferred width, not a hard requirement - {@link foldHeaderLine}\n * only forces a line break past it when a natural whitespace break point exists nearby. */\nconst MAX_HEADER_LINE_LENGTH = 78;\n/** The real hard requirement: SES rejects any raw-message physical line at or over 1000 bytes.\n * A 10-byte margin below that, and comfortably under RFC 5322's own 998-octet hard limit. Only\n * an unbroken token that would itself cross this line forces {@link foldHeaderLine}'s\n * content-altering hard-wrap fallback - below it, one long line is safer than corrupting an\n * atomic value (a single very long address, an unbroken encoded-word) by splitting it. */\nconst MAX_HEADER_HARD_LIMIT = 990;\n/** RFC 2047 caps one encoded-word (`=?charset?B?...?=` included) at 75 characters. */\nconst ENCODED_WORD_MAX_LENGTH = 75;\n\n/** `bytes` random bytes as lowercase hex, from the platform CSPRNG. */\nfunction generateRandomHex(opts: { bytes: number }): string {\n return Buffer.from(crypto.getRandomValues(new Uint8Array(opts.bytes))).toString('hex');\n}\n\nfunction isAscii(value: string): boolean {\n for (let index = 0; index < value.length; index++) {\n if (value.charCodeAt(index) > 127) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * RFC 2047 §5(3) requires each encoded-word to carry whole characters - a multi-byte UTF-8\n * sequence split across two encoded-words decodes to mojibake or invalid UTF-8 on either side of\n * the cut. `bytesPerChunk` is a fixed byte budget, not a character-aligned one, so after slicing\n * at that budget we walk the boundary back over any UTF-8 continuation bytes (`10xxxxxx`, i.e.\n * `byte & 0xC0 === 0x80`) until it lands on the leading byte of a character. `bytesPerChunk` is\n * always far larger than the longest UTF-8 sequence (4 bytes), so this walk-back can never\n * consume the whole chunk. Words are joined with a single space - the required separator between\n * adjacent encoded-words, and also a valid header-folding point.\n */\nfunction encodeWord(text: string): string {\n const prefix = '=?UTF-8?B?';\n const suffix = '?=';\n const maxPayloadChars = ENCODED_WORD_MAX_LENGTH - prefix.length - suffix.length;\n const bytesPerChunk = Math.floor(maxPayloadChars / 4) * 3;\n const bytes = Buffer.from(text, 'utf-8');\n const words: string[] = [];\n let offset = 0;\n\n while (offset < bytes.length) {\n let end = Math.min(offset + bytesPerChunk, bytes.length);\n\n while (end < bytes.length && (bytes[end] & 0xc0) === 0x80) {\n end--;\n }\n\n const chunk = bytes.subarray(offset, end);\n words.push(`${prefix}${chunk.toString('base64')}${suffix}`);\n offset = end;\n }\n\n return words.join(' ');\n}\n\n/** Only non-ASCII values pay for RFC 2047 encoding, so a plain-English subject or custom header\n * stays byte-for-byte readable. */\nfunction encodeHeaderValue(value: string): string {\n return isAscii(value) ? value : encodeWord(value);\n}\n\n/**\n * Encodes only the *display-name* portion of `\"Name\" <addr@x.com>` (or bare `Name <addr@x.com>`).\n * The `<addr-spec>` must stay 7-bit ASCII per RFC 5321/5322 and per the SES raw-message\n * requirements - only the free-text name may become an RFC 2047 encoded-word. A bare address with\n * no display name is returned unchanged.\n */\nfunction encodeAddress(address: string): string {\n const match = /^(.*)<([^<>]+)>\\s*$/.exec(address);\n\n if (!match) {\n return address;\n }\n\n const [, rawName, addr] = match;\n const name = rawName.trim().replace(/^\"|\"$/g, '');\n\n if (name.length === 0 || isAscii(name)) {\n return rawName.trim().length > 0 ? `${rawName.trim()} <${addr}>` : `<${addr}>`;\n }\n\n return `${encodeWord(name)} <${addr}>`;\n}\n\n/** The body of `MailMimeUtility.formatAddressHeader`, callable from the header builder. */\nfunction formatAddressList(value: string | string[]): string {\n return MailAddressUtility.splitList({ value }).map(encodeAddress).join(', ');\n}\n\n/**\n * RFC 5322 §2.2.3 header folding: inserting CRLF immediately before an existing whitespace\n * character splits one logical header value across physical lines without changing its content\n * (the folded whitespace is still there, just after a line break). SES enforces a 1000-byte\n * ceiling per raw-message line; folding at {@link MAX_HEADER_LINE_LENGTH} keeps arbitrarily long\n * recipient lists, subjects, or encoded display names deliverable regardless of how many\n * addresses or how much non-ASCII text a caller supplies - purely by adding more physical\n * lines, never by dropping or truncating anything (verified: rejoining every folded line always\n * reproduces the original value exactly).\n *\n * The one value-altering fallback is deliberately gated on the *hard* limit, not the soft one:\n * an unbroken token (a single very long address, an encoded-word with no adjacent break) that\n * fits under {@link MAX_HEADER_HARD_LIMIT} is left on one long physical line rather than\n * force-broken at the soft width - forcing a break through the middle of an atomic token (an\n * email address has no internal whitespace) would insert a space that was never there,\n * corrupting it. Only a token that would itself violate the real transport limit gets the\n * content-altering hard-wrap - a case that essentially never occurs with real-world input.\n */\nfunction foldHeaderLine(line: string): string {\n const lines: string[] = [];\n let remaining = line;\n\n while (remaining.length > MAX_HEADER_LINE_LENGTH) {\n let breakAt = remaining.lastIndexOf(' ', MAX_HEADER_LINE_LENGTH);\n\n if (breakAt <= 0) {\n // No break within the soft width - look further ahead instead of forcing one through an\n // atomic token. Still bounded by the hard limit, so the physical line this produces can\n // never violate the real transport constraint.\n const nextBreak = remaining.indexOf(' ', MAX_HEADER_LINE_LENGTH);\n breakAt = nextBreak > 0 && nextBreak <= MAX_HEADER_HARD_LIMIT ? nextBreak : -1;\n }\n\n if (breakAt > 0) {\n lines.push(remaining.slice(0, breakAt));\n remaining = remaining.slice(breakAt);\n continue;\n }\n\n if (remaining.length <= MAX_HEADER_HARD_LIMIT) {\n break;\n }\n\n // Truly no natural break within the hard limit - an unbroken token that would itself\n // violate the transport line cap. This is the only path that can alter the value.\n lines.push(remaining.slice(0, MAX_HEADER_HARD_LIMIT));\n remaining = ` ${remaining.slice(MAX_HEADER_HARD_LIMIT)}`;\n }\n\n lines.push(remaining);\n\n return lines.join(CRLF);\n}\n\n/** MIME requires encoded body lines capped well under the RFC 5322 998-byte hard limit. */\nfunction foldBase64(base64: string): string {\n const lines: string[] = [];\n\n for (let index = 0; index < base64.length; index += BASE64_LINE_LENGTH) {\n lines.push(base64.slice(index, index + BASE64_LINE_LENGTH));\n }\n\n return lines.join(CRLF);\n}\n\n/** UTF-8 text (`text`/`html` bodies) must be encoded before folding - unlike {@link encodeBufferBase64}, which folds bytes that are already final. Two names instead of one so the caller can never feed raw bytes through the wrong path and silently double-encode them. */\nfunction encodeTextBase64(text: string): string {\n return foldBase64(Buffer.from(text, 'utf-8').toString('base64'));\n}\n\n/** Attachment bytes are already final binary content - only folding applies, no UTF-8 re-encode. */\nfunction encodeBufferBase64(buffer: Buffer): string {\n return foldBase64(buffer.toString('base64'));\n}\n\n/** A literal CR/LF/NUL inside a header-bound value would let it break out of its own header line and forge additional headers or smuggle body content - classic email header injection. Every value spliced into a raw header line is checked here first, so an attempt fails loudly instead of silently reaching the wire.\n *\n * `value` is `unknown`, not `string`: `IMailMessage`/`IMailAttachment` both end in\n * `[key: string]: any`, so nothing at the type layer stops a caller (e.g. a controller\n * forwarding a request body) from putting a non-string - notably an array - where a string is\n * declared. `Array.prototype.includes('\\r')` checks element *equality*, not substring, so\n * `['x\\r\\nBcc: evil'].includes('\\r')` is `false` and a naive string-only check would wave a\n * forged header straight through once it is later stringified by a template literal. Requiring\n * `typeof value === 'string'` up front closes that gap for every field that flows through here. */\nfunction assertNoHeaderInjection(opts: { field: string; value: unknown }): void {\n const { field, value } = opts;\n\n if (typeof value !== 'string') {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n messageCode: MailErrorCodes.INVALID_CONFIGURATION,\n message: `Invalid Amazon SES message | ${field} must be a string`,\n });\n }\n\n if (!value.includes('\\r') && !value.includes('\\n') && !value.includes('\\0')) {\n return;\n }\n\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n messageCode: MailErrorCodes.INVALID_CONFIGURATION,\n message: `Invalid Amazon SES message | ${field} contains illegal control characters`,\n });\n}\n\n/** Same guard as {@link assertNoHeaderInjection}, applied to every address in a `to`/`cc`/`bcc`\n * field individually - a string field only, not `[key: string]: any`; validating the raw\n * caller-provided value (before splitting/joining) both types and content-checks each entry. */\nfunction assertNoAddressListInjection(opts: { field: string; value: string | string[] }): void {\n const { field, value } = opts;\n const list = Array.isArray(value) ? value : [value];\n\n for (const item of list) {\n assertNoHeaderInjection({ field, value: item });\n }\n}\n\nfunction extractDomain(address: string | undefined): string {\n const match = address ? /@([^@>\\s]+)>?\\s*$/.exec(address) : null;\n\n return match ? match[1] : 'localhost';\n}\n\nfunction buildHeaders(message: IMailMessage): string[] {\n const headers: string[] = [];\n\n if (message.from) {\n assertNoAddressListInjection({ field: 'from', value: message.from });\n headers.push(foldHeaderLine(`From: ${formatAddressList(message.from)}`));\n }\n\n if (message.to) {\n assertNoAddressListInjection({ field: 'to', value: message.to });\n headers.push(foldHeaderLine(`To: ${formatAddressList(message.to)}`));\n }\n\n if (message.cc) {\n assertNoAddressListInjection({ field: 'cc', value: message.cc });\n headers.push(foldHeaderLine(`Cc: ${formatAddressList(message.cc)}`));\n }\n\n if (message.replyTo) {\n assertNoAddressListInjection({ field: 'replyTo', value: message.replyTo });\n headers.push(foldHeaderLine(`Reply-To: ${formatAddressList(message.replyTo)}`));\n }\n\n // Checked, never emitted: a `Bcc:` header would disclose the blind recipients, so they travel as\n // `Destination.BccAddresses`. Without this, `bcc` is the one address field that fails at AWS.\n if (message.bcc) {\n assertNoAddressListInjection({ field: 'bcc', value: message.bcc });\n }\n\n assertNoHeaderInjection({ field: 'subject', value: message.subject });\n headers.push(foldHeaderLine(`Subject: ${encodeHeaderValue(message.subject)}`));\n // RFC 5322 requires both on every message; SES's raw-message parser does not synthesize them,\n // so an omission here is an omission on the wire (some receiving MTAs reject a `Date`-less\n // message outright, and a missing `Message-ID` breaks threading and dedup).\n headers.push(`Date: ${new Date().toUTCString()}`);\n headers.push(`Message-ID: <${generateRandomHex({ bytes: 16 })}@${extractDomain(message.from)}>`);\n headers.push('MIME-Version: 1.0');\n\n if (message.headers) {\n const messageHeadersEntries = Object.entries(message.headers);\n\n for (const [key, value] of messageHeadersEntries) {\n assertNoHeaderInjection({ field: `headers.${key}`, value: key });\n assertNoHeaderInjection({ field: `headers.${key}`, value });\n headers.push(foldHeaderLine(`${key}: ${encodeHeaderValue(value)}`));\n }\n }\n\n return headers;\n}\n\n/** One text/plain or text/html MIME part. `boundary` omitted only for the single-part, no-attachment case, where the content type belongs on the top-level headers instead of a nested part. */\nfunction textPart(\n boundary: string,\n contentType: 'text/plain' | 'text/html',\n content: string,\n): string {\n return [\n `--${boundary}`,\n `Content-Type: ${contentType}; charset=UTF-8`,\n 'Content-Transfer-Encoding: base64',\n '',\n encodeTextBase64(content),\n ].join(CRLF);\n}\n\nfunction escapeQuotedString(value: string): string {\n return value.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"');\n}\n\n/** RFC 2231 percent-encoding for the `filename*=`/`name*=` extended parameter form. */\nfunction encodeRfc2231(value: string): string {\n return encodeURIComponent(value).replace(\n /[!'()*]/g,\n (char) => `%${char.charCodeAt(0).toString(16).toUpperCase()}`,\n );\n}\n\n/**\n * Builds the `; name=\"...\"`/`; filename=\"...\"` (and, for non-ASCII names, the RFC 2231\n * `; filename*=UTF-8''...` extended form) suffix for a Content-Type/Content-Disposition line.\n * ASCII names are still quoted-string escaped - an unescaped `\"` or `\\` in a filename would\n * terminate the quoted string early and let the rest of the value merge into a sibling MIME\n * parameter, corrupting the part header for every downstream reader.\n */\nfunction attachmentNameParams(attribute: 'name' | 'filename', value: string): string {\n if (isAscii(value)) {\n return `; ${attribute}=\"${escapeQuotedString(value)}\"`;\n }\n\n const asciiFallback = value.replace(/[^\\x20-\\x7E]/g, '_');\n\n return (\n `; ${attribute}=\"${escapeQuotedString(asciiFallback)}\"` +\n `; ${attribute}*=UTF-8''${encodeRfc2231(value)}`\n );\n}\n\nasync function attachmentPart(attachment: IMailAttachment, boundary: string): Promise<string> {\n // No root here: a `path` that did not go through `MailAttachmentUtility.resolve` is refused, never read.\n const content = await MailAttachmentUtility.readContent({ attachment });\n const contentType = attachment.contentType ?? 'application/octet-stream';\n assertNoHeaderInjection({ field: 'attachment.contentType', value: contentType });\n\n if (attachment.filename) {\n assertNoHeaderInjection({ field: 'attachment.filename', value: attachment.filename });\n }\n\n if (attachment.cid) {\n assertNoHeaderInjection({ field: 'attachment.cid', value: attachment.cid });\n }\n\n const nameAttribute = attachment.filename\n ? attachmentNameParams('name', attachment.filename)\n : '';\n const filenameAttribute = attachment.filename\n ? attachmentNameParams('filename', attachment.filename)\n : '';\n const disposition = attachment.cid ? 'inline' : 'attachment';\n\n const headerLines = [\n `--${boundary}`,\n foldHeaderLine(`Content-Type: ${contentType}${nameAttribute}`),\n 'Content-Transfer-Encoding: base64',\n foldHeaderLine(`Content-Disposition: ${disposition}${filenameAttribute}`),\n ];\n\n if (attachment.cid) {\n headerLines.push(`Content-ID: <${attachment.cid}>`);\n }\n\n return [...headerLines, '', encodeBufferBase64(content)].join(CRLF);\n}\n\n/** Every boundary is generated the same way - a fixed prefix plus random hex - so no two nested multipart sections in one message can ever collide. */\nfunction newBoundary(label: string): string {\n return `----=_${label}_${generateRandomHex({ bytes: 12 })}`;\n}\n\nexport class MailMimeUtility {\n /** Formats a `to`/`cc`/`from`/`replyTo` field as one RFC 5322 address list: splits a\n * comma-separated string or array into individual mailboxes, RFC 2047-encodes each display name,\n * and rejoins with `, ` - the same shape whether the caller passed a string or an array. */\n static formatAddressHeader(opts: { value: string | string[] }): string {\n return formatAddressList(opts.value);\n }\n\n /**\n * Builds a raw RFC 822 message with zero external dependencies - Amazon SES's `SendEmailCommand`\n * `Content.Simple` shape has no attachment field, so attachments require a raw MIME body. Written\n * by hand instead of depending on `nodemailer`'s `MailComposer` so the `ses` provider never needs\n * the `nodemailer` peer installed at all.\n *\n * Inline (`cid`) attachments nest under `multipart/related` next to the body - a mail client\n * only renders `cid:` references inline when they share a `multipart/related` parent with the\n * body; under `multipart/mixed` they show up as ordinary downloadable attachments instead. Plain\n * file attachments (no `cid`) stay under `multipart/mixed`, alongside the body or the\n * `multipart/related` group when both kinds are present.\n */\n static async buildRawMessage(opts: { message: IMailMessage }): Promise<Buffer> {\n const { message } = opts;\n const headers = buildHeaders(message);\n const attachments = message.attachments ?? [];\n const inlineAttachments = attachments.filter((attachment) => Boolean(attachment.cid));\n const fileAttachments = attachments.filter((attachment) => !attachment.cid);\n const hasBothBodies = Boolean(message.text) && Boolean(message.html);\n const singleContentType = message.html ? ('text/html' as const) : ('text/plain' as const);\n const singleContent = message.html ?? message.text ?? '';\n\n const bodyPart = (boundary: string): string => {\n if (!hasBothBodies) {\n return textPart(boundary, singleContentType, singleContent);\n }\n\n const altBoundary = newBoundary('Alt');\n\n return [\n `--${boundary}`,\n `Content-Type: multipart/alternative; boundary=\"${altBoundary}\"`,\n '',\n [\n textPart(altBoundary, 'text/plain', message.text ?? ''),\n textPart(altBoundary, 'text/html', message.html ?? ''),\n `--${altBoundary}--`,\n ].join(CRLF),\n ].join(CRLF);\n };\n\n if (attachments.length === 0 && !hasBothBodies) {\n headers.push(`Content-Type: ${singleContentType}; charset=UTF-8`);\n headers.push('Content-Transfer-Encoding: base64');\n\n return Buffer.from([...headers, '', encodeTextBase64(singleContent)].join(CRLF), 'utf-8');\n }\n\n if (attachments.length === 0) {\n const boundary = newBoundary('Alt');\n headers.push(`Content-Type: multipart/alternative; boundary=\"${boundary}\"`);\n const parts = [\n textPart(boundary, 'text/plain', message.text ?? ''),\n textPart(boundary, 'text/html', message.html ?? ''),\n `--${boundary}--`,\n ];\n\n return Buffer.from([...headers, '', parts.join(CRLF)].join(CRLF), 'utf-8');\n }\n\n const buildRelatedPart = async (parentBoundary: string): Promise<string> => {\n const relatedBoundary = newBoundary('Related');\n const parts = [bodyPart(relatedBoundary)];\n\n for (const attachment of inlineAttachments) {\n const result = await attachmentPart(attachment, relatedBoundary);\n parts.push(result);\n }\n\n parts.push(`--${relatedBoundary}--`);\n\n return [\n `--${parentBoundary}`,\n `Content-Type: multipart/related; boundary=\"${relatedBoundary}\"`,\n '',\n parts.join(CRLF),\n ].join(CRLF);\n };\n\n if (inlineAttachments.length > 0 && fileAttachments.length === 0) {\n const relatedBoundary = newBoundary('Related');\n const parts = [bodyPart(relatedBoundary)];\n\n for (const attachment of inlineAttachments) {\n const result = await attachmentPart(attachment, relatedBoundary);\n parts.push(result);\n }\n\n parts.push(`--${relatedBoundary}--`);\n headers.push(`Content-Type: multipart/related; boundary=\"${relatedBoundary}\"`);\n\n return Buffer.from([...headers, '', parts.join(CRLF)].join(CRLF), 'utf-8');\n }\n\n const mixedBoundary = newBoundary('Mixed');\n headers.push(`Content-Type: multipart/mixed; boundary=\"${mixedBoundary}\"`);\n\n const bodyParts: string[] = [];\n\n if (inlineAttachments.length > 0) {\n const result2 = await buildRelatedPart(mixedBoundary);\n bodyParts.push(result2);\n } else {\n bodyParts.push(bodyPart(mixedBoundary));\n }\n\n for (const attachment of fileAttachments) {\n const result3 = await attachmentPart(attachment, mixedBoundary);\n bodyParts.push(result3);\n }\n\n bodyParts.push(`--${mixedBoundary}--`);\n\n return Buffer.from([...headers, '', bodyParts.join(CRLF)].join(CRLF), 'utf-8');\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/components/socket-io/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,cAAc,EAAuB,MAAM,+BAA+B,CAAC;AAC1F,OAAO,EAA4B,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACjF,OAAO,EACL,oBAAoB,GAIrB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EACL,mBAAmB,EACnB,sBAAsB,GAGvB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,IAAa,iBAAiB,yBAA9B,MAAa,iBAAkB,SAAQ,aAAa;IAGlD,YAC8D,WAA4B;QAExF,KAAK,CAAC;YACJ,KAAK,EAAE,mBAAiB,CAAC,IAAI;YAC7B,WAAW,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE;YACrD,QAAQ,EAAE;gBACR,CAAC,mBAAmB,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC,IAAI,CAAyB;oBACzE,GAAG,EAAE,mBAAmB,CAAC,cAAc;iBACxC,CAAC,CAAC,OAAO,CAAC,sBAAsB,CAAC;gBAElC,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC,IAAI,CAA6B;oBAC/E,GAAG,EAAE,mBAAmB,CAAC,gBAAgB;iBAC1C,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;gBAEhB,CAAC,m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sourcesContent":["import { type BaseApplication, type TBunServerInstance } from '@/base/applications';\nimport { BaseComponent } from '@venizia/ignis-kernel';\nimport { inject } from '@/base/metadata';\nimport { CoreBindings } from '@venizia/ignis-kernel';\nimport { Binding } from '@venizia/ignis-kernel';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { HTTP, RuntimeModules, type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { type AbstractRedisHelper, isRedisHelper } from '@venizia/ignis-helpers';\nimport {\n SocketIOServerHelper,\n type TSocketIOAuthenticateFn,\n type TSocketIOClientConnectedFn,\n type TSocketIOValidateRoomFn,\n} from '@venizia/ignis-helpers/socket-io';\nimport type { ServerOptions } from 'socket.io';\nimport {\n SocketIOBindingKeys,\n DEFAULT_SERVER_OPTIONS,\n type IResolvedBindings,\n type IServerOptions,\n} from './common';\nimport { SocketIOBunHandler } from './handlers';\n\nexport class SocketIOComponent extends BaseComponent {\n protected serverOptions: Partial<IServerOptions>;\n\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: SocketIOComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [SocketIOBindingKeys.SERVER_OPTIONS]: Binding.bind<Partial<ServerOptions>>({\n key: SocketIOBindingKeys.SERVER_OPTIONS,\n }).toValue(DEFAULT_SERVER_OPTIONS),\n\n [SocketIOBindingKeys.REDIS_CONNECTION]: Binding.bind<AbstractRedisHelper | null>({\n key: SocketIOBindingKeys.REDIS_CONNECTION,\n }).toValue(null),\n\n [SocketIOBindingKeys.AUTHENTICATE_HANDLER]: Binding.bind<TSocketIOAuthenticateFn | null>({\n key: SocketIOBindingKeys.AUTHENTICATE_HANDLER,\n }).toValue(null),\n\n [SocketIOBindingKeys.VALIDATE_ROOM_HANDLER]: Binding.bind<TSocketIOValidateRoomFn | null>({\n key: SocketIOBindingKeys.VALIDATE_ROOM_HANDLER,\n }).toValue(null),\n\n [SocketIOBindingKeys.CLIENT_CONNECTED_HANDLER]:\n Binding.bind<TSocketIOClientConnectedFn | null>({\n key: SocketIOBindingKeys.CLIENT_CONNECTED_HANDLER,\n }).toValue(null),\n },\n });\n }\n\n private resolveBindings(): IResolvedBindings {\n const extraServerOptions =\n this.application.get<Partial<ServerOptions>>({\n key: SocketIOBindingKeys.SERVER_OPTIONS,\n isOptional: true,\n }) ?? {};\n this.serverOptions = Object.assign({}, DEFAULT_SERVER_OPTIONS, extraServerOptions);\n\n const redisConnection = this.application.get<AbstractRedisHelper>({\n key: SocketIOBindingKeys.REDIS_CONNECTION,\n });\n if (!isRedisHelper(redisConnection)) {\n throw getError({\n message:\n '[SocketIOComponent][resolveBindings] Invalid instance of redisConnection | Please init connection with RedisSingleHelper (single), RedisClusterHelper (cluster), or RedisSentinelHelper (sentinel)!',\n });\n }\n\n const authenticateFn = this.application.get<TSocketIOAuthenticateFn>({\n key: SocketIOBindingKeys.AUTHENTICATE_HANDLER,\n });\n if (!authenticateFn) {\n throw getError({\n message: '[DANGER][SocketIOComponent] Invalid authenticateFn to setup io socket server!',\n });\n }\n\n const validateRoomFn =\n this.application.get<TSocketIOValidateRoomFn | null>({\n key: SocketIOBindingKeys.VALIDATE_ROOM_HANDLER,\n }) ?? undefined;\n\n const clientConnectedFn =\n this.application.get<TSocketIOClientConnectedFn | null>({\n key: SocketIOBindingKeys.CLIENT_CONNECTED_HANDLER,\n }) ?? undefined;\n\n return { redisConnection, authenticateFn, validateRoomFn, clientConnectedFn };\n }\n\n private registerBunHook(opts: IResolvedBindings) {\n const { redisConnection, authenticateFn, validateRoomFn, clientConnectedFn } = opts;\n const serverOptions = this.serverOptions;\n const logger = this.logger.for(this.registerBunHook.name);\n\n this.application.registerPostStartHook({\n identifier: 'socket-io-initialize',\n hook: async () => {\n const { engine, engineHandler } = await SocketIOBunHandler.createEngine({ serverOptions });\n\n const socketIOHelper = new SocketIOServerHelper({\n runtime: RuntimeModules.BUN,\n identifier: serverOptions.identifier!,\n engine,\n serverOptions,\n redisConnection,\n authenticateFn,\n validateRoomFn,\n clientConnectedFn,\n });\n await socketIOHelper.configure();\n\n this.application\n .bind({ key: SocketIOBindingKeys.SOCKET_IO_INSTANCE })\n .toValue(socketIOHelper);\n\n const serverInstance = this.application.getServerInstance<TBunServerInstance>();\n const honoServer = this.application.getServer();\n const enginePath = serverOptions.path ?? '/socket.io/';\n\n serverInstance!.reload({\n fetch: SocketIOBunHandler.createFetchHandler({ engine, enginePath, honoServer }),\n websocket: engineHandler.websocket,\n });\n\n logger.info('SocketIO initialized for Bun runtime');\n },\n });\n }\n\n override binding(): ValueOrPromise<void> {\n const logger = this.logger.for(this.binding.name);\n\n if (!this.application) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[binding] Invalid application to bind SocketIOComponent',\n });\n }\n\n logger.info('Binding SocketIO for application...');\n\n const resolved = this.resolveBindings();\n logger.debug('Socket.IO Server Options: %j', this.serverOptions);\n\n this.registerBunHook(resolved);\n }\n}\n"]}
1
+ {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/components/socket-io/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,cAAc,EAAuB,MAAM,+BAA+B,CAAC;AAC1F,OAAO,EAA4B,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACjF,OAAO,EACL,oBAAoB,GAIrB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EACL,mBAAmB,EACnB,sBAAsB,GAGvB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CA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D,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,MAAM,QAAQ,CAAC;gBACb,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB;gBACrD,OAAO,EAAE,yDAAyD;aACnE,CAAC,CAAC;QACL,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;QAEnD,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QACxC,MAAM,CAAC,KAAK,CAAC,8BAA8B,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAEjE,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;CACF,CAAA;AArIY,iBAAiB;IAIzB,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAA;;GAJ1C,iBAAiB,CAqI7B","sourcesContent":["import { type BaseApplication, type TBunServerInstance } from '@/base/applications';\nimport { BaseComponent } from '@venizia/ignis-kernel';\nimport { inject } from '@/base/metadata';\nimport { CoreBindings } from '@venizia/ignis-kernel';\nimport { Binding } from '@venizia/ignis-kernel';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { HTTP, RuntimeModules, type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { type AbstractRedisHelper, isRedisHelper } from '@venizia/ignis-helpers';\nimport {\n SocketIOServerHelper,\n type TSocketIOAuthenticateFn,\n type TSocketIOClientConnectedFn,\n type TSocketIOValidateRoomFn,\n} from '@venizia/ignis-helpers/socket-io';\nimport type { ServerOptions } from 'socket.io';\nimport {\n SocketIOBindingKeys,\n DEFAULT_SERVER_OPTIONS,\n type IResolvedBindings,\n type IServerOptions,\n} from './common';\nimport { SocketIOBunHandler } from './handlers';\n\nexport class SocketIOComponent extends BaseComponent {\n protected serverOptions: Partial<IServerOptions>;\n\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: SocketIOComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [SocketIOBindingKeys.SERVER_OPTIONS]: Binding.bind<Partial<ServerOptions>>({\n key: SocketIOBindingKeys.SERVER_OPTIONS,\n }).toValue(DEFAULT_SERVER_OPTIONS),\n\n [SocketIOBindingKeys.REDIS_CONNECTION]: Binding.bind<AbstractRedisHelper | null>({\n key: SocketIOBindingKeys.REDIS_CONNECTION,\n }).toValue(null),\n\n [SocketIOBindingKeys.AUTHENTICATE_HANDLER]: Binding.bind<TSocketIOAuthenticateFn | null>({\n key: SocketIOBindingKeys.AUTHENTICATE_HANDLER,\n }).toValue(null),\n\n [SocketIOBindingKeys.VALIDATE_ROOM_HANDLER]: Binding.bind<TSocketIOValidateRoomFn | null>({\n key: SocketIOBindingKeys.VALIDATE_ROOM_HANDLER,\n }).toValue(null),\n\n [SocketIOBindingKeys.CLIENT_CONNECTED_HANDLER]:\n Binding.bind<TSocketIOClientConnectedFn | null>({\n key: SocketIOBindingKeys.CLIENT_CONNECTED_HANDLER,\n }).toValue(null),\n },\n });\n }\n\n private resolveBindings(): IResolvedBindings {\n const extraServerOptions =\n this.application.get<Partial<ServerOptions>>({\n key: SocketIOBindingKeys.SERVER_OPTIONS,\n isOptional: true,\n }) ?? {};\n this.serverOptions = Object.assign({}, DEFAULT_SERVER_OPTIONS, extraServerOptions);\n\n const redisConnection = this.application.get<AbstractRedisHelper>({\n key: SocketIOBindingKeys.REDIS_CONNECTION,\n });\n\n if (!isRedisHelper(redisConnection)) {\n throw getError({\n message:\n '[SocketIOComponent][resolveBindings] Invalid instance of redisConnection | Please init connection with RedisSingleHelper (single), RedisClusterHelper (cluster), or RedisSentinelHelper (sentinel)!',\n });\n }\n\n const authenticateFn = this.application.get<TSocketIOAuthenticateFn>({\n key: SocketIOBindingKeys.AUTHENTICATE_HANDLER,\n });\n\n if (!authenticateFn) {\n throw getError({\n message: '[DANGER][SocketIOComponent] Invalid authenticateFn to setup io socket server!',\n });\n }\n\n const validateRoomFn =\n this.application.get<TSocketIOValidateRoomFn | null>({\n key: SocketIOBindingKeys.VALIDATE_ROOM_HANDLER,\n }) ?? undefined;\n\n const clientConnectedFn =\n this.application.get<TSocketIOClientConnectedFn | null>({\n key: SocketIOBindingKeys.CLIENT_CONNECTED_HANDLER,\n }) ?? undefined;\n\n return { redisConnection, authenticateFn, validateRoomFn, clientConnectedFn };\n }\n\n private registerBunHook(opts: IResolvedBindings) {\n const { redisConnection, authenticateFn, validateRoomFn, clientConnectedFn } = opts;\n const serverOptions = this.serverOptions;\n const logger = this.logger.for(this.registerBunHook.name);\n\n this.application.registerPostStartHook({\n identifier: 'socket-io-initialize',\n hook: async () => {\n const { engine, engineHandler } = await SocketIOBunHandler.createEngine({ serverOptions });\n\n const socketIOHelper = new SocketIOServerHelper({\n runtime: RuntimeModules.BUN,\n identifier: serverOptions.identifier!,\n engine,\n serverOptions,\n redisConnection,\n authenticateFn,\n validateRoomFn,\n clientConnectedFn,\n });\n await socketIOHelper.configure();\n\n this.application\n .bind({ key: SocketIOBindingKeys.SOCKET_IO_INSTANCE })\n .toValue(socketIOHelper);\n\n const serverInstance = this.application.getServerInstance<TBunServerInstance>();\n const honoServer = this.application.getServer();\n const enginePath = serverOptions.path ?? '/socket.io/';\n\n serverInstance!.reload({\n fetch: SocketIOBunHandler.createFetchHandler({ engine, enginePath, honoServer }),\n websocket: engineHandler.websocket,\n });\n\n logger.info('SocketIO initialized for Bun runtime');\n },\n });\n }\n\n override binding(): ValueOrPromise<void> {\n const logger = this.logger.for(this.binding.name);\n\n if (!this.application) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[binding] Invalid application to bind SocketIOComponent',\n });\n }\n\n logger.info('Binding SocketIO for application...');\n\n const resolved = this.resolveBindings();\n logger.debug('Socket.IO Server Options: %j', this.serverOptions);\n\n this.registerBunHook(resolved);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"commit-token.js","sourceRoot":"","sources":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C,GAAG,CAAC,CAAC;QAE3C,IAAI,CAAC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACxB,MAAM,QAAQ,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;QACzD,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;QACzE,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAErC,kGAAkG;QAClG,IAAI,QAAQ,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC;YACjF,MAAM,QAAQ,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;QACzD,CAAC;QAED,MAAM,OAAO,GAAwB,IAAI,CAAC,KAAK,CAC7C,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAChD,CAAC;QACF,IAAI,OAAO,CAAC,SAAS,IAAI,GAAG,EAAE,CAAC;YAC7B,MAAM,QAAQ,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;QACzD,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","sourcesContent":["import { getError } from '@venizia/ignis-helpers/core';\nimport { StaticAssetErrors } from './errors';\n\n/** What a commit token binds. Business fields are deliberately absent - which order or tenant an upload belongs to is the application's, and a token the framework signs is the wrong place to put its authorization. */\nexport interface ICommitTokenPayload {\n bucket: string;\n key: string;\n expiresAt: number;\n}\n\n/** Signs and reads the token the commit route trusts instead of a key a caller names. */\nexport class AssetCommitToken {\n private static encode(payload: ICommitTokenPayload): string {\n return Buffer.from(JSON.stringify(payload)).toString('base64url');\n }\n\n private static sign(opts: { body: string; secretKey: string }): string {\n // `Bun.CryptoHasher` given no key answers a plain SHA-256 instead of throwing, which anyone can compute: a\n // missing secret must stop here, as `createHmac` did, or a forged token would pass.\n if (typeof opts.secretKey !== 'string') {\n throw getError({\n message: '[AssetCommitToken][sign] Invalid secretKey | Expected a string',\n });\n }\n\n return new Bun.CryptoHasher('sha256', opts.secretKey).update(opts.body).digest('base64url');\n }\n\n /** Signs `{ bucket, key, expiresAt }` so the commit route can trust the key it is handed. */\n static build(opts: { payload: ICommitTokenPayload; secretKey: string }): string {\n const body = AssetCommitToken.encode(opts.payload);\n return `${body}.${AssetCommitToken.sign({ body, secretKey: opts.secretKey })}`;\n }\n\n /**\n * Reads a commit token back, or throws.\n *\n * Verification happens BEFORE any storage call, which is what makes the commit route refuse to be a\n * name prober: a forged token fails without a round trip, so timing says nothing about what exists.\n */\n static read(opts: { token: string; secretKey: string; now?: number }): ICommitTokenPayload {\n const { token, secretKey, now = Date.now() } = opts;\n const [body, signature] = token.split('.');\n\n if (!body || !signature) {\n throw getError(StaticAssetErrors.INVALID_COMMIT_TOKEN);\n }\n\n const expected = Buffer.from(AssetCommitToken.sign({ body, secretKey }));\n const given = Buffer.from(signature);\n\n // Length-checked first: `timingSafeEqual` throws on a length mismatch instead of answering false.\n if (expected.length !== given.length || !crypto.timingSafeEqual(expected, given)) {\n throw getError(StaticAssetErrors.INVALID_COMMIT_TOKEN);\n }\n\n const payload: ICommitTokenPayload = JSON.parse(\n Buffer.from(body, 'base64url').toString('utf8'),\n );\n if (payload.expiresAt <= now) {\n throw getError(StaticAssetErrors.EXPIRED_COMMIT_TOKEN);\n }\n\n return payload;\n }\n}\n"]}
1
+ {"version":3,"file":"commit-token.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/common/commit-token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAS7C,yFAAyF;AACzF,MAAM,OAAO,gBAAgB;IACnB,MAAM,CAAC,M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AC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;QACzE,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAErC,kGAAkG;QAClG,IAAI,QAAQ,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC;YACjF,MAAM,QAAQ,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;QACzD,CAAC;QAED,MAAM,OAAO,GAAwB,IAAI,CAAC,KAAK,CAC7C,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAChD,CAAC;QAEF,IAAI,OAAO,CAAC,SAAS,IAAI,GAAG,EAAE,CAAC;YAC7B,MAAM,QAAQ,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;QACzD,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","sourcesContent":["import { getError } from '@venizia/ignis-helpers/core';\nimport { StaticAssetErrors } from './errors';\n\n/** What a commit token binds. Business fields are deliberately absent - which order or tenant an upload belongs to is the application's, and a token the framework signs is the wrong place to put its authorization. */\nexport interface ICommitTokenPayload {\n bucket: string;\n key: string;\n expiresAt: number;\n}\n\n/** Signs and reads the token the commit route trusts instead of a key a caller names. */\nexport class AssetCommitToken {\n private static encode(payload: ICommitTokenPayload): string {\n return Buffer.from(JSON.stringify(payload)).toString('base64url');\n }\n\n private static sign(opts: { body: string; secretKey: string }): string {\n // `Bun.CryptoHasher` given no key answers a plain SHA-256 instead of throwing, which anyone can compute: a\n // missing secret must stop here, as `createHmac` did, or a forged token would pass.\n if (typeof opts.secretKey !== 'string') {\n throw getError({\n message: '[AssetCommitToken][sign] Invalid secretKey | Expected a string',\n });\n }\n\n return new Bun.CryptoHasher('sha256', opts.secretKey).update(opts.body).digest('base64url');\n }\n\n /** Signs `{ bucket, key, expiresAt }` so the commit route can trust the key it is handed. */\n static build(opts: { payload: ICommitTokenPayload; secretKey: string }): string {\n const body = AssetCommitToken.encode(opts.payload);\n\n return `${body}.${AssetCommitToken.sign({ body, secretKey: opts.secretKey })}`;\n }\n\n /**\n * Reads a commit token back, or throws.\n *\n * Verification happens BEFORE any storage call, which is what makes the commit route refuse to be a\n * name prober: a forged token fails without a round trip, so timing says nothing about what exists.\n */\n static read(opts: { token: string; secretKey: string; now?: number }): ICommitTokenPayload {\n const { token, secretKey, now = Date.now() } = opts;\n const [body, signature] = token.split('.');\n\n if (!body || !signature) {\n throw getError(StaticAssetErrors.INVALID_COMMIT_TOKEN);\n }\n\n const expected = Buffer.from(AssetCommitToken.sign({ body, secretKey }));\n const given = Buffer.from(signature);\n\n // Length-checked first: `timingSafeEqual` throws on a length mismatch instead of answering false.\n if (expected.length !== given.length || !crypto.timingSafeEqual(expected, given)) {\n throw getError(StaticAssetErrors.INVALID_COMMIT_TOKEN);\n }\n\n const payload: ICommitTokenPayload = JSON.parse(\n Buffer.from(body, 'base64url').toString('utf8'),\n );\n\n if (payload.expiresAt <= now) {\n throw getError(StaticAssetErrors.EXPIRED_COMMIT_TOKEN);\n }\n\n return payload;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/components/static-asset/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,+BAA+B,EAAsC,MAAM,UAAU,CAAC;AAE/F,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEtD,kQAAkQ;AAClQ,IAAa,oBAAoB,4BA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e,EACb,KAAK,EAAE,eAAe;wBACtB,2KAA2K;wBAC3K,CAAC,CAAC,WAAW,EAAE,EAAE,CACf,sBAAsB,CAAC,eAAe,CAAC;4BACrC,QAAQ,EAAE,UAAU,CAAC,QAAQ;4BAC7B,MAAM,EAAE,WAAW,CAAC,MAAM;4BAC1B,MAAM,EAAE,WAAW,CAAC,MAAM;4BAC1B,mBAAmB,EAAE,UAAU,CAAC,MAAM,KAAK,SAAS;4BACpD,aAAa,EAAE,UAAU,CAAC,aAAa;yBACxC,CAAC,CAAC;iBACR;aACF,CAAC,CACH,CAAC;YAEF,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAC1B,iFAAiF,EACjF,GAAG,EACH,OAAO,EACP,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CACzB,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAA;AA1EY,oBAAoB;IAI5B,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAA;;GAJ1C,oBAAoB,CA0EhC","sourcesContent":["import { type BaseApplication } from '@/base/applications';\nimport { BaseComponent } from '@venizia/ignis-kernel';\nimport { inject } from '@/base/metadata';\nimport { CoreBindings } from '@venizia/ignis-kernel';\nimport { Binding } from '@venizia/ignis-kernel';\nimport { type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { StaticAssetComponentBindingKeys, type TStaticAssetsComponentOptions } from './common';\nimport type { TMetaLinkCompatibleSchema, TMetaLinkSchema } from './models';\nimport { AssetControllerFactory } from './controller';\n\n/** `Schema` is the MetaLink table the application binds. It has to live on the CLASS, not only on the options: `component(Ctor, { options })` infers the options from the class, so a class pinned to the shipped table can only carry options for that table. */\nexport class StaticAssetComponent<\n Schema extends TMetaLinkCompatibleSchema = TMetaLinkSchema,\n> extends BaseComponent<TStaticAssetsComponentOptions<Schema>> {\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: StaticAssetComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [StaticAssetComponentBindingKeys.STATIC_ASSET_COMPONENT_OPTIONS]:\n Binding.bind<TStaticAssetsComponentOptions>({\n key: StaticAssetComponentBindingKeys.STATIC_ASSET_COMPONENT_OPTIONS,\n }).toValue({}),\n },\n });\n }\n\n override binding(): ValueOrPromise<void> {\n // Direct options win. The key is the path for an application that registers this component\n // through `configs.artifacts`, where an index carries classes and no options.\n const componentOptions =\n this.options ??\n this.application.get<TStaticAssetsComponentOptions<Schema>>({\n key: StaticAssetComponentBindingKeys.STATIC_ASSET_COMPONENT_OPTIONS,\n });\n\n const componentOptionsEntries = Object.entries(componentOptions);\n for (const [key, opt] of componentOptionsEntries) {\n const {\n storage,\n controller,\n helper,\n extra,\n resolveObjectName,\n defineRoutesBefore,\n defineExtraRoutes,\n } = opt;\n\n this.application.controller(\n AssetControllerFactory.defineAssetController({\n controller,\n storage,\n helper,\n useMetaLink: opt.useMetaLink,\n metaLink: opt.useMetaLink ? opt.metaLink : undefined,\n resolveObjectName,\n defineRoutesBefore,\n defineExtraRoutes,\n options: {\n ...extra,\n normalizeLinkFn:\n extra?.normalizeLinkFn ??\n // The link follows the URL shape the controller serves: `{objectName}` is one Hono path segment unless `rawObjectPath` widens it, and a configured bucket leaves the path.\n ((linkOptions) =>\n AssetControllerFactory.buildObjectLink({\n basePath: controller.basePath,\n bucket: linkOptions.bucket,\n object: linkOptions.object,\n hasConfiguredBucket: controller.bucket !== undefined,\n rawObjectPath: controller.rawObjectPath,\n })),\n },\n }),\n );\n\n this.application.logger.info(\n `[binding] Asset storage is bound | Key: %s | Storage type: %s | UseMetaLink: %s`,\n key,\n storage,\n Boolean(opt.useMetaLink),\n );\n }\n }\n}\n"]}
1
+ {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/components/static-asset/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;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,sBAAsB,CAAC,qBAAqB,CAAC;gBAC3C,UAAU;gBACV,OAAO;gBACP,MAAM;gBACN,WAAW,EAAE,GAAG,CAAC,WAAW;gBAC5B,QAAQ,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;gBACpD,iBAAiB;gBACjB,kBAAkB;gBAClB,iBAAiB;gBACjB,OAAO,EAAE;oBACP,GAAG,KAAK;oBACR,eAAe,EACb,KAAK,EAAE,eAAe;wBACtB,2KAA2K;wBAC3K,CAAC,CAAC,WAAW,EAAE,EAAE,CACf,sBAAsB,CAAC,eAAe,CAAC;4BACrC,QAAQ,EAAE,UAAU,CAAC,QAAQ;4BAC7B,MAAM,EAAE,WAAW,CAAC,MAAM;4BAC1B,MAAM,EAAE,WAAW,CAAC,MAAM;4BAC1B,mBAAmB,EAAE,UAAU,CAAC,MAAM,KAAK,SAAS;4BACpD,aAAa,EAAE,UAAU,CAAC,aAAa;yBACxC,CAAC,CAAC;iBACR;aACF,CAAC,CACH,CAAC;YAEF,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAC1B,iFAAiF,EACjF,GAAG,EACH,OAAO,EACP,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CACzB,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAA;AA3EY,oBAAoB;IAI5B,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAA;;GAJ1C,oBAAoB,CA2EhC","sourcesContent":["import { type BaseApplication } from '@/base/applications';\nimport { BaseComponent } from '@venizia/ignis-kernel';\nimport { inject } from '@/base/metadata';\nimport { CoreBindings } from '@venizia/ignis-kernel';\nimport { Binding } from '@venizia/ignis-kernel';\nimport { type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { StaticAssetComponentBindingKeys, type TStaticAssetsComponentOptions } from './common';\nimport type { TMetaLinkCompatibleSchema, TMetaLinkSchema } from './models';\nimport { AssetControllerFactory } from './controller';\n\n/** `Schema` is the MetaLink table the application binds. It has to live on the CLASS, not only on the options: `component(Ctor, { options })` infers the options from the class, so a class pinned to the shipped table can only carry options for that table. */\nexport class StaticAssetComponent<\n Schema extends TMetaLinkCompatibleSchema = TMetaLinkSchema,\n> extends BaseComponent<TStaticAssetsComponentOptions<Schema>> {\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: StaticAssetComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [StaticAssetComponentBindingKeys.STATIC_ASSET_COMPONENT_OPTIONS]:\n Binding.bind<TStaticAssetsComponentOptions>({\n key: StaticAssetComponentBindingKeys.STATIC_ASSET_COMPONENT_OPTIONS,\n }).toValue({}),\n },\n });\n }\n\n override binding(): ValueOrPromise<void> {\n // Direct options win. The key is the path for an application that registers this component\n // through `configs.artifacts`, where an index carries classes and no options.\n const componentOptions =\n this.options ??\n this.application.get<TStaticAssetsComponentOptions<Schema>>({\n key: StaticAssetComponentBindingKeys.STATIC_ASSET_COMPONENT_OPTIONS,\n });\n\n const componentOptionsEntries = Object.entries(componentOptions);\n\n for (const [key, opt] of componentOptionsEntries) {\n const {\n storage,\n controller,\n helper,\n extra,\n resolveObjectName,\n defineRoutesBefore,\n defineExtraRoutes,\n } = opt;\n\n this.application.controller(\n AssetControllerFactory.defineAssetController({\n controller,\n storage,\n helper,\n useMetaLink: opt.useMetaLink,\n metaLink: opt.useMetaLink ? opt.metaLink : undefined,\n resolveObjectName,\n defineRoutesBefore,\n defineExtraRoutes,\n options: {\n ...extra,\n normalizeLinkFn:\n extra?.normalizeLinkFn ??\n // The link follows the URL shape the controller serves: `{objectName}` is one Hono path segment unless `rawObjectPath` widens it, and a configured bucket leaves the path.\n ((linkOptions) =>\n AssetControllerFactory.buildObjectLink({\n basePath: controller.basePath,\n bucket: linkOptions.bucket,\n object: linkOptions.object,\n hasConfiguredBucket: controller.bucket !== undefined,\n rawObjectPath: controller.rawObjectPath,\n })),\n },\n }),\n );\n\n this.application.logger.info(\n `[binding] Asset storage is bound | Key: %s | Storage type: %s | UseMetaLink: %s`,\n key,\n storage,\n Boolean(opt.useMetaLink),\n );\n }\n }\n}\n"]}