nuxt-community / firebase-module

🔥 Easily integrate Firebase into your Nuxt project. 🔥
https://firebase.nuxtjs.org
MIT License
640 stars 99 forks source link

feat: add support for App Check #607

Closed eljass closed 2 years ago

eljass commented 2 years ago

Support for App Check

Adds support for Firebase App Check.

Note: This will currently work only on the client side.

Initialize:

Enable App Check inside nuxt.config.js:

firebase: {
  ...
  services: {
    ...,
    appCheck: true
  }
}

Options:

{
  // Fill debug token to be used.
  // See more https://firebase.google.com/docs/app-check/web/debug-provider
  debugToken: false // default
}

Usage

When initialized there is possibility to activate App Check by calling

// App check works currently only on client side.
if (process.client) {
  this.$fire.appCheck.activate('RECAPTCHA V3 SITE KEY')`
}

Relates to

https://github.com/nuxt-community/firebase-module/issues/534

lupas commented 2 years ago

Hey @eljass

Thanks a lot, that looks great and seems to work! Appreciate it 👍

I merged it to master already, but just saw that for some reason the Firestore implementation breaks in the demo when AppCheck is enabled. Without Firestore, AppCheck works, and without AppCheck, Firestore works.

Haven't used AppCheck much, any clue what that could be? See the demo in this branch: https://github.com/nuxt-community/firebase-module/tree/newStructure/packages/demo

Screenshot 2022-01-10 at 22 45 12
eljass commented 2 years ago

@lupas Happy to help!

I'm not sure why this happened, I did not actually test this with other features. Now I used the demo branch to test this through and found out that the App check was too high on the template-utils.js, I moved it to the last item on the list and now everything seems to work as expected.

Also, I did add lazy loading functionality on the app check. I made a PR from these changes (https://github.com/nuxt-community/firebase-module/pull/608)

lupas commented 2 years ago

Awesome stuff, thanks a lot @eljass !

I merged it, combined it with my restructuring of the repository and released it as 8.2.0.

Docs are currently broken, will try to fix them at some point soon.

Thanks a lot for the support! Pascal