werift 0.28.0 → 0.29.0
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/README.md +182 -2
- package/lib/common/src/transport.d.ts +39 -5
- package/lib/common/src/transport.js +32 -7
- package/lib/common/src/transport.js.map +1 -1
- package/lib/dtls/src/carrier/direct.d.ts +67 -0
- package/lib/dtls/src/carrier/direct.js +226 -0
- package/lib/dtls/src/carrier/direct.js.map +1 -0
- package/lib/dtls/src/carrier/types.d.ts +81 -0
- package/lib/dtls/src/carrier/types.js +7 -0
- package/lib/dtls/src/carrier/types.js.map +1 -0
- package/lib/dtls/src/cipher/const.d.ts +6 -0
- package/lib/dtls/src/cipher/const.js +13 -2
- package/lib/dtls/src/cipher/const.js.map +1 -1
- package/lib/dtls/src/cipher/prf.js +11 -2
- package/lib/dtls/src/cipher/prf.js.map +1 -1
- package/lib/dtls/src/cipher/tls13/aead.d.ts +41 -0
- package/lib/dtls/src/cipher/tls13/aead.js +128 -0
- package/lib/dtls/src/cipher/tls13/aead.js.map +1 -0
- package/lib/dtls/src/cipher/tls13/hkdf.d.ts +30 -0
- package/lib/dtls/src/cipher/tls13/hkdf.js +76 -0
- package/lib/dtls/src/cipher/tls13/hkdf.js.map +1 -0
- package/lib/dtls/src/cipher/tls13/keySchedule.d.ts +70 -0
- package/lib/dtls/src/cipher/tls13/keySchedule.js +114 -0
- package/lib/dtls/src/cipher/tls13/keySchedule.js.map +1 -0
- package/lib/dtls/src/cipher/tls13/signature.d.ts +30 -0
- package/lib/dtls/src/cipher/tls13/signature.js +149 -0
- package/lib/dtls/src/cipher/tls13/signature.js.map +1 -0
- package/lib/dtls/src/client.d.ts +253 -0
- package/lib/dtls/src/client.js +1257 -16
- package/lib/dtls/src/client.js.map +1 -1
- package/lib/dtls/src/context/dtls.d.ts +45 -0
- package/lib/dtls/src/context/dtls.js +114 -0
- package/lib/dtls/src/context/dtls.js.map +1 -1
- package/lib/dtls/src/context/transport.d.ts +13 -0
- package/lib/dtls/src/context/transport.js +29 -1
- package/lib/dtls/src/context/transport.js.map +1 -1
- package/lib/dtls/src/engine/v1_3/connection-base.d.ts +520 -0
- package/lib/dtls/src/engine/v1_3/connection-base.js +1644 -0
- package/lib/dtls/src/engine/v1_3/connection-base.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/connection.d.ts +181 -0
- package/lib/dtls/src/engine/v1_3/connection.js +680 -0
- package/lib/dtls/src/engine/v1_3/connection.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/early-data-buffer.d.ts +38 -0
- package/lib/dtls/src/engine/v1_3/early-data-buffer.js +166 -0
- package/lib/dtls/src/engine/v1_3/early-data-buffer.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/certificate.d.ts +4 -0
- package/lib/dtls/src/engine/v1_3/flight/certificate.js +62 -0
- package/lib/dtls/src/engine/v1_3/flight/certificate.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight1.d.ts +8 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight1.js +119 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight1.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight4.d.ts +8 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight4.js +251 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight4.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight5.d.ts +5 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight5.js +99 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight5.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/dispatch.d.ts +12 -0
- package/lib/dtls/src/engine/v1_3/flight/dispatch.js +138 -0
- package/lib/dtls/src/engine/v1_3/flight/dispatch.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/extensions.d.ts +13 -0
- package/lib/dtls/src/engine/v1_3/flight/extensions.js +46 -0
- package/lib/dtls/src/engine/v1_3/flight/extensions.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/finished.d.ts +6 -0
- package/lib/dtls/src/engine/v1_3/flight/finished.js +16 -0
- package/lib/dtls/src/engine/v1_3/flight/finished.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/post-hs.d.ts +12 -0
- package/lib/dtls/src/engine/v1_3/flight/post-hs.js +94 -0
- package/lib/dtls/src/engine/v1_3/flight/post-hs.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight2.d.ts +21 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight2.js +227 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight2.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight4.d.ts +6 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight4.js +455 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight4.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight5.d.ts +5 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight5.js +48 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight5.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight-tx.d.ts +119 -0
- package/lib/dtls/src/engine/v1_3/flight-tx.js +782 -0
- package/lib/dtls/src/engine/v1_3/flight-tx.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/host.d.ts +86 -0
- package/lib/dtls/src/engine/v1_3/host.js +11 -0
- package/lib/dtls/src/engine/v1_3/host.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/record-rx.d.ts +77 -0
- package/lib/dtls/src/engine/v1_3/record-rx.js +818 -0
- package/lib/dtls/src/engine/v1_3/record-rx.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/transcript.d.ts +22 -0
- package/lib/dtls/src/engine/v1_3/transcript.js +65 -0
- package/lib/dtls/src/engine/v1_3/transcript.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/types.d.ts +169 -0
- package/lib/dtls/src/engine/v1_3/types.js +113 -0
- package/lib/dtls/src/engine/v1_3/types.js.map +1 -0
- package/lib/dtls/src/flight/client/flight1.d.ts +7 -1
- package/lib/dtls/src/flight/client/flight1.js +9 -3
- package/lib/dtls/src/flight/client/flight1.js.map +1 -1
- package/lib/dtls/src/flight/client/flight3.d.ts +8 -0
- package/lib/dtls/src/flight/client/flight3.js +24 -4
- package/lib/dtls/src/flight/client/flight3.js.map +1 -1
- package/lib/dtls/src/flight/client/flight5.js +13 -1
- package/lib/dtls/src/flight/client/flight5.js.map +1 -1
- package/lib/dtls/src/flight/flight.d.ts +16 -0
- package/lib/dtls/src/flight/flight.js +109 -8
- package/lib/dtls/src/flight/flight.js.map +1 -1
- package/lib/dtls/src/flight/server/commitClientHello.d.ts +35 -0
- package/lib/dtls/src/flight/server/commitClientHello.js +149 -0
- package/lib/dtls/src/flight/server/commitClientHello.js.map +1 -0
- package/lib/dtls/src/flight/server/flight2.d.ts +12 -3
- package/lib/dtls/src/flight/server/flight2.js +29 -105
- package/lib/dtls/src/flight/server/flight2.js.map +1 -1
- package/lib/dtls/src/flight/server/flight4.js +14 -2
- package/lib/dtls/src/flight/server/flight4.js.map +1 -1
- package/lib/dtls/src/flight/server/flight6.js +8 -0
- package/lib/dtls/src/flight/server/flight6.js.map +1 -1
- package/lib/dtls/src/handshake/const.d.ts +10 -0
- package/lib/dtls/src/handshake/const.js +10 -0
- package/lib/dtls/src/handshake/const.js.map +1 -1
- package/lib/dtls/src/handshake/extensions/cookie.d.ts +113 -0
- package/lib/dtls/src/handshake/extensions/cookie.js +326 -0
- package/lib/dtls/src/handshake/extensions/cookie.js.map +1 -0
- package/lib/dtls/src/handshake/extensions/ids.d.ts +7 -0
- package/lib/dtls/src/handshake/extensions/ids.js +11 -0
- package/lib/dtls/src/handshake/extensions/ids.js.map +1 -0
- package/lib/dtls/src/handshake/extensions/keyShare.d.ts +28 -0
- package/lib/dtls/src/handshake/extensions/keyShare.js +156 -0
- package/lib/dtls/src/handshake/extensions/keyShare.js.map +1 -0
- package/lib/dtls/src/handshake/extensions/signatureAlgorithms.d.ts +27 -0
- package/lib/dtls/src/handshake/extensions/signatureAlgorithms.js +67 -0
- package/lib/dtls/src/handshake/extensions/signatureAlgorithms.js.map +1 -0
- package/lib/dtls/src/handshake/extensions/supportedVersions.d.ts +20 -0
- package/lib/dtls/src/handshake/extensions/supportedVersions.js +90 -0
- package/lib/dtls/src/handshake/extensions/supportedVersions.js.map +1 -0
- package/lib/dtls/src/handshake/extensions/unique.d.ts +7 -0
- package/lib/dtls/src/handshake/extensions/unique.js +19 -0
- package/lib/dtls/src/handshake/extensions/unique.js.map +1 -0
- package/lib/dtls/src/handshake/extensions/useSrtp.d.ts +26 -3
- package/lib/dtls/src/handshake/extensions/useSrtp.js +68 -12
- package/lib/dtls/src/handshake/extensions/useSrtp.js.map +1 -1
- package/lib/dtls/src/handshake/message/tls13/ack.d.ts +50 -0
- package/lib/dtls/src/handshake/message/tls13/ack.js +107 -0
- package/lib/dtls/src/handshake/message/tls13/ack.js.map +1 -0
- package/lib/dtls/src/handshake/message/tls13/certificate.d.ts +17 -0
- package/lib/dtls/src/handshake/message/tls13/certificate.js +112 -0
- package/lib/dtls/src/handshake/message/tls13/certificate.js.map +1 -0
- package/lib/dtls/src/handshake/message/tls13/certificateRequest.d.ts +17 -0
- package/lib/dtls/src/handshake/message/tls13/certificateRequest.js +99 -0
- package/lib/dtls/src/handshake/message/tls13/certificateRequest.js.map +1 -0
- package/lib/dtls/src/handshake/message/tls13/certificateVerify.d.ts +21 -0
- package/lib/dtls/src/handshake/message/tls13/certificateVerify.js +77 -0
- package/lib/dtls/src/handshake/message/tls13/certificateVerify.js.map +1 -0
- package/lib/dtls/src/handshake/message/tls13/encryptedExtensions.d.ts +19 -0
- package/lib/dtls/src/handshake/message/tls13/encryptedExtensions.js +56 -0
- package/lib/dtls/src/handshake/message/tls13/encryptedExtensions.js.map +1 -0
- package/lib/dtls/src/handshake/message/tls13/keyUpdate.d.ts +13 -0
- package/lib/dtls/src/handshake/message/tls13/keyUpdate.js +54 -0
- package/lib/dtls/src/handshake/message/tls13/keyUpdate.js.map +1 -0
- package/lib/dtls/src/handshake/message/tls13/newSessionTicket.d.ts +33 -0
- package/lib/dtls/src/handshake/message/tls13/newSessionTicket.js +158 -0
- package/lib/dtls/src/handshake/message/tls13/newSessionTicket.js.map +1 -0
- package/lib/dtls/src/handshake/random.d.ts +14 -0
- package/lib/dtls/src/handshake/random.js +24 -0
- package/lib/dtls/src/handshake/random.js.map +1 -1
- package/lib/dtls/src/handshake/validation.d.ts +26 -0
- package/lib/dtls/src/handshake/validation.js +32 -0
- package/lib/dtls/src/handshake/validation.js.map +1 -0
- package/lib/dtls/src/index.d.ts +6 -1
- package/lib/dtls/src/index.js +116 -44
- package/lib/dtls/src/index.js.map +1 -1
- package/lib/dtls/src/internal.d.ts +7 -0
- package/lib/dtls/src/internal.js +57 -0
- package/lib/dtls/src/internal.js.map +1 -0
- package/lib/dtls/src/peer.d.ts +49 -0
- package/lib/dtls/src/peer.js +54 -0
- package/lib/dtls/src/peer.js.map +1 -0
- package/lib/dtls/src/record/antiReplayWindow.d.ts +33 -0
- package/lib/dtls/src/record/antiReplayWindow.js +119 -0
- package/lib/dtls/src/record/antiReplayWindow.js.map +1 -0
- package/lib/dtls/src/record/const.d.ts +6 -0
- package/lib/dtls/src/record/const.js +6 -0
- package/lib/dtls/src/record/const.js.map +1 -1
- package/lib/dtls/src/record/message/fragment.d.ts +0 -2
- package/lib/dtls/src/record/message/fragment.js +36 -17
- package/lib/dtls/src/record/message/fragment.js.map +1 -1
- package/lib/dtls/src/record/message/reassembler.d.ts +62 -0
- package/lib/dtls/src/record/message/reassembler.js +249 -0
- package/lib/dtls/src/record/message/reassembler.js.map +1 -0
- package/lib/dtls/src/record/receive.js +24 -16
- package/lib/dtls/src/record/receive.js.map +1 -1
- package/lib/dtls/src/record/v1_3/header.d.ts +34 -0
- package/lib/dtls/src/record/v1_3/header.js +95 -0
- package/lib/dtls/src/record/v1_3/header.js.map +1 -0
- package/lib/dtls/src/record/v1_3/record.d.ts +133 -0
- package/lib/dtls/src/record/v1_3/record.js +370 -0
- package/lib/dtls/src/record/v1_3/record.js.map +1 -0
- package/lib/dtls/src/retransmission.d.ts +26 -0
- package/lib/dtls/src/retransmission.js +39 -0
- package/lib/dtls/src/retransmission.js.map +1 -0
- package/lib/dtls/src/server.d.ts +38 -0
- package/lib/dtls/src/server.js +367 -20
- package/lib/dtls/src/server.js.map +1 -1
- package/lib/dtls/src/socket.d.ts +379 -35
- package/lib/dtls/src/socket.js +1105 -132
- package/lib/dtls/src/socket.js.map +1 -1
- package/lib/dtls/src/version.d.ts +89 -0
- package/lib/dtls/src/version.js +204 -0
- package/lib/dtls/src/version.js.map +1 -0
- package/lib/ice/src/consent.d.ts +78 -1
- package/lib/ice/src/consent.js +236 -24
- package/lib/ice/src/consent.js.map +1 -1
- package/lib/ice/src/dns/lookup.d.ts +10 -0
- package/lib/ice/src/dns/lookup.js +130 -3
- package/lib/ice/src/dns/lookup.js.map +1 -1
- package/lib/ice/src/exceptions.d.ts +9 -0
- package/lib/ice/src/exceptions.js +14 -1
- package/lib/ice/src/exceptions.js.map +1 -1
- package/lib/ice/src/failover.d.ts +270 -0
- package/lib/ice/src/failover.js +674 -0
- package/lib/ice/src/failover.js.map +1 -0
- package/lib/ice/src/gatheringError.d.ts +28 -0
- package/lib/ice/src/gatheringError.js +17 -0
- package/lib/ice/src/gatheringError.js.map +1 -0
- package/lib/ice/src/ice.d.ts +265 -9
- package/lib/ice/src/ice.js +1624 -236
- package/lib/ice/src/ice.js.map +1 -1
- package/lib/ice/src/iceBase.d.ts +197 -6
- package/lib/ice/src/iceBase.js +157 -7
- package/lib/ice/src/iceBase.js.map +1 -1
- package/lib/ice/src/index.d.ts +2 -0
- package/lib/ice/src/index.js +4 -1
- package/lib/ice/src/index.js.map +1 -1
- package/lib/ice/src/internal/datagram.d.ts +37 -0
- package/lib/ice/src/internal/datagram.js +45 -0
- package/lib/ice/src/internal/datagram.js.map +1 -0
- package/lib/ice/src/internal/hostInterfaces.d.ts +13 -2
- package/lib/ice/src/internal/hostInterfaces.js +16 -4
- package/lib/ice/src/internal/hostInterfaces.js.map +1 -1
- package/lib/ice/src/internal/sped-bind.d.ts +44 -0
- package/lib/ice/src/internal/sped-bind.js +53 -0
- package/lib/ice/src/internal/sped-bind.js.map +1 -0
- package/lib/ice/src/internal/sped-binding-cache.d.ts +27 -0
- package/lib/ice/src/internal/sped-binding-cache.js +102 -0
- package/lib/ice/src/internal/sped-binding-cache.js.map +1 -0
- package/lib/ice/src/internal/sped.d.ts +15 -0
- package/lib/ice/src/internal/sped.js +62 -0
- package/lib/ice/src/internal/sped.js.map +1 -0
- package/lib/ice/src/nomination/selectionController.d.ts +111 -0
- package/lib/ice/src/nomination/selectionController.js +172 -0
- package/lib/ice/src/nomination/selectionController.js.map +1 -0
- package/lib/ice/src/nomination/selectionReplacement.d.ts +40 -0
- package/lib/ice/src/nomination/selectionReplacement.js +65 -7
- package/lib/ice/src/nomination/selectionReplacement.js.map +1 -1
- package/lib/ice/src/sped/draft00/codec.d.ts +20 -0
- package/lib/ice/src/sped/draft00/codec.js +59 -0
- package/lib/ice/src/sped/draft00/codec.js.map +1 -0
- package/lib/ice/src/sped/draft00/constants.d.ts +14 -0
- package/lib/ice/src/sped/draft00/constants.js +18 -0
- package/lib/ice/src/sped/draft00/constants.js.map +1 -0
- package/lib/ice/src/sped/draft00/index.d.ts +6 -0
- package/lib/ice/src/sped/draft00/index.js +26 -0
- package/lib/ice/src/sped/draft00/index.js.map +1 -0
- package/lib/ice/src/sped/draft00/mtu.d.ts +38 -0
- package/lib/ice/src/sped/draft00/mtu.js +96 -0
- package/lib/ice/src/sped/draft00/mtu.js.map +1 -0
- package/lib/ice/src/sped/draft00/session.d.ts +86 -0
- package/lib/ice/src/sped/draft00/session.js +353 -0
- package/lib/ice/src/sped/draft00/session.js.map +1 -0
- package/lib/ice/src/sped/draft00/types.d.ts +16 -0
- package/lib/ice/src/sped/draft00/types.js +3 -0
- package/lib/ice/src/sped/draft00/types.js.map +1 -0
- package/lib/ice/src/sped/runtime.d.ts +188 -0
- package/lib/ice/src/sped/runtime.js +643 -0
- package/lib/ice/src/sped/runtime.js.map +1 -0
- package/lib/ice/src/stun/protocol.d.ts +29 -0
- package/lib/ice/src/stun/protocol.js +91 -4
- package/lib/ice/src/stun/protocol.js.map +1 -1
- package/lib/ice/src/stun/rawAttributeValue.d.ts +1 -0
- package/lib/ice/src/stun/rawAttributeValue.js +6 -0
- package/lib/ice/src/stun/rawAttributeValue.js.map +1 -0
- package/lib/ice/src/stun/tcpProtocol.d.ts +1 -0
- package/lib/ice/src/stun/tcpProtocol.js +14 -2
- package/lib/ice/src/stun/tcpProtocol.js.map +1 -1
- package/lib/ice/src/stun/transaction.d.ts +4 -0
- package/lib/ice/src/stun/transaction.js +23 -0
- package/lib/ice/src/stun/transaction.js.map +1 -1
- package/lib/ice/src/turn/protocol.d.ts +21 -2
- package/lib/ice/src/turn/protocol.js +93 -8
- package/lib/ice/src/turn/protocol.js.map +1 -1
- package/lib/ice/src/types/model.d.ts +9 -0
- package/lib/ice/src/types/model.js.map +1 -1
- package/lib/ice/src/utils.d.ts +13 -0
- package/lib/ice/src/utils.js +13 -0
- package/lib/ice/src/utils.js.map +1 -1
- package/lib/ice-server/src/stun/message.d.ts +15 -2
- package/lib/ice-server/src/stun/message.js +156 -25
- package/lib/ice-server/src/stun/message.js.map +1 -1
- package/lib/ice-server/src/stun/rawAttributeValue.d.ts +6 -0
- package/lib/ice-server/src/stun/rawAttributeValue.js +12 -0
- package/lib/ice-server/src/stun/rawAttributeValue.js.map +1 -0
- package/lib/index.mjs +19568 -3106
- package/lib/nonstandard/index.mjs +2539 -1175
- package/lib/polyfill/dom.mjs +33210 -16872
- package/lib/polyfill/index.mjs +33345 -17013
- package/lib/rtp/src/extra/processor/fsRetry.d.ts +20 -0
- package/lib/rtp/src/extra/processor/fsRetry.js +73 -0
- package/lib/rtp/src/extra/processor/fsRetry.js.map +1 -0
- package/lib/rtp/src/extra/processor/webm.d.ts +6 -0
- package/lib/rtp/src/extra/processor/webm.js +6 -2
- package/lib/rtp/src/extra/processor/webm.js.map +1 -1
- package/lib/rtp/src/extra/processor/webmCallback.d.ts +11 -0
- package/lib/rtp/src/extra/processor/webmCallback.js +23 -31
- package/lib/rtp/src/extra/processor/webmCallback.js.map +1 -1
- package/lib/rtp/src/extra/processor/webmFileWriter.d.ts +24 -0
- package/lib/rtp/src/extra/processor/webmFileWriter.js +94 -0
- package/lib/rtp/src/extra/processor/webmFileWriter.js.map +1 -0
- package/lib/sctp/src/chunk.d.ts +5 -0
- package/lib/sctp/src/chunk.js +10 -0
- package/lib/sctp/src/chunk.js.map +1 -1
- package/lib/sctp/src/index.d.ts +1 -1
- package/lib/sctp/src/index.js +4 -1
- package/lib/sctp/src/index.js.map +1 -1
- package/lib/sctp/src/sctp.d.ts +81 -5
- package/lib/sctp/src/sctp.js +273 -28
- package/lib/sctp/src/sctp.js.map +1 -1
- package/lib/webrtc/src/api/compatibilityOptions.d.ts +11 -1
- package/lib/webrtc/src/api/compatibilityOptions.js +11 -1
- package/lib/webrtc/src/api/compatibilityOptions.js.map +1 -1
- package/lib/webrtc/src/api/peerConfig.d.ts +210 -13
- package/lib/webrtc/src/api/peerConfig.js +100 -5
- package/lib/webrtc/src/api/peerConfig.js.map +1 -1
- package/lib/webrtc/src/api/peerConnectionEvents.d.ts +10 -1
- package/lib/webrtc/src/api/peerConnectionEvents.js.map +1 -1
- package/lib/webrtc/src/dataChannel.d.ts +122 -10
- package/lib/webrtc/src/dataChannel.js +214 -20
- package/lib/webrtc/src/dataChannel.js.map +1 -1
- package/lib/webrtc/src/media/domEventTarget.d.ts +55 -0
- package/lib/webrtc/src/media/domEventTarget.js +216 -0
- package/lib/webrtc/src/media/domEventTarget.js.map +1 -0
- package/lib/webrtc/src/media/index.d.ts +2 -0
- package/lib/webrtc/src/media/index.js +1 -0
- package/lib/webrtc/src/media/index.js.map +1 -1
- package/lib/webrtc/src/media/parameters.d.ts +5 -0
- package/lib/webrtc/src/media/parameters.js +10 -0
- package/lib/webrtc/src/media/parameters.js.map +1 -1
- package/lib/webrtc/src/media/receiver/receiverTwcc.d.ts +10 -0
- package/lib/webrtc/src/media/receiver/receiverTwcc.js +4 -10
- package/lib/webrtc/src/media/receiver/receiverTwcc.js.map +1 -1
- package/lib/webrtc/src/media/router.d.ts +6 -0
- package/lib/webrtc/src/media/router.js +39 -1
- package/lib/webrtc/src/media/router.js.map +1 -1
- package/lib/webrtc/src/media/rtpReceiver.d.ts +56 -6
- package/lib/webrtc/src/media/rtpReceiver.js +165 -15
- package/lib/webrtc/src/media/rtpReceiver.js.map +1 -1
- package/lib/webrtc/src/media/rtpSender.d.ts +1 -1
- package/lib/webrtc/src/media/rtpSender.js +4 -3
- package/lib/webrtc/src/media/rtpSender.js.map +1 -1
- package/lib/webrtc/src/media/rtpTransceiver.d.ts +29 -11
- package/lib/webrtc/src/media/rtpTransceiver.js +31 -9
- package/lib/webrtc/src/media/rtpTransceiver.js.map +1 -1
- package/lib/webrtc/src/media/stats.d.ts +13 -0
- package/lib/webrtc/src/media/stats.js.map +1 -1
- package/lib/webrtc/src/media/track.d.ts +103 -11
- package/lib/webrtc/src/media/track.js +241 -19
- package/lib/webrtc/src/media/track.js.map +1 -1
- package/lib/webrtc/src/media/trackConstraints.d.ts +80 -0
- package/lib/webrtc/src/media/trackConstraints.js +141 -0
- package/lib/webrtc/src/media/trackConstraints.js.map +1 -0
- package/lib/webrtc/src/negotiation/internalState.d.ts +0 -4
- package/lib/webrtc/src/negotiation/internalState.js +0 -11
- package/lib/webrtc/src/negotiation/internalState.js.map +1 -1
- package/lib/webrtc/src/negotiation/remoteCandidates.d.ts +20 -1
- package/lib/webrtc/src/negotiation/remoteCandidates.js +29 -1
- package/lib/webrtc/src/negotiation/remoteCandidates.js.map +1 -1
- package/lib/webrtc/src/negotiation/transportActivation.d.ts +4 -0
- package/lib/webrtc/src/negotiation/transportActivation.js +112 -11
- package/lib/webrtc/src/negotiation/transportActivation.js.map +1 -1
- package/lib/webrtc/src/negotiationTransaction.d.ts +25 -4
- package/lib/webrtc/src/negotiationTransaction.js +27 -6
- package/lib/webrtc/src/negotiationTransaction.js.map +1 -1
- package/lib/webrtc/src/nonstandard/dummyMedia.d.ts +6 -0
- package/lib/webrtc/src/nonstandard/dummyMedia.js +14 -19
- package/lib/webrtc/src/nonstandard/dummyMedia.js.map +1 -1
- package/lib/webrtc/src/nonstandard/navigator.d.ts +1 -1
- package/lib/webrtc/src/nonstandard/recorder/index.js +5 -1
- package/lib/webrtc/src/nonstandard/recorder/index.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.d.ts +6 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js +31 -2
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js.map +1 -1
- package/lib/webrtc/src/nonstandard/userMedia/packetizer.d.ts +16 -0
- package/lib/webrtc/src/nonstandard/userMedia/packetizer.js +25 -0
- package/lib/webrtc/src/nonstandard/userMedia/packetizer.js.map +1 -1
- package/lib/webrtc/src/nonstandard/userMedia.js +6 -13
- package/lib/webrtc/src/nonstandard/userMedia.js.map +1 -1
- package/lib/webrtc/src/peerConnection.d.ts +44 -8
- package/lib/webrtc/src/peerConnection.js +88 -9
- package/lib/webrtc/src/peerConnection.js.map +1 -1
- package/lib/webrtc/src/polyfill/api.d.ts +2 -1
- package/lib/webrtc/src/polyfill/api.js +3 -3
- package/lib/webrtc/src/polyfill/api.js.map +1 -1
- package/lib/webrtc/src/polyfill/dom.d.ts +21 -7
- package/lib/webrtc/src/polyfill/dom.js +15 -0
- package/lib/webrtc/src/polyfill/dom.js.map +1 -1
- package/lib/webrtc/src/polyfill/globals.d.ts +6 -2
- package/lib/webrtc/src/polyfill/globals.js.map +1 -1
- package/lib/webrtc/src/polyfill/index.d.ts +1 -1
- package/lib/webrtc/src/polyfill/index.js +1 -1
- package/lib/webrtc/src/polyfill/index.js.map +1 -1
- package/lib/webrtc/src/polyfill/install.d.ts +5 -1
- package/lib/webrtc/src/polyfill/install.js +2 -2
- package/lib/webrtc/src/polyfill/install.js.map +1 -1
- package/lib/webrtc/src/polyfill/mediaDevices.js +28 -4
- package/lib/webrtc/src/polyfill/mediaDevices.js.map +1 -1
- package/lib/webrtc/src/polyfill/peerConnectionConfig.d.ts +6 -0
- package/lib/webrtc/src/polyfill/peerConnectionConfig.js +15 -4
- package/lib/webrtc/src/polyfill/peerConnectionConfig.js.map +1 -1
- package/lib/webrtc/src/polyfill/selectSettings.d.ts +4 -14
- package/lib/webrtc/src/polyfill/selectSettings.js +10 -106
- package/lib/webrtc/src/polyfill/selectSettings.js.map +1 -1
- package/lib/webrtc/src/polyfill/sourceIo.d.ts +1 -2
- package/lib/webrtc/src/polyfill/sourceIo.js +6 -6
- package/lib/webrtc/src/polyfill/sourceIo.js.map +1 -1
- package/lib/webrtc/src/sctpManager.d.ts +31 -18
- package/lib/webrtc/src/sctpManager.js +158 -38
- package/lib/webrtc/src/sctpManager.js.map +1 -1
- package/lib/webrtc/src/sdp.d.ts +38 -2
- package/lib/webrtc/src/sdp.js +84 -3
- package/lib/webrtc/src/sdp.js.map +1 -1
- package/lib/webrtc/src/sdpManager.d.ts +19 -9
- package/lib/webrtc/src/sdpManager.js +26 -4
- package/lib/webrtc/src/sdpManager.js.map +1 -1
- package/lib/webrtc/src/secureTransportManager.d.ts +11 -2
- package/lib/webrtc/src/secureTransportManager.js +84 -5
- package/lib/webrtc/src/secureTransportManager.js.map +1 -1
- package/lib/webrtc/src/transceiverManager.d.ts +5 -2
- package/lib/webrtc/src/transceiverManager.js +42 -14
- package/lib/webrtc/src/transceiverManager.js.map +1 -1
- package/lib/webrtc/src/transport/dtls-application-gate.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-application-gate.js +143 -0
- package/lib/webrtc/src/transport/dtls-application-gate.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-attempt.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-attempt.js +79 -0
- package/lib/webrtc/src/transport/dtls-attempt.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-certificate.d.ts +24 -0
- package/lib/webrtc/src/transport/dtls-certificate.js +98 -0
- package/lib/webrtc/src/transport/dtls-certificate.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-fingerprint.d.ts +7 -0
- package/lib/webrtc/src/transport/dtls-fingerprint.js +66 -0
- package/lib/webrtc/src/transport/dtls-fingerprint.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-ice-transport.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-ice-transport.js +123 -0
- package/lib/webrtc/src/transport/dtls-ice-transport.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-media-queue.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-media-queue.js +95 -0
- package/lib/webrtc/src/transport/dtls-media-queue.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-readiness.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-readiness.js +173 -0
- package/lib/webrtc/src/transport/dtls-readiness.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-sped-handshake.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-sped-handshake.js +146 -0
- package/lib/webrtc/src/transport/dtls-sped-handshake.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-srtp.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-srtp.js +133 -0
- package/lib/webrtc/src/transport/dtls-srtp.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-stats.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-stats.js +134 -0
- package/lib/webrtc/src/transport/dtls-stats.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-types.d.ts +23 -0
- package/lib/webrtc/src/transport/dtls-types.js +11 -0
- package/lib/webrtc/src/transport/dtls-types.js.map +1 -0
- package/lib/webrtc/src/transport/dtls.d.ts +150 -55
- package/lib/webrtc/src/transport/dtls.js +1017 -556
- package/lib/webrtc/src/transport/dtls.js.map +1 -1
- package/lib/webrtc/src/transport/ice.d.ts +35 -2
- package/lib/webrtc/src/transport/ice.js +147 -14
- package/lib/webrtc/src/transport/ice.js.map +1 -1
- package/lib/webrtc/src/transport/iceCandidateAttribute.d.ts +4 -2
- package/lib/webrtc/src/transport/iceCandidateAttribute.js.map +1 -1
- package/lib/webrtc/src/transport/sctp.d.ts +126 -2
- package/lib/webrtc/src/transport/sctp.js +747 -134
- package/lib/webrtc/src/transport/sctp.js.map +1 -1
- package/lib/webrtc/src/transport/sped.d.ts +139 -0
- package/lib/webrtc/src/transport/sped.js +757 -0
- package/lib/webrtc/src/transport/sped.js.map +1 -0
- package/lib/webrtc/src/types/util.d.ts +6 -0
- package/lib/webrtc/src/types/util.js.map +1 -1
- package/lib/webrtc/src/utils.d.ts +1 -1
- package/lib/webrtc/src/webidl.d.ts +15 -0
- package/lib/webrtc/src/webidl.js +34 -0
- package/lib/webrtc/src/webidl.js.map +1 -0
- package/package.json +7 -3
- package/lib/webrtc/src/polyfill/rtcSessionDescription.d.ts +0 -18
- package/lib/webrtc/src/polyfill/rtcSessionDescription.js +0 -36
- package/lib/webrtc/src/polyfill/rtcSessionDescription.js.map +0 -1
|
@@ -0,0 +1,1644 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Dtls13ConnectionBase = void 0;
|
|
4
|
+
const crypto_1 = require("crypto");
|
|
5
|
+
const direct_1 = require("../../carrier/direct");
|
|
6
|
+
const const_1 = require("../../cipher/const");
|
|
7
|
+
const namedCurve_1 = require("../../cipher/namedCurve");
|
|
8
|
+
const abstract_1 = require("../../cipher/suites/abstract");
|
|
9
|
+
const keySchedule_1 = require("../../cipher/tls13/keySchedule");
|
|
10
|
+
const signature_1 = require("../../cipher/tls13/signature");
|
|
11
|
+
const cookie_1 = require("../../handshake/extensions/cookie");
|
|
12
|
+
const signatureAlgorithms_1 = require("../../handshake/extensions/signatureAlgorithms");
|
|
13
|
+
const random_1 = require("../../handshake/random");
|
|
14
|
+
const common_1 = require("../../imports/common");
|
|
15
|
+
const record_1 = require("../../record/v1_3/record");
|
|
16
|
+
const version_1 = require("../../version");
|
|
17
|
+
const early_data_buffer_1 = require("./early-data-buffer");
|
|
18
|
+
const transcript_1 = require("./transcript");
|
|
19
|
+
const types_1 = require("./types");
|
|
20
|
+
/**
|
|
21
|
+
* Session state and lifecycle for the DTLS 1.3 endpoint.
|
|
22
|
+
* Dtls13Connection extends this class once; flight/record logic is functions
|
|
23
|
+
* with `this: Dtls13Host` (no further inheritance).
|
|
24
|
+
*/
|
|
25
|
+
class Dtls13ConnectionBase {
|
|
26
|
+
get earlyAppData() {
|
|
27
|
+
return this.earlyAppDataBuffer.packets;
|
|
28
|
+
}
|
|
29
|
+
get earlyAppDataBytes() {
|
|
30
|
+
return this.earlyAppDataBuffer.bytes;
|
|
31
|
+
}
|
|
32
|
+
/** @internal Snapshot of the DTLS-owned pre-connect application queue. */
|
|
33
|
+
get earlyDataStats() {
|
|
34
|
+
return this.earlyAppDataBuffer.snapshot();
|
|
35
|
+
}
|
|
36
|
+
constructor(options, sessionType) {
|
|
37
|
+
Object.defineProperty(this, "onConnect", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
configurable: true,
|
|
40
|
+
writable: true,
|
|
41
|
+
value: new common_1.Event()
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(this, "onData", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
configurable: true,
|
|
46
|
+
writable: true,
|
|
47
|
+
value: new common_1.Event()
|
|
48
|
+
});
|
|
49
|
+
Object.defineProperty(this, "onError", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
configurable: true,
|
|
52
|
+
writable: true,
|
|
53
|
+
value: new common_1.Event()
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(this, "onClose", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
configurable: true,
|
|
58
|
+
writable: true,
|
|
59
|
+
value: new common_1.Event()
|
|
60
|
+
});
|
|
61
|
+
/**
|
|
62
|
+
* Fires once when graceful close begins (local close or peer close_notify),
|
|
63
|
+
* *before* async close_notify / teardown. Association layer uses this to
|
|
64
|
+
* disable Public API synchronously so send() cannot race the notify path.
|
|
65
|
+
*/
|
|
66
|
+
Object.defineProperty(this, "onClosing", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
configurable: true,
|
|
69
|
+
writable: true,
|
|
70
|
+
value: new common_1.Event()
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(this, "onWriteReady", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
configurable: true,
|
|
75
|
+
writable: true,
|
|
76
|
+
value: new common_1.Event()
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(this, "onPeerHandshakeAuthenticated", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
configurable: true,
|
|
81
|
+
writable: true,
|
|
82
|
+
value: new common_1.Event()
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(this, "onHandshakeComplete", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
configurable: true,
|
|
87
|
+
writable: true,
|
|
88
|
+
value: new common_1.Event()
|
|
89
|
+
});
|
|
90
|
+
Object.defineProperty(this, "readiness", {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
configurable: true,
|
|
93
|
+
writable: true,
|
|
94
|
+
value: {
|
|
95
|
+
writeReady: false,
|
|
96
|
+
peerHandshakeAuthenticated: false,
|
|
97
|
+
handshakeComplete: false,
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
Object.defineProperty(this, "connected", {
|
|
101
|
+
enumerable: true,
|
|
102
|
+
configurable: true,
|
|
103
|
+
writable: true,
|
|
104
|
+
value: false
|
|
105
|
+
});
|
|
106
|
+
/**
|
|
107
|
+
* Graceful close in progress (close_notify may still be in flight).
|
|
108
|
+
* Distinct from {@link closed} (full teardown finished).
|
|
109
|
+
*/
|
|
110
|
+
Object.defineProperty(this, "closing", {
|
|
111
|
+
enumerable: true,
|
|
112
|
+
configurable: true,
|
|
113
|
+
writable: true,
|
|
114
|
+
value: false
|
|
115
|
+
});
|
|
116
|
+
Object.defineProperty(this, "role", {
|
|
117
|
+
enumerable: true,
|
|
118
|
+
configurable: true,
|
|
119
|
+
writable: true,
|
|
120
|
+
value: void 0
|
|
121
|
+
});
|
|
122
|
+
/** Handshake carrier (injectable; default DirectHandshakeCarrier). */
|
|
123
|
+
Object.defineProperty(this, "carrier", {
|
|
124
|
+
enumerable: true,
|
|
125
|
+
configurable: true,
|
|
126
|
+
writable: true,
|
|
127
|
+
value: void 0
|
|
128
|
+
});
|
|
129
|
+
Object.defineProperty(this, "keySchedule", {
|
|
130
|
+
enumerable: true,
|
|
131
|
+
configurable: true,
|
|
132
|
+
writable: true,
|
|
133
|
+
value: keySchedule_1.defaultKeySchedule
|
|
134
|
+
});
|
|
135
|
+
Object.defineProperty(this, "certDer", {
|
|
136
|
+
enumerable: true,
|
|
137
|
+
configurable: true,
|
|
138
|
+
writable: true,
|
|
139
|
+
value: void 0
|
|
140
|
+
});
|
|
141
|
+
Object.defineProperty(this, "keyPem", {
|
|
142
|
+
enumerable: true,
|
|
143
|
+
configurable: true,
|
|
144
|
+
writable: true,
|
|
145
|
+
value: void 0
|
|
146
|
+
});
|
|
147
|
+
Object.defineProperty(this, "hasLocalIdentity", {
|
|
148
|
+
enumerable: true,
|
|
149
|
+
configurable: true,
|
|
150
|
+
writable: true,
|
|
151
|
+
value: void 0
|
|
152
|
+
});
|
|
153
|
+
Object.defineProperty(this, "messageSeq", {
|
|
154
|
+
enumerable: true,
|
|
155
|
+
configurable: true,
|
|
156
|
+
writable: true,
|
|
157
|
+
value: 0
|
|
158
|
+
});
|
|
159
|
+
Object.defineProperty(this, "recordSeqEpoch0", {
|
|
160
|
+
enumerable: true,
|
|
161
|
+
configurable: true,
|
|
162
|
+
writable: true,
|
|
163
|
+
value: 0
|
|
164
|
+
});
|
|
165
|
+
Object.defineProperty(this, "transcript", {
|
|
166
|
+
enumerable: true,
|
|
167
|
+
configurable: true,
|
|
168
|
+
writable: true,
|
|
169
|
+
value: new transcript_1.HandshakeTranscript()
|
|
170
|
+
});
|
|
171
|
+
Object.defineProperty(this, "cookie", {
|
|
172
|
+
enumerable: true,
|
|
173
|
+
configurable: true,
|
|
174
|
+
writable: true,
|
|
175
|
+
value: Buffer.alloc(0)
|
|
176
|
+
});
|
|
177
|
+
Object.defineProperty(this, "localKeyPair", {
|
|
178
|
+
enumerable: true,
|
|
179
|
+
configurable: true,
|
|
180
|
+
writable: true,
|
|
181
|
+
value: (0, namedCurve_1.generateKeyPair)(const_1.NamedCurveAlgorithm.x25519_29)
|
|
182
|
+
});
|
|
183
|
+
Object.defineProperty(this, "remoteKeyShare", {
|
|
184
|
+
enumerable: true,
|
|
185
|
+
configurable: true,
|
|
186
|
+
writable: true,
|
|
187
|
+
value: void 0
|
|
188
|
+
});
|
|
189
|
+
Object.defineProperty(this, "selectedGroup", {
|
|
190
|
+
enumerable: true,
|
|
191
|
+
configurable: true,
|
|
192
|
+
writable: true,
|
|
193
|
+
value: const_1.NamedCurveAlgorithm.x25519_29
|
|
194
|
+
});
|
|
195
|
+
Object.defineProperty(this, "clientRandom", {
|
|
196
|
+
enumerable: true,
|
|
197
|
+
configurable: true,
|
|
198
|
+
writable: true,
|
|
199
|
+
value: new random_1.DtlsRandom()
|
|
200
|
+
});
|
|
201
|
+
Object.defineProperty(this, "serverRandom", {
|
|
202
|
+
enumerable: true,
|
|
203
|
+
configurable: true,
|
|
204
|
+
writable: true,
|
|
205
|
+
value: new random_1.DtlsRandom()
|
|
206
|
+
});
|
|
207
|
+
Object.defineProperty(this, "sessionId", {
|
|
208
|
+
enumerable: true,
|
|
209
|
+
configurable: true,
|
|
210
|
+
writable: true,
|
|
211
|
+
value: Buffer.alloc(0)
|
|
212
|
+
});
|
|
213
|
+
/** Epoch protections: 0 plaintext, 2 handshake, 3 app, 4+ KeyUpdate */
|
|
214
|
+
Object.defineProperty(this, "epochs", {
|
|
215
|
+
enumerable: true,
|
|
216
|
+
configurable: true,
|
|
217
|
+
writable: true,
|
|
218
|
+
value: new Map()
|
|
219
|
+
});
|
|
220
|
+
/** When each epoch's keys were installed (for TTL prune). */
|
|
221
|
+
Object.defineProperty(this, "epochInstalledAt", {
|
|
222
|
+
enumerable: true,
|
|
223
|
+
configurable: true,
|
|
224
|
+
writable: true,
|
|
225
|
+
value: new Map()
|
|
226
|
+
});
|
|
227
|
+
Object.defineProperty(this, "readEpoch", {
|
|
228
|
+
enumerable: true,
|
|
229
|
+
configurable: true,
|
|
230
|
+
writable: true,
|
|
231
|
+
value: 0
|
|
232
|
+
});
|
|
233
|
+
Object.defineProperty(this, "writeEpoch", {
|
|
234
|
+
enumerable: true,
|
|
235
|
+
configurable: true,
|
|
236
|
+
writable: true,
|
|
237
|
+
value: 0
|
|
238
|
+
});
|
|
239
|
+
Object.defineProperty(this, "clientHsTraffic", {
|
|
240
|
+
enumerable: true,
|
|
241
|
+
configurable: true,
|
|
242
|
+
writable: true,
|
|
243
|
+
value: void 0
|
|
244
|
+
});
|
|
245
|
+
Object.defineProperty(this, "serverHsTraffic", {
|
|
246
|
+
enumerable: true,
|
|
247
|
+
configurable: true,
|
|
248
|
+
writable: true,
|
|
249
|
+
value: void 0
|
|
250
|
+
});
|
|
251
|
+
Object.defineProperty(this, "clientAppTraffic", {
|
|
252
|
+
enumerable: true,
|
|
253
|
+
configurable: true,
|
|
254
|
+
writable: true,
|
|
255
|
+
value: void 0
|
|
256
|
+
});
|
|
257
|
+
Object.defineProperty(this, "serverAppTraffic", {
|
|
258
|
+
enumerable: true,
|
|
259
|
+
configurable: true,
|
|
260
|
+
writable: true,
|
|
261
|
+
value: void 0
|
|
262
|
+
});
|
|
263
|
+
Object.defineProperty(this, "exporterMasterSecret", {
|
|
264
|
+
enumerable: true,
|
|
265
|
+
configurable: true,
|
|
266
|
+
writable: true,
|
|
267
|
+
value: void 0
|
|
268
|
+
});
|
|
269
|
+
Object.defineProperty(this, "handshakeSecret", {
|
|
270
|
+
enumerable: true,
|
|
271
|
+
configurable: true,
|
|
272
|
+
writable: true,
|
|
273
|
+
value: void 0
|
|
274
|
+
});
|
|
275
|
+
Object.defineProperty(this, "firstClientHelloBody", {
|
|
276
|
+
enumerable: true,
|
|
277
|
+
configurable: true,
|
|
278
|
+
writable: true,
|
|
279
|
+
value: void 0
|
|
280
|
+
});
|
|
281
|
+
Object.defineProperty(this, "awaitingHrr", {
|
|
282
|
+
enumerable: true,
|
|
283
|
+
configurable: true,
|
|
284
|
+
writable: true,
|
|
285
|
+
value: false
|
|
286
|
+
});
|
|
287
|
+
/** Number of HelloRetryRequests processed (client) or sent (server). Max 1. */
|
|
288
|
+
Object.defineProperty(this, "hrrCount", {
|
|
289
|
+
enumerable: true,
|
|
290
|
+
configurable: true,
|
|
291
|
+
writable: true,
|
|
292
|
+
value: 0
|
|
293
|
+
});
|
|
294
|
+
/**
|
|
295
|
+
* Cipher suite selected by HRR (client). Final ServerHello must match.
|
|
296
|
+
* RFC 8446 §4.1.4.
|
|
297
|
+
*/
|
|
298
|
+
Object.defineProperty(this, "hrrCipherSuite", {
|
|
299
|
+
enumerable: true,
|
|
300
|
+
configurable: true,
|
|
301
|
+
writable: true,
|
|
302
|
+
value: void 0
|
|
303
|
+
});
|
|
304
|
+
/**
|
|
305
|
+
* Groups offered in the first ClientHello key_share (client).
|
|
306
|
+
* HRR selected_group must not already appear here (RFC 8446 §4.1.4).
|
|
307
|
+
*/
|
|
308
|
+
Object.defineProperty(this, "initialKeyShareGroups", {
|
|
309
|
+
enumerable: true,
|
|
310
|
+
configurable: true,
|
|
311
|
+
writable: true,
|
|
312
|
+
value: []
|
|
313
|
+
});
|
|
314
|
+
/**
|
|
315
|
+
* Versions listed in ClientHello supported_versions (preference order).
|
|
316
|
+
* Dual-stack association may include V1_2 for true negotiation.
|
|
317
|
+
*/
|
|
318
|
+
Object.defineProperty(this, "offeredProtocolVersions", {
|
|
319
|
+
enumerable: true,
|
|
320
|
+
configurable: true,
|
|
321
|
+
writable: true,
|
|
322
|
+
value: void 0
|
|
323
|
+
});
|
|
324
|
+
/**
|
|
325
|
+
* Peer signature_algorithms from ClientHello (server) or CertificateRequest
|
|
326
|
+
* schemes we will use for client CertificateVerify selection.
|
|
327
|
+
*/
|
|
328
|
+
Object.defineProperty(this, "peerSignatureSchemes", {
|
|
329
|
+
enumerable: true,
|
|
330
|
+
configurable: true,
|
|
331
|
+
writable: true,
|
|
332
|
+
value: [...signatureAlgorithms_1.DEFAULT_SIGNATURE_SCHEMES]
|
|
333
|
+
});
|
|
334
|
+
/** Schemes we advertised in CertificateRequest (server mutual auth). */
|
|
335
|
+
Object.defineProperty(this, "certificateRequestSignatureSchemes", {
|
|
336
|
+
enumerable: true,
|
|
337
|
+
configurable: true,
|
|
338
|
+
writable: true,
|
|
339
|
+
value: [...signatureAlgorithms_1.DEFAULT_SIGNATURE_SCHEMES]
|
|
340
|
+
});
|
|
341
|
+
/** Schemes we advertise in ClientHello / accept for server CertificateVerify. */
|
|
342
|
+
Object.defineProperty(this, "localOfferedSignatureSchemes", {
|
|
343
|
+
enumerable: true,
|
|
344
|
+
configurable: true,
|
|
345
|
+
writable: true,
|
|
346
|
+
value: [...signatureAlgorithms_1.DEFAULT_SIGNATURE_SCHEMES]
|
|
347
|
+
});
|
|
348
|
+
Object.defineProperty(this, "peerFinishedReceived", {
|
|
349
|
+
enumerable: true,
|
|
350
|
+
configurable: true,
|
|
351
|
+
writable: true,
|
|
352
|
+
value: false
|
|
353
|
+
});
|
|
354
|
+
Object.defineProperty(this, "localFinishedSent", {
|
|
355
|
+
enumerable: true,
|
|
356
|
+
configurable: true,
|
|
357
|
+
writable: true,
|
|
358
|
+
value: false
|
|
359
|
+
});
|
|
360
|
+
Object.defineProperty(this, "flightId", {
|
|
361
|
+
enumerable: true,
|
|
362
|
+
configurable: true,
|
|
363
|
+
writable: true,
|
|
364
|
+
value: 0
|
|
365
|
+
});
|
|
366
|
+
Object.defineProperty(this, "pendingFlight", {
|
|
367
|
+
enumerable: true,
|
|
368
|
+
configurable: true,
|
|
369
|
+
writable: true,
|
|
370
|
+
value: []
|
|
371
|
+
});
|
|
372
|
+
/** Record numbers of the current retransmittable flight (for ACK matching). */
|
|
373
|
+
Object.defineProperty(this, "pendingFlightRecords", {
|
|
374
|
+
enumerable: true,
|
|
375
|
+
configurable: true,
|
|
376
|
+
writable: true,
|
|
377
|
+
value: []
|
|
378
|
+
});
|
|
379
|
+
/**
|
|
380
|
+
* Per-datagram record map for selective retransmit after partial ACK.
|
|
381
|
+
* Index aligns with pendingFlight.
|
|
382
|
+
*/
|
|
383
|
+
Object.defineProperty(this, "pendingFlightRecordGroups", {
|
|
384
|
+
enumerable: true,
|
|
385
|
+
configurable: true,
|
|
386
|
+
writable: true,
|
|
387
|
+
value: []
|
|
388
|
+
});
|
|
389
|
+
/**
|
|
390
|
+
* Wire bytes for each pending handshake record (parallel to pendingFlightRecords).
|
|
391
|
+
* Enables selective retransmit of only un-ACK'd records after partial ACK.
|
|
392
|
+
*/
|
|
393
|
+
Object.defineProperty(this, "pendingFlightRecordBytes", {
|
|
394
|
+
enumerable: true,
|
|
395
|
+
configurable: true,
|
|
396
|
+
writable: true,
|
|
397
|
+
value: []
|
|
398
|
+
});
|
|
399
|
+
/**
|
|
400
|
+
* ServerHello (epoch 0) retransmitted with the encrypted server flight until
|
|
401
|
+
* the flight is fully ACK'd (SH loss otherwise leaves client without keys).
|
|
402
|
+
*/
|
|
403
|
+
Object.defineProperty(this, "pendingServerHello", {
|
|
404
|
+
enumerable: true,
|
|
405
|
+
configurable: true,
|
|
406
|
+
writable: true,
|
|
407
|
+
value: void 0
|
|
408
|
+
});
|
|
409
|
+
/**
|
|
410
|
+
* Pre-chunk ServerHello handshake (epoch 0). SPED MTU shrink re-fragments
|
|
411
|
+
* this independently of pendingFlightSource (epoch 2 encrypted flight).
|
|
412
|
+
*/
|
|
413
|
+
Object.defineProperty(this, "pendingServerHelloSource", {
|
|
414
|
+
enumerable: true,
|
|
415
|
+
configurable: true,
|
|
416
|
+
writable: true,
|
|
417
|
+
value: void 0
|
|
418
|
+
});
|
|
419
|
+
/**
|
|
420
|
+
* Last epoch-0 ServerHello datagrams built for an MTU shrink. Reused when
|
|
421
|
+
* re-fragment is asked again at the same (or larger) MTU so L1 bytes stay
|
|
422
|
+
* stable after the first shrink.
|
|
423
|
+
*/
|
|
424
|
+
Object.defineProperty(this, "pendingServerHelloNotify", {
|
|
425
|
+
enumerable: true,
|
|
426
|
+
configurable: true,
|
|
427
|
+
writable: true,
|
|
428
|
+
value: void 0
|
|
429
|
+
});
|
|
430
|
+
Object.defineProperty(this, "cancelRetransmit", {
|
|
431
|
+
enumerable: true,
|
|
432
|
+
configurable: true,
|
|
433
|
+
writable: true,
|
|
434
|
+
value: void 0
|
|
435
|
+
});
|
|
436
|
+
Object.defineProperty(this, "cancelEpochPrune", {
|
|
437
|
+
enumerable: true,
|
|
438
|
+
configurable: true,
|
|
439
|
+
writable: true,
|
|
440
|
+
value: void 0
|
|
441
|
+
});
|
|
442
|
+
Object.defineProperty(this, "retransmitCount", {
|
|
443
|
+
enumerable: true,
|
|
444
|
+
configurable: true,
|
|
445
|
+
writable: true,
|
|
446
|
+
value: 0
|
|
447
|
+
});
|
|
448
|
+
/** Association-lifetime count; unlike retransmitCount this never resets. */
|
|
449
|
+
Object.defineProperty(this, "totalRetransmitCount", {
|
|
450
|
+
enumerable: true,
|
|
451
|
+
configurable: true,
|
|
452
|
+
writable: true,
|
|
453
|
+
value: 0
|
|
454
|
+
});
|
|
455
|
+
Object.defineProperty(this, "maxRetransmit", {
|
|
456
|
+
enumerable: true,
|
|
457
|
+
configurable: true,
|
|
458
|
+
writable: true,
|
|
459
|
+
value: 10
|
|
460
|
+
});
|
|
461
|
+
Object.defineProperty(this, "closed", {
|
|
462
|
+
enumerable: true,
|
|
463
|
+
configurable: true,
|
|
464
|
+
writable: true,
|
|
465
|
+
value: false
|
|
466
|
+
});
|
|
467
|
+
/**
|
|
468
|
+
* Dual-stack HVR probe: engine stays open with CH-A retransmit while the
|
|
469
|
+
* association also runs the DTLS 1.2 cookie candidate. Not a hard fail.
|
|
470
|
+
*/
|
|
471
|
+
Object.defineProperty(this, "dualProbeParked", {
|
|
472
|
+
enumerable: true,
|
|
473
|
+
configurable: true,
|
|
474
|
+
writable: true,
|
|
475
|
+
value: false
|
|
476
|
+
});
|
|
477
|
+
Object.defineProperty(this, "remoteCert", {
|
|
478
|
+
enumerable: true,
|
|
479
|
+
configurable: true,
|
|
480
|
+
writable: true,
|
|
481
|
+
value: void 0
|
|
482
|
+
});
|
|
483
|
+
Object.defineProperty(this, "serverFlightComplete", {
|
|
484
|
+
enumerable: true,
|
|
485
|
+
configurable: true,
|
|
486
|
+
writable: true,
|
|
487
|
+
value: false
|
|
488
|
+
});
|
|
489
|
+
Object.defineProperty(this, "clientExpectsServerFlight", {
|
|
490
|
+
enumerable: true,
|
|
491
|
+
configurable: true,
|
|
492
|
+
writable: true,
|
|
493
|
+
value: false
|
|
494
|
+
});
|
|
495
|
+
Object.defineProperty(this, "negotiatedSrtpProfile", {
|
|
496
|
+
enumerable: true,
|
|
497
|
+
configurable: true,
|
|
498
|
+
writable: true,
|
|
499
|
+
value: void 0
|
|
500
|
+
});
|
|
501
|
+
/**
|
|
502
|
+
* Named Groups (RFC 8446 §4.2.7 Supported Groups; DTLS 1.3 inherits via RFC 9147).
|
|
503
|
+
* Each value identifies a finite-field or elliptic-curve group used for (EC)DHE
|
|
504
|
+
* key exchange. Preference order drives ClientHello key_share offers and the
|
|
505
|
+
* server's HRR selected_group when the client's share is unacceptable.
|
|
506
|
+
*/
|
|
507
|
+
Object.defineProperty(this, "groups", {
|
|
508
|
+
enumerable: true,
|
|
509
|
+
configurable: true,
|
|
510
|
+
writable: true,
|
|
511
|
+
value: void 0
|
|
512
|
+
});
|
|
513
|
+
Object.defineProperty(this, "fragmentBuffer", {
|
|
514
|
+
enumerable: true,
|
|
515
|
+
configurable: true,
|
|
516
|
+
writable: true,
|
|
517
|
+
value: new Map()
|
|
518
|
+
});
|
|
519
|
+
Object.defineProperty(this, "fragmentBufferBytes", {
|
|
520
|
+
enumerable: true,
|
|
521
|
+
configurable: true,
|
|
522
|
+
writable: true,
|
|
523
|
+
value: 0
|
|
524
|
+
});
|
|
525
|
+
/** Out-of-order complete handshake messages (by message_seq), with record epoch. */
|
|
526
|
+
Object.defineProperty(this, "handshakeInbox", {
|
|
527
|
+
enumerable: true,
|
|
528
|
+
configurable: true,
|
|
529
|
+
writable: true,
|
|
530
|
+
value: new Map()
|
|
531
|
+
});
|
|
532
|
+
Object.defineProperty(this, "nextReceiveSeq", {
|
|
533
|
+
enumerable: true,
|
|
534
|
+
configurable: true,
|
|
535
|
+
writable: true,
|
|
536
|
+
value: 0
|
|
537
|
+
});
|
|
538
|
+
/**
|
|
539
|
+
* Handshake records of the *current remote inbound flight* awaiting ACK
|
|
540
|
+
* (RFC 9147 §7: ACK lists only the current outstanding remote flight).
|
|
541
|
+
*/
|
|
542
|
+
Object.defineProperty(this, "receivedRecordNumbers", {
|
|
543
|
+
enumerable: true,
|
|
544
|
+
configurable: true,
|
|
545
|
+
writable: true,
|
|
546
|
+
value: []
|
|
547
|
+
});
|
|
548
|
+
/**
|
|
549
|
+
* Accepted inbound handshake records not yet covered by an ACK that was
|
|
550
|
+
* actually sent ("epoch:seq"). Unlike receivedRecordNumbers, an ACK whose
|
|
551
|
+
* send is in flight or failed keeps its records here, so completion is
|
|
552
|
+
* never inferred from an empty ACK queue alone.
|
|
553
|
+
*/
|
|
554
|
+
Object.defineProperty(this, "unackedHandshakeRecords", {
|
|
555
|
+
enumerable: true,
|
|
556
|
+
configurable: true,
|
|
557
|
+
writable: true,
|
|
558
|
+
value: new Set()
|
|
559
|
+
});
|
|
560
|
+
/**
|
|
561
|
+
* After we send a local flight, the next successfully accepted peer handshake
|
|
562
|
+
* record starts a new remote flight — clear the previous ACK list then.
|
|
563
|
+
*/
|
|
564
|
+
Object.defineProperty(this, "clearRemoteAckOnNextInbound", {
|
|
565
|
+
enumerable: true,
|
|
566
|
+
configurable: true,
|
|
567
|
+
writable: true,
|
|
568
|
+
value: false
|
|
569
|
+
});
|
|
570
|
+
/**
|
|
571
|
+
* Set by handlers (e.g. onFinished / onKeyUpdate) so the RX layer sends ACK
|
|
572
|
+
* only after the current record has been noted for ACK bookkeeping.
|
|
573
|
+
*/
|
|
574
|
+
Object.defineProperty(this, "ackAfterCurrentRecord", {
|
|
575
|
+
enumerable: true,
|
|
576
|
+
configurable: true,
|
|
577
|
+
writable: true,
|
|
578
|
+
value: false
|
|
579
|
+
});
|
|
580
|
+
/**
|
|
581
|
+
* When peer KeyUpdate has request_update, send our KeyUpdate only after we
|
|
582
|
+
* have ACKed theirs (response KeyUpdate is not an implicit ACK — RFC 9147 §8).
|
|
583
|
+
*/
|
|
584
|
+
Object.defineProperty(this, "keyUpdateResponseAfterAck", {
|
|
585
|
+
enumerable: true,
|
|
586
|
+
configurable: true,
|
|
587
|
+
writable: true,
|
|
588
|
+
value: false
|
|
589
|
+
});
|
|
590
|
+
/**
|
|
591
|
+
* Peer requested update while our own KeyUpdate is still awaiting ACK.
|
|
592
|
+
* Send response KeyUpdate only after applyPendingKeyUpdateWrite() (RFC 9147 §8:
|
|
593
|
+
* no concurrent un-ACKed KeyUpdates; TLS 1.3 crossed update_requested case).
|
|
594
|
+
*/
|
|
595
|
+
Object.defineProperty(this, "deferredKeyUpdateResponse", {
|
|
596
|
+
enumerable: true,
|
|
597
|
+
configurable: true,
|
|
598
|
+
writable: true,
|
|
599
|
+
value: false
|
|
600
|
+
});
|
|
601
|
+
/**
|
|
602
|
+
* Handshake records that were successfully accepted (processed or buffered).
|
|
603
|
+
* Replay path re-ACKs only records present here — anti-replay alone does not
|
|
604
|
+
* imply the peer may treat the record as acknowledged.
|
|
605
|
+
*/
|
|
606
|
+
Object.defineProperty(this, "acceptedHandshakeRecords", {
|
|
607
|
+
enumerable: true,
|
|
608
|
+
configurable: true,
|
|
609
|
+
writable: true,
|
|
610
|
+
value: new Set()
|
|
611
|
+
});
|
|
612
|
+
/**
|
|
613
|
+
* After sending KeyUpdate, hold next write epoch until peer ACK (RFC 9147 §8).
|
|
614
|
+
* Application data continues on the old writeEpoch until this is applied.
|
|
615
|
+
*/
|
|
616
|
+
Object.defineProperty(this, "pendingKeyUpdateWrite", {
|
|
617
|
+
enumerable: true,
|
|
618
|
+
configurable: true,
|
|
619
|
+
writable: true,
|
|
620
|
+
value: void 0
|
|
621
|
+
});
|
|
622
|
+
Object.defineProperty(this, "cookieSecret", {
|
|
623
|
+
enumerable: true,
|
|
624
|
+
configurable: true,
|
|
625
|
+
writable: true,
|
|
626
|
+
value: (0, crypto_1.randomBytes)(16)
|
|
627
|
+
});
|
|
628
|
+
Object.defineProperty(this, "tlsCookie", {
|
|
629
|
+
enumerable: true,
|
|
630
|
+
configurable: true,
|
|
631
|
+
writable: true,
|
|
632
|
+
value: Buffer.alloc(0)
|
|
633
|
+
});
|
|
634
|
+
Object.defineProperty(this, "addressValidated", {
|
|
635
|
+
enumerable: true,
|
|
636
|
+
configurable: true,
|
|
637
|
+
writable: true,
|
|
638
|
+
value: false
|
|
639
|
+
});
|
|
640
|
+
Object.defineProperty(this, "bytesReceived", {
|
|
641
|
+
enumerable: true,
|
|
642
|
+
configurable: true,
|
|
643
|
+
writable: true,
|
|
644
|
+
value: 0
|
|
645
|
+
});
|
|
646
|
+
Object.defineProperty(this, "bytesSent", {
|
|
647
|
+
enumerable: true,
|
|
648
|
+
configurable: true,
|
|
649
|
+
writable: true,
|
|
650
|
+
value: 0
|
|
651
|
+
});
|
|
652
|
+
/**
|
|
653
|
+
* Pre-cookie anti-amplification budget owner (peerKey).
|
|
654
|
+
* Unassociated RX resets the global counters for *this* source only — TX
|
|
655
|
+
* charged against that budget must target the same peer (never retransmit
|
|
656
|
+
* A's HRR using B's inflated RX).
|
|
657
|
+
*/
|
|
658
|
+
Object.defineProperty(this, "antiAmpBudgetPeerKey", {
|
|
659
|
+
enumerable: true,
|
|
660
|
+
configurable: true,
|
|
661
|
+
writable: true,
|
|
662
|
+
value: void 0
|
|
663
|
+
});
|
|
664
|
+
/** Current peer key (ip:port) for cookie binding / address validation. */
|
|
665
|
+
Object.defineProperty(this, "peerKey", {
|
|
666
|
+
enumerable: true,
|
|
667
|
+
configurable: true,
|
|
668
|
+
writable: true,
|
|
669
|
+
value: "unknown"
|
|
670
|
+
});
|
|
671
|
+
/**
|
|
672
|
+
* After address validation / connect, only this peer may deliver datagrams
|
|
673
|
+
* and all TX is directed here (Epic 1: no CID migration).
|
|
674
|
+
*/
|
|
675
|
+
Object.defineProperty(this, "pinnedPeerKey", {
|
|
676
|
+
enumerable: true,
|
|
677
|
+
configurable: true,
|
|
678
|
+
writable: true,
|
|
679
|
+
value: void 0
|
|
680
|
+
});
|
|
681
|
+
/**
|
|
682
|
+
* First *associated* remote 5-tuple (pre-cookie provisional, or post-cookie pin).
|
|
683
|
+
* Server with dtls-cookie: NOT set on the first cookie-less ClientHello —
|
|
684
|
+
* only after cookie verification (return-routability). Until then HRR replies
|
|
685
|
+
* use currentPeerAddr and an unauthenticated source cannot lock the association.
|
|
686
|
+
* Client: set/pinned at connect() to the configured destination.
|
|
687
|
+
*/
|
|
688
|
+
Object.defineProperty(this, "provisionalPeerKey", {
|
|
689
|
+
enumerable: true,
|
|
690
|
+
configurable: true,
|
|
691
|
+
writable: true,
|
|
692
|
+
value: void 0
|
|
693
|
+
});
|
|
694
|
+
/**
|
|
695
|
+
* Source of the datagram currently being processed (temporary).
|
|
696
|
+
* Used for cookie binding / reply TX before provisional promotion.
|
|
697
|
+
*/
|
|
698
|
+
Object.defineProperty(this, "currentPeerKey", {
|
|
699
|
+
enumerable: true,
|
|
700
|
+
configurable: true,
|
|
701
|
+
writable: true,
|
|
702
|
+
value: void 0
|
|
703
|
+
});
|
|
704
|
+
Object.defineProperty(this, "currentPeerAddr", {
|
|
705
|
+
enumerable: true,
|
|
706
|
+
configurable: true,
|
|
707
|
+
writable: true,
|
|
708
|
+
value: void 0
|
|
709
|
+
});
|
|
710
|
+
Object.defineProperty(this, "currentDatagramBytes", {
|
|
711
|
+
enumerable: true,
|
|
712
|
+
configurable: true,
|
|
713
|
+
writable: true,
|
|
714
|
+
value: 0
|
|
715
|
+
});
|
|
716
|
+
Object.defineProperty(this, "currentDatagramCounted", {
|
|
717
|
+
enumerable: true,
|
|
718
|
+
configurable: true,
|
|
719
|
+
writable: true,
|
|
720
|
+
value: false
|
|
721
|
+
});
|
|
722
|
+
/**
|
|
723
|
+
* Where to retransmit the pending flight when peer is not yet pinned
|
|
724
|
+
* (e.g. server HRR with cookie before address validation).
|
|
725
|
+
*/
|
|
726
|
+
Object.defineProperty(this, "pendingFlightReplyTo", {
|
|
727
|
+
enumerable: true,
|
|
728
|
+
configurable: true,
|
|
729
|
+
writable: true,
|
|
730
|
+
value: void 0
|
|
731
|
+
});
|
|
732
|
+
/** Explicit send address for transport.send (never rely on last rinfo). */
|
|
733
|
+
Object.defineProperty(this, "peerAddr", {
|
|
734
|
+
enumerable: true,
|
|
735
|
+
configurable: true,
|
|
736
|
+
writable: true,
|
|
737
|
+
value: void 0
|
|
738
|
+
});
|
|
739
|
+
/**
|
|
740
|
+
* Handshake message-order state machine (RFC 8446 full handshake order).
|
|
741
|
+
* Unexpected HandshakeType → unexpected_message.
|
|
742
|
+
*/
|
|
743
|
+
Object.defineProperty(this, "hsPhase", {
|
|
744
|
+
enumerable: true,
|
|
745
|
+
configurable: true,
|
|
746
|
+
writable: true,
|
|
747
|
+
value: "start"
|
|
748
|
+
});
|
|
749
|
+
/** ClientHello-offered use_srtp MKI (for RFC 5764 response check). */
|
|
750
|
+
Object.defineProperty(this, "clientOfferedSrtpMki", {
|
|
751
|
+
enumerable: true,
|
|
752
|
+
configurable: true,
|
|
753
|
+
writable: true,
|
|
754
|
+
value: Buffer.alloc(0)
|
|
755
|
+
});
|
|
756
|
+
/** Hash of first ClientHello used when minting the cookie. */
|
|
757
|
+
Object.defineProperty(this, "cookieClientHelloHash", {
|
|
758
|
+
enumerable: true,
|
|
759
|
+
configurable: true,
|
|
760
|
+
writable: true,
|
|
761
|
+
value: void 0
|
|
762
|
+
});
|
|
763
|
+
/**
|
|
764
|
+
* Per-source pre-cookie HRR attempts (CH1 body for optional field checks).
|
|
765
|
+
* Cookie itself is stateless (embeds CH1 message_hash); this map is an
|
|
766
|
+
* optimization and must never be a single global slot shared by all peers.
|
|
767
|
+
*/
|
|
768
|
+
Object.defineProperty(this, "preCookieAttempts", {
|
|
769
|
+
enumerable: true,
|
|
770
|
+
configurable: true,
|
|
771
|
+
writable: true,
|
|
772
|
+
value: new Map()
|
|
773
|
+
});
|
|
774
|
+
/**
|
|
775
|
+
* HRR deltas that ClientHello2 may apply (RFC 8446 §4.1.4).
|
|
776
|
+
* Set when processing / sending HelloRetryRequest.
|
|
777
|
+
*/
|
|
778
|
+
Object.defineProperty(this, "hrrHadCookie", {
|
|
779
|
+
enumerable: true,
|
|
780
|
+
configurable: true,
|
|
781
|
+
writable: true,
|
|
782
|
+
value: false
|
|
783
|
+
});
|
|
784
|
+
Object.defineProperty(this, "hrrSelectedGroup", {
|
|
785
|
+
enumerable: true,
|
|
786
|
+
configurable: true,
|
|
787
|
+
writable: true,
|
|
788
|
+
value: void 0
|
|
789
|
+
});
|
|
790
|
+
/** Extension types offered in the (last accepted) ClientHello — for EE allowlist. */
|
|
791
|
+
Object.defineProperty(this, "clientOfferedExtensionTypes", {
|
|
792
|
+
enumerable: true,
|
|
793
|
+
configurable: true,
|
|
794
|
+
writable: true,
|
|
795
|
+
value: new Set()
|
|
796
|
+
});
|
|
797
|
+
Object.defineProperty(this, "addressValidation", {
|
|
798
|
+
enumerable: true,
|
|
799
|
+
configurable: true,
|
|
800
|
+
writable: true,
|
|
801
|
+
value: void 0
|
|
802
|
+
});
|
|
803
|
+
/**
|
|
804
|
+
* Association peer-identity policy (datagram-address vs authenticated-single-peer).
|
|
805
|
+
* Resolved once at construction from options / transport hints.
|
|
806
|
+
*/
|
|
807
|
+
Object.defineProperty(this, "peerIdentityMode", {
|
|
808
|
+
enumerable: true,
|
|
809
|
+
configurable: true,
|
|
810
|
+
writable: true,
|
|
811
|
+
value: void 0
|
|
812
|
+
});
|
|
813
|
+
Object.defineProperty(this, "certificateRequestContext", {
|
|
814
|
+
enumerable: true,
|
|
815
|
+
configurable: true,
|
|
816
|
+
writable: true,
|
|
817
|
+
value: Buffer.alloc(0)
|
|
818
|
+
});
|
|
819
|
+
Object.defineProperty(this, "expectClientCertificate", {
|
|
820
|
+
enumerable: true,
|
|
821
|
+
configurable: true,
|
|
822
|
+
writable: true,
|
|
823
|
+
value: false
|
|
824
|
+
});
|
|
825
|
+
Object.defineProperty(this, "clientCertificateReceived", {
|
|
826
|
+
enumerable: true,
|
|
827
|
+
configurable: true,
|
|
828
|
+
writable: true,
|
|
829
|
+
value: false
|
|
830
|
+
});
|
|
831
|
+
Object.defineProperty(this, "clientCertificateVerified", {
|
|
832
|
+
enumerable: true,
|
|
833
|
+
configurable: true,
|
|
834
|
+
writable: true,
|
|
835
|
+
value: false
|
|
836
|
+
});
|
|
837
|
+
Object.defineProperty(this, "peerRequestedClientCert", {
|
|
838
|
+
enumerable: true,
|
|
839
|
+
configurable: true,
|
|
840
|
+
writable: true,
|
|
841
|
+
value: false
|
|
842
|
+
});
|
|
843
|
+
/**
|
|
844
|
+
* After CertificateRequest: whether we will present a local certificate
|
|
845
|
+
* (false → empty Certificate decline when schemes/key do not match).
|
|
846
|
+
*/
|
|
847
|
+
Object.defineProperty(this, "presentClientCertificate", {
|
|
848
|
+
enumerable: true,
|
|
849
|
+
configurable: true,
|
|
850
|
+
writable: true,
|
|
851
|
+
value: false
|
|
852
|
+
});
|
|
853
|
+
/**
|
|
854
|
+
* Epoch-3 app data received before markConnected (UDP reorder window).
|
|
855
|
+
* Bounded by {@link maxEarlyAppDataRecords} / {@link maxEarlyAppDataBytes}.
|
|
856
|
+
*/
|
|
857
|
+
Object.defineProperty(this, "earlyAppDataBuffer", {
|
|
858
|
+
enumerable: true,
|
|
859
|
+
configurable: true,
|
|
860
|
+
writable: true,
|
|
861
|
+
value: void 0
|
|
862
|
+
});
|
|
863
|
+
/** Resolved early-app-data record cap (Options or DataChannel default). */
|
|
864
|
+
Object.defineProperty(this, "maxEarlyAppDataRecords", {
|
|
865
|
+
enumerable: true,
|
|
866
|
+
configurable: true,
|
|
867
|
+
writable: true,
|
|
868
|
+
value: void 0
|
|
869
|
+
});
|
|
870
|
+
/** Resolved early-app-data byte cap (Options or DataChannel default). */
|
|
871
|
+
Object.defineProperty(this, "maxEarlyAppDataBytes", {
|
|
872
|
+
enumerable: true,
|
|
873
|
+
configurable: true,
|
|
874
|
+
writable: true,
|
|
875
|
+
value: void 0
|
|
876
|
+
});
|
|
877
|
+
/**
|
|
878
|
+
* Peer close_notify boundary (RFC 9147: ignore app data with larger epoch/seq).
|
|
879
|
+
* Not mere receive-order — UDP may reorder.
|
|
880
|
+
*/
|
|
881
|
+
Object.defineProperty(this, "peerCloseBoundary", {
|
|
882
|
+
enumerable: true,
|
|
883
|
+
configurable: true,
|
|
884
|
+
writable: true,
|
|
885
|
+
value: void 0
|
|
886
|
+
});
|
|
887
|
+
/** We have sent close_notify (or fatal alert) on the write path. */
|
|
888
|
+
Object.defineProperty(this, "localCloseNotifySent", {
|
|
889
|
+
enumerable: true,
|
|
890
|
+
configurable: true,
|
|
891
|
+
writable: true,
|
|
892
|
+
value: false
|
|
893
|
+
});
|
|
894
|
+
/**
|
|
895
|
+
* Source fragments for pending retransmittable flight (pre-chunk) so
|
|
896
|
+
* retransmit can re-fragment under a smaller MTU.
|
|
897
|
+
*/
|
|
898
|
+
Object.defineProperty(this, "pendingFlightSource", {
|
|
899
|
+
enumerable: true,
|
|
900
|
+
configurable: true,
|
|
901
|
+
writable: true,
|
|
902
|
+
value: void 0
|
|
903
|
+
});
|
|
904
|
+
/** Serialize datagram handling to avoid races on keys / message_seq inbox. */
|
|
905
|
+
Object.defineProperty(this, "rxChain", {
|
|
906
|
+
enumerable: true,
|
|
907
|
+
configurable: true,
|
|
908
|
+
writable: true,
|
|
909
|
+
value: Promise.resolve()
|
|
910
|
+
});
|
|
911
|
+
/**
|
|
912
|
+
* Opaque carrier generation provider (e.g. ICE generation, set by the
|
|
913
|
+
* WebRTC layer). When set, `handleDatagram` drops queued datagrams whose
|
|
914
|
+
* accept-time `rxGeneration` no longer matches at queue-execution time,
|
|
915
|
+
* closing the ICE-restart RX race. Unset = no check (generic engine use).
|
|
916
|
+
*/
|
|
917
|
+
Object.defineProperty(this, "expectedRxGeneration", {
|
|
918
|
+
enumerable: true,
|
|
919
|
+
configurable: true,
|
|
920
|
+
writable: true,
|
|
921
|
+
value: void 0
|
|
922
|
+
});
|
|
923
|
+
Object.defineProperty(this, "options", {
|
|
924
|
+
enumerable: true,
|
|
925
|
+
configurable: true,
|
|
926
|
+
writable: true,
|
|
927
|
+
value: void 0
|
|
928
|
+
});
|
|
929
|
+
this.options = options;
|
|
930
|
+
this.role = sessionType === abstract_1.SessionType.CLIENT ? "client" : "server";
|
|
931
|
+
if (this.role === "server") {
|
|
932
|
+
if (!options.cert || !options.key) {
|
|
933
|
+
throw new Error("DTLS 1.3 server requires cert and key options");
|
|
934
|
+
}
|
|
935
|
+
const parsed = (0, signature_1.parseCertAndKey)(options.cert, options.key);
|
|
936
|
+
this.certDer = parsed.certDer;
|
|
937
|
+
this.keyPem = parsed.keyPem;
|
|
938
|
+
this.hasLocalIdentity = true;
|
|
939
|
+
}
|
|
940
|
+
else if (options.cert && options.key) {
|
|
941
|
+
const parsed = (0, signature_1.parseCertAndKey)(options.cert, options.key);
|
|
942
|
+
this.certDer = parsed.certDer;
|
|
943
|
+
this.keyPem = parsed.keyPem;
|
|
944
|
+
this.hasLocalIdentity = true;
|
|
945
|
+
}
|
|
946
|
+
else {
|
|
947
|
+
// Server-auth-only client: no local certificate until CertificateRequest
|
|
948
|
+
this.certDer = Buffer.alloc(0);
|
|
949
|
+
this.keyPem = "";
|
|
950
|
+
this.hasLocalIdentity = false;
|
|
951
|
+
}
|
|
952
|
+
this.groups = options.groups ?? [
|
|
953
|
+
const_1.NamedCurveAlgorithm.x25519_29,
|
|
954
|
+
const_1.NamedCurveAlgorithm.secp256r1_23,
|
|
955
|
+
];
|
|
956
|
+
this.localKeyPair = (0, namedCurve_1.generateKeyPair)(this.groups[0]);
|
|
957
|
+
this.selectedGroup = this.groups[0];
|
|
958
|
+
this.offeredProtocolVersions = (0, version_1.normalizeProtocolVersions)(options.offeredProtocolVersions ?? [version_1.DtlsVersion.V1_3]);
|
|
959
|
+
// Client key_share initially offers the preferred local group only
|
|
960
|
+
this.initialKeyShareGroups = [this.selectedGroup];
|
|
961
|
+
this.addressValidation = options.addressValidation ?? "dtls-cookie";
|
|
962
|
+
// ICE-authenticated / none: address already trusted for amplification purposes
|
|
963
|
+
this.addressValidated =
|
|
964
|
+
this.addressValidation === "none" ||
|
|
965
|
+
this.addressValidation === "ice-authenticated";
|
|
966
|
+
const peerIdentityMode = (0, types_1.resolvePeerIdentityMode)({
|
|
967
|
+
peerIdentityMode: options.peerIdentityMode,
|
|
968
|
+
addressValidation: this.addressValidation,
|
|
969
|
+
transport: options.transport,
|
|
970
|
+
});
|
|
971
|
+
// "unpinned" is DTLS 1.2 only: a DTLS 1.3 association always pins.
|
|
972
|
+
this.peerIdentityMode =
|
|
973
|
+
peerIdentityMode === "unpinned" ? "datagram-address" : peerIdentityMode;
|
|
974
|
+
this.maxEarlyAppDataRecords = (0, types_1.resolveMaxEarlyAppDataRecords)(options.maxEarlyAppDataRecords);
|
|
975
|
+
this.maxEarlyAppDataBytes = (0, types_1.resolveMaxEarlyAppDataBytes)(options.maxEarlyAppDataBytes);
|
|
976
|
+
this.earlyAppDataBuffer = new early_data_buffer_1.EarlyDataBuffer(this.maxEarlyAppDataRecords, this.maxEarlyAppDataBytes, types_1.EARLY_DATA_LIMITS.retentionMs);
|
|
977
|
+
this.hsPhase =
|
|
978
|
+
this.role === "client" ? "wait_server_hello" : "wait_client_hello";
|
|
979
|
+
this.installEpoch(0, (0, record_1.createEpochProtection)(0));
|
|
980
|
+
// Injectable carrier for SPED / tests; default wraps transport directly
|
|
981
|
+
this.carrier =
|
|
982
|
+
options.carrier ??
|
|
983
|
+
new direct_1.DirectHandshakeCarrier(options.transport, {
|
|
984
|
+
mtu: options.mtu,
|
|
985
|
+
});
|
|
986
|
+
// Inject may carry peer from dual-engine reinject; fall back to transport.rinfo
|
|
987
|
+
const self = this;
|
|
988
|
+
this.carrier.setInjectHandler((bytes, peer, opts) => self.handleDatagram(bytes, peer, opts?.rxGeneration));
|
|
989
|
+
options.transport.onData = (data, addr, meta) => self.handleDatagram(data, addr, meta?.rxGeneration);
|
|
990
|
+
// external → internal: resume retransmission timer for pending flight
|
|
991
|
+
this.carrier.events.onRetransmissionModeChange = (mode) => {
|
|
992
|
+
if (mode === "external") {
|
|
993
|
+
this.cancelRetransmit?.();
|
|
994
|
+
this.cancelRetransmit = undefined;
|
|
995
|
+
}
|
|
996
|
+
else if (mode === "internal" &&
|
|
997
|
+
this.pendingFlight.length > 0 &&
|
|
998
|
+
!this.closed) {
|
|
999
|
+
self.scheduleRetransmit();
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
// Timer-driven epoch TTL prune so idle connections still drop old keys
|
|
1003
|
+
this.scheduleEpochPrune();
|
|
1004
|
+
}
|
|
1005
|
+
/**
|
|
1006
|
+
* Periodic prune so idle connections expire old epoch keys without new traffic.
|
|
1007
|
+
* Uses a dedicated timer (not carrier.schedule) so handshake-complete
|
|
1008
|
+
* cancelAllTimers() does not stop TTL expiry after connect.
|
|
1009
|
+
*/
|
|
1010
|
+
scheduleEpochPrune() {
|
|
1011
|
+
this.cancelEpochPrune?.();
|
|
1012
|
+
if (this.closed)
|
|
1013
|
+
return;
|
|
1014
|
+
const id = setInterval(() => {
|
|
1015
|
+
if (this.closed) {
|
|
1016
|
+
clearInterval(id);
|
|
1017
|
+
return;
|
|
1018
|
+
}
|
|
1019
|
+
this.pruneStaleEpochs();
|
|
1020
|
+
}, types_1.EPOCH_PRUNE_INTERVAL_MS);
|
|
1021
|
+
// Unref so tests / process exit are not blocked by the idle prune timer
|
|
1022
|
+
if (typeof id.unref === "function") {
|
|
1023
|
+
id.unref();
|
|
1024
|
+
}
|
|
1025
|
+
this.cancelEpochPrune = () => {
|
|
1026
|
+
clearInterval(id);
|
|
1027
|
+
this.cancelEpochPrune = undefined;
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
installEpoch(epoch, ep) {
|
|
1031
|
+
this.epochs.set(epoch, ep);
|
|
1032
|
+
this.epochInstalledAt.set(epoch, Date.now());
|
|
1033
|
+
this.pruneStaleEpochs();
|
|
1034
|
+
}
|
|
1035
|
+
handshakeRecordKey(epoch, sequenceNumber) {
|
|
1036
|
+
return `${epoch}:${sequenceNumber}`;
|
|
1037
|
+
}
|
|
1038
|
+
/** Remember a successfully accepted handshake record for future re-ACK on replay. */
|
|
1039
|
+
markHandshakeRecordAccepted(epoch, sequenceNumber) {
|
|
1040
|
+
const key = this.handshakeRecordKey(epoch, sequenceNumber);
|
|
1041
|
+
this.acceptedHandshakeRecords.add(key);
|
|
1042
|
+
// Bound memory: drop oldest-ish by re-creating from recent received list
|
|
1043
|
+
if (this.acceptedHandshakeRecords.size > types_1.MAX_ACCEPTED_HS_RECORDS) {
|
|
1044
|
+
const keys = [...this.acceptedHandshakeRecords];
|
|
1045
|
+
this.acceptedHandshakeRecords = new Set(keys.slice(-types_1.MAX_ACCEPTED_HS_RECORDS));
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
wasHandshakeRecordAccepted(epoch, sequenceNumber) {
|
|
1049
|
+
return this.acceptedHandshakeRecords.has(this.handshakeRecordKey(epoch, sequenceNumber));
|
|
1050
|
+
}
|
|
1051
|
+
zeroizeTrafficKeys(keys) {
|
|
1052
|
+
if (!keys)
|
|
1053
|
+
return;
|
|
1054
|
+
keys.key.fill(0);
|
|
1055
|
+
keys.iv.fill(0);
|
|
1056
|
+
keys.snKey.fill(0);
|
|
1057
|
+
}
|
|
1058
|
+
/**
|
|
1059
|
+
* Drop expired / excess epochs. Active read/write are never dropped.
|
|
1060
|
+
* Handshake epochs 0/2 and initial app epoch 3 are retained until connected
|
|
1061
|
+
* (or still active); after that they follow TTL like KeyUpdate epochs.
|
|
1062
|
+
*/
|
|
1063
|
+
pruneStaleEpochs() {
|
|
1064
|
+
const now = Date.now();
|
|
1065
|
+
const active = new Set([this.readEpoch, this.writeEpoch]);
|
|
1066
|
+
if (this.pendingKeyUpdateWrite) {
|
|
1067
|
+
active.add(this.pendingKeyUpdateWrite.nextWriteEpoch);
|
|
1068
|
+
}
|
|
1069
|
+
if (!this.connected) {
|
|
1070
|
+
active.add(0);
|
|
1071
|
+
active.add(2);
|
|
1072
|
+
active.add(3);
|
|
1073
|
+
}
|
|
1074
|
+
for (const [e, installedAt] of [...this.epochInstalledAt.entries()]) {
|
|
1075
|
+
if (active.has(e))
|
|
1076
|
+
continue;
|
|
1077
|
+
if (now - installedAt <= types_1.EPOCH_KEY_TTL_MS)
|
|
1078
|
+
continue;
|
|
1079
|
+
this.dropEpoch(e);
|
|
1080
|
+
}
|
|
1081
|
+
// Cap retained non-active app/handshake epochs (includes stale epoch 3)
|
|
1082
|
+
const idle = [...this.epochs.keys()]
|
|
1083
|
+
.filter((e) => !active.has(e))
|
|
1084
|
+
.sort((a, b) => (this.epochInstalledAt.get(a) ?? 0) -
|
|
1085
|
+
(this.epochInstalledAt.get(b) ?? 0));
|
|
1086
|
+
while (idle.length > types_1.MAX_RETAINED_APP_EPOCHS) {
|
|
1087
|
+
const e = idle.shift();
|
|
1088
|
+
this.dropEpoch(e);
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
dropEpoch(e) {
|
|
1092
|
+
const ep = this.epochs.get(e);
|
|
1093
|
+
if (ep) {
|
|
1094
|
+
this.zeroizeTrafficKeys(ep.readKeys);
|
|
1095
|
+
this.zeroizeTrafficKeys(ep.writeKeys);
|
|
1096
|
+
ep.readKeys = undefined;
|
|
1097
|
+
ep.writeKeys = undefined;
|
|
1098
|
+
}
|
|
1099
|
+
this.epochs.delete(e);
|
|
1100
|
+
this.epochInstalledAt.delete(e);
|
|
1101
|
+
}
|
|
1102
|
+
/**
|
|
1103
|
+
* Last UDP peer from transport (UdpTransport.rinfo), used when inject/onData
|
|
1104
|
+
* omits the address so cookie binding still sees a stable peerKey.
|
|
1105
|
+
*/
|
|
1106
|
+
peerFromTransport() {
|
|
1107
|
+
const t = this.options.transport;
|
|
1108
|
+
const r = t.rinfo;
|
|
1109
|
+
if (r?.address != null && r?.port != null) {
|
|
1110
|
+
return [r.address, r.port];
|
|
1111
|
+
}
|
|
1112
|
+
return r;
|
|
1113
|
+
}
|
|
1114
|
+
addrToTuple(addr) {
|
|
1115
|
+
if (!addr)
|
|
1116
|
+
return undefined;
|
|
1117
|
+
if (typeof addr === "string") {
|
|
1118
|
+
const i = addr.lastIndexOf(":");
|
|
1119
|
+
if (i <= 0)
|
|
1120
|
+
return undefined;
|
|
1121
|
+
const port = Number(addr.slice(i + 1));
|
|
1122
|
+
if (!Number.isFinite(port))
|
|
1123
|
+
return undefined;
|
|
1124
|
+
return [addr.slice(0, i), port];
|
|
1125
|
+
}
|
|
1126
|
+
if (Array.isArray(addr))
|
|
1127
|
+
return [addr[0], addr[1]];
|
|
1128
|
+
if (addr.address != null && addr.port != null) {
|
|
1129
|
+
return [addr.address, addr.port];
|
|
1130
|
+
}
|
|
1131
|
+
return undefined;
|
|
1132
|
+
}
|
|
1133
|
+
/**
|
|
1134
|
+
* Bind association to the first *accepted* remote 5-tuple (provisional until pin).
|
|
1135
|
+
* Subsequent different sources are dropped (Epic 1: no CID / migration).
|
|
1136
|
+
*/
|
|
1137
|
+
lockProvisionalPeer(key, addr) {
|
|
1138
|
+
if (!key || key === "unknown")
|
|
1139
|
+
return;
|
|
1140
|
+
if (this.provisionalPeerKey || this.pinnedPeerKey)
|
|
1141
|
+
return;
|
|
1142
|
+
this.provisionalPeerKey = key;
|
|
1143
|
+
this.peerKey = key;
|
|
1144
|
+
if (addr)
|
|
1145
|
+
this.peerAddr = addr;
|
|
1146
|
+
}
|
|
1147
|
+
/**
|
|
1148
|
+
* Promote the temporary source of the current datagram to the association peer.
|
|
1149
|
+
* Server dtls-cookie: call only after cookie verification (or when address is
|
|
1150
|
+
* already trusted via ice/none) — never on the first cookie-less ClientHello.
|
|
1151
|
+
* Client: destination is pinned at connect(); this only accounts anti-amp RX.
|
|
1152
|
+
*/
|
|
1153
|
+
acceptAssociationPeer() {
|
|
1154
|
+
const key = this.currentPeerKey && this.currentPeerKey !== "unknown"
|
|
1155
|
+
? this.currentPeerKey
|
|
1156
|
+
: this.peerKey;
|
|
1157
|
+
const addr = this.currentPeerAddr ?? this.peerAddr;
|
|
1158
|
+
if (!key || key === "unknown") {
|
|
1159
|
+
this.accountCurrentDatagramForAntiAmp();
|
|
1160
|
+
return;
|
|
1161
|
+
}
|
|
1162
|
+
// Already pinned (e.g. client connect destination): do not rebind to a
|
|
1163
|
+
// different source — demux already drops non-expected peers.
|
|
1164
|
+
if (this.pinnedPeerKey && this.pinnedPeerKey !== key) {
|
|
1165
|
+
return;
|
|
1166
|
+
}
|
|
1167
|
+
this.lockProvisionalPeer(key, addr);
|
|
1168
|
+
// ICE / none: address already trusted — pin on first accepted association
|
|
1169
|
+
if (this.addressValidated && !this.pinnedPeerKey) {
|
|
1170
|
+
this.pinPeer(key, addr);
|
|
1171
|
+
}
|
|
1172
|
+
this.accountCurrentDatagramForAntiAmp();
|
|
1173
|
+
}
|
|
1174
|
+
/**
|
|
1175
|
+
* Count the current datagram toward the anti-amplification budget.
|
|
1176
|
+
* Unassociated (no provisional/pin): treat this datagram as a fresh
|
|
1177
|
+
* unauthenticated exchange — reset counters so attacker B cannot lock
|
|
1178
|
+
* budget, and each CH reply is budgeted only against that CH.
|
|
1179
|
+
* The budget owner peerKey is recorded so TX/retransmit cannot charge
|
|
1180
|
+
* another source's RX against a different destination.
|
|
1181
|
+
*/
|
|
1182
|
+
accountCurrentDatagramForAntiAmp() {
|
|
1183
|
+
if (this.currentDatagramCounted)
|
|
1184
|
+
return;
|
|
1185
|
+
if (this.currentDatagramBytes <= 0)
|
|
1186
|
+
return;
|
|
1187
|
+
if (!this.provisionalPeerKey && !this.pinnedPeerKey) {
|
|
1188
|
+
this.bytesReceived = this.currentDatagramBytes;
|
|
1189
|
+
this.bytesSent = 0;
|
|
1190
|
+
this.antiAmpBudgetPeerKey =
|
|
1191
|
+
this.currentPeerKey && this.currentPeerKey !== "unknown"
|
|
1192
|
+
? this.currentPeerKey
|
|
1193
|
+
: undefined;
|
|
1194
|
+
this.currentDatagramCounted = true;
|
|
1195
|
+
return;
|
|
1196
|
+
}
|
|
1197
|
+
this.bytesReceived += this.currentDatagramBytes;
|
|
1198
|
+
this.currentDatagramCounted = true;
|
|
1199
|
+
}
|
|
1200
|
+
/**
|
|
1201
|
+
* Server with dtls-cookie before address validation: unauthenticated epoch-0
|
|
1202
|
+
* semantic errors must not fail()/close the whole association (spoofed-source
|
|
1203
|
+
* DoS). ICE/none keep prompt failure.
|
|
1204
|
+
*/
|
|
1205
|
+
isPreCookieUnvalidatedServer() {
|
|
1206
|
+
return (this.role === "server" &&
|
|
1207
|
+
this.addressValidation === "dtls-cookie" &&
|
|
1208
|
+
!this.addressValidated);
|
|
1209
|
+
}
|
|
1210
|
+
/**
|
|
1211
|
+
* Pre-cookie: outbound bytes may only use budget owned by the destination.
|
|
1212
|
+
* Prevents "TX to A, budget from B" after a second source overwrites counters.
|
|
1213
|
+
*/
|
|
1214
|
+
antiAmpAllowsSendTo(dest) {
|
|
1215
|
+
if (this.role !== "server" ||
|
|
1216
|
+
this.addressValidated ||
|
|
1217
|
+
this.addressValidation !== "dtls-cookie") {
|
|
1218
|
+
return true;
|
|
1219
|
+
}
|
|
1220
|
+
if (!this.antiAmpBudgetPeerKey) {
|
|
1221
|
+
// No owner yet (or unknown source) — deny amplification-sensitive TX
|
|
1222
|
+
return false;
|
|
1223
|
+
}
|
|
1224
|
+
const destKey = (0, cookie_1.peerKeyFromAddr)(dest);
|
|
1225
|
+
if (!destKey || destKey === "unknown")
|
|
1226
|
+
return false;
|
|
1227
|
+
return destKey === this.antiAmpBudgetPeerKey;
|
|
1228
|
+
}
|
|
1229
|
+
prunePreCookieAttempts(now = Date.now()) {
|
|
1230
|
+
for (const [k, v] of this.preCookieAttempts) {
|
|
1231
|
+
if (now - v.createdAt > types_1.PRE_COOKIE_ATTEMPT_TTL_MS) {
|
|
1232
|
+
this.preCookieAttempts.delete(k);
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
while (this.preCookieAttempts.size > types_1.MAX_PRE_COOKIE_ATTEMPTS) {
|
|
1236
|
+
// Drop oldest
|
|
1237
|
+
let oldestKey;
|
|
1238
|
+
let oldestAt = Number.POSITIVE_INFINITY;
|
|
1239
|
+
for (const [k, v] of this.preCookieAttempts) {
|
|
1240
|
+
if (v.createdAt < oldestAt) {
|
|
1241
|
+
oldestAt = v.createdAt;
|
|
1242
|
+
oldestKey = k;
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
if (oldestKey)
|
|
1246
|
+
this.preCookieAttempts.delete(oldestKey);
|
|
1247
|
+
else
|
|
1248
|
+
break;
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
storePreCookieAttempt(peerKey, attempt) {
|
|
1252
|
+
if (!peerKey || peerKey === "unknown")
|
|
1253
|
+
return;
|
|
1254
|
+
this.prunePreCookieAttempts();
|
|
1255
|
+
this.preCookieAttempts.set(peerKey, {
|
|
1256
|
+
ch1Body: Buffer.from(attempt.ch1Body),
|
|
1257
|
+
ch1MessageHash: Buffer.from(attempt.ch1MessageHash),
|
|
1258
|
+
selectedGroup: attempt.selectedGroup,
|
|
1259
|
+
createdAt: Date.now(),
|
|
1260
|
+
});
|
|
1261
|
+
this.prunePreCookieAttempts();
|
|
1262
|
+
}
|
|
1263
|
+
getPreCookieAttempt(peerKey) {
|
|
1264
|
+
this.prunePreCookieAttempts();
|
|
1265
|
+
return this.preCookieAttempts.get(peerKey);
|
|
1266
|
+
}
|
|
1267
|
+
clearPreCookieAttempts() {
|
|
1268
|
+
this.preCookieAttempts.clear();
|
|
1269
|
+
}
|
|
1270
|
+
/** Pin association to a single remote 5-tuple (no migration in Epic 1). */
|
|
1271
|
+
/**
|
|
1272
|
+
* Whether inbound source may deliver for this association.
|
|
1273
|
+
*
|
|
1274
|
+
* - No expected peer yet: allow (pre-pin / listening)
|
|
1275
|
+
* - authenticated-single-peer: always allow (transport is identity; 5-tuple
|
|
1276
|
+
* is not an auth boundary — addressless and wrong-addr spoof of the
|
|
1277
|
+
* transport path still share the single authenticated peer)
|
|
1278
|
+
* - datagram-address: require matching peer key; addressless after pin drops
|
|
1279
|
+
*/
|
|
1280
|
+
allowsAssociationPeer(peerKey) {
|
|
1281
|
+
const expected = this.expectedPeerKey();
|
|
1282
|
+
if (!expected)
|
|
1283
|
+
return true;
|
|
1284
|
+
if (this.peerIdentityMode === "authenticated-single-peer")
|
|
1285
|
+
return true;
|
|
1286
|
+
if (!peerKey || peerKey === "unknown")
|
|
1287
|
+
return false;
|
|
1288
|
+
return peerKey === expected;
|
|
1289
|
+
}
|
|
1290
|
+
/**
|
|
1291
|
+
* Lifecycle peer-auth (epoch-0 alerts / version errors), distinct from
|
|
1292
|
+
* 5-tuple TX pin. ICE / authenticated-single-peer is associated even when
|
|
1293
|
+
* the transport never exposes an address (WebRTC IceTransport).
|
|
1294
|
+
*/
|
|
1295
|
+
hasAssociationPeerAuth() {
|
|
1296
|
+
return (0, types_1.associationHasPeerAuth)({
|
|
1297
|
+
hasPinnedPeer: !!this.expectedPeerKey(),
|
|
1298
|
+
identityMode: this.peerIdentityMode,
|
|
1299
|
+
});
|
|
1300
|
+
}
|
|
1301
|
+
pinPeer(key, addr) {
|
|
1302
|
+
if (!key || key === "unknown")
|
|
1303
|
+
return;
|
|
1304
|
+
this.pinnedPeerKey = key;
|
|
1305
|
+
this.provisionalPeerKey = key;
|
|
1306
|
+
this.peerKey = key;
|
|
1307
|
+
if (addr)
|
|
1308
|
+
this.peerAddr = addr;
|
|
1309
|
+
this.pendingFlightReplyTo = undefined;
|
|
1310
|
+
}
|
|
1311
|
+
/** Expected peer key for inbound demux (pinned preferred, else provisional). */
|
|
1312
|
+
expectedPeerKey() {
|
|
1313
|
+
return this.pinnedPeerKey ?? this.provisionalPeerKey;
|
|
1314
|
+
}
|
|
1315
|
+
/**
|
|
1316
|
+
* Peer key for cookie binding during the current datagram (before or after promote).
|
|
1317
|
+
*/
|
|
1318
|
+
associationPeerKey() {
|
|
1319
|
+
return (this.pinnedPeerKey ??
|
|
1320
|
+
this.provisionalPeerKey ??
|
|
1321
|
+
(this.currentPeerKey && this.currentPeerKey !== "unknown"
|
|
1322
|
+
? this.currentPeerKey
|
|
1323
|
+
: this.peerKey));
|
|
1324
|
+
}
|
|
1325
|
+
/** Address for all outbound datagrams — never depend on last UDP rinfo alone. */
|
|
1326
|
+
getSendAddr() {
|
|
1327
|
+
// Prefer pinned/provisional peerAddr; pending HRR reply-to; current source
|
|
1328
|
+
return this.peerAddr ?? this.pendingFlightReplyTo ?? this.currentPeerAddr;
|
|
1329
|
+
}
|
|
1330
|
+
clearPendingFlight() {
|
|
1331
|
+
this.cancelRetransmit?.();
|
|
1332
|
+
this.cancelRetransmit = undefined;
|
|
1333
|
+
this.pendingFlight = [];
|
|
1334
|
+
this.pendingFlightRecords = [];
|
|
1335
|
+
this.pendingFlightRecordGroups = [];
|
|
1336
|
+
this.pendingFlightRecordBytes = [];
|
|
1337
|
+
this.pendingFlightSource = undefined;
|
|
1338
|
+
this.pendingServerHello = undefined;
|
|
1339
|
+
this.pendingServerHelloSource = undefined;
|
|
1340
|
+
this.pendingServerHelloNotify = undefined;
|
|
1341
|
+
this.pendingFlightReplyTo = undefined;
|
|
1342
|
+
this.retransmitCount = 0;
|
|
1343
|
+
}
|
|
1344
|
+
/**
|
|
1345
|
+
* Tear down the association: pending flights, timers, carrier, optional UDP.
|
|
1346
|
+
* Used by local close() and peer close_notify so public lifecycle stays consistent
|
|
1347
|
+
* (connected=false, onClose fires).
|
|
1348
|
+
*/
|
|
1349
|
+
/**
|
|
1350
|
+
* Enter graceful-close terminal for Public API: connected=false, closing=true,
|
|
1351
|
+
* onClosing once. Immediately cancels retransmission / epoch prune / carrier
|
|
1352
|
+
* timers so a stalled close_notify send cannot hold association resources.
|
|
1353
|
+
* Does not fire onClose or close the carrier (that is teardownAssociation).
|
|
1354
|
+
*/
|
|
1355
|
+
beginGracefulClose() {
|
|
1356
|
+
if (this.closed || this.closing) {
|
|
1357
|
+
this.connected = false;
|
|
1358
|
+
// Idempotent: still ensure work is stopped if re-entered mid-teardown.
|
|
1359
|
+
this.clearPendingFlight();
|
|
1360
|
+
this.cancelEpochPrune?.();
|
|
1361
|
+
this.cancelEpochPrune = undefined;
|
|
1362
|
+
this.carrier.cancelAllTimers();
|
|
1363
|
+
return;
|
|
1364
|
+
}
|
|
1365
|
+
this.closing = true;
|
|
1366
|
+
this.connected = false;
|
|
1367
|
+
// Stop HS/KeyUpdate RTO and TTL prune before any async close_notify.
|
|
1368
|
+
this.clearPendingFlight();
|
|
1369
|
+
this.cancelEpochPrune?.();
|
|
1370
|
+
this.cancelEpochPrune = undefined;
|
|
1371
|
+
this.carrier.cancelAllTimers();
|
|
1372
|
+
this.onClosing.execute();
|
|
1373
|
+
}
|
|
1374
|
+
/** True after full teardown, or while close_notify/teardown is in flight. */
|
|
1375
|
+
isClosed() {
|
|
1376
|
+
return this.closed || this.closing;
|
|
1377
|
+
}
|
|
1378
|
+
teardownAssociation(opts) {
|
|
1379
|
+
if (this.closed)
|
|
1380
|
+
return;
|
|
1381
|
+
// Ensure onClosing ran even if teardown is called without beginGracefulClose.
|
|
1382
|
+
this.beginGracefulClose();
|
|
1383
|
+
this.closed = true;
|
|
1384
|
+
this.connected = false;
|
|
1385
|
+
this.clearPendingFlight();
|
|
1386
|
+
this.clearEarlyAppData();
|
|
1387
|
+
this.cancelEpochPrune?.();
|
|
1388
|
+
this.cancelEpochPrune = undefined;
|
|
1389
|
+
this.carrier.cancelAllTimers();
|
|
1390
|
+
this.carrier.close();
|
|
1391
|
+
if (opts?.closeTransport !== false) {
|
|
1392
|
+
void this.options.transport.close().catch(() => { });
|
|
1393
|
+
}
|
|
1394
|
+
this.onClose.execute();
|
|
1395
|
+
}
|
|
1396
|
+
/**
|
|
1397
|
+
* Peer close_notify half-close entry (overridden in Dtls13Connection to reply
|
|
1398
|
+
* with close_notify before teardown).
|
|
1399
|
+
*/
|
|
1400
|
+
onPeerCloseNotify(epoch, sequenceNumber) {
|
|
1401
|
+
this.peerCloseBoundary = { epoch, sequenceNumber };
|
|
1402
|
+
this.clearPendingFlight();
|
|
1403
|
+
if (this.closed)
|
|
1404
|
+
return;
|
|
1405
|
+
// Sync terminal (onClosing) before any further work.
|
|
1406
|
+
this.beginGracefulClose();
|
|
1407
|
+
if (!this.closed) {
|
|
1408
|
+
this.teardownAssociation();
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
/** Drop pending remote-flight ACK record numbers. */
|
|
1412
|
+
clearAckAccumulator() {
|
|
1413
|
+
this.receivedRecordNumbers = [];
|
|
1414
|
+
this.unackedHandshakeRecords.clear();
|
|
1415
|
+
}
|
|
1416
|
+
applyPendingKeyUpdateWrite() {
|
|
1417
|
+
if (!this.pendingKeyUpdateWrite)
|
|
1418
|
+
return;
|
|
1419
|
+
const { nextWriteEpoch, nextTrafficSecret } = this.pendingKeyUpdateWrite;
|
|
1420
|
+
if (this.role === "client") {
|
|
1421
|
+
this.clientAppTraffic = nextTrafficSecret;
|
|
1422
|
+
}
|
|
1423
|
+
else {
|
|
1424
|
+
this.serverAppTraffic = nextTrafficSecret;
|
|
1425
|
+
}
|
|
1426
|
+
this.writeEpoch = nextWriteEpoch;
|
|
1427
|
+
this.pendingKeyUpdateWrite = undefined;
|
|
1428
|
+
this.pruneStaleEpochs();
|
|
1429
|
+
(0, types_1.log)("KeyUpdate write epoch advanced after ACK", nextWriteEpoch);
|
|
1430
|
+
}
|
|
1431
|
+
markConnected(opts) {
|
|
1432
|
+
// close/fatal mid-Finished must not resurrect connected after terminal.
|
|
1433
|
+
if (this.closed || this.closing) {
|
|
1434
|
+
(0, types_1.log)("skip markConnected: association already closing/closed");
|
|
1435
|
+
return;
|
|
1436
|
+
}
|
|
1437
|
+
this.connected = true;
|
|
1438
|
+
this.hsPhase = "connected";
|
|
1439
|
+
// Pin peer at handshake complete if not already (ICE/none or dual reinject)
|
|
1440
|
+
if (this.peerKey !== "unknown") {
|
|
1441
|
+
this.pinPeer(this.peerKey, this.peerAddr);
|
|
1442
|
+
}
|
|
1443
|
+
if (!opts?.keepPendingFlight) {
|
|
1444
|
+
this.clearPendingFlight();
|
|
1445
|
+
this.carrier.cancelAllTimers();
|
|
1446
|
+
}
|
|
1447
|
+
this.carrier.events.onHandshakeComplete?.();
|
|
1448
|
+
const drainGeneration = this.expectedRxGeneration?.();
|
|
1449
|
+
const drainIsCurrent = () => drainGeneration === undefined ||
|
|
1450
|
+
this.expectedRxGeneration?.() === drainGeneration;
|
|
1451
|
+
this.onConnect.execute();
|
|
1452
|
+
// Flush app data that arrived early due to reorder. Take one record at a
|
|
1453
|
+
// time so an ICE restart from one callback prevents the remainder of the
|
|
1454
|
+
// old-generation queue from reaching the application.
|
|
1455
|
+
while (drainIsCurrent()) {
|
|
1456
|
+
const buf = this.earlyAppDataBuffer.takeOne();
|
|
1457
|
+
if (!buf)
|
|
1458
|
+
break;
|
|
1459
|
+
this.onData.execute(buf);
|
|
1460
|
+
}
|
|
1461
|
+
if (!drainIsCurrent())
|
|
1462
|
+
this.clearEarlyAppData();
|
|
1463
|
+
}
|
|
1464
|
+
clearEarlyAppData() {
|
|
1465
|
+
this.earlyAppDataBuffer.clear(true);
|
|
1466
|
+
}
|
|
1467
|
+
bufferEarlyAppData(data) {
|
|
1468
|
+
return this.earlyAppDataBuffer.push(data);
|
|
1469
|
+
}
|
|
1470
|
+
markWriteReady() {
|
|
1471
|
+
if (this.readiness.writeReady || this.closed || this.closing)
|
|
1472
|
+
return;
|
|
1473
|
+
this.readiness.writeReady = true;
|
|
1474
|
+
this.onWriteReady.execute();
|
|
1475
|
+
}
|
|
1476
|
+
markPeerHandshakeAuthenticated() {
|
|
1477
|
+
if (this.readiness.peerHandshakeAuthenticated ||
|
|
1478
|
+
this.closed ||
|
|
1479
|
+
this.closing)
|
|
1480
|
+
return;
|
|
1481
|
+
this.readiness.peerHandshakeAuthenticated = true;
|
|
1482
|
+
this.onPeerHandshakeAuthenticated.execute();
|
|
1483
|
+
}
|
|
1484
|
+
markHandshakeComplete() {
|
|
1485
|
+
if (this.readiness.handshakeComplete || this.closed || this.closing)
|
|
1486
|
+
return;
|
|
1487
|
+
this.readiness.handshakeComplete = true;
|
|
1488
|
+
this.onHandshakeComplete.execute();
|
|
1489
|
+
}
|
|
1490
|
+
waitForWriteReady() {
|
|
1491
|
+
return this.waitForMilestone("writeReady", this.onWriteReady);
|
|
1492
|
+
}
|
|
1493
|
+
waitForPeerHandshakeAuthenticated() {
|
|
1494
|
+
return this.waitForMilestone("peerHandshakeAuthenticated", this.onPeerHandshakeAuthenticated);
|
|
1495
|
+
}
|
|
1496
|
+
waitForHandshakeComplete() {
|
|
1497
|
+
return this.waitForMilestone("handshakeComplete", this.onHandshakeComplete);
|
|
1498
|
+
}
|
|
1499
|
+
waitForMilestone(milestone, event) {
|
|
1500
|
+
if (this.readiness[milestone])
|
|
1501
|
+
return Promise.resolve();
|
|
1502
|
+
if (this.closed || this.closing) {
|
|
1503
|
+
return Promise.reject(new Error("DTLS association closed before readiness"));
|
|
1504
|
+
}
|
|
1505
|
+
return new Promise((resolve, reject) => {
|
|
1506
|
+
const ready = event.subscribe(() => {
|
|
1507
|
+
cleanup();
|
|
1508
|
+
resolve();
|
|
1509
|
+
});
|
|
1510
|
+
const closing = this.onClosing.subscribe(() => {
|
|
1511
|
+
cleanup();
|
|
1512
|
+
reject(new Error("DTLS association closed before readiness"));
|
|
1513
|
+
});
|
|
1514
|
+
const failed = this.onError.subscribe((error) => {
|
|
1515
|
+
cleanup();
|
|
1516
|
+
reject(error);
|
|
1517
|
+
});
|
|
1518
|
+
const closed = this.onClose.subscribe(() => {
|
|
1519
|
+
cleanup();
|
|
1520
|
+
reject(new Error("DTLS association closed before readiness"));
|
|
1521
|
+
});
|
|
1522
|
+
const cleanup = () => {
|
|
1523
|
+
ready.unSubscribe();
|
|
1524
|
+
closing.unSubscribe();
|
|
1525
|
+
failed.unSubscribe();
|
|
1526
|
+
closed.unSubscribe();
|
|
1527
|
+
};
|
|
1528
|
+
if (this.readiness[milestone]) {
|
|
1529
|
+
cleanup();
|
|
1530
|
+
resolve();
|
|
1531
|
+
}
|
|
1532
|
+
});
|
|
1533
|
+
}
|
|
1534
|
+
/**
|
|
1535
|
+
* Dual HVR: park for parallel 1.2 cookie probe without killing CH-A retransmit.
|
|
1536
|
+
* Returns true when the error was handled as a soft dual probe (not a hard fail).
|
|
1537
|
+
*/
|
|
1538
|
+
tryParkDualProbe(err) {
|
|
1539
|
+
if (this.role !== "client" || this.closed || this.dualProbeParked) {
|
|
1540
|
+
return false;
|
|
1541
|
+
}
|
|
1542
|
+
const isDualHvr = err.name === "DtlsVersionSelected" ||
|
|
1543
|
+
err.code === "version_selected";
|
|
1544
|
+
if (!isDualHvr)
|
|
1545
|
+
return false;
|
|
1546
|
+
if (!(0, version_1.supportsVersion)(this.offeredProtocolVersions, version_1.DtlsVersion.V1_2)) {
|
|
1547
|
+
return false;
|
|
1548
|
+
}
|
|
1549
|
+
// Keep pendingFlight + retransmit timers so original CH-A is still RTO'd
|
|
1550
|
+
// (RFC 9147: lost HRR/SH is recovered by ClientHello retransmit): an
|
|
1551
|
+
// off-path HelloVerifyRequest must not stop a DTLS 1.3 server's answer.
|
|
1552
|
+
this.dualProbeParked = true;
|
|
1553
|
+
this.connected = false;
|
|
1554
|
+
if (this.peerIdentityMode === "authenticated-single-peer") {
|
|
1555
|
+
// The transport path is the peer (WebRTC over ICE), so the HVR came
|
|
1556
|
+
// from the peer itself and the 1.2 cookie path retransmits its own
|
|
1557
|
+
// ClientHello. A retransmitted CH-A would make a DTLS 1.2 server
|
|
1558
|
+
// challenge again with a new cookie in the middle of the handshake; a
|
|
1559
|
+
// server that keeps its first transcript (werift before DTLS 1.3)
|
|
1560
|
+
// then derives other keys and the handshake never completes.
|
|
1561
|
+
this.cancelRetransmit?.();
|
|
1562
|
+
this.cancelRetransmit = undefined;
|
|
1563
|
+
}
|
|
1564
|
+
(0, types_1.log)("dual probe park: keep CH-A retransmit, signal association", err.message);
|
|
1565
|
+
this.onError.execute(err);
|
|
1566
|
+
return true;
|
|
1567
|
+
}
|
|
1568
|
+
/**
|
|
1569
|
+
* Force-stop timers / carrier after a soft engine fail (e.g. ProtocolVersionError
|
|
1570
|
+
* that left the carrier open for legacy dual rebind). Association-level fatal
|
|
1571
|
+
* teardown calls this so inject/RTO cannot continue after public onError.
|
|
1572
|
+
* Does not fire onError/onClose (association owns public lifecycle).
|
|
1573
|
+
*/
|
|
1574
|
+
hardDisposeResources() {
|
|
1575
|
+
this.clearPendingFlight();
|
|
1576
|
+
this.clearEarlyAppData();
|
|
1577
|
+
this.cancelEpochPrune?.();
|
|
1578
|
+
this.cancelEpochPrune = undefined;
|
|
1579
|
+
this.carrier.cancelAllTimers();
|
|
1580
|
+
this.dualProbeParked = false;
|
|
1581
|
+
this.closing = true;
|
|
1582
|
+
this.closed = true;
|
|
1583
|
+
this.connected = false;
|
|
1584
|
+
if (!this.carrier.isClosed()) {
|
|
1585
|
+
this.carrier.close();
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
fail(err) {
|
|
1589
|
+
if (this.closed)
|
|
1590
|
+
return;
|
|
1591
|
+
// Dual HVR with 1.2 fallback offered: park rather than tear down CH-A.
|
|
1592
|
+
// Association must NOT treat this as fatal (filterError + dual probing).
|
|
1593
|
+
if (this.tryParkDualProbe(err))
|
|
1594
|
+
return;
|
|
1595
|
+
(0, types_1.log)("fail", err.message);
|
|
1596
|
+
// Always stop timers / pending retransmits and refuse further 1.3 RX
|
|
1597
|
+
this.clearPendingFlight();
|
|
1598
|
+
this.clearEarlyAppData();
|
|
1599
|
+
this.cancelEpochPrune?.();
|
|
1600
|
+
this.cancelEpochPrune = undefined;
|
|
1601
|
+
this.carrier.cancelAllTimers();
|
|
1602
|
+
this.closed = true;
|
|
1603
|
+
this.connected = false;
|
|
1604
|
+
this.dualProbeParked = false;
|
|
1605
|
+
this.onError.execute(err);
|
|
1606
|
+
// Protocol-version engine soft fail: keep UDP socket open only long enough
|
|
1607
|
+
// for association to rebind (legacy dual). Association fatal teardown will
|
|
1608
|
+
// hardDisposeResources + close transport when the error is public.
|
|
1609
|
+
// DtlsVersionSelected soft park is handled above via tryParkDualProbe.
|
|
1610
|
+
const softVersion = err instanceof version_1.ProtocolVersionError ||
|
|
1611
|
+
err.name === "ProtocolVersionError" ||
|
|
1612
|
+
err.code === "version_selected";
|
|
1613
|
+
if (softVersion) {
|
|
1614
|
+
return;
|
|
1615
|
+
}
|
|
1616
|
+
// Hard fail: tear down carrier + transport
|
|
1617
|
+
this.carrier.close();
|
|
1618
|
+
void this.options.transport.close().catch(() => { });
|
|
1619
|
+
this.onClose.execute();
|
|
1620
|
+
}
|
|
1621
|
+
get negotiatedVersion() {
|
|
1622
|
+
return version_1.DtlsVersion.V1_3;
|
|
1623
|
+
}
|
|
1624
|
+
get remoteCertificate() {
|
|
1625
|
+
return this.remoteCert;
|
|
1626
|
+
}
|
|
1627
|
+
/** Negotiated SRTP profile from use_srtp (EncryptedExtensions / ClientHello). */
|
|
1628
|
+
get srtpProfile() {
|
|
1629
|
+
return this.negotiatedSrtpProfile;
|
|
1630
|
+
}
|
|
1631
|
+
/**
|
|
1632
|
+
* Package-internal: reinject a datagram (dual-engine association).
|
|
1633
|
+
* Not a stable Public API — Epic 2 may re-export a carrier interface.
|
|
1634
|
+
*
|
|
1635
|
+
* Calls engine RX directly (not carrier.inject) so association-owned inject
|
|
1636
|
+
* handlers cannot re-enter demux when dual commit reinjects SH/HRR.
|
|
1637
|
+
*/
|
|
1638
|
+
injectDatagram(bytes, peer, rxGeneration) {
|
|
1639
|
+
const self = this;
|
|
1640
|
+
return self.handleDatagram(Buffer.from(bytes), peer, rxGeneration);
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
exports.Dtls13ConnectionBase = Dtls13ConnectionBase;
|
|
1644
|
+
//# sourceMappingURL=connection-base.js.map
|