import { BaseError } from "@aa-sdk/core"; import { z } from "zod"; import type { AuthParams } from "../signer.js"; import { BaseSignerClient, type ExportWalletStamper } from "./base.js"; import type { AlchemySignerClientEvents, AuthenticatingEventMetadata, CredentialCreationOptionOverrides, EmailAuthParams, ExportWalletParams, OauthConfig, OtpParams, JwtParams, JwtResponse, User, SubmitOtpCodeResponse, AuthLinkingPrompt, GetWebAuthnAttestationResult, IdTokenOnly, SmsAuthParams, ExportWalletOutput } from "./types.js"; export declare const AlchemySignerClientParamsSchema: z.ZodObject<{ connection: z.ZodIntersection; apiKey: z.ZodString; jwt: z.ZodOptional; }, "strip", z.ZodTypeAny, { apiKey: string; rpcUrl?: undefined; jwt?: undefined; }, { apiKey: string; rpcUrl?: undefined; jwt?: undefined; }>, z.ZodObject<{ rpcUrl: z.ZodOptional; apiKey: z.ZodOptional; jwt: z.ZodString; }, "strip", z.ZodTypeAny, { jwt: string; rpcUrl?: undefined; apiKey?: undefined; }, { jwt: string; rpcUrl?: undefined; apiKey?: undefined; }>, z.ZodObject<{ rpcUrl: z.ZodString; apiKey: z.ZodOptional; jwt: z.ZodOptional; }, "strip", z.ZodTypeAny, { rpcUrl: string; apiKey?: undefined; jwt?: undefined; }, { rpcUrl: string; apiKey?: undefined; jwt?: undefined; }>, z.ZodObject<{ rpcUrl: z.ZodString; apiKey: z.ZodOptional; jwt: z.ZodString; }, "strip", z.ZodTypeAny, { rpcUrl: string; jwt: string; apiKey?: undefined; }, { rpcUrl: string; jwt: string; apiKey?: undefined; }>]>, z.ZodObject<{ chainAgnosticUrl: z.ZodOptional; }, "strip", z.ZodTypeAny, { chainAgnosticUrl?: string | undefined; }, { chainAgnosticUrl?: string | undefined; }>>; iframeConfig: z.ZodObject<{ iframeElementId: z.ZodDefault; iframeContainerId: z.ZodString; }, "strip", z.ZodTypeAny, { iframeElementId: string; iframeContainerId: string; }, { iframeContainerId: string; iframeElementId?: string | undefined; }>; rpId: z.ZodOptional; rootOrgId: z.ZodDefault>; oauthCallbackUrl: z.ZodDefault>; enablePopupOauth: z.ZodDefault>; }, "strip", z.ZodTypeAny, { connection: ({ apiKey: string; rpcUrl?: undefined; jwt?: undefined; } | { jwt: string; rpcUrl?: undefined; apiKey?: undefined; } | { rpcUrl: string; apiKey?: undefined; jwt?: undefined; } | { rpcUrl: string; jwt: string; apiKey?: undefined; }) & { chainAgnosticUrl?: string | undefined; }; iframeConfig: { iframeElementId: string; iframeContainerId: string; }; rootOrgId: string; oauthCallbackUrl: string; enablePopupOauth: boolean; rpId?: string | undefined; }, { connection: ({ apiKey: string; rpcUrl?: undefined; jwt?: undefined; } | { jwt: string; rpcUrl?: undefined; apiKey?: undefined; } | { rpcUrl: string; apiKey?: undefined; jwt?: undefined; } | { rpcUrl: string; jwt: string; apiKey?: undefined; }) & { chainAgnosticUrl?: string | undefined; }; iframeConfig: { iframeContainerId: string; iframeElementId?: string | undefined; }; rpId?: string | undefined; rootOrgId?: string | undefined; oauthCallbackUrl?: string | undefined; enablePopupOauth?: boolean | undefined; }>; export type AlchemySignerClientParams = z.input; /** * A lower level client used by the AlchemySigner used to communicate with * Alchemy's signer service. */ export declare class AlchemySignerWebClient extends BaseSignerClient { private iframeStamper; private webauthnStamper; oauthCallbackUrl: string; iframeConfig: { iframeElementId: string; iframeContainerId: string; }; /** * Initializes a new instance with the given parameters, setting up the connection, iframe configuration, and WebAuthn stamper. * * @example * ```ts * import { AlchemySignerWebClient } from "@account-kit/signer"; * * const client = new AlchemySignerWebClient({ * connection: { * apiKey: "your-api-key", * }, * iframeConfig: { * iframeContainerId: "signer-iframe-container", * }, * }); * ``` * * @param {AlchemySignerClientParams} params the parameters required to initialize the client * @param {ConnectionConfig} params.connection The connection details needed to connect to the service * @param {{ iframeElementId?: string; iframeContainerId: string }} params.iframeConfig The configuration details for setting up the iframe stamper * @param {string} params.rpId The relying party ID, defaulting to the current hostname if not provided * @param {string} params.rootOrgId The root organization ID */ constructor(params: AlchemySignerClientParams); /** * Begin authenticating a user with their email and an expiration time for the authentication request. Initializes the iframe stamper to get the target public key. * This method sends an email to the user to complete their login * * @example * ```ts * import { AlchemySignerWebClient } from "@account-kit/signer"; * * const client = new AlchemySignerWebClient({ * connection: { * apiKey: "your-api-key", * }, * iframeConfig: { * iframeContainerId: "signer-iframe-container", * }, * }); * * const account = await client.initEmailAuth({ email: "you@mail.com" }); * ``` * * @param {Omit} params The parameters for email authentication, excluding the target public key * @returns {Promise} The response from the authentication request */ initEmailAuth: (params: Omit) => Promise<{ orgId: string; otpId?: string; multiFactors?: import("./types.js").MfaFactor[]; }>; /** * Begin authenticating a user through sms. Initializes the iframe stamper to get the target public key. * This method sends a text message to the user to complete their login * * @example * ```ts * import { AlchemySignerWebClient } from "@account-kit/signer"; * * const client = new AlchemySignerWebClient({ * connection: { * apiKey: "your-api-key", * }, * iframeConfig: { * iframeContainerId: "signer-iframe-container", * }, * }); * * const account = await client.initSmsAuth({ phone: "+1234567890" }); * ``` * * @param {Omit} params The parameters for sms authentication, excluding the target public key * @returns {Promise} The response from the authentication request */ initSmsAuth: (params: Omit) => Promise<{ orgId: string; otpId?: string; multiFactors?: import("./types.js").MfaFactor[]; }>; /** * Authenticates using an OTP code which was previously received via email. * * @example * ```ts * import { AlchemySignerWebClient } from "@account-kit/signer"; * * const client = new AlchemySignerWebClient({ * connection: { * apiKey: "your-api-key", * }, * iframeConfig: { * iframeContainerId: "signer-iframe-container", * }, * }); * * const account = await client.submitOtpCode({ * orgId: "user-org-id", * otpId: "opt-returned-from-initEmailAuth", * otpCode: "otp-code-from-email", * }); * ``` * * @param {Omit} args The parameters for the OTP request, excluding the target public key. * @returns {Promise<{ bundle: string }>} A promise that resolves to an object containing the credential bundle. */ submitOtpCode(args: Omit): Promise; /** * Authenticates using a custom issued JWT * * @example * ```ts * import { AlchemySignerWebClient } from "@account-kit/signer"; * * const client = new AlchemySignerWebClient({ * connection: { * apiKey: "your-api-key", * }, * iframeConfig: { * iframeContainerId: "signer-iframe-container", * }, * }); * * const account = await client.submitJwt({ * jwt: "custom-issued-jwt", * authProvider: "auth-provider-name", * }); * ``` * * @param {Omit} args The parameters for the JWT request, excluding the target public key. * @returns {Promise<{ bundle: string }>} A promise that resolves to an object containing the credential bundle. */ submitJwt(args: Omit): Promise; /** * Completes auth for the user by injecting a credential bundle and retrieving * the user information based on the provided organization ID. Emits events * during the process. * * @example * ```ts * import { AlchemySignerWebClient } from "@account-kit/signer"; * * const client = new AlchemySignerWebClient({ * connection: { * apiKey: "your-api-key", * }, * iframeConfig: { * iframeContainerId: "signer-iframe-container", * }, * }); * * const account = await client.completeAuthWithBundle({ orgId: "user-org-id", bundle: "bundle-from-email", connectedEventName: "connectedEmail" }); * ``` * * @param {{ bundle: string; orgId: string, connectedEventName: keyof AlchemySignerClientEvents, idToken?: string }} config * The configuration object for the authentication function containing the * credential bundle to inject and the organization id associated with the * user, as well as the event to be emitted on success and optionally an OIDC * ID token with extra user information * @returns {Promise} A promise that resolves to the authenticated user * information */ completeAuthWithBundle: ({ bundle, orgId, connectedEventName, idToken, accessToken, authenticatingType, }: { bundle: string; orgId: string; connectedEventName: keyof AlchemySignerClientEvents; authenticatingType: AuthenticatingEventMetadata["type"]; idToken?: string; accessToken?: string; }) => Promise; /** * Initiates the export of a wallet by creating an iframe stamper and calling the appropriate export function. * The export can be based on a seed phrase or a private key. * * @example * ```ts * import { AlchemySignerWebClient } from "@account-kit/signer"; * * const client = new AlchemySignerWebClient({ * connection: { * apiKey: "your-api-key", * }, * iframeConfig: { * iframeContainerId: "signer-iframe-container", * }, * }); * * const account = await client.exportWallet({ * iframeContainerId: "export-iframe-container", * }); * ``` * * @param {ExportWalletParams} config The parameters for exporting the wallet * @param {string} config.iframeContainerId The ID of the container element that will hold the iframe stamper * @param {string} [config.iframeElementId] Optional ID for the iframe element * @returns {Promise} A promise that resolves when the export process is complete */ exportWallet: ({ iframeContainerId, iframeElementId, }: ExportWalletParams) => Promise; /** * Exports wallet credentials based on the specified type, either as a SEED_PHRASE or PRIVATE_KEY. * * @param {object} params The parameters for exporting the wallet * @param {ExportWalletStamper} params.exportStamper The stamper used for exporting the wallet * @param {"SEED_PHRASE" | "PRIVATE_KEY"} params.exportAs Specifies the format for exporting the wallet, either as a SEED_PHRASE or PRIVATE_KEY * @returns {Promise} A promise that resolves to true if the export is successful */ protected exportWalletInner(params: { exportStamper: ExportWalletStamper; exportAs: "SEED_PHRASE" | "PRIVATE_KEY"; }): Promise; /** * Asynchronous function that clears the user and resets the iframe stamper. * * @example * ```ts * import { AlchemySignerWebClient } from "@account-kit/signer"; * * const client = new AlchemySignerWebClient({ * connection: { * apiKey: "your-api-key", * }, * iframeConfig: { * iframeContainerId: "signer-iframe-container", * }, * }); * * const account = await client.disconnect(); * ``` */ disconnect: () => Promise; /** * Redirects the user to the OAuth provider URL based on the provided arguments. This function will always reject after 1 second if the redirection does not occur. * * @example * ```ts * import { AlchemySignerWebClient } from "@account-kit/signer"; * * const client = new AlchemySignerWebClient({ * connection: { * apiKey: "your-api-key", * }, * iframeConfig: { * iframeContainerId: "signer-iframe-container", * }, * }); * * await client.oauthWithRedirect({ * type: "oauth", * authProviderId: "google", * mode: "redirect", * redirectUrl: "/", * }); * ``` * * @param {Extract} args The arguments required to obtain the OAuth provider URL * @returns {Promise} A promise that will never resolve, only reject if the redirection fails */ oauthWithRedirect: (args: Extract) => Promise; /** * Initiates an OAuth authentication flow in a popup window and returns the authenticated user. * * @example * ```ts * import { AlchemySignerWebClient } from "@account-kit/signer"; * * const client = new AlchemySignerWebClient({ * connection: { * apiKey: "your-api-key", * }, * iframeConfig: { * iframeContainerId: "signer-iframe-container", * }, * }); * * const user = await client.oauthWithPopup({ * type: "oauth", * authProviderId: "google", * mode: "popup" * }); * ``` * * @param {Extract} args The authentication parameters specifying OAuth type and popup mode * @returns {Promise} A promise that resolves to a `User` object containing the authenticated user information */ oauthWithPopup: (args: Extract) => Promise; /** * Initializes the iframe stamper and returns its public key. * * @example * ```ts twoslash * import { AlchemySignerWebClient } from "@account-kit/signer"; * * const client = new AlchemySignerWebClient({ * connection: { * apiKey: "your-api-key", * }, * iframeConfig: { * iframeContainerId: "signer-iframe-container", * }, * }); * * const publicKey = await client.targetPublicKey(); * ``` * * @returns {Promise} A promise that resolves with the target public key when the iframe stamper is successfully initialized, or throws an error if the target public key is not supported. */ targetPublicKey: () => Promise; protected getWebAuthnAttestation: (options?: CredentialCreationOptionOverrides, userDetails?: { username: string; }) => Promise; protected getOauthConfig: () => Promise; private initSessionStamperPromise; protected initSessionStamper(): Promise; protected initWebauthnStamper(user?: User | undefined): Promise; private exportAsSeedPhrase; private exportAsPrivateKey; } /** * This error is thrown when the OAuth flow is cancelled because the auth popup * window was closed. */ export declare class OauthCancelledError extends BaseError { name: string; /** * Constructor for initializing an error indicating that the OAuth flow was * cancelled. */ constructor(); } /** * This error is thrown when an error occurs during the OAuth login flow. */ export declare class OauthFailedError extends BaseError { name: string; } //# sourceMappingURL=index.d.ts.map