@@ -68,16 +68,16 @@ export interface Token {
68
68
*/
69
69
user ?: User ;
70
70
71
- /** Invokes the given callback with the token's key and value. */
72
- applyHeaders ( callback : ( tokenKey : string , tokenValue : string ) => void ) : void ;
71
+ /** Header values to set for this token */
72
+ headers : Map < string , string > ;
73
73
}
74
74
75
75
export class OAuthToken implements Token {
76
76
type = 'OAuth' as TokenType ;
77
- constructor ( private value : string , public user : User ) { }
77
+ headers = new Map ( ) ;
78
78
79
- applyHeaders ( callback : ( tokenKey : string , tokenValue : string ) => void ) : void {
80
- callback ( 'Authorization' , `Bearer ${ this . value } ` ) ;
79
+ constructor ( value : string , public user : User ) {
80
+ this . headers . set ( 'Authorization' , `Bearer ${ value } ` ) ;
81
81
}
82
82
}
83
83
@@ -395,21 +395,16 @@ interface Gapi {
395
395
export class FirstPartyToken implements Token {
396
396
type = 'FirstParty' as TokenType ;
397
397
user = User . FIRST_PARTY ;
398
+ headers = new Map ( ) ;
398
399
399
- constructor (
400
- private gapi : Gapi ,
401
- private sessionIndex : string ,
402
- private iamToken : string | null
403
- ) { }
404
-
405
- applyHeaders ( callback : ( tokenKey : string , tokenValue : string ) => void ) : void {
406
- callback ( 'X-Goog-AuthUser' , this . sessionIndex ) ;
407
- const authHeader = this . gapi [ 'auth' ] [ 'getAuthHeaderValueForFirstParty' ] ( [ ] ) ;
400
+ constructor ( gapi : Gapi , sessionIndex : string , iamToken : string | null ) {
401
+ this . headers . set ( 'X-Goog-AuthUser' , sessionIndex ) ;
402
+ const authHeader = gapi [ 'auth' ] [ 'getAuthHeaderValueForFirstParty' ] ( [ ] ) ;
408
403
if ( authHeader ) {
409
- callback ( 'Authorization' , authHeader ) ;
404
+ this . headers . set ( 'Authorization' , authHeader ) ;
410
405
}
411
- if ( this . iamToken ) {
412
- callback ( 'X-Goog-Iam-Authorization-Token' , this . iamToken ) ;
406
+ if ( iamToken ) {
407
+ this . headers . set ( 'X-Goog-Iam-Authorization-Token' , iamToken ) ;
413
408
}
414
409
}
415
410
}
@@ -449,11 +444,11 @@ export class FirstPartyAuthCredentialsProvider
449
444
450
445
export class AppCheckToken implements Token {
451
446
type = 'AppCheck' as TokenType ;
452
- constructor ( private value : string ) { }
447
+ headers = new Map ( ) ;
453
448
454
- applyHeaders ( callback : ( tokenKey : string , tokenValue : string ) => void ) : void {
455
- if ( this . value && this . value . length > 0 ) {
456
- callback ( 'x-firebase-appcheck' , this . value ) ;
449
+ constructor ( private value : string ) {
450
+ if ( value && value . length > 0 ) {
451
+ this . headers . set ( 'x-firebase-appcheck' , this . value ) ;
457
452
}
458
453
}
459
454
}
0 commit comments