@transfergratis/react-native-sdk 0.1.12 → 0.1.14
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/android/build.gradle +1 -1
- package/build/components/KYCElements/IDCardCapture.d.ts +1 -0
- package/build/components/KYCElements/IDCardCapture.d.ts.map +1 -1
- package/build/components/KYCElements/IDCardCapture.js +11 -24
- package/build/components/KYCElements/IDCardCapture.js.map +1 -1
- package/build/components/KYCElements/VerificationProgressTemplate.js +1 -1
- package/build/components/KYCElements/VerificationProgressTemplate.js.map +1 -1
- package/build/components/TemplateKYCExample.js +0 -64
- package/build/components/TemplateKYCExample.js.map +1 -1
- package/build/components/TemplateKYCFlowRefactored.d.ts.map +1 -1
- package/build/components/TemplateKYCFlowRefactored.js +15 -3
- package/build/components/TemplateKYCFlowRefactored.js.map +1 -1
- package/build/hooks/useTemplateKYCFlow.d.ts.map +1 -1
- package/build/hooks/useTemplateKYCFlow.js +6 -12
- package/build/hooks/useTemplateKYCFlow.js.map +1 -1
- package/build/i18n/en/index.d.ts +7 -0
- package/build/i18n/en/index.d.ts.map +1 -1
- package/build/i18n/en/index.js +9 -1
- package/build/i18n/en/index.js.map +1 -1
- package/build/i18n/fr/index.d.ts +7 -0
- package/build/i18n/fr/index.d.ts.map +1 -1
- package/build/i18n/fr/index.js +9 -1
- package/build/i18n/fr/index.js.map +1 -1
- package/build/i18n/types.d.ts +7 -0
- package/build/i18n/types.d.ts.map +1 -1
- package/build/i18n/types.js.map +1 -1
- package/build/modules/api/CardAuthentification.d.ts.map +1 -1
- package/build/modules/api/CardAuthentification.js +2 -1
- package/build/modules/api/CardAuthentification.js.map +1 -1
- package/build/modules/camera/VisionCameraModule.d.ts.map +1 -1
- package/build/modules/camera/VisionCameraModule.js +24 -5
- package/build/modules/camera/VisionCameraModule.js.map +1 -1
- package/build/utils/pathToBase64.d.ts.map +1 -1
- package/build/utils/pathToBase64.js +8 -3
- package/build/utils/pathToBase64.js.map +1 -1
- package/package.json +1 -1
- package/src/components/KYCElements/IDCardCapture.tsx +14 -25
- package/src/components/KYCElements/VerificationProgressTemplate.tsx +1 -1
- package/src/components/TemplateKYCExample.tsx +0 -65
- package/src/components/TemplateKYCFlowRefactored.tsx +20 -3
- package/src/hooks/useTemplateKYCFlow.tsx +7 -12
- package/src/i18n/en/index.ts +10 -1
- package/src/i18n/fr/index.ts +10 -1
- package/src/i18n/types.ts +8 -0
- package/src/modules/api/CardAuthentification.ts +3 -1
- package/src/modules/camera/VisionCameraModule.ts +26 -7
- package/src/utils/pathToBase64.ts +8 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { View, Text, StyleSheet, SafeAreaView, TouchableOpacity, ActivityIndicator, Dimensions } from 'react-native';
|
|
2
|
+
import { View, Text, StyleSheet, SafeAreaView, TouchableOpacity, ActivityIndicator, Dimensions, Alert } from 'react-native';
|
|
3
3
|
import { KYCTemplate, VerificationState } from '../types/KYC.types';
|
|
4
4
|
import { TemplateKYCFlowProvider, useTemplateKYCFlowContext } from '../hooks/useTemplateKYCFlow';
|
|
5
5
|
import { useI18n } from '../hooks/useI18n';
|
|
@@ -29,16 +29,33 @@ export const TemplateKYCFlow: React.FC<TemplateKYCFlowProps> = ({
|
|
|
29
29
|
onCancel,
|
|
30
30
|
API_KEY,
|
|
31
31
|
}) => {
|
|
32
|
+
const { t } = useI18n();
|
|
33
|
+
|
|
34
|
+
const OnCancel = () => {
|
|
35
|
+
Alert.alert(
|
|
36
|
+
t('kyc.cancelConfirmation.title'),
|
|
37
|
+
t('kyc.cancelConfirmation.message'),
|
|
38
|
+
[
|
|
39
|
+
{ text: t('kyc.cancelConfirmation.cancelButton'), style: 'cancel' },
|
|
40
|
+
{
|
|
41
|
+
text: t('kyc.cancelConfirmation.confirmButton'),
|
|
42
|
+
onPress: () => {
|
|
43
|
+
onCancel?.();
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
]
|
|
47
|
+
);
|
|
48
|
+
};
|
|
32
49
|
return (
|
|
33
50
|
<TemplateKYCFlowProvider
|
|
34
51
|
template={template}
|
|
35
52
|
onComplete={onComplete}
|
|
36
53
|
onError={onError}
|
|
37
|
-
onCancel={
|
|
54
|
+
onCancel={OnCancel}
|
|
38
55
|
initialLanguage={language}
|
|
39
56
|
apiKey={API_KEY}
|
|
40
57
|
>
|
|
41
|
-
<TemplateKYCFlowContent onCancel={
|
|
58
|
+
<TemplateKYCFlowContent onCancel={OnCancel} />
|
|
42
59
|
</TemplateKYCFlowProvider>
|
|
43
60
|
);
|
|
44
61
|
};
|
|
@@ -130,8 +130,8 @@ export const useTemplateKYCFlow = (
|
|
|
130
130
|
const templateWithReview = useMemo(() => ensureReviewSubmitStep(template), [template, ensureReviewSubmitStep]);
|
|
131
131
|
const templateWithReviewAndVerification = useMemo(() => ensureVerificationProgressStep(templateWithReview), [templateWithReview, ensureVerificationProgressStep]);
|
|
132
132
|
|
|
133
|
-
// État du flux
|
|
134
|
-
const
|
|
133
|
+
// État initial du flux
|
|
134
|
+
const buildInitialState = (): TemplateState => ({
|
|
135
135
|
template: templateWithReviewAndVerification,
|
|
136
136
|
currentComponentIndex: 0,
|
|
137
137
|
completedComponents: [],
|
|
@@ -151,6 +151,9 @@ export const useTemplateKYCFlow = (
|
|
|
151
151
|
status: 'idle',
|
|
152
152
|
},
|
|
153
153
|
});
|
|
154
|
+
|
|
155
|
+
// État du flux
|
|
156
|
+
const [state, setState] = useState<TemplateState>(() => buildInitialState());
|
|
154
157
|
const mapComponentTypeToAction = useCallback((type: TemplateComponent['type']): string | null => {
|
|
155
158
|
switch (type) {
|
|
156
159
|
case 'id_card':
|
|
@@ -594,16 +597,8 @@ export const useTemplateKYCFlow = (
|
|
|
594
597
|
|
|
595
598
|
// Réinitialiser le template
|
|
596
599
|
resetTemplate: useCallback(() => {
|
|
597
|
-
setState(
|
|
598
|
-
|
|
599
|
-
currentComponentIndex: 0,
|
|
600
|
-
completedComponents: [],
|
|
601
|
-
componentData: {},
|
|
602
|
-
errors: {},
|
|
603
|
-
isProcessing: false,
|
|
604
|
-
verification: { status: 'idle', result: undefined },
|
|
605
|
-
}));
|
|
606
|
-
}, []),
|
|
600
|
+
setState(buildInitialState());
|
|
601
|
+
}, [buildInitialState]),
|
|
607
602
|
|
|
608
603
|
// Changer la langue
|
|
609
604
|
setLanguage: useCallback((language: string) => {
|
package/src/i18n/en/index.ts
CHANGED
|
@@ -140,7 +140,8 @@ export const en = {
|
|
|
140
140
|
pending: 'Pending',
|
|
141
141
|
processing: 'Processing',
|
|
142
142
|
completed: 'Completed',
|
|
143
|
-
failed: 'Failed'
|
|
143
|
+
failed: 'Failed',
|
|
144
|
+
retry: 'Retry'
|
|
144
145
|
}
|
|
145
146
|
},
|
|
146
147
|
|
|
@@ -161,6 +162,14 @@ export const en = {
|
|
|
161
162
|
right: 'Right',
|
|
162
163
|
left: 'Left'
|
|
163
164
|
}
|
|
165
|
+
},
|
|
166
|
+
|
|
167
|
+
// Cancel Confirmation
|
|
168
|
+
cancelConfirmation: {
|
|
169
|
+
title: 'Are you sure you want to cancel?',
|
|
170
|
+
message: 'You will lose all your progress.',
|
|
171
|
+
cancelButton: 'Cancel',
|
|
172
|
+
confirmButton: 'OK'
|
|
164
173
|
}
|
|
165
174
|
},
|
|
166
175
|
|
package/src/i18n/fr/index.ts
CHANGED
|
@@ -140,7 +140,8 @@ export const fr = {
|
|
|
140
140
|
pending: 'En attente',
|
|
141
141
|
processing: 'En cours',
|
|
142
142
|
completed: 'Terminé',
|
|
143
|
-
failed: 'Échoué'
|
|
143
|
+
failed: 'Échoué',
|
|
144
|
+
retry: 'Réessayer'
|
|
144
145
|
}
|
|
145
146
|
},
|
|
146
147
|
|
|
@@ -161,6 +162,14 @@ export const fr = {
|
|
|
161
162
|
right: 'Droite',
|
|
162
163
|
left: 'Gauche'
|
|
163
164
|
}
|
|
165
|
+
},
|
|
166
|
+
|
|
167
|
+
// Confirmation d'annulation
|
|
168
|
+
cancelConfirmation: {
|
|
169
|
+
title: 'Êtes-vous sûr de vouloir annuler ?',
|
|
170
|
+
message: 'Vous perdrez tout votre progrès.',
|
|
171
|
+
cancelButton: 'Annuler',
|
|
172
|
+
confirmButton: 'OK'
|
|
164
173
|
}
|
|
165
174
|
},
|
|
166
175
|
|
package/src/i18n/types.ts
CHANGED
|
@@ -98,6 +98,7 @@ export interface KYCTranslations {
|
|
|
98
98
|
processing: string;
|
|
99
99
|
completed: string;
|
|
100
100
|
failed: string;
|
|
101
|
+
retry: string;
|
|
101
102
|
};
|
|
102
103
|
};
|
|
103
104
|
|
|
@@ -113,6 +114,13 @@ export interface KYCTranslations {
|
|
|
113
114
|
success: string;
|
|
114
115
|
error: string;
|
|
115
116
|
};
|
|
117
|
+
|
|
118
|
+
cancelConfirmation: {
|
|
119
|
+
title: string;
|
|
120
|
+
message: string;
|
|
121
|
+
cancelButton: string;
|
|
122
|
+
confirmButton: string;
|
|
123
|
+
};
|
|
116
124
|
}
|
|
117
125
|
|
|
118
126
|
export interface CameraTranslations {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import kycService, { authentification, errorMessage } from "./KYCService";
|
|
1
|
+
import kycService, { authentification, errorMessage, truncateFields } from "./KYCService";
|
|
2
2
|
import { cropByObb } from "../../utils/cropByObb";
|
|
3
3
|
import { GovernmentDocumentType, IBbox } from "../../types/KYC.types";
|
|
4
4
|
import { logger } from "../../utils/logger";
|
|
@@ -149,6 +149,8 @@ export async function checkTemplateType(result: { path?: string, docType: string
|
|
|
149
149
|
try {
|
|
150
150
|
const token = await authentification();
|
|
151
151
|
const templateType = await kycService.checkTemplateType({ fileUri: result.path || '', docType: result?.docType as GovernmentDocumentType, docRegion: result?.docRegion || "", postfix: result?.postfix, token: token });
|
|
152
|
+
|
|
153
|
+
logger.log("templateType result", JSON.stringify(truncateFields(templateType), null, 2));
|
|
152
154
|
return templateType;
|
|
153
155
|
} catch (e: any) {
|
|
154
156
|
logger.error('Error checking template type:', JSON.stringify(errorMessage(e), null, 2));
|
|
@@ -2,6 +2,29 @@ import { Platform } from 'react-native';
|
|
|
2
2
|
import { Camera, CameraDevice, CameraPermissionStatus, PhotoFile } from 'react-native-vision-camera';
|
|
3
3
|
import * as FileSystem from "expo-file-system";
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Backward-compatible file copy function
|
|
7
|
+
* Uses legacy API from expo-file-system/legacy if available (Expo SDK 54+)
|
|
8
|
+
* Falls back to regular copyAsync for older versions
|
|
9
|
+
*/
|
|
10
|
+
async function copyFileCompat(from: string, to: string): Promise<void> {
|
|
11
|
+
try {
|
|
12
|
+
// Try legacy API from expo-file-system/legacy (Expo SDK 54+)
|
|
13
|
+
// This avoids deprecation warnings while maintaining backward compatibility
|
|
14
|
+
// @ts-ignore - legacy export might not be in types
|
|
15
|
+
const LegacyFileSystem = require('expo-file-system/legacy');
|
|
16
|
+
if (LegacyFileSystem?.copyAsync) {
|
|
17
|
+
await LegacyFileSystem.copyAsync({ from, to });
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
} catch (_) {
|
|
21
|
+
// Legacy export not available, fall through to regular import
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Fall back to regular copyAsync (for older Expo SDK versions < 54)
|
|
25
|
+
await FileSystem.copyAsync({ from, to });
|
|
26
|
+
}
|
|
27
|
+
|
|
5
28
|
export interface CameraCaptureResult {
|
|
6
29
|
success: boolean;
|
|
7
30
|
path?: string;
|
|
@@ -163,15 +186,11 @@ export class VisionCameraModule {
|
|
|
163
186
|
* Process photo capture result
|
|
164
187
|
*/
|
|
165
188
|
async processPhotoResult(photo: PhotoFile): Promise<CameraCaptureResult> {
|
|
189
|
+
try {
|
|
190
|
+
const newPath = FileSystem.documentDirectory + `photo_${Date.now()}.jpg`;
|
|
166
191
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
await FileSystem.copyAsync({
|
|
170
|
-
from: `file://${photo.path}`,
|
|
171
|
-
to: newPath,
|
|
172
|
-
});
|
|
192
|
+
await copyFileCompat(`file://${photo.path}`, newPath);
|
|
173
193
|
|
|
174
|
-
try {
|
|
175
194
|
return {
|
|
176
195
|
success: true,
|
|
177
196
|
path: newPath,
|
|
@@ -9,9 +9,14 @@ export async function pathToBase64(uri: string): Promise<string> {
|
|
|
9
9
|
|
|
10
10
|
// Try Expo FileSystem if available (React Native + Expo)
|
|
11
11
|
try {
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
|
|
12
|
+
// Try legacy API first (Expo SDK 54+) to avoid deprecation warnings
|
|
13
|
+
// @ts-ignore - legacy export might not be in types
|
|
14
|
+
let FileSystem = require('expo-file-system/legacy');
|
|
15
|
+
if (!FileSystem?.readAsStringAsync) {
|
|
16
|
+
// Fall back to regular import for older versions
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
18
|
+
FileSystem = require('expo-file-system');
|
|
19
|
+
}
|
|
15
20
|
if (FileSystem?.readAsStringAsync) {
|
|
16
21
|
const base64 = await FileSystem.readAsStringAsync(uri, { encoding: FileSystem.EncodingType.Base64 });
|
|
17
22
|
if (base64) return base64;
|