[typings] Add a few missing app, auth and firestore Typescript typings

This commit is contained in:
Chris Bianca
2018-01-31 09:09:12 +00:00
parent d46024f799
commit 8060c949a2

76
lib/index.d.ts vendored
View File

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