@bytexbyte/nxtlinq-ai-agent-sdk 1.5.6 → 1.5.8
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 +1 -1
- package/dist/components/context/ChatBotContext.d.ts.map +1 -1
- package/dist/components/context/ChatBotContext.js +176 -29
- package/dist/components/types/ChatBotTypes.d.ts +6 -2
- package/dist/components/types/ChatBotTypes.d.ts.map +1 -1
- 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/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;
|
|
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,CA6C1C,CAAC;AAEF,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { ChatBotProvider } from './context/ChatBotContext';
|
|
4
|
-
import { ChatBotUI } from './ui/ChatBotUI';
|
|
5
4
|
import { BerifyMeModal } from './ui/BerifyMeModal';
|
|
5
|
+
import { ChatBotUI } from './ui/ChatBotUI';
|
|
6
6
|
export const ChatBot = (props) => {
|
|
7
7
|
const [isBerifyMeModalOpen, setIsBerifyMeModalOpen] = React.useState(false);
|
|
8
8
|
// Handle wallet verification
|
|
@@ -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
|
|
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 }) => {
|
|
|
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 }) => {
|
|
|
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 }) => {
|
|
|
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') {
|
|
@@ -863,19 +901,23 @@ requireWalletIDVVerification = true }) => {
|
|
|
863
901
|
// Try to sign in wallet
|
|
864
902
|
await signInWallet(false); // Don't show success message yet
|
|
865
903
|
console.log('Auto sign-in successful, retrying message...');
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
904
|
+
if (isSemiAutomaticMode) {
|
|
905
|
+
setIsLoading(false);
|
|
906
|
+
setMessages(prev => [...prev, {
|
|
907
|
+
id: Date.now().toString(),
|
|
908
|
+
content: 'Click button to continue using tool',
|
|
909
|
+
role: 'assistant',
|
|
910
|
+
timestamp: new Date().toISOString(),
|
|
911
|
+
button: 'continue'
|
|
912
|
+
}]);
|
|
913
|
+
return;
|
|
914
|
+
}
|
|
915
|
+
else {
|
|
916
|
+
// Wait a bit for everything to settle
|
|
917
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
918
|
+
// Retry the message
|
|
919
|
+
sendMessage(content, retryCount + 1, isPresetMessage);
|
|
920
|
+
}
|
|
879
921
|
}
|
|
880
922
|
catch (signInError) {
|
|
881
923
|
console.log('Auto sign-in failed, showing error message');
|
|
@@ -952,12 +994,13 @@ requireWalletIDVVerification = true }) => {
|
|
|
952
994
|
permissionDenied = true;
|
|
953
995
|
}
|
|
954
996
|
if (!isToolAllowed) {
|
|
955
|
-
setIsLoading(false);
|
|
956
997
|
// If permission denied due to missing AIT permission return
|
|
957
998
|
if (permissionDenied) {
|
|
999
|
+
setIsLoading(false);
|
|
958
1000
|
return;
|
|
959
1001
|
}
|
|
960
|
-
if (
|
|
1002
|
+
if (isSemiAutomaticMode) {
|
|
1003
|
+
setIsLoading(false);
|
|
961
1004
|
setMessages(prev => [...prev, {
|
|
962
1005
|
id: Date.now().toString(),
|
|
963
1006
|
content: 'Click button to continue using tool',
|
|
@@ -967,9 +1010,55 @@ requireWalletIDVVerification = true }) => {
|
|
|
967
1010
|
}]);
|
|
968
1011
|
return;
|
|
969
1012
|
}
|
|
970
|
-
|
|
1013
|
+
else {
|
|
1014
|
+
// Only retry for auto-connect/auto-sign-in scenarios
|
|
1015
|
+
if (wasAutoConnected && retryCount < 1) {
|
|
1016
|
+
console.log('Auto-connected, retrying message...');
|
|
1017
|
+
// Clear loading state and retry immediately
|
|
1018
|
+
setIsLoading(false);
|
|
1019
|
+
// Check if wallet is already signed in
|
|
1020
|
+
const currentToken = nxtlinqAITServiceAccessTokenRef.current;
|
|
1021
|
+
if (!currentToken) {
|
|
1022
|
+
// If not signed in, directly retry the message without waiting for AIT
|
|
1023
|
+
console.log('Wallet connected but not signed in, retrying message directly');
|
|
1024
|
+
setTimeout(() => {
|
|
1025
|
+
sendMessage(content, retryCount + 1, isPresetMessage);
|
|
1026
|
+
}, 2000);
|
|
1027
|
+
}
|
|
1028
|
+
else {
|
|
1029
|
+
// If already signed in, wait for AIT to be fully loaded before retrying
|
|
1030
|
+
setTimeout(async () => {
|
|
1031
|
+
// Wait for AIT to be loaded if needed
|
|
1032
|
+
if (!aitRef.current && nxtlinqAITServiceAccessTokenRef.current) {
|
|
1033
|
+
await refreshAIT();
|
|
1034
|
+
}
|
|
1035
|
+
// Wait for AIT to be fully loaded with polling
|
|
1036
|
+
let attempts = 0;
|
|
1037
|
+
const maxAttempts = 5; // Wait up to 10 seconds (5 * 2000ms)
|
|
1038
|
+
while (!aitRef.current && attempts < maxAttempts) {
|
|
1039
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
1040
|
+
attempts++;
|
|
1041
|
+
}
|
|
1042
|
+
// Only retry if AIT is actually loaded
|
|
1043
|
+
if (aitRef.current) {
|
|
1044
|
+
console.log('AIT loaded successfully, retrying message');
|
|
1045
|
+
// Wait a bit more to ensure permissions are also loaded
|
|
1046
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
1047
|
+
sendMessage(content, retryCount + 1, isPresetMessage);
|
|
1048
|
+
}
|
|
1049
|
+
else {
|
|
1050
|
+
console.log('AIT failed to load, not retrying');
|
|
1051
|
+
}
|
|
1052
|
+
}, 2000);
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
else {
|
|
1056
|
+
console.log('Permission denied, not retrying. wasAutoConnected:', wasAutoConnected, 'retryCount:', retryCount);
|
|
1057
|
+
}
|
|
1058
|
+
return;
|
|
1059
|
+
}
|
|
971
1060
|
}
|
|
972
|
-
if (wasAutoSignedIn) {
|
|
1061
|
+
if (isSemiAutomaticMode && wasAutoSignedIn) {
|
|
973
1062
|
setIsLoading(false);
|
|
974
1063
|
setMessages(prev => [...prev, {
|
|
975
1064
|
id: Date.now().toString(),
|
|
@@ -1361,14 +1450,19 @@ requireWalletIDVVerification = true }) => {
|
|
|
1361
1450
|
}
|
|
1362
1451
|
};
|
|
1363
1452
|
// Handle verify wallet click
|
|
1364
|
-
const handleVerifyWalletClick = async () => {
|
|
1453
|
+
const handleVerifyWalletClick = async (method) => {
|
|
1365
1454
|
if (!hitAddress) {
|
|
1366
1455
|
showError('Please connect your wallet first.');
|
|
1367
1456
|
return;
|
|
1368
1457
|
}
|
|
1369
1458
|
try {
|
|
1370
|
-
|
|
1371
|
-
|
|
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
|
+
}
|
|
1372
1466
|
const result = await onVerifyWallet();
|
|
1373
1467
|
if (!result) {
|
|
1374
1468
|
setIsLoading(false);
|
|
@@ -1387,6 +1481,7 @@ requireWalletIDVVerification = true }) => {
|
|
|
1387
1481
|
const verifyWalletResponse = await nxtlinqApi.wallet.verifyWallet({ ...payload }, token);
|
|
1388
1482
|
if ('error' in verifyWalletResponse) {
|
|
1389
1483
|
if (verifyWalletResponse.error === 'Wallet already exists') {
|
|
1484
|
+
// Wallet already exists with the same method, just refresh AIT
|
|
1390
1485
|
setIsWalletLoading(true);
|
|
1391
1486
|
try {
|
|
1392
1487
|
const walletResponse = await nxtlinqApi.wallet.getWallet({ address }, token);
|
|
@@ -1472,6 +1567,54 @@ requireWalletIDVVerification = true }) => {
|
|
|
1472
1567
|
setIsLoading(false);
|
|
1473
1568
|
return;
|
|
1474
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);
|
|
1475
1618
|
}
|
|
1476
1619
|
catch (error) {
|
|
1477
1620
|
console.error('Failed to verify wallet:', error);
|
|
@@ -1480,7 +1623,6 @@ requireWalletIDVVerification = true }) => {
|
|
|
1480
1623
|
throw error;
|
|
1481
1624
|
}
|
|
1482
1625
|
};
|
|
1483
|
-
// Effects
|
|
1484
1626
|
React.useEffect(() => {
|
|
1485
1627
|
if (hitAddress && nxtlinqAITServiceAccessToken) {
|
|
1486
1628
|
refreshAIT();
|
|
@@ -1495,7 +1637,7 @@ requireWalletIDVVerification = true }) => {
|
|
|
1495
1637
|
const urlParams = new URLSearchParams(window.location.search);
|
|
1496
1638
|
const token = urlParams.get('token');
|
|
1497
1639
|
if (token && hitAddress) {
|
|
1498
|
-
handleVerifyWalletClick();
|
|
1640
|
+
handleVerifyWalletClick('berifyme');
|
|
1499
1641
|
}
|
|
1500
1642
|
}
|
|
1501
1643
|
catch (e) {
|
|
@@ -1514,23 +1656,24 @@ requireWalletIDVVerification = true }) => {
|
|
|
1514
1656
|
return;
|
|
1515
1657
|
}
|
|
1516
1658
|
const updateExternalId = async () => {
|
|
1659
|
+
const externalId = hitAddress;
|
|
1517
1660
|
await nxtlinqApi.agent.updateMessagesExternalIdByPseudoId({
|
|
1518
1661
|
apiKey,
|
|
1519
1662
|
apiSecret,
|
|
1520
1663
|
pseudoId,
|
|
1521
|
-
externalId:
|
|
1664
|
+
externalId: externalId,
|
|
1522
1665
|
});
|
|
1523
1666
|
await nxtlinqApi.agent.cloneUserProfileByPseudoId({
|
|
1524
1667
|
apiKey,
|
|
1525
1668
|
apiSecret,
|
|
1526
1669
|
pseudoId,
|
|
1527
|
-
externalId:
|
|
1670
|
+
externalId: externalId,
|
|
1528
1671
|
});
|
|
1529
1672
|
await nxtlinqApi.agent.cloneUserTopicByPseudoId({
|
|
1530
1673
|
apiKey,
|
|
1531
1674
|
apiSecret,
|
|
1532
1675
|
pseudoId,
|
|
1533
|
-
externalId:
|
|
1676
|
+
externalId: externalId,
|
|
1534
1677
|
});
|
|
1535
1678
|
};
|
|
1536
1679
|
updateExternalId();
|
|
@@ -1599,7 +1742,7 @@ requireWalletIDVVerification = true }) => {
|
|
|
1599
1742
|
onConnectWallet: () => connectWallet(false),
|
|
1600
1743
|
onSignIn: () => signInWallet(false),
|
|
1601
1744
|
isNeedSignInWithWallet,
|
|
1602
|
-
onVerifyWallet: handleVerifyWalletClick,
|
|
1745
|
+
onVerifyWallet: (method) => handleVerifyWalletClick(method),
|
|
1603
1746
|
serviceId,
|
|
1604
1747
|
permissionGroup,
|
|
1605
1748
|
// Props
|
|
@@ -1622,7 +1765,11 @@ requireWalletIDVVerification = true }) => {
|
|
|
1622
1765
|
showModelSelector,
|
|
1623
1766
|
onModelChange,
|
|
1624
1767
|
useSessionStorage: useSessionStorageMode,
|
|
1625
|
-
requireWalletIDVVerification
|
|
1768
|
+
requireWalletIDVVerification,
|
|
1769
|
+
isSemiAutomaticMode,
|
|
1770
|
+
customUserInfo,
|
|
1771
|
+
customUsername,
|
|
1772
|
+
idvBannerDismissSeconds
|
|
1626
1773
|
},
|
|
1627
1774
|
nxtlinqApi
|
|
1628
1775
|
};
|
|
@@ -55,6 +55,10 @@ export interface ChatBotProps {
|
|
|
55
55
|
onModelChange?: (model: AIModel) => void;
|
|
56
56
|
useSessionStorage?: boolean;
|
|
57
57
|
requireWalletIDVVerification?: boolean;
|
|
58
|
+
isSemiAutomaticMode?: boolean;
|
|
59
|
+
customUserInfo?: Record<string, any>;
|
|
60
|
+
customUsername?: string;
|
|
61
|
+
idvBannerDismissSeconds?: number;
|
|
58
62
|
}
|
|
59
63
|
export interface ChatBotContextType {
|
|
60
64
|
messages: Message[];
|
|
@@ -105,7 +109,7 @@ export interface ChatBotContextType {
|
|
|
105
109
|
handlePresetMessage: (message: PresetMessage) => void;
|
|
106
110
|
savePermissions: (newPermissions?: string[]) => Promise<void>;
|
|
107
111
|
enableAIT: (toolName: string) => Promise<boolean>;
|
|
108
|
-
handleVerifyWalletClick: () => Promise<void>;
|
|
112
|
+
handleVerifyWalletClick: (method: 'berifyme' | 'custom') => Promise<void>;
|
|
109
113
|
showSuccess: (message: string) => void;
|
|
110
114
|
showError: (message: string) => void;
|
|
111
115
|
showWarning: (message: string) => void;
|
|
@@ -119,7 +123,7 @@ export interface ChatBotContextType {
|
|
|
119
123
|
onConnectWallet: () => Promise<string | false | undefined>;
|
|
120
124
|
onSignIn: () => Promise<void>;
|
|
121
125
|
isNeedSignInWithWallet: boolean;
|
|
122
|
-
onVerifyWallet: () => Promise<void>;
|
|
126
|
+
onVerifyWallet: (method: 'berifyme' | 'custom') => Promise<void>;
|
|
123
127
|
serviceId: string;
|
|
124
128
|
permissionGroup?: string;
|
|
125
129
|
props: ChatBotProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBotTypes.d.ts","sourceRoot":"","sources":["../../../src/components/types/ChatBotTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE9E,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC5B;AAED,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/B,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAGD,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,iBAAiB,EAAE,OAAO,EAKtC,CAAC;AAGF,eAAO,MAAM,oBAAoB,EAAE,OAAO,EAwBzC,CAAC;AAEF,eAAO,MAAM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AI,CAAC,CAAC;IACpC,aAAa,EAAE,MAAM,IAAI,CAAC;IAE1B,iBAAiB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,eAAe,EAAE,MAAM,OAAO,CAAC;IAG/B,MAAM,EAAE,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,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":"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',
|