UNPKG

@adyen/kyc-components

Version:

This guide assumes that you have already an account with Adyen. A legalEntity needs to be created, and you need to have a `legalEntityId` to instatiate a Component.

296 lines (295 loc) 14 kB
try { let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack; n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "5db1f6c4-d2ad-4b6c-95be-61bd2332aedf", e._sentryDebugIdIdentifier = "sentry-dbid-5db1f6c4-d2ad-4b6c-95be-61bd2332aedf"); } catch (e) {} import { t as getLegalEntityCountry } from "./getLegalEntityCountry-C6bSV6sB.js"; import { t as CountryCodes } from "./country-code-CX5KqMBr.js"; import { p as TaskTypes, t as allowedCountriesForNominee } from "./entityAssociationUtil-BEzUdPbm.js"; import { t as DecisionMakerTypes } from "./decision-maker-type-Cow3CpUd.js"; import { t as Scenarios } from "./get-scenarios-DnCVdYIC.js"; import { t as getAvailableDecisionMakerRoleTypes } from "./decisionMaker-j9cwyXuS.js"; import { i as isLowRiskCountry } from "./country-COrdWGaq.js"; import { t as isBafinSignatoryFlow } from "./bafinUtils-kBPs58Au.js"; import { c as COUNTRIES_WITH_STATES_DATASET, t as getAddressSchemaForCountry } from "./utils-CfTVU2Hq.js"; import { t as getLocalizedIdDocumentTypeOptions } from "./utils-CzW6YqAz.js"; import { t as isJapanLocalizationEnabled } from "./japanSupportUtils-DcDqwV81.js"; import { t as createFormRules } from "./form-rules-ZiRm6ke_.js"; //#region src/components/Individual/forms/Individual.rules.ts var REQUIRED = "REQUIRED"; var OPTIONAL = "OPTIONAL"; var ID_NUMBER_EXEMPT_COUNTRIES = [ CountryCodes.Canada, CountryCodes.PuertoRico, CountryCodes.UnitedStates ]; var COUNTRIES_WHICH_USE_MULTIPLE_IDENTITY_TYPES = [ CountryCodes.HongKong, CountryCodes.Australia, CountryCodes.NewZealand ]; var ID_NUMBER_REQUIRED_FOR_DIRECTOR_COUNTRIES = [CountryCodes.Singapore, CountryCodes.UnitedStates]; var NATIONALITY_REQUIRED_FOR_COUNTRIES = [CountryCodes.Singapore, CountryCodes.HongKong]; var JOB_TITLE_REQUIRED_FOR_COUNTRIES = [CountryCodes.NewZealand]; var ISSUER_REQUIRED_FOR_COUNTRIES = [CountryCodes.Australia]; var EXPIRY_DATE_REQUIRED_FOR_COUNTRIES = [CountryCodes.NewZealand]; var LICENSE_CARD_NUMBER_REQUIRED_FOR_COUNTRIES = [CountryCodes.NewZealand, CountryCodes.Australia]; var TAX_ID_REQUIRED_COUNTRIES = [ CountryCodes.Austria, CountryCodes.Belgium, CountryCodes.Croatia, CountryCodes.Cyprus, CountryCodes.Estonia, CountryCodes.Finland, CountryCodes.France, CountryCodes.Germany, CountryCodes.Greece, CountryCodes.Ireland, CountryCodes.Latvia, CountryCodes.Lithuania, CountryCodes.Luxembourg, CountryCodes.Malta, CountryCodes.Netherlands, CountryCodes.Portugal, CountryCodes.Slovakia, CountryCodes.Slovenia, CountryCodes.UnitedKingdom ]; var SOLE_PROP_COUNTRIES = [ CountryCodes.Austria, CountryCodes.Australia, CountryCodes.Belgium, CountryCodes.Bulgaria, CountryCodes.Canada, CountryCodes.Croatia, CountryCodes.Cyprus, CountryCodes.CzechRepublic, CountryCodes.Denmark, CountryCodes.Estonia, CountryCodes.Finland, CountryCodes.France, CountryCodes.Germany, CountryCodes.Gibraltar, CountryCodes.Greece, CountryCodes.Guernsey, CountryCodes.HongKong, CountryCodes.Hungary, CountryCodes.Ireland, CountryCodes.IsleOfMan, CountryCodes.Italy, CountryCodes.Japan, CountryCodes.Jersey, CountryCodes.Latvia, CountryCodes.Liechtenstein, CountryCodes.Lithuania, CountryCodes.Luxembourg, CountryCodes.Malta, CountryCodes.Monaco, CountryCodes.Netherlands, CountryCodes.NewZealand, CountryCodes.Norway, CountryCodes.Poland, CountryCodes.Portugal, CountryCodes.PuertoRico, CountryCodes.Romania, CountryCodes.Singapore, CountryCodes.Slovakia, CountryCodes.Slovenia, CountryCodes.Spain, CountryCodes.Sweden, CountryCodes.Switzerland, CountryCodes.UnitedKingdom, CountryCodes.UnitedStates ]; var DECISION_MAKER_TYPES_WITH_JOBTITLE = [DecisionMakerTypes.SIGNATORY, DecisionMakerTypes.CONTROLLING_PERSON]; var ID_MISSING_DATA_ERROR_CODE = "2_8071"; var REMEDIATION_CODES_UPLOAD_ID = [ "1_301", "1_302", "1_303" ]; var individualRules = ({ matchingScenario, data, country, taskType, isFeatureEnabled = () => false, rootLegalEntity, problems }) => createFormRules({ countryUsesTaxId: () => { if (matchingScenario?.includes(Scenarios.L_TAXINFO) && TAX_ID_REQUIRED_COUNTRIES.includes(country)) return "REQUIRED"; }, isDirectorIdNumberRequiredForCountry: () => { if (!data.basicDetails?.role) return REQUIRED; if (data.basicDetails?.role?.some((role) => role !== DecisionMakerTypes.DIRECTOR)) return REQUIRED; if (ID_NUMBER_REQUIRED_FOR_DIRECTOR_COUNTRIES.includes(country) && data.basicDetails?.role?.some((role) => role === DecisionMakerTypes.DIRECTOR)) return REQUIRED; }, idNumberRules: () => { const hasTaxScenario = matchingScenario?.includes(Scenarios.L_TAXINFO); if (data.additionalPersonalDetails?.idNumberExempt) return OPTIONAL; if (!data.basicDetails?.role) return REQUIRED; if (hasTaxScenario && country === CountryCodes.UnitedStates && data.basicDetails?.role?.every((role) => role === DecisionMakerTypes.SIGNATORY)) return REQUIRED; if (!hasTaxScenario && country === CountryCodes.UnitedStates && data.basicDetails?.role?.every((role) => role === DecisionMakerTypes.SIGNATORY)) return; if (data.basicDetails?.role?.some((role) => role !== DecisionMakerTypes.DIRECTOR)) return REQUIRED; if (ID_NUMBER_REQUIRED_FOR_DIRECTOR_COUNTRIES.includes(country) && data.basicDetails?.role?.some((role) => role === DecisionMakerTypes.DIRECTOR)) return REQUIRED; }, requiredIfDecisionMakerTask: () => { if (taskType === TaskTypes.DECISION_MAKER || taskType === TaskTypes.TRUST_MEMBER_COMPANY_OWNER || taskType === TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY_OWNER) return REQUIRED; }, idNumberExemptIfApplicableCountry: () => { if (matchingScenario?.includes(Scenarios.L_TAXINFO)) return; if (country === CountryCodes.UnitedStates && data.basicDetails?.role?.every((role) => role === DecisionMakerTypes.SIGNATORY)) return; if (ID_NUMBER_EXEMPT_COUNTRIES.includes(country)) return REQUIRED; }, hasChosenIdType: () => { return data?.manualIdUpload?.idDocumentType ? REQUIRED : void 0; }, backPageIfRequiredForIdType: () => { return getLocalizedIdDocumentTypeOptions(country).find(({ id }) => id === data.manualIdUpload?.idDocumentType)?.hasBackPage ? REQUIRED : void 0; }, isProofOfResidencyRequired: () => { if (isBafinSignatoryFlow({ taskType, data, scenarios: matchingScenario })) return; if (data.proofOfResidency?.proofOfResidency?.length) return REQUIRED; if (!(data?.idVerificationMethod?.idVerificationMethod === "instantVerification")) return; const documentCountry = data?.idVerificationMethod?.idDocument?.documentCountry; const residenceCountry = data?.additionalPersonalDetails?.country ?? country; if (!documentCountry || !residenceCountry) return; const countriesMismatch = documentCountry !== residenceCountry; const isEeaLowRiskException = isLowRiskCountry(documentCountry) && isLowRiskCountry(residenceCountry); if (countriesMismatch && !isEeaLowRiskException) return REQUIRED; }, isProofOfNationalIdRequired: () => { if (isBafinSignatoryFlow({ taskType, data, scenarios: matchingScenario })) return; if (data.proofOfNationalId?.proofOfNationalId?.length) return REQUIRED; }, isIdVerificationMethodRequired: () => { if (isBafinSignatoryFlow({ taskType, data, scenarios: matchingScenario })) return; return REQUIRED; }, isVerifyByInviteSelected: () => { return taskType === TaskTypes.DECISION_MAKER && isFeatureEnabled("EnableVerifyByInvite") && data?.idVerificationMethod?.idVerificationMethod === "verifyByInvite" ? REQUIRED : void 0; }, contactsIfRequiredForRole: () => { if (taskType === TaskTypes.DECISION_MAKER) { if (data.basicDetails?.role?.includes(DecisionMakerTypes.SIGNATORY)) return REQUIRED; return; } return REQUIRED; }, requiredIfPhoneScenarioDisabled: () => !isFeatureEnabled("EnablePhoneFieldScenario") ? REQUIRED : void 0, jobTitleIfRequiredForRole: () => { if (taskType !== TaskTypes.DECISION_MAKER) return; if (data.basicDetails?.role?.some((role) => DECISION_MAKER_TYPES_WITH_JOBTITLE.includes(role)) || JOB_TITLE_REQUIRED_FOR_COUNTRIES.includes(country)) return REQUIRED; }, isPlaceOfBirthRequired: () => { if (isBafinSignatoryFlow({ taskType, data, scenarios: matchingScenario })) return REQUIRED; }, nationalityIfRequiredForRole: () => { if (isBafinSignatoryFlow({ taskType, data, scenarios: matchingScenario })) return REQUIRED; const enableNationalitySGHK = isFeatureEnabled("EnableNationalitySGHK"); const rootLegalEntityCountry = rootLegalEntity?.organization?.registeredAddress.country; if (enableNationalitySGHK && rootLegalEntityCountry && NATIONALITY_REQUIRED_FOR_COUNTRIES.includes(rootLegalEntityCountry)) return REQUIRED; if (NATIONALITY_REQUIRED_FOR_COUNTRIES.includes(country) || data?.additionalPersonalDetails?.nationality) return REQUIRED; }, requiredIfCountryUsesMultipleTypesOfIdentity: () => { if (COUNTRIES_WHICH_USE_MULTIPLE_IDENTITY_TYPES.includes(country)) return REQUIRED; }, licenseCardNumberRules: () => { if (data.additionalPersonalDetails?.typeOfIdentity === "driversLicense" && LICENSE_CARD_NUMBER_REQUIRED_FOR_COUNTRIES.includes(country)) return REQUIRED; }, issuerStateRequired: () => { if (data.additionalPersonalDetails?.typeOfIdentity === "driversLicense" && ISSUER_REQUIRED_FOR_COUNTRIES.includes(country)) return REQUIRED; }, expiryDateRequired: () => { if (data.additionalPersonalDetails?.typeOfIdentity === "passport" && EXPIRY_DATE_REQUIRED_FOR_COUNTRIES.includes(country)) return REQUIRED; }, legalRepresentativeRelationshipRequired: () => taskType === TaskTypes.LEGAL_REPRESENTATIVE_DETAILS ? REQUIRED : void 0, isProofOfRelationshipRequired: () => void 0, addressIfRequiredForCountry: () => { return getAddressSchemaForCountry(data?.additionalPersonalDetails?.country).includes("address") ? "REQUIRED" : void 0; }, otherAddressInfoIfRequiredForCountry: () => { if (isJapanLocalizationEnabled(isFeatureEnabled, country)) return "REQUIRED"; return getAddressSchemaForCountry(data?.additionalPersonalDetails?.country).includes("otherAddressInformation") ? "OPTIONAL" : void 0; }, postalCodeIfRequiredForCountry: () => { return getAddressSchemaForCountry(data?.additionalPersonalDetails?.country).includes("postalCode") ? "REQUIRED" : void 0; }, cityIfRequiredForCountry: () => { return getAddressSchemaForCountry(data?.additionalPersonalDetails?.country).includes("city") ? "REQUIRED" : void 0; }, stateOrProvinceIfRequiredForCountry: () => { return getAddressSchemaForCountry(data?.additionalPersonalDetails?.country).includes("stateOrProvince") && COUNTRIES_WITH_STATES_DATASET.includes(data?.additionalPersonalDetails?.country ?? country) ? "REQUIRED" : void 0; }, nomineeDirectorRequiredForCountry: () => { if (allowedCountriesForNominee.includes(data?.additionalPersonalDetails?.country ?? country) && data?.basicDetails?.role?.includes(DecisionMakerTypes.DIRECTOR)) return "REQUIRED"; }, nomineeShareHolderRequiredForCountry: () => { if (allowedCountriesForNominee.includes(data?.additionalPersonalDetails?.country ?? country) && data?.basicDetails?.role?.includes(DecisionMakerTypes.OWNER)) return "REQUIRED"; }, isUsingInstantVerificationOrHasExistingDocument: () => { if (isBafinSignatoryFlow({ taskType, data, scenarios: matchingScenario })) return; const isUsingInstantVerification = data?.idVerificationMethod?.idVerificationMethod === "instantVerification"; const existingDocument = data?.idVerificationMethod?.idDocument; return isUsingInstantVerification || existingDocument ? REQUIRED : void 0; }, isManualIdFlow: () => { if (isBafinSignatoryFlow({ taskType, data, scenarios: matchingScenario })) return; return data?.idVerificationMethod?.idVerificationMethod === "manualVerification" ? "REQUIRED" : void 0; }, isManualIdFlowAndNotProvidingIdNumber: () => { if (isBafinSignatoryFlow({ taskType, data, scenarios: matchingScenario })) return; const hasMissingId = problems?.missingData?.some((error) => error.code === ID_MISSING_DATA_ERROR_CODE); const isManualFlow = data?.idVerificationMethod?.idVerificationMethod === "manualVerification"; const idNumberExempt = data?.additionalPersonalDetails?.idNumberExempt; const hasIdRemediationAction = Object.keys(problems?.remediationActions ?? {}).some((code) => REMEDIATION_CODES_UPLOAD_ID.includes(code)); return isManualFlow && (idNumberExempt || hasMissingId || hasIdRemediationAction) ? "REQUIRED" : void 0; }, isManualIdFlowAndHasMissingData: () => { if (isBafinSignatoryFlow({ taskType, data, scenarios: matchingScenario })) return; const isManualFlow = data?.idVerificationMethod?.idVerificationMethod === "manualVerification"; if (matchingScenario?.includes(Scenarios.L1_IDDOC)) return isManualFlow ? "REQUIRED" : void 0; const hasMissingId = problems?.missingData?.some((error) => error.code === ID_MISSING_DATA_ERROR_CODE); const hasIdRemediationAction = Object.keys(problems?.remediationActions ?? {}).some((code) => REMEDIATION_CODES_UPLOAD_ID.includes(code)); return isManualFlow && (hasMissingId || hasIdRemediationAction) ? "REQUIRED" : void 0; }, idVerificationRequired: () => { return REQUIRED; }, isDirectorRequiredForCountry: () => { if (getAvailableDecisionMakerRoleTypes(rootLegalEntity ? getLegalEntityCountry(rootLegalEntity) : country, matchingScenario).some((maker) => maker.roleType === DecisionMakerTypes.DIRECTOR)) return "REQUIRED"; }, japanSpecificField: () => { if (isJapanLocalizationEnabled(isFeatureEnabled, taskType === TaskTypes.DECISION_MAKER && rootLegalEntity?.organization?.registeredAddress.country || country)) return "REQUIRED"; } }); //#endregion export { individualRules as i, DECISION_MAKER_TYPES_WITH_JOBTITLE as n, SOLE_PROP_COUNTRIES as r, COUNTRIES_WHICH_USE_MULTIPLE_IDENTITY_TYPES as t };