@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.
@@ -2266,6 +2266,7 @@ declare class RepoInfo {
2266
2266
  readonly nodeAdmin: boolean;
2267
2267
  readonly persistenceKey: string;
2268
2268
  readonly includeNamespaceInQueryParams: boolean;
2269
+ readonly isUsingEmulator: boolean;
2269
2270
  private _host;
2270
2271
  private _domain;
2271
2272
  internalHost: string;
@@ -2277,7 +2278,7 @@ declare class RepoInfo {
2277
2278
  * @param nodeAdmin - Whether this instance uses Admin SDK credentials
2278
2279
  * @param persistenceKey - Override the default session persistence storage key
2279
2280
  */
2280
- constructor(host: string, secure: boolean, namespace: string, webSocketOnly: boolean, nodeAdmin?: boolean, persistenceKey?: string, includeNamespaceInQueryParams?: boolean);
2281
+ constructor(host: string, secure: boolean, namespace: string, webSocketOnly: boolean, nodeAdmin?: boolean, persistenceKey?: string, includeNamespaceInQueryParams?: boolean, isUsingEmulator?: boolean);
2281
2282
  isCacheableHost(): boolean;
2282
2283
  isCustomHost(): boolean;
2283
2284
  get host(): string;
@@ -721,13 +721,14 @@ class RepoInfo {
721
721
  * @param nodeAdmin - Whether this instance uses Admin SDK credentials
722
722
  * @param persistenceKey - Override the default session persistence storage key
723
723
  */
724
- constructor(host, secure, namespace, webSocketOnly, nodeAdmin = false, persistenceKey = '', includeNamespaceInQueryParams = false) {
724
+ constructor(host, secure, namespace, webSocketOnly, nodeAdmin = false, persistenceKey = '', includeNamespaceInQueryParams = false, isUsingEmulator = false) {
725
725
  this.secure = secure;
726
726
  this.namespace = namespace;
727
727
  this.webSocketOnly = webSocketOnly;
728
728
  this.nodeAdmin = nodeAdmin;
729
729
  this.persistenceKey = persistenceKey;
730
730
  this.includeNamespaceInQueryParams = includeNamespaceInQueryParams;
731
+ this.isUsingEmulator = isUsingEmulator;
731
732
  this._host = host.toLowerCase();
732
733
  this._domain = this._host.substr(this._host.indexOf('.') + 1);
733
734
  this.internalHost =
@@ -1250,7 +1251,7 @@ WebSocketConnection.responsesRequiredToBeHealthy = 2;
1250
1251
  WebSocketConnection.healthyTimeout = 30000;
1251
1252
 
1252
1253
  const name = "@firebase/database";
1253
- const version = "0.14.1";
1254
+ const version = "0.14.2-20230201003102";
1254
1255
 
1255
1256
  /**
1256
1257
  * @license
@@ -2469,7 +2470,12 @@ class Connection {
2469
2470
  if (MESSAGE_DATA in controlData) {
2470
2471
  const payload = controlData[MESSAGE_DATA];
2471
2472
  if (cmd === SERVER_HELLO) {
2472
- this.onHandshake_(payload);
2473
+ const handshakePayload = Object.assign({}, payload);
2474
+ if (this.repoInfo_.isUsingEmulator) {
2475
+ // 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.
2476
+ handshakePayload.h = this.repoInfo_.host;
2477
+ }
2478
+ this.onHandshake_(handshakePayload);
2473
2479
  }
2474
2480
  else if (cmd === END_TRANSMISSION) {
2475
2481
  this.log_('recvd end transmission on primary');
@@ -13457,7 +13463,8 @@ let useRestClient = false;
13457
13463
  */
13458
13464
  function repoManagerApplyEmulatorSettings(repo, host, port, tokenProvider) {
13459
13465
  repo.repoInfo_ = new RepoInfo(`${host}:${port}`,
13460
- /* secure= */ false, repo.repoInfo_.namespace, repo.repoInfo_.webSocketOnly, repo.repoInfo_.nodeAdmin, repo.repoInfo_.persistenceKey, repo.repoInfo_.includeNamespaceInQueryParams);
13466
+ /* secure= */ false, repo.repoInfo_.namespace, repo.repoInfo_.webSocketOnly, repo.repoInfo_.nodeAdmin, repo.repoInfo_.persistenceKey, repo.repoInfo_.includeNamespaceInQueryParams,
13467
+ /*isUsingEmulator=*/ true);
13461
13468
  if (tokenProvider) {
13462
13469
  repo.authTokenProvider_ = tokenProvider;
13463
13470
  }