@zerohash-sdk/crypto-deposits-react 0.1.1 → 0.2.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 +35 -0
- package/dist/index.js +41 -40
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -45,8 +45,43 @@ declare interface CryptoDepositsProps {
|
|
|
45
45
|
onLoaded?: () => void;
|
|
46
46
|
/** Callback invoked for general application events during the crypto deposit flow. */
|
|
47
47
|
onEvent?: (event: CryptoDepositsEvent) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Callback invoked with the status of a deposit funded from a connected
|
|
50
|
+
* external account. Non-terminal: it can fire more than once per deposit, and
|
|
51
|
+
* the outcome is read off `status`.
|
|
52
|
+
*/
|
|
53
|
+
onDeposit?: (deposit: DepositCompletedPayload) => void;
|
|
48
54
|
}
|
|
49
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Deposit completed payload — emitted by SDKs that drive a deposit through
|
|
58
|
+
* the integrations flow. Lives on `CommonCallbacks` because both Auth and
|
|
59
|
+
* any SDK embedding `@zerohash/integrations-flow` (e.g. fund with `useAuth`)
|
|
60
|
+
* resolve through the same deposit-status hook.
|
|
61
|
+
*/
|
|
62
|
+
declare type DepositCompletedPayload = {
|
|
63
|
+
data: {
|
|
64
|
+
depositId: string;
|
|
65
|
+
status: DepositStatus;
|
|
66
|
+
assetId: string;
|
|
67
|
+
networkId: string;
|
|
68
|
+
amount?: string;
|
|
69
|
+
accountMatchingValidation?: {
|
|
70
|
+
status: 'PENDING' | 'VALID' | 'INVALID' | 'ERROR';
|
|
71
|
+
reason?: string;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Deposit status object — shared across SDKs that surface deposit completion.
|
|
78
|
+
*/
|
|
79
|
+
declare type DepositStatus = {
|
|
80
|
+
value: string;
|
|
81
|
+
details: string;
|
|
82
|
+
occurredAt: string;
|
|
83
|
+
};
|
|
84
|
+
|
|
50
85
|
/**
|
|
51
86
|
* Available environments for the Connect Crypto Deposits service.
|
|
52
87
|
*
|
package/dist/index.js
CHANGED
|
@@ -91,49 +91,49 @@ const $ = {
|
|
|
91
91
|
} catch {
|
|
92
92
|
}
|
|
93
93
|
}, Z = (e) => {
|
|
94
|
-
const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: a, fallbackScriptUrls: i, collectorUrls: s, env: n, jwt: c, timeoutMs:
|
|
94
|
+
const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: a, fallbackScriptUrls: i, collectorUrls: s, env: n, jwt: c, timeoutMs: g = 15e3, onLoad: h, onError: y } = e;
|
|
95
95
|
if (typeof document > "u")
|
|
96
96
|
return O;
|
|
97
|
-
const
|
|
98
|
-
if (customElements.get(t) || document.getElementById(
|
|
97
|
+
const p = `${t}-script-${n}`;
|
|
98
|
+
if (customElements.get(t) || document.getElementById(p))
|
|
99
99
|
return O;
|
|
100
|
-
const S = P(c), k = e.report ?? ((
|
|
100
|
+
const S = P(c), k = e.report ?? ((u) => K(s && H(s, n, c), u, r));
|
|
101
101
|
let m = !1, w = 0, v;
|
|
102
102
|
const R = () => {
|
|
103
103
|
v !== void 0 && clearTimeout(v);
|
|
104
|
-
}, C = (
|
|
104
|
+
}, C = (u, b, l) => {
|
|
105
105
|
if (m)
|
|
106
106
|
return;
|
|
107
107
|
const U = Math.round(performance.now() - w), E = {
|
|
108
108
|
webComponentTag: t,
|
|
109
109
|
appName: o,
|
|
110
110
|
env: n,
|
|
111
|
-
scriptUrl:
|
|
112
|
-
reason:
|
|
111
|
+
scriptUrl: b,
|
|
112
|
+
reason: u,
|
|
113
113
|
triedFallback: l,
|
|
114
114
|
elapsedMs: U,
|
|
115
115
|
claims: S
|
|
116
116
|
};
|
|
117
117
|
k(E);
|
|
118
118
|
const x = l ? void 0 : z(i ?? {}, n, c);
|
|
119
|
-
if (x && x !==
|
|
119
|
+
if (x && x !== b) {
|
|
120
120
|
N(x, !0);
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
|
-
m = !0, R(), document.getElementById(
|
|
124
|
-
}, N = (
|
|
123
|
+
m = !0, R(), document.getElementById(p)?.remove(), y?.(E);
|
|
124
|
+
}, N = (u, b) => {
|
|
125
125
|
R(), w = performance.now();
|
|
126
126
|
const l = document.createElement("script");
|
|
127
|
-
l.id =
|
|
127
|
+
l.id = p, l.src = u, l.type = "module", l.async = !0, l.onload = () => {
|
|
128
128
|
setTimeout(() => {
|
|
129
|
-
m || (customElements.get(t) ? (m = !0, R(),
|
|
129
|
+
m || (customElements.get(t) ? (m = !0, R(), h?.()) : C("not-defined", u, b));
|
|
130
130
|
}, 0);
|
|
131
|
-
}, l.onerror = () => C("network",
|
|
131
|
+
}, l.onerror = () => C("network", u, b), v = setTimeout(() => C("timeout", u, b), g), document.getElementById(p)?.remove(), document.head.appendChild(l);
|
|
132
132
|
}, T = z(a, n, c);
|
|
133
133
|
return T ? (N(T, !1), () => {
|
|
134
134
|
m = !0, R();
|
|
135
135
|
}) : O;
|
|
136
|
-
},
|
|
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,20 +141,20 @@ 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: a = !1, local: i =
|
|
144
|
+
const { eu: r = !1, legacyAliases: a = !1, local: i = f.local } = o, s = (c) => `${c}/${e}/${t}`, n = {
|
|
145
145
|
local: s(i),
|
|
146
|
-
dev: s(
|
|
146
|
+
dev: s(f.dev),
|
|
147
147
|
gating: s(q),
|
|
148
|
-
cert: s(
|
|
149
|
-
prod: s(
|
|
148
|
+
cert: s(f.cert),
|
|
149
|
+
prod: s(f.prod)
|
|
150
150
|
};
|
|
151
|
-
return a && (n.sandbox = s(
|
|
151
|
+
return a && (n.sandbox = s(f.cert), n.production = s(f.prod)), r && (n["eu-cert"] = s(f["eu-cert"]), n["eu-prod"] = s(f["eu-prod"])), n;
|
|
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
|
|
157
|
+
const _ = {
|
|
158
158
|
evergreen: "#00381D",
|
|
159
159
|
green: "#CCFFD0",
|
|
160
160
|
offBlack: "#1C1B1C",
|
|
@@ -170,9 +170,9 @@ const b = {
|
|
|
170
170
|
padding: "32px 24px",
|
|
171
171
|
textAlign: "center",
|
|
172
172
|
fontFamily: "inherit",
|
|
173
|
-
color:
|
|
173
|
+
color: _.offBlack,
|
|
174
174
|
background: "#FFFFFF",
|
|
175
|
-
border: `1px solid ${
|
|
175
|
+
border: `1px solid ${_.grayLight}`,
|
|
176
176
|
borderRadius: "12px"
|
|
177
177
|
}, children: [t && d("button", { type: "button", onClick: t, "aria-label": "Close", style: {
|
|
178
178
|
position: "absolute",
|
|
@@ -180,19 +180,19 @@ const b = {
|
|
|
180
180
|
right: "12px",
|
|
181
181
|
display: "flex",
|
|
182
182
|
padding: "4px",
|
|
183
|
-
color:
|
|
183
|
+
color: _.offBlack,
|
|
184
184
|
background: "none",
|
|
185
185
|
border: "none",
|
|
186
186
|
cursor: "pointer",
|
|
187
187
|
lineHeight: 0
|
|
188
|
-
}, children: d("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: d("path", { d: "M18 6L6 18M6 6l12 12", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) }), d("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: d("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:
|
|
188
|
+
}, children: d("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: d("path", { d: "M18 6L6 18M6 6l12 12", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) }), d("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: d("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: _.evergreen, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }), d("p", { style: { margin: 0, fontSize: "16px", fontWeight: 600 }, children: "Something went wrong" }), d("p", { style: { margin: 0, fontSize: "14px", opacity: 0.75 }, children: "We couldn't load this content. Please check your internet connection and try again." }), d("button", { type: "button", onClick: e, style: {
|
|
189
189
|
marginTop: "8px",
|
|
190
190
|
padding: "8px 20px",
|
|
191
191
|
fontSize: "14px",
|
|
192
192
|
fontWeight: 600,
|
|
193
193
|
fontFamily: "inherit",
|
|
194
|
-
color:
|
|
195
|
-
background:
|
|
194
|
+
color: _.green,
|
|
195
|
+
background: _.evergreen,
|
|
196
196
|
border: "none",
|
|
197
197
|
borderRadius: "8px",
|
|
198
198
|
cursor: "pointer"
|
|
@@ -204,8 +204,8 @@ const b = {
|
|
|
204
204
|
a !== void 0 && (o[r] = a);
|
|
205
205
|
});
|
|
206
206
|
}, ee = (e) => {
|
|
207
|
-
const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: a, fallbackScriptUrls: i, collectorUrls: s, env: n, jwt: c, timeoutMs:
|
|
208
|
-
A(() => (
|
|
207
|
+
const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: a, fallbackScriptUrls: i, collectorUrls: s, env: n, jwt: c, timeoutMs: g } = e, [h, y] = L(!1), [p, S] = L(0);
|
|
208
|
+
A(() => (y(!1), Z({
|
|
209
209
|
webComponentTag: t,
|
|
210
210
|
appName: o ?? t,
|
|
211
211
|
appVersion: r,
|
|
@@ -214,8 +214,8 @@ const b = {
|
|
|
214
214
|
collectorUrls: s ?? $,
|
|
215
215
|
env: n,
|
|
216
216
|
jwt: c,
|
|
217
|
-
timeoutMs:
|
|
218
|
-
onError: () =>
|
|
217
|
+
timeoutMs: g,
|
|
218
|
+
onError: () => y(!0)
|
|
219
219
|
})), [
|
|
220
220
|
t,
|
|
221
221
|
o,
|
|
@@ -225,11 +225,11 @@ const b = {
|
|
|
225
225
|
s,
|
|
226
226
|
n,
|
|
227
227
|
c,
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
g,
|
|
229
|
+
p
|
|
230
230
|
]);
|
|
231
231
|
const k = M(() => S((m) => m + 1), []);
|
|
232
|
-
return { loadFailed:
|
|
232
|
+
return { loadFailed: h, retry: k };
|
|
233
233
|
}, te = Q("crypto-deposits-web", "index.js", { eu: !0 }), B = "zerohash-crypto-deposits", ne = ({
|
|
234
234
|
jwt: e,
|
|
235
235
|
env: t = "prod",
|
|
@@ -239,22 +239,23 @@ const b = {
|
|
|
239
239
|
onClose: i,
|
|
240
240
|
onLoaded: s,
|
|
241
241
|
onEvent: n,
|
|
242
|
-
|
|
242
|
+
onDeposit: c,
|
|
243
|
+
...g
|
|
243
244
|
}) => {
|
|
244
|
-
const
|
|
245
|
-
Y(
|
|
246
|
-
const { loadFailed:
|
|
245
|
+
const h = j(null);
|
|
246
|
+
Y(h, { theme: o, onCompleted: r, onError: a, onClose: i, onLoaded: s, onEvent: n, onDeposit: c });
|
|
247
|
+
const { loadFailed: y, retry: p } = ee({
|
|
247
248
|
webComponentTag: B,
|
|
248
249
|
scriptUrls: te,
|
|
249
250
|
env: t,
|
|
250
251
|
jwt: e
|
|
251
252
|
});
|
|
252
|
-
return
|
|
253
|
-
ref:
|
|
253
|
+
return y ? /* @__PURE__ */ d(X, { onRetry: p }) : D.createElement(B, {
|
|
254
|
+
ref: h,
|
|
254
255
|
jwt: e,
|
|
255
256
|
env: t,
|
|
256
257
|
theme: o,
|
|
257
|
-
...
|
|
258
|
+
...g
|
|
258
259
|
});
|
|
259
260
|
};
|
|
260
261
|
export {
|