@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.
@@ -1,11 +1,11 @@
1
1
  import { getApp, _getProvider, _registerComponent, registerVersion, SDK_VERSION as SDK_VERSION$1 } from '@firebase/app';
2
2
  import { Component } from '@firebase/component';
3
- import { __spreadArray, __read, __values, __extends, __awaiter, __generator, __assign } from 'tslib';
3
+ import { __spreadArray, __read, __values, __assign, __extends, __awaiter, __generator } from 'tslib';
4
4
  import { stringify, jsonEval, contains, assert, isNodeSdk, stringToByteArray, Sha1, base64, deepCopy, base64Encode, isMobileCordova, stringLength, Deferred, safeGet, isAdmin, isValidFormat, isEmpty, isReactNative, assertionError, map, querystring, errorPrefix, getModularInstance, getDefaultEmulatorHostnameAndPort, createMockUserToken } from '@firebase/util';
5
5
  import { Logger, LogLevel } from '@firebase/logger';
6
6
 
7
7
  var name = "@firebase/database";
8
- var version = "0.14.1";
8
+ var version = "0.14.2-20230201003102";
9
9
 
10
10
  /**
11
11
  * @license
@@ -963,16 +963,18 @@ var RepoInfo = /** @class */ (function () {
963
963
  * @param nodeAdmin - Whether this instance uses Admin SDK credentials
964
964
  * @param persistenceKey - Override the default session persistence storage key
965
965
  */
966
- function RepoInfo(host, secure, namespace, webSocketOnly, nodeAdmin, persistenceKey, includeNamespaceInQueryParams) {
966
+ function RepoInfo(host, secure, namespace, webSocketOnly, nodeAdmin, persistenceKey, includeNamespaceInQueryParams, isUsingEmulator) {
967
967
  if (nodeAdmin === void 0) { nodeAdmin = false; }
968
968
  if (persistenceKey === void 0) { persistenceKey = ''; }
969
969
  if (includeNamespaceInQueryParams === void 0) { includeNamespaceInQueryParams = false; }
970
+ if (isUsingEmulator === void 0) { isUsingEmulator = false; }
970
971
  this.secure = secure;
971
972
  this.namespace = namespace;
972
973
  this.webSocketOnly = webSocketOnly;
973
974
  this.nodeAdmin = nodeAdmin;
974
975
  this.persistenceKey = persistenceKey;
975
976
  this.includeNamespaceInQueryParams = includeNamespaceInQueryParams;
977
+ this.isUsingEmulator = isUsingEmulator;
976
978
  this._host = host.toLowerCase();
977
979
  this._domain = this._host.substr(this._host.indexOf('.') + 1);
978
980
  this.internalHost =
@@ -2561,7 +2563,12 @@ var Connection = /** @class */ (function () {
2561
2563
  if (MESSAGE_DATA in controlData) {
2562
2564
  var payload = controlData[MESSAGE_DATA];
2563
2565
  if (cmd === SERVER_HELLO) {
2564
- this.onHandshake_(payload);
2566
+ var handshakePayload = __assign({}, payload);
2567
+ if (this.repoInfo_.isUsingEmulator) {
2568
+ // 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.
2569
+ handshakePayload.h = this.repoInfo_.host;
2570
+ }
2571
+ this.onHandshake_(handshakePayload);
2565
2572
  }
2566
2573
  else if (cmd === END_TRANSMISSION) {
2567
2574
  this.log_('recvd end transmission on primary');
@@ -13916,7 +13923,8 @@ var useRestClient = false;
13916
13923
  */
13917
13924
  function repoManagerApplyEmulatorSettings(repo, host, port, tokenProvider) {
13918
13925
  repo.repoInfo_ = new RepoInfo("".concat(host, ":").concat(port),
13919
- /* secure= */ false, repo.repoInfo_.namespace, repo.repoInfo_.webSocketOnly, repo.repoInfo_.nodeAdmin, repo.repoInfo_.persistenceKey, repo.repoInfo_.includeNamespaceInQueryParams);
13926
+ /* secure= */ false, repo.repoInfo_.namespace, repo.repoInfo_.webSocketOnly, repo.repoInfo_.nodeAdmin, repo.repoInfo_.persistenceKey, repo.repoInfo_.includeNamespaceInQueryParams,
13927
+ /*isUsingEmulator=*/ true);
13920
13928
  if (tokenProvider) {
13921
13929
  repo.authTokenProvider_ = tokenProvider;
13922
13930
  }