@firebase/auth 0.21.0 → 0.21.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.
Files changed (46) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/auth-public.d.ts +9 -2
  3. package/dist/auth.d.ts +9 -2
  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-f2a91123.js} +44 -10
  7. package/dist/cordova/{popup_redirect-b7568081.js.map → popup_redirect-f2a91123.js.map} +1 -1
  8. package/dist/cordova/src/platform_browser/strategies/redirect.d.ts +9 -2
  9. package/dist/cordova/test/helpers/mock_auth.d.ts +1 -1
  10. package/dist/esm2017/{index-c6def6da.js → index-e5b3cc81.js} +23 -4
  11. package/dist/esm2017/{index-c6def6da.js.map → index-e5b3cc81.js.map} +1 -1
  12. package/dist/esm2017/index.js +1 -1
  13. package/dist/esm2017/internal.js +2 -2
  14. package/dist/esm2017/src/platform_browser/strategies/redirect.d.ts +9 -2
  15. package/dist/esm2017/test/helpers/mock_auth.d.ts +1 -1
  16. package/dist/esm5/{index-ef8e1de2.js → index-624a9c08.js} +44 -10
  17. package/dist/esm5/{index-ef8e1de2.js.map → index-624a9c08.js.map} +1 -1
  18. package/dist/esm5/index.js +1 -1
  19. package/dist/esm5/internal.js +2 -2
  20. package/dist/esm5/src/platform_browser/strategies/redirect.d.ts +9 -2
  21. package/dist/esm5/test/helpers/mock_auth.d.ts +1 -1
  22. package/dist/index.webworker.esm5.js +1 -1
  23. package/dist/node/{index-2efb81c0.js → index-69e083b1.js} +2 -2
  24. package/dist/node/{index-2efb81c0.js.map → index-69e083b1.js.map} +1 -1
  25. package/dist/node/index.js +1 -1
  26. package/dist/node/internal.js +1 -1
  27. package/dist/node/internal.js.map +1 -1
  28. package/dist/node/src/platform_browser/strategies/redirect.d.ts +9 -2
  29. package/dist/node/test/helpers/mock_auth.d.ts +1 -1
  30. package/dist/node-esm/{index-e0bc98c8.js → index-67ff6dfa.js} +2 -2
  31. package/dist/node-esm/{index-e0bc98c8.js.map → index-67ff6dfa.js.map} +1 -1
  32. package/dist/node-esm/index.js +1 -1
  33. package/dist/node-esm/internal.js +2 -2
  34. package/dist/node-esm/internal.js.map +1 -1
  35. package/dist/node-esm/src/platform_browser/strategies/redirect.d.ts +9 -2
  36. package/dist/node-esm/test/helpers/mock_auth.d.ts +1 -1
  37. package/dist/rn/index.js +1 -1
  38. package/dist/rn/internal.js +43 -9
  39. package/dist/rn/internal.js.map +1 -1
  40. package/dist/rn/{phone-bc99e0b0.js → phone-ec5655af.js} +2 -2
  41. package/dist/rn/{phone-bc99e0b0.js.map → phone-ec5655af.js.map} +1 -1
  42. package/dist/rn/src/platform_browser/strategies/redirect.d.ts +9 -2
  43. package/dist/rn/test/helpers/mock_auth.d.ts +1 -1
  44. package/dist/src/platform_browser/strategies/redirect.d.ts +9 -2
  45. package/dist/test/helpers/mock_auth.d.ts +1 -1
  46. package/package.json +4 -4
@@ -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;
package/dist/rn/index.js CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var ReactNative = require('react-native');
6
6
  var app = require('@firebase/app');
7
- var phone = require('./phone-bc99e0b0.js');
7
+ var phone = require('./phone-ec5655af.js');
8
8
  var tslib = require('tslib');
9
9
  require('@firebase/util');
10
10
  require('@firebase/component');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var phone = require('./phone-bc99e0b0.js');
5
+ var phone = require('./phone-ec5655af.js');
6
6
  var tslib = require('tslib');
7
7
  var util = require('@firebase/util');
8
8
  var app = require('@firebase/app');
@@ -1848,6 +1848,7 @@ function pendingRedirectKey(auth) {
1848
1848
  *
1849
1849
  * @remarks
1850
1850
  * To handle the results and errors for this operation, refer to {@link getRedirectResult}.
1851
+ * Follow the [best practices](https://firebase.google.com/docs/auth/web/redirect-best-practices) when using {@link signInWithRedirect}.
1851
1852
  *
1852
1853
  * @example
1853
1854
  * ```javascript
@@ -1893,9 +1894,18 @@ function _signInWithRedirect(auth, provider, resolver) {
1893
1894
  case 0:
1894
1895
  authInternal = phone._castAuth(auth);
1895
1896
  phone._assertInstanceOf(auth, provider, phone.FederatedAuthProvider);
1897
+ // Wait for auth initialization to complete, this will process pending redirects and clear the
1898
+ // PENDING_REDIRECT_KEY in persistence. This should be completed before starting a new
1899
+ // redirect and creating a PENDING_REDIRECT_KEY entry.
1900
+ return [4 /*yield*/, authInternal._initializationPromise];
1901
+ case 1:
1902
+ // Wait for auth initialization to complete, this will process pending redirects and clear the
1903
+ // PENDING_REDIRECT_KEY in persistence. This should be completed before starting a new
1904
+ // redirect and creating a PENDING_REDIRECT_KEY entry.
1905
+ _a.sent();
1896
1906
  resolverInternal = _withDefaultResolver(authInternal, resolver);
1897
1907
  return [4 /*yield*/, _setPendingRedirectStatus(resolverInternal, authInternal)];
1898
- case 1:
1908
+ case 2:
1899
1909
  _a.sent();
1900
1910
  return [2 /*return*/, resolverInternal._openRedirect(authInternal, provider, "signInViaRedirect" /* AuthEventType.SIGN_IN_VIA_REDIRECT */)];
1901
1911
  }
@@ -1904,6 +1914,9 @@ function _signInWithRedirect(auth, provider, resolver) {
1904
1914
  }
1905
1915
  /**
1906
1916
  * Reauthenticates the current user with the specified {@link OAuthProvider} using a full-page redirect flow.
1917
+ * @remarks
1918
+ * To handle the results and errors for this operation, refer to {@link getRedirectResult}.
1919
+ * Follow the [best practices](https://firebase.google.com/docs/auth/web/redirect-best-practices) when using {@link reauthenticateWithRedirect}.
1907
1920
  *
1908
1921
  * @example
1909
1922
  * ```javascript
@@ -1914,8 +1927,8 @@ function _signInWithRedirect(auth, provider, resolver) {
1914
1927
  *
1915
1928
  * // After returning from the redirect when your app initializes you can obtain the result
1916
1929
  * const result = await getRedirectResult(auth);
1917
- * // Link using a redirect.
1918
- * await linkWithRedirect(result.user, provider);
1930
+ * // Reauthenticate using a redirect.
1931
+ * await reauthenticateWithRedirect(result.user, provider);
1919
1932
  * // This will again trigger a full page redirect away from your app
1920
1933
  *
1921
1934
  * // After returning from the redirect when your app initializes you can obtain the result
@@ -1941,12 +1954,21 @@ function _reauthenticateWithRedirect(user, provider, resolver) {
1941
1954
  case 0:
1942
1955
  userInternal = util.getModularInstance(user);
1943
1956
  phone._assertInstanceOf(userInternal.auth, provider, phone.FederatedAuthProvider);
1957
+ // Wait for auth initialization to complete, this will process pending redirects and clear the
1958
+ // PENDING_REDIRECT_KEY in persistence. This should be completed before starting a new
1959
+ // redirect and creating a PENDING_REDIRECT_KEY entry.
1960
+ return [4 /*yield*/, userInternal.auth._initializationPromise];
1961
+ case 1:
1962
+ // Wait for auth initialization to complete, this will process pending redirects and clear the
1963
+ // PENDING_REDIRECT_KEY in persistence. This should be completed before starting a new
1964
+ // redirect and creating a PENDING_REDIRECT_KEY entry.
1965
+ _a.sent();
1944
1966
  resolverInternal = _withDefaultResolver(userInternal.auth, resolver);
1945
1967
  return [4 /*yield*/, _setPendingRedirectStatus(resolverInternal, userInternal.auth)];
1946
- case 1:
1968
+ case 2:
1947
1969
  _a.sent();
1948
1970
  return [4 /*yield*/, prepareUserForRedirect(userInternal)];
1949
- case 2:
1971
+ case 3:
1950
1972
  eventId = _a.sent();
1951
1973
  return [2 /*return*/, resolverInternal._openRedirect(userInternal.auth, provider, "reauthViaRedirect" /* AuthEventType.REAUTH_VIA_REDIRECT */, eventId)];
1952
1974
  }
@@ -1955,6 +1977,9 @@ function _reauthenticateWithRedirect(user, provider, resolver) {
1955
1977
  }
1956
1978
  /**
1957
1979
  * Links the {@link OAuthProvider} to the user account using a full-page redirect flow.
1980
+ * @remarks
1981
+ * To handle the results and errors for this operation, refer to {@link getRedirectResult}.
1982
+ * Follow the [best practices](https://firebase.google.com/docs/auth/web/redirect-best-practices) when using {@link linkWithRedirect}.
1958
1983
  *
1959
1984
  * @example
1960
1985
  * ```javascript
@@ -1989,15 +2014,24 @@ function _linkWithRedirect(user, provider, resolver) {
1989
2014
  case 0:
1990
2015
  userInternal = util.getModularInstance(user);
1991
2016
  phone._assertInstanceOf(userInternal.auth, provider, phone.FederatedAuthProvider);
2017
+ // Wait for auth initialization to complete, this will process pending redirects and clear the
2018
+ // PENDING_REDIRECT_KEY in persistence. This should be completed before starting a new
2019
+ // redirect and creating a PENDING_REDIRECT_KEY entry.
2020
+ return [4 /*yield*/, userInternal.auth._initializationPromise];
2021
+ case 1:
2022
+ // Wait for auth initialization to complete, this will process pending redirects and clear the
2023
+ // PENDING_REDIRECT_KEY in persistence. This should be completed before starting a new
2024
+ // redirect and creating a PENDING_REDIRECT_KEY entry.
2025
+ _a.sent();
1992
2026
  resolverInternal = _withDefaultResolver(userInternal.auth, resolver);
1993
2027
  return [4 /*yield*/, phone._assertLinkedStatus(false, userInternal, provider.providerId)];
1994
- case 1:
2028
+ case 2:
1995
2029
  _a.sent();
1996
2030
  return [4 /*yield*/, _setPendingRedirectStatus(resolverInternal, userInternal.auth)];
1997
- case 2:
2031
+ case 3:
1998
2032
  _a.sent();
1999
2033
  return [4 /*yield*/, prepareUserForRedirect(userInternal)];
2000
- case 3:
2034
+ case 4:
2001
2035
  eventId = _a.sent();
2002
2036
  return [2 /*return*/, resolverInternal._openRedirect(userInternal.auth, provider, "linkViaRedirect" /* AuthEventType.LINK_VIA_REDIRECT */, eventId)];
2003
2037
  }