Provides access to Pusher's REST API, WebHooks and authentication. Modified to work with React Native, source: https://github.com/pusher/pusher-http-node

API hostname

whether to use TLS

deprecated; renamed to useTLS

port, default depends on the scheme

application ID

application key

application secret

request timeout in milliseconds

http agent to use

Constructors

Properties

RequestError: typeof RequestError = errors.RequestError

Exported RequestError constructor.

Token: typeof Token = Token

Exported Token constructor.

WebHookError: typeof WebHookError = errors.WebHookError

Exported WebHookError constructor.

Accessors

  • get config(): PusherConfig
  • Returns PusherConfig

Methods

  • Returns a signature for given socket id and user data.

    Parameters

    • socketId: string

      socket id

    • userData: {
          [key: string]: string;
      }

      user data

      • [key: string]: string

    Returns {
        auth: string;
        user_data: string;
    }

    authentication signature

    • auth: string
    • user_data: string
  • Returns a signature for given socket id, channel and socket data.

    Parameters

    • socketId: string

      socket id

    • channel: string

      channel name

    • Optionaldata: object

      additional socket data

    Returns {
        auth: string;
        channel_data?: string;
        shared_secret?: string;
    }

    authorization signature

    • auth: string
    • Optionalchannel_data?: string
    • Optionalshared_secret?: string
  • Parameters

    • _channel: string

    Returns string

  • Builds a signed query string that can be used in a request to Pusher.

    Parameters

    • options: {
          body?: string;
          method: string;
          params?: {
              [key: string]: string;
          };
          path: string;
      }
      • Optionalbody?: string

        request body

      • method: string

        request method

      • Optionalparams?: {
            [key: string]: string;
        }

        query params

        • [key: string]: string
      • path: string

        request path

    Returns string

    signed query string

  • Makes a GET request to Pusher, handles the authentication.

    Returns a promise resolving to a response, or rejecting to a RequestError.

    Parameters

    • options: {
          params?: {
              [key: string]: string;
          };
          path: string;
      }
      • Optionalparams?: {
            [key: string]: string;
        }

        query params

        • [key: string]: string
      • path: string

        request path

    Returns Promise<Response>

    RequestError

  • Makes a POST request to Pusher, handles the authentication.

    Returns a promise resolving to a response, or rejecting to a RequestError.

    Parameters

    • options: {
          body?: unknown;
          params?: {
              [key: string]: string;
          };
          path: string;
      }
      • Optionalbody?: unknown

        request body

      • Optionalparams?: {
            [key: string]: string;
        }

        query params

        • [key: string]: string
      • path: string

        request path

    Returns Promise<Response>

    RequestError

  • Sends an event to a user.

    Event name can be at most 200 characters long.

    Parameters

    • userId: string

      user id

    • event: string

      event name

    • data: unknown

      event data, objects are JSON-encoded

    Returns Promise<Response>

    a promise resolving to a response, or rejecting to a RequestError.

    RequestError

  • Terminate users's connections.

    Parameters

    • userId: string

      user id

    Returns Promise<Response>

    a promise resolving to a response, or rejecting to a RequestError.

    RequestError

  • Triggers an event.

    Channel names can contain only characters which are alphanumeric, '_' or '-' and have to be at most 200 characters long.

    Event name can be at most 200 characters long.

    Returns a promise resolving to a response, or rejecting to a RequestError.

    Parameters

    • channels: string | string[]
    • event: string

      event name

    • Optionaldata: unknown

      event data, objects are JSON-encoded

    • Optionalparams: {
          info?: string;
          socket_id?: string;
      }

      additional optional request body parameters

    Returns Promise<Response>

    RequestError

  • Parameters

    • batch: {
          channel: string;
          data?: string;
      }[]

    Returns Promise<Response>

  • Creates a WebHook object for a given request.

    Parameters

    • request: {
          headers: {
              [key: string]: string;
          };
          rawBody: string;
      }
      • headers: {
            [key: string]: string;
        }

        WebHook HTTP headers with lower-case keys

        • [key: string]: string
      • rawBody: string

        raw WebHook body

    Returns WebHook