@zerohash-sdk/crypto-deposits-react 0.1.1 → 0.3.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 +51 -0
- package/dist/index.js +43 -41
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -37,6 +37,28 @@ declare interface CryptoDepositsProps {
|
|
|
37
37
|
theme?: Theme;
|
|
38
38
|
/** Callback invoked when the crypto deposit flow is successfully completed. */
|
|
39
39
|
onCompleted?: (data: CryptoDepositsCompletedData) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Callback invoked when a deposit transaction reaches a terminal **failed**
|
|
42
|
+
* state (the "Transaction failed" page). Distinct from `onError` — this
|
|
43
|
+
* carries the failed transaction's details, not an SDK/request error.
|
|
44
|
+
*
|
|
45
|
+
* @param data - Details about the failed transaction (depositId, assetSymbol, network, amount)
|
|
46
|
+
*/
|
|
47
|
+
onFailed?: (data: CryptoDepositsCompletedData) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Callback invoked when a deposit made from an external funding source
|
|
50
|
+
* changes status. This is the "auth as a feature" path; the manual-deposit
|
|
51
|
+
* path reports through `onCompleted`/`onFailed` instead.
|
|
52
|
+
*
|
|
53
|
+
* A status notification, not a single terminal event: it can fire more than
|
|
54
|
+
* once for one deposit, including while account matching is still verifying.
|
|
55
|
+
* Read `deposit.data.status.value` (`PROCESSED` = funded, `FAILED` = not) and
|
|
56
|
+
* `deposit.data.accountMatchingValidation?.status` (`PENDING` = not finished
|
|
57
|
+
* yet) rather than assuming any call is the last one.
|
|
58
|
+
*
|
|
59
|
+
* @param deposit - The deposit and its current status
|
|
60
|
+
*/
|
|
61
|
+
onDeposit?: (deposit: DepositCompletedPayload) => void;
|
|
40
62
|
/** Callback invoked when an error occurs during the crypto deposit flow. */
|
|
41
63
|
onError?: (error: ErrorPayload) => void;
|
|
42
64
|
/** Callback invoked when the user closes the crypto deposits widget. */
|
|
@@ -47,6 +69,35 @@ declare interface CryptoDepositsProps {
|
|
|
47
69
|
onEvent?: (event: CryptoDepositsEvent) => void;
|
|
48
70
|
}
|
|
49
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Deposit completed payload — emitted by SDKs that drive a deposit through
|
|
74
|
+
* the integrations flow. Lives on `CommonCallbacks` because both Auth and
|
|
75
|
+
* any SDK embedding `@zerohash/integrations-flow` (e.g. fund with `useAuth`)
|
|
76
|
+
* resolve through the same deposit-status hook.
|
|
77
|
+
*/
|
|
78
|
+
declare type DepositCompletedPayload = {
|
|
79
|
+
data: {
|
|
80
|
+
depositId: string;
|
|
81
|
+
status: DepositStatus;
|
|
82
|
+
assetId: string;
|
|
83
|
+
networkId: string;
|
|
84
|
+
amount?: string;
|
|
85
|
+
accountMatchingValidation?: {
|
|
86
|
+
status: 'PENDING' | 'VALID' | 'INVALID' | 'ERROR';
|
|
87
|
+
reason?: string;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Deposit status object — shared across SDKs that surface deposit completion.
|
|
94
|
+
*/
|
|
95
|
+
declare type DepositStatus = {
|
|
96
|
+
value: string;
|
|
97
|
+
details: string;
|
|
98
|
+
occurredAt: string;
|
|
99
|
+
};
|
|
100
|
+
|
|
50
101
|
/**
|
|
51
102
|
* Available environments for the Connect Crypto Deposits service.
|
|
52
103
|
*
|
package/dist/index.js
CHANGED
|
@@ -91,28 +91,28 @@ 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: h = 15e3, onLoad: _, onError: m } = 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
|
|
101
|
-
let
|
|
102
|
-
const
|
|
100
|
+
const R = P(c), k = e.report ?? ((u) => K(s && H(s, n, c), u, r));
|
|
101
|
+
let g = !1, w = 0, v;
|
|
102
|
+
const S = () => {
|
|
103
103
|
v !== void 0 && clearTimeout(v);
|
|
104
|
-
}, C = (
|
|
105
|
-
if (
|
|
104
|
+
}, C = (u, y, l) => {
|
|
105
|
+
if (g)
|
|
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
111
|
scriptUrl: y,
|
|
112
|
-
reason:
|
|
112
|
+
reason: u,
|
|
113
113
|
triedFallback: l,
|
|
114
114
|
elapsedMs: U,
|
|
115
|
-
claims:
|
|
115
|
+
claims: R
|
|
116
116
|
};
|
|
117
117
|
k(E);
|
|
118
118
|
const x = l ? void 0 : z(i ?? {}, n, c);
|
|
@@ -120,20 +120,20 @@ const $ = {
|
|
|
120
120
|
N(x, !0);
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
|
-
|
|
124
|
-
}, N = (
|
|
125
|
-
|
|
123
|
+
g = !0, S(), document.getElementById(p)?.remove(), m?.(E);
|
|
124
|
+
}, N = (u, y) => {
|
|
125
|
+
S(), 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
|
-
|
|
129
|
+
g || (customElements.get(t) ? (g = !0, S(), _?.()) : C("not-defined", u, y));
|
|
130
130
|
}, 0);
|
|
131
|
-
}, l.onerror = () => C("network",
|
|
131
|
+
}, l.onerror = () => C("network", u, y), v = setTimeout(() => C("timeout", u, y), h), document.getElementById(p)?.remove(), document.head.appendChild(l);
|
|
132
132
|
}, T = z(a, n, c);
|
|
133
133
|
return T ? (N(T, !1), () => {
|
|
134
|
-
|
|
134
|
+
g = !0, S();
|
|
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,14 +141,14 @@ 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) {
|
|
@@ -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: h } = e, [_, m] = L(!1), [p, R] = L(0);
|
|
208
|
+
A(() => (m(!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: h,
|
|
218
|
+
onError: () => m(!0)
|
|
219
219
|
})), [
|
|
220
220
|
t,
|
|
221
221
|
o,
|
|
@@ -225,36 +225,38 @@ const b = {
|
|
|
225
225
|
s,
|
|
226
226
|
n,
|
|
227
227
|
c,
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
h,
|
|
229
|
+
p
|
|
230
230
|
]);
|
|
231
|
-
const k = M(() =>
|
|
231
|
+
const k = M(() => R((g) => g + 1), []);
|
|
232
232
|
return { loadFailed: _, 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",
|
|
236
236
|
theme: o,
|
|
237
237
|
onCompleted: r,
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
238
|
+
onFailed: a,
|
|
239
|
+
onDeposit: i,
|
|
240
|
+
onError: s,
|
|
241
|
+
onClose: n,
|
|
242
|
+
onLoaded: c,
|
|
243
|
+
onEvent: h,
|
|
244
|
+
..._
|
|
243
245
|
}) => {
|
|
244
|
-
const
|
|
245
|
-
Y(
|
|
246
|
-
const { loadFailed:
|
|
246
|
+
const m = j(null);
|
|
247
|
+
Y(m, { theme: o, onCompleted: r, onFailed: a, onDeposit: i, onError: s, onClose: n, onLoaded: c, onEvent: h });
|
|
248
|
+
const { loadFailed: p, retry: R } = ee({
|
|
247
249
|
webComponentTag: B,
|
|
248
250
|
scriptUrls: te,
|
|
249
251
|
env: t,
|
|
250
252
|
jwt: e
|
|
251
253
|
});
|
|
252
|
-
return
|
|
253
|
-
ref:
|
|
254
|
+
return p ? /* @__PURE__ */ d(X, { onRetry: R }) : D.createElement(B, {
|
|
255
|
+
ref: m,
|
|
254
256
|
jwt: e,
|
|
255
257
|
env: t,
|
|
256
258
|
theme: o,
|
|
257
|
-
...
|
|
259
|
+
..._
|
|
258
260
|
});
|
|
259
261
|
};
|
|
260
262
|
export {
|