import { P as PasskeyProviderConfig, S as SponsorshipConfig, T as ThemeConfig, ab as GetAssetsOptions, ae as AssetsResponse, z as AuthWithModalOptions, A as AuthResult, L as LoginWithModalOptions, B as CreateAccountWithModalOptions, D as ConnectResult, ah as CheckConsentOptions, ai as CheckConsentResult, aj as RequestConsentOptions, ak as RequestConsentResult, al as GrantPermissionsOptions, am as GrantPermissionsResult, an as ListSessionGrantsOptions, ao as ListSessionGrantsResult, F as AuthenticateOptions, G as AuthenticateResult, q as SigningRequestOptions, r as SigningResult, a2 as SendIntentOptions, j as SendIntentResult, au as SendBatchIntentOptions, av as SendBatchIntentResult, a8 as IntentHistoryOptions, aa as IntentHistoryResult, K as SignMessageOptions, M as SignMessageResult, N as SignTypedDataOptions, O as SignTypedDataResult, E as EmbedOptions } from './types-BN6cCuAd.js';
declare class OneAuthClient {
private config;
private theme;
private sponsorship;
private eoaDialogState;
private prewarmState;
private eoaSerialQueue;
/** Clear the default cache plus every provider bound to this client. */
private forgetApplicationSessions;
/** Forget embedder-side sessions from any trusted dialog transport. */
private installDisconnectListener;
/**
* Create a new OneAuthClient.
*
* Normalizes the config (filling in default URLs), then immediately injects
* `` tags for the passkey domain so that DNS lookup
* and TLS handshake start before the first dialog is opened, shaving
* noticeable latency from the first user interaction.
*
* @param config - Client configuration including optional providerUrl, dialogUrl,
* clientId, theme, and redirect settings.
*/
constructor(config: PasskeyProviderConfig);
/**
* Update the sponsorship configuration at runtime. Pass `undefined` to
* disable sponsorship.
*/
setSponsorship(sponsorship: SponsorshipConfig | undefined): void;
/**
* Whether the caller opted into SDK telemetry propagation or callbacks.
*/
private shouldUseTelemetry;
/**
* Resolve the host app's current trace context. Callback failures are
* ignored because observability can never be allowed to break signing.
*/
private getTelemetryTraceContext;
/**
* Resolve host-provided SDK event attributes and remove undefined fields.
*/
private getTelemetryAttributes;
/**
* Create per-operation telemetry context shared by callbacks, HTTP headers,
* dialog URL params, and PASSKEY_INIT messages.
*/
private createTelemetryOperation;
/**
* Emit a telemetry event to the host app. The callback is intentionally
* fire-and-forget and exception-safe so app telemetry cannot affect users.
*/
private emitTelemetry;
/**
* Attach SDK correlation and optional W3C trace context to dialog URLs.
*/
private appendTelemetryParams;
/**
* Add SDK correlation headers to passkey API calls. These headers are also
* valid W3C trace propagation inputs when the host app supplies traceparent.
*/
private telemetryHeaders;
/**
* Embed telemetry context in PASSKEY_INIT payloads for dialog-side API calls.
*/
private telemetryPayload;
/** Resolve the public funding policy while preserving the legacy user-paid alias. */
private resolveSponsorshipMode;
/**
* Determine whether this signing call should request invisible dialog mode.
* Resolution order: per-call option wins over the constructor config, which
* wins over the platform-wide {@link DEFAULT_BLIND_SIGNING}. This lets an app
* flip the global default for itself while still overriding individual
* high-risk calls.
*/
private shouldRequestBlindSigning;
/**
* Fetch the app's access token (JWT). Called up front, before
* `/api/intent/prepare`, so the passkey server can authenticate the
* orchestrator quote call with the app's JWT instead of a service-level
* API key.
*
* Does not depend on `intentOp` — can run in parallel with anything that
* also doesn't depend on the quote.
*/
private fetchAccessToken;
/**
* Fetch one extension token per canonical sponsorship intent input, aligned
* with `sponsorFlags`. Sponsored prepare uses the same token for the final
* quote and later submission, so route construction and execution share one
* digest-bound authorization.
*/
private fetchExtensionTokens;
/**
* Update the theme configuration at runtime
*/
setTheme(theme: ThemeConfig): void;
/**
* Serialize the active theme into URL query parameters for the dialog.
*
* Merges the instance-level theme (set via constructor or `setTheme`) with any
* per-call override, so callers can temporarily change the appearance for a
* single dialog invocation without mutating shared state.
*
* @param overrideTheme - One-shot theme values that take precedence over the
* instance theme for this call only.
* @returns A URL-encoded query string (e.g. `"theme=dark&accent=%230090ff"`),
* or an empty string if no theme properties are set.
*/
private getThemeParams;
/**
* Resolve the URL of the dialog app (the Vite/Next.js frontend that renders
* the WebAuthn UI inside the iframe).
*
* `dialogUrl` is a separate config option to support split deployments where
* the API server and the dialog frontend run at different origins. Falls back
* to `providerUrl` when not explicitly configured — the common case.
*
* @returns The base URL used when constructing all dialog endpoint paths.
*/
private getDialogUrl;
/**
* Extract the trusted origin used to validate incoming postMessage events.
*
* All `window.addEventListener("message", ...)` handlers in this class check
* `event.origin` against this value to prevent cross-origin spoofing. Wraps
* `getDialogUrl()` in a `new URL()` parse so that paths and query strings are
* stripped — only the scheme + host + port are compared.
*
* Falls back to the raw dialog URL string if URL parsing fails (e.g. during
* unit tests with non-standard URL formats).
*
* @returns The scheme + host + optional port of the dialog app (e.g. `"https://passkey.1auth.app"`).
*/
private getDialogOrigin;
/**
* Get the base provider URL
*/
getProviderUrl(): string;
/**
* Get the configured client ID
*/
getClientId(): string | undefined;
/**
* Whether this client operates on testnet chains only.
*/
getTestnets(): boolean;
/**
* Get a unified token portfolio for a 1auth account across mainnets and
* testnets.
*
* @example
* ```typescript
* const assets = await client.getAssets({
* accountAddress: "0x1111111111111111111111111111111111111111",
* });
* console.log(assets.mainnets.balances, assets.testnets.balances);
* ```
*/
getAssets(options: GetAssetsOptions): Promise;
/**
* Poll the intent status endpoint until a transaction hash appears or the
* intent reaches a terminal failure state.
*
* This is used after `sendIntent` resolves (with `waitForHash: true`) to
* continue waiting for the on-chain hash even after the dialog has been
* dismissed. It is intentionally separate from the in-dialog polling loop so
* callers that don't need the hash can skip it entirely.
*
* Errors during individual poll attempts are swallowed so that transient
* network issues don't abort the wait prematurely.
*
* @param intentId - The Rhinestone intent ID returned by the execute endpoint.
* @param options.timeoutMs - Maximum wait time in milliseconds (default 120 000).
* @param options.intervalMs - Time between polls in milliseconds (default 2 000).
* @returns The transaction hash string, or `undefined` if the deadline was
* reached or the intent failed/expired before a hash was produced.
*/
private waitForTransactionHash;
/**
* Open the authentication modal (sign in + sign up).
*
* Handles both new user registration and returning user login in a single
* call — the modal shows the appropriate flow based on whether the user
* has a passkey registered.
*
* @param options.theme - Override the theme for this modal invocation
* @param options.oauthEnabled - Set to false to hide OAuth sign-in buttons
* @param options.flow - Force the login or account-creation route instead
* of the default auto-detect entry route
* @returns {@link AuthResult} with user details and typed address
*
* @example
* ```typescript
* const result = await client.authWithModal();
*
* if (result.success) {
* console.log('Signed in as:', result.user?.address);
* console.log('Address:', result.user?.address); // typed `0x${string}`
* } else if (result.error?.code === 'USER_CANCELLED') {
* // User closed the modal
* }
* ```
*/
authWithModal(options?: AuthWithModalOptions): Promise;
/**
* Open the sign-in modal directly.
*
* This bypasses the `/dialog/auth` auto-router and targets the dedicated
* returning-user flow. Use it when the embedding app already knows the user
* is creating a login session, for example after an app-level "Log in"
* button. The result intentionally matches {@link authWithModal}.
*
* @param options.theme - Override the theme for this modal invocation
* @returns {@link AuthResult} with user details and typed address
*/
loginWithModal(options?: LoginWithModalOptions): Promise;
/**
* Open the account-creation modal directly.
*
* This bypasses the `/dialog/auth` auto-router and targets the dedicated
* sign-up flow. Account creation still happens server-side in the passkey
* service; the SDK only opens the dialog and receives the postMessage result.
*
* @param options.theme - Override the theme for this modal invocation
* @param options.oauthEnabled - Set to false to hide OAuth sign-in buttons
* @returns {@link AuthResult} with the newly authenticated account details
*/
createAccountWithModal(options?: CreateAccountWithModalOptions): Promise;
/**
* Open one of the passkey authentication modal routes and wait for the
* login-result message.
*
* Keeping URL construction in one helper prevents the explicit login/signup
* methods from drifting away from the legacy `authWithModal` behavior.
*/
private openAuthModal;
/**
* Generate a per-dialog nonce used to correlate iframe close messages with
* the SDK modal that opened them. Chromium can report a different
* `MessageEvent.source` WindowProxy after the `/dialog/auth` redirect, so
* auth close handling needs a stable in-band identifier without accepting
* stale close messages from earlier dialogs.
*/
private createDialogRequestId;
/**
* Resolve the passkey app route for a requested auth flow.
*/
private getAuthDialogPath;
/**
* Open the connect dialog (lightweight connection without passkey auth).
*
* This method shows a simple connection confirmation dialog that doesn't
* require a passkey signature. Users can optionally enable "auto-connect"
* to skip this dialog in the future.
*
* If the user has never connected before, this will return action: "switch"
* to indicate that the full auth modal should be opened instead.
*
* @example
* ```typescript
* const result = await client.connectWithModal();
*
* if (result.success) {
* console.log('Connected as:', result.user?.address);
* } else if (result.action === 'switch') {
* // User needs to sign in first
* const authResult = await client.authWithModal();
* }
* ```
*/
connectWithModal(options?: {
theme?: ThemeConfig;
}): Promise;
/**
* High-level connect entry point — the method most integrators want.
*
* Tries the lightweight {@link connectWithModal} first (no passkey ceremony
* for returning users on the same browser), and transparently falls back to
* {@link authWithModal} when the connect dialog reports it has no stored
* credentials for this origin (`action: "switch"`). First-time visitors get
* one passkey ceremony to register; subsequent connects on the same browser
* resolve with no biometric prompt — and silently when the user has enabled
* "Connect automatically".
*
* The return shape is the same {@link ConnectResult} discriminated union as
* {@link connectWithModal}, so callers can treat both paths uniformly. When
* the auth-modal fallback runs, its successful result is normalized into a
* `ConnectResult` (no `id` field — the embedder origin must not see it).
*
* Cancellation: if the user cancels either dialog, the result is
* `{ success: false, action: "cancel", error: { code: "USER_CANCELLED", … } }`.
*
* @param options - Forwarded to whichever underlying modal is shown.
* `oauthEnabled` only applies to the auth-modal fallback path.
* @returns A {@link ConnectResult} discriminated union.
*
* @example
* ```typescript
* const result = await client.connect();
* if (result.success) {
* console.log("Connected as", result.user?.address);
* }
* ```
*/
connect(options?: {
theme?: ThemeConfig;
oauthEnabled?: boolean;
/**
* Opt into "wallet as signer" mode for the auth-modal fallback — see
* {@link AuthWithModalOptions.eoaConnect}. Set by {@link createOneAuthConnection}.
*/
eoaConnect?: boolean;
}): Promise;
/**
* Open the account management dialog.
*
* Shows the account overview with guardian status and recovery setup
* options. The dialog closes when the user clicks the X button or
* completes their action.
*
* @example
* ```typescript
* await client.openAccountDialog();
* ```
*/
openAccountDialog(options?: {
theme?: ThemeConfig;
}): Promise;
/**
* Open the account-recovery backup flow directly.
*
* Deep-links into the "Backup your account" flow inside the account dialog
* (rather than the account overview): the user verifies with their passkey,
* then saves a recovery passphrase and downloads an encrypted backup file.
* Use this to prompt users to secure their account after sign-up.
*
* Requires an authenticated user (call `authWithModal()` / `connect()`
* first) — the dialog reads the signed-in user from the passkey origin.
*
* Resolves `{ completed: true }` when the user finishes the backup, or
* `{ completed: false }` if they dismiss it — so callers can mark an
* onboarding step done or re-prompt later.
*/
setupRecovery(options?: {
theme?: ThemeConfig;
}): Promise<{
completed: boolean;
}>;
/**
* Check if a user has already granted consent for the requested fields.
*
* @deprecated Data-sharing consent is disabled.
*
* Always returns `{ hasConsent: false }`.
*/
checkConsent(options: CheckConsentOptions): Promise;
/**
* Request consent from the user to share their data.
*
* @deprecated Data-sharing consent is disabled.
*
* Always returns an `INVALID_REQUEST` result.
*/
requestConsent(options: RequestConsentOptions): Promise;
/**
* Open the dedicated SmartSession permission grant dialog.
*
* The app owns the session key material and sends only the public
* `sessionKeyAddress`. 1auth renders the permission review, collects the
* owner's passkey authorization, submits the install/enable intent, and
* returns a persistable session handle.
*/
grantPermissions(options: GrantPermissionsOptions): Promise;
/**
* List SmartSession grants previously granted to the current browser origin.
*
* 1auth derives the app identity from the request Origin header. The SDK does
* not send `clientId` for this lookup because grants are origin-scoped.
*/
listSessionGrants(options: ListSessionGrantsOptions): Promise;
/**
* Authenticate a user with an optional challenge to sign.
*
* This method combines authentication (sign in / sign up) with optional
* challenge signing, enabling off-chain login without on-chain transactions.
*
* When a challenge is provided:
* 1. User authenticates (sign in or sign up) through the normal auth dialog
* 2. User signs the challenge through the normal signing dialog
* 3. Returns user info + signature for server-side verification
*
* This composes the same supported provider routes as calling
* `authWithModal()` followed by `signMessage()`, so challenge auth cannot
* drift onto a provider route that the passkey service does not expose.
*
* @example
* ```typescript
* const result = await client.authenticate({
* challenge: `Login to MyApp\nTimestamp: ${Date.now()}\nNonce: ${crypto.randomUUID()}`
* });
*
* if (result.success && result.challenge) {
* // Verify signature server-side
* const isValid = await verifyOnServer(
* result.user?.address,
* result.challenge.signature,
* result.challenge.signedHash
* );
* }
* ```
*/
authenticate(options?: AuthenticateOptions & {
theme?: ThemeConfig;
}): Promise;
/**
* Show signing in a modal overlay (iframe dialog)
*/
signWithModal(options: SigningRequestOptions & {
theme?: ThemeConfig;
}): Promise;
/**
* Send an intent to the Rhinestone orchestrator
*
* This is the high-level method for cross-chain transactions:
* 1. Prepares the intent (gets quote from orchestrator)
* 2. Shows the signing modal with real fees
* 3. Submits the signed intent for execution
* 4. Returns the transaction hash
*
* @example
* ```typescript
* const result = await client.sendIntent({
* accountAddress: '0x...',
* targetChain: 8453, // Base
* calls: [
* {
* to: '0x...',
* data: '0x...',
* label: 'Swap ETH for USDC',
* sublabel: '0.1 ETH → ~250 USDC',
* },
* ],
* });
*
* if (result.success) {
* console.log('Transaction hash:', result.transactionHash);
* }
* ```
*/
sendIntent(options: SendIntentOptions): Promise;
/**
* Send a batch of intents for multi-chain execution with a single passkey tap.
*
* This method prepares multiple intents, shows a paginated review,
* and signs all intents with a single passkey tap via a shared merkle tree.
*
* @example
* ```typescript
* const result = await client.sendBatchIntent({
* accountAddress: '0x...',
* intents: [
* {
* targetChain: 8453, // Base
* calls: [{ to: '0x...', data: '0x...', label: 'Swap on Base' }],
* },
* {
* targetChain: 42161, // Arbitrum
* calls: [{ to: '0x...', data: '0x...', label: 'Mint on Arbitrum' }],
* },
* ],
* });
*
* if (result.success) {
* console.log(`${result.successCount} intents submitted`);
* }
* ```
*/
sendBatchIntent(options: SendBatchIntentOptions): Promise;
/**
* Send transaction status to the dialog iframe
*/
private sendTransactionStatus;
/**
* Listen for a signing result that belongs to a specific `requestId`.
*
* Used by legacy server-side signing request flows (popup/embed/modal) where
* the dialog was pre-loaded with a signing request created via the API. The
* `requestId` filter is needed because multiple dialogs may be open or there
* may be stale messages from a previous dialog in the queue.
*
* Resolves on `PASSKEY_SIGNING_RESULT` matching `requestId`, or on
* `PASSKEY_CLOSE` (user dismissed the dialog).
*
* @param requestId - The signing request ID to match against incoming messages.
* @param dialog - The `