Class PlivoSmsChannelAdapter

Channel adapter for SMS backed by Plivo.

Capabilities: text. (MMS media is out of scope for this adapter.)

Hierarchy (view full)

Constructors

  • Parameters

    • Optional opts: {
          fetchImpl?: {
              (input, init?): Promise<Response>;
              (input, init?): Promise<Response>;
          };
          retryConfig?: Partial<RetryConfig>;
          nonceTtlMs?: number;
          maxNonces?: number;
      }
      • Optional fetchImpl?: {
            (input, init?): Promise<Response>;
            (input, init?): Promise<Response>;
        }

        Override the global fetch (inject a mock in tests).

          • (input, init?): Promise<Response>
          • Parameters

            • input: RequestInfo | URL
            • Optional init: RequestInit

            Returns Promise<Response>

          • (input, init?): Promise<Response>
          • Parameters

            • input: string | Request | URL
            • Optional init: RequestInit

            Returns Promise<Response>

      • Optional retryConfig?: Partial<RetryConfig>

        Connection retry tuning (see BaseChannelAdapter).

      • Optional nonceTtlMs?: number

        How long the nonce of an accepted callback is remembered, in milliseconds. Default: 24 hours.

      • Optional maxNonces?: number

        How many nonces are remembered at once; past it the oldest is forgotten first. Default: 10,000.

    Returns PlivoSmsChannelAdapter

Methods

  • Handle an inbound Plivo SMS webhook. The host forwards Plivo's request here.

    When signature verification is enabled (the default), the request must carry a valid Plivo signature over the URL Plivo requested, and each callback is accepted once: a request whose nonce was already accepted is dropped. Anything else is dropped as well (fail closed).

    What a valid signature proves depends on its family:

    • V3 covers the URL, its query, the params and the nonce, so From, Text and MessageUUID are the ones Plivo sent.
    • V2 covers the URL and the nonce only. It does not authenticate From, Text or MessageUUID: whoever holds one callback's signature and nonce can send them again over a different body. Plivo's messaging documentation describes V2 for message callbacks.

    The nonce memory narrows that replay; it does not end it. It holds the callbacks this process accepted, for nonceTtlMs (24 hours by default) and maxNonces of them at most, and a restart empties it. Plivo's signatures carry no timestamp, so a callback sent again after its nonce is forgotten, or one this process never accepted, is accepted. Do not let an inbound message authorize an action by its sender number alone.

    Parameters

    • body: Record<string, unknown>

      Parsed form body of Plivo's inbound-message POST. For a GET callback the params are read from the query string of meta.url, whose values win over body.

    • Optional meta: {
          method?: string;
          url?: string;
          headers?: Record<string, undefined | string | string[]>;
      }

      Request metadata needed to verify the signature.

      • Optional method?: string
      • Optional url?: string

        The exact externally-visible URL Plivo requested (must byte-match); for a GET callback, with its query string.

      • Optional headers?: Record<string, undefined | string | string[]>

    Returns void

Properties

status: ChannelConnectionStatus = 'disconnected'
connectedSince: undefined | string
errorMessage: undefined | string
platformInfo: Record<string, unknown> = {}
auth: undefined | ChannelAuthConfig & {
    params?: PlivoSmsAuthParams;
}

Stored auth config so reconnect() can re-use it.

retryConfig: RetryConfig
platform: ChannelPlatform = 'plivo'

Platform this adapter serves.

displayName: "Plivo SMS" = 'Plivo SMS'

Human-readable display name (e.g., "WhatsApp Business").

capabilities: readonly ChannelCapability[] = ...

Declared capabilities of this adapter.