@graphistry/js-upload-api
Version:
Graphistry upload client for reuse by node and browser clients
81 lines • 3.17 kB
TypeScript
export declare abstract class AbstractClient {
readonly protocol: string;
readonly host: string;
readonly clientProtocolHostname: string;
readonly agent: string;
readonly version?: string;
readonly org?: string;
protected _getAuthTokenPromise?: Promise<string>;
protected _token?: string;
protected fetch: any;
/**
* @param org The organization to use (optional)
* @param protocol The protocol to use for the server during uploads: 'http' or 'https'.
* @param host The hostname of the server during uploads: defaults to 'hub.graphistry.com'
* @param clientProtocolHostname Base path to use inside the browser and when sharing public URLs: defaults to '{protocol}://{host}'
* @param fetch The fetch implementation to use: defaults to JavaScript fetch function
* @param version The version of the client library
* @param agent The agent name to use when communicating with the server
*/
constructor(org?: string, protocol?: string, host?: string, clientProtocolHostname?: string, fetchFn?: any, version?: string, agent?: string);
/**
*
* See examples at top of file
*
* Set JWT token if already known
*
* @param token The token to use for authentication.
* @returns The client instance.
*/
setToken(token: string): this;
/**
*
* @returns Whether the current token is valid
*
*/
authTokenValid(): boolean;
/**
* @internal
* Internal helper
* @param uri The URI to upload to.
* @param payload The payload to upload.
* @param baseHeaders Optionally override base header object to mix with auth header for the upload.
* @returns The response from the server.
*/
post(uri: string, payload: any, baseHeaders?: any): Promise<any>;
static isConfigurationValid(userId: string, secret: string, host: string): boolean;
protected getToApi(url: string, headers: any, baseUrl?: string): Promise<any>;
protected postToApi(url: string, data: any, headers: any, baseUrl?: string): Promise<any>;
protected getBaseHeaders(): {
Accept: string;
'Content-Type': string;
};
protected getBaseUrl(): string;
private getSecureHeaders;
abstract isServerConfigured(): boolean;
abstract checkStale(username: string, password: string, protocol: string, host: string, clientProtocolHostname?: string): boolean;
/**
* Get the authentication token for the current user.
* By default, reuses current token if available.
*
* @param force If true, forces a new token to be generated; defaults to false
*
* @returns The authentication token
*
*/
protected abstract getAuthToken(): Promise<string>;
/**
*
* @param userId
* @param secret
* @param org
* @param protocol
* @param host
* @returns Promise for the authentication token
*
* Helper to fetch a token for a given user
*
*/
abstract fetchToken(userId: string, secret: string, org?: string, protocol?: string, host?: string): Promise<string>;
}
//# sourceMappingURL=AbstractClient.d.ts.map