@firebase/app-check 0.5.3 → 0.5.4-2022216223411
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 +11 -0
- package/dist/app-check-public.d.ts +2 -2
- package/dist/app-check.d.ts +2 -2
- package/dist/esm/index.esm.js +37 -31
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/index.esm2017.js +22 -19
- package/dist/esm/index.esm2017.js.map +1 -1
- package/dist/esm/src/client.d.ts +1 -1
- package/dist/esm/src/factory.d.ts +3 -3
- package/dist/esm/src/providers.d.ts +2 -2
- package/dist/esm/test/util.d.ts +1 -1
- package/dist/index.cjs.js +37 -31
- package/dist/index.cjs.js.map +1 -1
- package/dist/src/client.d.ts +1 -1
- package/dist/src/factory.d.ts +3 -3
- package/dist/src/providers.d.ts +2 -2
- package/dist/test/util.d.ts +1 -1
- package/package.json +5 -5
|
@@ -301,16 +301,19 @@ function pad(value) {
|
|
|
301
301
|
* See the License for the specific language governing permissions and
|
|
302
302
|
* limitations under the License.
|
|
303
303
|
*/
|
|
304
|
-
async function exchangeToken({ url, body },
|
|
304
|
+
async function exchangeToken({ url, body }, heartbeatServiceProvider) {
|
|
305
305
|
const headers = {
|
|
306
306
|
'Content-Type': 'application/json'
|
|
307
307
|
};
|
|
308
|
-
// If
|
|
309
|
-
const
|
|
308
|
+
// If heartbeat service exists, add heartbeat header string to the header.
|
|
309
|
+
const heartbeatService = heartbeatServiceProvider.getImmediate({
|
|
310
310
|
optional: true
|
|
311
311
|
});
|
|
312
|
-
if (
|
|
313
|
-
|
|
312
|
+
if (heartbeatService) {
|
|
313
|
+
const heartbeatsHeader = await heartbeatService.getHeartbeatsHeader();
|
|
314
|
+
if (heartbeatsHeader) {
|
|
315
|
+
headers['X-Firebase-Client'] = heartbeatsHeader;
|
|
316
|
+
}
|
|
314
317
|
}
|
|
315
318
|
const options = {
|
|
316
319
|
method: 'POST',
|
|
@@ -720,7 +723,7 @@ async function getToken$2(appCheck, forceRefresh = false) {
|
|
|
720
723
|
if (isDebugMode()) {
|
|
721
724
|
// Avoid making another call to the exchange endpoint if one is in flight.
|
|
722
725
|
if (!state.exchangeTokenPromise) {
|
|
723
|
-
state.exchangeTokenPromise = exchangeToken(getExchangeDebugTokenRequest(app, await getDebugToken()), appCheck.
|
|
726
|
+
state.exchangeTokenPromise = exchangeToken(getExchangeDebugTokenRequest(app, await getDebugToken()), appCheck.heartbeatServiceProvider).then(token => {
|
|
724
727
|
state.exchangeTokenPromise = undefined;
|
|
725
728
|
return token;
|
|
726
729
|
});
|
|
@@ -935,9 +938,9 @@ function makeDummyTokenResult(error) {
|
|
|
935
938
|
* AppCheck Service class.
|
|
936
939
|
*/
|
|
937
940
|
class AppCheckService {
|
|
938
|
-
constructor(app,
|
|
941
|
+
constructor(app, heartbeatServiceProvider) {
|
|
939
942
|
this.app = app;
|
|
940
|
-
this.
|
|
943
|
+
this.heartbeatServiceProvider = heartbeatServiceProvider;
|
|
941
944
|
}
|
|
942
945
|
_delete() {
|
|
943
946
|
const { tokenObservers } = getState(this.app);
|
|
@@ -947,8 +950,8 @@ class AppCheckService {
|
|
|
947
950
|
return Promise.resolve();
|
|
948
951
|
}
|
|
949
952
|
}
|
|
950
|
-
function factory(app,
|
|
951
|
-
return new AppCheckService(app,
|
|
953
|
+
function factory(app, heartbeatServiceProvider) {
|
|
954
|
+
return new AppCheckService(app, heartbeatServiceProvider);
|
|
952
955
|
}
|
|
953
956
|
function internalFactory(appCheck) {
|
|
954
957
|
return {
|
|
@@ -959,7 +962,7 @@ function internalFactory(appCheck) {
|
|
|
959
962
|
}
|
|
960
963
|
|
|
961
964
|
const name = "@firebase/app-check";
|
|
962
|
-
const version = "0.5.
|
|
965
|
+
const version = "0.5.4-2022216223411";
|
|
963
966
|
|
|
964
967
|
/**
|
|
965
968
|
* @license
|
|
@@ -1131,14 +1134,14 @@ class ReCaptchaV3Provider {
|
|
|
1131
1134
|
var _a;
|
|
1132
1135
|
throwIfThrottled(this._throttleData);
|
|
1133
1136
|
// Top-level `getToken()` has already checked that App Check is initialized
|
|
1134
|
-
// and therefore this._app and this.
|
|
1137
|
+
// and therefore this._app and this._heartbeatServiceProvider are available.
|
|
1135
1138
|
const attestedClaimsToken = await getToken$1(this._app).catch(_e => {
|
|
1136
1139
|
// reCaptcha.execute() throws null which is not very descriptive.
|
|
1137
1140
|
throw ERROR_FACTORY.create("recaptcha-error" /* RECAPTCHA_ERROR */);
|
|
1138
1141
|
});
|
|
1139
1142
|
let result;
|
|
1140
1143
|
try {
|
|
1141
|
-
result = await exchangeToken(getExchangeRecaptchaV3TokenRequest(this._app, attestedClaimsToken), this.
|
|
1144
|
+
result = await exchangeToken(getExchangeRecaptchaV3TokenRequest(this._app, attestedClaimsToken), this._heartbeatServiceProvider);
|
|
1142
1145
|
}
|
|
1143
1146
|
catch (e) {
|
|
1144
1147
|
if (e.code === "fetch-status-error" /* FETCH_STATUS_ERROR */) {
|
|
@@ -1161,7 +1164,7 @@ class ReCaptchaV3Provider {
|
|
|
1161
1164
|
*/
|
|
1162
1165
|
initialize(app) {
|
|
1163
1166
|
this._app = app;
|
|
1164
|
-
this.
|
|
1167
|
+
this._heartbeatServiceProvider = _getProvider(app, 'heartbeat');
|
|
1165
1168
|
initializeV3(app, this._siteKey).catch(() => {
|
|
1166
1169
|
/* we don't care about the initialization result */
|
|
1167
1170
|
});
|
|
@@ -1205,14 +1208,14 @@ class ReCaptchaEnterpriseProvider {
|
|
|
1205
1208
|
var _a;
|
|
1206
1209
|
throwIfThrottled(this._throttleData);
|
|
1207
1210
|
// Top-level `getToken()` has already checked that App Check is initialized
|
|
1208
|
-
// and therefore this._app and this.
|
|
1211
|
+
// and therefore this._app and this._heartbeatServiceProvider are available.
|
|
1209
1212
|
const attestedClaimsToken = await getToken$1(this._app).catch(_e => {
|
|
1210
1213
|
// reCaptcha.execute() throws null which is not very descriptive.
|
|
1211
1214
|
throw ERROR_FACTORY.create("recaptcha-error" /* RECAPTCHA_ERROR */);
|
|
1212
1215
|
});
|
|
1213
1216
|
let result;
|
|
1214
1217
|
try {
|
|
1215
|
-
result = await exchangeToken(getExchangeRecaptchaEnterpriseTokenRequest(this._app, attestedClaimsToken), this.
|
|
1218
|
+
result = await exchangeToken(getExchangeRecaptchaEnterpriseTokenRequest(this._app, attestedClaimsToken), this._heartbeatServiceProvider);
|
|
1216
1219
|
}
|
|
1217
1220
|
catch (e) {
|
|
1218
1221
|
if (e.code === "fetch-status-error" /* FETCH_STATUS_ERROR */) {
|
|
@@ -1235,7 +1238,7 @@ class ReCaptchaEnterpriseProvider {
|
|
|
1235
1238
|
*/
|
|
1236
1239
|
initialize(app) {
|
|
1237
1240
|
this._app = app;
|
|
1238
|
-
this.
|
|
1241
|
+
this._heartbeatServiceProvider = _getProvider(app, 'heartbeat');
|
|
1239
1242
|
initializeEnterprise(app, this._siteKey).catch(() => {
|
|
1240
1243
|
/* we don't care about the initialization result */
|
|
1241
1244
|
});
|
|
@@ -1531,8 +1534,8 @@ function registerAppCheck() {
|
|
|
1531
1534
|
_registerComponent(new Component(APP_CHECK_NAME, container => {
|
|
1532
1535
|
// getImmediate for FirebaseApp will always succeed
|
|
1533
1536
|
const app = container.getProvider('app').getImmediate();
|
|
1534
|
-
const
|
|
1535
|
-
return factory(app,
|
|
1537
|
+
const heartbeatServiceProvider = container.getProvider('heartbeat');
|
|
1538
|
+
return factory(app, heartbeatServiceProvider);
|
|
1536
1539
|
}, "PUBLIC" /* PUBLIC */)
|
|
1537
1540
|
.setInstantiationMode("EXPLICIT" /* EXPLICIT */)
|
|
1538
1541
|
/**
|