@zerohash-sdk/travel-rule-react 0.7.16 → 0.7.18

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.
Files changed (2) hide show
  1. package/dist/index.js +98 -84
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
- import n, { useCallback as r, useEffect as i, useRef as a, useState as o } from "react";
2
+ import n, { useCallback as r, useEffect as i, useMemo as a, useRef as o, useState as s } from "react";
3
3
  //#region ../../../common/js-sdk-base/dist/constants.js
4
- var s = {
4
+ var c = {
5
5
  dev: "https://grafana-faro-collector.dev.0hash.com/collect",
6
6
  cert: "https://grafana-faro-collector.cert.zerohash.com/collect",
7
7
  prod: "https://grafana-faro-collector.zerohash.com/collect",
@@ -9,26 +9,26 @@ var s = {
9
9
  "eu-prod": "https://grafana-faro-collector.zerohash.eu/collect",
10
10
  sandbox: "https://grafana-faro-collector.cert.zerohash.com/collect",
11
11
  production: "https://grafana-faro-collector.zerohash.com/collect"
12
- }, c = (e) => typeof e == "object" && !!e && !Array.isArray(e), l = (e) => {
12
+ }, l = (e) => typeof e == "object" && !!e && !Array.isArray(e), u = (e) => {
13
13
  if (!e || typeof e != "string") return null;
14
14
  let t = e.split(".");
15
15
  if (t.length < 2) return null;
16
16
  try {
17
- let e = t[1].replace(/-/g, "+").replace(/_/g, "/"), n = e + "===".slice(0, (4 - e.length % 4) % 4), r = typeof atob < "u" ? atob(n) : Buffer.from(n, "base64").toString("utf-8"), i = JSON.parse(r), a = c(i) ? i.payload : void 0, o = c(a) ? a.region : void 0;
17
+ let e = t[1].replace(/-/g, "+").replace(/_/g, "/"), n = e + "===".slice(0, (4 - e.length % 4) % 4), r = typeof atob < "u" ? atob(n) : Buffer.from(n, "base64").toString("utf-8"), i = JSON.parse(r), a = l(i) ? i.payload : void 0, o = l(a) ? a.region : void 0;
18
18
  if (typeof o != "string") return null;
19
19
  let s = o.toLowerCase();
20
20
  return s === "us" || s === "eu" ? s : null;
21
21
  } catch {
22
22
  return null;
23
23
  }
24
- }, u = (e, t) => l(t) === "eu" ? e === "cert" ? "eu-cert" : e === "prod" ? "eu-prod" : e : e, d = (e) => {
24
+ }, d = (e, t) => u(t) === "eu" ? e === "cert" ? "eu-cert" : e === "prod" ? "eu-prod" : e : e, f = (e) => {
25
25
  if (!e || typeof e != "string") return {};
26
26
  let t = e.split(".");
27
27
  if (t.length < 2) return {};
28
28
  try {
29
29
  let e = t[1].replace(/-/g, "+").replace(/_/g, "/"), n = e + "===".slice(0, (4 - e.length % 4) % 4), r = typeof atob < "u" ? atob(n) : Buffer.from(n, "base64").toString("utf-8"), i = JSON.parse(r);
30
- if (!c(i)) return {};
31
- let a = c(i.payload) ? i.payload : {}, o = (e) => typeof e == "string" && e.length > 0 ? e : void 0;
30
+ if (!l(i)) return {};
31
+ let a = l(i.payload) ? i.payload : {}, o = (e) => typeof e == "string" && e.length > 0 ? e : void 0;
32
32
  return {
33
33
  participantCode: o(a.participant_code),
34
34
  platformName: o(a.platform_name),
@@ -38,11 +38,11 @@ var s = {
38
38
  } catch {
39
39
  return {};
40
40
  }
41
- }, f = (e, t, n) => e[u(t, n)] ?? e[t] ?? e.prod, p = (e, t, n) => e[u(t, n)] ?? e[t], m = () => void 0, h = () => {
41
+ }, p = (e, t, n) => e[d(t, n)] ?? e[t] ?? e.prod, m = (e, t, n) => e[d(t, n)] ?? e[t], h = () => void 0, g = () => {
42
42
  let e = /* @__PURE__ */ new Uint8Array(8);
43
43
  return globalThis.crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
44
- }, g = (e, t) => {
45
- let n = h(), r = Reflect.get(globalThis, "__ZH_WEB_SDK_VERSION__"), i = typeof r == "string" ? r : void 0, a = {};
44
+ }, _ = (e, t) => {
45
+ let n = g(), r = Reflect.get(globalThis, "__ZH_WEB_SDK_VERSION__"), i = typeof r == "string" ? r : void 0, a = {};
46
46
  return e.claims.participantCode && (a.participant_code = e.claims.participantCode), e.claims.platformName && (a.platform_name = e.claims.platformName), e.claims.platformCode && (a.platform_code = e.claims.platformCode), e.claims.region && (a.region = e.claims.region), i && (a.zh_web_sdk_version = i), {
47
47
  sessionId: n,
48
48
  payload: {
@@ -73,26 +73,28 @@ var s = {
73
73
  }]
74
74
  }
75
75
  };
76
- }, _ = (e, t, n) => {
76
+ }, v = (e, t, n) => {
77
77
  if (!e || typeof fetch > "u") return;
78
- let { sessionId: r, payload: i } = g(t, n);
79
- try {
80
- fetch(e, {
81
- method: "POST",
82
- headers: {
83
- "Content-Type": "application/json",
84
- "x-faro-session-id": r
85
- },
86
- body: JSON.stringify(i),
87
- keepalive: !0
88
- }).catch(() => void 0);
89
- } catch {}
90
- }, v = (e) => {
91
- let { webComponentTag: t, appName: n, appVersion: r, scriptUrls: i, fallbackScriptUrls: a, collectorUrls: o, env: s, jwt: c, timeoutMs: l = 15e3, onLoad: u, onError: h } = e;
92
- if (typeof document > "u") return m;
78
+ let { sessionId: r, payload: i } = _(t, n);
79
+ (async () => {
80
+ try {
81
+ await fetch(e, {
82
+ method: "POST",
83
+ headers: {
84
+ "Content-Type": "application/json",
85
+ "x-faro-session-id": r
86
+ },
87
+ body: JSON.stringify(i),
88
+ keepalive: !0
89
+ });
90
+ } catch {}
91
+ })();
92
+ }, y = (e) => {
93
+ let { webComponentTag: t, appName: n, appVersion: r, scriptUrls: i, fallbackScriptUrls: a, collectorUrls: o, env: s, jwt: c, timeoutMs: l = 15e3, onLoad: u, onError: d } = e;
94
+ if (typeof document > "u") return h;
93
95
  let g = `${t}-script-${s}`;
94
- if (customElements.get(t) || document.getElementById(g)) return m;
95
- let v = d(c), y = e.report ?? ((e) => _(o && p(o, s, c), e, r)), b = !1, x = 0, S, C = () => {
96
+ if (customElements.get(t) || document.getElementById(g)) return h;
97
+ let _ = f(c), y = e.report ?? ((e) => v(o && m(o, s, c), e, r)), b = !1, x = 0, S, C = () => {
96
98
  S !== void 0 && clearTimeout(S);
97
99
  }, w = (e, r, i) => {
98
100
  if (b) return;
@@ -104,15 +106,15 @@ var s = {
104
106
  reason: e,
105
107
  triedFallback: i,
106
108
  elapsedMs: o,
107
- claims: v
109
+ claims: _
108
110
  };
109
111
  y(l);
110
- let u = i ? void 0 : f(a ?? {}, s, c);
112
+ let u = i ? void 0 : p(a ?? {}, s, c);
111
113
  if (u && u !== r) {
112
114
  T(u, !0);
113
115
  return;
114
116
  }
115
- b = !0, C(), document.getElementById(g)?.remove(), h?.(l);
117
+ b = !0, C(), document.getElementById(g)?.remove(), d?.(l);
116
118
  }, T = (e, n) => {
117
119
  C(), x = performance.now();
118
120
  let r = document.createElement("script");
@@ -121,11 +123,11 @@ var s = {
121
123
  b || (customElements.get(t) ? (b = !0, C(), u?.()) : w("not-defined", e, n));
122
124
  }, 0);
123
125
  }), r.addEventListener("error", () => w("network", e, n)), S = setTimeout(() => w("timeout", e, n), l), document.getElementById(g)?.remove(), document.head.appendChild(r);
124
- }, E = f(i, s, c);
126
+ }, E = p(i, s, c);
125
127
  return E ? (T(E, !1), () => {
126
128
  b = !0, C();
127
- }) : m;
128
- }, y = () => "0.7.16", b = {
129
+ }) : h;
130
+ }, b = () => "0.7.18", x = {
129
131
  local: {
130
132
  BASE_URL: "/",
131
133
  DEV: !1,
@@ -145,41 +147,42 @@ var s = {
145
147
  VITE_REDIRECT_HANDLER_URL: "http://localhost:4202/redirect-handler/index.html",
146
148
  VITE_SCRAPER_EXTENSION_ID_CHROMIUM: "kofibejdfkmnbobmbogndbiimkflcllf",
147
149
  VITE_TRADE_API_BASE_URL: "/trade",
148
- VITE_UNLEASH_APIKEY: "zerohash-sdk:dev.b0d8aa594e9b94564f885167881bcb9dc69332f935fcb253e656ff34"
150
+ VITE_UNLEASH_APIKEY: "zerohash-sdk:dev.b0d8aa594e9b94564f885167881bcb9dc69332f935fcb253e656ff34",
151
+ VITE_WALLET_DEPOSIT_DEBUG_PLATFORMS: "UW6VWU"
149
152
  }.VITE_LOCAL_CDN_HOST || "http://localhost:5173",
150
153
  dev: "https://sdk-cdn.dev.0hash.com",
151
154
  cert: "https://sdk-cdn.cert.zerohash.com",
152
155
  prod: "https://sdk-cdn.zerohash.com",
153
156
  "eu-cert": "https://sdk-cdn.cert.zerohash.eu",
154
157
  "eu-prod": "https://sdk-cdn.zerohash.eu"
155
- }, x = "https://sdk-cdn.gating.0hash.com", S = (e, t, n = {}) => {
156
- let { eu: r = !1, legacyAliases: i = !1, local: a = b.local } = n, o = (n) => `${n}/${e}/${t}`, s = {
158
+ }, S = "https://sdk-cdn.gating.0hash.com", C = (e, t, n = {}) => {
159
+ let { eu: r = !1, legacyAliases: i = !1, local: a = x.local } = n, o = (n) => `${n}/${e}/${t}`, s = {
157
160
  local: o(a),
158
- dev: o(b.dev),
159
- gating: o(x),
160
- cert: o(b.cert),
161
- prod: o(b.prod)
161
+ dev: o(x.dev),
162
+ gating: o(S),
163
+ cert: o(x.cert),
164
+ prod: o(x.prod)
162
165
  };
163
- return i && (s.sandbox = o(b.cert), s.production = o(b.prod)), r && (s["eu-cert"] = o(b["eu-cert"]), s["eu-prod"] = o(b["eu-prod"])), s;
166
+ return i && (s.sandbox = o(x.cert), s.production = o(x.prod)), r && (s["eu-cert"] = o(x["eu-cert"]), s["eu-prod"] = o(x["eu-prod"])), s;
164
167
  };
165
- [...Object.entries(b).filter(([e]) => e !== "local").map(([, e]) => e)], {
168
+ [...Object.entries(x).filter(([e]) => e !== "local").map(([, e]) => e)], {
166
169
  LOADED: "travel_rule_loaded",
167
170
  COMPLETED: "travel_rule_completed"
168
171
  }.LOADED;
169
172
  //#endregion
170
173
  //#region ../../../common/callbacks/dist/shared/models.js
171
- var C;
174
+ var w;
172
175
  (function(e) {
173
176
  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";
174
- })(C ||= {});
177
+ })(w ||= {});
175
178
  //#endregion
176
179
  //#region ../../../common/react-sdk-base/dist/script-load-fallback.js
177
- var w = {
180
+ var T = {
178
181
  evergreen: "#00381D",
179
182
  green: "#CCFFD0",
180
183
  offBlack: "#1C1B1C",
181
184
  grayLight: "#EBEBE9"
182
- }, T = ({ onRetry: n, onClose: r }) => t("div", {
185
+ }, E = ({ onRetry: n, onClose: r }) => t("div", {
183
186
  role: "alert",
184
187
  style: {
185
188
  position: "relative",
@@ -192,9 +195,9 @@ var w = {
192
195
  padding: "32px 24px",
193
196
  textAlign: "center",
194
197
  fontFamily: "inherit",
195
- color: w.offBlack,
198
+ color: T.offBlack,
196
199
  background: "#FFFFFF",
197
- border: `1px solid ${w.grayLight}`,
200
+ border: `1px solid ${T.grayLight}`,
198
201
  borderRadius: "12px"
199
202
  },
200
203
  children: [
@@ -208,7 +211,7 @@ var w = {
208
211
  right: "12px",
209
212
  display: "flex",
210
213
  padding: "4px",
211
- color: w.offBlack,
214
+ color: T.offBlack,
212
215
  background: "none",
213
216
  border: "none",
214
217
  cursor: "pointer",
@@ -237,7 +240,7 @@ var w = {
237
240
  "aria-hidden": "true",
238
241
  children: e("path", {
239
242
  d: "M12 9v4m0 4h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z",
240
- stroke: w.evergreen,
243
+ stroke: T.evergreen,
241
244
  strokeWidth: "1.5",
242
245
  strokeLinecap: "round",
243
246
  strokeLinejoin: "round"
@@ -268,8 +271,8 @@ var w = {
268
271
  fontSize: "14px",
269
272
  fontWeight: 600,
270
273
  fontFamily: "inherit",
271
- color: w.green,
272
- background: w.evergreen,
274
+ color: T.green,
275
+ background: T.evergreen,
273
276
  border: "none",
274
277
  borderRadius: "8px",
275
278
  cursor: "pointer"
@@ -277,72 +280,83 @@ var w = {
277
280
  children: "Try again"
278
281
  })
279
282
  ]
280
- }), E = (e, t) => {
283
+ }), D = (e, t) => {
281
284
  i(() => {
282
285
  let n = e.current;
283
286
  if (n) for (let [e, r] of Object.entries(t)) r !== void 0 && Reflect.set(n, e, r);
284
287
  });
285
- }, D = (e) => {
286
- let { webComponentTag: t, appName: n, appVersion: a, scriptUrls: c, fallbackScriptUrls: l, collectorUrls: u, env: d, jwt: f, timeoutMs: p } = e, [m, h] = o(!1), [g, _] = o(0);
287
- return i(() => (h(!1), v({
288
+ }, O = (e) => {
289
+ let { webComponentTag: t, appName: n, appVersion: o, scriptUrls: l, fallbackScriptUrls: u, collectorUrls: d, env: f, jwt: p, timeoutMs: m } = e, [h, g] = s(0), _ = a(() => ({
288
290
  webComponentTag: t,
289
291
  appName: n ?? t,
290
- appVersion: a,
291
- scriptUrls: c,
292
- fallbackScriptUrls: l,
293
- collectorUrls: u ?? s,
294
- env: d,
295
- jwt: f,
296
- timeoutMs: p,
297
- onError: () => h(!0)
298
- })), [
292
+ appVersion: o,
293
+ scriptUrls: l,
294
+ fallbackScriptUrls: u,
295
+ collectorUrls: d ?? c,
296
+ env: f,
297
+ jwt: p,
298
+ timeoutMs: m,
299
+ retryNonce: h
300
+ }), [
299
301
  t,
300
302
  n,
301
- a,
302
- c,
303
+ o,
303
304
  l,
304
305
  u,
305
306
  d,
306
307
  f,
307
308
  p,
308
- g
309
- ]), {
310
- loadFailed: m,
311
- retry: r(() => _((e) => e + 1), [])
309
+ m,
310
+ h
311
+ ]), [v, b] = s(null), x = v === _;
312
+ return i(() => y({
313
+ webComponentTag: _.webComponentTag,
314
+ appName: _.appName,
315
+ appVersion: _.appVersion,
316
+ scriptUrls: _.scriptUrls,
317
+ fallbackScriptUrls: _.fallbackScriptUrls,
318
+ collectorUrls: _.collectorUrls,
319
+ env: _.env,
320
+ jwt: _.jwt,
321
+ timeoutMs: _.timeoutMs,
322
+ onError: () => b(_)
323
+ }), [_]), {
324
+ loadFailed: x,
325
+ retry: r(() => g((e) => e + 1), [])
312
326
  };
313
- }, O = S("travel-rule-web", "index.js", { eu: !0 }), k = "zerohash-travel-rule", A = ({ jwt: t, depositId: r, walletAddress: i, intentionAction: o, env: s = "prod", theme: c, onCompleted: l, onError: u, onClose: d, onLoaded: f, onEvent: p, ...m }) => {
314
- let h = a(null);
315
- E(h, {
327
+ }, k = C("travel-rule-web", "index.js", { eu: !0 }), A = "zerohash-travel-rule", j = ({ jwt: t, depositId: r, walletAddress: i, intentionAction: a, env: s = "prod", theme: c, onCompleted: l, onError: u, onClose: d, onLoaded: f, onEvent: p, ...m }) => {
328
+ let h = o(null);
329
+ D(h, {
316
330
  theme: c,
317
331
  depositId: r,
318
332
  walletAddress: i,
319
- intentionAction: o,
333
+ intentionAction: a,
320
334
  onCompleted: l,
321
335
  onError: u,
322
336
  onClose: d,
323
337
  onLoaded: f,
324
338
  onEvent: p
325
339
  });
326
- let { loadFailed: g, retry: _ } = D({
327
- webComponentTag: k,
328
- scriptUrls: O,
340
+ let { loadFailed: g, retry: _ } = O({
341
+ webComponentTag: A,
342
+ scriptUrls: k,
329
343
  env: s,
330
344
  jwt: t
331
345
  });
332
- return g ? /* @__PURE__ */ e(T, {
346
+ return g ? /* @__PURE__ */ e(E, {
333
347
  onRetry: _,
334
348
  onClose: d
335
- }) : n.createElement(k, {
349
+ }) : n.createElement(A, {
336
350
  ref: h,
337
351
  jwt: t,
338
352
  env: s,
339
- sdkversion: y(),
353
+ sdkversion: b(),
340
354
  theme: c,
341
355
  depositId: r,
342
356
  walletAddress: i,
343
- intentionAction: o,
357
+ intentionAction: a,
344
358
  ...m
345
359
  });
346
360
  };
347
361
  //#endregion
348
- export { A as TravelRule };
362
+ export { j as TravelRule };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerohash-sdk/travel-rule-react",
3
- "version": "0.7.16",
3
+ "version": "0.7.18",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",