import type { EnvInterface } from "."; import { CubeSignerClient } from "."; import type { MfaReceipt } from "./mfa"; import type { AcceptedResponse, NewSessionResponse } from "./schema_types"; /** * Response type, which can be either a value of type {@link U} * or {@link AcceptedResponse} (status code 202) which requires MFA. */ export type Response = U | AcceptedResponse; /** * Request function which optionally takes additional headers * (which, for example, can be used to attach an MFA receipt). */ export type RequestFn = (headers?: HeadersInit) => Promise>; /** * Map function occasionally used to map a response from the API into a higher-level type. */ export type MapFn = (u: U) => V; /** * Take a {@link Response} and a {@link MapFn} function and return * a {@link Response} that maps the value of the original response when its status code is 200. * * @param {Response} resp Original response * @param {Map} mapFn Map to apply to the response value when its status code is 200. * @return {Response} Response whose value for status code 200 is mapped from U to V */ export declare function mapResponse(resp: Response, mapFn: MapFn): Response; export interface MfaRequired { /** Org id */ org_id: string; /** MFA request id */ id: string; /** Optional MFA session */ session?: NewSessionResponse | null; } /** * A response of a CubeSigner request. */ export declare class CubeSignerResponse { #private; /** @return {string} The MFA id associated with this request (if any) */ mfaId(): string; /** @return {boolean} True if this request requires an MFA approval */ requiresMfa(): boolean; /** * Return session information to use for any MFA approval requests (if any was included in the response). * @return {Promise} */ mfaClient(): Promise; /** @return {U} The response data, if no MFA is required */ data(): U; /** * Approve the MFA request using a given session and a TOTP code. * * @param {CubeSignerClient} client CubeSigner whose session to use * @param {string} code 6-digit TOTP code * @return {CubeSignerResponse} The result of resubmitting the request with the approval */ totpApprove(client: CubeSignerClient, code: string): Promise>; /** * Reject the MFA request using a given session and a TOTP code. * * @param {CubeSignerClient} client CubeSigner whose session to use * @param {string} code 6-digit TOTP code */ totpReject(client: CubeSignerClient, code: string): Promise; /** * Approve the MFA request using a given {@link CubeSignerClient} instance (i.e., its session). * * @param {CubeSignerClient} client CubeSigner whose session to use * @return {CubeSignerResponse} The result of resubmitting the request with the approval */ approve(client: CubeSignerClient): Promise>; /** * Reject the MFA request using a given {@link CubeSignerClient} instance (i.e., its session). * * @param {CubeSignerClient} client CubeSigner whose session to use */ reject(client: CubeSignerClient): Promise; /** * Resubmits the request with a given MFA receipt attached. * * @param {MfaReceipt} mfaReceipt The MFA receipt * @return {Promise>} The result of signing after MFA approval */ execWithMfaApproval(mfaReceipt: MfaReceipt): Promise>; /** * Constructor. * @param {EnvInterface} env The environment where the response comes from * @param {RequestFn} requestFn * The function that this response is from. * This argument is used to resend requests with different headers if needed. * @param {U | AcceptedResponse} resp The response as returned by the OpenAPI client. * @internal */ protected constructor(env: EnvInterface, requestFn: RequestFn, resp: U | AcceptedResponse); /** * Static constructor. * @param {EnvInterface} env The environment where the response comes from * @param {RequestFn} requestFn * The request function that this response is from. * This argument is used to resend requests with different headers if needed. * @param {MfaReceipt} mfaReceipt Optional MFA receipt * @return {Promise>} New instance of this class. * @internal */ static create(env: EnvInterface, requestFn: RequestFn, mfaReceipt?: MfaReceipt): Promise>; /** * Return HTTP headers containing a given MFA receipt. * * @param {MfaReceipt} mfaReceipt MFA receipt * @return {HeadersInit} Headers including that receipt * @internal */ static getMfaHeaders(mfaReceipt?: MfaReceipt): HeadersInit | undefined; }