@zerohash-sdk/csp-crypto-sell-react 1.6.0 → 1.6.2
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.js +49 -47
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
1
|
+
import { jsxs as U, jsx as h } from "react/jsx-runtime";
|
|
2
|
+
import W, { useEffect as B, useState as T, useCallback as A, useRef as M } from "react";
|
|
3
3
|
const b = {
|
|
4
4
|
evergreen: "#00381D",
|
|
5
5
|
green: "#CCFFD0",
|
|
6
6
|
offBlack: "#1C1B1C",
|
|
7
7
|
grayLight: "#EBEBE9"
|
|
8
|
-
}, D = ({ onRetry: e }) =>
|
|
8
|
+
}, D = ({ onRetry: e }) => U("div", { role: "alert", style: {
|
|
9
9
|
display: "flex",
|
|
10
10
|
flexDirection: "column",
|
|
11
11
|
alignItems: "center",
|
|
@@ -52,11 +52,11 @@ const b = {
|
|
|
52
52
|
if (t.length < 2)
|
|
53
53
|
return null;
|
|
54
54
|
try {
|
|
55
|
-
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"),
|
|
56
|
-
if (typeof
|
|
55
|
+
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)?.payload?.region;
|
|
56
|
+
if (typeof s != "string")
|
|
57
57
|
return null;
|
|
58
|
-
const
|
|
59
|
-
return
|
|
58
|
+
const c = s.toLowerCase();
|
|
59
|
+
return c === "us" || c === "eu" ? c : null;
|
|
60
60
|
} catch {
|
|
61
61
|
return null;
|
|
62
62
|
}
|
|
@@ -67,17 +67,17 @@ const b = {
|
|
|
67
67
|
if (t.length < 2)
|
|
68
68
|
return {};
|
|
69
69
|
try {
|
|
70
|
-
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),
|
|
70
|
+
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), s = i?.payload ?? {}, c = (a) => typeof a == "string" && a.length > 0 ? a : void 0;
|
|
71
71
|
return {
|
|
72
|
-
participantCode:
|
|
73
|
-
platformName:
|
|
74
|
-
platformCode:
|
|
75
|
-
region:
|
|
72
|
+
participantCode: c(s.participant_code),
|
|
73
|
+
platformName: c(s.platform_name),
|
|
74
|
+
platformCode: c(i.platform_code),
|
|
75
|
+
region: c(s.region)
|
|
76
76
|
};
|
|
77
77
|
} catch {
|
|
78
78
|
return {};
|
|
79
79
|
}
|
|
80
|
-
},
|
|
80
|
+
}, z = (e, t, o) => {
|
|
81
81
|
const r = I(t, o);
|
|
82
82
|
return e[r] ?? e[t] ?? e.prod;
|
|
83
83
|
}, K = (e, t, o) => {
|
|
@@ -128,64 +128,64 @@ const b = {
|
|
|
128
128
|
} catch {
|
|
129
129
|
}
|
|
130
130
|
}, q = (e) => {
|
|
131
|
-
const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls: i, collectorUrls:
|
|
131
|
+
const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls: i, collectorUrls: s, env: c, jwt: a, timeoutMs: p = 15e3, onLoad: y, onError: f } = e;
|
|
132
132
|
if (typeof document > "u")
|
|
133
133
|
return C;
|
|
134
|
-
const m = `${t}-script-${
|
|
134
|
+
const m = `${t}-script-${c}`;
|
|
135
135
|
if (customElements.get(t) || document.getElementById(m))
|
|
136
136
|
return C;
|
|
137
|
-
const R = $(
|
|
138
|
-
let u = !1,
|
|
137
|
+
const R = $(a), S = e.report ?? ((d) => Z(s && K(s, c, a), d, r));
|
|
138
|
+
let u = !1, k = 0, x;
|
|
139
139
|
const _ = () => {
|
|
140
140
|
x !== void 0 && clearTimeout(x);
|
|
141
|
-
},
|
|
141
|
+
}, w = (d, g, l) => {
|
|
142
142
|
if (u)
|
|
143
143
|
return;
|
|
144
|
-
const
|
|
144
|
+
const j = Math.round(performance.now() - k), N = {
|
|
145
145
|
webComponentTag: t,
|
|
146
146
|
appName: o,
|
|
147
|
-
env:
|
|
147
|
+
env: c,
|
|
148
148
|
scriptUrl: g,
|
|
149
149
|
reason: d,
|
|
150
150
|
triedFallback: l,
|
|
151
|
-
elapsedMs:
|
|
151
|
+
elapsedMs: j,
|
|
152
152
|
claims: R
|
|
153
153
|
};
|
|
154
154
|
S(N);
|
|
155
|
-
const
|
|
156
|
-
if (
|
|
157
|
-
|
|
155
|
+
const v = l ? void 0 : z(i ?? {}, c, a);
|
|
156
|
+
if (v && v !== g) {
|
|
157
|
+
O(v, !0);
|
|
158
158
|
return;
|
|
159
159
|
}
|
|
160
160
|
u = !0, _(), document.getElementById(m)?.remove(), f?.(N);
|
|
161
|
-
},
|
|
162
|
-
_(),
|
|
161
|
+
}, O = (d, g) => {
|
|
162
|
+
_(), k = performance.now();
|
|
163
163
|
const l = document.createElement("script");
|
|
164
164
|
l.id = m, l.src = d, l.type = "module", l.async = !0, l.onload = () => {
|
|
165
165
|
setTimeout(() => {
|
|
166
|
-
u || (customElements.get(t) ? (u = !0, _(), y?.()) :
|
|
166
|
+
u || (customElements.get(t) ? (u = !0, _(), y?.()) : w("not-defined", d, g));
|
|
167
167
|
}, 0);
|
|
168
|
-
}, l.onerror = () =>
|
|
169
|
-
}, E =
|
|
170
|
-
return E ? (
|
|
168
|
+
}, l.onerror = () => w("network", d, g), x = setTimeout(() => w("timeout", d, g), p), document.getElementById(m)?.remove(), document.head.appendChild(l);
|
|
169
|
+
}, E = z(n, c, a);
|
|
170
|
+
return E ? (O(E, !1), () => {
|
|
171
171
|
u = !0, _();
|
|
172
172
|
}) : C;
|
|
173
173
|
};
|
|
174
|
-
var
|
|
174
|
+
var L;
|
|
175
175
|
(function(e) {
|
|
176
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";
|
|
177
|
-
})(
|
|
177
|
+
})(L || (L = {}));
|
|
178
178
|
const Q = (e) => {
|
|
179
|
-
const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls: i, collectorUrls:
|
|
179
|
+
const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls: i, collectorUrls: s, env: c, jwt: a, timeoutMs: p } = e, [y, f] = T(!1), [m, R] = T(0);
|
|
180
180
|
B(() => (f(!1), q({
|
|
181
181
|
webComponentTag: t,
|
|
182
182
|
appName: o ?? t,
|
|
183
183
|
appVersion: r,
|
|
184
184
|
scriptUrls: n,
|
|
185
185
|
fallbackScriptUrls: i,
|
|
186
|
-
collectorUrls:
|
|
187
|
-
env:
|
|
188
|
-
jwt:
|
|
186
|
+
collectorUrls: s ?? P,
|
|
187
|
+
env: c,
|
|
188
|
+
jwt: a,
|
|
189
189
|
timeoutMs: p,
|
|
190
190
|
onError: () => f(!0)
|
|
191
191
|
})), [
|
|
@@ -194,44 +194,46 @@ const Q = (e) => {
|
|
|
194
194
|
r,
|
|
195
195
|
n,
|
|
196
196
|
i,
|
|
197
|
+
s,
|
|
197
198
|
c,
|
|
198
199
|
a,
|
|
199
|
-
s,
|
|
200
200
|
p,
|
|
201
201
|
m
|
|
202
202
|
]);
|
|
203
|
-
const S =
|
|
203
|
+
const S = A(() => R((u) => u + 1), []);
|
|
204
204
|
return { loadFailed: y, retry: S };
|
|
205
205
|
}, X = {
|
|
206
206
|
local: "http://localhost:5173/csp-crypto-sell-web/index.js",
|
|
207
207
|
dev: "https://connect-sdk.dev.0hash.com/csp-crypto-sell-web/index.js",
|
|
208
208
|
cert: "https://sdk.sandbox.connect.xyz/csp-crypto-sell-web/index.js",
|
|
209
|
-
prod: "https://sdk.connect.xyz/csp-crypto-sell-web/index.js"
|
|
210
|
-
|
|
209
|
+
prod: "https://sdk.connect.xyz/csp-crypto-sell-web/index.js",
|
|
210
|
+
"eu-cert": "https://sdk-cdn.cert.zerohash.eu/csp-crypto-sell-web/index.js",
|
|
211
|
+
"eu-prod": "https://sdk-cdn.zerohash.eu/csp-crypto-sell-web/index.js"
|
|
212
|
+
}, F = "zerohash-csp-crypto-sell", te = ({
|
|
211
213
|
jwt: e,
|
|
212
214
|
env: t = "prod",
|
|
213
215
|
theme: o,
|
|
214
216
|
onCompleted: r,
|
|
215
217
|
onError: n,
|
|
216
218
|
onClose: i,
|
|
217
|
-
onLoaded:
|
|
218
|
-
onEvent:
|
|
219
|
-
...
|
|
219
|
+
onLoaded: s,
|
|
220
|
+
onEvent: c,
|
|
221
|
+
...a
|
|
220
222
|
}) => {
|
|
221
223
|
const p = M(null);
|
|
222
|
-
V(p, { theme: o, onCompleted: r, onError: n, onClose: i, onLoaded:
|
|
224
|
+
V(p, { theme: o, onCompleted: r, onError: n, onClose: i, onLoaded: s, onEvent: c });
|
|
223
225
|
const { loadFailed: y, retry: f } = Q({
|
|
224
|
-
webComponentTag:
|
|
226
|
+
webComponentTag: F,
|
|
225
227
|
scriptUrls: X,
|
|
226
228
|
env: t,
|
|
227
229
|
jwt: e
|
|
228
230
|
});
|
|
229
|
-
return y ? /* @__PURE__ */ h(D, { onRetry: f }) :
|
|
231
|
+
return y ? /* @__PURE__ */ h(D, { onRetry: f }) : W.createElement(F, {
|
|
230
232
|
ref: p,
|
|
231
233
|
jwt: e,
|
|
232
234
|
env: t,
|
|
233
235
|
theme: o,
|
|
234
|
-
...
|
|
236
|
+
...a
|
|
235
237
|
});
|
|
236
238
|
};
|
|
237
239
|
export {
|