werift 0.26.0 → 0.28.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 -8
- package/THIRD_PARTY_LICENSES_LIBWEBRTC.txt +58 -0
- package/lib/common/src/binary.d.ts +1 -3
- package/lib/common/src/binary.js +8 -6
- package/lib/common/src/binary.js.map +1 -1
- package/lib/common/src/binaryData.js +2 -1
- package/lib/common/src/binaryData.js.map +1 -1
- package/lib/common/src/event.d.ts +26 -0
- package/lib/common/src/event.js +87 -2
- package/lib/common/src/event.js.map +1 -1
- package/lib/common/src/log.js +5 -7
- package/lib/common/src/log.js.map +1 -1
- package/lib/common/src/network.d.ts +6 -1
- package/lib/common/src/network.js +8 -2
- package/lib/common/src/network.js.map +1 -1
- package/lib/common/src/transport.d.ts +12 -5
- package/lib/common/src/transport.js +13 -7
- package/lib/common/src/transport.js.map +1 -1
- package/lib/dtls/src/alert.d.ts +49 -0
- package/lib/dtls/src/alert.js +103 -0
- package/lib/dtls/src/alert.js.map +1 -0
- package/lib/dtls/src/client.js +15 -1
- package/lib/dtls/src/client.js.map +1 -1
- package/lib/dtls/src/context/cipher.d.ts +1 -1
- package/lib/dtls/src/context/cipher.js +6 -3
- package/lib/dtls/src/context/cipher.js.map +1 -1
- package/lib/dtls/src/context/dtls.d.ts +2 -0
- package/lib/dtls/src/context/dtls.js +11 -2
- package/lib/dtls/src/context/dtls.js.map +1 -1
- package/lib/dtls/src/context/transport.d.ts +17 -1
- package/lib/dtls/src/context/transport.js +40 -3
- package/lib/dtls/src/context/transport.js.map +1 -1
- package/lib/dtls/src/flight/client/flight1.js +2 -1
- package/lib/dtls/src/flight/client/flight1.js.map +1 -1
- package/lib/dtls/src/flight/client/flight5.js +8 -3
- package/lib/dtls/src/flight/client/flight5.js.map +1 -1
- package/lib/dtls/src/flight/flight.d.ts +6 -1
- package/lib/dtls/src/flight/flight.js +18 -5
- package/lib/dtls/src/flight/flight.js.map +1 -1
- package/lib/dtls/src/flight/server/flight4.js +4 -2
- package/lib/dtls/src/flight/server/flight4.js.map +1 -1
- package/lib/dtls/src/flight/server/flight6.js +6 -2
- package/lib/dtls/src/flight/server/flight6.js.map +1 -1
- package/lib/dtls/src/handshake/const.d.ts +17 -13
- package/lib/dtls/src/handshake/const.js +16 -14
- package/lib/dtls/src/handshake/const.js.map +1 -1
- package/lib/dtls/src/handshake/message/alert.js +4 -2
- package/lib/dtls/src/handshake/message/alert.js.map +1 -1
- package/lib/dtls/src/handshake/message/certificate.js +2 -1
- package/lib/dtls/src/handshake/message/certificate.js.map +1 -1
- package/lib/dtls/src/handshake/message/changeCipherSpec.js +2 -1
- package/lib/dtls/src/handshake/message/changeCipherSpec.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/certificateVerify.js +4 -2
- package/lib/dtls/src/handshake/message/client/certificateVerify.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/hello.js +14 -7
- package/lib/dtls/src/handshake/message/client/hello.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/keyExchange.js +2 -1
- package/lib/dtls/src/handshake/message/client/keyExchange.js.map +1 -1
- package/lib/dtls/src/handshake/message/finished.js +2 -1
- package/lib/dtls/src/handshake/message/finished.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/certificateRequest.js +6 -3
- package/lib/dtls/src/handshake/message/server/certificateRequest.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/hello.js +12 -6
- package/lib/dtls/src/handshake/message/server/hello.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/helloDone.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js +4 -2
- package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/keyExchange.js +16 -8
- package/lib/dtls/src/handshake/message/server/keyExchange.js.map +1 -1
- package/lib/dtls/src/handshake/random.d.ts +2 -2
- package/lib/dtls/src/handshake/random.js +5 -2
- package/lib/dtls/src/handshake/random.js.map +1 -1
- package/lib/dtls/src/index.d.ts +3 -1
- package/lib/dtls/src/index.js +10 -1
- package/lib/dtls/src/index.js.map +1 -1
- package/lib/dtls/src/record/const.d.ts +52 -33
- package/lib/dtls/src/record/const.js +51 -36
- package/lib/dtls/src/record/const.js.map +1 -1
- package/lib/dtls/src/record/message/fragment.js +12 -6
- package/lib/dtls/src/record/message/fragment.js.map +1 -1
- package/lib/dtls/src/record/message/header.js +10 -5
- package/lib/dtls/src/record/message/header.js.map +1 -1
- package/lib/dtls/src/record/message/plaintext.js +4 -2
- package/lib/dtls/src/record/message/plaintext.js.map +1 -1
- package/lib/dtls/src/record/receive.d.ts +6 -0
- package/lib/dtls/src/record/receive.js +50 -19
- package/lib/dtls/src/record/receive.js.map +1 -1
- package/lib/dtls/src/server.js +19 -1
- package/lib/dtls/src/server.js.map +1 -1
- package/lib/dtls/src/socket.d.ts +134 -2
- package/lib/dtls/src/socket.js +326 -8
- package/lib/dtls/src/socket.js.map +1 -1
- package/lib/ice/src/candidate.d.ts +1 -1
- package/lib/ice/src/candidate.js +24 -12
- package/lib/ice/src/candidate.js.map +1 -1
- package/lib/ice/src/candidateError.d.ts +155 -0
- package/lib/ice/src/candidateError.js +246 -0
- package/lib/ice/src/candidateError.js.map +1 -0
- package/lib/ice/src/candidateGatherer.d.ts +127 -0
- package/lib/ice/src/candidateGatherer.js +745 -0
- package/lib/ice/src/candidateGatherer.js.map +1 -0
- package/lib/ice/src/consent.d.ts +49 -0
- package/lib/ice/src/consent.js +258 -0
- package/lib/ice/src/consent.js.map +1 -0
- package/lib/ice/src/dns/lookup.d.ts +10 -1
- package/lib/ice/src/dns/lookup.js +42 -7
- package/lib/ice/src/dns/lookup.js.map +1 -1
- package/lib/ice/src/exceptions.d.ts +21 -5
- package/lib/ice/src/exceptions.js +58 -13
- package/lib/ice/src/exceptions.js.map +1 -1
- package/lib/ice/src/ice.d.ts +254 -58
- package/lib/ice/src/ice.js +979 -945
- package/lib/ice/src/ice.js.map +1 -1
- package/lib/ice/src/iceBase.d.ts +328 -14
- package/lib/ice/src/iceBase.js +254 -38
- package/lib/ice/src/iceBase.js.map +1 -1
- package/lib/ice/src/index.d.ts +1 -0
- package/lib/ice/src/index.js +1 -0
- package/lib/ice/src/index.js.map +1 -1
- package/lib/ice/src/internal/checkMessages.d.ts +41 -0
- package/lib/ice/src/internal/checkMessages.js +63 -0
- package/lib/ice/src/internal/checkMessages.js.map +1 -0
- package/lib/ice/src/internal/defaultRoute.d.ts +20 -0
- package/lib/ice/src/internal/defaultRoute.js +134 -0
- package/lib/ice/src/internal/defaultRoute.js.map +1 -0
- package/lib/ice/src/internal/hostInterfaces.d.ts +17 -0
- package/lib/ice/src/internal/hostInterfaces.js +77 -0
- package/lib/ice/src/internal/hostInterfaces.js.map +1 -0
- package/lib/ice/src/internal/hostPreference.d.ts +24 -0
- package/lib/ice/src/internal/hostPreference.js +38 -0
- package/lib/ice/src/internal/hostPreference.js.map +1 -0
- package/lib/ice/src/internal/resolveHostAddresses.d.ts +56 -8
- package/lib/ice/src/internal/resolveHostAddresses.js +127 -24
- package/lib/ice/src/internal/resolveHostAddresses.js.map +1 -1
- package/lib/ice/src/internal/selectAddresses.d.ts +27 -0
- package/lib/ice/src/internal/selectAddresses.js +37 -18
- package/lib/ice/src/internal/selectAddresses.js.map +1 -1
- package/lib/ice/src/nomination/regularNomination.d.ts +200 -0
- package/lib/ice/src/nomination/regularNomination.js +311 -0
- package/lib/ice/src/nomination/regularNomination.js.map +1 -0
- package/lib/ice/src/nomination/selectionReplacement.d.ts +138 -0
- package/lib/ice/src/nomination/selectionReplacement.js +371 -0
- package/lib/ice/src/nomination/selectionReplacement.js.map +1 -0
- package/lib/ice/src/provisional.d.ts +139 -0
- package/lib/ice/src/provisional.js +468 -0
- package/lib/ice/src/provisional.js.map +1 -0
- package/lib/ice/src/stun/protocol.d.ts +9 -2
- package/lib/ice/src/stun/protocol.js +16 -17
- package/lib/ice/src/stun/protocol.js.map +1 -1
- package/lib/ice/src/stun/tcpProtocol.d.ts +1 -1
- package/lib/ice/src/stun/tcpProtocol.js +7 -7
- package/lib/ice/src/stun/tcpProtocol.js.map +1 -1
- package/lib/ice/src/stun/transaction.d.ts +30 -1
- package/lib/ice/src/stun/transaction.js +90 -19
- package/lib/ice/src/stun/transaction.js.map +1 -1
- package/lib/ice/src/turn/credential.d.ts +49 -0
- package/lib/ice/src/turn/credential.js +78 -0
- package/lib/ice/src/turn/credential.js.map +1 -0
- package/lib/ice/src/turn/protocol.d.ts +31 -10
- package/lib/ice/src/turn/protocol.js +127 -51
- package/lib/ice/src/turn/protocol.js.map +1 -1
- package/lib/ice/src/types/model.d.ts +16 -5
- package/lib/ice/src/types/model.js.map +1 -1
- package/lib/ice-server/src/stun/attributes.d.ts +2 -0
- package/lib/ice-server/src/stun/attributes.js +11 -1
- package/lib/ice-server/src/stun/attributes.js.map +1 -1
- package/lib/ice-server/src/stun/const.d.ts +44 -17
- package/lib/ice-server/src/stun/const.js +31 -19
- package/lib/ice-server/src/stun/const.js.map +1 -1
- package/lib/ice-server/src/stun/message.d.ts +29 -4
- package/lib/ice-server/src/stun/message.js +115 -24
- package/lib/ice-server/src/stun/message.js.map +1 -1
- package/lib/index.mjs +35121 -22337
- package/lib/nonstandard/index.mjs +3169 -1399
- package/lib/polyfill/dom.mjs +24650 -12365
- package/lib/polyfill/index.mjs +24650 -12365
- package/lib/rtp/src/codec/assertPayload.d.ts +4 -0
- package/lib/rtp/src/codec/assertPayload.js +12 -0
- package/lib/rtp/src/codec/assertPayload.js.map +1 -0
- package/lib/rtp/src/codec/av1.js +2 -0
- package/lib/rtp/src/codec/av1.js.map +1 -1
- package/lib/rtp/src/codec/h264.js +35 -43
- package/lib/rtp/src/codec/h264.js.map +1 -1
- package/lib/rtp/src/codec/vp8.js +11 -5
- package/lib/rtp/src/codec/vp8.js.map +1 -1
- package/lib/rtp/src/codec/vp9.js +12 -0
- package/lib/rtp/src/codec/vp9.js.map +1 -1
- package/lib/rtp/src/extra/container/mp4/container.js +2 -1
- package/lib/rtp/src/extra/container/mp4/container.js.map +1 -1
- package/lib/rtp/src/extra/container/mp4/exp-golomb.js +2 -1
- package/lib/rtp/src/extra/container/mp4/exp-golomb.js.map +1 -1
- package/lib/rtp/src/extra/container/mp4/h264.d.ts +21 -17
- package/lib/rtp/src/extra/container/mp4/h264.js +26 -24
- package/lib/rtp/src/extra/container/mp4/h264.js.map +1 -1
- package/lib/rtp/src/extra/container/ogg/index.d.ts +1 -0
- package/lib/rtp/src/extra/container/ogg/index.js +1 -0
- package/lib/rtp/src/extra/container/ogg/index.js.map +1 -1
- package/lib/rtp/src/extra/container/ogg/writer.d.ts +90 -0
- package/lib/rtp/src/extra/container/ogg/writer.js +300 -0
- package/lib/rtp/src/extra/container/ogg/writer.js.map +1 -0
- package/lib/rtp/src/extra/container/webm/ebml/ebml.js +6 -3
- package/lib/rtp/src/extra/container/webm/ebml/ebml.js.map +1 -1
- package/lib/rtp/src/extra/processor/depacketizer.d.ts +5 -0
- package/lib/rtp/src/extra/processor/depacketizer.js +28 -2
- package/lib/rtp/src/extra/processor/depacketizer.js.map +1 -1
- package/lib/rtp/src/extra/processor/dtx.js +4 -2
- package/lib/rtp/src/extra/processor/dtx.js.map +1 -1
- package/lib/rtp/src/extra/processor/index.d.ts +2 -0
- package/lib/rtp/src/extra/processor/index.js +2 -0
- package/lib/rtp/src/extra/processor/index.js.map +1 -1
- package/lib/rtp/src/extra/processor/jitterBuffer.d.ts +29 -6
- package/lib/rtp/src/extra/processor/jitterBuffer.js +101 -111
- package/lib/rtp/src/extra/processor/jitterBuffer.js.map +1 -1
- package/lib/rtp/src/extra/processor/jitterBufferTransformer.js +2 -1
- package/lib/rtp/src/extra/processor/jitterBufferTransformer.js.map +1 -1
- package/lib/rtp/src/extra/processor/lipsync.d.ts +63 -0
- package/lib/rtp/src/extra/processor/lipsync.js +202 -51
- package/lib/rtp/src/extra/processor/lipsync.js.map +1 -1
- package/lib/rtp/src/extra/processor/mp4.d.ts +0 -6
- package/lib/rtp/src/extra/processor/mp4.js +6 -3
- package/lib/rtp/src/extra/processor/mp4.js.map +1 -1
- package/lib/rtp/src/extra/processor/mute.js +4 -2
- package/lib/rtp/src/extra/processor/mute.js.map +1 -1
- package/lib/rtp/src/extra/processor/nack.js +4 -2
- package/lib/rtp/src/extra/processor/nack.js.map +1 -1
- package/lib/rtp/src/extra/processor/ntpTime.js +4 -6
- package/lib/rtp/src/extra/processor/ntpTime.js.map +1 -1
- package/lib/rtp/src/extra/processor/ogg.d.ts +72 -0
- package/lib/rtp/src/extra/processor/ogg.js +221 -0
- package/lib/rtp/src/extra/processor/ogg.js.map +1 -0
- package/lib/rtp/src/extra/processor/oggCallback.d.ts +21 -0
- package/lib/rtp/src/extra/processor/oggCallback.js +97 -0
- package/lib/rtp/src/extra/processor/oggCallback.js.map +1 -0
- package/lib/rtp/src/extra/processor/rtpCallback.js +2 -1
- package/lib/rtp/src/extra/processor/rtpCallback.js.map +1 -1
- package/lib/rtp/src/extra/processor/rtpStream.js +2 -1
- package/lib/rtp/src/extra/processor/rtpStream.js.map +1 -1
- package/lib/rtp/src/extra/processor/rtpTime.js +2 -1
- package/lib/rtp/src/extra/processor/rtpTime.js.map +1 -1
- package/lib/rtp/src/extra/processor/webm.js +14 -7
- package/lib/rtp/src/extra/processor/webm.js.map +1 -1
- package/lib/rtp/src/extra/processor/webmCallback.js.map +1 -1
- package/lib/rtp/src/index.d.ts +8 -0
- package/lib/rtp/src/index.js +8 -0
- package/lib/rtp/src/index.js.map +1 -1
- package/lib/rtp/src/rtcp/psfb/fullIntraRequest.d.ts +4 -0
- package/lib/rtp/src/rtcp/psfb/fullIntraRequest.js +4 -0
- package/lib/rtp/src/rtcp/psfb/fullIntraRequest.js.map +1 -1
- package/lib/rtp/src/rtcp/rtcp.js +8 -4
- package/lib/rtp/src/rtcp/rtcp.js.map +1 -1
- package/lib/rtp/src/rtcp/rtpfb/transportWideSequence.d.ts +58 -0
- package/lib/rtp/src/rtcp/rtpfb/transportWideSequence.js +143 -0
- package/lib/rtp/src/rtcp/rtpfb/transportWideSequence.js.map +1 -0
- package/lib/rtp/src/rtcp/rtpfb/twcc.d.ts +35 -13
- package/lib/rtp/src/rtcp/rtpfb/twcc.js +132 -54
- package/lib/rtp/src/rtcp/rtpfb/twcc.js.map +1 -1
- package/lib/rtp/src/rtcp/rtpfb/twccReceiveTiming.d.ts +13 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReceiveTiming.js +29 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReceiveTiming.js.map +1 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReferenceTime.d.ts +41 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReferenceTime.js +89 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReferenceTime.js.map +1 -0
- package/lib/rtp/src/rtcp/sr.js +1 -0
- package/lib/rtp/src/rtcp/sr.js.map +1 -1
- package/lib/rtp/src/rtp/continuity.d.ts +49 -0
- package/lib/rtp/src/rtp/continuity.js +120 -0
- package/lib/rtp/src/rtp/continuity.js.map +1 -0
- package/lib/rtp/src/rtp/headerExtension.js +41 -21
- package/lib/rtp/src/rtp/headerExtension.js.map +1 -1
- package/lib/rtp/src/rtp/padding.d.ts +17 -0
- package/lib/rtp/src/rtp/padding.js +37 -0
- package/lib/rtp/src/rtp/padding.js.map +1 -0
- package/lib/rtp/src/rtp/red/encoder.d.ts +10 -0
- package/lib/rtp/src/rtp/red/encoder.js +14 -1
- package/lib/rtp/src/rtp/red/encoder.js.map +1 -1
- package/lib/rtp/src/rtp/red/packet.js +24 -8
- package/lib/rtp/src/rtp/red/packet.js.map +1 -1
- package/lib/rtp/src/rtp/rtp.d.ts +24 -1
- package/lib/rtp/src/rtp/rtp.js +70 -29
- package/lib/rtp/src/rtp/rtp.js.map +1 -1
- package/lib/rtp/src/rtp/rtx.js +3 -0
- package/lib/rtp/src/rtp/rtx.js.map +1 -1
- package/lib/rtp/src/rtp/sendHeaderExtensions.d.ts +36 -0
- package/lib/rtp/src/rtp/sendHeaderExtensions.js +85 -0
- package/lib/rtp/src/rtp/sendHeaderExtensions.js.map +1 -0
- package/lib/rtp/src/rtp/timelineRewriter.d.ts +178 -0
- package/lib/rtp/src/rtp/timelineRewriter.js +417 -0
- package/lib/rtp/src/rtp/timelineRewriter.js.map +1 -0
- package/lib/rtp/src/srtp/cipher/ctr.js +4 -2
- package/lib/rtp/src/srtp/cipher/ctr.js.map +1 -1
- package/lib/rtp/src/srtp/cipher/index.js +8 -4
- package/lib/rtp/src/srtp/cipher/index.js.map +1 -1
- package/lib/rtp/src/srtp/context/context.js +6 -3
- package/lib/rtp/src/srtp/context/context.js.map +1 -1
- package/lib/rtp/src/srtp/context/srtcp.d.ts +1 -1
- package/lib/rtp/src/srtp/context/srtcp.js +33 -0
- package/lib/rtp/src/srtp/context/srtcp.js.map +1 -1
- package/lib/rtp/src/srtp/context/srtp.d.ts +1 -1
- package/lib/rtp/src/srtp/context/srtp.js +34 -10
- package/lib/rtp/src/srtp/context/srtp.js.map +1 -1
- package/lib/rtp/src/srtp/error.d.ts +8 -0
- package/lib/rtp/src/srtp/error.js +13 -1
- package/lib/rtp/src/srtp/error.js.map +1 -1
- package/lib/rtp/src/srtp/packet.js +4 -1
- package/lib/rtp/src/srtp/packet.js.map +1 -1
- package/lib/rtp/src/srtp/replay.d.ts +24 -0
- package/lib/rtp/src/srtp/replay.js +75 -0
- package/lib/rtp/src/srtp/replay.js.map +1 -0
- package/lib/rtp/src/srtp/session.js +2 -1
- package/lib/rtp/src/srtp/session.js.map +1 -1
- package/lib/rtp/src/srtp/srtcp.js +2 -1
- package/lib/rtp/src/srtp/srtcp.js.map +1 -1
- package/lib/rtp/src/srtp/srtp.js +2 -1
- package/lib/rtp/src/srtp/srtp.js.map +1 -1
- package/lib/rtp/src/util.js +2 -1
- package/lib/rtp/src/util.js.map +1 -1
- package/lib/sctp/src/chunk.d.ts +5 -0
- package/lib/sctp/src/chunk.js +31 -8
- package/lib/sctp/src/chunk.js.map +1 -1
- package/lib/sctp/src/const.d.ts +25 -17
- package/lib/sctp/src/const.js +23 -19
- package/lib/sctp/src/const.js.map +1 -1
- package/lib/sctp/src/param.d.ts +6 -2
- package/lib/sctp/src/param.js +22 -8
- package/lib/sctp/src/param.js.map +1 -1
- package/lib/sctp/src/sctp.d.ts +85 -0
- package/lib/sctp/src/sctp.js +707 -126
- package/lib/sctp/src/sctp.js.map +1 -1
- package/lib/sctp/src/transport.js +4 -2
- package/lib/sctp/src/transport.js.map +1 -1
- package/lib/webrtc/src/api/compatibilityOptions.d.ts +33 -0
- package/lib/webrtc/src/api/compatibilityOptions.js +33 -0
- package/lib/webrtc/src/api/compatibilityOptions.js.map +1 -0
- package/lib/webrtc/src/api/peerConfig.d.ts +385 -28
- package/lib/webrtc/src/api/peerConfig.js +121 -14
- package/lib/webrtc/src/api/peerConfig.js.map +1 -1
- package/lib/webrtc/src/api/peerConnectionEvents.d.ts +77 -1
- package/lib/webrtc/src/api/peerConnectionEvents.js +105 -1
- package/lib/webrtc/src/api/peerConnectionEvents.js.map +1 -1
- package/lib/webrtc/src/dataChannel.d.ts +10 -0
- package/lib/webrtc/src/dataChannel.js +24 -4
- package/lib/webrtc/src/dataChannel.js.map +1 -1
- package/lib/webrtc/src/helper.d.ts +8 -0
- package/lib/webrtc/src/helper.js +40 -4
- package/lib/webrtc/src/helper.js.map +1 -1
- package/lib/webrtc/src/media/codecCompatibility.d.ts +87 -1
- package/lib/webrtc/src/media/codecCompatibility.js +338 -12
- package/lib/webrtc/src/media/codecCompatibility.js.map +1 -1
- package/lib/webrtc/src/media/index.d.ts +10 -0
- package/lib/webrtc/src/media/index.js +70 -0
- package/lib/webrtc/src/media/index.js.map +1 -1
- package/lib/webrtc/src/media/receiver/nack.d.ts +43 -10
- package/lib/webrtc/src/media/receiver/nack.js +246 -88
- package/lib/webrtc/src/media/receiver/nack.js.map +1 -1
- package/lib/webrtc/src/media/receiver/receiverTwcc.d.ts +61 -1
- package/lib/webrtc/src/media/receiver/receiverTwcc.js +218 -63
- package/lib/webrtc/src/media/receiver/receiverTwcc.js.map +1 -1
- package/lib/webrtc/src/media/router.d.ts +241 -40
- package/lib/webrtc/src/media/router.js +676 -205
- package/lib/webrtc/src/media/router.js.map +1 -1
- package/lib/webrtc/src/media/routing/pendingRoutes.d.ts +26 -0
- package/lib/webrtc/src/media/routing/pendingRoutes.js +48 -0
- package/lib/webrtc/src/media/routing/pendingRoutes.js.map +1 -0
- package/lib/webrtc/src/media/routing/ridRouting.d.ts +37 -0
- package/lib/webrtc/src/media/routing/ridRouting.js +74 -0
- package/lib/webrtc/src/media/routing/ridRouting.js.map +1 -0
- package/lib/webrtc/src/media/routing/routeTable.d.ts +60 -0
- package/lib/webrtc/src/media/routing/routeTable.js +95 -0
- package/lib/webrtc/src/media/routing/routeTable.js.map +1 -0
- package/lib/webrtc/src/media/routing/rtcpRouting.d.ts +34 -0
- package/lib/webrtc/src/media/routing/rtcpRouting.js +165 -0
- package/lib/webrtc/src/media/routing/rtcpRouting.js.map +1 -0
- package/lib/webrtc/src/media/routing/unknownSsrc.d.ts +55 -0
- package/lib/webrtc/src/media/routing/unknownSsrc.js +117 -0
- package/lib/webrtc/src/media/routing/unknownSsrc.js.map +1 -0
- package/lib/webrtc/src/media/rtpReceiver.d.ts +252 -2
- package/lib/webrtc/src/media/rtpReceiver.js +833 -44
- package/lib/webrtc/src/media/rtpReceiver.js.map +1 -1
- package/lib/webrtc/src/media/rtpSender.d.ts +191 -70
- package/lib/webrtc/src/media/rtpSender.js +631 -448
- package/lib/webrtc/src/media/rtpSender.js.map +1 -1
- package/lib/webrtc/src/media/rtpTransceiver.d.ts +19 -3
- package/lib/webrtc/src/media/rtpTransceiver.js +74 -9
- package/lib/webrtc/src/media/rtpTransceiver.js.map +1 -1
- package/lib/webrtc/src/media/sender/bandwidthEstimator.d.ts +249 -0
- package/lib/webrtc/src/media/sender/bandwidthEstimator.js +144 -0
- package/lib/webrtc/src/media/sender/bandwidthEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/createBandwidthEstimator.d.ts +20 -0
- package/lib/webrtc/src/media/sender/createBandwidthEstimator.js +26 -0
- package/lib/webrtc/src/media/sender/createBandwidthEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimatorBinding.d.ts +70 -0
- package/lib/webrtc/src/media/sender/estimatorBinding.js +175 -0
- package/lib/webrtc/src/media/sender/estimatorBinding.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/disabledBwe.d.ts +18 -0
- package/lib/webrtc/src/media/sender/estimators/disabledBwe.js +44 -0
- package/lib/webrtc/src/media/sender/estimators/disabledBwe.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/acknowledgedBitrateEstimator.d.ts +79 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/acknowledgedBitrateEstimator.js +289 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/acknowledgedBitrateEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/aimdRateControl.d.ts +87 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/aimdRateControl.js +429 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/aimdRateControl.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/alrDetector.d.ts +21 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/alrDetector.js +84 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/alrDetector.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/bandwidthLimitedCause.d.ts +37 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/bandwidthLimitedCause.js +74 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/bandwidthLimitedCause.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/constants.d.ts +383 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/constants.js +408 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/constants.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/gccBwe.d.ts +406 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/gccBwe.js +1391 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/gccBwe.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/index.d.ts +19 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/index.js +75 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/index.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/interArrivalDelta.d.ts +68 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/interArrivalDelta.js +201 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/interArrivalDelta.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/intervalBudget.d.ts +26 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/intervalBudget.js +72 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/intervalBudget.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/linkCapacityEstimator.d.ts +41 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/linkCapacityEstimator.js +99 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/linkCapacityEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/lossBasedBwe.d.ts +247 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/lossBasedBwe.js +1042 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/lossBasedBwe.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/overuseDetector.d.ts +26 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/overuseDetector.js +132 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/overuseDetector.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/probeController.d.ts +305 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/probeController.js +1073 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/probeController.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/rttBasedBackoff.d.ts +60 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/rttBasedBackoff.js +151 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/rttBasedBackoff.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/trendlineEstimator.d.ts +44 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/trendlineEstimator.js +246 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/trendlineEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/index.d.ts +7 -0
- package/lib/webrtc/src/media/sender/estimators/index.js +19 -0
- package/lib/webrtc/src/media/sender/estimators/index.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/lightweightBwe.d.ts +64 -0
- package/lib/webrtc/src/media/sender/estimators/lightweightBwe.js +216 -0
- package/lib/webrtc/src/media/sender/estimators/lightweightBwe.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/twccFeedbackAdapter.d.ts +117 -0
- package/lib/webrtc/src/media/sender/estimators/twccFeedbackAdapter.js +250 -0
- package/lib/webrtc/src/media/sender/estimators/twccFeedbackAdapter.js.map +1 -0
- package/lib/webrtc/src/media/sender/outgoingQueue.d.ts +40 -0
- package/lib/webrtc/src/media/sender/outgoingQueue.js +153 -0
- package/lib/webrtc/src/media/sender/outgoingQueue.js.map +1 -0
- package/lib/webrtc/src/media/sender/padding.d.ts +45 -0
- package/lib/webrtc/src/media/sender/padding.js +134 -0
- package/lib/webrtc/src/media/sender/padding.js.map +1 -0
- package/lib/webrtc/src/media/sender/pendingRtp.d.ts +35 -0
- package/lib/webrtc/src/media/sender/pendingRtp.js +120 -0
- package/lib/webrtc/src/media/sender/pendingRtp.js.map +1 -0
- package/lib/webrtc/src/media/sender/rtpWire.d.ts +13 -0
- package/lib/webrtc/src/media/sender/rtpWire.js +38 -0
- package/lib/webrtc/src/media/sender/rtpWire.js.map +1 -0
- package/lib/webrtc/src/media/sender/sendPacer.d.ts +27 -0
- package/lib/webrtc/src/media/sender/sendPacer.js +110 -0
- package/lib/webrtc/src/media/sender/sendPacer.js.map +1 -0
- package/lib/webrtc/src/media/sender/senderBWE.d.ts +8 -33
- package/lib/webrtc/src/media/sender/senderBWE.js +5 -154
- package/lib/webrtc/src/media/sender/senderBWE.js.map +1 -1
- package/lib/webrtc/src/media/sender/senderReportHistory.d.ts +51 -0
- package/lib/webrtc/src/media/sender/senderReportHistory.js +111 -0
- package/lib/webrtc/src/media/sender/senderReportHistory.js.map +1 -0
- package/lib/webrtc/src/media/sender/senderStats.d.ts +101 -0
- package/lib/webrtc/src/media/sender/senderStats.js +317 -0
- package/lib/webrtc/src/media/sender/senderStats.js.map +1 -0
- package/lib/webrtc/src/media/track.d.ts +29 -2
- package/lib/webrtc/src/media/track.js +32 -5
- package/lib/webrtc/src/media/track.js.map +1 -1
- package/lib/webrtc/src/negotiation/bundleTopology.d.ts +1 -5
- package/lib/webrtc/src/negotiation/bundleTopology.js +15 -11
- package/lib/webrtc/src/negotiation/bundleTopology.js.map +1 -1
- package/lib/webrtc/src/negotiation/descriptionValidation.js +12 -6
- package/lib/webrtc/src/negotiation/descriptionValidation.js.map +1 -1
- package/lib/webrtc/src/negotiation/negotiationNeeded.js +2 -1
- package/lib/webrtc/src/negotiation/negotiationNeeded.js.map +1 -1
- package/lib/webrtc/src/negotiation/remoteCandidates.js +10 -5
- package/lib/webrtc/src/negotiation/remoteCandidates.js.map +1 -1
- package/lib/webrtc/src/negotiation/remoteMediaApplication.d.ts +24 -7
- package/lib/webrtc/src/negotiation/remoteMediaApplication.js +67 -27
- package/lib/webrtc/src/negotiation/remoteMediaApplication.js.map +1 -1
- package/lib/webrtc/src/negotiation/transceiverPairing.d.ts +1 -0
- package/lib/webrtc/src/negotiation/transceiverPairing.js +62 -0
- package/lib/webrtc/src/negotiation/transceiverPairing.js.map +1 -0
- package/lib/webrtc/src/negotiation/transportActivation.d.ts +8 -1
- package/lib/webrtc/src/negotiation/transportActivation.js +40 -8
- package/lib/webrtc/src/negotiation/transportActivation.js.map +1 -1
- package/lib/webrtc/src/negotiationTransaction.d.ts +43 -5
- package/lib/webrtc/src/negotiationTransaction.js +129 -13
- package/lib/webrtc/src/negotiationTransaction.js.map +1 -1
- package/lib/webrtc/src/nonstandard/dummyMedia.js +2 -1
- package/lib/webrtc/src/nonstandard/dummyMedia.js.map +1 -1
- package/lib/webrtc/src/nonstandard/navigator.js +4 -3
- package/lib/webrtc/src/nonstandard/navigator.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/index.d.ts +32 -8
- package/lib/webrtc/src/nonstandard/recorder/index.js +81 -20
- package/lib/webrtc/src/nonstandard/recorder/index.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/index.d.ts +9 -7
- package/lib/webrtc/src/nonstandard/recorder/writer/index.js +2 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/index.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/ogg.d.ts +32 -0
- package/lib/webrtc/src/nonstandard/recorder/writer/ogg.js +185 -0
- package/lib/webrtc/src/nonstandard/recorder/writer/ogg.js.map +1 -0
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js +8 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js.map +1 -1
- package/lib/webrtc/src/nonstandard/userMedia.js +2 -1
- package/lib/webrtc/src/nonstandard/userMedia.js.map +1 -1
- package/lib/webrtc/src/peerConnection.d.ts +108 -6
- package/lib/webrtc/src/peerConnection.js +357 -36
- package/lib/webrtc/src/peerConnection.js.map +1 -1
- package/lib/webrtc/src/polyfill/globals.d.ts +2 -1
- package/lib/webrtc/src/polyfill/globals.js.map +1 -1
- package/lib/webrtc/src/polyfill/install.js +2 -0
- package/lib/webrtc/src/polyfill/install.js.map +1 -1
- package/lib/webrtc/src/polyfill/mediaDevices.js +2 -1
- package/lib/webrtc/src/polyfill/mediaDevices.js.map +1 -1
- package/lib/webrtc/src/sctpManager.d.ts +46 -14
- package/lib/webrtc/src/sctpManager.js +92 -25
- package/lib/webrtc/src/sctpManager.js.map +1 -1
- package/lib/webrtc/src/sdp.d.ts +69 -0
- package/lib/webrtc/src/sdp.js +151 -20
- package/lib/webrtc/src/sdp.js.map +1 -1
- package/lib/webrtc/src/sdpManager.d.ts +85 -4
- package/lib/webrtc/src/sdpManager.js +214 -14
- package/lib/webrtc/src/sdpManager.js.map +1 -1
- package/lib/webrtc/src/secureTransportManager.d.ts +89 -4
- package/lib/webrtc/src/secureTransportManager.js +184 -26
- package/lib/webrtc/src/secureTransportManager.js.map +1 -1
- package/lib/webrtc/src/transceiverManager.d.ts +82 -4
- package/lib/webrtc/src/transceiverManager.js +239 -41
- package/lib/webrtc/src/transceiverManager.js.map +1 -1
- package/lib/webrtc/src/transport/dtls.d.ts +147 -1
- package/lib/webrtc/src/transport/dtls.js +446 -50
- package/lib/webrtc/src/transport/dtls.js.map +1 -1
- package/lib/webrtc/src/transport/ice.d.ts +71 -90
- package/lib/webrtc/src/transport/ice.js +250 -42
- package/lib/webrtc/src/transport/ice.js.map +1 -1
- package/lib/webrtc/src/transport/sctp.d.ts +25 -0
- package/lib/webrtc/src/transport/sctp.js +153 -22
- package/lib/webrtc/src/transport/sctp.js.map +1 -1
- package/lib/webrtc/src/utils.d.ts +69 -3
- package/lib/webrtc/src/utils.js +105 -16
- package/lib/webrtc/src/utils.js.map +1 -1
- package/package.json +9 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../../dtls/src/server.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AACvD,qDAAkD;AAClD,qDAAkD;AAClD,qDAAkD;AAClD,6CAAkD;AAClD,4DAA+D;AAC/D,6CAAyC;AAEzC,qCAAoD;AAEpD,MAAM,GAAG,GAAG,IAAA,cAAK,EAAC,iDAAiD,CAAC,CAAC;AAErE,MAAa,UAAW,SAAQ,mBAAU;IACxC,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,EAAE,sBAAW,CAAC,MAAM,CAAC,CAAC;QAK7B;;;;;WAAkB;Q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AAK,QAAQ,CAAC,CAAC;gCAC7D,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,CAC3B,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,CACnD,CAAC;gCACF,wDAAwD;gCACxD,IAAI,IAAI,CAAC,gBAAgB;oCAAE,OAAO;gCAClC,IACE,IAAI,CAAC,OAAO,CAAC,uBAAuB;oCACpC,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAC9B,CAAC;oCACD,gEAAgE;oCAChE,IAAI,CAAC,uBAAuB,EAAE,CAAC;oCAC/B,OAAO;gCACT,CAAC;gCACD,MAAM,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC;gCAC3B,IAAI,IAAI,CAAC,gBAAgB;oCAAE,OAAO;gCAElC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;gCACtB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;gCAC5B,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;4BAC7C,CAAC;4BACD,MAAM;oBACV,CAAC;gBACH,CAAC;YACH,CAAC;WAAC;QApGA,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAChD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;IAC3C,CAAC;CAmGF;AAxGD,gCAwGC","sourcesContent":["import { SessionType } from \"./cipher/suites/abstract\";\nimport { flight2 } from \"./flight/server/flight2\";\nimport { Flight4 } from \"./flight/server/flight4\";\nimport { Flight6 } from \"./flight/server/flight6\";\nimport { HandshakeType } from \"./handshake/const\";\nimport { ClientHello } from \"./handshake/message/client/hello\";\nimport { debug } from \"./imports/common\";\nimport type { FragmentedHandshake } from \"./record/message/fragment\";\nimport { DtlsSocket, type Options } from \"./socket\";\n\nconst log = debug(\"werift-dtls : packages/dtls/src/server.ts : log\");\n\nexport class DtlsServer extends DtlsSocket {\n constructor(options: Options) {\n super(options, SessionType.SERVER);\n this.onHandleHandshakes = this.handleHandshakes;\n log(this.dtls.sessionId, \"start server\");\n }\n\n private flight6?: Flight6;\n private handleHandshakes = async (assembled: FragmentedHandshake[]) => {\n log(\n this.dtls.sessionId,\n \"handleHandshakes\",\n assembled.map((a) => a.msg_type),\n );\n\n for (const handshake of assembled) {\n if (this.handshakeStopped) return;\n switch (handshake.msg_type) {\n // flight1,3\n case HandshakeType.client_hello_1:\n {\n if (this.connected) {\n this.renegotiation();\n }\n const clientHello = ClientHello.deSerialize(handshake.fragment);\n\n if (clientHello.cookie.length === 0) {\n log(this.dtls.sessionId, \"send flight2\");\n flight2(\n this.transport,\n this.dtls,\n this.cipher,\n this.srtp,\n )(clientHello);\n } else if (\n this.dtls.cookie &&\n clientHello.cookie.equals(this.dtls.cookie)\n ) {\n log(this.dtls.sessionId, \"send flight4\");\n await new Flight4(\n this.transport,\n this.dtls,\n this.cipher,\n this.srtp,\n ).exec(handshake, clientHello, this.options.certificateRequest);\n } else {\n log(\"wrong state\", {\n dtlsCookie: this.dtls.cookie?.toString(\"hex\").slice(10),\n helloCookie: clientHello.cookie.toString(\"hex\").slice(10),\n });\n }\n }\n break;\n // flight 5\n case HandshakeType.certificate_11:\n case HandshakeType.certificate_verify_15:\n case HandshakeType.client_key_exchange_16:\n {\n if (this.connected) return;\n this.flight6 = new Flight6(this.transport, this.dtls, this.cipher);\n this.flight6.handleHandshake(handshake);\n // Reject the client certificate before our Finished is sent.\n if (\n handshake.msg_type === HandshakeType.certificate_11 &&\n !this.verifyRemoteCertificate()\n ) {\n return;\n }\n }\n break;\n case HandshakeType.finished_20:\n {\n await this.waitForReady(() => !!this.flight6);\n this.flight6?.handleHandshake(handshake);\n\n const requiredHandshakes = [\n 16,\n this.options.certificateRequest && 11,\n this.options.certificateRequest && 15,\n ].filter((type): type is number => typeof type === \"number\");\n await this.waitForReady(() =>\n this.dtls.checkHandshakesExist(requiredHandshakes),\n );\n // The certificate may have been rejected while waiting.\n if (this.handshakeStopped) return;\n if (\n this.options.verifyRemoteCertificate &&\n !this.cipher.remoteCertificate\n ) {\n // A verifier needs the client certificate (certificateRequest).\n this.verifyRemoteCertificate();\n return;\n }\n await this.flight6?.exec();\n if (this.handshakeStopped) return;\n\n this.connected = true;\n this.notify(this.onConnect);\n log(this.dtls.sessionId, \"dtls connected\");\n }\n break;\n }\n }\n };\n}\n"]}
|
package/lib/dtls/src/socket.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type DtlsAlert } from "./alert";
|
|
1
2
|
import { type SignatureHash } from "./cipher/const";
|
|
2
3
|
import { type SessionTypes } from "./cipher/suites/abstract";
|
|
3
4
|
import { CipherContext } from "./context/cipher";
|
|
@@ -7,15 +8,26 @@ import { TransportContext } from "./context/transport";
|
|
|
7
8
|
import type { Address, Transport } from "./imports/common";
|
|
8
9
|
import { Event } from "./imports/common";
|
|
9
10
|
import type { SrtpProfile } from "./imports/rtp";
|
|
11
|
+
import { AlertDesc, AlertLevel } from "./record/const";
|
|
10
12
|
import { FragmentedHandshake } from "./record/message/fragment";
|
|
11
13
|
import type { Extension } from "./typings/domain";
|
|
12
14
|
export declare class DtlsSocket {
|
|
15
|
+
/** Default upper bound (ms) for waiting until an alert has been sent. */
|
|
16
|
+
static AlertSendTimeoutMs: number;
|
|
13
17
|
options: Options;
|
|
14
18
|
sessionType: SessionTypes;
|
|
15
19
|
readonly onConnect: Event<any[]>;
|
|
16
20
|
readonly onData: Event<[Buffer<ArrayBufferLike>]>;
|
|
21
|
+
/**
|
|
22
|
+
* Fires with a {@link DtlsAlertError} when the connection ends with a fatal
|
|
23
|
+
* alert (received from the peer, or sent by this side when it rejected the
|
|
24
|
+
* peer certificate), and with other errors raised by the handshake.
|
|
25
|
+
*/
|
|
17
26
|
readonly onError: Event<[Error]>;
|
|
27
|
+
/** Fires once when the peer closed the connection with close_notify. */
|
|
18
28
|
readonly onClose: Event<any[]>;
|
|
29
|
+
/** Fires for every alert received from the peer (before onClose / onError). */
|
|
30
|
+
readonly onAlert: Event<[DtlsAlert]>;
|
|
19
31
|
readonly transport: TransportContext;
|
|
20
32
|
cipher: CipherContext;
|
|
21
33
|
dtls: DtlsContext;
|
|
@@ -24,15 +36,125 @@ export declare class DtlsSocket {
|
|
|
24
36
|
extensions: Extension[];
|
|
25
37
|
onHandleHandshakes: (assembled: FragmentedHandshake[]) => Promise<void>;
|
|
26
38
|
private bufferFragmentedHandshakes;
|
|
39
|
+
/** close_notify or a fatal alert was sent: no record is sent any more. */
|
|
40
|
+
private alertSent;
|
|
41
|
+
/** The alert that is being sent (shared with concurrent close calls). */
|
|
42
|
+
private alertSending?;
|
|
43
|
+
/**
|
|
44
|
+
* The connection ended (close_notify / fatal alert sent or received, or
|
|
45
|
+
* close()): received records are no longer processed.
|
|
46
|
+
*/
|
|
47
|
+
private ended;
|
|
27
48
|
constructor(options: Options, sessionType: SessionTypes);
|
|
28
49
|
renegotiation(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Resolves once the alert being sent (e.g. the close_notify answering the
|
|
52
|
+
* peer's) has been handed to the transport or timed out. Resolves
|
|
53
|
+
* immediately when none is in flight. Never rejects.
|
|
54
|
+
*/
|
|
55
|
+
alertFlushed(): Promise<void>;
|
|
56
|
+
/** Whether the connection ended (alert, or close()). */
|
|
57
|
+
get terminated(): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Whether the handshake must not go on: the connection ended, or this side
|
|
60
|
+
* sent close_notify (RFC 5246 §7.2.1: nothing is sent after it, so a
|
|
61
|
+
* handshake that would answer or complete stops; records received after it
|
|
62
|
+
* are still processed, to receive the peer's close_notify).
|
|
63
|
+
*/
|
|
64
|
+
protected get handshakeStopped(): boolean;
|
|
29
65
|
private udpOnMessage;
|
|
66
|
+
/**
|
|
67
|
+
* Run the listeners of an event this socket reports, each isolated
|
|
68
|
+
* (`Event.executeIsolated`): a listener's exception is logged, so an
|
|
69
|
+
* application listener can never interrupt the socket's own processing
|
|
70
|
+
* (ending the connection, closing the transport, the receive loop) nor
|
|
71
|
+
* skip a listener registered after it.
|
|
72
|
+
*/
|
|
73
|
+
protected notify<T extends any[]>(event: Event<T>, ...args: T): void;
|
|
74
|
+
/**
|
|
75
|
+
* RFC 5246 §7.2: react to an alert received from the peer. The connection
|
|
76
|
+
* is ended (flights stopped, close_notify answered or the transport
|
|
77
|
+
* closed) before any listener runs, and each notification is isolated, so
|
|
78
|
+
* a throwing listener does not leave the socket ended but unreported.
|
|
79
|
+
*/
|
|
80
|
+
private handleAlert;
|
|
81
|
+
/**
|
|
82
|
+
* Send an alert to the peer, protected with the current epoch (plaintext
|
|
83
|
+
* before ChangeCipherSpec, encrypted after it).
|
|
84
|
+
*
|
|
85
|
+
* Resolves once the transport has sent the record, or after `timeoutMs`
|
|
86
|
+
* (default {@link DtlsSocket.AlertSendTimeoutMs}). It never rejects: a
|
|
87
|
+
* failed send is only logged. Nothing is sent once close_notify or a fatal
|
|
88
|
+
* alert has been sent or the transport is closed. Sending close_notify or a
|
|
89
|
+
* fatal alert also stops the handshake flights (no retransmission). The
|
|
90
|
+
* record is handed to the transport synchronously, so closing the socket
|
|
91
|
+
* right after calling this does not drop it.
|
|
92
|
+
*
|
|
93
|
+
* A fatal alert ends the connection like a fatal error this side detected
|
|
94
|
+
* itself: `onError` fires synchronously with a local {@link DtlsAlertError},
|
|
95
|
+
* and the transport is closed once the alert has been sent (the returned
|
|
96
|
+
* promise resolves after that).
|
|
97
|
+
*/
|
|
98
|
+
sendAlert(level: AlertLevel, description: AlertDesc, options?: {
|
|
99
|
+
timeoutMs?: number;
|
|
100
|
+
}): Promise<void>;
|
|
101
|
+
/** Encode, protect and send one alert record (see {@link sendAlert}). */
|
|
102
|
+
private transmitAlert;
|
|
103
|
+
/**
|
|
104
|
+
* Abort the handshake (or the connection) because this side detected a
|
|
105
|
+
* fatal error: see {@link endWithFatalAlert}.
|
|
106
|
+
*/
|
|
107
|
+
protected abortWithFatalAlert(description: AlertDesc, reason?: unknown): void;
|
|
108
|
+
/**
|
|
109
|
+
* The single ending path for a fatal alert sent by this side (the public
|
|
110
|
+
* {@link sendAlert} and an internal abort): send the alert, stop the
|
|
111
|
+
* flights, report a local {@link DtlsAlertError} on onError (once), and
|
|
112
|
+
* close the transport once the alert has been sent or timed out. Does
|
|
113
|
+
* nothing more once the connection already ended.
|
|
114
|
+
*/
|
|
115
|
+
private endWithFatalAlert;
|
|
116
|
+
/**
|
|
117
|
+
* Call `options.verifyRemoteCertificate` with the received peer
|
|
118
|
+
* certificate. When it returns false or throws, the handshake is aborted
|
|
119
|
+
* with a fatal bad_certificate alert and false is returned.
|
|
120
|
+
*/
|
|
121
|
+
protected verifyRemoteCertificate(): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Close the transport (once; concurrent callers share the same close) and
|
|
124
|
+
* resolve when it has closed. A failure (a rejection or a synchronous
|
|
125
|
+
* throw of the transport's close()) is only logged: it never interrupts
|
|
126
|
+
* the caller, e.g. the onError notification of a received fatal alert.
|
|
127
|
+
*/
|
|
128
|
+
private closeTransport;
|
|
30
129
|
private setupExtensions;
|
|
31
130
|
protected waitForReady: (condition: () => boolean) => Promise<void>;
|
|
32
131
|
handleFragmentHandshake(messages: FragmentedHandshake[]): FragmentedHandshake[];
|
|
33
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* send application data. Nothing is sent once close_notify or a fatal
|
|
134
|
+
* alert has been sent or received.
|
|
135
|
+
*/
|
|
34
136
|
send: (buf: Buffer, addr?: Address) => Promise<void>;
|
|
35
|
-
|
|
137
|
+
/**
|
|
138
|
+
* Close the socket: received records are no longer processed and a
|
|
139
|
+
* handshake flight stops retransmitting.
|
|
140
|
+
*
|
|
141
|
+
* - `close()`: sends no alert of its own and closes the transport right
|
|
142
|
+
* away, except that an alert already being sent (`sendAlert()`, the
|
|
143
|
+
* close_notify answering the peer's) is let through first: the transport
|
|
144
|
+
* closes once it has been sent or timed out.
|
|
145
|
+
* - `close({ notify: true })`: sends close_notify first and closes the
|
|
146
|
+
* transport once it has been sent, or after `timeoutMs`
|
|
147
|
+
* (default {@link DtlsSocket.AlertSendTimeoutMs}).
|
|
148
|
+
*
|
|
149
|
+
* The returned promise resolves once the transport is closed (also when
|
|
150
|
+
* the close was already started, e.g. after a fatal alert: it waits for
|
|
151
|
+
* that close) and never rejects; a failing transport close() (a rejection
|
|
152
|
+
* or a synchronous throw) is only logged.
|
|
153
|
+
*/
|
|
154
|
+
close(options?: {
|
|
155
|
+
notify?: boolean;
|
|
156
|
+
timeoutMs?: number;
|
|
157
|
+
}): Promise<void>;
|
|
36
158
|
extractSessionKeys(keyLength: number, saltLength: number): {
|
|
37
159
|
localKey: Buffer<ArrayBufferLike>;
|
|
38
160
|
localSalt: Buffer<ArrayBufferLike>;
|
|
@@ -50,4 +172,14 @@ export interface Options {
|
|
|
50
172
|
signatureHash?: SignatureHash;
|
|
51
173
|
certificateRequest?: boolean;
|
|
52
174
|
extendedMasterSecret?: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* Verify the peer certificate (DER) during the handshake. Returning false
|
|
177
|
+
* or throwing aborts the handshake with a fatal bad_certificate alert, so
|
|
178
|
+
* the peer learns the failure before it considers the connection
|
|
179
|
+
* established: the client checks the server certificate before sending
|
|
180
|
+
* flight 5, the server checks the client certificate before sending its
|
|
181
|
+
* Finished. onError receives a {@link DtlsAlertError} with
|
|
182
|
+
* `source: "local"`.
|
|
183
|
+
*/
|
|
184
|
+
verifyRemoteCertificate?: (certificate: Buffer) => boolean;
|
|
53
185
|
}
|
package/lib/dtls/src/socket.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DtlsSocket = void 0;
|
|
4
4
|
const promises_1 = require("timers/promises");
|
|
5
|
+
const alert_1 = require("./alert");
|
|
5
6
|
const const_1 = require("./cipher/const");
|
|
6
7
|
const prf_1 = require("./cipher/prf");
|
|
7
8
|
const abstract_1 = require("./cipher/suites/abstract");
|
|
@@ -28,13 +29,13 @@ class DtlsSocket {
|
|
|
28
29
|
enumerable: true,
|
|
29
30
|
configurable: true,
|
|
30
31
|
writable: true,
|
|
31
|
-
value:
|
|
32
|
+
value: void 0
|
|
32
33
|
});
|
|
33
34
|
Object.defineProperty(this, "sessionType", {
|
|
34
35
|
enumerable: true,
|
|
35
36
|
configurable: true,
|
|
36
37
|
writable: true,
|
|
37
|
-
value:
|
|
38
|
+
value: void 0
|
|
38
39
|
});
|
|
39
40
|
Object.defineProperty(this, "onConnect", {
|
|
40
41
|
enumerable: true,
|
|
@@ -48,18 +49,31 @@ class DtlsSocket {
|
|
|
48
49
|
writable: true,
|
|
49
50
|
value: new common_1.Event()
|
|
50
51
|
});
|
|
52
|
+
/**
|
|
53
|
+
* Fires with a {@link DtlsAlertError} when the connection ends with a fatal
|
|
54
|
+
* alert (received from the peer, or sent by this side when it rejected the
|
|
55
|
+
* peer certificate), and with other errors raised by the handshake.
|
|
56
|
+
*/
|
|
51
57
|
Object.defineProperty(this, "onError", {
|
|
52
58
|
enumerable: true,
|
|
53
59
|
configurable: true,
|
|
54
60
|
writable: true,
|
|
55
61
|
value: new common_1.Event()
|
|
56
62
|
});
|
|
63
|
+
/** Fires once when the peer closed the connection with close_notify. */
|
|
57
64
|
Object.defineProperty(this, "onClose", {
|
|
58
65
|
enumerable: true,
|
|
59
66
|
configurable: true,
|
|
60
67
|
writable: true,
|
|
61
68
|
value: new common_1.Event()
|
|
62
69
|
});
|
|
70
|
+
/** Fires for every alert received from the peer (before onClose / onError). */
|
|
71
|
+
Object.defineProperty(this, "onAlert", {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
configurable: true,
|
|
74
|
+
writable: true,
|
|
75
|
+
value: new common_1.Event()
|
|
76
|
+
});
|
|
63
77
|
Object.defineProperty(this, "transport", {
|
|
64
78
|
enumerable: true,
|
|
65
79
|
configurable: true,
|
|
@@ -108,19 +122,65 @@ class DtlsSocket {
|
|
|
108
122
|
writable: true,
|
|
109
123
|
value: []
|
|
110
124
|
});
|
|
125
|
+
/** close_notify or a fatal alert was sent: no record is sent any more. */
|
|
126
|
+
Object.defineProperty(this, "alertSent", {
|
|
127
|
+
enumerable: true,
|
|
128
|
+
configurable: true,
|
|
129
|
+
writable: true,
|
|
130
|
+
value: false
|
|
131
|
+
});
|
|
132
|
+
/** The alert that is being sent (shared with concurrent close calls). */
|
|
133
|
+
Object.defineProperty(this, "alertSending", {
|
|
134
|
+
enumerable: true,
|
|
135
|
+
configurable: true,
|
|
136
|
+
writable: true,
|
|
137
|
+
value: void 0
|
|
138
|
+
});
|
|
139
|
+
/**
|
|
140
|
+
* The connection ended (close_notify / fatal alert sent or received, or
|
|
141
|
+
* close()): received records are no longer processed.
|
|
142
|
+
*/
|
|
143
|
+
Object.defineProperty(this, "ended", {
|
|
144
|
+
enumerable: true,
|
|
145
|
+
configurable: true,
|
|
146
|
+
writable: true,
|
|
147
|
+
value: false
|
|
148
|
+
});
|
|
111
149
|
Object.defineProperty(this, "udpOnMessage", {
|
|
112
150
|
enumerable: true,
|
|
113
151
|
configurable: true,
|
|
114
152
|
writable: true,
|
|
115
153
|
value: (data) => {
|
|
154
|
+
if (this.ended)
|
|
155
|
+
return;
|
|
116
156
|
const packets = (0, receive_1.parsePacket)(data);
|
|
117
157
|
for (const packet of packets) {
|
|
158
|
+
// An alert earlier in this datagram may have ended the connection.
|
|
159
|
+
if (this.ended)
|
|
160
|
+
return;
|
|
118
161
|
try {
|
|
119
162
|
const messages = (0, receive_1.parsePlainText)(this.dtls, this.cipher)(packet);
|
|
120
163
|
for (const message of messages) {
|
|
164
|
+
// An alert earlier in this record (e.g. close_notify followed by a
|
|
165
|
+
// fatal alert) may have ended the connection: the rest is ignored.
|
|
166
|
+
if (this.ended)
|
|
167
|
+
return;
|
|
121
168
|
switch (message.type) {
|
|
122
169
|
case const_2.ContentType.handshake:
|
|
123
170
|
{
|
|
171
|
+
// Once the handshake completed, a handshake record of an
|
|
172
|
+
// epoch older than the peer's authenticated one (a plaintext
|
|
173
|
+
// epoch-0 Certificate, ClientHello, ...) is unauthenticated:
|
|
174
|
+
// anyone on the path can inject it, so it must not change
|
|
175
|
+
// the session (overwrite the peer certificate and fail its
|
|
176
|
+
// check, or reset the session through renegotiation()). It
|
|
177
|
+
// is dropped. A legitimate retransmission of the peer's last
|
|
178
|
+
// flight still carries its Finished at the current epoch.
|
|
179
|
+
if (this.connected &&
|
|
180
|
+
packet.recordLayerHeader.epoch < this.dtls.remoteEpoch) {
|
|
181
|
+
log(this.dtls.sessionId, "drop a stale-epoch handshake record after the handshake", packet.recordLayerHeader.epoch);
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
124
184
|
const handshake = message.data;
|
|
125
185
|
const handshakes = this.handleFragmentHandshake([handshake]);
|
|
126
186
|
const assembled = Object.values(handshakes.reduce((acc, cur) => {
|
|
@@ -133,22 +193,24 @@ class DtlsSocket {
|
|
|
133
193
|
.sort((a, b) => a.msg_type - b.msg_type);
|
|
134
194
|
this.onHandleHandshakes(assembled).catch((error) => {
|
|
135
195
|
err(this.dtls.sessionId, "onHandleHandshakes error", error);
|
|
136
|
-
this.onError
|
|
196
|
+
this.notify(this.onError, error);
|
|
137
197
|
});
|
|
138
198
|
}
|
|
139
199
|
break;
|
|
140
200
|
case const_2.ContentType.applicationData:
|
|
141
201
|
{
|
|
142
|
-
this.onData
|
|
202
|
+
this.notify(this.onData, message.data);
|
|
143
203
|
}
|
|
144
204
|
break;
|
|
145
205
|
case const_2.ContentType.alert:
|
|
146
|
-
this.
|
|
206
|
+
this.handleAlert(message.data);
|
|
147
207
|
break;
|
|
148
208
|
}
|
|
149
209
|
}
|
|
150
210
|
}
|
|
151
211
|
catch (error) {
|
|
212
|
+
// An invalid record (e.g. failed to decrypt) is discarded
|
|
213
|
+
// (RFC 6347 §4.1.2.1).
|
|
152
214
|
err(this.dtls.sessionId, "catch udpOnMessage error", error);
|
|
153
215
|
}
|
|
154
216
|
}
|
|
@@ -171,16 +233,25 @@ class DtlsSocket {
|
|
|
171
233
|
f("waitForReady timeout");
|
|
172
234
|
})
|
|
173
235
|
});
|
|
174
|
-
/**
|
|
236
|
+
/**
|
|
237
|
+
* send application data. Nothing is sent once close_notify or a fatal
|
|
238
|
+
* alert has been sent or received.
|
|
239
|
+
*/
|
|
175
240
|
Object.defineProperty(this, "send", {
|
|
176
241
|
enumerable: true,
|
|
177
242
|
configurable: true,
|
|
178
243
|
writable: true,
|
|
179
244
|
value: async (buf, addr) => {
|
|
245
|
+
if (this.alertSent || this.ended) {
|
|
246
|
+
log(this.dtls.sessionId, "drop application data after alert");
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
180
249
|
const pkt = (0, builder_1.createPlaintext)(this.dtls)([{ type: const_2.ContentType.applicationData, fragment: buf }], ++this.dtls.recordSequenceNumber)[0];
|
|
181
250
|
await this.transport.send(this.cipher.encryptPacket(pkt).serialize(), addr);
|
|
182
251
|
}
|
|
183
252
|
});
|
|
253
|
+
this.options = options;
|
|
254
|
+
this.sessionType = sessionType;
|
|
184
255
|
this.dtls = new dtls_1.DtlsContext(this.options, this.sessionType);
|
|
185
256
|
this.cipher = new cipher_1.CipherContext(this.sessionType, this.options.cert, this.options.key, this.options.signatureHash);
|
|
186
257
|
this.transport = new transport_1.TransportContext(this.options.transport);
|
|
@@ -196,6 +267,213 @@ class DtlsSocket {
|
|
|
196
267
|
this.extensions = [];
|
|
197
268
|
this.bufferFragmentedHandshakes = [];
|
|
198
269
|
}
|
|
270
|
+
/**
|
|
271
|
+
* Resolves once the alert being sent (e.g. the close_notify answering the
|
|
272
|
+
* peer's) has been handed to the transport or timed out. Resolves
|
|
273
|
+
* immediately when none is in flight. Never rejects.
|
|
274
|
+
*/
|
|
275
|
+
alertFlushed() {
|
|
276
|
+
return this.alertSending ?? Promise.resolve();
|
|
277
|
+
}
|
|
278
|
+
/** Whether the connection ended (alert, or close()). */
|
|
279
|
+
get terminated() {
|
|
280
|
+
return this.ended;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Whether the handshake must not go on: the connection ended, or this side
|
|
284
|
+
* sent close_notify (RFC 5246 §7.2.1: nothing is sent after it, so a
|
|
285
|
+
* handshake that would answer or complete stops; records received after it
|
|
286
|
+
* are still processed, to receive the peer's close_notify).
|
|
287
|
+
*/
|
|
288
|
+
get handshakeStopped() {
|
|
289
|
+
return this.ended || this.alertSent;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Run the listeners of an event this socket reports, each isolated
|
|
293
|
+
* (`Event.executeIsolated`): a listener's exception is logged, so an
|
|
294
|
+
* application listener can never interrupt the socket's own processing
|
|
295
|
+
* (ending the connection, closing the transport, the receive loop) nor
|
|
296
|
+
* skip a listener registered after it.
|
|
297
|
+
*/
|
|
298
|
+
notify(event, ...args) {
|
|
299
|
+
// Per listener: one that throws neither skips the later listeners (e.g.
|
|
300
|
+
// werift's own, if the application subscribed first) nor this socket.
|
|
301
|
+
event.executeIsolated((error) => err(this.dtls.sessionId, "event listener failed", error), ...args);
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* RFC 5246 §7.2: react to an alert received from the peer. The connection
|
|
305
|
+
* is ended (flights stopped, close_notify answered or the transport
|
|
306
|
+
* closed) before any listener runs, and each notification is isolated, so
|
|
307
|
+
* a throwing listener does not leave the socket ended but unreported.
|
|
308
|
+
*/
|
|
309
|
+
handleAlert(alert) {
|
|
310
|
+
const action = (0, alert_1.classifyAlert)(alert);
|
|
311
|
+
if (action === "ignore") {
|
|
312
|
+
log(this.dtls.sessionId, "ignore warning alert", alert);
|
|
313
|
+
this.notify(this.onAlert, alert);
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
this.ended = true;
|
|
317
|
+
// Retransmitting a handshake flight makes no sense any more.
|
|
318
|
+
this.transport.stopFlights();
|
|
319
|
+
if (action === "close") {
|
|
320
|
+
log(this.dtls.sessionId, "received close_notify");
|
|
321
|
+
// RFC 5246 §7.2.1: respond with close_notify; nothing is sent after it.
|
|
322
|
+
void this.sendAlert(const_2.AlertLevel.warning, const_2.AlertDesc.CloseNotify);
|
|
323
|
+
// The connection is over: the socket closes its transport once the
|
|
324
|
+
// reply has been sent or timed out, like after a fatal alert (the
|
|
325
|
+
// application does not need to call close()).
|
|
326
|
+
void this.alertFlushed().then(() => this.closeTransport());
|
|
327
|
+
this.notify(this.onAlert, alert);
|
|
328
|
+
this.notify(this.onClose);
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
err(this.dtls.sessionId, "received fatal alert", alert);
|
|
332
|
+
// A fatal alert is not answered (RFC 5246 §7.2.2).
|
|
333
|
+
this.alertSent = true;
|
|
334
|
+
this.closeTransport();
|
|
335
|
+
this.notify(this.onAlert, alert);
|
|
336
|
+
this.notify(this.onError, new alert_1.DtlsAlertError(alert, "remote"));
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Send an alert to the peer, protected with the current epoch (plaintext
|
|
341
|
+
* before ChangeCipherSpec, encrypted after it).
|
|
342
|
+
*
|
|
343
|
+
* Resolves once the transport has sent the record, or after `timeoutMs`
|
|
344
|
+
* (default {@link DtlsSocket.AlertSendTimeoutMs}). It never rejects: a
|
|
345
|
+
* failed send is only logged. Nothing is sent once close_notify or a fatal
|
|
346
|
+
* alert has been sent or the transport is closed. Sending close_notify or a
|
|
347
|
+
* fatal alert also stops the handshake flights (no retransmission). The
|
|
348
|
+
* record is handed to the transport synchronously, so closing the socket
|
|
349
|
+
* right after calling this does not drop it.
|
|
350
|
+
*
|
|
351
|
+
* A fatal alert ends the connection like a fatal error this side detected
|
|
352
|
+
* itself: `onError` fires synchronously with a local {@link DtlsAlertError},
|
|
353
|
+
* and the transport is closed once the alert has been sent (the returned
|
|
354
|
+
* promise resolves after that).
|
|
355
|
+
*/
|
|
356
|
+
sendAlert(level, description, options = {}) {
|
|
357
|
+
if (level === const_2.AlertLevel.fatal) {
|
|
358
|
+
return this.endWithFatalAlert(description, undefined, options);
|
|
359
|
+
}
|
|
360
|
+
return this.transmitAlert(level, description, options);
|
|
361
|
+
}
|
|
362
|
+
/** Encode, protect and send one alert record (see {@link sendAlert}). */
|
|
363
|
+
transmitAlert(level, description, options) {
|
|
364
|
+
if (this.alertSent || this.transport.closed) {
|
|
365
|
+
// A concurrent caller waits for the alert that is still being sent.
|
|
366
|
+
return this.alertSending ?? Promise.resolve();
|
|
367
|
+
}
|
|
368
|
+
if (level === const_2.AlertLevel.fatal || description === const_2.AlertDesc.CloseNotify) {
|
|
369
|
+
this.alertSent = true;
|
|
370
|
+
// A terminating alert ends the handshake too: no handshake flight is
|
|
371
|
+
// sent or retransmitted after it.
|
|
372
|
+
this.transport.stopFlights();
|
|
373
|
+
}
|
|
374
|
+
if (level === const_2.AlertLevel.fatal) {
|
|
375
|
+
this.ended = true;
|
|
376
|
+
}
|
|
377
|
+
let sending;
|
|
378
|
+
try {
|
|
379
|
+
const record = (0, alert_1.createAlertRecord)(this.dtls, this.cipher, {
|
|
380
|
+
level,
|
|
381
|
+
description,
|
|
382
|
+
});
|
|
383
|
+
log(this.dtls.sessionId, "send alert", {
|
|
384
|
+
level,
|
|
385
|
+
description,
|
|
386
|
+
epoch: this.dtls.epoch,
|
|
387
|
+
sequenceNumber: this.dtls.recordSequenceNumber,
|
|
388
|
+
});
|
|
389
|
+
sending = this.transport.send(record);
|
|
390
|
+
}
|
|
391
|
+
catch (error) {
|
|
392
|
+
err(this.dtls.sessionId, "failed to send alert", error);
|
|
393
|
+
return Promise.resolve();
|
|
394
|
+
}
|
|
395
|
+
const timeoutMs = options.timeoutMs ?? DtlsSocket.AlertSendTimeoutMs;
|
|
396
|
+
const timer = new AbortController();
|
|
397
|
+
const done = Promise.race([
|
|
398
|
+
sending,
|
|
399
|
+
(0, promises_1.setTimeout)(timeoutMs, undefined, { signal: timer.signal }).then(() => {
|
|
400
|
+
log(this.dtls.sessionId, "alert send timeout", timeoutMs);
|
|
401
|
+
}),
|
|
402
|
+
])
|
|
403
|
+
.catch((error) => {
|
|
404
|
+
if (timer.signal.aborted)
|
|
405
|
+
return;
|
|
406
|
+
err(this.dtls.sessionId, "failed to send alert", error);
|
|
407
|
+
})
|
|
408
|
+
.finally(() => timer.abort())
|
|
409
|
+
// A UDP transport hands the datagram to the socket on a later tick
|
|
410
|
+
// (dgram resolves the address asynchronously): closing the socket
|
|
411
|
+
// right after send() resolved would drop the alert.
|
|
412
|
+
.then(() => (0, promises_1.setImmediate)());
|
|
413
|
+
this.alertSending = done;
|
|
414
|
+
return done;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Abort the handshake (or the connection) because this side detected a
|
|
418
|
+
* fatal error: see {@link endWithFatalAlert}.
|
|
419
|
+
*/
|
|
420
|
+
abortWithFatalAlert(description, reason) {
|
|
421
|
+
void this.endWithFatalAlert(description, reason);
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* The single ending path for a fatal alert sent by this side (the public
|
|
425
|
+
* {@link sendAlert} and an internal abort): send the alert, stop the
|
|
426
|
+
* flights, report a local {@link DtlsAlertError} on onError (once), and
|
|
427
|
+
* close the transport once the alert has been sent or timed out. Does
|
|
428
|
+
* nothing more once the connection already ended.
|
|
429
|
+
*/
|
|
430
|
+
endWithFatalAlert(description, reason, options = {}) {
|
|
431
|
+
if (this.ended || this.alertSent || this.transport.closed) {
|
|
432
|
+
return this.alertSending ?? Promise.resolve();
|
|
433
|
+
}
|
|
434
|
+
const sending = this.transmitAlert(const_2.AlertLevel.fatal, description, options);
|
|
435
|
+
this.ended = true;
|
|
436
|
+
this.transport.stopFlights();
|
|
437
|
+
// The transport closes once the alert was sent, whatever a listener does.
|
|
438
|
+
const done = sending.then(() => this.closeTransport());
|
|
439
|
+
this.alertSending = done;
|
|
440
|
+
this.notify(this.onError, new alert_1.DtlsAlertError({ level: const_2.AlertLevel.fatal, description }, "local", reason));
|
|
441
|
+
return done;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Call `options.verifyRemoteCertificate` with the received peer
|
|
445
|
+
* certificate. When it returns false or throws, the handshake is aborted
|
|
446
|
+
* with a fatal bad_certificate alert and false is returned.
|
|
447
|
+
*/
|
|
448
|
+
verifyRemoteCertificate() {
|
|
449
|
+
const verify = this.options.verifyRemoteCertificate;
|
|
450
|
+
if (!verify)
|
|
451
|
+
return true;
|
|
452
|
+
const certificate = this.cipher.remoteCertificate;
|
|
453
|
+
let reason;
|
|
454
|
+
try {
|
|
455
|
+
if (certificate && verify(Buffer.from(certificate))) {
|
|
456
|
+
return true;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
catch (error) {
|
|
460
|
+
reason = error;
|
|
461
|
+
}
|
|
462
|
+
err(this.dtls.sessionId, "remote certificate rejected", reason);
|
|
463
|
+
this.abortWithFatalAlert(const_2.AlertDesc.BadCertificate, reason);
|
|
464
|
+
return false;
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Close the transport (once; concurrent callers share the same close) and
|
|
468
|
+
* resolve when it has closed. A failure (a rejection or a synchronous
|
|
469
|
+
* throw of the transport's close()) is only logged: it never interrupts
|
|
470
|
+
* the caller, e.g. the onError notification of a received fatal alert.
|
|
471
|
+
*/
|
|
472
|
+
closeTransport() {
|
|
473
|
+
return this.transport.close().catch((error) => {
|
|
474
|
+
err(this.dtls.sessionId, "failed to close transport", error);
|
|
475
|
+
});
|
|
476
|
+
}
|
|
199
477
|
setupExtensions() {
|
|
200
478
|
log(this.dtls.sessionId, "support srtpProfiles", this.options.srtpProfiles);
|
|
201
479
|
if (this.options.srtpProfiles && this.options.srtpProfiles.length > 0) {
|
|
@@ -242,8 +520,41 @@ class DtlsSocket {
|
|
|
242
520
|
}
|
|
243
521
|
return handshakes; // return un fragmented handshakes
|
|
244
522
|
}
|
|
245
|
-
|
|
246
|
-
|
|
523
|
+
/**
|
|
524
|
+
* Close the socket: received records are no longer processed and a
|
|
525
|
+
* handshake flight stops retransmitting.
|
|
526
|
+
*
|
|
527
|
+
* - `close()`: sends no alert of its own and closes the transport right
|
|
528
|
+
* away, except that an alert already being sent (`sendAlert()`, the
|
|
529
|
+
* close_notify answering the peer's) is let through first: the transport
|
|
530
|
+
* closes once it has been sent or timed out.
|
|
531
|
+
* - `close({ notify: true })`: sends close_notify first and closes the
|
|
532
|
+
* transport once it has been sent, or after `timeoutMs`
|
|
533
|
+
* (default {@link DtlsSocket.AlertSendTimeoutMs}).
|
|
534
|
+
*
|
|
535
|
+
* The returned promise resolves once the transport is closed (also when
|
|
536
|
+
* the close was already started, e.g. after a fatal alert: it waits for
|
|
537
|
+
* that close) and never rejects; a failing transport close() (a rejection
|
|
538
|
+
* or a synchronous throw) is only logged.
|
|
539
|
+
*/
|
|
540
|
+
async close(options = {}) {
|
|
541
|
+
if (options.notify) {
|
|
542
|
+
const sending = this.sendAlert(const_2.AlertLevel.warning, const_2.AlertDesc.CloseNotify, {
|
|
543
|
+
...(options.timeoutMs !== undefined && {
|
|
544
|
+
timeoutMs: options.timeoutMs,
|
|
545
|
+
}),
|
|
546
|
+
});
|
|
547
|
+
this.ended = true;
|
|
548
|
+
this.transport.stopFlights();
|
|
549
|
+
await sending;
|
|
550
|
+
}
|
|
551
|
+
this.ended = true;
|
|
552
|
+
this.transport.stopFlights();
|
|
553
|
+
// Closing the transport now would drop an alert handed to it but not
|
|
554
|
+
// yet written (a UDP datagram goes out on a later tick).
|
|
555
|
+
await this.alertFlushed();
|
|
556
|
+
// Waits for a close already in progress (e.g. after a fatal alert).
|
|
557
|
+
await this.closeTransport();
|
|
247
558
|
}
|
|
248
559
|
extractSessionKeys(keyLength, saltLength) {
|
|
249
560
|
const keyingMaterial = this.exportKeyingMaterial("EXTRACTOR-dtls_srtp", keyLength * 2 + saltLength * 2);
|
|
@@ -278,4 +589,11 @@ class DtlsSocket {
|
|
|
278
589
|
}
|
|
279
590
|
}
|
|
280
591
|
exports.DtlsSocket = DtlsSocket;
|
|
592
|
+
/** Default upper bound (ms) for waiting until an alert has been sent. */
|
|
593
|
+
Object.defineProperty(DtlsSocket, "AlertSendTimeoutMs", {
|
|
594
|
+
enumerable: true,
|
|
595
|
+
configurable: true,
|
|
596
|
+
writable: true,
|
|
597
|
+
value: 200
|
|
598
|
+
});
|
|
281
599
|
//# sourceMappingURL=socket.js.map
|