@dxos/messaging 0.9.0 → 0.9.1-staging.ee54ba693a
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/dist/lib/neutral/index.mjs +14 -14
- package/dist/lib/neutral/index.mjs.map +3 -3
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/testing/index.mjs +20 -9
- package/dist/lib/neutral/testing/index.mjs.map +3 -3
- package/dist/types/src/signal-manager/edge-signal-manager.d.ts.map +1 -1
- package/dist/types/src/testing/test-peer.d.ts +7 -1
- package/dist/types/src/testing/test-peer.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -16
- package/src/signal-client/signal-client.node.test.ts +2 -2
- package/src/signal-manager/edge-signal-manager.ts +13 -7
- package/src/testing/test-messages.ts +6 -6
- package/src/testing/test-peer.ts +17 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/messaging",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1-staging.ee54ba693a",
|
|
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/
|
|
37
|
-
"@dxos/codec-protobuf": "0.9.
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/invariant": "0.9.
|
|
40
|
-
"@dxos/keys": "0.9.
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/log": "0.9.
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/
|
|
36
|
+
"@dxos/async": "0.9.1-staging.ee54ba693a",
|
|
37
|
+
"@dxos/codec-protobuf": "0.9.1-staging.ee54ba693a",
|
|
38
|
+
"@dxos/edge-client": "0.9.1-staging.ee54ba693a",
|
|
39
|
+
"@dxos/invariant": "0.9.1-staging.ee54ba693a",
|
|
40
|
+
"@dxos/keys": "0.9.1-staging.ee54ba693a",
|
|
41
|
+
"@dxos/credentials": "0.9.1-staging.ee54ba693a",
|
|
42
|
+
"@dxos/context": "0.9.1-staging.ee54ba693a",
|
|
43
|
+
"@dxos/log": "0.9.1-staging.ee54ba693a",
|
|
44
|
+
"@dxos/node-std": "0.9.1-staging.ee54ba693a",
|
|
45
|
+
"@dxos/protocols": "0.9.1-staging.ee54ba693a",
|
|
46
|
+
"@dxos/rpc": "0.9.1-staging.ee54ba693a",
|
|
47
|
+
"@dxos/util": "0.9.1-staging.ee54ba693a",
|
|
48
|
+
"@dxos/tracing": "0.9.1-staging.ee54ba693a"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/test-utils": "0.9.
|
|
51
|
+
"@dxos/signal": "0.9.1-staging.ee54ba693a",
|
|
52
|
+
"@dxos/keyring": "0.9.1-staging.ee54ba693a",
|
|
53
|
+
"@dxos/test-utils": "0.9.1-staging.ee54ba693a"
|
|
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
|
-
|
|
73
|
+
identityDid: this._edgeConnection.identityDid,
|
|
70
74
|
},
|
|
71
75
|
});
|
|
72
76
|
|
|
73
|
-
|
|
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
|
-
|
|
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,
|
|
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.
|
|
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
|
-
|
|
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
|
};
|
package/src/testing/test-peer.ts
CHANGED
|
@@ -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 {
|
|
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
|
-
|
|
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
|
-
|
|
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();
|