Skip to content

mansisampat/firebase-extension-demo

 
 

Repository files navigation

Firebase Auth in Web Extensions

Firebase auth offers a number of different methods for authenticating users. While they do have a JavaScript SDK, it has a number of coding practices that are not allowed by policy in the Chrome Web Store. As a result, using them may result in an extension being rejected. This repo is a collection of example extensions that show how to package and occasionally modify the SDK in order to comply with CWS policies and fully function inside of the service worker used in Manifest v3.

To build yourself, you will need to create the file firebaseConfig.js at the root of this repo. This should be an exported JSON config file you can find in your project settings.

export default {
  apiKey: "xxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxx",
  authDomain: "xxxxxxxxxxxxxx.firebaseapp.com",
  projectId: "projectId",
  storageBucket: "projectId.appspot.com",
  messagingSenderId: "000000000000",
  appId: "x:xxxxxxxxxxxx:xxx:xxxxxxxxxxxxxxxxxxxxxx",
  measurementId: "x-xxxxxxxxxx"
};;

Once you have created firebaseConfig.js, select the API you want to build from one of the directories. It would be a good idea to read the README of any project you wish to build, in case there is configuraiton you need to do in order to proceed.

Building

The compiled version of each API is generated using rollup. While rollup itself isn't a strict requirement if you are looking to use Firebase Auth in your own extension, some kind of treeshaking build processs is. This will remove unused code from the build, and make sure the generated file does not include code that would get your extension rejected.

All of the extensions can be built using the npm scripts in the project's package.json.o

npm run compile:signInAnonymously
npm run compile:signInWithCustomToken
npm run compile:signInWithEmailAndPassword
npm run compile:signInWithEmailLink
npm run compile:signInWithPhoneNumber
npm run compile:signInWithPopup
npm run compile:signInWithRedirect

Specific installation and usage instructions can be found on each directorys individual README.

License

All code is authored by Google and licensed under the Apache License, Version 2.0.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 96.6%
  • HTML 3.4%