virgil-sdk
Version:
Virgil Security Services SDK
49 lines (48 loc) • 1.78 kB
TypeScript
/**
* Information about product for SDK usage statistic.
*/
export declare type IProductInfo = {
product: string;
version: string;
};
/**
* Interface to be implemented by objects capable of making HTTP requests.
* @hidden
*/
export interface IConnection {
get(endpoint: string, accessToken: string): Promise<Response>;
post(endpoint: string, accessToken: string, data?: object): Promise<Response>;
}
/**
* Class responsible for making HTTP requests.
* @hidden
*/
export declare class Connection implements IConnection {
private readonly prefix;
private virgilAgentValue;
/**
* Initializes a new instance of `Connection`.
* @param {string} prefix - `prefix` will be prepended to the `endpoint`
* argument of request methods.
* @param {VirgilAgentValue} [virgilAgentValue] - optional instance of VirgilAgent for products that wraps
* Virgil SDK
*/
constructor(prefix: string, info?: IProductInfo);
/**
* Issues a GET request against the `endpoint`.
* @param {string} endpoint - Endpoint URL relative to the `prefix`.
* @param {string} accessToken - Token to authenticate the request.
* @returns {Promise<Response>}
*/
get(endpoint: string, accessToken: string): Promise<Response>;
/**
* Issues a POST request against the `endpoint` sending the `data` as JSON.
* @param {string} endpoint - Endpoint URL relative to the `prefix`.
* @param {string} accessToken - Token to authenticate the request.
* @param {object} data - Response body.
* @returns {Promise<Response>}
*/
post(endpoint: string, accessToken: string, data?: object): Promise<Response>;
private send;
private createHeaders;
}