@bymax-one/nest-auth 1.5.3 → 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 +69 -1
- package/README.md +29 -10
- package/dist/client/index.cjs +18 -1
- package/dist/client/index.d.cts +2 -1
- package/dist/client/index.d.ts +2 -1
- package/dist/client/index.mjs +18 -1
- package/dist/react/index.cjs +16 -12
- package/dist/react/index.d.cts +3 -0
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.mjs +16 -12
- package/dist/server/index.cjs +127 -31
- package/dist/server/index.d.cts +24 -10
- package/dist/server/index.d.ts +24 -10
- package/dist/server/index.mjs +127 -31
- package/dist/shared/index.cjs +8 -2
- package/dist/shared/index.d.cts +5 -0
- package/dist/shared/index.d.ts +5 -0
- package/dist/shared/index.mjs +8 -2
- package/package.json +2 -2
package/dist/server/index.cjs
CHANGED
|
@@ -2276,7 +2276,17 @@ var AUTH_ERROR_CODES = {
|
|
|
2276
2276
|
* answers with. Without the filter the framework's own 500 shape stands, which is the
|
|
2277
2277
|
* behaviour this library had before it existed.
|
|
2278
2278
|
*/
|
|
2279
|
-
INTERNAL: "auth.internal"
|
|
2279
|
+
INTERNAL: "auth.internal",
|
|
2280
|
+
/**
|
|
2281
|
+
* A store this request depends on, Redis, did not answer in time or could not be reached, so
|
|
2282
|
+
* the request was refused and nothing was admitted. Retrying later may succeed; nothing here
|
|
2283
|
+
* knows when, so the answer carries no `Retry-After`.
|
|
2284
|
+
*
|
|
2285
|
+
* Raised by the library's Redis wrapper, not only by {@link AuthExceptionFilter}: it is a typed
|
|
2286
|
+
* exception, so any host filter that renders an `HttpException` answers it as a 503. The ioredis
|
|
2287
|
+
* error rides on the exception as `cause` and is never serialized.
|
|
2288
|
+
*/
|
|
2289
|
+
SERVICE_UNAVAILABLE: "auth.service_unavailable"
|
|
2280
2290
|
};
|
|
2281
2291
|
var AUTH_ERROR_STATUS = {
|
|
2282
2292
|
"auth.invalid_credentials": 401,
|
|
@@ -2328,7 +2338,8 @@ var AUTH_ERROR_STATUS = {
|
|
|
2328
2338
|
"auth.registration_closed": 403,
|
|
2329
2339
|
"auth.workspace_limit_reached": 403,
|
|
2330
2340
|
"auth.workspace_pending_deletion": 409,
|
|
2331
|
-
"auth.internal": 500
|
|
2341
|
+
"auth.internal": 500,
|
|
2342
|
+
"auth.service_unavailable": 503
|
|
2332
2343
|
};
|
|
2333
2344
|
var AUTH_ERROR_MESSAGES = {
|
|
2334
2345
|
"auth.invalid_credentials": "Invalid email or password",
|
|
@@ -2380,7 +2391,8 @@ var AUTH_ERROR_MESSAGES = {
|
|
|
2380
2391
|
"auth.registration_closed": "Registration is closed",
|
|
2381
2392
|
"auth.workspace_limit_reached": "Workspace limit reached. Workspaces pending deletion count toward the limit.",
|
|
2382
2393
|
"auth.workspace_pending_deletion": "Workspace is scheduled for deletion",
|
|
2383
|
-
"auth.internal": "Internal server error"
|
|
2394
|
+
"auth.internal": "Internal server error",
|
|
2395
|
+
"auth.service_unavailable": "Service temporarily unavailable"
|
|
2384
2396
|
};
|
|
2385
2397
|
var MESSAGE_BY_CODE = new Map(Object.entries(AUTH_ERROR_MESSAGES));
|
|
2386
2398
|
var STATUS_BY_CODE = new Map(Object.entries(AUTH_ERROR_STATUS));
|
|
@@ -2394,8 +2406,10 @@ var AuthException = class extends common.HttpException {
|
|
|
2394
2406
|
* @param details - Optional structured payload attached to the error body under
|
|
2395
2407
|
* `error.details`. An array where the failure is a list — `auth.validation` renders its
|
|
2396
2408
|
* per-field failures that way, matching what rust-auth serializes for the same code.
|
|
2409
|
+
* @param options - `cause`: the error this one reports, kept on the exception for a host's
|
|
2410
|
+
* logger and never serialized into the body.
|
|
2397
2411
|
*/
|
|
2398
|
-
constructor(code, details) {
|
|
2412
|
+
constructor(code, details, options) {
|
|
2399
2413
|
super(
|
|
2400
2414
|
{
|
|
2401
2415
|
error: {
|
|
@@ -2408,11 +2422,88 @@ var AuthException = class extends common.HttpException {
|
|
|
2408
2422
|
// A code with no entry is a programming error on the throwing side, not something the
|
|
2409
2423
|
// caller did — 500 says so, and says it with a number rather than the `undefined` an
|
|
2410
2424
|
// unguarded lookup used to hand to Express.
|
|
2411
|
-
STATUS_BY_CODE.get(code) ?? common.HttpStatus.INTERNAL_SERVER_ERROR
|
|
2425
|
+
STATUS_BY_CODE.get(code) ?? common.HttpStatus.INTERNAL_SERVER_ERROR,
|
|
2426
|
+
options?.cause === void 0 ? void 0 : {
|
|
2427
|
+
cause: options.cause
|
|
2428
|
+
}
|
|
2412
2429
|
);
|
|
2413
2430
|
}
|
|
2414
2431
|
};
|
|
2415
2432
|
|
|
2433
|
+
// src/server/redis/redis-outage.ts
|
|
2434
|
+
var MESSAGE_KINDS = /* @__PURE__ */ new Map([
|
|
2435
|
+
[
|
|
2436
|
+
"Command timed out",
|
|
2437
|
+
"timeout"
|
|
2438
|
+
],
|
|
2439
|
+
[
|
|
2440
|
+
"Connection is closed.",
|
|
2441
|
+
"closed"
|
|
2442
|
+
],
|
|
2443
|
+
[
|
|
2444
|
+
"Stream isn't writeable and enableOfflineQueue options is false",
|
|
2445
|
+
"closed"
|
|
2446
|
+
]
|
|
2447
|
+
]);
|
|
2448
|
+
var NETWORK_CODES = /* @__PURE__ */ new Set([
|
|
2449
|
+
"ECONNREFUSED",
|
|
2450
|
+
"ECONNRESET",
|
|
2451
|
+
"ETIMEDOUT",
|
|
2452
|
+
"EPIPE",
|
|
2453
|
+
"ENOTFOUND",
|
|
2454
|
+
"EAI_AGAIN",
|
|
2455
|
+
"EHOSTUNREACH",
|
|
2456
|
+
"ENETUNREACH"
|
|
2457
|
+
]);
|
|
2458
|
+
var UNAVAILABLE_REPLIES = /* @__PURE__ */ new Set([
|
|
2459
|
+
"READONLY",
|
|
2460
|
+
"LOADING",
|
|
2461
|
+
"MASTERDOWN",
|
|
2462
|
+
"CLUSTERDOWN",
|
|
2463
|
+
"TRYAGAIN"
|
|
2464
|
+
]);
|
|
2465
|
+
function redisOutageKindOf(error) {
|
|
2466
|
+
if (!(error instanceof Error)) return void 0;
|
|
2467
|
+
if (error.name === "MaxRetriesPerRequestError") return "unreachable";
|
|
2468
|
+
if (error.name === "ReplyError") {
|
|
2469
|
+
return UNAVAILABLE_REPLIES.has(error.message.split(" ", 1)[0]) ? "unavailable" : void 0;
|
|
2470
|
+
}
|
|
2471
|
+
const { code } = error;
|
|
2472
|
+
if (typeof code === "string" && NETWORK_CODES.has(code)) return "unreachable";
|
|
2473
|
+
return MESSAGE_KINDS.get(error.message);
|
|
2474
|
+
}
|
|
2475
|
+
__name(redisOutageKindOf, "redisOutageKindOf");
|
|
2476
|
+
function rethrowAsOutage(error) {
|
|
2477
|
+
if (redisOutageKindOf(error) === void 0) throw error;
|
|
2478
|
+
throw new AuthException(AUTH_ERROR_CODES.SERVICE_UNAVAILABLE, void 0, {
|
|
2479
|
+
cause: error
|
|
2480
|
+
});
|
|
2481
|
+
}
|
|
2482
|
+
__name(rethrowAsOutage, "rethrowAsOutage");
|
|
2483
|
+
function isServiceUnavailable(error) {
|
|
2484
|
+
if (!(error instanceof AuthException)) return false;
|
|
2485
|
+
const body = error.getResponse();
|
|
2486
|
+
return body.error?.code === AUTH_ERROR_CODES.SERVICE_UNAVAILABLE;
|
|
2487
|
+
}
|
|
2488
|
+
__name(isServiceUnavailable, "isServiceUnavailable");
|
|
2489
|
+
function isThenable(value) {
|
|
2490
|
+
return typeof value === "object" && value !== null && typeof value.then === "function";
|
|
2491
|
+
}
|
|
2492
|
+
__name(isThenable, "isThenable");
|
|
2493
|
+
function mappingOutages(redis) {
|
|
2494
|
+
return new Proxy(redis, {
|
|
2495
|
+
get(target, property) {
|
|
2496
|
+
const value = Reflect.get(target, property, target);
|
|
2497
|
+
if (typeof value !== "function") return value;
|
|
2498
|
+
return (...args) => {
|
|
2499
|
+
const result = Reflect.apply(value, target, args);
|
|
2500
|
+
return isThenable(result) ? result.then(void 0, rethrowAsOutage) : result;
|
|
2501
|
+
};
|
|
2502
|
+
}
|
|
2503
|
+
});
|
|
2504
|
+
}
|
|
2505
|
+
__name(mappingOutages, "mappingOutages");
|
|
2506
|
+
|
|
2416
2507
|
// src/server/constants/user-subject.ts
|
|
2417
2508
|
function userSubject(plane, userId, tenantId) {
|
|
2418
2509
|
if (plane === "platform") return `platform:${userId}`;
|
|
@@ -2460,7 +2551,6 @@ function _ts_param(paramIndex, decorator) {
|
|
|
2460
2551
|
};
|
|
2461
2552
|
}
|
|
2462
2553
|
__name(_ts_param, "_ts_param");
|
|
2463
|
-
var EPOCH_TTL_SECONDS = TOKEN_EPOCH_RETENTION_SECONDS;
|
|
2464
2554
|
var WS_TICKET_ENTROPY_BYTES = 32;
|
|
2465
2555
|
var GRACE_TAG = "GRACE:";
|
|
2466
2556
|
var REUSED_TAG = "REUSED:";
|
|
@@ -2628,7 +2718,7 @@ var AuthRedisService = class {
|
|
|
2628
2718
|
*/
|
|
2629
2719
|
#hmacKey;
|
|
2630
2720
|
constructor(redis, options) {
|
|
2631
|
-
this.#redis = redis;
|
|
2721
|
+
this.#redis = mappingOutages(redis);
|
|
2632
2722
|
this.namespace = options.redisNamespace;
|
|
2633
2723
|
this.#hmacKey = options.hmacKey;
|
|
2634
2724
|
}
|
|
@@ -3334,7 +3424,7 @@ var AuthRedisService = class {
|
|
|
3334
3424
|
return v`, [
|
|
3335
3425
|
key
|
|
3336
3426
|
], [
|
|
3337
|
-
String(
|
|
3427
|
+
String(TOKEN_EPOCH_RETENTION_SECONDS)
|
|
3338
3428
|
]);
|
|
3339
3429
|
return typeof result === "number" ? result : 0;
|
|
3340
3430
|
}
|
|
@@ -6345,6 +6435,9 @@ function _ts_param13(paramIndex, decorator) {
|
|
|
6345
6435
|
__name(_ts_param13, "_ts_param");
|
|
6346
6436
|
var MFA_TEMP_TOKEN_TTL_SECONDS = 300;
|
|
6347
6437
|
var MAX_SESSION_FIELD_LENGTH = 45;
|
|
6438
|
+
var CREDENTIAL_PROVED = {
|
|
6439
|
+
credentialProved: true
|
|
6440
|
+
};
|
|
6348
6441
|
var TokenManagerService = class _TokenManagerService {
|
|
6349
6442
|
static {
|
|
6350
6443
|
__name(this, "TokenManagerService");
|
|
@@ -6442,8 +6535,8 @@ var TokenManagerService = class _TokenManagerService {
|
|
|
6442
6535
|
* @param user - Safe user object (credential fields excluded).
|
|
6443
6536
|
* @param ip - Client IP address (for session audit).
|
|
6444
6537
|
* @param userAgent - User-Agent header value (for session description).
|
|
6445
|
-
* @param overrides - Optional JWT claim overrides
|
|
6446
|
-
*
|
|
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.
|
|
6447
6540
|
* @returns Full auth result containing access token, raw refresh token, and user.
|
|
6448
6541
|
*/
|
|
6449
6542
|
async issueTokens(user, ip, userAgent, overrides) {
|
|
@@ -6472,7 +6565,9 @@ var TokenManagerService = class _TokenManagerService {
|
|
|
6472
6565
|
userId: user.id,
|
|
6473
6566
|
refreshTtl: ttl
|
|
6474
6567
|
});
|
|
6475
|
-
|
|
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
|
+
}
|
|
6476
6571
|
return {
|
|
6477
6572
|
user,
|
|
6478
6573
|
accessToken,
|
|
@@ -7306,7 +7401,7 @@ async function settlePendingLogout(redis, key, fromSession, owner, ttlSeconds, l
|
|
|
7306
7401
|
return fromSession || removed;
|
|
7307
7402
|
} catch (err) {
|
|
7308
7403
|
logger.warn(`logout: the retry marker could not be cleared \u2014 ${describeChannelStatus(err)}`);
|
|
7309
|
-
if (!fromSession) throw new AuthException(AUTH_ERROR_CODES.INTERNAL);
|
|
7404
|
+
if (!fromSession) throw isServiceUnavailable(err) ? err : new AuthException(AUTH_ERROR_CODES.INTERNAL);
|
|
7310
7405
|
return confirmNoStaleMarker(redis, key, owner, ttlSeconds, logger);
|
|
7311
7406
|
}
|
|
7312
7407
|
}
|
|
@@ -7314,8 +7409,9 @@ __name(settlePendingLogout, "settlePendingLogout");
|
|
|
7314
7409
|
async function confirmNoStaleMarker(redis, key, owner, ttlSeconds, logger) {
|
|
7315
7410
|
try {
|
|
7316
7411
|
if (await redis.get(key) === null) return true;
|
|
7317
|
-
} catch {
|
|
7412
|
+
} catch (err) {
|
|
7318
7413
|
await rememberPendingLogout(redis, key, owner, ttlSeconds, logger);
|
|
7414
|
+
if (isServiceUnavailable(err)) throw err;
|
|
7319
7415
|
}
|
|
7320
7416
|
throw new AuthException(AUTH_ERROR_CODES.INTERNAL);
|
|
7321
7417
|
}
|
|
@@ -7586,7 +7682,7 @@ exports.AuthService = class _AuthService {
|
|
|
7586
7682
|
await this.sendVerificationOtp(tenantId, dto.email, newUser.id);
|
|
7587
7683
|
}
|
|
7588
7684
|
const safeUser = toSafeUser2(newUser);
|
|
7589
|
-
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent);
|
|
7685
|
+
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent, CREDENTIAL_PROVED);
|
|
7590
7686
|
if (this.options.sessions.enabled) {
|
|
7591
7687
|
await this.sessionService.createSession({
|
|
7592
7688
|
userId: safeUser.id,
|
|
@@ -7710,7 +7806,7 @@ exports.AuthService = class _AuthService {
|
|
|
7710
7806
|
};
|
|
7711
7807
|
}
|
|
7712
7808
|
const safeUser = toSafeUser2(user);
|
|
7713
|
-
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent);
|
|
7809
|
+
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent, CREDENTIAL_PROVED);
|
|
7714
7810
|
if (this.options.sessions.enabled) {
|
|
7715
7811
|
await this.sessionService.createSession({
|
|
7716
7812
|
userId: safeUser.id,
|
|
@@ -8043,7 +8139,7 @@ exports.AuthService = class _AuthService {
|
|
|
8043
8139
|
* instead — issuing tokens with `mfaVerified: false` would let the
|
|
8044
8140
|
* dashboard's `MfaRequiredGuard` lock the user out on every request.
|
|
8045
8141
|
*
|
|
8046
|
-
*
|
|
8142
|
+
* Unlike `login()`, the session is not a recent authentication. Other side effects mirror it:
|
|
8047
8143
|
* - Concurrent-session limit enforced via `sessionService.createSession`
|
|
8048
8144
|
* when `sessions.enabled`.
|
|
8049
8145
|
* - `userRepo.updateLastLogin` runs non-blocking.
|
|
@@ -10111,7 +10207,7 @@ exports.InvitationService = class _InvitationService {
|
|
|
10111
10207
|
emailVerified: true
|
|
10112
10208
|
});
|
|
10113
10209
|
const { passwordHash: _ph, mfaSecret: _ms, mfaRecoveryCodes: _mrc, ...safeUser } = authUser;
|
|
10114
|
-
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent);
|
|
10210
|
+
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent, CREDENTIAL_PROVED);
|
|
10115
10211
|
if (this.options.sessions.enabled) {
|
|
10116
10212
|
await this.sessionService.createSession({
|
|
10117
10213
|
userId: safeUser.id,
|
|
@@ -11309,7 +11405,8 @@ var MfaChallengeService = class {
|
|
|
11309
11405
|
async issueDashboardSession(user, userId, ip, userAgent) {
|
|
11310
11406
|
const safeUser = toSafeUser3(user);
|
|
11311
11407
|
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent, {
|
|
11312
|
-
mfaVerified: true
|
|
11408
|
+
mfaVerified: true,
|
|
11409
|
+
credentialProved: true
|
|
11313
11410
|
});
|
|
11314
11411
|
if (this.options.sessions.enabled) {
|
|
11315
11412
|
await this.sessionService.createSession({
|
|
@@ -12996,7 +13093,7 @@ async function answerResetRequest(deps, request) {
|
|
|
12996
13093
|
} catch (err) {
|
|
12997
13094
|
logger.error(`${label}: cooldown store failed: ${describeChannelStatus(err)}`);
|
|
12998
13095
|
await holdFloor();
|
|
12999
|
-
throw new AuthException(AUTH_ERROR_CODES.INTERNAL);
|
|
13096
|
+
throw isServiceUnavailable(err) ? err : new AuthException(AUTH_ERROR_CODES.INTERNAL);
|
|
13000
13097
|
}
|
|
13001
13098
|
if (!claimed) {
|
|
13002
13099
|
await holdFloor();
|
|
@@ -13123,10 +13220,9 @@ exports.PasswordResetService = class _PasswordResetService {
|
|
|
13123
13220
|
* - The account is blocked.
|
|
13124
13221
|
* - Issuing or storing the code, or the email provider, fails for an account that exists.
|
|
13125
13222
|
*
|
|
13126
|
-
*
|
|
13127
|
-
*
|
|
13128
|
-
*
|
|
13129
|
-
* whether an email address is registered.
|
|
13223
|
+
* What a failure answers, and when the cooldown this call took is released, is decided in one
|
|
13224
|
+
* place, {@link answerResetRequest}. The response cannot be used to probe whether an email
|
|
13225
|
+
* address is registered.
|
|
13130
13226
|
*
|
|
13131
13227
|
* Timing normalization: the method always takes at least {@link ANTI_ENUM_MIN_MS}
|
|
13132
13228
|
* milliseconds to respond, regardless of whether the user was found.
|
|
@@ -13234,8 +13330,8 @@ exports.PasswordResetService = class _PasswordResetService {
|
|
|
13234
13330
|
*
|
|
13235
13331
|
* Subject to an atomic 60-second cooldown enforced via a Redis NX key to
|
|
13236
13332
|
* prevent OTP flooding. Resolves the same way whether or not the user exists —
|
|
13237
|
-
* anti-enumeration principle; a failure
|
|
13238
|
-
*
|
|
13333
|
+
* anti-enumeration principle; what a failure answers is decided in one place,
|
|
13334
|
+
* {@link answerResetRequest}.
|
|
13239
13335
|
*
|
|
13240
13336
|
* Timing normalization: always takes at least {@link ANTI_ENUM_MIN_MS} ms.
|
|
13241
13337
|
*
|
|
@@ -13733,8 +13829,8 @@ var PasswordResetController = class {
|
|
|
13733
13829
|
*
|
|
13734
13830
|
* Sends a reset token or OTP to the user's email if the account exists and
|
|
13735
13831
|
* is eligible. Answers `200 OK` with an empty JSON object whether or not the account exists
|
|
13736
|
-
* (anti-enumeration; the body is pinned by the wire contract).
|
|
13737
|
-
*
|
|
13832
|
+
* (anti-enumeration; the body is pinned by the wire contract). What a failure answers is
|
|
13833
|
+
* decided in one place, `answerResetRequest` (utils/answer-reset-request.ts).
|
|
13738
13834
|
*
|
|
13739
13835
|
* @param dto - Validated DTO with `email` and `tenantId`.
|
|
13740
13836
|
* @returns An empty object.
|
|
@@ -13822,8 +13918,8 @@ var PasswordResetController = class {
|
|
|
13822
13918
|
*
|
|
13823
13919
|
* Subject to a 60-second atomic cooldown per `(tenantId, email)` pair.
|
|
13824
13920
|
* Answers `200 OK` with an empty JSON object whether or not the account exists
|
|
13825
|
-
* (anti-enumeration; the body is pinned by the wire contract).
|
|
13826
|
-
*
|
|
13921
|
+
* (anti-enumeration; the body is pinned by the wire contract). What a failure answers is
|
|
13922
|
+
* decided in one place, `answerResetRequest` (utils/answer-reset-request.ts).
|
|
13827
13923
|
*
|
|
13828
13924
|
* @param dto - Validated DTO with `email` and `tenantId`.
|
|
13829
13925
|
* @returns An empty object.
|
|
@@ -17229,7 +17325,7 @@ var WorkspaceInvitationAcceptService = class _WorkspaceInvitationAcceptService {
|
|
|
17229
17325
|
}
|
|
17230
17326
|
/** Issues the new account's session as a sign-in does, and fires the host's hook. */
|
|
17231
17327
|
async signIn(user, request, context) {
|
|
17232
|
-
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);
|
|
17233
17329
|
if (this.options.sessions.enabled) {
|
|
17234
17330
|
await this.sessions.createSession({
|
|
17235
17331
|
userId: user.id,
|
|
@@ -20583,7 +20679,7 @@ exports.OAuthService = class _OAuthService {
|
|
|
20583
20679
|
*/
|
|
20584
20680
|
async openSession(authUser, provider, hookResult, hookContext, ip, userAgent) {
|
|
20585
20681
|
const safeUser = toSafeUser5(authUser);
|
|
20586
|
-
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent);
|
|
20682
|
+
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent, CREDENTIAL_PROVED);
|
|
20587
20683
|
if (this.options.sessions.enabled) {
|
|
20588
20684
|
await this.sessionService.createSession({
|
|
20589
20685
|
userId: safeUser.id,
|
package/dist/server/index.d.cts
CHANGED
|
@@ -2749,6 +2749,16 @@ declare const AUTH_ERROR_CODES: {
|
|
|
2749
2749
|
* behaviour this library had before it existed.
|
|
2750
2750
|
*/
|
|
2751
2751
|
readonly INTERNAL: "auth.internal";
|
|
2752
|
+
/**
|
|
2753
|
+
* A store this request depends on, Redis, did not answer in time or could not be reached, so
|
|
2754
|
+
* the request was refused and nothing was admitted. Retrying later may succeed; nothing here
|
|
2755
|
+
* knows when, so the answer carries no `Retry-After`.
|
|
2756
|
+
*
|
|
2757
|
+
* Raised by the library's Redis wrapper, not only by {@link AuthExceptionFilter}: it is a typed
|
|
2758
|
+
* exception, so any host filter that renders an `HttpException` answers it as a 503. The ioredis
|
|
2759
|
+
* error rides on the exception as `cause` and is never serialized.
|
|
2760
|
+
*/
|
|
2761
|
+
readonly SERVICE_UNAVAILABLE: "auth.service_unavailable";
|
|
2752
2762
|
};
|
|
2753
2763
|
/**
|
|
2754
2764
|
* String literal union of all valid `AuthException` error codes.
|
|
@@ -2837,8 +2847,12 @@ declare class AuthException extends HttpException {
|
|
|
2837
2847
|
* @param details - Optional structured payload attached to the error body under
|
|
2838
2848
|
* `error.details`. An array where the failure is a list — `auth.validation` renders its
|
|
2839
2849
|
* per-field failures that way, matching what rust-auth serializes for the same code.
|
|
2850
|
+
* @param options - `cause`: the error this one reports, kept on the exception for a host's
|
|
2851
|
+
* logger and never serialized into the body.
|
|
2840
2852
|
*/
|
|
2841
|
-
constructor(code: AuthErrorCode, details?: Record<string, unknown> | readonly unknown[]
|
|
2853
|
+
constructor(code: AuthErrorCode, details?: Record<string, unknown> | readonly unknown[], options?: {
|
|
2854
|
+
readonly cause?: unknown;
|
|
2855
|
+
});
|
|
2842
2856
|
}
|
|
2843
2857
|
|
|
2844
2858
|
/**
|
|
@@ -9755,12 +9769,13 @@ declare class TokenManagerService {
|
|
|
9755
9769
|
* @param user - Safe user object (credential fields excluded).
|
|
9756
9770
|
* @param ip - Client IP address (for session audit).
|
|
9757
9771
|
* @param userAgent - User-Agent header value (for session description).
|
|
9758
|
-
* @param overrides - Optional JWT claim overrides
|
|
9759
|
-
*
|
|
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.
|
|
9760
9774
|
* @returns Full auth result containing access token, raw refresh token, and user.
|
|
9761
9775
|
*/
|
|
9762
9776
|
issueTokens(user: SafeAuthUser, ip: string, userAgent: string, overrides?: {
|
|
9763
9777
|
mfaVerified?: boolean;
|
|
9778
|
+
credentialProved?: boolean;
|
|
9764
9779
|
}): Promise<AuthResult>;
|
|
9765
9780
|
/**
|
|
9766
9781
|
* Issues access + refresh tokens for a successfully authenticated platform admin.
|
|
@@ -10444,7 +10459,7 @@ declare class AuthService {
|
|
|
10444
10459
|
* instead — issuing tokens with `mfaVerified: false` would let the
|
|
10445
10460
|
* dashboard's `MfaRequiredGuard` lock the user out on every request.
|
|
10446
10461
|
*
|
|
10447
|
-
*
|
|
10462
|
+
* Unlike `login()`, the session is not a recent authentication. Other side effects mirror it:
|
|
10448
10463
|
* - Concurrent-session limit enforced via `sessionService.createSession`
|
|
10449
10464
|
* when `sessions.enabled`.
|
|
10450
10465
|
* - `userRepo.updateLastLogin` runs non-blocking.
|
|
@@ -11888,10 +11903,9 @@ declare class PasswordResetService {
|
|
|
11888
11903
|
* - The account is blocked.
|
|
11889
11904
|
* - Issuing or storing the code, or the email provider, fails for an account that exists.
|
|
11890
11905
|
*
|
|
11891
|
-
*
|
|
11892
|
-
*
|
|
11893
|
-
*
|
|
11894
|
-
* whether an email address is registered.
|
|
11906
|
+
* What a failure answers, and when the cooldown this call took is released, is decided in one
|
|
11907
|
+
* place, {@link answerResetRequest}. The response cannot be used to probe whether an email
|
|
11908
|
+
* address is registered.
|
|
11895
11909
|
*
|
|
11896
11910
|
* Timing normalization: the method always takes at least {@link ANTI_ENUM_MIN_MS}
|
|
11897
11911
|
* milliseconds to respond, regardless of whether the user was found.
|
|
@@ -11948,8 +11962,8 @@ declare class PasswordResetService {
|
|
|
11948
11962
|
*
|
|
11949
11963
|
* Subject to an atomic 60-second cooldown enforced via a Redis NX key to
|
|
11950
11964
|
* prevent OTP flooding. Resolves the same way whether or not the user exists —
|
|
11951
|
-
* anti-enumeration principle; a failure
|
|
11952
|
-
*
|
|
11965
|
+
* anti-enumeration principle; what a failure answers is decided in one place,
|
|
11966
|
+
* {@link answerResetRequest}.
|
|
11953
11967
|
*
|
|
11954
11968
|
* Timing normalization: always takes at least {@link ANTI_ENUM_MIN_MS} ms.
|
|
11955
11969
|
*
|
package/dist/server/index.d.ts
CHANGED
|
@@ -2749,6 +2749,16 @@ declare const AUTH_ERROR_CODES: {
|
|
|
2749
2749
|
* behaviour this library had before it existed.
|
|
2750
2750
|
*/
|
|
2751
2751
|
readonly INTERNAL: "auth.internal";
|
|
2752
|
+
/**
|
|
2753
|
+
* A store this request depends on, Redis, did not answer in time or could not be reached, so
|
|
2754
|
+
* the request was refused and nothing was admitted. Retrying later may succeed; nothing here
|
|
2755
|
+
* knows when, so the answer carries no `Retry-After`.
|
|
2756
|
+
*
|
|
2757
|
+
* Raised by the library's Redis wrapper, not only by {@link AuthExceptionFilter}: it is a typed
|
|
2758
|
+
* exception, so any host filter that renders an `HttpException` answers it as a 503. The ioredis
|
|
2759
|
+
* error rides on the exception as `cause` and is never serialized.
|
|
2760
|
+
*/
|
|
2761
|
+
readonly SERVICE_UNAVAILABLE: "auth.service_unavailable";
|
|
2752
2762
|
};
|
|
2753
2763
|
/**
|
|
2754
2764
|
* String literal union of all valid `AuthException` error codes.
|
|
@@ -2837,8 +2847,12 @@ declare class AuthException extends HttpException {
|
|
|
2837
2847
|
* @param details - Optional structured payload attached to the error body under
|
|
2838
2848
|
* `error.details`. An array where the failure is a list — `auth.validation` renders its
|
|
2839
2849
|
* per-field failures that way, matching what rust-auth serializes for the same code.
|
|
2850
|
+
* @param options - `cause`: the error this one reports, kept on the exception for a host's
|
|
2851
|
+
* logger and never serialized into the body.
|
|
2840
2852
|
*/
|
|
2841
|
-
constructor(code: AuthErrorCode, details?: Record<string, unknown> | readonly unknown[]
|
|
2853
|
+
constructor(code: AuthErrorCode, details?: Record<string, unknown> | readonly unknown[], options?: {
|
|
2854
|
+
readonly cause?: unknown;
|
|
2855
|
+
});
|
|
2842
2856
|
}
|
|
2843
2857
|
|
|
2844
2858
|
/**
|
|
@@ -9755,12 +9769,13 @@ declare class TokenManagerService {
|
|
|
9755
9769
|
* @param user - Safe user object (credential fields excluded).
|
|
9756
9770
|
* @param ip - Client IP address (for session audit).
|
|
9757
9771
|
* @param userAgent - User-Agent header value (for session description).
|
|
9758
|
-
* @param overrides - Optional JWT claim overrides
|
|
9759
|
-
*
|
|
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.
|
|
9760
9774
|
* @returns Full auth result containing access token, raw refresh token, and user.
|
|
9761
9775
|
*/
|
|
9762
9776
|
issueTokens(user: SafeAuthUser, ip: string, userAgent: string, overrides?: {
|
|
9763
9777
|
mfaVerified?: boolean;
|
|
9778
|
+
credentialProved?: boolean;
|
|
9764
9779
|
}): Promise<AuthResult>;
|
|
9765
9780
|
/**
|
|
9766
9781
|
* Issues access + refresh tokens for a successfully authenticated platform admin.
|
|
@@ -10444,7 +10459,7 @@ declare class AuthService {
|
|
|
10444
10459
|
* instead — issuing tokens with `mfaVerified: false` would let the
|
|
10445
10460
|
* dashboard's `MfaRequiredGuard` lock the user out on every request.
|
|
10446
10461
|
*
|
|
10447
|
-
*
|
|
10462
|
+
* Unlike `login()`, the session is not a recent authentication. Other side effects mirror it:
|
|
10448
10463
|
* - Concurrent-session limit enforced via `sessionService.createSession`
|
|
10449
10464
|
* when `sessions.enabled`.
|
|
10450
10465
|
* - `userRepo.updateLastLogin` runs non-blocking.
|
|
@@ -11888,10 +11903,9 @@ declare class PasswordResetService {
|
|
|
11888
11903
|
* - The account is blocked.
|
|
11889
11904
|
* - Issuing or storing the code, or the email provider, fails for an account that exists.
|
|
11890
11905
|
*
|
|
11891
|
-
*
|
|
11892
|
-
*
|
|
11893
|
-
*
|
|
11894
|
-
* whether an email address is registered.
|
|
11906
|
+
* What a failure answers, and when the cooldown this call took is released, is decided in one
|
|
11907
|
+
* place, {@link answerResetRequest}. The response cannot be used to probe whether an email
|
|
11908
|
+
* address is registered.
|
|
11895
11909
|
*
|
|
11896
11910
|
* Timing normalization: the method always takes at least {@link ANTI_ENUM_MIN_MS}
|
|
11897
11911
|
* milliseconds to respond, regardless of whether the user was found.
|
|
@@ -11948,8 +11962,8 @@ declare class PasswordResetService {
|
|
|
11948
11962
|
*
|
|
11949
11963
|
* Subject to an atomic 60-second cooldown enforced via a Redis NX key to
|
|
11950
11964
|
* prevent OTP flooding. Resolves the same way whether or not the user exists —
|
|
11951
|
-
* anti-enumeration principle; a failure
|
|
11952
|
-
*
|
|
11965
|
+
* anti-enumeration principle; what a failure answers is decided in one place,
|
|
11966
|
+
* {@link answerResetRequest}.
|
|
11953
11967
|
*
|
|
11954
11968
|
* Timing normalization: always takes at least {@link ANTI_ENUM_MIN_MS} ms.
|
|
11955
11969
|
*
|