@bymax-one/nest-auth 1.4.8 → 1.4.9
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 +21 -1
- package/dist/server/index.cjs +26 -0
- package/dist/server/index.d.cts +11 -0
- package/dist/server/index.d.ts +11 -0
- package/dist/server/index.mjs +26 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -18,6 +18,25 @@ what moves, and that note is the compatibility contract until strict SemVer begi
|
|
|
18
18
|
|
|
19
19
|
## [Unreleased]
|
|
20
20
|
|
|
21
|
+
## [1.4.9] - 2026-11-01
|
|
22
|
+
|
|
23
|
+
### Apply to a derived backend
|
|
24
|
+
|
|
25
|
+
- **`invite` can now answer `auth.insufficient_role` when the invitee index moved under it.** The
|
|
26
|
+
index is claimed before the record is written, and a revoke or a later invite landing in that gap
|
|
27
|
+
used to leave a redeemable record that nothing named, with the email already sent. `invite` now
|
|
28
|
+
repeats the claim after the write; if the index no longer names the invitation, it withdraws its
|
|
29
|
+
own record, sends no email and answers `auth.insufficient_role`, the code a lost supersede race
|
|
30
|
+
already used. A store failure on that repeat withdraws the record too and surfaces unchanged.
|
|
31
|
+
Nothing changes for an invite that is not racing a revoke.
|
|
32
|
+
|
|
33
|
+
### Fixed
|
|
34
|
+
|
|
35
|
+
- **A revoke landing between the index claim and the record write left an orphan invitation.** The
|
|
36
|
+
invitation was redeemable for its whole TTL, the email was sent, and no later revoke could reach
|
|
37
|
+
it. The index TTL also started at the claim and the record's at the write, so the record outlived
|
|
38
|
+
the entry that names it; the repeated claim renews the index TTL after the write.
|
|
39
|
+
|
|
21
40
|
## [1.4.8] - 2026-10-31
|
|
22
41
|
|
|
23
42
|
### Apply to a derived backend
|
|
@@ -4076,7 +4095,8 @@ ever installable.
|
|
|
4076
4095
|
- 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
|
|
4077
4096
|
- 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
|
|
4078
4097
|
|
|
4079
|
-
[Unreleased]: https://github.com/bymaxone/nest-auth/compare/v1.4.
|
|
4098
|
+
[Unreleased]: https://github.com/bymaxone/nest-auth/compare/v1.4.9...HEAD
|
|
4099
|
+
[1.4.9]: https://github.com/bymaxone/nest-auth/compare/v1.4.8...v1.4.9
|
|
4080
4100
|
[1.4.8]: https://github.com/bymaxone/nest-auth/compare/v1.4.6...v1.4.8
|
|
4081
4101
|
[1.4.6]: https://github.com/bymaxone/nest-auth/compare/v1.4.5...v1.4.6
|
|
4082
4102
|
[1.4.5]: https://github.com/bymaxone/nest-auth/compare/v1.4.4...v1.4.5
|
package/dist/server/index.cjs
CHANGED
|
@@ -8766,6 +8766,17 @@ exports.InvitationService = class _InvitationService {
|
|
|
8766
8766
|
await this.redis.del(`inv:${supersededHash}`);
|
|
8767
8767
|
}
|
|
8768
8768
|
await this.redis.set(tokenKey, JSON.stringify(stored), ttl);
|
|
8769
|
+
let stillNamed;
|
|
8770
|
+
try {
|
|
8771
|
+
stillNamed = await this.claimInviteeIndex(normalizedEmail, tenantId, tokenHash, ttl, tokenHash);
|
|
8772
|
+
} catch (err) {
|
|
8773
|
+
await this.withdrawRecord(tokenKey);
|
|
8774
|
+
throw err;
|
|
8775
|
+
}
|
|
8776
|
+
if (!stillNamed.claimed) {
|
|
8777
|
+
await this.withdrawRecord(tokenKey);
|
|
8778
|
+
throw new AuthException(AUTH_ERROR_CODES.INSUFFICIENT_ROLE);
|
|
8779
|
+
}
|
|
8769
8780
|
const displayTenantName = tenantName ?? tenantId;
|
|
8770
8781
|
const expiresAt = new Date(Date.now() + ttl * 1e3);
|
|
8771
8782
|
try {
|
|
@@ -8892,6 +8903,21 @@ exports.InvitationService = class _InvitationService {
|
|
|
8892
8903
|
throw new AuthException(AUTH_ERROR_CODES.INSUFFICIENT_ROLE);
|
|
8893
8904
|
}
|
|
8894
8905
|
/**
|
|
8906
|
+
* Removes the invitation record this call wrote, best-effort.
|
|
8907
|
+
*
|
|
8908
|
+
* Used where the call is already ending in a refusal or a failure of its own, so a failing
|
|
8909
|
+
* delete must not replace that outcome: it is logged and the caller still raises the original.
|
|
8910
|
+
* The raw token has not been emailed at that point, so a record that survives is one nobody
|
|
8911
|
+
* holds the token for, until its TTL.
|
|
8912
|
+
*
|
|
8913
|
+
* @param tokenKey - The Redis key of the record written by this call.
|
|
8914
|
+
*/
|
|
8915
|
+
async withdrawRecord(tokenKey) {
|
|
8916
|
+
await this.redis.del(tokenKey).catch((err) => {
|
|
8917
|
+
this.logger.warn(`invite: could not withdraw the record \u2014 ${describeChannelStatus(err)}`);
|
|
8918
|
+
});
|
|
8919
|
+
}
|
|
8920
|
+
/**
|
|
8895
8921
|
* Atomically points the invitee index at `tokenHash`, answering with the hash it displaced.
|
|
8896
8922
|
*
|
|
8897
8923
|
* A compare-and-swap, not a plain write: the claim proceeds only when the index still holds
|
package/dist/server/index.d.cts
CHANGED
|
@@ -9319,6 +9319,17 @@ declare class InvitationService {
|
|
|
9319
9319
|
* allowed to destroy whatever is there now.
|
|
9320
9320
|
*/
|
|
9321
9321
|
private supersedeApprovedInvitation;
|
|
9322
|
+
/**
|
|
9323
|
+
* Removes the invitation record this call wrote, best-effort.
|
|
9324
|
+
*
|
|
9325
|
+
* Used where the call is already ending in a refusal or a failure of its own, so a failing
|
|
9326
|
+
* delete must not replace that outcome: it is logged and the caller still raises the original.
|
|
9327
|
+
* The raw token has not been emailed at that point, so a record that survives is one nobody
|
|
9328
|
+
* holds the token for, until its TTL.
|
|
9329
|
+
*
|
|
9330
|
+
* @param tokenKey - The Redis key of the record written by this call.
|
|
9331
|
+
*/
|
|
9332
|
+
private withdrawRecord;
|
|
9322
9333
|
/**
|
|
9323
9334
|
* Atomically points the invitee index at `tokenHash`, answering with the hash it displaced.
|
|
9324
9335
|
*
|
package/dist/server/index.d.ts
CHANGED
|
@@ -9319,6 +9319,17 @@ declare class InvitationService {
|
|
|
9319
9319
|
* allowed to destroy whatever is there now.
|
|
9320
9320
|
*/
|
|
9321
9321
|
private supersedeApprovedInvitation;
|
|
9322
|
+
/**
|
|
9323
|
+
* Removes the invitation record this call wrote, best-effort.
|
|
9324
|
+
*
|
|
9325
|
+
* Used where the call is already ending in a refusal or a failure of its own, so a failing
|
|
9326
|
+
* delete must not replace that outcome: it is logged and the caller still raises the original.
|
|
9327
|
+
* The raw token has not been emailed at that point, so a record that survives is one nobody
|
|
9328
|
+
* holds the token for, until its TTL.
|
|
9329
|
+
*
|
|
9330
|
+
* @param tokenKey - The Redis key of the record written by this call.
|
|
9331
|
+
*/
|
|
9332
|
+
private withdrawRecord;
|
|
9322
9333
|
/**
|
|
9323
9334
|
* Atomically points the invitee index at `tokenHash`, answering with the hash it displaced.
|
|
9324
9335
|
*
|
package/dist/server/index.mjs
CHANGED
|
@@ -8764,6 +8764,17 @@ var InvitationService = class _InvitationService {
|
|
|
8764
8764
|
await this.redis.del(`inv:${supersededHash}`);
|
|
8765
8765
|
}
|
|
8766
8766
|
await this.redis.set(tokenKey, JSON.stringify(stored), ttl);
|
|
8767
|
+
let stillNamed;
|
|
8768
|
+
try {
|
|
8769
|
+
stillNamed = await this.claimInviteeIndex(normalizedEmail, tenantId, tokenHash, ttl, tokenHash);
|
|
8770
|
+
} catch (err) {
|
|
8771
|
+
await this.withdrawRecord(tokenKey);
|
|
8772
|
+
throw err;
|
|
8773
|
+
}
|
|
8774
|
+
if (!stillNamed.claimed) {
|
|
8775
|
+
await this.withdrawRecord(tokenKey);
|
|
8776
|
+
throw new AuthException(AUTH_ERROR_CODES.INSUFFICIENT_ROLE);
|
|
8777
|
+
}
|
|
8767
8778
|
const displayTenantName = tenantName ?? tenantId;
|
|
8768
8779
|
const expiresAt = new Date(Date.now() + ttl * 1e3);
|
|
8769
8780
|
try {
|
|
@@ -8890,6 +8901,21 @@ var InvitationService = class _InvitationService {
|
|
|
8890
8901
|
throw new AuthException(AUTH_ERROR_CODES.INSUFFICIENT_ROLE);
|
|
8891
8902
|
}
|
|
8892
8903
|
/**
|
|
8904
|
+
* Removes the invitation record this call wrote, best-effort.
|
|
8905
|
+
*
|
|
8906
|
+
* Used where the call is already ending in a refusal or a failure of its own, so a failing
|
|
8907
|
+
* delete must not replace that outcome: it is logged and the caller still raises the original.
|
|
8908
|
+
* The raw token has not been emailed at that point, so a record that survives is one nobody
|
|
8909
|
+
* holds the token for, until its TTL.
|
|
8910
|
+
*
|
|
8911
|
+
* @param tokenKey - The Redis key of the record written by this call.
|
|
8912
|
+
*/
|
|
8913
|
+
async withdrawRecord(tokenKey) {
|
|
8914
|
+
await this.redis.del(tokenKey).catch((err) => {
|
|
8915
|
+
this.logger.warn(`invite: could not withdraw the record \u2014 ${describeChannelStatus(err)}`);
|
|
8916
|
+
});
|
|
8917
|
+
}
|
|
8918
|
+
/**
|
|
8893
8919
|
* Atomically points the invitee index at `tokenHash`, answering with the hash it displaced.
|
|
8894
8920
|
*
|
|
8895
8921
|
* A compare-and-swap, not a plain write: the claim proceeds only when the index still holds
|
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.9",
|
|
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",
|