@matter/protocol 0.16.0-alpha.0-20251205-dfb1e1556 → 0.16.0-alpha.0-20251209-d6072d23e
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/Val.js +1 -1
- package/dist/cjs/action/Val.js.map +1 -1
- package/dist/cjs/action/client/ClientInteraction.d.ts.map +1 -1
- package/dist/cjs/action/client/ClientInteraction.js +83 -35
- package/dist/cjs/action/client/ClientInteraction.js.map +2 -2
- package/dist/cjs/action/client/subscription/ClientSubscription.d.ts +10 -5
- package/dist/cjs/action/client/subscription/ClientSubscription.d.ts.map +1 -1
- package/dist/cjs/action/client/subscription/ClientSubscription.js +21 -1
- package/dist/cjs/action/client/subscription/ClientSubscription.js.map +2 -2
- package/dist/cjs/action/client/subscription/ClientSubscriptionHandler.js +2 -3
- package/dist/cjs/action/client/subscription/ClientSubscriptionHandler.js.map +1 -1
- package/dist/cjs/action/client/subscription/ClientSubscriptions.d.ts +4 -2
- package/dist/cjs/action/client/subscription/ClientSubscriptions.d.ts.map +1 -1
- package/dist/cjs/action/client/subscription/ClientSubscriptions.js +68 -8
- package/dist/cjs/action/client/subscription/ClientSubscriptions.js.map +1 -1
- package/dist/cjs/action/client/subscription/PeerSubscription.d.ts +0 -1
- package/dist/cjs/action/client/subscription/PeerSubscription.d.ts.map +1 -1
- package/dist/cjs/action/client/subscription/PeerSubscription.js +1 -2
- package/dist/cjs/action/client/subscription/PeerSubscription.js.map +1 -1
- package/dist/cjs/action/client/subscription/SustainedSubscription.d.ts +0 -2
- package/dist/cjs/action/client/subscription/SustainedSubscription.d.ts.map +1 -1
- package/dist/cjs/action/client/subscription/SustainedSubscription.js +2 -4
- package/dist/cjs/action/client/subscription/SustainedSubscription.js.map +1 -1
- package/dist/cjs/action/request/Invoke.js +2 -2
- package/dist/cjs/action/request/Invoke.js.map +1 -1
- package/dist/cjs/action/response/ReadResult.d.ts +1 -1
- package/dist/cjs/action/response/ReadResult.d.ts.map +1 -1
- package/dist/cjs/action/server/AttributeReadResponse.d.ts.map +1 -1
- package/dist/cjs/action/server/AttributeReadResponse.js +78 -25
- package/dist/cjs/action/server/AttributeReadResponse.js.map +1 -1
- package/dist/cjs/action/server/AttributeWriteResponse.d.ts.map +1 -1
- package/dist/cjs/action/server/AttributeWriteResponse.js +70 -17
- package/dist/cjs/action/server/AttributeWriteResponse.js.map +1 -1
- package/dist/cjs/action/server/CommandInvokeResponse.d.ts.map +1 -1
- package/dist/cjs/action/server/CommandInvokeResponse.js +83 -30
- package/dist/cjs/action/server/CommandInvokeResponse.js.map +1 -1
- package/dist/cjs/action/server/DataResponse.d.ts +1 -0
- package/dist/cjs/action/server/DataResponse.d.ts.map +1 -1
- package/dist/cjs/action/server/DataResponse.js +3 -0
- package/dist/cjs/action/server/DataResponse.js.map +1 -1
- package/dist/cjs/action/server/ServerInteraction.d.ts.map +1 -1
- package/dist/cjs/action/server/ServerInteraction.js +4 -4
- package/dist/cjs/action/server/ServerInteraction.js.map +1 -1
- package/dist/cjs/advertisement/Advertisement.d.ts.map +1 -1
- package/dist/cjs/advertisement/Advertisement.js +66 -14
- package/dist/cjs/advertisement/Advertisement.js.map +1 -1
- package/dist/cjs/advertisement/Advertiser.d.ts +4 -1
- package/dist/cjs/advertisement/Advertiser.d.ts.map +1 -1
- package/dist/cjs/advertisement/Advertiser.js +63 -2
- package/dist/cjs/advertisement/Advertiser.js.map +1 -1
- package/dist/cjs/advertisement/ble/BleAdvertiser.d.ts +6 -1
- package/dist/cjs/advertisement/ble/BleAdvertiser.d.ts.map +1 -1
- package/dist/cjs/advertisement/ble/BleAdvertiser.js +1 -1
- package/dist/cjs/advertisement/ble/BleAdvertiser.js.map +1 -1
- package/dist/cjs/advertisement/mdns/MdnsAdvertiser.d.ts +5 -1
- package/dist/cjs/advertisement/mdns/MdnsAdvertiser.d.ts.map +1 -1
- package/dist/cjs/advertisement/mdns/MdnsAdvertiser.js +1 -1
- package/dist/cjs/advertisement/mdns/MdnsAdvertiser.js.map +1 -1
- package/dist/cjs/certificate/kinds/Noc.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/Noc.js +8 -6
- package/dist/cjs/certificate/kinds/Noc.js.map +1 -1
- package/dist/cjs/certificate/kinds/definitions/asn.js +1 -1
- package/dist/cjs/certificate/kinds/definitions/asn.js.map +1 -1
- package/dist/cjs/certificate/kinds/definitions/attestation.d.ts.map +1 -1
- package/dist/cjs/cluster/client/AttributeClient.d.ts.map +1 -1
- package/dist/cjs/cluster/client/AttributeClient.js +2 -2
- package/dist/cjs/cluster/client/AttributeClient.js.map +1 -1
- package/dist/cjs/codec/MessageCodec.d.ts +8 -1
- package/dist/cjs/codec/MessageCodec.d.ts.map +1 -1
- package/dist/cjs/codec/MessageCodec.js +38 -28
- package/dist/cjs/codec/MessageCodec.js.map +2 -2
- package/dist/cjs/common/FailsafeContext.d.ts +8 -9
- package/dist/cjs/common/FailsafeContext.d.ts.map +1 -1
- package/dist/cjs/common/FailsafeContext.js +27 -33
- package/dist/cjs/common/FailsafeContext.js.map +1 -1
- package/dist/cjs/common/FailsafeTimer.d.ts +4 -3
- package/dist/cjs/common/FailsafeTimer.d.ts.map +1 -1
- package/dist/cjs/common/FailsafeTimer.js +4 -4
- package/dist/cjs/common/FailsafeTimer.js.map +1 -1
- package/dist/cjs/common/Mark.d.ts +17 -0
- package/dist/cjs/common/Mark.d.ts.map +1 -0
- package/dist/cjs/{peer/OperationalPeer.js → common/Mark.js} +19 -3
- package/dist/cjs/common/Mark.js.map +6 -0
- package/dist/cjs/common/index.d.ts +1 -0
- package/dist/cjs/common/index.d.ts.map +1 -1
- package/dist/cjs/common/index.js +1 -0
- package/dist/cjs/common/index.js.map +1 -1
- package/dist/cjs/fabric/Fabric.d.ts +16 -8
- package/dist/cjs/fabric/Fabric.d.ts.map +1 -1
- package/dist/cjs/fabric/Fabric.js +35 -18
- package/dist/cjs/fabric/Fabric.js.map +1 -1
- package/dist/cjs/fabric/FabricAuthority.d.ts +2 -2
- package/dist/cjs/fabric/FabricAuthority.d.ts.map +1 -1
- package/dist/cjs/fabric/FabricAuthority.js +3 -3
- package/dist/cjs/fabric/FabricAuthority.js.map +1 -1
- package/dist/cjs/fabric/FabricManager.d.ts +10 -14
- package/dist/cjs/fabric/FabricManager.d.ts.map +1 -1
- package/dist/cjs/fabric/FabricManager.js +44 -40
- package/dist/cjs/fabric/FabricManager.js.map +2 -2
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/interaction/AttributeDataEncoder.d.ts +1 -1
- package/dist/cjs/interaction/InteractionClient.d.ts +2 -2
- package/dist/cjs/interaction/InteractionClient.d.ts.map +1 -1
- package/dist/cjs/interaction/InteractionClient.js +39 -22
- package/dist/cjs/interaction/InteractionClient.js.map +1 -1
- package/dist/cjs/interaction/InteractionMessenger.d.ts +2 -2
- package/dist/cjs/interaction/InteractionMessenger.d.ts.map +1 -1
- package/dist/cjs/interaction/InteractionMessenger.js +35 -27
- package/dist/cjs/interaction/InteractionMessenger.js.map +1 -1
- package/dist/cjs/interaction/Subscription.d.ts +16 -37
- package/dist/cjs/interaction/Subscription.d.ts.map +1 -1
- package/dist/cjs/interaction/Subscription.js +15 -68
- package/dist/cjs/interaction/Subscription.js.map +2 -2
- package/dist/cjs/interaction/SubscriptionClient.d.ts +2 -2
- package/dist/cjs/interaction/SubscriptionClient.d.ts.map +1 -1
- package/dist/cjs/interaction/SubscriptionClient.js +2 -2
- package/dist/cjs/interaction/SubscriptionClient.js.map +1 -1
- package/dist/cjs/mdns/MdnsClient.d.ts +10 -10
- package/dist/cjs/mdns/MdnsClient.d.ts.map +1 -1
- package/dist/cjs/mdns/MdnsClient.js +165 -80
- package/dist/cjs/mdns/MdnsClient.js.map +1 -1
- package/dist/cjs/mdns/MdnsServer.d.ts +2 -2
- package/dist/cjs/mdns/MdnsServer.d.ts.map +1 -1
- package/dist/cjs/mdns/MdnsServer.js +173 -94
- package/dist/cjs/mdns/MdnsServer.js.map +2 -2
- package/dist/cjs/mdns/MdnsService.d.ts.map +1 -1
- package/dist/cjs/mdns/MdnsService.js +3 -2
- package/dist/cjs/mdns/MdnsService.js.map +1 -1
- package/dist/cjs/mdns/MdnsSocket.d.ts +3 -2
- package/dist/cjs/mdns/MdnsSocket.d.ts.map +1 -1
- package/dist/cjs/mdns/MdnsSocket.js +2 -1
- package/dist/cjs/mdns/MdnsSocket.js.map +1 -1
- package/dist/cjs/peer/ControllerCommissioner.d.ts +2 -2
- package/dist/cjs/peer/ControllerCommissioner.d.ts.map +1 -1
- package/dist/cjs/peer/ControllerCommissioner.js +26 -28
- package/dist/cjs/peer/ControllerCommissioner.js.map +1 -1
- package/dist/cjs/peer/ControllerDiscovery.d.ts +1 -1
- package/dist/cjs/peer/ControllerDiscovery.d.ts.map +1 -1
- package/dist/cjs/peer/ControllerDiscovery.js +3 -3
- package/dist/cjs/peer/ControllerDiscovery.js.map +1 -1
- package/dist/cjs/peer/Peer.d.ts +57 -0
- package/dist/cjs/peer/Peer.d.ts.map +1 -0
- package/dist/cjs/peer/Peer.js +182 -0
- package/dist/cjs/peer/Peer.js.map +6 -0
- package/dist/cjs/peer/PeerAddress.d.ts.map +1 -1
- package/dist/cjs/peer/PeerAddress.js +6 -3
- package/dist/cjs/peer/PeerAddress.js.map +1 -1
- package/dist/cjs/peer/PeerAddressStore.d.ts +3 -3
- package/dist/cjs/peer/PeerAddressStore.d.ts.map +1 -1
- package/{src/peer/OperationalPeer.ts → dist/cjs/peer/PeerDescriptor.d.ts} +14 -12
- package/dist/cjs/peer/PeerDescriptor.d.ts.map +1 -0
- package/dist/cjs/peer/PeerDescriptor.js +71 -0
- package/dist/cjs/peer/PeerDescriptor.js.map +6 -0
- package/dist/cjs/peer/PeerSet.d.ts +23 -26
- package/dist/cjs/peer/PeerSet.d.ts.map +1 -1
- package/dist/cjs/peer/PeerSet.js +173 -173
- package/dist/cjs/peer/PeerSet.js.map +2 -2
- package/dist/cjs/peer/index.d.ts +1 -1
- package/dist/cjs/peer/index.d.ts.map +1 -1
- package/dist/cjs/peer/index.js +1 -1
- package/dist/cjs/peer/index.js.map +1 -1
- package/dist/cjs/protocol/DeviceAdvertiser.js +4 -4
- package/dist/cjs/protocol/DeviceAdvertiser.js.map +1 -1
- package/dist/cjs/protocol/ExchangeManager.d.ts +6 -9
- package/dist/cjs/protocol/ExchangeManager.d.ts.map +1 -1
- package/dist/cjs/protocol/ExchangeManager.js +301 -243
- package/dist/cjs/protocol/ExchangeManager.js.map +2 -2
- package/dist/cjs/protocol/ExchangeProvider.d.ts +9 -11
- package/dist/cjs/protocol/ExchangeProvider.d.ts.map +1 -1
- package/dist/cjs/protocol/ExchangeProvider.js +79 -32
- package/dist/cjs/protocol/ExchangeProvider.js.map +2 -2
- package/dist/cjs/protocol/MessageChannel.d.ts +6 -7
- package/dist/cjs/protocol/MessageChannel.d.ts.map +1 -1
- package/dist/cjs/protocol/MessageChannel.js +14 -16
- package/dist/cjs/protocol/MessageChannel.js.map +1 -1
- package/dist/cjs/protocol/MessageCounter.d.ts +4 -4
- package/dist/cjs/protocol/MessageCounter.d.ts.map +1 -1
- package/dist/cjs/protocol/MessageCounter.js +7 -7
- package/dist/cjs/protocol/MessageCounter.js.map +1 -1
- package/dist/cjs/protocol/MessageExchange.d.ts +31 -20
- package/dist/cjs/protocol/MessageExchange.d.ts.map +1 -1
- package/dist/cjs/protocol/MessageExchange.js +316 -231
- package/dist/cjs/protocol/MessageExchange.js.map +2 -2
- package/dist/cjs/protocol/ProtocolMocks.d.ts +100 -0
- package/dist/cjs/protocol/ProtocolMocks.d.ts.map +1 -0
- package/dist/cjs/protocol/ProtocolMocks.js +237 -0
- package/dist/cjs/protocol/ProtocolMocks.js.map +6 -0
- package/dist/cjs/protocol/errors.d.ts +35 -0
- package/dist/cjs/protocol/errors.d.ts.map +1 -0
- package/dist/cjs/protocol/errors.js +50 -0
- package/dist/cjs/protocol/errors.js.map +6 -0
- package/dist/cjs/protocol/index.d.ts +2 -1
- package/dist/cjs/protocol/index.d.ts.map +1 -1
- package/dist/cjs/protocol/index.js +2 -1
- package/dist/cjs/protocol/index.js.map +1 -1
- package/dist/cjs/securechannel/SecureChannelMessenger.d.ts +1 -0
- package/dist/cjs/securechannel/SecureChannelMessenger.d.ts.map +1 -1
- package/dist/cjs/securechannel/SecureChannelMessenger.js +3 -0
- package/dist/cjs/securechannel/SecureChannelMessenger.js.map +1 -1
- package/dist/cjs/securechannel/SecureChannelProtocol.js +2 -2
- package/dist/cjs/securechannel/SecureChannelProtocol.js.map +1 -1
- package/dist/cjs/session/GroupSession.d.ts +21 -10
- package/dist/cjs/session/GroupSession.d.ts.map +1 -1
- package/dist/cjs/session/GroupSession.js +37 -12
- package/dist/cjs/session/GroupSession.js.map +1 -1
- package/dist/cjs/session/NodeSession.d.ts +56 -50
- package/dist/cjs/session/NodeSession.d.ts.map +1 -1
- package/dist/cjs/session/NodeSession.js +95 -103
- package/dist/cjs/session/NodeSession.js.map +1 -1
- package/dist/cjs/session/SecureSession.d.ts +4 -4
- package/dist/cjs/session/SecureSession.d.ts.map +1 -1
- package/dist/cjs/session/SecureSession.js +1 -1
- package/dist/cjs/session/SecureSession.js.map +1 -1
- package/dist/cjs/session/Session.d.ts +82 -66
- package/dist/cjs/session/Session.d.ts.map +1 -1
- package/dist/cjs/session/Session.js +218 -45
- package/dist/cjs/session/Session.js.map +1 -1
- package/dist/cjs/session/SessionManager.d.ts +33 -36
- package/dist/cjs/session/SessionManager.d.ts.map +1 -1
- package/dist/cjs/session/SessionManager.js +112 -150
- package/dist/cjs/session/SessionManager.js.map +1 -1
- package/dist/cjs/session/SessionParameters.d.ts +87 -0
- package/dist/cjs/session/SessionParameters.d.ts.map +1 -0
- package/dist/cjs/session/SessionParameters.js +81 -0
- package/dist/cjs/session/SessionParameters.js.map +6 -0
- package/dist/{esm/session/InsecureSession.d.ts → cjs/session/UnsecuredSession.d.ts} +18 -16
- package/dist/cjs/session/UnsecuredSession.d.ts.map +1 -0
- package/dist/cjs/session/{InsecureSession.js → UnsecuredSession.js} +21 -21
- package/dist/cjs/session/UnsecuredSession.js.map +6 -0
- package/dist/cjs/session/case/CaseClient.d.ts.map +1 -1
- package/dist/cjs/session/case/CaseClient.js +6 -4
- package/dist/cjs/session/case/CaseClient.js.map +1 -1
- package/dist/cjs/session/case/CaseServer.d.ts.map +1 -1
- package/dist/cjs/session/case/CaseServer.js +14 -10
- package/dist/cjs/session/case/CaseServer.js.map +1 -1
- package/dist/cjs/session/index.d.ts +2 -1
- package/dist/cjs/session/index.d.ts.map +1 -1
- package/dist/cjs/session/index.js +2 -1
- package/dist/cjs/session/index.js.map +1 -1
- package/dist/cjs/session/pase/PaseClient.d.ts +3 -3
- package/dist/cjs/session/pase/PaseClient.d.ts.map +1 -1
- package/dist/cjs/session/pase/PaseClient.js +5 -3
- package/dist/cjs/session/pase/PaseClient.js.map +1 -1
- package/dist/cjs/session/pase/PaseServer.d.ts.map +1 -1
- package/dist/cjs/session/pase/PaseServer.js +13 -13
- package/dist/cjs/session/pase/PaseServer.js.map +1 -1
- package/dist/esm/action/Val.js +1 -1
- package/dist/esm/action/Val.js.map +1 -1
- package/dist/esm/action/client/ClientInteraction.d.ts.map +1 -1
- package/dist/esm/action/client/ClientInteraction.js +83 -35
- package/dist/esm/action/client/ClientInteraction.js.map +2 -2
- package/dist/esm/action/client/subscription/ClientSubscription.d.ts +10 -5
- package/dist/esm/action/client/subscription/ClientSubscription.d.ts.map +1 -1
- package/dist/esm/action/client/subscription/ClientSubscription.js +22 -2
- package/dist/esm/action/client/subscription/ClientSubscription.js.map +2 -2
- package/dist/esm/action/client/subscription/ClientSubscriptionHandler.js +2 -3
- package/dist/esm/action/client/subscription/ClientSubscriptionHandler.js.map +1 -1
- package/dist/esm/action/client/subscription/ClientSubscriptions.d.ts +4 -2
- package/dist/esm/action/client/subscription/ClientSubscriptions.d.ts.map +1 -1
- package/dist/esm/action/client/subscription/ClientSubscriptions.js +68 -8
- package/dist/esm/action/client/subscription/ClientSubscriptions.js.map +1 -1
- package/dist/esm/action/client/subscription/PeerSubscription.d.ts +0 -1
- package/dist/esm/action/client/subscription/PeerSubscription.d.ts.map +1 -1
- package/dist/esm/action/client/subscription/PeerSubscription.js +1 -2
- package/dist/esm/action/client/subscription/PeerSubscription.js.map +1 -1
- package/dist/esm/action/client/subscription/SustainedSubscription.d.ts +0 -2
- package/dist/esm/action/client/subscription/SustainedSubscription.d.ts.map +1 -1
- package/dist/esm/action/client/subscription/SustainedSubscription.js +2 -4
- package/dist/esm/action/client/subscription/SustainedSubscription.js.map +1 -1
- package/dist/esm/action/request/Invoke.js +2 -2
- package/dist/esm/action/request/Invoke.js.map +1 -1
- package/dist/esm/action/response/ReadResult.d.ts +1 -1
- package/dist/esm/action/response/ReadResult.d.ts.map +1 -1
- package/dist/esm/action/server/AttributeReadResponse.d.ts.map +1 -1
- package/dist/esm/action/server/AttributeReadResponse.js +78 -25
- package/dist/esm/action/server/AttributeReadResponse.js.map +1 -1
- package/dist/esm/action/server/AttributeWriteResponse.d.ts.map +1 -1
- package/dist/esm/action/server/AttributeWriteResponse.js +70 -17
- package/dist/esm/action/server/AttributeWriteResponse.js.map +1 -1
- package/dist/esm/action/server/CommandInvokeResponse.d.ts.map +1 -1
- package/dist/esm/action/server/CommandInvokeResponse.js +83 -30
- package/dist/esm/action/server/CommandInvokeResponse.js.map +1 -1
- package/dist/esm/action/server/DataResponse.d.ts +1 -0
- package/dist/esm/action/server/DataResponse.d.ts.map +1 -1
- package/dist/esm/action/server/DataResponse.js +3 -0
- package/dist/esm/action/server/DataResponse.js.map +1 -1
- package/dist/esm/action/server/ServerInteraction.d.ts.map +1 -1
- package/dist/esm/action/server/ServerInteraction.js +4 -4
- package/dist/esm/action/server/ServerInteraction.js.map +1 -1
- package/dist/esm/advertisement/Advertisement.d.ts.map +1 -1
- package/dist/esm/advertisement/Advertisement.js +66 -14
- package/dist/esm/advertisement/Advertisement.js.map +1 -1
- package/dist/esm/advertisement/Advertiser.d.ts +4 -1
- package/dist/esm/advertisement/Advertiser.d.ts.map +1 -1
- package/dist/esm/advertisement/Advertiser.js +63 -2
- package/dist/esm/advertisement/Advertiser.js.map +1 -1
- package/dist/esm/advertisement/ble/BleAdvertiser.d.ts +6 -1
- package/dist/esm/advertisement/ble/BleAdvertiser.d.ts.map +1 -1
- package/dist/esm/advertisement/ble/BleAdvertiser.js +1 -1
- package/dist/esm/advertisement/ble/BleAdvertiser.js.map +1 -1
- package/dist/esm/advertisement/mdns/MdnsAdvertiser.d.ts +5 -1
- package/dist/esm/advertisement/mdns/MdnsAdvertiser.d.ts.map +1 -1
- package/dist/esm/advertisement/mdns/MdnsAdvertiser.js +1 -1
- package/dist/esm/advertisement/mdns/MdnsAdvertiser.js.map +1 -1
- package/dist/esm/certificate/kinds/Noc.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/Noc.js +8 -6
- package/dist/esm/certificate/kinds/Noc.js.map +1 -1
- package/dist/esm/certificate/kinds/definitions/asn.js +2 -2
- package/dist/esm/certificate/kinds/definitions/asn.js.map +1 -1
- package/dist/esm/certificate/kinds/definitions/attestation.d.ts.map +1 -1
- package/dist/esm/cluster/client/AttributeClient.d.ts.map +1 -1
- package/dist/esm/cluster/client/AttributeClient.js +1 -1
- package/dist/esm/cluster/client/AttributeClient.js.map +1 -1
- package/dist/esm/codec/MessageCodec.d.ts +8 -1
- package/dist/esm/codec/MessageCodec.d.ts.map +1 -1
- package/dist/esm/codec/MessageCodec.js +39 -28
- package/dist/esm/codec/MessageCodec.js.map +2 -2
- package/dist/esm/common/FailsafeContext.d.ts +8 -9
- package/dist/esm/common/FailsafeContext.d.ts.map +1 -1
- package/dist/esm/common/FailsafeContext.js +27 -33
- package/dist/esm/common/FailsafeContext.js.map +1 -1
- package/dist/esm/common/FailsafeTimer.d.ts +4 -3
- package/dist/esm/common/FailsafeTimer.d.ts.map +1 -1
- package/dist/esm/common/FailsafeTimer.js +4 -4
- package/dist/esm/common/FailsafeTimer.js.map +1 -1
- package/dist/esm/common/Mark.d.ts +17 -0
- package/dist/esm/common/Mark.d.ts.map +1 -0
- package/dist/esm/common/Mark.js +18 -0
- package/dist/esm/common/Mark.js.map +6 -0
- package/dist/esm/common/index.d.ts +1 -0
- package/dist/esm/common/index.d.ts.map +1 -1
- package/dist/esm/common/index.js +1 -0
- package/dist/esm/common/index.js.map +1 -1
- package/dist/esm/fabric/Fabric.d.ts +16 -8
- package/dist/esm/fabric/Fabric.d.ts.map +1 -1
- package/dist/esm/fabric/Fabric.js +36 -18
- package/dist/esm/fabric/Fabric.js.map +1 -1
- package/dist/esm/fabric/FabricAuthority.d.ts +2 -2
- package/dist/esm/fabric/FabricAuthority.d.ts.map +1 -1
- package/dist/esm/fabric/FabricAuthority.js +5 -5
- package/dist/esm/fabric/FabricAuthority.js.map +1 -1
- package/dist/esm/fabric/FabricManager.d.ts +10 -14
- package/dist/esm/fabric/FabricManager.d.ts.map +1 -1
- package/dist/esm/fabric/FabricManager.js +45 -40
- package/dist/esm/fabric/FabricManager.js.map +2 -2
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interaction/AttributeDataEncoder.d.ts +1 -1
- package/dist/esm/interaction/InteractionClient.d.ts +2 -2
- package/dist/esm/interaction/InteractionClient.d.ts.map +1 -1
- package/dist/esm/interaction/InteractionClient.js +39 -22
- package/dist/esm/interaction/InteractionClient.js.map +1 -1
- package/dist/esm/interaction/InteractionMessenger.d.ts +2 -2
- package/dist/esm/interaction/InteractionMessenger.d.ts.map +1 -1
- package/dist/esm/interaction/InteractionMessenger.js +33 -28
- package/dist/esm/interaction/InteractionMessenger.js.map +1 -1
- package/dist/esm/interaction/Subscription.d.ts +16 -37
- package/dist/esm/interaction/Subscription.d.ts.map +1 -1
- package/dist/esm/interaction/Subscription.js +16 -69
- package/dist/esm/interaction/Subscription.js.map +2 -2
- package/dist/esm/interaction/SubscriptionClient.d.ts +2 -2
- package/dist/esm/interaction/SubscriptionClient.d.ts.map +1 -1
- package/dist/esm/interaction/SubscriptionClient.js +2 -2
- package/dist/esm/interaction/SubscriptionClient.js.map +1 -1
- package/dist/esm/mdns/MdnsClient.d.ts +10 -10
- package/dist/esm/mdns/MdnsClient.d.ts.map +1 -1
- package/dist/esm/mdns/MdnsClient.js +166 -80
- package/dist/esm/mdns/MdnsClient.js.map +1 -1
- package/dist/esm/mdns/MdnsServer.d.ts +2 -2
- package/dist/esm/mdns/MdnsServer.d.ts.map +1 -1
- package/dist/esm/mdns/MdnsServer.js +176 -94
- package/dist/esm/mdns/MdnsServer.js.map +2 -2
- package/dist/esm/mdns/MdnsService.d.ts.map +1 -1
- package/dist/esm/mdns/MdnsService.js +3 -2
- package/dist/esm/mdns/MdnsService.js.map +1 -1
- package/dist/esm/mdns/MdnsSocket.d.ts +3 -2
- package/dist/esm/mdns/MdnsSocket.d.ts.map +1 -1
- package/dist/esm/mdns/MdnsSocket.js +2 -1
- package/dist/esm/mdns/MdnsSocket.js.map +1 -1
- package/dist/esm/peer/ControllerCommissioner.d.ts +2 -2
- package/dist/esm/peer/ControllerCommissioner.d.ts.map +1 -1
- package/dist/esm/peer/ControllerCommissioner.js +26 -28
- package/dist/esm/peer/ControllerCommissioner.js.map +1 -1
- package/dist/esm/peer/ControllerDiscovery.d.ts +1 -1
- package/dist/esm/peer/ControllerDiscovery.d.ts.map +1 -1
- package/dist/esm/peer/ControllerDiscovery.js +1 -1
- package/dist/esm/peer/ControllerDiscovery.js.map +1 -1
- package/dist/esm/peer/Peer.d.ts +57 -0
- package/dist/esm/peer/Peer.d.ts.map +1 -0
- package/dist/esm/peer/Peer.js +162 -0
- package/dist/esm/peer/Peer.js.map +6 -0
- package/dist/esm/peer/PeerAddress.d.ts.map +1 -1
- package/dist/esm/peer/PeerAddress.js +6 -3
- package/dist/esm/peer/PeerAddress.js.map +1 -1
- package/dist/esm/peer/PeerAddressStore.d.ts +3 -3
- package/dist/esm/peer/PeerAddressStore.d.ts.map +1 -1
- package/dist/{cjs/peer/OperationalPeer.d.ts → esm/peer/PeerDescriptor.d.ts} +14 -7
- package/dist/esm/peer/PeerDescriptor.d.ts.map +1 -0
- package/dist/esm/peer/PeerDescriptor.js +51 -0
- package/dist/esm/peer/PeerDescriptor.js.map +6 -0
- package/dist/esm/peer/PeerSet.d.ts +23 -26
- package/dist/esm/peer/PeerSet.d.ts.map +1 -1
- package/dist/esm/peer/PeerSet.js +173 -175
- package/dist/esm/peer/PeerSet.js.map +2 -2
- package/dist/esm/peer/index.d.ts +1 -1
- package/dist/esm/peer/index.d.ts.map +1 -1
- package/dist/esm/peer/index.js +1 -1
- package/dist/esm/protocol/DeviceAdvertiser.js +4 -4
- package/dist/esm/protocol/DeviceAdvertiser.js.map +1 -1
- package/dist/esm/protocol/ExchangeManager.d.ts +6 -9
- package/dist/esm/protocol/ExchangeManager.d.ts.map +1 -1
- package/dist/esm/protocol/ExchangeManager.js +303 -248
- package/dist/esm/protocol/ExchangeManager.js.map +2 -2
- package/dist/esm/protocol/ExchangeProvider.d.ts +9 -11
- package/dist/esm/protocol/ExchangeProvider.d.ts.map +1 -1
- package/dist/esm/protocol/ExchangeProvider.js +81 -37
- package/dist/esm/protocol/ExchangeProvider.js.map +2 -2
- package/dist/esm/protocol/MessageChannel.d.ts +6 -7
- package/dist/esm/protocol/MessageChannel.d.ts.map +1 -1
- package/dist/esm/protocol/MessageChannel.js +22 -18
- package/dist/esm/protocol/MessageChannel.js.map +1 -1
- package/dist/esm/protocol/MessageCounter.d.ts +4 -4
- package/dist/esm/protocol/MessageCounter.d.ts.map +1 -1
- package/dist/esm/protocol/MessageCounter.js +7 -7
- package/dist/esm/protocol/MessageCounter.js.map +1 -1
- package/dist/esm/protocol/MessageExchange.d.ts +31 -20
- package/dist/esm/protocol/MessageExchange.d.ts.map +1 -1
- package/dist/esm/protocol/MessageExchange.js +318 -238
- package/dist/esm/protocol/MessageExchange.js.map +2 -2
- package/dist/esm/protocol/ProtocolMocks.d.ts +100 -0
- package/dist/esm/protocol/ProtocolMocks.d.ts.map +1 -0
- package/dist/esm/protocol/ProtocolMocks.js +230 -0
- package/dist/esm/protocol/ProtocolMocks.js.map +6 -0
- package/dist/esm/protocol/errors.d.ts +35 -0
- package/dist/esm/protocol/errors.d.ts.map +1 -0
- package/dist/esm/protocol/errors.js +30 -0
- package/dist/esm/protocol/errors.js.map +6 -0
- package/dist/esm/protocol/index.d.ts +2 -1
- package/dist/esm/protocol/index.d.ts.map +1 -1
- package/dist/esm/protocol/index.js +2 -1
- package/dist/esm/protocol/index.js.map +1 -1
- package/dist/esm/securechannel/SecureChannelMessenger.d.ts +1 -0
- package/dist/esm/securechannel/SecureChannelMessenger.d.ts.map +1 -1
- package/dist/esm/securechannel/SecureChannelMessenger.js +3 -0
- package/dist/esm/securechannel/SecureChannelMessenger.js.map +1 -1
- package/dist/esm/securechannel/SecureChannelProtocol.js +2 -2
- package/dist/esm/securechannel/SecureChannelProtocol.js.map +1 -1
- package/dist/esm/session/GroupSession.d.ts +21 -10
- package/dist/esm/session/GroupSession.d.ts.map +1 -1
- package/dist/esm/session/GroupSession.js +41 -12
- package/dist/esm/session/GroupSession.js.map +1 -1
- package/dist/esm/session/NodeSession.d.ts +56 -50
- package/dist/esm/session/NodeSession.d.ts.map +1 -1
- package/dist/esm/session/NodeSession.js +99 -105
- package/dist/esm/session/NodeSession.js.map +1 -1
- package/dist/esm/session/SecureSession.d.ts +4 -4
- package/dist/esm/session/SecureSession.d.ts.map +1 -1
- package/dist/esm/session/SecureSession.js +1 -1
- package/dist/esm/session/SecureSession.js.map +1 -1
- package/dist/esm/session/Session.d.ts +82 -66
- package/dist/esm/session/Session.d.ts.map +1 -1
- package/dist/esm/session/Session.js +223 -45
- package/dist/esm/session/Session.js.map +1 -1
- package/dist/esm/session/SessionManager.d.ts +33 -36
- package/dist/esm/session/SessionManager.d.ts.map +1 -1
- package/dist/esm/session/SessionManager.js +113 -157
- package/dist/esm/session/SessionManager.js.map +1 -1
- package/dist/esm/session/SessionParameters.d.ts +87 -0
- package/dist/esm/session/SessionParameters.d.ts.map +1 -0
- package/dist/esm/session/SessionParameters.js +61 -0
- package/dist/esm/session/SessionParameters.js.map +6 -0
- package/dist/{cjs/session/InsecureSession.d.ts → esm/session/UnsecuredSession.d.ts} +18 -16
- package/dist/esm/session/UnsecuredSession.d.ts.map +1 -0
- package/dist/esm/session/{InsecureSession.js → UnsecuredSession.js} +18 -18
- package/dist/esm/session/UnsecuredSession.js.map +6 -0
- package/dist/esm/session/case/CaseClient.d.ts.map +1 -1
- package/dist/esm/session/case/CaseClient.js +5 -3
- package/dist/esm/session/case/CaseClient.js.map +1 -1
- package/dist/esm/session/case/CaseServer.d.ts.map +1 -1
- package/dist/esm/session/case/CaseServer.js +14 -10
- package/dist/esm/session/case/CaseServer.js.map +1 -1
- package/dist/esm/session/index.d.ts +2 -1
- package/dist/esm/session/index.d.ts.map +1 -1
- package/dist/esm/session/index.js +2 -1
- package/dist/esm/session/index.js.map +1 -1
- package/dist/esm/session/pase/PaseClient.d.ts +3 -3
- package/dist/esm/session/pase/PaseClient.d.ts.map +1 -1
- package/dist/esm/session/pase/PaseClient.js +5 -3
- package/dist/esm/session/pase/PaseClient.js.map +1 -1
- package/dist/esm/session/pase/PaseServer.d.ts.map +1 -1
- package/dist/esm/session/pase/PaseServer.js +13 -13
- package/dist/esm/session/pase/PaseServer.js.map +1 -1
- package/package.json +6 -6
- package/src/action/client/ClientInteraction.ts +47 -13
- package/src/action/client/subscription/ClientSubscription.ts +30 -5
- package/src/action/client/subscription/ClientSubscriptionHandler.ts +2 -4
- package/src/action/client/subscription/ClientSubscriptions.ts +14 -3
- package/src/action/client/subscription/PeerSubscription.ts +2 -2
- package/src/action/client/subscription/SustainedSubscription.ts +2 -6
- package/src/action/request/Invoke.ts +2 -2
- package/src/action/response/ReadResult.ts +1 -1
- package/src/action/server/AttributeReadResponse.ts +2 -0
- package/src/action/server/AttributeWriteResponse.ts +2 -0
- package/src/action/server/CommandInvokeResponse.ts +1 -0
- package/src/action/server/DataResponse.ts +4 -0
- package/src/action/server/ServerInteraction.ts +4 -4
- package/src/advertisement/Advertisement.ts +6 -7
- package/src/advertisement/Advertiser.ts +12 -1
- package/src/advertisement/ble/BleAdvertiser.ts +7 -2
- package/src/advertisement/mdns/MdnsAdvertiser.ts +7 -1
- package/src/certificate/kinds/Noc.ts +12 -7
- package/src/certificate/kinds/definitions/asn.ts +2 -2
- package/src/certificate/kinds/definitions/attestation.ts +1 -0
- package/src/cluster/client/AttributeClient.ts +1 -1
- package/src/codec/MessageCodec.ts +39 -32
- package/src/common/FailsafeContext.ts +36 -39
- package/src/common/FailsafeTimer.ts +7 -6
- package/src/common/Mark.ts +17 -0
- package/src/common/index.ts +1 -0
- package/src/fabric/Fabric.ts +51 -23
- package/src/fabric/FabricAuthority.ts +4 -4
- package/src/fabric/FabricManager.ts +53 -40
- package/src/index.ts +3 -1
- package/src/interaction/InteractionClient.ts +40 -23
- package/src/interaction/InteractionMessenger.ts +38 -32
- package/src/interaction/Subscription.ts +20 -92
- package/src/interaction/SubscriptionClient.ts +3 -3
- package/src/mdns/MdnsClient.ts +20 -3
- package/src/mdns/MdnsServer.ts +13 -1
- package/src/mdns/MdnsService.ts +3 -2
- package/src/mdns/MdnsSocket.ts +9 -3
- package/src/peer/ControllerCommissioner.ts +35 -37
- package/src/peer/ControllerDiscovery.ts +1 -1
- package/src/peer/Peer.ts +161 -0
- package/src/peer/PeerAddress.ts +6 -2
- package/src/peer/PeerAddressStore.ts +3 -3
- package/src/peer/PeerDescriptor.ts +89 -0
- package/src/peer/PeerSet.ts +145 -213
- package/src/peer/index.ts +1 -1
- package/src/protocol/DeviceAdvertiser.ts +4 -4
- package/src/protocol/ExchangeManager.ts +149 -178
- package/src/protocol/ExchangeProvider.ts +31 -40
- package/src/protocol/MessageChannel.ts +29 -18
- package/src/protocol/MessageCounter.ts +8 -8
- package/src/protocol/MessageExchange.ts +181 -144
- package/src/protocol/ProtocolMocks.ts +302 -0
- package/src/protocol/errors.ts +44 -0
- package/src/protocol/index.ts +2 -1
- package/src/securechannel/SecureChannelMessenger.ts +4 -0
- package/src/securechannel/SecureChannelProtocol.ts +2 -2
- package/src/session/GroupSession.ts +67 -23
- package/src/session/NodeSession.ts +140 -136
- package/src/session/SecureSession.ts +6 -5
- package/src/session/Session.ts +234 -101
- package/src/session/SessionManager.ts +148 -187
- package/src/session/SessionParameters.ts +108 -0
- package/src/session/{InsecureSession.ts → UnsecuredSession.ts} +28 -26
- package/src/session/case/CaseClient.ts +6 -3
- package/src/session/case/CaseServer.ts +15 -11
- package/src/session/index.ts +2 -1
- package/src/session/pase/PaseClient.ts +12 -5
- package/src/session/pase/PaseServer.ts +14 -13
- package/dist/cjs/peer/OperationalPeer.d.ts.map +0 -1
- package/dist/cjs/peer/OperationalPeer.js.map +0 -6
- package/dist/cjs/protocol/ChannelManager.d.ts +0 -29
- package/dist/cjs/protocol/ChannelManager.d.ts.map +0 -1
- package/dist/cjs/protocol/ChannelManager.js +0 -178
- package/dist/cjs/protocol/ChannelManager.js.map +0 -6
- package/dist/cjs/session/InsecureSession.d.ts.map +0 -1
- package/dist/cjs/session/InsecureSession.js.map +0 -6
- package/dist/esm/peer/OperationalPeer.d.ts +0 -38
- package/dist/esm/peer/OperationalPeer.d.ts.map +0 -1
- package/dist/esm/peer/OperationalPeer.js +0 -6
- package/dist/esm/peer/OperationalPeer.js.map +0 -6
- package/dist/esm/protocol/ChannelManager.d.ts +0 -29
- package/dist/esm/protocol/ChannelManager.d.ts.map +0 -1
- package/dist/esm/protocol/ChannelManager.js +0 -158
- package/dist/esm/protocol/ChannelManager.js.map +0 -6
- package/dist/esm/session/InsecureSession.d.ts.map +0 -1
- package/dist/esm/session/InsecureSession.js.map +0 -6
- package/src/protocol/ChannelManager.ts +0 -180
package/src/peer/PeerSet.ts
CHANGED
|
@@ -18,8 +18,8 @@ import {
|
|
|
18
18
|
Environmental,
|
|
19
19
|
ImmutableSet,
|
|
20
20
|
ImplementationError,
|
|
21
|
-
isIpNetworkChannel,
|
|
22
21
|
isIPv6,
|
|
22
|
+
Lifetime,
|
|
23
23
|
Logger,
|
|
24
24
|
MatterError,
|
|
25
25
|
Minutes,
|
|
@@ -28,27 +28,26 @@ import {
|
|
|
28
28
|
Seconds,
|
|
29
29
|
ServerAddress,
|
|
30
30
|
ServerAddressUdp,
|
|
31
|
-
STANDARD_MATTER_PORT,
|
|
32
31
|
Time,
|
|
33
32
|
Timer,
|
|
34
33
|
} from "#general";
|
|
35
34
|
import { MdnsClient } from "#mdns/MdnsClient.js";
|
|
36
35
|
import { PeerAddress, PeerAddressMap } from "#peer/PeerAddress.js";
|
|
37
|
-
import {
|
|
36
|
+
import { RetransmissionLimitReachedError } from "#protocol/errors.js";
|
|
38
37
|
import { ExchangeManager } from "#protocol/ExchangeManager.js";
|
|
39
38
|
import { DedicatedChannelExchangeProvider, ReconnectableExchangeProvider } from "#protocol/ExchangeProvider.js";
|
|
40
|
-
import {
|
|
41
|
-
import { MessageExchange, RetransmissionLimitReachedError } from "#protocol/MessageExchange.js";
|
|
39
|
+
import { MessageExchange } from "#protocol/MessageExchange.js";
|
|
42
40
|
import { ChannelStatusResponseError } from "#securechannel/SecureChannelMessenger.js";
|
|
43
41
|
import { CaseClient } from "#session/case/CaseClient.js";
|
|
44
42
|
import { SecureSession } from "#session/SecureSession.js";
|
|
45
43
|
import { Session } from "#session/Session.js";
|
|
46
44
|
import { SessionManager } from "#session/SessionManager.js";
|
|
47
|
-
import { CaseAuthenticatedTag,
|
|
45
|
+
import { CaseAuthenticatedTag, NodeId, SECURE_CHANNEL_PROTOCOL_ID, SecureChannelStatusCode } from "#types";
|
|
48
46
|
import { ControllerDiscovery, DiscoveryError, PairRetransmissionLimitReachedError } from "./ControllerDiscovery.js";
|
|
49
47
|
import { InteractionQueue } from "./InteractionQueue.js";
|
|
50
|
-
import {
|
|
48
|
+
import { Peer } from "./Peer.js";
|
|
51
49
|
import { PeerAddressStore, PeerDataStore } from "./PeerAddressStore.js";
|
|
50
|
+
import { PeerDescriptor } from "./PeerDescriptor.js";
|
|
52
51
|
|
|
53
52
|
const logger = Logger.get("PeerSet");
|
|
54
53
|
|
|
@@ -92,19 +91,12 @@ export interface PeerConnectionOptions {
|
|
|
92
91
|
caseAuthenticatedTags?: CaseAuthenticatedTag[];
|
|
93
92
|
}
|
|
94
93
|
|
|
95
|
-
interface RunningDiscovery {
|
|
96
|
-
type: NodeDiscoveryType;
|
|
97
|
-
promises?: (() => Promise<MessageChannel>)[];
|
|
98
|
-
stopTimerFunc?: (() => void) | undefined;
|
|
99
|
-
mdnsClient?: MdnsClient;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
94
|
/**
|
|
103
95
|
* Interfaces {@link PeerSet} with other components.
|
|
104
96
|
*/
|
|
105
97
|
export interface PeerSetContext {
|
|
98
|
+
lifetime: Lifetime.Owner;
|
|
106
99
|
sessions: SessionManager;
|
|
107
|
-
channels: ChannelManager;
|
|
108
100
|
exchanges: ExchangeManager;
|
|
109
101
|
scanners: ScannerSet;
|
|
110
102
|
transports: ConnectionlessTransportSet;
|
|
@@ -114,44 +106,46 @@ export interface PeerSetContext {
|
|
|
114
106
|
/**
|
|
115
107
|
* Manages operational connections to peers on shared fabric.
|
|
116
108
|
*/
|
|
117
|
-
export class PeerSet implements ImmutableSet<
|
|
109
|
+
export class PeerSet implements ImmutableSet<Peer>, ObservableSet<Peer> {
|
|
110
|
+
readonly #lifetime: Lifetime;
|
|
118
111
|
readonly #sessions: SessionManager;
|
|
119
|
-
readonly #channels: ChannelManager;
|
|
120
112
|
readonly #exchanges: ExchangeManager;
|
|
121
113
|
readonly #scanners: ScannerSet;
|
|
122
114
|
readonly #transports: ConnectionlessTransportSet;
|
|
123
115
|
readonly #caseClient: CaseClient;
|
|
124
|
-
readonly #peers = new BasicSet<
|
|
125
|
-
readonly #peersByAddress = new PeerAddressMap<OperationalPeer>();
|
|
126
|
-
readonly #runningPeerDiscoveries = new PeerAddressMap<RunningDiscovery>();
|
|
127
|
-
readonly #runningPeerReconnections = new PeerAddressMap<{
|
|
128
|
-
promise: Promise<MessageChannel>;
|
|
129
|
-
rejecter: (reason?: any) => void;
|
|
130
|
-
}>();
|
|
116
|
+
readonly #peers = new BasicSet<Peer>();
|
|
131
117
|
readonly #construction: Construction<PeerSet>;
|
|
132
118
|
readonly #store: PeerAddressStore;
|
|
133
119
|
readonly #interactionQueue = new InteractionQueue();
|
|
134
120
|
readonly #nodeCachedData = new PeerAddressMap<PeerDataStore>(); // Temporarily until we store it in new API
|
|
135
|
-
readonly #disconnected = AsyncObservable<[
|
|
121
|
+
readonly #disconnected = AsyncObservable<[peer: Peer]>();
|
|
122
|
+
readonly #peerContext: Peer.Context;
|
|
136
123
|
|
|
137
124
|
constructor(context: PeerSetContext) {
|
|
138
|
-
const {
|
|
125
|
+
const { lifetime, sessions, exchanges, scanners, transports: netInterfaces, store } = context;
|
|
139
126
|
|
|
127
|
+
this.#lifetime = lifetime.join("peers");
|
|
140
128
|
this.#sessions = sessions;
|
|
141
|
-
this.#channels = channels;
|
|
142
129
|
this.#exchanges = exchanges;
|
|
143
130
|
this.#scanners = scanners;
|
|
144
131
|
this.#transports = netInterfaces;
|
|
145
132
|
this.#store = store;
|
|
146
133
|
this.#caseClient = new CaseClient(this.#sessions);
|
|
147
134
|
|
|
148
|
-
this.#
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
135
|
+
this.#peerContext = {
|
|
136
|
+
lifetime: this.#lifetime,
|
|
137
|
+
sessions,
|
|
138
|
+
savePeer: peer => this.#store.updatePeer(peer.descriptor),
|
|
139
|
+
deletePeer: peer => this.#store.deletePeer(peer.address),
|
|
140
|
+
closed: peer => this.#peers.delete(peer),
|
|
141
|
+
};
|
|
152
142
|
|
|
153
|
-
this.#peers.
|
|
154
|
-
|
|
143
|
+
this.#peers.added.on(peer => {
|
|
144
|
+
peer.sessions.deleted.on(() => {
|
|
145
|
+
if (!peer.sessions.size) {
|
|
146
|
+
this.#disconnected.emit(peer);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
155
149
|
});
|
|
156
150
|
|
|
157
151
|
this.#sessions.retry.on((session, count) => {
|
|
@@ -162,17 +156,9 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
162
156
|
this.#handleFirstRetry(session);
|
|
163
157
|
});
|
|
164
158
|
|
|
165
|
-
/** A channel was added by ourselves */
|
|
166
|
-
this.#channels.added.on((address, msgChannel) => {
|
|
167
|
-
if (isIpNetworkChannel(msgChannel.channel)) {
|
|
168
|
-
// Update the channel address if it has one
|
|
169
|
-
return this.#addOrUpdatePeer(address, msgChannel.channel.networkAddress);
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
|
|
173
159
|
this.#construction = Construction(this, async () => {
|
|
174
|
-
for (const
|
|
175
|
-
this.#peers.add(
|
|
160
|
+
for (const descriptor of await this.#store.loadPeers()) {
|
|
161
|
+
this.#peers.add(new Peer(descriptor, this.#peerContext));
|
|
176
162
|
}
|
|
177
163
|
});
|
|
178
164
|
}
|
|
@@ -193,26 +179,40 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
193
179
|
return this.#disconnected;
|
|
194
180
|
}
|
|
195
181
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
182
|
+
/**
|
|
183
|
+
* Unconditional get.
|
|
184
|
+
*
|
|
185
|
+
* Creates the peer if not already present.
|
|
186
|
+
*/
|
|
187
|
+
for(address: PeerAddress) {
|
|
188
|
+
let peer = this.get(address);
|
|
189
|
+
if (peer) {
|
|
190
|
+
return peer;
|
|
199
191
|
}
|
|
200
|
-
|
|
192
|
+
|
|
193
|
+
peer = new Peer({ address }, this.#peerContext);
|
|
194
|
+
this.#peers.add(peer);
|
|
195
|
+
|
|
196
|
+
return peer;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
has(item: PeerAddress | PeerDescriptor | Peer) {
|
|
200
|
+
return !!this.get(item);
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
get size() {
|
|
204
204
|
return this.#peers.size;
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
find(predicate: (item:
|
|
207
|
+
find(predicate: (item: Peer) => boolean | undefined) {
|
|
208
208
|
return this.#peers.find(predicate);
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
-
filter(predicate: (item:
|
|
211
|
+
filter(predicate: (item: Peer) => boolean | undefined) {
|
|
212
212
|
return this.#peers.filter(predicate);
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
-
map<T>(mapper: (item:
|
|
215
|
+
map<T>(mapper: (item: Peer) => T) {
|
|
216
216
|
return this.#peers.map(mapper);
|
|
217
217
|
}
|
|
218
218
|
|
|
@@ -226,8 +226,8 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
226
226
|
|
|
227
227
|
static [Environmental.create](env: Environment) {
|
|
228
228
|
const instance = new PeerSet({
|
|
229
|
+
lifetime: env,
|
|
229
230
|
sessions: env.get(SessionManager),
|
|
230
|
-
channels: env.get(ChannelManager),
|
|
231
231
|
exchanges: env.get(ExchangeManager),
|
|
232
232
|
scanners: env.get(ScannerSet),
|
|
233
233
|
transports: env.get(ConnectionlessTransportSet),
|
|
@@ -261,36 +261,40 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
261
261
|
) {
|
|
262
262
|
address = PeerAddress(address);
|
|
263
263
|
|
|
264
|
-
|
|
264
|
+
if (PeerAddress.isGroup(address)) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
|
|
265
268
|
const { allowUnknownPeer, operationalAddress } = options;
|
|
266
|
-
if (!this
|
|
269
|
+
if (!this.has(address) && !allowUnknownPeer) {
|
|
267
270
|
throw new UnknownNodeError(`Cannot connect to unknown device ${PeerAddress(address)}`);
|
|
268
271
|
}
|
|
269
272
|
|
|
270
|
-
|
|
271
|
-
if (isGroupNode) {
|
|
272
|
-
await this.#createGroupChannel(address);
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
273
|
+
const peer = this.for(address);
|
|
275
274
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
275
|
+
if (this.#sessions.maybeSessionFor(address) || peer.activeDiscovery?.type === NodeDiscoveryType.FullDiscovery) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
280
278
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
279
|
+
const { promise: existingReconnectPromise } = peer.activeReconnection ?? {};
|
|
280
|
+
if (existingReconnectPromise !== undefined) {
|
|
281
|
+
return existingReconnectPromise;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const { promise, resolver, rejecter } = createPromise<SecureSession>();
|
|
285
|
+
peer.activeReconnection = { promise, rejecter };
|
|
286
|
+
|
|
287
|
+
this.#resume(address, options, operationalAddress)
|
|
288
|
+
.then(channel => {
|
|
289
|
+
peer.activeReconnection = undefined;
|
|
290
|
+
resolver(channel);
|
|
291
|
+
})
|
|
292
|
+
.catch(error => {
|
|
293
|
+
peer.activeReconnection = undefined;
|
|
294
|
+
rejecter(error);
|
|
295
|
+
});
|
|
293
296
|
|
|
297
|
+
if (options.discoveryOptions?.discoveryType !== NodeDiscoveryType.FullDiscovery) {
|
|
294
298
|
return promise;
|
|
295
299
|
}
|
|
296
300
|
}
|
|
@@ -299,42 +303,41 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
299
303
|
* Obtain an exchange provider for the designated peer.
|
|
300
304
|
* TODO enhance PeerConnectionOptions.discoveryOptions.discoveryData with "addresses" for known operational addresses
|
|
301
305
|
*/
|
|
302
|
-
async exchangeProviderFor(
|
|
303
|
-
if (
|
|
304
|
-
return new DedicatedChannelExchangeProvider(this.#exchanges,
|
|
306
|
+
async exchangeProviderFor(addressOrSession: PeerAddress | SecureSession, options: PeerConnectionOptions = {}) {
|
|
307
|
+
if (addressOrSession instanceof SecureSession) {
|
|
308
|
+
return new DedicatedChannelExchangeProvider(this.#exchanges, addressOrSession);
|
|
305
309
|
}
|
|
306
|
-
const address: PeerAddress =
|
|
310
|
+
const address: PeerAddress = addressOrSession;
|
|
307
311
|
if (PeerAddress.isGroup(address)) {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
await this.#createGroupChannel(address);
|
|
311
|
-
}
|
|
312
|
-
return new DedicatedChannelExchangeProvider(this.#exchanges, this.#channels.getChannel(address));
|
|
312
|
+
const session = await this.#sessions.groupSessionForAddress(address, this.#transports);
|
|
313
|
+
return new DedicatedChannelExchangeProvider(this.#exchanges, session);
|
|
313
314
|
}
|
|
314
|
-
let initiallyConnected = this.#
|
|
315
|
-
return new ReconnectableExchangeProvider(this.#exchanges, this.#
|
|
315
|
+
let initiallyConnected = !!this.#sessions.maybeSessionFor(address);
|
|
316
|
+
return new ReconnectableExchangeProvider(this.#exchanges, this.#sessions, address, async () => {
|
|
316
317
|
const { caseAuthenticatedTags, discoveryOptions } = options;
|
|
317
318
|
|
|
318
|
-
if (!initiallyConnected && !this.#
|
|
319
|
+
if (!initiallyConnected && !this.#sessions.maybeSessionFor(address)) {
|
|
319
320
|
// We got an uninitialized node, so do the first connection as usual
|
|
320
321
|
await this.#ensureConnection(address, {
|
|
321
322
|
discoveryOptions: { discoveryType: NodeDiscoveryType.None },
|
|
322
323
|
caseAuthenticatedTags,
|
|
323
324
|
});
|
|
324
325
|
initiallyConnected = true; // We only do this connection once, rest is handled in following code
|
|
325
|
-
if (this.#
|
|
326
|
+
if (this.#sessions.maybeSessionFor(address)) {
|
|
326
327
|
return;
|
|
327
328
|
}
|
|
328
329
|
}
|
|
329
330
|
|
|
330
|
-
if (!this.#
|
|
331
|
-
throw new RetransmissionLimitReachedError(`Device ${PeerAddress(address)} is
|
|
331
|
+
if (!this.#sessions.maybeSessionFor(address)) {
|
|
332
|
+
throw new RetransmissionLimitReachedError(`Device ${PeerAddress(address)} is unreachable`);
|
|
332
333
|
}
|
|
333
|
-
|
|
334
|
+
|
|
335
|
+
// Close all sessions
|
|
336
|
+
await this.#sessions.handlePeerLoss(address);
|
|
334
337
|
|
|
335
338
|
// Enrich discoveryData with data from the node store when not provided
|
|
336
339
|
const { discoveryData } = discoveryOptions ?? {
|
|
337
|
-
discoveryData: this
|
|
340
|
+
discoveryData: this.get(address)?.descriptor.discoveryData,
|
|
338
341
|
};
|
|
339
342
|
// Try to use first result for one last try before we need to reconnect
|
|
340
343
|
const operationalAddress = this.#knownOperationalAddressFor(address, true);
|
|
@@ -343,15 +346,16 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
343
346
|
`Re-discovering device failed (no address found), remove all sessions for ${PeerAddress(address)}`,
|
|
344
347
|
);
|
|
345
348
|
// We remove all sessions, this also informs the PairedNode class
|
|
346
|
-
await this.#sessions.removeAllSessionsForNode(address);
|
|
347
349
|
throw new RetransmissionLimitReachedError(`No operational address found for ${PeerAddress(address)}`);
|
|
348
350
|
}
|
|
351
|
+
|
|
352
|
+
// Try to reconnect to last known address
|
|
349
353
|
if (
|
|
350
354
|
(await this.#reconnectKnownAddress(address, operationalAddress, discoveryData, {
|
|
351
355
|
expectedProcessingTime: Seconds(2),
|
|
352
356
|
})) === undefined
|
|
353
357
|
) {
|
|
354
|
-
throw new RetransmissionLimitReachedError(`${PeerAddress(address)} is not reachable
|
|
358
|
+
throw new RetransmissionLimitReachedError(`${PeerAddress(address)} is not reachable`);
|
|
355
359
|
}
|
|
356
360
|
});
|
|
357
361
|
}
|
|
@@ -359,67 +363,21 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
359
363
|
/**
|
|
360
364
|
* Retrieve a peer by address.
|
|
361
365
|
*/
|
|
362
|
-
get(peer: PeerAddress |
|
|
366
|
+
get(peer: PeerAddress | PeerDescriptor) {
|
|
363
367
|
if ("address" in peer) {
|
|
364
|
-
return this.#
|
|
365
|
-
}
|
|
366
|
-
return this.#peersByAddress.get(peer);
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* Terminate any active peer connection.
|
|
371
|
-
* Also handles unknown peers
|
|
372
|
-
*/
|
|
373
|
-
async disconnect(peer: PeerAddress | OperationalPeer, sendSessionClose = true) {
|
|
374
|
-
let address = this.get(peer)?.address; // Check known Peers
|
|
375
|
-
if (address === undefined) {
|
|
376
|
-
// We did not find a ClientNode for this peer, so check if it is a PeerAddress
|
|
377
|
-
if ("nodeId" in peer && "fabricIndex" in peer) {
|
|
378
|
-
address = peer;
|
|
379
|
-
} else {
|
|
380
|
-
return;
|
|
381
|
-
}
|
|
368
|
+
return this.#peers.get("address", PeerAddress(peer.address));
|
|
382
369
|
}
|
|
383
|
-
|
|
384
|
-
await this.#sessions.removeAllSessionsForNode(address, sendSessionClose);
|
|
385
|
-
await this.#channels.removeAllNodeChannels(address);
|
|
386
|
-
await this.#disconnected.emit(address);
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
* Forget a known peer.
|
|
391
|
-
*/
|
|
392
|
-
async delete(peer: PeerAddress | OperationalPeer) {
|
|
393
|
-
const actual = this.get(peer);
|
|
394
|
-
if (actual === undefined) {
|
|
395
|
-
return;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
const { address } = actual;
|
|
399
|
-
logger.info(`Removing ${address}`);
|
|
400
|
-
this.#peers.delete(actual);
|
|
401
|
-
await this.#store.deletePeer(address);
|
|
402
|
-
await this.disconnect(address, false);
|
|
403
|
-
await this.#sessions.deleteResumptionRecord(address);
|
|
370
|
+
return this.#peers.get("address", PeerAddress(peer));
|
|
404
371
|
}
|
|
405
372
|
|
|
406
373
|
async close() {
|
|
407
|
-
|
|
408
|
-
stopTimerFunc?.();
|
|
409
|
-
|
|
410
|
-
// This ends discovery without triggering promises
|
|
411
|
-
mdnsScanner?.cancelOperationalDeviceDiscovery(this.#sessions.fabricFor(address), address.nodeId, false);
|
|
412
|
-
}
|
|
374
|
+
using _closing = this.#lifetime.closing();
|
|
413
375
|
|
|
414
|
-
for (const
|
|
415
|
-
await
|
|
376
|
+
for (const peer of this.#peers) {
|
|
377
|
+
await peer.close();
|
|
416
378
|
}
|
|
417
379
|
|
|
418
380
|
this.#interactionQueue.close();
|
|
419
|
-
this.#runningPeerReconnections.forEach(({ rejecter }) =>
|
|
420
|
-
rejecter(new ChannelNotConnectedError("PeerSet closed")),
|
|
421
|
-
);
|
|
422
|
-
this.#runningPeerReconnections.clear();
|
|
423
381
|
}
|
|
424
382
|
|
|
425
383
|
/**
|
|
@@ -442,12 +400,12 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
442
400
|
} catch (error) {
|
|
443
401
|
if (
|
|
444
402
|
(error instanceof DiscoveryError || error instanceof NoResponseTimeoutError) &&
|
|
445
|
-
this
|
|
403
|
+
this.has(address) &&
|
|
446
404
|
tryOperationalAddress === undefined
|
|
447
405
|
) {
|
|
448
406
|
logger.info(`Resume failed, remove all sessions for ${PeerAddress(address)}`);
|
|
449
407
|
// We remove all sessions, this also informs the PairedNode class
|
|
450
|
-
await this.#sessions.
|
|
408
|
+
await this.#sessions.handlePeerLoss(address);
|
|
451
409
|
}
|
|
452
410
|
throw error;
|
|
453
411
|
}
|
|
@@ -463,7 +421,7 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
463
421
|
discoveryOptions: {
|
|
464
422
|
discoveryType: requestedDiscoveryType = NodeDiscoveryType.FullDiscovery,
|
|
465
423
|
timeout,
|
|
466
|
-
discoveryData = this
|
|
424
|
+
discoveryData = this.get(address)?.descriptor.discoveryData,
|
|
467
425
|
} = {},
|
|
468
426
|
caseAuthenticatedTags,
|
|
469
427
|
} = options ?? {};
|
|
@@ -479,7 +437,8 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
479
437
|
throw new ImplementationError("Cannot discover device without mDNS scanner.");
|
|
480
438
|
}
|
|
481
439
|
|
|
482
|
-
const
|
|
440
|
+
const peer = this.for(address);
|
|
441
|
+
const existingDiscoveryDetails = peer.activeDiscovery ?? {
|
|
483
442
|
type: NodeDiscoveryType.None,
|
|
484
443
|
};
|
|
485
444
|
|
|
@@ -489,7 +448,7 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
489
448
|
existingDiscoveryDetails.type < requestedDiscoveryType
|
|
490
449
|
) {
|
|
491
450
|
mdnsScanner.cancelOperationalDeviceDiscovery(this.#sessions.fabricFor(address), address.nodeId);
|
|
492
|
-
|
|
451
|
+
peer.activeDiscovery = undefined;
|
|
493
452
|
existingDiscoveryDetails.type = NodeDiscoveryType.None;
|
|
494
453
|
}
|
|
495
454
|
|
|
@@ -530,7 +489,7 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
530
489
|
}
|
|
531
490
|
}
|
|
532
491
|
|
|
533
|
-
const discoveryPromises = new Array<() => Promise<
|
|
492
|
+
const discoveryPromises = new Array<() => Promise<SecureSession>>();
|
|
534
493
|
let reconnectionPollingTimer: Timer | undefined;
|
|
535
494
|
let stopTimerFunc: (() => void) | undefined;
|
|
536
495
|
|
|
@@ -538,7 +497,7 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
538
497
|
if (lastOperationalAddress !== undefined) {
|
|
539
498
|
// Additionally to general discovery we also try to poll the formerly known operational address
|
|
540
499
|
if (requestedDiscoveryType === NodeDiscoveryType.FullDiscovery) {
|
|
541
|
-
const { promise, resolver, rejecter } = createPromise<
|
|
500
|
+
const { promise, resolver, rejecter } = createPromise<SecureSession>();
|
|
542
501
|
|
|
543
502
|
logger.debug(
|
|
544
503
|
`Starting reconnection polling for ${ServerAddress.urlFor(lastOperationalAddress)} (interval ${Duration.format(RECONNECTION_POLLING_INTERVAL)})`,
|
|
@@ -561,7 +520,7 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
561
520
|
this.#sessions.fabricFor(address),
|
|
562
521
|
address.nodeId,
|
|
563
522
|
);
|
|
564
|
-
|
|
523
|
+
peer.activeDiscovery = undefined;
|
|
565
524
|
resolver(result);
|
|
566
525
|
}
|
|
567
526
|
} catch (error) {
|
|
@@ -571,7 +530,7 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
571
530
|
this.#sessions.fabricFor(address),
|
|
572
531
|
address.nodeId,
|
|
573
532
|
);
|
|
574
|
-
|
|
533
|
+
peer.activeDiscovery = undefined;
|
|
575
534
|
rejecter(error);
|
|
576
535
|
}
|
|
577
536
|
}
|
|
@@ -595,9 +554,9 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
595
554
|
timeout,
|
|
596
555
|
timeout === undefined,
|
|
597
556
|
);
|
|
598
|
-
const { stopTimerFunc } =
|
|
557
|
+
const { stopTimerFunc } = peer.activeDiscovery ?? {};
|
|
599
558
|
stopTimerFunc?.();
|
|
600
|
-
|
|
559
|
+
peer.activeDiscovery = undefined;
|
|
601
560
|
|
|
602
561
|
const { result } = await ControllerDiscovery.iterateServerAddresses(
|
|
603
562
|
[scanResult],
|
|
@@ -622,15 +581,15 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
622
581
|
return result;
|
|
623
582
|
});
|
|
624
583
|
|
|
625
|
-
|
|
584
|
+
peer.activeDiscovery = {
|
|
626
585
|
type: requestedDiscoveryType,
|
|
627
586
|
promises: discoveryPromises,
|
|
628
587
|
stopTimerFunc,
|
|
629
588
|
mdnsClient: mdnsScanner,
|
|
630
|
-
}
|
|
589
|
+
};
|
|
631
590
|
|
|
632
591
|
return await anyPromise(discoveryPromises).finally(() => {
|
|
633
|
-
|
|
592
|
+
peer.activeDiscovery = undefined;
|
|
634
593
|
});
|
|
635
594
|
}
|
|
636
595
|
|
|
@@ -639,7 +598,7 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
639
598
|
operationalAddress: ServerAddressUdp,
|
|
640
599
|
discoveryData?: DiscoveryData,
|
|
641
600
|
options?: CaseClient.PairOptions,
|
|
642
|
-
): Promise<
|
|
601
|
+
): Promise<SecureSession | undefined> {
|
|
643
602
|
address = PeerAddress(address);
|
|
644
603
|
|
|
645
604
|
const { ip, port } = operationalAddress;
|
|
@@ -653,17 +612,17 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
653
612
|
: ""
|
|
654
613
|
}`,
|
|
655
614
|
);
|
|
656
|
-
const
|
|
615
|
+
const session = await this.#pair(address, operationalAddress, discoveryData, options);
|
|
657
616
|
await this.#addOrUpdatePeer(address, operationalAddress);
|
|
658
|
-
return
|
|
617
|
+
return session;
|
|
659
618
|
} catch (error) {
|
|
660
|
-
if (error instanceof NoResponseTimeoutError) {
|
|
619
|
+
if (error instanceof NoResponseTimeoutError || error instanceof ChannelStatusResponseError) {
|
|
661
620
|
logger.debug(
|
|
662
621
|
`Failed to resume connection to ${address} connection with ${ip}:${port}, discovering the node now:`,
|
|
663
622
|
error.message ? error.message : error,
|
|
664
623
|
);
|
|
665
624
|
// We remove all sessions, this also informs the PairedNode class
|
|
666
|
-
await this.#sessions.
|
|
625
|
+
await this.#sessions.handlePeerLoss(address, startTime);
|
|
667
626
|
return undefined;
|
|
668
627
|
} else {
|
|
669
628
|
throw error;
|
|
@@ -671,27 +630,6 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
671
630
|
}
|
|
672
631
|
}
|
|
673
632
|
|
|
674
|
-
async #createGroupChannel(address: PeerAddress) {
|
|
675
|
-
const groupId = GroupId.fromNodeId(address.nodeId);
|
|
676
|
-
GroupId.assertGroupId(groupId);
|
|
677
|
-
const multicastAddress = this.#sessions.fabricFor(address).groups.multicastAddressFor(groupId);
|
|
678
|
-
|
|
679
|
-
const operationalInterface = this.#transports.interfaceFor(ChannelType.UDP, multicastAddress);
|
|
680
|
-
if (operationalInterface === undefined) {
|
|
681
|
-
throw new PairRetransmissionLimitReachedError(`IPv6 interface not initialized`);
|
|
682
|
-
}
|
|
683
|
-
const operationalChannel = await operationalInterface.openChannel({
|
|
684
|
-
type: ChannelType.UDP,
|
|
685
|
-
ip: multicastAddress,
|
|
686
|
-
port: STANDARD_MATTER_PORT,
|
|
687
|
-
});
|
|
688
|
-
|
|
689
|
-
const session = this.#sessions.groupSessionForAddress(address);
|
|
690
|
-
const channel = new MessageChannel(operationalChannel, session);
|
|
691
|
-
await this.#channels.setChannel(address, channel);
|
|
692
|
-
return channel;
|
|
693
|
-
}
|
|
694
|
-
|
|
695
633
|
/** Pair with an operational device (already commissioned) and establish a CASE session. */
|
|
696
634
|
async #pair(
|
|
697
635
|
address: PeerAddress,
|
|
@@ -715,7 +653,8 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
715
653
|
|
|
716
654
|
const operationalChannel = await operationalInterface.openChannel(operationalServerAddress);
|
|
717
655
|
const { sessionParameters } = this.#sessions.findResumptionRecordByAddress(address) ?? {};
|
|
718
|
-
const
|
|
656
|
+
const unsecuredSession = this.#sessions.createUnsecuredSession({
|
|
657
|
+
channel: operationalChannel,
|
|
719
658
|
// Use the session parameters from MDNS announcements when available and rest is assumed to be fallbacks
|
|
720
659
|
sessionParameters: {
|
|
721
660
|
...sessionParameters,
|
|
@@ -727,34 +666,26 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
727
666
|
});
|
|
728
667
|
|
|
729
668
|
try {
|
|
730
|
-
|
|
731
|
-
new MessageChannel(operationalChannel, unsecureSession),
|
|
732
|
-
address,
|
|
733
|
-
options,
|
|
734
|
-
);
|
|
735
|
-
|
|
736
|
-
const channel = new MessageChannel(operationalChannel, operationalSecureSession);
|
|
737
|
-
await this.#channels.setChannel(address, channel);
|
|
738
|
-
return channel;
|
|
669
|
+
return await this.#doCasePair(unsecuredSession, address, options);
|
|
739
670
|
} catch (error) {
|
|
740
671
|
NoResponseTimeoutError.accept(error);
|
|
741
672
|
|
|
742
673
|
// Convert error
|
|
743
674
|
throw new PairRetransmissionLimitReachedError(error.message);
|
|
744
675
|
} finally {
|
|
745
|
-
await
|
|
676
|
+
await unsecuredSession.initiateClose();
|
|
746
677
|
}
|
|
747
678
|
}
|
|
748
679
|
|
|
749
680
|
async #doCasePair(
|
|
750
|
-
|
|
681
|
+
paseSession: Session,
|
|
751
682
|
address: PeerAddress,
|
|
752
683
|
options?: CaseClient.PairOptions,
|
|
753
684
|
): Promise<SecureSession> {
|
|
754
685
|
const fabric = this.#sessions.fabricFor(address);
|
|
755
686
|
let exchange: MessageExchange | undefined;
|
|
756
687
|
try {
|
|
757
|
-
exchange = this.#exchanges.
|
|
688
|
+
exchange = this.#exchanges.initiateExchangeForSession(paseSession, SECURE_CHANNEL_PROTOCOL_ID);
|
|
758
689
|
|
|
759
690
|
const { session, resumed } = await this.#caseClient.pair(exchange, fabric, address.nodeId, options);
|
|
760
691
|
|
|
@@ -776,7 +707,7 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
776
707
|
`Case client: Resumption record seems outdated for Fabric ${NodeId.toHexString(fabric.nodeId)} (index ${fabric.fabricIndex}) and PeerNode ${NodeId.toHexString(address.nodeId)}. Retrying pairing without resumption...`,
|
|
777
708
|
);
|
|
778
709
|
// An endless loop should not happen here, as the resumption record is deleted in the next step
|
|
779
|
-
return await this.#doCasePair(
|
|
710
|
+
return await this.#doCasePair(paseSession, address, options);
|
|
780
711
|
}
|
|
781
712
|
}
|
|
782
713
|
throw error;
|
|
@@ -819,25 +750,24 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
819
750
|
operationalServerAddress?: ServerAddressUdp,
|
|
820
751
|
discoveryData?: DiscoveryData,
|
|
821
752
|
) {
|
|
822
|
-
let peer = this
|
|
753
|
+
let peer = this.get(address);
|
|
823
754
|
if (peer === undefined) {
|
|
824
|
-
peer = { address, dataStore: await this.#store.createNodeStore(address) };
|
|
755
|
+
peer = new Peer({ address, dataStore: await this.#store.createNodeStore(address) }, this.#peerContext);
|
|
825
756
|
this.#peers.add(peer);
|
|
826
757
|
}
|
|
827
|
-
peer.operationalAddress = operationalServerAddress ?? peer.operationalAddress;
|
|
758
|
+
peer.descriptor.operationalAddress = operationalServerAddress ?? peer.descriptor.operationalAddress;
|
|
828
759
|
if (discoveryData !== undefined) {
|
|
829
|
-
peer.discoveryData = {
|
|
830
|
-
...peer.discoveryData,
|
|
760
|
+
peer.descriptor.discoveryData = {
|
|
761
|
+
...peer.descriptor.discoveryData,
|
|
831
762
|
...discoveryData,
|
|
832
763
|
};
|
|
833
764
|
}
|
|
834
|
-
await this.#store.updatePeer(peer);
|
|
835
765
|
|
|
836
766
|
// If we got a new channel and have a running discovery we can end it
|
|
837
|
-
if (peer.operationalAddress !== undefined &&
|
|
767
|
+
if (peer.descriptor.operationalAddress !== undefined && peer.activeDiscovery) {
|
|
838
768
|
logger.info(`Found ${address} during discovery, cancel discovery.`);
|
|
839
769
|
// We are currently discovering this node, so we need to update the discovery data
|
|
840
|
-
const { mdnsClient: mdnsScanner } =
|
|
770
|
+
const { mdnsClient: mdnsScanner } = peer.activeDiscovery ?? {};
|
|
841
771
|
|
|
842
772
|
// This ends discovery and triggers the promises
|
|
843
773
|
mdnsScanner?.cancelOperationalDeviceDiscovery(this.#sessions.fabricFor(address), address.nodeId, true);
|
|
@@ -849,12 +779,13 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
849
779
|
}
|
|
850
780
|
|
|
851
781
|
#getLastOperationalAddress(address: PeerAddress) {
|
|
852
|
-
return this
|
|
782
|
+
return this.get(address)?.descriptor.operationalAddress;
|
|
853
783
|
}
|
|
854
784
|
|
|
855
785
|
#handleFirstRetry(session: Session) {
|
|
856
786
|
if (!session.isSecure || (session as SecureSession).fabric === undefined) {
|
|
857
|
-
// For
|
|
787
|
+
// For unsecured sessions from CASE/PASE or not yet fabric bound session establishments we do not need to do
|
|
788
|
+
// anything
|
|
858
789
|
return;
|
|
859
790
|
}
|
|
860
791
|
const { associatedFabric: fabric, peerNodeId: nodeId } = session;
|
|
@@ -862,11 +793,12 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
862
793
|
return;
|
|
863
794
|
}
|
|
864
795
|
const address = fabric.addressOf(nodeId);
|
|
865
|
-
|
|
796
|
+
const peer = this.for(address);
|
|
797
|
+
if (peer.activeDiscovery) {
|
|
866
798
|
// We already discover for this node, so we do not need to start a new discovery
|
|
867
799
|
return;
|
|
868
800
|
}
|
|
869
|
-
|
|
801
|
+
peer.activeDiscovery = { type: NodeDiscoveryType.RetransmissionDiscovery };
|
|
870
802
|
this.#scanners
|
|
871
803
|
.scannerFor(ChannelType.UDP)
|
|
872
804
|
?.findOperationalDevice(fabric, nodeId, RETRANSMISSION_DISCOVERY_TIMEOUT, true)
|
|
@@ -874,8 +806,8 @@ export class PeerSet implements ImmutableSet<OperationalPeer>, ObservableSet<Ope
|
|
|
874
806
|
logger.error(`Failed to discover ${address} after resubmission started.`, error);
|
|
875
807
|
})
|
|
876
808
|
.finally(() => {
|
|
877
|
-
if (
|
|
878
|
-
|
|
809
|
+
if (peer.activeDiscovery?.type === NodeDiscoveryType.RetransmissionDiscovery) {
|
|
810
|
+
peer.activeDiscovery = undefined;
|
|
879
811
|
}
|
|
880
812
|
});
|
|
881
813
|
}
|