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
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NONCE_COOKIE = void 0;
|
|
4
|
+
exports.parseNonceSecurityFeatures = parseNonceSecurityFeatures;
|
|
5
|
+
exports.credentialRetryOf = credentialRetryOf;
|
|
6
|
+
/** Prefix of a NONCE that carries STUN Security Features (RFC 8489 §9.2). */
|
|
7
|
+
exports.NONCE_COOKIE = "obMatJos2";
|
|
8
|
+
/**
|
|
9
|
+
* Security Features of a NONCE that starts with the nonce cookie: "obMatJos2"
|
|
10
|
+
* followed by 4 base64 characters encoding the 24-bit feature set
|
|
11
|
+
* (RFC 8489 §9.2, §18.1). Undefined for a NONCE without the cookie, which
|
|
12
|
+
* announces no feature.
|
|
13
|
+
*
|
|
14
|
+
* RFC 8489 numbers the bits from the most significant side in §9.2 and, as
|
|
15
|
+
* corrected by erratum 6290, from the least significant side in §18.1. Both
|
|
16
|
+
* readings are accepted so a feature is never missed: the client cannot use
|
|
17
|
+
* either feature, and the other positions are unassigned.
|
|
18
|
+
*/
|
|
19
|
+
function parseNonceSecurityFeatures(nonce) {
|
|
20
|
+
const text = nonce.toString("latin1");
|
|
21
|
+
if (!text.startsWith(exports.NONCE_COOKIE)) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
const encoded = text.slice(exports.NONCE_COOKIE.length, exports.NONCE_COOKIE.length + 4);
|
|
25
|
+
// A malformed feature set cannot be trusted to announce nothing.
|
|
26
|
+
if (!/^[A-Za-z0-9+/]{4}$/.test(encoded)) {
|
|
27
|
+
return { passwordAlgorithms: true, usernameAnonymity: true };
|
|
28
|
+
}
|
|
29
|
+
const bits = Buffer.from(encoded, "base64").readUIntBE(0, 3);
|
|
30
|
+
const bit = (n) => (bits & (1 << n)) !== 0 || (bits & (1 << (23 - n))) !== 0;
|
|
31
|
+
return { passwordAlgorithms: bit(0), usernameAnonymity: bit(1) };
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Decide whether a 401 (Unauthenticated) or 438 (Stale Nonce) error response
|
|
35
|
+
* allows one retry with new credentials (RFC 8489 §9.2.5), and with which
|
|
36
|
+
* realm and nonce. Undefined means the error is final.
|
|
37
|
+
*
|
|
38
|
+
* - NONCE is required, and Security Features the client does not implement
|
|
39
|
+
* (PASSWORD-ALGORITHMS, username anonymity) rule the retry out.
|
|
40
|
+
* - 401 to an unauthenticated request (the first Allocate): retry with the
|
|
41
|
+
* REALM and NONCE of the response.
|
|
42
|
+
* - 401 to an authenticated request: the username and password never change,
|
|
43
|
+
* so retrying with the same REALM is forbidden; only a new REALM is tried.
|
|
44
|
+
* - 438: retry with the new NONCE and the current realm, which a REALM in
|
|
45
|
+
* the response must not contradict.
|
|
46
|
+
*/
|
|
47
|
+
function credentialRetryOf(response, sent, currentRealm) {
|
|
48
|
+
const [errorCode] = response.getAttributeValue("ERROR-CODE") ?? [];
|
|
49
|
+
if (errorCode !== 401 && errorCode !== 438) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
const nonce = response.getAttributeValue("NONCE");
|
|
53
|
+
if (!nonce?.length) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
const features = parseNonceSecurityFeatures(nonce);
|
|
57
|
+
if (features?.passwordAlgorithms ||
|
|
58
|
+
features?.usernameAnonymity ||
|
|
59
|
+
response.getAttributeValue("PASSWORD-ALGORITHMS") !== undefined) {
|
|
60
|
+
// Only MD5 MESSAGE-INTEGRITY with a plain USERNAME is implemented.
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
const realm = response.getAttributeValue("REALM");
|
|
64
|
+
if (errorCode === 401) {
|
|
65
|
+
if (!realm) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
if (sent.authenticated && realm === sent.realm) {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
return { realm, nonce };
|
|
72
|
+
}
|
|
73
|
+
if (!currentRealm || (realm !== undefined && realm !== currentRealm)) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
return { realm: currentRealm, nonce };
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=credential.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential.js","sourceRoot":"","sources":["../../../../../ice/src/turn/credential.ts"],"names":[],"mappings":";;;AAwBA,gEAgBC;AA8BD,8CAuCC;AA3GD,6EAA6E;AAChE,QAAA,YAAY,GAAG,WAAW,CAAC;AAUxC;;;;;;;;;;GAUG;AACH,SAAgB,0BAA0B,CACxC,KAAa;IAEb,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACtC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,oBAAY,CAAC,EAAE,CAAC;QACnC,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,oBAAY,CAAC,MAAM,EAAE,oBAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACzE,iEAAiE;IACjE,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACxC,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC;IAC/D,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7D,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,EAAE,CACxB,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC5D,OAAO,EAAE,kBAAkB,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;AACnE,CAAC;AAgBD;;;;;;;;;;;;;GAaG;AACH,SAAgB,iBAAiB,CAC/B,QAAiB,EACjB,IAAqB,EACrB,YAAgC;IAEhC,MAAM,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAC,iBAAiB,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;IACnE,IAAI,SAAS,KAAK,GAAG,IAAI,SAAS,KAAK,GAAG,EAAE,CAAC;QAC3C,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,KAAK,GAAuB,QAAQ,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACtE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;QACnB,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,QAAQ,GAAG,0BAA0B,CAAC,KAAK,CAAC,CAAC;IACnD,IACE,QAAQ,EAAE,kBAAkB;QAC5B,QAAQ,EAAE,iBAAiB;QAC3B,QAAQ,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,KAAK,SAAS,EAC/D,CAAC;QACD,mEAAmE;QACnE,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,KAAK,GAAuB,QAAQ,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACtE,IAAI,SAAS,KAAK,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,IAAI,IAAI,CAAC,aAAa,IAAI,KAAK,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;YAC/C,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAC1B,CAAC;IAED,IAAI,CAAC,YAAY,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,YAAY,CAAC,EAAE,CAAC;QACrE,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;AACxC,CAAC","sourcesContent":["import type { Message } from \"../stun/message\";\n\n/** Prefix of a NONCE that carries STUN Security Features (RFC 8489 §9.2). */\nexport const NONCE_COOKIE = \"obMatJos2\";\n\n/** STUN Security Features a server announced in its nonce cookie. */\nexport interface NonceSecurityFeatures {\n /** Bit 0: PASSWORD-ALGORITHMS / PASSWORD-ALGORITHM negotiation. */\n passwordAlgorithms: boolean;\n /** Bit 1: USERHASH instead of USERNAME. */\n usernameAnonymity: boolean;\n}\n\n/**\n * Security Features of a NONCE that starts with the nonce cookie: \"obMatJos2\"\n * followed by 4 base64 characters encoding the 24-bit feature set\n * (RFC 8489 §9.2, §18.1). Undefined for a NONCE without the cookie, which\n * announces no feature.\n *\n * RFC 8489 numbers the bits from the most significant side in §9.2 and, as\n * corrected by erratum 6290, from the least significant side in §18.1. Both\n * readings are accepted so a feature is never missed: the client cannot use\n * either feature, and the other positions are unassigned.\n */\nexport function parseNonceSecurityFeatures(\n nonce: Buffer,\n): NonceSecurityFeatures | undefined {\n const text = nonce.toString(\"latin1\");\n if (!text.startsWith(NONCE_COOKIE)) {\n return undefined;\n }\n const encoded = text.slice(NONCE_COOKIE.length, NONCE_COOKIE.length + 4);\n // A malformed feature set cannot be trusted to announce nothing.\n if (!/^[A-Za-z0-9+/]{4}$/.test(encoded)) {\n return { passwordAlgorithms: true, usernameAnonymity: true };\n }\n const bits = Buffer.from(encoded, \"base64\").readUIntBE(0, 3);\n const bit = (n: number) =>\n (bits & (1 << n)) !== 0 || (bits & (1 << (23 - n))) !== 0;\n return { passwordAlgorithms: bit(0), usernameAnonymity: bit(1) };\n}\n\n/** The long-term credentials a request was sent with. */\nexport interface SentCredentials {\n /** The request carried MESSAGE-INTEGRITY. */\n authenticated: boolean;\n /** REALM the request was signed with, when authenticated. */\n realm?: string;\n}\n\n/** Realm and nonce to sign the retry of a challenged request with. */\nexport interface CredentialRetry {\n realm: string;\n nonce: Buffer;\n}\n\n/**\n * Decide whether a 401 (Unauthenticated) or 438 (Stale Nonce) error response\n * allows one retry with new credentials (RFC 8489 §9.2.5), and with which\n * realm and nonce. Undefined means the error is final.\n *\n * - NONCE is required, and Security Features the client does not implement\n * (PASSWORD-ALGORITHMS, username anonymity) rule the retry out.\n * - 401 to an unauthenticated request (the first Allocate): retry with the\n * REALM and NONCE of the response.\n * - 401 to an authenticated request: the username and password never change,\n * so retrying with the same REALM is forbidden; only a new REALM is tried.\n * - 438: retry with the new NONCE and the current realm, which a REALM in\n * the response must not contradict.\n */\nexport function credentialRetryOf(\n response: Message,\n sent: SentCredentials,\n currentRealm: string | undefined,\n): CredentialRetry | undefined {\n const [errorCode] = response.getAttributeValue(\"ERROR-CODE\") ?? [];\n if (errorCode !== 401 && errorCode !== 438) {\n return undefined;\n }\n\n const nonce: Buffer | undefined = response.getAttributeValue(\"NONCE\");\n if (!nonce?.length) {\n return undefined;\n }\n const features = parseNonceSecurityFeatures(nonce);\n if (\n features?.passwordAlgorithms ||\n features?.usernameAnonymity ||\n response.getAttributeValue(\"PASSWORD-ALGORITHMS\") !== undefined\n ) {\n // Only MD5 MESSAGE-INTEGRITY with a plain USERNAME is implemented.\n return undefined;\n }\n\n const realm: string | undefined = response.getAttributeValue(\"REALM\");\n if (errorCode === 401) {\n if (!realm) {\n return undefined;\n }\n if (sent.authenticated && realm === sent.realm) {\n return undefined;\n }\n return { realm, nonce };\n }\n\n if (!currentRealm || (realm !== undefined && realm !== currentRealm)) {\n return undefined;\n }\n return { realm: currentRealm, nonce };\n}\n"]}
|
|
@@ -20,12 +20,18 @@ export interface TurnChannel {
|
|
|
20
20
|
}
|
|
21
21
|
export declare class StunOverTurnProtocol implements Protocol {
|
|
22
22
|
turn: TurnProtocol;
|
|
23
|
+
/**
|
|
24
|
+
* The transport the TURN server was configured with. A UDP entry whose
|
|
25
|
+
* allocation fell back to TCP keeps "udp" here, so a restart that removes
|
|
26
|
+
* that entry also releases the fallback allocation.
|
|
27
|
+
*/
|
|
28
|
+
configuredTransport?: "udp" | "tcp" | "tls";
|
|
23
29
|
static type: string;
|
|
24
30
|
readonly type: string;
|
|
25
31
|
localCandidate: Candidate;
|
|
26
32
|
private disposer;
|
|
27
33
|
onRequestReceived: Event<[Message, Address, Buffer]>;
|
|
28
|
-
onDataReceived: Event<[Buffer]>;
|
|
34
|
+
onDataReceived: Event<[Buffer, Address]>;
|
|
29
35
|
constructor(turn: TurnProtocol);
|
|
30
36
|
private handleStunMessage;
|
|
31
37
|
request(request: Message, addr: Address, integrityKey?: Buffer, retransmissionsOrOptions?: number | TransactionRequestOptions, onRequestSent?: (attempt: number) => void): Promise<[Message, readonly [string, number]]>;
|
|
@@ -64,7 +70,7 @@ export declare class TurnProtocol implements Protocol {
|
|
|
64
70
|
readonly type: string;
|
|
65
71
|
readonly onData: Event<[Buffer<ArrayBufferLike>, readonly [string, number]]>;
|
|
66
72
|
onRequestReceived: Event<[Message, Address, Buffer]>;
|
|
67
|
-
onDataReceived: Event<[Buffer]>;
|
|
73
|
+
onDataReceived: Event<[Buffer, Address]>;
|
|
68
74
|
integrityKey?: Buffer;
|
|
69
75
|
nonce?: Buffer;
|
|
70
76
|
realm?: string;
|
|
@@ -105,13 +111,7 @@ export declare class TurnProtocol implements Protocol {
|
|
|
105
111
|
private serverEndpointSelection?;
|
|
106
112
|
/** TURN server as configured, before any 300 (Try Alternate) redirect. */
|
|
107
113
|
readonly configuredServer: Address;
|
|
108
|
-
constructor(
|
|
109
|
-
/**
|
|
110
|
-
* TURN server the allocation is made on; the host may be a hostname.
|
|
111
|
-
* Starts as the configured server and becomes the ALTERNATE-SERVER when
|
|
112
|
-
* an Allocate is redirected with 300 (Try Alternate).
|
|
113
|
-
*/
|
|
114
|
-
server: Address, username: string, password: string, lifetime: number, transport: Transport, options?: {
|
|
114
|
+
constructor(server: Address, username: string, password: string, lifetime: number, transport: Transport, options?: {
|
|
115
115
|
/**sec */
|
|
116
116
|
channelRefreshTime?: number;
|
|
117
117
|
/**
|
|
@@ -145,11 +145,24 @@ export declare class TurnProtocol implements Protocol {
|
|
|
145
145
|
private switchServer;
|
|
146
146
|
private handleChannelData;
|
|
147
147
|
private handleSTUNMessage;
|
|
148
|
+
/**
|
|
149
|
+
* Long-term credentials (RFC 8489 §9.2.5): a response to an authenticated
|
|
150
|
+
* request must carry a valid MESSAGE-INTEGRITY, except a 401/438 challenge
|
|
151
|
+
* without one, which goes to the retry logic of requestWithRetry. Over
|
|
152
|
+
* UDP an unverified response is dropped and retransmissions continue; over
|
|
153
|
+
* TCP/TLS it ends the transaction, except an unsigned 400, which is
|
|
154
|
+
* discarded as if never received.
|
|
155
|
+
*/
|
|
156
|
+
private handleResponse;
|
|
148
157
|
private dataReceived;
|
|
149
158
|
private send;
|
|
150
159
|
private createPermission;
|
|
151
160
|
private refresh;
|
|
152
|
-
request(request: Message, addr: Address, _integrityKey?: Buffer, retransmissionsOrOptions?: number | TransactionRequestOptions, onRequestSent?: (attempt: number) => void
|
|
161
|
+
request(request: Message, addr: Address, _integrityKey?: Buffer, retransmissionsOrOptions?: number | TransactionRequestOptions, onRequestSent?: (attempt: number) => void, credentials?: {
|
|
162
|
+
realm: string;
|
|
163
|
+
nonce: Buffer;
|
|
164
|
+
integrityKey: Buffer;
|
|
165
|
+
}): Promise<[Message, Address]>;
|
|
153
166
|
/**
|
|
154
167
|
* The concrete TURN server address, selected on the first request and
|
|
155
168
|
* pinned for the rest of the allocation, so a later DNS answer can never
|
|
@@ -172,6 +185,14 @@ export declare class TurnProtocol implements Protocol {
|
|
|
172
185
|
* dropped as coming from an unexpected address.
|
|
173
186
|
*/
|
|
174
187
|
private resolveServerEndpoint;
|
|
188
|
+
/**
|
|
189
|
+
* Send a request and follow the long-term credential mechanism of
|
|
190
|
+
* RFC 8489 §9.2.5: a 401 (Unauthenticated) or 438 (Stale Nonce) that
|
|
191
|
+
* allows it (see credentialRetryOf) is retried once with the new realm and
|
|
192
|
+
* nonce; any other error, or a second challenge, is thrown. The allocation's
|
|
193
|
+
* realm, nonce and integrity key change only when a retry is made; a retry
|
|
194
|
+
* under a new realm adopts them only once the server accepted it.
|
|
195
|
+
*/
|
|
175
196
|
requestWithRetry(request: Message, addr: Address, signal?: AbortSignal): Promise<[Message, Address]>;
|
|
176
197
|
sendData(data: Buffer, addr: Address): Promise<void>;
|
|
177
198
|
/**
|
|
@@ -47,6 +47,7 @@ const common_1 = require("../imports/common");
|
|
|
47
47
|
const const_1 = require("../stun/const");
|
|
48
48
|
const message_1 = require("../stun/message");
|
|
49
49
|
const transaction_1 = require("../stun/transaction");
|
|
50
|
+
const credential_1 = require("./credential");
|
|
50
51
|
const frame_1 = require("./frame");
|
|
51
52
|
const log = (0, common_1.debug)("werift-ice:packages/ice/src/turn/protocol.ts");
|
|
52
53
|
const DEFAULT_CHANNEL_REFRESH_TIME = 500;
|
|
@@ -73,7 +74,18 @@ class StunOverTurnProtocol {
|
|
|
73
74
|
enumerable: true,
|
|
74
75
|
configurable: true,
|
|
75
76
|
writable: true,
|
|
76
|
-
value:
|
|
77
|
+
value: void 0
|
|
78
|
+
});
|
|
79
|
+
/**
|
|
80
|
+
* The transport the TURN server was configured with. A UDP entry whose
|
|
81
|
+
* allocation fell back to TCP keeps "udp" here, so a restart that removes
|
|
82
|
+
* that entry also releases the fallback allocation.
|
|
83
|
+
*/
|
|
84
|
+
Object.defineProperty(this, "configuredTransport", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
configurable: true,
|
|
87
|
+
writable: true,
|
|
88
|
+
value: void 0
|
|
77
89
|
});
|
|
78
90
|
Object.defineProperty(this, "type", {
|
|
79
91
|
enumerable: true,
|
|
@@ -113,7 +125,7 @@ class StunOverTurnProtocol {
|
|
|
113
125
|
try {
|
|
114
126
|
const message = (0, message_1.parseMessage)(data);
|
|
115
127
|
if (!message) {
|
|
116
|
-
this.onDataReceived.execute(data);
|
|
128
|
+
this.onDataReceived.execute(data, addr);
|
|
117
129
|
return;
|
|
118
130
|
}
|
|
119
131
|
if (message.messageClass === const_1.classes.RESPONSE ||
|
|
@@ -139,6 +151,7 @@ class StunOverTurnProtocol {
|
|
|
139
151
|
}
|
|
140
152
|
}
|
|
141
153
|
});
|
|
154
|
+
this.turn = turn;
|
|
142
155
|
turn.onData
|
|
143
156
|
.subscribe((data, addr) => {
|
|
144
157
|
this.handleStunMessage(data, addr);
|
|
@@ -149,8 +162,9 @@ class StunOverTurnProtocol {
|
|
|
149
162
|
if (this.turn.transactions[request.transactionIdHex]) {
|
|
150
163
|
throw new Error("exist");
|
|
151
164
|
}
|
|
165
|
+
const options = (0, transaction_1.buildTransactionOptions)(integrityKey, retransmissionsOrOptions, onRequestSent);
|
|
152
166
|
if (integrityKey) {
|
|
153
|
-
request.
|
|
167
|
+
request.addIntegrity(integrityKey, options.integrityAlgorithm);
|
|
154
168
|
request.addFingerprint();
|
|
155
169
|
}
|
|
156
170
|
// Peer-facing STUN over TURN must honor retransmissions/responseTimeout
|
|
@@ -158,7 +172,6 @@ class StunOverTurnProtocol {
|
|
|
158
172
|
// allocation/refresh policy on TurnProtocol.
|
|
159
173
|
// Peer addresses are already IPs from candidates; resolve for safety.
|
|
160
174
|
const resolvedAddr = await (0, transaction_1.resolveRequestAddress)(addr);
|
|
161
|
-
const options = (0, transaction_1.buildTransactionOptions)(integrityKey, retransmissionsOrOptions, onRequestSent);
|
|
162
175
|
const transaction = new transaction_1.Transaction(request, resolvedAddr, this, options);
|
|
163
176
|
this.turn.transactions[request.transactionIdHex] = transaction;
|
|
164
177
|
try {
|
|
@@ -191,48 +204,47 @@ Object.defineProperty(StunOverTurnProtocol, "type", {
|
|
|
191
204
|
value: "turn"
|
|
192
205
|
});
|
|
193
206
|
class TurnProtocol {
|
|
194
|
-
constructor(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
server, username, password, lifetime, transport, options = {}) {
|
|
207
|
+
constructor(server, username, password, lifetime, transport, options = {}) {
|
|
208
|
+
/**
|
|
209
|
+
* TURN server the allocation is made on; the host may be a hostname.
|
|
210
|
+
* Starts as the configured server and becomes the ALTERNATE-SERVER when
|
|
211
|
+
* an Allocate is redirected with 300 (Try Alternate).
|
|
212
|
+
*/
|
|
201
213
|
Object.defineProperty(this, "server", {
|
|
202
214
|
enumerable: true,
|
|
203
215
|
configurable: true,
|
|
204
216
|
writable: true,
|
|
205
|
-
value:
|
|
217
|
+
value: void 0
|
|
206
218
|
});
|
|
207
219
|
Object.defineProperty(this, "username", {
|
|
208
220
|
enumerable: true,
|
|
209
221
|
configurable: true,
|
|
210
222
|
writable: true,
|
|
211
|
-
value:
|
|
223
|
+
value: void 0
|
|
212
224
|
});
|
|
213
225
|
Object.defineProperty(this, "password", {
|
|
214
226
|
enumerable: true,
|
|
215
227
|
configurable: true,
|
|
216
228
|
writable: true,
|
|
217
|
-
value:
|
|
229
|
+
value: void 0
|
|
218
230
|
});
|
|
219
231
|
Object.defineProperty(this, "lifetime", {
|
|
220
232
|
enumerable: true,
|
|
221
233
|
configurable: true,
|
|
222
234
|
writable: true,
|
|
223
|
-
value:
|
|
235
|
+
value: void 0
|
|
224
236
|
});
|
|
225
237
|
Object.defineProperty(this, "transport", {
|
|
226
238
|
enumerable: true,
|
|
227
239
|
configurable: true,
|
|
228
240
|
writable: true,
|
|
229
|
-
value:
|
|
241
|
+
value: void 0
|
|
230
242
|
});
|
|
231
243
|
Object.defineProperty(this, "options", {
|
|
232
244
|
enumerable: true,
|
|
233
245
|
configurable: true,
|
|
234
246
|
writable: true,
|
|
235
|
-
value:
|
|
247
|
+
value: void 0
|
|
236
248
|
});
|
|
237
249
|
Object.defineProperty(this, "type", {
|
|
238
250
|
enumerable: true,
|
|
@@ -449,6 +461,12 @@ class TurnProtocol {
|
|
|
449
461
|
});
|
|
450
462
|
}
|
|
451
463
|
});
|
|
464
|
+
this.server = server;
|
|
465
|
+
this.username = username;
|
|
466
|
+
this.password = password;
|
|
467
|
+
this.lifetime = lifetime;
|
|
468
|
+
this.transport = transport;
|
|
469
|
+
this.options = options;
|
|
452
470
|
this.configuredServer = server;
|
|
453
471
|
this.channelRefreshTime =
|
|
454
472
|
this.options.channelRefreshTime ?? DEFAULT_CHANNEL_REFRESH_TIME;
|
|
@@ -580,14 +598,7 @@ class TurnProtocol {
|
|
|
580
598
|
message.messageClass === const_1.classes.ERROR) {
|
|
581
599
|
const transaction = this.transactions[message.transactionIdHex];
|
|
582
600
|
if (transaction) {
|
|
583
|
-
|
|
584
|
-
? (0, message_1.parseMessage)(data, transaction.integrityKey)
|
|
585
|
-
: message;
|
|
586
|
-
if (!verified) {
|
|
587
|
-
log("TURN STUN response failed MESSAGE-INTEGRITY check");
|
|
588
|
-
return;
|
|
589
|
-
}
|
|
590
|
-
transaction.responseReceived(verified, addr);
|
|
601
|
+
this.handleResponse(transaction, message, data, addr);
|
|
591
602
|
}
|
|
592
603
|
}
|
|
593
604
|
else if (message.messageClass === const_1.classes.REQUEST) {
|
|
@@ -603,6 +614,37 @@ class TurnProtocol {
|
|
|
603
614
|
log("parse error", data.toString());
|
|
604
615
|
}
|
|
605
616
|
}
|
|
617
|
+
/**
|
|
618
|
+
* Long-term credentials (RFC 8489 §9.2.5): a response to an authenticated
|
|
619
|
+
* request must carry a valid MESSAGE-INTEGRITY, except a 401/438 challenge
|
|
620
|
+
* without one, which goes to the retry logic of requestWithRetry. Over
|
|
621
|
+
* UDP an unverified response is dropped and retransmissions continue; over
|
|
622
|
+
* TCP/TLS it ends the transaction, except an unsigned 400, which is
|
|
623
|
+
* discarded as if never received.
|
|
624
|
+
*/
|
|
625
|
+
handleResponse(transaction, message, data, addr) {
|
|
626
|
+
if (!transaction.integrityKey) {
|
|
627
|
+
transaction.responseReceived(message, addr);
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
if ((0, transaction_1.isUnauthenticatedChallenge)(message)) {
|
|
631
|
+
transaction.challengeReceived(message, addr);
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
const verified = (0, message_1.parseMessage)(data, transaction.integrityKey);
|
|
635
|
+
if (verified) {
|
|
636
|
+
transaction.responseReceived(verified, addr);
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
log("TURN STUN response failed MESSAGE-INTEGRITY check");
|
|
640
|
+
const [errorCode] = message.getAttributeValue("ERROR-CODE") ?? [];
|
|
641
|
+
const unsignedBadRequest = message.messageClass === const_1.classes.ERROR &&
|
|
642
|
+
errorCode === 400 &&
|
|
643
|
+
!(0, transaction_1.hasMessageIntegrity)(message);
|
|
644
|
+
if (isStreamTransport(this.transport) && !unsignedBadRequest) {
|
|
645
|
+
transaction.integrityViolated(addr);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
606
648
|
dataReceived(data, addr) {
|
|
607
649
|
const datagramReceived = (data, addr) => {
|
|
608
650
|
if (data.length >= 4 && (0, frame_1.isChannelData)(data)) {
|
|
@@ -640,16 +682,29 @@ class TurnProtocol {
|
|
|
640
682
|
// Use requestWithRetry for stale-nonce (438) consistency with ChannelBind.
|
|
641
683
|
await this.requestWithRetry(request, this.server);
|
|
642
684
|
}
|
|
643
|
-
async request(request, addr, _integrityKey, retransmissionsOrOptions, onRequestSent) {
|
|
685
|
+
async request(request, addr, _integrityKey, retransmissionsOrOptions, onRequestSent, credentials) {
|
|
644
686
|
if (this.transactions[request.transactionIdHex]) {
|
|
645
687
|
throw new Error("exist");
|
|
646
688
|
}
|
|
647
|
-
|
|
689
|
+
// Long-term credentials stay MESSAGE-INTEGRITY (SHA-1): SHA-256 needs the
|
|
690
|
+
// PASSWORD-ALGORITHM(S) negotiation of RFC 8489 §9.2, which is out of
|
|
691
|
+
// scope here (options.integrityAlgorithm is not applied).
|
|
692
|
+
const signing = credentials ?? {
|
|
693
|
+
realm: this.realm,
|
|
694
|
+
nonce: this.nonce,
|
|
695
|
+
integrityKey: this.integrityKey,
|
|
696
|
+
};
|
|
697
|
+
if (signing.integrityKey) {
|
|
698
|
+
// A retried request still carries the previous signature, which would
|
|
699
|
+
// otherwise be covered by the new MESSAGE-INTEGRITY.
|
|
648
700
|
request
|
|
701
|
+
.removeAttribute("MESSAGE-INTEGRITY")
|
|
702
|
+
.removeAttribute("MESSAGE-INTEGRITY-SHA256")
|
|
703
|
+
.removeAttribute("FINGERPRINT")
|
|
649
704
|
.setAttribute("USERNAME", this.username)
|
|
650
|
-
.setAttribute("REALM",
|
|
651
|
-
.setAttribute("NONCE",
|
|
652
|
-
.addMessageIntegrity(
|
|
705
|
+
.setAttribute("REALM", signing.realm)
|
|
706
|
+
.setAttribute("NONCE", signing.nonce)
|
|
707
|
+
.addMessageIntegrity(signing.integrityKey)
|
|
653
708
|
.addFingerprint();
|
|
654
709
|
}
|
|
655
710
|
// TURN server allocation/refresh uses default STUN retry policy unless
|
|
@@ -659,7 +714,7 @@ class TurnProtocol {
|
|
|
659
714
|
// close() ran during the lookup: no transaction starts on a closed client.
|
|
660
715
|
if (this.closed)
|
|
661
716
|
throw new exceptions_1.TransactionCancelled();
|
|
662
|
-
const options = (0, transaction_1.buildTransactionOptions)(
|
|
717
|
+
const options = (0, transaction_1.buildTransactionOptions)(signing.integrityKey, retransmissionsOrOptions, onRequestSent);
|
|
663
718
|
const transaction = new transaction_1.Transaction(request, resolvedAddr, this, options);
|
|
664
719
|
this.transactions[request.transactionIdHex] = transaction;
|
|
665
720
|
try {
|
|
@@ -728,37 +783,58 @@ class TurnProtocol {
|
|
|
728
783
|
// a lookup with no family preference.
|
|
729
784
|
return (0, transaction_1.resolveRequestAddress)(this.server);
|
|
730
785
|
}
|
|
786
|
+
/**
|
|
787
|
+
* Send a request and follow the long-term credential mechanism of
|
|
788
|
+
* RFC 8489 §9.2.5: a 401 (Unauthenticated) or 438 (Stale Nonce) that
|
|
789
|
+
* allows it (see credentialRetryOf) is retried once with the new realm and
|
|
790
|
+
* nonce; any other error, or a second challenge, is thrown. The allocation's
|
|
791
|
+
* realm, nonce and integrity key change only when a retry is made; a retry
|
|
792
|
+
* under a new realm adopts them only once the server accepted it.
|
|
793
|
+
*/
|
|
731
794
|
async requestWithRetry(request, addr, signal) {
|
|
732
|
-
let message, address;
|
|
733
795
|
try {
|
|
734
|
-
|
|
735
|
-
signal,
|
|
736
|
-
});
|
|
796
|
+
return await this.request(request, addr, undefined, { signal });
|
|
737
797
|
}
|
|
738
798
|
catch (error) {
|
|
739
799
|
if (error instanceof exceptions_1.TransactionFailed == false) {
|
|
740
800
|
log("requestWithRetry error", error);
|
|
741
801
|
throw error;
|
|
742
802
|
}
|
|
743
|
-
|
|
744
|
-
const
|
|
745
|
-
const
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
if (errorCode === 401) {
|
|
751
|
-
this.realm = realm;
|
|
752
|
-
}
|
|
753
|
-
this.integrityKey = makeIntegrityKey(this.username, this.realm, this.password);
|
|
754
|
-
request.transactionId = (0, helper_1.randomTransactionId)();
|
|
755
|
-
[message, address] = await this.request(request, this.server, undefined, { signal });
|
|
756
|
-
}
|
|
757
|
-
else {
|
|
803
|
+
// request() signed the request with the credentials of that moment.
|
|
804
|
+
const authenticated = request.attributesKeys.includes("MESSAGE-INTEGRITY");
|
|
805
|
+
const sentRealm = authenticated
|
|
806
|
+
? request.getAttributeValue("REALM")
|
|
807
|
+
: undefined;
|
|
808
|
+
const retry = (0, credential_1.credentialRetryOf)(error.response, { authenticated, realm: sentRealm }, this.realm);
|
|
809
|
+
if (!retry) {
|
|
758
810
|
throw error;
|
|
759
811
|
}
|
|
812
|
+
log("retry with nonce", error.str, {
|
|
813
|
+
signedError: !(error instanceof exceptions_1.TransactionChallenge),
|
|
814
|
+
});
|
|
815
|
+
const integrityKey = makeIntegrityKey(this.username, retry.realm, this.password);
|
|
816
|
+
request.transactionId = (0, helper_1.randomTransactionId)();
|
|
817
|
+
// A new realm on an authenticated request rekeys the whole allocation.
|
|
818
|
+
// Sign the retry with its own credentials and adopt them only once the
|
|
819
|
+
// server accepted it, so concurrent failures never overwrite the shared
|
|
820
|
+
// state with credentials that were rejected.
|
|
821
|
+
if (authenticated && retry.realm !== sentRealm) {
|
|
822
|
+
const credentials = {
|
|
823
|
+
realm: retry.realm,
|
|
824
|
+
nonce: retry.nonce,
|
|
825
|
+
integrityKey,
|
|
826
|
+
};
|
|
827
|
+
const result = await this.request(request, this.server, undefined, { signal }, undefined, credentials);
|
|
828
|
+
this.nonce = credentials.nonce;
|
|
829
|
+
this.realm = credentials.realm;
|
|
830
|
+
this.integrityKey = credentials.integrityKey;
|
|
831
|
+
return result;
|
|
832
|
+
}
|
|
833
|
+
this.nonce = retry.nonce;
|
|
834
|
+
this.realm = retry.realm;
|
|
835
|
+
this.integrityKey = integrityKey;
|
|
836
|
+
return await this.request(request, this.server, undefined, { signal });
|
|
760
837
|
}
|
|
761
|
-
return [message, address];
|
|
762
838
|
}
|
|
763
839
|
async sendData(data, addr) {
|
|
764
840
|
let channel;
|