@connect-xyz/auth-react 0.33.0 → 0.35.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 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 m, { useRef as h, useEffect as p } from "react";
2
- const x = {
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
- }, y = "connect-auth-script", a = "connect-auth", I = (n = "production") => x[n], b = ({
6
- jwt: n,
5
+ }, I = "connect-auth-script", a = "connect-auth", R = (r = "production") => y[r], E = ({
6
+ jwt: r,
7
7
  env: c = "production",
8
- theme: f,
9
- onError: r,
8
+ theme: l,
9
+ onError: n,
10
10
  onClose: o,
11
11
  onDeposit: s,
12
12
  onEvent: i,
13
- ...l
13
+ onLoaded: u,
14
+ ...m
14
15
  }) => {
15
- const d = h(null);
16
- return p(() => {
16
+ const d = x(null);
17
+ return f(() => {
17
18
  const t = d.current;
18
- t && (r && (t.onError = r), o && (t.onClose = o), s && (t.onDeposit = s), i && (t.onEvent = i));
19
- }, [r, o, s, i]), p(() => {
20
- const t = I(c), u = `${y}-${c}`;
21
- if (document.getElementById(u))
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 = u, e.src = t, e.type = "module", e.async = !0, e.onerror = () => {
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]), m.createElement(a, {
28
+ }, [c]), h.createElement(a, {
28
29
  ref: d,
29
- jwt: n,
30
+ jwt: r,
30
31
  env: c,
31
- theme: f,
32
- ...l
32
+ theme: l,
33
+ ...m
33
34
  });
34
35
  };
35
36
  export {
36
- b as Auth
37
+ E as Auth
37
38
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@connect-xyz/auth-react",
3
- "version": "0.33.0",
3
+ "version": "0.35.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",