1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252 |
- /**
- * Firebase Authentication
- *
- * @packageDocumentation
- */
- import { CompleteFn } from '@firebase/util';
- import { ErrorFactory } from '@firebase/util';
- import { ErrorFn } from '@firebase/util';
- import { FirebaseApp } from '@firebase/app';
- import { FirebaseError } from '@firebase/util';
- import { NextFn } from '@firebase/util';
- import { Observer } from '@firebase/util';
- import { Unsubscribe } from '@firebase/util';
- /**
- * A response from {@link checkActionCode}.
- *
- * @public
- */
- export declare interface ActionCodeInfo {
- /**
- * The data associated with the action code.
- *
- * @remarks
- * For the {@link ActionCodeOperation}.PASSWORD_RESET, {@link ActionCodeOperation}.VERIFY_EMAIL, and
- * {@link ActionCodeOperation}.RECOVER_EMAIL actions, this object contains an email field with the address
- * the email was sent to.
- *
- * For the {@link ActionCodeOperation}.RECOVER_EMAIL action, which allows a user to undo an email address
- * change, this object also contains a `previousEmail` field with the user account's current
- * email address. After the action completes, the user's email address will revert to the value
- * in the `email` field from the value in `previousEmail` field.
- *
- * For the {@link ActionCodeOperation}.VERIFY_AND_CHANGE_EMAIL action, which allows a user to verify the
- * email before updating it, this object contains a `previousEmail` field with the user account's
- * email address before updating. After the action completes, the user's email address will be
- * updated to the value in the `email` field from the value in `previousEmail` field.
- *
- * For the {@link ActionCodeOperation}.REVERT_SECOND_FACTOR_ADDITION action, which allows a user to
- * unenroll a newly added second factor, this object contains a `multiFactorInfo` field with
- * the information about the second factor. For phone second factor, the `multiFactorInfo`
- * is a {@link MultiFactorInfo} object, which contains the phone number.
- */
- data: {
- email?: string | null;
- multiFactorInfo?: MultiFactorInfo | null;
- previousEmail?: string | null;
- };
- /**
- * The type of operation that generated the action code.
- */
- operation: (typeof ActionCodeOperation)[keyof typeof ActionCodeOperation];
- }
- /**
- * An enumeration of the possible email action types.
- *
- * @public
- */
- export declare const ActionCodeOperation: {
- /** The email link sign-in action. */
- readonly EMAIL_SIGNIN: "EMAIL_SIGNIN";
- /** The password reset action. */
- readonly PASSWORD_RESET: "PASSWORD_RESET";
- /** The email revocation action. */
- readonly RECOVER_EMAIL: "RECOVER_EMAIL";
- /** The revert second factor addition email action. */
- readonly REVERT_SECOND_FACTOR_ADDITION: "REVERT_SECOND_FACTOR_ADDITION";
- /** The revert second factor addition email action. */
- readonly VERIFY_AND_CHANGE_EMAIL: "VERIFY_AND_CHANGE_EMAIL";
- /** The email verification action. */
- readonly VERIFY_EMAIL: "VERIFY_EMAIL";
- };
- /**
- * An interface that defines the required continue/state URL with optional Android and iOS
- * bundle identifiers.
- *
- * @public
- */
- export declare interface ActionCodeSettings {
- /**
- * Sets the Android package name.
- *
- * @remarks
- * This will try to open the link in an android app if it is
- * installed. If `installApp` is passed, it specifies whether to install the Android app if the
- * device supports it and the app is not already installed. If this field is provided without
- * a `packageName`, an error is thrown explaining that the `packageName` must be provided in
- * conjunction with this field. If `minimumVersion` is specified, and an older version of the
- * app is installed, the user is taken to the Play Store to upgrade the app.
- */
- android?: {
- installApp?: boolean;
- minimumVersion?: string;
- packageName: string;
- };
- /**
- * When set to true, the action code link will be be sent as a Universal Link or Android App
- * Link and will be opened by the app if installed.
- *
- * @remarks
- * In the false case, the code will be sent to the web widget first and then on continue will
- * redirect to the app if installed.
- *
- * @defaultValue false
- */
- handleCodeInApp?: boolean;
- /**
- * Sets the iOS bundle ID.
- *
- * @remarks
- * This will try to open the link in an iOS app if it is installed.
- *
- * App installation is not supported for iOS.
- */
- iOS?: {
- bundleId: string;
- };
- /**
- * Sets the link continue/state URL.
- *
- * @remarks
- * This has different meanings in different contexts:
- * - When the link is handled in the web action widgets, this is the deep link in the
- * `continueUrl` query parameter.
- * - When the link is handled in the app directly, this is the `continueUrl` query parameter in
- * the deep link of the Dynamic Link.
- */
- url: string;
- /**
- * When multiple custom dynamic link domains are defined for a project, specify which one to use
- * when the link is to be opened via a specified mobile app (for example, `example.page.link`).
- *
- *
- * @defaultValue The first domain is automatically selected.
- */
- dynamicLinkDomain?: string;
- }
- /**
- * @license
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- /**
- * A utility class to parse email action URLs such as password reset, email verification,
- * email link sign in, etc.
- *
- * @public
- */
- export declare class ActionCodeURL {
- /**
- * The API key of the email action link.
- */
- readonly apiKey: string;
- /**
- * The action code of the email action link.
- */
- readonly code: string;
- /**
- * The continue URL of the email action link. Null if not provided.
- */
- readonly continueUrl: string | null;
- /**
- * The language code of the email action link. Null if not provided.
- */
- readonly languageCode: string | null;
- /**
- * The action performed by the email action link. It returns from one of the types from
- * {@link ActionCodeInfo}
- */
- readonly operation: string;
- /**
- * The tenant ID of the email action link. Null if the email action is from the parent project.
- */
- readonly tenantId: string | null;
- /**
- * @param actionLink - The link from which to extract the URL.
- * @returns The {@link ActionCodeURL} object, or null if the link is invalid.
- *
- * @internal
- */
- constructor(actionLink: string);
- /**
- * Parses the email action link string and returns an {@link ActionCodeURL} if the link is valid,
- * otherwise returns null.
- *
- * @param link - The email action link string.
- * @returns The {@link ActionCodeURL} object, or null if the link is invalid.
- *
- * @public
- */
- static parseLink(link: string): ActionCodeURL | null;
- }
- /**
- * A structure containing additional user information from a federated identity provider.
- *
- * @public
- */
- export declare interface AdditionalUserInfo {
- /**
- * Whether the user is new (created via sign-up) or existing (authenticated using sign-in).
- */
- readonly isNewUser: boolean;
- /**
- * Map containing IDP-specific user data.
- */
- readonly profile: Record<string, unknown> | null;
- /**
- * Identifier for the provider used to authenticate this user.
- */
- readonly providerId: string | null;
- /**
- * The username if the provider is GitHub or Twitter.
- */
- readonly username?: string | null;
- }
- declare interface APIUserInfo {
- localId?: string;
- displayName?: string;
- photoUrl?: string;
- email?: string;
- emailVerified?: boolean;
- phoneNumber?: string;
- lastLoginAt?: number;
- createdAt?: number;
- tenantId?: string;
- passwordHash?: string;
- providerUserInfo?: ProviderUserInfo[];
- mfaInfo?: MfaEnrollment[];
- }
- /**
- * A verifier for domain verification and abuse prevention.
- *
- * @remarks
- * Currently, the only implementation is {@link RecaptchaVerifier}.
- *
- * @public
- */
- export declare interface ApplicationVerifier {
- /**
- * Identifies the type of application verifier (e.g. "recaptcha").
- */
- readonly type: string;
- /**
- * Executes the verification process.
- *
- * @returns A Promise for a token that can be used to assert the validity of a request.
- */
- verify(): Promise<string>;
- }
- declare interface ApplicationVerifierInternal extends ApplicationVerifier {
- /**
- * @internal
- */
- _reset(): void;
- }
- /**
- * Applies a verification code sent to the user by email or other out-of-band mechanism.
- *
- * @param auth - The {@link Auth} instance.
- * @param oobCode - A verification code sent to the user.
- *
- * @public
- */
- export declare function applyActionCode(auth: Auth, oobCode: string): Promise<void>;
- declare type AppName = string;
- /**
- * Interface representing Firebase Auth service.
- *
- * @remarks
- * See {@link https://firebase.google.com/docs/auth/ | Firebase Authentication} for a full guide
- * on how to use the Firebase Auth service.
- *
- * @public
- */
- export declare interface Auth {
- /** The {@link @firebase/app#FirebaseApp} associated with the `Auth` service instance. */
- readonly app: FirebaseApp;
- /** The name of the app associated with the `Auth` service instance. */
- readonly name: string;
- /** The {@link Config} used to initialize this instance. */
- readonly config: Config;
- /**
- * Changes the type of persistence on the `Auth` instance.
- *
- * @remarks
- * This will affect the currently saved Auth session and applies this type of persistence for
- * future sign-in requests, including sign-in with redirect requests.
- *
- * This makes it easy for a user signing in to specify whether their session should be
- * remembered or not. It also makes it easier to never persist the Auth state for applications
- * that are shared by other users or have sensitive data.
- *
- * @example
- * ```javascript
- * auth.setPersistence(browserSessionPersistence);
- * ```
- *
- * @param persistence - The {@link Persistence} to use.
- */
- setPersistence(persistence: Persistence): Promise<void>;
- /**
- * The {@link Auth} instance's language code.
- *
- * @remarks
- * This is a readable/writable property. When set to null, the default Firebase Console language
- * setting is applied. The language code will propagate to email action templates (password
- * reset, email verification and email change revocation), SMS templates for phone authentication,
- * reCAPTCHA verifier and OAuth popup/redirect operations provided the specified providers support
- * localization with the language code specified.
- */
- languageCode: string | null;
- /**
- * The {@link Auth} instance's tenant ID.
- *
- * @remarks
- * This is a readable/writable property. When you set the tenant ID of an {@link Auth} instance, all
- * future sign-in/sign-up operations will pass this tenant ID and sign in or sign up users to
- * the specified tenant project. When set to null, users are signed in to the parent project.
- *
- * @example
- * ```javascript
- * // Set the tenant ID on Auth instance.
- * auth.tenantId = 'TENANT_PROJECT_ID';
- *
- * // All future sign-in request now include tenant ID.
- * const result = await signInWithEmailAndPassword(auth, email, password);
- * // result.user.tenantId should be 'TENANT_PROJECT_ID'.
- * ```
- *
- * @defaultValue null
- */
- tenantId: string | null;
- /**
- * The {@link Auth} instance's settings.
- *
- * @remarks
- * This is used to edit/read configuration related options such as app verification mode for
- * phone authentication.
- */
- readonly settings: AuthSettings;
- /**
- * Adds an observer for changes to the user's sign-in state.
- *
- * @remarks
- * To keep the old behavior, see {@link Auth.onIdTokenChanged}.
- *
- * @param nextOrObserver - callback triggered on change.
- * @param error - Deprecated. This callback is never triggered. Errors
- * on signing in/out can be caught in promises returned from
- * sign-in/sign-out functions.
- * @param completed - Deprecated. This callback is never triggered.
- */
- onAuthStateChanged(nextOrObserver: NextOrObserver<User | null>, error?: ErrorFn, completed?: CompleteFn): Unsubscribe;
- /**
- * Adds a blocking callback that runs before an auth state change
- * sets a new user.
- *
- * @param callback - callback triggered before new user value is set.
- * If this throws, it blocks the user from being set.
- * @param onAbort - callback triggered if a later `beforeAuthStateChanged()`
- * callback throws, allowing you to undo any side effects.
- */
- beforeAuthStateChanged(callback: (user: User | null) => void | Promise<void>, onAbort?: () => void): Unsubscribe;
- /**
- * Adds an observer for changes to the signed-in user's ID token.
- *
- * @remarks
- * This includes sign-in, sign-out, and token refresh events.
- *
- * @param nextOrObserver - callback triggered on change.
- * @param error - Deprecated. This callback is never triggered. Errors
- * on signing in/out can be caught in promises returned from
- * sign-in/sign-out functions.
- * @param completed - Deprecated. This callback is never triggered.
- */
- onIdTokenChanged(nextOrObserver: NextOrObserver<User | null>, error?: ErrorFn, completed?: CompleteFn): Unsubscribe;
- /** The currently signed-in user (or null). */
- readonly currentUser: User | null;
- /** The current emulator configuration (or null). */
- readonly emulatorConfig: EmulatorConfig | null;
- /**
- * Asynchronously sets the provided user as {@link Auth.currentUser} on the {@link Auth} instance.
- *
- * @remarks
- * A new instance copy of the user provided will be made and set as currentUser.
- *
- * This will trigger {@link Auth.onAuthStateChanged} and {@link Auth.onIdTokenChanged} listeners
- * like other sign in methods.
- *
- * The operation fails with an error if the user to be updated belongs to a different Firebase
- * project.
- *
- * @param user - The new {@link User}.
- */
- updateCurrentUser(user: User | null): Promise<void>;
- /**
- * Sets the current language to the default device/browser preference.
- */
- useDeviceLanguage(): void;
- /**
- * Signs out the current user. This does not automatically revoke the user's ID token.
- */
- signOut(): Promise<void>;
- }
- /**
- * Interface that represents the credentials returned by an {@link AuthProvider}.
- *
- * @remarks
- * Implementations specify the details about each auth provider's credential requirements.
- *
- * @public
- */
- export declare class AuthCredential {
- /**
- * The authentication provider ID for the credential.
- *
- * @remarks
- * For example, 'facebook.com', or 'google.com'.
- */
- readonly providerId: string;
- /**
- * The authentication sign in method for the credential.
- *
- * @remarks
- * For example, {@link SignInMethod}.EMAIL_PASSWORD, or
- * {@link SignInMethod}.EMAIL_LINK. This corresponds to the sign-in method
- * identifier as returned in {@link fetchSignInMethodsForEmail}.
- */
- readonly signInMethod: string;
- /** @internal */
- protected constructor(
- /**
- * The authentication provider ID for the credential.
- *
- * @remarks
- * For example, 'facebook.com', or 'google.com'.
- */
- providerId: string,
- /**
- * The authentication sign in method for the credential.
- *
- * @remarks
- * For example, {@link SignInMethod}.EMAIL_PASSWORD, or
- * {@link SignInMethod}.EMAIL_LINK. This corresponds to the sign-in method
- * identifier as returned in {@link fetchSignInMethodsForEmail}.
- */
- signInMethod: string);
- /**
- * Returns a JSON-serializable representation of this object.
- *
- * @returns a JSON-serializable representation of this object.
- */
- toJSON(): object;
- /** @internal */
- _getIdTokenResponse(_auth: AuthInternal): Promise<PhoneOrOauthTokenResponse>;
- /** @internal */
- _linkToIdToken(_auth: AuthInternal, _idToken: string): Promise<IdTokenResponse>;
- /** @internal */
- _getReauthenticationResolver(_auth: AuthInternal): Promise<IdTokenResponse>;
- }
- /**
- * Interface for an `Auth` error.
- *
- * @public
- */
- export declare interface AuthError extends FirebaseError {
- /** Details about the Firebase Auth error. */
- readonly customData: {
- /** The name of the Firebase App which triggered this error. */
- readonly appName: string;
- /** The email address of the user's account, used for sign-in and linking. */
- readonly email?: string;
- /** The phone number of the user's account, used for sign-in and linking. */
- readonly phoneNumber?: string;
- /**
- * The tenant ID being used for sign-in and linking.
- *
- * @remarks
- * If you use {@link signInWithRedirect} to sign in,
- * you have to set the tenant ID on the {@link Auth} instance again as the tenant ID is not persisted
- * after redirection.
- */
- readonly tenantId?: string;
- };
- }
- /**
- * Enumeration of Firebase Auth error codes.
- *
- * @internal
- */
- declare const enum AuthErrorCode {
- ADMIN_ONLY_OPERATION = "admin-restricted-operation",
- ARGUMENT_ERROR = "argument-error",
- APP_NOT_AUTHORIZED = "app-not-authorized",
- APP_NOT_INSTALLED = "app-not-installed",
- CAPTCHA_CHECK_FAILED = "captcha-check-failed",
- CODE_EXPIRED = "code-expired",
- CORDOVA_NOT_READY = "cordova-not-ready",
- CORS_UNSUPPORTED = "cors-unsupported",
- CREDENTIAL_ALREADY_IN_USE = "credential-already-in-use",
- CREDENTIAL_MISMATCH = "custom-token-mismatch",
- CREDENTIAL_TOO_OLD_LOGIN_AGAIN = "requires-recent-login",
- DEPENDENT_SDK_INIT_BEFORE_AUTH = "dependent-sdk-initialized-before-auth",
- DYNAMIC_LINK_NOT_ACTIVATED = "dynamic-link-not-activated",
- EMAIL_CHANGE_NEEDS_VERIFICATION = "email-change-needs-verification",
- EMAIL_EXISTS = "email-already-in-use",
- EMULATOR_CONFIG_FAILED = "emulator-config-failed",
- EXPIRED_OOB_CODE = "expired-action-code",
- EXPIRED_POPUP_REQUEST = "cancelled-popup-request",
- INTERNAL_ERROR = "internal-error",
- INVALID_API_KEY = "invalid-api-key",
- INVALID_APP_CREDENTIAL = "invalid-app-credential",
- INVALID_APP_ID = "invalid-app-id",
- INVALID_AUTH = "invalid-user-token",
- INVALID_AUTH_EVENT = "invalid-auth-event",
- INVALID_CERT_HASH = "invalid-cert-hash",
- INVALID_CODE = "invalid-verification-code",
- INVALID_CONTINUE_URI = "invalid-continue-uri",
- INVALID_CORDOVA_CONFIGURATION = "invalid-cordova-configuration",
- INVALID_CUSTOM_TOKEN = "invalid-custom-token",
- INVALID_DYNAMIC_LINK_DOMAIN = "invalid-dynamic-link-domain",
- INVALID_EMAIL = "invalid-email",
- INVALID_EMULATOR_SCHEME = "invalid-emulator-scheme",
- INVALID_IDP_RESPONSE = "invalid-credential",
- INVALID_MESSAGE_PAYLOAD = "invalid-message-payload",
- INVALID_MFA_SESSION = "invalid-multi-factor-session",
- INVALID_OAUTH_CLIENT_ID = "invalid-oauth-client-id",
- INVALID_OAUTH_PROVIDER = "invalid-oauth-provider",
- INVALID_OOB_CODE = "invalid-action-code",
- INVALID_ORIGIN = "unauthorized-domain",
- INVALID_PASSWORD = "wrong-password",
- INVALID_PERSISTENCE = "invalid-persistence-type",
- INVALID_PHONE_NUMBER = "invalid-phone-number",
- INVALID_PROVIDER_ID = "invalid-provider-id",
- INVALID_RECIPIENT_EMAIL = "invalid-recipient-email",
- INVALID_SENDER = "invalid-sender",
- INVALID_SESSION_INFO = "invalid-verification-id",
- INVALID_TENANT_ID = "invalid-tenant-id",
- LOGIN_BLOCKED = "login-blocked",
- MFA_INFO_NOT_FOUND = "multi-factor-info-not-found",
- MFA_REQUIRED = "multi-factor-auth-required",
- MISSING_ANDROID_PACKAGE_NAME = "missing-android-pkg-name",
- MISSING_APP_CREDENTIAL = "missing-app-credential",
- MISSING_AUTH_DOMAIN = "auth-domain-config-required",
- MISSING_CODE = "missing-verification-code",
- MISSING_CONTINUE_URI = "missing-continue-uri",
- MISSING_IFRAME_START = "missing-iframe-start",
- MISSING_IOS_BUNDLE_ID = "missing-ios-bundle-id",
- MISSING_OR_INVALID_NONCE = "missing-or-invalid-nonce",
- MISSING_MFA_INFO = "missing-multi-factor-info",
- MISSING_MFA_SESSION = "missing-multi-factor-session",
- MISSING_PHONE_NUMBER = "missing-phone-number",
- MISSING_PASSWORD = "missing-password",
- MISSING_SESSION_INFO = "missing-verification-id",
- MODULE_DESTROYED = "app-deleted",
- NEED_CONFIRMATION = "account-exists-with-different-credential",
- NETWORK_REQUEST_FAILED = "network-request-failed",
- NULL_USER = "null-user",
- NO_AUTH_EVENT = "no-auth-event",
- NO_SUCH_PROVIDER = "no-such-provider",
- OPERATION_NOT_ALLOWED = "operation-not-allowed",
- OPERATION_NOT_SUPPORTED = "operation-not-supported-in-this-environment",
- POPUP_BLOCKED = "popup-blocked",
- POPUP_CLOSED_BY_USER = "popup-closed-by-user",
- PROVIDER_ALREADY_LINKED = "provider-already-linked",
- QUOTA_EXCEEDED = "quota-exceeded",
- REDIRECT_CANCELLED_BY_USER = "redirect-cancelled-by-user",
- REDIRECT_OPERATION_PENDING = "redirect-operation-pending",
- REJECTED_CREDENTIAL = "rejected-credential",
- SECOND_FACTOR_ALREADY_ENROLLED = "second-factor-already-in-use",
- SECOND_FACTOR_LIMIT_EXCEEDED = "maximum-second-factor-count-exceeded",
- TENANT_ID_MISMATCH = "tenant-id-mismatch",
- TIMEOUT = "timeout",
- TOKEN_EXPIRED = "user-token-expired",
- TOO_MANY_ATTEMPTS_TRY_LATER = "too-many-requests",
- UNAUTHORIZED_DOMAIN = "unauthorized-continue-uri",
- UNSUPPORTED_FIRST_FACTOR = "unsupported-first-factor",
- UNSUPPORTED_PERSISTENCE = "unsupported-persistence-type",
- UNSUPPORTED_TENANT_OPERATION = "unsupported-tenant-operation",
- UNVERIFIED_EMAIL = "unverified-email",
- USER_CANCELLED = "user-cancelled",
- USER_DELETED = "user-not-found",
- USER_DISABLED = "user-disabled",
- USER_MISMATCH = "user-mismatch",
- USER_SIGNED_OUT = "user-signed-out",
- WEAK_PASSWORD = "weak-password",
- WEB_STORAGE_UNSUPPORTED = "web-storage-unsupported",
- ALREADY_INITIALIZED = "already-initialized",
- RECAPTCHA_NOT_ENABLED = "recaptcha-not-enabled",
- MISSING_RECAPTCHA_TOKEN = "missing-recaptcha-token",
- INVALID_RECAPTCHA_TOKEN = "invalid-recaptcha-token",
- INVALID_RECAPTCHA_ACTION = "invalid-recaptcha-action",
- MISSING_CLIENT_TYPE = "missing-client-type",
- MISSING_RECAPTCHA_VERSION = "missing-recaptcha-version",
- INVALID_RECAPTCHA_VERSION = "invalid-recaptcha-version",
- INVALID_REQ_TYPE = "invalid-req-type"
- }
- /**
- * A map of potential `Auth` error codes, for easier comparison with errors
- * thrown by the SDK.
- *
- * @remarks
- * Note that you can't tree-shake individual keys
- * in the map, so by using the map you might substantially increase your
- * bundle size.
- *
- * @public
- */
- export declare const AuthErrorCodes: {
- readonly ADMIN_ONLY_OPERATION: "auth/admin-restricted-operation";
- readonly ARGUMENT_ERROR: "auth/argument-error";
- readonly APP_NOT_AUTHORIZED: "auth/app-not-authorized";
- readonly APP_NOT_INSTALLED: "auth/app-not-installed";
- readonly CAPTCHA_CHECK_FAILED: "auth/captcha-check-failed";
- readonly CODE_EXPIRED: "auth/code-expired";
- readonly CORDOVA_NOT_READY: "auth/cordova-not-ready";
- readonly CORS_UNSUPPORTED: "auth/cors-unsupported";
- readonly CREDENTIAL_ALREADY_IN_USE: "auth/credential-already-in-use";
- readonly CREDENTIAL_MISMATCH: "auth/custom-token-mismatch";
- readonly CREDENTIAL_TOO_OLD_LOGIN_AGAIN: "auth/requires-recent-login";
- readonly DEPENDENT_SDK_INIT_BEFORE_AUTH: "auth/dependent-sdk-initialized-before-auth";
- readonly DYNAMIC_LINK_NOT_ACTIVATED: "auth/dynamic-link-not-activated";
- readonly EMAIL_CHANGE_NEEDS_VERIFICATION: "auth/email-change-needs-verification";
- readonly EMAIL_EXISTS: "auth/email-already-in-use";
- readonly EMULATOR_CONFIG_FAILED: "auth/emulator-config-failed";
- readonly EXPIRED_OOB_CODE: "auth/expired-action-code";
- readonly EXPIRED_POPUP_REQUEST: "auth/cancelled-popup-request";
- readonly INTERNAL_ERROR: "auth/internal-error";
- readonly INVALID_API_KEY: "auth/invalid-api-key";
- readonly INVALID_APP_CREDENTIAL: "auth/invalid-app-credential";
- readonly INVALID_APP_ID: "auth/invalid-app-id";
- readonly INVALID_AUTH: "auth/invalid-user-token";
- readonly INVALID_AUTH_EVENT: "auth/invalid-auth-event";
- readonly INVALID_CERT_HASH: "auth/invalid-cert-hash";
- readonly INVALID_CODE: "auth/invalid-verification-code";
- readonly INVALID_CONTINUE_URI: "auth/invalid-continue-uri";
- readonly INVALID_CORDOVA_CONFIGURATION: "auth/invalid-cordova-configuration";
- readonly INVALID_CUSTOM_TOKEN: "auth/invalid-custom-token";
- readonly INVALID_DYNAMIC_LINK_DOMAIN: "auth/invalid-dynamic-link-domain";
- readonly INVALID_EMAIL: "auth/invalid-email";
- readonly INVALID_EMULATOR_SCHEME: "auth/invalid-emulator-scheme";
- readonly INVALID_IDP_RESPONSE: "auth/invalid-credential";
- readonly INVALID_MESSAGE_PAYLOAD: "auth/invalid-message-payload";
- readonly INVALID_MFA_SESSION: "auth/invalid-multi-factor-session";
- readonly INVALID_OAUTH_CLIENT_ID: "auth/invalid-oauth-client-id";
- readonly INVALID_OAUTH_PROVIDER: "auth/invalid-oauth-provider";
- readonly INVALID_OOB_CODE: "auth/invalid-action-code";
- readonly INVALID_ORIGIN: "auth/unauthorized-domain";
- readonly INVALID_PASSWORD: "auth/wrong-password";
- readonly INVALID_PERSISTENCE: "auth/invalid-persistence-type";
- readonly INVALID_PHONE_NUMBER: "auth/invalid-phone-number";
- readonly INVALID_PROVIDER_ID: "auth/invalid-provider-id";
- readonly INVALID_RECIPIENT_EMAIL: "auth/invalid-recipient-email";
- readonly INVALID_SENDER: "auth/invalid-sender";
- readonly INVALID_SESSION_INFO: "auth/invalid-verification-id";
- readonly INVALID_TENANT_ID: "auth/invalid-tenant-id";
- readonly MFA_INFO_NOT_FOUND: "auth/multi-factor-info-not-found";
- readonly MFA_REQUIRED: "auth/multi-factor-auth-required";
- readonly MISSING_ANDROID_PACKAGE_NAME: "auth/missing-android-pkg-name";
- readonly MISSING_APP_CREDENTIAL: "auth/missing-app-credential";
- readonly MISSING_AUTH_DOMAIN: "auth/auth-domain-config-required";
- readonly MISSING_CODE: "auth/missing-verification-code";
- readonly MISSING_CONTINUE_URI: "auth/missing-continue-uri";
- readonly MISSING_IFRAME_START: "auth/missing-iframe-start";
- readonly MISSING_IOS_BUNDLE_ID: "auth/missing-ios-bundle-id";
- readonly MISSING_OR_INVALID_NONCE: "auth/missing-or-invalid-nonce";
- readonly MISSING_MFA_INFO: "auth/missing-multi-factor-info";
- readonly MISSING_MFA_SESSION: "auth/missing-multi-factor-session";
- readonly MISSING_PHONE_NUMBER: "auth/missing-phone-number";
- readonly MISSING_SESSION_INFO: "auth/missing-verification-id";
- readonly MODULE_DESTROYED: "auth/app-deleted";
- readonly NEED_CONFIRMATION: "auth/account-exists-with-different-credential";
- readonly NETWORK_REQUEST_FAILED: "auth/network-request-failed";
- readonly NULL_USER: "auth/null-user";
- readonly NO_AUTH_EVENT: "auth/no-auth-event";
- readonly NO_SUCH_PROVIDER: "auth/no-such-provider";
- readonly OPERATION_NOT_ALLOWED: "auth/operation-not-allowed";
- readonly OPERATION_NOT_SUPPORTED: "auth/operation-not-supported-in-this-environment";
- readonly POPUP_BLOCKED: "auth/popup-blocked";
- readonly POPUP_CLOSED_BY_USER: "auth/popup-closed-by-user";
- readonly PROVIDER_ALREADY_LINKED: "auth/provider-already-linked";
- readonly QUOTA_EXCEEDED: "auth/quota-exceeded";
- readonly REDIRECT_CANCELLED_BY_USER: "auth/redirect-cancelled-by-user";
- readonly REDIRECT_OPERATION_PENDING: "auth/redirect-operation-pending";
- readonly REJECTED_CREDENTIAL: "auth/rejected-credential";
- readonly SECOND_FACTOR_ALREADY_ENROLLED: "auth/second-factor-already-in-use";
- readonly SECOND_FACTOR_LIMIT_EXCEEDED: "auth/maximum-second-factor-count-exceeded";
- readonly TENANT_ID_MISMATCH: "auth/tenant-id-mismatch";
- readonly TIMEOUT: "auth/timeout";
- readonly TOKEN_EXPIRED: "auth/user-token-expired";
- readonly TOO_MANY_ATTEMPTS_TRY_LATER: "auth/too-many-requests";
- readonly UNAUTHORIZED_DOMAIN: "auth/unauthorized-continue-uri";
- readonly UNSUPPORTED_FIRST_FACTOR: "auth/unsupported-first-factor";
- readonly UNSUPPORTED_PERSISTENCE: "auth/unsupported-persistence-type";
- readonly UNSUPPORTED_TENANT_OPERATION: "auth/unsupported-tenant-operation";
- readonly UNVERIFIED_EMAIL: "auth/unverified-email";
- readonly USER_CANCELLED: "auth/user-cancelled";
- readonly USER_DELETED: "auth/user-not-found";
- readonly USER_DISABLED: "auth/user-disabled";
- readonly USER_MISMATCH: "auth/user-mismatch";
- readonly USER_SIGNED_OUT: "auth/user-signed-out";
- readonly WEAK_PASSWORD: "auth/weak-password";
- readonly WEB_STORAGE_UNSUPPORTED: "auth/web-storage-unsupported";
- readonly ALREADY_INITIALIZED: "auth/already-initialized";
- readonly RECAPTCHA_NOT_ENABLED: "auth/recaptcha-not-enabled";
- readonly MISSING_RECAPTCHA_TOKEN: "auth/missing-recaptcha-token";
- readonly INVALID_RECAPTCHA_TOKEN: "auth/invalid-recaptcha-token";
- readonly INVALID_RECAPTCHA_ACTION: "auth/invalid-recaptcha-action";
- readonly MISSING_CLIENT_TYPE: "auth/missing-client-type";
- readonly MISSING_RECAPTCHA_VERSION: "auth/missing-recaptcha-version";
- readonly INVALID_RECAPTCHA_VERSION: "auth/invalid-recaptcha-version";
- readonly INVALID_REQ_TYPE: "auth/invalid-req-type";
- };
- /**
- * A mapping of error codes to error messages.
- *
- * @remarks
- *
- * While error messages are useful for debugging (providing verbose textual
- * context around what went wrong), these strings take up a lot of space in the
- * compiled code. When deploying code in production, using {@link prodErrorMap}
- * will save you roughly 10k compressed/gzipped over {@link debugErrorMap}. You
- * can select the error map during initialization:
- *
- * ```javascript
- * initializeAuth(app, {errorMap: debugErrorMap})
- * ```
- *
- * When initializing Auth, {@link prodErrorMap} is default.
- *
- * @public
- */
- export declare interface AuthErrorMap {
- }
- /**
- * @internal
- */
- declare interface AuthErrorParams extends GenericAuthErrorParams {
- [AuthErrorCode.ARGUMENT_ERROR]: {
- appName?: AppName;
- };
- [AuthErrorCode.DEPENDENT_SDK_INIT_BEFORE_AUTH]: {
- appName?: AppName;
- };
- [AuthErrorCode.INTERNAL_ERROR]: {
- appName?: AppName;
- };
- [AuthErrorCode.LOGIN_BLOCKED]: {
- appName?: AppName;
- originalMessage?: string;
- };
- [AuthErrorCode.OPERATION_NOT_SUPPORTED]: {
- appName?: AppName;
- };
- [AuthErrorCode.NO_AUTH_EVENT]: {
- appName?: AppName;
- };
- [AuthErrorCode.MFA_REQUIRED]: {
- appName: AppName;
- _serverResponse: IdTokenMfaResponse;
- };
- [AuthErrorCode.INVALID_CORDOVA_CONFIGURATION]: {
- appName: AppName;
- missingPlugin?: string;
- };
- }
- /**
- * @internal
- */
- declare interface AuthEvent {
- type: AuthEventType;
- eventId: string | null;
- urlResponse: string | null;
- sessionId: string | null;
- postBody: string | null;
- tenantId: string | null;
- error?: AuthEventError;
- }
- /**
- * @internal
- */
- declare interface AuthEventConsumer {
- readonly filter: AuthEventType[];
- eventId: string | null;
- onAuthEvent(event: AuthEvent): unknown;
- onError(error: FirebaseError): unknown;
- }
- declare interface AuthEventError extends Error {
- code: string;
- message: string;
- }
- /**
- * @internal
- */
- declare const enum AuthEventType {
- LINK_VIA_POPUP = "linkViaPopup",
- LINK_VIA_REDIRECT = "linkViaRedirect",
- REAUTH_VIA_POPUP = "reauthViaPopup",
- REAUTH_VIA_REDIRECT = "reauthViaRedirect",
- SIGN_IN_VIA_POPUP = "signInViaPopup",
- SIGN_IN_VIA_REDIRECT = "signInViaRedirect",
- UNKNOWN = "unknown",
- VERIFY_APP = "verifyApp"
- }
- /**
- * UserInternal and AuthInternal reference each other, so both of them are included in the public typings.
- * In order to exclude them, we mark them as internal explicitly.
- *
- * @internal
- */
- declare interface AuthInternal extends Auth {
- currentUser: User | null;
- emulatorConfig: EmulatorConfig | null;
- _agentRecaptchaConfig: RecaptchaConfig | null;
- _tenantRecaptchaConfigs: Record<string, RecaptchaConfig>;
- _canInitEmulator: boolean;
- _isInitialized: boolean;
- _initializationPromise: Promise<void> | null;
- _updateCurrentUser(user: UserInternal | null): Promise<void>;
- _onStorageEvent(): void;
- _notifyListenersIfCurrent(user: UserInternal): void;
- _persistUserIfCurrent(user: UserInternal): Promise<void>;
- _setRedirectUser(user: UserInternal | null, popupRedirectResolver?: PopupRedirectResolver): Promise<void>;
- _redirectUserForId(id: string): Promise<UserInternal | null>;
- _popupRedirectResolver: PopupRedirectResolverInternal | null;
- _key(): string;
- _startProactiveRefresh(): void;
- _stopProactiveRefresh(): void;
- _getPersistence(): string;
- _getRecaptchaConfig(): RecaptchaConfig | null;
- _logFramework(framework: string): void;
- _getFrameworks(): readonly string[];
- _getAdditionalHeaders(): Promise<Record<string, string>>;
- _getAppCheckToken(): Promise<string | undefined>;
- readonly name: AppName;
- readonly config: ConfigInternal;
- languageCode: string | null;
- tenantId: string | null;
- readonly settings: AuthSettings;
- _errorFactory: ErrorFactory<AuthErrorCode, AuthErrorParams>;
- useDeviceLanguage(): void;
- signOut(): Promise<void>;
- initializeRecaptchaConfig(): Promise<void>;
- }
- declare class AuthPopup {
- readonly window: Window | null;
- associatedEvent: string | null;
- constructor(window: Window | null);
- close(): void;
- }
- /**
- * Interface that represents an auth provider, used to facilitate creating {@link AuthCredential}.
- *
- * @public
- */
- export declare interface AuthProvider {
- /**
- * Provider for which credentials can be constructed.
- */
- readonly providerId: string;
- }
- /**
- * Interface representing an {@link Auth} instance's settings.
- *
- * @remarks Currently used for enabling/disabling app verification for phone Auth testing.
- *
- * @public
- */
- export declare interface AuthSettings {
- /**
- * When set, this property disables app verification for the purpose of testing phone
- * authentication. For this property to take effect, it needs to be set before rendering a
- * reCAPTCHA app verifier. When this is disabled, a mock reCAPTCHA is rendered instead. This is
- * useful for manual testing during development or for automated integration tests.
- *
- * In order to use this feature, you will need to
- * {@link https://firebase.google.com/docs/auth/web/phone-auth#test-with-whitelisted-phone-numbers | whitelist your phone number}
- * via the Firebase Console.
- *
- * The default value is false (app verification is enabled).
- */
- appVerificationDisabledForTesting: boolean;
- }
- /**
- * MFA Info as returned by the API.
- */
- declare interface BaseMfaEnrollment {
- mfaEnrollmentId: string;
- enrolledAt: number;
- displayName?: string;
- }
- /**
- * Common code to all OAuth providers. This is separate from the
- * {@link OAuthProvider} so that child providers (like
- * {@link GoogleAuthProvider}) don't inherit the `credential` instance method.
- * Instead, they rely on a static `credential` method.
- */
- declare abstract class BaseOAuthProvider extends FederatedAuthProvider implements AuthProvider {
- /** @internal */
- private scopes;
- /**
- * Add an OAuth scope to the credential.
- *
- * @param scope - Provider OAuth scope to add.
- */
- addScope(scope: string): AuthProvider;
- /**
- * Retrieve the current list of OAuth scopes.
- */
- getScopes(): string[];
- }
- /**
- * Adds a blocking callback that runs before an auth state change
- * sets a new user.
- *
- * @param auth - The {@link Auth} instance.
- * @param callback - callback triggered before new user value is set.
- * If this throws, it blocks the user from being set.
- * @param onAbort - callback triggered if a later `beforeAuthStateChanged()`
- * callback throws, allowing you to undo any side effects.
- */
- export declare function beforeAuthStateChanged(auth: Auth, callback: (user: User | null) => void | Promise<void>, onAbort?: () => void): Unsubscribe;
- /**
- * An implementation of {@link Persistence} of type `LOCAL` using `localStorage`
- * for the underlying storage.
- *
- * @public
- */
- export declare const browserLocalPersistence: Persistence;
- /**
- * An implementation of {@link PopupRedirectResolver} suitable for browser
- * based applications.
- *
- * @public
- */
- export declare const browserPopupRedirectResolver: PopupRedirectResolver;
- /**
- * An implementation of {@link Persistence} of `SESSION` using `sessionStorage`
- * for the underlying storage.
- *
- * @public
- */
- export declare const browserSessionPersistence: Persistence;
- /**
- * Checks a verification code sent to the user by email or other out-of-band mechanism.
- *
- * @returns metadata about the code.
- *
- * @param auth - The {@link Auth} instance.
- * @param oobCode - A verification code sent to the user.
- *
- * @public
- */
- export declare function checkActionCode(auth: Auth, oobCode: string): Promise<ActionCodeInfo>;
- /**
- * @internal
- */
- declare const enum ClientPlatform {
- BROWSER = "Browser",
- NODE = "Node",
- REACT_NATIVE = "ReactNative",
- CORDOVA = "Cordova",
- WORKER = "Worker"
- }
- export { CompleteFn }
- /**
- * Interface representing the `Auth` config.
- *
- * @public
- */
- export declare interface Config {
- /**
- * The API Key used to communicate with the Firebase Auth backend.
- */
- apiKey: string;
- /**
- * The host at which the Firebase Auth backend is running.
- */
- apiHost: string;
- /**
- * The scheme used to communicate with the Firebase Auth backend.
- */
- apiScheme: string;
- /**
- * The host at which the Secure Token API is running.
- */
- tokenApiHost: string;
- /**
- * The SDK Client Version.
- */
- sdkClientVersion: string;
- /**
- * The domain at which the web widgets are hosted (provided via Firebase Config).
- */
- authDomain?: string;
- }
- /**
- * @internal
- */
- declare interface ConfigInternal extends Config {
- /**
- * @readonly
- */
- emulator?: {
- url: string;
- };
- /**
- * @readonly
- */
- clientPlatform: ClientPlatform;
- }
- /**
- * A result from a phone number sign-in, link, or reauthenticate call.
- *
- * @public
- */
- export declare interface ConfirmationResult {
- /**
- * The phone number authentication operation's verification ID.
- *
- * @remarks
- * This can be used along with the verification code to initialize a
- * {@link PhoneAuthCredential}.
- */
- readonly verificationId: string;
- /**
- * Finishes a phone number sign-in, link, or reauthentication.
- *
- * @example
- * ```javascript
- * const confirmationResult = await signInWithPhoneNumber(auth, phoneNumber, applicationVerifier);
- * // Obtain verificationCode from the user.
- * const userCredential = await confirmationResult.confirm(verificationCode);
- * ```
- *
- * @param verificationCode - The code that was sent to the user's mobile device.
- */
- confirm(verificationCode: string): Promise<UserCredential>;
- }
- /**
- * Completes the password reset process, given a confirmation code and new password.
- *
- * @param auth - The {@link Auth} instance.
- * @param oobCode - A confirmation code sent to the user.
- * @param newPassword - The new password.
- *
- * @public
- */
- export declare function confirmPasswordReset(auth: Auth, oobCode: string, newPassword: string): Promise<void>;
- /**
- * Changes the {@link Auth} instance to communicate with the Firebase Auth Emulator, instead of production
- * Firebase Auth services.
- *
- * @remarks
- * This must be called synchronously immediately following the first call to
- * {@link initializeAuth}. Do not use with production credentials as emulator
- * traffic is not encrypted.
- *
- *
- * @example
- * ```javascript
- * connectAuthEmulator(auth, 'http://127.0.0.1:9099', { disableWarnings: true });
- * ```
- *
- * @param auth - The {@link Auth} instance.
- * @param url - The URL at which the emulator is running (eg, 'http://localhost:9099').
- * @param options - Optional. `options.disableWarnings` defaults to `false`. Set it to
- * `true` to disable the warning banner attached to the DOM.
- *
- * @public
- */
- export declare function connectAuthEmulator(auth: Auth, url: string, options?: {
- disableWarnings: boolean;
- }): void;
- /**
- * Creates a new user account associated with the specified email address and password.
- *
- * @remarks
- * On successful creation of the user account, this user will also be signed in to your application.
- *
- * User account creation can fail if the account already exists or the password is invalid.
- *
- * Note: The email address acts as a unique identifier for the user and enables an email-based
- * password reset. This function will create a new user account and set the initial user password.
- *
- * @param auth - The {@link Auth} instance.
- * @param email - The user's email address.
- * @param password - The user's chosen password.
- *
- * @public
- */
- export declare function createUserWithEmailAndPassword(auth: Auth, email: string, password: string): Promise<UserCredential>;
- /**
- * Map of OAuth Custom Parameters.
- *
- * @public
- */
- export declare type CustomParameters = Record<string, string>;
- /**
- * A verbose error map with detailed descriptions for most error codes.
- *
- * See discussion at {@link AuthErrorMap}
- *
- * @public
- */
- export declare const debugErrorMap: AuthErrorMap;
- /**
- * Deletes and signs out the user.
- *
- * @remarks
- * Important: this is a security-sensitive operation that requires the user to have recently
- * signed in. If this requirement isn't met, ask the user to authenticate again and then call
- * {@link reauthenticateWithCredential}.
- *
- * @param user - The user.
- *
- * @public
- */
- export declare function deleteUser(user: User): Promise<void>;
- /**
- * The dependencies that can be used to initialize an {@link Auth} instance.
- *
- * @remarks
- *
- * The modular SDK enables tree shaking by allowing explicit declarations of
- * dependencies. For example, a web app does not need to include code that
- * enables Cordova redirect sign in. That functionality is therefore split into
- * {@link browserPopupRedirectResolver} and
- * {@link cordovaPopupRedirectResolver}. The dependencies object is how Auth is
- * configured to reduce bundle sizes.
- *
- * There are two ways to initialize an {@link Auth} instance: {@link getAuth} and
- * {@link initializeAuth}. `getAuth` initializes everything using
- * platform-specific configurations, while `initializeAuth` takes a
- * `Dependencies` object directly, giving you more control over what is used.
- *
- * @public
- */
- export declare interface Dependencies {
- /**
- * Which {@link Persistence} to use. If this is an array, the first
- * `Persistence` that the device supports is used. The SDK searches for an
- * existing account in order and, if one is found in a secondary
- * `Persistence`, the account is moved to the primary `Persistence`.
- *
- * If no persistence is provided, the SDK falls back on
- * {@link inMemoryPersistence}.
- */
- persistence?: Persistence | Persistence[];
- /**
- * The {@link PopupRedirectResolver} to use. This value depends on the
- * platform. Options are {@link browserPopupRedirectResolver} and
- * {@link cordovaPopupRedirectResolver}. This field is optional if neither
- * {@link signInWithPopup} or {@link signInWithRedirect} are being used.
- */
- popupRedirectResolver?: PopupRedirectResolver;
- /**
- * Which {@link AuthErrorMap} to use.
- */
- errorMap?: AuthErrorMap;
- }
- /**
- * Interface that represents the credentials returned by {@link EmailAuthProvider} for
- * {@link ProviderId}.PASSWORD
- *
- * @remarks
- * Covers both {@link SignInMethod}.EMAIL_PASSWORD and
- * {@link SignInMethod}.EMAIL_LINK.
- *
- * @public
- */
- export declare class EmailAuthCredential extends AuthCredential {
- /** @internal */
- readonly _email: string;
- /** @internal */
- readonly _password: string;
- /** @internal */
- readonly _tenantId: string | null;
- /** @internal */
- private constructor();
- /** @internal */
- static _fromEmailAndPassword(email: string, password: string): EmailAuthCredential;
- /** @internal */
- static _fromEmailAndCode(email: string, oobCode: string, tenantId?: string | null): EmailAuthCredential;
- /** {@inheritdoc AuthCredential.toJSON} */
- toJSON(): object;
- /**
- * Static method to deserialize a JSON representation of an object into an {@link AuthCredential}.
- *
- * @param json - Either `object` or the stringified representation of the object. When string is
- * provided, `JSON.parse` would be called first.
- *
- * @returns If the JSON input does not represent an {@link AuthCredential}, null is returned.
- */
- static fromJSON(json: object | string): EmailAuthCredential | null;
- /** @internal */
- _getIdTokenResponse(auth: AuthInternal): Promise<IdTokenResponse>;
- /** @internal */
- _linkToIdToken(auth: AuthInternal, idToken: string): Promise<IdTokenResponse>;
- /** @internal */
- _getReauthenticationResolver(auth: AuthInternal): Promise<IdTokenResponse>;
- }
- /**
- * Provider for generating {@link EmailAuthCredential}.
- *
- * @public
- */
- export declare class EmailAuthProvider implements AuthProvider {
- /**
- * Always set to {@link ProviderId}.PASSWORD, even for email link.
- */
- static readonly PROVIDER_ID: 'password';
- /**
- * Always set to {@link SignInMethod}.EMAIL_PASSWORD.
- */
- static readonly EMAIL_PASSWORD_SIGN_IN_METHOD: 'password';
- /**
- * Always set to {@link SignInMethod}.EMAIL_LINK.
- */
- static readonly EMAIL_LINK_SIGN_IN_METHOD: 'emailLink';
- /**
- * Always set to {@link ProviderId}.PASSWORD, even for email link.
- */
- readonly providerId: "password";
- /**
- * Initialize an {@link AuthCredential} using an email and password.
- *
- * @example
- * ```javascript
- * const authCredential = EmailAuthProvider.credential(email, password);
- * const userCredential = await signInWithCredential(auth, authCredential);
- * ```
- *
- * @example
- * ```javascript
- * const userCredential = await signInWithEmailAndPassword(auth, email, password);
- * ```
- *
- * @param email - Email address.
- * @param password - User account password.
- * @returns The auth provider credential.
- */
- static credential(email: string, password: string): EmailAuthCredential;
- /**
- * Initialize an {@link AuthCredential} using an email and an email link after a sign in with
- * email link operation.
- *
- * @example
- * ```javascript
- * const authCredential = EmailAuthProvider.credentialWithLink(auth, email, emailLink);
- * const userCredential = await signInWithCredential(auth, authCredential);
- * ```
- *
- * @example
- * ```javascript
- * await sendSignInLinkToEmail(auth, email);
- * // Obtain emailLink from user.
- * const userCredential = await signInWithEmailLink(auth, email, emailLink);
- * ```
- *
- * @param auth - The {@link Auth} instance used to verify the link.
- * @param email - Email address.
- * @param emailLink - Sign-in email link.
- * @returns - The auth provider credential.
- */
- static credentialWithLink(email: string, emailLink: string): EmailAuthCredential;
- }
- /**
- * Configuration of Firebase Authentication Emulator.
- * @public
- */
- export declare interface EmulatorConfig {
- /**
- * The protocol used to communicate with the emulator ("http"/"https").
- */
- readonly protocol: string;
- /**
- * The hostname of the emulator, which may be a domain ("localhost"), IPv4 address ("127.0.0.1")
- * or quoted IPv6 address ("[::1]").
- */
- readonly host: string;
- /**
- * The port of the emulator, or null if port isn't specified (i.e. protocol default).
- */
- readonly port: number | null;
- /**
- * The emulator-specific options.
- */
- readonly options: {
- /**
- * Whether the warning banner attached to the DOM was disabled.
- */
- readonly disableWarnings: boolean;
- };
- }
- export { ErrorFn }
- /**
- * @internal
- */
- declare interface EventManager {
- registerConsumer(authEventConsumer: AuthEventConsumer): void;
- unregisterConsumer(authEventConsumer: AuthEventConsumer): void;
- }
- /**
- * Provider for generating an {@link OAuthCredential} for {@link ProviderId}.FACEBOOK.
- *
- * @example
- * ```javascript
- * // Sign in using a redirect.
- * const provider = new FacebookAuthProvider();
- * // Start a sign in process for an unauthenticated user.
- * provider.addScope('user_birthday');
- * await signInWithRedirect(auth, provider);
- * // This will trigger a full page redirect away from your app
- *
- * // After returning from the redirect when your app initializes you can obtain the result
- * const result = await getRedirectResult(auth);
- * if (result) {
- * // This is the signed-in user
- * const user = result.user;
- * // This gives you a Facebook Access Token.
- * const credential = FacebookAuthProvider.credentialFromResult(result);
- * const token = credential.accessToken;
- * }
- * ```
- *
- * @example
- * ```javascript
- * // Sign in using a popup.
- * const provider = new FacebookAuthProvider();
- * provider.addScope('user_birthday');
- * const result = await signInWithPopup(auth, provider);
- *
- * // The signed-in user info.
- * const user = result.user;
- * // This gives you a Facebook Access Token.
- * const credential = FacebookAuthProvider.credentialFromResult(result);
- * const token = credential.accessToken;
- * ```
- *
- * @public
- */
- export declare class FacebookAuthProvider extends BaseOAuthProvider {
- /** Always set to {@link SignInMethod}.FACEBOOK. */
- static readonly FACEBOOK_SIGN_IN_METHOD: 'facebook.com';
- /** Always set to {@link ProviderId}.FACEBOOK. */
- static readonly PROVIDER_ID: 'facebook.com';
- constructor();
- /**
- * Creates a credential for Facebook.
- *
- * @example
- * ```javascript
- * // `event` from the Facebook auth.authResponseChange callback.
- * const credential = FacebookAuthProvider.credential(event.authResponse.accessToken);
- * const result = await signInWithCredential(credential);
- * ```
- *
- * @param accessToken - Facebook access token.
- */
- static credential(accessToken: string): OAuthCredential;
- /**
- * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
- *
- * @param userCredential - The user credential.
- */
- static credentialFromResult(userCredential: UserCredential): OAuthCredential | null;
- /**
- * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
- * thrown during a sign-in, link, or reauthenticate operation.
- *
- * @param userCredential - The user credential.
- */
- static credentialFromError(error: FirebaseError): OAuthCredential | null;
- private static credentialFromTaggedObject;
- }
- /**
- * An enum of factors that may be used for multifactor authentication.
- *
- * @public
- */
- export declare const FactorId: {
- /** Phone as second factor */
- readonly PHONE: "phone";
- readonly TOTP: "totp";
- };
- /**
- * The base class for all Federated providers (OAuth (including OIDC), SAML).
- *
- * This class is not meant to be instantiated directly.
- *
- * @public
- */
- declare abstract class FederatedAuthProvider implements AuthProvider {
- readonly providerId: string;
- /** @internal */
- defaultLanguageCode: string | null;
- /** @internal */
- private customParameters;
- /**
- * Constructor for generic OAuth providers.
- *
- * @param providerId - Provider for which credentials should be generated.
- */
- constructor(providerId: string);
- /**
- * Set the language gode.
- *
- * @param languageCode - language code
- */
- setDefaultLanguage(languageCode: string | null): void;
- /**
- * Sets the OAuth custom parameters to pass in an OAuth request for popup and redirect sign-in
- * operations.
- *
- * @remarks
- * For a detailed list, check the reserved required OAuth 2.0 parameters such as `client_id`,
- * `redirect_uri`, `scope`, `response_type`, and `state` are not allowed and will be ignored.
- *
- * @param customOAuthParameters - The custom OAuth parameters to pass in the OAuth request.
- */
- setCustomParameters(customOAuthParameters: CustomParameters): AuthProvider;
- /**
- * Retrieve the current list of {@link CustomParameters}.
- */
- getCustomParameters(): CustomParameters;
- }
- /**
- * Gets the list of possible sign in methods for the given email address.
- *
- * @remarks
- * This is useful to differentiate methods of sign-in for the same provider, eg.
- * {@link EmailAuthProvider} which has 2 methods of sign-in,
- * {@link SignInMethod}.EMAIL_PASSWORD and
- * {@link SignInMethod}.EMAIL_LINK.
- *
- * @param auth - The {@link Auth} instance.
- * @param email - The user's email address.
- *
- * @public
- */
- export declare function fetchSignInMethodsForEmail(auth: Auth, email: string): Promise<string[]>;
- declare interface FinalizeMfaResponse {
- idToken: string;
- refreshToken: string;
- }
- /**
- * @internal
- */
- declare type GenericAuthErrorParams = {
- [key in Exclude<AuthErrorCode, AuthErrorCode.ARGUMENT_ERROR | AuthErrorCode.DEPENDENT_SDK_INIT_BEFORE_AUTH | AuthErrorCode.INTERNAL_ERROR | AuthErrorCode.MFA_REQUIRED | AuthErrorCode.NO_AUTH_EVENT | AuthErrorCode.OPERATION_NOT_SUPPORTED>]: {
- appName?: AppName;
- email?: string;
- phoneNumber?: string;
- message?: string;
- };
- };
- /**
- * Extracts provider specific {@link AdditionalUserInfo} for the given credential.
- *
- * @param userCredential - The user credential.
- *
- * @public
- */
- export declare function getAdditionalUserInfo(userCredential: UserCredential): AdditionalUserInfo | null;
- /**
- * Returns the Auth instance associated with the provided {@link @firebase/app#FirebaseApp}.
- * If no instance exists, initializes an Auth instance with platform-specific default dependencies.
- *
- * @param app - The Firebase App.
- *
- * @public
- */
- export declare function getAuth(app?: FirebaseApp): Auth;
- /**
- * Returns a JSON Web Token (JWT) used to identify the user to a Firebase service.
- *
- * @remarks
- * Returns the current token if it has not expired or if it will not expire in the next five
- * minutes. Otherwise, this will refresh the token and return a new one.
- *
- * @param user - The user.
- * @param forceRefresh - Force refresh regardless of token expiration.
- *
- * @public
- */
- export declare function getIdToken(user: User, forceRefresh?: boolean): Promise<string>;
- /**
- * Returns a deserialized JSON Web Token (JWT) used to identify the user to a Firebase service.
- *
- * @remarks
- * Returns the current token if it has not expired or if it will not expire in the next five
- * minutes. Otherwise, this will refresh the token and return a new one.
- *
- * @param user - The user.
- * @param forceRefresh - Force refresh regardless of token expiration.
- *
- * @public
- */
- export declare function getIdTokenResult(user: User, forceRefresh?: boolean): Promise<IdTokenResult>;
- /**
- * Provides a {@link MultiFactorResolver} suitable for completion of a
- * multi-factor flow.
- *
- * @param auth - The {@link Auth} instance.
- * @param error - The {@link MultiFactorError} raised during a sign-in, or
- * reauthentication operation.
- *
- * @public
- */
- export declare function getMultiFactorResolver(auth: Auth, error: MultiFactorError): MultiFactorResolver;
- declare interface GetRecaptchaConfigResponse {
- recaptchaKey: string;
- recaptchaEnforcementState: RecaptchaEnforcementState[];
- }
- /**
- * Returns a {@link UserCredential} from the redirect-based sign-in flow.
- *
- * @remarks
- * If sign-in succeeded, returns the signed in user. If sign-in was unsuccessful, fails with an
- * error. If no redirect operation was called, returns `null`.
- *
- * @example
- * ```javascript
- * // Sign in using a redirect.
- * const provider = new FacebookAuthProvider();
- * // You can add additional scopes to the provider:
- * provider.addScope('user_birthday');
- * // Start a sign in process for an unauthenticated user.
- * await signInWithRedirect(auth, provider);
- * // This will trigger a full page redirect away from your app
- *
- * // After returning from the redirect when your app initializes you can obtain the result
- * const result = await getRedirectResult(auth);
- * if (result) {
- * // This is the signed-in user
- * const user = result.user;
- * // This gives you a Facebook Access Token.
- * const credential = provider.credentialFromResult(auth, result);
- * const token = credential.accessToken;
- * }
- * // As this API can be used for sign-in, linking and reauthentication,
- * // check the operationType to determine what triggered this redirect
- * // operation.
- * const operationType = result.operationType;
- * ```
- *
- * @param auth - The {@link Auth} instance.
- * @param resolver - An instance of {@link PopupRedirectResolver}, optional
- * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
- *
- * @public
- */
- export declare function getRedirectResult(auth: Auth, resolver?: PopupRedirectResolver): Promise<UserCredential | null>;
- /**
- * Provider for generating an {@link OAuthCredential} for {@link ProviderId}.GITHUB.
- *
- * @remarks
- * GitHub requires an OAuth 2.0 redirect, so you can either handle the redirect directly, or use
- * the {@link signInWithPopup} handler:
- *
- * @example
- * ```javascript
- * // Sign in using a redirect.
- * const provider = new GithubAuthProvider();
- * // Start a sign in process for an unauthenticated user.
- * provider.addScope('repo');
- * await signInWithRedirect(auth, provider);
- * // This will trigger a full page redirect away from your app
- *
- * // After returning from the redirect when your app initializes you can obtain the result
- * const result = await getRedirectResult(auth);
- * if (result) {
- * // This is the signed-in user
- * const user = result.user;
- * // This gives you a Github Access Token.
- * const credential = GithubAuthProvider.credentialFromResult(result);
- * const token = credential.accessToken;
- * }
- * ```
- *
- * @example
- * ```javascript
- * // Sign in using a popup.
- * const provider = new GithubAuthProvider();
- * provider.addScope('repo');
- * const result = await signInWithPopup(auth, provider);
- *
- * // The signed-in user info.
- * const user = result.user;
- * // This gives you a Github Access Token.
- * const credential = GithubAuthProvider.credentialFromResult(result);
- * const token = credential.accessToken;
- * ```
- * @public
- */
- export declare class GithubAuthProvider extends BaseOAuthProvider {
- /** Always set to {@link SignInMethod}.GITHUB. */
- static readonly GITHUB_SIGN_IN_METHOD: 'github.com';
- /** Always set to {@link ProviderId}.GITHUB. */
- static readonly PROVIDER_ID: 'github.com';
- constructor();
- /**
- * Creates a credential for Github.
- *
- * @param accessToken - Github access token.
- */
- static credential(accessToken: string): OAuthCredential;
- /**
- * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
- *
- * @param userCredential - The user credential.
- */
- static credentialFromResult(userCredential: UserCredential): OAuthCredential | null;
- /**
- * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
- * thrown during a sign-in, link, or reauthenticate operation.
- *
- * @param userCredential - The user credential.
- */
- static credentialFromError(error: FirebaseError): OAuthCredential | null;
- private static credentialFromTaggedObject;
- }
- /**
- * Provider for generating an an {@link OAuthCredential} for {@link ProviderId}.GOOGLE.
- *
- * @example
- * ```javascript
- * // Sign in using a redirect.
- * const provider = new GoogleAuthProvider();
- * // Start a sign in process for an unauthenticated user.
- * provider.addScope('profile');
- * provider.addScope('email');
- * await signInWithRedirect(auth, provider);
- * // This will trigger a full page redirect away from your app
- *
- * // After returning from the redirect when your app initializes you can obtain the result
- * const result = await getRedirectResult(auth);
- * if (result) {
- * // This is the signed-in user
- * const user = result.user;
- * // This gives you a Google Access Token.
- * const credential = GoogleAuthProvider.credentialFromResult(result);
- * const token = credential.accessToken;
- * }
- * ```
- *
- * @example
- * ```javascript
- * // Sign in using a popup.
- * const provider = new GoogleAuthProvider();
- * provider.addScope('profile');
- * provider.addScope('email');
- * const result = await signInWithPopup(auth, provider);
- *
- * // The signed-in user info.
- * const user = result.user;
- * // This gives you a Google Access Token.
- * const credential = GoogleAuthProvider.credentialFromResult(result);
- * const token = credential.accessToken;
- * ```
- *
- * @public
- */
- export declare class GoogleAuthProvider extends BaseOAuthProvider {
- /** Always set to {@link SignInMethod}.GOOGLE. */
- static readonly GOOGLE_SIGN_IN_METHOD: 'google.com';
- /** Always set to {@link ProviderId}.GOOGLE. */
- static readonly PROVIDER_ID: 'google.com';
- constructor();
- /**
- * Creates a credential for Google. At least one of ID token and access token is required.
- *
- * @example
- * ```javascript
- * // \`googleUser\` from the onsuccess Google Sign In callback.
- * const credential = GoogleAuthProvider.credential(googleUser.getAuthResponse().id_token);
- * const result = await signInWithCredential(credential);
- * ```
- *
- * @param idToken - Google ID token.
- * @param accessToken - Google access token.
- */
- static credential(idToken?: string | null, accessToken?: string | null): OAuthCredential;
- /**
- * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
- *
- * @param userCredential - The user credential.
- */
- static credentialFromResult(userCredential: UserCredential): OAuthCredential | null;
- /**
- * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
- * thrown during a sign-in, link, or reauthenticate operation.
- *
- * @param userCredential - The user credential.
- */
- static credentialFromError(error: FirebaseError): OAuthCredential | null;
- private static credentialFromTaggedObject;
- }
- /**
- * Raw encoded JWT
- *
- */
- declare type IdToken = string;
- /**
- * @internal
- */
- declare interface IdTokenMfaResponse extends IdTokenResponse {
- mfaPendingCredential?: string;
- mfaInfo?: MfaEnrollment[];
- }
- /**
- * IdToken as returned by the API
- *
- * @internal
- */
- declare interface IdTokenResponse {
- localId: string;
- idToken?: IdToken;
- refreshToken?: string;
- expiresIn?: string;
- providerId?: string;
- displayName?: string | null;
- isNewUser?: boolean;
- kind?: IdTokenResponseKind;
- photoUrl?: string | null;
- rawUserInfo?: string;
- screenName?: string | null;
- }
- /**
- * The possible types of the `IdTokenResponse`
- *
- * @internal
- */
- declare const enum IdTokenResponseKind {
- CreateAuthUri = "identitytoolkit#CreateAuthUriResponse",
- DeleteAccount = "identitytoolkit#DeleteAccountResponse",
- DownloadAccount = "identitytoolkit#DownloadAccountResponse",
- EmailLinkSignin = "identitytoolkit#EmailLinkSigninResponse",
- GetAccountInfo = "identitytoolkit#GetAccountInfoResponse",
- GetOobConfirmationCode = "identitytoolkit#GetOobConfirmationCodeResponse",
- GetRecaptchaParam = "identitytoolkit#GetRecaptchaParamResponse",
- ResetPassword = "identitytoolkit#ResetPasswordResponse",
- SetAccountInfo = "identitytoolkit#SetAccountInfoResponse",
- SignupNewUser = "identitytoolkit#SignupNewUserResponse",
- UploadAccount = "identitytoolkit#UploadAccountResponse",
- VerifyAssertion = "identitytoolkit#VerifyAssertionResponse",
- VerifyCustomToken = "identitytoolkit#VerifyCustomTokenResponse",
- VerifyPassword = "identitytoolkit#VerifyPasswordResponse"
- }
- /**
- * Interface representing ID token result obtained from {@link User.getIdTokenResult}.
- *
- * @remarks
- * `IdTokenResult` contains the ID token JWT string and other helper properties for getting different data
- * associated with the token as well as all the decoded payload claims.
- *
- * Note that these claims are not to be trusted as they are parsed client side. Only server side
- * verification can guarantee the integrity of the token claims.
- *
- * @public
- */
- export declare interface IdTokenResult {
- /**
- * The authentication time formatted as a UTC string.
- *
- * @remarks
- * This is the time the user authenticated (signed in) and not the time the token was refreshed.
- */
- authTime: string;
- /** The ID token expiration time formatted as a UTC string. */
- expirationTime: string;
- /** The ID token issuance time formatted as a UTC string. */
- issuedAtTime: string;
- /**
- * The sign-in provider through which the ID token was obtained (anonymous, custom, phone,
- * password, etc).
- *
- * @remarks
- * Note, this does not map to provider IDs.
- */
- signInProvider: string | null;
- /**
- * The type of second factor associated with this session, provided the user was multi-factor
- * authenticated (eg. phone, etc).
- */
- signInSecondFactor: string | null;
- /** The Firebase Auth ID token JWT string. */
- token: string;
- /**
- * The entire payload claims of the ID token including the standard reserved claims as well as
- * the custom claims.
- */
- claims: ParsedToken;
- }
- /**
- * An implementation of {@link Persistence} of type `LOCAL` using `indexedDB`
- * for the underlying storage.
- *
- * @public
- */
- export declare const indexedDBLocalPersistence: Persistence;
- /**
- * Initializes an {@link Auth} instance with fine-grained control over
- * {@link Dependencies}.
- *
- * @remarks
- *
- * This function allows more control over the {@link Auth} instance than
- * {@link getAuth}. `getAuth` uses platform-specific defaults to supply
- * the {@link Dependencies}. In general, `getAuth` is the easiest way to
- * initialize Auth and works for most use cases. Use `initializeAuth` if you
- * need control over which persistence layer is used, or to minimize bundle
- * size if you're not using either `signInWithPopup` or `signInWithRedirect`.
- *
- * For example, if your app only uses anonymous accounts and you only want
- * accounts saved for the current session, initialize `Auth` with:
- *
- * ```js
- * const auth = initializeAuth(app, {
- * persistence: browserSessionPersistence,
- * popupRedirectResolver: undefined,
- * });
- * ```
- *
- * @public
- */
- export declare function initializeAuth(app: FirebaseApp, deps?: Dependencies): Auth;
- /**
- * Loads the reCAPTCHA configuration into the `Auth` instance.
- *
- * @remarks
- * This will load the reCAPTCHA config, which indicates whether the reCAPTCHA
- * verification flow should be triggered for each auth provider, into the
- * current Auth session.
- *
- * If initializeRecaptchaConfig() is not invoked, the auth flow will always start
- * without reCAPTCHA verification. If the provider is configured to require reCAPTCHA
- * verification, the SDK will transparently load the reCAPTCHA config and restart the
- * auth flows.
- *
- * Thus, by calling this optional method, you will reduce the latency of future auth flows.
- * Loading the reCAPTCHA config early will also enhance the signal collected by reCAPTCHA.
- *
- * @example
- * ```javascript
- * initializeRecaptchaConfig(auth);
- * ```
- *
- * @param auth - The {@link Auth} instance.
- *
- * @public
- */
- export declare function initializeRecaptchaConfig(auth: Auth): Promise<void>;
- /**
- * An implementation of {@link Persistence} of type 'NONE'.
- *
- * @public
- */
- export declare const inMemoryPersistence: Persistence;
- /**
- * Checks if an incoming link is a sign-in with email link suitable for {@link signInWithEmailLink}.
- *
- * @param auth - The {@link Auth} instance.
- * @param emailLink - The link sent to the user's email address.
- *
- * @public
- */
- export declare function isSignInWithEmailLink(auth: Auth, emailLink: string): boolean;
- /**
- * Links the user account with the given credentials.
- *
- * @remarks
- * An {@link AuthProvider} can be used to generate the credential.
- *
- * @param user - The user.
- * @param credential - The auth credential.
- *
- * @public
- */
- export declare function linkWithCredential(user: User, credential: AuthCredential): Promise<UserCredential>;
- /**
- * Links the user account with the given phone number.
- *
- * @param user - The user.
- * @param phoneNumber - The user's phone number in E.164 format (e.g. +16505550101).
- * @param appVerifier - The {@link ApplicationVerifier}.
- *
- * @public
- */
- export declare function linkWithPhoneNumber(user: User, phoneNumber: string, appVerifier: ApplicationVerifier): Promise<ConfirmationResult>;
- /**
- * Links the authenticated provider to the user account using a pop-up based OAuth flow.
- *
- * @remarks
- * If the linking is successful, the returned result will contain the user and the provider's credential.
- *
- *
- * @example
- * ```javascript
- * // Sign in using some other provider.
- * const result = await signInWithEmailAndPassword(auth, email, password);
- * // Link using a popup.
- * const provider = new FacebookAuthProvider();
- * await linkWithPopup(result.user, provider);
- * ```
- *
- * @param user - The user.
- * @param provider - The provider to authenticate. The provider has to be an {@link OAuthProvider}.
- * Non-OAuth providers like {@link EmailAuthProvider} will throw an error.
- * @param resolver - An instance of {@link PopupRedirectResolver}, optional
- * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
- *
- * @public
- */
- export declare function linkWithPopup(user: User, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<UserCredential>;
- /**
- * Links the {@link OAuthProvider} to the user account using a full-page redirect flow.
- * @remarks
- * To handle the results and errors for this operation, refer to {@link getRedirectResult}.
- * Follow the {@link https://firebase.google.com/docs/auth/web/redirect-best-practices
- * | best practices} when using {@link linkWithRedirect}.
- *
- * @example
- * ```javascript
- * // Sign in using some other provider.
- * const result = await signInWithEmailAndPassword(auth, email, password);
- * // Link using a redirect.
- * const provider = new FacebookAuthProvider();
- * await linkWithRedirect(result.user, provider);
- * // This will trigger a full page redirect away from your app
- *
- * // After returning from the redirect when your app initializes you can obtain the result
- * const result = await getRedirectResult(auth);
- * ```
- *
- * @param user - The user.
- * @param provider - The provider to authenticate. The provider has to be an {@link OAuthProvider}.
- * Non-OAuth providers like {@link EmailAuthProvider} will throw an error.
- * @param resolver - An instance of {@link PopupRedirectResolver}, optional
- * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
- *
- *
- * @public
- */
- export declare function linkWithRedirect(user: User, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<never>;
- /**
- * MfaEnrollment can be any subtype of BaseMfaEnrollment, currently only PhoneMfaEnrollment and TotpMfaEnrollment are supported.
- */
- declare type MfaEnrollment = PhoneMfaEnrollment | TotpMfaEnrollment;
- /**
- * The {@link MultiFactorUser} corresponding to the user.
- *
- * @remarks
- * This is used to access all multi-factor properties and operations related to the user.
- *
- * @param user - The user.
- *
- * @public
- */
- export declare function multiFactor(user: User): MultiFactorUser;
- /**
- * The base class for asserting ownership of a second factor.
- *
- * @remarks
- * This is used to facilitate enrollment of a second factor on an existing user or sign-in of a
- * user who already verified the first factor.
- *
- * @public
- */
- export declare interface MultiFactorAssertion {
- /** The identifier of the second factor. */
- readonly factorId: (typeof FactorId)[keyof typeof FactorId];
- }
- /**
- * The error thrown when the user needs to provide a second factor to sign in successfully.
- *
- * @remarks
- * The error code for this error is `auth/multi-factor-auth-required`.
- *
- * @example
- * ```javascript
- * let resolver;
- * let multiFactorHints;
- *
- * signInWithEmailAndPassword(auth, email, password)
- * .then((result) => {
- * // User signed in. No 2nd factor challenge is needed.
- * })
- * .catch((error) => {
- * if (error.code == 'auth/multi-factor-auth-required') {
- * resolver = getMultiFactorResolver(auth, error);
- * multiFactorHints = resolver.hints;
- * } else {
- * // Handle other errors.
- * }
- * });
- *
- * // Obtain a multiFactorAssertion by verifying the second factor.
- *
- * const userCredential = await resolver.resolveSignIn(multiFactorAssertion);
- * ```
- *
- * @public
- */
- export declare interface MultiFactorError extends AuthError {
- /** Details about the MultiFactorError. */
- readonly customData: AuthError['customData'] & {
- /**
- * The type of operation (sign-in, linking, or re-authentication) that raised the error.
- */
- readonly operationType: (typeof OperationType)[keyof typeof OperationType];
- };
- }
- /**
- * A structure containing the information of a second factor entity.
- *
- * @public
- */
- export declare interface MultiFactorInfo {
- /** The multi-factor enrollment ID. */
- readonly uid: string;
- /** The user friendly name of the current second factor. */
- readonly displayName?: string | null;
- /** The enrollment date of the second factor formatted as a UTC string. */
- readonly enrollmentTime: string;
- /** The identifier of the second factor. */
- readonly factorId: (typeof FactorId)[keyof typeof FactorId];
- }
- /**
- * The class used to facilitate recovery from {@link MultiFactorError} when a user needs to
- * provide a second factor to sign in.
- *
- * @example
- * ```javascript
- * let resolver;
- * let multiFactorHints;
- *
- * signInWithEmailAndPassword(auth, email, password)
- * .then((result) => {
- * // User signed in. No 2nd factor challenge is needed.
- * })
- * .catch((error) => {
- * if (error.code == 'auth/multi-factor-auth-required') {
- * resolver = getMultiFactorResolver(auth, error);
- * // Show UI to let user select second factor.
- * multiFactorHints = resolver.hints;
- * } else {
- * // Handle other errors.
- * }
- * });
- *
- * // The enrolled second factors that can be used to complete
- * // sign-in are returned in the `MultiFactorResolver.hints` list.
- * // UI needs to be presented to allow the user to select a second factor
- * // from that list.
- *
- * const selectedHint = // ; selected from multiFactorHints
- * const phoneAuthProvider = new PhoneAuthProvider(auth);
- * const phoneInfoOptions = {
- * multiFactorHint: selectedHint,
- * session: resolver.session
- * };
- * const verificationId = phoneAuthProvider.verifyPhoneNumber(phoneInfoOptions, appVerifier);
- * // Store `verificationId` and show UI to let user enter verification code.
- *
- * // UI to enter verification code and continue.
- * // Continue button click handler
- * const phoneAuthCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
- * const multiFactorAssertion = PhoneMultiFactorGenerator.assertion(phoneAuthCredential);
- * const userCredential = await resolver.resolveSignIn(multiFactorAssertion);
- * ```
- *
- * @public
- */
- export declare interface MultiFactorResolver {
- /**
- * The list of hints for the second factors needed to complete the sign-in for the current
- * session.
- */
- readonly hints: MultiFactorInfo[];
- /**
- * The session identifier for the current sign-in flow, which can be used to complete the second
- * factor sign-in.
- */
- readonly session: MultiFactorSession;
- /**
- * A helper function to help users complete sign in with a second factor using an
- * {@link MultiFactorAssertion} confirming the user successfully completed the second factor
- * challenge.
- *
- * @example
- * ```javascript
- * const phoneAuthCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
- * const multiFactorAssertion = PhoneMultiFactorGenerator.assertion(phoneAuthCredential);
- * const userCredential = await resolver.resolveSignIn(multiFactorAssertion);
- * ```
- *
- * @param assertion - The multi-factor assertion to resolve sign-in with.
- * @returns The promise that resolves with the user credential object.
- */
- resolveSignIn(assertion: MultiFactorAssertion): Promise<UserCredential>;
- }
- /**
- * An interface defining the multi-factor session object used for enrolling a second factor on a
- * user or helping sign in an enrolled user with a second factor.
- *
- * @public
- */
- export declare interface MultiFactorSession {
- }
- /**
- * An interface that defines the multi-factor related properties and operations pertaining
- * to a {@link User}.
- *
- * @public
- */
- export declare interface MultiFactorUser {
- /** Returns a list of the user's enrolled second factors. */
- readonly enrolledFactors: MultiFactorInfo[];
- /**
- * Returns the session identifier for a second factor enrollment operation. This is used to
- * identify the user trying to enroll a second factor.
- *
- * @example
- * ```javascript
- * const multiFactorUser = multiFactor(auth.currentUser);
- * const multiFactorSession = await multiFactorUser.getSession();
- *
- * // Send verification code.
- * const phoneAuthProvider = new PhoneAuthProvider(auth);
- * const phoneInfoOptions = {
- * phoneNumber: phoneNumber,
- * session: multiFactorSession
- * };
- * const verificationId = await phoneAuthProvider.verifyPhoneNumber(phoneInfoOptions, appVerifier);
- *
- * // Obtain verification code from user.
- * const phoneAuthCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
- * const multiFactorAssertion = PhoneMultiFactorGenerator.assertion(phoneAuthCredential);
- * await multiFactorUser.enroll(multiFactorAssertion);
- * ```
- *
- * @returns The promise that resolves with the {@link MultiFactorSession}.
- */
- getSession(): Promise<MultiFactorSession>;
- /**
- *
- * Enrolls a second factor as identified by the {@link MultiFactorAssertion} for the
- * user.
- *
- * @remarks
- * On resolution, the user tokens are updated to reflect the change in the JWT payload.
- * Accepts an additional display name parameter used to identify the second factor to the end
- * user. Recent re-authentication is required for this operation to succeed. On successful
- * enrollment, existing Firebase sessions (refresh tokens) are revoked. When a new factor is
- * enrolled, an email notification is sent to the user’s email.
- *
- * @example
- * ```javascript
- * const multiFactorUser = multiFactor(auth.currentUser);
- * const multiFactorSession = await multiFactorUser.getSession();
- *
- * // Send verification code.
- * const phoneAuthProvider = new PhoneAuthProvider(auth);
- * const phoneInfoOptions = {
- * phoneNumber: phoneNumber,
- * session: multiFactorSession
- * };
- * const verificationId = await phoneAuthProvider.verifyPhoneNumber(phoneInfoOptions, appVerifier);
- *
- * // Obtain verification code from user.
- * const phoneAuthCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
- * const multiFactorAssertion = PhoneMultiFactorGenerator.assertion(phoneAuthCredential);
- * await multiFactorUser.enroll(multiFactorAssertion);
- * // Second factor enrolled.
- * ```
- *
- * @param assertion - The multi-factor assertion to enroll with.
- * @param displayName - The display name of the second factor.
- */
- enroll(assertion: MultiFactorAssertion, displayName?: string | null): Promise<void>;
- /**
- * Unenrolls the specified second factor.
- *
- * @remarks
- * To specify the factor to remove, pass a {@link MultiFactorInfo} object (retrieved from
- * {@link MultiFactorUser.enrolledFactors}) or the
- * factor's UID string. Sessions are not revoked when the account is unenrolled. An email
- * notification is likely to be sent to the user notifying them of the change. Recent
- * re-authentication is required for this operation to succeed. When an existing factor is
- * unenrolled, an email notification is sent to the user’s email.
- *
- * @example
- * ```javascript
- * const multiFactorUser = multiFactor(auth.currentUser);
- * // Present user the option to choose which factor to unenroll.
- * await multiFactorUser.unenroll(multiFactorUser.enrolledFactors[i])
- * ```
- *
- * @param option - The multi-factor option to unenroll.
- * @returns - A `Promise` which resolves when the unenroll operation is complete.
- */
- unenroll(option: MultiFactorInfo | string): Promise<void>;
- }
- declare type MutableUserInfo = {
- -readonly [K in keyof UserInfo]: UserInfo[K];
- };
- export { NextFn }
- /**
- * Type definition for an event callback.
- *
- * @privateRemarks TODO(avolkovi): should we consolidate with Subscribe<T> since we're changing the API anyway?
- *
- * @public
- */
- export declare type NextOrObserver<T> = NextFn<T | null> | Observer<T | null>;
- /**
- * Represents the OAuth credentials returned by an {@link OAuthProvider}.
- *
- * @remarks
- * Implementations specify the details about each auth provider's credential requirements.
- *
- * @public
- */
- export declare class OAuthCredential extends AuthCredential {
- /**
- * The OAuth ID token associated with the credential if it belongs to an OIDC provider,
- * such as `google.com`.
- * @readonly
- */
- idToken?: string;
- /**
- * The OAuth access token associated with the credential if it belongs to an
- * {@link OAuthProvider}, such as `facebook.com`, `twitter.com`, etc.
- * @readonly
- */
- accessToken?: string;
- /**
- * The OAuth access token secret associated with the credential if it belongs to an OAuth 1.0
- * provider, such as `twitter.com`.
- * @readonly
- */
- secret?: string;
- private nonce?;
- private pendingToken;
- /** @internal */
- static _fromParams(params: OAuthCredentialParams): OAuthCredential;
- /** {@inheritdoc AuthCredential.toJSON} */
- toJSON(): object;
- /**
- * Static method to deserialize a JSON representation of an object into an
- * {@link AuthCredential}.
- *
- * @param json - Input can be either Object or the stringified representation of the object.
- * When string is provided, JSON.parse would be called first.
- *
- * @returns If the JSON input does not represent an {@link AuthCredential}, null is returned.
- */
- static fromJSON(json: string | object): OAuthCredential | null;
- /** @internal */
- _getIdTokenResponse(auth: AuthInternal): Promise<IdTokenResponse>;
- /** @internal */
- _linkToIdToken(auth: AuthInternal, idToken: string): Promise<IdTokenResponse>;
- /** @internal */
- _getReauthenticationResolver(auth: AuthInternal): Promise<IdTokenResponse>;
- private buildRequest;
- }
- /**
- * Defines the options for initializing an {@link OAuthCredential}.
- *
- * @remarks
- * For ID tokens with nonce claim, the raw nonce has to also be provided.
- *
- * @public
- */
- export declare interface OAuthCredentialOptions {
- /**
- * The OAuth ID token used to initialize the {@link OAuthCredential}.
- */
- idToken?: string;
- /**
- * The OAuth access token used to initialize the {@link OAuthCredential}.
- */
- accessToken?: string;
- /**
- * The raw nonce associated with the ID token.
- *
- * @remarks
- * It is required when an ID token with a nonce field is provided. The SHA-256 hash of the
- * raw nonce must match the nonce field in the ID token.
- */
- rawNonce?: string;
- }
- declare interface OAuthCredentialParams {
- idToken?: string | null;
- accessToken?: string | null;
- oauthToken?: string;
- secret?: string;
- oauthTokenSecret?: string;
- nonce?: string;
- pendingToken?: string;
- providerId: string;
- signInMethod: string;
- }
- /**
- * Provider for generating generic {@link OAuthCredential}.
- *
- * @example
- * ```javascript
- * // Sign in using a redirect.
- * const provider = new OAuthProvider('google.com');
- * // Start a sign in process for an unauthenticated user.
- * provider.addScope('profile');
- * provider.addScope('email');
- * await signInWithRedirect(auth, provider);
- * // This will trigger a full page redirect away from your app
- *
- * // After returning from the redirect when your app initializes you can obtain the result
- * const result = await getRedirectResult(auth);
- * if (result) {
- * // This is the signed-in user
- * const user = result.user;
- * // This gives you a OAuth Access Token for the provider.
- * const credential = provider.credentialFromResult(auth, result);
- * const token = credential.accessToken;
- * }
- * ```
- *
- * @example
- * ```javascript
- * // Sign in using a popup.
- * const provider = new OAuthProvider('google.com');
- * provider.addScope('profile');
- * provider.addScope('email');
- * const result = await signInWithPopup(auth, provider);
- *
- * // The signed-in user info.
- * const user = result.user;
- * // This gives you a OAuth Access Token for the provider.
- * const credential = provider.credentialFromResult(auth, result);
- * const token = credential.accessToken;
- * ```
- * @public
- */
- export declare class OAuthProvider extends BaseOAuthProvider {
- /**
- * Creates an {@link OAuthCredential} from a JSON string or a plain object.
- * @param json - A plain object or a JSON string
- */
- static credentialFromJSON(json: object | string): OAuthCredential;
- /**
- * Creates a {@link OAuthCredential} from a generic OAuth provider's access token or ID token.
- *
- * @remarks
- * The raw nonce is required when an ID token with a nonce field is provided. The SHA-256 hash of
- * the raw nonce must match the nonce field in the ID token.
- *
- * @example
- * ```javascript
- * // `googleUser` from the onsuccess Google Sign In callback.
- * // Initialize a generate OAuth provider with a `google.com` providerId.
- * const provider = new OAuthProvider('google.com');
- * const credential = provider.credential({
- * idToken: googleUser.getAuthResponse().id_token,
- * });
- * const result = await signInWithCredential(credential);
- * ```
- *
- * @param params - Either the options object containing the ID token, access token and raw nonce
- * or the ID token string.
- */
- credential(params: OAuthCredentialOptions): OAuthCredential;
- /** An internal credential method that accepts more permissive options */
- private _credential;
- /**
- * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
- *
- * @param userCredential - The user credential.
- */
- static credentialFromResult(userCredential: UserCredential): OAuthCredential | null;
- /**
- * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
- * thrown during a sign-in, link, or reauthenticate operation.
- *
- * @param userCredential - The user credential.
- */
- static credentialFromError(error: FirebaseError): OAuthCredential | null;
- private static oauthCredentialFromTaggedObject;
- }
- /**
- * Adds an observer for changes to the user's sign-in state.
- *
- * @remarks
- * To keep the old behavior, see {@link onIdTokenChanged}.
- *
- * @param auth - The {@link Auth} instance.
- * @param nextOrObserver - callback triggered on change.
- * @param error - Deprecated. This callback is never triggered. Errors
- * on signing in/out can be caught in promises returned from
- * sign-in/sign-out functions.
- * @param completed - Deprecated. This callback is never triggered.
- *
- * @public
- */
- export declare function onAuthStateChanged(auth: Auth, nextOrObserver: NextOrObserver<User>, error?: ErrorFn, completed?: CompleteFn): Unsubscribe;
- /**
- * Adds an observer for changes to the signed-in user's ID token.
- *
- * @remarks
- * This includes sign-in, sign-out, and token refresh events.
- * This will not be triggered automatically upon ID token expiration. Use {@link User.getIdToken} to refresh the ID token.
- *
- * @param auth - The {@link Auth} instance.
- * @param nextOrObserver - callback triggered on change.
- * @param error - Deprecated. This callback is never triggered. Errors
- * on signing in/out can be caught in promises returned from
- * sign-in/sign-out functions.
- * @param completed - Deprecated. This callback is never triggered.
- *
- * @public
- */
- export declare function onIdTokenChanged(auth: Auth, nextOrObserver: NextOrObserver<User>, error?: ErrorFn, completed?: CompleteFn): Unsubscribe;
- /**
- * Enumeration of supported operation types.
- *
- * @public
- */
- export declare const OperationType: {
- /** Operation involving linking an additional provider to an already signed-in user. */
- readonly LINK: "link";
- /** Operation involving using a provider to reauthenticate an already signed-in user. */
- readonly REAUTHENTICATE: "reauthenticate";
- /** Operation involving signing in a user. */
- readonly SIGN_IN: "signIn";
- };
- /**
- * Parses the email action link string and returns an {@link ActionCodeURL} if
- * the link is valid, otherwise returns null.
- *
- * @public
- */
- export declare function parseActionCodeURL(link: string): ActionCodeURL | null;
- /**
- * Interface representing a parsed ID token.
- *
- * @privateRemarks TODO(avolkovi): consolidate with parsed_token in implementation.
- *
- * @public
- */
- export declare interface ParsedToken {
- /** Expiration time of the token. */
- 'exp'?: string;
- /** UID of the user. */
- 'sub'?: string;
- /** Time at which authentication was performed. */
- 'auth_time'?: string;
- /** Issuance time of the token. */
- 'iat'?: string;
- /** Firebase specific claims, containing the provider(s) used to authenticate the user. */
- 'firebase'?: {
- 'sign_in_provider'?: string;
- 'sign_in_second_factor'?: string;
- 'identities'?: Record<string, string>;
- };
- /** Map of any additional custom claims. */
- [key: string]: any;
- }
- declare type PersistedBlob = Record<string, unknown>;
- /**
- * An interface covering the possible persistence mechanism types.
- *
- * @public
- */
- export declare interface Persistence {
- /**
- * Type of Persistence.
- * - 'SESSION' is used for temporary persistence such as `sessionStorage`.
- * - 'LOCAL' is used for long term persistence such as `localStorage` or `IndexedDB`.
- * - 'NONE' is used for in-memory, or no persistence.
- */
- readonly type: 'SESSION' | 'LOCAL' | 'NONE';
- }
- /**
- * Represents the credentials returned by {@link PhoneAuthProvider}.
- *
- * @public
- */
- export declare class PhoneAuthCredential extends AuthCredential {
- private readonly params;
- private constructor();
- /** @internal */
- static _fromVerification(verificationId: string, verificationCode: string): PhoneAuthCredential;
- /** @internal */
- static _fromTokenResponse(phoneNumber: string, temporaryProof: string): PhoneAuthCredential;
- /** @internal */
- _getIdTokenResponse(auth: AuthInternal): Promise<PhoneOrOauthTokenResponse>;
- /** @internal */
- _linkToIdToken(auth: AuthInternal, idToken: string): Promise<IdTokenResponse>;
- /** @internal */
- _getReauthenticationResolver(auth: AuthInternal): Promise<IdTokenResponse>;
- /** @internal */
- _makeVerificationRequest(): SignInWithPhoneNumberRequest;
- /** {@inheritdoc AuthCredential.toJSON} */
- toJSON(): object;
- /** Generates a phone credential based on a plain object or a JSON string. */
- static fromJSON(json: object | string): PhoneAuthCredential | null;
- }
- /**
- * Provider for generating an {@link PhoneAuthCredential}.
- *
- * @example
- * ```javascript
- * // 'recaptcha-container' is the ID of an element in the DOM.
- * const applicationVerifier = new RecaptchaVerifier('recaptcha-container');
- * const provider = new PhoneAuthProvider(auth);
- * const verificationId = await provider.verifyPhoneNumber('+16505550101', applicationVerifier);
- * // Obtain the verificationCode from the user.
- * const phoneCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
- * const userCredential = await signInWithCredential(auth, phoneCredential);
- * ```
- *
- * @public
- */
- export declare class PhoneAuthProvider {
- /** Always set to {@link ProviderId}.PHONE. */
- static readonly PROVIDER_ID: 'phone';
- /** Always set to {@link SignInMethod}.PHONE. */
- static readonly PHONE_SIGN_IN_METHOD: 'phone';
- /** Always set to {@link ProviderId}.PHONE. */
- readonly providerId: "phone";
- private readonly auth;
- /**
- * @param auth - The Firebase {@link Auth} instance in which sign-ins should occur.
- *
- */
- constructor(auth: Auth);
- /**
- *
- * Starts a phone number authentication flow by sending a verification code to the given phone
- * number.
- *
- * @example
- * ```javascript
- * const provider = new PhoneAuthProvider(auth);
- * const verificationId = await provider.verifyPhoneNumber(phoneNumber, applicationVerifier);
- * // Obtain verificationCode from the user.
- * const authCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
- * const userCredential = await signInWithCredential(auth, authCredential);
- * ```
- *
- * @example
- * An alternative flow is provided using the `signInWithPhoneNumber` method.
- * ```javascript
- * const confirmationResult = signInWithPhoneNumber(auth, phoneNumber, applicationVerifier);
- * // Obtain verificationCode from the user.
- * const userCredential = confirmationResult.confirm(verificationCode);
- * ```
- *
- * @param phoneInfoOptions - The user's {@link PhoneInfoOptions}. The phone number should be in
- * E.164 format (e.g. +16505550101).
- * @param applicationVerifier - For abuse prevention, this method also requires a
- * {@link ApplicationVerifier}. This SDK includes a reCAPTCHA-based implementation,
- * {@link RecaptchaVerifier}.
- *
- * @returns A Promise for a verification ID that can be passed to
- * {@link PhoneAuthProvider.credential} to identify this flow..
- */
- verifyPhoneNumber(phoneOptions: PhoneInfoOptions | string, applicationVerifier: ApplicationVerifier): Promise<string>;
- /**
- * Creates a phone auth credential, given the verification ID from
- * {@link PhoneAuthProvider.verifyPhoneNumber} and the code that was sent to the user's
- * mobile device.
- *
- * @example
- * ```javascript
- * const provider = new PhoneAuthProvider(auth);
- * const verificationId = provider.verifyPhoneNumber(phoneNumber, applicationVerifier);
- * // Obtain verificationCode from the user.
- * const authCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
- * const userCredential = signInWithCredential(auth, authCredential);
- * ```
- *
- * @example
- * An alternative flow is provided using the `signInWithPhoneNumber` method.
- * ```javascript
- * const confirmationResult = await signInWithPhoneNumber(auth, phoneNumber, applicationVerifier);
- * // Obtain verificationCode from the user.
- * const userCredential = await confirmationResult.confirm(verificationCode);
- * ```
- *
- * @param verificationId - The verification ID returned from {@link PhoneAuthProvider.verifyPhoneNumber}.
- * @param verificationCode - The verification code sent to the user's mobile device.
- *
- * @returns The auth provider credential.
- */
- static credential(verificationId: string, verificationCode: string): PhoneAuthCredential;
- /**
- * Generates an {@link AuthCredential} from a {@link UserCredential}.
- * @param userCredential - The user credential.
- */
- static credentialFromResult(userCredential: UserCredential): AuthCredential | null;
- /**
- * Returns an {@link AuthCredential} when passed an error.
- *
- * @remarks
- *
- * This method works for errors like
- * `auth/account-exists-with-different-credentials`. This is useful for
- * recovering when attempting to set a user's phone number but the number
- * in question is already tied to another account. For example, the following
- * code tries to update the current user's phone number, and if that
- * fails, links the user with the account associated with that number:
- *
- * ```js
- * const provider = new PhoneAuthProvider(auth);
- * const verificationId = await provider.verifyPhoneNumber(number, verifier);
- * try {
- * const code = ''; // Prompt the user for the verification code
- * await updatePhoneNumber(
- * auth.currentUser,
- * PhoneAuthProvider.credential(verificationId, code));
- * } catch (e) {
- * if ((e as FirebaseError)?.code === 'auth/account-exists-with-different-credential') {
- * const cred = PhoneAuthProvider.credentialFromError(e);
- * await linkWithCredential(auth.currentUser, cred);
- * }
- * }
- *
- * // At this point, auth.currentUser.phoneNumber === number.
- * ```
- *
- * @param error - The error to generate a credential from.
- */
- static credentialFromError(error: FirebaseError): AuthCredential | null;
- private static credentialFromTaggedObject;
- }
- /**
- * The information required to verify the ownership of a phone number.
- *
- * @remarks
- * The information that's required depends on whether you are doing single-factor sign-in,
- * multi-factor enrollment or multi-factor sign-in.
- *
- * @public
- */
- export declare type PhoneInfoOptions = PhoneSingleFactorInfoOptions | PhoneMultiFactorEnrollInfoOptions | PhoneMultiFactorSignInInfoOptions;
- /**
- * An MFA provided by SMS verification.
- */
- declare interface PhoneMfaEnrollment extends BaseMfaEnrollment {
- phoneInfo: string;
- }
- /**
- * The class for asserting ownership of a phone second factor. Provided by
- * {@link PhoneMultiFactorGenerator.assertion}.
- *
- * @public
- */
- export declare interface PhoneMultiFactorAssertion extends MultiFactorAssertion {
- }
- /**
- * Options used for enrolling a second factor.
- *
- * @public
- */
- export declare interface PhoneMultiFactorEnrollInfoOptions {
- /** Phone number to send a verification code to. */
- phoneNumber: string;
- /** The {@link MultiFactorSession} obtained via {@link MultiFactorUser.getSession}. */
- session: MultiFactorSession;
- }
- /**
- * Provider for generating a {@link PhoneMultiFactorAssertion}.
- *
- * @public
- */
- export declare class PhoneMultiFactorGenerator {
- private constructor();
- /**
- * Provides a {@link PhoneMultiFactorAssertion} to confirm ownership of the phone second factor.
- *
- * @param phoneAuthCredential - A credential provided by {@link PhoneAuthProvider.credential}.
- * @returns A {@link PhoneMultiFactorAssertion} which can be used with
- * {@link MultiFactorResolver.resolveSignIn}
- */
- static assertion(credential: PhoneAuthCredential): PhoneMultiFactorAssertion;
- /**
- * The identifier of the phone second factor: `phone`.
- */
- static FACTOR_ID: string;
- }
- /**
- * The subclass of the {@link MultiFactorInfo} interface for phone number
- * second factors. The `factorId` of this second factor is {@link FactorId}.PHONE.
- * @public
- */
- export declare interface PhoneMultiFactorInfo extends MultiFactorInfo {
- /** The phone number associated with the current second factor. */
- readonly phoneNumber: string;
- }
- /**
- * Options used for signing in with a second factor.
- *
- * @public
- */
- export declare interface PhoneMultiFactorSignInInfoOptions {
- /**
- * The {@link MultiFactorInfo} obtained via {@link MultiFactorResolver.hints}.
- *
- * One of `multiFactorHint` or `multiFactorUid` is required.
- */
- multiFactorHint?: MultiFactorInfo;
- /**
- * The uid of the second factor.
- *
- * One of `multiFactorHint` or `multiFactorUid` is required.
- */
- multiFactorUid?: string;
- /** The {@link MultiFactorSession} obtained via {@link MultiFactorResolver.session}. */
- session: MultiFactorSession;
- }
- /**
- * @internal
- */
- declare type PhoneOrOauthTokenResponse = SignInWithPhoneNumberResponse | SignInWithIdpResponse | IdTokenResponse;
- /**
- * Options used for single-factor sign-in.
- *
- * @public
- */
- export declare interface PhoneSingleFactorInfoOptions {
- /** Phone number to send a verification code to. */
- phoneNumber: string;
- }
- /**
- * A resolver used for handling DOM specific operations like {@link signInWithPopup}
- * or {@link signInWithRedirect}.
- *
- * @public
- */
- export declare interface PopupRedirectResolver {
- }
- /**
- * We need to mark this interface as internal explicitly to exclude it in the public typings, because
- * it references AuthInternal which has a circular dependency with UserInternal.
- *
- * @internal
- */
- declare interface PopupRedirectResolverInternal extends PopupRedirectResolver {
- _shouldInitProactively: boolean;
- _initialize(auth: AuthInternal): Promise<EventManager>;
- _openPopup(auth: AuthInternal, provider: AuthProvider, authType: AuthEventType, eventId?: string): Promise<AuthPopup>;
- _openRedirect(auth: AuthInternal, provider: AuthProvider, authType: AuthEventType, eventId?: string): Promise<void | never>;
- _isIframeWebStorageSupported(auth: AuthInternal, cb: (support: boolean) => unknown): void;
- _redirectPersistence: Persistence;
- _originValidation(auth: Auth): Promise<void>;
- _completeRedirectFn: (auth: Auth, resolver: PopupRedirectResolver, bypassAuthState: boolean) => Promise<UserCredential | null>;
- _overrideRedirectResult: (auth: AuthInternal, resultGetter: () => Promise<UserCredentialInternal | null>) => void;
- }
- /**
- * A minimal error map with all verbose error messages stripped.
- *
- * See discussion at {@link AuthErrorMap}
- *
- * @public
- */
- export declare const prodErrorMap: AuthErrorMap;
- /**
- * Enumeration of supported providers.
- *
- * @public
- */
- export declare const ProviderId: {
- /** Facebook provider ID */
- readonly FACEBOOK: "facebook.com";
- /** GitHub provider ID */
- readonly GITHUB: "github.com";
- /** Google provider ID */
- readonly GOOGLE: "google.com";
- /** Password provider */
- readonly PASSWORD: "password";
- /** Phone provider */
- readonly PHONE: "phone";
- /** Twitter provider ID */
- readonly TWITTER: "twitter.com";
- };
- /**
- * @license
- * Copyright 2021 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- /**
- * Enumeration of supported providers.
- * @internal
- */
- declare const enum ProviderId_2 {
- /** @internal */
- ANONYMOUS = "anonymous",
- /** @internal */
- CUSTOM = "custom",
- /** Facebook provider ID */
- FACEBOOK = "facebook.com",
- /** @internal */
- FIREBASE = "firebase",
- /** GitHub provider ID */
- GITHUB = "github.com",
- /** Google provider ID */
- GOOGLE = "google.com",
- /** Password provider */
- PASSWORD = "password",
- /** Phone provider */
- PHONE = "phone",
- /** Twitter provider ID */
- TWITTER = "twitter.com"
- }
- declare interface ProviderUserInfo {
- providerId: string;
- rawId?: string;
- email?: string;
- displayName?: string;
- photoUrl?: string;
- phoneNumber?: string;
- }
- /**
- * Interface for a supplied `AsyncStorage`.
- *
- * @public
- */
- export declare interface ReactNativeAsyncStorage {
- /**
- * Persist an item in storage.
- *
- * @param key - storage key.
- * @param value - storage value.
- */
- setItem(key: string, value: string): Promise<void>;
- /**
- * Retrieve an item from storage.
- *
- * @param key - storage key.
- */
- getItem(key: string): Promise<string | null>;
- /**
- * Remove an item from storage.
- *
- * @param key - storage key.
- */
- removeItem(key: string): Promise<void>;
- }
- /**
- * Re-authenticates a user using a fresh credential.
- *
- * @remarks
- * Use before operations such as {@link updatePassword} that require tokens from recent sign-in
- * attempts. This method can be used to recover from a `CREDENTIAL_TOO_OLD_LOGIN_AGAIN` error
- * or a `TOKEN_EXPIRED` error.
- *
- * @param user - The user.
- * @param credential - The auth credential.
- *
- * @public
- */
- export declare function reauthenticateWithCredential(user: User, credential: AuthCredential): Promise<UserCredential>;
- /**
- * Re-authenticates a user using a fresh phone credential.
- *
- * @remarks Use before operations such as {@link updatePassword} that require tokens from recent sign-in attempts.
- *
- * @param user - The user.
- * @param phoneNumber - The user's phone number in E.164 format (e.g. +16505550101).
- * @param appVerifier - The {@link ApplicationVerifier}.
- *
- * @public
- */
- export declare function reauthenticateWithPhoneNumber(user: User, phoneNumber: string, appVerifier: ApplicationVerifier): Promise<ConfirmationResult>;
- /**
- * Reauthenticates the current user with the specified {@link OAuthProvider} using a pop-up based
- * OAuth flow.
- *
- * @remarks
- * If the reauthentication is successful, the returned result will contain the user and the
- * provider's credential.
- *
- * @example
- * ```javascript
- * // Sign in using a popup.
- * const provider = new FacebookAuthProvider();
- * const result = await signInWithPopup(auth, provider);
- * // Reauthenticate using a popup.
- * await reauthenticateWithPopup(result.user, provider);
- * ```
- *
- * @param user - The user.
- * @param provider - The provider to authenticate. The provider has to be an {@link OAuthProvider}.
- * Non-OAuth providers like {@link EmailAuthProvider} will throw an error.
- * @param resolver - An instance of {@link PopupRedirectResolver}, optional
- * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
- *
- * @public
- */
- export declare function reauthenticateWithPopup(user: User, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<UserCredential>;
- /**
- * Reauthenticates the current user with the specified {@link OAuthProvider} using a full-page redirect flow.
- * @remarks
- * To handle the results and errors for this operation, refer to {@link getRedirectResult}.
- * Follow the {@link https://firebase.google.com/docs/auth/web/redirect-best-practices
- * | best practices} when using {@link reauthenticateWithRedirect}.
- *
- * @example
- * ```javascript
- * // Sign in using a redirect.
- * const provider = new FacebookAuthProvider();
- * const result = await signInWithRedirect(auth, provider);
- * // This will trigger a full page redirect away from your app
- *
- * // After returning from the redirect when your app initializes you can obtain the result
- * const result = await getRedirectResult(auth);
- * // Reauthenticate using a redirect.
- * await reauthenticateWithRedirect(result.user, provider);
- * // This will again trigger a full page redirect away from your app
- *
- * // After returning from the redirect when your app initializes you can obtain the result
- * const result = await getRedirectResult(auth);
- * ```
- *
- * @param user - The user.
- * @param provider - The provider to authenticate. The provider has to be an {@link OAuthProvider}.
- * Non-OAuth providers like {@link EmailAuthProvider} will throw an error.
- * @param resolver - An instance of {@link PopupRedirectResolver}, optional
- * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
- *
- * @public
- */
- export declare function reauthenticateWithRedirect(user: User, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<never>;
- declare interface Recaptcha {
- render: (container: HTMLElement, parameters: RecaptchaParameters) => number;
- getResponse: (id: number) => string;
- execute: (id: number) => unknown;
- reset: (id: number) => unknown;
- }
- declare class RecaptchaConfig {
- /**
- * The reCAPTCHA site key.
- */
- siteKey: string;
- /**
- * The reCAPTCHA enablement status of the {@link EmailAuthProvider} for the current tenant.
- */
- emailPasswordEnabled: boolean;
- constructor(response: GetRecaptchaConfigResponse);
- }
- declare interface RecaptchaEnforcementState {
- provider: string;
- enforcementState: string;
- }
- /**
- * We need to mark this interface as internal explicitly to exclude it in the public typings, because
- * it references AuthInternal which has a circular dependency with UserInternal.
- *
- * @internal
- */
- declare interface ReCaptchaLoader {
- load(auth: AuthInternal, hl?: string): Promise<Recaptcha>;
- clearedOneInstance(): void;
- }
- /**
- * Interface representing reCAPTCHA parameters.
- *
- * See the [reCAPTCHA docs](https://developers.google.com/recaptcha/docs/display#render_param)
- * for the list of accepted parameters. All parameters are accepted except for `sitekey`: Firebase Auth
- * provisions a reCAPTCHA for each project and will configure the site key upon rendering.
- *
- * For an invisible reCAPTCHA, set the `size` key to `invisible`.
- *
- * @public
- */
- export declare interface RecaptchaParameters {
- [key: string]: any;
- }
- /**
- * An {@link https://www.google.com/recaptcha/ | reCAPTCHA}-based application verifier.
- *
- * @public
- */
- export declare class RecaptchaVerifier implements ApplicationVerifierInternal {
- private readonly parameters;
- /**
- * The application verifier type.
- *
- * @remarks
- * For a reCAPTCHA verifier, this is 'recaptcha'.
- */
- readonly type = "recaptcha";
- private destroyed;
- private widgetId;
- private readonly container;
- private readonly isInvisible;
- private readonly tokenChangeListeners;
- private renderPromise;
- private readonly auth;
- /** @internal */
- readonly _recaptchaLoader: ReCaptchaLoader;
- private recaptcha;
- /**
- *
- * @param containerOrId - The reCAPTCHA container parameter.
- *
- * @remarks
- * This has different meaning depending on whether the reCAPTCHA is hidden or visible. For a
- * visible reCAPTCHA the container must be empty. If a string is used, it has to correspond to
- * an element ID. The corresponding element must also must be in the DOM at the time of
- * initialization.
- *
- * @param parameters - The optional reCAPTCHA parameters.
- *
- * @remarks
- * Check the reCAPTCHA docs for a comprehensive list. All parameters are accepted except for
- * the sitekey. Firebase Auth backend provisions a reCAPTCHA for each project and will
- * configure this upon rendering. For an invisible reCAPTCHA, a size key must have the value
- * 'invisible'.
- *
- * @param authExtern - The corresponding Firebase {@link Auth} instance.
- */
- constructor(containerOrId: HTMLElement | string, parameters: RecaptchaParameters, authExtern: Auth);
- /**
- * Waits for the user to solve the reCAPTCHA and resolves with the reCAPTCHA token.
- *
- * @returns A Promise for the reCAPTCHA token.
- */
- verify(): Promise<string>;
- /**
- * Renders the reCAPTCHA widget on the page.
- *
- * @returns A Promise that resolves with the reCAPTCHA widget ID.
- */
- render(): Promise<number>;
- /** @internal */
- _reset(): void;
- /**
- * Clears the reCAPTCHA widget from the page and destroys the instance.
- */
- clear(): void;
- private validateStartingState;
- private makeTokenCallback;
- private assertNotDestroyed;
- private makeRenderPromise;
- private init;
- private getAssertedRecaptcha;
- }
- /**
- * Reloads user account data, if signed in.
- *
- * @param user - The user.
- *
- * @public
- */
- export declare function reload(user: User): Promise<void>;
- /**
- * An {@link AuthProvider} for SAML.
- *
- * @public
- */
- export declare class SAMLAuthProvider extends FederatedAuthProvider {
- /**
- * Constructor. The providerId must start with "saml."
- * @param providerId - SAML provider ID.
- */
- constructor(providerId: string);
- /**
- * Generates an {@link AuthCredential} from a {@link UserCredential} after a
- * successful SAML flow completes.
- *
- * @remarks
- *
- * For example, to get an {@link AuthCredential}, you could write the
- * following code:
- *
- * ```js
- * const userCredential = await signInWithPopup(auth, samlProvider);
- * const credential = SAMLAuthProvider.credentialFromResult(userCredential);
- * ```
- *
- * @param userCredential - The user credential.
- */
- static credentialFromResult(userCredential: UserCredential): AuthCredential | null;
- /**
- * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
- * thrown during a sign-in, link, or reauthenticate operation.
- *
- * @param userCredential - The user credential.
- */
- static credentialFromError(error: FirebaseError): AuthCredential | null;
- /**
- * Creates an {@link AuthCredential} from a JSON string or a plain object.
- * @param json - A plain object or a JSON string
- */
- static credentialFromJSON(json: string | object): AuthCredential;
- private static samlCredentialFromTaggedObject;
- }
- /**
- * Sends a verification email to a user.
- *
- * @remarks
- * The verification process is completed by calling {@link applyActionCode}.
- *
- * @example
- * ```javascript
- * const actionCodeSettings = {
- * url: 'https://www.example.com/?email=user@example.com',
- * iOS: {
- * bundleId: 'com.example.ios'
- * },
- * android: {
- * packageName: 'com.example.android',
- * installApp: true,
- * minimumVersion: '12'
- * },
- * handleCodeInApp: true
- * };
- * await sendEmailVerification(user, actionCodeSettings);
- * // Obtain code from the user.
- * await applyActionCode(auth, code);
- * ```
- *
- * @param user - The user.
- * @param actionCodeSettings - The {@link ActionCodeSettings}.
- *
- * @public
- */
- export declare function sendEmailVerification(user: User, actionCodeSettings?: ActionCodeSettings | null): Promise<void>;
- /**
- * Sends a password reset email to the given email address.
- *
- * @remarks
- * To complete the password reset, call {@link confirmPasswordReset} with the code supplied in
- * the email sent to the user, along with the new password specified by the user.
- *
- * @example
- * ```javascript
- * const actionCodeSettings = {
- * url: 'https://www.example.com/?email=user@example.com',
- * iOS: {
- * bundleId: 'com.example.ios'
- * },
- * android: {
- * packageName: 'com.example.android',
- * installApp: true,
- * minimumVersion: '12'
- * },
- * handleCodeInApp: true
- * };
- * await sendPasswordResetEmail(auth, 'user@example.com', actionCodeSettings);
- * // Obtain code from user.
- * await confirmPasswordReset('user@example.com', code);
- * ```
- *
- * @param auth - The {@link Auth} instance.
- * @param email - The user's email address.
- * @param actionCodeSettings - The {@link ActionCodeSettings}.
- *
- * @public
- */
- export declare function sendPasswordResetEmail(auth: Auth, email: string, actionCodeSettings?: ActionCodeSettings): Promise<void>;
- /**
- * Sends a sign-in email link to the user with the specified email.
- *
- * @remarks
- * The sign-in operation has to always be completed in the app unlike other out of band email
- * actions (password reset and email verifications). This is because, at the end of the flow,
- * the user is expected to be signed in and their Auth state persisted within the app.
- *
- * To complete sign in with the email link, call {@link signInWithEmailLink} with the email
- * address and the email link supplied in the email sent to the user.
- *
- * @example
- * ```javascript
- * const actionCodeSettings = {
- * url: 'https://www.example.com/?email=user@example.com',
- * iOS: {
- * bundleId: 'com.example.ios'
- * },
- * android: {
- * packageName: 'com.example.android',
- * installApp: true,
- * minimumVersion: '12'
- * },
- * handleCodeInApp: true
- * };
- * await sendSignInLinkToEmail(auth, 'user@example.com', actionCodeSettings);
- * // Obtain emailLink from the user.
- * if(isSignInWithEmailLink(auth, emailLink)) {
- * await signInWithEmailLink(auth, 'user@example.com', emailLink);
- * }
- * ```
- *
- * @param authInternal - The {@link Auth} instance.
- * @param email - The user's email address.
- * @param actionCodeSettings - The {@link ActionCodeSettings}.
- *
- * @public
- */
- export declare function sendSignInLinkToEmail(auth: Auth, email: string, actionCodeSettings: ActionCodeSettings): Promise<void>;
- /**
- * Changes the type of persistence on the {@link Auth} instance for the currently saved
- * `Auth` session and applies this type of persistence for future sign-in requests, including
- * sign-in with redirect requests.
- *
- * @remarks
- * This makes it easy for a user signing in to specify whether their session should be
- * remembered or not. It also makes it easier to never persist the `Auth` state for applications
- * that are shared by other users or have sensitive data.
- *
- * @example
- * ```javascript
- * setPersistence(auth, browserSessionPersistence);
- * ```
- *
- * @param auth - The {@link Auth} instance.
- * @param persistence - The {@link Persistence} to use.
- * @returns A `Promise` that resolves once the persistence change has completed
- *
- * @public
- */
- export declare function setPersistence(auth: Auth, persistence: Persistence): Promise<void>;
- /**
- * Asynchronously signs in as an anonymous user.
- *
- * @remarks
- * If there is already an anonymous user signed in, that user will be returned; otherwise, a
- * new anonymous user identity will be created and returned.
- *
- * @param auth - The {@link Auth} instance.
- *
- * @public
- */
- export declare function signInAnonymously(auth: Auth): Promise<UserCredential>;
- /**
- * Enumeration of supported sign-in methods.
- *
- * @public
- */
- export declare const SignInMethod: {
- /** Email link sign in method */
- readonly EMAIL_LINK: "emailLink";
- /** Email/password sign in method */
- readonly EMAIL_PASSWORD: "password";
- /** Facebook sign in method */
- readonly FACEBOOK: "facebook.com";
- /** GitHub sign in method */
- readonly GITHUB: "github.com";
- /** Google sign in method */
- readonly GOOGLE: "google.com";
- /** Phone sign in method */
- readonly PHONE: "phone";
- /** Twitter sign in method */
- readonly TWITTER: "twitter.com";
- };
- /**
- * Asynchronously signs in with the given credentials.
- *
- * @remarks
- * An {@link AuthProvider} can be used to generate the credential.
- *
- * @param auth - The {@link Auth} instance.
- * @param credential - The auth credential.
- *
- * @public
- */
- export declare function signInWithCredential(auth: Auth, credential: AuthCredential): Promise<UserCredential>;
- /**
- * Asynchronously signs in using a custom token.
- *
- * @remarks
- * Custom tokens are used to integrate Firebase Auth with existing auth systems, and must
- * be generated by an auth backend using the
- * {@link https://firebase.google.com/docs/reference/admin/node/admin.auth.Auth#createcustomtoken | createCustomToken}
- * method in the {@link https://firebase.google.com/docs/auth/admin | Admin SDK} .
- *
- * Fails with an error if the token is invalid, expired, or not accepted by the Firebase Auth service.
- *
- * @param auth - The {@link Auth} instance.
- * @param customToken - The custom token to sign in with.
- *
- * @public
- */
- export declare function signInWithCustomToken(auth: Auth, customToken: string): Promise<UserCredential>;
- /**
- * Asynchronously signs in using an email and password.
- *
- * @remarks
- * Fails with an error if the email address and password do not match.
- *
- * Note: The user's password is NOT the password used to access the user's email account. The
- * email address serves as a unique identifier for the user, and the password is used to access
- * the user's account in your Firebase project. See also: {@link createUserWithEmailAndPassword}.
- *
- * @param auth - The {@link Auth} instance.
- * @param email - The users email address.
- * @param password - The users password.
- *
- * @public
- */
- export declare function signInWithEmailAndPassword(auth: Auth, email: string, password: string): Promise<UserCredential>;
- /**
- * Asynchronously signs in using an email and sign-in email link.
- *
- * @remarks
- * If no link is passed, the link is inferred from the current URL.
- *
- * Fails with an error if the email address is invalid or OTP in email link expires.
- *
- * Note: Confirm the link is a sign-in email link before calling this method firebase.auth.Auth.isSignInWithEmailLink.
- *
- * @example
- * ```javascript
- * const actionCodeSettings = {
- * url: 'https://www.example.com/?email=user@example.com',
- * iOS: {
- * bundleId: 'com.example.ios'
- * },
- * android: {
- * packageName: 'com.example.android',
- * installApp: true,
- * minimumVersion: '12'
- * },
- * handleCodeInApp: true
- * };
- * await sendSignInLinkToEmail(auth, 'user@example.com', actionCodeSettings);
- * // Obtain emailLink from the user.
- * if(isSignInWithEmailLink(auth, emailLink)) {
- * await signInWithEmailLink(auth, 'user@example.com', emailLink);
- * }
- * ```
- *
- * @param auth - The {@link Auth} instance.
- * @param email - The user's email address.
- * @param emailLink - The link sent to the user's email address.
- *
- * @public
- */
- export declare function signInWithEmailLink(auth: Auth, email: string, emailLink?: string): Promise<UserCredential>;
- /**
- * @internal
- */
- declare interface SignInWithIdpResponse extends IdTokenResponse {
- oauthAccessToken?: string;
- oauthTokenSecret?: string;
- nonce?: string;
- oauthIdToken?: string;
- pendingToken?: string;
- }
- /**
- * Asynchronously signs in using a phone number.
- *
- * @remarks
- * This method sends a code via SMS to the given
- * phone number, and returns a {@link ConfirmationResult}. After the user
- * provides the code sent to their phone, call {@link ConfirmationResult.confirm}
- * with the code to sign the user in.
- *
- * For abuse prevention, this method also requires a {@link ApplicationVerifier}.
- * This SDK includes a reCAPTCHA-based implementation, {@link RecaptchaVerifier}.
- * This function can work on other platforms that do not support the
- * {@link RecaptchaVerifier} (like React Native), but you need to use a
- * third-party {@link ApplicationVerifier} implementation.
- *
- * @example
- * ```javascript
- * // 'recaptcha-container' is the ID of an element in the DOM.
- * const applicationVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container');
- * const confirmationResult = await signInWithPhoneNumber(auth, phoneNumber, applicationVerifier);
- * // Obtain a verificationCode from the user.
- * const credential = await confirmationResult.confirm(verificationCode);
- * ```
- *
- * @param auth - The {@link Auth} instance.
- * @param phoneNumber - The user's phone number in E.164 format (e.g. +16505550101).
- * @param appVerifier - The {@link ApplicationVerifier}.
- *
- * @public
- */
- export declare function signInWithPhoneNumber(auth: Auth, phoneNumber: string, appVerifier: ApplicationVerifier): Promise<ConfirmationResult>;
- /**
- * @internal
- */
- declare interface SignInWithPhoneNumberRequest {
- temporaryProof?: string;
- phoneNumber?: string;
- sessionInfo?: string;
- code?: string;
- tenantId?: string;
- }
- /**
- * @internal
- */
- declare interface SignInWithPhoneNumberResponse extends IdTokenResponse {
- temporaryProof?: string;
- phoneNumber?: string;
- }
- /**
- * Authenticates a Firebase client using a popup-based OAuth authentication flow.
- *
- * @remarks
- * If succeeds, returns the signed in user along with the provider's credential. If sign in was
- * unsuccessful, returns an error object containing additional information about the error.
- *
- * @example
- * ```javascript
- * // Sign in using a popup.
- * const provider = new FacebookAuthProvider();
- * const result = await signInWithPopup(auth, provider);
- *
- * // The signed-in user info.
- * const user = result.user;
- * // This gives you a Facebook Access Token.
- * const credential = provider.credentialFromResult(auth, result);
- * const token = credential.accessToken;
- * ```
- *
- * @param auth - The {@link Auth} instance.
- * @param provider - The provider to authenticate. The provider has to be an {@link OAuthProvider}.
- * Non-OAuth providers like {@link EmailAuthProvider} will throw an error.
- * @param resolver - An instance of {@link PopupRedirectResolver}, optional
- * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
- *
- *
- * @public
- */
- export declare function signInWithPopup(auth: Auth, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<UserCredential>;
- /**
- * Authenticates a Firebase client using a full-page redirect flow.
- *
- * @remarks
- * To handle the results and errors for this operation, refer to {@link getRedirectResult}.
- * Follow the {@link https://firebase.google.com/docs/auth/web/redirect-best-practices
- * | best practices} when using {@link signInWithRedirect}.
- *
- * @example
- * ```javascript
- * // Sign in using a redirect.
- * const provider = new FacebookAuthProvider();
- * // You can add additional scopes to the provider:
- * provider.addScope('user_birthday');
- * // Start a sign in process for an unauthenticated user.
- * await signInWithRedirect(auth, provider);
- * // This will trigger a full page redirect away from your app
- *
- * // After returning from the redirect when your app initializes you can obtain the result
- * const result = await getRedirectResult(auth);
- * if (result) {
- * // This is the signed-in user
- * const user = result.user;
- * // This gives you a Facebook Access Token.
- * const credential = provider.credentialFromResult(auth, result);
- * const token = credential.accessToken;
- * }
- * // As this API can be used for sign-in, linking and reauthentication,
- * // check the operationType to determine what triggered this redirect
- * // operation.
- * const operationType = result.operationType;
- * ```
- *
- * @param auth - The {@link Auth} instance.
- * @param provider - The provider to authenticate. The provider has to be an {@link OAuthProvider}.
- * Non-OAuth providers like {@link EmailAuthProvider} will throw an error.
- * @param resolver - An instance of {@link PopupRedirectResolver}, optional
- * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
- *
- * @public
- */
- export declare function signInWithRedirect(auth: Auth, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<never>;
- /**
- * Signs out the current user.
- *
- * @param auth - The {@link Auth} instance.
- *
- * @public
- */
- export declare function signOut(auth: Auth): Promise<void>;
- declare interface StartTotpMfaEnrollmentResponse {
- totpSessionInfo: {
- sharedSecretKey: string;
- verificationCodeLength: number;
- hashingAlgorithm: string;
- periodSec: number;
- sessionInfo: string;
- finalizeEnrollmentTime: number;
- };
- }
- /**
- * We need to mark this class as internal explicitly to exclude it in the public typings, because
- * it references AuthInternal which has a circular dependency with UserInternal.
- *
- * @internal
- */
- declare class StsTokenManager {
- refreshToken: string | null;
- accessToken: string | null;
- expirationTime: number | null;
- get isExpired(): boolean;
- updateFromServerResponse(response: IdTokenResponse | FinalizeMfaResponse): void;
- getToken(auth: AuthInternal, forceRefresh?: boolean): Promise<string | null>;
- clearRefreshToken(): void;
- private refresh;
- private updateTokensAndExpiration;
- static fromJSON(appName: string, object: PersistedBlob): StsTokenManager;
- toJSON(): object;
- _assign(stsTokenManager: StsTokenManager): void;
- _clone(): StsTokenManager;
- _performRefresh(): never;
- }
- /**
- * @internal
- */
- declare interface TaggedWithTokenResponse {
- _tokenResponse?: PhoneOrOauthTokenResponse;
- }
- /**
- * An MFA provided by TOTP (Time-based One Time Password).
- */
- declare interface TotpMfaEnrollment extends BaseMfaEnrollment {
- }
- /**
- * The class for asserting ownership of a TOTP second factor. Provided by
- * {@link TotpMultiFactorGenerator.assertionForEnrollment} and
- * {@link TotpMultiFactorGenerator.assertionForSignIn}.
- *
- * @public
- */
- export declare interface TotpMultiFactorAssertion extends MultiFactorAssertion {
- }
- /**
- * Provider for generating a {@link TotpMultiFactorAssertion}.
- *
- * @public
- */
- export declare class TotpMultiFactorGenerator {
- /**
- * Provides a {@link TotpMultiFactorAssertion} to confirm ownership of
- * the TOTP (time-based one-time password) second factor.
- * This assertion is used to complete enrollment in TOTP second factor.
- *
- * @param secret A {@link TotpSecret} containing the shared secret key and other TOTP parameters.
- * @param oneTimePassword One-time password from TOTP App.
- * @returns A {@link TotpMultiFactorAssertion} which can be used with
- * {@link MultiFactorUser.enroll}.
- */
- static assertionForEnrollment(secret: TotpSecret, oneTimePassword: string): TotpMultiFactorAssertion;
- /**
- * Provides a {@link TotpMultiFactorAssertion} to confirm ownership of the TOTP second factor.
- * This assertion is used to complete signIn with TOTP as the second factor.
- *
- * @param enrollmentId identifies the enrolled TOTP second factor.
- * @param oneTimePassword One-time password from TOTP App.
- * @returns A {@link TotpMultiFactorAssertion} which can be used with
- * {@link MultiFactorResolver.resolveSignIn}.
- */
- static assertionForSignIn(enrollmentId: string, oneTimePassword: string): TotpMultiFactorAssertion;
- /**
- * Returns a promise to {@link TotpSecret} which contains the TOTP shared secret key and other parameters.
- * Creates a TOTP secret as part of enrolling a TOTP second factor.
- * Used for generating a QR code URL or inputting into a TOTP app.
- * This method uses the auth instance corresponding to the user in the multiFactorSession.
- *
- * @param session The {@link MultiFactorSession} that the user is part of.
- * @returns A promise to {@link TotpSecret}.
- */
- static generateSecret(session: MultiFactorSession): Promise<TotpSecret>;
- /**
- * The identifier of the TOTP second factor: `totp`.
- */
- static FACTOR_ID: 'totp';
- }
- /**
- * The subclass of the {@link MultiFactorInfo} interface for TOTP
- * second factors. The `factorId` of this second factor is {@link FactorId}.TOTP.
- * @public
- */
- export declare interface TotpMultiFactorInfo extends MultiFactorInfo {
- }
- /**
- * Provider for generating a {@link TotpMultiFactorAssertion}.
- *
- * Stores the shared secret key and other parameters to generate time-based OTPs.
- * Implements methods to retrieve the shared secret key and generate a QR code URL.
- * @public
- */
- export declare class TotpSecret {
- private readonly sessionInfo;
- private readonly auth;
- /**
- * Shared secret key/seed used for enrolling in TOTP MFA and generating OTPs.
- */
- readonly secretKey: string;
- /**
- * Hashing algorithm used.
- */
- readonly hashingAlgorithm: string;
- /**
- * Length of the one-time passwords to be generated.
- */
- readonly codeLength: number;
- /**
- * The interval (in seconds) when the OTP codes should change.
- */
- readonly codeIntervalSeconds: number;
- /**
- * The timestamp (UTC string) by which TOTP enrollment should be completed.
- */
- readonly enrollmentCompletionDeadline: string;
- private constructor();
- /** @internal */
- static _fromStartTotpMfaEnrollmentResponse(response: StartTotpMfaEnrollmentResponse, auth: AuthInternal): TotpSecret;
- /** @internal */
- _makeTotpVerificationInfo(otp: string): TotpVerificationInfo;
- /**
- * Returns a QR code URL as described in
- * https://github.com/google/google-authenticator/wiki/Key-Uri-Format
- * This can be displayed to the user as a QR code to be scanned into a TOTP app like Google Authenticator.
- * If the optional parameters are unspecified, an accountName of <userEmail> and issuer of <firebaseAppName> are used.
- *
- * @param accountName the name of the account/app along with a user identifier.
- * @param issuer issuer of the TOTP (likely the app name).
- * @returns A QR code URL string.
- */
- generateQrCodeUrl(accountName?: string, issuer?: string): string;
- }
- declare interface TotpVerificationInfo {
- sessionInfo: string;
- verificationCode: string;
- }
- /**
- * Provider for generating an {@link OAuthCredential} for {@link ProviderId}.TWITTER.
- *
- * @example
- * ```javascript
- * // Sign in using a redirect.
- * const provider = new TwitterAuthProvider();
- * // Start a sign in process for an unauthenticated user.
- * await signInWithRedirect(auth, provider);
- * // This will trigger a full page redirect away from your app
- *
- * // After returning from the redirect when your app initializes you can obtain the result
- * const result = await getRedirectResult(auth);
- * if (result) {
- * // This is the signed-in user
- * const user = result.user;
- * // This gives you a Twitter Access Token and Secret.
- * const credential = TwitterAuthProvider.credentialFromResult(result);
- * const token = credential.accessToken;
- * const secret = credential.secret;
- * }
- * ```
- *
- * @example
- * ```javascript
- * // Sign in using a popup.
- * const provider = new TwitterAuthProvider();
- * const result = await signInWithPopup(auth, provider);
- *
- * // The signed-in user info.
- * const user = result.user;
- * // This gives you a Twitter Access Token and Secret.
- * const credential = TwitterAuthProvider.credentialFromResult(result);
- * const token = credential.accessToken;
- * const secret = credential.secret;
- * ```
- *
- * @public
- */
- export declare class TwitterAuthProvider extends BaseOAuthProvider {
- /** Always set to {@link SignInMethod}.TWITTER. */
- static readonly TWITTER_SIGN_IN_METHOD: 'twitter.com';
- /** Always set to {@link ProviderId}.TWITTER. */
- static readonly PROVIDER_ID: 'twitter.com';
- constructor();
- /**
- * Creates a credential for Twitter.
- *
- * @param token - Twitter access token.
- * @param secret - Twitter secret.
- */
- static credential(token: string, secret: string): OAuthCredential;
- /**
- * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
- *
- * @param userCredential - The user credential.
- */
- static credentialFromResult(userCredential: UserCredential): OAuthCredential | null;
- /**
- * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
- * thrown during a sign-in, link, or reauthenticate operation.
- *
- * @param userCredential - The user credential.
- */
- static credentialFromError(error: FirebaseError): OAuthCredential | null;
- private static credentialFromTaggedObject;
- }
- /**
- * Unlinks a provider from a user account.
- *
- * @param user - The user.
- * @param providerId - The provider to unlink.
- *
- * @public
- */
- export declare function unlink(user: User, providerId: string): Promise<User>;
- export { Unsubscribe }
- /**
- * Asynchronously sets the provided user as {@link Auth.currentUser} on the
- * {@link Auth} instance.
- *
- * @remarks
- * A new instance copy of the user provided will be made and set as currentUser.
- *
- * This will trigger {@link onAuthStateChanged} and {@link onIdTokenChanged} listeners
- * like other sign in methods.
- *
- * The operation fails with an error if the user to be updated belongs to a different Firebase
- * project.
- *
- * @param auth - The {@link Auth} instance.
- * @param user - The new {@link User}.
- *
- * @public
- */
- export declare function updateCurrentUser(auth: Auth, user: User | null): Promise<void>;
- /**
- * Updates the user's email address.
- *
- * @remarks
- * An email will be sent to the original email address (if it was set) that allows to revoke the
- * email address change, in order to protect them from account hijacking.
- *
- * Important: this is a security sensitive operation that requires the user to have recently signed
- * in. If this requirement isn't met, ask the user to authenticate again and then call
- * {@link reauthenticateWithCredential}.
- *
- * @param user - The user.
- * @param newEmail - The new email address.
- *
- * @public
- */
- export declare function updateEmail(user: User, newEmail: string): Promise<void>;
- /**
- * Updates the user's password.
- *
- * @remarks
- * Important: this is a security sensitive operation that requires the user to have recently signed
- * in. If this requirement isn't met, ask the user to authenticate again and then call
- * {@link reauthenticateWithCredential}.
- *
- * @param user - The user.
- * @param newPassword - The new password.
- *
- * @public
- */
- export declare function updatePassword(user: User, newPassword: string): Promise<void>;
- /**
- * Updates the user's phone number.
- *
- * @example
- * ```
- * // 'recaptcha-container' is the ID of an element in the DOM.
- * const applicationVerifier = new RecaptchaVerifier('recaptcha-container');
- * const provider = new PhoneAuthProvider(auth);
- * const verificationId = await provider.verifyPhoneNumber('+16505550101', applicationVerifier);
- * // Obtain the verificationCode from the user.
- * const phoneCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
- * await updatePhoneNumber(user, phoneCredential);
- * ```
- *
- * @param user - The user.
- * @param credential - A credential authenticating the new phone number.
- *
- * @public
- */
- export declare function updatePhoneNumber(user: User, credential: PhoneAuthCredential): Promise<void>;
- /**
- * Updates a user's profile data.
- *
- * @param user - The user.
- * @param profile - The profile's `displayName` and `photoURL` to update.
- *
- * @public
- */
- export declare function updateProfile(user: User, { displayName, photoURL: photoUrl }: {
- displayName?: string | null;
- photoURL?: string | null;
- }): Promise<void>;
- /**
- * Sets the current language to the default device/browser preference.
- *
- * @param auth - The {@link Auth} instance.
- *
- * @public
- */
- export declare function useDeviceLanguage(auth: Auth): void;
- /**
- * A user account.
- *
- * @public
- */
- export declare interface User extends UserInfo {
- /**
- * Whether the email has been verified with {@link sendEmailVerification} and
- * {@link applyActionCode}.
- */
- readonly emailVerified: boolean;
- /**
- * Whether the user is authenticated using the {@link ProviderId}.ANONYMOUS provider.
- */
- readonly isAnonymous: boolean;
- /**
- * Additional metadata around user creation and sign-in times.
- */
- readonly metadata: UserMetadata;
- /**
- * Additional per provider such as displayName and profile information.
- */
- readonly providerData: UserInfo[];
- /**
- * Refresh token used to reauthenticate the user. Avoid using this directly and prefer
- * {@link User.getIdToken} to refresh the ID token instead.
- */
- readonly refreshToken: string;
- /**
- * The user's tenant ID.
- *
- * @remarks
- * This is a read-only property, which indicates the tenant ID
- * used to sign in the user. This is null if the user is signed in from the parent
- * project.
- *
- * @example
- * ```javascript
- * // Set the tenant ID on Auth instance.
- * auth.tenantId = 'TENANT_PROJECT_ID';
- *
- * // All future sign-in request now include tenant ID.
- * const result = await signInWithEmailAndPassword(auth, email, password);
- * // result.user.tenantId should be 'TENANT_PROJECT_ID'.
- * ```
- */
- readonly tenantId: string | null;
- /**
- * Deletes and signs out the user.
- *
- * @remarks
- * Important: this is a security-sensitive operation that requires the user to have recently
- * signed in. If this requirement isn't met, ask the user to authenticate again and then call
- * one of the reauthentication methods like {@link reauthenticateWithCredential}.
- */
- delete(): Promise<void>;
- /**
- * Returns a JSON Web Token (JWT) used to identify the user to a Firebase service.
- *
- * @remarks
- * Returns the current token if it has not expired or if it will not expire in the next five
- * minutes. Otherwise, this will refresh the token and return a new one.
- *
- * @param forceRefresh - Force refresh regardless of token expiration.
- */
- getIdToken(forceRefresh?: boolean): Promise<string>;
- /**
- * Returns a deserialized JSON Web Token (JWT) used to identify the user to a Firebase service.
- *
- * @remarks
- * Returns the current token if it has not expired or if it will not expire in the next five
- * minutes. Otherwise, this will refresh the token and return a new one.
- *
- * @param forceRefresh - Force refresh regardless of token expiration.
- */
- getIdTokenResult(forceRefresh?: boolean): Promise<IdTokenResult>;
- /**
- * Refreshes the user, if signed in.
- */
- reload(): Promise<void>;
- /**
- * Returns a JSON-serializable representation of this object.
- *
- * @returns A JSON-serializable representation of this object.
- */
- toJSON(): object;
- }
- /**
- * A structure containing a {@link User}, the {@link OperationType}, and the provider ID.
- *
- * @remarks
- * `operationType` could be {@link OperationType}.SIGN_IN for a sign-in operation,
- * {@link OperationType}.LINK for a linking operation and {@link OperationType}.REAUTHENTICATE for
- * a reauthentication operation.
- *
- * @public
- */
- export declare interface UserCredential {
- /**
- * The user authenticated by this credential.
- */
- user: User;
- /**
- * The provider which was used to authenticate the user.
- */
- providerId: string | null;
- /**
- * The type of operation which was used to authenticate the user (such as sign-in or link).
- */
- operationType: (typeof OperationType)[keyof typeof OperationType];
- }
- /**
- * @internal
- */
- declare interface UserCredentialInternal extends UserCredential, TaggedWithTokenResponse {
- user: UserInternal;
- }
- /**
- * User profile information, visible only to the Firebase project's apps.
- *
- * @public
- */
- export declare interface UserInfo {
- /**
- * The display name of the user.
- */
- readonly displayName: string | null;
- /**
- * The email of the user.
- */
- readonly email: string | null;
- /**
- * The phone number normalized based on the E.164 standard (e.g. +16505550101) for the
- * user.
- *
- * @remarks
- * This is null if the user has no phone credential linked to the account.
- */
- readonly phoneNumber: string | null;
- /**
- * The profile photo URL of the user.
- */
- readonly photoURL: string | null;
- /**
- * The provider used to authenticate the user.
- */
- readonly providerId: string;
- /**
- * The user's unique ID, scoped to the project.
- */
- readonly uid: string;
- }
- /**
- * UserInternal and AuthInternal reference each other, so both of them are included in the public typings.
- * In order to exclude them, we mark them as internal explicitly.
- *
- * @internal
- */
- declare interface UserInternal extends User {
- displayName: string | null;
- email: string | null;
- phoneNumber: string | null;
- photoURL: string | null;
- auth: AuthInternal;
- providerId: ProviderId_2.FIREBASE;
- refreshToken: string;
- emailVerified: boolean;
- tenantId: string | null;
- providerData: MutableUserInfo[];
- metadata: UserMetadata_2;
- stsTokenManager: StsTokenManager;
- _redirectEventId?: string;
- _updateTokensIfNecessary(response: IdTokenResponse | FinalizeMfaResponse, reload?: boolean): Promise<void>;
- _assign(user: UserInternal): void;
- _clone(auth: AuthInternal): UserInternal;
- _onReload: (cb: NextFn<APIUserInfo>) => void;
- _notifyReloadListener: NextFn<APIUserInfo>;
- _startProactiveRefresh: () => void;
- _stopProactiveRefresh: () => void;
- getIdToken(forceRefresh?: boolean): Promise<string>;
- getIdTokenResult(forceRefresh?: boolean): Promise<IdTokenResult>;
- reload(): Promise<void>;
- delete(): Promise<void>;
- toJSON(): PersistedBlob;
- }
- /**
- * Interface representing a user's metadata.
- *
- * @public
- */
- export declare interface UserMetadata {
- /** Time the user was created. */
- readonly creationTime?: string;
- /** Time the user last signed in. */
- readonly lastSignInTime?: string;
- }
- declare class UserMetadata_2 implements UserMetadata {
- private createdAt?;
- private lastLoginAt?;
- creationTime?: string;
- lastSignInTime?: string;
- constructor(createdAt?: string | number | undefined, lastLoginAt?: string | number | undefined);
- private _initializeTime;
- _copy(metadata: UserMetadata_2): void;
- toJSON(): object;
- }
- /**
- * User profile used in {@link AdditionalUserInfo}.
- *
- * @public
- */
- export declare type UserProfile = Record<string, unknown>;
- /**
- * Sends a verification email to a new email address.
- *
- * @remarks
- * The user's email will be updated to the new one after being verified.
- *
- * If you have a custom email action handler, you can complete the verification process by calling
- * {@link applyActionCode}.
- *
- * @example
- * ```javascript
- * const actionCodeSettings = {
- * url: 'https://www.example.com/?email=user@example.com',
- * iOS: {
- * bundleId: 'com.example.ios'
- * },
- * android: {
- * packageName: 'com.example.android',
- * installApp: true,
- * minimumVersion: '12'
- * },
- * handleCodeInApp: true
- * };
- * await verifyBeforeUpdateEmail(user, 'newemail@example.com', actionCodeSettings);
- * // Obtain code from the user.
- * await applyActionCode(auth, code);
- * ```
- *
- * @param user - The user.
- * @param newEmail - The new email address to be verified before update.
- * @param actionCodeSettings - The {@link ActionCodeSettings}.
- *
- * @public
- */
- export declare function verifyBeforeUpdateEmail(user: User, newEmail: string, actionCodeSettings?: ActionCodeSettings | null): Promise<void>;
- /**
- * Checks a password reset code sent to the user by email or other out-of-band mechanism.
- *
- * @returns the user's email address if valid.
- *
- * @param auth - The {@link Auth} instance.
- * @param code - A verification code sent to the user.
- *
- * @public
- */
- export declare function verifyPasswordResetCode(auth: Auth, code: string): Promise<string>;
- export { }
|