Class PermissionGrantBeta

The PermissionGrant class encapsulates a permissions protocol grant record, providing a more developer-friendly interface for working with Decentralized Web Node (DWN) records.

Methods are provided to revoke, check if isRevoked, and manage the grant's lifecycle, including writing to remote DWNs.

Implements

Constructors

  • Parameters

    • __namedParameters: {
          api: AgentPermissionsApi;
          connectedDid: string;
          grant: PermissionGrant;
          message: DataEncodedRecordsWriteMessage;
      }
      • api: AgentPermissionsApi
      • connectedDid: string
      • grant: PermissionGrant
      • message: DataEncodedRecordsWriteMessage

    Returns PermissionGrant

Properties

_connectedDid: string

The DID to use as the author and default target for the underlying permission grant

_grant: PermissionGrant

The parsed grant object

_message: DataEncodedRecordsWriteMessage

The underlying DWN RecordsWrite message along with encoded data that represent the grant

_permissions: AgentPermissionsApi

The PermissionsAPI used to interact with the underlying permission grant

Accessors

  • get agent(): Web5Agent
  • The agent to use for this instantiation of the grant

    Returns Web5Agent

  • get conditions(): PermissionConditions
  • The conditions under which the grant is valid

    Returns PermissionConditions

  • get delegated(): boolean
  • Whether or not the permission grant can be used to impersonate the grantor

    Returns boolean

  • get id(): string
  • The grant's ID, which is also the underlying record's ID

    Returns string

  • get rawMessage(): DataEncodedRecordsWriteMessage
  • The raw RecordsWrite DWN message with encoded data that was used to instantiate this grant

    Returns DataEncodedRecordsWriteMessage

  • get scope(): PermissionScope
  • The permission scope under which the grant is valid

    Returns PermissionScope

Methods

  • Beta

    Signs the current grant as the owner and optionally stores it to the owner's DWN. This is useful when importing a grant that was signed by someone else into your own DWN.

    Parameters

    • store: boolean = false

      if true, the grant will be stored to the owner's DWN after signing. Defaults to true.

    Returns Promise<DwnResponseStatus>

    the status of the import request

  • Beta

    Checks if the grant has been revoked.

    Parameters

    • remote: boolean = false

      if true, the check will be made against the remote DWN. Defaults to false.

    Returns Promise<boolean>

    true if the grant has been revoked, false otherwise.

    Throws

    if there is an error checking the revocation status.

  • Beta

    Revokes the grant and optionally stores the revocation to the owner's DWN.

    Parameters

    • store: boolean = true

      if true, the revocation will be stored to the owner's DWN. Defaults to true.

    Returns Promise<PermissionGrantRevocation>

    the grant revocation object

  • Beta

    Send the current grant to a remote DWN by specifying their DID If no DID is specified, the target is assumed to be the owner (connectedDID).

    Parameters

    • Optional target: string

      the optional DID to send the grant to, if none is set it is sent to the connectedDid

    Returns Promise<DwnResponseStatus>

    the status of the send grant request

  • Beta

    Stores the current grant to the owner's DWN.

    Parameters

    • importGrant: boolean = false

      if true, the grant will signed by the owner before storing it to the owner's DWN. Defaults to false.

    Returns Promise<DwnResponseStatus>

    the status of the store request

  • Returns PermissionGrant

    the JSON representation of the grant