import { type AuthAndWalletRpcReturnType, type AuthLoginReturnType } from "../../interfaces/auth"; import type { ClientIdWithQuerierType, LogoutReturnType, SendEmailOtpReturnType } from "../../interfaces/embedded-wallets/embedded-wallets"; import { LocalStorage } from "../../utils/Storage/LocalStorage"; import type { EmbeddedWalletIframeCommunicator } from "../../utils/iFrameCommunication/EmbeddedWalletIframeCommunicator"; import { BaseLogin } from "./base-login"; export type AuthQuerierTypes = { logout: void; initIframe: { clientId: string; authCookie: string; walletUserId: string; deviceShareStored: string; }; }; export declare class Auth { protected clientId: string; protected AuthQuerier: EmbeddedWalletIframeCommunicator; protected localStorage: LocalStorage; protected onAuthSuccess: (authResults: AuthAndWalletRpcReturnType) => Promise; private BaseLogin; /** * Used to manage the user's auth states. This should not be instantiated directly. * Call {@link EmbeddedWalletSdk.auth} instead. */ constructor({ clientId, querier, onAuthSuccess, }: ClientIdWithQuerierType & { onAuthSuccess: (authDetails: AuthAndWalletRpcReturnType) => Promise; }); private preLogin; private postLogin; /** * Used to log the user into their thirdweb wallet on your platform via a myriad of auth providers * * @example * ```typescript * const thirdwebEmbeddedWallet = new EmbeddedWalletSdk({clientId: "YOUR_CLIENT_ID", chain: "Polygon"}) * try { * const user = await thirdwebEmbeddedWallet.auth.loginWithModal(); * // user is now logged in * } catch (e) { * // User closed modal or something else went wrong during the authentication process * console.error(e) * } * ``` * * @returns `{{user: InitializedUser}}` An InitializedUser object. See {@link EmbeddedWalletSdk.getUser} for more */ loginWithModal(): Promise; /** * Used to log the user into their thirdweb wallet using email OTP * * @example * ```typescript * // Basic Flow * const thirdwebEmbeddedWallet = new EmbeddedWalletSdk({clientId: "", chain: "Polygon"}); * try { * // prompts user to enter the code they received * const user = await thirdwebEmbeddedWallet.auth.loginWithThirdwebEmailOtp({ email : "you@example.com" }); * // user is now logged in * } catch (e) { * // User closed the OTP modal or something else went wrong during the authentication process * console.error(e) * } * ``` * * @param args - args.email: We will send the email an OTP that needs to be entered in order for them to be logged in. * @returns `{{user: InitializedUser}}` An InitializedUser object. See {@link EmbeddedWalletSdk.getUser} for more */ loginWithEmailOtp(args: Parameters[0]): Promise; loginWithCustomJwt(args: Parameters[0]): Promise; loginWithCustomAuthEndpoint(args: Parameters[0]): Promise; loginWithOauth(args: Parameters[0]): Promise; /** * A headless way to send the users at the passed email an OTP code. * You need to then call {@link Auth.verifyEmailLoginOtp} in order to complete the login process * * @example * ```typescript * const thirdwebEmbeddedWallet = new EmbeddedWalletSdk({clientId: "", chain: "Polygon"}); * // sends user an OTP code * try { * await thirdwebEmbeddedWallet.auth.sendEmailLoginOtp({ email : "you@example.com" }); * } catch(e) { * // Error Sending user's email an OTP code * console.error(e); * } * * // Then when your user is ready to verify their OTP * try { * const user = await thirdwebEmbeddedWallet.auth.verifyEmailLoginOtp({ email: "you@example.com", otp: "6-DIGIT_CODE_HERE" }); * } catch(e) { * // Error verifying the OTP code * console.error(e) * } * ``` * * @param param0 - param0.email We will send the email an OTP that needs to be entered in order for them to be logged in. * @returns `{{ isNewUser: boolean }}` IsNewUser indicates if the user is a new user to your platform */ sendEmailLoginOtp({ email, }: Parameters[0]): Promise; sendSmsLoginOtp({ phoneNumber, }: Parameters[0]): Promise; /** * Used to verify the otp that the user receives from thirdweb * * See {@link Auth.sendEmailLoginOtp} for how the headless call flow looks like. Simply swap out the calls to `loginWithThirdwebEmailOtp` with `verifyThirdwebEmailLoginOtp` * * @param args - props.email We will send the email an OTP that needs to be entered in order for them to be logged in. * props.otp The code that the user received in their email * @returns `{{user: InitializedUser}}` An InitializedUser object containing the user's status, wallet, authDetails, and more */ verifyEmailLoginOtp(args: Parameters[0]): Promise; verifySmsLoginOtp(args: Parameters[0]): Promise; /** * Logs any existing user out of their wallet. * @returns `{{success: boolean}}` true if a user is successfully logged out. false if there's no user currently logged in. */ logout(): Promise; } //# sourceMappingURL=index.d.ts.map