@bytexbyte/nxtlinq-ai-agent-sdk 1.5.7 → 1.5.9
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 +75 -3
- package/dist/api/nxtlinq-api.d.ts.map +1 -1
- package/dist/api/nxtlinq-api.js +1 -4
- package/dist/components/ChatBot.d.ts.map +1 -1
- package/dist/components/ChatBot.js +6 -3
- package/dist/components/context/ChatBotContext.d.ts.map +1 -1
- package/dist/components/context/ChatBotContext.js +107 -12
- package/dist/components/types/ChatBotTypes.d.ts +6 -2
- package/dist/components/types/ChatBotTypes.d.ts.map +1 -1
- package/dist/components/ui/BerifyMeModal.d.ts +1 -0
- package/dist/components/ui/BerifyMeModal.d.ts.map +1 -1
- package/dist/components/ui/BerifyMeModal.js +32 -25
- package/dist/components/ui/ChatBotUI.d.ts.map +1 -1
- package/dist/components/ui/ChatBotUI.js +27 -8
- package/dist/components/ui/PermissionForm.js +1 -1
- package/dist/core/utils/__tests__/urlUtils.test.d.ts +5 -0
- package/dist/core/utils/__tests__/urlUtils.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/urlUtils.test.js +57 -0
- package/dist/core/utils/berifyMeReactFix.d.ts +8 -0
- package/dist/core/utils/berifyMeReactFix.d.ts.map +1 -0
- package/dist/core/utils/berifyMeReactFix.js +81 -0
- package/dist/core/utils/reactInstanceCheck.d.ts +9 -0
- package/dist/core/utils/reactInstanceCheck.d.ts.map +1 -0
- package/dist/core/utils/reactInstanceCheck.js +46 -0
- package/dist/setupTests.d.ts +2 -0
- package/dist/setupTests.d.ts.map +1 -0
- package/dist/setupTests.js +16 -0
- package/dist/types/ait-api.d.ts +3 -1
- package/dist/types/ait-api.d.ts.map +1 -1
- package/package.json +2 -2
- package/umd/nxtlinq-ai-agent.umd.js +19 -19
package/README.md
CHANGED
|
@@ -9,6 +9,8 @@ A comprehensive SDK for integrating AI agents with wallet verification capabilit
|
|
|
9
9
|
- 🎨 Customizable UI components
|
|
10
10
|
- 🔧 Tool integration support
|
|
11
11
|
- 📱 Responsive design
|
|
12
|
+
- 👤 Custom user identity support
|
|
13
|
+
- ⏰ Configurable banner dismiss duration
|
|
12
14
|
|
|
13
15
|
## Installation
|
|
14
16
|
|
|
@@ -120,6 +122,10 @@ If you want to allow users to set AIT permissions without wallet verification, y
|
|
|
120
122
|
|
|
121
123
|
✅ **Smart Suggestion Banner**: When verification is optional, shows helpful suggestion banner with 1-second delay to prevent flashing
|
|
122
124
|
|
|
125
|
+
✅ **Custom User Identity**: Support for custom usernames and flexible user information objects
|
|
126
|
+
|
|
127
|
+
✅ **Configurable Banner Duration**: Customize how long the IDV suggestion banner stays hidden after dismissal
|
|
128
|
+
|
|
123
129
|
## Configuration Options
|
|
124
130
|
|
|
125
131
|
### Built-in BerifyMe Support
|
|
@@ -130,6 +136,13 @@ The built-in BerifyMe support requires no configuration - it automatically redir
|
|
|
130
136
|
| Property | Type | Default | Description |
|
|
131
137
|
|----------|------|---------|-------------|
|
|
132
138
|
| `requireWalletIDVVerification` | `boolean` | `true` | Whether to check wallet IDV verification status before AIT operations |
|
|
139
|
+
| `customUsername` | `string` | - | Custom username for wallet verification when using custom method |
|
|
140
|
+
| `idvBannerDismissSeconds` | `number` | `86400` | Seconds to hide IDV suggestion banner after user dismisses it (default: 24 hours) |
|
|
141
|
+
|
|
142
|
+
**User Identity Options:**
|
|
143
|
+
| Property | Type | Default | Description |
|
|
144
|
+
|----------|------|---------|-------------|
|
|
145
|
+
| `customUserInfo` | `Record<string, any>` | - | Custom user identity information object for backend processing |
|
|
133
146
|
|
|
134
147
|
### Configuration Examples
|
|
135
148
|
|
|
@@ -156,6 +169,35 @@ The built-in BerifyMe support requires no configuration - it automatically redir
|
|
|
156
169
|
/>
|
|
157
170
|
```
|
|
158
171
|
|
|
172
|
+
#### Custom User Identity
|
|
173
|
+
```tsx
|
|
174
|
+
<ChatBot
|
|
175
|
+
serviceId="your-service-id"
|
|
176
|
+
apiKey="your-api-key"
|
|
177
|
+
apiSecret="your-api-secret"
|
|
178
|
+
requireWalletIDVVerification={false}
|
|
179
|
+
customUsername="john.doe"
|
|
180
|
+
customUserInfo={{
|
|
181
|
+
corpId: "CORP-001",
|
|
182
|
+
department: "Engineering",
|
|
183
|
+
role: "Developer"
|
|
184
|
+
}}
|
|
185
|
+
// Custom user identity information for backend processing
|
|
186
|
+
/>
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
#### Custom Banner Dismiss Duration
|
|
190
|
+
```tsx
|
|
191
|
+
<ChatBot
|
|
192
|
+
serviceId="your-service-id"
|
|
193
|
+
apiKey="your-api-key"
|
|
194
|
+
apiSecret="your-api-secret"
|
|
195
|
+
requireWalletIDVVerification={false}
|
|
196
|
+
idvBannerDismissSeconds={3600} // Hide banner for 1 hour (3600 seconds)
|
|
197
|
+
// Customize how long the IDV suggestion banner stays hidden
|
|
198
|
+
/>
|
|
199
|
+
```
|
|
200
|
+
|
|
159
201
|
## Advanced Features
|
|
160
202
|
|
|
161
203
|
### IDV Suggestion Banner
|
|
@@ -163,17 +205,47 @@ The built-in BerifyMe support requires no configuration - it automatically redir
|
|
|
163
205
|
When `requireWalletIDVVerification: false`, the SDK shows a helpful suggestion banner for unverified wallets:
|
|
164
206
|
|
|
165
207
|
- **Smart Timing**: 1-second delay prevents flashing during wallet connection
|
|
166
|
-
- **
|
|
208
|
+
- **Configurable Dismissal**: Users can dismiss the banner for a customizable duration (default: 24 hours)
|
|
167
209
|
- **Persistent State**: Dismissal preference is saved in localStorage
|
|
168
210
|
- **Responsive Design**: Banner adapts to different screen sizes
|
|
211
|
+
- **User-Friendly Display**: Shows time in hours/minutes format (e.g., "24h" or "1h 30m")
|
|
212
|
+
- **Flexible Configuration**: Set custom dismiss duration in seconds via `idvBannerDismissSeconds`
|
|
213
|
+
|
|
214
|
+
### Custom User Identity
|
|
215
|
+
|
|
216
|
+
The SDK supports flexible user identity information for enhanced backend processing:
|
|
217
|
+
|
|
218
|
+
- **Custom Username**: Set a custom username for wallet verification using the `custom` method
|
|
219
|
+
- **Flexible User Info**: Pass additional user data via `customUserInfo` object for backend processing
|
|
220
|
+
- **Backend Integration**: Custom identity information is sent to the AIT Service for processing
|
|
221
|
+
- **Optional Parameters**: Both `customUsername` and `customUserInfo` are optional
|
|
222
|
+
|
|
223
|
+
**Example Usage:**
|
|
224
|
+
```tsx
|
|
225
|
+
<ChatBot
|
|
226
|
+
serviceId="your-service-id"
|
|
227
|
+
apiKey="your-api-key"
|
|
228
|
+
apiSecret="your-api-secret"
|
|
229
|
+
requireWalletIDVVerification={false}
|
|
230
|
+
customUsername="employee-123"
|
|
231
|
+
customUserInfo={{
|
|
232
|
+
corpId: "COMPANY-001",
|
|
233
|
+
department: "Sales",
|
|
234
|
+
region: "Asia-Pacific",
|
|
235
|
+
accessLevel: "premium"
|
|
236
|
+
}}
|
|
237
|
+
// Custom user identity information sent to backend for processing
|
|
238
|
+
/>
|
|
239
|
+
```
|
|
169
240
|
|
|
170
241
|
### Wallet Connection Flow
|
|
171
242
|
|
|
172
243
|
1. **Connect Wallet**: User connects their wallet
|
|
173
244
|
2. **Sign In**: User signs in with wallet (if required)
|
|
174
245
|
3. **Verification Check**: SDK checks if wallet is verified
|
|
175
|
-
4. **
|
|
176
|
-
5. **
|
|
246
|
+
4. **Custom Identity**: If `customUsername` is provided and `requireWalletIDVVerification: false`, create wallet with custom method
|
|
247
|
+
5. **Conditional Banner**: If verification is optional and wallet is unverified, show suggestion banner
|
|
248
|
+
6. **User Choice**: User can verify wallet or continue without verification
|
|
177
249
|
|
|
178
250
|
## Support
|
|
179
251
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nxtlinq-api.d.ts","sourceRoot":"","sources":["../../src/api/nxtlinq-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"nxtlinq-api.d.ts","sourceRoot":"","sources":["../../src/api/nxtlinq-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAgW1C,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,EAAE,WAAW,MAAM,KAAG,MAUpE,CAAC"}
|
package/dist/api/nxtlinq-api.js
CHANGED
|
@@ -76,10 +76,6 @@ const createAgentApi = () => ({
|
|
|
76
76
|
const walletAddress = localStorage.getItem('walletAddress');
|
|
77
77
|
const aitTokenRaw = localStorage.getItem('nxtlinqAITServiceAccessToken');
|
|
78
78
|
const aitToken = aitTokenRaw ? JSON.parse(aitTokenRaw) : null;
|
|
79
|
-
console.log('=== SDK sendMessage AIT Info ===');
|
|
80
|
-
console.log('Wallet Address:', walletAddress);
|
|
81
|
-
console.log('AIT Token Raw:', aitTokenRaw);
|
|
82
|
-
console.log('AIT Token Parsed:', aitToken);
|
|
83
79
|
const response = await fetch(`${AI_AGENT_API_HOST}/api/${model}`, {
|
|
84
80
|
method: 'POST',
|
|
85
81
|
headers: {
|
|
@@ -92,6 +88,7 @@ const createAgentApi = () => ({
|
|
|
92
88
|
apiSecret: params.apiSecret,
|
|
93
89
|
pseudoId: params.pseudoId,
|
|
94
90
|
externalId: params.externalId,
|
|
91
|
+
customUserInfo: params.customUserInfo,
|
|
95
92
|
message: params.message,
|
|
96
93
|
walletAddress: walletAddress || undefined,
|
|
97
94
|
aitToken: aitToken || undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBot.d.ts","sourceRoot":"","sources":["../../src/components/ChatBot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIpD,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"ChatBot.d.ts","sourceRoot":"","sources":["../../src/components/ChatBot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIpD,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAqD1C,CAAC;AAEF,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -7,7 +7,6 @@ export const ChatBot = (props) => {
|
|
|
7
7
|
const [isBerifyMeModalOpen, setIsBerifyMeModalOpen] = React.useState(false);
|
|
8
8
|
// Handle wallet verification
|
|
9
9
|
const handleVerifyWallet = async () => {
|
|
10
|
-
// Built-in BerifyMe support is always available
|
|
11
10
|
// Check if token already exists in URL
|
|
12
11
|
const urlParams = new URLSearchParams(window.location.search);
|
|
13
12
|
const token = urlParams.get('token');
|
|
@@ -15,7 +14,11 @@ export const ChatBot = (props) => {
|
|
|
15
14
|
console.log('Token found in URL, returning it');
|
|
16
15
|
return Promise.resolve({ token });
|
|
17
16
|
}
|
|
18
|
-
//
|
|
17
|
+
// Use external onVerifyWallet if provided and in external mode
|
|
18
|
+
if (props.berifymeMode === 'external' && props.onVerifyWallet) {
|
|
19
|
+
return props.onVerifyWallet();
|
|
20
|
+
}
|
|
21
|
+
// Built-in mode: Open built-in BerifyMe modal
|
|
19
22
|
setIsBerifyMeModalOpen(true);
|
|
20
23
|
return;
|
|
21
24
|
};
|
|
@@ -29,5 +32,5 @@ export const ChatBot = (props) => {
|
|
|
29
32
|
...props,
|
|
30
33
|
onVerifyWallet: handleVerifyWallet
|
|
31
34
|
};
|
|
32
|
-
return (_jsxs(_Fragment, { children: [_jsx(ChatBotProvider, { ...enhancedProps, children: _jsx(ChatBotUI, {}) }), _jsx(BerifyMeModal, { isOpen: isBerifyMeModalOpen, onClose: () => setIsBerifyMeModalOpen(false), onVerificationComplete: handleBerifyMeComplete })] }));
|
|
35
|
+
return (_jsxs(_Fragment, { children: [_jsx(ChatBotProvider, { ...enhancedProps, children: _jsx(ChatBotUI, {}) }), props.berifymeMode !== 'external' && (_jsx(BerifyMeModal, { isOpen: isBerifyMeModalOpen, onClose: () => setIsBerifyMeModalOpen(false), onVerificationComplete: handleBerifyMeComplete, mode: props.berifymeMode || 'built-in' }))] }));
|
|
33
36
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBotContext.d.ts","sourceRoot":"","sources":["../../../src/components/context/ChatBotContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAS/B,OAAO,EACL,kBAAkB,EAClB,YAAY,EAGb,MAAM,uBAAuB,CAAC;AAI/B,eAAO,MAAM,UAAU,0BAMtB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"ChatBotContext.d.ts","sourceRoot":"","sources":["../../../src/components/context/ChatBotContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAS/B,OAAO,EACL,kBAAkB,EAClB,YAAY,EAGb,MAAM,uBAAuB,CAAC;AAI/B,eAAO,MAAM,UAAU,0BAMtB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAs4DlD,CAAC"}
|
|
@@ -24,7 +24,14 @@ availableModels = DEFAULT_AI_MODELS, defaultModelIndex = 0, showModelSelector =
|
|
|
24
24
|
// Storage mode configuration
|
|
25
25
|
useSessionStorage: useSessionStorageMode = false,
|
|
26
26
|
// Wallet verification configuration
|
|
27
|
-
requireWalletIDVVerification = true, isSemiAutomaticMode = false
|
|
27
|
+
requireWalletIDVVerification = true, isSemiAutomaticMode = false,
|
|
28
|
+
// Custom user identity information
|
|
29
|
+
customUserInfo,
|
|
30
|
+
// Custom username for wallet verification
|
|
31
|
+
customUsername,
|
|
32
|
+
// IDV suggestion banner configuration
|
|
33
|
+
idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
34
|
+
}) => {
|
|
28
35
|
const nxtlinqApi = React.useMemo(() => createNxtlinqApi(apiKey, apiSecret), [apiKey, apiSecret]);
|
|
29
36
|
// Custom hook
|
|
30
37
|
const { isRecording, transcript, start: startRecording, stop: stopRecording } = useSpeechToTextFromMic({
|
|
@@ -294,6 +301,36 @@ requireWalletIDVVerification = true, isSemiAutomaticMode = false }) => {
|
|
|
294
301
|
setNxtlinqAITServiceAccessToken('');
|
|
295
302
|
}
|
|
296
303
|
}
|
|
304
|
+
// If requireIDV is false and we have customUsername, check if wallet exists in AIT Service
|
|
305
|
+
if (!requireWalletIDVVerification && customUsername) {
|
|
306
|
+
try {
|
|
307
|
+
// Check if wallet exists in AIT Service
|
|
308
|
+
const walletResponse = await nxtlinqApi.wallet.getWallet({ address: userAddress }, '');
|
|
309
|
+
if ('error' in walletResponse) {
|
|
310
|
+
// Wallet doesn't exist, create it with custom method
|
|
311
|
+
console.log('Wallet not found in AIT Service, creating with custom method...');
|
|
312
|
+
const verifyPayload = {
|
|
313
|
+
address: userAddress,
|
|
314
|
+
method: 'custom',
|
|
315
|
+
timestamp: Date.now(),
|
|
316
|
+
customUsername: customUsername
|
|
317
|
+
};
|
|
318
|
+
const verifyResponse = await nxtlinqApi.wallet.verifyWallet(verifyPayload, '');
|
|
319
|
+
if ('error' in verifyResponse) {
|
|
320
|
+
console.error('Failed to create wallet with custom method:', verifyResponse.error);
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
console.log('Successfully created wallet with custom method');
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
console.log('Wallet already exists in AIT Service');
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
catch (error) {
|
|
331
|
+
console.error('Error checking/creating wallet in AIT Service:', error);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
297
334
|
if (autoShowSignInMessage) {
|
|
298
335
|
if (isNeedSignInWithWallet) {
|
|
299
336
|
setMessages(prev => [...prev, {
|
|
@@ -320,7 +357,7 @@ requireWalletIDVVerification = true, isSemiAutomaticMode = false }) => {
|
|
|
320
357
|
}
|
|
321
358
|
return false; // Return false on failure
|
|
322
359
|
}
|
|
323
|
-
}, [nxtlinqAITServiceAccessToken, refreshAIT, isNeedSignInWithWallet]);
|
|
360
|
+
}, [nxtlinqAITServiceAccessToken, refreshAIT, isNeedSignInWithWallet, requireWalletIDVVerification, customUsername, nxtlinqApi]);
|
|
324
361
|
// Sign in wallet
|
|
325
362
|
const signInWallet = async (autoShowSuccessMessage = true) => {
|
|
326
363
|
// Use refs to get latest state values for consistency with hasPermission
|
|
@@ -846,6 +883,7 @@ requireWalletIDVVerification = true, isSemiAutomaticMode = false }) => {
|
|
|
846
883
|
apiSecret,
|
|
847
884
|
pseudoId: pseudoId,
|
|
848
885
|
externalId: localStorage.getItem('walletAddress') || undefined,
|
|
886
|
+
customUserInfo,
|
|
849
887
|
message: content,
|
|
850
888
|
});
|
|
851
889
|
if ('error' in response || response.result === 'error') {
|
|
@@ -1412,14 +1450,19 @@ requireWalletIDVVerification = true, isSemiAutomaticMode = false }) => {
|
|
|
1412
1450
|
}
|
|
1413
1451
|
};
|
|
1414
1452
|
// Handle verify wallet click
|
|
1415
|
-
const handleVerifyWalletClick = async () => {
|
|
1453
|
+
const handleVerifyWalletClick = async (method) => {
|
|
1416
1454
|
if (!hitAddress) {
|
|
1417
1455
|
showError('Please connect your wallet first.');
|
|
1418
1456
|
return;
|
|
1419
1457
|
}
|
|
1420
1458
|
try {
|
|
1421
|
-
|
|
1422
|
-
|
|
1459
|
+
setIsLoading(true);
|
|
1460
|
+
if (method === 'berifyme') {
|
|
1461
|
+
if (!onVerifyWallet) {
|
|
1462
|
+
showError('Berify.me verification is not available. Please provide onVerifyWallet callback.');
|
|
1463
|
+
setIsLoading(false);
|
|
1464
|
+
return;
|
|
1465
|
+
}
|
|
1423
1466
|
const result = await onVerifyWallet();
|
|
1424
1467
|
if (!result) {
|
|
1425
1468
|
setIsLoading(false);
|
|
@@ -1438,6 +1481,7 @@ requireWalletIDVVerification = true, isSemiAutomaticMode = false }) => {
|
|
|
1438
1481
|
const verifyWalletResponse = await nxtlinqApi.wallet.verifyWallet({ ...payload }, token);
|
|
1439
1482
|
if ('error' in verifyWalletResponse) {
|
|
1440
1483
|
if (verifyWalletResponse.error === 'Wallet already exists') {
|
|
1484
|
+
// Wallet already exists with the same method, just refresh AIT
|
|
1441
1485
|
setIsWalletLoading(true);
|
|
1442
1486
|
try {
|
|
1443
1487
|
const walletResponse = await nxtlinqApi.wallet.getWallet({ address }, token);
|
|
@@ -1523,6 +1567,54 @@ requireWalletIDVVerification = true, isSemiAutomaticMode = false }) => {
|
|
|
1523
1567
|
setIsLoading(false);
|
|
1524
1568
|
return;
|
|
1525
1569
|
}
|
|
1570
|
+
if (method === 'custom') {
|
|
1571
|
+
if (!customUsername) {
|
|
1572
|
+
showError('Custom username is required for custom verification method.');
|
|
1573
|
+
setIsLoading(false);
|
|
1574
|
+
return;
|
|
1575
|
+
}
|
|
1576
|
+
const payload = {
|
|
1577
|
+
address: hitAddress,
|
|
1578
|
+
method: 'custom',
|
|
1579
|
+
timestamp: Date.now(),
|
|
1580
|
+
customUsername: customUsername
|
|
1581
|
+
};
|
|
1582
|
+
try {
|
|
1583
|
+
const verifyWalletResponse = await nxtlinqApi.wallet.verifyWallet(payload, '');
|
|
1584
|
+
if ('error' in verifyWalletResponse) {
|
|
1585
|
+
if (verifyWalletResponse.error === 'Wallet already exists') {
|
|
1586
|
+
// Wallet already exists with the same method, just refresh AIT
|
|
1587
|
+
await refreshAIT();
|
|
1588
|
+
setIsLoading(false);
|
|
1589
|
+
showSuccess('Wallet verification completed successfully! Your wallet is now verified and ready to use.');
|
|
1590
|
+
return;
|
|
1591
|
+
}
|
|
1592
|
+
// Handle specific error messages
|
|
1593
|
+
if (verifyWalletResponse.error === 'Cannot downgrade from Berify.me verification to custom verification') {
|
|
1594
|
+
showError('This wallet is already verified with Berify.me. Custom verification cannot override Berify.me verification.');
|
|
1595
|
+
}
|
|
1596
|
+
else {
|
|
1597
|
+
showError(verifyWalletResponse.error);
|
|
1598
|
+
}
|
|
1599
|
+
setIsLoading(false);
|
|
1600
|
+
return;
|
|
1601
|
+
}
|
|
1602
|
+
// Successfully created wallet with custom method
|
|
1603
|
+
await refreshAIT();
|
|
1604
|
+
setIsLoading(false);
|
|
1605
|
+
showSuccess('Wallet verification completed successfully! Your wallet is now verified and ready to use.');
|
|
1606
|
+
return;
|
|
1607
|
+
}
|
|
1608
|
+
catch (error) {
|
|
1609
|
+
console.error('Custom wallet verification failed:', error);
|
|
1610
|
+
showError('Failed to verify wallet with custom method. Please try again.');
|
|
1611
|
+
setIsLoading(false);
|
|
1612
|
+
return;
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
// If we reach here, the method is not supported
|
|
1616
|
+
showError(`Unsupported verification method: ${method}`);
|
|
1617
|
+
setIsLoading(false);
|
|
1526
1618
|
}
|
|
1527
1619
|
catch (error) {
|
|
1528
1620
|
console.error('Failed to verify wallet:', error);
|
|
@@ -1531,7 +1623,6 @@ requireWalletIDVVerification = true, isSemiAutomaticMode = false }) => {
|
|
|
1531
1623
|
throw error;
|
|
1532
1624
|
}
|
|
1533
1625
|
};
|
|
1534
|
-
// Effects
|
|
1535
1626
|
React.useEffect(() => {
|
|
1536
1627
|
if (hitAddress && nxtlinqAITServiceAccessToken) {
|
|
1537
1628
|
refreshAIT();
|
|
@@ -1546,7 +1637,7 @@ requireWalletIDVVerification = true, isSemiAutomaticMode = false }) => {
|
|
|
1546
1637
|
const urlParams = new URLSearchParams(window.location.search);
|
|
1547
1638
|
const token = urlParams.get('token');
|
|
1548
1639
|
if (token && hitAddress) {
|
|
1549
|
-
handleVerifyWalletClick();
|
|
1640
|
+
handleVerifyWalletClick('berifyme');
|
|
1550
1641
|
}
|
|
1551
1642
|
}
|
|
1552
1643
|
catch (e) {
|
|
@@ -1565,23 +1656,24 @@ requireWalletIDVVerification = true, isSemiAutomaticMode = false }) => {
|
|
|
1565
1656
|
return;
|
|
1566
1657
|
}
|
|
1567
1658
|
const updateExternalId = async () => {
|
|
1659
|
+
const externalId = hitAddress;
|
|
1568
1660
|
await nxtlinqApi.agent.updateMessagesExternalIdByPseudoId({
|
|
1569
1661
|
apiKey,
|
|
1570
1662
|
apiSecret,
|
|
1571
1663
|
pseudoId,
|
|
1572
|
-
externalId:
|
|
1664
|
+
externalId: externalId,
|
|
1573
1665
|
});
|
|
1574
1666
|
await nxtlinqApi.agent.cloneUserProfileByPseudoId({
|
|
1575
1667
|
apiKey,
|
|
1576
1668
|
apiSecret,
|
|
1577
1669
|
pseudoId,
|
|
1578
|
-
externalId:
|
|
1670
|
+
externalId: externalId,
|
|
1579
1671
|
});
|
|
1580
1672
|
await nxtlinqApi.agent.cloneUserTopicByPseudoId({
|
|
1581
1673
|
apiKey,
|
|
1582
1674
|
apiSecret,
|
|
1583
1675
|
pseudoId,
|
|
1584
|
-
externalId:
|
|
1676
|
+
externalId: externalId,
|
|
1585
1677
|
});
|
|
1586
1678
|
};
|
|
1587
1679
|
updateExternalId();
|
|
@@ -1650,7 +1742,7 @@ requireWalletIDVVerification = true, isSemiAutomaticMode = false }) => {
|
|
|
1650
1742
|
onConnectWallet: () => connectWallet(false),
|
|
1651
1743
|
onSignIn: () => signInWallet(false),
|
|
1652
1744
|
isNeedSignInWithWallet,
|
|
1653
|
-
onVerifyWallet: handleVerifyWalletClick,
|
|
1745
|
+
onVerifyWallet: (method) => handleVerifyWalletClick(method),
|
|
1654
1746
|
serviceId,
|
|
1655
1747
|
permissionGroup,
|
|
1656
1748
|
// Props
|
|
@@ -1674,7 +1766,10 @@ requireWalletIDVVerification = true, isSemiAutomaticMode = false }) => {
|
|
|
1674
1766
|
onModelChange,
|
|
1675
1767
|
useSessionStorage: useSessionStorageMode,
|
|
1676
1768
|
requireWalletIDVVerification,
|
|
1677
|
-
isSemiAutomaticMode
|
|
1769
|
+
isSemiAutomaticMode,
|
|
1770
|
+
customUserInfo,
|
|
1771
|
+
customUsername,
|
|
1772
|
+
idvBannerDismissSeconds
|
|
1678
1773
|
},
|
|
1679
1774
|
nxtlinqApi
|
|
1680
1775
|
};
|
|
@@ -56,6 +56,10 @@ export interface ChatBotProps {
|
|
|
56
56
|
useSessionStorage?: boolean;
|
|
57
57
|
requireWalletIDVVerification?: boolean;
|
|
58
58
|
isSemiAutomaticMode?: boolean;
|
|
59
|
+
customUserInfo?: Record<string, any>;
|
|
60
|
+
customUsername?: string;
|
|
61
|
+
idvBannerDismissSeconds?: number;
|
|
62
|
+
berifymeMode?: 'built-in' | 'external';
|
|
59
63
|
}
|
|
60
64
|
export interface ChatBotContextType {
|
|
61
65
|
messages: Message[];
|
|
@@ -106,7 +110,7 @@ export interface ChatBotContextType {
|
|
|
106
110
|
handlePresetMessage: (message: PresetMessage) => void;
|
|
107
111
|
savePermissions: (newPermissions?: string[]) => Promise<void>;
|
|
108
112
|
enableAIT: (toolName: string) => Promise<boolean>;
|
|
109
|
-
handleVerifyWalletClick: () => Promise<void>;
|
|
113
|
+
handleVerifyWalletClick: (method: 'berifyme' | 'custom') => Promise<void>;
|
|
110
114
|
showSuccess: (message: string) => void;
|
|
111
115
|
showError: (message: string) => void;
|
|
112
116
|
showWarning: (message: string) => void;
|
|
@@ -120,7 +124,7 @@ export interface ChatBotContextType {
|
|
|
120
124
|
onConnectWallet: () => Promise<string | false | undefined>;
|
|
121
125
|
onSignIn: () => Promise<void>;
|
|
122
126
|
isNeedSignInWithWallet: boolean;
|
|
123
|
-
onVerifyWallet: () => Promise<void>;
|
|
127
|
+
onVerifyWallet: (method: 'berifyme' | 'custom') => Promise<void>;
|
|
124
128
|
serviceId: string;
|
|
125
129
|
permissionGroup?: string;
|
|
126
130
|
props: ChatBotProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBotTypes.d.ts","sourceRoot":"","sources":["../../../src/components/types/ChatBotTypes.ts"],"names":[],"mapp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E,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,eAAe,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,KAAK,GAAG,SAAS,CAAC,CAAC;IAC3D,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,sBAAsB,EAAE,OAAO,CAAC;IAChC,cAAc,EAAE,CAAC,MAAM,EAAE,UAAU,GAAG,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IAGzB,KAAK,EAAE,YAAY,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BerifyMeModal.d.ts","sourceRoot":"","sources":["../../../src/components/ui/BerifyMeModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAEjD,UAAU,kBAAkB;IAC1B,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,sBAAsB,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"BerifyMeModal.d.ts","sourceRoot":"","sources":["../../../src/components/ui/BerifyMeModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAEjD,UAAU,kBAAkB;IAC1B,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,sBAAsB,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,IAAI,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;CAChC;AASD,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA2HtD,CAAC;AAGF,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,WAAW,CAAC,EAAE;YACZ,KAAK,EAAE,GAAG,CAAC;YACX,WAAW,EAAE;gBACX,OAAO,EAAE,GAAG,CAAC;gBACb,UAAU,EAAE,GAAG,CAAC;aACjB,CAAC;SACH,CAAC;KACH;CACF"}
|
|
@@ -6,40 +6,47 @@ const BUILT_IN_BERIFYME_CONFIG = {
|
|
|
6
6
|
secretKey: 'ee96158a-9ae2-42ad-8c30-f7b23edbf258',
|
|
7
7
|
environment: 'staging'
|
|
8
8
|
};
|
|
9
|
-
export const BerifyMeModal = ({ isOpen, onClose, onVerificationComplete }) => {
|
|
9
|
+
export const BerifyMeModal = ({ isOpen, onClose, onVerificationComplete, mode = 'built-in' }) => {
|
|
10
10
|
const modalRef = useRef(null);
|
|
11
11
|
const berifyMeModalRef = useRef(null);
|
|
12
12
|
useEffect(() => {
|
|
13
13
|
if (!isOpen)
|
|
14
14
|
return;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
script.src = 'https://docs.nxtlinq.ai/sdk/umd/berifyme-sdk.umd.js';
|
|
26
|
-
script.onload = () => {
|
|
15
|
+
if (mode === 'external') {
|
|
16
|
+
// External mode: This should not be called as BerifyMeModal is not rendered in external mode
|
|
17
|
+
console.warn('⚠️ BerifyMeModal should not be rendered in external mode');
|
|
18
|
+
onClose();
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
// Built-in mode: dynamically load BerifyMe SDK
|
|
22
|
+
const loadBerifyMeSDK = async () => {
|
|
23
|
+
try {
|
|
24
|
+
// Check if already loaded
|
|
27
25
|
if (window.BerifyMeSDK) {
|
|
28
26
|
renderBerifyMeModal();
|
|
27
|
+
return;
|
|
29
28
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
// Dynamically load SDK
|
|
30
|
+
const script = document.createElement('script');
|
|
31
|
+
script.src = 'https://docs.nxtlinq.ai/sdk/umd/berifyme-sdk.umd.js';
|
|
32
|
+
script.onload = () => {
|
|
33
|
+
if (window.BerifyMeSDK) {
|
|
34
|
+
renderBerifyMeModal();
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
script.onerror = () => {
|
|
38
|
+
console.error('❌ Failed to load BerifyMe SDK');
|
|
39
|
+
onClose();
|
|
40
|
+
};
|
|
41
|
+
document.head.appendChild(script);
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
console.error('❌ Error loading BerifyMe SDK:', error);
|
|
33
45
|
onClose();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
console.error('❌ Error loading BerifyMe SDK:', error);
|
|
39
|
-
onClose();
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
loadBerifyMeSDK();
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
loadBerifyMeSDK();
|
|
49
|
+
}
|
|
43
50
|
return () => {
|
|
44
51
|
// Cleanup function
|
|
45
52
|
if (berifyMeModalRef.current) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBotUI.d.ts","sourceRoot":"","sources":["../../../src/components/ui/ChatBotUI.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAqG/B,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"ChatBotUI.d.ts","sourceRoot":"","sources":["../../../src/components/ui/ChatBotUI.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAqG/B,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAke7B,CAAC"}
|
|
@@ -82,15 +82,28 @@ export const ChatBotUI = () => {
|
|
|
82
82
|
const [showIDVSuggestion, setShowIDVSuggestion] = React.useState(true);
|
|
83
83
|
const [dismissUntil, setDismissUntil] = React.useState(null);
|
|
84
84
|
const [timeRemaining, setTimeRemaining] = React.useState('');
|
|
85
|
+
// Check if there's a berifyme token in URL (indicating recent berifyme verification)
|
|
86
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
87
|
+
const hasBerifymeToken = urlParams.get('token') && urlParams.get('method') === 'berifyme';
|
|
88
|
+
// Check if wallet is verified with berifyme
|
|
89
|
+
const isWalletVerifiedWithBerifyme = walletInfo?.id && walletInfo?.method === 'berifyme';
|
|
85
90
|
// Check if IDV suggestion should be shown
|
|
86
91
|
React.useEffect(() => {
|
|
87
92
|
// Add delay to prevent flashing when wallet info is still loading
|
|
88
|
-
// Only show suggestion when verification is not required
|
|
89
|
-
|
|
93
|
+
// Only show suggestion when verification is not required and wallet is not verified with berifyme
|
|
94
|
+
const shouldShowBanner = hitAddress &&
|
|
95
|
+
!props.requireWalletIDVVerification &&
|
|
96
|
+
!hasBerifymeToken &&
|
|
97
|
+
!isWalletVerifiedWithBerifyme;
|
|
98
|
+
if (shouldShowBanner) {
|
|
90
99
|
// Wait 1 second to allow wallet info to fully load
|
|
91
100
|
const timer = setTimeout(() => {
|
|
92
101
|
// Re-check conditions after delay
|
|
93
|
-
|
|
102
|
+
const shouldShowBannerAfterDelay = hitAddress &&
|
|
103
|
+
!props.requireWalletIDVVerification &&
|
|
104
|
+
!hasBerifymeToken &&
|
|
105
|
+
!isWalletVerifiedWithBerifyme;
|
|
106
|
+
if (shouldShowBannerAfterDelay) {
|
|
94
107
|
const dismissed = localStorage.getItem('idv-suggestion-dismissed');
|
|
95
108
|
if (dismissed) {
|
|
96
109
|
const dismissTime = parseInt(dismissed);
|
|
@@ -155,15 +168,21 @@ export const ChatBotUI = () => {
|
|
|
155
168
|
}, [hitAddress, walletInfo]);
|
|
156
169
|
// Handle dismiss IDV suggestion
|
|
157
170
|
const handleDismissIDV = () => {
|
|
158
|
-
const
|
|
171
|
+
const dismissSeconds = props.idvBannerDismissSeconds || 86400; // Default 24 hours in seconds
|
|
172
|
+
const dismissTime = Date.now() + (dismissSeconds * 1000); // Configurable seconds from now
|
|
159
173
|
localStorage.setItem('idv-suggestion-dismissed', dismissTime.toString());
|
|
160
174
|
setShowIDVSuggestion(false);
|
|
161
175
|
setDismissUntil(dismissTime);
|
|
162
176
|
// Show confirmation message
|
|
177
|
+
const hours = Math.floor(dismissSeconds / 3600);
|
|
178
|
+
const minutes = Math.floor((dismissSeconds % 3600) / 60);
|
|
179
|
+
const timeText = hours > 0
|
|
180
|
+
? (minutes > 0 ? `${hours}h ${minutes}m` : `${hours}h`)
|
|
181
|
+
: `${minutes}m`;
|
|
163
182
|
setNotification({
|
|
164
183
|
show: true,
|
|
165
184
|
type: 'info',
|
|
166
|
-
message:
|
|
185
|
+
message: `IDV suggestion hidden for ${timeText}. You can still verify your wallet anytime.`,
|
|
167
186
|
autoHide: true,
|
|
168
187
|
duration: 5000
|
|
169
188
|
});
|
|
@@ -287,7 +306,7 @@ export const ChatBotUI = () => {
|
|
|
287
306
|
display: 'flex',
|
|
288
307
|
alignItems: 'center',
|
|
289
308
|
justifyContent: 'center'
|
|
290
|
-
}, children: "\u00D7" })] })] }), showIDVSuggestion && hitAddress && !
|
|
309
|
+
}, children: "\u00D7" })] })] }), showIDVSuggestion && hitAddress && !props.requireWalletIDVVerification && !hasBerifymeToken && !isWalletVerifiedWithBerifyme && (_jsxs("div", { "data-idv-banner": true, style: {
|
|
291
310
|
backgroundColor: '#fff3cd',
|
|
292
311
|
border: '1px solid #ffeaa7',
|
|
293
312
|
borderLeft: '4px solid #f39c12',
|
|
@@ -310,7 +329,7 @@ export const ChatBotUI = () => {
|
|
|
310
329
|
fontSize: '13px',
|
|
311
330
|
color: '#856404',
|
|
312
331
|
lineHeight: '1.4'
|
|
313
|
-
}, children: "While not required, verifying your wallet with Berify.me provides additional security and trust for your AI agent interactions." }), _jsx("button", { onClick: onVerifyWallet, style: {
|
|
332
|
+
}, children: "While not required, verifying your wallet with Berify.me provides additional security and trust for your AI agent interactions." }), _jsx("button", { onClick: () => onVerifyWallet('berifyme'), style: {
|
|
314
333
|
padding: '8px 16px',
|
|
315
334
|
backgroundColor: '#f39c12',
|
|
316
335
|
color: 'white',
|
|
@@ -329,7 +348,7 @@ export const ChatBotUI = () => {
|
|
|
329
348
|
padding: '4px',
|
|
330
349
|
borderRadius: '4px',
|
|
331
350
|
transition: 'background-color 0.2s'
|
|
332
|
-
}, onMouseOver: (e) => e.currentTarget.style.backgroundColor = 'rgba(133, 100, 4, 0.1)', onMouseOut: (e) => e.currentTarget.style.backgroundColor = 'transparent', title:
|
|
351
|
+
}, onMouseOver: (e) => e.currentTarget.style.backgroundColor = 'rgba(133, 100, 4, 0.1)', onMouseOut: (e) => e.currentTarget.style.backgroundColor = 'transparent', title: `Hide for ${Math.floor((props.idvBannerDismissSeconds || 86400) / 3600)} hours`, children: "\u00D7" })] })), !showIDVSuggestion && dismissUntil && timeRemaining && (_jsxs("div", { style: {
|
|
333
352
|
backgroundColor: '#f8f9fa',
|
|
334
353
|
border: '1px solid #e9ecef',
|
|
335
354
|
margin: '16px',
|
|
@@ -254,7 +254,7 @@ export const PermissionForm = ({ onClose, onOpen }) => {
|
|
|
254
254
|
marginBottom: '24px',
|
|
255
255
|
fontSize: '16px',
|
|
256
256
|
color: '#666'
|
|
257
|
-
}, children: "Please verify your wallet to continue" }), _jsx("button", { onClick: onVerifyWallet, style: {
|
|
257
|
+
}, children: "Please verify your wallet to continue" }), _jsx("button", { onClick: () => onVerifyWallet('berifyme'), style: {
|
|
258
258
|
padding: '12px 24px',
|
|
259
259
|
backgroundColor: '#007bff',
|
|
260
260
|
color: 'white',
|