@b3dotfun/sdk 0.0.40-test.2 → 0.0.40
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/cjs/anyspend/constants/index.d.ts +0 -1
- package/dist/cjs/anyspend/constants/index.js +1 -2
- package/dist/cjs/anyspend/react/components/AnySpend.js +5 -6
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +8 -9
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +4 -5
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +3 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetails.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +23 -19
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +9 -8
- package/dist/cjs/anyspend/react/components/common/PaymentMethodSwitch.d.ts +7 -0
- package/dist/cjs/anyspend/react/components/common/PaymentMethodSwitch.js +24 -0
- package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.js +6 -4
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +2 -9
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +1 -12
- package/dist/esm/anyspend/constants/index.d.ts +0 -1
- package/dist/esm/anyspend/constants/index.js +0 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +6 -7
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +8 -9
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +5 -6
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.d.ts +2 -1
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +3 -2
- package/dist/esm/anyspend/react/components/common/OrderDetails.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +24 -20
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +10 -9
- package/dist/esm/anyspend/react/components/common/PaymentMethodSwitch.d.ts +7 -0
- package/dist/esm/anyspend/react/components/common/PaymentMethodSwitch.js +21 -0
- package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.js +6 -4
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +2 -9
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +1 -12
- package/dist/types/anyspend/constants/index.d.ts +0 -1
- package/dist/types/anyspend/react/components/common/ConnectWalletPayment.d.ts +2 -1
- package/dist/types/anyspend/react/components/common/OrderDetails.d.ts +2 -0
- package/dist/types/anyspend/react/components/common/PaymentMethodSwitch.d.ts +7 -0
- package/dist/types/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -0
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +2 -9
- package/package.json +4 -5
- package/src/anyspend/constants/index.ts +0 -2
- package/src/anyspend/react/components/AnySpend.tsx +15 -17
- package/src/anyspend/react/components/AnySpendCustom.tsx +19 -21
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +16 -18
- package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +5 -0
- package/src/anyspend/react/components/common/OrderDetails.tsx +60 -43
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +62 -41
- package/src/anyspend/react/components/common/PaymentMethodSwitch.tsx +38 -0
- package/src/anyspend/react/components/common/TransferCryptoDetails.tsx +65 -43
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +3 -13
- package/dist/cjs/global-account/examples/client-selection-example.d.ts +0 -5
- package/dist/cjs/global-account/examples/client-selection-example.js +0 -96
- package/dist/esm/global-account/examples/client-selection-example.d.ts +0 -5
- package/dist/esm/global-account/examples/client-selection-example.js +0 -93
- package/dist/types/global-account/examples/client-selection-example.d.ts +0 -5
- package/src/global-account/app.d.ts +0 -14
- package/src/global-account/docs/client-selection.md +0 -292
- package/src/global-account/examples/client-selection-example.tsx +0 -197
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
# FeathersJS Client Selection
|
|
2
|
-
|
|
3
|
-
The B3 SDK now supports both Socket.IO and REST clients for communicating with the B3 API. This document explains how to choose and configure the appropriate client type for your application.
|
|
4
|
-
|
|
5
|
-
## Client Types
|
|
6
|
-
|
|
7
|
-
### Socket Client (Default)
|
|
8
|
-
- **Real-time communication** via WebSocket
|
|
9
|
-
- **Lower latency** for frequent updates
|
|
10
|
-
- **Automatic reconnection** on connection loss
|
|
11
|
-
- **Best for**: Interactive applications, real-time features, frequent API calls
|
|
12
|
-
|
|
13
|
-
### REST Client
|
|
14
|
-
- **HTTP-based communication** via REST API
|
|
15
|
-
- **Better for server-side rendering** and static generation
|
|
16
|
-
- **Simpler debugging** and network inspection
|
|
17
|
-
- **Best for**: Static sites, server-side rendering, simple integrations
|
|
18
|
-
|
|
19
|
-
## Configuration
|
|
20
|
-
|
|
21
|
-
### 1. Provider-Level Configuration (Recommended)
|
|
22
|
-
|
|
23
|
-
Configure the client type at the provider level for your entire application:
|
|
24
|
-
|
|
25
|
-
```tsx
|
|
26
|
-
import { B3Provider } from "@b3dotfun/sdk/global-account/react";
|
|
27
|
-
|
|
28
|
-
function App() {
|
|
29
|
-
return (
|
|
30
|
-
<B3Provider
|
|
31
|
-
environment="production"
|
|
32
|
-
clientType="rest" // or "socket"
|
|
33
|
-
// ... other props
|
|
34
|
-
>
|
|
35
|
-
<YourApp />
|
|
36
|
-
</B3Provider>
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### 2. Programmatic Configuration
|
|
42
|
-
|
|
43
|
-
Change the client type at runtime:
|
|
44
|
-
|
|
45
|
-
```tsx
|
|
46
|
-
import { useClient } from "@b3dotfun/sdk/global-account/react";
|
|
47
|
-
|
|
48
|
-
function MyComponent() {
|
|
49
|
-
const { switchClientType, clientType } = useClient();
|
|
50
|
-
|
|
51
|
-
const handleSwitchToRest = () => {
|
|
52
|
-
switchClientType("rest");
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
<div>
|
|
57
|
-
<p>Current client: {clientType}</p>
|
|
58
|
-
<button onClick={handleSwitchToRest}>Switch to REST</button>
|
|
59
|
-
</div>
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### 3. Direct Client Access
|
|
65
|
-
|
|
66
|
-
Access specific client types directly:
|
|
67
|
-
|
|
68
|
-
```tsx
|
|
69
|
-
import { useClient } from "@b3dotfun/sdk/global-account/react";
|
|
70
|
-
|
|
71
|
-
function MyComponent() {
|
|
72
|
-
const { getCurrentClient, getClientByType } = useClient();
|
|
73
|
-
|
|
74
|
-
// Get the currently active client
|
|
75
|
-
const currentClient = getCurrentClient();
|
|
76
|
-
|
|
77
|
-
// Get a specific client type
|
|
78
|
-
const restClient = getClientByType("rest");
|
|
79
|
-
const socketClient = getClientByType("socket");
|
|
80
|
-
|
|
81
|
-
// Use the clients directly
|
|
82
|
-
const data = await currentClient.service("users").find();
|
|
83
|
-
}
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
## Authentication
|
|
87
|
-
|
|
88
|
-
### Single Client Authentication
|
|
89
|
-
|
|
90
|
-
Authenticate with the currently active client:
|
|
91
|
-
|
|
92
|
-
```tsx
|
|
93
|
-
import { useClient } from "@b3dotfun/sdk/global-account/react";
|
|
94
|
-
|
|
95
|
-
function LoginComponent() {
|
|
96
|
-
const { getCurrentClient } = useClient();
|
|
97
|
-
|
|
98
|
-
const handleLogin = async () => {
|
|
99
|
-
const client = getCurrentClient();
|
|
100
|
-
await client.authenticate({
|
|
101
|
-
strategy: "jwt",
|
|
102
|
-
accessToken: "your-token"
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
### Multi-Client Authentication
|
|
109
|
-
|
|
110
|
-
Authenticate with both clients simultaneously (useful for migration scenarios):
|
|
111
|
-
|
|
112
|
-
```tsx
|
|
113
|
-
import { useClient } from "@b3dotfun/sdk/global-account/react";
|
|
114
|
-
|
|
115
|
-
function LoginComponent() {
|
|
116
|
-
const { authenticateWithBoth } = useClient();
|
|
117
|
-
|
|
118
|
-
const handleLogin = async () => {
|
|
119
|
-
const result = await authenticateWithBoth("access-token", "identity-token");
|
|
120
|
-
|
|
121
|
-
if (result.success) {
|
|
122
|
-
console.log("Socket auth:", result.socket);
|
|
123
|
-
console.log("REST auth:", result.rest);
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### Type-Specific Authentication
|
|
130
|
-
|
|
131
|
-
Authenticate with a specific client type:
|
|
132
|
-
|
|
133
|
-
```tsx
|
|
134
|
-
import { useClient } from "@b3dotfun/sdk/global-account/react";
|
|
135
|
-
|
|
136
|
-
function LoginComponent() {
|
|
137
|
-
const { authenticateWithType } = useClient();
|
|
138
|
-
|
|
139
|
-
const handleRestLogin = async () => {
|
|
140
|
-
await authenticateWithType("rest", "access-token", "identity-token");
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
const handleSocketLogin = async () => {
|
|
144
|
-
await authenticateWithType("socket", "access-token", "identity-token");
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
## Migration Guide
|
|
150
|
-
|
|
151
|
-
### From Socket-Only to Client Selection
|
|
152
|
-
|
|
153
|
-
**Before:**
|
|
154
|
-
```tsx
|
|
155
|
-
import app from "@b3dotfun/sdk/global-account/app";
|
|
156
|
-
|
|
157
|
-
// Always used socket client
|
|
158
|
-
const data = await app.service("users").find();
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
**After (Backwards Compatible):**
|
|
162
|
-
```tsx
|
|
163
|
-
import app from "@b3dotfun/sdk/global-account/app";
|
|
164
|
-
|
|
165
|
-
// Still works - defaults to socket client
|
|
166
|
-
const data = await app.service("users").find();
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
**After (Explicit Client Selection):**
|
|
170
|
-
```tsx
|
|
171
|
-
import { B3Provider } from "@b3dotfun/sdk/global-account/react";
|
|
172
|
-
|
|
173
|
-
// Configure at provider level
|
|
174
|
-
<B3Provider clientType="rest">
|
|
175
|
-
<App />
|
|
176
|
-
</B3Provider>
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
### From Direct REST Import
|
|
180
|
-
|
|
181
|
-
**Before:**
|
|
182
|
-
```tsx
|
|
183
|
-
import app from "@b3dotfun/sdk/global-account/app.rest";
|
|
184
|
-
|
|
185
|
-
// Always used REST client
|
|
186
|
-
const data = await app.service("users").find();
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
**After:**
|
|
190
|
-
```tsx
|
|
191
|
-
import { B3Provider } from "@b3dotfun/sdk/global-account/react";
|
|
192
|
-
|
|
193
|
-
// Configure at provider level
|
|
194
|
-
<B3Provider clientType="rest">
|
|
195
|
-
<App />
|
|
196
|
-
</B3Provider>
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
## Best Practices
|
|
200
|
-
|
|
201
|
-
### 1. Choose the Right Client Type
|
|
202
|
-
|
|
203
|
-
- **Use Socket** for: Real-time apps, frequent updates, interactive features
|
|
204
|
-
- **Use REST** for: Static sites, SSR, simple integrations, debugging
|
|
205
|
-
|
|
206
|
-
### 2. Consistent Client Usage
|
|
207
|
-
|
|
208
|
-
- Set the client type once at the provider level
|
|
209
|
-
- Avoid mixing client types within the same app unless necessary
|
|
210
|
-
- Use the `useClient` hook for runtime client access
|
|
211
|
-
|
|
212
|
-
### 3. Error Handling
|
|
213
|
-
|
|
214
|
-
```tsx
|
|
215
|
-
import { useClient } from "@b3dotfun/sdk/global-account/react";
|
|
216
|
-
|
|
217
|
-
function MyComponent() {
|
|
218
|
-
const { getCurrentClient } = useClient();
|
|
219
|
-
|
|
220
|
-
const fetchData = async () => {
|
|
221
|
-
try {
|
|
222
|
-
const client = getCurrentClient();
|
|
223
|
-
const data = await client.service("users").find();
|
|
224
|
-
return data;
|
|
225
|
-
} catch (error) {
|
|
226
|
-
console.error("API call failed:", error);
|
|
227
|
-
// Handle error appropriately
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
### 4. Performance Considerations
|
|
234
|
-
|
|
235
|
-
- Socket clients maintain persistent connections
|
|
236
|
-
- REST clients make individual HTTP requests
|
|
237
|
-
- Consider your app's communication patterns when choosing
|
|
238
|
-
|
|
239
|
-
## Troubleshooting
|
|
240
|
-
|
|
241
|
-
### Common Issues
|
|
242
|
-
|
|
243
|
-
1. **Client Type Not Switching**
|
|
244
|
-
- Ensure you're calling `switchClientType` after the provider is mounted
|
|
245
|
-
- Check that the provider has the correct `clientType` prop
|
|
246
|
-
|
|
247
|
-
2. **Authentication Failures**
|
|
248
|
-
- Verify the client type matches your authentication strategy
|
|
249
|
-
- Check that tokens are valid for the selected client type
|
|
250
|
-
|
|
251
|
-
3. **Connection Issues**
|
|
252
|
-
- For socket clients: Check WebSocket connectivity
|
|
253
|
-
- For REST clients: Verify HTTP endpoints are accessible
|
|
254
|
-
|
|
255
|
-
### Debug Information
|
|
256
|
-
|
|
257
|
-
```tsx
|
|
258
|
-
import { useClient } from "@b3dotfun/sdk/global-account/react";
|
|
259
|
-
|
|
260
|
-
function DebugComponent() {
|
|
261
|
-
const { clientType, getCurrentClient } = useClient();
|
|
262
|
-
|
|
263
|
-
console.log("Current client type:", clientType);
|
|
264
|
-
console.log("Current client:", getCurrentClient());
|
|
265
|
-
}
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
## API Reference
|
|
269
|
-
|
|
270
|
-
### B3Provider Props
|
|
271
|
-
|
|
272
|
-
```tsx
|
|
273
|
-
interface B3ProviderProps {
|
|
274
|
-
clientType?: "socket" | "rest"; // Default: "socket"
|
|
275
|
-
// ... other props
|
|
276
|
-
}
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
### useClient Hook
|
|
280
|
-
|
|
281
|
-
```tsx
|
|
282
|
-
interface UseClientReturn {
|
|
283
|
-
clientType: "socket" | "rest";
|
|
284
|
-
getCurrentClient: () => ClientApplication;
|
|
285
|
-
getClientByType: (type: ClientType) => ClientApplication;
|
|
286
|
-
switchClientType: (type: ClientType) => void;
|
|
287
|
-
authenticateWithType: (type: ClientType, accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<any>;
|
|
288
|
-
authenticateWithBoth: (accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<{socket: any, rest: any, success: boolean}>;
|
|
289
|
-
}
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import { B3Provider, useB3, useClient } from "@b3dotfun/sdk/global-account/react";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import { ClientType } from "../client-manager";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Example component showing how to use the client selection system
|
|
7
|
-
*/
|
|
8
|
-
function ClientSelectionExample() {
|
|
9
|
-
const { clientType, switchClientType, getCurrentClient, authenticateWithType } = useClient();
|
|
10
|
-
const { user } = useB3();
|
|
11
|
-
const [data, setData] = useState<any>(null);
|
|
12
|
-
const [loading, setLoading] = useState(false);
|
|
13
|
-
|
|
14
|
-
const handleSwitchClient = (type: ClientType) => {
|
|
15
|
-
switchClientType(type);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const handleFetchData = async () => {
|
|
19
|
-
setLoading(true);
|
|
20
|
-
try {
|
|
21
|
-
const client = getCurrentClient();
|
|
22
|
-
const result = await client.service("users").find();
|
|
23
|
-
setData(result);
|
|
24
|
-
} catch (error) {
|
|
25
|
-
console.error("Failed to fetch data:", error);
|
|
26
|
-
} finally {
|
|
27
|
-
setLoading(false);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const handleAuthenticateWithType = async (type: ClientType) => {
|
|
32
|
-
try {
|
|
33
|
-
const result = await authenticateWithType(
|
|
34
|
-
type,
|
|
35
|
-
"your-access-token",
|
|
36
|
-
"your-identity-token"
|
|
37
|
-
);
|
|
38
|
-
console.log(`Authenticated with ${type}:`, result);
|
|
39
|
-
} catch (error) {
|
|
40
|
-
console.error(`Authentication failed with ${type}:`, error);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<div style={{ padding: "20px", fontFamily: "Arial, sans-serif" }}>
|
|
46
|
-
<h2>Client Selection Example</h2>
|
|
47
|
-
|
|
48
|
-
<div style={{ marginBottom: "20px" }}>
|
|
49
|
-
<h3>Current Client Type: {clientType}</h3>
|
|
50
|
-
<div style={{ display: "flex", gap: "10px", marginBottom: "10px" }}>
|
|
51
|
-
<button
|
|
52
|
-
onClick={() => handleSwitchClient("socket")}
|
|
53
|
-
style={{
|
|
54
|
-
padding: "8px 16px",
|
|
55
|
-
backgroundColor: clientType === "socket" ? "#007bff" : "#f8f9fa",
|
|
56
|
-
color: clientType === "socket" ? "white" : "black",
|
|
57
|
-
border: "1px solid #007bff",
|
|
58
|
-
borderRadius: "4px",
|
|
59
|
-
cursor: "pointer"
|
|
60
|
-
}}
|
|
61
|
-
>
|
|
62
|
-
Switch to Socket
|
|
63
|
-
</button>
|
|
64
|
-
<button
|
|
65
|
-
onClick={() => handleSwitchClient("rest")}
|
|
66
|
-
style={{
|
|
67
|
-
padding: "8px 16px",
|
|
68
|
-
backgroundColor: clientType === "rest" ? "#007bff" : "#f8f9fa",
|
|
69
|
-
color: clientType === "rest" ? "white" : "black",
|
|
70
|
-
border: "1px solid #007bff",
|
|
71
|
-
borderRadius: "4px",
|
|
72
|
-
cursor: "pointer"
|
|
73
|
-
}}
|
|
74
|
-
>
|
|
75
|
-
Switch to REST
|
|
76
|
-
</button>
|
|
77
|
-
</div>
|
|
78
|
-
</div>
|
|
79
|
-
|
|
80
|
-
<div style={{ marginBottom: "20px" }}>
|
|
81
|
-
<h3>Test API Calls</h3>
|
|
82
|
-
<button
|
|
83
|
-
onClick={handleFetchData}
|
|
84
|
-
disabled={loading}
|
|
85
|
-
style={{
|
|
86
|
-
padding: "8px 16px",
|
|
87
|
-
backgroundColor: "#28a745",
|
|
88
|
-
color: "white",
|
|
89
|
-
border: "none",
|
|
90
|
-
borderRadius: "4px",
|
|
91
|
-
cursor: loading ? "not-allowed" : "pointer"
|
|
92
|
-
}}
|
|
93
|
-
>
|
|
94
|
-
{loading ? "Loading..." : "Fetch Data"}
|
|
95
|
-
</button>
|
|
96
|
-
|
|
97
|
-
{data && (
|
|
98
|
-
<pre style={{
|
|
99
|
-
marginTop: "10px",
|
|
100
|
-
padding: "10px",
|
|
101
|
-
backgroundColor: "#f8f9fa",
|
|
102
|
-
borderRadius: "4px",
|
|
103
|
-
overflow: "auto"
|
|
104
|
-
}}>
|
|
105
|
-
{JSON.stringify(data, null, 2)}
|
|
106
|
-
</pre>
|
|
107
|
-
)}
|
|
108
|
-
</div>
|
|
109
|
-
|
|
110
|
-
<div style={{ marginBottom: "20px" }}>
|
|
111
|
-
<h3>Authentication Tests</h3>
|
|
112
|
-
<div style={{ display: "flex", gap: "10px" }}>
|
|
113
|
-
<button
|
|
114
|
-
onClick={() => handleAuthenticateWithType("socket")}
|
|
115
|
-
style={{
|
|
116
|
-
padding: "8px 16px",
|
|
117
|
-
backgroundColor: "#17a2b8",
|
|
118
|
-
color: "white",
|
|
119
|
-
border: "none",
|
|
120
|
-
borderRadius: "4px",
|
|
121
|
-
cursor: "pointer"
|
|
122
|
-
}}
|
|
123
|
-
>
|
|
124
|
-
Auth with Socket
|
|
125
|
-
</button>
|
|
126
|
-
<button
|
|
127
|
-
onClick={() => handleAuthenticateWithType("rest")}
|
|
128
|
-
style={{
|
|
129
|
-
padding: "8px 16px",
|
|
130
|
-
backgroundColor: "#17a2b8",
|
|
131
|
-
color: "white",
|
|
132
|
-
border: "none",
|
|
133
|
-
borderRadius: "4px",
|
|
134
|
-
cursor: "pointer"
|
|
135
|
-
}}
|
|
136
|
-
>
|
|
137
|
-
Auth with REST
|
|
138
|
-
</button>
|
|
139
|
-
</div>
|
|
140
|
-
</div>
|
|
141
|
-
|
|
142
|
-
<div>
|
|
143
|
-
<h3>User Status</h3>
|
|
144
|
-
<p>Authenticated: {user ? "Yes" : "No"}</p>
|
|
145
|
-
{user && (
|
|
146
|
-
<pre style={{
|
|
147
|
-
padding: "10px",
|
|
148
|
-
backgroundColor: "#f8f9fa",
|
|
149
|
-
borderRadius: "4px",
|
|
150
|
-
overflow: "auto"
|
|
151
|
-
}}>
|
|
152
|
-
{JSON.stringify(user, null, 2)}
|
|
153
|
-
</pre>
|
|
154
|
-
)}
|
|
155
|
-
</div>
|
|
156
|
-
</div>
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Example app showing different client configurations
|
|
162
|
-
*/
|
|
163
|
-
export function ClientSelectionApp() {
|
|
164
|
-
const [clientType, setClientType] = useState<ClientType>("socket");
|
|
165
|
-
|
|
166
|
-
return (
|
|
167
|
-
<B3Provider
|
|
168
|
-
environment="development"
|
|
169
|
-
clientType={clientType}
|
|
170
|
-
automaticallySetFirstEoa={true}
|
|
171
|
-
theme="light"
|
|
172
|
-
>
|
|
173
|
-
<div>
|
|
174
|
-
<h1>B3 SDK Client Selection Demo</h1>
|
|
175
|
-
|
|
176
|
-
<div style={{ marginBottom: "20px" }}>
|
|
177
|
-
<label>
|
|
178
|
-
<strong>Provider Client Type:</strong>
|
|
179
|
-
<select
|
|
180
|
-
value={clientType}
|
|
181
|
-
onChange={(e) => setClientType(e.target.value as ClientType)}
|
|
182
|
-
style={{ marginLeft: "10px", padding: "4px 8px" }}
|
|
183
|
-
>
|
|
184
|
-
<option value="socket">Socket (Default)</option>
|
|
185
|
-
<option value="rest">REST</option>
|
|
186
|
-
</select>
|
|
187
|
-
</label>
|
|
188
|
-
</div>
|
|
189
|
-
|
|
190
|
-
<ClientSelectionExample />
|
|
191
|
-
</div>
|
|
192
|
-
</B3Provider>
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
export default ClientSelectionApp;
|
|
197
|
-
|