@cpanel/api
Version:
cPanel API JavaScript and TypeScript interface libraries. This library provides a set of classes for calling cPanel WHM API 1 and UAPI calls. The classes hide much of the complexity of these APIs behind classes the abstract the underlying variances betwee
81 lines (80 loc) • 2.18 kB
TypeScript
/**
* HTTP Header Abstraction
*/
export interface Header {
/**
* Name of the header
*/
name: string;
/**
* Value of the header
*/
value: string;
}
export type HeaderHash = {
[index: string]: string;
};
/**
* HTTP Headers Collection Abstraction
*
* The abstraction is an adapter to allow easy transformation of the headers array
* into various formats for external HTTP libraries.
*/
export declare class Headers {
private headers;
/**
* Create the adapter.
*
* @param headers - List of headers.
*/
constructor(headers?: Header[]);
/**
* Push a header into the collection.
*
* @param header - A header to add to the collection
*/
push(header: Header): void;
/**
* Iterator for the headers collection.
*
* @param fn - Transform for the forEach
* @param thisArg - Optional reference to `this` to apply to the transform function.
*/
forEach(fn: (v: Header, i: number, a: Header[]) => void, thisArg?: any): void;
/**
* Retrieve the headers as an array of Headers
*/
toArray(): Header[];
/**
* Retrieve the headers as an object
*/
toObject(): HeaderHash;
}
export declare class CustomHeader implements Header {
private _header;
constructor(_header: Header);
get name(): string;
get value(): string;
}
export declare class CpanelApiTokenInvalidError extends Error {
readonly name = "CpanelApiTokenInvalidError";
constructor(m: string);
}
export declare class CpanelApiTokenMismatchError extends Error {
readonly name = "CpanelApiTokenMismatchError";
constructor(m: string);
}
export declare class CpanelApiTokenHeader extends CustomHeader {
constructor(token: string, user?: string);
}
export declare class WhmApiTokenInvalidError extends Error {
readonly name = "WhmApiTokenInvalidError";
constructor(m: string);
}
export declare class WhmApiTokenMismatchError extends Error {
readonly name = "WhmApiTokenMismatchError";
constructor(m: string);
}
export declare class WhmApiTokenHeader extends CustomHeader {
constructor(token: string, user?: string);
}