@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
|
@@ -0,0 +1,794 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2026 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import {
|
|
7
|
+
Bytes,
|
|
8
|
+
ClosedError,
|
|
9
|
+
DnsCodec,
|
|
10
|
+
DnsMessageType,
|
|
11
|
+
DnsRecordType,
|
|
12
|
+
Instant,
|
|
13
|
+
isDeepEqual,
|
|
14
|
+
Logger,
|
|
15
|
+
MaybePromise,
|
|
16
|
+
Millis,
|
|
17
|
+
Minutes,
|
|
18
|
+
Mutex,
|
|
19
|
+
Seconds,
|
|
20
|
+
Time
|
|
21
|
+
} from "@matter/general";
|
|
22
|
+
const logger = Logger.get("MdnsServer");
|
|
23
|
+
const MULTICAST_INTERVAL = Seconds(1);
|
|
24
|
+
const INTERFACE_LIFETIME = Minutes(15);
|
|
25
|
+
const DETAILS_RETRY_INTERVAL = Seconds(10);
|
|
26
|
+
const GOODBYE_RETRY_MAXIMUM_INTERVAL = Minutes(1);
|
|
27
|
+
class InterfaceResponder {
|
|
28
|
+
name;
|
|
29
|
+
#owner;
|
|
30
|
+
#gate;
|
|
31
|
+
#details;
|
|
32
|
+
#detailsVersion = 0;
|
|
33
|
+
#detailsExpireAt = 0;
|
|
34
|
+
#retryReadAt = 0;
|
|
35
|
+
#reading;
|
|
36
|
+
#view;
|
|
37
|
+
/** What peer caches on this interface may hold, keyed by {@link recordKeyOf} */
|
|
38
|
+
#peerCache = /* @__PURE__ */ new Map();
|
|
39
|
+
/** Records the RFC 6762 §6 rule held back, keyed by {@link recordKeyOf} */
|
|
40
|
+
#deferred = /* @__PURE__ */ new Map();
|
|
41
|
+
#deferredTimer;
|
|
42
|
+
#goodbyeRetry;
|
|
43
|
+
#usedAt;
|
|
44
|
+
#isListed = true;
|
|
45
|
+
#isClosing = false;
|
|
46
|
+
/** Whether a read failed while no details were known; valid details are never forgotten, so this ends nothing */
|
|
47
|
+
#isDetailsFailing = false;
|
|
48
|
+
/** Set by a multicast that failed or missed an address family; cleared by one that reached every family */
|
|
49
|
+
#isMulticastOutage = false;
|
|
50
|
+
constructor(name, owner) {
|
|
51
|
+
this.name = name;
|
|
52
|
+
this.#owner = owner;
|
|
53
|
+
this.#gate = new Mutex(this);
|
|
54
|
+
this.#usedAt = Time.nowUs;
|
|
55
|
+
}
|
|
56
|
+
toString() {
|
|
57
|
+
return `mDNS responder on ${this.name}`;
|
|
58
|
+
}
|
|
59
|
+
/** The last valid details read, if any. */
|
|
60
|
+
get details() {
|
|
61
|
+
return this.#details;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Whether the details should be read before the next answer or announcement: never read, read longer than
|
|
65
|
+
* {@link INTERFACE_LIFETIME} ago, and no failed read waiting for its retry.
|
|
66
|
+
*/
|
|
67
|
+
get needsDetailsRead() {
|
|
68
|
+
const now = Time.nowUs;
|
|
69
|
+
return this.#detailsExpireAt <= now && this.#retryReadAt <= now;
|
|
70
|
+
}
|
|
71
|
+
/** Whether the last interface listing included this interface. */
|
|
72
|
+
get isListed() {
|
|
73
|
+
return this.#isListed;
|
|
74
|
+
}
|
|
75
|
+
set isListed(isListed) {
|
|
76
|
+
this.#isListed = isListed;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Forget records whose TTL ended and whose last multicast is more than a second ago. Returns whether this state
|
|
80
|
+
* can go: peers cache nothing sent here, nothing is deferred, no goodbye retry waits, and neither {@link answer}
|
|
81
|
+
* nor {@link publish} ran for {@link INTERFACE_LIFETIME}.
|
|
82
|
+
*/
|
|
83
|
+
prune() {
|
|
84
|
+
const now = Time.nowUs;
|
|
85
|
+
for (const [key, { cachedUntil, lastMulticastAt }] of this.#peerCache) {
|
|
86
|
+
if (cachedUntil <= now && now - (lastMulticastAt ?? -Infinity) >= MULTICAST_INTERVAL) {
|
|
87
|
+
this.#peerCache.delete(key);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return this.#peerCache.size === 0 && this.#deferred.size === 0 && !this.#goodbyeRetry?.timer.isRunning && now - this.#usedAt > INTERFACE_LIFETIME;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Read the details again at the next {@link readDetails}, also within {@link INTERFACE_LIFETIME} or a retry wait,
|
|
94
|
+
* because the network reported that they changed.
|
|
95
|
+
*/
|
|
96
|
+
detailsChanged() {
|
|
97
|
+
this.#detailsExpireAt = 0;
|
|
98
|
+
this.#retryReadAt = 0;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Read the addresses and MAC of this interface; synchronous if the network reports them synchronously.
|
|
102
|
+
* Concurrent reads share one lookup.
|
|
103
|
+
*
|
|
104
|
+
* A read that fails or reports no details never replaces valid details read before: those stay in use, and no
|
|
105
|
+
* read happens again before {@link DETAILS_RETRY_INTERVAL} passed; until then this returns at once. Without
|
|
106
|
+
* earlier details, a failed read throws what the network throws, after logging it: a notice for the first failure,
|
|
107
|
+
* debug for later ones.
|
|
108
|
+
*/
|
|
109
|
+
readDetails() {
|
|
110
|
+
if (this.#reading !== void 0) {
|
|
111
|
+
return this.#reading;
|
|
112
|
+
}
|
|
113
|
+
if (this.#retryReadAt > Time.nowUs) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
let details;
|
|
117
|
+
try {
|
|
118
|
+
details = this.#owner.socket.network.getIpMac(this.name);
|
|
119
|
+
} catch (error) {
|
|
120
|
+
this.#readFailed(error);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (!MaybePromise.is(details)) {
|
|
124
|
+
this.#setDetails(details);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
return this.#reading = Promise.resolve(details).then(
|
|
128
|
+
(details2) => this.#setDetails(details2),
|
|
129
|
+
(error) => this.#readFailed(error)
|
|
130
|
+
).finally(() => this.#reading = void 0);
|
|
131
|
+
}
|
|
132
|
+
#setDetails(details) {
|
|
133
|
+
const now = Time.nowUs;
|
|
134
|
+
if (details === void 0) {
|
|
135
|
+
if (this.#details !== void 0) {
|
|
136
|
+
logger.debug(`Keeping the last details of interface ${this.name}, which reports none now`);
|
|
137
|
+
}
|
|
138
|
+
this.#retryReadAt = now + DETAILS_RETRY_INTERVAL;
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (!isDeepEqual(details, this.#details)) {
|
|
142
|
+
this.#details = details;
|
|
143
|
+
this.#detailsVersion++;
|
|
144
|
+
}
|
|
145
|
+
this.#detailsExpireAt = now + INTERFACE_LIFETIME;
|
|
146
|
+
this.#retryReadAt = 0;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Without earlier details, the first failure logs a notice and later ones log at debug level; the error is
|
|
150
|
+
* rethrown, so the caller does not log it again. With earlier details, those stay in use.
|
|
151
|
+
*/
|
|
152
|
+
#readFailed(error) {
|
|
153
|
+
this.#retryReadAt = Time.nowUs + DETAILS_RETRY_INTERVAL;
|
|
154
|
+
if (this.#details !== void 0) {
|
|
155
|
+
logger.debug(`Keeping the last details of interface ${this.name}, which cannot be read`, error);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (this.#isDetailsFailing) {
|
|
159
|
+
logger.debug(`Details of interface ${this.name} cannot be read`, error);
|
|
160
|
+
} else {
|
|
161
|
+
this.#isDetailsFailing = true;
|
|
162
|
+
logger.notice(`Details of interface ${this.name} cannot be read`, error);
|
|
163
|
+
}
|
|
164
|
+
throw error;
|
|
165
|
+
}
|
|
166
|
+
/** The names of the records of the current registrations; empty without valid details. */
|
|
167
|
+
names() {
|
|
168
|
+
return this.#currentView(false)?.ownedNames ?? /* @__PURE__ */ new Set();
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Answer a query: one packet per service with answers, 20–120 ms apart. Settles once these packets are sent.
|
|
172
|
+
* A failed send is logged and does not stop the next packet. Records the one-second rule holds back are
|
|
173
|
+
* deferred, see the class description.
|
|
174
|
+
*
|
|
175
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc6762#section-6} RFC 6762 §6
|
|
176
|
+
*/
|
|
177
|
+
async answer(message) {
|
|
178
|
+
const receivedAt = this.#usedAt = Time.nowUs;
|
|
179
|
+
const view = this.#currentView();
|
|
180
|
+
if (view === void 0 || !message.queries.some(({ name }) => view.ownedNames.has(name.toLowerCase()))) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
const visited = /* @__PURE__ */ new Set();
|
|
184
|
+
let more = false;
|
|
185
|
+
do {
|
|
186
|
+
if (more) {
|
|
187
|
+
await Time.sleep("MDNS delay", packetDelay());
|
|
188
|
+
}
|
|
189
|
+
more = await this.#produce(() => this.#sendAnswer(message, visited, receivedAt));
|
|
190
|
+
} while (more);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* In one message, say goodbye to the records that peers may cache here but that the current records of the
|
|
194
|
+
* registrations no longer hold, and announce the named services, or all registered services for "all". A service
|
|
195
|
+
* is announced as well when one of its records replaces a record that gets a goodbye: a unique record (SRV, TXT,
|
|
196
|
+
* A, AAAA) of the same name, type and class, as after a change of the host name, a TXT value or an address. This
|
|
197
|
+
* holds for every publication, a goodbye retry included, while the interface is listed; an interface no longer
|
|
198
|
+
* listed gets only goodbyes. While such a goodbye does not reach every address family, each publication on the
|
|
199
|
+
* interface carries the replacing services again, until peers dropped the old record at the end of its TTL; we
|
|
200
|
+
* accept these repeats because a peer on the failed family would otherwise keep no record of the service.
|
|
201
|
+
*
|
|
202
|
+
* The goodbye goes out only while the current records are known: without valid interface details nothing is
|
|
203
|
+
* sent. Every record that left gets a goodbye with TTL 0. It carries the cache-flush bit only when its type is
|
|
204
|
+
* unique (SRV, TXT, A, AAAA) and the current records hold nothing of its name, type and class (RFC 6762 §10.2);
|
|
205
|
+
* otherwise it carries no bit, so it removes only the old record.
|
|
206
|
+
*
|
|
207
|
+
* Goodbyes and announcements are never held by the one-second rule, as in CHIP and matter.js 0.18; RFC 6762 §6
|
|
208
|
+
* has no such exception. Settles once sent. A failed
|
|
209
|
+
* send is logged like a failed answer; the goodbyes, with the services that replace them, are tried again, see
|
|
210
|
+
* {@link #retryGoodbyes}. Once
|
|
211
|
+
* {@link close} started, rejects with {@link ClosedError}.
|
|
212
|
+
*
|
|
213
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc6762#section-8.3} RFC 6762 §8.3
|
|
214
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc6762#section-10.1} RFC 6762 §10.1
|
|
215
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc6762#section-10.2} RFC 6762 §10.2
|
|
216
|
+
*/
|
|
217
|
+
async publish(services) {
|
|
218
|
+
if (this.#isClosing) {
|
|
219
|
+
throw new ClosedError(`Cannot publish: ${this} is closed`);
|
|
220
|
+
}
|
|
221
|
+
this.#usedAt = Time.nowUs;
|
|
222
|
+
await this.#gate.produce(() => this.#sendPublication(services));
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Stop sending. Deferred records are dropped, and so are answers that wait for the mutex; publications that
|
|
226
|
+
* wait still send their goodbyes. Settles once the last send settled, so it waits for the UDP send in flight.
|
|
227
|
+
*/
|
|
228
|
+
async close() {
|
|
229
|
+
this.#isClosing = true;
|
|
230
|
+
this.#deferredTimer?.stop();
|
|
231
|
+
this.#deferred.clear();
|
|
232
|
+
this.#goodbyeRetry?.timer.stop();
|
|
233
|
+
this.#goodbyeRetry = void 0;
|
|
234
|
+
await this.#gate.close();
|
|
235
|
+
}
|
|
236
|
+
/** Run {@link task} in the mutex unless closing; resolves to undefined if it did not run. */
|
|
237
|
+
#produce(task) {
|
|
238
|
+
if (this.#isClosing) {
|
|
239
|
+
return Promise.resolve(void 0);
|
|
240
|
+
}
|
|
241
|
+
return this.#gate.produce(() => this.#isClosing ? Promise.resolve(void 0) : task());
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Send the packet for the first service in registration order that has not been visited yet and that has
|
|
245
|
+
* answers. Resolves to whether services remain.
|
|
246
|
+
*/
|
|
247
|
+
#sendAnswer(message, visited, receivedAt) {
|
|
248
|
+
const view = this.#currentView();
|
|
249
|
+
if (view === void 0) {
|
|
250
|
+
return Promise.resolve(false);
|
|
251
|
+
}
|
|
252
|
+
const { sourceIp, transactionId, queries, answers: knownAnswers } = message;
|
|
253
|
+
const knownKeys = knownAnswers.map((record) => ({ key: recordKeyOf(record), ttl: record.ttl }));
|
|
254
|
+
const isKnown = (record) => knownKeys.some(({ key, ttl }) => ttl > record.ttl / 2 && key === recordKeyOf(record));
|
|
255
|
+
for (const [service, portRecords] of view.byService) {
|
|
256
|
+
if (visited.has(service)) continue;
|
|
257
|
+
visited.add(service);
|
|
258
|
+
const answers = uniqueRecords(queries.flatMap((query) => queryRecords(query, portRecords))).filter(
|
|
259
|
+
(record) => !isKnown(record)
|
|
260
|
+
);
|
|
261
|
+
if (answers.length === 0) continue;
|
|
262
|
+
const additionalRecords = additionalRecordsFor(queries, portRecords, answers).filter(
|
|
263
|
+
(record) => !isKnown(record)
|
|
264
|
+
);
|
|
265
|
+
const now = Time.nowUs;
|
|
266
|
+
const isUnicast = queries.every((query) => query.uniCastResponse) && answers.every((answer) => this.#sinceCachedMulticast(answer, now) <= answer.ttl / 4);
|
|
267
|
+
let sentAnswers = answers;
|
|
268
|
+
let sentAdditional = additionalRecords;
|
|
269
|
+
if (!isUnicast) {
|
|
270
|
+
const packet = [...answers, ...additionalRecords];
|
|
271
|
+
sentAnswers = this.#holdBack(
|
|
272
|
+
answers,
|
|
273
|
+
now,
|
|
274
|
+
() => receivedAt,
|
|
275
|
+
"answer",
|
|
276
|
+
() => additionalRecords,
|
|
277
|
+
packet
|
|
278
|
+
);
|
|
279
|
+
sentAdditional = this.#holdBack(
|
|
280
|
+
additionalRecords,
|
|
281
|
+
now,
|
|
282
|
+
() => receivedAt,
|
|
283
|
+
"additional",
|
|
284
|
+
noRecords,
|
|
285
|
+
packet
|
|
286
|
+
);
|
|
287
|
+
if (sentAnswers.length === 0) continue;
|
|
288
|
+
}
|
|
289
|
+
const more = [...view.byService.keys()].some((other) => !visited.has(other));
|
|
290
|
+
return this.#transmit(
|
|
291
|
+
{
|
|
292
|
+
messageType: DnsMessageType.Response,
|
|
293
|
+
transactionId,
|
|
294
|
+
answers: sendable(sentAnswers, portRecords, isUnicast),
|
|
295
|
+
additionalRecords: sendable(sentAdditional, portRecords, isUnicast)
|
|
296
|
+
},
|
|
297
|
+
isUnicast ? sourceIp : void 0,
|
|
298
|
+
sentAnswers
|
|
299
|
+
).then(
|
|
300
|
+
() => more,
|
|
301
|
+
(error) => {
|
|
302
|
+
this.#sendFailed(error, isUnicast ? sourceIp : void 0);
|
|
303
|
+
return more;
|
|
304
|
+
}
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
return Promise.resolve(false);
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* {@link records} without those the one-second rule holds back. The address records of one name form one set
|
|
311
|
+
* (RFC 6762 §6.2) across {@link packet}, the records that may go in the same packet in either section: when one of
|
|
312
|
+
* them is held, all of them wait for the latest one's second. A held record is
|
|
313
|
+
* deferred unless a multicast answer that carried it left at or after its {@link sinceOf} time. A deferred answer
|
|
314
|
+
* remembers its {@link additionalOf} records, so the deferred packet carries what this packet would have carried.
|
|
315
|
+
*/
|
|
316
|
+
#holdBack(records, now, sinceOf, section, additionalOf, packet) {
|
|
317
|
+
const heldUntil = /* @__PURE__ */ new Map();
|
|
318
|
+
for (const record of records) {
|
|
319
|
+
const until = this.#heldUntil(record);
|
|
320
|
+
if (now < until) {
|
|
321
|
+
heldUntil.set(record, until);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
for (const addressSet of addressSetsOf(packet)) {
|
|
325
|
+
const until = Math.max(...addressSet.map((record) => this.#heldUntil(record)));
|
|
326
|
+
if (now < until) {
|
|
327
|
+
for (const record of addressSet) {
|
|
328
|
+
if (records.includes(record)) {
|
|
329
|
+
heldUntil.set(record, until);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
return records.filter((record) => {
|
|
335
|
+
const until = heldUntil.get(record);
|
|
336
|
+
if (until === void 0) {
|
|
337
|
+
return true;
|
|
338
|
+
}
|
|
339
|
+
const since = sinceOf(record);
|
|
340
|
+
if (!this.#isDeliveredSince(record, since)) {
|
|
341
|
+
this.#defer(record, section, since, additionalOf(record), until);
|
|
342
|
+
}
|
|
343
|
+
return false;
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
#sendPublication(services) {
|
|
347
|
+
const view = this.#currentView();
|
|
348
|
+
if (view === void 0) {
|
|
349
|
+
return Promise.resolve();
|
|
350
|
+
}
|
|
351
|
+
const now = Time.nowUs;
|
|
352
|
+
const goodbye = this.#goodbyesFor(view, now);
|
|
353
|
+
const replaced = new Set(
|
|
354
|
+
this.#isListed ? goodbye.filter((record) => DnsRecordType.isUnique(record.recordType) && view.setKeys.has(setKeyOf(record))).map(setKeyOf) : []
|
|
355
|
+
);
|
|
356
|
+
const complete = new Array();
|
|
357
|
+
if (!this.#isClosing) {
|
|
358
|
+
for (const [service, records] of view.byService) {
|
|
359
|
+
if (services === "all" || services.includes(service) || records.some((record) => replaced.has(setKeyOf(record)))) {
|
|
360
|
+
complete.push(...records);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
const announced = uniqueRecords(complete);
|
|
365
|
+
if (!goodbye.length && !announced.length) {
|
|
366
|
+
this.#stopGoodbyeRetry();
|
|
367
|
+
return Promise.resolve();
|
|
368
|
+
}
|
|
369
|
+
return this.#transmit({
|
|
370
|
+
messageType: DnsMessageType.Response,
|
|
371
|
+
answers: [...goodbye, ...sendable(announced, complete, false)]
|
|
372
|
+
}).then(
|
|
373
|
+
() => this.#settleGoodbyes(),
|
|
374
|
+
(error) => {
|
|
375
|
+
this.#sendFailed(error);
|
|
376
|
+
this.#settleGoodbyes();
|
|
377
|
+
}
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* The goodbyes for the records peers may cache here that {@link view} no longer holds, see {@link publish}.
|
|
382
|
+
*
|
|
383
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc6762#section-10.2} RFC 6762 §10.2
|
|
384
|
+
*/
|
|
385
|
+
#goodbyesFor(view, now) {
|
|
386
|
+
const goodbye = new Array();
|
|
387
|
+
for (const [key, { record, cachedUntil }] of this.#peerCache) {
|
|
388
|
+
if (cachedUntil <= now || view.byKey.has(key)) {
|
|
389
|
+
continue;
|
|
390
|
+
}
|
|
391
|
+
goodbye.push({
|
|
392
|
+
...record,
|
|
393
|
+
ttl: Instant,
|
|
394
|
+
flushCache: DnsRecordType.isUnique(record.recordType) && !view.setKeys.has(setKeyOf(record))
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
return goodbye;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Send the goodbyes again that peers may still need here, with the services that replace them, see
|
|
401
|
+
* {@link publish}, and with no other publication needed: first a second later,
|
|
402
|
+
* then at twice the interval up to {@link GOODBYE_RETRY_MAXIMUM_INTERVAL}. A retry that waits keeps its schedule.
|
|
403
|
+
* {@link #settleGoodbyes} ends the retry, and the next one starts at a second again, once no goodbye is needed.
|
|
404
|
+
* Stops on {@link close}.
|
|
405
|
+
*/
|
|
406
|
+
#retryGoodbyes() {
|
|
407
|
+
if (this.#isClosing || this.#goodbyeRetry?.timer.isRunning) {
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
const interval = Math.min(
|
|
411
|
+
(this.#goodbyeRetry?.interval ?? MULTICAST_INTERVAL / 2) * 2,
|
|
412
|
+
GOODBYE_RETRY_MAXIMUM_INTERVAL
|
|
413
|
+
);
|
|
414
|
+
const timer = Time.getTimer(
|
|
415
|
+
"MDNS goodbye retry",
|
|
416
|
+
Millis(interval),
|
|
417
|
+
() => this.#gate.run(() => this.#sendPublication([]))
|
|
418
|
+
);
|
|
419
|
+
this.#goodbyeRetry = { timer, interval };
|
|
420
|
+
timer.start();
|
|
421
|
+
}
|
|
422
|
+
/** Try the goodbyes again that peers may still need here, or end the retry when none remain. */
|
|
423
|
+
#settleGoodbyes() {
|
|
424
|
+
const view = this.#currentView();
|
|
425
|
+
if (view !== void 0 && this.#goodbyesFor(view, Time.nowUs).length) {
|
|
426
|
+
this.#retryGoodbyes();
|
|
427
|
+
} else {
|
|
428
|
+
this.#stopGoodbyeRetry();
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
#stopGoodbyeRetry() {
|
|
432
|
+
this.#goodbyeRetry?.timer.stop();
|
|
433
|
+
this.#goodbyeRetry = void 0;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Send the deferred records whose second has passed, as one packet, under the same {@link #holdBack} decision as
|
|
437
|
+
* the packet that deferred them: a record held again is deferred again, and a record a multicast answer carried at
|
|
438
|
+
* or after its deferral's {@link Deferral.since} time is not sent. A record its service no longer publishes is
|
|
439
|
+
* dropped. A deferred answer brings the additional records its query would have carried.
|
|
440
|
+
*/
|
|
441
|
+
#sendDeferred() {
|
|
442
|
+
const now = Time.nowUs;
|
|
443
|
+
const published = this.#currentView()?.byKey ?? /* @__PURE__ */ new Map();
|
|
444
|
+
const deferrals = [...this.#deferred];
|
|
445
|
+
this.#deferred.clear();
|
|
446
|
+
const answers = new Array();
|
|
447
|
+
const additionalRecords = new Array();
|
|
448
|
+
const sinceOf = /* @__PURE__ */ new Map();
|
|
449
|
+
const additionalOf = /* @__PURE__ */ new Map();
|
|
450
|
+
for (const [key, { section, since, additionalKeys }] of deferrals) {
|
|
451
|
+
const record = published.get(key);
|
|
452
|
+
if (record === void 0) continue;
|
|
453
|
+
sinceOf.set(record, since);
|
|
454
|
+
if (section === "additional") {
|
|
455
|
+
additionalRecords.push(record);
|
|
456
|
+
continue;
|
|
457
|
+
}
|
|
458
|
+
answers.push(record);
|
|
459
|
+
const additional = new Array();
|
|
460
|
+
for (const additionalKey of additionalKeys) {
|
|
461
|
+
const additionalRecord = published.get(additionalKey);
|
|
462
|
+
if (additionalRecord !== void 0) {
|
|
463
|
+
additional.push(additionalRecord);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
additionalOf.set(record, additional);
|
|
467
|
+
}
|
|
468
|
+
const timeOf = (record) => sinceOf.get(record) ?? now;
|
|
469
|
+
const packet = uniqueRecords([...answers, ...additionalRecords, ...[...additionalOf.values()].flat()]);
|
|
470
|
+
const sentAnswers = this.#holdBack(
|
|
471
|
+
answers,
|
|
472
|
+
now,
|
|
473
|
+
timeOf,
|
|
474
|
+
"answer",
|
|
475
|
+
(record) => additionalOf.get(record) ?? [],
|
|
476
|
+
packet
|
|
477
|
+
);
|
|
478
|
+
const answerKeys = new Set(sentAnswers.map((record) => recordKeyOf(record)));
|
|
479
|
+
for (const answer of sentAnswers) {
|
|
480
|
+
for (const additional of additionalOf.get(answer) ?? []) {
|
|
481
|
+
if (!sinceOf.has(additional)) {
|
|
482
|
+
sinceOf.set(additional, timeOf(answer));
|
|
483
|
+
}
|
|
484
|
+
additionalRecords.push(additional);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
const sentAdditional = this.#holdBack(
|
|
488
|
+
uniqueRecords(additionalRecords).filter((record) => !answerKeys.has(recordKeyOf(record))),
|
|
489
|
+
now,
|
|
490
|
+
timeOf,
|
|
491
|
+
"additional",
|
|
492
|
+
noRecords,
|
|
493
|
+
uniqueRecords([...sentAnswers, ...additionalRecords])
|
|
494
|
+
);
|
|
495
|
+
this.#scheduleDeferred();
|
|
496
|
+
if (!sentAnswers.length && !sentAdditional.length) {
|
|
497
|
+
return Promise.resolve();
|
|
498
|
+
}
|
|
499
|
+
const complete = [...published.values()];
|
|
500
|
+
const answerSection = sentAnswers.length ? sentAnswers : sentAdditional;
|
|
501
|
+
return this.#transmit(
|
|
502
|
+
{
|
|
503
|
+
messageType: DnsMessageType.Response,
|
|
504
|
+
answers: sendable(answerSection, complete, false),
|
|
505
|
+
additionalRecords: sentAnswers.length ? sendable(sentAdditional, complete, false) : []
|
|
506
|
+
},
|
|
507
|
+
void 0,
|
|
508
|
+
answerSection
|
|
509
|
+
).catch((error) => this.#sendFailed(error));
|
|
510
|
+
}
|
|
511
|
+
/** When the RFC 6762 §6 rule stops holding {@link record} back; a goodbye counts as a multicast. */
|
|
512
|
+
#heldUntil(record) {
|
|
513
|
+
return (this.#peerCache.get(recordKeyOf(record))?.lastMulticastAt ?? -Infinity) + MULTICAST_INTERVAL;
|
|
514
|
+
}
|
|
515
|
+
/** Whether a multicast answer that carried {@link record}, not its goodbye, left at or after {@link since}. */
|
|
516
|
+
#isDeliveredSince(record, since) {
|
|
517
|
+
const entry = this.#peerCache.get(recordKeyOf(record));
|
|
518
|
+
return entry !== void 0 && !entry.lastMulticastIsGoodbye && (entry.lastMulticastAt ?? -Infinity) >= since;
|
|
519
|
+
}
|
|
520
|
+
/** Time since the last multicast answer that carried {@link record}, or infinity when peers may not cache it. */
|
|
521
|
+
#sinceCachedMulticast(record, now) {
|
|
522
|
+
const entry = this.#peerCache.get(recordKeyOf(record));
|
|
523
|
+
if (entry === void 0 || entry.lastMulticastAt === void 0 || entry.lastMulticastIsGoodbye || entry.cachedUntil <= now) {
|
|
524
|
+
return Infinity;
|
|
525
|
+
}
|
|
526
|
+
return now - entry.lastMulticastAt;
|
|
527
|
+
}
|
|
528
|
+
#defer(record, section, since, additionalRecords, dueAt) {
|
|
529
|
+
const key = recordKeyOf(record);
|
|
530
|
+
const deferral = this.#deferred.get(key);
|
|
531
|
+
if (deferral === void 0) {
|
|
532
|
+
this.#deferred.set(key, {
|
|
533
|
+
section,
|
|
534
|
+
dueAt,
|
|
535
|
+
since,
|
|
536
|
+
additionalKeys: new Set(additionalRecords.map((additional) => recordKeyOf(additional)))
|
|
537
|
+
});
|
|
538
|
+
} else {
|
|
539
|
+
if (section === "answer") {
|
|
540
|
+
deferral.section = "answer";
|
|
541
|
+
}
|
|
542
|
+
deferral.dueAt = Math.max(deferral.dueAt, dueAt);
|
|
543
|
+
deferral.since = Math.min(deferral.since, since);
|
|
544
|
+
for (const additional of additionalRecords) {
|
|
545
|
+
deferral.additionalKeys.add(recordKeyOf(additional));
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
this.#scheduleDeferred();
|
|
549
|
+
}
|
|
550
|
+
#scheduleDeferred() {
|
|
551
|
+
this.#deferredTimer?.stop();
|
|
552
|
+
this.#deferredTimer = void 0;
|
|
553
|
+
if (!this.#deferred.size) {
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
const dueAt = Math.min(...[...this.#deferred.values()].map(({ dueAt: dueAt2 }) => dueAt2));
|
|
557
|
+
this.#deferredTimer = Time.getTimer(
|
|
558
|
+
"MDNS deferred answer",
|
|
559
|
+
Millis(Math.max(0, dueAt - Time.nowUs)),
|
|
560
|
+
() => this.#gate.run(() => this.#sendDeferred())
|
|
561
|
+
).start();
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Logs a failed send, see {@link #multicastMissed}: peers trigger answers and goodbyes are sent again, so only the
|
|
565
|
+
* first failure of an outage logs a notice. A failed unicast answer logs at debug level and does not start an
|
|
566
|
+
* outage.
|
|
567
|
+
*/
|
|
568
|
+
#sendFailed(error, unicastTarget) {
|
|
569
|
+
if (unicastTarget !== void 0) {
|
|
570
|
+
logger.debug(`Failed to send mDNS response to ${unicastTarget}`, error);
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
this.#multicastMissed(`mDNS messages on interface ${this.name} cannot be sent`, error);
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* Logs a multicast that failed or reached only some address families. Both count as one outage, which only a
|
|
577
|
+
* multicast that reached every family ends, see {@link #transmit}. The first multicast of an outage logs a
|
|
578
|
+
* notice, so a peer that makes the reach change between "some" and failed cannot repeat it. Later ones log at
|
|
579
|
+
* debug level, and so does every one while closing or after the interface left the listing.
|
|
580
|
+
*/
|
|
581
|
+
#multicastMissed(text, error) {
|
|
582
|
+
if (this.#isMulticastOutage || this.#isClosing || !this.#isListed) {
|
|
583
|
+
logger.debug(text, error);
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
this.#isMulticastOutage = true;
|
|
587
|
+
logger.notice(text, error);
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* Send records, always on this interface: without an interface the socket lists interfaces first, an await
|
|
591
|
+
* before the send. Resolves to how far the message reached, see {@link MdnsSocket.send}.
|
|
592
|
+
*
|
|
593
|
+
* | Reach | Records with TTL | Goodbyes |
|
|
594
|
+
* |------------------------------|----------------------|-------------------------------------------------|
|
|
595
|
+
* | every address family | peers may cache them | end the record at once |
|
|
596
|
+
* | some address families | peers may cache them | count as its last multicast, the record stays |
|
|
597
|
+
* | none (no usable family) | change nothing | change nothing |
|
|
598
|
+
* | rejected (error, no address) | change nothing | change nothing |
|
|
599
|
+
*
|
|
600
|
+
* A message that reached some families counts as reaching each of its records, also those in a datagram that
|
|
601
|
+
* failed on every family: a peer may have got any of them. A deferred answer that missed a peer then waits for
|
|
602
|
+
* the querier's retry, which RFC 6762 §6 accepts. A record that stays here gets its goodbye again, see
|
|
603
|
+
* {@link #settleGoodbyes}.
|
|
604
|
+
*
|
|
605
|
+
* A record peers may cache is cached until its TTL after the time the send was called, which is earlier than the
|
|
606
|
+
* wire time by the send latency. Of a multicast, only goodbyes and the records in {@link answered}, the answers to
|
|
607
|
+
* a query, count as the last multicast of their record, see the class description.
|
|
608
|
+
*/
|
|
609
|
+
#transmit(message, unicastTarget, answered = []) {
|
|
610
|
+
const sentAt = Time.nowUs;
|
|
611
|
+
const isMulticast = unicastTarget === void 0;
|
|
612
|
+
const answeredKeys = new Set(answered.map((record) => recordKeyOf(record)));
|
|
613
|
+
return this.#owner.socket.send(message, this.name, unicastTarget).then((reach) => {
|
|
614
|
+
if (reach === void 0 || reach.kind === "none") {
|
|
615
|
+
return reach;
|
|
616
|
+
}
|
|
617
|
+
for (const record of [...message.answers ?? [], ...message.additionalRecords ?? []]) {
|
|
618
|
+
const key = recordKeyOf(record);
|
|
619
|
+
const entry = this.#peerCache.get(key);
|
|
620
|
+
if (record.ttl === 0 && reach.kind === "some") {
|
|
621
|
+
if (entry !== void 0) {
|
|
622
|
+
entry.lastMulticastAt = sentAt;
|
|
623
|
+
entry.lastMulticastIsGoodbye = true;
|
|
624
|
+
}
|
|
625
|
+
continue;
|
|
626
|
+
}
|
|
627
|
+
const isCounted = isMulticast && (record.ttl === 0 || answeredKeys.has(key));
|
|
628
|
+
this.#peerCache.set(key, {
|
|
629
|
+
record,
|
|
630
|
+
cachedUntil: sentAt + record.ttl,
|
|
631
|
+
lastMulticastAt: isCounted ? sentAt : entry?.lastMulticastAt,
|
|
632
|
+
lastMulticastIsGoodbye: isCounted ? record.ttl === 0 : entry?.lastMulticastIsGoodbye
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
if (!isMulticast) {
|
|
636
|
+
if (reach.kind === "some") {
|
|
637
|
+
logger.debug(`Failed to send part of mDNS response to ${unicastTarget}`, reach.failure);
|
|
638
|
+
}
|
|
639
|
+
return reach;
|
|
640
|
+
}
|
|
641
|
+
if (reach.kind === "all") {
|
|
642
|
+
this.#isMulticastOutage = false;
|
|
643
|
+
} else {
|
|
644
|
+
this.#multicastMissed(
|
|
645
|
+
`mDNS messages on interface ${this.name} reach only some address families`,
|
|
646
|
+
reach.failure
|
|
647
|
+
);
|
|
648
|
+
}
|
|
649
|
+
return reach;
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* The records of the current registrations, also keyed by {@link recordKeyOf}; rebuilt when the registrations,
|
|
654
|
+
* details or host name change. A rebuild tells the owner, whose socket names depend on the view, unless
|
|
655
|
+
* {@link notify} is false.
|
|
656
|
+
*/
|
|
657
|
+
#currentView(notify = true) {
|
|
658
|
+
const details = this.#details;
|
|
659
|
+
if (details === void 0) {
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
const { generation, registrations } = this.#owner;
|
|
663
|
+
const hostname = this.#owner.hostnameFor(details);
|
|
664
|
+
const view = this.#view;
|
|
665
|
+
if (view?.generation === generation && view.detailsVersion === this.#detailsVersion && view.hostname === hostname) {
|
|
666
|
+
return view;
|
|
667
|
+
}
|
|
668
|
+
const byService = /* @__PURE__ */ new Map();
|
|
669
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
670
|
+
const setKeys = /* @__PURE__ */ new Set();
|
|
671
|
+
const ownedNames = /* @__PURE__ */ new Set();
|
|
672
|
+
for (const [service, { generator }] of registrations) {
|
|
673
|
+
const records = generator(this.name, details, hostname);
|
|
674
|
+
byService.set(service, records);
|
|
675
|
+
for (const record of records) {
|
|
676
|
+
byKey.set(recordKeyOf(record), record);
|
|
677
|
+
setKeys.add(setKeyOf(record));
|
|
678
|
+
ownedNames.add(record.name.toLowerCase());
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
this.#view = {
|
|
682
|
+
generation,
|
|
683
|
+
detailsVersion: this.#detailsVersion,
|
|
684
|
+
hostname,
|
|
685
|
+
byService,
|
|
686
|
+
byKey,
|
|
687
|
+
setKeys,
|
|
688
|
+
ownedNames
|
|
689
|
+
};
|
|
690
|
+
if (notify) {
|
|
691
|
+
this.#owner.viewChanged();
|
|
692
|
+
}
|
|
693
|
+
return this.#view;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
function noRecords() {
|
|
697
|
+
return new Array();
|
|
698
|
+
}
|
|
699
|
+
function addressSetsOf(records) {
|
|
700
|
+
const sets = /* @__PURE__ */ new Map();
|
|
701
|
+
for (const record of records) {
|
|
702
|
+
if (record.recordType === DnsRecordType.A || record.recordType === DnsRecordType.AAAA) {
|
|
703
|
+
const name = record.name.toLowerCase();
|
|
704
|
+
sets.set(name, [...sets.get(name) ?? [], record]);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
return [...sets.values()];
|
|
708
|
+
}
|
|
709
|
+
function additionalRecordsFor(queries, records, answers) {
|
|
710
|
+
if (queries.every(({ recordType }) => recordType === DnsRecordType.A || recordType === DnsRecordType.AAAA)) {
|
|
711
|
+
return [];
|
|
712
|
+
}
|
|
713
|
+
return records.filter((record) => !answers.includes(record) && record.recordType !== DnsRecordType.PTR);
|
|
714
|
+
}
|
|
715
|
+
function packetDelay() {
|
|
716
|
+
return Millis(20 + Math.floor(Math.random() * 100));
|
|
717
|
+
}
|
|
718
|
+
function queryRecords({ name, recordType }, records) {
|
|
719
|
+
const queryName = name.toLowerCase();
|
|
720
|
+
if (recordType === DnsRecordType.ANY) {
|
|
721
|
+
return records.filter((record) => record.name.toLowerCase() === queryName);
|
|
722
|
+
} else {
|
|
723
|
+
return records.filter((record) => record.name.toLowerCase() === queryName && record.recordType === recordType);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
function sendable(sent, complete, isUnicast) {
|
|
727
|
+
if (isUnicast) {
|
|
728
|
+
return sent.map((record) => record.flushCache ? { ...record, flushCache: false } : record);
|
|
729
|
+
}
|
|
730
|
+
if (!sent.some((record) => record.flushCache)) {
|
|
731
|
+
return sent;
|
|
732
|
+
}
|
|
733
|
+
const sentSizes = setSizes(sent);
|
|
734
|
+
const completeSizes = setSizes(uniqueRecords(complete));
|
|
735
|
+
return sent.map(
|
|
736
|
+
(record) => record.flushCache && (sentSizes.get(setKeyOf(record)) ?? 0) < (completeSizes.get(setKeyOf(record)) ?? 0) ? { ...record, flushCache: false } : record
|
|
737
|
+
);
|
|
738
|
+
}
|
|
739
|
+
function setKeyOf(record) {
|
|
740
|
+
return `${record.recordType}-${record.recordClass}-${record.name.toLowerCase()}`;
|
|
741
|
+
}
|
|
742
|
+
function setSizes(records) {
|
|
743
|
+
const sizes = /* @__PURE__ */ new Map();
|
|
744
|
+
for (const record of records) {
|
|
745
|
+
const key = setKeyOf(record);
|
|
746
|
+
sizes.set(key, (sizes.get(key) ?? 0) + 1);
|
|
747
|
+
}
|
|
748
|
+
return sizes;
|
|
749
|
+
}
|
|
750
|
+
function uniqueRecords(records) {
|
|
751
|
+
const seen = /* @__PURE__ */ new Set();
|
|
752
|
+
return records.filter((record) => {
|
|
753
|
+
const key = recordKeyOf(record);
|
|
754
|
+
if (seen.has(key)) {
|
|
755
|
+
return false;
|
|
756
|
+
}
|
|
757
|
+
seen.add(key);
|
|
758
|
+
return true;
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
const recordKeys = /* @__PURE__ */ new WeakMap();
|
|
762
|
+
function recordKeyOf(record) {
|
|
763
|
+
let key = recordKeys.get(record);
|
|
764
|
+
if (key === void 0) {
|
|
765
|
+
key = Bytes.toHex(
|
|
766
|
+
DnsCodec.encodeRecord({
|
|
767
|
+
...record,
|
|
768
|
+
name: record.name.toLowerCase(),
|
|
769
|
+
value: canonicalValueOf(record),
|
|
770
|
+
ttl: Instant,
|
|
771
|
+
flushCache: false
|
|
772
|
+
})
|
|
773
|
+
);
|
|
774
|
+
recordKeys.set(record, key);
|
|
775
|
+
}
|
|
776
|
+
return key;
|
|
777
|
+
}
|
|
778
|
+
function canonicalValueOf({ recordType, value }) {
|
|
779
|
+
switch (recordType) {
|
|
780
|
+
case DnsRecordType.PTR:
|
|
781
|
+
return typeof value === "string" ? value.toLowerCase() : value;
|
|
782
|
+
case DnsRecordType.SRV:
|
|
783
|
+
return isSrvValue(value) ? { ...value, target: value.target.toLowerCase() } : value;
|
|
784
|
+
default:
|
|
785
|
+
return value;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
function isSrvValue(value) {
|
|
789
|
+
return typeof value === "object" && value !== null && "target" in value && typeof value.target === "string";
|
|
790
|
+
}
|
|
791
|
+
export {
|
|
792
|
+
InterfaceResponder
|
|
793
|
+
};
|
|
794
|
+
//# sourceMappingURL=InterfaceResponder.js.map
|