@firebase/database 0.12.8 → 0.13.0
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 +4 -4
package/dist/index.esm5.js
CHANGED
|
@@ -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 { stringify, jsonEval, contains, assert, base64, stringToByteArray, Sha1,
|
|
3
|
+
import { stringify, jsonEval, contains, assert, isNodeSdk, base64, stringToByteArray, Sha1, deepCopy, base64Encode, isMobileCordova, stringLength, Deferred, safeGet, isAdmin, isValidFormat, isEmpty, isReactNative, assertionError, map, querystring, errorPrefix, getModularInstance, createMockUserToken } from '@firebase/util';
|
|
4
4
|
import { __spreadArray, __read, __values, __extends, __awaiter, __generator, __assign } from 'tslib';
|
|
5
5
|
import { Logger, LogLevel } from '@firebase/logger';
|
|
6
6
|
|
|
7
7
|
var name = "@firebase/database";
|
|
8
|
-
var version = "0.
|
|
8
|
+
var version = "0.13.0";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @license
|
|
@@ -1873,7 +1873,7 @@ var WebSocketConnection = /** @class */ (function () {
|
|
|
1873
1873
|
this.bytesReceived = 0;
|
|
1874
1874
|
this.log_ = logWrapper(this.connId);
|
|
1875
1875
|
this.stats_ = statsManagerGetCollection(repoInfo);
|
|
1876
|
-
this.connURL = WebSocketConnection.connectionURL_(repoInfo, transportSessionId, lastSessionId, appCheckToken);
|
|
1876
|
+
this.connURL = WebSocketConnection.connectionURL_(repoInfo, transportSessionId, lastSessionId, appCheckToken, applicationId);
|
|
1877
1877
|
this.nodeAdmin = repoInfo.nodeAdmin;
|
|
1878
1878
|
}
|
|
1879
1879
|
/**
|
|
@@ -1883,7 +1883,7 @@ var WebSocketConnection = /** @class */ (function () {
|
|
|
1883
1883
|
* @param lastSessionId - Optional lastSessionId if there was a previous connection
|
|
1884
1884
|
* @returns connection url
|
|
1885
1885
|
*/
|
|
1886
|
-
WebSocketConnection.connectionURL_ = function (repoInfo, transportSessionId, lastSessionId, appCheckToken) {
|
|
1886
|
+
WebSocketConnection.connectionURL_ = function (repoInfo, transportSessionId, lastSessionId, appCheckToken, applicationId) {
|
|
1887
1887
|
var urlParams = {};
|
|
1888
1888
|
urlParams[VERSION_PARAM] = PROTOCOL_VERSION;
|
|
1889
1889
|
if (!isNodeSdk() &&
|
|
@@ -1901,6 +1901,9 @@ var WebSocketConnection = /** @class */ (function () {
|
|
|
1901
1901
|
if (appCheckToken) {
|
|
1902
1902
|
urlParams[APP_CHECK_TOKEN_PARAM] = appCheckToken;
|
|
1903
1903
|
}
|
|
1904
|
+
if (applicationId) {
|
|
1905
|
+
urlParams[APPLICATION_ID_PARAM] = applicationId;
|
|
1906
|
+
}
|
|
1904
1907
|
return repoInfoConnectionURL(repoInfo, WEBSOCKET, urlParams);
|
|
1905
1908
|
};
|
|
1906
1909
|
/**
|
|
@@ -1916,10 +1919,11 @@ var WebSocketConnection = /** @class */ (function () {
|
|
|
1916
1919
|
// Assume failure until proven otherwise.
|
|
1917
1920
|
PersistentStorage.set('previous_websocket_failure', true);
|
|
1918
1921
|
try {
|
|
1922
|
+
var options = void 0;
|
|
1919
1923
|
if (isNodeSdk()) {
|
|
1920
1924
|
var device = this.nodeAdmin ? 'AdminNode' : 'Node';
|
|
1921
1925
|
// UA Format: Firebase/<wire_protocol>/<sdk_version>/<platform>/<device>
|
|
1922
|
-
var
|
|
1926
|
+
var options_1 = {
|
|
1923
1927
|
headers: {
|
|
1924
1928
|
'User-Agent': "Firebase/" + PROTOCOL_VERSION + "/" + SDK_VERSION + "/" + process.platform + "/" + device,
|
|
1925
1929
|
'X-Firebase-GMPID': this.applicationId || ''
|
|
@@ -1931,10 +1935,10 @@ var WebSocketConnection = /** @class */ (function () {
|
|
|
1931
1935
|
// Note that this header is just used to bypass appcheck, and the token should still be sent
|
|
1932
1936
|
// through the websocket connection once it is established.
|
|
1933
1937
|
if (this.authToken) {
|
|
1934
|
-
|
|
1938
|
+
options_1.headers['Authorization'] = "Bearer " + this.authToken;
|
|
1935
1939
|
}
|
|
1936
1940
|
if (this.appCheckToken) {
|
|
1937
|
-
|
|
1941
|
+
options_1.headers['X-Firebase-AppCheck'] = this.appCheckToken;
|
|
1938
1942
|
}
|
|
1939
1943
|
// Plumb appropriate http_proxy environment variable into faye-websocket if it exists.
|
|
1940
1944
|
var env = process['env'];
|
|
@@ -1942,19 +1946,10 @@ var WebSocketConnection = /** @class */ (function () {
|
|
|
1942
1946
|
? env['HTTPS_PROXY'] || env['https_proxy']
|
|
1943
1947
|
: env['HTTP_PROXY'] || env['http_proxy'];
|
|
1944
1948
|
if (proxy) {
|
|
1945
|
-
|
|
1949
|
+
options_1['proxy'] = { origin: proxy };
|
|
1946
1950
|
}
|
|
1947
|
-
this.mySock = new WebSocketImpl(this.connURL, [], options);
|
|
1948
|
-
}
|
|
1949
|
-
else {
|
|
1950
|
-
var options = {
|
|
1951
|
-
headers: {
|
|
1952
|
-
'X-Firebase-GMPID': this.applicationId || '',
|
|
1953
|
-
'X-Firebase-AppCheck': this.appCheckToken || ''
|
|
1954
|
-
}
|
|
1955
|
-
};
|
|
1956
|
-
this.mySock = new WebSocketImpl(this.connURL, [], options);
|
|
1957
1951
|
}
|
|
1952
|
+
this.mySock = new WebSocketImpl(this.connURL, [], options);
|
|
1958
1953
|
}
|
|
1959
1954
|
catch (e) {
|
|
1960
1955
|
this.log_('Error instantiating WebSocket.');
|
|
@@ -2214,6 +2209,17 @@ var TransportManager = /** @class */ (function () {
|
|
|
2214
2209
|
enumerable: false,
|
|
2215
2210
|
configurable: true
|
|
2216
2211
|
});
|
|
2212
|
+
Object.defineProperty(TransportManager, "IS_TRANSPORT_INITIALIZED", {
|
|
2213
|
+
/**
|
|
2214
|
+
* Returns whether transport has been selected to ensure WebSocketConnection or BrowserPollConnection are not called after
|
|
2215
|
+
* TransportManager has already set up transports_
|
|
2216
|
+
*/
|
|
2217
|
+
get: function () {
|
|
2218
|
+
return this.globalTransportInitialized_;
|
|
2219
|
+
},
|
|
2220
|
+
enumerable: false,
|
|
2221
|
+
configurable: true
|
|
2222
|
+
});
|
|
2217
2223
|
TransportManager.prototype.initTransports_ = function (repoInfo) {
|
|
2218
2224
|
var e_1, _a;
|
|
2219
2225
|
var isWebSocketsAvailable = WebSocketConnection && WebSocketConnection['isAvailable']();
|
|
@@ -2244,6 +2250,7 @@ var TransportManager = /** @class */ (function () {
|
|
|
2244
2250
|
}
|
|
2245
2251
|
finally { if (e_1) throw e_1.error; }
|
|
2246
2252
|
}
|
|
2253
|
+
TransportManager.globalTransportInitialized_ = true;
|
|
2247
2254
|
}
|
|
2248
2255
|
};
|
|
2249
2256
|
/**
|
|
@@ -2268,6 +2275,8 @@ var TransportManager = /** @class */ (function () {
|
|
|
2268
2275
|
return null;
|
|
2269
2276
|
}
|
|
2270
2277
|
};
|
|
2278
|
+
// Keeps track of whether the TransportManager has already chosen a transport to use
|
|
2279
|
+
TransportManager.globalTransportInitialized_ = false;
|
|
2271
2280
|
return TransportManager;
|
|
2272
2281
|
}());
|
|
2273
2282
|
|
|
@@ -14118,6 +14127,26 @@ var Database = /** @class */ (function () {
|
|
|
14118
14127
|
};
|
|
14119
14128
|
return Database;
|
|
14120
14129
|
}());
|
|
14130
|
+
function checkTransportInit() {
|
|
14131
|
+
if (TransportManager.IS_TRANSPORT_INITIALIZED) {
|
|
14132
|
+
warn('Transport has already been initialized. Please call this function before calling ref or setting up a listener');
|
|
14133
|
+
}
|
|
14134
|
+
}
|
|
14135
|
+
/**
|
|
14136
|
+
* Force the use of websockets instead of longPolling.
|
|
14137
|
+
*/
|
|
14138
|
+
function forceWebSockets() {
|
|
14139
|
+
checkTransportInit();
|
|
14140
|
+
BrowserPollConnection.forceDisallow();
|
|
14141
|
+
}
|
|
14142
|
+
/**
|
|
14143
|
+
* Force the use of longPolling instead of websockets. This will be ignored if websocket protocol is used in databaseURL.
|
|
14144
|
+
*/
|
|
14145
|
+
function forceLongPolling() {
|
|
14146
|
+
checkTransportInit();
|
|
14147
|
+
WebSocketConnection.forceDisallow();
|
|
14148
|
+
BrowserPollConnection.forceAllow();
|
|
14149
|
+
}
|
|
14121
14150
|
/**
|
|
14122
14151
|
* Returns the instance of the Realtime Database SDK that is associated
|
|
14123
14152
|
* with the provided {@link @firebase/app#FirebaseApp}. Initializes a new instance with
|
|
@@ -14442,5 +14471,5 @@ var forceRestClient = function (forceRestClient) {
|
|
|
14442
14471
|
*/
|
|
14443
14472
|
registerDatabase();
|
|
14444
14473
|
|
|
14445
|
-
export { DataSnapshot, Database, OnDisconnect, QueryConstraint, TransactionResult, QueryImpl as _QueryImpl, QueryParams as _QueryParams, ReferenceImpl as _ReferenceImpl, forceRestClient as _TEST_ACCESS_forceRestClient, hijackHash as _TEST_ACCESS_hijackHash, repoManagerDatabaseFromApp as _repoManagerDatabaseFromApp, setSDKVersion as _setSDKVersion, validatePathString as _validatePathString, validateWritablePath as _validateWritablePath, child, connectDatabaseEmulator, enableLogging, endAt, endBefore, equalTo, get, getDatabase, goOffline, goOnline, increment, limitToFirst, limitToLast, off, onChildAdded, onChildChanged, onChildMoved, onChildRemoved, onDisconnect, onValue, orderByChild, orderByKey, orderByPriority, orderByValue, push, query, ref, refFromURL, remove, runTransaction, serverTimestamp, set, setPriority, setWithPriority, startAfter, startAt, update };
|
|
14474
|
+
export { DataSnapshot, Database, OnDisconnect, QueryConstraint, TransactionResult, QueryImpl as _QueryImpl, QueryParams as _QueryParams, ReferenceImpl as _ReferenceImpl, forceRestClient as _TEST_ACCESS_forceRestClient, hijackHash as _TEST_ACCESS_hijackHash, repoManagerDatabaseFromApp as _repoManagerDatabaseFromApp, setSDKVersion as _setSDKVersion, validatePathString as _validatePathString, validateWritablePath as _validateWritablePath, child, connectDatabaseEmulator, enableLogging, endAt, endBefore, equalTo, forceLongPolling, forceWebSockets, get, getDatabase, goOffline, goOnline, increment, limitToFirst, limitToLast, off, onChildAdded, onChildChanged, onChildMoved, onChildRemoved, onDisconnect, onValue, orderByChild, orderByKey, orderByPriority, orderByValue, push, query, ref, refFromURL, remove, runTransaction, serverTimestamp, set, setPriority, setWithPriority, startAfter, startAt, update };
|
|
14446
14475
|
//# sourceMappingURL=index.esm5.js.map
|