Skip to content

Commit

Permalink
Bump dwn-sdk-js version to 0.2.6 and fix bugs (#290)
Browse files Browse the repository at this point in the history
* This PR primarily bumps the dwn-sdk-js version from 0.2.4 to 0.2.6, fixes several bugs, and improves type safety.
  • Loading branch information
Diane Huxley authored Nov 18, 2023
1 parent 22d5f3d commit 50c27ec
Show file tree
Hide file tree
Showing 19 changed files with 4,504 additions and 1,939 deletions.
5,934 changes: 4,162 additions & 1,772 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/agent/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
]
}
]
}
}
4 changes: 2 additions & 2 deletions packages/agent/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web5/agent",
"version": "0.2.3",
"version": "0.2.4",
"type": "module",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
Expand Down Expand Up @@ -67,7 +67,7 @@
"node": ">=18.0.0"
},
"dependencies": {
"@tbd54566975/dwn-sdk-js": "0.2.4",
"@tbd54566975/dwn-sdk-js": "0.2.6",
"@web5/common": "0.2.1",
"@web5/crypto": "0.2.2",
"@web5/dids": "0.2.2",
Expand Down
22 changes: 11 additions & 11 deletions packages/agent/src/dwn-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,12 @@ export class DwnManager {
}
}

const dwnAuthorizationSigner = await this.constructDwnAuthorizationSigner(request.author);
const dwnSigner = await this.constructDwnSigner(request.author);

const messageCreator = dwnMessageCreators[request.messageType];
const dwnMessage = await messageCreator.create({
...<any>request.messageOptions,
authorizationSigner: dwnAuthorizationSigner
signer: dwnSigner
});

return { message: dwnMessage.toJSON(), dataStream: readableStream };
Expand All @@ -299,7 +299,7 @@ export class DwnManager {
return signingKeyId;
}

private async constructDwnAuthorizationSigner(author: string): Promise<Signer> {
private async constructDwnSigner(author: string): Promise<Signer> {
const signingKeyId = await this.getAuthorSigningKeyId({ did: author });

/**
Expand Down Expand Up @@ -341,11 +341,11 @@ export class DwnManager {
}): Promise<DwnMessage> {
const { author, messageType, messageCid } = options;

const dwnAuthorizationSigner = await this.constructDwnAuthorizationSigner(author);
const dwnSigner = await this.constructDwnSigner(author);

const messagesGet = await MessagesGet.create({
authorizationSigner : dwnAuthorizationSigner,
messageCids : [messageCid]
messageCids : [messageCid],
signer : dwnSigner
});

const result: MessagesGetReply = await this._dwn.processMessage(author, messagesGet.message);
Expand Down Expand Up @@ -374,10 +374,10 @@ export class DwnManager {
dwnMessage.data = new Blob([dataBytes]);
} else {
const recordsRead = await RecordsRead.create({
authorizationSigner : dwnAuthorizationSigner,
filter : {
filter: {
recordId: writeMessage.recordId
}
},
signer: dwnSigner
});

const reply = await this._dwn.processMessage(author, recordsRead.toJSON()) as RecordsReadReply;
Expand Down Expand Up @@ -409,13 +409,13 @@ export class DwnManager {
}): Promise<EventsGet | MessagesGet | RecordsRead | RecordsQuery | RecordsWrite | RecordsDelete | ProtocolsQuery | ProtocolsConfigure> {
const { author, messageOptions, messageType } = options;

const dwnAuthorizationSigner = await this.constructDwnAuthorizationSigner(author);
const dwnSigner = await this.constructDwnSigner(author);

const messageCreator = dwnMessageCreators[messageType];

const dwnMessage = await messageCreator.create({
...<any>messageOptions,
authorizationSigner: dwnAuthorizationSigner
signer: dwnSigner
});

return dwnMessage;
Expand Down
3 changes: 2 additions & 1 deletion packages/agent/src/types/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Readable } from 'readable-stream';
import type { DidResolutionOptions, DidResolutionResult, PortableDid } from '@web5/dids';
import type {
EventsGetMessage,
RecordsReadReply,
UnionMessageReply,
MessagesGetMessage,
RecordsQueryMessage,
Expand Down Expand Up @@ -86,7 +87,7 @@ export type SendDwnRequest = DwnRequest & (ProcessDwnRequest | { messageCid: str
export type DwnResponse = {
message?: unknown;
messageCid?: string;
reply: UnionMessageReply;
reply: UnionMessageReply & RecordsReadReply;
};

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/agent/tests/test-config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
declare const __karma__: { config?: { testDwnUrl?: string; } };

const DEFAULT_TEST_DWN_URL = 'https://dwn.tbddev.org/dwn0';
const DEFAULT_TEST_DWN_URL = 'http://localhost:3000';

function getTestDwnUrl(): string {
// Check to see if we're running in a Karma browser test environment.
Expand Down
8 changes: 4 additions & 4 deletions packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web5/api",
"version": "0.8.2",
"version": "0.8.3",
"description": "SDK for accessing the features and capabilities of Web5",
"type": "module",
"main": "./dist/cjs/index.js",
Expand Down Expand Up @@ -75,11 +75,11 @@
"node": ">=18.0.0"
},
"dependencies": {
"@tbd54566975/dwn-sdk-js": "0.2.4",
"@web5/agent": "0.2.3",
"@tbd54566975/dwn-sdk-js": "0.2.6",
"@web5/agent": "0.2.4",
"@web5/crypto": "0.2.2",
"@web5/dids": "0.2.2",
"@web5/user-agent": "0.2.3",
"@web5/user-agent": "0.2.4",
"level": "8.0.0",
"ms": "2.1.3",
"readable-stream": "4.4.2",
Expand Down
Loading

0 comments on commit 50c27ec

Please sign in to comment.