@bymax-one/nest-auth 1.5.1 → 1.5.2
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/CHANGELOG.md +45 -1
- package/README.md +16 -3
- package/dist/server/index.cjs +108 -27
- package/dist/server/index.d.cts +22 -10
- package/dist/server/index.d.ts +22 -10
- package/dist/server/index.mjs +108 -27
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -18,6 +18,49 @@ what moves, and that note is the compatibility contract until strict SemVer begi
|
|
|
18
18
|
|
|
19
19
|
## [Unreleased]
|
|
20
20
|
|
|
21
|
+
## [1.5.2] - 2026-11-12
|
|
22
|
+
|
|
23
|
+
A patch release for workspaces: the bundled email provider can deliver a workspace invitation, and a
|
|
24
|
+
registration mode that could never create an account is refused at startup.
|
|
25
|
+
|
|
26
|
+
### Apply to a derived backend
|
|
27
|
+
|
|
28
|
+
- **`WorkspaceInviteData` gains a required field, `kind: 'member' | 'bootstrap'`.** The service sets it
|
|
29
|
+
from the stored invitation: `'member'` joins a workspace that exists, `'bootstrap'` is a platform
|
|
30
|
+
invitation to set up and own one that is created when the invitee accepts (its `workspaceName` names a
|
|
31
|
+
workspace that does not exist yet, and its `inviterName` is a display name the platform chose, which may
|
|
32
|
+
be empty). An implementer of `sendWorkspaceInvitation` that reads the object is unaffected; a test double
|
|
33
|
+
or a caller that builds one must add the field.
|
|
34
|
+
- **`registration: 'invitation-only'` is refused at startup unless an invitation controller is mounted.**
|
|
35
|
+
The workspace layer being on was taken for a way in, but with no invitation controller mounted no account
|
|
36
|
+
could ever be created, and OAuth acceptance rides on the workspace invitation controller, so it is no way
|
|
37
|
+
in on its own. The mode now needs `controllers.workspaceInvitations` with `workspaces.enabled`, or
|
|
38
|
+
`controllers.invitations` with `invitations.enabled`, and the error names what each path lacks. A host
|
|
39
|
+
that runs `invitation-only` with its own invitation flow and none of these controllers must mount one.
|
|
40
|
+
|
|
41
|
+
### Fixed
|
|
42
|
+
|
|
43
|
+
- **The bundled `DefaultAuthEmailProvider` implements `sendWorkspaceInvitation`.** The module refuses to
|
|
44
|
+
boot with `controllers.workspaceInvitations` on unless the provider implements it, and the default
|
|
45
|
+
provider did not, so a host that took the default could not enable workspace invitations at all. It
|
|
46
|
+
renders the invitation like the tenant one: the inviter, the workspace, a token and its expiry,
|
|
47
|
+
with sign-in or sign-up wording, the text the sender chose escaped, and the same credential flag and
|
|
48
|
+
delivery-error policy as every other message; a bootstrap invitation is worded as an invitation to set up
|
|
49
|
+
the workspace as its owner. Like the tenant invitation, it renders a **token**, not a link, because the
|
|
50
|
+
provider has no base URL: override `messages.workspaceInvitation` to send a link. A test now derives, from
|
|
51
|
+
the source, the methods a feature refuses to boot without and the optional methods of `IEmailProvider`,
|
|
52
|
+
and checks the default provider implements each.
|
|
53
|
+
|
|
54
|
+
### Maintenance
|
|
55
|
+
|
|
56
|
+
Repository tooling; nothing changes for a host. The weekly cold mutation job now fails when a unit test did not run in the mutation run
|
|
57
|
+
(`inventory: enforce`), and the exempt list gains the one spec that executes no source and was missing,
|
|
58
|
+
`src/server/conformance-well-formed.spec.ts`. The sharded run of the 1.5.1 release commit finished Stryker
|
|
59
|
+
on all four shards with no surviving and no uncovered mutant in any shard's own report, over a plan that
|
|
60
|
+
puts each of the 272 files in exactly one shard. Its aggregate job stopped on a test id that carries an
|
|
61
|
+
unformatted `it.each` placeholder, a defect of the shared workflow that was reported there, and an
|
|
62
|
+
inventory of its four reports named the missing exempt entry.
|
|
63
|
+
|
|
21
64
|
## [1.5.1] - 2026-11-11
|
|
22
65
|
|
|
23
66
|
A patch release for workspaces: it adds the way to remove an account's memberships before the host deletes
|
|
@@ -4908,7 +4951,8 @@ ever installable.
|
|
|
4908
4951
|
- Phase 4 password-reset tests cover: both `token` and `otp` flows, mutual exclusivity validation, `verifiedToken` exchange, resend cooldown, anti-enumeration (no error on unknown email), and session invalidation on reset
|
|
4909
4952
|
- Phase 5 tests cover: platform login with MFA path and brute-force lockout, `JwtPlatformGuard` cross-context rejection, `PlatformRolesGuard` hierarchy enforcement, OAuth CSRF state lifecycle, `onOAuthLogin` hook resolution strategies, and invitation role-authorization + acceptance single-use enforcement
|
|
4910
4953
|
|
|
4911
|
-
[Unreleased]: https://github.com/bymaxone/nest-auth/compare/v1.5.
|
|
4954
|
+
[Unreleased]: https://github.com/bymaxone/nest-auth/compare/v1.5.2...HEAD
|
|
4955
|
+
[1.5.2]: https://github.com/bymaxone/nest-auth/compare/v1.5.1...v1.5.2
|
|
4912
4956
|
[1.5.1]: https://github.com/bymaxone/nest-auth/compare/v1.5.0...v1.5.1
|
|
4913
4957
|
[1.5.0]: https://github.com/bymaxone/nest-auth/compare/v1.4.22...v1.5.0
|
|
4914
4958
|
[1.4.22]: https://github.com/bymaxone/nest-auth/compare/v1.4.21...v1.4.22
|
package/README.md
CHANGED
|
@@ -371,6 +371,17 @@ Email delivery is fully delegated to the consumer — the library never imports
|
|
|
371
371
|
> If you use the bundled `DefaultAuthEmailProvider` with `onDeliveryError: 'rethrow'`, the error it
|
|
372
372
|
> re-throws is the channel's original and is still yours to contain the same way.
|
|
373
373
|
|
|
374
|
+
> [!NOTE]
|
|
375
|
+
> The bundled `DefaultAuthEmailProvider` implements every method of `IEmailProvider`, the optional
|
|
376
|
+
> ones included (`sendWorkspaceInvitation` among them), so a host that takes it can enable every
|
|
377
|
+
> controller. It renders a **token**, not a link: the invitation messages say "use this token to
|
|
378
|
+
> accept: ..." and it has no base URL to build one from. To send a link, override the message,
|
|
379
|
+
> `new DefaultAuthEmailProvider(sink, { messages: { invitation, workspaceInvitation } })`, with a
|
|
380
|
+
> renderer that returns your own `html`; the escaping of caller-supplied text, the credential flag
|
|
381
|
+
> and the delivery-error policy still apply to it. A workspace invitation says whether it is for a
|
|
382
|
+
> workspace that exists (`kind: 'member'`) or a platform invitation to set one up and own it
|
|
383
|
+
> (`kind: 'bootstrap'`).
|
|
384
|
+
|
|
374
385
|
```typescript
|
|
375
386
|
// email.provider.ts
|
|
376
387
|
import { Injectable } from '@nestjs/common'
|
|
@@ -1477,7 +1488,8 @@ BymaxAuthModule.registerAsync({
|
|
|
1477
1488
|
|
|
1478
1489
|
`controllers.workspaces` mounts the routes and needs `workspaces.enabled` and both repositories.
|
|
1479
1490
|
`controllers.workspaceInvitations` also needs an email provider that implements
|
|
1480
|
-
`sendWorkspaceInvitation
|
|
1491
|
+
`sendWorkspaceInvitation`, which the bundled `DefaultAuthEmailProvider` does. The module refuses to
|
|
1492
|
+
boot when a piece is missing. With
|
|
1481
1493
|
`workspaces.enabled: false`, the default, nothing in this section exists in your application.
|
|
1482
1494
|
|
|
1483
1495
|
You implement two ports: `IWorkspaceRepository` (`createWithOwner`, `findById`, `rename`,
|
|
@@ -1505,8 +1517,9 @@ the last owner.
|
|
|
1505
1517
|
|
|
1506
1518
|
`registration: 'invitation-only'` closes sign-up except through an invitation for that exact address
|
|
1507
1519
|
(password registration and the OAuth `create` action answer `403 auth.registration_closed`; the
|
|
1508
|
-
invitation accept routes stay open; existing accounts keep signing in). Startup refuses the mode
|
|
1509
|
-
|
|
1520
|
+
invitation accept routes stay open; existing accounts keep signing in). Startup refuses the mode unless an
|
|
1521
|
+
invitation controller is mounted (`controllers.workspaceInvitations` with `workspaces.enabled`, or
|
|
1522
|
+
`controllers.invitations` with `invitations.enabled`), and names what is missing.
|
|
1510
1523
|
|
|
1511
1524
|
### Protect a route
|
|
1512
1525
|
|
package/dist/server/index.cjs
CHANGED
|
@@ -459,6 +459,41 @@ function resolveRegistration(userOptions) {
|
|
|
459
459
|
return mode;
|
|
460
460
|
}
|
|
461
461
|
__name(resolveRegistration, "resolveRegistration");
|
|
462
|
+
function assertInvitationControllers(resolved, workspaceController, tenantController) {
|
|
463
|
+
const workspacesEnabled = resolved.workspaces !== void 0;
|
|
464
|
+
if (workspaceController && !workspacesEnabled) {
|
|
465
|
+
throw new Error("[BymaxAuthModule] controllers.workspaceInvitations: true requires workspaces.enabled: true and both workspace repository providers in extraProviders.");
|
|
466
|
+
}
|
|
467
|
+
if (resolved.registration !== "invitation-only") return;
|
|
468
|
+
const workspacePath = missingPieces([
|
|
469
|
+
[
|
|
470
|
+
"workspaces.enabled",
|
|
471
|
+
workspacesEnabled
|
|
472
|
+
],
|
|
473
|
+
[
|
|
474
|
+
"controllers.workspaceInvitations",
|
|
475
|
+
workspaceController
|
|
476
|
+
]
|
|
477
|
+
]);
|
|
478
|
+
const tenantPath = missingPieces([
|
|
479
|
+
[
|
|
480
|
+
"invitations.enabled",
|
|
481
|
+
resolved.invitations.enabled
|
|
482
|
+
],
|
|
483
|
+
[
|
|
484
|
+
"controllers.invitations",
|
|
485
|
+
tenantController
|
|
486
|
+
]
|
|
487
|
+
]);
|
|
488
|
+
if (workspacePath.length > 0 && tenantPath.length > 0) {
|
|
489
|
+
throw new Error(`[BymaxAuthModule] registration: 'invitation-only' leaves no way to create an account. Enable one invitation path: workspaces (missing: ${workspacePath.join(", ")}) or tenant invitations (missing: ${tenantPath.join(", ")}).`);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
__name(assertInvitationControllers, "assertInvitationControllers");
|
|
493
|
+
function missingPieces(pieces) {
|
|
494
|
+
return pieces.filter(([, on]) => !on).map(([name]) => name);
|
|
495
|
+
}
|
|
496
|
+
__name(missingPieces, "missingPieces");
|
|
462
497
|
function resolveWorkspaceOptions(userOptions) {
|
|
463
498
|
const group = userOptions.workspaces;
|
|
464
499
|
if (group?.enabled !== true) return void 0;
|
|
@@ -17604,7 +17639,8 @@ exports.WorkspaceInvitationService = class WorkspaceInvitationService {
|
|
|
17604
17639
|
role: record.role,
|
|
17605
17640
|
inviteToken: token,
|
|
17606
17641
|
expiresAt: new Date(Date.parse(record.createdAt) + ttl * 1e3),
|
|
17607
|
-
accountExists
|
|
17642
|
+
accountExists,
|
|
17643
|
+
kind: record.kind
|
|
17608
17644
|
});
|
|
17609
17645
|
} catch (err) {
|
|
17610
17646
|
throw new Error(describeChannelStatus(err));
|
|
@@ -23805,9 +23841,7 @@ exports.BymaxAuthModule = class _BymaxAuthModule {
|
|
|
23805
23841
|
if (includeWorkspaceController && resolved.workspaces === void 0) {
|
|
23806
23842
|
throw new Error("[BymaxAuthModule] controllers.workspaces: true requires workspaces.enabled: true and both workspace repository providers in extraProviders.");
|
|
23807
23843
|
}
|
|
23808
|
-
|
|
23809
|
-
throw new Error("[BymaxAuthModule] controllers.workspaceInvitations: true requires workspaces.enabled: true and both workspace repository providers in extraProviders.");
|
|
23810
|
-
}
|
|
23844
|
+
assertInvitationControllers(resolved, includeWorkspaceInvitations, includeInvitations);
|
|
23811
23845
|
if (resolved.apiKeys.auditMode === "required" && cannotAuditApiKeys(extraProviders)) {
|
|
23812
23846
|
throw new Error("[BymaxAuthModule] apiKeys.auditMode: 'required' needs an onApiKeyRequest hook, and the BYMAX_AUTH_HOOKS provider has none. Implement it, or use auditMode: 'best-effort'.");
|
|
23813
23847
|
}
|
|
@@ -24184,29 +24218,39 @@ function authDocumentSecurity({ guard, tokenDelivery }) {
|
|
|
24184
24218
|
return Object.freeze(schemes.map(requirementFor));
|
|
24185
24219
|
}
|
|
24186
24220
|
__name(authDocumentSecurity, "authDocumentSecurity");
|
|
24187
|
-
|
|
24188
|
-
|
|
24189
|
-
"passwordResetOtp",
|
|
24190
|
-
"emailVerificationOtp",
|
|
24191
|
-
"passwordChanged",
|
|
24192
|
-
"emailChangeVerification",
|
|
24193
|
-
"emailChanged",
|
|
24194
|
-
"mfaEnabled",
|
|
24195
|
-
"mfaDisabled",
|
|
24196
|
-
"newSessionAlert",
|
|
24197
|
-
"invitation"
|
|
24198
|
-
];
|
|
24199
|
-
Object.freeze(AUTH_EMAIL_KINDS);
|
|
24200
|
-
var CREDENTIAL_BEARING_KINDS = /* @__PURE__ */ new Set([
|
|
24201
|
-
"passwordResetToken",
|
|
24202
|
-
"passwordResetOtp",
|
|
24203
|
-
"emailVerificationOtp",
|
|
24204
|
-
"emailChangeVerification",
|
|
24205
|
-
"invitation"
|
|
24206
|
-
]);
|
|
24207
|
-
var KNOWN_EMAIL_KINDS = new Set(AUTH_EMAIL_KINDS);
|
|
24221
|
+
|
|
24222
|
+
// src/server/providers/default-auth-email.messages.ts
|
|
24208
24223
|
var CODE_VALIDITY_TEXT = "It expires shortly, so use it soon.";
|
|
24209
24224
|
var UNEXPECTED_CHANGE_TEXT = "If this was not you, secure your account immediately: change your password and sign out of every session.";
|
|
24225
|
+
function hasInviter(invite) {
|
|
24226
|
+
return invite.inviterName.trim() !== "";
|
|
24227
|
+
}
|
|
24228
|
+
__name(hasInviter, "hasInviter");
|
|
24229
|
+
function workspaceInvitationSubject(invite) {
|
|
24230
|
+
if (invite.kind === "member") {
|
|
24231
|
+
return `${invite.inviterName} invited you to ${invite.workspaceName}`;
|
|
24232
|
+
}
|
|
24233
|
+
return hasInviter(invite) ? `${invite.inviterName} invited you to set up ${invite.workspaceName}` : `You have been invited to set up ${invite.workspaceName}`;
|
|
24234
|
+
}
|
|
24235
|
+
__name(workspaceInvitationSubject, "workspaceInvitationSubject");
|
|
24236
|
+
function workspaceInvitationOpening(invite) {
|
|
24237
|
+
if (invite.kind === "member") {
|
|
24238
|
+
return `${invite.inviterName} invited you to the workspace ${invite.workspaceName} as ${invite.role}.`;
|
|
24239
|
+
}
|
|
24240
|
+
const subject = hasInviter(invite) ? `${invite.inviterName} invited you` : "You have been invited";
|
|
24241
|
+
return `${subject} to set up the workspace ${invite.workspaceName} as its owner.`;
|
|
24242
|
+
}
|
|
24243
|
+
__name(workspaceInvitationOpening, "workspaceInvitationOpening");
|
|
24244
|
+
function workspaceInvitationText(invite) {
|
|
24245
|
+
const step = invite.accountExists ? "Sign in" : "Create your account";
|
|
24246
|
+
return [
|
|
24247
|
+
workspaceInvitationOpening(invite),
|
|
24248
|
+
`${step} and use this token to accept: ${invite.inviteToken}`,
|
|
24249
|
+
`It expires on ${invite.expiresAt.toISOString()}.`,
|
|
24250
|
+
"If you were not expecting this invitation, ignore this message."
|
|
24251
|
+
].join("\n\n");
|
|
24252
|
+
}
|
|
24253
|
+
__name(workspaceInvitationText, "workspaceInvitationText");
|
|
24210
24254
|
var DEFAULT_MESSAGES = {
|
|
24211
24255
|
passwordResetToken: /* @__PURE__ */ __name(({ token }) => ({
|
|
24212
24256
|
subject: "Reset your password",
|
|
@@ -24283,8 +24327,37 @@ Use this token to accept: ${invite.inviteToken}
|
|
|
24283
24327
|
It expires on ${invite.expiresAt.toISOString()}.
|
|
24284
24328
|
|
|
24285
24329
|
If you were not expecting this invitation, ignore this message.`
|
|
24286
|
-
}), "invitation")
|
|
24330
|
+
}), "invitation"),
|
|
24331
|
+
workspaceInvitation: /* @__PURE__ */ __name(({ invite }) => ({
|
|
24332
|
+
subject: workspaceInvitationSubject(invite),
|
|
24333
|
+
text: workspaceInvitationText(invite)
|
|
24334
|
+
}), "workspaceInvitation")
|
|
24287
24335
|
};
|
|
24336
|
+
|
|
24337
|
+
// src/server/providers/default-auth-email.provider.ts
|
|
24338
|
+
var AUTH_EMAIL_KINDS = [
|
|
24339
|
+
"passwordResetToken",
|
|
24340
|
+
"passwordResetOtp",
|
|
24341
|
+
"emailVerificationOtp",
|
|
24342
|
+
"passwordChanged",
|
|
24343
|
+
"emailChangeVerification",
|
|
24344
|
+
"emailChanged",
|
|
24345
|
+
"mfaEnabled",
|
|
24346
|
+
"mfaDisabled",
|
|
24347
|
+
"newSessionAlert",
|
|
24348
|
+
"invitation",
|
|
24349
|
+
"workspaceInvitation"
|
|
24350
|
+
];
|
|
24351
|
+
Object.freeze(AUTH_EMAIL_KINDS);
|
|
24352
|
+
var CREDENTIAL_BEARING_KINDS = /* @__PURE__ */ new Set([
|
|
24353
|
+
"passwordResetToken",
|
|
24354
|
+
"passwordResetOtp",
|
|
24355
|
+
"emailVerificationOtp",
|
|
24356
|
+
"emailChangeVerification",
|
|
24357
|
+
"invitation",
|
|
24358
|
+
"workspaceInvitation"
|
|
24359
|
+
]);
|
|
24360
|
+
var KNOWN_EMAIL_KINDS = new Set(AUTH_EMAIL_KINDS);
|
|
24288
24361
|
function escapeHtml(value) {
|
|
24289
24362
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
24290
24363
|
}
|
|
@@ -24311,7 +24384,7 @@ var DefaultAuthEmailProvider = class _DefaultAuthEmailProvider {
|
|
|
24311
24384
|
*
|
|
24312
24385
|
* A `Map`, not the plain object the option accepts. An object lookup walks the prototype chain,
|
|
24313
24386
|
* so `policy['toString']` answers with a function rather than `undefined` — unreachable here,
|
|
24314
|
-
* because the key is a closed union of
|
|
24387
|
+
* because the key is a closed union of literals this file writes, but "the key cannot be
|
|
24315
24388
|
* dangerous" is a property of today's call sites and not of the lookup. A `Map` has no prototype
|
|
24316
24389
|
* chain to walk, which makes it a property of the data structure instead.
|
|
24317
24390
|
*/
|
|
@@ -24437,6 +24510,14 @@ var DefaultAuthEmailProvider = class _DefaultAuthEmailProvider {
|
|
|
24437
24510
|
locale
|
|
24438
24511
|
}), "invitation");
|
|
24439
24512
|
}
|
|
24513
|
+
async sendWorkspaceInvitation(tenantId, email, data, locale) {
|
|
24514
|
+
await this.deliver(tenantId, email, this.messages.workspaceInvitation({
|
|
24515
|
+
tenantId,
|
|
24516
|
+
email,
|
|
24517
|
+
invite: data,
|
|
24518
|
+
locale
|
|
24519
|
+
}), "workspaceInvitation");
|
|
24520
|
+
}
|
|
24440
24521
|
/**
|
|
24441
24522
|
* Renders the body to HTML (unless the message already carries its own), hands the message to the
|
|
24442
24523
|
* channel, and swallows any delivery error.
|
package/dist/server/index.d.cts
CHANGED
|
@@ -707,8 +707,9 @@ declare const ANY_WORKSPACE_MEMBER: unique symbol;
|
|
|
707
707
|
* address. `POST /auth/register` and the OAuth `create` action answer `403
|
|
708
708
|
* auth.registration_closed`, the invitation accept routes stay open, and an OAuth flow started
|
|
709
709
|
* with a workspace invitation may create the account it was addressed to. Existing accounts
|
|
710
|
-
* keep signing in. Startup refuses the mode
|
|
711
|
-
*
|
|
710
|
+
* keep signing in. Startup refuses the mode unless an invitation controller is mounted
|
|
711
|
+
* (`controllers.workspaceInvitations` with `workspaces.enabled`, or `controllers.invitations`
|
|
712
|
+
* with `invitations.enabled`), since otherwise no account could ever be created.
|
|
712
713
|
*/
|
|
713
714
|
type RegistrationMode = 'open' | 'invitation-only';
|
|
714
715
|
/** A role list in which `ANY_WORKSPACE_MEMBER` stands for every active member. */
|
|
@@ -3001,6 +3002,12 @@ interface WorkspaceInviteData {
|
|
|
3001
3002
|
expiresAt: Date;
|
|
3002
3003
|
/** Whether an account already exists for the address: sign-in wording versus sign-up wording. */
|
|
3003
3004
|
accountExists: boolean;
|
|
3005
|
+
/**
|
|
3006
|
+
* `'member'` joins a workspace that exists; `'bootstrap'` is a platform invitation to own a
|
|
3007
|
+
* workspace that is created when the invitee accepts, so `workspaceName` names one that does not
|
|
3008
|
+
* exist yet and `inviterName` is a display name the platform chose, which may be empty.
|
|
3009
|
+
*/
|
|
3010
|
+
kind: 'member' | 'bootstrap';
|
|
3004
3011
|
}
|
|
3005
3012
|
/**
|
|
3006
3013
|
* Data required to render and send a tenant invitation email.
|
|
@@ -5379,6 +5386,10 @@ interface AuthEmailCatalogue {
|
|
|
5379
5386
|
invitation(input: AuthEmailContext & {
|
|
5380
5387
|
invite: InviteData;
|
|
5381
5388
|
}): AuthEmailMessage;
|
|
5389
|
+
/** Invitation to a workspace, or to set one up and own it. */
|
|
5390
|
+
workspaceInvitation(input: AuthEmailContext & {
|
|
5391
|
+
invite: WorkspaceInviteData;
|
|
5392
|
+
}): AuthEmailMessage;
|
|
5382
5393
|
}
|
|
5383
5394
|
/** How the provider reacts to a delivery failure. */
|
|
5384
5395
|
type DeliveryErrorPolicy = 'swallow' | 'rethrow';
|
|
@@ -5391,7 +5402,7 @@ type AuthEmailKind = keyof AuthEmailCatalogue;
|
|
|
5391
5402
|
* bare `'rethrow'` needs the list. Kept adjacent to {@link AuthEmailCatalogue} so the two are read
|
|
5392
5403
|
* together; a catalogue entry added without a matching entry here fails the test that compares them.
|
|
5393
5404
|
*/
|
|
5394
|
-
declare const AUTH_EMAIL_KINDS: readonly ["passwordResetToken", "passwordResetOtp", "emailVerificationOtp", "passwordChanged", "emailChangeVerification", "emailChanged", "mfaEnabled", "mfaDisabled", "newSessionAlert", "invitation"];
|
|
5405
|
+
declare const AUTH_EMAIL_KINDS: readonly ["passwordResetToken", "passwordResetOtp", "emailVerificationOtp", "passwordChanged", "emailChangeVerification", "emailChanged", "mfaEnabled", "mfaDisabled", "newSessionAlert", "invitation", "workspaceInvitation"];
|
|
5395
5406
|
/**
|
|
5396
5407
|
* A delivery-error policy chosen per message.
|
|
5397
5408
|
*
|
|
@@ -5431,9 +5442,9 @@ interface DefaultAuthEmailProviderOptions {
|
|
|
5431
5442
|
* that. `redactSecrets` is for strings you know contain the literal value. This is the one
|
|
5432
5443
|
* credential this library cannot contain on your behalf.
|
|
5433
5444
|
*
|
|
5434
|
-
* **Which is why this takes a MAP as well as a bare policy.**
|
|
5445
|
+
* **Which is why this takes a MAP as well as a bare policy.** Six messages carry a credential
|
|
5435
5446
|
* in their body, and the two flows that motivate the opt-in are two of them — so a bare
|
|
5436
|
-
* `'rethrow'` reaches
|
|
5447
|
+
* `'rethrow'` reaches four MORE credential-bearing paths than anyone asked for, on top of every
|
|
5437
5448
|
* message that carries none. Naming the flows keeps the unlaundered error where a deployment
|
|
5438
5449
|
* wanted it and leaves it off the rest:
|
|
5439
5450
|
*
|
|
@@ -5445,7 +5456,7 @@ interface DefaultAuthEmailProviderOptions {
|
|
|
5445
5456
|
*
|
|
5446
5457
|
* A message left out of the map keeps `'swallow'`, so the safe value is what you get by saying
|
|
5447
5458
|
* nothing, and widening the opt-in is always an explicit act. A bare policy still works and
|
|
5448
|
-
* still applies to
|
|
5459
|
+
* still applies to every message — it is the coarse form, kept because it is the honest way to say
|
|
5449
5460
|
* "this deployment wants the throw everywhere".
|
|
5450
5461
|
*/
|
|
5451
5462
|
readonly onDeliveryError?: DeliveryErrorPolicy | DeliveryErrorPolicyMap;
|
|
@@ -5468,7 +5479,7 @@ interface DefaultAuthEmailProviderOptions {
|
|
|
5468
5479
|
* a channel that is down would turn each into a failed request over a message that is a
|
|
5469
5480
|
* notification rather than the operation itself. The failure is logged and the flow continues.
|
|
5470
5481
|
* Setting `'rethrow'` makes EVERY method reject with the channel's original error — there is one
|
|
5471
|
-
* `deliver()` behind all
|
|
5482
|
+
* `deliver()` behind all of them and one place the policy is read, so no method is exempt. That is the
|
|
5472
5483
|
* whole point of the option and is documented with the duty it carries.
|
|
5473
5484
|
*
|
|
5474
5485
|
* The three MFA notices are the exception at the CALLER rather than here: `MfaService` sends them
|
|
@@ -5484,8 +5495,8 @@ interface DefaultAuthEmailProviderOptions {
|
|
|
5484
5495
|
* verification the recipient never got, so it cannot complete. A deployment that wants the throw
|
|
5485
5496
|
* back on those two flows names them:
|
|
5486
5497
|
* `{ onDeliveryError: { passwordResetToken: 'rethrow', emailChangeVerification: 'rethrow' } }`.
|
|
5487
|
-
* A bare `'rethrow'` also works and opts in every message.
|
|
5488
|
-
* those two flows are two of the
|
|
5498
|
+
* A bare `'rethrow'` also works and opts in every message. Six of them render a credential, and
|
|
5499
|
+
* those two flows are two of the six — so the bare form reaches four further credential-bearing
|
|
5489
5500
|
* paths, a wider trade than either flow asks for. The default optimizes for the common case: a
|
|
5490
5501
|
* transient channel outage must not fail the user's action.
|
|
5491
5502
|
*
|
|
@@ -5506,7 +5517,7 @@ declare class DefaultAuthEmailProvider implements IEmailProvider {
|
|
|
5506
5517
|
*
|
|
5507
5518
|
* A `Map`, not the plain object the option accepts. An object lookup walks the prototype chain,
|
|
5508
5519
|
* so `policy['toString']` answers with a function rather than `undefined` — unreachable here,
|
|
5509
|
-
* because the key is a closed union of
|
|
5520
|
+
* because the key is a closed union of literals this file writes, but "the key cannot be
|
|
5510
5521
|
* dangerous" is a property of today's call sites and not of the lookup. A `Map` has no prototype
|
|
5511
5522
|
* chain to walk, which makes it a property of the data structure instead.
|
|
5512
5523
|
*/
|
|
@@ -5536,6 +5547,7 @@ declare class DefaultAuthEmailProvider implements IEmailProvider {
|
|
|
5536
5547
|
sendNewSessionAlert(tenantId: string, email: string, sessionInfo: SessionAlertInfo, locale?: string): Promise<void>;
|
|
5537
5548
|
/** @inheritdoc */
|
|
5538
5549
|
sendInvitation(tenantId: string, email: string, inviteData: InviteData, locale?: string): Promise<void>;
|
|
5550
|
+
sendWorkspaceInvitation(tenantId: string, email: string, data: WorkspaceInviteData, locale?: string): Promise<void>;
|
|
5539
5551
|
/**
|
|
5540
5552
|
* Renders the body to HTML (unless the message already carries its own), hands the message to the
|
|
5541
5553
|
* channel, and swallows any delivery error.
|
package/dist/server/index.d.ts
CHANGED
|
@@ -707,8 +707,9 @@ declare const ANY_WORKSPACE_MEMBER: unique symbol;
|
|
|
707
707
|
* address. `POST /auth/register` and the OAuth `create` action answer `403
|
|
708
708
|
* auth.registration_closed`, the invitation accept routes stay open, and an OAuth flow started
|
|
709
709
|
* with a workspace invitation may create the account it was addressed to. Existing accounts
|
|
710
|
-
* keep signing in. Startup refuses the mode
|
|
711
|
-
*
|
|
710
|
+
* keep signing in. Startup refuses the mode unless an invitation controller is mounted
|
|
711
|
+
* (`controllers.workspaceInvitations` with `workspaces.enabled`, or `controllers.invitations`
|
|
712
|
+
* with `invitations.enabled`), since otherwise no account could ever be created.
|
|
712
713
|
*/
|
|
713
714
|
type RegistrationMode = 'open' | 'invitation-only';
|
|
714
715
|
/** A role list in which `ANY_WORKSPACE_MEMBER` stands for every active member. */
|
|
@@ -3001,6 +3002,12 @@ interface WorkspaceInviteData {
|
|
|
3001
3002
|
expiresAt: Date;
|
|
3002
3003
|
/** Whether an account already exists for the address: sign-in wording versus sign-up wording. */
|
|
3003
3004
|
accountExists: boolean;
|
|
3005
|
+
/**
|
|
3006
|
+
* `'member'` joins a workspace that exists; `'bootstrap'` is a platform invitation to own a
|
|
3007
|
+
* workspace that is created when the invitee accepts, so `workspaceName` names one that does not
|
|
3008
|
+
* exist yet and `inviterName` is a display name the platform chose, which may be empty.
|
|
3009
|
+
*/
|
|
3010
|
+
kind: 'member' | 'bootstrap';
|
|
3004
3011
|
}
|
|
3005
3012
|
/**
|
|
3006
3013
|
* Data required to render and send a tenant invitation email.
|
|
@@ -5379,6 +5386,10 @@ interface AuthEmailCatalogue {
|
|
|
5379
5386
|
invitation(input: AuthEmailContext & {
|
|
5380
5387
|
invite: InviteData;
|
|
5381
5388
|
}): AuthEmailMessage;
|
|
5389
|
+
/** Invitation to a workspace, or to set one up and own it. */
|
|
5390
|
+
workspaceInvitation(input: AuthEmailContext & {
|
|
5391
|
+
invite: WorkspaceInviteData;
|
|
5392
|
+
}): AuthEmailMessage;
|
|
5382
5393
|
}
|
|
5383
5394
|
/** How the provider reacts to a delivery failure. */
|
|
5384
5395
|
type DeliveryErrorPolicy = 'swallow' | 'rethrow';
|
|
@@ -5391,7 +5402,7 @@ type AuthEmailKind = keyof AuthEmailCatalogue;
|
|
|
5391
5402
|
* bare `'rethrow'` needs the list. Kept adjacent to {@link AuthEmailCatalogue} so the two are read
|
|
5392
5403
|
* together; a catalogue entry added without a matching entry here fails the test that compares them.
|
|
5393
5404
|
*/
|
|
5394
|
-
declare const AUTH_EMAIL_KINDS: readonly ["passwordResetToken", "passwordResetOtp", "emailVerificationOtp", "passwordChanged", "emailChangeVerification", "emailChanged", "mfaEnabled", "mfaDisabled", "newSessionAlert", "invitation"];
|
|
5405
|
+
declare const AUTH_EMAIL_KINDS: readonly ["passwordResetToken", "passwordResetOtp", "emailVerificationOtp", "passwordChanged", "emailChangeVerification", "emailChanged", "mfaEnabled", "mfaDisabled", "newSessionAlert", "invitation", "workspaceInvitation"];
|
|
5395
5406
|
/**
|
|
5396
5407
|
* A delivery-error policy chosen per message.
|
|
5397
5408
|
*
|
|
@@ -5431,9 +5442,9 @@ interface DefaultAuthEmailProviderOptions {
|
|
|
5431
5442
|
* that. `redactSecrets` is for strings you know contain the literal value. This is the one
|
|
5432
5443
|
* credential this library cannot contain on your behalf.
|
|
5433
5444
|
*
|
|
5434
|
-
* **Which is why this takes a MAP as well as a bare policy.**
|
|
5445
|
+
* **Which is why this takes a MAP as well as a bare policy.** Six messages carry a credential
|
|
5435
5446
|
* in their body, and the two flows that motivate the opt-in are two of them — so a bare
|
|
5436
|
-
* `'rethrow'` reaches
|
|
5447
|
+
* `'rethrow'` reaches four MORE credential-bearing paths than anyone asked for, on top of every
|
|
5437
5448
|
* message that carries none. Naming the flows keeps the unlaundered error where a deployment
|
|
5438
5449
|
* wanted it and leaves it off the rest:
|
|
5439
5450
|
*
|
|
@@ -5445,7 +5456,7 @@ interface DefaultAuthEmailProviderOptions {
|
|
|
5445
5456
|
*
|
|
5446
5457
|
* A message left out of the map keeps `'swallow'`, so the safe value is what you get by saying
|
|
5447
5458
|
* nothing, and widening the opt-in is always an explicit act. A bare policy still works and
|
|
5448
|
-
* still applies to
|
|
5459
|
+
* still applies to every message — it is the coarse form, kept because it is the honest way to say
|
|
5449
5460
|
* "this deployment wants the throw everywhere".
|
|
5450
5461
|
*/
|
|
5451
5462
|
readonly onDeliveryError?: DeliveryErrorPolicy | DeliveryErrorPolicyMap;
|
|
@@ -5468,7 +5479,7 @@ interface DefaultAuthEmailProviderOptions {
|
|
|
5468
5479
|
* a channel that is down would turn each into a failed request over a message that is a
|
|
5469
5480
|
* notification rather than the operation itself. The failure is logged and the flow continues.
|
|
5470
5481
|
* Setting `'rethrow'` makes EVERY method reject with the channel's original error — there is one
|
|
5471
|
-
* `deliver()` behind all
|
|
5482
|
+
* `deliver()` behind all of them and one place the policy is read, so no method is exempt. That is the
|
|
5472
5483
|
* whole point of the option and is documented with the duty it carries.
|
|
5473
5484
|
*
|
|
5474
5485
|
* The three MFA notices are the exception at the CALLER rather than here: `MfaService` sends them
|
|
@@ -5484,8 +5495,8 @@ interface DefaultAuthEmailProviderOptions {
|
|
|
5484
5495
|
* verification the recipient never got, so it cannot complete. A deployment that wants the throw
|
|
5485
5496
|
* back on those two flows names them:
|
|
5486
5497
|
* `{ onDeliveryError: { passwordResetToken: 'rethrow', emailChangeVerification: 'rethrow' } }`.
|
|
5487
|
-
* A bare `'rethrow'` also works and opts in every message.
|
|
5488
|
-
* those two flows are two of the
|
|
5498
|
+
* A bare `'rethrow'` also works and opts in every message. Six of them render a credential, and
|
|
5499
|
+
* those two flows are two of the six — so the bare form reaches four further credential-bearing
|
|
5489
5500
|
* paths, a wider trade than either flow asks for. The default optimizes for the common case: a
|
|
5490
5501
|
* transient channel outage must not fail the user's action.
|
|
5491
5502
|
*
|
|
@@ -5506,7 +5517,7 @@ declare class DefaultAuthEmailProvider implements IEmailProvider {
|
|
|
5506
5517
|
*
|
|
5507
5518
|
* A `Map`, not the plain object the option accepts. An object lookup walks the prototype chain,
|
|
5508
5519
|
* so `policy['toString']` answers with a function rather than `undefined` — unreachable here,
|
|
5509
|
-
* because the key is a closed union of
|
|
5520
|
+
* because the key is a closed union of literals this file writes, but "the key cannot be
|
|
5510
5521
|
* dangerous" is a property of today's call sites and not of the lookup. A `Map` has no prototype
|
|
5511
5522
|
* chain to walk, which makes it a property of the data structure instead.
|
|
5512
5523
|
*/
|
|
@@ -5536,6 +5547,7 @@ declare class DefaultAuthEmailProvider implements IEmailProvider {
|
|
|
5536
5547
|
sendNewSessionAlert(tenantId: string, email: string, sessionInfo: SessionAlertInfo, locale?: string): Promise<void>;
|
|
5537
5548
|
/** @inheritdoc */
|
|
5538
5549
|
sendInvitation(tenantId: string, email: string, inviteData: InviteData, locale?: string): Promise<void>;
|
|
5550
|
+
sendWorkspaceInvitation(tenantId: string, email: string, data: WorkspaceInviteData, locale?: string): Promise<void>;
|
|
5539
5551
|
/**
|
|
5540
5552
|
* Renders the body to HTML (unless the message already carries its own), hands the message to the
|
|
5541
5553
|
* channel, and swallows any delivery error.
|
package/dist/server/index.mjs
CHANGED
|
@@ -457,6 +457,41 @@ function resolveRegistration(userOptions) {
|
|
|
457
457
|
return mode;
|
|
458
458
|
}
|
|
459
459
|
__name(resolveRegistration, "resolveRegistration");
|
|
460
|
+
function assertInvitationControllers(resolved, workspaceController, tenantController) {
|
|
461
|
+
const workspacesEnabled = resolved.workspaces !== void 0;
|
|
462
|
+
if (workspaceController && !workspacesEnabled) {
|
|
463
|
+
throw new Error("[BymaxAuthModule] controllers.workspaceInvitations: true requires workspaces.enabled: true and both workspace repository providers in extraProviders.");
|
|
464
|
+
}
|
|
465
|
+
if (resolved.registration !== "invitation-only") return;
|
|
466
|
+
const workspacePath = missingPieces([
|
|
467
|
+
[
|
|
468
|
+
"workspaces.enabled",
|
|
469
|
+
workspacesEnabled
|
|
470
|
+
],
|
|
471
|
+
[
|
|
472
|
+
"controllers.workspaceInvitations",
|
|
473
|
+
workspaceController
|
|
474
|
+
]
|
|
475
|
+
]);
|
|
476
|
+
const tenantPath = missingPieces([
|
|
477
|
+
[
|
|
478
|
+
"invitations.enabled",
|
|
479
|
+
resolved.invitations.enabled
|
|
480
|
+
],
|
|
481
|
+
[
|
|
482
|
+
"controllers.invitations",
|
|
483
|
+
tenantController
|
|
484
|
+
]
|
|
485
|
+
]);
|
|
486
|
+
if (workspacePath.length > 0 && tenantPath.length > 0) {
|
|
487
|
+
throw new Error(`[BymaxAuthModule] registration: 'invitation-only' leaves no way to create an account. Enable one invitation path: workspaces (missing: ${workspacePath.join(", ")}) or tenant invitations (missing: ${tenantPath.join(", ")}).`);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
__name(assertInvitationControllers, "assertInvitationControllers");
|
|
491
|
+
function missingPieces(pieces) {
|
|
492
|
+
return pieces.filter(([, on]) => !on).map(([name]) => name);
|
|
493
|
+
}
|
|
494
|
+
__name(missingPieces, "missingPieces");
|
|
460
495
|
function resolveWorkspaceOptions(userOptions) {
|
|
461
496
|
const group = userOptions.workspaces;
|
|
462
497
|
if (group?.enabled !== true) return void 0;
|
|
@@ -17602,7 +17637,8 @@ var WorkspaceInvitationService = class {
|
|
|
17602
17637
|
role: record.role,
|
|
17603
17638
|
inviteToken: token,
|
|
17604
17639
|
expiresAt: new Date(Date.parse(record.createdAt) + ttl * 1e3),
|
|
17605
|
-
accountExists
|
|
17640
|
+
accountExists,
|
|
17641
|
+
kind: record.kind
|
|
17606
17642
|
});
|
|
17607
17643
|
} catch (err) {
|
|
17608
17644
|
throw new Error(describeChannelStatus(err));
|
|
@@ -23803,9 +23839,7 @@ var BymaxAuthModule = class _BymaxAuthModule {
|
|
|
23803
23839
|
if (includeWorkspaceController && resolved.workspaces === void 0) {
|
|
23804
23840
|
throw new Error("[BymaxAuthModule] controllers.workspaces: true requires workspaces.enabled: true and both workspace repository providers in extraProviders.");
|
|
23805
23841
|
}
|
|
23806
|
-
|
|
23807
|
-
throw new Error("[BymaxAuthModule] controllers.workspaceInvitations: true requires workspaces.enabled: true and both workspace repository providers in extraProviders.");
|
|
23808
|
-
}
|
|
23842
|
+
assertInvitationControllers(resolved, includeWorkspaceInvitations, includeInvitations);
|
|
23809
23843
|
if (resolved.apiKeys.auditMode === "required" && cannotAuditApiKeys(extraProviders)) {
|
|
23810
23844
|
throw new Error("[BymaxAuthModule] apiKeys.auditMode: 'required' needs an onApiKeyRequest hook, and the BYMAX_AUTH_HOOKS provider has none. Implement it, or use auditMode: 'best-effort'.");
|
|
23811
23845
|
}
|
|
@@ -24182,29 +24216,39 @@ function authDocumentSecurity({ guard, tokenDelivery }) {
|
|
|
24182
24216
|
return Object.freeze(schemes.map(requirementFor));
|
|
24183
24217
|
}
|
|
24184
24218
|
__name(authDocumentSecurity, "authDocumentSecurity");
|
|
24185
|
-
|
|
24186
|
-
|
|
24187
|
-
"passwordResetOtp",
|
|
24188
|
-
"emailVerificationOtp",
|
|
24189
|
-
"passwordChanged",
|
|
24190
|
-
"emailChangeVerification",
|
|
24191
|
-
"emailChanged",
|
|
24192
|
-
"mfaEnabled",
|
|
24193
|
-
"mfaDisabled",
|
|
24194
|
-
"newSessionAlert",
|
|
24195
|
-
"invitation"
|
|
24196
|
-
];
|
|
24197
|
-
Object.freeze(AUTH_EMAIL_KINDS);
|
|
24198
|
-
var CREDENTIAL_BEARING_KINDS = /* @__PURE__ */ new Set([
|
|
24199
|
-
"passwordResetToken",
|
|
24200
|
-
"passwordResetOtp",
|
|
24201
|
-
"emailVerificationOtp",
|
|
24202
|
-
"emailChangeVerification",
|
|
24203
|
-
"invitation"
|
|
24204
|
-
]);
|
|
24205
|
-
var KNOWN_EMAIL_KINDS = new Set(AUTH_EMAIL_KINDS);
|
|
24219
|
+
|
|
24220
|
+
// src/server/providers/default-auth-email.messages.ts
|
|
24206
24221
|
var CODE_VALIDITY_TEXT = "It expires shortly, so use it soon.";
|
|
24207
24222
|
var UNEXPECTED_CHANGE_TEXT = "If this was not you, secure your account immediately: change your password and sign out of every session.";
|
|
24223
|
+
function hasInviter(invite) {
|
|
24224
|
+
return invite.inviterName.trim() !== "";
|
|
24225
|
+
}
|
|
24226
|
+
__name(hasInviter, "hasInviter");
|
|
24227
|
+
function workspaceInvitationSubject(invite) {
|
|
24228
|
+
if (invite.kind === "member") {
|
|
24229
|
+
return `${invite.inviterName} invited you to ${invite.workspaceName}`;
|
|
24230
|
+
}
|
|
24231
|
+
return hasInviter(invite) ? `${invite.inviterName} invited you to set up ${invite.workspaceName}` : `You have been invited to set up ${invite.workspaceName}`;
|
|
24232
|
+
}
|
|
24233
|
+
__name(workspaceInvitationSubject, "workspaceInvitationSubject");
|
|
24234
|
+
function workspaceInvitationOpening(invite) {
|
|
24235
|
+
if (invite.kind === "member") {
|
|
24236
|
+
return `${invite.inviterName} invited you to the workspace ${invite.workspaceName} as ${invite.role}.`;
|
|
24237
|
+
}
|
|
24238
|
+
const subject = hasInviter(invite) ? `${invite.inviterName} invited you` : "You have been invited";
|
|
24239
|
+
return `${subject} to set up the workspace ${invite.workspaceName} as its owner.`;
|
|
24240
|
+
}
|
|
24241
|
+
__name(workspaceInvitationOpening, "workspaceInvitationOpening");
|
|
24242
|
+
function workspaceInvitationText(invite) {
|
|
24243
|
+
const step = invite.accountExists ? "Sign in" : "Create your account";
|
|
24244
|
+
return [
|
|
24245
|
+
workspaceInvitationOpening(invite),
|
|
24246
|
+
`${step} and use this token to accept: ${invite.inviteToken}`,
|
|
24247
|
+
`It expires on ${invite.expiresAt.toISOString()}.`,
|
|
24248
|
+
"If you were not expecting this invitation, ignore this message."
|
|
24249
|
+
].join("\n\n");
|
|
24250
|
+
}
|
|
24251
|
+
__name(workspaceInvitationText, "workspaceInvitationText");
|
|
24208
24252
|
var DEFAULT_MESSAGES = {
|
|
24209
24253
|
passwordResetToken: /* @__PURE__ */ __name(({ token }) => ({
|
|
24210
24254
|
subject: "Reset your password",
|
|
@@ -24281,8 +24325,37 @@ Use this token to accept: ${invite.inviteToken}
|
|
|
24281
24325
|
It expires on ${invite.expiresAt.toISOString()}.
|
|
24282
24326
|
|
|
24283
24327
|
If you were not expecting this invitation, ignore this message.`
|
|
24284
|
-
}), "invitation")
|
|
24328
|
+
}), "invitation"),
|
|
24329
|
+
workspaceInvitation: /* @__PURE__ */ __name(({ invite }) => ({
|
|
24330
|
+
subject: workspaceInvitationSubject(invite),
|
|
24331
|
+
text: workspaceInvitationText(invite)
|
|
24332
|
+
}), "workspaceInvitation")
|
|
24285
24333
|
};
|
|
24334
|
+
|
|
24335
|
+
// src/server/providers/default-auth-email.provider.ts
|
|
24336
|
+
var AUTH_EMAIL_KINDS = [
|
|
24337
|
+
"passwordResetToken",
|
|
24338
|
+
"passwordResetOtp",
|
|
24339
|
+
"emailVerificationOtp",
|
|
24340
|
+
"passwordChanged",
|
|
24341
|
+
"emailChangeVerification",
|
|
24342
|
+
"emailChanged",
|
|
24343
|
+
"mfaEnabled",
|
|
24344
|
+
"mfaDisabled",
|
|
24345
|
+
"newSessionAlert",
|
|
24346
|
+
"invitation",
|
|
24347
|
+
"workspaceInvitation"
|
|
24348
|
+
];
|
|
24349
|
+
Object.freeze(AUTH_EMAIL_KINDS);
|
|
24350
|
+
var CREDENTIAL_BEARING_KINDS = /* @__PURE__ */ new Set([
|
|
24351
|
+
"passwordResetToken",
|
|
24352
|
+
"passwordResetOtp",
|
|
24353
|
+
"emailVerificationOtp",
|
|
24354
|
+
"emailChangeVerification",
|
|
24355
|
+
"invitation",
|
|
24356
|
+
"workspaceInvitation"
|
|
24357
|
+
]);
|
|
24358
|
+
var KNOWN_EMAIL_KINDS = new Set(AUTH_EMAIL_KINDS);
|
|
24286
24359
|
function escapeHtml(value) {
|
|
24287
24360
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
24288
24361
|
}
|
|
@@ -24309,7 +24382,7 @@ var DefaultAuthEmailProvider = class _DefaultAuthEmailProvider {
|
|
|
24309
24382
|
*
|
|
24310
24383
|
* A `Map`, not the plain object the option accepts. An object lookup walks the prototype chain,
|
|
24311
24384
|
* so `policy['toString']` answers with a function rather than `undefined` — unreachable here,
|
|
24312
|
-
* because the key is a closed union of
|
|
24385
|
+
* because the key is a closed union of literals this file writes, but "the key cannot be
|
|
24313
24386
|
* dangerous" is a property of today's call sites and not of the lookup. A `Map` has no prototype
|
|
24314
24387
|
* chain to walk, which makes it a property of the data structure instead.
|
|
24315
24388
|
*/
|
|
@@ -24435,6 +24508,14 @@ var DefaultAuthEmailProvider = class _DefaultAuthEmailProvider {
|
|
|
24435
24508
|
locale
|
|
24436
24509
|
}), "invitation");
|
|
24437
24510
|
}
|
|
24511
|
+
async sendWorkspaceInvitation(tenantId, email, data, locale) {
|
|
24512
|
+
await this.deliver(tenantId, email, this.messages.workspaceInvitation({
|
|
24513
|
+
tenantId,
|
|
24514
|
+
email,
|
|
24515
|
+
invite: data,
|
|
24516
|
+
locale
|
|
24517
|
+
}), "workspaceInvitation");
|
|
24518
|
+
}
|
|
24438
24519
|
/**
|
|
24439
24520
|
* Renders the body to HTML (unless the message already carries its own), hands the message to the
|
|
24440
24521
|
* channel, and swallows any delivery error.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bymax-one/nest-auth",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "Full-stack authentication and authorization package for NestJS, React and Next.js — JWT, MFA, OAuth, sessions, multi-tenant SaaS ready",
|
|
5
5
|
"author": "Bymax One <support@bymax.one>",
|
|
6
6
|
"license": "MIT",
|