Class VerdocsEndpoint

VerdocsEndpoint is a class wrapper for a specific connection and authorization context for calling the Verdocs APIs. Endpoints can be used for isolated session tasks.

For instance, ephemeral signing sessions may be created independently of a caller's status as an authenticated user. In that case, an Endpoint can be created and authenticated, used for calls related to signing operations, then discarded once signing is complete.

Note that endpoint configuration functions return the instance, so they can be chained, e.g.

import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';

const endpoint = new VerdocsEndpoint();
endpoint
.setSessionType('signing')
.logRequests(true)
.setClientID('1234)
.setTimeout(30000);

Constructors

Properties

api: AxiosInstance
session: TSession = ...

The current user session, or null if not authenticated. May be either a User or Signing session. If set, the presence of the document_id field can be used to differentiate the types. Only signing sessions are associated with Envelopes.

Methods

  • Retrieves the current session token, if any. Tokens should rarely be used for direct actions, but this is required by the <VerdocsView> and other components to authorize requests to raw PDF files.

    Returns null | string

  • Enable or disable request logging. This may expose sensitive data in the console log, so it should only be used for debugging.

    import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';

    const endpoint = new VerdocsEndpoint();
    endpoint.logRequests(true);

    Parameters

    • enable: boolean

    Returns VerdocsEndpoint

  • Set the base URL for API calls. Should be called only upon direction from Verdocs Customer Solutions Engineering.

    import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';

    const endpoint = new VerdocsEndpoint();
    endpoint.setBaseURL('https://api.verdocs.com');

    Parameters

    • url: string

    Returns VerdocsEndpoint

  • Set the Client ID for Verdocs API calls.

    import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';

    const endpoint = new VerdocsEndpoint();
    endpoint.setClientID('1234);

    Parameters

    • clientID: string

    Returns VerdocsEndpoint

  • Set the operating environment. This should rarely be anything other than 'verdocs'.

    import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';

    const endpoint = new VerdocsEndpoint();
    endpoint.setEnvironment('verdocs-stage');

    Parameters

    Returns VerdocsEndpoint

  • Set the session type. In general this should be done immediately when the endpoint is created. Changing the session type may be done at any time, but may have unintended consequences if the endpoint is shared between multiple widgets.

    Changing the session type will clear/reload the action session. This may trigger notifications to session state observers. Apps that use observers to trigger UI updates such as logging the user out should be prepared to handle this event.

    import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';

    const endpoint = new VerdocsEndpoint();
    endpoint.setEnvironment('verdocs-stage');

    Parameters

    Returns VerdocsEndpoint

  • Set the timeout for API calls in milliseconds. 5000-20000ms is recommended for most purposes. 15000ms is the default. Note that some calls may involve rendering operations that require some time to complete, so very short timeouts are not recommended.

    import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';

    const endpoint = new VerdocsEndpoint();
    endpoint.setTimeout(3000);

    Parameters

    • timeout: number

    Returns VerdocsEndpoint

  • Set the authorization token that will be used for Verdocs API calls. This will also set the session metadata and notify any listeners of the new data.

    If this Endpoint will be used for non-default purposes (e.g. signing, or in an alternate environment) those settings should be made before calling this. Sessions are persisted to localStorage, and the environment and type become part of the storage key.

    import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';

    const endpoint = new VerdocsEndpoint();
    endpoint.setToken(accessToken);

    Parameters

    • token: null | string

    Returns VerdocsEndpoint