Implements

Constructors

Properties

applicationId: string

The application ID to use for authenticating with the CFTools API, obtained here.

applicationSecret: string

The application secret to use for authenticating with the CFTools API, obtained here. This should be kept secret and not shared.

authenticated: boolean = false

Whether the client is currently authenticated.

authenticationToken: null | string = null

The authentication token to use for making requests.

enterpriseToken?: string

The enterprise token to use for authenticating with the CFTools API, privately obtained from the CFTools team.

expiresAt: null | Date = null

The date and time the authentication token expires.

issuedAt: null | Date = null

The date and time the authentication token was issued.

refreshTimeout: null | Timeout = null

The timeout for refreshing the authentication token.

serverApiId?: string

The default server API ID to use for actions, can be overridden in requests.

userAgent: string

The user agent to use for making requests.

Methods

  • Returns {
        application_id: string;
        secret: string;
    }

    The body required for authenticating with the CFTools API.

    • application_id: string
    • secret: string
  • Returns the headers required for making requests to the CFTools API.

    Parameters

    • isAuthenticating: boolean = false

      Whether the headers are for an authentication request.

    Returns AuthHeaders

    The headers required for making requests to the CFTools API.

    Thrown if the client is not authenticated.

  • Returns boolean

    Whether the authentication token has expired.

  • Returns boolean

    Whether the authentication token is currently refreshing.

  • Refreshes the authentication token.

    Returns Promise<void>

    A promise that resolves when the authentication token has been refreshed.

    Thrown if the authentication token has expired.

    Thrown if the client is not authenticated.

    Thrown if the server API ID is required but missing.

    Thrown if the authentication token could not be refreshed.

  • Resolves the server API ID to use for an action.

    Parameters

    • OptionalserverApiId: string

      The server API ID to use.

    • Optionalrequire: false

      Whether the server API ID is required or not.

    Returns null | string

    The resolved server API ID.

    Thrown if the server API ID is required but missing.

  • Parameters

    • OptionalserverApiId: string
    • Optionalrequire: true

    Returns string

  • Sets the authentication token refreshing state.

    Parameters

    • refreshing: boolean

      Whether the authentication token is refreshing.

    Returns void

  • Returns boolean

    Whether the authentication token should be refreshed.

  • Throws an error if the authentication token has expired.

    Returns void

    Thrown if the authentication token has expired.