@transfergratis/react-native-sdk 0.1.17 → 0.1.19
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/README.md +17 -617
- package/android/build.gradle +1 -1
- package/build/components/KYCElements/IDCardCapture.js +3 -3
- package/build/components/KYCElements/IDCardCapture.js.map +1 -1
- package/build/components/KYCElements/VerificationProgressTemplate.js +3 -3
- package/build/components/KYCElements/VerificationProgressTemplate.js.map +1 -1
- package/build/components/TemplateKYCExample.d.ts +1 -1
- package/build/components/TemplateKYCExample.d.ts.map +1 -1
- package/build/components/TemplateKYCExample.js +5 -8
- package/build/components/TemplateKYCExample.js.map +1 -1
- package/build/components/TemplateKYCFlowRefactored.js +7 -2
- package/build/components/TemplateKYCFlowRefactored.js.map +1 -1
- package/build/hooks/useTemplateKYCFlow.d.ts.map +1 -1
- package/build/hooks/useTemplateKYCFlow.js +3 -2
- package/build/hooks/useTemplateKYCFlow.js.map +1 -1
- package/build/index.d.ts +1 -31
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -41
- package/build/index.js.map +1 -1
- package/build/modules/api/KYCService.d.ts.map +1 -1
- package/build/modules/api/KYCService.js +15 -9
- package/build/modules/api/KYCService.js.map +1 -1
- package/build/modules/api/types.d.ts +1 -0
- package/build/modules/api/types.d.ts.map +1 -1
- package/build/modules/api/types.js.map +1 -1
- package/build/utils/cropByObb.js +3 -3
- package/build/utils/cropByObb.js.map +1 -1
- package/package.json +1 -1
- package/src/components/KYCElements/IDCardCapture.tsx +8 -8
- package/src/components/KYCElements/VerificationProgressTemplate.tsx +10 -10
- package/src/components/TemplateKYCExample.tsx +7 -9
- package/src/components/TemplateKYCFlowRefactored.tsx +10 -3
- package/src/hooks/useTemplateKYCFlow.tsx +4 -3
- package/src/index.ts +2 -66
- package/src/modules/api/KYCService.ts +17 -11
- package/src/modules/api/types.ts +1 -0
- package/src/utils/cropByObb.ts +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
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C,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}"]}
|
|
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;IAC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E3C,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 const url = `${this.mrzServiceURL}/get_template_version/?doc_type=${encodeURIComponent(docTypeShorted)}&doc_region=${encodeURIComponent(docRegion)}&postfix=${postfix}`;\n\n logger.log('checkTemplateType params', this.mrzServiceURL, JSON.stringify({ fileUri, docTypeShorted, docRegion, token, postfix, url }, null, 2));\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 \n // /api/v1/verification/api/kyc/sessions/{session_id}/steps/{step}/\n const { session_id, step, data, templateId, action, apiKey } = payload;\n\n const token = apiKey ? undefined : await authentification();\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', ...(this.apiKey ? { 'Authorization': `ApiKey ${this.apiKey}` } : { '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 try {\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 } catch (error) {\n logger.error('Error getting verification result:', JSON.stringify(errorMessage(error), null, 2));\n throw error;\n }\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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/modules/api/types.ts"],"names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AG,EAAE,MAAM,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;\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}"]}
|
|
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 apiKey?: 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/build/utils/cropByObb.js
CHANGED
|
@@ -66,9 +66,9 @@ export async function cropImageWithBBox(uri, bbox) {
|
|
|
66
66
|
// 3️⃣ Convertir le bbox à la taille réelle scale 0.10 = 10%
|
|
67
67
|
const crop = {
|
|
68
68
|
originX: bbox.minX,
|
|
69
|
-
originY: bbox.minY
|
|
70
|
-
width: bbox.width
|
|
71
|
-
height: bbox.height
|
|
69
|
+
originY: bbox.minY,
|
|
70
|
+
width: bbox.width,
|
|
71
|
+
height: bbox.height,
|
|
72
72
|
};
|
|
73
73
|
// 4️⃣ Appliquer le crop
|
|
74
74
|
const result = await ImageManipulator.manipulateAsync(uri, [{ crop }], { compress: 1, format: ImageManipulator.SaveFormat.PNG });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cropByObb.js","sourceRoot":"","sources":["../../src/utils/cropByObb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,KAAK,gBAAgB,MAAM,wBAAwB,CAAC;AAI3D,gEAAgE;AAChE,SAAS,WAAW,CAAC,MAAe;IAClC,MAAM,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACjC,MAAM,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACjC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;IAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;IAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;IAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;IAC7B,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,EAAE,MAAM,EAAE,IAAI,GAAG,IAAI,EAAE,CAAC;AAC7E,CAAC;AAED,uDAAuD;AACvD,KAAK,UAAU,OAAO,CAAC,GAAW,EAAE,MAAe;IACjD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;QACxB,GAAG,CAAC,WAAW,GAAG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AO,EAAE,IAAI,CAAC,IAAI;QAClB,OAAO,EAAE,IAAI,CAAC,IAAI;QAClB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,MAAM,EAAE,IAAI,CAAC,MAAM;KACpB,CAAC;IAEF,wBAAwB;IACxB,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,eAAe,CACnD,GAAG,EACH,CAAC,EAAE,IAAI,EAAE,CAAC,EACV,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,gBAAgB,CAAC,UAAU,CAAC,GAAG,EAAE,CACzD,CAAC;IAEF,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAC3C,OAAO,MAAM,CAAC,GAAG,CAAC;AACpB,CAAC","sourcesContent":["import { Image as RNImage, Platform } from 'react-native';\nimport * as ImageManipulator from \"expo-image-manipulator\";\n\ntype Point = [number, number];\n\n// Compute axis-aligned bounding box from oriented quadrilateral\nfunction computeAabb(points: Point[]) {\n const xs = points.map(p => p[0]);\n const ys = points.map(p => p[1]);\n const minX = Math.min(...xs);\n const minY = Math.min(...ys);\n const maxX = Math.max(...xs);\n const maxY = Math.max(...ys);\n return { minX, minY, maxX, maxY, width: maxX - minX, height: maxY - minY };\n}\n\n// Web-only crop using Canvas; returns dataURL (base64)\nasync function cropWeb(uri: string, points: Point[]): Promise<string> {\n return new Promise((resolve, reject) => {\n const img = new Image();\n img.crossOrigin = 'anonymous';\n img.onload = () => {\n const { minX, minY, width, height } = computeAabb(points);\n const canvas = document.createElement('canvas');\n canvas.width = Math.max(1, Math.round(width));\n canvas.height = Math.max(1, Math.round(height));\n const ctx = canvas.getContext('2d');\n if (!ctx) return reject(new Error('Canvas context not available'));\n ctx.drawImage(\n img,\n minX, // sx\n minY, // sy\n width, // sw\n height, // sh\n 0,\n 0,\n canvas.width,\n canvas.height\n );\n resolve(canvas.toDataURL('image/jpeg', 0.92));\n };\n img.onerror = (e) => reject(e);\n img.src = uri;\n });\n}\n\n// Fallback: return original for native (no dependency added); caller can still use bbox to draw overlay\nexport async function cropByObb(uri: string, cardObb: any): Promise<{ base64?: string; bbox?: { minX: number; minY: number; width: number; height: number } }> {\n try {\n // card_obb format: [ [ [p1,p2,p3,p4], score ] ]\n const first = Array.isArray(cardObb) ? cardObb[0] : null;\n const points = Array.isArray(first?.[0]) ? (first[0] as Point[]) : null;\n if (!points || points.length !== 4) return {};\n\n const { minX, minY, width, height } = computeAabb(points);\n\n if (Platform.OS === 'web') {\n const base64 = await cropWeb(uri, points);\n return { base64, bbox: { minX, minY, width, height } };\n }\n // Native: return bbox only; keep base64 undefined\n return { bbox: { minX, minY, width, height } };\n } catch (e) {\n return {};\n }\n}\n\n\n\n\n// exemple d'appel :\nexport async function cropImageWithBBox(uri: string, bbox: any) {\n // 1️⃣ Récupère la taille originale de l'image\n await RNImage.getSize(uri, (width, height) => {\n console.log(\"Image originale:\", width, height);\n });\n\n // // 2️⃣ Suppose que ton bbox vient d'une image affichée dans `displayedSize`\n // const scaleX = originalWidth / displayedSize.width;\n // const scaleY = originalHeight / displayedSize.height;\n\n // 3️⃣ Convertir le bbox à la taille réelle scale 0.10 = 10%\n const crop = {\n originX: bbox.minX ,\n originY: bbox.minY ,\n width: bbox.width ,\n height: bbox.height,\n };\n\n // 4️⃣ Appliquer le crop\n const result = await ImageManipulator.manipulateAsync(\n uri,\n [{ crop }],\n { compress: 1, format: ImageManipulator.SaveFormat.PNG }\n );\n\n console.log(\"Image recadrée:\", result.uri);\n return result.uri;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -139,7 +139,7 @@ export const IDCardCapture: React.FC<IDCardCaptureProps> = ({
|
|
|
139
139
|
setShowCamera(true);
|
|
140
140
|
actions.showCustomStepper(false);
|
|
141
141
|
setCapturedImages({ ...capturedImages, [currentSide]: { dir: '', file: '', mrz: '' } });
|
|
142
|
-
setSilentCaptureResult((prev) => ({ path: '', success: false, isAnalyzing: false, error: '' }));
|
|
142
|
+
setSilentCaptureResult((prev) => ({ ...prev, path: '', success: false, isAnalyzing: false, error: '' }));
|
|
143
143
|
setCropImageUri('');
|
|
144
144
|
onValueChange({ ...value, [currentSide]: { dir: '', file: '', mrz: '' } });
|
|
145
145
|
};
|
|
@@ -212,7 +212,7 @@ export const IDCardCapture: React.FC<IDCardCaptureProps> = ({
|
|
|
212
212
|
|
|
213
213
|
const regionMappings = getCurrentSideVerification(currentSide)
|
|
214
214
|
// logger.log("regionMappings", JSON.stringify(truncateFields({regionMappings, templatePath}), null, 2));
|
|
215
|
-
if (
|
|
215
|
+
if (templatePath.length === 0) {
|
|
216
216
|
try {
|
|
217
217
|
const templateType = await checkTemplateType({ path: result.path || '', docType: selectedDocumentType?.type as GovernmentDocumentType, docRegion: countryData?.code || "", postfix: currentSide });
|
|
218
218
|
|
|
@@ -224,9 +224,9 @@ export const IDCardCapture: React.FC<IDCardCaptureProps> = ({
|
|
|
224
224
|
if (templateType.card_obb) {
|
|
225
225
|
let bbox: IBbox | undefined;
|
|
226
226
|
try {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
227
|
+
const crop = await cropByObb(result?.path || '', (templateType as any).card_obb);
|
|
228
|
+
bbox = crop.bbox;
|
|
229
|
+
templateBbox = bbox;
|
|
230
230
|
} catch { }
|
|
231
231
|
}
|
|
232
232
|
} catch (e: any) {
|
|
@@ -250,7 +250,7 @@ export const IDCardCapture: React.FC<IDCardCaptureProps> = ({
|
|
|
250
250
|
logger.log("front verification result", truncateFields(mrz));
|
|
251
251
|
const bbox = (mrz as any)?.bbox || templateBbox;
|
|
252
252
|
setSilentCaptureResult((prev) => ({
|
|
253
|
-
...prev,
|
|
253
|
+
...prev,
|
|
254
254
|
path: result.path,
|
|
255
255
|
templatePath: templatePath,
|
|
256
256
|
bbox: bbox, success: true,
|
|
@@ -286,7 +286,7 @@ export const IDCardCapture: React.FC<IDCardCaptureProps> = ({
|
|
|
286
286
|
success: true, mrz: JSON.stringify(mrz), isAnalyzing: false,
|
|
287
287
|
country: countryData?.code,
|
|
288
288
|
documentType: selectedDocumentType?.type,
|
|
289
|
-
|
|
289
|
+
|
|
290
290
|
}));
|
|
291
291
|
// Stocker le bbox pour ce côté
|
|
292
292
|
if (bbox && typeof bbox === 'object') {
|
|
@@ -345,7 +345,7 @@ export const IDCardCapture: React.FC<IDCardCaptureProps> = ({
|
|
|
345
345
|
const handleDocumentTypeSelection = (docType: GovernmentDocumentType) => {
|
|
346
346
|
setSelectedDocumentType({ type: docType, region: hasRegions(docType) ? '' : 'root' });
|
|
347
347
|
setSilentCaptureResult((prev) => ({ ...prev, templatePath: '', bbox: undefined, success: false, isAnalyzing: false, error: '', path: '', mrz: '', country: '', documentType: '' }));
|
|
348
|
-
setCapturedImages((prev) => ({
|
|
348
|
+
setCapturedImages((prev) => ({ front: { dir: '', file: '', mrz: '', templatePath: '' }, back: { dir: '', file: '', mrz: '', templatePath: '' } }));
|
|
349
349
|
};
|
|
350
350
|
const handleRegionSelection = (region: string) => {
|
|
351
351
|
setSelectedDocumentType((prev) => ({ ...prev, region: region }));
|
|
@@ -3,7 +3,7 @@ import { View, Text, StyleSheet, TouchableOpacity } from 'react-native';
|
|
|
3
3
|
import { TemplateComponent } from '../../types/KYC.types';
|
|
4
4
|
import { useTemplateKYCFlowContext } from '../../hooks/useTemplateKYCFlow';
|
|
5
5
|
import { useI18n } from '../../hooks/useI18n';
|
|
6
|
-
import kycService from '../../modules/api/KYCService';
|
|
6
|
+
import kycService, { errorMessage } from '../../modules/api/KYCService';
|
|
7
7
|
import { logger } from '../../utils/logger';
|
|
8
8
|
|
|
9
9
|
interface VerificationProgressTemplateProps {
|
|
@@ -30,7 +30,7 @@ export const VerificationProgressTemplate: React.FC<VerificationProgressTemplate
|
|
|
30
30
|
const getVerificationResult = async (currentRetryCount = 0, maxRetries = 40) => {
|
|
31
31
|
try {
|
|
32
32
|
logger.log(`Starting verification check (attempt ${currentRetryCount + 1}/${maxRetries + 1})`);
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
const result = await kycService.getVerificationResult(state.session.session_id);
|
|
35
35
|
const verificationResult = result[state.session.session_id].data;
|
|
36
36
|
|
|
@@ -42,7 +42,7 @@ export const VerificationProgressTemplate: React.FC<VerificationProgressTemplate
|
|
|
42
42
|
const nextRetryCount = currentRetryCount + 1;
|
|
43
43
|
setRetryCount(nextRetryCount);
|
|
44
44
|
setIsRetrying(true);
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
logger.log(`Verification still processing, retrying in 10s... (${nextRetryCount}/${maxRetries})`);
|
|
47
47
|
|
|
48
48
|
// Nettoyer le timeout précédent s'il existe
|
|
@@ -54,7 +54,7 @@ export const VerificationProgressTemplate: React.FC<VerificationProgressTemplate
|
|
|
54
54
|
const newTimeoutId = setTimeout(() => {
|
|
55
55
|
getVerificationResult(nextRetryCount, maxRetries);
|
|
56
56
|
}, 10000);
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
setTimeoutId(newTimeoutId);
|
|
59
59
|
return; // Sortir de la fonction pour éviter de traiter le résultat
|
|
60
60
|
} else {
|
|
@@ -87,25 +87,25 @@ export const VerificationProgressTemplate: React.FC<VerificationProgressTemplate
|
|
|
87
87
|
setIsRetrying(false);
|
|
88
88
|
|
|
89
89
|
} catch (error) {
|
|
90
|
-
logger.error('getVerificationResult error', error);
|
|
90
|
+
logger.error('getVerificationResult error', JSON.stringify(errorMessage(error), null, 2));
|
|
91
91
|
|
|
92
92
|
// En cas d'erreur, on peut aussi retry
|
|
93
93
|
if (currentRetryCount < maxRetries) {
|
|
94
94
|
const nextRetryCount = currentRetryCount + 1;
|
|
95
95
|
setRetryCount(nextRetryCount);
|
|
96
96
|
setIsRetrying(true);
|
|
97
|
-
|
|
98
|
-
logger.log(`Error occurred, retrying in 10s... (${nextRetryCount}/${maxRetries})`);
|
|
99
|
-
|
|
97
|
+
|
|
98
|
+
logger.log(`getVerificationResult Error occurred, retrying in 10s... (${nextRetryCount}/${maxRetries})`);
|
|
99
|
+
|
|
100
100
|
// Nettoyer le timeout précédent s'il existe
|
|
101
101
|
if (timeoutId) {
|
|
102
102
|
clearTimeout(timeoutId);
|
|
103
103
|
}
|
|
104
|
-
|
|
104
|
+
|
|
105
105
|
const newTimeoutId = setTimeout(() => {
|
|
106
106
|
getVerificationResult(nextRetryCount, maxRetries);
|
|
107
107
|
}, 10000);
|
|
108
|
-
|
|
108
|
+
|
|
109
109
|
setTimeoutId(newTimeoutId);
|
|
110
110
|
} else {
|
|
111
111
|
setIsRetrying(false);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { View,
|
|
2
|
+
import { View, SafeAreaView } from 'react-native';
|
|
3
3
|
import { TemplateKYCFlow } from './TemplateKYCFlowRefactored';
|
|
4
4
|
import { KYCTemplate, VerificationState } from '../types/KYC.types';
|
|
5
5
|
|
|
@@ -56,7 +56,7 @@ const advancedVerificationTemplate: KYCTemplate = {
|
|
|
56
56
|
buttonText: { en: "Confirm", fr: "Confirmer" }
|
|
57
57
|
},
|
|
58
58
|
config: {
|
|
59
|
-
allowed_countries: ["CM", "NG", "CI", "KE","GH"],
|
|
59
|
+
allowed_countries: ["CM", "NG", "CI", "KE", "GH"],
|
|
60
60
|
default_country: "CM",
|
|
61
61
|
required: true
|
|
62
62
|
} as const
|
|
@@ -224,7 +224,7 @@ const advancedVerificationTemplate: KYCTemplate = {
|
|
|
224
224
|
]
|
|
225
225
|
};
|
|
226
226
|
|
|
227
|
-
export const TemplateKYCExample: React.FC<{ onComplete: (data: VerificationState) => void, onCancel: () => void, onError: (error: string) => void, language: string, API_KEY: string }> = ({ onComplete, onCancel, onError, language, API_KEY }) => {
|
|
227
|
+
export const TemplateKYCExample: React.FC<{ onComplete: (data: VerificationState) => void, onCancel: () => void, onError: (error: string) => void, language: string, API_KEY: string|undefined }> = ({ onComplete, onCancel, onError, language, API_KEY }) => {
|
|
228
228
|
const handleComplete = (data: VerificationState) => {
|
|
229
229
|
console.log('KYC Template completed with data:', data);
|
|
230
230
|
onComplete(data);
|
|
@@ -242,7 +242,8 @@ export const TemplateKYCExample: React.FC<{ onComplete: (data: VerificationState
|
|
|
242
242
|
};
|
|
243
243
|
|
|
244
244
|
return (
|
|
245
|
-
<
|
|
245
|
+
<SafeAreaView style={{ flex: 1 , paddingVertical:25}}>
|
|
246
|
+
<View style={{ flex: 1 }}>
|
|
246
247
|
<TemplateKYCFlow
|
|
247
248
|
template={advancedVerificationTemplate}
|
|
248
249
|
onComplete={handleComplete}
|
|
@@ -252,11 +253,8 @@ export const TemplateKYCExample: React.FC<{ onComplete: (data: VerificationState
|
|
|
252
253
|
API_KEY={API_KEY}
|
|
253
254
|
/>
|
|
254
255
|
</View>
|
|
256
|
+
</SafeAreaView>
|
|
255
257
|
);
|
|
256
258
|
};
|
|
257
259
|
|
|
258
|
-
|
|
259
|
-
container: {
|
|
260
|
-
flex: 1,
|
|
261
|
-
},
|
|
262
|
-
});
|
|
260
|
+
|
|
@@ -30,7 +30,7 @@ export const TemplateKYCFlow: React.FC<TemplateKYCFlowProps> = ({
|
|
|
30
30
|
API_KEY,
|
|
31
31
|
}) => {
|
|
32
32
|
const { t } = useI18n();
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
const OnCancel = () => {
|
|
35
35
|
Alert.alert(
|
|
36
36
|
t('kyc.cancelConfirmation.title'),
|
|
@@ -130,7 +130,7 @@ const TemplateKYCFlowContent: React.FC<{ onCancel?: () => void }> = ({ onCancel
|
|
|
130
130
|
};
|
|
131
131
|
|
|
132
132
|
return (
|
|
133
|
-
<View style={{ flex: 1 }}>
|
|
133
|
+
<View style={{ flex: 1, position: 'relative' }}>
|
|
134
134
|
{state.isProcessing && (
|
|
135
135
|
<View style={styles.processingContainer}>
|
|
136
136
|
<Text style={styles.processingText}>{t('common.loading')}</Text>
|
|
@@ -169,6 +169,13 @@ const TemplateKYCFlowContent: React.FC<{ onCancel?: () => void }> = ({ onCancel
|
|
|
169
169
|
<View style={styles.content}>
|
|
170
170
|
{renderCurrentComponent()}
|
|
171
171
|
</View>
|
|
172
|
+
|
|
173
|
+
{state.isProcessing && (
|
|
174
|
+
<View style={styles.processingContainer}>
|
|
175
|
+
<Text style={styles.processingText}>{t('common.loading')}</Text>
|
|
176
|
+
<ActivityIndicator size="large" color="#fff" />
|
|
177
|
+
</View>
|
|
178
|
+
)}
|
|
172
179
|
</SafeAreaView>
|
|
173
180
|
</View>
|
|
174
181
|
|
|
@@ -300,7 +307,7 @@ const styles = StyleSheet.create({
|
|
|
300
307
|
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
301
308
|
justifyContent: 'center',
|
|
302
309
|
alignItems: 'center',
|
|
303
|
-
zIndex:
|
|
310
|
+
zIndex: 10000000,
|
|
304
311
|
},
|
|
305
312
|
processingText: {
|
|
306
313
|
fontSize: 16,
|
|
@@ -483,7 +483,8 @@ export const useTemplateKYCFlow = (
|
|
|
483
483
|
data: payloadData,
|
|
484
484
|
templateId: null,
|
|
485
485
|
token: state.session.token,
|
|
486
|
-
action: action
|
|
486
|
+
action: action,
|
|
487
|
+
apiKey: apiKey,
|
|
487
488
|
});
|
|
488
489
|
logger.log("currentComp state", truncateFields(state));
|
|
489
490
|
// Marquer comme complété et passer au suivant
|
|
@@ -511,7 +512,7 @@ export const useTemplateKYCFlow = (
|
|
|
511
512
|
}));
|
|
512
513
|
}
|
|
513
514
|
|
|
514
|
-
}, [canGoNext, state.currentComponentIndex, state.template.components, validateComponent]),
|
|
515
|
+
}, [canGoNext, state.currentComponentIndex, state.template.components, validateComponent, apiKey]),
|
|
515
516
|
|
|
516
517
|
// Retourner au composant précédent
|
|
517
518
|
previousComponent: useCallback(() => {
|
|
@@ -566,7 +567,7 @@ export const useTemplateKYCFlow = (
|
|
|
566
567
|
setState(prev => ({ ...prev, isProcessing: false }));
|
|
567
568
|
}
|
|
568
569
|
}, [state.session.session_id, state.verification, onComplete]),
|
|
569
|
-
|
|
570
|
+
|
|
570
571
|
// Soumettre le template complet
|
|
571
572
|
submitTemplate: useCallback(async () => {
|
|
572
573
|
// Allow submission when on the review step and all previous steps are valid
|
package/src/index.ts
CHANGED
|
@@ -1,75 +1,11 @@
|
|
|
1
|
+
export * from './TransfergratisSdk.types';
|
|
1
2
|
|
|
2
|
-
// Reexport the native module. On web, it will be resolved to TransfergratisSdkModule.web.ts
|
|
3
|
-
// and on native platforms to TransfergratisSdkModule.ts
|
|
4
|
-
export { default } from './TransfergratisSdkModule';
|
|
5
|
-
export { default as TransfergratisSdkView } from './TransfergratisSdkView';
|
|
6
|
-
export * from './TransfergratisSdk.types';
|
|
7
|
-
|
|
8
|
-
// Export KYC Flow - Main component
|
|
9
|
-
export { default as LauchTransferGratisKYC } from './App';
|
|
10
3
|
|
|
11
4
|
// Export KYC types
|
|
12
5
|
export * from './types/KYC.types';
|
|
13
6
|
|
|
14
|
-
// Export Camera Modules (Legacy + Vision Camera + Web)
|
|
15
|
-
export { default as NativeCameraModule } from './modules/camera/NativeCameraModule';
|
|
16
|
-
export { default as VisionCameraModule } from './modules/camera/VisionCameraModule';
|
|
17
|
-
export { default as UnifiedCameraModule } from './modules/camera/UnifiedCameraModule';
|
|
18
|
-
|
|
19
|
-
// Export Camera Components
|
|
20
|
-
export { NativeCameraView } from './components/NativeCameraView'; // Legacy
|
|
21
|
-
export { VisionCameraView } from './components/VisionCameraView';
|
|
22
|
-
export { EnhancedCameraView } from './components/EnhancedCameraView';
|
|
23
|
-
|
|
24
|
-
// Export KYC Components
|
|
25
|
-
export { SelfieCapture } from './components/SelfieCapture';
|
|
26
|
-
export { FileUpload } from './components/FileUpload';
|
|
27
|
-
export { CustomCameraExample } from './components/CustomCameraExample';
|
|
28
|
-
|
|
29
|
-
// Export Orientation Video Processing Components
|
|
30
|
-
export { default as OrientationVideoCapture } from './components/KYCElements/OrientationVideoCapture';
|
|
31
|
-
export { default as OrientationVideoCaptureEnhanced } from './components/KYCElements/OrientationVideoCaptureEnhanced';
|
|
32
|
-
export { default as OrientationVideoCaptureFinal } from './components/KYCElements/OrientationVideoCaptureFinal';
|
|
33
|
-
export { default as OrientationVideoExample } from './components/example/OrientationVideoExample';
|
|
34
7
|
|
|
35
|
-
|
|
36
|
-
export { TemplateKYCFlow } from './components/TemplateKYCFlowRefactored';
|
|
37
|
-
export { TemplateKYCExample } from './components/TemplateKYCExample';
|
|
38
|
-
export { useTemplateKYCFlow, TemplateKYCFlowProvider, useTemplateKYCFlowContext } from './hooks/useTemplateKYCFlow';
|
|
39
|
-
export { IDCardCapture } from './components/KYCElements/IDCardCapture';
|
|
40
|
-
export { SelfieCaptureTemplate } from './components/KYCElements/SelfieCaptureTemplate';
|
|
41
|
-
export { FileUploadTemplate } from './components/KYCElements/FileUploadTemplate';
|
|
42
|
-
export { LocationCaptureTemplate } from './components/KYCElements/LocationCaptureTemplate';
|
|
43
|
-
export { CountrySelectionTemplate } from './components/KYCElements/CountrySelectionTemplate';
|
|
8
|
+
export { TemplateKYCExample as LauchTransferGratisKYC } from './components/TemplateKYCExample';
|
|
44
9
|
|
|
45
10
|
// Export Web KYC Components
|
|
46
11
|
export { WebKYCEntry } from './web';
|
|
47
|
-
|
|
48
|
-
// Export KYC Service
|
|
49
|
-
export { default as KYCService } from './modules/api/KYCService';
|
|
50
|
-
|
|
51
|
-
// Export Hooks
|
|
52
|
-
export { default as useOrientationVideo } from './hooks/useOrientationVideo';
|
|
53
|
-
export { default as useLocation } from './hooks/useLocation';
|
|
54
|
-
export type { LocationData, LocationError, UseLocationOptions, UseLocationReturn } from './hooks/useLocation';
|
|
55
|
-
|
|
56
|
-
// UI Components
|
|
57
|
-
export {
|
|
58
|
-
Button,
|
|
59
|
-
PrimaryButton,
|
|
60
|
-
SecondaryButton,
|
|
61
|
-
OutlineButton,
|
|
62
|
-
GhostButton,
|
|
63
|
-
DangerButton,
|
|
64
|
-
SuccessButton,
|
|
65
|
-
WarningButton,
|
|
66
|
-
SmallButton,
|
|
67
|
-
LargeButton,
|
|
68
|
-
BackButton,
|
|
69
|
-
NextButton,
|
|
70
|
-
SubmitButton,
|
|
71
|
-
CancelButton,
|
|
72
|
-
buttonIcons
|
|
73
|
-
} from './components/ui/Button';
|
|
74
|
-
export { buttonStyles, colors, shadows, buttonTextColors, iconSizes, buttonSpacing } from './components/ui/ButtonStyles';
|
|
75
|
-
export { default as ButtonExample } from './components/ui/ButtonExample';
|