@zero-server/webrtc 0.9.8 → 0.9.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/webrtc/signaling.js +32 -3
- package/package.json +7 -7
package/lib/webrtc/signaling.js
CHANGED
|
@@ -83,6 +83,11 @@ function _countCandidatesInSdp(sdp)
|
|
|
83
83
|
* Validate that an SDP has the required RFC 8829 attributes on every media
|
|
84
84
|
* section and uses DTLS-SRTP transport. Returns an error code string, or
|
|
85
85
|
* `null` if the SDP is acceptable.
|
|
86
|
+
*
|
|
87
|
+
* Accepts both RTP/SAVPF audio/video sections (RFC 8829) and SCTP data-channel
|
|
88
|
+
* sections (RFC 8841 m=application ... UDP/DTLS/SCTP). When BUNDLE is in use
|
|
89
|
+
* (every browser since ~2018), only the first m-section is required to carry
|
|
90
|
+
* iceUfrag/icePwd; other bundled sections inherit them via a=group:BUNDLE.
|
|
86
91
|
*/
|
|
87
92
|
function _validateSdpStructure(sdp)
|
|
88
93
|
{
|
|
@@ -94,12 +99,36 @@ function _validateSdpStructure(sdp)
|
|
|
94
99
|
return 'INVALID_SDP';
|
|
95
100
|
}
|
|
96
101
|
if (!desc.media || desc.media.length === 0) return 'INVALID_SDP';
|
|
102
|
+
|
|
103
|
+
// BUNDLE: collect bundled mids so per-section ice credentials are optional
|
|
104
|
+
// on every section except the first (the BUNDLE owner).
|
|
105
|
+
const bundleMids = new Set();
|
|
106
|
+
for (const a of desc.attributes || [])
|
|
107
|
+
{
|
|
108
|
+
if (a.key !== 'group') continue;
|
|
109
|
+
const parts = String(a.value || '').split(/\s+/);
|
|
110
|
+
if (parts[0] !== 'BUNDLE') continue;
|
|
111
|
+
for (let i = 1; i < parts.length; i++) bundleMids.add(parts[i]);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
let firstBundleMid = null;
|
|
97
115
|
for (const m of desc.media)
|
|
98
116
|
{
|
|
99
|
-
if (typeof m.proto !== 'string'
|
|
100
|
-
|
|
101
|
-
|
|
117
|
+
if (typeof m.proto !== 'string') return 'INVALID_SDP';
|
|
118
|
+
|
|
119
|
+
// RTP audio/video (RFC 8829) OR SCTP data channels (RFC 8841).
|
|
120
|
+
const isRtp = /^UDP\/TLS\/RTP\/SAVPF?$/i.test(m.proto);
|
|
121
|
+
const isSctp = /^(UDP|TCP)\/DTLS\/SCTP$/i.test(m.proto);
|
|
122
|
+
if (!isRtp && !isSctp) return 'INVALID_SDP';
|
|
123
|
+
|
|
102
124
|
if (!m.fingerprint) return 'INVALID_SDP';
|
|
125
|
+
|
|
126
|
+
// ice-ufrag / ice-pwd: required on the BUNDLE owner; optional on
|
|
127
|
+
// every other bundled section (inherited per RFC 8843 §9.2).
|
|
128
|
+
const bundled = m.mid && bundleMids.has(m.mid);
|
|
129
|
+
if (bundled && firstBundleMid === null) firstBundleMid = m.mid;
|
|
130
|
+
const isBundleOwner = !bundled || m.mid === firstBundleMid;
|
|
131
|
+
if (isBundleOwner && (!m.iceUfrag || !m.icePwd)) return 'INVALID_SDP';
|
|
103
132
|
}
|
|
104
133
|
return null;
|
|
105
134
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zero-server/webrtc",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.9",
|
|
4
4
|
"description": "WebRTC signaling hub, TURN credentials, STUN client, SFU adapter interface.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"zero-server",
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
},
|
|
46
46
|
"sideEffects": false,
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@zero-server/realtime": "0.9.
|
|
49
|
-
"@zero-server/auth": "0.9.
|
|
50
|
-
"@zero-server/observe": "0.9.
|
|
51
|
-
"@zero-server/errors": "0.9.
|
|
52
|
-
"@zero-server/middleware": "0.9.
|
|
48
|
+
"@zero-server/realtime": "0.9.9",
|
|
49
|
+
"@zero-server/auth": "0.9.9",
|
|
50
|
+
"@zero-server/observe": "0.9.9",
|
|
51
|
+
"@zero-server/errors": "0.9.9",
|
|
52
|
+
"@zero-server/middleware": "0.9.9"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@zero-server/sdk": ">=0.9.
|
|
55
|
+
"@zero-server/sdk": ">=0.9.9"
|
|
56
56
|
},
|
|
57
57
|
"peerDependenciesMeta": {
|
|
58
58
|
"@zero-server/sdk": {
|