@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.
Files changed (80) hide show
  1. package/dist/cjs/action/client/ClientInteraction.d.ts +1 -0
  2. package/dist/cjs/action/client/ClientInteraction.d.ts.map +1 -1
  3. package/dist/cjs/action/client/ClientInteraction.js +6 -2
  4. package/dist/cjs/action/client/ClientInteraction.js.map +1 -1
  5. package/dist/cjs/action/protocols.d.ts +10 -11
  6. package/dist/cjs/action/protocols.d.ts.map +1 -1
  7. package/dist/cjs/action/server/AttributeSubscriptionResponse.d.ts +14 -13
  8. package/dist/cjs/action/server/AttributeSubscriptionResponse.d.ts.map +1 -1
  9. package/dist/cjs/action/server/AttributeSubscriptionResponse.js +18 -18
  10. package/dist/cjs/action/server/AttributeSubscriptionResponse.js.map +1 -1
  11. package/dist/cjs/action/server/ServerInteraction.d.ts +1 -0
  12. package/dist/cjs/action/server/ServerInteraction.d.ts.map +1 -1
  13. package/dist/cjs/action/server/ServerInteraction.js +3 -0
  14. package/dist/cjs/action/server/ServerInteraction.js.map +1 -1
  15. package/dist/cjs/interaction/InteractionClient.js +1 -1
  16. package/dist/cjs/interaction/InteractionClient.js.map +1 -1
  17. package/dist/cjs/interaction/InteractionMessenger.js +1 -1
  18. package/dist/cjs/interaction/InteractionMessenger.js.map +1 -1
  19. package/dist/cjs/mdns/MdnsService.d.ts +1 -1
  20. package/dist/cjs/mdns/MdnsService.d.ts.map +1 -1
  21. package/dist/cjs/mdns/MdnsService.js +1 -1
  22. package/dist/cjs/mdns/MdnsService.js.map +1 -1
  23. package/dist/cjs/peer/ControllerCommissioner.d.ts.map +1 -1
  24. package/dist/cjs/peer/ControllerCommissioner.js +26 -21
  25. package/dist/cjs/peer/ControllerCommissioner.js.map +1 -1
  26. package/dist/cjs/peer/PeerSet.d.ts +5 -6
  27. package/dist/cjs/peer/PeerSet.d.ts.map +1 -1
  28. package/dist/cjs/peer/PeerSet.js +18 -6
  29. package/dist/cjs/peer/PeerSet.js.map +1 -1
  30. package/dist/cjs/protocol/ExchangeManager.js +2 -2
  31. package/dist/cjs/protocol/ExchangeManager.js.map +1 -1
  32. package/dist/cjs/protocol/MessageExchange.d.ts.map +1 -1
  33. package/dist/cjs/protocol/MessageExchange.js +1 -0
  34. package/dist/cjs/protocol/MessageExchange.js.map +1 -1
  35. package/dist/esm/action/client/ClientInteraction.d.ts +1 -0
  36. package/dist/esm/action/client/ClientInteraction.d.ts.map +1 -1
  37. package/dist/esm/action/client/ClientInteraction.js +6 -2
  38. package/dist/esm/action/client/ClientInteraction.js.map +1 -1
  39. package/dist/esm/action/protocols.d.ts +10 -11
  40. package/dist/esm/action/protocols.d.ts.map +1 -1
  41. package/dist/esm/action/server/AttributeSubscriptionResponse.d.ts +14 -13
  42. package/dist/esm/action/server/AttributeSubscriptionResponse.d.ts.map +1 -1
  43. package/dist/esm/action/server/AttributeSubscriptionResponse.js +18 -18
  44. package/dist/esm/action/server/AttributeSubscriptionResponse.js.map +1 -1
  45. package/dist/esm/action/server/ServerInteraction.d.ts +1 -0
  46. package/dist/esm/action/server/ServerInteraction.d.ts.map +1 -1
  47. package/dist/esm/action/server/ServerInteraction.js +3 -0
  48. package/dist/esm/action/server/ServerInteraction.js.map +1 -1
  49. package/dist/esm/interaction/InteractionClient.js +1 -1
  50. package/dist/esm/interaction/InteractionClient.js.map +1 -1
  51. package/dist/esm/interaction/InteractionMessenger.js +1 -1
  52. package/dist/esm/interaction/InteractionMessenger.js.map +1 -1
  53. package/dist/esm/mdns/MdnsService.d.ts +1 -1
  54. package/dist/esm/mdns/MdnsService.d.ts.map +1 -1
  55. package/dist/esm/mdns/MdnsService.js +1 -1
  56. package/dist/esm/mdns/MdnsService.js.map +1 -1
  57. package/dist/esm/peer/ControllerCommissioner.d.ts.map +1 -1
  58. package/dist/esm/peer/ControllerCommissioner.js +26 -21
  59. package/dist/esm/peer/ControllerCommissioner.js.map +1 -1
  60. package/dist/esm/peer/PeerSet.d.ts +5 -6
  61. package/dist/esm/peer/PeerSet.d.ts.map +1 -1
  62. package/dist/esm/peer/PeerSet.js +18 -6
  63. package/dist/esm/peer/PeerSet.js.map +1 -1
  64. package/dist/esm/protocol/ExchangeManager.js +2 -2
  65. package/dist/esm/protocol/ExchangeManager.js.map +1 -1
  66. package/dist/esm/protocol/MessageExchange.d.ts.map +1 -1
  67. package/dist/esm/protocol/MessageExchange.js +1 -0
  68. package/dist/esm/protocol/MessageExchange.js.map +1 -1
  69. package/package.json +6 -6
  70. package/src/action/client/ClientInteraction.ts +6 -2
  71. package/src/action/protocols.ts +11 -10
  72. package/src/action/server/AttributeSubscriptionResponse.ts +30 -27
  73. package/src/action/server/ServerInteraction.ts +5 -0
  74. package/src/interaction/InteractionClient.ts +1 -1
  75. package/src/interaction/InteractionMessenger.ts +1 -1
  76. package/src/mdns/MdnsService.ts +1 -1
  77. package/src/peer/ControllerCommissioner.ts +31 -23
  78. package/src/peer/PeerSet.ts +22 -7
  79. package/src/protocol/ExchangeManager.ts +2 -2
  80. package/src/protocol/MessageExchange.ts +1 -0
@@ -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.ensureConnection(address, {
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
- const address = this.get(peer)?.address;
387
+ let address = this.get(peer)?.address; // Check known Peers
382
388
  if (address === undefined) {
383
- return;
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: ServerAddressUdp,
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) {
@@ -198,6 +198,7 @@ export class MessageExchange {
198
198
 
199
199
  logger.debug(
200
200
  "New exchange",
201
+ isInitiator ? "»" : "«",
201
202
  Diagnostic.dict({
202
203
  channel: channel.name,
203
204
  protocol: this.#protocolId,