@firebase/database 0.12.8 → 0.13.0-canary.61f7112e0
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.
- package/CHANGELOG.md +14 -0
- package/dist/index.esm2017.js +41 -16
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +48 -19
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +48 -17
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.standalone.js +47 -16
- package/dist/index.standalone.js.map +1 -1
- package/dist/internal.d.ts +10 -0
- package/dist/node-esm/index.node.esm.js +41 -16
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/api/Database.d.ts +8 -0
- package/dist/node-esm/src/api.standalone.d.ts +1 -1
- package/dist/node-esm/src/realtime/BrowserPollConnection.d.ts +2 -2
- package/dist/node-esm/src/realtime/TransportManager.d.ts +6 -0
- package/dist/node-esm/test/transport.test.d.ts +17 -0
- package/dist/node-esm/test/websocketconnection.test.d.ts +17 -0
- package/dist/private.d.ts +10 -0
- package/dist/public.d.ts +8 -0
- package/dist/src/api/Database.d.ts +8 -0
- package/dist/src/api.standalone.d.ts +1 -1
- package/dist/src/realtime/BrowserPollConnection.d.ts +2 -2
- package/dist/src/realtime/TransportManager.d.ts +6 -0
- package/dist/test/transport.test.d.ts +17 -0
- package/dist/test/websocketconnection.test.d.ts +17 -0
- package/package.json +7 -7
package/dist/index.standalone.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
1052
|
+
options_1.headers['Authorization'] = "Bearer " + this.authToken;
|
|
1049
1053
|
}
|
|
1050
1054
|
if (this.appCheckToken) {
|
|
1051
|
-
|
|
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
|
-
|
|
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.');
|
|
@@ -2221,6 +2216,17 @@ var TransportManager = /** @class */ (function () {
|
|
|
2221
2216
|
enumerable: false,
|
|
2222
2217
|
configurable: true
|
|
2223
2218
|
});
|
|
2219
|
+
Object.defineProperty(TransportManager, "IS_TRANSPORT_INITIALIZED", {
|
|
2220
|
+
/**
|
|
2221
|
+
* Returns whether transport has been selected to ensure WebSocketConnection or BrowserPollConnection are not called after
|
|
2222
|
+
* TransportManager has already set up transports_
|
|
2223
|
+
*/
|
|
2224
|
+
get: function () {
|
|
2225
|
+
return this.globalTransportInitialized_;
|
|
2226
|
+
},
|
|
2227
|
+
enumerable: false,
|
|
2228
|
+
configurable: true
|
|
2229
|
+
});
|
|
2224
2230
|
TransportManager.prototype.initTransports_ = function (repoInfo) {
|
|
2225
2231
|
var e_1, _a;
|
|
2226
2232
|
var isWebSocketsAvailable = WebSocketConnection && WebSocketConnection['isAvailable']();
|
|
@@ -2251,6 +2257,7 @@ var TransportManager = /** @class */ (function () {
|
|
|
2251
2257
|
}
|
|
2252
2258
|
finally { if (e_1) throw e_1.error; }
|
|
2253
2259
|
}
|
|
2260
|
+
TransportManager.globalTransportInitialized_ = true;
|
|
2254
2261
|
}
|
|
2255
2262
|
};
|
|
2256
2263
|
/**
|
|
@@ -2275,6 +2282,8 @@ var TransportManager = /** @class */ (function () {
|
|
|
2275
2282
|
return null;
|
|
2276
2283
|
}
|
|
2277
2284
|
};
|
|
2285
|
+
// Keeps track of whether the TransportManager has already chosen a transport to use
|
|
2286
|
+
TransportManager.globalTransportInitialized_ = false;
|
|
2278
2287
|
return TransportManager;
|
|
2279
2288
|
}());
|
|
2280
2289
|
|
|
@@ -14125,6 +14134,26 @@ var Database = /** @class */ (function () {
|
|
|
14125
14134
|
};
|
|
14126
14135
|
return Database;
|
|
14127
14136
|
}());
|
|
14137
|
+
function checkTransportInit() {
|
|
14138
|
+
if (TransportManager.IS_TRANSPORT_INITIALIZED) {
|
|
14139
|
+
warn('Transport has already been initialized. Please call this function before calling ref or setting up a listener');
|
|
14140
|
+
}
|
|
14141
|
+
}
|
|
14142
|
+
/**
|
|
14143
|
+
* Force the use of websockets instead of longPolling.
|
|
14144
|
+
*/
|
|
14145
|
+
function forceWebSockets() {
|
|
14146
|
+
checkTransportInit();
|
|
14147
|
+
BrowserPollConnection.forceDisallow();
|
|
14148
|
+
}
|
|
14149
|
+
/**
|
|
14150
|
+
* Force the use of longPolling instead of websockets. This will be ignored if websocket protocol is used in databaseURL.
|
|
14151
|
+
*/
|
|
14152
|
+
function forceLongPolling() {
|
|
14153
|
+
checkTransportInit();
|
|
14154
|
+
WebSocketConnection.forceDisallow();
|
|
14155
|
+
BrowserPollConnection.forceAllow();
|
|
14156
|
+
}
|
|
14128
14157
|
/**
|
|
14129
14158
|
* Modify the provided instance to communicate with the Realtime Database
|
|
14130
14159
|
* emulator.
|
|
@@ -14432,6 +14461,8 @@ exports.enableLogging = enableLogging;
|
|
|
14432
14461
|
exports.endAt = endAt;
|
|
14433
14462
|
exports.endBefore = endBefore;
|
|
14434
14463
|
exports.equalTo = equalTo;
|
|
14464
|
+
exports.forceLongPolling = forceLongPolling;
|
|
14465
|
+
exports.forceWebSockets = forceWebSockets;
|
|
14435
14466
|
exports.get = get;
|
|
14436
14467
|
exports.goOffline = goOffline;
|
|
14437
14468
|
exports.goOnline = goOnline;
|