From 6e92db3d7471e3d62bf5584a730294c5f5efbce1 Mon Sep 17 00:00:00 2001 From: renkelvin Date: Tue, 16 Apr 2024 21:58:51 -0700 Subject: [PATCH 1/6] Check DOMException error name instead of error message --- .../auth/src/core/strategies/passkey.test.ts | 21 ++++++++++++++++--- packages/auth/src/core/strategies/passkey.ts | 6 +++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/packages/auth/src/core/strategies/passkey.test.ts b/packages/auth/src/core/strategies/passkey.test.ts index 35a50f27c44..50ab1ea0d3c 100644 --- a/packages/auth/src/core/strategies/passkey.test.ts +++ b/packages/auth/src/core/strategies/passkey.test.ts @@ -96,7 +96,12 @@ describe('passkey', async () => { } sinon .stub(navigator.credentials, 'get') - .throws(new Error('The operation either timed out or was not allowed.')); + .throws( + new DOMException( + 'The operation either timed out or was not allowed.', + 'NotAllowedError' + ) + ); sinon.stub(navigator.credentials, 'create').resolves(mockCredential); @@ -166,7 +171,12 @@ describe('passkey', async () => { } sinon .stub(navigator.credentials, 'get') - .throws(new Error('The operation either timed out or was not allowed.')); + .throws( + new DOMException( + 'The operation either timed out or was not allowed.', + 'NotAllowedError' + ) + ); mockEndpoint(Endpoint.START_PASSKEY_SIGNIN, { credentialRequestOptions: { @@ -243,7 +253,12 @@ describe('passkey', async () => { } sinon .stub(navigator.credentials, 'create') - .throws(new Error('The operation either timed out or was not allowed.')); + .throws( + new DOMException( + 'The operation either timed out or was not allowed.', + 'NotAllowedError' + ) + ); mockEndpoint(Endpoint.START_PASSKEY_ENROLLMENT, { credentialCreationOptions: { diff --git a/packages/auth/src/core/strategies/passkey.ts b/packages/auth/src/core/strategies/passkey.ts index 97843e961a9..5fd6c909c9a 100644 --- a/packages/auth/src/core/strategies/passkey.ts +++ b/packages/auth/src/core/strategies/passkey.ts @@ -42,8 +42,7 @@ import { UserCredentialImpl } from '../user/user_credential_impl'; import { signInAnonymously } from './anonymous'; const DEFAULT_PASSKEY_ACCOUNT_NAME = 'Unnamed account (Web)'; -const PASSKEY_LOOK_UP_ERROR_MESSAGE = - 'The operation either timed out or was not allowed.'; +const PASSKEY_LOOK_UP_ERROR_NAME = 'NotAllowedError'; /** * Signs in a user with a passkey. Use enrollPasskey to enroll a passkey credential for the current user. @@ -94,7 +93,8 @@ export async function signInWithPasskey( return userCredential; } catch (error) { if ( - (error as Error).message.includes(PASSKEY_LOOK_UP_ERROR_MESSAGE) && + error instanceof DOMException && + error.name === PASSKEY_LOOK_UP_ERROR_NAME && !manualSignUp ) { // If the user is not signed up, sign them up anonymously From 703dfb875733b7a9a768b77d2dfe5d81a0dc25ee Mon Sep 17 00:00:00 2001 From: renkelvin Date: Tue, 16 Apr 2024 22:12:45 -0700 Subject: [PATCH 2/6] `yarn docgen devsite` --- common/api-review/auth.api.md | 28 +++++++++++++++++----------- packages/auth/api-extractor.json | 2 +- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/common/api-review/auth.api.md b/common/api-review/auth.api.md index 03b62334d96..ecc44f26207 100644 --- a/common/api-review/auth.api.md +++ b/common/api-review/auth.api.md @@ -104,14 +104,14 @@ export class AuthCredential { protected constructor( providerId: string, signInMethod: string); - // Warning: (ae-forgotten-export) The symbol "AuthInternal" needs to be exported by the entry point index.d.ts - // Warning: (ae-forgotten-export) The symbol "PhoneOrOauthTokenResponse" needs to be exported by the entry point index.d.ts + // Warning: (ae-forgotten-export) The symbol "AuthInternal" needs to be exported by the entry point index.doc.d.ts + // Warning: (ae-forgotten-export) The symbol "PhoneOrOauthTokenResponse" needs to be exported by the entry point index.doc.d.ts // // @internal (undocumented) _getIdTokenResponse(_auth: AuthInternal): Promise; // @internal (undocumented) _getReauthenticationResolver(_auth: AuthInternal): Promise; - // Warning: (ae-forgotten-export) The symbol "IdTokenResponse" needs to be exported by the entry point index.d.ts + // Warning: (ae-forgotten-export) The symbol "IdTokenResponse" needs to be exported by the entry point index.doc.d.ts // // @internal (undocumented) _linkToIdToken(_auth: AuthInternal, _idToken: string): Promise; @@ -293,6 +293,9 @@ export function connectAuthEmulator(auth: Auth, url: string, options?: { disableWarnings: boolean; }): void; +// @public +export const cordovaPopupRedirectResolver: PopupRedirectResolver; + // @public export function createUserWithEmailAndPassword(auth: Auth, email: string, password: string): Promise; @@ -359,7 +362,7 @@ export function enrollPasskey(user: User, name: string): Promise export { ErrorFn } -// Warning: (ae-forgotten-export) The symbol "BaseOAuthProvider" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "BaseOAuthProvider" needs to be exported by the entry point index.doc.d.ts // // @public export class FacebookAuthProvider extends BaseOAuthProvider { @@ -395,6 +398,9 @@ export function getIdTokenResult(user: User, forceRefresh?: boolean): Promise; @@ -507,7 +513,7 @@ export type NextOrObserver = NextFn | Observer; export class OAuthCredential extends AuthCredential { accessToken?: string; static fromJSON(json: string | object): OAuthCredential | null; - // Warning: (ae-forgotten-export) The symbol "OAuthCredentialParams" needs to be exported by the entry point index.d.ts + // Warning: (ae-forgotten-export) The symbol "OAuthCredentialParams" needs to be exported by the entry point index.doc.d.ts // // @internal (undocumented) static _fromParams(params: OAuthCredentialParams): OAuthCredential; @@ -618,7 +624,7 @@ export class PhoneAuthCredential extends AuthCredential { _getReauthenticationResolver(auth: AuthInternal): Promise; // @internal (undocumented) _linkToIdToken(auth: AuthInternal, idToken: string): Promise; - // Warning: (ae-forgotten-export) The symbol "SignInWithPhoneNumberRequest" needs to be exported by the entry point index.d.ts + // Warning: (ae-forgotten-export) The symbol "SignInWithPhoneNumberRequest" needs to be exported by the entry point index.doc.d.ts // // @internal (undocumented) _makeVerificationRequest(): SignInWithPhoneNumberRequest; @@ -715,13 +721,13 @@ export interface RecaptchaParameters { [key: string]: any; } -// Warning: (ae-forgotten-export) The symbol "ApplicationVerifierInternal" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "ApplicationVerifierInternal" needs to be exported by the entry point index.doc.d.ts // // @public export class RecaptchaVerifier implements ApplicationVerifierInternal { constructor(authExtern: Auth, containerOrId: HTMLElement | string, parameters?: RecaptchaParameters); clear(): void; - // Warning: (ae-forgotten-export) The symbol "ReCaptchaLoader" needs to be exported by the entry point index.d.ts + // Warning: (ae-forgotten-export) The symbol "ReCaptchaLoader" needs to be exported by the entry point index.doc.d.ts // // @internal (undocumented) readonly _recaptchaLoader: ReCaptchaLoader; @@ -738,7 +744,7 @@ export function reload(user: User): Promise; // @public export function revokeAccessToken(auth: Auth, token: string): Promise; -// Warning: (ae-forgotten-export) The symbol "FederatedAuthProvider" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "FederatedAuthProvider" needs to be exported by the entry point index.doc.d.ts // // @public export class SAMLAuthProvider extends FederatedAuthProvider { @@ -822,13 +828,13 @@ export class TotpSecret { readonly codeIntervalSeconds: number; readonly codeLength: number; readonly enrollmentCompletionDeadline: string; - // Warning: (ae-forgotten-export) The symbol "StartTotpMfaEnrollmentResponse" needs to be exported by the entry point index.d.ts + // Warning: (ae-forgotten-export) The symbol "StartTotpMfaEnrollmentResponse" needs to be exported by the entry point index.doc.d.ts // // @internal (undocumented) static _fromStartTotpMfaEnrollmentResponse(response: StartTotpMfaEnrollmentResponse, auth: AuthInternal): TotpSecret; generateQrCodeUrl(accountName?: string, issuer?: string): string; readonly hashingAlgorithm: string; - // Warning: (ae-forgotten-export) The symbol "TotpVerificationInfo" needs to be exported by the entry point index.d.ts + // Warning: (ae-forgotten-export) The symbol "TotpVerificationInfo" needs to be exported by the entry point index.doc.d.ts // // @internal (undocumented) _makeTotpVerificationInfo(otp: string): TotpVerificationInfo; diff --git a/packages/auth/api-extractor.json b/packages/auth/api-extractor.json index ca7e1ee6983..325fe12d507 100644 --- a/packages/auth/api-extractor.json +++ b/packages/auth/api-extractor.json @@ -1,6 +1,6 @@ { "extends": "../../config/api-extractor.json", - "mainEntryPointFilePath": "/dist/esm5/index.d.ts", + "mainEntryPointFilePath": "/dist/esm5/index.doc.d.ts", "dtsRollup": { "enabled": true, "untrimmedFilePath": "/dist/.d.ts", From eff7e0388f7890170360d3e17b73f47c027bd812 Mon Sep 17 00:00:00 2001 From: renkelvin Date: Tue, 16 Apr 2024 22:31:56 -0700 Subject: [PATCH 3/6] doc fix --- docs-devsite/auth.md | 148 +++++++++++++++++++------------------- docs-devsite/auth.user.md | 2 +- 2 files changed, 74 insertions(+), 76 deletions(-) diff --git a/docs-devsite/auth.md b/docs-devsite/auth.md index aa372eee5a9..992c13aea1d 100644 --- a/docs-devsite/auth.md +++ b/docs-devsite/auth.md @@ -16,69 +16,70 @@ Firebase Authentication | Function | Description | | --- | --- | -| function(app...) | -| [getAuth(app)](./auth.md#getauth) | Returns the Auth instance associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes an Auth instance with platform-specific default dependencies. | -| [initializeAuth(app, deps)](./auth.md#initializeauth) | Initializes an [Auth](./auth.auth.md#auth_interface) instance with fine-grained control over [Dependencies](./auth.dependencies.md#dependencies_interface). | -| function(storage...) | -| [getReactNativePersistence(storage)](./auth.md#getreactnativepersistence) | Returns a persistence object that wraps AsyncStorage imported from react-native or @react-native-community/async-storage, and can be used in the persistence dependency field in [initializeAuth()](./auth.md#initializeauth). | -| function(auth...) | -| [applyActionCode(auth, oobCode)](./auth.md#applyactioncode) | Applies a verification code sent to the user by email or other out-of-band mechanism. | -| [beforeAuthStateChanged(auth, callback, onAbort)](./auth.md#beforeauthstatechanged) | Adds a blocking callback that runs before an auth state change sets a new user. | -| [checkActionCode(auth, oobCode)](./auth.md#checkactioncode) | Checks a verification code sent to the user by email or other out-of-band mechanism. | -| [confirmPasswordReset(auth, oobCode, newPassword)](./auth.md#confirmpasswordreset) | Completes the password reset process, given a confirmation code and new password. | -| [connectAuthEmulator(auth, url, options)](./auth.md#connectauthemulator) | 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) | Creates a new user account associated with the specified email address and password. | -| [fetchSignInMethodsForEmail(auth, email)](./auth.md#fetchsigninmethodsforemail) | Gets the list of possible sign in methods for the given email address. | -| [getMultiFactorResolver(auth, error)](./auth.md#getmultifactorresolver) | Provides a [MultiFactorResolver](./auth.multifactorresolver.md#multifactorresolver_interface) suitable for completion of a multi-factor flow. | -| [getRedirectResult(auth, resolver)](./auth.md#getredirectresult) | Returns a [UserCredential](./auth.usercredential.md#usercredential_interface) from the redirect-based sign-in flow. | -| [initializeRecaptchaConfig(auth)](./auth.md#initializerecaptchaconfig) | Loads the reCAPTCHA configuration into the Auth instance. | -| [isSignInWithEmailLink(auth, emailLink)](./auth.md#issigninwithemaillink) | Checks if an incoming link is a sign-in with email link suitable for [signInWithEmailLink()](./auth.md#signinwithemaillink). | -| [onAuthStateChanged(auth, nextOrObserver, error, completed)](./auth.md#onauthstatechanged) | Adds an observer for changes to the user's sign-in state. | -| [onIdTokenChanged(auth, nextOrObserver, error, completed)](./auth.md#onidtokenchanged) | Adds an observer for changes to the signed-in user's ID token. | -| [sendPasswordResetEmail(auth, email, actionCodeSettings)](./auth.md#sendpasswordresetemail) | Sends a password reset email to the given email address. | -| [sendSignInLinkToEmail(auth, email, actionCodeSettings)](./auth.md#sendsigninlinktoemail) | Sends a sign-in email link to the user with the specified email. | -| [setPersistence(auth, persistence)](./auth.md#setpersistence) | Changes the type of persistence on the [Auth](./auth.auth.md#auth_interface) instance for the currently saved Auth session and applies this type of persistence for future sign-in requests, including sign-in with redirect requests. | -| [signInAnonymously(auth)](./auth.md#signinanonymously) | Asynchronously signs in as an anonymous user. | -| [signInWithCredential(auth, credential)](./auth.md#signinwithcredential) | Asynchronously signs in with the given credentials. | -| [signInWithCustomToken(auth, customToken)](./auth.md#signinwithcustomtoken) | Asynchronously signs in using a custom token. | -| [signInWithEmailAndPassword(auth, email, password)](./auth.md#signinwithemailandpassword) | Asynchronously signs in using an email and password. | -| [signInWithEmailLink(auth, email, emailLink)](./auth.md#signinwithemaillink) | Asynchronously signs in using an email and sign-in email link. | -| [signInWithPasskey(auth, name, manualSignUp)](./auth.md#signinwithpasskey) | Signs in a user with a passkey. Use enrollPasskey to enroll a passkey credential for the current user. | -| [signInWithPhoneNumber(auth, phoneNumber, appVerifier)](./auth.md#signinwithphonenumber) | Asynchronously signs in using a phone number. | -| [signInWithPopup(auth, provider, resolver)](./auth.md#signinwithpopup) | Authenticates a Firebase client using a popup-based OAuth authentication flow. | -| [signInWithRedirect(auth, provider, resolver)](./auth.md#signinwithredirect) | Authenticates a Firebase client using a full-page redirect flow. | -| [signOut(auth)](./auth.md#signout) | Signs out the current user. | -| [updateCurrentUser(auth, user)](./auth.md#updatecurrentuser) | 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#usedevicelanguage) | Sets the current language to the default device/browser preference. | -| [validatePassword(auth, password)](./auth.md#validatepassword) | Validates the password against the password policy configured for the project or tenant. | -| [verifyPasswordResetCode(auth, code)](./auth.md#verifypasswordresetcode) | Checks a password reset code sent to the user by email or other out-of-band mechanism. | -| function(link...) | -| [parseActionCodeURL(link)](./auth.md#parseactioncodeurl) | Parses the email action link string and returns an [ActionCodeURL](./auth.actioncodeurl.md#actioncodeurl_class) if the link is valid, otherwise returns null. | -| function(user...) | -| [deleteUser(user)](./auth.md#deleteuser) | Deletes and signs out the user. | -| [enrollPasskey(user, name)](./auth.md#enrollpasskey) | Enrolls a passkey for the user account. | -| [getIdToken(user, forceRefresh)](./auth.md#getidtoken) | Returns a JSON Web Token (JWT) used to identify the user to a Firebase service. | -| [getIdTokenResult(user, forceRefresh)](./auth.md#getidtokenresult) | Returns a deserialized JSON Web Token (JWT) used to identify the user to a Firebase service. | -| [linkWithCredential(user, credential)](./auth.md#linkwithcredential) | Links the user account with the given credentials. | -| [linkWithPhoneNumber(user, phoneNumber, appVerifier)](./auth.md#linkwithphonenumber) | Links the user account with the given phone number. | -| [linkWithPopup(user, provider, resolver)](./auth.md#linkwithpopup) | Links the authenticated provider to the user account using a pop-up based OAuth flow. | -| [linkWithRedirect(user, provider, resolver)](./auth.md#linkwithredirect) | Links the [OAuthProvider](./auth.oauthprovider.md#oauthprovider_class) to the user account using a full-page redirect flow. | -| [multiFactor(user)](./auth.md#multifactor) | The [MultiFactorUser](./auth.multifactoruser.md#multifactoruser_interface) corresponding to the user. | -| [reauthenticateWithCredential(user, credential)](./auth.md#reauthenticatewithcredential) | Re-authenticates a user using a fresh credential. | -| [reauthenticateWithPhoneNumber(user, phoneNumber, appVerifier)](./auth.md#reauthenticatewithphonenumber) | Re-authenticates a user using a fresh phone credential. | -| [reauthenticateWithPopup(user, provider, resolver)](./auth.md#reauthenticatewithpopup) | Reauthenticates the current user with the specified [OAuthProvider](./auth.oauthprovider.md#oauthprovider_class) using a pop-up based OAuth flow. | -| [reauthenticateWithRedirect(user, provider, resolver)](./auth.md#reauthenticatewithredirect) | Reauthenticates the current user with the specified [OAuthProvider](./auth.oauthprovider.md#oauthprovider_class) using a full-page redirect flow. | -| [reload(user)](./auth.md#reload) | Reloads user account data, if signed in. | -| [sendEmailVerification(user, actionCodeSettings)](./auth.md#sendemailverification) | Sends a verification email to a user. | -| [unenrollPasskey(user, credentialId)](./auth.md#unenrollpasskey) | Unenrolls the passkey corresponding to the specified credentialId. | -| [unlink(user, providerId)](./auth.md#unlink) | Unlinks a provider from a user account. | -| [updateEmail(user, newEmail)](./auth.md#updateemail) | Updates the user's email address. | -| [updatePassword(user, newPassword)](./auth.md#updatepassword) | Updates the user's password. | -| [updatePhoneNumber(user, credential)](./auth.md#updatephonenumber) | Updates the user's phone number. | -| [updateProfile(user, { displayName, photoURL: photoUrl })](./auth.md#updateprofile) | Updates a user's profile data. | -| [verifyBeforeUpdateEmail(user, newEmail, actionCodeSettings)](./auth.md#verifybeforeupdateemail) | Sends a verification email to a new email address. | -| function(userCredential...) | -| [getAdditionalUserInfo(userCredential)](./auth.md#getadditionaluserinfo) | Extracts provider specific [AdditionalUserInfo](./auth.additionaluserinfo.md#additionaluserinfo_interface) for the given credential. | +| function(app, ...) | +| [getAuth(app)](./auth.md#getauth_cf608e1) | Returns the Auth instance associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes an Auth instance with platform-specific default dependencies. | +| [initializeAuth(app, deps)](./auth.md#initializeauth_ca77c9b) | Initializes an [Auth](./auth.auth.md#auth_interface) instance with fine-grained control over [Dependencies](./auth.dependencies.md#dependencies_interface). | +| function(storage, ...) | +| [getReactNativePersistence(storage)](./auth.md#getreactnativepersistence_bab4ada) | Returns a persistence object that wraps AsyncStorage imported from react-native or @react-native-community/async-storage, and can be used in the persistence dependency field in [initializeAuth()](./auth.md#initializeauth_ca77c9b). | +| function(auth, ...) | +| [applyActionCode(auth, oobCode)](./auth.md#applyactioncode_d2ae15a) | Applies a verification code sent to the user by email or other out-of-band mechanism. | +| [beforeAuthStateChanged(auth, callback, onAbort)](./auth.md#beforeauthstatechanged_22f2ab6) | Adds a blocking callback that runs before an auth state change sets a new user. | +| [checkActionCode(auth, oobCode)](./auth.md#checkactioncode_d2ae15a) | Checks a verification code sent to the user by email or other out-of-band mechanism. | +| [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. | +| [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. | +| [initializeRecaptchaConfig(auth)](./auth.md#initializerecaptchaconfig_2a61ea7) | Loads the reCAPTCHA configuration into the Auth instance. | +| [isSignInWithEmailLink(auth, emailLink)](./auth.md#issigninwithemaillink_db04f1d) | Checks if an incoming link is a sign-in with email link suitable for [signInWithEmailLink()](./auth.md#signinwithemaillink_ed14c53). | +| [onAuthStateChanged(auth, nextOrObserver, error, completed)](./auth.md#onauthstatechanged_b0d07ab) | Adds an observer for changes to the user's sign-in state. | +| [onIdTokenChanged(auth, nextOrObserver, error, completed)](./auth.md#onidtokenchanged_b0d07ab) | Adds an observer for changes to the signed-in user's ID token. | +| [revokeAccessToken(auth, token)](./auth.md#revokeaccesstoken_5556ad5) | Revokes the given access token. Currently only supports Apple OAuth access tokens. | +| [sendPasswordResetEmail(auth, email, actionCodeSettings)](./auth.md#sendpasswordresetemail_95b079b) | Sends a password reset email to the given email address. This method does not throw an error when there's no user account with the given email address and \[Email Enumeration Protection\](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled. | +| [sendSignInLinkToEmail(auth, email, actionCodeSettings)](./auth.md#sendsigninlinktoemail_95b079b) | Sends a sign-in email link to the user with the specified email. | +| [setPersistence(auth, persistence)](./auth.md#setpersistence_a3592ac) | Changes the type of persistence on the [Auth](./auth.auth.md#auth_interface) instance for the currently saved Auth session and applies this type of persistence for future sign-in requests, including sign-in with redirect requests. | +| [signInAnonymously(auth)](./auth.md#signinanonymously_2a61ea7) | Asynchronously signs in as an anonymous user. | +| [signInWithCredential(auth, credential)](./auth.md#signinwithcredential_8074518) | Asynchronously signs in with the given credentials. | +| [signInWithCustomToken(auth, customToken)](./auth.md#signinwithcustomtoken_32af683) | Asynchronously signs in using a custom token. | +| [signInWithEmailAndPassword(auth, email, password)](./auth.md#signinwithemailandpassword_21ad33b) | Asynchronously signs in using an email and password. | +| [signInWithEmailLink(auth, email, emailLink)](./auth.md#signinwithemaillink_ed14c53) | Asynchronously signs in using an email and sign-in email link. | +| [signInWithPasskey(auth, name, manualSignUp)](./auth.md#signinwithpasskey_d080044) | Signs in a user with a passkey. Use enrollPasskey to enroll a passkey credential for the current user. | +| [signInWithPhoneNumber(auth, phoneNumber, appVerifier)](./auth.md#signinwithphonenumber_75b2560) | Asynchronously signs in using a phone number. | +| [signInWithPopup(auth, provider, resolver)](./auth.md#signinwithpopup_770f816) | Authenticates a Firebase client using a popup-based OAuth authentication flow. | +| [signInWithRedirect(auth, provider, resolver)](./auth.md#signinwithredirect_770f816) | Authenticates a Firebase client using a full-page redirect flow. | +| [signOut(auth)](./auth.md#signout_2a61ea7) | Signs out the current user. | +| [updateCurrentUser(auth, user)](./auth.md#updatecurrentuser_9d96fff) | 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#usedevicelanguage_2a61ea7) | Sets the current language to the default device/browser preference. | +| [validatePassword(auth, password)](./auth.md#validatepassword_4dc4ad2) | Validates the password against the password policy configured for the project or tenant. | +| [verifyPasswordResetCode(auth, code)](./auth.md#verifypasswordresetcode_01e0a1a) | Checks a password reset code sent to the user by email or other out-of-band mechanism. | +| function(link, ...) | +| [parseActionCodeURL(link)](./auth.md#parseactioncodeurl_51293c3) | Parses the email action link string and returns an [ActionCodeURL](./auth.actioncodeurl.md#actioncodeurl_class) if the link is valid, otherwise returns null. | +| function(user, ...) | +| [deleteUser(user)](./auth.md#deleteuser_52b2e2e) | Deletes and signs out the user. | +| [enrollPasskey(user, name)](./auth.md#enrollpasskey_746f229) | Enrolls a passkey for the user account. | +| [getIdToken(user, forceRefresh)](./auth.md#getidtoken_ce7d429) | Returns a JSON Web Token (JWT) used to identify the user to a Firebase service. | +| [getIdTokenResult(user, forceRefresh)](./auth.md#getidtokenresult_ce7d429) | Returns a deserialized JSON Web Token (JWT) used to identify the user to a Firebase service. | +| [linkWithCredential(user, credential)](./auth.md#linkwithcredential_60f8043) | Links the user account with the given credentials. | +| [linkWithPhoneNumber(user, phoneNumber, appVerifier)](./auth.md#linkwithphonenumber_9ed75fe) | Links the user account with the given phone number. | +| [linkWithPopup(user, provider, resolver)](./auth.md#linkwithpopup_41c0b31) | Links the authenticated provider to the user account using a pop-up based OAuth flow. | +| [linkWithRedirect(user, provider, resolver)](./auth.md#linkwithredirect_41c0b31) | Links the [OAuthProvider](./auth.oauthprovider.md#oauthprovider_class) to the user account using a full-page redirect flow. | +| [multiFactor(user)](./auth.md#multifactor_52b2e2e) | The [MultiFactorUser](./auth.multifactoruser.md#multifactoruser_interface) corresponding to the user. | +| [reauthenticateWithCredential(user, credential)](./auth.md#reauthenticatewithcredential_60f8043) | Re-authenticates a user using a fresh credential. | +| [reauthenticateWithPhoneNumber(user, phoneNumber, appVerifier)](./auth.md#reauthenticatewithphonenumber_9ed75fe) | Re-authenticates a user using a fresh phone credential. | +| [reauthenticateWithPopup(user, provider, resolver)](./auth.md#reauthenticatewithpopup_41c0b31) | Reauthenticates the current user with the specified [OAuthProvider](./auth.oauthprovider.md#oauthprovider_class) using a pop-up based OAuth flow. | +| [reauthenticateWithRedirect(user, provider, resolver)](./auth.md#reauthenticatewithredirect_41c0b31) | Reauthenticates the current user with the specified [OAuthProvider](./auth.oauthprovider.md#oauthprovider_class) using a full-page redirect flow. | +| [reload(user)](./auth.md#reload_52b2e2e) | Reloads user account data, if signed in. | +| [sendEmailVerification(user, actionCodeSettings)](./auth.md#sendemailverification_6a885d6) | Sends a verification email to a user. | +| [unenrollPasskey(user, credentialId)](./auth.md#unenrollpasskey_d726b9b) | Unenrolls the passkey corresponding to the specified credentialId. | +| [unlink(user, providerId)](./auth.md#unlink_f289a14) | Unlinks a provider from a user account. | +| [updateEmail(user, newEmail)](./auth.md#updateemail_7737d57) | Updates the user's email address. | +| [updatePassword(user, newPassword)](./auth.md#updatepassword_6df673e) | Updates the user's password. | +| [updatePhoneNumber(user, credential)](./auth.md#updatephonenumber_0105c49) | Updates the user's phone number. | +| [updateProfile(user, { displayName, photoURL: photoUrl })](./auth.md#updateprofile_017e12d) | Updates a user's profile data. | +| [verifyBeforeUpdateEmail(user, newEmail, actionCodeSettings)](./auth.md#verifybeforeupdateemail_09d6f11) | Sends a verification email to a new email address. | +| function(userCredential, ...) | +| [getAdditionalUserInfo(userCredential)](./auth.md#getadditionaluserinfo_838a6bd) | Extracts provider specific [AdditionalUserInfo](./auth.additionaluserinfo.md#additionaluserinfo_interface) for the given credential. | ## Classes @@ -920,8 +921,7 @@ if(isSignInWithEmailLink(auth, emailLink)) { ``` -### signInWithPhoneNumber(auth, phoneNumber, appVerifier) {:#signinwithphonenumber_75b2560} -## signInWithPasskey() +### signInWithPasskey(auth, name, manualSignUp) {:#signinwithpasskey_d080044} Signs in a user with a passkey. Use enrollPasskey to enroll a passkey credential for the current user. @@ -931,7 +931,7 @@ Signs in a user with a passkey. Use enrollPasskey to enroll a passkey credential export declare function signInWithPasskey(auth: Auth, name: string, manualSignUp?: boolean): Promise; ``` -### Parameters +#### Parameters | Parameter | Type | Description | | --- | --- | --- | @@ -945,7 +945,7 @@ Promise<[UserCredential](./auth.usercredential.md#usercredential_interface); Promise<void> -### getIdToken(user, forceRefresh) {:#getidtoken_ce7d429} -## enrollPasskey() +### enrollPasskey(user, name) {:#enrollpasskey_746f229} Enrolls a passkey for the user account. @@ -1265,7 +1264,7 @@ Enrolls a passkey for the user account. export declare function enrollPasskey(user: User, name: string): Promise; ``` -### Parameters +#### Parameters | Parameter | Type | Description | | --- | --- | --- | @@ -1278,7 +1277,7 @@ Promise<[UserCredential](./auth.usercredential.md#usercredential_interface); ``` -### Parameters +#### Parameters | Parameter | Type | Description | | --- | --- | --- | @@ -1697,7 +1695,7 @@ Promise<void> A promise that resolves when the passkey is successfully unenrolled. -## unlink() +### unlink(user, providerId) {:#unlink_f289a14} Unlinks a provider from a user account. diff --git a/docs-devsite/auth.user.md b/docs-devsite/auth.user.md index 090b9873433..3036573923f 100644 --- a/docs-devsite/auth.user.md +++ b/docs-devsite/auth.user.md @@ -23,7 +23,7 @@ export interface User extends UserInfo | Property | Type | Description | | --- | --- | --- | -| [emailVerified](./auth.user.md#useremailverified) | boolean | Whether the email has been verified with [sendEmailVerification()](./auth.md#sendemailverification) and [applyActionCode()](./auth.md#applyactioncode). | +| [emailVerified](./auth.user.md#useremailverified) | boolean | Whether the email has been verified with [sendEmailVerification()](./auth.md#sendemailverification_6a885d6) and [applyActionCode()](./auth.md#applyactioncode_d2ae15a). | | [enrolledPasskeys](./auth.user.md#userenrolledpasskeys) | [PasskeyInfo](./auth.passkeyinfo.md#passkeyinfo_interface)\[\] | An array of PasskeyInfo objects representing the passkeys that the user has enrolled. | | [isAnonymous](./auth.user.md#userisanonymous) | boolean | Whether the user is authenticated using the [ProviderId](./auth.md#providerid).ANONYMOUS provider. | | [metadata](./auth.user.md#usermetadata) | [UserMetadata](./auth.usermetadata.md#usermetadata_interface) | Additional metadata around user creation and sign-in times. | From 894882f334485ca5bbb1bf84b22b36de7438ae12 Mon Sep 17 00:00:00 2001 From: renkelvin Date: Tue, 16 Apr 2024 23:19:02 -0700 Subject: [PATCH 4/6] Revert "doc fix" This reverts commit 0b8bed7b1e824fe97bcae6f237a12477038997ec. --- docs-devsite/auth.md | 148 +++++++++++++++++++------------------- docs-devsite/auth.user.md | 2 +- 2 files changed, 76 insertions(+), 74 deletions(-) diff --git a/docs-devsite/auth.md b/docs-devsite/auth.md index 992c13aea1d..aa372eee5a9 100644 --- a/docs-devsite/auth.md +++ b/docs-devsite/auth.md @@ -16,70 +16,69 @@ Firebase Authentication | Function | Description | | --- | --- | -| function(app, ...) | -| [getAuth(app)](./auth.md#getauth_cf608e1) | Returns the Auth instance associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes an Auth instance with platform-specific default dependencies. | -| [initializeAuth(app, deps)](./auth.md#initializeauth_ca77c9b) | Initializes an [Auth](./auth.auth.md#auth_interface) instance with fine-grained control over [Dependencies](./auth.dependencies.md#dependencies_interface). | -| function(storage, ...) | -| [getReactNativePersistence(storage)](./auth.md#getreactnativepersistence_bab4ada) | Returns a persistence object that wraps AsyncStorage imported from react-native or @react-native-community/async-storage, and can be used in the persistence dependency field in [initializeAuth()](./auth.md#initializeauth_ca77c9b). | -| function(auth, ...) | -| [applyActionCode(auth, oobCode)](./auth.md#applyactioncode_d2ae15a) | Applies a verification code sent to the user by email or other out-of-band mechanism. | -| [beforeAuthStateChanged(auth, callback, onAbort)](./auth.md#beforeauthstatechanged_22f2ab6) | Adds a blocking callback that runs before an auth state change sets a new user. | -| [checkActionCode(auth, oobCode)](./auth.md#checkactioncode_d2ae15a) | Checks a verification code sent to the user by email or other out-of-band mechanism. | -| [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. | -| [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. | -| [initializeRecaptchaConfig(auth)](./auth.md#initializerecaptchaconfig_2a61ea7) | Loads the reCAPTCHA configuration into the Auth instance. | -| [isSignInWithEmailLink(auth, emailLink)](./auth.md#issigninwithemaillink_db04f1d) | Checks if an incoming link is a sign-in with email link suitable for [signInWithEmailLink()](./auth.md#signinwithemaillink_ed14c53). | -| [onAuthStateChanged(auth, nextOrObserver, error, completed)](./auth.md#onauthstatechanged_b0d07ab) | Adds an observer for changes to the user's sign-in state. | -| [onIdTokenChanged(auth, nextOrObserver, error, completed)](./auth.md#onidtokenchanged_b0d07ab) | Adds an observer for changes to the signed-in user's ID token. | -| [revokeAccessToken(auth, token)](./auth.md#revokeaccesstoken_5556ad5) | Revokes the given access token. Currently only supports Apple OAuth access tokens. | -| [sendPasswordResetEmail(auth, email, actionCodeSettings)](./auth.md#sendpasswordresetemail_95b079b) | Sends a password reset email to the given email address. This method does not throw an error when there's no user account with the given email address and \[Email Enumeration Protection\](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled. | -| [sendSignInLinkToEmail(auth, email, actionCodeSettings)](./auth.md#sendsigninlinktoemail_95b079b) | Sends a sign-in email link to the user with the specified email. | -| [setPersistence(auth, persistence)](./auth.md#setpersistence_a3592ac) | Changes the type of persistence on the [Auth](./auth.auth.md#auth_interface) instance for the currently saved Auth session and applies this type of persistence for future sign-in requests, including sign-in with redirect requests. | -| [signInAnonymously(auth)](./auth.md#signinanonymously_2a61ea7) | Asynchronously signs in as an anonymous user. | -| [signInWithCredential(auth, credential)](./auth.md#signinwithcredential_8074518) | Asynchronously signs in with the given credentials. | -| [signInWithCustomToken(auth, customToken)](./auth.md#signinwithcustomtoken_32af683) | Asynchronously signs in using a custom token. | -| [signInWithEmailAndPassword(auth, email, password)](./auth.md#signinwithemailandpassword_21ad33b) | Asynchronously signs in using an email and password. | -| [signInWithEmailLink(auth, email, emailLink)](./auth.md#signinwithemaillink_ed14c53) | Asynchronously signs in using an email and sign-in email link. | -| [signInWithPasskey(auth, name, manualSignUp)](./auth.md#signinwithpasskey_d080044) | Signs in a user with a passkey. Use enrollPasskey to enroll a passkey credential for the current user. | -| [signInWithPhoneNumber(auth, phoneNumber, appVerifier)](./auth.md#signinwithphonenumber_75b2560) | Asynchronously signs in using a phone number. | -| [signInWithPopup(auth, provider, resolver)](./auth.md#signinwithpopup_770f816) | Authenticates a Firebase client using a popup-based OAuth authentication flow. | -| [signInWithRedirect(auth, provider, resolver)](./auth.md#signinwithredirect_770f816) | Authenticates a Firebase client using a full-page redirect flow. | -| [signOut(auth)](./auth.md#signout_2a61ea7) | Signs out the current user. | -| [updateCurrentUser(auth, user)](./auth.md#updatecurrentuser_9d96fff) | 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#usedevicelanguage_2a61ea7) | Sets the current language to the default device/browser preference. | -| [validatePassword(auth, password)](./auth.md#validatepassword_4dc4ad2) | Validates the password against the password policy configured for the project or tenant. | -| [verifyPasswordResetCode(auth, code)](./auth.md#verifypasswordresetcode_01e0a1a) | Checks a password reset code sent to the user by email or other out-of-band mechanism. | -| function(link, ...) | -| [parseActionCodeURL(link)](./auth.md#parseactioncodeurl_51293c3) | Parses the email action link string and returns an [ActionCodeURL](./auth.actioncodeurl.md#actioncodeurl_class) if the link is valid, otherwise returns null. | -| function(user, ...) | -| [deleteUser(user)](./auth.md#deleteuser_52b2e2e) | Deletes and signs out the user. | -| [enrollPasskey(user, name)](./auth.md#enrollpasskey_746f229) | Enrolls a passkey for the user account. | -| [getIdToken(user, forceRefresh)](./auth.md#getidtoken_ce7d429) | Returns a JSON Web Token (JWT) used to identify the user to a Firebase service. | -| [getIdTokenResult(user, forceRefresh)](./auth.md#getidtokenresult_ce7d429) | Returns a deserialized JSON Web Token (JWT) used to identify the user to a Firebase service. | -| [linkWithCredential(user, credential)](./auth.md#linkwithcredential_60f8043) | Links the user account with the given credentials. | -| [linkWithPhoneNumber(user, phoneNumber, appVerifier)](./auth.md#linkwithphonenumber_9ed75fe) | Links the user account with the given phone number. | -| [linkWithPopup(user, provider, resolver)](./auth.md#linkwithpopup_41c0b31) | Links the authenticated provider to the user account using a pop-up based OAuth flow. | -| [linkWithRedirect(user, provider, resolver)](./auth.md#linkwithredirect_41c0b31) | Links the [OAuthProvider](./auth.oauthprovider.md#oauthprovider_class) to the user account using a full-page redirect flow. | -| [multiFactor(user)](./auth.md#multifactor_52b2e2e) | The [MultiFactorUser](./auth.multifactoruser.md#multifactoruser_interface) corresponding to the user. | -| [reauthenticateWithCredential(user, credential)](./auth.md#reauthenticatewithcredential_60f8043) | Re-authenticates a user using a fresh credential. | -| [reauthenticateWithPhoneNumber(user, phoneNumber, appVerifier)](./auth.md#reauthenticatewithphonenumber_9ed75fe) | Re-authenticates a user using a fresh phone credential. | -| [reauthenticateWithPopup(user, provider, resolver)](./auth.md#reauthenticatewithpopup_41c0b31) | Reauthenticates the current user with the specified [OAuthProvider](./auth.oauthprovider.md#oauthprovider_class) using a pop-up based OAuth flow. | -| [reauthenticateWithRedirect(user, provider, resolver)](./auth.md#reauthenticatewithredirect_41c0b31) | Reauthenticates the current user with the specified [OAuthProvider](./auth.oauthprovider.md#oauthprovider_class) using a full-page redirect flow. | -| [reload(user)](./auth.md#reload_52b2e2e) | Reloads user account data, if signed in. | -| [sendEmailVerification(user, actionCodeSettings)](./auth.md#sendemailverification_6a885d6) | Sends a verification email to a user. | -| [unenrollPasskey(user, credentialId)](./auth.md#unenrollpasskey_d726b9b) | Unenrolls the passkey corresponding to the specified credentialId. | -| [unlink(user, providerId)](./auth.md#unlink_f289a14) | Unlinks a provider from a user account. | -| [updateEmail(user, newEmail)](./auth.md#updateemail_7737d57) | Updates the user's email address. | -| [updatePassword(user, newPassword)](./auth.md#updatepassword_6df673e) | Updates the user's password. | -| [updatePhoneNumber(user, credential)](./auth.md#updatephonenumber_0105c49) | Updates the user's phone number. | -| [updateProfile(user, { displayName, photoURL: photoUrl })](./auth.md#updateprofile_017e12d) | Updates a user's profile data. | -| [verifyBeforeUpdateEmail(user, newEmail, actionCodeSettings)](./auth.md#verifybeforeupdateemail_09d6f11) | Sends a verification email to a new email address. | -| function(userCredential, ...) | -| [getAdditionalUserInfo(userCredential)](./auth.md#getadditionaluserinfo_838a6bd) | Extracts provider specific [AdditionalUserInfo](./auth.additionaluserinfo.md#additionaluserinfo_interface) for the given credential. | +| function(app...) | +| [getAuth(app)](./auth.md#getauth) | Returns the Auth instance associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface). If no instance exists, initializes an Auth instance with platform-specific default dependencies. | +| [initializeAuth(app, deps)](./auth.md#initializeauth) | Initializes an [Auth](./auth.auth.md#auth_interface) instance with fine-grained control over [Dependencies](./auth.dependencies.md#dependencies_interface). | +| function(storage...) | +| [getReactNativePersistence(storage)](./auth.md#getreactnativepersistence) | Returns a persistence object that wraps AsyncStorage imported from react-native or @react-native-community/async-storage, and can be used in the persistence dependency field in [initializeAuth()](./auth.md#initializeauth). | +| function(auth...) | +| [applyActionCode(auth, oobCode)](./auth.md#applyactioncode) | Applies a verification code sent to the user by email or other out-of-band mechanism. | +| [beforeAuthStateChanged(auth, callback, onAbort)](./auth.md#beforeauthstatechanged) | Adds a blocking callback that runs before an auth state change sets a new user. | +| [checkActionCode(auth, oobCode)](./auth.md#checkactioncode) | Checks a verification code sent to the user by email or other out-of-band mechanism. | +| [confirmPasswordReset(auth, oobCode, newPassword)](./auth.md#confirmpasswordreset) | Completes the password reset process, given a confirmation code and new password. | +| [connectAuthEmulator(auth, url, options)](./auth.md#connectauthemulator) | 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) | Creates a new user account associated with the specified email address and password. | +| [fetchSignInMethodsForEmail(auth, email)](./auth.md#fetchsigninmethodsforemail) | Gets the list of possible sign in methods for the given email address. | +| [getMultiFactorResolver(auth, error)](./auth.md#getmultifactorresolver) | Provides a [MultiFactorResolver](./auth.multifactorresolver.md#multifactorresolver_interface) suitable for completion of a multi-factor flow. | +| [getRedirectResult(auth, resolver)](./auth.md#getredirectresult) | Returns a [UserCredential](./auth.usercredential.md#usercredential_interface) from the redirect-based sign-in flow. | +| [initializeRecaptchaConfig(auth)](./auth.md#initializerecaptchaconfig) | Loads the reCAPTCHA configuration into the Auth instance. | +| [isSignInWithEmailLink(auth, emailLink)](./auth.md#issigninwithemaillink) | Checks if an incoming link is a sign-in with email link suitable for [signInWithEmailLink()](./auth.md#signinwithemaillink). | +| [onAuthStateChanged(auth, nextOrObserver, error, completed)](./auth.md#onauthstatechanged) | Adds an observer for changes to the user's sign-in state. | +| [onIdTokenChanged(auth, nextOrObserver, error, completed)](./auth.md#onidtokenchanged) | Adds an observer for changes to the signed-in user's ID token. | +| [sendPasswordResetEmail(auth, email, actionCodeSettings)](./auth.md#sendpasswordresetemail) | Sends a password reset email to the given email address. | +| [sendSignInLinkToEmail(auth, email, actionCodeSettings)](./auth.md#sendsigninlinktoemail) | Sends a sign-in email link to the user with the specified email. | +| [setPersistence(auth, persistence)](./auth.md#setpersistence) | Changes the type of persistence on the [Auth](./auth.auth.md#auth_interface) instance for the currently saved Auth session and applies this type of persistence for future sign-in requests, including sign-in with redirect requests. | +| [signInAnonymously(auth)](./auth.md#signinanonymously) | Asynchronously signs in as an anonymous user. | +| [signInWithCredential(auth, credential)](./auth.md#signinwithcredential) | Asynchronously signs in with the given credentials. | +| [signInWithCustomToken(auth, customToken)](./auth.md#signinwithcustomtoken) | Asynchronously signs in using a custom token. | +| [signInWithEmailAndPassword(auth, email, password)](./auth.md#signinwithemailandpassword) | Asynchronously signs in using an email and password. | +| [signInWithEmailLink(auth, email, emailLink)](./auth.md#signinwithemaillink) | Asynchronously signs in using an email and sign-in email link. | +| [signInWithPasskey(auth, name, manualSignUp)](./auth.md#signinwithpasskey) | Signs in a user with a passkey. Use enrollPasskey to enroll a passkey credential for the current user. | +| [signInWithPhoneNumber(auth, phoneNumber, appVerifier)](./auth.md#signinwithphonenumber) | Asynchronously signs in using a phone number. | +| [signInWithPopup(auth, provider, resolver)](./auth.md#signinwithpopup) | Authenticates a Firebase client using a popup-based OAuth authentication flow. | +| [signInWithRedirect(auth, provider, resolver)](./auth.md#signinwithredirect) | Authenticates a Firebase client using a full-page redirect flow. | +| [signOut(auth)](./auth.md#signout) | Signs out the current user. | +| [updateCurrentUser(auth, user)](./auth.md#updatecurrentuser) | 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#usedevicelanguage) | Sets the current language to the default device/browser preference. | +| [validatePassword(auth, password)](./auth.md#validatepassword) | Validates the password against the password policy configured for the project or tenant. | +| [verifyPasswordResetCode(auth, code)](./auth.md#verifypasswordresetcode) | Checks a password reset code sent to the user by email or other out-of-band mechanism. | +| function(link...) | +| [parseActionCodeURL(link)](./auth.md#parseactioncodeurl) | Parses the email action link string and returns an [ActionCodeURL](./auth.actioncodeurl.md#actioncodeurl_class) if the link is valid, otherwise returns null. | +| function(user...) | +| [deleteUser(user)](./auth.md#deleteuser) | Deletes and signs out the user. | +| [enrollPasskey(user, name)](./auth.md#enrollpasskey) | Enrolls a passkey for the user account. | +| [getIdToken(user, forceRefresh)](./auth.md#getidtoken) | Returns a JSON Web Token (JWT) used to identify the user to a Firebase service. | +| [getIdTokenResult(user, forceRefresh)](./auth.md#getidtokenresult) | Returns a deserialized JSON Web Token (JWT) used to identify the user to a Firebase service. | +| [linkWithCredential(user, credential)](./auth.md#linkwithcredential) | Links the user account with the given credentials. | +| [linkWithPhoneNumber(user, phoneNumber, appVerifier)](./auth.md#linkwithphonenumber) | Links the user account with the given phone number. | +| [linkWithPopup(user, provider, resolver)](./auth.md#linkwithpopup) | Links the authenticated provider to the user account using a pop-up based OAuth flow. | +| [linkWithRedirect(user, provider, resolver)](./auth.md#linkwithredirect) | Links the [OAuthProvider](./auth.oauthprovider.md#oauthprovider_class) to the user account using a full-page redirect flow. | +| [multiFactor(user)](./auth.md#multifactor) | The [MultiFactorUser](./auth.multifactoruser.md#multifactoruser_interface) corresponding to the user. | +| [reauthenticateWithCredential(user, credential)](./auth.md#reauthenticatewithcredential) | Re-authenticates a user using a fresh credential. | +| [reauthenticateWithPhoneNumber(user, phoneNumber, appVerifier)](./auth.md#reauthenticatewithphonenumber) | Re-authenticates a user using a fresh phone credential. | +| [reauthenticateWithPopup(user, provider, resolver)](./auth.md#reauthenticatewithpopup) | Reauthenticates the current user with the specified [OAuthProvider](./auth.oauthprovider.md#oauthprovider_class) using a pop-up based OAuth flow. | +| [reauthenticateWithRedirect(user, provider, resolver)](./auth.md#reauthenticatewithredirect) | Reauthenticates the current user with the specified [OAuthProvider](./auth.oauthprovider.md#oauthprovider_class) using a full-page redirect flow. | +| [reload(user)](./auth.md#reload) | Reloads user account data, if signed in. | +| [sendEmailVerification(user, actionCodeSettings)](./auth.md#sendemailverification) | Sends a verification email to a user. | +| [unenrollPasskey(user, credentialId)](./auth.md#unenrollpasskey) | Unenrolls the passkey corresponding to the specified credentialId. | +| [unlink(user, providerId)](./auth.md#unlink) | Unlinks a provider from a user account. | +| [updateEmail(user, newEmail)](./auth.md#updateemail) | Updates the user's email address. | +| [updatePassword(user, newPassword)](./auth.md#updatepassword) | Updates the user's password. | +| [updatePhoneNumber(user, credential)](./auth.md#updatephonenumber) | Updates the user's phone number. | +| [updateProfile(user, { displayName, photoURL: photoUrl })](./auth.md#updateprofile) | Updates a user's profile data. | +| [verifyBeforeUpdateEmail(user, newEmail, actionCodeSettings)](./auth.md#verifybeforeupdateemail) | Sends a verification email to a new email address. | +| function(userCredential...) | +| [getAdditionalUserInfo(userCredential)](./auth.md#getadditionaluserinfo) | Extracts provider specific [AdditionalUserInfo](./auth.additionaluserinfo.md#additionaluserinfo_interface) for the given credential. | ## Classes @@ -921,7 +920,8 @@ if(isSignInWithEmailLink(auth, emailLink)) { ``` -### signInWithPasskey(auth, name, manualSignUp) {:#signinwithpasskey_d080044} +### signInWithPhoneNumber(auth, phoneNumber, appVerifier) {:#signinwithphonenumber_75b2560} +## signInWithPasskey() Signs in a user with a passkey. Use enrollPasskey to enroll a passkey credential for the current user. @@ -931,7 +931,7 @@ Signs in a user with a passkey. Use enrollPasskey to enroll a passkey credential export declare function signInWithPasskey(auth: Auth, name: string, manualSignUp?: boolean): Promise; ``` -#### Parameters +### Parameters | Parameter | Type | Description | | --- | --- | --- | @@ -945,7 +945,7 @@ Promise<[UserCredential](./auth.usercredential.md#usercredential_interface); Promise<void> -### enrollPasskey(user, name) {:#enrollpasskey_746f229} +### getIdToken(user, forceRefresh) {:#getidtoken_ce7d429} +## enrollPasskey() Enrolls a passkey for the user account. @@ -1264,7 +1265,7 @@ Enrolls a passkey for the user account. export declare function enrollPasskey(user: User, name: string): Promise; ``` -#### Parameters +### Parameters | Parameter | Type | Description | | --- | --- | --- | @@ -1277,7 +1278,7 @@ Promise<[UserCredential](./auth.usercredential.md#usercredential_interface); ``` -#### Parameters +### Parameters | Parameter | Type | Description | | --- | --- | --- | @@ -1695,7 +1697,7 @@ Promise<void> A promise that resolves when the passkey is successfully unenrolled. -### unlink(user, providerId) {:#unlink_f289a14} +## unlink() Unlinks a provider from a user account. diff --git a/docs-devsite/auth.user.md b/docs-devsite/auth.user.md index 3036573923f..090b9873433 100644 --- a/docs-devsite/auth.user.md +++ b/docs-devsite/auth.user.md @@ -23,7 +23,7 @@ export interface User extends UserInfo | Property | Type | Description | | --- | --- | --- | -| [emailVerified](./auth.user.md#useremailverified) | boolean | Whether the email has been verified with [sendEmailVerification()](./auth.md#sendemailverification_6a885d6) and [applyActionCode()](./auth.md#applyactioncode_d2ae15a). | +| [emailVerified](./auth.user.md#useremailverified) | boolean | Whether the email has been verified with [sendEmailVerification()](./auth.md#sendemailverification) and [applyActionCode()](./auth.md#applyactioncode). | | [enrolledPasskeys](./auth.user.md#userenrolledpasskeys) | [PasskeyInfo](./auth.passkeyinfo.md#passkeyinfo_interface)\[\] | An array of PasskeyInfo objects representing the passkeys that the user has enrolled. | | [isAnonymous](./auth.user.md#userisanonymous) | boolean | Whether the user is authenticated using the [ProviderId](./auth.md#providerid).ANONYMOUS provider. | | [metadata](./auth.user.md#usermetadata) | [UserMetadata](./auth.usermetadata.md#usermetadata_interface) | Additional metadata around user creation and sign-in times. | From 70d61c9c076cda3470f0311184d62859d2cd9127 Mon Sep 17 00:00:00 2001 From: renkelvin Date: Tue, 16 Apr 2024 23:19:13 -0700 Subject: [PATCH 5/6] Revert "`yarn docgen devsite`" This reverts commit 81880caa00b699dc0dfeb3b30534c7c8d24a4a11. --- common/api-review/auth.api.md | 28 +++++++++++----------------- packages/auth/api-extractor.json | 2 +- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/common/api-review/auth.api.md b/common/api-review/auth.api.md index ecc44f26207..03b62334d96 100644 --- a/common/api-review/auth.api.md +++ b/common/api-review/auth.api.md @@ -104,14 +104,14 @@ export class AuthCredential { protected constructor( providerId: string, signInMethod: string); - // Warning: (ae-forgotten-export) The symbol "AuthInternal" needs to be exported by the entry point index.doc.d.ts - // Warning: (ae-forgotten-export) The symbol "PhoneOrOauthTokenResponse" needs to be exported by the entry point index.doc.d.ts + // Warning: (ae-forgotten-export) The symbol "AuthInternal" needs to be exported by the entry point index.d.ts + // Warning: (ae-forgotten-export) The symbol "PhoneOrOauthTokenResponse" needs to be exported by the entry point index.d.ts // // @internal (undocumented) _getIdTokenResponse(_auth: AuthInternal): Promise; // @internal (undocumented) _getReauthenticationResolver(_auth: AuthInternal): Promise; - // Warning: (ae-forgotten-export) The symbol "IdTokenResponse" needs to be exported by the entry point index.doc.d.ts + // Warning: (ae-forgotten-export) The symbol "IdTokenResponse" needs to be exported by the entry point index.d.ts // // @internal (undocumented) _linkToIdToken(_auth: AuthInternal, _idToken: string): Promise; @@ -293,9 +293,6 @@ export function connectAuthEmulator(auth: Auth, url: string, options?: { disableWarnings: boolean; }): void; -// @public -export const cordovaPopupRedirectResolver: PopupRedirectResolver; - // @public export function createUserWithEmailAndPassword(auth: Auth, email: string, password: string): Promise; @@ -362,7 +359,7 @@ export function enrollPasskey(user: User, name: string): Promise export { ErrorFn } -// Warning: (ae-forgotten-export) The symbol "BaseOAuthProvider" needs to be exported by the entry point index.doc.d.ts +// Warning: (ae-forgotten-export) The symbol "BaseOAuthProvider" needs to be exported by the entry point index.d.ts // // @public export class FacebookAuthProvider extends BaseOAuthProvider { @@ -398,9 +395,6 @@ export function getIdTokenResult(user: User, forceRefresh?: boolean): Promise; @@ -513,7 +507,7 @@ export type NextOrObserver = NextFn | Observer; export class OAuthCredential extends AuthCredential { accessToken?: string; static fromJSON(json: string | object): OAuthCredential | null; - // Warning: (ae-forgotten-export) The symbol "OAuthCredentialParams" needs to be exported by the entry point index.doc.d.ts + // Warning: (ae-forgotten-export) The symbol "OAuthCredentialParams" needs to be exported by the entry point index.d.ts // // @internal (undocumented) static _fromParams(params: OAuthCredentialParams): OAuthCredential; @@ -624,7 +618,7 @@ export class PhoneAuthCredential extends AuthCredential { _getReauthenticationResolver(auth: AuthInternal): Promise; // @internal (undocumented) _linkToIdToken(auth: AuthInternal, idToken: string): Promise; - // Warning: (ae-forgotten-export) The symbol "SignInWithPhoneNumberRequest" needs to be exported by the entry point index.doc.d.ts + // Warning: (ae-forgotten-export) The symbol "SignInWithPhoneNumberRequest" needs to be exported by the entry point index.d.ts // // @internal (undocumented) _makeVerificationRequest(): SignInWithPhoneNumberRequest; @@ -721,13 +715,13 @@ export interface RecaptchaParameters { [key: string]: any; } -// Warning: (ae-forgotten-export) The symbol "ApplicationVerifierInternal" needs to be exported by the entry point index.doc.d.ts +// Warning: (ae-forgotten-export) The symbol "ApplicationVerifierInternal" needs to be exported by the entry point index.d.ts // // @public export class RecaptchaVerifier implements ApplicationVerifierInternal { constructor(authExtern: Auth, containerOrId: HTMLElement | string, parameters?: RecaptchaParameters); clear(): void; - // Warning: (ae-forgotten-export) The symbol "ReCaptchaLoader" needs to be exported by the entry point index.doc.d.ts + // Warning: (ae-forgotten-export) The symbol "ReCaptchaLoader" needs to be exported by the entry point index.d.ts // // @internal (undocumented) readonly _recaptchaLoader: ReCaptchaLoader; @@ -744,7 +738,7 @@ export function reload(user: User): Promise; // @public export function revokeAccessToken(auth: Auth, token: string): Promise; -// Warning: (ae-forgotten-export) The symbol "FederatedAuthProvider" needs to be exported by the entry point index.doc.d.ts +// Warning: (ae-forgotten-export) The symbol "FederatedAuthProvider" needs to be exported by the entry point index.d.ts // // @public export class SAMLAuthProvider extends FederatedAuthProvider { @@ -828,13 +822,13 @@ export class TotpSecret { readonly codeIntervalSeconds: number; readonly codeLength: number; readonly enrollmentCompletionDeadline: string; - // Warning: (ae-forgotten-export) The symbol "StartTotpMfaEnrollmentResponse" needs to be exported by the entry point index.doc.d.ts + // Warning: (ae-forgotten-export) The symbol "StartTotpMfaEnrollmentResponse" needs to be exported by the entry point index.d.ts // // @internal (undocumented) static _fromStartTotpMfaEnrollmentResponse(response: StartTotpMfaEnrollmentResponse, auth: AuthInternal): TotpSecret; generateQrCodeUrl(accountName?: string, issuer?: string): string; readonly hashingAlgorithm: string; - // Warning: (ae-forgotten-export) The symbol "TotpVerificationInfo" needs to be exported by the entry point index.doc.d.ts + // Warning: (ae-forgotten-export) The symbol "TotpVerificationInfo" needs to be exported by the entry point index.d.ts // // @internal (undocumented) _makeTotpVerificationInfo(otp: string): TotpVerificationInfo; diff --git a/packages/auth/api-extractor.json b/packages/auth/api-extractor.json index 325fe12d507..ca7e1ee6983 100644 --- a/packages/auth/api-extractor.json +++ b/packages/auth/api-extractor.json @@ -1,6 +1,6 @@ { "extends": "../../config/api-extractor.json", - "mainEntryPointFilePath": "/dist/esm5/index.doc.d.ts", + "mainEntryPointFilePath": "/dist/esm5/index.d.ts", "dtsRollup": { "enabled": true, "untrimmedFilePath": "/dist/.d.ts", From 5e4e35903ff281f18531bf05f4042a5ec5e3ef9b Mon Sep 17 00:00:00 2001 From: renkelvin Date: Tue, 16 Apr 2024 23:19:19 -0700 Subject: [PATCH 6/6] Revert "Check DOMException error name instead of error message" This reverts commit 7437de8012704a1336240f663e8fba2b4aa3332b. --- .../auth/src/core/strategies/passkey.test.ts | 21 +++---------------- packages/auth/src/core/strategies/passkey.ts | 6 +++--- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/packages/auth/src/core/strategies/passkey.test.ts b/packages/auth/src/core/strategies/passkey.test.ts index 50ab1ea0d3c..35a50f27c44 100644 --- a/packages/auth/src/core/strategies/passkey.test.ts +++ b/packages/auth/src/core/strategies/passkey.test.ts @@ -96,12 +96,7 @@ describe('passkey', async () => { } sinon .stub(navigator.credentials, 'get') - .throws( - new DOMException( - 'The operation either timed out or was not allowed.', - 'NotAllowedError' - ) - ); + .throws(new Error('The operation either timed out or was not allowed.')); sinon.stub(navigator.credentials, 'create').resolves(mockCredential); @@ -171,12 +166,7 @@ describe('passkey', async () => { } sinon .stub(navigator.credentials, 'get') - .throws( - new DOMException( - 'The operation either timed out or was not allowed.', - 'NotAllowedError' - ) - ); + .throws(new Error('The operation either timed out or was not allowed.')); mockEndpoint(Endpoint.START_PASSKEY_SIGNIN, { credentialRequestOptions: { @@ -253,12 +243,7 @@ describe('passkey', async () => { } sinon .stub(navigator.credentials, 'create') - .throws( - new DOMException( - 'The operation either timed out or was not allowed.', - 'NotAllowedError' - ) - ); + .throws(new Error('The operation either timed out or was not allowed.')); mockEndpoint(Endpoint.START_PASSKEY_ENROLLMENT, { credentialCreationOptions: { diff --git a/packages/auth/src/core/strategies/passkey.ts b/packages/auth/src/core/strategies/passkey.ts index 5fd6c909c9a..97843e961a9 100644 --- a/packages/auth/src/core/strategies/passkey.ts +++ b/packages/auth/src/core/strategies/passkey.ts @@ -42,7 +42,8 @@ import { UserCredentialImpl } from '../user/user_credential_impl'; import { signInAnonymously } from './anonymous'; const DEFAULT_PASSKEY_ACCOUNT_NAME = 'Unnamed account (Web)'; -const PASSKEY_LOOK_UP_ERROR_NAME = 'NotAllowedError'; +const PASSKEY_LOOK_UP_ERROR_MESSAGE = + 'The operation either timed out or was not allowed.'; /** * Signs in a user with a passkey. Use enrollPasskey to enroll a passkey credential for the current user. @@ -93,8 +94,7 @@ export async function signInWithPasskey( return userCredential; } catch (error) { if ( - error instanceof DOMException && - error.name === PASSKEY_LOOK_UP_ERROR_NAME && + (error as Error).message.includes(PASSKEY_LOOK_UP_ERROR_MESSAGE) && !manualSignUp ) { // If the user is not signed up, sign them up anonymously