Skip to content

Commit

Permalink
chore: update type declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
russellwheatley committed Feb 19, 2025
1 parent 2bac4e2 commit 84e9c7c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
13 changes: 11 additions & 2 deletions packages/auth/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,8 @@ export namespace FirebaseAuthTypes {

/**
* Re-authenticate a user with a federated authentication provider (Microsoft, Yahoo)
*
* This differs from firebase-js-sdk which returns void, but we return `UserCredential` as this is how it has been implemented
* and we don't have a native equivalent of pop-up re-authentication (i.e. `reauthenticateWithPopup()`).
* #### Example
*
* ```js
Expand All @@ -1365,9 +1366,17 @@ export namespace FirebaseAuthTypes {
* @error auth/invalid-verification-code Thrown if the credential is a auth.PhoneAuthProvider.credential and the verification code of the credential is not valid.
* @error auth/invalid-verification-id Thrown if the credential is a auth.PhoneAuthProvider.credential and the verification ID of the credential is not valid.
* @param provider A created {@link auth.AuthProvider}.
* @returns A promise that resolves with the user credentials.
*/
reauthenticateWithRedirect(provider: AuthProvider): Promise<UserCredential>;

/**
* Re-authenticates the current user. Internally calls `reauthenticateWithRedirect()` as there is no
* pop-up equivalent on native platforms.
*
* @param provider - The auth provider.
* @returns A promise that resolves with the user credentials.
*/
reauthenticateWithPopup(provider: AuthProvider): Promise<UserCredential>;
/**
* Refreshes the current user.
*
Expand Down
15 changes: 9 additions & 6 deletions packages/auth/lib/modular/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,11 +530,12 @@ export function reauthenticateWithPhoneNumber(
): Promise<FirebaseAuthTypes.ConfirmationResult>;

/**
* Reauthenticates the current user with the specified OAuthProvider using a pop-up based OAuth flow.
* Re-authenticates the current user. Internally calls `reauthenticateWithRedirect()` as there is no
* pop-up equivalent on native platforms.
*
* @param user - The user to re-authenticate.
* @param provider - The auth provider.
* @param resolver - Optional. The popup redirect resolver.
* @param resolver - Optional. The popup redirect resolver. Web only.
* @returns A promise that resolves with the user credentials.
*/
export function reauthenticateWithPopup(
Expand All @@ -544,18 +545,20 @@ export function reauthenticateWithPopup(
): Promise<FirebaseAuthTypes.UserCredential>;

/**
* Reauthenticates the current user with the specified OAuthProvider using a full-page redirect flow.
* Re-authenticate a user with a federated authentication provider (Microsoft, Yahoo)
* This differs from firebase-js-sdk which returns void, but we return `UserCredential` as this is how it has been implemented
* and we don't have a native equivalent of pop-up re-authentication (i.e. `reauthenticateWithPopup()`).
*
* @param user - The user to re-authenticate.
* @param provider - The auth provider.
* @param resolver - Optional. The popup redirect resolver.
* @returns A promise that resolves when the redirect is complete.
* @param resolver - Optional. The popup redirect resolver. Web only.
* @returns A promise that resolves with the user credentials.
*/
export function reauthenticateWithRedirect(
user: FirebaseAuthTypes.User,
provider: FirebaseAuthTypes.AuthProvider,
resolver?: PopupRedirectResolver,
): Promise<void>;
): Promise<FirebaseAuthTypes.UserCredential>;

/**
* Reloads user account data, if signed in.
Expand Down
10 changes: 6 additions & 4 deletions packages/auth/lib/modular/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,10 +474,10 @@ export async function reauthenticateWithPhoneNumber(user, phoneNumber, appVerifi
}

/**
* Reauthenticates the current user with the specified OAuthProvider using a pop-up based OAuth flow.
* This wraps around `reauthenticateWithRedirect()` as we do not have a native equivalent of pop-up re-authentication.
* @param {User} user - The user to re-authenticate.
* @param {AuthProvider} provider - The auth provider.
* @param {PopupRedirectResolver} [resolver] - Optional. The popup redirect resolver.
* @param {PopupRedirectResolver} [resolver] - Optional. The popup redirect resolver. Web onl.y
* @returns {Promise<UserCredential>}
*/
export async function reauthenticateWithPopup(user, provider, resolver) {
Expand All @@ -488,10 +488,12 @@ export async function reauthenticateWithPopup(user, provider, resolver) {
* Reauthenticates the current user with the specified OAuthProvider using a full-page redirect flow.
* @param {User} user - The user to re-authenticate.
* @param {AuthProvider} provider - The auth provider.
* @param {PopupRedirectResolver} [resolver] - Optional. The popup redirect resolver.
* @returns {Promise<void>}
* @param {PopupRedirectResolver} [resolver] - Optional. The popup redirect resolver. Web only.
* @returns {Promise<UserCredential>}
*/
export async function reauthenticateWithRedirect(user, provider, resolver) {
// This differs from firebase-js-sdk which returns void, but we return `UserCredential` as this is how it has been implemented
// already, and we don't have a native equivalent of pop-up re-authentication (i.e. `reauthenticateWithPopup()`).
return user.reauthenticateWithRedirect(provider, resolver);
}

Expand Down

0 comments on commit 84e9c7c

Please sign in to comment.