@transfergratis/react-native-sdk 0.1.23 → 0.1.25

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 (207) hide show
  1. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/AndroidManifest.xml +12 -5
  2. package/android/build/intermediates/aar_main_jar/debug/syncDebugLibJars/classes.jar +0 -0
  3. package/android/build/intermediates/annotations_typedef_file/debug/extractDebugAnnotations/typedefs.txt +0 -0
  4. package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +1 -1
  5. package/android/build/intermediates/incremental/debug-mergeJavaRes/merge-state +0 -0
  6. package/android/build/intermediates/manifest_merge_blame_file/debug/processDebugManifest/manifest-merger-blame-debug-report.txt +61 -59
  7. package/android/build/intermediates/merged_java_res/debug/mergeDebugJavaResource/feature-transfergratis-react-native-sdk.jar +0 -0
  8. package/android/build/intermediates/merged_manifest/debug/processDebugManifest/AndroidManifest.xml +12 -5
  9. package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
  10. package/android/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
  11. package/android/build/outputs/aar/transfergratis-react-native-sdk-debug.aar +0 -0
  12. package/android/build/outputs/logs/manifest-merger-debug-report.txt +26 -34
  13. package/android/src/main/AndroidManifest.xml +13 -5
  14. package/build/components/EnhancedCameraView.d.ts.map +1 -1
  15. package/build/components/EnhancedCameraView.js +26 -3
  16. package/build/components/EnhancedCameraView.js.map +1 -1
  17. package/build/components/EnhancedCameraView.web.d.ts.map +1 -1
  18. package/build/components/EnhancedCameraView.web.js +21 -0
  19. package/build/components/EnhancedCameraView.web.js.map +1 -1
  20. package/build/components/KYCElements/AdditionalDocumentsTemplate.d.ts +12 -0
  21. package/build/components/KYCElements/AdditionalDocumentsTemplate.d.ts.map +1 -0
  22. package/build/components/KYCElements/AdditionalDocumentsTemplate.js +283 -0
  23. package/build/components/KYCElements/AdditionalDocumentsTemplate.js.map +1 -0
  24. package/build/components/KYCElements/CameraCapture.d.ts.map +1 -1
  25. package/build/components/KYCElements/CameraCapture.js +4 -3
  26. package/build/components/KYCElements/CameraCapture.js.map +1 -1
  27. package/build/components/KYCElements/CountrySelectionTemplate.d.ts +5 -2
  28. package/build/components/KYCElements/CountrySelectionTemplate.d.ts.map +1 -1
  29. package/build/components/KYCElements/CountrySelectionTemplate.js +360 -101
  30. package/build/components/KYCElements/CountrySelectionTemplate.js.map +1 -1
  31. package/build/components/KYCElements/EmailVerificationTemplate.d.ts +12 -0
  32. package/build/components/KYCElements/EmailVerificationTemplate.d.ts.map +1 -0
  33. package/build/components/KYCElements/EmailVerificationTemplate.js +193 -0
  34. package/build/components/KYCElements/EmailVerificationTemplate.js.map +1 -0
  35. package/build/components/KYCElements/FileUpload.d.ts.map +1 -1
  36. package/build/components/KYCElements/FileUpload.js +5 -4
  37. package/build/components/KYCElements/FileUpload.js.map +1 -1
  38. package/build/components/KYCElements/FileUploadTemplate.d.ts.map +1 -1
  39. package/build/components/KYCElements/FileUploadTemplate.js +5 -4
  40. package/build/components/KYCElements/FileUploadTemplate.js.map +1 -1
  41. package/build/components/KYCElements/IDCardCapture.d.ts.map +1 -1
  42. package/build/components/KYCElements/IDCardCapture.js +356 -227
  43. package/build/components/KYCElements/IDCardCapture.js.map +1 -1
  44. package/build/components/KYCElements/LocationCaptureTemplate.d.ts.map +1 -1
  45. package/build/components/KYCElements/LocationCaptureTemplate.js +78 -37
  46. package/build/components/KYCElements/LocationCaptureTemplate.js.map +1 -1
  47. package/build/components/KYCElements/OrientationVideoCapture.d.ts +2 -0
  48. package/build/components/KYCElements/OrientationVideoCapture.d.ts.map +1 -1
  49. package/build/components/KYCElements/OrientationVideoCapture.js +5 -4
  50. package/build/components/KYCElements/OrientationVideoCapture.js.map +1 -1
  51. package/build/components/KYCElements/OrientationVideoCaptureEnhanced.d.ts +2 -0
  52. package/build/components/KYCElements/OrientationVideoCaptureEnhanced.d.ts.map +1 -1
  53. package/build/components/KYCElements/OrientationVideoCaptureEnhanced.js +5 -4
  54. package/build/components/KYCElements/OrientationVideoCaptureEnhanced.js.map +1 -1
  55. package/build/components/KYCElements/OrientationVideoCaptureFinal.d.ts +2 -0
  56. package/build/components/KYCElements/OrientationVideoCaptureFinal.d.ts.map +1 -1
  57. package/build/components/KYCElements/OrientationVideoCaptureFinal.js +5 -4
  58. package/build/components/KYCElements/OrientationVideoCaptureFinal.js.map +1 -1
  59. package/build/components/KYCElements/PersonalInformationTemplate.d.ts +12 -0
  60. package/build/components/KYCElements/PersonalInformationTemplate.d.ts.map +1 -0
  61. package/build/components/KYCElements/PersonalInformationTemplate.js +120 -0
  62. package/build/components/KYCElements/PersonalInformationTemplate.js.map +1 -0
  63. package/build/components/KYCElements/PhoneVerificationTemplate.d.ts +12 -0
  64. package/build/components/KYCElements/PhoneVerificationTemplate.d.ts.map +1 -0
  65. package/build/components/KYCElements/PhoneVerificationTemplate.js +185 -0
  66. package/build/components/KYCElements/PhoneVerificationTemplate.js.map +1 -0
  67. package/build/components/KYCElements/SelfieCapture.d.ts.map +1 -1
  68. package/build/components/KYCElements/SelfieCapture.js +4 -3
  69. package/build/components/KYCElements/SelfieCapture.js.map +1 -1
  70. package/build/components/KYCElements/SelfieCaptureTemplate.d.ts.map +1 -1
  71. package/build/components/KYCElements/SelfieCaptureTemplate.js +189 -42
  72. package/build/components/KYCElements/SelfieCaptureTemplate.js.map +1 -1
  73. package/build/components/KYCElements/WelcomeTemplate.d.ts +12 -0
  74. package/build/components/KYCElements/WelcomeTemplate.d.ts.map +1 -0
  75. package/build/components/KYCElements/WelcomeTemplate.js +243 -0
  76. package/build/components/KYCElements/WelcomeTemplate.js.map +1 -0
  77. package/build/components/TemplateKYCExample.d.ts +8 -2
  78. package/build/components/TemplateKYCExample.d.ts.map +1 -1
  79. package/build/components/TemplateKYCExample.js +10 -97
  80. package/build/components/TemplateKYCExample.js.map +1 -1
  81. package/build/components/TemplateKYCFlowRefactored.d.ts +6 -1
  82. package/build/components/TemplateKYCFlowRefactored.d.ts.map +1 -1
  83. package/build/components/TemplateKYCFlowRefactored.js +108 -11
  84. package/build/components/TemplateKYCFlowRefactored.js.map +1 -1
  85. package/build/components/example/DynamicTemplateExample.d.ts +10 -0
  86. package/build/components/example/DynamicTemplateExample.d.ts.map +1 -0
  87. package/build/components/example/DynamicTemplateExample.js +241 -0
  88. package/build/components/example/DynamicTemplateExample.js.map +1 -0
  89. package/build/config/KYCConfig.d.ts +14 -0
  90. package/build/config/KYCConfig.d.ts.map +1 -0
  91. package/build/config/KYCConfig.js +26 -0
  92. package/build/config/KYCConfig.js.map +1 -0
  93. package/build/config/allowedDomains.d.ts +30 -0
  94. package/build/config/allowedDomains.d.ts.map +1 -0
  95. package/build/config/allowedDomains.js +112 -0
  96. package/build/config/allowedDomains.js.map +1 -0
  97. package/build/hooks/useOrientationVideo.d.ts +2 -1
  98. package/build/hooks/useOrientationVideo.d.ts.map +1 -1
  99. package/build/hooks/useOrientationVideo.js +3 -3
  100. package/build/hooks/useOrientationVideo.js.map +1 -1
  101. package/build/hooks/useTemplateKYCFlow.d.ts +6 -1
  102. package/build/hooks/useTemplateKYCFlow.d.ts.map +1 -1
  103. package/build/hooks/useTemplateKYCFlow.js +317 -34
  104. package/build/hooks/useTemplateKYCFlow.js.map +1 -1
  105. package/build/hooks/useTemplateLoader.d.ts +14 -0
  106. package/build/hooks/useTemplateLoader.d.ts.map +1 -0
  107. package/build/hooks/useTemplateLoader.js +85 -0
  108. package/build/hooks/useTemplateLoader.js.map +1 -0
  109. package/build/i18n/en/index.d.ts +49 -0
  110. package/build/i18n/en/index.d.ts.map +1 -1
  111. package/build/i18n/en/index.js +50 -1
  112. package/build/i18n/en/index.js.map +1 -1
  113. package/build/i18n/fr/index.d.ts +35 -0
  114. package/build/i18n/fr/index.d.ts.map +1 -1
  115. package/build/i18n/fr/index.js +36 -1
  116. package/build/i18n/fr/index.js.map +1 -1
  117. package/build/index.d.ts +6 -0
  118. package/build/index.d.ts.map +1 -1
  119. package/build/index.js +10 -0
  120. package/build/index.js.map +1 -1
  121. package/build/modules/api/CardAuthentification.d.ts +24 -3
  122. package/build/modules/api/CardAuthentification.d.ts.map +1 -1
  123. package/build/modules/api/CardAuthentification.js +69 -10
  124. package/build/modules/api/CardAuthentification.js.map +1 -1
  125. package/build/modules/api/KYCService.d.ts +7 -7
  126. package/build/modules/api/KYCService.d.ts.map +1 -1
  127. package/build/modules/api/KYCService.js +108 -39
  128. package/build/modules/api/KYCService.js.map +1 -1
  129. package/build/modules/api/SelfieVerification.d.ts +3 -1
  130. package/build/modules/api/SelfieVerification.d.ts.map +1 -1
  131. package/build/modules/api/SelfieVerification.js +17 -1
  132. package/build/modules/api/SelfieVerification.js.map +1 -1
  133. package/build/modules/api/TemplateService.d.ts +44 -0
  134. package/build/modules/api/TemplateService.d.ts.map +1 -0
  135. package/build/modules/api/TemplateService.js +145 -0
  136. package/build/modules/api/TemplateService.js.map +1 -0
  137. package/build/types/KYC.types.d.ts +265 -4
  138. package/build/types/KYC.types.d.ts.map +1 -1
  139. package/build/types/KYC.types.js +15 -0
  140. package/build/types/KYC.types.js.map +1 -1
  141. package/build/types/env.types.d.ts +13 -0
  142. package/build/types/env.types.d.ts.map +1 -0
  143. package/build/types/env.types.js +2 -0
  144. package/build/types/env.types.js.map +1 -0
  145. package/build/utils/cropByObb.d.ts +1 -0
  146. package/build/utils/cropByObb.d.ts.map +1 -1
  147. package/build/utils/cropByObb.js +70 -0
  148. package/build/utils/cropByObb.js.map +1 -1
  149. package/build/utils/deviceDetection.d.ts +6 -0
  150. package/build/utils/deviceDetection.d.ts.map +1 -0
  151. package/build/utils/deviceDetection.js +12 -0
  152. package/build/utils/deviceDetection.js.map +1 -0
  153. package/build/utils/platformAlert.d.ts +20 -0
  154. package/build/utils/platformAlert.d.ts.map +1 -0
  155. package/build/utils/platformAlert.js +67 -0
  156. package/build/utils/platformAlert.js.map +1 -0
  157. package/build/utils/template-transformer.d.ts +10 -0
  158. package/build/utils/template-transformer.d.ts.map +1 -0
  159. package/build/utils/template-transformer.js +365 -0
  160. package/build/utils/template-transformer.js.map +1 -0
  161. package/build/web/WebKYCEntry.d.ts.map +1 -1
  162. package/build/web/WebKYCEntry.js +158 -32
  163. package/build/web/WebKYCEntry.js.map +1 -1
  164. package/package.json +1 -1
  165. package/plugin/build/withVisionCamera.js +3 -4
  166. package/plugin/src/withVisionCamera.js +3 -4
  167. package/plugin/src/withVisionCamera.ts +3 -4
  168. package/src/components/EnhancedCameraView.tsx +31 -2
  169. package/src/components/EnhancedCameraView.web.tsx +24 -0
  170. package/src/components/KYCElements/AdditionalDocumentsTemplate.tsx +346 -0
  171. package/src/components/KYCElements/CameraCapture.tsx +4 -3
  172. package/src/components/KYCElements/CountrySelectionTemplate.tsx +410 -113
  173. package/src/components/KYCElements/EmailVerificationTemplate.tsx +264 -0
  174. package/src/components/KYCElements/FileUpload.tsx +5 -4
  175. package/src/components/KYCElements/FileUploadTemplate.tsx +5 -4
  176. package/src/components/KYCElements/IDCardCapture.tsx +397 -254
  177. package/src/components/KYCElements/LocationCaptureTemplate.tsx +95 -44
  178. package/src/components/KYCElements/OrientationVideoCapture.tsx +6 -3
  179. package/src/components/KYCElements/OrientationVideoCaptureEnhanced.tsx +6 -3
  180. package/src/components/KYCElements/OrientationVideoCaptureFinal.tsx +6 -3
  181. package/src/components/KYCElements/PersonalInformationTemplate.tsx +158 -0
  182. package/src/components/KYCElements/PhoneVerificationTemplate.tsx +253 -0
  183. package/src/components/KYCElements/SelfieCapture.tsx +4 -3
  184. package/src/components/KYCElements/SelfieCaptureTemplate.tsx +201 -44
  185. package/src/components/KYCElements/WelcomeTemplate.tsx +289 -0
  186. package/src/components/TemplateKYCExample.tsx +37 -108
  187. package/src/components/TemplateKYCFlowRefactored.tsx +148 -12
  188. package/src/components/example/DynamicTemplateExample.tsx +289 -0
  189. package/src/config/KYCConfig.ts +34 -0
  190. package/src/config/allowedDomains.ts +133 -0
  191. package/src/hooks/useOrientationVideo.ts +5 -4
  192. package/src/hooks/useTemplateKYCFlow.tsx +347 -32
  193. package/src/hooks/useTemplateLoader.ts +102 -0
  194. package/src/i18n/en/index.ts +53 -2
  195. package/src/i18n/fr/index.ts +37 -1
  196. package/src/index.ts +14 -0
  197. package/src/modules/api/CardAuthentification.ts +76 -11
  198. package/src/modules/api/KYCService.ts +129 -45
  199. package/src/modules/api/SelfieVerification.ts +25 -3
  200. package/src/modules/api/TemplateService.ts +167 -0
  201. package/src/types/KYC.types.ts +331 -3
  202. package/src/types/env.types.ts +13 -0
  203. package/src/utils/cropByObb.ts +83 -3
  204. package/src/utils/deviceDetection.ts +11 -0
  205. package/src/utils/platformAlert.ts +86 -0
  206. package/src/utils/template-transformer.ts +445 -0
  207. package/src/web/WebKYCEntry.tsx +199 -50
@@ -0,0 +1,13 @@
1
+ /**
2
+ * KYC Environment types
3
+ * PRODUCTION: Full verification with AI checks
4
+ * SANDBOX: Skip AI verification, only save data to backend
5
+ */
6
+ export type KycEnvironment = 'PRODUCTION' | 'SANDBOX';
7
+ /**
8
+ * Backend Environment types
9
+ * PRODUCTION: Production backend
10
+ * TEST: Test backend
11
+ */
12
+ export type BackendEnvironment = 'PRODUCTION' | 'TEST';
13
+ //# sourceMappingURL=env.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.types.d.ts","sourceRoot":"","sources":["../../src/types/env.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,SAAS,CAAC;AAEtD;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,MAAM,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=env.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.types.js","sourceRoot":"","sources":["../../src/types/env.types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * KYC Environment types\n * PRODUCTION: Full verification with AI checks\n * SANDBOX: Skip AI verification, only save data to backend\n */\nexport type KycEnvironment = 'PRODUCTION' | 'SANDBOX';\n\n/**\n * Backend Environment types\n * PRODUCTION: Production backend\n * TEST: Test backend\n */\nexport type BackendEnvironment = 'PRODUCTION' | 'TEST';\n"]}
@@ -8,4 +8,5 @@ export declare function cropByObb(uri: string, cardObb: any): Promise<{
8
8
  };
9
9
  }>;
10
10
  export declare function cropImageWithBBox(uri: string, bbox: any): Promise<string>;
11
+ export declare function cropImageWithBBoxWithTolerance(uri: string, bbox: any, tolerance?: number): Promise<string>;
11
12
  //# sourceMappingURL=cropByObb.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cropByObb.d.ts","sourceRoot":"","sources":["../../src/utils/cropByObb.ts"],"names":[],"mappings":"AA+CA,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC,CAkB7J;AAMD,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,mBA2B7D"}
1
+ {"version":3,"file":"cropByObb.d.ts","sourceRoot":"","sources":["../../src/utils/cropByObb.ts"],"names":[],"mappings":"AAiDA,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC,CAkB7J;AAMD,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,mBA4B7D;AAGD,wBAAsB,8BAA8B,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,GAAE,MAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CA0ErH"}
@@ -1,5 +1,7 @@
1
1
  import { Image as RNImage, Platform } from 'react-native';
2
2
  import * as ImageManipulator from "expo-image-manipulator";
3
+ import { truncateFields } from '../modules/api/KYCService';
4
+ import { logger } from './logger';
3
5
  // Compute axis-aligned bounding box from oriented quadrilateral
4
6
  function computeAabb(points) {
5
7
  const xs = points.map(p => p[0]);
@@ -71,8 +73,76 @@ export async function cropImageWithBBox(uri, bbox) {
71
73
  height: bbox.height,
72
74
  };
73
75
  // 4️⃣ Appliquer le crop
76
+ // @ts-ignore - manipulateAsync is deprecated but still functional, new API (useImageManipulator) is a React hook and not suitable for utility functions
74
77
  const result = await ImageManipulator.manipulateAsync(uri, [{ crop }], { compress: 1, format: ImageManipulator.SaveFormat.PNG });
75
78
  console.log("Image recadrée:", result.uri);
76
79
  return result.uri;
77
80
  }
81
+ // Fonction pour rogner avec une tolérance de 10% autour du bbox
82
+ export async function cropImageWithBBoxWithTolerance(uri, bbox, tolerance = 0.1) {
83
+ console.log("cropImageWithBBoxWithTolerance", JSON.stringify(truncateFields({ uri, bbox, tolerance }), null, 2));
84
+ return new Promise((resolve, reject) => {
85
+ let isResolved = false;
86
+ // Timeout de sécurité (15 secondes)
87
+ const timeout = setTimeout(() => {
88
+ if (!isResolved) {
89
+ isResolved = true;
90
+ console.warn("Timeout lors du rognage avec tolérance, utilisation de l'image originale");
91
+ resolve(uri); // Retourner l'URI original en cas de timeout
92
+ }
93
+ }, 15000);
94
+ // 1️⃣ Récupère la taille originale de l'image
95
+ RNImage.getSize(uri, (imageWidth, imageHeight) => {
96
+ if (isResolved)
97
+ return;
98
+ // 2️⃣ Calculer la tolérance en pixels (10% de chaque côté)
99
+ const toleranceX = bbox.width * tolerance;
100
+ const toleranceY = bbox.height * tolerance;
101
+ // 3️⃣ Ajuster le bbox avec la tolérance
102
+ // Calculer les nouvelles coordonnées avec tolérance
103
+ const newMinX = Math.max(0, bbox.minX - toleranceX);
104
+ const newMinY = Math.max(0, bbox.minY - toleranceY);
105
+ const newMaxX = Math.min(imageWidth, bbox.minX + bbox.width + toleranceX);
106
+ const newMaxY = Math.min(imageHeight, bbox.minY + bbox.height + toleranceY);
107
+ // Calculer la largeur et hauteur finales
108
+ const finalWidth = newMaxX - newMinX;
109
+ const finalHeight = newMaxY - newMinY;
110
+ const crop = {
111
+ originX: newMinX,
112
+ originY: newMinY,
113
+ width: finalWidth,
114
+ height: finalHeight,
115
+ };
116
+ logger.log("cropImageWithBBoxWithTolerance - crop params", JSON.stringify(truncateFields({ uri, crop, tolerance, imageWidth, imageHeight }), null, 2));
117
+ // 4️⃣ Appliquer le crop avec tolérance
118
+ // @ts-ignore - manipulateAsync is deprecated but still functional, new API (useImageManipulator) is a React hook and not suitable for utility functions
119
+ ImageManipulator.manipulateAsync(uri, [{ crop }], { compress: 0.95, format: ImageManipulator.SaveFormat.JPEG })
120
+ .then((result) => {
121
+ if (isResolved)
122
+ return;
123
+ isResolved = true;
124
+ clearTimeout(timeout);
125
+ console.log("Image recadrée avec tolérance:", result.uri);
126
+ resolve(result.uri);
127
+ })
128
+ .catch((error) => {
129
+ if (isResolved)
130
+ return;
131
+ isResolved = true;
132
+ clearTimeout(timeout);
133
+ console.error("Erreur lors du rognage avec tolérance:", error);
134
+ // En cas d'erreur, retourner l'URI original au lieu de rejeter
135
+ resolve(uri);
136
+ });
137
+ }, (error) => {
138
+ if (isResolved)
139
+ return;
140
+ isResolved = true;
141
+ clearTimeout(timeout);
142
+ console.error("Erreur lors de la récupération de la taille de l'image:", error);
143
+ // En cas d'erreur, retourner l'URI original au lieu de rejeter
144
+ resolve(uri);
145
+ });
146
+ });
147
+ }
78
148
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AC,IAAI;QAClB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,MAAM,EAAE,IAAI,CAAC,MAAM;KACpB,CAAC;IAEF,wBAAwB;IACxB,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,eAAe,CACnD,GAAG,EACH,CAAC,EAAE,IAAI,EAAE,CAAC,EACV,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,gBAAgB,CAAC,UAAU,CAAC,GAAG,EAAE,CACzD,CAAC;IAEF,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAC3C,OAAO,MAAM,CAAC,GAAG,CAAC;AACpB,CAAC","sourcesContent":["import { Image as RNImage, Platform } from 'react-native';\nimport * as ImageManipulator from \"expo-image-manipulator\";\n\ntype Point = [number, number];\n\n// Compute axis-aligned bounding box from oriented quadrilateral\nfunction computeAabb(points: Point[]) {\n const xs = points.map(p => p[0]);\n const ys = points.map(p => p[1]);\n const minX = Math.min(...xs);\n const minY = Math.min(...ys);\n const maxX = Math.max(...xs);\n const maxY = Math.max(...ys);\n return { minX, minY, maxX, maxY, width: maxX - minX, height: maxY - minY };\n}\n\n// Web-only crop using Canvas; returns dataURL (base64)\nasync function cropWeb(uri: string, points: Point[]): Promise<string> {\n return new Promise((resolve, reject) => {\n const img = new Image();\n img.crossOrigin = 'anonymous';\n img.onload = () => {\n const { minX, minY, width, height } = computeAabb(points);\n const canvas = document.createElement('canvas');\n canvas.width = Math.max(1, Math.round(width));\n canvas.height = Math.max(1, Math.round(height));\n const ctx = canvas.getContext('2d');\n if (!ctx) return reject(new Error('Canvas context not available'));\n ctx.drawImage(\n img,\n minX, // sx\n minY, // sy\n width, // sw\n height, // sh\n 0,\n 0,\n canvas.width,\n canvas.height\n );\n resolve(canvas.toDataURL('image/jpeg', 0.92));\n };\n img.onerror = (e) => reject(e);\n img.src = uri;\n });\n}\n\n// Fallback: return original for native (no dependency added); caller can still use bbox to draw overlay\nexport async function cropByObb(uri: string, cardObb: any): Promise<{ base64?: string; bbox?: { minX: number; minY: number; width: number; height: number } }> {\n try {\n // card_obb format: [ [ [p1,p2,p3,p4], score ] ]\n const first = Array.isArray(cardObb) ? cardObb[0] : null;\n const points = Array.isArray(first?.[0]) ? (first[0] as Point[]) : null;\n if (!points || points.length !== 4) return {};\n\n const { minX, minY, width, height } = computeAabb(points);\n\n if (Platform.OS === 'web') {\n const base64 = await cropWeb(uri, points);\n return { base64, bbox: { minX, minY, width, height } };\n }\n // Native: return bbox only; keep base64 undefined\n return { bbox: { minX, minY, width, height } };\n } catch (e) {\n return {};\n }\n}\n\n\n\n\n// exemple d'appel :\nexport async function cropImageWithBBox(uri: string, bbox: any) {\n // 1️⃣ Récupère la taille originale de l'image\n await RNImage.getSize(uri, (width, height) => {\n console.log(\"Image originale:\", width, height);\n });\n\n // // 2️⃣ Suppose que ton bbox vient d'une image affichée dans `displayedSize`\n // const scaleX = originalWidth / displayedSize.width;\n // const scaleY = originalHeight / displayedSize.height;\n\n // 3️⃣ Convertir le bbox à la taille réelle scale 0.10 = 10%\n const crop = {\n originX: bbox.minX ,\n originY: bbox.minY ,\n width: bbox.width ,\n height: bbox.height,\n };\n\n // 4️⃣ Appliquer le crop\n const result = await ImageManipulator.manipulateAsync(\n uri,\n [{ crop }],\n { compress: 1, format: ImageManipulator.SaveFormat.PNG }\n );\n\n console.log(\"Image recadrée:\", result.uri);\n return result.uri;\n}\n"]}
1
+ {"version":3,"file":"cropByObb.js","sourceRoot":"","sources":["../../src/utils/cropByObb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,KAAK,gBAAgB,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIlC,gEAAgE;AAChE,SAAS,WAAW,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C,MAAM,CAAC,GAAG,CAAC,CAAC;YACtB,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;gBACf,IAAI,UAAU;oBAAE,OAAO;gBACvB,UAAU,GAAG,IAAI,CAAC;gBAClB,YAAY,CAAC,OAAO,CAAC,CAAC;gBACtB,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,KAAK,CAAC,CAAC;gBAC/D,+DAA+D;gBAC/D,OAAO,CAAC,GAAG,CAAC,CAAC;YACf,CAAC,CAAC,CAAC;QACP,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE;YACX,IAAI,UAAU;gBAAE,OAAO;YACvB,UAAU,GAAG,IAAI,CAAC;YAClB,YAAY,CAAC,OAAO,CAAC,CAAC;YACtB,OAAO,CAAC,KAAK,CAAC,yDAAyD,EAAE,KAAK,CAAC,CAAC;YAChF,+DAA+D;YAC/D,OAAO,CAAC,GAAG,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { Image as RNImage, Platform } from 'react-native';\nimport * as ImageManipulator from \"expo-image-manipulator\";\nimport { truncateFields } from '../modules/api/KYCService';\nimport { logger } from './logger';\n\ntype Point = [number, number];\n\n// Compute axis-aligned bounding box from oriented quadrilateral\nfunction computeAabb(points: Point[]) {\n const xs = points.map(p => p[0]);\n const ys = points.map(p => p[1]);\n const minX = Math.min(...xs);\n const minY = Math.min(...ys);\n const maxX = Math.max(...xs);\n const maxY = Math.max(...ys);\n return { minX, minY, maxX, maxY, width: maxX - minX, height: maxY - minY };\n}\n\n// Web-only crop using Canvas; returns dataURL (base64)\nasync function cropWeb(uri: string, points: Point[]): Promise<string> {\n return new Promise((resolve, reject) => {\n const img = new Image();\n img.crossOrigin = 'anonymous';\n img.onload = () => {\n const { minX, minY, width, height } = computeAabb(points);\n const canvas = document.createElement('canvas');\n canvas.width = Math.max(1, Math.round(width));\n canvas.height = Math.max(1, Math.round(height));\n const ctx = canvas.getContext('2d');\n if (!ctx) return reject(new Error('Canvas context not available'));\n ctx.drawImage(\n img,\n minX, // sx\n minY, // sy\n width, // sw\n height, // sh\n 0,\n 0,\n canvas.width,\n canvas.height\n );\n resolve(canvas.toDataURL('image/jpeg', 0.92));\n };\n img.onerror = (e) => reject(e);\n img.src = uri;\n });\n}\n\n// Fallback: return original for native (no dependency added); caller can still use bbox to draw overlay\nexport async function cropByObb(uri: string, cardObb: any): Promise<{ base64?: string; bbox?: { minX: number; minY: number; width: number; height: number } }> {\n try {\n // card_obb format: [ [ [p1,p2,p3,p4], score ] ]\n const first = Array.isArray(cardObb) ? cardObb[0] : null;\n const points = Array.isArray(first?.[0]) ? (first[0] as Point[]) : null;\n if (!points || points.length !== 4) return {};\n\n const { minX, minY, width, height } = computeAabb(points);\n\n if (Platform.OS === 'web') {\n const base64 = await cropWeb(uri, points);\n return { base64, bbox: { minX, minY, width, height } };\n }\n // Native: return bbox only; keep base64 undefined\n return { bbox: { minX, minY, width, height } };\n } catch (e) {\n return {};\n }\n}\n\n\n\n\n// exemple d'appel :\nexport async function cropImageWithBBox(uri: string, bbox: any) {\n // 1️⃣ Récupère la taille originale de l'image\n await RNImage.getSize(uri, (width, height) => {\n console.log(\"Image originale:\", width, height);\n });\n\n // // 2️⃣ Suppose que ton bbox vient d'une image affichée dans `displayedSize`\n // const scaleX = originalWidth / displayedSize.width;\n // const scaleY = originalHeight / displayedSize.height;\n\n // 3️⃣ Convertir le bbox à la taille réelle scale 0.10 = 10%\n const crop = {\n originX: bbox.minX,\n originY: bbox.minY,\n width: bbox.width,\n height: bbox.height,\n };\n\n // 4️⃣ Appliquer le crop\n // @ts-ignore - manipulateAsync is deprecated but still functional, new API (useImageManipulator) is a React hook and not suitable for utility functions\n const result = await ImageManipulator.manipulateAsync(\n uri,\n [{ crop }],\n { compress: 1, format: ImageManipulator.SaveFormat.PNG }\n );\n\n console.log(\"Image recadrée:\", result.uri);\n return result.uri;\n}\n\n// Fonction pour rogner avec une tolérance de 10% autour du bbox\nexport async function cropImageWithBBoxWithTolerance(uri: string, bbox: any, tolerance: number = 0.1): Promise<string> {\n console.log(\"cropImageWithBBoxWithTolerance\", JSON.stringify(truncateFields({ uri, bbox, tolerance }), null, 2));\n \n return new Promise<string>((resolve, reject) => {\n let isResolved = false;\n \n // Timeout de sécurité (15 secondes)\n const timeout = setTimeout(() => {\n if (!isResolved) {\n isResolved = true;\n console.warn(\"Timeout lors du rognage avec tolérance, utilisation de l'image originale\");\n resolve(uri); // Retourner l'URI original en cas de timeout\n }\n }, 15000);\n\n // 1️⃣ Récupère la taille originale de l'image\n RNImage.getSize(uri, (imageWidth, imageHeight) => {\n if (isResolved) return;\n \n // 2️⃣ Calculer la tolérance en pixels (10% de chaque côté)\n const toleranceX = bbox.width * tolerance;\n const toleranceY = bbox.height * tolerance;\n\n // 3️⃣ Ajuster le bbox avec la tolérance\n // Calculer les nouvelles coordonnées avec tolérance\n const newMinX = Math.max(0, bbox.minX - toleranceX);\n const newMinY = Math.max(0, bbox.minY - toleranceY);\n const newMaxX = Math.min(imageWidth, bbox.minX + bbox.width + toleranceX);\n const newMaxY = Math.min(imageHeight, bbox.minY + bbox.height + toleranceY);\n\n // Calculer la largeur et hauteur finales\n const finalWidth = newMaxX - newMinX;\n const finalHeight = newMaxY - newMinY;\n\n const crop = {\n originX: newMinX,\n originY: newMinY,\n width: finalWidth,\n height: finalHeight,\n };\n\n logger.log(\"cropImageWithBBoxWithTolerance - crop params\", JSON.stringify(truncateFields({ uri, crop, tolerance, imageWidth, imageHeight }), null, 2));\n\n // 4️⃣ Appliquer le crop avec tolérance\n // @ts-ignore - manipulateAsync is deprecated but still functional, new API (useImageManipulator) is a React hook and not suitable for utility functions\n ImageManipulator.manipulateAsync(\n uri,\n [{ crop }],\n { compress: 0.95, format: ImageManipulator.SaveFormat.JPEG }\n )\n .then((result) => {\n if (isResolved) return;\n isResolved = true;\n clearTimeout(timeout);\n console.log(\"Image recadrée avec tolérance:\", result.uri);\n resolve(result.uri);\n })\n .catch((error) => {\n if (isResolved) return;\n isResolved = true;\n clearTimeout(timeout);\n console.error(\"Erreur lors du rognage avec tolérance:\", error);\n // En cas d'erreur, retourner l'URI original au lieu de rejeter\n resolve(uri);\n });\n }, (error) => {\n if (isResolved) return;\n isResolved = true;\n clearTimeout(timeout);\n console.error(\"Erreur lors de la récupération de la taille de l'image:\", error);\n // En cas d'erreur, retourner l'URI original au lieu de rejeter\n resolve(uri);\n });\n });\n}\n"]}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Checks if the current environment is a mobile web browser based on User Agent.
3
+ * This can be used to distinguish between desktop web and mobile web.
4
+ */
5
+ export declare const isMobileWeb: () => boolean;
6
+ //# sourceMappingURL=deviceDetection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deviceDetection.d.ts","sourceRoot":"","sources":["../../src/utils/deviceDetection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,WAAW,QAAO,OAM9B,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Checks if the current environment is a mobile web browser based on User Agent.
3
+ * This can be used to distinguish between desktop web and mobile web.
4
+ */
5
+ export const isMobileWeb = () => {
6
+ if (typeof window === 'undefined' || !window.navigator) {
7
+ return false;
8
+ }
9
+ const userAgent = window.navigator.userAgent;
10
+ return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent);
11
+ };
12
+ //# sourceMappingURL=deviceDetection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deviceDetection.js","sourceRoot":"","sources":["../../src/utils/deviceDetection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,GAAY,EAAE;IACrC,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QACrD,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC;IAC7C,OAAO,gEAAgE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAC5F,CAAC,CAAC","sourcesContent":["/**\n * Checks if the current environment is a mobile web browser based on User Agent.\n * This can be used to distinguish between desktop web and mobile web.\n */\nexport const isMobileWeb = (): boolean => {\n if (typeof window === 'undefined' || !window.navigator) {\n return false;\n }\n const userAgent = window.navigator.userAgent;\n return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent);\n};\n"]}
@@ -0,0 +1,20 @@
1
+ export interface AlertButton {
2
+ text?: string;
3
+ onPress?: () => void;
4
+ style?: 'default' | 'cancel' | 'destructive';
5
+ }
6
+ /**
7
+ * Platform-aware alert helper that works on both native and web platforms
8
+ * On web, uses window.confirm/window.alert since Alert.alert is not supported
9
+ * On native, uses the standard Alert.alert
10
+ */
11
+ export declare const showAlert: (title: string, message?: string, buttons?: AlertButton[]) => void;
12
+ /**
13
+ * Simplified confirm dialog for yes/no scenarios
14
+ */
15
+ export declare const showConfirm: (title: string, message: string, onConfirm: () => void, onCancel?: () => void) => void;
16
+ /**
17
+ * Simple alert with just an OK button
18
+ */
19
+ export declare const showSimpleAlert: (title: string, message?: string, onPress?: () => void) => void;
20
+ //# sourceMappingURL=platformAlert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platformAlert.d.ts","sourceRoot":"","sources":["../../src/utils/platformAlert.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,aAAa,CAAC;CAC9C;AAED;;;;GAIG;AACH,eAAO,MAAM,SAAS,GACpB,OAAO,MAAM,EACb,UAAU,MAAM,EAChB,UAAU,WAAW,EAAE,KACtB,IAiCF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,GACtB,OAAO,MAAM,EACb,SAAS,MAAM,EACf,WAAW,MAAM,IAAI,EACrB,WAAW,MAAM,IAAI,KACpB,IAYF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,EAAE,UAAU,MAAM,EAAE,UAAU,MAAM,IAAI,KAAG,IAOvF,CAAC"}
@@ -0,0 +1,67 @@
1
+ import { Platform, Alert } from 'react-native';
2
+ /**
3
+ * Platform-aware alert helper that works on both native and web platforms
4
+ * On web, uses window.confirm/window.alert since Alert.alert is not supported
5
+ * On native, uses the standard Alert.alert
6
+ */
7
+ export const showAlert = (title, message, buttons) => {
8
+ if (Platform.OS === 'web') {
9
+ // Web implementation using native browser dialogs
10
+ const fullMessage = message ? `${title}\n\n${message}` : title;
11
+ if (buttons && buttons.length > 1) {
12
+ // Multiple buttons - use confirm dialog
13
+ const confirmed = window.confirm(fullMessage);
14
+ if (confirmed) {
15
+ // Find and call the primary/positive button callback
16
+ const confirmButton = buttons.find(btn => btn.style !== 'cancel' && btn.onPress);
17
+ confirmButton?.onPress?.();
18
+ }
19
+ else {
20
+ // Find and call the cancel button callback
21
+ const cancelButton = buttons.find(btn => btn.style === 'cancel');
22
+ cancelButton?.onPress?.();
23
+ }
24
+ }
25
+ else if (buttons && buttons.length === 1) {
26
+ // Single button - use alert dialog
27
+ window.alert(fullMessage);
28
+ buttons[0]?.onPress?.();
29
+ }
30
+ else {
31
+ // No buttons - just show alert
32
+ window.alert(fullMessage);
33
+ }
34
+ }
35
+ else {
36
+ // Native implementation - use standard Alert.alert
37
+ Alert.alert(title, message, buttons);
38
+ }
39
+ };
40
+ /**
41
+ * Simplified confirm dialog for yes/no scenarios
42
+ */
43
+ export const showConfirm = (title, message, onConfirm, onCancel) => {
44
+ showAlert(title, message, [
45
+ {
46
+ text: 'Cancel',
47
+ style: 'cancel',
48
+ onPress: onCancel,
49
+ },
50
+ {
51
+ text: 'OK',
52
+ onPress: onConfirm,
53
+ },
54
+ ]);
55
+ };
56
+ /**
57
+ * Simple alert with just an OK button
58
+ */
59
+ export const showSimpleAlert = (title, message, onPress) => {
60
+ showAlert(title, message, [
61
+ {
62
+ text: 'OK',
63
+ onPress,
64
+ },
65
+ ]);
66
+ };
67
+ //# sourceMappingURL=platformAlert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platformAlert.js","sourceRoot":"","sources":["../../src/utils/platformAlert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAQ/C;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,KAAa,EACb,OAAgB,EAChB,OAAuB,EACjB,EAAE;IACR,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;QAC1B,kDAAkD;QAClD,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,OAAO,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QAE/D,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAElC,wCAAwC;YACxC,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAE9C,IAAI,SAAS,EAAE,CAAC;gBACd,qDAAqD;gBACrD,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAChC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,KAAK,QAAQ,IAAI,GAAG,CAAC,OAAO,CAC7C,CAAC;gBACF,aAAa,EAAE,OAAO,EAAE,EAAE,CAAC;YAC7B,CAAC;iBAAM,CAAC;gBACN,2CAA2C;gBAC3C,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC;gBACjE,YAAY,EAAE,OAAO,EAAE,EAAE,CAAC;YAC5B,CAAC;QACH,CAAC;aAAM,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3C,mCAAmC;YACnC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YAC1B,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,CAAC;QAC1B,CAAC;aAAM,CAAC;YACN,+BAA+B;YAC/B,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;SAAM,CAAC;QACN,mDAAmD;QACnD,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;AACH,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,KAAa,EACb,OAAe,EACf,SAAqB,EACrB,QAAqB,EACf,EAAE;IACR,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE;QACxB;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,QAAQ;YACf,OAAO,EAAE,QAAQ;SAClB;QACD;YACE,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,SAAS;SACnB;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAa,EAAE,OAAgB,EAAE,OAAoB,EAAQ,EAAE;IAC7F,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE;QACxB;YACE,IAAI,EAAE,IAAI;YACV,OAAO;SACR;KACF,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { Platform, Alert } from 'react-native';\n\nexport interface AlertButton {\n text?: string;\n onPress?: () => void;\n style?: 'default' | 'cancel' | 'destructive';\n}\n\n/**\n * Platform-aware alert helper that works on both native and web platforms\n * On web, uses window.confirm/window.alert since Alert.alert is not supported\n * On native, uses the standard Alert.alert\n */\nexport const showAlert = (\n title: string,\n message?: string,\n buttons?: AlertButton[]\n): void => {\n if (Platform.OS === 'web') {\n // Web implementation using native browser dialogs\n const fullMessage = message ? `${title}\\n\\n${message}` : title;\n\n if (buttons && buttons.length > 1) {\n \n // Multiple buttons - use confirm dialog\n const confirmed = window.confirm(fullMessage);\n \n if (confirmed) {\n // Find and call the primary/positive button callback\n const confirmButton = buttons.find(\n btn => btn.style !== 'cancel' && btn.onPress\n );\n confirmButton?.onPress?.();\n } else {\n // Find and call the cancel button callback\n const cancelButton = buttons.find(btn => btn.style === 'cancel');\n cancelButton?.onPress?.();\n }\n } else if (buttons && buttons.length === 1) {\n // Single button - use alert dialog\n window.alert(fullMessage);\n buttons[0]?.onPress?.();\n } else {\n // No buttons - just show alert\n window.alert(fullMessage);\n }\n } else {\n // Native implementation - use standard Alert.alert\n Alert.alert(title, message, buttons);\n }\n};\n\n/**\n * Simplified confirm dialog for yes/no scenarios\n */\nexport const showConfirm = (\n title: string,\n message: string,\n onConfirm: () => void,\n onCancel?: () => void\n): void => {\n showAlert(title, message, [\n {\n text: 'Cancel',\n style: 'cancel',\n onPress: onCancel,\n },\n {\n text: 'OK',\n onPress: onConfirm,\n },\n ]);\n};\n\n/**\n * Simple alert with just an OK button\n */\nexport const showSimpleAlert = (title: string, message?: string, onPress?: () => void): void => {\n showAlert(title, message, [\n {\n text: 'OK',\n onPress,\n },\n ]);\n};\n\n"]}
@@ -0,0 +1,10 @@
1
+ import { BackendKYCTemplate, KYCTemplate } from '../types/KYC.types';
2
+ /**
3
+ * Transform backend template to SDK template format
4
+ */
5
+ export declare function transformBackendTemplateToSDK(backendTemplate: BackendKYCTemplate): KYCTemplate;
6
+ /**
7
+ * Validate transformed template
8
+ */
9
+ export declare function validateTransformedTemplate(template: KYCTemplate): boolean;
10
+ //# sourceMappingURL=template-transformer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template-transformer.d.ts","sourceRoot":"","sources":["../../src/utils/template-transformer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAElB,WAAW,EAaZ,MAAM,oBAAoB,CAAC;AA6S5B;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,eAAe,EAAE,kBAAkB,GAClC,WAAW,CAgGb;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO,CAqB1E"}