@fonderie/auth 7.17.0 → 7.17.1
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/dist/index.cjs +15 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -4
- package/dist/index.js.map +1 -1
- package/dist/middlewares/index.cjs.map +1 -1
- package/dist/middlewares/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -312,8 +312,8 @@ function issueMfaPendingToken(userId, config, loginMethod) {
|
|
|
312
312
|
);
|
|
313
313
|
}
|
|
314
314
|
function issueTokenPair(userId, config, options) {
|
|
315
|
-
const duration = config.sessionDuration
|
|
316
|
-
const accessDuration = config.accessTokenDuration
|
|
315
|
+
const duration = validDuration(config.sessionDuration, DEFAULT_SESSION_DURATION, "sessionDuration");
|
|
316
|
+
const accessDuration = validDuration(config.accessTokenDuration, DEFAULT_ACCESS_TOKEN_DURATION, "accessTokenDuration");
|
|
317
317
|
const authTime = options.authTime ?? Math.floor(Date.now() / 1e3);
|
|
318
318
|
const loginMethod = options.loginMethod;
|
|
319
319
|
const phoneVerified = options.phoneVerified ?? false;
|
|
@@ -356,6 +356,17 @@ function durationMs(value) {
|
|
|
356
356
|
const scale = { ms: 1, s: 1e3, m: 6e4, h: 36e5, d: 864e5, w: 6048e5, y: 315576e5 };
|
|
357
357
|
return Number(m[1]) * (scale[unit] ?? 1e3);
|
|
358
358
|
}
|
|
359
|
+
var warnedDurations = /* @__PURE__ */ new Set();
|
|
360
|
+
function validDuration(value, fallback, name) {
|
|
361
|
+
if (value === void 0 || value === null || value === "") return fallback;
|
|
362
|
+
if (durationMs(String(value)) !== null) return String(value);
|
|
363
|
+
const key = `${name}=${String(value)}`;
|
|
364
|
+
if (!warnedDurations.has(key)) {
|
|
365
|
+
warnedDurations.add(key);
|
|
366
|
+
console.warn(`[auth] ${name} ${JSON.stringify(value)} is not a duration (e.g. '90d', '1h') \u2014 using ${fallback}`);
|
|
367
|
+
}
|
|
368
|
+
return fallback;
|
|
369
|
+
}
|
|
359
370
|
|
|
360
371
|
// src/services/mfa.ts
|
|
361
372
|
import { createHmac, randomBytes } from "crypto";
|
|
@@ -1970,7 +1981,7 @@ function authController(store, config, bus, locales = defineLocales()) {
|
|
|
1970
1981
|
return setApiResponse3(HTTP3.UNAUTHORIZED, "TOKEN_REFRESH_FAILED", "Invalid refresh token");
|
|
1971
1982
|
}
|
|
1972
1983
|
const resolvedRefresh = { ...config, ...config.resolve?.(ctx) };
|
|
1973
|
-
const maxAgeMs = durationMs(resolvedRefresh.sessionMaxAge);
|
|
1984
|
+
const maxAgeMs = resolvedRefresh.sessionMaxAge ? durationMs(String(resolvedRefresh.sessionMaxAge)) : null;
|
|
1974
1985
|
let issued = null;
|
|
1975
1986
|
for (let attempt = 0; attempt < 3 && !issued; attempt++) {
|
|
1976
1987
|
const found = await sessions.match(token);
|
|
@@ -3629,7 +3640,7 @@ var AuthModule = class {
|
|
|
3629
3640
|
name = "@fonderie/auth";
|
|
3630
3641
|
// Baked in at build time by tsup.base, so the operator's Modules page can
|
|
3631
3642
|
// say what is actually deployed rather than 'not reported'.
|
|
3632
|
-
version = "7.17.
|
|
3643
|
+
version = "7.17.1";
|
|
3633
3644
|
// Users, sessions, login history, suspend — only through @fonderie/admin.
|
|
3634
3645
|
describeAdmin() {
|
|
3635
3646
|
return { routes: describeAuthAdminRoutes(this.store) };
|