@bymax-one/nest-auth 1.4.4 → 1.4.6
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 +610 -3
- package/README.md +248 -31
- package/dist/nextjs/index.d.cts +10 -12
- package/dist/nextjs/index.d.ts +10 -12
- package/dist/react/index.cjs +4 -4
- package/dist/react/index.d.cts +15 -2
- package/dist/react/index.d.ts +15 -2
- package/dist/react/index.mjs +4 -4
- package/dist/server/index.cjs +2169 -970
- package/dist/server/index.d.cts +639 -84
- package/dist/server/index.d.ts +639 -84
- package/dist/server/index.mjs +2172 -973
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -18,6 +18,609 @@ what moves, and that note is the compatibility contract until strict SemVer begi
|
|
|
18
18
|
|
|
19
19
|
## [Unreleased]
|
|
20
20
|
|
|
21
|
+
## [1.4.6] - 2026-10-31
|
|
22
|
+
|
|
23
|
+
### Apply to a derived backend
|
|
24
|
+
|
|
25
|
+
What a backend built on this library does about the changes below. Nothing here is a breaking
|
|
26
|
+
change to the public API; the items that change behaviour are the ones to read.
|
|
27
|
+
|
|
28
|
+
- **`identifierKey` (new, optional).** Nothing to do unless you rotate `jwt.secret`. Set
|
|
29
|
+
`identifierKey` to the current secret before a rotation to keep sessions, token epochs and MFA
|
|
30
|
+
state where they are. Choosing a new value keeps today's behaviour, and recovery codes then stop
|
|
31
|
+
verifying unless the old secret stays in `jwt.previousSecrets`.
|
|
32
|
+
- **`AuthTokenVerifierService` (new, exported by `BymaxAuthModule`).** Inject it where a long-lived
|
|
33
|
+
transport must establish the same facts a guarded route does:
|
|
34
|
+
`verifyAccessToken(token, { plane, requireMfa?, checkStatus? })` resolves `{ plane, payload }` and
|
|
35
|
+
rejects with an `AuthException`. It checks the account status before the MFA policy.
|
|
36
|
+
- **`AuthEmailContext` (new, exported).** A catalogue that implements the renderers keeps
|
|
37
|
+
compiling; read `tenantId` and `email` from the new argument where a URL needs them.
|
|
38
|
+
- **Refresh keeps the second factor.** A session that completed the MFA challenge now stays
|
|
39
|
+
`mfaVerified` across rotations. Refresh sessions stored before the deploy carry no field and stay
|
|
40
|
+
unverified until the user next completes the challenge. A backend that stores the record itself
|
|
41
|
+
must carry `mfaVerified` forward, written only as `true` and read strictly.
|
|
42
|
+
- **WebSocket tickets.** A ticket is refused after its minting token is revoked, and it expires no
|
|
43
|
+
later than that token. The stored `wst:` record needs `jti` and `epoch`, so a ticket minted before
|
|
44
|
+
the deploy is refused at redemption; it lives at most 30 seconds, and a client that holds one asks
|
|
45
|
+
for a new one. Read `expiresIn` from `POST {prefix}/ws-ticket` rather than assuming 30 seconds.
|
|
46
|
+
- **`next` peer floor `^16.4.1`.** Applies only to a deployment that uses the `./nextjs` subpath:
|
|
47
|
+
upgrade `next` to 16.4.1 or later.
|
|
48
|
+
- **A request without a body to `POST …/mfa/setup`.** It now answers exactly as it does for `{}`
|
|
49
|
+
instead of 500; a client needs no change.
|
|
50
|
+
- **`onLockout` when the store cannot answer.** Nothing to do beyond upgrading. If the reads that
|
|
51
|
+
decide whether the hook fires fail, the login still answers `auth.invalid_credentials`; the hook is
|
|
52
|
+
skipped when the lock cannot be confirmed. If only the remaining time cannot be read after the lock
|
|
53
|
+
was confirmed, the hook fires with `retryAfterSeconds` set to `bruteForce.windowSeconds`, an upper
|
|
54
|
+
bound. A handler that treats the value as exact should read it as at most that long.
|
|
55
|
+
|
|
56
|
+
### Added
|
|
57
|
+
|
|
58
|
+
- **`identifierKey` — rotate `jwt.secret` without moving the Redis identifiers.** Every name that
|
|
59
|
+
identifies an account (the session index, the token epoch, the MFA keys, the recent-authentication
|
|
60
|
+
marker, the OTP and rate-limit identifiers) derives from one key, which was always derived from
|
|
61
|
+
`jwt.secret`; rotating the secret therefore renamed all of them. The new optional top-level
|
|
62
|
+
`identifierKey` is the secret those names derive from instead, validated like `jwt.secret`, never
|
|
63
|
+
used to sign or verify a token, and defaulting to `jwt.secret`, so a deployment that does not set
|
|
64
|
+
it derives exactly the keys it derives today. Setting it to the current `jwt.secret` before a
|
|
65
|
+
rotation keeps sessions, token epochs and MFA state where they are; choosing a new value keeps
|
|
66
|
+
today's behaviour for a rotation that must cut the link. `jwt.previousSecrets` and the keys derived
|
|
67
|
+
from it are unchanged. Choosing a new `identifierKey` has two consequences: the stored MFA
|
|
68
|
+
recovery-code digests are an HMAC under the same derived key, so recovery codes stop verifying
|
|
69
|
+
unless the old secret stays in `jwt.previousSecrets`, and sessions leave the session list until
|
|
70
|
+
their next refresh (opaque refresh tokens keep working). The README gains a rotation guide with both paths, and
|
|
71
|
+
`conformance/wire-contract.json` states where the identifier secret comes from.
|
|
72
|
+
|
|
73
|
+
- **`AccountStatusService.invalidate({ userId, tenantId })` — a supported way to drop an account's
|
|
74
|
+
cached status.** Status is read through a Redis cache with a `userStatusCacheTtlSeconds`
|
|
75
|
+
lifetime, and nothing invalidated it on a change made outside this library. A host suspending a
|
|
76
|
+
user through its own admin surface therefore had two options, and both were bad: accept up to a
|
|
77
|
+
full TTL of continued access for a suspended account, or reach into
|
|
78
|
+
`<namespace>:us:{tenantId}:{userId}` and delete the key itself.
|
|
79
|
+
|
|
80
|
+
The canonical consumer chose the second, correctly — the first is worse — and documented it as a
|
|
81
|
+
workaround. **The format it depends on was never a contract**, and the failure when a format
|
|
82
|
+
moves is silent: the delete stops matching, nothing raises, and a security control quietly
|
|
83
|
+
degrades to "takes effect within a TTL". The format has moved once already, in 1.3.2, which added
|
|
84
|
+
the tenant segment.
|
|
85
|
+
|
|
86
|
+
`us` and `uev` were also absent from the key table in `AGENTS.md` and from
|
|
87
|
+
`conformance/wire-contract.json`, so the prefix a consumer actually reached for was the one
|
|
88
|
+
nothing had ever stated. `src/server/AGENTS.md` now lists both, with the rule that the format is not the
|
|
89
|
+
interface. **The wire contract deliberately still does not**: it is the parity artefact shared
|
|
90
|
+
with `rust-auth`, and adding a prefix there asserts a cross-implementation claim this change has
|
|
91
|
+
not verified. Whether these caches are part of that contract at all is a question for the two
|
|
92
|
+
libraries, not something to settle by editing one side's file.
|
|
93
|
+
|
|
94
|
+
The method drops both cached facts rather than only the one a caller has in mind — they are
|
|
95
|
+
written together, and the extra delete costs one repository read against an API where the caller
|
|
96
|
+
must know which of two entries their change invalidated. It is idempotent.
|
|
97
|
+
|
|
98
|
+
**What it does not promise, stated rather than left to be discovered.** The read path fills the
|
|
99
|
+
cache in two steps — resolve from the repository, then write — so a request that resolved the old
|
|
100
|
+
value just before your update lands will write it back afterwards with a full TTL, however
|
|
101
|
+
promptly you invalidate. The window shrinks from one TTL to one repository read; it does not
|
|
102
|
+
reach zero. Persist the status change **before** invalidating, so only genuinely concurrent
|
|
103
|
+
requests can lose the race. Closing it entirely needs the fill to be conditional on nothing
|
|
104
|
+
having invalidated in between — a per-account generation — which is a mechanism this service does
|
|
105
|
+
not have and which is tracked rather than implied here.
|
|
106
|
+
|
|
107
|
+
It refuses an empty or blank id with a `TypeError` rather than attempting the delete. An empty
|
|
108
|
+
tenant builds `us::{userId}`, a key no read ever wrote, so the delete would remove nothing and
|
|
109
|
+
resolve normally — the caller's admin surface reporting a suspension that never took effect,
|
|
110
|
+
which is the precise failure this method exists to eliminate. An unset resolver value, or an
|
|
111
|
+
`undefined` coerced by a JavaScript host, is how it arrives.
|
|
112
|
+
|
|
113
|
+
- **`AuthTokenVerifierService` — the whole identity chain for an access token, in one call.** A
|
|
114
|
+
guarded HTTP route establishes a chain of facts before a handler runs. A long-lived transport has no
|
|
115
|
+
guard in front of it and must establish the same ones itself, on a cadence, for as long as the
|
|
116
|
+
connection lives. Until now this library exported the parts and not the chain, and the parts do
|
|
117
|
+
not compose into it by inspection: `AuthRevocationService` answers two revocation channels and
|
|
118
|
+
says so, but a bridge calling it alone has checked a signature and a blacklist while checking
|
|
119
|
+
neither the token's **type**, nor its **`exp`**, nor whether the **account** behind it still
|
|
120
|
+
exists. `verifyWithRotation`, `assertValidJti`, `assertValidSub`, `assertValidTenantId` and
|
|
121
|
+
`assertTokenType` — the pieces that close those — were all internal.
|
|
122
|
+
|
|
123
|
+
`verifyAccessToken(token, { plane })` performs, in the order the refusals fire: the signature
|
|
124
|
+
under the pinned algorithm, the configured `issuer`/`audience` and any secret retired by a
|
|
125
|
+
rotation; `exp`; the claim shapes that become Redis keys downstream; the token type; both revocation
|
|
126
|
+
channels; the MFA claim shape; the account's **current** status;
|
|
127
|
+
and last the MFA policy (`MFA_REQUIRED`). The last two checks are opt-out (`checkStatus`,
|
|
128
|
+
`requireMfa`), defaulting to on.
|
|
129
|
+
|
|
130
|
+
**The plane is the caller's to declare and is never inferred from the token's own `type` claim.**
|
|
131
|
+
Inferring it would make the plane attacker-chosen — a platform token would open a dashboard
|
|
132
|
+
stream by saying it is one. It is returned on the result for the reason `HookContext.plane`
|
|
133
|
+
exists: a tenant cannot answer the question, because a platform token carries no tenant claim.
|
|
134
|
+
|
|
135
|
+
Two of them are worth naming for what they catch that a signature does not. A refresh mints
|
|
136
|
+
`mfaEnabled: true, mfaVerified: false`, so a token that is otherwise entirely valid can represent
|
|
137
|
+
a session that never completed its second factor — the type does not imply it. And the `status`
|
|
138
|
+
claim a token carries is a snapshot taken at issuance, so a suspension landing between two
|
|
139
|
+
reconnects is invisible to anything that reads the token alone; this asks the account.
|
|
140
|
+
|
|
141
|
+
**What it still does not do is stated rather than implied**, in the JSDoc and in the README:
|
|
142
|
+
route authorization is the consumer's and belongs on every message a stream carries rather than
|
|
143
|
+
on the handshake alone; `enforceTenantBinding` needs the request its resolver reads, which a
|
|
144
|
+
redeemed ticket no longer has; and the call holds no subscription, so a stream that asks once at
|
|
145
|
+
connect is authorized for the lifetime of the token rather than of the session.
|
|
146
|
+
|
|
147
|
+
**Two limits are stated rather than left to be discovered.** On the dashboard plane the status
|
|
148
|
+
check reads the `us:`/`uev:` cache. Email verification drops it, but a status change made by the
|
|
149
|
+
host's own code is seen only after `userStatusCacheTtlSeconds` (default 60 s) unless the host
|
|
150
|
+
calls `AccountStatusService.invalidate({ userId, tenantId })` after persisting the change. So its
|
|
151
|
+
freshness is bounded by that TTL and not by how often you call: a stream re-verifying every five
|
|
152
|
+
seconds still serves a banned account for up to a minute without the invalidation. The platform plane is uncached and genuinely current.
|
|
153
|
+
And a `plane` that is neither value throws a `TypeError` instead of falling through — the
|
|
154
|
+
fall-through arm would be the cross-tenant platform one, so a `'Dashboard'` from an unnarrowed
|
|
155
|
+
config value would verify a real platform token for a connection meant to be tenant-scoped.
|
|
156
|
+
|
|
157
|
+
Refusals mirror the code the equivalent guard already answers, so a consumer moving a surface
|
|
158
|
+
onto this service keeps branching on what it branched on before. That includes the asymmetry:
|
|
159
|
+
a wrong token type is `PLATFORM_AUTH_REQUIRED` on the platform plane, as `JwtPlatformGuard`
|
|
160
|
+
answers, and `TOKEN_INVALID` on the dashboard one, as `JwtAuthGuard` does.
|
|
161
|
+
|
|
162
|
+
The server entry exports the service together with the types `AuthPlane`, `VerifiedAccessToken`
|
|
163
|
+
and `VerifyAccessTokenOptions`, and `BymaxAuthModule` exports `AuthTokenVerifierService` and
|
|
164
|
+
`AccountStatusService`.
|
|
165
|
+
|
|
166
|
+
Closes the first candidate change in [#172](https://github.com/bymaxone/nest-auth/issues/172),
|
|
167
|
+
the one that removes the most from a consumer's plate.
|
|
168
|
+
|
|
169
|
+
- **`AccountStatusService`**, exported alongside it. It is the account lifecycle gate
|
|
170
|
+
`UserStatusGuard` already applied, lifted out of that guard so the verifier could share it rather
|
|
171
|
+
than carry a second copy of the cache key shape, the miss path and the order of the two refusals
|
|
172
|
+
— a guarded route and a long-lived transport have to reach the same verdict about the same
|
|
173
|
+
account, and one rule with two implementations is how that stops being true. Exported for the
|
|
174
|
+
narrower case too: a consumer already holding a verified payload can re-ask the one question
|
|
175
|
+
whose answer changes while a stream is open.
|
|
176
|
+
|
|
177
|
+
It also answers on the **platform** plane, which nothing did before: there is no
|
|
178
|
+
`PlatformUserStatusGuard`, and #172 recorded the absence as "no platform equivalent exists". That
|
|
179
|
+
is true of the guard and not of the capability — `IPlatformUserRepository.findById` and
|
|
180
|
+
`AuthPlatformUser.status` were already in the contract, so a platform administrator's suspension
|
|
181
|
+
was checkable and simply never checked. The platform read is uncached, unlike the dashboard one:
|
|
182
|
+
there is no tenant to scope a cache key by, and the population is small enough that a read per
|
|
183
|
+
call beats a keyspace no flow invalidates. It has no email-verification arm —
|
|
184
|
+
`emailVerification.required` gates tenant registration, and an administrator is provisioned.
|
|
185
|
+
|
|
186
|
+
**It fails closed when the platform repository is absent.** A deployment without
|
|
187
|
+
`controllers.platform` registers no repository and also mints no platform token, so that branch
|
|
188
|
+
answers a token which cannot have been issued there — which is exactly the case that must not be
|
|
189
|
+
waved through. Skipping a gate because its collaborator is missing is how a gate stops gating.
|
|
190
|
+
|
|
191
|
+
**Apply to a derived backend.** Nothing to do in the ordinary case: `UserStatusGuard` behaves
|
|
192
|
+
identically, `BymaxAuthModule` exports the new service, and `@UseGuards(UserStatusGuard)`
|
|
193
|
+
resolves exactly as before. **One narrow break:** the guard's constructor now takes a single
|
|
194
|
+
`AccountStatusService`, in place of the Redis service, the repository token and the options
|
|
195
|
+
token. If you register `UserStatusGuard` in your OWN module's `providers` rather than relying on
|
|
196
|
+
the auth module's export — or construct it directly in a test — list `AccountStatusService`
|
|
197
|
+
there and drop the three. A `useValue` double now needs one method,
|
|
198
|
+
`assertDashboardAccountUsable({ userId, tenantId })`, instead of a fake Redis and a fake
|
|
199
|
+
repository.
|
|
200
|
+
|
|
201
|
+
- **`afterPlatformLogout`, the first hook `PlatformAuthService` emits.** That service fired none at
|
|
202
|
+
all — it did not even receive the hooks provider — so a consumer holding a live platform stream
|
|
203
|
+
had no way to learn that the administrator behind it had signed out: the access token stayed
|
|
204
|
+
presentable until it expired and nothing observed the session's removal.
|
|
205
|
+
|
|
206
|
+
The platform **plane** was not silent, which is a narrower and more useful thing to know: it
|
|
207
|
+
already emits `afterLogin` from the platform branch of `MfaService.challenge`, and
|
|
208
|
+
`onRefreshTokenReuseDetected` from `TokenManagerService.reissuePlatformTokens`. What had no
|
|
209
|
+
signal was the logout, and only from this service.
|
|
210
|
+
|
|
211
|
+
Separate from `afterLogout` rather than sharing it, deliberately: an existing `afterLogout`
|
|
212
|
+
handler was written for dashboard users and may resolve a tenant, so routing platform events into
|
|
213
|
+
it would change what that handler receives without the handler asking. A new optional member is
|
|
214
|
+
additive and unambiguous.
|
|
215
|
+
|
|
216
|
+
- **`HookContext.plane`** — `'dashboard'` or `'platform'`, set on every context this library
|
|
217
|
+
builds. It exists because the tenant cannot answer that question: `MfaService` renders a platform
|
|
218
|
+
administrator as a `SafeAuthUser` carrying the sentinel `tenantId: ''` because the type demands
|
|
219
|
+
the field, while a platform access token has no tenant claim and reads `undefined`. A consumer
|
|
220
|
+
correlating a hook against a live connection by comparing those two matched nothing on the
|
|
221
|
+
platform plane and silently skipped every platform admin after an MFA enable, disable or
|
|
222
|
+
administrative reset. Branch on `plane` instead of on the shape of `tenantId`.
|
|
223
|
+
Every `HookContext` literal built under `src/server` carries it, including the one
|
|
224
|
+
`TokenManagerService.emitReuseDetected` hands to `onRefreshTokenReuseDetected`.
|
|
225
|
+
|
|
226
|
+
### Changed
|
|
227
|
+
|
|
228
|
+
- **Every `AuthEmailCatalogue` renderer now receives the tenant and the recipient.** The provider's
|
|
229
|
+
methods hold both (`tenantId`, and the address the message goes to), but the renderer that builds
|
|
230
|
+
the body was handed only its own fields, so a link built inside it could not carry `tenantId`: a
|
|
231
|
+
recipient opening it in a browser with no tenant cookie was refused by a `tenantIdResolver`. The
|
|
232
|
+
two workarounds are both bad, a field stashed on the singleton provider races across concurrent
|
|
233
|
+
requests and can put one tenant's link in another's mail, and re-implementing a renderer
|
|
234
|
+
re-implements its HTML escaping. All ten renderers now take an `AuthEmailContext`
|
|
235
|
+
(`{ tenantId, email, locale? }`, exported) together with their own fields, so any message that
|
|
236
|
+
builds a URL has the tenant and the recipient available. `email` is always
|
|
237
|
+
the address the message is delivered to: the new address for `emailChangeVerification`, the
|
|
238
|
+
previous one for `emailChanged`, which still receives `oldEmail` and `newEmail`. **Apply to a
|
|
239
|
+
derived backend:** a catalogue that implements these renderers keeps compiling, since a function
|
|
240
|
+
that reads fewer fields is assignable; read `tenantId` and `email` from the input where a URL
|
|
241
|
+
needs them.
|
|
242
|
+
|
|
243
|
+
- **`AuthTokenVerifierService` checks the account status before the MFA policy.** Both planes now
|
|
244
|
+
consult `assertDashboardAccountUsable` / `assertPlatformAccountUsable` first and only then
|
|
245
|
+
`requireMfa`. Only an account the status gate refuses, holding a token that predates its MFA
|
|
246
|
+
challenge, changes its error code, in two ways: a blocked account now receives the matching
|
|
247
|
+
`ACCOUNT_*` / `EMAIL_NOT_VERIFIED` code instead of `MFA_REQUIRED`, and a deleted account now
|
|
248
|
+
receives `TOKEN_INVALID` instead of `MFA_REQUIRED`. A usable account with a pending challenge
|
|
249
|
+
still receives `MFA_REQUIRED`, a missing or non-boolean `mfaEnabled` claim still answers
|
|
250
|
+
`TOKEN_INVALID` ahead of the lookup, and `checkStatus: false` still skips the lookup.
|
|
251
|
+
|
|
252
|
+
**Apply to a derived backend:** a client that branched on `MFA_REQUIRED` for a
|
|
253
|
+
blocked account must handle the `ACCOUNT_*` code there.
|
|
254
|
+
|
|
255
|
+
### Fixed
|
|
256
|
+
|
|
257
|
+
- **A store fault while deciding whether to fire `onLockout` no longer replaces the login
|
|
258
|
+
answer.** The two reads that exist only to feed the hook ran unguarded after the failure was
|
|
259
|
+
recorded, so a Redis error answered the request in place of `auth.invalid_credentials`. They are
|
|
260
|
+
now best-effort: an unreadable lock state skips the hook and logs one warning (the error class,
|
|
261
|
+
a masked address); an unreadable remaining time after a confirmed lock fires the hook with
|
|
262
|
+
`bruteForce.windowSeconds`. Recording the failure and the lockout pre-check still fail closed.
|
|
263
|
+
- **A request without a body to `POST …/mfa/setup` now behaves like an empty object instead of
|
|
264
|
+
answering 500.** The validation pipe returned a missing body as `undefined` to a handler that reads
|
|
265
|
+
`dto.password`; it now hands the handler an empty DTO, so the route answers exactly as it does for
|
|
266
|
+
`{}` (`auth.invalid_credentials` for an account with a password, success for an OAuth-only one).
|
|
267
|
+
The platform route and any DTO whose fields are all optional are covered by the same pipe.
|
|
268
|
+
|
|
269
|
+
- **A served OpenAPI document described every request body as `{}`.** This package is built without
|
|
270
|
+
the `@nestjs/swagger` CLI plugin, so `@nestjs/swagger` registered each of its DTOs as
|
|
271
|
+
`{"type":"object","properties":{}}` — valid, resolvable, and invisible to a dangling-`$ref`
|
|
272
|
+
sweep — and a client generated from the document typed `login(body: {})`. The contributor that
|
|
273
|
+
already describes the security posture now also offers the request-body schema of every DTO the
|
|
274
|
+
mounted controllers take, taken from `conformance/openapi-request-schemas.json` (compiled into the
|
|
275
|
+
bundle as a generated module, since `conformance/` is not published, with a gate that fails when
|
|
276
|
+
it differs from what the decorators produce). Only the controllers a deployment mounted
|
|
277
|
+
contribute, so a deployment without MFA, platform or invitations gets no unreferenced component. Measured in a scratch application
|
|
278
|
+
(outside this repository's suite) with `@bymax-one/nest-core` 1.6.1 and 1.6.3 over the package's
|
|
279
|
+
16 exported request DTOs: all 16 were empty before and carried their properties after, with
|
|
280
|
+
nothing reported as discarded. **Request schemas appear with `@bymax-one/nest-core` ≥ 1.6.1; older versions ignore the
|
|
281
|
+
contribution without a signal** — through 1.6.0 the empty placeholder wins and nothing reports it.
|
|
282
|
+
The two OAuth query DTOs are not request bodies and get no schema. No public export, option or
|
|
283
|
+
dependency is added; the server bundle grows by about 0.6 KiB brotli, and its size budget moves
|
|
284
|
+
from 122 to 129 KiB.
|
|
285
|
+
|
|
286
|
+
- **A refresh rotation dropped the second factor, locking every MFA user out of `MfaRequiredGuard`
|
|
287
|
+
routes at the first rotation.** The guard refuses a token whose claims say
|
|
288
|
+
`mfaEnabled && !mfaVerified`. A session that completed the MFA challenge carries
|
|
289
|
+
`mfaVerified: true`, but the refresh-session record stored only `mfaEnabled`, so every rotation
|
|
290
|
+
minted `mfaVerified: false`, and no route lets an authenticated session re-acquire the claim.
|
|
291
|
+
After `jwt.accessExpiresIn` the user was refused everywhere behind the guard until they signed in
|
|
292
|
+
again. The record now carries `mfaVerified`, written only as `true` and read back strictly (a
|
|
293
|
+
record without the field, or with any value other than the boolean `true`, reads as not
|
|
294
|
+
verified), and every rotation and grace-window recovery copies it forward on both planes. A
|
|
295
|
+
session opened without the challenge gains nothing, so no rotation can turn into a way around the
|
|
296
|
+
guard. This follows NIST SP 800-63B-4 §5: "A session SHOULD inherit the AAL properties of the
|
|
297
|
+
authentication event that triggered its creation"
|
|
298
|
+
(<https://pages.nist.gov/800-63-4/sp800-63b/session/>). Sessions already stored carry no field
|
|
299
|
+
and stay unverified until the user next completes the challenge. `conformance/wire-contract.json`
|
|
300
|
+
states the field under `refreshSession` (`optionalFields`), so `rust-auth` must carry the same.
|
|
301
|
+
|
|
302
|
+
- **The `uev:` key format was stated twice inside this library, and no test could see them
|
|
303
|
+
disagree.** `AccountStatusService` derived it; `AuthService.verifyEmail` hand-built the same
|
|
304
|
+
string inline to drop the flag after a verification. They agreed, and nothing kept them
|
|
305
|
+
agreeing — the consumer-facing risk this release fixes already existed one level in, between two
|
|
306
|
+
files in this package.
|
|
307
|
+
|
|
308
|
+
**The suites would have stayed green through the drift**, which is the part worth recording.
|
|
309
|
+
Each side was pinned by its own literal — `'uev:tenant-1:user-1'` in one spec,
|
|
310
|
+
`` `uev:tenant-1:${USER.id}` `` in the other — so changing the derivation would have been
|
|
311
|
+
absorbed by updating the spec that owns it, while the other stayed green against its unchanged
|
|
312
|
+
inline copy. Both passing, the two keys naming different entries, and a just-verified account
|
|
313
|
+
keeping a stale `0` until the TTL expired. Nothing fails; a user is simply locked out of the
|
|
314
|
+
routes they just earned.
|
|
315
|
+
|
|
316
|
+
`verifyEmail` now calls `invalidate` and the derivation lives in one place
|
|
317
|
+
(a module-private helper, deliberately not exported). The specs assert the delegation rather than
|
|
318
|
+
a key literal, which removes the second statement instead of pinning it, and a new test reads both
|
|
319
|
+
the write and the delete path and asserts they name the same keys.
|
|
320
|
+
|
|
321
|
+
**What that test guards, precisely.** With one derivation the two paths cannot disagree, so it
|
|
322
|
+
cannot fail on a format change — single-sourcing is what makes that unreachable, not the test.
|
|
323
|
+
What it catches is the reintroduction of a second statement: inline a key in either path, as
|
|
324
|
+
`verifyEmail` did, and it goes red. Verified that way rather than assumed — restoring an inline
|
|
325
|
+
derivation on one side turns it red, including on the delimiter and unicode cases.
|
|
326
|
+
|
|
327
|
+
The comment that stood where the inline key was had described this exact hazard — "the key must
|
|
328
|
+
be byte-identical to the guard's… or the delete misses" — and prevented none of it. It had also
|
|
329
|
+
gone stale within hours: it named the guard, which stopped building that key when
|
|
330
|
+
`AccountStatusService` was extracted.
|
|
331
|
+
|
|
332
|
+
**Apply to a derived backend.** Nothing changes for a consumer that uses `BymaxAuthModule` — the
|
|
333
|
+
service is registered and exported unconditionally, and every shipped flow resolves it through
|
|
334
|
+
the container.
|
|
335
|
+
|
|
336
|
+
**One narrow break:** `AuthService`'s constructor takes an additional `AccountStatusService` as
|
|
337
|
+
its last parameter, because `verifyEmail` now invalidates through it instead of naming the cache
|
|
338
|
+
key itself. That reaches you only if you construct `AuthService` yourself or provide it through a
|
|
339
|
+
custom factory rather than letting the module register it — add `AccountStatusService` to that
|
|
340
|
+
argument list, or to the `inject` array of your factory. A `useValue` double needs one method,
|
|
341
|
+
`invalidate({ userId, tenantId })`.
|
|
342
|
+
|
|
343
|
+
If you delete these cache keys yourself, replace that with
|
|
344
|
+
`AccountStatusService.invalidate({ userId, tenantId })`. Your delete works today and is not
|
|
345
|
+
guaranteed to keep working, and the day it stops there will be no error to notice.
|
|
346
|
+
|
|
347
|
+
- **Two hooks discarded the account scope they were holding.** `afterLogout` received an empty
|
|
348
|
+
`HookContext` and `onSessionEvicted` a context naming neither the user nor the tenant — in both
|
|
349
|
+
cases while the emitting method had both values in hand. `logout` reads `{ userId, tenantId }`
|
|
350
|
+
from `readSessionOwner` and keys its own session revoke on them; `enforceSessionLimit` takes
|
|
351
|
+
`userId` and `tenantId` as parameters. Neither value was ever unavailable.
|
|
352
|
+
|
|
353
|
+
**This is the same defect 1.4.4 fixed on `onRefreshTokenReuseDetected`**, whose entry noted that
|
|
354
|
+
the emit "built `createEmptyHookContext()` anyway". Two more sites had it and were missed then.
|
|
355
|
+
|
|
356
|
+
It costs more than tidiness, because of what these hooks are for. A consumer wiring them to
|
|
357
|
+
disconnect a user's live connections must match the **tenant as well as the id**: a repository id
|
|
358
|
+
is unique only within a tenant — `findById` takes one precisely because ids may collide — so
|
|
359
|
+
acting on a bare id drops another tenant's user, and repeated logouts in one tenant become a
|
|
360
|
+
denial of service against another. A hook that names only the id cannot be acted on safely, which
|
|
361
|
+
left the only correct response to it being to ignore it.
|
|
362
|
+
|
|
363
|
+
`ip` and `userAgent` stay empty on `afterLogout` deliberately: `logout` receives two tokens and no
|
|
364
|
+
request, so there is nothing to report and an invented value would be worse than an empty string
|
|
365
|
+
a consumer can see is empty. `tenantId` is omitted rather than set to `undefined` when the session
|
|
366
|
+
record predates the tenant-scoped write, so its absence reads as "the record did not say" rather
|
|
367
|
+
than as a tenant literally named `undefined`.
|
|
368
|
+
|
|
369
|
+
**Both specs asserted the context loosely, which is why this shipped.** One used
|
|
370
|
+
`expect.anything()` and the other `expect.objectContaining({ ip, userAgent })` — neither can
|
|
371
|
+
distinguish a populated context from an empty one, the exact weakness the 1.4.4 entry called out
|
|
372
|
+
on the hook it fixed. Both now pin the context exactly.
|
|
373
|
+
|
|
374
|
+
**The rest of the family was checked, and two sites are deliberately left alone.**
|
|
375
|
+
`afterEmailVerified` and `afterPasswordReset` pass a context carrying only `plane: 'dashboard'`;
|
|
376
|
+
their first argument is a `SafeAuthUser` carrying `id` and `tenantId`, so a consumer can already scope them and there
|
|
377
|
+
is no defect to fix. `onRefreshTokenReuseDetected` is the one real remainder: it names the account
|
|
378
|
+
in its `details` object but the tenant is genuinely not in scope at the emit — `emitReuseDetected`
|
|
379
|
+
receives no tenant — so scoping it means threading the
|
|
380
|
+
tenant down from its callers. That is a larger change than this one and is tracked separately
|
|
381
|
+
rather than smuggled in here.
|
|
382
|
+
|
|
383
|
+
**Apply to a derived backend.** Nothing breaks: the fields are additions to a context whose type
|
|
384
|
+
already declared them as optional. If you consume either hook, you can now scope its effect —
|
|
385
|
+
and if you disconnect sockets or invalidate caches on them, you should, because doing it on the
|
|
386
|
+
bare `userId` reaches other tenants' accounts.
|
|
387
|
+
|
|
388
|
+
- **`AuthProvider` invented a tenant, so `useAuth().login` and `useAuth().forgotPassword` could not
|
|
389
|
+
reach a multi-tenant deployment at all.** Both applied the literal fallback `'default'` when the
|
|
390
|
+
caller omitted `tenantId`, and there was no way to suppress it — passing `undefined` produced the
|
|
391
|
+
fallback too. Since 1.4.2 the server refuses **any** body naming a tenant when the deployment
|
|
392
|
+
configures `tenantIdResolver`, so every login through the hook answered `400 auth.validation`
|
|
393
|
+
with `details[0].field === 'tenantId'` before the credentials were read.
|
|
394
|
+
|
|
395
|
+
The refusal is correct and stays: it is what stops a caller from choosing the tenant its own
|
|
396
|
+
request is scoped to. The defect was one layer up — this library naming a tenant on the caller's
|
|
397
|
+
behalf, then sending the invented name to a server that had already been told not to accept one.
|
|
398
|
+
|
|
399
|
+
**A cross-layer regression inside a single package.** The server changed in 1.4.2 and `/client`
|
|
400
|
+
followed in 1.4.3, where `LoginInput.tenantId` became optional and `forgotPassword` learned to
|
|
401
|
+
spread the field so an absent tenant is an absent KEY rather than a present-but-undefined one.
|
|
402
|
+
`/react` was the layer that never followed, and it sat directly on top of the one that had. The
|
|
403
|
+
lesson generalises past this fix: a change to what the server accepts is not finished at the
|
|
404
|
+
transport client while a higher layer still constructs the body.
|
|
405
|
+
|
|
406
|
+
Both call sites now forward the caller's value exactly — omitted stays omitted, given is given —
|
|
407
|
+
using the spread `/client` already documents. That form is not a style preference here:
|
|
408
|
+
`exactOptionalPropertyTypes` is on, so assigning `tenantId: options?.tenantId` against an
|
|
409
|
+
optional property does not compile, and only an absent key survives `JSON.stringify` as an absent
|
|
410
|
+
wire field.
|
|
411
|
+
|
|
412
|
+
**The specs pinned the defect rather than the contract.** Both asserted the outgoing `'default'`,
|
|
413
|
+
so they passed for as long as the bug existed and would have failed had it been fixed. They now
|
|
414
|
+
pin the absence of the key itself — `'tenantId' in input` — because `toEqual` treats an
|
|
415
|
+
undefined-valued key as absent and therefore cannot tell a pass-through from a reintroduced
|
|
416
|
+
assignment.
|
|
417
|
+
|
|
418
|
+
`register` and `resetPassword` were checked and are untouched: both forward the caller's input
|
|
419
|
+
object unchanged, so a consumer can already omit the field.
|
|
420
|
+
|
|
421
|
+
**Apply to a derived backend.** No server change, and nothing to do if your deployment configures
|
|
422
|
+
`tenantIdResolver` — that is the case this repairs. **The change is breaking for the other
|
|
423
|
+
cohort:** a resolver-**less** single-tenant frontend that relied on the implicit `'default'` now
|
|
424
|
+
sends no tenant at all, so it receives the other arm of the same validation error — the one
|
|
425
|
+
reading `tenantId is required`. Two ways out, both one line: pass `{ tenantId: 'default' }` at
|
|
426
|
+
the `login` call sites and `forgotPassword(email, 'default')`, or configure
|
|
427
|
+
`tenantIdResolver: () => 'default'` on the module and delete the argument everywhere. Prefer the
|
|
428
|
+
resolver — it puts the answer in the deployment that owns it instead of in every component that
|
|
429
|
+
asks.
|
|
430
|
+
|
|
431
|
+
The alternative fix — special-casing `'default'` server-side — was rejected. It would accept a
|
|
432
|
+
client-supplied tenant under a resolver, which is precisely the hole 1.4.2 closed.
|
|
433
|
+
|
|
434
|
+
### Security
|
|
435
|
+
|
|
436
|
+
- **A WebSocket ticket expires no later than the access token that minted it.** A logout blacklists
|
|
437
|
+
the token's `jti` only for the token's remaining life, because nothing later can present that
|
|
438
|
+
token. A ticket minted from a token with a few seconds left still received the full 30, so the
|
|
439
|
+
blacklist entry expired with the token while the ticket stayed redeemable: the user's epoch is
|
|
440
|
+
unchanged, and the ticket redeemed although its session had ended. The lifetime is now the smaller
|
|
441
|
+
of 30 seconds and the token's remaining seconds less a one-second margin that covers the write
|
|
442
|
+
reaching Redis, and a token with no life left mints nothing (`auth.token_invalid`). The `expiresIn` that
|
|
443
|
+
`POST {prefix}/ws-ticket` returns is that capped value, in seconds. `conformance/wire-contract.json`
|
|
444
|
+
states the lifetime as "at most 30 s and never beyond the minting access token's own expiry".
|
|
445
|
+
**Apply to a derived backend:** cap the ticket's Redis TTL the same way when you mint, and report
|
|
446
|
+
the capped value as `expiresIn`; a client that assumed 30 seconds must read `expiresIn`.
|
|
447
|
+
|
|
448
|
+
- **A WebSocket ticket no longer outlives the session that minted it.** A ticket carried only
|
|
449
|
+
identity and account state, so one minted before a logout, a sign-out-everywhere, a password
|
|
450
|
+
change or an MFA reset still opened a socket for the rest of its 30 seconds, and a socket admitted
|
|
451
|
+
from it is authenticated once and never revalidated. The ticket now carries the `jti` and `epoch`
|
|
452
|
+
of the access token that minted it, and `WsTicketService.redeem` refuses it, with the same
|
|
453
|
+
`auth.token_invalid` as every other refusal, when that token is blacklisted or stamped below the
|
|
454
|
+
user's current epoch. This is the same two-channel check a bearer token gets at the handshake.
|
|
455
|
+
OWASP's WebSocket Security Cheat Sheet asks for exactly this: "Maintain a mapping of sessions to
|
|
456
|
+
active connections so you can invalidate WebSocket access the moment logout occurs"
|
|
457
|
+
(<https://cheatsheetseries.owasp.org/cheatsheets/WebSocket_Security_Cheat_Sheet.html>).
|
|
458
|
+
**Apply to a derived backend:** the stored `wst:` record gains two required fields, `jti` (a
|
|
459
|
+
non-empty string) and `epoch` (a non-negative integer, `0` when the token carried none); a record
|
|
460
|
+
missing either is no longer a ticket, so a ticket minted before the deploy, or by a backend that
|
|
461
|
+
does not yet write them, is refused at redemption. A ticket lives 30 seconds, so the effect is a
|
|
462
|
+
brief window in which a client that already holds one asks for a new one. `WsTicketSnapshot` gains the same two fields, and
|
|
463
|
+
`conformance/wire-contract.json` declares them. A logout
|
|
464
|
+
blacklists only the access token it was given and does not move the epoch, so a ticket minted
|
|
465
|
+
from an access token that a refresh had already replaced is not refused after that logout, as a
|
|
466
|
+
bearer token of that kind is not; it is refused only after a later epoch bump (a password reset or
|
|
467
|
+
change, an MFA enable, disable or reset, or revoking another session or all of them).
|
|
468
|
+
|
|
469
|
+
- **The `next` peer dependency floor is `^16.4.1`.** The previous floor, `^16.2.11`, admitted `next`
|
|
470
|
+
releases with published advisories: GHSA-673q-mjm6-r5xr and GHSA-2464-fhr4-w9xw (both critical,
|
|
471
|
+
unauthenticated remote code execution, fixed in 16.4.1 for the 16 line). A consumer of the
|
|
472
|
+
`./nextjs` subpath on `next` below 16.4.1 should upgrade `next`; `next` stays an optional peer,
|
|
473
|
+
so a deployment that does not use `./nextjs` is unaffected. A test holds the floor.
|
|
474
|
+
|
|
475
|
+
- **Rotating `jwt.secret` no longer has to reset the token epoch.** Without `identifierKey`, a
|
|
476
|
+
rotation renamed the epoch key, every epoch read zero, and an access token that a password reset
|
|
477
|
+
or a revoke-all had refused was accepted again until it expired. With `identifierKey` pinned
|
|
478
|
+
before the rotation the epoch survives it. Deployments that rotate should set it first; the
|
|
479
|
+
README guide says how, and what a rotation after a compromise should do instead.
|
|
480
|
+
|
|
481
|
+
- **`fast-uri` and `qs` floored above the 2026-09-02 advisories.** Resolved versions were
|
|
482
|
+
`fast-uri@3.1.5` and `qs@6.15.3`. Now `fast-uri@3.1.9` and `qs@6.17.0` (floors `^3.1.9` and `^6.16.1`). Severities and summaries
|
|
483
|
+
read per advisory rather than carried across as a group, because they are not one wave:
|
|
484
|
+
|
|
485
|
+
| advisory | severity | what it is |
|
|
486
|
+
| ------------------- | ---------- | ------------------------------------------------------------------------------------- |
|
|
487
|
+
| GHSA-5jgf-p345-68v8 | 7.5 high | `fast-uri` host confusion, skipped IDN canonicalization on scheme-relative references |
|
|
488
|
+
| GHSA-jqff-g426-hqxp | 7.5 high | `fast-uri` host confusion, percent-encoded scheme normalization |
|
|
489
|
+
| GHSA-f65p-4m7j-42xc | 7.5 high | `fast-uri` **SSRF**, malformed IPv6 normalization |
|
|
490
|
+
| GHSA-fph4-wmhf-6fwf | 7.5 high | `fast-uri` **SSRF**, repeated hostname percent-decoding |
|
|
491
|
+
| GHSA-4mjr-xmp4-gh2g | 5.3 medium | `qs` denial of service via attacker-controlled `isBuffer` |
|
|
492
|
+
| GHSA-x5fp-wj9c-mxmx | 3.7 low | `qs` array-limit bypass via bracket-key comma parsing |
|
|
493
|
+
|
|
494
|
+
Two of the four `fast-uri` advisories are SSRF rather than host confusion, and the `qs` pair is
|
|
495
|
+
5.3 and 3.7 rather than a single higher figure — both distinctions are lost by summarising a
|
|
496
|
+
batch, and a reader deciding urgency needs the per-ID numbers.
|
|
497
|
+
|
|
498
|
+
**How they reach this tree**, read from the lockfile rather than assumed: `qs` through `express`,
|
|
499
|
+
`body-parser`, `superagent` and `typed-rest-client`; `fast-uri` through `ajv`. Neither arrives via
|
|
500
|
+
`@stryker-mutator/core`.
|
|
501
|
+
|
|
502
|
+
`package.json` declares **no runtime dependencies at all**, so nothing this package publishes
|
|
503
|
+
carries either one. The floor is on this repository's own tree.
|
|
504
|
+
|
|
505
|
+
**It does not cover a consumer, and the reason matters.** `express` is a _peer_ dependency here,
|
|
506
|
+
so a consumer installs its own and resolves its own `qs` through it. An override is not published
|
|
507
|
+
— it applies to this lockfile and no other. A consumer wanting the same floor sets it in their
|
|
508
|
+
own workspace; reading this entry as protection they inherit would be the same mistake the entry
|
|
509
|
+
below documents.
|
|
510
|
+
|
|
511
|
+
**The `qs` entry is the finding worth keeping.** An override already existed —
|
|
512
|
+
`'qs@>=6.11.1 <=6.15.1': '>=6.15.2'` — and had stopped protecting anything. It fired once, the
|
|
513
|
+
resolved version moved to `6.15.3`, that left the selector's window, and the override silently
|
|
514
|
+
ceased to match. It still read in the config as coverage. **A selector-based override protects
|
|
515
|
+
against the advisory it was written for and nothing after it**, and nothing announces the moment
|
|
516
|
+
it stops applying. `fast-uri` had no override at all, so its appearance of coverage came from
|
|
517
|
+
nowhere in particular.
|
|
518
|
+
|
|
519
|
+
The only check that catches this is reading the **resolved** version in `pnpm-lock.yaml`. A
|
|
520
|
+
config range is a statement of intent, not of outcome.
|
|
521
|
+
|
|
522
|
+
**Swept the rest of the family rather than fixing only the two reported.** The remaining selector
|
|
523
|
+
overrides — `esbuild`, `postcss`, `tmp`, `ws` — resolve above their bounds today and are inert:
|
|
524
|
+
harmless now, and the same shape that made `qs` dangerous, since each will read as protection and
|
|
525
|
+
provide none the moment an advisory names a range above its bound. `brace-expansion` (major 5) and
|
|
526
|
+
`sharp` were re-floored by the later OSV sweep below and are active.
|
|
527
|
+
|
|
528
|
+
**Apply to a derived backend.** Check your own resolved versions. This package publishes no
|
|
529
|
+
runtime dependencies, so nothing here reaches you through it — but `express` is a peer, and your
|
|
530
|
+
own `express` brings its own `qs`. Floor it in your workspace if your resolution is below
|
|
531
|
+
`6.16.1`; our override cannot do it for you.
|
|
532
|
+
|
|
533
|
+
- **OSV advisories in the dev tree cleared.** Advisories in the
|
|
534
|
+
`pnpm-lock.yaml` transitive dev tree. Overrides now floor `fast-uri@3` at `^3.1.9`, `qs` at
|
|
535
|
+
`^6.16.1`, `sharp` at `>=0.35.5` and `brace-expansion@5` at `^5.0.12` (scoped to major 5, because
|
|
536
|
+
forcing every line onto 5.x broke `minimatch.braceExpand`), and add `body-parser@2`, `engine.io@6`,
|
|
537
|
+
`handlebars@4`, `js-yaml@3`/`4`, `multer@2`, `proxy-addr@2`, `source-map-js@1` and `zod@4`.
|
|
538
|
+
Dev-only `next` is raised to `^16.4.3`. `GHSA-gcqx-w48m-w2h4` (`deepmerge`, no patched release,
|
|
539
|
+
reached only through `jest-config`) is ignored in `osv-scanner.toml` until 2027-01-27. No
|
|
540
|
+
`peerDependencies` change and nothing under `src/`; the published package has no runtime
|
|
541
|
+
dependencies.
|
|
542
|
+
|
|
543
|
+
### Documentation
|
|
544
|
+
|
|
545
|
+
- **The proxy route lists say how an entry matches, and two examples no longer mislead.** An entry
|
|
546
|
+
matches the path equal to it and anything under it, takes no wildcards, and a `'/'` entry is a
|
|
547
|
+
plain prefix that matches every path. In `publicRoutes` that never opens a protected route
|
|
548
|
+
(protected patterns are tried first); in `publicRoutesRedirectIfAuthenticated` it redirects a
|
|
549
|
+
signed-in user away from every unprotected page. The specification's `'/auth/*'` public route
|
|
550
|
+
(which matches nothing) is now `'/auth'`, and the redirect examples in the guide and the
|
|
551
|
+
specification no longer list `'/'`. Text and tests only: the matcher is unchanged.
|
|
552
|
+
|
|
553
|
+
- **`conformance/wire-contract.json` names the key the token epoch is stored under.**
|
|
554
|
+
`accessTokenClaims.epoch.storedUnder` now reads `{ep|pep}:{hmac_sha256(hmacKey, userSubject)}`,
|
|
555
|
+
the derived key the epoch is written to, instead of the bare `{ep|pep}:{userId}`. Text only: the
|
|
556
|
+
key the library derives is unchanged.
|
|
557
|
+
|
|
558
|
+
## [1.4.5] - 2026-08-29
|
|
559
|
+
|
|
560
|
+
### Added
|
|
561
|
+
|
|
562
|
+
- **`AuthRevocationService` now warns when it refuses a dashboard token for carrying no tenant.**
|
|
563
|
+
1.4.4 made that case fail closed, which was the right call and is unchanged. What it did not do
|
|
564
|
+
is say so: the refusal answers the same `true` a genuinely revoked token answers, reads nothing,
|
|
565
|
+
throws nothing and emits no event, so it is indistinguishable from a revocation that worked.
|
|
566
|
+
|
|
567
|
+
Measured on the caller the 1.4.4 entry names. A consumer's realtime bridge called
|
|
568
|
+
`isAccessTokenRevoked({ jti, sub, epoch }, 'dashboard')` without the tenant; the SSE handshake
|
|
569
|
+
answered `200` and then registered nothing, and the connection registry sat at `count: 0` while
|
|
570
|
+
every stream was silently refused. It reads as a realtime bug rather than an auth one, and every
|
|
571
|
+
gate agreed with that reading: `tsc` passes because `tenantId` is optional on
|
|
572
|
+
`RevocableTokenPayload`, and a unit suite passes at 100% mutation score while asserting the
|
|
573
|
+
forwarded payload is exactly `{ jti, sub, epoch }` — a faithful test of a contract that had moved
|
|
574
|
+
underneath it. Twenty minutes of bisecting, ended by a log line that costs two.
|
|
575
|
+
|
|
576
|
+
The message names the missing field and the remedy, and says the refusal is deliberate so it is
|
|
577
|
+
not filed as a library bug. No identifier is logged: `sub` names an account and `jti` a live
|
|
578
|
+
token, and neither is needed to act on it.
|
|
579
|
+
|
|
580
|
+
**The tenant check also moved ahead of the per-token blacklist read**, which validates the input
|
|
581
|
+
before consulting a channel. The answer is unchanged — `true` either way, indistinguishable to a
|
|
582
|
+
caller — but behind the blacklist read the warn fired only for a token that happened not to be
|
|
583
|
+
blacklisted, so a bridge calling this wrongly on every request could go on doing so unheard, the
|
|
584
|
+
diagnostic coming and going with unrelated state. It also spares a Redis round trip on a request
|
|
585
|
+
that is already refused, and makes "without a store read" true of the path rather than nearly
|
|
586
|
+
true.
|
|
587
|
+
|
|
588
|
+
**A distinct error code was considered and rejected.** `isAccessTokenRevoked` returns a boolean
|
|
589
|
+
and the three guards turn it into a refusal, so giving this case its own `AuthErrorCode` means
|
|
590
|
+
widening the return of an exported service and threading it through all three — and an `auth.*`
|
|
591
|
+
code is wire vocabulary, so it would answer an unauthenticated client with a detail about the
|
|
592
|
+
deployment's own wiring that today's refusal does not leak. The operator's log is the one place
|
|
593
|
+
that can act on it.
|
|
594
|
+
|
|
595
|
+
**Apply to a derived backend.** Nothing to do — behaviour is unchanged, and the only new output
|
|
596
|
+
is a `warn` on a path that was already refusing. If it appears in your logs, a caller is reaching
|
|
597
|
+
the service without the tenant from its verified token; fix the caller rather than the log, and
|
|
598
|
+
consider typing the tenant as REQUIRED on your own port so the omission cannot recur.
|
|
599
|
+
|
|
600
|
+
- **`AuthRevocationService` is documented in the README**, under the API reference. It has been a
|
|
601
|
+
public export since it was extracted from the three JWT guards, and the README never mentioned it
|
|
602
|
+
— so the one thing a caller outside a guard has to know, that a dashboard check must forward
|
|
603
|
+
`tenantId` from the verified token, was reachable only from the JSDoc or from this changelog.
|
|
604
|
+
That is the omission the entry above was measured on. The new section names both revocation
|
|
605
|
+
channels, states the tenant obligation as a requirement rather than a note, and describes the
|
|
606
|
+
symptom to recognise — `true` with nothing thrown, a stream that registers nothing — because it
|
|
607
|
+
does not read as an auth bug from the transport side.
|
|
608
|
+
|
|
609
|
+
It also says what the method is **not**: it answers two channels at the moment it is called, and
|
|
610
|
+
reads no `exp`, holds no subscription, emits no event, and knows nothing about account status,
|
|
611
|
+
roles, tenant binding or the identity plane. It is one check among the many a guarded route
|
|
612
|
+
performs, not a way to authorise a stream.
|
|
613
|
+
|
|
614
|
+
**Guidance on doing that safely was drafted and withdrawn**, and the reasoning is worth recording
|
|
615
|
+
because it is a statement about the library rather than about the prose. Seven successive drafts
|
|
616
|
+
were each found wrong by review — a recipe that would have admitted a pre-MFA token, a bare-id
|
|
617
|
+
fan-out reintroducing the cross-tenant defect 1.4.4 removed, a reconnect that carries neither
|
|
618
|
+
route authorization nor `enforceTenantBinding`, and mitigations that cannot reach a
|
|
619
|
+
ticket-authenticated platform socket at all. The through-line is that this library does not
|
|
620
|
+
export the pieces a consumer would need, so the documentation was describing a hand-rolled
|
|
621
|
+
reproduction of a security chain that has no supported form. That belongs in an issue with the
|
|
622
|
+
gaps named, not in a release: [#172](https://github.com/bymaxone/nest-auth/issues/172).
|
|
623
|
+
|
|
21
624
|
## [1.4.4] - 2026-08-19
|
|
22
625
|
|
|
23
626
|
### Changed
|
|
@@ -2113,8 +2716,10 @@ follows it. For a rolling upgrade this release dual-writes the anti-replay marke
|
|
|
2113
2716
|
failure counters (every read consults both the old plane-only key and the new tenant-scoped key,
|
|
2114
2717
|
every write touches both) and dual-acquires the transition lock, so old and new pods stay
|
|
2115
2718
|
consistent while both are live. A later release drops the legacy arm; deploying it before this one
|
|
2116
|
-
has fully rolled out would split the anti-replay and lockout state across the two key shapes.
|
|
2117
|
-
|
|
2719
|
+
has fully rolled out would split the anti-replay and lockout state across the two key shapes. Host
|
|
2720
|
+
code changes: every `IUserRepository.updateMfa` implementation takes the tenant and scopes its
|
|
2721
|
+
write by it, and any direct dashboard call into `MfaService` passes one. The tenant is sourced from
|
|
2722
|
+
the authenticated account, never from the request.
|
|
2118
2723
|
|
|
2119
2724
|
## [1.3.1] - 2026-08-08
|
|
2120
2725
|
|
|
@@ -3382,7 +3987,9 @@ ever installable.
|
|
|
3382
3987
|
- 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
|
|
3383
3988
|
- 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
|
|
3384
3989
|
|
|
3385
|
-
[Unreleased]: https://github.com/bymaxone/nest-auth/compare/v1.4.
|
|
3990
|
+
[Unreleased]: https://github.com/bymaxone/nest-auth/compare/v1.4.6...HEAD
|
|
3991
|
+
[1.4.6]: https://github.com/bymaxone/nest-auth/compare/v1.4.5...v1.4.6
|
|
3992
|
+
[1.4.5]: https://github.com/bymaxone/nest-auth/compare/v1.4.4...v1.4.5
|
|
3386
3993
|
[1.4.4]: https://github.com/bymaxone/nest-auth/compare/v1.4.3...v1.4.4
|
|
3387
3994
|
[1.4.3]: https://github.com/bymaxone/nest-auth/compare/v1.4.2...v1.4.3
|
|
3388
3995
|
[1.4.2]: https://github.com/bymaxone/nest-auth/compare/v1.4.1...v1.4.2
|