UNPKG

@web3auth/ws-embed

Version:

Embed script

223 lines (222 loc) 6.26 kB
import { CONFIRMATION_STRATEGY_TYPE, ProviderConfig } from "@toruslabs/base-controllers"; import type { AccountAbstractionMultiChainConfig } from "@toruslabs/ethereum-controllers"; import { AUTH_CONNECTION_TYPE, JRPCRequest, WEB3AUTH_NETWORK_TYPE, WhiteLabelData } from "@web3auth/auth"; import { LogLevelDesc } from "loglevel"; export { CONFIRMATION_STRATEGY, type CONFIRMATION_STRATEGY_TYPE } from "@toruslabs/base-controllers"; export declare const WS_EMBED_BUILD_ENV: { readonly PRODUCTION: "production"; readonly STAGING: "staging"; readonly DEVELOPMENT: "development"; readonly TESTING: "testing"; }; export type WS_EMBED_BUILD_ENV_TYPE = (typeof WS_EMBED_BUILD_ENV)[keyof typeof WS_EMBED_BUILD_ENV]; export declare const BUTTON_POSITION: { readonly BOTTOM_LEFT: "bottom-left"; readonly TOP_LEFT: "top-left"; readonly BOTTOM_RIGHT: "bottom-right"; readonly TOP_RIGHT: "top-right"; }; export type BUTTON_POSITION_TYPE = (typeof BUTTON_POSITION)[keyof typeof BUTTON_POSITION]; export interface CtorArgs { /** * Z-index of the modal and iframe * @defaultValue 99999 */ modalZIndex?: number; /** * You can get your clientId/projectId by registering your * dapp on {@link "https://dashboard.web3auth.io"| developer dashboard} */ web3AuthClientId: string; /** * network specifies the web3auth network to be used. */ web3AuthNetwork: WEB3AUTH_NETWORK_TYPE; } export interface PaymentParams { /** * Address to send the funds to */ selectedAddress?: string; /** * Default fiat currency for the user to make the payment in */ selectedCurrency?: string; /** * Amount to buy in the selectedCurrency */ fiatValue?: number; /** * Cryptocurrency to buy */ selectedCryptoCurrency?: string; } export interface LoginParams { authConnection?: AUTH_CONNECTION_TYPE; login_hint?: string; } export interface LoginWithSessionIdParams { sessionId: string; sessionNamespace?: string; } export interface UserInfo { /** * Email of the logged in user */ email: string; /** * Full name of the logged in user */ name: string; /** * Profile image of the logged in user */ profileImage: string; /** * authConnection of the logged in user (google, facebook etc) */ authConnection: AUTH_CONNECTION_TYPE; /** * Auth Connection Id of the logged in user * * email for google, * id for facebook, * username for reddit, * id for twitch, * id for discord */ authConnectionId: string; /** * User Id of the logged in user */ userId: string; /** * Grouped Auth Connection Id of the logged in user */ groupedAuthConnectionId: string; } export interface WalletUrlConfig { url?: string; logLevel?: LogLevelDesc; } export interface WsEmbedParams { /** * Supported chains */ chains: ProviderConfig[]; /** * Chain to connect with */ chainId: string; /** * Build Environment of WsEmbed. * * production uses https://wallet.web3auth.io, * * staging uses https://staging-wallet.web3auth.io, * * testing uses https://develop-wallet.web3auth.io (latest internal build) * * development uses http://localhost:4050 (expects wallet-services-frontend to be run locally), * * @defaultValue production */ buildEnv?: WS_EMBED_BUILD_ENV_TYPE; /** * Enables or disables logging. * * Defaults to false in prod and true in other environments */ enableLogging?: boolean; /** * url of widget to load * * Defaults to true * @defaultValue true */ walletUrls?: Partial<Record<WS_EMBED_BUILD_ENV_TYPE, WalletUrlConfig>>; /** * Determines how to show confirmation screens * @defaultValue default * * default & popup * - use popop as default * - if wallet connect request use modal * * modal * - use modal always * * auto-approve * - does not work on embed. will use default */ confirmationStrategy?: CONFIRMATION_STRATEGY_TYPE; /** * Enable and configure account abstraction */ accountAbstractionConfig?: AccountAbstractionMultiChainConfig; /** * Enable private key export * * Defaults to false * @defaultValue false */ enableKeyExport?: boolean; /** * Allows you to customize the look & feel of the widget */ whiteLabel?: { /** * whether to show/hide ws-embed widget. * * Defaults to true * @defaultValue true */ showWidgetButton?: boolean; /** * Determines where the wsEmbed widget is visible on the page. * @defaultValue bottom-left */ buttonPosition?: BUTTON_POSITION_TYPE; hideNftDisplay?: boolean; hideTokenDisplay?: boolean; hideTransfers?: boolean; hideTopup?: boolean; hideReceive?: boolean; hideSwap?: boolean; hideShowAllTokens?: boolean; hideWalletConnect?: boolean; defaultPortfolio?: "token" | "nft"; } & WhiteLabelData; } export interface ProviderOptions { /** * The name of the stream used to connect to the wallet. */ jsonRpcStreamName?: string; /** * The maximum number of event listeners. */ maxEventListeners?: number; } export interface BaseProviderState { isConnected: boolean; initialized: boolean; isPermanentlyDisconnected: boolean; hasEmittedConnection: boolean; } export interface InPageProviderState extends BaseProviderState { accounts: null | string[]; isUnlocked: boolean; } export interface CommunicationProviderState extends BaseProviderState { buttonPosition: string; isLoggedIn: boolean; widgetVisibility: boolean; currentAuthConnection: AUTH_CONNECTION_TYPE; isIFrameFullScreen: boolean; allowWalletService: boolean; } export type Maybe<T> = Partial<T> | T | null | undefined; export interface UnValidatedJsonRpcRequest extends JRPCRequest<unknown> { windowId?: string; }