UNPKG

accounts

Version:

Tempo Accounts SDK

60 lines 2.45 kB
import { type DeviceCode, Store } from 'wata/host'; import { type Handler, from } from '../../Handler.js'; type PendingRequest = { context?: { account?: string | undefined; chainId?: number | undefined; } | undefined; id: string | number; method: string; params?: unknown; }; /** * Instantiates a Wata device-code handler for wallet RPC requests. * * The handler implements the OAuth 2.0 Device Authorization Grant endpoints, * accepts browser-submitted RPC results, and returns them to the polling * consumer. The consuming host is responsible for deciding which methods * its approval UI supports. * * @param options - Options. * @returns Request handler. */ export declare function deviceCode(options: deviceCode.Options): Handler; export declare namespace deviceCode { /** Options for {@link deviceCode}. */ type Options = from.Options & { /** Public host origin or a request-based origin resolver. */ baseUrl?: string | ((request: Request) => string) | undefined; /** Authorization intent lifetime in seconds. @default 600 */ expiresIn?: number | undefined; /** Discovery fetch implementation. */ fetch?: typeof globalThis.fetch | undefined; /** Approval page hooks. */ html: { /** Renders or redirects the approval page. */ render: DeviceCode.html.Hooks['render']; }; /** Maximum approval request body size in bytes. @default 65536 */ maxBodyBytes?: number | undefined; /** Device-code endpoint path. @default "/auth/device" */ path?: string | undefined; /** Suggested polling interval in milliseconds. */ pollingInterval?: number | undefined; /** Device-code persistence. @default in-memory */ store?: Store.Store | undefined; /** Host policy applied before an approved result is relayed to the consumer. */ validate: (options: { /** Pending device-code record. */ record: DeviceCode.PendingRecord; /** Pending JSON-RPC request matched to the submitted result. */ request: PendingRequest; /** Browser-submitted result. */ result: unknown; /** Normalized raw user code. */ userCode: string; }) => Promise<Response | undefined> | Response | undefined; }; } export {}; //# sourceMappingURL=deviceCode.d.ts.map