Skip to content

Commit

Permalink
fix(browser) detect WebRTC APIs and mark browser unsupported if not
Browse files Browse the repository at this point in the history
Some so called "security" browser extensions override WebRTC APIs so
even if the UA string suggests the browser is supported, it won't work.

Coincidentally, this should also mark Safari in Lockdown Mode as
unsupported, since the WebRTC APIs are not available in that case.
  • Loading branch information
saghul committed Dec 10, 2024
1 parent 39c4422 commit 10cf346
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 6 additions & 0 deletions modules/browser/BrowserCapabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ export default class BrowserCapabilities extends BrowserDetection {
* @returns {boolean} true if the browser is supported, false otherwise.
*/
isSupported() {
// First check for WebRTC APIs because some "security" extensions are dumb.
if (typeof RTCPeerConnection === 'undefined'
|| !navigator?.mediaDevices?.enumerateDevices || !navigator?.mediaDevices?.getUserMedia) {
return false;
}

if (this.isSafari() && this._getSafariVersion() < MIN_REQUIRED_SAFARI_VERSION) {
return false;
}
Expand Down
3 changes: 0 additions & 3 deletions modules/browser/index.js

This file was deleted.

0 comments on commit 10cf346

Please sign in to comment.