@bymax-one/nest-auth 1.4.9 → 1.4.10
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 +30 -1
- package/dist/server/index.cjs +7 -7
- package/dist/server/index.d.cts +2 -2
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.mjs +7 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -18,6 +18,34 @@ what moves, and that note is the compatibility contract until strict SemVer begi
|
|
|
18
18
|
|
|
19
19
|
## [Unreleased]
|
|
20
20
|
|
|
21
|
+
## [1.4.10] - 2026-11-01
|
|
22
|
+
|
|
23
|
+
### Apply to a derived backend
|
|
24
|
+
|
|
25
|
+
- **The account-status cache keys no longer carry the tenant and user id.** The `us:` (status) and
|
|
26
|
+
`uev:` (email-verified) entries were keyed by the percent-encoded tenant and user id; they are now
|
|
27
|
+
keyed by `HMAC-SHA-256(hmacKey, userSubject)` of the tenant-scoped dashboard subject, like the
|
|
28
|
+
session index, the token epoch and every other key that names an account. Both entries are
|
|
29
|
+
TTL'd cache values, so nothing needs migrating: the first read after the change misses and
|
|
30
|
+
refills. **Do not name these keys yourself**; `AccountStatusService.invalidate` is the supported
|
|
31
|
+
way to drop them and it already derives the new shape. A deployment that runs the old and the new
|
|
32
|
+
release side by side (a rolling deploy, or another backend on the old shape sharing the store)
|
|
33
|
+
can serve a changed status stale for **up to `userStatusCacheTtlSeconds`** (60 s by default),
|
|
34
|
+
because an invalidation issued by one side deletes a key the other does not read, and pays one
|
|
35
|
+
extra repository read per account. Drain the old release before the new one serves to avoid even
|
|
36
|
+
that.
|
|
37
|
+
|
|
38
|
+
### Security
|
|
39
|
+
|
|
40
|
+
- The status cache no longer writes account identifiers into Redis keys in the clear.
|
|
41
|
+
|
|
42
|
+
### Documentation
|
|
43
|
+
|
|
44
|
+
- **The account-status cache is part of the shared wire contract.** `conformance/wire-contract.json`
|
|
45
|
+
declares the `us` and `uev` prefixes and a `userStatusCache` section: the key derivation, the
|
|
46
|
+
value forms, the TTL source and the invalidation order (verified entry first), with vectors for
|
|
47
|
+
delimiter-bearing and multi-byte ids. A conformance test pins the library's behaviour to it.
|
|
48
|
+
|
|
21
49
|
## [1.4.9] - 2026-11-01
|
|
22
50
|
|
|
23
51
|
### Apply to a derived backend
|
|
@@ -4095,7 +4123,8 @@ ever installable.
|
|
|
4095
4123
|
- 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
|
|
4096
4124
|
- 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
|
|
4097
4125
|
|
|
4098
|
-
[Unreleased]: https://github.com/bymaxone/nest-auth/compare/v1.4.
|
|
4126
|
+
[Unreleased]: https://github.com/bymaxone/nest-auth/compare/v1.4.10...HEAD
|
|
4127
|
+
[1.4.10]: https://github.com/bymaxone/nest-auth/compare/v1.4.9...v1.4.10
|
|
4099
4128
|
[1.4.9]: https://github.com/bymaxone/nest-auth/compare/v1.4.8...v1.4.9
|
|
4100
4129
|
[1.4.8]: https://github.com/bymaxone/nest-auth/compare/v1.4.6...v1.4.8
|
|
4101
4130
|
[1.4.6]: https://github.com/bymaxone/nest-auth/compare/v1.4.5...v1.4.6
|
package/dist/server/index.cjs
CHANGED
|
@@ -3872,11 +3872,11 @@ function _ts_param7(paramIndex, decorator) {
|
|
|
3872
3872
|
};
|
|
3873
3873
|
}
|
|
3874
3874
|
__name(_ts_param7, "_ts_param");
|
|
3875
|
-
function cacheKeysFor(ref) {
|
|
3876
|
-
const
|
|
3875
|
+
function cacheKeysFor(ref, hmacKey) {
|
|
3876
|
+
const digest = hmacSha256(userSubject("dashboard", ref.userId, ref.tenantId), hmacKey);
|
|
3877
3877
|
return {
|
|
3878
|
-
statusKey: `us:${
|
|
3879
|
-
verifiedKey: `uev:${
|
|
3878
|
+
statusKey: `us:${digest}`,
|
|
3879
|
+
verifiedKey: `uev:${digest}`
|
|
3880
3880
|
};
|
|
3881
3881
|
}
|
|
3882
3882
|
__name(cacheKeysFor, "cacheKeysFor");
|
|
@@ -3934,7 +3934,7 @@ exports.AccountStatusService = class AccountStatusService {
|
|
|
3934
3934
|
*
|
|
3935
3935
|
* @param ref - The account whose cached facts are now stale. Both fields must be non-empty.
|
|
3936
3936
|
* @throws {TypeError} When either id is empty or blank. Refused rather than attempted: an empty
|
|
3937
|
-
* tenant
|
|
3937
|
+
* tenant derives a subject no read ever wrote, so the delete would
|
|
3938
3938
|
* remove nothing and resolve normally — the caller's admin surface reports the suspension
|
|
3939
3939
|
* applied while the cached `active` survives its full TTL. That is the exact silent failure
|
|
3940
3940
|
* this method exists to eliminate, and an unset resolver value or a `undefined` coerced by a
|
|
@@ -3944,7 +3944,7 @@ exports.AccountStatusService = class AccountStatusService {
|
|
|
3944
3944
|
if (ref.userId.trim() === "" || ref.tenantId.trim() === "") {
|
|
3945
3945
|
throw new TypeError("invalidate: userId and tenantId must both be non-empty");
|
|
3946
3946
|
}
|
|
3947
|
-
const { statusKey, verifiedKey } = cacheKeysFor(ref);
|
|
3947
|
+
const { statusKey, verifiedKey } = cacheKeysFor(ref, this.options.hmacKey);
|
|
3948
3948
|
await this.redis.del(verifiedKey);
|
|
3949
3949
|
await this.redis.del(statusKey);
|
|
3950
3950
|
}
|
|
@@ -3961,7 +3961,7 @@ exports.AccountStatusService = class AccountStatusService {
|
|
|
3961
3961
|
*/
|
|
3962
3962
|
async assertDashboardAccountUsable(ref) {
|
|
3963
3963
|
const { userId, tenantId } = ref;
|
|
3964
|
-
const { statusKey, verifiedKey } = cacheKeysFor(ref);
|
|
3964
|
+
const { statusKey, verifiedKey } = cacheKeysFor(ref, this.options.hmacKey);
|
|
3965
3965
|
const cacheTtl = this.options.userStatusCacheTtlSeconds;
|
|
3966
3966
|
const requireVerified = this.options.emailVerification.required;
|
|
3967
3967
|
let status = await this.redis.get(statusKey);
|
package/dist/server/index.d.cts
CHANGED
|
@@ -5674,7 +5674,7 @@ declare class TrustedOriginGuard implements CanActivate {
|
|
|
5674
5674
|
* request — an access token's whole lifetime, a stream held open for hours — therefore has to ask
|
|
5675
5675
|
* again, which is what this service exists to do.
|
|
5676
5676
|
*
|
|
5677
|
-
* It reads through a Redis cache (`us
|
|
5677
|
+
* It reads through a Redis cache (`us:` for the status and `uev:` for the verified flag, each keyed by the account)
|
|
5678
5678
|
* rather than the repository, so asking on every request or on every reconnect costs one `get`
|
|
5679
5679
|
* rather than a database round trip. A miss resolves both facts from a single tenant-scoped read
|
|
5680
5680
|
* and writes both back for `userStatusCacheTtlSeconds`.
|
|
@@ -5731,7 +5731,7 @@ declare class AccountStatusService {
|
|
|
5731
5731
|
*
|
|
5732
5732
|
* @param ref - The account whose cached facts are now stale. Both fields must be non-empty.
|
|
5733
5733
|
* @throws {TypeError} When either id is empty or blank. Refused rather than attempted: an empty
|
|
5734
|
-
* tenant
|
|
5734
|
+
* tenant derives a subject no read ever wrote, so the delete would
|
|
5735
5735
|
* remove nothing and resolve normally — the caller's admin surface reports the suspension
|
|
5736
5736
|
* applied while the cached `active` survives its full TTL. That is the exact silent failure
|
|
5737
5737
|
* this method exists to eliminate, and an unset resolver value or a `undefined` coerced by a
|
package/dist/server/index.d.ts
CHANGED
|
@@ -5674,7 +5674,7 @@ declare class TrustedOriginGuard implements CanActivate {
|
|
|
5674
5674
|
* request — an access token's whole lifetime, a stream held open for hours — therefore has to ask
|
|
5675
5675
|
* again, which is what this service exists to do.
|
|
5676
5676
|
*
|
|
5677
|
-
* It reads through a Redis cache (`us
|
|
5677
|
+
* It reads through a Redis cache (`us:` for the status and `uev:` for the verified flag, each keyed by the account)
|
|
5678
5678
|
* rather than the repository, so asking on every request or on every reconnect costs one `get`
|
|
5679
5679
|
* rather than a database round trip. A miss resolves both facts from a single tenant-scoped read
|
|
5680
5680
|
* and writes both back for `userStatusCacheTtlSeconds`.
|
|
@@ -5731,7 +5731,7 @@ declare class AccountStatusService {
|
|
|
5731
5731
|
*
|
|
5732
5732
|
* @param ref - The account whose cached facts are now stale. Both fields must be non-empty.
|
|
5733
5733
|
* @throws {TypeError} When either id is empty or blank. Refused rather than attempted: an empty
|
|
5734
|
-
* tenant
|
|
5734
|
+
* tenant derives a subject no read ever wrote, so the delete would
|
|
5735
5735
|
* remove nothing and resolve normally — the caller's admin surface reports the suspension
|
|
5736
5736
|
* applied while the cached `active` survives its full TTL. That is the exact silent failure
|
|
5737
5737
|
* this method exists to eliminate, and an unset resolver value or a `undefined` coerced by a
|
package/dist/server/index.mjs
CHANGED
|
@@ -3870,11 +3870,11 @@ function _ts_param7(paramIndex, decorator) {
|
|
|
3870
3870
|
};
|
|
3871
3871
|
}
|
|
3872
3872
|
__name(_ts_param7, "_ts_param");
|
|
3873
|
-
function cacheKeysFor(ref) {
|
|
3874
|
-
const
|
|
3873
|
+
function cacheKeysFor(ref, hmacKey) {
|
|
3874
|
+
const digest = hmacSha256(userSubject("dashboard", ref.userId, ref.tenantId), hmacKey);
|
|
3875
3875
|
return {
|
|
3876
|
-
statusKey: `us:${
|
|
3877
|
-
verifiedKey: `uev:${
|
|
3876
|
+
statusKey: `us:${digest}`,
|
|
3877
|
+
verifiedKey: `uev:${digest}`
|
|
3878
3878
|
};
|
|
3879
3879
|
}
|
|
3880
3880
|
__name(cacheKeysFor, "cacheKeysFor");
|
|
@@ -3932,7 +3932,7 @@ var AccountStatusService = class {
|
|
|
3932
3932
|
*
|
|
3933
3933
|
* @param ref - The account whose cached facts are now stale. Both fields must be non-empty.
|
|
3934
3934
|
* @throws {TypeError} When either id is empty or blank. Refused rather than attempted: an empty
|
|
3935
|
-
* tenant
|
|
3935
|
+
* tenant derives a subject no read ever wrote, so the delete would
|
|
3936
3936
|
* remove nothing and resolve normally — the caller's admin surface reports the suspension
|
|
3937
3937
|
* applied while the cached `active` survives its full TTL. That is the exact silent failure
|
|
3938
3938
|
* this method exists to eliminate, and an unset resolver value or a `undefined` coerced by a
|
|
@@ -3942,7 +3942,7 @@ var AccountStatusService = class {
|
|
|
3942
3942
|
if (ref.userId.trim() === "" || ref.tenantId.trim() === "") {
|
|
3943
3943
|
throw new TypeError("invalidate: userId and tenantId must both be non-empty");
|
|
3944
3944
|
}
|
|
3945
|
-
const { statusKey, verifiedKey } = cacheKeysFor(ref);
|
|
3945
|
+
const { statusKey, verifiedKey } = cacheKeysFor(ref, this.options.hmacKey);
|
|
3946
3946
|
await this.redis.del(verifiedKey);
|
|
3947
3947
|
await this.redis.del(statusKey);
|
|
3948
3948
|
}
|
|
@@ -3959,7 +3959,7 @@ var AccountStatusService = class {
|
|
|
3959
3959
|
*/
|
|
3960
3960
|
async assertDashboardAccountUsable(ref) {
|
|
3961
3961
|
const { userId, tenantId } = ref;
|
|
3962
|
-
const { statusKey, verifiedKey } = cacheKeysFor(ref);
|
|
3962
|
+
const { statusKey, verifiedKey } = cacheKeysFor(ref, this.options.hmacKey);
|
|
3963
3963
|
const cacheTtl = this.options.userStatusCacheTtlSeconds;
|
|
3964
3964
|
const requireVerified = this.options.emailVerification.required;
|
|
3965
3965
|
let status = await this.redis.get(statusKey);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bymax-one/nest-auth",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.10",
|
|
4
4
|
"description": "Full-stack authentication and authorization package for NestJS, React and Next.js — JWT, MFA, OAuth, sessions, multi-tenant SaaS ready",
|
|
5
5
|
"author": "Bymax One <support@bymax.one>",
|
|
6
6
|
"license": "MIT",
|