import superagent from 'superagent'; import { BitGoRequest } from '@bitgo/sdk-core'; import { AuthVersion, VerifyResponseOptions } from './types'; import { BitGoAPI } from './bitgoAPI'; /** * Add the bitgo-specific result() function on a superagent request. * * If the server response is successful, the `result()` function will return either the entire response body, * or the field from the response body specified by the `optionalField` parameter if it is provided. * * If the server response with an error, `result()` will handle HTTP errors appropriately by * rethrowing them as an `ApiResponseError` if possible, and otherwise rethrowing the underlying response error. * * @param req */ export declare function toBitgoRequest(req: superagent.SuperAgentRequest): BitGoRequest; /** * Return a function which extracts the specified response body property from the response if successful, * otherwise throw an `ApiErrorResponse` parsed from the response body. * @param optionalField */ export declare function handleResponseResult(optionalField?: string): (res: superagent.Response) => ResponseResultType; /** * Handle an error or an error containing an HTTP response and use it to throw a well-formed error object. * * @param e */ export declare function handleResponseError(e: Error & { response?: superagent.Response; }): never; /** * Serialize request data based on the request content type. * If data is already a string, returns it as-is to preserve exact bytes for HMAC. * If data is a Buffer, converts to UTF-8 string. * If data is an object, serializes it based on Content-Type. * @param req */ export declare function serializeRequestData(req: superagent.Request): string | undefined; /** * Set the superagent query string correctly for browsers or node. * @param req */ export declare function setRequestQueryString(req: superagent.SuperAgentRequest): void; /** * Verify that the response received from the server is signed correctly. * Right now, it is very permissive with the timestamp variance. */ export declare function verifyResponse(bitgo: BitGoAPI, token: string | undefined, method: VerifyResponseOptions['method'], req: superagent.SuperAgentRequest, response: superagent.Response, authVersion: AuthVersion): superagent.Response; export declare function verifyResponseAsync(bitgo: BitGoAPI, token: string | undefined, method: VerifyResponseOptions['method'], req: superagent.SuperAgentRequest, response: superagent.Response, authVersion: AuthVersion): Promise; //# sourceMappingURL=api.d.ts.map