@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.
@@ -4,7 +4,7 @@ import { stringify, jsonEval, contains, assert, isNodeSdk, stringToByteArray, Sh
4
4
  import { Logger, LogLevel } from '@firebase/logger';
5
5
 
6
6
  const name = "@firebase/database";
7
- const version = "0.14.1";
7
+ const version = "0.14.2-20230201003102";
8
8
 
9
9
  /**
10
10
  * @license
@@ -929,13 +929,14 @@ class RepoInfo {
929
929
  * @param nodeAdmin - Whether this instance uses Admin SDK credentials
930
930
  * @param persistenceKey - Override the default session persistence storage key
931
931
  */
932
- constructor(host, secure, namespace, webSocketOnly, nodeAdmin = false, persistenceKey = '', includeNamespaceInQueryParams = false) {
932
+ constructor(host, secure, namespace, webSocketOnly, nodeAdmin = false, persistenceKey = '', includeNamespaceInQueryParams = false, isUsingEmulator = false) {
933
933
  this.secure = secure;
934
934
  this.namespace = namespace;
935
935
  this.webSocketOnly = webSocketOnly;
936
936
  this.nodeAdmin = nodeAdmin;
937
937
  this.persistenceKey = persistenceKey;
938
938
  this.includeNamespaceInQueryParams = includeNamespaceInQueryParams;
939
+ this.isUsingEmulator = isUsingEmulator;
939
940
  this._host = host.toLowerCase();
940
941
  this._domain = this._host.substr(this._host.indexOf('.') + 1);
941
942
  this.internalHost =
@@ -2465,7 +2466,12 @@ class Connection {
2465
2466
  if (MESSAGE_DATA in controlData) {
2466
2467
  const payload = controlData[MESSAGE_DATA];
2467
2468
  if (cmd === SERVER_HELLO) {
2468
- this.onHandshake_(payload);
2469
+ const handshakePayload = Object.assign({}, payload);
2470
+ if (this.repoInfo_.isUsingEmulator) {
2471
+ // 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.
2472
+ handshakePayload.h = this.repoInfo_.host;
2473
+ }
2474
+ this.onHandshake_(handshakePayload);
2469
2475
  }
2470
2476
  else if (cmd === END_TRANSMISSION) {
2471
2477
  this.log_('recvd end transmission on primary');
@@ -13453,7 +13459,8 @@ let useRestClient = false;
13453
13459
  */
13454
13460
  function repoManagerApplyEmulatorSettings(repo, host, port, tokenProvider) {
13455
13461
  repo.repoInfo_ = new RepoInfo(`${host}:${port}`,
13456
- /* secure= */ false, repo.repoInfo_.namespace, repo.repoInfo_.webSocketOnly, repo.repoInfo_.nodeAdmin, repo.repoInfo_.persistenceKey, repo.repoInfo_.includeNamespaceInQueryParams);
13462
+ /* secure= */ false, repo.repoInfo_.namespace, repo.repoInfo_.webSocketOnly, repo.repoInfo_.nodeAdmin, repo.repoInfo_.persistenceKey, repo.repoInfo_.includeNamespaceInQueryParams,
13463
+ /*isUsingEmulator=*/ true);
13457
13464
  if (tokenProvider) {
13458
13465
  repo.authTokenProvider_ = tokenProvider;
13459
13466
  }