@cross-deck/web 1.10.3 → 1.11.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/react.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { C as CrossdeckOptions } from './types-B9sxUuKh.mjs';
2
+ import { C as CrossdeckOptions } from './types-iqtsOTGy.mjs';
3
3
 
4
4
  /**
5
5
  * @cross-deck/web/react — React hooks for the Crossdeck SDK.
package/dist/react.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { C as CrossdeckOptions } from './types-B9sxUuKh.js';
2
+ import { C as CrossdeckOptions } from './types-iqtsOTGy.js';
3
3
 
4
4
  /**
5
5
  * @cross-deck/web/react — React hooks for the Crossdeck SDK.
package/dist/react.mjs CHANGED
@@ -72,7 +72,7 @@ function typeMapForStatus(status) {
72
72
  }
73
73
 
74
74
  // src/_version.ts
75
- var SDK_VERSION = "1.10.3";
75
+ var SDK_VERSION = "1.11.1";
76
76
  var SDK_NAME = "@cross-deck/web";
77
77
 
78
78
  // src/http.ts
@@ -1300,6 +1300,7 @@ var CookieStorage = class {
1300
1300
  this.maxAgeSec = options?.maxAgeSec ?? 63072e3;
1301
1301
  this.secure = options?.secure ?? defaultSecure();
1302
1302
  this.sameSite = options?.sameSite ?? "Lax";
1303
+ this.domain = options?.domain || void 0;
1303
1304
  }
1304
1305
  getItem(key) {
1305
1306
  if (!hasDocument()) return null;
@@ -1326,6 +1327,7 @@ var CookieStorage = class {
1326
1327
  `Max-Age=${this.maxAgeSec}`,
1327
1328
  `SameSite=${this.sameSite}`
1328
1329
  ];
1330
+ if (this.domain) parts.push(`Domain=${this.domain}`);
1329
1331
  if (this.secure) parts.push("Secure");
1330
1332
  try {
1331
1333
  doc.cookie = parts.join("; ");
@@ -1341,6 +1343,7 @@ var CookieStorage = class {
1341
1343
  "Max-Age=0",
1342
1344
  `SameSite=${this.sameSite}`
1343
1345
  ];
1346
+ if (this.domain) parts.push(`Domain=${this.domain}`);
1344
1347
  if (this.secure) parts.push("Secure");
1345
1348
  try {
1346
1349
  doc.cookie = parts.join("; ");
@@ -1348,6 +1351,34 @@ var CookieStorage = class {
1348
1351
  }
1349
1352
  }
1350
1353
  };
1354
+ function resolveCookieDomain(config) {
1355
+ if (config === void 0 || config === "none" || config === "") return void 0;
1356
+ if (config !== "auto") {
1357
+ const d = config.trim().toLowerCase();
1358
+ return d.startsWith(".") ? d : `.${d}`;
1359
+ }
1360
+ if (!hasDocument()) return void 0;
1361
+ const doc = globalThis.document;
1362
+ const loc = globalThis.location;
1363
+ const host = (loc?.hostname ?? "").toLowerCase();
1364
+ if (!host || host === "localhost" || /^\d{1,3}(\.\d{1,3}){3}$/.test(host) || host.indexOf(".") === -1) {
1365
+ return void 0;
1366
+ }
1367
+ const labels = host.split(".");
1368
+ for (let i = labels.length - 2; i >= 0; i--) {
1369
+ const candidate = "." + labels.slice(i).join(".");
1370
+ const testKey = "__cd_domain_probe";
1371
+ try {
1372
+ doc.cookie = `${testKey}=1; Domain=${candidate}; Path=/; SameSite=Lax`;
1373
+ const accepted = doc.cookie.indexOf(`${testKey}=1`) !== -1;
1374
+ doc.cookie = `${testKey}=; Domain=${candidate}; Path=/; Max-Age=0; SameSite=Lax`;
1375
+ if (accepted) return candidate;
1376
+ } catch {
1377
+ return void 0;
1378
+ }
1379
+ }
1380
+ return void 0;
1381
+ }
1351
1382
  function detectDefaultStorage() {
1352
1383
  try {
1353
1384
  const ls = globalThis.localStorage;
@@ -4627,7 +4658,7 @@ var CrossdeckClient = class {
4627
4658
  const effectiveStorage = persistIdentity ? storage : new MemoryStorage();
4628
4659
  const useCookieRedundancy = persistIdentity && !options.storage && // honour caller's adapter choice
4629
4660
  typeof globalThis.document !== "undefined";
4630
- const cookieStore = useCookieRedundancy ? new CookieStorage() : void 0;
4661
+ const cookieStore = useCookieRedundancy ? new CookieStorage({ domain: resolveCookieDomain(options.cookieDomain ?? "auto") }) : void 0;
4631
4662
  const identity = new IdentityStore(effectiveStorage, opts.storagePrefix, cookieStore);
4632
4663
  const entitlements = new EntitlementCache(
4633
4664
  effectiveStorage,