cordova-plugin-firebase-authentication 5.0.0 → 7.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,258 @@
1
+ /**
2
+ * Registers a block as an auth state did change listener. To be invoked when:
3
+ * - The block is registered as a listener,
4
+ * - A user with a different UID from the current user has signed in, or
5
+ * - The current user has signed out.
6
+ * @param {(userDetails: UserDetails | null) => void} callback Callback function
7
+ * @param {(error: string) => void} [errorCallback] Error callback function
8
+ */
9
+ export function onAuthStateChanged(callback: (userDetails: UserDetails | null) => void, errorCallback?: (error: string) => void): () => void;
10
+ /**
11
+ * Returns the current user in the Firebase instance.
12
+ * @returns {Promise<UserDetails>} Fulfills promise with user details
13
+ */
14
+ export function getCurrentUser(): Promise<UserDetails>;
15
+ /**
16
+ * Returns a JWT token used to identify the user to a Firebase service.
17
+ * @param {boolean} forceRefresh When <code>true</code> cached value is ignored
18
+ * @returns {Promise<string>} Fulfills promis with id token string value
19
+ *
20
+ * @example
21
+ * cordova.plugins.firebase.auth.getIdToken().then(function(idToken) {
22
+ * // send token to server
23
+ * });
24
+ */
25
+ export function getIdToken(forceRefresh: boolean): Promise<string>;
26
+ /**
27
+ * Creates a new user account with the given email address and password.
28
+ * @param {string} email User account email
29
+ * @param {string} password User accound password
30
+ * @returns {Promise<void>} Callback when operation is completed
31
+ *
32
+ * @example
33
+ * cordova.plugins.firebase.auth.createUserWithEmailAndPassword("my@mail.com", "pa55w0rd");
34
+ */
35
+ export function createUserWithEmailAndPassword(email: string, password: string): Promise<void>;
36
+ /**
37
+ * Initiates email verification for the current user.
38
+ * @returns {Promise<void>} Callback when operation is completed
39
+ *
40
+ * @example
41
+ * cordova.plugins.firebase.auth.sendEmailVerification();
42
+ */
43
+ export function sendEmailVerification(): Promise<void>;
44
+ /**
45
+ * Triggers the Firebase Authentication backend to send a password-reset email
46
+ * to the given email address, which must correspond to an existing user of your app.
47
+ * @param {string} email User account email
48
+ * @returns {Promise<void>} Callback when operation is completed
49
+ *
50
+ * @example
51
+ * cordova.plugins.firebase.auth.sendPasswordResetEmail("my@mail.com");
52
+ */
53
+ export function sendPasswordResetEmail(email: string): Promise<void>;
54
+ /**
55
+ * Triggers the Firebase Authentication backend to send a password-reset email
56
+ * to the given email address, which must correspond to an existing user of your app.
57
+ * @param {string} email User account email
58
+ * @param {string} password User accound password
59
+ * @returns {Promise<void>} Callback when operation is completed
60
+ *
61
+ * @example
62
+ * cordova.plugins.firebase.auth.signInWithEmailAndPassword("my@mail.com", "pa55w0rd");
63
+ */
64
+ export function signInWithEmailAndPassword(email: string, password: string): Promise<void>;
65
+ /**
66
+ * Create and use temporary anonymous account to authenticate with Firebase.
67
+ * @returns {Promise<void>} Callback when operation is completed
68
+ *
69
+ * @example
70
+ * cordova.plugins.firebase.auth.signInAnonymously();
71
+ */
72
+ export function signInAnonymously(): Promise<void>;
73
+ /**
74
+ * Uses Google's <code>idToken</code> and <code>accessToken</code> to sign-in into firebase account.
75
+ * @param {string} idToken Google ID token
76
+ * @param {string} accessToken Google Access token
77
+ * @returns {Promise<void>} Callback when operation is completed
78
+ *
79
+ * @see https://firebase.google.com/docs/auth/android/google-signin
80
+ * @see https://firebase.google.com/docs/auth/ios/google-signin
81
+ *
82
+ * @example
83
+ * // Below we use cordova-plugin-googleplus to trigger Google Login UI
84
+ * window.plugins.googleplus.login({
85
+ * scopes: '... ',
86
+ * webClientId: '1234...',
87
+ * offline: true
88
+ * }, function(res) {
89
+ * cordova.plugins.firebase.auth.signInWithGoogle(res.idToken, res.accessToken).then(function() {
90
+ * console.log("Firebase logged in with Google");
91
+ * }, function(err) {
92
+ * console.error("Firebase login failed", err);
93
+ * });
94
+ * }, function(err) {
95
+ * console.error("Google login failed", err);
96
+ * });
97
+ */
98
+ export function signInWithGoogle(idToken: string, accessToken: string): Promise<void>;
99
+ /**
100
+ * Uses Facebook's <code>accessToken</code> to sign-in into firebase account. In order to
101
+ * retrieve those tokens follow instructions for iOS and Android from Firebase docs.
102
+ * @param {string} accessToken Facebook's access token string
103
+ * @returns {Promise<void>} Callback when operation is completed
104
+ *
105
+ * @see https://firebase.google.com/docs/auth/android/facebook-login
106
+ * @see https://firebase.google.com/docs/auth/ios/facebook-login
107
+ */
108
+ export function signInWithFacebook(accessToken: string): Promise<void>;
109
+ /**
110
+ * Uses Twitter's <code>token</code> and <code>secret</code> to sign-in into firebase account.
111
+ * In order to retrieve those tokens follow instructions for iOS and Android from Firebase docs.
112
+ * @param {string} token Twitter's token string
113
+ * @param {string} secret Twitter's secret string
114
+ * @returns {Promise<void>} Callback when operation is completed
115
+ *
116
+ * @see https://firebase.google.com/docs/auth/android/twitter-login
117
+ * @see https://firebase.google.com/docs/auth/ios/twitter-login
118
+ */
119
+ export function signInWithTwitter(token: string, secret: string): Promise<void>;
120
+ /**
121
+ * Uses Apples's <code>idToken</code> and <code>rawNonce</code> to sign-in into firebase account. For getting _idToken_ (_rawNonce_ is optional) you can use `cordova-plugin-sign-in-with-apple` (or any other cordova plugin for Apple Sign-In).
122
+ * @param {string} idToken Apple's ID token string
123
+ * @param {string} rawNonce Apple's raw token string
124
+ * @returns {Promise<void>} Callback when operation is completed
125
+ *
126
+ * @see https://firebase.google.com/docs/auth/android/apple
127
+ * @see https://firebase.google.com/docs/auth/ios/apple
128
+ *
129
+ * @example
130
+ * // below we use cordova-plugin-sign-in-with-apple to trigger Apple Login UI
131
+ * cordova.plugins.SignInWithApple.signin({
132
+ * requestedScopes: [0, 1]
133
+ * }, function(res) {
134
+ * cordova.plugins.firebase.auth.signInWithApple(res.identityToken).then(function() {
135
+ * console.log("Firebase logged in with Apple");
136
+ * }, function(err) {
137
+ * console.error("Firebase login failed", err);
138
+ * });
139
+ * }, function(err) {
140
+ * console.error("Apple signin failed", err);
141
+ * });
142
+ */
143
+ export function signInWithApple(idToken: string, rawNonce: string): Promise<void>;
144
+ /**
145
+ * You can integrate Firebase Authentication with a custom authentication system
146
+ * by modifying your authentication server to produce custom signed tokens when
147
+ * a user successfully signs in. Your app receives this token and uses it to
148
+ * authenticate with Firebase.
149
+ * @param {string} authToken Custom auth token
150
+ * @returns {Promise<void>} Callback when operation is completed
151
+ *
152
+ * @see https://firebase.google.com/docs/auth/android/custom-auth
153
+ * @see https://firebase.google.com/docs/auth/ios/custom-auth
154
+ */
155
+ export function signInWithCustomToken(authToken: string): Promise<void>;
156
+ /**
157
+ * Signs out the current user and clears it from the disk cache.
158
+ * @returns {Promise<void>} Callback when operation is completed
159
+ *
160
+ * @example
161
+ * cordova.plugins.firebase.auth.signOut();
162
+ */
163
+ export function signOut(): Promise<void>;
164
+ /**
165
+ * Starts the phone number verification process for the given phone number.
166
+ *
167
+ * Android supports auto-verify and instant device verification.
168
+ * <b>You must register `onAuthStateChanged` to get callback on instant verification.</b>
169
+ *
170
+ * Maximum allowed value for timeout is 2 minutes. Use 0 to disable SMS-auto-retrieval.
171
+ * If you specify a positive value less than 30 seconds, library will default to 30 seconds.
172
+ * @param {string} phoneNumber Phone number in international format
173
+ * @param {number} [timeoutMillis] Maximum amount of time you are willing to wait for SMS auto-retrieval to be completed by the library.
174
+ * @returns {Promise<string>} Fulfills promise with <code>verificationId</code> to use later for signing in
175
+ */
176
+ export function verifyPhoneNumber(phoneNumber: string, timeoutMillis?: number): Promise<string>;
177
+ /**
178
+ * Completes phone number verification process and use it to sign in.
179
+ * @param {string} verificationId [description]
180
+ * @param {string} code 6-digit SMS code
181
+ * @returns {Promise<void>} Callback when operation is completed
182
+ *
183
+ * @example
184
+ * cordova.plugins.firebase.auth.verifyPhoneNumber("+123456789").then(function(verificationId) {
185
+ * var code = prompt("Enter verification code");
186
+ * if (code) {
187
+ * return cordova.plugins.firebase.auth.signInWithVerificationId(verificationId, code);
188
+ * }
189
+ * }).catch(function(err) {
190
+ * console.error("Phone number verification failed", err);
191
+ * });
192
+ */
193
+ export function signInWithVerificationId(verificationId: string, code: string): Promise<void>;
194
+ /**
195
+ * Sets languageCode to the app’s current language.
196
+ * @param {string} host Emulator host name
197
+ * @param {number} port Emulator port
198
+ * @returns {Promise<void>} Callback when operation is completed
199
+ *
200
+ * @example
201
+ * cordova.plugins.firebase.auth.useEmulator('localhost', 8000);
202
+ */
203
+ export function useEmulator(host: string, port: number): Promise<void>;
204
+ /**
205
+ * Updates the current user's profile data.
206
+ * Passing a `null` value will delete the current attribute's value, but not
207
+ * passing a property won't change the current attribute's value.
208
+ * @param {{displayName: string; photoURL: string}} profileDetails User attributes.
209
+ * @returns {Promise<void>} Callback when operation is completed
210
+ *
211
+ * @example
212
+ * cordova.plugins.firebase.auth.updateProfile({
213
+ * displayName: "Jane Q. User",
214
+ * photoURL: "https://example.com/jane-q-user/profile.jpg",
215
+ * });
216
+ */
217
+ export function updateProfile(profileDetails: {
218
+ displayName: string;
219
+ photoURL: string;
220
+ }): Promise<void>;
221
+ /**
222
+ * Sets languageCode to the app’s current language.
223
+ * @returns {Promise<void>} Callback when operation is completed
224
+ *
225
+ * @example
226
+ * cordova.plugins.firebase.auth.useAppLanguage();
227
+ */
228
+ export function useAppLanguage(): Promise<void>;
229
+ /**
230
+ * Represents a user's profile information in your Firebase project's user database.
231
+ */
232
+ export type UserDetails = {
233
+ /**
234
+ * String used to uniquely identify your user in your Firebase project's user database
235
+ */
236
+ uid: string;
237
+ /**
238
+ * Main display name of this user from the Firebase project's user database
239
+ */
240
+ displayName: string;
241
+ /**
242
+ * Main email address of the user, as stored in the Firebase project's user database.
243
+ */
244
+ email: string;
245
+ /**
246
+ * <code>true</code> if the user's email is verified.
247
+ */
248
+ emailVerified: boolean;
249
+ /**
250
+ * Phone number of the user, as stored in the Firebase project's user database, or null if none exists.
251
+ */
252
+ phoneNumber: string | null;
253
+ /**
254
+ * URL of this user's main profile picture, as stored in the Firebase project's user database.
255
+ */
256
+ photoURL: string;
257
+ providerId: string;
258
+ };
@@ -0,0 +1,7 @@
1
+ interface CordovaPlugins {
2
+ firebase: FirebasePlugins;
3
+ }
4
+
5
+ interface FirebasePlugins {
6
+ auth: typeof import("./FirebaseAuthentication");
7
+ }