UNPKG

react-deck-link

Version:

React SDK for integrating Deck Link

49 lines (43 loc) 2.09 kB
declare type DeckOnSuccessPayload = { /** Used to identify a connection in webhooks. */ job_guid?: string; /** This token must be exchanged for an access_token. */ public_token?: string; }; declare type LinkInstance = { /** Calling open will display the Consent Pane view to your user, starting the Link flow. */ open: () => void; /** The exit function allows you to programmatically close Link. Calling exit will trigger the onExit callback. */ exit: () => void; }; /** * This hook loads Deck script and manages the Deck Link creation for you. * You get easy open & exit methods to call and loading & error states. * * A new Deck instance is created every time the token and products options change. * It's up to you to prevent unnecessary re-creations on re-render. */ export declare const useDeckLink: (options: UseDeckLinkOptions) => UseDeckLinkValues; declare type UseDeckLinkOptions = { /** You must provide a token to authenticate a new Link session. This is a short lived, one-time use token that is unique to each Link session */ token?: string | null; /** A function that is called when a user successfully creates a connection. You should implement it for sending the public_token returned by the Link iframe to your backend. */ onSuccess?: ({ job_guid, public_token }: DeckOnSuccessPayload) => void; /** A function that is called when the Widget encounters an error while submitting credentials. */ onError?: ({ reason }: { reason?: string; }) => void; /** A function that is called when a user exits Link. */ onExit?: () => void; /** If provided, the Link user will immediately be prompted to enter credentials for the corresponding source. */ source_id?: string; /** Default: https://link.deck.co/link-initialize.js */ linkSdkUrl?: string; }; declare type UseDeckLinkValues = LinkInstance & { /** True if SDK fails to load */ isError: boolean; /** True when the SDK is ready */ isReady: boolean; }; export { }