import { LoginConfig , OriginData , WhiteLabelData } from "@toruslabs/openlogin-jrpc" ; import { ExtraLoginOptions } from "@toruslabs/openlogin-utils" ; export const modalDOMElementID = "openlogin-modal" ; export const storeKey = "openlogin_store" ; export type PopupResponse < T > = { pid : string ; data : T ; } ; export type Maybe < T > = Partial < T > | null | undefined ; export const UX_MODE = { POPUP : "popup" , REDIRECT : "redirect" , } as const ; export type UX_MODE_TYPE = typeof UX_MODE [ keyof typeof UX_MODE ] ; export const OPENLOGIN_METHOD = { LOGIN : "openlogin_login" , LOGOUT : "openlogin_logout" , CHECK_3PC_SUPPORT : "openlogin_check_3PC_support" , SET_PID_DATA : "openlogin_set_pid_data" , GET_DATA : "openlogin_get_data" , } as const ; export type CUSTOM_OPENLOGIN_METHOD_TYPE = string & { toString ? : ( radix ? : number ) => string ; } ; export type OPENLOGIN_METHOD_TYPE = typeof OPENLOGIN_METHOD [ keyof typeof OPENLOGIN_METHOD ] ; export const ALLOWED_INTERACTIONS = { POPUP : "popup" , REDIRECT : "redirect" , JRPC : "jrpc" , } as const ; export type ALLOWED_INTERACTIONS_TYPE = typeof ALLOWED_INTERACTIONS [ keyof typeof ALLOWED_INTERACTIONS ] ; export type RequestParams = { startUrl ? : string ; popupUrl ? : string ; method : OPENLOGIN_METHOD_TYPE | CUSTOM_OPENLOGIN_METHOD_TYPE ; params : Record < string , unknown > [ ] ; allowedInteractions : ALLOWED_INTERACTIONS_TYPE [ ] ; } ; export type BaseLogoutParams = { /**
     * You can get your clientId/projectId by registering your
     * dapp on  {@link "https://developer.tor.us"| developer dashbaord} clientId : string ; defaultValue experimental remarks fastLogin : boolean ; } ; export type BaseRedirectParams = { remarks Register this url at  {@link "https://developer.tor.us"| developer dashbaord} * else initialization will give error.
      redirectUrl ? : string ; /**
     * Any custom state you wish to pass along. This will be returned to you post redirect.
     * Use this to store data that you want to be available to the dapp after login.
     */ appState ? : string ; } ; export const OPENLOGIN_NETWORK = { MAINNET : "mainnet" , TESTNET : "testnet" , DEVELOPMENT : "development" , } as const ; export type OPENLOGIN_NETWORK_TYPE = typeof OPENLOGIN_NETWORK [ keyof typeof OPENLOGIN_NETWORK ] ; export type OpenLoginOptions = { /**
     * You can get your clientId/projectId by registering your
     * dapp on  {@link "https://developer.tor.us"| developer dashbaord} clientId : string ; /**
     * network specifies the openlogin iframe url url to be used.
     *
     * - `'mainnet'`: https://app.openlogin.com will be used which is the production version.
     * - `'testnet'`: https://beta.openlogin.com will be used which is the beta version.
     * - `'development'`: http://localhost:3000 will be used for development purpose.
     */ network : OPENLOGIN_NETWORK_TYPE ; defaultValue remarks no3PC ? : boolean ; remarks Register this url at  {@link "https://developer.tor.us"| developer dashbaord} * else initialization will give error.
      redirectUrl ? : string ; defaultValue remarks uxMode ? : UX_MODE_TYPE ; defaultValue replaceUrlOnRedirect ? : boolean ; internal remarks You don't have to pass originData explicitly if you have registered your dapp at
     *  {@link "https://developer.tor.us"| developer dashbaord} .
     *
     * originData contains a signature of dapp's origin url which is generated using
     * project's secret.
      originData ? : OriginData ; remarks You can deploy your own verifiers from  {@link "https://developer.tor.us"| developer dashbaord} * to use here.
     *
      loginConfig ? : LoginConfig ; internal _iframeUrl ? : string ; internal _startUrl ? : string ; internal _popupUrl ? : string ; /**
     * options for whitelabling default openlogin modal.
     */ whiteLabel ? : WhiteLabelData ; } ; export const LOGIN_PROVIDER = { GOOGLE : "google" , FACEBOOK : "facebook" , REDDIT : "reddit" , DISCORD : "discord" , TWITCH : "twitch" , APPLE : "apple" , LINE : "line" , GITHUB : "github" , KAKAO : "kakao" , LINKEDIN : "linkedin" , TWITTER : "twitter" , WEIBO : "weibo" , WECHAT : "wechat" , EMAIL_PASSWORDLESS : "email_passwordless" , WEBAUTHN : "webauthn" , JWT : "jwt" , } as const ; /**
 * {@label loginProviderType}
 */ export type LOGIN_PROVIDER_TYPE = typeof LOGIN_PROVIDER [ keyof typeof LOGIN_PROVIDER ] ; export type CUSTOM_LOGIN_PROVIDER_TYPE = string & { toString ? : ( radix ? : number ) => string ; } ; export type LoginParams = BaseRedirectParams & { /**
     * loginProvider sets the oauth login method to be used.
     * You can use any of the valid loginProvider from the supported list.
     *
     * If this param is not passed then it will show all the available
     * login methods to user in a modal.
     *
     */ loginProvider ? : LOGIN_PROVIDER_TYPE | CUSTOM_LOGIN_PROVIDER_TYPE ; defaultValue experimental remarks fastLogin ? : boolean ; defaultValue relogin ? : boolean ; defaultValue skipTKey ? : boolean ; defaultValue internal getWalletKey ? : boolean ; /**
     * extraLoginOptions can be used to pass standard oauth login options to
     * loginProvider.
     *
     * For ex: you will have to pass `login_hint` as user's email and `domain`
     * as your app domain in `extraLoginOptions` while using `email_passwordless`
     * loginProvider
     */ extraLoginOptions ? : ExtraLoginOptions ; } ; export type OpenloginUserInfo = { email : string ; name : string ; profileImage : string ; aggregateVerifier : string ; verifier : string ; verifierId : string ; typeOfLogin : LOGIN_PROVIDER_TYPE | CUSTOM_LOGIN_PROVIDER_TYPE ; } ;