Skip to content

Commit

Permalink
Updated dwn-sdk-js dependency to v0.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
thehenrytsai committed Oct 8, 2024
1 parent bfa0417 commit 565f95a
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 15 deletions.
4 changes: 2 additions & 2 deletions packages/agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down Expand Up @@ -110,4 +110,4 @@
"sinon": "18.0.0",
"typescript": "5.1.6"
}
}
}
4 changes: 2 additions & 2 deletions packages/agent/src/store-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,12 @@ export class DwnDataStore<TStoreObject extends Record<string, any> = 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) {
Expand Down
4 changes: 2 additions & 2 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -109,4 +109,4 @@
"source-map-loader": "4.0.2",
"typescript": "5.1.6"
}
}
}
8 changes: 5 additions & 3 deletions packages/api/src/dwn-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) :
Expand Down
45 changes: 41 additions & 4 deletions pnpm-lock.yaml

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

0 comments on commit 565f95a

Please sign in to comment.