@nxgt/janus-mail 0.3.1 → 0.4.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/README.md +55 -11
- package/dist/generated/mail.d.ts +5 -0
- package/dist/generated/mail.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +19 -15
- package/dist/index.js.map +6 -6
- package/dist/janus-mail.d.ts +1 -0
- package/dist/janus-mail.d.ts.map +1 -1
- package/dist/notice-mails.d.ts +7 -5
- package/dist/notice-mails.d.ts.map +1 -1
- package/dist/options.d.ts.map +1 -1
- package/dist/template-types.d.ts +79 -0
- package/dist/template-types.d.ts.map +1 -0
- package/dist/templates.d.ts +1 -1
- package/dist/templates.d.ts.map +1 -1
- package/dist/types.d.ts +17 -67
- package/dist/types.d.ts.map +1 -1
- package/docs/README.md +3 -2
- package/docs/guide/building.md +1 -1
- package/docs/guide/locales.md +4 -3
- package/docs/guide/sending.md +66 -27
- package/docs/guide/templates.md +21 -14
- package/docs/roadmap.md +16 -4
- package/docs/troubleshooting.md +62 -15
- package/mails/en/email-changed.html +10 -9
- package/mails/en/password-changed.html +10 -9
- package/mails/en/reset-password.html +9 -8
- package/mails/en/sign-in-code.html +10 -9
- package/mails/en/two-factor-disabled.html +10 -9
- package/mails/en/two-factor-enabled.html +10 -9
- package/mails/en/verify-email.html +9 -8
- package/mails/en/welcome.html +50 -0
- package/mails/en/welcome.txt +19 -0
- package/mails/fr/email-changed.html +10 -9
- package/mails/fr/password-changed.html +10 -9
- package/mails/fr/reset-password.html +9 -8
- package/mails/fr/sign-in-code.html +10 -9
- package/mails/fr/two-factor-disabled.html +10 -9
- package/mails/fr/two-factor-enabled.html +10 -9
- package/mails/fr/verify-email.html +9 -8
- package/mails/fr/welcome.html +50 -0
- package/mails/fr/welcome.txt +19 -0
- package/mails/mail-manifest.json +24 -0
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
The e-mails of [`@nxgt/janus`](https://www.npmjs.com/package/@nxgt/janus)'s
|
|
4
4
|
flows, ready to send: **e-mail verification, password reset, sign-in code,
|
|
5
|
-
password changed, e-mail changed,
|
|
6
|
-
off**, in English and French, with your brand
|
|
5
|
+
password changed, e-mail changed, two-factor authentication turned on or
|
|
6
|
+
off, and a welcome to a new user**, in English and French, with your brand
|
|
7
7
|
in them. `@nxgt/janus` sends no e-mail — its flows answer what to send — and
|
|
8
8
|
this package turns that answer into an e-mail and hands it to any
|
|
9
9
|
[`@nxgt/mail`](https://www.npmjs.com/package/@nxgt/mail) transport.
|
|
@@ -20,6 +20,7 @@ const mail = janusMail({
|
|
|
20
20
|
verifyEmail: (token) => `https://acme.example/verify?token=${token}`,
|
|
21
21
|
resetPassword: (token) => `https://acme.example/reset?token=${token}`,
|
|
22
22
|
secureAccount: () => 'https://acme.example/account/security',
|
|
23
|
+
getStarted: () => 'https://acme.example/',
|
|
23
24
|
},
|
|
24
25
|
});
|
|
25
26
|
|
|
@@ -55,10 +56,10 @@ runtime. Like `@nxgt/janus`, it expects `"moduleResolution": "bundler"`.
|
|
|
55
56
|
|
|
56
57
|
| Export | What it is |
|
|
57
58
|
| --- | --- |
|
|
58
|
-
| `janusMail(options)` | The e-mails, over your mailer: `verifyEmail`, `resetPassword`, `signInCode`, `passwordChanged`, `emailChanged`, `twoFactorEnabled`, `twoFactorDisabled`, and `templates` and `locales`. Options: `mailer`, `from`, `replyTo?`, `brand`, `links` (`verifyEmail`, `resetPassword`, `secureAccount`), `locales?`, `fallbackLocale?`, `templates?`, `clock?`. A wrong option is a bare `TypeError`, thrown here |
|
|
59
|
-
| `janusTemplates()` | The
|
|
59
|
+
| `janusMail(options)` | The e-mails, over your mailer: `verifyEmail`, `resetPassword`, `signInCode`, `passwordChanged`, `emailChanged`, `twoFactorEnabled`, `twoFactorDisabled`, `welcome`, and `templates` and `locales`. Options: `mailer`, `from`, `replyTo?`, `brand`, `links` (`verifyEmail`, `resetPassword`, `secureAccount`, `getStarted`), `locales?`, `fallbackLocale?`, `templates?`, `clock?`. A wrong option is a bare `TypeError`, thrown here |
|
|
60
|
+
| `janusTemplates()` | The eight default templates alone, each `(variables & { locale }) => Rendered` |
|
|
60
61
|
| `JanusMail<L>`, `JanusMailOptions<L>` | What `janusMail()` answers and takes, for the locales `L` |
|
|
61
|
-
| `JanusMailTemplate<V, L>`, `JanusMailTemplates<L>`, `JanusMailTemplateName` | One template, the
|
|
62
|
+
| `JanusMailTemplate<V, L>`, `JanusMailTemplates<L>`, `JanusMailTemplateName` | One template, the eight of them, and their names |
|
|
62
63
|
| `JanusMailVariables` | What each template is given: `brand`, and `name`, `link`, `code`, `expiresIn` or `newEmail` as its e-mail needs |
|
|
63
64
|
| `JanusMailSendOptions` | The third argument of `verifyEmail`, `resetPassword` and `signInCode`: `{ expiresIn? }`, the expiry as text, over the one derived |
|
|
64
65
|
| `JanusMailLocale` | `'en' \| 'fr'`: the locales the defaults are built in |
|
|
@@ -81,6 +82,7 @@ imported too; see
|
|
|
81
82
|
| `emailChanged(to)` | A notice naming `to.newEmail`, with `links.secureAccount()` | `to.formerEmail` |
|
|
82
83
|
| `twoFactorEnabled(to)` | A notice: two-factor authentication was turned on, with `links.secureAccount()` | `to.email` |
|
|
83
84
|
| `twoFactorDisabled(to)` | A notice: two-factor authentication was turned off, with `links.secureAccount()` | `to.email` |
|
|
85
|
+
| `welcome(to)` | A welcome to a new user — "Welcome, Ada" — with `links.getStarted()` | `to.email` |
|
|
84
86
|
|
|
85
87
|
The three e-mails of a link or a code say how long it lasts — "This link
|
|
86
88
|
expires in 1 hour.", "Ce lien expire dans 1 heure." — from the flow's
|
|
@@ -171,6 +173,29 @@ const auth = janus({
|
|
|
171
173
|
The link is `links.secureAccount()`, the page where the user manages their
|
|
172
174
|
security settings.
|
|
173
175
|
|
|
176
|
+
### Welcoming a new user
|
|
177
|
+
|
|
178
|
+
`@nxgt/janus` sends `user.created` once `signUp` or `create` inserted the
|
|
179
|
+
user. Read the user by id, and welcome them:
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
const auth = janus({
|
|
183
|
+
...config,
|
|
184
|
+
async events(event) {
|
|
185
|
+
if (event.type === 'user.created') {
|
|
186
|
+
const user = await auth.get(event.userId);
|
|
187
|
+
await mail.welcome({ name: user.name, locale: user.locale, email: user.email });
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
The **Get started** button links to `links.getStarted()`: your home page,
|
|
194
|
+
or your sign-in page for an account someone else created. The welcome goes
|
|
195
|
+
out before the address is verified; to welcome proven addresses only, send
|
|
196
|
+
it on `user.emailVerified` instead — see
|
|
197
|
+
[Sending](docs/guide/sending.md#welcometo).
|
|
198
|
+
|
|
174
199
|
### Replacing a template
|
|
175
200
|
|
|
176
201
|
Any template can be your own function — React Email, a string, another
|
|
@@ -204,6 +229,23 @@ into an unhandled rejection and a user waiting for an e-mail that never
|
|
|
204
229
|
comes. `await` it, or hand it to a queue that retries — which is also how to
|
|
205
230
|
send after answering, as the sign-in code guide advises.
|
|
206
231
|
|
|
232
|
+
**A welcome sent from `janus({ events })` fails no sign-up.** `janus()`
|
|
233
|
+
awaits the listener, but a listener that throws is a `JANUS_EVENT_FAILED`
|
|
234
|
+
warning: the user exists, `signUp` answers, and a `MailFailure` is not
|
|
235
|
+
thrown to anyone. For a welcome that must arrive, put the event in a queue
|
|
236
|
+
that retries, and send from there.
|
|
237
|
+
|
|
238
|
+
**With open sign-up, welcome on `user.emailVerified`, not `user.created`.**
|
|
239
|
+
Whoever signs up picks both the address and the name, and the welcome
|
|
240
|
+
writes that name in its subject — "Welcome, <anything>" — so on
|
|
241
|
+
`user.created` anyone can make your brand send it to any address. Once the
|
|
242
|
+
address is proven, only its owner receives it.
|
|
243
|
+
|
|
244
|
+
**Every link is required, `getStarted` included.** `links` written for 0.3
|
|
245
|
+
has no `getStarted`: a compile error on `links`, and in JavaScript
|
|
246
|
+
`janusMail: links.getStarted must be a function`. Add it even if you never
|
|
247
|
+
send the welcome.
|
|
248
|
+
|
|
207
249
|
**`node:fs` means no edge runtime.** The default e-mails are read from the
|
|
208
250
|
package's `mails/` folder, on the first one sent. On an edge runtime, pass
|
|
209
251
|
every template yourself — or wait for the inlined build on the
|
|
@@ -231,7 +273,7 @@ and are refused with a `TypeError`; its fields (`signInCode = (variables) =>
|
|
|
231
273
|
…`) pass.
|
|
232
274
|
|
|
233
275
|
**A locale beyond `en` and `fr` needs every template.** The defaults are
|
|
234
|
-
built in those two only, so `locales: ['en', 'fr', 'de']` without all
|
|
276
|
+
built in those two only, so `locales: ['en', 'fr', 'de']` without all eight
|
|
235
277
|
templates is a compile error, and a `TypeError` in JavaScript.
|
|
236
278
|
|
|
237
279
|
**The brand is text only.** `brand: 'Acme'` is written in the header, the
|
|
@@ -289,7 +331,7 @@ The symptoms and fixes are in [troubleshooting](docs/troubleshooting.md).
|
|
|
289
331
|
|
|
290
332
|
## Type safety, counted
|
|
291
333
|
|
|
292
|
-
**Twenty-
|
|
334
|
+
**Twenty-nine plausible mistakes, twenty-nine refused at compile time.**
|
|
293
335
|
Four files hold one `@ts-expect-error` per mistake, beside the calls that
|
|
294
336
|
must keep compiling:
|
|
295
337
|
[`test/types/send-refusals.ts`](test/types/send-refusals.ts) the eight of a
|
|
@@ -299,8 +341,8 @@ of `janusMail()`'s options, 9 to 20, beside adding a language with every
|
|
|
299
341
|
template;
|
|
300
342
|
[`test/types/expiry-refusals.ts`](test/types/expiry-refusals.ts) the five of
|
|
301
343
|
the expiry and the clock, 21 to 25; and
|
|
302
|
-
[`test/types/notice-refusals.ts`](test/types/notice-refusals.ts) the
|
|
303
|
-
the two-factor notices, 26
|
|
344
|
+
[`test/types/notice-refusals.ts`](test/types/notice-refusals.ts) the four of
|
|
345
|
+
the two-factor notices and the welcome, 26 to 29:
|
|
304
346
|
|
|
305
347
|
1. A sign-in code given to `verifyEmail`: it has no token.
|
|
306
348
|
2. A one-time token given to `signInCode`: it has no code.
|
|
@@ -329,9 +371,11 @@ the two-factor notices, 26 and 27:
|
|
|
329
371
|
25. `clock` given as a function rather than `@nxgt/janus`'s `Clock`.
|
|
330
372
|
26. The user event itself given to `twoFactorDisabled`: it has neither a name nor an address.
|
|
331
373
|
27. `twoFactorEnabled` given `emailChanged`'s `formerEmail` rather than `email`.
|
|
374
|
+
28. The `user.created` event itself given to `welcome`: it has neither a name nor an address.
|
|
375
|
+
29. `links` written before the welcome, without `getStarted`.
|
|
332
376
|
|
|
333
|
-
In JavaScript, 19 to 23
|
|
334
|
-
call or the field, and 25 one from `janusMail()`.
|
|
377
|
+
In JavaScript, 19 to 23 and 26 to 28 are a `TypeError` at send time instead, naming the
|
|
378
|
+
call or the field, and 25 and 29 one from `janusMail()`.
|
|
335
379
|
|
|
336
380
|
[`test/types/variables.ts`](test/types/variables.ts) also holds
|
|
337
381
|
`JanusMailVariables` equal to the variables of the build: an e-mail that
|
package/dist/generated/mail.d.ts
CHANGED
|
@@ -38,5 +38,10 @@ export interface MailEmails {
|
|
|
38
38
|
readonly link: string;
|
|
39
39
|
readonly name: string | number;
|
|
40
40
|
};
|
|
41
|
+
"welcome": {
|
|
42
|
+
readonly brand: string | number;
|
|
43
|
+
readonly link: string;
|
|
44
|
+
readonly name: string | number;
|
|
45
|
+
};
|
|
41
46
|
}
|
|
42
47
|
//# sourceMappingURL=mail.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mail.d.ts","sourceRoot":"","sources":["../../src/generated/mail.ts"],"names":[],"mappings":"AAGA,kFAAkF;AAClF,MAAM,WAAW,UAAU;IAC1B,eAAe,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,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E;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACjH,cAAc,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAChJ,SAAS,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACtG"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* `@nxgt/janus` sends no e-mail: its flows answer what to send — a one-time
|
|
5
5
|
* token, a sign-in code, the address — and this package turns that answer
|
|
6
|
-
* into an e-mail and hands it to an `@nxgt/mail` transport.
|
|
6
|
+
* into an e-mail and hands it to an `@nxgt/mail` transport. Eight e-mails, in
|
|
7
7
|
* English and French, prebuilt with Maizzle when this package is built, and
|
|
8
8
|
* filled at send time with your brand, the recipient's name and your links.
|
|
9
9
|
* Any of them can be replaced by a function of your own.
|
package/dist/index.js
CHANGED
|
@@ -103,16 +103,17 @@ function expiringMails(options) {
|
|
|
103
103
|
// src/notice-mails.ts
|
|
104
104
|
function noticeMails(options) {
|
|
105
105
|
const { brand, links } = options;
|
|
106
|
-
const plain = (method) => async (to) => send(options, method, field(method, to, "email"), {
|
|
106
|
+
const plain = (method, target) => async (to) => send(options, method, field(method, to, "email"), {
|
|
107
107
|
brand,
|
|
108
108
|
name: field(method, to, "name"),
|
|
109
|
-
link: link(method, links
|
|
109
|
+
link: link(method, links[target](), `${target}()`),
|
|
110
110
|
locale: localeFor(options, to)
|
|
111
111
|
});
|
|
112
112
|
return {
|
|
113
|
-
passwordChanged: plain("passwordChanged"),
|
|
114
|
-
twoFactorEnabled: plain("twoFactorEnabled"),
|
|
115
|
-
twoFactorDisabled: plain("twoFactorDisabled"),
|
|
113
|
+
passwordChanged: plain("passwordChanged", "secureAccount"),
|
|
114
|
+
twoFactorEnabled: plain("twoFactorEnabled", "secureAccount"),
|
|
115
|
+
twoFactorDisabled: plain("twoFactorDisabled", "secureAccount"),
|
|
116
|
+
welcome: plain("welcome", "getStarted"),
|
|
116
117
|
async emailChanged(to) {
|
|
117
118
|
return send(options, "emailChanged", field("emailChanged", to, "formerEmail"), {
|
|
118
119
|
brand,
|
|
@@ -147,7 +148,8 @@ function janusTemplates() {
|
|
|
147
148
|
passwordChanged: ({ brand, name, link, locale }) => defaultRenderer().render("password-changed", { brand, name, link }, { locale }),
|
|
148
149
|
emailChanged: ({ brand, name, link, newEmail, locale }) => defaultRenderer().render("email-changed", { brand, name, link, newEmail }, { locale }),
|
|
149
150
|
twoFactorEnabled: ({ brand, name, link, locale }) => defaultRenderer().render("two-factor-enabled", { brand, name, link }, { locale }),
|
|
150
|
-
twoFactorDisabled: ({ brand, name, link, locale }) => defaultRenderer().render("two-factor-disabled", { brand, name, link }, { locale })
|
|
151
|
+
twoFactorDisabled: ({ brand, name, link, locale }) => defaultRenderer().render("two-factor-disabled", { brand, name, link }, { locale }),
|
|
152
|
+
welcome: ({ brand, name, link, locale }) => defaultRenderer().render("welcome", { brand, name, link }, { locale })
|
|
151
153
|
});
|
|
152
154
|
}
|
|
153
155
|
|
|
@@ -159,9 +161,15 @@ var TEMPLATE_NAMES = [
|
|
|
159
161
|
"passwordChanged",
|
|
160
162
|
"emailChanged",
|
|
161
163
|
"twoFactorEnabled",
|
|
162
|
-
"twoFactorDisabled"
|
|
164
|
+
"twoFactorDisabled",
|
|
165
|
+
"welcome"
|
|
166
|
+
];
|
|
167
|
+
var LINK_NAMES = [
|
|
168
|
+
"verifyEmail",
|
|
169
|
+
"resetPassword",
|
|
170
|
+
"secureAccount",
|
|
171
|
+
"getStarted"
|
|
163
172
|
];
|
|
164
|
-
var LINK_NAMES = ["verifyEmail", "resetPassword", "secureAccount"];
|
|
165
173
|
var SYSTEM_CLOCK = Object.freeze({ now: () => new Date });
|
|
166
174
|
function isObject(value) {
|
|
167
175
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -189,7 +197,7 @@ function checkSending(options) {
|
|
|
189
197
|
refuse("brand must be the name the e-mails show, as 'Acme'");
|
|
190
198
|
}
|
|
191
199
|
if (!isObject(links)) {
|
|
192
|
-
refuse("links must be an object, as { verifyEmail, resetPassword, secureAccount }");
|
|
200
|
+
refuse("links must be an object, as { verifyEmail, resetPassword, secureAccount, getStarted }");
|
|
193
201
|
}
|
|
194
202
|
for (const name of LINK_NAMES) {
|
|
195
203
|
if (typeof links[name] !== "function") {
|
|
@@ -262,11 +270,7 @@ function frozenAddress(address) {
|
|
|
262
270
|
return typeof address === "string" ? address : Object.freeze({ name: address.name, address: address.address });
|
|
263
271
|
}
|
|
264
272
|
function frozenLinks(links) {
|
|
265
|
-
return Object.freeze(
|
|
266
|
-
verifyEmail: links.verifyEmail.bind(links),
|
|
267
|
-
resetPassword: links.resetPassword.bind(links),
|
|
268
|
-
secureAccount: links.secureAccount.bind(links)
|
|
269
|
-
});
|
|
273
|
+
return Object.freeze(Object.fromEntries(LINK_NAMES.map((name) => [name, links[name].bind(links)])));
|
|
270
274
|
}
|
|
271
275
|
function resolveOptions(options) {
|
|
272
276
|
if (!isObject(options)) {
|
|
@@ -303,5 +307,5 @@ export {
|
|
|
303
307
|
janusTemplates
|
|
304
308
|
};
|
|
305
309
|
|
|
306
|
-
//# debugId=
|
|
310
|
+
//# debugId=D782DBFE9A92F69064756E2164756E21
|
|
307
311
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
"/**\n * `expiresIn`: how long the link or the code of an e-mail stays valid, as\n * the text the e-mail shows — \"1 hour\", \"1 heure\". Derived from the\n * `expiresAt` the flow answered and the locale the recipient gets, unless the\n * send passes its own.\n */\nimport type { Clock } from '@nxgt/janus';\n\nconst MINUTE_MS = 60_000;\nconst MINUTES_IN_HOUR = 60;\nconst MINUTES_IN_DAY = 24 * MINUTES_IN_HOUR;\n\n/**\n * A duration in the locale, in the largest unit it holds at least once:\n * rounded to the minute first — the flow set `expiresAt` a moment before the\n * send, so an hour is 59 minutes and 59 seconds by then — and then down to a\n * whole unit: 90 minutes is \"1 hour\", 36 hours \"1 day\". At 30 seconds or\n * more, the e-mail never promises more than half a minute beyond what is\n * left; under that, it says \"1 minute\".\n *\n * ```ts\n * formatExpiry(3_600_000, 'fr'); // '1 heure'\n * ```\n */\nexport function formatExpiry(ms: number, locale: string): string {\n\tconst minutes = Math.max(1, Math.round(ms / MINUTE_MS));\n\tconst [value, unit] =\n\t\tminutes >= MINUTES_IN_DAY\n\t\t\t? [Math.floor(minutes / MINUTES_IN_DAY), 'day']\n\t\t\t: minutes >= MINUTES_IN_HOUR\n\t\t\t\t? [Math.floor(minutes / MINUTES_IN_HOUR), 'hour']\n\t\t\t\t: [minutes, 'minute'];\n\treturn new Intl.NumberFormat(locale, {\n\t\tstyle: 'unit',\n\t\tunit,\n\t\tunitDisplay: 'long',\n\t}).format(value);\n}\n\n/** The per-send `expiresIn`, when one was passed, or `undefined`; a `TypeError` when it is not a string. */\nfunction passedExpiresIn(method: string, options: unknown): string | undefined {\n\tconst read =\n\t\ttypeof options === 'object' && options !== null\n\t\t\t? (options as { expiresIn?: unknown }).expiresIn\n\t\t\t: undefined;\n\tif (read !== undefined && typeof read !== 'string') {\n\t\tthrow new TypeError(`janusMail.${method}: expiresIn must be a string`);\n\t}\n\treturn read;\n}\n\n/**\n * The `expiresIn` of one send: the one passed, as is, or the time left\n * until the flow's `expiresAt` by `clock` — the one given to `janus()`, when\n * it was given to `janusMail()` too — in `locale`. A `TypeError` naming the method\n * when `expiresAt` is not a valid `Date` — a flow's answer that went through\n * JSON holds a string there — or is already past.\n */\nexport function expiresInFor(\n\tmethod: string,\n\tissued: unknown,\n\tlocale: string,\n\toptions: unknown,\n\tclock: Clock,\n): string {\n\tconst passed = passedExpiresIn(method, options);\n\tif (passed !== undefined) return passed;\n\tconst expiresAt =\n\t\ttypeof issued === 'object' && issued !== null\n\t\t\t? (issued as { expiresAt?: unknown }).expiresAt\n\t\t\t: undefined;\n\tif (!(expiresAt instanceof Date) || Number.isNaN(expiresAt.getTime())) {\n\t\tthrow new TypeError(`janusMail.${method}: expiresAt must be a Date`);\n\t}\n\tconst now = clock.now();\n\tif (!(now instanceof Date) || Number.isNaN(now.getTime())) {\n\t\tthrow new TypeError(`janusMail.${method}: clock.now() must answer a Date`);\n\t}\n\tconst left = expiresAt.getTime() - now.getTime();\n\tif (left <= 0) {\n\t\tthrow new TypeError(\n\t\t\t`janusMail.${method}: expiresAt is past — the link or code would not work`,\n\t\t);\n\t}\n\treturn formatExpiry(left, locale);\n}\n",
|
|
6
6
|
"/**\n * What every method shares: reading an argument's fields, a link, the\n * recipient's locale, and the send itself. A wrong argument is a `TypeError`\n * naming the method and the field — never its value.\n */\nimport type { Address, Rendered, SentMail, WantedLocales } from '@nxgt/mail';\nimport { pickLocale } from '@nxgt/mail';\nimport type { ResolvedOptions } from './options';\nimport type { JanusMailTemplateName, JanusMailVariables } from './types';\n\n/** A string field of an argument, or a `TypeError` naming the method and the field. */\nexport function field(method: string, value: unknown, key: string): string {\n\tconst read =\n\t\ttypeof value === 'object' && value !== null\n\t\t\t? (value as Record<string, unknown>)[key]\n\t\t\t: undefined;\n\tif (typeof read !== 'string') {\n\t\tthrow new TypeError(`janusMail.${method}: ${key} must be a string`);\n\t}\n\treturn read;\n}\n\n/**\n * What a `links` function answered, or a `TypeError` naming the method and\n * the call. Its scheme is the renderer's to check: `http(s)` and `mailto:`\n * pass, anything else is its `MailRefused`.\n */\nexport function link(method: string, value: unknown, call: string): string {\n\tif (typeof value !== 'string') {\n\t\tthrow new TypeError(\n\t\t\t`janusMail.${method}: links.${call} must answer a string`,\n\t\t);\n\t}\n\treturn value;\n}\n\n/** The locale the recipient gets: the first they want that is sent in, else the fallback. */\nexport function localeFor(options: ResolvedOptions, to: unknown): string {\n\tconst wanted =\n\t\ttypeof to === 'object' && to !== null\n\t\t\t? (to as { locale?: WantedLocales }).locale\n\t\t\t: undefined;\n\treturn pickLocale(wanted, options.locales, options.fallbackLocale);\n}\n\n/**\n * Renders one e-mail and hands it to the mailer. Only `subject`, `html` and\n * `text` are read from what the template answered: a template cannot add a\n * recipient or a header.\n */\nexport async function send<K extends JanusMailTemplateName>(\n\toptions: ResolvedOptions,\n\tname: K,\n\taddress: string,\n\tvariables: JanusMailVariables[K] & { readonly locale: string },\n): Promise<SentMail> {\n\tconst template = options.templates[name] as (\n\t\tvariables: JanusMailVariables[K] & { readonly locale: string },\n\t) => Rendered | PromiseLike<Rendered>;\n\tconst { subject, html, text }: Rendered = await template(variables);\n\tconst replyTo: { replyTo?: Address } =\n\t\toptions.replyTo === undefined ? {} : { replyTo: options.replyTo };\n\treturn options.mailer.send({\n\t\tto: address,\n\t\tfrom: options.from,\n\t\t...replyTo,\n\t\tsubject,\n\t\thtml,\n\t\ttext,\n\t});\n}\n",
|
|
7
7
|
"/**\n * The three e-mails that carry what a flow issued — a one-time link or a\n * sign-in code — and say how long it lasts: `verifyEmail`, `resetPassword`\n * and `signInCode`.\n */\nimport { expiresInFor } from './expiry';\nimport type { ResolvedOptions } from './options';\nimport { field, link, localeFor, send } from './send';\nimport type { JanusMail } from './types';\n\ntype ExpiringMails = Pick<\n\tJanusMail<string>,\n\t'verifyEmail' | 'resetPassword' | 'signInCode'\n>;\n\n/** The two e-mails of a one-time token, which link to your page with it. */\ntype LinkMailName = 'verifyEmail' | 'resetPassword';\n\n/** One e-mail of a one-time token: to `issued.email`, its link built from `issued.token`. */\nfunction linkMail(options: ResolvedOptions, name: LinkMailName) {\n\treturn async (issued: unknown, to: unknown, sendOptions?: unknown) => {\n\t\tconst token = field(name, issued, 'token');\n\t\tconst locale = localeFor(options, to);\n\t\treturn send(options, name, field(name, issued, 'email'), {\n\t\t\tbrand: options.brand,\n\t\t\tname: field(name, to, 'name'),\n\t\t\tlink: link(name, options.links[name](token), `${name}(token)`),\n\t\t\texpiresIn: expiresInFor(name, issued, locale, sendOptions, options.clock),\n\t\t\tlocale,\n\t\t});\n\t};\n}\n\n/** `verifyEmail`, `resetPassword` and `signInCode`, over the resolved options. */\nexport function expiringMails(options: ResolvedOptions): ExpiringMails {\n\treturn {\n\t\tverifyEmail: linkMail(options, 'verifyEmail'),\n\t\tresetPassword: linkMail(options, 'resetPassword'),\n\t\tasync signInCode(issued, to, sendOptions) {\n\t\t\t// `code`, `email` and `expiresAt` only: the challenge is the visitor's secret.\n\t\t\tconst locale = localeFor(options, to);\n\t\t\treturn send(options, 'signInCode', field('signInCode', issued, 'email'), {\n\t\t\t\tbrand: options.brand,\n\t\t\t\tcode: field('signInCode', issued, 'code'),\n\t\t\t\texpiresIn: expiresInFor(\n\t\t\t\t\t'signInCode',\n\t\t\t\t\tissued,\n\t\t\t\t\tlocale,\n\t\t\t\t\tsendOptions,\n\t\t\t\t\toptions.clock,\n\t\t\t\t),\n\t\t\t\tlocale,\n\t\t\t});\n\t\t},\n\t};\n}\n",
|
|
8
|
-
"/**\n * The notices of a change the user made — or someone else did
|
|
8
|
+
"/**\n * The e-mails about the account itself, sent on what happened to it rather\n * than on a flow's answer: the notices of a change the user made — or someone\n * else did — `passwordChanged`, `emailChanged`, `twoFactorEnabled` and\n * `twoFactorDisabled`, each linking to where the account is secured; and\n * `welcome`, once it was created, linking to where a new user starts.\n */\nimport type { ResolvedOptions } from './options';\nimport { field, link, localeFor, send } from './send';\nimport type { JanusMail } from './types';\n\ntype NoticeMails = Pick<\n\tJanusMail<string>,\n\t| 'passwordChanged'\n\t| 'emailChanged'\n\t| 'twoFactorEnabled'\n\t| 'twoFactorDisabled'\n\t| 'welcome'\n>;\n\n/** The e-mails that greet `to.name` at `to.email`, and link to one of `links`. */\ntype PlainNotice =\n\t| 'passwordChanged'\n\t| 'twoFactorEnabled'\n\t| 'twoFactorDisabled'\n\t| 'welcome';\n\n/** The links a plain notice may take: those called with nothing. */\ntype PlainLink = 'secureAccount' | 'getStarted';\n\n/** The notices and the welcome, over the resolved options. */\nexport function noticeMails(options: ResolvedOptions): NoticeMails {\n\tconst { brand, links } = options;\n\tconst plain =\n\t\t(method: PlainNotice, target: PlainLink) =>\n\t\t// Async, so a wrong argument rejects as the other methods' do.\n\t\tasync (to: unknown): ReturnType<NoticeMails[PlainNotice]> =>\n\t\t\tsend(options, method, field(method, to, 'email'), {\n\t\t\t\tbrand,\n\t\t\t\tname: field(method, to, 'name'),\n\t\t\t\tlink: link(method, links[target](), `${target}()`),\n\t\t\t\tlocale: localeFor(options, to),\n\t\t\t});\n\treturn {\n\t\tpasswordChanged: plain('passwordChanged', 'secureAccount'),\n\t\ttwoFactorEnabled: plain('twoFactorEnabled', 'secureAccount'),\n\t\ttwoFactorDisabled: plain('twoFactorDisabled', 'secureAccount'),\n\t\twelcome: plain('welcome', 'getStarted'),\n\t\tasync emailChanged(to) {\n\t\t\t// To the former address: the one a hijacker just took the account from.\n\t\t\treturn send(\n\t\t\t\toptions,\n\t\t\t\t'emailChanged',\n\t\t\t\tfield('emailChanged', to, 'formerEmail'),\n\t\t\t\t{\n\t\t\t\t\tbrand,\n\t\t\t\t\tname: field('emailChanged', to, 'name'),\n\t\t\t\t\tlink: link('emailChanged', links.secureAccount(), 'secureAccount()'),\n\t\t\t\t\tnewEmail: field('emailChanged', to, 'newEmail'),\n\t\t\t\t\tlocale: localeFor(options, to),\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t};\n}\n",
|
|
9
9
|
"// Generated by scripts/build-mail.ts from mails/mail-manifest.json, after\n// each build of the default e-mails. Never edited; committed.\n\n/** The locales the default e-mails are built in, the fallback locale first. */\nexport const LOCALES = ['en', 'fr'] as const;\n\n/** A locale the default e-mails are built in. */\nexport type JanusMailLocale = (typeof LOCALES)[number];\n",
|
|
10
10
|
"/**\n * Where the default e-mails are, and the one renderer that reads them.\n *\n * The package ships the built e-mails in `mails/`, beside `dist/` — not in\n * it, because the root `build.ts` removes from `dist/` every file it did not\n * write itself.\n */\nimport { fileURLToPath } from 'node:url';\nimport { createMailRenderer, type MailRenderer } from '@nxgt/mail/renderer';\nimport type { MailEmails } from './generated/mail';\n\n/**\n * The folder of the built e-mails, resolved from this module rather than from\n * the working directory, which is the consumer's.\n *\n * **This file must stay directly under `src/`.** `../mails/` is right from\n * `src/mails.ts` in the specs, and from `dist/index.js` in the tarball,\n * because the build bundles this module into the single entry\n * `dist/index.js`, one level under the package as `src/` is. Moved into a\n * subfolder, or bundled into `dist/chunks/` by a second entry point, it would\n * resolve a folder that does not exist — which the artifact spec, rendering\n * from `../dist`, would catch.\n */\nexport const MAILS_DIR = fileURLToPath(new URL('../mails/', import.meta.url));\n\nlet renderer: MailRenderer<MailEmails> | undefined;\n\n/**\n * The renderer of the default e-mails, created on first use and shared by\n * every `janusMail()` and `janusTemplates()` after it.\n *\n * Lazy, so importing the package reads nothing: an application that\n * overrides every template never opens `mails/`. The first default template\n * rendered reads the whole build once — a missing `mails/` throws there, with\n * `createMailRenderer`'s own message.\n */\nexport function defaultRenderer(): MailRenderer<MailEmails> {\n\trenderer ??= createMailRenderer<MailEmails>({ dir: MAILS_DIR });\n\treturn renderer;\n}\n",
|
|
11
|
-
"/**\n * The default templates: the prebuilt e-mails, filled by `@nxgt/mail`'s\n * renderer. Each picks from its variables exactly what its e-mail takes — the\n * renderer refuses a variable too many — so the `locale` beside them goes to\n * the renderer's options, and nowhere else.\n */\nimport type { Rendered } from '@nxgt/mail';\nimport { defaultRenderer } from './mails';\nimport type { JanusMailTemplates } from './types';\n\n/**\n * The
|
|
12
|
-
"/**\n * `janusMail()`'s options, checked once when it is called. A mistake is a\n * wiring mistake, so a bare `TypeError` naming the option — never its value —\n * thrown before anything is sent.\n */\nimport type { Clock } from '@nxgt/janus';\nimport type { Address, Mailer } from '@nxgt/mail';\nimport { LOCALES } from './generated/locales';\nimport { janusTemplates } from './templates';\nimport type {\n\tJanusMailLinks,\n\tJanusMailTemplateName,\n\tJanusMailTemplates,\n} from './types';\n\n/** The templates in the order the documentation lists them. */\nexport const TEMPLATE_NAMES: readonly JanusMailTemplateName[] = [\n\t'verifyEmail',\n\t'resetPassword',\n\t'signInCode',\n\t'passwordChanged',\n\t'emailChanged',\n\t'twoFactorEnabled',\n\t'twoFactorDisabled',\n];\n\nconst LINK_NAMES = ['verifyEmail'
|
|
13
|
-
"/**\n * `janusMail()`: the e-mails of Janus's flows, rendered by the templates and\n * handed to the mailer. It sends what a flow answered, to the address the\n * flow answered, and nothing else: no retry, no queue, no error of its own —\n * the mailer's `MailFailure` and `MailRefused` reach the caller untouched.\n */\n\nimport { expiringMails } from './expiring-mails';\nimport { noticeMails } from './notice-mails';\nimport { resolveOptions } from './options';\nimport type { JanusMail, JanusMailLocale, JanusMailOptions } from './types';\n\n/**\n * The e-mails of Janus's flows, over your mailer:\n *\n * ```ts\n * const mail = janusMail({\n * \tmailer,\n * \tfrom: 'noreply@acme.example',\n * \tbrand: 'Acme',\n * \tlinks: {\n * \t\tverifyEmail: (token) => `https://acme.example/verify?token=${token}`,\n * \t\tresetPassword: (token) => `https://acme.example/reset?token=${token}`,\n * \t\tsecureAccount: () => 'https://acme.example/account/security',\n * \t},\n * });\n *\n * await mail.verifyEmail(await auth.verifyEmail.send(user), { name: user.name, locale: user.locale });\n * ```\n *\n * Reads nothing when called: the default e-mails are read on the first one\n * sent. A wrong option is a bare `TypeError`, thrown here.\n */\nexport function janusMail<const L extends string = JanusMailLocale>(\n\toptions: JanusMailOptions<L>,\n): JanusMail<L> {\n\tconst resolved = resolveOptions(options);\n\tconst mail: JanusMail<string> = Object.freeze({\n\t\t...expiringMails(resolved),\n\t\t...noticeMails(resolved),\n\t\ttemplates: resolved.templates,\n\t\tlocales: resolved.locales,\n\t});\n\t// The one cast at the boundary: the mirror above works on `string` locales.\n\treturn mail as unknown as JanusMail<L>;\n}\n"
|
|
11
|
+
"/**\n * The default templates: the prebuilt e-mails, filled by `@nxgt/mail`'s\n * renderer. Each picks from its variables exactly what its e-mail takes — the\n * renderer refuses a variable too many — so the `locale` beside them goes to\n * the renderer's options, and nowhere else.\n */\nimport type { Rendered } from '@nxgt/mail';\nimport { defaultRenderer } from './mails';\nimport type { JanusMailTemplates } from './types';\n\n/**\n * The eight default templates, in the locales they are built in. The\n * renderer behind them is created on the first render, not here.\n *\n * ```ts\n * const defaults = janusTemplates();\n * const { subject } = await defaults.verifyEmail({ brand: 'Acme', name: 'Ada', link, locale: 'fr' });\n * ```\n *\n * A URL that is not `http:`, `https:` or `mailto:` throws `MailRefused`; a\n * missing `mails/` folder throws when the first one renders.\n */\nexport function janusTemplates(): JanusMailTemplates {\n\treturn Object.freeze({\n\t\tverifyEmail: ({ brand, name, link, expiresIn, locale }): Rendered =>\n\t\t\tdefaultRenderer().render(\n\t\t\t\t'verify-email',\n\t\t\t\t{ brand, name, link, expiresIn },\n\t\t\t\t{ locale },\n\t\t\t),\n\t\tresetPassword: ({ brand, name, link, expiresIn, locale }): Rendered =>\n\t\t\tdefaultRenderer().render(\n\t\t\t\t'reset-password',\n\t\t\t\t{ brand, name, link, expiresIn },\n\t\t\t\t{ locale },\n\t\t\t),\n\t\tsignInCode: ({ brand, code, expiresIn, locale }): Rendered =>\n\t\t\tdefaultRenderer().render(\n\t\t\t\t'sign-in-code',\n\t\t\t\t{ brand, code, expiresIn },\n\t\t\t\t{ locale },\n\t\t\t),\n\t\tpasswordChanged: ({ brand, name, link, locale }): Rendered =>\n\t\t\tdefaultRenderer().render(\n\t\t\t\t'password-changed',\n\t\t\t\t{ brand, name, link },\n\t\t\t\t{ locale },\n\t\t\t),\n\t\temailChanged: ({ brand, name, link, newEmail, locale }): Rendered =>\n\t\t\tdefaultRenderer().render(\n\t\t\t\t'email-changed',\n\t\t\t\t{ brand, name, link, newEmail },\n\t\t\t\t{ locale },\n\t\t\t),\n\t\ttwoFactorEnabled: ({ brand, name, link, locale }): Rendered =>\n\t\t\tdefaultRenderer().render(\n\t\t\t\t'two-factor-enabled',\n\t\t\t\t{ brand, name, link },\n\t\t\t\t{ locale },\n\t\t\t),\n\t\ttwoFactorDisabled: ({ brand, name, link, locale }): Rendered =>\n\t\t\tdefaultRenderer().render(\n\t\t\t\t'two-factor-disabled',\n\t\t\t\t{ brand, name, link },\n\t\t\t\t{ locale },\n\t\t\t),\n\t\twelcome: ({ brand, name, link, locale }): Rendered =>\n\t\t\tdefaultRenderer().render('welcome', { brand, name, link }, { locale }),\n\t});\n}\n",
|
|
12
|
+
"/**\n * `janusMail()`'s options, checked once when it is called. A mistake is a\n * wiring mistake, so a bare `TypeError` naming the option — never its value —\n * thrown before anything is sent.\n */\nimport type { Clock } from '@nxgt/janus';\nimport type { Address, Mailer } from '@nxgt/mail';\nimport { LOCALES } from './generated/locales';\nimport { janusTemplates } from './templates';\nimport type {\n\tJanusMailLinks,\n\tJanusMailTemplateName,\n\tJanusMailTemplates,\n} from './types';\n\n/** The templates in the order the documentation lists them. */\nexport const TEMPLATE_NAMES: readonly JanusMailTemplateName[] = [\n\t'verifyEmail',\n\t'resetPassword',\n\t'signInCode',\n\t'passwordChanged',\n\t'emailChanged',\n\t'twoFactorEnabled',\n\t'twoFactorDisabled',\n\t'welcome',\n];\n\n/** Every link of `JanusMailLinks`: checked, then copied, by these names. */\nconst LINK_NAMES = [\n\t'verifyEmail',\n\t'resetPassword',\n\t'secureAccount',\n\t'getStarted',\n] as const;\n\n/** The options once checked, with `string` for the locales: the degenericised mirror. */\nexport interface ResolvedOptions {\n\treadonly mailer: Mailer;\n\treadonly from: Address;\n\treadonly replyTo: Address | undefined;\n\treadonly brand: string;\n\treadonly links: JanusMailLinks;\n\treadonly locales: readonly string[];\n\treadonly fallbackLocale: string;\n\treadonly templates: JanusMailTemplates<string>;\n\treadonly clock: Clock;\n}\n\n/** The system clock, written here: `@nxgt/janus` is a peer for its types only. */\nconst SYSTEM_CLOCK: Clock = Object.freeze({ now: () => new Date() });\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction isAddress(value: unknown): value is Address {\n\tif (typeof value === 'string') return value.trim() !== '';\n\treturn (\n\t\tisObject(value) &&\n\t\ttypeof value.name === 'string' &&\n\t\ttypeof value.address === 'string' &&\n\t\tvalue.address.trim() !== ''\n\t);\n}\n\nfunction refuse(message: string): never {\n\tthrow new TypeError(`janusMail: ${message}`);\n}\n\n/** `mailer`, `from`, `replyTo`, `brand` and `links`. */\nfunction checkSending(options: Record<string, unknown>): void {\n\tconst { mailer, from, replyTo, brand, links } = options;\n\tif (!isObject(mailer) || typeof mailer.send !== 'function') {\n\t\trefuse('mailer must be a Mailer — an object with a send function');\n\t}\n\tif (!isAddress(from)) {\n\t\trefuse(\n\t\t\t\"from must be an address, as 'noreply@example.com' or { name, address }\",\n\t\t);\n\t}\n\tif (replyTo !== undefined && !isAddress(replyTo)) {\n\t\trefuse(\n\t\t\t\"replyTo must be an address, as 'support@example.com' or { name, address }\",\n\t\t);\n\t}\n\tif (typeof brand !== 'string' || brand.trim() === '') {\n\t\trefuse(\"brand must be the name the e-mails show, as 'Acme'\");\n\t}\n\tif (!isObject(links)) {\n\t\trefuse(\n\t\t\t'links must be an object, as { verifyEmail, resetPassword, secureAccount, getStarted }',\n\t\t);\n\t}\n\tfor (const name of LINK_NAMES) {\n\t\tif (typeof links[name] !== 'function') {\n\t\t\trefuse(`links.${name} must be a function`);\n\t\t}\n\t}\n}\n\n/** `clock`, bound to the caller's object, or the system clock. */\nfunction resolveClock(clock: unknown): Clock {\n\tif (clock === undefined) return SYSTEM_CLOCK;\n\tif (!isObject(clock) || typeof clock.now !== 'function') {\n\t\trefuse('clock must be a Clock — an object with a now function');\n\t}\n\treturn Object.freeze({ now: (clock.now as () => Date).bind(clock) });\n}\n\n/** Whether `Intl` takes the locale — the expiry is formatted in it — as `fr-CA`, not `fr_CA`. */\nfunction isLanguageTag(locale: string): boolean {\n\ttry {\n\t\tIntl.getCanonicalLocales(locale);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/** `locales` and `fallbackLocale`, with their defaults. */\nfunction resolveLocales(options: Record<string, unknown>): {\n\tlocales: readonly string[];\n\tfallbackLocale: string;\n} {\n\tconst wanted = options.locales ?? LOCALES;\n\tif (\n\t\t!Array.isArray(wanted) ||\n\t\twanted.length === 0 ||\n\t\t!wanted.every((locale) => typeof locale === 'string' && locale !== '')\n\t) {\n\t\trefuse(\"locales must list at least one locale, as ['en', 'fr']\");\n\t}\n\tconst locales: readonly string[] = Object.freeze([...wanted]);\n\tif (!locales.every(isLanguageTag)) {\n\t\trefuse(\"locales must be BCP 47 language tags, as 'fr-CA'\");\n\t}\n\tif (new Set(locales).size !== locales.length) {\n\t\trefuse('locales holds the same locale twice');\n\t}\n\tconst fallbackLocale =\n\t\toptions.fallbackLocale ??\n\t\t(locales.includes('en') ? 'en' : (locales[0] as string));\n\tif (typeof fallbackLocale !== 'string' || !locales.includes(fallbackLocale)) {\n\t\trefuse('fallbackLocale must be one of locales');\n\t}\n\treturn { locales, fallbackLocale };\n}\n\n/** `templates` over the defaults — the defaults only while every locale is built. */\nfunction resolveTemplates(\n\toptions: Record<string, unknown>,\n\tlocales: readonly string[],\n): JanusMailTemplates<string> {\n\tconst given = options.templates ?? {};\n\tif (!isObject(given)) {\n\t\trefuse(\n\t\t\t'templates must be an object of functions, as { verifyEmail: (variables) => rendered }',\n\t\t);\n\t}\n\tfor (const [name, template] of Object.entries(given)) {\n\t\tif (!(TEMPLATE_NAMES as readonly string[]).includes(name)) {\n\t\t\trefuse(\n\t\t\t\t`templates has no template ${name} — name one of ${TEMPLATE_NAMES.join(', ')}`,\n\t\t\t);\n\t\t}\n\t\tif (typeof template !== 'function') {\n\t\t\trefuse(`templates.${name} must be a function`);\n\t\t}\n\t}\n\t// Own enumerable keys, the ones the spread below copies. A template on a\n\t// prototype — a class instance's method — or an own property that is not\n\t// enumerable would be dropped without a word, the default sent in its\n\t// place: `in` sees it and `passed` does not, so it is refused instead.\n\tconst passed = Object.keys(given);\n\tfor (const name of TEMPLATE_NAMES) {\n\t\tif (name in given && !passed.includes(name)) {\n\t\t\trefuse(\n\t\t\t\t`templates.${name} is not an own enumerable property — pass a plain object, as { ${name}: (variables) => rendered }`,\n\t\t\t);\n\t\t}\n\t}\n\tconst built = locales.every((locale) =>\n\t\t(LOCALES as readonly string[]).includes(locale),\n\t);\n\tconst missing = TEMPLATE_NAMES.filter((name) => !passed.includes(name));\n\tif (!built && missing.length > 0) {\n\t\trefuse(\n\t\t\t`the default templates are built in ${LOCALES.join(' and ')} only — with another ` +\n\t\t\t\t`locale in locales, pass every template in templates; ${missing.join(', ')} missing`,\n\t\t);\n\t}\n\t// The one cast: a default template takes a built locale only, and the check\n\t// above proves every locale is one whenever a default is kept.\n\tconst defaults = janusTemplates() as unknown as JanusMailTemplates<string>;\n\treturn Object.freeze({ ...defaults, ...given }) as JanusMailTemplates<string>;\n}\n\n/** A frozen copy of a checked address: a later change to the caller's object is not seen. */\nfunction frozenAddress(address: Address): Address {\n\treturn typeof address === 'string'\n\t\t? address\n\t\t: Object.freeze({ name: address.name, address: address.address });\n}\n\n/**\n * A frozen copy of the checked links, each bound to the caller's object — a\n * class instance's methods keep their `this` — so replacing a link after\n * `janusMail()` cannot undo the check.\n */\nfunction frozenLinks(links: JanusMailLinks): JanusMailLinks {\n\t// LINK_NAMES is every key of JanusMailLinks, each checked a function.\n\treturn Object.freeze(\n\t\tObject.fromEntries(\n\t\t\tLINK_NAMES.map((name) => [name, links[name].bind(links)]),\n\t\t),\n\t) as unknown as JanusMailLinks;\n}\n\n/**\n * Checks `janusMail()`'s options and answers them resolved, or throws a\n * `TypeError`. What was checked is copied and frozen, so the guarantee made\n * here holds at every send.\n */\nexport function resolveOptions(options: unknown): ResolvedOptions {\n\tif (!isObject(options)) {\n\t\trefuse('options must be an object, as { mailer, from, brand, links }');\n\t}\n\tcheckSending(options);\n\tconst { locales, fallbackLocale } = resolveLocales(options);\n\treturn Object.freeze({\n\t\tmailer: options.mailer as Mailer,\n\t\tfrom: frozenAddress(options.from as Address),\n\t\treplyTo:\n\t\t\toptions.replyTo === undefined\n\t\t\t\t? undefined\n\t\t\t\t: frozenAddress(options.replyTo as Address),\n\t\tbrand: options.brand as string,\n\t\tlinks: frozenLinks(options.links as unknown as JanusMailLinks),\n\t\tlocales,\n\t\tfallbackLocale,\n\t\ttemplates: resolveTemplates(options, locales),\n\t\tclock: resolveClock(options.clock),\n\t});\n}\n",
|
|
13
|
+
"/**\n * `janusMail()`: the e-mails of Janus's flows, rendered by the templates and\n * handed to the mailer. It sends what a flow answered, to the address the\n * flow answered, and nothing else: no retry, no queue, no error of its own —\n * the mailer's `MailFailure` and `MailRefused` reach the caller untouched.\n */\n\nimport { expiringMails } from './expiring-mails';\nimport { noticeMails } from './notice-mails';\nimport { resolveOptions } from './options';\nimport type { JanusMail, JanusMailLocale, JanusMailOptions } from './types';\n\n/**\n * The e-mails of Janus's flows, over your mailer:\n *\n * ```ts\n * const mail = janusMail({\n * \tmailer,\n * \tfrom: 'noreply@acme.example',\n * \tbrand: 'Acme',\n * \tlinks: {\n * \t\tverifyEmail: (token) => `https://acme.example/verify?token=${token}`,\n * \t\tresetPassword: (token) => `https://acme.example/reset?token=${token}`,\n * \t\tsecureAccount: () => 'https://acme.example/account/security',\n * \t\tgetStarted: () => 'https://acme.example/',\n * \t},\n * });\n *\n * await mail.verifyEmail(await auth.verifyEmail.send(user), { name: user.name, locale: user.locale });\n * ```\n *\n * Reads nothing when called: the default e-mails are read on the first one\n * sent. A wrong option is a bare `TypeError`, thrown here.\n */\nexport function janusMail<const L extends string = JanusMailLocale>(\n\toptions: JanusMailOptions<L>,\n): JanusMail<L> {\n\tconst resolved = resolveOptions(options);\n\tconst mail: JanusMail<string> = Object.freeze({\n\t\t...expiringMails(resolved),\n\t\t...noticeMails(resolved),\n\t\ttemplates: resolved.templates,\n\t\tlocales: resolved.locales,\n\t});\n\t// The one cast at the boundary: the mirror above works on `string` locales.\n\treturn mail as unknown as JanusMail<L>;\n}\n"
|
|
14
14
|
],
|
|
15
|
-
"mappings": ";AAQA,IAAM,YAAY;AAClB,IAAM,kBAAkB;AACxB,IAAM,iBAAiB,KAAK;AAcrB,SAAS,YAAY,CAAC,IAAY,QAAwB;AAAA,EAChE,MAAM,UAAU,KAAK,IAAI,GAAG,KAAK,MAAM,KAAK,SAAS,CAAC;AAAA,EACtD,OAAO,OAAO,QACb,WAAW,iBACR,CAAC,KAAK,MAAM,UAAU,cAAc,GAAG,KAAK,IAC5C,WAAW,kBACV,CAAC,KAAK,MAAM,UAAU,eAAe,GAAG,MAAM,IAC9C,CAAC,SAAS,QAAQ;AAAA,EACvB,OAAO,IAAI,KAAK,aAAa,QAAQ;AAAA,IACpC,OAAO;AAAA,IACP;AAAA,IACA,aAAa;AAAA,EACd,CAAC,EAAE,OAAO,KAAK;AAAA;AAIhB,SAAS,eAAe,CAAC,QAAgB,SAAsC;AAAA,EAC9E,MAAM,OACL,OAAO,YAAY,YAAY,YAAY,OACvC,QAAoC,YACrC;AAAA,EACJ,IAAI,SAAS,aAAa,OAAO,SAAS,UAAU;AAAA,IACnD,MAAM,IAAI,UAAU,aAAa,oCAAoC;AAAA,EACtE;AAAA,EACA,OAAO;AAAA;AAUD,SAAS,YAAY,CAC3B,QACA,QACA,QACA,SACA,OACS;AAAA,EACT,MAAM,SAAS,gBAAgB,QAAQ,OAAO;AAAA,EAC9C,IAAI,WAAW;AAAA,IAAW,OAAO;AAAA,EACjC,MAAM,YACL,OAAO,WAAW,YAAY,WAAW,OACr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AO,OAAO;AAAA,OAC1C,cAAc,QAAQ;AAAA,OACtB,YAAY,QAAQ;AAAA,IACvB,WAAW,SAAS;AAAA,IACpB,SAAS,SAAS;AAAA,EACnB,CAAC;AAAA,EAED,OAAO;AAAA;",
|
|
16
|
+
"debugId": "D782DBFE9A92F69064756E2164756E21",
|
|
17
17
|
"names": []
|
|
18
18
|
}
|
package/dist/janus-mail.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ import type { JanusMail, JanusMailLocale, JanusMailOptions } from './types';
|
|
|
17
17
|
* verifyEmail: (token) => `https://acme.example/verify?token=${token}`,
|
|
18
18
|
* resetPassword: (token) => `https://acme.example/reset?token=${token}`,
|
|
19
19
|
* secureAccount: () => 'https://acme.example/account/security',
|
|
20
|
+
* getStarted: () => 'https://acme.example/',
|
|
20
21
|
* },
|
|
21
22
|
* });
|
|
22
23
|
*
|
package/dist/janus-mail.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"janus-mail.d.ts","sourceRoot":"","sources":["../src/janus-mail.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE5E
|
|
1
|
+
{"version":3,"file":"janus-mail.d.ts","sourceRoot":"","sources":["../src/janus-mail.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,SAAS,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,GAAG,eAAe,EACjE,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAC1B,SAAS,CAAC,CAAC,CAAC,CAUd"}
|
package/dist/notice-mails.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* The e-mails about the account itself, sent on what happened to it rather
|
|
3
|
+
* than on a flow's answer: the notices of a change the user made — or someone
|
|
4
|
+
* else did — `passwordChanged`, `emailChanged`, `twoFactorEnabled` and
|
|
5
|
+
* `twoFactorDisabled`, each linking to where the account is secured; and
|
|
6
|
+
* `welcome`, once it was created, linking to where a new user starts.
|
|
5
7
|
*/
|
|
6
8
|
import type { ResolvedOptions } from './options';
|
|
7
9
|
import type { JanusMail } from './types';
|
|
8
|
-
type NoticeMails = Pick<JanusMail<string>, 'passwordChanged' | 'emailChanged' | 'twoFactorEnabled' | 'twoFactorDisabled'>;
|
|
9
|
-
/** The notices, over the resolved options. */
|
|
10
|
+
type NoticeMails = Pick<JanusMail<string>, 'passwordChanged' | 'emailChanged' | 'twoFactorEnabled' | 'twoFactorDisabled' | 'welcome'>;
|
|
11
|
+
/** The notices and the welcome, over the resolved options. */
|
|
10
12
|
export declare function noticeMails(options: ResolvedOptions): NoticeMails;
|
|
11
13
|
export {};
|
|
12
14
|
//# sourceMappingURL=notice-mails.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notice-mails.d.ts","sourceRoot":"","sources":["../src/notice-mails.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"notice-mails.d.ts","sourceRoot":"","sources":["../src/notice-mails.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,KAAK,WAAW,GAAG,IAAI,CACtB,SAAS,CAAC,MAAM,CAAC,EACf,iBAAiB,GACjB,cAAc,GACd,kBAAkB,GAClB,mBAAmB,GACnB,SAAS,CACX,CAAC;AAYF,8DAA8D;AAC9D,wBAAgB,WAAW,CAAC,OAAO,EAAE,eAAe,GAAG,WAAW,CAiCjE"}
|
package/dist/options.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAGlD,OAAO,KAAK,EACX,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EAClB,MAAM,SAAS,CAAC;AAEjB,+DAA+D;AAC/D,eAAO,MAAM,cAAc,EAAE,SAAS,qBAAqB,
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAGlD,OAAO,KAAK,EACX,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EAClB,MAAM,SAAS,CAAC;AAEjB,+DAA+D;AAC/D,eAAO,MAAM,cAAc,EAAE,SAAS,qBAAqB,EAS1D,CAAC;AAUF,yFAAyF;AACzF,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC/C,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;CACtB;AA4KD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,eAAe,CAoBhE"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The public types of the templates, in their generic form: what each e-mail
|
|
3
|
+
* is given, and the function that renders it. Re-exported by `./types`.
|
|
4
|
+
*/
|
|
5
|
+
import type { Rendered } from '@nxgt/mail';
|
|
6
|
+
import type { JanusMailLocale } from './generated/locales';
|
|
7
|
+
/**
|
|
8
|
+
* What each e-mail's template is given, by template name. Every value is
|
|
9
|
+
* text: `brand` is the name `janusMail({ brand })` was given, `name` the
|
|
10
|
+
* recipient's, `link` an absolute URL from `links`, and `expiresIn` how long
|
|
11
|
+
* the link or the code stays valid, in the recipient's locale — "1 hour",
|
|
12
|
+
* "1 heure" — or the send's own `expiresIn`.
|
|
13
|
+
*
|
|
14
|
+
* Held equal to the build's variables by `test/types/variables.ts`: an e-mail
|
|
15
|
+
* of the build that gains or loses a variable fails the typecheck there.
|
|
16
|
+
*/
|
|
17
|
+
export interface JanusMailVariables {
|
|
18
|
+
readonly verifyEmail: {
|
|
19
|
+
readonly brand: string;
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly link: string;
|
|
22
|
+
readonly expiresIn: string;
|
|
23
|
+
};
|
|
24
|
+
readonly resetPassword: {
|
|
25
|
+
readonly brand: string;
|
|
26
|
+
readonly name: string;
|
|
27
|
+
readonly link: string;
|
|
28
|
+
readonly expiresIn: string;
|
|
29
|
+
};
|
|
30
|
+
/** No `challenge`, ever: it is the visitor's secret, and never goes in an e-mail. */
|
|
31
|
+
readonly signInCode: {
|
|
32
|
+
readonly brand: string;
|
|
33
|
+
readonly code: string;
|
|
34
|
+
readonly expiresIn: string;
|
|
35
|
+
};
|
|
36
|
+
readonly passwordChanged: {
|
|
37
|
+
readonly brand: string;
|
|
38
|
+
readonly name: string;
|
|
39
|
+
readonly link: string;
|
|
40
|
+
};
|
|
41
|
+
readonly emailChanged: {
|
|
42
|
+
readonly brand: string;
|
|
43
|
+
readonly name: string;
|
|
44
|
+
readonly link: string;
|
|
45
|
+
readonly newEmail: string;
|
|
46
|
+
};
|
|
47
|
+
readonly twoFactorEnabled: {
|
|
48
|
+
readonly brand: string;
|
|
49
|
+
readonly name: string;
|
|
50
|
+
readonly link: string;
|
|
51
|
+
};
|
|
52
|
+
readonly twoFactorDisabled: {
|
|
53
|
+
readonly brand: string;
|
|
54
|
+
readonly name: string;
|
|
55
|
+
readonly link: string;
|
|
56
|
+
};
|
|
57
|
+
/** `name` is in the subject too: "Welcome, Ada". */
|
|
58
|
+
readonly welcome: {
|
|
59
|
+
readonly brand: string;
|
|
60
|
+
readonly name: string;
|
|
61
|
+
readonly link: string;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/** The name of one of the eight templates: `verifyEmail`, `resetPassword`, … */
|
|
65
|
+
export type JanusMailTemplateName = keyof JanusMailVariables;
|
|
66
|
+
/**
|
|
67
|
+
* One e-mail: its variables and the locale picked for the recipient, in; its
|
|
68
|
+
* `subject`, `html` and `text`, out — escaping is then the function's job. A
|
|
69
|
+
* default, from the prebuilt e-mails, or yours: React Email, a string, or
|
|
70
|
+
* another Maizzle build.
|
|
71
|
+
*/
|
|
72
|
+
export type JanusMailTemplate<V, L extends string = JanusMailLocale> = (variables: V & {
|
|
73
|
+
readonly locale: L;
|
|
74
|
+
}) => Rendered | PromiseLike<Rendered>;
|
|
75
|
+
/** The eight templates, each for the locales `L`. */
|
|
76
|
+
export type JanusMailTemplates<L extends string = JanusMailLocale> = {
|
|
77
|
+
readonly [K in JanusMailTemplateName]: JanusMailTemplate<JanusMailVariables[K], L>;
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=template-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-types.d.ts","sourceRoot":"","sources":["../src/template-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,Q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AQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,QAAQ,CAAC,iBAAiB,EAAE;QAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,oDAAoD;IACpD,QAAQ,CAAC,OAAO,EAAE;QACjB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;KACtB,CAAC;CACF;AAED,gFAAgF;AAChF,MAAM,MAAM,qBAAqB,GAAG,MAAM,kBAAkB,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,eAAe,IAAI,CACtE,SAAS,EAAE,CAAC,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;CAAE,KACjC,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;AAEtC,qDAAqD;AACrD,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,GAAG,eAAe,IAAI;IACpE,QAAQ,EAAE,CAAC,IAAI,qBAAqB,GAAG,iBAAiB,CACvD,kBAAkB,CAAC,CAAC,CAAC,EACrB,CAAC,CACD;CACD,CAAC"}
|
package/dist/templates.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { JanusMailTemplates } from './types';
|
|
2
2
|
/**
|
|
3
|
-
* The
|
|
3
|
+
* The eight default templates, in the locales they are built in. The
|
|
4
4
|
* renderer behind them is created on the first render, not here.
|
|
5
5
|
*
|
|
6
6
|
* ```ts
|
package/dist/templates.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,IAAI,kBAAkB,
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,IAAI,kBAAkB,CA+CnD"}
|