import type { FetchResponseSuccessData, Op, Operation, SimpleOptions } from "../fetch.ts"; import { EventEmitter } from "../events.ts"; import { ErrResponse } from "../error.ts"; import type { SessionData, SessionManager, SessionMetadata } from "./session.ts"; import type { NewSessionResponse } from "../schema_types.ts"; import type { EnvInterface } from "../env.ts"; /** CubeSigner SDK package name */ export declare const NAME: string; /** CubeSigner SDK version */ export declare const VERSION: string; 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; /** * Client configuration options. */ export interface ClientConfig { /** Update retry delays (in milliseconds) */ updateRetryDelaysMs: number[]; /** Custom origin to set (NOTE that if running in a browser, the browser will overwrite this) */ origin?: string; /** Additional headers to set (default to empty) */ headers: HeadersInit; } /** * Implements a retry strategy and session refreshes */ export declare class BaseClient extends EventEmitter { #private; /** Information about the session contained within the client */ sessionMeta: SessionMetadata; /** Session persistence */ protected sessionManager: SessionManager; /** MUTABLE configuration. */ readonly config: ClientConfig; /** @returns The env */ get env(): EnvInterface; /** @returns All available regional environments */ get envs(): EnvInterface[]; /** * Construct a client with a session or session manager * * @param this Allows this static method to return subtypes when invoked through them * @param session The session (object or base64 string) or manager that will back this client * @param targetOrgId The ID of the organization this client should operate on. Defaults to * the org id from the supplied session. The only scenario in which it makes sense to use * a {@link targetOrgId} different from the session org id is if {@link targetOrgId} is a * child organization of the session organization. * @returns A Client */ static create(this: StaticClientSubclass, session: string | SessionManager | SessionData, targetOrgId?: string): Promise; /** * @param sessionMeta The initial session metadata * @param manager The manager for the current session * @param targetOrgId The ID of the organization this client should operate on. Defaults to * the org id from the supplied session. The only scenario in which it makes sense to use * a {@link targetOrgId} different from the session org id is if {@link targetOrgId} is a * child organization of the session organization. * @param config Client configuration * * @internal */ constructor(sessionMeta: SessionMetadata, manager: SessionManager, targetOrgId?: string, config?: ClientConfig & { preferredEnv?: EnvInterface; }); /** @returns The organization ID. If the org ID was set explicitly, it returns that ID; otherwise it returns the session's organization ID. */ get orgId(): string; /** * Executes an op using the state of the client (auth headers & org_id) with retries * * @internal * @param op The API operation you wish to perform * @param opts The parameters for the operation * @returns 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 meta An existing SessionData * @param info A new session created via the API * @param ctx Additional manual overrides * @returns SessionData with new information from info and ctx */ export declare function signerSessionFromSessionInfo(meta: SessionMetadata, info: NewSessionResponse, ctx: Partial<{ purpose: string; role_id: string; org_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; }; }; /** * Creates {@link HeadersInit} containing a single "Authorization" header with a given value. * * @param token The "Authorization" header value * @returns A {@link HeadersInit} object containing a single "Authorization" header with a given value. */ export declare function authHeader(token: string): HeadersInit; export {}; //# sourceMappingURL=base_client.d.ts.map