@@ -41,8 +41,7 @@ export type AuthTokenFactory = () => string;
41
41
42
42
export interface FirstPartyCredentialsSettings {
43
43
// These are external types. Prevent minification.
44
- [ 'type' ] : 'gapi' ;
45
- [ 'client' ] : unknown ;
44
+ [ 'type' ] : 'firstParty' ;
46
45
[ 'sessionIndex' ] : string ;
47
46
[ 'iamToken' ] : string | null ;
48
47
[ 'authTokenFactory' ] : AuthTokenFactory | null ;
@@ -379,15 +378,6 @@ export class FirebaseAuthCredentialsProvider
379
378
}
380
379
}
381
380
382
- // Manual type definition for the subset of Gapi we use.
383
- interface Gapi {
384
- auth : {
385
- getAuthHeaderValueForFirstParty : (
386
- userIdentifiers : Array < { [ key : string ] : string } >
387
- ) => string | null ;
388
- } ;
389
- }
390
-
391
381
/*
392
382
* FirstPartyToken provides a fresh token each time its value
393
383
* is requested, because if the token is too old, requests will be rejected.
@@ -401,28 +391,20 @@ export class FirstPartyToken implements Token {
401
391
private _headers = new Map ( ) ;
402
392
403
393
constructor (
404
- private readonly gapi : Gapi | null ,
405
394
private readonly sessionIndex : string ,
406
395
private readonly iamToken : string | null ,
407
396
private readonly authTokenFactory : AuthTokenFactory | null
408
397
) { }
409
398
410
- /** Gets an authorization token, using a provided factory function, or falling back to First Party GAPI. */
399
+ /**
400
+ * Gets an authorization token, using a provided factory function, or return
401
+ * null.
402
+ */
411
403
private getAuthToken ( ) : string | null {
412
404
if ( this . authTokenFactory ) {
413
405
return this . authTokenFactory ( ) ;
414
406
} else {
415
- // Make sure this really is a Gapi client.
416
- hardAssert (
417
- ! ! (
418
- typeof this . gapi === 'object' &&
419
- this . gapi !== null &&
420
- this . gapi [ 'auth' ] &&
421
- this . gapi [ 'auth' ] [ 'getAuthHeaderValueForFirstParty' ]
422
- ) ,
423
- 'unexpected gapi interface'
424
- ) ;
425
- return this . gapi ! [ 'auth' ] [ 'getAuthHeaderValueForFirstParty' ] ( [ ] ) ;
407
+ return null ;
426
408
}
427
409
}
428
410
@@ -450,7 +432,6 @@ export class FirstPartyAuthCredentialsProvider
450
432
implements CredentialsProvider < User >
451
433
{
452
434
constructor (
453
- private gapi : Gapi | null ,
454
435
private sessionIndex : string ,
455
436
private iamToken : string | null ,
456
437
private authTokenFactory : AuthTokenFactory | null
@@ -459,7 +440,6 @@ export class FirstPartyAuthCredentialsProvider
459
440
getToken ( ) : Promise < Token | null > {
460
441
return Promise . resolve (
461
442
new FirstPartyToken (
462
- this . gapi ,
463
443
this . sessionIndex ,
464
444
this . iamToken ,
465
445
this . authTokenFactory
@@ -668,12 +648,9 @@ export function makeAuthCredentialsProvider(
668
648
if ( ! credentials ) {
669
649
return new EmptyAuthCredentialsProvider ( ) ;
670
650
}
671
-
672
651
switch ( credentials [ 'type' ] ) {
673
- case 'gapi' :
674
- const client = credentials [ 'client' ] as Gapi ;
652
+ case 'firstParty' :
675
653
return new FirstPartyAuthCredentialsProvider (
676
- client ,
677
654
credentials [ 'sessionIndex' ] || '0' ,
678
655
credentials [ 'iamToken' ] || null ,
679
656
credentials [ 'authTokenFactory' ] || null
0 commit comments