From aaf4b4a23cada03a50f4dab6c9ce1c6200bf07ef Mon Sep 17 00:00:00 2001 From: Henry Tsai Date: Thu, 10 Oct 2024 09:47:53 -0700 Subject: [PATCH] Updated dwn-sdk-js dependency to v0.5.1 (#950) * Updated dwn-sdk-js dependency to v0.5.1 * Updated dwn-server docker image * Updated dwn-server dependency --- package.json | 4 +- packages/agent/package.json | 4 +- packages/agent/src/store-data.ts | 4 +- packages/agent/tests/dwn-api.spec.ts | 20 ++++---- .../clients/http-dwn-rpc-client.spec.ts | 4 +- .../clients/ws-dwn-rpc-client.spec.ts | 4 +- .../agent/tests/sync-engine-level.spec.ts | 10 ++-- packages/api/package.json | 4 +- packages/api/src/dwn-api.ts | 8 +-- packages/api/src/record.ts | 4 +- packages/dev-env/docker-compose.yaml | 2 +- pnpm-lock.yaml | 49 ++++++++++++------- 12 files changed, 66 insertions(+), 51 deletions(-) diff --git a/package.json b/package.json index 903e77a75..90f40f01e 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "@changesets/cli": "^2.27.5", "@npmcli/package-json": "5.0.0", "@typescript-eslint/eslint-plugin": "7.9.0", - "@web5/dwn-server": "0.4.10", + "@web5/dwn-server": "0.6.0", "audit-ci": "^7.0.1", "eslint-plugin-mocha": "10.4.3", "globals": "^13.24.0", @@ -60,4 +60,4 @@ "rollup@>=4.0.0 <4.22.4": ">=4.22.4" } } -} +} \ No newline at end of file diff --git a/packages/agent/package.json b/packages/agent/package.json index c2b248f30..e6ee360dc 100644 --- a/packages/agent/package.json +++ b/packages/agent/package.json @@ -71,7 +71,7 @@ "dependencies": { "@noble/ciphers": "0.5.3", "@scure/bip39": "1.2.2", - "@tbd54566975/dwn-sdk-js": "0.4.7", + "@tbd54566975/dwn-sdk-js": "0.5.1", "@web5/common": "workspace:*", "@web5/crypto": "workspace:*", "@web5/dids": "workspace:*", @@ -110,4 +110,4 @@ "sinon": "18.0.0", "typescript": "5.1.6" } -} +} \ No newline at end of file diff --git a/packages/agent/src/store-data.ts b/packages/agent/src/store-data.ts index 7d5699022..cc2b0535b 100644 --- a/packages/agent/src/store-data.ts +++ b/packages/agent/src/store-data.ts @@ -243,12 +243,12 @@ export class DwnDataStore = Jwk> implem messageParams : { filter: { recordId } } }); - if (!readReply.record?.data) { + if (!readReply.entry?.data) { throw new Error(`${this.name}: Failed to read data from DWN for: ${recordId}`); } // If the record was found, convert back to store object format. - const storeObject = await NodeStream.consumeToJson({ readable: readReply.record.data }) as TStoreObject; + const storeObject = await NodeStream.consumeToJson({ readable: readReply.entry.data }) as TStoreObject; // If caching is enabled, add the store object to the cache. if (useCache) { diff --git a/packages/agent/tests/dwn-api.spec.ts b/packages/agent/tests/dwn-api.spec.ts index 85c5abc2b..c089f13bf 100644 --- a/packages/agent/tests/dwn-api.spec.ts +++ b/packages/agent/tests/dwn-api.spec.ts @@ -486,12 +486,12 @@ describe('AgentDwnApi', () => { const readReply = readResponse.reply; expect(readReply).to.have.property('status'); expect(readReply.status.code).to.equal(200); - expect(readReply).to.have.property('record'); - expect(readReply.record).to.have.property('data'); - expect(readReply.record).to.have.property('descriptor'); - expect(readReply.record).to.have.property('recordId', writeMessage.recordId); + expect(readReply).to.have.property('entry'); + expect(readReply.entry).to.have.property('data'); + expect(readReply.entry!.recordsWrite).to.have.property('descriptor'); + expect(readReply.entry!.recordsWrite).to.have.property('recordId', writeMessage.recordId); - const readDataBytes = await NodeStream.consumeToBytes({ readable: readReply.record!.data }); + const readDataBytes = await NodeStream.consumeToBytes({ readable: readReply.entry!.data! }); expect(readDataBytes).to.deep.equal(dataBytes); }); @@ -1529,12 +1529,12 @@ describe('AgentDwnApi', () => { const readReply = readResponse.reply; expect(readReply).to.have.property('status'); expect(readReply.status.code).to.equal(200); - expect(readReply).to.have.property('record'); - expect(readReply.record).to.have.property('data'); - expect(readReply.record).to.have.property('descriptor'); - expect(readReply.record).to.have.property('recordId', writeMessage.recordId); + expect(readReply).to.have.property('entry'); + expect(readReply.entry).to.have.property('data'); + expect(readReply.entry?.recordsWrite).to.have.property('descriptor'); + expect(readReply.entry?.recordsWrite).to.have.property('recordId', writeMessage.recordId); - const dataStream: ReadableStream | Readable = readReply.record!.data; + const dataStream: ReadableStream | Readable = readReply.entry!.data!; // If the data stream is a web ReadableStream, convert it to a Node.js Readable. const nodeReadable = Stream.isReadableStream(dataStream) ? NodeStream.fromWebReadable({ readableStream: dataStream }) : diff --git a/packages/agent/tests/prototyping/clients/http-dwn-rpc-client.spec.ts b/packages/agent/tests/prototyping/clients/http-dwn-rpc-client.spec.ts index b860d041f..1cf3e5b11 100644 --- a/packages/agent/tests/prototyping/clients/http-dwn-rpc-client.spec.ts +++ b/packages/agent/tests/prototyping/clients/http-dwn-rpc-client.spec.ts @@ -74,8 +74,8 @@ describe('HttpDwnRpcClient', () => { // should return success, and the record we inserted expect(readResponse.status.code).to.equal(200); - expect(readResponse.record).to.exist; - expect(readResponse.record?.recordId).to.equal(writeMessage.recordId); + expect(readResponse.entry).to.exist; + expect(readResponse.entry?.recordsWrite?.recordId).to.equal(writeMessage.recordId); }); it('throws error if invalid response exists in the header', async () => { diff --git a/packages/agent/tests/prototyping/clients/ws-dwn-rpc-client.spec.ts b/packages/agent/tests/prototyping/clients/ws-dwn-rpc-client.spec.ts index 4d3d84d5f..e1d68f013 100644 --- a/packages/agent/tests/prototyping/clients/ws-dwn-rpc-client.spec.ts +++ b/packages/agent/tests/prototyping/clients/ws-dwn-rpc-client.spec.ts @@ -144,8 +144,8 @@ describe('WebSocketDwnRpcClient', () => { // should return success, and the record we inserted expect(readResponse.status.code).to.equal(200); - expect(readResponse.record).to.exist; - expect(readResponse.record?.recordId).to.equal(writeMessage.recordId); + expect(readResponse.entry).to.exist; + expect(readResponse.entry?.recordsWrite?.recordId).to.equal(writeMessage.recordId); }); it('subscribes to updates to a record', async () => { diff --git a/packages/agent/tests/sync-engine-level.spec.ts b/packages/agent/tests/sync-engine-level.spec.ts index 3d5653e03..4ce1a509d 100644 --- a/packages/agent/tests/sync-engine-level.spec.ts +++ b/packages/agent/tests/sync-engine-level.spec.ts @@ -1109,9 +1109,9 @@ describe('SyncEngineLevel', () => { messageParams : { filter: { recordId: writeResponse.message!.recordId } } }); expect(readResponse.reply.status.code).to.equal(200); - expect(readResponse.reply.record).to.exist; - expect(readResponse.reply.record!.data).to.exist; - expect(readResponse.reply.record!.descriptor.dataSize).to.equal(LARGE_DATA_SIZE); + expect(readResponse.reply.entry).to.exist; + expect(readResponse.reply.entry!.data).to.exist; + expect(readResponse.reply.entry!.recordsWrite!.descriptor.dataSize).to.equal(LARGE_DATA_SIZE); }).slow(1200); // Yellow at 600ms, Red at 1200ms. it('synchronizes records for multiple identities from remote DWN to local DWN', async () => { @@ -1776,8 +1776,8 @@ describe('SyncEngineLevel', () => { }); const reply = readRecord.reply; expect(reply.status.code).to.equal(200); - expect(reply.record).to.not.be.undefined; - expect(reply.record!.data).to.not.be.undefined; + expect(reply.entry).to.exist; + expect(reply.entry!.data).to.exist; }).slow(1200); // Yellow at 600ms, Red at 1200ms. it('synchronizes records for multiple identities from local DWN to remote DWN', async () => { diff --git a/packages/api/package.json b/packages/api/package.json index b9717cd48..590f7474b 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -85,7 +85,7 @@ }, "devDependencies": { "@playwright/test": "1.45.3", - "@tbd54566975/dwn-sdk-js": "0.4.7", + "@tbd54566975/dwn-sdk-js": "0.5.1", "@types/chai": "4.3.6", "@types/eslint": "8.56.10", "@types/mocha": "10.0.1", @@ -109,4 +109,4 @@ "source-map-loader": "4.0.2", "typescript": "5.1.6" } -} +} \ No newline at end of file diff --git a/packages/api/src/dwn-api.ts b/packages/api/src/dwn-api.ts index 464b1bb00..e91f21622 100644 --- a/packages/api/src/dwn-api.ts +++ b/packages/api/src/dwn-api.ts @@ -764,7 +764,7 @@ export class DwnApi { agentResponse = await this.agent.processDwnRequest(agentRequest); } - const { reply: { record: responseRecord, status } } = agentResponse; + const { reply: { entry, status } } = agentResponse; let record: Record; if (200 <= status.code && status.code <= 299) { @@ -773,7 +773,7 @@ export class DwnApi { * Extract the `author` DID from the record since records may be signed by the * tenant owner or any other entity. */ - author : getRecordAuthor(responseRecord), + author : getRecordAuthor(entry.recordsWrite), /** * Set the `connectedDid` to currently connected DID so that subsequent calls to * {@link Record} instance methods, such as `record.update()` are executed on the @@ -788,7 +788,9 @@ export class DwnApi { */ remoteOrigin : request.from, delegateDid : this.delegateDid, - ...responseRecord, + data : entry.data, + initialWrite : entry.initialWrite, + ...entry.recordsWrite, }; record = new Record(this.agent, recordOptions, this.permissionsApi); diff --git a/packages/api/src/record.ts b/packages/api/src/record.ts index bb0c51055..47b703c24 100644 --- a/packages/api/src/record.ts +++ b/packages/api/src/record.ts @@ -1062,12 +1062,12 @@ export class Record implements RecordModel { this._agent.processDwnRequest(readRequest); try { - const { reply: { status, record }} = await agentResponsePromise; + const { reply: { status, entry }} = await agentResponsePromise; if (status.code !== 200) { throw new Error(`${status.code}: ${status.detail}`); } - const dataStream: ReadableStream | Readable = record.data; + const dataStream: ReadableStream | Readable = entry.data; // If the data stream is a web ReadableStream, convert it to a Node.js Readable. const nodeReadable = Stream.isReadableStream(dataStream) ? NodeStream.fromWebReadable({ readableStream: dataStream }) : diff --git a/packages/dev-env/docker-compose.yaml b/packages/dev-env/docker-compose.yaml index f4beb63af..25cc3690d 100644 --- a/packages/dev-env/docker-compose.yaml +++ b/packages/dev-env/docker-compose.yaml @@ -3,6 +3,6 @@ version: "3.98" services: dwn-server: container_name: dwn-server - image: ghcr.io/tbd54566975/dwn-server:0.4.10 + image: ghcr.io/tbd54566975/dwn-server:0.6.0 ports: - "3000:3000" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3252bf6e3..c9ace1012 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -41,8 +41,8 @@ importers: specifier: 7.9.0 version: 7.9.0(@typescript-eslint/parser@7.14.1(eslint@9.7.0)(typescript@5.5.4))(eslint@9.7.0)(typescript@5.5.4) '@web5/dwn-server': - specifier: 0.4.10 - version: 0.4.10 + specifier: 0.6.0 + version: 0.6.0 audit-ci: specifier: ^7.0.1 version: 7.1.0 @@ -65,8 +65,8 @@ importers: specifier: 1.2.2 version: 1.2.2 '@tbd54566975/dwn-sdk-js': - specifier: 0.4.7 - version: 0.4.7 + specifier: 0.5.1 + version: 0.5.1 '@web5/common': specifier: workspace:* version: link:../common @@ -193,8 +193,8 @@ importers: specifier: 1.45.3 version: 1.45.3 '@tbd54566975/dwn-sdk-js': - specifier: 0.4.7 - version: 0.4.7 + specifier: 0.5.1 + version: 0.5.1 '@types/chai': specifier: 4.3.6 version: 4.3.6 @@ -2176,12 +2176,12 @@ packages: '@sphereon/ssi-types@0.26.0': resolution: {integrity: sha512-r4JQIN7rnPunEv0HvCFC1ZCc9qlWcegYvhJbMJqSvyFE6VhmT5NNdH9jNV9QetgMa0yo5r3k+TnHNv3nH58Dmg==} - '@tbd54566975/dwn-sdk-js@0.4.7': - resolution: {integrity: sha512-VYaLT4FKdHfVvUPZbicUpF77erkOSi1xBP/EVQIpnp0khPujp2lYcojbRcw4c4JR23CrRvLPy/iWXmEhdP8LqA==} + '@tbd54566975/dwn-sdk-js@0.5.1': + resolution: {integrity: sha512-4xfDttiXOzs7h3PHODflHxHP7Z1HlNod6BN+HX6elXKlqOlBueORrzB72BnzVBbv35eDRJR5w2upmGsUoq3dGg==} engines: {node: '>= 18'} - '@tbd54566975/dwn-sql-store@0.6.7': - resolution: {integrity: sha512-5v/BudrItBx8UUMEIH42nMBwykpM9ZyBpMERmWwJn06Xe47wv+ojkDhVX000Npuv4q+bsLv0lQhCaIAmKcMlaQ==} + '@tbd54566975/dwn-sql-store@0.6.8': + resolution: {integrity: sha512-2F1ACH9GKUBQm8kEKzyLdWw36Dakhx+Z8HAbPsNqbj9w8qht/AEykTJNhvcAi07G2Un83PfqCYDJURs8tM92tA==} engines: {node: '>=18'} '@tootallnate/quickjs-emscripten@0.23.0': @@ -2559,6 +2559,10 @@ packages: resolution: {integrity: sha512-dxczXqzWt6HCwuNyOVBeakg6GgOpP74tVEVxBeKkb+D3XcSP96mYaDtky5ZnjY4iBYb16SaCgwje+sgevOL51A==} engines: {node: '>=18.0.0'} + '@web5/common@1.0.2': + resolution: {integrity: sha512-SerGdrxZF47yidvhrRa8sGLEOunIlDHppxrtWYCuKMVgtQKgheEmaS4+xchGAc/mZggJX4LlwJbRuniIiSaXrw==} + engines: {node: '>=18.0.0'} + '@web5/crypto@1.0.3': resolution: {integrity: sha512-gZJKo0scX+L53E2K/5cgEiFYxejzHP2RSg64ncF6TitOnCNxUyWjofovgufb+u3ZpGC4iuliD7V0o1C+V73Law==} engines: {node: '>=18.0.0'} @@ -2567,8 +2571,8 @@ packages: resolution: {integrity: sha512-M9EfsEYcOtYuEvUQjow4vpxXbD0Sz5H8EuDXMtwuvP4UdYL0ATl+60F8+8HDmwPFeUy6M2wxuoixrLDwSRFwZA==} engines: {node: '>=18.0.0'} - '@web5/dwn-server@0.4.10': - resolution: {integrity: sha512-gdXIDC4OkCS58+EG85SN82IeWynl3uqkpeoq79A6X9NCGWO9+5XM5pNKCjkPxxNdsGfz0sX+nYLkSqrRX5BcFA==} + '@web5/dwn-server@0.6.0': + resolution: {integrity: sha512-jsY/RnefkDSJi8RVtWycc4InyBPZoohY2gntICNwbAzk1D7tJotArJIp7D8So9Id5eIau2SxJjSKkYoAWuedkQ==} hasBin: true '@webassemblyjs/ast@1.12.1': @@ -7423,7 +7427,7 @@ snapshots: transitivePeerDependencies: - supports-color - '@tbd54566975/dwn-sdk-js@0.4.7': + '@tbd54566975/dwn-sdk-js@0.5.1': dependencies: '@ipld/dag-cbor': 9.0.3 '@js-temporal/polyfill': 0.4.4 @@ -7456,10 +7460,10 @@ snapshots: - encoding - supports-color - '@tbd54566975/dwn-sql-store@0.6.7': + '@tbd54566975/dwn-sql-store@0.6.8': dependencies: '@ipld/dag-cbor': 9.0.5 - '@tbd54566975/dwn-sdk-js': 0.4.7 + '@tbd54566975/dwn-sdk-js': 0.5.1 kysely: 0.26.3 multiformats: 12.0.1 readable-stream: 4.4.2 @@ -8359,6 +8363,13 @@ snapshots: multiformats: 13.1.0 readable-stream: 4.4.2 + '@web5/common@1.0.2': + dependencies: + '@isaacs/ttlcache': 1.4.1 + level: 8.0.1 + multiformats: 13.1.0 + readable-stream: 4.5.2 + '@web5/crypto@1.0.3': dependencies: '@noble/ciphers': 0.5.3 @@ -8378,11 +8389,13 @@ snapshots: level: 8.0.1 ms: 2.1.3 - '@web5/dwn-server@0.4.10': + '@web5/dwn-server@0.6.0': dependencies: - '@tbd54566975/dwn-sdk-js': 0.4.7 - '@tbd54566975/dwn-sql-store': 0.6.7 + '@tbd54566975/dwn-sdk-js': 0.5.1 + '@tbd54566975/dwn-sql-store': 0.6.8 + '@web5/common': 1.0.2 '@web5/crypto': 1.0.3 + '@web5/dids': 1.1.3 better-sqlite3: 8.7.0 body-parser: 1.20.3 bytes: 3.1.2