UNPKG

accounts

Version:

Tempo Accounts SDK

59 lines 2.87 kB
import { DeviceCode } from 'wata'; import type * as Adapter from '../../Adapter.js'; import type * as Keystore from '../../Keystore.js'; import { fromRequest } from '../internal/fromRequest.js'; /** * Creates a device-code adapter that forwards wallet RPC through Wata. * * Each request runs one OAuth 2.0 Device Authorization Grant exchange * (RFC 8628 with PKCE): the host issues a user code surfaced via * `onPrompt`, the user approves on the host's verification page, and the * adapter polls until the response arrives. */ export declare function deviceCode(options: deviceCode.Options): Adapter.Adapter; export declare namespace deviceCode { /** Options for {@link deviceCode}. */ type Options = { /** Adapter-specific action overrides layered over the request-forwarding defaults. */ actions?: fromRequest.Options['actions'] | undefined; /** Override the transport `fetch` implementation. */ fetch?: typeof globalThis.fetch | undefined; /** Data URI of the provider icon, announced via EIP-6963. */ icon?: Adapter.Meta['icon'] | undefined; /** Keystores backing locally generated access keys (SDK default otherwise). */ keystores?: Keystore.Keystores | undefined; /** Consumer metadata shown on the host's approval page. */ meta?: { name: string; description?: string | undefined; icon?: string | undefined; websiteUrl?: string | undefined; } | undefined; /** Allowlist of RPC methods forwarded over the transport. Forwards all when omitted. */ methods?: readonly string[] | undefined; /** Provider display name. */ name: string; /** Surfaces the pairing prompt (user code + verification URL) to the user. */ onPrompt: (prompt: DeviceCode.Prompt) => Promise<void> | void; /** Poll cadence override in milliseconds. Defaults to the host-advertised interval. */ pollingInterval?: number | undefined; /** Reverse-DNS provider identifier. */ rdns: string; /** Overall wait for user approval in milliseconds. @default 300000 */ timeout?: number | undefined; /** Base URL of the host's device-code endpoints (derives `/register` and `/token`). */ url: string; }; } /** Thrown when the `onPrompt` callback fails (e.g. no browser could be opened). */ export declare class PromptError extends Error { cause?: unknown | undefined; prompt: DeviceCode.Prompt; constructor(prompt: DeviceCode.Prompt, cause?: unknown); } /** Thrown when the user did not approve within {@link deviceCode.Options.timeout}. */ export declare class TimeoutError extends Error { prompt: DeviceCode.Prompt | undefined; constructor(prompt: DeviceCode.Prompt | undefined); } //# sourceMappingURL=deviceCode.d.ts.map