import { Address } from 'viem'; import { O as OneAuthClient } from './client-CPt1hn4_.js'; import { C as CloseOnStatus, h as SignerType } from './types-BN6cCuAd.js'; /** * EIP-1193 JSON-RPC provider factory for the 1auth passkey authentication system. * * Creates a browser-side provider object that implements the EIP-1193 standard so any * Ethereum library (ethers, viem, wagmi) can use 1auth passkey signing and cross-chain * intent execution without modification. All transaction signing is delegated to the * passkey service rather than holding private keys in the browser. * * Supported RPC methods: * - eth_chainId, eth_accounts, eth_requestAccounts * - personal_sign, eth_sign, eth_signTypedData, eth_signTypedData_v4 * - eth_sendTransaction * - wallet_connect, wallet_disconnect, wallet_switchEthereumChain * - wallet_sendCalls, wallet_getCallsStatus, wallet_getCallsHistory (EIP-5792) * - wallet_getCapabilities, wallet_getAssets * * @module */ type ProviderRequest = { method: string; params?: unknown[] | Record; }; type Listener = (...args: unknown[]) => void; type OneAuthProvider = { request: (args: ProviderRequest) => Promise; on: (event: string, listener: Listener) => void; removeListener: (event: string, listener: Listener) => void; disconnect: () => Promise; /** * Bind the active session in-memory and persist it to `localStorage`. * * Used by {@link createOneAuthConnection} to hand a freshly connected session * to the provider the instant `connect()` resolves — before the app has * written `1auth-user` itself. This closes a race where a provider built right * after connect would read stale/empty storage and default an EOA session to * passkey intents. Passing `null` clears the session (same effect as * `disconnect()` minus the events). * * Existing `createOneAuthProvider` consumers never call this, so their * behavior is unchanged: `getStoredUser` falls back to the localStorage read. */ setSession: (session: { address: Address; signerType?: SignerType; connectorId?: string; } | null) => void; }; type OneAuthProviderOptions = { client: OneAuthClient; chainId: number; storageKey?: string; /** When to close the dialog and return success. Defaults to "preconfirmed" */ closeOn?: CloseOnStatus; waitForHash?: boolean; hashTimeoutMs?: number; hashIntervalMs?: number; }; /** * Creates an EIP-1193 compatible JSON-RPC provider backed by 1auth passkey authentication. * * The returned provider object can be used anywhere a standard Ethereum provider is * accepted (e.g. passed to `createWalletClient` in viem, used as `window.ethereum`, or * supplied to ethers.js `BrowserProvider`). Connection state (the account address) is * persisted in `localStorage` under the configured `storageKey`. * * @param options - Provider configuration * @param options.client - Configured `OneAuthClient` instance used to open auth/sign dialogs * @param options.chainId - Default chain ID the provider reports via `eth_chainId` * @param options.storageKey - localStorage key for persisting the connected user. * Defaults to `"1auth-user"`. Override to support multiple concurrent connections. * @param options.closeOn - Controls when the signing dialog closes and shows the "Done" button. * `"preconfirmed"` (default) closes as soon as the intent is confirmed by the orchestrator. * The `waitForHash` option independently controls whether the SDK continues polling for * a transaction hash after the dialog closes. * @param options.waitForHash - When true, polls the intent status until a transaction hash * is available before resolving `eth_sendTransaction` / `wallet_sendCalls`. Defaults to true. * @param options.hashTimeoutMs - Maximum milliseconds to wait for a transaction hash. * Passed directly to the passkey service intent submission. * @param options.hashIntervalMs - Polling interval in milliseconds when waiting for a hash. * Passed directly to the passkey service intent submission. * @returns An EIP-1193 provider with `request`, `on`, `removeListener`, and `disconnect`. * * @example * ```typescript * import { OneAuthClient } from "@rhinestone/1auth"; * import { createOneAuthProvider } from "@rhinestone/1auth"; * * const client = new OneAuthClient({ clientId: "my-app" }); * const provider = createOneAuthProvider({ client, chainId: 8453 }); // Base * * // Use with viem * import { createWalletClient, custom } from "viem"; * import { base } from "viem/chains"; * const walletClient = createWalletClient({ chain: base, transport: custom(provider) }); * * // Standard EIP-1193 usage * const accounts = await provider.request({ method: "eth_requestAccounts" }); * provider.on("accountsChanged", (accounts) => console.log(accounts)); * ``` */ declare function createOneAuthProvider(options: OneAuthProviderOptions): OneAuthProvider; export { type OneAuthProvider as O, type OneAuthProviderOptions as a, createOneAuthProvider as c };