From 8060c949a2881cada885849c63c9a4ff93ec5d8c Mon Sep 17 00:00:00 2001 From: Chris Bianca Date: Wed, 31 Jan 2018 09:09:12 +0000 Subject: [PATCH] [typings] Add a few missing app, auth and firestore Typescript typings --- lib/index.d.ts | 76 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 55 insertions(+), 21 deletions(-) diff --git a/lib/index.d.ts b/lib/index.d.ts index b67fc717..4f239a9e 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -37,8 +37,8 @@ declare module "react-native-firebase" { // utils: FirebaseModuleAndStatics; initializeApp(options: Firebase.Options, name: string): App; app(name?: string): App; - apps(): App[]; - SDK_VERSION(): string; + readonly apps: App[]; + readonly SDK_VERSION: string; } namespace Firebase { interface Options { @@ -71,6 +71,8 @@ declare module "react-native-firebase" { // perf(): RNFirebase.perf.Performance; storage(): RNFirebase.storage.Storage; // utils(): RNFirebase.utils.Utils; + readonly name: string; + readonly options: Firebase.Options; } export namespace RNFirebase { @@ -529,13 +531,25 @@ declare module "react-native-firebase" { [key: string]: any; } + type AdditionalUserInfo = { + isNewUser: boolean, + profile?: Object, + providerId: string, + username?: string, + } + + type UserCredential = { + additionalUserInfo?: AdditionalUserInfo, + user: User, + } + type UserInfo = { - displayName?: string, - email?: string, - phoneNumber?: string, - photoURL?: string, - providerId: string, - uid: string, + displayName?: string, + email?: string, + phoneNumber?: string, + photoURL?: string, + providerId: string, + uid: string, } type UpdateProfile = { @@ -543,6 +557,11 @@ declare module "react-native-firebase" { photoURL?: string, } + type UserMetadata = { + creationTime?: string, + lastSignInTime?: string, + } + interface User { /** * The user's display name (if available). @@ -561,6 +580,8 @@ declare module "react-native-firebase" { */ isAnonymous: boolean + metadata: UserMetadata + phoneNumber: string | null /** * - The URL of the user's profile picture (if available). @@ -592,11 +613,17 @@ declare module "react-native-firebase" { */ getIdToken(forceRefresh?: boolean): Promise + getToken(forceRefresh?: boolean): Promise + + linkAndRetrieveDataWithCredential(credential: AuthCredential): Promise + /** * Link the user with a 3rd party credential provider. */ linkWithCredential(credential: AuthCredential): Promise + reauthenticateAndRetrieveDataWithCredential(credential: AuthCredential): Promise + /** * Re-authenticate a user with a third-party authentication provider */ @@ -652,12 +679,11 @@ declare module "react-native-firebase" { } interface ActionCodeInfo { - email: string, - error: string, - fromEmail: string, - verifyEmail: string, - recoverEmail: string, - passwordReset: string + data: { + email?: string, + fromEmail?: string + }, + operation: 'PASSWORD_RESET' | 'VERIFY_EMAIL' | 'RECOVER_EMAIL' } interface ConfirmationResult { @@ -694,7 +720,6 @@ declare module "react-native-firebase" { } namespace auth { - type AuthResult = { authenticated: boolean, user: object | null @@ -706,6 +731,7 @@ declare module "react-native-firebase" { }; interface Auth { + readonly app: App; /** * Returns the current Firebase authentication state. */ @@ -713,7 +739,7 @@ declare module "react-native-firebase" { /** * Returns the currently signed-in user (or null). See the User class documentation for further usage. */ - user: User | null + currentUser: User | null /** * Gets/Sets the language for the app instance @@ -743,12 +769,15 @@ declare module "react-native-firebase" { signOut(): Promise + signInAnonymouslyAndRetrieveData(): Promise + /** * Sign an anonymous user. * If the user has already signed in, that user will be returned */ signInAnonymously(): Promise + createUserAndRetrieveDataWithEmailAndPassword(email: string, password: string): Promise /** * We can create a user by calling the createUserWithEmailAndPassword() function. @@ -756,12 +785,16 @@ declare module "react-native-firebase" { */ createUserWithEmailAndPassword(email: string, password: string): Promise + signInAndRetrieveDataWithEmailAndPassword(email: string, password: string): Promise + /** * To sign a user in with their email and password, use the signInWithEmailAndPassword() function. * It accepts two parameters, the user's email and password: */ signInWithEmailAndPassword(email: string, password: string): Promise + signInAndRetrieveDataWithCustomToken(token: string): Promise + /** * Sign a user in with a self-signed JWT token. * To sign a user using a self-signed custom token, @@ -770,6 +803,8 @@ declare module "react-native-firebase" { */ signInWithCustomToken(token: string): Promise + signInAndRetrieveDataWithCredential(credential: AuthCredential): Promise + /** * Sign in the user with a 3rd party credential provider. * credential requires the following properties: @@ -810,16 +845,13 @@ declare module "react-native-firebase" { */ checkActionCode(code: string): Promise - /** - * Get the currently signed in user - */ - getCurrentUser(): Promise - /** * Returns a list of authentication providers that can be used to sign in a given user (identified by its main email address). */ fetchProvidersForEmail(email: string): Promise> + verifyPasswordResetCode(code: string): Promise + [key: string]: any; } @@ -828,6 +860,7 @@ declare module "react-native-firebase" { PhoneAuthProvider: AuthProvider; GoogleAuthProvider: AuthProvider; GithubAuthProvider: AuthProvider; + OAuthProvider: AuthProvider; TwitterAuthProvider: AuthProvider; FacebookAuthProvider: AuthProvider; PhoneAuthState: { @@ -1079,6 +1112,7 @@ declare module "react-native-firebase" { namespace firestore { interface Firestore { + readonly app: App; batch(): WriteBatch; collection(collectionPath: string): CollectionReference; doc(documentPath: string): DocumentReference;