@transfergratis/react-native-sdk 0.1.10 → 0.1.12

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.
@@ -162,7 +162,7 @@ export class KYCService {
162
162
  headers: { 'Content-Type': 'multipart/form-data', 'Authorization': `Bearer ${token}`, },
163
163
  timeout: 60000,
164
164
  });
165
- logger.log('checkTemplateType res', JSON.stringify(res.data));
165
+ logger.log('checkTemplateType res', JSON.stringify(res.data, null, 2));
166
166
  return res.data;
167
167
  }
168
168
  catch (e) {
@@ -209,7 +209,7 @@ export class KYCService {
209
209
  headers: { 'Content-Type': 'multipart/form-data', 'Authorization': `Bearer ${token}`, },
210
210
  timeout: 60000,
211
211
  });
212
- logger.log('extractBarcode res', JSON.stringify(res.data));
212
+ logger.log('extractBarcode res', JSON.stringify(res.data, null, 2));
213
213
  //check if res.data has aleast one key
214
214
  if (Object.keys(res.data).length === 0)
215
215
  throw new Error('No data found');
@@ -243,7 +243,7 @@ export class KYCService {
243
243
  headers: { 'Content-Type': 'multipart/form-data', 'Authorization': `Bearer ${token}`, },
244
244
  timeout: 60000,
245
245
  });
246
- logger.log('extractMrzText res', JSON.stringify(res.data));
246
+ logger.log('extractMrzText res', JSON.stringify(res.data, null, 2));
247
247
  //check if res.data has aleast one key
248
248
  if (Object.keys(res.data).length === 0)
249
249
  throw new Error('No data found');
@@ -1 +1 @@
1
- {"version":3,"file":"KYCService.js","sourceRoot":"","sources":["../../../src/modules/api/KYCService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAA0B,6BAA6B,EAA4B,MAAM,uBAAuB,CAAC;AAGxH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAqC5C,MAAM,OAAO,UAAU;IACb,OAAO,CAAS;IAChB,MAAM,CAAS;IACvB,4DAA4D;IACpD,cAAc,GAAG,4CAA4C,CAAC;IAC9D,wBAAwB,GAAG,4CAA4C,CA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AAI,EAAE,KAAK;QAC3B,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC;AACzB,CAAC,CAAA","sourcesContent":["import axios from 'axios';\nimport { GovernmentDocumentType, GovernmentDocumentTypeShorted, OrientationVideoResponse } from '../../types/KYC.types';\nimport { CheckTemplateTypeResponse, ExtractMrzTextResponse } from '../../components/OverLay/type';\nimport { SessionResponse, VerificationResult, VerificationSessionRequest } from './types';\nimport { logger } from '../../utils/logger';\n\nexport interface KYCRequest {\n userId: string;\n documentImage: string;\n selfieImage: string;\n documentType: 'passport' | 'id_card' | 'drivers_license';\n}\n\nexport interface KYCResponse {\n success: boolean;\n verificationId: string;\n status: 'pending' | 'approved' | 'rejected';\n message?: string;\n}\n\nexport interface FaceDetectionRequest {\n selfieImage: string;\n documentImage: string;\n}\n\nexport interface FaceDetectionResponse {\n match: boolean;\n confidence: number;\n message: string;\n}\n\nexport interface SelfieVideoResponse {\n orientation_direction: \"center\" | \"left\" | \"right\",\n turn_score: number;\n bbox: number[];\n capture: boolean;\n instruction: string;\n error: string;\n}\n\n\nexport class KYCService {\n private baseURL: string;\n private apiKey: string;\n // Additional service base URLs (fixed as per current infra)\n private faceServiceURL = 'https://kyc-engine.transfergratis.net:8000';\n private textExtractionServiceURL = 'https://kyc-engine.transfergratis.net:8006';\n private mrzServiceURL = 'https://kyc-engine.transfergratis.net:8002';\n private barcodeServiceURL = 'https://kyc-engine.transfergratis.net:8000';\n private orientationServiceURL = 'http://18.188.180.154:8080';\n private backendServiceURL = 'https://kyc-backend.transfergratis.net/api/v1';\n\n constructor(baseURL: string, apiKey: string) {\n this.baseURL = baseURL;\n this.apiKey = apiKey;\n }\n\n private getHeaders() {\n return {\n 'Authorization': `Bearer ${this.apiKey}`,\n 'Content-Type': 'application/json',\n };\n }\n\n async submitKYC(data: KYCRequest): Promise<KYCResponse> {\n try {\n const response = await axios.post(\n `${this.baseURL}/kyc/submit`,\n data,\n { headers: this.getHeaders() }\n );\n return response.data;\n } catch (error) {\n logger.error('Error submitting KYC:', error);\n throw error;\n }\n }\n\n async detectFace(data: FaceDetectionRequest): Promise<FaceDetectionResponse> {\n try {\n const response = await axios.post(\n `${this.baseURL}/ai/face-detection`,\n data,\n { headers: this.getHeaders() }\n );\n return response.data;\n } catch (error) {\n logger.error('Error detecting face:', error);\n throw error;\n }\n }\n\n async validateDocument(documentImage: string, documentType: string): Promise<any> {\n try {\n const response = await axios.post(\n `${this.baseURL}/ai/document-validation`,\n { documentImage, documentType },\n { headers: this.getHeaders() }\n );\n return response.data;\n } catch (error) {\n logger.error('Error validating document:', error);\n throw error;\n }\n }\n\n async getKYCStatus(verificationId: string): Promise<KYCResponse> {\n try {\n const response = await axios.get(\n `${this.baseURL}/kyc/status/${verificationId}`,\n { headers: this.getHeaders() }\n );\n return response.data;\n } catch (error) {\n logger.error('Error getting KYC status:', error);\n throw error;\n }\n }\n\n async processSelfieOrientationPicture(videoFile: string, token: string): Promise<SelfieVideoResponse[]> {\n try {\n const formData = new FormData();\n const rnFile: any = {\n uri: videoFile,\n type: 'image/jpeg',\n name: 'selfie_picture.jpg',\n };\n formData.append('file', rnFile);\n const response = await axios.post<SelfieVideoResponse[]>(\n `${this.faceServiceURL}/detect_face_orientation/`,\n formData,\n {\n timeout: 20000,\n headers: { 'Content-Type': 'multipart/form-data', 'Authorization': `Bearer ${token}`, },\n }\n );\n return response.data;\n } catch (error) {\n logger.error('Error processing selfie orientation:', error);\n throw error;\n }\n }\n\n async processOrientationVideo(videoFile: string): Promise<OrientationVideoResponse> {\n try {\n // Create FormData for multipart/form-data request\n const formData = new FormData();\n // In React Native, prefer the { uri, type, name } pattern rather than Blob\n const rnFile: any = {\n uri: videoFile,\n type: 'video/mp4',\n name: 'orientation_video.mp4',\n };\n formData.append('file', rnFile);\n\n const response = await axios.post(\n `${this.orientationServiceURL}/process_orientation_video_stream/`,\n formData,\n {\n // Let axios set the proper multipart boundary header automatically\n timeout: 90000,\n }\n );\n\n return {\n success: true,\n data: response.data,\n message: 'Orientation video processed successfully'\n };\n } catch (error: any) {\n logger.error('Error processing orientation video:', JSON.stringify(error, null, 2));\n\n // Handle specific error cases\n if (error.response?.status === 503) {\n return {\n success: false,\n error: {\n code: 'SERVICE_UNAVAILABLE',\n message: 'Service not ready, model not initialized.',\n details: error.response.data\n },\n message: 'Service temporarily unavailable'\n };\n }\n\n return {\n success: false,\n error: {\n code: 'PROCESSING_ERROR',\n message: error.response?.data?.detail || error.message || 'Unknown error occurred',\n details: error.response?.data\n },\n message: 'Failed to process orientation video'\n };\n }\n }\n\n // STEP 1 - ID CARD VALIDATION\n async detectFaceOnId(idCardImageUri: string, token: string, docType: string): Promise<{ result: boolean, detail: any[] }> {\n const formData = new FormData();\n const rnFile: any = { uri: idCardImageUri, type: 'image/jpeg', name: 'id_card_photo.jpg' };\n formData.append('file', rnFile);\n\n const docTypeShorted = GovernmentDocumentTypeShorted[docType as GovernmentDocumentType];\n\n try {\n const res = await axios.post(`${this.faceServiceURL}/detect_face/?doc_type=${docTypeShorted}`, formData,\n {\n headers: { 'Content-Type': 'multipart/form-data', 'Authorization': `Bearer ${token}`, },\n timeout: 20000\n });\n logger.log('detectFaceOnId res', JSON.stringify(res.data, null, 2));\n\n if (res.data?.result) return res.data;\n throw new Error(res.data?.detail || 'detect_face failed');\n } catch (error) {\n logger.error('Error detecting face on id:', JSON.stringify(error));\n throw error;\n }\n }\n\n //check templatetemplate_type\n async checkTemplateType(params: { fileUri: string; docType: string; docRegion: string; token: string; postfix: string }): Promise<any> {\n const { fileUri, docType, docRegion, token, postfix } = params;\n const formData = new FormData();\n const rnFile: any = { uri: fileUri, type: 'image/jpeg', name: 'id_card_front.jpg' };\n formData.append('file', rnFile);\n const docTypeShorted = GovernmentDocumentTypeShorted[docType as GovernmentDocumentType];\n logger.log('checkTemplateType params', this.mrzServiceURL, JSON.stringify({ fileUri, docTypeShorted, docRegion, token, postfix }, null, 2));\n const url = `${this.mrzServiceURL}/get_template_version/?doc_type=${encodeURIComponent(docTypeShorted)}&doc_region=${encodeURIComponent(docRegion)}&postfix=${postfix}`;\n\n try {\n const res = await axios.post<CheckTemplateTypeResponse>(url, formData, {\n headers: { 'Content-Type': 'multipart/form-data', 'Authorization': `Bearer ${token}`, },\n timeout: 60000,\n });\n logger.log('checkTemplateType res', JSON.stringify(res.data));\n return res.data;\n } catch (e: any) {\n logger.error('Error checking template type:', JSON.stringify(e));\n throw e;\n }\n\n }\n\n async extractDocumentInformation(params: { fileUri: string; docType: string; docRegion: string; token: string }): Promise<any> {\n const { fileUri, docType, docRegion, token } = params;\n const formData = new FormData();\n const rnFile: any = { uri: fileUri, type: 'image/jpeg', name: 'id_card_front.jpg' };\n formData.append('file', rnFile);\n\n const url = `${this.textExtractionServiceURL}/extract_doc_information/?doc_type=${encodeURIComponent(docType)}&doc_region=${encodeURIComponent(docRegion)}`;\n const attempt = async () => {\n const res = await axios.post(url, formData, {\n headers: { 'Content-Type': 'multipart/form-data', 'Authorization': `Bearer ${token}`, },\n timeout: 60000,\n });\n logger.log('extractDocumentInformation res', JSON.stringify(truncateFields(res)));\n\n if (res.data?.detail) throw new Error(res.data.detail);\n return res.data;\n };\n try {\n return await attempt();\n } catch (e) {\n logger.error('Error extracting document information:', JSON.stringify(truncateFields(e)));\n throw e;\n // await new Promise(r => setTimeout(r, 1500));\n // return await attempt();\n }\n }\n // STEP 2 - barcode extraction\n async extractBarcode(params: { fileUri: string; token: string }): Promise<any> {\n const { fileUri, token } = params;\n const formData = new FormData();\n const rnFile: any = { uri: fileUri, type: 'image/jpeg', name: 'id_card_back.jpg' };\n formData.append('file', rnFile);\n\n const url = `${this.barcodeServiceURL}/decode_barcode/`;\n const attempt = async () => {\n try {\n const res = await axios.post(url, formData, {\n headers: { 'Content-Type': 'multipart/form-data', 'Authorization': `Bearer ${token}`, },\n timeout: 60000,\n });\n logger.log('extractBarcode res', JSON.stringify(res.data));\n //check if res.data has aleast one key\n if (Object.keys(res.data).length === 0) throw new Error('No data found');\n return res.data;\n } catch (e: any) {\n throw new Error(e?.message || 'Erreur de détection du barcode');\n }\n };\n try {\n return await attempt();\n } catch (e) {\n logger.error('Error extracting Barcode text:', JSON.stringify(e));\n throw e;\n }\n }\n // STEP 3 - MRZ TEXT EXTRACTION\n async extractMrzText(params: { fileUri: string; docType: string; docRegion: string; postfix?: string; token: string; template_path: string; mrz_type: string }): Promise<any> {\n const { fileUri, docType, docRegion, postfix = 'back', token, template_path, mrz_type } = params;\n const formData = new FormData();\n const rnFile: any = { uri: fileUri, type: 'image/jpeg', name: 'id_card_back.jpg' };\n formData.append('file', rnFile);\n const docTypeShorted = GovernmentDocumentTypeShorted[docType as GovernmentDocumentType];\n logger.log(\"docTypeShorted\", docTypeShorted, docRegion, postfix);\n\n const url = `${this.mrzServiceURL}/extract_mrz_text/?doc_type=${docTypeShorted}&doc_region=${docRegion}&postfix=${postfix}&template_path=${template_path}&mrz_type=${mrz_type}`;\n logger.log(\"url\", url);\n\n const attempt = async () => {\n try {\n const res = await axios.post<ExtractMrzTextResponse>(url, formData, {\n headers: { 'Content-Type': 'multipart/form-data', 'Authorization': `Bearer ${token}`, },\n timeout: 60000,\n });\n logger.log('extractMrzText res', JSON.stringify(res.data));\n //check if res.data has aleast one key\n if (Object.keys(res.data).length === 0) throw new Error('No data found');\n if (res.data?.success === false) throw new Error(res.data.parsed_data.status);\n return res.data;\n } catch (e: any) {\n throw new Error(e?.message || 'Erreur de détection du MRZ');\n }\n };\n try {\n return await attempt();\n } catch (e) {\n logger.error('Error extracting MRZ text:', JSON.stringify(errorMessage(e), null, 2));\n throw e;\n }\n }\n\n // STEP 2 - SELFIE VALIDATION\n async recognizeFace(params: { idPhotoUri: string; selfiePhotoUri: string }): Promise<{ is_match: boolean; similarity: number; id_bbox?: number[]; selfie_bbox?: number[] }> {\n const { idPhotoUri, selfiePhotoUri } = params;\n const formData = new FormData();\n const idFile: any = { uri: idPhotoUri, type: 'image/jpeg', name: 'id_card_photo.jpg' };\n const selfieFile: any = { uri: selfiePhotoUri, type: 'image/jpeg', name: 'selfie_final.jpg' };\n formData.append('id_photo', idFile);\n formData.append('selfie_photo', selfieFile);\n\n const res = await axios.post(`${this.faceServiceURL}/recognize_face/`, formData, { timeout: 45000 });\n if (res.data?.detail) throw new Error(res.data.detail);\n return res.data;\n }\n\n // HEALTH CHECKS\n async healthFaceDetection(): Promise<any> {\n const res = await axios.get(`${this.faceServiceURL}/health`);\n return res.data;\n }\n\n async healthTextExtraction(): Promise<any> {\n const res = await axios.get(`${this.textExtractionServiceURL}/health`);\n return res.data;\n }\n\n async healthMrzService(): Promise<any> {\n const res = await axios.get(`${this.mrzServiceURL}/health`);\n return res.data;\n }\n\n async healthOrientationService(): Promise<any> {\n const res = await axios.get(`${this.orientationServiceURL}/health`);\n return res.data;\n }\n\n async newSession(token: string): Promise<SessionResponse> {\n try {\n const data = {\n \"status\": \"PENDING\",\n \"metadata\": {},\n }\n const res = await axios.post<SessionResponse>(`${this.backendServiceURL}/verification/sessions/`,\n data, { headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` } });\n return res.data;\n } catch (error: any) {\n logger.error('Error creating session:', JSON.stringify(errorMessage(error), null, 2));\n\n // Extract backend error message if available\n const backendMessage = errorMessage(error);\n\n if (backendMessage) {\n logger.error('Backend error message:', JSON.stringify(truncateFields(backendMessage), null, 2));\n throw new Error(`Backend error: ${JSON.stringify(truncateFields(backendMessage))}`);\n }\n\n throw error;\n }\n }\n\n async verificationSession(payload: VerificationSessionRequest): Promise<any> {\n\n try {\n\n const token = await authentification();\n\n // /api/v1/verification/api/kyc/sessions/{session_id}/steps/{step}/\n const { session_id, step, data, templateId, action } = payload;\n // const session_id = \"kyc-8b4e069258d8\";\n const payloadData = {\n action: action,\n data: {\n step,\n templateId,\n ...(action === \"location_permission\" ? { permissionGranted: true, } : {}),\n ...data,\n },\n ...({ session_id: session_id }),\n timestamp: new Date().toISOString()\n }\n const url = `${this.backendServiceURL}/verification/api/kyc/sessions/${session_id}/steps/${step}/`;\n\n\n const logPayload = truncateFields({ payloadData, session_id, step });\n logger.log('verificationSession payload',\n JSON.stringify(truncateFields({ logPayload, token, path: url }),\n null, 2))\n\n const res = await axios.post<SessionResponse>(url,\n payloadData,\n {\n headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` }\n });\n logger.log('verificationSession res', JSON.stringify(truncateFields(res.data), null, 2));\n return res.data;\n\n\n } catch (error) {\n logger.error('Error validating component:', JSON.stringify(errorMessage(error), null, 2));\n throw new Error(errorMessage(error));\n }\n }\n // reultat de la verification\n async getVerificationResult(session_id: string): Promise<VerificationResult> {\n const token = await authentification();\n const url = `${this.backendServiceURL}/verification/api/kyc/result/?session_id=${session_id}`;\n const res = await axios.get<VerificationResult>(url,\n { headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` } });\n logger.log('getVerificationResult res', JSON.stringify(truncateFields(res.data), null, 2));\n return res.data;\n }\n}\n\n\nconst kycService = new KYCService(\"\", \"\");\nexport default kycService;\n\n\n// Pour éviter d'afficher des champs trop longs, on tronque les valeurs longues dans le log\nexport function truncateFields(obj: any, maxLength = 420): any {\n if (typeof obj !== 'object' || obj === null) return obj;\n if (Array.isArray(obj)) return obj.map(item => truncateFields(item, maxLength));\n const truncated: any = {};\n for (const key in obj) {\n if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;\n const value = obj[key];\n if (typeof value === 'string' && value.length > maxLength) {\n truncated[key] = value.slice(0, maxLength) + '... [truncated]';\n } else if (typeof value === 'object' && value !== null) {\n truncated[key] = truncateFields(value, maxLength);\n } else {\n truncated[key] = value;\n }\n }\n return truncated;\n}\nexport const authentification = async () => {\n try {\n const params = new URLSearchParams();\n params.append('client_id', 'kyc_frontend');\n params.append('client_secret', 'ZCW4mGaJXWR0UuI40lM1pHNQmYLw2xvX');\n params.append('grant_type', 'client_credentials');\n const res = await axios.post(`https://keycloak.transfergratis.net/realms/kyc/protocol/openid-connect/token`,\n params,\n {\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n }\n );\n logger.log('authentification res', JSON.stringify(truncateFields(res.data)));\n return res.data.access_token;\n } catch (error: any) {\n logger.error('Error authentifying:', {\n message: error.message,\n status: error.response?.status,\n statusText: error.response?.statusText,\n data: error.response?.data,\n url: error.config?.url,\n method: error.config?.method\n });\n\n // Extract backend error message if available\n const backendMessage = errorMessage(error);\n\n if (backendMessage) {\n logger.error('Backend authentication error:', JSON.stringify(truncateFields(backendMessage), null, 2));\n throw new Error(`Authentication failed: ${JSON.stringify(truncateFields(backendMessage))}`);\n }\n\n throw error;\n }\n}\n\n\n\nexport const errorMessage = (error: any) => {\n return error.response?.data?.message ||\n error.response?.data?.detail ||\n error.response?.data?.error ||\n error.response?.data;\n}"]}
1
+ {"version":3,"file":"KYCService.js","sourceRoot":"","sources":["../../../src/modules/api/KYCService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAA0B,6BAA6B,EAA4B,MAAM,uBAAuB,CAAC;AAGxH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAqC5C,MAAM,OAAO,UAAU;IACb,OAAO,CAAS;IAChB,MAAM,CAAS;IACvB,4DAA4D;IACpD,cAAc,GAAG,4CAA4C,CAAC;IAC9D,wBAAwB,GAAG,4CAA4C,CAAC;IACxE,aAAa,GAAG,4CAA4C,CAAC;IAC7D,iBAAiB,GAAG,4CAA4C,CAAC;IACjE,qBAAqB,GAAG,4BAA4B,CAAC;IACrD,iBAAiB,GAAG,+CAA+C,CAAC;IAE5E,YAAY,OAAe,EAAE,MAAc;QACzC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEO,UAAU;QAChB,OAAO;YACL,eAAe,EAAE,UAAU,IAAI,CAAC,MAAM,EAAE;YACxC,cAAc,EAAE,kBAAkB;SACnC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,IAAg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O;YACtB,MAAM,EAAE,KAAK,CAAC,QAAQ,EAAE,MAAM;YAC9B,UAAU,EAAE,KAAK,CAAC,QAAQ,EAAE,UAAU;YACtC,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE,IAAI;YAC1B,GAAG,EAAE,KAAK,CAAC,MAAM,EAAE,GAAG;YACtB,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,MAAM;SAC7B,CAAC,CAAC;QAEH,6CAA6C;QAC7C,MAAM,cAAc,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;QAE3C,IAAI,cAAc,EAAE,CAAC;YACnB,MAAM,CAAC,KAAK,CAAC,+BAA+B,EAAE,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YACvG,MAAM,IAAI,KAAK,CAAC,0BAA0B,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;QAC9F,CAAC;QAED,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAA;AAID,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAU,EAAE,EAAE;IACzC,OAAO,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO;QAClC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM;QAC5B,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK;QAC3B,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC;AACzB,CAAC,CAAA","sourcesContent":["import axios from 'axios';\nimport { GovernmentDocumentType, GovernmentDocumentTypeShorted, OrientationVideoResponse } from '../../types/KYC.types';\nimport { CheckTemplateTypeResponse, ExtractMrzTextResponse } from '../../components/OverLay/type';\nimport { SessionResponse, VerificationResult, VerificationSessionRequest } from './types';\nimport { logger } from '../../utils/logger';\n\nexport interface KYCRequest {\n userId: string;\n documentImage: string;\n selfieImage: string;\n documentType: 'passport' | 'id_card' | 'drivers_license';\n}\n\nexport interface KYCResponse {\n success: boolean;\n verificationId: string;\n status: 'pending' | 'approved' | 'rejected';\n message?: string;\n}\n\nexport interface FaceDetectionRequest {\n selfieImage: string;\n documentImage: string;\n}\n\nexport interface FaceDetectionResponse {\n match: boolean;\n confidence: number;\n message: string;\n}\n\nexport interface SelfieVideoResponse {\n orientation_direction: \"center\" | \"left\" | \"right\",\n turn_score: number;\n bbox: number[];\n capture: boolean;\n instruction: string;\n error: string;\n}\n\n\nexport class KYCService {\n private baseURL: string;\n private apiKey: string;\n // Additional service base URLs (fixed as per current infra)\n private faceServiceURL = 'https://kyc-engine.transfergratis.net:8000';\n private textExtractionServiceURL = 'https://kyc-engine.transfergratis.net:8006';\n private mrzServiceURL = 'https://kyc-engine.transfergratis.net:8002';\n private barcodeServiceURL = 'https://kyc-engine.transfergratis.net:8000';\n private orientationServiceURL = 'http://18.188.180.154:8080';\n private backendServiceURL = 'https://kyc-backend.transfergratis.net/api/v1';\n\n constructor(baseURL: string, apiKey: string) {\n this.baseURL = baseURL;\n this.apiKey = apiKey;\n }\n\n private getHeaders() {\n return {\n 'Authorization': `Bearer ${this.apiKey}`,\n 'Content-Type': 'application/json',\n };\n }\n\n async submitKYC(data: KYCRequest): Promise<KYCResponse> {\n try {\n const response = await axios.post(\n `${this.baseURL}/kyc/submit`,\n data,\n { headers: this.getHeaders() }\n );\n return response.data;\n } catch (error) {\n logger.error('Error submitting KYC:', error);\n throw error;\n }\n }\n\n async detectFace(data: FaceDetectionRequest): Promise<FaceDetectionResponse> {\n try {\n const response = await axios.post(\n `${this.baseURL}/ai/face-detection`,\n data,\n { headers: this.getHeaders() }\n );\n return response.data;\n } catch (error) {\n logger.error('Error detecting face:', error);\n throw error;\n }\n }\n\n async validateDocument(documentImage: string, documentType: string): Promise<any> {\n try {\n const response = await axios.post(\n `${this.baseURL}/ai/document-validation`,\n { documentImage, documentType },\n { headers: this.getHeaders() }\n );\n return response.data;\n } catch (error) {\n logger.error('Error validating document:', error);\n throw error;\n }\n }\n\n async getKYCStatus(verificationId: string): Promise<KYCResponse> {\n try {\n const response = await axios.get(\n `${this.baseURL}/kyc/status/${verificationId}`,\n { headers: this.getHeaders() }\n );\n return response.data;\n } catch (error) {\n logger.error('Error getting KYC status:', error);\n throw error;\n }\n }\n\n async processSelfieOrientationPicture(videoFile: string, token: string): Promise<SelfieVideoResponse[]> {\n try {\n const formData = new FormData();\n const rnFile: any = {\n uri: videoFile,\n type: 'image/jpeg',\n name: 'selfie_picture.jpg',\n };\n formData.append('file', rnFile);\n const response = await axios.post<SelfieVideoResponse[]>(\n `${this.faceServiceURL}/detect_face_orientation/`,\n formData,\n {\n timeout: 20000,\n headers: { 'Content-Type': 'multipart/form-data', 'Authorization': `Bearer ${token}`, },\n }\n );\n return response.data;\n } catch (error) {\n logger.error('Error processing selfie orientation:', error);\n throw error;\n }\n }\n\n async processOrientationVideo(videoFile: string): Promise<OrientationVideoResponse> {\n try {\n // Create FormData for multipart/form-data request\n const formData = new FormData();\n // In React Native, prefer the { uri, type, name } pattern rather than Blob\n const rnFile: any = {\n uri: videoFile,\n type: 'video/mp4',\n name: 'orientation_video.mp4',\n };\n formData.append('file', rnFile);\n\n const response = await axios.post(\n `${this.orientationServiceURL}/process_orientation_video_stream/`,\n formData,\n {\n // Let axios set the proper multipart boundary header automatically\n timeout: 90000,\n }\n );\n\n return {\n success: true,\n data: response.data,\n message: 'Orientation video processed successfully'\n };\n } catch (error: any) {\n logger.error('Error processing orientation video:', JSON.stringify(error, null, 2));\n\n // Handle specific error cases\n if (error.response?.status === 503) {\n return {\n success: false,\n error: {\n code: 'SERVICE_UNAVAILABLE',\n message: 'Service not ready, model not initialized.',\n details: error.response.data\n },\n message: 'Service temporarily unavailable'\n };\n }\n\n return {\n success: false,\n error: {\n code: 'PROCESSING_ERROR',\n message: error.response?.data?.detail || error.message || 'Unknown error occurred',\n details: error.response?.data\n },\n message: 'Failed to process orientation video'\n };\n }\n }\n\n // STEP 1 - ID CARD VALIDATION\n async detectFaceOnId(idCardImageUri: string, token: string, docType: string): Promise<{ result: boolean, detail: any[] }> {\n const formData = new FormData();\n const rnFile: any = { uri: idCardImageUri, type: 'image/jpeg', name: 'id_card_photo.jpg' };\n formData.append('file', rnFile);\n\n const docTypeShorted = GovernmentDocumentTypeShorted[docType as GovernmentDocumentType];\n\n try {\n const res = await axios.post(`${this.faceServiceURL}/detect_face/?doc_type=${docTypeShorted}`, formData,\n {\n headers: { 'Content-Type': 'multipart/form-data', 'Authorization': `Bearer ${token}`, },\n timeout: 20000\n });\n logger.log('detectFaceOnId res', JSON.stringify(res.data, null, 2));\n\n if (res.data?.result) return res.data;\n throw new Error(res.data?.detail || 'detect_face failed');\n } catch (error) {\n logger.error('Error detecting face on id:', JSON.stringify(error));\n throw error;\n }\n }\n\n //check templatetemplate_type\n async checkTemplateType(params: { fileUri: string; docType: string; docRegion: string; token: string; postfix: string }): Promise<any> {\n const { fileUri, docType, docRegion, token, postfix } = params;\n const formData = new FormData();\n const rnFile: any = { uri: fileUri, type: 'image/jpeg', name: 'id_card_front.jpg' };\n formData.append('file', rnFile);\n const docTypeShorted = GovernmentDocumentTypeShorted[docType as GovernmentDocumentType];\n logger.log('checkTemplateType params', this.mrzServiceURL, JSON.stringify({ fileUri, docTypeShorted, docRegion, token, postfix }, null, 2));\n const url = `${this.mrzServiceURL}/get_template_version/?doc_type=${encodeURIComponent(docTypeShorted)}&doc_region=${encodeURIComponent(docRegion)}&postfix=${postfix}`;\n\n try {\n const res = await axios.post<CheckTemplateTypeResponse>(url, formData, {\n headers: { 'Content-Type': 'multipart/form-data', 'Authorization': `Bearer ${token}`, },\n timeout: 60000,\n });\n logger.log('checkTemplateType res', JSON.stringify(res.data, null, 2));\n return res.data;\n } catch (e: any) {\n logger.error('Error checking template type:', JSON.stringify(e));\n throw e;\n }\n\n }\n\n async extractDocumentInformation(params: { fileUri: string; docType: string; docRegion: string; token: string }): Promise<any> {\n const { fileUri, docType, docRegion, token } = params;\n const formData = new FormData();\n const rnFile: any = { uri: fileUri, type: 'image/jpeg', name: 'id_card_front.jpg' };\n formData.append('file', rnFile);\n\n const url = `${this.textExtractionServiceURL}/extract_doc_information/?doc_type=${encodeURIComponent(docType)}&doc_region=${encodeURIComponent(docRegion)}`;\n const attempt = async () => {\n const res = await axios.post(url, formData, {\n headers: { 'Content-Type': 'multipart/form-data', 'Authorization': `Bearer ${token}`, },\n timeout: 60000,\n });\n logger.log('extractDocumentInformation res', JSON.stringify(truncateFields(res)));\n\n if (res.data?.detail) throw new Error(res.data.detail);\n return res.data;\n };\n try {\n return await attempt();\n } catch (e) {\n logger.error('Error extracting document information:', JSON.stringify(truncateFields(e)));\n throw e;\n // await new Promise(r => setTimeout(r, 1500));\n // return await attempt();\n }\n }\n // STEP 2 - barcode extraction\n async extractBarcode(params: { fileUri: string; token: string }): Promise<any> {\n const { fileUri, token } = params;\n const formData = new FormData();\n const rnFile: any = { uri: fileUri, type: 'image/jpeg', name: 'id_card_back.jpg' };\n formData.append('file', rnFile);\n\n const url = `${this.barcodeServiceURL}/decode_barcode/`;\n const attempt = async () => {\n try {\n const res = await axios.post(url, formData, {\n headers: { 'Content-Type': 'multipart/form-data', 'Authorization': `Bearer ${token}`, },\n timeout: 60000,\n });\n logger.log('extractBarcode res', JSON.stringify(res.data, null, 2));\n //check if res.data has aleast one key\n if (Object.keys(res.data).length === 0) throw new Error('No data found');\n return res.data;\n } catch (e: any) {\n throw new Error(e?.message || 'Erreur de détection du barcode');\n }\n };\n try {\n return await attempt();\n } catch (e) {\n logger.error('Error extracting Barcode text:', JSON.stringify(e));\n throw e;\n }\n }\n // STEP 3 - MRZ TEXT EXTRACTION\n async extractMrzText(params: { fileUri: string; docType: string; docRegion: string; postfix?: string; token: string; template_path: string; mrz_type: string }): Promise<any> {\n const { fileUri, docType, docRegion, postfix = 'back', token, template_path, mrz_type } = params;\n const formData = new FormData();\n const rnFile: any = { uri: fileUri, type: 'image/jpeg', name: 'id_card_back.jpg' };\n formData.append('file', rnFile);\n const docTypeShorted = GovernmentDocumentTypeShorted[docType as GovernmentDocumentType];\n logger.log(\"docTypeShorted\", docTypeShorted, docRegion, postfix);\n\n const url = `${this.mrzServiceURL}/extract_mrz_text/?doc_type=${docTypeShorted}&doc_region=${docRegion}&postfix=${postfix}&template_path=${template_path}&mrz_type=${mrz_type}`;\n logger.log(\"url\", url);\n\n const attempt = async () => {\n try {\n const res = await axios.post<ExtractMrzTextResponse>(url, formData, {\n headers: { 'Content-Type': 'multipart/form-data', 'Authorization': `Bearer ${token}`, },\n timeout: 60000,\n });\n logger.log('extractMrzText res', JSON.stringify(res.data, null, 2));\n //check if res.data has aleast one key\n if (Object.keys(res.data).length === 0) throw new Error('No data found');\n if (res.data?.success === false) throw new Error(res.data.parsed_data.status);\n return res.data;\n } catch (e: any) {\n throw new Error(e?.message || 'Erreur de détection du MRZ');\n }\n };\n try {\n return await attempt();\n } catch (e) {\n logger.error('Error extracting MRZ text:', JSON.stringify(errorMessage(e), null, 2));\n throw e;\n }\n }\n\n // STEP 2 - SELFIE VALIDATION\n async recognizeFace(params: { idPhotoUri: string; selfiePhotoUri: string }): Promise<{ is_match: boolean; similarity: number; id_bbox?: number[]; selfie_bbox?: number[] }> {\n const { idPhotoUri, selfiePhotoUri } = params;\n const formData = new FormData();\n const idFile: any = { uri: idPhotoUri, type: 'image/jpeg', name: 'id_card_photo.jpg' };\n const selfieFile: any = { uri: selfiePhotoUri, type: 'image/jpeg', name: 'selfie_final.jpg' };\n formData.append('id_photo', idFile);\n formData.append('selfie_photo', selfieFile);\n\n const res = await axios.post(`${this.faceServiceURL}/recognize_face/`, formData, { timeout: 45000 });\n if (res.data?.detail) throw new Error(res.data.detail);\n return res.data;\n }\n\n // HEALTH CHECKS\n async healthFaceDetection(): Promise<any> {\n const res = await axios.get(`${this.faceServiceURL}/health`);\n return res.data;\n }\n\n async healthTextExtraction(): Promise<any> {\n const res = await axios.get(`${this.textExtractionServiceURL}/health`);\n return res.data;\n }\n\n async healthMrzService(): Promise<any> {\n const res = await axios.get(`${this.mrzServiceURL}/health`);\n return res.data;\n }\n\n async healthOrientationService(): Promise<any> {\n const res = await axios.get(`${this.orientationServiceURL}/health`);\n return res.data;\n }\n\n async newSession(token: string): Promise<SessionResponse> {\n try {\n const data = {\n \"status\": \"PENDING\",\n \"metadata\": {},\n }\n const res = await axios.post<SessionResponse>(`${this.backendServiceURL}/verification/sessions/`,\n data, { headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` } });\n return res.data;\n } catch (error: any) {\n logger.error('Error creating session:', JSON.stringify(errorMessage(error), null, 2));\n\n // Extract backend error message if available\n const backendMessage = errorMessage(error);\n\n if (backendMessage) {\n logger.error('Backend error message:', JSON.stringify(truncateFields(backendMessage), null, 2));\n throw new Error(`Backend error: ${JSON.stringify(truncateFields(backendMessage))}`);\n }\n\n throw error;\n }\n }\n\n async verificationSession(payload: VerificationSessionRequest): Promise<any> {\n\n try {\n\n const token = await authentification();\n\n // /api/v1/verification/api/kyc/sessions/{session_id}/steps/{step}/\n const { session_id, step, data, templateId, action } = payload;\n // const session_id = \"kyc-8b4e069258d8\";\n const payloadData = {\n action: action,\n data: {\n step,\n templateId,\n ...(action === \"location_permission\" ? { permissionGranted: true, } : {}),\n ...data,\n },\n ...({ session_id: session_id }),\n timestamp: new Date().toISOString()\n }\n const url = `${this.backendServiceURL}/verification/api/kyc/sessions/${session_id}/steps/${step}/`;\n\n\n const logPayload = truncateFields({ payloadData, session_id, step });\n logger.log('verificationSession payload',\n JSON.stringify(truncateFields({ logPayload, token, path: url }),\n null, 2))\n\n const res = await axios.post<SessionResponse>(url,\n payloadData,\n {\n headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` }\n });\n logger.log('verificationSession res', JSON.stringify(truncateFields(res.data), null, 2));\n return res.data;\n\n\n } catch (error) {\n logger.error('Error validating component:', JSON.stringify(errorMessage(error), null, 2));\n throw new Error(errorMessage(error));\n }\n }\n // reultat de la verification\n async getVerificationResult(session_id: string): Promise<VerificationResult> {\n const token = await authentification();\n const url = `${this.backendServiceURL}/verification/api/kyc/result/?session_id=${session_id}`;\n const res = await axios.get<VerificationResult>(url,\n { headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` } });\n logger.log('getVerificationResult res', JSON.stringify(truncateFields(res.data), null, 2));\n return res.data;\n }\n}\n\n\nconst kycService = new KYCService(\"\", \"\");\nexport default kycService;\n\n\n// Pour éviter d'afficher des champs trop longs, on tronque les valeurs longues dans le log\nexport function truncateFields(obj: any, maxLength = 420): any {\n if (typeof obj !== 'object' || obj === null) return obj;\n if (Array.isArray(obj)) return obj.map(item => truncateFields(item, maxLength));\n const truncated: any = {};\n for (const key in obj) {\n if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;\n const value = obj[key];\n if (typeof value === 'string' && value.length > maxLength) {\n truncated[key] = value.slice(0, maxLength) + '... [truncated]';\n } else if (typeof value === 'object' && value !== null) {\n truncated[key] = truncateFields(value, maxLength);\n } else {\n truncated[key] = value;\n }\n }\n return truncated;\n}\nexport const authentification = async () => {\n try {\n const params = new URLSearchParams();\n params.append('client_id', 'kyc_frontend');\n params.append('client_secret', 'ZCW4mGaJXWR0UuI40lM1pHNQmYLw2xvX');\n params.append('grant_type', 'client_credentials');\n const res = await axios.post(`https://keycloak.transfergratis.net/realms/kyc/protocol/openid-connect/token`,\n params,\n {\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n }\n );\n logger.log('authentification res', JSON.stringify(truncateFields(res.data)));\n return res.data.access_token;\n } catch (error: any) {\n logger.error('Error authentifying:', {\n message: error.message,\n status: error.response?.status,\n statusText: error.response?.statusText,\n data: error.response?.data,\n url: error.config?.url,\n method: error.config?.method\n });\n\n // Extract backend error message if available\n const backendMessage = errorMessage(error);\n\n if (backendMessage) {\n logger.error('Backend authentication error:', JSON.stringify(truncateFields(backendMessage), null, 2));\n throw new Error(`Authentication failed: ${JSON.stringify(truncateFields(backendMessage))}`);\n }\n\n throw error;\n }\n}\n\n\n\nexport const errorMessage = (error: any) => {\n return error.response?.data?.message ||\n error.response?.data?.detail ||\n error.response?.data?.error ||\n error.response?.data;\n}"]}
@@ -28,10 +28,16 @@ export interface VerificationResult {
28
28
  full_name: string;
29
29
  first_name: string | null;
30
30
  last_name: string | null;
31
- date_of_birth: string | null;
32
- nationality: string | null;
33
- gender: string | null;
31
+ date_of_birth: string;
32
+ sex: string;
33
+ expiry_date: string;
34
+ issue_date: string;
35
+ issue_place: string | null;
34
36
  place_of_birth: string | null;
37
+ address: string | null;
38
+ city: string | null;
39
+ postal_code: string | null;
40
+ country: string | null;
35
41
  };
36
42
  };
37
43
  selfie_info: {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/modules/api/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAClB;AAGD,MAAM,WAAW,0BAA0B;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,uBAAuB,CAAC;IAC9B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAA;CACjB;AAID,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAG1D,MAAM,WAAW,kBAAkB;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG;QACX,IAAI,EAAE;YACF,eAAe,EAAE,MAAM,CAAC;YACxB,mBAAmB,EAAE,MAAM,CAAC;YAC5B,oBAAo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,GAAG;QACX,IAAI,EAAE;YACF,eAAe,EAAE,MAAM,CAAC;YACxB,mBAAmB,EAAE,MAAM,CAAC;YAC5B,oBAAoB,EAAE,MAAM,CAAC;YAC7B,SAAS,EAAE;gBACP,oBAAoB,EAAE;oBAClB,SAAS,EAAE,MAAM,CAAC;oBAClB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;oBAC1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;oBACzB,aAAa,EAAE,MAAM,CAAC;oBACtB,GAAG,EAAE,MAAM,CAAC;oBACZ,WAAW,EAAE,MAAM,CAAE;oBACrB,UAAU,EAAE,MAAM,CAAC;oBACnB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;oBAC3B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;oBAC9B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;oBACvB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;oBACpB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;oBAC3B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;iBAC1B,CAAC;aACL,CAAC;YACF,WAAW,EAAE;gBACT,QAAQ,EAAE,OAAO,CAAC;gBAClB,UAAU,EAAE,MAAM,CAAC;gBACnB,KAAK,EAAE,MAAM,CAAC;aACjB,CAAC;SACL,CAAC;KACL,CAAC;CACL"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/modules/api/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface SessionResponse {\n id: number;\n session_id: string;\n status: string;\n created_at: string;\n updated_at: string;\n metadata: string;\n user: number;\n module: number;\n}\n\n\nexport interface VerificationSessionRequest {\n step: number;\n data: VerificationSessionData;\n templateId: string | null;\n session_id: string;\n token: string;\n action: string\n}\n\n\n// dynamic type\nexport type VerificationSessionData = Record<string, any>;\n\n\nexport interface VerificationResult {\n [key: string]: {\n data: {\n verification_id: string;\n verification_status: string;\n completion_timestamp: string;\n user_data: {\n personal_information: {\n full_name: string;\n first_name: string | null;\n last_name: string | null;\n date_of_birth: string | null;\n nationality: string | null;\n gender: string | null;\n place_of_birth: string | null;\n };\n };\n selfie_info: {\n is_match: boolean;\n similarity: number;\n image: string;\n };\n };\n };\n}"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/modules/api/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface SessionResponse {\n id: number;\n session_id: string;\n status: string;\n created_at: string;\n updated_at: string;\n metadata: string;\n user: number;\n module: number;\n}\n\n\nexport interface VerificationSessionRequest {\n step: number;\n data: VerificationSessionData;\n templateId: string | null;\n session_id: string;\n token: string;\n action: string\n}\n\n\n// dynamic type\nexport type VerificationSessionData = Record<string, any>;\n\n\nexport interface VerificationResult {\n [key: string]: {\n data: {\n verification_id: string;\n verification_status: string;\n completion_timestamp: string;\n user_data: {\n personal_information: {\n full_name: string;\n first_name: string | null;\n last_name: string | null;\n date_of_birth: string;\n sex: string;\n expiry_date: string ;\n issue_date: string;\n issue_place: string | null;\n place_of_birth: string | null;\n address: string | null;\n city: string | null;\n postal_code: string | null;\n country: string | null;\n };\n };\n selfie_info: {\n is_match: boolean;\n similarity: number;\n image: string;\n };\n };\n };\n}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transfergratis/react-native-sdk",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "transfergratis react native sdk",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -1,7 +1,7 @@
1
1
  import React, { useCallback, useEffect, useMemo, useState } from 'react';
2
2
  import { View, Text, TouchableOpacity, StyleSheet, Image, Alert, ScrollView, Dimensions } from 'react-native';
3
3
  import { EnhancedCameraView } from '../EnhancedCameraView';
4
- import { TemplateComponent, IDCardConfig, LocalizedText, GovernmentDocumentType, ISilentCaptureResult } from '../../types/KYC.types';
4
+ import { TemplateComponent, IDCardConfig, LocalizedText, GovernmentDocumentType, ISilentCaptureResult, IBbox } from '../../types/KYC.types';
5
5
  import IdCardOverlay from '../OverLay/IdCard';
6
6
  import { useTemplateKYCFlowContext } from '../../hooks/useTemplateKYCFlow';
7
7
  import { useI18n } from '../../hooks/useI18n';
@@ -10,8 +10,8 @@ import { removeDuplicates } from '../../utils/remove-duplicate';
10
10
  import { backVerification, checkTemplateType, frontVerification } from '../../modules/api/CardAuthentification';
11
11
  import { getDocumentTypeInfo } from '../../utils/get-document-type-info';
12
12
  import pathToBase64 from '../../utils/pathToBase64';
13
- import { truncateFields } from '../../modules/api/KYCService';
14
- import { cropImageWithBBox } from '../../utils/cropByObb';
13
+ import { truncateFields } from '../../modules/api/KYCService';
14
+ import { cropByObb, cropImageWithBBox } from '../../utils/cropByObb';
15
15
  import { logger } from '../../utils/logger';
16
16
 
17
17
 
@@ -37,11 +37,13 @@ export const IDCardCapture: React.FC<IDCardCaptureProps> = ({
37
37
  error,
38
38
  language = 'en',
39
39
  }) => {
40
- const { t , locale} = useI18n();
40
+ const { t, locale } = useI18n();
41
41
  const [showCamera, setShowCamera] = useState(false);
42
42
  const [capturedImages, setCapturedImages] = useState<Record<string, IIDCardPayload>>(value || {});
43
43
  const [cropImageUri, setCropImageUri] = useState<string>('');
44
44
  const [currentSide, setCurrentSide] = useState<string>('front');
45
+ // Stocker les bbox par côté pour pouvoir restaurer les images croppées
46
+ const [bboxBySide, setBboxBySide] = useState<Record<string, IBbox>>({});
45
47
  const [selectedDocumentType, setSelectedDocumentType] = useState<{
46
48
  type: GovernmentDocumentType;
47
49
  region: string;
@@ -205,16 +207,30 @@ export const IDCardCapture: React.FC<IDCardCaptureProps> = ({
205
207
  if (result.success && result.path) {
206
208
  setSilentCaptureResult((prev) => ({ ...prev, isAnalyzing: true, success: false, error: '' }));
207
209
  let templatePath = silentCaptureResult.templatePath || '';
210
+ let templateBbox: IBbox | undefined;
208
211
 
209
212
  const regionMappings = getCurrentSideVerification(currentSide)
210
213
  // logger.log("regionMappings", JSON.stringify(truncateFields({regionMappings, templatePath}), null, 2));
211
214
  if (regionMappings.authMethod.includes('MRZ') && templatePath.length === 0) {
212
- const templateType = await checkTemplateType({ path: result.path || '', docType: selectedDocumentType?.type as GovernmentDocumentType, docRegion: countryData?.code || "", postfix: currentSide });
215
+ try {
216
+ const templateType = await checkTemplateType({ path: result.path || '', docType: selectedDocumentType?.type as GovernmentDocumentType, docRegion: countryData?.code || "", postfix: currentSide });
213
217
 
214
- if (templateType.template_path) {
215
- templatePath = templateType.template_path;
216
- logger.log("templatePath", templatePath);
217
- setSilentCaptureResult((prev) => ({ ...prev, templatePath: templatePath }));
218
+ if (templateType.template_path) {
219
+ templatePath = templateType.template_path;
220
+ logger.log("templatePath", templatePath);
221
+ setSilentCaptureResult((prev) => ({ ...prev, templatePath: templatePath }));
222
+ }
223
+ if (templateType.card_obb) {
224
+ let bbox: IBbox | undefined;
225
+ try {
226
+ const crop = await cropByObb(result?.path || '', (templateType as any).card_obb);
227
+ bbox = crop.bbox;
228
+ templateBbox = bbox;
229
+ } catch { }
230
+ }
231
+ } catch (e: any) {
232
+ logger.log("error checking template type", truncateFields(e));
233
+ setSilentCaptureResult((prev) => ({ ...prev, isAnalyzing: false, success: false, error: e?.message || 'Erreur de vérification du template' }));
218
234
  }
219
235
  }
220
236
  if (currentSide === 'front') {
@@ -230,15 +246,20 @@ export const IDCardCapture: React.FC<IDCardCaptureProps> = ({
230
246
  mrzType: getCorrespondingMrzType(templatePath, regionMappings.regionMapping, regionMappings.key || '') || '',
231
247
  }).then((mrz) => {
232
248
  logger.log("front verification result", truncateFields(mrz));
249
+ const bbox = (mrz as any)?.bbox || templateBbox;
233
250
  setSilentCaptureResult((prev) => ({
234
251
  ...prev, path: result.path,
235
- bbox: (mrz as any)?.bbox, success: true,
252
+ bbox: bbox, success: true,
236
253
  mrz: JSON.stringify(mrz), isAnalyzing: false,
237
254
  country: countryData?.code,
238
255
  documentType: selectedDocumentType?.type,
239
256
  templatePath: "",
240
257
  }),
241
258
  );
259
+ // Stocker le bbox pour ce côté
260
+ if (bbox && typeof bbox === 'object') {
261
+ setBboxBySide((prev) => ({ ...prev, [currentSide]: bbox }));
262
+ }
242
263
 
243
264
  }).catch((e: any) => {
244
265
  logger.log("error front verification", truncateFields(e));
@@ -256,13 +277,18 @@ export const IDCardCapture: React.FC<IDCardCaptureProps> = ({
256
277
  mrzType: getCorrespondingMrzType(templatePath, regionMappings.regionMapping, regionMappings.key || '') || '',
257
278
  }).then((mrz) => {
258
279
  logger.log("back verification result", truncateFields(mrz));
280
+ const bbox = (mrz as any)?.bbox || templateBbox;
259
281
  setSilentCaptureResult((prev) => ({
260
- ...prev, path: result.path, bbox: (mrz as any)?.bbox,
282
+ ...prev, path: result.path, bbox: bbox,
261
283
  success: true, mrz: JSON.stringify(mrz), isAnalyzing: false,
262
284
  country: countryData?.code,
263
285
  documentType: selectedDocumentType?.type,
264
286
  templatePath: "",
265
287
  }));
288
+ // Stocker le bbox pour ce côté
289
+ if (bbox && typeof bbox === 'object') {
290
+ setBboxBySide((prev) => ({ ...prev, [currentSide]: bbox }));
291
+ }
266
292
  }).catch((e: any) => {
267
293
  logger.log("error back verification", truncateFields(e));
268
294
  setSilentCaptureResult((prev) => ({ ...prev, isAnalyzing: false, templatePath: templatePath, success: false, error: e?.message || 'Erreur de détection du MRZ' }));
@@ -460,7 +486,26 @@ export const IDCardCapture: React.FC<IDCardCaptureProps> = ({
460
486
  documentSelection: false,
461
487
  regionSelection: false
462
488
  });
463
- setSilentCaptureResult((prev) => ({ path: '', success: false, isAnalyzing: false, error: '' }));
489
+ // Si une image front existe, on la restaure pour l'afficher
490
+ if (capturedImages['front']?.dir) {
491
+ // Restaurer l'état de capture du front pour afficher l'image
492
+ const frontImage = capturedImages['front'];
493
+ const frontBbox = bboxBySide['front'];
494
+ setSilentCaptureResult((prev) => ({
495
+ path: frontImage.dir,
496
+ success: true,
497
+ isAnalyzing: false,
498
+ error: '',
499
+ mrz: frontImage.mrz || '',
500
+ country: silentCaptureResult.country,
501
+ documentType: silentCaptureResult.documentType,
502
+ bbox: frontBbox // Restaurer le bbox pour recalculer le cropImageUri
503
+ }));
504
+ // Le useEffect va automatiquement recalculer le cropImageUri si bbox existe
505
+ } else {
506
+ // Pas d'image front, on réinitialise
507
+ setSilentCaptureResult((prev) => ({ path: '', success: false, isAnalyzing: false, error: '' }));
508
+ }
464
509
  } else {
465
510
  setShowDocumentSelection({
466
511
  documentSelection: true,
@@ -141,7 +141,7 @@ const IdCardOverlay = ({ xMin: xMinProps, yMin: yMinProps, xMax: xMaxProps, yMax
141
141
 
142
142
  <View style={styles.bottomIntruction}>
143
143
  <Text style={styles.bottomTitle}>
144
- {language === "en" ? "Scan the ${stepperProps?.side === 'front' ? 'front' : 'back'} side of your ${stepperProps?.selectedDocumentType}.":`Scanner de la face ${stepperProps?.side === 'front' ? 'avant' : 'arrière'} de votre ${stepperProps?.selectedDocumentType}.`}
144
+ {language === "en" ? `Scan the ${stepperProps?.side === 'front' ? 'front' : 'back'} side of your ${stepperProps?.selectedDocumentType}.`:`Scanner de la face ${stepperProps?.side === 'front' ? 'avant' : 'arrière'} de votre ${stepperProps?.selectedDocumentType}.`}
145
145
 
146
146
  </Text>
147
147
  <Text style={styles.bottomSubtitle}>
@@ -3,7 +3,7 @@ import { cropByObb } from "../../utils/cropByObb";
3
3
  import { GovernmentDocumentType, IBbox } from "../../types/KYC.types";
4
4
  import { logger } from "../../utils/logger";
5
5
 
6
- export async function frontVerification(result: { path?: string, regionMapping: { authMethod: string[], mrzTypes: string[] }, selectedDocumentType: string, code: string, currentSide: string, templatePath?: string,mrzType?: string }) {
6
+ export async function frontVerification(result: { path?: string, regionMapping: { authMethod: string[], mrzTypes: string[] }, selectedDocumentType: string, code: string, currentSide: string, templatePath?: string, mrzType?: string }) {
7
7
  try {
8
8
 
9
9
  logger.log("Front verification", JSON.stringify({ result }, null, 2));
@@ -25,19 +25,19 @@ export async function frontVerification(result: { path?: string, regionMapping:
25
25
  } catch { }
26
26
 
27
27
  if (result.regionMapping.authMethod.length > 0 && result.regionMapping.authMethod.includes('MRZ')) {
28
-
29
-
30
- mrz = await kycService.extractMrzText(
31
- {
32
- fileUri: result.path || '',
33
- docType: result?.selectedDocumentType || '',
34
- docRegion: result?.code || "",
35
- postfix: result?.currentSide,
36
- token: token,
37
- template_path: result?.templatePath || '',
38
- mrz_type: result?.mrzType || ''
39
- })
40
-
28
+
29
+
30
+ mrz = await kycService.extractMrzText(
31
+ {
32
+ fileUri: result.path || '',
33
+ docType: result?.selectedDocumentType || '',
34
+ docRegion: result?.code || "",
35
+ postfix: result?.currentSide,
36
+ token: token,
37
+ template_path: result?.templatePath || '',
38
+ mrz_type: result?.mrzType || ''
39
+ })
40
+
41
41
  }
42
42
 
43
43
  return { ...detected, croppedBase64, bbox, ...(mrz ? { mrz } : {}) };
@@ -47,7 +47,7 @@ export async function frontVerification(result: { path?: string, regionMapping:
47
47
  }
48
48
  }
49
49
 
50
- export async function backVerification(result: { path?: string, regionMapping: { authMethod: string[], mrzTypes: string[] }, selectedDocumentType: string, code: string, currentSide: string, templatePath?: string,mrzType?: string }) {
50
+ export async function backVerification(result: { path?: string, regionMapping: { authMethod: string[], mrzTypes: string[] }, selectedDocumentType: string, code: string, currentSide: string, templatePath?: string, mrzType?: string }) {
51
51
  try {
52
52
  if (!result.path) throw new Error('No path provided');
53
53
  logger.log("result.regionMapping", result.regionMapping, result.currentSide, result.code);
@@ -58,18 +58,27 @@ export async function backVerification(result: { path?: string, regionMapping: {
58
58
  // Fonction helper pour essayer MRZ puis barcode en fallback
59
59
  const tryMrzWithBarcodeFallback = async () => {
60
60
  try {
61
-
62
- logger.log("Tentative d'extraction MRZ");
63
- await kycService.extractMrzText({
64
- fileUri: result.path!,
65
- docType: result?.selectedDocumentType || '',
66
- docRegion: result?.code || '',
67
- postfix: 'back',
68
- token: token,
69
- template_path: result?.templatePath || '',
70
- mrz_type: result?.mrzType || ''
71
- });
72
-
61
+
62
+ logger.log("Tentative d'extraction MRZ");
63
+ const mrz = await kycService.extractMrzText({
64
+ fileUri: result.path!,
65
+ docType: result?.selectedDocumentType || '',
66
+ docRegion: result?.code || '',
67
+ postfix: 'back',
68
+ token: token,
69
+ template_path: result?.templatePath || '',
70
+ mrz_type: result?.mrzType || ''
71
+ });
72
+ let bbox: IBbox | undefined;
73
+ let croppedBase64: string | undefined;
74
+
75
+ try {
76
+ const crop = await cropByObb(result?.path || '', (mrz as any).card_obb);
77
+ bbox = crop.bbox;
78
+ croppedBase64 = crop.base64;
79
+
80
+ } catch { }
81
+ return { ...mrz, bbox, croppedBase64 }
73
82
  } catch (mrzError: any) {
74
83
  logger.log("MRZ échoué, tentative d'extraction barcode");
75
84
  try {
@@ -89,17 +98,17 @@ export async function backVerification(result: { path?: string, regionMapping: {
89
98
 
90
99
  if (result.regionMapping.authMethod.length > 0 && result.regionMapping.authMethod.includes('MRZ') && result?.mrzType && result?.mrzType.length > 0) {
91
100
  try {
92
-
101
+
93
102
  let mrz: any | undefined;
94
- mrz = await kycService.extractMrzText({
95
- fileUri: result.path!,
96
- docType: result?.selectedDocumentType || '',
97
- docRegion: result?.code || '',
98
- postfix: 'back',
99
- token: token,
100
- template_path: result?.templatePath || '',
101
- mrz_type: result?.mrzType || ''
102
- });
103
+ mrz = await kycService.extractMrzText({
104
+ fileUri: result.path!,
105
+ docType: result?.selectedDocumentType || '',
106
+ docRegion: result?.code || '',
107
+ postfix: 'back',
108
+ token: token,
109
+ template_path: result?.templatePath || '',
110
+ mrz_type: result?.mrzType || ''
111
+ });
103
112
  let bbox: IBbox | undefined;
104
113
  try {
105
114
  const crop = await cropByObb(result?.path || '', (mrz as any).card_obb);
@@ -234,7 +234,7 @@ export class KYCService {
234
234
  headers: { 'Content-Type': 'multipart/form-data', 'Authorization': `Bearer ${token}`, },
235
235
  timeout: 60000,
236
236
  });
237
- logger.log('checkTemplateType res', JSON.stringify(res.data));
237
+ logger.log('checkTemplateType res', JSON.stringify(res.data, null, 2));
238
238
  return res.data;
239
239
  } catch (e: any) {
240
240
  logger.error('Error checking template type:', JSON.stringify(e));
@@ -283,7 +283,7 @@ export class KYCService {
283
283
  headers: { 'Content-Type': 'multipart/form-data', 'Authorization': `Bearer ${token}`, },
284
284
  timeout: 60000,
285
285
  });
286
- logger.log('extractBarcode res', JSON.stringify(res.data));
286
+ logger.log('extractBarcode res', JSON.stringify(res.data, null, 2));
287
287
  //check if res.data has aleast one key
288
288
  if (Object.keys(res.data).length === 0) throw new Error('No data found');
289
289
  return res.data;
@@ -316,7 +316,7 @@ export class KYCService {
316
316
  headers: { 'Content-Type': 'multipart/form-data', 'Authorization': `Bearer ${token}`, },
317
317
  timeout: 60000,
318
318
  });
319
- logger.log('extractMrzText res', JSON.stringify(res.data));
319
+ logger.log('extractMrzText res', JSON.stringify(res.data, null, 2));
320
320
  //check if res.data has aleast one key
321
321
  if (Object.keys(res.data).length === 0) throw new Error('No data found');
322
322
  if (res.data?.success === false) throw new Error(res.data.parsed_data.status);
@@ -35,10 +35,16 @@ export interface VerificationResult {
35
35
  full_name: string;
36
36
  first_name: string | null;
37
37
  last_name: string | null;
38
- date_of_birth: string | null;
39
- nationality: string | null;
40
- gender: string | null;
38
+ date_of_birth: string;
39
+ sex: string;
40
+ expiry_date: string ;
41
+ issue_date: string;
42
+ issue_place: string | null;
41
43
  place_of_birth: string | null;
44
+ address: string | null;
45
+ city: string | null;
46
+ postal_code: string | null;
47
+ country: string | null;
42
48
  };
43
49
  };
44
50
  selfie_info: {