@adyen/kyc-components 3.91.0 → 3.92.0
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/dist/{4-people-BzyXLUF9.js → 4-people-BtDi7O9A.js} +2 -2
- package/dist/{AcceptTermsOfServiceComponent-Bl8Skw0p.js → AcceptTermsOfServiceComponent-T7eWi57Z.js} +17 -14
- package/dist/{Accordion-BxBwztLx.js → Accordion-Boa_Vira.js} +2 -2
- package/dist/{AccountSetupRejected-DWnI467S.js → AccountSetupRejected-LAVhMMBt.js} +4 -4
- package/dist/{ActionBar-BI8EL50o.js → ActionBar-CK8dwgSJ.js} +1 -1
- package/dist/{Address-BUrDDnmR.js → Address-ki-bCjUJ.js} +23 -289
- package/dist/{Alert-B83aFhFn.js → Alert-TCEgDc2-.js} +3 -3
- package/dist/{Avatar-CWGv3_UH.js → Avatar-AC-D1DKh.js} +2 -2
- package/dist/{BusinessFinancingComponent-Dp9pkrSs.js → BusinessFinancingComponent-Cf-EEnyR.js} +6 -6
- package/dist/{BusinessFinancingDropin-CxDQONVa.js → BusinessFinancingDropin-DeLlYaOF.js} +30 -22
- package/dist/{BusinessFinancingPage-CK4iko3V.js → BusinessFinancingPage-DtX8x3Zp.js} +4 -4
- package/dist/{BusinessTypeSelectionPage-BbCt3hSM.js → BusinessTypeSelectionPage-6Ltt53Mu.js} +58 -33
- package/dist/{Card-CQrP0PXC.js → Card-Det7uTiv.js} +2 -2
- package/dist/{debouncedInputEvent-CFFx_oML.js → Checkbox-D8rB6_HN.js} +3 -38
- package/dist/Confirm-Ctfqp-1b.js +64 -0
- package/dist/ConstitutionalDocument-TJAc9nDQ.js +2358 -0
- package/dist/ContextGuidance-CCknw_Y1.js +34 -0
- package/dist/CountryField-DzmOWqiE.js +66 -0
- package/dist/{CreateIndividualComponent-B6ecxCd8.js → CreateIndividualComponent-_H34wdze.js} +6 -6
- package/dist/{CreateTransferInstrumentComponent-Chqddjgy.js → CreateTransferInstrumentComponent-CmnVEFaB.js} +5 -12
- package/dist/{Currency-CkQVLmOQ.js → Currency-C2egEHMF.js} +64 -8
- package/dist/{CustomerSupport-BDynvVnl.js → CustomerSupport-DLfbNC-J.js} +12 -10
- package/dist/{DebugModal-DAu7rz8a.js → DebugModal-C0uG_A8N.js} +8 -7
- package/dist/{DecisionMakerDetailsPage-BBqNmh_M.js → DecisionMakerDetailsPage-BTR-hRwO.js} +6 -6
- package/dist/{DecisionMakers-Ddvw0N__.js → DecisionMakers-B4qQ3M6Y.js} +27 -21
- package/dist/Dropzone-CKT3THCY.js +218 -0
- package/dist/{EmbeddedStatus-BSK268B-.js → EmbeddedStatus-Bst5MPzi.js} +3 -3
- package/dist/{EndStateLayout-B8KmFejY.js → EndStateLayout-Ck_Lvgng.js} +2 -2
- package/dist/{EntityAssociation-DBPiXzNF.js → EntityAssociation-bcF_I_DK.js} +8 -8
- package/dist/{EntityGuidanceStatus-QEzHcb28.js → EntityGuidanceStatus-D6VoRE_0.js} +4 -3
- package/dist/ErrorPanel-CFN2G9Vz.js +190 -0
- package/dist/Field-B3Vy1-QZ.js +142 -0
- package/dist/{FormNavigation-DLJbUsy3.js → FormNavigation-Brw-75s0.js} +3 -3
- package/dist/{FormWrapper-41qnDF4W.js → FormWrapper-BcNyCMkD.js} +10 -10
- package/dist/Header-YafgG5Nz.js +83 -0
- package/dist/Image-Cvb4hnru.js +44 -0
- package/dist/{IndividualOnfido-pGSPtITh.js → IndividualOnfidoDropin-Dy5obHs1.js} +3833 -5548
- package/dist/InputDate-UCHQ3zOB.js +43 -0
- package/dist/InputGroup-WBfGDV5F.js +32 -0
- package/dist/InputText-DGKAS6ZI.js +134 -0
- package/dist/{Introduction-DaRfsN8P.js → Introduction-DOxSVZ6X.js} +4 -4
- package/dist/{JpAddress-BrtEV6zM.js → JpAddress-DClXaVjy.js} +22 -10
- package/dist/LandingLayout-co7NR2te.js +60 -0
- package/dist/{LegalRepresentativeDetailsPage-XcmRRT7P.js → LegalRepresentativeDetailsPage-DOP3L2r9.js} +4 -4
- package/dist/Link-DWTJ55UO.js +35 -0
- package/dist/List-BAzyC6sw.js +83 -0
- package/dist/{ListItem-DlRGqcSA.js → ListItem-B8D-kUHN.js} +3 -3
- package/dist/LoaderWrapper-CUz5NRFr.js +42 -0
- package/dist/{ManageIndividualComponent-BpzsaZ1O.js → ManageIndividualComponent-DND7vuna.js} +5 -5
- package/dist/{ManageTermsOfServiceComponent-D9i2HO5I.js → ManageTermsOfServiceComponent-ylDupO1E.js} +5 -5
- package/dist/{ManageTransferInstrumentComponent-C6LYppym.js → ManageTransferInstrumentComponent-CgUfGP5E.js} +16 -13
- package/dist/{Spacer-w89ksCbG.js → MaskedInput-Cn0VAuEp.js} +17 -631
- package/dist/{MaybeModal-DW5SxNsJ.js → MaybeModal-CWCEHeOg.js} +3 -3
- package/dist/{Modal-B4wxf7HK.js → Modal-pyBUluei.js} +2 -2
- package/dist/OnboardingDropinComponent-DwKImil4.js +2306 -0
- package/dist/{PayoutDetailsDropin-BKXxBApD.js → PayoutDetailsDropin-lYVb5WCQ.js} +105 -76
- package/dist/Radio-BMtxBpnn.js +39 -0
- package/dist/RadioGroup-DPc8nUuk.js +98 -0
- package/dist/RadioGroupCard-Pj9qq4uW.js +150 -0
- package/dist/{Review-DSdM3vGX.js → Review-gkTjl3a8.js} +7 -7
- package/dist/{RootBusinessDetailsPage-CqpiMFn9.js → RootBusinessDetailsPage-DjwEzuLA.js} +5 -5
- package/dist/{RootBusinessLinesPage-DUIp_zfH.js → RootBusinessLinesPage-2-U3mf6i.js} +104 -50
- package/dist/{RootIndividualDetailsPage-BpTbnRMJ.js → RootIndividualDetailsPage-BFYP63_i.js} +6 -6
- package/dist/{useForm-_Kjd_HFb.js → Select-D1rFT3T8.js} +10 -775
- package/dist/{SignPCIComponent-B-nJZ1cD.js → SignPCIComponent-DqElmjjG.js} +13 -11
- package/dist/{SingpassSelection-D7wRmaLb.js → SingpassSelection-eruroIiQ.js} +9 -7
- package/dist/{SoleProprietorshipPage-DUVjo6fc.js → SoleProprietorshipPage-7YdzA7iH.js} +4 -4
- package/dist/{SourceOfFundsPage-CFDBqD8v.js → SourceOfFundsPage-C_wiSoc4.js} +39 -26
- package/dist/Spacer-BK3jDget.js +18 -0
- package/dist/{StepProgressIndicator-BvU4jA3I.js → StepProgressIndicator-DLoEzGro.js} +1 -1
- package/dist/{StoreProvider-CyzNf7KK.js → StoreProvider-D9IR5HNN.js} +331 -222
- package/dist/StructuredList-9dnJRdx_.js +61 -0
- package/dist/{Summary-QyNHKBjO.js → Summary-Bq94iVfc.js} +10 -5
- package/dist/{InputText-DLAmX8CW.js → TaskVerificationStatus-BLCkXEn6.js} +3 -123
- package/dist/TaxInformationField-c-ZWfhUk.js +3134 -0
- package/dist/{TaxReportingDropin-Bn2xYbVw.js → TaxReportingDropin-ajO0q4eZ.js} +20 -17
- package/dist/TextArea-D9eJloeE.js +103 -0
- package/dist/TileGroup-CaY3i_T7.js +203 -0
- package/dist/{TrustDetailsPage-D0sr6zMt.js → TrustDetailsPage-BWXZX4-u.js} +40 -27
- package/dist/{TrustMemberCompanyPage-4sIP-M16.js → TrustMemberCompanyPage-CJj2BpXu.js} +5 -5
- package/dist/{TrustMemberIndividualPage-CelIjIAw.js → TrustMemberIndividualPage-BXp9RXDw.js} +4 -4
- package/dist/{TrustMemberRoleAndTypePage-C3CRy717.js → TrustMemberRoleAndTypePage-gYJ5U6RH.js} +24 -14
- package/dist/{TrustMembersOverview-HrRgAsno.js → TrustMembersOverview-Chmnt5jS.js} +13 -12
- package/dist/{UnincorporatedPartnershipIndividualPage-Dre5_Nuk.js → UnincorporatedPartnershipIndividualPage-DckUiPPY.js} +4 -4
- package/dist/{UnincorporatedPartnershipMemberCompanyPage-woQiy94h.js → UnincorporatedPartnershipMemberCompanyPage-Bx0A5Bit.js} +5 -5
- package/dist/{UnincorporatedPartnershipMemberRoleAndTypePage-DrirgJXY.js → UnincorporatedPartnershipMemberRoleAndTypePage-CEE1hzIn.js} +23 -16
- package/dist/{UnincorporatedPartnershipMembersOverview-BBiRqJkR.js → UnincorporatedPartnershipMembersOverview-wB8K9r6g.js} +10 -9
- package/dist/{VerificationErrorAlert-B_ovSmUS.js → VerificationErrorAlert-DZ5OOTBN.js} +4 -4
- package/dist/{ViewVerificationStatusComponent-CDQk4Nxa.js → ViewVerificationStatusComponent-BVY4YUJf.js} +4 -4
- package/dist/adyen-business-financing.js +3 -3
- package/dist/adyen-individual-configuration.js +3 -3
- package/dist/adyen-individual-status.js +3 -3
- package/dist/adyen-kyc-components.js +21 -20
- package/dist/adyen-onboarding.js +3 -3
- package/dist/adyen-terms-of-service-management.js +3 -3
- package/dist/adyen-terms-of-service-status.js +3 -3
- package/dist/adyen-transfer-instrument-configuration.js +3 -3
- package/dist/adyen-transfer-instrument-management.js +3 -3
- package/dist/adyen-verification-status.js +3 -3
- package/dist/{arrow-right-KxA3SvQj.js → arrow-right-BoqwUH_d.js} +2 -2
- package/dist/bafinUtils-Wct4TWLH.js +149 -0
- package/dist/{bag-BPumznWh.js → bag-BXVWLrwo.js} +2 -2
- package/dist/{bank-D6FiNBhs.js → bank-1GvaHPAZ.js} +2 -2
- package/dist/{bin-Bz6KOIeE.js → bin-Ba-3ll8T.js} +2 -2
- package/dist/{business-lines-DboUCbXw.js → business-lines-BAqTbnBw.js} +2 -2
- package/dist/{capital-GVQ3svwN.js → capital-9TKHySO7.js} +2 -2
- package/dist/{cash-stack-D9AoDDwt.js → cash-stack-DwYu4xNy.js} +2 -2
- package/dist/{certificate-CdEWgHQf.js → certificate-N2YFedpI.js} +2 -2
- package/dist/{checkmark-Q7x6tGhy.js → checkmark-D9dGhGpG.js} +2 -2
- package/dist/{checkmark-circle-x7dzbp3I.js → checkmark-circle-CFWClLQ6.js} +2 -2
- package/dist/{checkmark-circle-fill-CsvN5_PL.js → checkmark-circle-fill-DEB-tuGl.js} +2 -2
- package/dist/{checkmark-small-D35myntq.js → checkmark-small-D3VNx2lo.js} +2 -2
- package/dist/{chevron-down-C2iDorpW.js → chevron-down-C7SUSYfl.js} +2 -2
- package/dist/{chevron-left-ztPO84q-.js → chevron-left-BXmd-S46.js} +2 -2
- package/dist/{chevron-right-C_JN0oDt.js → chevron-right-jE6RwM2B.js} +2 -2
- package/dist/{chevron-up-CgG8n25g.js → chevron-up-BdfNcqzq.js} +2 -2
- package/dist/{circle-Bt3Nlr3q.js → circle-BJPTMCWB.js} +2 -2
- package/dist/{circle-small-filled-YMzP6yQU.js → circle-small-filled-BuO8Vg8j.js} +2 -2
- package/dist/{clock-BZHremOA.js → clock-DAzaBRWk.js} +2 -2
- package/dist/{coins-fkAk6dCo.js → coins-DYdzG5e_.js} +2 -2
- package/dist/commonValidators-DcFd5CHs.js +24 -0
- package/dist/{contract-BTa4HltT.js → contract-BfJb1t6M.js} +2 -2
- package/dist/{cross-Cn09MtQ_.js → cross-CDS_eot4.js} +2 -2
- package/dist/{cross-circle-fill-maan7Z5S.js → cross-circle-fill-C-EJ57Yn.js} +2 -2
- package/dist/{cross-circle-fill-small-DCz52AuN.js → cross-circle-fill-small-DkPjsuBH.js} +2 -2
- package/dist/currency-CrdnaaDu.js +35 -0
- package/dist/datasetUtil-BHQp0-xL.js +58 -0
- package/dist/debouncedInputEvent-Cv2S512Y.js +46 -0
- package/dist/{decision-makers-group-CgddXgrx.js → decision-makers-group-DrvpnEqj.js} +2 -2
- package/dist/{digital-wallet-D_IpxnkN.js → digital-wallet-Bx5YM1LY.js} +2 -2
- package/dist/{document-1-C08ut-Dt.js → document-1-qlSTF558.js} +2 -2
- package/dist/{document-blurred-2Zpodj3_.js → document-blurred-BiWap0xs.js} +2 -2
- package/dist/{document-cut-off-ClS7RiOp.js → document-cut-off-aQezqOif.js} +2 -2
- package/dist/{document-expired-CjksBq-N.js → document-expired-BhBXaWWQ.js} +2 -2
- package/dist/{document-front-DiAairT3.js → document-front-DYuhZGeQ.js} +2 -2
- package/dist/{document-person-vxlA6C5f.js → document-person-CDbnTOdV.js} +2 -2
- package/dist/{download-Drhk9k1f.js → download-BZQB1WkZ.js} +2 -2
- package/dist/{dropinUtils-DCWhMKpQ.js → dropinUtils-BpJn607e.js} +4 -4
- package/dist/{edit-1-CFoDTMvQ.js → edit-1-DAqtnOIx.js} +2 -2
- package/dist/{en-US-BzrLvydZ.js → en-US-CjjPhkB5.js} +2 -2
- package/dist/{external-link-DCMYUMfW.js → external-link-Cg6pJaSJ.js} +2 -2
- package/dist/fieldConfig-BPwb1GHc.js +134 -0
- package/dist/fieldConfigurations-BUT9DTUH.js +21 -0
- package/dist/form-rules-DhbF2mY4.js +13 -0
- package/dist/formUtils-BlVlgetw.js +137 -0
- package/dist/{funds-in-D8bj0aoE.js → funds-in-CInoUdmG.js} +2 -2
- package/dist/{getName-l7X1ZGKx.js → getName-CzpJ9tV7.js} +2 -2
- package/dist/getProps-CLJfvUMb.js +156 -0
- package/dist/{gift-CQ_DEma7.js → gift-omNInZeB.js} +2 -2
- package/dist/{graph-BJmqglH2.js → graph-DunG_uu1.js} +2 -2
- package/dist/{graph-up-Bq6adtlX.js → graph-up-BZze4i6m.js} +2 -2
- package/dist/{hasDataChanged-BXawTZla.js → hasDataChanged-8e8x8zjz.js} +2 -2
- package/dist/{headquarter-DNYyuuFq.js → headquarter-BhpSibFO.js} +2 -2
- package/dist/{hotel-BuNql78Z.js → hotel-Cp7VgGCJ.js} +2 -2
- package/dist/{house-B6sNRj-B.js → house-BhyBQdR3.js} +2 -2
- package/dist/{id-blurred-9dzBOWCE.js → id-blurred-B5lHEP8M.js} +2 -2
- package/dist/{id-cut-off-CohJCI2h.js → id-cut-off-Ba1FRzKO.js} +2 -2
- package/dist/{id-front-CSZfvdRg.js → id-front-CpNWN6nG.js} +2 -2
- package/dist/{id-glare-Q2JWo5ts.js → id-glare-DgCQON8k.js} +2 -2
- package/dist/{id-verification-instant-BUVBO4R3.js → id-verification-instant-Byt4Oul6.js} +2 -2
- package/dist/{id-verification-manual-B3YZALYU.js → id-verification-manual-CvcTkOSY.js} +2 -2
- package/dist/{iframeWidget-CbtmWmoO.js → iframeWidget-D6BlBF0m.js} +4 -4
- package/dist/{image-BSihO8lR.js → image-CmB0ioUM.js} +2 -2
- package/dist/{info-vHTZWoJ7.js → info-Bb_-xIEK.js} +2 -2
- package/dist/{info-filled-SQotHmT9.js → info-filled-CK8LB339.js} +2 -2
- package/dist/{instant-verification-Dvvkyfmp.js → instant-verification-UrnuHTYn.js} +2 -2
- package/dist/isEmpty-CsYVgjoD.js +23 -0
- package/dist/japanSupportUtils-iATUjnbf.js +17 -0
- package/dist/jpAddressSchema-De6ix57p.js +28 -0
- package/dist/{localizeDateString-BX5t59Ip.js → localizeDateString-BHDr1NID.js} +2 -2
- package/dist/{location-Q4oKvnkl.js → location-itJfxrDQ.js} +2 -2
- package/dist/{mail-BOdyoVqB.js → mail-VHTlAusn.js} +2 -2
- package/dist/makeSelectItemForRole-Bm2NwBxD.js +133 -0
- package/dist/{manual-verification-BvZWqA00.js → manual-verification-BO8zgAYT.js} +2 -2
- package/dist/{mapExistingFile-Bd7nsoK8.js → mapExistingFile-DNBa6Ekj.js} +80 -5
- package/dist/mapJpAddressSchemaToAddressLocalizations-BNb8d51F.js +147 -0
- package/dist/{mapLegalEntityToIndividualOnfidoSchema-CQF6zsO7.js → mapLegalEntityToIndividualOnfidoSchema-DREgz5Ms.js} +63 -3
- package/dist/{mapTransferInstrumentToPayoutAccount-CacHlKHM.js → mapTransferInstrumentToPayoutAccount-C5NqOfNW.js} +2 -2
- package/dist/{minus-circle-filled-kC2IUvKz.js → minus-circle-filled-ZhtJ0GD3.js} +2 -2
- package/dist/{onfido-logo-BWSv__sQ.js → onfido-logo-BSkKPH10.js} +2 -2
- package/dist/{options-horizontal-CBmbNv7R.js → options-horizontal-GuXvLvV3.js} +2 -2
- package/dist/{partner-CPjsrePY.js → partner-QD27Vy4w.js} +2 -2
- package/dist/{passport-blurred-B4UDQfmc.js → passport-blurred-CVG493IJ.js} +2 -2
- package/dist/{passport-cut-off-C0N2mgLk.js → passport-cut-off-COzA_TmB.js} +2 -2
- package/dist/{passport-front-BwA7wR91.js → passport-front-WJleLixT.js} +2 -2
- package/dist/{passport-front-green-BL4HmtsB.js → passport-front-green-CZVkCa1n.js} +2 -2
- package/dist/{passport-glare-Mg2ixsYA.js → passport-glare-BP5WnJZj.js} +2 -2
- package/dist/patternValidators-BXduwLbz.js +83 -0
- package/dist/{pay-by-link-plane-BVZndh67.js → pay-by-link-plane-BpY8Q6-B.js} +2 -2
- package/dist/{payout-ChUEoLjt.js → payout-DtB68BcZ.js} +2 -2
- package/dist/{payout-verification-instant-5u-wvFKv.js → payout-verification-instant-BzpfOQLD.js} +2 -2
- package/dist/{payout-verification-manual-BH2mu0UW.js → payout-verification-manual-gNEoeZkV.js} +2 -2
- package/dist/{person-DGjUU4S4.js → person-IVZG3t3_.js} +2 -2
- package/dist/{plaid-logo-CtActXTN.js → plaid-logo-FsZ7kfL-.js} +2 -2
- package/dist/{plus-CWXA5wdX.js → plus-DiALAL8-.js} +2 -2
- package/dist/{plus-circle-filled-CbC0u2Y1.js → plus-circle-filled-BzHtTqEN.js} +2 -2
- package/dist/{process-field-configurations-BZQqH4-M.js → process-field-configurations-B26ehyAw.js} +3 -3
- package/dist/{recurring-CkL4cCM2.js → recurring-DKNs9K3x.js} +2 -2
- package/dist/{reporting-DerosUNm.js → reporting-D5ABpLO_.js} +2 -2
- package/dist/{resolveEnvironment-C6JtHmZc.js → resolveEnvironment-B5Yrsa4J.js} +3 -3
- package/dist/{revenue-accelerate-Dp4Ns_5c.js → revenue-accelerate-D7Sp0V4a.js} +2 -2
- package/dist/{review-CxIN9azU.js → review-D4TUjcWF.js} +2 -2
- package/dist/roleMetadata-DmgqzhZJ.js +66 -0
- package/dist/{rules-ClDW_ZSK.js → rules-B_6RrE9T.js} +6 -5
- package/dist/{save-Fgy7EDid.js → save-BfqO2JBI.js} +2 -2
- package/dist/{search-C4GZ-Rc1.js → search-Cmzbf5zI.js} +2 -2
- package/dist/{show-yPjPmEf8.js → show-IdbU1C6P.js} +2 -2
- package/dist/{singpass-logo-BkMSwiGY.js → singpass-logo-wY4xsmTX.js} +2 -2
- package/dist/{singpass-verification-instant-hY4eGFwl.js → singpass-verification-instant-JCqTr7Mv.js} +2 -2
- package/dist/{singpass-verification-manual-DwhRpy5Q.js → singpass-verification-manual-DQ7XW6R3.js} +2 -2
- package/dist/{solution-payments-CNAat9h7.js → solution-payments-DpyE_sdS.js} +2 -2
- package/dist/{store-IuAkDRAp.js → store-Btc4GcmU.js} +2 -2
- package/dist/style.css +965 -993
- package/dist/styles-CLV89_hH.js +965 -993
- package/dist/summaryItem-CAQCQSkt.js +18 -0
- package/dist/{tax-reporting-graph-DjzwRgE6.js → tax-reporting-graph-hgoilCHZ.js} +2 -2
- package/dist/{terminal-1-_me9J9h0.js → terminal-1-D1pwXCoi.js} +2 -2
- package/dist/{tink-logo-BcIv93ND.js → tink-logo-DDyjz5eJ.js} +2 -2
- package/dist/types/api/businessLines/useCreateBusinessLine.d.ts +1 -1
- package/dist/types/api/businessLines/useDeleteBusinessLine.d.ts +1 -1
- package/dist/types/api/businessLines/useUpdateBusinessLines.d.ts +1 -1
- package/dist/types/api/businessLines/useUpdateSourceOfFunds.d.ts +1 -1
- package/dist/types/api/companyDataSet/useClearCompanyData.d.ts +1 -1
- package/dist/types/api/createLegalEntity/useCreateLegalEntity.d.ts +1 -1
- package/dist/types/api/documentValidation/useDocumentValidate.d.ts +1 -1
- package/dist/types/api/documents/useCreateDocument.d.ts +1 -1
- package/dist/types/api/documents/useDeleteDocument.d.ts +1 -1
- package/dist/types/api/documents/useDocument.d.ts +1 -1
- package/dist/types/api/documents/useUpdateDocument.d.ts +1 -1
- package/dist/types/api/entityVerifications/useVerifyIdNumber.d.ts +2 -2
- package/dist/types/api/idVerificationProviders/idVerificationStartCheck.d.ts +1 -1
- package/dist/types/api/idVerificationProviders/useExtractDocumentInformation.d.ts +1 -1
- package/dist/types/api/idVerificationProviders/useIdVerificationToken.d.ts +1 -1
- package/dist/types/api/legalEntity/useConfirmReview.d.ts +1 -1
- package/dist/types/api/legalEntity/useUpdateLegalEntity.d.ts +1 -1
- package/dist/types/api/onboardingStatus/useGenerateOnboardingLink.d.ts +1 -1
- package/dist/types/api/pci/useSignPci.d.ts +1 -2
- package/dist/types/api/taskStatus/useTaskStatus.d.ts +2 -2
- package/dist/types/api/termsOfService/useAcceptTermsOfService.d.ts +1 -1
- package/dist/types/api/types.d.ts +2 -1
- package/dist/types/api/uiAnalytics/useAnalyticsSession.d.ts +1 -1
- package/dist/types/api/uiAnalytics/usePushAnalyticEvent.d.ts +1 -1
- package/dist/types/api/validation/useValidateAccountIdentification.d.ts +1 -1
- package/dist/types/components/BankAccount/forms/BankDocument/types.d.ts +0 -1
- package/dist/types/components/BankAccount/forms/BankVerification/types.d.ts +1 -0
- package/dist/types/components/BankAccount/forms/BankVerification/verification/overlay/BankVerificationOverlay.d.ts +1 -1
- package/dist/types/components/BankAccount/forms/PayoutDetails/types.d.ts +0 -1
- package/dist/types/components/BankAccount/mapping/payoutKeyMappings.d.ts +439 -439
- package/dist/types/components/BankAccount/tasks/PayoutDetailsDropin/PayoutDetailsDropin.d.ts +1 -1
- package/dist/types/components/BankAccount/utils/payoutAccountUtil.d.ts +1 -1
- package/dist/types/components/Business/forms/BusinessDetails/form-ids.d.ts +2 -0
- package/dist/types/components/Business/forms/BusinessDetails/types.d.ts +1 -0
- package/dist/types/components/Business/forms/CompanyStructure/CompanyStructure.d.ts +0 -1
- package/dist/types/components/Business/tasks/BusinessDetailsDropin/types.d.ts +1 -1
- package/dist/types/components/Business/tasks/BusinessDetailsDropin/utils.d.ts +1 -1
- package/dist/types/components/BusinessLines/tasks/BusinessLines/BusinessLinesDropin.d.ts +1 -1
- package/dist/types/components/BusinessLines/tasks/types.d.ts +2 -0
- package/dist/types/components/BusinessLines/tasks/utils.d.ts +4 -2
- package/dist/types/components/EFP/mapping/businessFinancingKeyMappings.d.ts +475 -475
- package/dist/types/components/EFP/tasks/SourceOfFundsDropin/utils.d.ts +1 -2
- package/dist/types/components/EFP/tasks/TaxReportingDropin/utils.d.ts +1 -2
- package/dist/types/components/EmbeddedDropins/BusinessFinancingComponent/utils.d.ts +1 -1
- package/dist/types/components/Individual/forms/Individual/Individual.d.ts +41 -3
- package/dist/types/components/Individual/forms/Individual/form-ids.d.ts +2 -0
- package/dist/types/components/Individual/forms/Individual/types.d.ts +1 -2
- package/dist/types/components/Individual/forms/IndividualOnfido/IndividualOnfido.types.d.ts +1 -0
- package/dist/types/components/Individual/forms/IndividualOnfido/form-ids.d.ts +2 -0
- package/dist/types/components/Individual/tasks/DecisionMakers/DecisionMakerDetails/utils.d.ts +1 -1
- package/dist/types/components/Individual/tasks/DecisionMakers/utils.d.ts +1 -1
- package/dist/types/components/Shared/Introduction/copy.d.ts +1 -1
- package/dist/types/components/Shared/forms/Address/utils.d.ts +1 -1
- package/dist/types/components/Shared/forms/BusinessTypeSelection/utils.d.ts +1 -1
- package/dist/types/components/Trust/tasks/RoleAndTypeDropin/formatRoleAndEntityTypeSummary.d.ts +1 -1
- package/dist/types/components/ui/molecules/EmbeddedStatus/statusToTag.d.ts +1 -1
- package/dist/types/core/user-events.d.ts +1 -0
- package/dist/types/language/types.d.ts +7 -2
- package/dist/types/language/utils.d.ts +1 -2
- package/dist/types/types/assert.d.ts +1 -0
- package/dist/types/utils/analytics/debouncedInputEvent.d.ts +1 -0
- package/dist/types/utils/analytics/getPrefilledDetails.d.ts +28 -0
- package/dist/types/utils/api/processCapabilitites.d.ts +13 -0
- package/dist/types/utils/entityStatusUtil.d.ts +1 -1
- package/dist/types/utils/formUtils.d.ts +1 -2
- package/dist/types/utils/getDisplayErrorMessage.d.ts +1 -2
- package/dist/types/utils/getName.d.ts +1 -1
- package/dist/types/utils/makeSelectItemForRole.d.ts +1 -1
- package/dist/types/utils/translation.d.ts +3 -2
- package/dist/{types-DDnAZYTj.js → types-C6ntGMCy.js} +3 -26
- package/dist/{types-DE1uuPfP.js → types-CpAtsPmJ.js} +1 -1
- package/dist/{types-hGeLq0SR.js → types-c9nG7Dev.js} +1 -1
- package/dist/unincorporated-partnership-MeN1dp53.js +97 -0
- package/dist/{upload-BF65P4KM.js → upload-BmUXjsaU.js} +2 -2
- package/dist/{us-check-CYY6Crhr.js → us-check-C1rTBsCY.js} +2 -2
- package/dist/{us-check-account-number-C7KE5YzX.js → us-check-account-number-9lI1dXNC.js} +2 -2
- package/dist/{us-check-routing-number-DUbhsYAR.js → us-check-routing-number-s_KaAGSM.js} +2 -2
- package/dist/{useAssociatedLegalEntity-D_Nk_obe.js → useAssociatedLegalEntity-ahBb64MW.js} +2 -2
- package/dist/useBusinessDetailsData-qQ2HRnKK.js +5161 -0
- package/dist/{useCreateLegalEntity-DT7ue23d.js → useCreateLegalEntity-Kc8_ZlAe.js} +2 -2
- package/dist/useDataset-DfKmlbQd.js +74 -0
- package/dist/useForm-9uKM-XKf.js +582 -0
- package/dist/{FormFlow-BrgeP70A.js → useFormContext-CvQfKDA3.js} +26 -31
- package/dist/{useGlobalData-C7tjZfC0.js → useGlobalData-BVQ2OrIi.js} +3 -3
- package/dist/useId-BZ0PA7jP.js +24 -0
- package/dist/{useMultiForm-DWozxGN4.js → useMultiForm-pAiPIh7X.js} +4 -4
- package/dist/{useOnboardingStatus-DBLS6PUq.js → useOnboardingStatus-BhDBSLB6.js} +1 -1
- package/dist/{useScenarios-DD06bWNN.js → useScenarios-DFW21Vhf.js} +2 -2
- package/dist/{useTermsOfServiceStatus-D2lYSqHn.js → useTermsOfServiceStatus-BnO0rXiL.js} +1 -1
- package/dist/{useToastContext-Cbw29cqc.js → useToastContext-D6Lbxqj9.js} +5 -17
- package/dist/{useUnincorporatedPartnershipMembers-Dbb2VjkF.js → useUnincorporatedPartnershipMembers-CIC7xPbD.js} +5 -5
- package/dist/useUpdateBusinessLines-WlwUOtSU.js +337 -0
- package/dist/{useUpdateLegalEntity-Aubxhgvv.js → useUpdateLegalEntity-CStkUt4I.js} +3 -3
- package/dist/utils-7_xBiPO_.js +58 -0
- package/dist/utils-BmxzrkCX.js +165 -0
- package/dist/{utils-D1-D6fui.js → utils-CB39nVjj.js} +6 -6
- package/dist/{utils-DenrGsUh.js → utils-CDAwsXQa.js} +4 -4
- package/dist/utils-DOiFhaKn.js +29 -0
- package/dist/{documentUtils-Be5wlCwo.js → validate-Bsx2oHT1.js} +170 -6
- package/dist/{validate-BxVes1el.js → validate-D-l23QLG.js} +2 -2
- package/dist/validate-D4iK6FUk.js +385 -0
- package/dist/{validationError-DPP91cM3.js → validationError-DYYlX-5X.js} +2 -2
- package/dist/{warning-circle-fill-CEN1WL7A.js → warning-circle-fill-DBvt921B.js} +2 -2
- package/dist/{warning-diamond-filled-BfXMlVrG.js → warning-diamond-filled-Lb2od2ry.js} +2 -2
- package/dist/{webinar-DqjqrNEv.js → webinar-m9nuFZBt.js} +2 -2
- package/dist/{yapily-logo-CZ4ywjwA.js → yapily-logo-BduxhNRA.js} +2 -2
- package/package.json +6 -6
- package/dist/ConstitutionalDocument-DM6M40MP.js +0 -143
- package/dist/CountryField-CsKJAI53.js +0 -843
- package/dist/IndividualOnfidoDropin-DZEn2Tf8.js +0 -2575
- package/dist/OnboardingDropinComponent-Cx-c_p0i.js +0 -7623
- package/dist/getFieldsWithExistingData-CfckMyJ1.js +0 -22
- package/dist/mapFinancialReportsToFinancialInformation-Bfvt2G87.js +0 -67
- package/dist/mapJpAddressSchemaToAddressLocalizations-CWY2lZGD.js +0 -63
- package/dist/types/components/Shared/forms/BusinessTypeSelection/EntityTypeRadioGroupCard.d.ts +0 -11
- package/dist/useBusinessDetailsData-DG9EJBH_.js +0 -2441
- package/dist/useDataset-DCCxYOjr.js +0 -220
- package/dist/useUpdateBusinessLines-8bDYsLav.js +0 -46
- package/dist/validate-BgMFLdKI.js +0 -41
|
@@ -1,2575 +0,0 @@
|
|
|
1
|
-
;
|
|
2
|
-
{
|
|
3
|
-
try {
|
|
4
|
-
let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
|
|
5
|
-
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "07bf49ab-81ed-47bf-9539-c56d25484de2", e._sentryDebugIdIdentifier = "sentry-dbid-07bf49ab-81ed-47bf-9539-c56d25484de2");
|
|
6
|
-
} catch (e) {
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
;
|
|
10
|
-
import { jsx, jsxs, Fragment } from "preact/jsx-runtime";
|
|
11
|
-
import { useMemo, useState, useEffect, useCallback, useRef } from "preact/hooks";
|
|
12
|
-
import { u as useScenarios } from "./useScenarios-DD06bWNN.js";
|
|
13
|
-
import { b as useApiContext, a0 as useMutation, k as httpPost, aE as matchesRegex, aQ as trimValWithOneSpace, aF as NO_ALPHABET_REGEX, aG as EMOJI_REGEX, aH as hasRepeatedCharacters, aI as isInvalidName, b0 as INDIVIDUAL_VALID_CHAR_REGEX, aO as getFormattingRegEx, aP as SPECIAL_CHARS, C as CountryCodes, aL as standardKatakanaValidator, aM as standardKanjiValidator, W as isEmpty, O as TaskTypes, r as LegalEntityTypes, b1 as getAgeToday, b2 as euCountries, b3 as individualApiKeyMapping, a_ as reverseMapping, b4 as getNomineeFromAssociation, b5 as individualComponentsKeyMapping, b6 as drop, P as createLogger, K as useAccountHolder, V as useI18nContext, a3 as useAnalyticsContext, X as useExperimentsContext, $ as useVersionConfiguration, o as useSettingsContext, g as getLegalEntityCountry, b7 as getAllowedDecisionMakerRoles, b8 as filterOutUnwantedAssociationsIfRootLE, aB as cloneObject, b9 as individualDocumentMapping, ba as individualObscuredFields, ag as getOwnEntityAssociations, bb as hasNomineesChanged, bc as attachNomineeToRole, aV as doArraysMatch, j as useQuery, w as skipToken, m as httpGet, u as useTranslation, a2 as useQueryClient, B as Button, L as Loader, bd as individualOnfidoApiKeyMapping, am as Scenarios, an as DecisionMakerTypes, be as individualOnfidoDocumentMapping, bf as individualOnfidoObscuredFields } from "./StoreProvider-CyzNf7KK.js";
|
|
14
|
-
import { u as useCreateLegalEntity } from "./useCreateLegalEntity-DT7ue23d.js";
|
|
15
|
-
import { u as useUpdateLegalEntity } from "./useUpdateLegalEntity-Aubxhgvv.js";
|
|
16
|
-
import { h as useProviderStatus, l as addressValidators, n as addressFormatters, o as mapAddressLabels } from "./Address-BUrDDnmR.js";
|
|
17
|
-
import { c as contactDetailsValidationRules, u as useValidatePhoneNumberImperatively } from "./validate-BgMFLdKI.js";
|
|
18
|
-
import { F as FormContextProvider, a as FormFlow } from "./FormFlow-BrgeP70A.js";
|
|
19
|
-
import { a as useToastContext } from "./useToastContext-Cbw29cqc.js";
|
|
20
|
-
import { g as getPropsFromConfigurations, c as composePerScenarioFormConfigurations } from "./process-field-configurations-BZQqH4-M.js";
|
|
21
|
-
import { g as getRequiredForms, a as addValidityToForms, u as useFormComposer } from "./dropinUtils-DCWhMKpQ.js";
|
|
22
|
-
import { u as useMultiForm } from "./useMultiForm-DWozxGN4.js";
|
|
23
|
-
import { m as mapExistingFile, g as getPageName, a as getPage, u as useScenarioConfiguration } from "./mapExistingFile-Bd7nsoK8.js";
|
|
24
|
-
import { x as getSSNType, y as defaultFieldMetadata, z as defaultFieldConfig, A as defaultFieldMetadata$1, B as fieldConfig, t as taxInformationDefaultFieldMetadata, f as taxInformationDefaultFieldConfig, D as isEmpty$1, E as getTrustedFields, F as getAsyncIdNumberValidationRule, G as getAsyncPhoneValidationRules, H as setHasMotionCaptureScenario, I as showIndividualMotionCapture, p as individualForms, J as Individual, K as individualDocumentForms, L as idVerificationProviderId, M as idNowModalChildEntityId, N as LandingLayout, w as showIdNowModal, O as check4DigitSsnFailed, P as individualOnfidoRules, o as individualOnfidoForms, Q as isNextStepDisabled, R as shouldShowIdNowModal, U as IndividualOnfido, i as isCompatibleJapanVersion, V as JP_ADDRESS_REQUIRED_FIELDS, W as GuidanceQuestionValues, X as DECISION_MAKER_TYPES_WITH_JOBTITLE$1 } from "./IndividualOnfido-pGSPtITh.js";
|
|
25
|
-
import { i as isValidationError, p as processValidationErrors, a as isMaintenanceModeError } from "./validationError-DPP91cM3.js";
|
|
26
|
-
import { g as getIdDocument, a as getDocument, c as createDocumentRequest, d as documentApiUtils, m as mergeAttachments, b as getFileExtention } from "./documentUtils-Be5wlCwo.js";
|
|
27
|
-
import { a as datasetUtilities, C as Confirm } from "./useDataset-DCCxYOjr.js";
|
|
28
|
-
import { g as getFieldsWithExistingData } from "./getFieldsWithExistingData-CfckMyJ1.js";
|
|
29
|
-
import { l as localizeDateString } from "./localizeDateString-BX5t59Ip.js";
|
|
30
|
-
import { o as omitObscuredFieldsIfUnchanged, I as IFrameWidget } from "./iframeWidget-CbtmWmoO.js";
|
|
31
|
-
import { r as resolveFieldMetadata, w as getLocalizedIdDocumentTypeOptions, I as Image } from "./Spacer-w89ksCbG.js";
|
|
32
|
-
import { r as rules, D as DECISION_MAKER_TYPES_WITH_JOBTITLE } from "./rules-ClDW_ZSK.js";
|
|
33
|
-
import { f as formatObject } from "./utils-DNSfZiio.js";
|
|
34
|
-
import { m as mapSchemaFieldsToApiScriptLocalization, a as mapApiScriptLocalizationToSchemaFields } from "./mapAddressLocalizationToJpAddressSchema-vJWbpAyq.js";
|
|
35
|
-
import { Show } from "@preact/signals/utils";
|
|
36
|
-
import { m as mapJpAddressSchemaToAddressLocalizations, a as mapJpAddressSummary } from "./mapJpAddressSchemaToAddressLocalizations-CWY2lZGD.js";
|
|
37
|
-
import { g as getOnfidoIdentityTypeToApiIdentityTypeMap, i as individualFormDefaultData, m as mapLegalEntityToIndividualOnfidoSchema } from "./mapLegalEntityToIndividualOnfidoSchema-CQF6zsO7.js";
|
|
38
|
-
import { lazy } from "preact/compat";
|
|
39
|
-
import { M as Modal } from "./Modal-B4wxf7HK.js";
|
|
40
|
-
import { a as Alert } from "./Alert-B83aFhFn.js";
|
|
41
|
-
import { a as getIndividualLegalEntityName } from "./getName-l7X1ZGKx.js";
|
|
42
|
-
const verifyIdNumber = async (legalEntityId, baseUrl, data) => {
|
|
43
|
-
return await httpPost(
|
|
44
|
-
{
|
|
45
|
-
baseUrl,
|
|
46
|
-
path: `legalEntities/${legalEntityId}/verifications/idNumber`,
|
|
47
|
-
// Handler for unhappy flows, i.e. status != 200, in the idNumber verification process
|
|
48
|
-
errorHandler: async (response) => {
|
|
49
|
-
const responseData = await response;
|
|
50
|
-
if (responseData.status === 422) {
|
|
51
|
-
return { status: 422, message: responseData.detail, errorCode: responseData.errorCode };
|
|
52
|
-
}
|
|
53
|
-
if (responseData.status === 500) {
|
|
54
|
-
return { status: 500, message: "Service did not respond, do not block verification" };
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
data
|
|
59
|
-
);
|
|
60
|
-
};
|
|
61
|
-
const useVerifyIdNumber = (options) => {
|
|
62
|
-
const { rootLegalEntityId, baseUrl } = useApiContext();
|
|
63
|
-
return useMutation({
|
|
64
|
-
mutationFn: (data) => verifyIdNumber(rootLegalEntityId.value, baseUrl.value, data),
|
|
65
|
-
...options
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
|
-
const startVerificationCheck = async (rootLegalEntityId, baseUrl, data) => {
|
|
69
|
-
return httpPost(
|
|
70
|
-
{
|
|
71
|
-
baseUrl,
|
|
72
|
-
path: `legalEntities/${rootLegalEntityId}/providers/idVerification/process`
|
|
73
|
-
},
|
|
74
|
-
data
|
|
75
|
-
);
|
|
76
|
-
};
|
|
77
|
-
const useIdVerificationStartCheck = (options) => {
|
|
78
|
-
const { rootLegalEntityId, baseUrl } = useApiContext();
|
|
79
|
-
return useMutation({
|
|
80
|
-
mutationFn: (data) => startVerificationCheck(rootLegalEntityId.value, baseUrl.value, data),
|
|
81
|
-
...options
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
const nameValidationRulesV4 = {
|
|
85
|
-
firstName: [
|
|
86
|
-
{
|
|
87
|
-
modes: ["blur"],
|
|
88
|
-
validate: (input) => !matchesRegex(NO_ALPHABET_REGEX, input),
|
|
89
|
-
errorMessage: "nameMustContainLetters"
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
modes: ["blur"],
|
|
93
|
-
validate: (input) => !matchesRegex(EMOJI_REGEX, input) && !hasRepeatedCharacters(input) && !isInvalidName(input) && matchesRegex(INDIVIDUAL_VALID_CHAR_REGEX, input),
|
|
94
|
-
errorMessage: "checkForTypos"
|
|
95
|
-
}
|
|
96
|
-
],
|
|
97
|
-
lastName: [
|
|
98
|
-
{
|
|
99
|
-
modes: ["blur"],
|
|
100
|
-
validate: (input) => !matchesRegex(NO_ALPHABET_REGEX, input),
|
|
101
|
-
errorMessage: "nameMustContainLetters"
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
modes: ["blur"],
|
|
105
|
-
validate: (input) => !matchesRegex(EMOJI_REGEX, input) && !hasRepeatedCharacters(input) && !isInvalidName(input) && matchesRegex(INDIVIDUAL_VALID_CHAR_REGEX, input),
|
|
106
|
-
errorMessage: "checkForTypos"
|
|
107
|
-
}
|
|
108
|
-
]
|
|
109
|
-
};
|
|
110
|
-
const specialCharsRegEx = getFormattingRegEx(SPECIAL_CHARS.replace("-", ""));
|
|
111
|
-
const nameFormatters = {
|
|
112
|
-
firstName: {
|
|
113
|
-
// formatter: trimValWithOneSpace // just trim
|
|
114
|
-
// Example - removing disallowed chars as they are input: then they don't end up in state
|
|
115
|
-
formatter: (val) => val ? trimValWithOneSpace(val).replace(specialCharsRegEx, "") : void 0
|
|
116
|
-
// trim & replace
|
|
117
|
-
},
|
|
118
|
-
lastName: {
|
|
119
|
-
formatter: (val) => val ? trimValWithOneSpace(val).replace(specialCharsRegEx, "") : void 0
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
const customerSupportPresubmitProcess = (legalEntityResponse, legalEntityToSubmit) => {
|
|
123
|
-
if (legalEntityResponse.type === "individual") {
|
|
124
|
-
return processCustomerSupportForIndividual(legalEntityResponse, legalEntityToSubmit);
|
|
125
|
-
}
|
|
126
|
-
if (legalEntityResponse.type === "organization") {
|
|
127
|
-
return processCustomerSupportForOrganization(legalEntityResponse, legalEntityToSubmit);
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
const processCustomerSupportForOrganization = (legalEntityResponse, legalEntityToSubmit) => {
|
|
131
|
-
if (!legalEntityResponse.organization?.support) {
|
|
132
|
-
return legalEntityToSubmit.organization?.support ?? void 0;
|
|
133
|
-
}
|
|
134
|
-
if (legalEntityResponse.organization?.countryOfGoverningLaw !== legalEntityToSubmit.organization?.countryOfGoverningLaw) {
|
|
135
|
-
const customerSupport = legalEntityResponse.organization?.support;
|
|
136
|
-
const country = legalEntityToSubmit.organization?.countryOfGoverningLaw;
|
|
137
|
-
switch (country) {
|
|
138
|
-
case CountryCodes.Japan:
|
|
139
|
-
return unsetCustomerSupportNumber(customerSupport);
|
|
140
|
-
default:
|
|
141
|
-
return customerSupport;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
const processCustomerSupportForIndividual = (legalEntityResponse, legalEntityToSubmit) => {
|
|
146
|
-
if (!legalEntityResponse.individual?.support) {
|
|
147
|
-
return legalEntityToSubmit.individual?.support ?? void 0;
|
|
148
|
-
}
|
|
149
|
-
if (legalEntityResponse.individual?.residentialAddress.country !== legalEntityToSubmit.individual?.residentialAddress.country) {
|
|
150
|
-
const customerSupport = legalEntityResponse.individual?.support;
|
|
151
|
-
const country = legalEntityToSubmit.individual?.residentialAddress.country;
|
|
152
|
-
switch (country) {
|
|
153
|
-
case CountryCodes.Japan:
|
|
154
|
-
return unsetCustomerSupportNumber(customerSupport);
|
|
155
|
-
default:
|
|
156
|
-
return customerSupport;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
const unsetCustomerSupportNumber = (customerSupport) => {
|
|
161
|
-
return customerSupport ? {
|
|
162
|
-
email: customerSupport.email,
|
|
163
|
-
phone: { number: "", type: "mobile" }
|
|
164
|
-
} : void 0;
|
|
165
|
-
};
|
|
166
|
-
const onfidoDocumentTypeMapping = [
|
|
167
|
-
{ id: "driversLicense", name: "driversLicense", hasBackPage: true },
|
|
168
|
-
{ id: "identityCard", name: "identityCard", hasBackPage: true },
|
|
169
|
-
{ id: "passport", name: "passport", hasBackPage: false }
|
|
170
|
-
];
|
|
171
|
-
const jaHaniNameValidationRules = {
|
|
172
|
-
jaHaniFirstName: [
|
|
173
|
-
{
|
|
174
|
-
modes: ["blur"],
|
|
175
|
-
validate: (input) => standardKanjiValidator(input),
|
|
176
|
-
errorMessage: "nameMustContainLetters"
|
|
177
|
-
}
|
|
178
|
-
],
|
|
179
|
-
jaHaniLastName: [
|
|
180
|
-
{
|
|
181
|
-
modes: ["blur"],
|
|
182
|
-
validate: (input) => standardKanjiValidator(input),
|
|
183
|
-
errorMessage: "nameMustContainLetters"
|
|
184
|
-
}
|
|
185
|
-
]
|
|
186
|
-
};
|
|
187
|
-
const jaKanaNameValidationRules = {
|
|
188
|
-
jaKanaFirstName: [
|
|
189
|
-
{
|
|
190
|
-
modes: ["blur"],
|
|
191
|
-
validate: (input) => standardKatakanaValidator(input),
|
|
192
|
-
errorMessage: "nameMustContainLetters"
|
|
193
|
-
}
|
|
194
|
-
],
|
|
195
|
-
jaKanaLastName: [
|
|
196
|
-
{
|
|
197
|
-
modes: ["blur"],
|
|
198
|
-
validate: (input) => standardKatakanaValidator(input),
|
|
199
|
-
errorMessage: "nameMustContainLetters"
|
|
200
|
-
}
|
|
201
|
-
]
|
|
202
|
-
};
|
|
203
|
-
const isNotOutOfRangeBirthDateValidatorRule$1 = {
|
|
204
|
-
modes: ["blur"],
|
|
205
|
-
validate: (birthDate) => !isEmpty(birthDate) && new Date(birthDate) < /* @__PURE__ */ new Date(),
|
|
206
|
-
errorMessage: "invalidDateOfBirth"
|
|
207
|
-
};
|
|
208
|
-
const buildMinimumAgeValidationRule$1 = (minimumAge) => ({
|
|
209
|
-
modes: ["blur"],
|
|
210
|
-
validate: (birthDate) => !!birthDate && getAgeToday(birthDate) >= minimumAge,
|
|
211
|
-
errorMessage: {
|
|
212
|
-
key: "youMustXYearsOldToContinue",
|
|
213
|
-
values: { minimumAge: minimumAge.toString() }
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
const getCountrySpecificMinimumAgeValidationRule$1 = (country) => {
|
|
217
|
-
if (!country) {
|
|
218
|
-
return buildMinimumAgeValidationRule$1(13);
|
|
219
|
-
}
|
|
220
|
-
if ([...euCountries, CountryCodes.UnitedKingdom, CountryCodes.Switzerland].some(
|
|
221
|
-
(c) => c === country
|
|
222
|
-
)) {
|
|
223
|
-
return buildMinimumAgeValidationRule$1(16);
|
|
224
|
-
}
|
|
225
|
-
switch (country) {
|
|
226
|
-
case CountryCodes.HongKong:
|
|
227
|
-
case CountryCodes.Singapore:
|
|
228
|
-
return buildMinimumAgeValidationRule$1(18);
|
|
229
|
-
default:
|
|
230
|
-
return buildMinimumAgeValidationRule$1(13);
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
const personalDetailsValidators = ({
|
|
234
|
-
country,
|
|
235
|
-
isExperimentEnabled = () => false,
|
|
236
|
-
isSettingEnabled = () => false,
|
|
237
|
-
taskType,
|
|
238
|
-
idNumberType,
|
|
239
|
-
phonePrefix,
|
|
240
|
-
idNumberExempt,
|
|
241
|
-
idNumber,
|
|
242
|
-
existingIdNumber,
|
|
243
|
-
formVerificationErrors,
|
|
244
|
-
taxIdNumberType
|
|
245
|
-
}) => ({
|
|
246
|
-
taxInformation: resolveFieldMetadata(
|
|
247
|
-
taxInformationDefaultFieldConfig[country],
|
|
248
|
-
{
|
|
249
|
-
taxIdNumberType,
|
|
250
|
-
companyType: LegalEntityTypes.INDIVIDUAL
|
|
251
|
-
},
|
|
252
|
-
taxInformationDefaultFieldMetadata
|
|
253
|
-
)?.validators,
|
|
254
|
-
birthDate: (() => {
|
|
255
|
-
const baseValidators = [isNotOutOfRangeBirthDateValidatorRule$1];
|
|
256
|
-
if (isSettingEnabled("enforceLegalAge")) {
|
|
257
|
-
return [...baseValidators, buildMinimumAgeValidationRule$1(18)];
|
|
258
|
-
}
|
|
259
|
-
if (isExperimentEnabled("EnableAgeVerification")) {
|
|
260
|
-
if (taskType === TaskTypes.LEGAL_REPRESENTATIVE_DETAILS) {
|
|
261
|
-
return [...baseValidators, buildMinimumAgeValidationRule$1(18)];
|
|
262
|
-
}
|
|
263
|
-
return [...baseValidators, getCountrySpecificMinimumAgeValidationRule$1(country)];
|
|
264
|
-
}
|
|
265
|
-
return baseValidators;
|
|
266
|
-
})(),
|
|
267
|
-
...isExperimentEnabled("StrictNameAndAddressValidationV4") ? nameValidationRulesV4 : void 0,
|
|
268
|
-
...contactDetailsValidationRules,
|
|
269
|
-
phoneNumber: resolveFieldMetadata(
|
|
270
|
-
fieldConfig[phonePrefix ?? country],
|
|
271
|
-
{},
|
|
272
|
-
defaultFieldMetadata$1
|
|
273
|
-
)?.validators,
|
|
274
|
-
idNumber: (() => {
|
|
275
|
-
const derivedIdNumberType = country === CountryCodes.UnitedStates ? getSSNType(formVerificationErrors, existingIdNumber) : idNumberType;
|
|
276
|
-
return idNumberExempt ? {
|
|
277
|
-
validate: () => {
|
|
278
|
-
return idNumberExempt || !isEmpty(idNumber);
|
|
279
|
-
},
|
|
280
|
-
modes: ["blur"]
|
|
281
|
-
} : resolveFieldMetadata(
|
|
282
|
-
defaultFieldConfig[country],
|
|
283
|
-
{ idNumberType: derivedIdNumberType },
|
|
284
|
-
defaultFieldMetadata
|
|
285
|
-
)?.validators;
|
|
286
|
-
})(),
|
|
287
|
-
...jaHaniNameValidationRules,
|
|
288
|
-
...jaKanaNameValidationRules
|
|
289
|
-
});
|
|
290
|
-
const mandateIdVerificationForMotionCapture = (showMotionCapture, derivedProps) => {
|
|
291
|
-
if (!derivedProps) {
|
|
292
|
-
return void 0;
|
|
293
|
-
}
|
|
294
|
-
const copiedDerivedProps = { ...derivedProps };
|
|
295
|
-
if (showMotionCapture) {
|
|
296
|
-
const idVerificationFields = [
|
|
297
|
-
...derivedProps.requiredFields.idVerificationMethod ?? [],
|
|
298
|
-
"idVerificationMethod"
|
|
299
|
-
];
|
|
300
|
-
copiedDerivedProps.allFields.idVerificationMethod = idVerificationFields;
|
|
301
|
-
copiedDerivedProps.requiredFields.idVerificationMethod = idVerificationFields;
|
|
302
|
-
}
|
|
303
|
-
return copiedDerivedProps;
|
|
304
|
-
};
|
|
305
|
-
const mapApiDocumentToIndividualDocuments = (entityId) => {
|
|
306
|
-
const idDocument2 = getIdDocument(entityId);
|
|
307
|
-
const proofOfResidency = getDocument(entityId, "proofOfResidency");
|
|
308
|
-
const proofOfNationalId = getDocument(entityId, "proofOfNationalIdNumber");
|
|
309
|
-
const proofOfRelationship = getDocument(entityId, "proofOfRelationship");
|
|
310
|
-
return {
|
|
311
|
-
idDocument: idDocument2 ? mapApiIdDocumentToSchema(idDocument2) : void 0,
|
|
312
|
-
proofOfResidency: proofOfResidency ? { proofOfResidency: [mapExistingFile(getPageName(proofOfResidency))] } : void 0,
|
|
313
|
-
proofOfNationalId: proofOfNationalId ? { proofOfNationalId: [mapExistingFile(getPageName(proofOfNationalId))] } : void 0,
|
|
314
|
-
proofOfRelationship: proofOfRelationship ? { proofOfRelationship: [mapExistingFile(getPageName(proofOfRelationship))] } : void 0
|
|
315
|
-
};
|
|
316
|
-
};
|
|
317
|
-
const mapApiIdDocumentToSchema = (idDocument2) => {
|
|
318
|
-
const { type, attachments, modificationDate } = idDocument2;
|
|
319
|
-
const { hasBackPage } = getLocalizedIdDocumentTypeOptions().find(({ id }) => id === type);
|
|
320
|
-
let frontPage;
|
|
321
|
-
let backPage;
|
|
322
|
-
if (attachments?.length === 1) {
|
|
323
|
-
frontPage = getPage(idDocument2);
|
|
324
|
-
} else {
|
|
325
|
-
frontPage = hasBackPage ? getPage(idDocument2, "front") : getPage(idDocument2);
|
|
326
|
-
backPage = hasBackPage ? getPage(idDocument2, "back") : void 0;
|
|
327
|
-
}
|
|
328
|
-
return {
|
|
329
|
-
...frontPage ? { idFrontPage: [mapExistingFile(frontPage.pageName ?? "")] } : {},
|
|
330
|
-
...backPage ? { idBackPage: [mapExistingFile(backPage.pageName ?? "")] } : {},
|
|
331
|
-
idDocumentType: type,
|
|
332
|
-
modificationDate
|
|
333
|
-
};
|
|
334
|
-
};
|
|
335
|
-
const mapIndividualDocumentToApiDocument = async (data, entityId) => {
|
|
336
|
-
if (!data) return void 0;
|
|
337
|
-
const { proofOfNationalId, proofOfResidency, proofOfRelationship } = data;
|
|
338
|
-
const idDocument2 = "idDocument" in data ? data.idDocument : data.manualIdUpload;
|
|
339
|
-
const entityType = "legalEntity";
|
|
340
|
-
const documents = await Promise.all([
|
|
341
|
-
idDocument2?.idFrontPage ? createDocumentRequest({
|
|
342
|
-
entityId,
|
|
343
|
-
entityType,
|
|
344
|
-
documentType: idDocument2.idDocumentType,
|
|
345
|
-
page1: idDocument2.idFrontPage?.[0],
|
|
346
|
-
page2: idDocument2.idBackPage?.[0]
|
|
347
|
-
}) : void 0,
|
|
348
|
-
proofOfNationalId?.proofOfNationalId ? createDocumentRequest({
|
|
349
|
-
entityId,
|
|
350
|
-
entityType,
|
|
351
|
-
documentType: "proofOfNationalIdNumber",
|
|
352
|
-
page1: proofOfNationalId.proofOfNationalId[0]
|
|
353
|
-
}) : void 0,
|
|
354
|
-
proofOfResidency?.proofOfResidency ? createDocumentRequest({
|
|
355
|
-
entityId,
|
|
356
|
-
entityType,
|
|
357
|
-
documentType: "proofOfResidency",
|
|
358
|
-
description: proofOfResidency?.description,
|
|
359
|
-
page1: proofOfResidency.proofOfResidency[0]
|
|
360
|
-
}) : void 0,
|
|
361
|
-
proofOfRelationship?.proofOfRelationship ? createDocumentRequest({
|
|
362
|
-
entityId,
|
|
363
|
-
entityType,
|
|
364
|
-
documentType: "proofOfRelationship",
|
|
365
|
-
description: proofOfRelationship?.description,
|
|
366
|
-
page1: proofOfRelationship.proofOfRelationship[0]
|
|
367
|
-
}) : void 0
|
|
368
|
-
]);
|
|
369
|
-
return documents.filter(Boolean);
|
|
370
|
-
};
|
|
371
|
-
const getIdentityTypeToApiIdentityTypeMap = (data) => {
|
|
372
|
-
const { residencyCountry } = data;
|
|
373
|
-
switch (residencyCountry) {
|
|
374
|
-
case CountryCodes.HongKong:
|
|
375
|
-
return {
|
|
376
|
-
passport: "passport",
|
|
377
|
-
driversLicense: "driversLicense",
|
|
378
|
-
proofOfIdentityCard: "nationalIdNumber"
|
|
379
|
-
};
|
|
380
|
-
default:
|
|
381
|
-
return {
|
|
382
|
-
nationalIdNumber: "nationalIdNumber",
|
|
383
|
-
passport: "passport",
|
|
384
|
-
driversLicense: "driversLicense",
|
|
385
|
-
proofOfIdentityCard: "identityCard"
|
|
386
|
-
};
|
|
387
|
-
}
|
|
388
|
-
};
|
|
389
|
-
const adjustIdentificationData = (data, apiData) => {
|
|
390
|
-
const { typeOfIdentity, idNumber, idNumberExempt } = data;
|
|
391
|
-
const identificationData = {
|
|
392
|
-
...apiData,
|
|
393
|
-
number: idNumber,
|
|
394
|
-
type: getIdentityTypeToApiIdentityTypeMap(data)[typeOfIdentity] ?? "nationalIdNumber"
|
|
395
|
-
};
|
|
396
|
-
switch (typeOfIdentity) {
|
|
397
|
-
case "passport":
|
|
398
|
-
return {
|
|
399
|
-
...identificationData,
|
|
400
|
-
cardNumber: ""
|
|
401
|
-
};
|
|
402
|
-
case "driversLicense":
|
|
403
|
-
return {
|
|
404
|
-
...identificationData,
|
|
405
|
-
expiryDate: ""
|
|
406
|
-
};
|
|
407
|
-
default:
|
|
408
|
-
return idNumber === void 0 && idNumberExempt === void 0 ? void 0 : {
|
|
409
|
-
...identificationData,
|
|
410
|
-
expiryDate: "",
|
|
411
|
-
cardNumber: "",
|
|
412
|
-
nationalIdExempt: apiData?.nationalIdExempt ?? !idNumber
|
|
413
|
-
};
|
|
414
|
-
}
|
|
415
|
-
};
|
|
416
|
-
const mapIndividualToLegalEntity = (data) => {
|
|
417
|
-
const requestObj = {
|
|
418
|
-
...formatObject(data, individualApiKeyMapping)
|
|
419
|
-
};
|
|
420
|
-
requestObj.type = LegalEntityTypes.INDIVIDUAL;
|
|
421
|
-
const { personalDetails } = data;
|
|
422
|
-
if (!personalDetails) return requestObj;
|
|
423
|
-
requestObj.individual.identificationData = adjustIdentificationData(
|
|
424
|
-
personalDetails,
|
|
425
|
-
requestObj.individual.identificationData
|
|
426
|
-
);
|
|
427
|
-
const localization = [
|
|
428
|
-
mapSchemaFieldsToApiScriptLocalization(personalDetails, "jaHani"),
|
|
429
|
-
mapSchemaFieldsToApiScriptLocalization(personalDetails, "jaKana")
|
|
430
|
-
].filter(({ fields }) => !isEmpty$1(fields));
|
|
431
|
-
if (localization.length) {
|
|
432
|
-
requestObj.individual.name.localization = localization;
|
|
433
|
-
}
|
|
434
|
-
if (personalDetails.phoneNumber?.number) {
|
|
435
|
-
requestObj.individual.phone = {
|
|
436
|
-
number: personalDetails.phoneNumber.number,
|
|
437
|
-
type: "mobile"
|
|
438
|
-
};
|
|
439
|
-
} else {
|
|
440
|
-
delete requestObj.individual.phone;
|
|
441
|
-
}
|
|
442
|
-
return requestObj;
|
|
443
|
-
};
|
|
444
|
-
const mapLegalEntityToIndividual = (legalEntity, isChangingType, isRoleFieldNeeded, parentLegalEntity, isLegalRepresentative) => {
|
|
445
|
-
let individualData = formatObject(
|
|
446
|
-
legalEntity,
|
|
447
|
-
individualComponentsKeyMapping
|
|
448
|
-
);
|
|
449
|
-
individualData = {
|
|
450
|
-
...individualData,
|
|
451
|
-
personalDetails: {
|
|
452
|
-
...individualData?.personalDetails,
|
|
453
|
-
...isChangingType && {
|
|
454
|
-
firstName: "",
|
|
455
|
-
lastName: ""
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
};
|
|
459
|
-
if (!individualData.personalDetails?.idNumberExempt) {
|
|
460
|
-
individualData.personalDetails.idNumberExempt = false;
|
|
461
|
-
}
|
|
462
|
-
const apiIdentityTypeToIdentityTypeMap = reverseMapping(
|
|
463
|
-
getIdentityTypeToApiIdentityTypeMap(individualData.personalDetails)
|
|
464
|
-
);
|
|
465
|
-
if (legalEntity?.individual?.identificationData?.type) {
|
|
466
|
-
individualData.personalDetails.typeOfIdentity = apiIdentityTypeToIdentityTypeMap[legalEntity.individual.identificationData.type];
|
|
467
|
-
}
|
|
468
|
-
if (legalEntity?.documentDetails?.length) {
|
|
469
|
-
individualData = {
|
|
470
|
-
...individualData,
|
|
471
|
-
...mapApiDocumentToIndividualDocuments(legalEntity?.id)
|
|
472
|
-
};
|
|
473
|
-
}
|
|
474
|
-
if (legalEntity?.individual?.residentialAddress.country === "JP" && legalEntity.individual?.name?.localization) {
|
|
475
|
-
for (const scriptLoc of legalEntity.individual.name.localization) {
|
|
476
|
-
individualData.personalDetails = {
|
|
477
|
-
...individualData.personalDetails,
|
|
478
|
-
...mapApiScriptLocalizationToSchemaFields(scriptLoc)
|
|
479
|
-
};
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
if (!parentLegalEntity?.entityAssociations) {
|
|
483
|
-
return individualData;
|
|
484
|
-
}
|
|
485
|
-
const associations = parentLegalEntity?.entityAssociations?.filter((ea) => ea.legalEntityId === legalEntity?.id) ?? [];
|
|
486
|
-
if (isRoleFieldNeeded) {
|
|
487
|
-
individualData.personalDetails.role = associations.map((ea) => ea.type);
|
|
488
|
-
individualData.personalDetails.jobTitle = associations.find(
|
|
489
|
-
({ jobTitle }) => Boolean(jobTitle)
|
|
490
|
-
)?.jobTitle;
|
|
491
|
-
}
|
|
492
|
-
individualData.personalDetails = getNomineeFromAssociation(
|
|
493
|
-
associations,
|
|
494
|
-
individualData.personalDetails
|
|
495
|
-
);
|
|
496
|
-
if (isLegalRepresentative) {
|
|
497
|
-
individualData.personalDetails.relationship = associations.find(
|
|
498
|
-
({ relationship }) => Boolean(relationship)
|
|
499
|
-
)?.relationship;
|
|
500
|
-
}
|
|
501
|
-
return individualData;
|
|
502
|
-
};
|
|
503
|
-
const identityBase = {
|
|
504
|
-
role: {
|
|
505
|
-
rule: "requiredIfDecisionMakerTask"
|
|
506
|
-
},
|
|
507
|
-
firstName: {
|
|
508
|
-
rule: "REQUIRED"
|
|
509
|
-
},
|
|
510
|
-
lastName: {
|
|
511
|
-
rule: "REQUIRED"
|
|
512
|
-
},
|
|
513
|
-
birthDate: {
|
|
514
|
-
rule: "REQUIRED"
|
|
515
|
-
},
|
|
516
|
-
phoneNumber: {
|
|
517
|
-
rules: ["requiredIfPhoneScenarioDisabled", "contactsIfRequiredForRole"]
|
|
518
|
-
},
|
|
519
|
-
email: {
|
|
520
|
-
rule: "contactsIfRequiredForRole"
|
|
521
|
-
},
|
|
522
|
-
jobTitle: {
|
|
523
|
-
rule: "jobTitleIfRequiredForRole"
|
|
524
|
-
},
|
|
525
|
-
nationality: {
|
|
526
|
-
rule: "nationalityIfRequiredForRole"
|
|
527
|
-
},
|
|
528
|
-
address: {
|
|
529
|
-
rule: "addressIfRequiredForCountry"
|
|
530
|
-
},
|
|
531
|
-
otherAddressInformation: {
|
|
532
|
-
rule: "otherAddressInfoIfRequiredForCountry"
|
|
533
|
-
},
|
|
534
|
-
country: {
|
|
535
|
-
rule: "REQUIRED"
|
|
536
|
-
},
|
|
537
|
-
postalCode: {
|
|
538
|
-
rule: "postalCodeIfRequiredForCountry"
|
|
539
|
-
},
|
|
540
|
-
city: {
|
|
541
|
-
rule: "cityIfRequiredForCountry"
|
|
542
|
-
},
|
|
543
|
-
stateOrProvince: {
|
|
544
|
-
rule: "stateOrProvinceIfRequiredForCountry"
|
|
545
|
-
},
|
|
546
|
-
residencyCountry: {
|
|
547
|
-
rule: "REQUIRED"
|
|
548
|
-
},
|
|
549
|
-
proofOfResidency: {
|
|
550
|
-
rule: "isProofOfResidencyRequired"
|
|
551
|
-
},
|
|
552
|
-
proofOfNationalId: {
|
|
553
|
-
rule: "isProofOfNationalIdRequired"
|
|
554
|
-
},
|
|
555
|
-
relationship: {
|
|
556
|
-
rule: "legalRepresentativeRelationshipRequired"
|
|
557
|
-
},
|
|
558
|
-
proofOfRelationship: {
|
|
559
|
-
rule: "isProofOfRelationshipRequired"
|
|
560
|
-
},
|
|
561
|
-
nomineeDirector: {
|
|
562
|
-
rule: "nomineeDirectorRequiredForCountry"
|
|
563
|
-
},
|
|
564
|
-
nomineeShareholder: {
|
|
565
|
-
rule: "nomineeShareHolderRequiredForCountry"
|
|
566
|
-
},
|
|
567
|
-
jaHaniFirstName: {
|
|
568
|
-
rule: "japaneseFirstAndLastNames"
|
|
569
|
-
},
|
|
570
|
-
jaHaniLastName: {
|
|
571
|
-
rule: "japaneseFirstAndLastNames"
|
|
572
|
-
},
|
|
573
|
-
jaKanaFirstName: {
|
|
574
|
-
rule: "japaneseFirstAndLastNames"
|
|
575
|
-
},
|
|
576
|
-
jaKanaLastName: {
|
|
577
|
-
rule: "japaneseFirstAndLastNames"
|
|
578
|
-
},
|
|
579
|
-
idDocumentType: {
|
|
580
|
-
// If the user has a missing ID error and chooses manual flow
|
|
581
|
-
rule: "isManualIdFlowAndHasMissingData"
|
|
582
|
-
}
|
|
583
|
-
};
|
|
584
|
-
const identityNumber$1 = {
|
|
585
|
-
idNumber: {
|
|
586
|
-
rule: "idNumberRules",
|
|
587
|
-
obscured: true
|
|
588
|
-
},
|
|
589
|
-
idNumberExempt: {
|
|
590
|
-
rules: ["idNumberExemptIfApplicableCountry", "isDirectorIdNumberRequiredForCountry"]
|
|
591
|
-
},
|
|
592
|
-
idDocumentType: {
|
|
593
|
-
rule: "manualIdDocumentRequired"
|
|
594
|
-
},
|
|
595
|
-
idFrontPage: {
|
|
596
|
-
rule: "idFrontPageIfManualUpload"
|
|
597
|
-
},
|
|
598
|
-
idBackPage: {
|
|
599
|
-
rule: "backPageIfRequiredForDocumentType"
|
|
600
|
-
},
|
|
601
|
-
idVerificationMethod: {
|
|
602
|
-
rule: "idVerificationRequired"
|
|
603
|
-
},
|
|
604
|
-
instantIdVerificationData: {
|
|
605
|
-
rule: "instantVerificationDataRule"
|
|
606
|
-
}
|
|
607
|
-
};
|
|
608
|
-
const additionalIdentityInfo$1 = {
|
|
609
|
-
typeOfIdentity: {
|
|
610
|
-
rules: ["requiredIfCountryUsesMultipleTypesOfIdentity", "isDirectorIdNumberRequiredForCountry"]
|
|
611
|
-
},
|
|
612
|
-
issuerState: {
|
|
613
|
-
rule: "issuerStateRequired"
|
|
614
|
-
},
|
|
615
|
-
licenseCardNumber: {
|
|
616
|
-
rule: "licenseCardNumberRules"
|
|
617
|
-
},
|
|
618
|
-
expiryDate: {
|
|
619
|
-
rule: "expiryDateRequired"
|
|
620
|
-
}
|
|
621
|
-
};
|
|
622
|
-
const idDocument = {
|
|
623
|
-
idVerificationMethod: {
|
|
624
|
-
rule: "REQUIRED"
|
|
625
|
-
},
|
|
626
|
-
idDocumentType: {
|
|
627
|
-
rule: "REQUIRED"
|
|
628
|
-
},
|
|
629
|
-
idFrontPage: {
|
|
630
|
-
rule: "idFrontPageIfManualUpload"
|
|
631
|
-
},
|
|
632
|
-
idBackPage: {
|
|
633
|
-
rule: "backPageIfRequiredForDocumentType"
|
|
634
|
-
}
|
|
635
|
-
};
|
|
636
|
-
const nationality$1 = {
|
|
637
|
-
nationality: {
|
|
638
|
-
rule: "REQUIRED"
|
|
639
|
-
}
|
|
640
|
-
};
|
|
641
|
-
const phoneNumberBase$1 = {
|
|
642
|
-
phoneNumber: {
|
|
643
|
-
rule: "contactsIfRequiredForRole"
|
|
644
|
-
}
|
|
645
|
-
};
|
|
646
|
-
const taxInformationBase$1 = {
|
|
647
|
-
taxInformation: { rule: "countryUsesTaxId" }
|
|
648
|
-
};
|
|
649
|
-
const fieldsPerScenario = {
|
|
650
|
-
L0: drop("address", "birthDate").from(identityBase),
|
|
651
|
-
L1: identityBase,
|
|
652
|
-
L_TAXINFO: { ...identityBase, ...taxInformationBase$1 },
|
|
653
|
-
L1_ID: {
|
|
654
|
-
...identityBase,
|
|
655
|
-
...identityNumber$1,
|
|
656
|
-
...additionalIdentityInfo$1
|
|
657
|
-
},
|
|
658
|
-
L1_IDO: {
|
|
659
|
-
// TODO: change idNumber rule to optional once optional fields are implemented
|
|
660
|
-
...identityBase,
|
|
661
|
-
...identityNumber$1,
|
|
662
|
-
...additionalIdentityInfo$1
|
|
663
|
-
},
|
|
664
|
-
L1_NAT: {
|
|
665
|
-
...identityBase,
|
|
666
|
-
...identityNumber$1,
|
|
667
|
-
...additionalIdentityInfo$1,
|
|
668
|
-
...nationality$1
|
|
669
|
-
},
|
|
670
|
-
L1_IDDOC: idDocument,
|
|
671
|
-
L_PH: phoneNumberBase$1
|
|
672
|
-
};
|
|
673
|
-
const parseIndividualScenarios = (scenarios) => composePerScenarioFormConfigurations(scenarios, fieldsPerScenario);
|
|
674
|
-
const parseConfiguration$1 = ({ scenarios }) => parseIndividualScenarios(scenarios);
|
|
675
|
-
const logger$1 = createLogger();
|
|
676
|
-
function IndividualDropin({
|
|
677
|
-
taskType = TaskTypes.INDIVIDUAL,
|
|
678
|
-
parentLegalEntity,
|
|
679
|
-
legalEntityResponse,
|
|
680
|
-
handleHomeClick,
|
|
681
|
-
isTargetLegalEntityType,
|
|
682
|
-
country: parentCountry,
|
|
683
|
-
problems: propProblems,
|
|
684
|
-
trustMember,
|
|
685
|
-
onSubmit: externalOnSubmit,
|
|
686
|
-
asModal = false,
|
|
687
|
-
handleBackClick: externalBackClick,
|
|
688
|
-
trustedFields,
|
|
689
|
-
trustedFieldsProvider,
|
|
690
|
-
trustedRoles
|
|
691
|
-
}) {
|
|
692
|
-
const { baseUrl, rootLegalEntityId } = useApiContext();
|
|
693
|
-
const { accountHolder, setAccountHolder } = useAccountHolder();
|
|
694
|
-
const { i18n } = useI18nContext();
|
|
695
|
-
const userEvents = useAnalyticsContext();
|
|
696
|
-
const { showToast, clearToasts } = useToastContext();
|
|
697
|
-
const { isExperimentEnabled } = useExperimentsContext();
|
|
698
|
-
const { data: versionData } = useVersionConfiguration();
|
|
699
|
-
const { isSettingEnabled } = useSettingsContext();
|
|
700
|
-
const isRoleFieldNeeded = taskType === TaskTypes.DECISION_MAKER || taskType === TaskTypes.TRUST_MEMBER_COMPANY_OWNER || taskType === TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY_OWNER;
|
|
701
|
-
const isLegalRepresentative = taskType === TaskTypes.LEGAL_REPRESENTATIVE_DETAILS;
|
|
702
|
-
const dataFromResponse = useMemo(() => {
|
|
703
|
-
if (legalEntityResponse) {
|
|
704
|
-
return mapLegalEntityToIndividual(
|
|
705
|
-
legalEntityResponse,
|
|
706
|
-
isTargetLegalEntityType,
|
|
707
|
-
isRoleFieldNeeded,
|
|
708
|
-
parentLegalEntity,
|
|
709
|
-
isLegalRepresentative
|
|
710
|
-
);
|
|
711
|
-
}
|
|
712
|
-
return {
|
|
713
|
-
personalDetails: {
|
|
714
|
-
residencyCountry: parentCountry
|
|
715
|
-
},
|
|
716
|
-
address: {
|
|
717
|
-
country: parentCountry
|
|
718
|
-
}
|
|
719
|
-
};
|
|
720
|
-
}, [
|
|
721
|
-
legalEntityResponse,
|
|
722
|
-
parentCountry,
|
|
723
|
-
isTargetLegalEntityType,
|
|
724
|
-
parentLegalEntity,
|
|
725
|
-
isRoleFieldNeeded,
|
|
726
|
-
isLegalRepresentative
|
|
727
|
-
]);
|
|
728
|
-
const documentUtils = documentApiUtils({
|
|
729
|
-
baseUrl: baseUrl.value,
|
|
730
|
-
rootLegalEntityId: rootLegalEntityId.value
|
|
731
|
-
});
|
|
732
|
-
let roleTypes = [];
|
|
733
|
-
const [matchingScenario, setMatchingScenario] = useState();
|
|
734
|
-
const [validationErrors, setValidationErrors] = useState();
|
|
735
|
-
const [loadingStatus, setLoadingStatus] = useState("success");
|
|
736
|
-
const [documents, setDocuments] = useState();
|
|
737
|
-
const [existingAttachments, setExistingAttachments] = useState();
|
|
738
|
-
const [country, setCountry] = useState(
|
|
739
|
-
dataFromResponse?.personalDetails?.residencyCountry ?? parentCountry
|
|
740
|
-
);
|
|
741
|
-
const [hideFooter, setHideFooter] = useState(false);
|
|
742
|
-
const [derivedProps, setDerivedProps] = useState();
|
|
743
|
-
const associatedLegalEntityTrustedFields = useMemo(
|
|
744
|
-
() => legalEntityResponse ? getTrustedFields(legalEntityResponse, individualComponentsKeyMapping) : {},
|
|
745
|
-
[legalEntityResponse]
|
|
746
|
-
);
|
|
747
|
-
const { data: providerStatus } = useProviderStatus({
|
|
748
|
-
providers: ["address", "idDocument"],
|
|
749
|
-
country: legalEntityResponse ? getLegalEntityCountry(legalEntityResponse) : country
|
|
750
|
-
});
|
|
751
|
-
const problems = useMemo(
|
|
752
|
-
() => ({
|
|
753
|
-
...propProblems,
|
|
754
|
-
validationErrors
|
|
755
|
-
}),
|
|
756
|
-
[propProblems, validationErrors]
|
|
757
|
-
);
|
|
758
|
-
useEffect(() => {
|
|
759
|
-
userEvents.updateBaseTrackingPayload({ task: taskType });
|
|
760
|
-
userEvents.addTaskEvent("Landed on page", {
|
|
761
|
-
actionType: "start"
|
|
762
|
-
});
|
|
763
|
-
}, []);
|
|
764
|
-
const individualFieldValidations = useCallback(
|
|
765
|
-
(data2) => ({
|
|
766
|
-
personalDetails: personalDetailsValidators({
|
|
767
|
-
country: data2?.personalDetails?.residencyCountry ?? country,
|
|
768
|
-
isExperimentEnabled,
|
|
769
|
-
isSettingEnabled,
|
|
770
|
-
taskType,
|
|
771
|
-
idNumberType: data2?.personalDetails?.typeOfIdentity,
|
|
772
|
-
phonePrefix: data2?.personalDetails?.phoneNumber?.phoneCountryCode,
|
|
773
|
-
idNumberExempt: data2?.personalDetails?.idNumberExempt,
|
|
774
|
-
idNumber: data2?.personalDetails?.idNumber,
|
|
775
|
-
existingIdNumber: dataFromResponse.personalDetails?.idNumber,
|
|
776
|
-
formVerificationErrors: propProblems?.verificationErrors?.personalDetails,
|
|
777
|
-
taxIdNumberType: data2?.personalDetails?.taxInformation?.length ? data2?.personalDetails?.taxInformation[0]?.type : void 0
|
|
778
|
-
}),
|
|
779
|
-
address: addressValidators({
|
|
780
|
-
isExperimentEnabled,
|
|
781
|
-
country: data2?.personalDetails?.residencyCountry ?? country,
|
|
782
|
-
i18n
|
|
783
|
-
})
|
|
784
|
-
}),
|
|
785
|
-
[isExperimentEnabled, isSettingEnabled, taskType]
|
|
786
|
-
);
|
|
787
|
-
const validatePhoneNumber = useValidatePhoneNumberImperatively();
|
|
788
|
-
const { mutateAsync: verifyIdNumber2 } = useVerifyIdNumber();
|
|
789
|
-
const individualFieldAsyncValidations = useCallback(
|
|
790
|
-
(data2) => ({
|
|
791
|
-
personalDetails: {
|
|
792
|
-
phoneNumber: getAsyncPhoneValidationRules(validatePhoneNumber).phoneNumber,
|
|
793
|
-
idNumber: getAsyncIdNumberValidationRule(verifyIdNumber2, data2?.personalDetails).idNumber
|
|
794
|
-
}
|
|
795
|
-
}),
|
|
796
|
-
[getAsyncPhoneValidationRules, getAsyncIdNumberValidationRule]
|
|
797
|
-
);
|
|
798
|
-
const defaultData = useMemo(
|
|
799
|
-
() => ({
|
|
800
|
-
...dataFromResponse,
|
|
801
|
-
...documents,
|
|
802
|
-
idVerificationMethod: {
|
|
803
|
-
idVerificationMethod: "instantVerification"
|
|
804
|
-
}
|
|
805
|
-
}),
|
|
806
|
-
[legalEntityResponse, documents, isTargetLegalEntityType, dataFromResponse]
|
|
807
|
-
);
|
|
808
|
-
const formatters = useMemo(
|
|
809
|
-
() => ({
|
|
810
|
-
personalDetails: {
|
|
811
|
-
...nameFormatters
|
|
812
|
-
},
|
|
813
|
-
address: addressFormatters
|
|
814
|
-
}),
|
|
815
|
-
[]
|
|
816
|
-
);
|
|
817
|
-
const form = useMultiForm({
|
|
818
|
-
requiredFields: derivedProps?.requiredFields,
|
|
819
|
-
defaultData,
|
|
820
|
-
rules: individualFieldValidations,
|
|
821
|
-
asyncRules: individualFieldAsyncValidations,
|
|
822
|
-
optionalFields: derivedProps?.optionalFields,
|
|
823
|
-
formatters,
|
|
824
|
-
obscuredFields: {
|
|
825
|
-
personalDetails: ["idNumber"]
|
|
826
|
-
}
|
|
827
|
-
});
|
|
828
|
-
const { data = dataFromResponse } = form;
|
|
829
|
-
useEffect(() => {
|
|
830
|
-
setCountry(data?.personalDetails?.residencyCountry ?? parentCountry);
|
|
831
|
-
}, [data?.personalDetails?.residencyCountry, parentCountry]);
|
|
832
|
-
const { data: scenarios } = useScenarios(country, LegalEntityTypes.INDIVIDUAL);
|
|
833
|
-
useEffect(() => {
|
|
834
|
-
if (!scenarios) return;
|
|
835
|
-
setHasMotionCaptureScenario(scenarios);
|
|
836
|
-
setMatchingScenario(scenarios);
|
|
837
|
-
}, [scenarios]);
|
|
838
|
-
const { fieldConfigurations } = useScenarioConfiguration({
|
|
839
|
-
parseConfiguration: parseConfiguration$1,
|
|
840
|
-
legalEntityType: LegalEntityTypes.INDIVIDUAL,
|
|
841
|
-
setLoadingStatus,
|
|
842
|
-
country
|
|
843
|
-
});
|
|
844
|
-
const fieldsFromCustomRules = useMemo(
|
|
845
|
-
() => rules({
|
|
846
|
-
matchingScenario,
|
|
847
|
-
data,
|
|
848
|
-
country: data?.personalDetails?.residencyCountry ?? country,
|
|
849
|
-
taskType,
|
|
850
|
-
isExperimentEnabled,
|
|
851
|
-
rootLegalEntity: parentLegalEntity,
|
|
852
|
-
problems,
|
|
853
|
-
version: versionData?.version
|
|
854
|
-
}),
|
|
855
|
-
[country, matchingScenario, data, taskType, problems]
|
|
856
|
-
);
|
|
857
|
-
useEffect(() => {
|
|
858
|
-
const derivedProps2 = getPropsFromConfigurations({
|
|
859
|
-
scenarioConfiguration: fieldConfigurations,
|
|
860
|
-
forms: individualForms,
|
|
861
|
-
remediationActions: problems?.remediationActions ? Object.values(problems?.remediationActions) : [],
|
|
862
|
-
dataMissingErrors: problems?.missingData ?? [],
|
|
863
|
-
fieldsWithExistingData: legalEntityResponse ? getFieldsWithExistingData(
|
|
864
|
-
legalEntityResponse,
|
|
865
|
-
individualApiKeyMapping,
|
|
866
|
-
individualDocumentMapping,
|
|
867
|
-
// We ignore these fields for the purposes of this rule because we know them to be problematic
|
|
868
|
-
[
|
|
869
|
-
"personalDetails.typeOfIdentity",
|
|
870
|
-
"personalDetails.idNumber",
|
|
871
|
-
"address.stateOrProvince",
|
|
872
|
-
"personalDetails.issuerState"
|
|
873
|
-
]
|
|
874
|
-
) : [],
|
|
875
|
-
customRules: fieldsFromCustomRules,
|
|
876
|
-
legalEntityType: legalEntityResponse?.type,
|
|
877
|
-
legalEntityTrustedFields: [],
|
|
878
|
-
remediationFieldAsOptional: true
|
|
879
|
-
});
|
|
880
|
-
const updatedDerivedProps = mandateIdVerificationForMotionCapture(
|
|
881
|
-
showIndividualMotionCapture?.value,
|
|
882
|
-
derivedProps2
|
|
883
|
-
);
|
|
884
|
-
setDerivedProps(updatedDerivedProps);
|
|
885
|
-
}, [
|
|
886
|
-
fieldConfigurations,
|
|
887
|
-
legalEntityResponse,
|
|
888
|
-
fieldsFromCustomRules,
|
|
889
|
-
problems?.remediationActions,
|
|
890
|
-
problems?.missingData
|
|
891
|
-
]);
|
|
892
|
-
const forms = useMemo(() => {
|
|
893
|
-
const formsWithUpdatedName = {
|
|
894
|
-
...individualForms,
|
|
895
|
-
idDocument: {
|
|
896
|
-
...individualForms.idDocument,
|
|
897
|
-
formName: data.idVerificationMethod?.idVerificationMethod === "instantVerification" ? "instantVerification" : "idDocument"
|
|
898
|
-
}
|
|
899
|
-
};
|
|
900
|
-
const requiredForms = getRequiredForms(
|
|
901
|
-
formsWithUpdatedName,
|
|
902
|
-
derivedProps?.requiredFields,
|
|
903
|
-
derivedProps?.optionalFields
|
|
904
|
-
).filter(
|
|
905
|
-
// Prevent showing the ID verification method step when onfido is not enabled
|
|
906
|
-
(form2) => form2.formId !== "idVerificationMethod" || providerStatus?.statuses?.idDocument?.enabled
|
|
907
|
-
);
|
|
908
|
-
return addValidityToForms(requiredForms, form.isValid, problems);
|
|
909
|
-
}, [
|
|
910
|
-
derivedProps,
|
|
911
|
-
form.isValid,
|
|
912
|
-
problems,
|
|
913
|
-
providerStatus?.statuses?.idDocument?.enabled,
|
|
914
|
-
data.idVerificationMethod?.idVerificationMethod
|
|
915
|
-
]);
|
|
916
|
-
if (isRoleFieldNeeded && parentLegalEntity) {
|
|
917
|
-
roleTypes = getAllowedDecisionMakerRoles(parentLegalEntity, taskType);
|
|
918
|
-
}
|
|
919
|
-
useEffect(() => {
|
|
920
|
-
if (!legalEntityResponse?.documentDetails?.length) return;
|
|
921
|
-
documentUtils.fetchDocuments(legalEntityResponse.documentDetails, legalEntityResponse?.id).then((res) => {
|
|
922
|
-
setExistingAttachments(res[0].attachments);
|
|
923
|
-
setDocuments(mapApiDocumentToIndividualDocuments(legalEntityResponse?.id));
|
|
924
|
-
}).catch(() => {
|
|
925
|
-
showToast({ label: i18n.get("failedToFetchRelevantDocuments"), variant: "error" });
|
|
926
|
-
});
|
|
927
|
-
}, [legalEntityResponse]);
|
|
928
|
-
const { mutateAsync: createLegalEntity } = useCreateLegalEntity();
|
|
929
|
-
const { mutateAsync: updateLegalEntity } = useUpdateLegalEntity();
|
|
930
|
-
const idDocumentTypeOptions = getLocalizedIdDocumentTypeOptions(country);
|
|
931
|
-
const submitLegalEntity = async ({
|
|
932
|
-
dataSubmitted,
|
|
933
|
-
legalEntity,
|
|
934
|
-
idDocumentType
|
|
935
|
-
}) => {
|
|
936
|
-
let updatedLegalEntity;
|
|
937
|
-
const existingLeId = legalEntityResponse?.id;
|
|
938
|
-
if (legalEntity.individual && legalEntityResponse?.individual?.support) {
|
|
939
|
-
legalEntity.individual.support = customerSupportPresubmitProcess(
|
|
940
|
-
legalEntityResponse,
|
|
941
|
-
legalEntity
|
|
942
|
-
);
|
|
943
|
-
}
|
|
944
|
-
if (!existingLeId) {
|
|
945
|
-
updatedLegalEntity = await createLegalEntity(legalEntity);
|
|
946
|
-
userEvents.addTaskEvent("Success", {
|
|
947
|
-
actionType: "submit",
|
|
948
|
-
countryOfRegistration: dataSubmitted.personalDetails?.residencyCountry,
|
|
949
|
-
roles: dataSubmitted.personalDetails?.role
|
|
950
|
-
});
|
|
951
|
-
} else {
|
|
952
|
-
const patchLegalEntity = { ...drop("type").from(legalEntity), id: existingLeId };
|
|
953
|
-
updatedLegalEntity = await updateLegalEntity(patchLegalEntity);
|
|
954
|
-
userEvents.addTaskEvent("Success", {
|
|
955
|
-
actionType: "submit",
|
|
956
|
-
countryOfRegistration: dataSubmitted.personalDetails?.residencyCountry,
|
|
957
|
-
documentType: idDocumentType
|
|
958
|
-
});
|
|
959
|
-
}
|
|
960
|
-
return updatedLegalEntity;
|
|
961
|
-
};
|
|
962
|
-
const { mutateAsync: getIdVerificationStartCheck } = useIdVerificationStartCheck();
|
|
963
|
-
const handleInstantIdVerificationStartCheck = async (onfidoResponse, legalEntityId) => {
|
|
964
|
-
const providerId = idVerificationProviderId.value;
|
|
965
|
-
if (!providerId) throw Error("idVerificationProviderId not yet set");
|
|
966
|
-
const data2 = {
|
|
967
|
-
providerId,
|
|
968
|
-
legalEntityId,
|
|
969
|
-
captureMetadata: onfidoResponse
|
|
970
|
-
};
|
|
971
|
-
await getIdVerificationStartCheck(data2);
|
|
972
|
-
};
|
|
973
|
-
const submitDocuments = async ({
|
|
974
|
-
forms: forms2,
|
|
975
|
-
legalEntity,
|
|
976
|
-
dataSubmitted
|
|
977
|
-
}) => {
|
|
978
|
-
if (!isDocumentsRequired(forms2)) return;
|
|
979
|
-
if (dataSubmitted.idDocument?.instantIdVerificationData) {
|
|
980
|
-
if (providerStatus?.statuses?.idDocument?.enabled === false) {
|
|
981
|
-
throw new Error("Provider unexpectedly disabled instant verification flow");
|
|
982
|
-
}
|
|
983
|
-
await handleInstantIdVerificationStartCheck(
|
|
984
|
-
dataSubmitted.idDocument.instantIdVerificationData,
|
|
985
|
-
legalEntity.id
|
|
986
|
-
);
|
|
987
|
-
} else {
|
|
988
|
-
const formattedDocuments = await mapIndividualDocumentToApiDocument(
|
|
989
|
-
dataSubmitted,
|
|
990
|
-
legalEntity.id
|
|
991
|
-
);
|
|
992
|
-
if (!formattedDocuments || formattedDocuments.length === 0) {
|
|
993
|
-
if (existingAttachments?.length)
|
|
994
|
-
logger$1.log(
|
|
995
|
-
"User has already uploaded documents and is not changing them, nothing needs to be done"
|
|
996
|
-
);
|
|
997
|
-
else
|
|
998
|
-
logger$1.error(
|
|
999
|
-
`formattedDocuments is empty, but there are no existing documents. Something has gone wrong`
|
|
1000
|
-
);
|
|
1001
|
-
return;
|
|
1002
|
-
}
|
|
1003
|
-
formattedDocuments[0].attachments = mergeAttachments(
|
|
1004
|
-
existingAttachments ?? [],
|
|
1005
|
-
formattedDocuments[0]?.attachments ?? []
|
|
1006
|
-
).filter((attachment) => attachment.content);
|
|
1007
|
-
const uploadedDocuments = await documentUtils.uploadDocuments(
|
|
1008
|
-
formattedDocuments,
|
|
1009
|
-
legalEntity.id
|
|
1010
|
-
);
|
|
1011
|
-
uploadedDocuments?.forEach((doc) => {
|
|
1012
|
-
userEvents.addTaskEvent("Success", {
|
|
1013
|
-
actionType: "upload",
|
|
1014
|
-
documentType: doc.type,
|
|
1015
|
-
fileExtention: doc?.attachments?.map((item) => getFileExtention(item.pageName ?? "")).filter((item) => item !== void 0) ?? void 0
|
|
1016
|
-
});
|
|
1017
|
-
});
|
|
1018
|
-
}
|
|
1019
|
-
};
|
|
1020
|
-
const hasRolesChanged = (legalEntity, existingEntityAssociations, newRoles) => {
|
|
1021
|
-
const existingRoles = existingEntityAssociations?.filter((ea) => ea.legalEntityId === legalEntity.id)?.map(({ type }) => type);
|
|
1022
|
-
return !doArraysMatch(existingRoles, newRoles);
|
|
1023
|
-
};
|
|
1024
|
-
const attachAssociationToParentLegalEntity = async ({
|
|
1025
|
-
legalEntity,
|
|
1026
|
-
parentLE,
|
|
1027
|
-
dataSubmitted
|
|
1028
|
-
}) => {
|
|
1029
|
-
const newRoles = taskType === TaskTypes.DECISION_MAKER || taskType === TaskTypes.TRUST_MEMBER_COMPANY_OWNER || taskType === TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY_OWNER ? dataSubmitted?.personalDetails?.role : taskType === TaskTypes.TRUST_MEMBER_INDIVIDUAL || taskType === TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_INDIVIDUAL ? trustMember?.roles : null;
|
|
1030
|
-
const existingEntityAssociations = getOwnEntityAssociations(parentLE);
|
|
1031
|
-
if (newRoles && (hasRolesChanged(legalEntity, existingEntityAssociations, newRoles) || dataFromResponse.personalDetails?.jobTitle !== dataSubmitted?.personalDetails?.jobTitle || hasNomineesChanged(dataFromResponse.personalDetails, dataSubmitted.personalDetails))) {
|
|
1032
|
-
const updatedParentLegalEntity = {
|
|
1033
|
-
entityAssociations: [
|
|
1034
|
-
...newRoles.map((role) => ({
|
|
1035
|
-
type: role,
|
|
1036
|
-
legalEntityId: legalEntity.id,
|
|
1037
|
-
...DECISION_MAKER_TYPES_WITH_JOBTITLE.some((type) => type === role) && {
|
|
1038
|
-
jobTitle: dataSubmitted?.personalDetails?.jobTitle
|
|
1039
|
-
}
|
|
1040
|
-
})) || [],
|
|
1041
|
-
...existingEntityAssociations.filter((ea) => ea.legalEntityId !== legalEntity.id) || []
|
|
1042
|
-
]
|
|
1043
|
-
};
|
|
1044
|
-
if (updatedParentLegalEntity.entityAssociations) {
|
|
1045
|
-
updatedParentLegalEntity.entityAssociations = updatedParentLegalEntity.entityAssociations.map(
|
|
1046
|
-
(ea) => attachNomineeToRole(ea, country, dataSubmitted.personalDetails)
|
|
1047
|
-
);
|
|
1048
|
-
}
|
|
1049
|
-
await updateLegalEntity({ ...updatedParentLegalEntity, id: parentLE.id });
|
|
1050
|
-
}
|
|
1051
|
-
if (taskType === TaskTypes.LEGAL_REPRESENTATIVE_DETAILS && (existingEntityAssociations.every((ea) => ea.legalEntityId !== legalEntity.id) || dataFromResponse?.personalDetails?.relationship !== dataSubmitted?.personalDetails?.relationship)) {
|
|
1052
|
-
const newEntityAssociation = {
|
|
1053
|
-
type: "legalRepresentative",
|
|
1054
|
-
legalEntityId: legalEntity.id,
|
|
1055
|
-
relationship: dataSubmitted?.personalDetails?.relationship
|
|
1056
|
-
};
|
|
1057
|
-
const updatedParentLegalEntity = {
|
|
1058
|
-
entityAssociations: [newEntityAssociation, ...existingEntityAssociations]
|
|
1059
|
-
};
|
|
1060
|
-
await updateLegalEntity({ ...updatedParentLegalEntity, id: parentLE.id });
|
|
1061
|
-
}
|
|
1062
|
-
};
|
|
1063
|
-
const onSubmit = async () => {
|
|
1064
|
-
setLoadingStatus("loading");
|
|
1065
|
-
const dataSubmitted = omitObscuredFieldsIfUnchanged(
|
|
1066
|
-
individualObscuredFields,
|
|
1067
|
-
data,
|
|
1068
|
-
dataFromResponse
|
|
1069
|
-
);
|
|
1070
|
-
if (!dataSubmitted) {
|
|
1071
|
-
return;
|
|
1072
|
-
}
|
|
1073
|
-
try {
|
|
1074
|
-
const legalEntity = mapIndividualToLegalEntity(dataSubmitted);
|
|
1075
|
-
const idDocumentType = idDocumentTypeOptions.find(
|
|
1076
|
-
({ id }) => dataSubmitted?.idDocument?.idDocumentType === id
|
|
1077
|
-
)?.id;
|
|
1078
|
-
legalEntity.entityAssociations = filterOutUnwantedAssociationsIfRootLE(
|
|
1079
|
-
taskType,
|
|
1080
|
-
legalEntityResponse,
|
|
1081
|
-
accountHolder || void 0
|
|
1082
|
-
);
|
|
1083
|
-
const createdLegalEntity = await submitLegalEntity({
|
|
1084
|
-
dataSubmitted,
|
|
1085
|
-
legalEntity,
|
|
1086
|
-
idDocumentType
|
|
1087
|
-
});
|
|
1088
|
-
setAccountHolder(accountHolder);
|
|
1089
|
-
await submitDocuments({ forms, legalEntity: createdLegalEntity, dataSubmitted });
|
|
1090
|
-
if (parentLegalEntity) {
|
|
1091
|
-
await attachAssociationToParentLegalEntity({
|
|
1092
|
-
legalEntity: createdLegalEntity,
|
|
1093
|
-
parentLE: parentLegalEntity,
|
|
1094
|
-
dataSubmitted
|
|
1095
|
-
});
|
|
1096
|
-
}
|
|
1097
|
-
setLoadingStatus("success");
|
|
1098
|
-
clearToasts();
|
|
1099
|
-
externalOnSubmit?.(dataSubmitted);
|
|
1100
|
-
} catch (e) {
|
|
1101
|
-
logger$1.error("Failed to update individual", e);
|
|
1102
|
-
if (isValidationError(e)) {
|
|
1103
|
-
setValidationErrors(processValidationErrors(e, TaskTypes.INDIVIDUAL));
|
|
1104
|
-
} else if (isMaintenanceModeError(e)) {
|
|
1105
|
-
showToast({
|
|
1106
|
-
label: i18n.get("maintenanceModeMessage"),
|
|
1107
|
-
variant: "error",
|
|
1108
|
-
duration: "indefinite"
|
|
1109
|
-
});
|
|
1110
|
-
} else {
|
|
1111
|
-
showToast({ label: i18n.get("failedToUpdateDetails"), variant: "error" });
|
|
1112
|
-
}
|
|
1113
|
-
setLoadingStatus("success");
|
|
1114
|
-
userEvents.addTaskEvent("Encountered error", {
|
|
1115
|
-
actionType: "submit",
|
|
1116
|
-
returnType: e.errorCode,
|
|
1117
|
-
returnValue: e.title
|
|
1118
|
-
});
|
|
1119
|
-
}
|
|
1120
|
-
};
|
|
1121
|
-
const isDocumentsRequired = (forms2) => forms2.some((form2) => individualDocumentForms.includes(form2.formId));
|
|
1122
|
-
const datasetUtils = datasetUtilities(i18n.locale);
|
|
1123
|
-
const formatIdDocument = (idDocument2) => {
|
|
1124
|
-
if (!idDocument2) return void 0;
|
|
1125
|
-
const documentType = idDocument2?.instantIdVerificationData ? onfidoDocumentTypeMapping.find(
|
|
1126
|
-
(document2) => idDocument2.instantIdVerificationData?.document_front.type === document2.id
|
|
1127
|
-
) : idDocumentTypeOptions.find(({ id }) => idDocument2.idDocumentType === id);
|
|
1128
|
-
if (!documentType) return void 0;
|
|
1129
|
-
const frontPage = idDocument2.idFrontPage?.[0];
|
|
1130
|
-
const backPage = idDocument2.idBackPage?.[0];
|
|
1131
|
-
if (!frontPage) return void 0;
|
|
1132
|
-
return {
|
|
1133
|
-
documentType: i18n.get(documentType.name),
|
|
1134
|
-
...backPage && documentType.hasBackPage ? {
|
|
1135
|
-
frontPage: frontPage.name,
|
|
1136
|
-
backPage: backPage.name
|
|
1137
|
-
} : {
|
|
1138
|
-
fileName: frontPage.name
|
|
1139
|
-
}
|
|
1140
|
-
};
|
|
1141
|
-
};
|
|
1142
|
-
const formatFileSummaryData = ({
|
|
1143
|
-
idDocument: idDocument2,
|
|
1144
|
-
proofOfNationalId,
|
|
1145
|
-
proofOfResidency,
|
|
1146
|
-
proofOfRelationship
|
|
1147
|
-
}) => {
|
|
1148
|
-
const proofOfNationalIdFile = proofOfNationalId?.proofOfNationalId?.[0];
|
|
1149
|
-
const proofOfResidencyFile = proofOfResidency?.proofOfResidency?.[0];
|
|
1150
|
-
const proofOfRelationshipFile = proofOfRelationship?.proofOfRelationship?.[0];
|
|
1151
|
-
return {
|
|
1152
|
-
...(idDocument2?.idDocumentType || idDocument2?.instantIdVerificationData) && {
|
|
1153
|
-
idDocument: formatIdDocument(idDocument2)
|
|
1154
|
-
},
|
|
1155
|
-
...proofOfNationalIdFile && {
|
|
1156
|
-
proofOfNationalId: {
|
|
1157
|
-
fileName: proofOfNationalIdFile.name
|
|
1158
|
-
}
|
|
1159
|
-
},
|
|
1160
|
-
...proofOfResidencyFile && {
|
|
1161
|
-
proofOfResidency: {
|
|
1162
|
-
fileName: proofOfResidencyFile.name
|
|
1163
|
-
}
|
|
1164
|
-
},
|
|
1165
|
-
...proofOfRelationshipFile && {
|
|
1166
|
-
proofOfRelationship: {
|
|
1167
|
-
fileName: proofOfRelationshipFile.name
|
|
1168
|
-
}
|
|
1169
|
-
}
|
|
1170
|
-
};
|
|
1171
|
-
};
|
|
1172
|
-
const formatDataForSummary = () => {
|
|
1173
|
-
let summaryData = cloneObject(data);
|
|
1174
|
-
if (summaryData.personalDetails?.residencyCountry) {
|
|
1175
|
-
summaryData.personalDetails.residencyCountry = datasetUtils.getCountryName(
|
|
1176
|
-
summaryData.personalDetails.residencyCountry
|
|
1177
|
-
);
|
|
1178
|
-
}
|
|
1179
|
-
if (summaryData.personalDetails?.nationality) {
|
|
1180
|
-
summaryData.personalDetails.nationality = datasetUtils.getCountryName(
|
|
1181
|
-
summaryData.personalDetails.nationality
|
|
1182
|
-
);
|
|
1183
|
-
}
|
|
1184
|
-
if (summaryData.address) {
|
|
1185
|
-
summaryData.address = mapAddressLabels(summaryData.address, datasetUtils);
|
|
1186
|
-
}
|
|
1187
|
-
if (isDocumentsRequired(forms)) {
|
|
1188
|
-
individualDocumentForms.forEach((formId) => delete summaryData[formId]);
|
|
1189
|
-
summaryData = { ...summaryData, ...formatFileSummaryData(data) };
|
|
1190
|
-
}
|
|
1191
|
-
if (summaryData.personalDetails?.accountHolder) {
|
|
1192
|
-
summaryData.personalDetails.accountHolder = i18n.get(
|
|
1193
|
-
summaryData.personalDetails.accountHolder
|
|
1194
|
-
);
|
|
1195
|
-
}
|
|
1196
|
-
if (summaryData.personalDetails?.birthDate) {
|
|
1197
|
-
summaryData.personalDetails.birthDate = localizeDateString(
|
|
1198
|
-
summaryData.personalDetails.birthDate,
|
|
1199
|
-
i18n.locale
|
|
1200
|
-
);
|
|
1201
|
-
}
|
|
1202
|
-
if (summaryData.personalDetails?.phoneNumber) {
|
|
1203
|
-
delete summaryData.personalDetails.phoneNumber;
|
|
1204
|
-
summaryData.personalDetails.phoneNumber = data.personalDetails?.phoneNumber?.number;
|
|
1205
|
-
}
|
|
1206
|
-
if (summaryData.personalDetails?.taxInformation) {
|
|
1207
|
-
const taxInformation = summaryData.personalDetails.taxInformation.find(
|
|
1208
|
-
(taxId) => taxId.country === data.personalDetails?.nationality
|
|
1209
|
-
);
|
|
1210
|
-
if (taxInformation) {
|
|
1211
|
-
delete summaryData.personalDetails.taxInformation;
|
|
1212
|
-
summaryData.personalDetails[taxInformation.type] = taxInformation.number;
|
|
1213
|
-
}
|
|
1214
|
-
}
|
|
1215
|
-
return summaryData;
|
|
1216
|
-
};
|
|
1217
|
-
const summaryOmittedKeys = [
|
|
1218
|
-
...taskType === TaskTypes.DECISION_MAKER ? ["role"] : [],
|
|
1219
|
-
...data?.personalDetails?.idNumberExempt ? ["idNumber"] : []
|
|
1220
|
-
];
|
|
1221
|
-
const {
|
|
1222
|
-
handleNextClick,
|
|
1223
|
-
handleBackClick,
|
|
1224
|
-
activeForm,
|
|
1225
|
-
shouldValidate,
|
|
1226
|
-
gotoFormByFormIndex,
|
|
1227
|
-
steps
|
|
1228
|
-
} = useFormComposer({
|
|
1229
|
-
problems,
|
|
1230
|
-
externalBackClick,
|
|
1231
|
-
forms,
|
|
1232
|
-
onSubmit,
|
|
1233
|
-
triggerValidation: form.triggerValidation
|
|
1234
|
-
// TODO: figure out type of nested keys
|
|
1235
|
-
});
|
|
1236
|
-
return /* @__PURE__ */ jsx(FormContextProvider, { form, children: /* @__PURE__ */ jsx(
|
|
1237
|
-
FormFlow,
|
|
1238
|
-
{
|
|
1239
|
-
summary: {
|
|
1240
|
-
data: formatDataForSummary(),
|
|
1241
|
-
omitted: {
|
|
1242
|
-
keys: summaryOmittedKeys
|
|
1243
|
-
},
|
|
1244
|
-
problems
|
|
1245
|
-
},
|
|
1246
|
-
asModal,
|
|
1247
|
-
currentStep: steps.current,
|
|
1248
|
-
disableNextButton: hideFooter,
|
|
1249
|
-
forms,
|
|
1250
|
-
activeForm,
|
|
1251
|
-
gotoFormByFormIndex,
|
|
1252
|
-
handleBackClick,
|
|
1253
|
-
handleCancelClick: handleHomeClick,
|
|
1254
|
-
handleNextClick,
|
|
1255
|
-
loadingStatus,
|
|
1256
|
-
totalSteps: steps.total,
|
|
1257
|
-
children: /* @__PURE__ */ jsx(
|
|
1258
|
-
Individual,
|
|
1259
|
-
{
|
|
1260
|
-
...derivedProps,
|
|
1261
|
-
data,
|
|
1262
|
-
country,
|
|
1263
|
-
activeForm,
|
|
1264
|
-
forms,
|
|
1265
|
-
taskType,
|
|
1266
|
-
problems,
|
|
1267
|
-
onNext: handleNextClick,
|
|
1268
|
-
onBack: handleBackClick,
|
|
1269
|
-
setHideFooter,
|
|
1270
|
-
legalEntityId: legalEntityResponse?.id,
|
|
1271
|
-
allowedRoles: roleTypes,
|
|
1272
|
-
shouldValidate,
|
|
1273
|
-
accountHolder,
|
|
1274
|
-
parentLegalEntity,
|
|
1275
|
-
trustedFields: !parentLegalEntity ? trustedFields : associatedLegalEntityTrustedFields,
|
|
1276
|
-
trustedFieldsProvider,
|
|
1277
|
-
trustedRoles
|
|
1278
|
-
}
|
|
1279
|
-
)
|
|
1280
|
-
}
|
|
1281
|
-
) });
|
|
1282
|
-
}
|
|
1283
|
-
const isNotOutOfRangeBirthDateValidatorRule = {
|
|
1284
|
-
modes: ["blur"],
|
|
1285
|
-
validate: (birthDate) => !isEmpty(birthDate) && new Date(birthDate) < /* @__PURE__ */ new Date(),
|
|
1286
|
-
errorMessage: "invalidDateOfBirth"
|
|
1287
|
-
};
|
|
1288
|
-
const buildMinimumAgeValidationRule = (minimumAge) => ({
|
|
1289
|
-
modes: ["blur"],
|
|
1290
|
-
validate: (birthDate) => !!birthDate && getAgeToday(birthDate) >= minimumAge,
|
|
1291
|
-
errorMessage: {
|
|
1292
|
-
key: "youMustXYearsOldToContinue",
|
|
1293
|
-
values: { minimumAge: minimumAge.toString() }
|
|
1294
|
-
}
|
|
1295
|
-
});
|
|
1296
|
-
const getCountrySpecificMinimumAgeValidationRule = (country) => {
|
|
1297
|
-
if (!country) {
|
|
1298
|
-
return buildMinimumAgeValidationRule(13);
|
|
1299
|
-
}
|
|
1300
|
-
if ([...euCountries, CountryCodes.UnitedKingdom, CountryCodes.Switzerland].some(
|
|
1301
|
-
(c) => c === country
|
|
1302
|
-
)) {
|
|
1303
|
-
return buildMinimumAgeValidationRule(16);
|
|
1304
|
-
}
|
|
1305
|
-
switch (country) {
|
|
1306
|
-
case CountryCodes.HongKong:
|
|
1307
|
-
case CountryCodes.Singapore:
|
|
1308
|
-
return buildMinimumAgeValidationRule(18);
|
|
1309
|
-
default:
|
|
1310
|
-
return buildMinimumAgeValidationRule(13);
|
|
1311
|
-
}
|
|
1312
|
-
};
|
|
1313
|
-
const additionalPersonalDetailsValidators = ({
|
|
1314
|
-
country,
|
|
1315
|
-
isExperimentEnabled = () => false,
|
|
1316
|
-
isSettingEnabled = () => false,
|
|
1317
|
-
taskType,
|
|
1318
|
-
idNumberType,
|
|
1319
|
-
idNumberExempt,
|
|
1320
|
-
idNumber,
|
|
1321
|
-
existingIdNumber,
|
|
1322
|
-
formVerificationErrors,
|
|
1323
|
-
i18n,
|
|
1324
|
-
taxIdNumberType
|
|
1325
|
-
}) => ({
|
|
1326
|
-
taxInformation: resolveFieldMetadata(
|
|
1327
|
-
taxInformationDefaultFieldConfig[country],
|
|
1328
|
-
{
|
|
1329
|
-
taxIdNumberType,
|
|
1330
|
-
companyType: LegalEntityTypes.INDIVIDUAL
|
|
1331
|
-
},
|
|
1332
|
-
taxInformationDefaultFieldMetadata
|
|
1333
|
-
)?.validators,
|
|
1334
|
-
birthDate: (() => {
|
|
1335
|
-
const baseValidators = [isNotOutOfRangeBirthDateValidatorRule];
|
|
1336
|
-
if (isSettingEnabled("enforceLegalAge")) {
|
|
1337
|
-
return [...baseValidators, buildMinimumAgeValidationRule(18)];
|
|
1338
|
-
}
|
|
1339
|
-
if (isExperimentEnabled("EnableAgeVerification")) {
|
|
1340
|
-
if (taskType === TaskTypes.LEGAL_REPRESENTATIVE_DETAILS) {
|
|
1341
|
-
return [...baseValidators, buildMinimumAgeValidationRule(18)];
|
|
1342
|
-
}
|
|
1343
|
-
return [...baseValidators, getCountrySpecificMinimumAgeValidationRule(country)];
|
|
1344
|
-
}
|
|
1345
|
-
return baseValidators;
|
|
1346
|
-
})(),
|
|
1347
|
-
...isExperimentEnabled("StrictNameAndAddressValidationV4") ? nameValidationRulesV4 : void 0,
|
|
1348
|
-
...contactDetailsValidationRules,
|
|
1349
|
-
idNumber: (() => {
|
|
1350
|
-
const derivedIdNumberType = country === CountryCodes.UnitedStates || country === CountryCodes.PuertoRico ? getSSNType(formVerificationErrors, existingIdNumber) : idNumberType;
|
|
1351
|
-
return idNumberExempt ? {
|
|
1352
|
-
validate: () => {
|
|
1353
|
-
return idNumberExempt || !isEmpty(idNumber);
|
|
1354
|
-
},
|
|
1355
|
-
modes: ["blur"]
|
|
1356
|
-
} : resolveFieldMetadata(
|
|
1357
|
-
defaultFieldConfig[country],
|
|
1358
|
-
{ idNumberType: derivedIdNumberType },
|
|
1359
|
-
defaultFieldMetadata
|
|
1360
|
-
)?.validators;
|
|
1361
|
-
})(),
|
|
1362
|
-
...addressValidators({
|
|
1363
|
-
isExperimentEnabled,
|
|
1364
|
-
country,
|
|
1365
|
-
i18n
|
|
1366
|
-
})
|
|
1367
|
-
});
|
|
1368
|
-
const basicDetailsValidators = ({
|
|
1369
|
-
isExperimentEnabled = () => false
|
|
1370
|
-
}) => ({
|
|
1371
|
-
...contactDetailsValidationRules,
|
|
1372
|
-
...isExperimentEnabled("StrictNameAndAddressValidationV4") ? nameValidationRulesV4 : void 0
|
|
1373
|
-
});
|
|
1374
|
-
const getIdNowProviderIdentificationStatus = async (rootLegalEntityId, baseUrl, legalEntityId) => {
|
|
1375
|
-
return httpGet({
|
|
1376
|
-
baseUrl,
|
|
1377
|
-
path: `legalEntities/${rootLegalEntityId}/child/${legalEntityId}/provider/idnow/identification/status`,
|
|
1378
|
-
errorHandler: async (response) => {
|
|
1379
|
-
const responseData = await response;
|
|
1380
|
-
if (responseData.status === 404) {
|
|
1381
|
-
return { status: 404, message: responseData.detail, errorCode: responseData.errorCode };
|
|
1382
|
-
}
|
|
1383
|
-
}
|
|
1384
|
-
});
|
|
1385
|
-
};
|
|
1386
|
-
const useIdNowIdentificationStatus = (legalEntityId, options) => {
|
|
1387
|
-
const { rootLegalEntityId, baseUrl } = useApiContext();
|
|
1388
|
-
return useQuery({
|
|
1389
|
-
queryKey: legalEntityId === skipToken ? [] : ["idNowProviderIdentificationStatus", legalEntityId],
|
|
1390
|
-
queryFn: legalEntityId === skipToken ? skipToken : () => getIdNowProviderIdentificationStatus(
|
|
1391
|
-
rootLegalEntityId.value,
|
|
1392
|
-
baseUrl.value,
|
|
1393
|
-
legalEntityId
|
|
1394
|
-
),
|
|
1395
|
-
...options
|
|
1396
|
-
});
|
|
1397
|
-
};
|
|
1398
|
-
const idNowProviderStartIdentification = async (rootLegalEntityId, baseUrl, legalEntityId) => {
|
|
1399
|
-
return httpPost({
|
|
1400
|
-
baseUrl,
|
|
1401
|
-
path: `legalEntities/${rootLegalEntityId}/child/${legalEntityId}/provider/idnow/identification/start`
|
|
1402
|
-
});
|
|
1403
|
-
};
|
|
1404
|
-
const useIdNowStartIdentification = (legalEntityId, options) => {
|
|
1405
|
-
const { rootLegalEntityId, baseUrl } = useApiContext();
|
|
1406
|
-
return useQuery({
|
|
1407
|
-
queryKey: legalEntityId === skipToken ? [] : ["idNowProviderStartIdentification", legalEntityId],
|
|
1408
|
-
queryFn: legalEntityId === skipToken ? skipToken : () => idNowProviderStartIdentification(rootLegalEntityId.value, baseUrl.value, legalEntityId),
|
|
1409
|
-
...options
|
|
1410
|
-
});
|
|
1411
|
-
};
|
|
1412
|
-
const idnowHeader = "adyen-kyc-idnow-header";
|
|
1413
|
-
const idnowVerificationHeaderIframeContainer = "adyen-kyc-idnow-verification-header-iframe-container";
|
|
1414
|
-
const idnowVerificationHeaderIframe = "adyen-kyc-idnow-verification-header-iframe";
|
|
1415
|
-
const idnowVerificationHeaderImage = "adyen-kyc-idnow-verification-header-image";
|
|
1416
|
-
const styles = {
|
|
1417
|
-
idnowHeader,
|
|
1418
|
-
idnowVerificationHeaderIframeContainer,
|
|
1419
|
-
idnowVerificationHeaderIframe,
|
|
1420
|
-
idnowVerificationHeaderImage
|
|
1421
|
-
};
|
|
1422
|
-
const passportFrontGreenImage = lazy(
|
|
1423
|
-
() => import("./passport-front-green-BL4HmtsB.js")
|
|
1424
|
-
);
|
|
1425
|
-
const isIdNowSuccessful = (status) => {
|
|
1426
|
-
const providerStatus = status?.providerStatus;
|
|
1427
|
-
return providerStatus === "SUCCESS" || providerStatus === "SUCCESS_DATA_CHANGED" || providerStatus === "REVIEW_PENDING";
|
|
1428
|
-
};
|
|
1429
|
-
const IdNowVerificationModal = ({ handleFinish }) => {
|
|
1430
|
-
const { t } = useTranslation(["individual", "common"]);
|
|
1431
|
-
const [isConfirmPresented, setIsConfirmPresented] = useState(false);
|
|
1432
|
-
const [genericError, setGenericError] = useState(false);
|
|
1433
|
-
const widgetContainerRef = useRef(null);
|
|
1434
|
-
const iFrameRef = useRef(null);
|
|
1435
|
-
const iFrameWidgetRef = useRef(null);
|
|
1436
|
-
const [page, setPage] = useState(1);
|
|
1437
|
-
const queryClient = useQueryClient();
|
|
1438
|
-
const { showToast } = useToastContext();
|
|
1439
|
-
const {
|
|
1440
|
-
data: idNowStatus,
|
|
1441
|
-
isLoading: isStatusLoading,
|
|
1442
|
-
refetch: refetchIdNowIdentificationStatus
|
|
1443
|
-
} = useIdNowIdentificationStatus(idNowModalChildEntityId.value?.id ?? skipToken, {
|
|
1444
|
-
enabled: !!idNowModalChildEntityId.value?.id,
|
|
1445
|
-
refetchOnMount: "always",
|
|
1446
|
-
refetchInterval: 1e4,
|
|
1447
|
-
// poll every 10 seconds
|
|
1448
|
-
retry: (failureCount, error) => {
|
|
1449
|
-
if ("status" in error && error.status === 404) return false;
|
|
1450
|
-
return failureCount < 3;
|
|
1451
|
-
}
|
|
1452
|
-
});
|
|
1453
|
-
const {
|
|
1454
|
-
data: idNowStart,
|
|
1455
|
-
isLoading,
|
|
1456
|
-
isError: idNowStartError,
|
|
1457
|
-
refetch: refetchIdNowStartIdentification
|
|
1458
|
-
} = useIdNowStartIdentification(idNowModalChildEntityId.value?.id ?? skipToken, {
|
|
1459
|
-
enabled: !!idNowModalChildEntityId.value?.id && page === 2
|
|
1460
|
-
});
|
|
1461
|
-
const handleDismiss = () => {
|
|
1462
|
-
setIsConfirmPresented(true);
|
|
1463
|
-
};
|
|
1464
|
-
const handleCancelDismiss = () => {
|
|
1465
|
-
setIsConfirmPresented(false);
|
|
1466
|
-
};
|
|
1467
|
-
const handleConfirmDismiss = () => {
|
|
1468
|
-
setPage(1);
|
|
1469
|
-
setGenericError(false);
|
|
1470
|
-
setIsConfirmPresented(false);
|
|
1471
|
-
showIdNowModal.value = false;
|
|
1472
|
-
if (idNowStartError && idNowModalChildEntityId.value?.id) {
|
|
1473
|
-
queryClient.resetQueries({
|
|
1474
|
-
queryKey: ["idNowProviderStartIdentification", idNowModalChildEntityId.value?.id]
|
|
1475
|
-
});
|
|
1476
|
-
}
|
|
1477
|
-
idNowModalChildEntityId.value = void 0;
|
|
1478
|
-
iFrameWidgetRef.current?.unmount();
|
|
1479
|
-
iFrameRef.current?.remove();
|
|
1480
|
-
handleFinish?.();
|
|
1481
|
-
};
|
|
1482
|
-
if (idNowStatus?.status === "finished") {
|
|
1483
|
-
if (isIdNowSuccessful(idNowStatus)) {
|
|
1484
|
-
showToast({
|
|
1485
|
-
label: t(($) => $["successfullyUpdatedDetails"], { ns: "common" }),
|
|
1486
|
-
variant: "success"
|
|
1487
|
-
});
|
|
1488
|
-
handleConfirmDismiss();
|
|
1489
|
-
} else {
|
|
1490
|
-
if (page === 2) {
|
|
1491
|
-
handleConfirmDismiss();
|
|
1492
|
-
}
|
|
1493
|
-
}
|
|
1494
|
-
}
|
|
1495
|
-
if (!isLoading && idNowStartError) {
|
|
1496
|
-
setGenericError(true);
|
|
1497
|
-
setPage(1);
|
|
1498
|
-
}
|
|
1499
|
-
const initializeIdNowWidget = useCallback(async (url) => {
|
|
1500
|
-
const container = widgetContainerRef.current;
|
|
1501
|
-
if (!container) {
|
|
1502
|
-
return;
|
|
1503
|
-
}
|
|
1504
|
-
const iFrame = document.createElement("iframe");
|
|
1505
|
-
iFrameRef.current = iFrame;
|
|
1506
|
-
iFrame.setAttribute("allowFullscreen", "true");
|
|
1507
|
-
iFrame.classList.add(styles.idnowVerificationHeaderIframe);
|
|
1508
|
-
iFrame.setAttribute("height", "800");
|
|
1509
|
-
iFrame.setAttribute(
|
|
1510
|
-
"allow",
|
|
1511
|
-
"camera *;microphone *;geolocation *;clipboard-read *;clipboard-write *"
|
|
1512
|
-
);
|
|
1513
|
-
container.appendChild(iFrame);
|
|
1514
|
-
try {
|
|
1515
|
-
iFrameWidgetRef.current = new IFrameWidget(iFrame, url, "idnow", "");
|
|
1516
|
-
await iFrameWidgetRef.current.mountAndWaitForResponse();
|
|
1517
|
-
} catch (err) {
|
|
1518
|
-
console.error("Error occurred:", err);
|
|
1519
|
-
setGenericError(true);
|
|
1520
|
-
setPage(1);
|
|
1521
|
-
}
|
|
1522
|
-
}, []);
|
|
1523
|
-
useEffect(() => {
|
|
1524
|
-
if (page === 2 && !isLoading && idNowStart && idNowStart?.url) {
|
|
1525
|
-
(async () => {
|
|
1526
|
-
await refetchIdNowIdentificationStatus();
|
|
1527
|
-
await initializeIdNowWidget(idNowStart.url);
|
|
1528
|
-
})();
|
|
1529
|
-
}
|
|
1530
|
-
return () => {
|
|
1531
|
-
iFrameWidgetRef.current?.unmount();
|
|
1532
|
-
iFrameRef.current?.remove();
|
|
1533
|
-
};
|
|
1534
|
-
}, [isLoading, page, initializeIdNowWidget, refetchIdNowIdentificationStatus, idNowStart]);
|
|
1535
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1536
|
-
!isStatusLoading && /* @__PURE__ */ jsxs(
|
|
1537
|
-
Modal,
|
|
1538
|
-
{
|
|
1539
|
-
size: page === 2 ? "large" : "medium",
|
|
1540
|
-
showCloseButton: !isLoading && !isStatusLoading,
|
|
1541
|
-
onClose: handleDismiss,
|
|
1542
|
-
ariaLabel: t(($) => $["identityVerification"], { ns: "common" }),
|
|
1543
|
-
children: [
|
|
1544
|
-
page === 1 && /* @__PURE__ */ jsx("div", { className: styles.idnowHeader, children: /* @__PURE__ */ jsx(
|
|
1545
|
-
LandingLayout,
|
|
1546
|
-
{
|
|
1547
|
-
media: /* @__PURE__ */ jsx(
|
|
1548
|
-
Image,
|
|
1549
|
-
{
|
|
1550
|
-
className: styles.idnowVerificationHeaderImage,
|
|
1551
|
-
lazyLoadedImage: passportFrontGreenImage
|
|
1552
|
-
}
|
|
1553
|
-
),
|
|
1554
|
-
title: t(($) => $["identityVerification"], { ns: "common" }),
|
|
1555
|
-
description: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1556
|
-
t(($) => $["idNowDescription"], { ns: "individual" }),
|
|
1557
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
1558
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
1559
|
-
getIndividualLegalEntityName(idNowModalChildEntityId.value) && t(($) => $["idNowDescriptionName"], {
|
|
1560
|
-
ns: "individual",
|
|
1561
|
-
name: getIndividualLegalEntityName(idNowModalChildEntityId.value)
|
|
1562
|
-
})
|
|
1563
|
-
] }),
|
|
1564
|
-
error: !isLoading && genericError ? /* @__PURE__ */ jsx(
|
|
1565
|
-
Alert,
|
|
1566
|
-
{
|
|
1567
|
-
variant: "error",
|
|
1568
|
-
title: t(($) => $["thereWasAnErrorTryAgain"], { ns: "common" })
|
|
1569
|
-
}
|
|
1570
|
-
) : void 0,
|
|
1571
|
-
actions: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1572
|
-
/* @__PURE__ */ jsx(
|
|
1573
|
-
Button,
|
|
1574
|
-
{
|
|
1575
|
-
onClick: async () => {
|
|
1576
|
-
setGenericError(false);
|
|
1577
|
-
setPage(2);
|
|
1578
|
-
await refetchIdNowStartIdentification();
|
|
1579
|
-
},
|
|
1580
|
-
disabled: isLoading || isStatusLoading || idNowStatus?.status === "finished" && isIdNowSuccessful(idNowStatus),
|
|
1581
|
-
fullWidth: true,
|
|
1582
|
-
children: idNowStatus?.status === "pending" ? t(($) => $["continueVerification"], { ns: "common" }) : t(($) => $["startVerification"], { ns: "common" })
|
|
1583
|
-
}
|
|
1584
|
-
),
|
|
1585
|
-
/* @__PURE__ */ jsx(
|
|
1586
|
-
Button,
|
|
1587
|
-
{
|
|
1588
|
-
disabled: isLoading || isStatusLoading,
|
|
1589
|
-
variant: "tertiary",
|
|
1590
|
-
onClick: handleConfirmDismiss,
|
|
1591
|
-
fullWidth: true,
|
|
1592
|
-
children: t(($) => $["finishLater"], { ns: "common" })
|
|
1593
|
-
}
|
|
1594
|
-
)
|
|
1595
|
-
] })
|
|
1596
|
-
}
|
|
1597
|
-
) }),
|
|
1598
|
-
page === 2 && (isLoading ? /* @__PURE__ */ jsx(Loader, {}) : /* @__PURE__ */ jsx(
|
|
1599
|
-
"div",
|
|
1600
|
-
{
|
|
1601
|
-
ref: widgetContainerRef,
|
|
1602
|
-
className: styles.idnowVerificationHeaderIframeContainer
|
|
1603
|
-
}
|
|
1604
|
-
))
|
|
1605
|
-
]
|
|
1606
|
-
}
|
|
1607
|
-
),
|
|
1608
|
-
isConfirmPresented && /* @__PURE__ */ jsx(
|
|
1609
|
-
Confirm,
|
|
1610
|
-
{
|
|
1611
|
-
confirmText: t(($) => $["leave"], { ns: "common" }),
|
|
1612
|
-
onCancel: handleCancelDismiss,
|
|
1613
|
-
onConfirm: handleConfirmDismiss,
|
|
1614
|
-
title: t(($) => $["unsavedChanges"], { ns: "common" })
|
|
1615
|
-
}
|
|
1616
|
-
)
|
|
1617
|
-
] });
|
|
1618
|
-
};
|
|
1619
|
-
const adjustOnfidoIdentificationData = (data, apiData) => {
|
|
1620
|
-
const { typeOfIdentity, idNumber, idNumberExempt } = data;
|
|
1621
|
-
const identificationData = {
|
|
1622
|
-
...apiData,
|
|
1623
|
-
number: idNumber,
|
|
1624
|
-
type: getOnfidoIdentityTypeToApiIdentityTypeMap(data)[typeOfIdentity] ?? "nationalIdNumber"
|
|
1625
|
-
};
|
|
1626
|
-
switch (typeOfIdentity) {
|
|
1627
|
-
case "passport":
|
|
1628
|
-
return {
|
|
1629
|
-
...identificationData,
|
|
1630
|
-
cardNumber: ""
|
|
1631
|
-
};
|
|
1632
|
-
case "driversLicense":
|
|
1633
|
-
return {
|
|
1634
|
-
...identificationData,
|
|
1635
|
-
expiryDate: ""
|
|
1636
|
-
};
|
|
1637
|
-
default:
|
|
1638
|
-
return idNumber === void 0 && idNumberExempt === void 0 ? void 0 : {
|
|
1639
|
-
...identificationData,
|
|
1640
|
-
expiryDate: "",
|
|
1641
|
-
cardNumber: "",
|
|
1642
|
-
nationalIdExempt: apiData?.nationalIdExempt ?? !idNumber
|
|
1643
|
-
};
|
|
1644
|
-
}
|
|
1645
|
-
};
|
|
1646
|
-
const mapIndividualOnfidoSchemaToLegalEntity = (individualOnfido, isExperimentEnabled, matchingScenario) => {
|
|
1647
|
-
const legalEntity = {
|
|
1648
|
-
...formatObject(individualOnfido, individualOnfidoApiKeyMapping),
|
|
1649
|
-
type: LegalEntityTypes.INDIVIDUAL
|
|
1650
|
-
};
|
|
1651
|
-
if (individualOnfido.additionalPersonalDetails) {
|
|
1652
|
-
if (isExperimentEnabled("EnableTaxIdRequiredForBusinessAccountsScenarios") && matchingScenario?.includes(Scenarios.L_TAXINFO) && individualOnfido.additionalPersonalDetails?.idNumber && individualOnfido.additionalPersonalDetails?.typeOfIdentity && individualOnfido.additionalPersonalDetails?.country === CountryCodes.Spain) {
|
|
1653
|
-
legalEntity.individual.taxInformation = [
|
|
1654
|
-
{
|
|
1655
|
-
country: individualOnfido.additionalPersonalDetails.country,
|
|
1656
|
-
number: individualOnfido.additionalPersonalDetails.idNumber,
|
|
1657
|
-
type: individualOnfido.additionalPersonalDetails.typeOfIdentity.toUpperCase()
|
|
1658
|
-
}
|
|
1659
|
-
];
|
|
1660
|
-
}
|
|
1661
|
-
legalEntity.individual.identificationData = adjustOnfidoIdentificationData(
|
|
1662
|
-
individualOnfido.additionalPersonalDetails,
|
|
1663
|
-
legalEntity.individual.identificationData
|
|
1664
|
-
);
|
|
1665
|
-
}
|
|
1666
|
-
const nameLocalization = [
|
|
1667
|
-
mapSchemaFieldsToApiScriptLocalization(individualOnfido.basicDetails ?? {}, "jaHani"),
|
|
1668
|
-
mapSchemaFieldsToApiScriptLocalization(individualOnfido.basicDetails ?? {}, "jaKana")
|
|
1669
|
-
].filter(({ fields }) => !isEmpty$1(fields));
|
|
1670
|
-
if (nameLocalization.length) {
|
|
1671
|
-
legalEntity.individual.name.localization = nameLocalization;
|
|
1672
|
-
}
|
|
1673
|
-
const addressLocalizations = mapJpAddressSchemaToAddressLocalizations(
|
|
1674
|
-
individualOnfido.additionalPersonalDetails
|
|
1675
|
-
);
|
|
1676
|
-
if (addressLocalizations.length > 0)
|
|
1677
|
-
legalEntity.individual.residentialAddress.localization = addressLocalizations;
|
|
1678
|
-
if (individualOnfido.basicDetails?.phoneNumber) {
|
|
1679
|
-
const phone = {
|
|
1680
|
-
number: individualOnfido.basicDetails.phoneNumber.number,
|
|
1681
|
-
type: "mobile"
|
|
1682
|
-
};
|
|
1683
|
-
if (phone.number && legalEntity.individual) {
|
|
1684
|
-
legalEntity.individual.phone = phone;
|
|
1685
|
-
} else {
|
|
1686
|
-
delete legalEntity?.individual?.phone;
|
|
1687
|
-
}
|
|
1688
|
-
}
|
|
1689
|
-
return legalEntity;
|
|
1690
|
-
};
|
|
1691
|
-
const identityOnfidoBase = {
|
|
1692
|
-
role: {
|
|
1693
|
-
rule: "requiredIfDecisionMakerTask"
|
|
1694
|
-
},
|
|
1695
|
-
firstName: {
|
|
1696
|
-
rule: "REQUIRED"
|
|
1697
|
-
},
|
|
1698
|
-
lastName: {
|
|
1699
|
-
rule: "REQUIRED"
|
|
1700
|
-
},
|
|
1701
|
-
birthDate: {
|
|
1702
|
-
rule: "REQUIRED"
|
|
1703
|
-
},
|
|
1704
|
-
phoneNumber: {
|
|
1705
|
-
rules: ["requiredIfPhoneScenarioDisabled", "contactsIfRequiredForRole"]
|
|
1706
|
-
},
|
|
1707
|
-
email: {
|
|
1708
|
-
rule: "contactsIfRequiredForRole"
|
|
1709
|
-
},
|
|
1710
|
-
jobTitle: {
|
|
1711
|
-
rule: "jobTitleIfRequiredForRole"
|
|
1712
|
-
},
|
|
1713
|
-
placeOfBirth: {
|
|
1714
|
-
rule: "isPlaceOfBirthRequired"
|
|
1715
|
-
},
|
|
1716
|
-
nationality: {
|
|
1717
|
-
rule: "nationalityIfRequiredForRole"
|
|
1718
|
-
},
|
|
1719
|
-
address: {
|
|
1720
|
-
rule: "addressIfRequiredForCountry"
|
|
1721
|
-
},
|
|
1722
|
-
otherAddressInformation: {
|
|
1723
|
-
rule: "otherAddressInfoIfRequiredForCountry"
|
|
1724
|
-
},
|
|
1725
|
-
country: {
|
|
1726
|
-
rule: "REQUIRED"
|
|
1727
|
-
},
|
|
1728
|
-
postalCode: {
|
|
1729
|
-
rule: "postalCodeIfRequiredForCountry"
|
|
1730
|
-
},
|
|
1731
|
-
city: {
|
|
1732
|
-
rule: "cityIfRequiredForCountry"
|
|
1733
|
-
},
|
|
1734
|
-
stateOrProvince: {
|
|
1735
|
-
rule: "stateOrProvinceIfRequiredForCountry"
|
|
1736
|
-
},
|
|
1737
|
-
proofOfResidency: {
|
|
1738
|
-
rule: "isProofOfResidencyRequired"
|
|
1739
|
-
},
|
|
1740
|
-
proofOfNationalId: {
|
|
1741
|
-
rule: "isProofOfNationalIdRequired"
|
|
1742
|
-
},
|
|
1743
|
-
relationship: {
|
|
1744
|
-
rule: "legalRepresentativeRelationshipRequired"
|
|
1745
|
-
},
|
|
1746
|
-
proofOfRelationship: {
|
|
1747
|
-
rule: "isProofOfRelationshipRequired"
|
|
1748
|
-
},
|
|
1749
|
-
nomineeDirector: {
|
|
1750
|
-
rules: ["isGuidedDecisionMakersFlowDisabled", "nomineeDirectorRequiredForCountry"]
|
|
1751
|
-
},
|
|
1752
|
-
nomineeShareholder: {
|
|
1753
|
-
rules: ["isGuidedDecisionMakersFlowDisabled", "nomineeShareHolderRequiredForCountry"]
|
|
1754
|
-
},
|
|
1755
|
-
idVerificationMethod: {
|
|
1756
|
-
rule: "isIdVerificationMethodRequired"
|
|
1757
|
-
},
|
|
1758
|
-
idDocument: {
|
|
1759
|
-
// (either from Onfido or previously-uploaded document)
|
|
1760
|
-
rule: "isUsingInstantVerificationOrHasExistingDocument"
|
|
1761
|
-
},
|
|
1762
|
-
idDocumentType: {
|
|
1763
|
-
// If the user has a missing ID error and chooses manual flow
|
|
1764
|
-
rule: "isManualIdFlowAndHasMissingData"
|
|
1765
|
-
},
|
|
1766
|
-
/**
|
|
1767
|
-
* Below fields only relevant if manual ID is needed
|
|
1768
|
-
* @see identityNumber
|
|
1769
|
-
* @see idDocRequired
|
|
1770
|
-
*/
|
|
1771
|
-
idFrontPage: {
|
|
1772
|
-
rule: "hasChosenIdType"
|
|
1773
|
-
},
|
|
1774
|
-
idBackPage: {
|
|
1775
|
-
rule: "backPageIfRequiredForIdType"
|
|
1776
|
-
},
|
|
1777
|
-
// Fields required for Guided decision makers flow
|
|
1778
|
-
isSignatory: {
|
|
1779
|
-
rules: ["isGuidedDecisionMakersFlowEnabled", "requiredIfDecisionMakerTask"]
|
|
1780
|
-
},
|
|
1781
|
-
isOwner: {
|
|
1782
|
-
rules: ["isGuidedDecisionMakersFlowEnabled", "requiredIfDecisionMakerTask"]
|
|
1783
|
-
},
|
|
1784
|
-
isControllingPerson: {
|
|
1785
|
-
rules: ["isGuidedDecisionMakersFlowEnabled", "requiredIfDecisionMakerTask"]
|
|
1786
|
-
},
|
|
1787
|
-
isDirector: {
|
|
1788
|
-
rules: [
|
|
1789
|
-
"isGuidedDecisionMakersFlowEnabled",
|
|
1790
|
-
"requiredIfDecisionMakerTask",
|
|
1791
|
-
"isDirectorRequiredForCountry"
|
|
1792
|
-
]
|
|
1793
|
-
},
|
|
1794
|
-
isNomineeDirector: {
|
|
1795
|
-
rules: [
|
|
1796
|
-
"isGuidedDecisionMakersFlowEnabled",
|
|
1797
|
-
"requiredIfDecisionMakerTask",
|
|
1798
|
-
"nomineeDirectorRequiredForCountry"
|
|
1799
|
-
]
|
|
1800
|
-
},
|
|
1801
|
-
isNomineeShareholder: {
|
|
1802
|
-
rules: [
|
|
1803
|
-
"isGuidedDecisionMakersFlowEnabled",
|
|
1804
|
-
"requiredIfDecisionMakerTask",
|
|
1805
|
-
"nomineeShareHolderRequiredForCountry"
|
|
1806
|
-
]
|
|
1807
|
-
},
|
|
1808
|
-
// Japanese name fields
|
|
1809
|
-
jaHaniFirstName: {
|
|
1810
|
-
rule: "japanSpecificField"
|
|
1811
|
-
},
|
|
1812
|
-
jaHaniLastName: {
|
|
1813
|
-
rule: "japanSpecificField"
|
|
1814
|
-
},
|
|
1815
|
-
jaKanaFirstName: {
|
|
1816
|
-
rule: "japanSpecificField"
|
|
1817
|
-
},
|
|
1818
|
-
jaKanaLastName: {
|
|
1819
|
-
rule: "japanSpecificField"
|
|
1820
|
-
},
|
|
1821
|
-
// Japanese address fields
|
|
1822
|
-
jaHaniAddress: {
|
|
1823
|
-
rule: "japanSpecificField"
|
|
1824
|
-
},
|
|
1825
|
-
jaHaniCity: {
|
|
1826
|
-
rule: "japanSpecificField"
|
|
1827
|
-
},
|
|
1828
|
-
jaHaniStateOrProvince: {
|
|
1829
|
-
rule: "japanSpecificField"
|
|
1830
|
-
},
|
|
1831
|
-
jaKanaCity: {
|
|
1832
|
-
rule: "japanSpecificField"
|
|
1833
|
-
},
|
|
1834
|
-
jaKanaStateOrProvince: {
|
|
1835
|
-
rule: "japanSpecificField"
|
|
1836
|
-
}
|
|
1837
|
-
};
|
|
1838
|
-
const identityNumber = {
|
|
1839
|
-
idNumber: {
|
|
1840
|
-
rule: "idNumberRules",
|
|
1841
|
-
obscured: true
|
|
1842
|
-
},
|
|
1843
|
-
idNumberExempt: {
|
|
1844
|
-
rules: ["idNumberExemptIfApplicableCountry", "isDirectorIdNumberRequiredForCountry"]
|
|
1845
|
-
},
|
|
1846
|
-
idDocumentType: {
|
|
1847
|
-
// If the user chooses to not provide an ID number, we'll need an ID from them
|
|
1848
|
-
rule: "isManualIdFlowAndNotProvidingIdNumber"
|
|
1849
|
-
}
|
|
1850
|
-
};
|
|
1851
|
-
const additionalIdentityInfo = {
|
|
1852
|
-
typeOfIdentity: {
|
|
1853
|
-
rules: ["requiredIfCountryUsesMultipleTypesOfIdentity", "isDirectorIdNumberRequiredForCountry"]
|
|
1854
|
-
},
|
|
1855
|
-
issuerState: {
|
|
1856
|
-
rule: "issuerStateRequired"
|
|
1857
|
-
},
|
|
1858
|
-
licenseCardNumber: {
|
|
1859
|
-
rule: "licenseCardNumberRules"
|
|
1860
|
-
},
|
|
1861
|
-
expiryDate: {
|
|
1862
|
-
rule: "expiryDateRequired"
|
|
1863
|
-
}
|
|
1864
|
-
};
|
|
1865
|
-
const idDocRequired = {
|
|
1866
|
-
// These fields are relevant for the manual ID flow only.
|
|
1867
|
-
// If we get `L1_IDDOC` then we know we need to require a manual ID upload when the manual flow is used
|
|
1868
|
-
idDocumentType: {
|
|
1869
|
-
rule: "isManualIdFlow"
|
|
1870
|
-
}
|
|
1871
|
-
};
|
|
1872
|
-
const nationality = {
|
|
1873
|
-
nationality: {
|
|
1874
|
-
rule: "REQUIRED"
|
|
1875
|
-
}
|
|
1876
|
-
};
|
|
1877
|
-
const phoneNumberBase = {
|
|
1878
|
-
phoneNumber: {
|
|
1879
|
-
rule: "contactsIfRequiredForRole"
|
|
1880
|
-
}
|
|
1881
|
-
};
|
|
1882
|
-
const taxInformationBase = {
|
|
1883
|
-
taxInformation: { rule: "countryUsesTaxId" }
|
|
1884
|
-
};
|
|
1885
|
-
const individualOnfidoFieldsPerScenario = {
|
|
1886
|
-
L0: drop("address", "birthDate").from(identityOnfidoBase),
|
|
1887
|
-
L1: identityOnfidoBase,
|
|
1888
|
-
L1_ID: {
|
|
1889
|
-
...identityOnfidoBase,
|
|
1890
|
-
...identityNumber,
|
|
1891
|
-
...additionalIdentityInfo
|
|
1892
|
-
},
|
|
1893
|
-
L1_IDO: {
|
|
1894
|
-
// TODO: change idNumber rule to optional once optional fields are implemented
|
|
1895
|
-
...identityOnfidoBase,
|
|
1896
|
-
...identityNumber,
|
|
1897
|
-
...additionalIdentityInfo
|
|
1898
|
-
},
|
|
1899
|
-
L1_NAT: {
|
|
1900
|
-
...identityOnfidoBase,
|
|
1901
|
-
...identityNumber,
|
|
1902
|
-
...additionalIdentityInfo,
|
|
1903
|
-
...nationality
|
|
1904
|
-
},
|
|
1905
|
-
L_TAXINFO: { ...identityOnfidoBase, ...taxInformationBase },
|
|
1906
|
-
L1_IDDOC: idDocRequired,
|
|
1907
|
-
L_PH: phoneNumberBase
|
|
1908
|
-
};
|
|
1909
|
-
const parseIndividualOnfidoScenarios = (scenarios) => composePerScenarioFormConfigurations(scenarios, individualOnfidoFieldsPerScenario);
|
|
1910
|
-
const parseConfiguration = ({ scenarios }) => parseIndividualOnfidoScenarios(scenarios);
|
|
1911
|
-
const logger = createLogger();
|
|
1912
|
-
function IndividualOnfidoDropin({
|
|
1913
|
-
taskType = TaskTypes.INDIVIDUAL,
|
|
1914
|
-
parentLegalEntity,
|
|
1915
|
-
legalEntityResponse,
|
|
1916
|
-
handleHomeClick,
|
|
1917
|
-
isTargetLegalEntityType,
|
|
1918
|
-
country: parentCountry,
|
|
1919
|
-
problems: propProblems,
|
|
1920
|
-
onSubmit: externalOnSubmit,
|
|
1921
|
-
asModal = false,
|
|
1922
|
-
handleBackClick: externalBackClick,
|
|
1923
|
-
trustedFields,
|
|
1924
|
-
trustedFieldsProvider,
|
|
1925
|
-
trustedRoles
|
|
1926
|
-
}) {
|
|
1927
|
-
const { baseUrl, rootLegalEntityId } = useApiContext();
|
|
1928
|
-
const { accountHolder, setAccountHolder } = useAccountHolder();
|
|
1929
|
-
const { i18n } = useI18nContext();
|
|
1930
|
-
const { t } = useTranslation("individual");
|
|
1931
|
-
const userEvents = useAnalyticsContext();
|
|
1932
|
-
const { showToast, clearToasts } = useToastContext();
|
|
1933
|
-
const { isExperimentEnabled } = useExperimentsContext();
|
|
1934
|
-
const { data: versionData } = useVersionConfiguration();
|
|
1935
|
-
const { isSettingEnabled } = useSettingsContext();
|
|
1936
|
-
const queryClient = useQueryClient();
|
|
1937
|
-
const isGuidedDecisionMakersFlowEnabled = isExperimentEnabled("EnableGuidedDecisionMakersFlow") || isExperimentEnabled("DecisionMakersFlowOptimization_GuidedDecisionMakersFlow");
|
|
1938
|
-
const isGuidedDecisionMakersFlowDisabled = isExperimentEnabled("DisableGuidedDecisionMakersFlow");
|
|
1939
|
-
const defaultCountry = "NL";
|
|
1940
|
-
const { data: providerStatus } = useProviderStatus({
|
|
1941
|
-
providers: ["idDocument"],
|
|
1942
|
-
country: legalEntityResponse ? getLegalEntityCountry(legalEntityResponse) : defaultCountry
|
|
1943
|
-
});
|
|
1944
|
-
const isInstantVerificationEnabled = providerStatus?.statuses?.idDocument?.enabled ?? true;
|
|
1945
|
-
const { mutateAsync: updateLegalEntity } = useUpdateLegalEntity();
|
|
1946
|
-
const isRoleFieldNeeded = taskType === TaskTypes.DECISION_MAKER || taskType === TaskTypes.TRUST_MEMBER_COMPANY_OWNER || taskType === TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY_OWNER;
|
|
1947
|
-
const dataFromResponse = useMemo(() => {
|
|
1948
|
-
const formStateData = individualFormDefaultData.value;
|
|
1949
|
-
individualFormDefaultData.value = null;
|
|
1950
|
-
if (legalEntityResponse) {
|
|
1951
|
-
return {
|
|
1952
|
-
...mapLegalEntityToIndividualOnfidoSchema(
|
|
1953
|
-
legalEntityResponse,
|
|
1954
|
-
isTargetLegalEntityType,
|
|
1955
|
-
isRoleFieldNeeded,
|
|
1956
|
-
parentLegalEntity
|
|
1957
|
-
),
|
|
1958
|
-
...formStateData
|
|
1959
|
-
};
|
|
1960
|
-
}
|
|
1961
|
-
return {
|
|
1962
|
-
additionalPersonalDetails: {
|
|
1963
|
-
country: parentCountry
|
|
1964
|
-
},
|
|
1965
|
-
...formStateData
|
|
1966
|
-
};
|
|
1967
|
-
}, [
|
|
1968
|
-
legalEntityResponse,
|
|
1969
|
-
parentCountry,
|
|
1970
|
-
isTargetLegalEntityType,
|
|
1971
|
-
isRoleFieldNeeded,
|
|
1972
|
-
parentLegalEntity
|
|
1973
|
-
]);
|
|
1974
|
-
const [matchingScenario, setMatchingScenario] = useState();
|
|
1975
|
-
const [validationErrors, setValidationErrors] = useState();
|
|
1976
|
-
const [loadingStatus, setLoadingStatus] = useState("success");
|
|
1977
|
-
const [existingAttachments, setExistingAttachments] = useState();
|
|
1978
|
-
const [documents, setDocuments] = useState();
|
|
1979
|
-
const [country, setCountry] = useState(
|
|
1980
|
-
dataFromResponse?.additionalPersonalDetails?.country ?? parentCountry
|
|
1981
|
-
);
|
|
1982
|
-
const [derivedProps, setDerivedProps] = useState();
|
|
1983
|
-
const [nextHandler, setNextHandler] = useState();
|
|
1984
|
-
const problems = useMemo(
|
|
1985
|
-
() => ({
|
|
1986
|
-
...propProblems,
|
|
1987
|
-
validationErrors
|
|
1988
|
-
}),
|
|
1989
|
-
[propProblems, validationErrors]
|
|
1990
|
-
);
|
|
1991
|
-
const hasVerificationErrors = propProblems?.verificationErrors && Object.keys(propProblems.verificationErrors).length > 0;
|
|
1992
|
-
useEffect(() => {
|
|
1993
|
-
userEvents.updateBaseTrackingPayload({ task: taskType });
|
|
1994
|
-
userEvents.addTaskEvent("Landed on page", {
|
|
1995
|
-
actionType: "start"
|
|
1996
|
-
});
|
|
1997
|
-
}, []);
|
|
1998
|
-
const individualFieldValidations = useCallback(
|
|
1999
|
-
(data2) => ({
|
|
2000
|
-
basicDetails: basicDetailsValidators({
|
|
2001
|
-
isExperimentEnabled
|
|
2002
|
-
}),
|
|
2003
|
-
additionalPersonalDetails: additionalPersonalDetailsValidators({
|
|
2004
|
-
country: data2?.additionalPersonalDetails?.country ?? country,
|
|
2005
|
-
isExperimentEnabled,
|
|
2006
|
-
isSettingEnabled,
|
|
2007
|
-
taskType,
|
|
2008
|
-
idNumberType: data2?.additionalPersonalDetails?.typeOfIdentity,
|
|
2009
|
-
idNumberExempt: data2?.additionalPersonalDetails?.idNumberExempt,
|
|
2010
|
-
idNumber: data2?.additionalPersonalDetails?.idNumber,
|
|
2011
|
-
existingIdNumber: dataFromResponse.additionalPersonalDetails?.idNumber,
|
|
2012
|
-
formVerificationErrors: problems?.verificationErrors?.additionalPersonalDetails,
|
|
2013
|
-
i18n,
|
|
2014
|
-
taxIdNumberType: data2?.additionalPersonalDetails?.taxInformation?.length ? data2?.additionalPersonalDetails?.taxInformation[0]?.type : void 0
|
|
2015
|
-
})
|
|
2016
|
-
}),
|
|
2017
|
-
[
|
|
2018
|
-
country,
|
|
2019
|
-
dataFromResponse.additionalPersonalDetails?.idNumber,
|
|
2020
|
-
i18n,
|
|
2021
|
-
isExperimentEnabled,
|
|
2022
|
-
isSettingEnabled,
|
|
2023
|
-
problems?.verificationErrors?.additionalPersonalDetails,
|
|
2024
|
-
taskType
|
|
2025
|
-
]
|
|
2026
|
-
);
|
|
2027
|
-
const validatePhoneNumber = useValidatePhoneNumberImperatively();
|
|
2028
|
-
const { mutateAsync: verifyIdNumber2 } = useVerifyIdNumber();
|
|
2029
|
-
const individualFieldAsyncValidations = useCallback(
|
|
2030
|
-
(data2) => ({
|
|
2031
|
-
basicDetails: {
|
|
2032
|
-
phoneNumber: getAsyncPhoneValidationRules(validatePhoneNumber).phoneNumber
|
|
2033
|
-
},
|
|
2034
|
-
additionalPersonalDetails: {
|
|
2035
|
-
idNumber: getAsyncIdNumberValidationRule(verifyIdNumber2, data2?.additionalPersonalDetails).idNumber
|
|
2036
|
-
}
|
|
2037
|
-
}),
|
|
2038
|
-
[verifyIdNumber2, validatePhoneNumber]
|
|
2039
|
-
);
|
|
2040
|
-
const defaultData = useMemo(() => {
|
|
2041
|
-
if (!documents) return dataFromResponse;
|
|
2042
|
-
return {
|
|
2043
|
-
...dataFromResponse,
|
|
2044
|
-
...drop("idDocument").from(documents),
|
|
2045
|
-
idVerificationMethod: {
|
|
2046
|
-
idDocument: documents.idDocument,
|
|
2047
|
-
idVerificationMethod: "existingDocument"
|
|
2048
|
-
}
|
|
2049
|
-
};
|
|
2050
|
-
}, [documents, dataFromResponse]);
|
|
2051
|
-
const form = useMultiForm({
|
|
2052
|
-
requiredFields: derivedProps?.requiredFields,
|
|
2053
|
-
defaultData,
|
|
2054
|
-
rules: individualFieldValidations,
|
|
2055
|
-
asyncRules: individualFieldAsyncValidations,
|
|
2056
|
-
optionalFields: derivedProps?.optionalFields,
|
|
2057
|
-
obscuredFields: {
|
|
2058
|
-
/**takes care of scenario when the 4 digit provided is wrong based on verification errors and
|
|
2059
|
-
* we need to show validation error for defaultData which is already saved
|
|
2060
|
-
**/
|
|
2061
|
-
additionalPersonalDetails: check4DigitSsnFailed(
|
|
2062
|
-
problems?.verificationErrors?.additionalPersonalDetails
|
|
2063
|
-
) ? [] : ["idNumber"]
|
|
2064
|
-
}
|
|
2065
|
-
});
|
|
2066
|
-
const documentUtils = documentApiUtils({
|
|
2067
|
-
baseUrl: baseUrl.value,
|
|
2068
|
-
rootLegalEntityId: rootLegalEntityId.value
|
|
2069
|
-
});
|
|
2070
|
-
const { data, requiredFields } = form;
|
|
2071
|
-
useEffect(() => {
|
|
2072
|
-
setCountry(data?.additionalPersonalDetails?.country ?? parentCountry);
|
|
2073
|
-
}, [data?.additionalPersonalDetails?.country, parentCountry]);
|
|
2074
|
-
const { data: scenarios } = useScenarios(country, LegalEntityTypes.INDIVIDUAL);
|
|
2075
|
-
useEffect(() => {
|
|
2076
|
-
if (!scenarios) return;
|
|
2077
|
-
setHasMotionCaptureScenario(scenarios);
|
|
2078
|
-
setMatchingScenario(scenarios);
|
|
2079
|
-
}, [scenarios]);
|
|
2080
|
-
const { fieldConfigurations } = useScenarioConfiguration({
|
|
2081
|
-
parseConfiguration,
|
|
2082
|
-
legalEntityType: LegalEntityTypes.INDIVIDUAL,
|
|
2083
|
-
setLoadingStatus,
|
|
2084
|
-
country
|
|
2085
|
-
});
|
|
2086
|
-
const fieldsFromCustomRules = useMemo(
|
|
2087
|
-
() => individualOnfidoRules({
|
|
2088
|
-
matchingScenario,
|
|
2089
|
-
data,
|
|
2090
|
-
country: data?.additionalPersonalDetails?.country ?? country,
|
|
2091
|
-
taskType,
|
|
2092
|
-
isExperimentEnabled,
|
|
2093
|
-
rootLegalEntity: parentLegalEntity,
|
|
2094
|
-
problems,
|
|
2095
|
-
version: versionData?.version
|
|
2096
|
-
}),
|
|
2097
|
-
[
|
|
2098
|
-
country,
|
|
2099
|
-
matchingScenario,
|
|
2100
|
-
data,
|
|
2101
|
-
isExperimentEnabled,
|
|
2102
|
-
parentLegalEntity,
|
|
2103
|
-
taskType,
|
|
2104
|
-
problems,
|
|
2105
|
-
versionData?.version
|
|
2106
|
-
]
|
|
2107
|
-
);
|
|
2108
|
-
useEffect(() => {
|
|
2109
|
-
const derivedProps2 = getPropsFromConfigurations({
|
|
2110
|
-
scenarioConfiguration: fieldConfigurations,
|
|
2111
|
-
forms: individualOnfidoForms,
|
|
2112
|
-
remediationActions: problems?.remediationActions ? Object.values(problems?.remediationActions) : [],
|
|
2113
|
-
dataMissingErrors: problems?.missingData ?? [],
|
|
2114
|
-
fieldsWithExistingData: legalEntityResponse ? getFieldsWithExistingData(
|
|
2115
|
-
legalEntityResponse,
|
|
2116
|
-
individualOnfidoApiKeyMapping,
|
|
2117
|
-
individualOnfidoDocumentMapping,
|
|
2118
|
-
[
|
|
2119
|
-
"additionalPersonalDetails.typeOfIdentity",
|
|
2120
|
-
"additionalPersonalDetails.idNumber",
|
|
2121
|
-
"additionalPersonalDetails.stateOrProvince",
|
|
2122
|
-
"additionalPersonalDetails.issuerState"
|
|
2123
|
-
]
|
|
2124
|
-
) : [],
|
|
2125
|
-
customRules: fieldsFromCustomRules,
|
|
2126
|
-
legalEntityType: legalEntityResponse?.type,
|
|
2127
|
-
legalEntityTrustedFields: [],
|
|
2128
|
-
remediationFieldAsOptional: true
|
|
2129
|
-
});
|
|
2130
|
-
const updatedDerivedProps = mandateIdVerificationForMotionCapture(
|
|
2131
|
-
showIndividualMotionCapture?.value,
|
|
2132
|
-
derivedProps2
|
|
2133
|
-
);
|
|
2134
|
-
if (updatedDerivedProps) {
|
|
2135
|
-
setDerivedProps(updatedDerivedProps);
|
|
2136
|
-
}
|
|
2137
|
-
}, [
|
|
2138
|
-
fieldConfigurations,
|
|
2139
|
-
legalEntityResponse,
|
|
2140
|
-
fieldsFromCustomRules,
|
|
2141
|
-
problems?.remediationActions,
|
|
2142
|
-
problems?.missingData
|
|
2143
|
-
]);
|
|
2144
|
-
useEffect(() => {
|
|
2145
|
-
if (!legalEntityResponse?.documentDetails?.length) return;
|
|
2146
|
-
documentUtils.fetchDocuments(legalEntityResponse.documentDetails, legalEntityResponse?.id).then((res) => {
|
|
2147
|
-
setExistingAttachments(res[0].attachments);
|
|
2148
|
-
setDocuments(mapApiDocumentToIndividualDocuments(legalEntityResponse?.id));
|
|
2149
|
-
}).catch(() => {
|
|
2150
|
-
showToast({ label: i18n.get("failedToFetchRelevantDocuments"), variant: "error" });
|
|
2151
|
-
});
|
|
2152
|
-
}, []);
|
|
2153
|
-
const forms = useMemo(() => {
|
|
2154
|
-
const requiredForms = getRequiredForms(
|
|
2155
|
-
individualOnfidoForms,
|
|
2156
|
-
derivedProps?.requiredFields,
|
|
2157
|
-
derivedProps?.optionalFields
|
|
2158
|
-
);
|
|
2159
|
-
const filteredForms = !isInstantVerificationEnabled ? requiredForms.filter((f) => f.formId !== "idVerificationMethod") : requiredForms;
|
|
2160
|
-
return addValidityToForms(filteredForms, form.isValid, problems);
|
|
2161
|
-
}, [derivedProps, form.isValid, isInstantVerificationEnabled, problems]);
|
|
2162
|
-
const { mutateAsync: getIdVerificationStartCheck } = useIdVerificationStartCheck();
|
|
2163
|
-
const handleInstantIdVerificationStartCheck = async (onfidoResponse, legalEntityId) => {
|
|
2164
|
-
const providerId = idVerificationProviderId.value;
|
|
2165
|
-
if (!providerId) throw Error("idVerificationProviderId not yet set");
|
|
2166
|
-
const data2 = {
|
|
2167
|
-
providerId,
|
|
2168
|
-
legalEntityId,
|
|
2169
|
-
captureMetadata: onfidoResponse
|
|
2170
|
-
};
|
|
2171
|
-
await getIdVerificationStartCheck(data2);
|
|
2172
|
-
};
|
|
2173
|
-
const roleTypes = isRoleFieldNeeded && parentLegalEntity ? getAllowedDecisionMakerRoles(parentLegalEntity, taskType, matchingScenario) : [];
|
|
2174
|
-
const { mutateAsync: createLegalEntity } = useCreateLegalEntity();
|
|
2175
|
-
const idDocumentTypeOptions = getLocalizedIdDocumentTypeOptions(country);
|
|
2176
|
-
const submitLegalEntity = async ({
|
|
2177
|
-
dataSubmitted,
|
|
2178
|
-
legalEntity,
|
|
2179
|
-
idDocumentType
|
|
2180
|
-
}) => {
|
|
2181
|
-
let updatedLegalEntity;
|
|
2182
|
-
const existingLeId = legalEntityResponse?.id;
|
|
2183
|
-
if (legalEntity.individual && legalEntityResponse?.individual?.support) {
|
|
2184
|
-
legalEntity.individual.support = customerSupportPresubmitProcess(
|
|
2185
|
-
legalEntityResponse,
|
|
2186
|
-
legalEntity
|
|
2187
|
-
);
|
|
2188
|
-
}
|
|
2189
|
-
if (!existingLeId) {
|
|
2190
|
-
updatedLegalEntity = await createLegalEntity(legalEntity);
|
|
2191
|
-
userEvents.addTaskEvent("Success", {
|
|
2192
|
-
actionType: "submit",
|
|
2193
|
-
countryOfRegistration: dataSubmitted.additionalPersonalDetails?.country,
|
|
2194
|
-
roles: dataSubmitted.basicDetails?.role
|
|
2195
|
-
});
|
|
2196
|
-
} else {
|
|
2197
|
-
updatedLegalEntity = await updateLegalEntity({
|
|
2198
|
-
...drop("type").from(legalEntity),
|
|
2199
|
-
id: existingLeId
|
|
2200
|
-
});
|
|
2201
|
-
userEvents.addTaskEvent("Success", {
|
|
2202
|
-
actionType: "submit",
|
|
2203
|
-
countryOfRegistration: dataSubmitted.additionalPersonalDetails?.country,
|
|
2204
|
-
documentType: idDocumentType
|
|
2205
|
-
});
|
|
2206
|
-
}
|
|
2207
|
-
return updatedLegalEntity;
|
|
2208
|
-
};
|
|
2209
|
-
const submitDocuments = async ({
|
|
2210
|
-
legalEntity,
|
|
2211
|
-
dataSubmitted
|
|
2212
|
-
}) => {
|
|
2213
|
-
const idDocument2 = dataSubmitted.idVerificationMethod?.idDocument;
|
|
2214
|
-
if (idDocument2?.instantIdVerificationData) {
|
|
2215
|
-
if (providerStatus?.statuses?.idDocument?.enabled === false) {
|
|
2216
|
-
throw new Error("Provider unexpectedly disabled instant verification flow");
|
|
2217
|
-
}
|
|
2218
|
-
await handleInstantIdVerificationStartCheck(
|
|
2219
|
-
idDocument2.instantIdVerificationData,
|
|
2220
|
-
legalEntity.id
|
|
2221
|
-
);
|
|
2222
|
-
} else {
|
|
2223
|
-
const formattedDocuments = await mapIndividualDocumentToApiDocument(
|
|
2224
|
-
dataSubmitted,
|
|
2225
|
-
legalEntity.id
|
|
2226
|
-
);
|
|
2227
|
-
if (!formattedDocuments || formattedDocuments?.length === 0) {
|
|
2228
|
-
if (existingAttachments?.length)
|
|
2229
|
-
logger.log(
|
|
2230
|
-
"User has already uploaded documents and is not changing them, nothing needs to be done"
|
|
2231
|
-
);
|
|
2232
|
-
else
|
|
2233
|
-
logger.error(
|
|
2234
|
-
`formattedDocuments is empty, but there are no existing documents. Something has gone wrong`
|
|
2235
|
-
);
|
|
2236
|
-
return;
|
|
2237
|
-
}
|
|
2238
|
-
formattedDocuments[0].attachments = mergeAttachments(
|
|
2239
|
-
existingAttachments ?? [],
|
|
2240
|
-
formattedDocuments[0]?.attachments ?? []
|
|
2241
|
-
).filter((attachment) => attachment.content);
|
|
2242
|
-
const uploadedDocuments = await documentUtils.uploadDocuments(
|
|
2243
|
-
formattedDocuments,
|
|
2244
|
-
legalEntity.id
|
|
2245
|
-
);
|
|
2246
|
-
uploadedDocuments?.forEach((doc) => {
|
|
2247
|
-
userEvents.addTaskEvent("Success", {
|
|
2248
|
-
actionType: "upload",
|
|
2249
|
-
documentType: doc.type,
|
|
2250
|
-
fileExtention: doc?.attachments?.map((item) => getFileExtention(item.pageName ?? "")).filter((item) => item !== void 0) ?? void 0
|
|
2251
|
-
});
|
|
2252
|
-
});
|
|
2253
|
-
}
|
|
2254
|
-
};
|
|
2255
|
-
const hasRolesChanged = (legalEntityId, existingEntityAssociations, newRoles) => {
|
|
2256
|
-
const existingRoles = existingEntityAssociations?.filter((association) => association.legalEntityId === legalEntityId).map(({ type }) => type);
|
|
2257
|
-
return !doArraysMatch(existingRoles, newRoles);
|
|
2258
|
-
};
|
|
2259
|
-
const attachAssociationToParentLegalEntity = async ({
|
|
2260
|
-
legalEntity,
|
|
2261
|
-
parentLE,
|
|
2262
|
-
dataSubmitted
|
|
2263
|
-
}) => {
|
|
2264
|
-
const newRoles = taskType === TaskTypes.DECISION_MAKER || taskType === TaskTypes.TRUST_MEMBER_COMPANY_OWNER || taskType === TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY_OWNER ? dataSubmitted?.basicDetails?.role : null;
|
|
2265
|
-
const existingEntityAssociations = getOwnEntityAssociations(parentLE);
|
|
2266
|
-
if (newRoles && (hasRolesChanged(legalEntity?.id, existingEntityAssociations, newRoles) || dataFromResponse.basicDetails?.jobTitle !== dataSubmitted?.basicDetails?.jobTitle || hasNomineesChanged(dataFromResponse.basicDetails, dataSubmitted.basicDetails))) {
|
|
2267
|
-
const updatedParentLegalEntity = {
|
|
2268
|
-
entityAssociations: [
|
|
2269
|
-
...newRoles.map((role) => ({
|
|
2270
|
-
type: role,
|
|
2271
|
-
legalEntityId: legalEntity.id,
|
|
2272
|
-
...DECISION_MAKER_TYPES_WITH_JOBTITLE$1.some((type) => type === role) && {
|
|
2273
|
-
jobTitle: dataSubmitted?.basicDetails?.jobTitle
|
|
2274
|
-
}
|
|
2275
|
-
})) || [],
|
|
2276
|
-
...existingEntityAssociations.filter((ea) => ea.legalEntityId !== legalEntity.id) || []
|
|
2277
|
-
]
|
|
2278
|
-
};
|
|
2279
|
-
const nomineeDataSource = !isGuidedDecisionMakersFlowDisabled && isGuidedDecisionMakersFlowEnabled ? dataSubmitted?.uboQuestionnaire : dataSubmitted.basicDetails;
|
|
2280
|
-
if (nomineeDataSource && updatedParentLegalEntity.entityAssociations) {
|
|
2281
|
-
updatedParentLegalEntity.entityAssociations = updatedParentLegalEntity.entityAssociations.map(
|
|
2282
|
-
(ea) => attachNomineeToRole(ea, country, nomineeDataSource)
|
|
2283
|
-
);
|
|
2284
|
-
}
|
|
2285
|
-
await updateLegalEntity({ ...updatedParentLegalEntity, id: parentLE.id });
|
|
2286
|
-
}
|
|
2287
|
-
};
|
|
2288
|
-
const onSubmit = async () => {
|
|
2289
|
-
setLoadingStatus("loading");
|
|
2290
|
-
const dataSubmitted = omitObscuredFieldsIfUnchanged(
|
|
2291
|
-
individualOnfidoObscuredFields,
|
|
2292
|
-
data,
|
|
2293
|
-
dataFromResponse
|
|
2294
|
-
);
|
|
2295
|
-
if (!dataSubmitted) {
|
|
2296
|
-
return;
|
|
2297
|
-
}
|
|
2298
|
-
try {
|
|
2299
|
-
const legalEntity = mapIndividualOnfidoSchemaToLegalEntity(
|
|
2300
|
-
dataSubmitted,
|
|
2301
|
-
isExperimentEnabled,
|
|
2302
|
-
matchingScenario
|
|
2303
|
-
);
|
|
2304
|
-
const idDocumentType = idDocumentTypeOptions.find(
|
|
2305
|
-
({ id }) => dataSubmitted?.idVerificationMethod?.idDocument?.idDocumentType === id
|
|
2306
|
-
)?.id;
|
|
2307
|
-
legalEntity.entityAssociations = filterOutUnwantedAssociationsIfRootLE(
|
|
2308
|
-
taskType,
|
|
2309
|
-
legalEntityResponse,
|
|
2310
|
-
accountHolder || void 0
|
|
2311
|
-
);
|
|
2312
|
-
const submittedLegalEntity = await submitLegalEntity({
|
|
2313
|
-
dataSubmitted,
|
|
2314
|
-
legalEntity,
|
|
2315
|
-
idDocumentType
|
|
2316
|
-
});
|
|
2317
|
-
setAccountHolder(accountHolder);
|
|
2318
|
-
if (dataSubmitted.idVerificationMethod && dataSubmitted.idVerificationMethod?.idVerificationMethod !== "existingDocument" || hasVerificationErrors) {
|
|
2319
|
-
const isBafinSignatory = dataSubmitted?.basicDetails?.role?.includes(DecisionMakerTypes.SIGNATORY) && matchingScenario?.includes(Scenarios.L_BAFIN);
|
|
2320
|
-
if (!isBafinSignatory) {
|
|
2321
|
-
await submitDocuments({ legalEntity: submittedLegalEntity, dataSubmitted });
|
|
2322
|
-
}
|
|
2323
|
-
}
|
|
2324
|
-
if (parentLegalEntity) {
|
|
2325
|
-
await attachAssociationToParentLegalEntity({
|
|
2326
|
-
legalEntity: submittedLegalEntity,
|
|
2327
|
-
parentLE: parentLegalEntity,
|
|
2328
|
-
dataSubmitted
|
|
2329
|
-
});
|
|
2330
|
-
queryClient.invalidateQueries({
|
|
2331
|
-
queryKey: ["legalEntity", parentLegalEntity.id],
|
|
2332
|
-
refetchType: "all"
|
|
2333
|
-
});
|
|
2334
|
-
}
|
|
2335
|
-
idNowModalChildEntityId.value = submittedLegalEntity;
|
|
2336
|
-
setLoadingStatus("success");
|
|
2337
|
-
clearToasts();
|
|
2338
|
-
externalOnSubmit?.(dataSubmitted, matchingScenario);
|
|
2339
|
-
} catch (e) {
|
|
2340
|
-
const eventsAdditionalData = {};
|
|
2341
|
-
logger.error("Failed to update individual", e);
|
|
2342
|
-
if (isValidationError(e)) {
|
|
2343
|
-
const getErrors = processValidationErrors(e, TaskTypes.INDIVIDUAL);
|
|
2344
|
-
if (getErrors && !Object.keys(getErrors).length) {
|
|
2345
|
-
showToast({ label: i18n.get("failedToUpdateDetails"), variant: "error" });
|
|
2346
|
-
eventsAdditionalData.unmappedErrorNames = e.invalidFields?.map((field) => field.name).filter(Boolean);
|
|
2347
|
-
} else {
|
|
2348
|
-
setValidationErrors(getErrors);
|
|
2349
|
-
}
|
|
2350
|
-
} else if (isMaintenanceModeError(e)) {
|
|
2351
|
-
showToast({
|
|
2352
|
-
label: i18n.get("maintenanceModeMessage"),
|
|
2353
|
-
variant: "error",
|
|
2354
|
-
duration: "indefinite"
|
|
2355
|
-
});
|
|
2356
|
-
} else {
|
|
2357
|
-
showToast({ label: i18n.get("failedToUpdateDetails"), variant: "error" });
|
|
2358
|
-
}
|
|
2359
|
-
setLoadingStatus("success");
|
|
2360
|
-
userEvents.addTaskEvent("Encountered error", {
|
|
2361
|
-
actionType: "submit",
|
|
2362
|
-
additionalData: eventsAdditionalData,
|
|
2363
|
-
returnType: e?.errorCode,
|
|
2364
|
-
returnValue: e?.title || "backend"
|
|
2365
|
-
});
|
|
2366
|
-
}
|
|
2367
|
-
};
|
|
2368
|
-
const datasetUtils = datasetUtilities(i18n.locale);
|
|
2369
|
-
const formatIdDocument = (idDocument2) => {
|
|
2370
|
-
if (!idDocument2) return void 0;
|
|
2371
|
-
const documentType = idDocument2?.instantIdVerificationData ? onfidoDocumentTypeMapping.find(
|
|
2372
|
-
(document2) => idDocument2.instantIdVerificationData?.document_front.type === document2.id
|
|
2373
|
-
) : idDocumentTypeOptions.find(({ id }) => idDocument2.idDocumentType === id);
|
|
2374
|
-
if (!documentType) return void 0;
|
|
2375
|
-
const frontPage = idDocument2.idFrontPage?.[0];
|
|
2376
|
-
const backPage = idDocument2.idBackPage?.[0];
|
|
2377
|
-
if (!frontPage) return void 0;
|
|
2378
|
-
return {
|
|
2379
|
-
documentType: i18n.get(documentType.name),
|
|
2380
|
-
...backPage && documentType.hasBackPage ? {
|
|
2381
|
-
frontPage: frontPage.name,
|
|
2382
|
-
backPage: backPage.name
|
|
2383
|
-
} : {
|
|
2384
|
-
fileName: frontPage.name
|
|
2385
|
-
}
|
|
2386
|
-
};
|
|
2387
|
-
};
|
|
2388
|
-
const formatFileSummaryData = ({
|
|
2389
|
-
idVerificationMethod,
|
|
2390
|
-
manualIdUpload,
|
|
2391
|
-
proofOfNationalId,
|
|
2392
|
-
proofOfResidency,
|
|
2393
|
-
proofOfRelationship
|
|
2394
|
-
}) => {
|
|
2395
|
-
const proofOfNationalIdFile = proofOfNationalId?.proofOfNationalId?.[0];
|
|
2396
|
-
const proofOfResidencyFile = proofOfResidency?.proofOfResidency?.[0];
|
|
2397
|
-
const proofOfRelationshipFile = proofOfRelationship?.proofOfRelationship?.[0];
|
|
2398
|
-
const idDocument2 = idVerificationMethod?.idVerificationMethod === "manualVerification" ? manualIdUpload : idVerificationMethod?.idDocument;
|
|
2399
|
-
return {
|
|
2400
|
-
...(idDocument2?.idDocumentType || idDocument2?.instantIdVerificationData) && {
|
|
2401
|
-
idDocument: formatIdDocument(idDocument2)
|
|
2402
|
-
},
|
|
2403
|
-
...proofOfNationalIdFile && {
|
|
2404
|
-
proofOfNationalId: {
|
|
2405
|
-
fileName: proofOfNationalIdFile.name
|
|
2406
|
-
}
|
|
2407
|
-
},
|
|
2408
|
-
...proofOfResidencyFile && {
|
|
2409
|
-
proofOfResidency: {
|
|
2410
|
-
fileName: proofOfResidencyFile.name,
|
|
2411
|
-
description: proofOfResidency?.description
|
|
2412
|
-
}
|
|
2413
|
-
},
|
|
2414
|
-
...proofOfRelationshipFile && {
|
|
2415
|
-
proofOfRelationship: {
|
|
2416
|
-
fileName: proofOfRelationshipFile.name,
|
|
2417
|
-
description: proofOfRelationship?.description
|
|
2418
|
-
}
|
|
2419
|
-
}
|
|
2420
|
-
};
|
|
2421
|
-
};
|
|
2422
|
-
const isManualVerificationOrExistingDoc = (idVerificationMethod) => idVerificationMethod === "manualVerification" || idVerificationMethod === "existingDocument";
|
|
2423
|
-
const formatDataForSummary = () => {
|
|
2424
|
-
let summaryData = cloneObject(data);
|
|
2425
|
-
if (summaryData?.basicDetails?.phoneNumber) {
|
|
2426
|
-
summaryData.basicDetails.phoneNumber = summaryData.basicDetails.phoneNumber.number;
|
|
2427
|
-
}
|
|
2428
|
-
if (summaryData.additionalPersonalDetails?.nationality) {
|
|
2429
|
-
summaryData.additionalPersonalDetails.nationality = datasetUtils.getCountryName(
|
|
2430
|
-
summaryData.additionalPersonalDetails.nationality
|
|
2431
|
-
);
|
|
2432
|
-
}
|
|
2433
|
-
if (data.additionalPersonalDetails) {
|
|
2434
|
-
if (isCompatibleJapanVersion(country, versionData?.version)) {
|
|
2435
|
-
summaryData.additionalPersonalDetails = {
|
|
2436
|
-
...drop(...JP_ADDRESS_REQUIRED_FIELDS).from(summaryData.additionalPersonalDetails),
|
|
2437
|
-
...mapJpAddressSummary(data.additionalPersonalDetails, datasetUtils)
|
|
2438
|
-
};
|
|
2439
|
-
} else {
|
|
2440
|
-
summaryData.additionalPersonalDetails = {
|
|
2441
|
-
...summaryData.additionalPersonalDetails,
|
|
2442
|
-
...mapAddressLabels(data.additionalPersonalDetails, datasetUtils)
|
|
2443
|
-
};
|
|
2444
|
-
}
|
|
2445
|
-
}
|
|
2446
|
-
if (summaryData.basicDetails?.accountHolder) {
|
|
2447
|
-
summaryData.basicDetails.accountHolder = i18n.get(summaryData.basicDetails.accountHolder);
|
|
2448
|
-
}
|
|
2449
|
-
if (summaryData.additionalPersonalDetails?.birthDate) {
|
|
2450
|
-
summaryData.additionalPersonalDetails.birthDate = localizeDateString(
|
|
2451
|
-
summaryData.additionalPersonalDetails.birthDate,
|
|
2452
|
-
i18n.locale
|
|
2453
|
-
);
|
|
2454
|
-
}
|
|
2455
|
-
if (isManualVerificationOrExistingDoc(summaryData.idVerificationMethod?.idVerificationMethod) || summaryData.proofOfResidency) {
|
|
2456
|
-
const fileSummaryData = formatFileSummaryData(data);
|
|
2457
|
-
summaryData = { ...summaryData, ...fileSummaryData };
|
|
2458
|
-
summaryData.manualIdUpload = { ...summaryData.idDocument };
|
|
2459
|
-
summaryData.idVerificationMethod.idDocument = { ...summaryData.idDocument };
|
|
2460
|
-
}
|
|
2461
|
-
if (summaryData.additionalPersonalDetails?.taxInformation) {
|
|
2462
|
-
const taxInformation = summaryData.additionalPersonalDetails.taxInformation.find(
|
|
2463
|
-
(taxId) => taxId.country === data.additionalPersonalDetails?.nationality
|
|
2464
|
-
);
|
|
2465
|
-
if (taxInformation) {
|
|
2466
|
-
delete summaryData.additionalPersonalDetails.taxInformation;
|
|
2467
|
-
summaryData.additionalPersonalDetails[taxInformation.type] = taxInformation.number;
|
|
2468
|
-
}
|
|
2469
|
-
}
|
|
2470
|
-
if (summaryData?.signatoryQuestionnaire) {
|
|
2471
|
-
summaryData.signatoryQuestionnaire = data?.signatoryQuestionnaire?.isSignatory === GuidanceQuestionValues.YES ? [i18n.get("signatorySummaryLabel")] : [];
|
|
2472
|
-
}
|
|
2473
|
-
if (summaryData?.uboQuestionnaire) {
|
|
2474
|
-
const roleFieldToLabelMap = {
|
|
2475
|
-
isOwner: "ownerSummaryLabel",
|
|
2476
|
-
isControllingPerson: "controllingPersonSummaryLabel",
|
|
2477
|
-
isDirector: "directorSummaryLabel"
|
|
2478
|
-
};
|
|
2479
|
-
summaryData.uboQuestionnaire = Object.keys(roleFieldToLabelMap).flatMap(
|
|
2480
|
-
(field) => data?.uboQuestionnaire?.[field] === GuidanceQuestionValues.YES ? [t(($) => $[roleFieldToLabelMap[field]])] : []
|
|
2481
|
-
);
|
|
2482
|
-
}
|
|
2483
|
-
return summaryData;
|
|
2484
|
-
};
|
|
2485
|
-
const omittedKeysForSummary = [
|
|
2486
|
-
...taskType === TaskTypes.DECISION_MAKER ? ["role"] : [],
|
|
2487
|
-
...data?.additionalPersonalDetails?.idNumberExempt ? ["idNumber"] : [],
|
|
2488
|
-
...isManualVerificationOrExistingDoc(data?.idVerificationMethod?.idVerificationMethod) ? ["idVerificationMethod", "modificationDate"] : []
|
|
2489
|
-
];
|
|
2490
|
-
const isUploadEmpty = !data?.manualIdUpload || Object.keys(data?.manualIdUpload).length === 0;
|
|
2491
|
-
const omittedFormsForSummary = [
|
|
2492
|
-
// 1. Omit idDocument if instant OR (manual/existing AND upload is empty)
|
|
2493
|
-
...data?.idVerificationMethod?.idVerificationMethod === "instantVerification" || isManualVerificationOrExistingDoc(data?.idVerificationMethod?.idVerificationMethod) && isUploadEmpty ? ["idDocument"] : [],
|
|
2494
|
-
// 2. Omit idVerificationMethod if manual or existing
|
|
2495
|
-
...isManualVerificationOrExistingDoc(data?.idVerificationMethod?.idVerificationMethod) ? ["idVerificationMethod"] : []
|
|
2496
|
-
];
|
|
2497
|
-
const customLabelsForSummary = {
|
|
2498
|
-
idVerificationMethod: data?.idVerificationMethod?.idVerificationMethod === "instantVerification" ? "idVerificationMethod" : "idDocument"
|
|
2499
|
-
};
|
|
2500
|
-
const {
|
|
2501
|
-
handleNextClick,
|
|
2502
|
-
handleBackClick,
|
|
2503
|
-
activeForm,
|
|
2504
|
-
shouldValidate,
|
|
2505
|
-
gotoFormByFormIndex,
|
|
2506
|
-
steps
|
|
2507
|
-
} = useFormComposer({
|
|
2508
|
-
problems,
|
|
2509
|
-
externalBackClick,
|
|
2510
|
-
forms,
|
|
2511
|
-
onSubmit,
|
|
2512
|
-
triggerValidation: form.triggerValidation
|
|
2513
|
-
// TODO: figure out type of nested keys
|
|
2514
|
-
});
|
|
2515
|
-
const isVerificationMethod = activeForm?.formId === "idVerificationMethod";
|
|
2516
|
-
const disableNextButton = isVerificationMethod && !activeForm?.isValid || isNextStepDisabled.value;
|
|
2517
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2518
|
-
/* @__PURE__ */ jsx(Show, { when: shouldShowIdNowModal, children: /* @__PURE__ */ jsx(IdNowVerificationModal, { handleFinish: handleHomeClick }) }),
|
|
2519
|
-
/* @__PURE__ */ jsx(FormContextProvider, { form, children: /* @__PURE__ */ jsx(
|
|
2520
|
-
FormFlow,
|
|
2521
|
-
{
|
|
2522
|
-
summary: {
|
|
2523
|
-
data: formatDataForSummary(),
|
|
2524
|
-
omitted: {
|
|
2525
|
-
keys: omittedKeysForSummary,
|
|
2526
|
-
forms: omittedFormsForSummary
|
|
2527
|
-
},
|
|
2528
|
-
problems,
|
|
2529
|
-
labels: customLabelsForSummary
|
|
2530
|
-
},
|
|
2531
|
-
asModal,
|
|
2532
|
-
currentStep: steps.current,
|
|
2533
|
-
disableNextButton,
|
|
2534
|
-
forms,
|
|
2535
|
-
activeForm,
|
|
2536
|
-
gotoFormByFormIndex,
|
|
2537
|
-
handleBackClick,
|
|
2538
|
-
handleCancelClick: handleHomeClick,
|
|
2539
|
-
handleNextClick: nextHandler || handleNextClick,
|
|
2540
|
-
loadingStatus,
|
|
2541
|
-
totalSteps: steps.total,
|
|
2542
|
-
children: /* @__PURE__ */ jsx(
|
|
2543
|
-
IndividualOnfido,
|
|
2544
|
-
{
|
|
2545
|
-
...derivedProps,
|
|
2546
|
-
requiredFields,
|
|
2547
|
-
data,
|
|
2548
|
-
defaultCountry: country,
|
|
2549
|
-
activeForm,
|
|
2550
|
-
forms,
|
|
2551
|
-
scenarios,
|
|
2552
|
-
taskType,
|
|
2553
|
-
problems,
|
|
2554
|
-
onNext: handleNextClick,
|
|
2555
|
-
onBack: handleBackClick,
|
|
2556
|
-
legalEntityId: legalEntityResponse?.id,
|
|
2557
|
-
allowedRoles: roleTypes,
|
|
2558
|
-
shouldValidate,
|
|
2559
|
-
accountHolder,
|
|
2560
|
-
parentLegalEntity,
|
|
2561
|
-
trustedFields,
|
|
2562
|
-
trustedFieldsProvider,
|
|
2563
|
-
trustedRoles,
|
|
2564
|
-
setNextHandler,
|
|
2565
|
-
handleHomeClick
|
|
2566
|
-
}
|
|
2567
|
-
)
|
|
2568
|
-
}
|
|
2569
|
-
) })
|
|
2570
|
-
] });
|
|
2571
|
-
}
|
|
2572
|
-
export {
|
|
2573
|
-
IndividualOnfidoDropin as I,
|
|
2574
|
-
IndividualDropin as a
|
|
2575
|
-
};
|