@firebase/database-compat 2.0.2-canary.3aefcc3e1 → 2.0.2-canary.5250e8006
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/dist/index.esm2017.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.standalone.js +1833 -282
- package/dist/index.standalone.js.map +1 -1
- package/dist/node-esm/index.js +1 -1
- package/package.json +7 -7
package/dist/index.standalone.js
CHANGED
@@ -8,12 +8,11 @@ var require$$1 = require('events');
|
|
8
8
|
var require$$0$1 = require('stream');
|
9
9
|
var require$$1$1 = require('crypto');
|
10
10
|
var require$$2$1 = require('url');
|
11
|
-
var require$$0$2 = require('assert');
|
12
11
|
var require$$1$2 = require('net');
|
13
12
|
var require$$2$2 = require('tls');
|
14
|
-
var require$$
|
15
|
-
var require$$
|
16
|
-
var require$$
|
13
|
+
var require$$2$3 = require('@firebase/util');
|
14
|
+
var require$$1$3 = require('@firebase/logger');
|
15
|
+
var require$$0$2 = require('@firebase/component');
|
17
16
|
|
18
17
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
19
18
|
|
@@ -23,12 +22,26 @@ var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
|
|
23
22
|
var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
|
24
23
|
var require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$1);
|
25
24
|
var require$$2__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$2$1);
|
26
|
-
var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$2);
|
27
25
|
var require$$1__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$1$2);
|
28
26
|
var require$$2__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$2$2);
|
29
|
-
var require$$1__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$1$3);
|
30
27
|
var require$$2__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$2$3);
|
31
|
-
var require$$
|
28
|
+
var require$$1__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$1$3);
|
29
|
+
var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$2);
|
30
|
+
|
31
|
+
function getAugmentedNamespace(n) {
|
32
|
+
if (n.__esModule) return n;
|
33
|
+
var a = Object.defineProperty({}, '__esModule', {value: true});
|
34
|
+
Object.keys(n).forEach(function (k) {
|
35
|
+
var d = Object.getOwnPropertyDescriptor(n, k);
|
36
|
+
Object.defineProperty(a, k, d.get ? d : {
|
37
|
+
enumerable: true,
|
38
|
+
get: function () {
|
39
|
+
return n[k];
|
40
|
+
}
|
41
|
+
});
|
42
|
+
});
|
43
|
+
return a;
|
44
|
+
}
|
32
45
|
|
33
46
|
var index_standalone = {};
|
34
47
|
|
@@ -547,17 +560,20 @@ var base = Base$7;
|
|
547
560
|
var httpParser = {};
|
548
561
|
|
549
562
|
/*jshint node:true */
|
550
|
-
var assert = require$$0__default$2["default"];
|
551
|
-
|
552
563
|
httpParser.HTTPParser = HTTPParser;
|
553
564
|
function HTTPParser(type) {
|
554
|
-
|
565
|
+
if (type !== undefined && type !== HTTPParser.REQUEST && type !== HTTPParser.RESPONSE) {
|
566
|
+
throw new Error('type must be REQUEST or RESPONSE');
|
567
|
+
}
|
555
568
|
if (type === undefined) ; else {
|
556
569
|
this.initialize(type);
|
557
570
|
}
|
571
|
+
this.maxHeaderSize=HTTPParser.maxHeaderSize;
|
558
572
|
}
|
559
573
|
HTTPParser.prototype.initialize = function (type, async_resource) {
|
560
|
-
|
574
|
+
if (type !== HTTPParser.REQUEST && type !== HTTPParser.RESPONSE) {
|
575
|
+
throw new Error('type must be REQUEST or RESPONSE');
|
576
|
+
}
|
561
577
|
this.type = type;
|
562
578
|
this.state = type + '_LINE';
|
563
579
|
this.info = {
|
@@ -634,13 +650,15 @@ var methods = httpParser.methods = HTTPParser.methods = [
|
|
634
650
|
'PURGE',
|
635
651
|
'MKCALENDAR',
|
636
652
|
'LINK',
|
637
|
-
'UNLINK'
|
653
|
+
'UNLINK',
|
654
|
+
'SOURCE',
|
638
655
|
];
|
639
656
|
var method_connect = methods.indexOf('CONNECT');
|
640
657
|
HTTPParser.prototype.reinitialize = HTTPParser;
|
641
658
|
HTTPParser.prototype.close =
|
642
659
|
HTTPParser.prototype.pause =
|
643
660
|
HTTPParser.prototype.resume =
|
661
|
+
HTTPParser.prototype.remove =
|
644
662
|
HTTPParser.prototype.free = function () {};
|
645
663
|
HTTPParser.prototype._compatMode0_11 = false;
|
646
664
|
HTTPParser.prototype.getAsyncId = function() { return 0; };
|
@@ -680,7 +698,7 @@ HTTPParser.prototype.execute = function (chunk, start, length) {
|
|
680
698
|
length = this.offset - start;
|
681
699
|
if (headerState[this.state]) {
|
682
700
|
this.headerSize += length;
|
683
|
-
if (this.headerSize > HTTPParser.maxHeaderSize) {
|
701
|
+
if (this.headerSize > (this.maxHeaderSize||HTTPParser.maxHeaderSize)) {
|
684
702
|
return new Error('max header size exceeded');
|
685
703
|
}
|
686
704
|
}
|
@@ -935,7 +953,8 @@ HTTPParser.prototype.BODY_CHUNKHEAD = function () {
|
|
935
953
|
|
936
954
|
HTTPParser.prototype.BODY_CHUNK = function () {
|
937
955
|
var length = Math.min(this.end - this.offset, this.body_bytes);
|
938
|
-
|
956
|
+
// 0, length are for backwards compatibility. See: https://github.com/creationix/http-parser-js/pull/98
|
957
|
+
this.userCall()(this[kOnBody](this.chunk.slice(this.offset, this.offset + length), 0, length));
|
939
958
|
this.offset += length;
|
940
959
|
this.body_bytes -= length;
|
941
960
|
if (!this.body_bytes) {
|
@@ -948,7 +967,9 @@ HTTPParser.prototype.BODY_CHUNKEMPTYLINE = function () {
|
|
948
967
|
if (line === undefined) {
|
949
968
|
return;
|
950
969
|
}
|
951
|
-
|
970
|
+
if (line !== '') {
|
971
|
+
throw new Error('Expected empty line');
|
972
|
+
}
|
952
973
|
this.state = 'BODY_CHUNKHEAD';
|
953
974
|
};
|
954
975
|
|
@@ -968,14 +989,15 @@ HTTPParser.prototype.BODY_CHUNKTRAILERS = function () {
|
|
968
989
|
};
|
969
990
|
|
970
991
|
HTTPParser.prototype.BODY_RAW = function () {
|
971
|
-
|
972
|
-
this.userCall()(this[kOnBody](this.chunk, this.
|
992
|
+
// 0, length are for backwards compatibility. See: https://github.com/creationix/http-parser-js/pull/98
|
993
|
+
this.userCall()(this[kOnBody](this.chunk.slice(this.offset, this.end), 0, this.end - this.offset));
|
973
994
|
this.offset = this.end;
|
974
995
|
};
|
975
996
|
|
976
997
|
HTTPParser.prototype.BODY_SIZED = function () {
|
977
998
|
var length = Math.min(this.end - this.offset, this.body_bytes);
|
978
|
-
|
999
|
+
// 0, length are for backwards compatibility. See: https://github.com/creationix/http-parser-js/pull/98
|
1000
|
+
this.userCall()(this[kOnBody](this.chunk.slice(this.offset, this.offset + length), 0, length));
|
979
1001
|
this.offset += length;
|
980
1002
|
this.body_bytes -= length;
|
981
1003
|
if (!this.body_bytes) {
|
@@ -2217,7 +2239,7 @@ var Buffer$4 = safeBuffer.exports.Buffer,
|
|
2217
2239
|
|
2218
2240
|
var PORTS = { 'ws:': 80, 'wss:': 443 };
|
2219
2241
|
|
2220
|
-
var Proxy$
|
2242
|
+
var Proxy$2 = function(client, origin, options) {
|
2221
2243
|
this._client = client;
|
2222
2244
|
this._http = new HttpParser$2('response');
|
2223
2245
|
this._origin = (typeof client.url === 'object') ? client.url : url$2.parse(client.url);
|
@@ -2236,7 +2258,7 @@ var Proxy$1 = function(client, origin, options) {
|
|
2236
2258
|
var auth = this._url.auth && Buffer$4.from(this._url.auth, 'utf8').toString('base64');
|
2237
2259
|
if (auth) this._headers.set('Proxy-Authorization', 'Basic ' + auth);
|
2238
2260
|
};
|
2239
|
-
util$9.inherits(Proxy$
|
2261
|
+
util$9.inherits(Proxy$2, Stream$2);
|
2240
2262
|
|
2241
2263
|
var instance$6 = {
|
2242
2264
|
setHeader: function(name, value) {
|
@@ -2301,9 +2323,9 @@ var instance$6 = {
|
|
2301
2323
|
};
|
2302
2324
|
|
2303
2325
|
for (var key$6 in instance$6)
|
2304
|
-
Proxy$
|
2326
|
+
Proxy$2.prototype[key$6] = instance$6[key$6];
|
2305
2327
|
|
2306
|
-
var proxy = Proxy$
|
2328
|
+
var proxy = Proxy$2;
|
2307
2329
|
|
2308
2330
|
var Buffer$3 = safeBuffer.exports.Buffer,
|
2309
2331
|
crypto$1 = require$$1__default$1["default"],
|
@@ -2312,7 +2334,7 @@ var Buffer$3 = safeBuffer.exports.Buffer,
|
|
2312
2334
|
HttpParser$1 = http_parser,
|
2313
2335
|
Base$4 = base,
|
2314
2336
|
Hybi$1 = hybi,
|
2315
|
-
Proxy = proxy;
|
2337
|
+
Proxy$1 = proxy;
|
2316
2338
|
|
2317
2339
|
var Client$2 = function(_url, options) {
|
2318
2340
|
this.version = 'hybi-' + Hybi$1.VERSION;
|
@@ -2353,7 +2375,7 @@ var instance$5 = {
|
|
2353
2375
|
VALID_PROTOCOLS: ['ws:', 'wss:'],
|
2354
2376
|
|
2355
2377
|
proxy: function(origin, options) {
|
2356
|
-
return new Proxy(this, origin, options);
|
2378
|
+
return new Proxy$1(this, origin, options);
|
2357
2379
|
},
|
2358
2380
|
|
2359
2381
|
start: function() {
|
@@ -3345,50 +3367,305 @@ WebSocket$1.EventSource = eventsource;
|
|
3345
3367
|
|
3346
3368
|
var websocket = WebSocket$1;
|
3347
3369
|
|
3348
|
-
|
3370
|
+
var index_cjs = {};
|
3371
|
+
|
3372
|
+
const instanceOfAny = (object, constructors) => constructors.some((c) => object instanceof c);
|
3373
|
+
|
3374
|
+
let idbProxyableTypes;
|
3375
|
+
let cursorAdvanceMethods;
|
3376
|
+
// This is a function to prevent it throwing up in node environments.
|
3377
|
+
function getIdbProxyableTypes() {
|
3378
|
+
return (idbProxyableTypes ||
|
3379
|
+
(idbProxyableTypes = [
|
3380
|
+
IDBDatabase,
|
3381
|
+
IDBObjectStore,
|
3382
|
+
IDBIndex,
|
3383
|
+
IDBCursor,
|
3384
|
+
IDBTransaction,
|
3385
|
+
]));
|
3386
|
+
}
|
3387
|
+
// This is a function to prevent it throwing up in node environments.
|
3388
|
+
function getCursorAdvanceMethods() {
|
3389
|
+
return (cursorAdvanceMethods ||
|
3390
|
+
(cursorAdvanceMethods = [
|
3391
|
+
IDBCursor.prototype.advance,
|
3392
|
+
IDBCursor.prototype.continue,
|
3393
|
+
IDBCursor.prototype.continuePrimaryKey,
|
3394
|
+
]));
|
3395
|
+
}
|
3396
|
+
const cursorRequestMap = new WeakMap();
|
3397
|
+
const transactionDoneMap = new WeakMap();
|
3398
|
+
const transactionStoreNamesMap = new WeakMap();
|
3399
|
+
const transformCache = new WeakMap();
|
3400
|
+
const reverseTransformCache = new WeakMap();
|
3401
|
+
function promisifyRequest(request) {
|
3402
|
+
const promise = new Promise((resolve, reject) => {
|
3403
|
+
const unlisten = () => {
|
3404
|
+
request.removeEventListener('success', success);
|
3405
|
+
request.removeEventListener('error', error);
|
3406
|
+
};
|
3407
|
+
const success = () => {
|
3408
|
+
resolve(wrap(request.result));
|
3409
|
+
unlisten();
|
3410
|
+
};
|
3411
|
+
const error = () => {
|
3412
|
+
reject(request.error);
|
3413
|
+
unlisten();
|
3414
|
+
};
|
3415
|
+
request.addEventListener('success', success);
|
3416
|
+
request.addEventListener('error', error);
|
3417
|
+
});
|
3418
|
+
promise
|
3419
|
+
.then((value) => {
|
3420
|
+
// Since cursoring reuses the IDBRequest (*sigh*), we cache it for later retrieval
|
3421
|
+
// (see wrapFunction).
|
3422
|
+
if (value instanceof IDBCursor) {
|
3423
|
+
cursorRequestMap.set(value, request);
|
3424
|
+
}
|
3425
|
+
// Catching to avoid "Uncaught Promise exceptions"
|
3426
|
+
})
|
3427
|
+
.catch(() => { });
|
3428
|
+
// This mapping exists in reverseTransformCache but doesn't doesn't exist in transformCache. This
|
3429
|
+
// is because we create many promises from a single IDBRequest.
|
3430
|
+
reverseTransformCache.set(promise, request);
|
3431
|
+
return promise;
|
3432
|
+
}
|
3433
|
+
function cacheDonePromiseForTransaction(tx) {
|
3434
|
+
// Early bail if we've already created a done promise for this transaction.
|
3435
|
+
if (transactionDoneMap.has(tx))
|
3436
|
+
return;
|
3437
|
+
const done = new Promise((resolve, reject) => {
|
3438
|
+
const unlisten = () => {
|
3439
|
+
tx.removeEventListener('complete', complete);
|
3440
|
+
tx.removeEventListener('error', error);
|
3441
|
+
tx.removeEventListener('abort', error);
|
3442
|
+
};
|
3443
|
+
const complete = () => {
|
3444
|
+
resolve();
|
3445
|
+
unlisten();
|
3446
|
+
};
|
3447
|
+
const error = () => {
|
3448
|
+
reject(tx.error || new DOMException('AbortError', 'AbortError'));
|
3449
|
+
unlisten();
|
3450
|
+
};
|
3451
|
+
tx.addEventListener('complete', complete);
|
3452
|
+
tx.addEventListener('error', error);
|
3453
|
+
tx.addEventListener('abort', error);
|
3454
|
+
});
|
3455
|
+
// Cache it for later retrieval.
|
3456
|
+
transactionDoneMap.set(tx, done);
|
3457
|
+
}
|
3458
|
+
let idbProxyTraps = {
|
3459
|
+
get(target, prop, receiver) {
|
3460
|
+
if (target instanceof IDBTransaction) {
|
3461
|
+
// Special handling for transaction.done.
|
3462
|
+
if (prop === 'done')
|
3463
|
+
return transactionDoneMap.get(target);
|
3464
|
+
// Polyfill for objectStoreNames because of Edge.
|
3465
|
+
if (prop === 'objectStoreNames') {
|
3466
|
+
return target.objectStoreNames || transactionStoreNamesMap.get(target);
|
3467
|
+
}
|
3468
|
+
// Make tx.store return the only store in the transaction, or undefined if there are many.
|
3469
|
+
if (prop === 'store') {
|
3470
|
+
return receiver.objectStoreNames[1]
|
3471
|
+
? undefined
|
3472
|
+
: receiver.objectStore(receiver.objectStoreNames[0]);
|
3473
|
+
}
|
3474
|
+
}
|
3475
|
+
// Else transform whatever we get back.
|
3476
|
+
return wrap(target[prop]);
|
3477
|
+
},
|
3478
|
+
set(target, prop, value) {
|
3479
|
+
target[prop] = value;
|
3480
|
+
return true;
|
3481
|
+
},
|
3482
|
+
has(target, prop) {
|
3483
|
+
if (target instanceof IDBTransaction &&
|
3484
|
+
(prop === 'done' || prop === 'store')) {
|
3485
|
+
return true;
|
3486
|
+
}
|
3487
|
+
return prop in target;
|
3488
|
+
},
|
3489
|
+
};
|
3490
|
+
function replaceTraps(callback) {
|
3491
|
+
idbProxyTraps = callback(idbProxyTraps);
|
3492
|
+
}
|
3493
|
+
function wrapFunction(func) {
|
3494
|
+
// Due to expected object equality (which is enforced by the caching in `wrap`), we
|
3495
|
+
// only create one new func per func.
|
3496
|
+
// Edge doesn't support objectStoreNames (booo), so we polyfill it here.
|
3497
|
+
if (func === IDBDatabase.prototype.transaction &&
|
3498
|
+
!('objectStoreNames' in IDBTransaction.prototype)) {
|
3499
|
+
return function (storeNames, ...args) {
|
3500
|
+
const tx = func.call(unwrap(this), storeNames, ...args);
|
3501
|
+
transactionStoreNamesMap.set(tx, storeNames.sort ? storeNames.sort() : [storeNames]);
|
3502
|
+
return wrap(tx);
|
3503
|
+
};
|
3504
|
+
}
|
3505
|
+
// Cursor methods are special, as the behaviour is a little more different to standard IDB. In
|
3506
|
+
// IDB, you advance the cursor and wait for a new 'success' on the IDBRequest that gave you the
|
3507
|
+
// cursor. It's kinda like a promise that can resolve with many values. That doesn't make sense
|
3508
|
+
// with real promises, so each advance methods returns a new promise for the cursor object, or
|
3509
|
+
// undefined if the end of the cursor has been reached.
|
3510
|
+
if (getCursorAdvanceMethods().includes(func)) {
|
3511
|
+
return function (...args) {
|
3512
|
+
// Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
|
3513
|
+
// the original object.
|
3514
|
+
func.apply(unwrap(this), args);
|
3515
|
+
return wrap(cursorRequestMap.get(this));
|
3516
|
+
};
|
3517
|
+
}
|
3518
|
+
return function (...args) {
|
3519
|
+
// Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
|
3520
|
+
// the original object.
|
3521
|
+
return wrap(func.apply(unwrap(this), args));
|
3522
|
+
};
|
3523
|
+
}
|
3524
|
+
function transformCachableValue(value) {
|
3525
|
+
if (typeof value === 'function')
|
3526
|
+
return wrapFunction(value);
|
3527
|
+
// This doesn't return, it just creates a 'done' promise for the transaction,
|
3528
|
+
// which is later returned for transaction.done (see idbObjectHandler).
|
3529
|
+
if (value instanceof IDBTransaction)
|
3530
|
+
cacheDonePromiseForTransaction(value);
|
3531
|
+
if (instanceOfAny(value, getIdbProxyableTypes()))
|
3532
|
+
return new Proxy(value, idbProxyTraps);
|
3533
|
+
// Return the same value back if we're not going to transform it.
|
3534
|
+
return value;
|
3535
|
+
}
|
3536
|
+
function wrap(value) {
|
3537
|
+
// We sometimes generate multiple promises from a single IDBRequest (eg when cursoring), because
|
3538
|
+
// IDB is weird and a single IDBRequest can yield many responses, so these can't be cached.
|
3539
|
+
if (value instanceof IDBRequest)
|
3540
|
+
return promisifyRequest(value);
|
3541
|
+
// If we've already transformed this value before, reuse the transformed value.
|
3542
|
+
// This is faster, but it also provides object equality.
|
3543
|
+
if (transformCache.has(value))
|
3544
|
+
return transformCache.get(value);
|
3545
|
+
const newValue = transformCachableValue(value);
|
3546
|
+
// Not all types are transformed.
|
3547
|
+
// These may be primitive types, so they can't be WeakMap keys.
|
3548
|
+
if (newValue !== value) {
|
3549
|
+
transformCache.set(value, newValue);
|
3550
|
+
reverseTransformCache.set(newValue, value);
|
3551
|
+
}
|
3552
|
+
return newValue;
|
3553
|
+
}
|
3554
|
+
const unwrap = (value) => reverseTransformCache.get(value);
|
3555
|
+
|
3556
|
+
/**
|
3557
|
+
* Open a database.
|
3558
|
+
*
|
3559
|
+
* @param name Name of the database.
|
3560
|
+
* @param version Schema version.
|
3561
|
+
* @param callbacks Additional callbacks.
|
3562
|
+
*/
|
3563
|
+
function openDB(name, version, { blocked, upgrade, blocking, terminated } = {}) {
|
3564
|
+
const request = indexedDB.open(name, version);
|
3565
|
+
const openPromise = wrap(request);
|
3566
|
+
if (upgrade) {
|
3567
|
+
request.addEventListener('upgradeneeded', (event) => {
|
3568
|
+
upgrade(wrap(request.result), event.oldVersion, event.newVersion, wrap(request.transaction), event);
|
3569
|
+
});
|
3570
|
+
}
|
3571
|
+
if (blocked) {
|
3572
|
+
request.addEventListener('blocked', (event) => blocked(
|
3573
|
+
// Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405
|
3574
|
+
event.oldVersion, event.newVersion, event));
|
3575
|
+
}
|
3576
|
+
openPromise
|
3577
|
+
.then((db) => {
|
3578
|
+
if (terminated)
|
3579
|
+
db.addEventListener('close', () => terminated());
|
3580
|
+
if (blocking) {
|
3581
|
+
db.addEventListener('versionchange', (event) => blocking(event.oldVersion, event.newVersion, event));
|
3582
|
+
}
|
3583
|
+
})
|
3584
|
+
.catch(() => { });
|
3585
|
+
return openPromise;
|
3586
|
+
}
|
3587
|
+
/**
|
3588
|
+
* Delete a database.
|
3589
|
+
*
|
3590
|
+
* @param name Name of the database.
|
3591
|
+
*/
|
3592
|
+
function deleteDB(name, { blocked } = {}) {
|
3593
|
+
const request = indexedDB.deleteDatabase(name);
|
3594
|
+
if (blocked) {
|
3595
|
+
request.addEventListener('blocked', (event) => blocked(
|
3596
|
+
// Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405
|
3597
|
+
event.oldVersion, event));
|
3598
|
+
}
|
3599
|
+
return wrap(request).then(() => undefined);
|
3600
|
+
}
|
3349
3601
|
|
3350
|
-
|
3351
|
-
|
3352
|
-
|
3353
|
-
|
3602
|
+
const readMethods = ['get', 'getKey', 'getAll', 'getAllKeys', 'count'];
|
3603
|
+
const writeMethods = ['put', 'add', 'delete', 'clear'];
|
3604
|
+
const cachedMethods = new Map();
|
3605
|
+
function getMethod(target, prop) {
|
3606
|
+
if (!(target instanceof IDBDatabase &&
|
3607
|
+
!(prop in target) &&
|
3608
|
+
typeof prop === 'string')) {
|
3609
|
+
return;
|
3610
|
+
}
|
3611
|
+
if (cachedMethods.get(prop))
|
3612
|
+
return cachedMethods.get(prop);
|
3613
|
+
const targetFuncName = prop.replace(/FromIndex$/, '');
|
3614
|
+
const useIndex = prop !== targetFuncName;
|
3615
|
+
const isWrite = writeMethods.includes(targetFuncName);
|
3616
|
+
if (
|
3617
|
+
// Bail if the target doesn't exist on the target. Eg, getAll isn't in Edge.
|
3618
|
+
!(targetFuncName in (useIndex ? IDBIndex : IDBObjectStore).prototype) ||
|
3619
|
+
!(isWrite || readMethods.includes(targetFuncName))) {
|
3620
|
+
return;
|
3621
|
+
}
|
3622
|
+
const method = async function (storeName, ...args) {
|
3623
|
+
// isWrite ? 'readwrite' : undefined gzipps better, but fails in Edge :(
|
3624
|
+
const tx = this.transaction(storeName, isWrite ? 'readwrite' : 'readonly');
|
3625
|
+
let target = tx.store;
|
3626
|
+
if (useIndex)
|
3627
|
+
target = target.index(args.shift());
|
3628
|
+
// Must reject if op rejects.
|
3629
|
+
// If it's a write operation, must reject if tx.done rejects.
|
3630
|
+
// Must reject with op rejection first.
|
3631
|
+
// Must resolve with op value.
|
3632
|
+
// Must handle both promises (no unhandled rejections)
|
3633
|
+
return (await Promise.all([
|
3634
|
+
target[targetFuncName](...args),
|
3635
|
+
isWrite && tx.done,
|
3636
|
+
]))[0];
|
3637
|
+
};
|
3638
|
+
cachedMethods.set(prop, method);
|
3639
|
+
return method;
|
3640
|
+
}
|
3641
|
+
replaceTraps((oldTraps) => ({
|
3642
|
+
...oldTraps,
|
3643
|
+
get: (target, prop, receiver) => getMethod(target, prop) || oldTraps.get(target, prop, receiver),
|
3644
|
+
has: (target, prop) => !!getMethod(target, prop) || oldTraps.has(target, prop),
|
3645
|
+
}));
|
3646
|
+
|
3647
|
+
var build = /*#__PURE__*/Object.freeze({
|
3648
|
+
__proto__: null,
|
3649
|
+
deleteDB: deleteDB,
|
3650
|
+
openDB: openDB,
|
3651
|
+
unwrap: unwrap,
|
3652
|
+
wrap: wrap
|
3653
|
+
});
|
3354
3654
|
|
3355
|
-
|
3655
|
+
var require$$3 = /*@__PURE__*/getAugmentedNamespace(build);
|
3356
3656
|
|
3357
|
-
|
3657
|
+
(function (exports) {
|
3358
3658
|
|
3359
|
-
|
3360
|
-
|
3361
|
-
|
3362
|
-
|
3363
|
-
|
3364
|
-
|
3365
|
-
* You may obtain a copy of the License at
|
3366
|
-
*
|
3367
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
3368
|
-
*
|
3369
|
-
* Unless required by applicable law or agreed to in writing, software
|
3370
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
3371
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
3372
|
-
* See the License for the specific language governing permissions and
|
3373
|
-
* limitations under the License.
|
3374
|
-
*/
|
3375
|
-
const PROTOCOL_VERSION = '5';
|
3376
|
-
const VERSION_PARAM = 'v';
|
3377
|
-
const TRANSPORT_SESSION_PARAM = 's';
|
3378
|
-
const REFERER_PARAM = 'r';
|
3379
|
-
const FORGE_REF = 'f';
|
3380
|
-
// Matches console.firebase.google.com, firebase-console-*.corp.google.com and
|
3381
|
-
// firebase.corp.google.com
|
3382
|
-
const FORGE_DOMAIN_RE = /(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/;
|
3383
|
-
const LAST_SESSION_PARAM = 'ls';
|
3384
|
-
const APPLICATION_ID_PARAM = 'p';
|
3385
|
-
const APP_CHECK_TOKEN_PARAM = 'ac';
|
3386
|
-
const WEBSOCKET = 'websocket';
|
3387
|
-
const LONG_POLLING = 'long_polling';
|
3659
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
3660
|
+
|
3661
|
+
var component = require$$0__default$2["default"];
|
3662
|
+
var logger$1 = require$$1__default$3["default"];
|
3663
|
+
var util = require$$2__default$3["default"];
|
3664
|
+
var idb = require$$3;
|
3388
3665
|
|
3389
3666
|
/**
|
3390
3667
|
* @license
|
3391
|
-
* Copyright
|
3668
|
+
* Copyright 2019 Google LLC
|
3392
3669
|
*
|
3393
3670
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
3394
3671
|
* you may not use this file except in compliance with the License.
|
@@ -3402,62 +3679,49 @@ const LONG_POLLING = 'long_polling';
|
|
3402
3679
|
* See the License for the specific language governing permissions and
|
3403
3680
|
* limitations under the License.
|
3404
3681
|
*/
|
3682
|
+
class PlatformLoggerServiceImpl {
|
3683
|
+
constructor(container) {
|
3684
|
+
this.container = container;
|
3685
|
+
}
|
3686
|
+
// In initial implementation, this will be called by installations on
|
3687
|
+
// auth token refresh, and installations will send this string.
|
3688
|
+
getPlatformInfoString() {
|
3689
|
+
const providers = this.container.getProviders();
|
3690
|
+
// Loop through providers and get library/version pairs from any that are
|
3691
|
+
// version components.
|
3692
|
+
return providers
|
3693
|
+
.map(provider => {
|
3694
|
+
if (isVersionServiceProvider(provider)) {
|
3695
|
+
const service = provider.getImmediate();
|
3696
|
+
return `${service.library}/${service.version}`;
|
3697
|
+
}
|
3698
|
+
else {
|
3699
|
+
return null;
|
3700
|
+
}
|
3701
|
+
})
|
3702
|
+
.filter(logString => logString)
|
3703
|
+
.join(' ');
|
3704
|
+
}
|
3705
|
+
}
|
3405
3706
|
/**
|
3406
|
-
* Wraps a DOM Storage object and:
|
3407
|
-
* - automatically encode objects as JSON strings before storing them to allow us to store arbitrary types.
|
3408
|
-
* - prefixes names with "firebase:" to avoid collisions with app data.
|
3409
3707
|
*
|
3410
|
-
*
|
3411
|
-
* and one for localStorage.
|
3708
|
+
* @param provider check if this provider provides a VersionService
|
3412
3709
|
*
|
3710
|
+
* NOTE: Using Provider<'app-version'> is a hack to indicate that the provider
|
3711
|
+
* provides VersionService. The provider is not necessarily a 'app-version'
|
3712
|
+
* provider.
|
3413
3713
|
*/
|
3414
|
-
|
3415
|
-
|
3416
|
-
|
3417
|
-
*/
|
3418
|
-
constructor(domStorage_) {
|
3419
|
-
this.domStorage_ = domStorage_;
|
3420
|
-
// Use a prefix to avoid collisions with other stuff saved by the app.
|
3421
|
-
this.prefix_ = 'firebase:';
|
3422
|
-
}
|
3423
|
-
/**
|
3424
|
-
* @param key - The key to save the value under
|
3425
|
-
* @param value - The value being stored, or null to remove the key.
|
3426
|
-
*/
|
3427
|
-
set(key, value) {
|
3428
|
-
if (value == null) {
|
3429
|
-
this.domStorage_.removeItem(this.prefixedName_(key));
|
3430
|
-
}
|
3431
|
-
else {
|
3432
|
-
this.domStorage_.setItem(this.prefixedName_(key), util.stringify(value));
|
3433
|
-
}
|
3434
|
-
}
|
3435
|
-
/**
|
3436
|
-
* @returns The value that was stored under this key, or null
|
3437
|
-
*/
|
3438
|
-
get(key) {
|
3439
|
-
const storedVal = this.domStorage_.getItem(this.prefixedName_(key));
|
3440
|
-
if (storedVal == null) {
|
3441
|
-
return null;
|
3442
|
-
}
|
3443
|
-
else {
|
3444
|
-
return util.jsonEval(storedVal);
|
3445
|
-
}
|
3446
|
-
}
|
3447
|
-
remove(key) {
|
3448
|
-
this.domStorage_.removeItem(this.prefixedName_(key));
|
3449
|
-
}
|
3450
|
-
prefixedName_(name) {
|
3451
|
-
return this.prefix_ + name;
|
3452
|
-
}
|
3453
|
-
toString() {
|
3454
|
-
return this.domStorage_.toString();
|
3455
|
-
}
|
3714
|
+
function isVersionServiceProvider(provider) {
|
3715
|
+
const component = provider.getComponent();
|
3716
|
+
return (component === null || component === void 0 ? void 0 : component.type) === "VERSION" /* ComponentType.VERSION */;
|
3456
3717
|
}
|
3457
3718
|
|
3719
|
+
const name$q = "@firebase/app";
|
3720
|
+
const version$1 = "0.10.18-canary.5250e8006";
|
3721
|
+
|
3458
3722
|
/**
|
3459
3723
|
* @license
|
3460
|
-
* Copyright
|
3724
|
+
* Copyright 2019 Google LLC
|
3461
3725
|
*
|
3462
3726
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
3463
3727
|
* you may not use this file except in compliance with the License.
|
@@ -3471,37 +3735,64 @@ class DOMStorageWrapper {
|
|
3471
3735
|
* See the License for the specific language governing permissions and
|
3472
3736
|
* limitations under the License.
|
3473
3737
|
*/
|
3474
|
-
|
3475
|
-
|
3476
|
-
|
3477
|
-
|
3478
|
-
|
3479
|
-
|
3480
|
-
|
3481
|
-
|
3482
|
-
|
3483
|
-
|
3484
|
-
|
3485
|
-
|
3486
|
-
|
3487
|
-
|
3488
|
-
|
3489
|
-
|
3490
|
-
|
3491
|
-
|
3492
|
-
|
3493
|
-
|
3494
|
-
|
3495
|
-
|
3496
|
-
|
3497
|
-
|
3498
|
-
|
3499
|
-
|
3500
|
-
|
3738
|
+
const logger = new logger$1.Logger('@firebase/app');
|
3739
|
+
|
3740
|
+
const name$p = "@firebase/app-compat";
|
3741
|
+
|
3742
|
+
const name$o = "@firebase/analytics-compat";
|
3743
|
+
|
3744
|
+
const name$n = "@firebase/analytics";
|
3745
|
+
|
3746
|
+
const name$m = "@firebase/app-check-compat";
|
3747
|
+
|
3748
|
+
const name$l = "@firebase/app-check";
|
3749
|
+
|
3750
|
+
const name$k = "@firebase/auth";
|
3751
|
+
|
3752
|
+
const name$j = "@firebase/auth-compat";
|
3753
|
+
|
3754
|
+
const name$i = "@firebase/database";
|
3755
|
+
|
3756
|
+
const name$h = "@firebase/data-connect";
|
3757
|
+
|
3758
|
+
const name$g = "@firebase/database-compat";
|
3759
|
+
|
3760
|
+
const name$f = "@firebase/functions";
|
3761
|
+
|
3762
|
+
const name$e = "@firebase/functions-compat";
|
3763
|
+
|
3764
|
+
const name$d = "@firebase/installations";
|
3765
|
+
|
3766
|
+
const name$c = "@firebase/installations-compat";
|
3767
|
+
|
3768
|
+
const name$b = "@firebase/messaging";
|
3769
|
+
|
3770
|
+
const name$a = "@firebase/messaging-compat";
|
3771
|
+
|
3772
|
+
const name$9 = "@firebase/performance";
|
3773
|
+
|
3774
|
+
const name$8 = "@firebase/performance-compat";
|
3775
|
+
|
3776
|
+
const name$7 = "@firebase/remote-config";
|
3777
|
+
|
3778
|
+
const name$6 = "@firebase/remote-config-compat";
|
3779
|
+
|
3780
|
+
const name$5 = "@firebase/storage";
|
3781
|
+
|
3782
|
+
const name$4 = "@firebase/storage-compat";
|
3783
|
+
|
3784
|
+
const name$3 = "@firebase/firestore";
|
3785
|
+
|
3786
|
+
const name$2 = "@firebase/vertexai";
|
3787
|
+
|
3788
|
+
const name$1 = "@firebase/firestore-compat";
|
3789
|
+
|
3790
|
+
const name = "firebase";
|
3791
|
+
const version = "11.2.0-canary.5250e8006";
|
3501
3792
|
|
3502
3793
|
/**
|
3503
3794
|
* @license
|
3504
|
-
* Copyright
|
3795
|
+
* Copyright 2019 Google LLC
|
3505
3796
|
*
|
3506
3797
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
3507
3798
|
* you may not use this file except in compliance with the License.
|
@@ -3516,40 +3807,45 @@ class MemoryStorage {
|
|
3516
3807
|
* limitations under the License.
|
3517
3808
|
*/
|
3518
3809
|
/**
|
3519
|
-
*
|
3520
|
-
* TODO: Once MemoryStorage and DOMStorageWrapper have a shared interface this method annotation should change
|
3521
|
-
* to reflect this type
|
3810
|
+
* The default app name
|
3522
3811
|
*
|
3523
|
-
* @
|
3524
|
-
* (e.g. 'localStorage' or 'sessionStorage').
|
3525
|
-
* @returns Turning off type information until a common interface is defined.
|
3812
|
+
* @internal
|
3526
3813
|
*/
|
3527
|
-
const
|
3528
|
-
|
3529
|
-
|
3530
|
-
|
3531
|
-
|
3532
|
-
|
3533
|
-
|
3534
|
-
|
3535
|
-
|
3536
|
-
|
3537
|
-
|
3538
|
-
|
3539
|
-
|
3540
|
-
|
3541
|
-
|
3542
|
-
|
3543
|
-
|
3814
|
+
const DEFAULT_ENTRY_NAME = '[DEFAULT]';
|
3815
|
+
const PLATFORM_LOG_STRING = {
|
3816
|
+
[name$q]: 'fire-core',
|
3817
|
+
[name$p]: 'fire-core-compat',
|
3818
|
+
[name$n]: 'fire-analytics',
|
3819
|
+
[name$o]: 'fire-analytics-compat',
|
3820
|
+
[name$l]: 'fire-app-check',
|
3821
|
+
[name$m]: 'fire-app-check-compat',
|
3822
|
+
[name$k]: 'fire-auth',
|
3823
|
+
[name$j]: 'fire-auth-compat',
|
3824
|
+
[name$i]: 'fire-rtdb',
|
3825
|
+
[name$h]: 'fire-data-connect',
|
3826
|
+
[name$g]: 'fire-rtdb-compat',
|
3827
|
+
[name$f]: 'fire-fn',
|
3828
|
+
[name$e]: 'fire-fn-compat',
|
3829
|
+
[name$d]: 'fire-iid',
|
3830
|
+
[name$c]: 'fire-iid-compat',
|
3831
|
+
[name$b]: 'fire-fcm',
|
3832
|
+
[name$a]: 'fire-fcm-compat',
|
3833
|
+
[name$9]: 'fire-perf',
|
3834
|
+
[name$8]: 'fire-perf-compat',
|
3835
|
+
[name$7]: 'fire-rc',
|
3836
|
+
[name$6]: 'fire-rc-compat',
|
3837
|
+
[name$5]: 'fire-gcs',
|
3838
|
+
[name$4]: 'fire-gcs-compat',
|
3839
|
+
[name$3]: 'fire-fst',
|
3840
|
+
[name$1]: 'fire-fst-compat',
|
3841
|
+
[name$2]: 'fire-vertex',
|
3842
|
+
'fire-js': 'fire-js', // Platform identifier for JS SDK.
|
3843
|
+
[name]: 'fire-js-all'
|
3544
3844
|
};
|
3545
|
-
/** A storage object that lasts across sessions */
|
3546
|
-
const PersistentStorage = createStoragefor('localStorage');
|
3547
|
-
/** A storage object that only lasts one session */
|
3548
|
-
const SessionStorage = createStoragefor('sessionStorage');
|
3549
3845
|
|
3550
3846
|
/**
|
3551
3847
|
* @license
|
3552
|
-
* Copyright
|
3848
|
+
* Copyright 2019 Google LLC
|
3553
3849
|
*
|
3554
3850
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
3555
3851
|
* you may not use this file except in compliance with the License.
|
@@ -3563,38 +3859,1284 @@ const SessionStorage = createStoragefor('sessionStorage');
|
|
3563
3859
|
* See the License for the specific language governing permissions and
|
3564
3860
|
* limitations under the License.
|
3565
3861
|
*/
|
3566
|
-
const logClient$1 = new logger$1.Logger('@firebase/database');
|
3567
3862
|
/**
|
3568
|
-
*
|
3863
|
+
* @internal
|
3569
3864
|
*/
|
3570
|
-
const
|
3571
|
-
let id = 1;
|
3572
|
-
return function () {
|
3573
|
-
return id++;
|
3574
|
-
};
|
3575
|
-
})();
|
3865
|
+
const _apps = new Map();
|
3576
3866
|
/**
|
3577
|
-
*
|
3578
|
-
* @param str - The string to hash
|
3579
|
-
* @returns {!string} The resulting hash
|
3867
|
+
* @internal
|
3580
3868
|
*/
|
3581
|
-
const
|
3582
|
-
|
3583
|
-
|
3584
|
-
|
3585
|
-
|
3586
|
-
|
3587
|
-
|
3588
|
-
const
|
3589
|
-
|
3590
|
-
|
3591
|
-
|
3592
|
-
|
3593
|
-
|
3594
|
-
|
3595
|
-
|
3596
|
-
|
3597
|
-
|
3869
|
+
const _serverApps = new Map();
|
3870
|
+
/**
|
3871
|
+
* Registered components.
|
3872
|
+
*
|
3873
|
+
* @internal
|
3874
|
+
*/
|
3875
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
3876
|
+
const _components = new Map();
|
3877
|
+
/**
|
3878
|
+
* @param component - the component being added to this app's container
|
3879
|
+
*
|
3880
|
+
* @internal
|
3881
|
+
*/
|
3882
|
+
function _addComponent(app, component) {
|
3883
|
+
try {
|
3884
|
+
app.container.addComponent(component);
|
3885
|
+
}
|
3886
|
+
catch (e) {
|
3887
|
+
logger.debug(`Component ${component.name} failed to register with FirebaseApp ${app.name}`, e);
|
3888
|
+
}
|
3889
|
+
}
|
3890
|
+
/**
|
3891
|
+
*
|
3892
|
+
* @internal
|
3893
|
+
*/
|
3894
|
+
function _addOrOverwriteComponent(app, component) {
|
3895
|
+
app.container.addOrOverwriteComponent(component);
|
3896
|
+
}
|
3897
|
+
/**
|
3898
|
+
*
|
3899
|
+
* @param component - the component to register
|
3900
|
+
* @returns whether or not the component is registered successfully
|
3901
|
+
*
|
3902
|
+
* @internal
|
3903
|
+
*/
|
3904
|
+
function _registerComponent(component) {
|
3905
|
+
const componentName = component.name;
|
3906
|
+
if (_components.has(componentName)) {
|
3907
|
+
logger.debug(`There were multiple attempts to register component ${componentName}.`);
|
3908
|
+
return false;
|
3909
|
+
}
|
3910
|
+
_components.set(componentName, component);
|
3911
|
+
// add the component to existing app instances
|
3912
|
+
for (const app of _apps.values()) {
|
3913
|
+
_addComponent(app, component);
|
3914
|
+
}
|
3915
|
+
for (const serverApp of _serverApps.values()) {
|
3916
|
+
_addComponent(serverApp, component);
|
3917
|
+
}
|
3918
|
+
return true;
|
3919
|
+
}
|
3920
|
+
/**
|
3921
|
+
*
|
3922
|
+
* @param app - FirebaseApp instance
|
3923
|
+
* @param name - service name
|
3924
|
+
*
|
3925
|
+
* @returns the provider for the service with the matching name
|
3926
|
+
*
|
3927
|
+
* @internal
|
3928
|
+
*/
|
3929
|
+
function _getProvider(app, name) {
|
3930
|
+
const heartbeatController = app.container
|
3931
|
+
.getProvider('heartbeat')
|
3932
|
+
.getImmediate({ optional: true });
|
3933
|
+
if (heartbeatController) {
|
3934
|
+
void heartbeatController.triggerHeartbeat();
|
3935
|
+
}
|
3936
|
+
return app.container.getProvider(name);
|
3937
|
+
}
|
3938
|
+
/**
|
3939
|
+
*
|
3940
|
+
* @param app - FirebaseApp instance
|
3941
|
+
* @param name - service name
|
3942
|
+
* @param instanceIdentifier - service instance identifier in case the service supports multiple instances
|
3943
|
+
*
|
3944
|
+
* @internal
|
3945
|
+
*/
|
3946
|
+
function _removeServiceInstance(app, name, instanceIdentifier = DEFAULT_ENTRY_NAME) {
|
3947
|
+
_getProvider(app, name).clearInstance(instanceIdentifier);
|
3948
|
+
}
|
3949
|
+
/**
|
3950
|
+
*
|
3951
|
+
* @param obj - an object of type FirebaseApp or FirebaseOptions.
|
3952
|
+
*
|
3953
|
+
* @returns true if the provide object is of type FirebaseApp.
|
3954
|
+
*
|
3955
|
+
* @internal
|
3956
|
+
*/
|
3957
|
+
function _isFirebaseApp(obj) {
|
3958
|
+
return obj.options !== undefined;
|
3959
|
+
}
|
3960
|
+
/**
|
3961
|
+
*
|
3962
|
+
* @param obj - an object of type FirebaseApp.
|
3963
|
+
*
|
3964
|
+
* @returns true if the provided object is of type FirebaseServerAppImpl.
|
3965
|
+
*
|
3966
|
+
* @internal
|
3967
|
+
*/
|
3968
|
+
function _isFirebaseServerApp(obj) {
|
3969
|
+
if (obj === null || obj === undefined) {
|
3970
|
+
return false;
|
3971
|
+
}
|
3972
|
+
return obj.settings !== undefined;
|
3973
|
+
}
|
3974
|
+
/**
|
3975
|
+
* Test only
|
3976
|
+
*
|
3977
|
+
* @internal
|
3978
|
+
*/
|
3979
|
+
function _clearComponents() {
|
3980
|
+
_components.clear();
|
3981
|
+
}
|
3982
|
+
|
3983
|
+
/**
|
3984
|
+
* @license
|
3985
|
+
* Copyright 2019 Google LLC
|
3986
|
+
*
|
3987
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
3988
|
+
* you may not use this file except in compliance with the License.
|
3989
|
+
* You may obtain a copy of the License at
|
3990
|
+
*
|
3991
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
3992
|
+
*
|
3993
|
+
* Unless required by applicable law or agreed to in writing, software
|
3994
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
3995
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
3996
|
+
* See the License for the specific language governing permissions and
|
3997
|
+
* limitations under the License.
|
3998
|
+
*/
|
3999
|
+
const ERRORS = {
|
4000
|
+
["no-app" /* AppError.NO_APP */]: "No Firebase App '{$appName}' has been created - " +
|
4001
|
+
'call initializeApp() first',
|
4002
|
+
["bad-app-name" /* AppError.BAD_APP_NAME */]: "Illegal App name: '{$appName}'",
|
4003
|
+
["duplicate-app" /* AppError.DUPLICATE_APP */]: "Firebase App named '{$appName}' already exists with different options or config",
|
4004
|
+
["app-deleted" /* AppError.APP_DELETED */]: "Firebase App named '{$appName}' already deleted",
|
4005
|
+
["server-app-deleted" /* AppError.SERVER_APP_DELETED */]: 'Firebase Server App has been deleted',
|
4006
|
+
["no-options" /* AppError.NO_OPTIONS */]: 'Need to provide options, when not being deployed to hosting via source.',
|
4007
|
+
["invalid-app-argument" /* AppError.INVALID_APP_ARGUMENT */]: 'firebase.{$appName}() takes either no argument or a ' +
|
4008
|
+
'Firebase App instance.',
|
4009
|
+
["invalid-log-argument" /* AppError.INVALID_LOG_ARGUMENT */]: 'First argument to `onLog` must be null or a function.',
|
4010
|
+
["idb-open" /* AppError.IDB_OPEN */]: 'Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.',
|
4011
|
+
["idb-get" /* AppError.IDB_GET */]: 'Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.',
|
4012
|
+
["idb-set" /* AppError.IDB_WRITE */]: 'Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.',
|
4013
|
+
["idb-delete" /* AppError.IDB_DELETE */]: 'Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.',
|
4014
|
+
["finalization-registry-not-supported" /* AppError.FINALIZATION_REGISTRY_NOT_SUPPORTED */]: 'FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.',
|
4015
|
+
["invalid-server-app-environment" /* AppError.INVALID_SERVER_APP_ENVIRONMENT */]: 'FirebaseServerApp is not for use in browser environments.'
|
4016
|
+
};
|
4017
|
+
const ERROR_FACTORY = new util.ErrorFactory('app', 'Firebase', ERRORS);
|
4018
|
+
|
4019
|
+
/**
|
4020
|
+
* @license
|
4021
|
+
* Copyright 2019 Google LLC
|
4022
|
+
*
|
4023
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
4024
|
+
* you may not use this file except in compliance with the License.
|
4025
|
+
* You may obtain a copy of the License at
|
4026
|
+
*
|
4027
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
4028
|
+
*
|
4029
|
+
* Unless required by applicable law or agreed to in writing, software
|
4030
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
4031
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
4032
|
+
* See the License for the specific language governing permissions and
|
4033
|
+
* limitations under the License.
|
4034
|
+
*/
|
4035
|
+
class FirebaseAppImpl {
|
4036
|
+
constructor(options, config, container) {
|
4037
|
+
this._isDeleted = false;
|
4038
|
+
this._options = Object.assign({}, options);
|
4039
|
+
this._config = Object.assign({}, config);
|
4040
|
+
this._name = config.name;
|
4041
|
+
this._automaticDataCollectionEnabled =
|
4042
|
+
config.automaticDataCollectionEnabled;
|
4043
|
+
this._container = container;
|
4044
|
+
this.container.addComponent(new component.Component('app', () => this, "PUBLIC" /* ComponentType.PUBLIC */));
|
4045
|
+
}
|
4046
|
+
get automaticDataCollectionEnabled() {
|
4047
|
+
this.checkDestroyed();
|
4048
|
+
return this._automaticDataCollectionEnabled;
|
4049
|
+
}
|
4050
|
+
set automaticDataCollectionEnabled(val) {
|
4051
|
+
this.checkDestroyed();
|
4052
|
+
this._automaticDataCollectionEnabled = val;
|
4053
|
+
}
|
4054
|
+
get name() {
|
4055
|
+
this.checkDestroyed();
|
4056
|
+
return this._name;
|
4057
|
+
}
|
4058
|
+
get options() {
|
4059
|
+
this.checkDestroyed();
|
4060
|
+
return this._options;
|
4061
|
+
}
|
4062
|
+
get config() {
|
4063
|
+
this.checkDestroyed();
|
4064
|
+
return this._config;
|
4065
|
+
}
|
4066
|
+
get container() {
|
4067
|
+
return this._container;
|
4068
|
+
}
|
4069
|
+
get isDeleted() {
|
4070
|
+
return this._isDeleted;
|
4071
|
+
}
|
4072
|
+
set isDeleted(val) {
|
4073
|
+
this._isDeleted = val;
|
4074
|
+
}
|
4075
|
+
/**
|
4076
|
+
* This function will throw an Error if the App has already been deleted -
|
4077
|
+
* use before performing API actions on the App.
|
4078
|
+
*/
|
4079
|
+
checkDestroyed() {
|
4080
|
+
if (this.isDeleted) {
|
4081
|
+
throw ERROR_FACTORY.create("app-deleted" /* AppError.APP_DELETED */, { appName: this._name });
|
4082
|
+
}
|
4083
|
+
}
|
4084
|
+
}
|
4085
|
+
|
4086
|
+
/**
|
4087
|
+
* @license
|
4088
|
+
* Copyright 2023 Google LLC
|
4089
|
+
*
|
4090
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
4091
|
+
* you may not use this file except in compliance with the License.
|
4092
|
+
* You may obtain a copy of the License at
|
4093
|
+
*
|
4094
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
4095
|
+
*
|
4096
|
+
* Unless required by applicable law or agreed to in writing, software
|
4097
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
4098
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
4099
|
+
* See the License for the specific language governing permissions and
|
4100
|
+
* limitations under the License.
|
4101
|
+
*/
|
4102
|
+
// Parse the token and check to see if the `exp` claim is in the future.
|
4103
|
+
// Reports an error to the console if the token or claim could not be parsed, or if `exp` is in
|
4104
|
+
// the past.
|
4105
|
+
function validateTokenTTL(base64Token, tokenName) {
|
4106
|
+
const secondPart = util.base64Decode(base64Token.split('.')[1]);
|
4107
|
+
if (secondPart === null) {
|
4108
|
+
console.error(`FirebaseServerApp ${tokenName} is invalid: second part could not be parsed.`);
|
4109
|
+
return;
|
4110
|
+
}
|
4111
|
+
const expClaim = JSON.parse(secondPart).exp;
|
4112
|
+
if (expClaim === undefined) {
|
4113
|
+
console.error(`FirebaseServerApp ${tokenName} is invalid: expiration claim could not be parsed`);
|
4114
|
+
return;
|
4115
|
+
}
|
4116
|
+
const exp = JSON.parse(secondPart).exp * 1000;
|
4117
|
+
const now = new Date().getTime();
|
4118
|
+
const diff = exp - now;
|
4119
|
+
if (diff <= 0) {
|
4120
|
+
console.error(`FirebaseServerApp ${tokenName} is invalid: the token has expired.`);
|
4121
|
+
}
|
4122
|
+
}
|
4123
|
+
class FirebaseServerAppImpl extends FirebaseAppImpl {
|
4124
|
+
constructor(options, serverConfig, name, container) {
|
4125
|
+
// Build configuration parameters for the FirebaseAppImpl base class.
|
4126
|
+
const automaticDataCollectionEnabled = serverConfig.automaticDataCollectionEnabled !== undefined
|
4127
|
+
? serverConfig.automaticDataCollectionEnabled
|
4128
|
+
: false;
|
4129
|
+
// Create the FirebaseAppSettings object for the FirebaseAppImp constructor.
|
4130
|
+
const config = {
|
4131
|
+
name,
|
4132
|
+
automaticDataCollectionEnabled
|
4133
|
+
};
|
4134
|
+
if (options.apiKey !== undefined) {
|
4135
|
+
// Construct the parent FirebaseAppImp object.
|
4136
|
+
super(options, config, container);
|
4137
|
+
}
|
4138
|
+
else {
|
4139
|
+
const appImpl = options;
|
4140
|
+
super(appImpl.options, config, container);
|
4141
|
+
}
|
4142
|
+
// Now construct the data for the FirebaseServerAppImpl.
|
4143
|
+
this._serverConfig = Object.assign({ automaticDataCollectionEnabled }, serverConfig);
|
4144
|
+
// Ensure that the current time is within the `authIdtoken` window of validity.
|
4145
|
+
if (this._serverConfig.authIdToken) {
|
4146
|
+
validateTokenTTL(this._serverConfig.authIdToken, 'authIdToken');
|
4147
|
+
}
|
4148
|
+
// Ensure that the current time is within the `appCheckToken` window of validity.
|
4149
|
+
if (this._serverConfig.appCheckToken) {
|
4150
|
+
validateTokenTTL(this._serverConfig.appCheckToken, 'appCheckToken');
|
4151
|
+
}
|
4152
|
+
this._finalizationRegistry = null;
|
4153
|
+
if (typeof FinalizationRegistry !== 'undefined') {
|
4154
|
+
this._finalizationRegistry = new FinalizationRegistry(() => {
|
4155
|
+
this.automaticCleanup();
|
4156
|
+
});
|
4157
|
+
}
|
4158
|
+
this._refCount = 0;
|
4159
|
+
this.incRefCount(this._serverConfig.releaseOnDeref);
|
4160
|
+
// Do not retain a hard reference to the dref object, otherwise the FinalizationRegistry
|
4161
|
+
// will never trigger.
|
4162
|
+
this._serverConfig.releaseOnDeref = undefined;
|
4163
|
+
serverConfig.releaseOnDeref = undefined;
|
4164
|
+
registerVersion(name$q, version$1, 'serverapp');
|
4165
|
+
}
|
4166
|
+
toJSON() {
|
4167
|
+
return undefined;
|
4168
|
+
}
|
4169
|
+
get refCount() {
|
4170
|
+
return this._refCount;
|
4171
|
+
}
|
4172
|
+
// Increment the reference count of this server app. If an object is provided, register it
|
4173
|
+
// with the finalization registry.
|
4174
|
+
incRefCount(obj) {
|
4175
|
+
if (this.isDeleted) {
|
4176
|
+
return;
|
4177
|
+
}
|
4178
|
+
this._refCount++;
|
4179
|
+
if (obj !== undefined && this._finalizationRegistry !== null) {
|
4180
|
+
this._finalizationRegistry.register(obj, this);
|
4181
|
+
}
|
4182
|
+
}
|
4183
|
+
// Decrement the reference count.
|
4184
|
+
decRefCount() {
|
4185
|
+
if (this.isDeleted) {
|
4186
|
+
return 0;
|
4187
|
+
}
|
4188
|
+
return --this._refCount;
|
4189
|
+
}
|
4190
|
+
// Invoked by the FinalizationRegistry callback to note that this app should go through its
|
4191
|
+
// reference counts and delete itself if no reference count remain. The coordinating logic that
|
4192
|
+
// handles this is in deleteApp(...).
|
4193
|
+
automaticCleanup() {
|
4194
|
+
void deleteApp(this);
|
4195
|
+
}
|
4196
|
+
get settings() {
|
4197
|
+
this.checkDestroyed();
|
4198
|
+
return this._serverConfig;
|
4199
|
+
}
|
4200
|
+
/**
|
4201
|
+
* This function will throw an Error if the App has already been deleted -
|
4202
|
+
* use before performing API actions on the App.
|
4203
|
+
*/
|
4204
|
+
checkDestroyed() {
|
4205
|
+
if (this.isDeleted) {
|
4206
|
+
throw ERROR_FACTORY.create("server-app-deleted" /* AppError.SERVER_APP_DELETED */);
|
4207
|
+
}
|
4208
|
+
}
|
4209
|
+
}
|
4210
|
+
|
4211
|
+
/**
|
4212
|
+
* @license
|
4213
|
+
* Copyright 2019 Google LLC
|
4214
|
+
*
|
4215
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
4216
|
+
* you may not use this file except in compliance with the License.
|
4217
|
+
* You may obtain a copy of the License at
|
4218
|
+
*
|
4219
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
4220
|
+
*
|
4221
|
+
* Unless required by applicable law or agreed to in writing, software
|
4222
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
4223
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
4224
|
+
* See the License for the specific language governing permissions and
|
4225
|
+
* limitations under the License.
|
4226
|
+
*/
|
4227
|
+
/**
|
4228
|
+
* The current SDK version.
|
4229
|
+
*
|
4230
|
+
* @public
|
4231
|
+
*/
|
4232
|
+
const SDK_VERSION = version;
|
4233
|
+
function initializeApp(_options, rawConfig = {}) {
|
4234
|
+
let options = _options;
|
4235
|
+
if (typeof rawConfig !== 'object') {
|
4236
|
+
const name = rawConfig;
|
4237
|
+
rawConfig = { name };
|
4238
|
+
}
|
4239
|
+
const config = Object.assign({ name: DEFAULT_ENTRY_NAME, automaticDataCollectionEnabled: false }, rawConfig);
|
4240
|
+
const name = config.name;
|
4241
|
+
if (typeof name !== 'string' || !name) {
|
4242
|
+
throw ERROR_FACTORY.create("bad-app-name" /* AppError.BAD_APP_NAME */, {
|
4243
|
+
appName: String(name)
|
4244
|
+
});
|
4245
|
+
}
|
4246
|
+
options || (options = util.getDefaultAppConfig());
|
4247
|
+
if (!options) {
|
4248
|
+
throw ERROR_FACTORY.create("no-options" /* AppError.NO_OPTIONS */);
|
4249
|
+
}
|
4250
|
+
const existingApp = _apps.get(name);
|
4251
|
+
if (existingApp) {
|
4252
|
+
// return the existing app if options and config deep equal the ones in the existing app.
|
4253
|
+
if (util.deepEqual(options, existingApp.options) &&
|
4254
|
+
util.deepEqual(config, existingApp.config)) {
|
4255
|
+
return existingApp;
|
4256
|
+
}
|
4257
|
+
else {
|
4258
|
+
throw ERROR_FACTORY.create("duplicate-app" /* AppError.DUPLICATE_APP */, { appName: name });
|
4259
|
+
}
|
4260
|
+
}
|
4261
|
+
const container = new component.ComponentContainer(name);
|
4262
|
+
for (const component of _components.values()) {
|
4263
|
+
container.addComponent(component);
|
4264
|
+
}
|
4265
|
+
const newApp = new FirebaseAppImpl(options, config, container);
|
4266
|
+
_apps.set(name, newApp);
|
4267
|
+
return newApp;
|
4268
|
+
}
|
4269
|
+
function initializeServerApp(_options, _serverAppConfig) {
|
4270
|
+
if (util.isBrowser() && !util.isWebWorker()) {
|
4271
|
+
// FirebaseServerApp isn't designed to be run in browsers.
|
4272
|
+
throw ERROR_FACTORY.create("invalid-server-app-environment" /* AppError.INVALID_SERVER_APP_ENVIRONMENT */);
|
4273
|
+
}
|
4274
|
+
if (_serverAppConfig.automaticDataCollectionEnabled === undefined) {
|
4275
|
+
_serverAppConfig.automaticDataCollectionEnabled = false;
|
4276
|
+
}
|
4277
|
+
let appOptions;
|
4278
|
+
if (_isFirebaseApp(_options)) {
|
4279
|
+
appOptions = _options.options;
|
4280
|
+
}
|
4281
|
+
else {
|
4282
|
+
appOptions = _options;
|
4283
|
+
}
|
4284
|
+
// Build an app name based on a hash of the configuration options.
|
4285
|
+
const nameObj = Object.assign(Object.assign({}, _serverAppConfig), appOptions);
|
4286
|
+
// However, Do not mangle the name based on releaseOnDeref, since it will vary between the
|
4287
|
+
// construction of FirebaseServerApp instances. For example, if the object is the request headers.
|
4288
|
+
if (nameObj.releaseOnDeref !== undefined) {
|
4289
|
+
delete nameObj.releaseOnDeref;
|
4290
|
+
}
|
4291
|
+
const hashCode = (s) => {
|
4292
|
+
return [...s].reduce((hash, c) => (Math.imul(31, hash) + c.charCodeAt(0)) | 0, 0);
|
4293
|
+
};
|
4294
|
+
if (_serverAppConfig.releaseOnDeref !== undefined) {
|
4295
|
+
if (typeof FinalizationRegistry === 'undefined') {
|
4296
|
+
throw ERROR_FACTORY.create("finalization-registry-not-supported" /* AppError.FINALIZATION_REGISTRY_NOT_SUPPORTED */, {});
|
4297
|
+
}
|
4298
|
+
}
|
4299
|
+
const nameString = '' + hashCode(JSON.stringify(nameObj));
|
4300
|
+
const existingApp = _serverApps.get(nameString);
|
4301
|
+
if (existingApp) {
|
4302
|
+
existingApp.incRefCount(_serverAppConfig.releaseOnDeref);
|
4303
|
+
return existingApp;
|
4304
|
+
}
|
4305
|
+
const container = new component.ComponentContainer(nameString);
|
4306
|
+
for (const component of _components.values()) {
|
4307
|
+
container.addComponent(component);
|
4308
|
+
}
|
4309
|
+
const newApp = new FirebaseServerAppImpl(appOptions, _serverAppConfig, nameString, container);
|
4310
|
+
_serverApps.set(nameString, newApp);
|
4311
|
+
return newApp;
|
4312
|
+
}
|
4313
|
+
/**
|
4314
|
+
* Retrieves a {@link @firebase/app#FirebaseApp} instance.
|
4315
|
+
*
|
4316
|
+
* When called with no arguments, the default app is returned. When an app name
|
4317
|
+
* is provided, the app corresponding to that name is returned.
|
4318
|
+
*
|
4319
|
+
* An exception is thrown if the app being retrieved has not yet been
|
4320
|
+
* initialized.
|
4321
|
+
*
|
4322
|
+
* @example
|
4323
|
+
* ```javascript
|
4324
|
+
* // Return the default app
|
4325
|
+
* const app = getApp();
|
4326
|
+
* ```
|
4327
|
+
*
|
4328
|
+
* @example
|
4329
|
+
* ```javascript
|
4330
|
+
* // Return a named app
|
4331
|
+
* const otherApp = getApp("otherApp");
|
4332
|
+
* ```
|
4333
|
+
*
|
4334
|
+
* @param name - Optional name of the app to return. If no name is
|
4335
|
+
* provided, the default is `"[DEFAULT]"`.
|
4336
|
+
*
|
4337
|
+
* @returns The app corresponding to the provided app name.
|
4338
|
+
* If no app name is provided, the default app is returned.
|
4339
|
+
*
|
4340
|
+
* @public
|
4341
|
+
*/
|
4342
|
+
function getApp(name = DEFAULT_ENTRY_NAME) {
|
4343
|
+
const app = _apps.get(name);
|
4344
|
+
if (!app && name === DEFAULT_ENTRY_NAME && util.getDefaultAppConfig()) {
|
4345
|
+
return initializeApp();
|
4346
|
+
}
|
4347
|
+
if (!app) {
|
4348
|
+
throw ERROR_FACTORY.create("no-app" /* AppError.NO_APP */, { appName: name });
|
4349
|
+
}
|
4350
|
+
return app;
|
4351
|
+
}
|
4352
|
+
/**
|
4353
|
+
* A (read-only) array of all initialized apps.
|
4354
|
+
* @public
|
4355
|
+
*/
|
4356
|
+
function getApps() {
|
4357
|
+
return Array.from(_apps.values());
|
4358
|
+
}
|
4359
|
+
/**
|
4360
|
+
* Renders this app unusable and frees the resources of all associated
|
4361
|
+
* services.
|
4362
|
+
*
|
4363
|
+
* @example
|
4364
|
+
* ```javascript
|
4365
|
+
* deleteApp(app)
|
4366
|
+
* .then(function() {
|
4367
|
+
* console.log("App deleted successfully");
|
4368
|
+
* })
|
4369
|
+
* .catch(function(error) {
|
4370
|
+
* console.log("Error deleting app:", error);
|
4371
|
+
* });
|
4372
|
+
* ```
|
4373
|
+
*
|
4374
|
+
* @public
|
4375
|
+
*/
|
4376
|
+
async function deleteApp(app) {
|
4377
|
+
let cleanupProviders = false;
|
4378
|
+
const name = app.name;
|
4379
|
+
if (_apps.has(name)) {
|
4380
|
+
cleanupProviders = true;
|
4381
|
+
_apps.delete(name);
|
4382
|
+
}
|
4383
|
+
else if (_serverApps.has(name)) {
|
4384
|
+
const firebaseServerApp = app;
|
4385
|
+
if (firebaseServerApp.decRefCount() <= 0) {
|
4386
|
+
_serverApps.delete(name);
|
4387
|
+
cleanupProviders = true;
|
4388
|
+
}
|
4389
|
+
}
|
4390
|
+
if (cleanupProviders) {
|
4391
|
+
await Promise.all(app.container
|
4392
|
+
.getProviders()
|
4393
|
+
.map(provider => provider.delete()));
|
4394
|
+
app.isDeleted = true;
|
4395
|
+
}
|
4396
|
+
}
|
4397
|
+
/**
|
4398
|
+
* Registers a library's name and version for platform logging purposes.
|
4399
|
+
* @param library - Name of 1p or 3p library (e.g. firestore, angularfire)
|
4400
|
+
* @param version - Current version of that library.
|
4401
|
+
* @param variant - Bundle variant, e.g., node, rn, etc.
|
4402
|
+
*
|
4403
|
+
* @public
|
4404
|
+
*/
|
4405
|
+
function registerVersion(libraryKeyOrName, version, variant) {
|
4406
|
+
var _a;
|
4407
|
+
// TODO: We can use this check to whitelist strings when/if we set up
|
4408
|
+
// a good whitelist system.
|
4409
|
+
let library = (_a = PLATFORM_LOG_STRING[libraryKeyOrName]) !== null && _a !== void 0 ? _a : libraryKeyOrName;
|
4410
|
+
if (variant) {
|
4411
|
+
library += `-${variant}`;
|
4412
|
+
}
|
4413
|
+
const libraryMismatch = library.match(/\s|\//);
|
4414
|
+
const versionMismatch = version.match(/\s|\//);
|
4415
|
+
if (libraryMismatch || versionMismatch) {
|
4416
|
+
const warning = [
|
4417
|
+
`Unable to register library "${library}" with version "${version}":`
|
4418
|
+
];
|
4419
|
+
if (libraryMismatch) {
|
4420
|
+
warning.push(`library name "${library}" contains illegal characters (whitespace or "/")`);
|
4421
|
+
}
|
4422
|
+
if (libraryMismatch && versionMismatch) {
|
4423
|
+
warning.push('and');
|
4424
|
+
}
|
4425
|
+
if (versionMismatch) {
|
4426
|
+
warning.push(`version name "${version}" contains illegal characters (whitespace or "/")`);
|
4427
|
+
}
|
4428
|
+
logger.warn(warning.join(' '));
|
4429
|
+
return;
|
4430
|
+
}
|
4431
|
+
_registerComponent(new component.Component(`${library}-version`, () => ({ library, version }), "VERSION" /* ComponentType.VERSION */));
|
4432
|
+
}
|
4433
|
+
/**
|
4434
|
+
* Sets log handler for all Firebase SDKs.
|
4435
|
+
* @param logCallback - An optional custom log handler that executes user code whenever
|
4436
|
+
* the Firebase SDK makes a logging call.
|
4437
|
+
*
|
4438
|
+
* @public
|
4439
|
+
*/
|
4440
|
+
function onLog(logCallback, options) {
|
4441
|
+
if (logCallback !== null && typeof logCallback !== 'function') {
|
4442
|
+
throw ERROR_FACTORY.create("invalid-log-argument" /* AppError.INVALID_LOG_ARGUMENT */);
|
4443
|
+
}
|
4444
|
+
logger$1.setUserLogHandler(logCallback, options);
|
4445
|
+
}
|
4446
|
+
/**
|
4447
|
+
* Sets log level for all Firebase SDKs.
|
4448
|
+
*
|
4449
|
+
* All of the log types above the current log level are captured (i.e. if
|
4450
|
+
* you set the log level to `info`, errors are logged, but `debug` and
|
4451
|
+
* `verbose` logs are not).
|
4452
|
+
*
|
4453
|
+
* @public
|
4454
|
+
*/
|
4455
|
+
function setLogLevel(logLevel) {
|
4456
|
+
logger$1.setLogLevel(logLevel);
|
4457
|
+
}
|
4458
|
+
|
4459
|
+
/**
|
4460
|
+
* @license
|
4461
|
+
* Copyright 2021 Google LLC
|
4462
|
+
*
|
4463
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
4464
|
+
* you may not use this file except in compliance with the License.
|
4465
|
+
* You may obtain a copy of the License at
|
4466
|
+
*
|
4467
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
4468
|
+
*
|
4469
|
+
* Unless required by applicable law or agreed to in writing, software
|
4470
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
4471
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
4472
|
+
* See the License for the specific language governing permissions and
|
4473
|
+
* limitations under the License.
|
4474
|
+
*/
|
4475
|
+
const DB_NAME = 'firebase-heartbeat-database';
|
4476
|
+
const DB_VERSION = 1;
|
4477
|
+
const STORE_NAME = 'firebase-heartbeat-store';
|
4478
|
+
let dbPromise = null;
|
4479
|
+
function getDbPromise() {
|
4480
|
+
if (!dbPromise) {
|
4481
|
+
dbPromise = idb.openDB(DB_NAME, DB_VERSION, {
|
4482
|
+
upgrade: (db, oldVersion) => {
|
4483
|
+
// We don't use 'break' in this switch statement, the fall-through
|
4484
|
+
// behavior is what we want, because if there are multiple versions between
|
4485
|
+
// the old version and the current version, we want ALL the migrations
|
4486
|
+
// that correspond to those versions to run, not only the last one.
|
4487
|
+
// eslint-disable-next-line default-case
|
4488
|
+
switch (oldVersion) {
|
4489
|
+
case 0:
|
4490
|
+
try {
|
4491
|
+
db.createObjectStore(STORE_NAME);
|
4492
|
+
}
|
4493
|
+
catch (e) {
|
4494
|
+
// Safari/iOS browsers throw occasional exceptions on
|
4495
|
+
// db.createObjectStore() that may be a bug. Avoid blocking
|
4496
|
+
// the rest of the app functionality.
|
4497
|
+
console.warn(e);
|
4498
|
+
}
|
4499
|
+
}
|
4500
|
+
}
|
4501
|
+
}).catch(e => {
|
4502
|
+
throw ERROR_FACTORY.create("idb-open" /* AppError.IDB_OPEN */, {
|
4503
|
+
originalErrorMessage: e.message
|
4504
|
+
});
|
4505
|
+
});
|
4506
|
+
}
|
4507
|
+
return dbPromise;
|
4508
|
+
}
|
4509
|
+
async function readHeartbeatsFromIndexedDB(app) {
|
4510
|
+
try {
|
4511
|
+
const db = await getDbPromise();
|
4512
|
+
const tx = db.transaction(STORE_NAME);
|
4513
|
+
const result = await tx.objectStore(STORE_NAME).get(computeKey(app));
|
4514
|
+
// We already have the value but tx.done can throw,
|
4515
|
+
// so we need to await it here to catch errors
|
4516
|
+
await tx.done;
|
4517
|
+
return result;
|
4518
|
+
}
|
4519
|
+
catch (e) {
|
4520
|
+
if (e instanceof util.FirebaseError) {
|
4521
|
+
logger.warn(e.message);
|
4522
|
+
}
|
4523
|
+
else {
|
4524
|
+
const idbGetError = ERROR_FACTORY.create("idb-get" /* AppError.IDB_GET */, {
|
4525
|
+
originalErrorMessage: e === null || e === void 0 ? void 0 : e.message
|
4526
|
+
});
|
4527
|
+
logger.warn(idbGetError.message);
|
4528
|
+
}
|
4529
|
+
}
|
4530
|
+
}
|
4531
|
+
async function writeHeartbeatsToIndexedDB(app, heartbeatObject) {
|
4532
|
+
try {
|
4533
|
+
const db = await getDbPromise();
|
4534
|
+
const tx = db.transaction(STORE_NAME, 'readwrite');
|
4535
|
+
const objectStore = tx.objectStore(STORE_NAME);
|
4536
|
+
await objectStore.put(heartbeatObject, computeKey(app));
|
4537
|
+
await tx.done;
|
4538
|
+
}
|
4539
|
+
catch (e) {
|
4540
|
+
if (e instanceof util.FirebaseError) {
|
4541
|
+
logger.warn(e.message);
|
4542
|
+
}
|
4543
|
+
else {
|
4544
|
+
const idbGetError = ERROR_FACTORY.create("idb-set" /* AppError.IDB_WRITE */, {
|
4545
|
+
originalErrorMessage: e === null || e === void 0 ? void 0 : e.message
|
4546
|
+
});
|
4547
|
+
logger.warn(idbGetError.message);
|
4548
|
+
}
|
4549
|
+
}
|
4550
|
+
}
|
4551
|
+
function computeKey(app) {
|
4552
|
+
return `${app.name}!${app.options.appId}`;
|
4553
|
+
}
|
4554
|
+
|
4555
|
+
/**
|
4556
|
+
* @license
|
4557
|
+
* Copyright 2021 Google LLC
|
4558
|
+
*
|
4559
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
4560
|
+
* you may not use this file except in compliance with the License.
|
4561
|
+
* You may obtain a copy of the License at
|
4562
|
+
*
|
4563
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
4564
|
+
*
|
4565
|
+
* Unless required by applicable law or agreed to in writing, software
|
4566
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
4567
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
4568
|
+
* See the License for the specific language governing permissions and
|
4569
|
+
* limitations under the License.
|
4570
|
+
*/
|
4571
|
+
const MAX_HEADER_BYTES = 1024;
|
4572
|
+
const MAX_NUM_STORED_HEARTBEATS = 30;
|
4573
|
+
class HeartbeatServiceImpl {
|
4574
|
+
constructor(container) {
|
4575
|
+
this.container = container;
|
4576
|
+
/**
|
4577
|
+
* In-memory cache for heartbeats, used by getHeartbeatsHeader() to generate
|
4578
|
+
* the header string.
|
4579
|
+
* Stores one record per date. This will be consolidated into the standard
|
4580
|
+
* format of one record per user agent string before being sent as a header.
|
4581
|
+
* Populated from indexedDB when the controller is instantiated and should
|
4582
|
+
* be kept in sync with indexedDB.
|
4583
|
+
* Leave public for easier testing.
|
4584
|
+
*/
|
4585
|
+
this._heartbeatsCache = null;
|
4586
|
+
const app = this.container.getProvider('app').getImmediate();
|
4587
|
+
this._storage = new HeartbeatStorageImpl(app);
|
4588
|
+
this._heartbeatsCachePromise = this._storage.read().then(result => {
|
4589
|
+
this._heartbeatsCache = result;
|
4590
|
+
return result;
|
4591
|
+
});
|
4592
|
+
}
|
4593
|
+
/**
|
4594
|
+
* Called to report a heartbeat. The function will generate
|
4595
|
+
* a HeartbeatsByUserAgent object, update heartbeatsCache, and persist it
|
4596
|
+
* to IndexedDB.
|
4597
|
+
* Note that we only store one heartbeat per day. So if a heartbeat for today is
|
4598
|
+
* already logged, subsequent calls to this function in the same day will be ignored.
|
4599
|
+
*/
|
4600
|
+
async triggerHeartbeat() {
|
4601
|
+
var _a, _b;
|
4602
|
+
try {
|
4603
|
+
const platformLogger = this.container
|
4604
|
+
.getProvider('platform-logger')
|
4605
|
+
.getImmediate();
|
4606
|
+
// This is the "Firebase user agent" string from the platform logger
|
4607
|
+
// service, not the browser user agent.
|
4608
|
+
const agent = platformLogger.getPlatformInfoString();
|
4609
|
+
const date = getUTCDateString();
|
4610
|
+
if (((_a = this._heartbeatsCache) === null || _a === void 0 ? void 0 : _a.heartbeats) == null) {
|
4611
|
+
this._heartbeatsCache = await this._heartbeatsCachePromise;
|
4612
|
+
// If we failed to construct a heartbeats cache, then return immediately.
|
4613
|
+
if (((_b = this._heartbeatsCache) === null || _b === void 0 ? void 0 : _b.heartbeats) == null) {
|
4614
|
+
return;
|
4615
|
+
}
|
4616
|
+
}
|
4617
|
+
// Do not store a heartbeat if one is already stored for this day
|
4618
|
+
// or if a header has already been sent today.
|
4619
|
+
if (this._heartbeatsCache.lastSentHeartbeatDate === date ||
|
4620
|
+
this._heartbeatsCache.heartbeats.some(singleDateHeartbeat => singleDateHeartbeat.date === date)) {
|
4621
|
+
return;
|
4622
|
+
}
|
4623
|
+
else {
|
4624
|
+
// There is no entry for this date. Create one.
|
4625
|
+
this._heartbeatsCache.heartbeats.push({ date, agent });
|
4626
|
+
// If the number of stored heartbeats exceeds the maximum number of stored heartbeats, remove the heartbeat with the earliest date.
|
4627
|
+
// Since this is executed each time a heartbeat is pushed, the limit can only be exceeded by one, so only one needs to be removed.
|
4628
|
+
if (this._heartbeatsCache.heartbeats.length > MAX_NUM_STORED_HEARTBEATS) {
|
4629
|
+
const earliestHeartbeatIdx = getEarliestHeartbeatIdx(this._heartbeatsCache.heartbeats);
|
4630
|
+
this._heartbeatsCache.heartbeats.splice(earliestHeartbeatIdx, 1);
|
4631
|
+
}
|
4632
|
+
}
|
4633
|
+
return this._storage.overwrite(this._heartbeatsCache);
|
4634
|
+
}
|
4635
|
+
catch (e) {
|
4636
|
+
logger.warn(e);
|
4637
|
+
}
|
4638
|
+
}
|
4639
|
+
/**
|
4640
|
+
* Returns a base64 encoded string which can be attached to the heartbeat-specific header directly.
|
4641
|
+
* It also clears all heartbeats from memory as well as in IndexedDB.
|
4642
|
+
*
|
4643
|
+
* NOTE: Consuming product SDKs should not send the header if this method
|
4644
|
+
* returns an empty string.
|
4645
|
+
*/
|
4646
|
+
async getHeartbeatsHeader() {
|
4647
|
+
var _a;
|
4648
|
+
try {
|
4649
|
+
if (this._heartbeatsCache === null) {
|
4650
|
+
await this._heartbeatsCachePromise;
|
4651
|
+
}
|
4652
|
+
// If it's still null or the array is empty, there is no data to send.
|
4653
|
+
if (((_a = this._heartbeatsCache) === null || _a === void 0 ? void 0 : _a.heartbeats) == null ||
|
4654
|
+
this._heartbeatsCache.heartbeats.length === 0) {
|
4655
|
+
return '';
|
4656
|
+
}
|
4657
|
+
const date = getUTCDateString();
|
4658
|
+
// Extract as many heartbeats from the cache as will fit under the size limit.
|
4659
|
+
const { heartbeatsToSend, unsentEntries } = extractHeartbeatsForHeader(this._heartbeatsCache.heartbeats);
|
4660
|
+
const headerString = util.base64urlEncodeWithoutPadding(JSON.stringify({ version: 2, heartbeats: heartbeatsToSend }));
|
4661
|
+
// Store last sent date to prevent another being logged/sent for the same day.
|
4662
|
+
this._heartbeatsCache.lastSentHeartbeatDate = date;
|
4663
|
+
if (unsentEntries.length > 0) {
|
4664
|
+
// Store any unsent entries if they exist.
|
4665
|
+
this._heartbeatsCache.heartbeats = unsentEntries;
|
4666
|
+
// This seems more likely than emptying the array (below) to lead to some odd state
|
4667
|
+
// since the cache isn't empty and this will be called again on the next request,
|
4668
|
+
// and is probably safest if we await it.
|
4669
|
+
await this._storage.overwrite(this._heartbeatsCache);
|
4670
|
+
}
|
4671
|
+
else {
|
4672
|
+
this._heartbeatsCache.heartbeats = [];
|
4673
|
+
// Do not wait for this, to reduce latency.
|
4674
|
+
void this._storage.overwrite(this._heartbeatsCache);
|
4675
|
+
}
|
4676
|
+
return headerString;
|
4677
|
+
}
|
4678
|
+
catch (e) {
|
4679
|
+
logger.warn(e);
|
4680
|
+
return '';
|
4681
|
+
}
|
4682
|
+
}
|
4683
|
+
}
|
4684
|
+
function getUTCDateString() {
|
4685
|
+
const today = new Date();
|
4686
|
+
// Returns date format 'YYYY-MM-DD'
|
4687
|
+
return today.toISOString().substring(0, 10);
|
4688
|
+
}
|
4689
|
+
function extractHeartbeatsForHeader(heartbeatsCache, maxSize = MAX_HEADER_BYTES) {
|
4690
|
+
// Heartbeats grouped by user agent in the standard format to be sent in
|
4691
|
+
// the header.
|
4692
|
+
const heartbeatsToSend = [];
|
4693
|
+
// Single date format heartbeats that are not sent.
|
4694
|
+
let unsentEntries = heartbeatsCache.slice();
|
4695
|
+
for (const singleDateHeartbeat of heartbeatsCache) {
|
4696
|
+
// Look for an existing entry with the same user agent.
|
4697
|
+
const heartbeatEntry = heartbeatsToSend.find(hb => hb.agent === singleDateHeartbeat.agent);
|
4698
|
+
if (!heartbeatEntry) {
|
4699
|
+
// If no entry for this user agent exists, create one.
|
4700
|
+
heartbeatsToSend.push({
|
4701
|
+
agent: singleDateHeartbeat.agent,
|
4702
|
+
dates: [singleDateHeartbeat.date]
|
4703
|
+
});
|
4704
|
+
if (countBytes(heartbeatsToSend) > maxSize) {
|
4705
|
+
// If the header would exceed max size, remove the added heartbeat
|
4706
|
+
// entry and stop adding to the header.
|
4707
|
+
heartbeatsToSend.pop();
|
4708
|
+
break;
|
4709
|
+
}
|
4710
|
+
}
|
4711
|
+
else {
|
4712
|
+
heartbeatEntry.dates.push(singleDateHeartbeat.date);
|
4713
|
+
// If the header would exceed max size, remove the added date
|
4714
|
+
// and stop adding to the header.
|
4715
|
+
if (countBytes(heartbeatsToSend) > maxSize) {
|
4716
|
+
heartbeatEntry.dates.pop();
|
4717
|
+
break;
|
4718
|
+
}
|
4719
|
+
}
|
4720
|
+
// Pop unsent entry from queue. (Skipped if adding the entry exceeded
|
4721
|
+
// quota and the loop breaks early.)
|
4722
|
+
unsentEntries = unsentEntries.slice(1);
|
4723
|
+
}
|
4724
|
+
return {
|
4725
|
+
heartbeatsToSend,
|
4726
|
+
unsentEntries
|
4727
|
+
};
|
4728
|
+
}
|
4729
|
+
class HeartbeatStorageImpl {
|
4730
|
+
constructor(app) {
|
4731
|
+
this.app = app;
|
4732
|
+
this._canUseIndexedDBPromise = this.runIndexedDBEnvironmentCheck();
|
4733
|
+
}
|
4734
|
+
async runIndexedDBEnvironmentCheck() {
|
4735
|
+
if (!util.isIndexedDBAvailable()) {
|
4736
|
+
return false;
|
4737
|
+
}
|
4738
|
+
else {
|
4739
|
+
return util.validateIndexedDBOpenable()
|
4740
|
+
.then(() => true)
|
4741
|
+
.catch(() => false);
|
4742
|
+
}
|
4743
|
+
}
|
4744
|
+
/**
|
4745
|
+
* Read all heartbeats.
|
4746
|
+
*/
|
4747
|
+
async read() {
|
4748
|
+
const canUseIndexedDB = await this._canUseIndexedDBPromise;
|
4749
|
+
if (!canUseIndexedDB) {
|
4750
|
+
return { heartbeats: [] };
|
4751
|
+
}
|
4752
|
+
else {
|
4753
|
+
const idbHeartbeatObject = await readHeartbeatsFromIndexedDB(this.app);
|
4754
|
+
if (idbHeartbeatObject === null || idbHeartbeatObject === void 0 ? void 0 : idbHeartbeatObject.heartbeats) {
|
4755
|
+
return idbHeartbeatObject;
|
4756
|
+
}
|
4757
|
+
else {
|
4758
|
+
return { heartbeats: [] };
|
4759
|
+
}
|
4760
|
+
}
|
4761
|
+
}
|
4762
|
+
// overwrite the storage with the provided heartbeats
|
4763
|
+
async overwrite(heartbeatsObject) {
|
4764
|
+
var _a;
|
4765
|
+
const canUseIndexedDB = await this._canUseIndexedDBPromise;
|
4766
|
+
if (!canUseIndexedDB) {
|
4767
|
+
return;
|
4768
|
+
}
|
4769
|
+
else {
|
4770
|
+
const existingHeartbeatsObject = await this.read();
|
4771
|
+
return writeHeartbeatsToIndexedDB(this.app, {
|
4772
|
+
lastSentHeartbeatDate: (_a = heartbeatsObject.lastSentHeartbeatDate) !== null && _a !== void 0 ? _a : existingHeartbeatsObject.lastSentHeartbeatDate,
|
4773
|
+
heartbeats: heartbeatsObject.heartbeats
|
4774
|
+
});
|
4775
|
+
}
|
4776
|
+
}
|
4777
|
+
// add heartbeats
|
4778
|
+
async add(heartbeatsObject) {
|
4779
|
+
var _a;
|
4780
|
+
const canUseIndexedDB = await this._canUseIndexedDBPromise;
|
4781
|
+
if (!canUseIndexedDB) {
|
4782
|
+
return;
|
4783
|
+
}
|
4784
|
+
else {
|
4785
|
+
const existingHeartbeatsObject = await this.read();
|
4786
|
+
return writeHeartbeatsToIndexedDB(this.app, {
|
4787
|
+
lastSentHeartbeatDate: (_a = heartbeatsObject.lastSentHeartbeatDate) !== null && _a !== void 0 ? _a : existingHeartbeatsObject.lastSentHeartbeatDate,
|
4788
|
+
heartbeats: [
|
4789
|
+
...existingHeartbeatsObject.heartbeats,
|
4790
|
+
...heartbeatsObject.heartbeats
|
4791
|
+
]
|
4792
|
+
});
|
4793
|
+
}
|
4794
|
+
}
|
4795
|
+
}
|
4796
|
+
/**
|
4797
|
+
* Calculate bytes of a HeartbeatsByUserAgent array after being wrapped
|
4798
|
+
* in a platform logging header JSON object, stringified, and converted
|
4799
|
+
* to base 64.
|
4800
|
+
*/
|
4801
|
+
function countBytes(heartbeatsCache) {
|
4802
|
+
// base64 has a restricted set of characters, all of which should be 1 byte.
|
4803
|
+
return util.base64urlEncodeWithoutPadding(
|
4804
|
+
// heartbeatsCache wrapper properties
|
4805
|
+
JSON.stringify({ version: 2, heartbeats: heartbeatsCache })).length;
|
4806
|
+
}
|
4807
|
+
/**
|
4808
|
+
* Returns the index of the heartbeat with the earliest date.
|
4809
|
+
* If the heartbeats array is empty, -1 is returned.
|
4810
|
+
*/
|
4811
|
+
function getEarliestHeartbeatIdx(heartbeats) {
|
4812
|
+
if (heartbeats.length === 0) {
|
4813
|
+
return -1;
|
4814
|
+
}
|
4815
|
+
let earliestHeartbeatIdx = 0;
|
4816
|
+
let earliestHeartbeatDate = heartbeats[0].date;
|
4817
|
+
for (let i = 1; i < heartbeats.length; i++) {
|
4818
|
+
if (heartbeats[i].date < earliestHeartbeatDate) {
|
4819
|
+
earliestHeartbeatDate = heartbeats[i].date;
|
4820
|
+
earliestHeartbeatIdx = i;
|
4821
|
+
}
|
4822
|
+
}
|
4823
|
+
return earliestHeartbeatIdx;
|
4824
|
+
}
|
4825
|
+
|
4826
|
+
/**
|
4827
|
+
* @license
|
4828
|
+
* Copyright 2019 Google LLC
|
4829
|
+
*
|
4830
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
4831
|
+
* you may not use this file except in compliance with the License.
|
4832
|
+
* You may obtain a copy of the License at
|
4833
|
+
*
|
4834
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
4835
|
+
*
|
4836
|
+
* Unless required by applicable law or agreed to in writing, software
|
4837
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
4838
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
4839
|
+
* See the License for the specific language governing permissions and
|
4840
|
+
* limitations under the License.
|
4841
|
+
*/
|
4842
|
+
function registerCoreComponents(variant) {
|
4843
|
+
_registerComponent(new component.Component('platform-logger', container => new PlatformLoggerServiceImpl(container), "PRIVATE" /* ComponentType.PRIVATE */));
|
4844
|
+
_registerComponent(new component.Component('heartbeat', container => new HeartbeatServiceImpl(container), "PRIVATE" /* ComponentType.PRIVATE */));
|
4845
|
+
// Register `app` package.
|
4846
|
+
registerVersion(name$q, version$1, variant);
|
4847
|
+
// BUILD_TARGET will be replaced by values like esm2017, cjs2017, etc during the compilation
|
4848
|
+
registerVersion(name$q, version$1, 'cjs2017');
|
4849
|
+
// Register platform SDK identifier (no version).
|
4850
|
+
registerVersion('fire-js', '');
|
4851
|
+
}
|
4852
|
+
|
4853
|
+
/**
|
4854
|
+
* Firebase App
|
4855
|
+
*
|
4856
|
+
* @remarks This package coordinates the communication between the different Firebase components
|
4857
|
+
* @packageDocumentation
|
4858
|
+
*/
|
4859
|
+
registerCoreComponents('node');
|
4860
|
+
|
4861
|
+
Object.defineProperty(exports, 'FirebaseError', {
|
4862
|
+
enumerable: true,
|
4863
|
+
get: function () { return util.FirebaseError; }
|
4864
|
+
});
|
4865
|
+
exports.SDK_VERSION = SDK_VERSION;
|
4866
|
+
exports._DEFAULT_ENTRY_NAME = DEFAULT_ENTRY_NAME;
|
4867
|
+
exports._addComponent = _addComponent;
|
4868
|
+
exports._addOrOverwriteComponent = _addOrOverwriteComponent;
|
4869
|
+
exports._apps = _apps;
|
4870
|
+
exports._clearComponents = _clearComponents;
|
4871
|
+
exports._components = _components;
|
4872
|
+
exports._getProvider = _getProvider;
|
4873
|
+
exports._isFirebaseApp = _isFirebaseApp;
|
4874
|
+
exports._isFirebaseServerApp = _isFirebaseServerApp;
|
4875
|
+
exports._registerComponent = _registerComponent;
|
4876
|
+
exports._removeServiceInstance = _removeServiceInstance;
|
4877
|
+
exports._serverApps = _serverApps;
|
4878
|
+
exports.deleteApp = deleteApp;
|
4879
|
+
exports.getApp = getApp;
|
4880
|
+
exports.getApps = getApps;
|
4881
|
+
exports.initializeApp = initializeApp;
|
4882
|
+
exports.initializeServerApp = initializeServerApp;
|
4883
|
+
exports.onLog = onLog;
|
4884
|
+
exports.registerVersion = registerVersion;
|
4885
|
+
exports.setLogLevel = setLogLevel;
|
4886
|
+
|
4887
|
+
}(index_cjs));
|
4888
|
+
|
4889
|
+
Object.defineProperty(index_standalone, '__esModule', { value: true });
|
4890
|
+
|
4891
|
+
var Websocket = websocket;
|
4892
|
+
var util = require$$2__default$3["default"];
|
4893
|
+
var logger$1 = require$$1__default$3["default"];
|
4894
|
+
var app = index_cjs;
|
4895
|
+
var component = require$$0__default$2["default"];
|
4896
|
+
|
4897
|
+
function _interopDefaultLegacy$1 (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
4898
|
+
|
4899
|
+
var Websocket__default = /*#__PURE__*/_interopDefaultLegacy$1(Websocket);
|
4900
|
+
|
4901
|
+
/**
|
4902
|
+
* @license
|
4903
|
+
* Copyright 2017 Google LLC
|
4904
|
+
*
|
4905
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
4906
|
+
* you may not use this file except in compliance with the License.
|
4907
|
+
* You may obtain a copy of the License at
|
4908
|
+
*
|
4909
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
4910
|
+
*
|
4911
|
+
* Unless required by applicable law or agreed to in writing, software
|
4912
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
4913
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
4914
|
+
* See the License for the specific language governing permissions and
|
4915
|
+
* limitations under the License.
|
4916
|
+
*/
|
4917
|
+
const PROTOCOL_VERSION = '5';
|
4918
|
+
const VERSION_PARAM = 'v';
|
4919
|
+
const TRANSPORT_SESSION_PARAM = 's';
|
4920
|
+
const REFERER_PARAM = 'r';
|
4921
|
+
const FORGE_REF = 'f';
|
4922
|
+
// Matches console.firebase.google.com, firebase-console-*.corp.google.com and
|
4923
|
+
// firebase.corp.google.com
|
4924
|
+
const FORGE_DOMAIN_RE = /(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/;
|
4925
|
+
const LAST_SESSION_PARAM = 'ls';
|
4926
|
+
const APPLICATION_ID_PARAM = 'p';
|
4927
|
+
const APP_CHECK_TOKEN_PARAM = 'ac';
|
4928
|
+
const WEBSOCKET = 'websocket';
|
4929
|
+
const LONG_POLLING = 'long_polling';
|
4930
|
+
|
4931
|
+
/**
|
4932
|
+
* @license
|
4933
|
+
* Copyright 2017 Google LLC
|
4934
|
+
*
|
4935
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
4936
|
+
* you may not use this file except in compliance with the License.
|
4937
|
+
* You may obtain a copy of the License at
|
4938
|
+
*
|
4939
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
4940
|
+
*
|
4941
|
+
* Unless required by applicable law or agreed to in writing, software
|
4942
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
4943
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
4944
|
+
* See the License for the specific language governing permissions and
|
4945
|
+
* limitations under the License.
|
4946
|
+
*/
|
4947
|
+
/**
|
4948
|
+
* Wraps a DOM Storage object and:
|
4949
|
+
* - automatically encode objects as JSON strings before storing them to allow us to store arbitrary types.
|
4950
|
+
* - prefixes names with "firebase:" to avoid collisions with app data.
|
4951
|
+
*
|
4952
|
+
* We automatically (see storage.js) create two such wrappers, one for sessionStorage,
|
4953
|
+
* and one for localStorage.
|
4954
|
+
*
|
4955
|
+
*/
|
4956
|
+
class DOMStorageWrapper {
|
4957
|
+
/**
|
4958
|
+
* @param domStorage_ - The underlying storage object (e.g. localStorage or sessionStorage)
|
4959
|
+
*/
|
4960
|
+
constructor(domStorage_) {
|
4961
|
+
this.domStorage_ = domStorage_;
|
4962
|
+
// Use a prefix to avoid collisions with other stuff saved by the app.
|
4963
|
+
this.prefix_ = 'firebase:';
|
4964
|
+
}
|
4965
|
+
/**
|
4966
|
+
* @param key - The key to save the value under
|
4967
|
+
* @param value - The value being stored, or null to remove the key.
|
4968
|
+
*/
|
4969
|
+
set(key, value) {
|
4970
|
+
if (value == null) {
|
4971
|
+
this.domStorage_.removeItem(this.prefixedName_(key));
|
4972
|
+
}
|
4973
|
+
else {
|
4974
|
+
this.domStorage_.setItem(this.prefixedName_(key), util.stringify(value));
|
4975
|
+
}
|
4976
|
+
}
|
4977
|
+
/**
|
4978
|
+
* @returns The value that was stored under this key, or null
|
4979
|
+
*/
|
4980
|
+
get(key) {
|
4981
|
+
const storedVal = this.domStorage_.getItem(this.prefixedName_(key));
|
4982
|
+
if (storedVal == null) {
|
4983
|
+
return null;
|
4984
|
+
}
|
4985
|
+
else {
|
4986
|
+
return util.jsonEval(storedVal);
|
4987
|
+
}
|
4988
|
+
}
|
4989
|
+
remove(key) {
|
4990
|
+
this.domStorage_.removeItem(this.prefixedName_(key));
|
4991
|
+
}
|
4992
|
+
prefixedName_(name) {
|
4993
|
+
return this.prefix_ + name;
|
4994
|
+
}
|
4995
|
+
toString() {
|
4996
|
+
return this.domStorage_.toString();
|
4997
|
+
}
|
4998
|
+
}
|
4999
|
+
|
5000
|
+
/**
|
5001
|
+
* @license
|
5002
|
+
* Copyright 2017 Google LLC
|
5003
|
+
*
|
5004
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5005
|
+
* you may not use this file except in compliance with the License.
|
5006
|
+
* You may obtain a copy of the License at
|
5007
|
+
*
|
5008
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
5009
|
+
*
|
5010
|
+
* Unless required by applicable law or agreed to in writing, software
|
5011
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
5012
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
5013
|
+
* See the License for the specific language governing permissions and
|
5014
|
+
* limitations under the License.
|
5015
|
+
*/
|
5016
|
+
/**
|
5017
|
+
* An in-memory storage implementation that matches the API of DOMStorageWrapper
|
5018
|
+
* (TODO: create interface for both to implement).
|
5019
|
+
*/
|
5020
|
+
class MemoryStorage {
|
5021
|
+
constructor() {
|
5022
|
+
this.cache_ = {};
|
5023
|
+
this.isInMemoryStorage = true;
|
5024
|
+
}
|
5025
|
+
set(key, value) {
|
5026
|
+
if (value == null) {
|
5027
|
+
delete this.cache_[key];
|
5028
|
+
}
|
5029
|
+
else {
|
5030
|
+
this.cache_[key] = value;
|
5031
|
+
}
|
5032
|
+
}
|
5033
|
+
get(key) {
|
5034
|
+
if (util.contains(this.cache_, key)) {
|
5035
|
+
return this.cache_[key];
|
5036
|
+
}
|
5037
|
+
return null;
|
5038
|
+
}
|
5039
|
+
remove(key) {
|
5040
|
+
delete this.cache_[key];
|
5041
|
+
}
|
5042
|
+
}
|
5043
|
+
|
5044
|
+
/**
|
5045
|
+
* @license
|
5046
|
+
* Copyright 2017 Google LLC
|
5047
|
+
*
|
5048
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5049
|
+
* you may not use this file except in compliance with the License.
|
5050
|
+
* You may obtain a copy of the License at
|
5051
|
+
*
|
5052
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
5053
|
+
*
|
5054
|
+
* Unless required by applicable law or agreed to in writing, software
|
5055
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
5056
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
5057
|
+
* See the License for the specific language governing permissions and
|
5058
|
+
* limitations under the License.
|
5059
|
+
*/
|
5060
|
+
/**
|
5061
|
+
* Helper to create a DOMStorageWrapper or else fall back to MemoryStorage.
|
5062
|
+
* TODO: Once MemoryStorage and DOMStorageWrapper have a shared interface this method annotation should change
|
5063
|
+
* to reflect this type
|
5064
|
+
*
|
5065
|
+
* @param domStorageName - Name of the underlying storage object
|
5066
|
+
* (e.g. 'localStorage' or 'sessionStorage').
|
5067
|
+
* @returns Turning off type information until a common interface is defined.
|
5068
|
+
*/
|
5069
|
+
const createStoragefor = function (domStorageName) {
|
5070
|
+
try {
|
5071
|
+
// NOTE: just accessing "localStorage" or "window['localStorage']" may throw a security exception,
|
5072
|
+
// so it must be inside the try/catch.
|
5073
|
+
if (typeof window !== 'undefined' &&
|
5074
|
+
typeof window[domStorageName] !== 'undefined') {
|
5075
|
+
// Need to test cache. Just because it's here doesn't mean it works
|
5076
|
+
const domStorage = window[domStorageName];
|
5077
|
+
domStorage.setItem('firebase:sentinel', 'cache');
|
5078
|
+
domStorage.removeItem('firebase:sentinel');
|
5079
|
+
return new DOMStorageWrapper(domStorage);
|
5080
|
+
}
|
5081
|
+
}
|
5082
|
+
catch (e) { }
|
5083
|
+
// Failed to create wrapper. Just return in-memory storage.
|
5084
|
+
// TODO: log?
|
5085
|
+
return new MemoryStorage();
|
5086
|
+
};
|
5087
|
+
/** A storage object that lasts across sessions */
|
5088
|
+
const PersistentStorage = createStoragefor('localStorage');
|
5089
|
+
/** A storage object that only lasts one session */
|
5090
|
+
const SessionStorage = createStoragefor('sessionStorage');
|
5091
|
+
|
5092
|
+
/**
|
5093
|
+
* @license
|
5094
|
+
* Copyright 2017 Google LLC
|
5095
|
+
*
|
5096
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5097
|
+
* you may not use this file except in compliance with the License.
|
5098
|
+
* You may obtain a copy of the License at
|
5099
|
+
*
|
5100
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
5101
|
+
*
|
5102
|
+
* Unless required by applicable law or agreed to in writing, software
|
5103
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
5104
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
5105
|
+
* See the License for the specific language governing permissions and
|
5106
|
+
* limitations under the License.
|
5107
|
+
*/
|
5108
|
+
const logClient$1 = new logger$1.Logger('@firebase/database');
|
5109
|
+
/**
|
5110
|
+
* Returns a locally-unique ID (generated by just incrementing up from 0 each time its called).
|
5111
|
+
*/
|
5112
|
+
const LUIDGenerator = (function () {
|
5113
|
+
let id = 1;
|
5114
|
+
return function () {
|
5115
|
+
return id++;
|
5116
|
+
};
|
5117
|
+
})();
|
5118
|
+
/**
|
5119
|
+
* Sha1 hash of the input string
|
5120
|
+
* @param str - The string to hash
|
5121
|
+
* @returns {!string} The resulting hash
|
5122
|
+
*/
|
5123
|
+
const sha1 = function (str) {
|
5124
|
+
const utf8Bytes = util.stringToByteArray(str);
|
5125
|
+
const sha1 = new util.Sha1();
|
5126
|
+
sha1.update(utf8Bytes);
|
5127
|
+
const sha1Bytes = sha1.digest();
|
5128
|
+
return util.base64.encodeByteArray(sha1Bytes);
|
5129
|
+
};
|
5130
|
+
const buildLogMessage_ = function (...varArgs) {
|
5131
|
+
let message = '';
|
5132
|
+
for (let i = 0; i < varArgs.length; i++) {
|
5133
|
+
const arg = varArgs[i];
|
5134
|
+
if (Array.isArray(arg) ||
|
5135
|
+
(arg &&
|
5136
|
+
typeof arg === 'object' &&
|
5137
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
5138
|
+
typeof arg.length === 'number')) {
|
5139
|
+
message += buildLogMessage_.apply(null, arg);
|
3598
5140
|
}
|
3599
5141
|
else if (typeof arg === 'object') {
|
3600
5142
|
message += util.stringify(arg);
|
@@ -4622,15 +6164,24 @@ WebSocketConnection.healthyTimeout = 30000;
|
|
4622
6164
|
* Abstraction around AppCheck's token fetching capabilities.
|
4623
6165
|
*/
|
4624
6166
|
class AppCheckTokenProvider {
|
4625
|
-
constructor(
|
4626
|
-
this.appName_ = appName_;
|
6167
|
+
constructor(app$1, appCheckProvider) {
|
4627
6168
|
this.appCheckProvider = appCheckProvider;
|
6169
|
+
this.appName = app$1.name;
|
6170
|
+
if (app._isFirebaseServerApp(app$1) && app$1.settings.appCheckToken) {
|
6171
|
+
this.serverAppAppCheckToken = app$1.settings.appCheckToken;
|
6172
|
+
}
|
4628
6173
|
this.appCheck = appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.getImmediate({ optional: true });
|
4629
6174
|
if (!this.appCheck) {
|
4630
6175
|
appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.get().then(appCheck => (this.appCheck = appCheck));
|
4631
6176
|
}
|
4632
6177
|
}
|
4633
6178
|
getToken(forceRefresh) {
|
6179
|
+
if (this.serverAppAppCheckToken) {
|
6180
|
+
if (forceRefresh) {
|
6181
|
+
throw new Error('Attempted reuse of `FirebaseServerApp.appCheckToken` after previous usage failed.');
|
6182
|
+
}
|
6183
|
+
return Promise.resolve({ token: this.serverAppAppCheckToken });
|
6184
|
+
}
|
4634
6185
|
if (!this.appCheck) {
|
4635
6186
|
return new Promise((resolve, reject) => {
|
4636
6187
|
// Support delayed initialization of FirebaseAppCheck. This allows our
|
@@ -4654,7 +6205,7 @@ class AppCheckTokenProvider {
|
|
4654
6205
|
(_a = this.appCheckProvider) === null || _a === void 0 ? void 0 : _a.get().then(appCheck => appCheck.addTokenListener(listener));
|
4655
6206
|
}
|
4656
6207
|
notifyForInvalidToken() {
|
4657
|
-
warn$1(`Provided AppCheck credentials for the app named "${this.
|
6208
|
+
warn$1(`Provided AppCheck credentials for the app named "${this.appName}" ` +
|
4658
6209
|
'are invalid. This usually indicates your app was not initialized correctly.');
|
4659
6210
|
}
|
4660
6211
|
}
|
@@ -7085,7 +8636,7 @@ class PersistentConnection extends ServerActions {
|
|
7085
8636
|
}
|
7086
8637
|
this.lastConnectionEstablishedTime_ = null;
|
7087
8638
|
}
|
7088
|
-
const timeSinceLastConnectAttempt = new Date().getTime() - this.lastConnectionAttemptTime_;
|
8639
|
+
const timeSinceLastConnectAttempt = Math.max(0, new Date().getTime() - this.lastConnectionAttemptTime_);
|
7089
8640
|
let reconnectDelay = Math.max(0, this.reconnectDelay_ - timeSinceLastConnectAttempt);
|
7090
8641
|
reconnectDelay = Math.random() * reconnectDelay;
|
7091
8642
|
this.log_('Trying to reconnect in ' + reconnectDelay + 'ms');
|
@@ -16876,7 +18427,7 @@ function repoManagerDatabaseFromApp(app, authProvider, appCheckProvider, url, no
|
|
16876
18427
|
fatal('Database URL must point to the root of a Firebase Database ' +
|
16877
18428
|
'(not including a child path).');
|
16878
18429
|
}
|
16879
|
-
const repo = repoManagerCreateRepo(repoInfo, app, authTokenProvider, new AppCheckTokenProvider(app
|
18430
|
+
const repo = repoManagerCreateRepo(repoInfo, app, authTokenProvider, new AppCheckTokenProvider(app, appCheckProvider));
|
16880
18431
|
return new Database$1(repo, app);
|
16881
18432
|
}
|
16882
18433
|
/**
|
@@ -17362,7 +18913,7 @@ var update_1 = index_standalone.update = update;
|
|
17362
18913
|
* See the License for the specific language governing permissions and
|
17363
18914
|
* limitations under the License.
|
17364
18915
|
*/
|
17365
|
-
const logClient = new require$$
|
18916
|
+
const logClient = new require$$1$3.Logger('@firebase/database-compat');
|
17366
18917
|
const warn = function (msg) {
|
17367
18918
|
const message = 'FIREBASE WARNING: ' + msg;
|
17368
18919
|
logClient.warn(message);
|
@@ -17389,7 +18940,7 @@ const validateBoolean = function (fnName, argumentName, bool, optional) {
|
|
17389
18940
|
return;
|
17390
18941
|
}
|
17391
18942
|
if (typeof bool !== 'boolean') {
|
17392
|
-
throw new Error(require$$
|
18943
|
+
throw new Error(require$$2$3.errorPrefix(fnName, argumentName) + 'must be a boolean.');
|
17393
18944
|
}
|
17394
18945
|
};
|
17395
18946
|
const validateEventType = function (fnName, eventType, optional) {
|
@@ -17404,7 +18955,7 @@ const validateEventType = function (fnName, eventType, optional) {
|
|
17404
18955
|
case 'child_moved':
|
17405
18956
|
break;
|
17406
18957
|
default:
|
17407
|
-
throw new Error(require$$
|
18958
|
+
throw new Error(require$$2$3.errorPrefix(fnName, 'eventType') +
|
17408
18959
|
'must be a valid event type = "value", "child_added", "child_removed", ' +
|
17409
18960
|
'"child_changed", or "child_moved".');
|
17410
18961
|
}
|
@@ -17431,8 +18982,8 @@ class OnDisconnect {
|
|
17431
18982
|
this._delegate = _delegate;
|
17432
18983
|
}
|
17433
18984
|
cancel(onComplete) {
|
17434
|
-
require$$
|
17435
|
-
require$$
|
18985
|
+
require$$2$3.validateArgCount('OnDisconnect.cancel', 0, 1, arguments.length);
|
18986
|
+
require$$2$3.validateCallback('OnDisconnect.cancel', 'onComplete', onComplete, true);
|
17436
18987
|
const result = this._delegate.cancel();
|
17437
18988
|
if (onComplete) {
|
17438
18989
|
result.then(() => onComplete(null), error => onComplete(error));
|
@@ -17440,8 +18991,8 @@ class OnDisconnect {
|
|
17440
18991
|
return result;
|
17441
18992
|
}
|
17442
18993
|
remove(onComplete) {
|
17443
|
-
require$$
|
17444
|
-
require$$
|
18994
|
+
require$$2$3.validateArgCount('OnDisconnect.remove', 0, 1, arguments.length);
|
18995
|
+
require$$2$3.validateCallback('OnDisconnect.remove', 'onComplete', onComplete, true);
|
17445
18996
|
const result = this._delegate.remove();
|
17446
18997
|
if (onComplete) {
|
17447
18998
|
result.then(() => onComplete(null), error => onComplete(error));
|
@@ -17449,8 +19000,8 @@ class OnDisconnect {
|
|
17449
19000
|
return result;
|
17450
19001
|
}
|
17451
19002
|
set(value, onComplete) {
|
17452
|
-
require$$
|
17453
|
-
require$$
|
19003
|
+
require$$2$3.validateArgCount('OnDisconnect.set', 1, 2, arguments.length);
|
19004
|
+
require$$2$3.validateCallback('OnDisconnect.set', 'onComplete', onComplete, true);
|
17454
19005
|
const result = this._delegate.set(value);
|
17455
19006
|
if (onComplete) {
|
17456
19007
|
result.then(() => onComplete(null), error => onComplete(error));
|
@@ -17458,8 +19009,8 @@ class OnDisconnect {
|
|
17458
19009
|
return result;
|
17459
19010
|
}
|
17460
19011
|
setWithPriority(value, priority, onComplete) {
|
17461
|
-
require$$
|
17462
|
-
require$$
|
19012
|
+
require$$2$3.validateArgCount('OnDisconnect.setWithPriority', 2, 3, arguments.length);
|
19013
|
+
require$$2$3.validateCallback('OnDisconnect.setWithPriority', 'onComplete', onComplete, true);
|
17463
19014
|
const result = this._delegate.setWithPriority(value, priority);
|
17464
19015
|
if (onComplete) {
|
17465
19016
|
result.then(() => onComplete(null), error => onComplete(error));
|
@@ -17467,7 +19018,7 @@ class OnDisconnect {
|
|
17467
19018
|
return result;
|
17468
19019
|
}
|
17469
19020
|
update(objectToMerge, onComplete) {
|
17470
|
-
require$$
|
19021
|
+
require$$2$3.validateArgCount('OnDisconnect.update', 1, 2, arguments.length);
|
17471
19022
|
if (Array.isArray(objectToMerge)) {
|
17472
19023
|
const newObjectToMerge = {};
|
17473
19024
|
for (let i = 0; i < objectToMerge.length; ++i) {
|
@@ -17477,7 +19028,7 @@ class OnDisconnect {
|
|
17477
19028
|
warn('Passing an Array to firebase.database.onDisconnect().update() is deprecated. Use set() if you want to overwrite the ' +
|
17478
19029
|
'existing data, or an Object with integer keys if you really do want to only update some of the children.');
|
17479
19030
|
}
|
17480
|
-
require$$
|
19031
|
+
require$$2$3.validateCallback('OnDisconnect.update', 'onComplete', onComplete, true);
|
17481
19032
|
const result = this._delegate.update(objectToMerge);
|
17482
19033
|
if (onComplete) {
|
17483
19034
|
result.then(() => onComplete(null), error => onComplete(error));
|
@@ -17513,7 +19064,7 @@ class TransactionResult {
|
|
17513
19064
|
// Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary
|
17514
19065
|
// for end-users
|
17515
19066
|
toJSON() {
|
17516
|
-
require$$
|
19067
|
+
require$$2$3.validateArgCount('TransactionResult.toJSON', 0, 1, arguments.length);
|
17517
19068
|
return { committed: this.committed, snapshot: this.snapshot.toJSON() };
|
17518
19069
|
}
|
17519
19070
|
}
|
@@ -17550,7 +19101,7 @@ class DataSnapshot {
|
|
17550
19101
|
* @returns JSON representation of the DataSnapshot contents, or null if empty.
|
17551
19102
|
*/
|
17552
19103
|
val() {
|
17553
|
-
require$$
|
19104
|
+
require$$2$3.validateArgCount('DataSnapshot.val', 0, 0, arguments.length);
|
17554
19105
|
return this._delegate.val();
|
17555
19106
|
}
|
17556
19107
|
/**
|
@@ -17559,14 +19110,14 @@ class DataSnapshot {
|
|
17559
19110
|
* @returns JSON representation of the DataSnapshot contents, or null if empty.
|
17560
19111
|
*/
|
17561
19112
|
exportVal() {
|
17562
|
-
require$$
|
19113
|
+
require$$2$3.validateArgCount('DataSnapshot.exportVal', 0, 0, arguments.length);
|
17563
19114
|
return this._delegate.exportVal();
|
17564
19115
|
}
|
17565
19116
|
// Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary
|
17566
19117
|
// for end-users
|
17567
19118
|
toJSON() {
|
17568
19119
|
// Optional spacer argument is unnecessary because we're depending on recursion rather than stringifying the content
|
17569
|
-
require$$
|
19120
|
+
require$$2$3.validateArgCount('DataSnapshot.toJSON', 0, 1, arguments.length);
|
17570
19121
|
return this._delegate.toJSON();
|
17571
19122
|
}
|
17572
19123
|
/**
|
@@ -17575,7 +19126,7 @@ class DataSnapshot {
|
|
17575
19126
|
* @returns Whether the snapshot contains a non-null value, or is empty.
|
17576
19127
|
*/
|
17577
19128
|
exists() {
|
17578
|
-
require$$
|
19129
|
+
require$$2$3.validateArgCount('DataSnapshot.exists', 0, 0, arguments.length);
|
17579
19130
|
return this._delegate.exists();
|
17580
19131
|
}
|
17581
19132
|
/**
|
@@ -17585,7 +19136,7 @@ class DataSnapshot {
|
|
17585
19136
|
* @returns DataSnapshot for child node.
|
17586
19137
|
*/
|
17587
19138
|
child(path) {
|
17588
|
-
require$$
|
19139
|
+
require$$2$3.validateArgCount('DataSnapshot.child', 0, 1, arguments.length);
|
17589
19140
|
// Ensure the childPath is a string (can be a number)
|
17590
19141
|
path = String(path);
|
17591
19142
|
_validatePathString('DataSnapshot.child', 'path', path, false);
|
@@ -17598,7 +19149,7 @@ class DataSnapshot {
|
|
17598
19149
|
* @returns Whether the child exists.
|
17599
19150
|
*/
|
17600
19151
|
hasChild(path) {
|
17601
|
-
require$$
|
19152
|
+
require$$2$3.validateArgCount('DataSnapshot.hasChild', 1, 1, arguments.length);
|
17602
19153
|
_validatePathString('DataSnapshot.hasChild', 'path', path, false);
|
17603
19154
|
return this._delegate.hasChild(path);
|
17604
19155
|
}
|
@@ -17608,7 +19159,7 @@ class DataSnapshot {
|
|
17608
19159
|
* @returns The priority.
|
17609
19160
|
*/
|
17610
19161
|
getPriority() {
|
17611
|
-
require$$
|
19162
|
+
require$$2$3.validateArgCount('DataSnapshot.getPriority', 0, 0, arguments.length);
|
17612
19163
|
return this._delegate.priority;
|
17613
19164
|
}
|
17614
19165
|
/**
|
@@ -17620,8 +19171,8 @@ class DataSnapshot {
|
|
17620
19171
|
* one of the child nodes.
|
17621
19172
|
*/
|
17622
19173
|
forEach(action) {
|
17623
|
-
require$$
|
17624
|
-
require$$
|
19174
|
+
require$$2$3.validateArgCount('DataSnapshot.forEach', 1, 1, arguments.length);
|
19175
|
+
require$$2$3.validateCallback('DataSnapshot.forEach', 'action', action, false);
|
17625
19176
|
return this._delegate.forEach(expDataSnapshot => action(new DataSnapshot(this._database, expDataSnapshot)));
|
17626
19177
|
}
|
17627
19178
|
/**
|
@@ -17629,7 +19180,7 @@ class DataSnapshot {
|
|
17629
19180
|
* @returns True if the DataSnapshot contains 1 or more child nodes.
|
17630
19181
|
*/
|
17631
19182
|
hasChildren() {
|
17632
|
-
require$$
|
19183
|
+
require$$2$3.validateArgCount('DataSnapshot.hasChildren', 0, 0, arguments.length);
|
17633
19184
|
return this._delegate.hasChildren();
|
17634
19185
|
}
|
17635
19186
|
get key() {
|
@@ -17640,7 +19191,7 @@ class DataSnapshot {
|
|
17640
19191
|
* @returns The number of children that this DataSnapshot contains.
|
17641
19192
|
*/
|
17642
19193
|
numChildren() {
|
17643
|
-
require$$
|
19194
|
+
require$$2$3.validateArgCount('DataSnapshot.numChildren', 0, 0, arguments.length);
|
17644
19195
|
return this._delegate.size;
|
17645
19196
|
}
|
17646
19197
|
/**
|
@@ -17648,7 +19199,7 @@ class DataSnapshot {
|
|
17648
19199
|
* from.
|
17649
19200
|
*/
|
17650
19201
|
getRef() {
|
17651
|
-
require$$
|
19202
|
+
require$$2$3.validateArgCount('DataSnapshot.ref', 0, 0, arguments.length);
|
17652
19203
|
return new Reference(this._database, this._delegate.ref);
|
17653
19204
|
}
|
17654
19205
|
get ref() {
|
@@ -17668,8 +19219,8 @@ class Query {
|
|
17668
19219
|
}
|
17669
19220
|
on(eventType, callback, cancelCallbackOrContext, context) {
|
17670
19221
|
var _a;
|
17671
|
-
require$$
|
17672
|
-
require$$
|
19222
|
+
require$$2$3.validateArgCount('Query.on', 2, 4, arguments.length);
|
19223
|
+
require$$2$3.validateCallback('Query.on', 'callback', callback, false);
|
17673
19224
|
const ret = Query.getCancelAndContextArgs_('Query.on', cancelCallbackOrContext, context);
|
17674
19225
|
const valueCallback = (expSnapshot, previousChildName) => {
|
17675
19226
|
callback.call(ret.context, new DataSnapshot(this.database, expSnapshot), previousChildName);
|
@@ -17694,16 +19245,16 @@ class Query {
|
|
17694
19245
|
onChildMoved_1(this._delegate, valueCallback, cancelCallback);
|
17695
19246
|
return callback;
|
17696
19247
|
default:
|
17697
|
-
throw new Error(require$$
|
19248
|
+
throw new Error(require$$2$3.errorPrefix('Query.on', 'eventType') +
|
17698
19249
|
'must be a valid event type = "value", "child_added", "child_removed", ' +
|
17699
19250
|
'"child_changed", or "child_moved".');
|
17700
19251
|
}
|
17701
19252
|
}
|
17702
19253
|
off(eventType, callback, context) {
|
17703
|
-
require$$
|
19254
|
+
require$$2$3.validateArgCount('Query.off', 0, 3, arguments.length);
|
17704
19255
|
validateEventType('Query.off', eventType, true);
|
17705
|
-
require$$
|
17706
|
-
require$$
|
19256
|
+
require$$2$3.validateCallback('Query.off', 'callback', callback, true);
|
19257
|
+
require$$2$3.validateContextObject('Query.off', 'context', context, true);
|
17707
19258
|
if (callback) {
|
17708
19259
|
const valueCallback = () => { };
|
17709
19260
|
valueCallback.userCallback = callback;
|
@@ -17726,10 +19277,10 @@ class Query {
|
|
17726
19277
|
* Attaches a listener, waits for the first event, and then removes the listener
|
17727
19278
|
*/
|
17728
19279
|
once(eventType, callback, failureCallbackOrContext, context) {
|
17729
|
-
require$$
|
17730
|
-
require$$
|
19280
|
+
require$$2$3.validateArgCount('Query.once', 1, 4, arguments.length);
|
19281
|
+
require$$2$3.validateCallback('Query.once', 'callback', callback, true);
|
17731
19282
|
const ret = Query.getCancelAndContextArgs_('Query.once', failureCallbackOrContext, context);
|
17732
|
-
const deferred = new require$$
|
19283
|
+
const deferred = new require$$2$3.Deferred();
|
17733
19284
|
const valueCallback = (expSnapshot, previousChildName) => {
|
17734
19285
|
const result = new DataSnapshot(this.database, expSnapshot);
|
17735
19286
|
if (callback) {
|
@@ -17772,7 +19323,7 @@ class Query {
|
|
17772
19323
|
});
|
17773
19324
|
break;
|
17774
19325
|
default:
|
17775
|
-
throw new Error(require$$
|
19326
|
+
throw new Error(require$$2$3.errorPrefix('Query.once', 'eventType') +
|
17776
19327
|
'must be a valid event type = "value", "child_added", "child_removed", ' +
|
17777
19328
|
'"child_changed", or "child_moved".');
|
17778
19329
|
}
|
@@ -17782,58 +19333,58 @@ class Query {
|
|
17782
19333
|
* Set a limit and anchor it to the start of the window.
|
17783
19334
|
*/
|
17784
19335
|
limitToFirst(limit) {
|
17785
|
-
require$$
|
19336
|
+
require$$2$3.validateArgCount('Query.limitToFirst', 1, 1, arguments.length);
|
17786
19337
|
return new Query(this.database, query_1(this._delegate, limitToFirst_1(limit)));
|
17787
19338
|
}
|
17788
19339
|
/**
|
17789
19340
|
* Set a limit and anchor it to the end of the window.
|
17790
19341
|
*/
|
17791
19342
|
limitToLast(limit) {
|
17792
|
-
require$$
|
19343
|
+
require$$2$3.validateArgCount('Query.limitToLast', 1, 1, arguments.length);
|
17793
19344
|
return new Query(this.database, query_1(this._delegate, limitToLast_1(limit)));
|
17794
19345
|
}
|
17795
19346
|
/**
|
17796
19347
|
* Given a child path, return a new query ordered by the specified grandchild path.
|
17797
19348
|
*/
|
17798
19349
|
orderByChild(path) {
|
17799
|
-
require$$
|
19350
|
+
require$$2$3.validateArgCount('Query.orderByChild', 1, 1, arguments.length);
|
17800
19351
|
return new Query(this.database, query_1(this._delegate, orderByChild_1(path)));
|
17801
19352
|
}
|
17802
19353
|
/**
|
17803
19354
|
* Return a new query ordered by the KeyIndex
|
17804
19355
|
*/
|
17805
19356
|
orderByKey() {
|
17806
|
-
require$$
|
19357
|
+
require$$2$3.validateArgCount('Query.orderByKey', 0, 0, arguments.length);
|
17807
19358
|
return new Query(this.database, query_1(this._delegate, orderByKey_1()));
|
17808
19359
|
}
|
17809
19360
|
/**
|
17810
19361
|
* Return a new query ordered by the PriorityIndex
|
17811
19362
|
*/
|
17812
19363
|
orderByPriority() {
|
17813
|
-
require$$
|
19364
|
+
require$$2$3.validateArgCount('Query.orderByPriority', 0, 0, arguments.length);
|
17814
19365
|
return new Query(this.database, query_1(this._delegate, orderByPriority_1()));
|
17815
19366
|
}
|
17816
19367
|
/**
|
17817
19368
|
* Return a new query ordered by the ValueIndex
|
17818
19369
|
*/
|
17819
19370
|
orderByValue() {
|
17820
|
-
require$$
|
19371
|
+
require$$2$3.validateArgCount('Query.orderByValue', 0, 0, arguments.length);
|
17821
19372
|
return new Query(this.database, query_1(this._delegate, orderByValue_1()));
|
17822
19373
|
}
|
17823
19374
|
startAt(value = null, name) {
|
17824
|
-
require$$
|
19375
|
+
require$$2$3.validateArgCount('Query.startAt', 0, 2, arguments.length);
|
17825
19376
|
return new Query(this.database, query_1(this._delegate, startAt_1(value, name)));
|
17826
19377
|
}
|
17827
19378
|
startAfter(value = null, name) {
|
17828
|
-
require$$
|
19379
|
+
require$$2$3.validateArgCount('Query.startAfter', 0, 2, arguments.length);
|
17829
19380
|
return new Query(this.database, query_1(this._delegate, startAfter_1(value, name)));
|
17830
19381
|
}
|
17831
19382
|
endAt(value = null, name) {
|
17832
|
-
require$$
|
19383
|
+
require$$2$3.validateArgCount('Query.endAt', 0, 2, arguments.length);
|
17833
19384
|
return new Query(this.database, query_1(this._delegate, endAt_1(value, name)));
|
17834
19385
|
}
|
17835
19386
|
endBefore(value = null, name) {
|
17836
|
-
require$$
|
19387
|
+
require$$2$3.validateArgCount('Query.endBefore', 0, 2, arguments.length);
|
17837
19388
|
return new Query(this.database, query_1(this._delegate, endBefore_1(value, name)));
|
17838
19389
|
}
|
17839
19390
|
/**
|
@@ -17841,28 +19392,28 @@ class Query {
|
|
17841
19392
|
* the specified name.
|
17842
19393
|
*/
|
17843
19394
|
equalTo(value, name) {
|
17844
|
-
require$$
|
19395
|
+
require$$2$3.validateArgCount('Query.equalTo', 1, 2, arguments.length);
|
17845
19396
|
return new Query(this.database, query_1(this._delegate, equalTo_1(value, name)));
|
17846
19397
|
}
|
17847
19398
|
/**
|
17848
19399
|
* @returns URL for this location.
|
17849
19400
|
*/
|
17850
19401
|
toString() {
|
17851
|
-
require$$
|
19402
|
+
require$$2$3.validateArgCount('Query.toString', 0, 0, arguments.length);
|
17852
19403
|
return this._delegate.toString();
|
17853
19404
|
}
|
17854
19405
|
// Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary
|
17855
19406
|
// for end-users.
|
17856
19407
|
toJSON() {
|
17857
19408
|
// An optional spacer argument is unnecessary for a string.
|
17858
|
-
require$$
|
19409
|
+
require$$2$3.validateArgCount('Query.toJSON', 0, 1, arguments.length);
|
17859
19410
|
return this._delegate.toJSON();
|
17860
19411
|
}
|
17861
19412
|
/**
|
17862
19413
|
* Return true if this query and the provided query are equivalent; otherwise, return false.
|
17863
19414
|
*/
|
17864
19415
|
isEqual(other) {
|
17865
|
-
require$$
|
19416
|
+
require$$2$3.validateArgCount('Query.isEqual', 1, 1, arguments.length);
|
17866
19417
|
if (!(other instanceof Query)) {
|
17867
19418
|
const error = 'Query.isEqual failed: First argument must be an instance of firebase.database.Query.';
|
17868
19419
|
throw new Error(error);
|
@@ -17878,9 +19429,9 @@ class Query {
|
|
17878
19429
|
const ret = { cancel: undefined, context: undefined };
|
17879
19430
|
if (cancelOrContext && context) {
|
17880
19431
|
ret.cancel = cancelOrContext;
|
17881
|
-
require$$
|
19432
|
+
require$$2$3.validateCallback(fnName, 'cancel', ret.cancel, true);
|
17882
19433
|
ret.context = context;
|
17883
|
-
require$$
|
19434
|
+
require$$2$3.validateContextObject(fnName, 'context', ret.context, true);
|
17884
19435
|
}
|
17885
19436
|
else if (cancelOrContext) {
|
17886
19437
|
// we have either a cancel callback or a context.
|
@@ -17892,7 +19443,7 @@ class Query {
|
|
17892
19443
|
ret.cancel = cancelOrContext;
|
17893
19444
|
}
|
17894
19445
|
else {
|
17895
|
-
throw new Error(require$$
|
19446
|
+
throw new Error(require$$2$3.errorPrefix(fnName, 'cancelOrContext') +
|
17896
19447
|
' must either be a cancel callback or a context object.');
|
17897
19448
|
}
|
17898
19449
|
}
|
@@ -17917,11 +19468,11 @@ class Reference extends Query {
|
|
17917
19468
|
}
|
17918
19469
|
/** @returns {?string} */
|
17919
19470
|
getKey() {
|
17920
|
-
require$$
|
19471
|
+
require$$2$3.validateArgCount('Reference.key', 0, 0, arguments.length);
|
17921
19472
|
return this._delegate.key;
|
17922
19473
|
}
|
17923
19474
|
child(pathString) {
|
17924
|
-
require$$
|
19475
|
+
require$$2$3.validateArgCount('Reference.child', 1, 1, arguments.length);
|
17925
19476
|
if (typeof pathString === 'number') {
|
17926
19477
|
pathString = String(pathString);
|
17927
19478
|
}
|
@@ -17929,18 +19480,18 @@ class Reference extends Query {
|
|
17929
19480
|
}
|
17930
19481
|
/** @returns {?Reference} */
|
17931
19482
|
getParent() {
|
17932
|
-
require$$
|
19483
|
+
require$$2$3.validateArgCount('Reference.parent', 0, 0, arguments.length);
|
17933
19484
|
const parent = this._delegate.parent;
|
17934
19485
|
return parent ? new Reference(this.database, parent) : null;
|
17935
19486
|
}
|
17936
19487
|
/** @returns {!Reference} */
|
17937
19488
|
getRoot() {
|
17938
|
-
require$$
|
19489
|
+
require$$2$3.validateArgCount('Reference.root', 0, 0, arguments.length);
|
17939
19490
|
return new Reference(this.database, this._delegate.root);
|
17940
19491
|
}
|
17941
19492
|
set(newVal, onComplete) {
|
17942
|
-
require$$
|
17943
|
-
require$$
|
19493
|
+
require$$2$3.validateArgCount('Reference.set', 1, 2, arguments.length);
|
19494
|
+
require$$2$3.validateCallback('Reference.set', 'onComplete', onComplete, true);
|
17944
19495
|
const result = set_1(this._delegate, newVal);
|
17945
19496
|
if (onComplete) {
|
17946
19497
|
result.then(() => onComplete(null), error => onComplete(error));
|
@@ -17948,7 +19499,7 @@ class Reference extends Query {
|
|
17948
19499
|
return result;
|
17949
19500
|
}
|
17950
19501
|
update(values, onComplete) {
|
17951
|
-
require$$
|
19502
|
+
require$$2$3.validateArgCount('Reference.update', 1, 2, arguments.length);
|
17952
19503
|
if (Array.isArray(values)) {
|
17953
19504
|
const newObjectToMerge = {};
|
17954
19505
|
for (let i = 0; i < values.length; ++i) {
|
@@ -17961,7 +19512,7 @@ class Reference extends Query {
|
|
17961
19512
|
'only update some of the children.');
|
17962
19513
|
}
|
17963
19514
|
_validateWritablePath('Reference.update', this._delegate._path);
|
17964
|
-
require$$
|
19515
|
+
require$$2$3.validateCallback('Reference.update', 'onComplete', onComplete, true);
|
17965
19516
|
const result = update_1(this._delegate, values);
|
17966
19517
|
if (onComplete) {
|
17967
19518
|
result.then(() => onComplete(null), error => onComplete(error));
|
@@ -17969,8 +19520,8 @@ class Reference extends Query {
|
|
17969
19520
|
return result;
|
17970
19521
|
}
|
17971
19522
|
setWithPriority(newVal, newPriority, onComplete) {
|
17972
|
-
require$$
|
17973
|
-
require$$
|
19523
|
+
require$$2$3.validateArgCount('Reference.setWithPriority', 2, 3, arguments.length);
|
19524
|
+
require$$2$3.validateCallback('Reference.setWithPriority', 'onComplete', onComplete, true);
|
17974
19525
|
const result = setWithPriority_1(this._delegate, newVal, newPriority);
|
17975
19526
|
if (onComplete) {
|
17976
19527
|
result.then(() => onComplete(null), error => onComplete(error));
|
@@ -17978,8 +19529,8 @@ class Reference extends Query {
|
|
17978
19529
|
return result;
|
17979
19530
|
}
|
17980
19531
|
remove(onComplete) {
|
17981
|
-
require$$
|
17982
|
-
require$$
|
19532
|
+
require$$2$3.validateArgCount('Reference.remove', 0, 1, arguments.length);
|
19533
|
+
require$$2$3.validateCallback('Reference.remove', 'onComplete', onComplete, true);
|
17983
19534
|
const result = remove_1(this._delegate);
|
17984
19535
|
if (onComplete) {
|
17985
19536
|
result.then(() => onComplete(null), error => onComplete(error));
|
@@ -17987,9 +19538,9 @@ class Reference extends Query {
|
|
17987
19538
|
return result;
|
17988
19539
|
}
|
17989
19540
|
transaction(transactionUpdate, onComplete, applyLocally) {
|
17990
|
-
require$$
|
17991
|
-
require$$
|
17992
|
-
require$$
|
19541
|
+
require$$2$3.validateArgCount('Reference.transaction', 1, 3, arguments.length);
|
19542
|
+
require$$2$3.validateCallback('Reference.transaction', 'transactionUpdate', transactionUpdate, false);
|
19543
|
+
require$$2$3.validateCallback('Reference.transaction', 'onComplete', onComplete, true);
|
17993
19544
|
validateBoolean('Reference.transaction', 'applyLocally', applyLocally, true);
|
17994
19545
|
const result = runTransaction_1(this._delegate, transactionUpdate, {
|
17995
19546
|
applyLocally
|
@@ -18000,8 +19551,8 @@ class Reference extends Query {
|
|
18000
19551
|
return result;
|
18001
19552
|
}
|
18002
19553
|
setPriority(priority, onComplete) {
|
18003
|
-
require$$
|
18004
|
-
require$$
|
19554
|
+
require$$2$3.validateArgCount('Reference.setPriority', 1, 2, arguments.length);
|
19555
|
+
require$$2$3.validateCallback('Reference.setPriority', 'onComplete', onComplete, true);
|
18005
19556
|
const result = setPriority_1(this._delegate, priority);
|
18006
19557
|
if (onComplete) {
|
18007
19558
|
result.then(() => onComplete(null), error => onComplete(error));
|
@@ -18009,8 +19560,8 @@ class Reference extends Query {
|
|
18009
19560
|
return result;
|
18010
19561
|
}
|
18011
19562
|
push(value, onComplete) {
|
18012
|
-
require$$
|
18013
|
-
require$$
|
19563
|
+
require$$2$3.validateArgCount('Reference.push', 0, 2, arguments.length);
|
19564
|
+
require$$2$3.validateCallback('Reference.push', 'onComplete', onComplete, true);
|
18014
19565
|
const expPromise = push_1(this._delegate, value);
|
18015
19566
|
const promise = expPromise.then(expRef => new Reference(this.database, expRef));
|
18016
19567
|
if (onComplete) {
|
@@ -18081,7 +19632,7 @@ class Database {
|
|
18081
19632
|
connectDatabaseEmulator_1(this._delegate, host, port, options);
|
18082
19633
|
}
|
18083
19634
|
ref(path) {
|
18084
|
-
require$$
|
19635
|
+
require$$2$3.validateArgCount('database.ref', 0, 1, arguments.length);
|
18085
19636
|
if (path instanceof Reference) {
|
18086
19637
|
const childRef = refFromURL_1(this._delegate, path.toString());
|
18087
19638
|
return new Reference(this, childRef);
|
@@ -18099,17 +19650,17 @@ class Database {
|
|
18099
19650
|
*/
|
18100
19651
|
refFromURL(url) {
|
18101
19652
|
const apiName = 'database.refFromURL';
|
18102
|
-
require$$
|
19653
|
+
require$$2$3.validateArgCount(apiName, 1, 1, arguments.length);
|
18103
19654
|
const childRef = refFromURL_1(this._delegate, url);
|
18104
19655
|
return new Reference(this, childRef);
|
18105
19656
|
}
|
18106
19657
|
// Make individual repo go offline.
|
18107
19658
|
goOffline() {
|
18108
|
-
require$$
|
19659
|
+
require$$2$3.validateArgCount('database.goOffline', 0, 0, arguments.length);
|
18109
19660
|
return goOffline_1(this._delegate);
|
18110
19661
|
}
|
18111
19662
|
goOnline() {
|
18112
|
-
require$$
|
19663
|
+
require$$2$3.validateArgCount('database.goOnline', 0, 0, arguments.length);
|
18113
19664
|
return goOnline_1(this._delegate);
|
18114
19665
|
}
|
18115
19666
|
}
|
@@ -18129,17 +19680,17 @@ Database.ServerValue = {
|
|
18129
19680
|
*/
|
18130
19681
|
function initStandalone$1({ app, url, version, customAuthImpl, customAppCheckImpl, namespace, nodeAdmin = false }) {
|
18131
19682
|
_setSDKVersion(version);
|
18132
|
-
const container = new require$$
|
19683
|
+
const container = new require$$0$2.ComponentContainer('database-standalone');
|
18133
19684
|
/**
|
18134
19685
|
* ComponentContainer('database-standalone') is just a placeholder that doesn't perform
|
18135
19686
|
* any actual function.
|
18136
19687
|
*/
|
18137
|
-
const authProvider = new require$$
|
18138
|
-
authProvider.setComponent(new require$$
|
19688
|
+
const authProvider = new require$$0$2.Provider('auth-internal', container);
|
19689
|
+
authProvider.setComponent(new require$$0$2.Component('auth-internal', () => customAuthImpl, "PRIVATE" /* ComponentType.PRIVATE */));
|
18139
19690
|
let appCheckProvider = undefined;
|
18140
19691
|
if (customAppCheckImpl) {
|
18141
|
-
appCheckProvider = new require$$
|
18142
|
-
appCheckProvider.setComponent(new require$$
|
19692
|
+
appCheckProvider = new require$$0$2.Provider('app-check-internal', container);
|
19693
|
+
appCheckProvider.setComponent(new require$$0$2.Component('app-check-internal', () => customAppCheckImpl, "PRIVATE" /* ComponentType.PRIVATE */));
|
18143
19694
|
}
|
18144
19695
|
return {
|
18145
19696
|
instance: new Database(_repoManagerDatabaseFromApp(app, authProvider, appCheckProvider, url, nodeAdmin), app),
|
@@ -18148,8 +19699,8 @@ function initStandalone$1({ app, url, version, customAuthImpl, customAppCheckImp
|
|
18148
19699
|
}
|
18149
19700
|
|
18150
19701
|
var INTERNAL = /*#__PURE__*/Object.freeze({
|
18151
|
-
|
18152
|
-
|
19702
|
+
__proto__: null,
|
19703
|
+
initStandalone: initStandalone$1
|
18153
19704
|
});
|
18154
19705
|
|
18155
19706
|
/**
|
@@ -18179,7 +19730,7 @@ const ServerValue = Database.ServerValue;
|
|
18179
19730
|
* @param nodeAdmin - true if the SDK is being initialized from Firebase Admin.
|
18180
19731
|
*/
|
18181
19732
|
function initStandalone(app, url, version, nodeAdmin = true) {
|
18182
|
-
require$$
|
19733
|
+
require$$2$3.CONSTANTS.NODE_ADMIN = nodeAdmin;
|
18183
19734
|
return initStandalone$1({
|
18184
19735
|
app,
|
18185
19736
|
url,
|