From 3dab2f369dacd72db0ceed6aad5dde1726bb29ef Mon Sep 17 00:00:00 2001 From: milaGGL <107142260+milaGGL@users.noreply.github.com> Date: Tue, 7 Mar 2023 18:05:31 -0800 Subject: [PATCH 1/4] remove gapi.auth fall back option for getAuthToken() --- packages/firestore/src/api/credentials.ts | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/packages/firestore/src/api/credentials.ts b/packages/firestore/src/api/credentials.ts index 7ee1ca941b1..d5475c231fc 100644 --- a/packages/firestore/src/api/credentials.ts +++ b/packages/firestore/src/api/credentials.ts @@ -407,22 +407,15 @@ export class FirstPartyToken implements Token { private readonly authTokenFactory: AuthTokenFactory | null ) {} - /** Gets an authorization token, using a provided factory function, or falling back to First Party GAPI. */ + /** + * Gets an authorization token, using a provided factory function, or return + * null. + */ private getAuthToken(): string | null { if (this.authTokenFactory) { return this.authTokenFactory(); } else { - // Make sure this really is a Gapi client. - hardAssert( - !!( - typeof this.gapi === 'object' && - this.gapi !== null && - this.gapi['auth'] && - this.gapi['auth']['getAuthHeaderValueForFirstParty'] - ), - 'unexpected gapi interface' - ); - return this.gapi!['auth']['getAuthHeaderValueForFirstParty']([]); + return null; } } From c808cded656f302b17a6db9cfea6c6e3007867a8 Mon Sep 17 00:00:00 2001 From: milaGGL <107142260+milaGGL@users.noreply.github.com> Date: Tue, 7 Mar 2023 21:15:26 -0800 Subject: [PATCH 2/4] format code --- packages/firestore/src/api/credentials.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/firestore/src/api/credentials.ts b/packages/firestore/src/api/credentials.ts index d5475c231fc..14bc19e0a32 100644 --- a/packages/firestore/src/api/credentials.ts +++ b/packages/firestore/src/api/credentials.ts @@ -407,9 +407,9 @@ export class FirstPartyToken implements Token { private readonly authTokenFactory: AuthTokenFactory | null ) {} - /** + /** * Gets an authorization token, using a provided factory function, or return - * null. + * null. */ private getAuthToken(): string | null { if (this.authTokenFactory) { From e459d700c837a6ddb38b21bb207293c1b7198a60 Mon Sep 17 00:00:00 2001 From: milaGGL <107142260+milaGGL@users.noreply.github.com> Date: Wed, 8 Mar 2023 16:24:21 -0800 Subject: [PATCH 3/4] add changeset --- .changeset/plenty-radios-look.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/plenty-radios-look.md diff --git a/.changeset/plenty-radios-look.md b/.changeset/plenty-radios-look.md new file mode 100644 index 00000000000..f8d34fd34b6 --- /dev/null +++ b/.changeset/plenty-radios-look.md @@ -0,0 +1,6 @@ +--- +'@firebase/firestore': patch +'firebase': patch +--- + +Remove the deprecated gapi.auth from FirstPartyToken. From e7c44da13756af7ddd578bf8e7786c10a5aa0e3e Mon Sep 17 00:00:00 2001 From: milaGGL <107142260+milaGGL@users.noreply.github.com> Date: Fri, 10 Mar 2023 16:24:57 -0800 Subject: [PATCH 4/4] remove Gapi interface --- packages/firestore/src/api/credentials.ts | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/packages/firestore/src/api/credentials.ts b/packages/firestore/src/api/credentials.ts index 14bc19e0a32..f8af49696cb 100644 --- a/packages/firestore/src/api/credentials.ts +++ b/packages/firestore/src/api/credentials.ts @@ -41,8 +41,7 @@ export type AuthTokenFactory = () => string; export interface FirstPartyCredentialsSettings { // These are external types. Prevent minification. - ['type']: 'gapi'; - ['client']: unknown; + ['type']: 'firstParty'; ['sessionIndex']: string; ['iamToken']: string | null; ['authTokenFactory']: AuthTokenFactory | null; @@ -379,15 +378,6 @@ export class FirebaseAuthCredentialsProvider } } -// Manual type definition for the subset of Gapi we use. -interface Gapi { - auth: { - getAuthHeaderValueForFirstParty: ( - userIdentifiers: Array<{ [key: string]: string }> - ) => string | null; - }; -} - /* * FirstPartyToken provides a fresh token each time its value * is requested, because if the token is too old, requests will be rejected. @@ -401,7 +391,6 @@ export class FirstPartyToken implements Token { private _headers = new Map(); constructor( - private readonly gapi: Gapi | null, private readonly sessionIndex: string, private readonly iamToken: string | null, private readonly authTokenFactory: AuthTokenFactory | null @@ -443,7 +432,6 @@ export class FirstPartyAuthCredentialsProvider implements CredentialsProvider { constructor( - private gapi: Gapi | null, private sessionIndex: string, private iamToken: string | null, private authTokenFactory: AuthTokenFactory | null @@ -452,7 +440,6 @@ export class FirstPartyAuthCredentialsProvider getToken(): Promise { return Promise.resolve( new FirstPartyToken( - this.gapi, this.sessionIndex, this.iamToken, this.authTokenFactory @@ -661,12 +648,9 @@ export function makeAuthCredentialsProvider( if (!credentials) { return new EmptyAuthCredentialsProvider(); } - switch (credentials['type']) { - case 'gapi': - const client = credentials['client'] as Gapi; + case 'firstParty': return new FirstPartyAuthCredentialsProvider( - client, credentials['sessionIndex'] || '0', credentials['iamToken'] || null, credentials['authTokenFactory'] || null