@venizia/ignis 0.4.8-1 → 0.4.8-10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/README.md +7 -14
  2. package/dist/esm/base/applications/server.d.ts +12 -0
  3. package/dist/esm/base/applications/server.js +11 -0
  4. package/dist/esm/base/applications/server.js.map +1 -1
  5. package/dist/esm/base/middlewares/request-spy/request-spy.middleware.d.ts +1 -0
  6. package/dist/esm/base/middlewares/request-spy/request-spy.middleware.js +9 -2
  7. package/dist/esm/base/middlewares/request-spy/request-spy.middleware.js.map +1 -1
  8. package/dist/esm/components/auth/authenticate/component.js +37 -1
  9. package/dist/esm/components/auth/authenticate/component.js.map +1 -1
  10. package/dist/esm/components/auth/authenticate/controllers/factory.d.ts +1 -0
  11. package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.d.ts +56 -5
  12. package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js +115 -11
  13. package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js.map +1 -1
  14. package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.js +2 -2
  15. package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.js.map +1 -1
  16. package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.js +10 -3
  17. package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.js.map +1 -1
  18. package/dist/esm/components/auth/authenticate/services/bearer/jws.service.d.ts +11 -0
  19. package/dist/esm/components/auth/authenticate/services/bearer/jws.service.js +25 -3
  20. package/dist/esm/components/auth/authenticate/services/bearer/jws.service.js.map +1 -1
  21. package/dist/esm/components/auth/authenticate/services/index.d.ts +1 -0
  22. package/dist/esm/components/auth/authenticate/services/index.js +1 -0
  23. package/dist/esm/components/auth/authenticate/services/index.js.map +1 -1
  24. package/dist/esm/components/auth/authenticate/services/jwks-url-policy.d.ts +42 -0
  25. package/dist/esm/components/auth/authenticate/services/jwks-url-policy.js +162 -0
  26. package/dist/esm/components/auth/authenticate/services/jwks-url-policy.js.map +1 -0
  27. package/dist/esm/components/auth/authenticate/services/service/verifier.service.js +7 -1
  28. package/dist/esm/components/auth/authenticate/services/service/verifier.service.js.map +1 -1
  29. package/dist/esm/components/auth/authenticate/strategies/service.strategy.js +2 -4
  30. package/dist/esm/components/auth/authenticate/strategies/service.strategy.js.map +1 -1
  31. package/dist/esm/components/auth/authorize/adapters/base-filtered.d.ts +1 -1
  32. package/dist/esm/components/auth/authorize/adapters/base-filtered.js +3 -2
  33. package/dist/esm/components/auth/authorize/adapters/base-filtered.js.map +1 -1
  34. package/dist/esm/components/auth/authorize/adapters/common/types.d.ts +2 -0
  35. package/dist/esm/components/auth/authorize/adapters/common/types.js.map +1 -1
  36. package/dist/esm/components/auth/authorize/adapters/connector.d.ts +2 -2
  37. package/dist/esm/components/auth/authorize/adapters/connector.js +3 -2
  38. package/dist/esm/components/auth/authorize/adapters/connector.js.map +1 -1
  39. package/dist/esm/components/auth/authorize/adapters/custom-grant-expander.js +1 -1
  40. package/dist/esm/components/auth/authorize/adapters/custom-grant-expander.js.map +1 -1
  41. package/dist/esm/components/health-check/reporter.js +2 -2
  42. package/dist/esm/components/health-check/reporter.js.map +1 -1
  43. package/dist/esm/components/index.d.ts +1 -0
  44. package/dist/esm/components/index.js +1 -0
  45. package/dist/esm/components/index.js.map +1 -1
  46. package/dist/esm/components/mail/common/types/verification.d.ts +1 -0
  47. package/dist/esm/components/mail/common/types/verification.js.map +1 -1
  48. package/dist/esm/components/mail/services/generators/numeric-code.d.ts +1 -6
  49. package/dist/esm/components/mail/services/generators/numeric-code.js +3 -31
  50. package/dist/esm/components/mail/services/generators/numeric-code.js.map +1 -1
  51. package/dist/esm/components/mail/services/generators/random-token.d.ts +4 -1
  52. package/dist/esm/components/mail/services/generators/random-token.js +9 -6
  53. package/dist/esm/components/mail/services/generators/random-token.js.map +1 -1
  54. package/dist/esm/components/mail/utilities/mime.utility.js +4 -4
  55. package/dist/esm/components/mail/utilities/mime.utility.js.map +1 -1
  56. package/dist/esm/components/server-info/common/constants.d.ts +6 -0
  57. package/dist/esm/components/server-info/common/constants.js +6 -0
  58. package/dist/esm/components/server-info/common/constants.js.map +1 -0
  59. package/dist/esm/components/server-info/common/index.d.ts +5 -0
  60. package/dist/esm/components/server-info/common/index.js +5 -0
  61. package/dist/esm/components/server-info/common/index.js.map +1 -0
  62. package/dist/esm/components/server-info/common/keys.d.ts +5 -0
  63. package/dist/esm/components/server-info/common/keys.js +5 -0
  64. package/dist/esm/components/server-info/common/keys.js.map +1 -0
  65. package/dist/esm/components/server-info/common/rest-paths.d.ts +5 -0
  66. package/dist/esm/components/server-info/common/rest-paths.js +5 -0
  67. package/dist/esm/components/server-info/common/rest-paths.js.map +1 -0
  68. package/dist/esm/components/server-info/common/types.d.ts +68 -0
  69. package/dist/esm/components/server-info/common/types.js +2 -0
  70. package/dist/esm/components/server-info/common/types.js.map +1 -0
  71. package/dist/esm/components/server-info/component.d.ts +31 -0
  72. package/dist/esm/components/server-info/component.js +87 -0
  73. package/dist/esm/components/server-info/component.js.map +1 -0
  74. package/dist/esm/components/server-info/controller.d.ts +14 -0
  75. package/dist/esm/components/server-info/controller.js +68 -0
  76. package/dist/esm/components/server-info/controller.js.map +1 -0
  77. package/dist/esm/components/server-info/index.d.ts +5 -0
  78. package/dist/esm/components/server-info/index.js +5 -0
  79. package/dist/esm/components/server-info/index.js.map +1 -0
  80. package/dist/esm/components/server-info/reporter.d.ts +25 -0
  81. package/dist/esm/components/server-info/reporter.js +68 -0
  82. package/dist/esm/components/server-info/reporter.js.map +1 -0
  83. package/dist/esm/components/static-asset/common/constants.d.ts +2 -0
  84. package/dist/esm/components/static-asset/common/constants.js +2 -0
  85. package/dist/esm/components/static-asset/common/constants.js.map +1 -1
  86. package/dist/esm/components/static-asset/common/types.d.ts +6 -0
  87. package/dist/esm/components/static-asset/common/types.js.map +1 -1
  88. package/dist/esm/components/static-asset/controller/base.definition.d.ts +2 -0
  89. package/dist/esm/components/static-asset/controller/base.definition.js +6 -4
  90. package/dist/esm/components/static-asset/controller/base.definition.js.map +1 -1
  91. package/dist/esm/components/static-asset/controller/factory.d.ts +1 -0
  92. package/dist/esm/components/static-asset/controller/factory.js +17 -9
  93. package/dist/esm/components/static-asset/controller/factory.js.map +1 -1
  94. package/dist/esm/components/static-asset/controller/meta-link.js +1 -1
  95. package/dist/esm/components/static-asset/controller/meta-link.js.map +1 -1
  96. package/dist/esm/components/static-asset/controller/route-options.d.ts +9 -0
  97. package/dist/esm/components/static-asset/controller/route-options.js +16 -3
  98. package/dist/esm/components/static-asset/controller/route-options.js.map +1 -1
  99. package/dist/esm/components/static-asset/ingest.d.ts +2 -2
  100. package/dist/esm/components/static-asset/ingest.js +2 -2
  101. package/dist/esm/components/static-asset/ingest.js.map +1 -1
  102. package/dist/esm/testing/assert-application-boots.d.ts +9 -0
  103. package/dist/esm/testing/assert-application-boots.js +11 -1
  104. package/dist/esm/testing/assert-application-boots.js.map +1 -1
  105. package/dist/presets/app/preset.json +4 -4
  106. package/dist/presets/lib/preset.json +3 -3
  107. package/dist/presets/shared/preset.json +1 -1
  108. package/package.json +8 -8
@@ -1 +1 @@
1
- {"version":3,"file":"reporter.js","sourceRoot":"","sources":["../../../../src/components/health-check/reporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAyB,MAAM,6BAA6B,CAAC;AAIvF;;;;;;;GAOG;AACH,MAAM,OAAO,mBAAmB;aACN,iBAAY,GAAG,IAAI,GAAG,IAAI,CAAC;IAEnD,iGAAiG;IACjG,MAAM,CAAC,YAAY;QACjB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;IAC/D,CAAC;IAED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,cAAc,CAAC,IAIrB;QACC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AAG,EAAE,mBAAmB,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC;gBAC3D,QAAQ,EAAE,mBAAmB,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACrE,SAAS,EAAE,mBAAmB,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC;aACxE;SACF,CAAC;IACJ,CAAC","sourcesContent":["import { Environment } from '@venizia/ignis-helpers';\nimport { BuildInfoRegistry, type TBuildInfoRecord } from '@venizia/ignis-helpers/core';\nimport type { IApplicationInfo } from '@venizia/ignis-kernel';\nimport type { IHealthCheckOptions } from './common';\n\n/**\n * Assembles what `GET /health` and `GET /health/stats` answer.\n *\n * Never reads the filesystem and never spawns `git`: the build stamp is PUSHED in at the\n * entrypoint through {@link BuildInfoRegistry} (or the component's own options), so a\n * `bun build --compile` binary and a Distroless image - neither of which has `node_modules`,\n * `.git` or a readable `package.json` - report exactly what a dev machine does.\n */\nexport class HealthCheckReporter {\n private static readonly BYTES_PER_MB = 1024 * 1024;\n\n /** Public liveness answer: liveness and the server clock, nothing a probe cannot already see. */\n static buildSummary(): { status: string; timestamp: string } {\n return { status: 'ok', timestamp: new Date().toISOString() };\n }\n\n /**\n * Fail-closed, copying `AppErrorMiddleware.isProduction`: the default is MEMBERSHIP in\n * `DEVELOPMENT_ENVS`, never inequality against `production`. `staging`, `uat`, `alpha` and a\n * typo all keep this route shut, because the runtime and release it names are what picks an\n * exploit. `ambient`, not `current`: an unset `NODE_ENV` is a host that cannot prove it is a dev\n * machine, and `current` would mask it as `development`.\n *\n * `enable` is compared to `true`/`false` rather than read through `??`: this binding is\n * env/config driven, and a JSON-derived `\"false\"` is truthy - an operator who wrote false would\n * otherwise get the route mounted.\n */\n static isStatsEnabled(opts: {\n options: IHealthCheckOptions;\n /** Reads the ambient environment; injected by tests so nothing has to write `process.env`. */\n environment?: () => string | undefined;\n }): boolean {\n const { enable } = opts.options.stats ?? {};\n\n if (typeof enable === 'boolean') {\n return enable;\n }\n\n const ambient = opts.environment ? opts.environment() : Environment.ambient;\n\n if (ambient === undefined) {\n return false;\n }\n\n return Environment.DEVELOPMENT_ENVS.has(ambient.toLowerCase());\n }\n\n /**\n * No `secretKey` configured leaves the route open to whatever can reach the port - stated, not\n * implied. Anything that is not a non-blank string fails CLOSED: a blank or config-derived\n * non-string key is a pipeline that lost the variable, and reading it as \"no key\" would publish\n * the route the operator meant to lock.\n *\n * The comparison is a plain `===`: a remote timing attack on a header compare is not practical\n * through an HTTP stack, and a constant-time digest compare would buy nothing here.\n */\n /**\n * Whether the stats route is mounted, unauthenticated, and on a host that cannot be shown to be a\n * development one. That combination stays LEGAL - on a cluster-internal port it is often the right\n * call - so this reports rather than refuses, and the component turns it into one warning at boot.\n *\n * It exists because `enable: true` bypasses the environment gate entirely: an operator who sets it\n * for a local run and ships the same code publishes the runtime version, the release and the\n * memory profile to whatever can reach the port. A blank `secretKey` is NOT unguarded - that fails\n * closed in {@link isStatsAuthorized}.\n */\n static isStatsUnguarded(opts: {\n options: IHealthCheckOptions;\n environment?: () => string | undefined;\n }): boolean {\n if (!HealthCheckReporter.isStatsEnabled(opts)) {\n return false;\n }\n\n if (opts.options.stats?.secretKey !== undefined) {\n return false;\n }\n\n const ambient = opts.environment ? opts.environment() : Environment.ambient;\n\n if (ambient === undefined) {\n return true;\n }\n\n return !Environment.DEVELOPMENT_ENVS.has(ambient.toLowerCase());\n }\n\n static isStatsAuthorized(opts: { options: IHealthCheckOptions; header?: string }): boolean {\n const secretKey = opts.options.stats?.secretKey;\n\n if (secretKey === undefined) {\n return true;\n }\n\n if (typeof secretKey !== 'string' || secretKey.trim().length === 0) {\n return false;\n }\n\n return opts.header === secretKey;\n }\n\n /** The slot is a process-wide `globalThis` entry any dependency can write, and `IBuildInfo` types it without checking - so a non-string never reaches the response schema, which declares `z.string()`. */\n private static extractText(opts: { value: unknown }): string | undefined {\n return typeof opts.value === 'string' && opts.value.length > 0 ? opts.value : undefined;\n }\n\n /**\n * Explicit options win over the registry, and the application's own `getAppInfo()` fills what\n * neither carries - so a host that ran no generator still reports its real name and version.\n */\n static resolveBuildInfo(opts: {\n options: IHealthCheckOptions;\n appInfo?: IApplicationInfo;\n }): TBuildInfoRecord {\n const stamp = opts.options.stats?.buildInfo ?? BuildInfoRegistry.get() ?? {};\n const extract = HealthCheckReporter.extractText;\n\n return {\n service:\n extract({ value: stamp.service }) ?? opts.appInfo?.name ?? BuildInfoRegistry.UNSPECIFIED,\n version:\n extract({ value: stamp.version }) ?? opts.appInfo?.version ?? BuildInfoRegistry.UNSPECIFIED,\n commit: extract({ value: stamp.commit }) ?? BuildInfoRegistry.UNSPECIFIED,\n branch: extract({ value: stamp.branch }) ?? BuildInfoRegistry.UNSPECIFIED,\n builtAt: extract({ value: stamp.builtAt }) ?? BuildInfoRegistry.UNSPECIFIED,\n };\n }\n\n /** `3661` -> `1h 1m 1s`: an operator reads a restart out of this faster than out of a float. */\n static toHumanUptime(opts: { seconds: number }): string {\n const total = Math.floor(opts.seconds);\n const hours = Math.floor(total / 3600);\n const minutes = Math.floor((total % 3600) / 60);\n const seconds = total % 60;\n\n return `${hours}h ${minutes}m ${seconds}s`;\n }\n\n private static toMegabytes(opts: { bytes: number }): string {\n return `${(opts.bytes / HealthCheckReporter.BYTES_PER_MB).toFixed(1)} MB`;\n }\n\n static buildStats(opts: { options: IHealthCheckOptions; appInfo?: IApplicationInfo }) {\n const memory = process.memoryUsage();\n const uptime = process.uptime();\n\n return {\n ...HealthCheckReporter.buildSummary(),\n build: HealthCheckReporter.resolveBuildInfo(opts),\n process: {\n pid: process.pid,\n uptime,\n uptimeHuman: HealthCheckReporter.toHumanUptime({ seconds: uptime }),\n runtime: `bun ${Bun.version}`,\n // `ambient`, not `current`: an unset `NODE_ENV` is reported as such, never dressed up as `development`.\n environment: Environment.ambient ?? BuildInfoRegistry.UNSPECIFIED,\n },\n memory: {\n rss: HealthCheckReporter.toMegabytes({ bytes: memory.rss }),\n heapUsed: HealthCheckReporter.toMegabytes({ bytes: memory.heapUsed }),\n heapTotal: HealthCheckReporter.toMegabytes({ bytes: memory.heapTotal }),\n },\n };\n }\n}\n"]}
1
+ {"version":3,"file":"reporter.js","sourceRoot":"","sources":["../../../../src/components/health-check/reporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAyB,MAAM,6BAA6B,CAAC;AAIvF;;;;;;;GAOG;AACH,MAAM,OAAO,mBAAmB;aACN,iBAAY,GAAG,IAAI,GAAG,IAAI,CAAC;IAEnD,iGAAiG;IACjG,MAAM,CAAC,YAAY;QACjB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;IAC/D,CAAC;IAED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,cAAc,CAAC,IAIrB;QACC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;QAE5C,IAAI,OAAO,MAAM,KAAK,SAAS,EAAE,CAAC;YAChC,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC;QAE5E,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,WAAW,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IACjE,CAAC;IAED;;;;;;;;OAQG;IACH;;;;;;;;;OASG;IACH,MAAM,CAAC,gBAAgB,CAAC,IAGvB;QACC,IAAI,CAAC,mBAAm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C;IAC7C,CAAC;IAEO,MAAM,CAAC,WAAW,CAAC,IAAuB;QAChD,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,mBAAmB,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5E,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,IAAkE;QAClF,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;QACrC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;QAEhC,OAAO;YACL,GAAG,mBAAmB,CAAC,YAAY,EAAE;YACrC,KAAK,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,IAAI,CAAC;YACjD,OAAO,EAAE;gBACP,GAAG,EAAE,OAAO,CAAC,GAAG;gBAChB,MAAM;gBACN,WAAW,EAAE,mBAAmB,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;gBACnE,OAAO,EAAE,OAAO,GAAG,CAAC,OAAO,EAAE;gBAC7B,wGAAwG;gBACxG,WAAW,EAAE,WAAW,CAAC,OAAO,IAAI,iBAAiB,CAAC,WAAW;aAClE;YACD,MAAM,EAAE;gBACN,GAAG,EAAE,mBAAmB,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC;gBAC3D,QAAQ,EAAE,mBAAmB,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACrE,SAAS,EAAE,mBAAmB,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC;aACxE;SACF,CAAC;IACJ,CAAC","sourcesContent":["import { Environment, Hash } from '@venizia/ignis-helpers';\nimport { BuildInfoRegistry, type TBuildInfoRecord } from '@venizia/ignis-helpers/core';\nimport type { IApplicationInfo } from '@venizia/ignis-kernel';\nimport type { IHealthCheckOptions } from './common';\n\n/**\n * Assembles what `GET /health` and `GET /health/stats` answer.\n *\n * Never reads the filesystem and never spawns `git`: the build stamp is PUSHED in at the\n * entrypoint through {@link BuildInfoRegistry} (or the component's own options), so a\n * `bun build --compile` binary and a Distroless image - neither of which has `node_modules`,\n * `.git` or a readable `package.json` - report exactly what a dev machine does.\n */\nexport class HealthCheckReporter {\n private static readonly BYTES_PER_MB = 1024 * 1024;\n\n /** Public liveness answer: liveness and the server clock, nothing a probe cannot already see. */\n static buildSummary(): { status: string; timestamp: string } {\n return { status: 'ok', timestamp: new Date().toISOString() };\n }\n\n /**\n * Fail-closed, copying `AppErrorMiddleware.isProduction`: the default is MEMBERSHIP in\n * `DEVELOPMENT_ENVS`, never inequality against `production`. `staging`, `uat`, `alpha` and a\n * typo all keep this route shut, because the runtime and release it names are what picks an\n * exploit. `ambient`, not `current`: an unset `NODE_ENV` is a host that cannot prove it is a dev\n * machine, and `current` would mask it as `development`.\n *\n * `enable` is compared to `true`/`false` rather than read through `??`: this binding is\n * env/config driven, and a JSON-derived `\"false\"` is truthy - an operator who wrote false would\n * otherwise get the route mounted.\n */\n static isStatsEnabled(opts: {\n options: IHealthCheckOptions;\n /** Reads the ambient environment; injected by tests so nothing has to write `process.env`. */\n environment?: () => string | undefined;\n }): boolean {\n const { enable } = opts.options.stats ?? {};\n\n if (typeof enable === 'boolean') {\n return enable;\n }\n\n const ambient = opts.environment ? opts.environment() : Environment.ambient;\n\n if (ambient === undefined) {\n return false;\n }\n\n return Environment.DEVELOPMENT_ENVS.has(ambient.toLowerCase());\n }\n\n /**\n * No `secretKey` configured leaves the route open to whatever can reach the port - stated, not\n * implied. Anything that is not a non-blank string fails CLOSED: a blank or config-derived\n * non-string key is a pipeline that lost the variable, and reading it as \"no key\" would publish\n * the route the operator meant to lock.\n *\n * The comparison is a plain `===`: a remote timing attack on a header compare is not practical\n * through an HTTP stack, and a constant-time digest compare would buy nothing here.\n */\n /**\n * Whether the stats route is mounted, unauthenticated, and on a host that cannot be shown to be a\n * development one. That combination stays LEGAL - on a cluster-internal port it is often the right\n * call - so this reports rather than refuses, and the component turns it into one warning at boot.\n *\n * It exists because `enable: true` bypasses the environment gate entirely: an operator who sets it\n * for a local run and ships the same code publishes the runtime version, the release and the\n * memory profile to whatever can reach the port. A blank `secretKey` is NOT unguarded - that fails\n * closed in {@link isStatsAuthorized}.\n */\n static isStatsUnguarded(opts: {\n options: IHealthCheckOptions;\n environment?: () => string | undefined;\n }): boolean {\n if (!HealthCheckReporter.isStatsEnabled(opts)) {\n return false;\n }\n\n if (opts.options.stats?.secretKey !== undefined) {\n return false;\n }\n\n const ambient = opts.environment ? opts.environment() : Environment.ambient;\n\n if (ambient === undefined) {\n return true;\n }\n\n return !Environment.DEVELOPMENT_ENVS.has(ambient.toLowerCase());\n }\n\n static isStatsAuthorized(opts: { options: IHealthCheckOptions; header?: string }): boolean {\n const secretKey = opts.options.stats?.secretKey;\n\n if (secretKey === undefined) {\n return true;\n }\n\n if (typeof secretKey !== 'string' || secretKey.trim().length === 0) {\n return false;\n }\n\n return Hash.equals({ value: opts.header ?? '', expected: secretKey });\n }\n\n /** The slot is a process-wide `globalThis` entry any dependency can write, and `IBuildInfo` types it without checking - so a non-string never reaches the response schema, which declares `z.string()`. */\n private static extractText(opts: { value: unknown }): string | undefined {\n return typeof opts.value === 'string' && opts.value.length > 0 ? opts.value : undefined;\n }\n\n /**\n * Explicit options win over the registry, and the application's own `getAppInfo()` fills what\n * neither carries - so a host that ran no generator still reports its real name and version.\n */\n static resolveBuildInfo(opts: {\n options: IHealthCheckOptions;\n appInfo?: IApplicationInfo;\n }): TBuildInfoRecord {\n const stamp = opts.options.stats?.buildInfo ?? BuildInfoRegistry.get() ?? {};\n const extract = HealthCheckReporter.extractText;\n\n return {\n service:\n extract({ value: stamp.service }) ?? opts.appInfo?.name ?? BuildInfoRegistry.UNSPECIFIED,\n version:\n extract({ value: stamp.version }) ?? opts.appInfo?.version ?? BuildInfoRegistry.UNSPECIFIED,\n commit: extract({ value: stamp.commit }) ?? BuildInfoRegistry.UNSPECIFIED,\n branch: extract({ value: stamp.branch }) ?? BuildInfoRegistry.UNSPECIFIED,\n builtAt: extract({ value: stamp.builtAt }) ?? BuildInfoRegistry.UNSPECIFIED,\n };\n }\n\n /** `3661` -> `1h 1m 1s`: an operator reads a restart out of this faster than out of a float. */\n static toHumanUptime(opts: { seconds: number }): string {\n const total = Math.floor(opts.seconds);\n const hours = Math.floor(total / 3600);\n const minutes = Math.floor((total % 3600) / 60);\n const seconds = total % 60;\n\n return `${hours}h ${minutes}m ${seconds}s`;\n }\n\n private static toMegabytes(opts: { bytes: number }): string {\n return `${(opts.bytes / HealthCheckReporter.BYTES_PER_MB).toFixed(1)} MB`;\n }\n\n static buildStats(opts: { options: IHealthCheckOptions; appInfo?: IApplicationInfo }) {\n const memory = process.memoryUsage();\n const uptime = process.uptime();\n\n return {\n ...HealthCheckReporter.buildSummary(),\n build: HealthCheckReporter.resolveBuildInfo(opts),\n process: {\n pid: process.pid,\n uptime,\n uptimeHuman: HealthCheckReporter.toHumanUptime({ seconds: uptime }),\n runtime: `bun ${Bun.version}`,\n // `ambient`, not `current`: an unset `NODE_ENV` is reported as such, never dressed up as `development`.\n environment: Environment.ambient ?? BuildInfoRegistry.UNSPECIFIED,\n },\n memory: {\n rss: HealthCheckReporter.toMegabytes({ bytes: memory.rss }),\n heapUsed: HealthCheckReporter.toMegabytes({ bytes: memory.heapUsed }),\n heapTotal: HealthCheckReporter.toMegabytes({ bytes: memory.heapTotal }),\n },\n };\n }\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  export * from './auth/index.js';
2
2
  export * from './health-check/index.js';
3
+ export * from './server-info/index.js';
3
4
  export * from './request-tracker/index.js';
4
5
  export * from './api-reference/index.js';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,6 @@
1
1
  export * from './auth/index.js';
2
2
  export * from './health-check/index.js';
3
+ export * from './server-info/index.js';
3
4
  export * from './request-tracker/index.js';
4
5
  export * from './api-reference/index.js';
5
6
  // Excluded from the barrel - import directly from the subpath: mail, socket-io, static-asset, websocket
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAEhC,wGAAwG","sourcesContent":["export * from './auth';\nexport * from './health-check';\nexport * from './request-tracker';\nexport * from './api-reference';\n\n// Excluded from the barrel - import directly from the subpath: mail, socket-io, static-asset, websocket\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAEhC,wGAAwG","sourcesContent":["export * from './auth';\nexport * from './health-check';\nexport * from './server-info';\nexport * from './request-tracker';\nexport * from './api-reference';\n\n// Excluded from the barrel - import directly from the subpath: mail, socket-io, static-asset, websocket\n"]}
@@ -1,6 +1,7 @@
1
1
  /** Sizes and lifetimes for generated verification data: code digits, token bytes, code lifetime in minutes, token lifetime in hours. */
2
2
  export interface IVerificationGenerationOptions {
3
3
  codeLength: number;
4
+ /** Random bytes of the verification token; an integer of at least 16 (128 bits), or generation throws. */
4
5
  tokenBytes: number;
5
6
  codeExpiryMinutes: number;
6
7
  tokenExpiryHours: number;
@@ -1 +1 @@
1
- {"version":3,"file":"verification.js","sourceRoot":"","sources":["../../../../../../src/components/mail/common/types/verification.ts"],"names":[],"mappings":"","sourcesContent":["/** Sizes and lifetimes for generated verification data: code digits, token bytes, code lifetime in minutes, token lifetime in hours. */\nexport interface IVerificationGenerationOptions {\n codeLength: number;\n tokenBytes: number;\n codeExpiryMinutes: number;\n tokenExpiryHours: number;\n}\n\n/** A verification code and token with their generation and expiry times (ISO 8601 strings) and the failed-attempt count. */\nexport interface IVerificationData {\n verificationCode: string;\n codeGeneratedAt: string;\n codeExpiresAt: string;\n codeAttempts: number;\n\n verificationToken: string;\n tokenGeneratedAt: string;\n tokenExpiresAt: string;\n\n lastCodeSentAt: string;\n}\n\n/** Generates a numeric verification code. */\nexport interface IVerificationCodeGenerator {\n generateCode(length: number): string;\n}\n\n/** Generates a random verification token. */\nexport interface IVerificationTokenGenerator {\n generateToken(bytes: number): string;\n}\n\n/** Generates a full `IVerificationData` (code, token, timestamps) from the given sizes and lifetimes. */\nexport interface IVerificationDataGenerator {\n generateVerificationData(options: IVerificationGenerationOptions): IVerificationData;\n}\n"]}
1
+ {"version":3,"file":"verification.js","sourceRoot":"","sources":["../../../../../../src/components/mail/common/types/verification.ts"],"names":[],"mappings":"","sourcesContent":["/** Sizes and lifetimes for generated verification data: code digits, token bytes, code lifetime in minutes, token lifetime in hours. */\nexport interface IVerificationGenerationOptions {\n codeLength: number;\n /** Random bytes of the verification token; an integer of at least 16 (128 bits), or generation throws. */\n tokenBytes: number;\n codeExpiryMinutes: number;\n tokenExpiryHours: number;\n}\n\n/** A verification code and token with their generation and expiry times (ISO 8601 strings) and the failed-attempt count. */\nexport interface IVerificationData {\n verificationCode: string;\n codeGeneratedAt: string;\n codeExpiresAt: string;\n codeAttempts: number;\n\n verificationToken: string;\n tokenGeneratedAt: string;\n tokenExpiresAt: string;\n\n lastCodeSentAt: string;\n}\n\n/** Generates a numeric verification code. */\nexport interface IVerificationCodeGenerator {\n generateCode(length: number): string;\n}\n\n/** Generates a random verification token. */\nexport interface IVerificationTokenGenerator {\n generateToken(bytes: number): string;\n}\n\n/** Generates a full `IVerificationData` (code, token, timestamps) from the given sizes and lifetimes. */\nexport interface IVerificationDataGenerator {\n generateVerificationData(options: IVerificationGenerationOptions): IVerificationData;\n}\n"]}
@@ -1,13 +1,8 @@
1
1
  import { BaseHelper } from '@venizia/ignis-helpers/core';
2
2
  import type { IVerificationCodeGenerator } from '../../common/index.js';
3
- /** Generates zero-padded numeric codes from a cryptographic source, uniformly distributed. `generateCode` throws unless `10 ** length` is an integer up to 2 ** 48. */
3
+ /** Generates zero-padded numeric codes through `NumericUidHelper`, uniformly distributed. `generateCode` throws unless `10 ** length` is an integer up to 2 ** 48. */
4
4
  export declare class NumericCodeGenerator extends BaseHelper implements IVerificationCodeGenerator {
5
5
  constructor();
6
6
  generateCode(length: number): string;
7
- /**
8
- * A uniform integer in `[0, max)`. A draw at or above the largest multiple of `max` is thrown away and drawn
9
- * again, so no code is likelier than another (`value % max` alone favours the low codes).
10
- */
11
- private static getRandomBelow;
12
7
  }
13
8
  //# sourceMappingURL=numeric-code.d.ts.map
@@ -1,39 +1,11 @@
1
- import { BaseHelper, getError } from '@venizia/ignis-helpers/core';
2
- /** `crypto.randomInt` draws a 48-bit value; the same width keeps the same range (`max` up to 2 ** 48). */
3
- const DRAW_BYTES = 6;
4
- const DRAW_RANGE = 2 ** (DRAW_BYTES * 8);
5
- /** Generates zero-padded numeric codes from a cryptographic source, uniformly distributed. `generateCode` throws unless `10 ** length` is an integer up to 2 ** 48. */
1
+ import { BaseHelper, NumericUidHelper } from '@venizia/ignis-helpers/core';
2
+ /** Generates zero-padded numeric codes through `NumericUidHelper`, uniformly distributed. `generateCode` throws unless `10 ** length` is an integer up to 2 ** 48. */
6
3
  export class NumericCodeGenerator extends BaseHelper {
7
4
  constructor() {
8
5
  super({ scope: NumericCodeGenerator.name });
9
6
  }
10
7
  generateCode(length) {
11
- const max = Math.pow(10, length);
12
- const code = NumericCodeGenerator.getRandomBelow({ max });
13
- return code.toString().padStart(length, '0');
14
- }
15
- /**
16
- * A uniform integer in `[0, max)`. A draw at or above the largest multiple of `max` is thrown away and drawn
17
- * again, so no code is likelier than another (`value % max` alone favours the low codes).
18
- */
19
- static getRandomBelow(opts) {
20
- const { max } = opts;
21
- if (!Number.isSafeInteger(max) || max <= 0 || max > DRAW_RANGE) {
22
- throw getError({
23
- message: `[NumericCodeGenerator][generateCode] Invalid length | 10 ** length must be an integer from 1 to ${DRAW_RANGE} | Got: ${max}`,
24
- });
25
- }
26
- const limit = DRAW_RANGE - (DRAW_RANGE % max);
27
- for (;;) {
28
- const bytes = crypto.getRandomValues(new Uint8Array(DRAW_BYTES));
29
- let value = 0;
30
- for (const byte of bytes) {
31
- value = value * 256 + byte;
32
- }
33
- if (value < limit) {
34
- return value % max;
35
- }
36
- }
8
+ return new NumericUidHelper({ length }).nextId();
37
9
  }
38
10
  }
39
11
  //# sourceMappingURL=numeric-code.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"numeric-code.js","sourceRoot":"","sources":["../../../../../../src/components/mail/services/generators/numeric-code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAGnE,0GAA0G;AAC1G,MAAM,UAAU,GAAG,CAAC,CAAC;AACrB,MAAM,UAAU,GAAG,CAAC,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;AAEzC,uKAAuK;AACvK,MAAM,OAAO,oBAAqB,SAAQ,UAAU;IAClD;QACE,KAAK,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED,YAAY,CAAC,MAAc;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QACjC,MAAM,IAAI,GAAG,oBAAoB,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;QAE1D,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/C,CAAC;IAED;;;OAGG;IACK,MAAM,CAAC,cAAc,CAAC,IAAqB;QACjD,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;QAErB,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,GAAG,GAAG,UAAU,EAAE,CAAC;YAC/D,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,mGAAmG,UAAU,WAAW,GAAG,EAAE;aACvI,CAAC,CAAC;QACL,CAAC;QAED,MAAM,KAAK,GAAG,UAAU,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,CAAC;QAE9C,SAAS,CAAC;YACR,MAAM,KAAK,GAAG,MAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;YACjE,IAAI,KAAK,GAAG,CAAC,CAAC;YAEd,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,KAAK,GAAG,KAAK,GAAG,GAAG,GAAG,IAAI,CAAC;YAC7B,CAAC;YAED,IAAI,KAAK,GAAG,KAAK,EAAE,CAAC;gBAClB,OAAO,KAAK,GAAG,GAAG,CAAC;YACrB,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { BaseHelper, getError } from '@venizia/ignis-helpers/core';\nimport type { IVerificationCodeGenerator } from '../../common';\n\n/** `crypto.randomInt` draws a 48-bit value; the same width keeps the same range (`max` up to 2 ** 48). */\nconst DRAW_BYTES = 6;\nconst DRAW_RANGE = 2 ** (DRAW_BYTES * 8);\n\n/** Generates zero-padded numeric codes from a cryptographic source, uniformly distributed. `generateCode` throws unless `10 ** length` is an integer up to 2 ** 48. */\nexport class NumericCodeGenerator extends BaseHelper implements IVerificationCodeGenerator {\n constructor() {\n super({ scope: NumericCodeGenerator.name });\n }\n\n generateCode(length: number): string {\n const max = Math.pow(10, length);\n const code = NumericCodeGenerator.getRandomBelow({ max });\n\n return code.toString().padStart(length, '0');\n }\n\n /**\n * A uniform integer in `[0, max)`. A draw at or above the largest multiple of `max` is thrown away and drawn\n * again, so no code is likelier than another (`value % max` alone favours the low codes).\n */\n private static getRandomBelow(opts: { max: number }): number {\n const { max } = opts;\n\n if (!Number.isSafeInteger(max) || max <= 0 || max > DRAW_RANGE) {\n throw getError({\n message: `[NumericCodeGenerator][generateCode] Invalid length | 10 ** length must be an integer from 1 to ${DRAW_RANGE} | Got: ${max}`,\n });\n }\n\n const limit = DRAW_RANGE - (DRAW_RANGE % max);\n\n for (;;) {\n const bytes = crypto.getRandomValues(new Uint8Array(DRAW_BYTES));\n let value = 0;\n\n for (const byte of bytes) {\n value = value * 256 + byte;\n }\n\n if (value < limit) {\n return value % max;\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"numeric-code.js","sourceRoot":"","sources":["../../../../../../src/components/mail/services/generators/numeric-code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG3E,sKAAsK;AACtK,MAAM,OAAO,oBAAqB,SAAQ,UAAU;IAClD;QACE,KAAK,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED,YAAY,CAAC,MAAc;QACzB,OAAO,IAAI,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;IACnD,CAAC;CACF","sourcesContent":["import { BaseHelper, NumericUidHelper } from '@venizia/ignis-helpers/core';\nimport type { IVerificationCodeGenerator } from '../../common';\n\n/** Generates zero-padded numeric codes through `NumericUidHelper`, uniformly distributed. `generateCode` throws unless `10 ** length` is an integer up to 2 ** 48. */\nexport class NumericCodeGenerator extends BaseHelper implements IVerificationCodeGenerator {\n constructor() {\n super({ scope: NumericCodeGenerator.name });\n }\n\n generateCode(length: number): string {\n return new NumericUidHelper({ length }).nextId();\n }\n}\n"]}
@@ -1,6 +1,9 @@
1
1
  import { BaseHelper } from '@venizia/ignis-helpers/core';
2
2
  import type { IVerificationTokenGenerator } from '../../common/index.js';
3
- /** Generates base64url tokens from random bytes; `generateToken` throws unless `bytes` is a non-negative integer. */
3
+ /**
4
+ * Generates base64url tokens from random bytes, through `TokenUidHelper`. `generateToken` throws
5
+ * unless `bytes` is an integer of at least 16 (128 bits): a shorter token can be guessed offline.
6
+ */
4
7
  export declare class RandomTokenGenerator extends BaseHelper implements IVerificationTokenGenerator {
5
8
  constructor();
6
9
  generateToken(bytes: number): string;
@@ -1,17 +1,20 @@
1
- import { BaseHelper, getError } from '@venizia/ignis-helpers/core';
2
- /** Generates base64url tokens from random bytes; `generateToken` throws unless `bytes` is a non-negative integer. */
1
+ import { BaseHelper, getError, TokenUidHelper, UidTokenEncodings, } from '@venizia/ignis-helpers/core';
2
+ /**
3
+ * Generates base64url tokens from random bytes, through `TokenUidHelper`. `generateToken` throws
4
+ * unless `bytes` is an integer of at least 16 (128 bits): a shorter token can be guessed offline.
5
+ */
3
6
  export class RandomTokenGenerator extends BaseHelper {
4
7
  constructor() {
5
8
  super({ scope: RandomTokenGenerator.name });
6
9
  }
7
10
  generateToken(bytes) {
8
- // `new Uint8Array(NaN)` is empty: without this check a misconfigured size would give an empty token.
9
- if (!Number.isSafeInteger(bytes) || bytes < 0) {
11
+ // `TokenUidHelper` reads a missing size as its 32-byte default; here a missing size is a misconfiguration, as it always was.
12
+ if (typeof bytes !== 'number') {
10
13
  throw getError({
11
- message: `[RandomTokenGenerator][generateToken] Invalid bytes | Expected a non-negative integer | Got: ${bytes}`,
14
+ message: `[RandomTokenGenerator][generateToken] Invalid bytes | Expected an integer of at least 16 | Got: ${bytes}`,
12
15
  });
13
16
  }
14
- return Buffer.from(crypto.getRandomValues(new Uint8Array(bytes))).toString('base64url');
17
+ return new TokenUidHelper({ bytes, encoding: UidTokenEncodings.BASE64URL }).nextId();
15
18
  }
16
19
  }
17
20
  //# sourceMappingURL=random-token.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"random-token.js","sourceRoot":"","sources":["../../../../../../src/components/mail/services/generators/random-token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAGnE,qHAAqH;AACrH,MAAM,OAAO,oBAAqB,SAAQ,UAAU;IAClD;QACE,KAAK,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED,aAAa,CAAC,KAAa;QACzB,qGAAqG;QACrG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;YAC9C,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,gGAAgG,KAAK,EAAE;aACjH,CAAC,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC1F,CAAC;CACF","sourcesContent":["import { BaseHelper, getError } from '@venizia/ignis-helpers/core';\nimport type { IVerificationTokenGenerator } from '../../common';\n\n/** Generates base64url tokens from random bytes; `generateToken` throws unless `bytes` is a non-negative integer. */\nexport class RandomTokenGenerator extends BaseHelper implements IVerificationTokenGenerator {\n constructor() {\n super({ scope: RandomTokenGenerator.name });\n }\n\n generateToken(bytes: number): string {\n // `new Uint8Array(NaN)` is empty: without this check a misconfigured size would give an empty token.\n if (!Number.isSafeInteger(bytes) || bytes < 0) {\n throw getError({\n message: `[RandomTokenGenerator][generateToken] Invalid bytes | Expected a non-negative integer | Got: ${bytes}`,\n });\n }\n\n return Buffer.from(crypto.getRandomValues(new Uint8Array(bytes))).toString('base64url');\n }\n}\n"]}
1
+ {"version":3,"file":"random-token.js","sourceRoot":"","sources":["../../../../../../src/components/mail/services/generators/random-token.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,QAAQ,EACR,cAAc,EACd,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;AAGrC;;;GAGG;AACH,MAAM,OAAO,oBAAqB,SAAQ,UAAU;IAClD;QACE,KAAK,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED,aAAa,CAAC,KAAa;QACzB,6HAA6H;QAC7H,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,mGAAmG,KAAK,EAAE;aACpH,CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,cAAc,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,iBAAiB,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;IACvF,CAAC;CACF","sourcesContent":["import {\n BaseHelper,\n getError,\n TokenUidHelper,\n UidTokenEncodings,\n} from '@venizia/ignis-helpers/core';\nimport type { IVerificationTokenGenerator } from '../../common';\n\n/**\n * Generates base64url tokens from random bytes, through `TokenUidHelper`. `generateToken` throws\n * unless `bytes` is an integer of at least 16 (128 bits): a shorter token can be guessed offline.\n */\nexport class RandomTokenGenerator extends BaseHelper implements IVerificationTokenGenerator {\n constructor() {\n super({ scope: RandomTokenGenerator.name });\n }\n\n generateToken(bytes: number): string {\n // `TokenUidHelper` reads a missing size as its 32-byte default; here a missing size is a misconfiguration, as it always was.\n if (typeof bytes !== 'number') {\n throw getError({\n message: `[RandomTokenGenerator][generateToken] Invalid bytes | Expected an integer of at least 16 | Got: ${bytes}`,\n });\n }\n\n return new TokenUidHelper({ bytes, encoding: UidTokenEncodings.BASE64URL }).nextId();\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { HTTP } from '@venizia/ignis-helpers/common';
2
- import { getError } from '@venizia/ignis-helpers/core';
2
+ import { getError, TokenUidHelper, UidTokenEncodings } from '@venizia/ignis-helpers/core';
3
3
  import { MailErrorCodes } from '../common/index.js';
4
4
  import { MailAddressUtility } from './address.utility.js';
5
5
  import { MailAttachmentUtility } from './attachment.utility.js';
@@ -17,9 +17,9 @@ const MAX_HEADER_LINE_LENGTH = 78;
17
17
  const MAX_HEADER_HARD_LIMIT = 990;
18
18
  /** RFC 2047 caps one encoded-word (`=?charset?B?...?=` included) at 75 characters. */
19
19
  const ENCODED_WORD_MAX_LENGTH = 75;
20
- /** `bytes` random bytes as lowercase hex, from the platform CSPRNG. */
20
+ /** `bytes` random bytes as lowercase hex, from the platform CSPRNG. `bytes` is at least 16, the floor of `TokenUidHelper`. */
21
21
  function generateRandomHex(opts) {
22
- return Buffer.from(crypto.getRandomValues(new Uint8Array(opts.bytes))).toString('hex');
22
+ return new TokenUidHelper({ bytes: opts.bytes, encoding: UidTokenEncodings.HEX }).nextId();
23
23
  }
24
24
  function isAscii(value) {
25
25
  for (let index = 0; index < value.length; index++) {
@@ -292,7 +292,7 @@ async function attachmentPart(attachment, boundary) {
292
292
  }
293
293
  /** 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
294
  function newBoundary(label) {
295
- return `----=_${label}_${generateRandomHex({ bytes: 12 })}`;
295
+ return `----=_${label}_${generateRandomHex({ bytes: 16 })}`;
296
296
  }
297
297
  /** Builds the MIME pieces the Amazon SES transport sends: the raw message and RFC 5322 address headers. */
298
298
  export class MailMimeUtility {
@@ -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,uB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AAW,CAAC,OAAO,CAAC,CAAC;QAC3C,OAAO,CAAC,IAAI,CAAC,4CAA4C,aAAa,GAAG,CAAC,CAAC;QAE3E,MAAM,SAAS,GAAa,EAAE,CAAC;QAE/B,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACjC,MAAM,OAAO,GAAG,MAAM,gBAAgB,CAAC,aAAa,CAAC,CAAC;YACtD,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1B,CAAC;aAAM,CAAC;YACN,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;QAC1C,CAAC;QAED,KAAK,MAAM,UAAU,IAAI,eAAe,EAAE,CAAC;YACzC,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;YAChE,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1B,CAAC;QAED,SAAS,CAAC,IAAI,CAAC,KAAK,aAAa,IAAI,CAAC,CAAC;QAEvC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,EAAE,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;IACjF,CAAC;CACF","sourcesContent":["import { HTTP } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { MailErrorCodes, type IMailAttachment, type IMailMessage } from '../common';\nimport { MailAddressUtility } from './address.utility';\nimport { MailAttachmentUtility } from './attachment.utility';\n\nconst CRLF = '\\r\\n';\nconst BASE64_LINE_LENGTH = 76;\n/** RFC 5322 recommends folding well under its own 998-byte hard limit; 78 matches common MTA\n * practice. This is a *soft* preferred width, not a hard requirement - {@link foldHeaderLine}\n * only forces a line break past it when a natural whitespace break point exists nearby. */\nconst MAX_HEADER_LINE_LENGTH = 78;\n/** The real hard requirement: SES rejects any raw-message physical line at or over 1000 bytes.\n * A 10-byte margin below that, and comfortably under RFC 5322's own 998-octet hard limit. Only\n * an unbroken token that would itself cross this line forces {@link foldHeaderLine}'s\n * content-altering hard-wrap fallback - below it, one long line is safer than corrupting an\n * atomic value (a single very long address, an unbroken encoded-word) by splitting it. */\nconst MAX_HEADER_HARD_LIMIT = 990;\n/** RFC 2047 caps one encoded-word (`=?charset?B?...?=` included) at 75 characters. */\nconst ENCODED_WORD_MAX_LENGTH = 75;\n\n/** `bytes` random bytes as lowercase hex, from the platform CSPRNG. */\nfunction generateRandomHex(opts: { bytes: number }): string {\n return Buffer.from(crypto.getRandomValues(new Uint8Array(opts.bytes))).toString('hex');\n}\n\nfunction isAscii(value: string): boolean {\n for (let index = 0; index < value.length; index++) {\n if (value.charCodeAt(index) > 127) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * RFC 2047 §5(3) requires each encoded-word to carry whole characters - a multi-byte UTF-8\n * sequence split across two encoded-words decodes to mojibake or invalid UTF-8 on either side of\n * the cut. `bytesPerChunk` is a fixed byte budget, not a character-aligned one, so after slicing\n * at that budget we walk the boundary back over any UTF-8 continuation bytes (`10xxxxxx`, i.e.\n * `byte & 0xC0 === 0x80`) until it lands on the leading byte of a character. `bytesPerChunk` is\n * always far larger than the longest UTF-8 sequence (4 bytes), so this walk-back can never\n * consume the whole chunk. Words are joined with a single space - the required separator between\n * adjacent encoded-words, and also a valid header-folding point.\n */\nfunction encodeWord(text: string): string {\n const prefix = '=?UTF-8?B?';\n const suffix = '?=';\n const maxPayloadChars = ENCODED_WORD_MAX_LENGTH - prefix.length - suffix.length;\n const bytesPerChunk = Math.floor(maxPayloadChars / 4) * 3;\n const bytes = Buffer.from(text, 'utf-8');\n const words: string[] = [];\n let offset = 0;\n\n while (offset < bytes.length) {\n let end = Math.min(offset + bytesPerChunk, bytes.length);\n\n while (end < bytes.length && (bytes[end] & 0xc0) === 0x80) {\n end--;\n }\n\n const chunk = bytes.subarray(offset, end);\n words.push(`${prefix}${chunk.toString('base64')}${suffix}`);\n offset = end;\n }\n\n return words.join(' ');\n}\n\n/** Only non-ASCII values pay for RFC 2047 encoding, so a plain-English subject or custom header\n * stays byte-for-byte readable. */\nfunction encodeHeaderValue(value: string): string {\n return isAscii(value) ? value : encodeWord(value);\n}\n\n/**\n * Encodes only the *display-name* portion of `\"Name\" <addr@x.com>` (or bare `Name <addr@x.com>`).\n * The `<addr-spec>` must stay 7-bit ASCII per RFC 5321/5322 and per the SES raw-message\n * requirements - only the free-text name may become an RFC 2047 encoded-word. A bare address with\n * no display name is returned unchanged.\n */\nfunction encodeAddress(address: string): string {\n const match = /^(.*)<([^<>]+)>\\s*$/.exec(address);\n\n if (!match) {\n return address;\n }\n\n const [, rawName, addr] = match;\n const name = rawName.trim().replace(/^\"|\"$/g, '');\n\n if (name.length === 0 || isAscii(name)) {\n return rawName.trim().length > 0 ? `${rawName.trim()} <${addr}>` : `<${addr}>`;\n }\n\n return `${encodeWord(name)} <${addr}>`;\n}\n\n/** The body of `MailMimeUtility.formatAddressHeader`, callable from the header builder. */\nfunction formatAddressList(value: string | string[]): string {\n return MailAddressUtility.splitList({ value }).map(encodeAddress).join(', ');\n}\n\n/**\n * RFC 5322 §2.2.3 header folding: inserting CRLF immediately before an existing whitespace\n * character splits one logical header value across physical lines without changing its content\n * (the folded whitespace is still there, just after a line break). SES enforces a 1000-byte\n * ceiling per raw-message line; folding at {@link MAX_HEADER_LINE_LENGTH} keeps arbitrarily long\n * recipient lists, subjects, or encoded display names deliverable regardless of how many\n * addresses or how much non-ASCII text a caller supplies - purely by adding more physical\n * lines, never by dropping or truncating anything (verified: rejoining every folded line always\n * reproduces the original value exactly).\n *\n * The one value-altering fallback is deliberately gated on the *hard* limit, not the soft one:\n * an unbroken token (a single very long address, an encoded-word with no adjacent break) that\n * fits under {@link MAX_HEADER_HARD_LIMIT} is left on one long physical line rather than\n * force-broken at the soft width - forcing a break through the middle of an atomic token (an\n * email address has no internal whitespace) would insert a space that was never there,\n * corrupting it. Only a token that would itself violate the real transport limit gets the\n * content-altering hard-wrap - a case that essentially never occurs with real-world input.\n */\nfunction foldHeaderLine(line: string): string {\n const lines: string[] = [];\n let remaining = line;\n\n while (remaining.length > MAX_HEADER_LINE_LENGTH) {\n let breakAt = remaining.lastIndexOf(' ', MAX_HEADER_LINE_LENGTH);\n\n if (breakAt <= 0) {\n // No break within the soft width - look further ahead instead of forcing one through an\n // atomic token. Still bounded by the hard limit, so the physical line this produces can\n // never violate the real transport constraint.\n const nextBreak = remaining.indexOf(' ', MAX_HEADER_LINE_LENGTH);\n breakAt = nextBreak > 0 && nextBreak <= MAX_HEADER_HARD_LIMIT ? nextBreak : -1;\n }\n\n if (breakAt > 0) {\n lines.push(remaining.slice(0, breakAt));\n remaining = remaining.slice(breakAt);\n continue;\n }\n\n if (remaining.length <= MAX_HEADER_HARD_LIMIT) {\n break;\n }\n\n // Truly no natural break within the hard limit - an unbroken token that would itself\n // violate the transport line cap. This is the only path that can alter the value.\n lines.push(remaining.slice(0, MAX_HEADER_HARD_LIMIT));\n remaining = ` ${remaining.slice(MAX_HEADER_HARD_LIMIT)}`;\n }\n\n lines.push(remaining);\n\n return lines.join(CRLF);\n}\n\n/** MIME requires encoded body lines capped well under the RFC 5322 998-byte hard limit. */\nfunction foldBase64(base64: string): string {\n const lines: string[] = [];\n\n for (let index = 0; index < base64.length; index += BASE64_LINE_LENGTH) {\n lines.push(base64.slice(index, index + BASE64_LINE_LENGTH));\n }\n\n return lines.join(CRLF);\n}\n\n/** UTF-8 text (`text`/`html` bodies) must be encoded before folding - unlike {@link encodeBufferBase64}, which folds bytes that are already final. Two names instead of one so the caller can never feed raw bytes through the wrong path and silently double-encode them. */\nfunction encodeTextBase64(text: string): string {\n return foldBase64(Buffer.from(text, 'utf-8').toString('base64'));\n}\n\n/** Attachment bytes are already final binary content - only folding applies, no UTF-8 re-encode. */\nfunction encodeBufferBase64(buffer: Buffer): string {\n return foldBase64(buffer.toString('base64'));\n}\n\n/** A literal CR/LF/NUL inside a header-bound value would let it break out of its own header line and forge additional headers or smuggle body content - classic email header injection. Every value spliced into a raw header line is checked here first, so an attempt fails loudly instead of silently reaching the wire.\n *\n * `value` is `unknown`, not `string`: `IMailMessage`/`IMailAttachment` both end in\n * `[key: string]: any`, so nothing at the type layer stops a caller (e.g. a controller\n * forwarding a request body) from putting a non-string - notably an array - where a string is\n * declared. `Array.prototype.includes('\\r')` checks element *equality*, not substring, so\n * `['x\\r\\nBcc: evil'].includes('\\r')` is `false` and a naive string-only check would wave a\n * forged header straight through once it is later stringified by a template literal. Requiring\n * `typeof value === 'string'` up front closes that gap for every field that flows through here. */\nfunction assertNoHeaderInjection(opts: { field: string; value: unknown }): void {\n const { field, value } = opts;\n\n if (typeof value !== 'string') {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n messageCode: MailErrorCodes.INVALID_CONFIGURATION,\n message: `Invalid Amazon SES message | ${field} must be a string`,\n });\n }\n\n if (!value.includes('\\r') && !value.includes('\\n') && !value.includes('\\0')) {\n return;\n }\n\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n messageCode: MailErrorCodes.INVALID_CONFIGURATION,\n message: `Invalid Amazon SES message | ${field} contains illegal control characters`,\n });\n}\n\n/** Same guard as {@link assertNoHeaderInjection}, applied to every address in a `to`/`cc`/`bcc`\n * field individually - a string field only, not `[key: string]: any`; validating the raw\n * caller-provided value (before splitting/joining) both types and content-checks each entry. */\nfunction assertNoAddressListInjection(opts: { field: string; value: string | string[] }): void {\n const { field, value } = opts;\n const list = Array.isArray(value) ? value : [value];\n\n for (const item of list) {\n assertNoHeaderInjection({ field, value: item });\n }\n}\n\nfunction extractDomain(address: string | undefined): string {\n const match = address ? /@([^@>\\s]+)>?\\s*$/.exec(address) : null;\n\n return match ? match[1] : 'localhost';\n}\n\nfunction buildHeaders(message: IMailMessage): string[] {\n const headers: string[] = [];\n\n if (message.from) {\n assertNoAddressListInjection({ field: 'from', value: message.from });\n headers.push(foldHeaderLine(`From: ${formatAddressList(message.from)}`));\n }\n\n if (message.to) {\n assertNoAddressListInjection({ field: 'to', value: message.to });\n headers.push(foldHeaderLine(`To: ${formatAddressList(message.to)}`));\n }\n\n if (message.cc) {\n assertNoAddressListInjection({ field: 'cc', value: message.cc });\n headers.push(foldHeaderLine(`Cc: ${formatAddressList(message.cc)}`));\n }\n\n if (message.replyTo) {\n assertNoAddressListInjection({ field: 'replyTo', value: message.replyTo });\n headers.push(foldHeaderLine(`Reply-To: ${formatAddressList(message.replyTo)}`));\n }\n\n // Checked, never emitted: a `Bcc:` header would disclose the blind recipients, so they travel as\n // `Destination.BccAddresses`. Without this, `bcc` is the one address field that fails at AWS.\n if (message.bcc) {\n assertNoAddressListInjection({ field: 'bcc', value: message.bcc });\n }\n\n assertNoHeaderInjection({ field: 'subject', value: message.subject });\n headers.push(foldHeaderLine(`Subject: ${encodeHeaderValue(message.subject)}`));\n // RFC 5322 requires both on every message; SES's raw-message parser does not synthesize them,\n // so an omission here is an omission on the wire (some receiving MTAs reject a `Date`-less\n // message outright, and a missing `Message-ID` breaks threading and dedup).\n headers.push(`Date: ${new Date().toUTCString()}`);\n headers.push(`Message-ID: <${generateRandomHex({ bytes: 16 })}@${extractDomain(message.from)}>`);\n headers.push('MIME-Version: 1.0');\n\n if (message.headers) {\n const messageHeadersEntries = Object.entries(message.headers);\n\n for (const [key, value] of messageHeadersEntries) {\n assertNoHeaderInjection({ field: `headers.${key}`, value: key });\n assertNoHeaderInjection({ field: `headers.${key}`, value });\n headers.push(foldHeaderLine(`${key}: ${encodeHeaderValue(value)}`));\n }\n }\n\n return headers;\n}\n\n/** One text/plain or text/html MIME part. `boundary` omitted only for the single-part, no-attachment case, where the content type belongs on the top-level headers instead of a nested part. */\nfunction textPart(\n boundary: string,\n contentType: 'text/plain' | 'text/html',\n content: string,\n): string {\n return [\n `--${boundary}`,\n `Content-Type: ${contentType}; charset=UTF-8`,\n 'Content-Transfer-Encoding: base64',\n '',\n encodeTextBase64(content),\n ].join(CRLF);\n}\n\nfunction escapeQuotedString(value: string): string {\n return value.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"');\n}\n\n/** RFC 2231 percent-encoding for the `filename*=`/`name*=` extended parameter form. */\nfunction encodeRfc2231(value: string): string {\n return encodeURIComponent(value).replace(\n /[!'()*]/g,\n (char) => `%${char.charCodeAt(0).toString(16).toUpperCase()}`,\n );\n}\n\n/**\n * Builds the `; name=\"...\"`/`; filename=\"...\"` (and, for non-ASCII names, the RFC 2231\n * `; filename*=UTF-8''...` extended form) suffix for a Content-Type/Content-Disposition line.\n * ASCII names are still quoted-string escaped - an unescaped `\"` or `\\` in a filename would\n * terminate the quoted string early and let the rest of the value merge into a sibling MIME\n * parameter, corrupting the part header for every downstream reader.\n */\nfunction attachmentNameParams(attribute: 'name' | 'filename', value: string): string {\n if (isAscii(value)) {\n return `; ${attribute}=\"${escapeQuotedString(value)}\"`;\n }\n\n const asciiFallback = value.replace(/[^\\x20-\\x7E]/g, '_');\n\n return (\n `; ${attribute}=\"${escapeQuotedString(asciiFallback)}\"` +\n `; ${attribute}*=UTF-8''${encodeRfc2231(value)}`\n );\n}\n\nasync function attachmentPart(attachment: IMailAttachment, boundary: string): Promise<string> {\n // No root here: a `path` that did not go through `MailAttachmentUtility.resolve` is refused, never read.\n const content = await MailAttachmentUtility.readContent({ attachment });\n const contentType = attachment.contentType ?? 'application/octet-stream';\n assertNoHeaderInjection({ field: 'attachment.contentType', value: contentType });\n\n if (attachment.filename) {\n assertNoHeaderInjection({ field: 'attachment.filename', value: attachment.filename });\n }\n\n if (attachment.cid) {\n assertNoHeaderInjection({ field: 'attachment.cid', value: attachment.cid });\n }\n\n const nameAttribute = attachment.filename\n ? attachmentNameParams('name', attachment.filename)\n : '';\n const filenameAttribute = attachment.filename\n ? attachmentNameParams('filename', attachment.filename)\n : '';\n const disposition = attachment.cid ? 'inline' : 'attachment';\n\n const headerLines = [\n `--${boundary}`,\n foldHeaderLine(`Content-Type: ${contentType}${nameAttribute}`),\n 'Content-Transfer-Encoding: base64',\n foldHeaderLine(`Content-Disposition: ${disposition}${filenameAttribute}`),\n ];\n\n if (attachment.cid) {\n headerLines.push(`Content-ID: <${attachment.cid}>`);\n }\n\n return [...headerLines, '', encodeBufferBase64(content)].join(CRLF);\n}\n\n/** Every boundary is generated the same way - a fixed prefix plus random hex - so no two nested multipart sections in one message can ever collide. */\nfunction newBoundary(label: string): string {\n return `----=_${label}_${generateRandomHex({ bytes: 12 })}`;\n}\n\n/** Builds the MIME pieces the Amazon SES transport sends: the raw message and RFC 5322 address headers. */\nexport class MailMimeUtility {\n /** Formats a `to`/`cc`/`from`/`replyTo` field as one RFC 5322 address list: splits a\n * comma-separated string or array into individual mailboxes, RFC 2047-encodes each display name,\n * and rejoins with `, ` - the same shape whether the caller passed a string or an array. */\n static formatAddressHeader(opts: { value: string | string[] }): string {\n return formatAddressList(opts.value);\n }\n\n /**\n * Builds a raw RFC 822 message with zero external dependencies - Amazon SES's `SendEmailCommand`\n * `Content.Simple` shape has no attachment field, so attachments require a raw MIME body. Written\n * by hand instead of depending on `nodemailer`'s `MailComposer` so the `ses` provider never needs\n * the `nodemailer` peer installed at all.\n *\n * Inline (`cid`) attachments nest under `multipart/related` next to the body - a mail client\n * only renders `cid:` references inline when they share a `multipart/related` parent with the\n * body; under `multipart/mixed` they show up as ordinary downloadable attachments instead. Plain\n * file attachments (no `cid`) stay under `multipart/mixed`, alongside the body or the\n * `multipart/related` group when both kinds are present.\n */\n static async buildRawMessage(opts: { message: IMailMessage }): Promise<Buffer> {\n const { message } = opts;\n const headers = buildHeaders(message);\n const attachments = message.attachments ?? [];\n const inlineAttachments = attachments.filter((attachment) => Boolean(attachment.cid));\n const fileAttachments = attachments.filter((attachment) => !attachment.cid);\n const hasBothBodies = Boolean(message.text) && Boolean(message.html);\n const singleContentType = message.html ? ('text/html' as const) : ('text/plain' as const);\n const singleContent = message.html ?? message.text ?? '';\n\n const bodyPart = (boundary: string): string => {\n if (!hasBothBodies) {\n return textPart(boundary, singleContentType, singleContent);\n }\n\n const altBoundary = newBoundary('Alt');\n\n return [\n `--${boundary}`,\n `Content-Type: multipart/alternative; boundary=\"${altBoundary}\"`,\n '',\n [\n textPart(altBoundary, 'text/plain', message.text ?? ''),\n textPart(altBoundary, 'text/html', message.html ?? ''),\n `--${altBoundary}--`,\n ].join(CRLF),\n ].join(CRLF);\n };\n\n if (attachments.length === 0 && !hasBothBodies) {\n headers.push(`Content-Type: ${singleContentType}; charset=UTF-8`);\n headers.push('Content-Transfer-Encoding: base64');\n\n return Buffer.from([...headers, '', encodeTextBase64(singleContent)].join(CRLF), 'utf-8');\n }\n\n if (attachments.length === 0) {\n const boundary = newBoundary('Alt');\n headers.push(`Content-Type: multipart/alternative; boundary=\"${boundary}\"`);\n const parts = [\n textPart(boundary, 'text/plain', message.text ?? ''),\n textPart(boundary, 'text/html', message.html ?? ''),\n `--${boundary}--`,\n ];\n\n return Buffer.from([...headers, '', parts.join(CRLF)].join(CRLF), 'utf-8');\n }\n\n const buildRelatedPart = async (parentBoundary: string): Promise<string> => {\n const relatedBoundary = newBoundary('Related');\n const parts = [bodyPart(relatedBoundary)];\n\n for (const attachment of inlineAttachments) {\n const result = await attachmentPart(attachment, relatedBoundary);\n parts.push(result);\n }\n\n parts.push(`--${relatedBoundary}--`);\n\n return [\n `--${parentBoundary}`,\n `Content-Type: multipart/related; boundary=\"${relatedBoundary}\"`,\n '',\n parts.join(CRLF),\n ].join(CRLF);\n };\n\n if (inlineAttachments.length > 0 && fileAttachments.length === 0) {\n const relatedBoundary = newBoundary('Related');\n const parts = [bodyPart(relatedBoundary)];\n\n for (const attachment of inlineAttachments) {\n const result = await attachmentPart(attachment, relatedBoundary);\n parts.push(result);\n }\n\n parts.push(`--${relatedBoundary}--`);\n headers.push(`Content-Type: multipart/related; boundary=\"${relatedBoundary}\"`);\n\n return Buffer.from([...headers, '', parts.join(CRLF)].join(CRLF), 'utf-8');\n }\n\n const mixedBoundary = newBoundary('Mixed');\n headers.push(`Content-Type: multipart/mixed; boundary=\"${mixedBoundary}\"`);\n\n const bodyParts: string[] = [];\n\n if (inlineAttachments.length > 0) {\n const result2 = await buildRelatedPart(mixedBoundary);\n bodyParts.push(result2);\n } else {\n bodyParts.push(bodyPart(mixedBoundary));\n }\n\n for (const attachment of fileAttachments) {\n const result3 = await attachmentPart(attachment, mixedBoundary);\n bodyParts.push(result3);\n }\n\n bodyParts.push(`--${mixedBoundary}--`);\n\n return Buffer.from([...headers, '', bodyParts.join(CRLF)].join(CRLF), 'utf-8');\n }\n}\n"]}
1
+ {"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,cAAc,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAC1F,OAAO,EAAE,cAAc,EAA2C,MAAM,WAAW,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,MAAM,IAAI,GAAG,MAAM,CAAC;AACpB,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B;;2FAE2F;AAC3F,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC;;;;0FAI0F;AAC1F,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAClC,sFAAsF;AACtF,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAEnC,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;IAC5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AI,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, TokenUidHelper, UidTokenEncodings } 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. `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\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: 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 /** 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"]}
@@ -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
@@ -0,0 +1,5 @@
1
+ /** Container keys of the server info component. */
2
+ export class ServerInfoBindingKeys {
3
+ static { this.SERVER_INFO_OPTIONS = '@app/server-info/options'; }
4
+ }
5
+ //# sourceMappingURL=keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/server-info/common/keys.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,MAAM,OAAO,qBAAqB;aAChB,wBAAmB,GAAG,0BAA0B,CAAC","sourcesContent":["/** Container keys of the server info component. */\nexport class ServerInfoBindingKeys {\n static readonly SERVER_INFO_OPTIONS = '@app/server-info/options';\n}\n"]}
@@ -0,0 +1,5 @@
1
+ /** Routes of the server info controller, relative to the configured base path. */
2
+ export declare class ServerInfoRestPaths {
3
+ static readonly TIME = "/time";
4
+ }
5
+ //# sourceMappingURL=rest-paths.d.ts.map
@@ -0,0 +1,5 @@
1
+ /** Routes of the server info controller, relative to the configured base path. */
2
+ export class ServerInfoRestPaths {
3
+ static { this.TIME = '/time'; }
4
+ }
5
+ //# sourceMappingURL=rest-paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rest-paths.js","sourceRoot":"","sources":["../../../../../src/components/server-info/common/rest-paths.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,MAAM,OAAO,mBAAmB;aACd,SAAI,GAAG,OAAO,CAAC","sourcesContent":["/** Routes of the server info controller, relative to the configured base path. */\nexport class ServerInfoRestPaths {\n static readonly TIME = '/time';\n}\n"]}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Options of `ServerInfoComponent`, bound at `ServerInfoBindingKeys.SERVER_INFO_OPTIONS`.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * import { ServerInfoBindingKeys, type BaseApplication, type IServerInfoOptions } from '@venizia/ignis';
7
+ *
8
+ * export const bindServerInfo = (application: BaseApplication) => {
9
+ * application
10
+ * .bind<IServerInfoOptions>({ key: ServerInfoBindingKeys.SERVER_INFO_OPTIONS })
11
+ * .toValue({ restOptions: { path: '/clock' } });
12
+ * };
13
+ * ```
14
+ */
15
+ export interface IServerInfoOptions {
16
+ /** Partially-filled bindings are accepted; every missing field falls back to its default. */
17
+ restOptions?: {
18
+ /**
19
+ * Base path the server info routes mount under. The routes are public by design.
20
+ *
21
+ * @default '/server/info'
22
+ */
23
+ path?: string;
24
+ };
25
+ }
26
+ /**
27
+ * Body of `GET <path>/time`. Every field comes from ONE captured instant, so they never disagree.
28
+ *
29
+ * @example
30
+ * ```json
31
+ * {
32
+ * "server": {
33
+ * "date": "2026-11-10",
34
+ * "time": "15:00:00.123",
35
+ * "epoch": 1794297600123,
36
+ * "iso": "2026-11-10T15:00:00.123+07:00"
37
+ * },
38
+ * "tz": "Asia/Ho_Chi_Minh",
39
+ * "utc": { "offset": "+07:00", "minutes": 420, "iso": "2026-11-10T08:00:00.123Z" }
40
+ * }
41
+ * ```
42
+ */
43
+ export interface IServerTime {
44
+ server: {
45
+ /** Calendar date in the server time zone, `YYYY-MM-DD`. */
46
+ date: string;
47
+ /** Wall-clock time in the server time zone, `HH:mm:ss.SSS`. */
48
+ time: string;
49
+ /** Milliseconds since 1970-01-01T00:00:00Z (`Date.now()`). Compute clock skew from this field. */
50
+ epoch: number;
51
+ /** `date`, `time` and `utc.offset` joined as ISO-8601, e.g. `2026-11-10T15:00:00.123+07:00`. */
52
+ iso: string;
53
+ };
54
+ /** IANA time zone the server process resolved, e.g. `Asia/Ho_Chi_Minh`. */
55
+ tz: string;
56
+ utc: {
57
+ /** Offset of `tz` from UTC at response time, `+07:00` style. */
58
+ offset: string;
59
+ /**
60
+ * The same offset in minutes, POSITIVE east of UTC (`420` for `+07:00`). This is the opposite
61
+ * sign of JavaScript's `Date.prototype.getTimezoneOffset()`.
62
+ */
63
+ minutes: number;
64
+ /** The same instant in UTC, ISO-8601 with milliseconds (`toISOString()`). */
65
+ iso: string;
66
+ };
67
+ }
68
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/components/server-info/common/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Options of `ServerInfoComponent`, bound at `ServerInfoBindingKeys.SERVER_INFO_OPTIONS`.\n *\n * @example\n * ```typescript\n * import { ServerInfoBindingKeys, type BaseApplication, type IServerInfoOptions } from '@venizia/ignis';\n *\n * export const bindServerInfo = (application: BaseApplication) => {\n * application\n * .bind<IServerInfoOptions>({ key: ServerInfoBindingKeys.SERVER_INFO_OPTIONS })\n * .toValue({ restOptions: { path: '/clock' } });\n * };\n * ```\n */\nexport interface IServerInfoOptions {\n /** Partially-filled bindings are accepted; every missing field falls back to its default. */\n restOptions?: {\n /**\n * Base path the server info routes mount under. The routes are public by design.\n *\n * @default '/server/info'\n */\n path?: string;\n };\n}\n\n/**\n * Body of `GET <path>/time`. Every field comes from ONE captured instant, so they never disagree.\n *\n * @example\n * ```json\n * {\n * \"server\": {\n * \"date\": \"2026-11-10\",\n * \"time\": \"15:00:00.123\",\n * \"epoch\": 1794297600123,\n * \"iso\": \"2026-11-10T15:00:00.123+07:00\"\n * },\n * \"tz\": \"Asia/Ho_Chi_Minh\",\n * \"utc\": { \"offset\": \"+07:00\", \"minutes\": 420, \"iso\": \"2026-11-10T08:00:00.123Z\" }\n * }\n * ```\n */\nexport interface IServerTime {\n server: {\n /** Calendar date in the server time zone, `YYYY-MM-DD`. */\n date: string;\n /** Wall-clock time in the server time zone, `HH:mm:ss.SSS`. */\n time: string;\n /** Milliseconds since 1970-01-01T00:00:00Z (`Date.now()`). Compute clock skew from this field. */\n epoch: number;\n /** `date`, `time` and `utc.offset` joined as ISO-8601, e.g. `2026-11-10T15:00:00.123+07:00`. */\n iso: string;\n };\n /** IANA time zone the server process resolved, e.g. `Asia/Ho_Chi_Minh`. */\n tz: string;\n utc: {\n /** Offset of `tz` from UTC at response time, `+07:00` style. */\n offset: string;\n /**\n * The same offset in minutes, POSITIVE east of UTC (`420` for `+07:00`). This is the opposite\n * sign of JavaScript's `Date.prototype.getTimezoneOffset()`.\n */\n minutes: number;\n /** The same instant in UTC, ISO-8601 with milliseconds (`toISOString()`). */\n iso: string;\n };\n}\n"]}