werift 0.25.2 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (568) hide show
  1. package/README.md +63 -0
  2. package/THIRD_PARTY_LICENSES_LIBWEBRTC.txt +58 -0
  3. package/lib/common/src/asn1.d.ts +42 -0
  4. package/lib/common/src/asn1.js +163 -0
  5. package/lib/common/src/asn1.js.map +1 -0
  6. package/lib/common/src/binary.d.ts +1 -3
  7. package/lib/common/src/binary.js +8 -6
  8. package/lib/common/src/binary.js.map +1 -1
  9. package/lib/common/src/binaryData.js +2 -1
  10. package/lib/common/src/binaryData.js.map +1 -1
  11. package/lib/common/src/index.d.ts +6 -5
  12. package/lib/common/src/index.js +6 -5
  13. package/lib/common/src/index.js.map +1 -1
  14. package/lib/common/src/log.d.ts +12 -1
  15. package/lib/common/src/log.js +142 -12
  16. package/lib/common/src/log.js.map +1 -1
  17. package/lib/common/src/network.js.map +1 -1
  18. package/lib/common/src/queue.d.ts +41 -0
  19. package/lib/common/src/queue.js +146 -0
  20. package/lib/common/src/queue.js.map +1 -0
  21. package/lib/common/src/transport.d.ts +15 -2
  22. package/lib/common/src/transport.js +108 -19
  23. package/lib/common/src/transport.js.map +1 -1
  24. package/lib/dtls/src/cipher/create.js.map +1 -1
  25. package/lib/dtls/src/cipher/ec.js +8 -8
  26. package/lib/dtls/src/cipher/ec.js.map +1 -1
  27. package/lib/dtls/src/cipher/namedCurve.js +6 -7
  28. package/lib/dtls/src/cipher/namedCurve.js.map +1 -1
  29. package/lib/dtls/src/cipher/prf.d.ts +2 -2
  30. package/lib/dtls/src/cipher/prf.js +29 -8
  31. package/lib/dtls/src/cipher/prf.js.map +1 -1
  32. package/lib/dtls/src/cipher/suites/aead.d.ts +1 -1
  33. package/lib/dtls/src/context/certificate.d.ts +32 -0
  34. package/lib/dtls/src/context/certificate.js +54 -0
  35. package/lib/dtls/src/context/certificate.js.map +1 -0
  36. package/lib/dtls/src/context/cipher.d.ts +13 -7
  37. package/lib/dtls/src/context/cipher.js +58 -106
  38. package/lib/dtls/src/context/cipher.js.map +1 -1
  39. package/lib/dtls/src/context/dtls.js +4 -2
  40. package/lib/dtls/src/context/dtls.js.map +1 -1
  41. package/lib/dtls/src/context/transport.d.ts +4 -0
  42. package/lib/dtls/src/context/transport.js +16 -1
  43. package/lib/dtls/src/context/transport.js.map +1 -1
  44. package/lib/dtls/src/flight/client/flight1.js +2 -1
  45. package/lib/dtls/src/flight/client/flight1.js.map +1 -1
  46. package/lib/dtls/src/flight/client/flight5.js +4 -2
  47. package/lib/dtls/src/flight/client/flight5.js.map +1 -1
  48. package/lib/dtls/src/flight/flight.d.ts +1 -1
  49. package/lib/dtls/src/flight/flight.js +16 -5
  50. package/lib/dtls/src/flight/flight.js.map +1 -1
  51. package/lib/dtls/src/flight/server/flight2.js.map +1 -1
  52. package/lib/dtls/src/flight/server/flight4.d.ts +2 -1
  53. package/lib/dtls/src/flight/server/flight4.js +12 -4
  54. package/lib/dtls/src/flight/server/flight4.js.map +1 -1
  55. package/lib/dtls/src/flight/server/flight6.js +2 -1
  56. package/lib/dtls/src/flight/server/flight6.js.map +1 -1
  57. package/lib/dtls/src/handshake/const.d.ts +17 -13
  58. package/lib/dtls/src/handshake/const.js +16 -14
  59. package/lib/dtls/src/handshake/const.js.map +1 -1
  60. package/lib/dtls/src/handshake/extensions/signature.d.ts +1 -1
  61. package/lib/dtls/src/handshake/extensions/signature.js.map +1 -1
  62. package/lib/dtls/src/handshake/message/alert.js +5 -3
  63. package/lib/dtls/src/handshake/message/alert.js.map +1 -1
  64. package/lib/dtls/src/handshake/message/certificate.js +3 -2
  65. package/lib/dtls/src/handshake/message/certificate.js.map +1 -1
  66. package/lib/dtls/src/handshake/message/changeCipherSpec.js +4 -4
  67. package/lib/dtls/src/handshake/message/changeCipherSpec.js.map +1 -1
  68. package/lib/dtls/src/handshake/message/client/certificateVerify.d.ts +1 -1
  69. package/lib/dtls/src/handshake/message/client/certificateVerify.js +5 -3
  70. package/lib/dtls/src/handshake/message/client/certificateVerify.js.map +1 -1
  71. package/lib/dtls/src/handshake/message/client/hello.js +15 -8
  72. package/lib/dtls/src/handshake/message/client/hello.js.map +1 -1
  73. package/lib/dtls/src/handshake/message/client/keyExchange.js +3 -2
  74. package/lib/dtls/src/handshake/message/client/keyExchange.js.map +1 -1
  75. package/lib/dtls/src/handshake/message/finished.js +2 -1
  76. package/lib/dtls/src/handshake/message/finished.js.map +1 -1
  77. package/lib/dtls/src/handshake/message/server/certificateRequest.d.ts +1 -1
  78. package/lib/dtls/src/handshake/message/server/certificateRequest.js +7 -4
  79. package/lib/dtls/src/handshake/message/server/certificateRequest.js.map +1 -1
  80. package/lib/dtls/src/handshake/message/server/hello.d.ts +1 -1
  81. package/lib/dtls/src/handshake/message/server/hello.js +14 -8
  82. package/lib/dtls/src/handshake/message/server/hello.js.map +1 -1
  83. package/lib/dtls/src/handshake/message/server/helloDone.js +1 -1
  84. package/lib/dtls/src/handshake/message/server/helloDone.js.map +1 -1
  85. package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js +5 -3
  86. package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js.map +1 -1
  87. package/lib/dtls/src/handshake/message/server/keyExchange.d.ts +1 -1
  88. package/lib/dtls/src/handshake/message/server/keyExchange.js +17 -9
  89. package/lib/dtls/src/handshake/message/server/keyExchange.js.map +1 -1
  90. package/lib/dtls/src/handshake/random.d.ts +1 -1
  91. package/lib/dtls/src/handshake/random.js +7 -4
  92. package/lib/dtls/src/handshake/random.js.map +1 -1
  93. package/lib/dtls/src/imports/common.d.ts +1 -0
  94. package/lib/dtls/src/imports/common.js +1 -0
  95. package/lib/dtls/src/imports/common.js.map +1 -1
  96. package/lib/dtls/src/index.d.ts +2 -2
  97. package/lib/dtls/src/index.js +2 -2
  98. package/lib/dtls/src/index.js.map +1 -1
  99. package/lib/dtls/src/record/const.d.ts +43 -33
  100. package/lib/dtls/src/record/const.js +43 -36
  101. package/lib/dtls/src/record/const.js.map +1 -1
  102. package/lib/dtls/src/record/message/fragment.d.ts +1 -1
  103. package/lib/dtls/src/record/message/fragment.js +15 -9
  104. package/lib/dtls/src/record/message/fragment.js.map +1 -1
  105. package/lib/dtls/src/record/message/header.js +12 -7
  106. package/lib/dtls/src/record/message/header.js.map +1 -1
  107. package/lib/dtls/src/record/message/plaintext.js +4 -2
  108. package/lib/dtls/src/record/message/plaintext.js.map +1 -1
  109. package/lib/dtls/src/record/receive.js +2 -2
  110. package/lib/dtls/src/record/receive.js.map +1 -1
  111. package/lib/dtls/src/server.js +1 -1
  112. package/lib/dtls/src/server.js.map +1 -1
  113. package/lib/dtls/src/socket.d.ts +2 -2
  114. package/lib/dtls/src/socket.js +6 -4
  115. package/lib/dtls/src/socket.js.map +1 -1
  116. package/lib/ice/src/candidate.d.ts +1 -1
  117. package/lib/ice/src/candidate.js +24 -12
  118. package/lib/ice/src/candidate.js.map +1 -1
  119. package/lib/ice/src/dns/lookup.d.ts +10 -1
  120. package/lib/ice/src/dns/lookup.js +42 -7
  121. package/lib/ice/src/dns/lookup.js.map +1 -1
  122. package/lib/ice/src/exceptions.d.ts +46 -0
  123. package/lib/ice/src/exceptions.js +92 -5
  124. package/lib/ice/src/exceptions.js.map +1 -1
  125. package/lib/ice/src/helper.d.ts +1 -1
  126. package/lib/ice/src/ice.d.ts +191 -5
  127. package/lib/ice/src/ice.js +1048 -156
  128. package/lib/ice/src/ice.js.map +1 -1
  129. package/lib/ice/src/iceBase.d.ts +174 -10
  130. package/lib/ice/src/iceBase.js +165 -12
  131. package/lib/ice/src/iceBase.js.map +1 -1
  132. package/lib/ice/src/index.d.ts +5 -5
  133. package/lib/ice/src/index.js +5 -5
  134. package/lib/ice/src/index.js.map +1 -1
  135. package/lib/ice/src/internal/resolveHostAddresses.d.ts +26 -0
  136. package/lib/ice/src/internal/resolveHostAddresses.js +45 -0
  137. package/lib/ice/src/internal/resolveHostAddresses.js.map +1 -0
  138. package/lib/ice/src/stun/protocol.d.ts +3 -1
  139. package/lib/ice/src/stun/protocol.js +16 -0
  140. package/lib/ice/src/stun/protocol.js.map +1 -1
  141. package/lib/ice/src/stun/tcpProtocol.d.ts +2 -0
  142. package/lib/ice/src/stun/tcpProtocol.js +16 -1
  143. package/lib/ice/src/stun/tcpProtocol.js.map +1 -1
  144. package/lib/ice/src/stun/transaction.d.ts +35 -1
  145. package/lib/ice/src/stun/transaction.js +93 -18
  146. package/lib/ice/src/stun/transaction.js.map +1 -1
  147. package/lib/ice/src/turn/credential.d.ts +49 -0
  148. package/lib/ice/src/turn/credential.js +78 -0
  149. package/lib/ice/src/turn/credential.js.map +1 -0
  150. package/lib/ice/src/turn/protocol.d.ts +97 -7
  151. package/lib/ice/src/turn/protocol.js +357 -55
  152. package/lib/ice/src/turn/protocol.js.map +1 -1
  153. package/lib/ice/src/utils.js.map +1 -1
  154. package/lib/ice-server/src/stun/attributes.d.ts +2 -0
  155. package/lib/ice-server/src/stun/attributes.js +7 -1
  156. package/lib/ice-server/src/stun/attributes.js.map +1 -1
  157. package/lib/ice-server/src/stun/const.d.ts +24 -16
  158. package/lib/ice-server/src/stun/const.js +22 -18
  159. package/lib/ice-server/src/stun/const.js.map +1 -1
  160. package/lib/ice-server/src/stun/message.d.ts +3 -1
  161. package/lib/ice-server/src/stun/message.js +41 -6
  162. package/lib/ice-server/src/stun/message.js.map +1 -1
  163. package/lib/ice-server/src/turn/auth.d.ts +1 -1
  164. package/lib/index.mjs +25252 -12664
  165. package/lib/nonstandard/index.mjs +11015 -8906
  166. package/lib/polyfill/dom.mjs +30779 -18386
  167. package/lib/polyfill/index.mjs +30779 -18386
  168. package/lib/rtp/src/codec/assertPayload.d.ts +4 -0
  169. package/lib/rtp/src/codec/assertPayload.js +12 -0
  170. package/lib/rtp/src/codec/assertPayload.js.map +1 -0
  171. package/lib/rtp/src/codec/av1.js +2 -0
  172. package/lib/rtp/src/codec/av1.js.map +1 -1
  173. package/lib/rtp/src/codec/h264.d.ts +1 -1
  174. package/lib/rtp/src/codec/h264.js +35 -43
  175. package/lib/rtp/src/codec/h264.js.map +1 -1
  176. package/lib/rtp/src/codec/vp8.js +11 -5
  177. package/lib/rtp/src/codec/vp8.js.map +1 -1
  178. package/lib/rtp/src/codec/vp9.js +12 -0
  179. package/lib/rtp/src/codec/vp9.js.map +1 -1
  180. package/lib/rtp/src/extra/container/mp4/container.js +2 -1
  181. package/lib/rtp/src/extra/container/mp4/container.js.map +1 -1
  182. package/lib/rtp/src/extra/container/mp4/exp-golomb.js +2 -1
  183. package/lib/rtp/src/extra/container/mp4/exp-golomb.js.map +1 -1
  184. package/lib/rtp/src/extra/container/mp4/h264.d.ts +21 -17
  185. package/lib/rtp/src/extra/container/mp4/h264.js +26 -24
  186. package/lib/rtp/src/extra/container/mp4/h264.js.map +1 -1
  187. package/lib/rtp/src/extra/container/ogg/index.d.ts +1 -0
  188. package/lib/rtp/src/extra/container/ogg/index.js +1 -0
  189. package/lib/rtp/src/extra/container/ogg/index.js.map +1 -1
  190. package/lib/rtp/src/extra/container/ogg/writer.d.ts +90 -0
  191. package/lib/rtp/src/extra/container/ogg/writer.js +300 -0
  192. package/lib/rtp/src/extra/container/ogg/writer.js.map +1 -0
  193. package/lib/rtp/src/extra/container/webm/container.d.ts +1 -1
  194. package/lib/rtp/src/extra/container/webm/ebml/ebml.d.ts +6 -0
  195. package/lib/rtp/src/extra/container/webm/ebml/ebml.js +26 -4
  196. package/lib/rtp/src/extra/container/webm/ebml/ebml.js.map +1 -1
  197. package/lib/rtp/src/extra/processor/depacketizer.d.ts +6 -1
  198. package/lib/rtp/src/extra/processor/depacketizer.js +29 -3
  199. package/lib/rtp/src/extra/processor/depacketizer.js.map +1 -1
  200. package/lib/rtp/src/extra/processor/depacketizerCallback.d.ts +1 -11
  201. package/lib/rtp/src/extra/processor/depacketizerTransformer.d.ts +1 -1
  202. package/lib/rtp/src/extra/processor/dtx.js +4 -2
  203. package/lib/rtp/src/extra/processor/dtx.js.map +1 -1
  204. package/lib/rtp/src/extra/processor/dtxCallback.d.ts +1 -11
  205. package/lib/rtp/src/extra/processor/index.d.ts +2 -0
  206. package/lib/rtp/src/extra/processor/index.js +2 -0
  207. package/lib/rtp/src/extra/processor/index.js.map +1 -1
  208. package/lib/rtp/src/extra/processor/interface.d.ts +16 -11
  209. package/lib/rtp/src/extra/processor/interface.js.map +1 -1
  210. package/lib/rtp/src/extra/processor/jitterBuffer.d.ts +29 -6
  211. package/lib/rtp/src/extra/processor/jitterBuffer.js +101 -111
  212. package/lib/rtp/src/extra/processor/jitterBuffer.js.map +1 -1
  213. package/lib/rtp/src/extra/processor/jitterBufferCallback.d.ts +1 -11
  214. package/lib/rtp/src/extra/processor/jitterBufferTransformer.d.ts +1 -1
  215. package/lib/rtp/src/extra/processor/jitterBufferTransformer.js +2 -1
  216. package/lib/rtp/src/extra/processor/jitterBufferTransformer.js.map +1 -1
  217. package/lib/rtp/src/extra/processor/lipsync.d.ts +63 -0
  218. package/lib/rtp/src/extra/processor/lipsync.js +202 -51
  219. package/lib/rtp/src/extra/processor/lipsync.js.map +1 -1
  220. package/lib/rtp/src/extra/processor/mp4.d.ts +0 -6
  221. package/lib/rtp/src/extra/processor/mp4.js +7 -4
  222. package/lib/rtp/src/extra/processor/mp4.js.map +1 -1
  223. package/lib/rtp/src/extra/processor/mute.js +4 -2
  224. package/lib/rtp/src/extra/processor/mute.js.map +1 -1
  225. package/lib/rtp/src/extra/processor/nack.d.ts +1 -1
  226. package/lib/rtp/src/extra/processor/nack.js +5 -3
  227. package/lib/rtp/src/extra/processor/nack.js.map +1 -1
  228. package/lib/rtp/src/extra/processor/nackHandlerCallback.d.ts +1 -11
  229. package/lib/rtp/src/extra/processor/ntpTime.js +4 -6
  230. package/lib/rtp/src/extra/processor/ntpTime.js.map +1 -1
  231. package/lib/rtp/src/extra/processor/ntpTimeCallback.d.ts +1 -11
  232. package/lib/rtp/src/extra/processor/ogg.d.ts +72 -0
  233. package/lib/rtp/src/extra/processor/ogg.js +221 -0
  234. package/lib/rtp/src/extra/processor/ogg.js.map +1 -0
  235. package/lib/rtp/src/extra/processor/oggCallback.d.ts +21 -0
  236. package/lib/rtp/src/extra/processor/oggCallback.js +97 -0
  237. package/lib/rtp/src/extra/processor/oggCallback.js.map +1 -0
  238. package/lib/rtp/src/extra/processor/rtcpCallback.d.ts +1 -1
  239. package/lib/rtp/src/extra/processor/rtcpCallback.js.map +1 -1
  240. package/lib/rtp/src/extra/processor/rtpCallback.d.ts +1 -1
  241. package/lib/rtp/src/extra/processor/rtpCallback.js +3 -2
  242. package/lib/rtp/src/extra/processor/rtpCallback.js.map +1 -1
  243. package/lib/rtp/src/extra/processor/rtpStream.d.ts +2 -2
  244. package/lib/rtp/src/extra/processor/rtpStream.js +2 -1
  245. package/lib/rtp/src/extra/processor/rtpStream.js.map +1 -1
  246. package/lib/rtp/src/extra/processor/rtpTime.js +2 -1
  247. package/lib/rtp/src/extra/processor/rtpTime.js.map +1 -1
  248. package/lib/rtp/src/extra/processor/rtpTimeCallback.d.ts +1 -11
  249. package/lib/rtp/src/extra/processor/webm.d.ts +27 -0
  250. package/lib/rtp/src/extra/processor/webm.js +57 -23
  251. package/lib/rtp/src/extra/processor/webm.js.map +1 -1
  252. package/lib/rtp/src/extra/processor/webmCallback.js +6 -1
  253. package/lib/rtp/src/extra/processor/webmCallback.js.map +1 -1
  254. package/lib/rtp/src/extra/processor/webmStream.js.map +1 -1
  255. package/lib/rtp/src/helper.d.ts +2 -2
  256. package/lib/rtp/src/helper.js +2 -6
  257. package/lib/rtp/src/helper.js.map +1 -1
  258. package/lib/rtp/src/index.d.ts +10 -2
  259. package/lib/rtp/src/index.js +10 -2
  260. package/lib/rtp/src/index.js.map +1 -1
  261. package/lib/rtp/src/rtcp/psfb/fullIntraRequest.d.ts +4 -0
  262. package/lib/rtp/src/rtcp/psfb/fullIntraRequest.js +6 -1
  263. package/lib/rtp/src/rtcp/psfb/fullIntraRequest.js.map +1 -1
  264. package/lib/rtp/src/rtcp/rtcp.js +9 -4
  265. package/lib/rtp/src/rtcp/rtcp.js.map +1 -1
  266. package/lib/rtp/src/rtcp/rtpfb/transportWideSequence.d.ts +58 -0
  267. package/lib/rtp/src/rtcp/rtpfb/transportWideSequence.js +143 -0
  268. package/lib/rtp/src/rtcp/rtpfb/transportWideSequence.js.map +1 -0
  269. package/lib/rtp/src/rtcp/rtpfb/twcc.d.ts +35 -13
  270. package/lib/rtp/src/rtcp/rtpfb/twcc.js +132 -54
  271. package/lib/rtp/src/rtcp/rtpfb/twcc.js.map +1 -1
  272. package/lib/rtp/src/rtcp/rtpfb/twccReceiveTiming.d.ts +13 -0
  273. package/lib/rtp/src/rtcp/rtpfb/twccReceiveTiming.js +29 -0
  274. package/lib/rtp/src/rtcp/rtpfb/twccReceiveTiming.js.map +1 -0
  275. package/lib/rtp/src/rtcp/rtpfb/twccReferenceTime.d.ts +41 -0
  276. package/lib/rtp/src/rtcp/rtpfb/twccReferenceTime.js +89 -0
  277. package/lib/rtp/src/rtcp/rtpfb/twccReferenceTime.js.map +1 -0
  278. package/lib/rtp/src/rtcp/sr.d.ts +4 -3
  279. package/lib/rtp/src/rtcp/sr.js +4 -2
  280. package/lib/rtp/src/rtcp/sr.js.map +1 -1
  281. package/lib/rtp/src/rtp/continuity.d.ts +36 -0
  282. package/lib/rtp/src/rtp/continuity.js +100 -0
  283. package/lib/rtp/src/rtp/continuity.js.map +1 -0
  284. package/lib/rtp/src/rtp/headerExtension.js +41 -21
  285. package/lib/rtp/src/rtp/headerExtension.js.map +1 -1
  286. package/lib/rtp/src/rtp/padding.d.ts +17 -0
  287. package/lib/rtp/src/rtp/padding.js +37 -0
  288. package/lib/rtp/src/rtp/padding.js.map +1 -0
  289. package/lib/rtp/src/rtp/red/encoder.d.ts +10 -0
  290. package/lib/rtp/src/rtp/red/encoder.js +14 -1
  291. package/lib/rtp/src/rtp/red/encoder.js.map +1 -1
  292. package/lib/rtp/src/rtp/red/packet.js +24 -8
  293. package/lib/rtp/src/rtp/red/packet.js.map +1 -1
  294. package/lib/rtp/src/rtp/rtp.d.ts +24 -1
  295. package/lib/rtp/src/rtp/rtp.js +70 -29
  296. package/lib/rtp/src/rtp/rtp.js.map +1 -1
  297. package/lib/rtp/src/rtp/rtx.js +3 -0
  298. package/lib/rtp/src/rtp/rtx.js.map +1 -1
  299. package/lib/rtp/src/rtp/sendHeaderExtensions.d.ts +36 -0
  300. package/lib/rtp/src/rtp/sendHeaderExtensions.js +85 -0
  301. package/lib/rtp/src/rtp/sendHeaderExtensions.js.map +1 -0
  302. package/lib/rtp/src/srtp/cipher/ctr.d.ts +2 -2
  303. package/lib/rtp/src/srtp/cipher/ctr.js +5 -3
  304. package/lib/rtp/src/srtp/cipher/ctr.js.map +1 -1
  305. package/lib/rtp/src/srtp/cipher/gcm.d.ts +1 -1
  306. package/lib/rtp/src/srtp/cipher/gcm.js +1 -1
  307. package/lib/rtp/src/srtp/cipher/gcm.js.map +1 -1
  308. package/lib/rtp/src/srtp/cipher/index.js +8 -4
  309. package/lib/rtp/src/srtp/cipher/index.js.map +1 -1
  310. package/lib/rtp/src/srtp/context/context.d.ts +29 -1
  311. package/lib/rtp/src/srtp/context/context.js +84 -27
  312. package/lib/rtp/src/srtp/context/context.js.map +1 -1
  313. package/lib/rtp/src/srtp/context/srtcp.d.ts +1 -1
  314. package/lib/rtp/src/srtp/context/srtcp.js +33 -0
  315. package/lib/rtp/src/srtp/context/srtcp.js.map +1 -1
  316. package/lib/rtp/src/srtp/context/srtp.d.ts +1 -1
  317. package/lib/rtp/src/srtp/context/srtp.js +36 -4
  318. package/lib/rtp/src/srtp/context/srtp.js.map +1 -1
  319. package/lib/rtp/src/srtp/error.d.ts +8 -0
  320. package/lib/rtp/src/srtp/error.js +13 -1
  321. package/lib/rtp/src/srtp/error.js.map +1 -1
  322. package/lib/rtp/src/srtp/packet.js +4 -1
  323. package/lib/rtp/src/srtp/packet.js.map +1 -1
  324. package/lib/rtp/src/srtp/replay.d.ts +24 -0
  325. package/lib/rtp/src/srtp/replay.js +75 -0
  326. package/lib/rtp/src/srtp/replay.js.map +1 -0
  327. package/lib/rtp/src/srtp/session.js +2 -1
  328. package/lib/rtp/src/srtp/session.js.map +1 -1
  329. package/lib/rtp/src/srtp/srtcp.js +2 -1
  330. package/lib/rtp/src/srtp/srtcp.js.map +1 -1
  331. package/lib/rtp/src/srtp/srtp.js +2 -1
  332. package/lib/rtp/src/srtp/srtp.js.map +1 -1
  333. package/lib/rtp/src/util.js +2 -1
  334. package/lib/rtp/src/util.js.map +1 -1
  335. package/lib/sctp/src/chunk.d.ts +5 -0
  336. package/lib/sctp/src/chunk.js +31 -8
  337. package/lib/sctp/src/chunk.js.map +1 -1
  338. package/lib/sctp/src/const.d.ts +25 -17
  339. package/lib/sctp/src/const.js +23 -19
  340. package/lib/sctp/src/const.js.map +1 -1
  341. package/lib/sctp/src/index.d.ts +4 -3
  342. package/lib/sctp/src/index.js +10 -8
  343. package/lib/sctp/src/index.js.map +1 -1
  344. package/lib/sctp/src/param.d.ts +6 -2
  345. package/lib/sctp/src/param.js +22 -8
  346. package/lib/sctp/src/param.js.map +1 -1
  347. package/lib/sctp/src/sctp.d.ts +91 -2
  348. package/lib/sctp/src/sctp.js +700 -134
  349. package/lib/sctp/src/sctp.js.map +1 -1
  350. package/lib/sctp/src/transport.js +4 -2
  351. package/lib/sctp/src/transport.js.map +1 -1
  352. package/lib/webrtc/src/api/peerConfig.d.ts +307 -0
  353. package/lib/webrtc/src/api/peerConfig.js +291 -0
  354. package/lib/webrtc/src/api/peerConfig.js.map +1 -0
  355. package/lib/webrtc/src/api/peerConnectionEvents.d.ts +36 -0
  356. package/lib/webrtc/src/api/peerConnectionEvents.js +44 -0
  357. package/lib/webrtc/src/api/peerConnectionEvents.js.map +1 -0
  358. package/lib/webrtc/src/dataChannel.d.ts +11 -1
  359. package/lib/webrtc/src/dataChannel.js +25 -5
  360. package/lib/webrtc/src/dataChannel.js.map +1 -1
  361. package/lib/webrtc/src/index.d.ts +2 -2
  362. package/lib/webrtc/src/index.js +2 -2
  363. package/lib/webrtc/src/index.js.map +1 -1
  364. package/lib/webrtc/src/media/index.d.ts +11 -1
  365. package/lib/webrtc/src/media/index.js +71 -1
  366. package/lib/webrtc/src/media/index.js.map +1 -1
  367. package/lib/webrtc/src/media/receiver/nack.js +5 -5
  368. package/lib/webrtc/src/media/receiver/nack.js.map +1 -1
  369. package/lib/webrtc/src/media/receiver/receiverTwcc.d.ts +61 -1
  370. package/lib/webrtc/src/media/receiver/receiverTwcc.js +218 -63
  371. package/lib/webrtc/src/media/receiver/receiverTwcc.js.map +1 -1
  372. package/lib/webrtc/src/media/router.d.ts +130 -6
  373. package/lib/webrtc/src/media/router.js +325 -29
  374. package/lib/webrtc/src/media/router.js.map +1 -1
  375. package/lib/webrtc/src/media/rtpReceiver.d.ts +137 -14
  376. package/lib/webrtc/src/media/rtpReceiver.js +420 -44
  377. package/lib/webrtc/src/media/rtpReceiver.js.map +1 -1
  378. package/lib/webrtc/src/media/rtpSender.d.ts +232 -65
  379. package/lib/webrtc/src/media/rtpSender.js +784 -448
  380. package/lib/webrtc/src/media/rtpSender.js.map +1 -1
  381. package/lib/webrtc/src/media/rtpTransceiver.d.ts +95 -4
  382. package/lib/webrtc/src/media/rtpTransceiver.js +121 -9
  383. package/lib/webrtc/src/media/rtpTransceiver.js.map +1 -1
  384. package/lib/webrtc/src/media/sender/bandwidthEstimator.d.ts +249 -0
  385. package/lib/webrtc/src/media/sender/bandwidthEstimator.js +144 -0
  386. package/lib/webrtc/src/media/sender/bandwidthEstimator.js.map +1 -0
  387. package/lib/webrtc/src/media/sender/createBandwidthEstimator.d.ts +20 -0
  388. package/lib/webrtc/src/media/sender/createBandwidthEstimator.js +26 -0
  389. package/lib/webrtc/src/media/sender/createBandwidthEstimator.js.map +1 -0
  390. package/lib/webrtc/src/media/sender/estimatorBinding.d.ts +70 -0
  391. package/lib/webrtc/src/media/sender/estimatorBinding.js +175 -0
  392. package/lib/webrtc/src/media/sender/estimatorBinding.js.map +1 -0
  393. package/lib/webrtc/src/media/sender/estimators/disabledBwe.d.ts +18 -0
  394. package/lib/webrtc/src/media/sender/estimators/disabledBwe.js +44 -0
  395. package/lib/webrtc/src/media/sender/estimators/disabledBwe.js.map +1 -0
  396. package/lib/webrtc/src/media/sender/estimators/gcc/acknowledgedBitrateEstimator.d.ts +79 -0
  397. package/lib/webrtc/src/media/sender/estimators/gcc/acknowledgedBitrateEstimator.js +289 -0
  398. package/lib/webrtc/src/media/sender/estimators/gcc/acknowledgedBitrateEstimator.js.map +1 -0
  399. package/lib/webrtc/src/media/sender/estimators/gcc/aimdRateControl.d.ts +87 -0
  400. package/lib/webrtc/src/media/sender/estimators/gcc/aimdRateControl.js +429 -0
  401. package/lib/webrtc/src/media/sender/estimators/gcc/aimdRateControl.js.map +1 -0
  402. package/lib/webrtc/src/media/sender/estimators/gcc/alrDetector.d.ts +21 -0
  403. package/lib/webrtc/src/media/sender/estimators/gcc/alrDetector.js +84 -0
  404. package/lib/webrtc/src/media/sender/estimators/gcc/alrDetector.js.map +1 -0
  405. package/lib/webrtc/src/media/sender/estimators/gcc/bandwidthLimitedCause.d.ts +37 -0
  406. package/lib/webrtc/src/media/sender/estimators/gcc/bandwidthLimitedCause.js +74 -0
  407. package/lib/webrtc/src/media/sender/estimators/gcc/bandwidthLimitedCause.js.map +1 -0
  408. package/lib/webrtc/src/media/sender/estimators/gcc/constants.d.ts +383 -0
  409. package/lib/webrtc/src/media/sender/estimators/gcc/constants.js +408 -0
  410. package/lib/webrtc/src/media/sender/estimators/gcc/constants.js.map +1 -0
  411. package/lib/webrtc/src/media/sender/estimators/gcc/gccBwe.d.ts +406 -0
  412. package/lib/webrtc/src/media/sender/estimators/gcc/gccBwe.js +1391 -0
  413. package/lib/webrtc/src/media/sender/estimators/gcc/gccBwe.js.map +1 -0
  414. package/lib/webrtc/src/media/sender/estimators/gcc/index.d.ts +19 -0
  415. package/lib/webrtc/src/media/sender/estimators/gcc/index.js +75 -0
  416. package/lib/webrtc/src/media/sender/estimators/gcc/index.js.map +1 -0
  417. package/lib/webrtc/src/media/sender/estimators/gcc/interArrivalDelta.d.ts +68 -0
  418. package/lib/webrtc/src/media/sender/estimators/gcc/interArrivalDelta.js +201 -0
  419. package/lib/webrtc/src/media/sender/estimators/gcc/interArrivalDelta.js.map +1 -0
  420. package/lib/webrtc/src/media/sender/estimators/gcc/intervalBudget.d.ts +26 -0
  421. package/lib/webrtc/src/media/sender/estimators/gcc/intervalBudget.js +72 -0
  422. package/lib/webrtc/src/media/sender/estimators/gcc/intervalBudget.js.map +1 -0
  423. package/lib/webrtc/src/media/sender/estimators/gcc/linkCapacityEstimator.d.ts +41 -0
  424. package/lib/webrtc/src/media/sender/estimators/gcc/linkCapacityEstimator.js +99 -0
  425. package/lib/webrtc/src/media/sender/estimators/gcc/linkCapacityEstimator.js.map +1 -0
  426. package/lib/webrtc/src/media/sender/estimators/gcc/lossBasedBwe.d.ts +247 -0
  427. package/lib/webrtc/src/media/sender/estimators/gcc/lossBasedBwe.js +1042 -0
  428. package/lib/webrtc/src/media/sender/estimators/gcc/lossBasedBwe.js.map +1 -0
  429. package/lib/webrtc/src/media/sender/estimators/gcc/overuseDetector.d.ts +26 -0
  430. package/lib/webrtc/src/media/sender/estimators/gcc/overuseDetector.js +132 -0
  431. package/lib/webrtc/src/media/sender/estimators/gcc/overuseDetector.js.map +1 -0
  432. package/lib/webrtc/src/media/sender/estimators/gcc/probeController.d.ts +305 -0
  433. package/lib/webrtc/src/media/sender/estimators/gcc/probeController.js +1073 -0
  434. package/lib/webrtc/src/media/sender/estimators/gcc/probeController.js.map +1 -0
  435. package/lib/webrtc/src/media/sender/estimators/gcc/rttBasedBackoff.d.ts +60 -0
  436. package/lib/webrtc/src/media/sender/estimators/gcc/rttBasedBackoff.js +151 -0
  437. package/lib/webrtc/src/media/sender/estimators/gcc/rttBasedBackoff.js.map +1 -0
  438. package/lib/webrtc/src/media/sender/estimators/gcc/trendlineEstimator.d.ts +44 -0
  439. package/lib/webrtc/src/media/sender/estimators/gcc/trendlineEstimator.js +246 -0
  440. package/lib/webrtc/src/media/sender/estimators/gcc/trendlineEstimator.js.map +1 -0
  441. package/lib/webrtc/src/media/sender/estimators/index.d.ts +7 -0
  442. package/lib/webrtc/src/media/sender/estimators/index.js +19 -0
  443. package/lib/webrtc/src/media/sender/estimators/index.js.map +1 -0
  444. package/lib/webrtc/src/media/sender/estimators/lightweightBwe.d.ts +64 -0
  445. package/lib/webrtc/src/media/sender/estimators/lightweightBwe.js +216 -0
  446. package/lib/webrtc/src/media/sender/estimators/lightweightBwe.js.map +1 -0
  447. package/lib/webrtc/src/media/sender/estimators/twccFeedbackAdapter.d.ts +117 -0
  448. package/lib/webrtc/src/media/sender/estimators/twccFeedbackAdapter.js +250 -0
  449. package/lib/webrtc/src/media/sender/estimators/twccFeedbackAdapter.js.map +1 -0
  450. package/lib/webrtc/src/media/sender/outgoingQueue.d.ts +40 -0
  451. package/lib/webrtc/src/media/sender/outgoingQueue.js +153 -0
  452. package/lib/webrtc/src/media/sender/outgoingQueue.js.map +1 -0
  453. package/lib/webrtc/src/media/sender/padding.d.ts +45 -0
  454. package/lib/webrtc/src/media/sender/padding.js +134 -0
  455. package/lib/webrtc/src/media/sender/padding.js.map +1 -0
  456. package/lib/webrtc/src/media/sender/pendingRtp.d.ts +35 -0
  457. package/lib/webrtc/src/media/sender/pendingRtp.js +120 -0
  458. package/lib/webrtc/src/media/sender/pendingRtp.js.map +1 -0
  459. package/lib/webrtc/src/media/sender/rtpWire.d.ts +13 -0
  460. package/lib/webrtc/src/media/sender/rtpWire.js +38 -0
  461. package/lib/webrtc/src/media/sender/rtpWire.js.map +1 -0
  462. package/lib/webrtc/src/media/sender/sendPacer.d.ts +27 -0
  463. package/lib/webrtc/src/media/sender/sendPacer.js +110 -0
  464. package/lib/webrtc/src/media/sender/sendPacer.js.map +1 -0
  465. package/lib/webrtc/src/media/sender/senderBWE.d.ts +8 -32
  466. package/lib/webrtc/src/media/sender/senderBWE.js +5 -142
  467. package/lib/webrtc/src/media/sender/senderBWE.js.map +1 -1
  468. package/lib/webrtc/src/media/sender/senderStats.d.ts +100 -0
  469. package/lib/webrtc/src/media/sender/senderStats.js +322 -0
  470. package/lib/webrtc/src/media/sender/senderStats.js.map +1 -0
  471. package/lib/webrtc/src/media/track.d.ts +21 -3
  472. package/lib/webrtc/src/media/track.js +24 -6
  473. package/lib/webrtc/src/media/track.js.map +1 -1
  474. package/lib/webrtc/src/negotiation/bundleTopology.d.ts +103 -0
  475. package/lib/webrtc/src/negotiation/bundleTopology.js +384 -0
  476. package/lib/webrtc/src/negotiation/bundleTopology.js.map +1 -0
  477. package/lib/webrtc/src/negotiation/descriptionValidation.d.ts +51 -0
  478. package/lib/webrtc/src/negotiation/descriptionValidation.js +267 -0
  479. package/lib/webrtc/src/negotiation/descriptionValidation.js.map +1 -0
  480. package/lib/webrtc/src/negotiation/iceRestartRequest.d.ts +21 -0
  481. package/lib/webrtc/src/negotiation/iceRestartRequest.js +61 -0
  482. package/lib/webrtc/src/negotiation/iceRestartRequest.js.map +1 -0
  483. package/lib/webrtc/src/negotiation/internalState.d.ts +34 -0
  484. package/lib/webrtc/src/negotiation/internalState.js +21 -0
  485. package/lib/webrtc/src/negotiation/internalState.js.map +1 -0
  486. package/lib/webrtc/src/negotiation/negotiationNeeded.d.ts +44 -0
  487. package/lib/webrtc/src/negotiation/negotiationNeeded.js +119 -0
  488. package/lib/webrtc/src/negotiation/negotiationNeeded.js.map +1 -0
  489. package/lib/webrtc/src/negotiation/remoteCandidates.d.ts +86 -0
  490. package/lib/webrtc/src/negotiation/remoteCandidates.js +349 -0
  491. package/lib/webrtc/src/negotiation/remoteCandidates.js.map +1 -0
  492. package/lib/webrtc/src/negotiation/remoteMediaApplication.d.ts +71 -0
  493. package/lib/webrtc/src/negotiation/remoteMediaApplication.js +414 -0
  494. package/lib/webrtc/src/negotiation/remoteMediaApplication.js.map +1 -0
  495. package/lib/webrtc/src/negotiation/transportActivation.d.ts +59 -0
  496. package/lib/webrtc/src/negotiation/transportActivation.js +356 -0
  497. package/lib/webrtc/src/negotiation/transportActivation.js.map +1 -0
  498. package/lib/webrtc/src/negotiationTransaction.d.ts +240 -0
  499. package/lib/webrtc/src/negotiationTransaction.js +604 -0
  500. package/lib/webrtc/src/negotiationTransaction.js.map +1 -0
  501. package/lib/webrtc/src/nonstandard/dummyMedia.js +2 -1
  502. package/lib/webrtc/src/nonstandard/dummyMedia.js.map +1 -1
  503. package/lib/webrtc/src/nonstandard/index.d.ts +1 -1
  504. package/lib/webrtc/src/nonstandard/index.js +1 -1
  505. package/lib/webrtc/src/nonstandard/index.js.map +1 -1
  506. package/lib/webrtc/src/nonstandard/navigator.js +4 -3
  507. package/lib/webrtc/src/nonstandard/navigator.js.map +1 -1
  508. package/lib/webrtc/src/nonstandard/recorder/index.d.ts +32 -8
  509. package/lib/webrtc/src/nonstandard/recorder/index.js +81 -20
  510. package/lib/webrtc/src/nonstandard/recorder/index.js.map +1 -1
  511. package/lib/webrtc/src/nonstandard/recorder/writer/index.d.ts +10 -8
  512. package/lib/webrtc/src/nonstandard/recorder/writer/index.js +2 -1
  513. package/lib/webrtc/src/nonstandard/recorder/writer/index.js.map +1 -1
  514. package/lib/webrtc/src/nonstandard/recorder/writer/ogg.d.ts +32 -0
  515. package/lib/webrtc/src/nonstandard/recorder/writer/ogg.js +185 -0
  516. package/lib/webrtc/src/nonstandard/recorder/writer/ogg.js.map +1 -0
  517. package/lib/webrtc/src/nonstandard/recorder/writer/webm.d.ts +2 -2
  518. package/lib/webrtc/src/nonstandard/recorder/writer/webm.js +10 -3
  519. package/lib/webrtc/src/nonstandard/recorder/writer/webm.js.map +1 -1
  520. package/lib/webrtc/src/nonstandard/userMedia/packetizer.d.ts +2 -2
  521. package/lib/webrtc/src/nonstandard/userMedia/packetizer.js.map +1 -1
  522. package/lib/webrtc/src/nonstandard/userMedia.d.ts +2 -2
  523. package/lib/webrtc/src/nonstandard/userMedia.js +4 -3
  524. package/lib/webrtc/src/nonstandard/userMedia.js.map +1 -1
  525. package/lib/webrtc/src/peerConnection.d.ts +176 -238
  526. package/lib/webrtc/src/peerConnection.js +1042 -913
  527. package/lib/webrtc/src/peerConnection.js.map +1 -1
  528. package/lib/webrtc/src/polyfill/api.d.ts +5 -5
  529. package/lib/webrtc/src/polyfill/api.js.map +1 -1
  530. package/lib/webrtc/src/polyfill/index.js.map +1 -1
  531. package/lib/webrtc/src/polyfill/install.js +1 -1
  532. package/lib/webrtc/src/polyfill/install.js.map +1 -1
  533. package/lib/webrtc/src/polyfill/mediaDevices.js +2 -1
  534. package/lib/webrtc/src/polyfill/mediaDevices.js.map +1 -1
  535. package/lib/webrtc/src/polyfill/registers/mp4Webm.js.map +1 -1
  536. package/lib/webrtc/src/polyfill/registers/rtpRtcp.js.map +1 -1
  537. package/lib/webrtc/src/polyfill/selectSettings.js.map +1 -1
  538. package/lib/webrtc/src/polyfill/sourceIo.js.map +1 -1
  539. package/lib/webrtc/src/sctpManager.d.ts +97 -1
  540. package/lib/webrtc/src/sctpManager.js +189 -9
  541. package/lib/webrtc/src/sctpManager.js.map +1 -1
  542. package/lib/webrtc/src/sdp.js +12 -6
  543. package/lib/webrtc/src/sdp.js.map +1 -1
  544. package/lib/webrtc/src/sdpManager.d.ts +55 -11
  545. package/lib/webrtc/src/sdpManager.js +364 -87
  546. package/lib/webrtc/src/sdpManager.js.map +1 -1
  547. package/lib/webrtc/src/secureTransportManager.d.ts +89 -28
  548. package/lib/webrtc/src/secureTransportManager.js +232 -53
  549. package/lib/webrtc/src/secureTransportManager.js.map +1 -1
  550. package/lib/webrtc/src/transceiverManager.d.ts +62 -18
  551. package/lib/webrtc/src/transceiverManager.js +272 -107
  552. package/lib/webrtc/src/transceiverManager.js.map +1 -1
  553. package/lib/webrtc/src/transport/dtls.d.ts +64 -3
  554. package/lib/webrtc/src/transport/dtls.js +166 -42
  555. package/lib/webrtc/src/transport/dtls.js.map +1 -1
  556. package/lib/webrtc/src/transport/ice.d.ts +199 -28
  557. package/lib/webrtc/src/transport/ice.js +666 -71
  558. package/lib/webrtc/src/transport/ice.js.map +1 -1
  559. package/lib/webrtc/src/transport/iceCandidateAttribute.d.ts +98 -0
  560. package/lib/webrtc/src/transport/iceCandidateAttribute.js +129 -0
  561. package/lib/webrtc/src/transport/iceCandidateAttribute.js.map +1 -0
  562. package/lib/webrtc/src/transport/sctp.d.ts +6 -1
  563. package/lib/webrtc/src/transport/sctp.js +149 -37
  564. package/lib/webrtc/src/transport/sctp.js.map +1 -1
  565. package/lib/webrtc/src/utils.d.ts +39 -6
  566. package/lib/webrtc/src/utils.js +57 -17
  567. package/lib/webrtc/src/utils.js.map +1 -1
  568. package/package.json +16 -15
@@ -1,10 +1,44 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TurnProtocol = exports.StunOverTurnProtocol = void 0;
36
+ exports.TurnProtocol = exports.StunOverTurnProtocol = exports.TurnRedirectError = void 0;
4
37
  exports.createTurnClient = createTurnClient;
5
38
  exports.createStunOverTurnClient = createStunOverTurnClient;
6
39
  exports.makeIntegrityKey = makeIntegrityKey;
7
40
  const node_net_1 = require("node:net");
41
+ const tls = __importStar(require("node:tls"));
8
42
  const promises_1 = require("timers/promises");
9
43
  const auth_1 = require("../../../ice-server/src/turn/auth");
10
44
  const exceptions_1 = require("../exceptions");
@@ -13,11 +47,16 @@ const common_1 = require("../imports/common");
13
47
  const const_1 = require("../stun/const");
14
48
  const message_1 = require("../stun/message");
15
49
  const transaction_1 = require("../stun/transaction");
50
+ const credential_1 = require("./credential");
16
51
  const frame_1 = require("./frame");
17
52
  const log = (0, common_1.debug)("werift-ice:packages/ice/src/turn/protocol.ts");
18
53
  const DEFAULT_CHANNEL_REFRESH_TIME = 500;
19
54
  const DEFAULT_ALLOCATION_LIFETIME = 600;
20
55
  const UDP_TRANSPORT = 0x11000000;
56
+ /** 300 (Try Alternate) redirects followed for one Allocate before giving up. */
57
+ const DEFAULT_MAX_ALLOCATE_REDIRECTS = 3;
58
+ var exceptions_2 = require("../exceptions");
59
+ Object.defineProperty(exports, "TurnRedirectError", { enumerable: true, get: function () { return exceptions_2.TurnRedirectError; } });
21
60
  function isStreamTransport(transport) {
22
61
  return transport.type === "tcp" || transport.type === "tls";
23
62
  }
@@ -35,7 +74,18 @@ class StunOverTurnProtocol {
35
74
  enumerable: true,
36
75
  configurable: true,
37
76
  writable: true,
38
- value: turn
77
+ value: void 0
78
+ });
79
+ /**
80
+ * The transport the TURN server was configured with. A UDP entry whose
81
+ * allocation fell back to TCP keeps "udp" here, so a restart that removes
82
+ * that entry also releases the fallback allocation.
83
+ */
84
+ Object.defineProperty(this, "configuredTransport", {
85
+ enumerable: true,
86
+ configurable: true,
87
+ writable: true,
88
+ value: void 0
39
89
  });
40
90
  Object.defineProperty(this, "type", {
41
91
  enumerable: true,
@@ -101,6 +151,7 @@ class StunOverTurnProtocol {
101
151
  }
102
152
  }
103
153
  });
154
+ this.turn = turn;
104
155
  turn.onData
105
156
  .subscribe((data, addr) => {
106
157
  this.handleStunMessage(data, addr);
@@ -153,44 +204,47 @@ Object.defineProperty(StunOverTurnProtocol, "type", {
153
204
  value: "turn"
154
205
  });
155
206
  class TurnProtocol {
156
- constructor(
157
- /** TURN server as configured; the host may be a hostname. */
158
- server, username, password, lifetime, transport, options = {}) {
207
+ constructor(server, username, password, lifetime, transport, options = {}) {
208
+ /**
209
+ * TURN server the allocation is made on; the host may be a hostname.
210
+ * Starts as the configured server and becomes the ALTERNATE-SERVER when
211
+ * an Allocate is redirected with 300 (Try Alternate).
212
+ */
159
213
  Object.defineProperty(this, "server", {
160
214
  enumerable: true,
161
215
  configurable: true,
162
216
  writable: true,
163
- value: server
217
+ value: void 0
164
218
  });
165
219
  Object.defineProperty(this, "username", {
166
220
  enumerable: true,
167
221
  configurable: true,
168
222
  writable: true,
169
- value: username
223
+ value: void 0
170
224
  });
171
225
  Object.defineProperty(this, "password", {
172
226
  enumerable: true,
173
227
  configurable: true,
174
228
  writable: true,
175
- value: password
229
+ value: void 0
176
230
  });
177
231
  Object.defineProperty(this, "lifetime", {
178
232
  enumerable: true,
179
233
  configurable: true,
180
234
  writable: true,
181
- value: lifetime
235
+ value: void 0
182
236
  });
183
237
  Object.defineProperty(this, "transport", {
184
238
  enumerable: true,
185
239
  configurable: true,
186
240
  writable: true,
187
- value: transport
241
+ value: void 0
188
242
  });
189
243
  Object.defineProperty(this, "options", {
190
244
  enumerable: true,
191
245
  configurable: true,
192
246
  writable: true,
193
- value: options
247
+ value: void 0
194
248
  });
195
249
  Object.defineProperty(this, "type", {
196
250
  enumerable: true,
@@ -258,6 +312,13 @@ class TurnProtocol {
258
312
  writable: true,
259
313
  value: {}
260
314
  });
315
+ /** close() ran: no new transaction starts. */
316
+ Object.defineProperty(this, "closed", {
317
+ enumerable: true,
318
+ configurable: true,
319
+ writable: true,
320
+ value: false
321
+ });
261
322
  Object.defineProperty(this, "refreshHandle", {
262
323
  enumerable: true,
263
324
  configurable: true,
@@ -350,6 +411,13 @@ class TurnProtocol {
350
411
  writable: true,
351
412
  value: void 0
352
413
  });
414
+ /** TURN server as configured, before any 300 (Try Alternate) redirect. */
415
+ Object.defineProperty(this, "configuredServer", {
416
+ enumerable: true,
417
+ configurable: true,
418
+ writable: true,
419
+ value: void 0
420
+ });
353
421
  Object.defineProperty(this, "refresh", {
354
422
  enumerable: true,
355
423
  configurable: true,
@@ -393,18 +461,19 @@ class TurnProtocol {
393
461
  });
394
462
  }
395
463
  });
464
+ this.server = server;
465
+ this.username = username;
466
+ this.password = password;
467
+ this.lifetime = lifetime;
468
+ this.transport = transport;
469
+ this.options = options;
470
+ this.configuredServer = server;
396
471
  this.channelRefreshTime =
397
472
  this.options.channelRefreshTime ?? DEFAULT_CHANNEL_REFRESH_TIME;
398
473
  }
399
474
  async connectionMade() {
400
- this.transport.onData = (data, addr) => {
401
- this.dataReceived(data, addr);
402
- };
403
- const request = new message_1.Message(const_1.methods.ALLOCATE, const_1.classes.REQUEST);
404
- request
405
- .setAttribute("LIFETIME", this.lifetime)
406
- .setAttribute("REQUESTED-TRANSPORT", UDP_TRANSPORT);
407
- const [response] = await this.requestWithRetry(request, this.server).catch((e) => {
475
+ this.attachTransport();
476
+ const [response] = await this.allocate().catch((e) => {
408
477
  log("connect error", e);
409
478
  throw e;
410
479
  });
@@ -412,8 +481,106 @@ class TurnProtocol {
412
481
  this.mappedAddress = response.getAttributeValue("XOR-MAPPED-ADDRESS");
413
482
  const exp = response.getAttributeValue("LIFETIME");
414
483
  log("connect", this.relayedAddress, this.mappedAddress, { exp });
484
+ // close() ran while the response was in flight: no refresh starts.
485
+ if (this.closed)
486
+ throw new exceptions_1.TransactionCancelled();
415
487
  this.refresh(exp);
416
488
  }
489
+ attachTransport() {
490
+ this.transport.onData = (data, addr) => {
491
+ this.dataReceived(data, addr);
492
+ };
493
+ this.transport.onError?.subscribe((error) => {
494
+ log("transport error", error);
495
+ });
496
+ }
497
+ /**
498
+ * Allocate on the current server, following 300 (Try Alternate) to the
499
+ * ALTERNATE-SERVER with the same transport protocol and credentials
500
+ * (RFC 8656 §7.4, RFC 8489 §10). Only Allocate is redirected: an existing
501
+ * allocation lives on one server, so Refresh, CreatePermission and
502
+ * ChannelBind never move.
503
+ */
504
+ async allocate() {
505
+ const maxRedirects = this.options.maxAllocateRedirects ?? DEFAULT_MAX_ALLOCATE_REDIRECTS;
506
+ /** Servers this Allocate has been sent to, to detect redirect loops. */
507
+ const tried = [];
508
+ for (let redirects = 0;; redirects++) {
509
+ // A fresh request per server: a redirected request may already carry
510
+ // MESSAGE-INTEGRITY for the previous server's realm and nonce.
511
+ const request = new message_1.Message(const_1.methods.ALLOCATE, const_1.classes.REQUEST)
512
+ .setAttribute("LIFETIME", this.lifetime)
513
+ .setAttribute("REQUESTED-TRANSPORT", UDP_TRANSPORT);
514
+ try {
515
+ return await this.requestWithRetry(request, this.server);
516
+ }
517
+ catch (error) {
518
+ const alternate = tryAlternateOf(error, this.transport.addressFamily);
519
+ if (!alternate) {
520
+ throw error;
521
+ }
522
+ // The request has resolved the configured host, so its endpoint is
523
+ // known here: a redirect to the resolved IP of a host name is a loop.
524
+ tried.push(this.server);
525
+ if (this.pinnedServerEndpoint) {
526
+ tried.push(this.pinnedServerEndpoint);
527
+ }
528
+ const failed = error;
529
+ const fail = (reason) => new exceptions_1.TurnRedirectError(reason, this.server, alternate.server, failed);
530
+ if (!alternate.server) {
531
+ throw new exceptions_1.TurnRedirectError("missing-alternate", this.server, undefined, failed);
532
+ }
533
+ if (tried.some((addr) => (0, transaction_1.addressEquals)(addr, alternate.server))) {
534
+ throw fail("loop");
535
+ }
536
+ if (redirects >= maxRedirects) {
537
+ throw fail("too-many-redirects");
538
+ }
539
+ if (isStreamTransport(this.transport) && !this.options.reconnect) {
540
+ throw fail("unsupported-transport");
541
+ }
542
+ log("allocate redirected", this.server, "->", alternate);
543
+ await this.switchServer(alternate);
544
+ }
545
+ }
546
+ }
547
+ /**
548
+ * Point the client at an ALTERNATE-SERVER. Authentication state belongs to
549
+ * the previous server, so the alternate starts again with an
550
+ * unauthenticated Allocate and its own 401 realm/nonce; username and
551
+ * password are kept.
552
+ */
553
+ async switchServer({ server, domain }) {
554
+ let endpoint;
555
+ if (isStreamTransport(this.transport)) {
556
+ const previous = this.transport;
557
+ previous.onData = () => { };
558
+ await previous.close();
559
+ const reconnected = await this.options.reconnect(server, domain);
560
+ // close() ran while reconnecting: it saw only the closed previous
561
+ // transport, so the new connection is released here.
562
+ if (this.closed) {
563
+ reconnected.onData = () => { };
564
+ await reconnected.close();
565
+ throw new exceptions_1.TransactionCancelled();
566
+ }
567
+ this.transport = reconnected;
568
+ this.tcpBuffer = Buffer.alloc(0);
569
+ this.attachTransport();
570
+ endpoint = this.transport.remoteAddress ?? server;
571
+ }
572
+ else {
573
+ // ALTERNATE-SERVER is an IP literal. One of the other family cannot be
574
+ // reached from this socket (AddressFamilyMismatch).
575
+ endpoint = await (0, transaction_1.resolveRequestAddress)(server, this.transport.addressFamily ?? 0);
576
+ }
577
+ this.server = server;
578
+ this.pinnedServerEndpoint = endpoint;
579
+ this.serverEndpointSelection = Promise.resolve(endpoint);
580
+ this.nonce = undefined;
581
+ this.realm = undefined;
582
+ this.integrityKey = undefined;
583
+ }
417
584
  handleChannelData(data) {
418
585
  const decoded = (0, frame_1.decodeChannelData)(data);
419
586
  const addr = decoded && this.addrByChannel[decoded.channelNumber];
@@ -431,14 +598,7 @@ class TurnProtocol {
431
598
  message.messageClass === const_1.classes.ERROR) {
432
599
  const transaction = this.transactions[message.transactionIdHex];
433
600
  if (transaction) {
434
- const verified = transaction.integrityKey
435
- ? (0, message_1.parseMessage)(data, transaction.integrityKey)
436
- : message;
437
- if (!verified) {
438
- log("TURN STUN response failed MESSAGE-INTEGRITY check");
439
- return;
440
- }
441
- transaction.responseReceived(verified, addr);
601
+ this.handleResponse(transaction, message, data, addr);
442
602
  }
443
603
  }
444
604
  else if (message.messageClass === const_1.classes.REQUEST) {
@@ -454,6 +614,37 @@ class TurnProtocol {
454
614
  log("parse error", data.toString());
455
615
  }
456
616
  }
617
+ /**
618
+ * Long-term credentials (RFC 8489 §9.2.5): a response to an authenticated
619
+ * request must carry a valid MESSAGE-INTEGRITY, except a 401/438 challenge
620
+ * without one, which goes to the retry logic of requestWithRetry. Over
621
+ * UDP an unverified response is dropped and retransmissions continue; over
622
+ * TCP/TLS it ends the transaction, except an unsigned 400, which is
623
+ * discarded as if never received.
624
+ */
625
+ handleResponse(transaction, message, data, addr) {
626
+ if (!transaction.integrityKey) {
627
+ transaction.responseReceived(message, addr);
628
+ return;
629
+ }
630
+ if ((0, transaction_1.isUnauthenticatedChallenge)(message)) {
631
+ transaction.challengeReceived(message, addr);
632
+ return;
633
+ }
634
+ const verified = (0, message_1.parseMessage)(data, transaction.integrityKey);
635
+ if (verified) {
636
+ transaction.responseReceived(verified, addr);
637
+ return;
638
+ }
639
+ log("TURN STUN response failed MESSAGE-INTEGRITY check");
640
+ const [errorCode] = message.getAttributeValue("ERROR-CODE") ?? [];
641
+ const unsignedBadRequest = message.messageClass === const_1.classes.ERROR &&
642
+ errorCode === 400 &&
643
+ !(0, transaction_1.hasMessageIntegrity)(message);
644
+ if (isStreamTransport(this.transport) && !unsignedBadRequest) {
645
+ transaction.integrityViolated(addr);
646
+ }
647
+ }
457
648
  dataReceived(data, addr) {
458
649
  const datagramReceived = (data, addr) => {
459
650
  if (data.length >= 4 && (0, frame_1.isChannelData)(data)) {
@@ -491,23 +682,36 @@ class TurnProtocol {
491
682
  // Use requestWithRetry for stale-nonce (438) consistency with ChannelBind.
492
683
  await this.requestWithRetry(request, this.server);
493
684
  }
494
- async request(request, addr, _integrityKey, retransmissionsOrOptions, onRequestSent) {
685
+ async request(request, addr, _integrityKey, retransmissionsOrOptions, onRequestSent, credentials) {
495
686
  if (this.transactions[request.transactionIdHex]) {
496
687
  throw new Error("exist");
497
688
  }
498
- if (this.integrityKey) {
689
+ const signing = credentials ?? {
690
+ realm: this.realm,
691
+ nonce: this.nonce,
692
+ integrityKey: this.integrityKey,
693
+ };
694
+ if (signing.integrityKey) {
695
+ // A retried request still carries the previous signature, which would
696
+ // otherwise be covered by the new MESSAGE-INTEGRITY.
499
697
  request
698
+ .removeAttribute("MESSAGE-INTEGRITY")
699
+ .removeAttribute("MESSAGE-INTEGRITY-SHA256")
700
+ .removeAttribute("FINGERPRINT")
500
701
  .setAttribute("USERNAME", this.username)
501
- .setAttribute("REALM", this.realm)
502
- .setAttribute("NONCE", this.nonce)
503
- .addMessageIntegrity(this.integrityKey)
702
+ .setAttribute("REALM", signing.realm)
703
+ .setAttribute("NONCE", signing.nonce)
704
+ .addMessageIntegrity(signing.integrityKey)
504
705
  .addFingerprint();
505
706
  }
506
707
  // TURN server allocation/refresh uses default STUN retry policy unless
507
708
  // callers pass explicit options. Peer consent goes through StunOverTurnProtocol.
508
709
  // Prefer the TURN session integrity key for response verification.
509
710
  const resolvedAddr = await this.resolveRequestTarget(addr);
510
- const options = (0, transaction_1.buildTransactionOptions)(this.integrityKey, retransmissionsOrOptions, onRequestSent);
711
+ // close() ran during the lookup: no transaction starts on a closed client.
712
+ if (this.closed)
713
+ throw new exceptions_1.TransactionCancelled();
714
+ const options = (0, transaction_1.buildTransactionOptions)(signing.integrityKey, retransmissionsOrOptions, onRequestSent);
511
715
  const transaction = new transaction_1.Transaction(request, resolvedAddr, this, options);
512
716
  this.transactions[request.transactionIdHex] = transaction;
513
717
  try {
@@ -576,37 +780,58 @@ class TurnProtocol {
576
780
  // a lookup with no family preference.
577
781
  return (0, transaction_1.resolveRequestAddress)(this.server);
578
782
  }
783
+ /**
784
+ * Send a request and follow the long-term credential mechanism of
785
+ * RFC 8489 §9.2.5: a 401 (Unauthenticated) or 438 (Stale Nonce) that
786
+ * allows it (see credentialRetryOf) is retried once with the new realm and
787
+ * nonce; any other error, or a second challenge, is thrown. The allocation's
788
+ * realm, nonce and integrity key change only when a retry is made; a retry
789
+ * under a new realm adopts them only once the server accepted it.
790
+ */
579
791
  async requestWithRetry(request, addr, signal) {
580
- let message, address;
581
792
  try {
582
- [message, address] = await this.request(request, addr, undefined, {
583
- signal,
584
- });
793
+ return await this.request(request, addr, undefined, { signal });
585
794
  }
586
795
  catch (error) {
587
796
  if (error instanceof exceptions_1.TransactionFailed == false) {
588
797
  log("requestWithRetry error", error);
589
798
  throw error;
590
799
  }
591
- const [errorCode] = error.response.getAttributeValue("ERROR-CODE");
592
- const nonce = error.response.getAttributeValue("NONCE");
593
- const realm = error.response.getAttributeValue("REALM");
594
- if (((errorCode === 401 && realm) || (errorCode === 438 && this.realm)) &&
595
- nonce) {
596
- log("retry with nonce", errorCode);
597
- this.nonce = nonce;
598
- if (errorCode === 401) {
599
- this.realm = realm;
600
- }
601
- this.integrityKey = makeIntegrityKey(this.username, this.realm, this.password);
602
- request.transactionId = (0, helper_1.randomTransactionId)();
603
- [message, address] = await this.request(request, this.server, undefined, { signal });
604
- }
605
- else {
800
+ // request() signed the request with the credentials of that moment.
801
+ const authenticated = request.attributesKeys.includes("MESSAGE-INTEGRITY");
802
+ const sentRealm = authenticated
803
+ ? request.getAttributeValue("REALM")
804
+ : undefined;
805
+ const retry = (0, credential_1.credentialRetryOf)(error.response, { authenticated, realm: sentRealm }, this.realm);
806
+ if (!retry) {
606
807
  throw error;
607
808
  }
809
+ log("retry with nonce", error.str, {
810
+ signedError: !(error instanceof exceptions_1.TransactionChallenge),
811
+ });
812
+ const integrityKey = makeIntegrityKey(this.username, retry.realm, this.password);
813
+ request.transactionId = (0, helper_1.randomTransactionId)();
814
+ // A new realm on an authenticated request rekeys the whole allocation.
815
+ // Sign the retry with its own credentials and adopt them only once the
816
+ // server accepted it, so concurrent failures never overwrite the shared
817
+ // state with credentials that were rejected.
818
+ if (authenticated && retry.realm !== sentRealm) {
819
+ const credentials = {
820
+ realm: retry.realm,
821
+ nonce: retry.nonce,
822
+ integrityKey,
823
+ };
824
+ const result = await this.request(request, this.server, undefined, { signal }, undefined, credentials);
825
+ this.nonce = credentials.nonce;
826
+ this.realm = credentials.realm;
827
+ this.integrityKey = credentials.integrityKey;
828
+ return result;
829
+ }
830
+ this.nonce = retry.nonce;
831
+ this.realm = retry.realm;
832
+ this.integrityKey = integrityKey;
833
+ return await this.request(request, this.server, undefined, { signal });
608
834
  }
609
- return [message, address];
610
835
  }
611
836
  async sendData(data, addr) {
612
837
  let channel;
@@ -751,7 +976,20 @@ class TurnProtocol {
751
976
  async sendStun(message, addr) {
752
977
  await this.send(message.bytes, addr);
753
978
  }
979
+ /**
980
+ * Release the client: its transactions, refresh timer and socket. Known
981
+ * constraint (as in develop): the allocation is not deleted on the server
982
+ * (no Refresh with lifetime 0), so the server keeps it until its lifetime
983
+ * ends.
984
+ */
754
985
  async close() {
986
+ if (this.closed)
987
+ return;
988
+ this.closed = true;
989
+ // An allocation, refresh or ChannelBind still waiting settles now.
990
+ for (const transaction of Object.values(this.transactions)) {
991
+ transaction.cancel();
992
+ }
755
993
  this.refreshHandle?.resolve?.();
756
994
  await this.transport.close();
757
995
  }
@@ -783,7 +1021,7 @@ function selectTurnUdpSocketType(address, udpFamily) {
783
1021
  }
784
1022
  return (udpFamily ?? 4) === 6 ? "udp6" : "udp4";
785
1023
  }
786
- async function createTurnClient({ address, username, password }, { lifetime, portRange, interfaceAddresses, ssl, tlsOptions, transport: transportType, connectTimeoutMs, udpFamily, } = {}) {
1024
+ async function createTurnClient({ address, username, password }, { lifetime, portRange, interfaceAddresses, ssl, tlsOptions, transport: transportType, connectTimeoutMs, udpFamily, signal, } = {}) {
787
1025
  lifetime ?? (lifetime = DEFAULT_ALLOCATION_LIFETIME);
788
1026
  transportType ?? (transportType = ssl ? "tls" : "udp");
789
1027
  const transport = transportType === "udp"
@@ -794,9 +1032,29 @@ async function createTurnClient({ address, username, password }, { lifetime, por
794
1032
  : transportType === "tcp"
795
1033
  ? await common_1.TcpTransport.init(address, { connectTimeoutMs })
796
1034
  : await common_1.TlsTransport.init(address, tlsOptions, { connectTimeoutMs });
797
- const turn = new TurnProtocol(address, username, password, lifetime, transport);
1035
+ const turn = new TurnProtocol(address, username, password, lifetime, transport, {
1036
+ reconnect: transportType === "udp"
1037
+ ? undefined
1038
+ : (alternate, alternateDomain) => transportType === "tcp"
1039
+ ? common_1.TcpTransport.init(alternate, { connectTimeoutMs })
1040
+ : common_1.TlsTransport.init(alternate, alternateTlsOptions(address, alternateDomain, tlsOptions), { connectTimeoutMs }),
1041
+ });
1042
+ // The owner (an ICE agent) closed while the allocation runs: release the
1043
+ // socket and its retransmissions now instead of after the allocation.
1044
+ const abort = () => {
1045
+ turn
1046
+ .close()
1047
+ .catch((error) => log("failed to close aborted TURN client", error));
1048
+ };
1049
+ if (signal?.aborted)
1050
+ abort();
1051
+ signal?.addEventListener("abort", abort, { once: true });
798
1052
  try {
1053
+ if (signal?.aborted)
1054
+ throw new exceptions_1.TransactionCancelled();
799
1055
  await turn.connectionMade();
1056
+ if (signal?.aborted)
1057
+ throw new exceptions_1.TransactionCancelled();
800
1058
  }
801
1059
  catch (error) {
802
1060
  try {
@@ -807,6 +1065,9 @@ async function createTurnClient({ address, username, password }, { lifetime, por
807
1065
  }
808
1066
  throw error;
809
1067
  }
1068
+ finally {
1069
+ signal?.removeEventListener("abort", abort);
1070
+ }
810
1071
  return turn;
811
1072
  }
812
1073
  async function createStunOverTurnClient(config, options = {}) {
@@ -814,6 +1075,47 @@ async function createStunOverTurnClient(config, options = {}) {
814
1075
  const turnTransport = new StunOverTurnProtocol(turn);
815
1076
  return turnTransport;
816
1077
  }
1078
+ /**
1079
+ * TLS options for a connection to an ALTERNATE-SERVER (an IP literal). The
1080
+ * certificate is validated against ALTERNATE-DOMAIN when present, otherwise
1081
+ * against the name the original server would have been validated with
1082
+ * (RFC 8489 §10): `tlsOptions.servername`, else the configured host.
1083
+ */
1084
+ function alternateTlsOptions(configured, alternateDomain, tlsOptions = {}) {
1085
+ const identity = alternateDomain ?? tlsOptions.servername ?? configured[0];
1086
+ const checkServerIdentity = tlsOptions.checkServerIdentity ?? tls.checkServerIdentity;
1087
+ return {
1088
+ ...tlsOptions,
1089
+ // SNI cannot carry an IP literal.
1090
+ servername: (0, node_net_1.isIP)(identity) ? undefined : identity,
1091
+ checkServerIdentity: (_host, cert) => checkServerIdentity(identity, cert),
1092
+ };
1093
+ }
1094
+ /**
1095
+ * The redirect target of a 300 (Try Alternate) error response, or undefined
1096
+ * for any other error. `server` is undefined when ALTERNATE-SERVER is
1097
+ * missing.
1098
+ */
1099
+ function tryAlternateOf(error, addressFamily) {
1100
+ if (!(error instanceof exceptions_1.TransactionFailed)) {
1101
+ return undefined;
1102
+ }
1103
+ const [errorCode] = error.response.getAttributeValue("ERROR-CODE") ?? [];
1104
+ if (errorCode !== 300) {
1105
+ return undefined;
1106
+ }
1107
+ // A response may carry one ALTERNATE-SERVER per address family (RFC 8489
1108
+ // §10): take the first one this transport can reach, else the first.
1109
+ const servers = error.response.alternateServers;
1110
+ const reachable = servers.find(([host]) => addressFamily === undefined || ipFamily(host) === addressFamily);
1111
+ return {
1112
+ server: reachable ?? servers[0],
1113
+ domain: error.response.getAttributeValue("ALTERNATE-DOMAIN"),
1114
+ };
1115
+ }
1116
+ function ipFamily(host) {
1117
+ return host.includes(":") ? 6 : 4;
1118
+ }
817
1119
  function makeIntegrityKey(username, realm, password) {
818
1120
  return (0, auth_1.makeTurnIntegrityKey)(username, realm, password);
819
1121
  }