| 888 | } |
| 889 | |
| 890 | export class Auth implements IAuth { |
| 891 | _native: FIRAuth; |
| 892 | constructor(app?: FirebaseApp) { |
| 893 | this._app = app; |
| 894 | } |
| 895 | |
| 896 | useEmulator(host: string, port: number) { |
| 897 | this.native.useEmulatorWithHostPort(host, port); |
| 898 | } |
| 899 | |
| 900 | fetchSignInMethodsForEmail(email: string): Promise<string[]> { |
| 901 | return new Promise((resolve, reject) => { |
| 902 | if (!this.native) { |
| 903 | reject(); |
| 904 | } |
| 905 | this.native.fetchSignInMethodsForEmailCompletion(email, (emails, error) => { |
| 906 | if (error) { |
| 907 | reject(FirebaseError.fromNative(error)); |
| 908 | } else { |
| 909 | const arr = []; |
| 910 | if (emails) { |
| 911 | const size = emails.count; |
| 912 | for (let i = 0; i < size; i++) { |
| 913 | arr.push(emails.objectAtIndex(i)); |
| 914 | } |
| 915 | } |
| 916 | resolve(arr); |
| 917 | } |
| 918 | }); |
| 919 | }); |
| 920 | } |
| 921 | |
| 922 | isSignInWithEmailLink(emailLink: string): boolean { |
| 923 | return this.native.isSignInWithEmailLink(emailLink); |
| 924 | } |
| 925 | |
| 926 | _authStateChangeListeners = new Map(); |
| 927 | |
| 928 | addAuthStateChangeListener(listener: (user: User) => void) { |
| 929 | if (this.native && typeof listener === 'function') { |
| 930 | const id = this.native.addAuthStateDidChangeListener((auth, user) => { |
| 931 | listener(User.fromNative(user)); |
| 932 | }); |
| 933 | this._authStateChangeListeners.set(listener, id); |
| 934 | } |
| 935 | } |
| 936 | |
| 937 | removeAuthStateChangeListener(listener: (user: User) => void) { |
| 938 | if (this.native && typeof listener === 'function') { |
| 939 | const id = this._authStateChangeListeners.get(listener); |
| 940 | if (id) { |
| 941 | this.native.removeAuthStateDidChangeListener(id); |
| 942 | this._authStateChangeListeners.delete(id); |
| 943 | } |
| 944 | } |
| 945 | } |
| 946 | |
| 947 | _idTokenChangeListeners = new Map(); |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…