@matter/protocol 0.18.0 → 0.18.1-alpha.0-20261111-b89790712
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 +19 -20
- 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/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/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 +53 -7
- package/dist/cjs/certificate/DeviceAttestationValidator.d.ts.map +1 -1
- package/dist/cjs/certificate/DeviceAttestationValidator.js +114 -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/index.d.ts +1 -0
- package/dist/cjs/certificate/index.d.ts.map +1 -1
- package/dist/cjs/certificate/index.js +1 -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/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/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/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.map +1 -1
- package/dist/cjs/peer/ControllerCommissioner.js +48 -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 +109 -32
- package/dist/cjs/peer/ControllerCommissioningFlow.js.map +1 -1
- 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 +1 -0
- package/dist/cjs/peer/index.d.ts.map +1 -1
- package/dist/cjs/peer/index.js +1 -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 +16 -6
- 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 +19 -20
- 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/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/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 +53 -7
- package/dist/esm/certificate/DeviceAttestationValidator.d.ts.map +1 -1
- package/dist/esm/certificate/DeviceAttestationValidator.js +115 -43
- 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/index.d.ts +1 -0
- package/dist/esm/certificate/index.d.ts.map +1 -1
- package/dist/esm/certificate/index.js +1 -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/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/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/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.map +1 -1
- package/dist/esm/peer/ControllerCommissioner.js +48 -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 +109 -32
- package/dist/esm/peer/ControllerCommissioningFlow.js.map +1 -1
- 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 +1 -0
- package/dist/esm/peer/index.d.ts.map +1 -1
- package/dist/esm/peer/index.js +1 -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 +16 -6
- 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 +19 -21
- package/src/action/client/ClientRequest.ts +15 -0
- package/src/action/client/InputChunk.ts +57 -2
- 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/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 +202 -54
- package/src/certificate/DeviceCertification.ts +6 -2
- package/src/certificate/index.ts +1 -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/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/mdns/InterfaceResponder.ts +1031 -0
- package/src/mdns/MdnsServer.ts +400 -360
- package/src/peer/CommissioningConnection.ts +5 -1
- package/src/peer/ControllerCommissioner.ts +57 -19
- package/src/peer/ControllerCommissioningFlow.ts +132 -56
- 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 +1 -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 +22 -6
- 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
|
@@ -9,15 +9,15 @@ import { SupportedTransportsSchema } from "#common/SupportedTransportsBitmap.js"
|
|
|
9
9
|
import { FabricManager } from "#fabric/FabricManager.js";
|
|
10
10
|
import type { Subscription } from "#interaction/Subscription.js";
|
|
11
11
|
import { PeerAddress, PeerAddressMap } from "#peer/PeerAddress.js";
|
|
12
|
+
import { PeerAddressStore } from "#peer/PeerAddressStore.js";
|
|
12
13
|
import { PeerShutdownError } from "#peer/PeerCommunicationError.js";
|
|
13
14
|
import { PeerLossContext } from "#peer/PeerLossContext.js";
|
|
14
15
|
import { SessionClosedError } from "#protocol/errors.js";
|
|
15
|
-
import { GroupSession, GroupSessionDecodeError
|
|
16
|
+
import { GroupMessageRejection, GroupSession, GroupSessionDecodeError } from "#session/GroupSession.js";
|
|
16
17
|
import {
|
|
17
18
|
Diagnostic,
|
|
18
19
|
BasicSet,
|
|
19
20
|
Bytes,
|
|
20
|
-
causedBy,
|
|
21
21
|
Channel,
|
|
22
22
|
ClosedError,
|
|
23
23
|
Construction,
|
|
@@ -25,6 +25,8 @@ import {
|
|
|
25
25
|
Duration,
|
|
26
26
|
Environment,
|
|
27
27
|
Environmental,
|
|
28
|
+
hex,
|
|
29
|
+
ImmutableSet,
|
|
28
30
|
ImplementationError,
|
|
29
31
|
InternalError,
|
|
30
32
|
Lifecycle,
|
|
@@ -34,10 +36,10 @@ import {
|
|
|
34
36
|
Millis,
|
|
35
37
|
Mutex,
|
|
36
38
|
Observable,
|
|
39
|
+
ObservableSet,
|
|
37
40
|
ObserverGroup,
|
|
38
41
|
StorageContext,
|
|
39
42
|
StorageManager,
|
|
40
|
-
Time,
|
|
41
43
|
Timestamp,
|
|
42
44
|
toHex,
|
|
43
45
|
Transport,
|
|
@@ -49,7 +51,7 @@ import type { ExposedFabricInformation, Fabric } from "../fabric/Fabric.js";
|
|
|
49
51
|
import { MessageCounter, PersistedMessageCounter } from "../protocol/MessageCounter.js";
|
|
50
52
|
import { NodeSession } from "./NodeSession.js";
|
|
51
53
|
import { SecureSession } from "./SecureSession.js";
|
|
52
|
-
import
|
|
54
|
+
import { Session } from "./Session.js";
|
|
53
55
|
import { SessionIntervals } from "./SessionIntervals.js";
|
|
54
56
|
import { SessionParameters } from "./SessionParameters.js";
|
|
55
57
|
import { UnsecuredSession } from "./UnsecuredSession.js";
|
|
@@ -96,7 +98,8 @@ export interface ResumptionRecord extends Omit<InternalResumptionRecord, "fabric
|
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
type ResumptionStorageRecord = {
|
|
99
|
-
|
|
101
|
+
/** Format version, see {@link RESUMPTION_RECORD_VERSION}. Records written before versioning have none. */
|
|
102
|
+
version?: number;
|
|
100
103
|
sharedSecret: Bytes;
|
|
101
104
|
resumptionId: Bytes;
|
|
102
105
|
fabricId: FabricId;
|
|
@@ -116,6 +119,15 @@ type ResumptionStorageRecord = {
|
|
|
116
119
|
caseAuthenticatedTags?: readonly CaseAuthenticatedTag[];
|
|
117
120
|
};
|
|
118
121
|
|
|
122
|
+
/**
|
|
123
|
+
* Records as stored in one array under {@link LEGACY_RESUMPTION_RECORDS_KEY}; `nodeId` always equals `peerNodeId`.
|
|
124
|
+
* Records written before 0.15.5 have no `fabricIndex`.
|
|
125
|
+
*/
|
|
126
|
+
type LegacyResumptionStorageRecord = Omit<ResumptionStorageRecord, "fabricIndex"> & {
|
|
127
|
+
nodeId: NodeId;
|
|
128
|
+
fabricIndex?: FabricIndex;
|
|
129
|
+
};
|
|
130
|
+
|
|
119
131
|
export interface ActiveSessionInformation {
|
|
120
132
|
name: string;
|
|
121
133
|
nodeId: NodeId;
|
|
@@ -128,24 +140,18 @@ export interface ActiveSessionInformation {
|
|
|
128
140
|
numberOfActiveSubscriptions: number;
|
|
129
141
|
}
|
|
130
142
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
*/
|
|
135
|
-
export interface GroupMessageEventInfo {
|
|
136
|
-
result: Groupcast.GroupcastTestResult;
|
|
137
|
-
fabric?: Fabric;
|
|
138
|
-
|
|
139
|
-
/** Authenticated group id. Only set when the message decoded successfully for a known fabric. */
|
|
140
|
-
groupId?: GroupId;
|
|
143
|
+
interface GroupMessageEventBase {
|
|
144
|
+
sourceIp?: string;
|
|
145
|
+
}
|
|
141
146
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
*/
|
|
146
|
-
headerGroupId?: GroupId;
|
|
147
|
+
/** A received group message that a key of {@link fabric} authenticated. */
|
|
148
|
+
export interface GroupMessageAuthenticatedInfo extends GroupMessageEventBase {
|
|
149
|
+
kind: "authenticated";
|
|
147
150
|
|
|
148
|
-
|
|
151
|
+
/** FailedAuth here means GroupKeyMap or the key set changed between decode and dispatch. */
|
|
152
|
+
result: Groupcast.GroupcastTestResult;
|
|
153
|
+
fabric: Fabric;
|
|
154
|
+
groupId?: GroupId;
|
|
149
155
|
endpointId?: EndpointNumber;
|
|
150
156
|
clusterId?: ClusterId;
|
|
151
157
|
elementId?: number;
|
|
@@ -154,6 +160,17 @@ export interface GroupMessageEventInfo {
|
|
|
154
160
|
accessAllowed?: boolean;
|
|
155
161
|
}
|
|
156
162
|
|
|
163
|
+
/** A received group message for which no candidate key passed, see {@link GroupMessageRejection}. */
|
|
164
|
+
export interface GroupMessageUnauthenticatedInfo extends GroupMessageEventBase, GroupMessageRejection {
|
|
165
|
+
kind: "unauthenticated";
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Metadata about a received group message, emitted via {@link SessionManager.onGroupMessage} for Groupcast testing.
|
|
170
|
+
* An unauthenticated message names no fabric to report on; {@link GroupMessageRejection.resultFor} gives its result.
|
|
171
|
+
*/
|
|
172
|
+
export type GroupMessageEventInfo = GroupMessageAuthenticatedInfo | GroupMessageUnauthenticatedInfo;
|
|
173
|
+
|
|
157
174
|
/**
|
|
158
175
|
* Interfaces {@link SessionManager} with other components.
|
|
159
176
|
*/
|
|
@@ -188,6 +205,24 @@ const ID_SPACE_UPPER_BOUND = 0xffff;
|
|
|
188
205
|
*/
|
|
189
206
|
const MAX_SESSIONS_PER_PEER = 5;
|
|
190
207
|
|
|
208
|
+
/** Sub-context of the session storage context that holds one resumption record per peer. */
|
|
209
|
+
const RESUMPTION_RECORDS_CONTEXT = "resumption";
|
|
210
|
+
|
|
211
|
+
/** Key of the single array that held all resumption records before they were stored per peer. */
|
|
212
|
+
const LEGACY_RESUMPTION_RECORDS_KEY = "resumptionRecords";
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Format version of stored resumption records. {@link isUsableResumptionRecord} decides on load which stored versions
|
|
216
|
+
* this version uses:
|
|
217
|
+
*
|
|
218
|
+
* | Stored version | On load |
|
|
219
|
+
* | -------------- | ---------------------------------------------------------------- |
|
|
220
|
+
* | none (0) | with CATs: deleted; without CATs: used, stored with this version |
|
|
221
|
+
* | current | used |
|
|
222
|
+
* | any other | deleted |
|
|
223
|
+
*/
|
|
224
|
+
const RESUMPTION_RECORD_VERSION = 1;
|
|
225
|
+
|
|
191
226
|
/** Storage key for the node-global Group Encrypted Data Message Counter in the session storage context. */
|
|
192
227
|
const GROUP_DATA_COUNTER_KEY = "groupDataCounter";
|
|
193
228
|
|
|
@@ -221,10 +256,13 @@ export class SessionManager {
|
|
|
221
256
|
readonly #logger: Logger;
|
|
222
257
|
readonly #context: SessionManagerContext;
|
|
223
258
|
readonly #unsecuredSessions = new Map<NodeId, UnsecuredSession>();
|
|
224
|
-
readonly #
|
|
259
|
+
readonly #establishedSessions = new BasicSet<NodeSession>();
|
|
260
|
+
readonly #registeredSessions = new RegisteredSessions(this.#establishedSessions);
|
|
225
261
|
readonly #groupSessions = new Map<NodeId, BasicSet<GroupSession>>();
|
|
226
262
|
#nextSessionId: number;
|
|
227
|
-
#resumptionRecords = new PeerAddressMap<InternalResumptionRecord>();
|
|
263
|
+
readonly #resumptionRecords = new PeerAddressMap<InternalResumptionRecord>();
|
|
264
|
+
readonly #resumptionRecordsById = new Map<string, InternalResumptionRecord>();
|
|
265
|
+
readonly #resumptionStore: PeerAddressStore<ResumptionStorageRecord>;
|
|
228
266
|
readonly #globalUnencryptedMessageCounter;
|
|
229
267
|
#groupDataMessageCounter!: PersistedMessageCounter;
|
|
230
268
|
#sessionParameters: SessionParameters;
|
|
@@ -253,6 +291,7 @@ export class SessionManager {
|
|
|
253
291
|
constructor(context: SessionManagerContext) {
|
|
254
292
|
this.#context = context;
|
|
255
293
|
this.#logger = Logger.get("SessionManager", context.origin);
|
|
294
|
+
this.#resumptionStore = new PeerAddressStore(context.storage.createContext(RESUMPTION_RECORDS_CONTEXT));
|
|
256
295
|
const {
|
|
257
296
|
fabrics: { crypto },
|
|
258
297
|
} = context;
|
|
@@ -272,16 +311,8 @@ export class SessionManager {
|
|
|
272
311
|
await this.deleteResumptionRecordsForFabric(fabric);
|
|
273
312
|
});
|
|
274
313
|
|
|
275
|
-
this.#sessions.added.on(session => {
|
|
276
|
-
// We are the responder, so nothing else reclaims these: an initiator's sessions are swept by the peer
|
|
277
|
-
// loss its own traffic reports
|
|
278
|
-
if (!session.isInitiator) {
|
|
279
|
-
this.#sessionEvictionMutex.run(() => this.#evictExcessSessionsFor(session));
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
|
|
283
314
|
// Add subscription monitors to new node sessions
|
|
284
|
-
this.#
|
|
315
|
+
this.#registeredSessions.added.on(session => {
|
|
285
316
|
const subscriptionsChanged = (subscription: Subscription) => {
|
|
286
317
|
if (session.isClosing) {
|
|
287
318
|
return;
|
|
@@ -299,6 +330,11 @@ export class SessionManager {
|
|
|
299
330
|
});
|
|
300
331
|
});
|
|
301
332
|
|
|
333
|
+
this.#registeredSessions.deleted.on(session => {
|
|
334
|
+
this.#establishedSessions.delete(session);
|
|
335
|
+
});
|
|
336
|
+
this.#establishedSessions.added.on(session => this.#sessionEstablished(session));
|
|
337
|
+
|
|
302
338
|
this.#construction = Construction(this, () => this.#initialize());
|
|
303
339
|
}
|
|
304
340
|
|
|
@@ -334,10 +370,57 @@ export class SessionManager {
|
|
|
334
370
|
}
|
|
335
371
|
|
|
336
372
|
/**
|
|
337
|
-
*
|
|
373
|
+
* The established secure sessions. A session joins once its handshake completed, so {@link ObservableSet.added}
|
|
374
|
+
* emits on establishment, and a session whose handshake fails never appears. It leaves when it closes.
|
|
375
|
+
*
|
|
376
|
+
* Read this set to find a session to use, or to list or observe the sessions with peers.
|
|
377
|
+
*
|
|
378
|
+
* Read {@link registeredSessions} instead for subscriptions and reports, and for session teardown and message
|
|
379
|
+
* routing. A peer may send a Subscribe on a session we respond to before that session is established, so the
|
|
380
|
+
* subscriptions of a peer may live on a session that is not in this set. The CHIP SDK drops such messages; we
|
|
381
|
+
* serve them, see {@link NodeSession.isEstablishing}.
|
|
338
382
|
*/
|
|
339
|
-
get sessions() {
|
|
340
|
-
return this.#
|
|
383
|
+
get sessions(): ImmutableSet<NodeSession> & ObservableSet<NodeSession> {
|
|
384
|
+
return this.#establishedSessions;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Every secure session that receives messages, including those whose handshake still runs (see
|
|
389
|
+
* {@link NodeSession.isEstablishing}). A session joins on creation, unless it is created with
|
|
390
|
+
* `delayManagerRegistration`, and leaves when it closes.
|
|
391
|
+
*
|
|
392
|
+
* Read this set for message routing, session ID allocation, session teardown, peer loss, and for the subscriptions
|
|
393
|
+
* and reports of a peer. Code that looks for a session to use reads {@link sessions}.
|
|
394
|
+
*
|
|
395
|
+
* {@link sessions} emits {@link ObservableSet.added} for a session only after every observer of `added` here ran,
|
|
396
|
+
* so components that wire up a session here, such as the ExchangeManager, are ready before users of the
|
|
397
|
+
* established session see it.
|
|
398
|
+
*/
|
|
399
|
+
get registeredSessions(): BasicSet<NodeSession> {
|
|
400
|
+
return this.#registeredSessions;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* The number of registrations in {@link registeredSessions} so far. A session registered from now on gets this
|
|
405
|
+
* value or a higher one as its registration position, so the value marks "sessions registered after this point"
|
|
406
|
+
* for {@link PeerLossContext.registeredBefore}.
|
|
407
|
+
*/
|
|
408
|
+
get registrationCount() {
|
|
409
|
+
return this.#registeredSessions.count;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* The open sessions with the peer of {@link session} that registered at or after it. {@link handlePeerShutdown}
|
|
414
|
+
* keeps these sessions when it receives {@link session}. For a session that never registered, the result is empty.
|
|
415
|
+
*/
|
|
416
|
+
sessionsRegisteredSince(session: NodeSession) {
|
|
417
|
+
const position = this.#registeredSessions.positionOf(session);
|
|
418
|
+
if (position === undefined) {
|
|
419
|
+
return [];
|
|
420
|
+
}
|
|
421
|
+
return this.sessionsFor(session.peerAddress).filter(
|
|
422
|
+
other => !this.#registeredSessions.isRegisteredBefore(other, position),
|
|
423
|
+
);
|
|
341
424
|
}
|
|
342
425
|
|
|
343
426
|
/**
|
|
@@ -400,7 +483,10 @@ export class SessionManager {
|
|
|
400
483
|
}
|
|
401
484
|
|
|
402
485
|
/**
|
|
403
|
-
* Emits for
|
|
486
|
+
* Emits for a received group message whose keys are tried: when no candidate key passes, when the message is a
|
|
487
|
+
* replay, and when the Interaction Model processes a group invoke request. A datagram the codec refuses and a
|
|
488
|
+
* message with the R or A flag emit nothing. Any other message, such as a group write or a message for an
|
|
489
|
+
* unsupported protocol, emits only MessageReplay for a replayed copy. Observers remain inactive until at least one
|
|
404
490
|
* listener attaches, so fabrics not under test incur no emission overhead.
|
|
405
491
|
*/
|
|
406
492
|
get onGroupMessage() {
|
|
@@ -483,9 +569,9 @@ export class SessionManager {
|
|
|
483
569
|
async deleteResumptionRecord(address: PeerAddress) {
|
|
484
570
|
await this.#construction;
|
|
485
571
|
|
|
486
|
-
const result = this.#
|
|
572
|
+
const result = this.#forgetResumptionRecord(address);
|
|
487
573
|
if (result) {
|
|
488
|
-
await this.#
|
|
574
|
+
await this.#resumptionStore.delete(address);
|
|
489
575
|
}
|
|
490
576
|
return result;
|
|
491
577
|
}
|
|
@@ -498,24 +584,22 @@ export class SessionManager {
|
|
|
498
584
|
await this.#construction;
|
|
499
585
|
|
|
500
586
|
let deletedCount = 0;
|
|
501
|
-
for (const address of this.#resumptionRecords.keys()) {
|
|
502
|
-
if (address.fabricIndex === fabric.fabricIndex) {
|
|
503
|
-
|
|
504
|
-
deletedCount++;
|
|
505
|
-
}
|
|
587
|
+
for (const address of [...this.#resumptionRecords.keys()]) {
|
|
588
|
+
if (address.fabricIndex === fabric.fabricIndex && this.#forgetResumptionRecord(address)) {
|
|
589
|
+
deletedCount++;
|
|
506
590
|
}
|
|
507
591
|
}
|
|
508
592
|
|
|
509
593
|
if (deletedCount > 0) {
|
|
510
|
-
await this.#
|
|
594
|
+
await this.#resumptionStore.deleteFabric(fabric.fabricIndex);
|
|
511
595
|
}
|
|
512
596
|
return deletedCount > 0;
|
|
513
597
|
}
|
|
514
598
|
|
|
515
|
-
/** The session with the least recent traffic among
|
|
516
|
-
#leastRecentlyUsedSession(filter: (session: NodeSession) => boolean) {
|
|
599
|
+
/** The session with the least recent traffic among {@link sessions} that {@link filter} accepts, if any. */
|
|
600
|
+
#leastRecentlyUsedSession(sessions: Iterable<NodeSession>, filter: (session: NodeSession) => boolean) {
|
|
517
601
|
let oldest: NodeSession | undefined;
|
|
518
|
-
for (const session of
|
|
602
|
+
for (const session of sessions) {
|
|
519
603
|
if (filter(session) && (oldest === undefined || session.timestamp < oldest.timestamp)) {
|
|
520
604
|
oldest = session;
|
|
521
605
|
}
|
|
@@ -526,7 +610,7 @@ export class SessionManager {
|
|
|
526
610
|
findOldestInactiveSession() {
|
|
527
611
|
this.#construction.assert();
|
|
528
612
|
|
|
529
|
-
const oldest = this.#leastRecentlyUsedSession(() => true);
|
|
613
|
+
const oldest = this.#leastRecentlyUsedSession(this.#registeredSessions, () => true);
|
|
530
614
|
if (oldest === undefined) {
|
|
531
615
|
throw new MatterFlowError("No session found to close and all session ids are taken.");
|
|
532
616
|
}
|
|
@@ -570,21 +654,20 @@ export class SessionManager {
|
|
|
570
654
|
getSession(sessionId: number) {
|
|
571
655
|
this.#construction.assert();
|
|
572
656
|
|
|
573
|
-
return this.#
|
|
657
|
+
return this.#registeredSessions.get("id", sessionId);
|
|
574
658
|
}
|
|
575
659
|
|
|
576
660
|
getPaseSession() {
|
|
577
661
|
this.#construction.assert();
|
|
578
662
|
|
|
579
|
-
return
|
|
663
|
+
return this.#establishedSessions.find(session => session.isPase && !session.isClosing);
|
|
580
664
|
}
|
|
581
665
|
|
|
582
666
|
forFabric(fabric: Fabric) {
|
|
583
667
|
this.#construction.assert();
|
|
584
668
|
|
|
585
|
-
return
|
|
586
|
-
session =>
|
|
587
|
-
NodeSession.is(session) && session.isSecure && session.fabric?.fabricIndex === fabric.fabricIndex,
|
|
669
|
+
return this.#establishedSessions.filter(
|
|
670
|
+
session => session.isSecure && session.fabric?.fabricIndex === fabric.fabricIndex,
|
|
588
671
|
);
|
|
589
672
|
}
|
|
590
673
|
|
|
@@ -603,7 +686,7 @@ export class SessionManager {
|
|
|
603
686
|
// Prefer the most recently active session (i.e. the one we last heard from the peer on). Older ones may not
|
|
604
687
|
// work with broken peers (e.g. CHIP test harness).
|
|
605
688
|
let found: NodeSession | undefined;
|
|
606
|
-
for (const session of this.#
|
|
689
|
+
for (const session of this.#establishedSessions) {
|
|
607
690
|
if (!session.peerIs(address) || session.isClosing || session.isPeerLost) {
|
|
608
691
|
continue;
|
|
609
692
|
}
|
|
@@ -618,11 +701,11 @@ export class SessionManager {
|
|
|
618
701
|
|
|
619
702
|
sessionsFor(address: PeerAddress) {
|
|
620
703
|
address = PeerAddress(address);
|
|
621
|
-
return this.#
|
|
704
|
+
return this.#registeredSessions.filter(session => session.peerAddress === address && !session.isClosing);
|
|
622
705
|
}
|
|
623
706
|
|
|
624
707
|
sessionsForFabricIndex(fabricIndex: FabricIndex) {
|
|
625
|
-
return this.#
|
|
708
|
+
return this.#registeredSessions.filter(session => session.fabric?.fabricIndex === fabricIndex);
|
|
626
709
|
}
|
|
627
710
|
|
|
628
711
|
/**
|
|
@@ -630,23 +713,59 @@ export class SessionManager {
|
|
|
630
713
|
* sessions close. Our own subscriptions to the peer belong to the peer, not to a session, so a peer that persists
|
|
631
714
|
* subscriptions can refresh them after its restart.
|
|
632
715
|
*
|
|
633
|
-
*
|
|
634
|
-
*
|
|
716
|
+
* Sessions that register while the shutdown runs are kept.
|
|
717
|
+
*
|
|
718
|
+
* @param keep this session and the sessions registered after it are kept. Without it, or for a session that never
|
|
719
|
+
* registered, every session registered now is removed. A {@link Timestamp} is deprecated: then only the sessions
|
|
720
|
+
* created before that instant are removed, and a session created in the same instant counts as newer.
|
|
635
721
|
*/
|
|
636
|
-
handlePeerShutdown(address: PeerAddress,
|
|
637
|
-
|
|
722
|
+
handlePeerShutdown(address: PeerAddress, keep?: NodeSession | Timestamp) {
|
|
723
|
+
const context = {
|
|
638
724
|
address,
|
|
639
725
|
cause: new PeerShutdownError(),
|
|
640
|
-
asOf: asOf ?? Time.nowUs,
|
|
641
726
|
keepSubscriptions: true,
|
|
642
|
-
|
|
727
|
+
registeredBefore: this.registrationCount,
|
|
728
|
+
};
|
|
729
|
+
if (typeof keep === "number") {
|
|
730
|
+
return this.#handlePeerLoss({ ...context, asOf: keep });
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
const keepPosition = keep === undefined ? undefined : this.#registeredSessions.positionOf(keep);
|
|
734
|
+
return this.#handlePeerLoss({ ...context, registeredBefore: keepPosition ?? context.registeredBefore });
|
|
643
735
|
}
|
|
644
736
|
|
|
645
737
|
/**
|
|
646
|
-
* Removes all Peer sessions and closes subscriptions.
|
|
738
|
+
* Removes all Peer sessions and closes subscriptions. Only the sessions registered before
|
|
739
|
+
* {@link PeerLossContext.registeredBefore} are affected; by default every session registered now. A given
|
|
740
|
+
* {@link PeerLossContext.asOf} applies in addition.
|
|
647
741
|
*/
|
|
648
742
|
async handlePeerLoss(address: PeerAddress, context: PeerLossContext) {
|
|
649
|
-
return await this.#handlePeerLoss({
|
|
743
|
+
return await this.#handlePeerLoss({
|
|
744
|
+
...context,
|
|
745
|
+
address,
|
|
746
|
+
registeredBefore: context.registeredBefore ?? this.registrationCount,
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* Supersede the older sessions {@link newer} replaces, then evict excess sessions of the peer. Supersession comes
|
|
752
|
+
* first and is synchronous, so the subscriptions have left a session before eviction can close it.
|
|
753
|
+
*
|
|
754
|
+
* An older session that is still establishing is not superseded. Subscriptions exist on such a session only if a
|
|
755
|
+
* Subscribe arrived before its handshake finished. If that handshake fails, the subscriptions close with it.
|
|
756
|
+
*/
|
|
757
|
+
#sessionEstablished(newer: NodeSession) {
|
|
758
|
+
for (const older of this.#establishedSessions) {
|
|
759
|
+
if (older !== newer && !older.isClosing && supersedes(newer, older)) {
|
|
760
|
+
older.superseded.emit(newer);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
// We are the responder, so nothing else reclaims these: an initiator's sessions are swept by the peer loss its
|
|
765
|
+
// own traffic reports
|
|
766
|
+
if (!newer.isInitiator) {
|
|
767
|
+
this.#sessionEvictionMutex.run(() => this.#evictExcessSessionsFor(newer));
|
|
768
|
+
}
|
|
650
769
|
}
|
|
651
770
|
|
|
652
771
|
/**
|
|
@@ -654,7 +773,8 @@ export class SessionManager {
|
|
|
654
773
|
*
|
|
655
774
|
* Only sessions the peer established are eligible: ones we initiated are ours to manage, and the peer loss our
|
|
656
775
|
* own traffic reports already sweeps them. {@link added} is excluded so a burst of new sessions cannot evict the
|
|
657
|
-
* one that prompted the check.
|
|
776
|
+
* one that prompted the check. Only established sessions count and are evicted; an establishing session becomes
|
|
777
|
+
* established or closes within its handshake.
|
|
658
778
|
*/
|
|
659
779
|
async #evictExcessSessionsFor(added: NodeSession) {
|
|
660
780
|
if (added.isPase || added.isClosing) {
|
|
@@ -667,10 +787,13 @@ export class SessionManager {
|
|
|
667
787
|
|
|
668
788
|
// A session already closing still occupies a slot until it completes, so it counts here but is not evicted
|
|
669
789
|
// again -- otherwise one that parks in deferredClose drops out of the count and the cap stops capping
|
|
670
|
-
let excess = this.#
|
|
790
|
+
let excess = this.#establishedSessions.filter(claimsSlot).length + 1 - MAX_SESSIONS_PER_PEER;
|
|
671
791
|
|
|
672
792
|
while (excess-- > 0) {
|
|
673
|
-
const session = this.#leastRecentlyUsedSession(
|
|
793
|
+
const session = this.#leastRecentlyUsedSession(
|
|
794
|
+
this.#establishedSessions,
|
|
795
|
+
s => claimsSlot(s) && !s.isClosing,
|
|
796
|
+
);
|
|
674
797
|
if (session === undefined) {
|
|
675
798
|
return;
|
|
676
799
|
}
|
|
@@ -693,12 +816,19 @@ export class SessionManager {
|
|
|
693
816
|
) {
|
|
694
817
|
await this.#construction;
|
|
695
818
|
|
|
696
|
-
const { address, asOf } = context;
|
|
697
|
-
for (const session of this.#
|
|
819
|
+
const { address, asOf, registeredBefore } = context;
|
|
820
|
+
for (const session of this.#registeredSessions) {
|
|
698
821
|
if (!session.peerIs(address)) {
|
|
699
822
|
continue;
|
|
700
823
|
}
|
|
701
824
|
|
|
825
|
+
if (
|
|
826
|
+
registeredBefore !== undefined &&
|
|
827
|
+
!this.#registeredSessions.isRegisteredBefore(session, registeredBefore)
|
|
828
|
+
) {
|
|
829
|
+
continue;
|
|
830
|
+
}
|
|
831
|
+
|
|
702
832
|
if (asOf !== undefined && session.createdAt >= asOf) {
|
|
703
833
|
continue;
|
|
704
834
|
}
|
|
@@ -756,9 +886,11 @@ export class SessionManager {
|
|
|
756
886
|
}
|
|
757
887
|
|
|
758
888
|
/**
|
|
759
|
-
* Obtain a Group session for an incoming packet.
|
|
889
|
+
* Obtain a Group session for an incoming packet, with the decoded message and the facts decode established.
|
|
760
890
|
*
|
|
761
|
-
* The session ID is determined by decrypting the packet with possible keys.
|
|
891
|
+
* The session ID is determined by decrypting the packet with possible keys. Returns `undefined` when no candidate
|
|
892
|
+
* key passes; the message is then reported via {@link onGroupMessage} and must be dropped. Also returns
|
|
893
|
+
* `undefined`, without a report, for a group data message with the R or A flag.
|
|
762
894
|
*
|
|
763
895
|
* Note that the resulting session is non-operational in the sense that attempting outbound communication will
|
|
764
896
|
* result in an error.
|
|
@@ -767,43 +899,30 @@ export class SessionManager {
|
|
|
767
899
|
this.#construction.assert();
|
|
768
900
|
let decoded;
|
|
769
901
|
try {
|
|
770
|
-
decoded = GroupSession.
|
|
902
|
+
decoded = GroupSession.decodeWithCandidateKeys(this.#context.fabrics, packet, aad);
|
|
771
903
|
} catch (error) {
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
const noKey = error instanceof GroupSessionNoKeyError ? error : undefined;
|
|
782
|
-
this.#onGroupMessage.emit({
|
|
783
|
-
result: Groupcast.GroupcastTestResult.NoAvailableKey,
|
|
784
|
-
fabric: noKey?.fabric,
|
|
785
|
-
headerGroupId: headerGroupId ?? noKey?.groupId,
|
|
786
|
-
sourceIp,
|
|
787
|
-
});
|
|
788
|
-
} else if (causedBy(error, GroupSessionDecodeError)) {
|
|
789
|
-
this.#onGroupMessage.emit({
|
|
790
|
-
result: Groupcast.GroupcastTestResult.FailedAuth,
|
|
791
|
-
headerGroupId,
|
|
792
|
-
sourceIp,
|
|
793
|
-
});
|
|
794
|
-
}
|
|
795
|
-
throw error;
|
|
904
|
+
GroupSessionDecodeError.accept(error);
|
|
905
|
+
const { candidateFabrics, group } = error;
|
|
906
|
+
this.#logger.debug(
|
|
907
|
+
`Dropping group message for session ${Session.idStrOf(packet)} from ${sourceIp ?? "unknown address"}:`,
|
|
908
|
+
error.message,
|
|
909
|
+
Diagnostic.dict({ candidateFabrics: candidateFabrics.size }),
|
|
910
|
+
);
|
|
911
|
+
this.#onGroupMessage.emit({ kind: "unauthenticated", candidateFabrics, group, sourceIp });
|
|
912
|
+
return undefined;
|
|
796
913
|
}
|
|
797
914
|
|
|
798
|
-
const { message, key, privacyKey, sessionId, sourceNodeId, keySetId, fabric } = decoded;
|
|
915
|
+
const { message, key, privacyKey, sessionId, sourceNodeId, groupId, keySetId, fabric } = decoded;
|
|
799
916
|
|
|
800
|
-
//
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
917
|
+
// Spec 4.12.5.2 step 1: drop a group data message with the R or A flag; the codec refuses control messages.
|
|
918
|
+
// As CHIP does for the R flag, this runs before counter processing, though spec 4.7.2 orders the counter first
|
|
919
|
+
const { requiresAck, ackedMessageId } = message.payloadHeader;
|
|
920
|
+
if (requiresAck || ackedMessageId !== undefined) {
|
|
921
|
+
this.#logger.debug(
|
|
922
|
+
`Dropping group message ${hex.fixed(message.packetHeader.messageId, 8)} for session ${Session.idStrOf(packet)} with the ${requiresAck ? "R" : "A"} flag`,
|
|
923
|
+
);
|
|
924
|
+
return undefined;
|
|
804
925
|
}
|
|
805
|
-
const groupId = GroupId(rawGroupId);
|
|
806
|
-
GroupId.assertGroupId(groupId);
|
|
807
926
|
|
|
808
927
|
let session = this.#groupSessions.get(sourceNodeId)?.find(s => s.matches(fabric.fabricIndex, sessionId, key));
|
|
809
928
|
if (session === undefined) {
|
|
@@ -820,11 +939,11 @@ export class SessionManager {
|
|
|
820
939
|
});
|
|
821
940
|
}
|
|
822
941
|
|
|
823
|
-
return { session, message, key };
|
|
942
|
+
return { session, message, key, sourceNodeId, groupId };
|
|
824
943
|
}
|
|
825
944
|
|
|
826
|
-
/** Report
|
|
827
|
-
emitGroupMessage(info:
|
|
945
|
+
/** Report an authenticated group message (used by ExchangeManager for replay and InteractionServer for dispatch). */
|
|
946
|
+
emitGroupMessage(info: GroupMessageAuthenticatedInfo) {
|
|
828
947
|
this.#onGroupMessage.emit(info);
|
|
829
948
|
}
|
|
830
949
|
|
|
@@ -852,9 +971,7 @@ export class SessionManager {
|
|
|
852
971
|
|
|
853
972
|
findResumptionRecordById(resumptionId: Bytes) {
|
|
854
973
|
this.#construction.assert();
|
|
855
|
-
const record =
|
|
856
|
-
Bytes.areEqual(record.resumptionId, resumptionId),
|
|
857
|
-
);
|
|
974
|
+
const record = this.#resumptionRecordsById.get(Bytes.toHex(resumptionId));
|
|
858
975
|
if (record !== undefined) {
|
|
859
976
|
return this.#asExposedResumptionRecord(record);
|
|
860
977
|
}
|
|
@@ -877,43 +994,30 @@ export class SessionManager {
|
|
|
877
994
|
fabricId: fabric.fabricId,
|
|
878
995
|
fabricIndex: fabric.fabricIndex,
|
|
879
996
|
};
|
|
880
|
-
|
|
881
|
-
|
|
997
|
+
const address = fabric.addressOf(resumptionRecord.peerNodeId);
|
|
998
|
+
this.#rememberResumptionRecord(address, record);
|
|
999
|
+
await this.#resumptionStore.set(address, storageRecordOf(record));
|
|
882
1000
|
}
|
|
883
1001
|
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
resumptionId,
|
|
904
|
-
fabricId,
|
|
905
|
-
fabricIndex,
|
|
906
|
-
peerNodeId,
|
|
907
|
-
sessionParameters: {
|
|
908
|
-
...sessionParameters,
|
|
909
|
-
supportedTransports: sessionParameters.supportedTransports
|
|
910
|
-
? SupportedTransportsSchema.encode(sessionParameters.supportedTransports)
|
|
911
|
-
: undefined,
|
|
912
|
-
},
|
|
913
|
-
caseAuthenticatedTags,
|
|
914
|
-
}),
|
|
915
|
-
),
|
|
916
|
-
);
|
|
1002
|
+
#rememberResumptionRecord(address: PeerAddress, record: InternalResumptionRecord) {
|
|
1003
|
+
this.#forgetResumptionRecord(address);
|
|
1004
|
+
this.#resumptionRecords.set(address, record);
|
|
1005
|
+
this.#resumptionRecordsById.set(Bytes.toHex(record.resumptionId), record);
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
#forgetAllResumptionRecords() {
|
|
1009
|
+
this.#resumptionRecords.clear();
|
|
1010
|
+
this.#resumptionRecordsById.clear();
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
#forgetResumptionRecord(address: PeerAddress) {
|
|
1014
|
+
const record = this.#resumptionRecords.get(address);
|
|
1015
|
+
if (record === undefined) {
|
|
1016
|
+
return false;
|
|
1017
|
+
}
|
|
1018
|
+
this.#resumptionRecords.delete(address);
|
|
1019
|
+
this.#resumptionRecordsById.delete(Bytes.toHex(record.resumptionId));
|
|
1020
|
+
return true;
|
|
917
1021
|
}
|
|
918
1022
|
|
|
919
1023
|
#maybeFabricForId(fabricId: FabricId, fabricIndex?: FabricIndex) {
|
|
@@ -938,50 +1042,70 @@ export class SessionManager {
|
|
|
938
1042
|
|
|
939
1043
|
this.#groupDataMessageCounter = await this.#createGroupDataMessageCounter();
|
|
940
1044
|
|
|
941
|
-
|
|
942
|
-
"resumptionRecords",
|
|
943
|
-
[],
|
|
944
|
-
);
|
|
1045
|
+
await this.#migrateLegacyResumptionRecords();
|
|
945
1046
|
|
|
946
|
-
storedResumptionRecords.
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
sharedSecret,
|
|
950
|
-
resumptionId,
|
|
951
|
-
fabricId,
|
|
952
|
-
fabricIndex,
|
|
953
|
-
peerNodeId,
|
|
954
|
-
sessionParameters,
|
|
955
|
-
caseAuthenticatedTags,
|
|
956
|
-
}) => {
|
|
957
|
-
const fabric = this.#maybeFabricForId(fabricId, fabricIndex);
|
|
958
|
-
if (!fabric) {
|
|
959
|
-
this.#logger.warn(
|
|
960
|
-
`Ignoring resumption record for fabric 0x${toHex(fabricId)} and index ${fabricIndex} because we cannot find a matching fabric`,
|
|
961
|
-
);
|
|
962
|
-
return;
|
|
963
|
-
}
|
|
1047
|
+
const storedResumptionRecords = await this.#resumptionStore.load((address, record) => {
|
|
1048
|
+
const { fabricId, fabricIndex, version = 0 } = record;
|
|
1049
|
+
if (this.#maybeFabricForId(fabricId, fabricIndex)?.fabricIndex !== address.fabricIndex) {
|
|
964
1050
|
this.#logger.info(
|
|
965
|
-
|
|
966
|
-
fabric.addressOf(nodeId).toString(),
|
|
967
|
-
"and peer node",
|
|
968
|
-
fabric.addressOf(peerNodeId).toString(),
|
|
969
|
-
"for fabric id",
|
|
970
|
-
`0x${toHex(fabric.fabricId)}`,
|
|
971
|
-
`(0x${toHex(fabric.rootVendorId)}, "${fabric?.label}")`,
|
|
1051
|
+
`Deleting resumption record for ${address} because it does not match a fabric (fabric 0x${toHex(fabricId)} with index ${fabricIndex})`,
|
|
972
1052
|
);
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
)
|
|
1053
|
+
return false;
|
|
1054
|
+
}
|
|
1055
|
+
if (!isUsableResumptionRecord(record)) {
|
|
1056
|
+
this.#logger.info(
|
|
1057
|
+
`Deleting resumption record for ${address} stored with format version ${version}; the peer establishes a new session`,
|
|
1058
|
+
);
|
|
1059
|
+
return false;
|
|
1060
|
+
}
|
|
1061
|
+
return true;
|
|
1062
|
+
});
|
|
1063
|
+
|
|
1064
|
+
for (const [address, { version, sessionParameters, ...stored }] of storedResumptionRecords) {
|
|
1065
|
+
this.#logger.debug("Restoring resumption record for", address.toString());
|
|
1066
|
+
const record = {
|
|
1067
|
+
...stored,
|
|
1068
|
+
// Make sure to initialize default values when restoring an older resumption record
|
|
1069
|
+
sessionParameters: SessionParameters(sessionParameters),
|
|
1070
|
+
};
|
|
1071
|
+
this.#rememberResumptionRecord(address, record);
|
|
1072
|
+
if (version !== RESUMPTION_RECORD_VERSION) {
|
|
1073
|
+
await this.#resumptionStore.set(address, storageRecordOf(record));
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
if (storedResumptionRecords.size) {
|
|
1077
|
+
this.#logger.info(`Restored ${storedResumptionRecords.size} resumption records`);
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
/**
|
|
1082
|
+
* Move the records of the single legacy array to one key per peer. The array is authoritative when present because
|
|
1083
|
+
* only a version without per-peer storage writes it. It is deleted last, so a start interrupted before that moves
|
|
1084
|
+
* it again. Records of fabrics that no longer exist are dropped.
|
|
1085
|
+
*/
|
|
1086
|
+
async #migrateLegacyResumptionRecords() {
|
|
1087
|
+
const storage = this.#context.storage;
|
|
1088
|
+
if (!(await storage.has(LEGACY_RESUMPTION_RECORDS_KEY))) {
|
|
1089
|
+
return;
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
const legacyRecords = await storage.get<LegacyResumptionStorageRecord[]>(LEGACY_RESUMPTION_RECORDS_KEY, []);
|
|
1093
|
+
const records = new Array<[PeerAddress, ResumptionStorageRecord]>();
|
|
1094
|
+
for (const { nodeId, ...record } of legacyRecords) {
|
|
1095
|
+
const fabric = this.#maybeFabricForId(record.fabricId, record.fabricIndex);
|
|
1096
|
+
if (fabric === undefined) {
|
|
1097
|
+
this.#logger.info(
|
|
1098
|
+
`Dropping resumption record for fabric 0x${toHex(record.fabricId)} and index ${record.fabricIndex} because we cannot find a matching fabric`,
|
|
1099
|
+
);
|
|
1100
|
+
continue;
|
|
1101
|
+
}
|
|
1102
|
+
records.push([fabric.addressOf(nodeId), { ...record, fabricIndex: fabric.fabricIndex }]);
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
await this.#resumptionStore.replaceAll(records);
|
|
1106
|
+
await storage.delete(LEGACY_RESUMPTION_RECORDS_KEY);
|
|
1107
|
+
|
|
1108
|
+
this.#logger.info(`Moved ${records.length} resumption records to per-peer storage`);
|
|
985
1109
|
}
|
|
986
1110
|
|
|
987
1111
|
/**
|
|
@@ -1020,7 +1144,7 @@ export class SessionManager {
|
|
|
1020
1144
|
|
|
1021
1145
|
getActiveSessionInformation(): ActiveSessionInformation[] {
|
|
1022
1146
|
this.#construction.assert();
|
|
1023
|
-
return
|
|
1147
|
+
return this.#establishedSessions
|
|
1024
1148
|
.filter(session => session.isSecure && !session.isPase)
|
|
1025
1149
|
.map(session => {
|
|
1026
1150
|
const activity = session instanceof SecureSession ? session.wallClockActivity : undefined;
|
|
@@ -1055,8 +1179,9 @@ export class SessionManager {
|
|
|
1055
1179
|
}
|
|
1056
1180
|
|
|
1057
1181
|
await this.closeAllSessions();
|
|
1182
|
+
await this.#resumptionStore.clear();
|
|
1058
1183
|
await this.#context.storage.clearAll();
|
|
1059
|
-
this.#
|
|
1184
|
+
this.#forgetAllResumptionRecords();
|
|
1060
1185
|
await this.#groupDataMessageCounter?.close();
|
|
1061
1186
|
this.#groupDataMessageCounter = await this.#createGroupDataMessageCounter();
|
|
1062
1187
|
}
|
|
@@ -1071,7 +1196,7 @@ export class SessionManager {
|
|
|
1071
1196
|
|
|
1072
1197
|
const context: PeerLossContext = { cause: new ShutdownError("Session closed by node shutdown") };
|
|
1073
1198
|
|
|
1074
|
-
const closePromises = this.#
|
|
1199
|
+
const closePromises = this.#registeredSessions.map(async session => {
|
|
1075
1200
|
await session.closeSubscriptionsForShutdown();
|
|
1076
1201
|
|
|
1077
1202
|
// TODO - some CHIP tests (CASERecovery for one) expect us to exit without closing the session and will fail
|
|
@@ -1079,7 +1204,7 @@ export class SessionManager {
|
|
|
1079
1204
|
// node attempts contact even if we've already restarted
|
|
1080
1205
|
await session.initiateForceClose(context);
|
|
1081
1206
|
|
|
1082
|
-
this.#
|
|
1207
|
+
this.#registeredSessions.delete(session);
|
|
1083
1208
|
});
|
|
1084
1209
|
|
|
1085
1210
|
for (const session of this.#unsecuredSessions.values()) {
|
|
@@ -1104,3 +1229,118 @@ export class SessionManager {
|
|
|
1104
1229
|
this.#nextSessionId = (this.#context.fabrics.crypto.randomUint32 % upperBound) + 1;
|
|
1105
1230
|
}
|
|
1106
1231
|
}
|
|
1232
|
+
|
|
1233
|
+
/**
|
|
1234
|
+
* Whether {@link newer} replaces {@link older} for the peer's subscriptions: both are CASE sessions with the same peer
|
|
1235
|
+
* and equal CASE Authenticated Tags, so a subscription that moves keeps the access subject it was set up with. The
|
|
1236
|
+
* role does not matter, because both roles store the CATs of the peer's NOC. This matches
|
|
1237
|
+
* `SecureSessionTable::NewerSessionAvailable` of the CHIP SDK.
|
|
1238
|
+
*
|
|
1239
|
+
* Only {@link newer} needs the PASE check: a PASE session has the unspecified peer node ID, which no CASE peer has, so
|
|
1240
|
+
* an {@link older} session with the same peer as a CASE session is a CASE session too.
|
|
1241
|
+
*/
|
|
1242
|
+
function supersedes(newer: NodeSession, older: NodeSession) {
|
|
1243
|
+
return !newer.isPase && newer.peerIs(older.peerAddress) && hasEqualCats(newer, older);
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
function hasEqualCats(session: NodeSession, other: NodeSession) {
|
|
1247
|
+
const tags = new Set(session.caseAuthenticatedTags);
|
|
1248
|
+
const otherTags = new Set(other.caseAuthenticatedTags);
|
|
1249
|
+
return tags.size === otherTags.size && [...otherTags].every(tag => tags.has(tag));
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
/**
|
|
1253
|
+
* The registered sessions. The set also adds each session to the set of established sessions once it is established.
|
|
1254
|
+
* A session that is already established on registration joins that set after all observers of {@link added} ran.
|
|
1255
|
+
*/
|
|
1256
|
+
class RegisteredSessions extends BasicSet<NodeSession> {
|
|
1257
|
+
readonly #established: BasicSet<NodeSession>;
|
|
1258
|
+
readonly #positions = new WeakMap<NodeSession, number>();
|
|
1259
|
+
#count = 0;
|
|
1260
|
+
|
|
1261
|
+
constructor(established: BasicSet<NodeSession>) {
|
|
1262
|
+
super();
|
|
1263
|
+
this.#established = established;
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
override add(session: NodeSession) {
|
|
1267
|
+
if (this.has(session)) {
|
|
1268
|
+
return;
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
this.#positions.set(session, this.#count++);
|
|
1272
|
+
super.add(session);
|
|
1273
|
+
|
|
1274
|
+
if (session.isEstablishing) {
|
|
1275
|
+
session.established.once(() => {
|
|
1276
|
+
// A session disposed without a close leaves this set while it is not closing and may still establish
|
|
1277
|
+
if (this.has(session)) {
|
|
1278
|
+
this.#established.add(session);
|
|
1279
|
+
}
|
|
1280
|
+
});
|
|
1281
|
+
} else {
|
|
1282
|
+
this.#established.add(session);
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
get count() {
|
|
1287
|
+
return this.#count;
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
/** The position of {@link session} in the registration order; kept after it leaves. Undefined if never added. */
|
|
1291
|
+
positionOf(session: NodeSession) {
|
|
1292
|
+
return this.#positions.get(session);
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
isRegisteredBefore(session: NodeSession, position: number) {
|
|
1296
|
+
const own = this.#positions.get(session);
|
|
1297
|
+
return own !== undefined && own < position;
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
function storageRecordOf({
|
|
1302
|
+
sharedSecret,
|
|
1303
|
+
resumptionId,
|
|
1304
|
+
peerNodeId,
|
|
1305
|
+
fabricId,
|
|
1306
|
+
fabricIndex,
|
|
1307
|
+
sessionParameters,
|
|
1308
|
+
caseAuthenticatedTags,
|
|
1309
|
+
}: InternalResumptionRecord): ResumptionStorageRecord {
|
|
1310
|
+
return {
|
|
1311
|
+
version: RESUMPTION_RECORD_VERSION,
|
|
1312
|
+
sharedSecret,
|
|
1313
|
+
resumptionId,
|
|
1314
|
+
fabricId,
|
|
1315
|
+
fabricIndex,
|
|
1316
|
+
peerNodeId,
|
|
1317
|
+
sessionParameters: {
|
|
1318
|
+
...sessionParameters,
|
|
1319
|
+
supportedTransports: sessionParameters.supportedTransports
|
|
1320
|
+
? SupportedTransportsSchema.encode(sessionParameters.supportedTransports)
|
|
1321
|
+
: undefined,
|
|
1322
|
+
},
|
|
1323
|
+
caseAuthenticatedTags,
|
|
1324
|
+
};
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
/**
|
|
1328
|
+
* Whether this version uses a stored record. A record without a version that carries CATs is not used: a record does
|
|
1329
|
+
* not say which CASE role wrote it, and versions before {@link RESUMPTION_RECORD_VERSION} stored the local node's own
|
|
1330
|
+
* CATs when they initiated the session. A peer whose record is not used establishes a full CASE session once.
|
|
1331
|
+
*
|
|
1332
|
+
* Accepted tradeoff: a record without a version and without CATs may lack CATs that the peer's NOC has. The peer then
|
|
1333
|
+
* has fewer rights, never more, until its next full CASE session.
|
|
1334
|
+
*/
|
|
1335
|
+
function isUsableResumptionRecord({ version = 0, caseAuthenticatedTags }: ResumptionStorageRecord) {
|
|
1336
|
+
switch (version) {
|
|
1337
|
+
case 0:
|
|
1338
|
+
return !caseAuthenticatedTags?.length;
|
|
1339
|
+
|
|
1340
|
+
case RESUMPTION_RECORD_VERSION:
|
|
1341
|
+
return true;
|
|
1342
|
+
|
|
1343
|
+
default:
|
|
1344
|
+
return false;
|
|
1345
|
+
}
|
|
1346
|
+
}
|