Class MessageAbstract Beta

Representation of the protocol messages. It also provides helper functions to manipulate raw messages, JSON and parsing.

Hierarchy (view full)

Constructors

Properties

_signature: undefined | string

signature that verifies that authenticity and integrity of a message

Message kind-specific data to facilitate the exchange of assets between Alice and the PFI

The message kind (e.g. rfq, quote)

metadata: MessageMetadata

Metadata such as sender, recipient, date created, and ID

validNext: Set<MessageKind>

A set of valid Message kinds that can come after this message in an exchange

Accessors

  • get createdAt(): string
  • Message creation time. Expressed as ISO8601

    Returns string

  • get exchangeId(): string
  • ID for an "exchange" of messages between Alice - PFI. Uses the id of the RFQ that initiated the exchange

    Returns string

  • get externalId(): undefined | string
  • the external ID

    Returns undefined | string

  • get from(): string
  • The sender's DID

    Returns string

  • get id(): string
  • the message id

    Returns string

  • get protocol(): `${number}`
  • the protocol version

    Returns `${number}`

  • get signature(): undefined | string
  • the message's cryptographic signature

    Returns undefined | string

  • get to(): string
  • the recipient's DID

    Returns string

Methods

  • Computes a digest of the payload by:

    Returns Uint8Array

    The SHA-256 hash of the canonicalized payload, represented as a byte array.

  • Cancel type guard

    Returns this is Cancel

  • Close type guard

    Returns this is Close

  • Order type guard

    Returns this is Order

  • Quote type guard

    Returns this is Quote

  • Rfq type guard

    Returns this is Rfq

  • Signs the message as a jws with detached content and sets the signature property

    Parameters

    • did: BearerDid

      the signer's DID

    Returns Promise<void>

    Throws

    If the signature could not be produced

  • returns the message as a json object. Automatically used by JSON.stringify method.

    Returns MessageModel

  • Valid structure of the message including the presence of the signature using the official spec JSON Schemas

    Returns void

    Throws

    If the message's structure does not match the JSON schemas

  • Validates data section of message only using the official TBDex JSON Schemas. This is useful for partially validating unsigned messages.

    Returns void

    Throws

    If the structure of the messages's data does not match the JSON schemas

  • Validates the message structure and verifies the cryptographic signature

    Returns Promise<string>

    Signer's DID

    Throws

    if the message signature is invalid

    Throws

    if the message structure is invalid

    Throws

    see Crypto.verify

  • Verifies the integrity of the cryptographic signature

    Returns Promise<string>

    Resource signer's DID

    Throws

    if the resource signature is invalid

    Throws

    if the signer's DID does not match Resource.metadata.from

  • Generates a unique id with the message kind's prefix

    Parameters

    Returns string