@digilogiclabs/platform-core 1.17.1 → 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.mjs CHANGED
@@ -1316,9 +1316,15 @@ function isAllowedCallbackUrl(url, baseUrl) {
1316
1316
  return false;
1317
1317
  }
1318
1318
  }
1319
- var AUTH_COOKIE_NAMES = [
1319
+ var SESSION_TOKEN_BASE_NAMES_AUTHJS = [
1320
1320
  "authjs.session-token",
1321
- "__Secure-authjs.session-token",
1321
+ "__Secure-authjs.session-token"
1322
+ ];
1323
+ var SESSION_TOKEN_BASE_NAMES_LEGACY = [
1324
+ "next-auth.session-token",
1325
+ "__Secure-next-auth.session-token"
1326
+ ];
1327
+ var NON_SESSION_COOKIE_NAMES_AUTHJS = [
1322
1328
  "authjs.callback-url",
1323
1329
  "__Secure-authjs.callback-url",
1324
1330
  "authjs.csrf-token",
@@ -1326,21 +1332,42 @@ var AUTH_COOKIE_NAMES = [
1326
1332
  "authjs.pkce.code_verifier",
1327
1333
  "__Secure-authjs.pkce.code_verifier",
1328
1334
  "authjs.state",
1329
- "__Secure-authjs.state",
1330
- // Legacy next-auth names
1331
- "next-auth.session-token",
1332
- "__Secure-next-auth.session-token",
1335
+ "__Secure-authjs.state"
1336
+ ];
1337
+ var NON_SESSION_COOKIE_NAMES_LEGACY = [
1333
1338
  "next-auth.callback-url",
1334
1339
  "__Secure-next-auth.callback-url",
1335
1340
  "next-auth.csrf-token",
1336
1341
  "__Secure-next-auth.csrf-token"
1337
1342
  ];
1338
- var HOST_COOKIES = [
1339
- "__Host-authjs.csrf-token",
1340
- "__Host-next-auth.csrf-token"
1341
- ];
1343
+ var HOST_COOKIES_AUTHJS = ["__Host-authjs.csrf-token"];
1344
+ var HOST_COOKIES_LEGACY = ["__Host-next-auth.csrf-token"];
1345
+ function buildCookieNames(chunkCount, includeLegacy, extraCookies) {
1346
+ const sessionBases = includeLegacy ? [...SESSION_TOKEN_BASE_NAMES_AUTHJS, ...SESSION_TOKEN_BASE_NAMES_LEGACY] : SESSION_TOKEN_BASE_NAMES_AUTHJS;
1347
+ const sessionExpanded = [];
1348
+ for (const base of sessionBases) {
1349
+ sessionExpanded.push(base);
1350
+ for (let i = 0; i < chunkCount; i++) {
1351
+ sessionExpanded.push(`${base}.${i}`);
1352
+ }
1353
+ }
1354
+ const nonSession = includeLegacy ? [...NON_SESSION_COOKIE_NAMES_AUTHJS, ...NON_SESSION_COOKIE_NAMES_LEGACY] : NON_SESSION_COOKIE_NAMES_AUTHJS;
1355
+ const hostPrefixed = includeLegacy ? [...HOST_COOKIES_AUTHJS, ...HOST_COOKIES_LEGACY] : HOST_COOKIES_AUTHJS;
1356
+ return {
1357
+ scoped: [...sessionExpanded, ...nonSession, ...extraCookies],
1358
+ hostPrefixed
1359
+ };
1360
+ }
1342
1361
  function buildFederatedLogoutHandler(config) {
1343
- const { auth, domain, baseUrlFallback, extraCookies = [], onError } = config;
1362
+ const {
1363
+ auth,
1364
+ domain,
1365
+ baseUrlFallback,
1366
+ extraCookies = [],
1367
+ onError,
1368
+ chunkCount = 3,
1369
+ includeLegacyNextAuthCookies = true
1370
+ } = config;
1344
1371
  return async function GET(request) {
1345
1372
  const session = await auth();
1346
1373
  const url = new URL(request.url);
@@ -1411,8 +1438,12 @@ function buildFederatedLogoutHandler(config) {
1411
1438
  });
1412
1439
  const isProduction = process.env.NODE_ENV === "production";
1413
1440
  const isSecure = isProduction;
1414
- const allCookieNames = [...AUTH_COOKIE_NAMES, ...extraCookies];
1415
- for (const name of allCookieNames) {
1441
+ const { scoped, hostPrefixed } = buildCookieNames(
1442
+ chunkCount,
1443
+ includeLegacyNextAuthCookies,
1444
+ extraCookies
1445
+ );
1446
+ for (const name of scoped) {
1416
1447
  const needsSecure = isSecure || name.startsWith("__Secure-");
1417
1448
  response.headers.append(
1418
1449
  "Set-Cookie",
@@ -1425,7 +1456,7 @@ function buildFederatedLogoutHandler(config) {
1425
1456
  );
1426
1457
  }
1427
1458
  }
1428
- for (const name of HOST_COOKIES) {
1459
+ for (const name of hostPrefixed) {
1429
1460
  response.headers.append(
1430
1461
  "Set-Cookie",
1431
1462
  expireCookie(name, { hostPrefix: true })