@transfergratis/react-native-sdk 0.1.18 → 0.1.20
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 +17 -617
- package/build/components/KYCElements/SelfieCaptureTemplate.d.ts.map +1 -1
- package/build/components/KYCElements/SelfieCaptureTemplate.js +3 -3
- package/build/components/KYCElements/SelfieCaptureTemplate.js.map +1 -1
- package/build/components/TemplateKYCExample.d.ts +1 -1
- package/build/components/TemplateKYCExample.d.ts.map +1 -1
- package/build/components/TemplateKYCExample.js.map +1 -1
- package/build/hooks/useTemplateKYCFlow.d.ts.map +1 -1
- package/build/hooks/useTemplateKYCFlow.js +3 -2
- package/build/hooks/useTemplateKYCFlow.js.map +1 -1
- package/build/index.d.ts +1 -31
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -41
- package/build/index.js.map +1 -1
- package/build/modules/api/KYCService.d.ts.map +1 -1
- package/build/modules/api/KYCService.js +3 -3
- package/build/modules/api/KYCService.js.map +1 -1
- package/build/modules/api/types.d.ts +1 -0
- package/build/modules/api/types.d.ts.map +1 -1
- package/build/modules/api/types.js.map +1 -1
- package/package.json +1 -1
- package/src/components/KYCElements/SelfieCaptureTemplate.tsx +3 -4
- package/src/components/TemplateKYCExample.tsx +1 -1
- package/src/hooks/useTemplateKYCFlow.tsx +4 -3
- package/src/index.ts +2 -66
- package/src/modules/api/KYCService.ts +5 -4
- package/src/modules/api/types.ts +1 -0
package/README.md
CHANGED
|
@@ -77,633 +77,33 @@ iOS permissions are also automatically handled by the Expo plugin.
|
|
|
77
77
|
|
|
78
78
|
The recommended approach is to use the JSON template system to configure your KYC flow:
|
|
79
79
|
|
|
80
|
-
```tsx
|
|
81
|
-
import React from 'react';
|
|
82
|
-
import { TemplateKYCFlow, KYCTemplate, VerificationState } from '@transfergratis/react-native-sdk';
|
|
83
|
-
|
|
84
|
-
const myKYCTemplate: KYCTemplate = {
|
|
85
|
-
id: 1,
|
|
86
|
-
name: {
|
|
87
|
-
en: "Identity Verification",
|
|
88
|
-
fr: "Vérification d'Identité"
|
|
89
|
-
},
|
|
90
|
-
description: {
|
|
91
|
-
en: "Complete identity verification flow",
|
|
92
|
-
fr: "Processus complet de vérification d'identité"
|
|
93
|
-
},
|
|
94
|
-
version: "1.0.0",
|
|
95
|
-
components: [
|
|
96
|
-
{
|
|
97
|
-
id: 6,
|
|
98
|
-
type: "country_selection",
|
|
99
|
-
order: 1,
|
|
100
|
-
labels: {
|
|
101
|
-
en: "Select your country",
|
|
102
|
-
fr: "Sélectionnez votre pays"
|
|
103
|
-
},
|
|
104
|
-
instructions: {
|
|
105
|
-
en: "Choose your country of residence.",
|
|
106
|
-
fr: "Choisissez votre pays de résidence."
|
|
107
|
-
},
|
|
108
|
-
ui: {
|
|
109
|
-
icon: "country-icon.png",
|
|
110
|
-
themeColor: "#2DBD60",
|
|
111
|
-
buttonText: { en: "Confirm", fr: "Confirmer" }
|
|
112
|
-
},
|
|
113
|
-
config: {
|
|
114
|
-
allowed_countries: ["CM", "NG", "CI", "KE", "GH"],
|
|
115
|
-
default_country: "CM",
|
|
116
|
-
required: true
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
id: 1,
|
|
121
|
-
type: "id_card",
|
|
122
|
-
order: 2,
|
|
123
|
-
templateId: 1,
|
|
124
|
-
labels: {
|
|
125
|
-
front: {
|
|
126
|
-
en: "Upload front of ID card",
|
|
127
|
-
fr: "Téléversez le recto de votre carte d'identité"
|
|
128
|
-
},
|
|
129
|
-
back: {
|
|
130
|
-
en: "Upload back of ID card",
|
|
131
|
-
fr: "Téléversez le verso de votre carte d'identité"
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
instructions: {
|
|
135
|
-
front: {
|
|
136
|
-
en: "Take a clear photo of the front of your ID.",
|
|
137
|
-
fr: "Prenez une photo nette du recto de votre pièce."
|
|
138
|
-
},
|
|
139
|
-
back: {
|
|
140
|
-
en: "Take a clear photo of the back of your ID.",
|
|
141
|
-
fr: "Prenez une photo nette du verso de votre pièce."
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
ui: {
|
|
145
|
-
front: {
|
|
146
|
-
themeColor: "#2DBD60",
|
|
147
|
-
buttonText: { en: "Next", fr: "Suivant" }
|
|
148
|
-
},
|
|
149
|
-
back: {
|
|
150
|
-
themeColor: "#2DBD60",
|
|
151
|
-
buttonText: { en: "Next", fr: "Suivant" }
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
config: {
|
|
155
|
-
sides: ["front", "back"],
|
|
156
|
-
allowed_formats: ["jpg", "png"],
|
|
157
|
-
max_size_mb: 5,
|
|
158
|
-
document_types: ["identity_card", "passport", "drivers_licence", "national_id"],
|
|
159
|
-
bbox_configs: {
|
|
160
|
-
identity_card: {
|
|
161
|
-
xMin: 20,
|
|
162
|
-
yMin: 140,
|
|
163
|
-
xMax: 370,
|
|
164
|
-
yMax: 340,
|
|
165
|
-
borderColor: "#2DBD60",
|
|
166
|
-
borderWidth: 4,
|
|
167
|
-
cornerRadius: 12
|
|
168
|
-
},
|
|
169
|
-
passport: {
|
|
170
|
-
xMin: 15,
|
|
171
|
-
yMin: 130,
|
|
172
|
-
xMax: 375,
|
|
173
|
-
yMax: 350,
|
|
174
|
-
borderColor: "#007AFF",
|
|
175
|
-
borderWidth: 4,
|
|
176
|
-
cornerRadius: 8
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
id: 3,
|
|
183
|
-
type: "selfie",
|
|
184
|
-
order: 3,
|
|
185
|
-
templateId: 1,
|
|
186
|
-
labels: {
|
|
187
|
-
en: "Take selfies from different angles",
|
|
188
|
-
fr: "Prenez des selfies sous différents angles"
|
|
189
|
-
},
|
|
190
|
-
instructions: {
|
|
191
|
-
en: "Take selfies from front, left, and right angles.",
|
|
192
|
-
fr: "Prenez des selfies de face, profil gauche et profil droit."
|
|
193
|
-
},
|
|
194
|
-
ui: {
|
|
195
|
-
icon: "selfie-icon.png",
|
|
196
|
-
themeColor: "#2DBD60",
|
|
197
|
-
buttonText: { en: "Next", fr: "Suivant" }
|
|
198
|
-
},
|
|
199
|
-
config: {
|
|
200
|
-
liveness_check: true,
|
|
201
|
-
max_attempts: 3,
|
|
202
|
-
orientations: ["center", "left", "right"]
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
]
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
export default function App() {
|
|
209
|
-
const handleComplete = (result: VerificationState) => {
|
|
210
|
-
console.log('KYC completed:', result);
|
|
211
|
-
// Process verification result
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
const handleError = (error: string) => {
|
|
215
|
-
console.error('KYC error:', error);
|
|
216
|
-
// Handle error
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
const handleCancel = () => {
|
|
220
|
-
console.log('KYC cancelled');
|
|
221
|
-
// Handle cancellation
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
return (
|
|
225
|
-
<TemplateKYCFlow
|
|
226
|
-
template={myKYCTemplate}
|
|
227
|
-
onComplete={handleComplete}
|
|
228
|
-
onError={handleError}
|
|
229
|
-
onCancel={handleCancel}
|
|
230
|
-
language="en" // or "fr" for French
|
|
231
|
-
API_KEY="your-api-key-here"
|
|
232
|
-
/>
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
### Basic Usage (Simple Component)
|
|
238
|
-
|
|
239
|
-
For simple usage without templates:
|
|
240
|
-
|
|
241
80
|
```tsx
|
|
242
81
|
import React from 'react';
|
|
243
82
|
import { LauchTransferGratisKYC } from '@transfergratis/react-native-sdk';
|
|
244
83
|
|
|
245
84
|
export default function App() {
|
|
246
85
|
return (
|
|
247
|
-
<LauchTransferGratisKYC
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
console.log('Photo captured:', result.path);
|
|
265
|
-
setShowCamera(false);
|
|
266
|
-
} else {
|
|
267
|
-
console.error('Capture failed:', result.error);
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
return (
|
|
272
|
-
<View style={{ flex: 1 }}>
|
|
273
|
-
<EnhancedCameraView
|
|
274
|
-
showCamera={showCamera}
|
|
275
|
-
cameraType="front"
|
|
276
|
-
instructions="Position your face in the frame"
|
|
277
|
-
onCapture={handleCapture}
|
|
278
|
-
onError={(error) => console.error('Camera error:', error)}
|
|
279
|
-
onClose={() => setShowCamera(false)}
|
|
280
|
-
quality="high"
|
|
281
|
-
enableFlash={true}
|
|
282
|
-
showCaptureButton={true}
|
|
283
|
-
showSwitchCamera={true}
|
|
284
|
-
/>
|
|
285
|
-
</View>
|
|
286
|
-
);
|
|
287
|
-
}
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
## 📚 API Reference
|
|
291
|
-
|
|
292
|
-
### Main Components
|
|
293
|
-
|
|
294
|
-
#### `TemplateKYCFlow`
|
|
295
|
-
|
|
296
|
-
The main component for JSON template-based KYC flows.
|
|
297
|
-
|
|
298
|
-
```tsx
|
|
299
|
-
interface TemplateKYCFlowProps {
|
|
300
|
-
template: KYCTemplate;
|
|
301
|
-
onComplete?: (data: VerificationState) => void;
|
|
302
|
-
onError?: (error: string) => void;
|
|
303
|
-
onCancel?: () => void;
|
|
304
|
-
language?: string; // 'fr' | 'en'
|
|
305
|
-
API_KEY?: string;
|
|
306
|
-
}
|
|
307
|
-
```
|
|
308
|
-
|
|
309
|
-
#### `EnhancedCameraView`
|
|
310
|
-
|
|
311
|
-
Advanced camera component with full Vision Camera integration.
|
|
312
|
-
|
|
313
|
-
```tsx
|
|
314
|
-
interface EnhancedCameraViewProps {
|
|
315
|
-
instructions?: string;
|
|
316
|
-
showCamera: boolean;
|
|
317
|
-
cameraType?: 'front' | 'back';
|
|
318
|
-
style?: ViewStyle;
|
|
319
|
-
onCapture?: (result: CaptureResult) => void;
|
|
320
|
-
onError?: (event: { message: string }) => void;
|
|
321
|
-
onClose?: () => void;
|
|
322
|
-
enableFlash?: boolean;
|
|
323
|
-
enableHdr?: boolean;
|
|
324
|
-
quality?: 'low' | 'medium' | 'high';
|
|
325
|
-
showCaptureButton?: boolean;
|
|
326
|
-
showSwitchCamera?: boolean;
|
|
327
|
-
overlayComponent?: React.ReactNode;
|
|
328
|
-
bbox?: IBbox;
|
|
329
|
-
canFlip?: boolean;
|
|
330
|
-
enableVideo?: boolean;
|
|
331
|
-
isRecording?: boolean;
|
|
332
|
-
onVideoRecordingStart?: () => void;
|
|
333
|
-
onVideoRecordingStop?: () => void;
|
|
334
|
-
videoDuration?: number;
|
|
335
|
-
onSilentCapture?: (result: ISilentCaptureResult) => void;
|
|
336
|
-
silentCaptureResult?: ISilentCaptureResult;
|
|
337
|
-
}
|
|
338
|
-
```
|
|
339
|
-
|
|
340
|
-
#### `VisionCameraView`
|
|
341
|
-
|
|
342
|
-
Simplified camera component for basic use cases.
|
|
343
|
-
|
|
344
|
-
```tsx
|
|
345
|
-
interface VisionCameraViewProps {
|
|
346
|
-
instructions?: string;
|
|
347
|
-
showCamera: boolean;
|
|
348
|
-
cameraType?: 'front' | 'back';
|
|
349
|
-
style?: ViewStyle;
|
|
350
|
-
onCapture?: (result: CaptureResult) => void;
|
|
351
|
-
onError?: (event: { message: string }) => void;
|
|
352
|
-
onPermissionError?: () => void;
|
|
353
|
-
enableHdr?: boolean;
|
|
354
|
-
enableNightMode?: boolean;
|
|
355
|
-
quality?: 'low' | 'medium' | 'high';
|
|
356
|
-
}
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
#### Specialized KYC Components
|
|
360
|
-
|
|
361
|
-
##### `IDCardCapture`
|
|
362
|
-
|
|
363
|
-
Identity document capture with automatic validation.
|
|
364
|
-
|
|
365
|
-
```tsx
|
|
366
|
-
interface IDCardCaptureProps {
|
|
367
|
-
component: TemplateComponent;
|
|
368
|
-
value?: Record<string, IIDCardPayload>;
|
|
369
|
-
onValueChange: (value: Record<string, IIDCardPayload | string>) => void;
|
|
370
|
-
error?: string;
|
|
371
|
-
language?: string;
|
|
372
|
-
currentSide?: string;
|
|
373
|
-
}
|
|
374
|
-
```
|
|
375
|
-
|
|
376
|
-
##### `SelfieCaptureTemplate`
|
|
377
|
-
|
|
378
|
-
Selfie capture with liveness detection.
|
|
379
|
-
|
|
380
|
-
```tsx
|
|
381
|
-
interface SelfieCaptureTemplateProps {
|
|
382
|
-
component: TemplateComponent;
|
|
383
|
-
value?: any;
|
|
384
|
-
onValueChange: (value: any) => void;
|
|
385
|
-
error?: string;
|
|
386
|
-
language?: string;
|
|
387
|
-
}
|
|
388
|
-
```
|
|
389
|
-
|
|
390
|
-
##### `FileUploadTemplate`
|
|
391
|
-
|
|
392
|
-
File upload with validation.
|
|
393
|
-
|
|
394
|
-
```tsx
|
|
395
|
-
interface FileUploadTemplateProps {
|
|
396
|
-
component: TemplateComponent;
|
|
397
|
-
value?: any;
|
|
398
|
-
onValueChange: (value: any) => void;
|
|
399
|
-
error?: string;
|
|
400
|
-
language?: string;
|
|
401
|
-
}
|
|
402
|
-
```
|
|
403
|
-
|
|
404
|
-
##### `LocationCaptureTemplate`
|
|
405
|
-
|
|
406
|
-
GPS location capture.
|
|
407
|
-
|
|
408
|
-
```tsx
|
|
409
|
-
interface LocationCaptureTemplateProps {
|
|
410
|
-
component: TemplateComponent;
|
|
411
|
-
value?: LocationData;
|
|
412
|
-
onValueChange: (value: LocationData) => void;
|
|
413
|
-
error?: string;
|
|
414
|
-
language?: string;
|
|
415
|
-
}
|
|
416
|
-
```
|
|
417
|
-
|
|
418
|
-
##### `CountrySelectionTemplate`
|
|
419
|
-
|
|
420
|
-
Country selection with region mapping.
|
|
421
|
-
|
|
422
|
-
```tsx
|
|
423
|
-
interface CountrySelectionTemplateProps {
|
|
424
|
-
component: TemplateComponent;
|
|
425
|
-
value?: Country;
|
|
426
|
-
onValueChange: (value: Country) => void;
|
|
427
|
-
error?: string;
|
|
428
|
-
language?: string;
|
|
429
|
-
}
|
|
430
|
-
```
|
|
431
|
-
|
|
432
|
-
#### `OrientationVideoCapture`
|
|
433
|
-
|
|
434
|
-
Component for liveness detection via orientation video.
|
|
435
|
-
|
|
436
|
-
```tsx
|
|
437
|
-
interface OrientationVideoCaptureProps {
|
|
438
|
-
config: OrientationVideoConfig;
|
|
439
|
-
onComplete: (result: OrientationVideoResult) => void;
|
|
440
|
-
onError: (error: string) => void;
|
|
441
|
-
kycService: KYCService;
|
|
442
|
-
}
|
|
443
|
-
```
|
|
444
|
-
|
|
445
|
-
### Modules
|
|
446
|
-
|
|
447
|
-
#### `KYCService`
|
|
448
|
-
|
|
449
|
-
Main service for KYC API calls.
|
|
450
|
-
|
|
451
|
-
```tsx
|
|
452
|
-
import { KYCService } from '@transfergratis/react-native-sdk';
|
|
453
|
-
|
|
454
|
-
const kycService = new KYCService('https://api.yourdomain.com', 'your-api-key');
|
|
455
|
-
|
|
456
|
-
// Create a new session
|
|
457
|
-
const session = await kycService.newSession(token);
|
|
458
|
-
|
|
459
|
-
// Submit a verification step
|
|
460
|
-
await kycService.verificationSession({
|
|
461
|
-
session_id: session.id,
|
|
462
|
-
step: 'id_card',
|
|
463
|
-
data: { /* step data */ },
|
|
464
|
-
templateId: 1,
|
|
465
|
-
action: 'submit'
|
|
466
|
-
});
|
|
467
|
-
|
|
468
|
-
// Get verification result
|
|
469
|
-
const result = await kycService.getVerificationResult(session_id);
|
|
470
|
-
```
|
|
471
|
-
|
|
472
|
-
#### `VisionCameraModule`
|
|
473
|
-
|
|
474
|
-
Module for camera operations and permissions.
|
|
475
|
-
|
|
476
|
-
```tsx
|
|
477
|
-
import { VisionCameraModule } from '@transfergratis/react-native-sdk';
|
|
478
|
-
|
|
479
|
-
// Request permissions
|
|
480
|
-
const hasPermissions = await VisionCameraModule.requestAllPermissions();
|
|
481
|
-
|
|
482
|
-
// Check permissions
|
|
483
|
-
const hasAllPermissions = await VisionCameraModule.hasAllPermissions();
|
|
484
|
-
|
|
485
|
-
// Get camera devices
|
|
486
|
-
const frontCamera = await VisionCameraModule.getFrontCameraDevice();
|
|
487
|
-
const backCamera = await VisionCameraModule.getBackCameraDevice();
|
|
488
|
-
|
|
489
|
-
// Check camera availability
|
|
490
|
-
const isAvailable = await VisionCameraModule.isCameraAvailable();
|
|
491
|
-
```
|
|
492
|
-
|
|
493
|
-
### Hooks
|
|
494
|
-
|
|
495
|
-
#### `useTemplateKYCFlow`
|
|
496
|
-
|
|
497
|
-
Hook for managing template-based KYC flow.
|
|
498
|
-
|
|
499
|
-
```tsx
|
|
500
|
-
import { useTemplateKYCFlow, TemplateKYCFlowProvider } from '@transfergratis/react-native-sdk';
|
|
501
|
-
|
|
502
|
-
// In your component
|
|
503
|
-
const { state, actions, currentComponent, progress } = useTemplateKYCFlow();
|
|
504
|
-
```
|
|
505
|
-
|
|
506
|
-
#### `useOrientationVideo`
|
|
507
|
-
|
|
508
|
-
Hook for orientation video capture.
|
|
509
|
-
|
|
510
|
-
```tsx
|
|
511
|
-
import { useOrientationVideo, KYCService } from '@transfergratis/react-native-sdk';
|
|
512
|
-
|
|
513
|
-
const kycService = new KYCService('https://api.yourdomain.com', 'your-api-key');
|
|
514
|
-
const { state, actions } = useOrientationVideo(kycService, {
|
|
515
|
-
duration: 10,
|
|
516
|
-
maxRetakes: 2,
|
|
517
|
-
});
|
|
518
|
-
```
|
|
519
|
-
|
|
520
|
-
#### `useLocation`
|
|
521
|
-
|
|
522
|
-
Hook for location capture.
|
|
523
|
-
|
|
524
|
-
```tsx
|
|
525
|
-
import { useLocation } from '@transfergratis/react-native-sdk';
|
|
526
|
-
|
|
527
|
-
const { location, error, requestPermission, getCurrentLocation } = useLocation();
|
|
528
|
-
```
|
|
529
|
-
|
|
530
|
-
## 🎨 Customization
|
|
531
|
-
|
|
532
|
-
### Custom Overlay Example
|
|
533
|
-
|
|
534
|
-
```tsx
|
|
535
|
-
import React from 'react';
|
|
536
|
-
import { View, Text, StyleSheet } from 'react-native';
|
|
537
|
-
import { EnhancedCameraView } from '@transfergratis/react-native-sdk';
|
|
538
|
-
|
|
539
|
-
export default function CustomCameraExample() {
|
|
540
|
-
const customOverlay = (
|
|
541
|
-
<View style={styles.overlay}>
|
|
542
|
-
<View style={styles.faceFrame} />
|
|
543
|
-
<Text style={styles.instruction}>
|
|
544
|
-
Align your face with the frame
|
|
545
|
-
</Text>
|
|
546
|
-
</View>
|
|
547
|
-
);
|
|
548
|
-
|
|
549
|
-
return (
|
|
550
|
-
<EnhancedCameraView
|
|
551
|
-
showCamera={true}
|
|
552
|
-
overlayComponent={customOverlay}
|
|
553
|
-
onCapture={(result) => console.log(result)}
|
|
554
|
-
/>
|
|
86
|
+
<LauchTransferGratisKYC
|
|
87
|
+
onComplete={(data:VerificationState) => {
|
|
88
|
+
Alert.alert('Template KYC completed');
|
|
89
|
+
setShowTemplateKYC(false);
|
|
90
|
+
console.log('Template KYC completed', JSON.stringify(data, null, 2));
|
|
91
|
+
}}
|
|
92
|
+
onCancel={() => {
|
|
93
|
+
setShowTemplateKYC(false);
|
|
94
|
+
Alert.alert('Template KYC cancelled');
|
|
95
|
+
}}
|
|
96
|
+
onError={(error) => {
|
|
97
|
+
Alert.alert('Template KYC error', error);
|
|
98
|
+
setShowTemplateKYC(false);
|
|
99
|
+
}}
|
|
100
|
+
language="en"
|
|
101
|
+
API_KEY={undefined} // for test env leave this blanc
|
|
102
|
+
/>
|
|
555
103
|
);
|
|
556
104
|
}
|
|
557
|
-
|
|
558
|
-
const styles = StyleSheet.create({
|
|
559
|
-
overlay: {
|
|
560
|
-
position: 'absolute',
|
|
561
|
-
top: 0,
|
|
562
|
-
left: 0,
|
|
563
|
-
right: 0,
|
|
564
|
-
bottom: 0,
|
|
565
|
-
justifyContent: 'center',
|
|
566
|
-
alignItems: 'center',
|
|
567
|
-
pointerEvents: 'none',
|
|
568
|
-
},
|
|
569
|
-
faceFrame: {
|
|
570
|
-
width: 250,
|
|
571
|
-
height: 300,
|
|
572
|
-
borderWidth: 3,
|
|
573
|
-
borderColor: '#4CAF50',
|
|
574
|
-
borderRadius: 125,
|
|
575
|
-
},
|
|
576
|
-
instruction: {
|
|
577
|
-
color: 'white',
|
|
578
|
-
fontSize: 16,
|
|
579
|
-
textAlign: 'center',
|
|
580
|
-
marginTop: 20,
|
|
581
|
-
backgroundColor: 'rgba(0, 0, 0, 0.7)',
|
|
582
|
-
padding: 10,
|
|
583
|
-
borderRadius: 8,
|
|
584
|
-
},
|
|
585
|
-
});
|
|
586
|
-
```
|
|
587
|
-
|
|
588
|
-
### Orientation Video Processing
|
|
589
|
-
|
|
590
|
-
The SDK includes advanced liveness detection through orientation video processing. This feature captures and analyzes short videos to verify that a real person is present during the KYC process.
|
|
591
|
-
|
|
592
|
-
#### Basic Usage
|
|
593
|
-
|
|
594
|
-
```tsx
|
|
595
|
-
import React from 'react';
|
|
596
|
-
import { OrientationVideoCapture, KYCService } from '@transfergratis/react-native-sdk';
|
|
597
|
-
|
|
598
|
-
const kycService = new KYCService('https://api.yourdomain.com', 'your-api-key');
|
|
599
|
-
|
|
600
|
-
export default function LivenessDetection() {
|
|
601
|
-
return (
|
|
602
|
-
<OrientationVideoCapture
|
|
603
|
-
config={{
|
|
604
|
-
duration: 10,
|
|
605
|
-
orientations: ['center', 'left', 'right'],
|
|
606
|
-
instructions: {
|
|
607
|
-
center: 'Look straight ahead at the camera',
|
|
608
|
-
left: 'Turn your head to the left',
|
|
609
|
-
right: 'Turn your head to the right',
|
|
610
|
-
},
|
|
611
|
-
showPreview: true,
|
|
612
|
-
allowRetake: true,
|
|
613
|
-
maxRetakes: 3,
|
|
614
|
-
}}
|
|
615
|
-
onComplete={(result) => {
|
|
616
|
-
console.log('Liveness detection result:', result);
|
|
617
|
-
}}
|
|
618
|
-
onError={(error) => {
|
|
619
|
-
console.error('Liveness detection error:', error);
|
|
620
|
-
}}
|
|
621
|
-
kycService={kycService}
|
|
622
|
-
/>
|
|
623
|
-
);
|
|
624
|
-
}
|
|
625
|
-
```
|
|
626
|
-
|
|
627
|
-
#### Using the Hook
|
|
628
|
-
|
|
629
|
-
```tsx
|
|
630
|
-
import React from 'react';
|
|
631
|
-
import { View, Text, Button } from 'react-native';
|
|
632
|
-
import { useOrientationVideo, KYCService } from '@transfergratis/react-native-sdk';
|
|
633
|
-
|
|
634
|
-
export default function LivenessDetectionHook() {
|
|
635
|
-
const kycService = new KYCService('https://api.yourdomain.com', 'your-api-key');
|
|
636
|
-
|
|
637
|
-
const { state, actions } = useOrientationVideo(kycService, {
|
|
638
|
-
duration: 10,
|
|
639
|
-
maxRetakes: 2,
|
|
640
|
-
});
|
|
641
|
-
|
|
642
|
-
return (
|
|
643
|
-
<View>
|
|
644
|
-
{state.isRecording && <Text>Recording...</Text>}
|
|
645
|
-
{state.isProcessing && <Text>Processing...</Text>}
|
|
646
|
-
{state.error && <Text>Error: {state.error}</Text>}
|
|
647
|
-
|
|
648
|
-
<Button title="Start Recording" onPress={actions.startRecording} />
|
|
649
|
-
<Button title="Process Video" onPress={actions.processVideo} />
|
|
650
|
-
</View>
|
|
651
|
-
);
|
|
652
|
-
}
|
|
653
|
-
```
|
|
654
|
-
|
|
655
|
-
#### API Response Format
|
|
656
|
-
|
|
657
|
-
Orientation video processing returns detailed results for each face orientation:
|
|
658
|
-
|
|
659
|
-
```json
|
|
660
|
-
{
|
|
661
|
-
"center": {
|
|
662
|
-
"captured": true,
|
|
663
|
-
"frame": 35
|
|
664
|
-
},
|
|
665
|
-
"right": {
|
|
666
|
-
"captured": true,
|
|
667
|
-
"frame": 98
|
|
668
|
-
},
|
|
669
|
-
"left": {
|
|
670
|
-
"captured": false,
|
|
671
|
-
"frame": null
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
```
|
|
675
|
-
|
|
676
|
-
## 🔧 Plugin Configuration
|
|
677
|
-
|
|
678
|
-
The SDK includes an Expo config plugin for automatic setup of native permissions and dependencies.
|
|
679
|
-
|
|
680
|
-
### Plugin Options
|
|
681
|
-
|
|
682
|
-
```tsx
|
|
683
|
-
interface VisionCameraPluginProps {
|
|
684
|
-
cameraPermissionText?: string;
|
|
685
|
-
microphonePermissionText?: string;
|
|
686
|
-
enableFrameProcessors?: boolean;
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
interface LocationPluginProps {
|
|
690
|
-
locationPermissionText?: string;
|
|
691
|
-
locationWhenInUsePermissionText?: string;
|
|
692
|
-
enableBackgroundLocation?: boolean;
|
|
693
|
-
}
|
|
694
105
|
```
|
|
695
106
|
|
|
696
|
-
### Manual Plugin Usage
|
|
697
|
-
|
|
698
|
-
```tsx
|
|
699
|
-
import { withVisionCamera } from '@transfergratis/react-native-sdk/plugin';
|
|
700
|
-
|
|
701
|
-
export default withVisionCamera(config, {
|
|
702
|
-
cameraPermissionText: "Custom camera permission message",
|
|
703
|
-
microphonePermissionText: "Custom microphone permission message",
|
|
704
|
-
enableFrameProcessors: false
|
|
705
|
-
});
|
|
706
|
-
```
|
|
707
107
|
|
|
708
108
|
## 🛠️ Development
|
|
709
109
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelfieCaptureTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/KYCElements/SelfieCaptureTemplate.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAA8F,MAAM,uBAAuB,CAAC;AAUtJ,UAAU,aAAa;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AACD,UAAU,0BAA0B;IAClC,SAAS,EAAE,iBAAiB,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,SAAS,CAAC;IACjD,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAAC,KAAK,IAAI,CAAC;IACvE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,
|
|
1
|
+
{"version":3,"file":"SelfieCaptureTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/KYCElements/SelfieCaptureTemplate.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAA8F,MAAM,uBAAuB,CAAC;AAUtJ,UAAU,aAAa;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AACD,UAAU,0BAA0B;IAClC,SAAS,EAAE,iBAAiB,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,SAAS,CAAC;IACjD,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAAC,KAAK,IAAI,CAAC;IACvE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CA+UtE,CAAC"}
|
|
@@ -48,11 +48,11 @@ export const SelfieCaptureTemplate = ({ component, value, onValueChange, error,
|
|
|
48
48
|
const getOrientationLabel = (orientation) => {
|
|
49
49
|
switch (orientation) {
|
|
50
50
|
case 'center':
|
|
51
|
-
return state.currentLanguage === "en" ? "
|
|
51
|
+
return state.currentLanguage === "en" ? "Front Profil Selfie" : "Selfie de face";
|
|
52
52
|
case 'left':
|
|
53
|
-
return state.currentLanguage === "en" ? "
|
|
53
|
+
return state.currentLanguage === "en" ? "Left Profil Selfie" : "Selfie profil gauche";
|
|
54
54
|
case 'right':
|
|
55
|
-
return state.currentLanguage === "en" ? "
|
|
55
|
+
return state.currentLanguage === "en" ? "Rigth Profil Selfiee" : "Selfie profil droit";
|
|
56
56
|
default:
|
|
57
57
|
return getLocalizedText(component.labels);
|
|
58
58
|
}
|