Class PermissionRequestBeta

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

Methods are provided to grant the request and manage the request's lifecycle, including writing to remote DWNs.

Implements

Constructors

  • Parameters

    • __namedParameters: {
          api: AgentPermissionsApi;
          connectedDid: string;
          message: DataEncodedRecordsWriteMessage;
          request: PermissionRequest;
      }
      • api: AgentPermissionsApi
      • connectedDid: string
      • message: DataEncodedRecordsWriteMessage
      • request: PermissionRequest

    Returns PermissionRequest

Properties

_connectedDid: string

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

_message: DataEncodedRecordsWriteMessage

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

_permissions: AgentPermissionsApi

The PermissionsAPI used to interact with the underlying permission request

_request: PermissionRequest

The parsed permission request object

Accessors

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

    Returns Web5Agent

  • get conditions(): PermissionConditions
  • The conditions under which the requested grant would be valid

    Returns PermissionConditions

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

    Returns boolean

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

    Returns string

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

    Returns DataEncodedRecordsWriteMessage

  • get scope(): PermissionScope
  • The permission scope under which the requested grant would be valid

    Returns PermissionScope

Methods

  • Beta

    Grants the permission request to the requester.

    Parameters

    • dateExpires: string

      the date when the permission grant will expire.

    • store: boolean = true

      if true, the permission grant will be stored in the owner's DWN. Defaults to true.

    Returns Promise<PermissionGrant>

    the granted permission.

  • Beta

    Send the current permission request 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 permission request to, if none is set it is sent to the connectedDid

    Returns Promise<DwnResponseStatus>

    the status of the send permission request

  • Beta

    Stores the current permission request to the owner's DWN.

    Returns Promise<DwnResponseStatus>

    the status of the store request

  • parses the request given an agent, connectedDid and data encoded records write message

    Parameters

    • __namedParameters: {
          agent: Web5Agent;
          connectedDid: string;
          message: DataEncodedRecordsWriteMessage;
      }
      • agent: Web5Agent
      • connectedDid: string
      • message: DataEncodedRecordsWriteMessage

    Returns Promise<PermissionRequest>