@dxos/messaging 0.9.1-main.c7dcc2e112 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/messaging",
3
- "version": "0.9.1-main.c7dcc2e112",
3
+ "version": "0.10.0",
4
4
  "description": "Messaging",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -33,23 +33,24 @@
33
33
  "dependencies": {
34
34
  "isomorphic-ws": "^5.0.0",
35
35
  "ws": "^8.17.1",
36
- "@dxos/async": "0.9.1-main.c7dcc2e112",
37
- "@dxos/context": "0.9.1-main.c7dcc2e112",
38
- "@dxos/edge-client": "0.9.1-main.c7dcc2e112",
39
- "@dxos/invariant": "0.9.1-main.c7dcc2e112",
40
- "@dxos/log": "0.9.1-main.c7dcc2e112",
41
- "@dxos/rpc": "0.9.1-main.c7dcc2e112",
42
- "@dxos/node-std": "0.9.1-main.c7dcc2e112",
43
- "@dxos/keys": "0.9.1-main.c7dcc2e112",
44
- "@dxos/tracing": "0.9.1-main.c7dcc2e112",
45
- "@dxos/util": "0.9.1-main.c7dcc2e112",
46
- "@dxos/protocols": "0.9.1-main.c7dcc2e112",
47
- "@dxos/codec-protobuf": "0.9.1-main.c7dcc2e112"
36
+ "@dxos/async": "0.10.0",
37
+ "@dxos/codec-protobuf": "0.10.0",
38
+ "@dxos/context": "0.10.0",
39
+ "@dxos/credentials": "0.10.0",
40
+ "@dxos/invariant": "0.10.0",
41
+ "@dxos/keys": "0.10.0",
42
+ "@dxos/log": "0.10.0",
43
+ "@dxos/edge-client": "0.10.0",
44
+ "@dxos/node-std": "0.10.0",
45
+ "@dxos/rpc": "0.10.0",
46
+ "@dxos/protocols": "0.10.0",
47
+ "@dxos/tracing": "0.10.0",
48
+ "@dxos/util": "0.10.0"
48
49
  },
49
50
  "devDependencies": {
50
- "@dxos/keyring": "0.9.1-main.c7dcc2e112",
51
- "@dxos/signal": "0.9.1-main.c7dcc2e112",
52
- "@dxos/test-utils": "0.9.1-main.c7dcc2e112"
51
+ "@dxos/signal": "0.10.0",
52
+ "@dxos/keyring": "0.10.0",
53
+ "@dxos/test-utils": "0.10.0"
53
54
  },
54
55
  "publishConfig": {
55
56
  "access": "public"
@@ -18,8 +18,8 @@ import { SignalClient } from './signal-client';
18
18
 
19
19
  const PAYLOAD: TaggedType<TYPES, 'google.protobuf.Any'> = {
20
20
  '@type': 'google.protobuf.Any',
21
- type_url: 'google.protobuf.Any',
22
- value: Buffer.from('1'),
21
+ 'type_url': 'google.protobuf.Any',
22
+ 'value': Buffer.from('1'),
23
23
  };
24
24
 
25
25
  describe('SignalClient', () => {
@@ -2,6 +2,10 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
+ // DX-1059: this client is already DID-only — it never writes the deprecated `identity_key`
6
+ // (proto field 2). The dual-read fallback that still gates removing that field lives on the
7
+ // edge side (which relays peers from not-yet-migrated senders); nothing here needs it.
8
+
5
9
  import { Event, scheduleMicroTask } from '@dxos/async';
6
10
  import { type Context, Resource, cancelWithContext } from '@dxos/context';
7
11
  import { type EdgeConnection, EdgeIdentityChangedError, protocol } from '@dxos/edge-client';
@@ -66,11 +70,13 @@ export class EdgeSignalManager extends Resource implements SignalManager {
66
70
  peer,
67
71
  expected: {
68
72
  peerKey: this._edgeConnection.peerKey,
69
- identityKey: this._edgeConnection.identityKey,
73
+ identityDid: this._edgeConnection.identityDid,
70
74
  },
71
75
  });
72
76
 
73
- peer.identityKey = this._edgeConnection.identityKey;
77
+ // DX-1059: advertise only the identity DID; the client no longer sends the hex `identityKey`
78
+ // (edge derives the connection's identity from auth, not from this message body).
79
+ peer.identityDid = this._edgeConnection.identityDid;
74
80
  peer.peerKey = this._edgeConnection.peerKey;
75
81
  }
76
82
 
@@ -118,7 +124,7 @@ export class EdgeSignalManager extends Resource implements SignalManager {
118
124
  serviceId: EdgeService.SWARM,
119
125
  source: createMessageSource(topic, {
120
126
  peerKey: this._edgeConnection.peerKey,
121
- identityKey: this._edgeConnection.identityKey,
127
+ identityDid: this._edgeConnection.identityDid,
122
128
  }),
123
129
  payload: { action: SwarmRequestAction.INFO, swarmKeys: [topic.toHex()] },
124
130
  }),
@@ -132,7 +138,7 @@ export class EdgeSignalManager extends Resource implements SignalManager {
132
138
  // NOTE: Could only join swarm with the same peer info as the edge connection.
133
139
  log.warn('ignoring author on send request', {
134
140
  author: message.author,
135
- expected: { peerKey: this._edgeConnection.peerKey, identityKey: this._edgeConnection.identityKey },
141
+ expected: { peerKey: this._edgeConnection.peerKey, identityDid: this._edgeConnection.identityDid },
136
142
  });
137
143
  }
138
144
 
@@ -223,8 +229,8 @@ export class EdgeSignalManager extends Resource implements SignalManager {
223
229
  }
224
230
 
225
231
  private _matchSelfPeerInfo(peer: PeerInfo): boolean {
226
- return (
227
- peer && (peer.peerKey === this._edgeConnection.peerKey || peer.identityKey === this._edgeConnection.identityKey)
232
+ return Boolean(
233
+ peer && (peer.peerKey === this._edgeConnection.peerKey || peer.identityDid === this._edgeConnection.identityDid),
228
234
  );
229
235
  }
230
236
 
@@ -235,7 +241,7 @@ export class EdgeSignalManager extends Resource implements SignalManager {
235
241
  topic,
236
242
  peer: {
237
243
  peerKey: this._edgeConnection.peerKey,
238
- identityKey: this._edgeConnection.identityKey,
244
+ identityDid: this._edgeConnection.identityDid,
239
245
  state: lastState,
240
246
  },
241
247
  });
@@ -7,18 +7,18 @@ import { type TYPES } from '@dxos/protocols/proto';
7
7
 
8
8
  export const PAYLOAD_1: TaggedType<TYPES, 'google.protobuf.Any'> = {
9
9
  '@type': 'google.protobuf.Any',
10
- type_url: 'dxos.Example1',
11
- value: Buffer.from('1'),
10
+ 'type_url': 'dxos.Example1',
11
+ 'value': Buffer.from('1'),
12
12
  };
13
13
 
14
14
  export const PAYLOAD_2: TaggedType<TYPES, 'google.protobuf.Any'> = {
15
15
  '@type': 'google.protobuf.Any',
16
- type_url: 'dxos.Example2',
17
- value: Buffer.from('2'),
16
+ 'type_url': 'dxos.Example2',
17
+ 'value': Buffer.from('2'),
18
18
  };
19
19
 
20
20
  export const PAYLOAD_3: TaggedType<TYPES, 'google.protobuf.Any'> = {
21
21
  '@type': 'google.protobuf.Any',
22
- type_url: 'dxos.Example3',
23
- value: Buffer.from('3'),
22
+ 'type_url': 'dxos.Example3',
23
+ 'value': Buffer.from('3'),
24
24
  };
@@ -4,8 +4,10 @@
4
4
 
5
5
  import { Event } from '@dxos/async';
6
6
  import { Resource } from '@dxos/context';
7
+ import { createDidFromIdentityKey } from '@dxos/credentials';
7
8
  import { PeerSchema } from '@dxos/edge-client';
8
- import { PublicKey } from '@dxos/keys';
9
+ import { invariant } from '@dxos/invariant';
10
+ import { type IdentityDid, PublicKey } from '@dxos/keys';
9
11
  import { log } from '@dxos/log';
10
12
  import { buf } from '@dxos/protocols/buf';
11
13
 
@@ -16,17 +18,25 @@ import { type TestBuilder } from './test-builder';
16
18
  import { expectPeerAvailable, expectPeerLeft, expectReceivedMessage } from './utils';
17
19
 
18
20
  export class TestPeer extends Resource {
19
- public peerId = PublicKey.random();
21
+ /**
22
+ * Undefined until `_open()`: a `createSignalManager` factory (e.g. edge's) may install its own
23
+ * signer-backed key, otherwise a random one is generated. Read via {@link peerInfo} after opening.
24
+ */
25
+ public peerId?: PublicKey;
20
26
  public signalManager!: SignalManager;
21
27
  public messenger!: Messenger;
22
28
  public defaultReceived = new Event<Message>();
23
29
 
30
+ /** DID derived from {@link peerId} in `_open()`, mirroring `createDeviceEdgeIdentity`. */
31
+ private _identityDid?: IdentityDid;
32
+
24
33
  constructor(private readonly testBuilder: TestBuilder) {
25
34
  super();
26
35
  }
27
36
 
28
37
  get peerInfo(): PeerInfo {
29
- return buf.create(PeerSchema, { peerKey: this.peerId.toHex(), identityKey: this.peerId.toHex() });
38
+ invariant(this.peerId && this._identityDid, 'TestPeer not open');
39
+ return buf.create(PeerSchema, { peerKey: this.peerId.toHex(), identityDid: this._identityDid });
30
40
  }
31
41
 
32
42
  async waitTillReceive(message: Message): Promise<Message> {
@@ -42,7 +52,11 @@ export class TestPeer extends Resource {
42
52
  }
43
53
 
44
54
  protected override async _open(): Promise<void> {
55
+ // `createSignalManager` (e.g. edge's factory) may populate `peerId` with its own signer-backed
56
+ // key; otherwise fall back to a random one. Derive the DID only after `peerId` is settled.
45
57
  this.signalManager = await this.testBuilder.createSignalManager(this);
58
+ this.peerId ??= PublicKey.random();
59
+ this._identityDid = await createDidFromIdentityKey(this.peerId);
46
60
  this.messenger = new Messenger({ signalManager: this.signalManager, retryDelay: 300 });
47
61
 
48
62
  await this.signalManager.open();