File tree Expand file tree Collapse file tree 2 files changed +42
-2
lines changed Expand file tree Collapse file tree 2 files changed +42
-2
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ import { Component, ComponentType } from '@firebase/component';
24
24
25
25
import { version } from '../package.json' ;
26
26
import {
27
- FirebaseAppCheckTokenProvider ,
27
+ LiteAppCheckTokenProvider ,
28
28
LiteCredentialsProvider
29
29
} from '../src/api/credentials' ;
30
30
import { setSDKVersion } from '../src/core/version' ;
@@ -47,7 +47,7 @@ export function registerFirestore(): void {
47
47
const firestoreInstance = new Firestore (
48
48
app ,
49
49
new LiteCredentialsProvider ( container . getProvider ( 'auth-internal' ) ) ,
50
- new FirebaseAppCheckTokenProvider (
50
+ new LiteAppCheckTokenProvider (
51
51
container . getProvider ( 'app-check-internal' )
52
52
)
53
53
) ;
Original file line number Diff line number Diff line change @@ -579,6 +579,46 @@ export class EmptyAppCheckTokenProvider implements CredentialsProvider<string> {
579
579
shutdown ( ) : void { }
580
580
}
581
581
582
+ /** AppCheck token provider for the Lite SDK. */
583
+ export class LiteAppCheckTokenProvider implements CredentialsProvider < String > {
584
+ private appCheck : FirebaseAppCheckInternal | null = null ;
585
+
586
+ constructor (
587
+ private appCheckProvider : Provider < AppCheckInternalComponentName >
588
+ ) {
589
+ appCheckProvider . onInit ( appCheck => {
590
+ this . appCheck = appCheck ;
591
+ } ) ;
592
+ }
593
+
594
+ getToken ( ) : Promise < Token | null > {
595
+ if ( ! this . appCheck ) {
596
+ return Promise . resolve ( null ) ;
597
+ }
598
+
599
+ return this . appCheck . getToken ( ) . then ( tokenResult => {
600
+ if ( tokenResult ) {
601
+ hardAssert (
602
+ typeof tokenResult . token === 'string' ,
603
+ 'Invalid tokenResult returned from getToken():' + tokenResult
604
+ ) ;
605
+ return new AppCheckToken ( tokenResult . token ) ;
606
+ } else {
607
+ return null ;
608
+ }
609
+ } ) ;
610
+ }
611
+
612
+ invalidateToken ( ) : void { }
613
+
614
+ start (
615
+ asyncQueue : AsyncQueue ,
616
+ changeListener : CredentialChangeListener < string >
617
+ ) : void { }
618
+
619
+ shutdown ( ) : void { }
620
+ }
621
+
582
622
/**
583
623
* Builds a CredentialsProvider depending on the type of
584
624
* the credentials passed in.
You can’t perform that action at this time.
0 commit comments