@connect-xyz/auth-react 0.13.0 → 0.16.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/README.md +4 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +11 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,6 +35,7 @@ function App() {
|
|
|
35
35
|
<Auth
|
|
36
36
|
jwt={jwt}
|
|
37
37
|
env="production" // or "sandbox" for testing
|
|
38
|
+
theme="auto" // 'auto' (default), 'light', or 'dark'
|
|
38
39
|
/>
|
|
39
40
|
);
|
|
40
41
|
}
|
|
@@ -68,6 +69,7 @@ function App() {
|
|
|
68
69
|
<Auth
|
|
69
70
|
jwt={jwt}
|
|
70
71
|
env="production"
|
|
72
|
+
theme="auto" // 'auto' (default), 'light', or 'dark'
|
|
71
73
|
onError={handleError}
|
|
72
74
|
onClose={handleClose}
|
|
73
75
|
onDeposit={handleDeposit}
|
|
@@ -101,6 +103,7 @@ function App() {
|
|
|
101
103
|
<Auth
|
|
102
104
|
jwt={jwt}
|
|
103
105
|
env={environment}
|
|
106
|
+
theme="auto" // 'auto' (default), 'light', or 'dark'
|
|
104
107
|
onError={({ errorCode, reason }) => {
|
|
105
108
|
console.log('Error:', errorCode, 'Reason:', reason);
|
|
106
109
|
}}
|
|
@@ -129,6 +132,7 @@ export default App;
|
|
|
129
132
|
| ----------- | --------------------------------- | -------- | -------------- | ---------------------------------------------- |
|
|
130
133
|
| `jwt` | `string` | Yes | - | JWT token for authentication with Connect Auth |
|
|
131
134
|
| `env` | `"production" \| "sandbox"` | No | `"production"` | Target environment |
|
|
135
|
+
| `theme` | `"auto" \| "light" \| "dark"` | No | `"auto"` | Theme mode for the interface |
|
|
132
136
|
| `onError` | `({ errorCode, reason }) => void` | No | - | Callback for error events |
|
|
133
137
|
| `onClose` | `() => void` | No | - | Callback when the widget is closed |
|
|
134
138
|
| `onDeposit` | `({ data }) => void` | No | - | Callback for deposit received |
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ declare type AppEvent<TType extends string = string, TData = Record<string, unkn
|
|
|
18
18
|
* @param props - Component properties
|
|
19
19
|
* @param jwt - JWT token for authentication (required)
|
|
20
20
|
* @param env - Target environment ("sandbox" | "production", defaults to "production")
|
|
21
|
+
* @param theme - Theme mode ("auto" | "light" | "dark", defaults to "auto")
|
|
21
22
|
* @param onError - Callback function for error handling
|
|
22
23
|
* @param onClose - Callback function for close events
|
|
23
24
|
* @param onDeposit - Callback function for deposit events
|
|
@@ -31,9 +32,13 @@ declare type AppEvent<TType extends string = string, TData = Record<string, unkn
|
|
|
31
32
|
* // Using sandbox environment for testing
|
|
32
33
|
* <Auth jwt="your-jwt-token" env="sandbox" />
|
|
33
34
|
*
|
|
35
|
+
* // Force dark theme
|
|
36
|
+
* <Auth jwt="your-jwt-token" theme="dark" />
|
|
37
|
+
*
|
|
34
38
|
* // With callback functions
|
|
35
39
|
* <Auth
|
|
36
40
|
* jwt="your-jwt-token"
|
|
41
|
+
* theme="auto"
|
|
37
42
|
* onError={({ errorCode, reason }) => console.error('Auth error:', errorCode, 'Reason:', reason)}
|
|
38
43
|
* onClose={() => console.log('Auth closed')}
|
|
39
44
|
* onDeposit={({ data }) => console.log('Deposit completed:', data.depositId, 'Status:', data.status.value)}
|
|
@@ -95,6 +100,29 @@ declare interface AuthWrapperProps extends AuthCallbacks {
|
|
|
95
100
|
* ```
|
|
96
101
|
*/
|
|
97
102
|
env?: Environment;
|
|
103
|
+
/**
|
|
104
|
+
* Theme mode for the Connect Auth interface.
|
|
105
|
+
*
|
|
106
|
+
* @default "auto"
|
|
107
|
+
*
|
|
108
|
+
* Available themes:
|
|
109
|
+
* - `"auto"` - Automatically detect system preference (light/dark mode)
|
|
110
|
+
* - `"light"` - Force light theme
|
|
111
|
+
* - `"dark"` - Force dark theme
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```tsx
|
|
115
|
+
* // Auto-detect system preference (default)
|
|
116
|
+
* <Auth jwt={token} />
|
|
117
|
+
*
|
|
118
|
+
* // Force dark theme
|
|
119
|
+
* <Auth jwt={token} theme="dark" />
|
|
120
|
+
*
|
|
121
|
+
* // Force light theme
|
|
122
|
+
* <Auth jwt={token} theme="light" />
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
theme?: Theme;
|
|
98
126
|
}
|
|
99
127
|
|
|
100
128
|
/**
|
|
@@ -187,4 +215,13 @@ declare type ErrorPayload = {
|
|
|
187
215
|
reason: string;
|
|
188
216
|
};
|
|
189
217
|
|
|
218
|
+
/**
|
|
219
|
+
* Theme mode for the Connect Auth interface.
|
|
220
|
+
*
|
|
221
|
+
* - `"auto"` - Automatically detect system preference (light/dark mode)
|
|
222
|
+
* - `"light"` - Force light theme
|
|
223
|
+
* - `"dark"` - Force dark theme
|
|
224
|
+
*/
|
|
225
|
+
declare type Theme = 'auto' | 'light' | 'dark';
|
|
226
|
+
|
|
190
227
|
export { }
|
package/dist/index.js
CHANGED
|
@@ -1,35 +1,37 @@
|
|
|
1
|
-
import
|
|
2
|
-
const
|
|
1
|
+
import m, { useRef as h, useEffect as p } from "react";
|
|
2
|
+
const x = {
|
|
3
3
|
sandbox: "https://sdk.sandbox.connect.xyz/auth-web/index.js",
|
|
4
4
|
production: "https://sdk.connect.xyz/auth-web/index.js"
|
|
5
|
-
},
|
|
5
|
+
}, y = "connect-auth-script", a = "connect-auth", I = (n = "production") => x[n], b = ({
|
|
6
6
|
jwt: n,
|
|
7
7
|
env: c = "production",
|
|
8
|
+
theme: f,
|
|
8
9
|
onError: r,
|
|
9
10
|
onClose: o,
|
|
10
11
|
onDeposit: s,
|
|
11
12
|
onEvent: i,
|
|
12
|
-
...
|
|
13
|
+
...l
|
|
13
14
|
}) => {
|
|
14
|
-
const d =
|
|
15
|
+
const d = h(null);
|
|
15
16
|
return p(() => {
|
|
16
17
|
const t = d.current;
|
|
17
18
|
t && (r && (t.onError = r), o && (t.onClose = o), s && (t.onDeposit = s), i && (t.onEvent = i));
|
|
18
19
|
}, [r, o, s, i]), p(() => {
|
|
19
|
-
const t =
|
|
20
|
+
const t = I(c), u = `${y}-${c}`;
|
|
20
21
|
if (document.getElementById(u))
|
|
21
22
|
return;
|
|
22
23
|
const e = document.createElement("script");
|
|
23
24
|
e.id = u, e.src = t, e.type = "module", e.async = !0, e.onerror = () => {
|
|
24
25
|
console.error(`Failed to load the script for ${a} from ${c} environment.`);
|
|
25
26
|
}, document.head.appendChild(e);
|
|
26
|
-
}, [c]),
|
|
27
|
+
}, [c]), m.createElement(a, {
|
|
27
28
|
ref: d,
|
|
28
29
|
jwt: n,
|
|
29
30
|
env: c,
|
|
30
|
-
|
|
31
|
+
theme: f,
|
|
32
|
+
...l
|
|
31
33
|
});
|
|
32
34
|
};
|
|
33
35
|
export {
|
|
34
|
-
|
|
36
|
+
b as Auth
|
|
35
37
|
};
|