Class ResourceAbstract Beta

tbDEX Resources are published by PFIs for anyone to consume and generally used as a part of the discovery process. They are not part of the message exchange, i.e Alice cannot reply to a Resource.

Hierarchy (view full)

Constructors

Properties

_signature: any

signature that verifies that authenticity and integrity of a message

Resource kind-specific data

The resource kind (e.g. offering)

Metadata such as creator, date created, date updated, and ID

Accessors

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

    Returns string

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

    Returns string

  • get id(): string
  • the resource's id

    Returns string

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

    Returns `${number}`

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

    Returns undefined | string

  • get updatedAt(): undefined | string
  • Resource last updated time. Expressed as ISO8601

    Returns undefined | string

Methods

  • Computes a digest of the payload by:

    Returns Uint8Array

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

  • balance type guard

    Returns this is Balance

  • Signs the resource 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

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

    Returns void

    Throws

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

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

    Returns void

    Throws

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

  • Validates the resource structure and verifies 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

    Throws

    if the resource 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 resource kind's prefix

    Parameters

    Returns string