@firebase/database 1.0.11 → 1.0.12-20250205220033

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.
Files changed (45) hide show
  1. package/dist/index.cjs.js +15 -6
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.esm2017.js +16 -7
  4. package/dist/index.esm2017.js.map +1 -1
  5. package/dist/index.node.cjs.js +15 -6
  6. package/dist/index.node.cjs.js.map +1 -1
  7. package/dist/index.standalone.js +15 -5
  8. package/dist/index.standalone.js.map +1 -1
  9. package/dist/internal.d.ts +3 -2
  10. package/dist/node-esm/index.node.esm.js +16 -7
  11. package/dist/node-esm/index.node.esm.js.map +1 -1
  12. package/dist/node-esm/src/core/AppCheckTokenProvider.d.ts +4 -2
  13. package/dist/private.d.ts +3 -2
  14. package/dist/src/core/AppCheckTokenProvider.d.ts +4 -2
  15. package/package.json +4 -4
  16. package/dist/node-esm/test/compound_write.test.d.ts +0 -17
  17. package/dist/node-esm/test/connection.test.d.ts +0 -17
  18. package/dist/node-esm/test/deno.test.d.ts +0 -17
  19. package/dist/node-esm/test/exp/integration.test.d.ts +0 -17
  20. package/dist/node-esm/test/node.test.d.ts +0 -17
  21. package/dist/node-esm/test/parser.test.d.ts +0 -17
  22. package/dist/node-esm/test/path.test.d.ts +0 -17
  23. package/dist/node-esm/test/pushid.test.d.ts +0 -17
  24. package/dist/node-esm/test/queryconstraint.test.d.ts +0 -17
  25. package/dist/node-esm/test/repoinfo.test.d.ts +0 -17
  26. package/dist/node-esm/test/sortedmap.test.d.ts +0 -17
  27. package/dist/node-esm/test/sparsesnapshottree.test.d.ts +0 -17
  28. package/dist/node-esm/test/syncpoint.test.d.ts +0 -17
  29. package/dist/node-esm/test/transport.test.d.ts +0 -17
  30. package/dist/node-esm/test/websocketconnection.test.d.ts +0 -17
  31. package/dist/test/compound_write.test.d.ts +0 -17
  32. package/dist/test/connection.test.d.ts +0 -17
  33. package/dist/test/deno.test.d.ts +0 -17
  34. package/dist/test/exp/integration.test.d.ts +0 -17
  35. package/dist/test/node.test.d.ts +0 -17
  36. package/dist/test/parser.test.d.ts +0 -17
  37. package/dist/test/path.test.d.ts +0 -17
  38. package/dist/test/pushid.test.d.ts +0 -17
  39. package/dist/test/queryconstraint.test.d.ts +0 -17
  40. package/dist/test/repoinfo.test.d.ts +0 -17
  41. package/dist/test/sortedmap.test.d.ts +0 -17
  42. package/dist/test/sparsesnapshottree.test.d.ts +0 -17
  43. package/dist/test/syncpoint.test.d.ts +0 -17
  44. package/dist/test/transport.test.d.ts +0 -17
  45. package/dist/test/websocketconnection.test.d.ts +0 -17
package/dist/index.cjs.js CHANGED
@@ -8,7 +8,7 @@ var util = require('@firebase/util');
8
8
  var logger$1 = require('@firebase/logger');
9
9
 
10
10
  const name = "@firebase/database";
11
- const version = "1.0.11";
11
+ const version = "1.0.12-20250205220033";
12
12
 
13
13
  /**
14
14
  * @license
@@ -715,15 +715,24 @@ const setTimeoutNonBlocking = function (fn, time) {
715
715
  * Abstraction around AppCheck's token fetching capabilities.
716
716
  */
717
717
  class AppCheckTokenProvider {
718
- constructor(appName_, appCheckProvider) {
719
- this.appName_ = appName_;
718
+ constructor(app$1, appCheckProvider) {
720
719
  this.appCheckProvider = appCheckProvider;
720
+ this.appName = app$1.name;
721
+ if (app._isFirebaseServerApp(app$1) && app$1.settings.appCheckToken) {
722
+ this.serverAppAppCheckToken = app$1.settings.appCheckToken;
723
+ }
721
724
  this.appCheck = appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.getImmediate({ optional: true });
722
725
  if (!this.appCheck) {
723
726
  appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.get().then(appCheck => (this.appCheck = appCheck));
724
727
  }
725
728
  }
726
729
  getToken(forceRefresh) {
730
+ if (this.serverAppAppCheckToken) {
731
+ if (forceRefresh) {
732
+ throw new Error('Attempted reuse of `FirebaseServerApp.appCheckToken` after previous usage failed.');
733
+ }
734
+ return Promise.resolve({ token: this.serverAppAppCheckToken });
735
+ }
727
736
  if (!this.appCheck) {
728
737
  return new Promise((resolve, reject) => {
729
738
  // Support delayed initialization of FirebaseAppCheck. This allows our
@@ -747,7 +756,7 @@ class AppCheckTokenProvider {
747
756
  (_a = this.appCheckProvider) === null || _a === void 0 ? void 0 : _a.get().then(appCheck => appCheck.addTokenListener(listener));
748
757
  }
749
758
  notifyForInvalidToken() {
750
- warn(`Provided AppCheck credentials for the app named "${this.appName_}" ` +
759
+ warn(`Provided AppCheck credentials for the app named "${this.appName}" ` +
751
760
  'are invalid. This usually indicates your app was not initialized correctly.');
752
761
  }
753
762
  }
@@ -3736,7 +3745,7 @@ class PersistentConnection extends ServerActions {
3736
3745
  }
3737
3746
  this.lastConnectionEstablishedTime_ = null;
3738
3747
  }
3739
- const timeSinceLastConnectAttempt = new Date().getTime() - this.lastConnectionAttemptTime_;
3748
+ const timeSinceLastConnectAttempt = Math.max(0, new Date().getTime() - this.lastConnectionAttemptTime_);
3740
3749
  let reconnectDelay = Math.max(0, this.reconnectDelay_ - timeSinceLastConnectAttempt);
3741
3750
  reconnectDelay = Math.random() * reconnectDelay;
3742
3751
  this.log_('Trying to reconnect in ' + reconnectDelay + 'ms');
@@ -13527,7 +13536,7 @@ function repoManagerDatabaseFromApp(app, authProvider, appCheckProvider, url, no
13527
13536
  fatal('Database URL must point to the root of a Firebase Database ' +
13528
13537
  '(not including a child path).');
13529
13538
  }
13530
- const repo = repoManagerCreateRepo(repoInfo, app, authTokenProvider, new AppCheckTokenProvider(app.name, appCheckProvider));
13539
+ const repo = repoManagerCreateRepo(repoInfo, app, authTokenProvider, new AppCheckTokenProvider(app, appCheckProvider));
13531
13540
  return new Database(repo, app);
13532
13541
  }
13533
13542
  /**