Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
12e7f4b
GCIP BYO-CIAM Initialize Auth Changes (#8995)
mansisampat May 8, 2025
4a42a49
Throw Operation Not Allowed for Invalid Auth Endpoint (#9013)
mansisampat May 13, 2025
7690dcb
Implement exchangeToken public api (#9039)
mansisampat May 23, 2025
f6b44ee
Write Firebase Token to Auth instance during exchange_token API (#9060)
mansisampat May 30, 2025
306ddf8
Implement getToken method for Regional Auth Interop (#9061)
mansisampat Jun 4, 2025
6160502
Pass API Key as request param for Regional Auth requests & Demo App c…
mansisampat Jun 23, 2025
fc7e1fc
Fix typo
mansisampat Jun 23, 2025
7a14073
Store FirebaseToken to persistence - Required for BYO-CIAM (#9138)
mansisampat Jul 3, 2025
f2d9028
Implement signOut for BYO-CIAM firebaseToken (#9141)
mansisampat Jul 15, 2025
ac2fc52
Maintain persistence for firebaseToken in AuthImpl object
mansisampat Jun 25, 2025
644ded1
Implement Token refresh mechanism for BYO-CIAM (#9285)
mansisampat Oct 3, 2025
64a5a86
Update the backend endpoint for exchangeOidcToken to prod endpoint. (…
mansisampat Oct 3, 2025
870af07
Refresh Firebase Token Demo App changes (#9294)
mansisampat Oct 6, 2025
7e14a59
Update refresh token buffer from 30 seconds to 60 seconds (#9296)
mansisampat Oct 6, 2025
9edb9ac
Remove firebaseToken from persistence if tokenRefreshHandler is not s…
mansisampat Oct 7, 2025
c7f9c60
Demo app improvements. (#9299)
mansisampat Oct 7, 2025
b27267f
Add firebaseInterop getToken method call from BYO-CIAM demo app (#9301)
mansisampat Oct 8, 2025
bd77aed
Throw Operation Not Allowed Exception in FirebaseAuthInterop getUid f…
mansisampat Oct 21, 2025
95babba
Update registerStateListener internal method signature and structure
mansisampat Oct 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ env:
# the behavior to use the new URLs.
CHROMEDRIVER_CDNURL: https://googlechromelabs.github.io/
CHROMEDRIVER_CDNBINARIESURL: https://storage.googleapis.com/chrome-for-testing-public
CHROME_VALIDATED_VERSION: linux-132.0.6834.110
CHROME_VALIDATED_VERSION: linux-141.0.7390.78
CHROME_VERSION_MISMATCH_MESSAGE: "The Chrome version doesn't match the previously validated version. Consider updating CHROME_VALIDATED_VERSION in the GitHub workflow if tests pass, or rollback the installed Chrome version if tests fail."
artifactRetentionDays: 14
# Bump Node memory limit
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-changed-auth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ env:
# the behavior to use the new URLs.
CHROMEDRIVER_CDNURL: https://googlechromelabs.github.io/
CHROMEDRIVER_CDNBINARIESURL: https://storage.googleapis.com/chrome-for-testing-public
CHROME_VALIDATED_VERSION: linux-120.0.6099.71
CHROME_VALIDATED_VERSION: linux-137.0.7151.119
# Bump Node memory limit
NODE_OPTIONS: "--max_old_space_size=4096"

Expand Down Expand Up @@ -119,4 +119,4 @@ jobs:
- name: Run tests on changed packages
run: yarn test:changed auth
env:
BROWSERS: 'WebkitHeadless'
BROWSERS: 'WebkitHeadless'
23 changes: 23 additions & 0 deletions common/api-review/auth.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ export interface Auth {
onIdTokenChanged(nextOrObserver: NextOrObserver<User | null>, error?: ErrorFn, completed?: CompleteFn): Unsubscribe;
setPersistence(persistence: Persistence): Promise<void>;
readonly settings: AuthSettings;
setTokenRefreshHandler(tokenRefreshHandler: TokenRefreshHandler): void;
signOut(): Promise<void>;
readonly tenantConfig?: TenantConfig;
tenantId: string | null;
updateCurrentUser(user: User | null): Promise<void>;
useDeviceLanguage(): void;
Expand Down Expand Up @@ -316,6 +318,7 @@ export interface Dependencies {
errorMap?: AuthErrorMap;
persistence?: Persistence | Persistence[];
popupRedirectResolver?: PopupRedirectResolver;
tenantConfig?: TenantConfig;
}

// @public
Expand Down Expand Up @@ -362,6 +365,9 @@ export interface EmulatorConfig {

export { ErrorFn }

// @public
export function exchangeToken(auth: Auth, idpConfigId: string, customToken: string): Promise<string>;

// Warning: (ae-forgotten-export) The symbol "BaseOAuthProvider" needs to be exported by the entry point index.d.ts
//
// @public
Expand Down Expand Up @@ -729,6 +735,12 @@ export class RecaptchaVerifier implements ApplicationVerifierInternal {
verify(): Promise<string>;
}

// @public
export interface RefreshIdpTokenResult {
idpConfigId: string;
idToken: string;
}

// @public
export function reload(user: User): Promise<void>;

Expand Down Expand Up @@ -795,6 +807,17 @@ export function signInWithRedirect(auth: Auth, provider: AuthProvider, resolver?
// @public
export function signOut(auth: Auth): Promise<void>;

// @public
export interface TenantConfig {
location: string;
tenantId: string;
}

// @public
export interface TokenRefreshHandler {
refreshIdpToken(): Promise<RefreshIdpTokenResult>;
}

// @public
export interface TotpMultiFactorAssertion extends MultiFactorAssertion {
}
Expand Down
6 changes: 6 additions & 0 deletions docs-devsite/_toc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,14 @@ toc:
path: /docs/reference/js/auth.recaptchaparameters.md
- title: RecaptchaVerifier
path: /docs/reference/js/auth.recaptchaverifier.md
- title: RefreshIdpTokenResult
path: /docs/reference/js/auth.refreshidptokenresult.md
- title: SAMLAuthProvider
path: /docs/reference/js/auth.samlauthprovider.md
- title: TenantConfig
path: /docs/reference/js/auth.tenantconfig.md
- title: TokenRefreshHandler
path: /docs/reference/js/auth.tokenrefreshhandler.md
- title: TotpMultiFactorAssertion
path: /docs/reference/js/auth.totpmultifactorassertion.md
- title: TotpMultiFactorGenerator
Expand Down
50 changes: 50 additions & 0 deletions docs-devsite/auth.auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface Auth
| [languageCode](./auth.auth.md#authlanguagecode) | string \| null | The [Auth](./auth.auth.md#auth_interface) instance's language code. |
| [name](./auth.auth.md#authname) | string | The name of the app associated with the <code>Auth</code> service instance. |
| [settings](./auth.auth.md#authsettings) | [AuthSettings](./auth.authsettings.md#authsettings_interface) | The [Auth](./auth.auth.md#auth_interface) instance's settings. |
| [tenantConfig](./auth.auth.md#authtenantconfig) | [TenantConfig](./auth.tenantconfig.md#tenantconfig_interface) | The [TenantConfig](./auth.tenantconfig.md#tenantconfig_interface) used to initialize a Regional Auth. This is only present if regional auth is initialized and <code>DefaultConfig.REGIONAL_API_HOST</code> backend endpoint is used. |
| [tenantId](./auth.auth.md#authtenantid) | string \| null | The [Auth](./auth.auth.md#auth_interface) instance's tenant ID. |

## Methods
Expand All @@ -42,6 +43,7 @@ export interface Auth
| [onAuthStateChanged(nextOrObserver, error, completed)](./auth.auth.md#authonauthstatechanged) | Adds an observer for changes to the user's sign-in state. |
| [onIdTokenChanged(nextOrObserver, error, completed)](./auth.auth.md#authonidtokenchanged) | Adds an observer for changes to the signed-in user's ID token. |
| [setPersistence(persistence)](./auth.auth.md#authsetpersistence) | Changes the type of persistence on the <code>Auth</code> instance. |
| [setTokenRefreshHandler(tokenRefreshHandler)](./auth.auth.md#authsettokenrefreshhandler) | Registers a handler for refreshing third-party identity provider (IDP) tokens.<!-- -->When the Firebase access token is expired, the SDK will automatically invoke the provided handler's <code>refreshIdpToken()</code> method to obtain a new IDP token. This new token will then be exchanged for a fresh Firebase token, streamlining the authentication process. |
| [signOut()](./auth.auth.md#authsignout) | Signs out the current user. This does not automatically revoke the user's ID token. |
| [updateCurrentUser(user)](./auth.auth.md#authupdatecurrentuser) | Asynchronously sets the provided user as [Auth.currentUser](./auth.auth.md#authcurrentuser) on the [Auth](./auth.auth.md#auth_interface) instance. |
| [useDeviceLanguage()](./auth.auth.md#authusedevicelanguage) | Sets the current language to the default device/browser preference. |
Expand Down Expand Up @@ -120,6 +122,16 @@ This is used to edit/read configuration related options such as app verification
readonly settings: AuthSettings;
```

## Auth.tenantConfig

The [TenantConfig](./auth.tenantconfig.md#tenantconfig_interface) used to initialize a Regional Auth. This is only present if regional auth is initialized and `DefaultConfig.REGIONAL_API_HOST` backend endpoint is used.

<b>Signature:</b>

```typescript
readonly tenantConfig?: TenantConfig;
```

## Auth.tenantId

The [Auth](./auth.auth.md#auth_interface) instance's tenant ID.
Expand Down Expand Up @@ -261,6 +273,44 @@ auth.setPersistence(browserSessionPersistence);

```

## Auth.setTokenRefreshHandler()

Registers a handler for refreshing third-party identity provider (IDP) tokens.

When the Firebase access token is expired, the SDK will automatically invoke the provided handler's `refreshIdpToken()` method to obtain a new IDP token. This new token will then be exchanged for a fresh Firebase token, streamlining the authentication process.

<b>Signature:</b>

```typescript
setTokenRefreshHandler(tokenRefreshHandler: TokenRefreshHandler): void;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| tokenRefreshHandler | [TokenRefreshHandler](./auth.tokenrefreshhandler.md#tokenrefreshhandler_interface) | An object that implements the <code>TokenRefreshHandler</code> interface, providing the logic to refresh the IDP token. |

<b>Returns:</b>

void

### Example


```javascript
class TokenRefreshHandlerImpl {
refreshIdpToken() {
// Logic to fetch a new token from your custom IDP.
// Returns a Promise that resolves with a RefreshIdpTokenResult.
}
}

const tokenRefreshHandler = new TokenRefreshHandlerImpl();
auth.setTokenRefreshHandler(tokenRefreshHandler);

```

## Auth.signOut()

Signs out the current user. This does not automatically revoke the user's ID token.
Expand Down
11 changes: 11 additions & 0 deletions docs-devsite/auth.dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface Dependencies
| [errorMap](./auth.dependencies.md#dependencieserrormap) | [AuthErrorMap](./auth.autherrormap.md#autherrormap_interface) | Which [AuthErrorMap](./auth.autherrormap.md#autherrormap_interface) to use. |
| [persistence](./auth.dependencies.md#dependenciespersistence) | [Persistence](./auth.persistence.md#persistence_interface) \| [Persistence](./auth.persistence.md#persistence_interface)<!-- -->\[\] | Which [Persistence](./auth.persistence.md#persistence_interface) to use. If this is an array, the first <code>Persistence</code> that the device supports is used. The SDK searches for an existing account in order and, if one is found in a secondary <code>Persistence</code>, the account is moved to the primary <code>Persistence</code>.<!-- -->If no persistence is provided, the SDK falls back on [inMemoryPersistence](./auth.md#inmemorypersistence)<!-- -->. |
| [popupRedirectResolver](./auth.dependencies.md#dependenciespopupredirectresolver) | [PopupRedirectResolver](./auth.popupredirectresolver.md#popupredirectresolver_interface) | The [PopupRedirectResolver](./auth.popupredirectresolver.md#popupredirectresolver_interface) to use. This value depends on the platform. Options are [browserPopupRedirectResolver](./auth.md#browserpopupredirectresolver) and [cordovaPopupRedirectResolver](./auth.md#cordovapopupredirectresolver)<!-- -->. This field is optional if neither [signInWithPopup()](./auth.md#signinwithpopup_770f816) or [signInWithRedirect()](./auth.md#signinwithredirect_770f816) are being used. |
| [tenantConfig](./auth.dependencies.md#dependenciestenantconfig) | [TenantConfig](./auth.tenantconfig.md#tenantconfig_interface) | The [TenantConfig](./auth.tenantconfig.md#tenantconfig_interface) to use. This dependency is only required if you want to use regional auth which works with <code>DefaultConfig.REGIONAL_API_HOST</code> endpoint. It should not be set otherwise. |

## Dependencies.errorMap

Expand Down Expand Up @@ -61,3 +62,13 @@ The [PopupRedirectResolver](./auth.popupredirectresolver.md#popupredirectresolve
```typescript
popupRedirectResolver?: PopupRedirectResolver;
```

## Dependencies.tenantConfig

The [TenantConfig](./auth.tenantconfig.md#tenantconfig_interface) to use. This dependency is only required if you want to use regional auth which works with `DefaultConfig.REGIONAL_API_HOST` endpoint. It should not be set otherwise.

<b>Signature:</b>

```typescript
tenantConfig?: TenantConfig;
```
32 changes: 32 additions & 0 deletions docs-devsite/auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Firebase Authentication
| [confirmPasswordReset(auth, oobCode, newPassword)](./auth.md#confirmpasswordreset_749dad8) | Completes the password reset process, given a confirmation code and new password. |
| [connectAuthEmulator(auth, url, options)](./auth.md#connectauthemulator_657c7e5) | Changes the [Auth](./auth.auth.md#auth_interface) instance to communicate with the Firebase Auth Emulator, instead of production Firebase Auth services. |
| [createUserWithEmailAndPassword(auth, email, password)](./auth.md#createuserwithemailandpassword_21ad33b) | Creates a new user account associated with the specified email address and password. |
| [exchangeToken(auth, idpConfigId, customToken)](./auth.md#exchangetoken_b6b1871) | Asynchronously exchanges an OIDC provider's Authorization code or Id Token for a Firebase Token. |
| [fetchSignInMethodsForEmail(auth, email)](./auth.md#fetchsigninmethodsforemail_efb3887) | Gets the list of possible sign in methods for the given email address. This method returns an empty list when [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled, irrespective of the number of authentication methods available for the given email. |
| [getMultiFactorResolver(auth, error)](./auth.md#getmultifactorresolver_201ba61) | Provides a [MultiFactorResolver](./auth.multifactorresolver.md#multifactorresolver_interface) suitable for completion of a multi-factor flow. |
| [getRedirectResult(auth, resolver)](./auth.md#getredirectresult_c35dc1f) | Returns a [UserCredential](./auth.usercredential.md#usercredential_interface) from the redirect-based sign-in flow. |
Expand Down Expand Up @@ -137,6 +138,9 @@ Firebase Authentication
| [PopupRedirectResolver](./auth.popupredirectresolver.md#popupredirectresolver_interface) | A resolver used for handling DOM specific operations like [signInWithPopup()](./auth.md#signinwithpopup_770f816) or [signInWithRedirect()](./auth.md#signinwithredirect_770f816)<!-- -->. |
| [ReactNativeAsyncStorage](./auth.reactnativeasyncstorage.md#reactnativeasyncstorage_interface) | Interface for a supplied <code>AsyncStorage</code>. |
| [RecaptchaParameters](./auth.recaptchaparameters.md#recaptchaparameters_interface) | Interface representing reCAPTCHA parameters.<!-- -->See the [reCAPTCHA docs](https://developers.google.com/recaptcha/docs/display#render_param) for the list of accepted parameters. All parameters are accepted except for <code>sitekey</code>: Firebase Auth provisions a reCAPTCHA for each project and will configure the site key upon rendering.<!-- -->For an invisible reCAPTCHA, set the <code>size</code> key to <code>invisible</code>. |
| [RefreshIdpTokenResult](./auth.refreshidptokenresult.md#refreshidptokenresult_interface) | The result of a third-party IDP token refresh operation.<!-- -->This object contains the new IDP token and the Idp Config ID of the provider that issued it. |
| [TenantConfig](./auth.tenantconfig.md#tenantconfig_interface) | The tenant config that can be used to initialize a Regional [Auth](./auth.auth.md#auth_interface) instance. |
| [TokenRefreshHandler](./auth.tokenrefreshhandler.md#tokenrefreshhandler_interface) | An interface for handling the refresh of Firebase tokens. |
| [TotpMultiFactorAssertion](./auth.totpmultifactorassertion.md#totpmultifactorassertion_interface) | The class for asserting ownership of a TOTP second factor. Provided by [TotpMultiFactorGenerator.assertionForEnrollment()](./auth.totpmultifactorgenerator.md#totpmultifactorgeneratorassertionforenrollment) and [TotpMultiFactorGenerator.assertionForSignIn()](./auth.totpmultifactorgenerator.md#totpmultifactorgeneratorassertionforsignin)<!-- -->. |
| [TotpMultiFactorInfo](./auth.totpmultifactorinfo.md#totpmultifactorinfo_interface) | The subclass of the [MultiFactorInfo](./auth.multifactorinfo.md#multifactorinfo_interface) interface for TOTP second factors. The <code>factorId</code> of this second factor is [FactorId](./auth.md#factorid)<!-- -->.TOTP. |
| [User](./auth.user.md#user_interface) | A user account. |
Expand Down Expand Up @@ -404,6 +408,34 @@ export declare function createUserWithEmailAndPassword(auth: Auth, email: string

Promise&lt;[UserCredential](./auth.usercredential.md#usercredential_interface)<!-- -->&gt;

### exchangeToken(auth, idpConfigId, customToken) {:#exchangetoken_b6b1871}

Asynchronously exchanges an OIDC provider's Authorization code or Id Token for a Firebase Token.

This method is implemented only for `DefaultConfig.REGIONAL_API_HOST` and requires [TenantConfig](./auth.tenantconfig.md#tenantconfig_interface) to be configured in the [Auth](./auth.auth.md#auth_interface) instance used.

Fails with an error if the token is invalid, expired, or not accepted by the Firebase Auth service.

<b>Signature:</b>

```typescript
export declare function exchangeToken(auth: Auth, idpConfigId: string, customToken: string): Promise<string>;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| auth | [Auth](./auth.auth.md#auth_interface) | The [Auth](./auth.auth.md#auth_interface) instance. |
| idpConfigId | string | The ExternalUserDirectoryId corresponding to the OIDC custom Token. |
| customToken | string | The OIDC provider's Authorization code or Id Token to exchange. |

<b>Returns:</b>

Promise&lt;string&gt;

The firebase access token (JWT signed by Firebase Auth).

### fetchSignInMethodsForEmail(auth, email) {:#fetchsigninmethodsforemail_efb3887}

Gets the list of possible sign in methods for the given email address. This method returns an empty list when [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled, irrespective of the number of authentication methods available for the given email.
Expand Down
48 changes: 48 additions & 0 deletions docs-devsite/auth.refreshidptokenresult.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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 %}

# RefreshIdpTokenResult interface
The result of a third-party IDP token refresh operation.

This object contains the new IDP token and the Idp Config ID of the provider that issued it.

<b>Signature:</b>

```typescript
export interface RefreshIdpTokenResult
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [idpConfigId](./auth.refreshidptokenresult.md#refreshidptokenresultidpconfigid) | string | The configuration ID of the third-party identity provider. |
| [idToken](./auth.refreshidptokenresult.md#refreshidptokenresultidtoken) | string | The new Id Token from the 3rd party Identity Provider. |

## RefreshIdpTokenResult.idpConfigId

The configuration ID of the third-party identity provider.

<b>Signature:</b>

```typescript
idpConfigId: string;
```

## RefreshIdpTokenResult.idToken

The new Id Token from the 3rd party Identity Provider.

<b>Signature:</b>

```typescript
idToken: string;
```
46 changes: 46 additions & 0 deletions docs-devsite/auth.tenantconfig.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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 %}

# TenantConfig interface
The tenant config that can be used to initialize a Regional [Auth](./auth.auth.md#auth_interface) instance.

<b>Signature:</b>

```typescript
export interface TenantConfig
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [location](./auth.tenantconfig.md#tenantconfiglocation) | string | Which location to use. |
| [tenantId](./auth.tenantconfig.md#tenantconfigtenantid) | string | The tenant Id being used. |

## TenantConfig.location

Which location to use.

<b>Signature:</b>

```typescript
location: string;
```

## TenantConfig.tenantId

The tenant Id being used.

<b>Signature:</b>

```typescript
tenantId: string;
```
43 changes: 43 additions & 0 deletions docs-devsite/auth.tokenrefreshhandler.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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 %}

# TokenRefreshHandler interface
An interface for handling the refresh of Firebase tokens.

<b>Signature:</b>

```typescript
export interface TokenRefreshHandler
```

## Methods

| Method | Description |
| --- | --- |
| [refreshIdpToken()](./auth.tokenrefreshhandler.md#tokenrefreshhandlerrefreshidptoken) | Refreshes the third-party IDP token.<!-- -->This method should contain the logic to obtain a new, valid IDP token from your identity provider. |

## TokenRefreshHandler.refreshIdpToken()

Refreshes the third-party IDP token.

This method should contain the logic to obtain a new, valid IDP token from your identity provider.

<b>Signature:</b>

```typescript
refreshIdpToken(): Promise<RefreshIdpTokenResult>;
```
<b>Returns:</b>

Promise&lt;[RefreshIdpTokenResult](./auth.refreshidptokenresult.md#refreshidptokenresult_interface)<!-- -->&gt;

A promise that resolves with a `RefreshIdpTokenResult` object containing the new IDP token and its corresponding Idp Config ID.

Loading
Loading