Signatures()

This class contains useful utilities for verifying Websocket and Webhook Events.

new Signatures()

Example
// Verify signatures for Webhook Event
CashPay.Signatures.verifyWebhook(req.body, req.headers)

// Verify signatures for Websocket Event
CashPay.Signatures.verifyEvent(payload)

Methods

async, static refreshKeys()

Refreshes the keys using the endpoint given at CashPay.config.options.endpoint.

This will be called automatically, as needed, by verifyWebhook and verifyEvent.

You should not need to call this manually.

Example
CashPay.Signatures.refreshKeys()

async, static verifyEvent(payload)

Verifies the signature of a Webhook Payload
Parameters:
Name Type Description
payload string | object String or Object containing the Websocket Event payload
Example
CashPay.Signatures.verifyEvent(payload)

async, static verifyWebhook(payload, headers)

Verifies the signature of a Webhook Payload
Parameters:
Name Type Description
payload string | object String or Object containing the payload
headers object HTTP Headers (requires digest, x-identity, x-signature-type and x-signature)
Example
// ExpressJS
CashPay.Signatures.verifyWebhook(req.body, req.headers)