A class representing a RecordsWrite DWN message. NOTE: Unable to extend AbstractMessage directly because the incompatible _message type, which is not just a generic <M> type.

Implements

Properties

attesters: string[]

Accessors

  • get owner(): undefined | string
  • The owner DID of the message if owner signature is present in the message; undefined otherwise. This is the logical owner of the message, not to be confused with the actual signer of the owner signature, this is because the signer of the owner signature may not be the actual DWN owner, but a delegate authorized by the owner.

    Returns undefined | string

  • get ownerSignaturePayload(): undefined | GenericSignaturePayload
  • Decoded owner signature payload.

    Returns undefined | GenericSignaturePayload

  • get ownerSignatureSigner(): undefined | string
  • Gets the signer of owner signature; undefined if owner signature is not present in the message. This is not to be confused with the logical owner #owner of the message, this is because the signer of the owner signature may not be the actual DWN owner, but a delegate authorized by the owner. In the case that the owner signature is signed by the actual DWN owner, this value will be the same as #owner.

    Returns undefined | string

  • get signaturePayload(): undefined | RecordsWriteSignaturePayload
  • Returns undefined | RecordsWriteSignaturePayload

  • get signer(): undefined | string
  • Gets the signer of this message. This is not to be confused with the logical author of the message.

    Returns undefined | string

Methods

  • Authorizes the author-delegate who signed this message.

    Parameters

    • messageStore: MessageStore

      Used to check if the grant has been revoked.

    Returns Promise<void>

  • Authorizes the owner-delegate who signed this message.

    Parameters

    • messageStore: MessageStore

      Used to check if the grant has been revoked.

    Returns Promise<void>

  • Encrypts the symmetric encryption key using the public keys given and attach the resulting encryption property to the RecordsWrite.

    Parameters

    Returns Promise<void>

  • Signs the RecordsWrite, the signer is commonly the author, but can also be a delegate.

    Parameters

    • options: {
          delegatedGrant?: RecordsWriteMessage;
          permissionsGrantId?: string;
          protocolRole?: string;
          signer: Signer;
      }
      • Optional delegatedGrant?: RecordsWriteMessage
      • Optional permissionsGrantId?: string
      • Optional protocolRole?: string
      • signer: Signer

    Returns Promise<void>

  • Signs the RecordsWrite as the DWN owner. This is used when the DWN owner wants to retain a copy of a message that the owner did not author. NOTE: requires the RecordsWrite to already have the author's signature.

    Parameters

    Returns Promise<void>

  • Signs the RecordsWrite as the DWN owner-delegate. This is used when a DWN owner-delegate wants to retain a copy of a message that the owner did not author. NOTE: requires the RecordsWrite to already have the author's signature.

    Parameters

    Returns Promise<void>

  • Creates the attestation property of a RecordsWrite message if given signature inputs; returns undefined otherwise.

    Parameters

    • descriptorCid: string
    • Optional signers: Signer[]

    Returns Promise<undefined | GeneralJws>

  • Convenience method that creates a message by:

    1. Copying over immutable properties from the given source message
    2. Copying over mutable properties that are not overwritten from the given source message
    3. Replace the mutable properties that are given new value

    Parameters

    Returns Promise<RecordsWrite>

  • Creates the signature property in the authorization of a RecordsWrite message.

    Parameters

    • input: {
          attestation: undefined | GeneralJws;
          contextId: undefined | string;
          delegatedGrantId?: string;
          descriptorCid: string;
          encryption: undefined | EncryptionProperty;
          permissionsGrantId?: string;
          protocolRole?: string;
          recordId: string;
          signer: Signer;
      }
      • attestation: undefined | GeneralJws
      • contextId: undefined | string
      • Optional delegatedGrantId?: string
      • descriptorCid: string
      • encryption: undefined | EncryptionProperty
      • Optional permissionsGrantId?: string
      • Optional protocolRole?: string
      • recordId: string
      • signer: Signer

    Returns Promise<GeneralJws>

  • Fetches the initial RecordsWrite of a record.

    Parameters

    Returns Promise<undefined | RecordsWrite>

    The initial RecordsWrite if found; undefined if the record is not found.

  • Gets the DID of the author of the given message.

    Parameters

    • message: InternalRecordsWriteMessage

    Returns string[]