/** * HTTP Client for Hawcx Auth Protocol v2 * * Single endpoint: POST /auth * All actions go through sendAction(). */ import { type Result } from "neverthrow"; import { type AuthError } from "./errors"; import { type Action, type WireResponse } from "./protocol"; import { type Logger } from "./types"; export interface HttpClientConfig { apiBase: string; configId: string; logger?: Logger; /** Request timeout in milliseconds (default: 10000) */ timeout?: number; /** Custom fetch implementation for testing */ fetch?: typeof fetch; } /** * Throw unless `apiBase` is an https URL, or an http URL whose host is * exactly a loopback name (TOB-HSDK-13). * * Parsed with the URL API rather than string prefixes: a prefix check lets * "http://localhost.attacker.com" (a different host) or * "http://localhost@attacker.com" (userinfo "localhost", host attacker.com) * through over cleartext. URLs carrying credentials are rejected outright. */ export declare function assertSecureApiBase(apiBase: string): void; /** * HTTP client for Protocol v2. * Handles retries, timeouts, and error mapping. */ export declare class HttpClient { private readonly config; private readonly api; private readonly logger; constructor(config: HttpClientConfig); /** * Send a Protocol v2 action to the /auth endpoint. */ sendAction(action: Action, session?: string, signal?: AbortSignal): Promise>; /** * "Sign out everywhere": kill ALL of the caller's live sessions (incl. the * current one) + OIDC back-channel logout, WITHOUT de-enrolling any device. * Devices stay trusted, so the next sign-in is silent (no OTP re-enroll). * Authenticated with the caller's hx_auth session token (Bearer). The * tenant + protocol-version headers ride along from the shared config. */ logoutEverywhere(bearerToken: string, signal?: AbortSignal): Promise>; /** * Transform SDK-friendly action field names to wire protocol names. * Keeps the developer API clean while matching backend expectations. */ private transformAction; /** * Transform wire protocol response to SDK-friendly format. * Maps method.id -> method.name for cleaner developer API. */ private transformResponse; private mapNetworkError; private mapHttpError; private extractErrorDetails; }