@transfergratis/react-native-sdk 0.1.4 → 0.1.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.
Files changed (216) hide show
  1. package/build/api/axios.d.ts +30 -0
  2. package/build/api/axios.d.ts.map +1 -0
  3. package/build/api/axios.js +92 -0
  4. package/build/api/axios.js.map +1 -0
  5. package/build/components/EnhancedCameraView.d.ts +1 -41
  6. package/build/components/EnhancedCameraView.d.ts.map +1 -1
  7. package/build/components/EnhancedCameraView.js +75 -34
  8. package/build/components/EnhancedCameraView.js.map +1 -1
  9. package/build/components/EnhancedCameraView.web.d.ts +1 -41
  10. package/build/components/EnhancedCameraView.web.d.ts.map +1 -1
  11. package/build/components/EnhancedCameraView.web.js +28 -4
  12. package/build/components/EnhancedCameraView.web.js.map +1 -1
  13. package/build/components/KYCElements/CountrySelectionTemplate.d.ts +2 -2
  14. package/build/components/KYCElements/CountrySelectionTemplate.d.ts.map +1 -1
  15. package/build/components/KYCElements/CountrySelectionTemplate.js +77 -114
  16. package/build/components/KYCElements/CountrySelectionTemplate.js.map +1 -1
  17. package/build/components/KYCElements/FileUploadTemplate.d.ts.map +1 -1
  18. package/build/components/KYCElements/FileUploadTemplate.js +7 -3
  19. package/build/components/KYCElements/FileUploadTemplate.js.map +1 -1
  20. package/build/components/KYCElements/IDCardCapture.d.ts +7 -2
  21. package/build/components/KYCElements/IDCardCapture.d.ts.map +1 -1
  22. package/build/components/KYCElements/IDCardCapture.js +253 -104
  23. package/build/components/KYCElements/IDCardCapture.js.map +1 -1
  24. package/build/components/KYCElements/InitializationStep.d.ts +5 -0
  25. package/build/components/KYCElements/InitializationStep.d.ts.map +1 -0
  26. package/build/components/KYCElements/InitializationStep.js +41 -0
  27. package/build/components/KYCElements/InitializationStep.js.map +1 -0
  28. package/build/components/KYCElements/LocationCaptureTemplate.d.ts.map +1 -1
  29. package/build/components/KYCElements/LocationCaptureTemplate.js +15 -13
  30. package/build/components/KYCElements/LocationCaptureTemplate.js.map +1 -1
  31. package/build/components/KYCElements/OrientationVideoCapture.d.ts +2 -2
  32. package/build/components/KYCElements/OrientationVideoCapture.d.ts.map +1 -1
  33. package/build/components/KYCElements/OrientationVideoCapture.js.map +1 -1
  34. package/build/components/KYCElements/OrientationVideoCaptureEnhanced.d.ts +2 -2
  35. package/build/components/KYCElements/OrientationVideoCaptureEnhanced.d.ts.map +1 -1
  36. package/build/components/KYCElements/OrientationVideoCaptureEnhanced.js.map +1 -1
  37. package/build/components/KYCElements/OrientationVideoCaptureFinal.d.ts +2 -2
  38. package/build/components/KYCElements/OrientationVideoCaptureFinal.d.ts.map +1 -1
  39. package/build/components/KYCElements/OrientationVideoCaptureFinal.js.map +1 -1
  40. package/build/components/KYCElements/ReviewSubmitTemplate.d.ts +12 -0
  41. package/build/components/KYCElements/ReviewSubmitTemplate.d.ts.map +1 -0
  42. package/build/components/KYCElements/ReviewSubmitTemplate.js +171 -0
  43. package/build/components/KYCElements/ReviewSubmitTemplate.js.map +1 -0
  44. package/build/components/KYCElements/SelfieCaptureTemplate.d.ts +6 -2
  45. package/build/components/KYCElements/SelfieCaptureTemplate.d.ts.map +1 -1
  46. package/build/components/KYCElements/SelfieCaptureTemplate.js +137 -38
  47. package/build/components/KYCElements/SelfieCaptureTemplate.js.map +1 -1
  48. package/build/components/KYCElements/VerificationProgressTemplate.d.ts +12 -0
  49. package/build/components/KYCElements/VerificationProgressTemplate.d.ts.map +1 -0
  50. package/build/components/KYCElements/VerificationProgressTemplate.js +194 -0
  51. package/build/components/KYCElements/VerificationProgressTemplate.js.map +1 -0
  52. package/build/components/OverLay/IdCard.d.ts +1 -1
  53. package/build/components/OverLay/IdCard.d.ts.map +1 -1
  54. package/build/components/OverLay/IdCard.js +10 -6
  55. package/build/components/OverLay/IdCard.js.map +1 -1
  56. package/build/components/OverLay/SelfieOverlay.d.ts +1 -1
  57. package/build/components/OverLay/SelfieOverlay.d.ts.map +1 -1
  58. package/build/components/OverLay/SelfieOverlay.js +5 -4
  59. package/build/components/OverLay/SelfieOverlay.js.map +1 -1
  60. package/build/components/OverLay/type.d.ts +71 -1
  61. package/build/components/OverLay/type.d.ts.map +1 -1
  62. package/build/components/OverLay/type.js.map +1 -1
  63. package/build/components/TemplateKYCExample.d.ts +4 -1
  64. package/build/components/TemplateKYCExample.d.ts.map +1 -1
  65. package/build/components/TemplateKYCExample.js +74 -199
  66. package/build/components/TemplateKYCExample.js.map +1 -1
  67. package/build/components/TemplateKYCFlowRefactored.d.ts +3 -2
  68. package/build/components/TemplateKYCFlowRefactored.d.ts.map +1 -1
  69. package/build/components/TemplateKYCFlowRefactored.js +64 -40
  70. package/build/components/TemplateKYCFlowRefactored.js.map +1 -1
  71. package/build/components/example/OrientationVideoExample.d.ts.map +1 -1
  72. package/build/components/example/OrientationVideoExample.js +1 -5
  73. package/build/components/example/OrientationVideoExample.js.map +1 -1
  74. package/build/config/countriesData.d.ts +3 -0
  75. package/build/config/countriesData.d.ts.map +1 -0
  76. package/build/config/countriesData.js +79 -0
  77. package/build/config/countriesData.js.map +1 -0
  78. package/build/config/region_mapping.d.ts +3 -0
  79. package/build/config/region_mapping.d.ts.map +1 -0
  80. package/build/config/region_mapping.js +687 -0
  81. package/build/config/region_mapping.js.map +1 -0
  82. package/build/hooks/useI18n.d.ts +11 -0
  83. package/build/hooks/useI18n.d.ts.map +1 -0
  84. package/build/hooks/useI18n.js +37 -0
  85. package/build/hooks/useI18n.js.map +1 -0
  86. package/build/hooks/useOrientationVideo.d.ts +1 -2
  87. package/build/hooks/useOrientationVideo.d.ts.map +1 -1
  88. package/build/hooks/useOrientationVideo.js +2 -1
  89. package/build/hooks/useOrientationVideo.js.map +1 -1
  90. package/build/hooks/useRealtimeVerifier.d.ts +28 -0
  91. package/build/hooks/useRealtimeVerifier.d.ts.map +1 -0
  92. package/build/hooks/useRealtimeVerifier.js +91 -0
  93. package/build/hooks/useRealtimeVerifier.js.map +1 -0
  94. package/build/hooks/useTemplateKYCFlow.d.ts +6 -3
  95. package/build/hooks/useTemplateKYCFlow.d.ts.map +1 -1
  96. package/build/hooks/useTemplateKYCFlow.js +356 -42
  97. package/build/hooks/useTemplateKYCFlow.js.map +1 -1
  98. package/build/i18n/en/index.d.ts +168 -0
  99. package/build/i18n/en/index.d.ts.map +1 -0
  100. package/build/i18n/en/index.js +195 -0
  101. package/build/i18n/en/index.js.map +1 -0
  102. package/build/i18n/fr/index.d.ts +168 -0
  103. package/build/i18n/fr/index.d.ts.map +1 -0
  104. package/build/i18n/fr/index.js +194 -0
  105. package/build/i18n/fr/index.js.map +1 -0
  106. package/build/i18n/index.d.ts +10 -0
  107. package/build/i18n/index.d.ts.map +1 -0
  108. package/build/i18n/index.js +56 -0
  109. package/build/i18n/index.js.map +1 -0
  110. package/build/i18n/types.d.ts +153 -0
  111. package/build/i18n/types.d.ts.map +1 -0
  112. package/build/i18n/types.js +3 -0
  113. package/build/i18n/types.js.map +1 -0
  114. package/build/i18n/usage-example.d.ts +4 -0
  115. package/build/i18n/usage-example.d.ts.map +1 -0
  116. package/build/i18n/usage-example.js +189 -0
  117. package/build/i18n/usage-example.js.map +1 -0
  118. package/build/index.d.ts +1 -0
  119. package/build/index.d.ts.map +1 -1
  120. package/build/index.js +2 -0
  121. package/build/index.js.map +1 -1
  122. package/build/modules/api/CardAuthentification.d.ts +22 -0
  123. package/build/modules/api/CardAuthentification.d.ts.map +1 -0
  124. package/build/modules/api/CardAuthentification.js +107 -0
  125. package/build/modules/api/CardAuthentification.js.map +1 -0
  126. package/build/modules/api/KYCService.d.ts +58 -1
  127. package/build/modules/api/KYCService.d.ts.map +1 -1
  128. package/build/modules/api/KYCService.js +304 -27
  129. package/build/modules/api/KYCService.js.map +1 -1
  130. package/build/modules/api/SelfieVerification.d.ts +3 -0
  131. package/build/modules/api/SelfieVerification.d.ts.map +1 -0
  132. package/build/modules/api/SelfieVerification.js +9 -0
  133. package/build/modules/api/SelfieVerification.js.map +1 -0
  134. package/build/modules/api/backendApi.d.ts +2 -0
  135. package/build/modules/api/backendApi.d.ts.map +1 -0
  136. package/build/modules/api/backendApi.js +6 -0
  137. package/build/modules/api/backendApi.js.map +1 -0
  138. package/build/modules/api/types.d.ts +45 -0
  139. package/build/modules/api/types.d.ts.map +1 -0
  140. package/build/modules/api/types.js +2 -0
  141. package/build/modules/api/types.js.map +1 -0
  142. package/build/types/KYC.types.d.ts +56 -7
  143. package/build/types/KYC.types.d.ts.map +1 -1
  144. package/build/types/KYC.types.js +9 -1
  145. package/build/types/KYC.types.js.map +1 -1
  146. package/build/utils/cropByObb.d.ts +11 -0
  147. package/build/utils/cropByObb.d.ts.map +1 -0
  148. package/build/utils/cropByObb.js +78 -0
  149. package/build/utils/cropByObb.js.map +1 -0
  150. package/build/utils/get-document-type-info.d.ts +13 -0
  151. package/build/utils/get-document-type-info.d.ts.map +1 -0
  152. package/build/utils/get-document-type-info.js +59 -0
  153. package/build/utils/get-document-type-info.js.map +1 -0
  154. package/build/utils/pathToBase64.d.ts +3 -0
  155. package/build/utils/pathToBase64.d.ts.map +1 -0
  156. package/build/utils/pathToBase64.js +47 -0
  157. package/build/utils/pathToBase64.js.map +1 -0
  158. package/build/utils/remove-duplicate.d.ts +2 -0
  159. package/build/utils/remove-duplicate.d.ts.map +1 -0
  160. package/build/utils/remove-duplicate.js +4 -0
  161. package/build/utils/remove-duplicate.js.map +1 -0
  162. package/build/web/WebKYCEntry.d.ts +9 -0
  163. package/build/web/WebKYCEntry.d.ts.map +1 -0
  164. package/build/web/WebKYCEntry.js +156 -0
  165. package/build/web/WebKYCEntry.js.map +1 -0
  166. package/build/web/index.d.ts +2 -0
  167. package/build/web/index.d.ts.map +1 -0
  168. package/build/web/index.js +2 -0
  169. package/build/web/index.js.map +1 -0
  170. package/package.json +3 -1
  171. package/src/api/axios.ts +144 -0
  172. package/src/components/EnhancedCameraView.tsx +96 -78
  173. package/src/components/EnhancedCameraView.web.tsx +41 -40
  174. package/src/components/KYCElements/CountrySelectionTemplate.tsx +111 -136
  175. package/src/components/KYCElements/FileUploadTemplate.tsx +14 -8
  176. package/src/components/KYCElements/IDCardCapture.tsx +311 -115
  177. package/src/components/KYCElements/InitializationStep.tsx +53 -0
  178. package/src/components/KYCElements/LocationCaptureTemplate.tsx +17 -15
  179. package/src/components/KYCElements/OrientationVideoCapture.tsx +2 -2
  180. package/src/components/KYCElements/OrientationVideoCaptureEnhanced.tsx +2 -2
  181. package/src/components/KYCElements/OrientationVideoCaptureFinal.tsx +2 -2
  182. package/src/components/KYCElements/ReviewSubmitTemplate.tsx +201 -0
  183. package/src/components/KYCElements/SelfieCaptureTemplate.tsx +174 -57
  184. package/src/components/KYCElements/VerificationProgressTemplate.tsx +246 -0
  185. package/src/components/OverLay/IdCard.tsx +17 -9
  186. package/src/components/OverLay/SelfieOverlay.tsx +6 -5
  187. package/src/components/OverLay/type.ts +64 -2
  188. package/src/components/TemplateKYCExample.tsx +80 -200
  189. package/src/components/TemplateKYCFlowRefactored.tsx +80 -48
  190. package/src/components/example/OrientationVideoExample.tsx +3 -7
  191. package/src/config/countriesData.ts +84 -0
  192. package/src/config/region_mapping.ts +688 -0
  193. package/src/hooks/useI18n.ts +53 -0
  194. package/src/hooks/useOrientationVideo.ts +2 -2
  195. package/src/hooks/useRealtimeVerifier.ts +128 -0
  196. package/src/hooks/useTemplateKYCFlow.tsx +407 -57
  197. package/src/i18n/README.md +288 -0
  198. package/src/i18n/en/index.ts +206 -0
  199. package/src/i18n/fr/index.ts +205 -0
  200. package/src/i18n/index.ts +65 -0
  201. package/src/i18n/types.ts +172 -0
  202. package/src/i18n/usage-example.tsx +202 -0
  203. package/src/index.ts +3 -0
  204. package/src/modules/api/CardAuthentification.ts +114 -0
  205. package/src/modules/api/KYCService.ts +350 -30
  206. package/src/modules/api/SelfieVerification.ts +11 -0
  207. package/src/modules/api/backendApi.ts +8 -0
  208. package/src/modules/api/types.ts +51 -0
  209. package/src/types/KYC.types.ts +82 -14
  210. package/src/utils/cropByObb.ts +99 -0
  211. package/src/utils/get-document-type-info.ts +62 -0
  212. package/src/utils/pathToBase64.ts +47 -0
  213. package/src/utils/remove-duplicate.ts +3 -0
  214. package/src/web/WebKYCEntry.tsx +215 -0
  215. package/src/web/index.ts +1 -0
  216. 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 KYCService from '../modules/api/KYCService';
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
- kycService: KYCService,
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
+