auth package

Firebase 身份驗證

功能

功能描述
函數(應用程序,...)
取得身份驗證(應用程式)傳回與提供的FirebaseApp關聯的 Auth 實例。如果不存在實例,則使用特定於平台的預設依賴項初始化 Auth 實例。
初始化Auth(應用程序,部門)透過對依賴項的細粒度控制來初始化Auth實例
功能(存儲,...)
取得ReactNativePersistence(儲存)傳回一個持久化對象,該物件包裝從react-native@react-native-community/async-storage匯入的AsyncStorage ,並且可以在initializeAuth()中的持久化依賴欄位中使用
函數(驗證,...)
applyActionCode(身份驗證,oobCode)應用程式透過電子郵件或其他帶外機制傳送給使用者的驗證碼。
beforeAuthStateChanged(身份驗證,回調,onAbort)新增在身份驗證狀態變更設定新使用者之前執行的阻止回呼。
檢查操作代碼(驗證,oobCode)檢查透過電子郵件或其他帶外機制傳送給使用者的驗證碼。
確認密碼重設(身份驗證,oobCode,新密碼)給予確認碼和新密碼後,完成密碼重設程序。
connectAuthEmulator(身份驗證,網址,選項)更改Auth實例以與 Firebase Auth 模擬器(而不是生產 Firebase Auth 服務)進行通訊。
createUserWithEmailAndPassword(驗證、電子郵件、密碼)建立與指定的電子郵件地址和密碼關聯的新使用者帳戶。
fetchSignInMethodsForEmail(身份驗證,電子郵件)取得給定電子郵件地址的可能登入方法清單。啟用[電子郵件枚舉保護](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection)時,無論可用於​​多少種身份驗證方法,此方法都會傳回一個空列表。給定的電子郵件。
getMultiFactorResolver(驗證,錯誤)提供適合完成多因子流的MultiFactorResolver
getRedirectResult(身份驗證,解析器)從基於重定向的登入流程返回UserCredential
初始化RecaptchaConfig(身份驗證)將 reCAPTCHA 配置載入到Auth實例中。
isSignInWithEmailLink(auth, emailLink)檢查傳入連結是否為適合signInWithEmailLink()的電子郵件登入鏈接
onAuthStateChanged(auth,nextOrObserver,錯誤,已完成)新增觀察者以觀察使用者登入狀態的變化。
onIdTokenChanged(auth,nextOrObserver,錯誤,已完成)新增一個觀察者以監視登入使用者的 ID 令牌的變更。
撤銷AccessToken(身份驗證,令牌)撤銷給定的存取令牌。目前僅支援 Apple OAuth 存取權令牌。
傳送密碼重設電子郵件(驗證、電子郵件、actionCodeSettings)將密碼重設電子郵件傳送到給定的電子郵件地址。當沒有具有給定電子郵件地址的使用者帳戶並且啟用了[電子郵件枚舉保護](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection)時,此方法不會引發錯誤。
sendSignInLinkToEmail(身份驗證、電子郵件、actionCodeSettings)使用指定電子郵件向使用者發送登入電子郵件連結。
setPersistence(身份驗證,持久性)變更目前已儲存的Auth會話的Auth實例上的持久性類型,並將此類型的持久性應用於未來的登入要求,包括使用重定向請求登入。
匿名登入(auth)以匿名使用者身分非同步登入。
SignInWithCredential(身份驗證,憑證)使用給定的憑證非同步登入。
SignInWithCustomToken(身份驗證,customToken)使用自訂令牌異步登入。
SignInWithEmailAndPassword(身份驗證、電子郵件、密碼)使用電子郵件和密碼非同步登入。
SignInWithEmailLink(身份驗證、電子郵件、emailLink)使用電子郵件和登入電子郵件連結非同步登入。
SignInWithPhoneNumber(auth, 電話號碼, appVerifier)使用電話號碼非同步登入。
SignInWithPopup(身份驗證、提供者、解析器)使用基於彈出視窗的 OAuth 驗證流程對 Firebase 用戶端進行身份驗證。
SignInWithRedirect(身份驗證、提供者、解析器)使用全頁面重定向流對 Firebase 用戶端進行身份驗證。
退出(驗證)註銷目前使用者。
更新目前使用者(身份驗證,使用者)Auth實例上非同步將提供的使用者設定為Auth.currentUser
使用設備語言(auth)將目前語言設定為預設裝置/瀏覽器首選項。
驗證密碼(身份驗證,密碼)根據為專案或租用戶配置的密碼原則驗證密碼。
驗證密碼重設代碼(身份驗證,代碼)檢查透過電子郵件或其他帶外機制傳送給使用者的密碼重設代碼。
函數(鏈接,...)
解析ActionCodeURL(連結)解析電子郵件動作連結字串,如果連結有效,則傳回ActionCodeURL ,否則傳回 null。
函數(用戶,...)
刪除用戶(用戶)刪除並登出用戶。
getIdToken(用戶,強制刷新)傳回用於向 Firebase 服務識別使用者的 JSON Web 令牌 (JWT)。
getIdTokenResult(用戶,強制刷新)傳回反序列化的 JSON Web 令牌 (JWT),用於向 Firebase 服務識別使用者。
linkWithCredential(用戶,憑證)將使用者帳戶與給定的憑證連結起來。
linkWithPhoneNumber(用戶,電話號碼,appVerifier)將用戶帳戶與給定的電話號碼連結。
linkWithPopup(用戶,提供者,解析器)使用基於彈出的 OAuth 流程將經過身份驗證的提供者連結到使用者帳戶。
linkWithRedirect(用戶,提供者,解析器)使用全頁重定向流將OAuthProvider連結到使用者帳戶。
多因素(用戶)用戶對應的MultiFactorUser
reauthenticateWithCredential(用戶,憑證)使用新的憑證重新對使用者進行身份驗證。
reauthenticateWithPhoneNumber(用戶,電話號碼,appVerifier)使用新的電話憑證重新驗證使用者身分。
reauthenticateWithPopup(使用者、提供者、解析器)使用基於彈出視窗的 OAuth 流程透過指定的OAuthProvider重新驗證目前使用者。
reauthenticateWithRedirect(使用者、提供者、解析器)使用全頁重定向流透過指定的OAuthProvider重新驗證目前使用者。
重新載入(用戶)如果已登錄,則重新載入使用者帳戶資料。
發送電子郵件驗證(用戶,actionCodeSettings)向使用者發送驗證電子郵件。
取消連結(用戶,提供者 ID)取消提供者與使用者帳戶的連結。
更新電子郵件(用戶,新電子郵件)更新使用者的電子郵件地址。
更新密碼(用戶,新密碼)更新用戶的密碼。
更新電話號碼(用戶,憑證)更新用戶的電話號碼。
updateProfile(使用者, { 顯示名稱, photoURL: photoUrl })更新用戶的個人資料資料。
verifyBeforeUpdateEmail(用戶,新電子郵件,actionCodeSettings)向新電子郵件地址發送驗證電子郵件。
函數(使用者憑證,...)
取得附加使用者資訊(使用者憑證)提取給定憑證的提供者特定的AdditionalUserInfo

課程

班級描述
動作代碼URL用於解析電子郵件操作 URL(例如密碼重設、電子郵件驗證、電子郵件連結登入等)的實用程式類別。
驗證憑證表示AuthProvider傳回的憑證的介面
電子郵件驗證憑證表示EmailAuthProvider傳回的ProviderId憑證的介面。密碼
電子郵件驗證提供者用於產生EmailAuthCredential 的提供程序
FacebookAuthProvider用於為ProviderId產生OAuthCredential 的提供者。FACEBOOK。
GithubAuthProvider用於為ProviderId產生OAuthCredential 的提供者.GITHUB。
Google認證提供者用於為ProviderId產生OAuthCredential 的提供者.GOOGLE.
OAuth憑證表示OAuthProvider傳回的 OAuth 憑證
OAuth提供者用於產生通用OAuthCredential的提供程序
電話驗證憑證表示PhoneAuthProvider傳回的憑證
電話驗證提供者用於產生PhoneAuthCredential 的提供程序
電話多因素產生器用於產生PhoneMultiFactorAssertion的提供程序
驗證碼驗證器驗證碼基於應用程式的驗證器。
SAMLAuthProvider SAML 的AuthProvider
托普多因素產生器用於產生TotpMultiFactorAssertion 的提供程序
頂級秘密用於產生TotpMultiFactorAssertion 的提供程序儲存共用金鑰和其他參數以產生基於時間的 OTP。實作檢索共用金鑰並產生 QR 碼 URL 的方法。
TwitterAuthProvider用於為ProviderId產生OAuthCredential 的提供者。推特。

介面

介面描述
動作代碼訊息checkActionCode()的回應
動作代碼設定一個接口,使用可選的 Android 和 iOS 套件標識符定義所需的繼續/狀態 URL。
附加用戶資訊包含來自聯合身分提供者的附加使用者資訊的結構。
應用驗證器用於網域驗證和濫用預防的驗證程序。
授權代表 Firebase Auth 服務的介面。
驗證錯誤Auth錯誤的介面。
驗證錯誤映射表錯誤代碼到錯誤訊息的映射。
認證提供者代表身分驗證提供者的接口,用於方便建立AuthCredential
驗證設定代表Auth實例設定的介面。
配置代表Auth驗證配置的介面。
確認結果電話號碼登入、連結或重新驗證通話的結果。
依賴關係可用於初始化Auth實例的依賴項。
模擬器配置Firebase 身份驗證模擬器的配置。
IdToken結果表示從User.getIdTokenResult()取得的 ID 令牌結果的接口
多因素斷言用於聲明第二個因素的所有權的基底類別。
多因素錯誤當使用者需要提供第二個因素才能成功登入時引發的錯誤。
多因素資訊包含第二因素實體資訊的結構。
多因子解析器當使用者需要提供第二個因素進行登入時,該類別可協助從MultiFactorError中復原。
多因素會話定義多因素會話物件的接口,用於註冊使用者的第二因素或幫助使用第二因素登入已註冊的使用者。
多因素用戶定義與使用者相關的多因素相關屬性和操作的介面
OAuth憑證選項定義用於初始化OAuthCredential 的選項
解析令牌表示已解析 ID 令牌的介面。
密碼原則指定密碼策略要求的結構。
密碼驗證狀態指示滿足或違反哪些密碼策略要求以及要求是什麼的結構。
堅持涵蓋可能的持久性機制類型的介面。
電話多因素斷言用於聲明電話所有權的類別是第二個因素。由PhoneMultiFactorGenerator.assertion()提供
電話多因素註冊資訊選項用於註冊第二個因素的選項。
電話多因素訊息電話號碼第二因素的MultiFactorInfo介面的子類別。第二個因素的factorIdFactorId 。電話。
電話多重登入資訊選項用於使用第二因素登入的選項。
電話單因子資訊選項用於單一因素登入的選項。
彈出重定向解析器用於處理 DOM 特定操作的解析器,例如signInWithPopup()signInWithRedirect()
ReactNativeAsyncStorage提供的AsyncStorage的介面。
驗證碼參數表示 reCAPTCHA 參數的介面。有關可接受參數的列表,請參閱 [reCAPTCHA 文件](https://developers.google.com/recaptcha/docs/display#render_param)。除sitekey之外的所有參數均被接受:Firebase Auth 為每個專案提供 reCAPTCHA,並將在渲染時配置網站金鑰。對於不可見的 reCAPTCHA,請將size鍵設為invisible
頂部多因素斷言用於斷言 TOTP 第二個因素的所有權的類別。由TotpMultiFactorGenerator.assertionForEnrollment()TotpMultiFactorGenerator.assertionForSignIn()提供
頂部多因素信息TOTP 第二因子的MultiFactorInfo介面的子類別。第二個因素的factorIdFactorId .TOTP。
使用者一個用戶帳戶。
使用者憑證包含使用者的結構,操作類型,以及提供者 ID。
使用者資訊使用者個人資料訊息,僅對 Firebase 專案的應用可見。
用戶元數據代表用戶元資料的介面。

變數

多變的描述
動作代碼操作可能的電子郵件操作類型的列舉。
驗證錯誤代碼潛在的Auth錯誤代碼的映射,以便更輕鬆地與 SDK 引發的錯誤進行比較。
瀏覽器本機持久化使用localStorage作為底層儲存的LOCAL類型持久化的實作。
瀏覽器彈出重定向解析器PopupRedirectResolver的實作適用於基於瀏覽器的應用程式。
瀏覽器會話持久化使用sessionStorage作為底層儲存的SESSION持久化的實作。
cordovaPopupRedirectResolver適用於基於 Cordova 的應用程式的PopupRedirectResolver實作。
偵錯錯誤映射表詳細的錯誤圖,包含大多數錯誤代碼的詳細描述。請參閱AuthErrorMap中的討論
因子ID可用於多因素身份驗證的因素的列舉。
索引資料庫本地持久化使用indexedDB作為底層儲存的LOCAL類型持久化的實作。
記憶體持久化“NONE”類型持久化的實作。
操作類型支援的操作類型的枚舉。
產品錯誤圖刪除了所有詳細錯誤訊息的最小錯誤圖。請參閱AuthErrorMap中的討論
提供者ID支持的提供者的列舉。
登入方法支援的登入方法的列舉。

類型別名

類型別名描述
自訂參數OAuth 自訂參數映射。
下一個或觀察者事件回調的類型定義。
電話訊息選項驗證電話號碼所有權所需的資訊。
使用者資料AdditionalUserInfo使用的使用者設定檔

函數(應用程序,...)

取得身份驗證(應用程式)

傳回與提供的FirebaseApp關聯的 Auth 實例。如果不存在實例,則使用特定於平台的預設依賴項初始化 Auth 實例。

簽名:

export declare function getAuth(app?: FirebaseApp): Auth;

參數

範圍類型描述
應用程式Firebase應用程式Firebase 應用程式。

返回:

授權

初始化Auth(應用程序,部門)

透過對依賴項的細粒度控制來初始化Auth實例

getAuth()相比,此函數允許對Auth實例進行更多控制getAuth使用特定於平台的預設值來提供依賴項。一般來說, getAuth是初始化 Auth 最簡單的方法,適用於大多數用例。如果您需要控制使用哪個持久層,請使用initializeAuth ,或者如果您不使用signInWithPopupsignInWithRedirect ,請使用initializeAuth來最小化套件大小

例如,如果您的應用程式僅使用匿名帳戶,並且您只想保存當前會話的帳戶,請使用以下命令初始化Auth

const auth = initializeAuth(app, {
  persistence: browserSessionPersistence,
  popupRedirectResolver: undefined,
});

簽名:

export declare function initializeAuth(app: FirebaseApp, deps?: Dependencies): Auth;

參數

範圍類型描述
應用程式Firebase應用程式
部門依賴關係

返回:

授權

功能(存儲,...)

取得ReactNativePersistence(儲存)

傳回一個持久化對象,該物件包裝從react-native@react-native-community/async-storage匯入的AsyncStorage ,並且可以在initializeAuth()中的持久性依賴欄位中使用

簽名:

export declare function getReactNativePersistence(storage: ReactNativeAsyncStorage): Persistence;

參數

範圍類型描述
貯存ReactNativeAsyncStorage

返回:

堅持

函數(驗證,...)

applyActionCode(身份驗證,oobCode)

應用程式透過電子郵件或其他帶外機制傳送給使用者的驗證碼。

簽名:

export declare function applyActionCode(auth: Auth, oobCode: string): Promise<void>;

參數

範圍類型描述
授權授權Auth實例。
出庫程式碼細繩發送給使用者的驗證碼。

返回:

承諾<無效>

beforeAuthStateChanged(身份驗證,回調,onAbort)

新增在身份驗證狀態變更設定新使用者之前執行的阻止回呼。

簽名:

export declare function beforeAuthStateChanged(auth: Auth, callback: (user: User | null) => void | Promise<void>, onAbort?: () => void): Unsubscribe;

參數

範圍類型描述
授權授權Auth實例。
打回來(使用者:使用者| null)=> void |承諾<無效>設定新使用者值之前觸發的回調。如果拋出此異常,則會阻止使用者被設定。
中止時() => 無效如果稍後的beforeAuthStateChanged()回調拋出,則會觸發回調,允許您撤銷任何副作用。

返回:

退訂

檢查操作代碼(驗證,oobCode)

檢查透過電子郵件或其他帶外機制傳送給使用者的驗證碼。

簽名:

export declare function checkActionCode(auth: Auth, oobCode: string): Promise<ActionCodeInfo>;

參數

範圍類型描述
授權授權Auth實例。
出庫程式碼細繩發送給使用者的驗證碼。

返回:

Promise< ActionCodeInfo >

有關代碼的元資料。

確認密碼重設(身份驗證,oobCode,新密碼)

給予確認碼和新密碼後,完成密碼重設程序。

簽名:

export declare function confirmPasswordReset(auth: Auth, oobCode: string, newPassword: string): Promise<void>;

參數

範圍類型描述
授權授權Auth實例。
出庫程式碼細繩發送給用戶的確認碼。
新密碼細繩新密碼。

返回:

承諾<無效>

connectAuthEmulator(身份驗證,網址,選項)

更改Auth實例以與 Firebase Auth 模擬器(而不是生產 Firebase Auth 服務)進行通訊。

必須在第一次呼叫initializeAuth()之後立即同步調用。請勿與生產憑證一起使用,因為模擬器流量未加密。

簽名:

export declare function connectAuthEmulator(auth: Auth, url: string, options?: {
    disableWarnings: boolean;
}): void;

參數

範圍類型描述
授權授權Auth實例。
網址細繩執行模擬器的 URL(例如“http://localhost:9099”)。
選項{ 禁用警告:布林值; }選修的。 options.disableWarnings預設為false 。將其設為true以停用附加到 DOM 的警告橫幅。

返回:

空白

例子

connectAuthEmulator(auth, 'http://127.0.0.1:9099', { disableWarnings: true });

createUserWithEmailAndPassword(驗證、電子郵件、密碼)

建立與指定的電子郵件地址和密碼關聯的新使用者帳戶。

成功建立使用者帳戶後,該使用者也會登入您的應用程式。

如果帳戶已存在或密碼無效,使用者帳戶建立可能會失敗。

簽名:

export declare function createUserWithEmailAndPassword(auth: Auth, email: string, password: string): Promise<UserCredential>;

參數

範圍類型描述
授權授權Auth實例。
電子郵件細繩使用者的電子郵件地址。
密碼細繩用戶選擇的密碼。

返回:

承諾<使用者憑證>

fetchSignInMethodsForEmail(身份驗證,電子郵件)

取得給定電子郵件地址的可能登入方法清單。啟用[電子郵件枚舉保護](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection)時,無論可用於​​多少種身份驗證方法,此方法都會傳回一個空列表。給定的電子郵件。

這對於區分同一提供者的登入方法很有用,例如。 EmailAuthProvider有 2 種登入方法, SignInMethod .EMAIL_PASSWORD 和SignInMethod .EMAIL_LINK。

簽名:

export declare function fetchSignInMethodsForEmail(auth: Auth, email: string): Promise<string[]>;

參數

範圍類型描述
授權授權Auth實例。
電子郵件細繩使用者的電子郵件地址。已棄用。建議放棄此方法作為安全最佳實踐。有關詳細信息,請參閱 Identity Platform 文件中的 [電子郵件枚舉保護](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection)。

返回:

承諾<字串[]>

getMultiFactorResolver(驗證,錯誤)

提供適合完成多因子流的MultiFactorResolver

簽名:

export declare function getMultiFactorResolver(auth: Auth, error: MultiFactorError): MultiFactorResolver;

參數

範圍類型描述
授權授權Auth實例。
錯誤多因素錯誤在登入或重新驗證操作期間引發的MultiFactorError

返回:

多因子解析器

getRedirectResult(身份驗證,解析器)

從基於重定向的登入流程返回UserCredential

如果登入成功,則傳回登入的使用者。如果登入不成功,則會失敗並出現錯誤。如果沒有呼叫重定向操作,則傳回null

此方法不適用於 Node.js 環境。

簽名:

export declare function getRedirectResult(auth: Auth, resolver?: PopupRedirectResolver): Promise<UserCredential | null>;

參數

範圍類型描述
授權授權Auth實例。
解析器彈出重定向解析器PopupRedirectResolver的實例,如果已提供給initializeAuth()或由getAuth()提供,則為可選

返回:

承諾<使用者憑證|空>

例子

// Sign in using a redirect.
const provider = new FacebookAuthProvider();
// You can add additional scopes to the provider:
provider.addScope('user_birthday');
// Start a sign in process for an unauthenticated user.
await signInWithRedirect(auth, provider);
// This will trigger a full page redirect away from your app

// After returning from the redirect when your app initializes you can obtain the result
const result = await getRedirectResult(auth);
if (result) {
  // This is the signed-in user
  const user = result.user;
  // This gives you a Facebook Access Token.
  const credential = provider.credentialFromResult(auth, result);
  const token = credential.accessToken;
}
// As this API can be used for sign-in, linking and reauthentication,
// check the operationType to determine what triggered this redirect
// operation.
const operationType = result.operationType;

初始化RecaptchaConfig(身份驗證)

將 reCAPTCHA 配置載入到Auth實例中。

這會將 reCAPTCHA 配置載入到目前的 Auth 會話中,該配置指示是否應為每個身份驗證提供者觸發 reCAPTCHA 驗證流程。

如果不呼叫initializeRecaptchaConfig(),則身份驗證流程將始終在沒有 reCAPTCHA 驗證的情況下啟動。如果提供者配置為需要 reCAPTCHA 驗證,則 SDK 將透明地載入 reCAPTCHA 配置並重新啟動身份驗證流程。

因此,透過呼叫此可選方法,您將減少未來身份驗證流程的延遲。儘早載入 reCAPTCHA 配置也將增強 reCAPTCHA 收集的訊號。

此方法不適用於 Node.js 環境。

簽名:

export declare function initializeRecaptchaConfig(auth: Auth): Promise<void>;

參數

範圍類型描述
授權授權Auth實例。

返回:

承諾<無效>

例子

initializeRecaptchaConfig(auth);

檢查傳入連結是否為適合signInWithEmailLink()的電子郵件登入鏈接

簽名:

export declare function isSignInWithEmailLink(auth: Auth, emailLink: string): boolean;

參數

範圍類型描述
授權授權Auth實例。
電子郵件連結細繩發送到用戶電子郵件地址的連結。

返回:

布林值

onAuthStateChanged(auth,nextOrObserver,錯誤,已完成)

新增觀察者以觀察使用者登入狀態的變化。

若要保留舊行為,請參閱onIdTokenChanged()

簽名:

export declare function onAuthStateChanged(auth: Auth, nextOrObserver: NextOrObserver<User>, error?: ErrorFn, completed?: CompleteFn): Unsubscribe;

參數

範圍類型描述
授權授權Auth實例。
下一個或觀察者下一個或觀察者<使用者>更改時觸發回調。
錯誤錯誤Fn已棄用。這個回調永遠不會被觸發。登入/登出時的錯誤可以在從登入/登出函數傳回的承諾中捕獲。
完全的完整Fn已棄用。這個回調永遠不會被觸發。

返回:

退訂

onIdTokenChanged(身份驗證,nextOrObserver,錯誤,已完成)

新增一個觀察者以監視登入使用者的 ID 令牌的變更。

這包括登入、登出和令牌刷新事件。 ID 令牌過期後不會自動觸發。使用User.getIdToken()刷新 ID 令牌。

簽名:

export declare function onIdTokenChanged(auth: Auth, nextOrObserver: NextOrObserver<User>, error?: ErrorFn, completed?: CompleteFn): Unsubscribe;

參數

範圍類型描述
授權授權Auth實例。
下一個或觀察者下一個或觀察者<使用者>更改時觸發回調。
錯誤錯誤Fn已棄用。這個回調永遠不會被觸發。登入/登出時的錯誤可以在從登入/登出函數傳回的承諾中捕獲。
完全的完整Fn已棄用。這個回調永遠不會被觸發。

返回:

退訂

撤銷AccessToken(身份驗證,令牌)

撤銷給定的存取令牌。目前僅支援 Apple OAuth 存取權令牌。

簽名:

export declare function revokeAccessToken(auth: Auth, token: string): Promise<void>;

參數

範圍類型描述
授權授權Auth實例。
代幣細繩Apple OAuth 存取令牌。

返回:

承諾<無效>

傳送密碼重設電子郵件(驗證、電子郵件、actionCodeSettings)

將密碼重設電子郵件傳送到給定的電子郵件地址。當不存在具有給定電子郵件地址的使用者帳戶並且啟用了[電子郵件枚舉保護](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection)時,此方法不會引發錯誤。

若要完成密碼重置,請使用傳送給使用者的電子郵件中提供的程式碼以及使用者指定的新密碼來呼叫confirmPasswordReset()

簽名:

export declare function sendPasswordResetEmail(auth: Auth, email: string, actionCodeSettings?: ActionCodeSettings): Promise<void>;

參數

範圍類型描述
授權授權Auth實例。
電子郵件細繩使用者的電子郵件地址。
動作代碼設定動作代碼設定動作代碼設定

返回:

承諾<無效>

例子

const actionCodeSettings = {
  url: 'https://www.example.com/?email=user@example.com',
  iOS: {
     bundleId: 'com.example.ios'
  },
  android: {
    packageName: 'com.example.android',
    installApp: true,
    minimumVersion: '12'
  },
  handleCodeInApp: true
};
await sendPasswordResetEmail(auth, 'user@example.com', actionCodeSettings);
// Obtain code from user.
await confirmPasswordReset('user@example.com', code);

sendSignInLinkToEmail(身份驗證、電子郵件、actionCodeSettings)

使用指定電子郵件向使用者發送登入電子郵件連結。

與其他帶外電子郵件操作(密碼重設和電子郵件驗證)不同,登入操作必須始終在應用程式中完成。這是因為,在流程結束時,使用者應該登入並且他們的身份驗證狀態會保留在應用程式中。

若要使用電子郵件連結完成登錄,請使用傳送給使用者的電子郵件中提供的電子郵件地址和電子郵件連結來呼叫signInWithEmailLink()

簽名:

export declare function sendSignInLinkToEmail(auth: Auth, email: string, actionCodeSettings: ActionCodeSettings): Promise<void>;

參數

範圍類型描述
授權授權
電子郵件細繩使用者的電子郵件地址。
動作代碼設定動作代碼設定動作代碼設定

返回:

承諾<無效>

例子

const actionCodeSettings = {
  url: 'https://www.example.com/?email=user@example.com',
  iOS: {
     bundleId: 'com.example.ios'
  },
  android: {
    packageName: 'com.example.android',
    installApp: true,
    minimumVersion: '12'
  },
  handleCodeInApp: true
};
await sendSignInLinkToEmail(auth, 'user@example.com', actionCodeSettings);
// Obtain emailLink from the user.
if(isSignInWithEmailLink(auth, emailLink)) {
  await signInWithEmailLink(auth, 'user@example.com', emailLink);
}

setPersistence(身份驗證,持久性)

變更目前已儲存的Auth會話的Auth實例上的持久性類型,並將此類型的持久性應用於未來的登入要求,包括使用重定向請求登入。

這使得登入的使用者可以輕鬆指定是否應記住其會話。它還可以更輕鬆地永遠不會保留其他用戶共享或具有敏感資料的應用程式的Auth狀態。

此方法不適用於 Node.js 環境。

簽名:

export declare function setPersistence(auth: Auth, persistence: Persistence): Promise<void>;

參數

範圍類型描述
授權授權Auth實例。
堅持堅持堅持使用。

返回:

承諾<無效>

持久性更改完成後即可解決的Promise

例子

setPersistence(auth, browserSessionPersistence);

匿名登入(auth)

以匿名使用者身分非同步登入。

如果已經有匿名使用者登錄,則傳回該使用者;否則,將建立並傳回一個新的匿名使用者身分。

簽名:

export declare function signInAnonymously(auth: Auth): Promise<UserCredential>;

參數

範圍類型描述
授權授權Auth實例。

返回:

承諾<使用者憑證>

SignInWithCredential(身份驗證,憑證)

使用給定的憑證非同步登入。

AuthProvider可用於產生憑證。

簽名:

export declare function signInWithCredential(auth: Auth, credential: AuthCredential): Promise<UserCredential>;

參數

範圍類型描述
授權授權Auth實例。
憑證驗證憑證授權憑證。

返回:

承諾<使用者憑證>

SignInWithCustomToken(身份驗證,customToken)

使用自訂令牌異步登入。

自訂令牌用於將 Firebase Auth 與現有身份驗證系統集成,並且必須由身份驗證後端使用Admin SDK中的createCustomToken方法產生。

如果令牌無效、過期或不被 Firebase Auth 服務接受,則會失敗並顯示錯誤。

簽名:

export declare function signInWithCustomToken(auth: Auth, customToken: string): Promise<UserCredential>;

參數

範圍類型描述
授權授權Auth實例。
自訂令牌細繩用於登入的自訂令牌。

返回:

承諾<使用者憑證>

SignInWithEmailAndPassword(身份驗證、電子郵件、密碼)

使用電子郵件和密碼非同步登入。

如果電子郵件地址和密碼不匹配,則會失敗並顯示錯誤。啟用[電子郵件枚舉保護](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) 後,如果無效,此方法會失敗並顯示「auth/invalid-credential ”電子郵件/密碼。

簽名:

export declare function signInWithEmailAndPassword(auth: Auth, email: string, password: string): Promise<UserCredential>;

參數

範圍類型描述
授權授權Auth實例。
電子郵件細繩使用者的電子郵件地址。
密碼細繩用戶密碼。

返回:

承諾<使用者憑證>

使用電子郵件和登入電子郵件連結非同步登入。

如果未傳遞鏈接,則從目前 URL 推斷連結。

如果電子郵件地址無效或電子郵件連結中的 OTP 過期,則會失敗並顯示錯誤。

簽名:

export declare function signInWithEmailLink(auth: Auth, email: string, emailLink?: string): Promise<UserCredential>;

參數

範圍類型描述
授權授權Auth實例。
電子郵件細繩使用者的電子郵件地址。
電子郵件連結細繩發送到用戶電子郵件地址的連結。

返回:

承諾<使用者憑證>

例子

const actionCodeSettings = {
  url: 'https://www.example.com/?email=user@example.com',
  iOS: {
     bundleId: 'com.example.ios'
  },
  android: {
    packageName: 'com.example.android',
    installApp: true,
    minimumVersion: '12'
  },
  handleCodeInApp: true
};
await sendSignInLinkToEmail(auth, 'user@example.com', actionCodeSettings);
// Obtain emailLink from the user.
if(isSignInWithEmailLink(auth, emailLink)) {
  await signInWithEmailLink(auth, 'user@example.com', emailLink);
}

SignInWithPhoneNumber(auth, 電話號碼, appVerifier)

使用電話號碼非同步登入。

此方法透過簡訊發送代碼到給定的電話號碼,並傳回一個ConfirmationResult 。用戶提供發送到手機的程式碼後,使用該程式碼呼叫ConfirmationResult.confirm()以使用戶登入。

為了防止濫用,這個方法還需要一個ApplicationVerifier 。該 SDK 包括基於 reCAPTCHA 的實作RecaptchaVerifier 。此功能可以在不支援RecaptchaVerifier 的其他平台(如 React Native)上運作,但您需要使用第三方ApplicationVerifier實作。

此方法不適用於 Node.js 環境。

簽名:

export declare function signInWithPhoneNumber(auth: Auth, phoneNumber: string, appVerifier: ApplicationVerifier): Promise<ConfirmationResult>;

參數

範圍類型描述
授權授權Auth實例。
電話號碼細繩E.164 格式的使用者電話號碼(例如+16505550101)。
應用程式驗證器應用驗證器應用程式驗證器

返回:

承諾<確認結果>

例子

// 'recaptcha-container' is the ID of an element in the DOM.
const applicationVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container');
const confirmationResult = await signInWithPhoneNumber(auth, phoneNumber, applicationVerifier);
// Obtain a verificationCode from the user.
const credential = await confirmationResult.confirm(verificationCode);

SignInWithPopup(身份驗證、提供者、解析器)

使用基於彈出視窗的 OAuth 驗證流程對 Firebase 用戶端進行身份驗證。

如果成功,則傳回登入使用者以及提供者的憑證。如果登入不成功,則傳回錯誤對象,其中包含有關該錯誤的其他資訊。

此方法不適用於 Node.js 環境。

簽名:

export declare function signInWithPopup(auth: Auth, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<UserCredential>;

參數

範圍類型描述
授權授權Auth實例。
提供者認證提供者提供者進行身份驗證。提供者必須是OAuthProvider 。非 OAuth 提供者(例如EmailAuthProvider)將引發錯誤。
解析器彈出重定向解析器PopupRedirectResolver的實例,如果已提供給initializeAuth()或由getAuth()提供,則為可選

返回:

承諾<使用者憑證>

例子

// Sign in using a popup.
const provider = new FacebookAuthProvider();
const result = await signInWithPopup(auth, provider);

// The signed-in user info.
const user = result.user;
// This gives you a Facebook Access Token.
const credential = provider.credentialFromResult(auth, result);
const token = credential.accessToken;

SignInWithRedirect(身份驗證、提供者、解析器)

使用全頁面重定向流對 Firebase 用戶端進行身份驗證。

若要處理此操作的結果和錯誤,請參考getRedirectResult() 。使用signInWithRedirect()時遵循最佳實踐

此方法不適用於 Node.js 環境。

簽名:

export declare function signInWithRedirect(auth: Auth, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<never>;

參數

範圍類型描述
授權授權Auth實例。
提供者認證提供者提供者進行身份驗證。提供者必須是OAuthProvider 。非 OAuth 提供者(例如EmailAuthProvider)將引發錯誤。
解析器彈出重定向解析器PopupRedirectResolver的實例,如果已提供給initializeAuth()或由getAuth()提供,則為可選

返回:

承諾<從不>

例子

// Sign in using a redirect.
const provider = new FacebookAuthProvider();
// You can add additional scopes to the provider:
provider.addScope('user_birthday');
// Start a sign in process for an unauthenticated user.
await signInWithRedirect(auth, provider);
// This will trigger a full page redirect away from your app

// After returning from the redirect when your app initializes you can obtain the result
const result = await getRedirectResult(auth);
if (result) {
  // This is the signed-in user
  const user = result.user;
  // This gives you a Facebook Access Token.
  const credential = provider.credentialFromResult(auth, result);
  const token = credential.accessToken;
}
// As this API can be used for sign-in, linking and reauthentication,
// check the operationType to determine what triggered this redirect
// operation.
const operationType = result.operationType;

退出(授權)

註銷目前使用者。

簽名:

export declare function signOut(auth: Auth): Promise<void>;

參數

範圍類型描述
授權授權Auth實例。

返回:

承諾<無效>

更新目前使用者(身份驗證,使用者)

Auth實例上非同步將提供的使用者設定為Auth.currentUser

將建立所提供使用者的新實例副本並將其設定為 currentUser。

與其他登入方法一樣,這將觸發onAuthStateChanged()onIdTokenChanged()偵聽器。

如果要更新的使用者屬於不同的 Firebase 項目,則操作會失敗並出現錯誤。

簽名:

export declare function updateCurrentUser(auth: Auth, user: User | null): Promise<void>;

參數

範圍類型描述
授權授權Auth實例。
使用者用戶|無效的用戶

返回:

承諾<無效>

使用設備語言(auth)

將目前語言設定為預設裝置/瀏覽器首選項。

簽名:

export declare function useDeviceLanguage(auth: Auth): void;

參數

範圍類型描述
授權授權Auth實例。

返回:

空白

驗證密碼(身份驗證,密碼)

根據為專案或租用戶配置的密碼原則驗證密碼。

如果Auth實例上沒有設定租用戶ID,則此方法將使用為項目配置的密碼原則。否則,此方法將使用為租用戶配置的策略。如果尚未配置密碼策略,則將使用為所有項目配置的預設原則。

如果由於提交的密碼不符合密碼原則要求而導致身份驗證流程失敗,並且先前已呼叫此方法,則再次呼叫時此方法將使用最新的可用策略。

簽名:

export declare function validatePassword(auth: Auth, password: string): Promise<PasswordValidationStatus>;

參數

範圍類型描述
授權授權Auth實例。
密碼細繩要驗證的密碼。

返回:

Promise<密碼驗證狀態>

例子

validatePassword(auth, 'some-password');

驗證密碼重設代碼(身份驗證,代碼)

檢查透過電子郵件或其他帶外機制傳送給使用者的密碼重設代碼。

簽名:

export declare function verifyPasswordResetCode(auth: Auth, code: string): Promise<string>;

參數

範圍類型描述
授權授權Auth實例。
程式碼細繩發送給使用者的驗證碼。

返回:

承諾<字串>

使用者的電子郵件地址(如果有效)。

解析ActionCodeURL(連結)

解析電子郵件動作連結字串,如果連結有效,則傳回ActionCodeURL ,否則傳回 null。

簽名:

export declare function parseActionCodeURL(link: string): ActionCodeURL | null;

參數

範圍類型描述
關聯細繩

返回:

操作代碼URL |無效的

函數(用戶,...)

刪除用戶(用戶)

刪除並登出用戶。

簽名:

export declare function deleteUser(user: User): Promise<void>;

參數

範圍類型描述
使用者使用者用戶。

返回:

承諾<無效>

getIdToken(用戶,強制刷新)

傳回用於向 Firebase 服務識別使用者的 JSON Web 令牌 (JWT)。

如果目前令牌尚未過期或在接下來的五分鐘內不會過期,則傳回目前令牌。否則,這將刷新令牌並傳回一個新令牌。

簽名:

export declare function getIdToken(user: User, forceRefresh?: boolean): Promise<string>;

參數

範圍類型描述
使用者使用者用戶。
強制刷新布林值無論令牌是否過期,都強制刷新。

返回:

承諾<字串>

getIdTokenResult(用戶,強制刷新)

傳回反序列化的 JSON Web 令牌 (JWT),用於向 Firebase 服務識別使用者。

如果目前令牌尚未過期或在接下來的五分鐘內不會過期,則傳回目前令牌。否則,這將刷新令牌並傳回一個新令牌。

簽名:

export declare function getIdTokenResult(user: User, forceRefresh?: boolean): Promise<IdTokenResult>;

參數

範圍類型描述
使用者使用者用戶。
強制刷新布林值無論令牌是否過期,都強制刷新。

返回:

Promise< IdTokenResult >

linkWithCredential(用戶,憑證)

將使用者帳戶與給定的憑證連結起來。

AuthProvider可用於產生憑證。

簽名:

export declare function linkWithCredential(user: User, credential: AuthCredential): Promise<UserCredential>;

參數

範圍類型描述
使用者使用者用戶。
憑證驗證憑證授權憑證。

返回:

承諾<使用者憑證>

linkWithPhoneNumber(用戶,電話號碼,appVerifier)

將用戶帳戶與給定的電話號碼連結。

此方法不適用於 Node.js 環境。

簽名:

export declare function linkWithPhoneNumber(user: User, phoneNumber: string, appVerifier: ApplicationVerifier): Promise<ConfirmationResult>;

參數

範圍類型描述
使用者使用者用戶。
電話號碼細繩E.164 格式的使用者電話號碼(例如+16505550101)。
應用程式驗證器應用驗證器應用程式驗證器

返回:

承諾<確認結果>

linkWithPopup(用戶,提供者,解析器)

使用基於彈出的 OAuth 流程將經過身份驗證的提供者連結到使用者帳戶。

如果連結成功,傳回的結果將包含使用者和提供者的憑證。

此方法不適用於 Node.js 環境。

簽名:

export declare function linkWithPopup(user: User, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<UserCredential>;

參數

範圍類型描述
使用者使用者用戶。
提供者認證提供者提供者進行身份驗證。提供者必須是OAuthProvider 。非 OAuth 提供者(例如EmailAuthProvider)將引發錯誤。
解析器彈出重定向解析器PopupRedirectResolver的實例,如果已提供給initializeAuth()或由getAuth()提供,則為可選

返回:

承諾<使用者憑證>

例子

// Sign in using some other provider.
const result = await signInWithEmailAndPassword(auth, email, password);
// Link using a popup.
const provider = new FacebookAuthProvider();
await linkWithPopup(result.user, provider);

linkWithRedirect(用戶,提供者,解析器)

使用全頁重定向流將OAuthProvider連結到使用者帳戶。

若要處理此操作的結果和錯誤,請參考getRedirectResult() 。使用linkWithRedirect()時遵循最佳實踐

此方法不適用於 Node.js 環境。

簽名:

export declare function linkWithRedirect(user: User, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<never>;

參數

範圍類型描述
使用者使用者用戶。
提供者認證提供者提供者進行身份驗證。提供者必須是OAuthProvider 。非 OAuth 提供者(例如EmailAuthProvider)將引發錯誤。
解析器彈出重定向解析器PopupRedirectResolver的實例,如果已經提供給initializeauth()getauth()提供的可選

返回:

承諾<every>

例子

// Sign in using some other provider.
const result = await signInWithEmailAndPassword(auth, email, password);
// Link using a redirect.
const provider = new FacebookAuthProvider();
await linkWithRedirect(result.user, provider);
// This will trigger a full page redirect away from your app

// After returning from the redirect when your app initializes you can obtain the result
const result = await getRedirectResult(auth);

多因素(用戶)

與使用者相對應的多效應器

這用於存取與使用者相關的所有多因素屬性和操作。

簽名:

export declare function multiFactor(user: User): MultiFactorUser;

參數

範圍類型描述
使用者使用者用戶。

返回:

多重效應器

重新授權WithCredential(用戶,憑證)

使用新的憑證重新認證使用者。

在操作之前使用諸如UpdatePassword()之類的操作,該操作需要從最近的登入嘗試中需要令牌。此方法可用於從CREDENTIAL_TOO_OLD_LOGIN_AGAIN錯誤或TOKEN_EXPIRED錯誤錯誤中復原。

簽名:

export declare function reauthenticateWithCredential(user: User, credential: AuthCredential): Promise<UserCredential>;

參數

範圍類型描述
使用者使用者用戶。
憑證身份認證身份證明。

返回:

Promise < Usercredential >

重新授權WithphoneNumber(用戶,Phonenumber,Apphverier)

使用新的電話憑證重新認證使用者。

在操作之前使用諸如UpdatePassword()之類的操作,該操作需要從最近的登入嘗試中需要令牌。

此方法在node.js環境中不起作用。

簽名:

export declare function reauthenticateWithPhoneNumber(user: User, phoneNumber: string, appVerifier: ApplicationVerifier): Promise<ConfirmationResult>;

參數

範圍類型描述
使用者使用者用戶。
電話號碼細繩用戶的電話號碼以e.164格式(例如+16505550101)。
相關器ApplicationVerifier應用程式伺服器

返回:

Promise <確認重點>

重新授權WithPopup(用戶,提供者,解析器)

使用基於彈出的OAuth流量,使用指定的OAuthProvider對目前使用者進行重新驗證。

如果重新驗證成功,則傳回的結果將包含使用者和提供者的憑證。

此方法在node.js環境中不起作用。

簽名:

export declare function reauthenticateWithPopup(user: User, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<UserCredential>;

參數

範圍類型描述
使用者使用者用戶。
提供者AuthProvider提供者可以進行身份驗證。提供者必須是oauthproviderEmailAuthProvider (例如Emainauthprovider)的非歐洲訴訟提供者將發生錯誤。
解析器popupredirectResolver popupredirectResolver的實例,如果已經提供給initializeauth()getauth()提供的可選

返回:

Promise < Usercredential >

例子

// Sign in using a popup.
const provider = new FacebookAuthProvider();
const result = await signInWithPopup(auth, provider);
// Reauthenticate using a popup.
await reauthenticateWithPopup(result.user, provider);

重新授權WithRedirect(用戶,提供者,解析器)

使用全頁重定向流量透過指定的OAuthProvider對目前使用者進行重新驗證。

若要處理此操作的結果和錯誤,請參閱GetRedirectResult() 。使用ReePulenticateWithRedirect()時遵循最佳實踐

此方法在node.js環境中不起作用。

簽名:

export declare function reauthenticateWithRedirect(user: User, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<never>;

參數

範圍類型描述
使用者使用者用戶。
提供者AuthProvider提供者可以進行身份驗證。提供者必須是oauthproviderEmailAuthProvider (例如Emainauthprovider)的非歐洲訴訟提供者將發生錯誤。
解析器popupredirectResolver popupredirectResolver的實例,如果已經提供給initializeauth()getauth()提供的可選

返回:

承諾<every>

例子

// Sign in using a redirect.
const provider = new FacebookAuthProvider();
const result = await signInWithRedirect(auth, provider);
// This will trigger a full page redirect away from your app

// After returning from the redirect when your app initializes you can obtain the result
const result = await getRedirectResult(auth);
// Reauthenticate using a redirect.
await reauthenticateWithRedirect(result.user, provider);
// This will again trigger a full page redirect away from your app

// After returning from the redirect when your app initializes you can obtain the result
const result = await getRedirectResult(auth);

重新載入(用戶)

重新載入使用者帳戶資料(如果簽署)。

簽名:

export declare function reload(user: User): Promise<void>;

參數

範圍類型描述
使用者使用者用戶。

返回:

承諾<void>

sendemailverification(用戶,動作庫)

向使用者發送驗證電子郵件。

驗證過程是透過呼叫applyactionCode()完成的

簽名:

export declare function sendEmailVerification(user: User, actionCodeSettings?: ActionCodeSettings | null): Promise<void>;

參數

範圍類型描述
使用者使用者用戶。
Action Codesettings ActionCodesettings |無效的動作尺寸

返回:

承諾<void>

例子

const actionCodeSettings = {
  url: 'https://www.example.com/?email=user@example.com',
  iOS: {
     bundleId: 'com.example.ios'
  },
  android: {
    packageName: 'com.example.android',
    installApp: true,
    minimumVersion: '12'
  },
  handleCodeInApp: true
};
await sendEmailVerification(user, actionCodeSettings);
// Obtain code from the user.
await applyActionCode(auth, code);

將提供者與使用者帳戶連結。

簽名:

export declare function unlink(user: User, providerId: string): Promise<User>;

參數

範圍類型描述
使用者使用者用戶。
Providerid細繩提供者要取消連結。

返回:

承諾<用戶>

UpdateEmail(用戶,newemail)

更新使用者的電子郵件地址。

一封電子郵件將發送到原始電子郵件地址(如果設定的話),該電子郵件允許撤銷電子郵件地址更改,以保護它們免受帳戶劫持。

簽名:

export declare function updateEmail(user: User, newEmail: string): Promise<void>;

參數

範圍類型描述
使用者使用者用戶。
新郵件細繩新的電子郵件地址。啟用[https://cloud.google.com/indesity-platform/docs/admin/admin/email-email-enumeration-protection)時,拋出「 auth/auth/operation-not-howered」錯誤(https: //cloud.google.com/indy.google.com/indy.google.com/side。棄用 - 改用verifybeforeupdateemail()

返回:

承諾<void>

UpdatePassword(用戶,newPassword)

更新用戶的密碼。

簽名:

export declare function updatePassword(user: User, newPassword: string): Promise<void>;

參數

範圍類型描述
使用者使用者用戶。
新密碼細繩新密碼。

返回:

承諾<void>

UpdatePhoneNumber(用戶,憑證)

更新用戶的電話號碼。

此方法在node.js環境中不起作用。

簽名:

export declare function updatePhoneNumber(user: User, credential: PhoneAuthCredential): Promise<void>;

參數

範圍類型描述
使用者使用者用戶。
憑證phoneAuthcredential憑證身分驗證新電話號碼。

返回:

承諾<void>

例子

// 'recaptcha-container' is the ID of an element in the DOM.
const applicationVerifier = new RecaptchaVerifier('recaptcha-container');
const provider = new PhoneAuthProvider(auth);
const verificationId = await provider.verifyPhoneNumber('+16505550101', applicationVerifier);
// Obtain the verificationCode from the user.
const phoneCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
await updatePhoneNumber(user, phoneCredential);

updateProfile(用戶,{displayName,photourl:photourl})

更新用戶的個人資料資料。

簽名:

export declare function updateProfile(user: User, { displayName, photoURL: photoUrl }: {
    displayName?: string | null;
    photoURL?: string | null;
}): Promise<void>;

參數

範圍類型描述
使用者使用者用戶。
{displayName,photourl:photourl} {displayName?:字串|無效的; photourl?:字串|無效的; }

返回:

承諾<void>

verifybeforeupdateemail(用戶,newemail,Action Codesettings)

將驗證電子郵件傳送到新的電子郵件地址。

經過驗證後,使用者的電子郵件將更新至新電子郵件。

如果您有自訂的電子郵件操作處理程序,則可以透過呼叫ApplionActionCode()來完成驗證過程

簽名:

export declare function verifyBeforeUpdateEmail(user: User, newEmail: string, actionCodeSettings?: ActionCodeSettings | null): Promise<void>;

參數

範圍類型描述
使用者使用者用戶。
新郵件細繩更新之前要驗證的新電子郵件地址。
Action Codesettings ActionCodesettings |無效的動作尺寸

返回:

承諾<void>

例子

const actionCodeSettings = {
  url: 'https://www.example.com/?email=user@example.com',
  iOS: {
     bundleId: 'com.example.ios'
  },
  android: {
    packageName: 'com.example.android',
    installApp: true,
    minimumVersion: '12'
  },
  handleCodeInApp: true
};
await verifyBeforeUpdateEmail(user, 'newemail@example.com', actionCodeSettings);
// Obtain code from the user.
await applyActionCode(auth, code);

功能(使用者限制,...)

getAdditionaluserInfo(使用者credential)

提取給定憑證的提供者特定的額外用品

簽名:

export declare function getAdditionalUserInfo(userCredential: UserCredential): AdditionalUserInfo | null;

參數

範圍類型描述
使用者行為使用者行為用戶憑證。

返回:

其他userinfo |無效的

ActionCodoperation

列舉可能的電子郵件操作類型。

簽名:

ActionCodeOperation: {
    readonly EMAIL_SIGNIN: "EMAIL_SIGNIN";
    readonly PASSWORD_RESET: "PASSWORD_RESET";
    readonly RECOVER_EMAIL: "RECOVER_EMAIL";
    readonly REVERT_SECOND_FACTOR_ADDITION: "REVERT_SECOND_FACTOR_ADDITION";
    readonly VERIFY_AND_CHANGE_EMAIL: "VERIFY_AND_CHANGE_EMAIL";
    readonly VERIFY_EMAIL: "VERIFY_EMAIL";
}

自我程式碼

潛在的Auth錯誤代碼的地圖,以便於與SDK丟棄的錯誤進行更輕鬆的比較。

請注意,您無法在地圖中的樹蛋糕中的單鑰匙,因此,透過使用地圖,您可能會大大增加捆綁包大小。

簽名:

AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY: {
    readonly ADMIN_ONLY_OPERATION: "auth/admin-restricted-operation";
    readonly ARGUMENT_ERROR: "auth/argument-error";
    readonly APP_NOT_AUTHORIZED: "auth/app-not-authorized";
    readonly APP_NOT_INSTALLED: "auth/app-not-installed";
    readonly CAPTCHA_CHECK_FAILED: "auth/captcha-check-failed";
    readonly CODE_EXPIRED: "auth/code-expired";
    readonly CORDOVA_NOT_READY: "auth/cordova-not-ready";
    readonly CORS_UNSUPPORTED: "auth/cors-unsupported";
    readonly CREDENTIAL_ALREADY_IN_USE: "auth/credential-already-in-use";
    readonly CREDENTIAL_MISMATCH: "auth/custom-token-mismatch";
    readonly CREDENTIAL_TOO_OLD_LOGIN_AGAIN: "auth/requires-recent-login";
    readonly DEPENDENT_SDK_INIT_BEFORE_AUTH: "auth/dependent-sdk-initialized-before-auth";
    readonly DYNAMIC_LINK_NOT_ACTIVATED: "auth/dynamic-link-not-activated";
    readonly EMAIL_CHANGE_NEEDS_VERIFICATION: "auth/email-change-needs-verification";
    readonly EMAIL_EXISTS: "auth/email-already-in-use";
    readonly EMULATOR_CONFIG_FAILED: "auth/emulator-config-failed";
    readonly EXPIRED_OOB_CODE: "auth/expired-action-code";
    readonly EXPIRED_POPUP_REQUEST: "auth/cancelled-popup-request";
    readonly INTERNAL_ERROR: "auth/internal-error";
    readonly INVALID_API_KEY: "auth/invalid-api-key";
    readonly INVALID_APP_CREDENTIAL: "auth/invalid-app-credential";
    readonly INVALID_APP_ID: "auth/invalid-app-id";
    readonly INVALID_AUTH: "auth/invalid-user-token";
    readonly INVALID_AUTH_EVENT: "auth/invalid-auth-event";
    readonly INVALID_CERT_HASH: "auth/invalid-cert-hash";
    readonly INVALID_CODE: "auth/invalid-verification-code";
    readonly INVALID_CONTINUE_URI: "auth/invalid-continue-uri";
    readonly INVALID_CORDOVA_CONFIGURATION: "auth/invalid-cordova-configuration";
    readonly INVALID_CUSTOM_TOKEN: "auth/invalid-custom-token";
    readonly INVALID_DYNAMIC_LINK_DOMAIN: "auth/invalid-dynamic-link-domain";
    readonly INVALID_EMAIL: "auth/invalid-email";
    readonly INVALID_EMULATOR_SCHEME: "auth/invalid-emulator-scheme";
    readonly INVALID_IDP_RESPONSE: "auth/invalid-credential";
    readonly INVALID_LOGIN_CREDENTIALS: "auth/invalid-credential";
    readonly INVALID_MESSAGE_PAYLOAD: "auth/invalid-message-payload";
    readonly INVALID_MFA_SESSION: "auth/invalid-multi-factor-session";
    readonly INVALID_OAUTH_CLIENT_ID: "auth/invalid-oauth-client-id";
    readonly INVALID_OAUTH_PROVIDER: "auth/invalid-oauth-provider";
    readonly INVALID_OOB_CODE: "auth/invalid-action-code";
    readonly INVALID_ORIGIN: "auth/unauthorized-domain";
    readonly INVALID_PASSWORD: "auth/wrong-password";
    readonly INVALID_PERSISTENCE: "auth/invalid-persistence-type";
    readonly INVALID_PHONE_NUMBER: "auth/invalid-phone-number";
    readonly INVALID_PROVIDER_ID: "auth/invalid-provider-id";
    readonly INVALID_RECIPIENT_EMAIL: "auth/invalid-recipient-email";
    readonly INVALID_SENDER: "auth/invalid-sender";
    readonly INVALID_SESSION_INFO: "auth/invalid-verification-id";
    readonly INVALID_TENANT_ID: "auth/invalid-tenant-id";
    readonly MFA_INFO_NOT_FOUND: "auth/multi-factor-info-not-found";
    readonly MFA_REQUIRED: "auth/multi-factor-auth-required";
    readonly MISSING_ANDROID_PACKAGE_NAME: "auth/missing-android-pkg-name";
    readonly MISSING_APP_CREDENTIAL: "auth/missing-app-credential";
    readonly MISSING_AUTH_DOMAIN: "auth/auth-domain-config-required";
    readonly MISSING_CODE: "auth/missing-verification-code";
    readonly MISSING_CONTINUE_URI: "auth/missing-continue-uri";
    readonly MISSING_IFRAME_START: "auth/missing-iframe-start";
    readonly MISSING_IOS_BUNDLE_ID: "auth/missing-ios-bundle-id";
    readonly MISSING_OR_INVALID_NONCE: "auth/missing-or-invalid-nonce";
    readonly MISSING_MFA_INFO: "auth/missing-multi-factor-info";
    readonly MISSING_MFA_SESSION: "auth/missing-multi-factor-session";
    readonly MISSING_PHONE_NUMBER: "auth/missing-phone-number";
    readonly MISSING_SESSION_INFO: "auth/missing-verification-id";
    readonly MODULE_DESTROYED: "auth/app-deleted";
    readonly NEED_CONFIRMATION: "auth/account-exists-with-different-credential";
    readonly NETWORK_REQUEST_FAILED: "auth/network-request-failed";
    readonly NULL_USER: "auth/null-user";
    readonly NO_AUTH_EVENT: "auth/no-auth-event";
    readonly NO_SUCH_PROVIDER: "auth/no-such-provider";
    readonly OPERATION_NOT_ALLOWED: "auth/operation-not-allowed";
    readonly OPERATION_NOT_SUPPORTED: "auth/operation-not-supported-in-this-environment";
    readonly POPUP_BLOCKED: "auth/popup-blocked";
    readonly POPUP_CLOSED_BY_USER: "auth/popup-closed-by-user";
    readonly PROVIDER_ALREADY_LINKED: "auth/provider-already-linked";
    readonly QUOTA_EXCEEDED: "auth/quota-exceeded";
    readonly REDIRECT_CANCELLED_BY_USER: "auth/redirect-cancelled-by-user";
    readonly REDIRECT_OPERATION_PENDING: "auth/redirect-operation-pending";
    readonly REJECTED_CREDENTIAL: "auth/rejected-credential";
    readonly SECOND_FACTOR_ALREADY_ENROLLED: "auth/second-factor-already-in-use";
    readonly SECOND_FACTOR_LIMIT_EXCEEDED: "auth/maximum-second-factor-count-exceeded";
    readonly TENANT_ID_MISMATCH: "auth/tenant-id-mismatch";
    readonly TIMEOUT: "auth/timeout";
    readonly TOKEN_EXPIRED: "auth/user-token-expired";
    readonly TOO_MANY_ATTEMPTS_TRY_LATER: "auth/too-many-requests";
    readonly UNAUTHORIZED_DOMAIN: "auth/unauthorized-continue-uri";
    readonly UNSUPPORTED_FIRST_FACTOR: "auth/unsupported-first-factor";
    readonly UNSUPPORTED_PERSISTENCE: "auth/unsupported-persistence-type";
    readonly UNSUPPORTED_TENANT_OPERATION: "auth/unsupported-tenant-operation";
    readonly UNVERIFIED_EMAIL: "auth/unverified-email";
    readonly USER_CANCELLED: "auth/user-cancelled";
    readonly USER_DELETED: "auth/user-not-found";
    readonly USER_DISABLED: "auth/user-disabled";
    readonly USER_MISMATCH: "auth/user-mismatch";
    readonly USER_SIGNED_OUT: "auth/user-signed-out";
    readonly WEAK_PASSWORD: "auth/weak-password";
    readonly WEB_STORAGE_UNSUPPORTED: "auth/web-storage-unsupported";
    readonly ALREADY_INITIALIZED: "auth/already-initialized";
    readonly RECAPTCHA_NOT_ENABLED: "auth/recaptcha-not-enabled";
    readonly MISSING_RECAPTCHA_TOKEN: "auth/missing-recaptcha-token";
    readonly INVALID_RECAPTCHA_TOKEN: "auth/invalid-recaptcha-token";
    readonly INVALID_RECAPTCHA_ACTION: "auth/invalid-recaptcha-action";
    readonly MISSING_CLIENT_TYPE: "auth/missing-client-type";
    readonly MISSING_RECAPTCHA_VERSION: "auth/missing-recaptcha-version";
    readonly INVALID_RECAPTCHA_VERSION: "auth/invalid-recaptcha-version";
    readonly INVALID_REQ_TYPE: "auth/invalid-req-type";
}

browserlocalististence

使用localStorage用於基礎儲存的LOCAL類型的持久性實作。

簽名:

browserLocalPersistence: Persistence

browserPopupRedirectResolver

適用於基於瀏覽器的應用程式的PopupRedectResolver的實作。

此方法在node.js環境中不起作用。

簽名:

browserPopupRedirectResolver: PopupRedirectResolver

瀏覽經驗

使用sessionStorage進行基礎儲存的SESSION持續性的實作。

簽名:

browserSessionPersistence: Persistence

CordovaPopupRedirectResolver

適用於基於Cordova的應用程式的PopupredectResolver的實作。

簽名:

cordovaPopupRedirectResolver: PopupRedirectResolver

debugerrormap

大多數錯誤代碼的詳細描述的詳細錯誤映射。

請參閱AutherRormap的討論

簽名:

debugErrorMap: AuthErrorMap

fixsid

可以用於多因素身份驗證的一系列因素。

簽名:

FactorId: {
    readonly PHONE: "phone";
    readonly TOTP: "totp";
}

索引dblocalcalistensive

使用indexedDB進行基礎儲存的LOCAL類型持久性的實作。

簽名:

indexedDBLocalPersistence: Persistence

不良過性

“無”類型持久性的實現。

簽名:

inMemoryPersistence: Persistence

操作類型

支援操作類型的枚舉。

簽名:

OperationType: {
    readonly LINK: "link";
    readonly REAUTHENTICATE: "reauthenticate";
    readonly SIGN_IN: "signIn";
}

proderrormap

最小錯誤映射,所有詳細錯誤訊息都刪除了。

請參閱AutherRormap的討論

簽名:

prodErrorMap: AuthErrorMap

Providerid

枚舉支援提供者。

簽名:

ProviderId: {
    readonly FACEBOOK: "facebook.com";
    readonly GITHUB: "github.com";
    readonly GOOGLE: "google.com";
    readonly PASSWORD: "password";
    readonly PHONE: "phone";
    readonly TWITTER: "twitter.com";
}

SignInMethod

支援的登入方法的列舉。

簽名:

SignInMethod: {
    readonly EMAIL_LINK: "emailLink";
    readonly EMAIL_PASSWORD: "password";
    readonly FACEBOOK: "facebook.com";
    readonly GITHUB: "github.com";
    readonly GOOGLE: "google.com";
    readonly PHONE: "phone";
    readonly TWITTER: "twitter.com";
}

自訂參數

OAUTH自訂參數的地圖。

簽名:

export declare type CustomParameters = Record<string, string>;

NextRobserver

鍵入事件回呼的定義。

簽名:

export declare type NextOrObserver<T> = NextFn<T | null> | Observer<T | null>;

phoneinfooptions

驗證電話號碼所有權所需的資訊。

所需的資訊取決於您是進行單因素登錄,多因素註冊還是多因素登錄。

簽名:

export declare type PhoneInfoOptions = PhoneSingleFactorInfoOptions | PhoneMultiFactorEnrollInfoOptions | PhoneMultiFactorSignInInfoOptions;

使用者資料

使用者設定檔中使用的使用者設定檔

簽名:

export declare type UserProfile = Record<string, unknown>;