firebase 9.6.0 → 9.6.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.
package/firebase-auth.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _getProvider, _registerComponent, SDK_VERSION, registerVersion, getApp } from 'https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js';
1
+ import { _getProvider, _registerComponent, SDK_VERSION, registerVersion, getApp } from 'https://www.gstatic.com/firebasejs/9.6.1/firebase-app.js';
2
2
 
3
3
  /**
4
4
  * @license
@@ -1932,7 +1932,7 @@ function _addTidIfNecessary(auth, request) {
1932
1932
  return request;
1933
1933
  }
1934
1934
  async function _performApiRequest(auth, method, path, request, customErrorMap = {}) {
1935
- return _performFetchWithErrorHandling(auth, customErrorMap, () => {
1935
+ return _performFetchWithErrorHandling(auth, customErrorMap, async () => {
1936
1936
  let body = {};
1937
1937
  let params = {};
1938
1938
  if (request) {
@@ -1946,11 +1946,10 @@ async function _performApiRequest(auth, method, path, request, customErrorMap =
1946
1946
  }
1947
1947
  }
1948
1948
  const query = querystring(Object.assign({ key: auth.config.apiKey }, params)).slice(1);
1949
- const headers = new (FetchProvider.headers())();
1950
- headers.set("Content-Type" /* CONTENT_TYPE */, 'application/json');
1951
- headers.set("X-Client-Version" /* X_CLIENT_VERSION */, auth._getSdkClientVersion());
1949
+ const headers = await auth._getAdditionalHeaders();
1950
+ headers["Content-Type" /* CONTENT_TYPE */] = 'application/json';
1952
1951
  if (auth.languageCode) {
1953
- headers.set("X-Firebase-Locale" /* X_FIREBASE_LOCALE */, auth.languageCode);
1952
+ headers["X-Firebase-Locale" /* X_FIREBASE_LOCALE */] = auth.languageCode;
1954
1953
  }
1955
1954
  return FetchProvider.fetch()(_getFinalTarget(auth, auth.config.apiHost, path, query), Object.assign({ method,
1956
1955
  headers, referrerPolicy: 'no-referrer' }, body));
@@ -2468,19 +2467,18 @@ function extractProviderData(providers) {
2468
2467
  * limitations under the License.
2469
2468
  */
2470
2469
  async function requestStsToken(auth, refreshToken) {
2471
- const response = await _performFetchWithErrorHandling(auth, {}, () => {
2470
+ const response = await _performFetchWithErrorHandling(auth, {}, async () => {
2472
2471
  const body = querystring({
2473
2472
  'grant_type': 'refresh_token',
2474
2473
  'refresh_token': refreshToken
2475
2474
  }).slice(1);
2476
2475
  const { tokenApiHost, apiKey } = auth.config;
2477
2476
  const url = _getFinalTarget(auth, tokenApiHost, "/v1/token" /* TOKEN */, `key=${apiKey}`);
2477
+ const headers = await auth._getAdditionalHeaders();
2478
+ headers["Content-Type" /* CONTENT_TYPE */] = 'application/x-www-form-urlencoded';
2478
2479
  return FetchProvider.fetch()(url, {
2479
2480
  method: "POST" /* POST */,
2480
- headers: {
2481
- 'X-Client-Version': auth._getSdkClientVersion(),
2482
- 'Content-Type': 'application/x-www-form-urlencoded'
2483
- },
2481
+ headers,
2484
2482
  body
2485
2483
  });
2486
2484
  });
@@ -3203,7 +3201,11 @@ class AuthImpl {
3203
3201
  // Initialize the resolver early if necessary (only applicable to web:
3204
3202
  // this will cause the iframe to load immediately in certain cases)
3205
3203
  if ((_a = this._popupRedirectResolver) === null || _a === void 0 ? void 0 : _a._shouldInitProactively) {
3206
- await this._popupRedirectResolver._initialize(this);
3204
+ // If this fails, don't halt auth loading
3205
+ try {
3206
+ await this._popupRedirectResolver._initialize(this);
3207
+ }
3208
+ catch (e) { /* Ignore the error */ }
3207
3209
  }
3208
3210
  await this.initializeCurrentUser(popupRedirectResolver);
3209
3211
  this.lastNotifiedUid = ((_b = this.currentUser) === null || _b === void 0 ? void 0 : _b.uid) || null;
@@ -3519,8 +3521,15 @@ class AuthImpl {
3519
3521
  _getFrameworks() {
3520
3522
  return this.frameworks;
3521
3523
  }
3522
- _getSdkClientVersion() {
3523
- return this.clientVersion;
3524
+ async _getAdditionalHeaders() {
3525
+ // Additional headers on every request
3526
+ const headers = {
3527
+ ["X-Client-Version" /* X_CLIENT_VERSION */]: this.clientVersion,
3528
+ };
3529
+ if (this.app.options.appId) {
3530
+ headers["X-Firebase-gmpid" /* X_FIREBASE_GMPID */] = this.app.options.appId;
3531
+ }
3532
+ return headers;
3524
3533
  }
3525
3534
  }
3526
3535
  /**
@@ -9700,7 +9709,7 @@ function loadGapi(auth) {
9700
9709
  }
9701
9710
  };
9702
9711
  // Load GApi loader.
9703
- return _loadJS(`https://apis.google.com/js/api.js?onload=${cbName}`);
9712
+ return _loadJS(`https://apis.google.com/js/api.js?onload=${cbName}`).catch(e => reject(e));
9704
9713
  }
9705
9714
  }).catch(error => {
9706
9715
  // Reset cached promise to allow for retrial.
@@ -10021,6 +10030,11 @@ class BrowserPopupRedirectResolver {
10021
10030
  }
10022
10031
  const promise = this.initAndGetManager(auth);
10023
10032
  this.eventManagers[key] = { promise };
10033
+ // If the promise is rejected, the key should be removed so that the
10034
+ // operation can be retried later.
10035
+ promise.catch(() => {
10036
+ delete this.eventManagers[key];
10037
+ });
10024
10038
  return promise;
10025
10039
  }
10026
10040
  async initAndGetManager(auth) {
@@ -10137,7 +10151,7 @@ class PhoneMultiFactorGenerator {
10137
10151
  PhoneMultiFactorGenerator.FACTOR_ID = 'phone';
10138
10152
 
10139
10153
  var name = "@firebase/auth";
10140
- var version = "0.19.3";
10154
+ var version = "0.19.4";
10141
10155
 
10142
10156
  /**
10143
10157
  * @license
@@ -10303,7 +10317,7 @@ function registerAuth(clientPlatform) {
10303
10317
  * limitations under the License.
10304
10318
  */
10305
10319
  /**
10306
- * Returns the Auth instance associated with the provided {@link https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js#FirebaseApp}.
10320
+ * Returns the Auth instance associated with the provided {@link https://www.gstatic.com/firebasejs/9.6.1/firebase-app.js#FirebaseApp}.
10307
10321
  * If no instance exists, initializes an Auth instance with platform-specific default dependencies.
10308
10322
  *
10309
10323
  * @param app - The Firebase App.