File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { getBrowserName } from './Environment'
2+
3+ // Check host permissions before allowing the user to sign in with a provider.
4+ // as Firefox may block the Signin on v3 if the extension does not have host permissions.
5+ export const checkHostPermissions = async ( ) => {
6+ if ( getBrowserName ( ) !== 'firefox' ) {
7+ return true
8+ }
9+
10+ const HOST_PERMISSIONS = chrome . runtime . getManifest ( ) . content_scripts || [ ]
11+ const requiredHosts = HOST_PERMISSIONS . flatMap ( ( permission ) => {
12+ return permission . matches || [ ]
13+ } )
14+
15+ return await chrome . permissions . contains ( { origins : requiredHosts } )
16+ }
17+
18+ export const requestHostPermissions = async ( ) => {
19+ if ( getBrowserName ( ) !== 'firefox' ) {
20+ return true
21+ }
22+ const HOST_PERMISSIONS = chrome . runtime . getManifest ( ) . content_scripts || [ ]
23+ const requiredHosts = HOST_PERMISSIONS . flatMap ( ( permission ) => {
24+ return permission . matches || [ ]
25+ } )
26+
27+ return await chrome . permissions . request ( { origins : requiredHosts } )
28+ }
You can’t perform that action at this time.
0 commit comments