@zerohash-sdk/fund-react 1.3.1 → 1.3.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 CHANGED
@@ -79,7 +79,7 @@ declare type ErrorPayload = {
79
79
  * // With callback functions
80
80
  * <Fund
81
81
  * jwt="your-jwt-token"
82
- * theme="auto"
82
+ * theme="light"
83
83
  * onLoaded={() => console.log('Crypto sell loaded and ready')}
84
84
  * onCompleted={({ amountSold, assetSymbol }) => console.log('Sold', amountSold, assetSymbol)}
85
85
  * onClose={() => console.log('Crypto sell closed')}
package/dist/index.js CHANGED
@@ -1,42 +1,67 @@
1
- import x, { useRef as b, useEffect as l } from "react";
2
- const y = {
1
+ import m, { useRef as O, useEffect as p } from "react";
2
+ const E = (e) => {
3
+ if (!e || typeof e != "string")
4
+ return null;
5
+ const t = e.split(".");
6
+ if (t.length < 2)
7
+ return null;
8
+ try {
9
+ const r = t[1].replace(/-/g, "+").replace(/_/g, "/"), s = r + "===".slice(0, (4 - r.length % 4) % 4), u = typeof atob < "u" ? atob(s) : Buffer.from(s, "base64").toString("utf-8"), c = JSON.parse(u)?.payload?.region;
10
+ if (typeof c != "string")
11
+ return null;
12
+ const o = c.toLowerCase();
13
+ return o === "us" || o === "eu" ? o : null;
14
+ } catch {
15
+ return null;
16
+ }
17
+ }, N = (e, t) => E(t) !== "eu" ? e : e === "cert" ? "eu-cert" : e === "prod" ? "eu-prod" : e;
18
+ var R;
19
+ (function(e) {
20
+ 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";
21
+ })(R || (R = {}));
22
+ const h = {
3
23
  local: "http://localhost:5173/fund-web/index.js",
4
- dev: "https://connect-sdk.dev.0hash.com/fund-web/index.js",
5
- cert: "https://sdk.sandbox.connect.xyz/fund-web/index.js",
6
- prod: "https://sdk.connect.xyz/fund-web/index.js"
7
- }, I = "zerohash-fund-script", a = "zerohash-fund", R = (c = "prod") => y[c], w = ({
8
- jwt: c,
9
- env: r = "prod",
10
- theme: h,
11
- isPay: n = !1,
12
- onCompleted: s,
13
- onError: o,
14
- onClose: d,
15
- onLoaded: i,
24
+ dev: "https://sdk-cdn.dev.0hash.com/fund-web/index.js",
25
+ cert: "https://sdk-cdn.cert.zerohash.com/fund-web/index.js",
26
+ prod: "https://sdk-cdn.zerohash.com/fund-web/index.js",
27
+ "eu-cert": "https://sdk-cdn.cert.zerohash.eu/fund-web/index.js",
28
+ "eu-prod": "https://sdk-cdn.zerohash.eu/fund-web/index.js"
29
+ }, b = "zerohash-fund-script", _ = "zerohash-fund", y = (e = "prod", t) => {
30
+ const r = N(e, t);
31
+ return h[r] ?? h[e];
32
+ }, I = ({
33
+ jwt: e,
34
+ env: t = "prod",
35
+ theme: r,
36
+ isPay: s = !1,
37
+ onCompleted: u,
38
+ onError: i,
39
+ onClose: c,
40
+ onLoaded: o,
16
41
  onEvent: f,
17
- ...m
42
+ ...g
18
43
  }) => {
19
- const u = b(null);
20
- return l(() => {
21
- const t = u.current;
22
- t && (s && (t.onCompleted = s), o && (t.onError = o), d && (t.onClose = d), i && (t.onLoaded = i), f && (t.onEvent = f), t.isPay = n);
23
- }, [s, o, d, i, f, n]), l(() => {
24
- const t = R(r), p = `${I}-${r}`;
25
- if (document.getElementById(p))
44
+ const l = O(null);
45
+ return p(() => {
46
+ const n = l.current;
47
+ n && (n.isPay = s, r !== void 0 && (n.theme = r), u && (n.onCompleted = u), i && (n.onError = i), c && (n.onClose = c), o && (n.onLoaded = o), f && (n.onEvent = f));
48
+ }, [s, r, u, i, c, o, f]), p(() => {
49
+ const n = y(t, e), a = `${b}-${t}`;
50
+ if (document.getElementById(a))
26
51
  return;
27
- const e = document.createElement("script");
28
- e.id = p, e.src = t, e.type = "module", e.async = !0, e.onerror = () => {
29
- console.error(`Failed to load the script for ${a} from ${r} environment.`);
30
- }, document.head.appendChild(e);
31
- }, [r]), x.createElement(a, {
32
- ref: u,
33
- jwt: c,
34
- env: r,
35
- theme: h,
36
- ispay: n ? "true" : void 0,
37
- ...m
52
+ const d = document.createElement("script");
53
+ d.id = a, d.src = n, d.type = "module", d.async = !0, d.onerror = () => {
54
+ console.error(`Failed to load the script for ${_} from ${t} environment.`);
55
+ }, document.head.appendChild(d);
56
+ }, [t, e]), m.createElement(_, {
57
+ ref: l,
58
+ jwt: e,
59
+ env: t,
60
+ theme: r,
61
+ ispay: s ? "true" : void 0,
62
+ ...g
38
63
  });
39
64
  };
40
65
  export {
41
- w as Fund
66
+ I as Fund
42
67
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerohash-sdk/fund-react",
3
- "version": "1.3.1",
3
+ "version": "1.3.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",