@ultimat3/mail 31.31.0 → 31.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/mail",
3
- "version": "31.31.0",
3
+ "version": "31.33.0",
4
4
  "description": "Transactional email as data: one template renders HTML and text, sent through a job.",
5
5
  "keywords": [
6
6
  "ultimate",
@@ -44,11 +44,11 @@
44
44
  "test": "bun test"
45
45
  },
46
46
  "dependencies": {
47
- "@ultimat3/core": "31.31.0",
48
- "@ultimat3/i18n": "31.31.0",
49
- "@ultimat3/jobs": "31.31.0",
50
- "@ultimat3/schema": "31.31.0",
51
- "@ultimat3/storage": "31.31.0",
52
- "@ultimat3/time": "31.31.0"
47
+ "@ultimat3/core": "31.33.0",
48
+ "@ultimat3/i18n": "31.33.0",
49
+ "@ultimat3/jobs": "31.33.0",
50
+ "@ultimat3/schema": "31.33.0",
51
+ "@ultimat3/storage": "31.33.0",
52
+ "@ultimat3/time": "31.33.0"
53
53
  }
54
54
  }
package/src/driver-env.ts CHANGED
@@ -1,8 +1,9 @@
1
- // Single responsibility: environment → transport. The one place that decides which `MailDriver`
2
- // a boot installs, so `x dev`, a worker container and any custom host all resolve it identically.
3
- // The two production transports are useless until something constructs them from a credential;
4
- // this is that something, and it is keyed on env rather than a config field so the same image
5
- // deploys to every environment.
1
+ // Single responsibility: environment → transport. The one place that decides which `MailDriver` a
2
+ // boot installs, so `x dev`, a worker container and any custom host all resolve it identically.
3
+ //
4
+ // The two production transports are useless until something constructs them from a credential; this
5
+ // is that something, and it is keyed on env rather than a config field so the same image deploys to
6
+ // every environment.
6
7
 
7
8
  import { ConfigInvalidError, isLocal, resolveEnvironment } from '@ultimat3/core';
8
9
  import { type MailDriver, memoryMailDriver, unconfiguredMailDriver } from './driver';
@@ -13,6 +13,7 @@ import {
13
13
  isRetryableStatus,
14
14
  logger,
15
15
  nanoid,
16
+ renderFixShellArg,
16
17
  renderThrowable,
17
18
  } from '@ultimat3/core';
18
19
  import { outboundResponse } from '@ultimat3/core/outbound';
@@ -192,7 +193,7 @@ export function resendMailDriver(options: ResendDriverOptions): MailDriver {
192
193
  stage: 'request',
193
194
  detail: `${reason} — nothing left this host for ${baseUrl}/emails (egress, DNS or TLS)`,
194
195
  retryable: true,
195
- fix: `curl -sS -m 5 -o /dev/null ${baseUrl}/emails`,
196
+ fix: `curl -sS -m 5 -o /dev/null ${renderFixShellArg(`${baseUrl}/emails`, '<RESEND_BASE_URL>/emails')}`,
196
197
  });
197
198
  }
198
199
 
@@ -184,7 +184,8 @@ export function smtpMailDriver(options: SmtpDriverOptions): MailDriver {
184
184
  const dial: SmtpTarget = { host: target.host, port: target.port, tls: target.tls, timeoutMs };
185
185
  // `smtps://` is encrypted from the first byte; a submission port has to be told to upgrade, or
186
186
  // the probe named in the fix lines below opens a socket and then waits forever for a handshake.
187
- const starttls = target.tls ? '' : ' -starttls smtp';
187
+ // Screened once: both probe fixes below splice it, and a fix is pasted into a shell.
188
+ const endpoint = renderFixShellArg(`${target.host}:${String(target.port)}`, '<SMTP host>:<port>');
188
189
 
189
190
  return {
190
191
  name: 'smtp',
@@ -215,7 +216,9 @@ export function smtpMailDriver(options: SmtpDriverOptions): MailDriver {
215
216
  stage: 'connect',
216
217
  detail: `${target.host}:${target.port}, from SMTP_URL in .env — ${messageOf(error)}`,
217
218
  retryable: true,
218
- fix: `openssl s_client${starttls} -connect ${target.host}:${target.port}`,
219
+ fix: target.tls
220
+ ? `openssl s_client -connect ${endpoint}`
221
+ : `openssl s_client -starttls smtp -connect ${endpoint}`,
219
222
  });
220
223
  });
221
224
 
@@ -236,7 +239,9 @@ export function smtpMailDriver(options: SmtpDriverOptions): MailDriver {
236
239
  stage: 'data',
237
240
  detail: `${messageOf(error)} — the mail log on ${target.host} records why it dropped this`,
238
241
  retryable: true,
239
- fix: `openssl s_client -crlf${starttls} -connect ${target.host}:${target.port}`,
242
+ fix: target.tls
243
+ ? `openssl s_client -crlf -connect ${endpoint}`
244
+ : `openssl s_client -crlf -starttls smtp -connect ${endpoint}`,
240
245
  });
241
246
  } finally {
242
247
  stream.close();
package/src/driver.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  // Single responsibility: the transport seam. One `MailDriver` interface, the two local
2
- // implementations (memory + log), and a module-level ambient driver so `send()` never knows
3
- // which one is installed. The two production transports live in `driver-smtp.ts` and
4
- // `driver-resend.ts`; swapping one for the other is an `app.config.ts` line and zero template
5
- // changes.
2
+ // implementations (memory + log), and a module-level ambient driver so `send()` never knows which
3
+ // one is installed.
4
+ //
5
+ // The two production transports live in `driver-smtp.ts` and `driver-resend.ts`; swapping one for
6
+ // the other is an `app.config.ts` line and zero template changes.
6
7
 
7
8
  import {
8
9
  type Clock,
@@ -224,6 +225,7 @@ export function logMailDriver(logger = rootLogger): MailDriver {
224
225
  name: 'log',
225
226
  send(message: MailMessage): Promise<SendResult> {
226
227
  const result = resultFor('log', message, `log_${nanoid(12)}`);
228
+ // info: the log driver delivers BY logging: this line is the message the developer reads instead of an inbox.
227
229
  logger.info('mail.send', {
228
230
  mailId: message.mailId,
229
231
  to: message.to.length,
@@ -1,8 +1,9 @@
1
- // Single responsibility: what may appear inside an SMTP `MAIL FROM:<>` or `RCPT TO:<>`. One gate
2
- // for the envelope, exactly as `mime.ts`'s `header()` is the one gate for the message — two wire
3
- // formats, one check each, at the module that owns the format. It refuses, and it normalises one
4
- // thing only — the RFC 5322 display form down to the mailbox `RCPT TO:` can carry, always after
5
- // the control-character check, never before it.
1
+ // Single responsibility: what may appear inside an SMTP `MAIL FROM:<>` or `RCPT TO:<>`.
2
+ //
3
+ // One gate for the envelope, exactly as `mime.ts`'s `header()` is the one gate for the message —
4
+ // two wire formats, one check each, at the module that owns the format. It refuses, and it
5
+ // normalises one thing only — the RFC 5322 display form down to the mailbox `RCPT TO:` can carry,
6
+ // always after the control-character check, never before it.
6
7
 
7
8
  import { type AddressRefusal, addressInvalid, type EnvelopeAddressField } from './errors';
8
9
  import { addressSpec, hasNonAsciiAddrSpec } from './mime';
package/src/layout.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  // renderer, because email clients drop <style> and templates must never carry a raw hex.
4
4
  // Table-based and 600px wide: Outlook still renders with Word's HTML engine.
5
5
 
6
- import { escapeHtml } from '@ultimat3/core';
6
+ import { assert, escapeHtml, renderCauseValue } from '@ultimat3/core';
7
7
  import { mailLayoutDuplicate } from './errors';
8
8
  import { safeMailHref, styleAttr } from './html';
9
9
 
@@ -40,6 +40,12 @@ export const MAIL_TOKENS = Object.freeze<Record<MailToken, Readonly<Record<Color
40
40
 
41
41
  /** Resolve a token to a hex value. The only function in the package that returns a colour. */
42
42
  export function token(name: MailToken, scheme: ColorScheme = 'light'): string {
43
+ // Own keys only: a name reaching here untyped must never answer an `Object.prototype` member.
44
+ assert(
45
+ Object.hasOwn(MAIL_TOKENS, name),
46
+ `${renderCauseValue(name)} is not a mail token`,
47
+ "token('accentBg') # a key of MAIL_TOKENS",
48
+ );
43
49
  return MAIL_TOKENS[name][scheme];
44
50
  }
45
51