@connect-xyz/auth-react 0.32.0 → 0.34.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 +4 -0
- package/dist/index.js +20 -19
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ declare type AppEvent<TType extends string = string, TData = Record<string, unkn
|
|
|
23
23
|
* @param onClose - Callback function for close events
|
|
24
24
|
* @param onDeposit - Callback function for deposit events
|
|
25
25
|
* @param onEvent - Callback function for general events
|
|
26
|
+
* @param onLoaded - Callback function called when the Auth component is ready
|
|
26
27
|
*
|
|
27
28
|
* @example
|
|
28
29
|
* ```tsx
|
|
@@ -39,6 +40,7 @@ declare type AppEvent<TType extends string = string, TData = Record<string, unkn
|
|
|
39
40
|
* <Auth
|
|
40
41
|
* jwt="your-jwt-token"
|
|
41
42
|
* theme="auto"
|
|
43
|
+
* onLoaded={() => console.log('Auth loaded and ready')}
|
|
42
44
|
* onError={({ errorCode, reason }) => console.error('Auth error:', errorCode, 'Reason:', reason)}
|
|
43
45
|
* onClose={() => console.log('Auth closed')}
|
|
44
46
|
* onDeposit={({ data }) => console.log('Deposit completed:', data.depositId, 'Status:', data.status.value)}
|
|
@@ -57,6 +59,8 @@ export declare const Auth: default_2.FC<AuthWrapperProps>;
|
|
|
57
59
|
declare type AuthCallbacks = CommonCallbacks<AuthEvent> & {
|
|
58
60
|
/** Called when a deposit action occurs */
|
|
59
61
|
onDeposit?: (deposit: DepositCompletedPayload) => void;
|
|
62
|
+
/** Called when the Auth component has finished loading and is ready */
|
|
63
|
+
onLoaded?: () => void;
|
|
60
64
|
};
|
|
61
65
|
|
|
62
66
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,37 +1,38 @@
|
|
|
1
|
-
import
|
|
2
|
-
const
|
|
1
|
+
import h, { useRef as x, useEffect as f } from "react";
|
|
2
|
+
const y = {
|
|
3
3
|
sandbox: "https://sdk.sandbox.connect.xyz/auth-web/index.js",
|
|
4
4
|
production: "https://sdk.connect.xyz/auth-web/index.js"
|
|
5
|
-
},
|
|
6
|
-
jwt:
|
|
5
|
+
}, I = "connect-auth-script", a = "connect-auth", R = (r = "production") => y[r], E = ({
|
|
6
|
+
jwt: r,
|
|
7
7
|
env: c = "production",
|
|
8
|
-
theme:
|
|
9
|
-
onError:
|
|
8
|
+
theme: l,
|
|
9
|
+
onError: n,
|
|
10
10
|
onClose: o,
|
|
11
11
|
onDeposit: s,
|
|
12
12
|
onEvent: i,
|
|
13
|
-
|
|
13
|
+
onLoaded: u,
|
|
14
|
+
...m
|
|
14
15
|
}) => {
|
|
15
|
-
const d =
|
|
16
|
-
return
|
|
16
|
+
const d = x(null);
|
|
17
|
+
return f(() => {
|
|
17
18
|
const t = d.current;
|
|
18
|
-
t && (
|
|
19
|
-
}, [
|
|
20
|
-
const t =
|
|
21
|
-
if (document.getElementById(
|
|
19
|
+
t && (n && (t.onError = n), o && (t.onClose = o), s && (t.onDeposit = s), i && (t.onEvent = i), u && (t.onLoaded = u));
|
|
20
|
+
}, [n, o, s, i, u]), f(() => {
|
|
21
|
+
const t = R(c), p = `${I}-${c}`;
|
|
22
|
+
if (document.getElementById(p))
|
|
22
23
|
return;
|
|
23
24
|
const e = document.createElement("script");
|
|
24
|
-
e.id =
|
|
25
|
+
e.id = p, e.src = t, e.type = "module", e.async = !0, e.onerror = () => {
|
|
25
26
|
console.error(`Failed to load the script for ${a} from ${c} environment.`);
|
|
26
27
|
}, document.head.appendChild(e);
|
|
27
|
-
}, [c]),
|
|
28
|
+
}, [c]), h.createElement(a, {
|
|
28
29
|
ref: d,
|
|
29
|
-
jwt:
|
|
30
|
+
jwt: r,
|
|
30
31
|
env: c,
|
|
31
|
-
theme:
|
|
32
|
-
...
|
|
32
|
+
theme: l,
|
|
33
|
+
...m
|
|
33
34
|
});
|
|
34
35
|
};
|
|
35
36
|
export {
|
|
36
|
-
|
|
37
|
+
E as Auth
|
|
37
38
|
};
|