@react-native-firebase/auth 20.3.0 → 20.4.0

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [20.4.0](https://github.com/invertase/react-native-firebase/compare/v20.3.0...v20.4.0) (2024-08-13)
7
+
8
+ **Note:** Version bump only for package @react-native-firebase/auth
9
+
6
10
  ## [20.3.0](https://github.com/invertase/react-native-firebase/compare/v20.2.1...v20.3.0) (2024-07-19)
7
11
 
8
12
  ### Features
@@ -1,6 +1,62 @@
1
1
  import { describe, expect, it } from '@jest/globals';
2
2
 
3
- import auth, { firebase } from '../lib';
3
+ import auth, {
4
+ firebase,
5
+ getAuth,
6
+ initializeAuth,
7
+ applyActionCode,
8
+ beforeAuthStateChanged,
9
+ checkActionCode,
10
+ confirmPasswordReset,
11
+ connectAuthEmulator,
12
+ createUserWithEmailAndPassword,
13
+ fetchSignInMethodsForEmail,
14
+ getMultiFactorResolver,
15
+ getRedirectResult,
16
+ isSignInWithEmailLink,
17
+ onAuthStateChanged,
18
+ onIdTokenChanged,
19
+ sendPasswordResetEmail,
20
+ sendSignInLinkToEmail,
21
+ setPersistence,
22
+ signInAnonymously,
23
+ signInWithCredential,
24
+ signInWithCustomToken,
25
+ signInWithEmailAndPassword,
26
+ signInWithEmailLink,
27
+ signInWithPhoneNumber,
28
+ verifyPhoneNumber,
29
+ signInWithPopup,
30
+ signInWithRedirect,
31
+ signOut,
32
+ updateCurrentUser,
33
+ useDeviceLanguage,
34
+ useUserAccessGroup,
35
+ verifyPasswordResetCode,
36
+ parseActionCodeURL,
37
+ deleteUser,
38
+ getIdToken,
39
+ getIdTokenResult,
40
+ linkWithCredential,
41
+ linkWithPhoneNumber,
42
+ linkWithPopup,
43
+ linkWithRedirect,
44
+ multiFactor,
45
+ reauthenticateWithCredential,
46
+ reauthenticateWithPhoneNumber,
47
+ reauthenticateWithPopup,
48
+ reauthenticateWithRedirect,
49
+ reload,
50
+ sendEmailVerification,
51
+ unlink,
52
+ updateEmail,
53
+ updatePassword,
54
+ updatePhoneNumber,
55
+ updateProfile,
56
+ verifyBeforeUpdateEmail,
57
+ getAdditionalUserInfo,
58
+ getCustomAuthDomain,
59
+ } from '../lib';
4
60
 
5
61
  // @ts-ignore - We don't mind missing types here
6
62
  import { NativeFirebaseError } from '../../app/lib/internal';
@@ -118,4 +174,222 @@ describe('Auth', function () {
118
174
  expect(actual._auth).not.toBeNull();
119
175
  });
120
176
  });
177
+
178
+ describe('modular', function () {
179
+ it('`getAuth` function is properly exposed to end user', function () {
180
+ expect(getAuth).toBeDefined();
181
+ });
182
+
183
+ it('`initializeAuth` function is properly exposed to end user', function () {
184
+ expect(initializeAuth).toBeDefined();
185
+ });
186
+
187
+ it('`applyActionCode` function is properly exposed to end user', function () {
188
+ expect(applyActionCode).toBeDefined();
189
+ });
190
+
191
+ it('`beforeAuthStateChanged` function is properly exposed to end user', function () {
192
+ expect(beforeAuthStateChanged).toBeDefined();
193
+ });
194
+
195
+ it('`checkActionCode` function is properly exposed to end user', function () {
196
+ expect(checkActionCode).toBeDefined();
197
+ });
198
+
199
+ it('`confirmPasswordReset` function is properly exposed to end user', function () {
200
+ expect(confirmPasswordReset).toBeDefined();
201
+ });
202
+
203
+ it('`connectAuthEmulator` function is properly exposed to end user', function () {
204
+ expect(connectAuthEmulator).toBeDefined();
205
+ });
206
+
207
+ it('`createUserWithEmailAndPassword` function is properly exposed to end user', function () {
208
+ expect(createUserWithEmailAndPassword).toBeDefined();
209
+ });
210
+
211
+ it('`fetchSignInMethodsForEmail` function is properly exposed to end user', function () {
212
+ expect(fetchSignInMethodsForEmail).toBeDefined();
213
+ });
214
+
215
+ it('`getMultiFactorResolver` function is properly exposed to end user', function () {
216
+ expect(getMultiFactorResolver).toBeDefined();
217
+ });
218
+
219
+ it('`getRedirectResult` function is properly exposed to end user', function () {
220
+ expect(getRedirectResult).toBeDefined();
221
+ });
222
+
223
+ it('`isSignInWithEmailLink` function is properly exposed to end user', function () {
224
+ expect(isSignInWithEmailLink).toBeDefined();
225
+ });
226
+
227
+ it('`onAuthStateChanged` function is properly exposed to end user', function () {
228
+ expect(onAuthStateChanged).toBeDefined();
229
+ });
230
+
231
+ it('`onIdTokenChanged` function is properly exposed to end user', function () {
232
+ expect(onIdTokenChanged).toBeDefined();
233
+ });
234
+
235
+ it('`sendPasswordResetEmail` function is properly exposed to end user', function () {
236
+ expect(sendPasswordResetEmail).toBeDefined();
237
+ });
238
+
239
+ it('`sendSignInLinkToEmail` function is properly exposed to end user', function () {
240
+ expect(sendSignInLinkToEmail).toBeDefined();
241
+ });
242
+
243
+ it('`setPersistence` function is properly exposed to end user', function () {
244
+ expect(setPersistence).toBeDefined();
245
+ });
246
+
247
+ it('`signInAnonymously` function is properly exposed to end user', function () {
248
+ expect(signInAnonymously).toBeDefined();
249
+ });
250
+
251
+ it('`signInWithCredential` function is properly exposed to end user', function () {
252
+ expect(signInWithCredential).toBeDefined();
253
+ });
254
+
255
+ it('`signInWithCustomToken` function is properly exposed to end user', function () {
256
+ expect(signInWithCustomToken).toBeDefined();
257
+ });
258
+
259
+ it('`signInWithEmailAndPassword` function is properly exposed to end user', function () {
260
+ expect(signInWithEmailAndPassword).toBeDefined();
261
+ });
262
+
263
+ it('`signInWithEmailLink` function is properly exposed to end user', function () {
264
+ expect(signInWithEmailLink).toBeDefined();
265
+ });
266
+
267
+ it('`signInWithPhoneNumber` function is properly exposed to end user', function () {
268
+ expect(signInWithPhoneNumber).toBeDefined();
269
+ });
270
+
271
+ it('`verifyPhoneNumber` function is properly exposed to end user', function () {
272
+ expect(verifyPhoneNumber).toBeDefined();
273
+ });
274
+
275
+ it('`signInWithPopup` function is properly exposed to end user', function () {
276
+ expect(signInWithPopup).toBeDefined();
277
+ });
278
+
279
+ it('`signInWithRedirect` function is properly exposed to end user', function () {
280
+ expect(signInWithRedirect).toBeDefined();
281
+ });
282
+
283
+ it('`signOut` function is properly exposed to end user', function () {
284
+ expect(signOut).toBeDefined();
285
+ });
286
+
287
+ it('`updateCurrentUser` function is properly exposed to end user', function () {
288
+ expect(updateCurrentUser).toBeDefined();
289
+ });
290
+
291
+ it('`useDeviceLanguage` function is properly exposed to end user', function () {
292
+ expect(useDeviceLanguage).toBeDefined();
293
+ });
294
+
295
+ it('`useUserAccessGroup` function is properly exposed to end user', function () {
296
+ expect(useUserAccessGroup).toBeDefined();
297
+ });
298
+
299
+ it('`verifyPasswordResetCode` function is properly exposed to end user', function () {
300
+ expect(verifyPasswordResetCode).toBeDefined();
301
+ });
302
+
303
+ it('`parseActionCodeURL` function is properly exposed to end user', function () {
304
+ expect(parseActionCodeURL).toBeDefined();
305
+ });
306
+
307
+ it('`deleteUser` function is properly exposed to end user', function () {
308
+ expect(deleteUser).toBeDefined();
309
+ });
310
+
311
+ it('`getIdToken` function is properly exposed to end user', function () {
312
+ expect(getIdToken).toBeDefined();
313
+ });
314
+
315
+ it('`getIdTokenResult` function is properly exposed to end user', function () {
316
+ expect(getIdTokenResult).toBeDefined();
317
+ });
318
+
319
+ it('`linkWithCredential` function is properly exposed to end user', function () {
320
+ expect(linkWithCredential).toBeDefined();
321
+ });
322
+
323
+ it('`linkWithPhoneNumber` function is properly exposed to end user', function () {
324
+ expect(linkWithPhoneNumber).toBeDefined();
325
+ });
326
+
327
+ it('`linkWithPopup` function is properly exposed to end user', function () {
328
+ expect(linkWithPopup).toBeDefined();
329
+ });
330
+
331
+ it('`linkWithRedirect` function is properly exposed to end user', function () {
332
+ expect(linkWithRedirect).toBeDefined();
333
+ });
334
+
335
+ it('`multiFactor` function is properly exposed to end user', function () {
336
+ expect(multiFactor).toBeDefined();
337
+ });
338
+
339
+ it('`reauthenticateWithCredential` function is properly exposed to end user', function () {
340
+ expect(reauthenticateWithCredential).toBeDefined();
341
+ });
342
+
343
+ it('`reauthenticateWithPhoneNumber` function is properly exposed to end user', function () {
344
+ expect(reauthenticateWithPhoneNumber).toBeDefined();
345
+ });
346
+
347
+ it('`reauthenticateWithPopup` function is properly exposed to end user', function () {
348
+ expect(reauthenticateWithPopup).toBeDefined();
349
+ });
350
+
351
+ it('`reauthenticateWithRedirect` function is properly exposed to end user', function () {
352
+ expect(reauthenticateWithRedirect).toBeDefined();
353
+ });
354
+
355
+ it('`reload` function is properly exposed to end user', function () {
356
+ expect(reload).toBeDefined();
357
+ });
358
+
359
+ it('`sendEmailVerification` function is properly exposed to end user', function () {
360
+ expect(sendEmailVerification).toBeDefined();
361
+ });
362
+
363
+ it('`unlink` function is properly exposed to end user', function () {
364
+ expect(unlink).toBeDefined();
365
+ });
366
+
367
+ it('`updateEmail` function is properly exposed to end user', function () {
368
+ expect(updateEmail).toBeDefined();
369
+ });
370
+
371
+ it('`updatePassword` function is properly exposed to end user', function () {
372
+ expect(updatePassword).toBeDefined();
373
+ });
374
+
375
+ it('`updatePhoneNumber` function is properly exposed to end user', function () {
376
+ expect(updatePhoneNumber).toBeDefined();
377
+ });
378
+
379
+ it('`updateProfile` function is properly exposed to end user', function () {
380
+ expect(updateProfile).toBeDefined();
381
+ });
382
+
383
+ it('`verifyBeforeUpdateEmail` function is properly exposed to end user', function () {
384
+ expect(verifyBeforeUpdateEmail).toBeDefined();
385
+ });
386
+
387
+ it('`getAdditionalUserInfo` function is properly exposed to end user', function () {
388
+ expect(getAdditionalUserInfo).toBeDefined();
389
+ });
390
+
391
+ it('`getCustomAuthDomain` function is properly exposed to end user', function () {
392
+ expect(getCustomAuthDomain).toBeDefined();
393
+ });
394
+ });
121
395
  });
package/lib/index.d.ts CHANGED
@@ -2156,10 +2156,24 @@ export namespace FirebaseAuthTypes {
2156
2156
  * @param user The user.
2157
2157
  */
2158
2158
  multiFactor(user: User): MultiFactorUser;
2159
+ /**
2160
+ * Returns the custom auth domain for the auth instance.
2161
+ */
2162
+ getCustomAuthDomain(): Promise<string>;
2163
+ /**
2164
+ * Sets the language code on the auth instance. This is to match Firebase JS SDK behavior.
2165
+ * Please use the `setLanguageCode` method for setting the language code.
2166
+ */
2167
+ set languageCode(code: string | null);
2168
+ /**
2169
+ * Gets the config used to initialize this auth instance. This is to match Firebase JS SDK behavior.
2170
+ * It returns an empty map as the config is not available in the native SDK.
2171
+ */
2172
+ get config(): Map<any, any>;
2159
2173
  }
2160
2174
  }
2161
2175
 
2162
- type CallbackOrObserver<T extends (...args: any[]) => any> = T | { next: T };
2176
+ export type CallbackOrObserver<T extends (...args: any[]) => any> = T | { next: T };
2163
2177
 
2164
2178
  declare const defaultExport: ReactNativeFirebase.FirebaseModuleWithStaticsAndApp<
2165
2179
  FirebaseAuthTypes.Module,
@@ -2188,3 +2202,5 @@ declare module '@react-native-firebase/app' {
2188
2202
  }
2189
2203
  }
2190
2204
  }
2205
+
2206
+ export * from './modular';
package/lib/index.js CHANGED
@@ -47,63 +47,6 @@ import TwitterAuthProvider from './providers/TwitterAuthProvider';
47
47
  import version from './version';
48
48
  import fallBackModule from './web/RNFBAuthModule';
49
49
 
50
- export {
51
- applyActionCode,
52
- beforeAuthStateChanged,
53
- checkActionCode,
54
- confirmPasswordReset,
55
- connectAuthEmulator,
56
- createUserWithEmailAndPassword,
57
- deleteUser,
58
- fetchSignInMethodsForEmail,
59
- getAdditionalUserInfo,
60
- getAuth,
61
- getCustomAuthDomain,
62
- getIdToken,
63
- getIdTokenResult,
64
- getMultiFactorResolver,
65
- getRedirectResult,
66
- initializeAuth,
67
- isSignInWithEmailLink,
68
- linkWithCredential,
69
- linkWithPhoneNumber,
70
- linkWithPopup,
71
- linkWithRedirect,
72
- multiFactor,
73
- onAuthStateChanged,
74
- onIdTokenChanged,
75
- parseActionCodeURL,
76
- reauthenticateWithCredential,
77
- reauthenticateWithPhoneNumber,
78
- reauthenticateWithPopup,
79
- reauthenticateWithRedirect,
80
- reload,
81
- sendEmailVerification,
82
- sendPasswordResetEmail,
83
- sendSignInLinkToEmail,
84
- setPersistence,
85
- signInAnonymously,
86
- signInWithCredential,
87
- signInWithCustomToken,
88
- signInWithEmailAndPassword,
89
- signInWithEmailLink,
90
- signInWithPhoneNumber,
91
- signInWithPopup,
92
- signInWithRedirect,
93
- signOut,
94
- unlink,
95
- updateCurrentUser,
96
- updateEmail,
97
- updatePassword,
98
- updatePhoneNumber,
99
- updateProfile,
100
- useDeviceLanguage,
101
- useUserAccessGroup,
102
- verifyBeforeUpdateEmail,
103
- verifyPasswordResetCode,
104
- verifyPhoneNumber,
105
- } from './modular/index';
106
- // For modular imports
107
50
  export {
108
51
  AppleAuthProvider,
109
52
  EmailAuthProvider,
@@ -187,6 +130,32 @@ class FirebaseAuthModule extends FirebaseModule {
187
130
  return this._languageCode;
188
131
  }
189
132
 
133
+ set languageCode(code) {
134
+ // For modular API, not recommended to set languageCode directly as it should be set in the native SDKs first
135
+ if (!isString(code) && !isNull(code)) {
136
+ throw new Error(
137
+ "firebase.auth().languageCode = (*) expected 'languageCode' to be a string or null value",
138
+ );
139
+ }
140
+ // as this is a setter, we can't use async/await. So we set it first so it is available immediately
141
+ if (code === null) {
142
+ this._languageCode = this.native.APP_LANGUAGE[this.app._name];
143
+
144
+ if (!this.languageCode) {
145
+ this._languageCode = this.native.APP_LANGUAGE['[DEFAULT]'];
146
+ }
147
+ } else {
148
+ this._languageCode = code;
149
+ }
150
+ // This sets it natively
151
+ this.setLanguageCode(code);
152
+ }
153
+
154
+ get config() {
155
+ // for modular API, firebase JS SDK has a config object which is not available in native SDKs
156
+ return {};
157
+ }
158
+
190
159
  get tenantId() {
191
160
  return this._tenantId;
192
161
  }
@@ -530,6 +499,8 @@ export default createModuleNamespace({
530
499
  ModuleClass: FirebaseAuthModule,
531
500
  });
532
501
 
502
+ export * from './modular/index';
503
+
533
504
  // import auth, { firebase } from '@react-native-firebase/auth';
534
505
  // auth().X(...);
535
506
  // firebase.auth().X(...);