Skip to content

Commit

Permalink
PermissionsApi for Agent, permissions API for Web5 (#833)
Browse files Browse the repository at this point in the history
This refactors a lot of what's in #824 with regards to creating/fetching grants.

Satisfies: #827

Introduces a `PermissionsApi` interface and an `AgentPermissionsApi` concrete implementation.

The interface implements the following methods `fetchGrants`, `fetchRequests`, `isGrantRevoked`, `createGrant`, `createRequest`, `createRevocation` as convenience methods for dealing with the built-in permission protocol records.

The `AgentPermissionsApi` implements an additional static method `matchGrantFromArray` which was moved from a `PermissionsUtil` class, which is used to find the appropriate grant to use when authoring a message.

A Private API usedin a connected state to find and cache the correct grants to use for the request.

A Permissions API which implements `request`, `grant`, `queryRequests`, and `queryGrants` that a user can utilize

The `Web5` permissions api introduces 3 helper classes to represent permissions:
 Class to represent a permission request record. It implements convenience methods similar to the `Record` class where you can `store()`, `import()` or `send()` the underlying request record. Additionally a `grant()` method will create a `PermissionGrant` object.

 Class to represent a grant record. It implements convenience methods similar to the `Record` class where you can `store()`, `import()` or `send()` the underlying grant record. Additionally a `revoke()` method will create a `GrantRevocation` object, and `isRevoked()` will check if the underlying grant has been revoked.

 Class to represent a permission grant revocation record. It implements convenience methods similar to the `Record` class where you can `store()`  or `send()` the underlying revocation record.
  • Loading branch information
LiranCohen committed Aug 20, 2024
1 parent 29a2870 commit 5ba720a
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions packages/api/tests/dwn-api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ describe('DwnApi', () => {
// Instantiate DwnApi for both test identities.
dwnAlice = new DwnApi({ agent: testHarness.agent, connectedDid: aliceDid.uri });
dwnBob = new DwnApi({ agent: testHarness.agent, connectedDid: bobDid.uri });

// clear cached permissions between test runs
dwnAlice['cachedPermissions'].clear();
dwnBob['cachedPermissions'].clear();
});

after(async () => {
Expand Down

0 comments on commit 5ba720a

Please sign in to comment.