@transfergratis/react-native-sdk 0.1.4 → 0.1.5
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/build/api/axios.d.ts +30 -0
- package/build/api/axios.d.ts.map +1 -0
- package/build/api/axios.js +92 -0
- package/build/api/axios.js.map +1 -0
- package/build/components/EnhancedCameraView.d.ts +1 -41
- package/build/components/EnhancedCameraView.d.ts.map +1 -1
- package/build/components/EnhancedCameraView.js +75 -34
- package/build/components/EnhancedCameraView.js.map +1 -1
- package/build/components/EnhancedCameraView.web.d.ts +1 -41
- package/build/components/EnhancedCameraView.web.d.ts.map +1 -1
- package/build/components/EnhancedCameraView.web.js +28 -4
- package/build/components/EnhancedCameraView.web.js.map +1 -1
- package/build/components/KYCElements/CountrySelectionTemplate.d.ts +2 -2
- package/build/components/KYCElements/CountrySelectionTemplate.d.ts.map +1 -1
- package/build/components/KYCElements/CountrySelectionTemplate.js +71 -114
- package/build/components/KYCElements/CountrySelectionTemplate.js.map +1 -1
- package/build/components/KYCElements/FileUploadTemplate.d.ts.map +1 -1
- package/build/components/KYCElements/FileUploadTemplate.js +7 -3
- package/build/components/KYCElements/FileUploadTemplate.js.map +1 -1
- package/build/components/KYCElements/IDCardCapture.d.ts +7 -2
- package/build/components/KYCElements/IDCardCapture.d.ts.map +1 -1
- package/build/components/KYCElements/IDCardCapture.js +253 -104
- package/build/components/KYCElements/IDCardCapture.js.map +1 -1
- package/build/components/KYCElements/InitializationStep.d.ts +5 -0
- package/build/components/KYCElements/InitializationStep.d.ts.map +1 -0
- package/build/components/KYCElements/InitializationStep.js +41 -0
- package/build/components/KYCElements/InitializationStep.js.map +1 -0
- package/build/components/KYCElements/LocationCaptureTemplate.d.ts.map +1 -1
- package/build/components/KYCElements/LocationCaptureTemplate.js +15 -13
- package/build/components/KYCElements/LocationCaptureTemplate.js.map +1 -1
- package/build/components/KYCElements/OrientationVideoCapture.d.ts +2 -2
- package/build/components/KYCElements/OrientationVideoCapture.d.ts.map +1 -1
- package/build/components/KYCElements/OrientationVideoCapture.js.map +1 -1
- package/build/components/KYCElements/OrientationVideoCaptureEnhanced.d.ts +2 -2
- package/build/components/KYCElements/OrientationVideoCaptureEnhanced.d.ts.map +1 -1
- package/build/components/KYCElements/OrientationVideoCaptureEnhanced.js.map +1 -1
- package/build/components/KYCElements/OrientationVideoCaptureFinal.d.ts +2 -2
- package/build/components/KYCElements/OrientationVideoCaptureFinal.d.ts.map +1 -1
- package/build/components/KYCElements/OrientationVideoCaptureFinal.js.map +1 -1
- package/build/components/KYCElements/ReviewSubmitTemplate.d.ts +12 -0
- package/build/components/KYCElements/ReviewSubmitTemplate.d.ts.map +1 -0
- package/build/components/KYCElements/ReviewSubmitTemplate.js +171 -0
- package/build/components/KYCElements/ReviewSubmitTemplate.js.map +1 -0
- package/build/components/KYCElements/SelfieCaptureTemplate.d.ts +6 -2
- package/build/components/KYCElements/SelfieCaptureTemplate.d.ts.map +1 -1
- package/build/components/KYCElements/SelfieCaptureTemplate.js +105 -35
- package/build/components/KYCElements/SelfieCaptureTemplate.js.map +1 -1
- package/build/components/KYCElements/VerificationProgressTemplate.d.ts +12 -0
- package/build/components/KYCElements/VerificationProgressTemplate.d.ts.map +1 -0
- package/build/components/KYCElements/VerificationProgressTemplate.js +93 -0
- package/build/components/KYCElements/VerificationProgressTemplate.js.map +1 -0
- package/build/components/OverLay/IdCard.d.ts +1 -1
- package/build/components/OverLay/IdCard.d.ts.map +1 -1
- package/build/components/OverLay/IdCard.js +10 -6
- package/build/components/OverLay/IdCard.js.map +1 -1
- package/build/components/OverLay/SelfieOverlay.d.ts +1 -1
- package/build/components/OverLay/SelfieOverlay.d.ts.map +1 -1
- package/build/components/OverLay/SelfieOverlay.js +5 -4
- package/build/components/OverLay/SelfieOverlay.js.map +1 -1
- package/build/components/OverLay/type.d.ts +71 -1
- package/build/components/OverLay/type.d.ts.map +1 -1
- package/build/components/OverLay/type.js.map +1 -1
- package/build/components/TemplateKYCExample.d.ts.map +1 -1
- package/build/components/TemplateKYCExample.js +72 -197
- package/build/components/TemplateKYCExample.js.map +1 -1
- package/build/components/TemplateKYCFlowRefactored.d.ts.map +1 -1
- package/build/components/TemplateKYCFlowRefactored.js +63 -39
- package/build/components/TemplateKYCFlowRefactored.js.map +1 -1
- package/build/components/example/OrientationVideoExample.d.ts.map +1 -1
- package/build/components/example/OrientationVideoExample.js +1 -5
- package/build/components/example/OrientationVideoExample.js.map +1 -1
- package/build/config/countriesData.d.ts +3 -0
- package/build/config/countriesData.d.ts.map +1 -0
- package/build/config/countriesData.js +79 -0
- package/build/config/countriesData.js.map +1 -0
- package/build/config/region_mapping.d.ts +3 -0
- package/build/config/region_mapping.d.ts.map +1 -0
- package/build/config/region_mapping.js +687 -0
- package/build/config/region_mapping.js.map +1 -0
- package/build/hooks/useI18n.d.ts +11 -0
- package/build/hooks/useI18n.d.ts.map +1 -0
- package/build/hooks/useI18n.js +37 -0
- package/build/hooks/useI18n.js.map +1 -0
- package/build/hooks/useOrientationVideo.d.ts +1 -2
- package/build/hooks/useOrientationVideo.d.ts.map +1 -1
- package/build/hooks/useOrientationVideo.js +2 -1
- package/build/hooks/useOrientationVideo.js.map +1 -1
- package/build/hooks/useRealtimeVerifier.d.ts +28 -0
- package/build/hooks/useRealtimeVerifier.d.ts.map +1 -0
- package/build/hooks/useRealtimeVerifier.js +91 -0
- package/build/hooks/useRealtimeVerifier.js.map +1 -0
- package/build/hooks/useTemplateKYCFlow.d.ts +1 -0
- package/build/hooks/useTemplateKYCFlow.d.ts.map +1 -1
- package/build/hooks/useTemplateKYCFlow.js +337 -38
- package/build/hooks/useTemplateKYCFlow.js.map +1 -1
- package/build/i18n/en/index.d.ts +168 -0
- package/build/i18n/en/index.d.ts.map +1 -0
- package/build/i18n/en/index.js +195 -0
- package/build/i18n/en/index.js.map +1 -0
- package/build/i18n/fr/index.d.ts +168 -0
- package/build/i18n/fr/index.d.ts.map +1 -0
- package/build/i18n/fr/index.js +194 -0
- package/build/i18n/fr/index.js.map +1 -0
- package/build/i18n/index.d.ts +10 -0
- package/build/i18n/index.d.ts.map +1 -0
- package/build/i18n/index.js +56 -0
- package/build/i18n/index.js.map +1 -0
- package/build/i18n/types.d.ts +153 -0
- package/build/i18n/types.d.ts.map +1 -0
- package/build/i18n/types.js +3 -0
- package/build/i18n/types.js.map +1 -0
- package/build/i18n/usage-example.d.ts +4 -0
- package/build/i18n/usage-example.d.ts.map +1 -0
- package/build/i18n/usage-example.js +189 -0
- package/build/i18n/usage-example.js.map +1 -0
- package/build/modules/api/CardAuthentification.d.ts +22 -0
- package/build/modules/api/CardAuthentification.d.ts.map +1 -0
- package/build/modules/api/CardAuthentification.js +107 -0
- package/build/modules/api/CardAuthentification.js.map +1 -0
- package/build/modules/api/KYCService.d.ts +57 -1
- package/build/modules/api/KYCService.d.ts.map +1 -1
- package/build/modules/api/KYCService.js +348 -27
- package/build/modules/api/KYCService.js.map +1 -1
- package/build/modules/api/SelfieVerification.d.ts +3 -0
- package/build/modules/api/SelfieVerification.d.ts.map +1 -0
- package/build/modules/api/SelfieVerification.js +9 -0
- package/build/modules/api/SelfieVerification.js.map +1 -0
- package/build/modules/api/backendApi.d.ts +2 -0
- package/build/modules/api/backendApi.d.ts.map +1 -0
- package/build/modules/api/backendApi.js +6 -0
- package/build/modules/api/backendApi.js.map +1 -0
- package/build/modules/api/types.d.ts +20 -0
- package/build/modules/api/types.d.ts.map +1 -0
- package/build/modules/api/types.js +2 -0
- package/build/modules/api/types.js.map +1 -0
- package/build/types/KYC.types.d.ts +59 -7
- package/build/types/KYC.types.d.ts.map +1 -1
- package/build/types/KYC.types.js +9 -1
- package/build/types/KYC.types.js.map +1 -1
- package/build/utils/cropByObb.d.ts +11 -0
- package/build/utils/cropByObb.d.ts.map +1 -0
- package/build/utils/cropByObb.js +78 -0
- package/build/utils/cropByObb.js.map +1 -0
- package/build/utils/get-document-type-info.d.ts +13 -0
- package/build/utils/get-document-type-info.d.ts.map +1 -0
- package/build/utils/get-document-type-info.js +59 -0
- package/build/utils/get-document-type-info.js.map +1 -0
- package/build/utils/pathToBase64.d.ts +3 -0
- package/build/utils/pathToBase64.d.ts.map +1 -0
- package/build/utils/pathToBase64.js +47 -0
- package/build/utils/pathToBase64.js.map +1 -0
- package/build/utils/remove-duplicate.d.ts +2 -0
- package/build/utils/remove-duplicate.d.ts.map +1 -0
- package/build/utils/remove-duplicate.js +4 -0
- package/build/utils/remove-duplicate.js.map +1 -0
- package/package.json +3 -1
- package/src/api/axios.ts +144 -0
- package/src/components/EnhancedCameraView.tsx +96 -78
- package/src/components/EnhancedCameraView.web.tsx +41 -40
- package/src/components/KYCElements/CountrySelectionTemplate.tsx +104 -136
- package/src/components/KYCElements/FileUploadTemplate.tsx +14 -8
- package/src/components/KYCElements/IDCardCapture.tsx +311 -115
- package/src/components/KYCElements/InitializationStep.tsx +53 -0
- package/src/components/KYCElements/LocationCaptureTemplate.tsx +17 -15
- package/src/components/KYCElements/OrientationVideoCapture.tsx +2 -2
- package/src/components/KYCElements/OrientationVideoCaptureEnhanced.tsx +2 -2
- package/src/components/KYCElements/OrientationVideoCaptureFinal.tsx +2 -2
- package/src/components/KYCElements/ReviewSubmitTemplate.tsx +201 -0
- package/src/components/KYCElements/SelfieCaptureTemplate.tsx +140 -53
- package/src/components/KYCElements/VerificationProgressTemplate.tsx +123 -0
- package/src/components/OverLay/IdCard.tsx +17 -9
- package/src/components/OverLay/SelfieOverlay.tsx +6 -5
- package/src/components/OverLay/type.ts +64 -2
- package/src/components/TemplateKYCExample.tsx +76 -197
- package/src/components/TemplateKYCFlowRefactored.tsx +74 -46
- package/src/components/example/OrientationVideoExample.tsx +3 -7
- package/src/config/countriesData.ts +84 -0
- package/src/config/region_mapping.ts +688 -0
- package/src/hooks/useI18n.ts +53 -0
- package/src/hooks/useOrientationVideo.ts +2 -2
- package/src/hooks/useRealtimeVerifier.ts +128 -0
- package/src/hooks/useTemplateKYCFlow.tsx +375 -53
- package/src/i18n/README.md +288 -0
- package/src/i18n/en/index.ts +206 -0
- package/src/i18n/fr/index.ts +205 -0
- package/src/i18n/index.ts +65 -0
- package/src/i18n/types.ts +172 -0
- package/src/i18n/usage-example.tsx +202 -0
- package/src/modules/api/CardAuthentification.ts +114 -0
- package/src/modules/api/KYCService.ts +403 -30
- package/src/modules/api/SelfieVerification.ts +11 -0
- package/src/modules/api/backendApi.ts +8 -0
- package/src/modules/api/types.ts +24 -0
- package/src/types/KYC.types.ts +83 -14
- package/src/utils/cropByObb.ts +99 -0
- package/src/utils/get-document-type-info.ts +62 -0
- package/src/utils/pathToBase64.ts +47 -0
- package/src/utils/remove-duplicate.ts +3 -0
- package/src/types/nativewind.d.ts +0 -2
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { setLocale, getCurrentLocale, getAvailableLocales, translate, translatePlural } from '../i18n';
|
|
3
|
+
|
|
4
|
+
export interface UseI18nReturn {
|
|
5
|
+
t: (key: string, options?: any) => string;
|
|
6
|
+
tPlural: (key: string, count: number, options?: any) => string;
|
|
7
|
+
locale: string;
|
|
8
|
+
setLocale: (locale: string) => void;
|
|
9
|
+
availableLocales: string[];
|
|
10
|
+
isRTL: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const useI18n = (): UseI18nReturn => {
|
|
14
|
+
const [locale, setCurrentLocale] = useState(getCurrentLocale());
|
|
15
|
+
const [isRTL, setIsRTL] = useState(false);
|
|
16
|
+
|
|
17
|
+
// Update locale state when i18n locale changes
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const updateLocale = () => {
|
|
20
|
+
setCurrentLocale(getCurrentLocale());
|
|
21
|
+
// Check if current locale is RTL (Arabic, Hebrew, etc.)
|
|
22
|
+
setIsRTL(['ar', 'he', 'fa', 'ur'].includes(getCurrentLocale()));
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// Listen for locale changes (if i18n supports events)
|
|
26
|
+
updateLocale();
|
|
27
|
+
}, []);
|
|
28
|
+
|
|
29
|
+
const handleSetLocale = useCallback((newLocale: string) => {
|
|
30
|
+
setLocale(newLocale);
|
|
31
|
+
setCurrentLocale(newLocale);
|
|
32
|
+
setIsRTL(['ar', 'he', 'fa', 'ur'].includes(newLocale));
|
|
33
|
+
}, []);
|
|
34
|
+
|
|
35
|
+
const t = useCallback((key: string, options?: any) => {
|
|
36
|
+
return translate(key, options);
|
|
37
|
+
}, [locale]);
|
|
38
|
+
|
|
39
|
+
const tPlural = useCallback((key: string, count: number, options?: any) => {
|
|
40
|
+
return translatePlural(key, count, options);
|
|
41
|
+
}, [locale]);
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
t,
|
|
45
|
+
tPlural,
|
|
46
|
+
locale,
|
|
47
|
+
setLocale: handleSetLocale,
|
|
48
|
+
availableLocales: getAvailableLocales(),
|
|
49
|
+
isRTL,
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export default useI18n;
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
OrientationVideoResult,
|
|
7
7
|
OrientationType
|
|
8
8
|
} from '../types/KYC.types';
|
|
9
|
-
import
|
|
9
|
+
import kycService from '../modules/api/KYCService';
|
|
10
10
|
|
|
11
11
|
export interface UseOrientationVideoReturn {
|
|
12
12
|
state: OrientationVideoState;
|
|
@@ -15,7 +15,7 @@ export interface UseOrientationVideoReturn {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export const useOrientationVideo = (
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
config?: Partial<OrientationVideoConfig>
|
|
20
20
|
): UseOrientationVideoReturn => {
|
|
21
21
|
const defaultConfig: OrientationVideoConfig = {
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
export type CaptureFunction = () => Promise<{ success: boolean; uri?: string; error?: string }>;
|
|
4
|
+
export type VerifyFunction = (uri: string) => Promise<boolean>;
|
|
5
|
+
|
|
6
|
+
export interface RealtimeVerifierConfig {
|
|
7
|
+
intervalMs?: number; // default 5000
|
|
8
|
+
maxAttempts?: number; // default Infinity
|
|
9
|
+
stopOnError?: boolean; // default false
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface RealtimeVerifierState {
|
|
13
|
+
isRunning: boolean;
|
|
14
|
+
attempts: number;
|
|
15
|
+
lastError?: string | null;
|
|
16
|
+
verifiedUri?: string | null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface RealtimeVerifierControls {
|
|
20
|
+
start: () => void;
|
|
21
|
+
stop: () => void;
|
|
22
|
+
reset: () => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function useRealtimeVerifier(
|
|
26
|
+
capture: CaptureFunction,
|
|
27
|
+
verify: VerifyFunction,
|
|
28
|
+
config?: RealtimeVerifierConfig,
|
|
29
|
+
): { state: RealtimeVerifierState; controls: RealtimeVerifierControls } {
|
|
30
|
+
const { intervalMs = 5000, maxAttempts = Number.POSITIVE_INFINITY, stopOnError = false } = config || {};
|
|
31
|
+
|
|
32
|
+
const [state, setState] = useState<RealtimeVerifierState>({
|
|
33
|
+
isRunning: false,
|
|
34
|
+
attempts: 0,
|
|
35
|
+
lastError: null,
|
|
36
|
+
verifiedUri: null,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const timerRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
|
40
|
+
const runningRef = useRef<boolean>(false);
|
|
41
|
+
const attemptsRef = useRef<number>(0);
|
|
42
|
+
|
|
43
|
+
const tick = useCallback(async () => {
|
|
44
|
+
if (!runningRef.current) return;
|
|
45
|
+
if (attemptsRef.current >= maxAttempts) {
|
|
46
|
+
runningRef.current = false;
|
|
47
|
+
if (timerRef.current) {
|
|
48
|
+
clearInterval(timerRef.current);
|
|
49
|
+
timerRef.current = null;
|
|
50
|
+
}
|
|
51
|
+
setState(prev => ({ ...prev, isRunning: false }));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
attemptsRef.current += 1;
|
|
56
|
+
setState(prev => ({ ...prev, attempts: attemptsRef.current }));
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
const captureResult = await capture();
|
|
60
|
+
if (!captureResult.success || !captureResult.uri) {
|
|
61
|
+
if (stopOnError) {
|
|
62
|
+
throw new Error(captureResult.error || 'Capture failed');
|
|
63
|
+
}
|
|
64
|
+
setState(prev => ({ ...prev, lastError: captureResult.error || 'Capture failed' }));
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const ok = await verify(captureResult.uri);
|
|
69
|
+
if (ok) {
|
|
70
|
+
runningRef.current = false;
|
|
71
|
+
if (timerRef.current) {
|
|
72
|
+
clearInterval(timerRef.current);
|
|
73
|
+
timerRef.current = null;
|
|
74
|
+
}
|
|
75
|
+
setState(prev => ({ ...prev, isRunning: false, verifiedUri: captureResult.uri, lastError: null }));
|
|
76
|
+
}
|
|
77
|
+
} catch (err: any) {
|
|
78
|
+
const message = err?.message || 'Unknown error';
|
|
79
|
+
if (stopOnError) {
|
|
80
|
+
runningRef.current = false;
|
|
81
|
+
if (timerRef.current) {
|
|
82
|
+
clearInterval(timerRef.current);
|
|
83
|
+
timerRef.current = null;
|
|
84
|
+
}
|
|
85
|
+
setState(prev => ({ ...prev, isRunning: false, lastError: message }));
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
setState(prev => ({ ...prev, lastError: message }));
|
|
89
|
+
}
|
|
90
|
+
}, [capture, verify, maxAttempts, stopOnError]);
|
|
91
|
+
|
|
92
|
+
const start = useCallback(() => {
|
|
93
|
+
if (runningRef.current) return;
|
|
94
|
+
runningRef.current = true;
|
|
95
|
+
setState(prev => ({ ...prev, isRunning: true, lastError: null }));
|
|
96
|
+
// Fire immediately, then every interval
|
|
97
|
+
tick();
|
|
98
|
+
timerRef.current = setInterval(tick, intervalMs);
|
|
99
|
+
}, [intervalMs, tick]);
|
|
100
|
+
|
|
101
|
+
const stop = useCallback(() => {
|
|
102
|
+
runningRef.current = false;
|
|
103
|
+
if (timerRef.current) {
|
|
104
|
+
clearInterval(timerRef.current);
|
|
105
|
+
timerRef.current = null;
|
|
106
|
+
}
|
|
107
|
+
setState(prev => ({ ...prev, isRunning: false }));
|
|
108
|
+
}, []);
|
|
109
|
+
|
|
110
|
+
const reset = useCallback(() => {
|
|
111
|
+
attemptsRef.current = 0;
|
|
112
|
+
setState({ isRunning: false, attempts: 0, lastError: null, verifiedUri: null });
|
|
113
|
+
}, []);
|
|
114
|
+
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
return () => {
|
|
117
|
+
if (timerRef.current) {
|
|
118
|
+
clearInterval(timerRef.current);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}, []);
|
|
122
|
+
|
|
123
|
+
return { state, controls: { start, stop, reset } };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export default useRealtimeVerifier;
|
|
127
|
+
|
|
128
|
+
|