Options
All
  • Public
  • Public/Protected
  • All
Menu

Authenticate against a Graphistry server and manage communications with it.

Different authentication modes may be desirable depending on the type of Graphistry server.




example

Authenticate against Graphistry Hub

import { Client } from '@graphistry/node-api';
const client = new Client('my_username', 'my_password');

example

Authenticate against a private Graphistry server

import { Client } from '@graphistry/node-api';
const client = new Client('my_username', 'my_password', 'http', 'my-ec2.aws.com:8080');

example

Upload via internal IP but publish urls via a public domain

import { Client } from '@graphistry/node-api';
const client = new Client(
'my_username', 'my_password',
'http', '10.20.0.1:8080',
'https://www.my-site.com'
);

example

Upload through the local docker network but publish urls via a public domain

import { Client } from '@graphistry/node-api';
const client = new Client(
'my_username', 'my_password',
'http', 'nginx',
'https://www.my-site.com'
);

Hierarchy

  • Client

Index

Properties

clientProtocolHostname: string
host: string
protocol: string
username: string
_password: string
_token?: string

Constructors

  • new Client(username: string, password: string, protocol?: string, host?: string, clientProtocolHostname?: string): Client
  • Parameters

    • username: string

      The username to authenticate with.

    • password: string

      The password to authenticate with.

    • protocol: string = 'https'

      The protocol to use for the server during uploads: 'http' or 'https'.

    • host: string = 'hub.graphistry.com'

      The hostname of the server during uploads: defaults to 'hub.graphistry.com'

    • Optional clientProtocolHostname: string

      Base path to use inside the browser and when sharing public URLs: defaults to '{protocol}://{host}'

    Returns Client

Methods

  • post(uri: string, payload: any): Promise<any>
  • internal

    Internal helper

    Parameters

    • uri: string

      The URI to upload to.

    • payload: any

      The payload to upload.

    Returns Promise<any>

    The response from the server.

  • authTokenValid(): boolean
  • getAuthToken(force?: boolean): Promise<string>
  • Get the authentication token for the current user. By default, reuses current token if available.

    Parameters

    • force: boolean = false

      If true, forces a new token to be generated; defaults to false

    Returns Promise<string>

    The authentication token

  • getBaseHeaders(): Headers
  • getBaseUrl(): string
  • getSecureHeaders(): Promise<Headers>
  • postToApi(url: string, data: any, headers: Headers): Promise<any>
  • Parameters

    • url: string
    • data: any
    • headers: Headers

    Returns Promise<any>