@venizia/ignis 0.4.8-0 → 0.4.8-1

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 (201) hide show
  1. package/dist/esm/base/applications/base.d.ts +19 -0
  2. package/dist/esm/base/applications/base.js +19 -0
  3. package/dist/esm/base/applications/base.js.map +1 -1
  4. package/dist/esm/base/applications/boot-steps.d.ts +1 -0
  5. package/dist/esm/base/applications/boot-steps.js.map +1 -1
  6. package/dist/esm/base/applications/common/types.d.ts +21 -4
  7. package/dist/esm/base/applications/common/types.js.map +1 -1
  8. package/dist/esm/base/metadata/request-context.d.ts +1 -0
  9. package/dist/esm/base/metadata/request-context.js +1 -0
  10. package/dist/esm/base/metadata/request-context.js.map +1 -1
  11. package/dist/esm/components/api-reference/common/constants.d.ts +1 -0
  12. package/dist/esm/components/api-reference/common/constants.js +1 -0
  13. package/dist/esm/components/api-reference/common/constants.js.map +1 -1
  14. package/dist/esm/components/api-reference/common/keys.d.ts +1 -0
  15. package/dist/esm/components/api-reference/common/keys.js +1 -0
  16. package/dist/esm/components/api-reference/common/keys.js.map +1 -1
  17. package/dist/esm/components/api-reference/common/types.d.ts +18 -1
  18. package/dist/esm/components/api-reference/common/types.js.map +1 -1
  19. package/dist/esm/components/api-reference/component.d.ts +14 -0
  20. package/dist/esm/components/api-reference/component.js +14 -0
  21. package/dist/esm/components/api-reference/component.js.map +1 -1
  22. package/dist/esm/components/api-reference/ui/factory.d.ts +1 -0
  23. package/dist/esm/components/api-reference/ui/factory.js +1 -0
  24. package/dist/esm/components/api-reference/ui/factory.js.map +1 -1
  25. package/dist/esm/components/api-reference/ui/scalar.d.ts +1 -0
  26. package/dist/esm/components/api-reference/ui/scalar.js +1 -0
  27. package/dist/esm/components/api-reference/ui/scalar.js.map +1 -1
  28. package/dist/esm/components/api-reference/ui/swagger.d.ts +1 -0
  29. package/dist/esm/components/api-reference/ui/swagger.js +1 -0
  30. package/dist/esm/components/api-reference/ui/swagger.js.map +1 -1
  31. package/dist/esm/components/auth/authenticate/component.d.ts +1 -0
  32. package/dist/esm/components/auth/authenticate/component.js +1 -0
  33. package/dist/esm/components/auth/authenticate/component.js.map +1 -1
  34. package/dist/esm/components/auth/authenticate/controllers/factory.d.ts +1 -0
  35. package/dist/esm/components/auth/authenticate/controllers/factory.js +1 -0
  36. package/dist/esm/components/auth/authenticate/controllers/factory.js.map +1 -1
  37. package/dist/esm/components/auth/authenticate/controllers/jwks/controller.d.ts +1 -0
  38. package/dist/esm/components/auth/authenticate/controllers/jwks/controller.js +1 -0
  39. package/dist/esm/components/auth/authenticate/controllers/jwks/controller.js.map +1 -1
  40. package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.d.ts +1 -0
  41. package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.js +1 -0
  42. package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.js.map +1 -1
  43. package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.d.ts +1 -0
  44. package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.js +1 -0
  45. package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.js.map +1 -1
  46. package/dist/esm/components/auth/authenticate/strategies/jwks/issuer.d.ts +1 -0
  47. package/dist/esm/components/auth/authenticate/strategies/jwks/issuer.js +1 -0
  48. package/dist/esm/components/auth/authenticate/strategies/jwks/issuer.js.map +1 -1
  49. package/dist/esm/components/auth/authenticate/strategies/jwks/verifier.d.ts +1 -0
  50. package/dist/esm/components/auth/authenticate/strategies/jwks/verifier.js +1 -0
  51. package/dist/esm/components/auth/authenticate/strategies/jwks/verifier.js.map +1 -1
  52. package/dist/esm/components/auth/authenticate/strategies/jws.strategy.d.ts +1 -0
  53. package/dist/esm/components/auth/authenticate/strategies/jws.strategy.js +1 -0
  54. package/dist/esm/components/auth/authenticate/strategies/jws.strategy.js.map +1 -1
  55. package/dist/esm/components/auth/authorize/adapters/scoped-casbin/common/types.d.ts +2 -0
  56. package/dist/esm/components/auth/authorize/adapters/scoped-casbin/common/types.js.map +1 -1
  57. package/dist/esm/components/auth/authorize/adapters/scoped-casbin/policy-edges.d.ts +1 -0
  58. package/dist/esm/components/auth/authorize/adapters/scoped-casbin/policy-edges.js +1 -0
  59. package/dist/esm/components/auth/authorize/adapters/scoped-casbin/policy-edges.js.map +1 -1
  60. package/dist/esm/components/auth/authorize/component.d.ts +1 -0
  61. package/dist/esm/components/auth/authorize/component.js +1 -0
  62. package/dist/esm/components/auth/authorize/component.js.map +1 -1
  63. package/dist/esm/components/auth/authorize/enforcers/casbin.enforcer.d.ts +1 -0
  64. package/dist/esm/components/auth/authorize/enforcers/casbin.enforcer.js +1 -0
  65. package/dist/esm/components/auth/authorize/enforcers/casbin.enforcer.js.map +1 -1
  66. package/dist/esm/components/auth/models/entities/columns.d.ts +1 -0
  67. package/dist/esm/components/auth/models/entities/columns.js.map +1 -1
  68. package/dist/esm/components/auth/models/entities/permission.model.d.ts +2 -0
  69. package/dist/esm/components/auth/models/entities/permission.model.js.map +1 -1
  70. package/dist/esm/components/auth/models/entities/policy-definition.model.d.ts +1 -0
  71. package/dist/esm/components/auth/models/entities/policy-definition.model.js.map +1 -1
  72. package/dist/esm/components/controller/grpc/common/types.d.ts +2 -0
  73. package/dist/esm/components/controller/grpc/common/types.js +1 -0
  74. package/dist/esm/components/controller/grpc/common/types.js.map +1 -1
  75. package/dist/esm/components/controller/grpc/grpc.component.d.ts +1 -0
  76. package/dist/esm/components/controller/grpc/grpc.component.js +1 -0
  77. package/dist/esm/components/controller/grpc/grpc.component.js.map +1 -1
  78. package/dist/esm/components/health-check/common/constants.d.ts +1 -0
  79. package/dist/esm/components/health-check/common/constants.js +1 -0
  80. package/dist/esm/components/health-check/common/constants.js.map +1 -1
  81. package/dist/esm/components/health-check/common/keys.d.ts +1 -0
  82. package/dist/esm/components/health-check/common/keys.js +1 -0
  83. package/dist/esm/components/health-check/common/keys.js.map +1 -1
  84. package/dist/esm/components/health-check/common/rest-paths.d.ts +1 -0
  85. package/dist/esm/components/health-check/common/rest-paths.js +1 -0
  86. package/dist/esm/components/health-check/common/rest-paths.js.map +1 -1
  87. package/dist/esm/components/health-check/common/types.d.ts +24 -3
  88. package/dist/esm/components/health-check/common/types.js.map +1 -1
  89. package/dist/esm/components/health-check/component.d.ts +15 -0
  90. package/dist/esm/components/health-check/component.js +15 -0
  91. package/dist/esm/components/health-check/component.js.map +1 -1
  92. package/dist/esm/components/health-check/controller.d.ts +1 -0
  93. package/dist/esm/components/health-check/controller.js +1 -0
  94. package/dist/esm/components/health-check/controller.js.map +1 -1
  95. package/dist/esm/components/mail/common/constants.d.ts +6 -0
  96. package/dist/esm/components/mail/common/constants.js +5 -0
  97. package/dist/esm/components/mail/common/constants.js.map +1 -1
  98. package/dist/esm/components/mail/common/keys.d.ts +1 -0
  99. package/dist/esm/components/mail/common/keys.js +1 -0
  100. package/dist/esm/components/mail/common/keys.js.map +1 -1
  101. package/dist/esm/components/mail/common/types/message.d.ts +10 -0
  102. package/dist/esm/components/mail/common/types/message.js.map +1 -1
  103. package/dist/esm/components/mail/common/types/options.d.ts +22 -1
  104. package/dist/esm/components/mail/common/types/options.js.map +1 -1
  105. package/dist/esm/components/mail/common/types/queue.d.ts +7 -0
  106. package/dist/esm/components/mail/common/types/queue.js.map +1 -1
  107. package/dist/esm/components/mail/common/types/template.d.ts +2 -0
  108. package/dist/esm/components/mail/common/types/template.js.map +1 -1
  109. package/dist/esm/components/mail/common/types/verification.d.ts +5 -0
  110. package/dist/esm/components/mail/common/types/verification.js.map +1 -1
  111. package/dist/esm/components/mail/component.d.ts +1 -0
  112. package/dist/esm/components/mail/component.js +1 -0
  113. package/dist/esm/components/mail/component.js.map +1 -1
  114. package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.d.ts +1 -0
  115. package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.js +1 -0
  116. package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.js.map +1 -1
  117. package/dist/esm/components/mail/helpers/executors/direct-executor.helper.d.ts +1 -0
  118. package/dist/esm/components/mail/helpers/executors/direct-executor.helper.js +1 -0
  119. package/dist/esm/components/mail/helpers/executors/direct-executor.helper.js.map +1 -1
  120. package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.d.ts +1 -0
  121. package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.js +1 -0
  122. package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.js.map +1 -1
  123. package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.d.ts +1 -0
  124. package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.js +1 -0
  125. package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.js.map +1 -1
  126. package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.d.ts +1 -0
  127. package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.js +1 -0
  128. package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.js.map +1 -1
  129. package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.d.ts +1 -0
  130. package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.js +1 -0
  131. package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.js.map +1 -1
  132. package/dist/esm/components/mail/providers/mail-queue-executor.provider.d.ts +2 -0
  133. package/dist/esm/components/mail/providers/mail-queue-executor.provider.js +1 -0
  134. package/dist/esm/components/mail/providers/mail-queue-executor.provider.js.map +1 -1
  135. package/dist/esm/components/mail/providers/mail-transporter.provider.d.ts +2 -0
  136. package/dist/esm/components/mail/providers/mail-transporter.provider.js +1 -0
  137. package/dist/esm/components/mail/providers/mail-transporter.provider.js.map +1 -1
  138. package/dist/esm/components/mail/services/generators/numeric-code.d.ts +1 -0
  139. package/dist/esm/components/mail/services/generators/numeric-code.js +1 -0
  140. package/dist/esm/components/mail/services/generators/numeric-code.js.map +1 -1
  141. package/dist/esm/components/mail/services/generators/random-token.d.ts +1 -0
  142. package/dist/esm/components/mail/services/generators/random-token.js +1 -0
  143. package/dist/esm/components/mail/services/generators/random-token.js.map +1 -1
  144. package/dist/esm/components/mail/services/generators/verification-data.d.ts +1 -0
  145. package/dist/esm/components/mail/services/generators/verification-data.js +1 -0
  146. package/dist/esm/components/mail/services/generators/verification-data.js.map +1 -1
  147. package/dist/esm/components/mail/services/mail.service.d.ts +1 -0
  148. package/dist/esm/components/mail/services/mail.service.js +1 -0
  149. package/dist/esm/components/mail/services/mail.service.js.map +1 -1
  150. package/dist/esm/components/mail/services/template.service.d.ts +1 -0
  151. package/dist/esm/components/mail/services/template.service.js +1 -0
  152. package/dist/esm/components/mail/services/template.service.js.map +1 -1
  153. package/dist/esm/components/mail/utilities/address.utility.d.ts +1 -0
  154. package/dist/esm/components/mail/utilities/address.utility.js +1 -0
  155. package/dist/esm/components/mail/utilities/address.utility.js.map +1 -1
  156. package/dist/esm/components/mail/utilities/mime.utility.d.ts +1 -0
  157. package/dist/esm/components/mail/utilities/mime.utility.js +1 -0
  158. package/dist/esm/components/mail/utilities/mime.utility.js.map +1 -1
  159. package/dist/esm/components/mail/utilities/verification.utility.d.ts +1 -0
  160. package/dist/esm/components/mail/utilities/verification.utility.js +1 -0
  161. package/dist/esm/components/mail/utilities/verification.utility.js.map +1 -1
  162. package/dist/esm/components/request-tracker/component.d.ts +1 -0
  163. package/dist/esm/components/request-tracker/component.js +1 -0
  164. package/dist/esm/components/request-tracker/component.js.map +1 -1
  165. package/dist/esm/components/socket-io/common/keys.d.ts +1 -0
  166. package/dist/esm/components/socket-io/common/keys.js +1 -0
  167. package/dist/esm/components/socket-io/common/keys.js.map +1 -1
  168. package/dist/esm/components/socket-io/component.d.ts +1 -0
  169. package/dist/esm/components/socket-io/component.js +1 -0
  170. package/dist/esm/components/socket-io/component.js.map +1 -1
  171. package/dist/esm/components/static-asset/common/constants.d.ts +3 -0
  172. package/dist/esm/components/static-asset/common/constants.js +1 -0
  173. package/dist/esm/components/static-asset/common/constants.js.map +1 -1
  174. package/dist/esm/components/static-asset/common/keys.d.ts +1 -0
  175. package/dist/esm/components/static-asset/common/keys.js +1 -0
  176. package/dist/esm/components/static-asset/common/keys.js.map +1 -1
  177. package/dist/esm/components/static-asset/common/types.d.ts +42 -6
  178. package/dist/esm/components/static-asset/common/types.js.map +1 -1
  179. package/dist/esm/components/static-asset/controller/factory.d.ts +2 -0
  180. package/dist/esm/components/static-asset/controller/factory.js +1 -0
  181. package/dist/esm/components/static-asset/controller/factory.js.map +1 -1
  182. package/dist/esm/components/static-asset/ingest.d.ts +5 -1
  183. package/dist/esm/components/static-asset/ingest.js.map +1 -1
  184. package/dist/esm/components/static-asset/models/base.model.d.ts +2 -0
  185. package/dist/esm/components/static-asset/models/base.model.js.map +1 -1
  186. package/dist/esm/components/websocket/common/keys.d.ts +1 -0
  187. package/dist/esm/components/websocket/common/keys.js +1 -0
  188. package/dist/esm/components/websocket/common/keys.js.map +1 -1
  189. package/dist/esm/components/websocket/component.d.ts +1 -0
  190. package/dist/esm/components/websocket/component.js +1 -0
  191. package/dist/esm/components/websocket/component.js.map +1 -1
  192. package/dist/esm/testing/assert-application-boots.d.ts +39 -8
  193. package/dist/esm/testing/assert-application-boots.js +14 -0
  194. package/dist/esm/testing/assert-application-boots.js.map +1 -1
  195. package/dist/esm/utilities/drizzle-result.utility.d.ts +1 -0
  196. package/dist/esm/utilities/drizzle-result.utility.js +1 -0
  197. package/dist/esm/utilities/drizzle-result.utility.js.map +1 -1
  198. package/dist/presets/app/preset.json +4 -4
  199. package/dist/presets/lib/preset.json +3 -3
  200. package/dist/presets/shared/preset.json +1 -1
  201. package/package.json +8 -8
@@ -1,5 +1,6 @@
1
1
  import { BaseHelper } from '@venizia/ignis-helpers/core';
2
2
  import type { IVerificationCodeGenerator, IVerificationData, IVerificationDataGenerator, IVerificationGenerationOptions, IVerificationTokenGenerator } from '../../common/index.js';
3
+ /** Builds `IVerificationData` from the bound code and token generators, with every timestamp taken at call time. */
3
4
  export declare class DefaultVerificationDataGenerator extends BaseHelper implements IVerificationDataGenerator {
4
5
  private codeGenerator;
5
6
  private tokenGenerator;
@@ -15,6 +15,7 @@ import { inject } from '../../../../base/metadata/index.js';
15
15
  import { BaseHelper } from '@venizia/ignis-helpers/core';
16
16
  import { MailKeys } from '../../common/index.js';
17
17
  import { MailVerificationUtility } from '../../utilities/index.js';
18
+ /** Builds `IVerificationData` from the bound code and token generators, with every timestamp taken at call time. */
18
19
  let DefaultVerificationDataGenerator = DefaultVerificationDataGenerator_1 = class DefaultVerificationDataGenerator extends BaseHelper {
19
20
  constructor(codeGenerator, tokenGenerator) {
20
21
  super({ scope: DefaultVerificationDataGenerator_1.name });
@@ -1 +1 @@
1
- {"version":3,"file":"verification-data.js","sourceRoot":"","sources":["../../../../../../src/components/mail/services/generators/verification-data.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AASzD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,IAAa,gCAAgC,wCAA7C,MAAa,gCACX,SAAQ,UAAU;IAGlB,YAEU,aAAyC,EAGzC,cAA2C;QAEnD,KAAK,CAAC,EAAE,KAAK,EAAE,kCAAgC,CAAC,IAAI,EAAE,CAAC,CAAC;QALhD,kBAAa,GAAb,aAAa,CAA4B;QAGzC,mBAAc,GAAd,cAAc,CAA6B;IAGrD,CAAC;IAED,wBAAwB,CAAC,OAAuC;QAC9D,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACjE,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACpE,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAErC,OAAO;YACL,gBAAgB,EAAE,IAAI;YACtB,eAAe,EAAE,GAAG;YACpB,aAAa,EAAE,uBAAuB,CAAC,aAAa,CAAC;gBACnD,OAAO,EAAE,OAAO,CAAC,iBAAiB;aACnC,CAAC,CAAC,WAAW,EAAE;YAChB,YAAY,EAAE,CAAC;YAEf,iBAAiB,EAAE,KAAK;YACxB,gBAAgB,EAAE,GAAG;YACrB,cAAc,EAAE,uBAAuB,CAAC,oBAAoB,CAAC;gBAC3D,KAAK,EAAE,OAAO,CAAC,gBAAgB;aAChC,CAAC,CAAC,WAAW,EAAE;YAEhB,cAAc,EAAE,GAAG;SACpB,CAAC;IACJ,CAAC;CACF,CAAA;AApCY,gCAAgC;IAKxC,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,gCAAgC,EAAE,CAAC,CAAA;IAG1D,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,iCAAiC,EAAE,CAAC,CAAA;;GARnD,gCAAgC,CAoC5C","sourcesContent":["import { inject } from '@/base/metadata';\nimport { BaseHelper } from '@venizia/ignis-helpers/core';\n// Interfaces are `import type`: with emitDecoratorMetadata on, a value import of a type-only name survives transpilation and the ESM named-import check fails at load.\nimport type {\n IVerificationCodeGenerator,\n IVerificationData,\n IVerificationDataGenerator,\n IVerificationGenerationOptions,\n IVerificationTokenGenerator,\n} from '../../common';\nimport { MailKeys } from '../../common';\nimport { MailVerificationUtility } from '../../utilities';\n\nexport class DefaultVerificationDataGenerator\n extends BaseHelper\n implements IVerificationDataGenerator\n{\n constructor(\n @inject({ key: MailKeys.MAIL_VERIFICATION_CODE_GENERATOR })\n private codeGenerator: IVerificationCodeGenerator,\n\n @inject({ key: MailKeys.MAIL_VERIFICATION_TOKEN_GENERATOR })\n private tokenGenerator: IVerificationTokenGenerator,\n ) {\n super({ scope: DefaultVerificationDataGenerator.name });\n }\n\n generateVerificationData(options: IVerificationGenerationOptions): IVerificationData {\n const code = this.codeGenerator.generateCode(options.codeLength);\n const token = this.tokenGenerator.generateToken(options.tokenBytes);\n const now = new Date().toISOString();\n\n return {\n verificationCode: code,\n codeGeneratedAt: now,\n codeExpiresAt: MailVerificationUtility.getExpiryTime({\n minutes: options.codeExpiryMinutes,\n }).toISOString(),\n codeAttempts: 0,\n\n verificationToken: token,\n tokenGeneratedAt: now,\n tokenExpiresAt: MailVerificationUtility.getExpiryTimeInHours({\n hours: options.tokenExpiryHours,\n }).toISOString(),\n\n lastCodeSentAt: now,\n };\n }\n}\n"]}
1
+ {"version":3,"file":"verification-data.js","sourceRoot":"","sources":["../../../../../../src/components/mail/services/generators/verification-data.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AASzD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,oHAAoH;AACpH,IAAa,gCAAgC,wCAA7C,MAAa,gCACX,SAAQ,UAAU;IAGlB,YAEU,aAAyC,EAGzC,cAA2C;QAEnD,KAAK,CAAC,EAAE,KAAK,EAAE,kCAAgC,CAAC,IAAI,EAAE,CAAC,CAAC;QALhD,kBAAa,GAAb,aAAa,CAA4B;QAGzC,mBAAc,GAAd,cAAc,CAA6B;IAGrD,CAAC;IAED,wBAAwB,CAAC,OAAuC;QAC9D,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACjE,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACpE,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAErC,OAAO;YACL,gBAAgB,EAAE,IAAI;YACtB,eAAe,EAAE,GAAG;YACpB,aAAa,EAAE,uBAAuB,CAAC,aAAa,CAAC;gBACnD,OAAO,EAAE,OAAO,CAAC,iBAAiB;aACnC,CAAC,CAAC,WAAW,EAAE;YAChB,YAAY,EAAE,CAAC;YAEf,iBAAiB,EAAE,KAAK;YACxB,gBAAgB,EAAE,GAAG;YACrB,cAAc,EAAE,uBAAuB,CAAC,oBAAoB,CAAC;gBAC3D,KAAK,EAAE,OAAO,CAAC,gBAAgB;aAChC,CAAC,CAAC,WAAW,EAAE;YAEhB,cAAc,EAAE,GAAG;SACpB,CAAC;IACJ,CAAC;CACF,CAAA;AApCY,gCAAgC;IAKxC,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,gCAAgC,EAAE,CAAC,CAAA;IAG1D,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,iCAAiC,EAAE,CAAC,CAAA;;GARnD,gCAAgC,CAoC5C","sourcesContent":["import { inject } from '@/base/metadata';\nimport { BaseHelper } from '@venizia/ignis-helpers/core';\n// Interfaces are `import type`: with emitDecoratorMetadata on, a value import of a type-only name survives transpilation and the ESM named-import check fails at load.\nimport type {\n IVerificationCodeGenerator,\n IVerificationData,\n IVerificationDataGenerator,\n IVerificationGenerationOptions,\n IVerificationTokenGenerator,\n} from '../../common';\nimport { MailKeys } from '../../common';\nimport { MailVerificationUtility } from '../../utilities';\n\n/** Builds `IVerificationData` from the bound code and token generators, with every timestamp taken at call time. */\nexport class DefaultVerificationDataGenerator\n extends BaseHelper\n implements IVerificationDataGenerator\n{\n constructor(\n @inject({ key: MailKeys.MAIL_VERIFICATION_CODE_GENERATOR })\n private codeGenerator: IVerificationCodeGenerator,\n\n @inject({ key: MailKeys.MAIL_VERIFICATION_TOKEN_GENERATOR })\n private tokenGenerator: IVerificationTokenGenerator,\n ) {\n super({ scope: DefaultVerificationDataGenerator.name });\n }\n\n generateVerificationData(options: IVerificationGenerationOptions): IVerificationData {\n const code = this.codeGenerator.generateCode(options.codeLength);\n const token = this.tokenGenerator.generateToken(options.tokenBytes);\n const now = new Date().toISOString();\n\n return {\n verificationCode: code,\n codeGeneratedAt: now,\n codeExpiresAt: MailVerificationUtility.getExpiryTime({\n minutes: options.codeExpiryMinutes,\n }).toISOString(),\n codeAttempts: 0,\n\n verificationToken: token,\n tokenGeneratedAt: now,\n tokenExpiresAt: MailVerificationUtility.getExpiryTimeInHours({\n hours: options.tokenExpiryHours,\n }).toISOString(),\n\n lastCodeSentAt: now,\n };\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { BaseService } from '@venizia/ignis-kernel';
2
2
  import type { IMailMessage, IMailSendResult, IMailService, IMailTemplateEngine, IMailTransport, TMailOptions } from '../common/index.js';
3
3
  import { type AnyType } from '@venizia/ignis-helpers/common';
4
+ /** Sends mail through the bound transport. `send` validates the message, applies the attachment policy and defaults `from`; failures are thrown as application errors with a mail message code, except `sendBatch`, which reports each failure in its result. */
4
5
  export declare class MailService extends BaseService implements IMailService {
5
6
  protected options: TMailOptions;
6
7
  protected transport: IMailTransport;
@@ -19,6 +19,7 @@ import { getError, isApplicationError } from '@venizia/ignis-helpers/core';
19
19
  import { PromiseUtility } from '@venizia/ignis-helpers';
20
20
  import { MailAttachmentUtility } from '../utilities/attachment.utility.js';
21
21
  import { MailBodyUtility } from '../utilities/body.utility.js';
22
+ /** Sends mail through the bound transport. `send` validates the message, applies the attachment policy and defaults `from`; failures are thrown as application errors with a mail message code, except `sendBatch`, which reports each failure in its result. */
22
23
  let MailService = MailService_1 = class MailService extends BaseService {
23
24
  constructor(options, transport, templateEngine) {
24
25
  super({ scope: MailService_1.name });
@@ -1 +1 @@
1
- {"version":3,"file":"mail.service.js","sourceRoot":"","sources":["../../../../../src/components/mail/services/mail.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,WAAW,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ACnC,CAAC;CACF,CAAA;AA7NY,WAAW;IAEnB,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAA;IAEtC,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,uBAAuB,EAAE,CAAC,CAAA;IAEjD,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,oBAAoB,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAA;;GANxD,WAAW,CA6NvB","sourcesContent":["import { HTTP } from '@venizia/ignis-helpers/common';\nimport { BaseService } from '@venizia/ignis-kernel';\nimport type {\n IMailMessage,\n IMailSendResult,\n IMailService,\n IMailTemplateEngine,\n IMailTransport,\n TMailOptions,\n} from '../common';\nimport { MailDefaults, MailErrorCodes, MailErrors, MailKeys } from '../common';\nimport { inject } from '@/base/metadata';\nimport { getError, isApplicationError } from '@venizia/ignis-helpers/core';\nimport { type AnyType } from '@venizia/ignis-helpers/common';\nimport { PromiseUtility } from '@venizia/ignis-helpers';\nimport { MailAttachmentUtility } from '../utilities/attachment.utility';\nimport { MailBodyUtility } from '../utilities/body.utility';\n\nexport class MailService extends BaseService implements IMailService {\n constructor(\n @inject({ key: MailKeys.MAIL_OPTIONS })\n protected options: TMailOptions,\n @inject({ key: MailKeys.MAIL_TRANSPORT_INSTANCE })\n protected transport: IMailTransport,\n @inject({ key: MailKeys.MAIL_TEMPLATE_ENGINE, isOptional: true })\n protected templateEngine?: IMailTemplateEngine,\n ) {\n super({ scope: MailService.name });\n this.logger\n .for(this.constructor.name)\n .info('Mail service initialized with provider: %s', this.options.provider);\n }\n\n async send(message: IMailMessage): Promise<IMailSendResult> {\n try {\n this.validateMessage(message);\n\n const emailMessage: IMailMessage = {\n ...message,\n from: message.from ?? this.getDefaultFrom(),\n };\n\n // The one place the attachment policy applies: every transport receives bytes, never a path.\n if (message.attachments) {\n const result2 = await MailAttachmentUtility.resolve({\n attachments: message.attachments,\n attachmentRoot: this.options.attachmentRoot,\n maxBytes: this.options.maxAttachmentBytes ?? MailDefaults.MAX_ATTACHMENT_BYTES,\n });\n emailMessage.attachments = result2;\n }\n\n this.logger.for(this.send.name).debug('Sending email to: %s', emailMessage.to);\n const result = await this.transport.send(emailMessage);\n\n if (result.success) {\n this.logger\n .for(this.send.name)\n .debug('Email sent successfully. MessageId: %s', result.messageId);\n } else {\n this.logger.for(this.send.name).debug('Email send failed: %s', result.error);\n }\n\n return result;\n } catch (error) {\n this.logger.for(this.send.name).error('Error sending email: %s', error);\n MailAttachmentUtility.release({ attachments: message.attachments });\n\n // An error the framework already shaped carries its own status and message code; re-wrapping as 500 would report a caller mistake as a server fault.\n if (isApplicationError(error)) {\n throw error;\n }\n\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n messageCode: MailErrorCodes.SEND_FAILED,\n // The raw text can carry a file path or a provider detail; it rides in `cause`, which only development responses show.\n message: 'Failed to send email',\n cause: error,\n });\n }\n }\n\n async sendBatch(\n messages: IMailMessage[],\n options?: { concurrency?: number },\n ): Promise<IMailSendResult[]> {\n try {\n const concurrency = options?.concurrency ?? MailDefaults.BATCH_CONCURRENCY;\n this.logger\n .for(this.sendBatch.name)\n .info('Sending batch of %d emails with concurrency: %d', messages.length, concurrency);\n\n const tasks = messages.map((message) => async () => {\n try {\n const result = await this.send(message);\n\n return result;\n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error',\n };\n }\n });\n\n const results = await PromiseUtility.executeWithLimit<IMailSendResult>({\n tasks,\n limit: concurrency,\n });\n\n const successCount = results.filter((r) => r.success).length;\n this.logger\n .for(this.sendBatch.name)\n .info(\n 'Batch send completed. Success: %d, Failed: %d',\n successCount,\n results.length - successCount,\n );\n\n return results;\n } catch (error) {\n this.logger.for(this.sendBatch.name).error('Error sending batch emails: %s', error);\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n messageCode: MailErrorCodes.BATCH_SEND_FAILED,\n message: 'Failed to send batch emails',\n cause: error,\n });\n }\n }\n\n async sendTemplate(opts: {\n templateName: string;\n data: Record<string, AnyType>;\n recipients: string | string[];\n options?: Partial<IMailMessage>;\n }): Promise<IMailSendResult> {\n const { templateName, data, recipients, options } = opts;\n\n try {\n if (!this.templateEngine) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n messageCode: MailErrorCodes.INVALID_CONFIGURATION,\n message: 'Template engine not configured',\n });\n }\n\n this.logger.for(this.sendTemplate.name).debug('Rendering template: %s', templateName);\n const html = this.templateEngine.render({\n templateName,\n data,\n requireValidate: options?.requireValidate,\n });\n\n const templateData = this.templateEngine.getTemplate(templateName);\n\n const message: IMailMessage = {\n to: recipients,\n subject:\n options?.subject ??\n (templateData?.subject !== undefined\n ? this.templateEngine.render({\n templateData: templateData.subject,\n data,\n requireValidate: options?.requireValidate,\n })\n : 'No Subject'),\n html,\n ...options,\n };\n\n const result = await this.send(message);\n\n return result;\n } catch (error) {\n this.logger.for(this.sendTemplate.name).error('Error sending template email: %s', error);\n throw error;\n }\n }\n\n async verify(): Promise<boolean> {\n try {\n this.logger.for(this.verify.name).debug('Verifying mail transport connection');\n const isValid = await this.transport.verify();\n this.logger.for(this.verify.name).debug('Verification result: %s', isValid);\n\n return isValid;\n } catch (error) {\n this.logger.for(this.verify.name).error('Verification failed: %s', error);\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n messageCode: MailErrorCodes.VERIFICATION_FAILED,\n message: 'Mail transport verification failed',\n cause: error,\n });\n }\n }\n\n protected validateMessage(message: IMailMessage): void {\n if (!message.to || (Array.isArray(message.to) && message.to.length === 0)) {\n throw getError({\n error: MailErrors.INVALID_RECIPIENT,\n message: 'Recipient email address is required',\n });\n }\n\n if (!message.subject) {\n throw getError({\n error: MailErrors.INVALID_CONFIGURATION,\n message: 'Email subject is required',\n });\n }\n\n if (!message.text && !message.html) {\n throw getError({\n error: MailErrors.INVALID_CONFIGURATION,\n message: 'Email must have either text or html content',\n });\n }\n\n MailBodyUtility.assertIsText({ message });\n }\n\n protected getDefaultFrom(): string {\n const { from, fromName } = this.options;\n\n // A display name is only renderable around an address: `\"Name\" <undefined>` is not a sender.\n if (!from) {\n return MailDefaults.FALLBACK_FROM;\n }\n\n if (!fromName) {\n return from;\n }\n\n return `\"${fromName}\" <${from}>`;\n }\n}\n"]}
1
+ {"version":3,"file":"mail.service.js","sourceRoot":"","sources":["../../../../../src/components/mail/services/mail.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AASpD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,iQAAiQ;AACjQ,IAAa,WAAW,mBAAxB,MAAa,WAAY,SAAQ,WAAW;IAC1C,YAEY,OAAqB,EAErB,SAAyB,EAEzB,cAAoC;QAE9C,KAAK,CAAC,EAAE,KAAK,EAAE,aAAW,CAAC,IAAI,EAAE,CAAC,CAAC;QANzB,YAAO,GAAP,OAAO,CAAc;QAErB,cAAS,GAAT,SAAS,CAAgB;QAEzB,mBAAc,GAAd,cAAc,CAAsB;QAG9C,IAAI,CAAC,MAAM;aACR,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;aAC1B,IAAI,CAAC,4CAA4C,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,C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vC,OAAO,EAAE,6CAA6C;aACvD,CAAC,CAAC;QACL,CAAC;QAED,eAAe,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAC5C,CAAC;IAES,cAAc;QACtB,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QAExC,6FAA6F;QAC7F,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,YAAY,CAAC,aAAa,CAAC;QACpC,CAAC;QAED,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,IAAI,QAAQ,MAAM,IAAI,GAAG,CAAC;IACnC,CAAC;CACF,CAAA;AA7NY,WAAW;IAEnB,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAA;IAEtC,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,uBAAuB,EAAE,CAAC,CAAA;IAEjD,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,oBAAoB,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAA;;GANxD,WAAW,CA6NvB","sourcesContent":["import { HTTP } from '@venizia/ignis-helpers/common';\nimport { BaseService } from '@venizia/ignis-kernel';\nimport type {\n IMailMessage,\n IMailSendResult,\n IMailService,\n IMailTemplateEngine,\n IMailTransport,\n TMailOptions,\n} from '../common';\nimport { MailDefaults, MailErrorCodes, MailErrors, MailKeys } from '../common';\nimport { inject } from '@/base/metadata';\nimport { getError, isApplicationError } from '@venizia/ignis-helpers/core';\nimport { type AnyType } from '@venizia/ignis-helpers/common';\nimport { PromiseUtility } from '@venizia/ignis-helpers';\nimport { MailAttachmentUtility } from '../utilities/attachment.utility';\nimport { MailBodyUtility } from '../utilities/body.utility';\n\n/** Sends mail through the bound transport. `send` validates the message, applies the attachment policy and defaults `from`; failures are thrown as application errors with a mail message code, except `sendBatch`, which reports each failure in its result. */\nexport class MailService extends BaseService implements IMailService {\n constructor(\n @inject({ key: MailKeys.MAIL_OPTIONS })\n protected options: TMailOptions,\n @inject({ key: MailKeys.MAIL_TRANSPORT_INSTANCE })\n protected transport: IMailTransport,\n @inject({ key: MailKeys.MAIL_TEMPLATE_ENGINE, isOptional: true })\n protected templateEngine?: IMailTemplateEngine,\n ) {\n super({ scope: MailService.name });\n this.logger\n .for(this.constructor.name)\n .info('Mail service initialized with provider: %s', this.options.provider);\n }\n\n async send(message: IMailMessage): Promise<IMailSendResult> {\n try {\n this.validateMessage(message);\n\n const emailMessage: IMailMessage = {\n ...message,\n from: message.from ?? this.getDefaultFrom(),\n };\n\n // The one place the attachment policy applies: every transport receives bytes, never a path.\n if (message.attachments) {\n const result2 = await MailAttachmentUtility.resolve({\n attachments: message.attachments,\n attachmentRoot: this.options.attachmentRoot,\n maxBytes: this.options.maxAttachmentBytes ?? MailDefaults.MAX_ATTACHMENT_BYTES,\n });\n emailMessage.attachments = result2;\n }\n\n this.logger.for(this.send.name).debug('Sending email to: %s', emailMessage.to);\n const result = await this.transport.send(emailMessage);\n\n if (result.success) {\n this.logger\n .for(this.send.name)\n .debug('Email sent successfully. MessageId: %s', result.messageId);\n } else {\n this.logger.for(this.send.name).debug('Email send failed: %s', result.error);\n }\n\n return result;\n } catch (error) {\n this.logger.for(this.send.name).error('Error sending email: %s', error);\n MailAttachmentUtility.release({ attachments: message.attachments });\n\n // An error the framework already shaped carries its own status and message code; re-wrapping as 500 would report a caller mistake as a server fault.\n if (isApplicationError(error)) {\n throw error;\n }\n\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n messageCode: MailErrorCodes.SEND_FAILED,\n // The raw text can carry a file path or a provider detail; it rides in `cause`, which only development responses show.\n message: 'Failed to send email',\n cause: error,\n });\n }\n }\n\n async sendBatch(\n messages: IMailMessage[],\n options?: { concurrency?: number },\n ): Promise<IMailSendResult[]> {\n try {\n const concurrency = options?.concurrency ?? MailDefaults.BATCH_CONCURRENCY;\n this.logger\n .for(this.sendBatch.name)\n .info('Sending batch of %d emails with concurrency: %d', messages.length, concurrency);\n\n const tasks = messages.map((message) => async () => {\n try {\n const result = await this.send(message);\n\n return result;\n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error',\n };\n }\n });\n\n const results = await PromiseUtility.executeWithLimit<IMailSendResult>({\n tasks,\n limit: concurrency,\n });\n\n const successCount = results.filter((r) => r.success).length;\n this.logger\n .for(this.sendBatch.name)\n .info(\n 'Batch send completed. Success: %d, Failed: %d',\n successCount,\n results.length - successCount,\n );\n\n return results;\n } catch (error) {\n this.logger.for(this.sendBatch.name).error('Error sending batch emails: %s', error);\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n messageCode: MailErrorCodes.BATCH_SEND_FAILED,\n message: 'Failed to send batch emails',\n cause: error,\n });\n }\n }\n\n async sendTemplate(opts: {\n templateName: string;\n data: Record<string, AnyType>;\n recipients: string | string[];\n options?: Partial<IMailMessage>;\n }): Promise<IMailSendResult> {\n const { templateName, data, recipients, options } = opts;\n\n try {\n if (!this.templateEngine) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n messageCode: MailErrorCodes.INVALID_CONFIGURATION,\n message: 'Template engine not configured',\n });\n }\n\n this.logger.for(this.sendTemplate.name).debug('Rendering template: %s', templateName);\n const html = this.templateEngine.render({\n templateName,\n data,\n requireValidate: options?.requireValidate,\n });\n\n const templateData = this.templateEngine.getTemplate(templateName);\n\n const message: IMailMessage = {\n to: recipients,\n subject:\n options?.subject ??\n (templateData?.subject !== undefined\n ? this.templateEngine.render({\n templateData: templateData.subject,\n data,\n requireValidate: options?.requireValidate,\n })\n : 'No Subject'),\n html,\n ...options,\n };\n\n const result = await this.send(message);\n\n return result;\n } catch (error) {\n this.logger.for(this.sendTemplate.name).error('Error sending template email: %s', error);\n throw error;\n }\n }\n\n async verify(): Promise<boolean> {\n try {\n this.logger.for(this.verify.name).debug('Verifying mail transport connection');\n const isValid = await this.transport.verify();\n this.logger.for(this.verify.name).debug('Verification result: %s', isValid);\n\n return isValid;\n } catch (error) {\n this.logger.for(this.verify.name).error('Verification failed: %s', error);\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n messageCode: MailErrorCodes.VERIFICATION_FAILED,\n message: 'Mail transport verification failed',\n cause: error,\n });\n }\n }\n\n protected validateMessage(message: IMailMessage): void {\n if (!message.to || (Array.isArray(message.to) && message.to.length === 0)) {\n throw getError({\n error: MailErrors.INVALID_RECIPIENT,\n message: 'Recipient email address is required',\n });\n }\n\n if (!message.subject) {\n throw getError({\n error: MailErrors.INVALID_CONFIGURATION,\n message: 'Email subject is required',\n });\n }\n\n if (!message.text && !message.html) {\n throw getError({\n error: MailErrors.INVALID_CONFIGURATION,\n message: 'Email must have either text or html content',\n });\n }\n\n MailBodyUtility.assertIsText({ message });\n }\n\n protected getDefaultFrom(): string {\n const { from, fromName } = this.options;\n\n // A display name is only renderable around an address: `\"Name\" <undefined>` is not a sender.\n if (!from) {\n return MailDefaults.FALLBACK_FROM;\n }\n\n if (!fromName) {\n return from;\n }\n\n return `\"${fromName}\" <${from}>`;\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { BaseService } from '@venizia/ignis-kernel';
2
2
  import type { IMailTemplateEngine, ITemplate } from '../common/index.js';
3
3
  import type { AnyType } from '@venizia/ignis-helpers/common';
4
+ /** In-memory template store and renderer. Templates registered here are lost on restart. */
4
5
  export declare class TemplateEngineService extends BaseService implements IMailTemplateEngine {
5
6
  private templates;
6
7
  constructor();
@@ -1,6 +1,7 @@
1
1
  import { BaseService } from '@venizia/ignis-kernel';
2
2
  import { MailErrors } from '../common/index.js';
3
3
  import { getError } from '@venizia/ignis-helpers/core';
4
+ /** In-memory template store and renderer. Templates registered here are lost on restart. */
4
5
  export class TemplateEngineService extends BaseService {
5
6
  constructor() {
6
7
  super({ scope: TemplateEngineService.name });
@@ -1 +1 @@
1
- {"version":3,"file":"template.service.js","sourceRoot":"","sources":["../../../../../src/components/mail/services/template.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,MAAM,OAAO,qBAAsB,SAAQ,WAAW;IAGpD;QACE,KAAK,CAAC,EAAE,KAAK,EAAE,qBAAqB,CAAC,IAAI,EAAE,CAAC,CAAC;QAHvC,cAAS,GAA2B,IAAI,GAAG,EAAE,CAAC;QAIpD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;IAC7E,CAAC;IAED,gBAAgB,CAAC,IAAqE;QACpF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QACxC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,0BAA0B,EAAE,IAAI,CAAC,CAAC;QAEnF,MAAM,QAAQ,GAAc;YAC1B,IAAI;YACJ,OAAO;YACP,OAAO,EAAE,OAAO,EAAE,OAAO;YACzB,WAAW,EAAE,OAAO,EAAE,WAAW;SAClC,CAAC;QAEF,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACrC,CAAC;IAED,MAAM,CAAC,IAKN;QACC,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,IAAI,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC;QAEnE,IAAI,CAAC,YAAY,IAAI,CAAC,YAAY,EAAE,CAAC;YACnC,MAAM,QAAQ,CAAC,EAAE,OAAO,EAAE,sDAAsD,EAAE,CAAC,CAAC;QACtF,CAAC;QAED,IAA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-kernel';\nimport type { IMailTemplateEngine, ITemplate } from '../common';\nimport { MailErrors } from '../common';\nimport type { AnyType } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\n\nexport class TemplateEngineService extends BaseService implements IMailTemplateEngine {\n private templates: Map<string, ITemplate> = new Map();\n\n constructor() {\n super({ scope: TemplateEngineService.name });\n this.logger.for(this.constructor.name).info('Template engine initialized');\n }\n\n registerTemplate(opts: { name: string; content: string; options?: Partial<ITemplate> }): void {\n const { name, content, options } = opts;\n this.logger.for(this.registerTemplate.name).info('Registering template: %s', name);\n\n const template: ITemplate = {\n name,\n content,\n subject: options?.subject,\n description: options?.description,\n };\n\n this.templates.set(name, template);\n }\n\n render(opts: {\n templateData?: string;\n templateName?: string;\n data: Record<string, AnyType>;\n requireValidate?: boolean;\n }): string {\n const { templateData, templateName, data, requireValidate } = opts;\n\n if (!templateData && !templateName) {\n throw getError({ message: 'Either templateName or templateData must be provided' });\n }\n\n let content = templateData;\n\n if (!content && templateName) {\n const template = this.templates.get(templateName);\n\n if (!template) {\n throw getError({\n error: MailErrors.TEMPLATE_NOT_FOUND,\n message: `Template not found: ${templateName}`,\n });\n }\n\n this.logger.for(this.render.name).debug('Rendering template: %s', templateName);\n\n content = template.content;\n }\n\n // TODO: check content! later\n return this.renderSimpleTemplate(content!, data, { requireValidate });\n }\n\n getTemplate(name: string): ITemplate | undefined {\n return this.templates.get(name);\n }\n\n listTemplates(): ITemplate[] {\n return Array.from(this.templates.values());\n }\n\n hasTemplate(name: string): boolean {\n return this.templates.has(name);\n }\n\n removeTemplate(name: string): boolean {\n this.logger.for(this.removeTemplate.name).info('Removing template: %s', name);\n\n return this.templates.delete(name);\n }\n\n clearTemplates(): void {\n this.logger.for(this.clearTemplates.name).info('Clearing all templates');\n this.templates.clear();\n }\n\n validateTemplateData(opts: { template: string; data: Record<string, AnyType> }): {\n isValid: boolean;\n missingKeys: string[];\n allKeys: string[];\n } {\n const { template, data } = opts;\n const placeholderRegex = /\\{\\{(\\s*[\\w.]+\\s*)\\}\\}/g;\n const allKeys: string[] = [];\n const missingKeys: string[] = [];\n\n let match: RegExpExecArray | null;\n\n while ((match = placeholderRegex.exec(template)) !== null) {\n const key = match[1].trim();\n\n if (allKeys.includes(key)) {\n continue;\n }\n\n allKeys.push(key);\n\n const value = this.getNestedValue(data, key);\n\n if (value === undefined || value === null) {\n missingKeys.push(key);\n }\n }\n\n const isValid = missingKeys.length === 0;\n\n if (!isValid) {\n this.logger\n .for(this.validateTemplateData.name)\n .warn('Template validation failed | Missing keys: %s', missingKeys.join(', '));\n }\n\n return { isValid, missingKeys, allKeys };\n }\n\n renderSimpleTemplate(\n template: string,\n data: Record<string, AnyType>,\n opts?: { requireValidate?: boolean },\n ): string {\n if (opts?.requireValidate) {\n const validation = this.validateTemplateData({ template, data });\n\n if (!validation.isValid) {\n throw getError({\n error: MailErrors.INVALID_CONFIGURATION,\n message: `Missing template data for keys: ${validation.missingKeys.join(', ')}`,\n });\n }\n }\n\n return template.replace(/\\{\\{(\\s*[\\w.]+\\s*)\\}\\}/g, (match, key) => {\n const trimmedKey = key.trim();\n const value = this.getNestedValue(data, trimmedKey);\n\n if (value === undefined || value === null) {\n this.logger\n .for(this.renderSimpleTemplate.name)\n .warn('Missing value for key: %s', trimmedKey);\n\n return match;\n }\n\n return String(value);\n });\n }\n\n private getNestedValue(obj: AnyType, path: string) {\n return path.split('.').reduce((current, key) => {\n return current?.[key];\n }, obj);\n }\n}\n"]}
1
+ {"version":3,"file":"template.service.js","sourceRoot":"","sources":["../../../../../src/components/mail/services/template.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,4FAA4F;AAC5F,MAAM,OAAO,qBAAsB,SAAQ,WAAW;IAGpD;QACE,KAAK,CAA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BAAqB;oBACvC,OAAO,EAAE,mCAAmC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;iBAChF,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO,QAAQ,CAAC,OAAO,CAAC,yBAAyB,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YAChE,MAAM,UAAU,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;YAC9B,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;YAEpD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBAC1C,IAAI,CAAC,MAAM;qBACR,GAAG,CAAC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC;qBACnC,IAAI,CAAC,2BAA2B,EAAE,UAAU,CAAC,CAAC;gBAEjD,OAAO,KAAK,CAAC;YACf,CAAC;YAED,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,cAAc,CAAC,GAAY,EAAE,IAAY;QAC/C,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE;YAC7C,OAAO,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC,EAAE,GAAG,CAAC,CAAC;IACV,CAAC;CACF","sourcesContent":["import { BaseService } from '@venizia/ignis-kernel';\nimport type { IMailTemplateEngine, ITemplate } from '../common';\nimport { MailErrors } from '../common';\nimport type { AnyType } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\n\n/** In-memory template store and renderer. Templates registered here are lost on restart. */\nexport class TemplateEngineService extends BaseService implements IMailTemplateEngine {\n private templates: Map<string, ITemplate> = new Map();\n\n constructor() {\n super({ scope: TemplateEngineService.name });\n this.logger.for(this.constructor.name).info('Template engine initialized');\n }\n\n registerTemplate(opts: { name: string; content: string; options?: Partial<ITemplate> }): void {\n const { name, content, options } = opts;\n this.logger.for(this.registerTemplate.name).info('Registering template: %s', name);\n\n const template: ITemplate = {\n name,\n content,\n subject: options?.subject,\n description: options?.description,\n };\n\n this.templates.set(name, template);\n }\n\n render(opts: {\n templateData?: string;\n templateName?: string;\n data: Record<string, AnyType>;\n requireValidate?: boolean;\n }): string {\n const { templateData, templateName, data, requireValidate } = opts;\n\n if (!templateData && !templateName) {\n throw getError({ message: 'Either templateName or templateData must be provided' });\n }\n\n let content = templateData;\n\n if (!content && templateName) {\n const template = this.templates.get(templateName);\n\n if (!template) {\n throw getError({\n error: MailErrors.TEMPLATE_NOT_FOUND,\n message: `Template not found: ${templateName}`,\n });\n }\n\n this.logger.for(this.render.name).debug('Rendering template: %s', templateName);\n\n content = template.content;\n }\n\n // TODO: check content! later\n return this.renderSimpleTemplate(content!, data, { requireValidate });\n }\n\n getTemplate(name: string): ITemplate | undefined {\n return this.templates.get(name);\n }\n\n listTemplates(): ITemplate[] {\n return Array.from(this.templates.values());\n }\n\n hasTemplate(name: string): boolean {\n return this.templates.has(name);\n }\n\n removeTemplate(name: string): boolean {\n this.logger.for(this.removeTemplate.name).info('Removing template: %s', name);\n\n return this.templates.delete(name);\n }\n\n clearTemplates(): void {\n this.logger.for(this.clearTemplates.name).info('Clearing all templates');\n this.templates.clear();\n }\n\n validateTemplateData(opts: { template: string; data: Record<string, AnyType> }): {\n isValid: boolean;\n missingKeys: string[];\n allKeys: string[];\n } {\n const { template, data } = opts;\n const placeholderRegex = /\\{\\{(\\s*[\\w.]+\\s*)\\}\\}/g;\n const allKeys: string[] = [];\n const missingKeys: string[] = [];\n\n let match: RegExpExecArray | null;\n\n while ((match = placeholderRegex.exec(template)) !== null) {\n const key = match[1].trim();\n\n if (allKeys.includes(key)) {\n continue;\n }\n\n allKeys.push(key);\n\n const value = this.getNestedValue(data, key);\n\n if (value === undefined || value === null) {\n missingKeys.push(key);\n }\n }\n\n const isValid = missingKeys.length === 0;\n\n if (!isValid) {\n this.logger\n .for(this.validateTemplateData.name)\n .warn('Template validation failed | Missing keys: %s', missingKeys.join(', '));\n }\n\n return { isValid, missingKeys, allKeys };\n }\n\n renderSimpleTemplate(\n template: string,\n data: Record<string, AnyType>,\n opts?: { requireValidate?: boolean },\n ): string {\n if (opts?.requireValidate) {\n const validation = this.validateTemplateData({ template, data });\n\n if (!validation.isValid) {\n throw getError({\n error: MailErrors.INVALID_CONFIGURATION,\n message: `Missing template data for keys: ${validation.missingKeys.join(', ')}`,\n });\n }\n }\n\n return template.replace(/\\{\\{(\\s*[\\w.]+\\s*)\\}\\}/g, (match, key) => {\n const trimmedKey = key.trim();\n const value = this.getNestedValue(data, trimmedKey);\n\n if (value === undefined || value === null) {\n this.logger\n .for(this.renderSimpleTemplate.name)\n .warn('Missing value for key: %s', trimmedKey);\n\n return match;\n }\n\n return String(value);\n });\n }\n\n private getNestedValue(obj: AnyType, path: string) {\n return path.split('.').reduce((current, key) => {\n return current?.[key];\n }, obj);\n }\n}\n"]}
@@ -1,3 +1,4 @@
1
+ /** Helpers for mailbox address strings. */
1
2
  export declare class MailAddressUtility {
2
3
  /**
3
4
  * Splits one or more RFC 5322 mailbox strings into individual addresses. A caller-supplied `to`
@@ -1,3 +1,4 @@
1
+ /** Helpers for mailbox address strings. */
1
2
  export class MailAddressUtility {
2
3
  /**
3
4
  * Splits one or more RFC 5322 mailbox strings into individual addresses. A caller-supplied `to`
@@ -1 +1 @@
1
- {"version":3,"file":"address.utility.js","sourceRoot":"","sources":["../../../../../src/components/mail/utilities/address.utility.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,kBAAkB;IAC7B;;;;;;OAMG;IACH,MAAM,CAAC,SAAS,CAAC,IAAkC;QACjD,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QACvB,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACrD,MAAM,SAAS,GAAa,EAAE,CAAC;QAE/B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,OAAO,GAAG,EAAE,CAAC;YACjB,IAAI,QAAQ,GAAG,KAAK,CAAC;YAErB,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;gBACxB,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;oBACjB,QAAQ,GAAG,CAAC,QAAQ,CAAC;gBACvB,CAAC;gBAED,IAAI,IAAI,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;oBAC9B,IAAI,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;wBACnB,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;oBACjC,CAAC;oBAED,OAAO,GAAG,EAAE,CAAC;oBACb,SAAS;gBACX,CAAC;gBAED,OAAO,IAAI,IAAI,CAAC;YAClB,CAAC;YAED,IAAI,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;gBACnB,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;YACjC,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["export class MailAddressUtility {\n /**\n * Splits one or more RFC 5322 mailbox strings into individual addresses. A caller-supplied `to`\n * is frequently a single comma-separated string (`\"a@x.com, b@y.com\"`), not an array - treating\n * it as one opaque address turns it into a single malformed recipient. Splitting only at\n * top-level commas (outside a quoted display name) keeps `\"Doe, Jane\" <jane@x.com>` intact while\n * still separating `\"Doe, Jane\" <jane@x.com>, bob@y.com` into its two mailboxes.\n */\n static splitList(opts: { value: string | string[] }): string[] {\n const { value } = opts;\n const items = Array.isArray(value) ? value : [value];\n const addresses: string[] = [];\n\n for (const item of items) {\n let current = '';\n let inQuotes = false;\n\n for (const char of item) {\n if (char === '\"') {\n inQuotes = !inQuotes;\n }\n\n if (char === ',' && !inQuotes) {\n if (current.trim()) {\n addresses.push(current.trim());\n }\n\n current = '';\n continue;\n }\n\n current += char;\n }\n\n if (current.trim()) {\n addresses.push(current.trim());\n }\n }\n\n return addresses;\n }\n}\n"]}
1
+ {"version":3,"file":"address.utility.js","sourceRoot":"","sources":["../../../../../src/components/mail/utilities/address.utility.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,MAAM,OAAO,kBAAkB;IAC7B;;;;;;OAMG;IACH,MAAM,CAAC,SAAS,CAAC,IAAkC;QACjD,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QACvB,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACrD,MAAM,SAAS,GAAa,EAAE,CAAC;QAE/B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,OAAO,GAAG,EAAE,CAAC;YACjB,IAAI,QAAQ,GAAG,KAAK,CAAC;YAErB,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;gBACxB,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;oBACjB,QAAQ,GAAG,CAAC,QAAQ,CAAC;gBACvB,CAAC;gBAED,IAAI,IAAI,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;oBAC9B,IAAI,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;wBACnB,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;oBACjC,CAAC;oBAED,OAAO,GAAG,EAAE,CAAC;oBACb,SAAS;gBACX,CAAC;gBAED,OAAO,IAAI,IAAI,CAAC;YAClB,CAAC;YAED,IAAI,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;gBACnB,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;YACjC,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["/** Helpers for mailbox address strings. */\nexport class MailAddressUtility {\n /**\n * Splits one or more RFC 5322 mailbox strings into individual addresses. A caller-supplied `to`\n * is frequently a single comma-separated string (`\"a@x.com, b@y.com\"`), not an array - treating\n * it as one opaque address turns it into a single malformed recipient. Splitting only at\n * top-level commas (outside a quoted display name) keeps `\"Doe, Jane\" <jane@x.com>` intact while\n * still separating `\"Doe, Jane\" <jane@x.com>, bob@y.com` into its two mailboxes.\n */\n static splitList(opts: { value: string | string[] }): string[] {\n const { value } = opts;\n const items = Array.isArray(value) ? value : [value];\n const addresses: string[] = [];\n\n for (const item of items) {\n let current = '';\n let inQuotes = false;\n\n for (const char of item) {\n if (char === '\"') {\n inQuotes = !inQuotes;\n }\n\n if (char === ',' && !inQuotes) {\n if (current.trim()) {\n addresses.push(current.trim());\n }\n\n current = '';\n continue;\n }\n\n current += char;\n }\n\n if (current.trim()) {\n addresses.push(current.trim());\n }\n }\n\n return addresses;\n }\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import { type IMailMessage } from '../common/index.js';
2
+ /** Builds the MIME pieces the Amazon SES transport sends: the raw message and RFC 5322 address headers. */
2
3
  export declare class MailMimeUtility {
3
4
  /** Formats a `to`/`cc`/`from`/`replyTo` field as one RFC 5322 address list: splits a
4
5
  * comma-separated string or array into individual mailboxes, RFC 2047-encodes each display name,
@@ -294,6 +294,7 @@ async function attachmentPart(attachment, boundary) {
294
294
  function newBoundary(label) {
295
295
  return `----=_${label}_${generateRandomHex({ bytes: 12 })}`;
296
296
  }
297
+ /** Builds the MIME pieces the Amazon SES transport sends: the raw message and RFC 5322 address headers. */
297
298
  export class MailMimeUtility {
298
299
  /** Formats a `to`/`cc`/`from`/`replyTo` field as one RFC 5322 address list: splits a
299
300
  * comma-separated string or array into individual mailboxes, RFC 2047-encodes each display name,
@@ -1 +1 @@
1
- {"version":3,"file":"mime.utility.js","sourceRoot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AS,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
+ {"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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,CAAC,GAAG,OAAO,EAAE,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,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\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\n/** Builds the MIME pieces the Amazon SES transport sends: the raw message and RFC 5322 address headers. */\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,3 +1,4 @@
1
+ /** Computes expiry timestamps for verification data from now. */
1
2
  export declare class MailVerificationUtility {
2
3
  static getExpiryTime(opts: {
3
4
  minutes: number;
@@ -1,3 +1,4 @@
1
+ /** Computes expiry timestamps for verification data from now. */
1
2
  export class MailVerificationUtility {
2
3
  static getExpiryTime(opts) {
3
4
  return new Date(Date.now() + opts.minutes * 60 * 1000);
@@ -1 +1 @@
1
- {"version":3,"file":"verification.utility.js","sourceRoot":"","sources":["../../../../../src/components/mail/utilities/verification.utility.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,uBAAuB;IAClC,MAAM,CAAC,aAAa,CAAC,IAAyB;QAC5C,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IACzD,CAAC;IAED,MAAM,CAAC,oBAAoB,CAAC,IAAuB;QACjD,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IAC5D,CAAC;CACF","sourcesContent":["export class MailVerificationUtility {\n static getExpiryTime(opts: { minutes: number }): Date {\n return new Date(Date.now() + opts.minutes * 60 * 1000);\n }\n\n static getExpiryTimeInHours(opts: { hours: number }): Date {\n return new Date(Date.now() + opts.hours * 60 * 60 * 1000);\n }\n}\n"]}
1
+ {"version":3,"file":"verification.utility.js","sourceRoot":"","sources":["../../../../../src/components/mail/utilities/verification.utility.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,MAAM,OAAO,uBAAuB;IAClC,MAAM,CAAC,aAAa,CAAC,IAAyB;QAC5C,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IACzD,CAAC;IAED,MAAM,CAAC,oBAAoB,CAAC,IAAuB;QACjD,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IAC5D,CAAC;CACF","sourcesContent":["/** Computes expiry timestamps for verification data from now. */\nexport class MailVerificationUtility {\n static getExpiryTime(opts: { minutes: number }): Date {\n return new Date(Date.now() + opts.minutes * 60 * 1000);\n }\n\n static getExpiryTimeInHours(opts: { hours: number }): Date {\n return new Date(Date.now() + opts.hours * 60 * 60 * 1000);\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { type BaseApplication } from '../../base/applications/index.js';
2
2
  import { BaseComponent } from '@venizia/ignis-kernel';
3
3
  import { type ValueOrPromise } from '@venizia/ignis-helpers/common';
4
+ /** Installs the request spy middleware on the application server, which tracks each request. */
4
5
  export declare class RequestTrackerComponent extends BaseComponent {
5
6
  private application;
6
7
  static readonly REQUEST_TRACKER_MW_BINDING_KEY: string;
@@ -17,6 +17,7 @@ import { RequestSpyMiddleware } from '../../base/middlewares/index.js';
17
17
  import { BindingNamespaces, CoreBindings } from '@venizia/ignis-kernel';
18
18
  import { Binding, BindingScopes } from '@venizia/ignis-kernel';
19
19
  import { getError } from '@venizia/ignis-helpers/core';
20
+ /** Installs the request spy middleware on the application server, which tracks each request. */
20
21
  let RequestTrackerComponent = class RequestTrackerComponent extends BaseComponent {
21
22
  static { RequestTrackerComponent_1 = this; }
22
23
  static { this.REQUEST_TRACKER_MW_BINDING_KEY = [
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/components/request-tracker/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAIvD,IAAa,uBAAuB,GAApC,MAAa,uBAAwB,SAAQ,aAAa;;aACxC,mCAA8B,GAAG;QAC/C,iBAAiB,CAAC,UAAU;QAC5B,oBAAoB,CAAC,IAAI;KAC1B,CAAC,IAAI,CAAC,GAAG,CAAC,AAHmC,CAGlC;IAEZ,YAC8D,WAA4B;QAExF,KAAK,CAAC;YACJ,KAAK,EAAE,yBAAuB,CAAC,IAAI;YACnC,WAAW,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE;YACrD,QAAQ,EAAE;gBACR,CAAC,yBAAuB,CAAC,8BAA8B,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC;oBACrE,GAAG,EAAE,yBAAuB,CAAC,8BAA8B;iBAC5D,CAAC;qBACC,UAAU,CAAC,oBAAoB,CAAC;qBAChC,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC;aACrC;SACF,CAAC,CAAC;QAZyD,gBAAW,GAAX,WAAW,CAAiB;IAa1F,CAAC;IAED,sTAAsT;IAC7S,OAAO;QACd,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC;QAE5C,MAAM,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAoB;YACjD,GAAG,EAAE,yBAAuB,CAAC,8BAA8B;SAC5D,CAAC,CAAC;QAEH,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,2HAA2H,yBAAuB,CAAC,8BAA8B,EAAE;aAC7L,CAAC,CAAC;QACL,CAAC;QAED,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;;AArCU,uBAAuB;IAO/B,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAA;;GAP1C,uBAAuB,CAsCnC","sourcesContent":["import { type BaseApplication } from '@/base/applications';\nimport { BaseComponent } from '@venizia/ignis-kernel';\nimport { inject } from '@/base/metadata';\nimport { RequestSpyMiddleware } from '@/base/middlewares';\nimport { BindingNamespaces, CoreBindings } from '@venizia/ignis-kernel';\nimport { Binding, BindingScopes } from '@venizia/ignis-kernel';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { type MiddlewareHandler } from 'hono/types';\n\nexport class RequestTrackerComponent extends BaseComponent {\n static readonly REQUEST_TRACKER_MW_BINDING_KEY = [\n BindingNamespaces.MIDDLEWARE,\n RequestSpyMiddleware.name,\n ].join('.');\n\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: RequestTrackerComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [RequestTrackerComponent.REQUEST_TRACKER_MW_BINDING_KEY]: Binding.bind({\n key: RequestTrackerComponent.REQUEST_TRACKER_MW_BINDING_KEY,\n })\n .toProvider(RequestSpyMiddleware)\n .setScope(BindingScopes.SINGLETON),\n },\n });\n }\n\n /** No `requestId()` here: the id is installed by `RestApplication.registerDefaultMiddlewares()`, which runs first and uses `RequestIdGenerator`. Same UUID v4 shape hono's own default produces, but hono calls `crypto.randomUUID` unguarded, and a browser leaves that one `undefined` outside a secure context. */\n override binding(): ValueOrPromise<void> {\n const server = this.application.getServer();\n\n const mw = this.application.get<MiddlewareHandler>({\n key: RequestTrackerComponent.REQUEST_TRACKER_MW_BINDING_KEY,\n });\n\n if (!mw) {\n throw getError({\n message: `[RequestTrackerComponent][binding] Invalid middleware to init request tracker | Please check again binding value | key: ${RequestTrackerComponent.REQUEST_TRACKER_MW_BINDING_KEY}`,\n });\n }\n\n server.use(mw);\n }\n}\n"]}
1
+ {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/components/request-tracker/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAIvD,gGAAgG;AAChG,IAAa,uBAAuB,GAApC,MAAa,uBAAwB,SAAQ,aAAa;;aACxC,mCAA8B,GAAG;QAC/C,iBAAiB,CAAC,UAAU;QAC5B,oBAAoB,CAAC,IAAI;KAC1B,CAAC,IAAI,CAAC,GAAG,CAAC,AAHmC,CAGlC;IAEZ,YAC8D,WAA4B;QAExF,KAAK,CAAC;YACJ,KAAK,EAAE,yBAAuB,CAAC,IAAI;YACnC,WAAW,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE;YACrD,QAAQ,EAAE;gBACR,CAAC,yBAAuB,CAAC,8BAA8B,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC;oBACrE,GAAG,EAAE,yBAAuB,CAAC,8BAA8B;iBAC5D,CAAC;qBACC,UAAU,CAAC,oBAAoB,CAAC;qBAChC,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC;aACrC;SACF,CAAC,CAAC;QAZyD,gBAAW,GAAX,WAAW,CAAiB;IAa1F,CAAC;IAED,sTAAsT;IAC7S,OAAO;QACd,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC;QAE5C,MAAM,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAoB;YACjD,GAAG,EAAE,yBAAuB,CAAC,8BAA8B;SAC5D,CAAC,CAAC;QAEH,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,2HAA2H,yBAAuB,CAAC,8BAA8B,EAAE;aAC7L,CAAC,CAAC;QACL,CAAC;QAED,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;;AArCU,uBAAuB;IAO/B,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAA;;GAP1C,uBAAuB,CAsCnC","sourcesContent":["import { type BaseApplication } from '@/base/applications';\nimport { BaseComponent } from '@venizia/ignis-kernel';\nimport { inject } from '@/base/metadata';\nimport { RequestSpyMiddleware } from '@/base/middlewares';\nimport { BindingNamespaces, CoreBindings } from '@venizia/ignis-kernel';\nimport { Binding, BindingScopes } from '@venizia/ignis-kernel';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { type MiddlewareHandler } from 'hono/types';\n\n/** Installs the request spy middleware on the application server, which tracks each request. */\nexport class RequestTrackerComponent extends BaseComponent {\n static readonly REQUEST_TRACKER_MW_BINDING_KEY = [\n BindingNamespaces.MIDDLEWARE,\n RequestSpyMiddleware.name,\n ].join('.');\n\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: RequestTrackerComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [RequestTrackerComponent.REQUEST_TRACKER_MW_BINDING_KEY]: Binding.bind({\n key: RequestTrackerComponent.REQUEST_TRACKER_MW_BINDING_KEY,\n })\n .toProvider(RequestSpyMiddleware)\n .setScope(BindingScopes.SINGLETON),\n },\n });\n }\n\n /** No `requestId()` here: the id is installed by `RestApplication.registerDefaultMiddlewares()`, which runs first and uses `RequestIdGenerator`. Same UUID v4 shape hono's own default produces, but hono calls `crypto.randomUUID` unguarded, and a browser leaves that one `undefined` outside a secure context. */\n override binding(): ValueOrPromise<void> {\n const server = this.application.getServer();\n\n const mw = this.application.get<MiddlewareHandler>({\n key: RequestTrackerComponent.REQUEST_TRACKER_MW_BINDING_KEY,\n });\n\n if (!mw) {\n throw getError({\n message: `[RequestTrackerComponent][binding] Invalid middleware to init request tracker | Please check again binding value | key: ${RequestTrackerComponent.REQUEST_TRACKER_MW_BINDING_KEY}`,\n });\n }\n\n server.use(mw);\n }\n}\n"]}
@@ -1,3 +1,4 @@
1
+ /** Container keys of the Socket.IO component: the server instance, its options, the Redis connection and the handlers an application binds. */
1
2
  export declare class SocketIOBindingKeys {
2
3
  static readonly SOCKET_IO_INSTANCE = "@app/socket-io/instance";
3
4
  static readonly SERVER_OPTIONS = "@app/socket-io/server-options";
@@ -1,3 +1,4 @@
1
+ /** Container keys of the Socket.IO component: the server instance, its options, the Redis connection and the handlers an application binds. */
1
2
  export class SocketIOBindingKeys {
2
3
  static { this.SOCKET_IO_INSTANCE = '@app/socket-io/instance'; }
3
4
  static { this.SERVER_OPTIONS = '@app/socket-io/server-options'; }
@@ -1 +1 @@
1
- {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/socket-io/common/keys.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,mBAAmB;aACd,uBAAkB,GAAG,yBAAyB,CAAC;aAE/C,mBAAc,GAAG,+BAA+B,CAAC;aACjD,qBAAgB,GAAG,iCAAiC,CAAC;aAErD,yBAAoB,GAAG,qCAAqC,CAAC;aAC7D,0BAAqB,GAAG,sCAAsC,CAAC;aAC/D,6BAAwB,GAAG,yCAAyC,CAAC","sourcesContent":["export class SocketIOBindingKeys {\n static readonly SOCKET_IO_INSTANCE = '@app/socket-io/instance';\n\n static readonly SERVER_OPTIONS = '@app/socket-io/server-options';\n static readonly REDIS_CONNECTION = '@app/socket-io/redis-connection';\n\n static readonly AUTHENTICATE_HANDLER = '@app/socket-io/authenticate-handler';\n static readonly VALIDATE_ROOM_HANDLER = '@app/socket-io/validate-room-handler';\n static readonly CLIENT_CONNECTED_HANDLER = '@app/socket-io/client-connected-handler';\n}\n"]}
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/socket-io/common/keys.ts"],"names":[],"mappings":"AAAA,+IAA+I;AAC/I,MAAM,OAAO,mBAAmB;aACd,uBAAkB,GAAG,yBAAyB,CAAC;aAE/C,mBAAc,GAAG,+BAA+B,CAAC;aACjD,qBAAgB,GAAG,iCAAiC,CAAC;aAErD,yBAAoB,GAAG,qCAAqC,CAAC;aAC7D,0BAAqB,GAAG,sCAAsC,CAAC;aAC/D,6BAAwB,GAAG,yCAAyC,CAAC","sourcesContent":["/** Container keys of the Socket.IO component: the server instance, its options, the Redis connection and the handlers an application binds. */\nexport class SocketIOBindingKeys {\n static readonly SOCKET_IO_INSTANCE = '@app/socket-io/instance';\n\n static readonly SERVER_OPTIONS = '@app/socket-io/server-options';\n static readonly REDIS_CONNECTION = '@app/socket-io/redis-connection';\n\n static readonly AUTHENTICATE_HANDLER = '@app/socket-io/authenticate-handler';\n static readonly VALIDATE_ROOM_HANDLER = '@app/socket-io/validate-room-handler';\n static readonly CLIENT_CONNECTED_HANDLER = '@app/socket-io/client-connected-handler';\n}\n"]}
@@ -2,6 +2,7 @@ import { type BaseApplication } from '../../base/applications/index.js';
2
2
  import { BaseComponent } from '@venizia/ignis-kernel';
3
3
  import { type ValueOrPromise } from '@venizia/ignis-helpers/common';
4
4
  import { type IServerOptions } from './common/index.js';
5
+ /** Starts a Socket.IO server on Bun after the application starts. Requires a Redis helper at `SocketIOBindingKeys.REDIS_CONNECTION` and an authenticate handler at `AUTHENTICATE_HANDLER`; binding throws without them. */
5
6
  export declare class SocketIOComponent extends BaseComponent {
6
7
  private application;
7
8
  protected serverOptions: Partial<IServerOptions>;
@@ -21,6 +21,7 @@ import { isRedisHelper } from '@venizia/ignis-helpers';
21
21
  import { SocketIOServerHelper, } from '@venizia/ignis-helpers/socket-io';
22
22
  import { SocketIOBindingKeys, DEFAULT_SERVER_OPTIONS, } from './common/index.js';
23
23
  import { SocketIOBunHandler } from './handlers/index.js';
24
+ /** Starts a Socket.IO server on Bun after the application starts. Requires a Redis helper at `SocketIOBindingKeys.REDIS_CONNECTION` and an authenticate handler at `AUTHENTICATE_HANDLER`; binding throws without them. */
24
25
  let SocketIOComponent = SocketIOComponent_1 = class SocketIOComponent extends BaseComponent {
25
26
  constructor(application) {
26
27
  super({
@@ -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;A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C,CAAC;gBAEH,MAAM,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;YACtD,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAEQ,OAAO;QACd,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAElD,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
+ {"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,2NAA2N;AAC3N,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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AC;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\n/** Starts a Socket.IO server on Bun after the application starts. Requires a Redis helper at `SocketIOBindingKeys.REDIS_CONNECTION` and an authenticate handler at `AUTHENTICATE_HANDLER`; binding throws without them. */\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"]}