@cross-deck/web 1.10.2 → 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.cjs CHANGED
@@ -98,7 +98,7 @@ function typeMapForStatus(status) {
98
98
  }
99
99
 
100
100
  // src/_version.ts
101
- var SDK_VERSION = "1.10.2";
101
+ var SDK_VERSION = "1.11.1";
102
102
  var SDK_NAME = "@cross-deck/web";
103
103
 
104
104
  // src/http.ts
@@ -1326,6 +1326,7 @@ var CookieStorage = class {
1326
1326
  this.maxAgeSec = options?.maxAgeSec ?? 63072e3;
1327
1327
  this.secure = options?.secure ?? defaultSecure();
1328
1328
  this.sameSite = options?.sameSite ?? "Lax";
1329
+ this.domain = options?.domain || void 0;
1329
1330
  }
1330
1331
  getItem(key) {
1331
1332
  if (!hasDocument()) return null;
@@ -1352,6 +1353,7 @@ var CookieStorage = class {
1352
1353
  `Max-Age=${this.maxAgeSec}`,
1353
1354
  `SameSite=${this.sameSite}`
1354
1355
  ];
1356
+ if (this.domain) parts.push(`Domain=${this.domain}`);
1355
1357
  if (this.secure) parts.push("Secure");
1356
1358
  try {
1357
1359
  doc.cookie = parts.join("; ");
@@ -1367,6 +1369,7 @@ var CookieStorage = class {
1367
1369
  "Max-Age=0",
1368
1370
  `SameSite=${this.sameSite}`
1369
1371
  ];
1372
+ if (this.domain) parts.push(`Domain=${this.domain}`);
1370
1373
  if (this.secure) parts.push("Secure");
1371
1374
  try {
1372
1375
  doc.cookie = parts.join("; ");
@@ -1374,6 +1377,34 @@ var CookieStorage = class {
1374
1377
  }
1375
1378
  }
1376
1379
  };
1380
+ function resolveCookieDomain(config) {
1381
+ if (config === void 0 || config === "none" || config === "") return void 0;
1382
+ if (config !== "auto") {
1383
+ const d = config.trim().toLowerCase();
1384
+ return d.startsWith(".") ? d : `.${d}`;
1385
+ }
1386
+ if (!hasDocument()) return void 0;
1387
+ const doc = globalThis.document;
1388
+ const loc = globalThis.location;
1389
+ const host = (loc?.hostname ?? "").toLowerCase();
1390
+ if (!host || host === "localhost" || /^\d{1,3}(\.\d{1,3}){3}$/.test(host) || host.indexOf(".") === -1) {
1391
+ return void 0;
1392
+ }
1393
+ const labels = host.split(".");
1394
+ for (let i = labels.length - 2; i >= 0; i--) {
1395
+ const candidate = "." + labels.slice(i).join(".");
1396
+ const testKey = "__cd_domain_probe";
1397
+ try {
1398
+ doc.cookie = `${testKey}=1; Domain=${candidate}; Path=/; SameSite=Lax`;
1399
+ const accepted = doc.cookie.indexOf(`${testKey}=1`) !== -1;
1400
+ doc.cookie = `${testKey}=; Domain=${candidate}; Path=/; Max-Age=0; SameSite=Lax`;
1401
+ if (accepted) return candidate;
1402
+ } catch {
1403
+ return void 0;
1404
+ }
1405
+ }
1406
+ return void 0;
1407
+ }
1377
1408
  function detectDefaultStorage() {
1378
1409
  try {
1379
1410
  const ls = globalThis.localStorage;
@@ -3837,7 +3868,18 @@ function isInAppFrame(filename) {
3837
3868
  if (/\/crossdeck\.umd\.min\.js$/.test(filename)) return false;
3838
3869
  return true;
3839
3870
  }
3871
+ var BROWSER_INJECTED_GLOBAL = /(__firefox__|__gCrWeb|zaloJSV2)/;
3872
+ function injectedGlobalName(message) {
3873
+ const m = BROWSER_INJECTED_GLOBAL.exec(message ?? "");
3874
+ return m ? m[1] : null;
3875
+ }
3876
+ function demoteVendorInjectedFrames(frames, message) {
3877
+ if (!injectedGlobalName(message)) return frames;
3878
+ return frames.map((f) => f.in_app ? { ...f, in_app: false } : f);
3879
+ }
3840
3880
  function fingerprintError(message, frames, location2) {
3881
+ const injected = injectedGlobalName(message);
3882
+ if (injected) return djb2Hex(`injected-global:${injected}`);
3841
3883
  const inAppFrames = frames.filter((f) => f.in_app).slice(0, 3);
3842
3884
  const parts = [
3843
3885
  (message || "").slice(0, 200),
@@ -4194,7 +4236,7 @@ var ErrorTracker = class {
4194
4236
  const payload = coerceErrorPayload(err);
4195
4237
  const message = (payload.message || event.message || "Unknown error").slice(0, 1024);
4196
4238
  const stack = err instanceof Error ? err.stack ?? null : null;
4197
- const frames = parseStack(stack);
4239
+ const frames = demoteVendorInjectedFrames(parseStack(stack), message);
4198
4240
  const errorType = payload.errorType ?? null;
4199
4241
  const context = payload.extras ? { ...this.opts.getContext(), __error_extras: payload.extras } : this.opts.getContext();
4200
4242
  return {
@@ -4226,7 +4268,7 @@ var ErrorTracker = class {
4226
4268
  const payload = coerceErrorPayload(err);
4227
4269
  const message = (payload.message || "Unknown error").slice(0, 1024);
4228
4270
  const stack = err instanceof Error ? err.stack ?? null : null;
4229
- const frames = parseStack(stack);
4271
+ const frames = demoteVendorInjectedFrames(parseStack(stack), message);
4230
4272
  const errorType = payload.errorType ?? null;
4231
4273
  const context = payload.extras ? { ...this.opts.getContext(), __error_extras: payload.extras } : this.opts.getContext();
4232
4274
  return {
@@ -4642,7 +4684,7 @@ var CrossdeckClient = class {
4642
4684
  const effectiveStorage = persistIdentity ? storage : new MemoryStorage();
4643
4685
  const useCookieRedundancy = persistIdentity && !options.storage && // honour caller's adapter choice
4644
4686
  typeof globalThis.document !== "undefined";
4645
- const cookieStore = useCookieRedundancy ? new CookieStorage() : void 0;
4687
+ const cookieStore = useCookieRedundancy ? new CookieStorage({ domain: resolveCookieDomain(options.cookieDomain ?? "auto") }) : void 0;
4646
4688
  const identity = new IdentityStore(effectiveStorage, opts.storagePrefix, cookieStore);
4647
4689
  const entitlements = new EntitlementCache(
4648
4690
  effectiveStorage,