@firebase/database 0.14.1 → 0.14.2-20230201003102

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.
@@ -754,16 +754,18 @@ var RepoInfo = /** @class */ (function () {
754
754
  * @param nodeAdmin - Whether this instance uses Admin SDK credentials
755
755
  * @param persistenceKey - Override the default session persistence storage key
756
756
  */
757
- function RepoInfo(host, secure, namespace, webSocketOnly, nodeAdmin, persistenceKey, includeNamespaceInQueryParams) {
757
+ function RepoInfo(host, secure, namespace, webSocketOnly, nodeAdmin, persistenceKey, includeNamespaceInQueryParams, isUsingEmulator) {
758
758
  if (nodeAdmin === void 0) { nodeAdmin = false; }
759
759
  if (persistenceKey === void 0) { persistenceKey = ''; }
760
760
  if (includeNamespaceInQueryParams === void 0) { includeNamespaceInQueryParams = false; }
761
+ if (isUsingEmulator === void 0) { isUsingEmulator = false; }
761
762
  this.secure = secure;
762
763
  this.namespace = namespace;
763
764
  this.webSocketOnly = webSocketOnly;
764
765
  this.nodeAdmin = nodeAdmin;
765
766
  this.persistenceKey = persistenceKey;
766
767
  this.includeNamespaceInQueryParams = includeNamespaceInQueryParams;
768
+ this.isUsingEmulator = isUsingEmulator;
767
769
  this._host = host.toLowerCase();
768
770
  this._domain = this._host.substr(this._host.indexOf('.') + 1);
769
771
  this.internalHost =
@@ -2568,7 +2570,12 @@ var Connection = /** @class */ (function () {
2568
2570
  if (MESSAGE_DATA in controlData) {
2569
2571
  var payload = controlData[MESSAGE_DATA];
2570
2572
  if (cmd === SERVER_HELLO) {
2571
- this.onHandshake_(payload);
2573
+ var handshakePayload = tslib.__assign({}, payload);
2574
+ if (this.repoInfo_.isUsingEmulator) {
2575
+ // Upon connecting, the emulator will pass the hostname that it's aware of, but we prefer the user's set hostname via `connectDatabaseEmulator` over what the emulator passes.
2576
+ handshakePayload.h = this.repoInfo_.host;
2577
+ }
2578
+ this.onHandshake_(handshakePayload);
2572
2579
  }
2573
2580
  else if (cmd === END_TRANSMISSION) {
2574
2581
  this.log_('recvd end transmission on primary');
@@ -13923,7 +13930,8 @@ var useRestClient = false;
13923
13930
  */
13924
13931
  function repoManagerApplyEmulatorSettings(repo, host, port, tokenProvider) {
13925
13932
  repo.repoInfo_ = new RepoInfo("".concat(host, ":").concat(port),
13926
- /* secure= */ false, repo.repoInfo_.namespace, repo.repoInfo_.webSocketOnly, repo.repoInfo_.nodeAdmin, repo.repoInfo_.persistenceKey, repo.repoInfo_.includeNamespaceInQueryParams);
13933
+ /* secure= */ false, repo.repoInfo_.namespace, repo.repoInfo_.webSocketOnly, repo.repoInfo_.nodeAdmin, repo.repoInfo_.persistenceKey, repo.repoInfo_.includeNamespaceInQueryParams,
13934
+ /*isUsingEmulator=*/ true);
13927
13935
  if (tokenProvider) {
13928
13936
  repo.authTokenProvider_ = tokenProvider;
13929
13937
  }