@firebase/database 1.0.10 → 1.0.11-canary.01f36ea41
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/index.cjs.js +15 -6
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +16 -7
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.node.cjs.js +15 -6
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.standalone.js +15 -5
- package/dist/index.standalone.js.map +1 -1
- package/dist/internal.d.ts +3 -2
- package/dist/node-esm/index.node.esm.js +16 -7
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/core/AppCheckTokenProvider.d.ts +4 -2
- package/dist/private.d.ts +3 -2
- package/dist/src/core/AppCheckTokenProvider.d.ts +4 -2
- package/package.json +7 -7
package/dist/index.standalone.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var Websocket = require('faye-websocket');
|
|
6
6
|
var util = require('@firebase/util');
|
|
7
7
|
var logger$1 = require('@firebase/logger');
|
|
8
|
+
var app = require('@firebase/app');
|
|
8
9
|
var component = require('@firebase/component');
|
|
9
10
|
|
|
10
11
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -1277,15 +1278,24 @@ WebSocketConnection.healthyTimeout = 30000;
|
|
|
1277
1278
|
* Abstraction around AppCheck's token fetching capabilities.
|
|
1278
1279
|
*/
|
|
1279
1280
|
class AppCheckTokenProvider {
|
|
1280
|
-
constructor(
|
|
1281
|
-
this.appName_ = appName_;
|
|
1281
|
+
constructor(app$1, appCheckProvider) {
|
|
1282
1282
|
this.appCheckProvider = appCheckProvider;
|
|
1283
|
+
this.appName = app$1.name;
|
|
1284
|
+
if (app._isFirebaseServerApp(app$1) && app$1.settings.appCheckToken) {
|
|
1285
|
+
this.serverAppAppCheckToken = app$1.settings.appCheckToken;
|
|
1286
|
+
}
|
|
1283
1287
|
this.appCheck = appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.getImmediate({ optional: true });
|
|
1284
1288
|
if (!this.appCheck) {
|
|
1285
1289
|
appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.get().then(appCheck => (this.appCheck = appCheck));
|
|
1286
1290
|
}
|
|
1287
1291
|
}
|
|
1288
1292
|
getToken(forceRefresh) {
|
|
1293
|
+
if (this.serverAppAppCheckToken) {
|
|
1294
|
+
if (forceRefresh) {
|
|
1295
|
+
throw new Error('Attempted reuse of `FirebaseServerApp.appCheckToken` after previous usage failed.');
|
|
1296
|
+
}
|
|
1297
|
+
return Promise.resolve({ token: this.serverAppAppCheckToken });
|
|
1298
|
+
}
|
|
1289
1299
|
if (!this.appCheck) {
|
|
1290
1300
|
return new Promise((resolve, reject) => {
|
|
1291
1301
|
// Support delayed initialization of FirebaseAppCheck. This allows our
|
|
@@ -1309,7 +1319,7 @@ class AppCheckTokenProvider {
|
|
|
1309
1319
|
(_a = this.appCheckProvider) === null || _a === void 0 ? void 0 : _a.get().then(appCheck => appCheck.addTokenListener(listener));
|
|
1310
1320
|
}
|
|
1311
1321
|
notifyForInvalidToken() {
|
|
1312
|
-
warn(`Provided AppCheck credentials for the app named "${this.
|
|
1322
|
+
warn(`Provided AppCheck credentials for the app named "${this.appName}" ` +
|
|
1313
1323
|
'are invalid. This usually indicates your app was not initialized correctly.');
|
|
1314
1324
|
}
|
|
1315
1325
|
}
|
|
@@ -3740,7 +3750,7 @@ class PersistentConnection extends ServerActions {
|
|
|
3740
3750
|
}
|
|
3741
3751
|
this.lastConnectionEstablishedTime_ = null;
|
|
3742
3752
|
}
|
|
3743
|
-
const timeSinceLastConnectAttempt = new Date().getTime() - this.lastConnectionAttemptTime_;
|
|
3753
|
+
const timeSinceLastConnectAttempt = Math.max(0, new Date().getTime() - this.lastConnectionAttemptTime_);
|
|
3744
3754
|
let reconnectDelay = Math.max(0, this.reconnectDelay_ - timeSinceLastConnectAttempt);
|
|
3745
3755
|
reconnectDelay = Math.random() * reconnectDelay;
|
|
3746
3756
|
this.log_('Trying to reconnect in ' + reconnectDelay + 'ms');
|
|
@@ -13531,7 +13541,7 @@ function repoManagerDatabaseFromApp(app, authProvider, appCheckProvider, url, no
|
|
|
13531
13541
|
fatal('Database URL must point to the root of a Firebase Database ' +
|
|
13532
13542
|
'(not including a child path).');
|
|
13533
13543
|
}
|
|
13534
|
-
const repo = repoManagerCreateRepo(repoInfo, app, authTokenProvider, new AppCheckTokenProvider(app
|
|
13544
|
+
const repo = repoManagerCreateRepo(repoInfo, app, authTokenProvider, new AppCheckTokenProvider(app, appCheckProvider));
|
|
13535
13545
|
return new Database(repo, app);
|
|
13536
13546
|
}
|
|
13537
13547
|
/**
|