No "identities" property in ParseToken interface (original) (raw)

[REQUIRED] Describe your environment

[REQUIRED] Describe the problem

Steps to reproduce:

I've been using firebase v8, and yesterday I migrated v8 to v9.

With firebase v8, I used to get the userId below code.

user.getIdTokenResult().then(({ token, signInProvider, claims })=>{ const info = claims.firebase; const [id] = info?.identities[signInProvider || '']; consoel.log('Here is my id', id); });

but after upgrading to v9, I get a type error

Property 'identities' does not exist on type '{ sign_in_provider?: string | undefined; sign_in_second_factor?: string | undefined; }'.

For testing, I signed up using Twitter, and I got a ParsedToken.

and I printed that token on the console.

{ aud: "####", auth_time: 123456, exp: 123456, firebase: { identities: { twitter.com: ["ID"] }, sign_in_provider: "twitter.com", }, iat: 123456, ... }

identities is existed.

but there are no identities props in @firebase/auth/dist/auth-public.d.ts

/**

I think it should be updated like this.

export declare interface ParsedToken { /* ... / 'iat'?: string; /* Firebase specific claims, containing the provider(s) used to authenticate the user. / 'firebase'?: { identities: { [key: string]: Array }; 'sign_in_provider'?: string; 'sign_in_second_factor'?: string; }; /* Map of any additional custom claims. */ [key: string]: string | object | undefined; }

I compare v8 to v9, and I've found why it happened.

In version 9

export declare interface IdTokenResult { /** * The authentication time formatted as a UTC string. * * @remarks * This is the time the user authenticated (signed in) and not the time the token was refreshed. / authTime: string; /* The ID token expiration time formatted as a UTC string. / expirationTime: string; /* The ID token issuance time formatted as a UTC string. / issuedAtTime: string; /* * The sign-in provider through which the ID token was obtained (anonymous, custom, phone, * password, etc). * * @remarks * Note, this does not map to provider IDs. / signInProvider: string | null; /* * The type of second factor associated with this session, provided the user was multi-factor * authenticated (eg. phone, etc). / signInSecondFactor: string | null; /* The Firebase Auth ID token JWT string. / token: string; /* * The entire payload claims of the ID token including the standard reserved claims as well as * the custom claims. */ claims: ParsedToken; }

claims defined as ParsedToken in v9,
but v8 is

interface IdTokenResult { /* ... */ claims: { [key: string]: any; }; }