werift 0.27.0 → 0.28.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 (224) hide show
  1. package/README.md +119 -8
  2. package/lib/common/src/event.d.ts +26 -0
  3. package/lib/common/src/event.js +87 -2
  4. package/lib/common/src/event.js.map +1 -1
  5. package/lib/common/src/network.d.ts +6 -1
  6. package/lib/common/src/network.js +8 -2
  7. package/lib/common/src/network.js.map +1 -1
  8. package/lib/common/src/transport.d.ts +12 -5
  9. package/lib/common/src/transport.js +3 -2
  10. package/lib/common/src/transport.js.map +1 -1
  11. package/lib/dtls/src/alert.d.ts +49 -0
  12. package/lib/dtls/src/alert.js +103 -0
  13. package/lib/dtls/src/alert.js.map +1 -0
  14. package/lib/dtls/src/client.js +15 -1
  15. package/lib/dtls/src/client.js.map +1 -1
  16. package/lib/dtls/src/context/dtls.d.ts +2 -0
  17. package/lib/dtls/src/context/dtls.js +7 -0
  18. package/lib/dtls/src/context/dtls.js.map +1 -1
  19. package/lib/dtls/src/context/transport.d.ts +17 -1
  20. package/lib/dtls/src/context/transport.js +38 -2
  21. package/lib/dtls/src/context/transport.js.map +1 -1
  22. package/lib/dtls/src/flight/client/flight5.js +4 -1
  23. package/lib/dtls/src/flight/client/flight5.js.map +1 -1
  24. package/lib/dtls/src/flight/flight.d.ts +5 -0
  25. package/lib/dtls/src/flight/flight.js +10 -1
  26. package/lib/dtls/src/flight/flight.js.map +1 -1
  27. package/lib/dtls/src/flight/server/flight6.js +4 -1
  28. package/lib/dtls/src/flight/server/flight6.js.map +1 -1
  29. package/lib/dtls/src/index.d.ts +3 -1
  30. package/lib/dtls/src/index.js +10 -1
  31. package/lib/dtls/src/index.js.map +1 -1
  32. package/lib/dtls/src/record/const.d.ts +9 -0
  33. package/lib/dtls/src/record/const.js +9 -1
  34. package/lib/dtls/src/record/const.js.map +1 -1
  35. package/lib/dtls/src/record/receive.d.ts +6 -0
  36. package/lib/dtls/src/record/receive.js +50 -19
  37. package/lib/dtls/src/record/receive.js.map +1 -1
  38. package/lib/dtls/src/server.js +19 -1
  39. package/lib/dtls/src/server.js.map +1 -1
  40. package/lib/dtls/src/socket.d.ts +134 -2
  41. package/lib/dtls/src/socket.js +322 -6
  42. package/lib/dtls/src/socket.js.map +1 -1
  43. package/lib/ice/src/candidateError.d.ts +155 -0
  44. package/lib/ice/src/candidateError.js +246 -0
  45. package/lib/ice/src/candidateError.js.map +1 -0
  46. package/lib/ice/src/candidateGatherer.d.ts +127 -0
  47. package/lib/ice/src/candidateGatherer.js +745 -0
  48. package/lib/ice/src/candidateGatherer.js.map +1 -0
  49. package/lib/ice/src/consent.d.ts +49 -0
  50. package/lib/ice/src/consent.js +258 -0
  51. package/lib/ice/src/consent.js.map +1 -0
  52. package/lib/ice/src/ice.d.ts +223 -71
  53. package/lib/ice/src/ice.js +873 -975
  54. package/lib/ice/src/ice.js.map +1 -1
  55. package/lib/ice/src/iceBase.d.ts +207 -8
  56. package/lib/ice/src/iceBase.js +94 -31
  57. package/lib/ice/src/iceBase.js.map +1 -1
  58. package/lib/ice/src/index.d.ts +1 -0
  59. package/lib/ice/src/index.js +1 -0
  60. package/lib/ice/src/index.js.map +1 -1
  61. package/lib/ice/src/internal/checkMessages.d.ts +41 -0
  62. package/lib/ice/src/internal/checkMessages.js +63 -0
  63. package/lib/ice/src/internal/checkMessages.js.map +1 -0
  64. package/lib/ice/src/internal/defaultRoute.d.ts +20 -0
  65. package/lib/ice/src/internal/defaultRoute.js +134 -0
  66. package/lib/ice/src/internal/defaultRoute.js.map +1 -0
  67. package/lib/ice/src/internal/hostInterfaces.d.ts +17 -0
  68. package/lib/ice/src/internal/hostInterfaces.js +77 -0
  69. package/lib/ice/src/internal/hostInterfaces.js.map +1 -0
  70. package/lib/ice/src/internal/hostPreference.d.ts +24 -0
  71. package/lib/ice/src/internal/hostPreference.js +38 -0
  72. package/lib/ice/src/internal/hostPreference.js.map +1 -0
  73. package/lib/ice/src/internal/resolveHostAddresses.d.ts +56 -8
  74. package/lib/ice/src/internal/resolveHostAddresses.js +127 -24
  75. package/lib/ice/src/internal/resolveHostAddresses.js.map +1 -1
  76. package/lib/ice/src/internal/selectAddresses.d.ts +27 -0
  77. package/lib/ice/src/internal/selectAddresses.js +37 -18
  78. package/lib/ice/src/internal/selectAddresses.js.map +1 -1
  79. package/lib/ice/src/nomination/regularNomination.d.ts +200 -0
  80. package/lib/ice/src/nomination/regularNomination.js +311 -0
  81. package/lib/ice/src/nomination/regularNomination.js.map +1 -0
  82. package/lib/ice/src/nomination/selectionReplacement.d.ts +138 -0
  83. package/lib/ice/src/nomination/selectionReplacement.js +371 -0
  84. package/lib/ice/src/nomination/selectionReplacement.js.map +1 -0
  85. package/lib/ice/src/provisional.d.ts +139 -0
  86. package/lib/ice/src/provisional.js +468 -0
  87. package/lib/ice/src/provisional.js.map +1 -0
  88. package/lib/ice/src/stun/protocol.d.ts +9 -2
  89. package/lib/ice/src/stun/protocol.js +16 -17
  90. package/lib/ice/src/stun/protocol.js.map +1 -1
  91. package/lib/ice/src/stun/tcpProtocol.d.ts +1 -1
  92. package/lib/ice/src/stun/tcpProtocol.js +7 -7
  93. package/lib/ice/src/stun/tcpProtocol.js.map +1 -1
  94. package/lib/ice/src/stun/transaction.js +4 -2
  95. package/lib/ice/src/stun/transaction.js.map +1 -1
  96. package/lib/ice/src/turn/protocol.d.ts +2 -2
  97. package/lib/ice/src/turn/protocol.js +6 -3
  98. package/lib/ice/src/turn/protocol.js.map +1 -1
  99. package/lib/ice/src/types/model.d.ts +16 -5
  100. package/lib/ice/src/types/model.js.map +1 -1
  101. package/lib/ice-server/src/stun/attributes.js +4 -0
  102. package/lib/ice-server/src/stun/attributes.js.map +1 -1
  103. package/lib/ice-server/src/stun/const.d.ts +20 -1
  104. package/lib/ice-server/src/stun/const.js +9 -1
  105. package/lib/ice-server/src/stun/const.js.map +1 -1
  106. package/lib/ice-server/src/stun/message.d.ts +28 -1
  107. package/lib/ice-server/src/stun/message.js +102 -15
  108. package/lib/ice-server/src/stun/message.js.map +1 -1
  109. package/lib/index.mjs +13394 -7732
  110. package/lib/nonstandard/index.mjs +680 -286
  111. package/lib/polyfill/dom.mjs +19605 -14243
  112. package/lib/polyfill/index.mjs +19605 -14243
  113. package/lib/rtp/src/index.d.ts +1 -0
  114. package/lib/rtp/src/index.js +1 -0
  115. package/lib/rtp/src/index.js.map +1 -1
  116. package/lib/rtp/src/rtp/continuity.d.ts +14 -1
  117. package/lib/rtp/src/rtp/continuity.js +24 -4
  118. package/lib/rtp/src/rtp/continuity.js.map +1 -1
  119. package/lib/rtp/src/rtp/timelineRewriter.d.ts +178 -0
  120. package/lib/rtp/src/rtp/timelineRewriter.js +417 -0
  121. package/lib/rtp/src/rtp/timelineRewriter.js.map +1 -0
  122. package/lib/sctp/src/sctp.d.ts +5 -0
  123. package/lib/sctp/src/sctp.js +81 -47
  124. package/lib/sctp/src/sctp.js.map +1 -1
  125. package/lib/webrtc/src/api/compatibilityOptions.d.ts +33 -0
  126. package/lib/webrtc/src/api/compatibilityOptions.js +33 -0
  127. package/lib/webrtc/src/api/compatibilityOptions.js.map +1 -0
  128. package/lib/webrtc/src/api/peerConfig.d.ts +348 -34
  129. package/lib/webrtc/src/api/peerConfig.js +90 -24
  130. package/lib/webrtc/src/api/peerConfig.js.map +1 -1
  131. package/lib/webrtc/src/api/peerConnectionEvents.d.ts +77 -1
  132. package/lib/webrtc/src/api/peerConnectionEvents.js +105 -1
  133. package/lib/webrtc/src/api/peerConnectionEvents.js.map +1 -1
  134. package/lib/webrtc/src/helper.d.ts +8 -0
  135. package/lib/webrtc/src/helper.js +40 -4
  136. package/lib/webrtc/src/helper.js.map +1 -1
  137. package/lib/webrtc/src/media/codecCompatibility.d.ts +87 -1
  138. package/lib/webrtc/src/media/codecCompatibility.js +338 -12
  139. package/lib/webrtc/src/media/codecCompatibility.js.map +1 -1
  140. package/lib/webrtc/src/media/receiver/nack.d.ts +43 -10
  141. package/lib/webrtc/src/media/receiver/nack.js +245 -88
  142. package/lib/webrtc/src/media/receiver/nack.js.map +1 -1
  143. package/lib/webrtc/src/media/router.d.ts +239 -51
  144. package/lib/webrtc/src/media/router.js +664 -237
  145. package/lib/webrtc/src/media/router.js.map +1 -1
  146. package/lib/webrtc/src/media/routing/pendingRoutes.d.ts +26 -0
  147. package/lib/webrtc/src/media/routing/pendingRoutes.js +48 -0
  148. package/lib/webrtc/src/media/routing/pendingRoutes.js.map +1 -0
  149. package/lib/webrtc/src/media/routing/ridRouting.d.ts +37 -0
  150. package/lib/webrtc/src/media/routing/ridRouting.js +74 -0
  151. package/lib/webrtc/src/media/routing/ridRouting.js.map +1 -0
  152. package/lib/webrtc/src/media/routing/routeTable.d.ts +60 -0
  153. package/lib/webrtc/src/media/routing/routeTable.js +95 -0
  154. package/lib/webrtc/src/media/routing/routeTable.js.map +1 -0
  155. package/lib/webrtc/src/media/routing/rtcpRouting.d.ts +34 -0
  156. package/lib/webrtc/src/media/routing/rtcpRouting.js +165 -0
  157. package/lib/webrtc/src/media/routing/rtcpRouting.js.map +1 -0
  158. package/lib/webrtc/src/media/routing/unknownSsrc.d.ts +55 -0
  159. package/lib/webrtc/src/media/routing/unknownSsrc.js +117 -0
  160. package/lib/webrtc/src/media/routing/unknownSsrc.js.map +1 -0
  161. package/lib/webrtc/src/media/rtpReceiver.d.ts +222 -0
  162. package/lib/webrtc/src/media/rtpReceiver.js +668 -28
  163. package/lib/webrtc/src/media/rtpReceiver.js.map +1 -1
  164. package/lib/webrtc/src/media/rtpSender.d.ts +7 -0
  165. package/lib/webrtc/src/media/rtpSender.js +9 -3
  166. package/lib/webrtc/src/media/rtpSender.js.map +1 -1
  167. package/lib/webrtc/src/media/rtpTransceiver.d.ts +18 -0
  168. package/lib/webrtc/src/media/rtpTransceiver.js +64 -2
  169. package/lib/webrtc/src/media/rtpTransceiver.js.map +1 -1
  170. package/lib/webrtc/src/media/sender/senderReportHistory.d.ts +51 -0
  171. package/lib/webrtc/src/media/sender/senderReportHistory.js +111 -0
  172. package/lib/webrtc/src/media/sender/senderReportHistory.js.map +1 -0
  173. package/lib/webrtc/src/media/sender/senderStats.d.ts +6 -5
  174. package/lib/webrtc/src/media/sender/senderStats.js +14 -19
  175. package/lib/webrtc/src/media/sender/senderStats.js.map +1 -1
  176. package/lib/webrtc/src/media/track.d.ts +9 -0
  177. package/lib/webrtc/src/media/track.js +9 -0
  178. package/lib/webrtc/src/media/track.js.map +1 -1
  179. package/lib/webrtc/src/negotiation/remoteMediaApplication.d.ts +23 -6
  180. package/lib/webrtc/src/negotiation/remoteMediaApplication.js +46 -22
  181. package/lib/webrtc/src/negotiation/remoteMediaApplication.js.map +1 -1
  182. package/lib/webrtc/src/negotiation/transceiverPairing.d.ts +1 -0
  183. package/lib/webrtc/src/negotiation/transceiverPairing.js +62 -0
  184. package/lib/webrtc/src/negotiation/transceiverPairing.js.map +1 -0
  185. package/lib/webrtc/src/negotiation/transportActivation.d.ts +8 -1
  186. package/lib/webrtc/src/negotiation/transportActivation.js +21 -0
  187. package/lib/webrtc/src/negotiation/transportActivation.js.map +1 -1
  188. package/lib/webrtc/src/negotiationTransaction.d.ts +35 -4
  189. package/lib/webrtc/src/negotiationTransaction.js +111 -8
  190. package/lib/webrtc/src/negotiationTransaction.js.map +1 -1
  191. package/lib/webrtc/src/peerConnection.d.ts +65 -6
  192. package/lib/webrtc/src/peerConnection.js +283 -28
  193. package/lib/webrtc/src/peerConnection.js.map +1 -1
  194. package/lib/webrtc/src/polyfill/globals.d.ts +2 -1
  195. package/lib/webrtc/src/polyfill/globals.js.map +1 -1
  196. package/lib/webrtc/src/polyfill/install.js +2 -0
  197. package/lib/webrtc/src/polyfill/install.js.map +1 -1
  198. package/lib/webrtc/src/sctpManager.js +4 -0
  199. package/lib/webrtc/src/sctpManager.js.map +1 -1
  200. package/lib/webrtc/src/sdp.d.ts +69 -0
  201. package/lib/webrtc/src/sdp.js +139 -14
  202. package/lib/webrtc/src/sdp.js.map +1 -1
  203. package/lib/webrtc/src/sdpManager.d.ts +85 -4
  204. package/lib/webrtc/src/sdpManager.js +214 -14
  205. package/lib/webrtc/src/sdpManager.js.map +1 -1
  206. package/lib/webrtc/src/secureTransportManager.d.ts +38 -1
  207. package/lib/webrtc/src/secureTransportManager.js +82 -7
  208. package/lib/webrtc/src/secureTransportManager.js.map +1 -1
  209. package/lib/webrtc/src/transceiverManager.d.ts +82 -4
  210. package/lib/webrtc/src/transceiverManager.js +231 -38
  211. package/lib/webrtc/src/transceiverManager.js.map +1 -1
  212. package/lib/webrtc/src/transport/dtls.d.ts +95 -1
  213. package/lib/webrtc/src/transport/dtls.js +324 -28
  214. package/lib/webrtc/src/transport/dtls.js.map +1 -1
  215. package/lib/webrtc/src/transport/ice.d.ts +61 -4
  216. package/lib/webrtc/src/transport/ice.js +180 -11
  217. package/lib/webrtc/src/transport/ice.js.map +1 -1
  218. package/lib/webrtc/src/transport/sctp.d.ts +23 -0
  219. package/lib/webrtc/src/transport/sctp.js +87 -2
  220. package/lib/webrtc/src/transport/sctp.js.map +1 -1
  221. package/lib/webrtc/src/utils.d.ts +33 -0
  222. package/lib/webrtc/src/utils.js +52 -3
  223. package/lib/webrtc/src/utils.js.map +1 -1
  224. package/package.json +2 -1
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defaultPeerConfig = exports.findCodecByMimeType = void 0;
3
+ exports.defaultPeerConfig = exports.findCodecByMimeType = exports.DeprecatedCompatibilityValues = exports.CompatibilityPresets = exports.TransceiverPairingModes = exports.MLineReuseModes = exports.CertificateScopeModes = void 0;
4
4
  exports.generateDefaultPeerConfig = generateDefaultPeerConfig;
5
5
  exports.clonePeerConfiguration = clonePeerConfiguration;
6
6
  exports.mergePeerConfiguration = mergePeerConfiguration;
@@ -12,14 +12,33 @@ const errors_1 = require("../errors");
12
12
  const helper_1 = require("../helper");
13
13
  const codec_1 = require("../media/codec");
14
14
  const codecCompatibility_1 = require("../media/codecCompatibility");
15
- const router_1 = require("../media/router");
15
+ const sdpManager_1 = require("../sdpManager");
16
16
  const sctp_1 = require("../transport/sctp");
17
17
  const utils_1 = require("../utils");
18
- const CertificateScopes = [
19
- "process",
20
- "peerConnection",
18
+ const compatibilityOptions_1 = require("./compatibilityOptions");
19
+ exports.CertificateScopeModes = compatibilityOptions_1.CompatibilityOptionValues.certificateScope;
20
+ /** How local SDP marks inactive / stopped m-lines. See {@link PeerConfig.mLineReuse}. */
21
+ exports.MLineReuseModes = compatibilityOptions_1.CompatibilityOptionValues.mLineReuse;
22
+ exports.TransceiverPairingModes = compatibilityOptions_1.CompatibilityOptionValues.transceiverPairing;
23
+ exports.CompatibilityPresets = [
24
+ "standard",
25
+ ];
26
+ const COMPATIBILITY_OPTIONS = Object.keys(compatibilityOptions_1.CompatibilityOptionValues);
27
+ /**
28
+ * The values the compatibility options used up to v0.27.0 that are not
29
+ * values any more, and the value each one is read as. They are accepted on
30
+ * input only: `getConfiguration()` returns the current name.
31
+ */
32
+ exports.DeprecatedCompatibilityValues = {
33
+ certificateScope: { peerConnection: "standard" },
34
+ mLineReuse: { compatible: "standard" },
35
+ keyFrameRequestRouting: { compatible: "fallback", strict: "standard" },
36
+ };
37
+ const MessageIntegrityModes = [
38
+ "sha1",
39
+ "sha256",
40
+ "both",
21
41
  ];
22
- const MLineReuseModes = ["compatible", "aggressive"];
23
42
  const findCodecByMimeType = (codecs, target) => codecs.find((localCodec) => (0, codecCompatibility_1.normalizeCodecMimeType)(localCodec.mimeType) ===
24
43
  (0, codecCompatibility_1.normalizeCodecMimeType)(target.mimeType))
25
44
  ? target
@@ -72,11 +91,16 @@ function generateDefaultPeerConfig() {
72
91
  iceTcpPassive: true,
73
92
  iceStunGatherTimeout: undefined,
74
93
  iceTurnConnectTimeout: undefined,
94
+ iceNominationDelayMs: undefined,
95
+ iceNomination: undefined,
96
+ iceRenomination: false,
75
97
  turnTransport: undefined,
76
98
  turnTlsOptions: undefined,
77
99
  turnUdpFamily: undefined,
78
100
  iceFilterStunResponse: undefined,
79
101
  iceFilterCandidatePair: undefined,
102
+ iceMessageIntegrity: undefined,
103
+ iceOptionIce2: false,
80
104
  icePasswordPrefix: undefined,
81
105
  iceUseLinkLocalAddress: undefined,
82
106
  dtls: {},
@@ -93,8 +117,11 @@ function generateDefaultPeerConfig() {
93
117
  bandwidthEstimator: "lightweight",
94
118
  sctp: { mtu: src_1.DEFAULT_SCTP_MTU },
95
119
  pendingRtp: false,
96
- mLineReuse: "compatible",
97
- keyFrameRequestRouting: "compatible",
120
+ mLineReuse: "standard",
121
+ transceiverPairing: "byKind",
122
+ keyFrameRequestRouting: "fallback",
123
+ bundleCandidates: "legacy",
124
+ compatibility: undefined,
98
125
  };
99
126
  }
100
127
  exports.defaultPeerConfig = generateDefaultPeerConfig();
@@ -107,6 +134,15 @@ function normalizePeerConfiguration(config) {
107
134
  if (input.bundlePolicy === "balanced") {
108
135
  normalizedConfig.bundlePolicy = "max-compat";
109
136
  }
137
+ for (const option of COMPATIBILITY_OPTIONS) {
138
+ const value = input[option];
139
+ if (option in exports.DeprecatedCompatibilityValues && typeof value === "string") {
140
+ const aliases = exports.DeprecatedCompatibilityValues[option];
141
+ if (Object.hasOwn(aliases, value)) {
142
+ normalizedConfig[option] = aliases[value];
143
+ }
144
+ }
145
+ }
110
146
  if ("certificates" in input) {
111
147
  if (input.certificates === undefined) {
112
148
  normalizedConfig.certificates = undefined;
@@ -198,27 +234,57 @@ function mergePeerConfiguration(config, input, { isReconfiguration, hasLocalDesc
198
234
  normalizedConfig.bundlePolicy !== config.bundlePolicy) {
199
235
  throw new Error("bundlePolicy cannot be changed");
200
236
  }
201
- if (normalizedConfig.certificateScope !== undefined &&
202
- !CertificateScopes.includes(normalizedConfig.certificateScope)) {
203
- throw (0, errors_1.createWebRtcTypeError)(`certificateScope must be one of ${CertificateScopes.join(", ")}`);
237
+ if (normalizedConfig.compatibility !== undefined &&
238
+ !exports.CompatibilityPresets.includes(normalizedConfig.compatibility)) {
239
+ throw (0, errors_1.createWebRtcTypeError)(`compatibility must be one of ${exports.CompatibilityPresets.join(", ")}`);
204
240
  }
205
- if (isReconfiguration &&
206
- normalizedConfig.certificateScope !== undefined &&
207
- normalizedConfig.certificateScope !== config.certificateScope) {
208
- throw (0, errors_1.createWebRtcDomException)("InvalidModificationError", "certificateScope cannot be changed");
241
+ if (isReconfiguration) {
242
+ if (normalizedConfig.compatibility !== undefined &&
243
+ normalizedConfig.compatibility !== config.compatibility) {
244
+ throw (0, errors_1.createWebRtcDomException)("InvalidModificationError", "compatibility cannot be changed");
245
+ }
209
246
  }
210
- if (normalizedConfig.mLineReuse !== undefined &&
211
- !MLineReuseModes.includes(normalizedConfig.mLineReuse)) {
212
- throw (0, errors_1.createWebRtcTypeError)(`mLineReuse must be one of ${MLineReuseModes.join(", ")}`);
247
+ else if (normalizedConfig.compatibility === "standard") {
248
+ // 構築時だけ、明示されていない互換性オプションを standard にする。
249
+ // 明示された値は常に compatibility より優先する (PeerConfig.compatibility)
250
+ for (const option of COMPATIBILITY_OPTIONS) {
251
+ if (normalizedConfig[option] === undefined) {
252
+ normalizedConfig[option] = "standard";
253
+ }
254
+ }
255
+ }
256
+ for (const option of COMPATIBILITY_OPTIONS) {
257
+ const value = normalizedConfig[option];
258
+ if (value === undefined)
259
+ continue;
260
+ const values = compatibilityOptions_1.CompatibilityOptionValues[option];
261
+ if (!values.includes(value)) {
262
+ throw (0, errors_1.createWebRtcTypeError)(`${option} must be one of ${values.join(", ")}`);
263
+ }
264
+ // keyFrameRequestRouting は接続中に切り替えられる (router が次の要求から使う)
265
+ if (isReconfiguration &&
266
+ option !== "keyFrameRequestRouting" &&
267
+ value !== config[option]) {
268
+ throw (0, errors_1.createWebRtcDomException)("InvalidModificationError", `${option} cannot be changed`);
269
+ }
270
+ }
271
+ if (normalizedConfig.bundleCandidates !== undefined &&
272
+ !sdpManager_1.BundleCandidatesModes.includes(normalizedConfig.bundleCandidates)) {
273
+ throw (0, errors_1.createWebRtcTypeError)(`bundleCandidates must be one of ${sdpManager_1.BundleCandidatesModes.join(", ")}`);
274
+ }
275
+ if (isReconfiguration &&
276
+ normalizedConfig.bundleCandidates !== undefined &&
277
+ normalizedConfig.bundleCandidates !== config.bundleCandidates) {
278
+ throw (0, errors_1.createWebRtcDomException)("InvalidModificationError", "bundleCandidates cannot be changed");
213
279
  }
214
- if (normalizedConfig.keyFrameRequestRouting !== undefined &&
215
- !router_1.KeyFrameRequestRoutingModes.includes(normalizedConfig.keyFrameRequestRouting)) {
216
- throw (0, errors_1.createWebRtcTypeError)(`keyFrameRequestRouting must be one of ${router_1.KeyFrameRequestRoutingModes.join(", ")}`);
280
+ if (normalizedConfig.iceMessageIntegrity !== undefined &&
281
+ !MessageIntegrityModes.includes(normalizedConfig.iceMessageIntegrity)) {
282
+ throw (0, errors_1.createWebRtcTypeError)(`iceMessageIntegrity must be one of ${MessageIntegrityModes.join(", ")}`);
217
283
  }
218
284
  if (isReconfiguration &&
219
- normalizedConfig.mLineReuse !== undefined &&
220
- normalizedConfig.mLineReuse !== config.mLineReuse) {
221
- throw (0, errors_1.createWebRtcDomException)("InvalidModificationError", "mLineReuse cannot be changed");
285
+ normalizedConfig.iceOptionIce2 !== undefined &&
286
+ normalizedConfig.iceOptionIce2 !== config.iceOptionIce2) {
287
+ throw (0, errors_1.createWebRtcDomException)("InvalidModificationError", "iceOptionIce2 cannot be changed");
222
288
  }
223
289
  if (isReconfiguration &&
224
290
  normalizedConfig.rtcpMuxPolicy !== undefined &&
@@ -1 +1 @@
1
- {"version":3,"file":"peerConfig.js","sourceRoot":"","sources":["../../../../src/api/peerConfig.ts"],"names":[],"mappings":";;;AAmQA,8DA4CC;AAgED,wDAkCC;AAaD,wDA8KC;AA5kBD,yEAAyE;AACzE,6EAA6E;AAC7E,wDAAwD;AACxD,2CAAsE;AACtE,sCAA4E;AAC5E,sCAAsC;AAOtC,0CAA+C;AAC/C,oEAAqE;AAKrE,4CAGyB;AAMzB,4CAA6D;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E,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,MAAM,CAAC,cAAc,GAAG,CAAC,EAAE,CAAC;QAC1E,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACnE,CAAC;IAED,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAElC;QACE,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC;QACxC,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC;KACzC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACjB,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["// RTCPeerConnection configuration: the public configuration types, their\n// defaults, input normalization (W3C RTCConfiguration compatibility) and the\n// validation `setConfiguration` applies before merging.\nimport { DEFAULT_SCTP_MTU, validateSctpMtu } from \"../../../sctp/src\";\nimport { createWebRtcDomException, createWebRtcTypeError } from \"../errors\";\nimport { enumerate } from \"../helper\";\nimport type {\n Address,\n InterfaceAddresses,\n TlsConnectionOptions,\n} from \"../imports/common\";\nimport type { CandidatePair, Message, Protocol } from \"../imports/ice\";\nimport { defaultCodecs } from \"../media/codec\";\nimport { normalizeCodecMimeType } from \"../media/codecCompatibility\";\nimport type {\n RTCRtpCodecParameters,\n RTCRtpHeaderExtensionParameters,\n} from \"../media/parameters\";\nimport {\n type KeyFrameRequestRouting,\n KeyFrameRequestRoutingModes,\n} from \"../media/router\";\nimport type { RTCRtpSenderOptions } from \"../media/rtpSender\";\nimport type { BandwidthEstimatorOption } from \"../media/sender/createBandwidthEstimator\";\nimport type { BundlePolicy } from \"../sdp\";\nimport type { MLineReuse } from \"../sdpManager\";\nimport type { DtlsKeys, RTCCertificate } from \"../transport/dtls\";\nimport { DEFAULT_MAX_MESSAGE_SIZE } from \"../transport/sctp\";\nimport { deepMerge } from \"../utils\";\n\nexport type DebugConfig = Partial<{\n /**% */\n inboundPacketLoss: number;\n /**% */\n outboundPacketLoss: number;\n /**ms */\n receiverReportDelay: number;\n disableSendNack: boolean;\n disableRecvRetransmit: boolean;\n}>;\n\nexport interface PeerConfig {\n codecs: Partial<{\n /**\n * When specifying a codec with a fixed payloadType such as PCMU,\n * it is necessary to set the correct PayloadType in RTCRtpCodecParameters in advance.\n */\n audio: RTCRtpCodecParameters[];\n video: RTCRtpCodecParameters[];\n }>;\n headerExtensions: Partial<{\n audio: RTCRtpHeaderExtensionParameters[];\n video: RTCRtpHeaderExtensionParameters[];\n }>;\n iceTransportPolicy: \"all\" | \"relay\";\n /** Advertise local ICE lite and operate in the controlled role. */\n iceLite: boolean;\n iceServers: RTCIceServer[];\n /**\n * Fall back to the built-in public STUN server (`stun.l.google.com:19302`)\n * when `iceServers` contains no STUN URL (empty or TURN-only).\n * Set to false to gather server-reflexive candidates only from the STUN\n * servers given in `iceServers`. Defaults to true.\n */\n iceUseDefaultStunServer: boolean;\n /**Minimum port and Maximum port must not be the same value */\n icePortRange: [number, number] | undefined;\n /**\n * Local addresses to bind the ICE UDP host sockets to, per family\n * (`udp4` / `udp6`).\n *\n * The address given for a family is the only host address of that family:\n * its host candidate advertises the address the socket is actually bound\n * to, even when it is not an enumerated interface address (loopback, tun,\n * VPN, ...). If the bind fails, the family has no UDP host candidate.\n * A family left unspecified while the other one is set gathers no\n * enumerated addresses (only its `iceAdditionalHostAddresses`).\n */\n iceInterfaceAddresses: InterfaceAddresses | undefined;\n /** Add additional host (local) addresses to use for candidate gathering.\n * Notably, you can include hosts that are normally excluded, such as loopback, tun interfaces, etc.\n * For a family bound by `iceInterfaceAddresses`, addresses other than the bound one are ignored.\n */\n iceAdditionalHostAddresses: string[] | undefined;\n iceUseIpv4: boolean;\n iceUseIpv6: boolean;\n iceUseTcp: boolean;\n /** Gather passive (listening) TCP host candidates. Defaults to true. */\n iceTcpPassive: boolean;\n /**\n * Seconds to wait for server-reflexive candidates while gathering.\n * Defaults to 5 when undefined.\n */\n iceStunGatherTimeout: number | undefined;\n /**\n * Seconds to wait for a TURN TCP/TLS connection to be established.\n * Defaults to 8 when undefined.\n */\n iceTurnConnectTimeout: number | undefined;\n turnTransport: \"udp\" | \"tcp\" | \"tls\" | undefined;\n turnTlsOptions: TlsConnectionOptions | undefined;\n /**\n * Preferred IP family of the TURN/UDP socket, applied only when the TURN\n * server is a hostname. Ignored for an IP literal server, whose own family\n * always selects the socket. Defaults to 4 when undefined.\n */\n turnUdpFamily: 4 | 6 | undefined;\n /** @deprecated Prefer turn URL transport parameters or turnTransport. */\n forceTurnTCP: boolean;\n /** such as google cloud run */\n iceUseLinkLocalAddress: boolean | undefined;\n /** If provided, is called on each STUN request.\n * Return `true` if a STUN response should be sent, false if it should be skipped. */\n iceFilterStunResponse:\n | ((message: Message, addr: Address, protocol: Protocol) => boolean)\n | undefined;\n iceFilterCandidatePair: ((pair: CandidatePair) => boolean) | undefined;\n dtls: Partial<{\n keys: DtlsKeys;\n }>;\n icePasswordPrefix: string | undefined;\n bundlePolicy: BundlePolicy;\n rtcpMuxPolicy: \"require\";\n iceCandidatePoolSize: number;\n certificates: RTCCertificate[];\n /**\n * Which default DTLS certificate is used when neither `certificates` nor `dtls.keys` is given.\n * Cannot be changed after construction.\n * - `\"process\"` (default): one certificate shared by every RTCPeerConnection in the process\n * (legacy behavior), so their `a=fingerprint` values are identical.\n * - `\"peerConnection\"`: each RTCPeerConnection generates its own certificate (browser behavior).\n * All DTLS transports of that connection share it.\n */\n certificateScope: CertificateScope;\n debug: DebugConfig;\n midSuffix: boolean;\n /** Advertised local SCTP max-message-size in SDP. Use 0 for unlimited. */\n maxMessageSize: number;\n /**\n * When true, padding-only RTP is omitted from onReceiveRtp and later media\n * sequence numbers are compacted. Default false preserves wire RTP events.\n */\n filterProbePaddingOnReceiveRtp: boolean;\n /** Send-side estimator used by each new sender; defaults to `\"lightweight\"`. */\n bandwidthEstimator: BandwidthEstimatorOption;\n /** SCTP outbound packet MTU used for DATA chunk fragmentation. */\n sctp: { mtu: number };\n /**\n * Queue outbound RTP on each sender until DTLS is connected.\n * Disabled by default. Pass `true` or `{ enabled: true, maxLength }` to buffer.\n */\n pendingRtp: NonNullable<RTCRtpSenderOptions[\"pendingRtp\"]>;\n /**\n * How local SDP marks inactive / stopped m-lines. Cannot be changed after construction.\n * - `\"compatible\"` (default): an accepted `inactive` m-line keeps a non-zero port.\n * Only rejected (no common codec / remote port 0) or stopped m-lines use port 0,\n * and only those negotiated port 0 positions are reused by new transceivers.\n * - `\"aggressive\"`: legacy behavior. `inactive` m-lines are also written with port 0.\n */\n mLineReuse: MLineReuse;\n /**\n * Where a PLI / FIR goes when no route has its target SSRC. See {@link KeyFrameRequestRouting}.\n * - `\"compatible\"` (default): the sender whose RTX SSRC it is, else the only video sender.\n * - `\"strict\"`: not delivered, as RFC 4585 / RFC 5104 define the target.\n */\n keyFrameRequestRouting: KeyFrameRequestRouting;\n}\n\nexport type CertificateScope = \"process\" | \"peerConnection\";\nconst CertificateScopes: readonly CertificateScope[] = [\n \"process\",\n \"peerConnection\",\n];\n\nconst MLineReuseModes: readonly MLineReuse[] = [\"compatible\", \"aggressive\"];\n\nexport const findCodecByMimeType = (\n codecs: RTCRtpCodecParameters[],\n target: RTCRtpCodecParameters,\n) =>\n codecs.find(\n (localCodec) =>\n normalizeCodecMimeType(localCodec.mimeType) ===\n normalizeCodecMimeType(target.mimeType),\n )\n ? target\n : undefined;\n\nfunction assignDynamicPayloadTypes(config: PeerConfig) {\n for (const [i, codecParams] of enumerate([\n ...(config.codecs.audio || []),\n ...(config.codecs.video || []),\n ])) {\n if (codecParams.payloadType != undefined) {\n continue;\n }\n\n codecParams.payloadType = 96 + i;\n switch (codecParams.name.toLowerCase()) {\n case \"rtx\":\n {\n codecParams.parameters = `apt=${codecParams.payloadType - 1}`;\n }\n break;\n case \"red\":\n {\n if (codecParams.contentType === \"audio\") {\n const redundant = codecParams.payloadType + 1;\n codecParams.parameters = `${redundant}/${redundant}`;\n codecParams.payloadType = 63;\n }\n }\n break;\n }\n }\n}\n\nexport type RTCIceServer = {\n urls: string | string[];\n username?: string;\n credential?: string;\n};\n\nexport type RTCBundlePolicy = \"balanced\" | \"max-compat\" | \"max-bundle\";\nexport type RTCRtcpMuxPolicy = \"require\";\n\nexport interface RTCSctpConfiguration {\n /** SCTP outbound packet MTU used for DATA chunk fragmentation. Defaults to 1191. */\n mtu?: number;\n}\n\nexport interface RTCConfiguration {\n iceServers?: RTCIceServer[];\n iceTransportPolicy?: PeerConfig[\"iceTransportPolicy\"];\n bundlePolicy?: RTCBundlePolicy;\n rtcpMuxPolicy?: RTCRtcpMuxPolicy;\n iceCandidatePoolSize?: number;\n certificates?: RTCCertificate[];\n}\n\ntype RTCPeerConnectionRTCConfiguration = Omit<\n RTCConfiguration,\n \"bundlePolicy\"\n> & {\n bundlePolicy?: PeerConfig[\"bundlePolicy\"] | RTCBundlePolicy;\n};\n\nexport type RTCPeerConnectionConfig = Partial<\n Omit<\n PeerConfig,\n | \"bundlePolicy\"\n | \"rtcpMuxPolicy\"\n | \"iceCandidatePoolSize\"\n | \"certificates\"\n | \"sctp\"\n >\n> &\n RTCPeerConnectionRTCConfiguration & { sctp?: RTCSctpConfiguration };\n\nexport function generateDefaultPeerConfig(): PeerConfig {\n return {\n codecs: defaultCodecs(),\n headerExtensions: {\n audio: [],\n video: [],\n },\n iceTransportPolicy: \"all\",\n iceLite: false,\n iceServers: [{ urls: \"stun:stun.l.google.com:19302\" }],\n iceUseDefaultStunServer: true,\n icePortRange: undefined,\n iceInterfaceAddresses: undefined,\n iceAdditionalHostAddresses: undefined,\n iceUseIpv4: true,\n iceUseIpv6: true,\n iceUseTcp: false,\n iceTcpPassive: true,\n iceStunGatherTimeout: undefined,\n iceTurnConnectTimeout: undefined,\n turnTransport: undefined,\n turnTlsOptions: undefined,\n turnUdpFamily: undefined,\n iceFilterStunResponse: undefined,\n iceFilterCandidatePair: undefined,\n icePasswordPrefix: undefined,\n iceUseLinkLocalAddress: undefined,\n dtls: {},\n bundlePolicy: \"max-compat\",\n rtcpMuxPolicy: \"require\",\n iceCandidatePoolSize: 0,\n certificates: [],\n certificateScope: \"process\",\n debug: {},\n midSuffix: false,\n forceTurnTCP: false,\n maxMessageSize: DEFAULT_MAX_MESSAGE_SIZE,\n filterProbePaddingOnReceiveRtp: false,\n bandwidthEstimator: \"lightweight\",\n sctp: { mtu: DEFAULT_SCTP_MTU },\n pendingRtp: false,\n mLineReuse: \"compatible\",\n keyFrameRequestRouting: \"compatible\",\n };\n}\nexport const defaultPeerConfig: PeerConfig = generateDefaultPeerConfig();\n\nfunction normalizePeerConfiguration(\n config: RTCPeerConnectionConfig,\n): Partial<PeerConfig> & { sctp?: RTCSctpConfiguration } {\n const input = Object(config ?? {}) as RTCPeerConnectionConfig;\n const normalizedConfig = { ...input } as Partial<PeerConfig> & {\n sctp?: RTCSctpConfiguration;\n };\n\n if (input.sctp !== undefined) {\n normalizedConfig.sctp = { ...input.sctp } as PeerConfig[\"sctp\"];\n }\n\n if (input.bundlePolicy === \"balanced\") {\n normalizedConfig.bundlePolicy = \"max-compat\";\n }\n\n if (\"certificates\" in input) {\n if (input.certificates === undefined) {\n normalizedConfig.certificates = undefined;\n } else if (\n !Array.isArray(input.certificates) ||\n input.certificates.some((certificate) => certificate == null)\n ) {\n throw createWebRtcTypeError(\n \"certificates must be an array of RTCCertificate\",\n );\n } else {\n normalizedConfig.certificates = [...input.certificates];\n }\n }\n\n if (\"iceCandidatePoolSize\" in input) {\n normalizedConfig.iceCandidatePoolSize = coerceUnsignedShort(\n input.iceCandidatePoolSize,\n \"iceCandidatePoolSize\",\n );\n }\n\n return normalizedConfig;\n}\n\nfunction coerceUnsignedShort(value: unknown, name: string) {\n const coerced = Number(value);\n if (\n !Number.isFinite(coerced) ||\n !Number.isInteger(coerced) ||\n coerced < 0 ||\n coerced > 65535\n ) {\n throw createWebRtcTypeError(`${name} must be an unsigned short`);\n }\n return coerced;\n}\n\nfunction hasSameCertificates(left: RTCCertificate[], right: RTCCertificate[]) {\n return (\n left.length === right.length &&\n left.every((certificate, index) => certificate === right[index])\n );\n}\n\nexport function clonePeerConfiguration(config: PeerConfig) {\n return {\n ...config,\n codecs: {\n audio: config.codecs.audio ? [...config.codecs.audio] : undefined,\n video: config.codecs.video ? [...config.codecs.video] : undefined,\n },\n headerExtensions: {\n audio: config.headerExtensions.audio\n ? [...config.headerExtensions.audio]\n : undefined,\n video: config.headerExtensions.video\n ? [...config.headerExtensions.video]\n : undefined,\n },\n iceServers: config.iceServers.map((server) => ({\n ...server,\n urls: Array.isArray(server.urls) ? [...server.urls] : server.urls,\n })),\n icePortRange: config.icePortRange\n ? ([...config.icePortRange] as [number, number])\n : undefined,\n iceAdditionalHostAddresses: config.iceAdditionalHostAddresses\n ? [...config.iceAdditionalHostAddresses]\n : undefined,\n dtls: { ...config.dtls },\n certificates: [...config.certificates],\n debug: { ...config.debug },\n sctp: { ...config.sctp },\n pendingRtp:\n typeof config.pendingRtp === \"object\" && config.pendingRtp != undefined\n ? { ...config.pendingRtp }\n : config.pendingRtp,\n };\n}\n\n/**\n * `setConfiguration`: validate `input` against the current `config`, then\n * merge it in place. Returns the normalized input; side effects on live\n * transports (SCTP limits, ICE servers) stay with the caller.\n */\nconst CLEARABLE_TURN_KEYS = [\n \"turnTransport\",\n \"turnTlsOptions\",\n \"turnUdpFamily\",\n] as const;\n\nexport function mergePeerConfiguration(\n config: PeerConfig,\n input: RTCPeerConnectionConfig,\n {\n isReconfiguration,\n hasLocalDescription,\n hasSctpTransport,\n }: {\n isReconfiguration: boolean;\n hasLocalDescription: boolean;\n hasSctpTransport: boolean;\n },\n) {\n const normalizedConfig = normalizePeerConfiguration(input);\n\n if (\n normalizedConfig.rtcpMuxPolicy &&\n normalizedConfig.rtcpMuxPolicy !== \"require\"\n ) {\n throw new Error(\"rtcpMuxPolicy must be require\");\n }\n\n if (\n normalizedConfig.iceCandidatePoolSize !== undefined &&\n (!Number.isInteger(normalizedConfig.iceCandidatePoolSize) ||\n normalizedConfig.iceCandidatePoolSize < 0)\n ) {\n throw new Error(\"iceCandidatePoolSize must be a non-negative integer\");\n }\n\n if (\n isReconfiguration &&\n normalizedConfig.bundlePolicy !== undefined &&\n normalizedConfig.bundlePolicy !== config.bundlePolicy\n ) {\n throw new Error(\"bundlePolicy cannot be changed\");\n }\n\n if (\n normalizedConfig.certificateScope !== undefined &&\n !CertificateScopes.includes(normalizedConfig.certificateScope)\n ) {\n throw createWebRtcTypeError(\n `certificateScope must be one of ${CertificateScopes.join(\", \")}`,\n );\n }\n\n if (\n isReconfiguration &&\n normalizedConfig.certificateScope !== undefined &&\n normalizedConfig.certificateScope !== config.certificateScope\n ) {\n throw createWebRtcDomException(\n \"InvalidModificationError\",\n \"certificateScope cannot be changed\",\n );\n }\n\n if (\n normalizedConfig.mLineReuse !== undefined &&\n !MLineReuseModes.includes(normalizedConfig.mLineReuse)\n ) {\n throw createWebRtcTypeError(\n `mLineReuse must be one of ${MLineReuseModes.join(\", \")}`,\n );\n }\n\n if (\n normalizedConfig.keyFrameRequestRouting !== undefined &&\n !KeyFrameRequestRoutingModes.includes(\n normalizedConfig.keyFrameRequestRouting,\n )\n ) {\n throw createWebRtcTypeError(\n `keyFrameRequestRouting must be one of ${KeyFrameRequestRoutingModes.join(\", \")}`,\n );\n }\n\n if (\n isReconfiguration &&\n normalizedConfig.mLineReuse !== undefined &&\n normalizedConfig.mLineReuse !== config.mLineReuse\n ) {\n throw createWebRtcDomException(\n \"InvalidModificationError\",\n \"mLineReuse cannot be changed\",\n );\n }\n\n if (\n isReconfiguration &&\n normalizedConfig.rtcpMuxPolicy !== undefined &&\n normalizedConfig.rtcpMuxPolicy !== config.rtcpMuxPolicy\n ) {\n throw new Error(\"rtcpMuxPolicy cannot be changed\");\n }\n\n if (\n isReconfiguration &&\n normalizedConfig.certificates !== undefined &&\n !hasSameCertificates(normalizedConfig.certificates, config.certificates)\n ) {\n throw new Error(\"certificates cannot be changed\");\n }\n\n if (\n isReconfiguration &&\n normalizedConfig.iceCandidatePoolSize !== undefined &&\n hasLocalDescription &&\n normalizedConfig.iceCandidatePoolSize !== config.iceCandidatePoolSize\n ) {\n throw new Error(\n \"iceCandidatePoolSize cannot be changed after setLocalDescription\",\n );\n }\n\n if ((normalizedConfig.iceCandidatePoolSize ?? 0) > 0) {\n throw new Error(\"iceCandidatePoolSize > 0 is not supported\");\n }\n\n if (normalizedConfig.sctp !== undefined) {\n const requestedSctpMtu = normalizedConfig.sctp.mtu ?? DEFAULT_SCTP_MTU;\n validateSctpMtu(requestedSctpMtu);\n if (hasSctpTransport && requestedSctpMtu !== config.sctp.mtu) {\n throw new Error(\n \"sctp.mtu cannot be changed after SCTP transport creation\",\n );\n }\n }\n\n deepMerge(config, normalizedConfig as Partial<PeerConfig>);\n // Omitted keys keep their value, but an explicit `undefined` unsets these\n // optional TURN settings (deepMerge skips undefined).\n for (const key of CLEARABLE_TURN_KEYS) {\n if (Object.hasOwn(normalizedConfig, key) && normalizedConfig[key] == null) {\n // Union-key writes require the intersection of all indexed property\n // types. Narrow the key so each optional setting can be cleared safely.\n switch (key) {\n case \"turnTransport\":\n config.turnTransport = undefined;\n break;\n case \"turnTlsOptions\":\n config.turnTlsOptions = undefined;\n break;\n case \"turnUdpFamily\":\n config.turnUdpFamily = undefined;\n break;\n }\n }\n }\n config.sctp = {\n mtu: config.sctp?.mtu ?? DEFAULT_SCTP_MTU,\n };\n\n if (config.icePortRange) {\n const [min, max] = config.icePortRange;\n if (min === max) throw new Error(\"should not be same value\");\n if (min >= max) throw new Error(\"The min must be less than max\");\n }\n\n if (!Number.isInteger(config.maxMessageSize) || config.maxMessageSize < 0) {\n throw new Error(\"maxMessageSize must be a non-negative integer\");\n }\n\n assignDynamicPayloadTypes(config);\n\n [\n ...(config.headerExtensions.audio || []),\n ...(config.headerExtensions.video || []),\n ].forEach((v, i) => {\n v.id = 1 + i;\n });\n\n return normalizedConfig;\n}\n"]}
1
+ {"version":3,"file":"peerConfig.js","sourceRoot":"","sources":["../../../../src/api/peerConfig.ts"],"names":[],"mappings":";;;AAodA,8DAoDC;AA6ED,wDAkCC;AAaD,wDAqNC;AAz1BD,yEAAyE;AACzE,6EAA6E;AAC7E,wDAAwD;AACxD,2CAAsE;AACtE,sCAA4E;AAC5E,sCAAsC;AAYtC,0CAA+C;AAC/C,oEAAqE;AASrE,8CAIuB;AAEvB,4CAA6D;AAC7D,oCAAqC;AACrC,iEAIgC;AAwRnB,QAAA,qBAAqB,GAChC,gDAAyB,CAAC,gBAAgB,CAAC;AAE7C,yFAAyF;AAC5E,QAAA,eAAe,GAC1B,gDAAyB,CAAC,UAAU,CAAC;AAI1B,QAAA,uBAAuB,GAClC,gDAAyB,CAAC,kBAAkB,CAAC;AAIlC,QAAA,oBAAoB,GAAmC;IAClE,UAAU;CACX,CAAC;AAEF,MAAM,qBAAqB,GAAG,MAAM,CAAC,IAAI,CACvC,gDAAyB,CACD,CAAC;AAE3B;;;;GAIG;AACU,QAAA,6BAA6B,GAAG;IAC3C,gBAAgB,EAAE,EAAE,cAAc,EAAE,UAAU,EAAE;IAChD,UAAU,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE;IACtC,sBAAsB,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE;CAKvE,CAAC;AAYF,MAAM,qBAAqB,GAAoC;IAC7D,MAAM;IACN,QAAQ;IACR,MAAM;CACP,CAAC;AAEK,MAAM,mBAAmB,GAAG,CACjC,MAA+B,EAC/B,MAA6B,EAC7B,EAAE,CACF,MAAM,CAAC,IAAI,CACT,CAAC,UAAU,EAAE,EAAE,CACb,IAAA,2CAAsB,EAAC,UAAU,CAAC,QAAQ,CAAC;IAC3C,IAAA,2CAAsB,EAAC,MAAM,CAAC,QAAQ,CAAC,CAC1C;IACC,CAAC,CAAC,MAAM;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MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC7D,IAAI,GAAG,IAAI,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnE,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,MAAM,CAAC,cAAc,GAAG,CAAC,EAAE,CAAC;QAC1E,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACnE,CAAC;IAED,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAElC;QACE,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC;QACxC,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC;KACzC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACjB,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["// RTCPeerConnection configuration: the public configuration types, their\n// defaults, input normalization (W3C RTCConfiguration compatibility) and the\n// validation `setConfiguration` applies before merging.\nimport { DEFAULT_SCTP_MTU, validateSctpMtu } from \"../../../sctp/src\";\nimport { createWebRtcDomException, createWebRtcTypeError } from \"../errors\";\nimport { enumerate } from \"../helper\";\nimport type {\n Address,\n InterfaceAddresses,\n TlsConnectionOptions,\n} from \"../imports/common\";\nimport type {\n CandidatePair,\n Message,\n MessageIntegrityMode,\n Protocol,\n} from \"../imports/ice\";\nimport { defaultCodecs } from \"../media/codec\";\nimport { normalizeCodecMimeType } from \"../media/codecCompatibility\";\nimport type {\n RTCRtpCodecParameters,\n RTCRtpHeaderExtensionParameters,\n} from \"../media/parameters\";\nimport type { KeyFrameRequestRouting } from \"../media/router\";\nimport type { RTCRtpSenderOptions } from \"../media/rtpSender\";\nimport type { BandwidthEstimatorOption } from \"../media/sender/createBandwidthEstimator\";\nimport type { BundlePolicy } from \"../sdp\";\nimport {\n type BundleCandidates,\n BundleCandidatesModes,\n type MLineReuse,\n} from \"../sdpManager\";\nimport type { DtlsKeys, RTCCertificate } from \"../transport/dtls\";\nimport { DEFAULT_MAX_MESSAGE_SIZE } from \"../transport/sctp\";\nimport { deepMerge } from \"../utils\";\nimport {\n type CompatibilityOption,\n type CompatibilityOptionValue,\n CompatibilityOptionValues,\n} from \"./compatibilityOptions\";\n\nexport type DebugConfig = Partial<{\n /**% */\n inboundPacketLoss: number;\n /**% */\n outboundPacketLoss: number;\n /**ms */\n receiverReportDelay: number;\n disableSendNack: boolean;\n disableRecvRetransmit: boolean;\n}>;\n\nexport interface PeerConfig {\n codecs: Partial<{\n /**\n * When specifying a codec with a fixed payloadType such as PCMU,\n * it is necessary to set the correct PayloadType in RTCRtpCodecParameters in advance.\n */\n audio: RTCRtpCodecParameters[];\n video: RTCRtpCodecParameters[];\n }>;\n headerExtensions: Partial<{\n audio: RTCRtpHeaderExtensionParameters[];\n video: RTCRtpHeaderExtensionParameters[];\n }>;\n iceTransportPolicy: \"all\" | \"relay\";\n /** Advertise local ICE lite and operate in the controlled role. */\n iceLite: boolean;\n iceServers: RTCIceServer[];\n /**\n * Fall back to the built-in public STUN server (`stun.l.google.com:19302`)\n * when `iceServers` contains no STUN URL (empty or TURN-only).\n * Set to false to gather server-reflexive candidates only from the STUN\n * servers given in `iceServers`. Defaults to true.\n */\n iceUseDefaultStunServer: boolean;\n /**Minimum port and Maximum port must not be the same value */\n icePortRange: [number, number] | undefined;\n /**\n * Local addresses to bind the ICE UDP host sockets to, per family\n * (`udp4` / `udp6`).\n *\n * The address given for a family is the only host address of that family:\n * its host candidate advertises the address the socket is actually bound\n * to, even when it is not an enumerated interface address (loopback, tun,\n * VPN, ...). If the bind fails, the family has no UDP host candidate.\n * A family left unspecified while the other one is set gathers no\n * enumerated addresses (only its `iceAdditionalHostAddresses`).\n *\n * When unset, each enumerated interface address gets a UDP host socket\n * bound to that address, so connectivity checks leave from the advertised\n * candidate on multi-NIC hosts. An address whose bind fails is not\n * advertised. VPN / tunnel interfaces (`tun`, `utun`, `ipsec`, `tap`) are\n * gathered with a low priority and the default-route address with the\n * highest: the source address of the route to the configured STUN / TURN\n * server (without one, no address is preferred and nothing else is probed).\n * With a STUN server, one more socket per family is bound to the\n * wildcard address: it advertises no host candidate but maps the route the\n * OS picks (server-reflexive candidate with `raddr 0.0.0.0`).\n * `setLocalDescription()` waits only for that socket and the\n * default-route one; the other interfaces' server-reflexive candidates\n * trickle through `onicecandidate` before the end-of-candidates `null`.\n * Set a family to `0.0.0.0` / `::` to gather its enumerated addresses over\n * wildcard sockets instead.\n */\n iceInterfaceAddresses: InterfaceAddresses | undefined;\n /** Add additional host (local) addresses to use for candidate gathering.\n * Notably, you can include hosts that are normally excluded, such as loopback, vmnet / veth interfaces, etc.\n * For a family bound by `iceInterfaceAddresses`, addresses other than the bound one are ignored.\n * An address assigned to a local interface is bound like an enumerated one; any other address\n * (a 1:1 NAT public address, for example) is gathered over a wildcard socket.\n */\n iceAdditionalHostAddresses: string[] | undefined;\n iceUseIpv4: boolean;\n iceUseIpv6: boolean;\n iceUseTcp: boolean;\n /** Gather passive (listening) TCP host candidates. Defaults to true. */\n iceTcpPassive: boolean;\n /**\n * Seconds to wait for server-reflexive candidates while gathering.\n * Defaults to 5 when undefined. `setLocalDescription()` waits for it only\n * on the wildcard and default-route sockets (see `iceInterfaceAddresses`).\n */\n iceStunGatherTimeout: number | undefined;\n /**\n * Seconds to wait for a TURN TCP/TLS connection to be established.\n * Defaults to 8 when undefined.\n */\n iceTurnConnectTimeout: number | undefined;\n /**\n * werift extension. With `iceNomination: \"regular\"`: milliseconds the\n * controlling ICE agent keeps checking before it nominates a candidate pair,\n * so a higher-priority candidate trickled shortly after a lower-priority one\n * succeeded can still be selected. Maps to `IceOptions.nominationDelayMs`:\n * 300 when undefined, 0 nominates the first valid pair at once.\n */\n iceNominationDelayMs: number | undefined;\n /**\n * werift extension. How the controlling ICE agent nominates toward a full\n * ICE peer (`IceOptions.nomination`). `\"semi-aggressive\"` (default when\n * undefined, as Chrome): the first pair whose check succeeds is selected at\n * once and a higher-priority pair that succeeds later replaces it.\n * `\"regular\"`: RFC 8445 regular nomination, one nomination after\n * `iceNominationDelayMs`.\n */\n iceNomination: \"semi-aggressive\" | \"regular\" | undefined;\n /**\n * werift extension. Enable ICE renomination\n * (draft-thatcher-ice-renomination, as libwebrtc implements it): every\n * description advertises `a=ice-options:trickle renomination`. When the\n * remote description advertises `renomination` too, the controlling agent\n * nominates with the NOMINATION STUN attribute and an increasing value, so\n * a later, better pair reliably replaces the selection on both sides\n * (`IceOptions.renomination`). Chrome advertises it only when its SDP is\n * modified before `setLocalDescription`; as the controlled side it honours\n * the attribute regardless. Defaults to false.\n */\n iceRenomination: boolean;\n turnTransport: \"udp\" | \"tcp\" | \"tls\" | undefined;\n turnTlsOptions: TlsConnectionOptions | undefined;\n /**\n * Preferred IP family of the TURN/UDP socket, applied only when the TURN\n * server is a hostname. Ignored for an IP literal server, whose own family\n * always selects the socket. Defaults to 4 when undefined.\n */\n turnUdpFamily: 4 | 6 | undefined;\n /** @deprecated Prefer turn URL transport parameters or turnTransport. */\n forceTurnTCP: boolean;\n /** such as google cloud run */\n iceUseLinkLocalAddress: boolean | undefined;\n /** If provided, is called on each STUN request.\n * Return `true` if a STUN response should be sent, false if it should be skipped. */\n iceFilterStunResponse:\n | ((message: Message, addr: Address, protocol: Protocol) => boolean)\n | undefined;\n iceFilterCandidatePair: ((pair: CandidatePair) => boolean) | undefined;\n /**\n * Integrity attributes of the ICE connectivity checks and consent requests\n * werift sends (RFC 8489 short-term credentials). Applies to ICE transports\n * created after it is set.\n * - `undefined` / `\"sha1\"` (default): MESSAGE-INTEGRITY only. Browsers\n * (libwebrtc, Firefox) accept this.\n * - `\"sha256\"`: MESSAGE-INTEGRITY-SHA256 only. Only for peers known to\n * support it: a peer that does not know the attribute rejects the checks.\n * - `\"both\"`: MESSAGE-INTEGRITY followed by MESSAGE-INTEGRITY-SHA256.\n *\n * Checks and responses from the peer are accepted with either algorithm,\n * and responses are always signed with the algorithm of the request.\n */\n iceMessageIntegrity: MessageIntegrityMode | undefined;\n /**\n * Advertise the `ice2` ice-option (`a=ice-options:trickle ice2`, RFC 8445\n * §10 / RFC 8839) to declare an RFC 8445 agent. Defaults to false\n * (`a=ice-options:trickle`). It is only a declaration: werift runs the\n * RFC 8445 procedures either way. Cannot be changed after construction.\n */\n iceOptionIce2: boolean;\n dtls: Partial<{\n keys: DtlsKeys;\n }>;\n icePasswordPrefix: string | undefined;\n bundlePolicy: BundlePolicy;\n rtcpMuxPolicy: \"require\";\n iceCandidatePoolSize: number;\n certificates: RTCCertificate[];\n /**\n * Which default DTLS certificate is used when neither `certificates` nor `dtls.keys` is given\n * (see {@link CompatibilityOptionValues}). Cannot be changed after construction.\n * - `\"process\"` (default): one certificate shared by every RTCPeerConnection in the process,\n * so their `a=fingerprint` values are identical.\n * - `\"standard\"`: each RTCPeerConnection generates its own certificate, as browsers do.\n * All DTLS transports of that connection share it.\n *\n * Also accepts the v0.27.0 name `\"peerConnection\"` (= `\"standard\"`).\n */\n certificateScope: CertificateScope;\n debug: DebugConfig;\n midSuffix: boolean;\n /** Advertised local SCTP max-message-size in SDP. Use 0 for unlimited. */\n maxMessageSize: number;\n /**\n * When true, padding-only RTP is omitted from onReceiveRtp and later media\n * sequence numbers are compacted. Default false preserves wire RTP events.\n */\n filterProbePaddingOnReceiveRtp: boolean;\n /** Send-side estimator used by each new sender; defaults to `\"lightweight\"`. */\n bandwidthEstimator: BandwidthEstimatorOption;\n /** SCTP outbound packet MTU used for DATA chunk fragmentation. */\n sctp: { mtu: number };\n /**\n * Queue outbound RTP on each sender until DTLS is connected.\n * Disabled by default. Pass `true` or `{ enabled: true, maxLength }` to buffer.\n */\n pendingRtp: NonNullable<RTCRtpSenderOptions[\"pendingRtp\"]>;\n /**\n * How local SDP marks inactive / stopped m-lines (see {@link CompatibilityOptionValues}).\n * Cannot be changed after construction.\n * - `\"standard\"` (default): an accepted `inactive` m-line keeps a non-zero port, as JSEP\n * and browsers do. Only rejected (no common codec / remote port 0) or stopped m-lines\n * use port 0, and only those negotiated port 0 positions are reused by new transceivers.\n * - `\"aggressive\"`: behavior before v0.25.0. `inactive` m-lines are also written with\n * port 0, so the remote side treats them as rejected and their positions are reused.\n *\n * Also accepts the v0.27.0 name `\"compatible\"` (= `\"standard\"`).\n */\n mLineReuse: MLineReuse;\n /**\n * How a remote offer's m-sections are paired with local transceivers that\n * have no MID yet (see {@link CompatibilityOptionValues}). Cannot be changed\n * after construction.\n * - `\"byKind\"` (default): behavior up to v0.27.0. Any unassociated,\n * non-stopped transceiver of the same kind is paired (the one at the same\n * m-line index first), whatever created it. In glare (perfect negotiation)\n * the remote offer can take over a transceiver created with\n * `addTransceiver(kind, { direction: \"sendonly\" })` and its direction\n * becomes `sendrecv`.\n * - `\"standard\"`: RFC 8829 (JSEP) section 5.10, as browsers do. An\n * m-section whose MID no transceiver has is associated only with an\n * unassociated, non-stopped transceiver of the same kind that\n * `addTrack()` created (or one a rollback promoted to that, JSEP 4.1.8.2),\n * and only when the m-section is `sendrecv` or `recvonly`. A transceiver\n * created by `addTransceiver()` (with or without a track, also after\n * `replaceTrack()` or a later `addTrack()` reusing it) is never paired:\n * the offer gets a new transceiver, and the local one keeps its direction\n * and `mid === null` until a local offer negotiates it. Use it for the\n * perfect negotiation pattern and for code written for browsers.\n */\n transceiverPairing: TransceiverPairing;\n /**\n * Where a PLI / FIR goes when no route has its target SSRC (see\n * {@link CompatibilityOptionValues} and {@link KeyFrameRequestRouting}).\n * `setConfiguration()` may change it.\n * - `\"fallback\"` (default): the sender whose RTX SSRC it is, else the only video sender.\n * - `\"standard\"`: not delivered, as RFC 4585 / RFC 5104 define the target.\n *\n * Also accepts the names up to v0.27.0: `\"compatible\"` (= `\"fallback\"`) and\n * `\"strict\"` (= `\"standard\"`).\n */\n keyFrameRequestRouting: KeyFrameRequestRouting;\n /**\n * Which m-lines of a BUNDLE group carry the local ICE candidates.\n * Cannot be changed after construction. See {@link BundleCandidates}.\n * - `\"legacy\"` (default): every m-line repeats its transport's candidates and\n * `a=end-of-candidates` (werift's earlier output).\n * - `\"compatible\"`: as Chrome writes them, only the BUNDLE tag m-line carries\n * them, so renegotiation with more m-lines no longer repeats the candidate list.\n */\n bundleCandidates: BundleCandidates;\n /**\n * Sets every compatibility option (`certificateScope`, `mLineReuse`,\n * `transceiverPairing`, `keyFrameRequestRouting`, see\n * {@link CompatibilityOptionValues}) to the specification / browser behavior\n * at once. Cannot be changed after construction.\n * - `undefined` (default): each option keeps its own default.\n * - `\"standard\"`: every compatibility option not given in the same\n * configuration is `\"standard\"`.\n *\n * An option given explicitly always takes precedence over `compatibility`:\n * a value given in the same configuration (an old name included) is kept,\n * and `setConfiguration()` treats the options as if `compatibility` were\n * not set (`keyFrameRequestRouting` may change, the others cannot). An\n * option given as `undefined` counts as not given.\n *\n * ```ts\n * new RTCPeerConnection({ compatibility: \"standard\" });\n * // certificateScope, mLineReuse, transceiverPairing and\n * // keyFrameRequestRouting are all \"standard\"\n * new RTCPeerConnection({ compatibility: \"standard\", certificateScope: \"process\" });\n * // certificateScope is \"process\", the other three are \"standard\"\n * ```\n *\n * It does not change `iceServers` / `iceUseDefaultStunServer`, which are not\n * compatibility options.\n */\n compatibility: CompatibilityPreset | undefined;\n}\n\n/** Which default DTLS certificate is used. See {@link PeerConfig.certificateScope}. */\nexport type CertificateScope = CompatibilityOptionValue<\"certificateScope\">;\nexport const CertificateScopeModes: readonly CertificateScope[] =\n CompatibilityOptionValues.certificateScope;\n\n/** How local SDP marks inactive / stopped m-lines. See {@link PeerConfig.mLineReuse}. */\nexport const MLineReuseModes: readonly MLineReuse[] =\n CompatibilityOptionValues.mLineReuse;\n\n/** How a remote offer pairs m-sections with local transceivers. See {@link PeerConfig.transceiverPairing}. */\nexport type TransceiverPairing = CompatibilityOptionValue<\"transceiverPairing\">;\nexport const TransceiverPairingModes: readonly TransceiverPairing[] =\n CompatibilityOptionValues.transceiverPairing;\n\n/** The values of {@link PeerConfig.compatibility}. */\nexport type CompatibilityPreset = \"standard\";\nexport const CompatibilityPresets: readonly CompatibilityPreset[] = [\n \"standard\",\n];\n\nconst COMPATIBILITY_OPTIONS = Object.keys(\n CompatibilityOptionValues,\n) as CompatibilityOption[];\n\n/**\n * The values the compatibility options used up to v0.27.0 that are not\n * values any more, and the value each one is read as. They are accepted on\n * input only: `getConfiguration()` returns the current name.\n */\nexport const DeprecatedCompatibilityValues = {\n certificateScope: { peerConnection: \"standard\" },\n mLineReuse: { compatible: \"standard\" },\n keyFrameRequestRouting: { compatible: \"fallback\", strict: \"standard\" },\n} as const satisfies {\n [K in CompatibilityOption]?: Readonly<\n Record<string, CompatibilityOptionValue<K>>\n >;\n};\n\n/** @deprecated Use `\"standard\"` (`\"peerConnection\"`). */\nexport type DeprecatedCertificateScope =\n keyof (typeof DeprecatedCompatibilityValues)[\"certificateScope\"];\n/** @deprecated Use `\"standard\"` (`\"compatible\"`). */\nexport type DeprecatedMLineReuse =\n keyof (typeof DeprecatedCompatibilityValues)[\"mLineReuse\"];\n/** @deprecated Use `\"fallback\"` (`\"compatible\"`) or `\"standard\"` (`\"strict\"`). */\nexport type DeprecatedKeyFrameRequestRouting =\n keyof (typeof DeprecatedCompatibilityValues)[\"keyFrameRequestRouting\"];\n\nconst MessageIntegrityModes: readonly MessageIntegrityMode[] = [\n \"sha1\",\n \"sha256\",\n \"both\",\n];\n\nexport const findCodecByMimeType = (\n codecs: RTCRtpCodecParameters[],\n target: RTCRtpCodecParameters,\n) =>\n codecs.find(\n (localCodec) =>\n normalizeCodecMimeType(localCodec.mimeType) ===\n normalizeCodecMimeType(target.mimeType),\n )\n ? target\n : undefined;\n\nfunction assignDynamicPayloadTypes(config: PeerConfig) {\n for (const [i, codecParams] of enumerate([\n ...(config.codecs.audio || []),\n ...(config.codecs.video || []),\n ])) {\n if (codecParams.payloadType != undefined) {\n continue;\n }\n\n codecParams.payloadType = 96 + i;\n switch (codecParams.name.toLowerCase()) {\n case \"rtx\":\n {\n codecParams.parameters = `apt=${codecParams.payloadType - 1}`;\n }\n break;\n case \"red\":\n {\n if (codecParams.contentType === \"audio\") {\n const redundant = codecParams.payloadType + 1;\n codecParams.parameters = `${redundant}/${redundant}`;\n codecParams.payloadType = 63;\n }\n }\n break;\n }\n }\n}\n\nexport type RTCIceServer = {\n urls: string | string[];\n username?: string;\n credential?: string;\n};\n\nexport type RTCBundlePolicy = \"balanced\" | \"max-compat\" | \"max-bundle\";\nexport type RTCRtcpMuxPolicy = \"require\";\n\nexport interface RTCSctpConfiguration {\n /** SCTP outbound packet MTU used for DATA chunk fragmentation. Defaults to 1191. */\n mtu?: number;\n}\n\nexport interface RTCConfiguration {\n iceServers?: RTCIceServer[];\n iceTransportPolicy?: PeerConfig[\"iceTransportPolicy\"];\n bundlePolicy?: RTCBundlePolicy;\n rtcpMuxPolicy?: RTCRtcpMuxPolicy;\n iceCandidatePoolSize?: number;\n certificates?: RTCCertificate[];\n}\n\ntype RTCPeerConnectionRTCConfiguration = Omit<\n RTCConfiguration,\n \"bundlePolicy\"\n> & {\n bundlePolicy?: PeerConfig[\"bundlePolicy\"] | RTCBundlePolicy;\n};\n\nexport type RTCPeerConnectionConfig = Partial<\n Omit<\n PeerConfig,\n | \"bundlePolicy\"\n | \"rtcpMuxPolicy\"\n | \"iceCandidatePoolSize\"\n | \"certificates\"\n | \"sctp\"\n | \"certificateScope\"\n | \"mLineReuse\"\n | \"keyFrameRequestRouting\"\n >\n> &\n RTCPeerConnectionRTCConfiguration & {\n sctp?: RTCSctpConfiguration;\n /** See {@link PeerConfig.certificateScope}. */\n certificateScope?: CertificateScope | DeprecatedCertificateScope;\n /** See {@link PeerConfig.mLineReuse}. */\n mLineReuse?: MLineReuse | DeprecatedMLineReuse;\n /** See {@link PeerConfig.keyFrameRequestRouting}. */\n keyFrameRequestRouting?:\n | KeyFrameRequestRouting\n | DeprecatedKeyFrameRequestRouting;\n };\n\nexport function generateDefaultPeerConfig(): PeerConfig {\n return {\n codecs: defaultCodecs(),\n headerExtensions: {\n audio: [],\n video: [],\n },\n iceTransportPolicy: \"all\",\n iceLite: false,\n iceServers: [{ urls: \"stun:stun.l.google.com:19302\" }],\n iceUseDefaultStunServer: true,\n icePortRange: undefined,\n iceInterfaceAddresses: undefined,\n iceAdditionalHostAddresses: undefined,\n iceUseIpv4: true,\n iceUseIpv6: true,\n iceUseTcp: false,\n iceTcpPassive: true,\n iceStunGatherTimeout: undefined,\n iceTurnConnectTimeout: undefined,\n iceNominationDelayMs: undefined,\n iceNomination: undefined,\n iceRenomination: false,\n turnTransport: undefined,\n turnTlsOptions: undefined,\n turnUdpFamily: undefined,\n iceFilterStunResponse: undefined,\n iceFilterCandidatePair: undefined,\n iceMessageIntegrity: undefined,\n iceOptionIce2: false,\n icePasswordPrefix: undefined,\n iceUseLinkLocalAddress: undefined,\n dtls: {},\n bundlePolicy: \"max-compat\",\n rtcpMuxPolicy: \"require\",\n iceCandidatePoolSize: 0,\n certificates: [],\n certificateScope: \"process\",\n debug: {},\n midSuffix: false,\n forceTurnTCP: false,\n maxMessageSize: DEFAULT_MAX_MESSAGE_SIZE,\n filterProbePaddingOnReceiveRtp: false,\n bandwidthEstimator: \"lightweight\",\n sctp: { mtu: DEFAULT_SCTP_MTU },\n pendingRtp: false,\n mLineReuse: \"standard\",\n transceiverPairing: \"byKind\",\n keyFrameRequestRouting: \"fallback\",\n bundleCandidates: \"legacy\",\n compatibility: undefined,\n };\n}\nexport const defaultPeerConfig: PeerConfig = generateDefaultPeerConfig();\n\nfunction normalizePeerConfiguration(\n config: RTCPeerConnectionConfig,\n): Partial<PeerConfig> & { sctp?: RTCSctpConfiguration } {\n const input = Object(config ?? {}) as RTCPeerConnectionConfig;\n const normalizedConfig = { ...input } as Partial<PeerConfig> & {\n sctp?: RTCSctpConfiguration;\n };\n\n if (input.sctp !== undefined) {\n normalizedConfig.sctp = { ...input.sctp } as PeerConfig[\"sctp\"];\n }\n\n if (input.bundlePolicy === \"balanced\") {\n normalizedConfig.bundlePolicy = \"max-compat\";\n }\n\n for (const option of COMPATIBILITY_OPTIONS) {\n const value: unknown = input[option];\n if (option in DeprecatedCompatibilityValues && typeof value === \"string\") {\n const aliases: Readonly<Record<string, string>> =\n DeprecatedCompatibilityValues[\n option as keyof typeof DeprecatedCompatibilityValues\n ];\n if (Object.hasOwn(aliases, value)) {\n (normalizedConfig as Record<string, unknown>)[option] = aliases[value];\n }\n }\n }\n\n if (\"certificates\" in input) {\n if (input.certificates === undefined) {\n normalizedConfig.certificates = undefined;\n } else if (\n !Array.isArray(input.certificates) ||\n input.certificates.some((certificate) => certificate == null)\n ) {\n throw createWebRtcTypeError(\n \"certificates must be an array of RTCCertificate\",\n );\n } else {\n normalizedConfig.certificates = [...input.certificates];\n }\n }\n\n if (\"iceCandidatePoolSize\" in input) {\n normalizedConfig.iceCandidatePoolSize = coerceUnsignedShort(\n input.iceCandidatePoolSize,\n \"iceCandidatePoolSize\",\n );\n }\n\n return normalizedConfig;\n}\n\nfunction coerceUnsignedShort(value: unknown, name: string) {\n const coerced = Number(value);\n if (\n !Number.isFinite(coerced) ||\n !Number.isInteger(coerced) ||\n coerced < 0 ||\n coerced > 65535\n ) {\n throw createWebRtcTypeError(`${name} must be an unsigned short`);\n }\n return coerced;\n}\n\nfunction hasSameCertificates(left: RTCCertificate[], right: RTCCertificate[]) {\n return (\n left.length === right.length &&\n left.every((certificate, index) => certificate === right[index])\n );\n}\n\nexport function clonePeerConfiguration(config: PeerConfig) {\n return {\n ...config,\n codecs: {\n audio: config.codecs.audio ? [...config.codecs.audio] : undefined,\n video: config.codecs.video ? [...config.codecs.video] : undefined,\n },\n headerExtensions: {\n audio: config.headerExtensions.audio\n ? [...config.headerExtensions.audio]\n : undefined,\n video: config.headerExtensions.video\n ? [...config.headerExtensions.video]\n : undefined,\n },\n iceServers: config.iceServers.map((server) => ({\n ...server,\n urls: Array.isArray(server.urls) ? [...server.urls] : server.urls,\n })),\n icePortRange: config.icePortRange\n ? ([...config.icePortRange] as [number, number])\n : undefined,\n iceAdditionalHostAddresses: config.iceAdditionalHostAddresses\n ? [...config.iceAdditionalHostAddresses]\n : undefined,\n dtls: { ...config.dtls },\n certificates: [...config.certificates],\n debug: { ...config.debug },\n sctp: { ...config.sctp },\n pendingRtp:\n typeof config.pendingRtp === \"object\" && config.pendingRtp != undefined\n ? { ...config.pendingRtp }\n : config.pendingRtp,\n };\n}\n\n/**\n * `setConfiguration`: validate `input` against the current `config`, then\n * merge it in place. Returns the normalized input; side effects on live\n * transports (SCTP limits, ICE servers) stay with the caller.\n */\nconst CLEARABLE_TURN_KEYS = [\n \"turnTransport\",\n \"turnTlsOptions\",\n \"turnUdpFamily\",\n] as const;\n\nexport function mergePeerConfiguration(\n config: PeerConfig,\n input: RTCPeerConnectionConfig,\n {\n isReconfiguration,\n hasLocalDescription,\n hasSctpTransport,\n }: {\n isReconfiguration: boolean;\n hasLocalDescription: boolean;\n hasSctpTransport: boolean;\n },\n) {\n const normalizedConfig = normalizePeerConfiguration(input);\n\n if (\n normalizedConfig.rtcpMuxPolicy &&\n normalizedConfig.rtcpMuxPolicy !== \"require\"\n ) {\n throw new Error(\"rtcpMuxPolicy must be require\");\n }\n\n if (\n normalizedConfig.iceCandidatePoolSize !== undefined &&\n (!Number.isInteger(normalizedConfig.iceCandidatePoolSize) ||\n normalizedConfig.iceCandidatePoolSize < 0)\n ) {\n throw new Error(\"iceCandidatePoolSize must be a non-negative integer\");\n }\n\n if (\n isReconfiguration &&\n normalizedConfig.bundlePolicy !== undefined &&\n normalizedConfig.bundlePolicy !== config.bundlePolicy\n ) {\n throw new Error(\"bundlePolicy cannot be changed\");\n }\n\n if (\n normalizedConfig.compatibility !== undefined &&\n !CompatibilityPresets.includes(normalizedConfig.compatibility)\n ) {\n throw createWebRtcTypeError(\n `compatibility must be one of ${CompatibilityPresets.join(\", \")}`,\n );\n }\n if (isReconfiguration) {\n if (\n normalizedConfig.compatibility !== undefined &&\n normalizedConfig.compatibility !== config.compatibility\n ) {\n throw createWebRtcDomException(\n \"InvalidModificationError\",\n \"compatibility cannot be changed\",\n );\n }\n } else if (normalizedConfig.compatibility === \"standard\") {\n // 構築時だけ、明示されていない互換性オプションを standard にする。\n // 明示された値は常に compatibility より優先する (PeerConfig.compatibility)\n for (const option of COMPATIBILITY_OPTIONS) {\n if (normalizedConfig[option] === undefined) {\n (normalizedConfig as Record<string, unknown>)[option] = \"standard\";\n }\n }\n }\n\n for (const option of COMPATIBILITY_OPTIONS) {\n const value = normalizedConfig[option];\n if (value === undefined) continue;\n const values: readonly string[] = CompatibilityOptionValues[option];\n if (!values.includes(value)) {\n throw createWebRtcTypeError(\n `${option} must be one of ${values.join(\", \")}`,\n );\n }\n // keyFrameRequestRouting は接続中に切り替えられる (router が次の要求から使う)\n if (\n isReconfiguration &&\n option !== \"keyFrameRequestRouting\" &&\n value !== config[option]\n ) {\n throw createWebRtcDomException(\n \"InvalidModificationError\",\n `${option} cannot be changed`,\n );\n }\n }\n\n if (\n normalizedConfig.bundleCandidates !== undefined &&\n !BundleCandidatesModes.includes(normalizedConfig.bundleCandidates)\n ) {\n throw createWebRtcTypeError(\n `bundleCandidates must be one of ${BundleCandidatesModes.join(\", \")}`,\n );\n }\n\n if (\n isReconfiguration &&\n normalizedConfig.bundleCandidates !== undefined &&\n normalizedConfig.bundleCandidates !== config.bundleCandidates\n ) {\n throw createWebRtcDomException(\n \"InvalidModificationError\",\n \"bundleCandidates cannot be changed\",\n );\n }\n\n if (\n normalizedConfig.iceMessageIntegrity !== undefined &&\n !MessageIntegrityModes.includes(normalizedConfig.iceMessageIntegrity)\n ) {\n throw createWebRtcTypeError(\n `iceMessageIntegrity must be one of ${MessageIntegrityModes.join(\", \")}`,\n );\n }\n\n if (\n isReconfiguration &&\n normalizedConfig.iceOptionIce2 !== undefined &&\n normalizedConfig.iceOptionIce2 !== config.iceOptionIce2\n ) {\n throw createWebRtcDomException(\n \"InvalidModificationError\",\n \"iceOptionIce2 cannot be changed\",\n );\n }\n\n if (\n isReconfiguration &&\n normalizedConfig.rtcpMuxPolicy !== undefined &&\n normalizedConfig.rtcpMuxPolicy !== config.rtcpMuxPolicy\n ) {\n throw new Error(\"rtcpMuxPolicy cannot be changed\");\n }\n\n if (\n isReconfiguration &&\n normalizedConfig.certificates !== undefined &&\n !hasSameCertificates(normalizedConfig.certificates, config.certificates)\n ) {\n throw new Error(\"certificates cannot be changed\");\n }\n\n if (\n isReconfiguration &&\n normalizedConfig.iceCandidatePoolSize !== undefined &&\n hasLocalDescription &&\n normalizedConfig.iceCandidatePoolSize !== config.iceCandidatePoolSize\n ) {\n throw new Error(\n \"iceCandidatePoolSize cannot be changed after setLocalDescription\",\n );\n }\n\n if ((normalizedConfig.iceCandidatePoolSize ?? 0) > 0) {\n throw new Error(\"iceCandidatePoolSize > 0 is not supported\");\n }\n\n if (normalizedConfig.sctp !== undefined) {\n const requestedSctpMtu = normalizedConfig.sctp.mtu ?? DEFAULT_SCTP_MTU;\n validateSctpMtu(requestedSctpMtu);\n if (hasSctpTransport && requestedSctpMtu !== config.sctp.mtu) {\n throw new Error(\n \"sctp.mtu cannot be changed after SCTP transport creation\",\n );\n }\n }\n\n deepMerge(config, normalizedConfig as Partial<PeerConfig>);\n // Omitted keys keep their value, but an explicit `undefined` unsets these\n // optional TURN settings (deepMerge skips undefined).\n for (const key of CLEARABLE_TURN_KEYS) {\n if (Object.hasOwn(normalizedConfig, key) && normalizedConfig[key] == null) {\n // Union-key writes require the intersection of all indexed property\n // types. Narrow the key so each optional setting can be cleared safely.\n switch (key) {\n case \"turnTransport\":\n config.turnTransport = undefined;\n break;\n case \"turnTlsOptions\":\n config.turnTlsOptions = undefined;\n break;\n case \"turnUdpFamily\":\n config.turnUdpFamily = undefined;\n break;\n }\n }\n }\n config.sctp = {\n mtu: config.sctp?.mtu ?? DEFAULT_SCTP_MTU,\n };\n\n if (config.icePortRange) {\n const [min, max] = config.icePortRange;\n if (min === max) throw new Error(\"should not be same value\");\n if (min >= max) throw new Error(\"The min must be less than max\");\n }\n\n if (!Number.isInteger(config.maxMessageSize) || config.maxMessageSize < 0) {\n throw new Error(\"maxMessageSize must be a non-negative integer\");\n }\n\n assignDynamicPayloadTypes(config);\n\n [\n ...(config.headerExtensions.audio || []),\n ...(config.headerExtensions.video || []),\n ].forEach((v, i) => {\n v.id = 1 + i;\n });\n\n return normalizedConfig;\n}\n"]}
@@ -15,6 +15,82 @@ export declare class RTCTrackEvent {
15
15
  receiver: RTCRtpReceiver;
16
16
  });
17
17
  }
18
+ /** Members of {@link RTCPeerConnectionIceErrorEvent} (W3C RTCPeerConnectionIceErrorEventInit). */
19
+ export interface RTCPeerConnectionIceErrorEventInit {
20
+ address?: string | null;
21
+ port?: number | null;
22
+ url?: string;
23
+ errorCode: number;
24
+ errorText?: string;
25
+ /** Standard `EventInit` members. */
26
+ bubbles?: boolean;
27
+ cancelable?: boolean;
28
+ composed?: boolean;
29
+ }
30
+ /**
31
+ * `icecandidateerror` (W3C WebRTC §4.8.2): a configured STUN or TURN server
32
+ * could not give a candidate while gathering. Never fired after `close()`.
33
+ *
34
+ * - A server that answered with an error response (300-699): fired at once,
35
+ * once per local socket that asked it.
36
+ * - 701 (server not reached, W3C: no host candidate could reach it): judged
37
+ * once per gathering, when `iceGatheringState` leaves "gathering" (just
38
+ * before that `icegatheringstatechange`), and fired once per URL that some
39
+ * ICE transport of the gathering tried without reaching the server while
40
+ * none reached it. Only transports still in use at that point count, with
41
+ * the ICE generation they gathered in: one closed or discarded (rollback)
42
+ * meanwhile, one that did not try the URL, and a generation an ICE restart
43
+ * replaced do not count. The event carries the local address of the first
44
+ * socket that failed (STUN). A new gathering (ICE restart, a new transport)
45
+ * reports the URL again. A handler that closes the connection stops the
46
+ * rest: no further 701 nor `icegatheringstatechange` is fired.
47
+ *
48
+ * While listeners run, `target` and `currentTarget` are the
49
+ * `RTCPeerConnection` and `eventPhase` is 2 (`AT_TARGET`); afterwards
50
+ * `currentTarget` is `null` and `eventPhase` 0. The event reaches
51
+ * `pc.onIceCandidateError`, `onicecandidateerror` and the
52
+ * `icecandidateerror` listeners in that order; `stopImmediatePropagation()`
53
+ * stops the ones after the caller (also later `pc.onIceCandidateError`
54
+ * subscribers), `stopPropagation()` does not (AT_TARGET). A listener
55
+ * removed during the dispatch is not called, one added during it is not
56
+ * called this time. The event is not cancelable (`preventDefault()` does
57
+ * nothing) and, as fired by the connection, `isTrusted` is true. While a 701 is dispatched,
58
+ * `iceGatheringState` still reads `"gathering"`.
59
+ *
60
+ * - `url`: the configured URL of the server, canonical: trimmed, lower-case
61
+ * scheme, and `?transport=tcp` added to a `turns:` URL that names no
62
+ * transport (`turns:h:5349` → `turns:h:5349?transport=tcp`, the Chrome /
63
+ * WPT form). Several URLs naming one server each get their own event. The
64
+ * built-in default STUN server (`iceUseDefaultStunServer`, used when no
65
+ * STUN server is configured) is in no configuration; werift reports it
66
+ * with the synthesized URL `stun:stun.l.google.com:19302`.
67
+ * - `errorCode`: the STUN error code the server answered with (300-699),
68
+ * or 701 when it was not reached (DNS, timeout, connect or socket error).
69
+ * A server that answered without a STUN error code (an error response
70
+ * without ERROR-CODE, a response failing MESSAGE-INTEGRITY, a success
71
+ * without XOR-MAPPED-ADDRESS) was reached: it gives no event, and never
72
+ * a 701.
73
+ * - `errorText`: the reason phrase the server returned (W3C), with the
74
+ * credential material werift knows replaced by `***` (the configured TURN
75
+ * username and password, and the USERNAME / REALM / NONCE of the
76
+ * response), control characters dropped and cut to 127 characters; the
77
+ * registered phrase of the code (`"Unauthorized"`, `"STUN error 499"`)
78
+ * when that is empty; a description of the cause for a 701.
79
+ * - `address` / `port`: the local host address used to contact a STUN
80
+ * server; both `null` when unknown (TURN) or hidden (the `"relay"` ICE
81
+ * transport policy), as the W3C spec says (a null address has a null
82
+ * port). Chrome gives `port: 0` instead and the upstream WPT tests
83
+ * expect that; werift's WPT runner maps the `null` to 0, the API keeps
84
+ * the spec value.
85
+ */
86
+ export declare class RTCPeerConnectionIceErrorEvent extends Event {
87
+ readonly address: string | null;
88
+ readonly port: number | null;
89
+ readonly url: string;
90
+ readonly errorCode: number;
91
+ readonly errorText: string;
92
+ constructor(type: string, init: RTCPeerConnectionIceErrorEventInit);
93
+ }
18
94
  export interface RTCDataChannelEvent {
19
95
  type?: "datachannel";
20
96
  channel: RTCDataChannel;
@@ -26,7 +102,7 @@ export interface RTCPeerConnectionIceEvent {
26
102
  export type PeerConnectionEventHandlers = {
27
103
  ondatachannel?: CallbackWithValue<RTCDataChannelEvent>;
28
104
  onicecandidate?: CallbackWithValue<RTCPeerConnectionIceEvent>;
29
- onicecandidateerror?: CallbackWithValue<any>;
105
+ onicecandidateerror?: CallbackWithValue<RTCPeerConnectionIceErrorEvent>;
30
106
  onicegatheringstatechange?: CallbackWithValue<any>;
31
107
  onnegotiationneeded?: CallbackWithValue<any>;
32
108
  onsignalingstatechange?: CallbackWithValue<any>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RTCTrackEvent = void 0;
3
+ exports.RTCPeerConnectionIceErrorEvent = exports.RTCTrackEvent = void 0;
4
4
  // Events RTCPeerConnection dispatches and the `on*` handler attributes.
5
5
  class RTCTrackEvent {
6
6
  constructor(init) {
@@ -41,4 +41,108 @@ class RTCTrackEvent {
41
41
  }
42
42
  }
43
43
  exports.RTCTrackEvent = RTCTrackEvent;
44
+ /**
45
+ * `icecandidateerror` (W3C WebRTC §4.8.2): a configured STUN or TURN server
46
+ * could not give a candidate while gathering. Never fired after `close()`.
47
+ *
48
+ * - A server that answered with an error response (300-699): fired at once,
49
+ * once per local socket that asked it.
50
+ * - 701 (server not reached, W3C: no host candidate could reach it): judged
51
+ * once per gathering, when `iceGatheringState` leaves "gathering" (just
52
+ * before that `icegatheringstatechange`), and fired once per URL that some
53
+ * ICE transport of the gathering tried without reaching the server while
54
+ * none reached it. Only transports still in use at that point count, with
55
+ * the ICE generation they gathered in: one closed or discarded (rollback)
56
+ * meanwhile, one that did not try the URL, and a generation an ICE restart
57
+ * replaced do not count. The event carries the local address of the first
58
+ * socket that failed (STUN). A new gathering (ICE restart, a new transport)
59
+ * reports the URL again. A handler that closes the connection stops the
60
+ * rest: no further 701 nor `icegatheringstatechange` is fired.
61
+ *
62
+ * While listeners run, `target` and `currentTarget` are the
63
+ * `RTCPeerConnection` and `eventPhase` is 2 (`AT_TARGET`); afterwards
64
+ * `currentTarget` is `null` and `eventPhase` 0. The event reaches
65
+ * `pc.onIceCandidateError`, `onicecandidateerror` and the
66
+ * `icecandidateerror` listeners in that order; `stopImmediatePropagation()`
67
+ * stops the ones after the caller (also later `pc.onIceCandidateError`
68
+ * subscribers), `stopPropagation()` does not (AT_TARGET). A listener
69
+ * removed during the dispatch is not called, one added during it is not
70
+ * called this time. The event is not cancelable (`preventDefault()` does
71
+ * nothing) and, as fired by the connection, `isTrusted` is true. While a 701 is dispatched,
72
+ * `iceGatheringState` still reads `"gathering"`.
73
+ *
74
+ * - `url`: the configured URL of the server, canonical: trimmed, lower-case
75
+ * scheme, and `?transport=tcp` added to a `turns:` URL that names no
76
+ * transport (`turns:h:5349` → `turns:h:5349?transport=tcp`, the Chrome /
77
+ * WPT form). Several URLs naming one server each get their own event. The
78
+ * built-in default STUN server (`iceUseDefaultStunServer`, used when no
79
+ * STUN server is configured) is in no configuration; werift reports it
80
+ * with the synthesized URL `stun:stun.l.google.com:19302`.
81
+ * - `errorCode`: the STUN error code the server answered with (300-699),
82
+ * or 701 when it was not reached (DNS, timeout, connect or socket error).
83
+ * A server that answered without a STUN error code (an error response
84
+ * without ERROR-CODE, a response failing MESSAGE-INTEGRITY, a success
85
+ * without XOR-MAPPED-ADDRESS) was reached: it gives no event, and never
86
+ * a 701.
87
+ * - `errorText`: the reason phrase the server returned (W3C), with the
88
+ * credential material werift knows replaced by `***` (the configured TURN
89
+ * username and password, and the USERNAME / REALM / NONCE of the
90
+ * response), control characters dropped and cut to 127 characters; the
91
+ * registered phrase of the code (`"Unauthorized"`, `"STUN error 499"`)
92
+ * when that is empty; a description of the cause for a 701.
93
+ * - `address` / `port`: the local host address used to contact a STUN
94
+ * server; both `null` when unknown (TURN) or hidden (the `"relay"` ICE
95
+ * transport policy), as the W3C spec says (a null address has a null
96
+ * port). Chrome gives `port: 0` instead and the upstream WPT tests
97
+ * expect that; werift's WPT runner maps the `null` to 0, the API keeps
98
+ * the spec value.
99
+ */
100
+ class RTCPeerConnectionIceErrorEvent extends Event {
101
+ constructor(type, init) {
102
+ super(type, {
103
+ bubbles: init?.bubbles,
104
+ cancelable: init?.cancelable,
105
+ composed: init?.composed,
106
+ });
107
+ Object.defineProperty(this, "address", {
108
+ enumerable: true,
109
+ configurable: true,
110
+ writable: true,
111
+ value: void 0
112
+ });
113
+ Object.defineProperty(this, "port", {
114
+ enumerable: true,
115
+ configurable: true,
116
+ writable: true,
117
+ value: void 0
118
+ });
119
+ Object.defineProperty(this, "url", {
120
+ enumerable: true,
121
+ configurable: true,
122
+ writable: true,
123
+ value: void 0
124
+ });
125
+ Object.defineProperty(this, "errorCode", {
126
+ enumerable: true,
127
+ configurable: true,
128
+ writable: true,
129
+ value: void 0
130
+ });
131
+ Object.defineProperty(this, "errorText", {
132
+ enumerable: true,
133
+ configurable: true,
134
+ writable: true,
135
+ value: void 0
136
+ });
137
+ if (init == null || typeof init.errorCode !== "number") {
138
+ throw new TypeError("RTCPeerConnectionIceErrorEvent: errorCode is required");
139
+ }
140
+ this.address = init.address ?? null;
141
+ this.port = init.port ?? null;
142
+ this.url = init.url ?? "";
143
+ this.errorCode = init.errorCode;
144
+ this.errorText = init.errorText ?? "";
145
+ }
146
+ }
147
+ exports.RTCPeerConnectionIceErrorEvent = RTCPeerConnectionIceErrorEvent;
44
148
  //# sourceMappingURL=peerConnectionEvents.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"peerConnectionEvents.js","sourceRoot":"","sources":["../../../../src/api/peerConnectionEvents.ts"],"names":[],"mappings":";;;AAUA,wEAAwE;AAExE,MAAa,aAAa;IAOxB,YAAY,IAKX;QAXQ;;;;mBAAO,OAAO;WAAC;QACf;;;;;WAAwB;QACxB;;;;;WAAuB;QACvB;;;;;WAA+B;QAC/B;;;;;WAAyB;QAQhC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;QACjC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACpC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;IAChC,CAAC;CACF;AAlBD,sCAkBC","sourcesContent":["import type { RTCDataChannel } from \"../dataChannel\";\nimport type {\n MediaStream,\n MediaStreamTrack,\n RTCRtpReceiver,\n RTCRtpTransceiver,\n} from \"../media\";\nimport type { RTCIceCandidate } from \"../transport/ice\";\nimport type { Callback, CallbackWithValue } from \"../types/util\";\n\n// Events RTCPeerConnection dispatches and the `on*` handler attributes.\n\nexport class RTCTrackEvent {\n readonly type = \"track\";\n readonly track: MediaStreamTrack;\n readonly streams: MediaStream[];\n readonly transceiver: RTCRtpTransceiver;\n readonly receiver: RTCRtpReceiver;\n\n constructor(init: {\n track: MediaStreamTrack;\n streams: MediaStream[];\n transceiver: RTCRtpTransceiver;\n receiver: RTCRtpReceiver;\n }) {\n this.track = init.track;\n this.streams = [...init.streams];\n this.transceiver = init.transceiver;\n this.receiver = init.receiver;\n }\n}\n\nexport interface RTCDataChannelEvent {\n type?: \"datachannel\";\n channel: RTCDataChannel;\n}\n\nexport interface RTCPeerConnectionIceEvent {\n type?: \"icecandidate\";\n candidate?: RTCIceCandidate;\n}\n\nexport type PeerConnectionEventHandlers = {\n ondatachannel?: CallbackWithValue<RTCDataChannelEvent>;\n onicecandidate?: CallbackWithValue<RTCPeerConnectionIceEvent>;\n onicecandidateerror?: CallbackWithValue<any>;\n onicegatheringstatechange?: CallbackWithValue<any>;\n onnegotiationneeded?: CallbackWithValue<any>;\n onsignalingstatechange?: CallbackWithValue<any>;\n ontrack?: CallbackWithValue<RTCTrackEvent>;\n onconnectionstatechange?: Callback;\n oniceconnectionstatechange?: Callback;\n};\n"]}
1
+ {"version":3,"file":"peerConnectionEvents.js","sourceRoot":"","sources":["../../../../src/api/peerConnectionEvents.ts"],"names":[],"mappings":";;;AAUA,wEAAwE;AAExE,MAAa,aAAa;IAOxB,YAAY,IAKX;QAXQ;;;;mBAAO,OAAO;WAAC;QACf;;;;;WAAwB;QACxB;;;;;WAAuB;QACvB;;;;;WAA+B;QAC/B;;;;;WAAyB;QAQhC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;QACjC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACpC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;IAChC,CAAC;CACF;AAlBD,sCAkBC;AAeD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,MAAa,8BAA+B,SAAQ,KAAK;IAOvD,YAAY,IAAY,EAAE,IAAwC;QAChE,KAAK,CAAC,IAAI,EAAE;YACV,OAAO,EAAE,IAAI,EAAE,OAAO;YACtB,UAAU,EAAE,IAAI,EAAE,UAAU;YAC5B,QAAQ,EAAE,IAAI,EAAE,QAAQ;SACzB,CAAC,CAAC;QAXI;;;;;WAAuB;QACvB;;;;;WAAoB;QACpB;;;;;WAAY;QACZ;;;;;WAAkB;QAClB;;;;;WAAkB;QAQzB,IAAI,IAAI,IAAI,IAAI,IAAI,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;YACvD,MAAM,IAAI,SAAS,CACjB,uDAAuD,CACxD,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC;QACpC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC;QAC9B,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;IACxC,CAAC;CACF;AAxBD,wEAwBC","sourcesContent":["import type { RTCDataChannel } from \"../dataChannel\";\nimport type {\n MediaStream,\n MediaStreamTrack,\n RTCRtpReceiver,\n RTCRtpTransceiver,\n} from \"../media\";\nimport type { RTCIceCandidate } from \"../transport/ice\";\nimport type { Callback, CallbackWithValue } from \"../types/util\";\n\n// Events RTCPeerConnection dispatches and the `on*` handler attributes.\n\nexport class RTCTrackEvent {\n readonly type = \"track\";\n readonly track: MediaStreamTrack;\n readonly streams: MediaStream[];\n readonly transceiver: RTCRtpTransceiver;\n readonly receiver: RTCRtpReceiver;\n\n constructor(init: {\n track: MediaStreamTrack;\n streams: MediaStream[];\n transceiver: RTCRtpTransceiver;\n receiver: RTCRtpReceiver;\n }) {\n this.track = init.track;\n this.streams = [...init.streams];\n this.transceiver = init.transceiver;\n this.receiver = init.receiver;\n }\n}\n\n/** Members of {@link RTCPeerConnectionIceErrorEvent} (W3C RTCPeerConnectionIceErrorEventInit). */\nexport interface RTCPeerConnectionIceErrorEventInit {\n address?: string | null;\n port?: number | null;\n url?: string;\n errorCode: number;\n errorText?: string;\n /** Standard `EventInit` members. */\n bubbles?: boolean;\n cancelable?: boolean;\n composed?: boolean;\n}\n\n/**\n * `icecandidateerror` (W3C WebRTC §4.8.2): a configured STUN or TURN server\n * could not give a candidate while gathering. Never fired after `close()`.\n *\n * - A server that answered with an error response (300-699): fired at once,\n * once per local socket that asked it.\n * - 701 (server not reached, W3C: no host candidate could reach it): judged\n * once per gathering, when `iceGatheringState` leaves \"gathering\" (just\n * before that `icegatheringstatechange`), and fired once per URL that some\n * ICE transport of the gathering tried without reaching the server while\n * none reached it. Only transports still in use at that point count, with\n * the ICE generation they gathered in: one closed or discarded (rollback)\n * meanwhile, one that did not try the URL, and a generation an ICE restart\n * replaced do not count. The event carries the local address of the first\n * socket that failed (STUN). A new gathering (ICE restart, a new transport)\n * reports the URL again. A handler that closes the connection stops the\n * rest: no further 701 nor `icegatheringstatechange` is fired.\n *\n * While listeners run, `target` and `currentTarget` are the\n * `RTCPeerConnection` and `eventPhase` is 2 (`AT_TARGET`); afterwards\n * `currentTarget` is `null` and `eventPhase` 0. The event reaches\n * `pc.onIceCandidateError`, `onicecandidateerror` and the\n * `icecandidateerror` listeners in that order; `stopImmediatePropagation()`\n * stops the ones after the caller (also later `pc.onIceCandidateError`\n * subscribers), `stopPropagation()` does not (AT_TARGET). A listener\n * removed during the dispatch is not called, one added during it is not\n * called this time. The event is not cancelable (`preventDefault()` does\n * nothing) and, as fired by the connection, `isTrusted` is true. While a 701 is dispatched,\n * `iceGatheringState` still reads `\"gathering\"`.\n *\n * - `url`: the configured URL of the server, canonical: trimmed, lower-case\n * scheme, and `?transport=tcp` added to a `turns:` URL that names no\n * transport (`turns:h:5349` → `turns:h:5349?transport=tcp`, the Chrome /\n * WPT form). Several URLs naming one server each get their own event. The\n * built-in default STUN server (`iceUseDefaultStunServer`, used when no\n * STUN server is configured) is in no configuration; werift reports it\n * with the synthesized URL `stun:stun.l.google.com:19302`.\n * - `errorCode`: the STUN error code the server answered with (300-699),\n * or 701 when it was not reached (DNS, timeout, connect or socket error).\n * A server that answered without a STUN error code (an error response\n * without ERROR-CODE, a response failing MESSAGE-INTEGRITY, a success\n * without XOR-MAPPED-ADDRESS) was reached: it gives no event, and never\n * a 701.\n * - `errorText`: the reason phrase the server returned (W3C), with the\n * credential material werift knows replaced by `***` (the configured TURN\n * username and password, and the USERNAME / REALM / NONCE of the\n * response), control characters dropped and cut to 127 characters; the\n * registered phrase of the code (`\"Unauthorized\"`, `\"STUN error 499\"`)\n * when that is empty; a description of the cause for a 701.\n * - `address` / `port`: the local host address used to contact a STUN\n * server; both `null` when unknown (TURN) or hidden (the `\"relay\"` ICE\n * transport policy), as the W3C spec says (a null address has a null\n * port). Chrome gives `port: 0` instead and the upstream WPT tests\n * expect that; werift's WPT runner maps the `null` to 0, the API keeps\n * the spec value.\n */\nexport class RTCPeerConnectionIceErrorEvent extends Event {\n readonly address: string | null;\n readonly port: number | null;\n readonly url: string;\n readonly errorCode: number;\n readonly errorText: string;\n\n constructor(type: string, init: RTCPeerConnectionIceErrorEventInit) {\n super(type, {\n bubbles: init?.bubbles,\n cancelable: init?.cancelable,\n composed: init?.composed,\n });\n if (init == null || typeof init.errorCode !== \"number\") {\n throw new TypeError(\n \"RTCPeerConnectionIceErrorEvent: errorCode is required\",\n );\n }\n this.address = init.address ?? null;\n this.port = init.port ?? null;\n this.url = init.url ?? \"\";\n this.errorCode = init.errorCode;\n this.errorText = init.errorText ?? \"\";\n }\n}\n\nexport interface RTCDataChannelEvent {\n type?: \"datachannel\";\n channel: RTCDataChannel;\n}\n\nexport interface RTCPeerConnectionIceEvent {\n type?: \"icecandidate\";\n candidate?: RTCIceCandidate;\n}\n\nexport type PeerConnectionEventHandlers = {\n ondatachannel?: CallbackWithValue<RTCDataChannelEvent>;\n onicecandidate?: CallbackWithValue<RTCPeerConnectionIceEvent>;\n onicecandidateerror?: CallbackWithValue<RTCPeerConnectionIceErrorEvent>;\n onicegatheringstatechange?: CallbackWithValue<any>;\n onnegotiationneeded?: CallbackWithValue<any>;\n onsignalingstatechange?: CallbackWithValue<any>;\n ontrack?: CallbackWithValue<RTCTrackEvent>;\n onconnectionstatechange?: Callback;\n oniceconnectionstatechange?: Callback;\n};\n"]}
@@ -1,4 +1,10 @@
1
1
  import { EventEmitter } from "node:events";
2
+ /**
3
+ * Run one notification to listeners (an `Event.execute`, an `on*` handler or
4
+ * an `emit`) so that an exception a listener throws is logged and never
5
+ * interrupts the caller's own processing (state propagation, cleanup).
6
+ */
7
+ export declare function notifySafely(log: (...args: unknown[]) => void, name: string, notify: () => void): void;
2
8
  export declare function enumerate<T>(arr: T[]): [number, T][];
3
9
  export declare function divide(from: string, split: string): [string, string];
4
10
  export declare class PromiseQueue {
@@ -12,6 +18,8 @@ export declare class PromiseQueue {
12
18
  }
13
19
  export declare class EventTarget extends EventEmitter {
14
20
  emit(type: string | symbol, ...args: any[]): boolean;
21
+ /** The DOM-like event arguments: an Event with `type` as the first one. */
22
+ private eventArgs;
15
23
  addEventListener: (type: string, listener: (...args: any[]) => void, options?: boolean | {
16
24
  once?: boolean;
17
25
  }) => void;