@firebase/database-compat 2.1.5 → 2.1.6
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.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.standalone.js +1695 -98
- package/dist/index.standalone.js.map +1 -1
- package/dist/node-esm/index.js +1 -1
- package/package.json +1 -1
package/dist/index.standalone.js
CHANGED
|
@@ -10,10 +10,24 @@ var require$$1$1 = require('crypto');
|
|
|
10
10
|
var require$$2$1 = require('url');
|
|
11
11
|
var require$$1$2 = require('net');
|
|
12
12
|
var require$$2$2 = require('tls');
|
|
13
|
-
var require$$
|
|
14
|
-
var require$$
|
|
15
|
-
var require$$
|
|
16
|
-
|
|
13
|
+
var require$$2$3 = require('@firebase/util');
|
|
14
|
+
var require$$1$3 = require('@firebase/logger');
|
|
15
|
+
var require$$0$2 = require('@firebase/component');
|
|
16
|
+
|
|
17
|
+
function getAugmentedNamespace(n) {
|
|
18
|
+
if (n.__esModule) return n;
|
|
19
|
+
var a = Object.defineProperty({}, '__esModule', {value: true});
|
|
20
|
+
Object.keys(n).forEach(function (k) {
|
|
21
|
+
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
22
|
+
Object.defineProperty(a, k, d.get ? d : {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () {
|
|
25
|
+
return n[k];
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
return a;
|
|
30
|
+
}
|
|
17
31
|
|
|
18
32
|
var index_standalone = {};
|
|
19
33
|
|
|
@@ -2216,7 +2230,7 @@ var Buffer$4 = safeBuffer.exports.Buffer,
|
|
|
2216
2230
|
|
|
2217
2231
|
var PORTS = { 'ws:': 80, 'wss:': 443 };
|
|
2218
2232
|
|
|
2219
|
-
var Proxy$
|
|
2233
|
+
var Proxy$2 = function(client, origin, options) {
|
|
2220
2234
|
this._client = client;
|
|
2221
2235
|
this._http = new HttpParser$2('response');
|
|
2222
2236
|
this._origin = (typeof client.url === 'object') ? client.url : url$2.parse(client.url);
|
|
@@ -2235,7 +2249,7 @@ var Proxy$1 = function(client, origin, options) {
|
|
|
2235
2249
|
var auth = this._url.auth && Buffer$4.from(this._url.auth, 'utf8').toString('base64');
|
|
2236
2250
|
if (auth) this._headers.set('Proxy-Authorization', 'Basic ' + auth);
|
|
2237
2251
|
};
|
|
2238
|
-
util$9.inherits(Proxy$
|
|
2252
|
+
util$9.inherits(Proxy$2, Stream$2);
|
|
2239
2253
|
|
|
2240
2254
|
var instance$6 = {
|
|
2241
2255
|
setHeader: function(name, value) {
|
|
@@ -2300,9 +2314,9 @@ var instance$6 = {
|
|
|
2300
2314
|
};
|
|
2301
2315
|
|
|
2302
2316
|
for (var key$6 in instance$6)
|
|
2303
|
-
Proxy$
|
|
2317
|
+
Proxy$2.prototype[key$6] = instance$6[key$6];
|
|
2304
2318
|
|
|
2305
|
-
var proxy = Proxy$
|
|
2319
|
+
var proxy = Proxy$2;
|
|
2306
2320
|
|
|
2307
2321
|
var Buffer$3 = safeBuffer.exports.Buffer,
|
|
2308
2322
|
crypto$1 = require$$1$1,
|
|
@@ -2311,7 +2325,7 @@ var Buffer$3 = safeBuffer.exports.Buffer,
|
|
|
2311
2325
|
HttpParser$1 = http_parser,
|
|
2312
2326
|
Base$4 = base,
|
|
2313
2327
|
Hybi$1 = hybi,
|
|
2314
|
-
Proxy = proxy;
|
|
2328
|
+
Proxy$1 = proxy;
|
|
2315
2329
|
|
|
2316
2330
|
var Client$2 = function(_url, options) {
|
|
2317
2331
|
this.version = 'hybi-' + Hybi$1.VERSION;
|
|
@@ -2352,7 +2366,7 @@ var instance$5 = {
|
|
|
2352
2366
|
VALID_PROTOCOLS: ['ws:', 'wss:'],
|
|
2353
2367
|
|
|
2354
2368
|
proxy: function(origin, options) {
|
|
2355
|
-
return new Proxy(this, origin, options);
|
|
2369
|
+
return new Proxy$1(this, origin, options);
|
|
2356
2370
|
},
|
|
2357
2371
|
|
|
2358
2372
|
start: function() {
|
|
@@ -3345,13 +3359,1596 @@ WebSocket$1.EventSource = eventsource;
|
|
|
3345
3359
|
|
|
3346
3360
|
var websocket = WebSocket$1;
|
|
3347
3361
|
|
|
3362
|
+
var index_cjs = {};
|
|
3363
|
+
|
|
3364
|
+
const instanceOfAny = (object, constructors) => constructors.some((c) => object instanceof c);
|
|
3365
|
+
|
|
3366
|
+
let idbProxyableTypes;
|
|
3367
|
+
let cursorAdvanceMethods;
|
|
3368
|
+
// This is a function to prevent it throwing up in node environments.
|
|
3369
|
+
function getIdbProxyableTypes() {
|
|
3370
|
+
return (idbProxyableTypes ||
|
|
3371
|
+
(idbProxyableTypes = [
|
|
3372
|
+
IDBDatabase,
|
|
3373
|
+
IDBObjectStore,
|
|
3374
|
+
IDBIndex,
|
|
3375
|
+
IDBCursor,
|
|
3376
|
+
IDBTransaction,
|
|
3377
|
+
]));
|
|
3378
|
+
}
|
|
3379
|
+
// This is a function to prevent it throwing up in node environments.
|
|
3380
|
+
function getCursorAdvanceMethods() {
|
|
3381
|
+
return (cursorAdvanceMethods ||
|
|
3382
|
+
(cursorAdvanceMethods = [
|
|
3383
|
+
IDBCursor.prototype.advance,
|
|
3384
|
+
IDBCursor.prototype.continue,
|
|
3385
|
+
IDBCursor.prototype.continuePrimaryKey,
|
|
3386
|
+
]));
|
|
3387
|
+
}
|
|
3388
|
+
const cursorRequestMap = new WeakMap();
|
|
3389
|
+
const transactionDoneMap = new WeakMap();
|
|
3390
|
+
const transactionStoreNamesMap = new WeakMap();
|
|
3391
|
+
const transformCache = new WeakMap();
|
|
3392
|
+
const reverseTransformCache = new WeakMap();
|
|
3393
|
+
function promisifyRequest(request) {
|
|
3394
|
+
const promise = new Promise((resolve, reject) => {
|
|
3395
|
+
const unlisten = () => {
|
|
3396
|
+
request.removeEventListener('success', success);
|
|
3397
|
+
request.removeEventListener('error', error);
|
|
3398
|
+
};
|
|
3399
|
+
const success = () => {
|
|
3400
|
+
resolve(wrap(request.result));
|
|
3401
|
+
unlisten();
|
|
3402
|
+
};
|
|
3403
|
+
const error = () => {
|
|
3404
|
+
reject(request.error);
|
|
3405
|
+
unlisten();
|
|
3406
|
+
};
|
|
3407
|
+
request.addEventListener('success', success);
|
|
3408
|
+
request.addEventListener('error', error);
|
|
3409
|
+
});
|
|
3410
|
+
promise
|
|
3411
|
+
.then((value) => {
|
|
3412
|
+
// Since cursoring reuses the IDBRequest (*sigh*), we cache it for later retrieval
|
|
3413
|
+
// (see wrapFunction).
|
|
3414
|
+
if (value instanceof IDBCursor) {
|
|
3415
|
+
cursorRequestMap.set(value, request);
|
|
3416
|
+
}
|
|
3417
|
+
// Catching to avoid "Uncaught Promise exceptions"
|
|
3418
|
+
})
|
|
3419
|
+
.catch(() => { });
|
|
3420
|
+
// This mapping exists in reverseTransformCache but doesn't doesn't exist in transformCache. This
|
|
3421
|
+
// is because we create many promises from a single IDBRequest.
|
|
3422
|
+
reverseTransformCache.set(promise, request);
|
|
3423
|
+
return promise;
|
|
3424
|
+
}
|
|
3425
|
+
function cacheDonePromiseForTransaction(tx) {
|
|
3426
|
+
// Early bail if we've already created a done promise for this transaction.
|
|
3427
|
+
if (transactionDoneMap.has(tx))
|
|
3428
|
+
return;
|
|
3429
|
+
const done = new Promise((resolve, reject) => {
|
|
3430
|
+
const unlisten = () => {
|
|
3431
|
+
tx.removeEventListener('complete', complete);
|
|
3432
|
+
tx.removeEventListener('error', error);
|
|
3433
|
+
tx.removeEventListener('abort', error);
|
|
3434
|
+
};
|
|
3435
|
+
const complete = () => {
|
|
3436
|
+
resolve();
|
|
3437
|
+
unlisten();
|
|
3438
|
+
};
|
|
3439
|
+
const error = () => {
|
|
3440
|
+
reject(tx.error || new DOMException('AbortError', 'AbortError'));
|
|
3441
|
+
unlisten();
|
|
3442
|
+
};
|
|
3443
|
+
tx.addEventListener('complete', complete);
|
|
3444
|
+
tx.addEventListener('error', error);
|
|
3445
|
+
tx.addEventListener('abort', error);
|
|
3446
|
+
});
|
|
3447
|
+
// Cache it for later retrieval.
|
|
3448
|
+
transactionDoneMap.set(tx, done);
|
|
3449
|
+
}
|
|
3450
|
+
let idbProxyTraps = {
|
|
3451
|
+
get(target, prop, receiver) {
|
|
3452
|
+
if (target instanceof IDBTransaction) {
|
|
3453
|
+
// Special handling for transaction.done.
|
|
3454
|
+
if (prop === 'done')
|
|
3455
|
+
return transactionDoneMap.get(target);
|
|
3456
|
+
// Polyfill for objectStoreNames because of Edge.
|
|
3457
|
+
if (prop === 'objectStoreNames') {
|
|
3458
|
+
return target.objectStoreNames || transactionStoreNamesMap.get(target);
|
|
3459
|
+
}
|
|
3460
|
+
// Make tx.store return the only store in the transaction, or undefined if there are many.
|
|
3461
|
+
if (prop === 'store') {
|
|
3462
|
+
return receiver.objectStoreNames[1]
|
|
3463
|
+
? undefined
|
|
3464
|
+
: receiver.objectStore(receiver.objectStoreNames[0]);
|
|
3465
|
+
}
|
|
3466
|
+
}
|
|
3467
|
+
// Else transform whatever we get back.
|
|
3468
|
+
return wrap(target[prop]);
|
|
3469
|
+
},
|
|
3470
|
+
set(target, prop, value) {
|
|
3471
|
+
target[prop] = value;
|
|
3472
|
+
return true;
|
|
3473
|
+
},
|
|
3474
|
+
has(target, prop) {
|
|
3475
|
+
if (target instanceof IDBTransaction &&
|
|
3476
|
+
(prop === 'done' || prop === 'store')) {
|
|
3477
|
+
return true;
|
|
3478
|
+
}
|
|
3479
|
+
return prop in target;
|
|
3480
|
+
},
|
|
3481
|
+
};
|
|
3482
|
+
function replaceTraps(callback) {
|
|
3483
|
+
idbProxyTraps = callback(idbProxyTraps);
|
|
3484
|
+
}
|
|
3485
|
+
function wrapFunction(func) {
|
|
3486
|
+
// Due to expected object equality (which is enforced by the caching in `wrap`), we
|
|
3487
|
+
// only create one new func per func.
|
|
3488
|
+
// Edge doesn't support objectStoreNames (booo), so we polyfill it here.
|
|
3489
|
+
if (func === IDBDatabase.prototype.transaction &&
|
|
3490
|
+
!('objectStoreNames' in IDBTransaction.prototype)) {
|
|
3491
|
+
return function (storeNames, ...args) {
|
|
3492
|
+
const tx = func.call(unwrap(this), storeNames, ...args);
|
|
3493
|
+
transactionStoreNamesMap.set(tx, storeNames.sort ? storeNames.sort() : [storeNames]);
|
|
3494
|
+
return wrap(tx);
|
|
3495
|
+
};
|
|
3496
|
+
}
|
|
3497
|
+
// Cursor methods are special, as the behaviour is a little more different to standard IDB. In
|
|
3498
|
+
// IDB, you advance the cursor and wait for a new 'success' on the IDBRequest that gave you the
|
|
3499
|
+
// cursor. It's kinda like a promise that can resolve with many values. That doesn't make sense
|
|
3500
|
+
// with real promises, so each advance methods returns a new promise for the cursor object, or
|
|
3501
|
+
// undefined if the end of the cursor has been reached.
|
|
3502
|
+
if (getCursorAdvanceMethods().includes(func)) {
|
|
3503
|
+
return function (...args) {
|
|
3504
|
+
// Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
|
|
3505
|
+
// the original object.
|
|
3506
|
+
func.apply(unwrap(this), args);
|
|
3507
|
+
return wrap(cursorRequestMap.get(this));
|
|
3508
|
+
};
|
|
3509
|
+
}
|
|
3510
|
+
return function (...args) {
|
|
3511
|
+
// Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
|
|
3512
|
+
// the original object.
|
|
3513
|
+
return wrap(func.apply(unwrap(this), args));
|
|
3514
|
+
};
|
|
3515
|
+
}
|
|
3516
|
+
function transformCachableValue(value) {
|
|
3517
|
+
if (typeof value === 'function')
|
|
3518
|
+
return wrapFunction(value);
|
|
3519
|
+
// This doesn't return, it just creates a 'done' promise for the transaction,
|
|
3520
|
+
// which is later returned for transaction.done (see idbObjectHandler).
|
|
3521
|
+
if (value instanceof IDBTransaction)
|
|
3522
|
+
cacheDonePromiseForTransaction(value);
|
|
3523
|
+
if (instanceOfAny(value, getIdbProxyableTypes()))
|
|
3524
|
+
return new Proxy(value, idbProxyTraps);
|
|
3525
|
+
// Return the same value back if we're not going to transform it.
|
|
3526
|
+
return value;
|
|
3527
|
+
}
|
|
3528
|
+
function wrap(value) {
|
|
3529
|
+
// We sometimes generate multiple promises from a single IDBRequest (eg when cursoring), because
|
|
3530
|
+
// IDB is weird and a single IDBRequest can yield many responses, so these can't be cached.
|
|
3531
|
+
if (value instanceof IDBRequest)
|
|
3532
|
+
return promisifyRequest(value);
|
|
3533
|
+
// If we've already transformed this value before, reuse the transformed value.
|
|
3534
|
+
// This is faster, but it also provides object equality.
|
|
3535
|
+
if (transformCache.has(value))
|
|
3536
|
+
return transformCache.get(value);
|
|
3537
|
+
const newValue = transformCachableValue(value);
|
|
3538
|
+
// Not all types are transformed.
|
|
3539
|
+
// These may be primitive types, so they can't be WeakMap keys.
|
|
3540
|
+
if (newValue !== value) {
|
|
3541
|
+
transformCache.set(value, newValue);
|
|
3542
|
+
reverseTransformCache.set(newValue, value);
|
|
3543
|
+
}
|
|
3544
|
+
return newValue;
|
|
3545
|
+
}
|
|
3546
|
+
const unwrap = (value) => reverseTransformCache.get(value);
|
|
3547
|
+
|
|
3548
|
+
/**
|
|
3549
|
+
* Open a database.
|
|
3550
|
+
*
|
|
3551
|
+
* @param name Name of the database.
|
|
3552
|
+
* @param version Schema version.
|
|
3553
|
+
* @param callbacks Additional callbacks.
|
|
3554
|
+
*/
|
|
3555
|
+
function openDB(name, version, { blocked, upgrade, blocking, terminated } = {}) {
|
|
3556
|
+
const request = indexedDB.open(name, version);
|
|
3557
|
+
const openPromise = wrap(request);
|
|
3558
|
+
if (upgrade) {
|
|
3559
|
+
request.addEventListener('upgradeneeded', (event) => {
|
|
3560
|
+
upgrade(wrap(request.result), event.oldVersion, event.newVersion, wrap(request.transaction), event);
|
|
3561
|
+
});
|
|
3562
|
+
}
|
|
3563
|
+
if (blocked) {
|
|
3564
|
+
request.addEventListener('blocked', (event) => blocked(
|
|
3565
|
+
// Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405
|
|
3566
|
+
event.oldVersion, event.newVersion, event));
|
|
3567
|
+
}
|
|
3568
|
+
openPromise
|
|
3569
|
+
.then((db) => {
|
|
3570
|
+
if (terminated)
|
|
3571
|
+
db.addEventListener('close', () => terminated());
|
|
3572
|
+
if (blocking) {
|
|
3573
|
+
db.addEventListener('versionchange', (event) => blocking(event.oldVersion, event.newVersion, event));
|
|
3574
|
+
}
|
|
3575
|
+
})
|
|
3576
|
+
.catch(() => { });
|
|
3577
|
+
return openPromise;
|
|
3578
|
+
}
|
|
3579
|
+
/**
|
|
3580
|
+
* Delete a database.
|
|
3581
|
+
*
|
|
3582
|
+
* @param name Name of the database.
|
|
3583
|
+
*/
|
|
3584
|
+
function deleteDB(name, { blocked } = {}) {
|
|
3585
|
+
const request = indexedDB.deleteDatabase(name);
|
|
3586
|
+
if (blocked) {
|
|
3587
|
+
request.addEventListener('blocked', (event) => blocked(
|
|
3588
|
+
// Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405
|
|
3589
|
+
event.oldVersion, event));
|
|
3590
|
+
}
|
|
3591
|
+
return wrap(request).then(() => undefined);
|
|
3592
|
+
}
|
|
3593
|
+
|
|
3594
|
+
const readMethods = ['get', 'getKey', 'getAll', 'getAllKeys', 'count'];
|
|
3595
|
+
const writeMethods = ['put', 'add', 'delete', 'clear'];
|
|
3596
|
+
const cachedMethods = new Map();
|
|
3597
|
+
function getMethod(target, prop) {
|
|
3598
|
+
if (!(target instanceof IDBDatabase &&
|
|
3599
|
+
!(prop in target) &&
|
|
3600
|
+
typeof prop === 'string')) {
|
|
3601
|
+
return;
|
|
3602
|
+
}
|
|
3603
|
+
if (cachedMethods.get(prop))
|
|
3604
|
+
return cachedMethods.get(prop);
|
|
3605
|
+
const targetFuncName = prop.replace(/FromIndex$/, '');
|
|
3606
|
+
const useIndex = prop !== targetFuncName;
|
|
3607
|
+
const isWrite = writeMethods.includes(targetFuncName);
|
|
3608
|
+
if (
|
|
3609
|
+
// Bail if the target doesn't exist on the target. Eg, getAll isn't in Edge.
|
|
3610
|
+
!(targetFuncName in (useIndex ? IDBIndex : IDBObjectStore).prototype) ||
|
|
3611
|
+
!(isWrite || readMethods.includes(targetFuncName))) {
|
|
3612
|
+
return;
|
|
3613
|
+
}
|
|
3614
|
+
const method = async function (storeName, ...args) {
|
|
3615
|
+
// isWrite ? 'readwrite' : undefined gzipps better, but fails in Edge :(
|
|
3616
|
+
const tx = this.transaction(storeName, isWrite ? 'readwrite' : 'readonly');
|
|
3617
|
+
let target = tx.store;
|
|
3618
|
+
if (useIndex)
|
|
3619
|
+
target = target.index(args.shift());
|
|
3620
|
+
// Must reject if op rejects.
|
|
3621
|
+
// If it's a write operation, must reject if tx.done rejects.
|
|
3622
|
+
// Must reject with op rejection first.
|
|
3623
|
+
// Must resolve with op value.
|
|
3624
|
+
// Must handle both promises (no unhandled rejections)
|
|
3625
|
+
return (await Promise.all([
|
|
3626
|
+
target[targetFuncName](...args),
|
|
3627
|
+
isWrite && tx.done,
|
|
3628
|
+
]))[0];
|
|
3629
|
+
};
|
|
3630
|
+
cachedMethods.set(prop, method);
|
|
3631
|
+
return method;
|
|
3632
|
+
}
|
|
3633
|
+
replaceTraps((oldTraps) => ({
|
|
3634
|
+
...oldTraps,
|
|
3635
|
+
get: (target, prop, receiver) => getMethod(target, prop) || oldTraps.get(target, prop, receiver),
|
|
3636
|
+
has: (target, prop) => !!getMethod(target, prop) || oldTraps.has(target, prop),
|
|
3637
|
+
}));
|
|
3638
|
+
|
|
3639
|
+
var build = /*#__PURE__*/Object.freeze({
|
|
3640
|
+
__proto__: null,
|
|
3641
|
+
deleteDB: deleteDB,
|
|
3642
|
+
openDB: openDB,
|
|
3643
|
+
unwrap: unwrap,
|
|
3644
|
+
wrap: wrap
|
|
3645
|
+
});
|
|
3646
|
+
|
|
3647
|
+
var require$$3 = /*@__PURE__*/getAugmentedNamespace(build);
|
|
3648
|
+
|
|
3649
|
+
(function (exports) {
|
|
3650
|
+
|
|
3651
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3652
|
+
|
|
3653
|
+
var component = require$$0$2;
|
|
3654
|
+
var logger$1 = require$$1$3;
|
|
3655
|
+
var util = require$$2$3;
|
|
3656
|
+
var idb = require$$3;
|
|
3657
|
+
|
|
3658
|
+
/**
|
|
3659
|
+
* @license
|
|
3660
|
+
* Copyright 2019 Google LLC
|
|
3661
|
+
*
|
|
3662
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3663
|
+
* you may not use this file except in compliance with the License.
|
|
3664
|
+
* You may obtain a copy of the License at
|
|
3665
|
+
*
|
|
3666
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3667
|
+
*
|
|
3668
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3669
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3670
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3671
|
+
* See the License for the specific language governing permissions and
|
|
3672
|
+
* limitations under the License.
|
|
3673
|
+
*/
|
|
3674
|
+
class PlatformLoggerServiceImpl {
|
|
3675
|
+
constructor(container) {
|
|
3676
|
+
this.container = container;
|
|
3677
|
+
}
|
|
3678
|
+
// In initial implementation, this will be called by installations on
|
|
3679
|
+
// auth token refresh, and installations will send this string.
|
|
3680
|
+
getPlatformInfoString() {
|
|
3681
|
+
const providers = this.container.getProviders();
|
|
3682
|
+
// Loop through providers and get library/version pairs from any that are
|
|
3683
|
+
// version components.
|
|
3684
|
+
return providers
|
|
3685
|
+
.map(provider => {
|
|
3686
|
+
if (isVersionServiceProvider(provider)) {
|
|
3687
|
+
const service = provider.getImmediate();
|
|
3688
|
+
return `${service.library}/${service.version}`;
|
|
3689
|
+
}
|
|
3690
|
+
else {
|
|
3691
|
+
return null;
|
|
3692
|
+
}
|
|
3693
|
+
})
|
|
3694
|
+
.filter(logString => logString)
|
|
3695
|
+
.join(' ');
|
|
3696
|
+
}
|
|
3697
|
+
}
|
|
3698
|
+
/**
|
|
3699
|
+
*
|
|
3700
|
+
* @param provider check if this provider provides a VersionService
|
|
3701
|
+
*
|
|
3702
|
+
* NOTE: Using Provider<'app-version'> is a hack to indicate that the provider
|
|
3703
|
+
* provides VersionService. The provider is not necessarily a 'app-version'
|
|
3704
|
+
* provider.
|
|
3705
|
+
*/
|
|
3706
|
+
function isVersionServiceProvider(provider) {
|
|
3707
|
+
const component = provider.getComponent();
|
|
3708
|
+
return component?.type === "VERSION" /* ComponentType.VERSION */;
|
|
3709
|
+
}
|
|
3710
|
+
|
|
3711
|
+
const name$q = "@firebase/app";
|
|
3712
|
+
const version$1 = "0.16.0";
|
|
3713
|
+
|
|
3714
|
+
/**
|
|
3715
|
+
* @license
|
|
3716
|
+
* Copyright 2019 Google LLC
|
|
3717
|
+
*
|
|
3718
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3719
|
+
* you may not use this file except in compliance with the License.
|
|
3720
|
+
* You may obtain a copy of the License at
|
|
3721
|
+
*
|
|
3722
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3723
|
+
*
|
|
3724
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3725
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3726
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3727
|
+
* See the License for the specific language governing permissions and
|
|
3728
|
+
* limitations under the License.
|
|
3729
|
+
*/
|
|
3730
|
+
const logger = new logger$1.Logger('@firebase/app');
|
|
3731
|
+
|
|
3732
|
+
const name$p = "@firebase/app-compat";
|
|
3733
|
+
|
|
3734
|
+
const name$o = "@firebase/analytics-compat";
|
|
3735
|
+
|
|
3736
|
+
const name$n = "@firebase/analytics";
|
|
3737
|
+
|
|
3738
|
+
const name$m = "@firebase/app-check-compat";
|
|
3739
|
+
|
|
3740
|
+
const name$l = "@firebase/app-check";
|
|
3741
|
+
|
|
3742
|
+
const name$k = "@firebase/auth";
|
|
3743
|
+
|
|
3744
|
+
const name$j = "@firebase/auth-compat";
|
|
3745
|
+
|
|
3746
|
+
const name$i = "@firebase/database";
|
|
3747
|
+
|
|
3748
|
+
const name$h = "@firebase/data-connect";
|
|
3749
|
+
|
|
3750
|
+
const name$g = "@firebase/database-compat";
|
|
3751
|
+
|
|
3752
|
+
const name$f = "@firebase/functions";
|
|
3753
|
+
|
|
3754
|
+
const name$e = "@firebase/functions-compat";
|
|
3755
|
+
|
|
3756
|
+
const name$d = "@firebase/installations";
|
|
3757
|
+
|
|
3758
|
+
const name$c = "@firebase/installations-compat";
|
|
3759
|
+
|
|
3760
|
+
const name$b = "@firebase/messaging";
|
|
3761
|
+
|
|
3762
|
+
const name$a = "@firebase/messaging-compat";
|
|
3763
|
+
|
|
3764
|
+
const name$9 = "@firebase/performance";
|
|
3765
|
+
|
|
3766
|
+
const name$8 = "@firebase/performance-compat";
|
|
3767
|
+
|
|
3768
|
+
const name$7 = "@firebase/remote-config";
|
|
3769
|
+
|
|
3770
|
+
const name$6 = "@firebase/remote-config-compat";
|
|
3771
|
+
|
|
3772
|
+
const name$5 = "@firebase/storage";
|
|
3773
|
+
|
|
3774
|
+
const name$4 = "@firebase/storage-compat";
|
|
3775
|
+
|
|
3776
|
+
const name$3 = "@firebase/firestore";
|
|
3777
|
+
|
|
3778
|
+
const name$2 = "@firebase/ai";
|
|
3779
|
+
|
|
3780
|
+
const name$1 = "@firebase/firestore-compat";
|
|
3781
|
+
|
|
3782
|
+
const name = "firebase";
|
|
3783
|
+
const version = "12.17.1";
|
|
3784
|
+
|
|
3785
|
+
/**
|
|
3786
|
+
* @license
|
|
3787
|
+
* Copyright 2019 Google LLC
|
|
3788
|
+
*
|
|
3789
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3790
|
+
* you may not use this file except in compliance with the License.
|
|
3791
|
+
* You may obtain a copy of the License at
|
|
3792
|
+
*
|
|
3793
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3794
|
+
*
|
|
3795
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3796
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3797
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3798
|
+
* See the License for the specific language governing permissions and
|
|
3799
|
+
* limitations under the License.
|
|
3800
|
+
*/
|
|
3801
|
+
/**
|
|
3802
|
+
* The default app name
|
|
3803
|
+
*
|
|
3804
|
+
* @internal
|
|
3805
|
+
*/
|
|
3806
|
+
const DEFAULT_ENTRY_NAME = '[DEFAULT]';
|
|
3807
|
+
const PLATFORM_LOG_STRING = {
|
|
3808
|
+
[name$q]: 'fire-core',
|
|
3809
|
+
[name$p]: 'fire-core-compat',
|
|
3810
|
+
[name$n]: 'fire-analytics',
|
|
3811
|
+
[name$o]: 'fire-analytics-compat',
|
|
3812
|
+
[name$l]: 'fire-app-check',
|
|
3813
|
+
[name$m]: 'fire-app-check-compat',
|
|
3814
|
+
[name$k]: 'fire-auth',
|
|
3815
|
+
[name$j]: 'fire-auth-compat',
|
|
3816
|
+
[name$i]: 'fire-rtdb',
|
|
3817
|
+
[name$h]: 'fire-data-connect',
|
|
3818
|
+
[name$g]: 'fire-rtdb-compat',
|
|
3819
|
+
[name$f]: 'fire-fn',
|
|
3820
|
+
[name$e]: 'fire-fn-compat',
|
|
3821
|
+
[name$d]: 'fire-iid',
|
|
3822
|
+
[name$c]: 'fire-iid-compat',
|
|
3823
|
+
[name$b]: 'fire-fcm',
|
|
3824
|
+
[name$a]: 'fire-fcm-compat',
|
|
3825
|
+
[name$9]: 'fire-perf',
|
|
3826
|
+
[name$8]: 'fire-perf-compat',
|
|
3827
|
+
[name$7]: 'fire-rc',
|
|
3828
|
+
[name$6]: 'fire-rc-compat',
|
|
3829
|
+
[name$5]: 'fire-gcs',
|
|
3830
|
+
[name$4]: 'fire-gcs-compat',
|
|
3831
|
+
[name$3]: 'fire-fst',
|
|
3832
|
+
[name$1]: 'fire-fst-compat',
|
|
3833
|
+
[name$2]: 'fire-vertex',
|
|
3834
|
+
'fire-js': 'fire-js', // Platform identifier for JS SDK.
|
|
3835
|
+
[name]: 'fire-js-all'
|
|
3836
|
+
};
|
|
3837
|
+
|
|
3838
|
+
/**
|
|
3839
|
+
* @license
|
|
3840
|
+
* Copyright 2019 Google LLC
|
|
3841
|
+
*
|
|
3842
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3843
|
+
* you may not use this file except in compliance with the License.
|
|
3844
|
+
* You may obtain a copy of the License at
|
|
3845
|
+
*
|
|
3846
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3847
|
+
*
|
|
3848
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3849
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3850
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3851
|
+
* See the License for the specific language governing permissions and
|
|
3852
|
+
* limitations under the License.
|
|
3853
|
+
*/
|
|
3854
|
+
/**
|
|
3855
|
+
* @internal
|
|
3856
|
+
*/
|
|
3857
|
+
const _apps = new Map();
|
|
3858
|
+
/**
|
|
3859
|
+
* @internal
|
|
3860
|
+
*/
|
|
3861
|
+
const _serverApps = new Map();
|
|
3862
|
+
/**
|
|
3863
|
+
* Registered components.
|
|
3864
|
+
*
|
|
3865
|
+
* @internal
|
|
3866
|
+
*/
|
|
3867
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3868
|
+
const _components = new Map();
|
|
3869
|
+
/**
|
|
3870
|
+
* @param component - the component being added to this app's container
|
|
3871
|
+
*
|
|
3872
|
+
* @internal
|
|
3873
|
+
*/
|
|
3874
|
+
function _addComponent(app, component) {
|
|
3875
|
+
try {
|
|
3876
|
+
app.container.addComponent(component);
|
|
3877
|
+
}
|
|
3878
|
+
catch (e) {
|
|
3879
|
+
logger.debug(`Component ${component.name} failed to register with FirebaseApp ${app.name}`, e);
|
|
3880
|
+
}
|
|
3881
|
+
}
|
|
3882
|
+
/**
|
|
3883
|
+
*
|
|
3884
|
+
* @internal
|
|
3885
|
+
*/
|
|
3886
|
+
function _addOrOverwriteComponent(app, component) {
|
|
3887
|
+
app.container.addOrOverwriteComponent(component);
|
|
3888
|
+
}
|
|
3889
|
+
/**
|
|
3890
|
+
*
|
|
3891
|
+
* @param component - the component to register
|
|
3892
|
+
* @returns whether or not the component is registered successfully
|
|
3893
|
+
*
|
|
3894
|
+
* @internal
|
|
3895
|
+
*/
|
|
3896
|
+
function _registerComponent(component) {
|
|
3897
|
+
const componentName = component.name;
|
|
3898
|
+
if (_components.has(componentName)) {
|
|
3899
|
+
logger.debug(`There were multiple attempts to register component ${componentName}.`);
|
|
3900
|
+
return false;
|
|
3901
|
+
}
|
|
3902
|
+
_components.set(componentName, component);
|
|
3903
|
+
// add the component to existing app instances
|
|
3904
|
+
for (const app of _apps.values()) {
|
|
3905
|
+
_addComponent(app, component);
|
|
3906
|
+
}
|
|
3907
|
+
for (const serverApp of _serverApps.values()) {
|
|
3908
|
+
_addComponent(serverApp, component);
|
|
3909
|
+
}
|
|
3910
|
+
return true;
|
|
3911
|
+
}
|
|
3912
|
+
/**
|
|
3913
|
+
*
|
|
3914
|
+
* @param app - FirebaseApp instance
|
|
3915
|
+
* @param name - service name
|
|
3916
|
+
*
|
|
3917
|
+
* @returns the provider for the service with the matching name
|
|
3918
|
+
*
|
|
3919
|
+
* @internal
|
|
3920
|
+
*/
|
|
3921
|
+
function _getProvider(app, name) {
|
|
3922
|
+
const heartbeatController = app.container
|
|
3923
|
+
.getProvider('heartbeat')
|
|
3924
|
+
.getImmediate({ optional: true });
|
|
3925
|
+
if (heartbeatController) {
|
|
3926
|
+
void heartbeatController.triggerHeartbeat();
|
|
3927
|
+
}
|
|
3928
|
+
return app.container.getProvider(name);
|
|
3929
|
+
}
|
|
3930
|
+
/**
|
|
3931
|
+
*
|
|
3932
|
+
* @param app - FirebaseApp instance
|
|
3933
|
+
* @param name - service name
|
|
3934
|
+
* @param instanceIdentifier - service instance identifier in case the service supports multiple instances
|
|
3935
|
+
*
|
|
3936
|
+
* @internal
|
|
3937
|
+
*/
|
|
3938
|
+
function _removeServiceInstance(app, name, instanceIdentifier = DEFAULT_ENTRY_NAME) {
|
|
3939
|
+
_getProvider(app, name).clearInstance(instanceIdentifier);
|
|
3940
|
+
}
|
|
3941
|
+
/**
|
|
3942
|
+
*
|
|
3943
|
+
* @param obj - an object of type FirebaseApp, FirebaseOptions or FirebaseAppSettings.
|
|
3944
|
+
*
|
|
3945
|
+
* @returns true if the provide object is of type FirebaseApp.
|
|
3946
|
+
*
|
|
3947
|
+
* @internal
|
|
3948
|
+
*/
|
|
3949
|
+
function _isFirebaseApp(obj) {
|
|
3950
|
+
return obj.options !== undefined;
|
|
3951
|
+
}
|
|
3952
|
+
/**
|
|
3953
|
+
*
|
|
3954
|
+
* @param obj - an object of type FirebaseApp, FirebaseOptions or FirebaseAppSettings.
|
|
3955
|
+
*
|
|
3956
|
+
* @returns true if the provided object is of type FirebaseServerAppImpl.
|
|
3957
|
+
*
|
|
3958
|
+
* @internal
|
|
3959
|
+
*/
|
|
3960
|
+
function _isFirebaseServerAppSettings(obj) {
|
|
3961
|
+
if (_isFirebaseApp(obj)) {
|
|
3962
|
+
return false;
|
|
3963
|
+
}
|
|
3964
|
+
return ('authIdToken' in obj ||
|
|
3965
|
+
'appCheckToken' in obj ||
|
|
3966
|
+
'releaseOnDeref' in obj ||
|
|
3967
|
+
'automaticDataCollectionEnabled' in obj);
|
|
3968
|
+
}
|
|
3969
|
+
/**
|
|
3970
|
+
*
|
|
3971
|
+
* @param obj - an object of type FirebaseApp.
|
|
3972
|
+
*
|
|
3973
|
+
* @returns true if the provided object is of type FirebaseServerAppImpl.
|
|
3974
|
+
*
|
|
3975
|
+
* @internal
|
|
3976
|
+
*/
|
|
3977
|
+
function _isFirebaseServerApp(obj) {
|
|
3978
|
+
if (obj === null || obj === undefined) {
|
|
3979
|
+
return false;
|
|
3980
|
+
}
|
|
3981
|
+
return obj.settings !== undefined;
|
|
3982
|
+
}
|
|
3983
|
+
/**
|
|
3984
|
+
* Test only
|
|
3985
|
+
*
|
|
3986
|
+
* @internal
|
|
3987
|
+
*/
|
|
3988
|
+
function _clearComponents() {
|
|
3989
|
+
_components.clear();
|
|
3990
|
+
}
|
|
3991
|
+
|
|
3992
|
+
/**
|
|
3993
|
+
* @license
|
|
3994
|
+
* Copyright 2019 Google LLC
|
|
3995
|
+
*
|
|
3996
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3997
|
+
* you may not use this file except in compliance with the License.
|
|
3998
|
+
* You may obtain a copy of the License at
|
|
3999
|
+
*
|
|
4000
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4001
|
+
*
|
|
4002
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
4003
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4004
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4005
|
+
* See the License for the specific language governing permissions and
|
|
4006
|
+
* limitations under the License.
|
|
4007
|
+
*/
|
|
4008
|
+
const ERRORS = {
|
|
4009
|
+
["no-app" /* AppError.NO_APP */]: "No Firebase App '{$appName}' has been created - " +
|
|
4010
|
+
'call initializeApp() first',
|
|
4011
|
+
["bad-app-name" /* AppError.BAD_APP_NAME */]: "Illegal App name: '{$appName}'",
|
|
4012
|
+
["duplicate-app" /* AppError.DUPLICATE_APP */]: "Firebase App named '{$appName}' already exists with different {$mismatchedParam}." +
|
|
4013
|
+
" Existing: '{$oldValue}'. New: '{$newValue}'.",
|
|
4014
|
+
["app-deleted" /* AppError.APP_DELETED */]: "Firebase App named '{$appName}' already deleted",
|
|
4015
|
+
["server-app-deleted" /* AppError.SERVER_APP_DELETED */]: 'Firebase Server App has been deleted',
|
|
4016
|
+
["no-options" /* AppError.NO_OPTIONS */]: 'Need to provide options, when not being deployed to hosting via source.',
|
|
4017
|
+
["invalid-app-argument" /* AppError.INVALID_APP_ARGUMENT */]: 'firebase.{$appName}() takes either no argument or a ' +
|
|
4018
|
+
'Firebase App instance.',
|
|
4019
|
+
["invalid-log-argument" /* AppError.INVALID_LOG_ARGUMENT */]: 'First argument to `onLog` must be null or a function.',
|
|
4020
|
+
["idb-open" /* AppError.IDB_OPEN */]: 'Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.',
|
|
4021
|
+
["idb-get" /* AppError.IDB_GET */]: 'Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.',
|
|
4022
|
+
["idb-set" /* AppError.IDB_WRITE */]: 'Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.',
|
|
4023
|
+
["idb-delete" /* AppError.IDB_DELETE */]: 'Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.',
|
|
4024
|
+
["finalization-registry-not-supported" /* AppError.FINALIZATION_REGISTRY_NOT_SUPPORTED */]: 'FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.',
|
|
4025
|
+
["invalid-server-app-environment" /* AppError.INVALID_SERVER_APP_ENVIRONMENT */]: 'FirebaseServerApp is not for use in browser environments.'
|
|
4026
|
+
};
|
|
4027
|
+
const ERROR_FACTORY = new util.ErrorFactory('app', 'Firebase', ERRORS);
|
|
4028
|
+
|
|
4029
|
+
/**
|
|
4030
|
+
* @license
|
|
4031
|
+
* Copyright 2019 Google LLC
|
|
4032
|
+
*
|
|
4033
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4034
|
+
* you may not use this file except in compliance with the License.
|
|
4035
|
+
* You may obtain a copy of the License at
|
|
4036
|
+
*
|
|
4037
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4038
|
+
*
|
|
4039
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
4040
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4041
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4042
|
+
* See the License for the specific language governing permissions and
|
|
4043
|
+
* limitations under the License.
|
|
4044
|
+
*/
|
|
4045
|
+
class FirebaseAppImpl {
|
|
4046
|
+
constructor(options, config, container) {
|
|
4047
|
+
this._isDeleted = false;
|
|
4048
|
+
this._options = { ...options };
|
|
4049
|
+
this._config = { ...config };
|
|
4050
|
+
this._name = config.name;
|
|
4051
|
+
this._automaticDataCollectionEnabled =
|
|
4052
|
+
config.automaticDataCollectionEnabled;
|
|
4053
|
+
this._container = container;
|
|
4054
|
+
this.container.addComponent(new component.Component('app', () => this, "PUBLIC" /* ComponentType.PUBLIC */));
|
|
4055
|
+
}
|
|
4056
|
+
get automaticDataCollectionEnabled() {
|
|
4057
|
+
this.checkDestroyed();
|
|
4058
|
+
return this._automaticDataCollectionEnabled;
|
|
4059
|
+
}
|
|
4060
|
+
set automaticDataCollectionEnabled(val) {
|
|
4061
|
+
this.checkDestroyed();
|
|
4062
|
+
this._automaticDataCollectionEnabled = val;
|
|
4063
|
+
}
|
|
4064
|
+
get name() {
|
|
4065
|
+
this.checkDestroyed();
|
|
4066
|
+
return this._name;
|
|
4067
|
+
}
|
|
4068
|
+
get options() {
|
|
4069
|
+
this.checkDestroyed();
|
|
4070
|
+
return this._options;
|
|
4071
|
+
}
|
|
4072
|
+
get config() {
|
|
4073
|
+
this.checkDestroyed();
|
|
4074
|
+
return this._config;
|
|
4075
|
+
}
|
|
4076
|
+
get container() {
|
|
4077
|
+
return this._container;
|
|
4078
|
+
}
|
|
4079
|
+
get isDeleted() {
|
|
4080
|
+
return this._isDeleted;
|
|
4081
|
+
}
|
|
4082
|
+
set isDeleted(val) {
|
|
4083
|
+
this._isDeleted = val;
|
|
4084
|
+
}
|
|
4085
|
+
/**
|
|
4086
|
+
* This function will throw an Error if the App has already been deleted -
|
|
4087
|
+
* use before performing API actions on the App.
|
|
4088
|
+
*/
|
|
4089
|
+
checkDestroyed() {
|
|
4090
|
+
if (this.isDeleted) {
|
|
4091
|
+
throw ERROR_FACTORY.create("app-deleted" /* AppError.APP_DELETED */, { appName: this._name });
|
|
4092
|
+
}
|
|
4093
|
+
}
|
|
4094
|
+
}
|
|
4095
|
+
|
|
4096
|
+
/**
|
|
4097
|
+
* @license
|
|
4098
|
+
* Copyright 2023 Google LLC
|
|
4099
|
+
*
|
|
4100
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4101
|
+
* you may not use this file except in compliance with the License.
|
|
4102
|
+
* You may obtain a copy of the License at
|
|
4103
|
+
*
|
|
4104
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4105
|
+
*
|
|
4106
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
4107
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4108
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4109
|
+
* See the License for the specific language governing permissions and
|
|
4110
|
+
* limitations under the License.
|
|
4111
|
+
*/
|
|
4112
|
+
// Parse the token and check to see if the `exp` claim is in the future.
|
|
4113
|
+
// Reports an error to the console if the token or claim could not be parsed, or if `exp` is in
|
|
4114
|
+
// the past.
|
|
4115
|
+
function validateTokenTTL(base64Token, tokenName) {
|
|
4116
|
+
const secondPart = util.base64Decode(base64Token.split('.')[1]);
|
|
4117
|
+
if (secondPart === null) {
|
|
4118
|
+
console.error(`FirebaseServerApp ${tokenName} is invalid: second part could not be parsed.`);
|
|
4119
|
+
return;
|
|
4120
|
+
}
|
|
4121
|
+
const expClaim = JSON.parse(secondPart).exp;
|
|
4122
|
+
if (expClaim === undefined) {
|
|
4123
|
+
console.error(`FirebaseServerApp ${tokenName} is invalid: expiration claim could not be parsed`);
|
|
4124
|
+
return;
|
|
4125
|
+
}
|
|
4126
|
+
const exp = JSON.parse(secondPart).exp * 1000;
|
|
4127
|
+
const now = new Date().getTime();
|
|
4128
|
+
const diff = exp - now;
|
|
4129
|
+
if (diff <= 0) {
|
|
4130
|
+
console.error(`FirebaseServerApp ${tokenName} is invalid: the token has expired.`);
|
|
4131
|
+
}
|
|
4132
|
+
}
|
|
4133
|
+
class FirebaseServerAppImpl extends FirebaseAppImpl {
|
|
4134
|
+
constructor(options, serverConfig, name, container) {
|
|
4135
|
+
// Build configuration parameters for the FirebaseAppImpl base class.
|
|
4136
|
+
const automaticDataCollectionEnabled = serverConfig.automaticDataCollectionEnabled !== undefined
|
|
4137
|
+
? serverConfig.automaticDataCollectionEnabled
|
|
4138
|
+
: true;
|
|
4139
|
+
// Create the FirebaseAppSettings object for the FirebaseAppImp constructor.
|
|
4140
|
+
const config = {
|
|
4141
|
+
name,
|
|
4142
|
+
automaticDataCollectionEnabled
|
|
4143
|
+
};
|
|
4144
|
+
if (options.apiKey !== undefined) {
|
|
4145
|
+
// Construct the parent FirebaseAppImp object.
|
|
4146
|
+
super(options, config, container);
|
|
4147
|
+
}
|
|
4148
|
+
else {
|
|
4149
|
+
const appImpl = options;
|
|
4150
|
+
super(appImpl.options, config, container);
|
|
4151
|
+
}
|
|
4152
|
+
// Now construct the data for the FirebaseServerAppImpl.
|
|
4153
|
+
this._serverConfig = {
|
|
4154
|
+
automaticDataCollectionEnabled,
|
|
4155
|
+
...serverConfig
|
|
4156
|
+
};
|
|
4157
|
+
// Ensure that the current time is within the `authIdtoken` window of validity.
|
|
4158
|
+
if (this._serverConfig.authIdToken) {
|
|
4159
|
+
validateTokenTTL(this._serverConfig.authIdToken, 'authIdToken');
|
|
4160
|
+
}
|
|
4161
|
+
// Ensure that the current time is within the `appCheckToken` window of validity.
|
|
4162
|
+
if (this._serverConfig.appCheckToken) {
|
|
4163
|
+
validateTokenTTL(this._serverConfig.appCheckToken, 'appCheckToken');
|
|
4164
|
+
}
|
|
4165
|
+
this._finalizationRegistry = null;
|
|
4166
|
+
if (typeof FinalizationRegistry !== 'undefined') {
|
|
4167
|
+
this._finalizationRegistry = new FinalizationRegistry(() => {
|
|
4168
|
+
this.automaticCleanup();
|
|
4169
|
+
});
|
|
4170
|
+
}
|
|
4171
|
+
this._refCount = 0;
|
|
4172
|
+
this.incRefCount(this._serverConfig.releaseOnDeref);
|
|
4173
|
+
// Do not retain a hard reference to the dref object, otherwise the FinalizationRegistry
|
|
4174
|
+
// will never trigger.
|
|
4175
|
+
this._serverConfig.releaseOnDeref = undefined;
|
|
4176
|
+
serverConfig.releaseOnDeref = undefined;
|
|
4177
|
+
registerVersion(name$q, version$1, 'serverapp');
|
|
4178
|
+
}
|
|
4179
|
+
toJSON() {
|
|
4180
|
+
return undefined;
|
|
4181
|
+
}
|
|
4182
|
+
get refCount() {
|
|
4183
|
+
return this._refCount;
|
|
4184
|
+
}
|
|
4185
|
+
// Increment the reference count of this server app. If an object is provided, register it
|
|
4186
|
+
// with the finalization registry.
|
|
4187
|
+
incRefCount(obj) {
|
|
4188
|
+
if (this.isDeleted) {
|
|
4189
|
+
return;
|
|
4190
|
+
}
|
|
4191
|
+
this._refCount++;
|
|
4192
|
+
if (obj !== undefined && this._finalizationRegistry !== null) {
|
|
4193
|
+
this._finalizationRegistry.register(obj, this);
|
|
4194
|
+
}
|
|
4195
|
+
}
|
|
4196
|
+
// Decrement the reference count.
|
|
4197
|
+
decRefCount() {
|
|
4198
|
+
if (this.isDeleted) {
|
|
4199
|
+
return 0;
|
|
4200
|
+
}
|
|
4201
|
+
return --this._refCount;
|
|
4202
|
+
}
|
|
4203
|
+
// Invoked by the FinalizationRegistry callback to note that this app should go through its
|
|
4204
|
+
// reference counts and delete itself if no reference count remain. The coordinating logic that
|
|
4205
|
+
// handles this is in deleteApp(...).
|
|
4206
|
+
automaticCleanup() {
|
|
4207
|
+
void deleteApp(this);
|
|
4208
|
+
}
|
|
4209
|
+
get settings() {
|
|
4210
|
+
this.checkDestroyed();
|
|
4211
|
+
return this._serverConfig;
|
|
4212
|
+
}
|
|
4213
|
+
/**
|
|
4214
|
+
* This function will throw an Error if the App has already been deleted -
|
|
4215
|
+
* use before performing API actions on the App.
|
|
4216
|
+
*/
|
|
4217
|
+
checkDestroyed() {
|
|
4218
|
+
if (this.isDeleted) {
|
|
4219
|
+
throw ERROR_FACTORY.create("server-app-deleted" /* AppError.SERVER_APP_DELETED */);
|
|
4220
|
+
}
|
|
4221
|
+
}
|
|
4222
|
+
}
|
|
4223
|
+
|
|
4224
|
+
/**
|
|
4225
|
+
* @license
|
|
4226
|
+
* Copyright 2019 Google LLC
|
|
4227
|
+
*
|
|
4228
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4229
|
+
* you may not use this file except in compliance with the License.
|
|
4230
|
+
* You may obtain a copy of the License at
|
|
4231
|
+
*
|
|
4232
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4233
|
+
*
|
|
4234
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
4235
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4236
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4237
|
+
* See the License for the specific language governing permissions and
|
|
4238
|
+
* limitations under the License.
|
|
4239
|
+
*/
|
|
4240
|
+
/**
|
|
4241
|
+
* The current SDK version.
|
|
4242
|
+
*
|
|
4243
|
+
* @public
|
|
4244
|
+
*/
|
|
4245
|
+
const SDK_VERSION = version;
|
|
4246
|
+
function initializeApp(_options, rawConfig = {}) {
|
|
4247
|
+
let options = _options;
|
|
4248
|
+
if (typeof rawConfig !== 'object') {
|
|
4249
|
+
const name = rawConfig;
|
|
4250
|
+
rawConfig = { name };
|
|
4251
|
+
}
|
|
4252
|
+
const config = {
|
|
4253
|
+
name: DEFAULT_ENTRY_NAME,
|
|
4254
|
+
automaticDataCollectionEnabled: true,
|
|
4255
|
+
...rawConfig
|
|
4256
|
+
};
|
|
4257
|
+
const name = config.name;
|
|
4258
|
+
if (typeof name !== 'string' || !name) {
|
|
4259
|
+
throw ERROR_FACTORY.create("bad-app-name" /* AppError.BAD_APP_NAME */, {
|
|
4260
|
+
appName: String(name)
|
|
4261
|
+
});
|
|
4262
|
+
}
|
|
4263
|
+
options || (options = util.getDefaultAppConfig());
|
|
4264
|
+
if (!options) {
|
|
4265
|
+
throw ERROR_FACTORY.create("no-options" /* AppError.NO_OPTIONS */);
|
|
4266
|
+
}
|
|
4267
|
+
const existingApp = _apps.get(name);
|
|
4268
|
+
if (existingApp) {
|
|
4269
|
+
// return the existing app if options and config deep equal the ones in the existing app.
|
|
4270
|
+
if (!util.deepEqual(options, existingApp.options)) {
|
|
4271
|
+
throw ERROR_FACTORY.create("duplicate-app" /* AppError.DUPLICATE_APP */, {
|
|
4272
|
+
appName: name,
|
|
4273
|
+
mismatchedParam: 'options',
|
|
4274
|
+
oldValue: JSON.stringify(existingApp.options),
|
|
4275
|
+
newValue: JSON.stringify(options)
|
|
4276
|
+
});
|
|
4277
|
+
}
|
|
4278
|
+
else if (!util.deepEqual(config, existingApp.config)) {
|
|
4279
|
+
throw ERROR_FACTORY.create("duplicate-app" /* AppError.DUPLICATE_APP */, {
|
|
4280
|
+
appName: name,
|
|
4281
|
+
mismatchedParam: 'config',
|
|
4282
|
+
oldValue: JSON.stringify(existingApp.config),
|
|
4283
|
+
newValue: JSON.stringify(config)
|
|
4284
|
+
});
|
|
4285
|
+
}
|
|
4286
|
+
else {
|
|
4287
|
+
return existingApp;
|
|
4288
|
+
}
|
|
4289
|
+
}
|
|
4290
|
+
const container = new component.ComponentContainer(name);
|
|
4291
|
+
for (const component of _components.values()) {
|
|
4292
|
+
container.addComponent(component);
|
|
4293
|
+
}
|
|
4294
|
+
const newApp = new FirebaseAppImpl(options, config, container);
|
|
4295
|
+
_apps.set(name, newApp);
|
|
4296
|
+
return newApp;
|
|
4297
|
+
}
|
|
4298
|
+
function initializeServerApp(_options, _serverAppConfig = {}) {
|
|
4299
|
+
if (util.isBrowser() && !util.isWebWorker()) {
|
|
4300
|
+
// FirebaseServerApp isn't designed to be run in browsers.
|
|
4301
|
+
throw ERROR_FACTORY.create("invalid-server-app-environment" /* AppError.INVALID_SERVER_APP_ENVIRONMENT */);
|
|
4302
|
+
}
|
|
4303
|
+
let firebaseOptions;
|
|
4304
|
+
let serverAppSettings = _serverAppConfig || {};
|
|
4305
|
+
if (_options) {
|
|
4306
|
+
if (_isFirebaseApp(_options)) {
|
|
4307
|
+
firebaseOptions = _options.options;
|
|
4308
|
+
}
|
|
4309
|
+
else if (_isFirebaseServerAppSettings(_options)) {
|
|
4310
|
+
serverAppSettings = _options;
|
|
4311
|
+
}
|
|
4312
|
+
else {
|
|
4313
|
+
firebaseOptions = _options;
|
|
4314
|
+
}
|
|
4315
|
+
}
|
|
4316
|
+
if (serverAppSettings.automaticDataCollectionEnabled === undefined) {
|
|
4317
|
+
serverAppSettings.automaticDataCollectionEnabled = true;
|
|
4318
|
+
}
|
|
4319
|
+
firebaseOptions || (firebaseOptions = util.getDefaultAppConfig());
|
|
4320
|
+
if (!firebaseOptions) {
|
|
4321
|
+
throw ERROR_FACTORY.create("no-options" /* AppError.NO_OPTIONS */);
|
|
4322
|
+
}
|
|
4323
|
+
// Build an app name based on a hash of the configuration options.
|
|
4324
|
+
const nameObj = {
|
|
4325
|
+
...serverAppSettings,
|
|
4326
|
+
...firebaseOptions
|
|
4327
|
+
};
|
|
4328
|
+
// However, Do not mangle the name based on releaseOnDeref, since it will vary between the
|
|
4329
|
+
// construction of FirebaseServerApp instances. For example, if the object is the request headers.
|
|
4330
|
+
if (nameObj.releaseOnDeref !== undefined) {
|
|
4331
|
+
delete nameObj.releaseOnDeref;
|
|
4332
|
+
}
|
|
4333
|
+
const hashCode = (s) => {
|
|
4334
|
+
return [...s].reduce((hash, c) => (Math.imul(31, hash) + c.charCodeAt(0)) | 0, 0);
|
|
4335
|
+
};
|
|
4336
|
+
if (serverAppSettings.releaseOnDeref !== undefined) {
|
|
4337
|
+
if (typeof FinalizationRegistry === 'undefined') {
|
|
4338
|
+
throw ERROR_FACTORY.create("finalization-registry-not-supported" /* AppError.FINALIZATION_REGISTRY_NOT_SUPPORTED */, {});
|
|
4339
|
+
}
|
|
4340
|
+
}
|
|
4341
|
+
const nameString = '' + hashCode(JSON.stringify(nameObj));
|
|
4342
|
+
const existingApp = _serverApps.get(nameString);
|
|
4343
|
+
if (existingApp) {
|
|
4344
|
+
existingApp.incRefCount(serverAppSettings.releaseOnDeref);
|
|
4345
|
+
return existingApp;
|
|
4346
|
+
}
|
|
4347
|
+
const container = new component.ComponentContainer(nameString);
|
|
4348
|
+
for (const component of _components.values()) {
|
|
4349
|
+
container.addComponent(component);
|
|
4350
|
+
}
|
|
4351
|
+
const newApp = new FirebaseServerAppImpl(firebaseOptions, serverAppSettings, nameString, container);
|
|
4352
|
+
_serverApps.set(nameString, newApp);
|
|
4353
|
+
return newApp;
|
|
4354
|
+
}
|
|
4355
|
+
/**
|
|
4356
|
+
* Retrieves a {@link @firebase/app#FirebaseApp} instance.
|
|
4357
|
+
*
|
|
4358
|
+
* When called with no arguments, the default app is returned. When an app name
|
|
4359
|
+
* is provided, the app corresponding to that name is returned.
|
|
4360
|
+
*
|
|
4361
|
+
* An exception is thrown if the app being retrieved has not yet been
|
|
4362
|
+
* initialized.
|
|
4363
|
+
*
|
|
4364
|
+
* @example
|
|
4365
|
+
* ```javascript
|
|
4366
|
+
* // Return the default app
|
|
4367
|
+
* const app = getApp();
|
|
4368
|
+
* ```
|
|
4369
|
+
*
|
|
4370
|
+
* @example
|
|
4371
|
+
* ```javascript
|
|
4372
|
+
* // Return a named app
|
|
4373
|
+
* const otherApp = getApp("otherApp");
|
|
4374
|
+
* ```
|
|
4375
|
+
*
|
|
4376
|
+
* @param name - Optional name of the app to return. If no name is
|
|
4377
|
+
* provided, the default is `"[DEFAULT]"`.
|
|
4378
|
+
*
|
|
4379
|
+
* @returns The app corresponding to the provided app name.
|
|
4380
|
+
* If no app name is provided, the default app is returned.
|
|
4381
|
+
*
|
|
4382
|
+
* @public
|
|
4383
|
+
*/
|
|
4384
|
+
function getApp(name = DEFAULT_ENTRY_NAME) {
|
|
4385
|
+
const app = _apps.get(name);
|
|
4386
|
+
if (!app && name === DEFAULT_ENTRY_NAME && util.getDefaultAppConfig()) {
|
|
4387
|
+
return initializeApp();
|
|
4388
|
+
}
|
|
4389
|
+
if (!app) {
|
|
4390
|
+
throw ERROR_FACTORY.create("no-app" /* AppError.NO_APP */, { appName: name });
|
|
4391
|
+
}
|
|
4392
|
+
return app;
|
|
4393
|
+
}
|
|
4394
|
+
/**
|
|
4395
|
+
* A (read-only) array of all initialized apps.
|
|
4396
|
+
* @public
|
|
4397
|
+
*/
|
|
4398
|
+
function getApps() {
|
|
4399
|
+
return Array.from(_apps.values());
|
|
4400
|
+
}
|
|
4401
|
+
/**
|
|
4402
|
+
* Renders this app unusable and frees the resources of all associated
|
|
4403
|
+
* services.
|
|
4404
|
+
*
|
|
4405
|
+
* @example
|
|
4406
|
+
* ```javascript
|
|
4407
|
+
* deleteApp(app)
|
|
4408
|
+
* .then(function() {
|
|
4409
|
+
* console.log("App deleted successfully");
|
|
4410
|
+
* })
|
|
4411
|
+
* .catch(function(error) {
|
|
4412
|
+
* console.log("Error deleting app:", error);
|
|
4413
|
+
* });
|
|
4414
|
+
* ```
|
|
4415
|
+
*
|
|
4416
|
+
* @public
|
|
4417
|
+
*/
|
|
4418
|
+
async function deleteApp(app) {
|
|
4419
|
+
let cleanupProviders = false;
|
|
4420
|
+
const name = app.name;
|
|
4421
|
+
if (_apps.has(name)) {
|
|
4422
|
+
cleanupProviders = true;
|
|
4423
|
+
_apps.delete(name);
|
|
4424
|
+
}
|
|
4425
|
+
else if (_serverApps.has(name)) {
|
|
4426
|
+
const firebaseServerApp = app;
|
|
4427
|
+
if (firebaseServerApp.decRefCount() <= 0) {
|
|
4428
|
+
_serverApps.delete(name);
|
|
4429
|
+
cleanupProviders = true;
|
|
4430
|
+
}
|
|
4431
|
+
}
|
|
4432
|
+
if (cleanupProviders) {
|
|
4433
|
+
await Promise.all(app.container
|
|
4434
|
+
.getProviders()
|
|
4435
|
+
.map(provider => provider.delete()));
|
|
4436
|
+
app.isDeleted = true;
|
|
4437
|
+
}
|
|
4438
|
+
}
|
|
4439
|
+
/**
|
|
4440
|
+
* Registers a library's name and version for platform logging purposes.
|
|
4441
|
+
* @param library - Name of 1p or 3p library (e.g. firestore, angularfire)
|
|
4442
|
+
* @param version - Current version of that library.
|
|
4443
|
+
* @param variant - Bundle variant, e.g., node, rn, etc.
|
|
4444
|
+
*
|
|
4445
|
+
* @public
|
|
4446
|
+
*/
|
|
4447
|
+
function registerVersion(libraryKeyOrName, version, variant) {
|
|
4448
|
+
// TODO: We can use this check to whitelist strings when/if we set up
|
|
4449
|
+
// a good whitelist system.
|
|
4450
|
+
let library = PLATFORM_LOG_STRING[libraryKeyOrName] ?? libraryKeyOrName;
|
|
4451
|
+
if (variant) {
|
|
4452
|
+
library += `-${variant}`;
|
|
4453
|
+
}
|
|
4454
|
+
const libraryMismatch = library.match(/\s|\//);
|
|
4455
|
+
const versionMismatch = version.match(/\s|\//);
|
|
4456
|
+
if (libraryMismatch || versionMismatch) {
|
|
4457
|
+
const warning = [
|
|
4458
|
+
`Unable to register library "${library}" with version "${version}":`
|
|
4459
|
+
];
|
|
4460
|
+
if (libraryMismatch) {
|
|
4461
|
+
warning.push(`library name "${library}" contains illegal characters (whitespace or "/")`);
|
|
4462
|
+
}
|
|
4463
|
+
if (libraryMismatch && versionMismatch) {
|
|
4464
|
+
warning.push('and');
|
|
4465
|
+
}
|
|
4466
|
+
if (versionMismatch) {
|
|
4467
|
+
warning.push(`version name "${version}" contains illegal characters (whitespace or "/")`);
|
|
4468
|
+
}
|
|
4469
|
+
logger.warn(warning.join(' '));
|
|
4470
|
+
return;
|
|
4471
|
+
}
|
|
4472
|
+
_registerComponent(new component.Component(`${library}-version`, () => ({ library, version }), "VERSION" /* ComponentType.VERSION */));
|
|
4473
|
+
}
|
|
4474
|
+
/**
|
|
4475
|
+
* Sets log handler for all Firebase SDKs.
|
|
4476
|
+
* @param logCallback - An optional custom log handler that executes user code whenever
|
|
4477
|
+
* the Firebase SDK makes a logging call.
|
|
4478
|
+
*
|
|
4479
|
+
* @public
|
|
4480
|
+
*/
|
|
4481
|
+
function onLog(logCallback, options) {
|
|
4482
|
+
if (logCallback !== null && typeof logCallback !== 'function') {
|
|
4483
|
+
throw ERROR_FACTORY.create("invalid-log-argument" /* AppError.INVALID_LOG_ARGUMENT */);
|
|
4484
|
+
}
|
|
4485
|
+
logger$1.setUserLogHandler(logCallback, options);
|
|
4486
|
+
}
|
|
4487
|
+
/**
|
|
4488
|
+
* Sets log level for all Firebase SDKs.
|
|
4489
|
+
*
|
|
4490
|
+
* All of the log types above the current log level are captured (i.e. if
|
|
4491
|
+
* you set the log level to `info`, errors are logged, but `debug` and
|
|
4492
|
+
* `verbose` logs are not).
|
|
4493
|
+
*
|
|
4494
|
+
* @public
|
|
4495
|
+
*/
|
|
4496
|
+
function setLogLevel(logLevel) {
|
|
4497
|
+
logger$1.setLogLevel(logLevel);
|
|
4498
|
+
}
|
|
4499
|
+
|
|
4500
|
+
/**
|
|
4501
|
+
* @license
|
|
4502
|
+
* Copyright 2021 Google LLC
|
|
4503
|
+
*
|
|
4504
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4505
|
+
* you may not use this file except in compliance with the License.
|
|
4506
|
+
* You may obtain a copy of the License at
|
|
4507
|
+
*
|
|
4508
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4509
|
+
*
|
|
4510
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
4511
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4512
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4513
|
+
* See the License for the specific language governing permissions and
|
|
4514
|
+
* limitations under the License.
|
|
4515
|
+
*/
|
|
4516
|
+
const DB_NAME = 'firebase-heartbeat-database';
|
|
4517
|
+
const DB_VERSION = 1;
|
|
4518
|
+
const STORE_NAME = 'firebase-heartbeat-store';
|
|
4519
|
+
let dbPromise = null;
|
|
4520
|
+
function getDbPromise() {
|
|
4521
|
+
if (!dbPromise) {
|
|
4522
|
+
dbPromise = idb.openDB(DB_NAME, DB_VERSION, {
|
|
4523
|
+
upgrade: (db, oldVersion) => {
|
|
4524
|
+
// We don't use 'break' in this switch statement, the fall-through
|
|
4525
|
+
// behavior is what we want, because if there are multiple versions between
|
|
4526
|
+
// the old version and the current version, we want ALL the migrations
|
|
4527
|
+
// that correspond to those versions to run, not only the last one.
|
|
4528
|
+
// eslint-disable-next-line default-case
|
|
4529
|
+
switch (oldVersion) {
|
|
4530
|
+
case 0:
|
|
4531
|
+
try {
|
|
4532
|
+
db.createObjectStore(STORE_NAME);
|
|
4533
|
+
}
|
|
4534
|
+
catch (e) {
|
|
4535
|
+
// Safari/iOS browsers throw occasional exceptions on
|
|
4536
|
+
// db.createObjectStore() that may be a bug. Avoid blocking
|
|
4537
|
+
// the rest of the app functionality.
|
|
4538
|
+
console.warn(e);
|
|
4539
|
+
}
|
|
4540
|
+
}
|
|
4541
|
+
}
|
|
4542
|
+
}).catch(e => {
|
|
4543
|
+
throw ERROR_FACTORY.create("idb-open" /* AppError.IDB_OPEN */, {
|
|
4544
|
+
originalErrorMessage: e.message
|
|
4545
|
+
});
|
|
4546
|
+
});
|
|
4547
|
+
}
|
|
4548
|
+
return dbPromise;
|
|
4549
|
+
}
|
|
4550
|
+
async function readHeartbeatsFromIndexedDB(app) {
|
|
4551
|
+
try {
|
|
4552
|
+
const db = await getDbPromise();
|
|
4553
|
+
const tx = db.transaction(STORE_NAME);
|
|
4554
|
+
const result = await tx.objectStore(STORE_NAME).get(computeKey(app));
|
|
4555
|
+
// We already have the value but tx.done can throw,
|
|
4556
|
+
// so we need to await it here to catch errors
|
|
4557
|
+
await tx.done;
|
|
4558
|
+
return result;
|
|
4559
|
+
}
|
|
4560
|
+
catch (e) {
|
|
4561
|
+
if (e instanceof util.FirebaseError) {
|
|
4562
|
+
logger.warn(e.message);
|
|
4563
|
+
}
|
|
4564
|
+
else {
|
|
4565
|
+
const idbGetError = ERROR_FACTORY.create("idb-get" /* AppError.IDB_GET */, {
|
|
4566
|
+
originalErrorMessage: e?.message
|
|
4567
|
+
});
|
|
4568
|
+
logger.warn(idbGetError.message);
|
|
4569
|
+
}
|
|
4570
|
+
}
|
|
4571
|
+
}
|
|
4572
|
+
async function writeHeartbeatsToIndexedDB(app, heartbeatObject) {
|
|
4573
|
+
try {
|
|
4574
|
+
const db = await getDbPromise();
|
|
4575
|
+
const tx = db.transaction(STORE_NAME, 'readwrite');
|
|
4576
|
+
const objectStore = tx.objectStore(STORE_NAME);
|
|
4577
|
+
await objectStore.put(heartbeatObject, computeKey(app));
|
|
4578
|
+
await tx.done;
|
|
4579
|
+
}
|
|
4580
|
+
catch (e) {
|
|
4581
|
+
if (e instanceof util.FirebaseError) {
|
|
4582
|
+
logger.warn(e.message);
|
|
4583
|
+
}
|
|
4584
|
+
else {
|
|
4585
|
+
const idbGetError = ERROR_FACTORY.create("idb-set" /* AppError.IDB_WRITE */, {
|
|
4586
|
+
originalErrorMessage: e?.message
|
|
4587
|
+
});
|
|
4588
|
+
logger.warn(idbGetError.message);
|
|
4589
|
+
}
|
|
4590
|
+
}
|
|
4591
|
+
}
|
|
4592
|
+
function computeKey(app) {
|
|
4593
|
+
return `${app.name}!${app.options.appId}`;
|
|
4594
|
+
}
|
|
4595
|
+
|
|
4596
|
+
/**
|
|
4597
|
+
* @license
|
|
4598
|
+
* Copyright 2021 Google LLC
|
|
4599
|
+
*
|
|
4600
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4601
|
+
* you may not use this file except in compliance with the License.
|
|
4602
|
+
* You may obtain a copy of the License at
|
|
4603
|
+
*
|
|
4604
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4605
|
+
*
|
|
4606
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
4607
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4608
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4609
|
+
* See the License for the specific language governing permissions and
|
|
4610
|
+
* limitations under the License.
|
|
4611
|
+
*/
|
|
4612
|
+
const MAX_HEADER_BYTES = 1024;
|
|
4613
|
+
const MAX_NUM_STORED_HEARTBEATS = 30;
|
|
4614
|
+
class HeartbeatServiceImpl {
|
|
4615
|
+
constructor(container) {
|
|
4616
|
+
this.container = container;
|
|
4617
|
+
/**
|
|
4618
|
+
* In-memory cache for heartbeats, used by getHeartbeatsHeader() to generate
|
|
4619
|
+
* the header string.
|
|
4620
|
+
* Stores one record per date. This will be consolidated into the standard
|
|
4621
|
+
* format of one record per user agent string before being sent as a header.
|
|
4622
|
+
* Populated from indexedDB when the controller is instantiated and should
|
|
4623
|
+
* be kept in sync with indexedDB.
|
|
4624
|
+
* Leave public for easier testing.
|
|
4625
|
+
*/
|
|
4626
|
+
this._heartbeatsCache = null;
|
|
4627
|
+
const app = this.container.getProvider('app').getImmediate();
|
|
4628
|
+
this._storage = new HeartbeatStorageImpl(app);
|
|
4629
|
+
this._heartbeatsCachePromise = this._storage.read().then(result => {
|
|
4630
|
+
this._heartbeatsCache = result;
|
|
4631
|
+
return result;
|
|
4632
|
+
});
|
|
4633
|
+
}
|
|
4634
|
+
/**
|
|
4635
|
+
* Called to report a heartbeat. The function will generate
|
|
4636
|
+
* a HeartbeatsByUserAgent object, update heartbeatsCache, and persist it
|
|
4637
|
+
* to IndexedDB.
|
|
4638
|
+
* Note that we only store one heartbeat per day. So if a heartbeat for today is
|
|
4639
|
+
* already logged, subsequent calls to this function in the same day will be ignored.
|
|
4640
|
+
*/
|
|
4641
|
+
async triggerHeartbeat() {
|
|
4642
|
+
try {
|
|
4643
|
+
const platformLogger = this.container
|
|
4644
|
+
.getProvider('platform-logger')
|
|
4645
|
+
.getImmediate();
|
|
4646
|
+
// This is the "Firebase user agent" string from the platform logger
|
|
4647
|
+
// service, not the browser user agent.
|
|
4648
|
+
const agent = platformLogger.getPlatformInfoString();
|
|
4649
|
+
const date = getUTCDateString();
|
|
4650
|
+
if (this._heartbeatsCache?.heartbeats == null) {
|
|
4651
|
+
this._heartbeatsCache = await this._heartbeatsCachePromise;
|
|
4652
|
+
// If we failed to construct a heartbeats cache, then return immediately.
|
|
4653
|
+
if (this._heartbeatsCache?.heartbeats == null) {
|
|
4654
|
+
return;
|
|
4655
|
+
}
|
|
4656
|
+
}
|
|
4657
|
+
// Do not store a heartbeat if one is already stored for this day
|
|
4658
|
+
// or if a header has already been sent today.
|
|
4659
|
+
if (this._heartbeatsCache.lastSentHeartbeatDate === date ||
|
|
4660
|
+
this._heartbeatsCache.heartbeats.some(singleDateHeartbeat => singleDateHeartbeat.date === date)) {
|
|
4661
|
+
return;
|
|
4662
|
+
}
|
|
4663
|
+
else {
|
|
4664
|
+
// There is no entry for this date. Create one.
|
|
4665
|
+
this._heartbeatsCache.heartbeats.push({ date, agent });
|
|
4666
|
+
// If the number of stored heartbeats exceeds the maximum number of stored heartbeats, remove the heartbeat with the earliest date.
|
|
4667
|
+
// 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.
|
|
4668
|
+
if (this._heartbeatsCache.heartbeats.length > MAX_NUM_STORED_HEARTBEATS) {
|
|
4669
|
+
const earliestHeartbeatIdx = getEarliestHeartbeatIdx(this._heartbeatsCache.heartbeats);
|
|
4670
|
+
this._heartbeatsCache.heartbeats.splice(earliestHeartbeatIdx, 1);
|
|
4671
|
+
}
|
|
4672
|
+
}
|
|
4673
|
+
return this._storage.overwrite(this._heartbeatsCache);
|
|
4674
|
+
}
|
|
4675
|
+
catch (e) {
|
|
4676
|
+
logger.warn(e);
|
|
4677
|
+
}
|
|
4678
|
+
}
|
|
4679
|
+
/**
|
|
4680
|
+
* Returns a base64 encoded string which can be attached to the heartbeat-specific header directly.
|
|
4681
|
+
* It also clears all heartbeats from memory as well as in IndexedDB.
|
|
4682
|
+
*
|
|
4683
|
+
* NOTE: Consuming product SDKs should not send the header if this method
|
|
4684
|
+
* returns an empty string.
|
|
4685
|
+
*/
|
|
4686
|
+
async getHeartbeatsHeader() {
|
|
4687
|
+
try {
|
|
4688
|
+
if (this._heartbeatsCache === null) {
|
|
4689
|
+
await this._heartbeatsCachePromise;
|
|
4690
|
+
}
|
|
4691
|
+
// If it's still null or the array is empty, there is no data to send.
|
|
4692
|
+
if (this._heartbeatsCache?.heartbeats == null ||
|
|
4693
|
+
this._heartbeatsCache.heartbeats.length === 0) {
|
|
4694
|
+
return '';
|
|
4695
|
+
}
|
|
4696
|
+
const date = getUTCDateString();
|
|
4697
|
+
// Extract as many heartbeats from the cache as will fit under the size limit.
|
|
4698
|
+
const { heartbeatsToSend, unsentEntries } = extractHeartbeatsForHeader(this._heartbeatsCache.heartbeats);
|
|
4699
|
+
const headerString = util.base64urlEncodeWithoutPadding(JSON.stringify({ version: 2, heartbeats: heartbeatsToSend }));
|
|
4700
|
+
// Store last sent date to prevent another being logged/sent for the same day.
|
|
4701
|
+
this._heartbeatsCache.lastSentHeartbeatDate = date;
|
|
4702
|
+
if (unsentEntries.length > 0) {
|
|
4703
|
+
// Store any unsent entries if they exist.
|
|
4704
|
+
this._heartbeatsCache.heartbeats = unsentEntries;
|
|
4705
|
+
// This seems more likely than emptying the array (below) to lead to some odd state
|
|
4706
|
+
// since the cache isn't empty and this will be called again on the next request,
|
|
4707
|
+
// and is probably safest if we await it.
|
|
4708
|
+
await this._storage.overwrite(this._heartbeatsCache);
|
|
4709
|
+
}
|
|
4710
|
+
else {
|
|
4711
|
+
this._heartbeatsCache.heartbeats = [];
|
|
4712
|
+
// Do not wait for this, to reduce latency.
|
|
4713
|
+
void this._storage.overwrite(this._heartbeatsCache);
|
|
4714
|
+
}
|
|
4715
|
+
return headerString;
|
|
4716
|
+
}
|
|
4717
|
+
catch (e) {
|
|
4718
|
+
logger.warn(e);
|
|
4719
|
+
return '';
|
|
4720
|
+
}
|
|
4721
|
+
}
|
|
4722
|
+
}
|
|
4723
|
+
function getUTCDateString() {
|
|
4724
|
+
const today = new Date();
|
|
4725
|
+
// Returns date format 'YYYY-MM-DD'
|
|
4726
|
+
return today.toISOString().substring(0, 10);
|
|
4727
|
+
}
|
|
4728
|
+
function extractHeartbeatsForHeader(heartbeatsCache, maxSize = MAX_HEADER_BYTES) {
|
|
4729
|
+
// Heartbeats grouped by user agent in the standard format to be sent in
|
|
4730
|
+
// the header.
|
|
4731
|
+
const heartbeatsToSend = [];
|
|
4732
|
+
// Single date format heartbeats that are not sent.
|
|
4733
|
+
let unsentEntries = heartbeatsCache.slice();
|
|
4734
|
+
for (const singleDateHeartbeat of heartbeatsCache) {
|
|
4735
|
+
// Look for an existing entry with the same user agent.
|
|
4736
|
+
const heartbeatEntry = heartbeatsToSend.find(hb => hb.agent === singleDateHeartbeat.agent);
|
|
4737
|
+
if (!heartbeatEntry) {
|
|
4738
|
+
// If no entry for this user agent exists, create one.
|
|
4739
|
+
heartbeatsToSend.push({
|
|
4740
|
+
agent: singleDateHeartbeat.agent,
|
|
4741
|
+
dates: [singleDateHeartbeat.date]
|
|
4742
|
+
});
|
|
4743
|
+
if (countBytes(heartbeatsToSend) > maxSize) {
|
|
4744
|
+
// If the header would exceed max size, remove the added heartbeat
|
|
4745
|
+
// entry and stop adding to the header.
|
|
4746
|
+
heartbeatsToSend.pop();
|
|
4747
|
+
break;
|
|
4748
|
+
}
|
|
4749
|
+
}
|
|
4750
|
+
else {
|
|
4751
|
+
heartbeatEntry.dates.push(singleDateHeartbeat.date);
|
|
4752
|
+
// If the header would exceed max size, remove the added date
|
|
4753
|
+
// and stop adding to the header.
|
|
4754
|
+
if (countBytes(heartbeatsToSend) > maxSize) {
|
|
4755
|
+
heartbeatEntry.dates.pop();
|
|
4756
|
+
break;
|
|
4757
|
+
}
|
|
4758
|
+
}
|
|
4759
|
+
// Pop unsent entry from queue. (Skipped if adding the entry exceeded
|
|
4760
|
+
// quota and the loop breaks early.)
|
|
4761
|
+
unsentEntries = unsentEntries.slice(1);
|
|
4762
|
+
}
|
|
4763
|
+
return {
|
|
4764
|
+
heartbeatsToSend,
|
|
4765
|
+
unsentEntries
|
|
4766
|
+
};
|
|
4767
|
+
}
|
|
4768
|
+
class HeartbeatStorageImpl {
|
|
4769
|
+
constructor(app) {
|
|
4770
|
+
this.app = app;
|
|
4771
|
+
this._canUseIndexedDBPromise = this.runIndexedDBEnvironmentCheck();
|
|
4772
|
+
}
|
|
4773
|
+
async runIndexedDBEnvironmentCheck() {
|
|
4774
|
+
if (!util.isIndexedDBAvailable()) {
|
|
4775
|
+
return false;
|
|
4776
|
+
}
|
|
4777
|
+
else {
|
|
4778
|
+
return util.validateIndexedDBOpenable()
|
|
4779
|
+
.then(() => true)
|
|
4780
|
+
.catch(() => false);
|
|
4781
|
+
}
|
|
4782
|
+
}
|
|
4783
|
+
/**
|
|
4784
|
+
* Read all heartbeats.
|
|
4785
|
+
*/
|
|
4786
|
+
async read() {
|
|
4787
|
+
const canUseIndexedDB = await this._canUseIndexedDBPromise;
|
|
4788
|
+
if (!canUseIndexedDB) {
|
|
4789
|
+
return { heartbeats: [] };
|
|
4790
|
+
}
|
|
4791
|
+
else {
|
|
4792
|
+
const idbHeartbeatObject = await readHeartbeatsFromIndexedDB(this.app);
|
|
4793
|
+
if (idbHeartbeatObject?.heartbeats) {
|
|
4794
|
+
return idbHeartbeatObject;
|
|
4795
|
+
}
|
|
4796
|
+
else {
|
|
4797
|
+
return { heartbeats: [] };
|
|
4798
|
+
}
|
|
4799
|
+
}
|
|
4800
|
+
}
|
|
4801
|
+
// overwrite the storage with the provided heartbeats
|
|
4802
|
+
async overwrite(heartbeatsObject) {
|
|
4803
|
+
const canUseIndexedDB = await this._canUseIndexedDBPromise;
|
|
4804
|
+
if (!canUseIndexedDB) {
|
|
4805
|
+
return;
|
|
4806
|
+
}
|
|
4807
|
+
else {
|
|
4808
|
+
const existingHeartbeatsObject = await this.read();
|
|
4809
|
+
return writeHeartbeatsToIndexedDB(this.app, {
|
|
4810
|
+
lastSentHeartbeatDate: heartbeatsObject.lastSentHeartbeatDate ??
|
|
4811
|
+
existingHeartbeatsObject.lastSentHeartbeatDate,
|
|
4812
|
+
heartbeats: heartbeatsObject.heartbeats
|
|
4813
|
+
});
|
|
4814
|
+
}
|
|
4815
|
+
}
|
|
4816
|
+
// add heartbeats
|
|
4817
|
+
async add(heartbeatsObject) {
|
|
4818
|
+
const canUseIndexedDB = await this._canUseIndexedDBPromise;
|
|
4819
|
+
if (!canUseIndexedDB) {
|
|
4820
|
+
return;
|
|
4821
|
+
}
|
|
4822
|
+
else {
|
|
4823
|
+
const existingHeartbeatsObject = await this.read();
|
|
4824
|
+
return writeHeartbeatsToIndexedDB(this.app, {
|
|
4825
|
+
lastSentHeartbeatDate: heartbeatsObject.lastSentHeartbeatDate ??
|
|
4826
|
+
existingHeartbeatsObject.lastSentHeartbeatDate,
|
|
4827
|
+
heartbeats: [
|
|
4828
|
+
...existingHeartbeatsObject.heartbeats,
|
|
4829
|
+
...heartbeatsObject.heartbeats
|
|
4830
|
+
]
|
|
4831
|
+
});
|
|
4832
|
+
}
|
|
4833
|
+
}
|
|
4834
|
+
}
|
|
4835
|
+
/**
|
|
4836
|
+
* Calculate bytes of a HeartbeatsByUserAgent array after being wrapped
|
|
4837
|
+
* in a platform logging header JSON object, stringified, and converted
|
|
4838
|
+
* to base 64.
|
|
4839
|
+
*/
|
|
4840
|
+
function countBytes(heartbeatsCache) {
|
|
4841
|
+
// base64 has a restricted set of characters, all of which should be 1 byte.
|
|
4842
|
+
return util.base64urlEncodeWithoutPadding(
|
|
4843
|
+
// heartbeatsCache wrapper properties
|
|
4844
|
+
JSON.stringify({ version: 2, heartbeats: heartbeatsCache })).length;
|
|
4845
|
+
}
|
|
4846
|
+
/**
|
|
4847
|
+
* Returns the index of the heartbeat with the earliest date.
|
|
4848
|
+
* If the heartbeats array is empty, -1 is returned.
|
|
4849
|
+
*/
|
|
4850
|
+
function getEarliestHeartbeatIdx(heartbeats) {
|
|
4851
|
+
if (heartbeats.length === 0) {
|
|
4852
|
+
return -1;
|
|
4853
|
+
}
|
|
4854
|
+
let earliestHeartbeatIdx = 0;
|
|
4855
|
+
let earliestHeartbeatDate = heartbeats[0].date;
|
|
4856
|
+
for (let i = 1; i < heartbeats.length; i++) {
|
|
4857
|
+
if (heartbeats[i].date < earliestHeartbeatDate) {
|
|
4858
|
+
earliestHeartbeatDate = heartbeats[i].date;
|
|
4859
|
+
earliestHeartbeatIdx = i;
|
|
4860
|
+
}
|
|
4861
|
+
}
|
|
4862
|
+
return earliestHeartbeatIdx;
|
|
4863
|
+
}
|
|
4864
|
+
|
|
4865
|
+
/**
|
|
4866
|
+
* @license
|
|
4867
|
+
* Copyright 2019 Google LLC
|
|
4868
|
+
*
|
|
4869
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4870
|
+
* you may not use this file except in compliance with the License.
|
|
4871
|
+
* You may obtain a copy of the License at
|
|
4872
|
+
*
|
|
4873
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4874
|
+
*
|
|
4875
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
4876
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4877
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4878
|
+
* See the License for the specific language governing permissions and
|
|
4879
|
+
* limitations under the License.
|
|
4880
|
+
*/
|
|
4881
|
+
function registerCoreComponents(variant) {
|
|
4882
|
+
_registerComponent(new component.Component('platform-logger', container => new PlatformLoggerServiceImpl(container), "PRIVATE" /* ComponentType.PRIVATE */));
|
|
4883
|
+
_registerComponent(new component.Component('heartbeat', container => new HeartbeatServiceImpl(container), "PRIVATE" /* ComponentType.PRIVATE */));
|
|
4884
|
+
// Register `app` package.
|
|
4885
|
+
registerVersion(name$q, version$1, variant);
|
|
4886
|
+
// BUILD_TARGET will be replaced by values like esm, cjs, etc during the compilation
|
|
4887
|
+
registerVersion(name$q, version$1, 'cjs2020');
|
|
4888
|
+
// Register platform SDK identifier (no version).
|
|
4889
|
+
registerVersion('fire-js', '');
|
|
4890
|
+
}
|
|
4891
|
+
|
|
4892
|
+
/**
|
|
4893
|
+
* Firebase App
|
|
4894
|
+
*
|
|
4895
|
+
* @remarks This package coordinates the communication between the different Firebase components
|
|
4896
|
+
* @packageDocumentation
|
|
4897
|
+
*/
|
|
4898
|
+
/**
|
|
4899
|
+
* @license
|
|
4900
|
+
* Copyright 2019 Google LLC
|
|
4901
|
+
*
|
|
4902
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4903
|
+
* you may not use this file except in compliance with the License.
|
|
4904
|
+
* You may obtain a copy of the License at
|
|
4905
|
+
*
|
|
4906
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4907
|
+
*
|
|
4908
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
4909
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4910
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4911
|
+
* See the License for the specific language governing permissions and
|
|
4912
|
+
* limitations under the License.
|
|
4913
|
+
*/
|
|
4914
|
+
registerCoreComponents('node');
|
|
4915
|
+
|
|
4916
|
+
Object.defineProperty(exports, "FirebaseError", {
|
|
4917
|
+
enumerable: true,
|
|
4918
|
+
get: function () { return util.FirebaseError; }
|
|
4919
|
+
});
|
|
4920
|
+
exports.SDK_VERSION = SDK_VERSION;
|
|
4921
|
+
exports._DEFAULT_ENTRY_NAME = DEFAULT_ENTRY_NAME;
|
|
4922
|
+
exports._addComponent = _addComponent;
|
|
4923
|
+
exports._addOrOverwriteComponent = _addOrOverwriteComponent;
|
|
4924
|
+
exports._apps = _apps;
|
|
4925
|
+
exports._clearComponents = _clearComponents;
|
|
4926
|
+
exports._components = _components;
|
|
4927
|
+
exports._getProvider = _getProvider;
|
|
4928
|
+
exports._isFirebaseApp = _isFirebaseApp;
|
|
4929
|
+
exports._isFirebaseServerApp = _isFirebaseServerApp;
|
|
4930
|
+
exports._isFirebaseServerAppSettings = _isFirebaseServerAppSettings;
|
|
4931
|
+
exports._registerComponent = _registerComponent;
|
|
4932
|
+
exports._removeServiceInstance = _removeServiceInstance;
|
|
4933
|
+
exports._serverApps = _serverApps;
|
|
4934
|
+
exports.deleteApp = deleteApp;
|
|
4935
|
+
exports.getApp = getApp;
|
|
4936
|
+
exports.getApps = getApps;
|
|
4937
|
+
exports.initializeApp = initializeApp;
|
|
4938
|
+
exports.initializeServerApp = initializeServerApp;
|
|
4939
|
+
exports.onLog = onLog;
|
|
4940
|
+
exports.registerVersion = registerVersion;
|
|
4941
|
+
exports.setLogLevel = setLogLevel;
|
|
4942
|
+
|
|
4943
|
+
}(index_cjs));
|
|
4944
|
+
|
|
3348
4945
|
Object.defineProperty(index_standalone, '__esModule', { value: true });
|
|
3349
4946
|
|
|
3350
4947
|
var Websocket = websocket;
|
|
3351
|
-
var util = require$$
|
|
3352
|
-
var logger$1 = require$$
|
|
3353
|
-
var app =
|
|
3354
|
-
var component = require$$
|
|
4948
|
+
var util = require$$2$3;
|
|
4949
|
+
var logger$1 = require$$1$3;
|
|
4950
|
+
var app = index_cjs;
|
|
4951
|
+
var component = require$$0$2;
|
|
3355
4952
|
|
|
3356
4953
|
/**
|
|
3357
4954
|
* @license
|
|
@@ -17394,7 +18991,7 @@ var update_1 = index_standalone.update = update;
|
|
|
17394
18991
|
* See the License for the specific language governing permissions and
|
|
17395
18992
|
* limitations under the License.
|
|
17396
18993
|
*/
|
|
17397
|
-
const logClient = new require$$
|
|
18994
|
+
const logClient = new require$$1$3.Logger('@firebase/database-compat');
|
|
17398
18995
|
const warn = function (msg) {
|
|
17399
18996
|
const message = 'FIREBASE WARNING: ' + msg;
|
|
17400
18997
|
logClient.warn(message);
|
|
@@ -17421,7 +19018,7 @@ const validateBoolean = function (fnName, argumentName, bool, optional) {
|
|
|
17421
19018
|
return;
|
|
17422
19019
|
}
|
|
17423
19020
|
if (typeof bool !== 'boolean') {
|
|
17424
|
-
throw new Error(require$$
|
|
19021
|
+
throw new Error(require$$2$3.errorPrefix(fnName, argumentName) + 'must be a boolean.');
|
|
17425
19022
|
}
|
|
17426
19023
|
};
|
|
17427
19024
|
const validateEventType = function (fnName, eventType, optional) {
|
|
@@ -17436,7 +19033,7 @@ const validateEventType = function (fnName, eventType, optional) {
|
|
|
17436
19033
|
case 'child_moved':
|
|
17437
19034
|
break;
|
|
17438
19035
|
default:
|
|
17439
|
-
throw new Error(require$$
|
|
19036
|
+
throw new Error(require$$2$3.errorPrefix(fnName, 'eventType') +
|
|
17440
19037
|
'must be a valid event type = "value", "child_added", "child_removed", ' +
|
|
17441
19038
|
'"child_changed", or "child_moved".');
|
|
17442
19039
|
}
|
|
@@ -17463,8 +19060,8 @@ class OnDisconnect {
|
|
|
17463
19060
|
this._delegate = _delegate;
|
|
17464
19061
|
}
|
|
17465
19062
|
cancel(onComplete) {
|
|
17466
|
-
require$$
|
|
17467
|
-
require$$
|
|
19063
|
+
require$$2$3.validateArgCount('OnDisconnect.cancel', 0, 1, arguments.length);
|
|
19064
|
+
require$$2$3.validateCallback('OnDisconnect.cancel', 'onComplete', onComplete, true);
|
|
17468
19065
|
const result = this._delegate.cancel();
|
|
17469
19066
|
if (onComplete) {
|
|
17470
19067
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -17472,8 +19069,8 @@ class OnDisconnect {
|
|
|
17472
19069
|
return result;
|
|
17473
19070
|
}
|
|
17474
19071
|
remove(onComplete) {
|
|
17475
|
-
require$$
|
|
17476
|
-
require$$
|
|
19072
|
+
require$$2$3.validateArgCount('OnDisconnect.remove', 0, 1, arguments.length);
|
|
19073
|
+
require$$2$3.validateCallback('OnDisconnect.remove', 'onComplete', onComplete, true);
|
|
17477
19074
|
const result = this._delegate.remove();
|
|
17478
19075
|
if (onComplete) {
|
|
17479
19076
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -17481,8 +19078,8 @@ class OnDisconnect {
|
|
|
17481
19078
|
return result;
|
|
17482
19079
|
}
|
|
17483
19080
|
set(value, onComplete) {
|
|
17484
|
-
require$$
|
|
17485
|
-
require$$
|
|
19081
|
+
require$$2$3.validateArgCount('OnDisconnect.set', 1, 2, arguments.length);
|
|
19082
|
+
require$$2$3.validateCallback('OnDisconnect.set', 'onComplete', onComplete, true);
|
|
17486
19083
|
const result = this._delegate.set(value);
|
|
17487
19084
|
if (onComplete) {
|
|
17488
19085
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -17490,8 +19087,8 @@ class OnDisconnect {
|
|
|
17490
19087
|
return result;
|
|
17491
19088
|
}
|
|
17492
19089
|
setWithPriority(value, priority, onComplete) {
|
|
17493
|
-
require$$
|
|
17494
|
-
require$$
|
|
19090
|
+
require$$2$3.validateArgCount('OnDisconnect.setWithPriority', 2, 3, arguments.length);
|
|
19091
|
+
require$$2$3.validateCallback('OnDisconnect.setWithPriority', 'onComplete', onComplete, true);
|
|
17495
19092
|
const result = this._delegate.setWithPriority(value, priority);
|
|
17496
19093
|
if (onComplete) {
|
|
17497
19094
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -17499,7 +19096,7 @@ class OnDisconnect {
|
|
|
17499
19096
|
return result;
|
|
17500
19097
|
}
|
|
17501
19098
|
update(objectToMerge, onComplete) {
|
|
17502
|
-
require$$
|
|
19099
|
+
require$$2$3.validateArgCount('OnDisconnect.update', 1, 2, arguments.length);
|
|
17503
19100
|
if (Array.isArray(objectToMerge)) {
|
|
17504
19101
|
const newObjectToMerge = {};
|
|
17505
19102
|
for (let i = 0; i < objectToMerge.length; ++i) {
|
|
@@ -17509,7 +19106,7 @@ class OnDisconnect {
|
|
|
17509
19106
|
warn('Passing an Array to firebase.database.onDisconnect().update() is deprecated. Use set() if you want to overwrite the ' +
|
|
17510
19107
|
'existing data, or an Object with integer keys if you really do want to only update some of the children.');
|
|
17511
19108
|
}
|
|
17512
|
-
require$$
|
|
19109
|
+
require$$2$3.validateCallback('OnDisconnect.update', 'onComplete', onComplete, true);
|
|
17513
19110
|
const result = this._delegate.update(objectToMerge);
|
|
17514
19111
|
if (onComplete) {
|
|
17515
19112
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -17545,7 +19142,7 @@ class TransactionResult {
|
|
|
17545
19142
|
// Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary
|
|
17546
19143
|
// for end-users
|
|
17547
19144
|
toJSON() {
|
|
17548
|
-
require$$
|
|
19145
|
+
require$$2$3.validateArgCount('TransactionResult.toJSON', 0, 1, arguments.length);
|
|
17549
19146
|
return { committed: this.committed, snapshot: this.snapshot.toJSON() };
|
|
17550
19147
|
}
|
|
17551
19148
|
}
|
|
@@ -17582,7 +19179,7 @@ class DataSnapshot {
|
|
|
17582
19179
|
* @returns JSON representation of the DataSnapshot contents, or null if empty.
|
|
17583
19180
|
*/
|
|
17584
19181
|
val() {
|
|
17585
|
-
require$$
|
|
19182
|
+
require$$2$3.validateArgCount('DataSnapshot.val', 0, 0, arguments.length);
|
|
17586
19183
|
return this._delegate.val();
|
|
17587
19184
|
}
|
|
17588
19185
|
/**
|
|
@@ -17591,14 +19188,14 @@ class DataSnapshot {
|
|
|
17591
19188
|
* @returns JSON representation of the DataSnapshot contents, or null if empty.
|
|
17592
19189
|
*/
|
|
17593
19190
|
exportVal() {
|
|
17594
|
-
require$$
|
|
19191
|
+
require$$2$3.validateArgCount('DataSnapshot.exportVal', 0, 0, arguments.length);
|
|
17595
19192
|
return this._delegate.exportVal();
|
|
17596
19193
|
}
|
|
17597
19194
|
// Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary
|
|
17598
19195
|
// for end-users
|
|
17599
19196
|
toJSON() {
|
|
17600
19197
|
// Optional spacer argument is unnecessary because we're depending on recursion rather than stringifying the content
|
|
17601
|
-
require$$
|
|
19198
|
+
require$$2$3.validateArgCount('DataSnapshot.toJSON', 0, 1, arguments.length);
|
|
17602
19199
|
return this._delegate.toJSON();
|
|
17603
19200
|
}
|
|
17604
19201
|
/**
|
|
@@ -17607,7 +19204,7 @@ class DataSnapshot {
|
|
|
17607
19204
|
* @returns Whether the snapshot contains a non-null value, or is empty.
|
|
17608
19205
|
*/
|
|
17609
19206
|
exists() {
|
|
17610
|
-
require$$
|
|
19207
|
+
require$$2$3.validateArgCount('DataSnapshot.exists', 0, 0, arguments.length);
|
|
17611
19208
|
return this._delegate.exists();
|
|
17612
19209
|
}
|
|
17613
19210
|
/**
|
|
@@ -17617,7 +19214,7 @@ class DataSnapshot {
|
|
|
17617
19214
|
* @returns DataSnapshot for child node.
|
|
17618
19215
|
*/
|
|
17619
19216
|
child(path) {
|
|
17620
|
-
require$$
|
|
19217
|
+
require$$2$3.validateArgCount('DataSnapshot.child', 0, 1, arguments.length);
|
|
17621
19218
|
// Ensure the childPath is a string (can be a number)
|
|
17622
19219
|
path = String(path);
|
|
17623
19220
|
_validatePathString('DataSnapshot.child', 'path', path, false);
|
|
@@ -17630,7 +19227,7 @@ class DataSnapshot {
|
|
|
17630
19227
|
* @returns Whether the child exists.
|
|
17631
19228
|
*/
|
|
17632
19229
|
hasChild(path) {
|
|
17633
|
-
require$$
|
|
19230
|
+
require$$2$3.validateArgCount('DataSnapshot.hasChild', 1, 1, arguments.length);
|
|
17634
19231
|
_validatePathString('DataSnapshot.hasChild', 'path', path, false);
|
|
17635
19232
|
return this._delegate.hasChild(path);
|
|
17636
19233
|
}
|
|
@@ -17640,7 +19237,7 @@ class DataSnapshot {
|
|
|
17640
19237
|
* @returns The priority.
|
|
17641
19238
|
*/
|
|
17642
19239
|
getPriority() {
|
|
17643
|
-
require$$
|
|
19240
|
+
require$$2$3.validateArgCount('DataSnapshot.getPriority', 0, 0, arguments.length);
|
|
17644
19241
|
return this._delegate.priority;
|
|
17645
19242
|
}
|
|
17646
19243
|
/**
|
|
@@ -17652,8 +19249,8 @@ class DataSnapshot {
|
|
|
17652
19249
|
* one of the child nodes.
|
|
17653
19250
|
*/
|
|
17654
19251
|
forEach(action) {
|
|
17655
|
-
require$$
|
|
17656
|
-
require$$
|
|
19252
|
+
require$$2$3.validateArgCount('DataSnapshot.forEach', 1, 1, arguments.length);
|
|
19253
|
+
require$$2$3.validateCallback('DataSnapshot.forEach', 'action', action, false);
|
|
17657
19254
|
return this._delegate.forEach(expDataSnapshot => action(new DataSnapshot(this._database, expDataSnapshot)));
|
|
17658
19255
|
}
|
|
17659
19256
|
/**
|
|
@@ -17661,7 +19258,7 @@ class DataSnapshot {
|
|
|
17661
19258
|
* @returns True if the DataSnapshot contains 1 or more child nodes.
|
|
17662
19259
|
*/
|
|
17663
19260
|
hasChildren() {
|
|
17664
|
-
require$$
|
|
19261
|
+
require$$2$3.validateArgCount('DataSnapshot.hasChildren', 0, 0, arguments.length);
|
|
17665
19262
|
return this._delegate.hasChildren();
|
|
17666
19263
|
}
|
|
17667
19264
|
get key() {
|
|
@@ -17672,7 +19269,7 @@ class DataSnapshot {
|
|
|
17672
19269
|
* @returns The number of children that this DataSnapshot contains.
|
|
17673
19270
|
*/
|
|
17674
19271
|
numChildren() {
|
|
17675
|
-
require$$
|
|
19272
|
+
require$$2$3.validateArgCount('DataSnapshot.numChildren', 0, 0, arguments.length);
|
|
17676
19273
|
return this._delegate.size;
|
|
17677
19274
|
}
|
|
17678
19275
|
/**
|
|
@@ -17680,7 +19277,7 @@ class DataSnapshot {
|
|
|
17680
19277
|
* from.
|
|
17681
19278
|
*/
|
|
17682
19279
|
getRef() {
|
|
17683
|
-
require$$
|
|
19280
|
+
require$$2$3.validateArgCount('DataSnapshot.ref', 0, 0, arguments.length);
|
|
17684
19281
|
return new Reference(this._database, this._delegate.ref);
|
|
17685
19282
|
}
|
|
17686
19283
|
get ref() {
|
|
@@ -17699,8 +19296,8 @@ class Query {
|
|
|
17699
19296
|
this._delegate = _delegate;
|
|
17700
19297
|
}
|
|
17701
19298
|
on(eventType, callback, cancelCallbackOrContext, context) {
|
|
17702
|
-
require$$
|
|
17703
|
-
require$$
|
|
19299
|
+
require$$2$3.validateArgCount('Query.on', 2, 4, arguments.length);
|
|
19300
|
+
require$$2$3.validateCallback('Query.on', 'callback', callback, false);
|
|
17704
19301
|
const ret = Query.getCancelAndContextArgs_('Query.on', cancelCallbackOrContext, context);
|
|
17705
19302
|
const valueCallback = (expSnapshot, previousChildName) => {
|
|
17706
19303
|
callback.call(ret.context, new DataSnapshot(this.database, expSnapshot), previousChildName);
|
|
@@ -17725,16 +19322,16 @@ class Query {
|
|
|
17725
19322
|
onChildMoved_1(this._delegate, valueCallback, cancelCallback);
|
|
17726
19323
|
return callback;
|
|
17727
19324
|
default:
|
|
17728
|
-
throw new Error(require$$
|
|
19325
|
+
throw new Error(require$$2$3.errorPrefix('Query.on', 'eventType') +
|
|
17729
19326
|
'must be a valid event type = "value", "child_added", "child_removed", ' +
|
|
17730
19327
|
'"child_changed", or "child_moved".');
|
|
17731
19328
|
}
|
|
17732
19329
|
}
|
|
17733
19330
|
off(eventType, callback, context) {
|
|
17734
|
-
require$$
|
|
19331
|
+
require$$2$3.validateArgCount('Query.off', 0, 3, arguments.length);
|
|
17735
19332
|
validateEventType('Query.off', eventType);
|
|
17736
|
-
require$$
|
|
17737
|
-
require$$
|
|
19333
|
+
require$$2$3.validateCallback('Query.off', 'callback', callback, true);
|
|
19334
|
+
require$$2$3.validateContextObject('Query.off', 'context', context, true);
|
|
17738
19335
|
if (callback) {
|
|
17739
19336
|
const valueCallback = () => { };
|
|
17740
19337
|
valueCallback.userCallback = callback;
|
|
@@ -17757,10 +19354,10 @@ class Query {
|
|
|
17757
19354
|
* Attaches a listener, waits for the first event, and then removes the listener
|
|
17758
19355
|
*/
|
|
17759
19356
|
once(eventType, callback, failureCallbackOrContext, context) {
|
|
17760
|
-
require$$
|
|
17761
|
-
require$$
|
|
19357
|
+
require$$2$3.validateArgCount('Query.once', 1, 4, arguments.length);
|
|
19358
|
+
require$$2$3.validateCallback('Query.once', 'callback', callback, true);
|
|
17762
19359
|
const ret = Query.getCancelAndContextArgs_('Query.once', failureCallbackOrContext, context);
|
|
17763
|
-
const deferred = new require$$
|
|
19360
|
+
const deferred = new require$$2$3.Deferred();
|
|
17764
19361
|
const valueCallback = (expSnapshot, previousChildName) => {
|
|
17765
19362
|
const result = new DataSnapshot(this.database, expSnapshot);
|
|
17766
19363
|
if (callback) {
|
|
@@ -17803,7 +19400,7 @@ class Query {
|
|
|
17803
19400
|
});
|
|
17804
19401
|
break;
|
|
17805
19402
|
default:
|
|
17806
|
-
throw new Error(require$$
|
|
19403
|
+
throw new Error(require$$2$3.errorPrefix('Query.once', 'eventType') +
|
|
17807
19404
|
'must be a valid event type = "value", "child_added", "child_removed", ' +
|
|
17808
19405
|
'"child_changed", or "child_moved".');
|
|
17809
19406
|
}
|
|
@@ -17813,58 +19410,58 @@ class Query {
|
|
|
17813
19410
|
* Set a limit and anchor it to the start of the window.
|
|
17814
19411
|
*/
|
|
17815
19412
|
limitToFirst(limit) {
|
|
17816
|
-
require$$
|
|
19413
|
+
require$$2$3.validateArgCount('Query.limitToFirst', 1, 1, arguments.length);
|
|
17817
19414
|
return new Query(this.database, query_1(this._delegate, limitToFirst_1(limit)));
|
|
17818
19415
|
}
|
|
17819
19416
|
/**
|
|
17820
19417
|
* Set a limit and anchor it to the end of the window.
|
|
17821
19418
|
*/
|
|
17822
19419
|
limitToLast(limit) {
|
|
17823
|
-
require$$
|
|
19420
|
+
require$$2$3.validateArgCount('Query.limitToLast', 1, 1, arguments.length);
|
|
17824
19421
|
return new Query(this.database, query_1(this._delegate, limitToLast_1(limit)));
|
|
17825
19422
|
}
|
|
17826
19423
|
/**
|
|
17827
19424
|
* Given a child path, return a new query ordered by the specified grandchild path.
|
|
17828
19425
|
*/
|
|
17829
19426
|
orderByChild(path) {
|
|
17830
|
-
require$$
|
|
19427
|
+
require$$2$3.validateArgCount('Query.orderByChild', 1, 1, arguments.length);
|
|
17831
19428
|
return new Query(this.database, query_1(this._delegate, orderByChild_1(path)));
|
|
17832
19429
|
}
|
|
17833
19430
|
/**
|
|
17834
19431
|
* Return a new query ordered by the KeyIndex
|
|
17835
19432
|
*/
|
|
17836
19433
|
orderByKey() {
|
|
17837
|
-
require$$
|
|
19434
|
+
require$$2$3.validateArgCount('Query.orderByKey', 0, 0, arguments.length);
|
|
17838
19435
|
return new Query(this.database, query_1(this._delegate, orderByKey_1()));
|
|
17839
19436
|
}
|
|
17840
19437
|
/**
|
|
17841
19438
|
* Return a new query ordered by the PriorityIndex
|
|
17842
19439
|
*/
|
|
17843
19440
|
orderByPriority() {
|
|
17844
|
-
require$$
|
|
19441
|
+
require$$2$3.validateArgCount('Query.orderByPriority', 0, 0, arguments.length);
|
|
17845
19442
|
return new Query(this.database, query_1(this._delegate, orderByPriority_1()));
|
|
17846
19443
|
}
|
|
17847
19444
|
/**
|
|
17848
19445
|
* Return a new query ordered by the ValueIndex
|
|
17849
19446
|
*/
|
|
17850
19447
|
orderByValue() {
|
|
17851
|
-
require$$
|
|
19448
|
+
require$$2$3.validateArgCount('Query.orderByValue', 0, 0, arguments.length);
|
|
17852
19449
|
return new Query(this.database, query_1(this._delegate, orderByValue_1()));
|
|
17853
19450
|
}
|
|
17854
19451
|
startAt(value = null, name) {
|
|
17855
|
-
require$$
|
|
19452
|
+
require$$2$3.validateArgCount('Query.startAt', 0, 2, arguments.length);
|
|
17856
19453
|
return new Query(this.database, query_1(this._delegate, startAt_1(value, name)));
|
|
17857
19454
|
}
|
|
17858
19455
|
startAfter(value = null, name) {
|
|
17859
|
-
require$$
|
|
19456
|
+
require$$2$3.validateArgCount('Query.startAfter', 0, 2, arguments.length);
|
|
17860
19457
|
return new Query(this.database, query_1(this._delegate, startAfter_1(value, name)));
|
|
17861
19458
|
}
|
|
17862
19459
|
endAt(value = null, name) {
|
|
17863
|
-
require$$
|
|
19460
|
+
require$$2$3.validateArgCount('Query.endAt', 0, 2, arguments.length);
|
|
17864
19461
|
return new Query(this.database, query_1(this._delegate, endAt_1(value, name)));
|
|
17865
19462
|
}
|
|
17866
19463
|
endBefore(value = null, name) {
|
|
17867
|
-
require$$
|
|
19464
|
+
require$$2$3.validateArgCount('Query.endBefore', 0, 2, arguments.length);
|
|
17868
19465
|
return new Query(this.database, query_1(this._delegate, endBefore_1(value, name)));
|
|
17869
19466
|
}
|
|
17870
19467
|
/**
|
|
@@ -17872,28 +19469,28 @@ class Query {
|
|
|
17872
19469
|
* the specified name.
|
|
17873
19470
|
*/
|
|
17874
19471
|
equalTo(value, name) {
|
|
17875
|
-
require$$
|
|
19472
|
+
require$$2$3.validateArgCount('Query.equalTo', 1, 2, arguments.length);
|
|
17876
19473
|
return new Query(this.database, query_1(this._delegate, equalTo_1(value, name)));
|
|
17877
19474
|
}
|
|
17878
19475
|
/**
|
|
17879
19476
|
* @returns URL for this location.
|
|
17880
19477
|
*/
|
|
17881
19478
|
toString() {
|
|
17882
|
-
require$$
|
|
19479
|
+
require$$2$3.validateArgCount('Query.toString', 0, 0, arguments.length);
|
|
17883
19480
|
return this._delegate.toString();
|
|
17884
19481
|
}
|
|
17885
19482
|
// Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary
|
|
17886
19483
|
// for end-users.
|
|
17887
19484
|
toJSON() {
|
|
17888
19485
|
// An optional spacer argument is unnecessary for a string.
|
|
17889
|
-
require$$
|
|
19486
|
+
require$$2$3.validateArgCount('Query.toJSON', 0, 1, arguments.length);
|
|
17890
19487
|
return this._delegate.toJSON();
|
|
17891
19488
|
}
|
|
17892
19489
|
/**
|
|
17893
19490
|
* Return true if this query and the provided query are equivalent; otherwise, return false.
|
|
17894
19491
|
*/
|
|
17895
19492
|
isEqual(other) {
|
|
17896
|
-
require$$
|
|
19493
|
+
require$$2$3.validateArgCount('Query.isEqual', 1, 1, arguments.length);
|
|
17897
19494
|
if (!(other instanceof Query)) {
|
|
17898
19495
|
const error = 'Query.isEqual failed: First argument must be an instance of firebase.database.Query.';
|
|
17899
19496
|
throw new Error(error);
|
|
@@ -17909,9 +19506,9 @@ class Query {
|
|
|
17909
19506
|
const ret = { cancel: undefined, context: undefined };
|
|
17910
19507
|
if (cancelOrContext && context) {
|
|
17911
19508
|
ret.cancel = cancelOrContext;
|
|
17912
|
-
require$$
|
|
19509
|
+
require$$2$3.validateCallback(fnName, 'cancel', ret.cancel, true);
|
|
17913
19510
|
ret.context = context;
|
|
17914
|
-
require$$
|
|
19511
|
+
require$$2$3.validateContextObject(fnName, 'context', ret.context, true);
|
|
17915
19512
|
}
|
|
17916
19513
|
else if (cancelOrContext) {
|
|
17917
19514
|
// we have either a cancel callback or a context.
|
|
@@ -17923,7 +19520,7 @@ class Query {
|
|
|
17923
19520
|
ret.cancel = cancelOrContext;
|
|
17924
19521
|
}
|
|
17925
19522
|
else {
|
|
17926
|
-
throw new Error(require$$
|
|
19523
|
+
throw new Error(require$$2$3.errorPrefix(fnName, 'cancelOrContext') +
|
|
17927
19524
|
' must either be a cancel callback or a context object.');
|
|
17928
19525
|
}
|
|
17929
19526
|
}
|
|
@@ -17948,11 +19545,11 @@ class Reference extends Query {
|
|
|
17948
19545
|
}
|
|
17949
19546
|
/** @returns {?string} */
|
|
17950
19547
|
getKey() {
|
|
17951
|
-
require$$
|
|
19548
|
+
require$$2$3.validateArgCount('Reference.key', 0, 0, arguments.length);
|
|
17952
19549
|
return this._delegate.key;
|
|
17953
19550
|
}
|
|
17954
19551
|
child(pathString) {
|
|
17955
|
-
require$$
|
|
19552
|
+
require$$2$3.validateArgCount('Reference.child', 1, 1, arguments.length);
|
|
17956
19553
|
if (typeof pathString === 'number') {
|
|
17957
19554
|
pathString = String(pathString);
|
|
17958
19555
|
}
|
|
@@ -17960,18 +19557,18 @@ class Reference extends Query {
|
|
|
17960
19557
|
}
|
|
17961
19558
|
/** @returns {?Reference} */
|
|
17962
19559
|
getParent() {
|
|
17963
|
-
require$$
|
|
19560
|
+
require$$2$3.validateArgCount('Reference.parent', 0, 0, arguments.length);
|
|
17964
19561
|
const parent = this._delegate.parent;
|
|
17965
19562
|
return parent ? new Reference(this.database, parent) : null;
|
|
17966
19563
|
}
|
|
17967
19564
|
/** @returns {!Reference} */
|
|
17968
19565
|
getRoot() {
|
|
17969
|
-
require$$
|
|
19566
|
+
require$$2$3.validateArgCount('Reference.root', 0, 0, arguments.length);
|
|
17970
19567
|
return new Reference(this.database, this._delegate.root);
|
|
17971
19568
|
}
|
|
17972
19569
|
set(newVal, onComplete) {
|
|
17973
|
-
require$$
|
|
17974
|
-
require$$
|
|
19570
|
+
require$$2$3.validateArgCount('Reference.set', 1, 2, arguments.length);
|
|
19571
|
+
require$$2$3.validateCallback('Reference.set', 'onComplete', onComplete, true);
|
|
17975
19572
|
const result = set_1(this._delegate, newVal);
|
|
17976
19573
|
if (onComplete) {
|
|
17977
19574
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -17979,7 +19576,7 @@ class Reference extends Query {
|
|
|
17979
19576
|
return result;
|
|
17980
19577
|
}
|
|
17981
19578
|
update(values, onComplete) {
|
|
17982
|
-
require$$
|
|
19579
|
+
require$$2$3.validateArgCount('Reference.update', 1, 2, arguments.length);
|
|
17983
19580
|
if (Array.isArray(values)) {
|
|
17984
19581
|
const newObjectToMerge = {};
|
|
17985
19582
|
for (let i = 0; i < values.length; ++i) {
|
|
@@ -17992,7 +19589,7 @@ class Reference extends Query {
|
|
|
17992
19589
|
'only update some of the children.');
|
|
17993
19590
|
}
|
|
17994
19591
|
_validateWritablePath('Reference.update', this._delegate._path);
|
|
17995
|
-
require$$
|
|
19592
|
+
require$$2$3.validateCallback('Reference.update', 'onComplete', onComplete, true);
|
|
17996
19593
|
const result = update_1(this._delegate, values);
|
|
17997
19594
|
if (onComplete) {
|
|
17998
19595
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -18000,8 +19597,8 @@ class Reference extends Query {
|
|
|
18000
19597
|
return result;
|
|
18001
19598
|
}
|
|
18002
19599
|
setWithPriority(newVal, newPriority, onComplete) {
|
|
18003
|
-
require$$
|
|
18004
|
-
require$$
|
|
19600
|
+
require$$2$3.validateArgCount('Reference.setWithPriority', 2, 3, arguments.length);
|
|
19601
|
+
require$$2$3.validateCallback('Reference.setWithPriority', 'onComplete', onComplete, true);
|
|
18005
19602
|
const result = setWithPriority_1(this._delegate, newVal, newPriority);
|
|
18006
19603
|
if (onComplete) {
|
|
18007
19604
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -18009,8 +19606,8 @@ class Reference extends Query {
|
|
|
18009
19606
|
return result;
|
|
18010
19607
|
}
|
|
18011
19608
|
remove(onComplete) {
|
|
18012
|
-
require$$
|
|
18013
|
-
require$$
|
|
19609
|
+
require$$2$3.validateArgCount('Reference.remove', 0, 1, arguments.length);
|
|
19610
|
+
require$$2$3.validateCallback('Reference.remove', 'onComplete', onComplete, true);
|
|
18014
19611
|
const result = remove_1(this._delegate);
|
|
18015
19612
|
if (onComplete) {
|
|
18016
19613
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -18018,9 +19615,9 @@ class Reference extends Query {
|
|
|
18018
19615
|
return result;
|
|
18019
19616
|
}
|
|
18020
19617
|
transaction(transactionUpdate, onComplete, applyLocally) {
|
|
18021
|
-
require$$
|
|
18022
|
-
require$$
|
|
18023
|
-
require$$
|
|
19618
|
+
require$$2$3.validateArgCount('Reference.transaction', 1, 3, arguments.length);
|
|
19619
|
+
require$$2$3.validateCallback('Reference.transaction', 'transactionUpdate', transactionUpdate, false);
|
|
19620
|
+
require$$2$3.validateCallback('Reference.transaction', 'onComplete', onComplete, true);
|
|
18024
19621
|
validateBoolean('Reference.transaction', 'applyLocally', applyLocally);
|
|
18025
19622
|
const result = runTransaction_1(this._delegate, transactionUpdate, {
|
|
18026
19623
|
applyLocally
|
|
@@ -18031,8 +19628,8 @@ class Reference extends Query {
|
|
|
18031
19628
|
return result;
|
|
18032
19629
|
}
|
|
18033
19630
|
setPriority(priority, onComplete) {
|
|
18034
|
-
require$$
|
|
18035
|
-
require$$
|
|
19631
|
+
require$$2$3.validateArgCount('Reference.setPriority', 1, 2, arguments.length);
|
|
19632
|
+
require$$2$3.validateCallback('Reference.setPriority', 'onComplete', onComplete, true);
|
|
18036
19633
|
const result = setPriority_1(this._delegate, priority);
|
|
18037
19634
|
if (onComplete) {
|
|
18038
19635
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -18040,8 +19637,8 @@ class Reference extends Query {
|
|
|
18040
19637
|
return result;
|
|
18041
19638
|
}
|
|
18042
19639
|
push(value, onComplete) {
|
|
18043
|
-
require$$
|
|
18044
|
-
require$$
|
|
19640
|
+
require$$2$3.validateArgCount('Reference.push', 0, 2, arguments.length);
|
|
19641
|
+
require$$2$3.validateCallback('Reference.push', 'onComplete', onComplete, true);
|
|
18045
19642
|
const expPromise = push_1(this._delegate, value);
|
|
18046
19643
|
const promise = expPromise.then(expRef => new Reference(this.database, expRef));
|
|
18047
19644
|
if (onComplete) {
|
|
@@ -18113,7 +19710,7 @@ class Database {
|
|
|
18113
19710
|
connectDatabaseEmulator_1(this._delegate, host, port, options);
|
|
18114
19711
|
}
|
|
18115
19712
|
ref(path) {
|
|
18116
|
-
require$$
|
|
19713
|
+
require$$2$3.validateArgCount('database.ref', 0, 1, arguments.length);
|
|
18117
19714
|
if (path instanceof Reference) {
|
|
18118
19715
|
const childRef = refFromURL_1(this._delegate, path.toString());
|
|
18119
19716
|
return new Reference(this, childRef);
|
|
@@ -18131,17 +19728,17 @@ class Database {
|
|
|
18131
19728
|
*/
|
|
18132
19729
|
refFromURL(url) {
|
|
18133
19730
|
const apiName = 'database.refFromURL';
|
|
18134
|
-
require$$
|
|
19731
|
+
require$$2$3.validateArgCount(apiName, 1, 1, arguments.length);
|
|
18135
19732
|
const childRef = refFromURL_1(this._delegate, url);
|
|
18136
19733
|
return new Reference(this, childRef);
|
|
18137
19734
|
}
|
|
18138
19735
|
// Make individual repo go offline.
|
|
18139
19736
|
goOffline() {
|
|
18140
|
-
require$$
|
|
19737
|
+
require$$2$3.validateArgCount('database.goOffline', 0, 0, arguments.length);
|
|
18141
19738
|
return goOffline_1(this._delegate);
|
|
18142
19739
|
}
|
|
18143
19740
|
goOnline() {
|
|
18144
|
-
require$$
|
|
19741
|
+
require$$2$3.validateArgCount('database.goOnline', 0, 0, arguments.length);
|
|
18145
19742
|
return goOnline_1(this._delegate);
|
|
18146
19743
|
}
|
|
18147
19744
|
}
|
|
@@ -18161,17 +19758,17 @@ Database.ServerValue = {
|
|
|
18161
19758
|
*/
|
|
18162
19759
|
function initStandalone$1({ app, url, version, customAuthImpl, customAppCheckImpl, namespace, nodeAdmin = false }) {
|
|
18163
19760
|
_setSDKVersion(version);
|
|
18164
|
-
const container = new require$$
|
|
19761
|
+
const container = new require$$0$2.ComponentContainer('database-standalone');
|
|
18165
19762
|
/**
|
|
18166
19763
|
* ComponentContainer('database-standalone') is just a placeholder that doesn't perform
|
|
18167
19764
|
* any actual function.
|
|
18168
19765
|
*/
|
|
18169
|
-
const authProvider = new require$$
|
|
18170
|
-
authProvider.setComponent(new require$$
|
|
19766
|
+
const authProvider = new require$$0$2.Provider('auth-internal', container);
|
|
19767
|
+
authProvider.setComponent(new require$$0$2.Component('auth-internal', () => customAuthImpl, "PRIVATE" /* ComponentType.PRIVATE */));
|
|
18171
19768
|
let appCheckProvider = undefined;
|
|
18172
19769
|
if (customAppCheckImpl) {
|
|
18173
|
-
appCheckProvider = new require$$
|
|
18174
|
-
appCheckProvider.setComponent(new require$$
|
|
19770
|
+
appCheckProvider = new require$$0$2.Provider('app-check-internal', container);
|
|
19771
|
+
appCheckProvider.setComponent(new require$$0$2.Component('app-check-internal', () => customAppCheckImpl, "PRIVATE" /* ComponentType.PRIVATE */));
|
|
18175
19772
|
}
|
|
18176
19773
|
return {
|
|
18177
19774
|
instance: new Database(_repoManagerDatabaseFromApp(app, authProvider, appCheckProvider, url, nodeAdmin), app),
|
|
@@ -18180,8 +19777,8 @@ function initStandalone$1({ app, url, version, customAuthImpl, customAppCheckImp
|
|
|
18180
19777
|
}
|
|
18181
19778
|
|
|
18182
19779
|
var INTERNAL = /*#__PURE__*/Object.freeze({
|
|
18183
|
-
|
|
18184
|
-
|
|
19780
|
+
__proto__: null,
|
|
19781
|
+
initStandalone: initStandalone$1
|
|
18185
19782
|
});
|
|
18186
19783
|
|
|
18187
19784
|
/**
|
|
@@ -18211,7 +19808,7 @@ const ServerValue = Database.ServerValue;
|
|
|
18211
19808
|
* @param nodeAdmin - true if the SDK is being initialized from Firebase Admin.
|
|
18212
19809
|
*/
|
|
18213
19810
|
function initStandalone(app, url, version, nodeAdmin = true) {
|
|
18214
|
-
require$$
|
|
19811
|
+
require$$2$3.CONSTANTS.NODE_ADMIN = nodeAdmin;
|
|
18215
19812
|
return initStandalone$1({
|
|
18216
19813
|
app,
|
|
18217
19814
|
url,
|