Skip to content

Commit

Permalink
PermissionsApi in agent, grants API for web5
Browse files Browse the repository at this point in the history
  • Loading branch information
LiranCohen committed Aug 14, 2024
1 parent c65f479 commit 2b0eda3
Show file tree
Hide file tree
Showing 34 changed files with 4,074 additions and 2,038 deletions.
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

0 comments on commit 2b0eda3

Please sign in to comment.