@matter/protocol 0.16.0-alpha.0-20251006-3fe1e7c57 → 0.16.0-alpha.0-20251013-89bb7099d
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/cjs/action/client/ClientInteraction.d.ts +1 -0
- package/dist/cjs/action/client/ClientInteraction.d.ts.map +1 -1
- package/dist/cjs/action/client/ClientInteraction.js +6 -2
- package/dist/cjs/action/client/ClientInteraction.js.map +1 -1
- package/dist/cjs/action/protocols.d.ts +10 -11
- package/dist/cjs/action/protocols.d.ts.map +1 -1
- package/dist/cjs/action/server/AttributeSubscriptionResponse.d.ts +14 -13
- package/dist/cjs/action/server/AttributeSubscriptionResponse.d.ts.map +1 -1
- package/dist/cjs/action/server/AttributeSubscriptionResponse.js +18 -18
- package/dist/cjs/action/server/AttributeSubscriptionResponse.js.map +1 -1
- package/dist/cjs/action/server/ServerInteraction.d.ts +1 -0
- package/dist/cjs/action/server/ServerInteraction.d.ts.map +1 -1
- package/dist/cjs/action/server/ServerInteraction.js +3 -0
- package/dist/cjs/action/server/ServerInteraction.js.map +1 -1
- package/dist/cjs/interaction/InteractionClient.js +1 -1
- package/dist/cjs/interaction/InteractionClient.js.map +1 -1
- package/dist/cjs/interaction/InteractionMessenger.js +1 -1
- package/dist/cjs/interaction/InteractionMessenger.js.map +1 -1
- package/dist/cjs/mdns/MdnsService.d.ts +1 -1
- package/dist/cjs/mdns/MdnsService.d.ts.map +1 -1
- package/dist/cjs/mdns/MdnsService.js +1 -1
- package/dist/cjs/mdns/MdnsService.js.map +1 -1
- package/dist/cjs/peer/ControllerCommissioner.d.ts.map +1 -1
- package/dist/cjs/peer/ControllerCommissioner.js +26 -21
- package/dist/cjs/peer/ControllerCommissioner.js.map +1 -1
- package/dist/cjs/peer/PeerSet.d.ts +5 -6
- package/dist/cjs/peer/PeerSet.d.ts.map +1 -1
- package/dist/cjs/peer/PeerSet.js +18 -6
- package/dist/cjs/peer/PeerSet.js.map +1 -1
- package/dist/cjs/protocol/ExchangeManager.js +2 -2
- package/dist/cjs/protocol/ExchangeManager.js.map +1 -1
- package/dist/cjs/protocol/MessageExchange.d.ts.map +1 -1
- package/dist/cjs/protocol/MessageExchange.js +1 -0
- package/dist/cjs/protocol/MessageExchange.js.map +1 -1
- package/dist/esm/action/client/ClientInteraction.d.ts +1 -0
- package/dist/esm/action/client/ClientInteraction.d.ts.map +1 -1
- package/dist/esm/action/client/ClientInteraction.js +6 -2
- package/dist/esm/action/client/ClientInteraction.js.map +1 -1
- package/dist/esm/action/protocols.d.ts +10 -11
- package/dist/esm/action/protocols.d.ts.map +1 -1
- package/dist/esm/action/server/AttributeSubscriptionResponse.d.ts +14 -13
- package/dist/esm/action/server/AttributeSubscriptionResponse.d.ts.map +1 -1
- package/dist/esm/action/server/AttributeSubscriptionResponse.js +18 -18
- package/dist/esm/action/server/AttributeSubscriptionResponse.js.map +1 -1
- package/dist/esm/action/server/ServerInteraction.d.ts +1 -0
- package/dist/esm/action/server/ServerInteraction.d.ts.map +1 -1
- package/dist/esm/action/server/ServerInteraction.js +3 -0
- package/dist/esm/action/server/ServerInteraction.js.map +1 -1
- package/dist/esm/interaction/InteractionClient.js +1 -1
- package/dist/esm/interaction/InteractionClient.js.map +1 -1
- package/dist/esm/interaction/InteractionMessenger.js +1 -1
- package/dist/esm/interaction/InteractionMessenger.js.map +1 -1
- package/dist/esm/mdns/MdnsService.d.ts +1 -1
- package/dist/esm/mdns/MdnsService.d.ts.map +1 -1
- package/dist/esm/mdns/MdnsService.js +1 -1
- package/dist/esm/mdns/MdnsService.js.map +1 -1
- package/dist/esm/peer/ControllerCommissioner.d.ts.map +1 -1
- package/dist/esm/peer/ControllerCommissioner.js +26 -21
- package/dist/esm/peer/ControllerCommissioner.js.map +1 -1
- package/dist/esm/peer/PeerSet.d.ts +5 -6
- package/dist/esm/peer/PeerSet.d.ts.map +1 -1
- package/dist/esm/peer/PeerSet.js +18 -6
- package/dist/esm/peer/PeerSet.js.map +1 -1
- package/dist/esm/protocol/ExchangeManager.js +2 -2
- package/dist/esm/protocol/ExchangeManager.js.map +1 -1
- package/dist/esm/protocol/MessageExchange.d.ts.map +1 -1
- package/dist/esm/protocol/MessageExchange.js +1 -0
- package/dist/esm/protocol/MessageExchange.js.map +1 -1
- package/package.json +6 -6
- package/src/action/client/ClientInteraction.ts +6 -2
- package/src/action/protocols.ts +11 -10
- package/src/action/server/AttributeSubscriptionResponse.ts +30 -27
- package/src/action/server/ServerInteraction.ts +5 -0
- package/src/interaction/InteractionClient.ts +1 -1
- package/src/interaction/InteractionMessenger.ts +1 -1
- package/src/mdns/MdnsService.ts +1 -1
- package/src/peer/ControllerCommissioner.ts +31 -23
- package/src/peer/PeerSet.ts +22 -7
- package/src/protocol/ExchangeManager.ts +2 -2
- package/src/protocol/MessageExchange.ts +1 -0
package/src/peer/PeerSet.ts
CHANGED
|
@@ -258,10 +258,14 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
258
258
|
return this.#interactionQueue;
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
+
async connect(address: PeerAddress, options: PeerConnectionOptions & { operationalAddress?: ServerAddressUdp }) {
|
|
262
|
+
await this.#ensureConnection(address, { ...options, allowUnknownPeer: true });
|
|
263
|
+
}
|
|
264
|
+
|
|
261
265
|
/**
|
|
262
266
|
* Ensure there is a channel to the designated peer.
|
|
263
267
|
*/
|
|
264
|
-
async ensureConnection(
|
|
268
|
+
async #ensureConnection(
|
|
265
269
|
address: PeerAddress,
|
|
266
270
|
options: PeerConnectionOptions & {
|
|
267
271
|
allowUnknownPeer?: boolean;
|
|
@@ -306,6 +310,7 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
306
310
|
|
|
307
311
|
/**
|
|
308
312
|
* Obtain an exchange provider for the designated peer.
|
|
313
|
+
* TODO enhance PeerConnectionOptions.discoveryOptions.discoveryData with "addresses" for known operational addresses
|
|
309
314
|
*/
|
|
310
315
|
async exchangeProviderFor(addressOrChannel: PeerAddress | MessageChannel, options: PeerConnectionOptions = {}) {
|
|
311
316
|
if (addressOrChannel instanceof MessageChannel) {
|
|
@@ -325,7 +330,7 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
325
330
|
|
|
326
331
|
if (!initiallyConnected && !this.#channels.hasChannel(address)) {
|
|
327
332
|
// We got an uninitialized node, so do the first connection as usual
|
|
328
|
-
await this
|
|
333
|
+
await this.#ensureConnection(address, {
|
|
329
334
|
discoveryOptions: { discoveryType: NodeDiscoveryType.None },
|
|
330
335
|
caseAuthenticatedTags,
|
|
331
336
|
});
|
|
@@ -376,11 +381,17 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
376
381
|
|
|
377
382
|
/**
|
|
378
383
|
* Terminate any active peer connection.
|
|
384
|
+
* Also handles unknown peers
|
|
379
385
|
*/
|
|
380
386
|
async disconnect(peer: PeerAddress | OperationalPeer, sendSessionClose = true) {
|
|
381
|
-
|
|
387
|
+
let address = this.get(peer)?.address; // Check known Peers
|
|
382
388
|
if (address === undefined) {
|
|
383
|
-
|
|
389
|
+
// We did not find a ClientNode for this peer, so check if it is a PeerAddress
|
|
390
|
+
if ("nodeId" in peer && "fabricIndex" in peer) {
|
|
391
|
+
address = peer;
|
|
392
|
+
} else {
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
384
395
|
}
|
|
385
396
|
|
|
386
397
|
await this.#sessions.removeAllSessionsForNode(address, sendSessionClose);
|
|
@@ -818,7 +829,7 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
818
829
|
|
|
819
830
|
async #addOrUpdatePeer(
|
|
820
831
|
address: PeerAddress,
|
|
821
|
-
operationalServerAddress
|
|
832
|
+
operationalServerAddress?: ServerAddressUdp,
|
|
822
833
|
discoveryData?: DiscoveryData,
|
|
823
834
|
) {
|
|
824
835
|
let peer = this.#peersByAddress.get(address);
|
|
@@ -826,7 +837,7 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
826
837
|
peer = { address, dataStore: await this.#store.createNodeStore(address) };
|
|
827
838
|
this.#peers.add(peer);
|
|
828
839
|
}
|
|
829
|
-
peer.operationalAddress = operationalServerAddress;
|
|
840
|
+
peer.operationalAddress = operationalServerAddress ?? peer.operationalAddress;
|
|
830
841
|
if (discoveryData !== undefined) {
|
|
831
842
|
peer.discoveryData = {
|
|
832
843
|
...peer.discoveryData,
|
|
@@ -836,7 +847,7 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
836
847
|
await this.#store.updatePeer(peer);
|
|
837
848
|
|
|
838
849
|
// If we got a new channel and have a running discovery we can end it
|
|
839
|
-
if (this.#runningPeerDiscoveries.has(address)) {
|
|
850
|
+
if (peer.operationalAddress !== undefined && this.#runningPeerDiscoveries.has(address)) {
|
|
840
851
|
logger.info(`Found ${address} during discovery, cancel discovery.`);
|
|
841
852
|
// We are currently discovering this node, so we need to update the discovery data
|
|
842
853
|
const { mdnsClient: mdnsScanner } = this.#runningPeerDiscoveries.get(address) ?? {};
|
|
@@ -846,6 +857,10 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
846
857
|
}
|
|
847
858
|
}
|
|
848
859
|
|
|
860
|
+
addKnownPeer(address: PeerAddress, operationalServerAddress?: ServerAddressUdp, discoveryData?: DiscoveryData) {
|
|
861
|
+
return this.#addOrUpdatePeer(address, operationalServerAddress, discoveryData);
|
|
862
|
+
}
|
|
863
|
+
|
|
849
864
|
#getLastOperationalAddress(address: PeerAddress) {
|
|
850
865
|
return this.#peersByAddress.get(address)?.operationalAddress;
|
|
851
866
|
}
|
|
@@ -335,9 +335,10 @@ export class ExchangeManager {
|
|
|
335
335
|
return;
|
|
336
336
|
}
|
|
337
337
|
const { session } = exchange;
|
|
338
|
+
this.#exchanges.delete(exchangeIndex);
|
|
338
339
|
if (NodeSession.is(session) && session.closingAfterExchangeFinished) {
|
|
339
340
|
logger.debug(
|
|
340
|
-
`Exchange index ${exchangeIndex} Session ${session.name} is already marked for closure. Close session now.`,
|
|
341
|
+
`Exchange index ${exchangeIndex} on Session ${session.name} is already marked for closure. Close session now.`,
|
|
341
342
|
);
|
|
342
343
|
try {
|
|
343
344
|
await this.#closeSession(session);
|
|
@@ -345,7 +346,6 @@ export class ExchangeManager {
|
|
|
345
346
|
logger.error(`Error closing session ${session.name}. Ignoring.`, error);
|
|
346
347
|
}
|
|
347
348
|
}
|
|
348
|
-
this.#exchanges.delete(exchangeIndex);
|
|
349
349
|
}
|
|
350
350
|
|
|
351
351
|
async #closeSession(session: NodeSession) {
|