UNPKG

@graphistry/js-upload-api

Version:

Graphistry upload client for reuse by node and browser clients

115 lines 4 kB
import { AbstractClient } from './AbstractClient.js'; /** * # Client examples * * Authenticate against a Graphistry server using a personal key id and secret, and manage communications with it. * * Different authentication modes may be desirable depending on the type of Graphistry server. * * <br> * * --- * * <br> * * @example **Authenticate against Graphistry Hub for a personal account** * ```javascript * import { Client } from '@graphistry/node-api'; * const client = new Client('my_personal_key_id', 'my_personal_key_secret'); * ``` * * <br> * * @example **Authenticate against an org in Graphistry Hub** * ```javascript * import { Client } from '@graphistry/node-api'; * const client = new Client('my_personal_key_id', 'my_personal_key_secret', 'my_org'); * ``` * * <br> * * @example **Authenticate against a private Graphistry server** * ```javascript * import { Client } from '@graphistry/node-api'; * const client = new Client('my_personal_key_id', 'my_personal_key_secret', '', 'http', 'my-ec2.aws.com:8080'); * ``` * * <br> * * @example **Upload via internal IP but publish urls via a public domain** * ```javascript * import { Client } from '@graphistry/node-api'; * const client = new Client( * 'my_personal_key_id', 'my_personal_key_secret', '', * 'http', '10.20.0.1:8080', * 'https://www.my-site.com' * ); * ``` * * <br> * * @example **Upload through the local docker network but publish urls via a public domain** * ```javascript * import { Client } from '@graphistry/node-api'; * const client = new Client( * 'my_personal_key_id', 'my_personal_key_secret', '', * 'http', 'nginx', * 'https://www.my-site.com' * ); * ``` * * <br> * * @example **Create a client with an externally-provided JWT token** * ```javascript * import { Client } from '@graphistry/node-api'; * const client = new Client(); * client.setToken('Bearer 123abc'); * ``` */ export declare class ClientPKey extends AbstractClient { readonly personalKeyId: string; private _personalKeySecret; /** * * See examples at top of file * * @param personalKeyId The personal key id to authenticate with. * @param personalKeySecret The personal key secret to authenticate with. * @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 * @param version The version of the client library * @param agent The agent name to use when communicating with the server */ constructor(personalKeyId: string, personalKeySecret: string, org?: string, protocol?: string, host?: string, clientProtocolHostname?: string, fetch?: any, version?: string, agent?: string); isServerConfigured(): boolean; checkStale(personalKeyId: string, personalKeySecret: string, protocol: string, host: string, clientProtocolHostname?: string): boolean; private getPKeyString; /** * 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 getAuthToken(force?: boolean): Promise<string>; /** * * @param personalKeyId * @param personalKeySecret * @param org * @param protocol * @param host * @returns Promise for the authentication token * * Helper to fetch a token for a given user * */ fetchToken(personalKeyId: string, personalKeySecret: string, org?: string, protocol?: string, host?: string): Promise<string>; } //# sourceMappingURL=ClientPKey.d.ts.map