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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
41c43f3
permission grant flow for agent/identities
LiranCohen Jul 13, 2024
f18392d
refactor into smaller modules, fetching the grants, matchig the grant…
LiranCohen Aug 3, 2024
3fef8c8
use permissions with records in DwnApi
LiranCohen Aug 5, 2024
9c28949
mock connect flow
LiranCohen Aug 5, 2024
5a17d20
stub and test connect with permissions
LiranCohen Aug 6, 2024
0b89ade
mocked connect flow without sync
LiranCohen Aug 6, 2024
3bb8b81
added isConnected method to platform agent
LiranCohen Aug 6, 2024
c3d4d08
add isConnected to user, proxy and identity agents
LiranCohen Aug 6, 2024
a966bbc
add isConnected functionality
LiranCohen Aug 6, 2024
abc0602
update typedoc requirements
LiranCohen Aug 6, 2024
f5f7327
identity api `connectedIdentity` method in place of `isConnected`
LiranCohen Aug 7, 2024
3b2839c
break out processing grants for connect into separate function, handl…
LiranCohen Aug 7, 2024
c21e783
update tests, move methods to concise grants api
LiranCohen Aug 8, 2024
82229ba
additional test coverage, move mocked connect into temp file to ignor…
LiranCohen Aug 8, 2024
7c74cc2
refactor api grants interfaces
LiranCohen Aug 8, 2024
99199ff
simplify grants interface, update tests
LiranCohen Aug 8, 2024
b01c1b2
slight refactor/reording of connect flow, comments and more consisten…
LiranCohen Aug 8, 2024
e85a652
slight refactor/reording of connect flow, comments and more consisten…
LiranCohen Aug 8, 2024
886c9bc
include test for multiple identities race conditions
LiranCohen Aug 8, 2024
c65f479
review comments for delegateDid, update dwn-server to latest
LiranCohen Aug 8, 2024
2b0eda3
PermissionsApi in agent, grants API for web5
LiranCohen Aug 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gold-lamps-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@web5/api": patch
---

Introduce a `grants` API for `Web5.dwn`
8 changes: 8 additions & 0 deletions .changeset/polite-days-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@web5/identity-agent": patch
"@web5/proxy-agent": patch
"@web5/user-agent": patch
"@web5/agent": patch
---

Introduce a `PermissionsApi` for Web5Agents
44 changes: 0 additions & 44 deletions packages/agent/src/dwn-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { Readable } from '@web5/common';

import {
Cid,
DataEncodedRecordsWriteMessage,
DataStoreLevel,
Dwn,
DwnConfig,
Expand All @@ -11,10 +10,6 @@ import {
GenericMessage,
Message,
MessageStoreLevel,
PermissionGrant,
PermissionScope,
PermissionsProtocol,
RecordsWrite,
ResumableTaskStoreLevel
} from '@tbd54566975/dwn-sdk-js';

Expand Down Expand Up @@ -449,43 +444,4 @@ export class AgentDwnApi {

return dwnMessageWithBlob;
}

/**
* NOTE EVERYTHING BELOW THIS LINE IS TEMPORARY
* TODO: Create a `grants` API to handle creating permission requests, grants and revocations
* */

public async createGrant({ grantedFrom, dateExpires, grantedTo, scope, delegated }:{
dateExpires: string,
grantedFrom: string,
grantedTo: string,
scope: PermissionScope,
delegated?: boolean
}): Promise<{
recordsWrite: RecordsWrite,
dataEncodedMessage: DataEncodedRecordsWriteMessage,
permissionGrantBytes: Uint8Array
}> {
return await PermissionsProtocol.createGrant({
signer: await this.getSigner(grantedFrom),
grantedTo,
dateExpires,
scope,
delegated
});
}

public async createRevocation({ grant, author }:{
author: string,
grant: PermissionGrant
}): Promise<{
recordsWrite: RecordsWrite,
dataEncodedMessage: DataEncodedRecordsWriteMessage,
permissionRevocationBytes: Uint8Array
}> {
return await PermissionsProtocol.createRevocation({
signer: await this.getSigner(author),
grant,
});
}
}
116 changes: 0 additions & 116 deletions packages/agent/src/dwn-permissions-util.ts

This file was deleted.

3 changes: 2 additions & 1 deletion packages/agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ export * from './types/dwn.js';
export type * from './types/identity.js';
export type * from './types/identity-vault.js';
export type * from './types/key-manager.js';
export type * from './types/permissions.js';
export type * from './types/sync.js';
export type * from './types/vc.js';

export * from './bearer-identity.js';
export * from './crypto-api.js';
export * from './did-api.js';
export * from './dwn-api.js';
export * from './dwn-permissions-util.js';
export * from './dwn-registrar.js';
export * from './hd-identity-vault.js';
export * from './identity-api.js';
export * from './local-key-manager.js';
export * from './permissions-api.js';
export * from './rpc-client.js';
export * from './store-data.js';
export * from './store-did.js';
Expand Down
Loading
Loading