werift 0.27.0 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +299 -8
- package/lib/common/src/event.d.ts +26 -0
- package/lib/common/src/event.js +87 -2
- package/lib/common/src/event.js.map +1 -1
- package/lib/common/src/network.d.ts +6 -1
- package/lib/common/src/network.js +8 -2
- package/lib/common/src/network.js.map +1 -1
- package/lib/common/src/transport.d.ts +51 -10
- package/lib/common/src/transport.js +35 -9
- package/lib/common/src/transport.js.map +1 -1
- package/lib/dtls/src/alert.d.ts +49 -0
- package/lib/dtls/src/alert.js +103 -0
- package/lib/dtls/src/alert.js.map +1 -0
- package/lib/dtls/src/carrier/direct.d.ts +67 -0
- package/lib/dtls/src/carrier/direct.js +226 -0
- package/lib/dtls/src/carrier/direct.js.map +1 -0
- package/lib/dtls/src/carrier/types.d.ts +81 -0
- package/lib/dtls/src/carrier/types.js +7 -0
- package/lib/dtls/src/carrier/types.js.map +1 -0
- package/lib/dtls/src/cipher/const.d.ts +6 -0
- package/lib/dtls/src/cipher/const.js +13 -2
- package/lib/dtls/src/cipher/const.js.map +1 -1
- package/lib/dtls/src/cipher/prf.js +11 -2
- package/lib/dtls/src/cipher/prf.js.map +1 -1
- package/lib/dtls/src/cipher/tls13/aead.d.ts +41 -0
- package/lib/dtls/src/cipher/tls13/aead.js +128 -0
- package/lib/dtls/src/cipher/tls13/aead.js.map +1 -0
- package/lib/dtls/src/cipher/tls13/hkdf.d.ts +30 -0
- package/lib/dtls/src/cipher/tls13/hkdf.js +76 -0
- package/lib/dtls/src/cipher/tls13/hkdf.js.map +1 -0
- package/lib/dtls/src/cipher/tls13/keySchedule.d.ts +70 -0
- package/lib/dtls/src/cipher/tls13/keySchedule.js +114 -0
- package/lib/dtls/src/cipher/tls13/keySchedule.js.map +1 -0
- package/lib/dtls/src/cipher/tls13/signature.d.ts +30 -0
- package/lib/dtls/src/cipher/tls13/signature.js +149 -0
- package/lib/dtls/src/cipher/tls13/signature.js.map +1 -0
- package/lib/dtls/src/client.d.ts +253 -0
- package/lib/dtls/src/client.js +1269 -14
- package/lib/dtls/src/client.js.map +1 -1
- package/lib/dtls/src/context/dtls.d.ts +47 -0
- package/lib/dtls/src/context/dtls.js +121 -0
- package/lib/dtls/src/context/dtls.js.map +1 -1
- package/lib/dtls/src/context/transport.d.ts +30 -1
- package/lib/dtls/src/context/transport.js +67 -3
- package/lib/dtls/src/context/transport.js.map +1 -1
- package/lib/dtls/src/engine/v1_3/connection-base.d.ts +520 -0
- package/lib/dtls/src/engine/v1_3/connection-base.js +1644 -0
- package/lib/dtls/src/engine/v1_3/connection-base.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/connection.d.ts +181 -0
- package/lib/dtls/src/engine/v1_3/connection.js +680 -0
- package/lib/dtls/src/engine/v1_3/connection.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/early-data-buffer.d.ts +38 -0
- package/lib/dtls/src/engine/v1_3/early-data-buffer.js +166 -0
- package/lib/dtls/src/engine/v1_3/early-data-buffer.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/certificate.d.ts +4 -0
- package/lib/dtls/src/engine/v1_3/flight/certificate.js +62 -0
- package/lib/dtls/src/engine/v1_3/flight/certificate.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight1.d.ts +8 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight1.js +119 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight1.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight4.d.ts +8 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight4.js +251 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight4.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight5.d.ts +5 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight5.js +99 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight5.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/dispatch.d.ts +12 -0
- package/lib/dtls/src/engine/v1_3/flight/dispatch.js +138 -0
- package/lib/dtls/src/engine/v1_3/flight/dispatch.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/extensions.d.ts +13 -0
- package/lib/dtls/src/engine/v1_3/flight/extensions.js +46 -0
- package/lib/dtls/src/engine/v1_3/flight/extensions.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/finished.d.ts +6 -0
- package/lib/dtls/src/engine/v1_3/flight/finished.js +16 -0
- package/lib/dtls/src/engine/v1_3/flight/finished.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/post-hs.d.ts +12 -0
- package/lib/dtls/src/engine/v1_3/flight/post-hs.js +94 -0
- package/lib/dtls/src/engine/v1_3/flight/post-hs.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight2.d.ts +21 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight2.js +227 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight2.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight4.d.ts +6 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight4.js +455 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight4.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight5.d.ts +5 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight5.js +48 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight5.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight-tx.d.ts +119 -0
- package/lib/dtls/src/engine/v1_3/flight-tx.js +782 -0
- package/lib/dtls/src/engine/v1_3/flight-tx.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/host.d.ts +86 -0
- package/lib/dtls/src/engine/v1_3/host.js +11 -0
- package/lib/dtls/src/engine/v1_3/host.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/record-rx.d.ts +77 -0
- package/lib/dtls/src/engine/v1_3/record-rx.js +818 -0
- package/lib/dtls/src/engine/v1_3/record-rx.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/transcript.d.ts +22 -0
- package/lib/dtls/src/engine/v1_3/transcript.js +65 -0
- package/lib/dtls/src/engine/v1_3/transcript.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/types.d.ts +169 -0
- package/lib/dtls/src/engine/v1_3/types.js +113 -0
- package/lib/dtls/src/engine/v1_3/types.js.map +1 -0
- package/lib/dtls/src/flight/client/flight1.d.ts +7 -1
- package/lib/dtls/src/flight/client/flight1.js +9 -3
- package/lib/dtls/src/flight/client/flight1.js.map +1 -1
- package/lib/dtls/src/flight/client/flight3.d.ts +8 -0
- package/lib/dtls/src/flight/client/flight3.js +24 -4
- package/lib/dtls/src/flight/client/flight3.js.map +1 -1
- package/lib/dtls/src/flight/client/flight5.js +17 -2
- package/lib/dtls/src/flight/client/flight5.js.map +1 -1
- package/lib/dtls/src/flight/flight.d.ts +21 -0
- package/lib/dtls/src/flight/flight.js +119 -9
- package/lib/dtls/src/flight/flight.js.map +1 -1
- package/lib/dtls/src/flight/server/commitClientHello.d.ts +35 -0
- package/lib/dtls/src/flight/server/commitClientHello.js +149 -0
- package/lib/dtls/src/flight/server/commitClientHello.js.map +1 -0
- package/lib/dtls/src/flight/server/flight2.d.ts +12 -3
- package/lib/dtls/src/flight/server/flight2.js +29 -105
- package/lib/dtls/src/flight/server/flight2.js.map +1 -1
- package/lib/dtls/src/flight/server/flight4.js +14 -2
- package/lib/dtls/src/flight/server/flight4.js.map +1 -1
- package/lib/dtls/src/flight/server/flight6.js +12 -1
- package/lib/dtls/src/flight/server/flight6.js.map +1 -1
- package/lib/dtls/src/handshake/const.d.ts +10 -0
- package/lib/dtls/src/handshake/const.js +10 -0
- package/lib/dtls/src/handshake/const.js.map +1 -1
- package/lib/dtls/src/handshake/extensions/cookie.d.ts +113 -0
- package/lib/dtls/src/handshake/extensions/cookie.js +326 -0
- package/lib/dtls/src/handshake/extensions/cookie.js.map +1 -0
- package/lib/dtls/src/handshake/extensions/ids.d.ts +7 -0
- package/lib/dtls/src/handshake/extensions/ids.js +11 -0
- package/lib/dtls/src/handshake/extensions/ids.js.map +1 -0
- package/lib/dtls/src/handshake/extensions/keyShare.d.ts +28 -0
- package/lib/dtls/src/handshake/extensions/keyShare.js +156 -0
- package/lib/dtls/src/handshake/extensions/keyShare.js.map +1 -0
- package/lib/dtls/src/handshake/extensions/signatureAlgorithms.d.ts +27 -0
- package/lib/dtls/src/handshake/extensions/signatureAlgorithms.js +67 -0
- package/lib/dtls/src/handshake/extensions/signatureAlgorithms.js.map +1 -0
- package/lib/dtls/src/handshake/extensions/supportedVersions.d.ts +20 -0
- package/lib/dtls/src/handshake/extensions/supportedVersions.js +90 -0
- package/lib/dtls/src/handshake/extensions/supportedVersions.js.map +1 -0
- package/lib/dtls/src/handshake/extensions/unique.d.ts +7 -0
- package/lib/dtls/src/handshake/extensions/unique.js +19 -0
- package/lib/dtls/src/handshake/extensions/unique.js.map +1 -0
- package/lib/dtls/src/handshake/extensions/useSrtp.d.ts +26 -3
- package/lib/dtls/src/handshake/extensions/useSrtp.js +68 -12
- package/lib/dtls/src/handshake/extensions/useSrtp.js.map +1 -1
- package/lib/dtls/src/handshake/message/tls13/ack.d.ts +50 -0
- package/lib/dtls/src/handshake/message/tls13/ack.js +107 -0
- package/lib/dtls/src/handshake/message/tls13/ack.js.map +1 -0
- package/lib/dtls/src/handshake/message/tls13/certificate.d.ts +17 -0
- package/lib/dtls/src/handshake/message/tls13/certificate.js +112 -0
- package/lib/dtls/src/handshake/message/tls13/certificate.js.map +1 -0
- package/lib/dtls/src/handshake/message/tls13/certificateRequest.d.ts +17 -0
- package/lib/dtls/src/handshake/message/tls13/certificateRequest.js +99 -0
- package/lib/dtls/src/handshake/message/tls13/certificateRequest.js.map +1 -0
- package/lib/dtls/src/handshake/message/tls13/certificateVerify.d.ts +21 -0
- package/lib/dtls/src/handshake/message/tls13/certificateVerify.js +77 -0
- package/lib/dtls/src/handshake/message/tls13/certificateVerify.js.map +1 -0
- package/lib/dtls/src/handshake/message/tls13/encryptedExtensions.d.ts +19 -0
- package/lib/dtls/src/handshake/message/tls13/encryptedExtensions.js +56 -0
- package/lib/dtls/src/handshake/message/tls13/encryptedExtensions.js.map +1 -0
- package/lib/dtls/src/handshake/message/tls13/keyUpdate.d.ts +13 -0
- package/lib/dtls/src/handshake/message/tls13/keyUpdate.js +54 -0
- package/lib/dtls/src/handshake/message/tls13/keyUpdate.js.map +1 -0
- package/lib/dtls/src/handshake/message/tls13/newSessionTicket.d.ts +33 -0
- package/lib/dtls/src/handshake/message/tls13/newSessionTicket.js +158 -0
- package/lib/dtls/src/handshake/message/tls13/newSessionTicket.js.map +1 -0
- package/lib/dtls/src/handshake/random.d.ts +14 -0
- package/lib/dtls/src/handshake/random.js +24 -0
- package/lib/dtls/src/handshake/random.js.map +1 -1
- package/lib/dtls/src/handshake/validation.d.ts +26 -0
- package/lib/dtls/src/handshake/validation.js +32 -0
- package/lib/dtls/src/handshake/validation.js.map +1 -0
- package/lib/dtls/src/index.d.ts +8 -1
- package/lib/dtls/src/index.js +125 -44
- package/lib/dtls/src/index.js.map +1 -1
- package/lib/dtls/src/internal.d.ts +7 -0
- package/lib/dtls/src/internal.js +57 -0
- package/lib/dtls/src/internal.js.map +1 -0
- package/lib/dtls/src/peer.d.ts +49 -0
- package/lib/dtls/src/peer.js +54 -0
- package/lib/dtls/src/peer.js.map +1 -0
- package/lib/dtls/src/record/antiReplayWindow.d.ts +33 -0
- package/lib/dtls/src/record/antiReplayWindow.js +119 -0
- package/lib/dtls/src/record/antiReplayWindow.js.map +1 -0
- package/lib/dtls/src/record/const.d.ts +15 -0
- package/lib/dtls/src/record/const.js +15 -1
- package/lib/dtls/src/record/const.js.map +1 -1
- package/lib/dtls/src/record/message/fragment.d.ts +0 -2
- package/lib/dtls/src/record/message/fragment.js +36 -17
- package/lib/dtls/src/record/message/fragment.js.map +1 -1
- package/lib/dtls/src/record/message/reassembler.d.ts +62 -0
- package/lib/dtls/src/record/message/reassembler.js +249 -0
- package/lib/dtls/src/record/message/reassembler.js.map +1 -0
- package/lib/dtls/src/record/receive.d.ts +6 -0
- package/lib/dtls/src/record/receive.js +58 -19
- package/lib/dtls/src/record/receive.js.map +1 -1
- package/lib/dtls/src/record/v1_3/header.d.ts +34 -0
- package/lib/dtls/src/record/v1_3/header.js +95 -0
- package/lib/dtls/src/record/v1_3/header.js.map +1 -0
- package/lib/dtls/src/record/v1_3/record.d.ts +133 -0
- package/lib/dtls/src/record/v1_3/record.js +370 -0
- package/lib/dtls/src/record/v1_3/record.js.map +1 -0
- package/lib/dtls/src/retransmission.d.ts +26 -0
- package/lib/dtls/src/retransmission.js +39 -0
- package/lib/dtls/src/retransmission.js.map +1 -0
- package/lib/dtls/src/server.d.ts +38 -0
- package/lib/dtls/src/server.js +382 -17
- package/lib/dtls/src/server.js.map +1 -1
- package/lib/dtls/src/socket.d.ts +487 -11
- package/lib/dtls/src/socket.js +1359 -70
- package/lib/dtls/src/socket.js.map +1 -1
- package/lib/dtls/src/version.d.ts +89 -0
- package/lib/dtls/src/version.js +204 -0
- package/lib/dtls/src/version.js.map +1 -0
- package/lib/ice/src/candidateError.d.ts +155 -0
- package/lib/ice/src/candidateError.js +246 -0
- package/lib/ice/src/candidateError.js.map +1 -0
- package/lib/ice/src/candidateGatherer.d.ts +127 -0
- package/lib/ice/src/candidateGatherer.js +745 -0
- package/lib/ice/src/candidateGatherer.js.map +1 -0
- package/lib/ice/src/consent.d.ts +126 -0
- package/lib/ice/src/consent.js +470 -0
- package/lib/ice/src/consent.js.map +1 -0
- package/lib/ice/src/dns/lookup.d.ts +10 -0
- package/lib/ice/src/dns/lookup.js +130 -3
- package/lib/ice/src/dns/lookup.js.map +1 -1
- package/lib/ice/src/exceptions.d.ts +9 -0
- package/lib/ice/src/exceptions.js +14 -1
- package/lib/ice/src/exceptions.js.map +1 -1
- package/lib/ice/src/failover.d.ts +270 -0
- package/lib/ice/src/failover.js +674 -0
- package/lib/ice/src/failover.js.map +1 -0
- package/lib/ice/src/gatheringError.d.ts +28 -0
- package/lib/ice/src/gatheringError.js +17 -0
- package/lib/ice/src/gatheringError.js.map +1 -0
- package/lib/ice/src/ice.d.ts +486 -78
- package/lib/ice/src/ice.js +2415 -1129
- package/lib/ice/src/ice.js.map +1 -1
- package/lib/ice/src/iceBase.d.ts +404 -14
- package/lib/ice/src/iceBase.js +251 -38
- package/lib/ice/src/iceBase.js.map +1 -1
- package/lib/ice/src/index.d.ts +3 -0
- package/lib/ice/src/index.js +5 -1
- package/lib/ice/src/index.js.map +1 -1
- package/lib/ice/src/internal/checkMessages.d.ts +41 -0
- package/lib/ice/src/internal/checkMessages.js +63 -0
- package/lib/ice/src/internal/checkMessages.js.map +1 -0
- package/lib/ice/src/internal/datagram.d.ts +37 -0
- package/lib/ice/src/internal/datagram.js +45 -0
- package/lib/ice/src/internal/datagram.js.map +1 -0
- package/lib/ice/src/internal/defaultRoute.d.ts +20 -0
- package/lib/ice/src/internal/defaultRoute.js +134 -0
- package/lib/ice/src/internal/defaultRoute.js.map +1 -0
- package/lib/ice/src/internal/hostInterfaces.d.ts +28 -0
- package/lib/ice/src/internal/hostInterfaces.js +89 -0
- package/lib/ice/src/internal/hostInterfaces.js.map +1 -0
- package/lib/ice/src/internal/hostPreference.d.ts +24 -0
- package/lib/ice/src/internal/hostPreference.js +38 -0
- package/lib/ice/src/internal/hostPreference.js.map +1 -0
- package/lib/ice/src/internal/resolveHostAddresses.d.ts +56 -8
- package/lib/ice/src/internal/resolveHostAddresses.js +127 -24
- package/lib/ice/src/internal/resolveHostAddresses.js.map +1 -1
- package/lib/ice/src/internal/selectAddresses.d.ts +27 -0
- package/lib/ice/src/internal/selectAddresses.js +37 -18
- package/lib/ice/src/internal/selectAddresses.js.map +1 -1
- package/lib/ice/src/internal/sped-bind.d.ts +44 -0
- package/lib/ice/src/internal/sped-bind.js +53 -0
- package/lib/ice/src/internal/sped-bind.js.map +1 -0
- package/lib/ice/src/internal/sped-binding-cache.d.ts +27 -0
- package/lib/ice/src/internal/sped-binding-cache.js +102 -0
- package/lib/ice/src/internal/sped-binding-cache.js.map +1 -0
- package/lib/ice/src/internal/sped.d.ts +15 -0
- package/lib/ice/src/internal/sped.js +62 -0
- package/lib/ice/src/internal/sped.js.map +1 -0
- package/lib/ice/src/nomination/regularNomination.d.ts +200 -0
- package/lib/ice/src/nomination/regularNomination.js +311 -0
- package/lib/ice/src/nomination/regularNomination.js.map +1 -0
- package/lib/ice/src/nomination/selectionController.d.ts +111 -0
- package/lib/ice/src/nomination/selectionController.js +172 -0
- package/lib/ice/src/nomination/selectionController.js.map +1 -0
- package/lib/ice/src/nomination/selectionReplacement.d.ts +178 -0
- package/lib/ice/src/nomination/selectionReplacement.js +429 -0
- package/lib/ice/src/nomination/selectionReplacement.js.map +1 -0
- package/lib/ice/src/provisional.d.ts +139 -0
- package/lib/ice/src/provisional.js +468 -0
- package/lib/ice/src/provisional.js.map +1 -0
- package/lib/ice/src/sped/draft00/codec.d.ts +20 -0
- package/lib/ice/src/sped/draft00/codec.js +59 -0
- package/lib/ice/src/sped/draft00/codec.js.map +1 -0
- package/lib/ice/src/sped/draft00/constants.d.ts +14 -0
- package/lib/ice/src/sped/draft00/constants.js +18 -0
- package/lib/ice/src/sped/draft00/constants.js.map +1 -0
- package/lib/ice/src/sped/draft00/index.d.ts +6 -0
- package/lib/ice/src/sped/draft00/index.js +26 -0
- package/lib/ice/src/sped/draft00/index.js.map +1 -0
- package/lib/ice/src/sped/draft00/mtu.d.ts +38 -0
- package/lib/ice/src/sped/draft00/mtu.js +96 -0
- package/lib/ice/src/sped/draft00/mtu.js.map +1 -0
- package/lib/ice/src/sped/draft00/session.d.ts +86 -0
- package/lib/ice/src/sped/draft00/session.js +353 -0
- package/lib/ice/src/sped/draft00/session.js.map +1 -0
- package/lib/ice/src/sped/draft00/types.d.ts +16 -0
- package/lib/ice/src/sped/draft00/types.js +3 -0
- package/lib/ice/src/sped/draft00/types.js.map +1 -0
- package/lib/ice/src/sped/runtime.d.ts +188 -0
- package/lib/ice/src/sped/runtime.js +643 -0
- package/lib/ice/src/sped/runtime.js.map +1 -0
- package/lib/ice/src/stun/protocol.d.ts +38 -2
- package/lib/ice/src/stun/protocol.js +107 -21
- package/lib/ice/src/stun/protocol.js.map +1 -1
- package/lib/ice/src/stun/rawAttributeValue.d.ts +1 -0
- package/lib/ice/src/stun/rawAttributeValue.js +6 -0
- package/lib/ice/src/stun/rawAttributeValue.js.map +1 -0
- package/lib/ice/src/stun/tcpProtocol.d.ts +2 -1
- package/lib/ice/src/stun/tcpProtocol.js +21 -9
- package/lib/ice/src/stun/tcpProtocol.js.map +1 -1
- package/lib/ice/src/stun/transaction.d.ts +4 -0
- package/lib/ice/src/stun/transaction.js +27 -2
- package/lib/ice/src/stun/transaction.js.map +1 -1
- package/lib/ice/src/turn/protocol.d.ts +23 -4
- package/lib/ice/src/turn/protocol.js +99 -11
- package/lib/ice/src/turn/protocol.js.map +1 -1
- package/lib/ice/src/types/model.d.ts +25 -5
- package/lib/ice/src/types/model.js.map +1 -1
- package/lib/ice/src/utils.d.ts +13 -0
- package/lib/ice/src/utils.js +13 -0
- package/lib/ice/src/utils.js.map +1 -1
- package/lib/ice-server/src/stun/attributes.js +4 -0
- package/lib/ice-server/src/stun/attributes.js.map +1 -1
- package/lib/ice-server/src/stun/const.d.ts +20 -1
- package/lib/ice-server/src/stun/const.js +9 -1
- package/lib/ice-server/src/stun/const.js.map +1 -1
- package/lib/ice-server/src/stun/message.d.ts +43 -3
- package/lib/ice-server/src/stun/message.js +258 -40
- package/lib/ice-server/src/stun/message.js.map +1 -1
- package/lib/ice-server/src/stun/rawAttributeValue.d.ts +6 -0
- package/lib/ice-server/src/stun/rawAttributeValue.js +12 -0
- package/lib/ice-server/src/stun/rawAttributeValue.js.map +1 -0
- package/lib/index.mjs +47427 -25303
- package/lib/nonstandard/index.mjs +3076 -1318
- package/lib/polyfill/dom.mjs +40430 -18730
- package/lib/polyfill/index.mjs +40333 -18639
- package/lib/rtp/src/extra/processor/fsRetry.d.ts +20 -0
- package/lib/rtp/src/extra/processor/fsRetry.js +73 -0
- package/lib/rtp/src/extra/processor/fsRetry.js.map +1 -0
- package/lib/rtp/src/extra/processor/webm.d.ts +6 -0
- package/lib/rtp/src/extra/processor/webm.js +6 -2
- package/lib/rtp/src/extra/processor/webm.js.map +1 -1
- package/lib/rtp/src/extra/processor/webmCallback.d.ts +11 -0
- package/lib/rtp/src/extra/processor/webmCallback.js +23 -31
- package/lib/rtp/src/extra/processor/webmCallback.js.map +1 -1
- package/lib/rtp/src/extra/processor/webmFileWriter.d.ts +24 -0
- package/lib/rtp/src/extra/processor/webmFileWriter.js +94 -0
- package/lib/rtp/src/extra/processor/webmFileWriter.js.map +1 -0
- package/lib/rtp/src/index.d.ts +1 -0
- package/lib/rtp/src/index.js +1 -0
- package/lib/rtp/src/index.js.map +1 -1
- package/lib/rtp/src/rtp/continuity.d.ts +14 -1
- package/lib/rtp/src/rtp/continuity.js +24 -4
- package/lib/rtp/src/rtp/continuity.js.map +1 -1
- package/lib/rtp/src/rtp/timelineRewriter.d.ts +178 -0
- package/lib/rtp/src/rtp/timelineRewriter.js +417 -0
- package/lib/rtp/src/rtp/timelineRewriter.js.map +1 -0
- package/lib/sctp/src/chunk.d.ts +5 -0
- package/lib/sctp/src/chunk.js +10 -0
- package/lib/sctp/src/chunk.js.map +1 -1
- package/lib/sctp/src/index.d.ts +1 -1
- package/lib/sctp/src/index.js +4 -1
- package/lib/sctp/src/index.js.map +1 -1
- package/lib/sctp/src/sctp.d.ts +86 -5
- package/lib/sctp/src/sctp.js +354 -75
- package/lib/sctp/src/sctp.js.map +1 -1
- package/lib/webrtc/src/api/compatibilityOptions.d.ts +43 -0
- package/lib/webrtc/src/api/compatibilityOptions.js +43 -0
- package/lib/webrtc/src/api/compatibilityOptions.js.map +1 -0
- package/lib/webrtc/src/api/peerConfig.d.ts +547 -36
- package/lib/webrtc/src/api/peerConfig.js +187 -26
- package/lib/webrtc/src/api/peerConfig.js.map +1 -1
- package/lib/webrtc/src/api/peerConnectionEvents.d.ts +87 -2
- package/lib/webrtc/src/api/peerConnectionEvents.js +105 -1
- package/lib/webrtc/src/api/peerConnectionEvents.js.map +1 -1
- package/lib/webrtc/src/dataChannel.d.ts +122 -10
- package/lib/webrtc/src/dataChannel.js +214 -20
- package/lib/webrtc/src/dataChannel.js.map +1 -1
- package/lib/webrtc/src/helper.d.ts +8 -0
- package/lib/webrtc/src/helper.js +40 -4
- package/lib/webrtc/src/helper.js.map +1 -1
- package/lib/webrtc/src/media/codecCompatibility.d.ts +87 -1
- package/lib/webrtc/src/media/codecCompatibility.js +338 -12
- package/lib/webrtc/src/media/codecCompatibility.js.map +1 -1
- package/lib/webrtc/src/media/domEventTarget.d.ts +55 -0
- package/lib/webrtc/src/media/domEventTarget.js +216 -0
- package/lib/webrtc/src/media/domEventTarget.js.map +1 -0
- package/lib/webrtc/src/media/index.d.ts +2 -0
- package/lib/webrtc/src/media/index.js +1 -0
- package/lib/webrtc/src/media/index.js.map +1 -1
- package/lib/webrtc/src/media/parameters.d.ts +5 -0
- package/lib/webrtc/src/media/parameters.js +10 -0
- package/lib/webrtc/src/media/parameters.js.map +1 -1
- package/lib/webrtc/src/media/receiver/nack.d.ts +43 -10
- package/lib/webrtc/src/media/receiver/nack.js +245 -88
- package/lib/webrtc/src/media/receiver/nack.js.map +1 -1
- package/lib/webrtc/src/media/receiver/receiverTwcc.d.ts +10 -0
- package/lib/webrtc/src/media/receiver/receiverTwcc.js +4 -10
- package/lib/webrtc/src/media/receiver/receiverTwcc.js.map +1 -1
- package/lib/webrtc/src/media/router.d.ts +245 -51
- package/lib/webrtc/src/media/router.js +702 -237
- package/lib/webrtc/src/media/router.js.map +1 -1
- package/lib/webrtc/src/media/routing/pendingRoutes.d.ts +26 -0
- package/lib/webrtc/src/media/routing/pendingRoutes.js +48 -0
- package/lib/webrtc/src/media/routing/pendingRoutes.js.map +1 -0
- package/lib/webrtc/src/media/routing/ridRouting.d.ts +37 -0
- package/lib/webrtc/src/media/routing/ridRouting.js +74 -0
- package/lib/webrtc/src/media/routing/ridRouting.js.map +1 -0
- package/lib/webrtc/src/media/routing/routeTable.d.ts +60 -0
- package/lib/webrtc/src/media/routing/routeTable.js +95 -0
- package/lib/webrtc/src/media/routing/routeTable.js.map +1 -0
- package/lib/webrtc/src/media/routing/rtcpRouting.d.ts +34 -0
- package/lib/webrtc/src/media/routing/rtcpRouting.js +165 -0
- package/lib/webrtc/src/media/routing/rtcpRouting.js.map +1 -0
- package/lib/webrtc/src/media/routing/unknownSsrc.d.ts +55 -0
- package/lib/webrtc/src/media/routing/unknownSsrc.js +117 -0
- package/lib/webrtc/src/media/routing/unknownSsrc.js.map +1 -0
- package/lib/webrtc/src/media/rtpReceiver.d.ts +277 -5
- package/lib/webrtc/src/media/rtpReceiver.js +826 -36
- package/lib/webrtc/src/media/rtpReceiver.js.map +1 -1
- package/lib/webrtc/src/media/rtpSender.d.ts +8 -1
- package/lib/webrtc/src/media/rtpSender.js +13 -6
- package/lib/webrtc/src/media/rtpSender.js.map +1 -1
- package/lib/webrtc/src/media/rtpTransceiver.d.ts +47 -11
- package/lib/webrtc/src/media/rtpTransceiver.js +95 -11
- package/lib/webrtc/src/media/rtpTransceiver.js.map +1 -1
- package/lib/webrtc/src/media/sender/senderReportHistory.d.ts +51 -0
- package/lib/webrtc/src/media/sender/senderReportHistory.js +111 -0
- package/lib/webrtc/src/media/sender/senderReportHistory.js.map +1 -0
- package/lib/webrtc/src/media/sender/senderStats.d.ts +6 -5
- package/lib/webrtc/src/media/sender/senderStats.js +14 -19
- package/lib/webrtc/src/media/sender/senderStats.js.map +1 -1
- package/lib/webrtc/src/media/stats.d.ts +13 -0
- package/lib/webrtc/src/media/stats.js.map +1 -1
- package/lib/webrtc/src/media/track.d.ts +112 -11
- package/lib/webrtc/src/media/track.js +250 -19
- package/lib/webrtc/src/media/track.js.map +1 -1
- package/lib/webrtc/src/media/trackConstraints.d.ts +80 -0
- package/lib/webrtc/src/media/trackConstraints.js +141 -0
- package/lib/webrtc/src/media/trackConstraints.js.map +1 -0
- package/lib/webrtc/src/negotiation/internalState.d.ts +0 -4
- package/lib/webrtc/src/negotiation/internalState.js +0 -11
- package/lib/webrtc/src/negotiation/internalState.js.map +1 -1
- package/lib/webrtc/src/negotiation/remoteCandidates.d.ts +20 -1
- package/lib/webrtc/src/negotiation/remoteCandidates.js +29 -1
- package/lib/webrtc/src/negotiation/remoteCandidates.js.map +1 -1
- package/lib/webrtc/src/negotiation/remoteMediaApplication.d.ts +23 -6
- package/lib/webrtc/src/negotiation/remoteMediaApplication.js +46 -22
- package/lib/webrtc/src/negotiation/remoteMediaApplication.js.map +1 -1
- package/lib/webrtc/src/negotiation/transceiverPairing.d.ts +1 -0
- package/lib/webrtc/src/negotiation/transceiverPairing.js +62 -0
- package/lib/webrtc/src/negotiation/transceiverPairing.js.map +1 -0
- package/lib/webrtc/src/negotiation/transportActivation.d.ts +12 -1
- package/lib/webrtc/src/negotiation/transportActivation.js +133 -11
- package/lib/webrtc/src/negotiation/transportActivation.js.map +1 -1
- package/lib/webrtc/src/negotiationTransaction.d.ts +57 -5
- package/lib/webrtc/src/negotiationTransaction.js +134 -10
- package/lib/webrtc/src/negotiationTransaction.js.map +1 -1
- package/lib/webrtc/src/nonstandard/dummyMedia.d.ts +6 -0
- package/lib/webrtc/src/nonstandard/dummyMedia.js +14 -19
- package/lib/webrtc/src/nonstandard/dummyMedia.js.map +1 -1
- package/lib/webrtc/src/nonstandard/navigator.d.ts +1 -1
- package/lib/webrtc/src/nonstandard/recorder/index.js +5 -1
- package/lib/webrtc/src/nonstandard/recorder/index.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.d.ts +6 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js +31 -2
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js.map +1 -1
- package/lib/webrtc/src/nonstandard/userMedia/packetizer.d.ts +16 -0
- package/lib/webrtc/src/nonstandard/userMedia/packetizer.js +25 -0
- package/lib/webrtc/src/nonstandard/userMedia/packetizer.js.map +1 -1
- package/lib/webrtc/src/nonstandard/userMedia.js +6 -13
- package/lib/webrtc/src/nonstandard/userMedia.js.map +1 -1
- package/lib/webrtc/src/peerConnection.d.ts +106 -11
- package/lib/webrtc/src/peerConnection.js +370 -36
- package/lib/webrtc/src/peerConnection.js.map +1 -1
- package/lib/webrtc/src/polyfill/api.d.ts +2 -1
- package/lib/webrtc/src/polyfill/api.js +3 -3
- package/lib/webrtc/src/polyfill/api.js.map +1 -1
- package/lib/webrtc/src/polyfill/dom.d.ts +21 -7
- package/lib/webrtc/src/polyfill/dom.js +15 -0
- package/lib/webrtc/src/polyfill/dom.js.map +1 -1
- package/lib/webrtc/src/polyfill/globals.d.ts +8 -3
- package/lib/webrtc/src/polyfill/globals.js.map +1 -1
- package/lib/webrtc/src/polyfill/index.d.ts +1 -1
- package/lib/webrtc/src/polyfill/index.js +1 -1
- package/lib/webrtc/src/polyfill/index.js.map +1 -1
- package/lib/webrtc/src/polyfill/install.d.ts +5 -1
- package/lib/webrtc/src/polyfill/install.js +4 -2
- package/lib/webrtc/src/polyfill/install.js.map +1 -1
- package/lib/webrtc/src/polyfill/mediaDevices.js +28 -4
- package/lib/webrtc/src/polyfill/mediaDevices.js.map +1 -1
- package/lib/webrtc/src/polyfill/peerConnectionConfig.d.ts +6 -0
- package/lib/webrtc/src/polyfill/peerConnectionConfig.js +15 -4
- package/lib/webrtc/src/polyfill/peerConnectionConfig.js.map +1 -1
- package/lib/webrtc/src/polyfill/selectSettings.d.ts +4 -14
- package/lib/webrtc/src/polyfill/selectSettings.js +10 -106
- package/lib/webrtc/src/polyfill/selectSettings.js.map +1 -1
- package/lib/webrtc/src/polyfill/sourceIo.d.ts +1 -2
- package/lib/webrtc/src/polyfill/sourceIo.js +6 -6
- package/lib/webrtc/src/polyfill/sourceIo.js.map +1 -1
- package/lib/webrtc/src/sctpManager.d.ts +31 -18
- package/lib/webrtc/src/sctpManager.js +162 -38
- package/lib/webrtc/src/sctpManager.js.map +1 -1
- package/lib/webrtc/src/sdp.d.ts +107 -2
- package/lib/webrtc/src/sdp.js +223 -17
- package/lib/webrtc/src/sdp.js.map +1 -1
- package/lib/webrtc/src/sdpManager.d.ts +101 -10
- package/lib/webrtc/src/sdpManager.js +236 -14
- package/lib/webrtc/src/sdpManager.js.map +1 -1
- package/lib/webrtc/src/secureTransportManager.d.ts +49 -3
- package/lib/webrtc/src/secureTransportManager.js +166 -12
- package/lib/webrtc/src/secureTransportManager.js.map +1 -1
- package/lib/webrtc/src/transceiverManager.d.ts +87 -6
- package/lib/webrtc/src/transceiverManager.js +272 -51
- package/lib/webrtc/src/transceiverManager.js.map +1 -1
- package/lib/webrtc/src/transport/dtls-application-gate.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-application-gate.js +143 -0
- package/lib/webrtc/src/transport/dtls-application-gate.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-attempt.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-attempt.js +79 -0
- package/lib/webrtc/src/transport/dtls-attempt.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-certificate.d.ts +24 -0
- package/lib/webrtc/src/transport/dtls-certificate.js +98 -0
- package/lib/webrtc/src/transport/dtls-certificate.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-fingerprint.d.ts +7 -0
- package/lib/webrtc/src/transport/dtls-fingerprint.js +66 -0
- package/lib/webrtc/src/transport/dtls-fingerprint.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-ice-transport.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-ice-transport.js +123 -0
- package/lib/webrtc/src/transport/dtls-ice-transport.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-media-queue.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-media-queue.js +95 -0
- package/lib/webrtc/src/transport/dtls-media-queue.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-readiness.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-readiness.js +173 -0
- package/lib/webrtc/src/transport/dtls-readiness.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-sped-handshake.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-sped-handshake.js +146 -0
- package/lib/webrtc/src/transport/dtls-sped-handshake.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-srtp.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-srtp.js +133 -0
- package/lib/webrtc/src/transport/dtls-srtp.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-stats.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-stats.js +134 -0
- package/lib/webrtc/src/transport/dtls-stats.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-types.d.ts +23 -0
- package/lib/webrtc/src/transport/dtls-types.js +11 -0
- package/lib/webrtc/src/transport/dtls-types.js.map +1 -0
- package/lib/webrtc/src/transport/dtls.d.ts +236 -47
- package/lib/webrtc/src/transport/dtls.js +1198 -441
- package/lib/webrtc/src/transport/dtls.js.map +1 -1
- package/lib/webrtc/src/transport/ice.d.ts +95 -5
- package/lib/webrtc/src/transport/ice.js +323 -21
- package/lib/webrtc/src/transport/ice.js.map +1 -1
- package/lib/webrtc/src/transport/iceCandidateAttribute.d.ts +4 -2
- package/lib/webrtc/src/transport/iceCandidateAttribute.js.map +1 -1
- package/lib/webrtc/src/transport/sctp.d.ts +149 -2
- package/lib/webrtc/src/transport/sctp.js +826 -128
- package/lib/webrtc/src/transport/sctp.js.map +1 -1
- package/lib/webrtc/src/transport/sped.d.ts +139 -0
- package/lib/webrtc/src/transport/sped.js +757 -0
- package/lib/webrtc/src/transport/sped.js.map +1 -0
- package/lib/webrtc/src/types/util.d.ts +6 -0
- package/lib/webrtc/src/types/util.js.map +1 -1
- package/lib/webrtc/src/utils.d.ts +34 -1
- package/lib/webrtc/src/utils.js +52 -3
- package/lib/webrtc/src/utils.js.map +1 -1
- package/lib/webrtc/src/webidl.d.ts +15 -0
- package/lib/webrtc/src/webidl.js +34 -0
- package/lib/webrtc/src/webidl.js.map +1 -0
- package/package.json +8 -3
- package/lib/webrtc/src/polyfill/rtcSessionDescription.d.ts +0 -18
- package/lib/webrtc/src/polyfill/rtcSessionDescription.js +0 -36
- package/lib/webrtc/src/polyfill/rtcSessionDescription.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectionReplacement.js","sourceRoot":"","sources":["../../../../../ice/src/nomination/selectionReplacement.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAA+C;AAC/C,wCAAoE;AACpE,8CAAwD;AAIxD,MAAM,GAAG,GAAG,IAAA,cAAK,EACf,wEAAwE,CACzE,CAAC;AAEF;;;;;GAKG;AACU,QAAA,0BAA0B,GAAG;IACxC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK;CACrB,CAAC;AA6DX;;;;;;;;;;;GAWG;AACH,MAAa,oBAAoB;IA6B/B;;;;;;;;OAQG;IACH,eAAe;QACb,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACtC,IACE,CAAC,QAAQ;YACT,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAClB,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACxB,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAC9B,CAAC;YACD,OAAO;QACT,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;YACzC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC;gBAAE,SAAS;YACtD,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACnC,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,KA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AAC;QACH,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;QAChC,CAAC;IACH,CAAC;IAID,YAAY,IAAmB;QA7V/B;;;;WAIG;QACK;;;;;WAGN;QACF,wEAAwE;QAChE;;;;mBAAkB,CAAC;WAAC;QAC5B,yCAAyC;QACjC;;;;mBAAmB,KAAK;WAAC;QACjC;;;;WAIG;QACc;;;;mBAAW,IAAI,OAAO,EAAyB;WAAC;QACzD;;;;mBAAe,CAAC;WAAC;QACzB;;;WAGG;QACc;;;;mBAAU,IAAI,GAAG,EAG/B;WAAC;QAgUa;;;;;WAAoB;QAGnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,qDAAqD;IACrD,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC;IACrC,CAAC;IAED,mEAAmE;IACnE,mBAAmB;QACjB,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;CACF;AA3WD,oDA2WC","sourcesContent":["import * as timers from \"node:timers/promises\";\nimport { type CandidatePair, CandidatePairState } from \"../iceBase\";\nimport { type Address, debug } from \"../imports/common\";\nimport type { Protocol } from \"../types/model\";\nimport type { NominationOutcome } from \"./regularNomination\";\n\nconst log = debug(\n \"werift-ice : packages/ice/src/nomination/selectionReplacement.ts : log\",\n);\n\n/**\n * Semi-aggressive nomination and renomination: delays before a failed pair\n * that outranks the selection is checked again (`retryOutrankingPair`), one\n * per retry. As libwebrtc keeps pinging a connection until it has heard\n * nothing for 30 s, the retries end about 31 s after the failure.\n */\nexport const OUTRANKING_RETRY_DELAYS_MS = [\n 1000, 2000, 4000, 8000, 16000,\n] as const;\n\n/** What the agent supplies to its `SelectionReplacement`. */\nexport type SelectionHost = {\n /** The live checklist, highest priority first. */\n checkList: () => readonly CandidatePair[];\n /** The selected pair (`Connection.nominated`). */\n selected: () => CandidatePair | undefined;\n controlling: () => boolean;\n closed: () => boolean;\n remoteGeneration: () => number;\n usesRenomination: () => boolean;\n usesSemiAggressiveNomination: () => boolean;\n /** The controlling agent may move the selection to a higher-priority pair. */\n replacesSelection: () => boolean;\n /** A pair semi-aggressive nomination and renomination may select (not ICE-TCP, checked locally). */\n replacesWith: (pair: CandidatePair) => boolean;\n outranks: (pair: CandidatePair, other: CandidatePair) => boolean;\n bestValidPair: (pairs: CandidatePair[]) => CandidatePair | undefined;\n isTcpPair: (pair: CandidatePair) => boolean;\n /** Start the ordinary check of `pair` (its handle is kept on the pair). */\n check: (pair: CandidatePair) => void;\n /** Apply the outcome of `pair` (`Connection.checkComplete`). */\n complete: (pair: CandidatePair) => void;\n /** Send the nominating check (USE-CANDIDATE, or NOMINATION `value`); never rejects. */\n sendNomination: (\n pair: CandidatePair,\n signal: AbortSignal,\n value?: number,\n ) => Promise<NominationOutcome>;\n /** A nomination of `pair` sent in remote `generation` no longer applies. */\n isStaleNomination: (pair: CandidatePair, generation: number) => boolean;\n /** 487: the peer is controlling and wins; the agent becomes controlled. */\n roleConflict: () => void;\n /**\n * Failover: `pair` may be nominated to move the selection up (its socket\n * is not one the agent failed over from and has not recovered yet, and it\n * is not known to be unwritable). Unset: every pair.\n */\n allows?: (pair: CandidatePair) => boolean;\n /**\n * Failover (controlling): the nominated `pair` replaces the selection\n * whatever its priority (the selection stopped answering, or it is the\n * failover nomination's pair).\n */\n failoverReplaces?: (pair: CandidatePair) => boolean;\n /** The nominating check of `pair` ended (any outcome, or aborted). */\n nominationEnded?: (pair: CandidatePair) => void;\n /**\n * Failover applies (`Connection.failoverEnabled`): the retries of failed\n * pairs that outrank the selection go on every last delay (16 s) instead\n * of stopping after `OUTRANKING_RETRY_DELAYS_MS`.\n */\n retriesForever?: () => boolean;\n /**\n * Controlled agent: the selected pair stopped answering (failover), so a\n * nomination of the peer equal to the selection's replaces it.\n */\n selectionDown?: () => boolean;\n};\n\n/**\n * Semi-aggressive nomination and renomination (as libwebrtc): how a selection\n * is replaced after the first one.\n *\n * - Controlling: the pairs that outrank the selection go on being checked\n * (`checkOutrankingPairs`), a failed one again after\n * `OUTRANKING_RETRY_DELAYS_MS` (`scheduleRetries`), and the best valid pair\n * is nominated with a separate check when no check of it did\n * (`evaluate`; renomination sends increasing NOMINATION values).\n * - Controlled: between equal nominations the pair the peer sends data on\n * wins (`controlledDataReceived`, `replaces`).\n */\nexport class SelectionReplacement {\n /**\n * Semi-aggressive nomination or renomination: the separate check that\n * nominates a valid pair which outranks the selection (see\n * `evaluate`). One at a time.\n */\n private inFlight?: {\n pair: CandidatePair;\n abort: AbortController;\n };\n /** The last NOMINATION value sent (renomination); it only increases. */\n private nominationValue = 0;\n /** `checkOutrankingPairs` is running. */\n private outrankingChecks = false;\n /**\n * Controlled agent: when each live pair last received application data\n * (an increasing sequence, larger is more recent). Between nominated pairs\n * of equal nomination, the one the peer sends on wins (`replaces`).\n */\n private readonly lastData = new WeakMap<CandidatePair, number>();\n private dataSequence = 0;\n /**\n * Retries of failed pairs that outrank the selection\n * (`scheduleRetries`): how many ran, and the pending timer.\n */\n private readonly retries = new Map<\n CandidatePair,\n { retries: number; timer?: ReturnType<typeof setTimeout> }\n >();\n /**\n * Semi-aggressive nomination and renomination (controlling): a pair that\n * outranks the selection but failed (a check or nomination that went\n * unanswered, e.g. while the path was briefly down) is checked again after\n * `OUTRANKING_RETRY_DELAYS_MS`, as libwebrtc keeps pinging its\n * connections. Without it the agents stay on the lower path when the\n * peer does not trigger a check on that pair either (e.g. its own check\n * failed too). Each pair waits for one retry at a time.\n */\n scheduleRetries() {\n const selected = this.host.selected();\n if (\n !selected ||\n this.host.closed() ||\n !this.host.controlling() ||\n !this.host.replacesSelection()\n ) {\n return;\n }\n for (const pair of this.host.checkList()) {\n if (!this.retriesOutranking(pair, selected)) continue;\n let entry = this.retries.get(pair);\n if (!entry) {\n entry = { retries: 0 };\n this.retries.set(pair, entry);\n }\n const forever = this.host.retriesForever?.() ?? false;\n if (\n entry.timer !== undefined ||\n (!forever && entry.retries >= OUTRANKING_RETRY_DELAYS_MS.length)\n ) {\n continue;\n }\n const current = entry;\n const remoteGeneration = this.host.remoteGeneration();\n const delay =\n OUTRANKING_RETRY_DELAYS_MS[\n Math.min(current.retries, OUTRANKING_RETRY_DELAYS_MS.length - 1)\n ];\n current.timer = setTimeout(() => {\n current.timer = undefined;\n current.retries++;\n this.retryOutrankingPair(pair, remoteGeneration);\n }, delay);\n }\n }\n\n /**\n * Failover (controlling): the selection stopped answering and no backup\n * is writable, so the failed pairs that outrank it are checked at once\n * instead of waiting for their next retry (libwebrtc pings at its strong\n * interval when no connection is writable). One check per pair at a time:\n * a pair being checked is not Failed.\n */\n checkFailedOutranking() {\n const selected = this.host.selected();\n if (\n !selected ||\n this.host.closed() ||\n !this.host.controlling() ||\n !this.host.replacesSelection()\n ) {\n return;\n }\n for (const pair of this.host.checkList()) {\n if (!this.retriesOutranking(pair, selected)) continue;\n log(\"check failed outranking pair at once\", pair.toJSON());\n this.host.check(pair);\n }\n }\n\n /** `pair` failed, outranks `selected` and may replace it. */\n private retriesOutranking(pair: CandidatePair, selected: CandidatePair) {\n return (\n pair.state === CandidatePairState.FAILED &&\n this.host.replacesWith(pair) &&\n this.host.outranks(pair, selected) &&\n this.allows(pair)\n );\n }\n\n /** A retry of `scheduleRetries` is due: check `pair` again. */\n private retryOutrankingPair(pair: CandidatePair, remoteGeneration: number) {\n const selected = this.host.selected();\n if (\n !selected ||\n this.host.closed() ||\n this.host.remoteGeneration() !== remoteGeneration ||\n !this.host.controlling() ||\n !this.host.replacesSelection() ||\n !this.host.checkList().includes(pair) ||\n !this.retriesOutranking(pair, selected)\n ) {\n return;\n }\n log(\"retry outranking pair\", pair.toJSON());\n // One check per due retry (each pair has its own timer), so it starts\n // at once instead of waiting for the paced `checkOutrankingPairs`.\n this.host.check(pair);\n }\n\n /** `pair` succeeded: its retries of `scheduleRetries` are over. */\n forgetRetry(pair: CandidatePair) {\n const entry = this.retries.get(pair);\n if (!entry) return;\n if (entry.timer !== undefined) clearTimeout(entry.timer);\n this.retries.delete(pair);\n }\n\n /** Stop the retries of `scheduleRetries` (restart, close, role change). */\n clearRetries() {\n for (const entry of this.retries.values()) {\n if (entry.timer !== undefined) clearTimeout(entry.timer);\n }\n this.retries.clear();\n }\n\n /**\n * Whether the nominated `pair` replaces the selected pair:\n * - controlled: the peer's larger nomination (the NOMINATION value;\n * USE-CANDIDATE counts as 1, as in libwebrtc), the higher-priority pair\n * between equal ones (RFC 5245 §8.1.1.2: the highest-priority nominated\n * pair is used). A controlling peer nominating once (regular nomination)\n * never causes a switch.\n * - controlling with renomination: the pair renominated last.\n * - controlling, semi-aggressive: a higher-priority pair.\n * - controlling, regular nomination or toward ICE-lite: never.\n */\n replaces(pair: CandidatePair) {\n const selected = this.host.selected();\n if (!selected || selected === pair) return false;\n if (!this.host.controlling()) {\n if (pair.remoteNomination !== selected.remoteNomination) {\n return pair.remoteNomination > selected.remoteNomination;\n }\n // Failover: the selected pair stopped answering and the peer\n // nominates a valid pair as strongly as the selection (USE-CANDIDATE\n // again): it replaces the selection without waiting for data, as\n // libwebrtc's controlled agent ranks a writable connection first.\n if (\n this.host.selectionDown?.() &&\n pair.state === CandidatePairState.SUCCEEDED\n ) {\n return true;\n }\n // Equal nominations: the pair the peer last sent data on, as libwebrtc\n // (the peer's own selection may move to a lower-priority pair, e.g.\n // when the selected one stopped working).\n const received = this.lastData.get(pair) ?? 0;\n const selectedReceived = this.lastData.get(selected) ?? 0;\n if (received !== selectedReceived) return received > selectedReceived;\n return this.host.outranks(pair, selected);\n }\n if (!this.host.replacesWith(pair)) return false;\n if (this.host.failoverReplaces?.(pair)) return true;\n if (this.host.usesRenomination())\n return pair.nomination > selected.nomination;\n if (this.host.usesSemiAggressiveNomination()) {\n return this.host.outranks(pair, selected);\n }\n return false;\n }\n\n /**\n * Controlled agent: application data arrived on the live pair of\n * `protocol` and `addr`. Record it (`lastData`) and, when the pair is\n * nominated but not selected, let it replace the selection if the peer\n * now sends on it (`replaces`). ICE-TCP pairs only record:\n * selecting one prunes the other TCP connections.\n */\n controlledDataReceived(protocol: Protocol, addr: Address) {\n const selected = this.host.selected();\n const sameAddress = (pair: CandidatePair) =>\n pair.protocol === protocol &&\n pair.remoteAddr[0] === addr[0] &&\n pair.remoteAddr[1] === addr[1];\n const pair =\n selected && sameAddress(selected)\n ? selected\n : this.host.checkList().find(sameAddress);\n if (!pair) return;\n this.lastData.set(pair, ++this.dataSequence);\n if (\n pair !== selected &&\n pair.nominated &&\n pair.state === CandidatePairState.SUCCEEDED &&\n !this.host.isTcpPair(pair) &&\n this.replaces(pair)\n ) {\n this.host.complete(pair);\n }\n }\n\n /**\n * Semi-aggressive nomination and renomination: nominate the best valid\n * pair with a separate check when it outranks the selection (or nothing is\n * selected yet) and no check of it nominated it already. With renomination\n * ordinary checks never nominate; with semi-aggressive nomination a pair\n * whose check went without USE-CANDIDATE (sent while controlled) still\n * needs one. One such check at a time; its outcome re-evaluates.\n */\n evaluate() {\n if (!this.host.replacesSelection() || this.inFlight || this.host.closed()) {\n return;\n }\n const renomination = this.host.usesRenomination();\n const best = this.host.bestValidPair(\n this.host\n .checkList()\n .filter((pair) => this.host.replacesWith(pair) && this.allows(pair)),\n );\n const selected = this.host.selected();\n if (!best || best === selected) return;\n if (selected && !this.host.outranks(best, selected)) return;\n // Semi-aggressive: the USE-CANDIDATE check that succeeded selected it.\n if (!renomination && best.nominated) return;\n void this.nominateSelection(best, renomination);\n }\n\n /**\n * Failover (controlling): nominate `pair` now (USE-CANDIDATE, or the next\n * NOMINATION value), whatever its priority; its success moves the\n * selection (`replaces` with `failoverReplaces`).\n */\n nominate(pair: CandidatePair) {\n if (this.inFlight || this.host.closed()) return;\n void this.nominateSelection(pair, this.host.usesRenomination());\n }\n\n private allows(pair: CandidatePair) {\n return this.host.allows?.(pair) ?? true;\n }\n\n private async nominateSelection(pair: CandidatePair, renomination: boolean) {\n const current = { pair, abort: new AbortController() };\n this.inFlight = current;\n const value = renomination ? ++this.nominationValue : undefined;\n const remoteGeneration = this.host.remoteGeneration();\n log(\"nominate selection\", pair.toJSON(), { nomination: value });\n const outcome = await this.host.sendNomination(\n pair,\n current.abort.signal,\n value,\n );\n // A role change, restart or close replaced it.\n if (this.inFlight !== current) return;\n this.inFlight = undefined;\n if (this.host.isStaleNomination(pair, remoteGeneration)) {\n this.host.nominationEnded?.(pair);\n return;\n }\n if (outcome === \"nominated\") {\n if (value !== undefined) pair.nomination = value;\n pair.nominated = true;\n this.host.complete(pair);\n this.host.nominationEnded?.(pair);\n return;\n }\n this.host.nominationEnded?.(pair);\n if (outcome === \"role-conflict\") {\n // 487: the peer is controlling and wins; it nominates.\n this.host.roleConflict();\n return;\n }\n // Not taken (an error, or no answer): the pair is not used and the next\n // best valid pair is considered (checkComplete re-evaluates).\n log(\"selection nomination failed\", pair.toJSON(), outcome);\n pair.updateState(CandidatePairState.FAILED);\n this.host.complete(pair);\n }\n\n abort() {\n const inFlight = this.inFlight;\n inFlight?.abort.abort();\n this.inFlight = undefined;\n if (inFlight) this.host.nominationEnded?.(inFlight.pair);\n }\n\n /**\n * After the first selection (semi-aggressive nomination, renomination):\n * check the pairs that outrank the selected one, paced like the ordinary\n * schedule. A pair added later that outranks it (a trickled candidate, a\n * late relay allocation) restarts it (`addPair`).\n */\n async checkOutrankingPairs() {\n if (this.outrankingChecks) return;\n this.outrankingChecks = true;\n const remoteGeneration = this.host.remoteGeneration();\n try {\n for (;;) {\n const selected = this.host.selected();\n if (\n !selected ||\n this.host.closed() ||\n this.host.remoteGeneration() !== remoteGeneration ||\n !this.host.controlling() ||\n !this.host.replacesSelection()\n ) {\n return;\n }\n const pair = this.host\n .checkList()\n .find(\n (pair) =>\n (pair.state === CandidatePairState.WAITING ||\n pair.state === CandidatePairState.FROZEN) &&\n this.host.replacesWith(pair) &&\n this.host.outranks(pair, selected) &&\n this.allows(pair),\n );\n if (!pair) return;\n this.host.check(pair);\n await timers.setTimeout(20);\n }\n } finally {\n this.outrankingChecks = false;\n }\n }\n\n private readonly host: SelectionHost;\n\n constructor(host: SelectionHost) {\n this.host = host;\n }\n\n /** A nominating check of `evaluate` is in flight. */\n get nominating() {\n return this.inFlight !== undefined;\n }\n\n /** The next NOMINATION value (renomination); it only increases. */\n nextNominationValue() {\n return ++this.nominationValue;\n }\n}\n"]}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { Candidate } from "./candidate";
|
|
2
|
+
import type { MdnsLookup } from "./dns/lookup";
|
|
3
|
+
import { CandidatePair, type IceOptions } from "./iceBase";
|
|
4
|
+
import { type Address } from "./imports/common";
|
|
5
|
+
import { type NominationOutcome, RegularNomination } from "./nomination/regularNomination";
|
|
6
|
+
import type { Message } from "./stun/message";
|
|
7
|
+
import type { Protocol } from "./types/model";
|
|
8
|
+
/**
|
|
9
|
+
* The checklist of an ICE restart negotiated with a pranswer: checked beside
|
|
10
|
+
* the selected pair of the live checklist, which keeps carrying data until
|
|
11
|
+
* the final answer commits (or discards) the restart.
|
|
12
|
+
*/
|
|
13
|
+
export type ProvisionalGeneration = {
|
|
14
|
+
localUsername: string;
|
|
15
|
+
localPassword: string;
|
|
16
|
+
/** The options the staged generation gathers with (stageLocalCredentials). */
|
|
17
|
+
gatherOptions?: Partial<IceOptions>;
|
|
18
|
+
remoteUsername?: string;
|
|
19
|
+
remotePassword?: string;
|
|
20
|
+
remoteCandidates: Candidate[];
|
|
21
|
+
remoteCandidatesEnd: boolean;
|
|
22
|
+
/** End-of-candidates arrived; waiting for earlier mDNS resolutions. */
|
|
23
|
+
remoteCandidatesEndRequested: boolean;
|
|
24
|
+
resolutions: Set<Promise<string>>;
|
|
25
|
+
/** Incremented when a replacement pranswer restarts this checklist. */
|
|
26
|
+
revision: number;
|
|
27
|
+
pairs: CandidatePair[];
|
|
28
|
+
nominated?: CandidatePair;
|
|
29
|
+
/** The ICE-lite nomination (first valid pair) is in flight. */
|
|
30
|
+
liteNominating?: boolean;
|
|
31
|
+
/** Regular nomination toward a full ICE peer (shares the live rules). */
|
|
32
|
+
nomination: RegularNomination;
|
|
33
|
+
started: boolean;
|
|
34
|
+
/** Aborts the checks in flight when the checklist is replaced or dropped. */
|
|
35
|
+
checks: AbortController;
|
|
36
|
+
};
|
|
37
|
+
/** What the agent supplies to its `ProvisionalChecklist`. */
|
|
38
|
+
export type ProvisionalHost = {
|
|
39
|
+
closed: () => boolean;
|
|
40
|
+
iceLite: () => boolean;
|
|
41
|
+
iceControlling: () => boolean;
|
|
42
|
+
remoteIsLite: () => boolean;
|
|
43
|
+
localCandidatesEnd: () => boolean;
|
|
44
|
+
options: () => IceOptions;
|
|
45
|
+
/** The agent's sockets and TURN allocations. */
|
|
46
|
+
protocols: () => readonly Protocol[];
|
|
47
|
+
/** The agent's mDNS resolver (created on first use). */
|
|
48
|
+
mdnsLookup: () => MdnsLookup;
|
|
49
|
+
/** A pair the agent never checks itself (forceTurn). */
|
|
50
|
+
isUncheckedPair: (pair: CandidatePair) => boolean;
|
|
51
|
+
/** A wildcard socket (`CandidateGatherer.isWildcardProtocol`). */
|
|
52
|
+
isWildcardProtocol: (protocol: Protocol) => boolean;
|
|
53
|
+
/**
|
|
54
|
+
* The wildcard socket should check `remoteCandidate`: no host socket
|
|
55
|
+
* covers its path (`CandidateGatherer.wildcardPathUncovered`).
|
|
56
|
+
*/
|
|
57
|
+
wildcardPathUncovered: (remoteCandidate: Candidate) => Promise<boolean>;
|
|
58
|
+
/** Full ICE on both sides and this agent controlling. */
|
|
59
|
+
nominatesFullPeer: () => boolean;
|
|
60
|
+
usesRegularNomination: () => boolean;
|
|
61
|
+
/** A pair semi-aggressive nomination and renomination may select. */
|
|
62
|
+
replacesWith: (pair: CandidatePair) => boolean;
|
|
63
|
+
/** The pairs `RegularNomination` nominates from. */
|
|
64
|
+
regularNominationPairs: (pairs: readonly CandidatePair[]) => readonly CandidatePair[];
|
|
65
|
+
bestValidPair: (pairs: CandidatePair[]) => CandidatePair | undefined;
|
|
66
|
+
outranks: (pair: CandidatePair, other: CandidatePair) => boolean;
|
|
67
|
+
nominationDelayMs: () => number;
|
|
68
|
+
buildRequest: (params: {
|
|
69
|
+
nominate: boolean;
|
|
70
|
+
localUsername: string;
|
|
71
|
+
remoteUsername: string;
|
|
72
|
+
iceControlling: boolean;
|
|
73
|
+
localCandidate: Candidate;
|
|
74
|
+
}) => Message;
|
|
75
|
+
switchRole: (iceControlling: boolean) => void;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* The provisional generation of an ICE restart (`ProvisionalGeneration`):
|
|
79
|
+
* staged by `stage()` with the local credentials of the restart offer,
|
|
80
|
+
* given the pranswer's credentials and candidates, checked (`start()`) and
|
|
81
|
+
* nominated with the same rules as the live checklist, and dropped by
|
|
82
|
+
* `end()` when the final answer commits or discards the restart. It never
|
|
83
|
+
* touches the live checklist.
|
|
84
|
+
*/
|
|
85
|
+
export declare class ProvisionalChecklist {
|
|
86
|
+
/** The staged generation, if any. */
|
|
87
|
+
generation?: ProvisionalGeneration;
|
|
88
|
+
private readonly host;
|
|
89
|
+
constructor(host: ProvisionalHost);
|
|
90
|
+
/**
|
|
91
|
+
* Drop the provisional generation and stop the checks still in flight for
|
|
92
|
+
* it (their retransmissions would outlive it).
|
|
93
|
+
*/
|
|
94
|
+
end(): void;
|
|
95
|
+
/** Stage a provisional generation for the local credentials of an ICE restart offer. */
|
|
96
|
+
stage(usernameFragment: string, password: string, gatherOptions?: Partial<IceOptions>): void;
|
|
97
|
+
/** Remote credentials of the provisional generation (pranswer). */
|
|
98
|
+
setRemoteParams({ usernameFragment, password, }: {
|
|
99
|
+
usernameFragment: string;
|
|
100
|
+
password: string;
|
|
101
|
+
}): void;
|
|
102
|
+
/** A remote candidate (or end-of-candidates) of the pranswer. */
|
|
103
|
+
addRemoteCandidate(remoteCandidate: Candidate | undefined): Promise<void>;
|
|
104
|
+
/** Start checks for the provisional generation; the selected pair is kept. */
|
|
105
|
+
start(): void;
|
|
106
|
+
get nominated(): CandidatePair | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* @param routeChecked a wildcard socket's pair whose path no host socket
|
|
109
|
+
* covers (checked by `wildcardPathUncovered`, as the live checklist does).
|
|
110
|
+
*/
|
|
111
|
+
private tryPair;
|
|
112
|
+
private check;
|
|
113
|
+
/** Put `pair` on the provisional checklist (see `addPair`). */
|
|
114
|
+
private addPair;
|
|
115
|
+
/**
|
|
116
|
+
* The provisional checklist's side of regular nomination: the same rules
|
|
117
|
+
* as the live checklist (`liveNominationHost`), on its own pairs,
|
|
118
|
+
* credentials and end-of-candidates.
|
|
119
|
+
*/
|
|
120
|
+
private nominationHost;
|
|
121
|
+
/**
|
|
122
|
+
* Send a USE-CANDIDATE check for a provisional `pair` (see
|
|
123
|
+
* `NominationOutcome`). `signal` stops it: the checklist's checks
|
|
124
|
+
* (`end()`, a replacement pranswer) and, for regular nomination,
|
|
125
|
+
* the attempt.
|
|
126
|
+
*/
|
|
127
|
+
nominate(generation: ProvisionalGeneration, pair: CandidatePair, signal: AbortSignal): Promise<NominationOutcome>;
|
|
128
|
+
/** Incoming check for the provisional ufrag; never touches the current checklist. */
|
|
129
|
+
checkIncoming(generation: ProvisionalGeneration, message: Message, addr: Address, protocol: Protocol): void;
|
|
130
|
+
/**
|
|
131
|
+
* Whether the provisional generation may use `protocol`: the staged
|
|
132
|
+
* generation drops the sockets its gather options exclude at the commit,
|
|
133
|
+
* so its checks never use them. A kept TURN allocation serves it only when
|
|
134
|
+
* the generation still uses that TURN server, credential and transport (any of its
|
|
135
|
+
* TURN servers): one whose server was removed or replaced (a credential
|
|
136
|
+
* rotation) is not part of it.
|
|
137
|
+
*/
|
|
138
|
+
allows(generation: ProvisionalGeneration, protocol: Protocol): boolean;
|
|
139
|
+
}
|
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProvisionalChecklist = void 0;
|
|
4
|
+
const candidate_1 = require("./candidate");
|
|
5
|
+
const exceptions_1 = require("./exceptions");
|
|
6
|
+
const helper_1 = require("./helper");
|
|
7
|
+
const iceBase_1 = require("./iceBase");
|
|
8
|
+
const common_1 = require("./imports/common");
|
|
9
|
+
const checkMessages_1 = require("./internal/checkMessages");
|
|
10
|
+
const regularNomination_1 = require("./nomination/regularNomination");
|
|
11
|
+
const protocol_1 = require("./turn/protocol");
|
|
12
|
+
const log = (0, common_1.debug)("werift-ice : packages/ice/src/provisional.ts : log");
|
|
13
|
+
/**
|
|
14
|
+
* The provisional generation of an ICE restart (`ProvisionalGeneration`):
|
|
15
|
+
* staged by `stage()` with the local credentials of the restart offer,
|
|
16
|
+
* given the pranswer's credentials and candidates, checked (`start()`) and
|
|
17
|
+
* nominated with the same rules as the live checklist, and dropped by
|
|
18
|
+
* `end()` when the final answer commits or discards the restart. It never
|
|
19
|
+
* touches the live checklist.
|
|
20
|
+
*/
|
|
21
|
+
class ProvisionalChecklist {
|
|
22
|
+
constructor(host) {
|
|
23
|
+
/** The staged generation, if any. */
|
|
24
|
+
Object.defineProperty(this, "generation", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
writable: true,
|
|
28
|
+
value: void 0
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(this, "host", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
configurable: true,
|
|
33
|
+
writable: true,
|
|
34
|
+
value: void 0
|
|
35
|
+
});
|
|
36
|
+
this.host = host;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Drop the provisional generation and stop the checks still in flight for
|
|
40
|
+
* it (their retransmissions would outlive it).
|
|
41
|
+
*/
|
|
42
|
+
end() {
|
|
43
|
+
if (this.generation) {
|
|
44
|
+
this.generation.checks.abort();
|
|
45
|
+
this.generation.nomination.reset();
|
|
46
|
+
}
|
|
47
|
+
this.generation = undefined;
|
|
48
|
+
}
|
|
49
|
+
/** Stage a provisional generation for the local credentials of an ICE restart offer. */
|
|
50
|
+
stage(usernameFragment, password, gatherOptions) {
|
|
51
|
+
this.end();
|
|
52
|
+
const generation = {
|
|
53
|
+
localUsername: usernameFragment,
|
|
54
|
+
localPassword: password,
|
|
55
|
+
gatherOptions,
|
|
56
|
+
remoteCandidates: [],
|
|
57
|
+
remoteCandidatesEnd: false,
|
|
58
|
+
remoteCandidatesEndRequested: false,
|
|
59
|
+
resolutions: new Set(),
|
|
60
|
+
revision: 0,
|
|
61
|
+
pairs: [],
|
|
62
|
+
nomination: new regularNomination_1.RegularNomination(this.nominationHost(() => generation)),
|
|
63
|
+
started: false,
|
|
64
|
+
checks: new AbortController(),
|
|
65
|
+
};
|
|
66
|
+
this.generation = generation;
|
|
67
|
+
}
|
|
68
|
+
/** Remote credentials of the provisional generation (pranswer). */
|
|
69
|
+
setRemoteParams({ usernameFragment, password, }) {
|
|
70
|
+
const generation = this.generation;
|
|
71
|
+
if (!generation)
|
|
72
|
+
return;
|
|
73
|
+
if (generation.remoteUsername === usernameFragment &&
|
|
74
|
+
generation.remotePassword === password) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
// A replacement pranswer starts a new provisional checklist; candidates
|
|
78
|
+
// still resolving for the replaced one are dropped by `revision`.
|
|
79
|
+
generation.remoteUsername = usernameFragment;
|
|
80
|
+
generation.remotePassword = password;
|
|
81
|
+
generation.remoteCandidates = [];
|
|
82
|
+
generation.remoteCandidatesEnd = false;
|
|
83
|
+
generation.remoteCandidatesEndRequested = false;
|
|
84
|
+
generation.resolutions.clear();
|
|
85
|
+
generation.revision++;
|
|
86
|
+
generation.checks.abort();
|
|
87
|
+
generation.checks = new AbortController();
|
|
88
|
+
generation.pairs = [];
|
|
89
|
+
generation.nominated = undefined;
|
|
90
|
+
generation.liteNominating = false;
|
|
91
|
+
generation.nomination.reset();
|
|
92
|
+
}
|
|
93
|
+
/** A remote candidate (or end-of-candidates) of the pranswer. */
|
|
94
|
+
async addRemoteCandidate(remoteCandidate) {
|
|
95
|
+
const generation = this.generation;
|
|
96
|
+
if (!generation || this.host.closed())
|
|
97
|
+
return;
|
|
98
|
+
const revision = generation.revision;
|
|
99
|
+
const current = () => !this.host.closed() &&
|
|
100
|
+
this.generation === generation &&
|
|
101
|
+
generation.revision === revision;
|
|
102
|
+
if (!remoteCandidate) {
|
|
103
|
+
if (generation.remoteCandidatesEnd ||
|
|
104
|
+
generation.remoteCandidatesEndRequested) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
// Candidates that arrived before end-of-candidates finish first.
|
|
108
|
+
generation.remoteCandidatesEndRequested = true;
|
|
109
|
+
if (generation.resolutions.size > 0) {
|
|
110
|
+
await Promise.allSettled([...generation.resolutions]);
|
|
111
|
+
if (!current())
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
generation.remoteCandidatesEnd = true;
|
|
115
|
+
generation.nomination.evaluate();
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
// RFC 8838: a completed generation takes no further candidates.
|
|
119
|
+
if (generation.remoteCandidatesEnd ||
|
|
120
|
+
generation.remoteCandidatesEndRequested) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (remoteCandidate.host.includes(".local")) {
|
|
124
|
+
try {
|
|
125
|
+
const resolution = this.host.mdnsLookup().lookup(remoteCandidate.host);
|
|
126
|
+
generation.resolutions.add(resolution);
|
|
127
|
+
try {
|
|
128
|
+
remoteCandidate.host = await resolution;
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
generation.resolutions.delete(resolution);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
// The generation may have been replaced or completed while resolving.
|
|
138
|
+
if (!current() || generation.remoteCandidatesEnd)
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
(0, iceBase_1.validateRemoteCandidate)(remoteCandidate);
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (!current() ||
|
|
148
|
+
generation.remoteCandidates.some((c) => c.host === remoteCandidate.host &&
|
|
149
|
+
c.port === remoteCandidate.port &&
|
|
150
|
+
c.transport.toLowerCase() === remoteCandidate.transport.toLowerCase())) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
generation.remoteCandidates.push(remoteCandidate);
|
|
154
|
+
for (const protocol of this.host.protocols()) {
|
|
155
|
+
this.tryPair(generation, protocol, remoteCandidate);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/** Start checks for the provisional generation; the selected pair is kept. */
|
|
159
|
+
start() {
|
|
160
|
+
const generation = this.generation;
|
|
161
|
+
if (!generation || generation.started)
|
|
162
|
+
return;
|
|
163
|
+
generation.started = true;
|
|
164
|
+
for (const remoteCandidate of generation.remoteCandidates) {
|
|
165
|
+
for (const protocol of this.host.protocols()) {
|
|
166
|
+
this.tryPair(generation, protocol, remoteCandidate);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
for (const pair of generation.pairs) {
|
|
170
|
+
if (!this.host.isUncheckedPair(pair)) {
|
|
171
|
+
void this.check(generation, pair);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
get nominated() {
|
|
176
|
+
return this.generation?.nominated;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* @param routeChecked a wildcard socket's pair whose path no host socket
|
|
180
|
+
* covers (checked by `wildcardPathUncovered`, as the live checklist does).
|
|
181
|
+
*/
|
|
182
|
+
tryPair(generation, protocol, remoteCandidate, routeChecked = false) {
|
|
183
|
+
if (!routeChecked && this.host.isWildcardProtocol(protocol)) {
|
|
184
|
+
void this.host
|
|
185
|
+
.wildcardPathUncovered(remoteCandidate)
|
|
186
|
+
.then((uncovered) => {
|
|
187
|
+
if (uncovered && this.generation === generation) {
|
|
188
|
+
this.tryPair(generation, protocol, remoteCandidate, true);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (!protocol.localCandidate?.canPairWith(remoteCandidate) ||
|
|
194
|
+
!this.allows(generation, protocol) ||
|
|
195
|
+
(protocol.localCandidate.transport.toLowerCase() === "tcp" &&
|
|
196
|
+
protocol.localCandidate.tcptype === "passive" &&
|
|
197
|
+
remoteCandidate.type !== "prflx") ||
|
|
198
|
+
generation.pairs.some((pair) => pair.protocol === protocol &&
|
|
199
|
+
pair.remoteCandidate === remoteCandidate)) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const pair = new iceBase_1.CandidatePair(protocol, remoteCandidate, this.host.iceControlling());
|
|
203
|
+
// The provisional checklist admits the same pairs as the live one.
|
|
204
|
+
const { filterCandidatePair } = this.host.options();
|
|
205
|
+
if (filterCandidatePair && !filterCandidatePair(pair)) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
pair.updateState(iceBase_1.CandidatePairState.WAITING);
|
|
209
|
+
this.addPair(generation, pair);
|
|
210
|
+
// As the live schedule does, forceTurn leaves host pairs unchecked.
|
|
211
|
+
if (generation.started && !this.host.isUncheckedPair(pair)) {
|
|
212
|
+
void this.check(generation, pair);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
async check(generation, pair, retry = true) {
|
|
216
|
+
const revision = generation.revision;
|
|
217
|
+
// A check belongs to one checklist: a replacement pranswer (new revision)
|
|
218
|
+
// or a replaced generation makes its outcome meaningless.
|
|
219
|
+
const belongs = () => this.generation === generation &&
|
|
220
|
+
generation.revision === revision &&
|
|
221
|
+
generation.pairs.includes(pair);
|
|
222
|
+
if (
|
|
223
|
+
// An ICE-lite agent only answers checks (RFC 8445 §2.5), in the
|
|
224
|
+
// provisional generation as in the live one.
|
|
225
|
+
this.host.iceLite() ||
|
|
226
|
+
!belongs() ||
|
|
227
|
+
!generation.started ||
|
|
228
|
+
!generation.remoteUsername ||
|
|
229
|
+
!generation.remotePassword ||
|
|
230
|
+
[
|
|
231
|
+
iceBase_1.CandidatePairState.IN_PROGRESS,
|
|
232
|
+
iceBase_1.CandidatePairState.SUCCEEDED,
|
|
233
|
+
].includes(pair.state)) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
pair.updateState(iceBase_1.CandidatePairState.IN_PROGRESS);
|
|
237
|
+
// Regular nomination: a check never carries USE-CANDIDATE; the
|
|
238
|
+
// nomination is a separate check (`generation.nomination`). Otherwise
|
|
239
|
+
// (semi-aggressive nomination, renomination) checks carry USE-CANDIDATE
|
|
240
|
+
// until a pair is selected: the provisional checklist only selects once,
|
|
241
|
+
// and the final answer checks the live one from scratch.
|
|
242
|
+
const nominate = this.host.nominatesFullPeer() &&
|
|
243
|
+
!this.host.usesRegularNomination() &&
|
|
244
|
+
!generation.nominated &&
|
|
245
|
+
this.host.replacesWith(pair);
|
|
246
|
+
const request = this.host.buildRequest({
|
|
247
|
+
nominate,
|
|
248
|
+
localUsername: generation.localUsername,
|
|
249
|
+
remoteUsername: generation.remoteUsername,
|
|
250
|
+
iceControlling: this.host.iceControlling(),
|
|
251
|
+
localCandidate: pair.localCandidate,
|
|
252
|
+
});
|
|
253
|
+
try {
|
|
254
|
+
pair.requestsSent++;
|
|
255
|
+
const [, addr] = await pair.protocol.request(request, pair.remoteAddr, Buffer.from(generation.remotePassword, "utf8"), {
|
|
256
|
+
retransmissions: pair.localCandidate.transport.toLowerCase() === "tcp" ? 0 : 4,
|
|
257
|
+
signal: generation.checks.signal,
|
|
258
|
+
integrityAlgorithm: this.host.options().messageIntegrity,
|
|
259
|
+
});
|
|
260
|
+
pair.responsesReceived++;
|
|
261
|
+
if (!belongs())
|
|
262
|
+
return;
|
|
263
|
+
if (addr[0] !== pair.remoteAddr[0] || addr[1] !== pair.remoteAddr[1]) {
|
|
264
|
+
pair.updateState(iceBase_1.CandidatePairState.FAILED);
|
|
265
|
+
generation.nomination.evaluate();
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
270
|
+
if (!belongs())
|
|
271
|
+
return;
|
|
272
|
+
const code = error.response?.getAttributeValue("ERROR-CODE")?.[0];
|
|
273
|
+
pair.updateState(iceBase_1.CandidatePairState.FAILED);
|
|
274
|
+
if (code === 487 && retry) {
|
|
275
|
+
this.host.switchRole(request.attributesKeys.includes("ICE-CONTROLLED"));
|
|
276
|
+
pair.updateState(iceBase_1.CandidatePairState.WAITING);
|
|
277
|
+
return this.check(generation, pair, false);
|
|
278
|
+
}
|
|
279
|
+
generation.nomination.evaluate();
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
// Only a controlled agent takes the peer's nomination (see checkStart).
|
|
283
|
+
if (pair.remoteNominated && !this.host.iceControlling())
|
|
284
|
+
pair.nominated = true;
|
|
285
|
+
else if (nominate && this.host.iceControlling())
|
|
286
|
+
pair.nominated = true;
|
|
287
|
+
pair.updateState(iceBase_1.CandidatePairState.SUCCEEDED);
|
|
288
|
+
if (!pair.nominated &&
|
|
289
|
+
this.host.iceControlling() &&
|
|
290
|
+
this.host.remoteIsLite() &&
|
|
291
|
+
!generation.nominated &&
|
|
292
|
+
!generation.liteNominating) {
|
|
293
|
+
// Toward an ICE-lite peer, as the live checklist does: nominate the
|
|
294
|
+
// first pair that succeeded with a check that carries USE-CANDIDATE.
|
|
295
|
+
generation.liteNominating = true;
|
|
296
|
+
const result = await this.nominate(generation, pair, generation.checks.signal);
|
|
297
|
+
if (belongs()) {
|
|
298
|
+
generation.liteNominating = false;
|
|
299
|
+
if (result === "nominated")
|
|
300
|
+
pair.nominated = true;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
if (pair.nominated && !generation.nominated) {
|
|
304
|
+
log("provisional nominated", pair.toJSON());
|
|
305
|
+
generation.nominated = pair;
|
|
306
|
+
generation.nomination.stop();
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
if (belongs())
|
|
310
|
+
generation.nomination.evaluate();
|
|
311
|
+
}
|
|
312
|
+
/** Put `pair` on the provisional checklist (see `addPair`). */
|
|
313
|
+
addPair(generation, pair) {
|
|
314
|
+
const best = this.host.bestValidPair(generation.pairs);
|
|
315
|
+
generation.pairs.push(pair);
|
|
316
|
+
generation.nomination.pairAdded(pair, best);
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* The provisional checklist's side of regular nomination: the same rules
|
|
320
|
+
* as the live checklist (`liveNominationHost`), on its own pairs,
|
|
321
|
+
* credentials and end-of-candidates.
|
|
322
|
+
*/
|
|
323
|
+
nominationHost(generationOf) {
|
|
324
|
+
const current = () => this.generation === generationOf();
|
|
325
|
+
return {
|
|
326
|
+
active: () => current() &&
|
|
327
|
+
this.host.nominatesFullPeer() &&
|
|
328
|
+
generationOf().started &&
|
|
329
|
+
!generationOf().nominated,
|
|
330
|
+
checking: () => generationOf().started,
|
|
331
|
+
pairs: () => {
|
|
332
|
+
const pairs = [
|
|
333
|
+
...this.host.regularNominationPairs(generationOf().pairs),
|
|
334
|
+
];
|
|
335
|
+
(0, iceBase_1.sortCandidatePairs)(pairs, this.host.iceControlling());
|
|
336
|
+
return pairs;
|
|
337
|
+
},
|
|
338
|
+
remoteCandidatesEnd: () => generationOf().remoteCandidatesEnd,
|
|
339
|
+
localCandidatesEnd: () => this.host.localCandidatesEnd(),
|
|
340
|
+
delayMs: () => this.host.nominationDelayMs(),
|
|
341
|
+
unchecked: (pair) => this.host.isUncheckedPair(pair),
|
|
342
|
+
outranks: (pair, other) => this.host.outranks(pair, other),
|
|
343
|
+
preferred: () => undefined,
|
|
344
|
+
owns: (pair) => current() && generationOf().pairs.includes(pair),
|
|
345
|
+
send: (pair, signal) => this.nominate(generationOf(), pair, AbortSignal.any([generationOf().checks.signal, signal])),
|
|
346
|
+
nominated: (pair) => {
|
|
347
|
+
const generation = generationOf();
|
|
348
|
+
pair.nominated = true;
|
|
349
|
+
if (!generation.nominated) {
|
|
350
|
+
log("provisional nominated", pair.toJSON());
|
|
351
|
+
generation.nominated = pair;
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
rejected: (pair) => {
|
|
355
|
+
pair.updateState(iceBase_1.CandidatePairState.FAILED);
|
|
356
|
+
generationOf().nomination.evaluate();
|
|
357
|
+
},
|
|
358
|
+
// As in the live checklist: become controlled, keep the pair valid.
|
|
359
|
+
roleConflict: () => this.host.switchRole(false),
|
|
360
|
+
abandoned: (pair) => pair?.updateState(iceBase_1.CandidatePairState.FAILED),
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Send a USE-CANDIDATE check for a provisional `pair` (see
|
|
365
|
+
* `NominationOutcome`). `signal` stops it: the checklist's checks
|
|
366
|
+
* (`end()`, a replacement pranswer) and, for regular nomination,
|
|
367
|
+
* the attempt.
|
|
368
|
+
*/
|
|
369
|
+
async nominate(generation, pair, signal) {
|
|
370
|
+
const request = this.host.buildRequest({
|
|
371
|
+
nominate: true,
|
|
372
|
+
localUsername: generation.localUsername,
|
|
373
|
+
remoteUsername: generation.remoteUsername,
|
|
374
|
+
iceControlling: this.host.iceControlling(),
|
|
375
|
+
localCandidate: pair.localCandidate,
|
|
376
|
+
});
|
|
377
|
+
try {
|
|
378
|
+
pair.requestsSent++;
|
|
379
|
+
await pair.protocol.request(request, pair.remoteAddr, Buffer.from(generation.remotePassword, "utf8"), {
|
|
380
|
+
retransmissions: pair.localCandidate.transport.toLowerCase() === "tcp" ? 0 : 4,
|
|
381
|
+
// end() / a replacement pranswer stops it with the checks.
|
|
382
|
+
signal: AbortSignal.any([signal, generation.checks.signal]),
|
|
383
|
+
integrityAlgorithm: this.host.options().messageIntegrity,
|
|
384
|
+
});
|
|
385
|
+
pair.responsesReceived++;
|
|
386
|
+
return "nominated";
|
|
387
|
+
}
|
|
388
|
+
catch (error) {
|
|
389
|
+
log("provisional regular nomination failed", error);
|
|
390
|
+
if ((0, checkMessages_1.isRoleConflict)(error))
|
|
391
|
+
return "role-conflict";
|
|
392
|
+
return error instanceof exceptions_1.TransactionTimeout ? "unanswered" : "rejected";
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
/** Incoming check for the provisional ufrag; never touches the current checklist. */
|
|
396
|
+
checkIncoming(generation, message, addr, protocol) {
|
|
397
|
+
// A socket the staged generation drops at the commit takes no pair.
|
|
398
|
+
if (!this.allows(generation, protocol))
|
|
399
|
+
return;
|
|
400
|
+
// Only checks from the remote credentials of the current checklist count
|
|
401
|
+
// (a replacement pranswer replaced any earlier ones).
|
|
402
|
+
const txUsername = message.getAttributeValue("USERNAME");
|
|
403
|
+
const sender = typeof txUsername === "string"
|
|
404
|
+
? (0, checkMessages_1.decodeTxUsername)(txUsername).localUsername
|
|
405
|
+
: undefined;
|
|
406
|
+
if (generation.remoteUsername && sender !== generation.remoteUsername) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
const [host, port] = addr;
|
|
410
|
+
let remoteCandidate = generation.remoteCandidates.find((c) => c.host === host && c.port === port);
|
|
411
|
+
if (!remoteCandidate) {
|
|
412
|
+
remoteCandidate = new candidate_1.Candidate((0, helper_1.randomString)(10), 1, protocol.localCandidate?.transport ?? "udp", message.getAttributeValue("PRIORITY"), host, port, "prflx", undefined, undefined, protocol.localCandidate?.transport === "tcp"
|
|
413
|
+
? (0, candidate_1.remoteTcpTypeForIncoming)(protocol.localCandidate.tcptype)
|
|
414
|
+
: undefined, undefined, undefined);
|
|
415
|
+
generation.remoteCandidates.push(remoteCandidate);
|
|
416
|
+
}
|
|
417
|
+
let pair = generation.pairs.find((p) => p.protocol === protocol && p.remoteCandidate === remoteCandidate);
|
|
418
|
+
if (!pair) {
|
|
419
|
+
pair = new iceBase_1.CandidatePair(protocol, remoteCandidate, this.host.iceControlling());
|
|
420
|
+
pair.updateState(iceBase_1.CandidatePairState.WAITING);
|
|
421
|
+
this.addPair(generation, pair);
|
|
422
|
+
}
|
|
423
|
+
pair.noteIncomingRequest(message.transactionIdHex);
|
|
424
|
+
pair.requestsReceived++;
|
|
425
|
+
pair.responsesSent++;
|
|
426
|
+
if ((0, checkMessages_1.receivedNomination)(message) > 0 && !this.host.iceControlling()) {
|
|
427
|
+
pair.remoteNominated = true;
|
|
428
|
+
if (this.host.iceLite() || pair.state === iceBase_1.CandidatePairState.SUCCEEDED) {
|
|
429
|
+
pair.nominated = true;
|
|
430
|
+
pair.updateState(iceBase_1.CandidatePairState.SUCCEEDED);
|
|
431
|
+
generation.nominated ?? (generation.nominated = pair);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
if (!this.host.iceLite() &&
|
|
435
|
+
[
|
|
436
|
+
iceBase_1.CandidatePairState.WAITING,
|
|
437
|
+
iceBase_1.CandidatePairState.FAILED,
|
|
438
|
+
].includes(pair.state)) {
|
|
439
|
+
void this.check(generation, pair);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Whether the provisional generation may use `protocol`: the staged
|
|
444
|
+
* generation drops the sockets its gather options exclude at the commit,
|
|
445
|
+
* so its checks never use them. A kept TURN allocation serves it only when
|
|
446
|
+
* the generation still uses that TURN server, credential and transport (any of its
|
|
447
|
+
* TURN servers): one whose server was removed or replaced (a credential
|
|
448
|
+
* rotation) is not part of it.
|
|
449
|
+
*/
|
|
450
|
+
allows(generation, protocol) {
|
|
451
|
+
const options = generation.gatherOptions ?? this.host.options();
|
|
452
|
+
if (!protocol.localCandidate ||
|
|
453
|
+
!(0, iceBase_1.isCandidateAllowedByGatherOptions)(protocol.localCandidate, options)) {
|
|
454
|
+
return false;
|
|
455
|
+
}
|
|
456
|
+
if (protocol instanceof protocol_1.StunOverTurnProtocol) {
|
|
457
|
+
const { configuredServer, username, password } = protocol.turn;
|
|
458
|
+
return (0, iceBase_1.normalizeIceServerOptions)(options).turnServers.some((server) => configuredServer[0] === server.address[0] &&
|
|
459
|
+
configuredServer[1] === server.address[1] &&
|
|
460
|
+
username === server.username &&
|
|
461
|
+
password === server.password &&
|
|
462
|
+
protocol.configuredTransport === server.transport);
|
|
463
|
+
}
|
|
464
|
+
return true;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
exports.ProvisionalChecklist = ProvisionalChecklist;
|
|
468
|
+
//# sourceMappingURL=provisional.js.map
|