@sanctum-key/react-native-sdk 1.0.23 → 1.0.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.
- package/build/package.json +3 -1
- package/build/src/components/EnhancedCameraView.d.ts +7 -1
- package/build/src/components/EnhancedCameraView.d.ts.map +1 -1
- package/build/src/components/EnhancedCameraView.js +88 -30
- package/build/src/components/EnhancedCameraView.js.map +1 -1
- package/build/src/components/EnhancedCameraView.web.d.ts +5 -1
- package/build/src/components/EnhancedCameraView.web.d.ts.map +1 -1
- package/build/src/components/EnhancedCameraView.web.js +80 -295
- package/build/src/components/EnhancedCameraView.web.js.map +1 -1
- package/build/src/components/KYCElements/CameraCapture.js +1 -1
- package/build/src/components/KYCElements/CameraCapture.js.map +1 -1
- package/build/src/components/KYCElements/CountrySelection.d.ts.map +1 -1
- package/build/src/components/KYCElements/CountrySelection.js +38 -218
- package/build/src/components/KYCElements/CountrySelection.js.map +1 -1
- package/build/src/components/KYCElements/CountrySelectionTemplate.d.ts.map +1 -1
- package/build/src/components/KYCElements/CountrySelectionTemplate.js +119 -26
- package/build/src/components/KYCElements/CountrySelectionTemplate.js.map +1 -1
- package/build/src/components/KYCElements/IDCardCapture.d.ts.map +1 -1
- package/build/src/components/KYCElements/IDCardCapture.js +512 -87
- package/build/src/components/KYCElements/IDCardCapture.js.map +1 -1
- package/build/src/components/KYCElements/VerificationProgressTemplate.d.ts.map +1 -1
- package/build/src/components/KYCElements/VerificationProgressTemplate.js +93 -51
- package/build/src/components/KYCElements/VerificationProgressTemplate.js.map +1 -1
- package/build/src/components/OverLay/type.d.ts +1 -0
- package/build/src/components/OverLay/type.d.ts.map +1 -1
- package/build/src/components/OverLay/type.js.map +1 -1
- package/build/src/components/WebBarcodeScanner.d.ts +9 -0
- package/build/src/components/WebBarcodeScanner.d.ts.map +1 -0
- package/build/src/components/WebBarcodeScanner.js +152 -0
- package/build/src/components/WebBarcodeScanner.js.map +1 -0
- package/build/src/config/KYCConfigs.js +2 -2
- package/build/src/config/KYCConfigs.js.map +1 -1
- package/build/src/config/region_mapping.js +14 -14
- package/build/src/config/region_mapping.js.map +1 -1
- package/build/src/config/region_mapping.json +0 -14
- package/build/src/modules/api/CardAuthentification.d.ts +2 -0
- package/build/src/modules/api/CardAuthentification.d.ts.map +1 -1
- package/build/src/modules/api/CardAuthentification.js +23 -40
- package/build/src/modules/api/CardAuthentification.js.map +1 -1
- package/build/src/modules/api/KYCService.d.ts +7 -2
- package/build/src/modules/api/KYCService.d.ts.map +1 -1
- package/build/src/modules/api/KYCService.js +163 -57
- package/build/src/modules/api/KYCService.js.map +1 -1
- package/build/src/types/KYC.types.d.ts +1 -0
- package/build/src/types/KYC.types.d.ts.map +1 -1
- package/build/src/types/KYC.types.js.map +1 -1
- package/build/src/utils/aamvaParser.d.ts +62 -0
- package/build/src/utils/aamvaParser.d.ts.map +1 -0
- package/build/src/utils/aamvaParser.js +91 -0
- package/build/src/utils/aamvaParser.js.map +1 -0
- package/build/src/utils/cropByObb.d.ts.map +1 -1
- package/build/src/utils/cropByObb.js +4 -3
- package/build/src/utils/cropByObb.js.map +1 -1
- package/build/src/web/WebKYCEntry.d.ts +1 -1
- package/build/src/web/WebKYCEntry.d.ts.map +1 -1
- package/build/src/web/WebKYCEntry.js +105 -239
- package/build/src/web/WebKYCEntry.js.map +1 -1
- package/package.json +3 -1
- package/src/components/EnhancedCameraView.tsx +116 -42
- package/src/components/EnhancedCameraView.web.tsx +98 -338
- package/src/components/KYCElements/CameraCapture.tsx +1 -1
- package/src/components/KYCElements/CountrySelection.tsx +60 -240
- package/src/components/KYCElements/CountrySelectionTemplate.tsx +148 -29
- package/src/components/KYCElements/IDCardCapture.tsx +675 -142
- package/src/components/KYCElements/VerificationProgressTemplate.tsx +112 -65
- package/src/components/OverLay/type.ts +1 -1
- package/src/components/WebBarcodeScanner.tsx +273 -0
- package/src/config/KYCConfigs.ts +2 -2
- package/src/config/region_mapping.json +0 -14
- package/src/config/region_mapping.ts +14 -14
- package/src/modules/api/CardAuthentification.ts +44 -58
- package/src/modules/api/KYCService.ts +236 -82
- package/src/types/KYC.types.ts +1 -0
- package/src/utils/aamvaParser.ts +102 -0
- package/src/utils/cropByObb.ts +5 -3
- package/src/web/WebKYCEntry.tsx +125 -301
|
@@ -3,7 +3,7 @@ import { cropByObb, getObbConfidence, OBB_CONFIDENCE_THRESHOLD } from "../../uti
|
|
|
3
3
|
import { GovernmentDocumentType, IBbox } from "../../types/KYC.types";
|
|
4
4
|
import { KycEnvironment } from "../../types/env.types";
|
|
5
5
|
import { logger } from "../../utils/logger";
|
|
6
|
-
import { countryData } from "../../config/countriesData";
|
|
6
|
+
// import { countryData } from "../../config/countriesData";
|
|
7
7
|
|
|
8
8
|
interface CardObbData {
|
|
9
9
|
obb: number[][];
|
|
@@ -31,7 +31,8 @@ export async function frontVerification(
|
|
|
31
31
|
currentSide: string,
|
|
32
32
|
templatePath?: string,
|
|
33
33
|
mrzType?: string,
|
|
34
|
-
issuingSubdivision?: string
|
|
34
|
+
issuingSubdivision?: string,
|
|
35
|
+
clientSideBarcodeData?: string // 🚨 ADDED: Accept the SDK barcode data
|
|
35
36
|
},
|
|
36
37
|
env: KycEnvironment = 'PRODUCTION'
|
|
37
38
|
) {
|
|
@@ -86,7 +87,7 @@ export async function frontVerification(
|
|
|
86
87
|
: null;
|
|
87
88
|
|
|
88
89
|
let points: number[][] | null = null;
|
|
89
|
-
console.log(points)
|
|
90
|
+
console.log(points);
|
|
90
91
|
let isCardInFrame = true;
|
|
91
92
|
let hasCroppedSides = false;
|
|
92
93
|
|
|
@@ -119,7 +120,7 @@ export async function frontVerification(
|
|
|
119
120
|
croppedBase64 = crop.base64;
|
|
120
121
|
bbox = crop.bbox;
|
|
121
122
|
} catch { }
|
|
122
|
-
|
|
123
|
+
|
|
123
124
|
if (result.code === 'CA') {
|
|
124
125
|
try {
|
|
125
126
|
logger.log("Tentative d'extraction OCR (Front) - Canada Only");
|
|
@@ -132,13 +133,16 @@ export async function frontVerification(
|
|
|
132
133
|
token: token,
|
|
133
134
|
postfix: result.currentSide || 'front'
|
|
134
135
|
});
|
|
135
|
-
|
|
136
|
-
if (documentData && documentData.data && Object.keys(documentData.data).length === 0) {
|
|
136
|
+
if (documentData?.no_data || (documentData && documentData.data && Object.keys(documentData.data).length === 0)) {
|
|
137
137
|
logger.log("Front OCR Extraction Failed: Backend returned empty data dict.");
|
|
138
|
-
|
|
138
|
+
if (!hasBarcode && !hasMrz) {
|
|
139
|
+
throw new Error("Impossible de lire les informations du document. L'image est peut-être floue ou mal éclairée.");
|
|
140
|
+
}
|
|
139
141
|
}
|
|
140
142
|
} catch (err: any) {
|
|
141
|
-
|
|
143
|
+
const errorMsg = typeof err === 'object' ? JSON.stringify(err) : err;
|
|
144
|
+
logger.log("Front OCR Extraction Error:", errorMsg);
|
|
145
|
+
throw new Error(err?.message || "Impossible d'extraire les données. Veuillez reprendre la photo.");
|
|
142
146
|
}
|
|
143
147
|
}
|
|
144
148
|
|
|
@@ -169,27 +173,16 @@ export async function frontVerification(
|
|
|
169
173
|
throw new Error(err?.message || "Erreur lors de l'extraction MRZ. Veuillez reprendre la photo.");
|
|
170
174
|
}
|
|
171
175
|
}
|
|
176
|
+
|
|
172
177
|
|
|
173
|
-
if (hasBarcode) {
|
|
174
|
-
try {
|
|
175
|
-
logger.log("Tentative d'extraction barcode (Front)");
|
|
176
|
-
barcode = await kycService.extractBarcode({ fileUri: result.path || '', token: token }, env);
|
|
177
|
-
} catch (e: any) {
|
|
178
|
-
logger.log("Front Barcode Extraction Error:", e?.message);
|
|
179
|
-
// If it exclusively has a barcode (no MRZ) and barcode fails, throw.
|
|
180
|
-
if (!mrz) {
|
|
181
|
-
throw new Error(`Lecture Barcode échouée: ${e?.message || 'Veuillez réessayer'}`);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
178
|
|
|
186
|
-
return {
|
|
187
|
-
...detected,
|
|
188
|
-
croppedBase64,
|
|
189
|
-
bbox,
|
|
190
|
-
...(mrz ? { mrz } : {}),
|
|
179
|
+
return {
|
|
180
|
+
...detected,
|
|
181
|
+
croppedBase64,
|
|
182
|
+
bbox,
|
|
183
|
+
...(mrz ? { mrz } : {}),
|
|
191
184
|
...(barcode ? { barcode } : {}),
|
|
192
|
-
...(documentData ? { documentData } : {})
|
|
185
|
+
...(documentData ? { documentData } : {})
|
|
193
186
|
};
|
|
194
187
|
|
|
195
188
|
} catch (e: any) {
|
|
@@ -208,8 +201,9 @@ export async function backVerification(
|
|
|
208
201
|
templatePath?: string,
|
|
209
202
|
mrzType?: string,
|
|
210
203
|
templateResponse?: ApiVerificationResponse,
|
|
211
|
-
issuingSubdivision?: string,
|
|
212
|
-
frontTemplatePath?: string
|
|
204
|
+
issuingSubdivision?: string,
|
|
205
|
+
frontTemplatePath?: string,
|
|
206
|
+
clientSideBarcodeData?: string // 🚨 ADDED: Accept the SDK barcode data
|
|
213
207
|
},
|
|
214
208
|
env: KycEnvironment = 'PRODUCTION'
|
|
215
209
|
) {
|
|
@@ -233,7 +227,7 @@ export async function backVerification(
|
|
|
233
227
|
card_in_frame: true,
|
|
234
228
|
cropped_sides: []
|
|
235
229
|
}];
|
|
236
|
-
|
|
230
|
+
|
|
237
231
|
if (hasMrz) {
|
|
238
232
|
return {
|
|
239
233
|
success: true,
|
|
@@ -278,7 +272,7 @@ export async function backVerification(
|
|
|
278
272
|
if (!cardData) throw new Error('CARD_NOT_FULLY_IN_FRAME');
|
|
279
273
|
|
|
280
274
|
let points: number[][] | null = null;
|
|
281
|
-
console.log(points)
|
|
275
|
+
console.log(points);
|
|
282
276
|
let isCardInFrame = false;
|
|
283
277
|
let hasCroppedSides = true;
|
|
284
278
|
|
|
@@ -307,16 +301,15 @@ export async function backVerification(
|
|
|
307
301
|
const activeTemplatePath = templateResponse.template_path || result.templatePath || '';
|
|
308
302
|
|
|
309
303
|
if (activeTemplatePath) {
|
|
310
|
-
|
|
304
|
+
// Note: Make sure ISO_TO_COUNTRY_NAME is properly defined or imported if needed here
|
|
311
305
|
const hasCodeMatch = activeTemplatePath.includes(`_${result.code}_`);
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
logger.log(`Template mismatch! Expected: ${result.code} (${expectedCountryName}), Detected: ${activeTemplatePath}`);
|
|
306
|
+
// Assuming you have countryData available, otherwise you can rely just on CodeMatch
|
|
307
|
+
if (!hasCodeMatch && !activeTemplatePath.toLowerCase().includes(result.code.toLowerCase())) {
|
|
308
|
+
logger.log(`Template mismatch! Expected region: ${result.code}, Detected: ${activeTemplatePath}`);
|
|
316
309
|
throw new Error(`Le document ne correspond pas au pays sélectionné (${result.code}).`);
|
|
317
310
|
}
|
|
318
311
|
}
|
|
319
|
-
|
|
312
|
+
|
|
320
313
|
if (result.frontTemplatePath && activeTemplatePath) {
|
|
321
314
|
try {
|
|
322
315
|
const frontPy = result.frontTemplatePath.split("/").pop()?.replace(/\.(jpg|png)$/i, ".py");
|
|
@@ -325,9 +318,9 @@ export async function backVerification(
|
|
|
325
318
|
if (frontPy && backPy) {
|
|
326
319
|
logger.log(`Validating Front (${frontPy}) vs Back (${backPy}) for region ${result.code}`);
|
|
327
320
|
|
|
328
|
-
const isCanadianSubRegionDoc = result.code === 'CA' && ['
|
|
321
|
+
const isCanadianSubRegionDoc = result.code === 'CA' && ['pr'].includes(result.selectedDocumentType);
|
|
329
322
|
const safeSubRegion = isCanadianSubRegionDoc ? (result.issuingSubdivision || "") : "";
|
|
330
|
-
|
|
323
|
+
|
|
331
324
|
const matchValidation = await kycService.validateBackTemplate({
|
|
332
325
|
region: result.code,
|
|
333
326
|
docType: result.selectedDocumentType,
|
|
@@ -350,7 +343,7 @@ export async function backVerification(
|
|
|
350
343
|
|
|
351
344
|
logger.log("Framing, Country, and Match verified successfully. Proceeding to Data Extraction.");
|
|
352
345
|
let extractionResult: any = {};
|
|
353
|
-
|
|
346
|
+
|
|
354
347
|
if (result.code === 'CA') {
|
|
355
348
|
try {
|
|
356
349
|
logger.log("Tentative d'extraction OCR (Back) - Canada Only");
|
|
@@ -363,14 +356,19 @@ export async function backVerification(
|
|
|
363
356
|
token: token,
|
|
364
357
|
postfix: result.currentSide || 'back'
|
|
365
358
|
});
|
|
366
|
-
|
|
367
|
-
if (documentData
|
|
368
|
-
logger.log("
|
|
369
|
-
|
|
359
|
+
|
|
360
|
+
if (documentData?.no_data || (documentData?.data && Object.keys(documentData.data).length === 0)) {
|
|
361
|
+
logger.log("Back OCR Extraction: No text data found (Normal for barcode-only sides).");
|
|
362
|
+
if (!hasBarcode && !hasMrz) {
|
|
363
|
+
throw new Error("Impossible de lire les informations du document. L'image est peut-être floue ou mal éclairée.");
|
|
364
|
+
}
|
|
365
|
+
} else {
|
|
366
|
+
extractionResult.documentData = documentData;
|
|
370
367
|
}
|
|
371
|
-
extractionResult.documentData = documentData;
|
|
372
368
|
} catch (err: any) {
|
|
373
|
-
|
|
369
|
+
const errorMsg = typeof err === 'object' ? JSON.stringify(err) : err;
|
|
370
|
+
logger.log("Back OCR Extraction Error:", errorMsg);
|
|
371
|
+
throw new Error(err?.message || "Impossible d'extraire les données. Veuillez reprendre la photo.");
|
|
374
372
|
}
|
|
375
373
|
}
|
|
376
374
|
|
|
@@ -392,25 +390,13 @@ export async function backVerification(
|
|
|
392
390
|
if (mrz?.parsed_data?.status === 'FAILURE' || mrz?.success === false) {
|
|
393
391
|
throw new Error(mrz?.parsed_data?.status_message || 'Lecture MRZ échouée');
|
|
394
392
|
}
|
|
395
|
-
extractionResult.mrz = mrz;
|
|
393
|
+
extractionResult.mrz = mrz;
|
|
396
394
|
} catch (mrzError: any) {
|
|
397
395
|
logger.log(`MRZ échoué: ${mrzError?.message}`);
|
|
398
396
|
throw new Error(`Lecture MRZ invalide: ${mrzError?.message || 'Veuillez nettoyer l\'objectif et réessayer'}`);
|
|
399
397
|
}
|
|
400
398
|
}
|
|
401
399
|
|
|
402
|
-
if (hasBarcode) {
|
|
403
|
-
try {
|
|
404
|
-
logger.log("Tentative d'extraction barcode (Back)");
|
|
405
|
-
const barcode = await kycService.extractBarcode({ fileUri: result.path!, token: token }, env);
|
|
406
|
-
extractionResult.barcode = barcode;
|
|
407
|
-
} catch (e: any) {
|
|
408
|
-
// If it explicitly expects a barcode (and not an MRZ) and fails, throw to user
|
|
409
|
-
if (!extractionResult.mrz) {
|
|
410
|
-
throw new Error(`Lecture Barcode échouée: ${e?.message}`);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
400
|
|
|
415
401
|
let bbox: IBbox | undefined;
|
|
416
402
|
let croppedBase64: string | undefined;
|