werift 0.25.2 → 0.27.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 +63 -0
- package/THIRD_PARTY_LICENSES_LIBWEBRTC.txt +58 -0
- package/lib/common/src/asn1.d.ts +42 -0
- package/lib/common/src/asn1.js +163 -0
- package/lib/common/src/asn1.js.map +1 -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/index.d.ts +6 -5
- package/lib/common/src/index.js +6 -5
- package/lib/common/src/index.js.map +1 -1
- package/lib/common/src/log.d.ts +12 -1
- package/lib/common/src/log.js +142 -12
- package/lib/common/src/log.js.map +1 -1
- package/lib/common/src/network.js.map +1 -1
- package/lib/common/src/queue.d.ts +41 -0
- package/lib/common/src/queue.js +146 -0
- package/lib/common/src/queue.js.map +1 -0
- package/lib/common/src/transport.d.ts +15 -2
- package/lib/common/src/transport.js +108 -19
- package/lib/common/src/transport.js.map +1 -1
- package/lib/dtls/src/cipher/create.js.map +1 -1
- package/lib/dtls/src/cipher/ec.js +8 -8
- package/lib/dtls/src/cipher/ec.js.map +1 -1
- package/lib/dtls/src/cipher/namedCurve.js +6 -7
- package/lib/dtls/src/cipher/namedCurve.js.map +1 -1
- package/lib/dtls/src/cipher/prf.d.ts +2 -2
- package/lib/dtls/src/cipher/prf.js +29 -8
- package/lib/dtls/src/cipher/prf.js.map +1 -1
- package/lib/dtls/src/cipher/suites/aead.d.ts +1 -1
- package/lib/dtls/src/context/certificate.d.ts +32 -0
- package/lib/dtls/src/context/certificate.js +54 -0
- package/lib/dtls/src/context/certificate.js.map +1 -0
- package/lib/dtls/src/context/cipher.d.ts +13 -7
- package/lib/dtls/src/context/cipher.js +58 -106
- package/lib/dtls/src/context/cipher.js.map +1 -1
- package/lib/dtls/src/context/dtls.js +4 -2
- package/lib/dtls/src/context/dtls.js.map +1 -1
- package/lib/dtls/src/context/transport.d.ts +4 -0
- package/lib/dtls/src/context/transport.js +16 -1
- 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 +4 -2
- package/lib/dtls/src/flight/client/flight5.js.map +1 -1
- package/lib/dtls/src/flight/flight.d.ts +1 -1
- package/lib/dtls/src/flight/flight.js +16 -5
- package/lib/dtls/src/flight/flight.js.map +1 -1
- package/lib/dtls/src/flight/server/flight2.js.map +1 -1
- package/lib/dtls/src/flight/server/flight4.d.ts +2 -1
- package/lib/dtls/src/flight/server/flight4.js +12 -4
- package/lib/dtls/src/flight/server/flight4.js.map +1 -1
- package/lib/dtls/src/flight/server/flight6.js +2 -1
- 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/extensions/signature.d.ts +1 -1
- package/lib/dtls/src/handshake/extensions/signature.js.map +1 -1
- package/lib/dtls/src/handshake/message/alert.js +5 -3
- package/lib/dtls/src/handshake/message/alert.js.map +1 -1
- package/lib/dtls/src/handshake/message/certificate.js +3 -2
- package/lib/dtls/src/handshake/message/certificate.js.map +1 -1
- package/lib/dtls/src/handshake/message/changeCipherSpec.js +4 -4
- package/lib/dtls/src/handshake/message/changeCipherSpec.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/certificateVerify.d.ts +1 -1
- package/lib/dtls/src/handshake/message/client/certificateVerify.js +5 -3
- package/lib/dtls/src/handshake/message/client/certificateVerify.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/hello.js +15 -8
- package/lib/dtls/src/handshake/message/client/hello.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/keyExchange.js +3 -2
- 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.d.ts +1 -1
- package/lib/dtls/src/handshake/message/server/certificateRequest.js +7 -4
- package/lib/dtls/src/handshake/message/server/certificateRequest.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/hello.d.ts +1 -1
- package/lib/dtls/src/handshake/message/server/hello.js +14 -8
- package/lib/dtls/src/handshake/message/server/hello.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/helloDone.js +1 -1
- package/lib/dtls/src/handshake/message/server/helloDone.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js +5 -3
- package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/keyExchange.d.ts +1 -1
- package/lib/dtls/src/handshake/message/server/keyExchange.js +17 -9
- package/lib/dtls/src/handshake/message/server/keyExchange.js.map +1 -1
- package/lib/dtls/src/handshake/random.d.ts +1 -1
- package/lib/dtls/src/handshake/random.js +7 -4
- package/lib/dtls/src/handshake/random.js.map +1 -1
- package/lib/dtls/src/imports/common.d.ts +1 -0
- package/lib/dtls/src/imports/common.js +1 -0
- package/lib/dtls/src/imports/common.js.map +1 -1
- package/lib/dtls/src/index.d.ts +2 -2
- package/lib/dtls/src/index.js +2 -2
- package/lib/dtls/src/index.js.map +1 -1
- package/lib/dtls/src/record/const.d.ts +43 -33
- package/lib/dtls/src/record/const.js +43 -36
- package/lib/dtls/src/record/const.js.map +1 -1
- package/lib/dtls/src/record/message/fragment.d.ts +1 -1
- package/lib/dtls/src/record/message/fragment.js +15 -9
- package/lib/dtls/src/record/message/fragment.js.map +1 -1
- package/lib/dtls/src/record/message/header.js +12 -7
- 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.js +2 -2
- package/lib/dtls/src/record/receive.js.map +1 -1
- package/lib/dtls/src/server.js +1 -1
- package/lib/dtls/src/server.js.map +1 -1
- package/lib/dtls/src/socket.d.ts +2 -2
- package/lib/dtls/src/socket.js +6 -4
- 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/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 +46 -0
- package/lib/ice/src/exceptions.js +92 -5
- package/lib/ice/src/exceptions.js.map +1 -1
- package/lib/ice/src/helper.d.ts +1 -1
- package/lib/ice/src/ice.d.ts +191 -5
- package/lib/ice/src/ice.js +1048 -156
- package/lib/ice/src/ice.js.map +1 -1
- package/lib/ice/src/iceBase.d.ts +174 -10
- package/lib/ice/src/iceBase.js +165 -12
- package/lib/ice/src/iceBase.js.map +1 -1
- package/lib/ice/src/index.d.ts +5 -5
- package/lib/ice/src/index.js +5 -5
- package/lib/ice/src/index.js.map +1 -1
- package/lib/ice/src/internal/resolveHostAddresses.d.ts +26 -0
- package/lib/ice/src/internal/resolveHostAddresses.js +45 -0
- package/lib/ice/src/internal/resolveHostAddresses.js.map +1 -0
- package/lib/ice/src/stun/protocol.d.ts +3 -1
- package/lib/ice/src/stun/protocol.js +16 -0
- package/lib/ice/src/stun/protocol.js.map +1 -1
- package/lib/ice/src/stun/tcpProtocol.d.ts +2 -0
- package/lib/ice/src/stun/tcpProtocol.js +16 -1
- package/lib/ice/src/stun/tcpProtocol.js.map +1 -1
- package/lib/ice/src/stun/transaction.d.ts +35 -1
- package/lib/ice/src/stun/transaction.js +93 -18
- 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 +97 -7
- package/lib/ice/src/turn/protocol.js +357 -55
- package/lib/ice/src/turn/protocol.js.map +1 -1
- package/lib/ice/src/utils.js.map +1 -1
- package/lib/ice-server/src/stun/attributes.d.ts +2 -0
- package/lib/ice-server/src/stun/attributes.js +7 -1
- package/lib/ice-server/src/stun/attributes.js.map +1 -1
- package/lib/ice-server/src/stun/const.d.ts +24 -16
- package/lib/ice-server/src/stun/const.js +22 -18
- package/lib/ice-server/src/stun/const.js.map +1 -1
- package/lib/ice-server/src/stun/message.d.ts +3 -1
- package/lib/ice-server/src/stun/message.js +41 -6
- package/lib/ice-server/src/stun/message.js.map +1 -1
- package/lib/ice-server/src/turn/auth.d.ts +1 -1
- package/lib/index.mjs +25252 -12664
- package/lib/nonstandard/index.mjs +11015 -8906
- package/lib/polyfill/dom.mjs +30779 -18386
- package/lib/polyfill/index.mjs +30779 -18386
- 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.d.ts +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/container.d.ts +1 -1
- package/lib/rtp/src/extra/container/webm/ebml/ebml.d.ts +6 -0
- package/lib/rtp/src/extra/container/webm/ebml/ebml.js +26 -4
- package/lib/rtp/src/extra/container/webm/ebml/ebml.js.map +1 -1
- package/lib/rtp/src/extra/processor/depacketizer.d.ts +6 -1
- package/lib/rtp/src/extra/processor/depacketizer.js +29 -3
- package/lib/rtp/src/extra/processor/depacketizer.js.map +1 -1
- package/lib/rtp/src/extra/processor/depacketizerCallback.d.ts +1 -11
- package/lib/rtp/src/extra/processor/depacketizerTransformer.d.ts +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/dtxCallback.d.ts +1 -11
- 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/interface.d.ts +16 -11
- package/lib/rtp/src/extra/processor/interface.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/jitterBufferCallback.d.ts +1 -11
- package/lib/rtp/src/extra/processor/jitterBufferTransformer.d.ts +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 +7 -4
- 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.d.ts +1 -1
- package/lib/rtp/src/extra/processor/nack.js +5 -3
- package/lib/rtp/src/extra/processor/nack.js.map +1 -1
- package/lib/rtp/src/extra/processor/nackHandlerCallback.d.ts +1 -11
- 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/ntpTimeCallback.d.ts +1 -11
- 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/rtcpCallback.d.ts +1 -1
- package/lib/rtp/src/extra/processor/rtcpCallback.js.map +1 -1
- package/lib/rtp/src/extra/processor/rtpCallback.d.ts +1 -1
- package/lib/rtp/src/extra/processor/rtpCallback.js +3 -2
- package/lib/rtp/src/extra/processor/rtpCallback.js.map +1 -1
- package/lib/rtp/src/extra/processor/rtpStream.d.ts +2 -2
- 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/rtpTimeCallback.d.ts +1 -11
- package/lib/rtp/src/extra/processor/webm.d.ts +27 -0
- package/lib/rtp/src/extra/processor/webm.js +57 -23
- package/lib/rtp/src/extra/processor/webm.js.map +1 -1
- package/lib/rtp/src/extra/processor/webmCallback.js +6 -1
- package/lib/rtp/src/extra/processor/webmCallback.js.map +1 -1
- package/lib/rtp/src/extra/processor/webmStream.js.map +1 -1
- package/lib/rtp/src/helper.d.ts +2 -2
- package/lib/rtp/src/helper.js +2 -6
- package/lib/rtp/src/helper.js.map +1 -1
- package/lib/rtp/src/index.d.ts +10 -2
- package/lib/rtp/src/index.js +10 -2
- 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 +6 -1
- package/lib/rtp/src/rtcp/psfb/fullIntraRequest.js.map +1 -1
- package/lib/rtp/src/rtcp/rtcp.js +9 -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.d.ts +4 -3
- package/lib/rtp/src/rtcp/sr.js +4 -2
- package/lib/rtp/src/rtcp/sr.js.map +1 -1
- package/lib/rtp/src/rtp/continuity.d.ts +36 -0
- package/lib/rtp/src/rtp/continuity.js +100 -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/srtp/cipher/ctr.d.ts +2 -2
- package/lib/rtp/src/srtp/cipher/ctr.js +5 -3
- package/lib/rtp/src/srtp/cipher/ctr.js.map +1 -1
- package/lib/rtp/src/srtp/cipher/gcm.d.ts +1 -1
- package/lib/rtp/src/srtp/cipher/gcm.js +1 -1
- package/lib/rtp/src/srtp/cipher/gcm.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.d.ts +29 -1
- package/lib/rtp/src/srtp/context/context.js +84 -27
- 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 +36 -4
- 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/index.d.ts +4 -3
- package/lib/sctp/src/index.js +10 -8
- package/lib/sctp/src/index.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 +91 -2
- package/lib/sctp/src/sctp.js +700 -134
- 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/peerConfig.d.ts +307 -0
- package/lib/webrtc/src/api/peerConfig.js +291 -0
- package/lib/webrtc/src/api/peerConfig.js.map +1 -0
- package/lib/webrtc/src/api/peerConnectionEvents.d.ts +36 -0
- package/lib/webrtc/src/api/peerConnectionEvents.js +44 -0
- package/lib/webrtc/src/api/peerConnectionEvents.js.map +1 -0
- package/lib/webrtc/src/dataChannel.d.ts +11 -1
- package/lib/webrtc/src/dataChannel.js +25 -5
- package/lib/webrtc/src/dataChannel.js.map +1 -1
- package/lib/webrtc/src/index.d.ts +2 -2
- package/lib/webrtc/src/index.js +2 -2
- package/lib/webrtc/src/index.js.map +1 -1
- package/lib/webrtc/src/media/index.d.ts +11 -1
- package/lib/webrtc/src/media/index.js +71 -1
- package/lib/webrtc/src/media/index.js.map +1 -1
- package/lib/webrtc/src/media/receiver/nack.js +5 -5
- 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 +130 -6
- package/lib/webrtc/src/media/router.js +325 -29
- package/lib/webrtc/src/media/router.js.map +1 -1
- package/lib/webrtc/src/media/rtpReceiver.d.ts +137 -14
- package/lib/webrtc/src/media/rtpReceiver.js +420 -44
- package/lib/webrtc/src/media/rtpReceiver.js.map +1 -1
- package/lib/webrtc/src/media/rtpSender.d.ts +232 -65
- package/lib/webrtc/src/media/rtpSender.js +784 -448
- package/lib/webrtc/src/media/rtpSender.js.map +1 -1
- package/lib/webrtc/src/media/rtpTransceiver.d.ts +95 -4
- package/lib/webrtc/src/media/rtpTransceiver.js +121 -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 -32
- package/lib/webrtc/src/media/sender/senderBWE.js +5 -142
- package/lib/webrtc/src/media/sender/senderBWE.js.map +1 -1
- package/lib/webrtc/src/media/sender/senderStats.d.ts +100 -0
- package/lib/webrtc/src/media/sender/senderStats.js +322 -0
- package/lib/webrtc/src/media/sender/senderStats.js.map +1 -0
- package/lib/webrtc/src/media/track.d.ts +21 -3
- package/lib/webrtc/src/media/track.js +24 -6
- package/lib/webrtc/src/media/track.js.map +1 -1
- package/lib/webrtc/src/negotiation/bundleTopology.d.ts +103 -0
- package/lib/webrtc/src/negotiation/bundleTopology.js +384 -0
- package/lib/webrtc/src/negotiation/bundleTopology.js.map +1 -0
- package/lib/webrtc/src/negotiation/descriptionValidation.d.ts +51 -0
- package/lib/webrtc/src/negotiation/descriptionValidation.js +267 -0
- package/lib/webrtc/src/negotiation/descriptionValidation.js.map +1 -0
- package/lib/webrtc/src/negotiation/iceRestartRequest.d.ts +21 -0
- package/lib/webrtc/src/negotiation/iceRestartRequest.js +61 -0
- package/lib/webrtc/src/negotiation/iceRestartRequest.js.map +1 -0
- package/lib/webrtc/src/negotiation/internalState.d.ts +34 -0
- package/lib/webrtc/src/negotiation/internalState.js +21 -0
- package/lib/webrtc/src/negotiation/internalState.js.map +1 -0
- package/lib/webrtc/src/negotiation/negotiationNeeded.d.ts +44 -0
- package/lib/webrtc/src/negotiation/negotiationNeeded.js +119 -0
- package/lib/webrtc/src/negotiation/negotiationNeeded.js.map +1 -0
- package/lib/webrtc/src/negotiation/remoteCandidates.d.ts +86 -0
- package/lib/webrtc/src/negotiation/remoteCandidates.js +349 -0
- package/lib/webrtc/src/negotiation/remoteCandidates.js.map +1 -0
- package/lib/webrtc/src/negotiation/remoteMediaApplication.d.ts +71 -0
- package/lib/webrtc/src/negotiation/remoteMediaApplication.js +414 -0
- package/lib/webrtc/src/negotiation/remoteMediaApplication.js.map +1 -0
- package/lib/webrtc/src/negotiation/transportActivation.d.ts +59 -0
- package/lib/webrtc/src/negotiation/transportActivation.js +356 -0
- package/lib/webrtc/src/negotiation/transportActivation.js.map +1 -0
- package/lib/webrtc/src/negotiationTransaction.d.ts +240 -0
- package/lib/webrtc/src/negotiationTransaction.js +604 -0
- package/lib/webrtc/src/negotiationTransaction.js.map +1 -0
- package/lib/webrtc/src/nonstandard/dummyMedia.js +2 -1
- package/lib/webrtc/src/nonstandard/dummyMedia.js.map +1 -1
- package/lib/webrtc/src/nonstandard/index.d.ts +1 -1
- package/lib/webrtc/src/nonstandard/index.js +1 -1
- package/lib/webrtc/src/nonstandard/index.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 +10 -8
- 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.d.ts +2 -2
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js +10 -3
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js.map +1 -1
- package/lib/webrtc/src/nonstandard/userMedia/packetizer.d.ts +2 -2
- package/lib/webrtc/src/nonstandard/userMedia/packetizer.js.map +1 -1
- package/lib/webrtc/src/nonstandard/userMedia.d.ts +2 -2
- package/lib/webrtc/src/nonstandard/userMedia.js +4 -3
- package/lib/webrtc/src/nonstandard/userMedia.js.map +1 -1
- package/lib/webrtc/src/peerConnection.d.ts +176 -238
- package/lib/webrtc/src/peerConnection.js +1042 -913
- package/lib/webrtc/src/peerConnection.js.map +1 -1
- package/lib/webrtc/src/polyfill/api.d.ts +5 -5
- package/lib/webrtc/src/polyfill/api.js.map +1 -1
- package/lib/webrtc/src/polyfill/index.js.map +1 -1
- package/lib/webrtc/src/polyfill/install.js +1 -1
- 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/polyfill/registers/mp4Webm.js.map +1 -1
- package/lib/webrtc/src/polyfill/registers/rtpRtcp.js.map +1 -1
- package/lib/webrtc/src/polyfill/selectSettings.js.map +1 -1
- package/lib/webrtc/src/polyfill/sourceIo.js.map +1 -1
- package/lib/webrtc/src/sctpManager.d.ts +97 -1
- package/lib/webrtc/src/sctpManager.js +189 -9
- package/lib/webrtc/src/sctpManager.js.map +1 -1
- package/lib/webrtc/src/sdp.js +12 -6
- package/lib/webrtc/src/sdp.js.map +1 -1
- package/lib/webrtc/src/sdpManager.d.ts +55 -11
- package/lib/webrtc/src/sdpManager.js +364 -87
- package/lib/webrtc/src/sdpManager.js.map +1 -1
- package/lib/webrtc/src/secureTransportManager.d.ts +89 -28
- package/lib/webrtc/src/secureTransportManager.js +232 -53
- package/lib/webrtc/src/secureTransportManager.js.map +1 -1
- package/lib/webrtc/src/transceiverManager.d.ts +62 -18
- package/lib/webrtc/src/transceiverManager.js +272 -107
- package/lib/webrtc/src/transceiverManager.js.map +1 -1
- package/lib/webrtc/src/transport/dtls.d.ts +64 -3
- package/lib/webrtc/src/transport/dtls.js +166 -42
- package/lib/webrtc/src/transport/dtls.js.map +1 -1
- package/lib/webrtc/src/transport/ice.d.ts +199 -28
- package/lib/webrtc/src/transport/ice.js +666 -71
- package/lib/webrtc/src/transport/ice.js.map +1 -1
- package/lib/webrtc/src/transport/iceCandidateAttribute.d.ts +98 -0
- package/lib/webrtc/src/transport/iceCandidateAttribute.js +129 -0
- package/lib/webrtc/src/transport/iceCandidateAttribute.js.map +1 -0
- package/lib/webrtc/src/transport/sctp.d.ts +6 -1
- package/lib/webrtc/src/transport/sctp.js +149 -37
- package/lib/webrtc/src/transport/sctp.js.map +1 -1
- package/lib/webrtc/src/utils.d.ts +39 -6
- package/lib/webrtc/src/utils.js +57 -17
- package/lib/webrtc/src/utils.js.map +1 -1
- package/package.json +16 -15
|
@@ -1,10 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TurnProtocol = exports.StunOverTurnProtocol = void 0;
|
|
36
|
+
exports.TurnProtocol = exports.StunOverTurnProtocol = exports.TurnRedirectError = void 0;
|
|
4
37
|
exports.createTurnClient = createTurnClient;
|
|
5
38
|
exports.createStunOverTurnClient = createStunOverTurnClient;
|
|
6
39
|
exports.makeIntegrityKey = makeIntegrityKey;
|
|
7
40
|
const node_net_1 = require("node:net");
|
|
41
|
+
const tls = __importStar(require("node:tls"));
|
|
8
42
|
const promises_1 = require("timers/promises");
|
|
9
43
|
const auth_1 = require("../../../ice-server/src/turn/auth");
|
|
10
44
|
const exceptions_1 = require("../exceptions");
|
|
@@ -13,11 +47,16 @@ const common_1 = require("../imports/common");
|
|
|
13
47
|
const const_1 = require("../stun/const");
|
|
14
48
|
const message_1 = require("../stun/message");
|
|
15
49
|
const transaction_1 = require("../stun/transaction");
|
|
50
|
+
const credential_1 = require("./credential");
|
|
16
51
|
const frame_1 = require("./frame");
|
|
17
52
|
const log = (0, common_1.debug)("werift-ice:packages/ice/src/turn/protocol.ts");
|
|
18
53
|
const DEFAULT_CHANNEL_REFRESH_TIME = 500;
|
|
19
54
|
const DEFAULT_ALLOCATION_LIFETIME = 600;
|
|
20
55
|
const UDP_TRANSPORT = 0x11000000;
|
|
56
|
+
/** 300 (Try Alternate) redirects followed for one Allocate before giving up. */
|
|
57
|
+
const DEFAULT_MAX_ALLOCATE_REDIRECTS = 3;
|
|
58
|
+
var exceptions_2 = require("../exceptions");
|
|
59
|
+
Object.defineProperty(exports, "TurnRedirectError", { enumerable: true, get: function () { return exceptions_2.TurnRedirectError; } });
|
|
21
60
|
function isStreamTransport(transport) {
|
|
22
61
|
return transport.type === "tcp" || transport.type === "tls";
|
|
23
62
|
}
|
|
@@ -35,7 +74,18 @@ class StunOverTurnProtocol {
|
|
|
35
74
|
enumerable: true,
|
|
36
75
|
configurable: true,
|
|
37
76
|
writable: true,
|
|
38
|
-
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
|
|
39
89
|
});
|
|
40
90
|
Object.defineProperty(this, "type", {
|
|
41
91
|
enumerable: true,
|
|
@@ -101,6 +151,7 @@ class StunOverTurnProtocol {
|
|
|
101
151
|
}
|
|
102
152
|
}
|
|
103
153
|
});
|
|
154
|
+
this.turn = turn;
|
|
104
155
|
turn.onData
|
|
105
156
|
.subscribe((data, addr) => {
|
|
106
157
|
this.handleStunMessage(data, addr);
|
|
@@ -153,44 +204,47 @@ Object.defineProperty(StunOverTurnProtocol, "type", {
|
|
|
153
204
|
value: "turn"
|
|
154
205
|
});
|
|
155
206
|
class TurnProtocol {
|
|
156
|
-
constructor(
|
|
157
|
-
|
|
158
|
-
|
|
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
|
+
*/
|
|
159
213
|
Object.defineProperty(this, "server", {
|
|
160
214
|
enumerable: true,
|
|
161
215
|
configurable: true,
|
|
162
216
|
writable: true,
|
|
163
|
-
value:
|
|
217
|
+
value: void 0
|
|
164
218
|
});
|
|
165
219
|
Object.defineProperty(this, "username", {
|
|
166
220
|
enumerable: true,
|
|
167
221
|
configurable: true,
|
|
168
222
|
writable: true,
|
|
169
|
-
value:
|
|
223
|
+
value: void 0
|
|
170
224
|
});
|
|
171
225
|
Object.defineProperty(this, "password", {
|
|
172
226
|
enumerable: true,
|
|
173
227
|
configurable: true,
|
|
174
228
|
writable: true,
|
|
175
|
-
value:
|
|
229
|
+
value: void 0
|
|
176
230
|
});
|
|
177
231
|
Object.defineProperty(this, "lifetime", {
|
|
178
232
|
enumerable: true,
|
|
179
233
|
configurable: true,
|
|
180
234
|
writable: true,
|
|
181
|
-
value:
|
|
235
|
+
value: void 0
|
|
182
236
|
});
|
|
183
237
|
Object.defineProperty(this, "transport", {
|
|
184
238
|
enumerable: true,
|
|
185
239
|
configurable: true,
|
|
186
240
|
writable: true,
|
|
187
|
-
value:
|
|
241
|
+
value: void 0
|
|
188
242
|
});
|
|
189
243
|
Object.defineProperty(this, "options", {
|
|
190
244
|
enumerable: true,
|
|
191
245
|
configurable: true,
|
|
192
246
|
writable: true,
|
|
193
|
-
value:
|
|
247
|
+
value: void 0
|
|
194
248
|
});
|
|
195
249
|
Object.defineProperty(this, "type", {
|
|
196
250
|
enumerable: true,
|
|
@@ -258,6 +312,13 @@ class TurnProtocol {
|
|
|
258
312
|
writable: true,
|
|
259
313
|
value: {}
|
|
260
314
|
});
|
|
315
|
+
/** close() ran: no new transaction starts. */
|
|
316
|
+
Object.defineProperty(this, "closed", {
|
|
317
|
+
enumerable: true,
|
|
318
|
+
configurable: true,
|
|
319
|
+
writable: true,
|
|
320
|
+
value: false
|
|
321
|
+
});
|
|
261
322
|
Object.defineProperty(this, "refreshHandle", {
|
|
262
323
|
enumerable: true,
|
|
263
324
|
configurable: true,
|
|
@@ -350,6 +411,13 @@ class TurnProtocol {
|
|
|
350
411
|
writable: true,
|
|
351
412
|
value: void 0
|
|
352
413
|
});
|
|
414
|
+
/** TURN server as configured, before any 300 (Try Alternate) redirect. */
|
|
415
|
+
Object.defineProperty(this, "configuredServer", {
|
|
416
|
+
enumerable: true,
|
|
417
|
+
configurable: true,
|
|
418
|
+
writable: true,
|
|
419
|
+
value: void 0
|
|
420
|
+
});
|
|
353
421
|
Object.defineProperty(this, "refresh", {
|
|
354
422
|
enumerable: true,
|
|
355
423
|
configurable: true,
|
|
@@ -393,18 +461,19 @@ class TurnProtocol {
|
|
|
393
461
|
});
|
|
394
462
|
}
|
|
395
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;
|
|
470
|
+
this.configuredServer = server;
|
|
396
471
|
this.channelRefreshTime =
|
|
397
472
|
this.options.channelRefreshTime ?? DEFAULT_CHANNEL_REFRESH_TIME;
|
|
398
473
|
}
|
|
399
474
|
async connectionMade() {
|
|
400
|
-
this.
|
|
401
|
-
|
|
402
|
-
};
|
|
403
|
-
const request = new message_1.Message(const_1.methods.ALLOCATE, const_1.classes.REQUEST);
|
|
404
|
-
request
|
|
405
|
-
.setAttribute("LIFETIME", this.lifetime)
|
|
406
|
-
.setAttribute("REQUESTED-TRANSPORT", UDP_TRANSPORT);
|
|
407
|
-
const [response] = await this.requestWithRetry(request, this.server).catch((e) => {
|
|
475
|
+
this.attachTransport();
|
|
476
|
+
const [response] = await this.allocate().catch((e) => {
|
|
408
477
|
log("connect error", e);
|
|
409
478
|
throw e;
|
|
410
479
|
});
|
|
@@ -412,8 +481,106 @@ class TurnProtocol {
|
|
|
412
481
|
this.mappedAddress = response.getAttributeValue("XOR-MAPPED-ADDRESS");
|
|
413
482
|
const exp = response.getAttributeValue("LIFETIME");
|
|
414
483
|
log("connect", this.relayedAddress, this.mappedAddress, { exp });
|
|
484
|
+
// close() ran while the response was in flight: no refresh starts.
|
|
485
|
+
if (this.closed)
|
|
486
|
+
throw new exceptions_1.TransactionCancelled();
|
|
415
487
|
this.refresh(exp);
|
|
416
488
|
}
|
|
489
|
+
attachTransport() {
|
|
490
|
+
this.transport.onData = (data, addr) => {
|
|
491
|
+
this.dataReceived(data, addr);
|
|
492
|
+
};
|
|
493
|
+
this.transport.onError?.subscribe((error) => {
|
|
494
|
+
log("transport error", error);
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Allocate on the current server, following 300 (Try Alternate) to the
|
|
499
|
+
* ALTERNATE-SERVER with the same transport protocol and credentials
|
|
500
|
+
* (RFC 8656 §7.4, RFC 8489 §10). Only Allocate is redirected: an existing
|
|
501
|
+
* allocation lives on one server, so Refresh, CreatePermission and
|
|
502
|
+
* ChannelBind never move.
|
|
503
|
+
*/
|
|
504
|
+
async allocate() {
|
|
505
|
+
const maxRedirects = this.options.maxAllocateRedirects ?? DEFAULT_MAX_ALLOCATE_REDIRECTS;
|
|
506
|
+
/** Servers this Allocate has been sent to, to detect redirect loops. */
|
|
507
|
+
const tried = [];
|
|
508
|
+
for (let redirects = 0;; redirects++) {
|
|
509
|
+
// A fresh request per server: a redirected request may already carry
|
|
510
|
+
// MESSAGE-INTEGRITY for the previous server's realm and nonce.
|
|
511
|
+
const request = new message_1.Message(const_1.methods.ALLOCATE, const_1.classes.REQUEST)
|
|
512
|
+
.setAttribute("LIFETIME", this.lifetime)
|
|
513
|
+
.setAttribute("REQUESTED-TRANSPORT", UDP_TRANSPORT);
|
|
514
|
+
try {
|
|
515
|
+
return await this.requestWithRetry(request, this.server);
|
|
516
|
+
}
|
|
517
|
+
catch (error) {
|
|
518
|
+
const alternate = tryAlternateOf(error, this.transport.addressFamily);
|
|
519
|
+
if (!alternate) {
|
|
520
|
+
throw error;
|
|
521
|
+
}
|
|
522
|
+
// The request has resolved the configured host, so its endpoint is
|
|
523
|
+
// known here: a redirect to the resolved IP of a host name is a loop.
|
|
524
|
+
tried.push(this.server);
|
|
525
|
+
if (this.pinnedServerEndpoint) {
|
|
526
|
+
tried.push(this.pinnedServerEndpoint);
|
|
527
|
+
}
|
|
528
|
+
const failed = error;
|
|
529
|
+
const fail = (reason) => new exceptions_1.TurnRedirectError(reason, this.server, alternate.server, failed);
|
|
530
|
+
if (!alternate.server) {
|
|
531
|
+
throw new exceptions_1.TurnRedirectError("missing-alternate", this.server, undefined, failed);
|
|
532
|
+
}
|
|
533
|
+
if (tried.some((addr) => (0, transaction_1.addressEquals)(addr, alternate.server))) {
|
|
534
|
+
throw fail("loop");
|
|
535
|
+
}
|
|
536
|
+
if (redirects >= maxRedirects) {
|
|
537
|
+
throw fail("too-many-redirects");
|
|
538
|
+
}
|
|
539
|
+
if (isStreamTransport(this.transport) && !this.options.reconnect) {
|
|
540
|
+
throw fail("unsupported-transport");
|
|
541
|
+
}
|
|
542
|
+
log("allocate redirected", this.server, "->", alternate);
|
|
543
|
+
await this.switchServer(alternate);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Point the client at an ALTERNATE-SERVER. Authentication state belongs to
|
|
549
|
+
* the previous server, so the alternate starts again with an
|
|
550
|
+
* unauthenticated Allocate and its own 401 realm/nonce; username and
|
|
551
|
+
* password are kept.
|
|
552
|
+
*/
|
|
553
|
+
async switchServer({ server, domain }) {
|
|
554
|
+
let endpoint;
|
|
555
|
+
if (isStreamTransport(this.transport)) {
|
|
556
|
+
const previous = this.transport;
|
|
557
|
+
previous.onData = () => { };
|
|
558
|
+
await previous.close();
|
|
559
|
+
const reconnected = await this.options.reconnect(server, domain);
|
|
560
|
+
// close() ran while reconnecting: it saw only the closed previous
|
|
561
|
+
// transport, so the new connection is released here.
|
|
562
|
+
if (this.closed) {
|
|
563
|
+
reconnected.onData = () => { };
|
|
564
|
+
await reconnected.close();
|
|
565
|
+
throw new exceptions_1.TransactionCancelled();
|
|
566
|
+
}
|
|
567
|
+
this.transport = reconnected;
|
|
568
|
+
this.tcpBuffer = Buffer.alloc(0);
|
|
569
|
+
this.attachTransport();
|
|
570
|
+
endpoint = this.transport.remoteAddress ?? server;
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
// ALTERNATE-SERVER is an IP literal. One of the other family cannot be
|
|
574
|
+
// reached from this socket (AddressFamilyMismatch).
|
|
575
|
+
endpoint = await (0, transaction_1.resolveRequestAddress)(server, this.transport.addressFamily ?? 0);
|
|
576
|
+
}
|
|
577
|
+
this.server = server;
|
|
578
|
+
this.pinnedServerEndpoint = endpoint;
|
|
579
|
+
this.serverEndpointSelection = Promise.resolve(endpoint);
|
|
580
|
+
this.nonce = undefined;
|
|
581
|
+
this.realm = undefined;
|
|
582
|
+
this.integrityKey = undefined;
|
|
583
|
+
}
|
|
417
584
|
handleChannelData(data) {
|
|
418
585
|
const decoded = (0, frame_1.decodeChannelData)(data);
|
|
419
586
|
const addr = decoded && this.addrByChannel[decoded.channelNumber];
|
|
@@ -431,14 +598,7 @@ class TurnProtocol {
|
|
|
431
598
|
message.messageClass === const_1.classes.ERROR) {
|
|
432
599
|
const transaction = this.transactions[message.transactionIdHex];
|
|
433
600
|
if (transaction) {
|
|
434
|
-
|
|
435
|
-
? (0, message_1.parseMessage)(data, transaction.integrityKey)
|
|
436
|
-
: message;
|
|
437
|
-
if (!verified) {
|
|
438
|
-
log("TURN STUN response failed MESSAGE-INTEGRITY check");
|
|
439
|
-
return;
|
|
440
|
-
}
|
|
441
|
-
transaction.responseReceived(verified, addr);
|
|
601
|
+
this.handleResponse(transaction, message, data, addr);
|
|
442
602
|
}
|
|
443
603
|
}
|
|
444
604
|
else if (message.messageClass === const_1.classes.REQUEST) {
|
|
@@ -454,6 +614,37 @@ class TurnProtocol {
|
|
|
454
614
|
log("parse error", data.toString());
|
|
455
615
|
}
|
|
456
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
|
+
}
|
|
457
648
|
dataReceived(data, addr) {
|
|
458
649
|
const datagramReceived = (data, addr) => {
|
|
459
650
|
if (data.length >= 4 && (0, frame_1.isChannelData)(data)) {
|
|
@@ -491,23 +682,36 @@ class TurnProtocol {
|
|
|
491
682
|
// Use requestWithRetry for stale-nonce (438) consistency with ChannelBind.
|
|
492
683
|
await this.requestWithRetry(request, this.server);
|
|
493
684
|
}
|
|
494
|
-
async request(request, addr, _integrityKey, retransmissionsOrOptions, onRequestSent) {
|
|
685
|
+
async request(request, addr, _integrityKey, retransmissionsOrOptions, onRequestSent, credentials) {
|
|
495
686
|
if (this.transactions[request.transactionIdHex]) {
|
|
496
687
|
throw new Error("exist");
|
|
497
688
|
}
|
|
498
|
-
|
|
689
|
+
const signing = credentials ?? {
|
|
690
|
+
realm: this.realm,
|
|
691
|
+
nonce: this.nonce,
|
|
692
|
+
integrityKey: this.integrityKey,
|
|
693
|
+
};
|
|
694
|
+
if (signing.integrityKey) {
|
|
695
|
+
// A retried request still carries the previous signature, which would
|
|
696
|
+
// otherwise be covered by the new MESSAGE-INTEGRITY.
|
|
499
697
|
request
|
|
698
|
+
.removeAttribute("MESSAGE-INTEGRITY")
|
|
699
|
+
.removeAttribute("MESSAGE-INTEGRITY-SHA256")
|
|
700
|
+
.removeAttribute("FINGERPRINT")
|
|
500
701
|
.setAttribute("USERNAME", this.username)
|
|
501
|
-
.setAttribute("REALM",
|
|
502
|
-
.setAttribute("NONCE",
|
|
503
|
-
.addMessageIntegrity(
|
|
702
|
+
.setAttribute("REALM", signing.realm)
|
|
703
|
+
.setAttribute("NONCE", signing.nonce)
|
|
704
|
+
.addMessageIntegrity(signing.integrityKey)
|
|
504
705
|
.addFingerprint();
|
|
505
706
|
}
|
|
506
707
|
// TURN server allocation/refresh uses default STUN retry policy unless
|
|
507
708
|
// callers pass explicit options. Peer consent goes through StunOverTurnProtocol.
|
|
508
709
|
// Prefer the TURN session integrity key for response verification.
|
|
509
710
|
const resolvedAddr = await this.resolveRequestTarget(addr);
|
|
510
|
-
|
|
711
|
+
// close() ran during the lookup: no transaction starts on a closed client.
|
|
712
|
+
if (this.closed)
|
|
713
|
+
throw new exceptions_1.TransactionCancelled();
|
|
714
|
+
const options = (0, transaction_1.buildTransactionOptions)(signing.integrityKey, retransmissionsOrOptions, onRequestSent);
|
|
511
715
|
const transaction = new transaction_1.Transaction(request, resolvedAddr, this, options);
|
|
512
716
|
this.transactions[request.transactionIdHex] = transaction;
|
|
513
717
|
try {
|
|
@@ -576,37 +780,58 @@ class TurnProtocol {
|
|
|
576
780
|
// a lookup with no family preference.
|
|
577
781
|
return (0, transaction_1.resolveRequestAddress)(this.server);
|
|
578
782
|
}
|
|
783
|
+
/**
|
|
784
|
+
* Send a request and follow the long-term credential mechanism of
|
|
785
|
+
* RFC 8489 §9.2.5: a 401 (Unauthenticated) or 438 (Stale Nonce) that
|
|
786
|
+
* allows it (see credentialRetryOf) is retried once with the new realm and
|
|
787
|
+
* nonce; any other error, or a second challenge, is thrown. The allocation's
|
|
788
|
+
* realm, nonce and integrity key change only when a retry is made; a retry
|
|
789
|
+
* under a new realm adopts them only once the server accepted it.
|
|
790
|
+
*/
|
|
579
791
|
async requestWithRetry(request, addr, signal) {
|
|
580
|
-
let message, address;
|
|
581
792
|
try {
|
|
582
|
-
|
|
583
|
-
signal,
|
|
584
|
-
});
|
|
793
|
+
return await this.request(request, addr, undefined, { signal });
|
|
585
794
|
}
|
|
586
795
|
catch (error) {
|
|
587
796
|
if (error instanceof exceptions_1.TransactionFailed == false) {
|
|
588
797
|
log("requestWithRetry error", error);
|
|
589
798
|
throw error;
|
|
590
799
|
}
|
|
591
|
-
|
|
592
|
-
const
|
|
593
|
-
const
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
if (errorCode === 401) {
|
|
599
|
-
this.realm = realm;
|
|
600
|
-
}
|
|
601
|
-
this.integrityKey = makeIntegrityKey(this.username, this.realm, this.password);
|
|
602
|
-
request.transactionId = (0, helper_1.randomTransactionId)();
|
|
603
|
-
[message, address] = await this.request(request, this.server, undefined, { signal });
|
|
604
|
-
}
|
|
605
|
-
else {
|
|
800
|
+
// request() signed the request with the credentials of that moment.
|
|
801
|
+
const authenticated = request.attributesKeys.includes("MESSAGE-INTEGRITY");
|
|
802
|
+
const sentRealm = authenticated
|
|
803
|
+
? request.getAttributeValue("REALM")
|
|
804
|
+
: undefined;
|
|
805
|
+
const retry = (0, credential_1.credentialRetryOf)(error.response, { authenticated, realm: sentRealm }, this.realm);
|
|
806
|
+
if (!retry) {
|
|
606
807
|
throw error;
|
|
607
808
|
}
|
|
809
|
+
log("retry with nonce", error.str, {
|
|
810
|
+
signedError: !(error instanceof exceptions_1.TransactionChallenge),
|
|
811
|
+
});
|
|
812
|
+
const integrityKey = makeIntegrityKey(this.username, retry.realm, this.password);
|
|
813
|
+
request.transactionId = (0, helper_1.randomTransactionId)();
|
|
814
|
+
// A new realm on an authenticated request rekeys the whole allocation.
|
|
815
|
+
// Sign the retry with its own credentials and adopt them only once the
|
|
816
|
+
// server accepted it, so concurrent failures never overwrite the shared
|
|
817
|
+
// state with credentials that were rejected.
|
|
818
|
+
if (authenticated && retry.realm !== sentRealm) {
|
|
819
|
+
const credentials = {
|
|
820
|
+
realm: retry.realm,
|
|
821
|
+
nonce: retry.nonce,
|
|
822
|
+
integrityKey,
|
|
823
|
+
};
|
|
824
|
+
const result = await this.request(request, this.server, undefined, { signal }, undefined, credentials);
|
|
825
|
+
this.nonce = credentials.nonce;
|
|
826
|
+
this.realm = credentials.realm;
|
|
827
|
+
this.integrityKey = credentials.integrityKey;
|
|
828
|
+
return result;
|
|
829
|
+
}
|
|
830
|
+
this.nonce = retry.nonce;
|
|
831
|
+
this.realm = retry.realm;
|
|
832
|
+
this.integrityKey = integrityKey;
|
|
833
|
+
return await this.request(request, this.server, undefined, { signal });
|
|
608
834
|
}
|
|
609
|
-
return [message, address];
|
|
610
835
|
}
|
|
611
836
|
async sendData(data, addr) {
|
|
612
837
|
let channel;
|
|
@@ -751,7 +976,20 @@ class TurnProtocol {
|
|
|
751
976
|
async sendStun(message, addr) {
|
|
752
977
|
await this.send(message.bytes, addr);
|
|
753
978
|
}
|
|
979
|
+
/**
|
|
980
|
+
* Release the client: its transactions, refresh timer and socket. Known
|
|
981
|
+
* constraint (as in develop): the allocation is not deleted on the server
|
|
982
|
+
* (no Refresh with lifetime 0), so the server keeps it until its lifetime
|
|
983
|
+
* ends.
|
|
984
|
+
*/
|
|
754
985
|
async close() {
|
|
986
|
+
if (this.closed)
|
|
987
|
+
return;
|
|
988
|
+
this.closed = true;
|
|
989
|
+
// An allocation, refresh or ChannelBind still waiting settles now.
|
|
990
|
+
for (const transaction of Object.values(this.transactions)) {
|
|
991
|
+
transaction.cancel();
|
|
992
|
+
}
|
|
755
993
|
this.refreshHandle?.resolve?.();
|
|
756
994
|
await this.transport.close();
|
|
757
995
|
}
|
|
@@ -783,7 +1021,7 @@ function selectTurnUdpSocketType(address, udpFamily) {
|
|
|
783
1021
|
}
|
|
784
1022
|
return (udpFamily ?? 4) === 6 ? "udp6" : "udp4";
|
|
785
1023
|
}
|
|
786
|
-
async function createTurnClient({ address, username, password }, { lifetime, portRange, interfaceAddresses, ssl, tlsOptions, transport: transportType, connectTimeoutMs, udpFamily, } = {}) {
|
|
1024
|
+
async function createTurnClient({ address, username, password }, { lifetime, portRange, interfaceAddresses, ssl, tlsOptions, transport: transportType, connectTimeoutMs, udpFamily, signal, } = {}) {
|
|
787
1025
|
lifetime ?? (lifetime = DEFAULT_ALLOCATION_LIFETIME);
|
|
788
1026
|
transportType ?? (transportType = ssl ? "tls" : "udp");
|
|
789
1027
|
const transport = transportType === "udp"
|
|
@@ -794,9 +1032,29 @@ async function createTurnClient({ address, username, password }, { lifetime, por
|
|
|
794
1032
|
: transportType === "tcp"
|
|
795
1033
|
? await common_1.TcpTransport.init(address, { connectTimeoutMs })
|
|
796
1034
|
: await common_1.TlsTransport.init(address, tlsOptions, { connectTimeoutMs });
|
|
797
|
-
const turn = new TurnProtocol(address, username, password, lifetime, transport
|
|
1035
|
+
const turn = new TurnProtocol(address, username, password, lifetime, transport, {
|
|
1036
|
+
reconnect: transportType === "udp"
|
|
1037
|
+
? undefined
|
|
1038
|
+
: (alternate, alternateDomain) => transportType === "tcp"
|
|
1039
|
+
? common_1.TcpTransport.init(alternate, { connectTimeoutMs })
|
|
1040
|
+
: common_1.TlsTransport.init(alternate, alternateTlsOptions(address, alternateDomain, tlsOptions), { connectTimeoutMs }),
|
|
1041
|
+
});
|
|
1042
|
+
// The owner (an ICE agent) closed while the allocation runs: release the
|
|
1043
|
+
// socket and its retransmissions now instead of after the allocation.
|
|
1044
|
+
const abort = () => {
|
|
1045
|
+
turn
|
|
1046
|
+
.close()
|
|
1047
|
+
.catch((error) => log("failed to close aborted TURN client", error));
|
|
1048
|
+
};
|
|
1049
|
+
if (signal?.aborted)
|
|
1050
|
+
abort();
|
|
1051
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
798
1052
|
try {
|
|
1053
|
+
if (signal?.aborted)
|
|
1054
|
+
throw new exceptions_1.TransactionCancelled();
|
|
799
1055
|
await turn.connectionMade();
|
|
1056
|
+
if (signal?.aborted)
|
|
1057
|
+
throw new exceptions_1.TransactionCancelled();
|
|
800
1058
|
}
|
|
801
1059
|
catch (error) {
|
|
802
1060
|
try {
|
|
@@ -807,6 +1065,9 @@ async function createTurnClient({ address, username, password }, { lifetime, por
|
|
|
807
1065
|
}
|
|
808
1066
|
throw error;
|
|
809
1067
|
}
|
|
1068
|
+
finally {
|
|
1069
|
+
signal?.removeEventListener("abort", abort);
|
|
1070
|
+
}
|
|
810
1071
|
return turn;
|
|
811
1072
|
}
|
|
812
1073
|
async function createStunOverTurnClient(config, options = {}) {
|
|
@@ -814,6 +1075,47 @@ async function createStunOverTurnClient(config, options = {}) {
|
|
|
814
1075
|
const turnTransport = new StunOverTurnProtocol(turn);
|
|
815
1076
|
return turnTransport;
|
|
816
1077
|
}
|
|
1078
|
+
/**
|
|
1079
|
+
* TLS options for a connection to an ALTERNATE-SERVER (an IP literal). The
|
|
1080
|
+
* certificate is validated against ALTERNATE-DOMAIN when present, otherwise
|
|
1081
|
+
* against the name the original server would have been validated with
|
|
1082
|
+
* (RFC 8489 §10): `tlsOptions.servername`, else the configured host.
|
|
1083
|
+
*/
|
|
1084
|
+
function alternateTlsOptions(configured, alternateDomain, tlsOptions = {}) {
|
|
1085
|
+
const identity = alternateDomain ?? tlsOptions.servername ?? configured[0];
|
|
1086
|
+
const checkServerIdentity = tlsOptions.checkServerIdentity ?? tls.checkServerIdentity;
|
|
1087
|
+
return {
|
|
1088
|
+
...tlsOptions,
|
|
1089
|
+
// SNI cannot carry an IP literal.
|
|
1090
|
+
servername: (0, node_net_1.isIP)(identity) ? undefined : identity,
|
|
1091
|
+
checkServerIdentity: (_host, cert) => checkServerIdentity(identity, cert),
|
|
1092
|
+
};
|
|
1093
|
+
}
|
|
1094
|
+
/**
|
|
1095
|
+
* The redirect target of a 300 (Try Alternate) error response, or undefined
|
|
1096
|
+
* for any other error. `server` is undefined when ALTERNATE-SERVER is
|
|
1097
|
+
* missing.
|
|
1098
|
+
*/
|
|
1099
|
+
function tryAlternateOf(error, addressFamily) {
|
|
1100
|
+
if (!(error instanceof exceptions_1.TransactionFailed)) {
|
|
1101
|
+
return undefined;
|
|
1102
|
+
}
|
|
1103
|
+
const [errorCode] = error.response.getAttributeValue("ERROR-CODE") ?? [];
|
|
1104
|
+
if (errorCode !== 300) {
|
|
1105
|
+
return undefined;
|
|
1106
|
+
}
|
|
1107
|
+
// A response may carry one ALTERNATE-SERVER per address family (RFC 8489
|
|
1108
|
+
// §10): take the first one this transport can reach, else the first.
|
|
1109
|
+
const servers = error.response.alternateServers;
|
|
1110
|
+
const reachable = servers.find(([host]) => addressFamily === undefined || ipFamily(host) === addressFamily);
|
|
1111
|
+
return {
|
|
1112
|
+
server: reachable ?? servers[0],
|
|
1113
|
+
domain: error.response.getAttributeValue("ALTERNATE-DOMAIN"),
|
|
1114
|
+
};
|
|
1115
|
+
}
|
|
1116
|
+
function ipFamily(host) {
|
|
1117
|
+
return host.includes(":") ? 6 : 4;
|
|
1118
|
+
}
|
|
817
1119
|
function makeIntegrityKey(username, realm, password) {
|
|
818
1120
|
return (0, auth_1.makeTurnIntegrityKey)(username, realm, password);
|
|
819
1121
|
}
|