@firebase/app-check 0.6.4 → 0.6.5-canary.253b998fc
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/CHANGELOG.md +6 -0
- package/dist/esm/index.esm.js +38 -22
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/index.esm2017.js +24 -8
- package/dist/esm/index.esm2017.js.map +1 -1
- package/dist/esm/src/recaptcha.d.ts +2 -0
- package/dist/esm/src/state.d.ts +1 -0
- package/dist/index.cjs.js +38 -22
- package/dist/index.cjs.js.map +1 -1
- package/dist/src/recaptcha.d.ts +2 -0
- package/dist/src/state.d.ts +1 -0
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @firebase/app-check
|
|
2
2
|
|
|
3
|
+
## 0.6.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`8c44d5863`](https://github.com/firebase/firebase-js-sdk/commit/8c44d586355ffd2d58b6841730ebdac89229954c) [#7203](https://github.com/firebase/firebase-js-sdk/pull/7203) - Catch all ReCAPTCHA errors and, if caught, prevent App Check from making a request to the exchange endpoint.
|
|
8
|
+
|
|
3
9
|
## 0.6.4
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/esm/index.esm.js
CHANGED
|
@@ -1120,7 +1120,7 @@ function internalFactory(appCheck) {
|
|
|
1120
1120
|
}
|
|
1121
1121
|
|
|
1122
1122
|
var name = "@firebase/app-check";
|
|
1123
|
-
var version = "0.6.
|
|
1123
|
+
var version = "0.6.5-canary.253b998fc";
|
|
1124
1124
|
|
|
1125
1125
|
/**
|
|
1126
1126
|
* @license
|
|
@@ -1239,7 +1239,15 @@ function getToken$1(app) {
|
|
|
1239
1239
|
function renderInvisibleWidget(app, siteKey, grecaptcha, container) {
|
|
1240
1240
|
var widgetId = grecaptcha.render(container, {
|
|
1241
1241
|
sitekey: siteKey,
|
|
1242
|
-
size: 'invisible'
|
|
1242
|
+
size: 'invisible',
|
|
1243
|
+
// Success callback - set state
|
|
1244
|
+
callback: function () {
|
|
1245
|
+
getStateReference(app).reCAPTCHAState.succeeded = true;
|
|
1246
|
+
},
|
|
1247
|
+
// Failure callback - set state
|
|
1248
|
+
'error-callback': function () {
|
|
1249
|
+
getStateReference(app).reCAPTCHAState.succeeded = false;
|
|
1250
|
+
}
|
|
1243
1251
|
});
|
|
1244
1252
|
var state = getStateReference(app);
|
|
1245
1253
|
state.reCAPTCHAState = __assign(__assign({}, state.reCAPTCHAState), { // state.reCAPTCHAState is set in the initialize()
|
|
@@ -1298,11 +1306,11 @@ var ReCaptchaV3Provider = /** @class */ (function () {
|
|
|
1298
1306
|
* @internal
|
|
1299
1307
|
*/
|
|
1300
1308
|
ReCaptchaV3Provider.prototype.getToken = function () {
|
|
1301
|
-
var _a, _b;
|
|
1309
|
+
var _a, _b, _c;
|
|
1302
1310
|
return __awaiter(this, void 0, void 0, function () {
|
|
1303
1311
|
var attestedClaimsToken, result, e_1;
|
|
1304
|
-
return __generator(this, function (
|
|
1305
|
-
switch (
|
|
1312
|
+
return __generator(this, function (_d) {
|
|
1313
|
+
switch (_d.label) {
|
|
1306
1314
|
case 0:
|
|
1307
1315
|
throwIfThrottled(this._throttleData);
|
|
1308
1316
|
return [4 /*yield*/, getToken$1(this._app).catch(function (_e) {
|
|
@@ -1310,18 +1318,22 @@ var ReCaptchaV3Provider = /** @class */ (function () {
|
|
|
1310
1318
|
throw ERROR_FACTORY.create("recaptcha-error" /* AppCheckError.RECAPTCHA_ERROR */);
|
|
1311
1319
|
})];
|
|
1312
1320
|
case 1:
|
|
1313
|
-
attestedClaimsToken =
|
|
1314
|
-
|
|
1321
|
+
attestedClaimsToken = _d.sent();
|
|
1322
|
+
// Check if a failure state was set by the recaptcha "error-callback".
|
|
1323
|
+
if (!((_a = getStateReference(this._app).reCAPTCHAState) === null || _a === void 0 ? void 0 : _a.succeeded)) {
|
|
1324
|
+
throw ERROR_FACTORY.create("recaptcha-error" /* AppCheckError.RECAPTCHA_ERROR */);
|
|
1325
|
+
}
|
|
1326
|
+
_d.label = 2;
|
|
1315
1327
|
case 2:
|
|
1316
|
-
|
|
1328
|
+
_d.trys.push([2, 4, , 5]);
|
|
1317
1329
|
return [4 /*yield*/, exchangeToken(getExchangeRecaptchaV3TokenRequest(this._app, attestedClaimsToken), this._heartbeatServiceProvider)];
|
|
1318
1330
|
case 3:
|
|
1319
|
-
result =
|
|
1331
|
+
result = _d.sent();
|
|
1320
1332
|
return [3 /*break*/, 5];
|
|
1321
1333
|
case 4:
|
|
1322
|
-
e_1 =
|
|
1323
|
-
if ((
|
|
1324
|
-
this._throttleData = setBackoff(Number((
|
|
1334
|
+
e_1 = _d.sent();
|
|
1335
|
+
if ((_b = e_1.code) === null || _b === void 0 ? void 0 : _b.includes("fetch-status-error" /* AppCheckError.FETCH_STATUS_ERROR */)) {
|
|
1336
|
+
this._throttleData = setBackoff(Number((_c = e_1.customData) === null || _c === void 0 ? void 0 : _c.httpStatus), this._throttleData);
|
|
1325
1337
|
throw ERROR_FACTORY.create("throttled" /* AppCheckError.THROTTLED */, {
|
|
1326
1338
|
time: getDurationString(this._throttleData.allowRequestsAfter - Date.now()),
|
|
1327
1339
|
httpStatus: this._throttleData.httpStatus
|
|
@@ -1385,11 +1397,11 @@ var ReCaptchaEnterpriseProvider = /** @class */ (function () {
|
|
|
1385
1397
|
* @internal
|
|
1386
1398
|
*/
|
|
1387
1399
|
ReCaptchaEnterpriseProvider.prototype.getToken = function () {
|
|
1388
|
-
var _a, _b;
|
|
1400
|
+
var _a, _b, _c;
|
|
1389
1401
|
return __awaiter(this, void 0, void 0, function () {
|
|
1390
1402
|
var attestedClaimsToken, result, e_2;
|
|
1391
|
-
return __generator(this, function (
|
|
1392
|
-
switch (
|
|
1403
|
+
return __generator(this, function (_d) {
|
|
1404
|
+
switch (_d.label) {
|
|
1393
1405
|
case 0:
|
|
1394
1406
|
throwIfThrottled(this._throttleData);
|
|
1395
1407
|
return [4 /*yield*/, getToken$1(this._app).catch(function (_e) {
|
|
@@ -1397,18 +1409,22 @@ var ReCaptchaEnterpriseProvider = /** @class */ (function () {
|
|
|
1397
1409
|
throw ERROR_FACTORY.create("recaptcha-error" /* AppCheckError.RECAPTCHA_ERROR */);
|
|
1398
1410
|
})];
|
|
1399
1411
|
case 1:
|
|
1400
|
-
attestedClaimsToken =
|
|
1401
|
-
|
|
1412
|
+
attestedClaimsToken = _d.sent();
|
|
1413
|
+
// Check if a failure state was set by the recaptcha "error-callback".
|
|
1414
|
+
if (!((_a = getStateReference(this._app).reCAPTCHAState) === null || _a === void 0 ? void 0 : _a.succeeded)) {
|
|
1415
|
+
throw ERROR_FACTORY.create("recaptcha-error" /* AppCheckError.RECAPTCHA_ERROR */);
|
|
1416
|
+
}
|
|
1417
|
+
_d.label = 2;
|
|
1402
1418
|
case 2:
|
|
1403
|
-
|
|
1419
|
+
_d.trys.push([2, 4, , 5]);
|
|
1404
1420
|
return [4 /*yield*/, exchangeToken(getExchangeRecaptchaEnterpriseTokenRequest(this._app, attestedClaimsToken), this._heartbeatServiceProvider)];
|
|
1405
1421
|
case 3:
|
|
1406
|
-
result =
|
|
1422
|
+
result = _d.sent();
|
|
1407
1423
|
return [3 /*break*/, 5];
|
|
1408
1424
|
case 4:
|
|
1409
|
-
e_2 =
|
|
1410
|
-
if ((
|
|
1411
|
-
this._throttleData = setBackoff(Number((
|
|
1425
|
+
e_2 = _d.sent();
|
|
1426
|
+
if ((_b = e_2.code) === null || _b === void 0 ? void 0 : _b.includes("fetch-status-error" /* AppCheckError.FETCH_STATUS_ERROR */)) {
|
|
1427
|
+
this._throttleData = setBackoff(Number((_c = e_2.customData) === null || _c === void 0 ? void 0 : _c.httpStatus), this._throttleData);
|
|
1412
1428
|
throw ERROR_FACTORY.create("throttled" /* AppCheckError.THROTTLED */, {
|
|
1413
1429
|
time: getDurationString(this._throttleData.allowRequestsAfter - Date.now()),
|
|
1414
1430
|
httpStatus: this._throttleData.httpStatus
|