1- import * as firebase from "../../firebase" ;
2- import { FirebaseEmailLinkActionCodeSettings , LoginType , User , Unsubscribe } from "../../firebase" ;
1+ import { firebase } from "../../firebase" ;
32
43export namespace auth {
54 export class Auth {
65 private authStateChangedHandler ;
76 private authStateOnErrorHandler ;
8- public currentUser : User ;
7+ public currentUser : firebase . User ;
98 public languageCode : string | null ;
109
1110 private loginHelper ( options : firebase . LoginOptions ) {
1211 return new Promise ( ( resolve , reject ) => {
1312 firebase . login ( options )
14- . then ( ( user : User ) => {
13+ . then ( ( user : firebase . User ) => {
1514 this . currentUser = user ;
1615 this . authStateChangedHandler && this . authStateChangedHandler ( user ) ;
1716 resolve ( {
@@ -45,7 +44,7 @@ export namespace auth {
4544
4645 // Completed will never be called, but it is here to closely follow the web api interface.
4746 // When called, the callback handler will be passed in the currentUser or undefined if not signed in
48- public onAuthStateChanged ( handler : ( user : User ) => void , error ?: ( err ) => any , completed ?: Unsubscribe ) : Unsubscribe {
47+ public onAuthStateChanged ( handler : ( user : firebase . User ) => void , error ?: ( err ) => any , completed ?: firebase . Unsubscribe ) : firebase . Unsubscribe {
4948 this . authStateChangedHandler = handler ;
5049 if ( error ) this . authStateOnErrorHandler = error ;
5150 console . log ( ">> added onAuthStateChanged handler" ) ;
@@ -92,7 +91,7 @@ export namespace auth {
9291
9392 public signInWithEmailAndPassword ( email : string , password : string ) : Promise < any > {
9493 const emailOption : firebase . LoginOptions = {
95- type : LoginType . PASSWORD ,
94+ type : firebase . LoginType . PASSWORD ,
9695 passwordOptions : {
9796 email : email ,
9897 password : password
@@ -103,7 +102,7 @@ export namespace auth {
103102
104103 public signInWithCustomToken ( token : string ) : Promise < any > {
105104 const customTokenOption : firebase . LoginOptions = {
106- type : LoginType . CUSTOM ,
105+ type : firebase . LoginType . CUSTOM ,
107106 customOptions : {
108107 token : token
109108 }
@@ -113,14 +112,14 @@ export namespace auth {
113112
114113 public signInAnonymously ( ) : Promise < any > {
115114 const anonymousOption : firebase . LoginOptions = {
116- type : LoginType . ANONYMOUS
115+ type : firebase . LoginType . ANONYMOUS
117116 } ;
118117 return this . loginHelper ( anonymousOption ) ;
119118 }
120119
121- public sendSignInLinkToEmail ( email : string , actionCodeSettings : FirebaseEmailLinkActionCodeSettings ) : Promise < any > {
120+ public sendSignInLinkToEmail ( email : string , actionCodeSettings : firebase . FirebaseEmailLinkActionCodeSettings ) : Promise < any > {
122121 const sendSignInLinklOption : firebase . LoginOptions = {
123- type : LoginType . EMAIL_LINK ,
122+ type : firebase . LoginType . EMAIL_LINK ,
124123 emailLinkOptions : {
125124 email : email ,
126125 url : actionCodeSettings . url ,
@@ -140,12 +139,12 @@ export namespace auth {
140139 return this . loginHelper ( signInWithEmailOption ) ;
141140 }
142141
143- public createUserWithEmailAndPassword ( email : string , password : string ) : Promise < User > {
142+ public createUserWithEmailAndPassword ( email : string , password : string ) : Promise < firebase . User > {
144143 return new Promise ( ( resolve , reject ) => {
145144 firebase . createUser ( {
146145 email : email ,
147146 password : password
148- } ) . then ( ( user : User ) => {
147+ } ) . then ( ( user : firebase . User ) => {
149148 this . currentUser = user ;
150149 resolve ( user ) ;
151150 } ) . catch ( err => reject ( err ) ) ;
0 commit comments