-
Notifications
You must be signed in to change notification settings - Fork 937
Add App Check token to FirebaseServerApp #8651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
25f264f
b971b89
7c8ec93
de89ecd
e632eeb
1e511b5
ad17dab
33e4889
02708d3
c1a1322
34372c4
a5075a2
a218674
e6b6625
9da69bc
9a1299b
b3a1c4f
037041f
d6e1917
4fc151f
302e1dc
61ec38d
0526b87
c444e66
3352b7f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -196,6 +196,12 @@ export interface FirebaseServerAppSettings | |
*/ | ||
authIdToken?: string; | ||
|
||
/** | ||
* An optional App Check token. If provided, the Firebase SDKs that use App Check will utilizze | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo "utilize." Personally I like in lieu, but I'll bet good money our style guide advises something more like "instead of" or "in place of." There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed! I went with "in place of". |
||
* this App Check token in lieu of requiring an instance of App Check to be initialized. | ||
*/ | ||
appCheckToken?: string; | ||
|
||
/** | ||
* An optional object. If provided, the Firebase SDK uses a `FinalizationRegistry` | ||
* object to monitor the garbage collection status of the provided object. The | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
import { FirebaseApp, _isFirebaseServerApp } from '@firebase/app'; | ||
import { | ||
AppCheckInternalComponentName, | ||
AppCheckTokenListener, | ||
|
@@ -29,10 +30,14 @@ import { Provider } from '@firebase/component'; | |
*/ | ||
export class AppCheckTokenProvider { | ||
private appCheck?: FirebaseAppCheckInternal; | ||
private serverAppAppCheckToken?: string; | ||
constructor( | ||
private appName_: string, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This value was never used. |
||
app: FirebaseApp, | ||
private appCheckProvider?: Provider<AppCheckInternalComponentName> | ||
) { | ||
if (_isFirebaseServerApp(app) && app.settings.appCheckToken) { | ||
this.serverAppAppCheckToken = app.settings.appCheckToken; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. During the initialization of the Data Connect-specific |
||
this.appCheck = appCheckProvider?.getImmediate({ optional: true }); | ||
if (!this.appCheck) { | ||
void appCheckProvider | ||
|
@@ -43,6 +48,10 @@ export class AppCheckTokenProvider { | |
} | ||
|
||
getToken(forceRefresh?: boolean): Promise<AppCheckTokenResult> { | ||
if (this.serverAppAppCheckToken) { | ||
return Promise.resolve({ token: this.serverAppAppCheckToken }); | ||
} | ||
|
||
if (!this.appCheck) { | ||
return new Promise<AppCheckTokenResult>((resolve, reject) => { | ||
// Support delayed initialization of FirebaseAppCheck. This allows our | ||
|
Uh oh!
There was an error while loading. Please reload this page.