Class SessionBuilder

The builder for an ngrok session.

Hierarchy

  • SessionBuilder

Constructors

Methods

  • Configures the TLS certificate used to connect to the ngrok service while establishing the session. Use this option only if you are connecting through a man-in-the-middle or deep packet inspection proxy. Pass in the bytes of the certificate to be used to validate the connection, then override the address to connect to via the server_addr call.

    Roughly corresponds to the root_cas parameter in the ngrok docs.

    Parameters

    • certBytes: Uint8Array

    Returns SessionBuilder

  • Add client type and version information for a client application.

    This is a way for applications and library consumers of this crate identify themselves.

    This will add a new entry to the User-Agent field in the "most significant" (first) position. Comments must follow RFC 7230 or a connection error may occur.

    Parameters

    • clientType: string
    • version: string
    • Optional comments: null | string

    Returns SessionBuilder

  • Attempt to establish an ngrok session using the current configuration.

    Returns Promise<Session>

  • Configures a function which is called to after a disconnection to the ngrok service. In the event of network disruptions, it will be called each time the session reconnects. The handler is given the address that will be used to connect the session to, e.g. "example.com:443", and the message from the error that occurred. Returning true from the handler will cause the session to reconnect, returning false will cause the Session to throw an uncaught error.

    Parameters

    • handler: ((addr, error) => boolean)
        • (addr, error): boolean
        • Parameters

          • addr: string
          • error: string

          Returns boolean

    Returns SessionBuilder

  • Call the provided handler whenever a heartbeat response is received, with the latency in milliseconds.

    If the handler returns an error, the heartbeat task will exit, resulting in the session eventually dying as well.

    Parameters

    • handler: ((latency) => void)
        • (latency): void
        • Parameters

          • latency: number

          Returns void

    Returns SessionBuilder

  • Configures a function which is called when the ngrok service requests that this [Session] updates. Your application may choose to interpret this callback as a request to restart the [Session] or the entire process.

    Errors returned by this function will be visible to the ngrok dashboard or API as the response to the Restart operation.

    Do not block inside this callback. It will cause the Dashboard or API stop operation to time out. Do not call [std::process::exit] inside this callback, it will also cause the operation to time out.

    Parameters

    • handler: (() => void)
        • (): void
        • Returns void

    Returns SessionBuilder

  • Configures a function which is called when the ngrok service requests that this [Session] stops. Your application may choose to interpret this callback as a request to terminate the [Session] or the entire process.

    Errors returned by this function will be visible to the ngrok dashboard or API as the response to the Stop operation.

    Do not block inside this callback. It will cause the Dashboard or API stop operation to time out. Do not call [std::process::exit] inside this callback, it will also cause the operation to time out.

    Parameters

    • handler: (() => void)
        • (): void
        • Returns void

    Returns SessionBuilder

  • Configures a function which is called when the ngrok service requests that this [Session] updates. Your application may choose to interpret this callback as a request to update its configuration, itself, or to invoke some other application-specific behavior.

    Errors returned by this function will be visible to the ngrok dashboard or API as the response to the Restart operation.

    Do not block inside this callback. It will cause the Dashboard or API stop operation to time out. Do not call [std::process::exit] inside this callback, it will also cause the operation to time out.

    Parameters

    • handler: ((update) => void)

    Returns SessionBuilder

  • Configures the opaque, machine-readable metadata string for this session. Metadata is made available to you in the ngrok dashboard and the Agents API resource. It is a useful way to allow you to uniquely identify sessions. We suggest encoding the value in a structured format like JSON.

    See the metdata parameter in the ngrok docs for additional details.

    Parameters

    • metadata: string

    Returns SessionBuilder

Generated using TypeDoc