Skip to content

Commit 037041f

Browse files
committed
Fixes or PR feedback.
1 parent b3a1c4f commit 037041f

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

packages/data-connect/src/core/AppCheckTokenProvider.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class AppCheckTokenProvider {
4747
}
4848
}
4949

50-
getToken(forceRefresh?: boolean): Promise<AppCheckTokenResult> {
50+
getToken(): Promise<AppCheckTokenResult> {
5151
if (this.serverAppAppCheckToken) {
5252
return Promise.resolve({ token: this.serverAppAppCheckToken });
5353
}
@@ -60,14 +60,14 @@ export class AppCheckTokenProvider {
6060
// becomes available before the timoeout below expires.
6161
setTimeout(() => {
6262
if (this.appCheck) {
63-
this.getToken(forceRefresh).then(resolve, reject);
63+
this.getToken().then(resolve, reject);
6464
} else {
6565
resolve(null);
6666
}
6767
}, 0);
6868
});
6969
}
70-
return this.appCheck.getToken(forceRefresh);
70+
return this.appCheck.getToken();
7171
}
7272

7373
addTokenChangeListener(listener: AppCheckTokenListener): void {

packages/database/src/core/AppCheckTokenProvider.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ export class AppCheckTokenProvider {
4949

5050
getToken(forceRefresh?: boolean): Promise<AppCheckTokenResult> {
5151
if (this.serverAppAppCheckToken) {
52+
if (forceRefresh) {
53+
return new Promise<AppCheckTokenResult>(resolve => {
54+
const appCheckTokenResult = {
55+
token: 'ERROR',
56+
error: new Error(
57+
'Attempted reuse of FirebaseServerApp.appCheckToken after previous usage failed.'
58+
)
59+
};
60+
resolve(appCheckTokenResult);
61+
});
62+
}
5263
return Promise.resolve({ token: this.serverAppAppCheckToken });
5364
}
5465
if (!this.appCheck) {

packages/functions/src/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class ContextProvider {
8282
}
8383

8484
if (!this.appCheck) {
85-
appCheckProvider.get().then(
85+
appCheckProvider?.get().then(
8686
appCheck => (this.appCheck = appCheck),
8787
() => {
8888
/* get() never rejects */

packages/vertexai/src/models/generative-model.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ export class GenerativeModel {
8585
};
8686

8787
if (
88-
vertexAI.app &&
8988
_isFirebaseServerApp(vertexAI.app) &&
9089
vertexAI.app.settings.appCheckToken
9190
) {

0 commit comments

Comments
 (0)