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

Bump DWN SDK 0.2.8 #310

Merged
merged 4 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 6 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"node": ">=18.0.0"
},
"dependencies": {
"@tbd54566975/dwn-sdk-js": "0.2.6",
"@tbd54566975/dwn-sdk-js": "0.2.8",
"@web5/common": "0.2.1",
"@web5/crypto": "0.2.2",
"@web5/dids": "0.2.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"node": ">=18.0.0"
},
"dependencies": {
"@tbd54566975/dwn-sdk-js": "0.2.6",
"@tbd54566975/dwn-sdk-js": "0.2.8",
"@web5/agent": "0.2.4",
"@web5/crypto": "0.2.2",
"@web5/dids": "0.2.2",
Expand Down
72 changes: 62 additions & 10 deletions packages/api/tests/dwn-api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,25 +149,77 @@ describe('DwnApi', () => {
expect(response.protocols.length).to.equal(0);
});

it('returns a 401 when authorization fails', async () => {
/** Create a new DID to represent an external entity who has a remote
* DWN server defined in their DID document. */
const { did: bob } = await testAgent.createIdentity({ testDwnUrls });
it('returns published protocol definitions for requests from external DID', async () => {
// Configure a published protocol on Alice's local DWN.
const publicProtocol = await dwnAlice.protocols.configure({
message: {
definition: { ...emailProtocolDefinition, protocol: 'http://proto-published', published: true }
}
});
expect(publicProtocol.status.code).to.equal(202);

// Attempt to query for a protocol using Bob's DWN tenant.
const response = await dwnAlice.protocols.query({
from : bob.did,
// Configure the published protocol on Alice's remote DWN.
const sendPublic = await publicProtocol.protocol.send(aliceDid.did);
expect(sendPublic.status.code).to.equal(202);

// Attempt to query for the published protocol on Alice's remote DWN authored by Bob.
const publishedResponse = await dwnBob.protocols.query({
from : aliceDid.did,
message : {
filter: {
protocol: 'http://proto-published'
}
}
});

// Verify that one query result is returned.
expect(publishedResponse.status.code).to.equal(200);
expect(publishedResponse.protocols.length).to.equal(1);
expect(publishedResponse.protocols[0].definition.protocol).to.equal('http://proto-published');
});

it('does not return unpublished protocol definitions for requests from external DID', async () => {
// Configure an unpublished protocol on Alice's DWN.
const notPublicProtocol = await dwnAlice.protocols.configure({
message: {
definition: { ...emailProtocolDefinition, protocol: 'http://proto-not-published', published: false }
}
});
expect(notPublicProtocol.status.code).to.equal(202);

// Configure the unpublished protocol on Alice's remote DWN.
const sendNotPublic = await notPublicProtocol.protocol.send(aliceDid.did);
expect(sendNotPublic.status.code).to.equal(202);

// Attempt to query for the unpublished protocol on Alice's remote DWN authored by Bob.
const nonPublishedResponse = await dwnBob.protocols.query({
from : aliceDid.did,
message : {
filter: {
protocol: 'http://proto-not-published'
}
}
});

// Verify that no query results are returned.
expect(nonPublishedResponse.status.code).to.equal(200);
expect(nonPublishedResponse.protocols.length).to.equal(0);
});

it('returns a 401 with an invalid permissions grant', async () => {
// Attempt to query for a record using Bob's DWN tenant with an invalid grant.
const response = await dwnAlice.protocols.query({
from : bobDid.did,
message : {
permissionsGrantId : 'bafyreiduimprbncdo2oruvjrvmfmwuyz4xx3d5biegqd2qntlryvuuosem',
filter : {
protocol: 'https://doesnotexist.com/protocol'
}
}
});

/** Confirm that authorization failed because the test identity does not have
* permission to delete a record from Bob's DWN. */
expect(response.status.code).to.equal(401);
expect(response.status.detail).to.include('ProtocolsQuery failed authorization');
expect(response.status.detail).to.include('GrantAuthorizationGrantMissing');
expect(response.protocols).to.exist;
expect(response.protocols.length).to.equal(0);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/dev-env/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ version: "3.98"
services:
dwn-server:
container_name: dwn-server
image: ghcr.io/tbd54566975/dwn-server:dwn-sdk-0.2.6
image: ghcr.io/tbd54566975/dwn-server:dwn-sdk-0.2.8
ports:
- "3000:3000"
Loading