@bytexbyte/nxtlinq-ai-agent-sdk 1.6.10 → 1.6.11
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 +231 -105
- package/dist/api/nxtlinq-api.js +1 -1
- package/package.json +1 -1
- package/dist/core/utils/__tests__/urlUtils.test.d.ts +0 -5
- package/dist/core/utils/__tests__/urlUtils.test.d.ts.map +0 -1
- package/dist/core/utils/__tests__/urlUtils.test.js +0 -57
- package/dist/core/utils/berifyMeReactFix.d.ts +0 -8
- package/dist/core/utils/berifyMeReactFix.d.ts.map +0 -1
- package/dist/core/utils/berifyMeReactFix.js +0 -81
- package/dist/core/utils/reactInstanceCheck.d.ts +0 -9
- package/dist/core/utils/reactInstanceCheck.d.ts.map +0 -1
- package/dist/core/utils/reactInstanceCheck.js +0 -46
- package/dist/setupTests.d.ts +0 -2
- package/dist/setupTests.d.ts.map +0 -1
- package/dist/setupTests.js +0 -16
package/README.md
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
# nxtlinq AI Agent SDK
|
|
2
2
|
|
|
3
|
-
A comprehensive SDK for integrating AI agents with wallet verification capabilities.
|
|
3
|
+
A comprehensive SDK for integrating AI agents with wallet verification capabilities, speech-to-text functionality, and responsive mobile design.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- 🤖 AI-powered chat interface
|
|
7
|
+
- 🤖 AI-powered chat interface with multiple model support
|
|
8
8
|
- 🔐 Built-in BerifyMe wallet verification
|
|
9
|
-
-
|
|
9
|
+
- 🎤 Speech-to-text voice input with Microsoft Cognitive Services
|
|
10
|
+
- 🎨 Customizable UI components with responsive design
|
|
10
11
|
- 🔧 Tool integration support
|
|
11
|
-
- 📱
|
|
12
|
+
- 📱 Mobile-optimized responsive design (65-70% viewport on mobile)
|
|
12
13
|
- 👤 Custom user identity support
|
|
13
14
|
- ⏰ Configurable banner dismiss duration
|
|
15
|
+
- 🎯 Multiple AI model support
|
|
16
|
+
- 💾 Flexible storage options (localStorage/sessionStorage)
|
|
17
|
+
- 🔄 Semi-automatic mode for user activation
|
|
14
18
|
|
|
15
19
|
## Installation
|
|
16
20
|
|
|
@@ -40,7 +44,7 @@ function App() {
|
|
|
40
44
|
|
|
41
45
|
### With Built-in BerifyMe Support
|
|
42
46
|
|
|
43
|
-
The SDK
|
|
47
|
+
The SDK includes built-in BerifyMe wallet verification for seamless integration:
|
|
44
48
|
|
|
45
49
|
```tsx
|
|
46
50
|
import { ChatBot } from '@bytexbyte/nxtlinq-ai-agent-sdk';
|
|
@@ -57,35 +61,22 @@ function App() {
|
|
|
57
61
|
}
|
|
58
62
|
```
|
|
59
63
|
|
|
60
|
-
###
|
|
64
|
+
### With Speech-to-Text Support
|
|
61
65
|
|
|
62
|
-
|
|
66
|
+
Enable voice input with Microsoft Cognitive Services:
|
|
63
67
|
|
|
64
68
|
```tsx
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
apiKey="your-api-key"
|
|
72
|
-
apiSecret="your-api-secret"
|
|
73
|
-
// Built-in wallet verification - no onVerifyWallet needed!
|
|
74
|
-
/>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
69
|
+
<ChatBot
|
|
70
|
+
serviceId="your-service-id"
|
|
71
|
+
apiKey="your-api-key"
|
|
72
|
+
apiSecret="your-api-secret"
|
|
73
|
+
isStopRecordingOnSend={true} // Stop recording automatically when sending message
|
|
74
|
+
/>
|
|
77
75
|
```
|
|
78
76
|
|
|
79
|
-
**What happens automatically:**
|
|
80
|
-
1. ✅ Check for existing token in URL parameters
|
|
81
|
-
2. ✅ Open BerifyMe modal when verification is needed
|
|
82
|
-
3. ✅ Handle verification completion and token extraction
|
|
83
|
-
4. ✅ Clean up modal and state management
|
|
84
|
-
5. ✅ Return token to the system for wallet verification
|
|
85
|
-
|
|
86
77
|
### Skip Wallet Verification Check
|
|
87
78
|
|
|
88
|
-
|
|
79
|
+
Allow users to set AIT permissions without wallet verification:
|
|
89
80
|
|
|
90
81
|
```tsx
|
|
91
82
|
<ChatBot
|
|
@@ -96,110 +87,163 @@ If you want to allow users to set AIT permissions without wallet verification, y
|
|
|
96
87
|
/>
|
|
97
88
|
```
|
|
98
89
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
**Default Behavior**: `requireWalletIDVVerification` defaults to `true`, meaning wallet verification is required by default for security.
|
|
102
|
-
|
|
103
|
-
## Benefits of Built-in BerifyMe Support
|
|
104
|
-
|
|
105
|
-
✅ **Always Available**: Built-in BerifyMe support is always enabled - no configuration needed!
|
|
90
|
+
## Mobile Responsive Design
|
|
106
91
|
|
|
107
|
-
|
|
92
|
+
The SDK is optimized for mobile devices with responsive breakpoints:
|
|
108
93
|
|
|
109
|
-
|
|
94
|
+
- **Tablet (≤768px)**: Chat window sized to 70% viewport width/height
|
|
95
|
+
- **Mobile (≤480px)**: Chat window sized to 65% viewport width/height
|
|
96
|
+
- **PermissionForm**: Responsive sizing with 75% width on tablet, 70% on mobile
|
|
97
|
+
- **Floating Button**: Optimized positioning and sizing for touch interfaces
|
|
98
|
+
- **Browser Compatibility**: Accounts for mobile browser address bars and UI elements
|
|
110
99
|
|
|
111
|
-
|
|
100
|
+
## Configuration Options
|
|
112
101
|
|
|
113
|
-
|
|
102
|
+
### Core Configuration
|
|
114
103
|
|
|
115
|
-
|
|
104
|
+
| Property | Type | Default | Description |
|
|
105
|
+
|----------|------|---------|-------------|
|
|
106
|
+
| `serviceId` | `string` | - | **Required** - Your service ID |
|
|
107
|
+
| `apiKey` | `string` | - | **Required** - Your API key |
|
|
108
|
+
| `apiSecret` | `string` | - | **Required** - Your API secret |
|
|
116
109
|
|
|
117
|
-
|
|
110
|
+
### Wallet Verification Options
|
|
118
111
|
|
|
119
|
-
|
|
112
|
+
| Property | Type | Default | Description |
|
|
113
|
+
|----------|------|---------|-------------|
|
|
114
|
+
| `requireWalletIDVVerification` | `boolean` | `true` | Whether to check wallet IDV verification status before AIT operations |
|
|
115
|
+
| `customUsername` | `string` | - | Custom username for wallet verification when using custom method |
|
|
116
|
+
| `idvBannerDismissSeconds` | `number` | `86400` | Seconds to hide IDV suggestion banner after user dismisses it (default: 24 hours) |
|
|
117
|
+
| `berifymeMode` | `'built-in' \| 'external'` | `'built-in'` | BerifyMe integration mode |
|
|
120
118
|
|
|
121
|
-
|
|
119
|
+
### AI Model Configuration
|
|
122
120
|
|
|
123
|
-
|
|
121
|
+
| Property | Type | Default | Description |
|
|
122
|
+
|----------|------|---------|-------------|
|
|
123
|
+
| `availableModels` | `AIModel[]` | `DEFAULT_AI_MODELS` | Available AI models for selection |
|
|
124
|
+
| `defaultModelIndex` | `number` | `0` | Default selected model index |
|
|
125
|
+
| `showModelSelector` | `boolean` | `true` | Whether to show model selector in UI |
|
|
126
|
+
| `onModelChange` | `(model: AIModel) => void` | - | Callback when model is changed |
|
|
124
127
|
|
|
125
|
-
|
|
128
|
+
### Storage Configuration
|
|
126
129
|
|
|
127
|
-
|
|
130
|
+
| Property | Type | Default | Description |
|
|
131
|
+
|----------|------|---------|-------------|
|
|
132
|
+
| `useSessionStorage` | `boolean` | `false` | Use sessionStorage instead of localStorage for chat state |
|
|
128
133
|
|
|
129
|
-
|
|
134
|
+
### User Identity Options
|
|
130
135
|
|
|
131
|
-
|
|
136
|
+
| Property | Type | Default | Description |
|
|
137
|
+
|----------|------|---------|-------------|
|
|
138
|
+
| `customUserInfo` | `Record<string, any>` | - | Custom user identity information object for backend processing |
|
|
132
139
|
|
|
133
|
-
|
|
140
|
+
### Speech-to-Text Options
|
|
134
141
|
|
|
135
|
-
**Wallet Verification Options:**
|
|
136
142
|
| Property | Type | Default | Description |
|
|
137
143
|
|----------|------|---------|-------------|
|
|
138
|
-
| `
|
|
139
|
-
|
|
140
|
-
|
|
144
|
+
| `isStopRecordingOnSend` | `boolean` | `false` | Stop recording automatically when sending message |
|
|
145
|
+
|
|
146
|
+
### Advanced Options
|
|
141
147
|
|
|
142
|
-
**User Identity Options:**
|
|
143
148
|
| Property | Type | Default | Description |
|
|
144
149
|
|----------|------|---------|-------------|
|
|
145
|
-
| `
|
|
150
|
+
| `isSemiAutomaticMode` | `boolean` | `false` | Enable semi-automatic mode for user activation |
|
|
151
|
+
| `maxRetries` | `number` | `3` | Maximum retry attempts for failed requests |
|
|
152
|
+
| `retryDelay` | `number` | `1000` | Delay between retry attempts (ms) |
|
|
146
153
|
|
|
147
|
-
|
|
154
|
+
## Available AI Models
|
|
148
155
|
|
|
149
|
-
|
|
150
|
-
```tsx
|
|
151
|
-
<ChatBot
|
|
152
|
-
serviceId="your-service-id"
|
|
153
|
-
apiKey="your-api-key"
|
|
154
|
-
apiSecret="your-api-secret"
|
|
155
|
-
// requireWalletIDVVerification defaults to true
|
|
156
|
-
// Users must complete wallet verification before using AIT
|
|
157
|
-
/>
|
|
158
|
-
```
|
|
156
|
+
The SDK supports multiple AI models:
|
|
159
157
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
/>
|
|
170
|
-
```
|
|
158
|
+
- **Claude** (`claude`)
|
|
159
|
+
- **ChatGPT** (`open-ai`)
|
|
160
|
+
- **Llama** (`llama`)
|
|
161
|
+
- **Gemini** (`gemini`)
|
|
162
|
+
- **Nova** (`nova`)
|
|
163
|
+
|
|
164
|
+
## Configuration Examples
|
|
165
|
+
|
|
166
|
+
### Complete Configuration Example
|
|
171
167
|
|
|
172
|
-
#### Custom User Identity
|
|
173
168
|
```tsx
|
|
174
169
|
<ChatBot
|
|
175
170
|
serviceId="your-service-id"
|
|
176
171
|
apiKey="your-api-key"
|
|
177
172
|
apiSecret="your-api-secret"
|
|
173
|
+
|
|
174
|
+
// Wallet verification
|
|
178
175
|
requireWalletIDVVerification={false}
|
|
179
176
|
customUsername="john.doe"
|
|
177
|
+
idvBannerDismissSeconds={3600}
|
|
178
|
+
berifymeMode="built-in"
|
|
179
|
+
|
|
180
|
+
// AI models
|
|
181
|
+
availableModels={DEFAULT_AI_MODELS}
|
|
182
|
+
defaultModelIndex={0}
|
|
183
|
+
showModelSelector={true}
|
|
184
|
+
onModelChange={(model) => console.log('Model changed:', model)}
|
|
185
|
+
|
|
186
|
+
// Storage
|
|
187
|
+
useSessionStorage={true}
|
|
188
|
+
|
|
189
|
+
// User identity
|
|
180
190
|
customUserInfo={{
|
|
181
191
|
corpId: "CORP-001",
|
|
182
192
|
department: "Engineering",
|
|
183
193
|
role: "Developer"
|
|
184
194
|
}}
|
|
185
|
-
|
|
195
|
+
|
|
196
|
+
// Speech-to-text
|
|
197
|
+
isStopRecordingOnSend={true}
|
|
198
|
+
|
|
199
|
+
// Advanced
|
|
200
|
+
isSemiAutomaticMode={false}
|
|
201
|
+
maxRetries={3}
|
|
202
|
+
retryDelay={1000}
|
|
203
|
+
|
|
204
|
+
// Callbacks
|
|
205
|
+
onMessage={(message) => console.log('New message:', message)}
|
|
206
|
+
onError={(error) => console.error('Error:', error)}
|
|
207
|
+
onToolUse={async (toolUse) => {
|
|
208
|
+
// Handle tool use
|
|
209
|
+
return { text: 'Tool executed successfully' };
|
|
210
|
+
}}
|
|
186
211
|
/>
|
|
187
212
|
```
|
|
188
213
|
|
|
189
|
-
|
|
214
|
+
### Custom AI Models
|
|
215
|
+
|
|
190
216
|
```tsx
|
|
217
|
+
import { ChatBot, AIModel } from '@bytexbyte/nxtlinq-ai-agent-sdk';
|
|
218
|
+
|
|
219
|
+
const customModels: AIModel[] = [
|
|
220
|
+
{ label: 'Claude', value: 'claude' },
|
|
221
|
+
{ label: 'ChatGPT', value: 'open-ai' },
|
|
222
|
+
{ label: 'Llama', value: 'llama' },
|
|
223
|
+
{ label: 'Gemini', value: 'gemini' }
|
|
224
|
+
];
|
|
225
|
+
|
|
191
226
|
<ChatBot
|
|
192
227
|
serviceId="your-service-id"
|
|
193
228
|
apiKey="your-api-key"
|
|
194
229
|
apiSecret="your-api-secret"
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
// Customize how long the IDV suggestion banner stays hidden
|
|
230
|
+
availableModels={customModels}
|
|
231
|
+
defaultModelIndex={0}
|
|
198
232
|
/>
|
|
199
233
|
```
|
|
200
234
|
|
|
201
235
|
## Advanced Features
|
|
202
236
|
|
|
237
|
+
### Speech-to-Text Integration
|
|
238
|
+
|
|
239
|
+
The SDK includes built-in speech-to-text functionality using Microsoft Cognitive Services:
|
|
240
|
+
|
|
241
|
+
- **Real-time transcription**: Live voice-to-text conversion
|
|
242
|
+
- **Partial transcripts**: Shows real-time partial results while speaking
|
|
243
|
+
- **Wake lock support**: Prevents screen from sleeping during recording
|
|
244
|
+
- **Automatic cleanup**: Handles microphone permissions and cleanup
|
|
245
|
+
- **Configurable behavior**: Control when recording stops
|
|
246
|
+
|
|
203
247
|
### IDV Suggestion Banner
|
|
204
248
|
|
|
205
249
|
When `requireWalletIDVVerification: false`, the SDK shows a helpful suggestion banner for unverified wallets:
|
|
@@ -209,7 +253,6 @@ When `requireWalletIDVVerification: false`, the SDK shows a helpful suggestion b
|
|
|
209
253
|
- **Persistent State**: Dismissal preference is saved in localStorage
|
|
210
254
|
- **Responsive Design**: Banner adapts to different screen sizes
|
|
211
255
|
- **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
256
|
|
|
214
257
|
### Custom User Identity
|
|
215
258
|
|
|
@@ -220,32 +263,115 @@ The SDK supports flexible user identity information for enhanced backend process
|
|
|
220
263
|
- **Backend Integration**: Custom identity information is sent to the AIT Service for processing
|
|
221
264
|
- **Optional Parameters**: Both `customUsername` and `customUserInfo` are optional
|
|
222
265
|
|
|
223
|
-
|
|
266
|
+
### Storage Modes
|
|
267
|
+
|
|
268
|
+
Choose between different storage strategies:
|
|
269
|
+
|
|
270
|
+
- **localStorage** (default): Persistent across browser sessions
|
|
271
|
+
- **sessionStorage**: Data cleared when browser tab is closed
|
|
272
|
+
|
|
273
|
+
### BerifyMe Integration Modes
|
|
274
|
+
|
|
275
|
+
- **built-in** (default): SDK automatically loads and manages BerifyMe
|
|
276
|
+
- **external**: Use your own BerifyMe integration with `onVerifyWallet` callback
|
|
277
|
+
|
|
278
|
+
## Exported Components and Utilities
|
|
279
|
+
|
|
280
|
+
### Components
|
|
224
281
|
```tsx
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
282
|
+
import {
|
|
283
|
+
ChatBot,
|
|
284
|
+
ChatBotUI,
|
|
285
|
+
MessageInput,
|
|
286
|
+
MessageList,
|
|
287
|
+
ModelSelector,
|
|
288
|
+
NotificationModal,
|
|
289
|
+
PermissionForm,
|
|
290
|
+
PresetMessages,
|
|
291
|
+
BerifyMeModal
|
|
292
|
+
} from '@bytexbyte/nxtlinq-ai-agent-sdk';
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### Hooks and Context
|
|
296
|
+
```tsx
|
|
297
|
+
import {
|
|
298
|
+
ChatBotProvider,
|
|
299
|
+
useChatBot,
|
|
300
|
+
useLocalStorage,
|
|
301
|
+
useSessionStorage
|
|
302
|
+
} from '@bytexbyte/nxtlinq-ai-agent-sdk';
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### Utilities
|
|
306
|
+
```tsx
|
|
307
|
+
import {
|
|
308
|
+
connectWallet,
|
|
309
|
+
disconnectWallet,
|
|
310
|
+
validateToken,
|
|
311
|
+
createAITMetadata,
|
|
312
|
+
generateAITId,
|
|
313
|
+
prepareAITCreation,
|
|
314
|
+
createNotification,
|
|
315
|
+
getNotificationIcon,
|
|
316
|
+
containsUrls,
|
|
317
|
+
convertUrlsToLinks,
|
|
318
|
+
convertUrlsToHtml,
|
|
319
|
+
createNxtlinqApi
|
|
320
|
+
} from '@bytexbyte/nxtlinq-ai-agent-sdk';
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
### Types
|
|
324
|
+
```tsx
|
|
325
|
+
import type {
|
|
326
|
+
ChatBotProps,
|
|
327
|
+
ChatBotContextType,
|
|
328
|
+
AIModel,
|
|
329
|
+
AITMetadata,
|
|
330
|
+
NovaResponse,
|
|
331
|
+
NovaError,
|
|
332
|
+
PresetMessage,
|
|
333
|
+
ToolCall,
|
|
334
|
+
ToolUse,
|
|
335
|
+
AIT,
|
|
336
|
+
AITApi,
|
|
337
|
+
Message,
|
|
338
|
+
ServicePermission
|
|
339
|
+
} from '@bytexbyte/nxtlinq-ai-agent-sdk';
|
|
239
340
|
```
|
|
240
341
|
|
|
241
|
-
|
|
342
|
+
## Benefits
|
|
343
|
+
|
|
344
|
+
✅ **Always Available**: Built-in BerifyMe support is always enabled - no configuration needed!
|
|
345
|
+
|
|
346
|
+
✅ **No onVerifyWallet Needed**: SDK automatically handles wallet verification - no callback implementation required
|
|
347
|
+
|
|
348
|
+
✅ **Simplified Integration**: No need to manually handle DOM manipulation, React roots, or modal lifecycle
|
|
349
|
+
|
|
350
|
+
✅ **Automatic SDK Loading**: SDK automatically loads BerifyMe dependencies when needed
|
|
351
|
+
|
|
352
|
+
✅ **Built-in Error Handling**: Comprehensive error handling and fallback mechanisms
|
|
353
|
+
|
|
354
|
+
✅ **Consistent UI**: Unified modal experience across all implementations
|
|
355
|
+
|
|
356
|
+
✅ **Easy Configuration**: Simple configuration object with sensible defaults
|
|
357
|
+
|
|
358
|
+
✅ **Automatic Cleanup**: Modal cleanup and memory management handled automatically
|
|
359
|
+
|
|
360
|
+
✅ **Flexible IDV Verification**: Control whether to require wallet IDV verification before AIT operations
|
|
361
|
+
|
|
362
|
+
✅ **Smart Suggestion Banner**: When verification is optional, shows helpful suggestion banner with 1-second delay to prevent flashing
|
|
363
|
+
|
|
364
|
+
✅ **Custom User Identity**: Support for custom usernames and flexible user information objects
|
|
365
|
+
|
|
366
|
+
✅ **Configurable Banner Duration**: Customize how long the IDV suggestion banner stays hidden after dismissal
|
|
367
|
+
|
|
368
|
+
✅ **Mobile Optimized**: Responsive design that works perfectly on mobile devices with optimized dimensions
|
|
369
|
+
|
|
370
|
+
✅ **Speech-to-Text**: Built-in voice input with Microsoft Cognitive Services integration
|
|
371
|
+
|
|
372
|
+
✅ **Multiple AI Models**: Support for various AI models (Claude, ChatGPT, Llama, Gemini, Nova)
|
|
242
373
|
|
|
243
|
-
|
|
244
|
-
2. **Sign In**: User signs in with wallet (if required)
|
|
245
|
-
3. **Verification Check**: SDK checks if wallet is verified
|
|
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
|
|
374
|
+
✅ **Flexible Storage**: Choose between localStorage and sessionStorage for different use cases
|
|
249
375
|
|
|
250
376
|
## Support
|
|
251
377
|
|
package/dist/api/nxtlinq-api.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const AI_AGENT_API_HOST = 'https://ai-agent.nxtlinq.ai';
|
|
2
|
-
const AIT_SERVICE_API_HOST = 'https://
|
|
2
|
+
const AIT_SERVICE_API_HOST = 'https://ait-service.nxtlinq.ai';
|
|
3
3
|
// Helper function to get auth header
|
|
4
4
|
const getAuthHeader = () => {
|
|
5
5
|
const token = localStorage.getItem('nxtlinqAITServiceAccessToken');
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"urlUtils.test.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/__tests__/urlUtils.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for URL utility functions
|
|
3
|
-
*/
|
|
4
|
-
import { containsUrls, convertUrlsToLinks, convertUrlsToHtml } from '../urlUtils';
|
|
5
|
-
describe('URL Utils', () => {
|
|
6
|
-
describe('containsUrls', () => {
|
|
7
|
-
it('should detect URLs with http protocol', () => {
|
|
8
|
-
expect(containsUrls('Visit https://example.com for more info')).toBe(true);
|
|
9
|
-
expect(containsUrls('Check out http://test.org')).toBe(true);
|
|
10
|
-
});
|
|
11
|
-
it('should detect URLs with www', () => {
|
|
12
|
-
expect(containsUrls('Go to www.google.com')).toBe(true);
|
|
13
|
-
expect(containsUrls('Visit www.example.org')).toBe(true);
|
|
14
|
-
});
|
|
15
|
-
it('should detect domain names', () => {
|
|
16
|
-
expect(containsUrls('Contact us at support@company.com')).toBe(false);
|
|
17
|
-
expect(containsUrls('Visit company.com for details')).toBe(true);
|
|
18
|
-
});
|
|
19
|
-
it('should return false for text without URLs', () => {
|
|
20
|
-
expect(containsUrls('This is just plain text')).toBe(false);
|
|
21
|
-
expect(containsUrls('No URLs here')).toBe(false);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
describe('convertUrlsToHtml', () => {
|
|
25
|
-
it('should convert URLs to HTML anchor tags', () => {
|
|
26
|
-
const text = 'Visit https://example.com for more info';
|
|
27
|
-
const result = convertUrlsToHtml(text);
|
|
28
|
-
expect(result).toContain('<a href="https://example.com"');
|
|
29
|
-
expect(result).toContain('target="_blank"');
|
|
30
|
-
expect(result).toContain('rel="noopener noreferrer"');
|
|
31
|
-
});
|
|
32
|
-
it('should handle www URLs', () => {
|
|
33
|
-
const text = 'Go to www.google.com';
|
|
34
|
-
const result = convertUrlsToHtml(text);
|
|
35
|
-
expect(result).toContain('<a href="https://www.google.com"');
|
|
36
|
-
});
|
|
37
|
-
it('should handle multiple URLs', () => {
|
|
38
|
-
const text = 'Visit https://example.com and www.google.com';
|
|
39
|
-
const result = convertUrlsToHtml(text);
|
|
40
|
-
expect(result).toContain('https://example.com');
|
|
41
|
-
expect(result).toContain('https://www.google.com');
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
describe('convertUrlsToLinks', () => {
|
|
45
|
-
it('should return array with mixed content', () => {
|
|
46
|
-
const text = 'Visit https://example.com for more info';
|
|
47
|
-
const result = convertUrlsToLinks(text);
|
|
48
|
-
expect(Array.isArray(result)).toBe(true);
|
|
49
|
-
expect(result.length).toBeGreaterThan(0);
|
|
50
|
-
});
|
|
51
|
-
it('should handle text without URLs', () => {
|
|
52
|
-
const text = 'This is just plain text';
|
|
53
|
-
const result = convertUrlsToLinks(text);
|
|
54
|
-
expect(result).toEqual([text]);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* BerifyMe React Instance Fix
|
|
3
|
-
*
|
|
4
|
-
* This utility ensures that BerifyMe SDK uses the same React instance
|
|
5
|
-
* as our SDK, preventing the __SECRET_INTERNALS error.
|
|
6
|
-
*/
|
|
7
|
-
export declare function fixBerifyMeReactInstance(): void;
|
|
8
|
-
//# sourceMappingURL=berifyMeReactFix.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"berifyMeReactFix.d.ts","sourceRoot":"","sources":["../../../src/core/utils/berifyMeReactFix.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,wBAAwB,IAAI,IAAI,CA4E/C"}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* BerifyMe React Instance Fix
|
|
3
|
-
*
|
|
4
|
-
* This utility ensures that BerifyMe SDK uses the same React instance
|
|
5
|
-
* as our SDK, preventing the __SECRET_INTERNALS error.
|
|
6
|
-
*/
|
|
7
|
-
export function fixBerifyMeReactInstance() {
|
|
8
|
-
try {
|
|
9
|
-
// Wait for BerifyMe SDK to load
|
|
10
|
-
const checkBerifyMe = () => {
|
|
11
|
-
if (window.BerifyMeSDK) {
|
|
12
|
-
console.log('[BerifyMe React Fix] BerifyMe SDK detected, applying React instance fix...');
|
|
13
|
-
// Method 1: Try to set React instance if the method exists
|
|
14
|
-
if (window.BerifyMeSDK.setReactInstance) {
|
|
15
|
-
try {
|
|
16
|
-
const React = require('react');
|
|
17
|
-
const createRoot = require('react-dom/client').createRoot;
|
|
18
|
-
window.BerifyMeSDK.setReactInstance(React, createRoot);
|
|
19
|
-
console.log('[BerifyMe React Fix] ✅ React instance set successfully');
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
catch (e) {
|
|
23
|
-
console.warn('[BerifyMe React Fix] Failed to set React instance via setReactInstance:', e);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
// Method 2: Monkey patch React globals
|
|
27
|
-
try {
|
|
28
|
-
const React = require('react');
|
|
29
|
-
const ReactDOM = require('react-dom');
|
|
30
|
-
const createRoot = require('react-dom/client').createRoot;
|
|
31
|
-
// Store original globals
|
|
32
|
-
const originalReact = window.React;
|
|
33
|
-
const originalReactDOM = window.ReactDOM;
|
|
34
|
-
// Set our React instance as global
|
|
35
|
-
window.React = React;
|
|
36
|
-
window.ReactDOM = ReactDOM;
|
|
37
|
-
window.ReactDOMClient = { createRoot };
|
|
38
|
-
console.log('[BerifyMe React Fix] ✅ React globals patched successfully');
|
|
39
|
-
// Restore original globals after a delay
|
|
40
|
-
setTimeout(() => {
|
|
41
|
-
if (originalReact)
|
|
42
|
-
window.React = originalReact;
|
|
43
|
-
if (originalReactDOM)
|
|
44
|
-
window.ReactDOM = originalReactDOM;
|
|
45
|
-
console.log('[BerifyMe React Fix] Original React globals restored');
|
|
46
|
-
}, 1000);
|
|
47
|
-
}
|
|
48
|
-
catch (e) {
|
|
49
|
-
console.warn('[BerifyMe React Fix] Failed to patch React globals:', e);
|
|
50
|
-
}
|
|
51
|
-
// Method 3: Try to patch the BerifyMe modal component
|
|
52
|
-
try {
|
|
53
|
-
if (window.BerifyMeSDK.modal) {
|
|
54
|
-
const originalModal = window.BerifyMeSDK.modal;
|
|
55
|
-
const React = require('react');
|
|
56
|
-
// Create a wrapper that uses our React instance
|
|
57
|
-
window.BerifyMeSDK.modal = (props) => {
|
|
58
|
-
return React.createElement(originalModal, props);
|
|
59
|
-
};
|
|
60
|
-
console.log('[BerifyMe React Fix] ✅ BerifyMe modal component patched');
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
catch (e) {
|
|
64
|
-
console.warn('[BerifyMe React Fix] Failed to patch BerifyMe modal:', e);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
// Retry after a short delay
|
|
69
|
-
setTimeout(checkBerifyMe, 100);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
checkBerifyMe();
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
console.error('[BerifyMe React Fix] Error applying React instance fix:', error);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
// Auto-apply the fix when this module is loaded
|
|
79
|
-
if (typeof window !== 'undefined') {
|
|
80
|
-
fixBerifyMeReactInstance();
|
|
81
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* React Instance Check Utility
|
|
3
|
-
*
|
|
4
|
-
* This utility helps prevent React version conflicts by ensuring
|
|
5
|
-
* the SDK uses the same React instance as the host application.
|
|
6
|
-
*/
|
|
7
|
-
export declare function checkReactInstance(): void;
|
|
8
|
-
export declare function ensureReactCompatibility(): void;
|
|
9
|
-
//# sourceMappingURL=reactInstanceCheck.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reactInstanceCheck.d.ts","sourceRoot":"","sources":["../../../src/core/utils/reactInstanceCheck.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,wBAAgB,kBAAkB,IAAI,IAAI,CAoCzC;AAED,wBAAgB,wBAAwB,IAAI,IAAI,CAG/C"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* React Instance Check Utility
|
|
3
|
-
*
|
|
4
|
-
* This utility helps prevent React version conflicts by ensuring
|
|
5
|
-
* the SDK uses the same React instance as the host application.
|
|
6
|
-
*/
|
|
7
|
-
let reactInstanceCheckPerformed = false;
|
|
8
|
-
export function checkReactInstance() {
|
|
9
|
-
if (reactInstanceCheckPerformed) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
try {
|
|
13
|
-
// Check if React is available globally
|
|
14
|
-
const globalReact = window.React;
|
|
15
|
-
const globalReactDOM = window.ReactDOM;
|
|
16
|
-
if (globalReact && globalReactDOM) {
|
|
17
|
-
console.log('[NxtlinqAIAgent] Using global React instance from host application');
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
// Check if we're in a module environment
|
|
21
|
-
if (typeof require !== 'undefined') {
|
|
22
|
-
try {
|
|
23
|
-
const react = require('react');
|
|
24
|
-
const reactDOM = require('react-dom');
|
|
25
|
-
if (react && reactDOM) {
|
|
26
|
-
console.log('[NxtlinqAIAgent] Using React instance from module system');
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
catch (e) {
|
|
31
|
-
// Module system not available or React not found
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
console.warn('[NxtlinqAIAgent] React instance check completed - using bundled React');
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
console.error('[NxtlinqAIAgent] React instance check failed:', error);
|
|
38
|
-
}
|
|
39
|
-
finally {
|
|
40
|
-
reactInstanceCheckPerformed = true;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
export function ensureReactCompatibility() {
|
|
44
|
-
// This function can be extended to perform more compatibility checks
|
|
45
|
-
checkReactInstance();
|
|
46
|
-
}
|
package/dist/setupTests.d.ts
DELETED
package/dist/setupTests.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setupTests.d.ts","sourceRoot":"","sources":["../src/setupTests.ts"],"names":[],"mappings":"AACA,OAAO,2BAA2B,CAAC"}
|
package/dist/setupTests.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// Test setup file for Jest
|
|
2
|
-
import '@testing-library/jest-dom';
|
|
3
|
-
// Mock window.open for URL tests
|
|
4
|
-
Object.defineProperty(window, 'open', {
|
|
5
|
-
writable: true,
|
|
6
|
-
value: jest.fn(),
|
|
7
|
-
});
|
|
8
|
-
// Mock console methods to avoid noise in tests
|
|
9
|
-
global.console = {
|
|
10
|
-
...console,
|
|
11
|
-
log: jest.fn(),
|
|
12
|
-
debug: jest.fn(),
|
|
13
|
-
info: jest.fn(),
|
|
14
|
-
warn: jest.fn(),
|
|
15
|
-
error: jest.fn(),
|
|
16
|
-
};
|