@zerohash-sdk/travel-rule-react 0.3.5 → 0.5.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/dist/index.d.ts CHANGED
@@ -81,9 +81,9 @@ export declare const TravelRule: default_2.FC<TravelRuleProps>;
81
81
 
82
82
  declare type TravelRuleCompletedData = {
83
83
  /** Deposit id the travel-rule submission is tied to */
84
- deposit_id: string;
84
+ deposit_id?: string;
85
85
  /** ISO-8601 timestamp of the travel-rule submission */
86
- submitted_at: string;
86
+ submitted_at?: string;
87
87
  };
88
88
 
89
89
  /**
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { jsxs as W, jsx as y } from "react/jsx-runtime";
2
- import D, { useEffect as I, useState as z, useCallback as j, useRef as M } from "react";
1
+ import { jsxs as A, jsx as p } from "react/jsx-runtime";
2
+ import M, { useEffect as I, useState as L, useCallback as j, useRef as D } from "react";
3
3
  const $ = {
4
4
  dev: "https://grafana-faro-collector.dev.0hash.com/collect",
5
5
  cert: "https://grafana-faro-collector.cert.zerohash.com/collect",
@@ -30,30 +30,30 @@ const $ = {
30
30
  if (t.length < 2)
31
31
  return {};
32
32
  try {
33
- const o = t[1].replace(/-/g, "+").replace(/_/g, "/"), r = o + "===".slice(0, (4 - o.length % 4) % 4), n = typeof atob < "u" ? atob(r) : Buffer.from(r, "base64").toString("utf-8"), s = JSON.parse(n), c = s?.payload ?? {}, a = (l) => typeof l == "string" && l.length > 0 ? l : void 0;
33
+ const o = t[1].replace(/-/g, "+").replace(/_/g, "/"), r = o + "===".slice(0, (4 - o.length % 4) % 4), n = typeof atob < "u" ? atob(r) : Buffer.from(r, "base64").toString("utf-8"), i = JSON.parse(n), c = i?.payload ?? {}, a = (s) => typeof s == "string" && s.length > 0 ? s : void 0;
34
34
  return {
35
35
  participantCode: a(c.participant_code),
36
36
  platformName: a(c.platform_name),
37
- platformCode: a(s.platform_code),
37
+ platformCode: a(i.platform_code),
38
38
  region: a(c.region)
39
39
  };
40
40
  } catch {
41
41
  return {};
42
42
  }
43
- }, L = (e, t, o) => {
43
+ }, z = (e, t, o) => {
44
44
  const r = U(t, o);
45
45
  return e[r] ?? e[t] ?? e.prod;
46
- }, J = (e, t, o) => {
46
+ }, H = (e, t, o) => {
47
47
  const r = U(t, o);
48
48
  return e[r] ?? e[t];
49
- }, T = () => {
50
- }, H = () => {
49
+ }, O = () => {
50
+ }, J = () => {
51
51
  const e = new Uint8Array(8);
52
52
  return globalThis.crypto.getRandomValues(e), Array.from(e, (t) => t.toString(16).padStart(2, "0")).join("");
53
53
  }, G = (e, t) => {
54
- const o = H(), r = globalThis.__ZH_WEB_SDK_VERSION__, n = {};
54
+ const o = J(), r = globalThis.__ZH_WEB_SDK_VERSION__, n = {};
55
55
  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), r && (n.zh_web_sdk_version = r);
56
- const s = {
56
+ const i = {
57
57
  meta: {
58
58
  app: { name: e.appName, version: t ?? "unknown", environment: e.env },
59
59
  session: { id: o, attributes: n },
@@ -75,7 +75,7 @@ const $ = {
75
75
  }
76
76
  ]
77
77
  };
78
- return { sessionId: o, payload: s };
78
+ return { sessionId: o, payload: i };
79
79
  }, K = (e, t, o) => {
80
80
  if (!e || typeof fetch > "u")
81
81
  return;
@@ -91,49 +91,49 @@ const $ = {
91
91
  } catch {
92
92
  }
93
93
  }, Z = (e) => {
94
- const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls: s, collectorUrls: c, env: a, jwt: l, timeoutMs: m = 15e3, onLoad: _, onError: g } = e;
94
+ const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls: i, collectorUrls: c, env: a, jwt: s, timeoutMs: g = 15e3, onLoad: _, onError: h } = e;
95
95
  if (typeof document > "u")
96
- return T;
96
+ return O;
97
97
  const d = `${t}-script-${a}`;
98
98
  if (customElements.get(t) || document.getElementById(d))
99
- return T;
100
- const b = P(l), R = e.report ?? ((p) => K(c && J(c, a, l), p, r));
101
- let f = !1, x = 0, C;
102
- const v = () => {
103
- C !== void 0 && clearTimeout(C);
104
- }, k = (p, h, i) => {
105
- if (f)
99
+ return O;
100
+ const R = P(s), v = e.report ?? ((u) => K(c && H(c, a, s), u, r));
101
+ let m = !1, T = 0, k;
102
+ const S = () => {
103
+ k !== void 0 && clearTimeout(k);
104
+ }, x = (u, y, l) => {
105
+ if (m)
106
106
  return;
107
- const A = Math.round(performance.now() - x), w = {
107
+ const W = Math.round(performance.now() - T), E = {
108
108
  webComponentTag: t,
109
109
  appName: o,
110
110
  env: a,
111
- scriptUrl: h,
112
- reason: p,
113
- triedFallback: i,
114
- elapsedMs: A,
115
- claims: b
111
+ scriptUrl: y,
112
+ reason: u,
113
+ triedFallback: l,
114
+ elapsedMs: W,
115
+ claims: R
116
116
  };
117
- R(w);
118
- const O = i ? void 0 : L(s ?? {}, a, l);
119
- if (O && O !== h) {
120
- N(O, !0);
117
+ v(E);
118
+ const C = l ? void 0 : z(i ?? {}, a, s);
119
+ if (C && C !== y) {
120
+ w(C, !0);
121
121
  return;
122
122
  }
123
- f = !0, v(), document.getElementById(d)?.remove(), g?.(w);
124
- }, N = (p, h) => {
125
- v(), x = performance.now();
126
- const i = document.createElement("script");
127
- i.id = d, i.src = p, i.type = "module", i.async = !0, i.onload = () => {
123
+ m = !0, S(), document.getElementById(d)?.remove(), h?.(E);
124
+ }, w = (u, y) => {
125
+ S(), T = performance.now();
126
+ const l = document.createElement("script");
127
+ l.id = d, l.src = u, l.type = "module", l.async = !0, l.onload = () => {
128
128
  setTimeout(() => {
129
- f || (customElements.get(t) ? (f = !0, v(), _?.()) : k("not-defined", p, h));
129
+ m || (customElements.get(t) ? (m = !0, S(), _?.()) : x("not-defined", u, y));
130
130
  }, 0);
131
- }, i.onerror = () => k("network", p, h), C = setTimeout(() => k("timeout", p, h), m), document.getElementById(d)?.remove(), document.head.appendChild(i);
132
- }, E = L(n, a, l);
133
- return E ? (N(E, !1), () => {
134
- f = !0, v();
135
- }) : T;
136
- }, u = {
131
+ }, l.onerror = () => x("network", u, y), k = setTimeout(() => x("timeout", u, y), g), document.getElementById(d)?.remove(), document.head.appendChild(l);
132
+ }, N = z(n, a, s);
133
+ return N ? (w(N, !1), () => {
134
+ m = !0, S();
135
+ }) : O;
136
+ }, f = {
137
137
  local: "http://localhost:5173",
138
138
  dev: "https://sdk-cdn.dev.0hash.com",
139
139
  cert: "https://sdk-cdn.cert.zerohash.com",
@@ -141,25 +141,26 @@ const $ = {
141
141
  "eu-cert": "https://sdk-cdn.cert.zerohash.eu",
142
142
  "eu-prod": "https://sdk-cdn.zerohash.eu"
143
143
  }, q = "https://sdk-cdn.gating.0hash.com", Q = (e, t, o = {}) => {
144
- const { eu: r = !1, legacyAliases: n = !1, local: s = u.local } = o, c = (l) => `${l}/${e}/${t}`, a = {
145
- local: c(s),
146
- dev: c(u.dev),
144
+ const { eu: r = !1, legacyAliases: n = !1, local: i = f.local } = o, c = (s) => `${s}/${e}/${t}`, a = {
145
+ local: c(i),
146
+ dev: c(f.dev),
147
147
  gating: c(q),
148
- cert: c(u.cert),
149
- prod: c(u.prod)
148
+ cert: c(f.cert),
149
+ prod: c(f.prod)
150
150
  };
151
- return n && (a.sandbox = c(u.cert), a.production = c(u.prod)), r && (a["eu-cert"] = c(u["eu-cert"]), a["eu-prod"] = c(u["eu-prod"])), a;
151
+ return n && (a.sandbox = c(f.cert), a.production = c(f.prod)), r && (a["eu-cert"] = c(f["eu-cert"]), a["eu-prod"] = c(f["eu-prod"])), a;
152
152
  };
153
153
  var F;
154
154
  (function(e) {
155
155
  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";
156
156
  })(F || (F = {}));
157
- const S = {
157
+ const b = {
158
158
  evergreen: "#00381D",
159
159
  green: "#CCFFD0",
160
160
  offBlack: "#1C1B1C",
161
161
  grayLight: "#EBEBE9"
162
- }, X = ({ onRetry: e }) => W("div", { role: "alert", style: {
162
+ }, X = ({ onRetry: e, onClose: t }) => A("div", { role: "alert", style: {
163
+ position: "relative",
163
164
  display: "flex",
164
165
  flexDirection: "column",
165
166
  alignItems: "center",
@@ -169,18 +170,29 @@ const S = {
169
170
  padding: "32px 24px",
170
171
  textAlign: "center",
171
172
  fontFamily: "inherit",
172
- color: S.offBlack,
173
+ color: b.offBlack,
173
174
  background: "#FFFFFF",
174
- border: `1px solid ${S.grayLight}`,
175
+ border: `1px solid ${b.grayLight}`,
175
176
  borderRadius: "12px"
176
- }, children: [y("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: y("path", { 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", stroke: S.evergreen, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }), y("p", { style: { margin: 0, fontSize: "16px", fontWeight: 600 }, children: "Something went wrong" }), y("p", { style: { margin: 0, fontSize: "14px", opacity: 0.75 }, children: "We couldn't load this content. Please check your internet connection and try again." }), y("button", { type: "button", onClick: e, style: {
177
+ }, children: [t && p("button", { type: "button", onClick: t, "aria-label": "Close", style: {
178
+ position: "absolute",
179
+ top: "12px",
180
+ right: "12px",
181
+ display: "flex",
182
+ padding: "4px",
183
+ color: b.offBlack,
184
+ background: "none",
185
+ border: "none",
186
+ cursor: "pointer",
187
+ lineHeight: 0
188
+ }, children: p("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: p("path", { d: "M18 6L6 18M6 6l12 12", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) }), p("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: p("path", { 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", stroke: b.evergreen, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }), p("p", { style: { margin: 0, fontSize: "16px", fontWeight: 600 }, children: "Something went wrong" }), p("p", { style: { margin: 0, fontSize: "14px", opacity: 0.75 }, children: "We couldn't load this content. Please check your internet connection and try again." }), p("button", { type: "button", onClick: e, style: {
177
189
  marginTop: "8px",
178
190
  padding: "8px 20px",
179
191
  fontSize: "14px",
180
192
  fontWeight: 600,
181
193
  fontFamily: "inherit",
182
- color: S.green,
183
- background: S.evergreen,
194
+ color: b.green,
195
+ background: b.evergreen,
184
196
  border: "none",
185
197
  borderRadius: "8px",
186
198
  cursor: "pointer"
@@ -192,69 +204,75 @@ const S = {
192
204
  n !== void 0 && (o[r] = n);
193
205
  });
194
206
  }, ee = (e) => {
195
- const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls: s, collectorUrls: c, env: a, jwt: l, timeoutMs: m } = e, [_, g] = z(!1), [d, b] = z(0);
196
- I(() => (g(!1), Z({
207
+ const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls: i, collectorUrls: c, env: a, jwt: s, timeoutMs: g } = e, [_, h] = L(!1), [d, R] = L(0);
208
+ I(() => (h(!1), Z({
197
209
  webComponentTag: t,
198
210
  appName: o ?? t,
199
211
  appVersion: r,
200
212
  scriptUrls: n,
201
- fallbackScriptUrls: s,
213
+ fallbackScriptUrls: i,
202
214
  collectorUrls: c ?? $,
203
215
  env: a,
204
- jwt: l,
205
- timeoutMs: m,
206
- onError: () => g(!0)
216
+ jwt: s,
217
+ timeoutMs: g,
218
+ onError: () => h(!0)
207
219
  })), [
208
220
  t,
209
221
  o,
210
222
  r,
211
223
  n,
212
- s,
224
+ i,
213
225
  c,
214
226
  a,
215
- l,
216
- m,
227
+ s,
228
+ g,
217
229
  d
218
230
  ]);
219
- const R = j(() => b((f) => f + 1), []);
220
- return { loadFailed: _, retry: R };
231
+ const v = j(() => R((m) => m + 1), []);
232
+ return { loadFailed: _, retry: v };
221
233
  }, te = Q("travel-rule-web", "index.js", { eu: !0 }), B = "zerohash-travel-rule", ne = ({
222
234
  jwt: e,
223
235
  depositId: t,
224
236
  walletAddress: o,
225
237
  intentionAction: r,
226
238
  env: n = "prod",
227
- theme: s,
239
+ theme: i,
228
240
  onCompleted: c,
229
241
  onError: a,
230
- onClose: l,
231
- onLoaded: m,
242
+ onClose: s,
243
+ onLoaded: g,
232
244
  onEvent: _,
233
- ...g
245
+ ...h
234
246
  }) => {
235
- const d = M(null);
247
+ const d = D(null);
236
248
  Y(d, {
237
- theme: s,
249
+ theme: i,
238
250
  depositId: t,
239
251
  walletAddress: o,
240
252
  intentionAction: r,
241
253
  onCompleted: c,
242
254
  onError: a,
243
- onClose: l,
244
- onLoaded: m,
255
+ onClose: s,
256
+ onLoaded: g,
245
257
  onEvent: _
246
258
  });
247
- const { loadFailed: b, retry: R } = ee({
259
+ const { loadFailed: R, retry: v } = ee({
248
260
  webComponentTag: B,
249
261
  scriptUrls: te,
250
262
  env: n,
251
263
  jwt: e
252
264
  });
253
- return b ? /* @__PURE__ */ y(X, { onRetry: R }) : D.createElement(B, {
265
+ return R ? /* @__PURE__ */ p(
266
+ X,
267
+ {
268
+ onRetry: v,
269
+ onClose: s
270
+ }
271
+ ) : M.createElement(B, {
254
272
  ref: d,
255
273
  jwt: e,
256
274
  env: n,
257
- theme: s,
275
+ theme: i,
258
276
  // camelCase — React 19 sets these as properties via the extra-prop
259
277
  // setters before connectedCallback runs when the element is registered,
260
278
  // and as lowercased HTML attributes when it isn't (the base's
@@ -262,7 +280,7 @@ const S = {
262
280
  depositId: t,
263
281
  walletAddress: o,
264
282
  intentionAction: r,
265
- ...g
283
+ ...h
266
284
  });
267
285
  };
268
286
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerohash-sdk/travel-rule-react",
3
- "version": "0.3.5",
3
+ "version": "0.5.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",