Module: thaliNotificationBeacons

Classes

ParseBeaconsResponse

Methods

(static) generatePreambleAndBeacons(publicKeysToNotify, ecdhForLocalDevice, secondsUntilExpiration) → {Buffer}

This function will generate a buffer containing the notification preamble and beacons for the given set of public keys using the supplied private key and set to the specified seconds until expiration.

Parameters:
Name Type Description
publicKeysToNotify Array.<string>

An array of strings holding base64 url safe encoded ECDH public keys

ecdhForLocalDevice ECDH

A Crypto.ECDH object initialized with the local device's public and private keys

secondsUntilExpiration number

The number of seconds into the future after which the beacons should expire.

Source:
Returns:
  • A buffer containing the serialized preamble and beacons
Type
Buffer

(static) parseBeacons(beaconStreamWithPreAmble, ecdhForLocalDevice, addressBookCallback) → {ParseBeaconsResponse}

Parameters:
Name Type Description
beaconStreamWithPreAmble Buffer

A buffer stream containing the preamble and beacons

ecdhForLocalDevice Crypto.ECDH

A Crypto.ECDH object initialized with the local device's public and private keys

addressBookCallback addressBookCallback

A callback used by the function to determine if the identified remote peer's public key hash represents a remote peer the local peer wishes to communicate with.

Source:
Returns:
  • Null if none of the beacons could be validated as being targeted at the local peer or if the beacon came from a remote peer the local peer does not wish to communicate with. Otherwise a .
Type
ParseBeaconsResponse

(inner) generateBeacon(publicKey, ecdhWithPrivateKey, IV, Ke, expirationValue) → {Buffer}

Generates a single beacon using the specified values.

Parameters:
Name Type Description
publicKey string

This is a base64 url safe encoded public key we need to create a beacon for

ecdhWithPrivateKey ECDH

A Crypto.ECDH object initialized with the local device's public and private keys

IV Buffer

The IV to use for this beacon (we use the same IV for all beacons)

Ke ECDH

A Crypto.ECDH object initialized with the public and private ephemeral key

expirationValue Buffer

The calculated expirationValue used the pre-amble that pairs with this beacon

Source:
Returns:
  • A buffer containing the beacon
Type
Buffer

Type Definitions

addressBookCallback(unencryptedKeyId) → {string}

This callback is used to lookup if the public key hash retrieved from a notification beacon belongs to a peer that the local peer wishes to talk to. If not the callback will return null. If so then the callback will return the full public key for the remote peer. In other words, there is an explicit assumption that the caller has an address book mapping hashes of public keys with the full public keys. The hashes are in the beacon and this function is used to retrieve the full public key so that the beacon validation process can complete.

Parameters:
Name Type Description
unencryptedKeyId Buffer

This is a Buffer containing the unencryptedKeId.

Source:
Returns:
  • The base64 url safe encoded public key associated with the unecryptedKeyId or null if the remote peer is not one the local peer recognizes or wishes to communicate with.
Type
string