@cross-deck/web 1.12.1 → 1.13.0
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/CHANGELOG.md +10 -0
- package/README.md +35 -0
- package/dist/crossdeck.umd.min.js +2 -2
- package/dist/crossdeck.umd.min.js.map +1 -1
- package/dist/error-codes.json +1 -1
- package/dist/index.cjs +150 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +23 -2
- package/dist/index.d.ts +23 -2
- package/dist/index.mjs +147 -2
- package/dist/index.mjs.map +1 -1
- package/dist/react.cjs +186 -3
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.mts +40 -2
- package/dist/react.d.ts +40 -2
- package/dist/react.mjs +184 -3
- package/dist/react.mjs.map +1 -1
- package/dist/trust-C0RcpR5I.d.mts +91 -0
- package/dist/trust-C0RcpR5I.d.ts +91 -0
- package/dist/vue.cjs +168 -3
- package/dist/vue.cjs.map +1 -1
- package/dist/vue.d.mts +25 -1
- package/dist/vue.d.ts +25 -1
- package/dist/vue.mjs +166 -2
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { C as CrossdeckTrustNamespace } from './trust-C0RcpR5I.mjs';
|
|
2
|
+
export { M as MountTrustPanelOptions, T as TRUST_PANEL_ORIGIN, a as TrustPanelHandle, b as TrustPanelInput, c as TrustResult, d as TrustToken, e as TrustTokenStatus, f as TrustUnavailable, m as mountTrustPanel } from './trust-C0RcpR5I.mjs';
|
|
1
3
|
import { P as PublicEntitlement, C as CrossdeckOptions, I as IdentifyOptions, A as AliasResult, G as GroupTraits, E as EventProperties, a as PurchaseResult, H as HeartbeatResponse, D as Diagnostics, K as KeyValueStorage } from './types-iqtsOTGy.mjs';
|
|
2
4
|
export { b as AuditRail, c as AutoTrackOptions, d as EntitlementsListResponse, e as Environment, f as Platform } from './types-iqtsOTGy.mjs';
|
|
3
5
|
|
|
@@ -821,6 +823,25 @@ declare class CrossdeckClient {
|
|
|
821
823
|
* user is authenticated.
|
|
822
824
|
*/
|
|
823
825
|
getAnonymousId(): string | null;
|
|
826
|
+
/**
|
|
827
|
+
* **Crossdeck Trust** — human-proof at your signup, native to the SDK.
|
|
828
|
+
*
|
|
829
|
+
* `Crossdeck.trust.panel({ target, onToken })` renders the branded, un-restylable
|
|
830
|
+
* Trust panel (the same cross-origin iframe on every install) and mints a
|
|
831
|
+
* single-use attestation. Hand the token to your server and verify it at the gate
|
|
832
|
+
* (`crossdeck.trust.gate(...)` in @cross-deck/node). The publishable key is taken
|
|
833
|
+
* from your `init()` — you don't pass it again.
|
|
834
|
+
*
|
|
835
|
+
* Fail-open by contract: if the panel can't mint (adblocker, offline, our outage),
|
|
836
|
+
* `ready` resolves with `{ token: null }` and your signup proceeds — the server
|
|
837
|
+
* scores the missing token. It never throws and never blocks your form.
|
|
838
|
+
*
|
|
839
|
+
* @example
|
|
840
|
+
* const { ready } = Crossdeck.trust.panel({ target: "#cd-trust" });
|
|
841
|
+
* const result = await ready; // { token, expiresAt } | { token: null }
|
|
842
|
+
* await createUser({ email, cdTrustToken: result.token });
|
|
843
|
+
*/
|
|
844
|
+
get trust(): CrossdeckTrustNamespace;
|
|
824
845
|
private requireStarted;
|
|
825
846
|
/**
|
|
826
847
|
* Build the identity query for /v1/entitlements. Priority:
|
|
@@ -969,7 +990,7 @@ declare class MemoryStorage implements KeyValueStorage {
|
|
|
969
990
|
*
|
|
970
991
|
* Do NOT edit by hand — `node scripts/sync-sdk-versions.mjs`.
|
|
971
992
|
*/
|
|
972
|
-
declare const SDK_VERSION = "1.
|
|
993
|
+
declare const SDK_VERSION = "1.13.0";
|
|
973
994
|
declare const SDK_NAME = "@cross-deck/web";
|
|
974
995
|
|
|
975
996
|
/**
|
|
@@ -1053,4 +1074,4 @@ interface DeviceInfo {
|
|
|
1053
1074
|
appVersion?: string;
|
|
1054
1075
|
}
|
|
1055
1076
|
|
|
1056
|
-
export { AliasResult, type Breadcrumb, type BreadcrumbCategory, type BreadcrumbLevel, CROSSDECK_ERROR_CODES, type CapturedError, type ConsentState, type Contract, type ContractAppliesTo, type ContractFailureInput, type ContractPillar, type ContractStatus, type ContractTestRef, Crossdeck, CrossdeckClient, CrossdeckContracts, CrossdeckError, type CrossdeckErrorPayload, type CrossdeckErrorType, CrossdeckOptions, DEFAULT_BASE_URL, type DeviceInfo, Diagnostics, type ErrorCodeEntry, type ErrorLevel, EventProperties, GroupTraits, HeartbeatResponse, IdentifyOptions, KeyValueStorage, MemoryStorage, PublicEntitlement, PurchaseResult, SDK_NAME, SDK_VERSION, type StackFrame, getErrorCode };
|
|
1077
|
+
export { AliasResult, type Breadcrumb, type BreadcrumbCategory, type BreadcrumbLevel, CROSSDECK_ERROR_CODES, type CapturedError, type ConsentState, type Contract, type ContractAppliesTo, type ContractFailureInput, type ContractPillar, type ContractStatus, type ContractTestRef, Crossdeck, CrossdeckClient, CrossdeckContracts, CrossdeckError, type CrossdeckErrorPayload, type CrossdeckErrorType, CrossdeckOptions, CrossdeckTrustNamespace, DEFAULT_BASE_URL, type DeviceInfo, Diagnostics, type ErrorCodeEntry, type ErrorLevel, EventProperties, GroupTraits, HeartbeatResponse, IdentifyOptions, KeyValueStorage, MemoryStorage, PublicEntitlement, PurchaseResult, SDK_NAME, SDK_VERSION, type StackFrame, getErrorCode };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { C as CrossdeckTrustNamespace } from './trust-C0RcpR5I.js';
|
|
2
|
+
export { M as MountTrustPanelOptions, T as TRUST_PANEL_ORIGIN, a as TrustPanelHandle, b as TrustPanelInput, c as TrustResult, d as TrustToken, e as TrustTokenStatus, f as TrustUnavailable, m as mountTrustPanel } from './trust-C0RcpR5I.js';
|
|
1
3
|
import { P as PublicEntitlement, C as CrossdeckOptions, I as IdentifyOptions, A as AliasResult, G as GroupTraits, E as EventProperties, a as PurchaseResult, H as HeartbeatResponse, D as Diagnostics, K as KeyValueStorage } from './types-iqtsOTGy.js';
|
|
2
4
|
export { b as AuditRail, c as AutoTrackOptions, d as EntitlementsListResponse, e as Environment, f as Platform } from './types-iqtsOTGy.js';
|
|
3
5
|
|
|
@@ -821,6 +823,25 @@ declare class CrossdeckClient {
|
|
|
821
823
|
* user is authenticated.
|
|
822
824
|
*/
|
|
823
825
|
getAnonymousId(): string | null;
|
|
826
|
+
/**
|
|
827
|
+
* **Crossdeck Trust** — human-proof at your signup, native to the SDK.
|
|
828
|
+
*
|
|
829
|
+
* `Crossdeck.trust.panel({ target, onToken })` renders the branded, un-restylable
|
|
830
|
+
* Trust panel (the same cross-origin iframe on every install) and mints a
|
|
831
|
+
* single-use attestation. Hand the token to your server and verify it at the gate
|
|
832
|
+
* (`crossdeck.trust.gate(...)` in @cross-deck/node). The publishable key is taken
|
|
833
|
+
* from your `init()` — you don't pass it again.
|
|
834
|
+
*
|
|
835
|
+
* Fail-open by contract: if the panel can't mint (adblocker, offline, our outage),
|
|
836
|
+
* `ready` resolves with `{ token: null }` and your signup proceeds — the server
|
|
837
|
+
* scores the missing token. It never throws and never blocks your form.
|
|
838
|
+
*
|
|
839
|
+
* @example
|
|
840
|
+
* const { ready } = Crossdeck.trust.panel({ target: "#cd-trust" });
|
|
841
|
+
* const result = await ready; // { token, expiresAt } | { token: null }
|
|
842
|
+
* await createUser({ email, cdTrustToken: result.token });
|
|
843
|
+
*/
|
|
844
|
+
get trust(): CrossdeckTrustNamespace;
|
|
824
845
|
private requireStarted;
|
|
825
846
|
/**
|
|
826
847
|
* Build the identity query for /v1/entitlements. Priority:
|
|
@@ -969,7 +990,7 @@ declare class MemoryStorage implements KeyValueStorage {
|
|
|
969
990
|
*
|
|
970
991
|
* Do NOT edit by hand — `node scripts/sync-sdk-versions.mjs`.
|
|
971
992
|
*/
|
|
972
|
-
declare const SDK_VERSION = "1.
|
|
993
|
+
declare const SDK_VERSION = "1.13.0";
|
|
973
994
|
declare const SDK_NAME = "@cross-deck/web";
|
|
974
995
|
|
|
975
996
|
/**
|
|
@@ -1053,4 +1074,4 @@ interface DeviceInfo {
|
|
|
1053
1074
|
appVersion?: string;
|
|
1054
1075
|
}
|
|
1055
1076
|
|
|
1056
|
-
export { AliasResult, type Breadcrumb, type BreadcrumbCategory, type BreadcrumbLevel, CROSSDECK_ERROR_CODES, type CapturedError, type ConsentState, type Contract, type ContractAppliesTo, type ContractFailureInput, type ContractPillar, type ContractStatus, type ContractTestRef, Crossdeck, CrossdeckClient, CrossdeckContracts, CrossdeckError, type CrossdeckErrorPayload, type CrossdeckErrorType, CrossdeckOptions, DEFAULT_BASE_URL, type DeviceInfo, Diagnostics, type ErrorCodeEntry, type ErrorLevel, EventProperties, GroupTraits, HeartbeatResponse, IdentifyOptions, KeyValueStorage, MemoryStorage, PublicEntitlement, PurchaseResult, SDK_NAME, SDK_VERSION, type StackFrame, getErrorCode };
|
|
1077
|
+
export { AliasResult, type Breadcrumb, type BreadcrumbCategory, type BreadcrumbLevel, CROSSDECK_ERROR_CODES, type CapturedError, type ConsentState, type Contract, type ContractAppliesTo, type ContractFailureInput, type ContractPillar, type ContractStatus, type ContractTestRef, Crossdeck, CrossdeckClient, CrossdeckContracts, CrossdeckError, type CrossdeckErrorPayload, type CrossdeckErrorType, CrossdeckOptions, CrossdeckTrustNamespace, DEFAULT_BASE_URL, type DeviceInfo, Diagnostics, type ErrorCodeEntry, type ErrorLevel, EventProperties, GroupTraits, HeartbeatResponse, IdentifyOptions, KeyValueStorage, MemoryStorage, PublicEntitlement, PurchaseResult, SDK_NAME, SDK_VERSION, type StackFrame, getErrorCode };
|
package/dist/index.mjs
CHANGED
|
@@ -69,7 +69,7 @@ function typeMapForStatus(status) {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
// src/_version.ts
|
|
72
|
-
var SDK_VERSION = "1.
|
|
72
|
+
var SDK_VERSION = "1.13.0";
|
|
73
73
|
var SDK_NAME = "@cross-deck/web";
|
|
74
74
|
|
|
75
75
|
// src/http.ts
|
|
@@ -326,6 +326,125 @@ function randomChars(count) {
|
|
|
326
326
|
return out.join("");
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
+
// src/trust.ts
|
|
330
|
+
var TRUST_PANEL_ORIGIN = "https://trust.cross-deck.com";
|
|
331
|
+
var MAX_WIDTH_PX = 360;
|
|
332
|
+
var INITIAL_HEIGHT_PX = 132;
|
|
333
|
+
var MIN_HEIGHT_PX = 96;
|
|
334
|
+
var MAX_HEIGHT_PX = 220;
|
|
335
|
+
var DEFAULT_TIMEOUT_MS2 = 15e3;
|
|
336
|
+
function mountTrustPanel(opts) {
|
|
337
|
+
const origin = normalizeOrigin(opts.origin) || TRUST_PANEL_ORIGIN;
|
|
338
|
+
const timeoutMs = clampInt(opts.timeoutMs, DEFAULT_TIMEOUT_MS2, 1e3, 12e4);
|
|
339
|
+
let settled = false;
|
|
340
|
+
let onMessage = null;
|
|
341
|
+
let timer = null;
|
|
342
|
+
let frame = null;
|
|
343
|
+
let resolveReady;
|
|
344
|
+
const ready = new Promise((res) => {
|
|
345
|
+
resolveReady = res;
|
|
346
|
+
});
|
|
347
|
+
function settle(result, reason) {
|
|
348
|
+
if (settled) return;
|
|
349
|
+
settled = true;
|
|
350
|
+
if (timer) safe(() => clearTimeout(timer));
|
|
351
|
+
if (onMessage) safe(() => window.removeEventListener("message", onMessage));
|
|
352
|
+
if (result) {
|
|
353
|
+
safe(() => opts.onToken?.(result));
|
|
354
|
+
resolveReady(result);
|
|
355
|
+
} else {
|
|
356
|
+
const why = reason || "unavailable";
|
|
357
|
+
safe(() => opts.onUnavailable?.(why));
|
|
358
|
+
resolveReady({ token: null, expiresAt: null, reason: why });
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
try {
|
|
362
|
+
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
363
|
+
queueMicrotask(() => settle(null, "no_dom"));
|
|
364
|
+
return makeHandle();
|
|
365
|
+
}
|
|
366
|
+
const host = resolveTarget(opts.target);
|
|
367
|
+
frame = createFrame(origin, opts.publicKey);
|
|
368
|
+
if (!host) {
|
|
369
|
+
queueMicrotask(() => settle(null, "no_mount_target"));
|
|
370
|
+
return makeHandle();
|
|
371
|
+
}
|
|
372
|
+
onMessage = (ev) => {
|
|
373
|
+
if (ev.origin !== origin) return;
|
|
374
|
+
if (!ev.data || !frame || ev.source !== frame.contentWindow) return;
|
|
375
|
+
const d = ev.data;
|
|
376
|
+
if (d.type === "cd-trust-size" && typeof d.height === "number") {
|
|
377
|
+
safe(() => {
|
|
378
|
+
if (frame) frame.style.height = clampInt(d.height, INITIAL_HEIGHT_PX, MIN_HEIGHT_PX, MAX_HEIGHT_PX) + "px";
|
|
379
|
+
});
|
|
380
|
+
} else if (d.type === "cd-trust-token" && typeof d.token === "string") {
|
|
381
|
+
settle({ token: d.token, expiresAt: typeof d.expMs === "number" ? d.expMs : null });
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
window.addEventListener("message", onMessage);
|
|
385
|
+
host.appendChild(frame);
|
|
386
|
+
timer = setTimeout(() => settle(null, "timeout"), timeoutMs);
|
|
387
|
+
} catch (err) {
|
|
388
|
+
queueMicrotask(() => settle(null, "mount_error:" + safeMessage(err)));
|
|
389
|
+
}
|
|
390
|
+
return makeHandle();
|
|
391
|
+
function makeHandle() {
|
|
392
|
+
return {
|
|
393
|
+
frame,
|
|
394
|
+
ready,
|
|
395
|
+
destroy() {
|
|
396
|
+
if (onMessage) safe(() => window.removeEventListener("message", onMessage));
|
|
397
|
+
if (timer) safe(() => clearTimeout(timer));
|
|
398
|
+
safe(() => frame?.parentNode?.removeChild(frame));
|
|
399
|
+
settle(null, "destroyed");
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
function createFrame(origin, publicKey) {
|
|
405
|
+
const frame = document.createElement("iframe");
|
|
406
|
+
frame.title = "Protected by Crossdeck Trust";
|
|
407
|
+
frame.setAttribute("aria-label", "Protected by Crossdeck Trust");
|
|
408
|
+
frame.setAttribute("scrolling", "no");
|
|
409
|
+
frame.setAttribute("allowtransparency", "true");
|
|
410
|
+
frame.style.cssText = "border:0;display:block;width:100%;max-width:" + MAX_WIDTH_PX + "px;height:" + INITIAL_HEIGHT_PX + "px;margin:0;background:transparent;color-scheme:light;";
|
|
411
|
+
frame.src = origin + "/panel?k=" + encodeURIComponent(publicKey || "");
|
|
412
|
+
return frame;
|
|
413
|
+
}
|
|
414
|
+
function resolveTarget(target) {
|
|
415
|
+
try {
|
|
416
|
+
if (typeof target === "string") return document.querySelector(target);
|
|
417
|
+
return target || null;
|
|
418
|
+
} catch {
|
|
419
|
+
return null;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
function normalizeOrigin(o) {
|
|
423
|
+
if (!o || typeof o !== "string") return null;
|
|
424
|
+
try {
|
|
425
|
+
return new URL(o).origin;
|
|
426
|
+
} catch {
|
|
427
|
+
return null;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
function clampInt(v, fallback, min, max) {
|
|
431
|
+
const n = typeof v === "number" && isFinite(v) ? v : fallback;
|
|
432
|
+
return Math.min(Math.max(n, min), max);
|
|
433
|
+
}
|
|
434
|
+
function safe(fn) {
|
|
435
|
+
try {
|
|
436
|
+
fn();
|
|
437
|
+
} catch {
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
function safeMessage(err) {
|
|
441
|
+
try {
|
|
442
|
+
return err instanceof Error ? err.message : String(err);
|
|
443
|
+
} catch {
|
|
444
|
+
return "unknown";
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
329
448
|
// src/hash.ts
|
|
330
449
|
var K = new Uint32Array([
|
|
331
450
|
1116352408,
|
|
@@ -5788,6 +5907,30 @@ var CrossdeckClient = class {
|
|
|
5788
5907
|
getAnonymousId() {
|
|
5789
5908
|
return this.state ? this.state.identity.anonymousId : null;
|
|
5790
5909
|
}
|
|
5910
|
+
/**
|
|
5911
|
+
* **Crossdeck Trust** — human-proof at your signup, native to the SDK.
|
|
5912
|
+
*
|
|
5913
|
+
* `Crossdeck.trust.panel({ target, onToken })` renders the branded, un-restylable
|
|
5914
|
+
* Trust panel (the same cross-origin iframe on every install) and mints a
|
|
5915
|
+
* single-use attestation. Hand the token to your server and verify it at the gate
|
|
5916
|
+
* (`crossdeck.trust.gate(...)` in @cross-deck/node). The publishable key is taken
|
|
5917
|
+
* from your `init()` — you don't pass it again.
|
|
5918
|
+
*
|
|
5919
|
+
* Fail-open by contract: if the panel can't mint (adblocker, offline, our outage),
|
|
5920
|
+
* `ready` resolves with `{ token: null }` and your signup proceeds — the server
|
|
5921
|
+
* scores the missing token. It never throws and never blocks your form.
|
|
5922
|
+
*
|
|
5923
|
+
* @example
|
|
5924
|
+
* const { ready } = Crossdeck.trust.panel({ target: "#cd-trust" });
|
|
5925
|
+
* const result = await ready; // { token, expiresAt } | { token: null }
|
|
5926
|
+
* await createUser({ email, cdTrustToken: result.token });
|
|
5927
|
+
*/
|
|
5928
|
+
get trust() {
|
|
5929
|
+
const publicKey = this.state ? this.state.options.publicKey : "";
|
|
5930
|
+
return {
|
|
5931
|
+
panel: (input) => mountTrustPanel({ ...input, publicKey })
|
|
5932
|
+
};
|
|
5933
|
+
}
|
|
5791
5934
|
// ---------- private helpers ----------
|
|
5792
5935
|
requireStarted() {
|
|
5793
5936
|
if (!this.state) {
|
|
@@ -6579,6 +6722,8 @@ export {
|
|
|
6579
6722
|
MemoryStorage,
|
|
6580
6723
|
SDK_NAME,
|
|
6581
6724
|
SDK_VERSION,
|
|
6582
|
-
|
|
6725
|
+
TRUST_PANEL_ORIGIN,
|
|
6726
|
+
getErrorCode,
|
|
6727
|
+
mountTrustPanel
|
|
6583
6728
|
};
|
|
6584
6729
|
//# sourceMappingURL=index.mjs.map
|