@firebase/app-check 0.8.12-canary.a24a76aa2 → 0.8.12-canary.cf3c8fb2a

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.
@@ -233,7 +233,8 @@ const ERRORS = {
233
233
  ["storage-get" /* AppCheckError.STORAGE_GET */]: 'Error thrown when reading from storage. Original error: {$originalErrorMessage}.',
234
234
  ["storage-set" /* AppCheckError.STORAGE_WRITE */]: 'Error thrown when writing to storage. Original error: {$originalErrorMessage}.',
235
235
  ["recaptcha-error" /* AppCheckError.RECAPTCHA_ERROR */]: 'ReCAPTCHA error.',
236
- ["throttled" /* AppCheckError.THROTTLED */]: `Requests throttled due to {$httpStatus} error. Attempts allowed again after {$time}`
236
+ ["initial-throttle" /* AppCheckError.INITIAL_THROTTLE */]: `{$httpStatus} error. Attempts allowed again after {$time}`,
237
+ ["throttled" /* AppCheckError.THROTTLED */]: `Requests throttled due to previous {$httpStatus} error. Attempts allowed again after {$time}`
237
238
  };
238
239
  const ERROR_FACTORY = new ErrorFactory('appCheck', 'AppCheck', ERRORS);
239
240
 
@@ -692,7 +693,7 @@ function formatDummyToken(tokenErrorData) {
692
693
  * The result will contain an error field if there is any error.
693
694
  * In case there is an error, the token field in the result will be populated with a dummy value
694
695
  */
695
- async function getToken$2(appCheck, forceRefresh = false) {
696
+ async function getToken$2(appCheck, forceRefresh = false, shouldLogErrors = false) {
696
697
  const app = appCheck.app;
697
698
  ensureActivated(app);
698
699
  const state = getStateReference(app);
@@ -758,12 +759,13 @@ async function getToken$2(appCheck, forceRefresh = false) {
758
759
  return { token: tokenFromDebugExchange.token };
759
760
  }
760
761
  catch (e) {
761
- if (e.code === `appCheck/${"throttled" /* AppCheckError.THROTTLED */}`) {
762
+ if (e.code === `appCheck/${"throttled" /* AppCheckError.THROTTLED */}` ||
763
+ e.code ===
764
+ `appCheck/${"initial-throttle" /* AppCheckError.INITIAL_THROTTLE */}`) {
762
765
  // Warn if throttled, but do not treat it as an error.
763
766
  logger.warn(e.message);
764
767
  }
765
- else {
766
- // `getToken()` should never throw, but logging error text to console will aid debugging.
768
+ else if (shouldLogErrors) {
767
769
  logger.error(e);
768
770
  }
769
771
  // Return dummy token and error
@@ -790,12 +792,12 @@ async function getToken$2(appCheck, forceRefresh = false) {
790
792
  token = await getStateReference(app).exchangeTokenPromise;
791
793
  }
792
794
  catch (e) {
793
- if (e.code === `appCheck/${"throttled" /* AppCheckError.THROTTLED */}`) {
795
+ if (e.code === `appCheck/${"throttled" /* AppCheckError.THROTTLED */}` ||
796
+ e.code === `appCheck/${"initial-throttle" /* AppCheckError.INITIAL_THROTTLE */}`) {
794
797
  // Warn if throttled, but do not treat it as an error.
795
798
  logger.warn(e.message);
796
799
  }
797
- else {
798
- // `getToken()` should never throw, but logging error text to console will aid debugging.
800
+ else if (shouldLogErrors) {
799
801
  logger.error(e);
800
802
  }
801
803
  // Always save error to be added to dummy token.
@@ -1052,7 +1054,7 @@ function internalFactory(appCheck) {
1052
1054
  }
1053
1055
 
1054
1056
  const name = "@firebase/app-check";
1055
- const version = "0.8.12-canary.a24a76aa2";
1057
+ const version = "0.8.12-canary.cf3c8fb2a";
1056
1058
 
1057
1059
  /**
1058
1060
  * @license
@@ -1248,7 +1250,7 @@ class ReCaptchaV3Provider {
1248
1250
  catch (e) {
1249
1251
  if ((_b = e.code) === null || _b === void 0 ? void 0 : _b.includes("fetch-status-error" /* AppCheckError.FETCH_STATUS_ERROR */)) {
1250
1252
  this._throttleData = setBackoff(Number((_c = e.customData) === null || _c === void 0 ? void 0 : _c.httpStatus), this._throttleData);
1251
- throw ERROR_FACTORY.create("throttled" /* AppCheckError.THROTTLED */, {
1253
+ throw ERROR_FACTORY.create("initial-throttle" /* AppCheckError.INITIAL_THROTTLE */, {
1252
1254
  time: getDurationString(this._throttleData.allowRequestsAfter - Date.now()),
1253
1255
  httpStatus: this._throttleData.httpStatus
1254
1256
  });
@@ -1326,7 +1328,7 @@ class ReCaptchaEnterpriseProvider {
1326
1328
  catch (e) {
1327
1329
  if ((_b = e.code) === null || _b === void 0 ? void 0 : _b.includes("fetch-status-error" /* AppCheckError.FETCH_STATUS_ERROR */)) {
1328
1330
  this._throttleData = setBackoff(Number((_c = e.customData) === null || _c === void 0 ? void 0 : _c.httpStatus), this._throttleData);
1329
- throw ERROR_FACTORY.create("throttled" /* AppCheckError.THROTTLED */, {
1331
+ throw ERROR_FACTORY.create("initial-throttle" /* AppCheckError.INITIAL_THROTTLE */, {
1330
1332
  time: getDurationString(this._throttleData.allowRequestsAfter - Date.now()),
1331
1333
  httpStatus: this._throttleData.httpStatus
1332
1334
  });
@@ -1598,6 +1600,9 @@ async function getToken(appCheckInstance, forceRefresh) {
1598
1600
  if (result.error) {
1599
1601
  throw result.error;
1600
1602
  }
1603
+ if (result.internalError) {
1604
+ throw result.internalError;
1605
+ }
1601
1606
  return { token: result.token };
1602
1607
  }
1603
1608
  /**