@firebase/app-check 0.5.17 → 0.6.0
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 +13 -0
- package/dist/esm/index.esm.js +64 -65
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/index.esm2017.js +39 -41
- package/dist/esm/index.esm2017.js.map +1 -1
- package/dist/index.cjs.js +64 -65
- package/dist/index.cjs.js.map +1 -1
- package/package.json +6 -6
package/dist/index.cjs.js
CHANGED
|
@@ -239,22 +239,22 @@ function sleep(ms) {
|
|
|
239
239
|
*/
|
|
240
240
|
var _a;
|
|
241
241
|
var ERRORS = (_a = {},
|
|
242
|
-
_a["already-initialized" /* ALREADY_INITIALIZED */] = 'You have already called initializeAppCheck() for FirebaseApp {$appName} with ' +
|
|
242
|
+
_a["already-initialized" /* AppCheckError.ALREADY_INITIALIZED */] = 'You have already called initializeAppCheck() for FirebaseApp {$appName} with ' +
|
|
243
243
|
'different options. To avoid this error, call initializeAppCheck() with the ' +
|
|
244
244
|
'same options as when it was originally called. This will return the ' +
|
|
245
245
|
'already initialized instance.',
|
|
246
|
-
_a["use-before-activation" /* USE_BEFORE_ACTIVATION */] = 'App Check is being used before initializeAppCheck() is called for FirebaseApp {$appName}. ' +
|
|
246
|
+
_a["use-before-activation" /* AppCheckError.USE_BEFORE_ACTIVATION */] = 'App Check is being used before initializeAppCheck() is called for FirebaseApp {$appName}. ' +
|
|
247
247
|
'Call initializeAppCheck() before instantiating other Firebase services.',
|
|
248
|
-
_a["fetch-network-error" /* FETCH_NETWORK_ERROR */] = 'Fetch failed to connect to a network. Check Internet connection. ' +
|
|
248
|
+
_a["fetch-network-error" /* AppCheckError.FETCH_NETWORK_ERROR */] = 'Fetch failed to connect to a network. Check Internet connection. ' +
|
|
249
249
|
'Original error: {$originalErrorMessage}.',
|
|
250
|
-
_a["fetch-parse-error" /* FETCH_PARSE_ERROR */] = 'Fetch client could not parse response.' +
|
|
250
|
+
_a["fetch-parse-error" /* AppCheckError.FETCH_PARSE_ERROR */] = 'Fetch client could not parse response.' +
|
|
251
251
|
' Original error: {$originalErrorMessage}.',
|
|
252
|
-
_a["fetch-status-error" /* FETCH_STATUS_ERROR */] = 'Fetch server returned an HTTP error status. HTTP status: {$httpStatus}.',
|
|
253
|
-
_a["storage-open" /* STORAGE_OPEN */] = 'Error thrown when opening storage. Original error: {$originalErrorMessage}.',
|
|
254
|
-
_a["storage-get" /* STORAGE_GET */] = 'Error thrown when reading from storage. Original error: {$originalErrorMessage}.',
|
|
255
|
-
_a["storage-set" /* STORAGE_WRITE */] = 'Error thrown when writing to storage. Original error: {$originalErrorMessage}.',
|
|
256
|
-
_a["recaptcha-error" /* RECAPTCHA_ERROR */] = 'ReCAPTCHA error.',
|
|
257
|
-
_a["throttled" /* THROTTLED */] = "Requests throttled due to {$httpStatus} error. Attempts allowed again after {$time}",
|
|
252
|
+
_a["fetch-status-error" /* AppCheckError.FETCH_STATUS_ERROR */] = 'Fetch server returned an HTTP error status. HTTP status: {$httpStatus}.',
|
|
253
|
+
_a["storage-open" /* AppCheckError.STORAGE_OPEN */] = 'Error thrown when opening storage. Original error: {$originalErrorMessage}.',
|
|
254
|
+
_a["storage-get" /* AppCheckError.STORAGE_GET */] = 'Error thrown when reading from storage. Original error: {$originalErrorMessage}.',
|
|
255
|
+
_a["storage-set" /* AppCheckError.STORAGE_WRITE */] = 'Error thrown when writing to storage. Original error: {$originalErrorMessage}.',
|
|
256
|
+
_a["recaptcha-error" /* AppCheckError.RECAPTCHA_ERROR */] = 'ReCAPTCHA error.',
|
|
257
|
+
_a["throttled" /* AppCheckError.THROTTLED */] = "Requests throttled due to {$httpStatus} error. Attempts allowed again after {$time}",
|
|
258
258
|
_a);
|
|
259
259
|
var ERROR_FACTORY = new util.ErrorFactory('appCheck', 'AppCheck', ERRORS);
|
|
260
260
|
|
|
@@ -284,7 +284,7 @@ function getRecaptcha(isEnterprise) {
|
|
|
284
284
|
}
|
|
285
285
|
function ensureActivated(app) {
|
|
286
286
|
if (!getStateReference(app).activated) {
|
|
287
|
-
throw ERROR_FACTORY.create("use-before-activation" /* USE_BEFORE_ACTIVATION */, {
|
|
287
|
+
throw ERROR_FACTORY.create("use-before-activation" /* AppCheckError.USE_BEFORE_ACTIVATION */, {
|
|
288
288
|
appName: app.name
|
|
289
289
|
});
|
|
290
290
|
}
|
|
@@ -329,12 +329,11 @@ function pad(value) {
|
|
|
329
329
|
* limitations under the License.
|
|
330
330
|
*/
|
|
331
331
|
function exchangeToken(_a, heartbeatServiceProvider) {
|
|
332
|
-
var _b, _c;
|
|
333
332
|
var url = _a.url, body = _a.body;
|
|
334
333
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
335
334
|
var headers, heartbeatService, heartbeatsHeader, options, response, originalError_1, responseBody, originalError_2, match, timeToLiveAsNumber, now;
|
|
336
|
-
return tslib.__generator(this, function (
|
|
337
|
-
switch (
|
|
335
|
+
return tslib.__generator(this, function (_b) {
|
|
336
|
+
switch (_b.label) {
|
|
338
337
|
case 0:
|
|
339
338
|
headers = {
|
|
340
339
|
'Content-Type': 'application/json'
|
|
@@ -345,54 +344,54 @@ function exchangeToken(_a, heartbeatServiceProvider) {
|
|
|
345
344
|
if (!heartbeatService) return [3 /*break*/, 2];
|
|
346
345
|
return [4 /*yield*/, heartbeatService.getHeartbeatsHeader()];
|
|
347
346
|
case 1:
|
|
348
|
-
heartbeatsHeader =
|
|
347
|
+
heartbeatsHeader = _b.sent();
|
|
349
348
|
if (heartbeatsHeader) {
|
|
350
349
|
headers['X-Firebase-Client'] = heartbeatsHeader;
|
|
351
350
|
}
|
|
352
|
-
|
|
351
|
+
_b.label = 2;
|
|
353
352
|
case 2:
|
|
354
353
|
options = {
|
|
355
354
|
method: 'POST',
|
|
356
355
|
body: JSON.stringify(body),
|
|
357
356
|
headers: headers
|
|
358
357
|
};
|
|
359
|
-
|
|
358
|
+
_b.label = 3;
|
|
360
359
|
case 3:
|
|
361
|
-
|
|
360
|
+
_b.trys.push([3, 5, , 6]);
|
|
362
361
|
return [4 /*yield*/, fetch(url, options)];
|
|
363
362
|
case 4:
|
|
364
|
-
response =
|
|
363
|
+
response = _b.sent();
|
|
365
364
|
return [3 /*break*/, 6];
|
|
366
365
|
case 5:
|
|
367
|
-
originalError_1 =
|
|
368
|
-
throw ERROR_FACTORY.create("fetch-network-error" /* FETCH_NETWORK_ERROR */, {
|
|
369
|
-
originalErrorMessage:
|
|
366
|
+
originalError_1 = _b.sent();
|
|
367
|
+
throw ERROR_FACTORY.create("fetch-network-error" /* AppCheckError.FETCH_NETWORK_ERROR */, {
|
|
368
|
+
originalErrorMessage: originalError_1 === null || originalError_1 === void 0 ? void 0 : originalError_1.message
|
|
370
369
|
});
|
|
371
370
|
case 6:
|
|
372
371
|
if (response.status !== 200) {
|
|
373
|
-
throw ERROR_FACTORY.create("fetch-status-error" /* FETCH_STATUS_ERROR */, {
|
|
372
|
+
throw ERROR_FACTORY.create("fetch-status-error" /* AppCheckError.FETCH_STATUS_ERROR */, {
|
|
374
373
|
httpStatus: response.status
|
|
375
374
|
});
|
|
376
375
|
}
|
|
377
|
-
|
|
376
|
+
_b.label = 7;
|
|
378
377
|
case 7:
|
|
379
|
-
|
|
378
|
+
_b.trys.push([7, 9, , 10]);
|
|
380
379
|
return [4 /*yield*/, response.json()];
|
|
381
380
|
case 8:
|
|
382
381
|
// JSON parsing throws SyntaxError if the response body isn't a JSON string.
|
|
383
|
-
responseBody =
|
|
382
|
+
responseBody = _b.sent();
|
|
384
383
|
return [3 /*break*/, 10];
|
|
385
384
|
case 9:
|
|
386
|
-
originalError_2 =
|
|
387
|
-
throw ERROR_FACTORY.create("fetch-parse-error" /* FETCH_PARSE_ERROR */, {
|
|
388
|
-
originalErrorMessage:
|
|
385
|
+
originalError_2 = _b.sent();
|
|
386
|
+
throw ERROR_FACTORY.create("fetch-parse-error" /* AppCheckError.FETCH_PARSE_ERROR */, {
|
|
387
|
+
originalErrorMessage: originalError_2 === null || originalError_2 === void 0 ? void 0 : originalError_2.message
|
|
389
388
|
});
|
|
390
389
|
case 10:
|
|
391
390
|
match = responseBody.ttl.match(/^([\d.]+)(s)$/);
|
|
392
391
|
if (!match || !match[2] || isNaN(Number(match[1]))) {
|
|
393
|
-
throw ERROR_FACTORY.create("fetch-parse-error" /* FETCH_PARSE_ERROR */, {
|
|
392
|
+
throw ERROR_FACTORY.create("fetch-parse-error" /* AppCheckError.FETCH_PARSE_ERROR */, {
|
|
394
393
|
originalErrorMessage: "ttl field (timeToLive) is not in standard Protobuf Duration " +
|
|
395
|
-
|
|
394
|
+
"format: ".concat(responseBody.ttl)
|
|
396
395
|
});
|
|
397
396
|
}
|
|
398
397
|
timeToLiveAsNumber = Number(match[1]) * 1000;
|
|
@@ -409,7 +408,7 @@ function exchangeToken(_a, heartbeatServiceProvider) {
|
|
|
409
408
|
function getExchangeRecaptchaV3TokenRequest(app, reCAPTCHAToken) {
|
|
410
409
|
var _a = app.options, projectId = _a.projectId, appId = _a.appId, apiKey = _a.apiKey;
|
|
411
410
|
return {
|
|
412
|
-
url: BASE_ENDPOINT
|
|
411
|
+
url: "".concat(BASE_ENDPOINT, "/projects/").concat(projectId, "/apps/").concat(appId, ":").concat(EXCHANGE_RECAPTCHA_TOKEN_METHOD, "?key=").concat(apiKey),
|
|
413
412
|
body: {
|
|
414
413
|
'recaptcha_v3_token': reCAPTCHAToken
|
|
415
414
|
}
|
|
@@ -418,7 +417,7 @@ function getExchangeRecaptchaV3TokenRequest(app, reCAPTCHAToken) {
|
|
|
418
417
|
function getExchangeRecaptchaEnterpriseTokenRequest(app, reCAPTCHAToken) {
|
|
419
418
|
var _a = app.options, projectId = _a.projectId, appId = _a.appId, apiKey = _a.apiKey;
|
|
420
419
|
return {
|
|
421
|
-
url: BASE_ENDPOINT
|
|
420
|
+
url: "".concat(BASE_ENDPOINT, "/projects/").concat(projectId, "/apps/").concat(appId, ":").concat(EXCHANGE_RECAPTCHA_ENTERPRISE_TOKEN_METHOD, "?key=").concat(apiKey),
|
|
422
421
|
body: {
|
|
423
422
|
'recaptcha_enterprise_token': reCAPTCHAToken
|
|
424
423
|
}
|
|
@@ -427,7 +426,7 @@ function getExchangeRecaptchaEnterpriseTokenRequest(app, reCAPTCHAToken) {
|
|
|
427
426
|
function getExchangeDebugTokenRequest(app, debugToken) {
|
|
428
427
|
var _a = app.options, projectId = _a.projectId, appId = _a.appId, apiKey = _a.apiKey;
|
|
429
428
|
return {
|
|
430
|
-
url: BASE_ENDPOINT
|
|
429
|
+
url: "".concat(BASE_ENDPOINT, "/projects/").concat(projectId, "/apps/").concat(appId, ":").concat(EXCHANGE_DEBUG_TOKEN_METHOD, "?key=").concat(apiKey),
|
|
431
430
|
body: {
|
|
432
431
|
// eslint-disable-next-line
|
|
433
432
|
debug_token: debugToken
|
|
@@ -461,7 +460,6 @@ function getDBPromise() {
|
|
|
461
460
|
return dbPromise;
|
|
462
461
|
}
|
|
463
462
|
dbPromise = new Promise(function (resolve, reject) {
|
|
464
|
-
var _a;
|
|
465
463
|
try {
|
|
466
464
|
var request = indexedDB.open(DB_NAME, DB_VERSION);
|
|
467
465
|
request.onsuccess = function (event) {
|
|
@@ -469,7 +467,7 @@ function getDBPromise() {
|
|
|
469
467
|
};
|
|
470
468
|
request.onerror = function (event) {
|
|
471
469
|
var _a;
|
|
472
|
-
reject(ERROR_FACTORY.create("storage-open" /* STORAGE_OPEN */, {
|
|
470
|
+
reject(ERROR_FACTORY.create("storage-open" /* AppCheckError.STORAGE_OPEN */, {
|
|
473
471
|
originalErrorMessage: (_a = event.target.error) === null || _a === void 0 ? void 0 : _a.message
|
|
474
472
|
}));
|
|
475
473
|
};
|
|
@@ -489,8 +487,8 @@ function getDBPromise() {
|
|
|
489
487
|
};
|
|
490
488
|
}
|
|
491
489
|
catch (e) {
|
|
492
|
-
reject(ERROR_FACTORY.create("storage-open" /* STORAGE_OPEN */, {
|
|
493
|
-
originalErrorMessage:
|
|
490
|
+
reject(ERROR_FACTORY.create("storage-open" /* AppCheckError.STORAGE_OPEN */, {
|
|
491
|
+
originalErrorMessage: e === null || e === void 0 ? void 0 : e.message
|
|
494
492
|
}));
|
|
495
493
|
}
|
|
496
494
|
});
|
|
@@ -528,7 +526,7 @@ function write(key, value) {
|
|
|
528
526
|
};
|
|
529
527
|
transaction.onerror = function (event) {
|
|
530
528
|
var _a;
|
|
531
|
-
reject(ERROR_FACTORY.create("storage-set" /* STORAGE_WRITE */, {
|
|
529
|
+
reject(ERROR_FACTORY.create("storage-set" /* AppCheckError.STORAGE_WRITE */, {
|
|
532
530
|
originalErrorMessage: (_a = event.target.error) === null || _a === void 0 ? void 0 : _a.message
|
|
533
531
|
}));
|
|
534
532
|
};
|
|
@@ -560,7 +558,7 @@ function read(key) {
|
|
|
560
558
|
};
|
|
561
559
|
transaction.onerror = function (event) {
|
|
562
560
|
var _a;
|
|
563
|
-
reject(ERROR_FACTORY.create("storage-get" /* STORAGE_GET */, {
|
|
561
|
+
reject(ERROR_FACTORY.create("storage-get" /* AppCheckError.STORAGE_GET */, {
|
|
564
562
|
originalErrorMessage: (_a = event.target.error) === null || _a === void 0 ? void 0 : _a.message
|
|
565
563
|
}));
|
|
566
564
|
};
|
|
@@ -570,7 +568,7 @@ function read(key) {
|
|
|
570
568
|
});
|
|
571
569
|
}
|
|
572
570
|
function computeKey(app) {
|
|
573
|
-
return app.options.appId
|
|
571
|
+
return "".concat(app.options.appId, "-").concat(app.name);
|
|
574
572
|
}
|
|
575
573
|
|
|
576
574
|
/**
|
|
@@ -628,7 +626,7 @@ function readTokenFromStorage(app) {
|
|
|
628
626
|
case 3:
|
|
629
627
|
e_1 = _a.sent();
|
|
630
628
|
// swallow the error and return undefined
|
|
631
|
-
logger.warn("Failed to read token from IndexedDB. Error: "
|
|
629
|
+
logger.warn("Failed to read token from IndexedDB. Error: ".concat(e_1));
|
|
632
630
|
return [3 /*break*/, 4];
|
|
633
631
|
case 4: return [2 /*return*/, token];
|
|
634
632
|
case 5: return [2 /*return*/, undefined];
|
|
@@ -643,7 +641,7 @@ function writeTokenToStorage(app, token) {
|
|
|
643
641
|
if (util.isIndexedDBAvailable()) {
|
|
644
642
|
return writeTokenToIndexedDB(app, token).catch(function (e) {
|
|
645
643
|
// swallow the error and resolve the promise
|
|
646
|
-
logger.warn("Failed to write token to IndexedDB. Error: "
|
|
644
|
+
logger.warn("Failed to write token to IndexedDB. Error: ".concat(e));
|
|
647
645
|
});
|
|
648
646
|
}
|
|
649
647
|
return Promise.resolve();
|
|
@@ -674,7 +672,7 @@ function readOrCreateDebugTokenFromStorage() {
|
|
|
674
672
|
// If you see this error trying to use debug token, it probably means you are using a browser that doesn't support indexeddb.
|
|
675
673
|
// You should switch to a different browser that supports indexeddb
|
|
676
674
|
writeDebugTokenToIndexedDB(newToken).catch(function (e) {
|
|
677
|
-
return logger.warn("Failed to persist debug token to IndexedDB. Error: "
|
|
675
|
+
return logger.warn("Failed to persist debug token to IndexedDB. Error: ".concat(e));
|
|
678
676
|
});
|
|
679
677
|
return [2 /*return*/, newToken];
|
|
680
678
|
}
|
|
@@ -826,7 +824,8 @@ function getToken$2(appCheck, forceRefresh) {
|
|
|
826
824
|
_d = [app];
|
|
827
825
|
return [4 /*yield*/, getDebugToken()];
|
|
828
826
|
case 5:
|
|
829
|
-
_a.exchangeTokenPromise = _b.apply(void 0, [_c.apply(void 0, _d.concat([_e.sent()])),
|
|
827
|
+
_a.exchangeTokenPromise = _b.apply(void 0, [_c.apply(void 0, _d.concat([_e.sent()])),
|
|
828
|
+
appCheck.heartbeatServiceProvider]).finally(function () {
|
|
830
829
|
// Clear promise when settled - either resolved or rejected.
|
|
831
830
|
state.exchangeTokenPromise = undefined;
|
|
832
831
|
});
|
|
@@ -862,7 +861,7 @@ function getToken$2(appCheck, forceRefresh) {
|
|
|
862
861
|
return [3 /*break*/, 12];
|
|
863
862
|
case 11:
|
|
864
863
|
e_1 = _e.sent();
|
|
865
|
-
if (e_1.code === "appCheck/"
|
|
864
|
+
if (e_1.code === "appCheck/".concat("throttled" /* AppCheckError.THROTTLED */)) {
|
|
866
865
|
// Warn if throttled, but do not treat it as an error.
|
|
867
866
|
logger.warn(e_1.message);
|
|
868
867
|
}
|
|
@@ -928,7 +927,7 @@ function addTokenListener(appCheck, type, listener, onError) {
|
|
|
928
927
|
error: onError,
|
|
929
928
|
type: type
|
|
930
929
|
};
|
|
931
|
-
state.tokenObservers = tslib.__spreadArray(tslib.__spreadArray([], state.tokenObservers), [tokenObserver]);
|
|
930
|
+
state.tokenObservers = tslib.__spreadArray(tslib.__spreadArray([], state.tokenObservers, true), [tokenObserver], false);
|
|
932
931
|
// Invoke the listener async immediately if there is a valid token
|
|
933
932
|
// in memory.
|
|
934
933
|
if (state.token && isValid(state.token)) {
|
|
@@ -1049,7 +1048,7 @@ function notifyTokenListeners(app, token) {
|
|
|
1049
1048
|
for (var _i = 0, observers_1 = observers; _i < observers_1.length; _i++) {
|
|
1050
1049
|
var observer = observers_1[_i];
|
|
1051
1050
|
try {
|
|
1052
|
-
if (observer.type === "EXTERNAL" /* EXTERNAL */ && token.error != null) {
|
|
1051
|
+
if (observer.type === "EXTERNAL" /* ListenerType.EXTERNAL */ && token.error != null) {
|
|
1053
1052
|
// If this listener was added by a 3P call, send any token error to
|
|
1054
1053
|
// the supplied error handler. A 3P observer always has an error
|
|
1055
1054
|
// handler.
|
|
@@ -1118,14 +1117,14 @@ function internalFactory(appCheck) {
|
|
|
1118
1117
|
return {
|
|
1119
1118
|
getToken: function (forceRefresh) { return getToken$2(appCheck, forceRefresh); },
|
|
1120
1119
|
addTokenListener: function (listener) {
|
|
1121
|
-
return addTokenListener(appCheck, "INTERNAL" /* INTERNAL */, listener);
|
|
1120
|
+
return addTokenListener(appCheck, "INTERNAL" /* ListenerType.INTERNAL */, listener);
|
|
1122
1121
|
},
|
|
1123
1122
|
removeTokenListener: function (listener) { return removeTokenListener(appCheck.app, listener); }
|
|
1124
1123
|
};
|
|
1125
1124
|
}
|
|
1126
1125
|
|
|
1127
1126
|
var name = "@firebase/app-check";
|
|
1128
|
-
var version = "0.
|
|
1127
|
+
var version = "0.6.0";
|
|
1129
1128
|
|
|
1130
1129
|
/**
|
|
1131
1130
|
* @license
|
|
@@ -1203,7 +1202,7 @@ function queueWidgetRender(app, siteKey, grecaptcha, container, initialized) {
|
|
|
1203
1202
|
* Add invisible div to page.
|
|
1204
1203
|
*/
|
|
1205
1204
|
function makeDiv(app) {
|
|
1206
|
-
var divId = "fire_app_check_"
|
|
1205
|
+
var divId = "fire_app_check_".concat(app.name);
|
|
1207
1206
|
var invisibleDiv = document.createElement('div');
|
|
1208
1207
|
invisibleDiv.id = divId;
|
|
1209
1208
|
invisibleDiv.style.display = 'none';
|
|
@@ -1312,7 +1311,7 @@ var ReCaptchaV3Provider = /** @class */ (function () {
|
|
|
1312
1311
|
throwIfThrottled(this._throttleData);
|
|
1313
1312
|
return [4 /*yield*/, getToken$1(this._app).catch(function (_e) {
|
|
1314
1313
|
// reCaptcha.execute() throws null which is not very descriptive.
|
|
1315
|
-
throw ERROR_FACTORY.create("recaptcha-error" /* RECAPTCHA_ERROR */);
|
|
1314
|
+
throw ERROR_FACTORY.create("recaptcha-error" /* AppCheckError.RECAPTCHA_ERROR */);
|
|
1316
1315
|
})];
|
|
1317
1316
|
case 1:
|
|
1318
1317
|
attestedClaimsToken = _c.sent();
|
|
@@ -1325,9 +1324,9 @@ var ReCaptchaV3Provider = /** @class */ (function () {
|
|
|
1325
1324
|
return [3 /*break*/, 5];
|
|
1326
1325
|
case 4:
|
|
1327
1326
|
e_1 = _c.sent();
|
|
1328
|
-
if ((_a = e_1.code) === null || _a === void 0 ? void 0 : _a.includes("fetch-status-error" /* FETCH_STATUS_ERROR */)) {
|
|
1327
|
+
if ((_a = e_1.code) === null || _a === void 0 ? void 0 : _a.includes("fetch-status-error" /* AppCheckError.FETCH_STATUS_ERROR */)) {
|
|
1329
1328
|
this._throttleData = setBackoff(Number((_b = e_1.customData) === null || _b === void 0 ? void 0 : _b.httpStatus), this._throttleData);
|
|
1330
|
-
throw ERROR_FACTORY.create("throttled" /* THROTTLED */, {
|
|
1329
|
+
throw ERROR_FACTORY.create("throttled" /* AppCheckError.THROTTLED */, {
|
|
1331
1330
|
time: getDurationString(this._throttleData.allowRequestsAfter - Date.now()),
|
|
1332
1331
|
httpStatus: this._throttleData.httpStatus
|
|
1333
1332
|
});
|
|
@@ -1399,7 +1398,7 @@ var ReCaptchaEnterpriseProvider = /** @class */ (function () {
|
|
|
1399
1398
|
throwIfThrottled(this._throttleData);
|
|
1400
1399
|
return [4 /*yield*/, getToken$1(this._app).catch(function (_e) {
|
|
1401
1400
|
// reCaptcha.execute() throws null which is not very descriptive.
|
|
1402
|
-
throw ERROR_FACTORY.create("recaptcha-error" /* RECAPTCHA_ERROR */);
|
|
1401
|
+
throw ERROR_FACTORY.create("recaptcha-error" /* AppCheckError.RECAPTCHA_ERROR */);
|
|
1403
1402
|
})];
|
|
1404
1403
|
case 1:
|
|
1405
1404
|
attestedClaimsToken = _c.sent();
|
|
@@ -1412,9 +1411,9 @@ var ReCaptchaEnterpriseProvider = /** @class */ (function () {
|
|
|
1412
1411
|
return [3 /*break*/, 5];
|
|
1413
1412
|
case 4:
|
|
1414
1413
|
e_2 = _c.sent();
|
|
1415
|
-
if ((_a = e_2.code) === null || _a === void 0 ? void 0 : _a.includes("fetch-status-error" /* FETCH_STATUS_ERROR */)) {
|
|
1414
|
+
if ((_a = e_2.code) === null || _a === void 0 ? void 0 : _a.includes("fetch-status-error" /* AppCheckError.FETCH_STATUS_ERROR */)) {
|
|
1416
1415
|
this._throttleData = setBackoff(Number((_b = e_2.customData) === null || _b === void 0 ? void 0 : _b.httpStatus), this._throttleData);
|
|
1417
|
-
throw ERROR_FACTORY.create("throttled" /* THROTTLED */, {
|
|
1416
|
+
throw ERROR_FACTORY.create("throttled" /* AppCheckError.THROTTLED */, {
|
|
1418
1417
|
time: getDurationString(this._throttleData.allowRequestsAfter - Date.now()),
|
|
1419
1418
|
httpStatus: this._throttleData.httpStatus
|
|
1420
1419
|
});
|
|
@@ -1547,7 +1546,7 @@ function throwIfThrottled(throttleData) {
|
|
|
1547
1546
|
if (throttleData) {
|
|
1548
1547
|
if (Date.now() - throttleData.allowRequestsAfter <= 0) {
|
|
1549
1548
|
// If before, throw.
|
|
1550
|
-
throw ERROR_FACTORY.create("throttled" /* THROTTLED */, {
|
|
1549
|
+
throw ERROR_FACTORY.create("throttled" /* AppCheckError.THROTTLED */, {
|
|
1551
1550
|
time: getDurationString(throttleData.allowRequestsAfter - Date.now()),
|
|
1552
1551
|
httpStatus: throttleData.httpStatus
|
|
1553
1552
|
});
|
|
@@ -1591,7 +1590,7 @@ function initializeAppCheck(app$1, options) {
|
|
|
1591
1590
|
// Do not block initialization to get the token for the message.
|
|
1592
1591
|
void getDebugToken().then(function (token) {
|
|
1593
1592
|
// Not using logger because I don't think we ever want this accidentally hidden.
|
|
1594
|
-
return console.log("App Check debug token: "
|
|
1593
|
+
return console.log("App Check debug token: ".concat(token, ". You will need to add it to your app's App Check settings in the Firebase console for it to work."));
|
|
1595
1594
|
});
|
|
1596
1595
|
}
|
|
1597
1596
|
if (provider.isInitialized()) {
|
|
@@ -1603,7 +1602,7 @@ function initializeAppCheck(app$1, options) {
|
|
|
1603
1602
|
return existingInstance;
|
|
1604
1603
|
}
|
|
1605
1604
|
else {
|
|
1606
|
-
throw ERROR_FACTORY.create("already-initialized" /* ALREADY_INITIALIZED */, {
|
|
1605
|
+
throw ERROR_FACTORY.create("already-initialized" /* AppCheckError.ALREADY_INITIALIZED */, {
|
|
1607
1606
|
appName: app$1.name
|
|
1608
1607
|
});
|
|
1609
1608
|
}
|
|
@@ -1619,7 +1618,7 @@ function initializeAppCheck(app$1, options) {
|
|
|
1619
1618
|
// requests the token.
|
|
1620
1619
|
// Listener function does not need to do anything, its base functionality
|
|
1621
1620
|
// of calling getToken() already fetches token and writes it to memory/storage.
|
|
1622
|
-
addTokenListener(appCheck, "INTERNAL" /* INTERNAL */, function () { });
|
|
1621
|
+
addTokenListener(appCheck, "INTERNAL" /* ListenerType.INTERNAL */, function () { });
|
|
1623
1622
|
}
|
|
1624
1623
|
return appCheck;
|
|
1625
1624
|
}
|
|
@@ -1733,7 +1732,7 @@ onCompletion) {
|
|
|
1733
1732
|
else if (onError) {
|
|
1734
1733
|
errorFn = onError;
|
|
1735
1734
|
}
|
|
1736
|
-
addTokenListener(appCheckInstance, "EXTERNAL" /* EXTERNAL */, nextFn, errorFn);
|
|
1735
|
+
addTokenListener(appCheckInstance, "EXTERNAL" /* ListenerType.EXTERNAL */, nextFn, errorFn);
|
|
1737
1736
|
return function () { return removeTokenListener(appCheckInstance.app, nextFn); };
|
|
1738
1737
|
}
|
|
1739
1738
|
|
|
@@ -1751,8 +1750,8 @@ function registerAppCheck() {
|
|
|
1751
1750
|
var app = container.getProvider('app').getImmediate();
|
|
1752
1751
|
var heartbeatServiceProvider = container.getProvider('heartbeat');
|
|
1753
1752
|
return factory(app, heartbeatServiceProvider);
|
|
1754
|
-
}, "PUBLIC" /* PUBLIC */)
|
|
1755
|
-
.setInstantiationMode("EXPLICIT" /* EXPLICIT */)
|
|
1753
|
+
}, "PUBLIC" /* ComponentType.PUBLIC */)
|
|
1754
|
+
.setInstantiationMode("EXPLICIT" /* InstantiationMode.EXPLICIT */)
|
|
1756
1755
|
/**
|
|
1757
1756
|
* Initialize app-check-internal after app-check is initialized to make AppCheck available to
|
|
1758
1757
|
* other Firebase SDKs
|
|
@@ -1764,7 +1763,7 @@ function registerAppCheck() {
|
|
|
1764
1763
|
app._registerComponent(new component.Component(APP_CHECK_NAME_INTERNAL, function (container) {
|
|
1765
1764
|
var appCheck = container.getProvider('app-check').getImmediate();
|
|
1766
1765
|
return internalFactory(appCheck);
|
|
1767
|
-
}, "PUBLIC" /* PUBLIC */).setInstantiationMode("EXPLICIT" /* EXPLICIT */));
|
|
1766
|
+
}, "PUBLIC" /* ComponentType.PUBLIC */).setInstantiationMode("EXPLICIT" /* InstantiationMode.EXPLICIT */));
|
|
1768
1767
|
app.registerVersion(name, version);
|
|
1769
1768
|
}
|
|
1770
1769
|
registerAppCheck();
|