@venizia/ignis 0.4.8-8 → 0.4.8

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 (225) hide show
  1. package/README.md +1 -0
  2. package/dist/esm/base/applications/base.js.map +1 -1
  3. package/dist/esm/components/api-reference/common/types.d.ts +6 -3
  4. package/dist/esm/components/api-reference/common/types.js.map +1 -1
  5. package/dist/esm/components/api-reference/component.js +8 -3
  6. package/dist/esm/components/api-reference/component.js.map +1 -1
  7. package/dist/esm/components/auth/authenticate/component.js +3 -2
  8. package/dist/esm/components/auth/authenticate/component.js.map +1 -1
  9. package/dist/esm/components/auth/authenticate/controllers/factory.d.ts +3 -3
  10. package/dist/esm/components/auth/authenticate/controllers/factory.js +1 -1
  11. package/dist/esm/components/auth/authenticate/controllers/factory.js.map +1 -1
  12. package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.d.ts +5 -3
  13. package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js +18 -1
  14. package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js.map +1 -1
  15. package/dist/esm/components/auth/authorize/adapters/common/types.d.ts +1 -2
  16. package/dist/esm/components/auth/authorize/adapters/common/types.js.map +1 -1
  17. package/dist/esm/components/index.d.ts +1 -0
  18. package/dist/esm/components/index.js +1 -0
  19. package/dist/esm/components/index.js.map +1 -1
  20. package/dist/esm/components/mail/common/constants.d.ts +24 -14
  21. package/dist/esm/components/mail/common/constants.js +19 -32
  22. package/dist/esm/components/mail/common/constants.js.map +1 -1
  23. package/dist/esm/components/mail/common/errors.d.ts +10 -1
  24. package/dist/esm/components/mail/common/errors.js +7 -1
  25. package/dist/esm/components/mail/common/errors.js.map +1 -1
  26. package/dist/esm/components/mail/common/types/message.d.ts +4 -4
  27. package/dist/esm/components/mail/common/types/message.js.map +1 -1
  28. package/dist/esm/components/mail/common/types/options.d.ts +54 -10
  29. package/dist/esm/components/mail/common/types/options.js.map +1 -1
  30. package/dist/esm/components/mail/common/types/queue.d.ts +23 -12
  31. package/dist/esm/components/mail/common/types/queue.js.map +1 -1
  32. package/dist/esm/components/mail/common/types/template.d.ts +5 -4
  33. package/dist/esm/components/mail/common/types/template.js.map +1 -1
  34. package/dist/esm/components/mail/common/types/verification.d.ts +1 -0
  35. package/dist/esm/components/mail/common/types/verification.js.map +1 -1
  36. package/dist/esm/components/mail/component.js +11 -2
  37. package/dist/esm/components/mail/component.js.map +1 -1
  38. package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.d.ts +1 -1
  39. package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.js +15 -28
  40. package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.js.map +1 -1
  41. package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.d.ts +2 -0
  42. package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.js +17 -10
  43. package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.js.map +1 -1
  44. package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.js +11 -6
  45. package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.js.map +1 -1
  46. package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.d.ts +2 -3
  47. package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.js +15 -6
  48. package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.js.map +1 -1
  49. package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.d.ts +2 -3
  50. package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.js +2 -2
  51. package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.js.map +1 -1
  52. package/dist/esm/components/mail/providers/mail-queue-executor.provider.d.ts +2 -2
  53. package/dist/esm/components/mail/providers/mail-queue-executor.provider.js +7 -9
  54. package/dist/esm/components/mail/providers/mail-queue-executor.provider.js.map +1 -1
  55. package/dist/esm/components/mail/providers/mail-transporter.provider.js +7 -7
  56. package/dist/esm/components/mail/providers/mail-transporter.provider.js.map +1 -1
  57. package/dist/esm/components/mail/services/generators/numeric-code.d.ts +1 -6
  58. package/dist/esm/components/mail/services/generators/numeric-code.js +3 -31
  59. package/dist/esm/components/mail/services/generators/numeric-code.js.map +1 -1
  60. package/dist/esm/components/mail/services/generators/random-token.d.ts +4 -1
  61. package/dist/esm/components/mail/services/generators/random-token.js +9 -6
  62. package/dist/esm/components/mail/services/generators/random-token.js.map +1 -1
  63. package/dist/esm/components/mail/services/mail.service.d.ts +1 -2
  64. package/dist/esm/components/mail/services/mail.service.js +21 -19
  65. package/dist/esm/components/mail/services/mail.service.js.map +1 -1
  66. package/dist/esm/components/mail/services/template.service.d.ts +7 -5
  67. package/dist/esm/components/mail/services/template.service.js +24 -16
  68. package/dist/esm/components/mail/services/template.service.js.map +1 -1
  69. package/dist/esm/components/mail/utilities/attachment.utility.js +8 -6
  70. package/dist/esm/components/mail/utilities/attachment.utility.js.map +1 -1
  71. package/dist/esm/components/mail/utilities/header.utility.d.ts +14 -0
  72. package/dist/esm/components/mail/utilities/header.utility.js +44 -0
  73. package/dist/esm/components/mail/utilities/header.utility.js.map +1 -0
  74. package/dist/esm/components/mail/utilities/index.d.ts +1 -0
  75. package/dist/esm/components/mail/utilities/index.js +1 -0
  76. package/dist/esm/components/mail/utilities/index.js.map +1 -1
  77. package/dist/esm/components/mail/utilities/mime.utility.d.ts +5 -1
  78. package/dist/esm/components/mail/utilities/mime.utility.js +12 -58
  79. package/dist/esm/components/mail/utilities/mime.utility.js.map +1 -1
  80. package/dist/esm/components/mail/utilities/type.utility.d.ts +2 -3
  81. package/dist/esm/components/mail/utilities/type.utility.js +6 -7
  82. package/dist/esm/components/mail/utilities/type.utility.js.map +1 -1
  83. package/dist/esm/components/server-info/common/constants.d.ts +6 -0
  84. package/dist/esm/components/server-info/common/constants.js +6 -0
  85. package/dist/esm/components/server-info/common/constants.js.map +1 -0
  86. package/dist/esm/components/server-info/common/index.d.ts +5 -0
  87. package/dist/esm/components/server-info/common/index.js +5 -0
  88. package/dist/esm/components/server-info/common/index.js.map +1 -0
  89. package/dist/esm/components/server-info/common/keys.d.ts +5 -0
  90. package/dist/esm/components/server-info/common/keys.js +5 -0
  91. package/dist/esm/components/server-info/common/keys.js.map +1 -0
  92. package/dist/esm/components/server-info/common/rest-paths.d.ts +5 -0
  93. package/dist/esm/components/server-info/common/rest-paths.js +5 -0
  94. package/dist/esm/components/server-info/common/rest-paths.js.map +1 -0
  95. package/dist/esm/components/server-info/common/types.d.ts +68 -0
  96. package/dist/esm/components/server-info/common/types.js +2 -0
  97. package/dist/esm/components/server-info/common/types.js.map +1 -0
  98. package/dist/esm/components/server-info/component.d.ts +31 -0
  99. package/dist/esm/components/server-info/component.js +87 -0
  100. package/dist/esm/components/server-info/component.js.map +1 -0
  101. package/dist/esm/components/server-info/controller.d.ts +14 -0
  102. package/dist/esm/components/server-info/controller.js +68 -0
  103. package/dist/esm/components/server-info/controller.js.map +1 -0
  104. package/dist/esm/components/server-info/index.d.ts +5 -0
  105. package/dist/esm/components/server-info/index.js +5 -0
  106. package/dist/esm/components/server-info/index.js.map +1 -0
  107. package/dist/esm/components/server-info/reporter.d.ts +25 -0
  108. package/dist/esm/components/server-info/reporter.js +68 -0
  109. package/dist/esm/components/server-info/reporter.js.map +1 -0
  110. package/dist/esm/components/socket-io/handlers/bun.handler.d.ts +13 -3
  111. package/dist/esm/components/socket-io/handlers/bun.handler.js.map +1 -1
  112. package/dist/esm/components/static-asset/common/constants.d.ts +51 -24
  113. package/dist/esm/components/static-asset/common/constants.js +75 -47
  114. package/dist/esm/components/static-asset/common/constants.js.map +1 -1
  115. package/dist/esm/components/static-asset/common/errors.d.ts +30 -35
  116. package/dist/esm/components/static-asset/common/errors.js +31 -33
  117. package/dist/esm/components/static-asset/common/errors.js.map +1 -1
  118. package/dist/esm/components/static-asset/common/index.d.ts +1 -1
  119. package/dist/esm/components/static-asset/common/index.js +1 -1
  120. package/dist/esm/components/static-asset/common/index.js.map +1 -1
  121. package/dist/esm/components/static-asset/common/keys.d.ts +10 -2
  122. package/dist/esm/components/static-asset/common/keys.js +10 -2
  123. package/dist/esm/components/static-asset/common/keys.js.map +1 -1
  124. package/dist/esm/components/static-asset/common/types.d.ts +267 -147
  125. package/dist/esm/components/static-asset/common/types.js.map +1 -1
  126. package/dist/esm/components/static-asset/common/validation.d.ts +10 -0
  127. package/dist/esm/components/static-asset/common/validation.js +8 -0
  128. package/dist/esm/components/static-asset/common/validation.js.map +1 -0
  129. package/dist/esm/components/static-asset/component.d.ts +4 -2
  130. package/dist/esm/components/static-asset/component.js +26 -31
  131. package/dist/esm/components/static-asset/component.js.map +1 -1
  132. package/dist/esm/components/static-asset/controller/factory.d.ts +37 -79
  133. package/dist/esm/components/static-asset/controller/factory.js +26 -917
  134. package/dist/esm/components/static-asset/controller/factory.js.map +1 -1
  135. package/dist/esm/components/static-asset/controller/index.d.ts +1 -0
  136. package/dist/esm/components/static-asset/controller/index.js +1 -0
  137. package/dist/esm/components/static-asset/controller/index.js.map +1 -1
  138. package/dist/esm/components/static-asset/controller/routes/context.d.ts +62 -0
  139. package/dist/esm/components/static-asset/controller/routes/context.js +45 -0
  140. package/dist/esm/components/static-asset/controller/routes/context.js.map +1 -0
  141. package/dist/esm/components/static-asset/controller/routes/definition.d.ts +40 -0
  142. package/dist/esm/components/static-asset/controller/routes/definition.js +83 -0
  143. package/dist/esm/components/static-asset/controller/routes/definition.js.map +1 -0
  144. package/dist/esm/components/static-asset/controller/routes/direct-upload.d.ts +3 -0
  145. package/dist/esm/components/static-asset/controller/routes/direct-upload.js +153 -0
  146. package/dist/esm/components/static-asset/controller/routes/direct-upload.js.map +1 -0
  147. package/dist/esm/components/static-asset/controller/routes/labels.d.ts +16 -0
  148. package/dist/esm/components/static-asset/controller/routes/labels.js +19 -0
  149. package/dist/esm/components/static-asset/controller/routes/labels.js.map +1 -0
  150. package/dist/esm/components/static-asset/controller/routes/objects.d.ts +7 -0
  151. package/dist/esm/components/static-asset/controller/routes/objects.js +193 -0
  152. package/dist/esm/components/static-asset/controller/routes/objects.js.map +1 -0
  153. package/dist/esm/components/static-asset/controller/routes/serve.d.ts +29 -0
  154. package/dist/esm/components/static-asset/controller/routes/serve.js +152 -0
  155. package/dist/esm/components/static-asset/controller/routes/serve.js.map +1 -0
  156. package/dist/esm/components/static-asset/controller/routes/table.d.ts +12 -0
  157. package/dist/esm/components/static-asset/controller/routes/table.js +52 -0
  158. package/dist/esm/components/static-asset/controller/routes/table.js.map +1 -0
  159. package/dist/esm/components/static-asset/controller/routes/upload.d.ts +10 -0
  160. package/dist/esm/components/static-asset/controller/routes/upload.js +175 -0
  161. package/dist/esm/components/static-asset/controller/routes/upload.js.map +1 -0
  162. package/dist/esm/components/static-asset/index.d.ts +2 -1
  163. package/dist/esm/components/static-asset/index.js +2 -1
  164. package/dist/esm/components/static-asset/index.js.map +1 -1
  165. package/dist/esm/components/static-asset/models/base.model.d.ts +4 -4
  166. package/dist/esm/components/static-asset/models/base.model.js.map +1 -1
  167. package/dist/esm/components/static-asset/services/commitment.service.d.ts +103 -0
  168. package/dist/esm/components/static-asset/services/commitment.service.js +252 -0
  169. package/dist/esm/components/static-asset/services/commitment.service.js.map +1 -0
  170. package/dist/esm/components/static-asset/services/index.d.ts +3 -0
  171. package/dist/esm/components/static-asset/services/index.js +3 -0
  172. package/dist/esm/components/static-asset/services/index.js.map +1 -0
  173. package/dist/esm/components/static-asset/services/policy.service.d.ts +45 -0
  174. package/dist/esm/components/static-asset/services/policy.service.js +104 -0
  175. package/dist/esm/components/static-asset/services/policy.service.js.map +1 -0
  176. package/dist/esm/components/static-asset/utilities/commit-token.utility.d.ts +28 -0
  177. package/dist/esm/components/static-asset/utilities/commit-token.utility.js +112 -0
  178. package/dist/esm/components/static-asset/utilities/commit-token.utility.js.map +1 -0
  179. package/dist/esm/components/static-asset/utilities/entry.utility.d.ts +69 -0
  180. package/dist/esm/components/static-asset/utilities/entry.utility.js +160 -0
  181. package/dist/esm/components/static-asset/utilities/entry.utility.js.map +1 -0
  182. package/dist/esm/components/static-asset/utilities/index.d.ts +6 -0
  183. package/dist/esm/components/static-asset/utilities/index.js +6 -0
  184. package/dist/esm/components/static-asset/utilities/index.js.map +1 -0
  185. package/dist/esm/components/static-asset/{ingest.d.ts → utilities/ingest.utility.d.ts} +5 -5
  186. package/dist/esm/components/static-asset/{ingest.js → utilities/ingest.utility.js} +12 -10
  187. package/dist/esm/components/static-asset/utilities/ingest.utility.js.map +1 -0
  188. package/dist/esm/components/static-asset/{controller/key-scope.d.ts → utilities/key-scope.utility.d.ts} +21 -2
  189. package/dist/esm/components/static-asset/utilities/key-scope.utility.js +74 -0
  190. package/dist/esm/components/static-asset/utilities/key-scope.utility.js.map +1 -0
  191. package/dist/esm/components/static-asset/{controller/meta-link.d.ts → utilities/meta-link.utility.d.ts} +9 -9
  192. package/dist/esm/components/static-asset/{controller/meta-link.js → utilities/meta-link.utility.js} +10 -10
  193. package/dist/esm/components/static-asset/utilities/meta-link.utility.js.map +1 -0
  194. package/dist/esm/components/static-asset/utilities/object-link.utility.d.ts +16 -0
  195. package/dist/esm/components/static-asset/utilities/object-link.utility.js +20 -0
  196. package/dist/esm/components/static-asset/utilities/object-link.utility.js.map +1 -0
  197. package/dist/esm/components/static-asset/utilities/pinned-file.utility.d.ts +39 -0
  198. package/dist/esm/components/static-asset/utilities/pinned-file.utility.js +53 -0
  199. package/dist/esm/components/static-asset/utilities/pinned-file.utility.js.map +1 -0
  200. package/dist/esm/components/static-asset/utilities/route-options.utility.d.ts +43 -0
  201. package/dist/esm/components/static-asset/utilities/route-options.utility.js +71 -0
  202. package/dist/esm/components/static-asset/utilities/route-options.utility.js.map +1 -0
  203. package/dist/esm/components/static-asset/utilities/toggle.utility.d.ts +5 -0
  204. package/dist/esm/components/static-asset/utilities/toggle.utility.js +5 -0
  205. package/dist/esm/components/static-asset/utilities/toggle.utility.js.map +1 -0
  206. package/dist/esm/testing/assert-application-boots.d.ts +2 -2
  207. package/dist/esm/testing/assert-application-boots.js +6 -2
  208. package/dist/esm/testing/assert-application-boots.js.map +1 -1
  209. package/dist/presets/app/preset.json +4 -4
  210. package/dist/presets/lib/preset.json +3 -3
  211. package/dist/presets/shared/preset.json +1 -1
  212. package/package.json +8 -8
  213. package/dist/esm/components/static-asset/common/commit-token.d.ts +0 -28
  214. package/dist/esm/components/static-asset/common/commit-token.js +0 -48
  215. package/dist/esm/components/static-asset/common/commit-token.js.map +0 -1
  216. package/dist/esm/components/static-asset/controller/base.definition.d.ts +0 -30
  217. package/dist/esm/components/static-asset/controller/base.definition.js +0 -307
  218. package/dist/esm/components/static-asset/controller/base.definition.js.map +0 -1
  219. package/dist/esm/components/static-asset/controller/key-scope.js +0 -41
  220. package/dist/esm/components/static-asset/controller/key-scope.js.map +0 -1
  221. package/dist/esm/components/static-asset/controller/meta-link.js.map +0 -1
  222. package/dist/esm/components/static-asset/controller/route-options.d.ts +0 -29
  223. package/dist/esm/components/static-asset/controller/route-options.js +0 -47
  224. package/dist/esm/components/static-asset/controller/route-options.js.map +0 -1
  225. package/dist/esm/components/static-asset/ingest.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"attachment.utility.js","sourceRoot":"","sources":["../../../../../src/components/mail/utilities/attachment.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAmB,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAwB,MAAM,WAAW,CAAC;AAE7D,MAAM,MAAM,GAA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AC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC;gBAC/C,GAAG,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;gBACrD,OAAO,EAAE,KAAK;aACf,CAAC,CAAC;QACL,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,OAAO,CAAC,IAAyC;QACtD,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,WAAW,IAAI,EAAE,EAAE,CAAC;YAChD,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC;YAE/B,IAAI,OAAO,YAAY,cAAc,EAAE,CAAC;gBACtC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;oBACpB,OAAO,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;wBAC/B,MAAM,CAAC,IAAI,CACT,4EAA4E,EAC5E,KAAK,CACN,CAAC;oBACJ,CAAC,CAAC,CAAC;gBACL,CAAC;gBAED,SAAS;YACX,CAAC;YAED,IACE,OAAO,OAAO,KAAK,QAAQ;gBAC3B,OAAO,KAAK,IAAI;gBAChB,SAAS,IAAI,OAAO;gBACpB,OAAO,OAAO,CAAC,OAAO,KAAK,UAAU,EACrC,CAAC;gBACD,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { constants } from 'node:fs';\nimport { open, realpath, type FileHandle } from 'node:fs/promises';\nimport { basename, isAbsolute, relative, resolve, sep } from 'node:path';\nimport { ContentTypeTable } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { LoggerFactory } from '@venizia/ignis-helpers';\nimport { MailErrors, type IMailAttachment } from '../common';\n\nconst logger = LoggerFactory.getLogger(['MailAttachments']);\n\n// O_NONBLOCK: opening a FIFO must not wait for a writer; the fstat check then refuses it.\n// Windows has neither flag; there the realpath containment check stands alone.\nconst OPEN_FLAGS = constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0);\n\n// One reason for missing, directory, unreadable and escaping paths: no existence oracle.\nconst PATH_OUTSIDE_REASON =\n 'attachment.path must name a readable file inside attachmentRoot | pass the bytes as content instead';\n\ntype TAttachmentStream = AsyncIterable<Uint8Array | string>;\n\nconst buildPathRefusedError = (opts: { reason: string; cause?: unknown }) => {\n return getError({\n error: MailErrors.ATTACHMENT_PATH_REFUSED,\n message: `Mail attachment path refused | ${opts.reason}`,\n cause: opts.cause,\n });\n};\n\nconst buildTooLargeError = (opts: { maxBytes: number }) => {\n return getError({\n error: MailErrors.ATTACHMENT_TOO_LARGE,\n message: `Mail attachments are over maxAttachmentBytes (${opts.maxBytes} bytes per message) | raise maxAttachmentBytes on the mail options, or send smaller attachments`,\n });\n};\n\nconst assertWithinLimit = (opts: { byteLength: number; usedBytes: number; maxBytes?: number }) => {\n const { byteLength, usedBytes, maxBytes } = opts;\n\n if (maxBytes === undefined || usedBytes + byteLength <= maxBytes) {\n return;\n }\n\n throw buildTooLargeError({ maxBytes });\n};\n\nconst isAttachmentStream = (value: unknown): value is TAttachmentStream => {\n return typeof value === 'object' && value !== null && Symbol.asyncIterator in value;\n};\n\nconst toBuffer = (chunk: Uint8Array | string): Buffer => {\n if (typeof chunk === 'string') {\n return Buffer.from(chunk);\n }\n\n return Buffer.isBuffer(chunk)\n ? chunk\n : Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength);\n};\n\n/** Throwing out of `for await` destroys a Node Readable and cancels a web ReadableStream. */\nconst drainStream = async (opts: {\n stream: TAttachmentStream;\n usedBytes: number;\n maxBytes?: number;\n}): Promise<Buffer> => {\n const { stream, usedBytes, maxBytes } = opts;\n const chunks: Buffer[] = [];\n let streamBytes = 0;\n\n for await (const chunk of stream) {\n const buffer = toBuffer(chunk);\n streamBytes += buffer.byteLength;\n\n // Per chunk: a stream has no length up front, and the rest must never be buffered.\n assertWithinLimit({ byteLength: streamBytes, usedBytes, maxBytes });\n chunks.push(buffer);\n }\n\n return Buffer.concat(chunks, streamBytes);\n};\n\n/**\n * Both sides go through realpath, so neither `..` nor a symlink can leave the root. Not closed: a\n * directory inside the root swapped for a symlink between this check and `open` - that takes write\n * access inside the root, so keep the root writable only by what the application trusts.\n */\nconst resolveConfinedPath = async (opts: {\n path: string;\n attachmentRoot: string;\n}): Promise<string> => {\n const { path, attachmentRoot } = opts;\n\n let rootPath: string;\n let filePath: string;\n\n // `resolve` throws synchronously on a non-string `path` from an untyped caller; it lands here too.\n try {\n const resolved = await Promise.all([\n realpath(attachmentRoot),\n realpath(resolve(attachmentRoot, path)),\n ]);\n [rootPath, filePath] = resolved;\n } catch (error) {\n throw buildPathRefusedError({ reason: PATH_OUTSIDE_REASON, cause: error });\n }\n\n const relation = relative(rootPath, filePath);\n const isOutside =\n relation === '' || relation === '..' || relation.startsWith(`..${sep}`) || isAbsolute(relation);\n\n if (isOutside) {\n throw buildPathRefusedError({ reason: PATH_OUTSIDE_REASON });\n }\n\n return filePath;\n};\n\nconst readConfinedFile = async (opts: {\n path: string;\n usedBytes: number;\n attachmentRoot?: string;\n maxBytes?: number;\n}): Promise<Buffer> => {\n const { path, usedBytes, attachmentRoot, maxBytes } = opts;\n\n if (!attachmentRoot) {\n throw buildPathRefusedError({\n reason:\n 'attachment.path is read only under attachmentRoot, which is not set | set attachmentRoot on the mail options, or pass the bytes as content',\n });\n }\n\n const filePath = await resolveConfinedPath({ path, attachmentRoot });\n let handle: FileHandle;\n\n try {\n const opened = await open(filePath, OPEN_FLAGS);\n handle = opened;\n } catch (error) {\n throw buildPathRefusedError({ reason: PATH_OUTSIDE_REASON, cause: error });\n }\n\n try {\n const stats = await handle.stat();\n\n if (!stats.isFile()) {\n throw buildPathRefusedError({ reason: PATH_OUTSIDE_REASON });\n }\n\n // Sized before reading, so a file known to be oversized is never opened for reading.\n assertWithinLimit({ byteLength: stats.size, usedBytes, maxBytes });\n\n // Counted while read, and read no further than one byte past the budget: the file may have\n // grown since fstat.\n const stream = handle.createReadStream({\n autoClose: false,\n end: maxBytes === undefined ? Infinity : maxBytes - usedBytes,\n });\n\n const result = await drainStream({ stream, usedBytes, maxBytes });\n\n return result;\n } finally {\n await handle.close();\n }\n};\n\nexport class MailAttachmentUtility {\n /**\n * Reads one attachment's bytes. A string `content` is raw text unless `encoding` says otherwise\n * (nodemailer's convention); `null` counts as absent. A `path` is read only inside\n * `attachmentRoot` and refused without one. `maxBytes` caps the whole message; `usedBytes` is what\n * earlier attachments already took.\n */\n static async readContent(opts: {\n attachment: IMailAttachment;\n attachmentRoot?: string;\n maxBytes?: number;\n usedBytes?: number;\n }): Promise<Buffer> {\n const { attachment, attachmentRoot, maxBytes, usedBytes = 0 } = opts;\n const { content } = attachment;\n\n if (content !== undefined && content !== null) {\n if (typeof content === 'string') {\n const encoding = attachment.encoding ?? 'utf-8';\n assertWithinLimit({\n byteLength: Buffer.byteLength(content, encoding),\n usedBytes,\n maxBytes,\n });\n\n return Buffer.from(content, encoding);\n }\n\n if (content instanceof Uint8Array) {\n assertWithinLimit({ byteLength: content.byteLength, usedBytes, maxBytes });\n\n return toBuffer(content);\n }\n\n if (!isAttachmentStream(content)) {\n throw getError({\n error: MailErrors.INVALID_CONFIGURATION,\n message:\n 'Invalid mail attachment | attachment.content must be a Buffer, a Uint8Array, a string or a stream',\n });\n }\n\n return drainStream({ stream: content, usedBytes, maxBytes });\n }\n\n if (attachment.path !== undefined && attachment.path !== null) {\n return readConfinedFile({ path: attachment.path, usedBytes, attachmentRoot, maxBytes });\n }\n\n return Buffer.alloc(0);\n }\n\n /**\n * Turns every attachment into `content` bytes and drops `path`, so no transport is ever handed a\n * file or URL to read on its own. `maxBytes` is shared by all attachments of the message. An\n * attachment read from `path` keeps the file's name and, when none is given, its content type.\n */\n static async resolve(opts: {\n attachments: IMailAttachment[];\n attachmentRoot?: string;\n maxBytes?: number;\n }): Promise<IMailAttachment[]> {\n const { attachments, attachmentRoot, maxBytes } = opts;\n const resolved: IMailAttachment[] = [];\n let usedBytes = 0;\n\n // Sequential on purpose: each read spends the budget the previous ones left.\n for (const attachment of attachments) {\n const { path, href, raw, content, encoding, ...rest } = attachment;\n\n // nodemailer reads both on its own - `href` fetches a URL, `raw` can carry a `path`.\n if ((href !== undefined && href !== null) || (raw !== undefined && raw !== null)) {\n throw buildPathRefusedError({\n reason:\n 'attachment.href and attachment.raw are not supported | pass the bytes as content',\n });\n }\n\n const bytes = await MailAttachmentUtility.readContent({\n attachment: { content, encoding, path },\n attachmentRoot,\n maxBytes,\n usedBytes,\n });\n\n usedBytes += bytes.byteLength;\n\n const isReadFromPath =\n (content === undefined || content === null) && typeof path === 'string';\n const filename = rest.filename ?? (isReadFromPath ? basename(path) : undefined);\n const contentType =\n rest.contentType ??\n (isReadFromPath && filename ? ContentTypeTable.resolve({ filename }) : undefined);\n\n resolved.push({\n ...rest,\n ...(filename === undefined ? {} : { filename }),\n ...(contentType === undefined ? {} : { contentType }),\n content: bytes,\n });\n }\n\n return resolved;\n }\n\n /**\n * Releases every attachment stream of a refused send, read or not, so none keeps a descriptor\n * open. A drained stream is already closed; releasing it again is harmless.\n */\n static release(opts: { attachments?: IMailAttachment[] }): void {\n for (const attachment of opts.attachments ?? []) {\n const { content } = attachment;\n\n if (content instanceof ReadableStream) {\n if (!content.locked) {\n content.cancel().catch((error) => {\n logger.warn(\n '[MailAttachmentUtility.release] Cancelling a web stream failed | error: %s',\n error,\n );\n });\n }\n\n continue;\n }\n\n if (\n typeof content === 'object' &&\n content !== null &&\n 'destroy' in content &&\n typeof content.destroy === 'function'\n ) {\n content.destroy();\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"attachment.utility.js","sourceRoot":"","sources":["../../../../../src/components/mail/utilities/attachment.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO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,OAAO,KAAK,UAAU,EACrC,CAAC;gBACD,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { constants } from 'node:fs';\nimport { open, realpath, type FileHandle } from 'node:fs/promises';\nimport { basename, isAbsolute, relative, resolve, sep } from 'node:path';\nimport { ContentTypeTable } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { LoggerFactory } from '@venizia/ignis-helpers';\nimport { MailErrors, type IMailAttachment } from '../common';\n\nconst logger = LoggerFactory.getLogger(['MailAttachments']);\n\n// O_NONBLOCK: opening a FIFO must not wait for a writer; the fstat check then refuses it.\n// Windows has neither flag; there the realpath containment check stands alone.\nconst OPEN_FLAGS = constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0);\n\n// One reason for missing, directory, unreadable and escaping paths: no existence oracle.\nconst PATH_OUTSIDE_REASON =\n 'attachment.path must name a readable file inside attachmentRoot | pass the bytes as content instead';\n\ntype TAttachmentStream = AsyncIterable<Uint8Array | string>;\n\nconst buildPathRefusedError = (opts: { reason: string; cause?: unknown }) => {\n return getError({\n error: MailErrors.ATTACHMENT_PATH_REFUSED,\n message: `Mail attachment path refused | ${opts.reason}`,\n cause: opts.cause,\n });\n};\n\nconst buildTooLargeError = (opts: { maxBytes: number }) => {\n return getError({\n error: MailErrors.ATTACHMENT_TOO_LARGE,\n message: `Mail attachments are over maxAttachmentBytes (${opts.maxBytes} bytes per message) | raise maxAttachmentBytes on the mail options, or send smaller attachments`,\n });\n};\n\nconst assertWithinLimit = (opts: { byteLength: number; usedBytes: number; maxBytes?: number }) => {\n const { byteLength, usedBytes, maxBytes } = opts;\n\n if (maxBytes === undefined || usedBytes + byteLength <= maxBytes) {\n return;\n }\n\n throw buildTooLargeError({ maxBytes });\n};\n\nconst isAttachmentStream = (value: unknown): value is TAttachmentStream => {\n return typeof value === 'object' && value !== null && Symbol.asyncIterator in value;\n};\n\nconst toBuffer = (chunk: Uint8Array | string): Buffer => {\n if (typeof chunk === 'string') {\n return Buffer.from(chunk);\n }\n\n return Buffer.isBuffer(chunk)\n ? chunk\n : Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength);\n};\n\n/** Throwing out of `for await` destroys a Node Readable and cancels a web ReadableStream. */\nconst drainStream = async (opts: {\n stream: TAttachmentStream;\n usedBytes: number;\n maxBytes?: number;\n}): Promise<Buffer> => {\n const { stream, usedBytes, maxBytes } = opts;\n const chunks: Buffer[] = [];\n let streamBytes = 0;\n\n for await (const chunk of stream) {\n const buffer = toBuffer(chunk);\n streamBytes += buffer.byteLength;\n\n // Per chunk: a stream has no length up front, and the rest must never be buffered.\n assertWithinLimit({ byteLength: streamBytes, usedBytes, maxBytes });\n chunks.push(buffer);\n }\n\n return Buffer.concat(chunks, streamBytes);\n};\n\n/**\n * Both sides go through realpath, so neither `..` nor a symlink can leave the root. Not closed: a\n * directory inside the root swapped for a symlink between this check and `open` - that takes write\n * access inside the root, so keep the root writable only by what the application trusts.\n */\nconst resolveConfinedPath = async (opts: {\n path: string;\n attachmentRoot: string;\n}): Promise<string> => {\n const { path, attachmentRoot } = opts;\n\n let rootPath: string;\n let filePath: string;\n\n // `resolve` throws synchronously on a non-string `path` from an untyped caller; it lands here too.\n try {\n const resolved = await Promise.all([\n realpath(attachmentRoot),\n realpath(resolve(attachmentRoot, path)),\n ]);\n [rootPath, filePath] = resolved;\n } catch (error) {\n throw buildPathRefusedError({ reason: PATH_OUTSIDE_REASON, cause: error });\n }\n\n const relation = relative(rootPath, filePath);\n const isOutside =\n relation === '' || relation === '..' || relation.startsWith(`..${sep}`) || isAbsolute(relation);\n\n if (isOutside) {\n throw buildPathRefusedError({ reason: PATH_OUTSIDE_REASON });\n }\n\n return filePath;\n};\n\nconst readConfinedFile = async (opts: {\n path: string;\n usedBytes: number;\n attachmentRoot?: string;\n maxBytes?: number;\n}): Promise<Buffer> => {\n const { path, usedBytes, attachmentRoot, maxBytes } = opts;\n\n if (!attachmentRoot) {\n throw buildPathRefusedError({\n reason:\n 'attachment.path is read only under attachmentRoot, which is not set | set attachmentRoot on the mail options, or pass the bytes as content',\n });\n }\n\n const filePath = await resolveConfinedPath({ path, attachmentRoot });\n let handle: FileHandle;\n\n try {\n const opened = await open(filePath, OPEN_FLAGS);\n handle = opened;\n } catch (error) {\n throw buildPathRefusedError({ reason: PATH_OUTSIDE_REASON, cause: error });\n }\n\n try {\n const stats = await handle.stat();\n\n if (!stats.isFile()) {\n throw buildPathRefusedError({ reason: PATH_OUTSIDE_REASON });\n }\n\n // Sized before reading, so a file known to be oversized is never opened for reading.\n assertWithinLimit({ byteLength: stats.size, usedBytes, maxBytes });\n\n // Counted while read, and read no further than one byte past the budget: the file may have\n // grown since fstat.\n const stream = handle.createReadStream({\n autoClose: false,\n end: maxBytes === undefined ? Infinity : maxBytes - usedBytes,\n });\n\n const result = await drainStream({ stream, usedBytes, maxBytes });\n\n return result;\n } finally {\n await handle.close();\n }\n};\n\nexport class MailAttachmentUtility {\n /**\n * Reads one attachment's bytes. A string `content` is raw text unless `encoding` says otherwise\n * (nodemailer's convention); `null` counts as absent. A `path` is read only inside\n * `attachmentRoot` and refused without one. `maxBytes` caps the whole message; `usedBytes` is what\n * earlier attachments already took.\n */\n static async readContent(opts: {\n attachment: IMailAttachment;\n attachmentRoot?: string;\n maxBytes?: number;\n usedBytes?: number;\n }): Promise<Buffer> {\n const { attachment, attachmentRoot, maxBytes, usedBytes = 0 } = opts;\n const { content } = attachment;\n\n if (content !== undefined && content !== null) {\n if (typeof content === 'string') {\n const encoding = attachment.encoding ?? 'utf-8';\n assertWithinLimit({\n byteLength: Buffer.byteLength(content, encoding),\n usedBytes,\n maxBytes,\n });\n\n return Buffer.from(content, encoding);\n }\n\n if (content instanceof Uint8Array) {\n assertWithinLimit({ byteLength: content.byteLength, usedBytes, maxBytes });\n\n return toBuffer(content);\n }\n\n if (!isAttachmentStream(content)) {\n throw getError({\n error: MailErrors.INVALID_CONFIGURATION,\n message:\n 'Invalid mail attachment | attachment.content must be a Buffer, a Uint8Array, a string or a stream',\n });\n }\n\n return drainStream({ stream: content, usedBytes, maxBytes });\n }\n\n if (attachment.path !== undefined && attachment.path !== null) {\n return readConfinedFile({ path: attachment.path, usedBytes, attachmentRoot, maxBytes });\n }\n\n return Buffer.alloc(0);\n }\n\n /**\n * Turns every attachment into `content` bytes and drops `path`, so no transport is ever handed a\n * file or URL to read on its own. `maxBytes` is shared by all attachments of the message. An\n * attachment read from `path` keeps the file's name and, when none is given, its content type.\n */\n static async resolve(opts: {\n attachments: IMailAttachment[];\n attachmentRoot?: string;\n maxBytes?: number;\n }): Promise<IMailAttachment[]> {\n const { attachments, attachmentRoot, maxBytes } = opts;\n const resolved: IMailAttachment[] = [];\n let usedBytes = 0;\n\n // Sequential on purpose: each read spends the budget the previous ones left.\n for (const attachment of attachments) {\n const { path, href, raw, content, encoding, ...rest } = attachment;\n\n // nodemailer reads both on its own - `href` fetches a URL, `raw` can carry a `path`.\n if ((href !== undefined && href !== null) || (raw !== undefined && raw !== null)) {\n throw buildPathRefusedError({\n reason:\n 'attachment.href and attachment.raw are not supported | pass the bytes as content',\n });\n }\n\n const bytes = await MailAttachmentUtility.readContent({\n attachment: { content, encoding, path },\n attachmentRoot,\n maxBytes,\n usedBytes,\n });\n\n usedBytes += bytes.byteLength;\n\n const isReadFromPath =\n (content === undefined || content === null) && typeof path === 'string';\n const filename = rest.filename ?? (isReadFromPath ? basename(path) : undefined);\n const contentType =\n rest.contentType ??\n (isReadFromPath && filename ? ContentTypeTable.resolve({ filename }) : undefined);\n\n const item: IMailAttachment = { ...rest, content: bytes };\n\n if (filename !== undefined) {\n item.filename = filename;\n }\n\n if (contentType !== undefined) {\n item.contentType = contentType;\n }\n\n resolved.push(item);\n }\n\n return resolved;\n }\n\n /**\n * Releases every attachment stream of a refused send, read or not, so none keeps a descriptor\n * open. A drained stream is already closed; releasing it again is harmless.\n */\n static release(opts: { attachments?: IMailAttachment[] }): void {\n for (const attachment of opts.attachments ?? []) {\n const { content } = attachment;\n\n if (content instanceof ReadableStream) {\n if (!content.locked) {\n content.cancel().catch((error) => {\n logger.warn(\n '[MailAttachmentUtility.release] Cancelling a web stream failed | error: %s',\n error,\n );\n });\n }\n\n continue;\n }\n\n if (\n typeof content === 'object' &&\n content !== null &&\n 'destroy' in content &&\n typeof content.destroy === 'function'\n ) {\n content.destroy();\n }\n }\n }\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import { type IMailMessage } from '../common/index.js';
2
+ /** The one place a message is checked for header injection, before any transport sees it. A transport called directly skips it. */
3
+ export declare class MailHeaderUtility {
4
+ /** `value` is `unknown`: the message types end in `[key: string]: unknown`, so nothing stops a controller forwarding a request body from putting an array where a string is declared. */
5
+ static assertValue(opts: {
6
+ field: string;
7
+ value: unknown;
8
+ }): void;
9
+ /** Every address field, the subject and the custom headers, names included. */
10
+ static assert(opts: {
11
+ message: IMailMessage;
12
+ }): void;
13
+ }
14
+ //# sourceMappingURL=header.utility.d.ts.map
@@ -0,0 +1,44 @@
1
+ import { getError } from '@venizia/ignis-helpers/core';
2
+ import { MailErrors } from '../common/index.js';
3
+ /** Printable ASCII without the colon: what RFC 5322 allows in a header field name. */
4
+ const HEADER_NAME_PATTERN = /^[\x21-\x39\x3b-\x7e]+$/;
5
+ /** A value spliced into a header line cannot hold a line break or NUL: it would break out of its line and forge headers or smuggle body content. */
6
+ const HEADER_VALUE_FORBIDDEN = /[\r\n\0]/;
7
+ /** The one place a message is checked for header injection, before any transport sees it. A transport called directly skips it. */
8
+ export class MailHeaderUtility {
9
+ /** `value` is `unknown`: the message types end in `[key: string]: unknown`, so nothing stops a controller forwarding a request body from putting an array where a string is declared. */
10
+ static assertValue(opts) {
11
+ const { field, value } = opts;
12
+ if (typeof value === 'string' && !HEADER_VALUE_FORBIDDEN.test(value)) {
13
+ return;
14
+ }
15
+ throw getError({
16
+ error: MailErrors.INVALID_HEADER,
17
+ message: `Invalid mail header | ${field} must be a string without line breaks or control characters`,
18
+ });
19
+ }
20
+ /** Every address field, the subject and the custom headers, names included. */
21
+ static assert(opts) {
22
+ const { from, to, cc, bcc, replyTo, subject, headers } = opts.message;
23
+ const addresses = { from, to, cc, bcc, replyTo };
24
+ for (const [field, value] of Object.entries(addresses)) {
25
+ if (value === undefined || value === null) {
26
+ continue;
27
+ }
28
+ for (const item of Array.isArray(value) ? value : [value]) {
29
+ MailHeaderUtility.assertValue({ field, value: item });
30
+ }
31
+ }
32
+ MailHeaderUtility.assertValue({ field: 'subject', value: subject });
33
+ for (const [name, value] of Object.entries(headers ?? {})) {
34
+ if (!HEADER_NAME_PATTERN.test(name)) {
35
+ throw getError({
36
+ error: MailErrors.INVALID_HEADER,
37
+ message: 'Invalid mail header | a header name must be printable ASCII without a colon',
38
+ });
39
+ }
40
+ MailHeaderUtility.assertValue({ field: `headers.${name}`, value });
41
+ }
42
+ }
43
+ }
44
+ //# sourceMappingURL=header.utility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"header.utility.js","sourceRoot":"","sources":["../../../../../src/components/mail/utilities/header.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAqB,MAAM,WAAW,CAAC;AAE1D,sFAAsF;AACtF,MAAM,mBAAmB,GAAG,yBAAyB,CAAC;AAEtD,oJAAoJ;AACpJ,MAAM,sBAAsB,GAAG,UAAU,CAAC;AAE1C,mIAAmI;AACnI,MAAM,OAAO,iBAAiB;IAC5B,yLAAyL;IACzL,MAAM,CAAC,WAAW,CAAC,IAAuC;QACxD,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAE9B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACrE,OAAO;QACT,CAAC;QAED,MAAM,QAAQ,CAAC;YACb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ED,iBAAiB,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,WAAW,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;CACF","sourcesContent":["import { getError } from '@venizia/ignis-helpers/core';\nimport { MailErrors, type IMailMessage } from '../common';\n\n/** Printable ASCII without the colon: what RFC 5322 allows in a header field name. */\nconst HEADER_NAME_PATTERN = /^[\\x21-\\x39\\x3b-\\x7e]+$/;\n\n/** A value spliced into a header line cannot hold a line break or NUL: it would break out of its line and forge headers or smuggle body content. */\nconst HEADER_VALUE_FORBIDDEN = /[\\r\\n\\0]/;\n\n/** The one place a message is checked for header injection, before any transport sees it. A transport called directly skips it. */\nexport class MailHeaderUtility {\n /** `value` is `unknown`: the message types end in `[key: string]: unknown`, so nothing stops a controller forwarding a request body from putting an array where a string is declared. */\n static assertValue(opts: { field: string; value: unknown }): void {\n const { field, value } = opts;\n\n if (typeof value === 'string' && !HEADER_VALUE_FORBIDDEN.test(value)) {\n return;\n }\n\n throw getError({\n error: MailErrors.INVALID_HEADER,\n message: `Invalid mail header | ${field} must be a string without line breaks or control characters`,\n });\n }\n\n /** Every address field, the subject and the custom headers, names included. */\n static assert(opts: { message: IMailMessage }): void {\n const { from, to, cc, bcc, replyTo, subject, headers } = opts.message;\n const addresses = { from, to, cc, bcc, replyTo };\n\n for (const [field, value] of Object.entries(addresses)) {\n if (value === undefined || value === null) {\n continue;\n }\n\n for (const item of Array.isArray(value) ? value : [value]) {\n MailHeaderUtility.assertValue({ field, value: item });\n }\n }\n\n MailHeaderUtility.assertValue({ field: 'subject', value: subject });\n\n for (const [name, value] of Object.entries(headers ?? {})) {\n if (!HEADER_NAME_PATTERN.test(name)) {\n throw getError({\n error: MailErrors.INVALID_HEADER,\n message: 'Invalid mail header | a header name must be printable ASCII without a colon',\n });\n }\n\n MailHeaderUtility.assertValue({ field: `headers.${name}`, value });\n }\n }\n}\n"]}
@@ -2,4 +2,5 @@ export * from './type.utility.js';
2
2
  export * from './address.utility.js';
3
3
  export * from './verification.utility.js';
4
4
  export * from './mime.utility.js';
5
+ export * from './header.utility.js';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -2,4 +2,5 @@ export * from './type.utility.js';
2
2
  export * from './address.utility.js';
3
3
  export * from './verification.utility.js';
4
4
  export * from './mime.utility.js';
5
+ export * from './header.utility.js';
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/mail/utilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC","sourcesContent":["export * from './type.utility';\nexport * from './address.utility';\nexport * from './verification.utility';\nexport * from './mime.utility';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/mail/utilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC","sourcesContent":["export * from './type.utility';\nexport * from './address.utility';\nexport * from './verification.utility';\nexport * from './mime.utility';\nexport * from './header.utility';\n"]}
@@ -1,6 +1,10 @@
1
- import { type IMailMessage } from '../common/index.js';
1
+ import type { IMailMessage } from '../common/index.js';
2
2
  /** Builds the MIME pieces the Amazon SES transport sends: the raw message and RFC 5322 address headers. */
3
3
  export declare class MailMimeUtility {
4
+ /** Escapes `\` and `"` so a value can sit inside a quoted string: a display name, a MIME parameter. */
5
+ static escapeQuotedString(opts: {
6
+ value: string;
7
+ }): string;
4
8
  /** Formats a `to`/`cc`/`from`/`replyTo` field as one RFC 5322 address list: splits a
5
9
  * comma-separated string or array into individual mailboxes, RFC 2047-encodes each display name,
6
10
  * and rejoins with `, ` - the same shape whether the caller passed a string or an array. */
@@ -1,8 +1,7 @@
1
- import { HTTP } from '@venizia/ignis-helpers/common';
2
- import { getError } from '@venizia/ignis-helpers/core';
3
- import { MailErrorCodes } from '../common/index.js';
1
+ import { TokenUidHelper, UidTokenEncodings } from '@venizia/ignis-helpers/core';
4
2
  import { MailAddressUtility } from './address.utility.js';
5
3
  import { MailAttachmentUtility } from './attachment.utility.js';
4
+ import { MailHeaderUtility } from './header.utility.js';
6
5
  const CRLF = '\r\n';
7
6
  const BASE64_LINE_LENGTH = 76;
8
7
  /** RFC 5322 recommends folding well under its own 998-byte hard limit; 78 matches common MTA
@@ -17,9 +16,9 @@ const MAX_HEADER_LINE_LENGTH = 78;
17
16
  const MAX_HEADER_HARD_LIMIT = 990;
18
17
  /** RFC 2047 caps one encoded-word (`=?charset?B?...?=` included) at 75 characters. */
19
18
  const ENCODED_WORD_MAX_LENGTH = 75;
20
- /** `bytes` random bytes as lowercase hex, from the platform CSPRNG. */
19
+ /** `bytes` random bytes as lowercase hex, from the platform CSPRNG. `bytes` is at least 16, the floor of `TokenUidHelper`. */
21
20
  function generateRandomHex(opts) {
22
- return Buffer.from(crypto.getRandomValues(new Uint8Array(opts.bytes))).toString('hex');
21
+ return new TokenUidHelper({ bytes: opts.bytes, encoding: UidTokenEncodings.HEX }).nextId();
23
22
  }
24
23
  function isAscii(value) {
25
24
  for (let index = 0; index < value.length; index++) {
@@ -147,43 +146,6 @@ function encodeTextBase64(text) {
147
146
  function encodeBufferBase64(buffer) {
148
147
  return foldBase64(buffer.toString('base64'));
149
148
  }
150
- /** 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.
151
- *
152
- * `value` is `unknown`, not `string`: `IMailMessage`/`IMailAttachment` both end in
153
- * `[key: string]: any`, so nothing at the type layer stops a caller (e.g. a controller
154
- * forwarding a request body) from putting a non-string - notably an array - where a string is
155
- * declared. `Array.prototype.includes('\r')` checks element *equality*, not substring, so
156
- * `['x\r\nBcc: evil'].includes('\r')` is `false` and a naive string-only check would wave a
157
- * forged header straight through once it is later stringified by a template literal. Requiring
158
- * `typeof value === 'string'` up front closes that gap for every field that flows through here. */
159
- function assertNoHeaderInjection(opts) {
160
- const { field, value } = opts;
161
- if (typeof value !== 'string') {
162
- throw getError({
163
- statusCode: HTTP.ResultCodes.RS_5.InternalServerError,
164
- messageCode: MailErrorCodes.INVALID_CONFIGURATION,
165
- message: `Invalid Amazon SES message | ${field} must be a string`,
166
- });
167
- }
168
- if (!value.includes('\r') && !value.includes('\n') && !value.includes('\0')) {
169
- return;
170
- }
171
- throw getError({
172
- statusCode: HTTP.ResultCodes.RS_5.InternalServerError,
173
- messageCode: MailErrorCodes.INVALID_CONFIGURATION,
174
- message: `Invalid Amazon SES message | ${field} contains illegal control characters`,
175
- });
176
- }
177
- /** Same guard as {@link assertNoHeaderInjection}, applied to every address in a `to`/`cc`/`bcc`
178
- * field individually - a string field only, not `[key: string]: any`; validating the raw
179
- * caller-provided value (before splitting/joining) both types and content-checks each entry. */
180
- function assertNoAddressListInjection(opts) {
181
- const { field, value } = opts;
182
- const list = Array.isArray(value) ? value : [value];
183
- for (const item of list) {
184
- assertNoHeaderInjection({ field, value: item });
185
- }
186
- }
187
149
  function extractDomain(address) {
188
150
  const match = address ? /@([^@>\s]+)>?\s*$/.exec(address) : null;
189
151
  return match ? match[1] : 'localhost';
@@ -191,27 +153,17 @@ function extractDomain(address) {
191
153
  function buildHeaders(message) {
192
154
  const headers = [];
193
155
  if (message.from) {
194
- assertNoAddressListInjection({ field: 'from', value: message.from });
195
156
  headers.push(foldHeaderLine(`From: ${formatAddressList(message.from)}`));
196
157
  }
197
158
  if (message.to) {
198
- assertNoAddressListInjection({ field: 'to', value: message.to });
199
159
  headers.push(foldHeaderLine(`To: ${formatAddressList(message.to)}`));
200
160
  }
201
161
  if (message.cc) {
202
- assertNoAddressListInjection({ field: 'cc', value: message.cc });
203
162
  headers.push(foldHeaderLine(`Cc: ${formatAddressList(message.cc)}`));
204
163
  }
205
164
  if (message.replyTo) {
206
- assertNoAddressListInjection({ field: 'replyTo', value: message.replyTo });
207
165
  headers.push(foldHeaderLine(`Reply-To: ${formatAddressList(message.replyTo)}`));
208
166
  }
209
- // Checked, never emitted: a `Bcc:` header would disclose the blind recipients, so they travel as
210
- // `Destination.BccAddresses`. Without this, `bcc` is the one address field that fails at AWS.
211
- if (message.bcc) {
212
- assertNoAddressListInjection({ field: 'bcc', value: message.bcc });
213
- }
214
- assertNoHeaderInjection({ field: 'subject', value: message.subject });
215
167
  headers.push(foldHeaderLine(`Subject: ${encodeHeaderValue(message.subject)}`));
216
168
  // RFC 5322 requires both on every message; SES's raw-message parser does not synthesize them,
217
169
  // so an omission here is an omission on the wire (some receiving MTAs reject a `Date`-less
@@ -222,8 +174,6 @@ function buildHeaders(message) {
222
174
  if (message.headers) {
223
175
  const messageHeadersEntries = Object.entries(message.headers);
224
176
  for (const [key, value] of messageHeadersEntries) {
225
- assertNoHeaderInjection({ field: `headers.${key}`, value: key });
226
- assertNoHeaderInjection({ field: `headers.${key}`, value });
227
177
  headers.push(foldHeaderLine(`${key}: ${encodeHeaderValue(value)}`));
228
178
  }
229
179
  }
@@ -265,12 +215,12 @@ async function attachmentPart(attachment, boundary) {
265
215
  // No root here: a `path` that did not go through `MailAttachmentUtility.resolve` is refused, never read.
266
216
  const content = await MailAttachmentUtility.readContent({ attachment });
267
217
  const contentType = attachment.contentType ?? 'application/octet-stream';
268
- assertNoHeaderInjection({ field: 'attachment.contentType', value: contentType });
218
+ MailHeaderUtility.assertValue({ field: 'attachment.contentType', value: contentType });
269
219
  if (attachment.filename) {
270
- assertNoHeaderInjection({ field: 'attachment.filename', value: attachment.filename });
220
+ MailHeaderUtility.assertValue({ field: 'attachment.filename', value: attachment.filename });
271
221
  }
272
222
  if (attachment.cid) {
273
- assertNoHeaderInjection({ field: 'attachment.cid', value: attachment.cid });
223
+ MailHeaderUtility.assertValue({ field: 'attachment.cid', value: attachment.cid });
274
224
  }
275
225
  const nameAttribute = attachment.filename
276
226
  ? attachmentNameParams('name', attachment.filename)
@@ -292,10 +242,14 @@ async function attachmentPart(attachment, boundary) {
292
242
  }
293
243
  /** 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. */
294
244
  function newBoundary(label) {
295
- return `----=_${label}_${generateRandomHex({ bytes: 12 })}`;
245
+ return `----=_${label}_${generateRandomHex({ bytes: 16 })}`;
296
246
  }
297
247
  /** Builds the MIME pieces the Amazon SES transport sends: the raw message and RFC 5322 address headers. */
298
248
  export class MailMimeUtility {
249
+ /** Escapes `\` and `"` so a value can sit inside a quoted string: a display name, a MIME parameter. */
250
+ static escapeQuotedString(opts) {
251
+ return escapeQuotedString(opts.value);
252
+ }
299
253
  /** Formats a `to`/`cc`/`from`/`replyTo` field as one RFC 5322 address list: splits a
300
254
  * comma-separated string or array into individual mailboxes, RFC 2047-encodes each display name,
301
255
  * and rejoins with `, ` - the same shape whether the caller passed a string or an array. */
@@ -1 +1 @@
1
- {"version":3,"file":"mime.utility.js","sourceRoot":"","sources":["../../../../../src/components/mail/utilities/mime.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,cAAc,EAA2C,MAAM,WAAW,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,MAAM,IAAI,GAAG,MAAM,CAAC;AACpB,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B;;2FAE2F;AAC3F,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC;;;;0FAI0F;AAC1F,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAClC,sFAAsF;AACtF,MAAM,uBAAuB,GAAG,EAA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,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
+ {"version":3,"file":"mime.utility.js","sourceRoot":"","sources":["../../../../../src/components/mail/utilities/mime.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhF,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,IAAI,GAAG,MAAM,CAAC;AACpB,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B;;2FAE2F;AAC3F,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC;;;;0FAI0F;AAC1F,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAClC,sFAAsF;AACtF,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAEnC,8HAA8H;AAC9H,SAAS,iBAAiB,CAAC,IAAuB;IAChD,OAAO,IAAI,cAAc,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,iBAAiB,CAAC,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;AAC7F,CAAC;AAED,SAAS,OAAO,CAAC,KAAa;IAC5B,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,K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AAI,CAAC,CAAC;YACrC,OAAO,CAAC,IAAI,CAAC,8CAA8C,eAAe,GAAG,CAAC,CAAC;YAE/E,OAAO,MAAM,CAAC,IAAI,CAAC,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 { TokenUidHelper, UidTokenEncodings } from '@venizia/ignis-helpers/core';\nimport type { IMailAttachment, IMailMessage } from '../common';\nimport { MailAddressUtility } from './address.utility';\nimport { MailAttachmentUtility } from './attachment.utility';\nimport { MailHeaderUtility } from './header.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. `bytes` is at least 16, the floor of `TokenUidHelper`. */\nfunction generateRandomHex(opts: { bytes: number }): string {\n return new TokenUidHelper({ bytes: opts.bytes, encoding: UidTokenEncodings.HEX }).nextId();\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\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 headers.push(foldHeaderLine(`From: ${formatAddressList(message.from)}`));\n }\n\n if (message.to) {\n headers.push(foldHeaderLine(`To: ${formatAddressList(message.to)}`));\n }\n\n if (message.cc) {\n headers.push(foldHeaderLine(`Cc: ${formatAddressList(message.cc)}`));\n }\n\n if (message.replyTo) {\n headers.push(foldHeaderLine(`Reply-To: ${formatAddressList(message.replyTo)}`));\n }\n\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 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 MailHeaderUtility.assertValue({ field: 'attachment.contentType', value: contentType });\n\n if (attachment.filename) {\n MailHeaderUtility.assertValue({ field: 'attachment.filename', value: attachment.filename });\n }\n\n if (attachment.cid) {\n MailHeaderUtility.assertValue({ 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: 16 })}`;\n}\n\n/** Builds the MIME pieces the Amazon SES transport sends: the raw message and RFC 5322 address headers. */\nexport class MailMimeUtility {\n /** Escapes `\\` and `\"` so a value can sit inside a quoted string: a display name, a MIME parameter. */\n static escapeQuotedString(opts: { value: string }): string {\n return escapeQuotedString(opts.value);\n }\n\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,4 +1,3 @@
1
- import type { AnyType } from '@venizia/ignis-helpers/common';
2
1
  import type { IMailTransport, TMailOptions } from '../common/index.js';
3
2
  /**
4
3
  * Type guards for the mail component. Each takes its value as a positional parameter, not an options
@@ -7,8 +6,8 @@ import type { IMailTransport, TMailOptions } from '../common/index.js';
7
6
  */
8
7
  export declare class MailTypeUtility {
9
8
  /** Whether `value` is a transport: `send` and `verify` are functions, and `close` is a function or absent. */
10
- static isTransport(value: AnyType): value is IMailTransport;
9
+ static isTransport(value: unknown): value is IMailTransport;
11
10
  /** Whether `options` has a string `provider` and a truthy `config`; the shape of `config` is not checked. */
12
- static isValidOptions(options: AnyType): options is TMailOptions;
11
+ static isValidOptions(options: unknown): options is TMailOptions;
13
12
  }
14
13
  //# sourceMappingURL=type.utility.d.ts.map
@@ -9,14 +9,14 @@ export class MailTypeUtility {
9
9
  if (!value || typeof value !== 'object') {
10
10
  return false;
11
11
  }
12
- const transport = value;
13
- if (typeof transport.send !== 'function') {
12
+ if (typeof Reflect.get(value, 'send') !== 'function') {
14
13
  return false;
15
14
  }
16
- if (typeof transport.verify !== 'function') {
15
+ if (typeof Reflect.get(value, 'verify') !== 'function') {
17
16
  return false;
18
17
  }
19
- if (transport.close !== undefined && typeof transport.close !== 'function') {
18
+ const close = Reflect.get(value, 'close');
19
+ if (close !== undefined && typeof close !== 'function') {
20
20
  return false;
21
21
  }
22
22
  return true;
@@ -26,11 +26,10 @@ export class MailTypeUtility {
26
26
  if (!options || typeof options !== 'object') {
27
27
  return false;
28
28
  }
29
- const opts = options;
30
- if (typeof opts.provider !== 'string') {
29
+ if (typeof Reflect.get(options, 'provider') !== 'string') {
31
30
  return false;
32
31
  }
33
- if (!opts.config) {
32
+ if (!Reflect.get(options, 'config')) {
34
33
  return false;
35
34
  }
36
35
  return true;
@@ -1 +1 @@
1
- {"version":3,"file":"type.utility.js","sourceRoot":"","sources":["../../../../../src/components/mail/utilities/type.utility.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,OAAO,eAAe;IAC1B,8GAA8G;IAC9G,MAAM,CAAC,WAAW,CAAC,KAAc;QAC/B,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACxC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,SAAS,GAAG,KAAgC,CAAC;QAEnD,IAAI,OAAO,SAAS,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YACzC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,OAAO,SAAS,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;YAC3C,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,SAAS,CAAC,KAAK,KAAK,SAAS,IAAI,OAAO,SAAS,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;YAC3E,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,6GAA6G;IAC7G,MAAM,CAAC,cAAc,CAAC,OAAgB;QACpC,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAC5C,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,IAAI,GAAG,OAAkC,CAAC;QAEhD,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACtC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import type { AnyType } from '@venizia/ignis-helpers/common';\nimport type { IMailTransport, TMailOptions } from '../common';\n\n/**\n * Type guards for the mail component. Each takes its value as a positional parameter, not an options\n * object (V-C-02): a type predicate narrows its own parameter, so `{ value }` could not narrow the\n * caller's variable.\n */\nexport class MailTypeUtility {\n /** Whether `value` is a transport: `send` and `verify` are functions, and `close` is a function or absent. */\n static isTransport(value: AnyType): value is IMailTransport {\n if (!value || typeof value !== 'object') {\n return false;\n }\n\n const transport = value as Record<string, unknown>;\n\n if (typeof transport.send !== 'function') {\n return false;\n }\n\n if (typeof transport.verify !== 'function') {\n return false;\n }\n\n if (transport.close !== undefined && typeof transport.close !== 'function') {\n return false;\n }\n\n return true;\n }\n\n /** Whether `options` has a string `provider` and a truthy `config`; the shape of `config` is not checked. */\n static isValidOptions(options: AnyType): options is TMailOptions {\n if (!options || typeof options !== 'object') {\n return false;\n }\n\n const opts = options as Record<string, unknown>;\n\n if (typeof opts.provider !== 'string') {\n return false;\n }\n\n if (!opts.config) {\n return false;\n }\n\n return true;\n }\n}\n"]}
1
+ {"version":3,"file":"type.utility.js","sourceRoot":"","sources":["../../../../../src/components/mail/utilities/type.utility.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,eAAe;IAC1B,8GAA8G;IAC9G,MAAM,CAAC,WAAW,CAAC,KAAc;QAC/B,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACxC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC;YACrD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,UAAU,EAAE,CAAC;YACvD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,KAAK,GAAY,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAEnD,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;YACvD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,6GAA6G;IAC7G,MAAM,CAAC,cAAc,CAAC,OAAgB;QACpC,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAC5C,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC,KAAK,QAAQ,EAAE,CAAC;YACzD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC;YACpC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import type { IMailTransport, TMailOptions } from '../common';\n\n/**\n * Type guards for the mail component. Each takes its value as a positional parameter, not an options\n * object (V-C-02): a type predicate narrows its own parameter, so `{ value }` could not narrow the\n * caller's variable.\n */\nexport class MailTypeUtility {\n /** Whether `value` is a transport: `send` and `verify` are functions, and `close` is a function or absent. */\n static isTransport(value: unknown): value is IMailTransport {\n if (!value || typeof value !== 'object') {\n return false;\n }\n\n if (typeof Reflect.get(value, 'send') !== 'function') {\n return false;\n }\n\n if (typeof Reflect.get(value, 'verify') !== 'function') {\n return false;\n }\n\n const close: unknown = Reflect.get(value, 'close');\n\n if (close !== undefined && typeof close !== 'function') {\n return false;\n }\n\n return true;\n }\n\n /** Whether `options` has a string `provider` and a truthy `config`; the shape of `config` is not checked. */\n static isValidOptions(options: unknown): options is TMailOptions {\n if (!options || typeof options !== 'object') {\n return false;\n }\n\n if (typeof Reflect.get(options, 'provider') !== 'string') {\n return false;\n }\n\n if (!Reflect.get(options, 'config')) {\n return false;\n }\n\n return true;\n }\n}\n"]}
@@ -0,0 +1,6 @@
1
+ /** `Cache-Control` values the server info controller sends. */
2
+ export declare class ServerInfoCacheControls {
3
+ /** A cached server time is a wrong server time: no cache and no service worker may store the answer. */
4
+ static readonly NO_STORE = "no-store";
5
+ }
6
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1,6 @@
1
+ /** `Cache-Control` values the server info controller sends. */
2
+ export class ServerInfoCacheControls {
3
+ /** A cached server time is a wrong server time: no cache and no service worker may store the answer. */
4
+ static { this.NO_STORE = 'no-store'; }
5
+ }
6
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/components/server-info/common/constants.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,MAAM,OAAO,uBAAuB;IAClC,wGAAwG;aACxF,aAAQ,GAAG,UAAU,CAAC","sourcesContent":["/** `Cache-Control` values the server info controller sends. */\nexport class ServerInfoCacheControls {\n /** A cached server time is a wrong server time: no cache and no service worker may store the answer. */\n static readonly NO_STORE = 'no-store';\n}\n"]}
@@ -0,0 +1,5 @@
1
+ export * from './constants.js';
2
+ export * from './keys.js';
3
+ export * from './rest-paths.js';
4
+ export * from './types.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,5 @@
1
+ export * from './constants.js';
2
+ export * from './keys.js';
3
+ export * from './rest-paths.js';
4
+ export * from './types.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/server-info/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC","sourcesContent":["export * from './constants';\nexport * from './keys';\nexport * from './rest-paths';\nexport * from './types';\n"]}
@@ -0,0 +1,5 @@
1
+ /** Container keys of the server info component. */
2
+ export declare class ServerInfoBindingKeys {
3
+ static readonly SERVER_INFO_OPTIONS = "@app/server-info/options";
4
+ }
5
+ //# sourceMappingURL=keys.d.ts.map