@bymax-one/nest-auth 1.4.16 → 1.4.18
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 +126 -1
- package/dist/server/index.cjs +1061 -726
- package/dist/server/index.d.cts +182 -16
- package/dist/server/index.d.ts +182 -16
- package/dist/server/index.mjs +1062 -728
- package/package.json +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -18,6 +18,129 @@ what moves, and that note is the compatibility contract until strict SemVer begi
|
|
|
18
18
|
|
|
19
19
|
## [Unreleased]
|
|
20
20
|
|
|
21
|
+
## [1.4.18] - 2026-11-07
|
|
22
|
+
|
|
23
|
+
### Apply to a derived backend
|
|
24
|
+
|
|
25
|
+
- **A request body declared compressed is now refused with `415 auth.validation`, whatever the
|
|
26
|
+
host's body parser does.** Express's default parser decompresses `gzip`, `deflate` and `br`
|
|
27
|
+
before a handler runs, so these requests used to be accepted; rust-auth refuses them. The
|
|
28
|
+
library now answers `415` "Unsupported media type" in the library envelope for any
|
|
29
|
+
`Content-Encoding` other than `identity` on its JSON-body routes, before the handler. Refresh,
|
|
30
|
+
logout, revoke-all and the WebSocket ticket request are unchecked; the MFA setup routes, which
|
|
31
|
+
accept an empty body, refuse it only when a body is present; `GET`, `HEAD`, `OPTIONS` and
|
|
32
|
+
`DELETE` requests are never checked. The route-by-route scope is the new `requestEncoding`
|
|
33
|
+
section of `conformance/wire-contract.json`, and a test fails when a controller route is added
|
|
34
|
+
without a decision. A client that compresses its request bodies must send them uncompressed;
|
|
35
|
+
browsers and `fetch` do not compress them. A host that also sets `inflate: false` on its JSON
|
|
36
|
+
parser refuses earlier, with the same `415` through `AuthExceptionFilter`.
|
|
37
|
+
- **A body that claims to be compressed and is not now answers `400 auth.validation`
|
|
38
|
+
`Malformed request`, not `500`.** The body parser raises that failure as a plain 400 with no
|
|
39
|
+
`type`, so `AuthExceptionFilter` now answers a 400 error of that shape that arrived before any
|
|
40
|
+
route matched with the fixed message. The `transportErrors` section lists the row.
|
|
41
|
+
- **New public API:** `RequestEncodingGuard`, applied at class level to every library controller
|
|
42
|
+
and available for a host's own controllers; the `@RequestEncoding('unchecked' | 'when-body')`
|
|
43
|
+
decorator and its `RequestEncodingPolicy` type, which set a route's policy (a route with none is
|
|
44
|
+
strict). `content-encoding`, `content-length` and `transfer-encoding` join the headers the library reads,
|
|
45
|
+
so `apiKeys.header` can no longer name them.
|
|
46
|
+
- **A logout that needed a retry now fires `afterLogout` (and `afterPlatformLogout`) once, on the
|
|
47
|
+
retry that completes it.** A logout attempts every revocation write and answers `5xx` when one
|
|
48
|
+
failed, and the attempt had already deleted the refresh session, so the retry found no record to
|
|
49
|
+
say whose logout it was and the hook never fired for it. An attempt that fails a write while it
|
|
50
|
+
still has the session's owner now leaves a short-lived marker, `lp:{sha256(refreshToken)}` on the
|
|
51
|
+
dashboard plane and `plp:{...}` on the platform plane, holding the owner and tenant from the
|
|
52
|
+
session record; it lives for the access-token lifetime and never less than 300 seconds. A retry
|
|
53
|
+
that finds no session reads the owner from the marker, and when it completes with no failure it
|
|
54
|
+
removes the marker and fires the hook only if that removal removed it, so sequential retries
|
|
55
|
+
announce once and a repeat announces nothing; attempts of one logout that run concurrently are
|
|
56
|
+
at-least-once. The owner is never taken from an access
|
|
57
|
+
token's claims. A marker that cannot be written leaves the retry silent, as before, and a marker
|
|
58
|
+
that cannot be removed never fails a completed logout. HTTP statuses, bodies and cookies are
|
|
59
|
+
unchanged. The shared contract gains the two key prefixes and a `logoutPending` record row. A
|
|
60
|
+
consumer whose hook assumed a logout is announced only by the call that found the session now
|
|
61
|
+
also receives it from the completing retry. Private `blacklistWrites` (both services) and
|
|
62
|
+
`revokeSessionMetadata` (`AuthService`) appear in the declarations.
|
|
63
|
+
- **A late MFA re-encryption can no longer overwrite a `disable` or a re-enrolment.** This applies
|
|
64
|
+
only to a deployment that has configured `mfa.previousEncryptionKeys` and still holds secrets
|
|
65
|
+
stored under a retired key: the first successful challenge on such an account re-encrypts the
|
|
66
|
+
secret under the current key, and that write replaces the whole MFA record. If the user disabled
|
|
67
|
+
MFA, or re-enrolled with a new secret and recovery codes, while that write was in flight, it could
|
|
68
|
+
restore the removed factor or the replaced secret and recovery digests. The re-encryption is now
|
|
69
|
+
one of the serialized MFA transitions and writes only when the stored secret still decrypts to
|
|
70
|
+
the secret the challenge opened, and the recovery-code challenge makes the same check before it
|
|
71
|
+
writes back the list without the used code. A sibling challenge that only re-encrypted the same secret does not count as a
|
|
72
|
+
change. Accounts already past the migration, and deployments with no retired key, are not
|
|
73
|
+
affected; draining the retired keys closes the exposure. When another transition holds the lock
|
|
74
|
+
the migration is skipped and retried by the next challenge. No contract change. Private
|
|
75
|
+
`holdsSecret` appears in the `MfaService` declarations, and the private `reencryptSecret` loses
|
|
76
|
+
its recovery-codes parameter.
|
|
77
|
+
|
|
78
|
+
### Fixed
|
|
79
|
+
|
|
80
|
+
- **Compressed request bodies are refused the way rust-auth refuses them, and a corrupt one no
|
|
81
|
+
longer answers `500`.** See the note above.
|
|
82
|
+
- **A logout completed by a retry no longer goes unannounced.** See the note above.
|
|
83
|
+
- **The MFA re-encryption under the current key no longer overwrites a concurrent `disable` or
|
|
84
|
+
re-enrolment.** See the note above.
|
|
85
|
+
|
|
86
|
+
## [1.4.17] - 2026-11-07
|
|
87
|
+
|
|
88
|
+
### Apply to a derived backend
|
|
89
|
+
|
|
90
|
+
- **`AuthExceptionFilter` now answers a request the HTTP layer refused with a client-error
|
|
91
|
+
envelope, not `auth.internal`.** Applies only where the filter is registered, and only on
|
|
92
|
+
Express (the filter writes through Express's `Response`; nothing here is defined for Fastify).
|
|
93
|
+
A malformed JSON body, a bare JSON string or number, a form body nested past the parser's
|
|
94
|
+
depth limit, and a path that cannot be decoded now answer `400 auth.validation` with the fixed
|
|
95
|
+
message `Malformed request`; the parser's own text, which could quote the start of the body, is
|
|
96
|
+
no longer in the response. An oversized body answers `413` and an unsupported charset or
|
|
97
|
+
content-encoding `415`, both `auth.validation`, where they answered `500 auth.internal`. A client that branched on `auth.internal` for these must branch on
|
|
98
|
+
`auth.validation` and the status. The 400 is recognised by having been raised before any route
|
|
99
|
+
matched (`req.route` unset), so a `BadRequestException` thrown by the application's own
|
|
100
|
+
middleware that runs before routing is answered the same generic way; one thrown from a
|
|
101
|
+
handler, guard, pipe or service keeps its message and `auth.internal`. The new `transportErrors`
|
|
102
|
+
section of `conformance/wire-contract.json` lists the rows; `errorCatalog.statuses` still holds
|
|
103
|
+
one status per code. No public member is added or changed.
|
|
104
|
+
- **A production deployment can no longer start with `secureCookies: false`.** `environment` is
|
|
105
|
+
`'production'` when unset, so a configuration that sets `secureCookies: false` without declaring
|
|
106
|
+
`environment: 'development'` or `'test'` now throws at startup, after the `SameSite=None` check,
|
|
107
|
+
with a message that contains "secureCookies is false but environment is 'production' (the default
|
|
108
|
+
when unset)." Remove the option, set it to `true`, or declare the environment. A session cookie
|
|
109
|
+
without `Secure` travels over plain HTTP, and a TLS-terminating proxy still serves HTTPS to the
|
|
110
|
+
browser. Omitting `secureCookies` and setting it to `true` are unchanged. No public member is
|
|
111
|
+
added or changed.
|
|
112
|
+
- **A refresh token that rotated a moment ago now stands for the session that replaced it, on
|
|
113
|
+
`POST /password/change` and `POST /sessions/revoke-all`.** A refresh of the caller's own session
|
|
114
|
+
that landed while the request was being handled turned the token it carried into a rotation
|
|
115
|
+
predecessor, and both routes answered `404 auth.session_not_found`; a password change left the
|
|
116
|
+
password unchanged. A presented token now counts when it is a live session or when its grace
|
|
117
|
+
pointer (`rp:{hash}`) names a live successor, and that successor is the session kept. It is one
|
|
118
|
+
hop, the pointer is read and never consumed or extended, and a token past the grace window is
|
|
119
|
+
still refused with `404`. The current password still gates the change. When the session to keep
|
|
120
|
+
cannot be resolved after the new password is written, every session still ends, as before; a
|
|
121
|
+
session that rotated while the new password was being hashed is no longer among them, since it
|
|
122
|
+
is the caller's device and now survives. `SessionService` gains a public
|
|
123
|
+
`resolveLiveSession(params)` returning the hash to keep, `assertLiveSession` takes
|
|
124
|
+
`params: LiveSessionParams`, and private `isLiveMember`, `resolveLiveMember` and `graceSuccessor`
|
|
125
|
+
replace the private `requireLiveMember`. In `PasswordResetService` the private `requireLiveCurrentSession` becomes
|
|
126
|
+
`resolveCurrentSession`, and `endOtherSessions` now takes the hash to keep.
|
|
127
|
+
- **A login no longer evicts a session when the store fails to read a session record.** The
|
|
128
|
+
session limit ranks sessions by the creation time in each one's detail record; a read the store
|
|
129
|
+
failed was ranked as the oldest, so a transient Redis fault could end a live, newest device. Now
|
|
130
|
+
no session is evicted by that login, one error is logged without any key or hash, and the limit
|
|
131
|
+
is checked again by the next login. An absent or unparseable detail record is not a fault and
|
|
132
|
+
still ranks as the oldest. While such reads fail no login evicts, so the limit is unenforced.
|
|
133
|
+
A private `readCreatedAt` appears in the `SessionService` declarations.
|
|
134
|
+
|
|
135
|
+
### Fixed
|
|
136
|
+
|
|
137
|
+
- **Requests refused by the body parser no longer answer `500` or echo the body.** See the note
|
|
138
|
+
above.
|
|
139
|
+
- **A password change or revoke-all no longer fails when the caller refreshes the session
|
|
140
|
+
concurrently.** See the note above.
|
|
141
|
+
- **A store fault while ranking sessions no longer evicts a live session.** See the note above.
|
|
142
|
+
- **`secureCookies: false` in a production deployment is refused at startup.** See the note above.
|
|
143
|
+
|
|
21
144
|
## [1.4.16] - 2026-11-06
|
|
22
145
|
|
|
23
146
|
### Apply to a derived backend
|
|
@@ -4360,7 +4483,9 @@ ever installable.
|
|
|
4360
4483
|
- 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
|
|
4361
4484
|
- 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
|
|
4362
4485
|
|
|
4363
|
-
[Unreleased]: https://github.com/bymaxone/nest-auth/compare/v1.4.
|
|
4486
|
+
[Unreleased]: https://github.com/bymaxone/nest-auth/compare/v1.4.18...HEAD
|
|
4487
|
+
[1.4.18]: https://github.com/bymaxone/nest-auth/compare/v1.4.17...v1.4.18
|
|
4488
|
+
[1.4.17]: https://github.com/bymaxone/nest-auth/compare/v1.4.16...v1.4.17
|
|
4364
4489
|
[1.4.16]: https://github.com/bymaxone/nest-auth/compare/v1.4.15...v1.4.16
|
|
4365
4490
|
[1.4.15]: https://github.com/bymaxone/nest-auth/compare/v1.4.14...v1.4.15
|
|
4366
4491
|
[1.4.14]: https://github.com/bymaxone/nest-auth/compare/v1.4.13...v1.4.14
|