@firebase/auth 0.19.3 → 0.19.4

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 (66) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/auth-public.d.ts +1 -2
  3. package/dist/auth.d.ts +2 -3
  4. package/dist/cordova/index.js +2 -2
  5. package/dist/cordova/internal.js +9 -3
  6. package/dist/cordova/internal.js.map +1 -1
  7. package/dist/cordova/{popup_redirect-1cde31c6.js → popup_redirect-958a9598.js} +82 -48
  8. package/dist/cordova/popup_redirect-958a9598.js.map +1 -0
  9. package/dist/cordova/src/api/index.d.ts +2 -1
  10. package/dist/cordova/src/core/auth/auth_impl.d.ts +1 -1
  11. package/dist/cordova/src/model/auth.d.ts +1 -1
  12. package/dist/cordova/src/model/public_types.d.ts +1 -2
  13. package/dist/esm2017/{index-8593558d.js → index-839de510.js} +30 -16
  14. package/dist/esm2017/index-839de510.js.map +1 -0
  15. package/dist/esm2017/index.js +1 -1
  16. package/dist/esm2017/internal.js +2 -2
  17. package/dist/esm2017/src/api/index.d.ts +2 -1
  18. package/dist/esm2017/src/core/auth/auth_impl.d.ts +1 -1
  19. package/dist/esm2017/src/model/auth.d.ts +1 -1
  20. package/dist/esm2017/src/model/public_types.d.ts +1 -2
  21. package/dist/esm5/{index-4f7e1a18.js → index-26e00cb2.js} +89 -49
  22. package/dist/esm5/index-26e00cb2.js.map +1 -0
  23. package/dist/esm5/index.js +1 -1
  24. package/dist/esm5/internal.js +2 -2
  25. package/dist/esm5/src/api/index.d.ts +2 -1
  26. package/dist/esm5/src/core/auth/auth_impl.d.ts +1 -1
  27. package/dist/esm5/src/model/auth.d.ts +1 -1
  28. package/dist/esm5/src/model/public_types.d.ts +1 -2
  29. package/dist/index.webworker.esm5.js +81 -47
  30. package/dist/index.webworker.esm5.js.map +1 -1
  31. package/dist/node/{index-057dcc31.js → index-fe696f9c.js} +82 -48
  32. package/dist/node/index-fe696f9c.js.map +1 -0
  33. package/dist/node/index.js +1 -1
  34. package/dist/node/internal.js +1 -1
  35. package/dist/node/src/api/index.d.ts +2 -1
  36. package/dist/node/src/core/auth/auth_impl.d.ts +1 -1
  37. package/dist/node/src/model/auth.d.ts +1 -1
  38. package/dist/node/src/model/public_types.d.ts +1 -2
  39. package/dist/node-esm/{index-c327074d.js → index-62b96d71.js} +24 -15
  40. package/dist/node-esm/index-62b96d71.js.map +1 -0
  41. package/dist/node-esm/index.js +1 -1
  42. package/dist/node-esm/internal.js +2 -2
  43. package/dist/node-esm/src/api/index.d.ts +2 -1
  44. package/dist/node-esm/src/core/auth/auth_impl.d.ts +1 -1
  45. package/dist/node-esm/src/model/auth.d.ts +1 -1
  46. package/dist/node-esm/src/model/public_types.d.ts +1 -2
  47. package/dist/rn/index.js +1 -1
  48. package/dist/rn/internal.js +8 -2
  49. package/dist/rn/internal.js.map +1 -1
  50. package/dist/rn/{phone-4c7624c1.js → phone-1d904137.js} +82 -48
  51. package/dist/rn/phone-1d904137.js.map +1 -0
  52. package/dist/rn/src/api/index.d.ts +2 -1
  53. package/dist/rn/src/core/auth/auth_impl.d.ts +1 -1
  54. package/dist/rn/src/model/auth.d.ts +1 -1
  55. package/dist/rn/src/model/public_types.d.ts +1 -2
  56. package/dist/src/api/index.d.ts +2 -1
  57. package/dist/src/core/auth/auth_impl.d.ts +1 -1
  58. package/dist/src/model/auth.d.ts +1 -1
  59. package/dist/src/model/public_types.d.ts +1 -2
  60. package/package.json +4 -3
  61. package/dist/cordova/popup_redirect-1cde31c6.js.map +0 -1
  62. package/dist/esm2017/index-8593558d.js.map +0 -1
  63. package/dist/esm5/index-4f7e1a18.js.map +0 -1
  64. package/dist/node/index-057dcc31.js.map +0 -1
  65. package/dist/node-esm/index-c327074d.js.map +0 -1
  66. package/dist/rn/phone-4c7624c1.js.map +0 -1
@@ -27,7 +27,8 @@ export declare const enum HttpMethod {
27
27
  export declare const enum HttpHeader {
28
28
  CONTENT_TYPE = "Content-Type",
29
29
  X_FIREBASE_LOCALE = "X-Firebase-Locale",
30
- X_CLIENT_VERSION = "X-Client-Version"
30
+ X_CLIENT_VERSION = "X-Client-Version",
31
+ X_FIREBASE_GMPID = "X-Firebase-gmpid"
31
32
  }
32
33
  export declare const enum Endpoint {
33
34
  CREATE_AUTH_URI = "/v1/accounts:createAuthUri",
@@ -95,7 +95,7 @@ export declare class AuthImpl implements AuthInternal, _FirebaseService {
95
95
  private clientVersion;
96
96
  _logFramework(framework: string): void;
97
97
  _getFrameworks(): readonly string[];
98
- _getSdkClientVersion(): string;
98
+ _getAdditionalHeaders(): Promise<Record<string, string>>;
99
99
  }
100
100
  /**
101
101
  * Method to be used to cast down to our private implmentation of Auth.
@@ -63,7 +63,7 @@ export interface AuthInternal extends Auth {
63
63
  _getPersistence(): string;
64
64
  _logFramework(framework: string): void;
65
65
  _getFrameworks(): readonly string[];
66
- _getSdkClientVersion(): string;
66
+ _getAdditionalHeaders(): Promise<Record<string, string>>;
67
67
  readonly name: AppName;
68
68
  readonly config: ConfigInternal;
69
69
  languageCode: string | null;
@@ -934,8 +934,7 @@ export interface User extends UserInfo {
934
934
  toJSON(): object;
935
935
  }
936
936
  /**
937
- * A structure containing a {@link User}, an {@link AuthCredential}, the {@link OperationType},
938
- * and any additional user information that was returned from the identity provider.
937
+ * A structure containing a {@link User}, the {@link OperationType}, and the provider ID.
939
938
  *
940
939
  * @remarks
941
940
  * `operationType` could be {@link OperationType}.SIGN_IN for a sign-in operation,
@@ -910,7 +910,7 @@ function _addTidIfNecessary(auth, request) {
910
910
  return request;
911
911
  }
912
912
  async function _performApiRequest(auth, method, path, request, customErrorMap = {}) {
913
- return _performFetchWithErrorHandling(auth, customErrorMap, () => {
913
+ return _performFetchWithErrorHandling(auth, customErrorMap, async () => {
914
914
  let body = {};
915
915
  let params = {};
916
916
  if (request) {
@@ -924,11 +924,10 @@ async function _performApiRequest(auth, method, path, request, customErrorMap =
924
924
  }
925
925
  }
926
926
  const query = querystring(Object.assign({ key: auth.config.apiKey }, params)).slice(1);
927
- const headers = new (FetchProvider.headers())();
928
- headers.set("Content-Type" /* CONTENT_TYPE */, 'application/json');
929
- headers.set("X-Client-Version" /* X_CLIENT_VERSION */, auth._getSdkClientVersion());
927
+ const headers = await auth._getAdditionalHeaders();
928
+ headers["Content-Type" /* CONTENT_TYPE */] = 'application/json';
930
929
  if (auth.languageCode) {
931
- headers.set("X-Firebase-Locale" /* X_FIREBASE_LOCALE */, auth.languageCode);
930
+ headers["X-Firebase-Locale" /* X_FIREBASE_LOCALE */] = auth.languageCode;
932
931
  }
933
932
  return FetchProvider.fetch()(_getFinalTarget(auth, auth.config.apiHost, path, query), Object.assign({ method,
934
933
  headers, referrerPolicy: 'no-referrer' }, body));
@@ -1446,19 +1445,18 @@ function extractProviderData(providers) {
1446
1445
  * limitations under the License.
1447
1446
  */
1448
1447
  async function requestStsToken(auth, refreshToken) {
1449
- const response = await _performFetchWithErrorHandling(auth, {}, () => {
1448
+ const response = await _performFetchWithErrorHandling(auth, {}, async () => {
1450
1449
  const body = querystring({
1451
1450
  'grant_type': 'refresh_token',
1452
1451
  'refresh_token': refreshToken
1453
1452
  }).slice(1);
1454
1453
  const { tokenApiHost, apiKey } = auth.config;
1455
1454
  const url = _getFinalTarget(auth, tokenApiHost, "/v1/token" /* TOKEN */, `key=${apiKey}`);
1455
+ const headers = await auth._getAdditionalHeaders();
1456
+ headers["Content-Type" /* CONTENT_TYPE */] = 'application/x-www-form-urlencoded';
1456
1457
  return FetchProvider.fetch()(url, {
1457
1458
  method: "POST" /* POST */,
1458
- headers: {
1459
- 'X-Client-Version': auth._getSdkClientVersion(),
1460
- 'Content-Type': 'application/x-www-form-urlencoded'
1461
- },
1459
+ headers,
1462
1460
  body
1463
1461
  });
1464
1462
  });
@@ -2185,7 +2183,11 @@ class AuthImpl {
2185
2183
  // Initialize the resolver early if necessary (only applicable to web:
2186
2184
  // this will cause the iframe to load immediately in certain cases)
2187
2185
  if ((_a = this._popupRedirectResolver) === null || _a === void 0 ? void 0 : _a._shouldInitProactively) {
2188
- await this._popupRedirectResolver._initialize(this);
2186
+ // If this fails, don't halt auth loading
2187
+ try {
2188
+ await this._popupRedirectResolver._initialize(this);
2189
+ }
2190
+ catch (e) { /* Ignore the error */ }
2189
2191
  }
2190
2192
  await this.initializeCurrentUser(popupRedirectResolver);
2191
2193
  this.lastNotifiedUid = ((_b = this.currentUser) === null || _b === void 0 ? void 0 : _b.uid) || null;
@@ -2501,8 +2503,15 @@ class AuthImpl {
2501
2503
  _getFrameworks() {
2502
2504
  return this.frameworks;
2503
2505
  }
2504
- _getSdkClientVersion() {
2505
- return this.clientVersion;
2506
+ async _getAdditionalHeaders() {
2507
+ // Additional headers on every request
2508
+ const headers = {
2509
+ ["X-Client-Version" /* X_CLIENT_VERSION */]: this.clientVersion,
2510
+ };
2511
+ if (this.app.options.appId) {
2512
+ headers["X-Firebase-gmpid" /* X_FIREBASE_GMPID */] = this.app.options.appId;
2513
+ }
2514
+ return headers;
2506
2515
  }
2507
2516
  }
2508
2517
  /**
@@ -8685,7 +8694,7 @@ function loadGapi(auth) {
8685
8694
  }
8686
8695
  };
8687
8696
  // Load GApi loader.
8688
- return _loadJS(`https://apis.google.com/js/api.js?onload=${cbName}`);
8697
+ return _loadJS(`https://apis.google.com/js/api.js?onload=${cbName}`).catch(e => reject(e));
8689
8698
  }
8690
8699
  }).catch(error => {
8691
8700
  // Reset cached promise to allow for retrial.
@@ -9006,6 +9015,11 @@ class BrowserPopupRedirectResolver {
9006
9015
  }
9007
9016
  const promise = this.initAndGetManager(auth);
9008
9017
  this.eventManagers[key] = { promise };
9018
+ // If the promise is rejected, the key should be removed so that the
9019
+ // operation can be retried later.
9020
+ promise.catch(() => {
9021
+ delete this.eventManagers[key];
9022
+ });
9009
9023
  return promise;
9010
9024
  }
9011
9025
  async initAndGetManager(auth) {
@@ -9122,7 +9136,7 @@ class PhoneMultiFactorGenerator {
9122
9136
  PhoneMultiFactorGenerator.FACTOR_ID = 'phone';
9123
9137
 
9124
9138
  var name = "@firebase/auth";
9125
- var version = "0.19.3";
9139
+ var version = "0.19.4";
9126
9140
 
9127
9141
  /**
9128
9142
  * @license
@@ -9312,4 +9326,4 @@ function getAuth(app = getApp()) {
9312
9326
  registerAuth("Browser" /* BROWSER */);
9313
9327
 
9314
9328
  export { sendPasswordResetEmail as $, ActionCodeOperation as A, prodErrorMap as B, AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY as C, initializeAuth as D, connectAuthEmulator as E, FactorId as F, AuthCredential as G, EmailAuthCredential as H, OAuthCredential as I, PhoneAuthCredential as J, inMemoryPersistence as K, EmailAuthProvider as L, FacebookAuthProvider as M, GoogleAuthProvider as N, OperationType as O, PhoneAuthProvider as P, GithubAuthProvider as Q, RecaptchaVerifier as R, SignInMethod as S, OAuthProvider as T, SAMLAuthProvider as U, TwitterAuthProvider as V, signInAnonymously as W, signInWithCredential as X, linkWithCredential as Y, reauthenticateWithCredential as Z, signInWithCustomToken as _, browserSessionPersistence as a, confirmPasswordReset as a0, applyActionCode as a1, checkActionCode as a2, verifyPasswordResetCode as a3, createUserWithEmailAndPassword as a4, signInWithEmailAndPassword as a5, sendSignInLinkToEmail as a6, isSignInWithEmailLink as a7, signInWithEmailLink as a8, fetchSignInMethodsForEmail as a9, _getRedirectResult as aA, _clearRedirectOutcomes as aB, _castAuth as aC, UserImpl as aD, AuthImpl as aE, _getClientVersion as aF, _generateEventId as aG, AuthPopup as aH, FetchProvider as aI, SAMLAuthCredential as aJ, sendEmailVerification as aa, verifyBeforeUpdateEmail as ab, ActionCodeURL as ac, parseActionCodeURL as ad, updateProfile as ae, updateEmail as af, updatePassword as ag, getIdToken as ah, getIdTokenResult as ai, unlink as aj, getAdditionalUserInfo as ak, reload as al, getMultiFactorResolver as am, multiFactor as an, _isIOS7Or8 as ao, debugAssert as ap, _isIOS as aq, _isAndroid as ar, _fail as as, _getRedirectUrl as at, _getProjectConfig as au, _createError as av, _assert as aw, _getInstance as ax, _persistenceKeyName as ay, AuthEventManager 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, onAuthStateChanged as t, updatePhoneNumber as u, useDeviceLanguage as v, updateCurrentUser as w, signOut as x, deleteUser as y, debugErrorMap as z };
9315
- //# sourceMappingURL=index-8593558d.js.map
9329
+ //# sourceMappingURL=index-839de510.js.map