@sanctum-key/react-native-sdk 1.0.23 → 1.0.24

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.
@@ -208,8 +208,8 @@ export async function backVerification(
208
208
  templatePath?: string,
209
209
  mrzType?: string,
210
210
  templateResponse?: ApiVerificationResponse,
211
- issuingSubdivision?: string,
212
- frontTemplatePath?: string
211
+ issuingSubdivision?: string, // Capture province/state
212
+ frontTemplatePath?: string // Capture the front template to compare against
213
213
  },
214
214
  env: KycEnvironment = 'PRODUCTION'
215
215
  ) {
@@ -278,7 +278,7 @@ export async function backVerification(
278
278
  if (!cardData) throw new Error('CARD_NOT_FULLY_IN_FRAME');
279
279
 
280
280
  let points: number[][] | null = null;
281
- console.log(points)
281
+ console.log(points);
282
282
  let isCardInFrame = false;
283
283
  let hasCroppedSides = true;
284
284
 
@@ -325,7 +325,7 @@ export async function backVerification(
325
325
  if (frontPy && backPy) {
326
326
  logger.log(`Validating Front (${frontPy}) vs Back (${backPy}) for region ${result.code}`);
327
327
 
328
- const isCanadianSubRegionDoc = result.code === 'CA' && ['hic'].includes(result.selectedDocumentType);
328
+ const isCanadianSubRegionDoc = result.code === 'CA' && ['xxx'].includes(result.selectedDocumentType);
329
329
  const safeSubRegion = isCanadianSubRegionDoc ? (result.issuingSubdivision || "") : "";
330
330
 
331
331
  const matchValidation = await kycService.validateBackTemplate({
@@ -363,14 +363,16 @@ export async function backVerification(
363
363
  token: token,
364
364
  postfix: result.currentSide || 'back'
365
365
  });
366
-
366
+
367
367
  if (documentData && documentData.data && Object.keys(documentData.data).length === 0) {
368
- logger.log("Front OCR Extraction Failed: Backend returned empty data dict.");
368
+ logger.log("Back OCR Extraction Failed: Backend returned empty data dict.");
369
369
  throw new Error("Impossible de lire les informations du document. L'image est peut-être floue ou mal éclairée.");
370
370
  }
371
+
371
372
  extractionResult.documentData = documentData;
372
373
  } catch (err: any) {
373
374
  logger.log("Back OCR Extraction Error:", err?.message || err);
375
+ throw new Error(err?.message || "Impossible d'extraire les données. Veuillez reprendre la photo.");
374
376
  }
375
377
  }
376
378
 
@@ -405,7 +407,6 @@ export async function backVerification(
405
407
  const barcode = await kycService.extractBarcode({ fileUri: result.path!, token: token }, env);
406
408
  extractionResult.barcode = barcode;
407
409
  } catch (e: any) {
408
- // If it explicitly expects a barcode (and not an MRZ) and fails, throw to user
409
410
  if (!extractionResult.mrz) {
410
411
  throw new Error(`Lecture Barcode échouée: ${e?.message}`);
411
412
  }