@firebase/database 1.0.11-canary.3aefcc3e1 → 1.0.11-canary.97d48c765

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 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-canary.3aefcc3e1";
11
+ const version = "1.0.11-canary.97d48c765";
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
  }
@@ -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
  /**