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,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RTCDtlsParameters = exports.RTCDtlsFingerprint = exports.RTCCertificate = exports.DtlsStates = exports.RTCDtlsTransport = void 0;
|
|
3
|
+
exports.RTCDtlsParameters = exports.RTCDtlsFingerprint = exports.RTCCertificate = exports.DtlsStates = exports.RTCDtlsTransport = exports.RTCError = exports.DTLS_ALERT_SEND_TIMEOUT_MS = void 0;
|
|
4
4
|
const node_crypto_1 = require("node:crypto");
|
|
5
5
|
const promises_1 = require("timers/promises");
|
|
6
6
|
const helper_1 = require("../helper");
|
|
@@ -9,7 +9,76 @@ const dtls_1 = require("../imports/dtls");
|
|
|
9
9
|
const rtp_1 = require("../imports/rtp");
|
|
10
10
|
const stats_1 = require("../media/stats");
|
|
11
11
|
const utils_1 = require("../utils");
|
|
12
|
+
/**
|
|
13
|
+
* Upper bound (ms) for waiting until close_notify / a fatal alert has been
|
|
14
|
+
* handed to ICE in {@link RTCDtlsTransport.stop}; it adds directly to the
|
|
15
|
+
* time `RTCPeerConnection.close()` takes.
|
|
16
|
+
*/
|
|
17
|
+
exports.DTLS_ALERT_SEND_TIMEOUT_MS = 100;
|
|
18
|
+
/**
|
|
19
|
+
* Minimal `RTCError` (W3C webrtc-pc §10.1) for the DTLS failures that
|
|
20
|
+
* {@link RTCDtlsTransport} reports with its `error` event.
|
|
21
|
+
*
|
|
22
|
+
* - `"fingerprint-failure"`: the remote certificate matched none of the
|
|
23
|
+
* fingerprints of the remote description. `receivedAlert` / `sentAlert` are
|
|
24
|
+
* null, as the spec defines them only for `"dtls-failure"`, although werift
|
|
25
|
+
* still sends a fatal `bad_certificate` (42) to the peer, which in turn
|
|
26
|
+
* reports `"dtls-failure"` with `receivedAlert: 42`.
|
|
27
|
+
* - `"dtls-failure"`: any other DTLS failure, e.g. a fatal alert received
|
|
28
|
+
* (`receivedAlert`) or sent (`sentAlert`).
|
|
29
|
+
*/
|
|
30
|
+
class RTCError extends Error {
|
|
31
|
+
constructor(init, message) {
|
|
32
|
+
super(message);
|
|
33
|
+
Object.defineProperty(this, "errorDetail", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
writable: true,
|
|
37
|
+
value: void 0
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* `"dtls-failure"` only: the fatal alert description received from the
|
|
41
|
+
* peer, otherwise null.
|
|
42
|
+
*/
|
|
43
|
+
Object.defineProperty(this, "receivedAlert", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
configurable: true,
|
|
46
|
+
writable: true,
|
|
47
|
+
value: void 0
|
|
48
|
+
});
|
|
49
|
+
/**
|
|
50
|
+
* `"dtls-failure"` only: the fatal alert description sent to the peer,
|
|
51
|
+
* otherwise null.
|
|
52
|
+
*/
|
|
53
|
+
Object.defineProperty(this, "sentAlert", {
|
|
54
|
+
enumerable: true,
|
|
55
|
+
configurable: true,
|
|
56
|
+
writable: true,
|
|
57
|
+
value: void 0
|
|
58
|
+
});
|
|
59
|
+
this.name = "OperationError";
|
|
60
|
+
this.errorDetail = init.errorDetail;
|
|
61
|
+
this.receivedAlert = init.receivedAlert ?? null;
|
|
62
|
+
this.sentAlert = init.sentAlert ?? null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.RTCError = RTCError;
|
|
12
66
|
const log = (0, rtp_1.debug)("werift:packages/webrtc/src/transport/dtls.ts");
|
|
67
|
+
/**
|
|
68
|
+
* Internal: the remote certificate matched none of the remote fingerprints
|
|
69
|
+
* (reported as `errorDetail: "fingerprint-failure"`). Other verification
|
|
70
|
+
* errors (no certificate, no usable fingerprint) stay `"dtls-failure"`.
|
|
71
|
+
*/
|
|
72
|
+
class FingerprintMismatchError extends Error {
|
|
73
|
+
constructor() {
|
|
74
|
+
super("remote certificate fingerprint mismatch");
|
|
75
|
+
this.name = "FingerprintMismatchError";
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/** The RTCError for a failed check of the remote certificate. */
|
|
79
|
+
const certificateVerificationError = (reason) => reason instanceof FingerprintMismatchError
|
|
80
|
+
? new RTCError({ errorDetail: "fingerprint-failure" }, reason.message)
|
|
81
|
+
: new RTCError({ errorDetail: "dtls-failure", sentAlert: dtls_1.AlertDesc.BadCertificate }, String(reason));
|
|
13
82
|
function formatDtlsVersion(version) {
|
|
14
83
|
if (!version) {
|
|
15
84
|
return;
|
|
@@ -37,25 +106,25 @@ class RTCDtlsTransport {
|
|
|
37
106
|
enumerable: true,
|
|
38
107
|
configurable: true,
|
|
39
108
|
writable: true,
|
|
40
|
-
value:
|
|
109
|
+
value: void 0
|
|
41
110
|
});
|
|
42
111
|
Object.defineProperty(this, "iceTransport", {
|
|
43
112
|
enumerable: true,
|
|
44
113
|
configurable: true,
|
|
45
114
|
writable: true,
|
|
46
|
-
value:
|
|
115
|
+
value: void 0
|
|
47
116
|
});
|
|
48
117
|
Object.defineProperty(this, "localCertificate", {
|
|
49
118
|
enumerable: true,
|
|
50
119
|
configurable: true,
|
|
51
120
|
writable: true,
|
|
52
|
-
value:
|
|
121
|
+
value: void 0
|
|
53
122
|
});
|
|
54
123
|
Object.defineProperty(this, "srtpProfiles", {
|
|
55
124
|
enumerable: true,
|
|
56
125
|
configurable: true,
|
|
57
126
|
writable: true,
|
|
58
|
-
value:
|
|
127
|
+
value: void 0
|
|
59
128
|
});
|
|
60
129
|
Object.defineProperty(this, "id", {
|
|
61
130
|
enumerable: true,
|
|
@@ -93,6 +162,18 @@ class RTCDtlsTransport {
|
|
|
93
162
|
writable: true,
|
|
94
163
|
value: false
|
|
95
164
|
});
|
|
165
|
+
/**
|
|
166
|
+
* Monotonic transport-wide sequence allocated at ICE enqueue time.
|
|
167
|
+
* Never wraps in JS Number. {@link transportSequenceNumber} is the wire
|
|
168
|
+
* 16-bit view (`extended & 0xffff`).
|
|
169
|
+
*/
|
|
170
|
+
Object.defineProperty(this, "transportSequenceNumberExtended", {
|
|
171
|
+
enumerable: true,
|
|
172
|
+
configurable: true,
|
|
173
|
+
writable: true,
|
|
174
|
+
value: 0
|
|
175
|
+
});
|
|
176
|
+
/** Wire 16-bit TWCC sequence (low bits of {@link transportSequenceNumberExtended}). */
|
|
96
177
|
Object.defineProperty(this, "transportSequenceNumber", {
|
|
97
178
|
enumerable: true,
|
|
98
179
|
configurable: true,
|
|
@@ -166,6 +247,17 @@ class RTCDtlsTransport {
|
|
|
166
247
|
writable: true,
|
|
167
248
|
value: new common_1.Event()
|
|
168
249
|
});
|
|
250
|
+
/**
|
|
251
|
+
* Fires once when {@link RTCDtlsTransport.stop} has finished, i.e. ICE has
|
|
252
|
+
* stopped too. The DTLS "closed" state alone (e.g. a received alert) does
|
|
253
|
+
* not mean ICE has released its resources.
|
|
254
|
+
*/
|
|
255
|
+
Object.defineProperty(this, "onStopped", {
|
|
256
|
+
enumerable: true,
|
|
257
|
+
configurable: true,
|
|
258
|
+
writable: true,
|
|
259
|
+
value: new common_1.Event()
|
|
260
|
+
});
|
|
169
261
|
Object.defineProperty(this, "events", {
|
|
170
262
|
enumerable: true,
|
|
171
263
|
configurable: true,
|
|
@@ -178,6 +270,25 @@ class RTCDtlsTransport {
|
|
|
178
270
|
writable: true,
|
|
179
271
|
value: void 0
|
|
180
272
|
});
|
|
273
|
+
/**
|
|
274
|
+
* Fires once when the transport becomes `failed`:
|
|
275
|
+
* - the remote certificate matched none of the remote fingerprints:
|
|
276
|
+
* `errorDetail: "fingerprint-failure"` (`receivedAlert` / `sentAlert`
|
|
277
|
+
* null; a fatal `bad_certificate` is still sent to the peer);
|
|
278
|
+
* - a fatal alert received from the peer, or sent by this side (e.g.
|
|
279
|
+
* `bad_certificate` for a certificate it could not verify for another
|
|
280
|
+
* reason), and other DTLS errors: `errorDetail: "dtls-failure"` with
|
|
281
|
+
* `receivedAlert` / `sentAlert`.
|
|
282
|
+
*
|
|
283
|
+
* A close_notify (`closed`) does not fire it. Also delivered as
|
|
284
|
+
* `addEventListener("error", ...)`.
|
|
285
|
+
*/
|
|
286
|
+
Object.defineProperty(this, "onerror", {
|
|
287
|
+
enumerable: true,
|
|
288
|
+
configurable: true,
|
|
289
|
+
writable: true,
|
|
290
|
+
value: void 0
|
|
291
|
+
});
|
|
181
292
|
Object.defineProperty(this, "remoteParameters", {
|
|
182
293
|
enumerable: true,
|
|
183
294
|
configurable: true,
|
|
@@ -206,6 +317,13 @@ class RTCDtlsTransport {
|
|
|
206
317
|
writable: true,
|
|
207
318
|
value: (event) => this.events.dispatchEvent(event)
|
|
208
319
|
});
|
|
320
|
+
/** Settles a pending start() (set while the handshake is awaited). */
|
|
321
|
+
Object.defineProperty(this, "settleStart", {
|
|
322
|
+
enumerable: true,
|
|
323
|
+
configurable: true,
|
|
324
|
+
writable: true,
|
|
325
|
+
value: void 0
|
|
326
|
+
});
|
|
209
327
|
Object.defineProperty(this, "sendData", {
|
|
210
328
|
enumerable: true,
|
|
211
329
|
configurable: true,
|
|
@@ -221,26 +339,45 @@ class RTCDtlsTransport {
|
|
|
221
339
|
await this.dtls.send(data);
|
|
222
340
|
}
|
|
223
341
|
});
|
|
342
|
+
Object.defineProperty(this, "stopPromise", {
|
|
343
|
+
enumerable: true,
|
|
344
|
+
configurable: true,
|
|
345
|
+
writable: true,
|
|
346
|
+
value: void 0
|
|
347
|
+
});
|
|
348
|
+
this.config = config;
|
|
349
|
+
this.iceTransport = iceTransport;
|
|
350
|
+
this.localCertificate = localCertificate;
|
|
351
|
+
this.srtpProfiles = srtpProfiles;
|
|
224
352
|
this.localCertificate ?? (this.localCertificate = RTCDtlsTransport.localCertificate);
|
|
225
353
|
}
|
|
226
354
|
get localParameters() {
|
|
227
355
|
return new RTCDtlsParameters(this.localCertificate ? this.localCertificate.getFingerprints() : [], this.role);
|
|
228
356
|
}
|
|
357
|
+
/**
|
|
358
|
+
* Generates a new self-signed certificate (ECDSA P-256 / SHA-256) on every call.
|
|
359
|
+
* Used by an RTCPeerConnection created with `certificateScope: "standard"`
|
|
360
|
+
* when `RTCConfiguration.certificates` is not given.
|
|
361
|
+
*/
|
|
362
|
+
static async generateCertificate() {
|
|
363
|
+
const { certPem, keyPem, signatureHash } = await dtls_1.CipherContext.createSelfSignedCertificateWithKey({
|
|
364
|
+
signature: dtls_1.SignatureAlgorithm.ecdsa_3,
|
|
365
|
+
hash: dtls_1.HashAlgorithm.sha256_4,
|
|
366
|
+
}, dtls_1.NamedCurveAlgorithm.secp256r1_23);
|
|
367
|
+
return new RTCCertificate(keyPem, certPem, signatureHash);
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Returns the default certificate cached for the whole process
|
|
371
|
+
* (the default `certificateScope: "process"`).
|
|
372
|
+
*/
|
|
229
373
|
static async SetupCertificate() {
|
|
230
374
|
if (this.localCertificate) {
|
|
231
375
|
return this.localCertificate;
|
|
232
376
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
const { certPem, keyPem, signatureHash } = await dtls_1.CipherContext.createSelfSignedCertificateWithKey({
|
|
238
|
-
signature: dtls_1.SignatureAlgorithm.ecdsa_3,
|
|
239
|
-
hash: dtls_1.HashAlgorithm.sha256_4,
|
|
240
|
-
}, dtls_1.NamedCurveAlgorithm.secp256r1_23);
|
|
241
|
-
this.localCertificate = new RTCCertificate(keyPem, certPem, signatureHash);
|
|
242
|
-
return this.localCertificate;
|
|
243
|
-
})();
|
|
377
|
+
this.localCertificatePromise ?? (this.localCertificatePromise = this.generateCertificate().then((certificate) => {
|
|
378
|
+
this.localCertificate = certificate;
|
|
379
|
+
return certificate;
|
|
380
|
+
}));
|
|
244
381
|
return this.localCertificatePromise;
|
|
245
382
|
}
|
|
246
383
|
setRemoteParams(remoteParameters) {
|
|
@@ -272,7 +409,23 @@ class RTCDtlsTransport {
|
|
|
272
409
|
}
|
|
273
410
|
}
|
|
274
411
|
this.setState("connecting");
|
|
412
|
+
// A connecting listener may have stopped the transport synchronously
|
|
413
|
+
// (stop() ran before any socket existed): start() then ends here,
|
|
414
|
+
// without creating a socket nobody would close, and closed stays.
|
|
415
|
+
// (Narrowed by the check above, the state may have changed meanwhile.)
|
|
416
|
+
if (this.isFinalState) {
|
|
417
|
+
log("stopped while notifying connecting", this.state);
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
// The certificate is checked during the handshake, so that a mismatch is
|
|
421
|
+
// reported to the peer with a fatal bad_certificate alert before either
|
|
422
|
+
// side considers the connection established.
|
|
423
|
+
const verifyRemoteCertificate = (certificate) => {
|
|
424
|
+
this.verifyRemoteCertificateFingerprint(certificate);
|
|
425
|
+
return true;
|
|
426
|
+
};
|
|
275
427
|
await new Promise(async (r, f) => {
|
|
428
|
+
this.settleStart = r;
|
|
276
429
|
if (this.role === "server") {
|
|
277
430
|
this.dtls = new dtls_1.DtlsServer({
|
|
278
431
|
cert: this.localCertificate?.certPem,
|
|
@@ -282,6 +435,7 @@ class RTCDtlsTransport {
|
|
|
282
435
|
srtpProfiles: this.srtpProfiles,
|
|
283
436
|
extendedMasterSecret: true,
|
|
284
437
|
certificateRequest: true,
|
|
438
|
+
verifyRemoteCertificate,
|
|
285
439
|
});
|
|
286
440
|
}
|
|
287
441
|
else {
|
|
@@ -292,6 +446,7 @@ class RTCDtlsTransport {
|
|
|
292
446
|
transport: createIceTransport(this.iceTransport.connection),
|
|
293
447
|
srtpProfiles: this.srtpProfiles,
|
|
294
448
|
extendedMasterSecret: true,
|
|
449
|
+
verifyRemoteCertificate,
|
|
295
450
|
});
|
|
296
451
|
}
|
|
297
452
|
this.dtls.onData.subscribe((buf) => {
|
|
@@ -301,32 +456,77 @@ class RTCDtlsTransport {
|
|
|
301
456
|
}
|
|
302
457
|
this.dataReceiver(buf);
|
|
303
458
|
});
|
|
459
|
+
// close_notify from the peer, also during the handshake: closed (with
|
|
460
|
+
// statechange, the peer caused it; W3C RTCDtlsTransportState "closed").
|
|
461
|
+
// close_notify is not a fatal alert, so neither failed nor an error
|
|
462
|
+
// event. closed / failed are final.
|
|
304
463
|
this.dtls.onClose.subscribe(() => {
|
|
305
|
-
if (this.
|
|
464
|
+
if (this.isFinalState)
|
|
465
|
+
return;
|
|
466
|
+
log("dtls closed by the peer");
|
|
467
|
+
try {
|
|
306
468
|
this.setState("closed");
|
|
307
469
|
}
|
|
470
|
+
finally {
|
|
471
|
+
// Settle start() even if a statechange listener threw: it returns
|
|
472
|
+
// with closed (transport activation then ends a connection attempt
|
|
473
|
+
// that never connected as failed).
|
|
474
|
+
r();
|
|
475
|
+
}
|
|
308
476
|
});
|
|
309
477
|
this.dtls.onConnect.once(r);
|
|
310
|
-
|
|
311
|
-
|
|
478
|
+
// A handshake error, or a fatal alert received or sent while
|
|
479
|
+
// connecting or after the connection was established.
|
|
480
|
+
this.dtls.onError.subscribe((error) => {
|
|
312
481
|
log("dtls failed", error);
|
|
313
|
-
|
|
482
|
+
try {
|
|
483
|
+
this.fail(error);
|
|
484
|
+
}
|
|
485
|
+
finally {
|
|
486
|
+
// Settle start() even if a statechange listener threw. A local
|
|
487
|
+
// certificate rejection rejects with the verifier's error (e.g.
|
|
488
|
+
// "remote certificate fingerprint mismatch").
|
|
489
|
+
f(error instanceof dtls_1.DtlsAlertError &&
|
|
490
|
+
error.source === "local" &&
|
|
491
|
+
error.reason instanceof Error
|
|
492
|
+
? error.reason
|
|
493
|
+
: error);
|
|
494
|
+
}
|
|
314
495
|
});
|
|
315
496
|
if (this.dtls instanceof dtls_1.DtlsClient) {
|
|
316
497
|
await (0, promises_1.setTimeout)(100);
|
|
498
|
+
if (this.isFinalState) {
|
|
499
|
+
// stop() / a failure during the wait: settle start().
|
|
500
|
+
r();
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
317
503
|
this.dtls.connect().catch((error) => {
|
|
318
|
-
this.
|
|
504
|
+
this.fail(error);
|
|
319
505
|
log("dtls connect failed", error);
|
|
320
506
|
f(error);
|
|
321
507
|
});
|
|
322
508
|
}
|
|
323
509
|
});
|
|
510
|
+
// A fatal alert raced with the end of the handshake.
|
|
511
|
+
// (Narrowed by the checks above, the state may have changed meanwhile.)
|
|
512
|
+
const state = this.state;
|
|
513
|
+
if (state === "failed")
|
|
514
|
+
throw new Error("dtls transport failed");
|
|
515
|
+
// stop() raced with the end of the handshake: closed stays.
|
|
516
|
+
if (state === "closed")
|
|
517
|
+
return;
|
|
324
518
|
try {
|
|
325
|
-
|
|
519
|
+
// Fallback: a certificate the in-handshake check did not see.
|
|
520
|
+
this.verifyRemoteCertificateFingerprint(this.dtls?.remoteCertificate);
|
|
326
521
|
}
|
|
327
522
|
catch (error) {
|
|
328
|
-
this.
|
|
329
|
-
this.
|
|
523
|
+
const dtls = this.dtls;
|
|
524
|
+
this.fail(certificateVerificationError(error));
|
|
525
|
+
// Tell the peer (whose handshake already completed); a fatal alert
|
|
526
|
+
// closes the DTLS transport once it has been sent.
|
|
527
|
+
void dtls?.sendAlert(dtls_1.AlertLevel.fatal, dtls_1.AlertDesc.BadCertificate, {
|
|
528
|
+
timeoutMs: exports.DTLS_ALERT_SEND_TIMEOUT_MS,
|
|
529
|
+
});
|
|
330
530
|
throw error;
|
|
331
531
|
}
|
|
332
532
|
if (this.srtpProfiles.length > 0) {
|
|
@@ -335,12 +535,47 @@ class RTCDtlsTransport {
|
|
|
335
535
|
this.setState("connected");
|
|
336
536
|
log("dtls connected");
|
|
337
537
|
}
|
|
338
|
-
|
|
538
|
+
/** closed / failed: no later DTLS event changes the state any more. */
|
|
539
|
+
get isFinalState() {
|
|
540
|
+
return this.state === "closed" || this.state === "failed";
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* Move to failed (once; closed / failed are final) and fire the `error`
|
|
544
|
+
* event with the DTLS alert that caused it.
|
|
545
|
+
*/
|
|
546
|
+
fail(error) {
|
|
547
|
+
if (this.isFinalState)
|
|
548
|
+
return;
|
|
549
|
+
this.setState("failed");
|
|
550
|
+
const rtcError = error instanceof RTCError
|
|
551
|
+
? error
|
|
552
|
+
: error instanceof dtls_1.DtlsAlertError &&
|
|
553
|
+
error.source === "local" &&
|
|
554
|
+
error.reason instanceof FingerprintMismatchError
|
|
555
|
+
? // This side rejected the peer certificate during the handshake
|
|
556
|
+
// (bad_certificate was sent).
|
|
557
|
+
certificateVerificationError(error.reason)
|
|
558
|
+
: error instanceof dtls_1.DtlsAlertError
|
|
559
|
+
? new RTCError({
|
|
560
|
+
errorDetail: "dtls-failure",
|
|
561
|
+
...(error.source === "remote"
|
|
562
|
+
? { receivedAlert: error.description }
|
|
563
|
+
: { sentAlert: error.description }),
|
|
564
|
+
}, error.message)
|
|
565
|
+
: new RTCError({ errorDetail: "dtls-failure" }, String(error));
|
|
566
|
+
const event = {
|
|
567
|
+
type: "error",
|
|
568
|
+
error: rtcError,
|
|
569
|
+
};
|
|
570
|
+
this.notifySafely("onerror", () => this.onerror?.(event));
|
|
571
|
+
// Per listener (and no throw when nobody listens to "error").
|
|
572
|
+
this.events.emitIsolated((error) => log("error listener failed", error), "error", event);
|
|
573
|
+
}
|
|
574
|
+
verifyRemoteCertificateFingerprint(remoteCertificate) {
|
|
339
575
|
if (!this.remoteParameters ||
|
|
340
576
|
this.remoteParameters.fingerprints.length === 0) {
|
|
341
577
|
throw new Error("remote fingerprint not exist");
|
|
342
578
|
}
|
|
343
|
-
const remoteCertificate = this.dtls?.remoteCertificate;
|
|
344
579
|
if (!remoteCertificate) {
|
|
345
580
|
throw new Error("remote certificate not available");
|
|
346
581
|
}
|
|
@@ -368,7 +603,7 @@ class RTCDtlsTransport {
|
|
|
368
603
|
}, new Map());
|
|
369
604
|
const matched = expectedFingerprints.some(({ normalizedAlgorithm, normalizedValue }) => actualFingerprints.get(normalizedAlgorithm) === normalizedValue);
|
|
370
605
|
if (!matched) {
|
|
371
|
-
throw new
|
|
606
|
+
throw new FingerprintMismatchError();
|
|
372
607
|
}
|
|
373
608
|
}
|
|
374
609
|
updateSrtpSession() {
|
|
@@ -404,6 +639,9 @@ class RTCDtlsTransport {
|
|
|
404
639
|
}
|
|
405
640
|
if (!(0, rtp_1.isMedia)(data))
|
|
406
641
|
return;
|
|
642
|
+
// Nothing is processed after close_notify / a fatal alert.
|
|
643
|
+
if (this.isFinalState)
|
|
644
|
+
return;
|
|
407
645
|
// Track received data statistics
|
|
408
646
|
this.bytesReceived += data.length;
|
|
409
647
|
this.packetsReceived++;
|
|
@@ -465,25 +703,74 @@ class RTCDtlsTransport {
|
|
|
465
703
|
}
|
|
466
704
|
});
|
|
467
705
|
}
|
|
706
|
+
/**
|
|
707
|
+
* Allocate the next transport-wide sequence at send time.
|
|
708
|
+
* Call immediately before DTLS/ICE enqueue so BUNDLE senders cannot
|
|
709
|
+
* reserve a TSN then wait in a per-sender pacer.
|
|
710
|
+
*/
|
|
711
|
+
allocateTransportWideSequence() {
|
|
712
|
+
const wireNow = this.transportSequenceNumber & 0xffff;
|
|
713
|
+
if ((this.transportSequenceNumberExtended & 0xffff) !== wireNow) {
|
|
714
|
+
const gen = Math.floor(this.transportSequenceNumberExtended / 0x10000);
|
|
715
|
+
this.transportSequenceNumberExtended = gen * 0x10000 + wireNow;
|
|
716
|
+
}
|
|
717
|
+
this.transportSequenceNumberExtended += 1;
|
|
718
|
+
this.transportSequenceNumber =
|
|
719
|
+
this.transportSequenceNumberExtended & 0xffff;
|
|
720
|
+
return {
|
|
721
|
+
wire: this.transportSequenceNumber,
|
|
722
|
+
extended: this.transportSequenceNumberExtended,
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* Encrypt RTP and enqueue on ICE. Returns on-wire size.
|
|
727
|
+
* Send-time metadata: {@link sendRtpWithMeta}.
|
|
728
|
+
*/
|
|
468
729
|
async sendRtp(payload, header) {
|
|
730
|
+
const { size } = await this.sendRtpWithMeta(payload, header);
|
|
731
|
+
return size;
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* Encrypt RTP and enqueue on ICE, capturing the clock immediately before
|
|
735
|
+
* the ICE write (RFC 8888). Prefer {@link sendRtp} unless send time is needed.
|
|
736
|
+
*
|
|
737
|
+
* Nothing is sent once the transport is `closed` / `failed` (close_notify
|
|
738
|
+
* or a fatal alert, `stop()`): ICE may still be up, but the DTLS
|
|
739
|
+
* association that keyed SRTP has ended. The size is then 0.
|
|
740
|
+
*/
|
|
741
|
+
async sendRtpWithMeta(payload, header) {
|
|
742
|
+
if (this.isFinalState) {
|
|
743
|
+
log("drop RTP on a", this.state, "transport");
|
|
744
|
+
return { size: 0, sendingAtMs: (0, utils_1.milliTime)() };
|
|
745
|
+
}
|
|
469
746
|
try {
|
|
470
747
|
const enc = this.srtp.encrypt(payload, header);
|
|
471
748
|
if (this.config.debug?.outboundPacketLoss &&
|
|
472
749
|
this.config.debug?.outboundPacketLoss / 100 < Math.random()) {
|
|
473
|
-
return enc.length;
|
|
750
|
+
return { size: enc.length, sendingAtMs: (0, utils_1.milliTime)() };
|
|
474
751
|
}
|
|
475
752
|
// Track statistics
|
|
476
753
|
this.bytesSent += enc.length;
|
|
477
754
|
this.packetsSent++;
|
|
755
|
+
const sendingAtMs = (0, utils_1.milliTime)();
|
|
478
756
|
await this.iceTransport.connection.send(enc).catch(() => { });
|
|
479
|
-
return enc.length;
|
|
757
|
+
return { size: enc.length, sendingAtMs };
|
|
480
758
|
}
|
|
481
759
|
catch (error) {
|
|
482
760
|
log("failed to send", error);
|
|
483
|
-
return 0;
|
|
761
|
+
return { size: 0, sendingAtMs: (0, utils_1.milliTime)() };
|
|
484
762
|
}
|
|
485
763
|
}
|
|
764
|
+
/**
|
|
765
|
+
* Encrypt RTCP and enqueue on ICE. Like RTP, nothing is sent once the
|
|
766
|
+
* transport is `closed` / `failed` (periodic sender / receiver reports,
|
|
767
|
+
* NACK, PLI, TWCC feedback included).
|
|
768
|
+
*/
|
|
486
769
|
async sendRtcp(packets) {
|
|
770
|
+
if (this.isFinalState) {
|
|
771
|
+
log("drop RTCP on a", this.state, "transport");
|
|
772
|
+
return;
|
|
773
|
+
}
|
|
487
774
|
const payload = Buffer.concat(packets.map((packet) => packet.serialize()));
|
|
488
775
|
const enc = this.srtcp.encrypt(payload);
|
|
489
776
|
if (this.config.debug?.outboundPacketLoss &&
|
|
@@ -495,22 +782,110 @@ class RTCDtlsTransport {
|
|
|
495
782
|
this.packetsSent++;
|
|
496
783
|
await this.iceTransport.connection.send(enc).catch(() => { });
|
|
497
784
|
}
|
|
785
|
+
/**
|
|
786
|
+
* Change the state and notify. Each notification is isolated: an
|
|
787
|
+
* exception thrown by a listener is logged and never interrupts the
|
|
788
|
+
* caller (stop() cleanup, settling start(), failing the transport).
|
|
789
|
+
*/
|
|
498
790
|
setState(state, emitEvent = true) {
|
|
499
791
|
if (state != this.state) {
|
|
500
792
|
this.state = state;
|
|
501
|
-
|
|
793
|
+
// Per subscriber: an application subscriber registered before the
|
|
794
|
+
// internal ones (SCTP closing its association, connectionState) must
|
|
795
|
+
// not stop them by throwing.
|
|
796
|
+
this.onStateChange.executeIsolated((error) => log("onStateChange listener failed", error), state);
|
|
502
797
|
if (emitEvent) {
|
|
503
|
-
this.onstatechange?.();
|
|
504
|
-
this.events.
|
|
798
|
+
this.notifySafely("onstatechange", () => this.onstatechange?.());
|
|
799
|
+
this.events.emitIsolated((error) => log("statechange listener failed", error), "statechange");
|
|
505
800
|
}
|
|
506
801
|
}
|
|
507
802
|
}
|
|
508
|
-
|
|
803
|
+
notifySafely(name, notify) {
|
|
804
|
+
(0, helper_1.notifySafely)(log, name, notify);
|
|
805
|
+
}
|
|
806
|
+
/**
|
|
807
|
+
* @internal
|
|
808
|
+
* The synchronous part of {@link RTCDtlsTransport.stop}: `closed` without
|
|
809
|
+
* statechange (W3C webrtc-pc `close()`), and a start() still waiting for
|
|
810
|
+
* the handshake settles. `RTCPeerConnection.close()` calls it before its
|
|
811
|
+
* first await; the alert and the ICE / socket teardown follow in stop().
|
|
812
|
+
*/
|
|
813
|
+
markClosed() {
|
|
509
814
|
this.setState("closed", false);
|
|
510
|
-
//
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
815
|
+
// A start() still waiting for the handshake ends here (closed stays).
|
|
816
|
+
this.settleStart?.();
|
|
817
|
+
}
|
|
818
|
+
/** Resolves once ICE has stopped; concurrent callers share one stop. */
|
|
819
|
+
stop() {
|
|
820
|
+
if (this.stopPromise)
|
|
821
|
+
return this.stopPromise;
|
|
822
|
+
// Publish the shared promise before runStop() notifies "closed": a
|
|
823
|
+
// subscriber that re-enters stop() must get this same promise.
|
|
824
|
+
let settle;
|
|
825
|
+
this.stopPromise = new Promise((resolve) => {
|
|
826
|
+
settle = resolve;
|
|
827
|
+
});
|
|
828
|
+
settle(this.runStop());
|
|
829
|
+
return this.stopPromise;
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* 1. closed, synchronously and without statechange (W3C webrtc-pc
|
|
833
|
+
* `close()`).
|
|
834
|
+
* 2. close_notify to the peer (RFC 5246 §7.2.1), encrypted once the
|
|
835
|
+
* handshake reached epoch 1, plaintext while it is still at epoch 0. It
|
|
836
|
+
* is awaited for at most {@link DTLS_ALERT_SEND_TIMEOUT_MS}, so a dead
|
|
837
|
+
* ICE path cannot hold the close. Nothing is sent after a fatal alert,
|
|
838
|
+
* a received close_notify, or when ICE is already closed / failed.
|
|
839
|
+
* 3. ICE stops (the alert must reach ICE before it closes).
|
|
840
|
+
* 4. The DTLS socket closes, so a handshake still in flight stops
|
|
841
|
+
* retransmitting.
|
|
842
|
+
*
|
|
843
|
+
* Steps 3 and 4 and `onStopped` always run, even if an earlier step or a
|
|
844
|
+
* listener threw, so the underlying transports never outlive stop().
|
|
845
|
+
*/
|
|
846
|
+
async runStop() {
|
|
847
|
+
const dtls = this.dtls;
|
|
848
|
+
try {
|
|
849
|
+
this.markClosed();
|
|
850
|
+
if (dtls &&
|
|
851
|
+
!dtls.terminated &&
|
|
852
|
+
!["closed", "failed"].includes(this.iceTransport.state)) {
|
|
853
|
+
log("send close_notify", this.iceTransport.state);
|
|
854
|
+
await dtls.sendAlert(dtls_1.AlertLevel.warning, dtls_1.AlertDesc.CloseNotify, {
|
|
855
|
+
timeoutMs: exports.DTLS_ALERT_SEND_TIMEOUT_MS,
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
else if (dtls?.terminated) {
|
|
859
|
+
// The peer's close_notify is being answered: let that reply reach ICE
|
|
860
|
+
// before ICE stops.
|
|
861
|
+
await dtls.alertFlushed();
|
|
862
|
+
}
|
|
863
|
+
else {
|
|
864
|
+
log("skip close_notify", {
|
|
865
|
+
dtls: !!dtls,
|
|
866
|
+
terminated: dtls?.terminated,
|
|
867
|
+
ice: this.iceTransport.state,
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
catch (error) {
|
|
872
|
+
log("stop: close_notify step failed", error);
|
|
873
|
+
}
|
|
874
|
+
try {
|
|
875
|
+
await this.iceTransport.stop();
|
|
876
|
+
}
|
|
877
|
+
catch (error) {
|
|
878
|
+
log("stop: ice stop failed", error);
|
|
879
|
+
}
|
|
880
|
+
try {
|
|
881
|
+
await dtls?.close();
|
|
882
|
+
}
|
|
883
|
+
catch (error) {
|
|
884
|
+
log("stop: dtls close failed", error);
|
|
885
|
+
}
|
|
886
|
+
// Per subscriber: the owner releasing this transport must run.
|
|
887
|
+
this.onStopped.executeIsolated((error) => log("onStopped listener failed", error));
|
|
888
|
+
this.notifySafely("onStopped", () => this.onStopped.complete());
|
|
514
889
|
}
|
|
515
890
|
async getStats(timestamp = (0, stats_1.getStatsTimestamp)()) {
|
|
516
891
|
const stats = [];
|
|
@@ -594,13 +969,13 @@ class RTCCertificate {
|
|
|
594
969
|
enumerable: true,
|
|
595
970
|
configurable: true,
|
|
596
971
|
writable: true,
|
|
597
|
-
value:
|
|
972
|
+
value: void 0
|
|
598
973
|
});
|
|
599
974
|
Object.defineProperty(this, "signatureHash", {
|
|
600
975
|
enumerable: true,
|
|
601
976
|
configurable: true,
|
|
602
977
|
writable: true,
|
|
603
|
-
value:
|
|
978
|
+
value: void 0
|
|
604
979
|
});
|
|
605
980
|
Object.defineProperty(this, "publicKey", {
|
|
606
981
|
enumerable: true,
|
|
@@ -614,6 +989,8 @@ class RTCCertificate {
|
|
|
614
989
|
writable: true,
|
|
615
990
|
value: void 0
|
|
616
991
|
});
|
|
992
|
+
this.certPem = certPem;
|
|
993
|
+
this.signatureHash = signatureHash;
|
|
617
994
|
this.certPem = (0, dtls_1.normalizePem)(certPem);
|
|
618
995
|
const cert = new node_crypto_1.X509Certificate(this.certPem);
|
|
619
996
|
this.publicKey = cert.publicKey
|
|
@@ -636,14 +1013,16 @@ class RTCDtlsFingerprint {
|
|
|
636
1013
|
enumerable: true,
|
|
637
1014
|
configurable: true,
|
|
638
1015
|
writable: true,
|
|
639
|
-
value:
|
|
1016
|
+
value: void 0
|
|
640
1017
|
});
|
|
641
1018
|
Object.defineProperty(this, "value", {
|
|
642
1019
|
enumerable: true,
|
|
643
1020
|
configurable: true,
|
|
644
1021
|
writable: true,
|
|
645
|
-
value:
|
|
1022
|
+
value: void 0
|
|
646
1023
|
});
|
|
1024
|
+
this.algorithm = algorithm;
|
|
1025
|
+
this.value = value;
|
|
647
1026
|
}
|
|
648
1027
|
}
|
|
649
1028
|
exports.RTCDtlsFingerprint = RTCDtlsFingerprint;
|
|
@@ -653,14 +1032,16 @@ class RTCDtlsParameters {
|
|
|
653
1032
|
enumerable: true,
|
|
654
1033
|
configurable: true,
|
|
655
1034
|
writable: true,
|
|
656
|
-
value:
|
|
1035
|
+
value: void 0
|
|
657
1036
|
});
|
|
658
1037
|
Object.defineProperty(this, "role", {
|
|
659
1038
|
enumerable: true,
|
|
660
1039
|
configurable: true,
|
|
661
1040
|
writable: true,
|
|
662
|
-
value:
|
|
1041
|
+
value: void 0
|
|
663
1042
|
});
|
|
1043
|
+
this.fingerprints = fingerprints;
|
|
1044
|
+
this.role = role;
|
|
664
1045
|
}
|
|
665
1046
|
}
|
|
666
1047
|
exports.RTCDtlsParameters = RTCDtlsParameters;
|
|
@@ -685,13 +1066,26 @@ const preferredFingerprintAlgorithms = [
|
|
|
685
1066
|
const selectPreferredFingerprintAlgorithm = (fingerprints) => {
|
|
686
1067
|
return (preferredFingerprintAlgorithms.find((algorithm) => fingerprints.some(({ normalizedAlgorithm }) => normalizedAlgorithm === algorithm)) ?? fingerprints[0].normalizedAlgorithm);
|
|
687
1068
|
};
|
|
1069
|
+
/**
|
|
1070
|
+
* The DTLS socket's view of the ICE connection. The ICE connection belongs to
|
|
1071
|
+
* {@link RTCIceTransport} (shared with SRTP, stopped by
|
|
1072
|
+
* {@link RTCDtlsTransport.stop}): when the DTLS socket closes its transport
|
|
1073
|
+
* (after a received close_notify or fatal alert, or close()), this only
|
|
1074
|
+
* detaches DTLS from ICE; it never closes the ICE agent.
|
|
1075
|
+
*/
|
|
688
1076
|
class IceTransport {
|
|
689
1077
|
constructor(ice) {
|
|
690
1078
|
Object.defineProperty(this, "ice", {
|
|
691
1079
|
enumerable: true,
|
|
692
1080
|
configurable: true,
|
|
693
1081
|
writable: true,
|
|
694
|
-
value:
|
|
1082
|
+
value: void 0
|
|
1083
|
+
});
|
|
1084
|
+
Object.defineProperty(this, "unSubscribe", {
|
|
1085
|
+
enumerable: true,
|
|
1086
|
+
configurable: true,
|
|
1087
|
+
writable: true,
|
|
1088
|
+
value: void 0
|
|
695
1089
|
});
|
|
696
1090
|
Object.defineProperty(this, "closed", {
|
|
697
1091
|
enumerable: true,
|
|
@@ -716,27 +1110,29 @@ class IceTransport {
|
|
|
716
1110
|
configurable: true,
|
|
717
1111
|
writable: true,
|
|
718
1112
|
value: (data) => {
|
|
1113
|
+
if (this.closed)
|
|
1114
|
+
return Promise.resolve();
|
|
719
1115
|
return this.ice.send(data);
|
|
720
1116
|
}
|
|
721
1117
|
});
|
|
722
|
-
ice
|
|
1118
|
+
this.ice = ice;
|
|
1119
|
+
this.unSubscribe = ice.onData.subscribe((buf) => {
|
|
723
1120
|
if ((0, utils_1.isDtls)(buf)) {
|
|
724
1121
|
if (this.onData) {
|
|
725
1122
|
this.onData(buf);
|
|
726
1123
|
}
|
|
727
1124
|
}
|
|
728
|
-
});
|
|
1125
|
+
}).unSubscribe;
|
|
729
1126
|
}
|
|
730
1127
|
get address() {
|
|
731
1128
|
return {};
|
|
732
1129
|
}
|
|
1130
|
+
/** Detach DTLS from ICE: no more DTLS records in either direction. */
|
|
733
1131
|
async close() {
|
|
734
1132
|
if (this.closed)
|
|
735
1133
|
return;
|
|
736
1134
|
this.closed = true;
|
|
737
|
-
|
|
738
|
-
if (this.ice.state !== "closed")
|
|
739
|
-
this.ice.close();
|
|
1135
|
+
this.unSubscribe();
|
|
740
1136
|
}
|
|
741
1137
|
}
|
|
742
1138
|
const createIceTransport = (ice) => new IceTransport(ice);
|