From de89ecd29e35510f05f0f1bcb77f194d574586b4 Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Mon, 16 Dec 2024 11:02:27 -0500 Subject: [PATCH] Firestore cache appCheckToken instead of full app. --- packages/firestore/src/api/credentials.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/firestore/src/api/credentials.ts b/packages/firestore/src/api/credentials.ts index cbd02444282..ecaa982dcc8 100644 --- a/packages/firestore/src/api/credentials.ts +++ b/packages/firestore/src/api/credentials.ts @@ -496,11 +496,16 @@ export class FirebaseAppCheckTokenProvider private forceRefresh = false; private appCheck: FirebaseAppCheckInternal | null = null; private latestAppCheckToken: string | null = null; + private serverAppAppCheckToken: string | null = null; constructor( - private app: FirebaseApp, + app: FirebaseApp, private appCheckProvider: Provider - ) {} + ) { + if (_isFirebaseServerApp(app) && app.settings.appCheckToken) { + this.serverAppAppCheckToken = app.settings.appCheckToken; + } + } start( asyncQueue: AsyncQueue, @@ -564,10 +569,8 @@ export class FirebaseAppCheckTokenProvider } getToken(): Promise { - if (_isFirebaseServerApp(this.app) && this.app.settings.appCheckToken) { - return Promise.resolve( - new AppCheckToken(this.app.settings.appCheckToken) - ); + if (this.serverAppAppCheckToken !== null) { + return Promise.resolve(new AppCheckToken(this.serverAppAppCheckToken)); } debugAssert( this.tokenListener != null,