UNPKG

@adyen/kyc-components

Version:

`adyen-kyc-components` provides the required pieces to build an onboarding flow based on a legal entity. To onboard and verify users, you need to create a user interface (UI) to collect user data. To speed up building your integration, Adyen offers onboar

35 lines (34 loc) 2.28 kB
import type { DropinAPIHandlers } from '../../components/Dropins/types'; import type { Attachment } from '../../core/models/api/attachment'; import type { Document, DocumentEntityType, DocumentType, ExistingDocument } from '../../core/models/api/document'; import type { FileSchema } from '../../core/models/file'; export type DocumentApiUtils = { fetchDocuments(documentIds: string[], entityId: string): Promise<Document[]>; fetchDocument(documentId: string, entityId: string): Promise<Document>; uploadDocuments(documents: Document[], entityId: string): Promise<Document[]>; deleteDocument?: (documentId: string, entityId: string) => Promise<Document>; }; export declare const documentApiUtils: (createDocumentHandler: Required<DropinAPIHandlers>["handleCreateDocument"], getDocumentHandler: Required<DropinAPIHandlers>["handleGetDocument"], updateDocumentHandler: Required<DropinAPIHandlers>["handleUpdateDocument"], deleteDocumentHandler?: Required<DropinAPIHandlers>["handleDeleteDocument"]) => DocumentApiUtils; export declare const getDocument: (entityId: string | undefined, documentType: DocumentType) => ExistingDocument | undefined; export declare const getIdDocument: (entityId: string) => Document | 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 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[];