@zerohash-sdk/travel-rule-js 0.7.2 → 0.7.4
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/index.d.ts +7 -2
- package/dist/index.js +62 -62
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -256,15 +256,20 @@ declare abstract class BaseJsSdk<Config extends BaseConfig<never> = BaseConfig>
|
|
|
256
256
|
return this.scriptLoadingPromise;
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
-
private async waitForWebComponent(
|
|
259
|
+
private async waitForWebComponent() {
|
|
260
260
|
if (this.getWebComponent()) {
|
|
261
261
|
return;
|
|
262
262
|
}
|
|
263
263
|
|
|
264
|
+
// The script has already loaded (loadScript awaited its onLoad); this only
|
|
265
|
+
// covers the window until the custom element registers. Under load (CI, slow
|
|
266
|
+
// devices) that can take longer than a few seconds, so the grace period is
|
|
267
|
+
// generous — a genuine load failure still fails fast via loadScript's
|
|
268
|
+
// onError, not this timer.
|
|
264
269
|
return new Promise<void>((resolve, reject) => {
|
|
265
270
|
const timeoutId = setTimeout(() => {
|
|
266
271
|
reject(new Error(`Timeout waiting for ${this.webComponentTag} to be defined`));
|
|
267
|
-
},
|
|
272
|
+
}, DEFAULT_WEB_COMPONENT_TIMEOUT_MS);
|
|
268
273
|
|
|
269
274
|
customElements
|
|
270
275
|
.whenDefined(this.webComponentTag)
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const N = "production", M = "JWT token is required and must be a string.", W = {
|
|
2
2
|
dev: "https://grafana-faro-collector.dev.0hash.com/collect",
|
|
3
3
|
cert: "https://grafana-faro-collector.cert.zerohash.com/collect",
|
|
4
4
|
prod: "https://grafana-faro-collector.zerohash.com/collect",
|
|
@@ -6,7 +6,7 @@ const C = "production", M = "JWT token is required and must be a string.", W = {
|
|
|
6
6
|
"eu-prod": "https://grafana-faro-collector.zerohash.eu/collect",
|
|
7
7
|
sandbox: "https://grafana-faro-collector.cert.zerohash.com/collect",
|
|
8
8
|
production: "https://grafana-faro-collector.zerohash.com/collect"
|
|
9
|
-
},
|
|
9
|
+
}, U = (e) => {
|
|
10
10
|
if (!e || typeof e != "string")
|
|
11
11
|
return null;
|
|
12
12
|
const t = e.split(".");
|
|
@@ -21,37 +21,37 @@ const C = "production", M = "JWT token is required and must be a string.", W = {
|
|
|
21
21
|
} catch {
|
|
22
22
|
return null;
|
|
23
23
|
}
|
|
24
|
-
},
|
|
24
|
+
}, S = (e, t) => U(t) !== "eu" ? e : e === "cert" ? "eu-cert" : e === "prod" ? "eu-prod" : e, P = (e) => {
|
|
25
25
|
if (!e || typeof e != "string")
|
|
26
26
|
return {};
|
|
27
27
|
const t = e.split(".");
|
|
28
28
|
if (t.length < 2)
|
|
29
29
|
return {};
|
|
30
30
|
try {
|
|
31
|
-
const r = t[1].replace(/-/g, "+").replace(/_/g, "/"), o = r + "===".slice(0, (4 - r.length % 4) % 4), n = typeof atob < "u" ? atob(o) : Buffer.from(o, "base64").toString("utf-8"),
|
|
31
|
+
const r = t[1].replace(/-/g, "+").replace(/_/g, "/"), o = r + "===".slice(0, (4 - r.length % 4) % 4), n = typeof atob < "u" ? atob(o) : Buffer.from(o, "base64").toString("utf-8"), d = JSON.parse(n), i = d?.payload ?? {}, s = (a) => typeof a == "string" && a.length > 0 ? a : void 0;
|
|
32
32
|
return {
|
|
33
33
|
participantCode: s(i.participant_code),
|
|
34
34
|
platformName: s(i.platform_name),
|
|
35
|
-
platformCode: s(
|
|
35
|
+
platformCode: s(d.platform_code),
|
|
36
36
|
region: s(i.region)
|
|
37
37
|
};
|
|
38
38
|
} catch {
|
|
39
39
|
return {};
|
|
40
40
|
}
|
|
41
|
-
},
|
|
42
|
-
const o =
|
|
41
|
+
}, y = (e, t, r) => {
|
|
42
|
+
const o = S(t, r);
|
|
43
43
|
return e[o] ?? e[t] ?? e.prod;
|
|
44
|
-
},
|
|
45
|
-
const o =
|
|
44
|
+
}, k = (e, t, r) => {
|
|
45
|
+
const o = S(t, r);
|
|
46
46
|
return e[o] ?? e[t];
|
|
47
|
-
},
|
|
47
|
+
}, T = () => {
|
|
48
48
|
}, F = () => {
|
|
49
49
|
const e = new Uint8Array(8);
|
|
50
50
|
return globalThis.crypto.getRandomValues(e), Array.from(e, (t) => t.toString(16).padStart(2, "0")).join("");
|
|
51
|
-
},
|
|
51
|
+
}, B = (e, t) => {
|
|
52
52
|
const r = F(), o = globalThis.__ZH_WEB_SDK_VERSION__, n = {};
|
|
53
53
|
e.claims.participantCode && (n.participant_code = e.claims.participantCode), e.claims.platformName && (n.platform_name = e.claims.platformName), e.claims.platformCode && (n.platform_code = e.claims.platformCode), e.claims.region && (n.region = e.claims.region), o && (n.zh_web_sdk_version = o);
|
|
54
|
-
const
|
|
54
|
+
const d = {
|
|
55
55
|
meta: {
|
|
56
56
|
app: { name: e.appName, version: t ?? "unknown", environment: e.env },
|
|
57
57
|
session: { id: r, attributes: n },
|
|
@@ -73,11 +73,11 @@ const C = "production", M = "JWT token is required and must be a string.", W = {
|
|
|
73
73
|
}
|
|
74
74
|
]
|
|
75
75
|
};
|
|
76
|
-
return { sessionId: r, payload:
|
|
77
|
-
},
|
|
76
|
+
return { sessionId: r, payload: d };
|
|
77
|
+
}, $ = (e, t, r) => {
|
|
78
78
|
if (!e || typeof fetch > "u")
|
|
79
79
|
return;
|
|
80
|
-
const { sessionId: o, payload: n } =
|
|
80
|
+
const { sessionId: o, payload: n } = B(t, r);
|
|
81
81
|
try {
|
|
82
82
|
fetch(e, {
|
|
83
83
|
method: "POST",
|
|
@@ -89,50 +89,50 @@ const C = "production", M = "JWT token is required and must be a string.", W = {
|
|
|
89
89
|
} catch {
|
|
90
90
|
}
|
|
91
91
|
}, V = (e) => {
|
|
92
|
-
const { webComponentTag: t, appName: r, appVersion: o, scriptUrls: n, fallbackScriptUrls:
|
|
92
|
+
const { webComponentTag: t, appName: r, appVersion: o, scriptUrls: n, fallbackScriptUrls: d, collectorUrls: i, env: s, jwt: a, timeoutMs: v = 15e3, onLoad: L, onError: I } = e;
|
|
93
93
|
if (typeof document > "u")
|
|
94
|
-
return
|
|
94
|
+
return T;
|
|
95
95
|
const h = `${t}-script-${s}`;
|
|
96
96
|
if (customElements.get(t) || document.getElementById(h))
|
|
97
|
-
return
|
|
98
|
-
const A = P(
|
|
99
|
-
let m = !1,
|
|
97
|
+
return T;
|
|
98
|
+
const A = P(a), D = e.report ?? ((l) => $(i && k(i, s, a), l, o));
|
|
99
|
+
let m = !1, w = 0, g;
|
|
100
100
|
const f = () => {
|
|
101
101
|
g !== void 0 && clearTimeout(g);
|
|
102
|
-
},
|
|
102
|
+
}, _ = (l, u, c) => {
|
|
103
103
|
if (m)
|
|
104
104
|
return;
|
|
105
|
-
const z = Math.round(performance.now() -
|
|
105
|
+
const z = Math.round(performance.now() - w), b = {
|
|
106
106
|
webComponentTag: t,
|
|
107
107
|
appName: r,
|
|
108
108
|
env: s,
|
|
109
109
|
scriptUrl: u,
|
|
110
110
|
reason: l,
|
|
111
|
-
triedFallback:
|
|
111
|
+
triedFallback: c,
|
|
112
112
|
elapsedMs: z,
|
|
113
113
|
claims: A
|
|
114
114
|
};
|
|
115
|
-
D(
|
|
116
|
-
const
|
|
117
|
-
if (
|
|
118
|
-
|
|
115
|
+
D(b);
|
|
116
|
+
const E = c ? void 0 : y(d ?? {}, s, a);
|
|
117
|
+
if (E && E !== u) {
|
|
118
|
+
R(E, !0);
|
|
119
119
|
return;
|
|
120
120
|
}
|
|
121
|
-
m = !0, f(), document.getElementById(h)?.remove(), I?.(
|
|
122
|
-
},
|
|
123
|
-
f(),
|
|
124
|
-
const
|
|
125
|
-
|
|
121
|
+
m = !0, f(), document.getElementById(h)?.remove(), I?.(b);
|
|
122
|
+
}, R = (l, u) => {
|
|
123
|
+
f(), w = performance.now();
|
|
124
|
+
const c = document.createElement("script");
|
|
125
|
+
c.id = h, c.src = l, c.type = "module", c.async = !0, c.onload = () => {
|
|
126
126
|
setTimeout(() => {
|
|
127
|
-
m || (customElements.get(t) ? (m = !0, f(), L?.()) :
|
|
127
|
+
m || (customElements.get(t) ? (m = !0, f(), L?.()) : _("not-defined", l, u));
|
|
128
128
|
}, 0);
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
return
|
|
129
|
+
}, c.onerror = () => _("network", l, u), g = setTimeout(() => _("timeout", l, u), v), document.getElementById(h)?.remove(), document.head.appendChild(c);
|
|
130
|
+
}, C = y(n, s, a);
|
|
131
|
+
return C ? (R(C, !1), () => {
|
|
132
132
|
m = !0, f();
|
|
133
|
-
}) :
|
|
134
|
-
};
|
|
135
|
-
class
|
|
133
|
+
}) : T;
|
|
134
|
+
}, j = 1e4;
|
|
135
|
+
class H {
|
|
136
136
|
config;
|
|
137
137
|
state;
|
|
138
138
|
scriptLoadingPromise;
|
|
@@ -141,7 +141,7 @@ class j {
|
|
|
141
141
|
throw new Error(M);
|
|
142
142
|
this.config = {
|
|
143
143
|
...t,
|
|
144
|
-
env: t.env ||
|
|
144
|
+
env: t.env || N,
|
|
145
145
|
theme: t.theme
|
|
146
146
|
}, this.state = {
|
|
147
147
|
initialized: !1,
|
|
@@ -206,7 +206,7 @@ class j {
|
|
|
206
206
|
return { ...this.config };
|
|
207
207
|
}
|
|
208
208
|
getEnvironment() {
|
|
209
|
-
return this.config.env ||
|
|
209
|
+
return this.config.env || N;
|
|
210
210
|
}
|
|
211
211
|
getScriptId() {
|
|
212
212
|
return `${this.webComponentTag}-script-${this.getEnvironment()}`;
|
|
@@ -246,16 +246,16 @@ class j {
|
|
|
246
246
|
return this.scriptLoadingPromise;
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
|
-
async waitForWebComponent(
|
|
249
|
+
async waitForWebComponent() {
|
|
250
250
|
if (!this.getWebComponent())
|
|
251
|
-
return new Promise((
|
|
252
|
-
const
|
|
253
|
-
|
|
254
|
-
},
|
|
251
|
+
return new Promise((t, r) => {
|
|
252
|
+
const o = setTimeout(() => {
|
|
253
|
+
r(new Error(`Timeout waiting for ${this.webComponentTag} to be defined`));
|
|
254
|
+
}, j);
|
|
255
255
|
customElements.whenDefined(this.webComponentTag).then(() => {
|
|
256
|
-
clearTimeout(
|
|
257
|
-
}).catch((
|
|
258
|
-
clearTimeout(
|
|
256
|
+
clearTimeout(o), t();
|
|
257
|
+
}).catch((n) => {
|
|
258
|
+
clearTimeout(o), r(n);
|
|
259
259
|
});
|
|
260
260
|
});
|
|
261
261
|
}
|
|
@@ -277,28 +277,28 @@ class j {
|
|
|
277
277
|
}), t;
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
|
-
const p = {
|
|
281
|
-
local:
|
|
280
|
+
const J = {}, x = typeof import.meta < "u" && J?.VITE_LOCAL_CDN_HOST || "http://localhost:5173", p = {
|
|
281
|
+
local: x,
|
|
282
282
|
dev: "https://sdk-cdn.dev.0hash.com",
|
|
283
283
|
cert: "https://sdk-cdn.cert.zerohash.com",
|
|
284
284
|
prod: "https://sdk-cdn.zerohash.com",
|
|
285
285
|
"eu-cert": "https://sdk-cdn.cert.zerohash.eu",
|
|
286
286
|
"eu-prod": "https://sdk-cdn.zerohash.eu"
|
|
287
|
-
},
|
|
288
|
-
const { eu: o = !1, legacyAliases: n = !1, local:
|
|
289
|
-
local: i(
|
|
287
|
+
}, G = "https://sdk-cdn.gating.0hash.com", K = (e, t, r = {}) => {
|
|
288
|
+
const { eu: o = !1, legacyAliases: n = !1, local: d = p.local } = r, i = (a) => `${a}/${e}/${t}`, s = {
|
|
289
|
+
local: i(d),
|
|
290
290
|
dev: i(p.dev),
|
|
291
|
-
gating: i(
|
|
291
|
+
gating: i(G),
|
|
292
292
|
cert: i(p.cert),
|
|
293
293
|
prod: i(p.prod)
|
|
294
294
|
};
|
|
295
295
|
return n && (s.sandbox = i(p.cert), s.production = i(p.prod)), o && (s["eu-cert"] = i(p["eu-cert"]), s["eu-prod"] = i(p["eu-prod"])), s;
|
|
296
296
|
};
|
|
297
|
-
var
|
|
297
|
+
var O;
|
|
298
298
|
(function(e) {
|
|
299
299
|
e.NETWORK_ERROR = "network_error", e.AUTH_ERROR = "auth_error", e.NOT_FOUND_ERROR = "not_found_error", e.VALIDATION_ERROR = "validation_error", e.SERVER_ERROR = "server_error", e.CLIENT_ERROR = "client_error", e.UNKNOWN_ERROR = "unknown_error";
|
|
300
|
-
})(
|
|
301
|
-
class
|
|
300
|
+
})(O || (O = {}));
|
|
301
|
+
class Y extends H {
|
|
302
302
|
errorMessages = {
|
|
303
303
|
ALREADY_RENDERED: "TravelRule widget is already rendered. Call destroy() before rendering again.",
|
|
304
304
|
NOT_RENDERED: "TravelRule widget is not rendered. Call render() first.",
|
|
@@ -306,7 +306,7 @@ class H extends j {
|
|
|
306
306
|
SCRIPT_LOAD_FAILED: "Failed to load the Zerohash TravelRule script.",
|
|
307
307
|
WEB_COMPONENT_NOT_DEFINED: "Web component is not defined. Script may not be loaded."
|
|
308
308
|
};
|
|
309
|
-
scriptUrls =
|
|
309
|
+
scriptUrls = K("travel-rule-web", "index.js", { legacyAliases: !0, eu: !0 });
|
|
310
310
|
webComponentTag = "zerohash-travel-rule";
|
|
311
311
|
/**
|
|
312
312
|
* Render the TravelRule widget to a container element
|
|
@@ -345,7 +345,7 @@ class H extends j {
|
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
347
|
export {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
348
|
+
O as ErrorCode,
|
|
349
|
+
Y as TravelRule,
|
|
350
|
+
Y as default
|
|
351
351
|
};
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(a,m){typeof exports=="object"&&typeof module<"u"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(a=typeof globalThis<"u"?globalThis:a||self,m(a.TravelRule={}))})(this,(function(a){"use strict";var m=typeof document<"u"?document.currentScript:null;const w="production",I="JWT token is required and must be a string.",A={dev:"https://grafana-faro-collector.dev.0hash.com/collect",cert:"https://grafana-faro-collector.cert.zerohash.com/collect",prod:"https://grafana-faro-collector.zerohash.com/collect","eu-cert":"https://grafana-faro-collector.cert.zerohash.eu/collect","eu-prod":"https://grafana-faro-collector.zerohash.eu/collect",sandbox:"https://grafana-faro-collector.cert.zerohash.com/collect",production:"https://grafana-faro-collector.zerohash.com/collect"},D=e=>{if(!e||typeof e!="string")return null;const t=e.split(".");if(t.length<2)return null;try{const r=t[1].replace(/-/g,"+").replace(/_/g,"/"),n=r+"===".slice(0,(4-r.length%4)%4),o=typeof atob<"u"?atob(n):Buffer.from(n,"base64").toString("utf-8"),i=JSON.parse(o)?.payload?.region;if(typeof i!="string")return null;const s=i.toLowerCase();return s==="us"||s==="eu"?s:null}catch{return null}},y=(e,t)=>D(t)!=="eu"?e:e==="cert"?"eu-cert":e==="prod"?"eu-prod":e,M=e=>{if(!e||typeof e!="string")return{};const t=e.split(".");if(t.length<2)return{};try{const r=t[1].replace(/-/g,"+").replace(/_/g,"/"),n=r+"===".slice(0,(4-r.length%4)%4),o=typeof atob<"u"?atob(n):Buffer.from(n,"base64").toString("utf-8"),l=JSON.parse(o),i=l?.payload??{},s=c=>typeof c=="string"&&c.length>0?c:void 0;return{participantCode:s(i.participant_code),platformName:s(i.platform_name),platformCode:s(l.platform_code),region:s(i.region)}}catch{return{}}},b=(e,t,r)=>{const n=y(t,r);return e[n]??e[t]??e.prod},z=(e,t,r)=>{const n=y(t,r);return e[n]??e[t]},E=()=>{},U=()=>{const e=new Uint8Array(8);return globalThis.crypto.getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")},P=(e,t)=>{const r=U(),n=globalThis.__ZH_WEB_SDK_VERSION__,o={};e.claims.participantCode&&(o.participant_code=e.claims.participantCode),e.claims.platformName&&(o.platform_name=e.claims.platformName),e.claims.platformCode&&(o.platform_code=e.claims.platformCode),e.claims.region&&(o.region=e.claims.region),n&&(o.zh_web_sdk_version=n);const l={meta:{app:{name:e.appName,version:t??"unknown",environment:e.env},session:{id:r,attributes:o},browser:typeof navigator<"u"?{userAgent:navigator.userAgent}:void 0,page:typeof window<"u"?{url:window.location.origin}:void 0},logs:[{message:`Failed to load the script for ${e.webComponentTag} from ${e.env} environment.`,level:"error",timestamp:new Date().toISOString(),context:{web_component:e.webComponentTag,script_url:e.scriptUrl,reason:e.reason,tried_fallback:String(e.triedFallback),elapsed_ms:String(e.elapsedMs)}}]};return{sessionId:r,payload:l}},W=(e,t,r)=>{if(!e||typeof fetch>"u")return;const{sessionId:n,payload:o}=P(t,r);try{fetch(e,{method:"POST",headers:{"Content-Type":"application/json","x-faro-session-id":n},body:JSON.stringify(o),keepalive:!0}).catch(()=>{})}catch{}},k=e=>{const{webComponentTag:t,appName:r,appVersion:n,scriptUrls:o,fallbackScriptUrls:l,collectorUrls:i,env:s,jwt:c,timeoutMs:H=15e3,onLoad:J,onError:x}=e;if(typeof document>"u")return E;const g=`${t}-script-${s}`;if(customElements.get(t)||document.getElementById(g))return E;const G=M(c),K=e.report??(u=>W(i&&z(i,s,c),u,n));let h=!1,O=0,T;const _=()=>{T!==void 0&&clearTimeout(T)},R=(u,f,d)=>{if(h)return;const q=Math.round(performance.now()-O),L={webComponentTag:t,appName:r,env:s,scriptUrl:f,reason:u,triedFallback:d,elapsedMs:q,claims:G};K(L);const C=d?void 0:b(l??{},s,c);if(C&&C!==f){S(C,!0);return}h=!0,_(),document.getElementById(g)?.remove(),x?.(L)},S=(u,f)=>{_(),O=performance.now();const d=document.createElement("script");d.id=g,d.src=u,d.type="module",d.async=!0,d.onload=()=>{setTimeout(()=>{h||(customElements.get(t)?(h=!0,_(),J?.()):R("not-defined",u,f))},0)},d.onerror=()=>R("network",u,f),T=setTimeout(()=>R("timeout",u,f),H),document.getElementById(g)?.remove(),document.head.appendChild(d)},v=b(o,s,c);return v?(S(v,!1),()=>{h=!0,_()}):E},F=1e4;class j{config;state;scriptLoadingPromise;constructor(t){if(!t.jwt||typeof t.jwt!="string")throw new Error(I);this.config={...t,env:t.env||w,theme:t.theme},this.state={initialized:!1,scriptLoaded:!1,container:null,element:null}}async render(t){if(!t||!(t instanceof HTMLElement))throw new Error(this.errorMessages.INVALID_CONTAINER);if(this.state.initialized)throw new Error(this.errorMessages.ALREADY_RENDERED);try{await this.ensureScriptLoaded();const r=this.createWebComponent();t.innerHTML="",t.appendChild(r),this.state.container=t,this.state.element=r,this.state.initialized=!0}catch(r){throw console.error("Failed to render widget:",r),r}}updateConfig(t){if(!this.state.initialized||!this.state.element)throw new Error(this.errorMessages.NOT_RENDERED);const r=this.state.element;Object.entries(t).forEach(([n,o])=>{o&&(this.config[n]=o,r[n]=o)})}destroy(){this.state.initialized&&(this.state.element&&this.state.element.parentNode&&this.state.element.parentNode.removeChild(this.state.element),this.state.container&&(this.state.container.innerHTML=""),this.state.container=null,this.state.element=null,this.state.initialized=!1)}isRendered(){return this.state.initialized}getConfig(){return{...this.config}}getEnvironment(){return this.config.env||w}getScriptId(){return`${this.webComponentTag}-script-${this.getEnvironment()}`}isScriptLoaded(){return!!document.getElementById(this.getScriptId())}getWebComponent(){return customElements.get(this.webComponentTag)}getEffectiveScriptUrls(){return this.scriptUrls}async loadScript(){if(!(this.getWebComponent()||this.isScriptLoaded())){if(this.scriptLoadingPromise)return this.scriptLoadingPromise;this.scriptLoadingPromise=new Promise((t,r)=>{k({webComponentTag:this.webComponentTag,appName:this.webComponentTag,scriptUrls:this.getEffectiveScriptUrls(),collectorUrls:A,env:this.getEnvironment(),jwt:this.config.jwt,onLoad:t,onError:n=>{r(new Error(n.reason==="not-defined"?this.errorMessages.WEB_COMPONENT_NOT_DEFINED:`${this.errorMessages.SCRIPT_LOAD_FAILED} (${this.getEnvironment()})`))}})});try{await this.scriptLoadingPromise}catch(t){throw this.scriptLoadingPromise=void 0,t}return this.scriptLoadingPromise}}async waitForWebComponent(){if(!this.getWebComponent())return new Promise((t,r)=>{const n=setTimeout(()=>{r(new Error(`Timeout waiting for ${this.webComponentTag} to be defined`))},F);customElements.whenDefined(this.webComponentTag).then(()=>{clearTimeout(n),t()}).catch(o=>{clearTimeout(n),r(o)})})}async ensureScriptLoaded(){if(!this.state.scriptLoaded)try{await this.loadScript(),await this.waitForWebComponent(),this.state.scriptLoaded=!0}catch(t){throw console.error("Failed to load Connect script:",t),t}}createWebComponent(){const t=document.createElement(this.webComponentTag);return Object.entries(this.config).forEach(([r,n])=>{n&&(t[r]=n)}),t}}const B={},p={local:typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:m&&m.tagName.toUpperCase()==="SCRIPT"&&m.src||new URL("index.umd.cjs",document.baseURI).href}<"u"&&B?.VITE_LOCAL_CDN_HOST||"http://localhost:5173",dev:"https://sdk-cdn.dev.0hash.com",cert:"https://sdk-cdn.cert.zerohash.com",prod:"https://sdk-cdn.zerohash.com","eu-cert":"https://sdk-cdn.cert.zerohash.eu","eu-prod":"https://sdk-cdn.zerohash.eu"},$="https://sdk-cdn.gating.0hash.com",V=(e,t,r={})=>{const{eu:n=!1,legacyAliases:o=!1,local:l=p.local}=r,i=c=>`${c}/${e}/${t}`,s={local:i(l),dev:i(p.dev),gating:i($),cert:i(p.cert),prod:i(p.prod)};return o&&(s.sandbox=i(p.cert),s.production=i(p.prod)),n&&(s["eu-cert"]=i(p["eu-cert"]),s["eu-prod"]=i(p["eu-prod"])),s};a.ErrorCode=void 0,(function(e){e.NETWORK_ERROR="network_error",e.AUTH_ERROR="auth_error",e.NOT_FOUND_ERROR="not_found_error",e.VALIDATION_ERROR="validation_error",e.SERVER_ERROR="server_error",e.CLIENT_ERROR="client_error",e.UNKNOWN_ERROR="unknown_error"})(a.ErrorCode||(a.ErrorCode={}));class N extends j{errorMessages={ALREADY_RENDERED:"TravelRule widget is already rendered. Call destroy() before rendering again.",NOT_RENDERED:"TravelRule widget is not rendered. Call render() first.",INVALID_CONTAINER:"Invalid container element provided.",SCRIPT_LOAD_FAILED:"Failed to load the Zerohash TravelRule script.",WEB_COMPONENT_NOT_DEFINED:"Web component is not defined. Script may not be loaded."};scriptUrls=V("travel-rule-web","index.js",{legacyAliases:!0,eu:!0});webComponentTag="zerohash-travel-rule";render(t){return super.render(t)}updateConfig(t){return super.updateConfig(t)}getConfig(){return super.getConfig()}isRendered(){return super.isRendered()}destroy(){return super.destroy()}}a.TravelRule=N,a.default=N,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|