import { WalletReadyMessage, WalletUserData } from '@moonpay/login-common'; import * as LanguageDetector from './LanguageDetector'; import { WidgetTextCustomisation } from './MoonpayWalletSDK'; /** * `LoginWidget` provides functionality to handle login flows for Web3 applications. * It utilizes an iframe to facilitate a secure cross-origin login process, * allowing users to authenticate and authorize through the provider's login widget. */ declare class LoginWidget { /** * The domain from where the login widget is loaded. This should point to the * login service the application is using. */ loginDomain: string; /** * API Key provided by the login service. This is used to authenticate the * requests to the login service. */ apiKey: string; /** * A flag indicating whether the user is logged in or not. */ loggedIn: boolean; /** * Message received from the login service when the login is ready. */ readyMessage?: WalletReadyMessage; /** * User data received from the wallet. This is null until the user logs in. */ walletUserData: WalletUserData | null; /** * Customer email to prefill the login form with */ customerEmail?: string; /** * Language used to override the detected language */ language?: LanguageDetector.AllowedLocales; /** * Allows for a custom themeId to be passed to the login widget */ themeId?: string; /** * Callback function to be called when the login widget is closed. */ onCloseCallback: () => void; /** * Callback function to be called when the login widget sends a ready message. * This typically means that the login process is completed. */ onReadyCallback: (readyMessage: WalletReadyMessage) => void; /** * An optional object to override and customize the default copy in the MoonPay widget */ widgetTextCustomisation?: WidgetTextCustomisation; /** * LoginWidget constructor. * * @param {string} loginDomain - The domain of the login service. * @param {string} apiKey - API key provided by the login service. * @param {Function} onCloseCallback - Optional. Callback function to be called when the login widget is closed. * @param {Function} onReadyCallback - Optional. Callback function to be called when the login widget sends a ready message. * @param {string} language - Optional. Override detected language for login widget. * @param {string} themeId - Optional. Pass in a themeId to the login widget * @param {WidgetTextCustomisation} widgetTextCustomisation - Optional. Pass in a text override object to customize the default copy in the MoonPay widget */ constructor(loginDomain: string, apiKey: string, onCloseCallback?: () => void, onReadyCallback?: (readyMessage: WalletReadyMessage) => void, language?: LanguageDetector.AllowedLocales, themeId?: string, widgetTextCustomisation?: WidgetTextCustomisation); /** * Initiates the login process by embedding the login widget in an iframe. * The iframe will load a login page from the login service, using the provided * login domain and API key. * @param {boolean} hiddenIframe */ private embedLoginWidget; /** * Shows the login widget by making it visible in the view. */ showLoginWidget(): void; /** * Closes the login widget by hiding it from the view. * Note that the login widget iframe is not removed from the DOM. */ private closeLoginWidget; /** * Completely removes the login widget iframe from the DOM. */ private unmountLoginWidget; /** * Get login widget if it is mounted in the DOM. * * @returns {HTMLElement | undefined} The login widget element if it is mounted, undefined otherwise. */ private getLoginWindow; setCustomerEmail(email: string): void; /** * Public method to set the language of the login widget. Should be * called after the login widget is initialized. * @param language the new language to set */ setLanguage(language: LanguageDetector.AllowedLocales): void; /** * Public method to initiate the login process. * If the user is already logged in, this method will do nothing. * * @returns {Promise} A promise that resolves when the login process * is successful, and rejects when the login widget sends an exit message. */ login(): Promise; /** * Public method to log out the user. * This method also unmounts the login widget from the DOM. */ logout(): void; } export { LoginWidget };