@zerohash-sdk/travel-rule-react 0.3.0 → 0.3.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/index.d.ts +14 -9
- package/dist/index.js +73 -70
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ declare type Theme = 'auto' | 'light' | 'dark';
|
|
|
66
66
|
*
|
|
67
67
|
* @param props - Component properties
|
|
68
68
|
* @param jwt - JWT token for authentication (required)
|
|
69
|
-
* @param depositId - Deposit id the submission is tied to (required
|
|
69
|
+
* @param depositId - Deposit id the submission is tied to (required)
|
|
70
70
|
* @param env - Target environment ("local" | "dev" | "cert" | "prod", defaults to "prod")
|
|
71
71
|
* @param theme - Theme mode ("auto" | "light" | "dark", defaults to "auto")
|
|
72
72
|
* @param onCompleted - Callback invoked when the flow is successfully completed
|
|
@@ -107,21 +107,26 @@ declare interface TravelRuleProps {
|
|
|
107
107
|
jwt: string;
|
|
108
108
|
/**
|
|
109
109
|
* Deposit id the travel-rule submission is tied to. Required — every
|
|
110
|
-
* travel-rule submission is scoped to a specific deposit
|
|
111
|
-
*
|
|
112
|
-
* the behaviour of `env`.
|
|
110
|
+
* travel-rule submission is scoped to a specific deposit. Init-only:
|
|
111
|
+
* post-mount changes are ignored, matching the behaviour of `env`.
|
|
113
112
|
*
|
|
114
113
|
* @example "deposit-abc123"
|
|
115
114
|
*/
|
|
116
115
|
depositId: string;
|
|
117
116
|
/**
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
117
|
+
* On-chain address the SDK is asking about (deposit source wallet for
|
|
118
|
+
* deposits, destination wallet for withdrawals). Used to query the
|
|
119
|
+
* travel-rule ownership status and pick which screen to show. Init-only.
|
|
121
120
|
*
|
|
122
|
-
* @example "
|
|
121
|
+
* @example "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
|
|
123
122
|
*/
|
|
124
|
-
walletAddress
|
|
123
|
+
walletAddress: string;
|
|
124
|
+
/**
|
|
125
|
+
* Which side of the flow the SDK is being opened for. Sent as
|
|
126
|
+
* `intention_action` on the status query — the same address can require
|
|
127
|
+
* different ownership evidence for deposits vs. withdrawals. Init-only.
|
|
128
|
+
*/
|
|
129
|
+
intentionAction: 'deposit' | 'withdrawal';
|
|
125
130
|
/**
|
|
126
131
|
* Target environment for the Zerohash Travel Rule service.
|
|
127
132
|
*
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as A, jsx as y } from "react/jsx-runtime";
|
|
2
2
|
import j, { useEffect as U, useState as z, useCallback as D, useRef as M } from "react";
|
|
3
3
|
const $ = {
|
|
4
4
|
dev: "https://grafana-faro-collector.dev.0hash.com/collect",
|
|
@@ -23,28 +23,28 @@ const $ = {
|
|
|
23
23
|
} catch {
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
|
-
},
|
|
26
|
+
}, I = (e, t) => V(t) !== "eu" ? e : e === "cert" ? "eu-cert" : e === "prod" ? "eu-prod" : e, P = (e) => {
|
|
27
27
|
if (!e || typeof e != "string")
|
|
28
28
|
return {};
|
|
29
29
|
const t = e.split(".");
|
|
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"),
|
|
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;
|
|
34
34
|
return {
|
|
35
35
|
participantCode: a(c.participant_code),
|
|
36
36
|
platformName: a(c.platform_name),
|
|
37
|
-
platformCode: a(
|
|
37
|
+
platformCode: a(s.platform_code),
|
|
38
38
|
region: a(c.region)
|
|
39
39
|
};
|
|
40
40
|
} catch {
|
|
41
41
|
return {};
|
|
42
42
|
}
|
|
43
43
|
}, L = (e, t, o) => {
|
|
44
|
-
const r =
|
|
44
|
+
const r = I(t, o);
|
|
45
45
|
return e[r] ?? e[t] ?? e.prod;
|
|
46
46
|
}, J = (e, t, o) => {
|
|
47
|
-
const r =
|
|
47
|
+
const r = I(t, o);
|
|
48
48
|
return e[r] ?? e[t];
|
|
49
49
|
}, x = () => {
|
|
50
50
|
}, H = () => {
|
|
@@ -53,7 +53,7 @@ const $ = {
|
|
|
53
53
|
}, K = (e, t) => {
|
|
54
54
|
const o = H(), 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
|
|
56
|
+
const s = {
|
|
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:
|
|
78
|
+
return { sessionId: o, payload: s };
|
|
79
79
|
}, G = (e, t, o) => {
|
|
80
80
|
if (!e || typeof fetch > "u")
|
|
81
81
|
return;
|
|
@@ -91,47 +91,47 @@ const $ = {
|
|
|
91
91
|
} catch {
|
|
92
92
|
}
|
|
93
93
|
}, Z = (e) => {
|
|
94
|
-
const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls:
|
|
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;
|
|
95
95
|
if (typeof document > "u")
|
|
96
96
|
return x;
|
|
97
97
|
const d = `${t}-script-${a}`;
|
|
98
98
|
if (customElements.get(t) || document.getElementById(d))
|
|
99
99
|
return x;
|
|
100
|
-
const b = P(
|
|
101
|
-
let
|
|
102
|
-
const
|
|
100
|
+
const b = P(l), R = e.report ?? ((p) => G(c && J(c, a, l), p, r));
|
|
101
|
+
let f = !1, E = 0, C;
|
|
102
|
+
const v = () => {
|
|
103
103
|
C !== void 0 && clearTimeout(C);
|
|
104
104
|
}, k = (p, h, i) => {
|
|
105
|
-
if (
|
|
105
|
+
if (f)
|
|
106
106
|
return;
|
|
107
|
-
const
|
|
107
|
+
const W = Math.round(performance.now() - E), N = {
|
|
108
108
|
webComponentTag: t,
|
|
109
109
|
appName: o,
|
|
110
110
|
env: a,
|
|
111
111
|
scriptUrl: h,
|
|
112
112
|
reason: p,
|
|
113
113
|
triedFallback: i,
|
|
114
|
-
elapsedMs:
|
|
114
|
+
elapsedMs: W,
|
|
115
115
|
claims: b
|
|
116
116
|
};
|
|
117
|
-
|
|
118
|
-
const O = i ? void 0 : L(
|
|
117
|
+
R(N);
|
|
118
|
+
const O = i ? void 0 : L(s ?? {}, a, l);
|
|
119
119
|
if (O && O !== h) {
|
|
120
120
|
T(O, !0);
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
|
-
|
|
123
|
+
f = !0, v(), document.getElementById(d)?.remove(), g?.(N);
|
|
124
124
|
}, T = (p, h) => {
|
|
125
|
-
|
|
125
|
+
v(), E = performance.now();
|
|
126
126
|
const i = document.createElement("script");
|
|
127
127
|
i.id = d, i.src = p, i.type = "module", i.async = !0, i.onload = () => {
|
|
128
128
|
setTimeout(() => {
|
|
129
|
-
|
|
129
|
+
f || (customElements.get(t) ? (f = !0, v(), _?.()) : k("not-defined", p, h));
|
|
130
130
|
}, 0);
|
|
131
|
-
}, i.onerror = () => k("network", p, h), C = setTimeout(() => k("timeout", p, h),
|
|
132
|
-
}, w = L(n, a,
|
|
131
|
+
}, i.onerror = () => k("network", p, h), C = setTimeout(() => k("timeout", p, h), m), document.getElementById(d)?.remove(), document.head.appendChild(i);
|
|
132
|
+
}, w = L(n, a, l);
|
|
133
133
|
return w ? (T(w, !1), () => {
|
|
134
|
-
|
|
134
|
+
f = !0, v();
|
|
135
135
|
}) : x;
|
|
136
136
|
}, u = {
|
|
137
137
|
local: "http://localhost:5173",
|
|
@@ -141,8 +141,8 @@ const $ = {
|
|
|
141
141
|
"eu-cert": "https://sdk-cdn.cert.zerohash.eu",
|
|
142
142
|
"eu-prod": "https://sdk-cdn.zerohash.eu"
|
|
143
143
|
}, q = (e, t, o = {}) => {
|
|
144
|
-
const { eu: r = !1, legacyAliases: n = !1, local:
|
|
145
|
-
local: c(
|
|
144
|
+
const { eu: r = !1, legacyAliases: n = !1, local: s = u.local } = o, c = (l) => `${l}/${e}/${t}`, a = {
|
|
145
|
+
local: c(s),
|
|
146
146
|
dev: c(u.dev),
|
|
147
147
|
cert: c(u.cert),
|
|
148
148
|
prod: c(u.prod)
|
|
@@ -153,12 +153,12 @@ var F;
|
|
|
153
153
|
(function(e) {
|
|
154
154
|
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";
|
|
155
155
|
})(F || (F = {}));
|
|
156
|
-
const
|
|
156
|
+
const S = {
|
|
157
157
|
evergreen: "#00381D",
|
|
158
158
|
green: "#CCFFD0",
|
|
159
159
|
offBlack: "#1C1B1C",
|
|
160
160
|
grayLight: "#EBEBE9"
|
|
161
|
-
}, Q = ({ onRetry: e }) =>
|
|
161
|
+
}, Q = ({ onRetry: e }) => A("div", { role: "alert", style: {
|
|
162
162
|
display: "flex",
|
|
163
163
|
flexDirection: "column",
|
|
164
164
|
alignItems: "center",
|
|
@@ -168,18 +168,18 @@ const R = {
|
|
|
168
168
|
padding: "32px 24px",
|
|
169
169
|
textAlign: "center",
|
|
170
170
|
fontFamily: "inherit",
|
|
171
|
-
color:
|
|
171
|
+
color: S.offBlack,
|
|
172
172
|
background: "#FFFFFF",
|
|
173
|
-
border: `1px solid ${
|
|
173
|
+
border: `1px solid ${S.grayLight}`,
|
|
174
174
|
borderRadius: "12px"
|
|
175
|
-
}, 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:
|
|
175
|
+
}, 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: {
|
|
176
176
|
marginTop: "8px",
|
|
177
177
|
padding: "8px 20px",
|
|
178
178
|
fontSize: "14px",
|
|
179
179
|
fontWeight: 600,
|
|
180
180
|
fontFamily: "inherit",
|
|
181
|
-
color:
|
|
182
|
-
background:
|
|
181
|
+
color: S.green,
|
|
182
|
+
background: S.evergreen,
|
|
183
183
|
border: "none",
|
|
184
184
|
borderRadius: "8px",
|
|
185
185
|
cursor: "pointer"
|
|
@@ -191,74 +191,77 @@ const R = {
|
|
|
191
191
|
n !== void 0 && (o[r] = n);
|
|
192
192
|
});
|
|
193
193
|
}, Y = (e) => {
|
|
194
|
-
const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls:
|
|
195
|
-
U(() => (
|
|
194
|
+
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);
|
|
195
|
+
U(() => (g(!1), Z({
|
|
196
196
|
webComponentTag: t,
|
|
197
197
|
appName: o ?? t,
|
|
198
198
|
appVersion: r,
|
|
199
199
|
scriptUrls: n,
|
|
200
|
-
fallbackScriptUrls:
|
|
200
|
+
fallbackScriptUrls: s,
|
|
201
201
|
collectorUrls: c ?? $,
|
|
202
202
|
env: a,
|
|
203
|
-
jwt:
|
|
204
|
-
timeoutMs:
|
|
205
|
-
onError: () =>
|
|
203
|
+
jwt: l,
|
|
204
|
+
timeoutMs: m,
|
|
205
|
+
onError: () => g(!0)
|
|
206
206
|
})), [
|
|
207
207
|
t,
|
|
208
208
|
o,
|
|
209
209
|
r,
|
|
210
210
|
n,
|
|
211
|
-
|
|
211
|
+
s,
|
|
212
212
|
c,
|
|
213
213
|
a,
|
|
214
|
-
|
|
215
|
-
|
|
214
|
+
l,
|
|
215
|
+
m,
|
|
216
216
|
d
|
|
217
217
|
]);
|
|
218
|
-
const
|
|
219
|
-
return { loadFailed: _, retry:
|
|
218
|
+
const R = D(() => b((f) => f + 1), []);
|
|
219
|
+
return { loadFailed: _, retry: R };
|
|
220
220
|
}, ee = q("travel-rule-web", "index.js", { eu: !0 }), B = "zerohash-travel-rule", re = ({
|
|
221
221
|
jwt: e,
|
|
222
222
|
depositId: t,
|
|
223
223
|
walletAddress: o,
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
224
|
+
intentionAction: r,
|
|
225
|
+
env: n = "prod",
|
|
226
|
+
theme: s,
|
|
227
|
+
onCompleted: c,
|
|
228
|
+
onError: a,
|
|
229
|
+
onClose: l,
|
|
230
|
+
onLoaded: m,
|
|
231
|
+
onEvent: _,
|
|
232
|
+
...g
|
|
232
233
|
}) => {
|
|
233
|
-
const
|
|
234
|
-
X(
|
|
235
|
-
theme:
|
|
234
|
+
const d = M(null);
|
|
235
|
+
X(d, {
|
|
236
|
+
theme: s,
|
|
236
237
|
depositId: t,
|
|
237
238
|
walletAddress: o,
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
239
|
+
intentionAction: r,
|
|
240
|
+
onCompleted: c,
|
|
241
|
+
onError: a,
|
|
242
|
+
onClose: l,
|
|
243
|
+
onLoaded: m,
|
|
244
|
+
onEvent: _
|
|
243
245
|
});
|
|
244
|
-
const { loadFailed:
|
|
246
|
+
const { loadFailed: b, retry: R } = Y({
|
|
245
247
|
webComponentTag: B,
|
|
246
248
|
scriptUrls: ee,
|
|
247
|
-
env:
|
|
249
|
+
env: n,
|
|
248
250
|
jwt: e
|
|
249
251
|
});
|
|
250
|
-
return
|
|
251
|
-
ref:
|
|
252
|
+
return b ? /* @__PURE__ */ y(Q, { onRetry: R }) : j.createElement(B, {
|
|
253
|
+
ref: d,
|
|
252
254
|
jwt: e,
|
|
253
|
-
env:
|
|
254
|
-
theme:
|
|
255
|
-
// camelCase — React 19 sets
|
|
256
|
-
// before connectedCallback runs
|
|
257
|
-
//
|
|
258
|
-
//
|
|
255
|
+
env: n,
|
|
256
|
+
theme: s,
|
|
257
|
+
// camelCase — React 19 sets these as properties via the extra-prop
|
|
258
|
+
// setters before connectedCallback runs when the element is registered,
|
|
259
|
+
// and as lowercased HTML attributes when it isn't (the base's
|
|
260
|
+
// `parseJsonAttr` accepts raw string values on that fallback path).
|
|
259
261
|
depositId: t,
|
|
260
262
|
walletAddress: o,
|
|
261
|
-
|
|
263
|
+
intentionAction: r,
|
|
264
|
+
...g
|
|
262
265
|
});
|
|
263
266
|
};
|
|
264
267
|
export {
|