Skip to content

Commit cc3aa58

Browse files
Added wallet connect options for Web5.connect() (#694)
- Added WalletConnectOptions for the connect flow. - Updated to latest `dwn-sdk-js` (v0.3.10) - Fixed npm audit vulnerability GHSA-3h5v-q93c-6h6q - Updated "agent" dependencies using `workspace:*` syntax to always keep "agent" dependency in sync to avoid manual updates/mistakes. --------- Co-authored-by: Liran Cohen <c.liran.c@gmail.com>
1 parent 617e9a9 commit cc3aa58

22 files changed

Lines changed: 340 additions & 556 deletions

File tree

.changeset/famous-otters-kick.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
"@web5/crypto-aws-kms": patch
3+
"@web5/identity-agent": patch
4+
"@web5/credentials": patch
5+
"@web5/proxy-agent": patch
6+
"@web5/user-agent": patch
7+
"@web5/common": patch
8+
"@web5/crypto": patch
9+
"@web5/agent": patch
10+
"@web5/dids": patch
11+
---
12+
13+
Dependency updates.

.changeset/rare-garlics-kneel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@web5/api": minor
3+
---
4+
5+
Added WalletConnectOptions and updated dwn-sdk-js dependencies.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@
3131
"@changesets/cli": "^2.27.5",
3232
"@npmcli/package-json": "5.0.0",
3333
"@typescript-eslint/eslint-plugin": "7.9.0",
34-
"@web5/dwn-server": "0.2.3",
34+
"@web5/dwn-server": "0.3.1",
3535
"audit-ci": "^7.0.1",
3636
"eslint-plugin-mocha": "10.4.3",
3737
"npkill": "0.11.3"
3838
},
3939
"pnpm": {
4040
"overrides": {
41-
"express@<4.19.2": ">=4.19.2"
41+
"express@<4.19.2": ">=4.19.2",
42+
"ws@<8.17.1": ">=8.17.1"
4243
}
4344
}
4445
}

packages/agent/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"dependencies": {
7272
"@noble/ciphers": "0.4.1",
7373
"@scure/bip39": "1.2.2",
74-
"@tbd54566975/dwn-sdk-js": "0.3.5",
74+
"@tbd54566975/dwn-sdk-js": "0.3.10",
7575
"@web5/common": "1.0.0",
7676
"@web5/crypto": "1.0.0",
7777
"@web5/dids": "1.1.0",
@@ -93,8 +93,8 @@
9393
"@types/node": "20.11.19",
9494
"@types/sinon": "17.0.2",
9595
"@typescript-eslint/eslint-plugin": "7.9.0",
96-
"@typescript-eslint/parser": "7.9.0",
97-
"@web/test-runner": "0.18.0",
96+
"@typescript-eslint/parser": "7.14.1",
97+
"@web/test-runner": "0.18.2",
9898
"@web/test-runner-playwright": "0.11.0",
9999
"abstract-level": "1.0.4",
100100
"c8": "9.1.0",

packages/agent/src/dwn-api.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { DwnConfig, GenericMessage, UnionMessageReply } from '@tbd54566975/
44
import { Convert, NodeStream } from '@web5/common';
55
import { utils as cryptoUtils } from '@web5/crypto';
66
import { DidDht, DidJwk, DidResolverCacheLevel, UniversalResolver } from '@web5/dids';
7-
import { Cid, DataStoreLevel, Dwn, DwnMethodName, EventLogLevel, Message, MessageStoreLevel } from '@tbd54566975/dwn-sdk-js';
7+
import { Cid, DataStoreLevel, Dwn, DwnMethodName, EventLogLevel, Message, MessageStoreLevel, ResumableTaskStoreLevel } from '@tbd54566975/dwn-sdk-js';
88

99
import type { Web5PlatformAgent } from './types/agent.js';
1010
import type { DwnMessage, DwnMessageInstance, DwnMessageParams, DwnMessageReply, DwnMessageWithData, DwnResponse, DwnSigner, MessageHandler, ProcessDwnRequest, SendDwnRequest } from './types/dwn.js';
@@ -95,7 +95,7 @@ export class AgentDwnApi {
9595
}
9696

9797
public static async createDwn({
98-
dataPath, dataStore, didResolver, eventLog, eventStream, messageStore, tenantGate
98+
dataPath, dataStore, didResolver, eventLog, eventStream, messageStore, tenantGate, resumableTaskStore
9999
}: DwnApiCreateDwnParams): Promise<Dwn> {
100100
dataStore ??= new DataStoreLevel({ blockstoreLocation: `${dataPath}/DWN_DATASTORE` });
101101

@@ -111,7 +111,9 @@ export class AgentDwnApi {
111111
indexLocation : `${dataPath}/DWN_MESSAGEINDEX`
112112
}));
113113

114-
return await Dwn.create({ dataStore, didResolver, eventLog, eventStream, messageStore, tenantGate });
114+
resumableTaskStore ??= new ResumableTaskStoreLevel({ location: `${dataPath}/DWN_RESUMABLETASKSTORE` });
115+
116+
return await Dwn.create({ dataStore, didResolver, eventLog, eventStream, messageStore, tenantGate, resumableTaskStore });
115117
}
116118

117119
public async processRequest<T extends DwnInterface>(

packages/agent/src/prototyping/clients/dwn-rpc-types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import type { RecordsReadReply, UnionMessageReply, EventSubscriptionHandler, RecordSubscriptionHandler } from '@tbd54566975/dwn-sdk-js';
1+
import type { RecordsReadReply, UnionMessageReply, MessageSubscriptionHandler, RecordSubscriptionHandler } from '@tbd54566975/dwn-sdk-js';
22

33
export interface SerializableDwnMessage {
44
toJSON(): string;
55
}
66

7-
export type DwnSubscriptionHandler = EventSubscriptionHandler | RecordSubscriptionHandler;
7+
export type DwnSubscriptionHandler = MessageSubscriptionHandler | RecordSubscriptionHandler;
88

99
/**
1010
* Interface for communicating with {@link https://github.com/TBD54566975/dwn-server | DWN Servers}

packages/agent/src/sync-engine-level.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ULIDFactory } from 'ulidx';
22
import type { AbstractBatchOperation, AbstractLevel } from 'abstract-level';
33
import type {
4-
EventsGetReply,
4+
EventsQueryReply,
55
GenericMessage,
66
MessagesGetReply,
77
PaginationCursor,
@@ -355,22 +355,22 @@ export class SyncEngineLevel implements SyncEngine {
355355
syncDirection: SyncDirection,
356356
cursor?: PaginationCursor
357357
}) {
358-
let eventsReply = {} as EventsGetReply;
358+
let eventsReply = {} as EventsQueryReply;
359359

360360
if (syncDirection === 'pull') {
361361
// When sync is a pull, get the event log from the remote DWN.
362362
const eventsGetMessage = await this.agent.dwn.createMessage({
363363
author : did,
364-
messageType : DwnInterface.EventsGet,
365-
messageParams : { cursor }
364+
messageType : DwnInterface.EventsQuery,
365+
messageParams : { filters: [], cursor }
366366
});
367367

368368
try {
369369
eventsReply = await this.agent.rpc.sendDwnRequest({
370370
dwnUrl : dwnUrl,
371371
targetDid : did,
372372
message : eventsGetMessage
373-
}) as EventsGetReply;
373+
}) as EventsQueryReply;
374374
} catch {
375375
// If a particular DWN service endpoint is unreachable, silently ignore.
376376
}
@@ -380,10 +380,10 @@ export class SyncEngineLevel implements SyncEngine {
380380
const eventsGetDwnResponse = await this.agent.dwn.processRequest({
381381
author : did,
382382
target : did,
383-
messageType : DwnInterface.EventsGet,
384-
messageParams : { cursor }
383+
messageType : DwnInterface.EventsQuery,
384+
messageParams : { filters: [], cursor }
385385
});
386-
eventsReply = eventsGetDwnResponse.reply as EventsGetReply;
386+
eventsReply = eventsGetDwnResponse.reply as EventsQueryReply;
387387
}
388388

389389
const eventLog = eventsReply.entries ?? [];

packages/agent/src/test-harness.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { AbstractLevel } from 'abstract-level';
33

44
import { Level } from 'level';
55
import { LevelStore, MemoryStore } from '@web5/common';
6-
import { DataStoreLevel, Dwn, EventEmitterStream, EventLogLevel, MessageStoreLevel } from '@tbd54566975/dwn-sdk-js';
6+
import { DataStoreLevel, Dwn, EventEmitterStream, EventLogLevel, MessageStoreLevel, ResumableTaskStoreLevel } from '@tbd54566975/dwn-sdk-js';
77
import { DidDht, DidJwk, DidResolutionResult, DidResolverCache, DidResolverCacheLevel } from '@web5/dids';
88

99
import type { Web5PlatformAgent } from './types/agent.js';
@@ -32,6 +32,7 @@ type PlatformAgentTestHarnessParams = {
3232
dwnDataStore: DataStoreLevel;
3333
dwnEventLog: EventLogLevel;
3434
dwnMessageStore: MessageStoreLevel;
35+
dwnResumableTaskStore: ResumableTaskStoreLevel;
3536
syncStore: AbstractLevel<string | Buffer | Uint8Array>;
3637
vaultStore: KeyValueStore<string, string>;
3738
}
@@ -51,6 +52,7 @@ export class PlatformAgentTestHarness {
5152
public dwnDataStore: DataStoreLevel;
5253
public dwnEventLog: EventLogLevel;
5354
public dwnMessageStore: MessageStoreLevel;
55+
public dwnResumableTaskStore: ResumableTaskStoreLevel;
5456
public syncStore: AbstractLevel<string | Buffer | Uint8Array>;
5557
public vaultStore: KeyValueStore<string, string>;
5658

@@ -64,6 +66,7 @@ export class PlatformAgentTestHarness {
6466
this.dwnMessageStore = params.dwnMessageStore;
6567
this.syncStore = params.syncStore;
6668
this.vaultStore = params.vaultStore;
69+
this.dwnResumableTaskStore = params.dwnResumableTaskStore;
6770
}
6871

6972
public async clearStorage(): Promise<void> {
@@ -73,6 +76,7 @@ export class PlatformAgentTestHarness {
7376
await this.dwnDataStore.clear();
7477
await this.dwnEventLog.clear();
7578
await this.dwnMessageStore.clear();
79+
await this.dwnResumableTaskStore.clear();
7680
await this.syncStore.clear();
7781
await this.vaultStore.clear();
7882

@@ -98,6 +102,7 @@ export class PlatformAgentTestHarness {
98102
await this.dwnDataStore.close();
99103
await this.dwnEventLog.close();
100104
await this.dwnMessageStore.close();
105+
await this.dwnResumableTaskStore.close();
101106
await this.syncStore.close();
102107
await this.vaultStore.close();
103108
}
@@ -181,6 +186,7 @@ export class PlatformAgentTestHarness {
181186
const dwnDataStore = new DataStoreLevel({ blockstoreLocation: testDataPath('DWN_DATASTORE') });
182187
const dwnEventLog = new EventLogLevel({ location: testDataPath('DWN_EVENTLOG') });
183188
const dwnEventStream = new EventEmitterStream();
189+
const dwnResumableTaskStore = new ResumableTaskStoreLevel({ location: testDataPath('DWN_RESUMABLETASKSTORE') });
184190

185191
const dwnMessageStore = new MessageStoreLevel({
186192
blockstoreLocation : testDataPath('DWN_MESSAGESTORE'),
@@ -189,12 +195,13 @@ export class PlatformAgentTestHarness {
189195

190196
// Instantiate DWN instance using the custom stores.
191197
const dwn = await AgentDwnApi.createDwn({
192-
dataPath : testDataLocation,
193-
dataStore : dwnDataStore,
194-
didResolver : didApi,
195-
eventLog : dwnEventLog,
196-
eventStream : dwnEventStream,
197-
messageStore : dwnMessageStore,
198+
dataPath : testDataLocation,
199+
dataStore : dwnDataStore,
200+
didResolver : didApi,
201+
eventLog : dwnEventLog,
202+
eventStream : dwnEventStream,
203+
messageStore : dwnMessageStore,
204+
resumableTaskStore : dwnResumableTaskStore
198205
});
199206

200207
// Instantiate Agent's DWN API using the custom DWN instance.
@@ -225,6 +232,7 @@ export class PlatformAgentTestHarness {
225232
dwnDataStore,
226233
dwnEventLog,
227234
dwnMessageStore,
235+
dwnResumableTaskStore,
228236
syncStore,
229237
vaultStore
230238
});

packages/agent/src/types/dwn.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import type { DidService } from '@web5/dids';
22
import type { Readable, RequireOnly } from '@web5/common';
33
import type {
4-
EventsGetReply,
5-
EventsGetOptions,
6-
EventsGetMessage,
74
EventsQueryReply,
85
MessagesGetReply,
96
RecordsReadReply,
@@ -32,12 +29,11 @@ import type {
3229
RecordsSubscribeOptions,
3330
EventsSubscribeReply,
3431
RecordsSubscribeReply,
32+
MessageSubscriptionHandler,
3533
RecordSubscriptionHandler,
36-
EventSubscriptionHandler,
3734
} from '@tbd54566975/dwn-sdk-js';
3835

3936
import {
40-
EventsGet,
4137
MessagesGet,
4238
RecordsRead,
4339
RecordsQuery,
@@ -91,7 +87,6 @@ export interface DwnDidService extends DidService {
9187
}
9288

9389
export enum DwnInterface {
94-
EventsGet = DwnInterfaceName.Events + DwnMethodName.Get,
9590
EventsQuery = DwnInterfaceName.Events + DwnMethodName.Query,
9691
EventsSubscribe = DwnInterfaceName.Events + DwnMethodName.Subscribe,
9792
MessagesGet = DwnInterfaceName.Messages + DwnMethodName.Get,
@@ -105,7 +100,6 @@ export enum DwnInterface {
105100
}
106101

107102
export interface DwnMessage {
108-
[DwnInterface.EventsGet] : EventsGetMessage;
109103
[DwnInterface.EventsSubscribe] : EventsSubscribeMessage;
110104
[DwnInterface.EventsQuery] : EventsQueryMessage;
111105
[DwnInterface.MessagesGet] : MessagesGetMessage;
@@ -119,7 +113,6 @@ export interface DwnMessage {
119113
}
120114

121115
export interface DwnMessageDescriptor {
122-
[DwnInterface.EventsGet] : EventsGetMessage['descriptor'];
123116
[DwnInterface.EventsSubscribe] : EventsSubscribeMessage['descriptor'];
124117
[DwnInterface.EventsQuery] : EventsQueryMessage['descriptor'];
125118
[DwnInterface.MessagesGet] : MessagesGetMessage['descriptor'];
@@ -133,7 +126,6 @@ export interface DwnMessageDescriptor {
133126
}
134127

135128
export interface DwnMessageParams {
136-
[DwnInterface.EventsGet] : Partial<EventsGetOptions>;
137129
[DwnInterface.EventsQuery] : RequireOnly<EventsQueryOptions, 'filters'>;
138130
[DwnInterface.EventsSubscribe] : Partial<EventsSubscribeOptions>;
139131
[DwnInterface.MessagesGet] : RequireOnly<MessagesGetOptions, 'messageCids'>;
@@ -147,7 +139,6 @@ export interface DwnMessageParams {
147139
}
148140

149141
export interface DwnMessageReply {
150-
[DwnInterface.EventsGet] : EventsGetReply;
151142
[DwnInterface.EventsQuery] : EventsQueryReply;
152143
[DwnInterface.EventsSubscribe] : EventsSubscribeReply;
153144
[DwnInterface.MessagesGet] : MessagesGetReply;
@@ -161,11 +152,10 @@ export interface DwnMessageReply {
161152
}
162153

163154
export interface MessageHandler {
164-
[DwnInterface.EventsSubscribe] : EventSubscriptionHandler;
155+
[DwnInterface.EventsSubscribe] : MessageSubscriptionHandler;
165156
[DwnInterface.RecordsSubscribe] : RecordSubscriptionHandler;
166157

167158
// define all of them individually as undefined
168-
[DwnInterface.EventsGet] : undefined;
169159
[DwnInterface.EventsQuery] : undefined;
170160
[DwnInterface.MessagesGet] : undefined;
171161
[DwnInterface.ProtocolsConfigure] : undefined;
@@ -220,7 +210,6 @@ export interface DwnMessageConstructor<T extends DwnInterface> {
220210
}
221211

222212
export const dwnMessageConstructors: { [T in DwnInterface]: DwnMessageConstructor<T> } = {
223-
[DwnInterface.EventsGet] : EventsGet as any,
224213
[DwnInterface.EventsQuery] : EventsQuery as any,
225214
[DwnInterface.EventsSubscribe] : EventsSubscribe as any,
226215
[DwnInterface.MessagesGet] : MessagesGet as any,
@@ -236,7 +225,6 @@ export const dwnMessageConstructors: { [T in DwnInterface]: DwnMessageConstructo
236225
export type DwnMessageConstructors = typeof dwnMessageConstructors;
237226

238227
export interface DwnMessageInstance {
239-
[DwnInterface.EventsGet] : EventsGet;
240228
[DwnInterface.EventsQuery] : EventsQuery;
241229
[DwnInterface.EventsSubscribe] : EventsSubscribe;
242230
[DwnInterface.MessagesGet] : MessagesGet;
@@ -264,9 +252,14 @@ export {
264252
DateSort as DwnDateSort,
265253
PublicJwk as DwnPublicKeyJwk, // TODO: Remove once DWN SDK switches to Jwk from @web5/crypto
266254
PaginationCursor as DwnPaginationCursor,
267-
EventSubscriptionHandler as DwnEventSubscriptionHandler,
255+
MessageSubscriptionHandler as DwnMessageSubscriptionHandler,
268256
RecordSubscriptionHandler as DwnRecordSubscriptionHandler,
269257
MessageSubscription as DwnMessageSubscription,
270258
EncryptionAlgorithm as DwnEncryptionAlgorithm,
271259
KeyDerivationScheme as DwnKeyDerivationScheme,
260+
PermissionGrant as DwnPermissionGrant,
261+
PermissionRequest as DwnPermissionRequest,
262+
PermissionsProtocol as DwnPermissionsProtocol,
263+
ProtocolDefinition as DwnProtocolDefinition,
264+
RecordsPermissionScope as DwnRecordsPermissionScope,
272265
} from '@tbd54566975/dwn-sdk-js';

0 commit comments

Comments
 (0)