@bymax-one/nest-auth 1.4.20 → 1.4.22
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 +65 -1
- package/README.md +9 -8
- package/dist/server/index.cjs +1826 -1282
- package/dist/server/index.d.cts +532 -198
- package/dist/server/index.d.ts +532 -198
- package/dist/server/index.mjs +1827 -1283
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -18,6 +18,68 @@ what moves, and that note is the compatibility contract until strict SemVer begi
|
|
|
18
18
|
|
|
19
19
|
## [Unreleased]
|
|
20
20
|
|
|
21
|
+
## [1.4.22] - 2026-11-08
|
|
22
|
+
|
|
23
|
+
### Apply to a derived backend
|
|
24
|
+
|
|
25
|
+
- **`MfaService` is built from different collaborators.** Its constructor now takes
|
|
26
|
+
`MfaRecordService`, `MfaChallengeService`, `MfaManagementService`, `MfaFlowLockoutService` and
|
|
27
|
+
`ReauthenticationService`, and no longer takes `BruteForceService` or `PasswordService`.
|
|
28
|
+
`BymaxAuthModule` registers the new providers, and a class listed in `extraProviders` is resolved inside that module, so a host that
|
|
29
|
+
wires `MfaService` through the module changes nothing. Only code that calls `new MfaService(...)`
|
|
30
|
+
itself, such as a hand-built test double, must pass the new arguments.
|
|
31
|
+
|
|
32
|
+
### Fixed
|
|
33
|
+
|
|
34
|
+
- **MFA log lines read `[MfaService]` again.** 1.4.21 moved the re-authentication and record-transition
|
|
35
|
+
code out of `MfaService`, and the log lines of those services began to carry their
|
|
36
|
+
own class names as the logger context, so a log filter or alert keyed on the `MfaService`
|
|
37
|
+
context stopped matching them. They log under `MfaService` again, as they did before 1.4.21. The
|
|
38
|
+
1.4.21 note that log output was unchanged held for the message text and level only. No message
|
|
39
|
+
text or level has changed in either release.
|
|
40
|
+
|
|
41
|
+
### Changed
|
|
42
|
+
|
|
43
|
+
- **`MfaService` moves its challenge and its enrolment-management code to internal services.**
|
|
44
|
+
`challenge` and `challengePlatformOnly`, and `disable`, `resetMfa` and
|
|
45
|
+
`regenerateRecoveryCodes`, now run in internal services that `MfaService` calls. The public
|
|
46
|
+
methods keep their signatures and defaults, and behaviour, error codes, Redis keys and log text
|
|
47
|
+
are unchanged. None of the moved code was part of the public API.
|
|
48
|
+
|
|
49
|
+
## [1.4.21] - 2026-11-08
|
|
50
|
+
|
|
51
|
+
### Apply to a derived backend
|
|
52
|
+
|
|
53
|
+
- **Add `limitExpiry` to your `IApiKeyRepository` (optional, recommended).** Rotating a key with an
|
|
54
|
+
overlap read its expiry and then wrote the earlier of that and the end of the overlap with
|
|
55
|
+
`setExpiry`. Two rotations of one key could interleave, so that a delayed one with a longer
|
|
56
|
+
overlap overwrote the shorter deadline another had just set, and the old key kept verifying past
|
|
57
|
+
the shortest overlap anyone asked for. Implement
|
|
58
|
+
`limitExpiry(id, at): Promise<boolean>` as one atomic minimum, for example
|
|
59
|
+
`UPDATE api_keys SET expires_at = LEAST(COALESCE(expires_at, :at), :at) WHERE id = :id`, and
|
|
60
|
+
return `false` only when the key does not exist. Rotation then calls it and no longer computes the
|
|
61
|
+
minimum itself. A repository without it keeps the old read-then-write behaviour, which has the gap:
|
|
62
|
+
serialize rotation per key there.
|
|
63
|
+
|
|
64
|
+
### Fixed
|
|
65
|
+
|
|
66
|
+
- **Concurrent rotations of one API key no longer lengthen the old key's life.** With a repository
|
|
67
|
+
that implements the new optional `limitExpiry`, rotation lowers the old key's expiry atomically
|
|
68
|
+
instead of overwriting it with a value computed from an earlier read. See the note above.
|
|
69
|
+
|
|
70
|
+
### Added
|
|
71
|
+
|
|
72
|
+
- **`ReauthenticationService` is exported.** It re-proves the account password before a sensitive
|
|
73
|
+
change, counted against the same `reauth` lockout `MfaService` uses, or for an account with no
|
|
74
|
+
password requires a recent real sign-in. A host can guard its own destructive routes with it. It
|
|
75
|
+
is provided by `BymaxAuthModule` whether or not MFA is configured.
|
|
76
|
+
|
|
77
|
+
### Changed
|
|
78
|
+
|
|
79
|
+
- **`MfaService` moves its re-authentication, flow lockout, record-transition and plane-tenant
|
|
80
|
+
code to internal modules.** Behaviour, error codes, Redis keys and log text are unchanged, and
|
|
81
|
+
none of the moved members was part of the public API.
|
|
82
|
+
|
|
21
83
|
## [1.4.20] - 2026-11-07
|
|
22
84
|
|
|
23
85
|
### Apply to a derived backend
|
|
@@ -4600,7 +4662,9 @@ ever installable.
|
|
|
4600
4662
|
- 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
|
|
4601
4663
|
- 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
|
|
4602
4664
|
|
|
4603
|
-
[Unreleased]: https://github.com/bymaxone/nest-auth/compare/v1.4.
|
|
4665
|
+
[Unreleased]: https://github.com/bymaxone/nest-auth/compare/v1.4.22...HEAD
|
|
4666
|
+
[1.4.22]: https://github.com/bymaxone/nest-auth/compare/v1.4.21...v1.4.22
|
|
4667
|
+
[1.4.21]: https://github.com/bymaxone/nest-auth/compare/v1.4.20...v1.4.21
|
|
4604
4668
|
[1.4.20]: https://github.com/bymaxone/nest-auth/compare/v1.4.19...v1.4.20
|
|
4605
4669
|
[1.4.19]: https://github.com/bymaxone/nest-auth/compare/v1.4.18...v1.4.19
|
|
4606
4670
|
[1.4.18]: https://github.com/bymaxone/nest-auth/compare/v1.4.17...v1.4.18
|
package/README.md
CHANGED
|
@@ -1316,14 +1316,15 @@ export class KeysAdminController {
|
|
|
1316
1316
|
You implement `IApiKeyRepository`, as you do for users. The library supplies the `id` and the
|
|
1317
1317
|
`digest`; the store only persists them.
|
|
1318
1318
|
|
|
1319
|
-
| Method | Contract
|
|
1320
|
-
| ------------------------ |
|
|
1321
|
-
| `findById(id)` | One primary-key read per request. Return revoked and expired rows too: the library decides validity.
|
|
1322
|
-
| `create(row)` | Insert `{ id, label, digest, scopes, createdAt, expiresAt }`. Do not make `label` unique.
|
|
1323
|
-
| `markRevoked(id, at)` | `false` when unknown. Revoking twice is not an error. A row with `revokedAt` set is revoked at once on every instance, whatever instant it holds: a future date is not a schedule, so schedule with `expiresAt`.
|
|
1324
|
-
| `setExpiry(id, at)` | `false` when unknown. The scheduling field: a key stops verifying at `expiresAt`. Used by rotation to retire the old key after the overlap.
|
|
1325
|
-
| `
|
|
1326
|
-
| `
|
|
1319
|
+
| Method | Contract |
|
|
1320
|
+
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
1321
|
+
| `findById(id)` | One primary-key read per request. Return revoked and expired rows too: the library decides validity. |
|
|
1322
|
+
| `create(row)` | Insert `{ id, label, digest, scopes, createdAt, expiresAt }`. Do not make `label` unique. |
|
|
1323
|
+
| `markRevoked(id, at)` | `false` when unknown. Revoking twice is not an error. A row with `revokedAt` set is revoked at once on every instance, whatever instant it holds: a future date is not a schedule, so schedule with `expiresAt`. |
|
|
1324
|
+
| `setExpiry(id, at)` | `false` when unknown. The scheduling field: a key stops verifying at `expiresAt`. Used by rotation to retire the old key after the overlap. |
|
|
1325
|
+
| `limitExpiry(id, at)` | **Optional, recommended.** An atomic minimum: lower the expiry to `at`, never raise it (`SET expires_at = LEAST(COALESCE(expires_at, :at), :at)`). `false` when unknown. Rotation uses it when present; without it two rotations of one key can interleave and leave the old key valid past the shortest overlap, so serialize rotation per key. |
|
|
1326
|
+
| `touchLastUsed(entries)` | One batch. **Must be monotonic**: `GREATEST(last_used_at, :at)`, never backwards — several instances flush independently. |
|
|
1327
|
+
| `listByLabel(label)` | Every key of a label, for your admin screen. |
|
|
1327
1328
|
|
|
1328
1329
|
### How a key is stored and checked
|
|
1329
1330
|
|