/** * React hook for the browser side of the direct Data Portability flow. * * @remarks * `useDirectVanaConnect` is a thin `useSyncExternalStore` binding over the * framework-agnostic {@link createDirectConnectFlow} store. The browser never * sees the app private key and never chooses scopes — it only calls the app's * own backend routes via the injected transports. * * This module is browser-safe and imports nothing Node-only. `react` is a peer * dependency. * * @category Direct * @module direct/use-direct-vana-connect */ import { type DirectConnectOptions, type DirectConnectRetryOutcome, type DirectConnectState, type DirectConnectTransports } from "./connect-flow.js"; /** Options for {@link useDirectVanaConnect}: transports plus flow tunables. */ export type UseDirectVanaConnectOptions = DirectConnectTransports & DirectConnectOptions; /** Return value of {@link useDirectVanaConnect}. */ export interface UseDirectVanaConnectResult { /** Current flow state (`state.type` is `"idle"` until `start()` is called). */ state: DirectConnectState; /** Begin the connect flow (create request, open Vana, poll, read). */ start: () => void; /** Retry the read and report whether prior consent could be reused. */ retryRead: () => Promise; /** Reset back to `idle` and cancel any in-flight polling. */ reset: () => void; } /** * Drive the two-tab connect flow from a React component. * * @param options - The `createRequest`/`getStatus`/`readResult` transports plus * optional polling/timeout tunables. * @returns `{ state, start, reset }`. * * @example * ```tsx * const connect = useDirectVanaConnect({ * createRequest: () => fetch("/api/vana/request", { method: "POST" }).then((r) => r.json()), * getStatus: (id) => fetch(`/api/vana/status?requestId=${id}`).then((r) => r.json()), * readResult: (id) => fetch(`/api/vana/data?requestId=${id}`).then((r) => r.json()), * }); * return ; * ``` */ export declare function useDirectVanaConnect(options: UseDirectVanaConnectOptions): UseDirectVanaConnectResult;