vuejs / vuefire

🔥 Firebase bindings for Vue.js
https://vuefire.vuejs.org
MIT License
3.82k stars 323 forks source link

Nuxt 3 - Error getting AppCheck token from the server: App attestation failed. #1433

Closed daviddomkar closed 9 months ago

daviddomkar commented 9 months ago

Reproduction

https://github.com/DavidDomkar/firebase-appcheck-windows-error-reproduction

Steps to reproduce the bug

  1. Clone the provided reproduction repo.
  2. Setup .env file based on the .env.example
  3. Run the project using yarn dev on windows machine
  4. Error is logged to the console when the page is loaded in the browser for the first time

Expected behavior

I would expect no errors in the console when using useCollection or useDocument on the server during SSR and app check enabled.

Actual behavior

When doing useCollection or useDocument in setup function of the vue page/layout/component or app.vue with SSR enabled with app check on windows, server logs the following error to the console:

[vuefire]  ERROR  Error getting AppCheck token from the server: App attestation failed.

  at AppCheckApiClient.toFirebaseError (node_modules\firebase-admin\lib\app-check\app-check-api-client-internal.js:150:16)
  at node_modules\firebase-admin\lib\app-check\app-check-api-client-internal.js:72:24
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at CustomProvider.getToken (node_modules\@firebase\app-check\src\providers.ts:240:25)
  at getToken$2 (node_modules\@firebase\app-check\src\internal-api.ts:156:13)
  at async Promise.all (index 1)

[2023-09-21T20:17:24.365Z]  @firebase/app-check: FirebaseAppCheckError: App attestation failed.
    at AppCheckApiClient.toFirebaseError (C:\Users\David\Projects\firebase-appcheck-windows-error-reproduction\node_modules\firebase-admin\lib\app-check\app-check-api-client-internal.js:150:16)      
    at C:\Users\David\Projects\firebase-appcheck-windows-error-reproduction\node_modules\firebase-admin\lib\app-check\app-check-api-client-internal.js:72:24
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at CustomProvider.getToken (C:\Users\David\Projects\firebase-appcheck-windows-error-reproduction\node_modules\@firebase\app-check\src\providers.ts:240:25)
    at getToken$2 (C:\Users\David\Projects\firebase-appcheck-windows-error-reproduction\node_modules\@firebase\app-check\src\internal-api.ts:156:13)
    at async Promise.all (index 1) {
  errorInfo: {
    code: 'app-check/permission-denied',
    message: 'App attestation failed.'
  },
  codePrefix: 'app-check'
}

[vuefire]  ERROR  Error getting AppCheck token from the server: App attestation failed.

  at AppCheckApiClient.toFirebaseError (node_modules\firebase-admin\lib\app-check\app-check-api-client-internal.js:150:16)
  at node_modules\firebase-admin\lib\app-check\app-check-api-client-internal.js:72:24
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at CustomProvider.getToken (node_modules\@firebase\app-check\src\providers.ts:240:25)
  at getToken$2 (node_modules\@firebase\app-check\src\internal-api.ts:156:13)
  at async Promise.all (index 1)

[2023-09-21T20:17:24.560Z]  @firebase/app-check: FirebaseAppCheckError: App attestation failed.
    at AppCheckApiClient.toFirebaseError (C:\Users\David\Projects\firebase-appcheck-windows-error-reproduction\node_modules\firebase-admin\lib\app-check\app-check-api-client-internal.js:150:16)      
    at C:\Users\David\Projects\firebase-appcheck-windows-error-reproduction\node_modules\firebase-admin\lib\app-check\app-check-api-client-internal.js:72:24
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at CustomProvider.getToken (C:\Users\David\Projects\firebase-appcheck-windows-error-reproduction\node_modules\@firebase\app-check\src\providers.ts:240:25)
    at getToken$2 (C:\Users\David\Projects\firebase-appcheck-windows-error-reproduction\node_modules\@firebase\app-check\src\internal-api.ts:156:13)
    at async Promise.all (index 1) {
  errorInfo: {
    code: 'app-check/permission-denied',
    message: 'App attestation failed.'
  },
  codePrefix: 'app-check'
}

Additional information

I tested this on two windows machines, where this problem occurred. However, when I tested on macos, no errors were present.

I also tried setting up appcheck with ReCaptchaV3 and ReCaptchaEnterprise, but both have the same issue.

I tried changing node versions and downgrading dependencies, but nothing worked. (my environment is node 18.17.1)

posva commented 9 months ago

I can't reproduce it...

I hope following these two examples help you out:

It would be surprising if this is windows only, but if it is, this should be reported to the Firebase team. It could be a bug in the firebase/app-check implementation

daviddomkar commented 9 months ago

I can't reproduce it...

I hope following these two examples help you out:

It would be surprising if this is windows only, but if it is, this should be reported to the Firebase team. It could be a bug in the firebase/app-check implementation

I appreciate your time trying to reproduce and for the links. After some more digging into this, I isolated the issue to the createToken function of the Firebase Admin SDK AppCheck client. I reported my findings in the issue in Firebase Admin SDK repository: https://github.com/firebase/firebase-admin-node/issues/2308