Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

auth-public.d.ts 121KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557
  1. /**
  2. * Firebase Authentication
  3. *
  4. * @packageDocumentation
  5. */
  6. import { CompleteFn } from '@firebase/util';
  7. import { ErrorFactory } from '@firebase/util';
  8. import { ErrorFn } from '@firebase/util';
  9. import { FirebaseApp } from '@firebase/app';
  10. import { FirebaseError } from '@firebase/util';
  11. import { NextFn } from '@firebase/util';
  12. import { Observer } from '@firebase/util';
  13. import { Unsubscribe } from '@firebase/util';
  14. /**
  15. * A response from {@link checkActionCode}.
  16. *
  17. * @public
  18. */
  19. export declare interface ActionCodeInfo {
  20. /**
  21. * The data associated with the action code.
  22. *
  23. * @remarks
  24. * For the {@link ActionCodeOperation}.PASSWORD_RESET, {@link ActionCodeOperation}.VERIFY_EMAIL, and
  25. * {@link ActionCodeOperation}.RECOVER_EMAIL actions, this object contains an email field with the address
  26. * the email was sent to.
  27. *
  28. * For the {@link ActionCodeOperation}.RECOVER_EMAIL action, which allows a user to undo an email address
  29. * change, this object also contains a `previousEmail` field with the user account's current
  30. * email address. After the action completes, the user's email address will revert to the value
  31. * in the `email` field from the value in `previousEmail` field.
  32. *
  33. * For the {@link ActionCodeOperation}.VERIFY_AND_CHANGE_EMAIL action, which allows a user to verify the
  34. * email before updating it, this object contains a `previousEmail` field with the user account's
  35. * email address before updating. After the action completes, the user's email address will be
  36. * updated to the value in the `email` field from the value in `previousEmail` field.
  37. *
  38. * For the {@link ActionCodeOperation}.REVERT_SECOND_FACTOR_ADDITION action, which allows a user to
  39. * unenroll a newly added second factor, this object contains a `multiFactorInfo` field with
  40. * the information about the second factor. For phone second factor, the `multiFactorInfo`
  41. * is a {@link MultiFactorInfo} object, which contains the phone number.
  42. */
  43. data: {
  44. email?: string | null;
  45. multiFactorInfo?: MultiFactorInfo | null;
  46. previousEmail?: string | null;
  47. };
  48. /**
  49. * The type of operation that generated the action code.
  50. */
  51. operation: typeof ActionCodeOperation[keyof typeof ActionCodeOperation];
  52. }
  53. /**
  54. * An enumeration of the possible email action types.
  55. *
  56. * @public
  57. */
  58. export declare const ActionCodeOperation: {
  59. /** The email link sign-in action. */
  60. readonly EMAIL_SIGNIN: "EMAIL_SIGNIN";
  61. /** The password reset action. */
  62. readonly PASSWORD_RESET: "PASSWORD_RESET";
  63. /** The email revocation action. */
  64. readonly RECOVER_EMAIL: "RECOVER_EMAIL";
  65. /** The revert second factor addition email action. */
  66. readonly REVERT_SECOND_FACTOR_ADDITION: "REVERT_SECOND_FACTOR_ADDITION";
  67. /** The revert second factor addition email action. */
  68. readonly VERIFY_AND_CHANGE_EMAIL: "VERIFY_AND_CHANGE_EMAIL";
  69. /** The email verification action. */
  70. readonly VERIFY_EMAIL: "VERIFY_EMAIL";
  71. };
  72. /**
  73. * An interface that defines the required continue/state URL with optional Android and iOS
  74. * bundle identifiers.
  75. *
  76. * @public
  77. */
  78. export declare interface ActionCodeSettings {
  79. /**
  80. * Sets the Android package name.
  81. *
  82. * @remarks
  83. * This will try to open the link in an android app if it is
  84. * installed. If `installApp` is passed, it specifies whether to install the Android app if the
  85. * device supports it and the app is not already installed. If this field is provided without
  86. * a `packageName`, an error is thrown explaining that the `packageName` must be provided in
  87. * conjunction with this field. If `minimumVersion` is specified, and an older version of the
  88. * app is installed, the user is taken to the Play Store to upgrade the app.
  89. */
  90. android?: {
  91. installApp?: boolean;
  92. minimumVersion?: string;
  93. packageName: string;
  94. };
  95. /**
  96. * When set to true, the action code link will be be sent as a Universal Link or Android App
  97. * Link and will be opened by the app if installed.
  98. *
  99. * @remarks
  100. * In the false case, the code will be sent to the web widget first and then on continue will
  101. * redirect to the app if installed.
  102. *
  103. * @defaultValue false
  104. */
  105. handleCodeInApp?: boolean;
  106. /**
  107. * Sets the iOS bundle ID.
  108. *
  109. * @remarks
  110. * This will try to open the link in an iOS app if it is installed.
  111. *
  112. * App installation is not supported for iOS.
  113. */
  114. iOS?: {
  115. bundleId: string;
  116. };
  117. /**
  118. * Sets the link continue/state URL.
  119. *
  120. * @remarks
  121. * This has different meanings in different contexts:
  122. * - When the link is handled in the web action widgets, this is the deep link in the
  123. * `continueUrl` query parameter.
  124. * - When the link is handled in the app directly, this is the `continueUrl` query parameter in
  125. * the deep link of the Dynamic Link.
  126. */
  127. url: string;
  128. /**
  129. * When multiple custom dynamic link domains are defined for a project, specify which one to use
  130. * when the link is to be opened via a specified mobile app (for example, `example.page.link`).
  131. *
  132. *
  133. * @defaultValue The first domain is automatically selected.
  134. */
  135. dynamicLinkDomain?: string;
  136. }
  137. /**
  138. * @license
  139. * Copyright 2020 Google LLC
  140. *
  141. * Licensed under the Apache License, Version 2.0 (the "License");
  142. * you may not use this file except in compliance with the License.
  143. * You may obtain a copy of the License at
  144. *
  145. * http://www.apache.org/licenses/LICENSE-2.0
  146. *
  147. * Unless required by applicable law or agreed to in writing, software
  148. * distributed under the License is distributed on an "AS IS" BASIS,
  149. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  150. * See the License for the specific language governing permissions and
  151. * limitations under the License.
  152. */
  153. /**
  154. * A utility class to parse email action URLs such as password reset, email verification,
  155. * email link sign in, etc.
  156. *
  157. * @public
  158. */
  159. export declare class ActionCodeURL {
  160. /**
  161. * The API key of the email action link.
  162. */
  163. readonly apiKey: string;
  164. /**
  165. * The action code of the email action link.
  166. */
  167. readonly code: string;
  168. /**
  169. * The continue URL of the email action link. Null if not provided.
  170. */
  171. readonly continueUrl: string | null;
  172. /**
  173. * The language code of the email action link. Null if not provided.
  174. */
  175. readonly languageCode: string | null;
  176. /**
  177. * The action performed by the email action link. It returns from one of the types from
  178. * {@link ActionCodeInfo}
  179. */
  180. readonly operation: string;
  181. /**
  182. * The tenant ID of the email action link. Null if the email action is from the parent project.
  183. */
  184. readonly tenantId: string | null;
  185. /* Excluded from this release type: __constructor */
  186. /**
  187. * Parses the email action link string and returns an {@link ActionCodeURL} if the link is valid,
  188. * otherwise returns null.
  189. *
  190. * @param link - The email action link string.
  191. * @returns The {@link ActionCodeURL} object, or null if the link is invalid.
  192. *
  193. * @public
  194. */
  195. static parseLink(link: string): ActionCodeURL | null;
  196. }
  197. /**
  198. * A structure containing additional user information from a federated identity provider.
  199. *
  200. * @public
  201. */
  202. export declare interface AdditionalUserInfo {
  203. /**
  204. * Whether the user is new (created via sign-up) or existing (authenticated using sign-in).
  205. */
  206. readonly isNewUser: boolean;
  207. /**
  208. * Map containing IDP-specific user data.
  209. */
  210. readonly profile: Record<string, unknown> | null;
  211. /**
  212. * Identifier for the provider used to authenticate this user.
  213. */
  214. readonly providerId: string | null;
  215. /**
  216. * The username if the provider is GitHub or Twitter.
  217. */
  218. readonly username?: string | null;
  219. }
  220. declare interface APIUserInfo {
  221. localId?: string;
  222. displayName?: string;
  223. photoUrl?: string;
  224. email?: string;
  225. emailVerified?: boolean;
  226. phoneNumber?: string;
  227. lastLoginAt?: number;
  228. createdAt?: number;
  229. tenantId?: string;
  230. passwordHash?: string;
  231. providerUserInfo?: ProviderUserInfo[];
  232. mfaInfo?: MfaEnrollment[];
  233. }
  234. /**
  235. * A verifier for domain verification and abuse prevention.
  236. *
  237. * @remarks
  238. * Currently, the only implementation is {@link RecaptchaVerifier}.
  239. *
  240. * @public
  241. */
  242. export declare interface ApplicationVerifier {
  243. /**
  244. * Identifies the type of application verifier (e.g. "recaptcha").
  245. */
  246. readonly type: string;
  247. /**
  248. * Executes the verification process.
  249. *
  250. * @returns A Promise for a token that can be used to assert the validity of a request.
  251. */
  252. verify(): Promise<string>;
  253. }
  254. declare interface ApplicationVerifierInternal extends ApplicationVerifier {
  255. /* Excluded from this release type: _reset */
  256. }
  257. /**
  258. * Applies a verification code sent to the user by email or other out-of-band mechanism.
  259. *
  260. * @param auth - The {@link Auth} instance.
  261. * @param oobCode - A verification code sent to the user.
  262. *
  263. * @public
  264. */
  265. export declare function applyActionCode(auth: Auth, oobCode: string): Promise<void>;
  266. declare type AppName = string;
  267. /**
  268. * Interface representing Firebase Auth service.
  269. *
  270. * @remarks
  271. * See {@link https://firebase.google.com/docs/auth/ | Firebase Authentication} for a full guide
  272. * on how to use the Firebase Auth service.
  273. *
  274. * @public
  275. */
  276. export declare interface Auth {
  277. /** The {@link @firebase/app#FirebaseApp} associated with the `Auth` service instance. */
  278. readonly app: FirebaseApp;
  279. /** The name of the app associated with the `Auth` service instance. */
  280. readonly name: string;
  281. /** The {@link Config} used to initialize this instance. */
  282. readonly config: Config;
  283. /**
  284. * Changes the type of persistence on the `Auth` instance.
  285. *
  286. * @remarks
  287. * This will affect the currently saved Auth session and applies this type of persistence for
  288. * future sign-in requests, including sign-in with redirect requests.
  289. *
  290. * This makes it easy for a user signing in to specify whether their session should be
  291. * remembered or not. It also makes it easier to never persist the Auth state for applications
  292. * that are shared by other users or have sensitive data.
  293. *
  294. * @example
  295. * ```javascript
  296. * auth.setPersistence(browserSessionPersistence);
  297. * ```
  298. *
  299. * @param persistence - The {@link Persistence} to use.
  300. */
  301. setPersistence(persistence: Persistence): Promise<void>;
  302. /**
  303. * The {@link Auth} instance's language code.
  304. *
  305. * @remarks
  306. * This is a readable/writable property. When set to null, the default Firebase Console language
  307. * setting is applied. The language code will propagate to email action templates (password
  308. * reset, email verification and email change revocation), SMS templates for phone authentication,
  309. * reCAPTCHA verifier and OAuth popup/redirect operations provided the specified providers support
  310. * localization with the language code specified.
  311. */
  312. languageCode: string | null;
  313. /**
  314. * The {@link Auth} instance's tenant ID.
  315. *
  316. * @remarks
  317. * This is a readable/writable property. When you set the tenant ID of an {@link Auth} instance, all
  318. * future sign-in/sign-up operations will pass this tenant ID and sign in or sign up users to
  319. * the specified tenant project. When set to null, users are signed in to the parent project.
  320. *
  321. * @example
  322. * ```javascript
  323. * // Set the tenant ID on Auth instance.
  324. * auth.tenantId = 'TENANT_PROJECT_ID';
  325. *
  326. * // All future sign-in request now include tenant ID.
  327. * const result = await signInWithEmailAndPassword(auth, email, password);
  328. * // result.user.tenantId should be 'TENANT_PROJECT_ID'.
  329. * ```
  330. *
  331. * @defaultValue null
  332. */
  333. tenantId: string | null;
  334. /**
  335. * The {@link Auth} instance's settings.
  336. *
  337. * @remarks
  338. * This is used to edit/read configuration related options such as app verification mode for
  339. * phone authentication.
  340. */
  341. readonly settings: AuthSettings;
  342. /**
  343. * Adds an observer for changes to the user's sign-in state.
  344. *
  345. * @remarks
  346. * To keep the old behavior, see {@link Auth.onIdTokenChanged}.
  347. *
  348. * @param nextOrObserver - callback triggered on change.
  349. * @param error - Deprecated. This callback is never triggered. Errors
  350. * on signing in/out can be caught in promises returned from
  351. * sign-in/sign-out functions.
  352. * @param completed - Deprecated. This callback is never triggered.
  353. */
  354. onAuthStateChanged(nextOrObserver: NextOrObserver<User | null>, error?: ErrorFn, completed?: CompleteFn): Unsubscribe;
  355. /**
  356. * Adds a blocking callback that runs before an auth state change
  357. * sets a new user.
  358. *
  359. * @param callback - callback triggered before new user value is set.
  360. * If this throws, it blocks the user from being set.
  361. * @param onAbort - callback triggered if a later `beforeAuthStateChanged()`
  362. * callback throws, allowing you to undo any side effects.
  363. */
  364. beforeAuthStateChanged(callback: (user: User | null) => void | Promise<void>, onAbort?: () => void): Unsubscribe;
  365. /**
  366. * Adds an observer for changes to the signed-in user's ID token.
  367. *
  368. * @remarks
  369. * This includes sign-in, sign-out, and token refresh events.
  370. *
  371. * @param nextOrObserver - callback triggered on change.
  372. * @param error - Deprecated. This callback is never triggered. Errors
  373. * on signing in/out can be caught in promises returned from
  374. * sign-in/sign-out functions.
  375. * @param completed - Deprecated. This callback is never triggered.
  376. */
  377. onIdTokenChanged(nextOrObserver: NextOrObserver<User | null>, error?: ErrorFn, completed?: CompleteFn): Unsubscribe;
  378. /** The currently signed-in user (or null). */
  379. readonly currentUser: User | null;
  380. /** The current emulator configuration (or null). */
  381. readonly emulatorConfig: EmulatorConfig | null;
  382. /**
  383. * Asynchronously sets the provided user as {@link Auth.currentUser} on the {@link Auth} instance.
  384. *
  385. * @remarks
  386. * A new instance copy of the user provided will be made and set as currentUser.
  387. *
  388. * This will trigger {@link Auth.onAuthStateChanged} and {@link Auth.onIdTokenChanged} listeners
  389. * like other sign in methods.
  390. *
  391. * The operation fails with an error if the user to be updated belongs to a different Firebase
  392. * project.
  393. *
  394. * @param user - The new {@link User}.
  395. */
  396. updateCurrentUser(user: User | null): Promise<void>;
  397. /**
  398. * Sets the current language to the default device/browser preference.
  399. */
  400. useDeviceLanguage(): void;
  401. /**
  402. * Signs out the current user.
  403. */
  404. signOut(): Promise<void>;
  405. }
  406. /**
  407. * Interface that represents the credentials returned by an {@link AuthProvider}.
  408. *
  409. * @remarks
  410. * Implementations specify the details about each auth provider's credential requirements.
  411. *
  412. * @public
  413. */
  414. export declare class AuthCredential {
  415. /**
  416. * The authentication provider ID for the credential.
  417. *
  418. * @remarks
  419. * For example, 'facebook.com', or 'google.com'.
  420. */
  421. readonly providerId: string;
  422. /**
  423. * The authentication sign in method for the credential.
  424. *
  425. * @remarks
  426. * For example, {@link SignInMethod}.EMAIL_PASSWORD, or
  427. * {@link SignInMethod}.EMAIL_LINK. This corresponds to the sign-in method
  428. * identifier as returned in {@link fetchSignInMethodsForEmail}.
  429. */
  430. readonly signInMethod: string;
  431. /* Excluded from this release type: __constructor */
  432. /**
  433. * Returns a JSON-serializable representation of this object.
  434. *
  435. * @returns a JSON-serializable representation of this object.
  436. */
  437. toJSON(): object;
  438. /* Excluded from this release type: _getIdTokenResponse */
  439. /* Excluded from this release type: _linkToIdToken */
  440. /* Excluded from this release type: _getReauthenticationResolver */
  441. }
  442. /**
  443. * Interface for an `Auth` error.
  444. *
  445. * @public
  446. */
  447. export declare interface AuthError extends FirebaseError {
  448. /** Details about the Firebase Auth error. */
  449. readonly customData: {
  450. /** The name of the Firebase App which triggered this error. */
  451. readonly appName: string;
  452. /** The email address of the user's account, used for sign-in and linking. */
  453. readonly email?: string;
  454. /** The phone number of the user's account, used for sign-in and linking. */
  455. readonly phoneNumber?: string;
  456. /**
  457. * The tenant ID being used for sign-in and linking.
  458. *
  459. * @remarks
  460. * If you use {@link signInWithRedirect} to sign in,
  461. * you have to set the tenant ID on the {@link Auth} instance again as the tenant ID is not persisted
  462. * after redirection.
  463. */
  464. readonly tenantId?: string;
  465. };
  466. }
  467. /* Excluded from this release type: AuthErrorCode */
  468. /**
  469. * A map of potential `Auth` error codes, for easier comparison with errors
  470. * thrown by the SDK.
  471. *
  472. * @remarks
  473. * Note that you can't tree-shake individual keys
  474. * in the map, so by using the map you might substantially increase your
  475. * bundle size.
  476. *
  477. * @public
  478. */
  479. export declare const AuthErrorCodes: {
  480. readonly ADMIN_ONLY_OPERATION: "auth/admin-restricted-operation";
  481. readonly ARGUMENT_ERROR: "auth/argument-error";
  482. readonly APP_NOT_AUTHORIZED: "auth/app-not-authorized";
  483. readonly APP_NOT_INSTALLED: "auth/app-not-installed";
  484. readonly CAPTCHA_CHECK_FAILED: "auth/captcha-check-failed";
  485. readonly CODE_EXPIRED: "auth/code-expired";
  486. readonly CORDOVA_NOT_READY: "auth/cordova-not-ready";
  487. readonly CORS_UNSUPPORTED: "auth/cors-unsupported";
  488. readonly CREDENTIAL_ALREADY_IN_USE: "auth/credential-already-in-use";
  489. readonly CREDENTIAL_MISMATCH: "auth/custom-token-mismatch";
  490. readonly CREDENTIAL_TOO_OLD_LOGIN_AGAIN: "auth/requires-recent-login";
  491. readonly DEPENDENT_SDK_INIT_BEFORE_AUTH: "auth/dependent-sdk-initialized-before-auth";
  492. readonly DYNAMIC_LINK_NOT_ACTIVATED: "auth/dynamic-link-not-activated";
  493. readonly EMAIL_CHANGE_NEEDS_VERIFICATION: "auth/email-change-needs-verification";
  494. readonly EMAIL_EXISTS: "auth/email-already-in-use";
  495. readonly EMULATOR_CONFIG_FAILED: "auth/emulator-config-failed";
  496. readonly EXPIRED_OOB_CODE: "auth/expired-action-code";
  497. readonly EXPIRED_POPUP_REQUEST: "auth/cancelled-popup-request";
  498. readonly INTERNAL_ERROR: "auth/internal-error";
  499. readonly INVALID_API_KEY: "auth/invalid-api-key";
  500. readonly INVALID_APP_CREDENTIAL: "auth/invalid-app-credential";
  501. readonly INVALID_APP_ID: "auth/invalid-app-id";
  502. readonly INVALID_AUTH: "auth/invalid-user-token";
  503. readonly INVALID_AUTH_EVENT: "auth/invalid-auth-event";
  504. readonly INVALID_CERT_HASH: "auth/invalid-cert-hash";
  505. readonly INVALID_CODE: "auth/invalid-verification-code";
  506. readonly INVALID_CONTINUE_URI: "auth/invalid-continue-uri";
  507. readonly INVALID_CORDOVA_CONFIGURATION: "auth/invalid-cordova-configuration";
  508. readonly INVALID_CUSTOM_TOKEN: "auth/invalid-custom-token";
  509. readonly INVALID_DYNAMIC_LINK_DOMAIN: "auth/invalid-dynamic-link-domain";
  510. readonly INVALID_EMAIL: "auth/invalid-email";
  511. readonly INVALID_EMULATOR_SCHEME: "auth/invalid-emulator-scheme";
  512. readonly INVALID_IDP_RESPONSE: "auth/invalid-credential";
  513. readonly INVALID_MESSAGE_PAYLOAD: "auth/invalid-message-payload";
  514. readonly INVALID_MFA_SESSION: "auth/invalid-multi-factor-session";
  515. readonly INVALID_OAUTH_CLIENT_ID: "auth/invalid-oauth-client-id";
  516. readonly INVALID_OAUTH_PROVIDER: "auth/invalid-oauth-provider";
  517. readonly INVALID_OOB_CODE: "auth/invalid-action-code";
  518. readonly INVALID_ORIGIN: "auth/unauthorized-domain";
  519. readonly INVALID_PASSWORD: "auth/wrong-password";
  520. readonly INVALID_PERSISTENCE: "auth/invalid-persistence-type";
  521. readonly INVALID_PHONE_NUMBER: "auth/invalid-phone-number";
  522. readonly INVALID_PROVIDER_ID: "auth/invalid-provider-id";
  523. readonly INVALID_RECIPIENT_EMAIL: "auth/invalid-recipient-email";
  524. readonly INVALID_SENDER: "auth/invalid-sender";
  525. readonly INVALID_SESSION_INFO: "auth/invalid-verification-id";
  526. readonly INVALID_TENANT_ID: "auth/invalid-tenant-id";
  527. readonly MFA_INFO_NOT_FOUND: "auth/multi-factor-info-not-found";
  528. readonly MFA_REQUIRED: "auth/multi-factor-auth-required";
  529. readonly MISSING_ANDROID_PACKAGE_NAME: "auth/missing-android-pkg-name";
  530. readonly MISSING_APP_CREDENTIAL: "auth/missing-app-credential";
  531. readonly MISSING_AUTH_DOMAIN: "auth/auth-domain-config-required";
  532. readonly MISSING_CODE: "auth/missing-verification-code";
  533. readonly MISSING_CONTINUE_URI: "auth/missing-continue-uri";
  534. readonly MISSING_IFRAME_START: "auth/missing-iframe-start";
  535. readonly MISSING_IOS_BUNDLE_ID: "auth/missing-ios-bundle-id";
  536. readonly MISSING_OR_INVALID_NONCE: "auth/missing-or-invalid-nonce";
  537. readonly MISSING_MFA_INFO: "auth/missing-multi-factor-info";
  538. readonly MISSING_MFA_SESSION: "auth/missing-multi-factor-session";
  539. readonly MISSING_PHONE_NUMBER: "auth/missing-phone-number";
  540. readonly MISSING_SESSION_INFO: "auth/missing-verification-id";
  541. readonly MODULE_DESTROYED: "auth/app-deleted";
  542. readonly NEED_CONFIRMATION: "auth/account-exists-with-different-credential";
  543. readonly NETWORK_REQUEST_FAILED: "auth/network-request-failed";
  544. readonly NULL_USER: "auth/null-user";
  545. readonly NO_AUTH_EVENT: "auth/no-auth-event";
  546. readonly NO_SUCH_PROVIDER: "auth/no-such-provider";
  547. readonly OPERATION_NOT_ALLOWED: "auth/operation-not-allowed";
  548. readonly OPERATION_NOT_SUPPORTED: "auth/operation-not-supported-in-this-environment";
  549. readonly POPUP_BLOCKED: "auth/popup-blocked";
  550. readonly POPUP_CLOSED_BY_USER: "auth/popup-closed-by-user";
  551. readonly PROVIDER_ALREADY_LINKED: "auth/provider-already-linked";
  552. readonly QUOTA_EXCEEDED: "auth/quota-exceeded";
  553. readonly REDIRECT_CANCELLED_BY_USER: "auth/redirect-cancelled-by-user";
  554. readonly REDIRECT_OPERATION_PENDING: "auth/redirect-operation-pending";
  555. readonly REJECTED_CREDENTIAL: "auth/rejected-credential";
  556. readonly SECOND_FACTOR_ALREADY_ENROLLED: "auth/second-factor-already-in-use";
  557. readonly SECOND_FACTOR_LIMIT_EXCEEDED: "auth/maximum-second-factor-count-exceeded";
  558. readonly TENANT_ID_MISMATCH: "auth/tenant-id-mismatch";
  559. readonly TIMEOUT: "auth/timeout";
  560. readonly TOKEN_EXPIRED: "auth/user-token-expired";
  561. readonly TOO_MANY_ATTEMPTS_TRY_LATER: "auth/too-many-requests";
  562. readonly UNAUTHORIZED_DOMAIN: "auth/unauthorized-continue-uri";
  563. readonly UNSUPPORTED_FIRST_FACTOR: "auth/unsupported-first-factor";
  564. readonly UNSUPPORTED_PERSISTENCE: "auth/unsupported-persistence-type";
  565. readonly UNSUPPORTED_TENANT_OPERATION: "auth/unsupported-tenant-operation";
  566. readonly UNVERIFIED_EMAIL: "auth/unverified-email";
  567. readonly USER_CANCELLED: "auth/user-cancelled";
  568. readonly USER_DELETED: "auth/user-not-found";
  569. readonly USER_DISABLED: "auth/user-disabled";
  570. readonly USER_MISMATCH: "auth/user-mismatch";
  571. readonly USER_SIGNED_OUT: "auth/user-signed-out";
  572. readonly WEAK_PASSWORD: "auth/weak-password";
  573. readonly WEB_STORAGE_UNSUPPORTED: "auth/web-storage-unsupported";
  574. readonly ALREADY_INITIALIZED: "auth/already-initialized";
  575. };
  576. /**
  577. * A mapping of error codes to error messages.
  578. *
  579. * @remarks
  580. *
  581. * While error messages are useful for debugging (providing verbose textual
  582. * context around what went wrong), these strings take up a lot of space in the
  583. * compiled code. When deploying code in production, using {@link prodErrorMap}
  584. * will save you roughly 10k compressed/gzipped over {@link debugErrorMap}. You
  585. * can select the error map during initialization:
  586. *
  587. * ```javascript
  588. * initializeAuth(app, {errorMap: debugErrorMap})
  589. * ```
  590. *
  591. * When initializing Auth, {@link prodErrorMap} is default.
  592. *
  593. * @public
  594. */
  595. export declare interface AuthErrorMap {
  596. }
  597. /* Excluded from this release type: AuthErrorParams */
  598. /* Excluded from this release type: AuthEvent */
  599. /* Excluded from this release type: AuthEventConsumer */
  600. declare interface AuthEventError extends Error {
  601. code: string;
  602. message: string;
  603. }
  604. /* Excluded from this release type: AuthEventType */
  605. /* Excluded from this release type: AuthInternal */
  606. declare class AuthPopup {
  607. readonly window: Window | null;
  608. associatedEvent: string | null;
  609. constructor(window: Window | null);
  610. close(): void;
  611. }
  612. /**
  613. * Interface that represents an auth provider, used to facilitate creating {@link AuthCredential}.
  614. *
  615. * @public
  616. */
  617. export declare interface AuthProvider {
  618. /**
  619. * Provider for which credentials can be constructed.
  620. */
  621. readonly providerId: string;
  622. }
  623. /**
  624. * Interface representing an {@link Auth} instance's settings.
  625. *
  626. * @remarks Currently used for enabling/disabling app verification for phone Auth testing.
  627. *
  628. * @public
  629. */
  630. export declare interface AuthSettings {
  631. /**
  632. * When set, this property disables app verification for the purpose of testing phone
  633. * authentication. For this property to take effect, it needs to be set before rendering a
  634. * reCAPTCHA app verifier. When this is disabled, a mock reCAPTCHA is rendered instead. This is
  635. * useful for manual testing during development or for automated integration tests.
  636. *
  637. * In order to use this feature, you will need to
  638. * {@link https://firebase.google.com/docs/auth/web/phone-auth#test-with-whitelisted-phone-numbers | whitelist your phone number}
  639. * via the Firebase Console.
  640. *
  641. * The default value is false (app verification is enabled).
  642. */
  643. appVerificationDisabledForTesting: boolean;
  644. }
  645. /**
  646. * MFA Info as returned by the API
  647. */
  648. declare interface BaseMfaEnrollment {
  649. mfaEnrollmentId: string;
  650. enrolledAt: number;
  651. displayName?: string;
  652. }
  653. /**
  654. * Common code to all OAuth providers. This is separate from the
  655. * {@link OAuthProvider} so that child providers (like
  656. * {@link GoogleAuthProvider}) don't inherit the `credential` instance method.
  657. * Instead, they rely on a static `credential` method.
  658. */
  659. declare abstract class BaseOAuthProvider extends FederatedAuthProvider implements AuthProvider {
  660. /* Excluded from this release type: scopes */
  661. /**
  662. * Add an OAuth scope to the credential.
  663. *
  664. * @param scope - Provider OAuth scope to add.
  665. */
  666. addScope(scope: string): AuthProvider;
  667. /**
  668. * Retrieve the current list of OAuth scopes.
  669. */
  670. getScopes(): string[];
  671. }
  672. /**
  673. * Adds a blocking callback that runs before an auth state change
  674. * sets a new user.
  675. *
  676. * @param auth - The {@link Auth} instance.
  677. * @param callback - callback triggered before new user value is set.
  678. * If this throws, it blocks the user from being set.
  679. * @param onAbort - callback triggered if a later `beforeAuthStateChanged()`
  680. * callback throws, allowing you to undo any side effects.
  681. */
  682. export declare function beforeAuthStateChanged(auth: Auth, callback: (user: User | null) => void | Promise<void>, onAbort?: () => void): Unsubscribe;
  683. /**
  684. * An implementation of {@link Persistence} of type `LOCAL` using `localStorage`
  685. * for the underlying storage.
  686. *
  687. * @public
  688. */
  689. export declare const browserLocalPersistence: Persistence;
  690. /**
  691. * An implementation of {@link PopupRedirectResolver} suitable for browser
  692. * based applications.
  693. *
  694. * @public
  695. */
  696. export declare const browserPopupRedirectResolver: PopupRedirectResolver;
  697. /**
  698. * An implementation of {@link Persistence} of `SESSION` using `sessionStorage`
  699. * for the underlying storage.
  700. *
  701. * @public
  702. */
  703. export declare const browserSessionPersistence: Persistence;
  704. /**
  705. * Checks a verification code sent to the user by email or other out-of-band mechanism.
  706. *
  707. * @returns metadata about the code.
  708. *
  709. * @param auth - The {@link Auth} instance.
  710. * @param oobCode - A verification code sent to the user.
  711. *
  712. * @public
  713. */
  714. export declare function checkActionCode(auth: Auth, oobCode: string): Promise<ActionCodeInfo>;
  715. /* Excluded from this release type: ClientPlatform */
  716. export { CompleteFn }
  717. /**
  718. * Interface representing the `Auth` config.
  719. *
  720. * @public
  721. */
  722. export declare interface Config {
  723. /**
  724. * The API Key used to communicate with the Firebase Auth backend.
  725. */
  726. apiKey: string;
  727. /**
  728. * The host at which the Firebase Auth backend is running.
  729. */
  730. apiHost: string;
  731. /**
  732. * The scheme used to communicate with the Firebase Auth backend.
  733. */
  734. apiScheme: string;
  735. /**
  736. * The host at which the Secure Token API is running.
  737. */
  738. tokenApiHost: string;
  739. /**
  740. * The SDK Client Version.
  741. */
  742. sdkClientVersion: string;
  743. /**
  744. * The domain at which the web widgets are hosted (provided via Firebase Config).
  745. */
  746. authDomain?: string;
  747. }
  748. /* Excluded from this release type: ConfigInternal */
  749. /**
  750. * A result from a phone number sign-in, link, or reauthenticate call.
  751. *
  752. * @public
  753. */
  754. export declare interface ConfirmationResult {
  755. /**
  756. * The phone number authentication operation's verification ID.
  757. *
  758. * @remarks
  759. * This can be used along with the verification code to initialize a
  760. * {@link PhoneAuthCredential}.
  761. */
  762. readonly verificationId: string;
  763. /**
  764. * Finishes a phone number sign-in, link, or reauthentication.
  765. *
  766. * @example
  767. * ```javascript
  768. * const confirmationResult = await signInWithPhoneNumber(auth, phoneNumber, applicationVerifier);
  769. * // Obtain verificationCode from the user.
  770. * const userCredential = await confirmationResult.confirm(verificationCode);
  771. * ```
  772. *
  773. * @param verificationCode - The code that was sent to the user's mobile device.
  774. */
  775. confirm(verificationCode: string): Promise<UserCredential>;
  776. }
  777. /**
  778. * Completes the password reset process, given a confirmation code and new password.
  779. *
  780. * @param auth - The {@link Auth} instance.
  781. * @param oobCode - A confirmation code sent to the user.
  782. * @param newPassword - The new password.
  783. *
  784. * @public
  785. */
  786. export declare function confirmPasswordReset(auth: Auth, oobCode: string, newPassword: string): Promise<void>;
  787. /**
  788. * Changes the {@link Auth} instance to communicate with the Firebase Auth Emulator, instead of production
  789. * Firebase Auth services.
  790. *
  791. * @remarks
  792. * This must be called synchronously immediately following the first call to
  793. * {@link initializeAuth}. Do not use with production credentials as emulator
  794. * traffic is not encrypted.
  795. *
  796. *
  797. * @example
  798. * ```javascript
  799. * connectAuthEmulator(auth, 'http://127.0.0.1:9099', { disableWarnings: true });
  800. * ```
  801. *
  802. * @param auth - The {@link Auth} instance.
  803. * @param url - The URL at which the emulator is running (eg, 'http://localhost:9099').
  804. * @param options - Optional. `options.disableWarnings` defaults to `false`. Set it to
  805. * `true` to disable the warning banner attached to the DOM.
  806. *
  807. * @public
  808. */
  809. export declare function connectAuthEmulator(auth: Auth, url: string, options?: {
  810. disableWarnings: boolean;
  811. }): void;
  812. /**
  813. * Creates a new user account associated with the specified email address and password.
  814. *
  815. * @remarks
  816. * On successful creation of the user account, this user will also be signed in to your application.
  817. *
  818. * User account creation can fail if the account already exists or the password is invalid.
  819. *
  820. * Note: The email address acts as a unique identifier for the user and enables an email-based
  821. * password reset. This function will create a new user account and set the initial user password.
  822. *
  823. * @param auth - The {@link Auth} instance.
  824. * @param email - The user's email address.
  825. * @param password - The user's chosen password.
  826. *
  827. * @public
  828. */
  829. export declare function createUserWithEmailAndPassword(auth: Auth, email: string, password: string): Promise<UserCredential>;
  830. /**
  831. * Map of OAuth Custom Parameters.
  832. *
  833. * @public
  834. */
  835. export declare type CustomParameters = Record<string, string>;
  836. /**
  837. * A verbose error map with detailed descriptions for most error codes.
  838. *
  839. * See discussion at {@link AuthErrorMap}
  840. *
  841. * @public
  842. */
  843. export declare const debugErrorMap: AuthErrorMap;
  844. /**
  845. * Deletes and signs out the user.
  846. *
  847. * @remarks
  848. * Important: this is a security-sensitive operation that requires the user to have recently
  849. * signed in. If this requirement isn't met, ask the user to authenticate again and then call
  850. * {@link reauthenticateWithCredential}.
  851. *
  852. * @param user - The user.
  853. *
  854. * @public
  855. */
  856. export declare function deleteUser(user: User): Promise<void>;
  857. /**
  858. * The dependencies that can be used to initialize an {@link Auth} instance.
  859. *
  860. * @remarks
  861. *
  862. * The modular SDK enables tree shaking by allowing explicit declarations of
  863. * dependencies. For example, a web app does not need to include code that
  864. * enables Cordova redirect sign in. That functionality is therefore split into
  865. * {@link browserPopupRedirectResolver} and
  866. * {@link cordovaPopupRedirectResolver}. The dependencies object is how Auth is
  867. * configured to reduce bundle sizes.
  868. *
  869. * There are two ways to initialize an {@link Auth} instance: {@link getAuth} and
  870. * {@link initializeAuth}. `getAuth` initializes everything using
  871. * platform-specific configurations, while `initializeAuth` takes a
  872. * `Dependencies` object directly, giving you more control over what is used.
  873. *
  874. * @public
  875. */
  876. export declare interface Dependencies {
  877. /**
  878. * Which {@link Persistence} to use. If this is an array, the first
  879. * `Persistence` that the device supports is used. The SDK searches for an
  880. * existing account in order and, if one is found in a secondary
  881. * `Persistence`, the account is moved to the primary `Persistence`.
  882. *
  883. * If no persistence is provided, the SDK falls back on
  884. * {@link inMemoryPersistence}.
  885. */
  886. persistence?: Persistence | Persistence[];
  887. /**
  888. * The {@link PopupRedirectResolver} to use. This value depends on the
  889. * platform. Options are {@link browserPopupRedirectResolver} and
  890. * {@link cordovaPopupRedirectResolver}. This field is optional if neither
  891. * {@link signInWithPopup} or {@link signInWithRedirect} are being used.
  892. */
  893. popupRedirectResolver?: PopupRedirectResolver;
  894. /**
  895. * Which {@link AuthErrorMap} to use.
  896. */
  897. errorMap?: AuthErrorMap;
  898. }
  899. /**
  900. * Interface that represents the credentials returned by {@link EmailAuthProvider} for
  901. * {@link ProviderId}.PASSWORD
  902. *
  903. * @remarks
  904. * Covers both {@link SignInMethod}.EMAIL_PASSWORD and
  905. * {@link SignInMethod}.EMAIL_LINK.
  906. *
  907. * @public
  908. */
  909. export declare class EmailAuthCredential extends AuthCredential {
  910. /* Excluded from this release type: _email */
  911. /* Excluded from this release type: _password */
  912. /* Excluded from this release type: _tenantId */
  913. /* Excluded from this release type: __constructor */
  914. /* Excluded from this release type: _fromEmailAndPassword */
  915. /* Excluded from this release type: _fromEmailAndCode */
  916. /** {@inheritdoc AuthCredential.toJSON} */
  917. toJSON(): object;
  918. /**
  919. * Static method to deserialize a JSON representation of an object into an {@link AuthCredential}.
  920. *
  921. * @param json - Either `object` or the stringified representation of the object. When string is
  922. * provided, `JSON.parse` would be called first.
  923. *
  924. * @returns If the JSON input does not represent an {@link AuthCredential}, null is returned.
  925. */
  926. static fromJSON(json: object | string): EmailAuthCredential | null;
  927. /* Excluded from this release type: _getIdTokenResponse */
  928. /* Excluded from this release type: _linkToIdToken */
  929. /* Excluded from this release type: _getReauthenticationResolver */
  930. }
  931. /**
  932. * Provider for generating {@link EmailAuthCredential}.
  933. *
  934. * @public
  935. */
  936. export declare class EmailAuthProvider implements AuthProvider {
  937. /**
  938. * Always set to {@link ProviderId}.PASSWORD, even for email link.
  939. */
  940. static readonly PROVIDER_ID: 'password';
  941. /**
  942. * Always set to {@link SignInMethod}.EMAIL_PASSWORD.
  943. */
  944. static readonly EMAIL_PASSWORD_SIGN_IN_METHOD: 'password';
  945. /**
  946. * Always set to {@link SignInMethod}.EMAIL_LINK.
  947. */
  948. static readonly EMAIL_LINK_SIGN_IN_METHOD: 'emailLink';
  949. /**
  950. * Always set to {@link ProviderId}.PASSWORD, even for email link.
  951. */
  952. readonly providerId: "password";
  953. /**
  954. * Initialize an {@link AuthCredential} using an email and password.
  955. *
  956. * @example
  957. * ```javascript
  958. * const authCredential = EmailAuthProvider.credential(email, password);
  959. * const userCredential = await signInWithCredential(auth, authCredential);
  960. * ```
  961. *
  962. * @example
  963. * ```javascript
  964. * const userCredential = await signInWithEmailAndPassword(auth, email, password);
  965. * ```
  966. *
  967. * @param email - Email address.
  968. * @param password - User account password.
  969. * @returns The auth provider credential.
  970. */
  971. static credential(email: string, password: string): EmailAuthCredential;
  972. /**
  973. * Initialize an {@link AuthCredential} using an email and an email link after a sign in with
  974. * email link operation.
  975. *
  976. * @example
  977. * ```javascript
  978. * const authCredential = EmailAuthProvider.credentialWithLink(auth, email, emailLink);
  979. * const userCredential = await signInWithCredential(auth, authCredential);
  980. * ```
  981. *
  982. * @example
  983. * ```javascript
  984. * await sendSignInLinkToEmail(auth, email);
  985. * // Obtain emailLink from user.
  986. * const userCredential = await signInWithEmailLink(auth, email, emailLink);
  987. * ```
  988. *
  989. * @param auth - The {@link Auth} instance used to verify the link.
  990. * @param email - Email address.
  991. * @param emailLink - Sign-in email link.
  992. * @returns - The auth provider credential.
  993. */
  994. static credentialWithLink(email: string, emailLink: string): EmailAuthCredential;
  995. }
  996. /**
  997. * Configuration of Firebase Authentication Emulator.
  998. * @public
  999. */
  1000. export declare interface EmulatorConfig {
  1001. /**
  1002. * The protocol used to communicate with the emulator ("http"/"https").
  1003. */
  1004. readonly protocol: string;
  1005. /**
  1006. * The hostname of the emulator, which may be a domain ("localhost"), IPv4 address ("127.0.0.1")
  1007. * or quoted IPv6 address ("[::1]").
  1008. */
  1009. readonly host: string;
  1010. /**
  1011. * The port of the emulator, or null if port isn't specified (i.e. protocol default).
  1012. */
  1013. readonly port: number | null;
  1014. /**
  1015. * The emulator-specific options.
  1016. */
  1017. readonly options: {
  1018. /**
  1019. * Whether the warning banner attached to the DOM was disabled.
  1020. */
  1021. readonly disableWarnings: boolean;
  1022. };
  1023. }
  1024. export { ErrorFn }
  1025. /* Excluded from this release type: EventManager */
  1026. /**
  1027. * Provider for generating an {@link OAuthCredential} for {@link ProviderId}.FACEBOOK.
  1028. *
  1029. * @example
  1030. * ```javascript
  1031. * // Sign in using a redirect.
  1032. * const provider = new FacebookAuthProvider();
  1033. * // Start a sign in process for an unauthenticated user.
  1034. * provider.addScope('user_birthday');
  1035. * await signInWithRedirect(auth, provider);
  1036. * // This will trigger a full page redirect away from your app
  1037. *
  1038. * // After returning from the redirect when your app initializes you can obtain the result
  1039. * const result = await getRedirectResult(auth);
  1040. * if (result) {
  1041. * // This is the signed-in user
  1042. * const user = result.user;
  1043. * // This gives you a Facebook Access Token.
  1044. * const credential = FacebookAuthProvider.credentialFromResult(result);
  1045. * const token = credential.accessToken;
  1046. * }
  1047. * ```
  1048. *
  1049. * @example
  1050. * ```javascript
  1051. * // Sign in using a popup.
  1052. * const provider = new FacebookAuthProvider();
  1053. * provider.addScope('user_birthday');
  1054. * const result = await signInWithPopup(auth, provider);
  1055. *
  1056. * // The signed-in user info.
  1057. * const user = result.user;
  1058. * // This gives you a Facebook Access Token.
  1059. * const credential = FacebookAuthProvider.credentialFromResult(result);
  1060. * const token = credential.accessToken;
  1061. * ```
  1062. *
  1063. * @public
  1064. */
  1065. export declare class FacebookAuthProvider extends BaseOAuthProvider {
  1066. /** Always set to {@link SignInMethod}.FACEBOOK. */
  1067. static readonly FACEBOOK_SIGN_IN_METHOD: 'facebook.com';
  1068. /** Always set to {@link ProviderId}.FACEBOOK. */
  1069. static readonly PROVIDER_ID: 'facebook.com';
  1070. constructor();
  1071. /**
  1072. * Creates a credential for Facebook.
  1073. *
  1074. * @example
  1075. * ```javascript
  1076. * // `event` from the Facebook auth.authResponseChange callback.
  1077. * const credential = FacebookAuthProvider.credential(event.authResponse.accessToken);
  1078. * const result = await signInWithCredential(credential);
  1079. * ```
  1080. *
  1081. * @param accessToken - Facebook access token.
  1082. */
  1083. static credential(accessToken: string): OAuthCredential;
  1084. /**
  1085. * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
  1086. *
  1087. * @param userCredential - The user credential.
  1088. */
  1089. static credentialFromResult(userCredential: UserCredential): OAuthCredential | null;
  1090. /**
  1091. * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
  1092. * thrown during a sign-in, link, or reauthenticate operation.
  1093. *
  1094. * @param userCredential - The user credential.
  1095. */
  1096. static credentialFromError(error: FirebaseError): OAuthCredential | null;
  1097. private static credentialFromTaggedObject;
  1098. }
  1099. /**
  1100. * An enum of factors that may be used for multifactor authentication.
  1101. *
  1102. * @public
  1103. */
  1104. export declare const FactorId: {
  1105. /** Phone as second factor */
  1106. readonly PHONE: "phone";
  1107. };
  1108. /**
  1109. * The base class for all Federated providers (OAuth (including OIDC), SAML).
  1110. *
  1111. * This class is not meant to be instantiated directly.
  1112. *
  1113. * @public
  1114. */
  1115. declare abstract class FederatedAuthProvider implements AuthProvider {
  1116. readonly providerId: string;
  1117. /* Excluded from this release type: defaultLanguageCode */
  1118. /* Excluded from this release type: customParameters */
  1119. /**
  1120. * Constructor for generic OAuth providers.
  1121. *
  1122. * @param providerId - Provider for which credentials should be generated.
  1123. */
  1124. constructor(providerId: string);
  1125. /**
  1126. * Set the language gode.
  1127. *
  1128. * @param languageCode - language code
  1129. */
  1130. setDefaultLanguage(languageCode: string | null): void;
  1131. /**
  1132. * Sets the OAuth custom parameters to pass in an OAuth request for popup and redirect sign-in
  1133. * operations.
  1134. *
  1135. * @remarks
  1136. * For a detailed list, check the reserved required OAuth 2.0 parameters such as `client_id`,
  1137. * `redirect_uri`, `scope`, `response_type`, and `state` are not allowed and will be ignored.
  1138. *
  1139. * @param customOAuthParameters - The custom OAuth parameters to pass in the OAuth request.
  1140. */
  1141. setCustomParameters(customOAuthParameters: CustomParameters): AuthProvider;
  1142. /**
  1143. * Retrieve the current list of {@link CustomParameters}.
  1144. */
  1145. getCustomParameters(): CustomParameters;
  1146. }
  1147. /**
  1148. * Gets the list of possible sign in methods for the given email address.
  1149. *
  1150. * @remarks
  1151. * This is useful to differentiate methods of sign-in for the same provider, eg.
  1152. * {@link EmailAuthProvider} which has 2 methods of sign-in,
  1153. * {@link SignInMethod}.EMAIL_PASSWORD and
  1154. * {@link SignInMethod}.EMAIL_LINK.
  1155. *
  1156. * @param auth - The {@link Auth} instance.
  1157. * @param email - The user's email address.
  1158. *
  1159. * @public
  1160. */
  1161. export declare function fetchSignInMethodsForEmail(auth: Auth, email: string): Promise<string[]>;
  1162. declare interface FinalizeMfaResponse {
  1163. idToken: string;
  1164. refreshToken: string;
  1165. }
  1166. /* Excluded from this release type: GenericAuthErrorParams */
  1167. /**
  1168. * Extracts provider specific {@link AdditionalUserInfo} for the given credential.
  1169. *
  1170. * @param userCredential - The user credential.
  1171. *
  1172. * @public
  1173. */
  1174. export declare function getAdditionalUserInfo(userCredential: UserCredential): AdditionalUserInfo | null;
  1175. /**
  1176. * Returns the Auth instance associated with the provided {@link @firebase/app#FirebaseApp}.
  1177. * If no instance exists, initializes an Auth instance with platform-specific default dependencies.
  1178. *
  1179. * @param app - The Firebase App.
  1180. *
  1181. * @public
  1182. */
  1183. export declare function getAuth(app?: FirebaseApp): Auth;
  1184. /**
  1185. * Returns a JSON Web Token (JWT) used to identify the user to a Firebase service.
  1186. *
  1187. * @remarks
  1188. * Returns the current token if it has not expired or if it will not expire in the next five
  1189. * minutes. Otherwise, this will refresh the token and return a new one.
  1190. *
  1191. * @param user - The user.
  1192. * @param forceRefresh - Force refresh regardless of token expiration.
  1193. *
  1194. * @public
  1195. */
  1196. export declare function getIdToken(user: User, forceRefresh?: boolean): Promise<string>;
  1197. /**
  1198. * Returns a deserialized JSON Web Token (JWT) used to identitfy the user to a Firebase service.
  1199. *
  1200. * @remarks
  1201. * Returns the current token if it has not expired or if it will not expire in the next five
  1202. * minutes. Otherwise, this will refresh the token and return a new one.
  1203. *
  1204. * @param user - The user.
  1205. * @param forceRefresh - Force refresh regardless of token expiration.
  1206. *
  1207. * @public
  1208. */
  1209. export declare function getIdTokenResult(user: User, forceRefresh?: boolean): Promise<IdTokenResult>;
  1210. /**
  1211. * Provides a {@link MultiFactorResolver} suitable for completion of a
  1212. * multi-factor flow.
  1213. *
  1214. * @param auth - The {@link Auth} instance.
  1215. * @param error - The {@link MultiFactorError} raised during a sign-in, or
  1216. * reauthentication operation.
  1217. *
  1218. * @public
  1219. */
  1220. export declare function getMultiFactorResolver(auth: Auth, error: MultiFactorError): MultiFactorResolver;
  1221. /**
  1222. * Returns a {@link UserCredential} from the redirect-based sign-in flow.
  1223. *
  1224. * @remarks
  1225. * If sign-in succeeded, returns the signed in user. If sign-in was unsuccessful, fails with an
  1226. * error. If no redirect operation was called, returns `null`.
  1227. *
  1228. * @example
  1229. * ```javascript
  1230. * // Sign in using a redirect.
  1231. * const provider = new FacebookAuthProvider();
  1232. * // You can add additional scopes to the provider:
  1233. * provider.addScope('user_birthday');
  1234. * // Start a sign in process for an unauthenticated user.
  1235. * await signInWithRedirect(auth, provider);
  1236. * // This will trigger a full page redirect away from your app
  1237. *
  1238. * // After returning from the redirect when your app initializes you can obtain the result
  1239. * const result = await getRedirectResult(auth);
  1240. * if (result) {
  1241. * // This is the signed-in user
  1242. * const user = result.user;
  1243. * // This gives you a Facebook Access Token.
  1244. * const credential = provider.credentialFromResult(auth, result);
  1245. * const token = credential.accessToken;
  1246. * }
  1247. * // As this API can be used for sign-in, linking and reauthentication,
  1248. * // check the operationType to determine what triggered this redirect
  1249. * // operation.
  1250. * const operationType = result.operationType;
  1251. * ```
  1252. *
  1253. * @param auth - The {@link Auth} instance.
  1254. * @param resolver - An instance of {@link PopupRedirectResolver}, optional
  1255. * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
  1256. *
  1257. * @public
  1258. */
  1259. export declare function getRedirectResult(auth: Auth, resolver?: PopupRedirectResolver): Promise<UserCredential | null>;
  1260. /**
  1261. * Provider for generating an {@link OAuthCredential} for {@link ProviderId}.GITHUB.
  1262. *
  1263. * @remarks
  1264. * GitHub requires an OAuth 2.0 redirect, so you can either handle the redirect directly, or use
  1265. * the {@link signInWithPopup} handler:
  1266. *
  1267. * @example
  1268. * ```javascript
  1269. * // Sign in using a redirect.
  1270. * const provider = new GithubAuthProvider();
  1271. * // Start a sign in process for an unauthenticated user.
  1272. * provider.addScope('repo');
  1273. * await signInWithRedirect(auth, provider);
  1274. * // This will trigger a full page redirect away from your app
  1275. *
  1276. * // After returning from the redirect when your app initializes you can obtain the result
  1277. * const result = await getRedirectResult(auth);
  1278. * if (result) {
  1279. * // This is the signed-in user
  1280. * const user = result.user;
  1281. * // This gives you a Github Access Token.
  1282. * const credential = GithubAuthProvider.credentialFromResult(result);
  1283. * const token = credential.accessToken;
  1284. * }
  1285. * ```
  1286. *
  1287. * @example
  1288. * ```javascript
  1289. * // Sign in using a popup.
  1290. * const provider = new GithubAuthProvider();
  1291. * provider.addScope('repo');
  1292. * const result = await signInWithPopup(auth, provider);
  1293. *
  1294. * // The signed-in user info.
  1295. * const user = result.user;
  1296. * // This gives you a Github Access Token.
  1297. * const credential = GithubAuthProvider.credentialFromResult(result);
  1298. * const token = credential.accessToken;
  1299. * ```
  1300. * @public
  1301. */
  1302. export declare class GithubAuthProvider extends BaseOAuthProvider {
  1303. /** Always set to {@link SignInMethod}.GITHUB. */
  1304. static readonly GITHUB_SIGN_IN_METHOD: 'github.com';
  1305. /** Always set to {@link ProviderId}.GITHUB. */
  1306. static readonly PROVIDER_ID: 'github.com';
  1307. constructor();
  1308. /**
  1309. * Creates a credential for Github.
  1310. *
  1311. * @param accessToken - Github access token.
  1312. */
  1313. static credential(accessToken: string): OAuthCredential;
  1314. /**
  1315. * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
  1316. *
  1317. * @param userCredential - The user credential.
  1318. */
  1319. static credentialFromResult(userCredential: UserCredential): OAuthCredential | null;
  1320. /**
  1321. * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
  1322. * thrown during a sign-in, link, or reauthenticate operation.
  1323. *
  1324. * @param userCredential - The user credential.
  1325. */
  1326. static credentialFromError(error: FirebaseError): OAuthCredential | null;
  1327. private static credentialFromTaggedObject;
  1328. }
  1329. /**
  1330. * Provider for generating an an {@link OAuthCredential} for {@link ProviderId}.GOOGLE.
  1331. *
  1332. * @example
  1333. * ```javascript
  1334. * // Sign in using a redirect.
  1335. * const provider = new GoogleAuthProvider();
  1336. * // Start a sign in process for an unauthenticated user.
  1337. * provider.addScope('profile');
  1338. * provider.addScope('email');
  1339. * await signInWithRedirect(auth, provider);
  1340. * // This will trigger a full page redirect away from your app
  1341. *
  1342. * // After returning from the redirect when your app initializes you can obtain the result
  1343. * const result = await getRedirectResult(auth);
  1344. * if (result) {
  1345. * // This is the signed-in user
  1346. * const user = result.user;
  1347. * // This gives you a Google Access Token.
  1348. * const credential = GoogleAuthProvider.credentialFromResult(result);
  1349. * const token = credential.accessToken;
  1350. * }
  1351. * ```
  1352. *
  1353. * @example
  1354. * ```javascript
  1355. * // Sign in using a popup.
  1356. * const provider = new GoogleAuthProvider();
  1357. * provider.addScope('profile');
  1358. * provider.addScope('email');
  1359. * const result = await signInWithPopup(auth, provider);
  1360. *
  1361. * // The signed-in user info.
  1362. * const user = result.user;
  1363. * // This gives you a Google Access Token.
  1364. * const credential = GoogleAuthProvider.credentialFromResult(result);
  1365. * const token = credential.accessToken;
  1366. * ```
  1367. *
  1368. * @public
  1369. */
  1370. export declare class GoogleAuthProvider extends BaseOAuthProvider {
  1371. /** Always set to {@link SignInMethod}.GOOGLE. */
  1372. static readonly GOOGLE_SIGN_IN_METHOD: 'google.com';
  1373. /** Always set to {@link ProviderId}.GOOGLE. */
  1374. static readonly PROVIDER_ID: 'google.com';
  1375. constructor();
  1376. /**
  1377. * Creates a credential for Google. At least one of ID token and access token is required.
  1378. *
  1379. * @example
  1380. * ```javascript
  1381. * // \`googleUser\` from the onsuccess Google Sign In callback.
  1382. * const credential = GoogleAuthProvider.credential(googleUser.getAuthResponse().id_token);
  1383. * const result = await signInWithCredential(credential);
  1384. * ```
  1385. *
  1386. * @param idToken - Google ID token.
  1387. * @param accessToken - Google access token.
  1388. */
  1389. static credential(idToken?: string | null, accessToken?: string | null): OAuthCredential;
  1390. /**
  1391. * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
  1392. *
  1393. * @param userCredential - The user credential.
  1394. */
  1395. static credentialFromResult(userCredential: UserCredential): OAuthCredential | null;
  1396. /**
  1397. * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
  1398. * thrown during a sign-in, link, or reauthenticate operation.
  1399. *
  1400. * @param userCredential - The user credential.
  1401. */
  1402. static credentialFromError(error: FirebaseError): OAuthCredential | null;
  1403. private static credentialFromTaggedObject;
  1404. }
  1405. /**
  1406. * Raw encoded JWT
  1407. *
  1408. */
  1409. declare type IdToken = string;
  1410. /* Excluded from this release type: IdTokenMfaResponse */
  1411. /* Excluded from this release type: IdTokenResponse */
  1412. /* Excluded from this release type: IdTokenResponseKind */
  1413. /**
  1414. * Interface representing ID token result obtained from {@link User.getIdTokenResult}.
  1415. *
  1416. * @remarks
  1417. * `IdTokenResult` contains the ID token JWT string and other helper properties for getting different data
  1418. * associated with the token as well as all the decoded payload claims.
  1419. *
  1420. * Note that these claims are not to be trusted as they are parsed client side. Only server side
  1421. * verification can guarantee the integrity of the token claims.
  1422. *
  1423. * @public
  1424. */
  1425. export declare interface IdTokenResult {
  1426. /**
  1427. * The authentication time formatted as a UTC string.
  1428. *
  1429. * @remarks
  1430. * This is the time the user authenticated (signed in) and not the time the token was refreshed.
  1431. */
  1432. authTime: string;
  1433. /** The ID token expiration time formatted as a UTC string. */
  1434. expirationTime: string;
  1435. /** The ID token issuance time formatted as a UTC string. */
  1436. issuedAtTime: string;
  1437. /**
  1438. * The sign-in provider through which the ID token was obtained (anonymous, custom, phone,
  1439. * password, etc).
  1440. *
  1441. * @remarks
  1442. * Note, this does not map to provider IDs.
  1443. */
  1444. signInProvider: string | null;
  1445. /**
  1446. * The type of second factor associated with this session, provided the user was multi-factor
  1447. * authenticated (eg. phone, etc).
  1448. */
  1449. signInSecondFactor: string | null;
  1450. /** The Firebase Auth ID token JWT string. */
  1451. token: string;
  1452. /**
  1453. * The entire payload claims of the ID token including the standard reserved claims as well as
  1454. * the custom claims.
  1455. */
  1456. claims: ParsedToken;
  1457. }
  1458. /**
  1459. * An implementation of {@link Persistence} of type `LOCAL` using `indexedDB`
  1460. * for the underlying storage.
  1461. *
  1462. * @public
  1463. */
  1464. export declare const indexedDBLocalPersistence: Persistence;
  1465. /**
  1466. * Initializes an {@link Auth} instance with fine-grained control over
  1467. * {@link Dependencies}.
  1468. *
  1469. * @remarks
  1470. *
  1471. * This function allows more control over the {@link Auth} instance than
  1472. * {@link getAuth}. `getAuth` uses platform-specific defaults to supply
  1473. * the {@link Dependencies}. In general, `getAuth` is the easiest way to
  1474. * initialize Auth and works for most use cases. Use `initializeAuth` if you
  1475. * need control over which persistence layer is used, or to minimize bundle
  1476. * size if you're not using either `signInWithPopup` or `signInWithRedirect`.
  1477. *
  1478. * For example, if your app only uses anonymous accounts and you only want
  1479. * accounts saved for the current session, initialize `Auth` with:
  1480. *
  1481. * ```js
  1482. * const auth = initializeAuth(app, {
  1483. * persistence: browserSessionPersistence,
  1484. * popupRedirectResolver: undefined,
  1485. * });
  1486. * ```
  1487. *
  1488. * @public
  1489. */
  1490. export declare function initializeAuth(app: FirebaseApp, deps?: Dependencies): Auth;
  1491. /**
  1492. * An implementation of {@link Persistence} of type 'NONE'.
  1493. *
  1494. * @public
  1495. */
  1496. export declare const inMemoryPersistence: Persistence;
  1497. /**
  1498. * Checks if an incoming link is a sign-in with email link suitable for {@link signInWithEmailLink}.
  1499. *
  1500. * @param auth - The {@link Auth} instance.
  1501. * @param emailLink - The link sent to the user's email address.
  1502. *
  1503. * @public
  1504. */
  1505. export declare function isSignInWithEmailLink(auth: Auth, emailLink: string): boolean;
  1506. /**
  1507. * Links the user account with the given credentials.
  1508. *
  1509. * @remarks
  1510. * An {@link AuthProvider} can be used to generate the credential.
  1511. *
  1512. * @param user - The user.
  1513. * @param credential - The auth credential.
  1514. *
  1515. * @public
  1516. */
  1517. export declare function linkWithCredential(user: User, credential: AuthCredential): Promise<UserCredential>;
  1518. /**
  1519. * Links the user account with the given phone number.
  1520. *
  1521. * @param user - The user.
  1522. * @param phoneNumber - The user's phone number in E.164 format (e.g. +16505550101).
  1523. * @param appVerifier - The {@link ApplicationVerifier}.
  1524. *
  1525. * @public
  1526. */
  1527. export declare function linkWithPhoneNumber(user: User, phoneNumber: string, appVerifier: ApplicationVerifier): Promise<ConfirmationResult>;
  1528. /**
  1529. * Links the authenticated provider to the user account using a pop-up based OAuth flow.
  1530. *
  1531. * @remarks
  1532. * If the linking is successful, the returned result will contain the user and the provider's credential.
  1533. *
  1534. *
  1535. * @example
  1536. * ```javascript
  1537. * // Sign in using some other provider.
  1538. * const result = await signInWithEmailAndPassword(auth, email, password);
  1539. * // Link using a popup.
  1540. * const provider = new FacebookAuthProvider();
  1541. * await linkWithPopup(result.user, provider);
  1542. * ```
  1543. *
  1544. * @param user - The user.
  1545. * @param provider - The provider to authenticate. The provider has to be an {@link OAuthProvider}.
  1546. * Non-OAuth providers like {@link EmailAuthProvider} will throw an error.
  1547. * @param resolver - An instance of {@link PopupRedirectResolver}, optional
  1548. * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
  1549. *
  1550. * @public
  1551. */
  1552. export declare function linkWithPopup(user: User, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<UserCredential>;
  1553. /**
  1554. * Links the {@link OAuthProvider} to the user account using a full-page redirect flow.
  1555. * @remarks
  1556. * To handle the results and errors for this operation, refer to {@link getRedirectResult}.
  1557. * Follow the [best practices](https://firebase.google.com/docs/auth/web/redirect-best-practices) when using {@link linkWithRedirect}.
  1558. *
  1559. * @example
  1560. * ```javascript
  1561. * // Sign in using some other provider.
  1562. * const result = await signInWithEmailAndPassword(auth, email, password);
  1563. * // Link using a redirect.
  1564. * const provider = new FacebookAuthProvider();
  1565. * await linkWithRedirect(result.user, provider);
  1566. * // This will trigger a full page redirect away from your app
  1567. *
  1568. * // After returning from the redirect when your app initializes you can obtain the result
  1569. * const result = await getRedirectResult(auth);
  1570. * ```
  1571. *
  1572. * @param user - The user.
  1573. * @param provider - The provider to authenticate. The provider has to be an {@link OAuthProvider}.
  1574. * Non-OAuth providers like {@link EmailAuthProvider} will throw an error.
  1575. * @param resolver - An instance of {@link PopupRedirectResolver}, optional
  1576. * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
  1577. *
  1578. *
  1579. * @public
  1580. */
  1581. export declare function linkWithRedirect(user: User, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<never>;
  1582. /**
  1583. * MfaEnrollment can be any subtype of BaseMfaEnrollment, currently only PhoneMfaEnrollment is supported
  1584. */
  1585. declare type MfaEnrollment = PhoneMfaEnrollment;
  1586. /**
  1587. * The {@link MultiFactorUser} corresponding to the user.
  1588. *
  1589. * @remarks
  1590. * This is used to access all multi-factor properties and operations related to the user.
  1591. *
  1592. * @param user - The user.
  1593. *
  1594. * @public
  1595. */
  1596. export declare function multiFactor(user: User): MultiFactorUser;
  1597. /**
  1598. * The base class for asserting ownership of a second factor.
  1599. *
  1600. * @remarks
  1601. * This is used to facilitate enrollment of a second factor on an existing user or sign-in of a
  1602. * user who already verified the first factor.
  1603. *
  1604. * @public
  1605. */
  1606. export declare interface MultiFactorAssertion {
  1607. /** The identifier of the second factor. */
  1608. readonly factorId: typeof FactorId[keyof typeof FactorId];
  1609. }
  1610. /**
  1611. * The error thrown when the user needs to provide a second factor to sign in successfully.
  1612. *
  1613. * @remarks
  1614. * The error code for this error is `auth/multi-factor-auth-required`.
  1615. *
  1616. * @example
  1617. * ```javascript
  1618. * let resolver;
  1619. * let multiFactorHints;
  1620. *
  1621. * signInWithEmailAndPassword(auth, email, password)
  1622. * .then((result) => {
  1623. * // User signed in. No 2nd factor challenge is needed.
  1624. * })
  1625. * .catch((error) => {
  1626. * if (error.code == 'auth/multi-factor-auth-required') {
  1627. * resolver = getMultiFactorResolver(auth, error);
  1628. * multiFactorHints = resolver.hints;
  1629. * } else {
  1630. * // Handle other errors.
  1631. * }
  1632. * });
  1633. *
  1634. * // Obtain a multiFactorAssertion by verifying the second factor.
  1635. *
  1636. * const userCredential = await resolver.resolveSignIn(multiFactorAssertion);
  1637. * ```
  1638. *
  1639. * @public
  1640. */
  1641. export declare interface MultiFactorError extends AuthError {
  1642. /** Details about the MultiFactorError. */
  1643. readonly customData: AuthError['customData'] & {
  1644. /**
  1645. * The type of operation (sign-in, linking, or re-authentication) that raised the error.
  1646. */
  1647. readonly operationType: typeof OperationType[keyof typeof OperationType];
  1648. };
  1649. }
  1650. /**
  1651. * A structure containing the information of a second factor entity.
  1652. *
  1653. * @public
  1654. */
  1655. export declare interface MultiFactorInfo {
  1656. /** The multi-factor enrollment ID. */
  1657. readonly uid: string;
  1658. /** The user friendly name of the current second factor. */
  1659. readonly displayName?: string | null;
  1660. /** The enrollment date of the second factor formatted as a UTC string. */
  1661. readonly enrollmentTime: string;
  1662. /** The identifier of the second factor. */
  1663. readonly factorId: typeof FactorId[keyof typeof FactorId];
  1664. }
  1665. /**
  1666. * The class used to facilitate recovery from {@link MultiFactorError} when a user needs to
  1667. * provide a second factor to sign in.
  1668. *
  1669. * @example
  1670. * ```javascript
  1671. * let resolver;
  1672. * let multiFactorHints;
  1673. *
  1674. * signInWithEmailAndPassword(auth, email, password)
  1675. * .then((result) => {
  1676. * // User signed in. No 2nd factor challenge is needed.
  1677. * })
  1678. * .catch((error) => {
  1679. * if (error.code == 'auth/multi-factor-auth-required') {
  1680. * resolver = getMultiFactorResolver(auth, error);
  1681. * // Show UI to let user select second factor.
  1682. * multiFactorHints = resolver.hints;
  1683. * } else {
  1684. * // Handle other errors.
  1685. * }
  1686. * });
  1687. *
  1688. * // The enrolled second factors that can be used to complete
  1689. * // sign-in are returned in the `MultiFactorResolver.hints` list.
  1690. * // UI needs to be presented to allow the user to select a second factor
  1691. * // from that list.
  1692. *
  1693. * const selectedHint = // ; selected from multiFactorHints
  1694. * const phoneAuthProvider = new PhoneAuthProvider(auth);
  1695. * const phoneInfoOptions = {
  1696. * multiFactorHint: selectedHint,
  1697. * session: resolver.session
  1698. * };
  1699. * const verificationId = phoneAuthProvider.verifyPhoneNumber(phoneInfoOptions, appVerifier);
  1700. * // Store `verificationId` and show UI to let user enter verification code.
  1701. *
  1702. * // UI to enter verification code and continue.
  1703. * // Continue button click handler
  1704. * const phoneAuthCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
  1705. * const multiFactorAssertion = PhoneMultiFactorGenerator.assertion(phoneAuthCredential);
  1706. * const userCredential = await resolver.resolveSignIn(multiFactorAssertion);
  1707. * ```
  1708. *
  1709. * @public
  1710. */
  1711. export declare interface MultiFactorResolver {
  1712. /**
  1713. * The list of hints for the second factors needed to complete the sign-in for the current
  1714. * session.
  1715. */
  1716. readonly hints: MultiFactorInfo[];
  1717. /**
  1718. * The session identifier for the current sign-in flow, which can be used to complete the second
  1719. * factor sign-in.
  1720. */
  1721. readonly session: MultiFactorSession;
  1722. /**
  1723. * A helper function to help users complete sign in with a second factor using an
  1724. * {@link MultiFactorAssertion} confirming the user successfully completed the second factor
  1725. * challenge.
  1726. *
  1727. * @example
  1728. * ```javascript
  1729. * const phoneAuthCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
  1730. * const multiFactorAssertion = PhoneMultiFactorGenerator.assertion(phoneAuthCredential);
  1731. * const userCredential = await resolver.resolveSignIn(multiFactorAssertion);
  1732. * ```
  1733. *
  1734. * @param assertion - The multi-factor assertion to resolve sign-in with.
  1735. * @returns The promise that resolves with the user credential object.
  1736. */
  1737. resolveSignIn(assertion: MultiFactorAssertion): Promise<UserCredential>;
  1738. }
  1739. /**
  1740. * An interface defining the multi-factor session object used for enrolling a second factor on a
  1741. * user or helping sign in an enrolled user with a second factor.
  1742. *
  1743. * @public
  1744. */
  1745. export declare interface MultiFactorSession {
  1746. }
  1747. /**
  1748. * An interface that defines the multi-factor related properties and operations pertaining
  1749. * to a {@link User}.
  1750. *
  1751. * @public
  1752. */
  1753. export declare interface MultiFactorUser {
  1754. /** Returns a list of the user's enrolled second factors. */
  1755. readonly enrolledFactors: MultiFactorInfo[];
  1756. /**
  1757. * Returns the session identifier for a second factor enrollment operation. This is used to
  1758. * identify the user trying to enroll a second factor.
  1759. *
  1760. * @example
  1761. * ```javascript
  1762. * const multiFactorUser = multiFactor(auth.currentUser);
  1763. * const multiFactorSession = await multiFactorUser.getSession();
  1764. *
  1765. * // Send verification code.
  1766. * const phoneAuthProvider = new PhoneAuthProvider(auth);
  1767. * const phoneInfoOptions = {
  1768. * phoneNumber: phoneNumber,
  1769. * session: multiFactorSession
  1770. * };
  1771. * const verificationId = await phoneAuthProvider.verifyPhoneNumber(phoneInfoOptions, appVerifier);
  1772. *
  1773. * // Obtain verification code from user.
  1774. * const phoneAuthCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
  1775. * const multiFactorAssertion = PhoneMultiFactorGenerator.assertion(phoneAuthCredential);
  1776. * await multiFactorUser.enroll(multiFactorAssertion);
  1777. * ```
  1778. *
  1779. * @returns The promise that resolves with the {@link MultiFactorSession}.
  1780. */
  1781. getSession(): Promise<MultiFactorSession>;
  1782. /**
  1783. *
  1784. * Enrolls a second factor as identified by the {@link MultiFactorAssertion} for the
  1785. * user.
  1786. *
  1787. * @remarks
  1788. * On resolution, the user tokens are updated to reflect the change in the JWT payload.
  1789. * Accepts an additional display name parameter used to identify the second factor to the end
  1790. * user. Recent re-authentication is required for this operation to succeed. On successful
  1791. * enrollment, existing Firebase sessions (refresh tokens) are revoked. When a new factor is
  1792. * enrolled, an email notification is sent to the user’s email.
  1793. *
  1794. * @example
  1795. * ```javascript
  1796. * const multiFactorUser = multiFactor(auth.currentUser);
  1797. * const multiFactorSession = await multiFactorUser.getSession();
  1798. *
  1799. * // Send verification code.
  1800. * const phoneAuthProvider = new PhoneAuthProvider(auth);
  1801. * const phoneInfoOptions = {
  1802. * phoneNumber: phoneNumber,
  1803. * session: multiFactorSession
  1804. * };
  1805. * const verificationId = await phoneAuthProvider.verifyPhoneNumber(phoneInfoOptions, appVerifier);
  1806. *
  1807. * // Obtain verification code from user.
  1808. * const phoneAuthCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
  1809. * const multiFactorAssertion = PhoneMultiFactorGenerator.assertion(phoneAuthCredential);
  1810. * await multiFactorUser.enroll(multiFactorAssertion);
  1811. * // Second factor enrolled.
  1812. * ```
  1813. *
  1814. * @param assertion - The multi-factor assertion to enroll with.
  1815. * @param displayName - The display name of the second factor.
  1816. */
  1817. enroll(assertion: MultiFactorAssertion, displayName?: string | null): Promise<void>;
  1818. /**
  1819. * Unenrolls the specified second factor.
  1820. *
  1821. * @remarks
  1822. * To specify the factor to remove, pass a {@link MultiFactorInfo} object (retrieved from
  1823. * {@link MultiFactorUser.enrolledFactors}) or the
  1824. * factor's UID string. Sessions are not revoked when the account is unenrolled. An email
  1825. * notification is likely to be sent to the user notifying them of the change. Recent
  1826. * re-authentication is required for this operation to succeed. When an existing factor is
  1827. * unenrolled, an email notification is sent to the user’s email.
  1828. *
  1829. * @example
  1830. * ```javascript
  1831. * const multiFactorUser = multiFactor(auth.currentUser);
  1832. * // Present user the option to choose which factor to unenroll.
  1833. * await multiFactorUser.unenroll(multiFactorUser.enrolledFactors[i])
  1834. * ```
  1835. *
  1836. * @param option - The multi-factor option to unenroll.
  1837. * @returns - A `Promise` which resolves when the unenroll operation is complete.
  1838. */
  1839. unenroll(option: MultiFactorInfo | string): Promise<void>;
  1840. }
  1841. declare type MutableUserInfo = {
  1842. -readonly [K in keyof UserInfo]: UserInfo[K];
  1843. };
  1844. export { NextFn }
  1845. /**
  1846. * Type definition for an event callback.
  1847. *
  1848. * @privateRemarks TODO(avolkovi): should we consolidate with Subscribe<T> since we're changing the API anyway?
  1849. *
  1850. * @public
  1851. */
  1852. export declare type NextOrObserver<T> = NextFn<T | null> | Observer<T | null>;
  1853. /**
  1854. * Represents the OAuth credentials returned by an {@link OAuthProvider}.
  1855. *
  1856. * @remarks
  1857. * Implementations specify the details about each auth provider's credential requirements.
  1858. *
  1859. * @public
  1860. */
  1861. export declare class OAuthCredential extends AuthCredential {
  1862. /**
  1863. * The OAuth ID token associated with the credential if it belongs to an OIDC provider,
  1864. * such as `google.com`.
  1865. * @readonly
  1866. */
  1867. idToken?: string;
  1868. /**
  1869. * The OAuth access token associated with the credential if it belongs to an
  1870. * {@link OAuthProvider}, such as `facebook.com`, `twitter.com`, etc.
  1871. * @readonly
  1872. */
  1873. accessToken?: string;
  1874. /**
  1875. * The OAuth access token secret associated with the credential if it belongs to an OAuth 1.0
  1876. * provider, such as `twitter.com`.
  1877. * @readonly
  1878. */
  1879. secret?: string;
  1880. private nonce?;
  1881. private pendingToken;
  1882. /* Excluded from this release type: _fromParams */
  1883. /** {@inheritdoc AuthCredential.toJSON} */
  1884. toJSON(): object;
  1885. /**
  1886. * Static method to deserialize a JSON representation of an object into an
  1887. * {@link AuthCredential}.
  1888. *
  1889. * @param json - Input can be either Object or the stringified representation of the object.
  1890. * When string is provided, JSON.parse would be called first.
  1891. *
  1892. * @returns If the JSON input does not represent an {@link AuthCredential}, null is returned.
  1893. */
  1894. static fromJSON(json: string | object): OAuthCredential | null;
  1895. /* Excluded from this release type: _getIdTokenResponse */
  1896. /* Excluded from this release type: _linkToIdToken */
  1897. /* Excluded from this release type: _getReauthenticationResolver */
  1898. private buildRequest;
  1899. }
  1900. /**
  1901. * Defines the options for initializing an {@link OAuthCredential}.
  1902. *
  1903. * @remarks
  1904. * For ID tokens with nonce claim, the raw nonce has to also be provided.
  1905. *
  1906. * @public
  1907. */
  1908. export declare interface OAuthCredentialOptions {
  1909. /**
  1910. * The OAuth ID token used to initialize the {@link OAuthCredential}.
  1911. */
  1912. idToken?: string;
  1913. /**
  1914. * The OAuth access token used to initialize the {@link OAuthCredential}.
  1915. */
  1916. accessToken?: string;
  1917. /**
  1918. * The raw nonce associated with the ID token.
  1919. *
  1920. * @remarks
  1921. * It is required when an ID token with a nonce field is provided. The SHA-256 hash of the
  1922. * raw nonce must match the nonce field in the ID token.
  1923. */
  1924. rawNonce?: string;
  1925. }
  1926. declare interface OAuthCredentialParams {
  1927. idToken?: string | null;
  1928. accessToken?: string | null;
  1929. oauthToken?: string;
  1930. secret?: string;
  1931. oauthTokenSecret?: string;
  1932. nonce?: string;
  1933. pendingToken?: string;
  1934. providerId: string;
  1935. signInMethod: string;
  1936. }
  1937. /**
  1938. * Provider for generating generic {@link OAuthCredential}.
  1939. *
  1940. * @example
  1941. * ```javascript
  1942. * // Sign in using a redirect.
  1943. * const provider = new OAuthProvider('google.com');
  1944. * // Start a sign in process for an unauthenticated user.
  1945. * provider.addScope('profile');
  1946. * provider.addScope('email');
  1947. * await signInWithRedirect(auth, provider);
  1948. * // This will trigger a full page redirect away from your app
  1949. *
  1950. * // After returning from the redirect when your app initializes you can obtain the result
  1951. * const result = await getRedirectResult(auth);
  1952. * if (result) {
  1953. * // This is the signed-in user
  1954. * const user = result.user;
  1955. * // This gives you a OAuth Access Token for the provider.
  1956. * const credential = provider.credentialFromResult(auth, result);
  1957. * const token = credential.accessToken;
  1958. * }
  1959. * ```
  1960. *
  1961. * @example
  1962. * ```javascript
  1963. * // Sign in using a popup.
  1964. * const provider = new OAuthProvider('google.com');
  1965. * provider.addScope('profile');
  1966. * provider.addScope('email');
  1967. * const result = await signInWithPopup(auth, provider);
  1968. *
  1969. * // The signed-in user info.
  1970. * const user = result.user;
  1971. * // This gives you a OAuth Access Token for the provider.
  1972. * const credential = provider.credentialFromResult(auth, result);
  1973. * const token = credential.accessToken;
  1974. * ```
  1975. * @public
  1976. */
  1977. export declare class OAuthProvider extends BaseOAuthProvider {
  1978. /**
  1979. * Creates an {@link OAuthCredential} from a JSON string or a plain object.
  1980. * @param json - A plain object or a JSON string
  1981. */
  1982. static credentialFromJSON(json: object | string): OAuthCredential;
  1983. /**
  1984. * Creates a {@link OAuthCredential} from a generic OAuth provider's access token or ID token.
  1985. *
  1986. * @remarks
  1987. * The raw nonce is required when an ID token with a nonce field is provided. The SHA-256 hash of
  1988. * the raw nonce must match the nonce field in the ID token.
  1989. *
  1990. * @example
  1991. * ```javascript
  1992. * // `googleUser` from the onsuccess Google Sign In callback.
  1993. * // Initialize a generate OAuth provider with a `google.com` providerId.
  1994. * const provider = new OAuthProvider('google.com');
  1995. * const credential = provider.credential({
  1996. * idToken: googleUser.getAuthResponse().id_token,
  1997. * });
  1998. * const result = await signInWithCredential(credential);
  1999. * ```
  2000. *
  2001. * @param params - Either the options object containing the ID token, access token and raw nonce
  2002. * or the ID token string.
  2003. */
  2004. credential(params: OAuthCredentialOptions): OAuthCredential;
  2005. /** An internal credential method that accepts more permissive options */
  2006. private _credential;
  2007. /**
  2008. * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
  2009. *
  2010. * @param userCredential - The user credential.
  2011. */
  2012. static credentialFromResult(userCredential: UserCredential): OAuthCredential | null;
  2013. /**
  2014. * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
  2015. * thrown during a sign-in, link, or reauthenticate operation.
  2016. *
  2017. * @param userCredential - The user credential.
  2018. */
  2019. static credentialFromError(error: FirebaseError): OAuthCredential | null;
  2020. private static oauthCredentialFromTaggedObject;
  2021. }
  2022. /**
  2023. * Adds an observer for changes to the user's sign-in state.
  2024. *
  2025. * @remarks
  2026. * To keep the old behavior, see {@link onIdTokenChanged}.
  2027. *
  2028. * @param auth - The {@link Auth} instance.
  2029. * @param nextOrObserver - callback triggered on change.
  2030. * @param error - Deprecated. This callback is never triggered. Errors
  2031. * on signing in/out can be caught in promises returned from
  2032. * sign-in/sign-out functions.
  2033. * @param completed - Deprecated. This callback is never triggered.
  2034. *
  2035. * @public
  2036. */
  2037. export declare function onAuthStateChanged(auth: Auth, nextOrObserver: NextOrObserver<User>, error?: ErrorFn, completed?: CompleteFn): Unsubscribe;
  2038. /**
  2039. * Adds an observer for changes to the signed-in user's ID token.
  2040. *
  2041. * @remarks
  2042. * This includes sign-in, sign-out, and token refresh events.
  2043. *
  2044. * @param auth - The {@link Auth} instance.
  2045. * @param nextOrObserver - callback triggered on change.
  2046. * @param error - Deprecated. This callback is never triggered. Errors
  2047. * on signing in/out can be caught in promises returned from
  2048. * sign-in/sign-out functions.
  2049. * @param completed - Deprecated. This callback is never triggered.
  2050. *
  2051. * @public
  2052. */
  2053. export declare function onIdTokenChanged(auth: Auth, nextOrObserver: NextOrObserver<User>, error?: ErrorFn, completed?: CompleteFn): Unsubscribe;
  2054. /**
  2055. * Enumeration of supported operation types.
  2056. *
  2057. * @public
  2058. */
  2059. export declare const OperationType: {
  2060. /** Operation involving linking an additional provider to an already signed-in user. */
  2061. readonly LINK: "link";
  2062. /** Operation involving using a provider to reauthenticate an already signed-in user. */
  2063. readonly REAUTHENTICATE: "reauthenticate";
  2064. /** Operation involving signing in a user. */
  2065. readonly SIGN_IN: "signIn";
  2066. };
  2067. /**
  2068. * Parses the email action link string and returns an {@link ActionCodeURL} if
  2069. * the link is valid, otherwise returns null.
  2070. *
  2071. * @public
  2072. */
  2073. export declare function parseActionCodeURL(link: string): ActionCodeURL | null;
  2074. /**
  2075. * Interface representing a parsed ID token.
  2076. *
  2077. * @privateRemarks TODO(avolkovi): consolidate with parsed_token in implementation.
  2078. *
  2079. * @public
  2080. */
  2081. export declare interface ParsedToken {
  2082. /** Expiration time of the token. */
  2083. 'exp'?: string;
  2084. /** UID of the user. */
  2085. 'sub'?: string;
  2086. /** Time at which authentication was performed. */
  2087. 'auth_time'?: string;
  2088. /** Issuance time of the token. */
  2089. 'iat'?: string;
  2090. /** Firebase specific claims, containing the provider(s) used to authenticate the user. */
  2091. 'firebase'?: {
  2092. 'sign_in_provider'?: string;
  2093. 'sign_in_second_factor'?: string;
  2094. 'identities'?: Record<string, string>;
  2095. };
  2096. /** Map of any additional custom claims. */
  2097. [key: string]: any;
  2098. }
  2099. declare type PersistedBlob = Record<string, unknown>;
  2100. /**
  2101. * An interface covering the possible persistence mechanism types.
  2102. *
  2103. * @public
  2104. */
  2105. export declare interface Persistence {
  2106. /**
  2107. * Type of Persistence.
  2108. * - 'SESSION' is used for temporary persistence such as `sessionStorage`.
  2109. * - 'LOCAL' is used for long term persistence such as `localStorage` or `IndexedDB`.
  2110. * - 'NONE' is used for in-memory, or no persistence.
  2111. */
  2112. readonly type: 'SESSION' | 'LOCAL' | 'NONE';
  2113. }
  2114. /**
  2115. * Represents the credentials returned by {@link PhoneAuthProvider}.
  2116. *
  2117. * @public
  2118. */
  2119. export declare class PhoneAuthCredential extends AuthCredential {
  2120. private readonly params;
  2121. private constructor();
  2122. /* Excluded from this release type: _fromVerification */
  2123. /* Excluded from this release type: _fromTokenResponse */
  2124. /* Excluded from this release type: _getIdTokenResponse */
  2125. /* Excluded from this release type: _linkToIdToken */
  2126. /* Excluded from this release type: _getReauthenticationResolver */
  2127. /* Excluded from this release type: _makeVerificationRequest */
  2128. /** {@inheritdoc AuthCredential.toJSON} */
  2129. toJSON(): object;
  2130. /** Generates a phone credential based on a plain object or a JSON string. */
  2131. static fromJSON(json: object | string): PhoneAuthCredential | null;
  2132. }
  2133. /**
  2134. * Provider for generating an {@link PhoneAuthCredential}.
  2135. *
  2136. * @example
  2137. * ```javascript
  2138. * // 'recaptcha-container' is the ID of an element in the DOM.
  2139. * const applicationVerifier = new RecaptchaVerifier('recaptcha-container');
  2140. * const provider = new PhoneAuthProvider(auth);
  2141. * const verificationId = await provider.verifyPhoneNumber('+16505550101', applicationVerifier);
  2142. * // Obtain the verificationCode from the user.
  2143. * const phoneCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
  2144. * const userCredential = await signInWithCredential(auth, phoneCredential);
  2145. * ```
  2146. *
  2147. * @public
  2148. */
  2149. export declare class PhoneAuthProvider {
  2150. /** Always set to {@link ProviderId}.PHONE. */
  2151. static readonly PROVIDER_ID: 'phone';
  2152. /** Always set to {@link SignInMethod}.PHONE. */
  2153. static readonly PHONE_SIGN_IN_METHOD: 'phone';
  2154. /** Always set to {@link ProviderId}.PHONE. */
  2155. readonly providerId: "phone";
  2156. private readonly auth;
  2157. /**
  2158. * @param auth - The Firebase {@link Auth} instance in which sign-ins should occur.
  2159. *
  2160. */
  2161. constructor(auth: Auth);
  2162. /**
  2163. *
  2164. * Starts a phone number authentication flow by sending a verification code to the given phone
  2165. * number.
  2166. *
  2167. * @example
  2168. * ```javascript
  2169. * const provider = new PhoneAuthProvider(auth);
  2170. * const verificationId = await provider.verifyPhoneNumber(phoneNumber, applicationVerifier);
  2171. * // Obtain verificationCode from the user.
  2172. * const authCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
  2173. * const userCredential = await signInWithCredential(auth, authCredential);
  2174. * ```
  2175. *
  2176. * @example
  2177. * An alternative flow is provided using the `signInWithPhoneNumber` method.
  2178. * ```javascript
  2179. * const confirmationResult = signInWithPhoneNumber(auth, phoneNumber, applicationVerifier);
  2180. * // Obtain verificationCode from the user.
  2181. * const userCredential = confirmationResult.confirm(verificationCode);
  2182. * ```
  2183. *
  2184. * @param phoneInfoOptions - The user's {@link PhoneInfoOptions}. The phone number should be in
  2185. * E.164 format (e.g. +16505550101).
  2186. * @param applicationVerifier - For abuse prevention, this method also requires a
  2187. * {@link ApplicationVerifier}. This SDK includes a reCAPTCHA-based implementation,
  2188. * {@link RecaptchaVerifier}.
  2189. *
  2190. * @returns A Promise for a verification ID that can be passed to
  2191. * {@link PhoneAuthProvider.credential} to identify this flow..
  2192. */
  2193. verifyPhoneNumber(phoneOptions: PhoneInfoOptions | string, applicationVerifier: ApplicationVerifier): Promise<string>;
  2194. /**
  2195. * Creates a phone auth credential, given the verification ID from
  2196. * {@link PhoneAuthProvider.verifyPhoneNumber} and the code that was sent to the user's
  2197. * mobile device.
  2198. *
  2199. * @example
  2200. * ```javascript
  2201. * const provider = new PhoneAuthProvider(auth);
  2202. * const verificationId = provider.verifyPhoneNumber(phoneNumber, applicationVerifier);
  2203. * // Obtain verificationCode from the user.
  2204. * const authCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
  2205. * const userCredential = signInWithCredential(auth, authCredential);
  2206. * ```
  2207. *
  2208. * @example
  2209. * An alternative flow is provided using the `signInWithPhoneNumber` method.
  2210. * ```javascript
  2211. * const confirmationResult = await signInWithPhoneNumber(auth, phoneNumber, applicationVerifier);
  2212. * // Obtain verificationCode from the user.
  2213. * const userCredential = await confirmationResult.confirm(verificationCode);
  2214. * ```
  2215. *
  2216. * @param verificationId - The verification ID returned from {@link PhoneAuthProvider.verifyPhoneNumber}.
  2217. * @param verificationCode - The verification code sent to the user's mobile device.
  2218. *
  2219. * @returns The auth provider credential.
  2220. */
  2221. static credential(verificationId: string, verificationCode: string): PhoneAuthCredential;
  2222. /**
  2223. * Generates an {@link AuthCredential} from a {@link UserCredential}.
  2224. * @param userCredential - The user credential.
  2225. */
  2226. static credentialFromResult(userCredential: UserCredential): AuthCredential | null;
  2227. /**
  2228. * Returns an {@link AuthCredential} when passed an error.
  2229. *
  2230. * @remarks
  2231. *
  2232. * This method works for errors like
  2233. * `auth/account-exists-with-different-credentials`. This is useful for
  2234. * recovering when attempting to set a user's phone number but the number
  2235. * in question is already tied to another account. For example, the following
  2236. * code tries to update the current user's phone number, and if that
  2237. * fails, links the user with the account associated with that number:
  2238. *
  2239. * ```js
  2240. * const provider = new PhoneAuthProvider(auth);
  2241. * const verificationId = await provider.verifyPhoneNumber(number, verifier);
  2242. * try {
  2243. * const code = ''; // Prompt the user for the verification code
  2244. * await updatePhoneNumber(
  2245. * auth.currentUser,
  2246. * PhoneAuthProvider.credential(verificationId, code));
  2247. * } catch (e) {
  2248. * if ((e as FirebaseError)?.code === 'auth/account-exists-with-different-credential') {
  2249. * const cred = PhoneAuthProvider.credentialFromError(e);
  2250. * await linkWithCredential(auth.currentUser, cred);
  2251. * }
  2252. * }
  2253. *
  2254. * // At this point, auth.currentUser.phoneNumber === number.
  2255. * ```
  2256. *
  2257. * @param error - The error to generate a credential from.
  2258. */
  2259. static credentialFromError(error: FirebaseError): AuthCredential | null;
  2260. private static credentialFromTaggedObject;
  2261. }
  2262. /**
  2263. * The information required to verify the ownership of a phone number.
  2264. *
  2265. * @remarks
  2266. * The information that's required depends on whether you are doing single-factor sign-in,
  2267. * multi-factor enrollment or multi-factor sign-in.
  2268. *
  2269. * @public
  2270. */
  2271. export declare type PhoneInfoOptions = PhoneSingleFactorInfoOptions | PhoneMultiFactorEnrollInfoOptions | PhoneMultiFactorSignInInfoOptions;
  2272. /**
  2273. * An MFA provided by SMS verification
  2274. */
  2275. declare interface PhoneMfaEnrollment extends BaseMfaEnrollment {
  2276. phoneInfo: string;
  2277. }
  2278. /**
  2279. * The class for asserting ownership of a phone second factor. Provided by
  2280. * {@link PhoneMultiFactorGenerator.assertion}.
  2281. *
  2282. * @public
  2283. */
  2284. export declare interface PhoneMultiFactorAssertion extends MultiFactorAssertion {
  2285. }
  2286. /**
  2287. * Options used for enrolling a second factor.
  2288. *
  2289. * @public
  2290. */
  2291. export declare interface PhoneMultiFactorEnrollInfoOptions {
  2292. /** Phone number to send a verification code to. */
  2293. phoneNumber: string;
  2294. /** The {@link MultiFactorSession} obtained via {@link MultiFactorUser.getSession}. */
  2295. session: MultiFactorSession;
  2296. }
  2297. /**
  2298. * Provider for generating a {@link PhoneMultiFactorAssertion}.
  2299. *
  2300. * @public
  2301. */
  2302. export declare class PhoneMultiFactorGenerator {
  2303. private constructor();
  2304. /**
  2305. * Provides a {@link PhoneMultiFactorAssertion} to confirm ownership of the phone second factor.
  2306. *
  2307. * @param phoneAuthCredential - A credential provided by {@link PhoneAuthProvider.credential}.
  2308. * @returns A {@link PhoneMultiFactorAssertion} which can be used with
  2309. * {@link MultiFactorResolver.resolveSignIn}
  2310. */
  2311. static assertion(credential: PhoneAuthCredential): PhoneMultiFactorAssertion;
  2312. /**
  2313. * The identifier of the phone second factor: `phone`.
  2314. */
  2315. static FACTOR_ID: string;
  2316. }
  2317. /**
  2318. * The subclass of the {@link MultiFactorInfo} interface for phone number
  2319. * second factors. The `factorId` of this second factor is {@link FactorId}.PHONE.
  2320. * @public
  2321. */
  2322. export declare interface PhoneMultiFactorInfo extends MultiFactorInfo {
  2323. /** The phone number associated with the current second factor. */
  2324. readonly phoneNumber: string;
  2325. }
  2326. /**
  2327. * Options used for signing in with a second factor.
  2328. *
  2329. * @public
  2330. */
  2331. export declare interface PhoneMultiFactorSignInInfoOptions {
  2332. /**
  2333. * The {@link MultiFactorInfo} obtained via {@link MultiFactorResolver.hints}.
  2334. *
  2335. * One of `multiFactorHint` or `multiFactorUid` is required.
  2336. */
  2337. multiFactorHint?: MultiFactorInfo;
  2338. /**
  2339. * The uid of the second factor.
  2340. *
  2341. * One of `multiFactorHint` or `multiFactorUid` is required.
  2342. */
  2343. multiFactorUid?: string;
  2344. /** The {@link MultiFactorSession} obtained via {@link MultiFactorResolver.session}. */
  2345. session: MultiFactorSession;
  2346. }
  2347. /* Excluded from this release type: PhoneOrOauthTokenResponse */
  2348. /**
  2349. * Options used for single-factor sign-in.
  2350. *
  2351. * @public
  2352. */
  2353. export declare interface PhoneSingleFactorInfoOptions {
  2354. /** Phone number to send a verification code to. */
  2355. phoneNumber: string;
  2356. }
  2357. /**
  2358. * A resolver used for handling DOM specific operations like {@link signInWithPopup}
  2359. * or {@link signInWithRedirect}.
  2360. *
  2361. * @public
  2362. */
  2363. export declare interface PopupRedirectResolver {
  2364. }
  2365. /* Excluded from this release type: PopupRedirectResolverInternal */
  2366. /**
  2367. * A minimal error map with all verbose error messages stripped.
  2368. *
  2369. * See discussion at {@link AuthErrorMap}
  2370. *
  2371. * @public
  2372. */
  2373. export declare const prodErrorMap: AuthErrorMap;
  2374. /**
  2375. * Enumeration of supported providers.
  2376. *
  2377. * @public
  2378. */
  2379. export declare const ProviderId: {
  2380. /** Facebook provider ID */
  2381. readonly FACEBOOK: "facebook.com";
  2382. /** GitHub provider ID */
  2383. readonly GITHUB: "github.com";
  2384. /** Google provider ID */
  2385. readonly GOOGLE: "google.com";
  2386. /** Password provider */
  2387. readonly PASSWORD: "password";
  2388. /** Phone provider */
  2389. readonly PHONE: "phone";
  2390. /** Twitter provider ID */
  2391. readonly TWITTER: "twitter.com";
  2392. };
  2393. /* Excluded from this release type: ProviderId_2 */
  2394. declare interface ProviderUserInfo {
  2395. providerId: string;
  2396. rawId?: string;
  2397. email?: string;
  2398. displayName?: string;
  2399. photoUrl?: string;
  2400. phoneNumber?: string;
  2401. }
  2402. /**
  2403. * Interface for a supplied `AsyncStorage`.
  2404. *
  2405. * @public
  2406. */
  2407. export declare interface ReactNativeAsyncStorage {
  2408. /**
  2409. * Persist an item in storage.
  2410. *
  2411. * @param key - storage key.
  2412. * @param value - storage value.
  2413. */
  2414. setItem(key: string, value: string): Promise<void>;
  2415. /**
  2416. * Retrieve an item from storage.
  2417. *
  2418. * @param key - storage key.
  2419. */
  2420. getItem(key: string): Promise<string | null>;
  2421. /**
  2422. * Remove an item from storage.
  2423. *
  2424. * @param key - storage key.
  2425. */
  2426. removeItem(key: string): Promise<void>;
  2427. }
  2428. /**
  2429. * Re-authenticates a user using a fresh credential.
  2430. *
  2431. * @remarks
  2432. * Use before operations such as {@link updatePassword} that require tokens from recent sign-in
  2433. * attempts. This method can be used to recover from a `CREDENTIAL_TOO_OLD_LOGIN_AGAIN` error.
  2434. *
  2435. * @param user - The user.
  2436. * @param credential - The auth credential.
  2437. *
  2438. * @public
  2439. */
  2440. export declare function reauthenticateWithCredential(user: User, credential: AuthCredential): Promise<UserCredential>;
  2441. /**
  2442. * Re-authenticates a user using a fresh phone credential.
  2443. *
  2444. * @remarks Use before operations such as {@link updatePassword} that require tokens from recent sign-in attempts.
  2445. *
  2446. * @param user - The user.
  2447. * @param phoneNumber - The user's phone number in E.164 format (e.g. +16505550101).
  2448. * @param appVerifier - The {@link ApplicationVerifier}.
  2449. *
  2450. * @public
  2451. */
  2452. export declare function reauthenticateWithPhoneNumber(user: User, phoneNumber: string, appVerifier: ApplicationVerifier): Promise<ConfirmationResult>;
  2453. /**
  2454. * Reauthenticates the current user with the specified {@link OAuthProvider} using a pop-up based
  2455. * OAuth flow.
  2456. *
  2457. * @remarks
  2458. * If the reauthentication is successful, the returned result will contain the user and the
  2459. * provider's credential.
  2460. *
  2461. * @example
  2462. * ```javascript
  2463. * // Sign in using a popup.
  2464. * const provider = new FacebookAuthProvider();
  2465. * const result = await signInWithPopup(auth, provider);
  2466. * // Reauthenticate using a popup.
  2467. * await reauthenticateWithPopup(result.user, provider);
  2468. * ```
  2469. *
  2470. * @param user - The user.
  2471. * @param provider - The provider to authenticate. The provider has to be an {@link OAuthProvider}.
  2472. * Non-OAuth providers like {@link EmailAuthProvider} will throw an error.
  2473. * @param resolver - An instance of {@link PopupRedirectResolver}, optional
  2474. * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
  2475. *
  2476. * @public
  2477. */
  2478. export declare function reauthenticateWithPopup(user: User, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<UserCredential>;
  2479. /**
  2480. * Reauthenticates the current user with the specified {@link OAuthProvider} using a full-page redirect flow.
  2481. * @remarks
  2482. * To handle the results and errors for this operation, refer to {@link getRedirectResult}.
  2483. * Follow the [best practices](https://firebase.google.com/docs/auth/web/redirect-best-practices) when using {@link reauthenticateWithRedirect}.
  2484. *
  2485. * @example
  2486. * ```javascript
  2487. * // Sign in using a redirect.
  2488. * const provider = new FacebookAuthProvider();
  2489. * const result = await signInWithRedirect(auth, provider);
  2490. * // This will trigger a full page redirect away from your app
  2491. *
  2492. * // After returning from the redirect when your app initializes you can obtain the result
  2493. * const result = await getRedirectResult(auth);
  2494. * // Reauthenticate using a redirect.
  2495. * await reauthenticateWithRedirect(result.user, provider);
  2496. * // This will again trigger a full page redirect away from your app
  2497. *
  2498. * // After returning from the redirect when your app initializes you can obtain the result
  2499. * const result = await getRedirectResult(auth);
  2500. * ```
  2501. *
  2502. * @param user - The user.
  2503. * @param provider - The provider to authenticate. The provider has to be an {@link OAuthProvider}.
  2504. * Non-OAuth providers like {@link EmailAuthProvider} will throw an error.
  2505. * @param resolver - An instance of {@link PopupRedirectResolver}, optional
  2506. * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
  2507. *
  2508. * @public
  2509. */
  2510. export declare function reauthenticateWithRedirect(user: User, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<never>;
  2511. declare interface Recaptcha {
  2512. render: (container: HTMLElement, parameters: RecaptchaParameters) => number;
  2513. getResponse: (id: number) => string;
  2514. execute: (id: number) => unknown;
  2515. reset: (id: number) => unknown;
  2516. }
  2517. /* Excluded from this release type: ReCaptchaLoader */
  2518. /**
  2519. * Interface representing reCAPTCHA parameters.
  2520. *
  2521. * See the [reCAPTCHA docs](https://developers.google.com/recaptcha/docs/display#render_param)
  2522. * for the list of accepted parameters. All parameters are accepted except for `sitekey`: Firebase Auth
  2523. * provisions a reCAPTCHA for each project and will configure the site key upon rendering.
  2524. *
  2525. * For an invisible reCAPTCHA, set the `size` key to `invisible`.
  2526. *
  2527. * @public
  2528. */
  2529. export declare interface RecaptchaParameters {
  2530. [key: string]: any;
  2531. }
  2532. /**
  2533. * An {@link https://www.google.com/recaptcha/ | reCAPTCHA}-based application verifier.
  2534. *
  2535. * @public
  2536. */
  2537. export declare class RecaptchaVerifier implements ApplicationVerifierInternal {
  2538. private readonly parameters;
  2539. /**
  2540. * The application verifier type.
  2541. *
  2542. * @remarks
  2543. * For a reCAPTCHA verifier, this is 'recaptcha'.
  2544. */
  2545. readonly type = "recaptcha";
  2546. private destroyed;
  2547. private widgetId;
  2548. private readonly container;
  2549. private readonly isInvisible;
  2550. private readonly tokenChangeListeners;
  2551. private renderPromise;
  2552. private readonly auth;
  2553. /* Excluded from this release type: _recaptchaLoader */
  2554. private recaptcha;
  2555. /**
  2556. *
  2557. * @param containerOrId - The reCAPTCHA container parameter.
  2558. *
  2559. * @remarks
  2560. * This has different meaning depending on whether the reCAPTCHA is hidden or visible. For a
  2561. * visible reCAPTCHA the container must be empty. If a string is used, it has to correspond to
  2562. * an element ID. The corresponding element must also must be in the DOM at the time of
  2563. * initialization.
  2564. *
  2565. * @param parameters - The optional reCAPTCHA parameters.
  2566. *
  2567. * @remarks
  2568. * Check the reCAPTCHA docs for a comprehensive list. All parameters are accepted except for
  2569. * the sitekey. Firebase Auth backend provisions a reCAPTCHA for each project and will
  2570. * configure this upon rendering. For an invisible reCAPTCHA, a size key must have the value
  2571. * 'invisible'.
  2572. *
  2573. * @param authExtern - The corresponding Firebase {@link Auth} instance.
  2574. */
  2575. constructor(containerOrId: HTMLElement | string, parameters: RecaptchaParameters, authExtern: Auth);
  2576. /**
  2577. * Waits for the user to solve the reCAPTCHA and resolves with the reCAPTCHA token.
  2578. *
  2579. * @returns A Promise for the reCAPTCHA token.
  2580. */
  2581. verify(): Promise<string>;
  2582. /**
  2583. * Renders the reCAPTCHA widget on the page.
  2584. *
  2585. * @returns A Promise that resolves with the reCAPTCHA widget ID.
  2586. */
  2587. render(): Promise<number>;
  2588. /* Excluded from this release type: _reset */
  2589. /**
  2590. * Clears the reCAPTCHA widget from the page and destroys the instance.
  2591. */
  2592. clear(): void;
  2593. private validateStartingState;
  2594. private makeTokenCallback;
  2595. private assertNotDestroyed;
  2596. private makeRenderPromise;
  2597. private init;
  2598. private getAssertedRecaptcha;
  2599. }
  2600. /**
  2601. * Reloads user account data, if signed in.
  2602. *
  2603. * @param user - The user.
  2604. *
  2605. * @public
  2606. */
  2607. export declare function reload(user: User): Promise<void>;
  2608. /**
  2609. * An {@link AuthProvider} for SAML.
  2610. *
  2611. * @public
  2612. */
  2613. export declare class SAMLAuthProvider extends FederatedAuthProvider {
  2614. /**
  2615. * Constructor. The providerId must start with "saml."
  2616. * @param providerId - SAML provider ID.
  2617. */
  2618. constructor(providerId: string);
  2619. /**
  2620. * Generates an {@link AuthCredential} from a {@link UserCredential} after a
  2621. * successful SAML flow completes.
  2622. *
  2623. * @remarks
  2624. *
  2625. * For example, to get an {@link AuthCredential}, you could write the
  2626. * following code:
  2627. *
  2628. * ```js
  2629. * const userCredential = await signInWithPopup(auth, samlProvider);
  2630. * const credential = SAMLAuthProvider.credentialFromResult(userCredential);
  2631. * ```
  2632. *
  2633. * @param userCredential - The user credential.
  2634. */
  2635. static credentialFromResult(userCredential: UserCredential): AuthCredential | null;
  2636. /**
  2637. * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
  2638. * thrown during a sign-in, link, or reauthenticate operation.
  2639. *
  2640. * @param userCredential - The user credential.
  2641. */
  2642. static credentialFromError(error: FirebaseError): AuthCredential | null;
  2643. /**
  2644. * Creates an {@link AuthCredential} from a JSON string or a plain object.
  2645. * @param json - A plain object or a JSON string
  2646. */
  2647. static credentialFromJSON(json: string | object): AuthCredential;
  2648. private static samlCredentialFromTaggedObject;
  2649. }
  2650. /**
  2651. * Sends a verification email to a user.
  2652. *
  2653. * @remarks
  2654. * The verification process is completed by calling {@link applyActionCode}.
  2655. *
  2656. * @example
  2657. * ```javascript
  2658. * const actionCodeSettings = {
  2659. * url: 'https://www.example.com/?email=user@example.com',
  2660. * iOS: {
  2661. * bundleId: 'com.example.ios'
  2662. * },
  2663. * android: {
  2664. * packageName: 'com.example.android',
  2665. * installApp: true,
  2666. * minimumVersion: '12'
  2667. * },
  2668. * handleCodeInApp: true
  2669. * };
  2670. * await sendEmailVerification(user, actionCodeSettings);
  2671. * // Obtain code from the user.
  2672. * await applyActionCode(auth, code);
  2673. * ```
  2674. *
  2675. * @param user - The user.
  2676. * @param actionCodeSettings - The {@link ActionCodeSettings}.
  2677. *
  2678. * @public
  2679. */
  2680. export declare function sendEmailVerification(user: User, actionCodeSettings?: ActionCodeSettings | null): Promise<void>;
  2681. /**
  2682. * Sends a password reset email to the given email address.
  2683. *
  2684. * @remarks
  2685. * To complete the password reset, call {@link confirmPasswordReset} with the code supplied in
  2686. * the email sent to the user, along with the new password specified by the user.
  2687. *
  2688. * @example
  2689. * ```javascript
  2690. * const actionCodeSettings = {
  2691. * url: 'https://www.example.com/?email=user@example.com',
  2692. * iOS: {
  2693. * bundleId: 'com.example.ios'
  2694. * },
  2695. * android: {
  2696. * packageName: 'com.example.android',
  2697. * installApp: true,
  2698. * minimumVersion: '12'
  2699. * },
  2700. * handleCodeInApp: true
  2701. * };
  2702. * await sendPasswordResetEmail(auth, 'user@example.com', actionCodeSettings);
  2703. * // Obtain code from user.
  2704. * await confirmPasswordReset('user@example.com', code);
  2705. * ```
  2706. *
  2707. * @param auth - The {@link Auth} instance.
  2708. * @param email - The user's email address.
  2709. * @param actionCodeSettings - The {@link ActionCodeSettings}.
  2710. *
  2711. * @public
  2712. */
  2713. export declare function sendPasswordResetEmail(auth: Auth, email: string, actionCodeSettings?: ActionCodeSettings): Promise<void>;
  2714. /**
  2715. * Sends a sign-in email link to the user with the specified email.
  2716. *
  2717. * @remarks
  2718. * The sign-in operation has to always be completed in the app unlike other out of band email
  2719. * actions (password reset and email verifications). This is because, at the end of the flow,
  2720. * the user is expected to be signed in and their Auth state persisted within the app.
  2721. *
  2722. * To complete sign in with the email link, call {@link signInWithEmailLink} with the email
  2723. * address and the email link supplied in the email sent to the user.
  2724. *
  2725. * @example
  2726. * ```javascript
  2727. * const actionCodeSettings = {
  2728. * url: 'https://www.example.com/?email=user@example.com',
  2729. * iOS: {
  2730. * bundleId: 'com.example.ios'
  2731. * },
  2732. * android: {
  2733. * packageName: 'com.example.android',
  2734. * installApp: true,
  2735. * minimumVersion: '12'
  2736. * },
  2737. * handleCodeInApp: true
  2738. * };
  2739. * await sendSignInLinkToEmail(auth, 'user@example.com', actionCodeSettings);
  2740. * // Obtain emailLink from the user.
  2741. * if(isSignInWithEmailLink(auth, emailLink)) {
  2742. * await signInWithEmailLink(auth, 'user@example.com', emailLink);
  2743. * }
  2744. * ```
  2745. *
  2746. * @param authInternal - The {@link Auth} instance.
  2747. * @param email - The user's email address.
  2748. * @param actionCodeSettings - The {@link ActionCodeSettings}.
  2749. *
  2750. * @public
  2751. */
  2752. export declare function sendSignInLinkToEmail(auth: Auth, email: string, actionCodeSettings: ActionCodeSettings): Promise<void>;
  2753. /**
  2754. * Changes the type of persistence on the {@link Auth} instance for the currently saved
  2755. * `Auth` session and applies this type of persistence for future sign-in requests, including
  2756. * sign-in with redirect requests.
  2757. *
  2758. * @remarks
  2759. * This makes it easy for a user signing in to specify whether their session should be
  2760. * remembered or not. It also makes it easier to never persist the `Auth` state for applications
  2761. * that are shared by other users or have sensitive data.
  2762. *
  2763. * @example
  2764. * ```javascript
  2765. * setPersistence(auth, browserSessionPersistence);
  2766. * ```
  2767. *
  2768. * @param auth - The {@link Auth} instance.
  2769. * @param persistence - The {@link Persistence} to use.
  2770. * @returns A `Promise` that resolves once the persistence change has completed
  2771. *
  2772. * @public
  2773. */
  2774. export declare function setPersistence(auth: Auth, persistence: Persistence): Promise<void>;
  2775. /**
  2776. * Asynchronously signs in as an anonymous user.
  2777. *
  2778. * @remarks
  2779. * If there is already an anonymous user signed in, that user will be returned; otherwise, a
  2780. * new anonymous user identity will be created and returned.
  2781. *
  2782. * @param auth - The {@link Auth} instance.
  2783. *
  2784. * @public
  2785. */
  2786. export declare function signInAnonymously(auth: Auth): Promise<UserCredential>;
  2787. /**
  2788. * Enumeration of supported sign-in methods.
  2789. *
  2790. * @public
  2791. */
  2792. export declare const SignInMethod: {
  2793. /** Email link sign in method */
  2794. readonly EMAIL_LINK: "emailLink";
  2795. /** Email/password sign in method */
  2796. readonly EMAIL_PASSWORD: "password";
  2797. /** Facebook sign in method */
  2798. readonly FACEBOOK: "facebook.com";
  2799. /** GitHub sign in method */
  2800. readonly GITHUB: "github.com";
  2801. /** Google sign in method */
  2802. readonly GOOGLE: "google.com";
  2803. /** Phone sign in method */
  2804. readonly PHONE: "phone";
  2805. /** Twitter sign in method */
  2806. readonly TWITTER: "twitter.com";
  2807. };
  2808. /**
  2809. * Asynchronously signs in with the given credentials.
  2810. *
  2811. * @remarks
  2812. * An {@link AuthProvider} can be used to generate the credential.
  2813. *
  2814. * @param auth - The {@link Auth} instance.
  2815. * @param credential - The auth credential.
  2816. *
  2817. * @public
  2818. */
  2819. export declare function signInWithCredential(auth: Auth, credential: AuthCredential): Promise<UserCredential>;
  2820. /**
  2821. * Asynchronously signs in using a custom token.
  2822. *
  2823. * @remarks
  2824. * Custom tokens are used to integrate Firebase Auth with existing auth systems, and must
  2825. * be generated by an auth backend using the
  2826. * {@link https://firebase.google.com/docs/reference/admin/node/admin.auth.Auth#createcustomtoken | createCustomToken}
  2827. * method in the {@link https://firebase.google.com/docs/auth/admin | Admin SDK} .
  2828. *
  2829. * Fails with an error if the token is invalid, expired, or not accepted by the Firebase Auth service.
  2830. *
  2831. * @param auth - The {@link Auth} instance.
  2832. * @param customToken - The custom token to sign in with.
  2833. *
  2834. * @public
  2835. */
  2836. export declare function signInWithCustomToken(auth: Auth, customToken: string): Promise<UserCredential>;
  2837. /**
  2838. * Asynchronously signs in using an email and password.
  2839. *
  2840. * @remarks
  2841. * Fails with an error if the email address and password do not match.
  2842. *
  2843. * Note: The user's password is NOT the password used to access the user's email account. The
  2844. * email address serves as a unique identifier for the user, and the password is used to access
  2845. * the user's account in your Firebase project. See also: {@link createUserWithEmailAndPassword}.
  2846. *
  2847. * @param auth - The {@link Auth} instance.
  2848. * @param email - The users email address.
  2849. * @param password - The users password.
  2850. *
  2851. * @public
  2852. */
  2853. export declare function signInWithEmailAndPassword(auth: Auth, email: string, password: string): Promise<UserCredential>;
  2854. /**
  2855. * Asynchronously signs in using an email and sign-in email link.
  2856. *
  2857. * @remarks
  2858. * If no link is passed, the link is inferred from the current URL.
  2859. *
  2860. * Fails with an error if the email address is invalid or OTP in email link expires.
  2861. *
  2862. * Note: Confirm the link is a sign-in email link before calling this method firebase.auth.Auth.isSignInWithEmailLink.
  2863. *
  2864. * @example
  2865. * ```javascript
  2866. * const actionCodeSettings = {
  2867. * url: 'https://www.example.com/?email=user@example.com',
  2868. * iOS: {
  2869. * bundleId: 'com.example.ios'
  2870. * },
  2871. * android: {
  2872. * packageName: 'com.example.android',
  2873. * installApp: true,
  2874. * minimumVersion: '12'
  2875. * },
  2876. * handleCodeInApp: true
  2877. * };
  2878. * await sendSignInLinkToEmail(auth, 'user@example.com', actionCodeSettings);
  2879. * // Obtain emailLink from the user.
  2880. * if(isSignInWithEmailLink(auth, emailLink)) {
  2881. * await signInWithEmailLink(auth, 'user@example.com', emailLink);
  2882. * }
  2883. * ```
  2884. *
  2885. * @param auth - The {@link Auth} instance.
  2886. * @param email - The user's email address.
  2887. * @param emailLink - The link sent to the user's email address.
  2888. *
  2889. * @public
  2890. */
  2891. export declare function signInWithEmailLink(auth: Auth, email: string, emailLink?: string): Promise<UserCredential>;
  2892. /* Excluded from this release type: SignInWithIdpResponse */
  2893. /**
  2894. * Asynchronously signs in using a phone number.
  2895. *
  2896. * @remarks
  2897. * This method sends a code via SMS to the given
  2898. * phone number, and returns a {@link ConfirmationResult}. After the user
  2899. * provides the code sent to their phone, call {@link ConfirmationResult.confirm}
  2900. * with the code to sign the user in.
  2901. *
  2902. * For abuse prevention, this method also requires a {@link ApplicationVerifier}.
  2903. * This SDK includes a reCAPTCHA-based implementation, {@link RecaptchaVerifier}.
  2904. * This function can work on other platforms that do not support the
  2905. * {@link RecaptchaVerifier} (like React Native), but you need to use a
  2906. * third-party {@link ApplicationVerifier} implementation.
  2907. *
  2908. * @example
  2909. * ```javascript
  2910. * // 'recaptcha-container' is the ID of an element in the DOM.
  2911. * const applicationVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container');
  2912. * const confirmationResult = await signInWithPhoneNumber(auth, phoneNumber, applicationVerifier);
  2913. * // Obtain a verificationCode from the user.
  2914. * const credential = await confirmationResult.confirm(verificationCode);
  2915. * ```
  2916. *
  2917. * @param auth - The {@link Auth} instance.
  2918. * @param phoneNumber - The user's phone number in E.164 format (e.g. +16505550101).
  2919. * @param appVerifier - The {@link ApplicationVerifier}.
  2920. *
  2921. * @public
  2922. */
  2923. export declare function signInWithPhoneNumber(auth: Auth, phoneNumber: string, appVerifier: ApplicationVerifier): Promise<ConfirmationResult>;
  2924. /* Excluded from this release type: SignInWithPhoneNumberRequest */
  2925. /* Excluded from this release type: SignInWithPhoneNumberResponse */
  2926. /**
  2927. * Authenticates a Firebase client using a popup-based OAuth authentication flow.
  2928. *
  2929. * @remarks
  2930. * If succeeds, returns the signed in user along with the provider's credential. If sign in was
  2931. * unsuccessful, returns an error object containing additional information about the error.
  2932. *
  2933. * @example
  2934. * ```javascript
  2935. * // Sign in using a popup.
  2936. * const provider = new FacebookAuthProvider();
  2937. * const result = await signInWithPopup(auth, provider);
  2938. *
  2939. * // The signed-in user info.
  2940. * const user = result.user;
  2941. * // This gives you a Facebook Access Token.
  2942. * const credential = provider.credentialFromResult(auth, result);
  2943. * const token = credential.accessToken;
  2944. * ```
  2945. *
  2946. * @param auth - The {@link Auth} instance.
  2947. * @param provider - The provider to authenticate. The provider has to be an {@link OAuthProvider}.
  2948. * Non-OAuth providers like {@link EmailAuthProvider} will throw an error.
  2949. * @param resolver - An instance of {@link PopupRedirectResolver}, optional
  2950. * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
  2951. *
  2952. *
  2953. * @public
  2954. */
  2955. export declare function signInWithPopup(auth: Auth, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<UserCredential>;
  2956. /**
  2957. * Authenticates a Firebase client using a full-page redirect flow.
  2958. *
  2959. * @remarks
  2960. * To handle the results and errors for this operation, refer to {@link getRedirectResult}.
  2961. * Follow the [best practices](https://firebase.google.com/docs/auth/web/redirect-best-practices) when using {@link signInWithRedirect}.
  2962. *
  2963. * @example
  2964. * ```javascript
  2965. * // Sign in using a redirect.
  2966. * const provider = new FacebookAuthProvider();
  2967. * // You can add additional scopes to the provider:
  2968. * provider.addScope('user_birthday');
  2969. * // Start a sign in process for an unauthenticated user.
  2970. * await signInWithRedirect(auth, provider);
  2971. * // This will trigger a full page redirect away from your app
  2972. *
  2973. * // After returning from the redirect when your app initializes you can obtain the result
  2974. * const result = await getRedirectResult(auth);
  2975. * if (result) {
  2976. * // This is the signed-in user
  2977. * const user = result.user;
  2978. * // This gives you a Facebook Access Token.
  2979. * const credential = provider.credentialFromResult(auth, result);
  2980. * const token = credential.accessToken;
  2981. * }
  2982. * // As this API can be used for sign-in, linking and reauthentication,
  2983. * // check the operationType to determine what triggered this redirect
  2984. * // operation.
  2985. * const operationType = result.operationType;
  2986. * ```
  2987. *
  2988. * @param auth - The {@link Auth} instance.
  2989. * @param provider - The provider to authenticate. The provider has to be an {@link OAuthProvider}.
  2990. * Non-OAuth providers like {@link EmailAuthProvider} will throw an error.
  2991. * @param resolver - An instance of {@link PopupRedirectResolver}, optional
  2992. * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
  2993. *
  2994. * @public
  2995. */
  2996. export declare function signInWithRedirect(auth: Auth, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<never>;
  2997. /**
  2998. * Signs out the current user.
  2999. *
  3000. * @param auth - The {@link Auth} instance.
  3001. *
  3002. * @public
  3003. */
  3004. export declare function signOut(auth: Auth): Promise<void>;
  3005. /* Excluded from this release type: StsTokenManager */
  3006. /* Excluded from this release type: TaggedWithTokenResponse */
  3007. /**
  3008. * Provider for generating an {@link OAuthCredential} for {@link ProviderId}.TWITTER.
  3009. *
  3010. * @example
  3011. * ```javascript
  3012. * // Sign in using a redirect.
  3013. * const provider = new TwitterAuthProvider();
  3014. * // Start a sign in process for an unauthenticated user.
  3015. * await signInWithRedirect(auth, provider);
  3016. * // This will trigger a full page redirect away from your app
  3017. *
  3018. * // After returning from the redirect when your app initializes you can obtain the result
  3019. * const result = await getRedirectResult(auth);
  3020. * if (result) {
  3021. * // This is the signed-in user
  3022. * const user = result.user;
  3023. * // This gives you a Twitter Access Token and Secret.
  3024. * const credential = TwitterAuthProvider.credentialFromResult(result);
  3025. * const token = credential.accessToken;
  3026. * const secret = credential.secret;
  3027. * }
  3028. * ```
  3029. *
  3030. * @example
  3031. * ```javascript
  3032. * // Sign in using a popup.
  3033. * const provider = new TwitterAuthProvider();
  3034. * const result = await signInWithPopup(auth, provider);
  3035. *
  3036. * // The signed-in user info.
  3037. * const user = result.user;
  3038. * // This gives you a Twitter Access Token and Secret.
  3039. * const credential = TwitterAuthProvider.credentialFromResult(result);
  3040. * const token = credential.accessToken;
  3041. * const secret = credential.secret;
  3042. * ```
  3043. *
  3044. * @public
  3045. */
  3046. export declare class TwitterAuthProvider extends BaseOAuthProvider {
  3047. /** Always set to {@link SignInMethod}.TWITTER. */
  3048. static readonly TWITTER_SIGN_IN_METHOD: 'twitter.com';
  3049. /** Always set to {@link ProviderId}.TWITTER. */
  3050. static readonly PROVIDER_ID: 'twitter.com';
  3051. constructor();
  3052. /**
  3053. * Creates a credential for Twitter.
  3054. *
  3055. * @param token - Twitter access token.
  3056. * @param secret - Twitter secret.
  3057. */
  3058. static credential(token: string, secret: string): OAuthCredential;
  3059. /**
  3060. * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
  3061. *
  3062. * @param userCredential - The user credential.
  3063. */
  3064. static credentialFromResult(userCredential: UserCredential): OAuthCredential | null;
  3065. /**
  3066. * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
  3067. * thrown during a sign-in, link, or reauthenticate operation.
  3068. *
  3069. * @param userCredential - The user credential.
  3070. */
  3071. static credentialFromError(error: FirebaseError): OAuthCredential | null;
  3072. private static credentialFromTaggedObject;
  3073. }
  3074. /**
  3075. * Unlinks a provider from a user account.
  3076. *
  3077. * @param user - The user.
  3078. * @param providerId - The provider to unlink.
  3079. *
  3080. * @public
  3081. */
  3082. export declare function unlink(user: User, providerId: string): Promise<User>;
  3083. export { Unsubscribe }
  3084. /**
  3085. * Asynchronously sets the provided user as {@link Auth.currentUser} on the
  3086. * {@link Auth} instance.
  3087. *
  3088. * @remarks
  3089. * A new instance copy of the user provided will be made and set as currentUser.
  3090. *
  3091. * This will trigger {@link onAuthStateChanged} and {@link onIdTokenChanged} listeners
  3092. * like other sign in methods.
  3093. *
  3094. * The operation fails with an error if the user to be updated belongs to a different Firebase
  3095. * project.
  3096. *
  3097. * @param auth - The {@link Auth} instance.
  3098. * @param user - The new {@link User}.
  3099. *
  3100. * @public
  3101. */
  3102. export declare function updateCurrentUser(auth: Auth, user: User | null): Promise<void>;
  3103. /**
  3104. * Updates the user's email address.
  3105. *
  3106. * @remarks
  3107. * An email will be sent to the original email address (if it was set) that allows to revoke the
  3108. * email address change, in order to protect them from account hijacking.
  3109. *
  3110. * Important: this is a security sensitive operation that requires the user to have recently signed
  3111. * in. If this requirement isn't met, ask the user to authenticate again and then call
  3112. * {@link reauthenticateWithCredential}.
  3113. *
  3114. * @param user - The user.
  3115. * @param newEmail - The new email address.
  3116. *
  3117. * @public
  3118. */
  3119. export declare function updateEmail(user: User, newEmail: string): Promise<void>;
  3120. /**
  3121. * Updates the user's password.
  3122. *
  3123. * @remarks
  3124. * Important: this is a security sensitive operation that requires the user to have recently signed
  3125. * in. If this requirement isn't met, ask the user to authenticate again and then call
  3126. * {@link reauthenticateWithCredential}.
  3127. *
  3128. * @param user - The user.
  3129. * @param newPassword - The new password.
  3130. *
  3131. * @public
  3132. */
  3133. export declare function updatePassword(user: User, newPassword: string): Promise<void>;
  3134. /**
  3135. * Updates the user's phone number.
  3136. *
  3137. * @example
  3138. * ```
  3139. * // 'recaptcha-container' is the ID of an element in the DOM.
  3140. * const applicationVerifier = new RecaptchaVerifier('recaptcha-container');
  3141. * const provider = new PhoneAuthProvider(auth);
  3142. * const verificationId = await provider.verifyPhoneNumber('+16505550101', applicationVerifier);
  3143. * // Obtain the verificationCode from the user.
  3144. * const phoneCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
  3145. * await updatePhoneNumber(user, phoneCredential);
  3146. * ```
  3147. *
  3148. * @param user - The user.
  3149. * @param credential - A credential authenticating the new phone number.
  3150. *
  3151. * @public
  3152. */
  3153. export declare function updatePhoneNumber(user: User, credential: PhoneAuthCredential): Promise<void>;
  3154. /**
  3155. * Updates a user's profile data.
  3156. *
  3157. * @param user - The user.
  3158. * @param profile - The profile's `displayName` and `photoURL` to update.
  3159. *
  3160. * @public
  3161. */
  3162. export declare function updateProfile(user: User, { displayName, photoURL: photoUrl }: {
  3163. displayName?: string | null;
  3164. photoURL?: string | null;
  3165. }): Promise<void>;
  3166. /**
  3167. * Sets the current language to the default device/browser preference.
  3168. *
  3169. * @param auth - The {@link Auth} instance.
  3170. *
  3171. * @public
  3172. */
  3173. export declare function useDeviceLanguage(auth: Auth): void;
  3174. /**
  3175. * A user account.
  3176. *
  3177. * @public
  3178. */
  3179. export declare interface User extends UserInfo {
  3180. /**
  3181. * Whether the email has been verified with {@link sendEmailVerification} and
  3182. * {@link applyActionCode}.
  3183. */
  3184. readonly emailVerified: boolean;
  3185. /**
  3186. * Whether the user is authenticated using the {@link ProviderId}.ANONYMOUS provider.
  3187. */
  3188. readonly isAnonymous: boolean;
  3189. /**
  3190. * Additional metadata around user creation and sign-in times.
  3191. */
  3192. readonly metadata: UserMetadata;
  3193. /**
  3194. * Additional per provider such as displayName and profile information.
  3195. */
  3196. readonly providerData: UserInfo[];
  3197. /**
  3198. * Refresh token used to reauthenticate the user. Avoid using this directly and prefer
  3199. * {@link User.getIdToken} to refresh the ID token instead.
  3200. */
  3201. readonly refreshToken: string;
  3202. /**
  3203. * The user's tenant ID.
  3204. *
  3205. * @remarks
  3206. * This is a read-only property, which indicates the tenant ID
  3207. * used to sign in the user. This is null if the user is signed in from the parent
  3208. * project.
  3209. *
  3210. * @example
  3211. * ```javascript
  3212. * // Set the tenant ID on Auth instance.
  3213. * auth.tenantId = 'TENANT_PROJECT_ID';
  3214. *
  3215. * // All future sign-in request now include tenant ID.
  3216. * const result = await signInWithEmailAndPassword(auth, email, password);
  3217. * // result.user.tenantId should be 'TENANT_PROJECT_ID'.
  3218. * ```
  3219. */
  3220. readonly tenantId: string | null;
  3221. /**
  3222. * Deletes and signs out the user.
  3223. *
  3224. * @remarks
  3225. * Important: this is a security-sensitive operation that requires the user to have recently
  3226. * signed in. If this requirement isn't met, ask the user to authenticate again and then call
  3227. * one of the reauthentication methods like {@link reauthenticateWithCredential}.
  3228. */
  3229. delete(): Promise<void>;
  3230. /**
  3231. * Returns a JSON Web Token (JWT) used to identify the user to a Firebase service.
  3232. *
  3233. * @remarks
  3234. * Returns the current token if it has not expired or if it will not expire in the next five
  3235. * minutes. Otherwise, this will refresh the token and return a new one.
  3236. *
  3237. * @param forceRefresh - Force refresh regardless of token expiration.
  3238. */
  3239. getIdToken(forceRefresh?: boolean): Promise<string>;
  3240. /**
  3241. * Returns a deserialized JSON Web Token (JWT) used to identitfy the user to a Firebase service.
  3242. *
  3243. * @remarks
  3244. * Returns the current token if it has not expired or if it will not expire in the next five
  3245. * minutes. Otherwise, this will refresh the token and return a new one.
  3246. *
  3247. * @param forceRefresh - Force refresh regardless of token expiration.
  3248. */
  3249. getIdTokenResult(forceRefresh?: boolean): Promise<IdTokenResult>;
  3250. /**
  3251. * Refreshes the user, if signed in.
  3252. */
  3253. reload(): Promise<void>;
  3254. /**
  3255. * Returns a JSON-serializable representation of this object.
  3256. *
  3257. * @returns A JSON-serializable representation of this object.
  3258. */
  3259. toJSON(): object;
  3260. }
  3261. /**
  3262. * A structure containing a {@link User}, the {@link OperationType}, and the provider ID.
  3263. *
  3264. * @remarks
  3265. * `operationType` could be {@link OperationType}.SIGN_IN for a sign-in operation,
  3266. * {@link OperationType}.LINK for a linking operation and {@link OperationType}.REAUTHENTICATE for
  3267. * a reauthentication operation.
  3268. *
  3269. * @public
  3270. */
  3271. export declare interface UserCredential {
  3272. /**
  3273. * The user authenticated by this credential.
  3274. */
  3275. user: User;
  3276. /**
  3277. * The provider which was used to authenticate the user.
  3278. */
  3279. providerId: string | null;
  3280. /**
  3281. * The type of operation which was used to authenticate the user (such as sign-in or link).
  3282. */
  3283. operationType: typeof OperationType[keyof typeof OperationType];
  3284. }
  3285. /* Excluded from this release type: UserCredentialInternal */
  3286. /**
  3287. * User profile information, visible only to the Firebase project's apps.
  3288. *
  3289. * @public
  3290. */
  3291. export declare interface UserInfo {
  3292. /**
  3293. * The display name of the user.
  3294. */
  3295. readonly displayName: string | null;
  3296. /**
  3297. * The email of the user.
  3298. */
  3299. readonly email: string | null;
  3300. /**
  3301. * The phone number normalized based on the E.164 standard (e.g. +16505550101) for the
  3302. * user.
  3303. *
  3304. * @remarks
  3305. * This is null if the user has no phone credential linked to the account.
  3306. */
  3307. readonly phoneNumber: string | null;
  3308. /**
  3309. * The profile photo URL of the user.
  3310. */
  3311. readonly photoURL: string | null;
  3312. /**
  3313. * The provider used to authenticate the user.
  3314. */
  3315. readonly providerId: string;
  3316. /**
  3317. * The user's unique ID, scoped to the project.
  3318. */
  3319. readonly uid: string;
  3320. }
  3321. /* Excluded from this release type: UserInternal */
  3322. /**
  3323. * Interface representing a user's metadata.
  3324. *
  3325. * @public
  3326. */
  3327. export declare interface UserMetadata {
  3328. /** Time the user was created. */
  3329. readonly creationTime?: string;
  3330. /** Time the user last signed in. */
  3331. readonly lastSignInTime?: string;
  3332. }
  3333. declare class UserMetadata_2 implements UserMetadata {
  3334. private createdAt?;
  3335. private lastLoginAt?;
  3336. creationTime?: string;
  3337. lastSignInTime?: string;
  3338. constructor(createdAt?: string | number | undefined, lastLoginAt?: string | number | undefined);
  3339. private _initializeTime;
  3340. _copy(metadata: UserMetadata_2): void;
  3341. toJSON(): object;
  3342. }
  3343. /**
  3344. * User profile used in {@link AdditionalUserInfo}.
  3345. *
  3346. * @public
  3347. */
  3348. export declare type UserProfile = Record<string, unknown>;
  3349. /**
  3350. * Sends a verification email to a new email address.
  3351. *
  3352. * @remarks
  3353. * The user's email will be updated to the new one after being verified.
  3354. *
  3355. * If you have a custom email action handler, you can complete the verification process by calling
  3356. * {@link applyActionCode}.
  3357. *
  3358. * @example
  3359. * ```javascript
  3360. * const actionCodeSettings = {
  3361. * url: 'https://www.example.com/?email=user@example.com',
  3362. * iOS: {
  3363. * bundleId: 'com.example.ios'
  3364. * },
  3365. * android: {
  3366. * packageName: 'com.example.android',
  3367. * installApp: true,
  3368. * minimumVersion: '12'
  3369. * },
  3370. * handleCodeInApp: true
  3371. * };
  3372. * await verifyBeforeUpdateEmail(user, 'newemail@example.com', actionCodeSettings);
  3373. * // Obtain code from the user.
  3374. * await applyActionCode(auth, code);
  3375. * ```
  3376. *
  3377. * @param user - The user.
  3378. * @param newEmail - The new email address to be verified before update.
  3379. * @param actionCodeSettings - The {@link ActionCodeSettings}.
  3380. *
  3381. * @public
  3382. */
  3383. export declare function verifyBeforeUpdateEmail(user: User, newEmail: string, actionCodeSettings?: ActionCodeSettings | null): Promise<void>;
  3384. /**
  3385. * Checks a password reset code sent to the user by email or other out-of-band mechanism.
  3386. *
  3387. * @returns the user's email address if valid.
  3388. *
  3389. * @param auth - The {@link Auth} instance.
  3390. * @param code - A verification code sent to the user.
  3391. *
  3392. * @public
  3393. */
  3394. export declare function verifyPasswordResetCode(auth: Auth, code: string): Promise<string>;
  3395. export { }