omnipay-reactnative-sdk 1.2.2-beta.4 → 1.2.2-beta.6
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 +93 -43
- package/android/build.gradle +16 -15
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/omniretail/omnipay/OmnipayActivityPackage.java +2 -2
- package/android/src/main/java/com/omniretail/omnipay/OmnipayLivenessCameraView.java +153 -0
- package/android/src/main/java/com/omniretail/omnipay/OmnipayLivenessCameraViewManager.java +49 -0
- package/android/src/main/java/com/omniretail/omnipay/OmnipayLivenessModule.java +524 -0
- package/ios/OmnipayLivenessCameraView.h +15 -0
- package/ios/OmnipayLivenessCameraView.m +80 -0
- package/ios/OmnipayLivenessCameraViewManager.m +19 -0
- package/ios/OmnipayLivenessModule.h +38 -0
- package/ios/OmnipayLivenessModule.m +554 -0
- package/lib/commonjs/components/OmnipayProvider.js +2 -66
- package/lib/commonjs/components/OmnipayProvider.js.map +1 -1
- package/lib/commonjs/components/OmnipayView.js.map +1 -1
- package/lib/commonjs/components/biometrics/FaceVerification.js +252 -345
- package/lib/commonjs/components/biometrics/FaceVerification.js.map +1 -1
- package/lib/commonjs/components/biometrics/LivenessDetection.js +90 -198
- package/lib/commonjs/components/biometrics/LivenessDetection.js.map +1 -1
- package/lib/commonjs/components/biometrics/OmnipayLivenessCameraView.js +15 -0
- package/lib/commonjs/components/biometrics/OmnipayLivenessCameraView.js.map +1 -0
- package/lib/commonjs/components/biometrics/PermissionManager.js +279 -0
- package/lib/commonjs/components/biometrics/PermissionManager.js.map +1 -0
- package/lib/commonjs/components/biometrics/index.js +45 -0
- package/lib/commonjs/components/biometrics/index.js.map +1 -0
- package/lib/commonjs/components/biometrics/types.js +17 -0
- package/lib/commonjs/components/biometrics/types.js.map +1 -0
- package/lib/commonjs/components/views/BvnVerification.js.map +1 -1
- package/lib/commonjs/components/views/PaylaterAgreement.js.map +1 -1
- package/lib/commonjs/components/views/Registration.js.map +1 -1
- package/lib/commonjs/index.js +23 -18
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/components/OmnipayProvider.js +3 -67
- package/lib/module/components/OmnipayProvider.js.map +1 -1
- package/lib/module/components/OmnipayView.js.map +1 -1
- package/lib/module/components/biometrics/FaceVerification.js +254 -346
- package/lib/module/components/biometrics/FaceVerification.js.map +1 -1
- package/lib/module/components/biometrics/LivenessDetection.js +75 -197
- package/lib/module/components/biometrics/LivenessDetection.js.map +1 -1
- package/lib/module/components/biometrics/OmnipayLivenessCameraView.js +7 -0
- package/lib/module/components/biometrics/OmnipayLivenessCameraView.js.map +1 -0
- package/lib/module/components/biometrics/PermissionManager.js +272 -0
- package/lib/module/components/biometrics/PermissionManager.js.map +1 -0
- package/lib/module/components/biometrics/index.js +12 -0
- package/lib/module/components/biometrics/index.js.map +1 -0
- package/lib/module/components/biometrics/types.js +16 -0
- package/lib/module/components/biometrics/types.js.map +1 -0
- package/lib/module/components/views/BvnVerification.js.map +1 -1
- package/lib/module/components/views/PaylaterAgreement.js.map +1 -1
- package/lib/module/components/views/Registration.js.map +1 -1
- package/lib/module/index.js +5 -4
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/{src/components → components}/OmnipayProvider.d.ts +1 -1
- package/lib/typescript/components/OmnipayProvider.d.ts.map +1 -0
- package/lib/typescript/{src/components → components}/OmnipayView.d.ts +21 -20
- package/lib/typescript/components/OmnipayView.d.ts.map +1 -0
- package/lib/typescript/components/biometrics/FaceVerification.d.ts +11 -0
- package/lib/typescript/components/biometrics/FaceVerification.d.ts.map +1 -0
- package/lib/typescript/components/biometrics/LivenessDetection.d.ts +33 -0
- package/lib/typescript/components/biometrics/LivenessDetection.d.ts.map +1 -0
- package/lib/typescript/components/biometrics/OmnipayLivenessCameraView.d.ts +18 -0
- package/lib/typescript/components/biometrics/OmnipayLivenessCameraView.d.ts.map +1 -0
- package/lib/typescript/components/biometrics/PermissionManager.d.ts +58 -0
- package/lib/typescript/components/biometrics/PermissionManager.d.ts.map +1 -0
- package/lib/typescript/components/biometrics/index.d.ts +5 -0
- package/lib/typescript/components/biometrics/index.d.ts.map +1 -0
- package/lib/typescript/components/biometrics/types.d.ts +73 -0
- package/lib/typescript/components/biometrics/types.d.ts.map +1 -0
- package/lib/typescript/{src/components → components}/views/BvnVerification.d.ts +2 -1
- package/lib/typescript/components/views/BvnVerification.d.ts.map +1 -0
- package/lib/typescript/{src/components → components}/views/PaylaterAgreement.d.ts +2 -1
- package/lib/typescript/components/views/PaylaterAgreement.d.ts.map +1 -0
- package/lib/typescript/{src/components → components}/views/Registration.d.ts +2 -1
- package/lib/typescript/components/views/Registration.d.ts.map +1 -0
- package/lib/typescript/functions.d.ts.map +1 -0
- package/lib/typescript/hooks/useOmnipay.d.ts +28 -0
- package/lib/typescript/hooks/useOmnipay.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +7 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/lib/colors.d.ts.map +1 -0
- package/lib/typescript/lib/config.d.ts.map +1 -0
- package/omnipay-reactnative-sdk.podspec +32 -29
- package/package.json +15 -10
- package/src/components/OmnipayProvider.tsx +3 -106
- package/src/components/OmnipayView.tsx +1 -1
- package/src/components/biometrics/FaceVerification.tsx +291 -368
- package/src/components/biometrics/LivenessDetection.ts +113 -250
- package/src/components/biometrics/OmnipayLivenessCameraView.tsx +19 -0
- package/src/components/biometrics/PermissionManager.ts +317 -0
- package/src/components/biometrics/index.ts +11 -0
- package/src/components/biometrics/types.ts +86 -0
- package/src/components/views/BvnVerification.tsx +1 -1
- package/src/components/views/PaylaterAgreement.tsx +1 -1
- package/src/components/views/Registration.tsx +1 -1
- package/src/index.tsx +4 -15
- package/android/src/main/java/com/omniretail/omnipay/LivenessCameraViewManager.java +0 -116
- package/android/src/main/java/com/omniretail/omnipay/LivenessDetectionModule.java +0 -588
- package/ios/LivenessCameraView.h +0 -22
- package/ios/LivenessCameraView.m +0 -135
- package/ios/LivenessCameraViewManager.h +0 -12
- package/ios/LivenessCameraViewManager.m +0 -24
- package/ios/LivenessDetectionModule.h +0 -46
- package/ios/LivenessDetectionModule.m +0 -603
- package/lib/commonjs/components/biometrics/LivenessCameraView.js +0 -45
- package/lib/commonjs/components/biometrics/LivenessCameraView.js.map +0 -1
- package/lib/module/components/biometrics/LivenessCameraView.js +0 -39
- package/lib/module/components/biometrics/LivenessCameraView.js.map +0 -1
- package/lib/typescript/demo/src/App.d.ts +0 -3
- package/lib/typescript/demo/src/App.d.ts.map +0 -1
- package/lib/typescript/demo/src/Body.d.ts +0 -3
- package/lib/typescript/demo/src/Body.d.ts.map +0 -1
- package/lib/typescript/demo/src/NotificationsExample.d.ts +0 -4
- package/lib/typescript/demo/src/NotificationsExample.d.ts.map +0 -1
- package/lib/typescript/src/components/OmnipayProvider.d.ts.map +0 -1
- package/lib/typescript/src/components/OmnipayView.d.ts.map +0 -1
- package/lib/typescript/src/components/biometrics/FaceVerification.d.ts +0 -12
- package/lib/typescript/src/components/biometrics/FaceVerification.d.ts.map +0 -1
- package/lib/typescript/src/components/biometrics/LivenessCameraView.d.ts +0 -22
- package/lib/typescript/src/components/biometrics/LivenessCameraView.d.ts.map +0 -1
- package/lib/typescript/src/components/biometrics/LivenessDetection.d.ts +0 -73
- package/lib/typescript/src/components/biometrics/LivenessDetection.d.ts.map +0 -1
- package/lib/typescript/src/components/views/BvnVerification.d.ts.map +0 -1
- package/lib/typescript/src/components/views/PaylaterAgreement.d.ts.map +0 -1
- package/lib/typescript/src/components/views/Registration.d.ts.map +0 -1
- package/lib/typescript/src/functions.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useOmnipay.d.ts +0 -28
- package/lib/typescript/src/hooks/useOmnipay.d.ts.map +0 -1
- package/lib/typescript/src/index.d.ts +0 -8
- package/lib/typescript/src/index.d.ts.map +0 -1
- package/lib/typescript/src/lib/colors.d.ts.map +0 -1
- package/lib/typescript/src/lib/config.d.ts.map +0 -1
- package/src/components/biometrics/LivenessCameraView.tsx +0 -61
- /package/lib/typescript/{src/functions.d.ts → functions.d.ts} +0 -0
- /package/lib/typescript/{src/lib → lib}/colors.d.ts +0 -0
- /package/lib/typescript/{src/lib → lib}/config.d.ts +0 -0
|
@@ -1,305 +1,168 @@
|
|
|
1
1
|
import { NativeModules, NativeEventEmitter } from 'react-native';
|
|
2
|
+
import type {
|
|
3
|
+
LivenessConfig,
|
|
4
|
+
LivenessResult,
|
|
5
|
+
LivenessChallenge,
|
|
6
|
+
ChallengeResult,
|
|
7
|
+
LivenessEventCallbacks,
|
|
8
|
+
} from './types';
|
|
2
9
|
|
|
3
|
-
const {
|
|
10
|
+
const { OmnipayLivenessModule } = NativeModules;
|
|
4
11
|
|
|
5
|
-
// TypeScript interfaces matching PRD specifications
|
|
6
|
-
export interface LivenessDetectionConfig {
|
|
7
|
-
challenges: ('smile' | 'blink' | 'turn_left' | 'turn_right')[];
|
|
8
|
-
timeout?: number; // Optional timeout in milliseconds
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface ChallengeResult {
|
|
12
|
-
challenge: string;
|
|
13
|
-
success: boolean;
|
|
14
|
-
timestamp: number;
|
|
15
|
-
duration?: number; // Time taken to complete challenge
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface LivenessResult {
|
|
19
|
-
success: boolean;
|
|
20
|
-
screenshot?: string; // Base64 encoded image
|
|
21
|
-
challengeResults: ChallengeResult[];
|
|
22
|
-
error?: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Event callback types
|
|
26
|
-
export interface LivenessCallbacks {
|
|
27
|
-
onChallengeStart?: (challenge: string) => void;
|
|
28
|
-
onChallengeSuccess?: (challenge: string) => void;
|
|
29
|
-
onChallengeFailure?: (challenge: string, reason: string) => void;
|
|
30
|
-
onAllChallengesComplete?: (result: LivenessResult) => void;
|
|
31
|
-
onScreenshotCaptured?: (screenshot: string) => void;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Main LivenessDetection class
|
|
35
12
|
class LivenessDetectionManager {
|
|
36
|
-
private eventEmitter
|
|
37
|
-
private
|
|
38
|
-
private callbacks: LivenessCallbacks = {};
|
|
39
|
-
private isActive = false;
|
|
40
|
-
private challengeResults: ChallengeResult[] = [];
|
|
41
|
-
private startTime: number = 0;
|
|
13
|
+
private eventEmitter?: NativeEventEmitter;
|
|
14
|
+
private eventListeners: { [key: string]: any } = {};
|
|
42
15
|
|
|
43
16
|
constructor() {
|
|
44
|
-
if (
|
|
45
|
-
this.eventEmitter = new NativeEventEmitter(
|
|
46
|
-
this.setupEventListeners();
|
|
17
|
+
if (OmnipayLivenessModule) {
|
|
18
|
+
this.eventEmitter = new NativeEventEmitter(OmnipayLivenessModule);
|
|
47
19
|
}
|
|
48
20
|
}
|
|
49
21
|
|
|
50
|
-
private setupEventListeners() {
|
|
51
|
-
if (!this.eventEmitter) return;
|
|
52
|
-
|
|
53
|
-
// Challenge start event
|
|
54
|
-
this.listeners.push(
|
|
55
|
-
this.eventEmitter.addListener('onChallengeStart', (event) => {
|
|
56
|
-
console.log('Liveness: Challenge started -', event.challenge);
|
|
57
|
-
if (this.callbacks.onChallengeStart) {
|
|
58
|
-
this.callbacks.onChallengeStart(event.challenge);
|
|
59
|
-
}
|
|
60
|
-
})
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
// Challenge success event
|
|
64
|
-
this.listeners.push(
|
|
65
|
-
this.eventEmitter.addListener('onChallengeSuccess', (event) => {
|
|
66
|
-
console.log('Liveness: Challenge completed -', event.challenge);
|
|
67
|
-
|
|
68
|
-
// Record challenge result
|
|
69
|
-
const result: ChallengeResult = {
|
|
70
|
-
challenge: event.challenge,
|
|
71
|
-
success: true,
|
|
72
|
-
timestamp: Date.now(),
|
|
73
|
-
duration: Date.now() - this.startTime,
|
|
74
|
-
};
|
|
75
|
-
this.challengeResults.push(result);
|
|
76
|
-
|
|
77
|
-
if (this.callbacks.onChallengeSuccess) {
|
|
78
|
-
this.callbacks.onChallengeSuccess(event.challenge);
|
|
79
|
-
}
|
|
80
|
-
})
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
// Challenge failure event
|
|
84
|
-
this.listeners.push(
|
|
85
|
-
this.eventEmitter.addListener('onChallengeFailure', (event) => {
|
|
86
|
-
console.log(
|
|
87
|
-
'Liveness: Challenge failed -',
|
|
88
|
-
event.challenge,
|
|
89
|
-
event.reason
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
// Record failed challenge result
|
|
93
|
-
const result: ChallengeResult = {
|
|
94
|
-
challenge: event.challenge,
|
|
95
|
-
success: false,
|
|
96
|
-
timestamp: Date.now(),
|
|
97
|
-
duration: Date.now() - this.startTime,
|
|
98
|
-
};
|
|
99
|
-
this.challengeResults.push(result);
|
|
100
|
-
|
|
101
|
-
if (this.callbacks.onChallengeFailure) {
|
|
102
|
-
this.callbacks.onChallengeFailure(event.challenge, event.reason);
|
|
103
|
-
}
|
|
104
|
-
})
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
// All challenges complete event
|
|
108
|
-
this.listeners.push(
|
|
109
|
-
this.eventEmitter.addListener('onAllChallengesComplete', (event) => {
|
|
110
|
-
console.log('Liveness: All challenges completed', event);
|
|
111
|
-
|
|
112
|
-
const result: LivenessResult = {
|
|
113
|
-
success: event.success,
|
|
114
|
-
screenshot: event.screenshot,
|
|
115
|
-
challengeResults: this.challengeResults,
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
this.isActive = false;
|
|
119
|
-
|
|
120
|
-
if (this.callbacks.onAllChallengesComplete) {
|
|
121
|
-
this.callbacks.onAllChallengesComplete(result);
|
|
122
|
-
}
|
|
123
|
-
})
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
// Screenshot captured event
|
|
127
|
-
this.listeners.push(
|
|
128
|
-
this.eventEmitter.addListener('onScreenshotCaptured', (event) => {
|
|
129
|
-
console.log('Liveness: Screenshot captured');
|
|
130
|
-
|
|
131
|
-
if (this.callbacks.onScreenshotCaptured) {
|
|
132
|
-
this.callbacks.onScreenshotCaptured(event.screenshot);
|
|
133
|
-
}
|
|
134
|
-
})
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
22
|
/**
|
|
139
|
-
*
|
|
140
|
-
* @param config - Configuration including challenges array
|
|
141
|
-
* @param callbacks - Event callbacks
|
|
142
|
-
* @returns Promise resolving to LivenessResult
|
|
23
|
+
* Check if liveness detection is supported on this device
|
|
143
24
|
*/
|
|
144
|
-
async
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
): Promise<LivenessResult> {
|
|
148
|
-
if (this.isActive) {
|
|
149
|
-
throw new Error('Liveness detection is already active');
|
|
25
|
+
async isSupported(): Promise<boolean> {
|
|
26
|
+
if (!OmnipayLivenessModule) {
|
|
27
|
+
return false;
|
|
150
28
|
}
|
|
151
29
|
|
|
152
|
-
|
|
153
|
-
|
|
30
|
+
try {
|
|
31
|
+
return await OmnipayLivenessModule.isSupported();
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.warn('Liveness detection support check failed:', error);
|
|
34
|
+
return false;
|
|
154
35
|
}
|
|
36
|
+
}
|
|
155
37
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Start liveness detection with given configuration
|
|
40
|
+
*/
|
|
41
|
+
async startDetection(
|
|
42
|
+
config: LivenessConfig,
|
|
43
|
+
callbacks?: LivenessEventCallbacks
|
|
44
|
+
): Promise<LivenessResult> {
|
|
45
|
+
if (!OmnipayLivenessModule) {
|
|
46
|
+
throw new Error('Liveness detection module not available');
|
|
159
47
|
}
|
|
160
48
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
throw new Error(`Invalid challenge: ${challenge}`);
|
|
165
|
-
}
|
|
49
|
+
// Set up event listeners if callbacks provided
|
|
50
|
+
if (callbacks) {
|
|
51
|
+
this.setupEventListeners(callbacks);
|
|
166
52
|
}
|
|
167
53
|
|
|
168
54
|
try {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
if (!hasPermission) {
|
|
172
|
-
throw new Error(
|
|
173
|
-
'Camera permission is required. Please call requestCameraPermission() first.'
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// Set callbacks
|
|
178
|
-
this.callbacks = callbacks || {};
|
|
179
|
-
this.challengeResults = [];
|
|
180
|
-
this.startTime = Date.now();
|
|
181
|
-
this.isActive = true;
|
|
182
|
-
|
|
183
|
-
// Start detection on native side
|
|
184
|
-
const result = await LivenessDetectionNative.startLivenessDetection(
|
|
185
|
-
config.challenges
|
|
186
|
-
);
|
|
187
|
-
console.log('Liveness detection started:', result);
|
|
188
|
-
|
|
189
|
-
// Return a promise that resolves when all challenges are complete
|
|
190
|
-
return new Promise((resolve, reject) => {
|
|
191
|
-
const originalOnComplete = this.callbacks.onAllChallengesComplete;
|
|
192
|
-
|
|
193
|
-
this.callbacks.onAllChallengesComplete = (
|
|
194
|
-
livenessResult: LivenessResult
|
|
195
|
-
) => {
|
|
196
|
-
// Call original callback if provided
|
|
197
|
-
if (originalOnComplete) {
|
|
198
|
-
originalOnComplete(livenessResult);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// Resolve the promise
|
|
202
|
-
resolve(livenessResult);
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
// Set up timeout if specified
|
|
206
|
-
if (config.timeout) {
|
|
207
|
-
setTimeout(() => {
|
|
208
|
-
if (this.isActive) {
|
|
209
|
-
this.stopDetection();
|
|
210
|
-
reject(new Error('Liveness detection timed out'));
|
|
211
|
-
}
|
|
212
|
-
}, config.timeout);
|
|
213
|
-
}
|
|
214
|
-
});
|
|
55
|
+
const result = await OmnipayLivenessModule.startLivenessDetection(config);
|
|
56
|
+
return result;
|
|
215
57
|
} catch (error) {
|
|
216
|
-
this.
|
|
58
|
+
this.cleanupEventListeners();
|
|
217
59
|
throw error;
|
|
218
60
|
}
|
|
219
61
|
}
|
|
220
62
|
|
|
221
63
|
/**
|
|
222
|
-
* Stop
|
|
64
|
+
* Stop the current detection
|
|
223
65
|
*/
|
|
224
|
-
stopDetection(): void {
|
|
225
|
-
if (
|
|
226
|
-
|
|
227
|
-
this.isActive = false;
|
|
228
|
-
this.callbacks = {};
|
|
229
|
-
this.challengeResults = [];
|
|
230
|
-
console.log('Liveness detection stopped');
|
|
66
|
+
async stopDetection(): Promise<void> {
|
|
67
|
+
if (!OmnipayLivenessModule) {
|
|
68
|
+
return;
|
|
231
69
|
}
|
|
232
|
-
}
|
|
233
70
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
71
|
+
try {
|
|
72
|
+
await OmnipayLivenessModule.stopDetection();
|
|
73
|
+
} finally {
|
|
74
|
+
this.cleanupEventListeners();
|
|
75
|
+
}
|
|
239
76
|
}
|
|
240
77
|
|
|
241
78
|
/**
|
|
242
|
-
*
|
|
79
|
+
* Set up event listeners for detection callbacks
|
|
243
80
|
*/
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
81
|
+
private setupEventListeners(callbacks: LivenessEventCallbacks) {
|
|
82
|
+
this.cleanupEventListeners(); // Clean up any existing listeners
|
|
247
83
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
async checkCameraPermission(): Promise<boolean> {
|
|
252
|
-
if (!LivenessDetectionNative) {
|
|
253
|
-
throw new Error('Liveness detection is not available on this platform');
|
|
84
|
+
if (!this.eventEmitter) {
|
|
85
|
+
console.warn('Event emitter not available for liveness detection');
|
|
86
|
+
return;
|
|
254
87
|
}
|
|
255
88
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
89
|
+
if (callbacks.onChallengeStart) {
|
|
90
|
+
this.eventListeners.challengeStart = this.eventEmitter.addListener(
|
|
91
|
+
'onChallengeStart',
|
|
92
|
+
(challenge: LivenessChallenge) => callbacks.onChallengeStart!(challenge)
|
|
93
|
+
);
|
|
261
94
|
}
|
|
262
|
-
}
|
|
263
95
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
96
|
+
if (callbacks.onChallengeSuccess) {
|
|
97
|
+
this.eventListeners.challengeSuccess = this.eventEmitter.addListener(
|
|
98
|
+
'onChallengeSuccess',
|
|
99
|
+
(data: { challenge: LivenessChallenge; result: ChallengeResult }) =>
|
|
100
|
+
callbacks.onChallengeSuccess!(data.challenge, data.result)
|
|
101
|
+
);
|
|
270
102
|
}
|
|
271
103
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
104
|
+
if (callbacks.onChallengeFailure) {
|
|
105
|
+
this.eventListeners.challengeFailure = this.eventEmitter.addListener(
|
|
106
|
+
'onChallengeFailure',
|
|
107
|
+
(data: { challenge: LivenessChallenge; reason: string }) =>
|
|
108
|
+
callbacks.onChallengeFailure!(data.challenge, data.reason)
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (callbacks.onAllChallengesComplete) {
|
|
113
|
+
this.eventListeners.allComplete = this.eventEmitter.addListener(
|
|
114
|
+
'onAllChallengesComplete',
|
|
115
|
+
() => callbacks.onAllChallengesComplete!()
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (callbacks.onScreenshotCaptured) {
|
|
120
|
+
this.eventListeners.screenshot = this.eventEmitter.addListener(
|
|
121
|
+
'onScreenshotCaptured',
|
|
122
|
+
(screenshot: string) => callbacks.onScreenshotCaptured!(screenshot)
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (callbacks.onDetectionFailed) {
|
|
127
|
+
this.eventListeners.failed = this.eventEmitter.addListener(
|
|
128
|
+
'onDetectionFailed',
|
|
129
|
+
(reason: string) => callbacks.onDetectionFailed!(reason)
|
|
130
|
+
);
|
|
277
131
|
}
|
|
278
132
|
}
|
|
279
133
|
|
|
280
134
|
/**
|
|
281
|
-
*
|
|
135
|
+
* Clean up all event listeners
|
|
282
136
|
*/
|
|
283
|
-
|
|
284
|
-
this.
|
|
137
|
+
private cleanupEventListeners() {
|
|
138
|
+
Object.values(this.eventListeners).forEach((listener) => {
|
|
285
139
|
if (listener && listener.remove) {
|
|
286
140
|
listener.remove();
|
|
287
141
|
}
|
|
288
142
|
});
|
|
289
|
-
this.
|
|
290
|
-
|
|
143
|
+
this.eventListeners = {};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Get default configuration
|
|
148
|
+
*/
|
|
149
|
+
getDefaultConfig(): LivenessConfig {
|
|
150
|
+
return {
|
|
151
|
+
challenges: [
|
|
152
|
+
'smile',
|
|
153
|
+
'blink',
|
|
154
|
+
'turnLeft',
|
|
155
|
+
'turnRight',
|
|
156
|
+
] as LivenessChallenge[],
|
|
157
|
+
challengeTimeout: 10,
|
|
158
|
+
totalTimeout: 60,
|
|
159
|
+
debugMode: __DEV__,
|
|
160
|
+
};
|
|
291
161
|
}
|
|
292
162
|
}
|
|
293
163
|
|
|
294
164
|
// Export singleton instance
|
|
295
165
|
export const LivenessDetection = new LivenessDetectionManager();
|
|
296
166
|
|
|
297
|
-
//
|
|
298
|
-
|
|
299
|
-
// Constants from native module
|
|
300
|
-
export const LivenessConstants = {
|
|
301
|
-
CHALLENGE_SMILE: 'smile',
|
|
302
|
-
CHALLENGE_BLINK: 'blink',
|
|
303
|
-
CHALLENGE_TURN_LEFT: 'turn_left',
|
|
304
|
-
CHALLENGE_TURN_RIGHT: 'turn_right',
|
|
305
|
-
} as const;
|
|
167
|
+
// Export types for convenience
|
|
168
|
+
export * from './types';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { requireNativeComponent, ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
interface OmnipayLivenessCameraViewProps {
|
|
5
|
+
style?: ViewStyle;
|
|
6
|
+
onCameraReady?: (event: { nativeEvent: { ready: boolean } }) => void;
|
|
7
|
+
onCameraError?: (event: { nativeEvent: { error: string } }) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const NativeOmnipayLivenessCameraView =
|
|
11
|
+
requireNativeComponent<OmnipayLivenessCameraViewProps>(
|
|
12
|
+
'OmnipayLivenessCameraView'
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export const OmnipayLivenessCameraView: React.FC<
|
|
16
|
+
OmnipayLivenessCameraViewProps
|
|
17
|
+
> = (props) => {
|
|
18
|
+
return <NativeOmnipayLivenessCameraView {...props} />;
|
|
19
|
+
};
|