omnipay-reactnative-sdk 1.2.3-beta.9 → 1.2.3

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.
Files changed (58) hide show
  1. package/README.md +42 -102
  2. package/android/build.gradle +4 -15
  3. package/android/src/main/java/com/omniretail/omnipay/OmnipayActivityPackage.java +0 -5
  4. package/lib/commonjs/components/OmnipayProvider.js +91 -18
  5. package/lib/commonjs/components/OmnipayProvider.js.map +1 -1
  6. package/lib/module/components/OmnipayProvider.js +92 -19
  7. package/lib/module/components/OmnipayProvider.js.map +1 -1
  8. package/lib/module/components/OmnipayView.js.map +1 -1
  9. package/lib/module/components/views/BvnVerification.js.map +1 -1
  10. package/lib/module/components/views/PaylaterAgreement.js.map +1 -1
  11. package/lib/module/components/views/Registration.js.map +1 -1
  12. package/lib/typescript/components/OmnipayProvider.d.ts +3 -2
  13. package/lib/typescript/components/OmnipayProvider.d.ts.map +1 -1
  14. package/lib/typescript/hooks/useOmnipay.d.ts +2 -1
  15. package/lib/typescript/hooks/useOmnipay.d.ts.map +1 -1
  16. package/package.json +12 -29
  17. package/src/components/OmnipayProvider.tsx +133 -21
  18. package/src/components/OmnipayView.tsx +1 -1
  19. package/src/components/views/BvnVerification.tsx +1 -1
  20. package/src/components/views/PaylaterAgreement.tsx +1 -1
  21. package/src/components/views/Registration.tsx +1 -1
  22. package/src/hooks/useOmnipay.tsx +1 -1
  23. package/android/src/main/java/com/omniretail/omnipay/FaceVerificationFrameProcessor.kt +0 -111
  24. package/ios/FaceVerificationFrameProcessor.swift +0 -138
  25. package/ios/FaceVerificationFrameProcessorPlugin.m +0 -4
  26. package/ios/OmnipayReactnativeSdk.m +0 -5
  27. package/ios/OmnipayReactnativeSdk.swift +0 -10
  28. package/ios/omnipay-reactnative-sdk-Bridging-Header.h +0 -8
  29. package/ios/omnipay_reactnative_sdk.h +0 -6
  30. package/lib/commonjs/components/Button.js +0 -68
  31. package/lib/commonjs/components/Button.js.map +0 -1
  32. package/lib/commonjs/components/biometrics/FaceVerification.js +0 -380
  33. package/lib/commonjs/components/biometrics/FaceVerification.js.map +0 -1
  34. package/lib/commonjs/components/biometrics/useFaceVerification.js +0 -85
  35. package/lib/commonjs/components/biometrics/useFaceVerification.js.map +0 -1
  36. package/lib/commonjs/components/biometrics/useFaceVerificationFlow.js +0 -157
  37. package/lib/commonjs/components/biometrics/useFaceVerificationFlow.js.map +0 -1
  38. package/lib/module/components/Button.js +0 -61
  39. package/lib/module/components/Button.js.map +0 -1
  40. package/lib/module/components/biometrics/FaceVerification.js +0 -372
  41. package/lib/module/components/biometrics/FaceVerification.js.map +0 -1
  42. package/lib/module/components/biometrics/useFaceVerification.js +0 -78
  43. package/lib/module/components/biometrics/useFaceVerification.js.map +0 -1
  44. package/lib/module/components/biometrics/useFaceVerificationFlow.js +0 -150
  45. package/lib/module/components/biometrics/useFaceVerificationFlow.js.map +0 -1
  46. package/lib/typescript/components/Button.d.ts +0 -17
  47. package/lib/typescript/components/Button.d.ts.map +0 -1
  48. package/lib/typescript/components/biometrics/FaceVerification.d.ts +0 -9
  49. package/lib/typescript/components/biometrics/FaceVerification.d.ts.map +0 -1
  50. package/lib/typescript/components/biometrics/useFaceVerification.d.ts +0 -38
  51. package/lib/typescript/components/biometrics/useFaceVerification.d.ts.map +0 -1
  52. package/lib/typescript/components/biometrics/useFaceVerificationFlow.d.ts +0 -29
  53. package/lib/typescript/components/biometrics/useFaceVerificationFlow.d.ts.map +0 -1
  54. package/omnipay_reactnative_sdk.podspec +0 -52
  55. package/src/components/Button.tsx +0 -86
  56. package/src/components/biometrics/FaceVerification.tsx +0 -429
  57. package/src/components/biometrics/useFaceVerification.ts +0 -120
  58. package/src/components/biometrics/useFaceVerificationFlow.ts +0 -224
@@ -1,224 +0,0 @@
1
- import { useState, useEffect, useCallback } from 'react';
2
- import {
3
- FaceVerificationResult,
4
- FaceVerificationUtils,
5
- } from './useFaceVerification';
6
-
7
- export type VerificationStep =
8
- | 'position_face'
9
- | 'smile'
10
- | 'blink'
11
- | 'turn_left'
12
- | 'turn_right'
13
- | 'completed'
14
- | 'failed';
15
-
16
- export interface VerificationFlowState {
17
- currentStep: VerificationStep;
18
- completedSteps: VerificationStep[];
19
- stepStartTime: number;
20
- totalStartTime: number;
21
- isProcessing: boolean;
22
- progress: number;
23
- instruction: string;
24
- error?: string;
25
- }
26
-
27
- export interface VerificationFlowConfig {
28
- stepTimeout: number; // Maximum time per step (ms)
29
- totalTimeout: number; // Maximum total time (ms)
30
- confirmationFrames: number; // Frames needed to confirm action
31
- requiredSteps: VerificationStep[]; // Steps to complete
32
- }
33
-
34
- const DEFAULT_CONFIG: VerificationFlowConfig = {
35
- stepTimeout: 10000, // 10 seconds per step
36
- totalTimeout: 60000, // 1 minute total
37
- confirmationFrames: 5, // 5 consecutive frames
38
- requiredSteps: ['position_face', 'smile', 'blink', 'turn_left', 'turn_right'],
39
- };
40
-
41
- const STEP_INSTRUCTIONS: Record<VerificationStep, string> = {
42
- position_face: 'Position your face in the center of the frame',
43
- smile: 'Please smile for the camera',
44
- blink: 'Please blink your eyes',
45
- turn_left: 'Slowly turn your head to the left',
46
- turn_right: 'Slowly turn your head to the right',
47
- completed: 'Verification completed successfully!',
48
- failed: 'Verification failed. Please try again.',
49
- };
50
-
51
- export const useFaceVerificationFlow = (
52
- config: Partial<VerificationFlowConfig> = {}
53
- ) => {
54
- const fullConfig = { ...DEFAULT_CONFIG, ...config };
55
-
56
- const [state, setState] = useState<VerificationFlowState>({
57
- currentStep: 'position_face',
58
- completedSteps: [],
59
- stepStartTime: Date.now(),
60
- totalStartTime: Date.now(),
61
- isProcessing: false,
62
- progress: 0,
63
- instruction: STEP_INSTRUCTIONS.position_face,
64
- });
65
-
66
- const [confirmationCount, setConfirmationCount] = useState(0);
67
-
68
- // Reset verification flow
69
- const resetFlow = useCallback(() => {
70
- const now = Date.now();
71
- setState({
72
- currentStep: 'position_face',
73
- completedSteps: [],
74
- stepStartTime: now,
75
- totalStartTime: now,
76
- isProcessing: false,
77
- progress: 0,
78
- instruction: STEP_INSTRUCTIONS.position_face,
79
- });
80
- setConfirmationCount(0);
81
- }, []);
82
-
83
- // Check if current step is completed based on face detection result
84
- const checkStepCompletion = useCallback(
85
- (result: FaceVerificationResult): boolean => {
86
- if (!result.faceDetected) return false;
87
-
88
- switch (state.currentStep) {
89
- case 'position_face':
90
- return FaceVerificationUtils.isFaceCentered(result);
91
-
92
- case 'smile':
93
- return FaceVerificationUtils.isConfidentSmile(result);
94
-
95
- case 'blink':
96
- return FaceVerificationUtils.isConfidentBlink(result);
97
-
98
- case 'turn_left':
99
- return FaceVerificationUtils.isHeadTurnedLeft(result);
100
-
101
- case 'turn_right':
102
- return FaceVerificationUtils.isHeadTurnedRight(result);
103
-
104
- default:
105
- return false;
106
- }
107
- },
108
- [state.currentStep]
109
- );
110
-
111
- // Get next step in sequence
112
- const getNextStep = useCallback(
113
- (currentStep: VerificationStep): VerificationStep => {
114
- const currentIndex = fullConfig.requiredSteps.indexOf(currentStep);
115
- if (
116
- currentIndex === -1 ||
117
- currentIndex === fullConfig.requiredSteps.length - 1
118
- ) {
119
- return 'completed';
120
- }
121
- const nextStep = fullConfig.requiredSteps[currentIndex + 1];
122
- return nextStep || 'completed';
123
- },
124
- [fullConfig.requiredSteps]
125
- );
126
-
127
- // Process face detection result
128
- const processFaceResult = useCallback(
129
- (result: FaceVerificationResult) => {
130
- if (state.currentStep === 'completed' || state.currentStep === 'failed') {
131
- return;
132
- }
133
-
134
- const now = Date.now();
135
-
136
- // Check for timeouts
137
- if (now - state.totalStartTime > fullConfig.totalTimeout) {
138
- setState((prev) => ({
139
- ...prev,
140
- currentStep: 'failed',
141
- instruction: 'Verification timed out. Please try again.',
142
- error: 'Total verification timeout exceeded',
143
- }));
144
- return;
145
- }
146
-
147
- if (now - state.stepStartTime > fullConfig.stepTimeout) {
148
- setState((prev) => ({
149
- ...prev,
150
- currentStep: 'failed',
151
- instruction: 'Step timed out. Please try again.',
152
- error: 'Step timeout exceeded',
153
- }));
154
- return;
155
- }
156
-
157
- // Check if current step is completed
158
- const stepCompleted = checkStepCompletion(result);
159
-
160
- if (stepCompleted) {
161
- setConfirmationCount((prev) => prev + 1);
162
-
163
- // Require multiple consecutive confirmations
164
- if (confirmationCount + 1 >= fullConfig.confirmationFrames) {
165
- const nextStep = getNextStep(state.currentStep);
166
- const newCompletedSteps = [
167
- ...state.completedSteps,
168
- state.currentStep,
169
- ];
170
- const newProgress =
171
- (newCompletedSteps.length / fullConfig.requiredSteps.length) * 100;
172
-
173
- setState((prev) => ({
174
- ...prev,
175
- currentStep: nextStep,
176
- completedSteps: newCompletedSteps,
177
- stepStartTime: now,
178
- progress: newProgress,
179
- instruction: STEP_INSTRUCTIONS[nextStep],
180
- isProcessing: nextStep === 'completed',
181
- }));
182
-
183
- setConfirmationCount(0);
184
- }
185
- } else {
186
- // Reset confirmation count if step not completed
187
- setConfirmationCount(0);
188
- }
189
- },
190
- [
191
- state,
192
- fullConfig.totalTimeout,
193
- fullConfig.stepTimeout,
194
- fullConfig.confirmationFrames,
195
- fullConfig.requiredSteps.length,
196
- confirmationCount,
197
- checkStepCompletion,
198
- getNextStep,
199
- ]
200
- );
201
-
202
- // Auto-reset on mount
203
- useEffect(() => {
204
- resetFlow();
205
- }, [resetFlow]);
206
-
207
- return {
208
- state,
209
- processFaceResult,
210
- resetFlow,
211
- isCompleted: state.currentStep === 'completed',
212
- isFailed: state.currentStep === 'failed',
213
- isActive:
214
- state.currentStep !== 'completed' && state.currentStep !== 'failed',
215
- remainingTime: Math.max(
216
- 0,
217
- fullConfig.stepTimeout - (Date.now() - state.stepStartTime)
218
- ),
219
- totalRemainingTime: Math.max(
220
- 0,
221
- fullConfig.totalTimeout - (Date.now() - state.totalStartTime)
222
- ),
223
- };
224
- };