/** https://plaid.com/docs/#onevent-callback */ export type EventName = | 'ERROR' // A recoverable error occurred in the Link flow, see the error_code metadata. | 'EXIT' // The user has exited without completing the Link flow and the onExit callback is fired. | 'HANDOFF' // The user has completed the Link flow and the onSuccess callback is fired. | 'OPEN' // The user has opened Link. | 'OPEN_MY_PLAID' // The user has opened my.plaid.com. This event is only sent when Link is initialized with assets as a product | 'SEARCH_INSTITUTION' // The user has searched for an institution. | 'SELECT_INSTITUTION' // The user selected an institution. | 'SUBMIT_CREDENTIALS' // The user has submitted credentials. | 'SUBMIT_MFA' // The user has submitted MFA. | 'TRANSITION_VIEW' // The TRANSITION_VIEW event indicates that the user has moved from one view to the next. /** https://plaid.com/docs/#metadata-view_name */ export type ViewName = | 'CONNECTED' // The user has connected their account. | 'CREDENTIAL' // Asking the user for their account credentials. | 'ERROR' // An error has occurred. | 'EXIT' // Confirming if the user wishes to close Link. | 'LOADING' // Link is making a request to our servers. | 'MFA' // The user is asked by the institution for additional MFA authentication. | 'RECAPTCHA' // The user was presented with a Google reCAPTCHA to verify they are human. | 'SELECT_ACCOUNT' // We ask the user to choose an account. | 'SELECT_INSTITUTION' // We ask the user to choose their institution. /** https://plaid.com/docs/#metadata-reference */ export interface EventMeta { link_session_id: string request_id?: string status?: string exit_status?: string timestamp?: Date view_name?: ViewName mfa_type?: string institution?: Institution institution_search_query?: string institution_name?: string institution_id?: string account_id?: null account?: Account accounts?: Account[] error_type?: string error_code?: string error_message?: string } export interface Account { id?: string type?: string mask?: string name?: string subtype?: string } export interface Institution { name: string institution_id: string } export interface PlaidConfiguration { key: string env: 'sandbox' | 'development' | 'production' product: string[] clientName?: string webhook?: string selectAccount?: boolean userLegalName?: string userEmailAddress?: string countryCodes?: string[] language?: string onSuccess: (publicToken: string, meta: EventMeta) => void onExit: (error: any, meta: EventMeta) => void onEvent?: (eventName: EventName, meta: EventMeta) => void } export interface OpenOptions { publicToken?: string institution?: string } interface PlaidLink { /** * Create Plaid Link. * * The `configuration` object must contain one or more of: * * - `key` (string) - the Plaid public_key (required) * - `env` (string) - the Plaid environment (required) * - `product` (array of strings) - a list of Plaid products (required) * - `clientName` (string) - the name to display on info panes (recommended) * - `webhook` (string) - webhook to receive transaction and error updates * - `selectAccount` (boolean) - enables the select account flow when set to true * * - `userLegalName` (string) - the legal name of the end-user, necessary for microdeposit support * - `userEmailAddress` (string) - the email address of the end-user, necessary for microdeposit support * - `countryCodes` (array of strings) - a list of ISO 3166-1 alpha-2 country codes, used to select institutions available in the given countries * - `language` (string) - Plaid-supported language to localize Link. English ('en') will be used by default. For details consult https://plaid.com/docs/#parameter-reference. * * The are deprecated configuration options for the legacy API * - `longtailAuth` (boolean) - enable longtail auth institutions * - `apiVersion` (string) - the Plaid API version to use * * - `onSuccess` (function) - takes two parameters: the created public_token and the associated metadata. * - `onExit` (function) - takes two parameters: error and the associated metadata. * - `onEvent` (function) - takes two parameters: the event name and the associated metadata. */ create: (config: PlaidConfiguration) => this /** * Open Plaid Link. * * Calling `open()` will present the Plaid Link user interface implemented by the native `PLKPlaidLinkViewController` * - `publicToken` (string) - the public_token to invoke update mode (see https://plaid.com/docs/quickstart/#use-link-to-resolve-error) * - `institution` (string) - institution identifier for which to invoke the custom initializer flow */ open: (options?: OpenOptions) => void version: string } declare const PlaidLink: PlaidLink export default PlaidLink /** TODO: Better mapping of eventName to metadata */ // export type PlaidEvent = // | { // eventName: 'EXIT' // metadata: { link_session_id: string } // } // | { // eventName: 'TRANSITION_VIEW' // metadata: { link_session_id: string } // } // | { // eventName: 'OPEN' // metadata: { link_session_id: string } // } // | { // metadata: { public_token: string; link_session_id: string } // } // | { // eventName: 'SEARCH_INSTITUTION' // metadata: { institution_search_query: string; link_session_id: string } // } // | { // eventName: 'SELECT_INSTITUTION' // metadata: { // institution_id: string // institution_name: string // link_session_id: string // } // } // | { // eventName: 'SUBMIT_CREDENTIALS' // metadata: { // institution_id: string // institution_name: string // link_session_id: string // } // } // | { // eventName: 'ERROR' // metadata: { // error_code: string // 'INVALID_CREDENTIALS' // error_message: string // 'the provided credentials were not correct' // error_type: string // 'ITEM_ERROR' // link_session_id: string // } // }