@firebase/auth 0.21.0 → 0.21.1-canary.68369740a

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.
Files changed (58) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/auth-public.d.ts +11 -3
  3. package/dist/auth.d.ts +11 -3
  4. package/dist/cordova/index.js +2 -2
  5. package/dist/cordova/internal.js +2 -2
  6. package/dist/cordova/{popup_redirect-b7568081.js → popup_redirect-616e0b14.js} +52 -20
  7. package/dist/cordova/popup_redirect-616e0b14.js.map +1 -0
  8. package/dist/cordova/src/core/strategies/credential.d.ts +2 -1
  9. package/dist/cordova/src/platform_browser/strategies/redirect.d.ts +9 -2
  10. package/dist/cordova/test/helpers/mock_auth.d.ts +1 -1
  11. package/dist/esm2017/{index-c6def6da.js → index-af761b12.js} +37 -19
  12. package/dist/esm2017/index-af761b12.js.map +1 -0
  13. package/dist/esm2017/index.js +1 -1
  14. package/dist/esm2017/internal.js +2 -2
  15. package/dist/esm2017/src/core/strategies/credential.d.ts +2 -1
  16. package/dist/esm2017/src/platform_browser/strategies/redirect.d.ts +9 -2
  17. package/dist/esm2017/test/helpers/mock_auth.d.ts +1 -1
  18. package/dist/esm5/{index-ef8e1de2.js → index-4e4377a9.js} +52 -20
  19. package/dist/esm5/index-4e4377a9.js.map +1 -0
  20. package/dist/esm5/index.js +1 -1
  21. package/dist/esm5/internal.js +2 -2
  22. package/dist/esm5/src/core/strategies/credential.d.ts +2 -1
  23. package/dist/esm5/src/platform_browser/strategies/redirect.d.ts +9 -2
  24. package/dist/esm5/test/helpers/mock_auth.d.ts +1 -1
  25. package/dist/index.webworker.esm5.js +9 -11
  26. package/dist/index.webworker.esm5.js.map +1 -1
  27. package/dist/node/{index-2efb81c0.js → index-edd1794a.js} +10 -12
  28. package/dist/node/{index-2efb81c0.js.map → index-edd1794a.js.map} +1 -1
  29. package/dist/node/index.js +1 -1
  30. package/dist/node/internal.js +1 -1
  31. package/dist/node/internal.js.map +1 -1
  32. package/dist/node/src/core/strategies/credential.d.ts +2 -1
  33. package/dist/node/src/platform_browser/strategies/redirect.d.ts +9 -2
  34. package/dist/node/test/helpers/mock_auth.d.ts +1 -1
  35. package/dist/node-esm/{index-e0bc98c8.js → index-d458390f.js} +16 -17
  36. package/dist/node-esm/{index-e0bc98c8.js.map → index-d458390f.js.map} +1 -1
  37. package/dist/node-esm/index.js +1 -1
  38. package/dist/node-esm/internal.js +2 -2
  39. package/dist/node-esm/internal.js.map +1 -1
  40. package/dist/node-esm/src/core/strategies/credential.d.ts +2 -1
  41. package/dist/node-esm/src/platform_browser/strategies/redirect.d.ts +9 -2
  42. package/dist/node-esm/test/helpers/mock_auth.d.ts +1 -1
  43. package/dist/rn/index.js +1 -1
  44. package/dist/rn/internal.js +43 -9
  45. package/dist/rn/internal.js.map +1 -1
  46. package/dist/rn/{phone-bc99e0b0.js → phone-8afa33ea.js} +10 -12
  47. package/dist/rn/phone-8afa33ea.js.map +1 -0
  48. package/dist/rn/src/core/strategies/credential.d.ts +2 -1
  49. package/dist/rn/src/platform_browser/strategies/redirect.d.ts +9 -2
  50. package/dist/rn/test/helpers/mock_auth.d.ts +1 -1
  51. package/dist/src/core/strategies/credential.d.ts +2 -1
  52. package/dist/src/platform_browser/strategies/redirect.d.ts +9 -2
  53. package/dist/test/helpers/mock_auth.d.ts +1 -1
  54. package/package.json +6 -6
  55. package/dist/cordova/popup_redirect-b7568081.js.map +0 -1
  56. package/dist/esm2017/index-c6def6da.js.map +0 -1
  57. package/dist/esm5/index-ef8e1de2.js.map +0 -1
  58. package/dist/rn/phone-bc99e0b0.js.map +0 -1
@@ -47,7 +47,8 @@ export declare function linkWithCredential(user: User, credential: AuthCredentia
47
47
  *
48
48
  * @remarks
49
49
  * Use before operations such as {@link updatePassword} that require tokens from recent sign-in
50
- * attempts. This method can be used to recover from a `CREDENTIAL_TOO_OLD_LOGIN_AGAIN` error.
50
+ * attempts. This method can be used to recover from a `CREDENTIAL_TOO_OLD_LOGIN_AGAIN` error
51
+ * or a `TOKEN_EXPIRED` error.
51
52
  *
52
53
  * @param user - The user.
53
54
  * @param credential - The auth credential.
@@ -20,6 +20,7 @@ import { Auth, AuthProvider, PopupRedirectResolver, User, UserCredential } from
20
20
  *
21
21
  * @remarks
22
22
  * To handle the results and errors for this operation, refer to {@link getRedirectResult}.
23
+ * Follow the [best practices](https://firebase.google.com/docs/auth/web/redirect-best-practices) when using {@link signInWithRedirect}.
23
24
  *
24
25
  * @example
25
26
  * ```javascript
@@ -58,6 +59,9 @@ export declare function signInWithRedirect(auth: Auth, provider: AuthProvider, r
58
59
  export declare function _signInWithRedirect(auth: Auth, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<void | never>;
59
60
  /**
60
61
  * Reauthenticates the current user with the specified {@link OAuthProvider} using a full-page redirect flow.
62
+ * @remarks
63
+ * To handle the results and errors for this operation, refer to {@link getRedirectResult}.
64
+ * Follow the [best practices](https://firebase.google.com/docs/auth/web/redirect-best-practices) when using {@link reauthenticateWithRedirect}.
61
65
  *
62
66
  * @example
63
67
  * ```javascript
@@ -68,8 +72,8 @@ export declare function _signInWithRedirect(auth: Auth, provider: AuthProvider,
68
72
  *
69
73
  * // After returning from the redirect when your app initializes you can obtain the result
70
74
  * const result = await getRedirectResult(auth);
71
- * // Link using a redirect.
72
- * await linkWithRedirect(result.user, provider);
75
+ * // Reauthenticate using a redirect.
76
+ * await reauthenticateWithRedirect(result.user, provider);
73
77
  * // This will again trigger a full page redirect away from your app
74
78
  *
75
79
  * // After returning from the redirect when your app initializes you can obtain the result
@@ -88,6 +92,9 @@ export declare function reauthenticateWithRedirect(user: User, provider: AuthPro
88
92
  export declare function _reauthenticateWithRedirect(user: User, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<void | never>;
89
93
  /**
90
94
  * Links the {@link OAuthProvider} to the user account using a full-page redirect flow.
95
+ * @remarks
96
+ * To handle the results and errors for this operation, refer to {@link getRedirectResult}.
97
+ * Follow the [best practices](https://firebase.google.com/docs/auth/web/redirect-best-practices) when using {@link linkWithRedirect}.
91
98
  *
92
99
  * @example
93
100
  * ```javascript
@@ -38,5 +38,5 @@ export declare class MockPersistenceLayer extends InMemoryPersistence {
38
38
  _set(key: string, object: PersistedBlob): Promise<void>;
39
39
  _remove(key: string): Promise<void>;
40
40
  }
41
- export declare function testAuth(popupRedirectResolver?: PopupRedirectResolver, persistence?: MockPersistenceLayer): Promise<TestAuth>;
41
+ export declare function testAuth(popupRedirectResolver?: PopupRedirectResolver, persistence?: MockPersistenceLayer, skipAwaitOnInit?: boolean): Promise<TestAuth>;
42
42
  export declare function testUser(auth: AuthInternal, uid: string, email?: string, fakeTokens?: boolean): UserInternal;
@@ -4755,7 +4755,8 @@ async function linkWithCredential(user, credential) {
4755
4755
  *
4756
4756
  * @remarks
4757
4757
  * Use before operations such as {@link updatePassword} that require tokens from recent sign-in
4758
- * attempts. This method can be used to recover from a `CREDENTIAL_TOO_OLD_LOGIN_AGAIN` error.
4758
+ * attempts. This method can be used to recover from a `CREDENTIAL_TOO_OLD_LOGIN_AGAIN` error
4759
+ * or a `TOKEN_EXPIRED` error.
4759
4760
  *
4760
4761
  * @param user - The user.
4761
4762
  * @param credential - The auth credential.
@@ -5938,24 +5939,22 @@ class MultiFactorUserImpl {
5938
5939
  async unenroll(infoOrUid) {
5939
5940
  const mfaEnrollmentId = typeof infoOrUid === 'string' ? infoOrUid : infoOrUid.uid;
5940
5941
  const idToken = await this.user.getIdToken();
5941
- const idTokenResponse = await _logoutIfInvalidated(this.user, withdrawMfa(this.user.auth, {
5942
- idToken,
5943
- mfaEnrollmentId
5944
- }));
5945
- // Remove the second factor from the user's list.
5946
- this.enrolledFactors = this.enrolledFactors.filter(({ uid }) => uid !== mfaEnrollmentId);
5947
- // Depending on whether the backend decided to revoke the user's session,
5948
- // the tokenResponse may be empty. If the tokens were not updated (and they
5949
- // are now invalid), reloading the user will discover this and invalidate
5950
- // the user's state accordingly.
5951
- await this.user._updateTokensIfNecessary(idTokenResponse);
5952
5942
  try {
5943
+ const idTokenResponse = await _logoutIfInvalidated(this.user, withdrawMfa(this.user.auth, {
5944
+ idToken,
5945
+ mfaEnrollmentId
5946
+ }));
5947
+ // Remove the second factor from the user's list.
5948
+ this.enrolledFactors = this.enrolledFactors.filter(({ uid }) => uid !== mfaEnrollmentId);
5949
+ // Depending on whether the backend decided to revoke the user's session,
5950
+ // the tokenResponse may be empty. If the tokens were not updated (and they
5951
+ // are now invalid), reloading the user will discover this and invalidate
5952
+ // the user's state accordingly.
5953
+ await this.user._updateTokensIfNecessary(idTokenResponse);
5953
5954
  await this.user.reload();
5954
5955
  }
5955
5956
  catch (e) {
5956
- if ((e === null || e === void 0 ? void 0 : e.code) !== `auth/${"user-token-expired" /* AuthErrorCode.TOKEN_EXPIRED */}`) {
5957
- throw e;
5958
- }
5957
+ throw e;
5959
5958
  }
5960
5959
  }
5961
5960
  }
@@ -8363,6 +8362,7 @@ function pendingRedirectKey(auth) {
8363
8362
  *
8364
8363
  * @remarks
8365
8364
  * To handle the results and errors for this operation, refer to {@link getRedirectResult}.
8365
+ * Follow the [best practices](https://firebase.google.com/docs/auth/web/redirect-best-practices) when using {@link signInWithRedirect}.
8366
8366
  *
8367
8367
  * @example
8368
8368
  * ```javascript
@@ -8403,12 +8403,19 @@ function signInWithRedirect(auth, provider, resolver) {
8403
8403
  async function _signInWithRedirect(auth, provider, resolver) {
8404
8404
  const authInternal = _castAuth(auth);
8405
8405
  _assertInstanceOf(auth, provider, FederatedAuthProvider);
8406
+ // Wait for auth initialization to complete, this will process pending redirects and clear the
8407
+ // PENDING_REDIRECT_KEY in persistence. This should be completed before starting a new
8408
+ // redirect and creating a PENDING_REDIRECT_KEY entry.
8409
+ await authInternal._initializationPromise;
8406
8410
  const resolverInternal = _withDefaultResolver(authInternal, resolver);
8407
8411
  await _setPendingRedirectStatus(resolverInternal, authInternal);
8408
8412
  return resolverInternal._openRedirect(authInternal, provider, "signInViaRedirect" /* AuthEventType.SIGN_IN_VIA_REDIRECT */);
8409
8413
  }
8410
8414
  /**
8411
8415
  * Reauthenticates the current user with the specified {@link OAuthProvider} using a full-page redirect flow.
8416
+ * @remarks
8417
+ * To handle the results and errors for this operation, refer to {@link getRedirectResult}.
8418
+ * Follow the [best practices](https://firebase.google.com/docs/auth/web/redirect-best-practices) when using {@link reauthenticateWithRedirect}.
8412
8419
  *
8413
8420
  * @example
8414
8421
  * ```javascript
@@ -8419,8 +8426,8 @@ async function _signInWithRedirect(auth, provider, resolver) {
8419
8426
  *
8420
8427
  * // After returning from the redirect when your app initializes you can obtain the result
8421
8428
  * const result = await getRedirectResult(auth);
8422
- * // Link using a redirect.
8423
- * await linkWithRedirect(result.user, provider);
8429
+ * // Reauthenticate using a redirect.
8430
+ * await reauthenticateWithRedirect(result.user, provider);
8424
8431
  * // This will again trigger a full page redirect away from your app
8425
8432
  *
8426
8433
  * // After returning from the redirect when your app initializes you can obtain the result
@@ -8441,6 +8448,10 @@ function reauthenticateWithRedirect(user, provider, resolver) {
8441
8448
  async function _reauthenticateWithRedirect(user, provider, resolver) {
8442
8449
  const userInternal = getModularInstance(user);
8443
8450
  _assertInstanceOf(userInternal.auth, provider, FederatedAuthProvider);
8451
+ // Wait for auth initialization to complete, this will process pending redirects and clear the
8452
+ // PENDING_REDIRECT_KEY in persistence. This should be completed before starting a new
8453
+ // redirect and creating a PENDING_REDIRECT_KEY entry.
8454
+ await userInternal.auth._initializationPromise;
8444
8455
  // Allow the resolver to error before persisting the redirect user
8445
8456
  const resolverInternal = _withDefaultResolver(userInternal.auth, resolver);
8446
8457
  await _setPendingRedirectStatus(resolverInternal, userInternal.auth);
@@ -8449,6 +8460,9 @@ async function _reauthenticateWithRedirect(user, provider, resolver) {
8449
8460
  }
8450
8461
  /**
8451
8462
  * Links the {@link OAuthProvider} to the user account using a full-page redirect flow.
8463
+ * @remarks
8464
+ * To handle the results and errors for this operation, refer to {@link getRedirectResult}.
8465
+ * Follow the [best practices](https://firebase.google.com/docs/auth/web/redirect-best-practices) when using {@link linkWithRedirect}.
8452
8466
  *
8453
8467
  * @example
8454
8468
  * ```javascript
@@ -8478,6 +8492,10 @@ function linkWithRedirect(user, provider, resolver) {
8478
8492
  async function _linkWithRedirect(user, provider, resolver) {
8479
8493
  const userInternal = getModularInstance(user);
8480
8494
  _assertInstanceOf(userInternal.auth, provider, FederatedAuthProvider);
8495
+ // Wait for auth initialization to complete, this will process pending redirects and clear the
8496
+ // PENDING_REDIRECT_KEY in persistence. This should be completed before starting a new
8497
+ // redirect and creating a PENDING_REDIRECT_KEY entry.
8498
+ await userInternal.auth._initializationPromise;
8481
8499
  // Allow the resolver to error before persisting the redirect user
8482
8500
  const resolverInternal = _withDefaultResolver(userInternal.auth, resolver);
8483
8501
  await _assertLinkedStatus(false, userInternal, provider.providerId);
@@ -9289,7 +9307,7 @@ class PhoneMultiFactorGenerator {
9289
9307
  PhoneMultiFactorGenerator.FACTOR_ID = 'phone';
9290
9308
 
9291
9309
  var name = "@firebase/auth";
9292
- var version = "0.21.0";
9310
+ var version = "0.21.1-canary.68369740a";
9293
9311
 
9294
9312
  /**
9295
9313
  * @license
@@ -9515,4 +9533,4 @@ function getAuth(app = getApp()) {
9515
9533
  registerAuth("Browser" /* ClientPlatform.BROWSER */);
9516
9534
 
9517
9535
  export { signInWithCustomToken as $, ActionCodeOperation as A, debugErrorMap as B, prodErrorMap as C, AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY as D, initializeAuth as E, FactorId as F, connectAuthEmulator as G, AuthCredential as H, EmailAuthCredential as I, OAuthCredential as J, PhoneAuthCredential as K, inMemoryPersistence as L, EmailAuthProvider as M, FacebookAuthProvider as N, OperationType as O, PhoneAuthProvider as P, GoogleAuthProvider as Q, RecaptchaVerifier as R, SignInMethod as S, GithubAuthProvider as T, OAuthProvider as U, SAMLAuthProvider as V, TwitterAuthProvider as W, signInAnonymously as X, signInWithCredential as Y, linkWithCredential as Z, reauthenticateWithCredential as _, browserSessionPersistence as a, sendPasswordResetEmail as a0, confirmPasswordReset as a1, applyActionCode as a2, checkActionCode as a3, verifyPasswordResetCode as a4, createUserWithEmailAndPassword as a5, signInWithEmailAndPassword as a6, sendSignInLinkToEmail as a7, isSignInWithEmailLink as a8, signInWithEmailLink as a9, _persistenceKeyName as aA, _getRedirectResult as aB, _overrideRedirectResult as aC, _clearRedirectOutcomes as aD, _castAuth as aE, UserImpl as aF, AuthImpl as aG, _getClientVersion as aH, _generateEventId as aI, AuthPopup as aJ, FetchProvider as aK, SAMLAuthCredential as aL, fetchSignInMethodsForEmail as aa, sendEmailVerification as ab, verifyBeforeUpdateEmail as ac, ActionCodeURL as ad, parseActionCodeURL as ae, updateProfile as af, updateEmail as ag, updatePassword as ah, getIdToken as ai, getIdTokenResult as aj, unlink as ak, getAdditionalUserInfo as al, reload as am, getMultiFactorResolver as an, multiFactor as ao, debugAssert as ap, _isIOS as aq, _isAndroid as ar, _fail as as, _getRedirectUrl as at, _getProjectConfig as au, _isIOS7Or8 as av, _createError as aw, _assert as ax, AuthEventManager as ay, _getInstance as az, browserLocalPersistence as b, signInWithPopup as c, linkWithPopup as d, reauthenticateWithPopup as e, signInWithRedirect as f, linkWithRedirect as g, reauthenticateWithRedirect as h, indexedDBLocalPersistence as i, getRedirectResult as j, browserPopupRedirectResolver as k, linkWithPhoneNumber as l, PhoneMultiFactorGenerator as m, getAuth as n, ProviderId as o, setPersistence as p, onIdTokenChanged as q, reauthenticateWithPhoneNumber as r, signInWithPhoneNumber as s, beforeAuthStateChanged as t, updatePhoneNumber as u, onAuthStateChanged as v, useDeviceLanguage as w, updateCurrentUser as x, signOut as y, deleteUser as z };
9518
- //# sourceMappingURL=index-c6def6da.js.map
9536
+ //# sourceMappingURL=index-af761b12.js.map