@adyen/kyc-components 2.13.1 → 2.13.3
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/es/adyen-kyc-components.es.js +91 -58
- package/dist/types/core/models/api/attachment.d.ts +3 -2
- package/dist/types/core/models/api/individual.d.ts +1 -0
- package/dist/types/utils/mapping/componentApiMapping.d.ts +1 -1
- package/dist/types/utils/mapping/mapping.d.ts +3 -1
- package/package.json +1 -1
|
@@ -11104,7 +11104,7 @@ const createDocumentRequest = async ({
|
|
|
11104
11104
|
attachments: [...page1 && page2 && encodedFront && encodedBack ? [createAttachment(encodedFront, page1.name, "front"), createAttachment(encodedBack, page2.name, "back")] : [createAttachment(encodedFront, page1.name)]]
|
|
11105
11105
|
};
|
|
11106
11106
|
};
|
|
11107
|
-
const createAttachment = (content, pageName, pageType
|
|
11107
|
+
const createAttachment = (content, pageName, pageType) => ({
|
|
11108
11108
|
content,
|
|
11109
11109
|
pageName,
|
|
11110
11110
|
...pageType && {
|
|
@@ -12091,14 +12091,36 @@ const identityTypeToApiIdentityTypeMap = {
|
|
|
12091
12091
|
};
|
|
12092
12092
|
const apiIdentityTypeToIdentityTypeMap = reverseObject(identityTypeToApiIdentityTypeMap);
|
|
12093
12093
|
const adjustIdentificationData = (data, apiData) => {
|
|
12094
|
-
|
|
12095
|
-
|
|
12096
|
-
|
|
12094
|
+
const {
|
|
12095
|
+
typeOfIdentity: typeOfIdentity2,
|
|
12096
|
+
idNumber: idNumber2,
|
|
12097
|
+
idNumberExempt,
|
|
12098
|
+
residencyCountry: residencyCountry2
|
|
12099
|
+
} = data;
|
|
12100
|
+
const identificationData = {
|
|
12097
12101
|
...apiData,
|
|
12098
|
-
number: stripCountryIdFormat(
|
|
12099
|
-
|
|
12100
|
-
type: identityTypeToApiIdentityTypeMap[data.typeOfIdentity] ?? "nationalIdNumber"
|
|
12102
|
+
number: stripCountryIdFormat(idNumber2, residencyCountry2),
|
|
12103
|
+
type: identityTypeToApiIdentityTypeMap[typeOfIdentity2] ?? "nationalIdNumber"
|
|
12101
12104
|
};
|
|
12105
|
+
switch (typeOfIdentity2) {
|
|
12106
|
+
case "passport":
|
|
12107
|
+
return {
|
|
12108
|
+
...identificationData,
|
|
12109
|
+
cardNumber: ""
|
|
12110
|
+
};
|
|
12111
|
+
case "driversLicense":
|
|
12112
|
+
return {
|
|
12113
|
+
...identificationData,
|
|
12114
|
+
expiryDate: ""
|
|
12115
|
+
};
|
|
12116
|
+
default:
|
|
12117
|
+
return idNumber2 === void 0 && idNumberExempt === void 0 ? void 0 : {
|
|
12118
|
+
...identificationData,
|
|
12119
|
+
expiryDate: "",
|
|
12120
|
+
cardNumber: "",
|
|
12121
|
+
nationalIdExempt: apiData.nationalIdExempt ?? !idNumber2
|
|
12122
|
+
};
|
|
12123
|
+
}
|
|
12102
12124
|
};
|
|
12103
12125
|
const mapTransferInstrumentToPayoutAccount = (transferInstrument) => formatObject(transferInstrument, payoutComponentKeyMapping);
|
|
12104
12126
|
const mapPayoutAccountToTransferInstrument = ({
|
|
@@ -12328,10 +12350,17 @@ const mapSolePropToLegalEntity = (data) => {
|
|
|
12328
12350
|
requestObj.type = LegalEntityType.SOLE_PROPRIETORSHIP;
|
|
12329
12351
|
return requestObj;
|
|
12330
12352
|
};
|
|
12331
|
-
const
|
|
12332
|
-
|
|
12333
|
-
|
|
12334
|
-
|
|
12353
|
+
const getPage = ({
|
|
12354
|
+
attachments
|
|
12355
|
+
}, pageType) => {
|
|
12356
|
+
if (!attachments)
|
|
12357
|
+
throw Error("Document has no attachments");
|
|
12358
|
+
const attachment = pageType ? attachments.find((attach) => attach.pageType === pageType) : attachments[0];
|
|
12359
|
+
if (!attachment)
|
|
12360
|
+
throw Error(`Attachment not found${pageType ? ` with type '${pageType}'` : ""}`);
|
|
12361
|
+
return attachment;
|
|
12362
|
+
};
|
|
12363
|
+
const getPageName = (document2, pageType) => getPage(document2, pageType).pageName;
|
|
12335
12364
|
const mapIndividualDocumentToApiDocument = async (data, entityId) => {
|
|
12336
12365
|
var _a, _b, _c, _d;
|
|
12337
12366
|
if (data) {
|
|
@@ -12361,24 +12390,34 @@ const mapIndividualDocumentToApiDocument = async (data, entityId) => {
|
|
|
12361
12390
|
return documents2.filter(Boolean);
|
|
12362
12391
|
}
|
|
12363
12392
|
};
|
|
12393
|
+
const mapApiIdDocumentToSchema = (idDocument2) => {
|
|
12394
|
+
const {
|
|
12395
|
+
hasBackPage
|
|
12396
|
+
} = idDocumentTypeOptions.find(({
|
|
12397
|
+
id: id2
|
|
12398
|
+
}) => id2 === idDocument2.type);
|
|
12399
|
+
const frontPage2 = hasBackPage ? getPage(idDocument2, "front") : getPage(idDocument2);
|
|
12400
|
+
const backPage2 = hasBackPage ? getPage(idDocument2, "back") : void 0;
|
|
12401
|
+
return {
|
|
12402
|
+
...frontPage2 ? {
|
|
12403
|
+
idFrontPage: [{
|
|
12404
|
+
name: frontPage2.pageName
|
|
12405
|
+
}]
|
|
12406
|
+
} : {},
|
|
12407
|
+
...backPage2 ? {
|
|
12408
|
+
idBackPage: [{
|
|
12409
|
+
name: backPage2.pageName
|
|
12410
|
+
}]
|
|
12411
|
+
} : {},
|
|
12412
|
+
idDocumentType: idDocument2.type
|
|
12413
|
+
};
|
|
12414
|
+
};
|
|
12364
12415
|
const mapApiDocumentToIndividualDocuments = (entityId) => {
|
|
12365
12416
|
const idDocument2 = getIdDocument(entityId) || null;
|
|
12366
12417
|
const proofOfResidence2 = getDocument$1(entityId, DocumentType.PROOF_OF_RESIDENCY) || null;
|
|
12367
12418
|
const proofOfNationalId2 = getDocument$1(entityId, DocumentType.PROOF_OF_NATIONAL_ID_NUMBER) || null;
|
|
12368
12419
|
return {
|
|
12369
|
-
idDocument:
|
|
12370
|
-
...(idDocument2 == null ? void 0 : idDocument2.attachments[0]) ? {
|
|
12371
|
-
idFrontPage: [{
|
|
12372
|
-
name: getPageName(idDocument2, 0)
|
|
12373
|
-
}]
|
|
12374
|
-
} : {},
|
|
12375
|
-
...(idDocument2 == null ? void 0 : idDocument2.attachments[1]) ? {
|
|
12376
|
-
idBackPage: [{
|
|
12377
|
-
name: getPageName(idDocument2, 1)
|
|
12378
|
-
}]
|
|
12379
|
-
} : {},
|
|
12380
|
-
idDocumentType: idDocument2 == null ? void 0 : idDocument2.type
|
|
12381
|
-
},
|
|
12420
|
+
idDocument: idDocument2 ? mapApiIdDocumentToSchema(idDocument2) : null,
|
|
12382
12421
|
proofOfResidence: proofOfResidence2 ? [{
|
|
12383
12422
|
name: getPageName(proofOfResidence2)
|
|
12384
12423
|
}] : null,
|
|
@@ -12588,40 +12627,34 @@ function IdDocumentManualUploadComponent(props) {
|
|
|
12588
12627
|
prevState,
|
|
12589
12628
|
changeInitiatedBy
|
|
12590
12629
|
}) => {
|
|
12591
|
-
var _a2, _b, _c, _d, _e, _f
|
|
12592
|
-
if (changeInitiatedBy === "idDocument") {
|
|
12593
|
-
|
|
12594
|
-
|
|
12595
|
-
|
|
12596
|
-
|
|
12597
|
-
|
|
12598
|
-
|
|
12599
|
-
|
|
12600
|
-
|
|
12601
|
-
|
|
12602
|
-
|
|
12603
|
-
|
|
12604
|
-
|
|
12605
|
-
|
|
12606
|
-
|
|
12607
|
-
|
|
12608
|
-
|
|
12609
|
-
|
|
12610
|
-
|
|
12611
|
-
|
|
12612
|
-
|
|
12613
|
-
|
|
12614
|
-
|
|
12615
|
-
|
|
12616
|
-
|
|
12617
|
-
|
|
12618
|
-
|
|
12619
|
-
if (!isBackPageSelected) {
|
|
12620
|
-
setIdBackPage({
|
|
12621
|
-
idBackPage: null
|
|
12622
|
-
});
|
|
12623
|
-
}
|
|
12624
|
-
}
|
|
12630
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
12631
|
+
if (changeInitiatedBy === "idDocument" && ((_b = (_a2 = currentState == null ? void 0 : currentState.data) == null ? void 0 : _a2.idDocument) == null ? void 0 : _b.idDocumentType) !== ((_d = (_c = prevState == null ? void 0 : prevState.data) == null ? void 0 : _c.idDocument) == null ? void 0 : _d.idDocumentType)) {
|
|
12632
|
+
const idDocumentType = (_f = (_e = currentState.data) == null ? void 0 : _e.idDocument) == null ? void 0 : _f.idDocumentType;
|
|
12633
|
+
const document2 = idDocumentType ? getDocument$1(props.legalEntityId, idDocumentType) : void 0;
|
|
12634
|
+
if (!document2) {
|
|
12635
|
+
setIdFrontPage({
|
|
12636
|
+
idFrontPage: null
|
|
12637
|
+
});
|
|
12638
|
+
setIdBackPage({
|
|
12639
|
+
idBackPage: null
|
|
12640
|
+
});
|
|
12641
|
+
} else if (hasBackPage(idDocumentType)) {
|
|
12642
|
+
setIdFrontPage({
|
|
12643
|
+
idFrontPage: [{
|
|
12644
|
+
name: getPageName(document2, "front")
|
|
12645
|
+
}]
|
|
12646
|
+
});
|
|
12647
|
+
setIdBackPage({
|
|
12648
|
+
idBackPage: [{
|
|
12649
|
+
name: getPageName(document2, "back")
|
|
12650
|
+
}]
|
|
12651
|
+
});
|
|
12652
|
+
} else {
|
|
12653
|
+
setIdFrontPage({
|
|
12654
|
+
idFrontPage: [{
|
|
12655
|
+
name: getPageName(document2)
|
|
12656
|
+
}]
|
|
12657
|
+
});
|
|
12625
12658
|
}
|
|
12626
12659
|
}
|
|
12627
12660
|
};
|
|
@@ -38,7 +38,7 @@ export declare const individualComponentsKeyMapping: {
|
|
|
38
38
|
'address.otherAddressInformation': string;
|
|
39
39
|
};
|
|
40
40
|
export declare const individualApiKeyMapping: {
|
|
41
|
-
[x: string]: "personalDetails.firstName" | "personalDetails.lastName" | "personalDetails.issuerState" | "personalDetails.phoneNumber" | "personalDetails.email" | "personalDetails.birthDate" | "personalDetails.idNumber" | "personalDetails.licenseCardNumber" | "personalDetails.nationality" | "personalDetails.jobTitle" | "personalDetails.typeOfIdentity" | "personalDetails.idNumberExempt" | "
|
|
41
|
+
[x: string]: "personalDetails.firstName" | "personalDetails.lastName" | "personalDetails.issuerState" | "personalDetails.expiryDate" | "personalDetails.phoneNumber" | "personalDetails.email" | "personalDetails.birthDate" | "personalDetails.idNumber" | "personalDetails.licenseCardNumber" | "personalDetails.nationality" | "personalDetails.jobTitle" | "personalDetails.typeOfIdentity" | "personalDetails.idNumberExempt" | "address.country" | "address.postalCode" | "address.city" | "address.stateOrProvince" | "address.otherAddressInformation" | "address.address";
|
|
42
42
|
};
|
|
43
43
|
export declare const companyComponentsKeyMapping: {
|
|
44
44
|
'companyNameAndCountry.country': string;
|
|
@@ -5,6 +5,7 @@ import { PayoutDetailsSchema } from '../../components/PayoutDetails/types';
|
|
|
5
5
|
import { PersonalDetailsSchema } from '../../components/PersonalDetails/types';
|
|
6
6
|
import { SolePropSchema } from '../../components/SoleProp/types';
|
|
7
7
|
import { TrustSchema } from '../../components/Trust/types';
|
|
8
|
+
import { Attachment, PageType } from '../../core/models/api/attachment';
|
|
8
9
|
import { Document } from '../../core/models/api/document';
|
|
9
10
|
import { Individual } from '../../core/models/api/individual';
|
|
10
11
|
import { LegalEntity } from '../../core/models/api/legal-entity';
|
|
@@ -34,7 +35,8 @@ export declare const mapTrustToLegalEntity: (data: TrustSchema) => LegalEntity;
|
|
|
34
35
|
export declare const mapLegalEntityToSoleProp: (legalEntity: LegalEntity) => SolePropSchema;
|
|
35
36
|
export declare const mapSolePropToLegalEntity: (data: SolePropSchema) => LegalEntity;
|
|
36
37
|
export type IndividualDocumentFields = Pick<IndividualSchema, 'idDocument' | 'proofOfResidence' | 'proofOfNationalId'>;
|
|
37
|
-
export declare const
|
|
38
|
+
export declare const getPage: ({ attachments }: Document, pageType?: PageType) => Attachment;
|
|
39
|
+
export declare const getPageName: (document: Document, pageType?: PageType) => string;
|
|
38
40
|
export declare const mapIndividualDocumentToApiDocument: (data: IndividualSchema, entityId: string) => Promise<Document[]>;
|
|
39
41
|
export declare const mapApiDocumentToIndividualDocuments: (entityId: string) => IndividualDocumentFields;
|
|
40
42
|
export declare const mapCompanyDocumentToApiDocument: (data: CompanySchema, entityId: string) => Promise<Document[]>;
|