@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/dist/index.cjs.js
CHANGED
|
@@ -1124,7 +1124,7 @@ function internalFactory(appCheck) {
|
|
|
1124
1124
|
}
|
|
1125
1125
|
|
|
1126
1126
|
var name = "@firebase/app-check";
|
|
1127
|
-
var version = "0.6.
|
|
1127
|
+
var version = "0.6.5-canary.253b998fc";
|
|
1128
1128
|
|
|
1129
1129
|
/**
|
|
1130
1130
|
* @license
|
|
@@ -1243,7 +1243,15 @@ function getToken$1(app) {
|
|
|
1243
1243
|
function renderInvisibleWidget(app, siteKey, grecaptcha, container) {
|
|
1244
1244
|
var widgetId = grecaptcha.render(container, {
|
|
1245
1245
|
sitekey: siteKey,
|
|
1246
|
-
size: 'invisible'
|
|
1246
|
+
size: 'invisible',
|
|
1247
|
+
// Success callback - set state
|
|
1248
|
+
callback: function () {
|
|
1249
|
+
getStateReference(app).reCAPTCHAState.succeeded = true;
|
|
1250
|
+
},
|
|
1251
|
+
// Failure callback - set state
|
|
1252
|
+
'error-callback': function () {
|
|
1253
|
+
getStateReference(app).reCAPTCHAState.succeeded = false;
|
|
1254
|
+
}
|
|
1247
1255
|
});
|
|
1248
1256
|
var state = getStateReference(app);
|
|
1249
1257
|
state.reCAPTCHAState = tslib.__assign(tslib.__assign({}, state.reCAPTCHAState), { // state.reCAPTCHAState is set in the initialize()
|
|
@@ -1302,11 +1310,11 @@ var ReCaptchaV3Provider = /** @class */ (function () {
|
|
|
1302
1310
|
* @internal
|
|
1303
1311
|
*/
|
|
1304
1312
|
ReCaptchaV3Provider.prototype.getToken = function () {
|
|
1305
|
-
var _a, _b;
|
|
1313
|
+
var _a, _b, _c;
|
|
1306
1314
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1307
1315
|
var attestedClaimsToken, result, e_1;
|
|
1308
|
-
return tslib.__generator(this, function (
|
|
1309
|
-
switch (
|
|
1316
|
+
return tslib.__generator(this, function (_d) {
|
|
1317
|
+
switch (_d.label) {
|
|
1310
1318
|
case 0:
|
|
1311
1319
|
throwIfThrottled(this._throttleData);
|
|
1312
1320
|
return [4 /*yield*/, getToken$1(this._app).catch(function (_e) {
|
|
@@ -1314,18 +1322,22 @@ var ReCaptchaV3Provider = /** @class */ (function () {
|
|
|
1314
1322
|
throw ERROR_FACTORY.create("recaptcha-error" /* AppCheckError.RECAPTCHA_ERROR */);
|
|
1315
1323
|
})];
|
|
1316
1324
|
case 1:
|
|
1317
|
-
attestedClaimsToken =
|
|
1318
|
-
|
|
1325
|
+
attestedClaimsToken = _d.sent();
|
|
1326
|
+
// Check if a failure state was set by the recaptcha "error-callback".
|
|
1327
|
+
if (!((_a = getStateReference(this._app).reCAPTCHAState) === null || _a === void 0 ? void 0 : _a.succeeded)) {
|
|
1328
|
+
throw ERROR_FACTORY.create("recaptcha-error" /* AppCheckError.RECAPTCHA_ERROR */);
|
|
1329
|
+
}
|
|
1330
|
+
_d.label = 2;
|
|
1319
1331
|
case 2:
|
|
1320
|
-
|
|
1332
|
+
_d.trys.push([2, 4, , 5]);
|
|
1321
1333
|
return [4 /*yield*/, exchangeToken(getExchangeRecaptchaV3TokenRequest(this._app, attestedClaimsToken), this._heartbeatServiceProvider)];
|
|
1322
1334
|
case 3:
|
|
1323
|
-
result =
|
|
1335
|
+
result = _d.sent();
|
|
1324
1336
|
return [3 /*break*/, 5];
|
|
1325
1337
|
case 4:
|
|
1326
|
-
e_1 =
|
|
1327
|
-
if ((
|
|
1328
|
-
this._throttleData = setBackoff(Number((
|
|
1338
|
+
e_1 = _d.sent();
|
|
1339
|
+
if ((_b = e_1.code) === null || _b === void 0 ? void 0 : _b.includes("fetch-status-error" /* AppCheckError.FETCH_STATUS_ERROR */)) {
|
|
1340
|
+
this._throttleData = setBackoff(Number((_c = e_1.customData) === null || _c === void 0 ? void 0 : _c.httpStatus), this._throttleData);
|
|
1329
1341
|
throw ERROR_FACTORY.create("throttled" /* AppCheckError.THROTTLED */, {
|
|
1330
1342
|
time: getDurationString(this._throttleData.allowRequestsAfter - Date.now()),
|
|
1331
1343
|
httpStatus: this._throttleData.httpStatus
|
|
@@ -1389,11 +1401,11 @@ var ReCaptchaEnterpriseProvider = /** @class */ (function () {
|
|
|
1389
1401
|
* @internal
|
|
1390
1402
|
*/
|
|
1391
1403
|
ReCaptchaEnterpriseProvider.prototype.getToken = function () {
|
|
1392
|
-
var _a, _b;
|
|
1404
|
+
var _a, _b, _c;
|
|
1393
1405
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1394
1406
|
var attestedClaimsToken, result, e_2;
|
|
1395
|
-
return tslib.__generator(this, function (
|
|
1396
|
-
switch (
|
|
1407
|
+
return tslib.__generator(this, function (_d) {
|
|
1408
|
+
switch (_d.label) {
|
|
1397
1409
|
case 0:
|
|
1398
1410
|
throwIfThrottled(this._throttleData);
|
|
1399
1411
|
return [4 /*yield*/, getToken$1(this._app).catch(function (_e) {
|
|
@@ -1401,18 +1413,22 @@ var ReCaptchaEnterpriseProvider = /** @class */ (function () {
|
|
|
1401
1413
|
throw ERROR_FACTORY.create("recaptcha-error" /* AppCheckError.RECAPTCHA_ERROR */);
|
|
1402
1414
|
})];
|
|
1403
1415
|
case 1:
|
|
1404
|
-
attestedClaimsToken =
|
|
1405
|
-
|
|
1416
|
+
attestedClaimsToken = _d.sent();
|
|
1417
|
+
// Check if a failure state was set by the recaptcha "error-callback".
|
|
1418
|
+
if (!((_a = getStateReference(this._app).reCAPTCHAState) === null || _a === void 0 ? void 0 : _a.succeeded)) {
|
|
1419
|
+
throw ERROR_FACTORY.create("recaptcha-error" /* AppCheckError.RECAPTCHA_ERROR */);
|
|
1420
|
+
}
|
|
1421
|
+
_d.label = 2;
|
|
1406
1422
|
case 2:
|
|
1407
|
-
|
|
1423
|
+
_d.trys.push([2, 4, , 5]);
|
|
1408
1424
|
return [4 /*yield*/, exchangeToken(getExchangeRecaptchaEnterpriseTokenRequest(this._app, attestedClaimsToken), this._heartbeatServiceProvider)];
|
|
1409
1425
|
case 3:
|
|
1410
|
-
result =
|
|
1426
|
+
result = _d.sent();
|
|
1411
1427
|
return [3 /*break*/, 5];
|
|
1412
1428
|
case 4:
|
|
1413
|
-
e_2 =
|
|
1414
|
-
if ((
|
|
1415
|
-
this._throttleData = setBackoff(Number((
|
|
1429
|
+
e_2 = _d.sent();
|
|
1430
|
+
if ((_b = e_2.code) === null || _b === void 0 ? void 0 : _b.includes("fetch-status-error" /* AppCheckError.FETCH_STATUS_ERROR */)) {
|
|
1431
|
+
this._throttleData = setBackoff(Number((_c = e_2.customData) === null || _c === void 0 ? void 0 : _c.httpStatus), this._throttleData);
|
|
1416
1432
|
throw ERROR_FACTORY.create("throttled" /* AppCheckError.THROTTLED */, {
|
|
1417
1433
|
time: getDurationString(this._throttleData.allowRequestsAfter - Date.now()),
|
|
1418
1434
|
httpStatus: this._throttleData.httpStatus
|