@@ -118,6 +118,46 @@ export interface ParsedToken {
118118 */
119119export type NextOrObserver < T > = NextFn < T | null > | Observer < T | null > ;
120120
121+ /**
122+ * An interface for handling the refresh of Firebase tokens.
123+ *
124+ * @public
125+ */
126+ export interface TokenRefreshHandler {
127+ /**
128+ * Refreshes the third-party IDP token.
129+ *
130+ * This method should contain the logic to obtain a new, valid IDP token from
131+ * your identity provider.
132+ *
133+ * @returns A promise that resolves with a `RefreshIdpTokenResult` object
134+ * containing the new IDP token and its corresponding Idp Config ID.
135+ */
136+ refreshIdpToken ( ) : Promise < RefreshIdpTokenResult >
137+ }
138+
139+ /**
140+ * The result of a third-party IDP token refresh operation.
141+ *
142+ * This object contains the new IDP token and the Idp Config ID of the
143+ * provider that issued it.
144+ *
145+ * @public
146+ */
147+ export interface RefreshIdpTokenResult {
148+ /**
149+ * The configuration ID of the third-party identity provider.
150+ */
151+ idpConfigId : string ;
152+
153+ /**
154+ * The new Id Token from the 3rd party Identity Provider.
155+ */
156+ idToken : string ;
157+ }
158+
159+
160+
121161/**
122162 * Interface for an `Auth` error.
123163 *
@@ -210,6 +250,32 @@ export interface Auth {
210250 * @param persistence - The {@link Persistence} to use.
211251 */
212252 setPersistence ( persistence : Persistence ) : Promise < void > ;
253+ /**
254+ * Registers a handler for refreshing third-party identity provider (IDP) tokens.
255+ *
256+ * When the Firebase access token is expired, the SDK will automatically invoke the
257+ * provided handler's `refreshIdpToken()` method to obtain a new IDP token. This new
258+ * token will then be exchanged for a fresh Firebase token, streamlining the
259+ * authentication process.
260+ *
261+ * @example
262+ * ```javascript
263+ * class TokenRefreshHandlerImpl {
264+ * refreshIdpToken() {
265+ * // Logic to fetch a new token from your custom IDP.
266+ * // Returns a Promise that resolves with a RefreshIdpTokenResult.
267+ * }
268+ * }
269+ *
270+ * const tokenRefreshHandler = new TokenRefreshHandlerImpl();
271+ * auth.setTokenRefreshHandler(tokenRefreshHandler);
272+ * ```
273+ *
274+ * @param tokenRefreshHandler - An object that implements the `TokenRefreshHandler`
275+ * interface, providing the logic to refresh the IDP token.
276+ */
277+ setTokenRefreshHandler ( tokenRefreshHandler : TokenRefreshHandler ) : void ;
278+
213279 /**
214280 * The {@link Auth} instance's language code.
215281 *
0 commit comments