Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PermissionsApi for Agent, permissions API for Web5 #833

Merged
merged 21 commits into from
Aug 14, 2024

Conversation

LiranCohen
Copy link
Member

@LiranCohen LiranCohen commented Aug 12, 2024

This refactors a lot of what's in #824 with regards to creating/fetching grants.

Satisfies: #827

PermissionsApi

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.

dwn.connected

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

dwn.permissions

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:

PermissionRequest

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.

PermissionGrant

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.

GrantRevocation

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.

Copy link

changeset-bot bot commented Aug 12, 2024

🦋 Changeset detected

Latest commit: 2b0eda3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@web5/api Patch
@web5/identity-agent Patch
@web5/proxy-agent Patch
@web5/user-agent Patch
@web5/agent Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

codecov bot commented Aug 12, 2024

Codecov Report

Attention: Patch coverage is 99.76134% with 3 lines in your changes missing coverage. Please review.

Project coverage is 93.29%. Comparing base (e93f109) to head (2b0eda3).

Additional details and impacted files
@@                     Coverage Diff                     @@
##           lirancohen/grants-web5     #833       +/-   ##
===========================================================
+ Coverage                        0   93.29%   +93.29%     
===========================================================
  Files                           0      115      +115     
  Lines                           0    32550    +32550     
  Branches                        0     2560     +2560     
===========================================================
+ Hits                            0    30369    +30369     
- Misses                          0     2143     +2143     
- Partials                        0       38       +38     
Components Coverage Δ
agent 86.88% <100.00%> (∅)
api 99.53% <100.00%> (∅)
common 98.68% <ø> (∅)
credentials 94.95% <ø> (∅)
crypto 93.88% <ø> (∅)
dids 97.77% <ø> (∅)
identity-agent 96.42% <90.90%> (∅)
crypto-aws-kms 100.00% <ø> (∅)
proxy-agent 96.42% <90.90%> (∅)
user-agent 96.42% <90.90%> (∅)

@LiranCohen LiranCohen force-pushed the lirancohen/grants-api branch from 980fbf6 to 0718bd9 Compare August 12, 2024 17:34
Copy link
Contributor

github-actions bot commented Aug 12, 2024

TBDocs Report

✅ No errors or warnings

@web5/api

  • Project entry file: packages/api/src/index.ts

@web5/crypto

  • Project entry file: packages/crypto/src/index.ts

@web5/crypto-aws-kms

  • Project entry file: packages/crypto-aws-kms/src/index.ts

@web5/dids

  • Project entry file: packages/dids/src/index.ts

@web5/credentials

  • Project entry file: packages/credentials/src/index.ts

TBDocs Report Updated at 2024-08-12T20:26:41Z 20f317d

@LiranCohen LiranCohen force-pushed the lirancohen/grants-api branch from 66ca7b7 to 3f07c1b Compare August 12, 2024 20:16
@LiranCohen LiranCohen changed the title [WIP] PermissionsApi for Agent, permissions API for Web5 PermissionsApi for Agent, permissions API for Web5 Aug 13, 2024
@LiranCohen LiranCohen marked this pull request as ready for review August 13, 2024 15:34
@LiranCohen LiranCohen force-pushed the lirancohen/grants-api branch from f28ae42 to 090dd73 Compare August 13, 2024 21:55
@LiranCohen LiranCohen force-pushed the lirancohen/grants-web5 branch from 0cd1698 to e93f109 Compare August 14, 2024 02:46
@LiranCohen LiranCohen force-pushed the lirancohen/grants-api branch from 090dd73 to 2b0eda3 Compare August 14, 2024 02:46
@LiranCohen LiranCohen merged commit 2b9391c into lirancohen/grants-web5 Aug 14, 2024
29 checks passed
@LiranCohen LiranCohen deleted the lirancohen/grants-api branch August 14, 2024 03:03
LiranCohen added a commit that referenced this pull request Aug 14, 2024
This refactors a lot of what's in #824 with regards to creating/fetching grants.

Satisfies: #827

#### `PermissionsApi`
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.

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

#### `dwn.permissions`
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:
#### `PermissionRequest`
 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.
 
#### `PermissionGrant`
 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.

#### `GrantRevocation`
 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.
LiranCohen added a commit that referenced this pull request Aug 14, 2024
This refactors a lot of what's in #824 with regards to creating/fetching grants.

Satisfies: #827

#### `PermissionsApi`
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.

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

#### `dwn.permissions`
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:
#### `PermissionRequest`
 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.
 
#### `PermissionGrant`
 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.

#### `GrantRevocation`
 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.
LiranCohen added a commit that referenced this pull request Aug 19, 2024
…` with the ability to select delegate grants for `Web5.dwn` (#824)

* first pass at connect flow and grants api

* PermissionsApi for Agent, `permissions` API for `Web5` (#833)

This refactors a lot of what's in #824 with regards to creating/fetching grants.

Satisfies: #827

#### `PermissionsApi`
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.

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

#### `dwn.permissions`
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:
#### `PermissionRequest`
 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.
 
#### `PermissionGrant`
 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.

#### `GrantRevocation`
 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.

* package lock update after rebase

* add additional comments around the signer for the permissions DWN api
LiranCohen added a commit that referenced this pull request Aug 19, 2024
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.
LiranCohen added a commit that referenced this pull request Aug 20, 2024
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.
LiranCohen added a commit that referenced this pull request Aug 23, 2024
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.
LiranCohen added a commit that referenced this pull request Aug 23, 2024
* first pass at connect flow and grants api

* PermissionsApi for Agent, `permissions` API for `Web5` (#833)

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 used in 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant