MCPcopy Create free account
hub / github.com/NativeScript/firebase / Auth

Class Auth

packages/firebase-auth/index.android.ts:960–1465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

958const NSFirebaseAuth = lazy(() => org.nativescript.firebase.auth.FirebaseAuth);
959
960export class Auth implements IAuth {
961 _native: com.google.firebase.auth.FirebaseAuth;
962
963 constructor(app?: FirebaseApp) {
964 if (app?.native) {
965 this._native = com.google.firebase.auth.FirebaseAuth.getInstance(app.native);
966 } else {
967 if (defaultAuth) {
968 return defaultAuth;
969 }
970 defaultAuth = this;
971 }
972 }
973
974 useEmulator(host: string, port: number) {
975 this.native.useEmulator(host === 'localhost' || host === '127.0.0.1' ? '10.0.2.2' : host, port);
976 }
977
978 fetchSignInMethodsForEmail(email: string): Promise<string[]> {
979 return new Promise((resolve, reject) => {
980 if (!this.native) {
981 reject();
982 }
983 NSFirebaseAuth().fetchSignInMethodsForEmail(
984 this.native,
985 email,
986 new org.nativescript.firebase.auth.FirebaseAuth.Callback({
987 onSuccess(success) {
988 const nativeArray = success.getSignInMethods().toArray();
989 const arr = [];
990 for (let i = 0; i < nativeArray.length; i++) {
991 arr.push(nativeArray[i]);
992 }
993 resolve(arr);
994 },
995 onError(error) {
996 reject({
997 message: error.getMessage(),
998 native: error,
999 });
1000 },
1001 })
1002 );
1003 });
1004 }
1005
1006 isSignInWithEmailLink(emailLink: string): boolean {
1007 return this.native.isSignInWithEmailLink(emailLink);
1008 }
1009
1010 _authStateChangeListeners = new Map();
1011
1012 addAuthStateChangeListener(listener: (user: User) => void) {
1013 if (this.native && typeof listener === 'function') {
1014 const nativeListener = new com.google.firebase.auth.FirebaseAuth.AuthStateListener({
1015 onAuthStateChanged(auth: com.google.firebase.auth.FirebaseAuth) {
1016 listener(User.fromNative(auth.getCurrentUser()));
1017 },

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…