import { type HostRequestLoginResponse } from "@parity/truapi"; /** * How the test host answers a product's login request while signed out. * `"success"` signs an account in and answers `Success`. `"reject"` answers * `Rejected`, as a user dismissing the login would. */ export type LoginRequestBehavior = "success" | "reject"; /** * The request id of a `V1` login request, or `undefined` for any other frame. * * Only the version this host can answer is claimed. A later version falls * through to the core, which knows it, rather than being misread here. */ export declare function loginRequestId(frame: Uint8Array): string | undefined; /** The request id a login request's withdrawal names, or `undefined`. */ export declare function loginCancelId(frame: Uint8Array): string | undefined; /** * The frame answering the login request `requestId`: `response`, or the * `Cancelled` call error the core answers a withdrawn call with. */ export declare function loginResponse(requestId: string, response: HostRequestLoginResponse | "Cancelled"): Uint8Array; /** What the login answerer needs from the host page. */ export interface LoginRequestHost { /** Whether a session is active. */ signedIn(): boolean; /** Names of the accounts the host can sign in as, in order. */ accounts(): string[]; /** Activate a session as `account`. */ signIn(account: string): Promise; } /** Answers login requests on behalf of the host page. */ export interface LoginRequests { /** Answer requests made while signed out with `behavior` from now on. */ set(behavior: LoginRequestBehavior, account?: string): void; /** Leave login requests to the core again. */ clear(): void; /** * Answer `frame` when it is a login request, or the withdrawal of one, that * this host is answering, and report whether it did. Anything else goes on * to the core. */ handle(frame: Uint8Array, reply: (frame: Uint8Array) => void): boolean; /** * Resolves once a sign-in started for a login request has finished, so a * test changing the session afterwards does not race it. */ settled(): Promise; } /** Build the login answerer for one host page. */ export declare function createLoginRequests(host: LoginRequestHost): LoginRequests;