-
Notifications
You must be signed in to change notification settings - Fork 982
Write Firebase Token to Auth instance during exchange_token API #9060
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
Project: /docs/reference/js/_project.yaml | ||
Book: /docs/reference/_book.yaml | ||
page_type: reference | ||
|
||
{% comment %} | ||
DO NOT EDIT THIS FILE! | ||
This is generated by the JS SDK team, and any local changes will be | ||
overwritten. Changes should be made in the source code at | ||
https://github.com/firebase/firebase-js-sdk | ||
{% endcomment %} | ||
|
||
# FirebaseToken interface | ||
<b>Signature:</b> | ||
|
||
```typescript | ||
export interface FirebaseToken | ||
``` | ||
|
||
## Properties | ||
|
||
| Property | Type | Description | | ||
| --- | --- | --- | | ||
| [expirationTime](./auth.firebasetoken.md#firebasetokenexpirationtime) | number | | | ||
| [token](./auth.firebasetoken.md#firebasetokentoken) | string | | | ||
|
||
## FirebaseToken.expirationTime | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
readonly expirationTime: number; | ||
``` | ||
|
||
## FirebaseToken.token | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
readonly token: string; | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,8 @@ import { | |
NextFn, | ||
Unsubscribe, | ||
PasswordValidationStatus, | ||
TenantConfig | ||
TenantConfig, | ||
FirebaseToken | ||
} from '../../model/public_types'; | ||
import { | ||
createSubscribe, | ||
|
@@ -100,6 +101,7 @@ export const enum DefaultConfig { | |
export class AuthImpl implements AuthInternal, _FirebaseService { | ||
currentUser: User | null = null; | ||
emulatorConfig: EmulatorConfig | null = null; | ||
firebaseToken: FirebaseToken | null = null; | ||
private operations = Promise.resolve(); | ||
private persistenceManager?: PersistenceUserManager; | ||
private redirectPersistenceManager?: PersistenceUserManager; | ||
|
@@ -455,6 +457,14 @@ export class AuthImpl implements AuthInternal, _FirebaseService { | |
}); | ||
} | ||
|
||
async _updateFirebaseToken( | ||
firebaseToken: FirebaseToken | null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have to accept null here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah i just saw your new changes in https://github.com/firebase/firebase-js-sdk/pull/9061/files. If this.firebaseToken can be null, then this makes sense. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. We are updating FirebaseToken with |
||
): Promise<void> { | ||
if (firebaseToken) { | ||
this.firebaseToken = firebaseToken; | ||
} | ||
} | ||
|
||
async signOut(): Promise<void> { | ||
if (_isFirebaseServerApp(this.app)) { | ||
return Promise.reject( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -334,6 +334,14 @@ export interface Auth { | |
* {@link @firebase/app#FirebaseServerApp}. | ||
*/ | ||
signOut(): Promise<void>; | ||
/** | ||
* The token response initialized via {@link exchangeToken} endpoint. | ||
* | ||
* @remarks | ||
* This field is only supported for {@link Auth} instance that have defined | ||
* {@link TenantConfig}. | ||
*/ | ||
readonly firebaseToken: FirebaseToken | null; | ||
} | ||
|
||
/** | ||
|
@@ -966,6 +974,13 @@ export interface ReactNativeAsyncStorage { | |
removeItem(key: string): Promise<void>; | ||
} | ||
|
||
export interface FirebaseToken { | ||
// The firebase access token (JWT signed by Firebase Auth). | ||
readonly token: string; | ||
// The time when the access token expires. | ||
|
||
readonly expirationTime: number; | ||
} | ||
|
||
/** | ||
* A user account. | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Is this in seconds?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, The expiresIn is in seconds.