[types] firebase.auth.AuthSettings

This commit is contained in:
Salakar
2018-09-16 23:08:13 +01:00
parent dc0a62402f
commit 7807ef2629

262
src/index.d.ts vendored
View File

@@ -59,6 +59,7 @@ declare module 'react-native-firebase' {
// Modules commented-out do not currently have type definitions
export class Firebase {
private constructor();
// admob: AdmobModule;
analytics: AnalyticsModule;
auth: AuthModule;
@@ -74,12 +75,16 @@ declare module 'react-native-firebase' {
notifications: NotificationsModule;
perf: PerfModule;
storage: StorageModule;
// utils: UtilsModule;
initializeApp(options: Firebase.Options, name: string): App;
app(name?: string): App;
readonly apps: App[];
readonly SDK_VERSION: string;
}
namespace Firebase {
interface Options {
apiKey: string;
@@ -109,21 +114,35 @@ declare module 'react-native-firebase' {
// Modules commented-out do not currently have type definitions
export class App {
private constructor();
// admob(): RNFirebase.admob.AdMob;
analytics(): RNFirebase.Analytics;
auth(): RNFirebase.auth.Auth;
config(): RNFirebase.config.Config;
crashlytics(): RNFirebase.crashlytics.Crashlytics;
database(): RNFirebase.database.Database;
firestore(): RNFirebase.firestore.Firestore;
functions(): RNFirebase.functions.Functions;
iid(): RNFirebase.iid.InstanceId;
// invites(): RNFirebase.invites.Invites;
links(): RNFirebase.links.Links;
messaging(): RNFirebase.messaging.Messaging;
notifications(): RNFirebase.notifications.Notifications;
perf(): RNFirebase.perf.Perf;
storage(): RNFirebase.storage.Storage;
// utils(): RNFirebase.utils.Utils;
readonly name: string;
readonly options: Firebase.Options;
@@ -225,15 +244,15 @@ declare module 'react-native-firebase' {
static TaskState: TaskState;
static TaskEvent: TaskState;
static Native?: {
MAIN_BUNDLE_PATH: string,
CACHES_DIRECTORY_PATH: string,
DOCUMENT_DIRECTORY_PATH: string,
EXTERNAL_DIRECTORY_PATH: string,
EXTERNAL_STORAGE_DIRECTORY_PATH: string,
TEMP_DIRECTORY_PATH: string,
LIBRARY_DIRECTORY_PATH: string,
FILETYPE_REGULAR: string,
FILETYPE_DIRECTORY: string,
MAIN_BUNDLE_PATH: string;
CACHES_DIRECTORY_PATH: string;
DOCUMENT_DIRECTORY_PATH: string;
EXTERNAL_DIRECTORY_PATH: string;
EXTERNAL_STORAGE_DIRECTORY_PATH: string;
TEMP_DIRECTORY_PATH: string;
LIBRARY_DIRECTORY_PATH: string;
FILETYPE_REGULAR: string;
FILETYPE_DIRECTORY: string;
};
/**
@@ -283,6 +302,7 @@ declare module 'react-native-firebase' {
*/
interface Reference {
fullPath: string;
toString(): string;
/**
@@ -334,7 +354,8 @@ declare module 'react-native-firebase' {
* @param metadata The metadata to associate with this file.
*/
putFile(
filePath: string, metadata?: SettableMetadata
filePath: string,
metadata?: SettableMetadata
): StorageTask<UploadTaskSnapshot>;
}
@@ -364,8 +385,9 @@ declare module 'react-native-firebase' {
event: TaskEvent,
next: Handler<T>,
error?: ErrorHandler,
complete?: Handler<T>,
complete?: Handler<T>
): () => void;
on(
event: TaskEvent,
observer: {
@@ -908,6 +930,33 @@ declare module 'react-native-firebase' {
) => AuthCredential;
};
interface AuthSettings {
/**
* Flag to determine whether app verification should be disabled for testing or not.
*
* @platform iOS
* @param disabled
*/
appVerificationDisabledForTesting: boolean;
/**
* The phone number and SMS code here must have been configured in the
* Firebase Console (Authentication > Sign In Method > Phone).
*
* Calling this method a second time will overwrite the previously passed parameters.
* Only one number can be configured at a given time.
*
* @platform Android
* @param phoneNumber
* @param smsCode
* @return {*}
*/
setAutoRetrievedSmsCodeForPhoneNumber(
phoneNumber: string,
smsCode: string
): Promise<null>;
}
interface Auth {
readonly app: App;
/**
@@ -924,6 +973,8 @@ declare module 'react-native-firebase' {
*/
languageCode: string | null;
settings: AuthSettings;
/**
* Listen for changes in the users auth state (logging in and out).
* This method returns a unsubscribe function to stop listening to events.
@@ -1149,10 +1200,15 @@ declare module 'react-native-firebase' {
constructor();
setCollapseKey(collapseKey: string): RemoteMessage;
setData(data: Object): RemoteMessage;
setMessageId(messageId: string): RemoteMessage;
setMessageType(messageType: string): RemoteMessage;
setTo(to: string): RemoteMessage;
setTtl(ttl: number): RemoteMessage;
}
@@ -1164,8 +1220,11 @@ declare module 'react-native-firebase' {
namespace iid {
interface InstanceId {
delete(): Promise<void>;
get(): Promise<string>;
getToken(authorizedEntity?: string, scope?: string): Promise<string>;
deleteToken(authorizedEntity?: string, scope?: string): Promise<void>;
}
}
@@ -1173,12 +1232,17 @@ declare module 'react-native-firebase' {
namespace notifications {
interface AndroidNotifications {
createChannel(channel: Android.Channel): Promise<void>;
createChannelGroup(channelGroup: Android.ChannelGroup): Promise<void>;
createChannelGroups(
channelGroups: Android.ChannelGroup[]
): Promise<void>;
createChannels(channels: Android.Channel[]): Promise<void>;
deleteChannelGroup(groupId: string): Promise<void>;
deleteChannel(channelId: string): Promise<void>;
}
@@ -1251,10 +1315,15 @@ declare module 'react-native-firebase' {
constructor();
setBody(body: string): Notification;
setData(data: any): Notification;
setNotificationId(notificationId: string): Notification;
setSound(sound: string): Notification;
setSubtitle(subtitle: string): Notification;
setTitle(title: string): Notification;
}
@@ -1303,56 +1372,91 @@ declare module 'react-native-firebase' {
when?: number;
addAction(action: Android.Action): Notification;
addPerson(person: string): Notification;
setAutoCancel(autoCancel: boolean): Notification;
setBadgeIconType(badgeIconType: Android.BadgeIconType): Notification;
setBigPicture(
picture: string,
largeIcon?: string,
contentTitle?: string,
summaryText?: string
): Notification;
setBigText(
text: string,
contentTitle?: string,
summaryText?: string
): Notification;
setCategory(category: Android.Category): Notification;
setChannelId(channelId: string): Notification;
setClickAction(clickAction: string): Notification;
setColor(color: string): Notification;
setColorized(colorized: boolean): Notification;
setContentInfo(contentInfo: string): Notification;
setDefaults(defaults: Android.Defaults[]): Notification;
setGroup(group: string): Notification;
setGroupAlertBehaviour(
groupAlertBehaviour: Android.GroupAlert
): Notification;
setGroupSummary(groupSummary: boolean): Notification;
setLargeIcon(largeIcon: string): Notification;
setLights(argb: number, onMs: number, offMs: number): Notification;
setLocalOnly(localOnly: boolean): Notification;
setNumber(number: number): Notification;
setOngoing(ongoing: boolean): Notification;
setOnlyAlertOnce(onlyAlertOnce: boolean): Notification;
setPriority(priority: Android.Priority): Notification;
setProgress(
max: number,
progress: number,
indeterminate: boolean
): Notification;
//setPublicVersion(publicVersion: Notification): Notification
setRemoteInputHistory(remoteInputHistory: string[]): Notification;
setShortcutId(shortcutId: string): Notification;
setShowWhen(showWhen: boolean): Notification;
setSmallIcon(icon: string, level?: number): Notification;
setSortKey(sortKey: string): Notification;
setTag(tag: string): Notification;
setTicker(ticker: string): Notification;
setTimeoutAfter(timeoutAfter: number): Notification;
setUsesChronometer(usesChronometer: boolean): Notification;
setVibrate(vibrate: number[]): Notification;
setVisibility(visibility: Android.Visibility): Notification;
setWhen(when: number): Notification;
}
@@ -1369,8 +1473,11 @@ declare module 'react-native-firebase' {
constructor(action: string, icon: string, title: string);
addRemoteInput(remoteInput: RemoteInput): Action;
setAllowGenerateReplies(allowGeneratedReplies: boolean): Action;
setSemanticAction(semanticAction: SemanticAction): Action;
setShowUserInterface(showUserInterface: boolean): Action;
}
@@ -1384,8 +1491,11 @@ declare module 'react-native-firebase' {
constructor(resultKey: string);
setAllowDataType(mimeType: string, allow: boolean): RemoteInput;
setAllowFreeFormInput(allowFreeFormInput: boolean): RemoteInput;
setChoices(choices: string[]): RemoteInput;
setLabel(label: string): RemoteInput;
}
@@ -1408,14 +1518,23 @@ declare module 'react-native-firebase' {
constructor(channelId: string, name: string, importance: Importance);
enableLights(lightsEnabled: boolean): Channel;
enableVibration(vibrationEnabled: boolean): Channel;
setBypassDnd(bypassDnd: boolean): Channel;
setDescription(description: string): Channel;
setGroup(groupId: string): Channel;
setLightColor(lightColor: string): Channel;
setLockScreenVisibility(lockScreenVisibility: Visibility): Channel;
setShowBadge(showBadge: boolean): Channel;
setSound(sound: string): Channel;
setVibrationPattern(vibrationPattern: number[]): Channel;
}
@@ -1528,11 +1647,17 @@ declare module 'react-native-firebase' {
url: string,
options: IOSAttachmentOptions
): Notification;
setAlertAction(alertAction: string): Notification;
setBadge(badge: string): Notification;
setCategory(category: string): Notification;
setHasAction(hasAction: boolean): Notification;
setLaunchImage(launchImage: string): Notification;
setThreadIdentifier(threadIdentifier: string): Notification;
}
@@ -1571,6 +1696,7 @@ declare module 'react-native-firebase' {
namespace config {
interface ConfigSnapshot {
source: string;
val(): any;
}
@@ -1807,13 +1933,16 @@ declare module 'react-native-firebase' {
interface Links {
/** Creates a standard dynamic link. */
createDynamicLink(dynamicLink: DynamicLink): Promise<string>;
/** Creates a short dynamic link. */
createShortDynamicLink(type: 'SHORT' | 'UNGUESSABLE'): Promise<string>;
/**
* Returns the URL that the app has been launched from. If the app was
* not launched from a URL the return value will be null.
*/
getInitialLink(): Promise<string | null>;
/**
* Subscribe to URL open events while the app is still running.
* The listener is called from URL open events whilst the app is still
@@ -1838,31 +1967,45 @@ declare module 'react-native-firebase' {
interface AnalyticsParameters {
setCampaign(campaign: string): DynamicLink;
setContent(content: string): DynamicLink;
setMedium(medium: string): DynamicLink;
setSource(source: string): DynamicLink;
setTerm(term: string): DynamicLink;
}
interface AndroidParameters {
setFallbackUrl(fallbackUrl: string): DynamicLink;
setMinimumVersion(minimumVersion: number): DynamicLink;
setPackageName(packageName: string): DynamicLink;
}
interface IOSParameters {
setAppStoreId(appStoreId: string): DynamicLink;
setBundleId(bundleId: string): DynamicLink;
setCustomScheme(customScheme: string): DynamicLink;
setFallbackUrl(fallbackUrl: string): DynamicLink;
setIPadBundleId(iPadBundleId: string): DynamicLink;
setIPadFallbackUrl(iPadFallbackUrl: string): DynamicLink;
setMinimumVersion(minimumVersion: string): DynamicLink;
}
interface ITunesParameters {
setAffiliateToken(affiliateToken: string): DynamicLink;
setCampaignToken(campaignToken: string): DynamicLink;
setProviderToken(providerToken: string): DynamicLink;
}
@@ -1872,7 +2015,9 @@ declare module 'react-native-firebase' {
interface SocialParameters {
setDescriptionText(descriptionText: string): DynamicLink;
setImageUrl(imageUrl: string): DynamicLink;
setTitle(title: string): DynamicLink;
}
@@ -2012,15 +2157,23 @@ declare module 'react-native-firebase' {
namespace firestore {
interface Firestore {
readonly app: App;
batch(): WriteBatch;
collection(collectionPath: string): CollectionReference;
disableNetwork(): Promise<void>;
doc(documentPath: string): DocumentReference;
enableNetwork(): Promise<void>;
enablePersistence(enabled: boolean): Promise<void>;
runTransaction(
updateFunction: (transaction: Transaction) => Promise<any>
): Promise<any>;
settings(settings: Settings): Promise<void>;
}
@@ -2029,7 +2182,9 @@ declare module 'react-native-firebase' {
FieldPath: typeof FieldPath;
FieldValue: typeof FieldValue;
GeoPoint: typeof GeoPoint;
enableLogging(enabled: boolean): void;
setLogLevel(logLevel: 'debug' | 'error' | 'silent'): void;
}
@@ -2037,36 +2192,54 @@ declare module 'react-native-firebase' {
readonly firestore: Firestore;
readonly id: string;
readonly parent: DocumentReference;
add(data: object): Promise<DocumentReference>;
doc(documentPath?: string): DocumentReference;
endAt(snapshot: DocumentSnapshot): Query;
endAt(...varargs: any[]): Query;
endBefore(snapshot: DocumentSnapshot): Query;
endBefore(...varargs: any[]): Query;
get(options?: Types.GetOptions): Promise<QuerySnapshot>;
limit(limit: number): Query;
onSnapshot(
onNext: Query.ObserverOnNext,
onError?: Query.ObserverOnError
): () => void;
onSnapshot(observer: Query.Observer): () => void;
onSnapshot(
metadataChanges: MetadataChanges,
onNext: Query.ObserverOnNext,
onError?: Query.ObserverOnError
): () => void;
onSnapshot(
metadataChanges: MetadataChanges,
observer: Query.Observer
): () => void;
orderBy(
fieldPath: string | FieldPath,
directionStr?: Types.QueryDirection
): Query;
startAfter(snapshot: DocumentSnapshot): Query;
startAfter(...varargs: any[]): Query;
startAt(snapshot: DocumentSnapshot): Query;
startAt(...varargs: any[]): Query;
where(
fieldPath: string | FieldPath,
op: Types.QueryOperator,
@@ -2086,32 +2259,44 @@ declare module 'react-native-firebase' {
readonly id: string | null;
readonly parent: CollectionReference;
readonly path: string;
collection(collectionPath: string): CollectionReference;
delete(): Promise<void>;
get(options?: Types.GetOptions): Promise<DocumentSnapshot>;
onSnapshot(
onNext: DocumentReference.ObserverOnNext,
onError?: DocumentReference.ObserverOnError
): () => void;
onSnapshot(observer: DocumentReference.Observer): () => void;
onSnapshot(
metadataChanges: MetadataChanges,
onNext: DocumentReference.ObserverOnNext,
onError?: DocumentReference.ObserverOnError
): () => void;
onSnapshot(
metadataChanges: MetadataChanges,
observer: DocumentReference.Observer
): () => void;
set(data: object, writeOptions?: Types.SetOptions): Promise<void>;
update(obj: object): Promise<void>;
update(key1: Types.UpdateKey, val1: any): Promise<void>;
update(
key1: Types.UpdateKey,
val1: any,
key2: Types.UpdateKey,
val2: any
): Promise<void>;
update(
key1: Types.UpdateKey,
val1: any,
@@ -2120,6 +2305,7 @@ declare module 'react-native-firebase' {
key3: Types.UpdateKey,
val3: any
): Promise<void>;
update(
key1: Types.UpdateKey,
val1: any,
@@ -2130,6 +2316,7 @@ declare module 'react-native-firebase' {
key4: Types.UpdateKey,
val4: any
): Promise<void>;
update(
key1: Types.UpdateKey,
val1: any,
@@ -2143,9 +2330,11 @@ declare module 'react-native-firebase' {
val5: any
): Promise<void>;
}
namespace DocumentReference {
type ObserverOnNext = (documentSnapshot: DocumentSnapshot) => void;
type ObserverOnError = (err: object) => void;
interface Observer {
next: ObserverOnNext;
error?: ObserverOnError;
@@ -2157,42 +2346,55 @@ declare module 'react-native-firebase' {
readonly id: string | null;
readonly metadata: Types.SnapshotMetadata;
readonly ref: DocumentReference;
data(): object | void;
get(fieldPath: string | FieldPath): any | undefined;
}
class Blob {
static fromBase64String(base64: string): Blob;
static fromUint8Array(array: Uint8Array): Blob;
isEqual(other: Blob): boolean;
toBase64(): string;
toUint8Array: Uint8Array;
}
class FieldPath {
static documentId(): FieldPath;
constructor(...segments: string[]);
}
class FieldValue {
static delete(): FieldValue;
static serverTimestamp(): FieldValue;
}
class GeoPoint {
constructor(latitude: number, longitude: number);
readonly latitude: number;
readonly longitude: number;
}
class Path {
static fromName(name: string): Path;
constructor(pathComponents: string[]);
readonly id: string | null;
readonly isDocument: boolean;
readonly isCollection: boolean;
readonly relativeName: string;
child(relativePath: string): Path;
parent(): Path | null;
}
@@ -2202,40 +2404,57 @@ declare module 'react-native-firebase' {
interface Query {
readonly firestore: Firestore;
endAt(snapshot: DocumentSnapshot): Query;
endAt(...varargs: any[]): Query;
endBefore(snapshot: DocumentSnapshot): Query;
endBefore(...varargs: any[]): Query;
get(options?: Types.GetOptions): Promise<QuerySnapshot>;
limit(limit: number): Query;
onSnapshot(
onNext: Query.ObserverOnNext,
onError?: Query.ObserverOnError
): () => void;
onSnapshot(observer: Query.Observer): () => void;
onSnapshot(
metadataChanges: MetadataChanges,
onNext: Query.ObserverOnNext,
onError?: Query.ObserverOnError
): () => void;
onSnapshot(
metadataChanges: MetadataChanges,
observer: Query.Observer
): () => void;
orderBy(
fieldPath: string | FieldPath,
directionStr?: Types.QueryDirection
): Query;
startAfter(snapshot: DocumentSnapshot): Query;
startAfter(...varargs: any[]): Query;
startAt(snapshot: DocumentSnapshot): Query;
startAt(...varargs: any[]): Query;
where(
fieldPath: string | FieldPath,
op: Types.QueryOperator,
value: any
): Query;
}
namespace Query {
interface NativeFieldPath {
elements?: string[];
@@ -2266,6 +2485,7 @@ declare module 'react-native-firebase' {
type ObserverOnNext = (querySnapshot: QuerySnapshot) => void;
type ObserverOnError = (err: object) => void;
interface Observer {
next: ObserverOnNext;
error?: ObserverOnError;
@@ -2279,8 +2499,10 @@ declare module 'react-native-firebase' {
readonly metadata: Types.SnapshotMetadata;
readonly query: Query;
readonly size: number;
forEach(callback: (snapshot: DocumentSnapshot) => any): void;
}
namespace QuerySnapshot {
interface NativeData {
changes: Types.NativeDocumentChange[];
@@ -2298,19 +2520,24 @@ declare module 'react-native-firebase' {
interface Transaction {
delete(docRef: DocumentReference): WriteBatch;
get(documentRef: DocumentReference): Promise<DocumentSnapshot>;
set(
documentRef: DocumentReference,
data: Object,
options?: Types.SetOptions
): Transaction;
// multiple overrides for update() to allow strong-typed var_args
update(docRef: DocumentReference, obj: object): WriteBatch;
update(
docRef: DocumentReference,
key1: Types.UpdateKey,
val1: any
): WriteBatch;
update(
docRef: DocumentReference,
key1: Types.UpdateKey,
@@ -2318,6 +2545,7 @@ declare module 'react-native-firebase' {
key2: Types.UpdateKey,
val2: any
): WriteBatch;
update(
docRef: DocumentReference,
key1: Types.UpdateKey,
@@ -2327,6 +2555,7 @@ declare module 'react-native-firebase' {
key3: Types.UpdateKey,
val3: any
): WriteBatch;
update(
docRef: DocumentReference,
key1: Types.UpdateKey,
@@ -2338,6 +2567,7 @@ declare module 'react-native-firebase' {
key4: Types.UpdateKey,
val4: any
): WriteBatch;
update(
docRef: DocumentReference,
key1: Types.UpdateKey,
@@ -2355,19 +2585,24 @@ declare module 'react-native-firebase' {
interface WriteBatch {
commit(): Promise<void>;
delete(docRef: DocumentReference): WriteBatch;
set(
docRef: DocumentReference,
data: object,
options?: Types.SetOptions
): WriteBatch;
// multiple overrides for update() to allow strong-typed var_args
update(docRef: DocumentReference, obj: object): WriteBatch;
update(
docRef: DocumentReference,
key1: Types.UpdateKey,
val1: any
): WriteBatch;
update(
docRef: DocumentReference,
key1: Types.UpdateKey,
@@ -2375,6 +2610,7 @@ declare module 'react-native-firebase' {
key2: Types.UpdateKey,
val2: any
): WriteBatch;
update(
docRef: DocumentReference,
key1: Types.UpdateKey,
@@ -2384,6 +2620,7 @@ declare module 'react-native-firebase' {
key3: Types.UpdateKey,
val3: any
): WriteBatch;
update(
docRef: DocumentReference,
key1: Types.UpdateKey,
@@ -2395,6 +2632,7 @@ declare module 'react-native-firebase' {
key4: Types.UpdateKey,
val4: any
): WriteBatch;
update(
docRef: DocumentReference,
key1: Types.UpdateKey,
@@ -2489,7 +2727,9 @@ declare module 'react-native-firebase/database' {
export type DataSnapshot = RNFirebase.database.DataSnapshot;
export type Reference = RNFirebase.database.Reference;
export type DatabaseStatics = RNFirebase.database.DatabaseStatics;
interface ThenableReference<T> extends Promise<T> {}
interface ThenableReference<T> extends RNFirebase.database.Reference {}
}