@firebase/auth 0.21.0 → 0.21.1-canary.27b5e7d70

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 +14 -3
  3. package/dist/auth.d.ts +14 -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-100145d2.js} +55 -20
  7. package/dist/cordova/popup_redirect-100145d2.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 +12 -2
  10. package/dist/cordova/test/helpers/mock_auth.d.ts +1 -1
  11. package/dist/esm2017/{index-c6def6da.js → index-8b268dcc.js} +40 -19
  12. package/dist/esm2017/index-8b268dcc.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 +12 -2
  17. package/dist/esm2017/test/helpers/mock_auth.d.ts +1 -1
  18. package/dist/esm5/{index-ef8e1de2.js → index-d0f42d93.js} +55 -20
  19. package/dist/esm5/index-d0f42d93.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 +12 -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-8f4e9d92.js} +10 -12
  28. package/dist/node/{index-2efb81c0.js.map → index-8f4e9d92.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 +12 -2
  34. package/dist/node/test/helpers/mock_auth.d.ts +1 -1
  35. package/dist/node-esm/{index-e0bc98c8.js → index-fe3db70f.js} +16 -17
  36. package/dist/node-esm/{index-e0bc98c8.js.map → index-fe3db70f.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 +12 -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 +46 -9
  45. package/dist/rn/internal.js.map +1 -1
  46. package/dist/rn/{phone-bc99e0b0.js → phone-edfc46b9.js} +10 -12
  47. package/dist/rn/phone-edfc46b9.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 +12 -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 +12 -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,8 @@ 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 {@link https://firebase.google.com/docs/auth/web/redirect-best-practices
24
+ * | best practices} when using {@link signInWithRedirect}.
23
25
  *
24
26
  * @example
25
27
  * ```javascript
@@ -58,6 +60,10 @@ export declare function signInWithRedirect(auth: Auth, provider: AuthProvider, r
58
60
  export declare function _signInWithRedirect(auth: Auth, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<void | never>;
59
61
  /**
60
62
  * Reauthenticates the current user with the specified {@link OAuthProvider} using a full-page redirect flow.
63
+ * @remarks
64
+ * To handle the results and errors for this operation, refer to {@link getRedirectResult}.
65
+ * Follow the {@link https://firebase.google.com/docs/auth/web/redirect-best-practices
66
+ * | best practices} when using {@link reauthenticateWithRedirect}.
61
67
  *
62
68
  * @example
63
69
  * ```javascript
@@ -68,8 +74,8 @@ export declare function _signInWithRedirect(auth: Auth, provider: AuthProvider,
68
74
  *
69
75
  * // After returning from the redirect when your app initializes you can obtain the result
70
76
  * const result = await getRedirectResult(auth);
71
- * // Link using a redirect.
72
- * await linkWithRedirect(result.user, provider);
77
+ * // Reauthenticate using a redirect.
78
+ * await reauthenticateWithRedirect(result.user, provider);
73
79
  * // This will again trigger a full page redirect away from your app
74
80
  *
75
81
  * // After returning from the redirect when your app initializes you can obtain the result
@@ -88,6 +94,10 @@ export declare function reauthenticateWithRedirect(user: User, provider: AuthPro
88
94
  export declare function _reauthenticateWithRedirect(user: User, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<void | never>;
89
95
  /**
90
96
  * Links the {@link OAuthProvider} to the user account using a full-page redirect flow.
97
+ * @remarks
98
+ * To handle the results and errors for this operation, refer to {@link getRedirectResult}.
99
+ * Follow the {@link https://firebase.google.com/docs/auth/web/redirect-best-practices
100
+ * | best practices} when using {@link linkWithRedirect}.
91
101
  *
92
102
  * @example
93
103
  * ```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,8 @@ 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 {@link https://firebase.google.com/docs/auth/web/redirect-best-practices
8366
+ * | best practices} when using {@link signInWithRedirect}.
8366
8367
  *
8367
8368
  * @example
8368
8369
  * ```javascript
@@ -8403,12 +8404,20 @@ function signInWithRedirect(auth, provider, resolver) {
8403
8404
  async function _signInWithRedirect(auth, provider, resolver) {
8404
8405
  const authInternal = _castAuth(auth);
8405
8406
  _assertInstanceOf(auth, provider, FederatedAuthProvider);
8407
+ // Wait for auth initialization to complete, this will process pending redirects and clear the
8408
+ // PENDING_REDIRECT_KEY in persistence. This should be completed before starting a new
8409
+ // redirect and creating a PENDING_REDIRECT_KEY entry.
8410
+ await authInternal._initializationPromise;
8406
8411
  const resolverInternal = _withDefaultResolver(authInternal, resolver);
8407
8412
  await _setPendingRedirectStatus(resolverInternal, authInternal);
8408
8413
  return resolverInternal._openRedirect(authInternal, provider, "signInViaRedirect" /* AuthEventType.SIGN_IN_VIA_REDIRECT */);
8409
8414
  }
8410
8415
  /**
8411
8416
  * Reauthenticates the current user with the specified {@link OAuthProvider} using a full-page redirect flow.
8417
+ * @remarks
8418
+ * To handle the results and errors for this operation, refer to {@link getRedirectResult}.
8419
+ * Follow the {@link https://firebase.google.com/docs/auth/web/redirect-best-practices
8420
+ * | best practices} when using {@link reauthenticateWithRedirect}.
8412
8421
  *
8413
8422
  * @example
8414
8423
  * ```javascript
@@ -8419,8 +8428,8 @@ async function _signInWithRedirect(auth, provider, resolver) {
8419
8428
  *
8420
8429
  * // After returning from the redirect when your app initializes you can obtain the result
8421
8430
  * const result = await getRedirectResult(auth);
8422
- * // Link using a redirect.
8423
- * await linkWithRedirect(result.user, provider);
8431
+ * // Reauthenticate using a redirect.
8432
+ * await reauthenticateWithRedirect(result.user, provider);
8424
8433
  * // This will again trigger a full page redirect away from your app
8425
8434
  *
8426
8435
  * // After returning from the redirect when your app initializes you can obtain the result
@@ -8441,6 +8450,10 @@ function reauthenticateWithRedirect(user, provider, resolver) {
8441
8450
  async function _reauthenticateWithRedirect(user, provider, resolver) {
8442
8451
  const userInternal = getModularInstance(user);
8443
8452
  _assertInstanceOf(userInternal.auth, provider, FederatedAuthProvider);
8453
+ // Wait for auth initialization to complete, this will process pending redirects and clear the
8454
+ // PENDING_REDIRECT_KEY in persistence. This should be completed before starting a new
8455
+ // redirect and creating a PENDING_REDIRECT_KEY entry.
8456
+ await userInternal.auth._initializationPromise;
8444
8457
  // Allow the resolver to error before persisting the redirect user
8445
8458
  const resolverInternal = _withDefaultResolver(userInternal.auth, resolver);
8446
8459
  await _setPendingRedirectStatus(resolverInternal, userInternal.auth);
@@ -8449,6 +8462,10 @@ async function _reauthenticateWithRedirect(user, provider, resolver) {
8449
8462
  }
8450
8463
  /**
8451
8464
  * Links the {@link OAuthProvider} to the user account using a full-page redirect flow.
8465
+ * @remarks
8466
+ * To handle the results and errors for this operation, refer to {@link getRedirectResult}.
8467
+ * Follow the {@link https://firebase.google.com/docs/auth/web/redirect-best-practices
8468
+ * | best practices} when using {@link linkWithRedirect}.
8452
8469
  *
8453
8470
  * @example
8454
8471
  * ```javascript
@@ -8478,6 +8495,10 @@ function linkWithRedirect(user, provider, resolver) {
8478
8495
  async function _linkWithRedirect(user, provider, resolver) {
8479
8496
  const userInternal = getModularInstance(user);
8480
8497
  _assertInstanceOf(userInternal.auth, provider, FederatedAuthProvider);
8498
+ // Wait for auth initialization to complete, this will process pending redirects and clear the
8499
+ // PENDING_REDIRECT_KEY in persistence. This should be completed before starting a new
8500
+ // redirect and creating a PENDING_REDIRECT_KEY entry.
8501
+ await userInternal.auth._initializationPromise;
8481
8502
  // Allow the resolver to error before persisting the redirect user
8482
8503
  const resolverInternal = _withDefaultResolver(userInternal.auth, resolver);
8483
8504
  await _assertLinkedStatus(false, userInternal, provider.providerId);
@@ -9289,7 +9310,7 @@ class PhoneMultiFactorGenerator {
9289
9310
  PhoneMultiFactorGenerator.FACTOR_ID = 'phone';
9290
9311
 
9291
9312
  var name = "@firebase/auth";
9292
- var version = "0.21.0";
9313
+ var version = "0.21.1-canary.27b5e7d70";
9293
9314
 
9294
9315
  /**
9295
9316
  * @license
@@ -9515,4 +9536,4 @@ function getAuth(app = getApp()) {
9515
9536
  registerAuth("Browser" /* ClientPlatform.BROWSER */);
9516
9537
 
9517
9538
  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
9539
+ //# sourceMappingURL=index-8b268dcc.js.map