import type { BrokerType } from '@meshconnect/node-api'; import { SessionSummary, LinkEventType } from './event-types'; export type EventType = 'brokerageAccountAccessToken' | 'delayedAuthentication' | 'loaded' | 'transferFinished'; export interface Link { /** * A function that takes linkToken parameter from `/api/v1/linktoken` endpoint as an input, and opens the Link UI popup * @param linkToken - Base64 encoded link token from the `/api/v1/linktoken` endpoint * @param customIframeId - Optional custom ID for the existing iframe element. If not provided, a new iframe element will be created */ openLink: (linkToken: string, customIframeId?: string) => void; /** * A function to close Link UI popup */ closeLink: () => void; /** * A function to request Link UI to close gracefully in embedded mode. */ closeLinkRequested: () => void; } export interface AccountToken { account: Account; accessToken: string; refreshToken?: string; tokenId?: string; } export interface Account { accountId: string; accountName: string; fund?: number; cash?: number; isReconnected?: boolean; } /** * Integration brand information */ export interface BrandInfo { /** * Integration logo in base 64 format */ brokerLogo: string; /** * Integration logo URL (obsolete, use `logoLightUrl` instead) */ brokerLogoUrl?: string; /** * Integration logo URL for light theme */ logoLightUrl?: string; /** * Integration logo URL for dark theme */ logoDarkUrl?: string; /** * Integration icon URL for light theme */ iconLightUrl?: string; /** * Integration icon URL for dark theme */ iconDarkUrl?: string; } export interface LinkPayload { accessToken?: AccessTokenPayload; delayedAuth?: DelayedAuthPayload; } export interface AccessTokenPayload { accountTokens: AccountToken[]; brokerBrandInfo: BrandInfo; expiresInSeconds?: number; refreshTokenExpiresInSeconds?: number; brokerType: BrokerType; brokerName: string; } export interface DelayedAuthPayload { refreshTokenExpiresInSeconds?: number; brokerType: BrokerType; refreshToken: string; brokerName: string; brokerBrandInfo: BrandInfo; } export interface TransferFinishedPayload { status: 'success'; txId: string; fromAddress: string; toAddress: string; symbol: string; amount: number; networkId: string; userId?: string; clientTransactionId?: string; amountInFiat?: number; totalAmountInFiat?: number; networkName?: string; txHash?: string; transferId?: string; refundAddress?: string; } export interface IntegrationAccessToken { accountId: string; accountName: string; accessToken: string; brokerType: BrokerType; brokerName: string; } export interface LinkOptions { /** * @deprecated This property is unused and will be removed in the next major version. */ clientId?: string; /** * A callback function that is called when an integration is successfully connected. * It receives a payload of type `LinkPayload`. */ onIntegrationConnected: (payload: LinkPayload) => void; /** * (Optional) A callback function that is called when the Front iframe is closed. */ onExit?: (error?: string, summary?: SessionSummary) => void; /** * (Optional) A callback function that is called when a transfer is finished. * It receives a payload of type `TransferFinishedPayload`. */ onTransferFinished?: (payload: TransferFinishedPayload) => void; /** * (Optional) A callback function that is called when various events occur within the Front iframe. * It receives an object with type `LinkEventTypeKeys` indicating the event, and an optional 'payload' containing additional data. */ onEvent?: (event: LinkEventType) => void; /** * (Optional) An array of integration access tokens. * These access tokens are used to initialize crypto transfers flow at 'Select asset step' */ accessTokens?: IntegrationAccessToken[]; /** * Link UI language. Supported: 'en', 'ru'. Can be set as 'en-US', 'ru-RU', etc. */ language?: string; /** * The currency to display a fiat equivalent of the crypto amount in Link UI. * Default: 'USD' */ displayFiatCurrency?: string; /** * Link UI theme. Possible values: 'dark', 'light' and 'system'. */ theme?: 'dark' | 'light' | 'system'; /** * Controls how the Link UI is rendered. * - 'overlay' (default): renders as a full-screen popup managed by the SDK. * - 'embedded': renders inside a client-supplied iframe for a more native UI experience. Requires `customIframeId` in `openLink`. */ renderType?: 'overlay' | 'embedded'; } export interface LinkStyle { ir: number; io: number; } declare global { interface Window { meshLinkShouldSkipPrewarm?: boolean; } }