@matter/protocol 0.18.0 → 0.18.1-alpha.0-20261111-b84c5d1bc
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.d.ts +8 -0
- package/dist/cjs/action/Val.d.ts.map +1 -1
- package/dist/cjs/action/client/ClientInteraction.d.ts.map +1 -1
- package/dist/cjs/action/client/ClientInteraction.js +45 -32
- package/dist/cjs/action/client/ClientInteraction.js.map +1 -1
- package/dist/cjs/action/client/ClientRequest.d.ts +14 -0
- package/dist/cjs/action/client/ClientRequest.d.ts.map +1 -1
- package/dist/cjs/action/client/InputChunk.js +39 -2
- package/dist/cjs/action/client/InputChunk.js.map +1 -1
- package/dist/cjs/action/client/subscription/ClientSubscription.d.ts +2 -0
- package/dist/cjs/action/client/subscription/ClientSubscription.d.ts.map +1 -1
- package/dist/cjs/action/client/subscription/ClientSubscription.js +4 -0
- package/dist/cjs/action/client/subscription/ClientSubscription.js.map +1 -1
- package/dist/cjs/action/client/subscription/ClientSubscriptionHandler.d.ts.map +1 -1
- package/dist/cjs/action/client/subscription/ClientSubscriptionHandler.js +14 -0
- package/dist/cjs/action/client/subscription/ClientSubscriptionHandler.js.map +1 -1
- package/dist/cjs/action/client/subscription/PeerSubscription.d.ts +32 -0
- package/dist/cjs/action/client/subscription/PeerSubscription.d.ts.map +1 -1
- package/dist/cjs/action/client/subscription/PeerSubscription.js +61 -0
- package/dist/cjs/action/client/subscription/PeerSubscription.js.map +1 -1
- package/dist/cjs/action/errors.d.ts +3 -1
- package/dist/cjs/action/errors.d.ts.map +1 -1
- package/dist/cjs/action/errors.js +7 -2
- package/dist/cjs/action/errors.js.map +1 -1
- package/dist/cjs/action/protocols.d.ts +6 -1
- package/dist/cjs/action/protocols.d.ts.map +1 -1
- package/dist/cjs/action/request/Invoke.d.ts +24 -1
- package/dist/cjs/action/request/Invoke.d.ts.map +1 -1
- package/dist/cjs/action/request/Invoke.js +40 -12
- package/dist/cjs/action/request/Invoke.js.map +1 -1
- package/dist/cjs/action/request/Write.d.ts.map +1 -1
- package/dist/cjs/action/request/Write.js +6 -5
- package/dist/cjs/action/request/Write.js.map +1 -1
- package/dist/cjs/action/response/InvokeResult.d.ts +8 -2
- package/dist/cjs/action/response/InvokeResult.d.ts.map +1 -1
- package/dist/cjs/action/response/InvokeResult.js +28 -0
- package/dist/cjs/action/response/InvokeResult.js.map +2 -2
- package/dist/cjs/action/response/ReadResult.d.ts +14 -5
- 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 +1 -1
- 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 +4 -2
- package/dist/cjs/action/server/AttributeWriteResponse.js.map +1 -1
- package/dist/cjs/action/server/EventReadResponse.d.ts.map +1 -1
- package/dist/cjs/action/server/EventReadResponse.js +1 -0
- package/dist/cjs/action/server/EventReadResponse.js.map +1 -1
- package/dist/cjs/advertisement/mdns/MdnsAdvertisement.d.ts +1 -1
- package/dist/cjs/advertisement/mdns/MdnsAdvertisement.d.ts.map +1 -1
- package/dist/cjs/advertisement/mdns/MdnsAdvertisement.js +7 -7
- package/dist/cjs/advertisement/mdns/MdnsAdvertisement.js.map +1 -1
- package/dist/cjs/ble/Ble.d.ts +2 -0
- package/dist/cjs/ble/Ble.d.ts.map +1 -1
- package/dist/cjs/ble/Ble.js +4 -0
- package/dist/cjs/ble/Ble.js.map +1 -1
- package/dist/cjs/certificate/CdSigners.d.ts +52 -0
- package/dist/cjs/certificate/CdSigners.d.ts.map +1 -0
- package/dist/cjs/certificate/CdSigners.js +111 -0
- package/dist/cjs/certificate/CdSigners.js.map +6 -0
- package/dist/cjs/certificate/CertificateAuthority.d.ts +1 -1
- package/dist/cjs/certificate/CertificateAuthority.d.ts.map +1 -1
- package/dist/cjs/certificate/DeviceAttestationValidator.d.ts +59 -7
- package/dist/cjs/certificate/DeviceAttestationValidator.d.ts.map +1 -1
- package/dist/cjs/certificate/DeviceAttestationValidator.js +122 -42
- package/dist/cjs/certificate/DeviceAttestationValidator.js.map +1 -1
- package/dist/cjs/certificate/DeviceCertification.d.ts.map +1 -1
- package/dist/cjs/certificate/DeviceCertification.js +5 -2
- package/dist/cjs/certificate/DeviceCertification.js.map +1 -1
- package/dist/cjs/certificate/NocsrValidator.d.ts +57 -0
- package/dist/cjs/certificate/NocsrValidator.d.ts.map +1 -0
- package/dist/cjs/certificate/NocsrValidator.js +109 -0
- package/dist/cjs/certificate/NocsrValidator.js.map +6 -0
- package/dist/cjs/certificate/PeerData.d.ts +12 -0
- package/dist/cjs/certificate/PeerData.d.ts.map +1 -0
- package/dist/cjs/certificate/PeerData.js +33 -0
- package/dist/cjs/certificate/PeerData.js.map +6 -0
- package/dist/cjs/certificate/index.d.ts +2 -0
- package/dist/cjs/certificate/index.d.ts.map +1 -1
- package/dist/cjs/certificate/index.js +2 -0
- package/dist/cjs/certificate/index.js.map +1 -1
- package/dist/cjs/certificate/kinds/AttestationCertificates.d.ts +42 -6
- package/dist/cjs/certificate/kinds/AttestationCertificates.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/AttestationCertificates.js +110 -13
- package/dist/cjs/certificate/kinds/AttestationCertificates.js.map +1 -1
- package/dist/cjs/certificate/kinds/Certificate.d.ts +13 -7
- package/dist/cjs/certificate/kinds/Certificate.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/Certificate.js +146 -240
- package/dist/cjs/certificate/kinds/Certificate.js.map +2 -2
- package/dist/cjs/certificate/kinds/CertificationDeclaration.d.ts +21 -3
- package/dist/cjs/certificate/kinds/CertificationDeclaration.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/CertificationDeclaration.js +76 -20
- package/dist/cjs/certificate/kinds/CertificationDeclaration.js.map +1 -1
- package/dist/cjs/certificate/kinds/DistinguishedName.d.ts +190 -0
- package/dist/cjs/certificate/kinds/DistinguishedName.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/DistinguishedName.js +417 -0
- package/dist/cjs/certificate/kinds/DistinguishedName.js.map +6 -0
- package/dist/cjs/certificate/kinds/Icac.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/Icac.js +5 -10
- package/dist/cjs/certificate/kinds/Icac.js.map +1 -1
- package/dist/cjs/certificate/kinds/Noc.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/Noc.js +5 -4
- package/dist/cjs/certificate/kinds/Noc.js.map +1 -1
- package/dist/cjs/certificate/kinds/OperationalBase.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/OperationalBase.js +4 -2
- package/dist/cjs/certificate/kinds/OperationalBase.js.map +1 -1
- package/dist/cjs/certificate/kinds/Rcac.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/Rcac.js +5 -10
- package/dist/cjs/certificate/kinds/Rcac.js.map +1 -1
- package/dist/cjs/certificate/kinds/Vvsc.d.ts +3 -3
- package/dist/cjs/certificate/kinds/Vvsc.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/Vvsc.js +19 -14
- package/dist/cjs/certificate/kinds/Vvsc.js.map +1 -1
- package/dist/cjs/certificate/kinds/definitions/asn.d.ts +1 -1
- package/dist/cjs/certificate/kinds/definitions/asn.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/definitions/asn.js.map +1 -1
- package/dist/cjs/certificate/kinds/definitions/attestation.d.ts +15 -15
- package/dist/cjs/certificate/kinds/definitions/attestation.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/definitions/base.d.ts +33 -0
- package/dist/cjs/certificate/kinds/definitions/base.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/definitions/base.js +8 -1
- package/dist/cjs/certificate/kinds/definitions/base.js.map +1 -1
- package/dist/cjs/certificate/kinds/definitions/operational.d.ts +24 -20
- package/dist/cjs/certificate/kinds/definitions/operational.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/definitions/operational.js +5 -3
- package/dist/cjs/certificate/kinds/definitions/operational.js.map +1 -1
- package/dist/cjs/codec/MessageCodec.d.ts +27 -2
- package/dist/cjs/codec/MessageCodec.d.ts.map +1 -1
- package/dist/cjs/codec/MessageCodec.js +81 -74
- package/dist/cjs/codec/MessageCodec.js.map +1 -1
- package/dist/cjs/common/OperationalCredentialsTypes.d.ts +6 -0
- package/dist/cjs/common/OperationalCredentialsTypes.d.ts.map +1 -1
- package/dist/cjs/common/OperationalCredentialsTypes.js +2 -0
- package/dist/cjs/common/OperationalCredentialsTypes.js.map +1 -1
- package/dist/cjs/dcl/DclCertificateService.d.ts +28 -7
- package/dist/cjs/dcl/DclCertificateService.d.ts.map +1 -1
- package/dist/cjs/dcl/DclCertificateService.js +103 -30
- package/dist/cjs/dcl/DclCertificateService.js.map +1 -1
- package/dist/cjs/fabric/Fabric.d.ts +10 -5
- package/dist/cjs/fabric/Fabric.d.ts.map +1 -1
- package/dist/cjs/fabric/Fabric.js +12 -5
- package/dist/cjs/fabric/Fabric.js.map +1 -1
- package/dist/cjs/fabric/FabricManager.d.ts +2 -2
- package/dist/cjs/fabric/FabricManager.js +2 -2
- package/dist/cjs/groups/FabricGroups.d.ts +2 -0
- package/dist/cjs/groups/FabricGroups.d.ts.map +1 -1
- package/dist/cjs/groups/FabricGroups.js +4 -0
- package/dist/cjs/groups/FabricGroups.js.map +1 -1
- package/dist/cjs/groups/Groups.d.ts +7 -0
- package/dist/cjs/groups/Groups.d.ts.map +1 -1
- package/dist/cjs/groups/Groups.js +11 -2
- package/dist/cjs/groups/Groups.js.map +1 -1
- package/dist/cjs/groups/KeySets.d.ts +3 -3
- package/dist/cjs/groups/KeySets.js +3 -3
- package/dist/cjs/interaction/InteractionMessenger.d.ts +18 -1
- package/dist/cjs/interaction/InteractionMessenger.d.ts.map +1 -1
- package/dist/cjs/interaction/InteractionMessenger.js +49 -19
- package/dist/cjs/interaction/InteractionMessenger.js.map +1 -1
- package/dist/cjs/mdns/InterfaceResponder.d.ts +137 -0
- package/dist/cjs/mdns/InterfaceResponder.d.ts.map +1 -0
- package/dist/cjs/mdns/InterfaceResponder.js +799 -0
- package/dist/cjs/mdns/InterfaceResponder.js.map +6 -0
- package/dist/cjs/mdns/MdnsServer.d.ts +82 -9
- package/dist/cjs/mdns/MdnsServer.d.ts.map +1 -1
- package/dist/cjs/mdns/MdnsServer.js +337 -267
- 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 -1
- package/dist/cjs/mdns/MdnsService.js.map +1 -1
- package/dist/cjs/peer/AdministratorCommands.d.ts +26 -0
- package/dist/cjs/peer/AdministratorCommands.d.ts.map +1 -0
- package/dist/cjs/peer/AdministratorCommands.js +40 -0
- package/dist/cjs/peer/AdministratorCommands.js.map +6 -0
- package/dist/cjs/peer/CommissioningConnection.d.ts.map +1 -1
- package/dist/cjs/peer/CommissioningConnection.js +4 -2
- package/dist/cjs/peer/CommissioningConnection.js.map +1 -1
- package/dist/cjs/peer/ControllerCommissioner.d.ts +9 -0
- package/dist/cjs/peer/ControllerCommissioner.d.ts.map +1 -1
- package/dist/cjs/peer/ControllerCommissioner.js +59 -13
- package/dist/cjs/peer/ControllerCommissioner.js.map +1 -1
- package/dist/cjs/peer/ControllerCommissioningFlow.d.ts +7 -7
- package/dist/cjs/peer/ControllerCommissioningFlow.d.ts.map +1 -1
- package/dist/cjs/peer/ControllerCommissioningFlow.js +124 -67
- package/dist/cjs/peer/ControllerCommissioningFlow.js.map +1 -1
- package/dist/cjs/peer/OperationalCertificateUpdate.d.ts +181 -0
- package/dist/cjs/peer/OperationalCertificateUpdate.d.ts.map +1 -0
- package/dist/cjs/peer/OperationalCertificateUpdate.js +553 -0
- package/dist/cjs/peer/OperationalCertificateUpdate.js.map +6 -0
- package/dist/cjs/peer/Peer.d.ts +5 -0
- package/dist/cjs/peer/Peer.d.ts.map +1 -1
- package/dist/cjs/peer/Peer.js +29 -1
- package/dist/cjs/peer/Peer.js.map +1 -1
- package/dist/cjs/peer/PeerAddressStore.d.ts +37 -0
- package/dist/cjs/peer/PeerAddressStore.d.ts.map +1 -0
- package/dist/cjs/peer/PeerAddressStore.js +114 -0
- package/dist/cjs/peer/PeerAddressStore.js.map +6 -0
- package/dist/cjs/peer/PeerConnection.d.ts.map +1 -1
- package/dist/cjs/peer/PeerConnection.js +0 -1
- package/dist/cjs/peer/PeerConnection.js.map +1 -1
- package/dist/cjs/peer/PeerDescriptor.d.ts +3 -4
- package/dist/cjs/peer/PeerDescriptor.d.ts.map +1 -1
- package/dist/cjs/peer/PeerDescriptor.js.map +1 -1
- package/dist/cjs/peer/PeerExchangeProvider.d.ts.map +1 -1
- package/dist/cjs/peer/PeerExchangeProvider.js +2 -1
- package/dist/cjs/peer/PeerExchangeProvider.js.map +1 -1
- package/dist/cjs/peer/PeerLossContext.d.ts +10 -2
- package/dist/cjs/peer/PeerLossContext.d.ts.map +1 -1
- package/dist/cjs/peer/PhysicalDeviceProperties.d.ts +13 -0
- package/dist/cjs/peer/PhysicalDeviceProperties.d.ts.map +1 -1
- package/dist/cjs/peer/PhysicalDeviceProperties.js +3 -2
- package/dist/cjs/peer/PhysicalDeviceProperties.js.map +1 -1
- package/dist/cjs/peer/RebootResubscribeArmer.d.ts +3 -3
- package/dist/cjs/peer/RebootResubscribeArmer.d.ts.map +1 -1
- package/dist/cjs/peer/RebootResubscribeArmer.js +21 -9
- package/dist/cjs/peer/RebootResubscribeArmer.js.map +1 -1
- package/dist/cjs/peer/index.d.ts +2 -0
- package/dist/cjs/peer/index.d.ts.map +1 -1
- package/dist/cjs/peer/index.js +2 -0
- package/dist/cjs/peer/index.js.map +1 -1
- package/dist/cjs/protocol/DeviceAdvertiser.d.ts.map +1 -1
- package/dist/cjs/protocol/DeviceAdvertiser.js +1 -1
- package/dist/cjs/protocol/DeviceAdvertiser.js.map +1 -1
- package/dist/cjs/protocol/ExchangeManager.d.ts +0 -1
- package/dist/cjs/protocol/ExchangeManager.d.ts.map +1 -1
- package/dist/cjs/protocol/ExchangeManager.js +136 -64
- package/dist/cjs/protocol/ExchangeManager.js.map +1 -1
- package/dist/cjs/protocol/ExchangeProvider.d.ts +3 -2
- package/dist/cjs/protocol/ExchangeProvider.d.ts.map +1 -1
- package/dist/cjs/protocol/ExchangeProvider.js.map +1 -1
- package/dist/cjs/protocol/MessageExchange.d.ts +13 -0
- package/dist/cjs/protocol/MessageExchange.d.ts.map +1 -1
- package/dist/cjs/protocol/MessageExchange.js +23 -7
- package/dist/cjs/protocol/MessageExchange.js.map +1 -1
- package/dist/cjs/protocol/MessageReceptionState.d.ts +1 -1
- package/dist/cjs/protocol/errors.d.ts +7 -1
- package/dist/cjs/protocol/errors.d.ts.map +1 -1
- package/dist/cjs/protocol/errors.js +3 -0
- package/dist/cjs/protocol/errors.js.map +1 -1
- package/dist/cjs/securechannel/SecureChannelMessenger.d.ts +6 -1
- package/dist/cjs/securechannel/SecureChannelMessenger.d.ts.map +1 -1
- package/dist/cjs/securechannel/SecureChannelMessenger.js +27 -12
- package/dist/cjs/securechannel/SecureChannelMessenger.js.map +1 -1
- package/dist/cjs/session/GroupSession.d.ts +58 -15
- package/dist/cjs/session/GroupSession.d.ts.map +1 -1
- package/dist/cjs/session/GroupSession.js +97 -102
- package/dist/cjs/session/GroupSession.js.map +2 -2
- package/dist/cjs/session/NodeSession.d.ts +50 -1
- package/dist/cjs/session/NodeSession.d.ts.map +1 -1
- package/dist/cjs/session/NodeSession.js +80 -4
- package/dist/cjs/session/NodeSession.js.map +1 -1
- package/dist/cjs/session/SecureSession.d.ts +9 -0
- package/dist/cjs/session/SecureSession.d.ts.map +1 -1
- package/dist/cjs/session/SecureSession.js +12 -0
- package/dist/cjs/session/SecureSession.js.map +1 -1
- package/dist/cjs/session/Session.d.ts +2 -2
- package/dist/cjs/session/Session.d.ts.map +1 -1
- package/dist/cjs/session/Session.js +1 -1
- package/dist/cjs/session/SessionManager.d.ts +76 -28
- package/dist/cjs/session/SessionManager.d.ts.map +1 -1
- package/dist/cjs/session/SessionManager.js +316 -153
- package/dist/cjs/session/SessionManager.js.map +2 -2
- package/dist/cjs/session/UnsecuredSession.d.ts +0 -1
- package/dist/cjs/session/UnsecuredSession.d.ts.map +1 -1
- package/dist/cjs/session/UnsecuredSession.js +2 -4
- package/dist/cjs/session/UnsecuredSession.js.map +1 -1
- package/dist/cjs/session/case/CaseClient.d.ts +5 -0
- package/dist/cjs/session/case/CaseClient.d.ts.map +1 -1
- package/dist/cjs/session/case/CaseClient.js +12 -11
- package/dist/cjs/session/case/CaseClient.js.map +2 -2
- package/dist/cjs/session/case/CaseServer.d.ts.map +1 -1
- package/dist/cjs/session/case/CaseServer.js +31 -11
- package/dist/cjs/session/case/CaseServer.js.map +1 -1
- package/dist/esm/action/Val.d.ts +8 -0
- package/dist/esm/action/Val.d.ts.map +1 -1
- package/dist/esm/action/client/ClientInteraction.d.ts.map +1 -1
- package/dist/esm/action/client/ClientInteraction.js +45 -32
- package/dist/esm/action/client/ClientInteraction.js.map +1 -1
- package/dist/esm/action/client/ClientRequest.d.ts +14 -0
- package/dist/esm/action/client/ClientRequest.d.ts.map +1 -1
- package/dist/esm/action/client/InputChunk.js +39 -2
- package/dist/esm/action/client/InputChunk.js.map +1 -1
- package/dist/esm/action/client/subscription/ClientSubscription.d.ts +2 -0
- package/dist/esm/action/client/subscription/ClientSubscription.d.ts.map +1 -1
- package/dist/esm/action/client/subscription/ClientSubscription.js +4 -0
- package/dist/esm/action/client/subscription/ClientSubscription.js.map +1 -1
- package/dist/esm/action/client/subscription/ClientSubscriptionHandler.d.ts.map +1 -1
- package/dist/esm/action/client/subscription/ClientSubscriptionHandler.js +14 -0
- package/dist/esm/action/client/subscription/ClientSubscriptionHandler.js.map +1 -1
- package/dist/esm/action/client/subscription/PeerSubscription.d.ts +32 -0
- package/dist/esm/action/client/subscription/PeerSubscription.d.ts.map +1 -1
- package/dist/esm/action/client/subscription/PeerSubscription.js +61 -0
- package/dist/esm/action/client/subscription/PeerSubscription.js.map +1 -1
- package/dist/esm/action/errors.d.ts +3 -1
- package/dist/esm/action/errors.d.ts.map +1 -1
- package/dist/esm/action/errors.js +7 -2
- package/dist/esm/action/errors.js.map +1 -1
- package/dist/esm/action/protocols.d.ts +6 -1
- package/dist/esm/action/protocols.d.ts.map +1 -1
- package/dist/esm/action/request/Invoke.d.ts +24 -1
- package/dist/esm/action/request/Invoke.d.ts.map +1 -1
- package/dist/esm/action/request/Invoke.js +41 -13
- package/dist/esm/action/request/Invoke.js.map +1 -1
- package/dist/esm/action/request/Write.d.ts.map +1 -1
- package/dist/esm/action/request/Write.js +7 -6
- package/dist/esm/action/request/Write.js.map +1 -1
- package/dist/esm/action/response/InvokeResult.d.ts +8 -2
- package/dist/esm/action/response/InvokeResult.d.ts.map +1 -1
- package/dist/esm/action/response/InvokeResult.js +26 -0
- package/dist/esm/action/response/InvokeResult.js.map +2 -2
- package/dist/esm/action/response/ReadResult.d.ts +14 -5
- 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 +2 -2
- 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 +11 -3
- package/dist/esm/action/server/AttributeWriteResponse.js.map +1 -1
- package/dist/esm/action/server/EventReadResponse.d.ts.map +1 -1
- package/dist/esm/action/server/EventReadResponse.js +1 -0
- package/dist/esm/action/server/EventReadResponse.js.map +1 -1
- package/dist/esm/advertisement/mdns/MdnsAdvertisement.d.ts +1 -1
- package/dist/esm/advertisement/mdns/MdnsAdvertisement.d.ts.map +1 -1
- package/dist/esm/advertisement/mdns/MdnsAdvertisement.js +7 -7
- package/dist/esm/advertisement/mdns/MdnsAdvertisement.js.map +1 -1
- package/dist/esm/ble/Ble.d.ts +2 -0
- package/dist/esm/ble/Ble.d.ts.map +1 -1
- package/dist/esm/ble/Ble.js +4 -0
- package/dist/esm/ble/Ble.js.map +1 -1
- package/dist/esm/certificate/CdSigners.d.ts +52 -0
- package/dist/esm/certificate/CdSigners.d.ts.map +1 -0
- package/dist/esm/certificate/CdSigners.js +91 -0
- package/dist/esm/certificate/CdSigners.js.map +6 -0
- package/dist/esm/certificate/CertificateAuthority.d.ts +1 -1
- package/dist/esm/certificate/CertificateAuthority.d.ts.map +1 -1
- package/dist/esm/certificate/DeviceAttestationValidator.d.ts +59 -7
- package/dist/esm/certificate/DeviceAttestationValidator.d.ts.map +1 -1
- package/dist/esm/certificate/DeviceAttestationValidator.js +124 -45
- package/dist/esm/certificate/DeviceAttestationValidator.js.map +1 -1
- package/dist/esm/certificate/DeviceCertification.d.ts.map +1 -1
- package/dist/esm/certificate/DeviceCertification.js +5 -2
- package/dist/esm/certificate/DeviceCertification.js.map +1 -1
- package/dist/esm/certificate/NocsrValidator.d.ts +57 -0
- package/dist/esm/certificate/NocsrValidator.d.ts.map +1 -0
- package/dist/esm/certificate/NocsrValidator.js +89 -0
- package/dist/esm/certificate/NocsrValidator.js.map +6 -0
- package/dist/esm/certificate/PeerData.d.ts +12 -0
- package/dist/esm/certificate/PeerData.d.ts.map +1 -0
- package/dist/esm/certificate/PeerData.js +13 -0
- package/dist/esm/certificate/PeerData.js.map +6 -0
- package/dist/esm/certificate/index.d.ts +2 -0
- package/dist/esm/certificate/index.d.ts.map +1 -1
- package/dist/esm/certificate/index.js +2 -0
- package/dist/esm/certificate/index.js.map +1 -1
- package/dist/esm/certificate/kinds/AttestationCertificates.d.ts +42 -6
- package/dist/esm/certificate/kinds/AttestationCertificates.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/AttestationCertificates.js +112 -15
- package/dist/esm/certificate/kinds/AttestationCertificates.js.map +1 -1
- package/dist/esm/certificate/kinds/Certificate.d.ts +13 -7
- package/dist/esm/certificate/kinds/Certificate.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/Certificate.js +153 -256
- package/dist/esm/certificate/kinds/Certificate.js.map +2 -2
- package/dist/esm/certificate/kinds/CertificationDeclaration.d.ts +21 -3
- package/dist/esm/certificate/kinds/CertificationDeclaration.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/CertificationDeclaration.js +79 -20
- package/dist/esm/certificate/kinds/CertificationDeclaration.js.map +1 -1
- package/dist/esm/certificate/kinds/DistinguishedName.d.ts +190 -0
- package/dist/esm/certificate/kinds/DistinguishedName.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/DistinguishedName.js +422 -0
- package/dist/esm/certificate/kinds/DistinguishedName.js.map +6 -0
- package/dist/esm/certificate/kinds/Icac.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/Icac.js +6 -11
- package/dist/esm/certificate/kinds/Icac.js.map +1 -1
- package/dist/esm/certificate/kinds/Noc.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/Noc.js +5 -4
- package/dist/esm/certificate/kinds/Noc.js.map +1 -1
- package/dist/esm/certificate/kinds/OperationalBase.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/OperationalBase.js +4 -2
- package/dist/esm/certificate/kinds/OperationalBase.js.map +1 -1
- package/dist/esm/certificate/kinds/Rcac.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/Rcac.js +6 -11
- package/dist/esm/certificate/kinds/Rcac.js.map +1 -1
- package/dist/esm/certificate/kinds/Vvsc.d.ts +3 -3
- package/dist/esm/certificate/kinds/Vvsc.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/Vvsc.js +20 -15
- package/dist/esm/certificate/kinds/Vvsc.js.map +1 -1
- package/dist/esm/certificate/kinds/definitions/asn.d.ts +1 -1
- package/dist/esm/certificate/kinds/definitions/asn.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/definitions/asn.js.map +1 -1
- package/dist/esm/certificate/kinds/definitions/attestation.d.ts +15 -15
- package/dist/esm/certificate/kinds/definitions/attestation.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/definitions/base.d.ts +33 -0
- package/dist/esm/certificate/kinds/definitions/base.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/definitions/base.js +9 -2
- package/dist/esm/certificate/kinds/definitions/base.js.map +1 -1
- package/dist/esm/certificate/kinds/definitions/operational.d.ts +24 -20
- package/dist/esm/certificate/kinds/definitions/operational.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/definitions/operational.js +5 -3
- package/dist/esm/certificate/kinds/definitions/operational.js.map +1 -1
- package/dist/esm/codec/MessageCodec.d.ts +27 -2
- package/dist/esm/codec/MessageCodec.d.ts.map +1 -1
- package/dist/esm/codec/MessageCodec.js +82 -75
- package/dist/esm/codec/MessageCodec.js.map +1 -1
- package/dist/esm/common/OperationalCredentialsTypes.d.ts +6 -0
- package/dist/esm/common/OperationalCredentialsTypes.d.ts.map +1 -1
- package/dist/esm/common/OperationalCredentialsTypes.js +2 -0
- package/dist/esm/common/OperationalCredentialsTypes.js.map +1 -1
- package/dist/esm/dcl/DclCertificateService.d.ts +28 -7
- package/dist/esm/dcl/DclCertificateService.d.ts.map +1 -1
- package/dist/esm/dcl/DclCertificateService.js +108 -31
- package/dist/esm/dcl/DclCertificateService.js.map +1 -1
- package/dist/esm/fabric/Fabric.d.ts +10 -5
- package/dist/esm/fabric/Fabric.d.ts.map +1 -1
- package/dist/esm/fabric/Fabric.js +12 -5
- package/dist/esm/fabric/Fabric.js.map +1 -1
- package/dist/esm/fabric/FabricManager.d.ts +2 -2
- package/dist/esm/fabric/FabricManager.js +2 -2
- package/dist/esm/groups/FabricGroups.d.ts +2 -0
- package/dist/esm/groups/FabricGroups.d.ts.map +1 -1
- package/dist/esm/groups/FabricGroups.js +4 -0
- package/dist/esm/groups/FabricGroups.js.map +1 -1
- package/dist/esm/groups/Groups.d.ts +7 -0
- package/dist/esm/groups/Groups.d.ts.map +1 -1
- package/dist/esm/groups/Groups.js +11 -2
- package/dist/esm/groups/Groups.js.map +1 -1
- package/dist/esm/groups/KeySets.d.ts +3 -3
- package/dist/esm/groups/KeySets.js +3 -3
- package/dist/esm/interaction/InteractionMessenger.d.ts +18 -1
- package/dist/esm/interaction/InteractionMessenger.d.ts.map +1 -1
- package/dist/esm/interaction/InteractionMessenger.js +50 -20
- package/dist/esm/interaction/InteractionMessenger.js.map +1 -1
- package/dist/esm/mdns/InterfaceResponder.d.ts +137 -0
- package/dist/esm/mdns/InterfaceResponder.d.ts.map +1 -0
- package/dist/esm/mdns/InterfaceResponder.js +794 -0
- package/dist/esm/mdns/InterfaceResponder.js.map +6 -0
- package/dist/esm/mdns/MdnsServer.d.ts +82 -9
- package/dist/esm/mdns/MdnsServer.d.ts.map +1 -1
- package/dist/esm/mdns/MdnsServer.js +341 -273
- 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 -1
- package/dist/esm/mdns/MdnsService.js.map +1 -1
- package/dist/esm/peer/AdministratorCommands.d.ts +26 -0
- package/dist/esm/peer/AdministratorCommands.d.ts.map +1 -0
- package/dist/esm/peer/AdministratorCommands.js +20 -0
- package/dist/esm/peer/AdministratorCommands.js.map +6 -0
- package/dist/esm/peer/CommissioningConnection.d.ts.map +1 -1
- package/dist/esm/peer/CommissioningConnection.js +4 -2
- package/dist/esm/peer/CommissioningConnection.js.map +1 -1
- package/dist/esm/peer/ControllerCommissioner.d.ts +9 -0
- package/dist/esm/peer/ControllerCommissioner.d.ts.map +1 -1
- package/dist/esm/peer/ControllerCommissioner.js +59 -13
- package/dist/esm/peer/ControllerCommissioner.js.map +1 -1
- package/dist/esm/peer/ControllerCommissioningFlow.d.ts +7 -7
- package/dist/esm/peer/ControllerCommissioningFlow.d.ts.map +1 -1
- package/dist/esm/peer/ControllerCommissioningFlow.js +125 -70
- package/dist/esm/peer/ControllerCommissioningFlow.js.map +1 -1
- package/dist/esm/peer/OperationalCertificateUpdate.d.ts +181 -0
- package/dist/esm/peer/OperationalCertificateUpdate.d.ts.map +1 -0
- package/dist/esm/peer/OperationalCertificateUpdate.js +553 -0
- package/dist/esm/peer/OperationalCertificateUpdate.js.map +6 -0
- package/dist/esm/peer/Peer.d.ts +5 -0
- package/dist/esm/peer/Peer.d.ts.map +1 -1
- package/dist/esm/peer/Peer.js +29 -1
- package/dist/esm/peer/Peer.js.map +1 -1
- package/dist/esm/peer/PeerAddressStore.d.ts +37 -0
- package/dist/esm/peer/PeerAddressStore.d.ts.map +1 -0
- package/dist/esm/peer/PeerAddressStore.js +94 -0
- package/dist/esm/peer/PeerAddressStore.js.map +6 -0
- package/dist/esm/peer/PeerConnection.d.ts.map +1 -1
- package/dist/esm/peer/PeerConnection.js +0 -1
- package/dist/esm/peer/PeerConnection.js.map +1 -1
- package/dist/esm/peer/PeerDescriptor.d.ts +3 -4
- package/dist/esm/peer/PeerDescriptor.d.ts.map +1 -1
- package/dist/esm/peer/PeerDescriptor.js.map +1 -1
- package/dist/esm/peer/PeerExchangeProvider.d.ts.map +1 -1
- package/dist/esm/peer/PeerExchangeProvider.js +3 -2
- package/dist/esm/peer/PeerExchangeProvider.js.map +1 -1
- package/dist/esm/peer/PeerLossContext.d.ts +10 -2
- package/dist/esm/peer/PeerLossContext.d.ts.map +1 -1
- package/dist/esm/peer/PhysicalDeviceProperties.d.ts +13 -0
- package/dist/esm/peer/PhysicalDeviceProperties.d.ts.map +1 -1
- package/dist/esm/peer/PhysicalDeviceProperties.js +3 -2
- package/dist/esm/peer/PhysicalDeviceProperties.js.map +1 -1
- package/dist/esm/peer/RebootResubscribeArmer.d.ts +3 -3
- package/dist/esm/peer/RebootResubscribeArmer.d.ts.map +1 -1
- package/dist/esm/peer/RebootResubscribeArmer.js +21 -9
- package/dist/esm/peer/RebootResubscribeArmer.js.map +1 -1
- package/dist/esm/peer/index.d.ts +2 -0
- package/dist/esm/peer/index.d.ts.map +1 -1
- package/dist/esm/peer/index.js +2 -0
- package/dist/esm/peer/index.js.map +1 -1
- package/dist/esm/protocol/DeviceAdvertiser.d.ts.map +1 -1
- package/dist/esm/protocol/DeviceAdvertiser.js +1 -1
- package/dist/esm/protocol/DeviceAdvertiser.js.map +1 -1
- package/dist/esm/protocol/ExchangeManager.d.ts +0 -1
- package/dist/esm/protocol/ExchangeManager.d.ts.map +1 -1
- package/dist/esm/protocol/ExchangeManager.js +145 -67
- package/dist/esm/protocol/ExchangeManager.js.map +1 -1
- package/dist/esm/protocol/ExchangeProvider.d.ts +3 -2
- package/dist/esm/protocol/ExchangeProvider.d.ts.map +1 -1
- package/dist/esm/protocol/ExchangeProvider.js.map +1 -1
- package/dist/esm/protocol/MessageExchange.d.ts +13 -0
- package/dist/esm/protocol/MessageExchange.d.ts.map +1 -1
- package/dist/esm/protocol/MessageExchange.js +23 -7
- package/dist/esm/protocol/MessageExchange.js.map +1 -1
- package/dist/esm/protocol/MessageReceptionState.d.ts +1 -1
- package/dist/esm/protocol/errors.d.ts +7 -1
- package/dist/esm/protocol/errors.d.ts.map +1 -1
- package/dist/esm/protocol/errors.js +4 -1
- package/dist/esm/protocol/errors.js.map +1 -1
- package/dist/esm/securechannel/SecureChannelMessenger.d.ts +6 -1
- package/dist/esm/securechannel/SecureChannelMessenger.d.ts.map +1 -1
- package/dist/esm/securechannel/SecureChannelMessenger.js +27 -12
- package/dist/esm/securechannel/SecureChannelMessenger.js.map +1 -1
- package/dist/esm/session/GroupSession.d.ts +58 -15
- package/dist/esm/session/GroupSession.d.ts.map +1 -1
- package/dist/esm/session/GroupSession.js +97 -102
- package/dist/esm/session/GroupSession.js.map +2 -2
- package/dist/esm/session/NodeSession.d.ts +50 -1
- package/dist/esm/session/NodeSession.d.ts.map +1 -1
- package/dist/esm/session/NodeSession.js +83 -5
- package/dist/esm/session/NodeSession.js.map +1 -1
- package/dist/esm/session/SecureSession.d.ts +9 -0
- package/dist/esm/session/SecureSession.d.ts.map +1 -1
- package/dist/esm/session/SecureSession.js +18 -1
- package/dist/esm/session/SecureSession.js.map +1 -1
- package/dist/esm/session/Session.d.ts +2 -2
- package/dist/esm/session/Session.d.ts.map +1 -1
- package/dist/esm/session/Session.js +1 -1
- package/dist/esm/session/SessionManager.d.ts +76 -28
- package/dist/esm/session/SessionManager.d.ts.map +1 -1
- package/dist/esm/session/SessionManager.js +319 -156
- package/dist/esm/session/SessionManager.js.map +2 -2
- package/dist/esm/session/UnsecuredSession.d.ts +0 -1
- package/dist/esm/session/UnsecuredSession.d.ts.map +1 -1
- package/dist/esm/session/UnsecuredSession.js +5 -3
- package/dist/esm/session/UnsecuredSession.js.map +1 -1
- package/dist/esm/session/case/CaseClient.d.ts +5 -0
- package/dist/esm/session/case/CaseClient.d.ts.map +1 -1
- package/dist/esm/session/case/CaseClient.js +12 -11
- package/dist/esm/session/case/CaseClient.js.map +2 -2
- package/dist/esm/session/case/CaseServer.d.ts.map +1 -1
- package/dist/esm/session/case/CaseServer.js +31 -11
- package/dist/esm/session/case/CaseServer.js.map +1 -1
- package/package.json +5 -5
- package/src/action/Val.ts +8 -0
- package/src/action/client/ClientInteraction.ts +57 -33
- package/src/action/client/ClientRequest.ts +15 -0
- package/src/action/client/InputChunk.ts +57 -2
- package/src/action/client/subscription/ClientSubscription.ts +5 -0
- package/src/action/client/subscription/ClientSubscriptionHandler.ts +15 -0
- package/src/action/client/subscription/PeerSubscription.ts +73 -0
- package/src/action/errors.ts +10 -3
- package/src/action/protocols.ts +7 -1
- package/src/action/request/Invoke.ts +60 -15
- package/src/action/request/Write.ts +7 -6
- package/src/action/response/InvokeResult.ts +32 -2
- package/src/action/response/ReadResult.ts +15 -5
- package/src/action/server/AttributeReadResponse.ts +3 -2
- package/src/action/server/AttributeWriteResponse.ts +14 -3
- package/src/action/server/EventReadResponse.ts +1 -0
- package/src/advertisement/mdns/MdnsAdvertisement.ts +9 -9
- package/src/ble/Ble.ts +5 -0
- package/src/certificate/CdSigners.ts +137 -0
- package/src/certificate/CertificateAuthority.ts +1 -1
- package/src/certificate/DeviceAttestationValidator.ts +213 -56
- package/src/certificate/DeviceCertification.ts +6 -2
- package/src/certificate/NocsrValidator.ts +140 -0
- package/src/certificate/PeerData.ts +15 -0
- package/src/certificate/index.ts +2 -0
- package/src/certificate/kinds/AttestationCertificates.ts +183 -15
- package/src/certificate/kinds/Certificate.ts +203 -308
- package/src/certificate/kinds/CertificationDeclaration.ts +100 -46
- package/src/certificate/kinds/DistinguishedName.ts +677 -0
- package/src/certificate/kinds/Icac.ts +7 -12
- package/src/certificate/kinds/Noc.ts +12 -8
- package/src/certificate/kinds/OperationalBase.ts +5 -2
- package/src/certificate/kinds/Rcac.ts +7 -12
- package/src/certificate/kinds/Vvsc.ts +24 -15
- package/src/certificate/kinds/definitions/asn.ts +1 -1
- package/src/certificate/kinds/definitions/attestation.ts +15 -15
- package/src/certificate/kinds/definitions/base.ts +43 -1
- package/src/certificate/kinds/definitions/operational.ts +4 -3
- package/src/codec/MessageCodec.ts +92 -81
- package/src/common/OperationalCredentialsTypes.ts +7 -0
- package/src/dcl/DclCertificateService.ts +135 -36
- package/src/fabric/Fabric.ts +13 -6
- package/src/fabric/FabricManager.ts +2 -2
- package/src/groups/FabricGroups.ts +5 -0
- package/src/groups/Groups.ts +12 -3
- package/src/groups/KeySets.ts +3 -3
- package/src/interaction/InteractionMessenger.ts +58 -20
- package/src/mdns/InterfaceResponder.ts +1031 -0
- package/src/mdns/MdnsServer.ts +400 -360
- package/src/mdns/MdnsService.ts +2 -0
- package/src/peer/AdministratorCommands.ts +37 -0
- package/src/peer/CommissioningConnection.ts +5 -1
- package/src/peer/ControllerCommissioner.ts +69 -19
- package/src/peer/ControllerCommissioningFlow.ts +149 -99
- package/src/peer/OperationalCertificateUpdate.ts +922 -0
- package/src/peer/Peer.ts +31 -16
- package/src/peer/PeerAddressStore.ts +119 -0
- package/src/peer/PeerConnection.ts +0 -1
- package/src/peer/PeerDescriptor.ts +3 -4
- package/src/peer/PeerExchangeProvider.ts +4 -6
- package/src/peer/PeerLossContext.ts +11 -2
- package/src/peer/PhysicalDeviceProperties.ts +25 -12
- package/src/peer/RebootResubscribeArmer.ts +37 -16
- package/src/peer/index.ts +2 -0
- package/src/protocol/DeviceAdvertiser.ts +5 -1
- package/src/protocol/ExchangeManager.ts +162 -88
- package/src/protocol/ExchangeProvider.ts +3 -2
- package/src/protocol/MessageExchange.ts +29 -7
- package/src/protocol/MessageReceptionState.ts +2 -2
- package/src/protocol/errors.ts +7 -1
- package/src/securechannel/SecureChannelMessenger.ts +26 -13
- package/src/session/GroupSession.ts +147 -111
- package/src/session/NodeSession.ts +89 -4
- package/src/session/SecureSession.ts +27 -1
- package/src/session/Session.ts +2 -2
- package/src/session/SessionManager.ts +429 -189
- package/src/session/UnsecuredSession.ts +9 -3
- package/src/session/case/CaseClient.ts +15 -10
- package/src/session/case/CaseServer.ts +41 -17
|
@@ -6,16 +6,18 @@
|
|
|
6
6
|
import { SupportedTransportsSchema } from "#common/SupportedTransportsBitmap.js";
|
|
7
7
|
import { FabricManager } from "#fabric/FabricManager.js";
|
|
8
8
|
import { PeerAddress, PeerAddressMap } from "#peer/PeerAddress.js";
|
|
9
|
+
import { PeerAddressStore } from "#peer/PeerAddressStore.js";
|
|
9
10
|
import { PeerShutdownError } from "#peer/PeerCommunicationError.js";
|
|
10
11
|
import { SessionClosedError } from "#protocol/errors.js";
|
|
11
|
-
import { GroupSession, GroupSessionDecodeError
|
|
12
|
+
import { GroupSession, GroupSessionDecodeError } from "#session/GroupSession.js";
|
|
12
13
|
import {
|
|
14
|
+
Diagnostic,
|
|
13
15
|
BasicSet,
|
|
14
16
|
Bytes,
|
|
15
|
-
causedBy,
|
|
16
17
|
ClosedError,
|
|
17
18
|
Construction,
|
|
18
19
|
Environmental,
|
|
20
|
+
hex,
|
|
19
21
|
ImplementationError,
|
|
20
22
|
InternalError,
|
|
21
23
|
Lifecycle,
|
|
@@ -27,15 +29,14 @@ import {
|
|
|
27
29
|
Observable,
|
|
28
30
|
ObserverGroup,
|
|
29
31
|
StorageManager,
|
|
30
|
-
Time,
|
|
31
32
|
toHex,
|
|
32
33
|
UnexpectedDataError
|
|
33
34
|
} from "@matter/general";
|
|
34
35
|
import { GroupId, NodeId } from "@matter/types";
|
|
35
|
-
import { Groupcast } from "@matter/types/clusters/groupcast";
|
|
36
36
|
import { MessageCounter, PersistedMessageCounter } from "../protocol/MessageCounter.js";
|
|
37
37
|
import { NodeSession } from "./NodeSession.js";
|
|
38
38
|
import { SecureSession } from "./SecureSession.js";
|
|
39
|
+
import { Session } from "./Session.js";
|
|
39
40
|
import { SessionIntervals } from "./SessionIntervals.js";
|
|
40
41
|
import { SessionParameters } from "./SessionParameters.js";
|
|
41
42
|
import { UnsecuredSession } from "./UnsecuredSession.js";
|
|
@@ -55,6 +56,9 @@ function assertMaxPathsPerInvoke(maxPathsPerInvoke) {
|
|
|
55
56
|
}
|
|
56
57
|
const ID_SPACE_UPPER_BOUND = 65535;
|
|
57
58
|
const MAX_SESSIONS_PER_PEER = 5;
|
|
59
|
+
const RESUMPTION_RECORDS_CONTEXT = "resumption";
|
|
60
|
+
const LEGACY_RESUMPTION_RECORDS_KEY = "resumptionRecords";
|
|
61
|
+
const RESUMPTION_RECORD_VERSION = 1;
|
|
58
62
|
const GROUP_DATA_COUNTER_KEY = "groupDataCounter";
|
|
59
63
|
const GROUP_DATA_COUNTER_RESERVE = 1e3;
|
|
60
64
|
class SessionEvictedError extends ClosedError {
|
|
@@ -71,10 +75,13 @@ class SessionManager {
|
|
|
71
75
|
#logger;
|
|
72
76
|
#context;
|
|
73
77
|
#unsecuredSessions = /* @__PURE__ */ new Map();
|
|
74
|
-
#
|
|
78
|
+
#establishedSessions = new BasicSet();
|
|
79
|
+
#registeredSessions = new RegisteredSessions(this.#establishedSessions);
|
|
75
80
|
#groupSessions = /* @__PURE__ */ new Map();
|
|
76
81
|
#nextSessionId;
|
|
77
82
|
#resumptionRecords = new PeerAddressMap();
|
|
83
|
+
#resumptionRecordsById = /* @__PURE__ */ new Map();
|
|
84
|
+
#resumptionStore;
|
|
78
85
|
#globalUnencryptedMessageCounter;
|
|
79
86
|
#groupDataMessageCounter;
|
|
80
87
|
#sessionParameters;
|
|
@@ -99,6 +106,7 @@ class SessionManager {
|
|
|
99
106
|
constructor(context) {
|
|
100
107
|
this.#context = context;
|
|
101
108
|
this.#logger = Logger.get("SessionManager", context.origin);
|
|
109
|
+
this.#resumptionStore = new PeerAddressStore(context.storage.createContext(RESUMPTION_RECORDS_CONTEXT));
|
|
102
110
|
const {
|
|
103
111
|
fabrics: { crypto }
|
|
104
112
|
} = context;
|
|
@@ -115,12 +123,7 @@ class SessionManager {
|
|
|
115
123
|
this.#observers.on(context.fabrics.events.deleting, async (fabric) => {
|
|
116
124
|
await this.deleteResumptionRecordsForFabric(fabric);
|
|
117
125
|
});
|
|
118
|
-
this.#
|
|
119
|
-
if (!session.isInitiator) {
|
|
120
|
-
this.#sessionEvictionMutex.run(() => this.#evictExcessSessionsFor(session));
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
this.#sessions.added.on((session) => {
|
|
126
|
+
this.#registeredSessions.added.on((session) => {
|
|
124
127
|
const subscriptionsChanged = (subscription) => {
|
|
125
128
|
if (session.isClosing) {
|
|
126
129
|
return;
|
|
@@ -134,6 +137,10 @@ class SessionManager {
|
|
|
134
137
|
session.subscriptions.deleted.off(subscriptionsChanged);
|
|
135
138
|
});
|
|
136
139
|
});
|
|
140
|
+
this.#registeredSessions.deleted.on((session) => {
|
|
141
|
+
this.#establishedSessions.delete(session);
|
|
142
|
+
});
|
|
143
|
+
this.#establishedSessions.added.on((session) => this.#sessionEstablished(session));
|
|
137
144
|
this.#construction = Construction(this, () => this.#initialize());
|
|
138
145
|
}
|
|
139
146
|
static [Environmental.create](env) {
|
|
@@ -163,10 +170,54 @@ class SessionManager {
|
|
|
163
170
|
return this.#groupDataMessageCounter;
|
|
164
171
|
}
|
|
165
172
|
/**
|
|
166
|
-
*
|
|
173
|
+
* The established secure sessions. A session joins once its handshake completed, so {@link ObservableSet.added}
|
|
174
|
+
* emits on establishment, and a session whose handshake fails never appears. It leaves when it closes.
|
|
175
|
+
*
|
|
176
|
+
* Read this set to find a session to use, or to list or observe the sessions with peers.
|
|
177
|
+
*
|
|
178
|
+
* Read {@link registeredSessions} instead for subscriptions and reports, and for session teardown and message
|
|
179
|
+
* routing. A peer may send a Subscribe on a session we respond to before that session is established, so the
|
|
180
|
+
* subscriptions of a peer may live on a session that is not in this set. The CHIP SDK drops such messages; we
|
|
181
|
+
* serve them, see {@link NodeSession.isEstablishing}.
|
|
167
182
|
*/
|
|
168
183
|
get sessions() {
|
|
169
|
-
return this.#
|
|
184
|
+
return this.#establishedSessions;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Every secure session that receives messages, including those whose handshake still runs (see
|
|
188
|
+
* {@link NodeSession.isEstablishing}). A session joins on creation, unless it is created with
|
|
189
|
+
* `delayManagerRegistration`, and leaves when it closes.
|
|
190
|
+
*
|
|
191
|
+
* Read this set for message routing, session ID allocation, session teardown, peer loss, and for the subscriptions
|
|
192
|
+
* and reports of a peer. Code that looks for a session to use reads {@link sessions}.
|
|
193
|
+
*
|
|
194
|
+
* {@link sessions} emits {@link ObservableSet.added} for a session only after every observer of `added` here ran,
|
|
195
|
+
* so components that wire up a session here, such as the ExchangeManager, are ready before users of the
|
|
196
|
+
* established session see it.
|
|
197
|
+
*/
|
|
198
|
+
get registeredSessions() {
|
|
199
|
+
return this.#registeredSessions;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* The number of registrations in {@link registeredSessions} so far. A session registered from now on gets this
|
|
203
|
+
* value or a higher one as its registration position, so the value marks "sessions registered after this point"
|
|
204
|
+
* for {@link PeerLossContext.registeredBefore}.
|
|
205
|
+
*/
|
|
206
|
+
get registrationCount() {
|
|
207
|
+
return this.#registeredSessions.count;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* The open sessions with the peer of {@link session} that registered at or after it. {@link handlePeerShutdown}
|
|
211
|
+
* keeps these sessions when it receives {@link session}. For a session that never registered, the result is empty.
|
|
212
|
+
*/
|
|
213
|
+
sessionsRegisteredSince(session) {
|
|
214
|
+
const position = this.#registeredSessions.positionOf(session);
|
|
215
|
+
if (position === void 0) {
|
|
216
|
+
return [];
|
|
217
|
+
}
|
|
218
|
+
return this.sessionsFor(session.peerAddress).filter(
|
|
219
|
+
(other) => !this.#registeredSessions.isRegisteredBefore(other, position)
|
|
220
|
+
);
|
|
170
221
|
}
|
|
171
222
|
/**
|
|
172
223
|
* Active unsecured sessions.
|
|
@@ -223,7 +274,10 @@ class SessionManager {
|
|
|
223
274
|
return this.#retry;
|
|
224
275
|
}
|
|
225
276
|
/**
|
|
226
|
-
* Emits for
|
|
277
|
+
* Emits for a received group message whose keys are tried: when no candidate key passes, when the message is a
|
|
278
|
+
* replay, and when the Interaction Model processes a group invoke request. A datagram the codec refuses and a
|
|
279
|
+
* message with the R or A flag emit nothing. Any other message, such as a group write or a message for an
|
|
280
|
+
* unsupported protocol, emits only MessageReplay for a replayed copy. Observers remain inactive until at least one
|
|
227
281
|
* listener attaches, so fabrics not under test incur no emission overhead.
|
|
228
282
|
*/
|
|
229
283
|
get onGroupMessage() {
|
|
@@ -289,9 +343,9 @@ class SessionManager {
|
|
|
289
343
|
*/
|
|
290
344
|
async deleteResumptionRecord(address) {
|
|
291
345
|
await this.#construction;
|
|
292
|
-
const result = this.#
|
|
346
|
+
const result = this.#forgetResumptionRecord(address);
|
|
293
347
|
if (result) {
|
|
294
|
-
await this.#
|
|
348
|
+
await this.#resumptionStore.delete(address);
|
|
295
349
|
}
|
|
296
350
|
return result;
|
|
297
351
|
}
|
|
@@ -302,22 +356,20 @@ class SessionManager {
|
|
|
302
356
|
async deleteResumptionRecordsForFabric(fabric) {
|
|
303
357
|
await this.#construction;
|
|
304
358
|
let deletedCount = 0;
|
|
305
|
-
for (const address of this.#resumptionRecords.keys()) {
|
|
306
|
-
if (address.fabricIndex === fabric.fabricIndex) {
|
|
307
|
-
|
|
308
|
-
deletedCount++;
|
|
309
|
-
}
|
|
359
|
+
for (const address of [...this.#resumptionRecords.keys()]) {
|
|
360
|
+
if (address.fabricIndex === fabric.fabricIndex && this.#forgetResumptionRecord(address)) {
|
|
361
|
+
deletedCount++;
|
|
310
362
|
}
|
|
311
363
|
}
|
|
312
364
|
if (deletedCount > 0) {
|
|
313
|
-
await this.#
|
|
365
|
+
await this.#resumptionStore.deleteFabric(fabric.fabricIndex);
|
|
314
366
|
}
|
|
315
367
|
return deletedCount > 0;
|
|
316
368
|
}
|
|
317
|
-
/** The session with the least recent traffic among
|
|
318
|
-
#leastRecentlyUsedSession(filter) {
|
|
369
|
+
/** The session with the least recent traffic among {@link sessions} that {@link filter} accepts, if any. */
|
|
370
|
+
#leastRecentlyUsedSession(sessions, filter) {
|
|
319
371
|
let oldest;
|
|
320
|
-
for (const session of
|
|
372
|
+
for (const session of sessions) {
|
|
321
373
|
if (filter(session) && (oldest === void 0 || session.timestamp < oldest.timestamp)) {
|
|
322
374
|
oldest = session;
|
|
323
375
|
}
|
|
@@ -326,7 +378,7 @@ class SessionManager {
|
|
|
326
378
|
}
|
|
327
379
|
findOldestInactiveSession() {
|
|
328
380
|
this.#construction.assert();
|
|
329
|
-
const oldest = this.#leastRecentlyUsedSession(() => true);
|
|
381
|
+
const oldest = this.#leastRecentlyUsedSession(this.#registeredSessions, () => true);
|
|
330
382
|
if (oldest === void 0) {
|
|
331
383
|
throw new MatterFlowError("No session found to close and all session ids are taken.");
|
|
332
384
|
}
|
|
@@ -362,16 +414,16 @@ class SessionManager {
|
|
|
362
414
|
}
|
|
363
415
|
getSession(sessionId) {
|
|
364
416
|
this.#construction.assert();
|
|
365
|
-
return this.#
|
|
417
|
+
return this.#registeredSessions.get("id", sessionId);
|
|
366
418
|
}
|
|
367
419
|
getPaseSession() {
|
|
368
420
|
this.#construction.assert();
|
|
369
|
-
return
|
|
421
|
+
return this.#establishedSessions.find((session) => session.isPase && !session.isClosing);
|
|
370
422
|
}
|
|
371
423
|
forFabric(fabric) {
|
|
372
424
|
this.#construction.assert();
|
|
373
|
-
return
|
|
374
|
-
(session) =>
|
|
425
|
+
return this.#establishedSessions.filter(
|
|
426
|
+
(session) => session.isSecure && session.fabric?.fabricIndex === fabric.fabricIndex
|
|
375
427
|
);
|
|
376
428
|
}
|
|
377
429
|
sessionFor(peer) {
|
|
@@ -384,7 +436,7 @@ class SessionManager {
|
|
|
384
436
|
maybeSessionFor(address) {
|
|
385
437
|
this.#construction.assert();
|
|
386
438
|
let found;
|
|
387
|
-
for (const session of this.#
|
|
439
|
+
for (const session of this.#establishedSessions) {
|
|
388
440
|
if (!session.peerIs(address) || session.isClosing || session.isPeerLost) {
|
|
389
441
|
continue;
|
|
390
442
|
}
|
|
@@ -396,39 +448,71 @@ class SessionManager {
|
|
|
396
448
|
}
|
|
397
449
|
sessionsFor(address) {
|
|
398
450
|
address = PeerAddress(address);
|
|
399
|
-
return this.#
|
|
451
|
+
return this.#registeredSessions.filter((session) => session.peerAddress === address && !session.isClosing);
|
|
400
452
|
}
|
|
401
453
|
sessionsForFabricIndex(fabricIndex) {
|
|
402
|
-
return this.#
|
|
454
|
+
return this.#registeredSessions.filter((session) => session.fabric?.fabricIndex === fabricIndex);
|
|
403
455
|
}
|
|
404
456
|
/**
|
|
405
457
|
* Removes all Peer sessions without first closing the subscriptions the peer holds on them; those end when the
|
|
406
458
|
* sessions close. Our own subscriptions to the peer belong to the peer, not to a session, so a peer that persists
|
|
407
459
|
* subscriptions can refresh them after its restart.
|
|
408
460
|
*
|
|
409
|
-
*
|
|
410
|
-
*
|
|
461
|
+
* Sessions that register while the shutdown runs are kept.
|
|
462
|
+
*
|
|
463
|
+
* @param keep this session and the sessions registered after it are kept. Without it, or for a session that never
|
|
464
|
+
* registered, every session registered now is removed. A {@link Timestamp} is deprecated: then only the sessions
|
|
465
|
+
* created before that instant are removed, and a session created in the same instant counts as newer.
|
|
411
466
|
*/
|
|
412
|
-
handlePeerShutdown(address,
|
|
413
|
-
|
|
467
|
+
handlePeerShutdown(address, keep) {
|
|
468
|
+
const context = {
|
|
414
469
|
address,
|
|
415
470
|
cause: new PeerShutdownError(),
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
}
|
|
471
|
+
keepSubscriptions: true,
|
|
472
|
+
registeredBefore: this.registrationCount
|
|
473
|
+
};
|
|
474
|
+
if (typeof keep === "number") {
|
|
475
|
+
return this.#handlePeerLoss({ ...context, asOf: keep });
|
|
476
|
+
}
|
|
477
|
+
const keepPosition = keep === void 0 ? void 0 : this.#registeredSessions.positionOf(keep);
|
|
478
|
+
return this.#handlePeerLoss({ ...context, registeredBefore: keepPosition ?? context.registeredBefore });
|
|
419
479
|
}
|
|
420
480
|
/**
|
|
421
|
-
* Removes all Peer sessions and closes subscriptions.
|
|
481
|
+
* Removes all Peer sessions and closes subscriptions. Only the sessions registered before
|
|
482
|
+
* {@link PeerLossContext.registeredBefore} are affected; by default every session registered now. A given
|
|
483
|
+
* {@link PeerLossContext.asOf} applies in addition.
|
|
422
484
|
*/
|
|
423
485
|
async handlePeerLoss(address, context) {
|
|
424
|
-
return await this.#handlePeerLoss({
|
|
486
|
+
return await this.#handlePeerLoss({
|
|
487
|
+
...context,
|
|
488
|
+
address,
|
|
489
|
+
registeredBefore: context.registeredBefore ?? this.registrationCount
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Supersede the older sessions {@link newer} replaces, then evict excess sessions of the peer. Supersession comes
|
|
494
|
+
* first and is synchronous, so the subscriptions have left a session before eviction can close it.
|
|
495
|
+
*
|
|
496
|
+
* An older session that is still establishing is not superseded. Subscriptions exist on such a session only if a
|
|
497
|
+
* Subscribe arrived before its handshake finished. If that handshake fails, the subscriptions close with it.
|
|
498
|
+
*/
|
|
499
|
+
#sessionEstablished(newer) {
|
|
500
|
+
for (const older of this.#establishedSessions) {
|
|
501
|
+
if (older !== newer && !older.isClosing && supersedes(newer, older)) {
|
|
502
|
+
older.superseded.emit(newer);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
if (!newer.isInitiator) {
|
|
506
|
+
this.#sessionEvictionMutex.run(() => this.#evictExcessSessionsFor(newer));
|
|
507
|
+
}
|
|
425
508
|
}
|
|
426
509
|
/**
|
|
427
510
|
* Close the peer's least recently active sessions once it exceeds {@link MAX_SESSIONS_PER_PEER}.
|
|
428
511
|
*
|
|
429
512
|
* Only sessions the peer established are eligible: ones we initiated are ours to manage, and the peer loss our
|
|
430
513
|
* own traffic reports already sweeps them. {@link added} is excluded so a burst of new sessions cannot evict the
|
|
431
|
-
* one that prompted the check.
|
|
514
|
+
* one that prompted the check. Only established sessions count and are evicted; an establishing session becomes
|
|
515
|
+
* established or closes within its handshake.
|
|
432
516
|
*/
|
|
433
517
|
async #evictExcessSessionsFor(added) {
|
|
434
518
|
if (added.isPase || added.isClosing) {
|
|
@@ -436,9 +520,12 @@ class SessionManager {
|
|
|
436
520
|
}
|
|
437
521
|
const address = added.peerAddress;
|
|
438
522
|
const claimsSlot = (session) => session !== added && !session.isInitiator && session.peerIs(address);
|
|
439
|
-
let excess = this.#
|
|
523
|
+
let excess = this.#establishedSessions.filter(claimsSlot).length + 1 - MAX_SESSIONS_PER_PEER;
|
|
440
524
|
while (excess-- > 0) {
|
|
441
|
-
const session = this.#leastRecentlyUsedSession(
|
|
525
|
+
const session = this.#leastRecentlyUsedSession(
|
|
526
|
+
this.#establishedSessions,
|
|
527
|
+
(s) => claimsSlot(s) && !s.isClosing
|
|
528
|
+
);
|
|
442
529
|
if (session === void 0) {
|
|
443
530
|
return;
|
|
444
531
|
}
|
|
@@ -451,11 +538,14 @@ class SessionManager {
|
|
|
451
538
|
}
|
|
452
539
|
async #handlePeerLoss(context) {
|
|
453
540
|
await this.#construction;
|
|
454
|
-
const { address, asOf } = context;
|
|
455
|
-
for (const session of this.#
|
|
541
|
+
const { address, asOf, registeredBefore } = context;
|
|
542
|
+
for (const session of this.#registeredSessions) {
|
|
456
543
|
if (!session.peerIs(address)) {
|
|
457
544
|
continue;
|
|
458
545
|
}
|
|
546
|
+
if (registeredBefore !== void 0 && !this.#registeredSessions.isRegisteredBefore(session, registeredBefore)) {
|
|
547
|
+
continue;
|
|
548
|
+
}
|
|
459
549
|
if (asOf !== void 0 && session.createdAt >= asOf) {
|
|
460
550
|
continue;
|
|
461
551
|
}
|
|
@@ -501,9 +591,11 @@ class SessionManager {
|
|
|
501
591
|
});
|
|
502
592
|
}
|
|
503
593
|
/**
|
|
504
|
-
* Obtain a Group session for an incoming packet.
|
|
594
|
+
* Obtain a Group session for an incoming packet, with the decoded message and the facts decode established.
|
|
505
595
|
*
|
|
506
|
-
* The session ID is determined by decrypting the packet with possible keys.
|
|
596
|
+
* The session ID is determined by decrypting the packet with possible keys. Returns `undefined` when no candidate
|
|
597
|
+
* key passes; the message is then reported via {@link onGroupMessage} and must be dropped. Also returns
|
|
598
|
+
* `undefined`, without a report, for a group data message with the R or A flag.
|
|
507
599
|
*
|
|
508
600
|
* Note that the resulting session is non-operational in the sense that attempting outbound communication will
|
|
509
601
|
* result in an error.
|
|
@@ -512,33 +604,26 @@ class SessionManager {
|
|
|
512
604
|
this.#construction.assert();
|
|
513
605
|
let decoded;
|
|
514
606
|
try {
|
|
515
|
-
decoded = GroupSession.
|
|
607
|
+
decoded = GroupSession.decodeWithCandidateKeys(this.#context.fabrics, packet, aad);
|
|
516
608
|
} catch (error) {
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
})
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
}
|
|
535
|
-
const { message, key, privacyKey, sessionId, sourceNodeId, keySetId, fabric } = decoded;
|
|
536
|
-
const rawGroupId = message.packetHeader.destGroupId;
|
|
537
|
-
if (rawGroupId === void 0) {
|
|
538
|
-
throw new UnexpectedDataError("Group ID is required for GroupSession fromPacket.");
|
|
609
|
+
GroupSessionDecodeError.accept(error);
|
|
610
|
+
const { candidateFabrics, group } = error;
|
|
611
|
+
this.#logger.debug(
|
|
612
|
+
`Dropping group message for session ${Session.idStrOf(packet)} from ${sourceIp ?? "unknown address"}:`,
|
|
613
|
+
error.message,
|
|
614
|
+
Diagnostic.dict({ candidateFabrics: candidateFabrics.size })
|
|
615
|
+
);
|
|
616
|
+
this.#onGroupMessage.emit({ kind: "unauthenticated", candidateFabrics, group, sourceIp });
|
|
617
|
+
return void 0;
|
|
618
|
+
}
|
|
619
|
+
const { message, key, privacyKey, sessionId, sourceNodeId, groupId, keySetId, fabric } = decoded;
|
|
620
|
+
const { requiresAck, ackedMessageId } = message.payloadHeader;
|
|
621
|
+
if (requiresAck || ackedMessageId !== void 0) {
|
|
622
|
+
this.#logger.debug(
|
|
623
|
+
`Dropping group message ${hex.fixed(message.packetHeader.messageId, 8)} for session ${Session.idStrOf(packet)} with the ${requiresAck ? "R" : "A"} flag`
|
|
624
|
+
);
|
|
625
|
+
return void 0;
|
|
539
626
|
}
|
|
540
|
-
const groupId = GroupId(rawGroupId);
|
|
541
|
-
GroupId.assertGroupId(groupId);
|
|
542
627
|
let session = this.#groupSessions.get(sourceNodeId)?.find((s) => s.matches(fabric.fabricIndex, sessionId, key));
|
|
543
628
|
if (session === void 0) {
|
|
544
629
|
session = new GroupSession({
|
|
@@ -553,9 +638,9 @@ class SessionManager {
|
|
|
553
638
|
messageCounter: this.#groupDataMessageCounter
|
|
554
639
|
});
|
|
555
640
|
}
|
|
556
|
-
return { session, message, key };
|
|
641
|
+
return { session, message, key, sourceNodeId, groupId };
|
|
557
642
|
}
|
|
558
|
-
/** Report
|
|
643
|
+
/** Report an authenticated group message (used by ExchangeManager for replay and InteractionServer for dispatch). */
|
|
559
644
|
emitGroupMessage(info) {
|
|
560
645
|
this.#onGroupMessage.emit(info);
|
|
561
646
|
}
|
|
@@ -580,9 +665,7 @@ class SessionManager {
|
|
|
580
665
|
}
|
|
581
666
|
findResumptionRecordById(resumptionId) {
|
|
582
667
|
this.#construction.assert();
|
|
583
|
-
const record =
|
|
584
|
-
(record2) => Bytes.areEqual(record2.resumptionId, resumptionId)
|
|
585
|
-
);
|
|
668
|
+
const record = this.#resumptionRecordsById.get(Bytes.toHex(resumptionId));
|
|
586
669
|
if (record !== void 0) {
|
|
587
670
|
return this.#asExposedResumptionRecord(record);
|
|
588
671
|
}
|
|
@@ -602,40 +685,27 @@ class SessionManager {
|
|
|
602
685
|
fabricId: fabric.fabricId,
|
|
603
686
|
fabricIndex: fabric.fabricIndex
|
|
604
687
|
};
|
|
605
|
-
|
|
606
|
-
|
|
688
|
+
const address = fabric.addressOf(resumptionRecord.peerNodeId);
|
|
689
|
+
this.#rememberResumptionRecord(address, record);
|
|
690
|
+
await this.#resumptionStore.set(address, storageRecordOf(record));
|
|
607
691
|
}
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
nodeId: address.nodeId,
|
|
626
|
-
sharedSecret,
|
|
627
|
-
resumptionId,
|
|
628
|
-
fabricId,
|
|
629
|
-
fabricIndex,
|
|
630
|
-
peerNodeId,
|
|
631
|
-
sessionParameters: {
|
|
632
|
-
...sessionParameters,
|
|
633
|
-
supportedTransports: sessionParameters.supportedTransports ? SupportedTransportsSchema.encode(sessionParameters.supportedTransports) : void 0
|
|
634
|
-
},
|
|
635
|
-
caseAuthenticatedTags
|
|
636
|
-
})
|
|
637
|
-
)
|
|
638
|
-
);
|
|
692
|
+
#rememberResumptionRecord(address, record) {
|
|
693
|
+
this.#forgetResumptionRecord(address);
|
|
694
|
+
this.#resumptionRecords.set(address, record);
|
|
695
|
+
this.#resumptionRecordsById.set(Bytes.toHex(record.resumptionId), record);
|
|
696
|
+
}
|
|
697
|
+
#forgetAllResumptionRecords() {
|
|
698
|
+
this.#resumptionRecords.clear();
|
|
699
|
+
this.#resumptionRecordsById.clear();
|
|
700
|
+
}
|
|
701
|
+
#forgetResumptionRecord(address) {
|
|
702
|
+
const record = this.#resumptionRecords.get(address);
|
|
703
|
+
if (record === void 0) {
|
|
704
|
+
return false;
|
|
705
|
+
}
|
|
706
|
+
this.#resumptionRecords.delete(address);
|
|
707
|
+
this.#resumptionRecordsById.delete(Bytes.toHex(record.resumptionId));
|
|
708
|
+
return true;
|
|
639
709
|
}
|
|
640
710
|
#maybeFabricForId(fabricId, fabricIndex) {
|
|
641
711
|
return this.#context.fabrics.find(
|
|
@@ -653,49 +723,64 @@ class SessionManager {
|
|
|
653
723
|
async #initialize() {
|
|
654
724
|
await this.#context.fabrics.construction;
|
|
655
725
|
this.#groupDataMessageCounter = await this.#createGroupDataMessageCounter();
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
storedResumptionRecords.forEach(
|
|
661
|
-
({
|
|
662
|
-
nodeId,
|
|
663
|
-
sharedSecret,
|
|
664
|
-
resumptionId,
|
|
665
|
-
fabricId,
|
|
666
|
-
fabricIndex,
|
|
667
|
-
peerNodeId,
|
|
668
|
-
sessionParameters,
|
|
669
|
-
caseAuthenticatedTags
|
|
670
|
-
}) => {
|
|
671
|
-
const fabric = this.#maybeFabricForId(fabricId, fabricIndex);
|
|
672
|
-
if (!fabric) {
|
|
673
|
-
this.#logger.warn(
|
|
674
|
-
`Ignoring resumption record for fabric 0x${toHex(fabricId)} and index ${fabricIndex} because we cannot find a matching fabric`
|
|
675
|
-
);
|
|
676
|
-
return;
|
|
677
|
-
}
|
|
726
|
+
await this.#migrateLegacyResumptionRecords();
|
|
727
|
+
const storedResumptionRecords = await this.#resumptionStore.load((address, record) => {
|
|
728
|
+
const { fabricId, fabricIndex, version = 0 } = record;
|
|
729
|
+
if (this.#maybeFabricForId(fabricId, fabricIndex)?.fabricIndex !== address.fabricIndex) {
|
|
678
730
|
this.#logger.info(
|
|
679
|
-
|
|
680
|
-
fabric.addressOf(nodeId).toString(),
|
|
681
|
-
"and peer node",
|
|
682
|
-
fabric.addressOf(peerNodeId).toString(),
|
|
683
|
-
"for fabric id",
|
|
684
|
-
`0x${toHex(fabric.fabricId)}`,
|
|
685
|
-
`(0x${toHex(fabric.rootVendorId)}, "${fabric?.label}")`
|
|
731
|
+
`Deleting resumption record for ${address} because it does not match a fabric (fabric 0x${toHex(fabricId)} with index ${fabricIndex})`
|
|
686
732
|
);
|
|
687
|
-
|
|
688
|
-
sharedSecret,
|
|
689
|
-
resumptionId,
|
|
690
|
-
fabricId,
|
|
691
|
-
fabricIndex: fabric.fabricIndex,
|
|
692
|
-
peerNodeId,
|
|
693
|
-
// Make sure to initialize default values when restoring an older resumption record
|
|
694
|
-
sessionParameters: SessionParameters(sessionParameters),
|
|
695
|
-
caseAuthenticatedTags
|
|
696
|
-
});
|
|
733
|
+
return false;
|
|
697
734
|
}
|
|
698
|
-
|
|
735
|
+
if (!isUsableResumptionRecord(record)) {
|
|
736
|
+
this.#logger.info(
|
|
737
|
+
`Deleting resumption record for ${address} stored with format version ${version}; the peer establishes a new session`
|
|
738
|
+
);
|
|
739
|
+
return false;
|
|
740
|
+
}
|
|
741
|
+
return true;
|
|
742
|
+
});
|
|
743
|
+
for (const [address, { version, sessionParameters, ...stored }] of storedResumptionRecords) {
|
|
744
|
+
this.#logger.debug("Restoring resumption record for", address.toString());
|
|
745
|
+
const record = {
|
|
746
|
+
...stored,
|
|
747
|
+
// Make sure to initialize default values when restoring an older resumption record
|
|
748
|
+
sessionParameters: SessionParameters(sessionParameters)
|
|
749
|
+
};
|
|
750
|
+
this.#rememberResumptionRecord(address, record);
|
|
751
|
+
if (version !== RESUMPTION_RECORD_VERSION) {
|
|
752
|
+
await this.#resumptionStore.set(address, storageRecordOf(record));
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
if (storedResumptionRecords.size) {
|
|
756
|
+
this.#logger.info(`Restored ${storedResumptionRecords.size} resumption records`);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* Move the records of the single legacy array to one key per peer. The array is authoritative when present because
|
|
761
|
+
* only a version without per-peer storage writes it. It is deleted last, so a start interrupted before that moves
|
|
762
|
+
* it again. Records of fabrics that no longer exist are dropped.
|
|
763
|
+
*/
|
|
764
|
+
async #migrateLegacyResumptionRecords() {
|
|
765
|
+
const storage = this.#context.storage;
|
|
766
|
+
if (!await storage.has(LEGACY_RESUMPTION_RECORDS_KEY)) {
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
const legacyRecords = await storage.get(LEGACY_RESUMPTION_RECORDS_KEY, []);
|
|
770
|
+
const records = new Array();
|
|
771
|
+
for (const { nodeId, ...record } of legacyRecords) {
|
|
772
|
+
const fabric = this.#maybeFabricForId(record.fabricId, record.fabricIndex);
|
|
773
|
+
if (fabric === void 0) {
|
|
774
|
+
this.#logger.info(
|
|
775
|
+
`Dropping resumption record for fabric 0x${toHex(record.fabricId)} and index ${record.fabricIndex} because we cannot find a matching fabric`
|
|
776
|
+
);
|
|
777
|
+
continue;
|
|
778
|
+
}
|
|
779
|
+
records.push([fabric.addressOf(nodeId), { ...record, fabricIndex: fabric.fabricIndex }]);
|
|
780
|
+
}
|
|
781
|
+
await this.#resumptionStore.replaceAll(records);
|
|
782
|
+
await storage.delete(LEGACY_RESUMPTION_RECORDS_KEY);
|
|
783
|
+
this.#logger.info(`Moved ${records.length} resumption records to per-peer storage`);
|
|
699
784
|
}
|
|
700
785
|
/**
|
|
701
786
|
* Build the node-global group data message counter. On the first run after upgrading from the legacy per-key
|
|
@@ -728,7 +813,7 @@ class SessionManager {
|
|
|
728
813
|
}
|
|
729
814
|
getActiveSessionInformation() {
|
|
730
815
|
this.#construction.assert();
|
|
731
|
-
return
|
|
816
|
+
return this.#establishedSessions.filter((session) => session.isSecure && !session.isPase).map((session) => {
|
|
732
817
|
const activity = session instanceof SecureSession ? session.wallClockActivity : void 0;
|
|
733
818
|
return {
|
|
734
819
|
name: `${session.via}`,
|
|
@@ -758,8 +843,9 @@ class SessionManager {
|
|
|
758
843
|
await this.#construction;
|
|
759
844
|
}
|
|
760
845
|
await this.closeAllSessions();
|
|
846
|
+
await this.#resumptionStore.clear();
|
|
761
847
|
await this.#context.storage.clearAll();
|
|
762
|
-
this.#
|
|
848
|
+
this.#forgetAllResumptionRecords();
|
|
763
849
|
await this.#groupDataMessageCounter?.close();
|
|
764
850
|
this.#groupDataMessageCounter = await this.#createGroupDataMessageCounter();
|
|
765
851
|
}
|
|
@@ -770,10 +856,10 @@ class SessionManager {
|
|
|
770
856
|
await this.#subscriptionUpdateMutex;
|
|
771
857
|
await this.#sessionEvictionMutex;
|
|
772
858
|
const context = { cause: new ShutdownError("Session closed by node shutdown") };
|
|
773
|
-
const closePromises = this.#
|
|
859
|
+
const closePromises = this.#registeredSessions.map(async (session) => {
|
|
774
860
|
await session.closeSubscriptionsForShutdown();
|
|
775
861
|
await session.initiateForceClose(context);
|
|
776
|
-
this.#
|
|
862
|
+
this.#registeredSessions.delete(session);
|
|
777
863
|
});
|
|
778
864
|
for (const session of this.#unsecuredSessions.values()) {
|
|
779
865
|
closePromises.push(session.initiateForceClose(context));
|
|
@@ -795,6 +881,83 @@ class SessionManager {
|
|
|
795
881
|
this.#nextSessionId = this.#context.fabrics.crypto.randomUint32 % upperBound + 1;
|
|
796
882
|
}
|
|
797
883
|
}
|
|
884
|
+
function supersedes(newer, older) {
|
|
885
|
+
return !newer.isPase && newer.peerIs(older.peerAddress) && hasEqualCats(newer, older);
|
|
886
|
+
}
|
|
887
|
+
function hasEqualCats(session, other) {
|
|
888
|
+
const tags = new Set(session.caseAuthenticatedTags);
|
|
889
|
+
const otherTags = new Set(other.caseAuthenticatedTags);
|
|
890
|
+
return tags.size === otherTags.size && [...otherTags].every((tag) => tags.has(tag));
|
|
891
|
+
}
|
|
892
|
+
class RegisteredSessions extends BasicSet {
|
|
893
|
+
#established;
|
|
894
|
+
#positions = /* @__PURE__ */ new WeakMap();
|
|
895
|
+
#count = 0;
|
|
896
|
+
constructor(established) {
|
|
897
|
+
super();
|
|
898
|
+
this.#established = established;
|
|
899
|
+
}
|
|
900
|
+
add(session) {
|
|
901
|
+
if (this.has(session)) {
|
|
902
|
+
return;
|
|
903
|
+
}
|
|
904
|
+
this.#positions.set(session, this.#count++);
|
|
905
|
+
super.add(session);
|
|
906
|
+
if (session.isEstablishing) {
|
|
907
|
+
session.established.once(() => {
|
|
908
|
+
if (this.has(session)) {
|
|
909
|
+
this.#established.add(session);
|
|
910
|
+
}
|
|
911
|
+
});
|
|
912
|
+
} else {
|
|
913
|
+
this.#established.add(session);
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
get count() {
|
|
917
|
+
return this.#count;
|
|
918
|
+
}
|
|
919
|
+
/** The position of {@link session} in the registration order; kept after it leaves. Undefined if never added. */
|
|
920
|
+
positionOf(session) {
|
|
921
|
+
return this.#positions.get(session);
|
|
922
|
+
}
|
|
923
|
+
isRegisteredBefore(session, position) {
|
|
924
|
+
const own = this.#positions.get(session);
|
|
925
|
+
return own !== void 0 && own < position;
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
function storageRecordOf({
|
|
929
|
+
sharedSecret,
|
|
930
|
+
resumptionId,
|
|
931
|
+
peerNodeId,
|
|
932
|
+
fabricId,
|
|
933
|
+
fabricIndex,
|
|
934
|
+
sessionParameters,
|
|
935
|
+
caseAuthenticatedTags
|
|
936
|
+
}) {
|
|
937
|
+
return {
|
|
938
|
+
version: RESUMPTION_RECORD_VERSION,
|
|
939
|
+
sharedSecret,
|
|
940
|
+
resumptionId,
|
|
941
|
+
fabricId,
|
|
942
|
+
fabricIndex,
|
|
943
|
+
peerNodeId,
|
|
944
|
+
sessionParameters: {
|
|
945
|
+
...sessionParameters,
|
|
946
|
+
supportedTransports: sessionParameters.supportedTransports ? SupportedTransportsSchema.encode(sessionParameters.supportedTransports) : void 0
|
|
947
|
+
},
|
|
948
|
+
caseAuthenticatedTags
|
|
949
|
+
};
|
|
950
|
+
}
|
|
951
|
+
function isUsableResumptionRecord({ version = 0, caseAuthenticatedTags }) {
|
|
952
|
+
switch (version) {
|
|
953
|
+
case 0:
|
|
954
|
+
return !caseAuthenticatedTags?.length;
|
|
955
|
+
case RESUMPTION_RECORD_VERSION:
|
|
956
|
+
return true;
|
|
957
|
+
default:
|
|
958
|
+
return false;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
798
961
|
export {
|
|
799
962
|
SessionEvictedError,
|
|
800
963
|
SessionManager,
|