@firebase/app-check 0.8.11-canary.d8aabaf9e → 0.8.11-canary.dcfb3da2e
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/dist/esm/index.esm2017.js +28 -14
- package/dist/esm/index.esm2017.js.map +1 -1
- package/dist/index.cjs.js +28 -14
- package/dist/index.cjs.js.map +1 -1
- package/package.json +10 -10
package/dist/index.cjs.js
CHANGED
|
@@ -745,20 +745,34 @@ async function getToken$2(appCheck, forceRefresh = false) {
|
|
|
745
745
|
* Check token using the debug token, and return it directly.
|
|
746
746
|
*/
|
|
747
747
|
if (isDebugMode()) {
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
state.exchangeTokenPromise
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
748
|
+
try {
|
|
749
|
+
// Avoid making another call to the exchange endpoint if one is in flight.
|
|
750
|
+
if (!state.exchangeTokenPromise) {
|
|
751
|
+
state.exchangeTokenPromise = exchangeToken(getExchangeDebugTokenRequest(app, await getDebugToken()), appCheck.heartbeatServiceProvider).finally(() => {
|
|
752
|
+
// Clear promise when settled - either resolved or rejected.
|
|
753
|
+
state.exchangeTokenPromise = undefined;
|
|
754
|
+
});
|
|
755
|
+
shouldCallListeners = true;
|
|
756
|
+
}
|
|
757
|
+
const tokenFromDebugExchange = await state.exchangeTokenPromise;
|
|
758
|
+
// Write debug token to indexedDB.
|
|
759
|
+
await writeTokenToStorage(app, tokenFromDebugExchange);
|
|
760
|
+
// Write debug token to state.
|
|
761
|
+
state.token = tokenFromDebugExchange;
|
|
762
|
+
return { token: tokenFromDebugExchange.token };
|
|
763
|
+
}
|
|
764
|
+
catch (e) {
|
|
765
|
+
if (e.code === `appCheck/${"throttled" /* AppCheckError.THROTTLED */}`) {
|
|
766
|
+
// Warn if throttled, but do not treat it as an error.
|
|
767
|
+
logger.warn(e.message);
|
|
768
|
+
}
|
|
769
|
+
else {
|
|
770
|
+
// `getToken()` should never throw, but logging error text to console will aid debugging.
|
|
771
|
+
logger.error(e);
|
|
772
|
+
}
|
|
773
|
+
// Return dummy token and error
|
|
774
|
+
return makeDummyTokenResult(e);
|
|
755
775
|
}
|
|
756
|
-
const tokenFromDebugExchange = await state.exchangeTokenPromise;
|
|
757
|
-
// Write debug token to indexedDB.
|
|
758
|
-
await writeTokenToStorage(app, tokenFromDebugExchange);
|
|
759
|
-
// Write debug token to state.
|
|
760
|
-
state.token = tokenFromDebugExchange;
|
|
761
|
-
return { token: tokenFromDebugExchange.token };
|
|
762
776
|
}
|
|
763
777
|
/**
|
|
764
778
|
* There are no valid tokens in memory or indexedDB and we are not in
|
|
@@ -1042,7 +1056,7 @@ function internalFactory(appCheck) {
|
|
|
1042
1056
|
}
|
|
1043
1057
|
|
|
1044
1058
|
const name = "@firebase/app-check";
|
|
1045
|
-
const version = "0.8.11-canary.
|
|
1059
|
+
const version = "0.8.11-canary.dcfb3da2e";
|
|
1046
1060
|
|
|
1047
1061
|
/**
|
|
1048
1062
|
* @license
|