@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.
42 lines (41 loc) • 2.63 kB
TypeScript
import type { Attachment } from '../../core/models/api/attachment';
import type { Document, DocumentDetail, DocumentEntityType, DocumentType, ExistingDocument, ExistingDocumentWithModificationDate } from '../../core/models/api/document';
import type { ComponentApiRequestContext } from '../../core/services/types';
import type { FileSchema } from '../../types/file';
export type DocumentApiUtils = {
fetchDocuments(documentDetails: DocumentDetail[], entityId: string): Promise<Document[]>;
fetchDocument(documentDetail: DocumentDetail, entityId: string): Promise<Document>;
uploadDocuments(documents: Document[], entityId: string): Promise<Document[]>;
deleteDocument?: (documentId: string, entityId: string) => Promise<Document>;
};
export declare const documentApiUtils: (context: ComponentApiRequestContext) => DocumentApiUtils;
export declare const getDocument: (entityId: string | undefined, documentType: DocumentType) => ExistingDocumentWithModificationDate | undefined;
export declare const getDocuments: (entityId: string | undefined, documentType: DocumentType) => ExistingDocumentWithModificationDate[];
export declare const getIdDocument: (entityId: string) => ExistingDocumentWithModificationDate | undefined;
export interface CreateDocumentRequestProps {
entityId: string;
entityType: DocumentEntityType;
documentType: DocumentType;
page1: FileSchema;
page2?: FileSchema;
description?: string;
existingDocument?: ExistingDocument;
}
export declare const createDocumentRequest: ({ entityId, entityType, documentType, page1, page2, description, existingDocument, }: CreateDocumentRequestProps) => Promise<Document | undefined>;
export declare const fileToBase64: (file: File) => Promise<string>;
export declare const getFileExtention: (fileName: string) => string | undefined;
/**
* Merges existing attachments from API with newly added attachments in UI
* making sure new ones override only corresponding ones based on pageType (front<->front)
* Eg: user selects new front of ID, we keep the back already saved in DB, override front
*
* @param existing Attachments copied from API response
* @param incoming New attachments
* @returns merged attachments with deduped pageTypes
*/
export declare const mergeAttachments: (existing: Attachment[], incoming: Attachment[]) => Attachment[];
/**
* Merges proof of ownership attachments by filtering based on pageName (not pageType)
* since proofOfOwnership attachments may not have pageType
*/
export declare const mergeProofOfOwnershipAttachments: (existing: Attachment[], incoming: Attachment[]) => Attachment[];