@digilogiclabs/platform-core 1.17.0 → 1.17.2
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/auth.d.mts +27 -0
- package/dist/auth.d.ts +27 -0
- package/dist/auth.js +45 -14
- package/dist/auth.js.map +1 -1
- package/dist/auth.mjs +45 -14
- package/dist/auth.mjs.map +1 -1
- package/dist/index.js +145 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +145 -29
- package/dist/index.mjs.map +1 -1
- package/dist/migrate.js +5 -1
- package/dist/migrate.js.map +1 -1
- package/package.json +11 -11
package/dist/auth.d.mts
CHANGED
|
@@ -341,6 +341,33 @@ interface FederatedLogoutConfig {
|
|
|
341
341
|
* If not provided, errors are silently ignored.
|
|
342
342
|
*/
|
|
343
343
|
onError?: (message: string, error?: unknown) => void;
|
|
344
|
+
/**
|
|
345
|
+
* Number of chunk suffixes to enumerate when clearing session-token cookies.
|
|
346
|
+
*
|
|
347
|
+
* Auth.js splits encrypted JWE session tokens across `.0`, `.1`, `.2` ...
|
|
348
|
+
* suffixed cookies when the value exceeds the ~4 KB per-cookie limit.
|
|
349
|
+
* Keycloak access + id + refresh tokens reliably push past this threshold,
|
|
350
|
+
* so the unsuffixed name alone does NOT clear the session in production —
|
|
351
|
+
* the chunks survive and Auth.js reassembles the session on the next
|
|
352
|
+
* `/api/auth/session` call, causing silent re-auth after logout.
|
|
353
|
+
*
|
|
354
|
+
* Default: `3` (covers `.0`/`.1`/`.2` — 12 KB ceiling, well above any
|
|
355
|
+
* realistic JWE). Raise only if your tokens are unusually large; each
|
|
356
|
+
* additional chunk adds 4 Set-Cookie headers (host + domain scopes for
|
|
357
|
+
* both `authjs` and `next-auth` session-token names), and the total
|
|
358
|
+
* response headers must stay under Cloudflare's ~16 KB HTTP/2 limit.
|
|
359
|
+
*/
|
|
360
|
+
chunkCount?: number;
|
|
361
|
+
/**
|
|
362
|
+
* Whether to also clear legacy `next-auth.*` cookie names in addition to
|
|
363
|
+
* the `authjs.*` names. Defaults to `true` for compatibility with apps
|
|
364
|
+
* that migrated from NextAuth v4 → Auth.js v5 (their sessions may still
|
|
365
|
+
* be under the old names). Set to `false` on apps that never ran
|
|
366
|
+
* pre-Auth.js-v5 to slim the Set-Cookie response.
|
|
367
|
+
*
|
|
368
|
+
* Default: `true`
|
|
369
|
+
*/
|
|
370
|
+
includeLegacyNextAuthCookies?: boolean;
|
|
344
371
|
}
|
|
345
372
|
/**
|
|
346
373
|
* Build a Next.js route handler for federated logout with Keycloak.
|
package/dist/auth.d.ts
CHANGED
|
@@ -341,6 +341,33 @@ interface FederatedLogoutConfig {
|
|
|
341
341
|
* If not provided, errors are silently ignored.
|
|
342
342
|
*/
|
|
343
343
|
onError?: (message: string, error?: unknown) => void;
|
|
344
|
+
/**
|
|
345
|
+
* Number of chunk suffixes to enumerate when clearing session-token cookies.
|
|
346
|
+
*
|
|
347
|
+
* Auth.js splits encrypted JWE session tokens across `.0`, `.1`, `.2` ...
|
|
348
|
+
* suffixed cookies when the value exceeds the ~4 KB per-cookie limit.
|
|
349
|
+
* Keycloak access + id + refresh tokens reliably push past this threshold,
|
|
350
|
+
* so the unsuffixed name alone does NOT clear the session in production —
|
|
351
|
+
* the chunks survive and Auth.js reassembles the session on the next
|
|
352
|
+
* `/api/auth/session` call, causing silent re-auth after logout.
|
|
353
|
+
*
|
|
354
|
+
* Default: `3` (covers `.0`/`.1`/`.2` — 12 KB ceiling, well above any
|
|
355
|
+
* realistic JWE). Raise only if your tokens are unusually large; each
|
|
356
|
+
* additional chunk adds 4 Set-Cookie headers (host + domain scopes for
|
|
357
|
+
* both `authjs` and `next-auth` session-token names), and the total
|
|
358
|
+
* response headers must stay under Cloudflare's ~16 KB HTTP/2 limit.
|
|
359
|
+
*/
|
|
360
|
+
chunkCount?: number;
|
|
361
|
+
/**
|
|
362
|
+
* Whether to also clear legacy `next-auth.*` cookie names in addition to
|
|
363
|
+
* the `authjs.*` names. Defaults to `true` for compatibility with apps
|
|
364
|
+
* that migrated from NextAuth v4 → Auth.js v5 (their sessions may still
|
|
365
|
+
* be under the old names). Set to `false` on apps that never ran
|
|
366
|
+
* pre-Auth.js-v5 to slim the Set-Cookie response.
|
|
367
|
+
*
|
|
368
|
+
* Default: `true`
|
|
369
|
+
*/
|
|
370
|
+
includeLegacyNextAuthCookies?: boolean;
|
|
344
371
|
}
|
|
345
372
|
/**
|
|
346
373
|
* Build a Next.js route handler for federated logout with Keycloak.
|
package/dist/auth.js
CHANGED
|
@@ -1428,9 +1428,15 @@ function isAllowedCallbackUrl(url, baseUrl) {
|
|
|
1428
1428
|
return false;
|
|
1429
1429
|
}
|
|
1430
1430
|
}
|
|
1431
|
-
var
|
|
1431
|
+
var SESSION_TOKEN_BASE_NAMES_AUTHJS = [
|
|
1432
1432
|
"authjs.session-token",
|
|
1433
|
-
"__Secure-authjs.session-token"
|
|
1433
|
+
"__Secure-authjs.session-token"
|
|
1434
|
+
];
|
|
1435
|
+
var SESSION_TOKEN_BASE_NAMES_LEGACY = [
|
|
1436
|
+
"next-auth.session-token",
|
|
1437
|
+
"__Secure-next-auth.session-token"
|
|
1438
|
+
];
|
|
1439
|
+
var NON_SESSION_COOKIE_NAMES_AUTHJS = [
|
|
1434
1440
|
"authjs.callback-url",
|
|
1435
1441
|
"__Secure-authjs.callback-url",
|
|
1436
1442
|
"authjs.csrf-token",
|
|
@@ -1438,21 +1444,42 @@ var AUTH_COOKIE_NAMES = [
|
|
|
1438
1444
|
"authjs.pkce.code_verifier",
|
|
1439
1445
|
"__Secure-authjs.pkce.code_verifier",
|
|
1440
1446
|
"authjs.state",
|
|
1441
|
-
"__Secure-authjs.state"
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
"__Secure-next-auth.session-token",
|
|
1447
|
+
"__Secure-authjs.state"
|
|
1448
|
+
];
|
|
1449
|
+
var NON_SESSION_COOKIE_NAMES_LEGACY = [
|
|
1445
1450
|
"next-auth.callback-url",
|
|
1446
1451
|
"__Secure-next-auth.callback-url",
|
|
1447
1452
|
"next-auth.csrf-token",
|
|
1448
1453
|
"__Secure-next-auth.csrf-token"
|
|
1449
1454
|
];
|
|
1450
|
-
var
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
];
|
|
1455
|
+
var HOST_COOKIES_AUTHJS = ["__Host-authjs.csrf-token"];
|
|
1456
|
+
var HOST_COOKIES_LEGACY = ["__Host-next-auth.csrf-token"];
|
|
1457
|
+
function buildCookieNames(chunkCount, includeLegacy, extraCookies) {
|
|
1458
|
+
const sessionBases = includeLegacy ? [...SESSION_TOKEN_BASE_NAMES_AUTHJS, ...SESSION_TOKEN_BASE_NAMES_LEGACY] : SESSION_TOKEN_BASE_NAMES_AUTHJS;
|
|
1459
|
+
const sessionExpanded = [];
|
|
1460
|
+
for (const base of sessionBases) {
|
|
1461
|
+
sessionExpanded.push(base);
|
|
1462
|
+
for (let i = 0; i < chunkCount; i++) {
|
|
1463
|
+
sessionExpanded.push(`${base}.${i}`);
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
const nonSession = includeLegacy ? [...NON_SESSION_COOKIE_NAMES_AUTHJS, ...NON_SESSION_COOKIE_NAMES_LEGACY] : NON_SESSION_COOKIE_NAMES_AUTHJS;
|
|
1467
|
+
const hostPrefixed = includeLegacy ? [...HOST_COOKIES_AUTHJS, ...HOST_COOKIES_LEGACY] : HOST_COOKIES_AUTHJS;
|
|
1468
|
+
return {
|
|
1469
|
+
scoped: [...sessionExpanded, ...nonSession, ...extraCookies],
|
|
1470
|
+
hostPrefixed
|
|
1471
|
+
};
|
|
1472
|
+
}
|
|
1454
1473
|
function buildFederatedLogoutHandler(config) {
|
|
1455
|
-
const {
|
|
1474
|
+
const {
|
|
1475
|
+
auth,
|
|
1476
|
+
domain,
|
|
1477
|
+
baseUrlFallback,
|
|
1478
|
+
extraCookies = [],
|
|
1479
|
+
onError,
|
|
1480
|
+
chunkCount = 3,
|
|
1481
|
+
includeLegacyNextAuthCookies = true
|
|
1482
|
+
} = config;
|
|
1456
1483
|
return async function GET(request) {
|
|
1457
1484
|
const session = await auth();
|
|
1458
1485
|
const url = new URL(request.url);
|
|
@@ -1523,8 +1550,12 @@ function buildFederatedLogoutHandler(config) {
|
|
|
1523
1550
|
});
|
|
1524
1551
|
const isProduction = process.env.NODE_ENV === "production";
|
|
1525
1552
|
const isSecure = isProduction;
|
|
1526
|
-
const
|
|
1527
|
-
|
|
1553
|
+
const { scoped, hostPrefixed } = buildCookieNames(
|
|
1554
|
+
chunkCount,
|
|
1555
|
+
includeLegacyNextAuthCookies,
|
|
1556
|
+
extraCookies
|
|
1557
|
+
);
|
|
1558
|
+
for (const name of scoped) {
|
|
1528
1559
|
const needsSecure = isSecure || name.startsWith("__Secure-");
|
|
1529
1560
|
response.headers.append(
|
|
1530
1561
|
"Set-Cookie",
|
|
@@ -1537,7 +1568,7 @@ function buildFederatedLogoutHandler(config) {
|
|
|
1537
1568
|
);
|
|
1538
1569
|
}
|
|
1539
1570
|
}
|
|
1540
|
-
for (const name of
|
|
1571
|
+
for (const name of hostPrefixed) {
|
|
1541
1572
|
response.headers.append(
|
|
1542
1573
|
"Set-Cookie",
|
|
1543
1574
|
expireCookie(name, { hostPrefix: true })
|