@bymax-one/nest-auth 1.3.0 → 1.3.1
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 +82 -1
- package/README.md +38 -9
- package/dist/server/index.cjs +1243 -984
- package/dist/server/index.d.cts +285 -24
- package/dist/server/index.d.ts +285 -24
- package/dist/server/index.mjs +1243 -985
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,86 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.3.1] - 2026-08-08
|
|
11
|
+
|
|
12
|
+
Adds the revocation checker and the overridable default auth-email provider, carries the tenant
|
|
13
|
+
on the email port, and refreshes the mutation figures the packaged README and CHANGELOG report.
|
|
14
|
+
All of it stays in the 1.3.x line: there are no published dependents, so nothing installed breaks.
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- **`DefaultAuthEmailProvider` is exported**, the overridable default that fills the email port so a
|
|
19
|
+
derived backend no longer hand-writes the same bridge onto its notification channel. It carries
|
|
20
|
+
the policy that should not be copied per backend: HTML escaping on a path that renders
|
|
21
|
+
caller-chosen text (an inviter's name, a tenant's name, the address an account moved to), the
|
|
22
|
+
NIST SP 800-63B notification catalogue (a password-changed notice, MFA enable/disable notices, an
|
|
23
|
+
email-changed notice to the _previous_ address), and a swallow-and-log failure policy so a down
|
|
24
|
+
channel never turns "enable MFA" into a failed request. It sends through `AuthEmailSink`, a port
|
|
25
|
+
narrow enough that the class imports no concrete mailer — `@bymax-one/nest-notification`'s
|
|
26
|
+
`EmailService` satisfies it structurally — and it consumes the tenant the email port now carries,
|
|
27
|
+
so a multi-tenant channel can attribute and route each message. Pass `messages` to override any
|
|
28
|
+
subset of the copy with a product's own wording or branding; the escaping and failure policy
|
|
29
|
+
still apply. It closes bymaxone/nest-notification#54.
|
|
30
|
+
|
|
31
|
+
- **`AuthRevocationService` is exported**, answering whether a verified access token has been
|
|
32
|
+
revoked across both channels the module writes to — the per-token blacklist a logout writes and
|
|
33
|
+
the per-user epoch a password reset or revoke-all advances. It closes bymaxone/nest-auth#92: a
|
|
34
|
+
backend bridging this library to a realtime transport can inject it and consult the same two
|
|
35
|
+
channels the HTTP guards do, instead of verifying a token's signature and granting a stream that
|
|
36
|
+
outlives every revocation window. The `JwtAuthGuard`, `WsJwtGuard` and `JwtPlatformGuard` now
|
|
37
|
+
delegate to it rather than each carrying its own copy of the two Redis reads — one source of
|
|
38
|
+
truth for the check, so a fix reaches all three and every consumer at once. No behaviour changed:
|
|
39
|
+
the guards' full suites pass unmodified.
|
|
40
|
+
|
|
41
|
+
### Changed
|
|
42
|
+
|
|
43
|
+
- **`IEmailProvider` carries the tenant on every method.** Each of the ten methods now
|
|
44
|
+
takes `tenantId: string` as its first parameter, ahead of the recipient address. A notification
|
|
45
|
+
backend serving more than one tenant could not, before this, tell which tenant a password-reset
|
|
46
|
+
or invitation email belonged to: it saw only an address, so it could not pick the right sender
|
|
47
|
+
identity, branding, locale default or audit stream. The tenant was known at every call site — a
|
|
48
|
+
dashboard user carries its own `tenantId`, and a cross-tenant platform admin is attributed to the
|
|
49
|
+
`'platform'` plane, mirroring the `pep:` epoch namespace — it simply was not being passed. It
|
|
50
|
+
closes bymaxone/nest-auth#93.
|
|
51
|
+
|
|
52
|
+
**Apply to a derived backend.** Any `IEmailProvider` implementation must add `tenantId: string`
|
|
53
|
+
as the first argument of every method it defines and route on it as its backend requires; a
|
|
54
|
+
provider that ignores tenancy can name the parameter `_tenantId` and change nothing else. The
|
|
55
|
+
bundled `NoOpEmailProvider` already conforms.
|
|
56
|
+
|
|
57
|
+
Migrate **every** method, not only the one the compiler flags. Because the added argument is a
|
|
58
|
+
`string` prepended to methods whose other arguments are also strings, a stale
|
|
59
|
+
`sendPasswordResetToken(email, token)` stays assignable to the new type — TypeScript accepts an
|
|
60
|
+
implementation with fewer parameters — so it compiles while binding `tenantId` to the recipient
|
|
61
|
+
at runtime. Only `sendInvitation`, whose second argument is an object, fails compilation. Fixing
|
|
62
|
+
that one is not proof the rest are done; the surest path is to extend the `DefaultAuthEmailProvider`
|
|
63
|
+
this release adds rather than hand-write the port.
|
|
64
|
+
|
|
65
|
+
The library has no published dependents yet, so this breaks nothing already released and ships in
|
|
66
|
+
the ordinary `1.3.x` line rather than as a major — SemVer's promise is to existing consumers, and
|
|
67
|
+
there are none to break.
|
|
68
|
+
|
|
69
|
+
- **The mutation score is re-measured rather than restated.** The last recorded run was
|
|
70
|
+
2026-07-28, before 1.1.0, 1.1.1, 1.2.0, 1.3.0 and the third security audit, and the README still
|
|
71
|
+
quoted its figures: 3,474 faults killed against 2,458 tests. A cold run on 2026-08-08 —
|
|
72
|
+
incremental baseline deleted, nothing inherited, and now covering this release's own additions —
|
|
73
|
+
puts the library at **100.00% with 4,870 mutants detected (4,849 killed, 21 timed out), no
|
|
74
|
+
survivors and none without coverage**, out of 7,718 instrumented across 147 files. The suite
|
|
75
|
+
behind it is **3,547 tests** (3,420 unit, 127 end-to-end). All five subpaths are individually at
|
|
76
|
+
100.00%.
|
|
77
|
+
|
|
78
|
+
The count of documented equivalents is now reported as the number it is — **350 mutants under
|
|
79
|
+
217 `// Stryker disable` directives** — instead of "the handful that no test can kill". Nothing
|
|
80
|
+
about them changed; the README's description of them had simply stopped matching their size, and
|
|
81
|
+
a number that is written down can be audited.
|
|
82
|
+
|
|
83
|
+
- **`docs/mutation_testing_results.md` records the run** in a new dated section, with the full
|
|
84
|
+
outcome table, the per-subpath split, and where the twenty-one timeouts sit. The earlier
|
|
85
|
+
sections are left as they were — they are the record of the passes that produced them. The
|
|
86
|
+
reproduce instructions are corrected in the same pass: they named `pnpm mutation:incremental`,
|
|
87
|
+
which is not a script in this package, and promised a ten-minute run that now takes
|
|
88
|
+
forty-eight at `--concurrency 2`.
|
|
89
|
+
|
|
10
90
|
## [1.3.0] - 2026-08-08
|
|
11
91
|
|
|
12
92
|
Minor rather than patch because the API now accepts a request it previously rejected: with a
|
|
@@ -1193,7 +1273,8 @@ ever installable.
|
|
|
1193
1273
|
- 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
|
|
1194
1274
|
- 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
|
|
1195
1275
|
|
|
1196
|
-
[Unreleased]: https://github.com/bymaxone/nest-auth/compare/v1.3.
|
|
1276
|
+
[Unreleased]: https://github.com/bymaxone/nest-auth/compare/v1.3.1...HEAD
|
|
1277
|
+
[1.3.1]: https://github.com/bymaxone/nest-auth/compare/v1.3.0...v1.3.1
|
|
1197
1278
|
[1.3.0]: https://github.com/bymaxone/nest-auth/compare/v1.2.0...v1.3.0
|
|
1198
1279
|
[1.2.0]: https://github.com/bymaxone/nest-auth/compare/v1.1.1...v1.2.0
|
|
1199
1280
|
[1.1.1]: https://github.com/bymaxone/nest-auth/compare/v1.1.0...v1.1.1
|
package/README.md
CHANGED
|
@@ -299,7 +299,12 @@ export class ResendEmailProvider implements IEmailProvider {
|
|
|
299
299
|
private readonly from = 'no-reply@example.com'
|
|
300
300
|
private readonly appUrl = process.env.APP_URL!
|
|
301
301
|
|
|
302
|
-
async sendPasswordResetToken(
|
|
302
|
+
async sendPasswordResetToken(
|
|
303
|
+
_tenantId: string,
|
|
304
|
+
email: string,
|
|
305
|
+
token: string,
|
|
306
|
+
_locale?: string
|
|
307
|
+
): Promise<void> {
|
|
303
308
|
const url = `${this.appUrl}/reset-password?token=${encodeURIComponent(token)}`
|
|
304
309
|
await this.client.emails.send({
|
|
305
310
|
from: this.from,
|
|
@@ -309,7 +314,12 @@ export class ResendEmailProvider implements IEmailProvider {
|
|
|
309
314
|
})
|
|
310
315
|
}
|
|
311
316
|
|
|
312
|
-
async sendPasswordResetOtp(
|
|
317
|
+
async sendPasswordResetOtp(
|
|
318
|
+
_tenantId: string,
|
|
319
|
+
email: string,
|
|
320
|
+
otp: string,
|
|
321
|
+
_locale?: string
|
|
322
|
+
): Promise<void> {
|
|
313
323
|
await this.client.emails.send({
|
|
314
324
|
from: this.from,
|
|
315
325
|
to: email,
|
|
@@ -318,7 +328,12 @@ export class ResendEmailProvider implements IEmailProvider {
|
|
|
318
328
|
})
|
|
319
329
|
}
|
|
320
330
|
|
|
321
|
-
async sendEmailVerificationOtp(
|
|
331
|
+
async sendEmailVerificationOtp(
|
|
332
|
+
_tenantId: string,
|
|
333
|
+
email: string,
|
|
334
|
+
otp: string,
|
|
335
|
+
_locale?: string
|
|
336
|
+
): Promise<void> {
|
|
322
337
|
await this.client.emails.send({
|
|
323
338
|
from: this.from,
|
|
324
339
|
to: email,
|
|
@@ -327,7 +342,11 @@ export class ResendEmailProvider implements IEmailProvider {
|
|
|
327
342
|
})
|
|
328
343
|
}
|
|
329
344
|
|
|
330
|
-
async sendMfaEnabledNotification(
|
|
345
|
+
async sendMfaEnabledNotification(
|
|
346
|
+
_tenantId: string,
|
|
347
|
+
email: string,
|
|
348
|
+
_locale?: string
|
|
349
|
+
): Promise<void> {
|
|
331
350
|
await this.client.emails.send({
|
|
332
351
|
from: this.from,
|
|
333
352
|
to: email,
|
|
@@ -336,7 +355,11 @@ export class ResendEmailProvider implements IEmailProvider {
|
|
|
336
355
|
})
|
|
337
356
|
}
|
|
338
357
|
|
|
339
|
-
async sendMfaDisabledNotification(
|
|
358
|
+
async sendMfaDisabledNotification(
|
|
359
|
+
_tenantId: string,
|
|
360
|
+
email: string,
|
|
361
|
+
_locale?: string
|
|
362
|
+
): Promise<void> {
|
|
340
363
|
await this.client.emails.send({
|
|
341
364
|
from: this.from,
|
|
342
365
|
to: email,
|
|
@@ -346,6 +369,7 @@ export class ResendEmailProvider implements IEmailProvider {
|
|
|
346
369
|
}
|
|
347
370
|
|
|
348
371
|
async sendNewSessionAlert(
|
|
372
|
+
_tenantId: string,
|
|
349
373
|
email: string,
|
|
350
374
|
sessionInfo: SessionInfo,
|
|
351
375
|
_locale?: string
|
|
@@ -365,7 +389,12 @@ export class ResendEmailProvider implements IEmailProvider {
|
|
|
365
389
|
})
|
|
366
390
|
}
|
|
367
391
|
|
|
368
|
-
async sendInvitation(
|
|
392
|
+
async sendInvitation(
|
|
393
|
+
_tenantId: string,
|
|
394
|
+
email: string,
|
|
395
|
+
inviteData: InviteData,
|
|
396
|
+
_locale?: string
|
|
397
|
+
): Promise<void> {
|
|
369
398
|
const url = `${this.appUrl}/accept-invite?token=${encodeURIComponent(inviteData.inviteToken)}`
|
|
370
399
|
await this.client.emails.send({
|
|
371
400
|
from: this.from,
|
|
@@ -927,9 +956,9 @@ When integrating `@bymax-one/nest-auth` in production, verify each of the follow
|
|
|
927
956
|
Authentication is critical infrastructure, so the suite is held to a bar beyond "it runs" — every behavior is pinned so that a regression **fails a test**.
|
|
928
957
|
|
|
929
958
|
- ✅ **100% line coverage** — statements, branches, functions, and lines, enforced as a release gate across unit + e2e
|
|
930
|
-
- ✅ **100% mutation score** — verified with [Stryker](https://stryker-mutator.io/):
|
|
931
|
-
- ✅ **
|
|
932
|
-
- ✅ **Every equivalent mutant documented** — the
|
|
959
|
+
- ✅ **100% mutation score** — verified with [Stryker](https://stryker-mutator.io/): 4,870 seeded faults detected (4,849 killed, 21 timed out), **no survivors and nothing left uncovered**, against a `break` threshold of 95 ([measured cold on 2026-08-08](./docs/mutation_testing_results.md#re-measured-cold--2026-08-08))
|
|
960
|
+
- ✅ **3,547 tests** — 3,420 unit and 127 end-to-end, spanning all five subpaths
|
|
961
|
+
- ✅ **Every equivalent mutant documented** — the 350 mutants that no test can kill (a redundant guard, a dependency array of stable references) each carry an inline `// Stryker disable` with the reason, so the score is an accounting rather than a number
|
|
933
962
|
|
|
934
963
|
```bash
|
|
935
964
|
pnpm test # unit suite
|