@bymax-one/nest-auth 1.5.4 → 1.5.5
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 +16 -1
- package/dist/server/index.cjs +16 -10
- package/dist/server/index.d.cts +4 -3
- package/dist/server/index.d.ts +4 -3
- package/dist/server/index.mjs +16 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -18,6 +18,20 @@ what moves, and that note is the compatibility contract until strict SemVer begi
|
|
|
18
18
|
|
|
19
19
|
## [Unreleased]
|
|
20
20
|
|
|
21
|
+
## [1.5.5] - 2026-11-14
|
|
22
|
+
|
|
23
|
+
A patch release.
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
|
|
27
|
+
- `issueTokensForUserId` no longer marks the session it issues as recently authenticated, matching rust-auth.
|
|
28
|
+
|
|
29
|
+
### Apply to a derived backend
|
|
30
|
+
|
|
31
|
+
- **`TokenManagerService.issueTokens` takes an optional `credentialProved` override.** A host that calls it directly
|
|
32
|
+
and wants the session to count as a recent authentication passes `{ credentialProved: true }`; without it no
|
|
33
|
+
recent-authentication mark is written. `AuthService.issueTokensForUserId` no longer writes one.
|
|
34
|
+
|
|
21
35
|
## [1.5.4] - 2026-11-14
|
|
22
36
|
|
|
23
37
|
A patch release for outages and browsers: a Redis outage answers `503 auth.service_unavailable` instead of
|
|
@@ -5135,7 +5149,8 @@ ever installable.
|
|
|
5135
5149
|
- 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
|
|
5136
5150
|
- 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
|
|
5137
5151
|
|
|
5138
|
-
[Unreleased]: https://github.com/bymaxone/nest-auth/compare/v1.5.
|
|
5152
|
+
[Unreleased]: https://github.com/bymaxone/nest-auth/compare/v1.5.5...HEAD
|
|
5153
|
+
[1.5.5]: https://github.com/bymaxone/nest-auth/compare/v1.5.4...v1.5.5
|
|
5139
5154
|
[1.5.4]: https://github.com/bymaxone/nest-auth/compare/v1.5.3...v1.5.4
|
|
5140
5155
|
[1.5.3]: https://github.com/bymaxone/nest-auth/compare/v1.5.2...v1.5.3
|
|
5141
5156
|
[1.5.2]: https://github.com/bymaxone/nest-auth/compare/v1.5.1...v1.5.2
|
package/dist/server/index.cjs
CHANGED
|
@@ -6435,6 +6435,9 @@ function _ts_param13(paramIndex, decorator) {
|
|
|
6435
6435
|
__name(_ts_param13, "_ts_param");
|
|
6436
6436
|
var MFA_TEMP_TOKEN_TTL_SECONDS = 300;
|
|
6437
6437
|
var MAX_SESSION_FIELD_LENGTH = 45;
|
|
6438
|
+
var CREDENTIAL_PROVED = {
|
|
6439
|
+
credentialProved: true
|
|
6440
|
+
};
|
|
6438
6441
|
var TokenManagerService = class _TokenManagerService {
|
|
6439
6442
|
static {
|
|
6440
6443
|
__name(this, "TokenManagerService");
|
|
@@ -6532,8 +6535,8 @@ var TokenManagerService = class _TokenManagerService {
|
|
|
6532
6535
|
* @param user - Safe user object (credential fields excluded).
|
|
6533
6536
|
* @param ip - Client IP address (for session audit).
|
|
6534
6537
|
* @param userAgent - User-Agent header value (for session description).
|
|
6535
|
-
* @param overrides - Optional JWT claim overrides
|
|
6536
|
-
*
|
|
6538
|
+
* @param overrides - Optional JWT claim overrides: `{ mfaVerified: true }` after an MFA challenge;
|
|
6539
|
+
* `credentialProved` (default `false`) is what lets the recent-authentication mark be written.
|
|
6537
6540
|
* @returns Full auth result containing access token, raw refresh token, and user.
|
|
6538
6541
|
*/
|
|
6539
6542
|
async issueTokens(user, ip, userAgent, overrides) {
|
|
@@ -6562,7 +6565,9 @@ var TokenManagerService = class _TokenManagerService {
|
|
|
6562
6565
|
userId: user.id,
|
|
6563
6566
|
refreshTtl: ttl
|
|
6564
6567
|
});
|
|
6565
|
-
|
|
6568
|
+
if (overrides?.credentialProved === true) {
|
|
6569
|
+
await this.redis.set(recentAuthKey("dashboard", user.id, this.options.hmacKey, user.tenantId), "1", RECENT_AUTH_TTL_SECONDS);
|
|
6570
|
+
}
|
|
6566
6571
|
return {
|
|
6567
6572
|
user,
|
|
6568
6573
|
accessToken,
|
|
@@ -7677,7 +7682,7 @@ exports.AuthService = class _AuthService {
|
|
|
7677
7682
|
await this.sendVerificationOtp(tenantId, dto.email, newUser.id);
|
|
7678
7683
|
}
|
|
7679
7684
|
const safeUser = toSafeUser2(newUser);
|
|
7680
|
-
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent);
|
|
7685
|
+
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent, CREDENTIAL_PROVED);
|
|
7681
7686
|
if (this.options.sessions.enabled) {
|
|
7682
7687
|
await this.sessionService.createSession({
|
|
7683
7688
|
userId: safeUser.id,
|
|
@@ -7801,7 +7806,7 @@ exports.AuthService = class _AuthService {
|
|
|
7801
7806
|
};
|
|
7802
7807
|
}
|
|
7803
7808
|
const safeUser = toSafeUser2(user);
|
|
7804
|
-
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent);
|
|
7809
|
+
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent, CREDENTIAL_PROVED);
|
|
7805
7810
|
if (this.options.sessions.enabled) {
|
|
7806
7811
|
await this.sessionService.createSession({
|
|
7807
7812
|
userId: safeUser.id,
|
|
@@ -8134,7 +8139,7 @@ exports.AuthService = class _AuthService {
|
|
|
8134
8139
|
* instead — issuing tokens with `mfaVerified: false` would let the
|
|
8135
8140
|
* dashboard's `MfaRequiredGuard` lock the user out on every request.
|
|
8136
8141
|
*
|
|
8137
|
-
*
|
|
8142
|
+
* Unlike `login()`, the session is not a recent authentication. Other side effects mirror it:
|
|
8138
8143
|
* - Concurrent-session limit enforced via `sessionService.createSession`
|
|
8139
8144
|
* when `sessions.enabled`.
|
|
8140
8145
|
* - `userRepo.updateLastLogin` runs non-blocking.
|
|
@@ -10202,7 +10207,7 @@ exports.InvitationService = class _InvitationService {
|
|
|
10202
10207
|
emailVerified: true
|
|
10203
10208
|
});
|
|
10204
10209
|
const { passwordHash: _ph, mfaSecret: _ms, mfaRecoveryCodes: _mrc, ...safeUser } = authUser;
|
|
10205
|
-
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent);
|
|
10210
|
+
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent, CREDENTIAL_PROVED);
|
|
10206
10211
|
if (this.options.sessions.enabled) {
|
|
10207
10212
|
await this.sessionService.createSession({
|
|
10208
10213
|
userId: safeUser.id,
|
|
@@ -11400,7 +11405,8 @@ var MfaChallengeService = class {
|
|
|
11400
11405
|
async issueDashboardSession(user, userId, ip, userAgent) {
|
|
11401
11406
|
const safeUser = toSafeUser3(user);
|
|
11402
11407
|
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent, {
|
|
11403
|
-
mfaVerified: true
|
|
11408
|
+
mfaVerified: true,
|
|
11409
|
+
credentialProved: true
|
|
11404
11410
|
});
|
|
11405
11411
|
if (this.options.sessions.enabled) {
|
|
11406
11412
|
await this.sessionService.createSession({
|
|
@@ -17319,7 +17325,7 @@ var WorkspaceInvitationAcceptService = class _WorkspaceInvitationAcceptService {
|
|
|
17319
17325
|
}
|
|
17320
17326
|
/** Issues the new account's session as a sign-in does, and fires the host's hook. */
|
|
17321
17327
|
async signIn(user, request, context) {
|
|
17322
|
-
const result = await this.tokens.issueTokens(user, request.ip, request.userAgent);
|
|
17328
|
+
const result = await this.tokens.issueTokens(user, request.ip, request.userAgent, CREDENTIAL_PROVED);
|
|
17323
17329
|
if (this.options.sessions.enabled) {
|
|
17324
17330
|
await this.sessions.createSession({
|
|
17325
17331
|
userId: user.id,
|
|
@@ -20673,7 +20679,7 @@ exports.OAuthService = class _OAuthService {
|
|
|
20673
20679
|
*/
|
|
20674
20680
|
async openSession(authUser, provider, hookResult, hookContext, ip, userAgent) {
|
|
20675
20681
|
const safeUser = toSafeUser5(authUser);
|
|
20676
|
-
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent);
|
|
20682
|
+
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent, CREDENTIAL_PROVED);
|
|
20677
20683
|
if (this.options.sessions.enabled) {
|
|
20678
20684
|
await this.sessionService.createSession({
|
|
20679
20685
|
userId: safeUser.id,
|
package/dist/server/index.d.cts
CHANGED
|
@@ -9769,12 +9769,13 @@ declare class TokenManagerService {
|
|
|
9769
9769
|
* @param user - Safe user object (credential fields excluded).
|
|
9770
9770
|
* @param ip - Client IP address (for session audit).
|
|
9771
9771
|
* @param userAgent - User-Agent header value (for session description).
|
|
9772
|
-
* @param overrides - Optional JWT claim overrides
|
|
9773
|
-
*
|
|
9772
|
+
* @param overrides - Optional JWT claim overrides: `{ mfaVerified: true }` after an MFA challenge;
|
|
9773
|
+
* `credentialProved` (default `false`) is what lets the recent-authentication mark be written.
|
|
9774
9774
|
* @returns Full auth result containing access token, raw refresh token, and user.
|
|
9775
9775
|
*/
|
|
9776
9776
|
issueTokens(user: SafeAuthUser, ip: string, userAgent: string, overrides?: {
|
|
9777
9777
|
mfaVerified?: boolean;
|
|
9778
|
+
credentialProved?: boolean;
|
|
9778
9779
|
}): Promise<AuthResult>;
|
|
9779
9780
|
/**
|
|
9780
9781
|
* Issues access + refresh tokens for a successfully authenticated platform admin.
|
|
@@ -10458,7 +10459,7 @@ declare class AuthService {
|
|
|
10458
10459
|
* instead — issuing tokens with `mfaVerified: false` would let the
|
|
10459
10460
|
* dashboard's `MfaRequiredGuard` lock the user out on every request.
|
|
10460
10461
|
*
|
|
10461
|
-
*
|
|
10462
|
+
* Unlike `login()`, the session is not a recent authentication. Other side effects mirror it:
|
|
10462
10463
|
* - Concurrent-session limit enforced via `sessionService.createSession`
|
|
10463
10464
|
* when `sessions.enabled`.
|
|
10464
10465
|
* - `userRepo.updateLastLogin` runs non-blocking.
|
package/dist/server/index.d.ts
CHANGED
|
@@ -9769,12 +9769,13 @@ declare class TokenManagerService {
|
|
|
9769
9769
|
* @param user - Safe user object (credential fields excluded).
|
|
9770
9770
|
* @param ip - Client IP address (for session audit).
|
|
9771
9771
|
* @param userAgent - User-Agent header value (for session description).
|
|
9772
|
-
* @param overrides - Optional JWT claim overrides
|
|
9773
|
-
*
|
|
9772
|
+
* @param overrides - Optional JWT claim overrides: `{ mfaVerified: true }` after an MFA challenge;
|
|
9773
|
+
* `credentialProved` (default `false`) is what lets the recent-authentication mark be written.
|
|
9774
9774
|
* @returns Full auth result containing access token, raw refresh token, and user.
|
|
9775
9775
|
*/
|
|
9776
9776
|
issueTokens(user: SafeAuthUser, ip: string, userAgent: string, overrides?: {
|
|
9777
9777
|
mfaVerified?: boolean;
|
|
9778
|
+
credentialProved?: boolean;
|
|
9778
9779
|
}): Promise<AuthResult>;
|
|
9779
9780
|
/**
|
|
9780
9781
|
* Issues access + refresh tokens for a successfully authenticated platform admin.
|
|
@@ -10458,7 +10459,7 @@ declare class AuthService {
|
|
|
10458
10459
|
* instead — issuing tokens with `mfaVerified: false` would let the
|
|
10459
10460
|
* dashboard's `MfaRequiredGuard` lock the user out on every request.
|
|
10460
10461
|
*
|
|
10461
|
-
*
|
|
10462
|
+
* Unlike `login()`, the session is not a recent authentication. Other side effects mirror it:
|
|
10462
10463
|
* - Concurrent-session limit enforced via `sessionService.createSession`
|
|
10463
10464
|
* when `sessions.enabled`.
|
|
10464
10465
|
* - `userRepo.updateLastLogin` runs non-blocking.
|
package/dist/server/index.mjs
CHANGED
|
@@ -6433,6 +6433,9 @@ function _ts_param13(paramIndex, decorator) {
|
|
|
6433
6433
|
__name(_ts_param13, "_ts_param");
|
|
6434
6434
|
var MFA_TEMP_TOKEN_TTL_SECONDS = 300;
|
|
6435
6435
|
var MAX_SESSION_FIELD_LENGTH = 45;
|
|
6436
|
+
var CREDENTIAL_PROVED = {
|
|
6437
|
+
credentialProved: true
|
|
6438
|
+
};
|
|
6436
6439
|
var TokenManagerService = class _TokenManagerService {
|
|
6437
6440
|
static {
|
|
6438
6441
|
__name(this, "TokenManagerService");
|
|
@@ -6530,8 +6533,8 @@ var TokenManagerService = class _TokenManagerService {
|
|
|
6530
6533
|
* @param user - Safe user object (credential fields excluded).
|
|
6531
6534
|
* @param ip - Client IP address (for session audit).
|
|
6532
6535
|
* @param userAgent - User-Agent header value (for session description).
|
|
6533
|
-
* @param overrides - Optional JWT claim overrides
|
|
6534
|
-
*
|
|
6536
|
+
* @param overrides - Optional JWT claim overrides: `{ mfaVerified: true }` after an MFA challenge;
|
|
6537
|
+
* `credentialProved` (default `false`) is what lets the recent-authentication mark be written.
|
|
6535
6538
|
* @returns Full auth result containing access token, raw refresh token, and user.
|
|
6536
6539
|
*/
|
|
6537
6540
|
async issueTokens(user, ip, userAgent, overrides) {
|
|
@@ -6560,7 +6563,9 @@ var TokenManagerService = class _TokenManagerService {
|
|
|
6560
6563
|
userId: user.id,
|
|
6561
6564
|
refreshTtl: ttl
|
|
6562
6565
|
});
|
|
6563
|
-
|
|
6566
|
+
if (overrides?.credentialProved === true) {
|
|
6567
|
+
await this.redis.set(recentAuthKey("dashboard", user.id, this.options.hmacKey, user.tenantId), "1", RECENT_AUTH_TTL_SECONDS);
|
|
6568
|
+
}
|
|
6564
6569
|
return {
|
|
6565
6570
|
user,
|
|
6566
6571
|
accessToken,
|
|
@@ -7675,7 +7680,7 @@ var AuthService = class _AuthService {
|
|
|
7675
7680
|
await this.sendVerificationOtp(tenantId, dto.email, newUser.id);
|
|
7676
7681
|
}
|
|
7677
7682
|
const safeUser = toSafeUser2(newUser);
|
|
7678
|
-
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent);
|
|
7683
|
+
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent, CREDENTIAL_PROVED);
|
|
7679
7684
|
if (this.options.sessions.enabled) {
|
|
7680
7685
|
await this.sessionService.createSession({
|
|
7681
7686
|
userId: safeUser.id,
|
|
@@ -7799,7 +7804,7 @@ var AuthService = class _AuthService {
|
|
|
7799
7804
|
};
|
|
7800
7805
|
}
|
|
7801
7806
|
const safeUser = toSafeUser2(user);
|
|
7802
|
-
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent);
|
|
7807
|
+
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent, CREDENTIAL_PROVED);
|
|
7803
7808
|
if (this.options.sessions.enabled) {
|
|
7804
7809
|
await this.sessionService.createSession({
|
|
7805
7810
|
userId: safeUser.id,
|
|
@@ -8132,7 +8137,7 @@ var AuthService = class _AuthService {
|
|
|
8132
8137
|
* instead — issuing tokens with `mfaVerified: false` would let the
|
|
8133
8138
|
* dashboard's `MfaRequiredGuard` lock the user out on every request.
|
|
8134
8139
|
*
|
|
8135
|
-
*
|
|
8140
|
+
* Unlike `login()`, the session is not a recent authentication. Other side effects mirror it:
|
|
8136
8141
|
* - Concurrent-session limit enforced via `sessionService.createSession`
|
|
8137
8142
|
* when `sessions.enabled`.
|
|
8138
8143
|
* - `userRepo.updateLastLogin` runs non-blocking.
|
|
@@ -10200,7 +10205,7 @@ var InvitationService = class _InvitationService {
|
|
|
10200
10205
|
emailVerified: true
|
|
10201
10206
|
});
|
|
10202
10207
|
const { passwordHash: _ph, mfaSecret: _ms, mfaRecoveryCodes: _mrc, ...safeUser } = authUser;
|
|
10203
|
-
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent);
|
|
10208
|
+
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent, CREDENTIAL_PROVED);
|
|
10204
10209
|
if (this.options.sessions.enabled) {
|
|
10205
10210
|
await this.sessionService.createSession({
|
|
10206
10211
|
userId: safeUser.id,
|
|
@@ -11398,7 +11403,8 @@ var MfaChallengeService = class {
|
|
|
11398
11403
|
async issueDashboardSession(user, userId, ip, userAgent) {
|
|
11399
11404
|
const safeUser = toSafeUser3(user);
|
|
11400
11405
|
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent, {
|
|
11401
|
-
mfaVerified: true
|
|
11406
|
+
mfaVerified: true,
|
|
11407
|
+
credentialProved: true
|
|
11402
11408
|
});
|
|
11403
11409
|
if (this.options.sessions.enabled) {
|
|
11404
11410
|
await this.sessionService.createSession({
|
|
@@ -17317,7 +17323,7 @@ var WorkspaceInvitationAcceptService = class _WorkspaceInvitationAcceptService {
|
|
|
17317
17323
|
}
|
|
17318
17324
|
/** Issues the new account's session as a sign-in does, and fires the host's hook. */
|
|
17319
17325
|
async signIn(user, request, context) {
|
|
17320
|
-
const result = await this.tokens.issueTokens(user, request.ip, request.userAgent);
|
|
17326
|
+
const result = await this.tokens.issueTokens(user, request.ip, request.userAgent, CREDENTIAL_PROVED);
|
|
17321
17327
|
if (this.options.sessions.enabled) {
|
|
17322
17328
|
await this.sessions.createSession({
|
|
17323
17329
|
userId: user.id,
|
|
@@ -20671,7 +20677,7 @@ var OAuthService = class _OAuthService {
|
|
|
20671
20677
|
*/
|
|
20672
20678
|
async openSession(authUser, provider, hookResult, hookContext, ip, userAgent) {
|
|
20673
20679
|
const safeUser = toSafeUser5(authUser);
|
|
20674
|
-
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent);
|
|
20680
|
+
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent, CREDENTIAL_PROVED);
|
|
20675
20681
|
if (this.options.sessions.enabled) {
|
|
20676
20682
|
await this.sessionService.createSession({
|
|
20677
20683
|
userId: safeUser.id,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bymax-one/nest-auth",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.5",
|
|
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",
|