import type { EnvInterface, NewSessionResponse, SessionManager, SessionMetadata, SessionData } from ".."; import { ErrResponse } from ".."; import type { FetchResponseSuccessData, Op, Operation, SimpleOptions } from "../fetch"; import { EventEmitter } from "../events"; export type ErrorEvent = ErrResponse; /** Event emitted when a request fails because of an expired/invalid session */ export declare class SessionExpiredEvent { } /** Event emitted when a request fails because user failed to answer an MFA challenge */ export declare class UserMfaFailedEvent extends ErrResponse { } type ClientEvents = { "user-mfa-failed": (ev: UserMfaFailedEvent) => void; "session-expired": (ev: SessionExpiredEvent) => void; error: (ev: ErrorEvent) => void; }; type StaticClientSubclass = { new (...args: ConstructorParameters): T; } & typeof BaseClient; /** * An event emitter for all clients * @deprecated */ export declare const ALL_EVENTS: EventEmitter; /** * Implements a retry strategy and session refreshes */ export declare class BaseClient extends EventEmitter { #private; /** Information about the session contained within the client */ sessionMeta: SessionMetadata; /** MUTABLE configuration */ config: { updateRetryDelaysMs: number[]; }; /** Get the env */ get env(): EnvInterface; /** * Construct a client with a session or session manager * @param {StaticClientSubclass} this Allows this static method to return subtypes when invoked through them * @param {SessionManager | SessionData | string} session The session (object or base64 string) or manager that will back this client * @return {T} A Client */ static create(this: StaticClientSubclass, session: string | SessionManager | SessionData): Promise; /** * @param {SessionMetadata} [sessionMeta] The initial session metadata * @param {SessionManager} [manager] The manager for the current session * * @internal */ constructor(sessionMeta: SessionMetadata, manager: SessionManager); /** The organization ID */ get orgId(): string; /** * Executes an op using the state of the client (auth headers & org_id) with retries * * @param {Op} op The API operation you wish to perform * @param {SimpleOptions} opts The parameters for the operation * @return {FetchResponseSuccessData} A promise for the successful result (errors will be thrown) */ exec(op: Op, opts: OmitAutoParams>): Promise>; } /** * Upgrade a session response into a full SessionData by incorporating * elements of an existing SessionData * @param {SessionData} meta An existing SessionData * @param {NewSessionResponse} info A new session created via the API * @param {object} ctx Additional manual overrides * @return {SessionData} */ export declare function signerSessionFromSessionInfo(meta: SessionMetadata, info: NewSessionResponse, ctx: Partial<{ purpose: string; role_id: string; }>): SessionData; type DeepOmit = [A, B] extends [object, object] ? { [K in keyof A as K extends keyof B ? A[K] extends B[K] ? K : never : never]?: K extends keyof B ? DeepOmit : never; } & { [K in keyof A as K extends keyof B ? (B[K] extends A[K] ? never : K) : K]: K extends keyof B ? DeepOmit : A[K]; } : A; export type OmitAutoParams = DeepOmit & { params?: { path?: Record; }; }; export {};