@bymax-one/nest-auth 1.4.20 → 1.4.21
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 +36 -1
- package/README.md +9 -8
- package/dist/server/index.cjs +1171 -1013
- package/dist/server/index.d.cts +250 -173
- package/dist/server/index.d.ts +250 -173
- package/dist/server/index.mjs +1172 -1014
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -18,6 +18,40 @@ what moves, and that note is the compatibility contract until strict SemVer begi
|
|
|
18
18
|
|
|
19
19
|
## [Unreleased]
|
|
20
20
|
|
|
21
|
+
## [1.4.21] - 2026-11-08
|
|
22
|
+
|
|
23
|
+
### Apply to a derived backend
|
|
24
|
+
|
|
25
|
+
- **Add `limitExpiry` to your `IApiKeyRepository` (optional, recommended).** Rotating a key with an
|
|
26
|
+
overlap read its expiry and then wrote the earlier of that and the end of the overlap with
|
|
27
|
+
`setExpiry`. Two rotations of one key could interleave, so that a delayed one with a longer
|
|
28
|
+
overlap overwrote the shorter deadline another had just set, and the old key kept verifying past
|
|
29
|
+
the shortest overlap anyone asked for. Implement
|
|
30
|
+
`limitExpiry(id, at): Promise<boolean>` as one atomic minimum, for example
|
|
31
|
+
`UPDATE api_keys SET expires_at = LEAST(COALESCE(expires_at, :at), :at) WHERE id = :id`, and
|
|
32
|
+
return `false` only when the key does not exist. Rotation then calls it and no longer computes the
|
|
33
|
+
minimum itself. A repository without it keeps the old read-then-write behaviour, which has the gap:
|
|
34
|
+
serialize rotation per key there.
|
|
35
|
+
|
|
36
|
+
### Fixed
|
|
37
|
+
|
|
38
|
+
- **Concurrent rotations of one API key no longer lengthen the old key's life.** With a repository
|
|
39
|
+
that implements the new optional `limitExpiry`, rotation lowers the old key's expiry atomically
|
|
40
|
+
instead of overwriting it with a value computed from an earlier read. See the note above.
|
|
41
|
+
|
|
42
|
+
### Added
|
|
43
|
+
|
|
44
|
+
- **`ReauthenticationService` is exported.** It re-proves the account password before a sensitive
|
|
45
|
+
change, counted against the same `reauth` lockout `MfaService` uses, or for an account with no
|
|
46
|
+
password requires a recent real sign-in. A host can guard its own destructive routes with it. It
|
|
47
|
+
is provided by `BymaxAuthModule` whether or not MFA is configured.
|
|
48
|
+
|
|
49
|
+
### Changed
|
|
50
|
+
|
|
51
|
+
- **`MfaService` moves its re-authentication, flow lockout, record-transition and plane-tenant
|
|
52
|
+
code to internal modules.** Behaviour, error codes, Redis keys and log text are unchanged, and
|
|
53
|
+
none of the moved members was part of the public API.
|
|
54
|
+
|
|
21
55
|
## [1.4.20] - 2026-11-07
|
|
22
56
|
|
|
23
57
|
### Apply to a derived backend
|
|
@@ -4600,7 +4634,8 @@ ever installable.
|
|
|
4600
4634
|
- 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
4635
|
- 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
4636
|
|
|
4603
|
-
[Unreleased]: https://github.com/bymaxone/nest-auth/compare/v1.4.
|
|
4637
|
+
[Unreleased]: https://github.com/bymaxone/nest-auth/compare/v1.4.21...HEAD
|
|
4638
|
+
[1.4.21]: https://github.com/bymaxone/nest-auth/compare/v1.4.20...v1.4.21
|
|
4604
4639
|
[1.4.20]: https://github.com/bymaxone/nest-auth/compare/v1.4.19...v1.4.20
|
|
4605
4640
|
[1.4.19]: https://github.com/bymaxone/nest-auth/compare/v1.4.18...v1.4.19
|
|
4606
4641
|
[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
|
|