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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../../../../ice/src/stun/transaction.ts"],"names":[],"mappings":";;;AAyBA,sDAaC;AAMD,kEAmBC;AAOD,sCAEC;AA2MD,0DAaC;AAhSD,uCAA2C;AAC3C,uCAA+C;AAE/C,8CAA+D;AAE/D,8CAIuB;AAEvB,mCAAwD;AAGxD,MAAM,GAAG,GAAG,IAAA,cAAK,EAAC,iDAAiD,CAAC,CAAC;AAErE;;;;;;;;GAQG;AACI,KAAK,UAAU,qBAAqB,CACzC,IAAa,EACb,SAAoB,CAAC;IAErB,MAAM,aAAa,GAAG,IAAA,eAAI,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,IAAI,aAAa,EAAE,CAAC;QAClB,IAAI,MAAM,KAAK,CAAC,IAAI,aAAa,KAAK,MAAM,EAAE,CAAC;YAC7C,MAAM,IAAI,kCAAqB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,mBAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IACrD,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACnC,CAAC;AAED;;;GAGG;AACH,SAAgB,2BAA2B,CACzC,wBAA6D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ClB,IAAI,CAAC,SAAS,EAAE,CAAC;QACjB,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAChC,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YACvD,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QAC3B,CAAC;IACH,CAAC;CACF;AA3LD,kCA2LC;AAED;;;GAGG;AACH,SAAgB,uBAAuB,CACrC,YAAgC,EAChC,wBAA6D,EAC7D,aAAyC;IAEzC,MAAM,OAAO,GAAG,2BAA2B,CACzC,wBAAwB,EACxB,aAAa,CACd,CAAC;IACF,IAAI,YAAY,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;QAC1C,OAAO,CAAC,YAAY,GAAG,YAAY,CAAC;IACtC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { promises as dns } from \"node:dns\";\nimport { SocketAddress, isIP } from \"node:net\";\n\nimport { type Address, Event, debug } from \"../imports/common\";\n\nimport {\n AddressFamilyMismatch,\n TransactionFailed,\n TransactionTimeout,\n} from \"../exceptions\";\nimport type { Protocol, TransactionRequestOptions } from \"../types/model\";\nimport { RETRY_MAX, RETRY_RTO, classes } from \"./const\";\nimport type { Message } from \"./message\";\n\nconst log = debug(\"werift-ice:packages/ice/src/stun/transaction.ts\");\n\n/**\n * Resolve a request target to a concrete IP before creating a Transaction so\n * response source-address checks match the UDP peer address (hostname ≠ IP).\n *\n * `family` is the family of the socket that will carry the request: a\n * hostname resolves only in that family, and an IP literal of the other\n * family throws AddressFamilyMismatch instead of retransmitting into a send\n * that cannot succeed. Family 0 means unknown: no preference, no check.\n */\nexport async function resolveRequestAddress(\n addr: Address,\n family: 0 | 4 | 6 = 0,\n): Promise<Address> {\n const literalFamily = isIP(addr[0]);\n if (literalFamily) {\n if (family !== 0 && literalFamily !== family) {\n throw new AddressFamilyMismatch(addr, family);\n }\n return addr;\n }\n const looked = await dns.lookup(addr[0], { family });\n return [looked.address, addr[1]];\n}\n\n/**\n * Normalize legacy positional args and the options-object form into one shape.\n * Existing callers pass `(retransmissions?, onRequestSent?)`.\n */\nexport function normalizeTransactionOptions(\n retransmissionsOrOptions?: number | TransactionRequestOptions,\n onRequestSent?: (attempt: number) => void,\n): TransactionRequestOptions {\n if (\n retransmissionsOrOptions !== null &&\n typeof retransmissionsOrOptions === \"object\"\n ) {\n return retransmissionsOrOptions;\n }\n // After the object branch, only number | undefined remains (legacy positional API).\n const retransmissions =\n typeof retransmissionsOrOptions === \"number\"\n ? retransmissionsOrOptions\n : undefined;\n return {\n retransmissions,\n onRequestSent,\n };\n}\n\n/**\n * Compare ICE transport addresses (host, port).\n * IPv6 literals are compared in canonical form because the socket reports\n * `::1` even when the peer was configured as `0:0:0:0:0:0:0:1`.\n */\nexport function addressEquals(a: Address, b: Address): boolean {\n return a[1] === b[1] && canonicalHost(a[0]) === canonicalHost(b[0]);\n}\n\n// Only used for comparison; never for the address a packet is sent to,\n// since SocketAddress drops the zone id (`fe80::1%eth0`).\nfunction canonicalHost(host: string): string {\n return isIP(host) === 6\n ? new SocketAddress({ address: host, family: \"ipv6\" }).address\n : host;\n}\n\nexport class Transaction {\n private timeoutDelay: number;\n ended = false;\n private tries = 0;\n private readonly triesMax: number;\n private readonly onResponse = new Event<[Message, Address]>();\n private readonly onRequestSent?: (attempt: number) => void;\n private readonly signal?: AbortSignal;\n private readonly failOnSendError: boolean;\n /** Remote address this transaction was sent to; responses must match. */\n readonly expectedAddr: Address;\n /**\n * When set, protocol layers re-parse the wire response with this key so\n * MESSAGE-INTEGRITY failures are rejected before responseReceived.\n */\n readonly integrityKey?: Buffer;\n private waitTimer?: ReturnType<typeof setTimeout>;\n private waitResolve?: () => void;\n private onAbort?: () => void;\n\n constructor(\n private request: Message,\n private addr: Address,\n private protocol: Protocol,\n retransmissionsOrOptions?: number | TransactionRequestOptions,\n onRequestSent?: (attempt: number) => void,\n ) {\n const options = normalizeTransactionOptions(\n retransmissionsOrOptions,\n onRequestSent,\n );\n // triesMax = initial send + retransmissions\n this.triesMax = 1 + (options.retransmissions ?? RETRY_MAX);\n // responseTimeout is independent of retransmission count (RFC 7675 / 8445)\n this.timeoutDelay = options.responseTimeout ?? RETRY_RTO;\n this.onRequestSent = options.onRequestSent;\n this.signal = options.signal;\n this.failOnSendError = options.failOnSendError ?? false;\n this.expectedAddr = addr;\n this.integrityKey = options.integrityKey;\n }\n\n /**\n * Accept a matching authenticated non-error response from the expected\n * remote address. Wrong address, missing MESSAGE-INTEGRITY (when required),\n * or non-success class is rejected without completing the transaction\n * (wrong address / unauthenticated responses are ignored so we keep waiting).\n */\n responseReceived = (message: Message, addr: Address) => {\n if (this.ended || this.onResponse.length === 0) {\n return;\n }\n\n // RFC 7675 / ICE: only responses from the request's transport address.\n if (!addressEquals(this.expectedAddr, addr)) {\n log(\n \"ignore STUN response from unexpected address\",\n addr,\n \"expected\",\n this.expectedAddr,\n );\n return;\n }\n\n // RFC 7675 authenticated consent: integrityKey requires MESSAGE-INTEGRITY.\n // Wire HMAC is verified by protocol layers via parseMessage(data, key);\n // this presence check is defense-in-depth if responseReceived is called\n // with a constructed Message that skipped the wire re-parse path.\n if (this.integrityKey) {\n const hasIntegrity =\n message.attributesKeys.includes(\"MESSAGE-INTEGRITY\") ||\n message.attributesKeys.includes(\"MESSAGE-INTEGRITY-SHA256\");\n if (!hasIntegrity) {\n log(\n \"ignore unauthenticated STUN response (MESSAGE-INTEGRITY required)\",\n );\n return;\n }\n }\n\n if (message.messageClass === classes.RESPONSE) {\n this.onResponse.execute(message, addr);\n this.onResponse.complete();\n } else {\n // ERROR class or other non-success\n this.onResponse.error(new TransactionFailed(message, addr));\n }\n };\n\n run = async () => {\n try {\n if (this.signal?.aborted) {\n throw new TransactionTimeout();\n }\n this.attachAbortListener();\n this.retry().catch((e) => {\n log(\"retry failed\", e);\n });\n const res = await this.onResponse.asPromise();\n return res;\n } catch (error) {\n throw error;\n } finally {\n this.cancel();\n }\n };\n\n private attachAbortListener() {\n if (!this.signal) {\n return;\n }\n this.onAbort = () => {\n this.failWithTimeout();\n };\n this.signal.addEventListener(\"abort\", this.onAbort, { once: true });\n }\n\n private failWithTimeout() {\n this.fail(new TransactionTimeout());\n }\n\n private fail(error: Error) {\n if (this.ended) {\n return;\n }\n this.ended = true;\n this.clearWait();\n if (this.onResponse.length > 0) {\n this.onResponse.error(error);\n }\n }\n\n private clearWait() {\n if (this.waitTimer !== undefined) {\n clearTimeout(this.waitTimer);\n this.waitTimer = undefined;\n }\n const resolve = this.waitResolve;\n this.waitResolve = undefined;\n resolve?.();\n }\n\n private wait(ms: number): Promise<void> {\n return new Promise((resolve) => {\n if (this.ended || this.signal?.aborted) {\n resolve();\n return;\n }\n this.waitResolve = resolve;\n this.waitTimer = setTimeout(() => {\n this.waitTimer = undefined;\n this.waitResolve = undefined;\n resolve();\n }, ms);\n });\n }\n\n private retry = async () => {\n while (this.tries < this.triesMax && !this.ended) {\n this.onRequestSent?.(this.tries);\n this.protocol.sendStun(this.request, this.addr).catch((e) => {\n log(\"send stun failed\", e);\n if (this.failOnSendError) {\n this.fail(e);\n }\n });\n await this.wait(this.timeoutDelay);\n if (this.ended) {\n break;\n }\n this.timeoutDelay *= 2;\n this.tries++;\n }\n if (this.tries >= this.triesMax && !this.ended) {\n log(`retry failed times:${this.tries} maxLimit:${this.triesMax}`);\n this.failWithTimeout();\n }\n };\n\n cancel() {\n this.ended = true;\n this.clearWait();\n if (this.signal && this.onAbort) {\n this.signal.removeEventListener(\"abort\", this.onAbort);\n this.onAbort = undefined;\n }\n }\n}\n\n/**\n * Build Transaction options for Protocol.request, folding integrityKey into\n * options so response path can re-verify MESSAGE-INTEGRITY.\n */\nexport function buildTransactionOptions(\n integrityKey: Buffer | undefined,\n retransmissionsOrOptions?: number | TransactionRequestOptions,\n onRequestSent?: (attempt: number) => void,\n): TransactionRequestOptions {\n const options = normalizeTransactionOptions(\n retransmissionsOrOptions,\n onRequestSent,\n );\n if (integrityKey && !options.integrityKey) {\n options.integrityKey = integrityKey;\n }\n return options;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../../../../ice/src/stun/transaction.ts"],"names":[],"mappings":";;;AA0BA,sDAaC;AAMD,kEAmBC;AAOD,sCAEC;AAWD,kDAKC;AAMD,gEAMC;AAwPD,0DAaC;AA1WD,uCAA2C;AAC3C,uCAA+C;AAC/C,8CAOuB;AACvB,8CAA+D;AAE/D,mCAAwD;AAGxD,MAAM,GAAG,GAAG,IAAA,cAAK,EAAC,iDAAiD,CAAC,CAAC;AAErE;;;;;;;;GAQG;AACI,KAAK,UAAU,qBAAqB,CACzC,IAAa,EACb,SAAoB,CAAC;IAErB,MAAM,aAAa,GAAG,IAAA,eAAI,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,IAAI,aAAa,EAAE,CAAC;QAClB,IAAI,MAAM,KAAK,CAAC,IAAI,aAAa,KAAK,MAAM,EAAE,CAAC;YAC7C,MAAM,IAAI,kCAAqB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,mBAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IACrD,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACnC,CAAC;AAED;;;GAGG;AACH,SAAgB,2BAA2B,CACzC,wBAA6D,EAC7D,aAAyC;IAEzC,IACE,wBAAwB,KAAK,IAAI;QACjC,OAAO,wBAAwB,KAAK,QAAQ,EAC5C,CAAC;QACD,OAAO,wBAAwB,CAAC;IAClC,CAAC;IACD,oFAAoF;IACpF,MAAM,eAAe,GACnB,OAAO,wBAAwB,KAAK,QAAQ;QAC1C,CAAC,CAAC,wBAAwB;Q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AAI,CAAC,SAAS,EAAE,CAAC;QACjB,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAChC,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YACvD,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QAC3B,CAAC;IACH,CAAC;CACF;AAhPD,kCAgPC;AAED;;;GAGG;AACH,SAAgB,uBAAuB,CACrC,YAAgC,EAChC,wBAA6D,EAC7D,aAAyC;IAEzC,MAAM,OAAO,GAAG,2BAA2B,CACzC,wBAAwB,EACxB,aAAa,CACd,CAAC;IACF,IAAI,YAAY,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;QAC1C,OAAO,CAAC,YAAY,GAAG,YAAY,CAAC;IACtC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { promises as dns } from \"node:dns\";\nimport { isIP, SocketAddress } from \"node:net\";\nimport {\n AddressFamilyMismatch,\n TransactionCancelled,\n TransactionChallenge,\n TransactionFailed,\n TransactionIntegrityViolation,\n TransactionTimeout,\n} from \"../exceptions\";\nimport { type Address, debug, Event } from \"../imports/common\";\nimport type { Protocol, TransactionRequestOptions } from \"../types/model\";\nimport { classes, RETRY_MAX, RETRY_RTO } from \"./const\";\nimport type { Message } from \"./message\";\n\nconst log = debug(\"werift-ice:packages/ice/src/stun/transaction.ts\");\n\n/**\n * Resolve a request target to a concrete IP before creating a Transaction so\n * response source-address checks match the UDP peer address (hostname ≠ IP).\n *\n * `family` is the family of the socket that will carry the request: a\n * hostname resolves only in that family, and an IP literal of the other\n * family throws AddressFamilyMismatch instead of retransmitting into a send\n * that cannot succeed. Family 0 means unknown: no preference, no check.\n */\nexport async function resolveRequestAddress(\n addr: Address,\n family: 0 | 4 | 6 = 0,\n): Promise<Address> {\n const literalFamily = isIP(addr[0]);\n if (literalFamily) {\n if (family !== 0 && literalFamily !== family) {\n throw new AddressFamilyMismatch(addr, family);\n }\n return addr;\n }\n const looked = await dns.lookup(addr[0], { family });\n return [looked.address, addr[1]];\n}\n\n/**\n * Normalize legacy positional args and the options-object form into one shape.\n * Existing callers pass `(retransmissions?, onRequestSent?)`.\n */\nexport function normalizeTransactionOptions(\n retransmissionsOrOptions?: number | TransactionRequestOptions,\n onRequestSent?: (attempt: number) => void,\n): TransactionRequestOptions {\n if (\n retransmissionsOrOptions !== null &&\n typeof retransmissionsOrOptions === \"object\"\n ) {\n return retransmissionsOrOptions;\n }\n // After the object branch, only number | undefined remains (legacy positional API).\n const retransmissions =\n typeof retransmissionsOrOptions === \"number\"\n ? retransmissionsOrOptions\n : undefined;\n return {\n retransmissions,\n onRequestSent,\n };\n}\n\n/**\n * Compare ICE transport addresses (host, port).\n * IPv6 literals are compared in canonical form because the socket reports\n * `::1` even when the peer was configured as `0:0:0:0:0:0:0:1`.\n */\nexport function addressEquals(a: Address, b: Address): boolean {\n return a[1] === b[1] && canonicalHost(a[0]) === canonicalHost(b[0]);\n}\n\n// Only used for comparison; never for the address a packet is sent to,\n// since SocketAddress drops the zone id (`fe80::1%eth0`).\nfunction canonicalHost(host: string): string {\n return isIP(host) === 6\n ? new SocketAddress({ address: host, family: \"ipv6\" }).address\n : host;\n}\n\n/** Whether `message` carries MESSAGE-INTEGRITY or MESSAGE-INTEGRITY-SHA256. */\nexport function hasMessageIntegrity(message: Message): boolean {\n return (\n message.attributesKeys.includes(\"MESSAGE-INTEGRITY\") ||\n message.attributesKeys.includes(\"MESSAGE-INTEGRITY-SHA256\")\n );\n}\n\n/**\n * A long-term credential challenge (RFC 8489 §9.2.4): a 401 (Unauthenticated)\n * or 438 (Stale Nonce) error response without MESSAGE-INTEGRITY.\n */\nexport function isUnauthenticatedChallenge(message: Message): boolean {\n if (message.messageClass !== classes.ERROR || hasMessageIntegrity(message)) {\n return false;\n }\n const [errorCode] = message.getAttributeValue(\"ERROR-CODE\") ?? [];\n return errorCode === 401 || errorCode === 438;\n}\n\nexport class Transaction {\n private request: Message;\n private addr: Address;\n private protocol: Protocol;\n\n private timeoutDelay: number;\n ended = false;\n private tries = 0;\n private readonly triesMax: number;\n private readonly onResponse = new Event<[Message, Address]>();\n private readonly onRequestSent?: (attempt: number) => void;\n private readonly signal?: AbortSignal;\n private readonly failOnSendError: boolean;\n /** Remote address this transaction was sent to; responses must match. */\n readonly expectedAddr: Address;\n /**\n * When set, protocol layers re-parse the wire response with this key so\n * MESSAGE-INTEGRITY failures are rejected before responseReceived. The one\n * exception is a TURN long-term credential challenge (unsigned 401/438),\n * which TurnProtocol passes to challengeReceived instead.\n */\n readonly integrityKey?: Buffer;\n private waitTimer?: ReturnType<typeof setTimeout>;\n private waitResolve?: () => void;\n private onAbort?: () => void;\n\n constructor(\n request: Message,\n addr: Address,\n protocol: Protocol,\n retransmissionsOrOptions?: number | TransactionRequestOptions,\n onRequestSent?: (attempt: number) => void,\n ) {\n this.request = request;\n this.addr = addr;\n this.protocol = protocol;\n const options = normalizeTransactionOptions(\n retransmissionsOrOptions,\n onRequestSent,\n );\n // triesMax = initial send + retransmissions\n this.triesMax = 1 + (options.retransmissions ?? RETRY_MAX);\n // responseTimeout is independent of retransmission count (RFC 7675 / 8445)\n this.timeoutDelay = options.responseTimeout ?? RETRY_RTO;\n this.onRequestSent = options.onRequestSent;\n this.signal = options.signal;\n this.failOnSendError = options.failOnSendError ?? false;\n this.expectedAddr = addr;\n this.integrityKey = options.integrityKey;\n }\n\n /**\n * Accept a matching authenticated non-error response from the expected\n * remote address. Wrong address, missing MESSAGE-INTEGRITY (when required),\n * or non-success class is rejected without completing the transaction\n * (wrong address / unauthenticated responses are ignored so we keep waiting).\n * An unsigned 401/438 challenge is not accepted here even for long-term\n * credentials; only challengeReceived takes it.\n */\n responseReceived = (message: Message, addr: Address) => {\n if (!this.accepts(addr)) {\n return;\n }\n\n // RFC 7675 authenticated consent: integrityKey requires MESSAGE-INTEGRITY.\n // Wire HMAC is verified by protocol layers via parseMessage(data, key);\n // this presence check is defense-in-depth if responseReceived is called\n // with a constructed Message that skipped the wire re-parse path.\n if (this.integrityKey && !hasMessageIntegrity(message)) {\n log(\"ignore unauthenticated STUN response (MESSAGE-INTEGRITY required)\");\n return;\n }\n\n if (message.messageClass === classes.RESPONSE) {\n this.onResponse.execute(message, addr);\n this.onResponse.complete();\n } else {\n // ERROR class or other non-success\n this.onResponse.error(new TransactionFailed(message, addr));\n }\n };\n\n /**\n * Fail the transaction with TransactionChallenge on a long-term credential\n * challenge: an unsigned 401/438 error response (RFC 8489 §9.2.4) to this\n * request's method, from the expected remote address. Any other message is\n * ignored. Only TurnProtocol calls this: short-term credential checks (ICE\n * connectivity checks, consent) have no challenge and keep requiring\n * MESSAGE-INTEGRITY through responseReceived.\n */\n challengeReceived = (message: Message, addr: Address) => {\n if (!this.accepts(addr)) {\n return;\n }\n if (\n !isUnauthenticatedChallenge(message) ||\n message.messageMethod !== this.request.messageMethod\n ) {\n log(\"ignore STUN response that is not a long-term credential challenge\");\n return;\n }\n this.onResponse.error(new TransactionChallenge(message, addr));\n };\n\n /**\n * Fail the transaction with TransactionIntegrityViolation: a response from\n * the expected remote address failed MESSAGE-INTEGRITY validation on a\n * reliable transport, where it cannot be a retransmission race\n * (RFC 8489 §9.2.5).\n */\n integrityViolated = (addr: Address) => {\n if (!this.accepts(addr)) {\n return;\n }\n this.fail(new TransactionIntegrityViolation(addr));\n };\n\n /** Whether a response from `addr` may settle this transaction. */\n private accepts(addr: Address) {\n if (this.ended || this.onResponse.length === 0) {\n return false;\n }\n\n // RFC 7675 / ICE: only responses from the request's transport address.\n if (!addressEquals(this.expectedAddr, addr)) {\n log(\n \"ignore STUN response from unexpected address\",\n addr,\n \"expected\",\n this.expectedAddr,\n );\n return false;\n }\n return true;\n }\n\n run = async () => {\n try {\n if (this.signal?.aborted) {\n throw new TransactionTimeout();\n }\n this.attachAbortListener();\n this.retry().catch((e) => {\n log(\"retry failed\", e);\n });\n const res = await this.onResponse.asPromise();\n return res;\n } catch (error) {\n throw error;\n } finally {\n this.cancel();\n }\n };\n\n private attachAbortListener() {\n if (!this.signal) {\n return;\n }\n this.onAbort = () => {\n this.failWithTimeout();\n };\n this.signal.addEventListener(\"abort\", this.onAbort, { once: true });\n }\n\n private failWithTimeout() {\n this.fail(new TransactionTimeout());\n }\n\n private fail(error: Error) {\n if (this.ended) {\n return;\n }\n this.ended = true;\n this.clearWait();\n if (this.onResponse.length > 0) {\n this.onResponse.error(error);\n }\n }\n\n private clearWait() {\n if (this.waitTimer !== undefined) {\n clearTimeout(this.waitTimer);\n this.waitTimer = undefined;\n }\n const resolve = this.waitResolve;\n this.waitResolve = undefined;\n resolve?.();\n }\n\n private wait(ms: number): Promise<void> {\n return new Promise((resolve) => {\n if (this.ended || this.signal?.aborted) {\n resolve();\n return;\n }\n this.waitResolve = resolve;\n this.waitTimer = setTimeout(() => {\n this.waitTimer = undefined;\n this.waitResolve = undefined;\n resolve();\n }, ms);\n });\n }\n\n private retry = async () => {\n while (this.tries < this.triesMax && !this.ended) {\n this.onRequestSent?.(this.tries);\n this.protocol.sendStun(this.request, this.addr).catch((e) => {\n log(\"send stun failed\", e);\n if (this.failOnSendError) {\n this.fail(e);\n }\n });\n await this.wait(this.timeoutDelay);\n if (this.ended) {\n break;\n }\n this.timeoutDelay *= 2;\n this.tries++;\n }\n if (this.tries >= this.triesMax && !this.ended) {\n log(`retry failed times:${this.tries} maxLimit:${this.triesMax}`);\n this.failWithTimeout();\n }\n };\n\n /**\n * End the transaction. A `run()` still waiting for a response rejects with\n * `TransactionCancelled`, so whoever awaits it (and its timers) settles\n * instead of waiting forever on a closed protocol.\n */\n cancel() {\n this.fail(new TransactionCancelled());\n this.ended = true;\n this.clearWait();\n if (this.signal && this.onAbort) {\n this.signal.removeEventListener(\"abort\", this.onAbort);\n this.onAbort = undefined;\n }\n }\n}\n\n/**\n * Build Transaction options for Protocol.request, folding integrityKey into\n * options so response path can re-verify MESSAGE-INTEGRITY.\n */\nexport function buildTransactionOptions(\n integrityKey: Buffer | undefined,\n retransmissionsOrOptions?: number | TransactionRequestOptions,\n onRequestSent?: (attempt: number) => void,\n): TransactionRequestOptions {\n const options = normalizeTransactionOptions(\n retransmissionsOrOptions,\n onRequestSent,\n );\n if (integrityKey && !options.integrityKey) {\n options.integrityKey = integrityKey;\n }\n return options;\n}\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Message } from "../stun/message";
|
|
2
|
+
/** Prefix of a NONCE that carries STUN Security Features (RFC 8489 §9.2). */
|
|
3
|
+
export declare const NONCE_COOKIE = "obMatJos2";
|
|
4
|
+
/** STUN Security Features a server announced in its nonce cookie. */
|
|
5
|
+
export interface NonceSecurityFeatures {
|
|
6
|
+
/** Bit 0: PASSWORD-ALGORITHMS / PASSWORD-ALGORITHM negotiation. */
|
|
7
|
+
passwordAlgorithms: boolean;
|
|
8
|
+
/** Bit 1: USERHASH instead of USERNAME. */
|
|
9
|
+
usernameAnonymity: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Security Features of a NONCE that starts with the nonce cookie: "obMatJos2"
|
|
13
|
+
* followed by 4 base64 characters encoding the 24-bit feature set
|
|
14
|
+
* (RFC 8489 §9.2, §18.1). Undefined for a NONCE without the cookie, which
|
|
15
|
+
* announces no feature.
|
|
16
|
+
*
|
|
17
|
+
* RFC 8489 numbers the bits from the most significant side in §9.2 and, as
|
|
18
|
+
* corrected by erratum 6290, from the least significant side in §18.1. Both
|
|
19
|
+
* readings are accepted so a feature is never missed: the client cannot use
|
|
20
|
+
* either feature, and the other positions are unassigned.
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseNonceSecurityFeatures(nonce: Buffer): NonceSecurityFeatures | undefined;
|
|
23
|
+
/** The long-term credentials a request was sent with. */
|
|
24
|
+
export interface SentCredentials {
|
|
25
|
+
/** The request carried MESSAGE-INTEGRITY. */
|
|
26
|
+
authenticated: boolean;
|
|
27
|
+
/** REALM the request was signed with, when authenticated. */
|
|
28
|
+
realm?: string;
|
|
29
|
+
}
|
|
30
|
+
/** Realm and nonce to sign the retry of a challenged request with. */
|
|
31
|
+
export interface CredentialRetry {
|
|
32
|
+
realm: string;
|
|
33
|
+
nonce: Buffer;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Decide whether a 401 (Unauthenticated) or 438 (Stale Nonce) error response
|
|
37
|
+
* allows one retry with new credentials (RFC 8489 §9.2.5), and with which
|
|
38
|
+
* realm and nonce. Undefined means the error is final.
|
|
39
|
+
*
|
|
40
|
+
* - NONCE is required, and Security Features the client does not implement
|
|
41
|
+
* (PASSWORD-ALGORITHMS, username anonymity) rule the retry out.
|
|
42
|
+
* - 401 to an unauthenticated request (the first Allocate): retry with the
|
|
43
|
+
* REALM and NONCE of the response.
|
|
44
|
+
* - 401 to an authenticated request: the username and password never change,
|
|
45
|
+
* so retrying with the same REALM is forbidden; only a new REALM is tried.
|
|
46
|
+
* - 438: retry with the new NONCE and the current realm, which a REALM in
|
|
47
|
+
* the response must not contradict.
|
|
48
|
+
*/
|
|
49
|
+
export declare function credentialRetryOf(response: Message, sent: SentCredentials, currentRealm: string | undefined): CredentialRetry | undefined;
|
|
@@ -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,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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"]}
|
|
@@ -3,6 +3,14 @@ import { type Address, Event, type InterfaceAddresses, type TlsConnectionOptions
|
|
|
3
3
|
import { Message } from "../stun/message";
|
|
4
4
|
import { Transaction } from "../stun/transaction";
|
|
5
5
|
import type { Protocol, TransactionRequestOptions } from "../types/model";
|
|
6
|
+
export { TurnRedirectError, type TurnRedirectFailureReason, } from "../exceptions";
|
|
7
|
+
/**
|
|
8
|
+
* Opens a new stream transport to the TURN server named by a 300 (Try
|
|
9
|
+
* Alternate) ALTERNATE-SERVER. `alternateDomain` is the ALTERNATE-DOMAIN
|
|
10
|
+
* attribute, if any, which a TLS transport must validate the certificate
|
|
11
|
+
* against (RFC 8489 §10).
|
|
12
|
+
*/
|
|
13
|
+
export type TurnStreamReconnect = (server: Address, alternateDomain: string | undefined) => Promise<Transport>;
|
|
6
14
|
/** Channel binding state for a single peer transport address. */
|
|
7
15
|
export interface TurnChannel {
|
|
8
16
|
number: number;
|
|
@@ -12,6 +20,12 @@ export interface TurnChannel {
|
|
|
12
20
|
}
|
|
13
21
|
export declare class StunOverTurnProtocol implements Protocol {
|
|
14
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";
|
|
15
29
|
static type: string;
|
|
16
30
|
readonly type: string;
|
|
17
31
|
localCandidate: Candidate;
|
|
@@ -27,7 +41,11 @@ export declare class StunOverTurnProtocol implements Protocol {
|
|
|
27
41
|
close(): Promise<void>;
|
|
28
42
|
}
|
|
29
43
|
export declare class TurnProtocol implements Protocol {
|
|
30
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* TURN server the allocation is made on; the host may be a hostname.
|
|
46
|
+
* Starts as the configured server and becomes the ALTERNATE-SERVER when
|
|
47
|
+
* an Allocate is redirected with 300 (Try Alternate).
|
|
48
|
+
*/
|
|
31
49
|
server: Address;
|
|
32
50
|
username: string;
|
|
33
51
|
password: string;
|
|
@@ -36,6 +54,17 @@ export declare class TurnProtocol implements Protocol {
|
|
|
36
54
|
options: {
|
|
37
55
|
/**sec */
|
|
38
56
|
channelRefreshTime?: number;
|
|
57
|
+
/**
|
|
58
|
+
* 300 (Try Alternate) redirects followed for one Allocate.
|
|
59
|
+
* Defaults to 3.
|
|
60
|
+
*/
|
|
61
|
+
maxAllocateRedirects?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Reconnects a TCP/TLS transport to an ALTERNATE-SERVER. Without it, a
|
|
64
|
+
* redirect over a stream transport fails with TurnRedirectError
|
|
65
|
+
* ("unsupported-transport"). UDP needs no reconnect.
|
|
66
|
+
*/
|
|
67
|
+
reconnect?: TurnStreamReconnect;
|
|
39
68
|
};
|
|
40
69
|
static type: string;
|
|
41
70
|
readonly type: string;
|
|
@@ -51,6 +80,8 @@ export declare class TurnProtocol implements Protocol {
|
|
|
51
80
|
transactions: {
|
|
52
81
|
[hexId: string]: Transaction;
|
|
53
82
|
};
|
|
83
|
+
/** close() ran: no new transaction starts. */
|
|
84
|
+
private closed;
|
|
54
85
|
private refreshHandle?;
|
|
55
86
|
private channelNumber;
|
|
56
87
|
private channelByAddr;
|
|
@@ -78,20 +109,60 @@ export declare class TurnProtocol implements Protocol {
|
|
|
78
109
|
/** Concrete TURN server address the allocation lives on, once selected. */
|
|
79
110
|
private pinnedServerEndpoint?;
|
|
80
111
|
private serverEndpointSelection?;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
server: Address, username: string, password: string, lifetime: number, transport: Transport, options?: {
|
|
112
|
+
/** TURN server as configured, before any 300 (Try Alternate) redirect. */
|
|
113
|
+
readonly configuredServer: Address;
|
|
114
|
+
constructor(server: Address, username: string, password: string, lifetime: number, transport: Transport, options?: {
|
|
84
115
|
/**sec */
|
|
85
116
|
channelRefreshTime?: number;
|
|
117
|
+
/**
|
|
118
|
+
* 300 (Try Alternate) redirects followed for one Allocate.
|
|
119
|
+
* Defaults to 3.
|
|
120
|
+
*/
|
|
121
|
+
maxAllocateRedirects?: number;
|
|
122
|
+
/**
|
|
123
|
+
* Reconnects a TCP/TLS transport to an ALTERNATE-SERVER. Without it, a
|
|
124
|
+
* redirect over a stream transport fails with TurnRedirectError
|
|
125
|
+
* ("unsupported-transport"). UDP needs no reconnect.
|
|
126
|
+
*/
|
|
127
|
+
reconnect?: TurnStreamReconnect;
|
|
86
128
|
});
|
|
87
129
|
connectionMade(): Promise<void>;
|
|
130
|
+
private attachTransport;
|
|
131
|
+
/**
|
|
132
|
+
* Allocate on the current server, following 300 (Try Alternate) to the
|
|
133
|
+
* ALTERNATE-SERVER with the same transport protocol and credentials
|
|
134
|
+
* (RFC 8656 §7.4, RFC 8489 §10). Only Allocate is redirected: an existing
|
|
135
|
+
* allocation lives on one server, so Refresh, CreatePermission and
|
|
136
|
+
* ChannelBind never move.
|
|
137
|
+
*/
|
|
138
|
+
private allocate;
|
|
139
|
+
/**
|
|
140
|
+
* Point the client at an ALTERNATE-SERVER. Authentication state belongs to
|
|
141
|
+
* the previous server, so the alternate starts again with an
|
|
142
|
+
* unauthenticated Allocate and its own 401 realm/nonce; username and
|
|
143
|
+
* password are kept.
|
|
144
|
+
*/
|
|
145
|
+
private switchServer;
|
|
88
146
|
private handleChannelData;
|
|
89
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;
|
|
90
157
|
private dataReceived;
|
|
91
158
|
private send;
|
|
92
159
|
private createPermission;
|
|
93
160
|
private refresh;
|
|
94
|
-
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]>;
|
|
95
166
|
/**
|
|
96
167
|
* The concrete TURN server address, selected on the first request and
|
|
97
168
|
* pinned for the rest of the allocation, so a later DNS answer can never
|
|
@@ -114,6 +185,14 @@ export declare class TurnProtocol implements Protocol {
|
|
|
114
185
|
* dropped as coming from an unexpected address.
|
|
115
186
|
*/
|
|
116
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
|
+
*/
|
|
117
196
|
requestWithRetry(request: Message, addr: Address, signal?: AbortSignal): Promise<[Message, Address]>;
|
|
118
197
|
sendData(data: Buffer, addr: Address): Promise<void>;
|
|
119
198
|
/**
|
|
@@ -135,6 +214,12 @@ export declare class TurnProtocol implements Protocol {
|
|
|
135
214
|
private ensureChannel;
|
|
136
215
|
private channelBind;
|
|
137
216
|
sendStun(message: Message, addr: Address): Promise<void>;
|
|
217
|
+
/**
|
|
218
|
+
* Release the client: its transactions, refresh timer and socket. Known
|
|
219
|
+
* constraint (as in develop): the allocation is not deleted on the server
|
|
220
|
+
* (no Refresh with lifetime 0), so the server keeps it until its lifetime
|
|
221
|
+
* ends.
|
|
222
|
+
*/
|
|
138
223
|
close(): Promise<void>;
|
|
139
224
|
}
|
|
140
225
|
export interface TurnClientConfig {
|
|
@@ -157,7 +242,12 @@ export interface TurnClientOptions {
|
|
|
157
242
|
* own family always selects the socket. Defaults to 4.
|
|
158
243
|
*/
|
|
159
244
|
udpFamily?: 4 | 6;
|
|
245
|
+
/**
|
|
246
|
+
* Aborting it while the allocation runs closes the client (its socket and
|
|
247
|
+
* transactions) and rejects with `TransactionCancelled`.
|
|
248
|
+
*/
|
|
249
|
+
signal?: AbortSignal;
|
|
160
250
|
}
|
|
161
|
-
export declare function createTurnClient({ address, username, password }: TurnClientConfig, { lifetime, portRange, interfaceAddresses, ssl, tlsOptions, transport: transportType, connectTimeoutMs, udpFamily, }?: TurnClientOptions): Promise<TurnProtocol>;
|
|
251
|
+
export declare function createTurnClient({ address, username, password }: TurnClientConfig, { lifetime, portRange, interfaceAddresses, ssl, tlsOptions, transport: transportType, connectTimeoutMs, udpFamily, signal, }?: TurnClientOptions): Promise<TurnProtocol>;
|
|
162
252
|
export declare function createStunOverTurnClient(config: TurnClientConfig, options?: TurnClientOptions): Promise<StunOverTurnProtocol>;
|
|
163
|
-
export declare function makeIntegrityKey(username: string, realm: string, password: string):
|
|
253
|
+
export declare function makeIntegrityKey(username: string, realm: string, password: string): NonSharedBuffer;
|