@sanctum-key/react-native-sdk 1.0.6 → 1.0.8

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 (206) hide show
  1. package/README.md +3 -3
  2. package/android/build/.transforms/{f62cb96b2d1f78ca96ab35932dd530dc → c9d62bb333688ab562f51958998d5a48}/transformed/classes/classes_dex/classes.dex +0 -0
  3. package/android/build/generated/source/buildConfig/debug/kyc/{transfergratis → SanctumKey}/com/BuildConfig.java +2 -2
  4. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/AndroidManifest.xml +1 -1
  5. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/output-metadata.json +1 -1
  6. package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
  7. package/android/build/intermediates/compile_r_class_jar/debug/generateDebugRFile/R.jar +0 -0
  8. package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +2 -2
  9. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/kyc/SanctumKey/com/BuildConfig.class +0 -0
  10. package/android/build/intermediates/manifest_merge_blame_file/debug/processDebugManifest/manifest-merger-blame-debug-report.txt +1 -1
  11. package/android/build/intermediates/merged_manifest/debug/processDebugManifest/AndroidManifest.xml +1 -1
  12. package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
  13. package/android/build/intermediates/symbol_list_with_package_name/debug/generateDebugRFile/package-aware-r.txt +1 -1
  14. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
  15. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
  16. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
  17. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream +0 -0
  18. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream.len +0 -0
  19. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i +0 -0
  20. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
  21. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
  22. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
  23. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
  24. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
  25. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
  26. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
  27. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
  28. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
  29. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
  30. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
  31. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
  32. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
  33. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
  34. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
  35. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
  36. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
  37. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
  38. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream +0 -0
  39. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream.len +0 -0
  40. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i +0 -0
  41. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
  42. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
  43. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
  44. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
  45. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
  46. package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
  47. package/android/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
  48. package/android/build/outputs/logs/manifest-merger-debug-report.txt +1 -1
  49. package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
  50. package/android/build/tmp/kotlin-classes/debug/kyc/SanctumKey/com/SanctumKeySdkModule$definition$1$5$1.class +0 -0
  51. package/android/build/tmp/kotlin-classes/debug/kyc/SanctumKey/com/SanctumKeySdkModule$definition$1$5$2.class +0 -0
  52. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$1.class → SanctumKey/com/SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunction$1.class} +0 -0
  53. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$2.class → SanctumKey/com/SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunction$2.class} +0 -0
  54. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$3.class → SanctumKey/com/SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunction$3.class} +0 -0
  55. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$4.class → SanctumKey/com/SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunction$4.class} +0 -0
  56. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$5.class → SanctumKey/com/SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunction$5.class} +0 -0
  57. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$6.class → SanctumKey/com/SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunction$6.class} +0 -0
  58. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$1.class → SanctumKey/com/SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$1.class} +0 -0
  59. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$2.class → SanctumKey/com/SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$2.class} +0 -0
  60. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$3.class → SanctumKey/com/SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$3.class} +0 -0
  61. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$4.class → SanctumKey/com/SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$4.class} +0 -0
  62. package/android/build/tmp/kotlin-classes/debug/kyc/SanctumKey/com/SanctumKeySdkModule$definition$lambda$5$$inlined$View$1.class +0 -0
  63. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkModule$definition$lambda$5$lambda$4$$inlined$Prop$1.class → SanctumKey/com/SanctumKeySdkModule$definition$lambda$5$lambda$4$$inlined$Prop$1.class} +0 -0
  64. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkModule$definition$lambda$5$lambda$4$$inlined$Prop$2.class → SanctumKey/com/SanctumKeySdkModule$definition$lambda$5$lambda$4$$inlined$Prop$2.class} +0 -0
  65. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkModule.class → SanctumKey/com/SanctumKeySdkModule.class} +0 -0
  66. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkView.class → SanctumKey/com/SanctumKeySdkView.class} +0 -0
  67. package/android/build.gradle +2 -2
  68. package/android/src/main/AndroidManifest.xml +1 -1
  69. package/android/src/main/java/kyc/transfergratis/com/TransfergratisSdkModule.kt +6 -6
  70. package/android/src/main/java/kyc/transfergratis/com/TransfergratisSdkView.kt +2 -2
  71. package/build/package.json +9 -7
  72. package/build/src/App.d.ts +2 -2
  73. package/build/src/App.d.ts.map +1 -1
  74. package/build/src/App.js +2 -2
  75. package/build/src/App.js.map +1 -1
  76. package/build/src/{TransfergratisSdk.types.d.ts → SanctumKeySdk.types.d.ts} +3 -3
  77. package/build/src/SanctumKeySdk.types.d.ts.map +1 -0
  78. package/build/src/SanctumKeySdk.types.js +2 -0
  79. package/build/src/SanctumKeySdk.types.js.map +1 -0
  80. package/build/src/{TransfergratisSdkModule.d.ts → SanctumKeySdkModule.d.ts} +4 -4
  81. package/build/src/SanctumKeySdkModule.d.ts.map +1 -0
  82. package/build/src/{TransfergratisSdkModule.js → SanctumKeySdkModule.js} +2 -2
  83. package/build/src/SanctumKeySdkModule.js.map +1 -0
  84. package/build/src/{TransfergratisSdkModule.web.d.ts → SanctumKeySdkModule.web.d.ts} +4 -4
  85. package/build/src/SanctumKeySdkModule.web.d.ts.map +1 -0
  86. package/build/src/{TransfergratisSdkModule.web.js → SanctumKeySdkModule.web.js} +3 -3
  87. package/build/src/SanctumKeySdkModule.web.js.map +1 -0
  88. package/build/src/SanctumKeySdkView.d.ts +4 -0
  89. package/build/src/SanctumKeySdkView.d.ts.map +1 -0
  90. package/build/src/SanctumKeySdkView.js +7 -0
  91. package/build/src/SanctumKeySdkView.js.map +1 -0
  92. package/build/src/SanctumKeySdkView.web.d.ts +4 -0
  93. package/build/src/SanctumKeySdkView.web.d.ts.map +1 -0
  94. package/build/src/{TransfergratisSdkView.web.js → SanctumKeySdkView.web.js} +2 -2
  95. package/build/src/SanctumKeySdkView.web.js.map +1 -0
  96. package/build/src/api/axios.js +2 -2
  97. package/build/src/api/axios.js.map +1 -1
  98. package/build/src/components/EnhancedCameraView.d.ts.map +1 -1
  99. package/build/src/components/EnhancedCameraView.js +107 -330
  100. package/build/src/components/EnhancedCameraView.js.map +1 -1
  101. package/build/src/components/KYCElements/EmailVerificationTemplate.d.ts.map +1 -1
  102. package/build/src/components/KYCElements/EmailVerificationTemplate.js +114 -15
  103. package/build/src/components/KYCElements/EmailVerificationTemplate.js.map +1 -1
  104. package/build/src/components/KYCElements/IDCardCapture.d.ts.map +1 -1
  105. package/build/src/components/KYCElements/IDCardCapture.js +166 -695
  106. package/build/src/components/KYCElements/IDCardCapture.js.map +1 -1
  107. package/build/src/components/KYCElements/PhoneVerificationTemplate.d.ts.map +1 -1
  108. package/build/src/components/KYCElements/PhoneVerificationTemplate.js +282 -40
  109. package/build/src/components/KYCElements/PhoneVerificationTemplate.js.map +1 -1
  110. package/build/src/components/KYCElements/SelfieCapture.d.ts +1 -1
  111. package/build/src/components/KYCElements/SelfieCapture.d.ts.map +1 -1
  112. package/build/src/components/KYCElements/SelfieCapture.js +130 -192
  113. package/build/src/components/KYCElements/SelfieCapture.js.map +1 -1
  114. package/build/src/components/KYCElements/SelfieCaptureTemplate.d.ts.map +1 -1
  115. package/build/src/components/KYCElements/SelfieCaptureTemplate.js +131 -433
  116. package/build/src/components/KYCElements/SelfieCaptureTemplate.js.map +1 -1
  117. package/build/src/components/NativeCameraView.js +1 -1
  118. package/build/src/components/NativeCameraView.js.map +1 -1
  119. package/build/src/components/OverLay/IdCard.d.ts +3 -2
  120. package/build/src/components/OverLay/IdCard.d.ts.map +1 -1
  121. package/build/src/components/OverLay/IdCard.js +149 -141
  122. package/build/src/components/OverLay/IdCard.js.map +1 -1
  123. package/build/src/components/OverLay/SelfieOverlay.d.ts +2 -1
  124. package/build/src/components/OverLay/SelfieOverlay.d.ts.map +1 -1
  125. package/build/src/components/OverLay/SelfieOverlay.js +37 -95
  126. package/build/src/components/OverLay/SelfieOverlay.js.map +1 -1
  127. package/build/src/components/OverLay/type.d.ts +1 -0
  128. package/build/src/components/OverLay/type.d.ts.map +1 -1
  129. package/build/src/components/OverLay/type.js.map +1 -1
  130. package/build/src/components/Svgs/scanningLine.d.ts +2 -1
  131. package/build/src/components/Svgs/scanningLine.d.ts.map +1 -1
  132. package/build/src/components/Svgs/scanningLine.js +55 -51
  133. package/build/src/components/Svgs/scanningLine.js.map +1 -1
  134. package/build/src/config/KYCConfig.js +1 -1
  135. package/build/src/config/KYCConfig.js.map +1 -1
  136. package/build/src/config/allowedDomains.js +6 -6
  137. package/build/src/config/allowedDomains.js.map +1 -1
  138. package/build/src/hooks/useTemplateKYCFlow.d.ts.map +1 -1
  139. package/build/src/hooks/useTemplateKYCFlow.js +37 -38
  140. package/build/src/hooks/useTemplateKYCFlow.js.map +1 -1
  141. package/build/src/index.d.ts +3 -3
  142. package/build/src/index.d.ts.map +1 -1
  143. package/build/src/index.js +3 -3
  144. package/build/src/index.js.map +1 -1
  145. package/build/src/modules/api/CardAuthentification.d.ts +0 -5
  146. package/build/src/modules/api/CardAuthentification.d.ts.map +1 -1
  147. package/build/src/modules/api/CardAuthentification.js +114 -116
  148. package/build/src/modules/api/CardAuthentification.js.map +1 -1
  149. package/build/src/modules/api/KYCService.d.ts +12 -1
  150. package/build/src/modules/api/KYCService.d.ts.map +1 -1
  151. package/build/src/modules/api/KYCService.js +102 -38
  152. package/build/src/modules/api/KYCService.js.map +1 -1
  153. package/build/src/modules/camera/NativeCameraModule.js +17 -17
  154. package/build/src/modules/camera/NativeCameraModule.js.map +1 -1
  155. package/expo-module.config.json +2 -2
  156. package/ios/TransfergratisSdk.podspec +2 -2
  157. package/ios/TransfergratisSdkModule.swift +12 -12
  158. package/package.json +9 -7
  159. package/src/App.tsx +2 -2
  160. package/src/{TransfergratisSdk.types.ts → SanctumKeySdk.types.ts} +2 -2
  161. package/src/{TransfergratisSdkModule.ts → SanctumKeySdkModule.ts} +3 -3
  162. package/src/{TransfergratisSdkModule.web.ts → SanctumKeySdkModule.web.ts} +3 -3
  163. package/src/SanctumKeySdkView.tsx +11 -0
  164. package/src/{TransfergratisSdkView.web.tsx → SanctumKeySdkView.web.tsx} +2 -2
  165. package/src/api/axios.ts +2 -2
  166. package/src/components/EnhancedCameraView.tsx +131 -385
  167. package/src/components/KYCElements/EmailVerificationTemplate.tsx +141 -26
  168. package/src/components/KYCElements/IDCardCapture.tsx +228 -868
  169. package/src/components/KYCElements/PhoneVerificationTemplate.tsx +342 -60
  170. package/src/components/KYCElements/SelfieCapture.tsx +184 -213
  171. package/src/components/KYCElements/SelfieCaptureTemplate.tsx +330 -662
  172. package/src/components/NativeCameraView.tsx +1 -1
  173. package/src/components/OverLay/IdCard.tsx +218 -217
  174. package/src/components/OverLay/SelfieOverlay.tsx +56 -134
  175. package/src/components/OverLay/type.ts +1 -0
  176. package/src/components/Svgs/scanningLine.tsx +71 -72
  177. package/src/config/KYCConfig.ts +1 -1
  178. package/src/config/allowedDomains.ts +6 -6
  179. package/src/hooks/useTemplateKYCFlow.tsx +45 -39
  180. package/src/i18n/README.md +1 -1
  181. package/src/index.ts +3 -3
  182. package/src/modules/api/CardAuthentification.ts +202 -200
  183. package/src/modules/api/KYCService.ts +169 -53
  184. package/src/modules/camera/NativeCameraModule.ts +17 -17
  185. package/android/build/tmp/kotlin-classes/debug/kyc/transfergratis/com/TransfergratisSdkModule$definition$1$5$1.class +0 -0
  186. package/android/build/tmp/kotlin-classes/debug/kyc/transfergratis/com/TransfergratisSdkModule$definition$1$5$2.class +0 -0
  187. package/android/build/tmp/kotlin-classes/debug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$View$1.class +0 -0
  188. package/build/src/TransfergratisSdk.types.d.ts.map +0 -1
  189. package/build/src/TransfergratisSdk.types.js +0 -2
  190. package/build/src/TransfergratisSdk.types.js.map +0 -1
  191. package/build/src/TransfergratisSdkModule.d.ts.map +0 -1
  192. package/build/src/TransfergratisSdkModule.js.map +0 -1
  193. package/build/src/TransfergratisSdkModule.web.d.ts.map +0 -1
  194. package/build/src/TransfergratisSdkModule.web.js.map +0 -1
  195. package/build/src/TransfergratisSdkView.d.ts +0 -4
  196. package/build/src/TransfergratisSdkView.d.ts.map +0 -1
  197. package/build/src/TransfergratisSdkView.js +0 -7
  198. package/build/src/TransfergratisSdkView.js.map +0 -1
  199. package/build/src/TransfergratisSdkView.web.d.ts +0 -4
  200. package/build/src/TransfergratisSdkView.web.d.ts.map +0 -1
  201. package/build/src/TransfergratisSdkView.web.js.map +0 -1
  202. package/src/TransfergratisSdkView.tsx +0 -11
  203. /package/android/build/.transforms/{532c0e65d82f446633d0a7dab2772198 → ab90740579f5bd05b27b4343ada2d1c9}/results.bin +0 -0
  204. /package/android/build/.transforms/{532c0e65d82f446633d0a7dab2772198 → ab90740579f5bd05b27b4343ada2d1c9}/transformed/classes/classes_dex/classes.dex +0 -0
  205. /package/android/build/.transforms/{f62cb96b2d1f78ca96ab35932dd530dc → c9d62bb333688ab562f51958998d5a48}/results.bin +0 -0
  206. /package/android/build/{intermediates/javac/debug/compileDebugJavaWithJavac/classes/kyc/transfergratis/com/BuildConfig.class → tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/BuildConfig.class.uniqueId0} +0 -0
@@ -1,8 +1,8 @@
1
- export * from './TransfergratisSdk.types';
1
+ export * from './SanctumKeySdk.types';
2
2
  export * from './types/KYC.types';
3
3
  export * from './types/env.types';
4
- export { TemplateKYCExample as LaunchTransferGratisKYC } from './components/TemplateKYCExample';
5
- export { TemplateKYCExample as LauchTransferGratisKYC } from './components/TemplateKYCExample';
4
+ export { TemplateKYCExample as LaunchSanctumKeyKYC } from './components/TemplateKYCExample';
5
+ export { TemplateKYCExample as LauchSanctumKeyKYC } from './components/TemplateKYCExample';
6
6
  export { TemplateKYCFlow } from './components/TemplateKYCFlowRefactored';
7
7
  export { default as templateService } from './modules/api/TemplateService';
8
8
  export { transformBackendTemplateToSDK, validateTransformedTemplate } from './utils/template-transformer';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAI1C,cAAc,mBAAmB,CAAC;AAGlC,cAAc,mBAAmB,CAAC;AAGlC,OAAO,EAAE,kBAAkB,IAAI,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAEhG,OAAO,EAAE,kBAAkB,IAAI,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAG/F,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAGzE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,6BAA6B,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAG9D,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAGvD,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AAItC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,mBAAmB,CAAC;AAGlC,OAAO,EAAE,kBAAkB,IAAI,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAE5F,OAAO,EAAE,kBAAkB,IAAI,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAG3F,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAGzE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,6BAA6B,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAG9D,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAGvD,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC"}
@@ -1,11 +1,11 @@
1
- export * from './TransfergratisSdk.types';
1
+ export * from './SanctumKeySdk.types';
2
2
  // Export KYC types
3
3
  export * from './types/KYC.types';
4
4
  // Export Environment types
5
5
  export * from './types/env.types';
6
- export { TemplateKYCExample as LaunchTransferGratisKYC } from './components/TemplateKYCExample';
6
+ export { TemplateKYCExample as LaunchSanctumKeyKYC } from './components/TemplateKYCExample';
7
7
  // Backward compatibility for existing integrations using the typo.
8
- export { TemplateKYCExample as LauchTransferGratisKYC } from './components/TemplateKYCExample';
8
+ export { TemplateKYCExample as LauchSanctumKeyKYC } from './components/TemplateKYCExample';
9
9
  // Export Template Flow Components
10
10
  export { TemplateKYCFlow } from './components/TemplateKYCFlowRefactored';
11
11
  // Export Template Service and Utilities
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAG1C,mBAAmB;AACnB,cAAc,mBAAmB,CAAC;AAElC,2BAA2B;AAC3B,cAAc,mBAAmB,CAAC;AAGlC,OAAO,EAAE,kBAAkB,IAAI,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAChG,mEAAmE;AACnE,OAAO,EAAE,kBAAkB,IAAI,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAE/F,kCAAkC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAEzE,wCAAwC;AACxC,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,6BAA6B,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,6BAA6B;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,4BAA4B;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC","sourcesContent":["export * from './TransfergratisSdk.types';\n\n\n// Export KYC types\nexport * from './types/KYC.types';\n\n// Export Environment types\nexport * from './types/env.types';\n\n\nexport { TemplateKYCExample as LaunchTransferGratisKYC } from './components/TemplateKYCExample';\n// Backward compatibility for existing integrations using the typo.\nexport { TemplateKYCExample as LauchTransferGratisKYC } from './components/TemplateKYCExample';\n\n// Export Template Flow Components\nexport { TemplateKYCFlow } from './components/TemplateKYCFlowRefactored';\n\n// Export Template Service and Utilities\nexport { default as templateService } from './modules/api/TemplateService';\nexport { transformBackendTemplateToSDK, validateTransformedTemplate } from './utils/template-transformer';\nexport { useTemplateLoader } from './hooks/useTemplateLoader';\n\n// Export Template Components\nexport { WelcomeTemplate } from './components/KYCElements/WelcomeTemplate';\nexport { EnhancedCameraView } from './components/EnhancedCameraView';\nexport { UnifiedCameraModule } from './modules/camera';\n\n// Export Web KYC Components\nexport { WebKYCEntry } from './web';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AAGtC,mBAAmB;AACnB,cAAc,mBAAmB,CAAC;AAElC,2BAA2B;AAC3B,cAAc,mBAAmB,CAAC;AAGlC,OAAO,EAAE,kBAAkB,IAAI,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC5F,mEAAmE;AACnE,OAAO,EAAE,kBAAkB,IAAI,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAE3F,kCAAkC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAEzE,wCAAwC;AACxC,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,6BAA6B,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,6BAA6B;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,4BAA4B;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC","sourcesContent":["export * from './SanctumKeySdk.types';\n\n\n// Export KYC types\nexport * from './types/KYC.types';\n\n// Export Environment types\nexport * from './types/env.types';\n\n\nexport { TemplateKYCExample as LaunchSanctumKeyKYC } from './components/TemplateKYCExample';\n// Backward compatibility for existing integrations using the typo.\nexport { TemplateKYCExample as LauchSanctumKeyKYC } from './components/TemplateKYCExample';\n\n// Export Template Flow Components\nexport { TemplateKYCFlow } from './components/TemplateKYCFlowRefactored';\n\n// Export Template Service and Utilities\nexport { default as templateService } from './modules/api/TemplateService';\nexport { transformBackendTemplateToSDK, validateTransformedTemplate } from './utils/template-transformer';\nexport { useTemplateLoader } from './hooks/useTemplateLoader';\n\n// Export Template Components\nexport { WelcomeTemplate } from './components/KYCElements/WelcomeTemplate';\nexport { EnhancedCameraView } from './components/EnhancedCameraView';\nexport { UnifiedCameraModule } from './modules/camera';\n\n// Export Web KYC Components\nexport { WebKYCEntry } from './web';\n"]}
@@ -70,11 +70,6 @@ export declare function backVerification(result: {
70
70
  mrzType?: string;
71
71
  templateResponse?: ApiVerificationResponse;
72
72
  }, env?: KycEnvironment): Promise<any>;
73
- /**
74
- * Check template type
75
- * @param result
76
- * @returns
77
- */
78
73
  export declare function checkTemplateType(result: {
79
74
  path?: string;
80
75
  docType: string;
@@ -1 +1 @@
1
- {"version":3,"file":"CardAuthentification.d.ts","sourceRoot":"","sources":["../../../../src/modules/api/CardAuthentification.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0B,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAKvD,UAAU,WAAW;IACjB,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED,UAAU,uBAAuB;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,QAAQ,CAAC,EAAE,WAAW,EAAE,GAAG,GAAG,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB;AAED,wBAAsB,iBAAiB,CACnC,MAAM,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE;QAAE,UAAU,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAAC,oBAAoB,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,EAChM,GAAG,GAAE,cAA6B;;;;;;;;;;;;;;;;;;;;;;;;aAXzB,OAAO;cACN,OAAO;aACR,GAAG,EAAE;eACH,WAAW,EAAE,GAAG,GAAG;oBACd,MAAM;YACd,GAAG;GAkJd;AAGD,wBAAsB,gBAAgB,CAClC,MAAM,EAAE;IACJ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,EAAE;QAAE,UAAU,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAC5D,oBAAoB,EAAE,MAAM,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,uBAAuB,CAAA;CAC7C,EACD,GAAG,GAAE,cAA6B,gBAoNrC;AAGD;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,MAAM,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,GAAG,GAAE,cAA6B,gBAoFzJ"}
1
+ {"version":3,"file":"CardAuthentification.d.ts","sourceRoot":"","sources":["../../../../src/modules/api/CardAuthentification.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0B,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAIvD,UAAU,WAAW;IACjB,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED,UAAU,uBAAuB;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,QAAQ,CAAC,EAAE,WAAW,EAAE,GAAG,GAAG,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB;AA8CD,wBAAsB,iBAAiB,CACnC,MAAM,EAAE;IACJ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,EAAE;QAAE,UAAU,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAC5D,oBAAoB,EAAE,MAAM,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAA;CACnB,EACD,GAAG,GAAE,cAA6B;;;;;;;;;;;;;;;;;;;;;;;;aA/DzB,OAAO;cACN,OAAO;aACR,GAAG,EAAE;eACH,WAAW,EAAE,GAAG,GAAG;oBACd,MAAM;YACd,GAAG;GAqLd;AAID,wBAAsB,gBAAgB,CAClC,MAAM,EAAE;IACJ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,EAAE;QAAE,UAAU,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAC5D,oBAAoB,EAAE,MAAM,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,uBAAuB,CAAA;CAC7C,EACD,GAAG,GAAE,cAA6B,gBA0LrC;AAED,wBAAsB,iBAAiB,CACnC,MAAM,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAC9E,GAAG,GAAE,cAA6B,gBAiFrC"}
@@ -2,14 +2,47 @@ import kycService, { authentification, errorMessage, truncateFields } from "./KY
2
2
  import { cropByObb, getObbConfidence, OBB_CONFIDENCE_THRESHOLD } from "../../utils/cropByObb";
3
3
  import { logger } from "../../utils/logger";
4
4
  import { countryData } from "../../config/countriesData";
5
+ function getDistance(p1, p2) {
6
+ return Math.sqrt(Math.pow(p2[0] - p1[0], 2) + Math.pow(p2[1] - p1[1], 2));
7
+ }
8
+ function getPolygonArea(points) {
9
+ const n = points.length;
10
+ let area = 0;
11
+ for (let i = 0; i < n; i++) {
12
+ const j = (i + 1) % n;
13
+ area += points[i][0] * points[j][1];
14
+ area -= points[j][0] * points[i][1];
15
+ }
16
+ return Math.abs(area) / 2;
17
+ }
18
+ function assertCardNotTooFar(points) {
19
+ if (!points || points.length < 3)
20
+ return;
21
+ const longestCardEdge = Math.max(getDistance(points[0], points[1]), getDistance(points[1], points[2]), getDistance(points[2], points[3] ?? points[0]));
22
+ const cardArea = getPolygonArea(points);
23
+ logger.log(`Card distance check – longest edge: ${Math.round(longestCardEdge)} px, ` +
24
+ `OBB area: ${Math.round(cardArea)} px²`);
25
+ if (longestCardEdge < 700) {
26
+ logger.log(`🛑 Rejected: longest edge too short (${Math.round(longestCardEdge)} px < 700 px)`);
27
+ throw new Error('TOO_FAR_AWAY');
28
+ }
29
+ if (cardArea < 400_000) {
30
+ logger.log(`🛑 Rejected: card area too small (${Math.round(cardArea)} px² < 400 000 px²)`);
31
+ throw new Error('TOO_FAR_AWAY');
32
+ }
33
+ }
34
+ // ─── frontVerification ────────────────────────────────────────────────────────
5
35
  export async function frontVerification(result, env = 'PRODUCTION') {
6
36
  try {
7
37
  console.log("Front verification START", JSON.stringify({ result }, null, 2));
8
38
  logger.log("Front verification", JSON.stringify({ result }, null, 2));
9
- // SANDBOX mode
39
+ // 🚨 FIX 1: Bulletproof Case-Insensitive Check
40
+ const authMethods = Array.isArray(result.regionMapping?.authMethod)
41
+ ? result.regionMapping.authMethod.map(m => String(m).toUpperCase())
42
+ : [];
43
+ const hasMrz = authMethods.some(m => m.includes('MRZ'));
10
44
  if (env === 'SANDBOX') {
11
45
  console.log("SANDBOX mode: Skipping AI verification for front document");
12
- logger.log("SANDBOX mode: Returning mock front verification response");
13
46
  const mockBbox = { minX: 400, minY: 800, width: 2200, height: 1400 };
14
47
  const mockResponse = {
15
48
  result: true,
@@ -21,11 +54,11 @@ export async function frontVerification(result, env = 'PRODUCTION') {
21
54
  cropped_sides: []
22
55
  }],
23
56
  bbox: mockBbox,
24
- ...(result.regionMapping?.authMethod?.includes('MRZ') ? {
57
+ ...(hasMrz ? {
25
58
  mrz: {
26
59
  success: true,
27
60
  parsed_data: {
28
- status: 'success',
61
+ status: 'SUCCESS',
29
62
  document_type: result.selectedDocumentType,
30
63
  mrz_type: result.mrzType || 'TD1'
31
64
  }
@@ -35,7 +68,6 @@ export async function frontVerification(result, env = 'PRODUCTION') {
35
68
  return mockResponse;
36
69
  }
37
70
  const token = await authentification();
38
- // Cast the response so TypeScript knows about card_obb
39
71
  const detected = await kycService.detectFaceOnId(result?.path || '', token, result?.selectedDocumentType || '', env);
40
72
  if (!detected.result) {
41
73
  throw new Error('Aucun visage détecté sur la carte. Veuillez reprendre.');
@@ -46,7 +78,6 @@ export async function frontVerification(result, env = 'PRODUCTION') {
46
78
  let points = null;
47
79
  let isCardInFrame = true;
48
80
  let hasCroppedSides = false;
49
- // Extract data safely
50
81
  if (cardData) {
51
82
  points = cardData.obb;
52
83
  if (typeof cardData.card_in_frame !== 'undefined') {
@@ -54,31 +85,17 @@ export async function frontVerification(result, env = 'PRODUCTION') {
54
85
  hasCroppedSides = Array.isArray(cardData.cropped_sides) && cardData.cropped_sides.length > 0;
55
86
  }
56
87
  }
57
- // --- 1. STRICT FRAMING CHECK (MUST HAPPEN FIRST) ---
58
88
  if (!isCardInFrame || hasCroppedSides) {
59
89
  logger.log(`Front Framing failed. Cropped sides detected.`);
60
90
  throw new Error('CARD_NOT_FULLY_IN_FRAME');
61
91
  }
62
- // --- 2. STRICT DISTANCE CHECK (ONLY RUNS IF FULLY IN FRAME) ---
63
- if (points && points.length === 4) {
64
- const getDistance = (p1, p2) => Math.sqrt(Math.pow(p2[0] - p1[0], 2) + Math.pow(p2[1] - p1[1], 2));
65
- const longestCardEdge = Math.max(getDistance(points[0], points[1]), getDistance(points[1], points[2]));
66
- const maxX = Math.max(points[0][0], points[1][0], points[2][0], points[3][0]);
67
- const maxY = Math.max(points[0][1], points[1][1], points[2][1], points[3][1]);
68
- const estimatedImageScale = Math.max(maxX, maxY);
69
- const fillPercentage = longestCardEdge / estimatedImageScale;
70
- logger.log(`Front Card Fill Percentage: ${(fillPercentage * 100).toFixed(1)}%`);
71
- if (fillPercentage < 0.50) {
72
- logger.log("🛑 Front Image rejected: Document is too far away.");
73
- throw new Error("TOO_FAR_AWAY");
74
- }
92
+ if (points && points.length >= 3) {
93
+ assertCardNotTooFar(points);
75
94
  }
76
- // Check Confidence Threshold
77
95
  const obbConfidence = getObbConfidence(detected.card_obb);
78
96
  if (obbConfidence !== null && obbConfidence < OBB_CONFIDENCE_THRESHOLD) {
79
97
  throw new Error('Carte non entièrement visible. Positionnez toute la carte dans le cadre.');
80
98
  }
81
- // Optional: crop image using card_obb for better MRZ/barcode extraction
82
99
  let croppedBase64;
83
100
  let bbox;
84
101
  let mrz;
@@ -88,40 +105,49 @@ export async function frontVerification(result, env = 'PRODUCTION') {
88
105
  bbox = crop.bbox;
89
106
  }
90
107
  catch { }
91
- // MRZ Extraction: only run when a concrete mrzType is available
92
- const shouldRunMrzExtraction = result.regionMapping?.authMethod?.length > 0 &&
93
- result.regionMapping.authMethod.includes('MRZ') &&
94
- !!result?.mrzType;
95
- if (shouldRunMrzExtraction) {
96
- const mrzResponse = await kycService.extractMrzText({
97
- fileUri: result.path || '',
98
- docType: result?.selectedDocumentType || '',
99
- docRegion: result?.code || "",
100
- postfix: result?.currentSide,
101
- token: token,
102
- template_path: result?.templatePath || '',
103
- mrz_type: result?.mrzType || ''
104
- }, env);
105
- // Safety check: parse if it was returned as a raw string
106
- mrz = typeof mrzResponse === 'string' ? JSON.parse(mrzResponse) : mrzResponse;
107
- if (mrz && (!mrz.success || mrz.parsed_data?.status === 'FAILURE')) {
108
- logger.log("🛑 Front MRZ Extraction Failed:", mrz.parsed_data?.status_message);
109
- throw new Error(`MRZ illisible: ${mrz.parsed_data?.status_message || 'Veuillez nettoyer l\'objectif et réessayer'}`);
108
+ // 🚨 FIX 2: Execute MRZ if required (Removed restrictive guards)
109
+ if (hasMrz) {
110
+ try {
111
+ logger.log("Tentative d'extraction MRZ (Front)");
112
+ const mrzResponse = await kycService.extractMrzText({
113
+ fileUri: result.path || '',
114
+ docType: result?.selectedDocumentType || '',
115
+ docRegion: result?.code || "",
116
+ postfix: result?.currentSide || 'front',
117
+ token: token,
118
+ template_path: result?.templatePath || '',
119
+ mrz_type: result?.mrzType || 'TD1' // Fallback to ensure it always runs
120
+ }, env);
121
+ mrz = typeof mrzResponse === 'string' ? JSON.parse(mrzResponse) : mrzResponse;
122
+ if (mrz?.parsed_data?.status === 'FAILURE' || mrz?.success === false) {
123
+ logger.log("🛑 Front MRZ Extraction Failed:", mrz?.parsed_data?.status_message);
124
+ throw new Error(`MRZ illisible: ${mrz?.parsed_data?.status_message || 'Veuillez nettoyer l\'objectif et réessayer'}`);
125
+ }
126
+ }
127
+ catch (err) {
128
+ logger.error("MRZ Extraction Error:", err);
129
+ throw new Error(err?.message || "Erreur lors de l'extraction MRZ. Veuillez reprendre la photo.");
110
130
  }
111
131
  }
112
132
  return { ...detected, croppedBase64, bbox, ...(mrz ? { mrz } : {}) };
113
133
  }
114
134
  catch (e) {
115
135
  logger.error('Error front verification:', e?.message);
116
- // Do not use LogBox for background silent errors
117
136
  throw new Error(e?.message || 'Erreur de détection du visage');
118
137
  }
119
138
  }
139
+ // ─── backVerification ────────────────────────────────────────────────────────
120
140
  export async function backVerification(result, env = 'PRODUCTION') {
121
141
  try {
122
142
  if (!result.path)
123
143
  throw new Error('No path provided');
124
144
  logger.log("result.regionMapping", result.regionMapping, result.currentSide, result.code);
145
+ // 🚨 FIX 3: Robust Auth Method Resolution for the Back Side
146
+ const authMethods = Array.isArray(result.regionMapping?.authMethod)
147
+ ? result.regionMapping.authMethod.map(m => String(m).toUpperCase())
148
+ : [];
149
+ const hasMrz = authMethods.some(m => m.includes('MRZ'));
150
+ const hasBarcode = authMethods.some(m => m.includes('BARCODE') || m.includes('2D'));
125
151
  if (env === 'SANDBOX') {
126
152
  console.log("SANDBOX mode: Skipping AI verification for back document");
127
153
  const mockBbox = { minX: 400, minY: 800, width: 2200, height: 1400 };
@@ -131,7 +157,7 @@ export async function backVerification(result, env = 'PRODUCTION') {
131
157
  card_in_frame: true,
132
158
  cropped_sides: []
133
159
  }];
134
- if (result.regionMapping?.authMethod?.includes('MRZ')) {
160
+ if (hasMrz) {
135
161
  return {
136
162
  success: true,
137
163
  mrz: {
@@ -146,7 +172,7 @@ export async function backVerification(result, env = 'PRODUCTION') {
146
172
  card_obb: mockCardObb
147
173
  };
148
174
  }
149
- else if (result.regionMapping?.authMethod?.includes('2D_barcode')) {
175
+ else if (hasBarcode) {
150
176
  return {
151
177
  success: true,
152
178
  barcode: { barcode_data: 'SANDBOX_MOCK_BARCODE' },
@@ -158,27 +184,25 @@ export async function backVerification(result, env = 'PRODUCTION') {
158
184
  }
159
185
  const token = await authentification();
160
186
  logger.log("1. Checking template and framing for back document...");
161
- const templateResponse = result.templateResponse || await kycService.checkTemplateType({
162
- fileUri: result.path,
163
- docType: result.selectedDocumentType,
164
- docRegion: result.code,
165
- postfix: 'back',
166
- token: token
167
- }, env);
187
+ const templateResponse = result.templateResponse ||
188
+ await kycService.checkTemplateType({
189
+ fileUri: result.path,
190
+ docType: result.selectedDocumentType,
191
+ docRegion: result.code,
192
+ postfix: 'back',
193
+ token: token
194
+ }, env);
168
195
  if (templateResponse.success === false || templateResponse.Error) {
169
- logger.log("Backend returned an error:", templateResponse.Error);
170
196
  throw new Error('Impossible de lire le document. Veuillez vous rapprocher et stabiliser la caméra.');
171
197
  }
172
198
  const cardData = templateResponse?.card_obb && Array.isArray(templateResponse.card_obb) && templateResponse.card_obb.length > 0
173
199
  ? templateResponse.card_obb[0]
174
200
  : null;
175
- if (!cardData) {
201
+ if (!cardData)
176
202
  throw new Error('CARD_NOT_FULLY_IN_FRAME');
177
- }
178
203
  let points = null;
179
204
  let isCardInFrame = false;
180
205
  let hasCroppedSides = true;
181
- // Safely extract coordinates and frame status
182
206
  if (cardData.obb) {
183
207
  points = cardData.obb;
184
208
  if (typeof cardData.card_in_frame !== 'undefined') {
@@ -199,24 +223,12 @@ export async function backVerification(result, env = 'PRODUCTION') {
199
223
  }
200
224
  }
201
225
  }
202
- // --- 2. STRICT FRAMING CHECK (MUST HAPPEN FIRST) ---
203
226
  if (!isCardInFrame || hasCroppedSides) {
204
227
  logger.log(`Back Framing failed. Coordinates hit image boundary.`);
205
228
  throw new Error('CARD_NOT_FULLY_IN_FRAME');
206
229
  }
207
- // --- 3. STRICT DISTANCE CHECK (ONLY RUNS IF FULLY IN FRAME) ---
208
- if (points && points.length === 4) {
209
- const getDistance = (p1, p2) => Math.sqrt(Math.pow(p2[0] - p1[0], 2) + Math.pow(p2[1] - p1[1], 2));
210
- const longestCardEdge = Math.max(getDistance(points[0], points[1]), getDistance(points[1], points[2]));
211
- const maxX = Math.max(points[0][0], points[1][0], points[2][0], points[3][0]);
212
- const maxY = Math.max(points[0][1], points[1][1], points[2][1], points[3][1]);
213
- const estimatedImageScale = Math.max(maxX, maxY);
214
- const fillPercentage = longestCardEdge / estimatedImageScale;
215
- logger.log(`Back Card Fill Percentage: ${(fillPercentage * 100).toFixed(1)}%`);
216
- if (fillPercentage < 0.50) {
217
- logger.log("🛑 Back Image rejected: Document is too far away.");
218
- throw new Error("TOO_FAR_AWAY");
219
- }
230
+ if (points && points.length >= 3) {
231
+ assertCardNotTooFar(points);
220
232
  }
221
233
  const obbConf = getObbConfidence(templateResponse?.card_obb);
222
234
  if (obbConf !== null && obbConf < OBB_CONFIDENCE_THRESHOLD) {
@@ -228,58 +240,48 @@ export async function backVerification(result, env = 'PRODUCTION') {
228
240
  const hasCodeMatch = activeTemplatePath.includes(`_${result.code}_`);
229
241
  const hasNameMatch = expectedCountryName && activeTemplatePath.toLowerCase().includes(expectedCountryName.toLowerCase());
230
242
  if (!hasCodeMatch && !hasNameMatch) {
231
- logger.log(`Template mismatch! Expected country: ${result.code} (${expectedCountryName}), Detected: ${activeTemplatePath}`);
243
+ logger.log(`Template mismatch! Expected: ${result.code} (${expectedCountryName}), Detected: ${activeTemplatePath}`);
232
244
  throw new Error(`Le document ne correspond pas au pays sélectionné (${result.code}).`);
233
245
  }
234
246
  }
235
247
  logger.log("Framing and Country Template verified successfully. Proceeding to Data Extraction.");
236
- const hasMrz = result.regionMapping?.authMethod?.includes('MRZ') && result?.mrzType;
237
- const hasBarcode = result.regionMapping?.authMethod?.includes('2D_barcode');
238
248
  let extractionResult = {};
239
- // --- 4. Try MRZ First (If required or default) ---
249
+ // 🚨 FIX 4: Guaranteed MRZ Extraction Attachment
240
250
  if (hasMrz) {
241
251
  try {
242
- logger.log("Tentative d'extraction MRZ");
252
+ logger.log("Tentative d'extraction MRZ (Back)");
243
253
  const mrzResponse = await kycService.extractMrzText({
244
254
  fileUri: result.path,
245
255
  docType: result?.selectedDocumentType || '',
246
256
  docRegion: result?.code || '',
247
- postfix: 'back',
257
+ postfix: result?.currentSide || 'back',
248
258
  token: token,
249
259
  template_path: activeTemplatePath,
250
- mrz_type: result?.mrzType || '' // Safe to send empty string
260
+ mrz_type: result?.mrzType || 'TD1'
251
261
  }, env);
252
262
  const mrz = typeof mrzResponse === 'string' ? JSON.parse(mrzResponse) : mrzResponse;
253
- if (!mrz || !mrz.success || mrz.parsed_data?.status === 'FAILURE') {
263
+ if (mrz?.parsed_data?.status === 'FAILURE' || mrz?.success === false) {
254
264
  throw new Error(mrz?.parsed_data?.status_message || 'Lecture MRZ échouée');
255
265
  }
256
- extractionResult = { mrz };
266
+ extractionResult.mrz = mrz; // Attaching securely to result object
257
267
  }
258
268
  catch (mrzError) {
259
- if (hasBarcode) {
260
- logger.log(`MRZ échoué (${mrzError?.message}), tentative d'extraction barcode...`);
261
- try {
262
- const barcode = await kycService.extractBarcode({ fileUri: result.path, token: token }, env);
263
- extractionResult = { barcode };
264
- }
265
- catch (barcodeError) {
266
- throw new Error(`MRZ et Barcode ont échoué. Veuillez stabiliser la carte.`);
267
- }
268
- }
269
- else {
270
- throw new Error(`Lecture MRZ invalide: ${mrzError?.message}`);
271
- }
269
+ logger.log(`MRZ échoué: ${mrzError?.message}`);
270
+ // If MRZ fails, we MUST throw an error so the user is forced to retake it!
271
+ throw new Error(`Lecture MRZ invalide: ${mrzError?.message || 'Veuillez nettoyer l\'objectif et réessayer'}`);
272
272
  }
273
273
  }
274
- // --- 5. Try Barcode Only ---
275
- else if (hasBarcode) {
274
+ if (hasBarcode) {
276
275
  try {
277
- logger.log("Tentative d'extraction barcode seule");
276
+ logger.log("Tentative d'extraction barcode");
278
277
  const barcode = await kycService.extractBarcode({ fileUri: result.path, token: token }, env);
279
- extractionResult = { barcode };
278
+ extractionResult.barcode = barcode;
280
279
  }
281
280
  catch (e) {
282
- throw new Error(`Lecture Barcode échouée: ${e?.message}`);
281
+ // Only throw barcode error if MRZ wasn't already successfully extracted
282
+ if (!extractionResult.mrz) {
283
+ throw new Error(`Lecture Barcode échouée: ${e?.message}`);
284
+ }
283
285
  }
284
286
  }
285
287
  let bbox;
@@ -299,17 +301,11 @@ export async function backVerification(result, env = 'PRODUCTION') {
299
301
  };
300
302
  }
301
303
  catch (e) {
302
- if (e?.message === 'CARD_NOT_FULLY_IN_FRAME' || e?.message === 'TOO_FAR_AWAY') {
304
+ if (e?.message === 'CARD_NOT_FULLY_IN_FRAME' || e?.message === 'TOO_FAR_AWAY')
303
305
  throw e;
304
- }
305
306
  throw new Error(e?.message || 'Erreur de détection des données');
306
307
  }
307
308
  }
308
- /**
309
- * Check template type
310
- * @param result
311
- * @returns
312
- */
313
309
  export async function checkTemplateType(result, env = 'PRODUCTION') {
314
310
  try {
315
311
  if (env === 'SANDBOX') {
@@ -324,7 +320,13 @@ export async function checkTemplateType(result, env = 'PRODUCTION') {
324
320
  };
325
321
  }
326
322
  const token = await authentification();
327
- const templateType = await kycService.checkTemplateType({ fileUri: result.path || '', docType: result?.docType, docRegion: result?.docRegion || "", postfix: result?.postfix, token: token }, env);
323
+ const templateType = await kycService.checkTemplateType({
324
+ fileUri: result.path || '',
325
+ docType: result?.docType,
326
+ docRegion: result?.docRegion || "",
327
+ postfix: result?.postfix,
328
+ token: token
329
+ }, env);
328
330
  if (templateType.success === false || templateType.Error) {
329
331
  logger.log("Backend returned an error:", templateType.Error);
330
332
  throw new Error('Impossible de lire le document. Veuillez vous rapprocher et stabiliser la caméra.');
@@ -332,14 +334,11 @@ export async function checkTemplateType(result, env = 'PRODUCTION') {
332
334
  const cardData = templateType.card_obb && Array.isArray(templateType.card_obb) && templateType.card_obb.length > 0
333
335
  ? templateType.card_obb[0]
334
336
  : null;
335
- if (!cardData) {
337
+ if (!cardData)
336
338
  throw new Error('CARD_NOT_FULLY_IN_FRAME');
337
- }
338
- // Default to FALSE so it must prove it is in the frame
339
339
  let points = null;
340
340
  let isCardInFrame = false;
341
341
  let hasCroppedSides = true;
342
- // Extract data safely based on API response format
343
342
  if (cardData.obb) {
344
343
  points = cardData.obb;
345
344
  if (typeof cardData.card_in_frame !== 'undefined') {
@@ -349,27 +348,27 @@ export async function checkTemplateType(result, env = 'PRODUCTION') {
349
348
  }
350
349
  else if (Array.isArray(cardData) && Array.isArray(cardData[0])) {
351
350
  points = cardData[0];
352
- isCardInFrame = true; // Passed initial existence check
351
+ isCardInFrame = true;
353
352
  hasCroppedSides = false;
354
- // MATH FALLBACK: Check if the coordinates are touching the absolute edge of the photo.
355
353
  if (points && points.length === 4) {
356
354
  const minX = Math.min(...points.map((p) => p[0]));
357
355
  const minY = Math.min(...points.map((p) => p[1]));
358
- // If any corner is within 15 pixels of the edge, it is physically cut off!
359
356
  if (minX <= 15 || minY <= 15) {
360
357
  isCardInFrame = false;
361
358
  hasCroppedSides = true;
362
359
  }
363
360
  }
364
361
  }
365
- // --- 3. STRICT FRAMING CHECK (MUST HAPPEN FIRST) ---
366
362
  if (!isCardInFrame || hasCroppedSides) {
367
- logger.log(`Template Framing failed. Coordinates hit image boundary.`);
363
+ logger.log(`Template Framing failed.`);
368
364
  throw new Error('CARD_NOT_FULLY_IN_FRAME');
369
365
  }
366
+ if (points && points.length >= 3) {
367
+ assertCardNotTooFar(points);
368
+ }
370
369
  const LPIPS_THRESHOLD = 0.75;
371
370
  if (templateType.lpips_score !== undefined && templateType.lpips_score > LPIPS_THRESHOLD) {
372
- logger.log(`🛑 Country Mismatch! LPIPS Score too high: ${templateType.lpips_score}`);
371
+ logger.log(`🛑 Country Mismatch! LPIPS: ${templateType.lpips_score}`);
373
372
  throw new Error(`Le document présenté ne correspond pas au pays sélectionné (${result.docRegion}).`);
374
373
  }
375
374
  logger.log("templateType result", JSON.stringify(truncateFields(templateType), null, 2));
@@ -377,9 +376,8 @@ export async function checkTemplateType(result, env = 'PRODUCTION') {
377
376
  }
378
377
  catch (e) {
379
378
  logger.error('Error checking template type:', JSON.stringify(errorMessage(e), null, 2));
380
- if (e?.message === 'CARD_NOT_FULLY_IN_FRAME' || e?.message?.includes('ne correspond pas')) {
379
+ if (e?.message === 'CARD_NOT_FULLY_IN_FRAME' || e?.message === 'TOO_FAR_AWAY' || e?.message?.includes('ne correspond pas'))
381
380
  throw e;
382
- }
383
381
  throw new Error(e?.message || 'Erreur de vérification du template');
384
382
  }
385
383
  }