Skip to content

Commit

Permalink
Firestore cache appCheckToken instead of full app.
Browse files Browse the repository at this point in the history
  • Loading branch information
DellaBitta committed Dec 16, 2024
1 parent 7c8ec93 commit de89ecd
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/firestore/src/api/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AppCheckInternalComponentName>
) {}
) {
if (_isFirebaseServerApp(app) && app.settings.appCheckToken) {
this.serverAppAppCheckToken = app.settings.appCheckToken;
}
}

start(
asyncQueue: AsyncQueue,
Expand Down Expand Up @@ -564,10 +569,8 @@ export class FirebaseAppCheckTokenProvider
}

getToken(): Promise<Token | null> {
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,
Expand Down

0 comments on commit de89ecd

Please sign in to comment.