@firebase/database 0.13.0-20220505222723 → 0.13.0-canary.094da9eed

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.
@@ -987,7 +987,7 @@ var WebSocketConnection = /** @class */ (function () {
987
987
  this.bytesReceived = 0;
988
988
  this.log_ = logWrapper(this.connId);
989
989
  this.stats_ = statsManagerGetCollection(repoInfo);
990
- this.connURL = WebSocketConnection.connectionURL_(repoInfo, transportSessionId, lastSessionId, appCheckToken);
990
+ this.connURL = WebSocketConnection.connectionURL_(repoInfo, transportSessionId, lastSessionId, appCheckToken, applicationId);
991
991
  this.nodeAdmin = repoInfo.nodeAdmin;
992
992
  }
993
993
  /**
@@ -997,7 +997,7 @@ var WebSocketConnection = /** @class */ (function () {
997
997
  * @param lastSessionId - Optional lastSessionId if there was a previous connection
998
998
  * @returns connection url
999
999
  */
1000
- WebSocketConnection.connectionURL_ = function (repoInfo, transportSessionId, lastSessionId, appCheckToken) {
1000
+ WebSocketConnection.connectionURL_ = function (repoInfo, transportSessionId, lastSessionId, appCheckToken, applicationId) {
1001
1001
  var urlParams = {};
1002
1002
  urlParams[VERSION_PARAM] = PROTOCOL_VERSION;
1003
1003
  if (!util.isNodeSdk() &&
@@ -1015,6 +1015,9 @@ var WebSocketConnection = /** @class */ (function () {
1015
1015
  if (appCheckToken) {
1016
1016
  urlParams[APP_CHECK_TOKEN_PARAM] = appCheckToken;
1017
1017
  }
1018
+ if (applicationId) {
1019
+ urlParams[APPLICATION_ID_PARAM] = applicationId;
1020
+ }
1018
1021
  return repoInfoConnectionURL(repoInfo, WEBSOCKET, urlParams);
1019
1022
  };
1020
1023
  /**
@@ -1030,10 +1033,11 @@ var WebSocketConnection = /** @class */ (function () {
1030
1033
  // Assume failure until proven otherwise.
1031
1034
  PersistentStorage.set('previous_websocket_failure', true);
1032
1035
  try {
1036
+ var options = void 0;
1033
1037
  if (util.isNodeSdk()) {
1034
1038
  var device = this.nodeAdmin ? 'AdminNode' : 'Node';
1035
1039
  // UA Format: Firebase/<wire_protocol>/<sdk_version>/<platform>/<device>
1036
- var options = {
1040
+ var options_1 = {
1037
1041
  headers: {
1038
1042
  'User-Agent': "Firebase/" + PROTOCOL_VERSION + "/" + SDK_VERSION + "/" + process.platform + "/" + device,
1039
1043
  'X-Firebase-GMPID': this.applicationId || ''
@@ -1045,10 +1049,10 @@ var WebSocketConnection = /** @class */ (function () {
1045
1049
  // Note that this header is just used to bypass appcheck, and the token should still be sent
1046
1050
  // through the websocket connection once it is established.
1047
1051
  if (this.authToken) {
1048
- options.headers['Authorization'] = "Bearer " + this.authToken;
1052
+ options_1.headers['Authorization'] = "Bearer " + this.authToken;
1049
1053
  }
1050
1054
  if (this.appCheckToken) {
1051
- options.headers['X-Firebase-AppCheck'] = this.appCheckToken;
1055
+ options_1.headers['X-Firebase-AppCheck'] = this.appCheckToken;
1052
1056
  }
1053
1057
  // Plumb appropriate http_proxy environment variable into faye-websocket if it exists.
1054
1058
  var env = process['env'];
@@ -1056,19 +1060,10 @@ var WebSocketConnection = /** @class */ (function () {
1056
1060
  ? env['HTTPS_PROXY'] || env['https_proxy']
1057
1061
  : env['HTTP_PROXY'] || env['http_proxy'];
1058
1062
  if (proxy) {
1059
- options['proxy'] = { origin: proxy };
1063
+ options_1['proxy'] = { origin: proxy };
1060
1064
  }
1061
- this.mySock = new WebSocketImpl(this.connURL, [], options);
1062
- }
1063
- else {
1064
- var options = {
1065
- headers: {
1066
- 'X-Firebase-GMPID': this.applicationId || '',
1067
- 'X-Firebase-AppCheck': this.appCheckToken || ''
1068
- }
1069
- };
1070
- this.mySock = new WebSocketImpl(this.connURL, [], options);
1071
1065
  }
1066
+ this.mySock = new WebSocketImpl(this.connURL, [], options);
1072
1067
  }
1073
1068
  catch (e) {
1074
1069
  this.log_('Error instantiating WebSocket.');