Firebase Auth in a Chrome Plugin Manifest V3?

178 Views Asked by At

If I import firebase auth in background.js, it doesn't have access to the window object.

And if I import it in my App.js (React file), the chrome plugin does not allow me to call external scripts, because of content security policy.

The problem is not just importing the firebase via npm, that's fine, but the firebase auth calls on external apis from the App.js file.

enter image description here

And I would very much appreciate if you do not suggest me something like this in my Manifest v3.

"content_security_policy": {
  "extension_pages": "script-src 'self' 'wasm-unsafe-eval' 'inline-speculation-rules' https://apis.google.com; object-src 'self';"
}

Because obviously Chrome extensions can no longer have urls like that in their manifest.

P.S: I can already authenticate a user via chrome.identity but that doesn't help me authenticate the user on firebase (or at least I don't know how).

1

There are 1 best solutions below

1
On

For avoiding external calls update to "firebase": "^10.8.0" and import from 'firebase/auth/web-extension'

import { signInWithCredential, signInWithEmailAndPassword, GoogleAuthProvider, } from 'firebase/auth/web-extension';