@lakutata/webrtc 0.0.0-stage → 3.1.1
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/LICENSE +23 -0
- package/README.md +509 -2
- package/README.zh-CN.md +399 -0
- package/THIRD_PARTY_NOTICES.md +652 -0
- package/dist/cjs/client/SignalingConnection.d.ts +81 -0
- package/dist/cjs/client/SignalingConnection.js +67 -0
- package/dist/cjs/cluster/Cluster.d.ts +503 -0
- package/dist/cjs/cluster/Cluster.js +546 -0
- package/dist/cjs/cluster/ClusterFrames.d.ts +24 -0
- package/dist/cjs/cluster/ClusterFrames.js +90 -0
- package/dist/cjs/cluster/ClusterTURN.d.ts +63 -0
- package/dist/cjs/cluster/ClusterTURN.js +78 -0
- package/dist/cjs/cluster/Rendezvous.d.ts +8 -0
- package/dist/cjs/cluster/Rendezvous.js +23 -0
- package/dist/cjs/cluster/transports/ClusterTransport.d.ts +34 -0
- package/dist/cjs/cluster/transports/ClusterTransport.js +2 -0
- package/dist/cjs/cluster/transports/LoadClient.d.ts +6 -0
- package/dist/cjs/cluster/transports/LoadClient.js +80 -0
- package/dist/cjs/cluster/transports/MemoryClusterTransport.d.ts +13 -0
- package/dist/cjs/cluster/transports/MemoryClusterTransport.js +47 -0
- package/dist/cjs/cluster/transports/NATSClusterTransport.d.ts +23 -0
- package/dist/cjs/cluster/transports/NATSClusterTransport.js +70 -0
- package/dist/cjs/cluster/transports/RedisClusterTransport.d.ts +23 -0
- package/dist/cjs/cluster/transports/RedisClusterTransport.js +77 -0
- package/dist/cjs/exceptions/ClusterRequestException.d.ts +11 -0
- package/dist/cjs/exceptions/ClusterRequestException.js +18 -0
- package/dist/cjs/exceptions/ClusterTimeoutException.d.ts +10 -0
- package/dist/cjs/exceptions/ClusterTimeoutException.js +17 -0
- package/dist/cjs/exceptions/ClusterTransportNotFoundException.d.ts +11 -0
- package/dist/cjs/exceptions/ClusterTransportNotFoundException.js +18 -0
- package/dist/cjs/exceptions/SignalingClientRequiredException.d.ts +12 -0
- package/dist/cjs/exceptions/SignalingClientRequiredException.js +19 -0
- package/dist/cjs/exceptions/SignalingConnectionException.d.ts +12 -0
- package/dist/cjs/exceptions/SignalingConnectionException.js +19 -0
- package/dist/cjs/exceptions/SignalingDeniedException.d.ts +11 -0
- package/dist/cjs/exceptions/SignalingDeniedException.js +18 -0
- package/dist/cjs/exceptions/SignalingLimitException.d.ts +11 -0
- package/dist/cjs/exceptions/SignalingLimitException.js +18 -0
- package/dist/cjs/exceptions/SignalingNotAMemberException.d.ts +11 -0
- package/dist/cjs/exceptions/SignalingNotAMemberException.js +18 -0
- package/dist/cjs/exceptions/WHEPDeniedException.d.ts +15 -0
- package/dist/cjs/exceptions/WHEPDeniedException.js +22 -0
- package/dist/cjs/exceptions/WHEPLimitException.d.ts +15 -0
- package/dist/cjs/exceptions/WHEPLimitException.js +22 -0
- package/dist/cjs/exceptions/WHEPMediaTypeException.d.ts +15 -0
- package/dist/cjs/exceptions/WHEPMediaTypeException.js +22 -0
- package/dist/cjs/exceptions/WHEPOfferException.d.ts +16 -0
- package/dist/cjs/exceptions/WHEPOfferException.js +23 -0
- package/dist/cjs/exceptions/WHEPSessionNotFoundException.d.ts +15 -0
- package/dist/cjs/exceptions/WHEPSessionNotFoundException.js +22 -0
- package/dist/cjs/exceptions/WHIPDeniedException.d.ts +15 -0
- package/dist/cjs/exceptions/WHIPDeniedException.js +22 -0
- package/dist/cjs/exceptions/WHIPLimitException.d.ts +15 -0
- package/dist/cjs/exceptions/WHIPLimitException.js +22 -0
- package/dist/cjs/exceptions/WHIPMediaTypeException.d.ts +15 -0
- package/dist/cjs/exceptions/WHIPMediaTypeException.js +22 -0
- package/dist/cjs/exceptions/WHIPOfferException.d.ts +16 -0
- package/dist/cjs/exceptions/WHIPOfferException.js +23 -0
- package/dist/cjs/exceptions/WHIPSessionNotFoundException.d.ts +15 -0
- package/dist/cjs/exceptions/WHIPSessionNotFoundException.js +22 -0
- package/dist/cjs/exports/Client.d.ts +11 -0
- package/dist/cjs/exports/Client.js +29 -0
- package/dist/cjs/exports/WebRTC.d.ts +48 -0
- package/dist/cjs/exports/WebRTC.js +72 -0
- package/dist/cjs/lib/common/binary.d.ts +51 -0
- package/dist/cjs/lib/common/binary.js +264 -0
- package/dist/cjs/lib/common/binaryData.d.ts +116 -0
- package/dist/cjs/lib/common/binaryData.js +400 -0
- package/dist/cjs/lib/common/crc.d.ts +4 -0
- package/dist/cjs/lib/common/crc.js +122 -0
- package/dist/cjs/lib/common/deque.d.ts +36 -0
- package/dist/cjs/lib/common/deque.js +89 -0
- package/dist/cjs/lib/common/event.d.ts +48 -0
- package/dist/cjs/lib/common/event.js +207 -0
- package/dist/cjs/lib/common/index.d.ts +11 -0
- package/dist/cjs/lib/common/index.js +50 -0
- package/dist/cjs/lib/common/log.d.ts +47 -0
- package/dist/cjs/lib/common/log.js +62 -0
- package/dist/cjs/lib/common/network.d.ts +10 -0
- package/dist/cjs/lib/common/network.js +60 -0
- package/dist/cjs/lib/common/number.d.ts +13 -0
- package/dist/cjs/lib/common/number.js +43 -0
- package/dist/cjs/lib/common/promise.d.ts +21 -0
- package/dist/cjs/lib/common/promise.js +70 -0
- package/dist/cjs/lib/common/transport.d.ts +104 -0
- package/dist/cjs/lib/common/transport.js +441 -0
- package/dist/cjs/lib/common/type.d.ts +3 -0
- package/dist/cjs/lib/common/type.js +2 -0
- package/dist/cjs/lib/dtls/cipher/const.d.ts +42 -0
- package/dist/cjs/lib/dtls/cipher/const.js +33 -0
- package/dist/cjs/lib/dtls/cipher/create.d.ts +21 -0
- package/dist/cjs/lib/dtls/cipher/create.js +105 -0
- package/dist/cjs/lib/dtls/cipher/ec.d.ts +28 -0
- package/dist/cjs/lib/dtls/cipher/ec.js +44 -0
- package/dist/cjs/lib/dtls/cipher/key-exchange.d.ts +43 -0
- package/dist/cjs/lib/dtls/cipher/key-exchange.js +113 -0
- package/dist/cjs/lib/dtls/cipher/namedCurve.d.ts +7 -0
- package/dist/cjs/lib/dtls/cipher/namedCurve.js +27 -0
- package/dist/cjs/lib/dtls/cipher/prf.d.ts +17 -0
- package/dist/cjs/lib/dtls/cipher/prf.js +92 -0
- package/dist/cjs/lib/dtls/cipher/suites/abstract.d.ts +40 -0
- package/dist/cjs/lib/dtls/cipher/suites/abstract.js +41 -0
- package/dist/cjs/lib/dtls/cipher/suites/aead.d.ts +28 -0
- package/dist/cjs/lib/dtls/cipher/suites/aead.js +132 -0
- package/dist/cjs/lib/dtls/cipher/suites/null.d.ts +24 -0
- package/dist/cjs/lib/dtls/cipher/suites/null.js +41 -0
- package/dist/cjs/lib/dtls/cipher/utils.d.ts +18 -0
- package/dist/cjs/lib/dtls/cipher/utils.js +70 -0
- package/dist/cjs/lib/dtls/cipher/x509.d.ts +33 -0
- package/dist/cjs/lib/dtls/cipher/x509.js +100 -0
- package/dist/cjs/lib/dtls/client.d.ts +7 -0
- package/dist/cjs/lib/dtls/client.js +76 -0
- package/dist/cjs/lib/dtls/context/cipher.d.ts +42 -0
- package/dist/cjs/lib/dtls/context/cipher.js +87 -0
- package/dist/cjs/lib/dtls/context/dtls.d.ts +38 -0
- package/dist/cjs/lib/dtls/context/dtls.js +49 -0
- package/dist/cjs/lib/dtls/context/srtp.d.ts +5 -0
- package/dist/cjs/lib/dtls/context/srtp.js +12 -0
- package/dist/cjs/lib/dtls/context/transport.d.ts +8 -0
- package/dist/cjs/lib/dtls/context/transport.js +17 -0
- package/dist/cjs/lib/dtls/flight/client/flight1.d.ts +10 -0
- package/dist/cjs/lib/dtls/flight/client/flight1.js +26 -0
- package/dist/cjs/lib/dtls/flight/client/flight3.d.ts +8 -0
- package/dist/cjs/lib/dtls/flight/client/flight3.js +25 -0
- package/dist/cjs/lib/dtls/flight/client/flight5.d.ts +18 -0
- package/dist/cjs/lib/dtls/flight/client/flight5.js +206 -0
- package/dist/cjs/lib/dtls/flight/flight.d.ts +18 -0
- package/dist/cjs/lib/dtls/flight/flight.js +68 -0
- package/dist/cjs/lib/dtls/flight/server/flight2.d.ts +6 -0
- package/dist/cjs/lib/dtls/flight/server/flight2.js +126 -0
- package/dist/cjs/lib/dtls/flight/server/flight4.d.ts +17 -0
- package/dist/cjs/lib/dtls/flight/server/flight4.js +87 -0
- package/dist/cjs/lib/dtls/flight/server/flight6.d.ts +13 -0
- package/dist/cjs/lib/dtls/flight/server/flight6.js +111 -0
- package/dist/cjs/lib/dtls/handshake/binary.d.ts +16 -0
- package/dist/cjs/lib/dtls/handshake/binary.js +20 -0
- package/dist/cjs/lib/dtls/handshake/const.d.ts +13 -0
- package/dist/cjs/lib/dtls/handshake/const.js +17 -0
- package/dist/cjs/lib/dtls/handshake/extensions/ellipticCurves.d.ts +17 -0
- package/dist/cjs/lib/dtls/handshake/extensions/ellipticCurves.js +40 -0
- package/dist/cjs/lib/dtls/handshake/extensions/extendedMasterSecret.d.ts +3 -0
- package/dist/cjs/lib/dtls/handshake/extensions/extendedMasterSecret.js +7 -0
- package/dist/cjs/lib/dtls/handshake/extensions/renegotiationIndication.d.ts +18 -0
- package/dist/cjs/lib/dtls/handshake/extensions/renegotiationIndication.js +34 -0
- package/dist/cjs/lib/dtls/handshake/extensions/signature.d.ts +26 -0
- package/dist/cjs/lib/dtls/handshake/extensions/signature.js +39 -0
- package/dist/cjs/lib/dtls/handshake/extensions/useSrtp.d.ts +19 -0
- package/dist/cjs/lib/dtls/handshake/extensions/useSrtp.js +65 -0
- package/dist/cjs/lib/dtls/handshake/message/alert.d.ts +12 -0
- package/dist/cjs/lib/dtls/handshake/message/alert.js +24 -0
- package/dist/cjs/lib/dtls/handshake/message/certificate.d.ts +17 -0
- package/dist/cjs/lib/dtls/handshake/message/certificate.js +35 -0
- package/dist/cjs/lib/dtls/handshake/message/changeCipherSpec.d.ts +11 -0
- package/dist/cjs/lib/dtls/handshake/message/changeCipherSpec.js +24 -0
- package/dist/cjs/lib/dtls/handshake/message/client/certificateVerify.d.ts +20 -0
- package/dist/cjs/lib/dtls/handshake/message/client/certificateVerify.js +35 -0
- package/dist/cjs/lib/dtls/handshake/message/client/hello.d.ts +50 -0
- package/dist/cjs/lib/dtls/handshake/message/client/hello.js +48 -0
- package/dist/cjs/lib/dtls/handshake/message/client/keyExchange.d.ts +17 -0
- package/dist/cjs/lib/dtls/handshake/message/client/keyExchange.js +33 -0
- package/dist/cjs/lib/dtls/handshake/message/finished.d.ts +13 -0
- package/dist/cjs/lib/dtls/handshake/message/finished.js +26 -0
- package/dist/cjs/lib/dtls/handshake/message/server/certificateRequest.d.ts +31 -0
- package/dist/cjs/lib/dtls/handshake/message/server/certificateRequest.js +38 -0
- package/dist/cjs/lib/dtls/handshake/message/server/hello.d.ts +33 -0
- package/dist/cjs/lib/dtls/handshake/message/server/hello.js +57 -0
- package/dist/cjs/lib/dtls/handshake/message/server/helloDone.d.ts +12 -0
- package/dist/cjs/lib/dtls/handshake/message/server/helloDone.js +30 -0
- package/dist/cjs/lib/dtls/handshake/message/server/helloVerifyRequest.d.ts +32 -0
- package/dist/cjs/lib/dtls/handshake/message/server/helloVerifyRequest.js +42 -0
- package/dist/cjs/lib/dtls/handshake/message/server/keyExchange.d.ts +32 -0
- package/dist/cjs/lib/dtls/handshake/message/server/keyExchange.js +49 -0
- package/dist/cjs/lib/dtls/handshake/random.d.ts +13 -0
- package/dist/cjs/lib/dtls/handshake/random.js +29 -0
- package/dist/cjs/lib/dtls/helper.d.ts +4 -0
- package/dist/cjs/lib/dtls/helper.js +30 -0
- package/dist/cjs/lib/dtls/imports/common.d.ts +1 -0
- package/dist/cjs/lib/dtls/imports/common.js +17 -0
- package/dist/cjs/lib/dtls/imports/rtp.d.ts +1 -0
- package/dist/cjs/lib/dtls/imports/rtp.js +17 -0
- package/dist/cjs/lib/dtls/index.d.ts +7 -0
- package/dist/cjs/lib/dtls/index.js +117 -0
- package/dist/cjs/lib/dtls/record/antiReplayWindow.d.ts +27 -0
- package/dist/cjs/lib/dtls/record/antiReplayWindow.js +102 -0
- package/dist/cjs/lib/dtls/record/builder.d.ts +9 -0
- package/dist/cjs/lib/dtls/record/builder.js +27 -0
- package/dist/cjs/lib/dtls/record/const.d.ts +33 -0
- package/dist/cjs/lib/dtls/record/const.js +38 -0
- package/dist/cjs/lib/dtls/record/message/fragment.d.ts +26 -0
- package/dist/cjs/lib/dtls/record/message/fragment.js +96 -0
- package/dist/cjs/lib/dtls/record/message/header.d.ts +38 -0
- package/dist/cjs/lib/dtls/record/message/header.js +34 -0
- package/dist/cjs/lib/dtls/record/message/plaintext.d.ts +14 -0
- package/dist/cjs/lib/dtls/record/message/plaintext.js +63 -0
- package/dist/cjs/lib/dtls/record/receive.d.ts +9 -0
- package/dist/cjs/lib/dtls/record/receive.js +91 -0
- package/dist/cjs/lib/dtls/server.d.ts +6 -0
- package/dist/cjs/lib/dtls/server.js +78 -0
- package/dist/cjs/lib/dtls/socket.d.ts +52 -0
- package/dist/cjs/lib/dtls/socket.js +188 -0
- package/dist/cjs/lib/dtls/typings/domain.d.ts +20 -0
- package/dist/cjs/lib/dtls/typings/domain.js +2 -0
- package/dist/cjs/lib/dtls/util/binary.d.ts +2 -0
- package/dist/cjs/lib/dtls/util/binary.js +8 -0
- package/dist/cjs/lib/ice/candidate.d.ts +35 -0
- package/dist/cjs/lib/ice/candidate.js +198 -0
- package/dist/cjs/lib/ice/dns/lookup.d.ts +16 -0
- package/dist/cjs/lib/ice/dns/lookup.js +133 -0
- package/dist/cjs/lib/ice/dns/mdns.d.ts +38 -0
- package/dist/cjs/lib/ice/dns/mdns.js +145 -0
- package/dist/cjs/lib/ice/exceptions.d.ts +24 -0
- package/dist/cjs/lib/ice/exceptions.js +41 -0
- package/dist/cjs/lib/ice/helper.d.ts +17 -0
- package/dist/cjs/lib/ice/helper.js +74 -0
- package/dist/cjs/lib/ice/ice.d.ts +182 -0
- package/dist/cjs/lib/ice/ice.js +1584 -0
- package/dist/cjs/lib/ice/iceBase.d.ts +214 -0
- package/dist/cjs/lib/ice/iceBase.js +182 -0
- package/dist/cjs/lib/ice/imports/common.d.ts +1 -0
- package/dist/cjs/lib/ice/imports/common.js +17 -0
- package/dist/cjs/lib/ice/index.d.ts +12 -0
- package/dist/cjs/lib/ice/index.js +30 -0
- package/dist/cjs/lib/ice/internal/selectAddresses.d.ts +9 -0
- package/dist/cjs/lib/ice/internal/selectAddresses.js +39 -0
- package/dist/cjs/lib/ice/stun/attributes.d.ts +1 -0
- package/dist/cjs/lib/ice/stun/attributes.js +17 -0
- package/dist/cjs/lib/ice/stun/const.d.ts +8 -0
- package/dist/cjs/lib/ice/stun/const.js +25 -0
- package/dist/cjs/lib/ice/stun/message.d.ts +1 -0
- package/dist/cjs/lib/ice/stun/message.js +17 -0
- package/dist/cjs/lib/ice/stun/protocol.d.ts +30 -0
- package/dist/cjs/lib/ice/stun/protocol.js +125 -0
- package/dist/cjs/lib/ice/stun/tcpFrame.d.ts +5 -0
- package/dist/cjs/lib/ice/stun/tcpFrame.js +25 -0
- package/dist/cjs/lib/ice/stun/tcpProtocol.d.ts +57 -0
- package/dist/cjs/lib/ice/stun/tcpProtocol.js +323 -0
- package/dist/cjs/lib/ice/stun/transaction.d.ts +75 -0
- package/dist/cjs/lib/ice/stun/transaction.js +239 -0
- package/dist/cjs/lib/ice/turn/frame.d.ts +1 -0
- package/dist/cjs/lib/ice/turn/frame.js +17 -0
- package/dist/cjs/lib/ice/turn/protocol.d.ts +170 -0
- package/dist/cjs/lib/ice/turn/protocol.js +638 -0
- package/dist/cjs/lib/ice/types/model.d.ts +56 -0
- package/dist/cjs/lib/ice/types/model.js +2 -0
- package/dist/cjs/lib/ice/utils.d.ts +13 -0
- package/dist/cjs/lib/ice/utils.js +84 -0
- package/dist/cjs/lib/peer/const.d.ts +36 -0
- package/dist/cjs/lib/peer/const.js +53 -0
- package/dist/cjs/lib/peer/dataChannel.d.ts +69 -0
- package/dist/cjs/lib/peer/dataChannel.js +133 -0
- package/dist/cjs/lib/peer/errors.d.ts +11 -0
- package/dist/cjs/lib/peer/errors.js +23 -0
- package/dist/cjs/lib/peer/helper.d.ts +20 -0
- package/dist/cjs/lib/peer/helper.js +84 -0
- package/dist/cjs/lib/peer/imports/common.d.ts +1 -0
- package/dist/cjs/lib/peer/imports/common.js +17 -0
- package/dist/cjs/lib/peer/imports/dtls.d.ts +1 -0
- package/dist/cjs/lib/peer/imports/dtls.js +17 -0
- package/dist/cjs/lib/peer/imports/ice.d.ts +1 -0
- package/dist/cjs/lib/peer/imports/ice.js +17 -0
- package/dist/cjs/lib/peer/imports/rtp.d.ts +1 -0
- package/dist/cjs/lib/peer/imports/rtp.js +17 -0
- package/dist/cjs/lib/peer/index.d.ts +14 -0
- package/dist/cjs/lib/peer/index.js +30 -0
- package/dist/cjs/lib/peer/media/codec.d.ts +15 -0
- package/dist/cjs/lib/peer/media/codec.js +80 -0
- package/dist/cjs/lib/peer/media/codecCompatibility.d.ts +23 -0
- package/dist/cjs/lib/peer/media/codecCompatibility.js +137 -0
- package/dist/cjs/lib/peer/media/extension/rtcpFeedback.d.ts +6 -0
- package/dist/cjs/lib/peer/media/extension/rtcpFeedback.js +13 -0
- package/dist/cjs/lib/peer/media/extension/rtpExtension.d.ts +9 -0
- package/dist/cjs/lib/peer/media/extension/rtpExtension.js +52 -0
- package/dist/cjs/lib/peer/media/index.d.ts +12 -0
- package/dist/cjs/lib/peer/media/index.js +28 -0
- package/dist/cjs/lib/peer/media/parameters.d.ts +65 -0
- package/dist/cjs/lib/peer/media/parameters.js +60 -0
- package/dist/cjs/lib/peer/media/receiver/nack.d.ts +23 -0
- package/dist/cjs/lib/peer/media/receiver/nack.js +104 -0
- package/dist/cjs/lib/peer/media/receiver/receiverTwcc.d.ts +47 -0
- package/dist/cjs/lib/peer/media/receiver/receiverTwcc.js +179 -0
- package/dist/cjs/lib/peer/media/receiver/statistics.d.ts +22 -0
- package/dist/cjs/lib/peer/media/receiver/statistics.js +71 -0
- package/dist/cjs/lib/peer/media/router.d.ts +25 -0
- package/dist/cjs/lib/peer/media/router.js +166 -0
- package/dist/cjs/lib/peer/media/rtpReceiver.d.ts +90 -0
- package/dist/cjs/lib/peer/media/rtpReceiver.js +407 -0
- package/dist/cjs/lib/peer/media/rtpSender.d.ts +209 -0
- package/dist/cjs/lib/peer/media/rtpSender.js +826 -0
- package/dist/cjs/lib/peer/media/rtpTransceiver.d.ts +117 -0
- package/dist/cjs/lib/peer/media/rtpTransceiver.js +245 -0
- package/dist/cjs/lib/peer/media/sender/cumulativeResult.d.ts +19 -0
- package/dist/cjs/lib/peer/media/sender/cumulativeResult.js +61 -0
- package/dist/cjs/lib/peer/media/sender/senderBWE.d.ts +32 -0
- package/dist/cjs/lib/peer/media/sender/senderBWE.js +99 -0
- package/dist/cjs/lib/peer/media/stats.d.ts +293 -0
- package/dist/cjs/lib/peer/media/stats.js +90 -0
- package/dist/cjs/lib/peer/media/track.d.ts +67 -0
- package/dist/cjs/lib/peer/media/track.js +216 -0
- package/dist/cjs/lib/peer/peerConnection.d.ts +458 -0
- package/dist/cjs/lib/peer/peerConnection.js +1591 -0
- package/dist/cjs/lib/peer/sctpManager.d.ts +28 -0
- package/dist/cjs/lib/peer/sctpManager.js +138 -0
- package/dist/cjs/lib/peer/sdp.d.ts +97 -0
- package/dist/cjs/lib/peer/sdp.js +628 -0
- package/dist/cjs/lib/peer/sdpManager.d.ts +116 -0
- package/dist/cjs/lib/peer/sdpManager.js +573 -0
- package/dist/cjs/lib/peer/secureTransportManager.d.ts +96 -0
- package/dist/cjs/lib/peer/secureTransportManager.js +472 -0
- package/dist/cjs/lib/peer/transceiverManager.d.ts +151 -0
- package/dist/cjs/lib/peer/transceiverManager.js +767 -0
- package/dist/cjs/lib/peer/transport/dtls.d.ts +95 -0
- package/dist/cjs/lib/peer/transport/dtls.js +571 -0
- package/dist/cjs/lib/peer/transport/ice.d.ts +143 -0
- package/dist/cjs/lib/peer/transport/ice.js +436 -0
- package/dist/cjs/lib/peer/transport/sctp.d.ts +56 -0
- package/dist/cjs/lib/peer/transport/sctp.js +387 -0
- package/dist/cjs/lib/peer/types/domain.d.ts +5 -0
- package/dist/cjs/lib/peer/types/domain.js +19 -0
- package/dist/cjs/lib/peer/types/util.d.ts +2 -0
- package/dist/cjs/lib/peer/types/util.js +2 -0
- package/dist/cjs/lib/peer/utils.d.ts +73 -0
- package/dist/cjs/lib/peer/utils.js +306 -0
- package/dist/cjs/lib/rtp/codec/av1.d.ts +56 -0
- package/dist/cjs/lib/rtp/codec/av1.js +209 -0
- package/dist/cjs/lib/rtp/codec/base.d.ts +8 -0
- package/dist/cjs/lib/rtp/codec/base.js +15 -0
- package/dist/cjs/lib/rtp/codec/h264.d.ts +32 -0
- package/dist/cjs/lib/rtp/codec/h264.js +122 -0
- package/dist/cjs/lib/rtp/codec/index.d.ts +16 -0
- package/dist/cjs/lib/rtp/codec/index.js +84 -0
- package/dist/cjs/lib/rtp/codec/leb128.d.ts +5 -0
- package/dist/cjs/lib/rtp/codec/leb128.js +23 -0
- package/dist/cjs/lib/rtp/codec/opus.d.ts +9 -0
- package/dist/cjs/lib/rtp/codec/opus.js +25 -0
- package/dist/cjs/lib/rtp/codec/vp8.d.ts +27 -0
- package/dist/cjs/lib/rtp/codec/vp8.js +109 -0
- package/dist/cjs/lib/rtp/codec/vp9.d.ts +46 -0
- package/dist/cjs/lib/rtp/codec/vp9.js +161 -0
- package/dist/cjs/lib/rtp/const.d.ts +1 -0
- package/dist/cjs/lib/rtp/const.js +4 -0
- package/dist/cjs/lib/rtp/helper.d.ts +8 -0
- package/dist/cjs/lib/rtp/helper.js +36 -0
- package/dist/cjs/lib/rtp/imports/common.d.ts +1 -0
- package/dist/cjs/lib/rtp/imports/common.js +17 -0
- package/dist/cjs/lib/rtp/index.d.ts +25 -0
- package/dist/cjs/lib/rtp/index.js +41 -0
- package/dist/cjs/lib/rtp/rtcp/header.d.ts +13 -0
- package/dist/cjs/lib/rtp/rtcp/header.js +50 -0
- package/dist/cjs/lib/rtp/rtcp/psfb/fullIntraRequest.d.ts +16 -0
- package/dist/cjs/lib/rtp/rtcp/psfb/fullIntraRequest.js +34 -0
- package/dist/cjs/lib/rtp/rtcp/psfb/index.d.ts +14 -0
- package/dist/cjs/lib/rtp/rtcp/psfb/index.js +39 -0
- package/dist/cjs/lib/rtp/rtcp/psfb/pictureLossIndication.d.ts +10 -0
- package/dist/cjs/lib/rtp/rtcp/psfb/pictureLossIndication.js +20 -0
- package/dist/cjs/lib/rtp/rtcp/psfb/remb.d.ts +16 -0
- package/dist/cjs/lib/rtp/rtcp/psfb/remb.js +53 -0
- package/dist/cjs/lib/rtp/rtcp/rr.d.ts +32 -0
- package/dist/cjs/lib/rtp/rtcp/rr.js +73 -0
- package/dist/cjs/lib/rtp/rtcp/rtcp.d.ts +10 -0
- package/dist/cjs/lib/rtp/rtcp/rtcp.js +58 -0
- package/dist/cjs/lib/rtp/rtcp/rtpfb/const.d.ts +1 -0
- package/dist/cjs/lib/rtp/rtcp/rtpfb/const.js +4 -0
- package/dist/cjs/lib/rtp/rtcp/rtpfb/index.d.ts +14 -0
- package/dist/cjs/lib/rtp/rtcp/rtpfb/index.js +35 -0
- package/dist/cjs/lib/rtp/rtcp/rtpfb/nack.d.ts +17 -0
- package/dist/cjs/lib/rtp/rtcp/rtpfb/nack.js +77 -0
- package/dist/cjs/lib/rtp/rtcp/rtpfb/twcc.d.ts +71 -0
- package/dist/cjs/lib/rtp/rtcp/rtpfb/twcc.js +352 -0
- package/dist/cjs/lib/rtp/rtcp/sdes.d.ts +26 -0
- package/dist/cjs/lib/rtp/rtcp/sdes.js +97 -0
- package/dist/cjs/lib/rtp/rtcp/sr.d.ts +41 -0
- package/dist/cjs/lib/rtp/rtcp/sr.js +110 -0
- package/dist/cjs/lib/rtp/rtp/headerExtension.d.ts +72 -0
- package/dist/cjs/lib/rtp/rtp/headerExtension.js +117 -0
- package/dist/cjs/lib/rtp/rtp/red/encoder.d.ts +13 -0
- package/dist/cjs/lib/rtp/rtp/red/encoder.js +44 -0
- package/dist/cjs/lib/rtp/rtp/red/handler.d.ts +6 -0
- package/dist/cjs/lib/rtp/rtp/red/handler.js +59 -0
- package/dist/cjs/lib/rtp/rtp/red/packet.d.ts +26 -0
- package/dist/cjs/lib/rtp/rtp/red/packet.js +112 -0
- package/dist/cjs/lib/rtp/rtp/rtp.d.ts +44 -0
- package/dist/cjs/lib/rtp/rtp/rtp.js +271 -0
- package/dist/cjs/lib/rtp/rtp/rtx.d.ts +3 -0
- package/dist/cjs/lib/rtp/rtp/rtx.js +29 -0
- package/dist/cjs/lib/rtp/srtp/cipher/ctr.d.ts +16 -0
- package/dist/cjs/lib/rtp/srtp/cipher/ctr.js +107 -0
- package/dist/cjs/lib/rtp/srtp/cipher/gcm.d.ts +17 -0
- package/dist/cjs/lib/rtp/srtp/cipher/gcm.js +145 -0
- package/dist/cjs/lib/rtp/srtp/cipher/index.d.ts +13 -0
- package/dist/cjs/lib/rtp/srtp/cipher/index.js +24 -0
- package/dist/cjs/lib/rtp/srtp/const.d.ts +6 -0
- package/dist/cjs/lib/rtp/srtp/const.js +26 -0
- package/dist/cjs/lib/rtp/srtp/context/context.d.ts +45 -0
- package/dist/cjs/lib/rtp/srtp/context/context.js +180 -0
- package/dist/cjs/lib/rtp/srtp/context/srtcp.d.ts +8 -0
- package/dist/cjs/lib/rtp/srtp/context/srtcp.js +25 -0
- package/dist/cjs/lib/rtp/srtp/context/srtp.d.ts +9 -0
- package/dist/cjs/lib/rtp/srtp/context/srtp.js +41 -0
- package/dist/cjs/lib/rtp/srtp/error.d.ts +3 -0
- package/dist/cjs/lib/rtp/srtp/error.js +10 -0
- package/dist/cjs/lib/rtp/srtp/packet.d.ts +5 -0
- package/dist/cjs/lib/rtp/srtp/packet.js +47 -0
- package/dist/cjs/lib/rtp/srtp/session.d.ts +19 -0
- package/dist/cjs/lib/rtp/srtp/session.js +13 -0
- package/dist/cjs/lib/rtp/srtp/srtcp.d.ts +8 -0
- package/dist/cjs/lib/rtp/srtp/srtcp.js +21 -0
- package/dist/cjs/lib/rtp/srtp/srtp.d.ts +9 -0
- package/dist/cjs/lib/rtp/srtp/srtp.js +20 -0
- package/dist/cjs/lib/rtp/transport.d.ts +15 -0
- package/dist/cjs/lib/rtp/transport.js +23 -0
- package/dist/cjs/lib/rtp/util.d.ts +11 -0
- package/dist/cjs/lib/rtp/util.js +28 -0
- package/dist/cjs/lib/sctp/chunk.d.ts +164 -0
- package/dist/cjs/lib/sctp/chunk.js +542 -0
- package/dist/cjs/lib/sctp/const.d.ts +17 -0
- package/dist/cjs/lib/sctp/const.js +22 -0
- package/dist/cjs/lib/sctp/helper.d.ts +5 -0
- package/dist/cjs/lib/sctp/helper.js +14 -0
- package/dist/cjs/lib/sctp/imports/common.d.ts +1 -0
- package/dist/cjs/lib/sctp/imports/common.js +17 -0
- package/dist/cjs/lib/sctp/index.d.ts +6 -0
- package/dist/cjs/lib/sctp/index.js +20 -0
- package/dist/cjs/lib/sctp/param.d.ts +40 -0
- package/dist/cjs/lib/sctp/param.js +132 -0
- package/dist/cjs/lib/sctp/sctp.d.ts +210 -0
- package/dist/cjs/lib/sctp/sctp.js +1467 -0
- package/dist/cjs/lib/sctp/transport.d.ts +15 -0
- package/dist/cjs/lib/sctp/transport.js +28 -0
- package/dist/cjs/lib/turn/index.d.ts +9 -0
- package/dist/cjs/lib/turn/index.js +25 -0
- package/dist/cjs/lib/turn/node/server.d.ts +21 -0
- package/dist/cjs/lib/turn/node/server.js +94 -0
- package/dist/cjs/lib/turn/node/turnServer.d.ts +91 -0
- package/dist/cjs/lib/turn/node/turnServer.js +565 -0
- package/dist/cjs/lib/turn/protocol.d.ts +47 -0
- package/dist/cjs/lib/turn/protocol.js +116 -0
- package/dist/cjs/lib/turn/stun/attributes.d.ts +37 -0
- package/dist/cjs/lib/turn/stun/attributes.js +208 -0
- package/dist/cjs/lib/turn/stun/const.d.ts +28 -0
- package/dist/cjs/lib/turn/stun/const.js +87 -0
- package/dist/cjs/lib/turn/stun/ip.d.ts +12 -0
- package/dist/cjs/lib/turn/stun/ip.js +87 -0
- package/dist/cjs/lib/turn/stun/message.d.ts +37 -0
- package/dist/cjs/lib/turn/stun/message.js +180 -0
- package/dist/cjs/lib/turn/turn/auth.d.ts +1 -0
- package/dist/cjs/lib/turn/turn/auth.js +9 -0
- package/dist/cjs/lib/turn/turn/frame.d.ts +13 -0
- package/dist/cjs/lib/turn/turn/frame.js +68 -0
- package/dist/cjs/lib/turn/turn/protocol.d.ts +147 -0
- package/dist/cjs/lib/turn/turn/protocol.js +785 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/peer/Endpoints.d.ts +75 -0
- package/dist/cjs/peer/Endpoints.js +154 -0
- package/dist/cjs/peer/EngineConfig.d.ts +20 -0
- package/dist/cjs/peer/EngineConfig.js +36 -0
- package/dist/cjs/peer/EngineConnection.d.ts +22 -0
- package/dist/cjs/peer/EngineConnection.js +27 -0
- package/dist/cjs/peer/Events.d.ts +55 -0
- package/dist/cjs/peer/Events.js +85 -0
- package/dist/cjs/peer/MediaCodecs.d.ts +27 -0
- package/dist/cjs/peer/MediaCodecs.js +53 -0
- package/dist/cjs/peer/MediaTrack.d.ts +212 -0
- package/dist/cjs/peer/MediaTrack.js +313 -0
- package/dist/cjs/peer/PeerChannel.d.ts +248 -0
- package/dist/cjs/peer/PeerChannel.js +319 -0
- package/dist/cjs/peer/PeerConnection.d.ts +603 -0
- package/dist/cjs/peer/PeerConnection.js +697 -0
- package/dist/cjs/peer/PeerThreadChannel.d.ts +112 -0
- package/dist/cjs/peer/PeerThreadChannel.js +273 -0
- package/dist/cjs/peer/PeerThreadProtocol.d.ts +325 -0
- package/dist/cjs/peer/PeerThreadProtocol.js +2 -0
- package/dist/cjs/peer/PeerThreads.d.ts +114 -0
- package/dist/cjs/peer/PeerThreads.js +268 -0
- package/dist/cjs/peer/PeerWorker.d.ts +6 -0
- package/dist/cjs/peer/PeerWorker.js +461 -0
- package/dist/cjs/peer/PeerWorkerCode.d.ts +5 -0
- package/dist/cjs/peer/PeerWorkerCode.js +4 -0
- package/dist/cjs/peer/RemoteConnection.d.ts +314 -0
- package/dist/cjs/peer/RemoteConnection.js +913 -0
- package/dist/cjs/peer/RtpPacket.d.ts +112 -0
- package/dist/cjs/peer/RtpPacket.js +92 -0
- package/dist/cjs/peer/RtpTransceiver.d.ts +167 -0
- package/dist/cjs/peer/RtpTransceiver.js +235 -0
- package/dist/cjs/peer/SignalingClient.d.ts +236 -0
- package/dist/cjs/peer/SignalingClient.js +285 -0
- package/dist/cjs/protocol/SignalingProtocol.d.ts +266 -0
- package/dist/cjs/protocol/SignalingProtocol.js +65 -0
- package/dist/cjs/service/WebRTCServiceEntrypoint.d.ts +158 -0
- package/dist/cjs/service/WebRTCServiceEntrypoint.js +356 -0
- package/dist/cjs/sfu/SFU.d.ts +356 -0
- package/dist/cjs/sfu/SFU.js +763 -0
- package/dist/cjs/sfu/SFUAccess.d.ts +48 -0
- package/dist/cjs/sfu/SFUAccess.js +15 -0
- package/dist/cjs/sfu/SFUClusterLeg.d.ts +101 -0
- package/dist/cjs/sfu/SFUClusterLeg.js +106 -0
- package/dist/cjs/sfu/SFURoom.d.ts +148 -0
- package/dist/cjs/sfu/SFURoom.js +1300 -0
- package/dist/cjs/sfu/SFUWorker.d.ts +13 -0
- package/dist/cjs/sfu/SFUWorker.js +168 -0
- package/dist/cjs/sfu/SFUWorkerChannel.d.ts +204 -0
- package/dist/cjs/sfu/SFUWorkerChannel.js +105 -0
- package/dist/cjs/sfu/SFUWorkerCode.d.ts +5 -0
- package/dist/cjs/sfu/SFUWorkerCode.js +4 -0
- package/dist/cjs/sfu/SFUWorkers.d.ts +247 -0
- package/dist/cjs/sfu/SFUWorkers.js +552 -0
- package/dist/cjs/shared/ChunkedChannel.d.ts +122 -0
- package/dist/cjs/shared/ChunkedChannel.js +182 -0
- package/dist/cjs/shared/Connections.d.ts +231 -0
- package/dist/cjs/shared/Connections.js +2 -0
- package/dist/cjs/shared/Emitter.d.ts +50 -0
- package/dist/cjs/shared/Emitter.js +80 -0
- package/dist/cjs/shared/Peer.d.ts +182 -0
- package/dist/cjs/shared/Peer.js +509 -0
- package/dist/cjs/shared/PeerServiceProxy.d.ts +173 -0
- package/dist/cjs/shared/PeerServiceProxy.js +304 -0
- package/dist/cjs/shared/Room.d.ts +143 -0
- package/dist/cjs/shared/Room.js +515 -0
- package/dist/cjs/shared/SignalingError.d.ts +40 -0
- package/dist/cjs/shared/SignalingError.js +48 -0
- package/dist/cjs/shared/SignalingSession.d.ts +97 -0
- package/dist/cjs/shared/SignalingSession.js +347 -0
- package/dist/cjs/shared/Transports.d.ts +139 -0
- package/dist/cjs/shared/Transports.js +285 -0
- package/dist/cjs/signaling/MediaServers.d.ts +40 -0
- package/dist/cjs/signaling/MediaServers.js +16 -0
- package/dist/cjs/signaling/Signaling.d.ts +573 -0
- package/dist/cjs/signaling/Signaling.js +945 -0
- package/dist/cjs/signaling/SignalingController.d.ts +128 -0
- package/dist/cjs/signaling/SignalingController.js +229 -0
- package/dist/cjs/turn/TURNCredentials.d.ts +49 -0
- package/dist/cjs/turn/TURNCredentials.js +49 -0
- package/dist/cjs/turn/TURNIceServers.d.ts +11 -0
- package/dist/cjs/turn/TURNIceServers.js +25 -0
- package/dist/cjs/turn/TURNServer.d.ts +309 -0
- package/dist/cjs/turn/TURNServer.js +331 -0
- package/dist/cjs/turn/TURNWorker.d.ts +42 -0
- package/dist/cjs/turn/TURNWorker.js +52 -0
- package/dist/cjs/turn/TURNWorkerCode.d.ts +5 -0
- package/dist/cjs/turn/TURNWorkerCode.js +4 -0
- package/dist/cjs/turn/TURNWorkers.d.ts +52 -0
- package/dist/cjs/turn/TURNWorkers.js +211 -0
- package/dist/cjs/whep/WHEP.d.ts +386 -0
- package/dist/cjs/whep/WHEP.js +426 -0
- package/dist/cjs/whep/WHEPController.d.ts +134 -0
- package/dist/cjs/whep/WHEPController.js +301 -0
- package/dist/cjs/whip/WHIP.d.ts +426 -0
- package/dist/cjs/whip/WHIP.js +470 -0
- package/dist/cjs/whip/WHIPController.d.ts +132 -0
- package/dist/cjs/whip/WHIPController.js +299 -0
- package/dist/esm/client/SignalingConnection.js +63 -0
- package/dist/esm/cluster/Cluster.js +542 -0
- package/dist/esm/cluster/ClusterFrames.js +85 -0
- package/dist/esm/cluster/ClusterTURN.js +73 -0
- package/dist/esm/cluster/Rendezvous.js +20 -0
- package/dist/esm/cluster/transports/ClusterTransport.js +1 -0
- package/dist/esm/cluster/transports/LoadClient.js +44 -0
- package/dist/esm/cluster/transports/MemoryClusterTransport.js +43 -0
- package/dist/esm/cluster/transports/NATSClusterTransport.js +66 -0
- package/dist/esm/cluster/transports/RedisClusterTransport.js +73 -0
- package/dist/esm/exceptions/ClusterRequestException.js +14 -0
- package/dist/esm/exceptions/ClusterTimeoutException.js +13 -0
- package/dist/esm/exceptions/ClusterTransportNotFoundException.js +14 -0
- package/dist/esm/exceptions/SignalingClientRequiredException.js +15 -0
- package/dist/esm/exceptions/SignalingConnectionException.js +15 -0
- package/dist/esm/exceptions/SignalingDeniedException.js +14 -0
- package/dist/esm/exceptions/SignalingLimitException.js +14 -0
- package/dist/esm/exceptions/SignalingNotAMemberException.js +14 -0
- package/dist/esm/exceptions/WHEPDeniedException.js +18 -0
- package/dist/esm/exceptions/WHEPLimitException.js +18 -0
- package/dist/esm/exceptions/WHEPMediaTypeException.js +18 -0
- package/dist/esm/exceptions/WHEPOfferException.js +19 -0
- package/dist/esm/exceptions/WHEPSessionNotFoundException.js +18 -0
- package/dist/esm/exceptions/WHIPDeniedException.js +18 -0
- package/dist/esm/exceptions/WHIPLimitException.js +18 -0
- package/dist/esm/exceptions/WHIPMediaTypeException.js +18 -0
- package/dist/esm/exceptions/WHIPOfferException.js +19 -0
- package/dist/esm/exceptions/WHIPSessionNotFoundException.js +18 -0
- package/dist/esm/exports/Client.js +5 -0
- package/dist/esm/exports/WebRTC.js +41 -0
- package/dist/esm/lib/common/binary.js +244 -0
- package/dist/esm/lib/common/binaryData.js +392 -0
- package/dist/esm/lib/common/crc.js +118 -0
- package/dist/esm/lib/common/deque.js +85 -0
- package/dist/esm/lib/common/event.js +202 -0
- package/dist/esm/lib/common/index.js +11 -0
- package/dist/esm/lib/common/log.js +55 -0
- package/dist/esm/lib/common/network.js +52 -0
- package/dist/esm/lib/common/number.js +31 -0
- package/dist/esm/lib/common/promise.js +64 -0
- package/dist/esm/lib/common/transport.js +401 -0
- package/dist/esm/lib/common/type.js +1 -0
- package/dist/esm/lib/dtls/cipher/const.js +30 -0
- package/dist/esm/lib/dtls/cipher/create.js +98 -0
- package/dist/esm/lib/dtls/cipher/ec.js +37 -0
- package/dist/esm/lib/dtls/cipher/key-exchange.js +103 -0
- package/dist/esm/lib/dtls/cipher/namedCurve.js +24 -0
- package/dist/esm/lib/dtls/cipher/prf.js +79 -0
- package/dist/esm/lib/dtls/cipher/suites/abstract.js +37 -0
- package/dist/esm/lib/dtls/cipher/suites/aead.js +96 -0
- package/dist/esm/lib/dtls/cipher/suites/null.js +35 -0
- package/dist/esm/lib/dtls/cipher/utils.js +34 -0
- package/dist/esm/lib/dtls/cipher/x509.js +94 -0
- package/dist/esm/lib/dtls/client.js +72 -0
- package/dist/esm/lib/dtls/context/cipher.js +83 -0
- package/dist/esm/lib/dtls/context/dtls.js +45 -0
- package/dist/esm/lib/dtls/context/srtp.js +8 -0
- package/dist/esm/lib/dtls/context/transport.js +13 -0
- package/dist/esm/lib/dtls/flight/client/flight1.js +22 -0
- package/dist/esm/lib/dtls/flight/client/flight3.js +21 -0
- package/dist/esm/lib/dtls/flight/client/flight5.js +202 -0
- package/dist/esm/lib/dtls/flight/flight.js +64 -0
- package/dist/esm/lib/dtls/flight/server/flight2.js +122 -0
- package/dist/esm/lib/dtls/flight/server/flight4.js +83 -0
- package/dist/esm/lib/dtls/flight/server/flight6.js +107 -0
- package/dist/esm/lib/dtls/handshake/binary.js +17 -0
- package/dist/esm/lib/dtls/handshake/const.js +14 -0
- package/dist/esm/lib/dtls/handshake/extensions/ellipticCurves.js +36 -0
- package/dist/esm/lib/dtls/handshake/extensions/extendedMasterSecret.js +3 -0
- package/dist/esm/lib/dtls/handshake/extensions/renegotiationIndication.js +30 -0
- package/dist/esm/lib/dtls/handshake/extensions/signature.js +35 -0
- package/dist/esm/lib/dtls/handshake/extensions/useSrtp.js +61 -0
- package/dist/esm/lib/dtls/handshake/message/alert.js +20 -0
- package/dist/esm/lib/dtls/handshake/message/certificate.js +31 -0
- package/dist/esm/lib/dtls/handshake/message/changeCipherSpec.js +20 -0
- package/dist/esm/lib/dtls/handshake/message/client/certificateVerify.js +31 -0
- package/dist/esm/lib/dtls/handshake/message/client/hello.js +44 -0
- package/dist/esm/lib/dtls/handshake/message/client/keyExchange.js +29 -0
- package/dist/esm/lib/dtls/handshake/message/finished.js +22 -0
- package/dist/esm/lib/dtls/handshake/message/server/certificateRequest.js +34 -0
- package/dist/esm/lib/dtls/handshake/message/server/hello.js +53 -0
- package/dist/esm/lib/dtls/handshake/message/server/helloDone.js +26 -0
- package/dist/esm/lib/dtls/handshake/message/server/helloVerifyRequest.js +38 -0
- package/dist/esm/lib/dtls/handshake/message/server/keyExchange.js +45 -0
- package/dist/esm/lib/dtls/handshake/random.js +25 -0
- package/dist/esm/lib/dtls/helper.js +23 -0
- package/dist/esm/lib/dtls/imports/common.js +1 -0
- package/dist/esm/lib/dtls/imports/rtp.js +1 -0
- package/dist/esm/lib/dtls/index.js +97 -0
- package/dist/esm/lib/dtls/record/antiReplayWindow.js +98 -0
- package/dist/esm/lib/dtls/record/builder.js +22 -0
- package/dist/esm/lib/dtls/record/const.js +35 -0
- package/dist/esm/lib/dtls/record/message/fragment.js +92 -0
- package/dist/esm/lib/dtls/record/message/header.js +30 -0
- package/dist/esm/lib/dtls/record/message/plaintext.js +59 -0
- package/dist/esm/lib/dtls/record/receive.js +86 -0
- package/dist/esm/lib/dtls/server.js +74 -0
- package/dist/esm/lib/dtls/socket.js +184 -0
- package/dist/esm/lib/dtls/typings/domain.js +1 -0
- package/dist/esm/lib/dtls/util/binary.js +5 -0
- package/dist/esm/lib/ice/candidate.js +190 -0
- package/dist/esm/lib/ice/dns/lookup.js +95 -0
- package/dist/esm/lib/ice/dns/mdns.js +139 -0
- package/dist/esm/lib/ice/exceptions.js +34 -0
- package/dist/esm/lib/ice/helper.js +65 -0
- package/dist/esm/lib/ice/ice.js +1547 -0
- package/dist/esm/lib/ice/iceBase.js +172 -0
- package/dist/esm/lib/ice/imports/common.js +1 -0
- package/dist/esm/lib/ice/index.js +12 -0
- package/dist/esm/lib/ice/internal/selectAddresses.js +36 -0
- package/dist/esm/lib/ice/stun/attributes.js +1 -0
- package/dist/esm/lib/ice/stun/const.js +8 -0
- package/dist/esm/lib/ice/stun/message.js +1 -0
- package/dist/esm/lib/ice/stun/protocol.js +121 -0
- package/dist/esm/lib/ice/stun/tcpFrame.js +21 -0
- package/dist/esm/lib/ice/stun/tcpProtocol.js +318 -0
- package/dist/esm/lib/ice/stun/transaction.js +230 -0
- package/dist/esm/lib/ice/turn/frame.js +1 -0
- package/dist/esm/lib/ice/turn/protocol.js +630 -0
- package/dist/esm/lib/ice/types/model.js +1 -0
- package/dist/esm/lib/ice/utils.js +43 -0
- package/dist/esm/lib/peer/const.js +50 -0
- package/dist/esm/lib/peer/dataChannel.js +127 -0
- package/dist/esm/lib/peer/errors.js +17 -0
- package/dist/esm/lib/peer/helper.js +77 -0
- package/dist/esm/lib/peer/imports/common.js +1 -0
- package/dist/esm/lib/peer/imports/dtls.js +1 -0
- package/dist/esm/lib/peer/imports/ice.js +1 -0
- package/dist/esm/lib/peer/imports/rtp.js +1 -0
- package/dist/esm/lib/peer/index.js +14 -0
- package/dist/esm/lib/peer/media/codec.js +69 -0
- package/dist/esm/lib/peer/media/codecCompatibility.js +128 -0
- package/dist/esm/lib/peer/media/extension/rtcpFeedback.js +5 -0
- package/dist/esm/lib/peer/media/extension/rtpExtension.js +42 -0
- package/dist/esm/lib/peer/media/index.js +12 -0
- package/dist/esm/lib/peer/media/parameters.js +50 -0
- package/dist/esm/lib/peer/media/receiver/nack.js +100 -0
- package/dist/esm/lib/peer/media/receiver/receiverTwcc.js +175 -0
- package/dist/esm/lib/peer/media/receiver/statistics.js +67 -0
- package/dist/esm/lib/peer/media/router.js +162 -0
- package/dist/esm/lib/peer/media/rtpReceiver.js +403 -0
- package/dist/esm/lib/peer/media/rtpSender.js +822 -0
- package/dist/esm/lib/peer/media/rtpTransceiver.js +241 -0
- package/dist/esm/lib/peer/media/sender/cumulativeResult.js +57 -0
- package/dist/esm/lib/peer/media/sender/senderBWE.js +95 -0
- package/dist/esm/lib/peer/media/stats.js +81 -0
- package/dist/esm/lib/peer/media/track.js +208 -0
- package/dist/esm/lib/peer/peerConnection.js +1585 -0
- package/dist/esm/lib/peer/sctpManager.js +134 -0
- package/dist/esm/lib/peer/sdp.js +614 -0
- package/dist/esm/lib/peer/sdpManager.js +569 -0
- package/dist/esm/lib/peer/secureTransportManager.js +468 -0
- package/dist/esm/lib/peer/transceiverManager.js +763 -0
- package/dist/esm/lib/peer/transport/dtls.js +564 -0
- package/dist/esm/lib/peer/transport/ice.js +426 -0
- package/dist/esm/lib/peer/transport/sctp.js +382 -0
- package/dist/esm/lib/peer/types/domain.js +16 -0
- package/dist/esm/lib/peer/types/util.js +1 -0
- package/dist/esm/lib/peer/utils.js +286 -0
- package/dist/esm/lib/rtp/codec/av1.js +203 -0
- package/dist/esm/lib/rtp/codec/base.js +11 -0
- package/dist/esm/lib/rtp/codec/h264.js +118 -0
- package/dist/esm/lib/rtp/codec/index.js +66 -0
- package/dist/esm/lib/rtp/codec/leb128.js +20 -0
- package/dist/esm/lib/rtp/codec/opus.js +21 -0
- package/dist/esm/lib/rtp/codec/vp8.js +105 -0
- package/dist/esm/lib/rtp/codec/vp9.js +157 -0
- package/dist/esm/lib/rtp/const.js +1 -0
- package/dist/esm/lib/rtp/helper.js +29 -0
- package/dist/esm/lib/rtp/imports/common.js +1 -0
- package/dist/esm/lib/rtp/index.js +25 -0
- package/dist/esm/lib/rtp/rtcp/header.js +46 -0
- package/dist/esm/lib/rtp/rtcp/psfb/fullIntraRequest.js +30 -0
- package/dist/esm/lib/rtp/rtcp/psfb/index.js +35 -0
- package/dist/esm/lib/rtp/rtcp/psfb/pictureLossIndication.js +16 -0
- package/dist/esm/lib/rtp/rtcp/psfb/remb.js +49 -0
- package/dist/esm/lib/rtp/rtcp/rr.js +68 -0
- package/dist/esm/lib/rtp/rtcp/rtcp.js +53 -0
- package/dist/esm/lib/rtp/rtcp/rtpfb/const.js +1 -0
- package/dist/esm/lib/rtp/rtcp/rtpfb/index.js +31 -0
- package/dist/esm/lib/rtp/rtcp/rtpfb/nack.js +73 -0
- package/dist/esm/lib/rtp/rtcp/rtpfb/twcc.js +344 -0
- package/dist/esm/lib/rtp/rtcp/sdes.js +91 -0
- package/dist/esm/lib/rtp/rtcp/sr.js +104 -0
- package/dist/esm/lib/rtp/rtp/headerExtension.js +102 -0
- package/dist/esm/lib/rtp/rtp/red/encoder.js +40 -0
- package/dist/esm/lib/rtp/rtp/red/handler.js +55 -0
- package/dist/esm/lib/rtp/rtp/red/packet.js +107 -0
- package/dist/esm/lib/rtp/rtp/rtp.js +266 -0
- package/dist/esm/lib/rtp/rtp/rtx.js +25 -0
- package/dist/esm/lib/rtp/srtp/cipher/ctr.js +103 -0
- package/dist/esm/lib/rtp/srtp/cipher/gcm.js +141 -0
- package/dist/esm/lib/rtp/srtp/cipher/index.js +20 -0
- package/dist/esm/lib/rtp/srtp/const.js +21 -0
- package/dist/esm/lib/rtp/srtp/context/context.js +175 -0
- package/dist/esm/lib/rtp/srtp/context/srtcp.js +21 -0
- package/dist/esm/lib/rtp/srtp/context/srtp.js +37 -0
- package/dist/esm/lib/rtp/srtp/error.js +6 -0
- package/dist/esm/lib/rtp/srtp/packet.js +42 -0
- package/dist/esm/lib/rtp/srtp/session.js +9 -0
- package/dist/esm/lib/rtp/srtp/srtcp.js +17 -0
- package/dist/esm/lib/rtp/srtp/srtp.js +16 -0
- package/dist/esm/lib/rtp/transport.js +18 -0
- package/dist/esm/lib/rtp/util.js +24 -0
- package/dist/esm/lib/sctp/chunk.js +515 -0
- package/dist/esm/lib/sctp/const.js +19 -0
- package/dist/esm/lib/sctp/helper.js +10 -0
- package/dist/esm/lib/sctp/imports/common.js +1 -0
- package/dist/esm/lib/sctp/index.js +4 -0
- package/dist/esm/lib/sctp/param.js +126 -0
- package/dist/esm/lib/sctp/sctp.js +1459 -0
- package/dist/esm/lib/sctp/transport.js +23 -0
- package/dist/esm/lib/turn/index.js +9 -0
- package/dist/esm/lib/turn/node/server.js +89 -0
- package/dist/esm/lib/turn/node/turnServer.js +560 -0
- package/dist/esm/lib/turn/protocol.js +112 -0
- package/dist/esm/lib/turn/stun/attributes.js +198 -0
- package/dist/esm/lib/turn/stun/const.js +82 -0
- package/dist/esm/lib/turn/stun/ip.js +81 -0
- package/dist/esm/lib/turn/stun/message.js +174 -0
- package/dist/esm/lib/turn/turn/auth.js +6 -0
- package/dist/esm/lib/turn/turn/frame.js +61 -0
- package/dist/esm/lib/turn/turn/protocol.js +781 -0
- package/dist/esm/peer/Endpoints.js +143 -0
- package/dist/esm/peer/EngineConfig.js +33 -0
- package/dist/esm/peer/EngineConnection.js +22 -0
- package/dist/esm/peer/Events.js +81 -0
- package/dist/esm/peer/MediaCodecs.js +47 -0
- package/dist/esm/peer/MediaTrack.js +305 -0
- package/dist/esm/peer/PeerChannel.js +315 -0
- package/dist/esm/peer/PeerConnection.js +694 -0
- package/dist/esm/peer/PeerThreadChannel.js +266 -0
- package/dist/esm/peer/PeerThreadProtocol.js +1 -0
- package/dist/esm/peer/PeerThreads.js +264 -0
- package/dist/esm/peer/PeerWorker.js +458 -0
- package/dist/esm/peer/PeerWorkerCode.js +1 -0
- package/dist/esm/peer/RemoteConnection.js +905 -0
- package/dist/esm/peer/RtpPacket.js +86 -0
- package/dist/esm/peer/RtpTransceiver.js +225 -0
- package/dist/esm/peer/SignalingClient.js +249 -0
- package/dist/esm/protocol/SignalingProtocol.js +62 -0
- package/dist/esm/service/WebRTCServiceEntrypoint.js +352 -0
- package/dist/esm/sfu/SFU.js +759 -0
- package/dist/esm/sfu/SFUAccess.js +12 -0
- package/dist/esm/sfu/SFUClusterLeg.js +102 -0
- package/dist/esm/sfu/SFURoom.js +1296 -0
- package/dist/esm/sfu/SFUWorker.js +165 -0
- package/dist/esm/sfu/SFUWorkerChannel.js +101 -0
- package/dist/esm/sfu/SFUWorkerCode.js +1 -0
- package/dist/esm/sfu/SFUWorkers.js +547 -0
- package/dist/esm/shared/ChunkedChannel.js +178 -0
- package/dist/esm/shared/Connections.js +1 -0
- package/dist/esm/shared/Emitter.js +76 -0
- package/dist/esm/shared/Peer.js +505 -0
- package/dist/esm/shared/PeerServiceProxy.js +299 -0
- package/dist/esm/shared/Room.js +511 -0
- package/dist/esm/shared/SignalingError.js +43 -0
- package/dist/esm/shared/SignalingSession.js +343 -0
- package/dist/esm/shared/Transports.js +279 -0
- package/dist/esm/signaling/MediaServers.js +13 -0
- package/dist/esm/signaling/Signaling.js +941 -0
- package/dist/esm/signaling/SignalingController.js +225 -0
- package/dist/esm/turn/TURNCredentials.js +44 -0
- package/dist/esm/turn/TURNIceServers.js +22 -0
- package/dist/esm/turn/TURNServer.js +327 -0
- package/dist/esm/turn/TURNWorker.js +49 -0
- package/dist/esm/turn/TURNWorkerCode.js +1 -0
- package/dist/esm/turn/TURNWorkers.js +206 -0
- package/dist/esm/whep/WHEP.js +422 -0
- package/dist/esm/whep/WHEPController.js +298 -0
- package/dist/esm/whip/WHIP.js +466 -0
- package/dist/esm/whip/WHIPController.js +296 -0
- package/dist/types/client/SignalingConnection.d.ts +81 -0
- package/dist/types/cluster/Cluster.d.ts +503 -0
- package/dist/types/cluster/ClusterFrames.d.ts +24 -0
- package/dist/types/cluster/ClusterTURN.d.ts +63 -0
- package/dist/types/cluster/Rendezvous.d.ts +8 -0
- package/dist/types/cluster/transports/ClusterTransport.d.ts +34 -0
- package/dist/types/cluster/transports/LoadClient.d.ts +6 -0
- package/dist/types/cluster/transports/MemoryClusterTransport.d.ts +13 -0
- package/dist/types/cluster/transports/NATSClusterTransport.d.ts +23 -0
- package/dist/types/cluster/transports/RedisClusterTransport.d.ts +23 -0
- package/dist/types/exceptions/ClusterRequestException.d.ts +11 -0
- package/dist/types/exceptions/ClusterTimeoutException.d.ts +10 -0
- package/dist/types/exceptions/ClusterTransportNotFoundException.d.ts +11 -0
- package/dist/types/exceptions/SignalingClientRequiredException.d.ts +12 -0
- package/dist/types/exceptions/SignalingConnectionException.d.ts +12 -0
- package/dist/types/exceptions/SignalingDeniedException.d.ts +11 -0
- package/dist/types/exceptions/SignalingLimitException.d.ts +11 -0
- package/dist/types/exceptions/SignalingNotAMemberException.d.ts +11 -0
- package/dist/types/exceptions/WHEPDeniedException.d.ts +15 -0
- package/dist/types/exceptions/WHEPLimitException.d.ts +15 -0
- package/dist/types/exceptions/WHEPMediaTypeException.d.ts +15 -0
- package/dist/types/exceptions/WHEPOfferException.d.ts +16 -0
- package/dist/types/exceptions/WHEPSessionNotFoundException.d.ts +15 -0
- package/dist/types/exceptions/WHIPDeniedException.d.ts +15 -0
- package/dist/types/exceptions/WHIPLimitException.d.ts +15 -0
- package/dist/types/exceptions/WHIPMediaTypeException.d.ts +15 -0
- package/dist/types/exceptions/WHIPOfferException.d.ts +16 -0
- package/dist/types/exceptions/WHIPSessionNotFoundException.d.ts +15 -0
- package/dist/types/exports/Client.d.ts +11 -0
- package/dist/types/exports/WebRTC.d.ts +48 -0
- package/dist/types/lib/common/binary.d.ts +51 -0
- package/dist/types/lib/common/binaryData.d.ts +116 -0
- package/dist/types/lib/common/crc.d.ts +4 -0
- package/dist/types/lib/common/deque.d.ts +36 -0
- package/dist/types/lib/common/event.d.ts +48 -0
- package/dist/types/lib/common/index.d.ts +11 -0
- package/dist/types/lib/common/log.d.ts +47 -0
- package/dist/types/lib/common/network.d.ts +10 -0
- package/dist/types/lib/common/number.d.ts +13 -0
- package/dist/types/lib/common/promise.d.ts +21 -0
- package/dist/types/lib/common/transport.d.ts +104 -0
- package/dist/types/lib/common/type.d.ts +3 -0
- package/dist/types/lib/dtls/cipher/const.d.ts +42 -0
- package/dist/types/lib/dtls/cipher/create.d.ts +21 -0
- package/dist/types/lib/dtls/cipher/ec.d.ts +28 -0
- package/dist/types/lib/dtls/cipher/key-exchange.d.ts +43 -0
- package/dist/types/lib/dtls/cipher/namedCurve.d.ts +7 -0
- package/dist/types/lib/dtls/cipher/prf.d.ts +17 -0
- package/dist/types/lib/dtls/cipher/suites/abstract.d.ts +40 -0
- package/dist/types/lib/dtls/cipher/suites/aead.d.ts +28 -0
- package/dist/types/lib/dtls/cipher/suites/null.d.ts +24 -0
- package/dist/types/lib/dtls/cipher/utils.d.ts +18 -0
- package/dist/types/lib/dtls/cipher/x509.d.ts +33 -0
- package/dist/types/lib/dtls/client.d.ts +7 -0
- package/dist/types/lib/dtls/context/cipher.d.ts +42 -0
- package/dist/types/lib/dtls/context/dtls.d.ts +38 -0
- package/dist/types/lib/dtls/context/srtp.d.ts +5 -0
- package/dist/types/lib/dtls/context/transport.d.ts +8 -0
- package/dist/types/lib/dtls/flight/client/flight1.d.ts +10 -0
- package/dist/types/lib/dtls/flight/client/flight3.d.ts +8 -0
- package/dist/types/lib/dtls/flight/client/flight5.d.ts +18 -0
- package/dist/types/lib/dtls/flight/flight.d.ts +18 -0
- package/dist/types/lib/dtls/flight/server/flight2.d.ts +6 -0
- package/dist/types/lib/dtls/flight/server/flight4.d.ts +17 -0
- package/dist/types/lib/dtls/flight/server/flight6.d.ts +13 -0
- package/dist/types/lib/dtls/handshake/binary.d.ts +16 -0
- package/dist/types/lib/dtls/handshake/const.d.ts +13 -0
- package/dist/types/lib/dtls/handshake/extensions/ellipticCurves.d.ts +17 -0
- package/dist/types/lib/dtls/handshake/extensions/extendedMasterSecret.d.ts +3 -0
- package/dist/types/lib/dtls/handshake/extensions/renegotiationIndication.d.ts +18 -0
- package/dist/types/lib/dtls/handshake/extensions/signature.d.ts +26 -0
- package/dist/types/lib/dtls/handshake/extensions/useSrtp.d.ts +19 -0
- package/dist/types/lib/dtls/handshake/message/alert.d.ts +12 -0
- package/dist/types/lib/dtls/handshake/message/certificate.d.ts +17 -0
- package/dist/types/lib/dtls/handshake/message/changeCipherSpec.d.ts +11 -0
- package/dist/types/lib/dtls/handshake/message/client/certificateVerify.d.ts +20 -0
- package/dist/types/lib/dtls/handshake/message/client/hello.d.ts +50 -0
- package/dist/types/lib/dtls/handshake/message/client/keyExchange.d.ts +17 -0
- package/dist/types/lib/dtls/handshake/message/finished.d.ts +13 -0
- package/dist/types/lib/dtls/handshake/message/server/certificateRequest.d.ts +31 -0
- package/dist/types/lib/dtls/handshake/message/server/hello.d.ts +33 -0
- package/dist/types/lib/dtls/handshake/message/server/helloDone.d.ts +12 -0
- package/dist/types/lib/dtls/handshake/message/server/helloVerifyRequest.d.ts +32 -0
- package/dist/types/lib/dtls/handshake/message/server/keyExchange.d.ts +32 -0
- package/dist/types/lib/dtls/handshake/random.d.ts +13 -0
- package/dist/types/lib/dtls/helper.d.ts +4 -0
- package/dist/types/lib/dtls/imports/common.d.ts +1 -0
- package/dist/types/lib/dtls/imports/rtp.d.ts +1 -0
- package/dist/types/lib/dtls/index.d.ts +7 -0
- package/dist/types/lib/dtls/record/antiReplayWindow.d.ts +27 -0
- package/dist/types/lib/dtls/record/builder.d.ts +9 -0
- package/dist/types/lib/dtls/record/const.d.ts +33 -0
- package/dist/types/lib/dtls/record/message/fragment.d.ts +26 -0
- package/dist/types/lib/dtls/record/message/header.d.ts +38 -0
- package/dist/types/lib/dtls/record/message/plaintext.d.ts +14 -0
- package/dist/types/lib/dtls/record/receive.d.ts +9 -0
- package/dist/types/lib/dtls/server.d.ts +6 -0
- package/dist/types/lib/dtls/socket.d.ts +52 -0
- package/dist/types/lib/dtls/typings/domain.d.ts +20 -0
- package/dist/types/lib/dtls/util/binary.d.ts +2 -0
- package/dist/types/lib/ice/candidate.d.ts +35 -0
- package/dist/types/lib/ice/dns/lookup.d.ts +16 -0
- package/dist/types/lib/ice/dns/mdns.d.ts +38 -0
- package/dist/types/lib/ice/exceptions.d.ts +24 -0
- package/dist/types/lib/ice/helper.d.ts +17 -0
- package/dist/types/lib/ice/ice.d.ts +182 -0
- package/dist/types/lib/ice/iceBase.d.ts +214 -0
- package/dist/types/lib/ice/imports/common.d.ts +1 -0
- package/dist/types/lib/ice/index.d.ts +12 -0
- package/dist/types/lib/ice/internal/selectAddresses.d.ts +9 -0
- package/dist/types/lib/ice/stun/attributes.d.ts +1 -0
- package/dist/types/lib/ice/stun/const.d.ts +8 -0
- package/dist/types/lib/ice/stun/message.d.ts +1 -0
- package/dist/types/lib/ice/stun/protocol.d.ts +30 -0
- package/dist/types/lib/ice/stun/tcpFrame.d.ts +5 -0
- package/dist/types/lib/ice/stun/tcpProtocol.d.ts +57 -0
- package/dist/types/lib/ice/stun/transaction.d.ts +75 -0
- package/dist/types/lib/ice/turn/frame.d.ts +1 -0
- package/dist/types/lib/ice/turn/protocol.d.ts +170 -0
- package/dist/types/lib/ice/types/model.d.ts +56 -0
- package/dist/types/lib/ice/utils.d.ts +13 -0
- package/dist/types/lib/peer/const.d.ts +36 -0
- package/dist/types/lib/peer/dataChannel.d.ts +69 -0
- package/dist/types/lib/peer/errors.d.ts +11 -0
- package/dist/types/lib/peer/helper.d.ts +20 -0
- package/dist/types/lib/peer/imports/common.d.ts +1 -0
- package/dist/types/lib/peer/imports/dtls.d.ts +1 -0
- package/dist/types/lib/peer/imports/ice.d.ts +1 -0
- package/dist/types/lib/peer/imports/rtp.d.ts +1 -0
- package/dist/types/lib/peer/index.d.ts +14 -0
- package/dist/types/lib/peer/media/codec.d.ts +15 -0
- package/dist/types/lib/peer/media/codecCompatibility.d.ts +23 -0
- package/dist/types/lib/peer/media/extension/rtcpFeedback.d.ts +6 -0
- package/dist/types/lib/peer/media/extension/rtpExtension.d.ts +9 -0
- package/dist/types/lib/peer/media/index.d.ts +12 -0
- package/dist/types/lib/peer/media/parameters.d.ts +65 -0
- package/dist/types/lib/peer/media/receiver/nack.d.ts +23 -0
- package/dist/types/lib/peer/media/receiver/receiverTwcc.d.ts +47 -0
- package/dist/types/lib/peer/media/receiver/statistics.d.ts +22 -0
- package/dist/types/lib/peer/media/router.d.ts +25 -0
- package/dist/types/lib/peer/media/rtpReceiver.d.ts +90 -0
- package/dist/types/lib/peer/media/rtpSender.d.ts +209 -0
- package/dist/types/lib/peer/media/rtpTransceiver.d.ts +117 -0
- package/dist/types/lib/peer/media/sender/cumulativeResult.d.ts +19 -0
- package/dist/types/lib/peer/media/sender/senderBWE.d.ts +32 -0
- package/dist/types/lib/peer/media/stats.d.ts +293 -0
- package/dist/types/lib/peer/media/track.d.ts +67 -0
- package/dist/types/lib/peer/peerConnection.d.ts +458 -0
- package/dist/types/lib/peer/sctpManager.d.ts +28 -0
- package/dist/types/lib/peer/sdp.d.ts +97 -0
- package/dist/types/lib/peer/sdpManager.d.ts +116 -0
- package/dist/types/lib/peer/secureTransportManager.d.ts +96 -0
- package/dist/types/lib/peer/transceiverManager.d.ts +151 -0
- package/dist/types/lib/peer/transport/dtls.d.ts +95 -0
- package/dist/types/lib/peer/transport/ice.d.ts +143 -0
- package/dist/types/lib/peer/transport/sctp.d.ts +56 -0
- package/dist/types/lib/peer/types/domain.d.ts +5 -0
- package/dist/types/lib/peer/types/util.d.ts +2 -0
- package/dist/types/lib/peer/utils.d.ts +73 -0
- package/dist/types/lib/rtp/codec/av1.d.ts +56 -0
- package/dist/types/lib/rtp/codec/base.d.ts +8 -0
- package/dist/types/lib/rtp/codec/h264.d.ts +32 -0
- package/dist/types/lib/rtp/codec/index.d.ts +16 -0
- package/dist/types/lib/rtp/codec/leb128.d.ts +5 -0
- package/dist/types/lib/rtp/codec/opus.d.ts +9 -0
- package/dist/types/lib/rtp/codec/vp8.d.ts +27 -0
- package/dist/types/lib/rtp/codec/vp9.d.ts +46 -0
- package/dist/types/lib/rtp/const.d.ts +1 -0
- package/dist/types/lib/rtp/helper.d.ts +8 -0
- package/dist/types/lib/rtp/imports/common.d.ts +1 -0
- package/dist/types/lib/rtp/index.d.ts +25 -0
- package/dist/types/lib/rtp/rtcp/header.d.ts +13 -0
- package/dist/types/lib/rtp/rtcp/psfb/fullIntraRequest.d.ts +16 -0
- package/dist/types/lib/rtp/rtcp/psfb/index.d.ts +14 -0
- package/dist/types/lib/rtp/rtcp/psfb/pictureLossIndication.d.ts +10 -0
- package/dist/types/lib/rtp/rtcp/psfb/remb.d.ts +16 -0
- package/dist/types/lib/rtp/rtcp/rr.d.ts +32 -0
- package/dist/types/lib/rtp/rtcp/rtcp.d.ts +10 -0
- package/dist/types/lib/rtp/rtcp/rtpfb/const.d.ts +1 -0
- package/dist/types/lib/rtp/rtcp/rtpfb/index.d.ts +14 -0
- package/dist/types/lib/rtp/rtcp/rtpfb/nack.d.ts +17 -0
- package/dist/types/lib/rtp/rtcp/rtpfb/twcc.d.ts +71 -0
- package/dist/types/lib/rtp/rtcp/sdes.d.ts +26 -0
- package/dist/types/lib/rtp/rtcp/sr.d.ts +41 -0
- package/dist/types/lib/rtp/rtp/headerExtension.d.ts +72 -0
- package/dist/types/lib/rtp/rtp/red/encoder.d.ts +13 -0
- package/dist/types/lib/rtp/rtp/red/handler.d.ts +6 -0
- package/dist/types/lib/rtp/rtp/red/packet.d.ts +26 -0
- package/dist/types/lib/rtp/rtp/rtp.d.ts +44 -0
- package/dist/types/lib/rtp/rtp/rtx.d.ts +3 -0
- package/dist/types/lib/rtp/srtp/cipher/ctr.d.ts +16 -0
- package/dist/types/lib/rtp/srtp/cipher/gcm.d.ts +17 -0
- package/dist/types/lib/rtp/srtp/cipher/index.d.ts +13 -0
- package/dist/types/lib/rtp/srtp/const.d.ts +6 -0
- package/dist/types/lib/rtp/srtp/context/context.d.ts +45 -0
- package/dist/types/lib/rtp/srtp/context/srtcp.d.ts +8 -0
- package/dist/types/lib/rtp/srtp/context/srtp.d.ts +9 -0
- package/dist/types/lib/rtp/srtp/error.d.ts +3 -0
- package/dist/types/lib/rtp/srtp/packet.d.ts +5 -0
- package/dist/types/lib/rtp/srtp/session.d.ts +19 -0
- package/dist/types/lib/rtp/srtp/srtcp.d.ts +8 -0
- package/dist/types/lib/rtp/srtp/srtp.d.ts +9 -0
- package/dist/types/lib/rtp/transport.d.ts +15 -0
- package/dist/types/lib/rtp/util.d.ts +11 -0
- package/dist/types/lib/sctp/chunk.d.ts +164 -0
- package/dist/types/lib/sctp/const.d.ts +17 -0
- package/dist/types/lib/sctp/helper.d.ts +5 -0
- package/dist/types/lib/sctp/imports/common.d.ts +1 -0
- package/dist/types/lib/sctp/index.d.ts +6 -0
- package/dist/types/lib/sctp/param.d.ts +40 -0
- package/dist/types/lib/sctp/sctp.d.ts +210 -0
- package/dist/types/lib/sctp/transport.d.ts +15 -0
- package/dist/types/lib/turn/index.d.ts +9 -0
- package/dist/types/lib/turn/node/server.d.ts +21 -0
- package/dist/types/lib/turn/node/turnServer.d.ts +91 -0
- package/dist/types/lib/turn/protocol.d.ts +47 -0
- package/dist/types/lib/turn/stun/attributes.d.ts +37 -0
- package/dist/types/lib/turn/stun/const.d.ts +28 -0
- package/dist/types/lib/turn/stun/ip.d.ts +12 -0
- package/dist/types/lib/turn/stun/message.d.ts +37 -0
- package/dist/types/lib/turn/turn/auth.d.ts +1 -0
- package/dist/types/lib/turn/turn/frame.d.ts +13 -0
- package/dist/types/lib/turn/turn/protocol.d.ts +147 -0
- package/dist/types/peer/Endpoints.d.ts +75 -0
- package/dist/types/peer/EngineConfig.d.ts +20 -0
- package/dist/types/peer/EngineConnection.d.ts +22 -0
- package/dist/types/peer/Events.d.ts +55 -0
- package/dist/types/peer/MediaCodecs.d.ts +27 -0
- package/dist/types/peer/MediaTrack.d.ts +212 -0
- package/dist/types/peer/PeerChannel.d.ts +248 -0
- package/dist/types/peer/PeerConnection.d.ts +603 -0
- package/dist/types/peer/PeerThreadChannel.d.ts +112 -0
- package/dist/types/peer/PeerThreadProtocol.d.ts +325 -0
- package/dist/types/peer/PeerThreads.d.ts +114 -0
- package/dist/types/peer/PeerWorker.d.ts +6 -0
- package/dist/types/peer/PeerWorkerCode.d.ts +5 -0
- package/dist/types/peer/RemoteConnection.d.ts +314 -0
- package/dist/types/peer/RtpPacket.d.ts +112 -0
- package/dist/types/peer/RtpTransceiver.d.ts +167 -0
- package/dist/types/peer/SignalingClient.d.ts +236 -0
- package/dist/types/protocol/SignalingProtocol.d.ts +266 -0
- package/dist/types/service/WebRTCServiceEntrypoint.d.ts +158 -0
- package/dist/types/sfu/SFU.d.ts +356 -0
- package/dist/types/sfu/SFUAccess.d.ts +48 -0
- package/dist/types/sfu/SFUClusterLeg.d.ts +101 -0
- package/dist/types/sfu/SFURoom.d.ts +148 -0
- package/dist/types/sfu/SFUWorker.d.ts +13 -0
- package/dist/types/sfu/SFUWorkerChannel.d.ts +204 -0
- package/dist/types/sfu/SFUWorkerCode.d.ts +5 -0
- package/dist/types/sfu/SFUWorkers.d.ts +247 -0
- package/dist/types/shared/ChunkedChannel.d.ts +122 -0
- package/dist/types/shared/Connections.d.ts +231 -0
- package/dist/types/shared/Emitter.d.ts +50 -0
- package/dist/types/shared/Peer.d.ts +182 -0
- package/dist/types/shared/PeerServiceProxy.d.ts +173 -0
- package/dist/types/shared/Room.d.ts +143 -0
- package/dist/types/shared/SignalingError.d.ts +40 -0
- package/dist/types/shared/SignalingSession.d.ts +97 -0
- package/dist/types/shared/Transports.d.ts +139 -0
- package/dist/types/signaling/MediaServers.d.ts +40 -0
- package/dist/types/signaling/Signaling.d.ts +573 -0
- package/dist/types/signaling/SignalingController.d.ts +128 -0
- package/dist/types/turn/TURNCredentials.d.ts +49 -0
- package/dist/types/turn/TURNIceServers.d.ts +11 -0
- package/dist/types/turn/TURNServer.d.ts +309 -0
- package/dist/types/turn/TURNWorker.d.ts +42 -0
- package/dist/types/turn/TURNWorkerCode.d.ts +5 -0
- package/dist/types/turn/TURNWorkers.d.ts +52 -0
- package/dist/types/whep/WHEP.d.ts +386 -0
- package/dist/types/whep/WHEPController.d.ts +134 -0
- package/dist/types/whip/WHIP.d.ts +426 -0
- package/dist/types/whip/WHIPController.d.ts +132 -0
- package/package.json +115 -4
|
@@ -0,0 +1,1467 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RTCSctpCapabilities = exports.InboundStream = exports.SCTP = exports.DEFAULT_SCTP_MTU = void 0;
|
|
4
|
+
exports.maxPayloadSizeForMtu = maxPayloadSizeForMtu;
|
|
5
|
+
exports.validateSctpMtu = validateSctpMtu;
|
|
6
|
+
const node_crypto_1 = require("node:crypto");
|
|
7
|
+
const chunk_js_1 = require("./chunk.js");
|
|
8
|
+
const const_js_1 = require("./const.js");
|
|
9
|
+
const helper_js_1 = require("./helper.js");
|
|
10
|
+
const common_js_1 = require("./imports/common.js");
|
|
11
|
+
const param_js_1 = require("./param.js");
|
|
12
|
+
const log = (0, common_js_1.debug)('webrtc/sctp/sctp');
|
|
13
|
+
// SSN: Stream Sequence Number
|
|
14
|
+
// # local constants
|
|
15
|
+
const COOKIE_LENGTH = 24;
|
|
16
|
+
const COOKIE_LIFETIME = 60;
|
|
17
|
+
const MAX_STREAMS = 65535;
|
|
18
|
+
exports.DEFAULT_SCTP_MTU = 1191;
|
|
19
|
+
function maxPayloadSizeForMtu(mtu, dataChunkHeaderSize = chunk_js_1.SCTP_DATA_CHUNK_HEADER_SIZE) {
|
|
20
|
+
const headerSize = chunk_js_1.SCTP_COMMON_HEADER_SIZE + dataChunkHeaderSize;
|
|
21
|
+
if (mtu <= headerSize)
|
|
22
|
+
return 0;
|
|
23
|
+
const payloadBudget = mtu - headerSize;
|
|
24
|
+
return payloadBudget - (payloadBudget % chunk_js_1.SCTP_PADDING_MULTIPLE);
|
|
25
|
+
}
|
|
26
|
+
function validateSctpMtu(mtu) {
|
|
27
|
+
if (!Number.isSafeInteger(mtu) || mtu <= 0) {
|
|
28
|
+
throw new Error('SCTP MTU must be a positive integer');
|
|
29
|
+
}
|
|
30
|
+
if (maxPayloadSizeForMtu(mtu) === 0) {
|
|
31
|
+
throw new Error('SCTP MTU is too small for a DATA chunk');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// # protocol constants
|
|
35
|
+
const SCTP_DATA_LAST_FRAG = 0x01;
|
|
36
|
+
const SCTP_DATA_FIRST_FRAG = 0x02;
|
|
37
|
+
const SCTP_DATA_UNORDERED = 0x04;
|
|
38
|
+
const SCTP_MAX_ASSOCIATION_RETRANS = 10;
|
|
39
|
+
const SCTP_MAX_INIT_RETRANS = 8;
|
|
40
|
+
const SCTP_INITIAL_CWND_PACKETS = 10;
|
|
41
|
+
// RFC 9260 section 7.2.1: in slow start cwnd grows by at most L * MTU per SACK; with a SACK for every second packet,
|
|
42
|
+
// L = 2 keeps the growth of one MTU per packet acknowledged (as appropriate byte counting, RFC 3465)
|
|
43
|
+
const SCTP_SLOW_START_L = 2;
|
|
44
|
+
const SCTP_RTO_ALPHA = 1 / 8;
|
|
45
|
+
const SCTP_RTO_BETA = 1 / 4;
|
|
46
|
+
// RFC 9260 RTO.Initial/RTO.Min/RTO.Max defaults and bounds are in seconds.
|
|
47
|
+
const SCTP_RTO_INITIAL = 3;
|
|
48
|
+
const SCTP_RTO_MIN = 1;
|
|
49
|
+
const SCTP_RTO_MAX = 60;
|
|
50
|
+
const SCTP_TSN_MODULO = 2 ** 32;
|
|
51
|
+
// RFC 9260 delayed ACK guidance: a SACK for every second packet, and within 200ms at the latest. A shorter delay keeps
|
|
52
|
+
// the request/response latency low; a SACK also goes with the next DATA sent (bundling)
|
|
53
|
+
const SCTP_SACK_DELAY_MS = 20;
|
|
54
|
+
//The chunks waiting in the reassembly at most: beyond them (or without window left), the chunks past the highest TSN
|
|
55
|
+
//received are dropped, so a peer ignoring the window cannot grow the memory without bound (RFC 9260 section 6.2)
|
|
56
|
+
const SCTP_MAX_PENDING_CHUNKS = 4096;
|
|
57
|
+
// RFC 9260 HB.interval recommended default is 30 seconds.
|
|
58
|
+
const SCTP_HEARTBEAT_INTERVAL = 30;
|
|
59
|
+
const RECONFIG_MAX_STREAMS = 135;
|
|
60
|
+
// # parameters
|
|
61
|
+
const SCTP_STATE_COOKIE = 0x0007;
|
|
62
|
+
const SCTP_SUPPORTED_CHUNK_EXT = 0x8008; //32778
|
|
63
|
+
const SCTP_PRSCTP_SUPPORTED = 0xc000; //49152
|
|
64
|
+
const SCTPConnectionStates = [
|
|
65
|
+
'new',
|
|
66
|
+
'closed',
|
|
67
|
+
'connected',
|
|
68
|
+
'connecting'
|
|
69
|
+
];
|
|
70
|
+
class SCTP {
|
|
71
|
+
get peerRwnd() {
|
|
72
|
+
// RFC 9260 §6.2.1(D-ii): available receiver window = a_rwnd - outstanding DATA.
|
|
73
|
+
return Math.max(0, this.peerAdvertisedRwnd - this.flightSize);
|
|
74
|
+
}
|
|
75
|
+
constructor(transport, port = 5000, options = {}) {
|
|
76
|
+
this.transport = transport;
|
|
77
|
+
this.port = port;
|
|
78
|
+
this.flush = new common_js_1.Event();
|
|
79
|
+
this.stateChanged = (0, helper_js_1.createEventsFromList)(SCTPConnectionStates);
|
|
80
|
+
this.onReconfigStreams = new common_js_1.Event();
|
|
81
|
+
/**streamId: number, ppId: number, data: Buffer */
|
|
82
|
+
this.onReceive = new common_js_1.Event();
|
|
83
|
+
this.onSackReceived = async () => { };
|
|
84
|
+
this.associationState = const_js_1.SCTP_STATE.CLOSED;
|
|
85
|
+
this.started = false;
|
|
86
|
+
this.state = 'new';
|
|
87
|
+
this.isServer = true;
|
|
88
|
+
this.isStopping = false;
|
|
89
|
+
this.isClosed = false;
|
|
90
|
+
this.hmacKey = (0, node_crypto_1.randomBytes)(16);
|
|
91
|
+
this.localPartialReliability = true;
|
|
92
|
+
this.localVerificationTag = (0, common_js_1.random32)();
|
|
93
|
+
this.remoteExtensions = [];
|
|
94
|
+
this.remotePartialReliability = true;
|
|
95
|
+
this.remoteVerificationTag = 0;
|
|
96
|
+
// inbound
|
|
97
|
+
this.advertisedRwnd = 1024 * 1024; // Receiver Window
|
|
98
|
+
//The window told in the last SACK: a window the application opens again is told at once when it was nearly closed
|
|
99
|
+
this.lastAdvertisedRwnd = this.advertisedRwnd;
|
|
100
|
+
this.peerAdvertisedRwnd = this.advertisedRwnd;
|
|
101
|
+
this.inboundStreams = {};
|
|
102
|
+
this._inboundStreamsCount = 0;
|
|
103
|
+
this._inboundStreamsMax = MAX_STREAMS;
|
|
104
|
+
this.pendingChunks = 0;
|
|
105
|
+
this.sackDuplicates = [];
|
|
106
|
+
this.sackMisOrdered = new Set();
|
|
107
|
+
this.sackNeeded = false;
|
|
108
|
+
this.sackPacketCount = 0;
|
|
109
|
+
this.sackHasNewDataInPacket = false;
|
|
110
|
+
this.sackImmediate = false;
|
|
111
|
+
this.fastRecoveryTransmit = false;
|
|
112
|
+
this.flightSize = 0;
|
|
113
|
+
this.outboundQueue = new common_js_1.Deque();
|
|
114
|
+
this.outboundStreamSeq = {};
|
|
115
|
+
this._outboundStreamsCount = MAX_STREAMS;
|
|
116
|
+
/**local transmission sequence number */
|
|
117
|
+
this.localTsn = Number((0, common_js_1.random32)());
|
|
118
|
+
this.lastSackedTsn = tsnMinusOne(this.localTsn);
|
|
119
|
+
this.advancedPeerAckTsn = tsnMinusOne(this.localTsn); // acknowledgement
|
|
120
|
+
this.partialBytesAcked = 0;
|
|
121
|
+
this.sentQueue = new common_js_1.Deque();
|
|
122
|
+
/**some chunks of the sent queue are marked for retransmission: the queue is only walked then */
|
|
123
|
+
this.retransmitPending = false;
|
|
124
|
+
this.transmitting = false;
|
|
125
|
+
this.transmitRequested = false;
|
|
126
|
+
//A transmission at the end of the current task (the messages sent meanwhile bundled)
|
|
127
|
+
this.transmitScheduled = false;
|
|
128
|
+
// # reconfiguration
|
|
129
|
+
/**初期TSNと同じ値に初期化される単調に増加する数です. これは、新しいre-configuration requestパラメーターを送信するたびに1ずつ増加します */
|
|
130
|
+
this.reconfigRequestSeq = this.localTsn;
|
|
131
|
+
/**このフィールドは、incoming要求のre-configuration requestシーケンス番号を保持します. 他の場合では、次に予想されるre-configuration requestシーケンス番号から1を引いた値が保持されます */
|
|
132
|
+
this.reconfigResponseSeq = 0;
|
|
133
|
+
this.reconfigQueue = [];
|
|
134
|
+
// timers
|
|
135
|
+
this.rto = SCTP_RTO_INITIAL;
|
|
136
|
+
this.timer1Failures = 0;
|
|
137
|
+
this.timer2Failures = 0;
|
|
138
|
+
this.timerReconfigFailures = 0;
|
|
139
|
+
this.heartbeatInterval = SCTP_HEARTBEAT_INTERVAL;
|
|
140
|
+
this.send = async (streamId, ppId, userData, { expiry, maxRetransmits, ordered } = { expiry: undefined, maxRetransmits: undefined, ordered: true }) => {
|
|
141
|
+
const streamSeqNum = ordered ? this.outboundStreamSeq[streamId] || 0 : 0;
|
|
142
|
+
const fragments = Math.ceil(userData.length / this.maxPayloadSize);
|
|
143
|
+
let pos = 0;
|
|
144
|
+
const chunks = [];
|
|
145
|
+
for (let fragment = 0; fragment < fragments; fragment++) {
|
|
146
|
+
const chunk = new chunk_js_1.DataChunk(0, undefined);
|
|
147
|
+
chunk.flags = 0;
|
|
148
|
+
if (!ordered) {
|
|
149
|
+
chunk.flags = SCTP_DATA_UNORDERED;
|
|
150
|
+
}
|
|
151
|
+
if (fragment === 0) {
|
|
152
|
+
chunk.flags |= SCTP_DATA_FIRST_FRAG;
|
|
153
|
+
}
|
|
154
|
+
if (fragment === fragments - 1) {
|
|
155
|
+
chunk.flags |= SCTP_DATA_LAST_FRAG;
|
|
156
|
+
}
|
|
157
|
+
chunk.tsn = this.localTsn;
|
|
158
|
+
chunk.streamId = streamId;
|
|
159
|
+
chunk.streamSeqNum = streamSeqNum;
|
|
160
|
+
chunk.protocol = ppId;
|
|
161
|
+
chunk.userData = userData.subarray(pos, pos + this.maxPayloadSize);
|
|
162
|
+
chunk.bookSize = chunk.userData.length;
|
|
163
|
+
chunk.expiry = expiry;
|
|
164
|
+
chunk.maxRetransmits = maxRetransmits;
|
|
165
|
+
pos += this.maxPayloadSize;
|
|
166
|
+
this.localTsn = tsnPlusOne(this.localTsn);
|
|
167
|
+
chunks.push(chunk);
|
|
168
|
+
}
|
|
169
|
+
for (const chunk of chunks) {
|
|
170
|
+
this.outboundQueue.push(chunk);
|
|
171
|
+
}
|
|
172
|
+
if (ordered) {
|
|
173
|
+
this.outboundStreamSeq[streamId] = (0, common_js_1.uint16Add)(streamSeqNum, 1);
|
|
174
|
+
}
|
|
175
|
+
//The chunks wait in the queue for the congestion and receive windows; onSent tells when they leave it. They go
|
|
176
|
+
//at the end of the task: the messages sent together are bundled in the same packets
|
|
177
|
+
this.transmitSoon();
|
|
178
|
+
};
|
|
179
|
+
this.timer1Expired = () => {
|
|
180
|
+
if (this.isStopped)
|
|
181
|
+
return;
|
|
182
|
+
this.timer1Failures++;
|
|
183
|
+
this.timer1Handle = undefined;
|
|
184
|
+
if (this.timer1Failures > SCTP_MAX_INIT_RETRANS) {
|
|
185
|
+
this.setState(const_js_1.SCTP_STATE.CLOSED);
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
setImmediate(() => {
|
|
189
|
+
if (this.isStopped)
|
|
190
|
+
return;
|
|
191
|
+
this.sendChunk(this.timer1Chunk).catch((err) => {
|
|
192
|
+
log('send timer1 chunk failed', err.message);
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
if (this.isStopped)
|
|
196
|
+
return;
|
|
197
|
+
this.timer1Handle = setTimeout(this.timer1Expired, this.rto * 1000);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
this.timer2Expired = () => {
|
|
201
|
+
if (this.isStopped)
|
|
202
|
+
return;
|
|
203
|
+
this.timer2Failures++;
|
|
204
|
+
this.timer2Handle = undefined;
|
|
205
|
+
if (this.timer2Failures > SCTP_MAX_ASSOCIATION_RETRANS) {
|
|
206
|
+
this.setState(const_js_1.SCTP_STATE.CLOSED);
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
setImmediate(() => {
|
|
210
|
+
if (this.isStopped)
|
|
211
|
+
return;
|
|
212
|
+
this.sendChunk(this.timer2Chunk).catch((err) => {
|
|
213
|
+
log('send timer2Chunk failed', err.message);
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
if (this.isStopped)
|
|
217
|
+
return;
|
|
218
|
+
this.timer2Handle = setTimeout(this.timer2Expired, this.rto * 1000);
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
this.timer3Expired = () => {
|
|
222
|
+
if (this.isStopped)
|
|
223
|
+
return;
|
|
224
|
+
this.timer3Handle = undefined;
|
|
225
|
+
// # mark retransmit or abandoned chunks
|
|
226
|
+
for (const chunk of this.sentQueue) {
|
|
227
|
+
if (!this.maybeAbandon(chunk)) {
|
|
228
|
+
chunk.retransmit = true;
|
|
229
|
+
this.retransmitPending = true;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
this.updateAdvancedPeerAckPoint();
|
|
233
|
+
// # adjust congestion window
|
|
234
|
+
this.fastRecoveryExit = undefined;
|
|
235
|
+
this.flightSize = 0;
|
|
236
|
+
this.partialBytesAcked = 0;
|
|
237
|
+
this.ssthresh = Math.max(Math.floor(this.cwnd / 2), 4 * this.maxPayloadSize);
|
|
238
|
+
this.cwnd = this.maxPayloadSize;
|
|
239
|
+
this.transmit().catch((error) => log('transmit failed', error));
|
|
240
|
+
};
|
|
241
|
+
this.timerReconfigHandleExpired = async () => {
|
|
242
|
+
if (this.isStopped)
|
|
243
|
+
return;
|
|
244
|
+
this.timerReconfigFailures++;
|
|
245
|
+
// back off
|
|
246
|
+
this.rto = Math.ceil(this.rto * 1.5);
|
|
247
|
+
if (this.timerReconfigFailures > SCTP_MAX_ASSOCIATION_RETRANS) {
|
|
248
|
+
log('timerReconfigFailures', this.timerReconfigFailures);
|
|
249
|
+
this.setState(const_js_1.SCTP_STATE.CLOSED);
|
|
250
|
+
this.timerReconfigHandle = undefined;
|
|
251
|
+
}
|
|
252
|
+
else if (this.reconfigRequest) {
|
|
253
|
+
log('timerReconfigHandleExpired', this.timerReconfigFailures, this.rto);
|
|
254
|
+
await this.sendReconfigParam(this.reconfigRequest);
|
|
255
|
+
if (this.isStopped)
|
|
256
|
+
return;
|
|
257
|
+
this.timerReconfigHandle = setTimeout((0, common_js_1.detached)(this.timerReconfigHandleExpired, (error) => log('reconfig timer failed', error)), this.rto * 1000);
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
this.timerHeartbeatExpired = async () => {
|
|
261
|
+
this.timerHeartbeatHandle = undefined;
|
|
262
|
+
if (this.associationState !== const_js_1.SCTP_STATE.ESTABLISHED)
|
|
263
|
+
return;
|
|
264
|
+
if (this.flightSize === 0 && this.outboundQueue.length === 0) {
|
|
265
|
+
const heartbeat = new chunk_js_1.HeartbeatChunk();
|
|
266
|
+
const heartbeatTime = Buffer.allocUnsafe(4);
|
|
267
|
+
heartbeatTime.writeUInt32BE(Math.floor(Date.now() / 1000), 0);
|
|
268
|
+
heartbeat.params.push([1, heartbeatTime]);
|
|
269
|
+
await this.sendChunk(heartbeat).catch((err) => {
|
|
270
|
+
log('send heartbeat failed', err.message);
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
this.heartbeatStart();
|
|
274
|
+
};
|
|
275
|
+
this.mtu = options.mtu ?? exports.DEFAULT_SCTP_MTU;
|
|
276
|
+
validateSctpMtu(this.mtu);
|
|
277
|
+
this.maxPayloadSize = maxPayloadSizeForMtu(this.mtu);
|
|
278
|
+
//The initial congestion window of dcsctp (Chrome): 10 packets, as TCP's initial window (RFC 6928)
|
|
279
|
+
this.cwnd = SCTP_INITIAL_CWND_PACKETS * this.maxPayloadSize;
|
|
280
|
+
this.localPort = this.port;
|
|
281
|
+
this.transport.onData = (buf) => {
|
|
282
|
+
this.handleData(buf).catch((error) => log('receive failed', error));
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
get isStopped() {
|
|
286
|
+
return this.isStopping || this.isClosed;
|
|
287
|
+
}
|
|
288
|
+
get maxChannels() {
|
|
289
|
+
if (this._inboundStreamsCount > 0) {
|
|
290
|
+
return Math.min(this._inboundStreamsCount, this._outboundStreamsCount);
|
|
291
|
+
}
|
|
292
|
+
return undefined;
|
|
293
|
+
}
|
|
294
|
+
static client(transport, port = 5000, options = {}) {
|
|
295
|
+
const sctp = new SCTP(transport, port, options);
|
|
296
|
+
sctp.isServer = false;
|
|
297
|
+
return sctp;
|
|
298
|
+
}
|
|
299
|
+
static server(transport, port = 5000, options = {}) {
|
|
300
|
+
const sctp = new SCTP(transport, port, options);
|
|
301
|
+
sctp.isServer = true;
|
|
302
|
+
return sctp;
|
|
303
|
+
}
|
|
304
|
+
// call from dtls transport
|
|
305
|
+
async handleData(data) {
|
|
306
|
+
if (this.isStopped)
|
|
307
|
+
return;
|
|
308
|
+
let expectedTag;
|
|
309
|
+
const [, , verificationTag, chunks] = (0, chunk_js_1.parsePacket)(data);
|
|
310
|
+
const initChunk = chunks.filter((v) => v.type === chunk_js_1.InitChunk.type).length;
|
|
311
|
+
if (initChunk > 0) {
|
|
312
|
+
if (chunks.length != 1) {
|
|
313
|
+
throw new Error();
|
|
314
|
+
}
|
|
315
|
+
expectedTag = 0;
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
expectedTag = this.localVerificationTag;
|
|
319
|
+
}
|
|
320
|
+
if (verificationTag !== expectedTag) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
this.sackHasNewDataInPacket = false;
|
|
324
|
+
for (const chunk of chunks) {
|
|
325
|
+
if (chunk.type === chunk_js_1.DataChunk.type)
|
|
326
|
+
this.receiveDataChunk(chunk);
|
|
327
|
+
else
|
|
328
|
+
await this.receiveChunk(chunk);
|
|
329
|
+
}
|
|
330
|
+
if (this.sackNeeded) {
|
|
331
|
+
// RFC 9260 delayed ACK guidance is per packet ("every second packet").
|
|
332
|
+
if (this.sackHasNewDataInPacket) {
|
|
333
|
+
this.sackPacketCount++;
|
|
334
|
+
}
|
|
335
|
+
if (this.sackPacketCount >= 2) {
|
|
336
|
+
this.sackImmediate = true;
|
|
337
|
+
}
|
|
338
|
+
await this.scheduleSack();
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
async scheduleSack() {
|
|
342
|
+
if (this.isStopped)
|
|
343
|
+
return;
|
|
344
|
+
if (!this.sackNeeded)
|
|
345
|
+
return;
|
|
346
|
+
if (this.sackImmediate) {
|
|
347
|
+
if (this.sackTimeout) {
|
|
348
|
+
clearTimeout(this.sackTimeout);
|
|
349
|
+
this.sackTimeout = undefined;
|
|
350
|
+
}
|
|
351
|
+
await this.sendSack();
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
if (this.sackTimeout)
|
|
355
|
+
return;
|
|
356
|
+
// RFC 9260 delayed ACK path: defer SACK, but never beyond 200ms.
|
|
357
|
+
this.sackTimeout = setTimeout(() => {
|
|
358
|
+
this.sackTimeout = undefined;
|
|
359
|
+
this.sendSack().catch((err) => {
|
|
360
|
+
log('send delayed sack failed', err.message);
|
|
361
|
+
});
|
|
362
|
+
}, SCTP_SACK_DELAY_MS);
|
|
363
|
+
}
|
|
364
|
+
async sendSack() {
|
|
365
|
+
if (this.isStopped)
|
|
366
|
+
return;
|
|
367
|
+
if (!this.sackNeeded)
|
|
368
|
+
return;
|
|
369
|
+
await this.sendChunk(this.takeSack()).catch((err) => {
|
|
370
|
+
log('send sack failed', err.message);
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
/**The SACK of what was received so far; the state of the pending SACK is reset, its timer cancelled */
|
|
374
|
+
takeSack() {
|
|
375
|
+
const gaps = [];
|
|
376
|
+
let gapNext;
|
|
377
|
+
//The TSNs received out of order, by distance from the cumulative TSN (it can wrap around)
|
|
378
|
+
const misOrdered = [...this.sackMisOrdered].sort((a, b) => ((a - this.lastReceivedTsn + SCTP_TSN_MODULO) % SCTP_TSN_MODULO) -
|
|
379
|
+
((b - this.lastReceivedTsn + SCTP_TSN_MODULO) % SCTP_TSN_MODULO));
|
|
380
|
+
for (const tsn of misOrdered) {
|
|
381
|
+
const pos = (tsn - this.lastReceivedTsn + SCTP_TSN_MODULO) % SCTP_TSN_MODULO;
|
|
382
|
+
if (tsn === gapNext) {
|
|
383
|
+
gaps[gaps.length - 1][1] = pos;
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
gaps.push([pos, pos]);
|
|
387
|
+
}
|
|
388
|
+
gapNext = tsnPlusOne(tsn);
|
|
389
|
+
}
|
|
390
|
+
const sack = new chunk_js_1.SackChunk(0, undefined);
|
|
391
|
+
sack.cumulativeTsn = this.lastReceivedTsn;
|
|
392
|
+
sack.advertisedRwnd = Math.max(0, this.advertisedRwnd);
|
|
393
|
+
this.lastAdvertisedRwnd = sack.advertisedRwnd;
|
|
394
|
+
sack.duplicates = [...this.sackDuplicates];
|
|
395
|
+
sack.gaps = gaps;
|
|
396
|
+
this.sackDuplicates = [];
|
|
397
|
+
this.sackNeeded = false;
|
|
398
|
+
this.sackPacketCount = 0;
|
|
399
|
+
this.sackImmediate = false;
|
|
400
|
+
if (this.sackTimeout) {
|
|
401
|
+
clearTimeout(this.sackTimeout);
|
|
402
|
+
this.sackTimeout = undefined;
|
|
403
|
+
}
|
|
404
|
+
return sack;
|
|
405
|
+
}
|
|
406
|
+
async receiveChunk(chunk) {
|
|
407
|
+
switch (chunk.type) {
|
|
408
|
+
case chunk_js_1.DataChunk.type:
|
|
409
|
+
{
|
|
410
|
+
this.receiveDataChunk(chunk);
|
|
411
|
+
}
|
|
412
|
+
break;
|
|
413
|
+
case chunk_js_1.InitChunk.type:
|
|
414
|
+
{
|
|
415
|
+
if (!this.isServer)
|
|
416
|
+
return;
|
|
417
|
+
const init = chunk;
|
|
418
|
+
log('receive init', init);
|
|
419
|
+
this.lastReceivedTsn = tsnMinusOne(init.initialTsn);
|
|
420
|
+
this.highestReceivedTsn = this.lastReceivedTsn;
|
|
421
|
+
this.reconfigResponseSeq = tsnMinusOne(init.initialTsn);
|
|
422
|
+
this.remoteVerificationTag = init.initiateTag;
|
|
423
|
+
this.ssthresh = init.advertisedRwnd;
|
|
424
|
+
this.peerAdvertisedRwnd = init.advertisedRwnd;
|
|
425
|
+
this.getExtensions(init.params);
|
|
426
|
+
this._inboundStreamsCount = Math.min(init.outboundStreams, this._inboundStreamsMax);
|
|
427
|
+
this._outboundStreamsCount = Math.min(this._outboundStreamsCount, init.inboundStreams);
|
|
428
|
+
const ack = new chunk_js_1.InitAckChunk();
|
|
429
|
+
ack.initiateTag = this.localVerificationTag;
|
|
430
|
+
ack.advertisedRwnd = this.advertisedRwnd;
|
|
431
|
+
ack.outboundStreams = this._outboundStreamsCount;
|
|
432
|
+
ack.inboundStreams = this._inboundStreamsCount;
|
|
433
|
+
ack.initialTsn = this.localTsn;
|
|
434
|
+
this.setExtensions(ack.params);
|
|
435
|
+
// cookie timestamp は秒単位の整数 (小数を混入させない)
|
|
436
|
+
const time = Math.floor(Date.now() / 1000);
|
|
437
|
+
const cookieTime = Buffer.allocUnsafe(4);
|
|
438
|
+
cookieTime.writeUInt32BE(time, 0);
|
|
439
|
+
let cookie = cookieTime;
|
|
440
|
+
cookie = Buffer.concat([
|
|
441
|
+
cookie,
|
|
442
|
+
(0, node_crypto_1.createHmac)('sha1', this.hmacKey).update(cookie).digest()
|
|
443
|
+
]);
|
|
444
|
+
ack.params.push([SCTP_STATE_COOKIE, cookie]);
|
|
445
|
+
log('send initAck', ack);
|
|
446
|
+
await this.sendChunk(ack).catch((err) => {
|
|
447
|
+
log('send initAck failed', err.message);
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
break;
|
|
451
|
+
case chunk_js_1.InitAckChunk.type:
|
|
452
|
+
{
|
|
453
|
+
if (this.associationState != const_js_1.SCTP_STATE.COOKIE_WAIT)
|
|
454
|
+
return;
|
|
455
|
+
const initAck = chunk;
|
|
456
|
+
this.timer1Cancel();
|
|
457
|
+
this.lastReceivedTsn = tsnMinusOne(initAck.initialTsn);
|
|
458
|
+
this.highestReceivedTsn = this.lastReceivedTsn;
|
|
459
|
+
this.reconfigResponseSeq = tsnMinusOne(initAck.initialTsn);
|
|
460
|
+
this.remoteVerificationTag = initAck.initiateTag;
|
|
461
|
+
this.ssthresh = initAck.advertisedRwnd;
|
|
462
|
+
this.peerAdvertisedRwnd = initAck.advertisedRwnd;
|
|
463
|
+
this.getExtensions(initAck.params);
|
|
464
|
+
this._inboundStreamsCount = Math.min(initAck.outboundStreams, this._inboundStreamsMax);
|
|
465
|
+
this._outboundStreamsCount = Math.min(this._outboundStreamsCount, initAck.inboundStreams);
|
|
466
|
+
const echo = new chunk_js_1.CookieEchoChunk();
|
|
467
|
+
for (const [k, v] of initAck.params) {
|
|
468
|
+
if (k === SCTP_STATE_COOKIE) {
|
|
469
|
+
echo.body = v;
|
|
470
|
+
break;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
await this.sendChunk(echo).catch((err) => {
|
|
474
|
+
log('send echo failed', err.message);
|
|
475
|
+
});
|
|
476
|
+
this.timer1Start(echo);
|
|
477
|
+
this.setState(const_js_1.SCTP_STATE.COOKIE_ECHOED);
|
|
478
|
+
}
|
|
479
|
+
break;
|
|
480
|
+
case chunk_js_1.SackChunk.type:
|
|
481
|
+
{
|
|
482
|
+
await this.receiveSackChunk(chunk);
|
|
483
|
+
}
|
|
484
|
+
break;
|
|
485
|
+
case chunk_js_1.HeartbeatChunk.type:
|
|
486
|
+
{
|
|
487
|
+
const ack = new chunk_js_1.HeartbeatAckChunk();
|
|
488
|
+
ack.params = chunk.params;
|
|
489
|
+
await this.sendChunk(ack).catch((err) => {
|
|
490
|
+
log('send heartbeat ack failed', err.message);
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
break;
|
|
494
|
+
case chunk_js_1.AbortChunk.type:
|
|
495
|
+
{
|
|
496
|
+
this.setState(const_js_1.SCTP_STATE.CLOSED);
|
|
497
|
+
}
|
|
498
|
+
break;
|
|
499
|
+
case chunk_js_1.ShutdownChunk.type:
|
|
500
|
+
{
|
|
501
|
+
this.timer2Cancel();
|
|
502
|
+
this.setState(const_js_1.SCTP_STATE.SHUTDOWN_RECEIVED);
|
|
503
|
+
const ack = new chunk_js_1.ShutdownAckChunk();
|
|
504
|
+
await this.sendChunk(ack).catch((err) => {
|
|
505
|
+
log('send shutdown ack failed', err.message);
|
|
506
|
+
});
|
|
507
|
+
this.t2Start(ack);
|
|
508
|
+
this.setState(const_js_1.SCTP_STATE.SHUTDOWN_SENT);
|
|
509
|
+
}
|
|
510
|
+
break;
|
|
511
|
+
case chunk_js_1.ErrorChunk.type:
|
|
512
|
+
{
|
|
513
|
+
// 3.3.10. Operation Error (ERROR) (9)
|
|
514
|
+
// An Operation Error is not considered fatal in and of itself, but may be
|
|
515
|
+
// used with an ABORT chunk to report a fatal condition. It has the
|
|
516
|
+
// following parameters:
|
|
517
|
+
log('ErrorChunk', chunk.descriptions);
|
|
518
|
+
}
|
|
519
|
+
break;
|
|
520
|
+
case chunk_js_1.CookieEchoChunk.type:
|
|
521
|
+
{
|
|
522
|
+
if (!this.isServer)
|
|
523
|
+
return;
|
|
524
|
+
const data = chunk;
|
|
525
|
+
const cookie = data.body;
|
|
526
|
+
const digest = (0, node_crypto_1.createHmac)('sha1', this.hmacKey)
|
|
527
|
+
.update(cookie.slice(0, 4))
|
|
528
|
+
.digest();
|
|
529
|
+
if (cookie?.length != COOKIE_LENGTH ||
|
|
530
|
+
!cookie.slice(4).equals(digest)) {
|
|
531
|
+
log('x State cookie is invalid');
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
const now = Math.floor(Date.now() / 1000);
|
|
535
|
+
const stamp = cookie.readUInt32BE(0);
|
|
536
|
+
if (stamp < now - COOKIE_LIFETIME || stamp > now) {
|
|
537
|
+
const error = new chunk_js_1.ErrorChunk(0, undefined);
|
|
538
|
+
error.params.push([
|
|
539
|
+
chunk_js_1.ErrorChunk.CODE.StaleCookieError,
|
|
540
|
+
Buffer.concat([...Array(8)].map(() => Buffer.from('\x00')))
|
|
541
|
+
]);
|
|
542
|
+
await this.sendChunk(error).catch((err) => {
|
|
543
|
+
log('send errorChunk failed', err.message);
|
|
544
|
+
});
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
const ack = new chunk_js_1.CookieAckChunk();
|
|
548
|
+
await this.sendChunk(ack).catch((err) => {
|
|
549
|
+
log('send cookieAck failed', err.message);
|
|
550
|
+
});
|
|
551
|
+
this.setState(const_js_1.SCTP_STATE.ESTABLISHED);
|
|
552
|
+
}
|
|
553
|
+
break;
|
|
554
|
+
case chunk_js_1.CookieAckChunk.type:
|
|
555
|
+
{
|
|
556
|
+
if (this.associationState != const_js_1.SCTP_STATE.COOKIE_ECHOED)
|
|
557
|
+
return;
|
|
558
|
+
this.timer1Cancel();
|
|
559
|
+
this.setState(const_js_1.SCTP_STATE.ESTABLISHED);
|
|
560
|
+
}
|
|
561
|
+
break;
|
|
562
|
+
case chunk_js_1.ShutdownCompleteChunk.type:
|
|
563
|
+
{
|
|
564
|
+
if (this.associationState != const_js_1.SCTP_STATE.SHUTDOWN_ACK_SENT)
|
|
565
|
+
return;
|
|
566
|
+
this.timer2Cancel();
|
|
567
|
+
this.setState(const_js_1.SCTP_STATE.CLOSED);
|
|
568
|
+
}
|
|
569
|
+
break;
|
|
570
|
+
// extensions
|
|
571
|
+
case chunk_js_1.ReconfigChunk.type:
|
|
572
|
+
{
|
|
573
|
+
if (this.associationState != const_js_1.SCTP_STATE.ESTABLISHED)
|
|
574
|
+
return;
|
|
575
|
+
const reconfig = chunk;
|
|
576
|
+
for (const [type, body] of reconfig.params) {
|
|
577
|
+
const target = param_js_1.RECONFIG_PARAM_BY_TYPES[type];
|
|
578
|
+
if (target) {
|
|
579
|
+
await this.receiveReconfigParam(target.parse(body));
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
break;
|
|
584
|
+
case chunk_js_1.ForwardTsnChunk.type:
|
|
585
|
+
{
|
|
586
|
+
this.receiveForwardTsnChunk(chunk);
|
|
587
|
+
}
|
|
588
|
+
break;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
getExtensions(params) {
|
|
592
|
+
for (const [k, v] of params) {
|
|
593
|
+
if (k === SCTP_PRSCTP_SUPPORTED) {
|
|
594
|
+
this.remotePartialReliability = true;
|
|
595
|
+
}
|
|
596
|
+
else if (k === SCTP_SUPPORTED_CHUNK_EXT) {
|
|
597
|
+
this.remoteExtensions = [...v];
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
async receiveReconfigParam(param) {
|
|
602
|
+
log('receiveReconfigParam', param_js_1.RECONFIG_PARAM_BY_TYPES[param.type]);
|
|
603
|
+
switch (param.type) {
|
|
604
|
+
case param_js_1.OutgoingSSNResetRequestParam.type:
|
|
605
|
+
{
|
|
606
|
+
const p = param;
|
|
607
|
+
// # send response
|
|
608
|
+
const response = new param_js_1.ReconfigResponseParam(p.requestSequence, param_js_1.reconfigResult.ReconfigResultSuccessPerformed);
|
|
609
|
+
this.reconfigResponseSeq = p.requestSequence;
|
|
610
|
+
await this.sendReconfigParam(response);
|
|
611
|
+
// # mark closed inbound streams
|
|
612
|
+
await Promise.all(p.streams.map(async (streamId) => {
|
|
613
|
+
//The chunks waiting in its reassembly are dropped: they give their room back
|
|
614
|
+
const inboundStream = this.inboundStreams[streamId];
|
|
615
|
+
if (inboundStream) {
|
|
616
|
+
this.pendingChunks -= inboundStream.reassembly.length;
|
|
617
|
+
this.advertisedRwnd += inboundStream.reassembly.reduce((size, chunk) => size + chunk.userData.length, 0);
|
|
618
|
+
}
|
|
619
|
+
delete this.inboundStreams[streamId];
|
|
620
|
+
if (this.outboundStreamSeq[streamId]) {
|
|
621
|
+
// Only add to reconfigQueue if not already present
|
|
622
|
+
if (!this.reconfigQueue.includes(streamId)) {
|
|
623
|
+
this.reconfigQueue.push(streamId);
|
|
624
|
+
}
|
|
625
|
+
// await this.sendResetRequest(streamId);
|
|
626
|
+
}
|
|
627
|
+
}));
|
|
628
|
+
await this.transmitReconfigRequest();
|
|
629
|
+
// # close data channel
|
|
630
|
+
this.onReconfigStreams.execute(p.streams);
|
|
631
|
+
}
|
|
632
|
+
break;
|
|
633
|
+
case param_js_1.ReconfigResponseParam.type:
|
|
634
|
+
{
|
|
635
|
+
const reset = param;
|
|
636
|
+
if (reset.result !== param_js_1.reconfigResult.ReconfigResultSuccessPerformed) {
|
|
637
|
+
log('OutgoingSSNResetRequestParam failed', Object.keys(param_js_1.reconfigResult).find((key) => param_js_1.reconfigResult[key] === reset.result));
|
|
638
|
+
}
|
|
639
|
+
else if (reset.responseSequence === this.reconfigRequest?.requestSequence) {
|
|
640
|
+
const streamIds = this.reconfigRequest.streams.map((streamId) => {
|
|
641
|
+
delete this.outboundStreamSeq[streamId];
|
|
642
|
+
return streamId;
|
|
643
|
+
});
|
|
644
|
+
this.onReconfigStreams.execute(streamIds);
|
|
645
|
+
this.reconfigRequest = undefined;
|
|
646
|
+
this.timerReconfigCancel();
|
|
647
|
+
// Reset RTO backoff on successful reconfiguration
|
|
648
|
+
this.rto = SCTP_RTO_INITIAL;
|
|
649
|
+
this.timerReconfigFailures = 0;
|
|
650
|
+
if (this.reconfigQueue.length > 0) {
|
|
651
|
+
await this.transmitReconfigRequest();
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
break;
|
|
656
|
+
case param_js_1.StreamAddOutgoingParam.type:
|
|
657
|
+
{
|
|
658
|
+
const add = param;
|
|
659
|
+
this._inboundStreamsCount += add.newStreams;
|
|
660
|
+
const res = new param_js_1.ReconfigResponseParam(add.requestSequence, 1);
|
|
661
|
+
this.reconfigResponseSeq = add.requestSequence;
|
|
662
|
+
await this.sendReconfigParam(res);
|
|
663
|
+
}
|
|
664
|
+
break;
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
receiveDataChunk(chunk) {
|
|
668
|
+
this.sackNeeded = true;
|
|
669
|
+
if ((this.advertisedRwnd <= 0 || this.pendingChunks >= SCTP_MAX_PENDING_CHUNKS) &&
|
|
670
|
+
(0, common_js_1.uint32Gt)(chunk.tsn, this.highestReceivedTsn)) {
|
|
671
|
+
//No room: dropped, the SACK tells the window (RFC 9260 section 6.2)
|
|
672
|
+
this.sackImmediate = true;
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
if (this.markReceived(chunk.tsn)) {
|
|
676
|
+
//A duplicate: SACK at once (RFC 9260 section 6.7)
|
|
677
|
+
this.sackImmediate = true;
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
this.sackHasNewDataInPacket = true;
|
|
681
|
+
if (this.sackMisOrdered.size > 0) {
|
|
682
|
+
// RFC 9260 permits immediate SACK on gap/loss indicators.
|
|
683
|
+
this.sackImmediate = true;
|
|
684
|
+
}
|
|
685
|
+
const inboundStream = this.getInboundStream(chunk.streamId);
|
|
686
|
+
//A whole message (one chunk) is delivered at once when nothing waits before it: unordered, or the next of its stream
|
|
687
|
+
if ((chunk.flags & (SCTP_DATA_FIRST_FRAG | SCTP_DATA_LAST_FRAG)) ===
|
|
688
|
+
(SCTP_DATA_FIRST_FRAG | SCTP_DATA_LAST_FRAG)) {
|
|
689
|
+
if (chunk.flags & SCTP_DATA_UNORDERED) {
|
|
690
|
+
this.receive(chunk.streamId, chunk.protocol, chunk.userData);
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
if (inboundStream.reassembly.length === 0 &&
|
|
694
|
+
chunk.streamSeqNum === inboundStream.streamSequenceNumber) {
|
|
695
|
+
inboundStream.streamSequenceNumber = (0, common_js_1.uint16Add)(inboundStream.streamSequenceNumber, 1);
|
|
696
|
+
this.receive(chunk.streamId, chunk.protocol, chunk.userData);
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
const pending = inboundStream.reassembly.length;
|
|
701
|
+
inboundStream.addChunk(chunk);
|
|
702
|
+
this.advertisedRwnd -= chunk.userData.length;
|
|
703
|
+
for (const message of inboundStream.popMessages()) {
|
|
704
|
+
this.advertisedRwnd += message[2].length;
|
|
705
|
+
this.receive(...message);
|
|
706
|
+
}
|
|
707
|
+
this.pendingChunks += inboundStream.reassembly.length - pending;
|
|
708
|
+
}
|
|
709
|
+
async receiveSackChunk(chunk) {
|
|
710
|
+
// """
|
|
711
|
+
// Handle a SACK chunk.
|
|
712
|
+
// """
|
|
713
|
+
if ((0, common_js_1.uint32Gt)(this.lastSackedTsn, chunk.cumulativeTsn))
|
|
714
|
+
return;
|
|
715
|
+
const receivedTime = Date.now() / 1000;
|
|
716
|
+
this.lastSackedTsn = chunk.cumulativeTsn;
|
|
717
|
+
const cwndFullyUtilized = this.flightSize >= this.cwnd;
|
|
718
|
+
let done = 0, doneBytes = 0;
|
|
719
|
+
// # handle acknowledged data
|
|
720
|
+
while (this.sentQueue.length > 0 &&
|
|
721
|
+
(0, common_js_1.uint32Gte)(this.lastSackedTsn, this.sentQueue.at(0).tsn)) {
|
|
722
|
+
const sChunk = this.sentQueue.shift();
|
|
723
|
+
done++;
|
|
724
|
+
if (!sChunk?.acked) {
|
|
725
|
+
doneBytes += sChunk.bookSize;
|
|
726
|
+
this.flightSizeDecrease(sChunk);
|
|
727
|
+
}
|
|
728
|
+
if (done === 1 && sChunk.sentCount === 1) {
|
|
729
|
+
this.updateRto(receivedTime - sChunk.sentTime);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
// # handle gap blocks
|
|
733
|
+
let loss = false;
|
|
734
|
+
if (chunk.gaps.length > 0) {
|
|
735
|
+
const seen = new Set();
|
|
736
|
+
let highestSeenTsn;
|
|
737
|
+
chunk.gaps.forEach((gap) => {
|
|
738
|
+
for (let pos = gap[0]; pos < gap[1] + 1; pos++) {
|
|
739
|
+
highestSeenTsn = (chunk.cumulativeTsn + pos) % SCTP_TSN_MODULO;
|
|
740
|
+
seen.add(highestSeenTsn);
|
|
741
|
+
}
|
|
742
|
+
});
|
|
743
|
+
let highestNewlyAcked = chunk.cumulativeTsn;
|
|
744
|
+
for (const sChunk of this.sentQueue) {
|
|
745
|
+
if ((0, common_js_1.uint32Gt)(sChunk.tsn, highestSeenTsn)) {
|
|
746
|
+
break;
|
|
747
|
+
}
|
|
748
|
+
if (seen.has(sChunk.tsn) && !sChunk.acked) {
|
|
749
|
+
doneBytes += sChunk.bookSize;
|
|
750
|
+
sChunk.acked = true;
|
|
751
|
+
this.flightSizeDecrease(sChunk);
|
|
752
|
+
highestNewlyAcked = sChunk.tsn;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
// # strike missing chunks prior to HTNA
|
|
756
|
+
for (const sChunk of this.sentQueue) {
|
|
757
|
+
if ((0, common_js_1.uint32Gt)(sChunk.tsn, highestNewlyAcked)) {
|
|
758
|
+
break;
|
|
759
|
+
}
|
|
760
|
+
if (!seen.has(sChunk.tsn)) {
|
|
761
|
+
sChunk.misses++;
|
|
762
|
+
if (sChunk.misses === 3) {
|
|
763
|
+
sChunk.misses = 0;
|
|
764
|
+
if (!this.maybeAbandon(sChunk)) {
|
|
765
|
+
sChunk.retransmit = true;
|
|
766
|
+
this.retransmitPending = true;
|
|
767
|
+
}
|
|
768
|
+
sChunk.acked = false;
|
|
769
|
+
this.flightSizeDecrease(sChunk);
|
|
770
|
+
loss = true;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
// # adjust congestion window
|
|
776
|
+
if (this.fastRecoveryExit === undefined) {
|
|
777
|
+
if (done && cwndFullyUtilized) {
|
|
778
|
+
if (this.cwnd <= this.ssthresh) {
|
|
779
|
+
this.cwnd += Math.min(doneBytes, SCTP_SLOW_START_L * this.maxPayloadSize);
|
|
780
|
+
}
|
|
781
|
+
else {
|
|
782
|
+
this.partialBytesAcked += doneBytes;
|
|
783
|
+
if (this.partialBytesAcked >= this.cwnd) {
|
|
784
|
+
this.partialBytesAcked -= this.cwnd;
|
|
785
|
+
this.cwnd += this.maxPayloadSize;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
if (loss) {
|
|
790
|
+
this.ssthresh = Math.max(Math.floor(this.cwnd / 2), 4 * this.maxPayloadSize);
|
|
791
|
+
this.cwnd = this.ssthresh;
|
|
792
|
+
this.partialBytesAcked = 0;
|
|
793
|
+
this.fastRecoveryExit = this.sentQueue.at(-1).tsn;
|
|
794
|
+
this.fastRecoveryTransmit = true;
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
else if ((0, common_js_1.uint32Gte)(chunk.cumulativeTsn, this.fastRecoveryExit)) {
|
|
798
|
+
this.fastRecoveryExit = undefined;
|
|
799
|
+
}
|
|
800
|
+
if (this.sentQueue.length === 0) {
|
|
801
|
+
this.timer3Cancel();
|
|
802
|
+
}
|
|
803
|
+
else if (done > 0) {
|
|
804
|
+
this.timer3Restart();
|
|
805
|
+
}
|
|
806
|
+
// RFC 9260 §6.2.1(D-ii): keep latest peer a_rwnd; available window is derived via flightSize.
|
|
807
|
+
this.peerAdvertisedRwnd = chunk.advertisedRwnd;
|
|
808
|
+
this.updateAdvancedPeerAckPoint();
|
|
809
|
+
await this.onSackReceived();
|
|
810
|
+
await this.transmit();
|
|
811
|
+
}
|
|
812
|
+
receiveForwardTsnChunk(chunk) {
|
|
813
|
+
this.sackNeeded = true;
|
|
814
|
+
this.sackImmediate = true;
|
|
815
|
+
if ((0, common_js_1.uint32Gte)(this.lastReceivedTsn, chunk.cumulativeTsn)) {
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
const isObsolete = (x) => (0, common_js_1.uint32Gt)(x, this.lastReceivedTsn);
|
|
819
|
+
// # advance cumulative TSN
|
|
820
|
+
this.lastReceivedTsn = chunk.cumulativeTsn;
|
|
821
|
+
this.sackMisOrdered = new Set([...this.sackMisOrdered].filter(isObsolete));
|
|
822
|
+
for (const tsn of [...this.sackMisOrdered].sort()) {
|
|
823
|
+
if (tsn === tsnPlusOne(this.lastReceivedTsn)) {
|
|
824
|
+
this.lastReceivedTsn = tsn;
|
|
825
|
+
}
|
|
826
|
+
else {
|
|
827
|
+
break;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
// # filter out obsolete entries
|
|
831
|
+
this.sackDuplicates = this.sackDuplicates.filter(isObsolete);
|
|
832
|
+
this.sackMisOrdered = new Set([...this.sackMisOrdered].filter(isObsolete));
|
|
833
|
+
// # update reassembly
|
|
834
|
+
for (const [streamId, streamSeqNum] of chunk.streams) {
|
|
835
|
+
const inboundStream = this.getInboundStream(streamId);
|
|
836
|
+
// # advance sequence number and perform delivery
|
|
837
|
+
inboundStream.streamSequenceNumber = (0, common_js_1.uint16Add)(streamSeqNum, 1);
|
|
838
|
+
for (const message of inboundStream.popMessages()) {
|
|
839
|
+
this.advertisedRwnd += message[2].length;
|
|
840
|
+
this.receive(...message);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
// # prune obsolete chunks
|
|
844
|
+
Object.values(this.inboundStreams).forEach((inboundStream) => {
|
|
845
|
+
this.advertisedRwnd += inboundStream.pruneChunks(this.lastReceivedTsn);
|
|
846
|
+
});
|
|
847
|
+
this.pendingChunks = Object.values(this.inboundStreams).reduce((count, inboundStream) => count + inboundStream.reassembly.length, 0);
|
|
848
|
+
if ((0, common_js_1.uint32Gt)(this.lastReceivedTsn, this.highestReceivedTsn))
|
|
849
|
+
this.highestReceivedTsn = this.lastReceivedTsn;
|
|
850
|
+
}
|
|
851
|
+
updateRto(R) {
|
|
852
|
+
if (!this.srtt) {
|
|
853
|
+
this.rttvar = R / 2;
|
|
854
|
+
this.srtt = R;
|
|
855
|
+
}
|
|
856
|
+
else {
|
|
857
|
+
this.rttvar =
|
|
858
|
+
(1 - SCTP_RTO_BETA) * this.rttvar +
|
|
859
|
+
SCTP_RTO_BETA * Math.abs(this.srtt - R);
|
|
860
|
+
this.srtt = (1 - SCTP_RTO_ALPHA) * this.srtt + SCTP_RTO_ALPHA * R;
|
|
861
|
+
}
|
|
862
|
+
this.rto = Math.max(SCTP_RTO_MIN, Math.min(this.srtt + 4 * this.rttvar, SCTP_RTO_MAX));
|
|
863
|
+
}
|
|
864
|
+
receive(streamId, ppId, data) {
|
|
865
|
+
this.onReceive.execute(streamId, ppId, data);
|
|
866
|
+
}
|
|
867
|
+
getInboundStream(streamId) {
|
|
868
|
+
if (!this.inboundStreams[streamId]) {
|
|
869
|
+
this.inboundStreams[streamId] = new InboundStream();
|
|
870
|
+
}
|
|
871
|
+
return this.inboundStreams[streamId];
|
|
872
|
+
}
|
|
873
|
+
markReceived(tsn) {
|
|
874
|
+
if ((0, common_js_1.uint32Gte)(this.lastReceivedTsn, tsn) || this.sackMisOrdered.has(tsn)) {
|
|
875
|
+
this.sackDuplicates.push(tsn);
|
|
876
|
+
return true;
|
|
877
|
+
}
|
|
878
|
+
if ((0, common_js_1.uint32Gt)(tsn, this.highestReceivedTsn))
|
|
879
|
+
this.highestReceivedTsn = tsn;
|
|
880
|
+
if (tsn === tsnPlusOne(this.lastReceivedTsn)) {
|
|
881
|
+
//In order: the cumulative TSN advances, then over the TSNs received early that now follow it
|
|
882
|
+
this.lastReceivedTsn = tsn;
|
|
883
|
+
while (this.sackMisOrdered.size > 0) {
|
|
884
|
+
const next = tsnPlusOne(this.lastReceivedTsn);
|
|
885
|
+
if (!this.sackMisOrdered.delete(next))
|
|
886
|
+
break;
|
|
887
|
+
this.lastReceivedTsn = next;
|
|
888
|
+
}
|
|
889
|
+
if (this.sackDuplicates.length > 0) {
|
|
890
|
+
const isObsolete = (x) => (0, common_js_1.uint32Gt)(x, this.lastReceivedTsn);
|
|
891
|
+
this.sackDuplicates = this.sackDuplicates.filter(isObsolete);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
else {
|
|
895
|
+
this.sackMisOrdered.add(tsn);
|
|
896
|
+
}
|
|
897
|
+
return false;
|
|
898
|
+
}
|
|
899
|
+
/**
|
|
900
|
+
* Keep bytes received out of the receive window while the application holds them (it passes them on later): the
|
|
901
|
+
* sender waits once the window is closed
|
|
902
|
+
* @param bytes
|
|
903
|
+
*/
|
|
904
|
+
holdReceived(bytes) {
|
|
905
|
+
this.advertisedRwnd -= bytes;
|
|
906
|
+
}
|
|
907
|
+
/**
|
|
908
|
+
* Give back to the receive window bytes held; the sender is told at once when the window it knows is less than half
|
|
909
|
+
* of the window now
|
|
910
|
+
* @param bytes
|
|
911
|
+
*/
|
|
912
|
+
releaseReceived(bytes) {
|
|
913
|
+
this.advertisedRwnd += bytes;
|
|
914
|
+
if (this.associationState !== const_js_1.SCTP_STATE.ESTABLISHED || this.lastReceivedTsn === undefined)
|
|
915
|
+
return;
|
|
916
|
+
if (this.lastAdvertisedRwnd * 2 < this.advertisedRwnd) {
|
|
917
|
+
this.sackNeeded = true;
|
|
918
|
+
this.sackImmediate = true;
|
|
919
|
+
this.scheduleSack().catch((err) => log('send window update failed', err.message));
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* Transmit at the end of the current task, once: a burst of small messages fills packets, rather than going out
|
|
924
|
+
* one by one while the congestion window has room
|
|
925
|
+
*/
|
|
926
|
+
transmitSoon() {
|
|
927
|
+
if (this.transmitScheduled)
|
|
928
|
+
return;
|
|
929
|
+
this.transmitScheduled = true;
|
|
930
|
+
queueMicrotask(() => {
|
|
931
|
+
this.transmitScheduled = false;
|
|
932
|
+
this.transmit().catch((error) => log('transmit failed', error));
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
async transmit() {
|
|
936
|
+
if (this.isStopped)
|
|
937
|
+
return;
|
|
938
|
+
if (this.transmitting) {
|
|
939
|
+
this.transmitRequested = true;
|
|
940
|
+
return;
|
|
941
|
+
}
|
|
942
|
+
this.transmitting = true;
|
|
943
|
+
try {
|
|
944
|
+
do {
|
|
945
|
+
this.transmitRequested = false;
|
|
946
|
+
this.transmitOnce();
|
|
947
|
+
} while (this.transmitRequested);
|
|
948
|
+
}
|
|
949
|
+
finally {
|
|
950
|
+
this.transmitting = false;
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
/**
|
|
954
|
+
* Sends what the windows allow: FORWARD TSN, then the retransmissions, then the queued DATA, bundled in packets of the
|
|
955
|
+
* MTU; a pending SACK goes in front of the first DATA. The packets are handed to the transport without waiting: the
|
|
956
|
+
* DTLS records are numbered and encrypted when sent, so their order holds
|
|
957
|
+
*/
|
|
958
|
+
transmitOnce() {
|
|
959
|
+
if (this.isStopped)
|
|
960
|
+
return;
|
|
961
|
+
const packet = [];
|
|
962
|
+
let size = chunk_js_1.SCTP_COMMON_HEADER_SIZE;
|
|
963
|
+
let sackAdded = false;
|
|
964
|
+
const flush = () => {
|
|
965
|
+
if (packet.length === 0)
|
|
966
|
+
return;
|
|
967
|
+
this.sendChunks(packet.splice(0, packet.length));
|
|
968
|
+
size = chunk_js_1.SCTP_COMMON_HEADER_SIZE;
|
|
969
|
+
};
|
|
970
|
+
const add = (chunk) => {
|
|
971
|
+
const length = (0, chunk_js_1.chunkWireLength)(chunk);
|
|
972
|
+
if (packet.length > 0 && size + length > this.mtu)
|
|
973
|
+
flush();
|
|
974
|
+
packet.push(chunk);
|
|
975
|
+
size += length;
|
|
976
|
+
};
|
|
977
|
+
const addData = (chunk) => {
|
|
978
|
+
if (!sackAdded && this.sackNeeded && this.lastReceivedTsn !== undefined) {
|
|
979
|
+
add(this.takeSack());
|
|
980
|
+
sackAdded = true;
|
|
981
|
+
}
|
|
982
|
+
add(chunk);
|
|
983
|
+
};
|
|
984
|
+
// # send FORWARD TSN
|
|
985
|
+
if (this.forwardTsnChunk) {
|
|
986
|
+
add(this.forwardTsnChunk);
|
|
987
|
+
this.forwardTsnChunk = undefined;
|
|
988
|
+
if (!this.timer3Handle) {
|
|
989
|
+
this.timer3Start();
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
const burstSize = this.fastRecoveryExit != undefined
|
|
993
|
+
? 2 * this.maxPayloadSize
|
|
994
|
+
: 4 * this.maxPayloadSize;
|
|
995
|
+
const cwnd = Math.min(this.flightSize + burstSize, this.cwnd);
|
|
996
|
+
if (this.retransmitPending) {
|
|
997
|
+
let retransmitEarliest = true;
|
|
998
|
+
let walked = true;
|
|
999
|
+
for (const dataChunk of this.sentQueue) {
|
|
1000
|
+
if (dataChunk.retransmit) {
|
|
1001
|
+
if (this.fastRecoveryTransmit) {
|
|
1002
|
+
this.fastRecoveryTransmit = false;
|
|
1003
|
+
}
|
|
1004
|
+
else if (this.flightSize >= cwnd) {
|
|
1005
|
+
walked = false;
|
|
1006
|
+
break;
|
|
1007
|
+
}
|
|
1008
|
+
this.flightSizeIncrease(dataChunk);
|
|
1009
|
+
dataChunk.misses = 0;
|
|
1010
|
+
dataChunk.retransmit = false;
|
|
1011
|
+
dataChunk.sentCount++;
|
|
1012
|
+
addData(dataChunk);
|
|
1013
|
+
if (retransmitEarliest) {
|
|
1014
|
+
this.timer3Restart();
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
retransmitEarliest = false;
|
|
1018
|
+
}
|
|
1019
|
+
if (walked)
|
|
1020
|
+
this.retransmitPending = false;
|
|
1021
|
+
}
|
|
1022
|
+
// Drain queued outbound DATA; retransmission pacing is controlled by RTO/T3. With a closed window and nothing in
|
|
1023
|
+
// flight, one chunk goes as a probe (RFC 9260 section 6.1, rule A)
|
|
1024
|
+
while (this.outboundQueue.length > 0 &&
|
|
1025
|
+
this.flightSize < cwnd &&
|
|
1026
|
+
(this.peerRwnd > 0 || this.flightSize === 0)) {
|
|
1027
|
+
const chunk = this.outboundQueue.shift();
|
|
1028
|
+
if (!chunk)
|
|
1029
|
+
break;
|
|
1030
|
+
if (chunk.bookSize > this.peerRwnd && this.flightSize > 0) {
|
|
1031
|
+
this.outboundQueue.unshift(chunk);
|
|
1032
|
+
break;
|
|
1033
|
+
}
|
|
1034
|
+
this.sentQueue.push(chunk);
|
|
1035
|
+
this.flightSizeIncrease(chunk);
|
|
1036
|
+
// # update counters
|
|
1037
|
+
chunk.sentCount++;
|
|
1038
|
+
chunk.sentTime = Date.now() / 1000;
|
|
1039
|
+
addData(chunk);
|
|
1040
|
+
this.onSent?.(chunk.streamId, chunk.protocol, chunk.userData.length);
|
|
1041
|
+
if (!this.timer3Handle) {
|
|
1042
|
+
this.timer3Start();
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
flush();
|
|
1046
|
+
this.flush.execute();
|
|
1047
|
+
}
|
|
1048
|
+
/**One packet of chunks, handed to the transport without waiting for it */
|
|
1049
|
+
sendChunks(chunks) {
|
|
1050
|
+
if (this.state === 'closed')
|
|
1051
|
+
return;
|
|
1052
|
+
if (this.remotePort === undefined) {
|
|
1053
|
+
log('send chunks failed', 'invalid remote port');
|
|
1054
|
+
return;
|
|
1055
|
+
}
|
|
1056
|
+
const packet = (0, chunk_js_1.serializePackets)(this.localPort, this.remotePort, this.remoteVerificationTag, chunks);
|
|
1057
|
+
this.transport.send(packet).catch((err) => {
|
|
1058
|
+
log('send packet failed', err.message);
|
|
1059
|
+
});
|
|
1060
|
+
}
|
|
1061
|
+
async transmitReconfigRequest() {
|
|
1062
|
+
if (this.reconfigQueue.length > 0 &&
|
|
1063
|
+
this.associationState === const_js_1.SCTP_STATE.ESTABLISHED &&
|
|
1064
|
+
!this.reconfigRequest) {
|
|
1065
|
+
// Remove duplicate stream IDs from reconfigQueue
|
|
1066
|
+
const uniqueStreams = [...new Set(this.reconfigQueue)];
|
|
1067
|
+
const streams = uniqueStreams.slice(0, RECONFIG_MAX_STREAMS);
|
|
1068
|
+
this.reconfigQueue = uniqueStreams.slice(RECONFIG_MAX_STREAMS);
|
|
1069
|
+
const param = new param_js_1.OutgoingSSNResetRequestParam(this.reconfigRequestSeq, this.reconfigResponseSeq, tsnMinusOne(this.localTsn), streams);
|
|
1070
|
+
this.reconfigRequestSeq = tsnPlusOne(this.reconfigRequestSeq);
|
|
1071
|
+
this.reconfigRequest = param;
|
|
1072
|
+
await this.sendReconfigParam(param);
|
|
1073
|
+
this.timerReconfigHandleStart();
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
async sendReconfigParam(param) {
|
|
1077
|
+
log('sendReconfigParam', param);
|
|
1078
|
+
const chunk = new chunk_js_1.ReconfigChunk();
|
|
1079
|
+
chunk.params.push([param.type, param.bytes]);
|
|
1080
|
+
await this.sendChunk(chunk).catch((err) => {
|
|
1081
|
+
log('send reconfig failed', err.message);
|
|
1082
|
+
});
|
|
1083
|
+
}
|
|
1084
|
+
// https://github.com/pion/sctp/pull/44/files
|
|
1085
|
+
async sendResetRequest(streamId) {
|
|
1086
|
+
log('sendResetRequest', streamId);
|
|
1087
|
+
const chunk = new chunk_js_1.DataChunk(0, undefined);
|
|
1088
|
+
chunk.streamId = streamId;
|
|
1089
|
+
this.outboundQueue.push(chunk);
|
|
1090
|
+
if (!this.timer3Handle) {
|
|
1091
|
+
await this.transmit();
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
flightSizeIncrease(chunk) {
|
|
1095
|
+
this.flightSize += chunk.bookSize;
|
|
1096
|
+
}
|
|
1097
|
+
flightSizeDecrease(chunk) {
|
|
1098
|
+
this.flightSize = Math.max(0, this.flightSize - chunk.bookSize);
|
|
1099
|
+
}
|
|
1100
|
+
// # timers
|
|
1101
|
+
/**t1 is wait for initAck or cookieAck */
|
|
1102
|
+
timer1Start(chunk) {
|
|
1103
|
+
if (this.timer1Handle)
|
|
1104
|
+
throw new Error();
|
|
1105
|
+
this.timer1Chunk = chunk;
|
|
1106
|
+
this.timer1Failures = 0;
|
|
1107
|
+
this.timer1Handle = setTimeout(this.timer1Expired, this.rto * 1000);
|
|
1108
|
+
}
|
|
1109
|
+
timer1Cancel() {
|
|
1110
|
+
if (this.timer1Handle) {
|
|
1111
|
+
clearTimeout(this.timer1Handle);
|
|
1112
|
+
this.timer1Handle = undefined;
|
|
1113
|
+
this.timer1Chunk = undefined;
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
/**t2 is wait for shutdown */
|
|
1117
|
+
t2Start(chunk) {
|
|
1118
|
+
if (this.timer2Handle)
|
|
1119
|
+
throw new Error();
|
|
1120
|
+
this.timer2Chunk = chunk;
|
|
1121
|
+
this.timer2Failures = 0;
|
|
1122
|
+
this.timer2Handle = setTimeout(this.timer2Expired, this.rto * 1000);
|
|
1123
|
+
}
|
|
1124
|
+
timer2Cancel() {
|
|
1125
|
+
if (this.timer2Handle) {
|
|
1126
|
+
clearTimeout(this.timer2Handle);
|
|
1127
|
+
this.timer2Handle = undefined;
|
|
1128
|
+
this.timer2Chunk = undefined;
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
/**t3 is wait for data sack */
|
|
1132
|
+
timer3Start() {
|
|
1133
|
+
if (this.isStopped)
|
|
1134
|
+
return;
|
|
1135
|
+
if (this.timer3Handle)
|
|
1136
|
+
throw new Error();
|
|
1137
|
+
// RFC 9260 T3-rtx runs on current RTO; rto is stored in seconds.
|
|
1138
|
+
this.timer3Handle = setTimeout(this.timer3Expired, this.rto * 1000);
|
|
1139
|
+
}
|
|
1140
|
+
timer3Restart() {
|
|
1141
|
+
if (this.isStopped)
|
|
1142
|
+
return;
|
|
1143
|
+
this.timer3Cancel();
|
|
1144
|
+
// RFC 9260 requires restarting T3-rtx with current RTO (seconds -> JS ms).
|
|
1145
|
+
this.timer3Handle = setTimeout(this.timer3Expired, this.rto * 1000);
|
|
1146
|
+
}
|
|
1147
|
+
timer3Cancel() {
|
|
1148
|
+
if (this.timer3Handle) {
|
|
1149
|
+
clearTimeout(this.timer3Handle);
|
|
1150
|
+
this.timer3Handle = undefined;
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
/**Re-configuration Timer */
|
|
1154
|
+
timerReconfigHandleStart() {
|
|
1155
|
+
if (this.isStopped)
|
|
1156
|
+
return;
|
|
1157
|
+
if (this.timerReconfigHandle)
|
|
1158
|
+
return;
|
|
1159
|
+
log('timerReconfigHandleStart', { rto: this.rto });
|
|
1160
|
+
this.timerReconfigFailures = 0;
|
|
1161
|
+
this.timerReconfigHandle = setTimeout((0, common_js_1.detached)(this.timerReconfigHandleExpired, (error) => log('reconfig timer failed', error)), this.rto * 1000);
|
|
1162
|
+
}
|
|
1163
|
+
timerReconfigCancel() {
|
|
1164
|
+
if (this.timerReconfigHandle) {
|
|
1165
|
+
log('timerReconfigCancel');
|
|
1166
|
+
clearTimeout(this.timerReconfigHandle);
|
|
1167
|
+
this.timerReconfigHandle = undefined;
|
|
1168
|
+
// Reset failures counter when timer is successfully cancelled
|
|
1169
|
+
this.timerReconfigFailures = 0;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
heartbeatStart() {
|
|
1173
|
+
if (this.timerHeartbeatHandle ||
|
|
1174
|
+
this.associationState !== const_js_1.SCTP_STATE.ESTABLISHED) {
|
|
1175
|
+
return;
|
|
1176
|
+
}
|
|
1177
|
+
// RFC 9260 heartbeat timer is based on RTO + HB.interval for idle paths.
|
|
1178
|
+
this.timerHeartbeatHandle = setTimeout((0, common_js_1.detached)(this.timerHeartbeatExpired, (error) => log('heartbeat failed', error)), (this.rto + this.heartbeatInterval) * 1000);
|
|
1179
|
+
}
|
|
1180
|
+
heartbeatRestart() {
|
|
1181
|
+
this.heartbeatCancel();
|
|
1182
|
+
this.heartbeatStart();
|
|
1183
|
+
}
|
|
1184
|
+
heartbeatCancel() {
|
|
1185
|
+
if (this.timerHeartbeatHandle) {
|
|
1186
|
+
clearTimeout(this.timerHeartbeatHandle);
|
|
1187
|
+
this.timerHeartbeatHandle = undefined;
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
setHeartbeatInterval(interval) {
|
|
1191
|
+
if (interval <= 0) {
|
|
1192
|
+
throw new Error('heartbeat interval must be > 0');
|
|
1193
|
+
}
|
|
1194
|
+
this.heartbeatInterval = interval;
|
|
1195
|
+
this.heartbeatRestart();
|
|
1196
|
+
}
|
|
1197
|
+
updateAdvancedPeerAckPoint() {
|
|
1198
|
+
if ((0, common_js_1.uint32Gt)(this.lastSackedTsn, this.advancedPeerAckTsn)) {
|
|
1199
|
+
this.advancedPeerAckTsn = this.lastSackedTsn;
|
|
1200
|
+
}
|
|
1201
|
+
let done = 0;
|
|
1202
|
+
const streams = {};
|
|
1203
|
+
while (this.sentQueue.length > 0 && this.sentQueue.at(0).abandoned) {
|
|
1204
|
+
const chunk = this.sentQueue.shift();
|
|
1205
|
+
this.advancedPeerAckTsn = chunk.tsn;
|
|
1206
|
+
done++;
|
|
1207
|
+
if (!(chunk.flags & SCTP_DATA_UNORDERED)) {
|
|
1208
|
+
streams[chunk.streamId] = chunk.streamSeqNum;
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
if (done) {
|
|
1212
|
+
this.forwardTsnChunk = new chunk_js_1.ForwardTsnChunk(0, undefined);
|
|
1213
|
+
this.forwardTsnChunk.cumulativeTsn = this.advancedPeerAckTsn;
|
|
1214
|
+
this.forwardTsnChunk.streams = Object.entries(streams).map(([k, v]) => [
|
|
1215
|
+
Number(k),
|
|
1216
|
+
v
|
|
1217
|
+
]);
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
maybeAbandon(chunk) {
|
|
1221
|
+
if (chunk.abandoned)
|
|
1222
|
+
return true;
|
|
1223
|
+
const abandon = (!!chunk.maxRetransmits && chunk.maxRetransmits < chunk.sentCount) ||
|
|
1224
|
+
(!!chunk.expiry && chunk.expiry < Date.now() / 1000);
|
|
1225
|
+
if (!abandon)
|
|
1226
|
+
return false;
|
|
1227
|
+
const chunkPos = this.sentQueue.findIndex((v) => v === chunk);
|
|
1228
|
+
for (let pos = chunkPos; pos >= 0; pos--) {
|
|
1229
|
+
const oChunk = this.sentQueue.at(pos);
|
|
1230
|
+
oChunk.abandoned = true;
|
|
1231
|
+
oChunk.retransmit = false;
|
|
1232
|
+
if (oChunk.flags & SCTP_DATA_LAST_FRAG) {
|
|
1233
|
+
break;
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
for (let pos = chunkPos; pos < this.sentQueue.length; pos++) {
|
|
1237
|
+
const oChunk = this.sentQueue.at(pos);
|
|
1238
|
+
oChunk.abandoned = true;
|
|
1239
|
+
oChunk.retransmit = false;
|
|
1240
|
+
if (oChunk.flags & SCTP_DATA_LAST_FRAG) {
|
|
1241
|
+
break;
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
return true;
|
|
1245
|
+
}
|
|
1246
|
+
static getCapabilities() {
|
|
1247
|
+
return new RTCSctpCapabilities(65536);
|
|
1248
|
+
}
|
|
1249
|
+
setRemotePort(port) {
|
|
1250
|
+
this.remotePort = port;
|
|
1251
|
+
}
|
|
1252
|
+
async start(remotePort) {
|
|
1253
|
+
if (!this.started) {
|
|
1254
|
+
this.started = true;
|
|
1255
|
+
this.setConnectionState('connecting');
|
|
1256
|
+
if (remotePort) {
|
|
1257
|
+
this.setRemotePort(remotePort);
|
|
1258
|
+
}
|
|
1259
|
+
if (!this.isServer) {
|
|
1260
|
+
await this.init();
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
async init() {
|
|
1265
|
+
const init = new chunk_js_1.InitChunk();
|
|
1266
|
+
init.initiateTag = this.localVerificationTag;
|
|
1267
|
+
init.advertisedRwnd = this.advertisedRwnd;
|
|
1268
|
+
init.outboundStreams = this._outboundStreamsCount;
|
|
1269
|
+
init.inboundStreams = this._inboundStreamsMax;
|
|
1270
|
+
init.initialTsn = this.localTsn;
|
|
1271
|
+
this.setExtensions(init.params);
|
|
1272
|
+
log('send init', init);
|
|
1273
|
+
try {
|
|
1274
|
+
await this.sendChunk(init);
|
|
1275
|
+
// # start T1 timer and enter COOKIE-WAIT state
|
|
1276
|
+
this.timer1Start(init);
|
|
1277
|
+
this.setState(const_js_1.SCTP_STATE.COOKIE_WAIT);
|
|
1278
|
+
}
|
|
1279
|
+
catch (error) {
|
|
1280
|
+
log('send init failed', error.message);
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
setExtensions(params) {
|
|
1284
|
+
const extensions = [];
|
|
1285
|
+
if (this.localPartialReliability) {
|
|
1286
|
+
params.push([SCTP_PRSCTP_SUPPORTED, Buffer.from('')]);
|
|
1287
|
+
extensions.push(chunk_js_1.ForwardTsnChunk.type);
|
|
1288
|
+
}
|
|
1289
|
+
extensions.push(chunk_js_1.ReConfigChunk.type);
|
|
1290
|
+
params.push([SCTP_SUPPORTED_CHUNK_EXT, Buffer.from(extensions)]);
|
|
1291
|
+
}
|
|
1292
|
+
async sendChunk(chunk) {
|
|
1293
|
+
if (this.state === 'closed')
|
|
1294
|
+
return;
|
|
1295
|
+
if (this.remotePort === undefined) {
|
|
1296
|
+
throw new Error('invalid remote port');
|
|
1297
|
+
}
|
|
1298
|
+
const packet = (0, chunk_js_1.serializePacket)(this.localPort, this.remotePort, this.remoteVerificationTag, chunk);
|
|
1299
|
+
await this.transport.send(packet);
|
|
1300
|
+
}
|
|
1301
|
+
setState(state) {
|
|
1302
|
+
if (state != this.associationState) {
|
|
1303
|
+
this.associationState = state;
|
|
1304
|
+
}
|
|
1305
|
+
if (state === const_js_1.SCTP_STATE.ESTABLISHED) {
|
|
1306
|
+
this.isStopping = false;
|
|
1307
|
+
this.isClosed = false;
|
|
1308
|
+
this.setConnectionState('connected');
|
|
1309
|
+
this.heartbeatStart();
|
|
1310
|
+
}
|
|
1311
|
+
else if (state === const_js_1.SCTP_STATE.CLOSED) {
|
|
1312
|
+
this.isClosed = true;
|
|
1313
|
+
this.timer1Cancel();
|
|
1314
|
+
this.timer2Cancel();
|
|
1315
|
+
this.timer3Cancel();
|
|
1316
|
+
this.timerReconfigCancel();
|
|
1317
|
+
this.heartbeatCancel();
|
|
1318
|
+
if (this.sackTimeout) {
|
|
1319
|
+
clearTimeout(this.sackTimeout);
|
|
1320
|
+
this.sackTimeout = undefined;
|
|
1321
|
+
}
|
|
1322
|
+
this.setConnectionState('closed');
|
|
1323
|
+
this.removeAllListeners();
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
setConnectionState(state) {
|
|
1327
|
+
this.state = state;
|
|
1328
|
+
log('setConnectionState', state);
|
|
1329
|
+
this.stateChanged[state].execute();
|
|
1330
|
+
}
|
|
1331
|
+
async stop() {
|
|
1332
|
+
if (this.isStopped) {
|
|
1333
|
+
this.setState(const_js_1.SCTP_STATE.CLOSED);
|
|
1334
|
+
return;
|
|
1335
|
+
}
|
|
1336
|
+
this.isStopping = true;
|
|
1337
|
+
this.transport.onData = undefined;
|
|
1338
|
+
if (this.sackTimeout) {
|
|
1339
|
+
clearTimeout(this.sackTimeout);
|
|
1340
|
+
this.sackTimeout = undefined;
|
|
1341
|
+
}
|
|
1342
|
+
if (this.associationState !== const_js_1.SCTP_STATE.CLOSED) {
|
|
1343
|
+
await this.abort();
|
|
1344
|
+
}
|
|
1345
|
+
this.setState(const_js_1.SCTP_STATE.CLOSED);
|
|
1346
|
+
clearTimeout(this.timer1Handle);
|
|
1347
|
+
clearTimeout(this.timer2Handle);
|
|
1348
|
+
clearTimeout(this.timer3Handle);
|
|
1349
|
+
clearTimeout(this.timerReconfigHandle);
|
|
1350
|
+
clearTimeout(this.timerHeartbeatHandle);
|
|
1351
|
+
clearTimeout(this.sackTimeout);
|
|
1352
|
+
}
|
|
1353
|
+
async abort() {
|
|
1354
|
+
const abort = new chunk_js_1.AbortChunk();
|
|
1355
|
+
await this.sendChunk(abort).catch((err) => {
|
|
1356
|
+
log('send abort failed', err.message);
|
|
1357
|
+
});
|
|
1358
|
+
}
|
|
1359
|
+
removeAllListeners() {
|
|
1360
|
+
Object.values(this.stateChanged).forEach((v) => v.allUnsubscribe());
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
exports.SCTP = SCTP;
|
|
1364
|
+
class InboundStream {
|
|
1365
|
+
constructor() {
|
|
1366
|
+
this.reassembly = [];
|
|
1367
|
+
this.streamSequenceNumber = 0; // SSN
|
|
1368
|
+
}
|
|
1369
|
+
addChunk(chunk) {
|
|
1370
|
+
if (this.reassembly.length === 0 ||
|
|
1371
|
+
(0, common_js_1.uint32Gt)(chunk.tsn, this.reassembly[this.reassembly.length - 1].tsn)) {
|
|
1372
|
+
this.reassembly.push(chunk);
|
|
1373
|
+
return;
|
|
1374
|
+
}
|
|
1375
|
+
for (const [i, v] of (0, helper_js_1.enumerate)(this.reassembly)) {
|
|
1376
|
+
if (v.tsn === chunk.tsn)
|
|
1377
|
+
throw new Error('duplicate chunk in reassembly');
|
|
1378
|
+
if ((0, common_js_1.uint32Gt)(v.tsn, chunk.tsn)) {
|
|
1379
|
+
this.reassembly.splice(i, 0, chunk);
|
|
1380
|
+
break;
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
*popMessages() {
|
|
1385
|
+
let pos = 0;
|
|
1386
|
+
let startPos;
|
|
1387
|
+
let expectedTsn;
|
|
1388
|
+
let ordered;
|
|
1389
|
+
while (pos < this.reassembly.length) {
|
|
1390
|
+
const chunk = this.reassembly[pos];
|
|
1391
|
+
if (startPos === undefined) {
|
|
1392
|
+
ordered = !(chunk.flags & SCTP_DATA_UNORDERED);
|
|
1393
|
+
if (!(chunk.flags & SCTP_DATA_FIRST_FRAG)) {
|
|
1394
|
+
if (ordered) {
|
|
1395
|
+
break;
|
|
1396
|
+
}
|
|
1397
|
+
else {
|
|
1398
|
+
pos++;
|
|
1399
|
+
continue;
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
if (ordered &&
|
|
1403
|
+
(0, common_js_1.uint16Gt)(chunk.streamSeqNum, this.streamSequenceNumber)) {
|
|
1404
|
+
break;
|
|
1405
|
+
}
|
|
1406
|
+
expectedTsn = chunk.tsn;
|
|
1407
|
+
startPos = pos;
|
|
1408
|
+
}
|
|
1409
|
+
else if (chunk.tsn !== expectedTsn) {
|
|
1410
|
+
if (ordered) {
|
|
1411
|
+
break;
|
|
1412
|
+
}
|
|
1413
|
+
else {
|
|
1414
|
+
startPos = undefined;
|
|
1415
|
+
pos++;
|
|
1416
|
+
continue;
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
if (chunk.flags & SCTP_DATA_LAST_FRAG) {
|
|
1420
|
+
const parts = this.reassembly
|
|
1421
|
+
.slice(startPos, pos + 1)
|
|
1422
|
+
.map((c) => c.userData);
|
|
1423
|
+
const userData = parts.length === 1 ? parts[0] : Buffer.concat(parts);
|
|
1424
|
+
this.reassembly.splice(startPos, pos + 1 - startPos);
|
|
1425
|
+
if (ordered && chunk.streamSeqNum === this.streamSequenceNumber) {
|
|
1426
|
+
this.streamSequenceNumber = (0, common_js_1.uint16Add)(this.streamSequenceNumber, 1);
|
|
1427
|
+
}
|
|
1428
|
+
pos = startPos;
|
|
1429
|
+
yield [chunk.streamId, chunk.protocol, userData];
|
|
1430
|
+
}
|
|
1431
|
+
else {
|
|
1432
|
+
pos++;
|
|
1433
|
+
}
|
|
1434
|
+
expectedTsn = tsnPlusOne(expectedTsn);
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
pruneChunks(tsn) {
|
|
1438
|
+
// """
|
|
1439
|
+
// Prune chunks up to the given TSN.
|
|
1440
|
+
// """
|
|
1441
|
+
let pos = -1, size = 0;
|
|
1442
|
+
for (const [i, chunk] of this.reassembly.entries()) {
|
|
1443
|
+
if ((0, common_js_1.uint32Gte)(tsn, chunk.tsn)) {
|
|
1444
|
+
pos = i;
|
|
1445
|
+
size += chunk.userData.length;
|
|
1446
|
+
}
|
|
1447
|
+
else {
|
|
1448
|
+
break;
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
this.reassembly = this.reassembly.slice(pos + 1);
|
|
1452
|
+
return size;
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
exports.InboundStream = InboundStream;
|
|
1456
|
+
class RTCSctpCapabilities {
|
|
1457
|
+
constructor(maxMessageSize) {
|
|
1458
|
+
this.maxMessageSize = maxMessageSize;
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
exports.RTCSctpCapabilities = RTCSctpCapabilities;
|
|
1462
|
+
function tsnMinusOne(a) {
|
|
1463
|
+
return (a - 1) % SCTP_TSN_MODULO;
|
|
1464
|
+
}
|
|
1465
|
+
function tsnPlusOne(a) {
|
|
1466
|
+
return (a + 1) % SCTP_TSN_MODULO;
|
|
1467
|
+
}
|