Skip to content

Commit b4d7701

Browse files
authored
fix(feedback): Only allow screenshots in secure contexts (#11188)
We use [getDisplayMedia](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia) to take screenshots, which only works in secure contexts, so disable screenshot when not a secure context.
1 parent 8787900 commit b4d7701

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/feedback/src/util/isScreenshotSupported.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,17 @@ import { NAVIGATOR } from '../constants';
88
*
99
* https://stackoverflow.com/a/58879212
1010
* https://stackoverflow.com/a/3540295
11+
*
12+
* `mediaDevices.getDisplayMedia` is also only supported in secure contexts, and return a `mediaDevices is not supported` error, so we should also avoid loading the integration if we can.
13+
*
14+
* https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia
1115
*/
1216
export function isScreenshotSupported(): boolean {
1317
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(NAVIGATOR.userAgent)) {
1418
return false;
1519
}
20+
if (!isSecureContext) {
21+
return false;
22+
}
1623
return true;
1724
}

0 commit comments

Comments
 (0)