prompt-api-polyfill 1.12.1 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backends/firebase.js +462 -405
- package/dist/backends/gemini.js +12 -14
- package/dist/backends/openai.js +62 -64
- package/dist/backends/transformers.js +74 -62
- package/dist/chunks/{defaults-j68Er1oH.js → defaults-CzvdT-At.js} +12 -4
- package/dist/prompt-api-polyfill.js +276 -332
- package/package.json +2 -4
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { initializeApp as
|
|
2
|
-
import { VertexAIBackend as
|
|
3
|
-
import { P as
|
|
4
|
-
const
|
|
1
|
+
import { initializeApp as Ue } from "firebase/app";
|
|
2
|
+
import { VertexAIBackend as Ve, GoogleAIBackend as We, getAI as Ke, getGenerativeModel as je, InferenceMode as Ge, Schema as m } from "firebase/ai";
|
|
3
|
+
import { P as qe, D as Xe } from "../chunks/defaults-CzvdT-At.js";
|
|
4
|
+
const Ye = () => {
|
|
5
5
|
};
|
|
6
|
-
const
|
|
6
|
+
const _e = function(t) {
|
|
7
7
|
const e = [];
|
|
8
8
|
let r = 0;
|
|
9
9
|
for (let n = 0; n < t.length; n++) {
|
|
@@ -11,7 +11,7 @@ const be = function(t) {
|
|
|
11
11
|
s < 128 ? e[r++] = s : s < 2048 ? (e[r++] = s >> 6 | 192, e[r++] = s & 63 | 128) : (s & 64512) === 55296 && n + 1 < t.length && (t.charCodeAt(n + 1) & 64512) === 56320 ? (s = 65536 + ((s & 1023) << 10) + (t.charCodeAt(++n) & 1023), e[r++] = s >> 18 | 240, e[r++] = s >> 12 & 63 | 128, e[r++] = s >> 6 & 63 | 128, e[r++] = s & 63 | 128) : (e[r++] = s >> 12 | 224, e[r++] = s >> 6 & 63 | 128, e[r++] = s & 63 | 128);
|
|
12
12
|
}
|
|
13
13
|
return e;
|
|
14
|
-
},
|
|
14
|
+
}, Je = function(t) {
|
|
15
15
|
const e = [];
|
|
16
16
|
let r = 0, n = 0;
|
|
17
17
|
for (; r < t.length; ) {
|
|
@@ -30,7 +30,7 @@ const be = function(t) {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
return e.join("");
|
|
33
|
-
},
|
|
33
|
+
}, Y = {
|
|
34
34
|
/**
|
|
35
35
|
* Maps bytes to characters.
|
|
36
36
|
*/
|
|
@@ -90,8 +90,8 @@ const be = function(t) {
|
|
|
90
90
|
const r = e ? this.byteToCharMapWebSafe_ : this.byteToCharMap_, n = [];
|
|
91
91
|
for (let s = 0; s < t.length; s += 3) {
|
|
92
92
|
const o = t[s], i = s + 1 < t.length, c = i ? t[s + 1] : 0, a = s + 2 < t.length, l = a ? t[s + 2] : 0, p = o >> 2, f = (o & 3) << 4 | c >> 4;
|
|
93
|
-
let
|
|
94
|
-
a || (
|
|
93
|
+
let S = (c & 15) << 2 | l >> 6, v = l & 63;
|
|
94
|
+
a || (v = 64, i || (S = 64)), n.push(r[p], r[f], r[S], r[v]);
|
|
95
95
|
}
|
|
96
96
|
return n.join("");
|
|
97
97
|
},
|
|
@@ -104,7 +104,7 @@ const be = function(t) {
|
|
|
104
104
|
* @return The base64 encoded string.
|
|
105
105
|
*/
|
|
106
106
|
encodeString(t, e) {
|
|
107
|
-
return this.HAS_NATIVE_SUPPORT && !e ? btoa(t) : this.encodeByteArray(
|
|
107
|
+
return this.HAS_NATIVE_SUPPORT && !e ? btoa(t) : this.encodeByteArray(_e(t), e);
|
|
108
108
|
},
|
|
109
109
|
/**
|
|
110
110
|
* Base64-decode a string.
|
|
@@ -115,7 +115,7 @@ const be = function(t) {
|
|
|
115
115
|
* @return string representing the decoded value.
|
|
116
116
|
*/
|
|
117
117
|
decodeString(t, e) {
|
|
118
|
-
return this.HAS_NATIVE_SUPPORT && !e ? atob(t) :
|
|
118
|
+
return this.HAS_NATIVE_SUPPORT && !e ? atob(t) : Je(this.decodeStringToByteArray(t, e));
|
|
119
119
|
},
|
|
120
120
|
/**
|
|
121
121
|
* Base64-decode a string.
|
|
@@ -142,13 +142,13 @@ const be = function(t) {
|
|
|
142
142
|
++s;
|
|
143
143
|
const f = s < t.length ? r[t.charAt(s)] : 64;
|
|
144
144
|
if (++s, o == null || c == null || l == null || f == null)
|
|
145
|
-
throw new
|
|
146
|
-
const
|
|
147
|
-
if (n.push(
|
|
148
|
-
const
|
|
149
|
-
if (n.push(
|
|
150
|
-
const
|
|
151
|
-
n.push(
|
|
145
|
+
throw new Ze();
|
|
146
|
+
const S = o << 2 | c >> 4;
|
|
147
|
+
if (n.push(S), l !== 64) {
|
|
148
|
+
const v = c << 4 & 240 | l >> 2;
|
|
149
|
+
if (n.push(v), f !== 64) {
|
|
150
|
+
const ze = l << 6 & 192 | f;
|
|
151
|
+
n.push(ze);
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
}
|
|
@@ -167,25 +167,25 @@ const be = function(t) {
|
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
};
|
|
170
|
-
class
|
|
170
|
+
class Ze extends Error {
|
|
171
171
|
constructor() {
|
|
172
172
|
super(...arguments), this.name = "DecodeBase64StringError";
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
-
const
|
|
176
|
-
const e =
|
|
177
|
-
return
|
|
178
|
-
},
|
|
179
|
-
return
|
|
180
|
-
},
|
|
175
|
+
const Qe = function(t) {
|
|
176
|
+
const e = _e(t);
|
|
177
|
+
return Y.encodeByteArray(e, !0);
|
|
178
|
+
}, we = function(t) {
|
|
179
|
+
return Qe(t).replace(/\./g, "");
|
|
180
|
+
}, et = function(t) {
|
|
181
181
|
try {
|
|
182
|
-
return
|
|
182
|
+
return Y.decodeString(t, !0);
|
|
183
183
|
} catch (e) {
|
|
184
184
|
console.error("base64Decode failed: ", e);
|
|
185
185
|
}
|
|
186
186
|
return null;
|
|
187
187
|
};
|
|
188
|
-
function
|
|
188
|
+
function ye() {
|
|
189
189
|
if (typeof self < "u")
|
|
190
190
|
return self;
|
|
191
191
|
if (typeof window < "u")
|
|
@@ -194,13 +194,13 @@ function _e() {
|
|
|
194
194
|
return global;
|
|
195
195
|
throw new Error("Unable to locate global object.");
|
|
196
196
|
}
|
|
197
|
-
const
|
|
197
|
+
const tt = () => ye().__FIREBASE_DEFAULTS__, rt = () => {
|
|
198
198
|
if (typeof process > "u" || typeof process.env > "u")
|
|
199
199
|
return;
|
|
200
200
|
const t = process.env.__FIREBASE_DEFAULTS__;
|
|
201
201
|
if (t)
|
|
202
202
|
return JSON.parse(t);
|
|
203
|
-
},
|
|
203
|
+
}, nt = () => {
|
|
204
204
|
if (typeof document > "u")
|
|
205
205
|
return;
|
|
206
206
|
let t;
|
|
@@ -209,17 +209,17 @@ const Qe = () => _e().__FIREBASE_DEFAULTS__, et = () => {
|
|
|
209
209
|
} catch {
|
|
210
210
|
return;
|
|
211
211
|
}
|
|
212
|
-
const e = t &&
|
|
212
|
+
const e = t && et(t[1]);
|
|
213
213
|
return e && JSON.parse(e);
|
|
214
|
-
},
|
|
214
|
+
}, st = () => {
|
|
215
215
|
try {
|
|
216
|
-
return
|
|
216
|
+
return Ye() || tt() || rt() || nt();
|
|
217
217
|
} catch (t) {
|
|
218
218
|
console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${t}`);
|
|
219
219
|
return;
|
|
220
220
|
}
|
|
221
|
-
},
|
|
222
|
-
class
|
|
221
|
+
}, Ae = () => st()?.config;
|
|
222
|
+
class I {
|
|
223
223
|
constructor() {
|
|
224
224
|
this.reject = () => {
|
|
225
225
|
}, this.resolve = () => {
|
|
@@ -239,14 +239,14 @@ class A {
|
|
|
239
239
|
};
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
|
-
function
|
|
242
|
+
function J() {
|
|
243
243
|
try {
|
|
244
244
|
return typeof indexedDB == "object";
|
|
245
245
|
} catch {
|
|
246
246
|
return !1;
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
|
-
function
|
|
249
|
+
function ot() {
|
|
250
250
|
return new Promise((t, e) => {
|
|
251
251
|
try {
|
|
252
252
|
let r = !0;
|
|
@@ -263,29 +263,29 @@ function nt() {
|
|
|
263
263
|
}
|
|
264
264
|
});
|
|
265
265
|
}
|
|
266
|
-
const
|
|
267
|
-
class
|
|
266
|
+
const it = "FirebaseError";
|
|
267
|
+
class k extends Error {
|
|
268
268
|
constructor(e, r, n) {
|
|
269
|
-
super(r), this.code = e, this.customData = n, this.name =
|
|
269
|
+
super(r), this.code = e, this.customData = n, this.name = it, Object.setPrototypeOf(this, k.prototype), Error.captureStackTrace && Error.captureStackTrace(this, Z.prototype.create);
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
|
-
class
|
|
272
|
+
class Z {
|
|
273
273
|
constructor(e, r, n) {
|
|
274
274
|
this.service = e, this.serviceName = r, this.errors = n;
|
|
275
275
|
}
|
|
276
276
|
create(e, ...r) {
|
|
277
|
-
const n = r[0] || {}, s = `${this.service}/${e}`, o = this.errors[e], i = o ?
|
|
278
|
-
return new
|
|
277
|
+
const n = r[0] || {}, s = `${this.service}/${e}`, o = this.errors[e], i = o ? at(o, n) : "Error", c = `${this.serviceName}: ${i} (${s}).`;
|
|
278
|
+
return new k(s, c, n);
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
|
-
function
|
|
282
|
-
return t.replace(
|
|
281
|
+
function at(t, e) {
|
|
282
|
+
return t.replace(ct, (r, n) => {
|
|
283
283
|
const s = e[n];
|
|
284
284
|
return s != null ? String(s) : `<${n}?>`;
|
|
285
285
|
});
|
|
286
286
|
}
|
|
287
|
-
const
|
|
288
|
-
function
|
|
287
|
+
const ct = /\{\$([^}]+)}/g;
|
|
288
|
+
function z(t, e) {
|
|
289
289
|
if (t === e)
|
|
290
290
|
return !0;
|
|
291
291
|
const r = Object.keys(t), n = Object.keys(e);
|
|
@@ -293,8 +293,8 @@ function F(t, e) {
|
|
|
293
293
|
if (!n.includes(s))
|
|
294
294
|
return !1;
|
|
295
295
|
const o = t[s], i = e[s];
|
|
296
|
-
if (
|
|
297
|
-
if (!
|
|
296
|
+
if (oe(o) && oe(i)) {
|
|
297
|
+
if (!z(o, i))
|
|
298
298
|
return !1;
|
|
299
299
|
} else if (o !== i)
|
|
300
300
|
return !1;
|
|
@@ -304,24 +304,24 @@ function F(t, e) {
|
|
|
304
304
|
return !1;
|
|
305
305
|
return !0;
|
|
306
306
|
}
|
|
307
|
-
function
|
|
307
|
+
function oe(t) {
|
|
308
308
|
return t !== null && typeof t == "object";
|
|
309
309
|
}
|
|
310
|
-
const
|
|
311
|
-
function
|
|
310
|
+
const lt = 1e3, ht = 2, dt = 14400 * 1e3, ut = 0.5;
|
|
311
|
+
function ft(t, e = lt, r = ht) {
|
|
312
312
|
const n = e * Math.pow(r, t), s = Math.round(
|
|
313
313
|
// A fraction of the backoff value to add/subtract.
|
|
314
314
|
// Deviation: changes multiplication order to improve readability.
|
|
315
|
-
|
|
315
|
+
ut * n * // A random float (rounded to int by Math.round above) in the range [-1, 1]. Determines
|
|
316
316
|
// if we add or subtract.
|
|
317
317
|
(Math.random() - 0.5) * 2
|
|
318
318
|
);
|
|
319
|
-
return Math.min(
|
|
319
|
+
return Math.min(dt, n + s);
|
|
320
320
|
}
|
|
321
|
-
function
|
|
321
|
+
function pt(t) {
|
|
322
322
|
return t && t._delegate ? t._delegate : t;
|
|
323
323
|
}
|
|
324
|
-
class
|
|
324
|
+
class A {
|
|
325
325
|
/**
|
|
326
326
|
*
|
|
327
327
|
* @param name The public service name, e.g. app, auth, firestore, database
|
|
@@ -344,8 +344,8 @@ class y {
|
|
|
344
344
|
return this.onInstanceCreated = e, this;
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
|
-
const
|
|
348
|
-
class
|
|
347
|
+
const w = "[DEFAULT]";
|
|
348
|
+
class gt {
|
|
349
349
|
constructor(e, r) {
|
|
350
350
|
this.name = e, this.container = r, this.component = null, this.instances = /* @__PURE__ */ new Map(), this.instancesDeferred = /* @__PURE__ */ new Map(), this.instancesOptions = /* @__PURE__ */ new Map(), this.onInitCallbacks = /* @__PURE__ */ new Map();
|
|
351
351
|
}
|
|
@@ -356,7 +356,7 @@ class ft {
|
|
|
356
356
|
get(e) {
|
|
357
357
|
const r = this.normalizeInstanceIdentifier(e);
|
|
358
358
|
if (!this.instancesDeferred.has(r)) {
|
|
359
|
-
const n = new
|
|
359
|
+
const n = new I();
|
|
360
360
|
if (this.instancesDeferred.set(r, n), this.isInitialized(r) || this.shouldAutoInitialize())
|
|
361
361
|
try {
|
|
362
362
|
const s = this.getOrInitializeService({
|
|
@@ -395,9 +395,9 @@ class ft {
|
|
|
395
395
|
if (this.component)
|
|
396
396
|
throw Error(`Component for ${this.name} has already been provided`);
|
|
397
397
|
if (this.component = e, !!this.shouldAutoInitialize()) {
|
|
398
|
-
if (
|
|
398
|
+
if (bt(e))
|
|
399
399
|
try {
|
|
400
|
-
this.getOrInitializeService({ instanceIdentifier:
|
|
400
|
+
this.getOrInitializeService({ instanceIdentifier: w });
|
|
401
401
|
} catch {
|
|
402
402
|
}
|
|
403
403
|
for (const [r, n] of this.instancesDeferred.entries()) {
|
|
@@ -412,7 +412,7 @@ class ft {
|
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
414
|
}
|
|
415
|
-
clearInstance(e =
|
|
415
|
+
clearInstance(e = w) {
|
|
416
416
|
this.instancesDeferred.delete(e), this.instancesOptions.delete(e), this.instances.delete(e);
|
|
417
417
|
}
|
|
418
418
|
// app.delete() will call this method on every provider to delete the services
|
|
@@ -427,10 +427,10 @@ class ft {
|
|
|
427
427
|
isComponentSet() {
|
|
428
428
|
return this.component != null;
|
|
429
429
|
}
|
|
430
|
-
isInitialized(e =
|
|
430
|
+
isInitialized(e = w) {
|
|
431
431
|
return this.instances.has(e);
|
|
432
432
|
}
|
|
433
|
-
getOptions(e =
|
|
433
|
+
getOptions(e = w) {
|
|
434
434
|
return this.instancesOptions.get(e) || {};
|
|
435
435
|
}
|
|
436
436
|
initialize(e = {}) {
|
|
@@ -481,7 +481,7 @@ class ft {
|
|
|
481
481
|
getOrInitializeService({ instanceIdentifier: e, options: r = {} }) {
|
|
482
482
|
let n = this.instances.get(e);
|
|
483
483
|
if (!n && this.component && (n = this.component.instanceFactory(this.container, {
|
|
484
|
-
instanceIdentifier:
|
|
484
|
+
instanceIdentifier: mt(e),
|
|
485
485
|
options: r
|
|
486
486
|
}), this.instances.set(e, n), this.instancesOptions.set(e, r), this.invokeOnInitCallbacks(n, e), this.component.onInstanceCreated))
|
|
487
487
|
try {
|
|
@@ -490,20 +490,20 @@ class ft {
|
|
|
490
490
|
}
|
|
491
491
|
return n || null;
|
|
492
492
|
}
|
|
493
|
-
normalizeInstanceIdentifier(e =
|
|
494
|
-
return this.component ? this.component.multipleInstances ? e :
|
|
493
|
+
normalizeInstanceIdentifier(e = w) {
|
|
494
|
+
return this.component ? this.component.multipleInstances ? e : w : e;
|
|
495
495
|
}
|
|
496
496
|
shouldAutoInitialize() {
|
|
497
497
|
return !!this.component && this.component.instantiationMode !== "EXPLICIT";
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
|
-
function
|
|
501
|
-
return t ===
|
|
500
|
+
function mt(t) {
|
|
501
|
+
return t === w ? void 0 : t;
|
|
502
502
|
}
|
|
503
|
-
function
|
|
503
|
+
function bt(t) {
|
|
504
504
|
return t.instantiationMode === "EAGER";
|
|
505
505
|
}
|
|
506
|
-
class
|
|
506
|
+
class Et {
|
|
507
507
|
constructor(e) {
|
|
508
508
|
this.name = e, this.providers = /* @__PURE__ */ new Map();
|
|
509
509
|
}
|
|
@@ -535,7 +535,7 @@ class mt {
|
|
|
535
535
|
getProvider(e) {
|
|
536
536
|
if (this.providers.has(e))
|
|
537
537
|
return this.providers.get(e);
|
|
538
|
-
const r = new
|
|
538
|
+
const r = new gt(e, this);
|
|
539
539
|
return this.providers.set(e, r), r;
|
|
540
540
|
}
|
|
541
541
|
getProviders() {
|
|
@@ -546,29 +546,29 @@ var h;
|
|
|
546
546
|
(function(t) {
|
|
547
547
|
t[t.DEBUG = 0] = "DEBUG", t[t.VERBOSE = 1] = "VERBOSE", t[t.INFO = 2] = "INFO", t[t.WARN = 3] = "WARN", t[t.ERROR = 4] = "ERROR", t[t.SILENT = 5] = "SILENT";
|
|
548
548
|
})(h || (h = {}));
|
|
549
|
-
const
|
|
549
|
+
const _t = {
|
|
550
550
|
debug: h.DEBUG,
|
|
551
551
|
verbose: h.VERBOSE,
|
|
552
552
|
info: h.INFO,
|
|
553
553
|
warn: h.WARN,
|
|
554
554
|
error: h.ERROR,
|
|
555
555
|
silent: h.SILENT
|
|
556
|
-
},
|
|
556
|
+
}, wt = h.INFO, yt = {
|
|
557
557
|
[h.DEBUG]: "log",
|
|
558
558
|
[h.VERBOSE]: "log",
|
|
559
559
|
[h.INFO]: "info",
|
|
560
560
|
[h.WARN]: "warn",
|
|
561
561
|
[h.ERROR]: "error"
|
|
562
|
-
},
|
|
562
|
+
}, At = (t, e, ...r) => {
|
|
563
563
|
if (e < t.logLevel)
|
|
564
564
|
return;
|
|
565
|
-
const n = (/* @__PURE__ */ new Date()).toISOString(), s =
|
|
565
|
+
const n = (/* @__PURE__ */ new Date()).toISOString(), s = yt[e];
|
|
566
566
|
if (s)
|
|
567
567
|
console[s](`[${n}] ${t.name}:`, ...r);
|
|
568
568
|
else
|
|
569
569
|
throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`);
|
|
570
570
|
};
|
|
571
|
-
class
|
|
571
|
+
class Ie {
|
|
572
572
|
/**
|
|
573
573
|
* Gives you an instance of a Logger to capture messages according to
|
|
574
574
|
* Firebase's logging scheme.
|
|
@@ -576,7 +576,7 @@ class ye {
|
|
|
576
576
|
* @param name The name that the logs will be associated with
|
|
577
577
|
*/
|
|
578
578
|
constructor(e) {
|
|
579
|
-
this.name = e, this._logLevel =
|
|
579
|
+
this.name = e, this._logLevel = wt, this._logHandler = At, this._userLogHandler = null;
|
|
580
580
|
}
|
|
581
581
|
get logLevel() {
|
|
582
582
|
return this._logLevel;
|
|
@@ -588,7 +588,7 @@ class ye {
|
|
|
588
588
|
}
|
|
589
589
|
// Workaround for setter/getter having to be the same type.
|
|
590
590
|
setLogLevel(e) {
|
|
591
|
-
this._logLevel = typeof e == "string" ?
|
|
591
|
+
this._logLevel = typeof e == "string" ? _t[e] : e;
|
|
592
592
|
}
|
|
593
593
|
get logHandler() {
|
|
594
594
|
return this._logHandler;
|
|
@@ -623,10 +623,10 @@ class ye {
|
|
|
623
623
|
this._userLogHandler && this._userLogHandler(this, h.ERROR, ...e), this._logHandler(this, h.ERROR, ...e);
|
|
624
624
|
}
|
|
625
625
|
}
|
|
626
|
-
const
|
|
627
|
-
let
|
|
628
|
-
function
|
|
629
|
-
return
|
|
626
|
+
const It = (t, e) => e.some((r) => t instanceof r);
|
|
627
|
+
let ie, ae;
|
|
628
|
+
function Tt() {
|
|
629
|
+
return ie || (ie = [
|
|
630
630
|
IDBDatabase,
|
|
631
631
|
IDBObjectStore,
|
|
632
632
|
IDBIndex,
|
|
@@ -634,32 +634,32 @@ function At() {
|
|
|
634
634
|
IDBTransaction
|
|
635
635
|
]);
|
|
636
636
|
}
|
|
637
|
-
function
|
|
638
|
-
return
|
|
637
|
+
function Ct() {
|
|
638
|
+
return ae || (ae = [
|
|
639
639
|
IDBCursor.prototype.advance,
|
|
640
640
|
IDBCursor.prototype.continue,
|
|
641
641
|
IDBCursor.prototype.continuePrimaryKey
|
|
642
642
|
]);
|
|
643
643
|
}
|
|
644
|
-
const
|
|
645
|
-
function
|
|
644
|
+
const Te = /* @__PURE__ */ new WeakMap(), U = /* @__PURE__ */ new WeakMap(), Ce = /* @__PURE__ */ new WeakMap(), N = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new WeakMap();
|
|
645
|
+
function Dt(t) {
|
|
646
646
|
const e = new Promise((r, n) => {
|
|
647
647
|
const s = () => {
|
|
648
648
|
t.removeEventListener("success", o), t.removeEventListener("error", i);
|
|
649
649
|
}, o = () => {
|
|
650
|
-
r(
|
|
650
|
+
r(E(t.result)), s();
|
|
651
651
|
}, i = () => {
|
|
652
652
|
n(t.error), s();
|
|
653
653
|
};
|
|
654
654
|
t.addEventListener("success", o), t.addEventListener("error", i);
|
|
655
655
|
});
|
|
656
656
|
return e.then((r) => {
|
|
657
|
-
r instanceof IDBCursor &&
|
|
657
|
+
r instanceof IDBCursor && Te.set(r, t);
|
|
658
658
|
}).catch(() => {
|
|
659
|
-
}),
|
|
659
|
+
}), Q.set(e, t), e;
|
|
660
660
|
}
|
|
661
|
-
function
|
|
662
|
-
if (
|
|
661
|
+
function kt(t) {
|
|
662
|
+
if (U.has(t))
|
|
663
663
|
return;
|
|
664
664
|
const e = new Promise((r, n) => {
|
|
665
665
|
const s = () => {
|
|
@@ -671,19 +671,19 @@ function Ct(t) {
|
|
|
671
671
|
};
|
|
672
672
|
t.addEventListener("complete", o), t.addEventListener("error", i), t.addEventListener("abort", i);
|
|
673
673
|
});
|
|
674
|
-
|
|
674
|
+
U.set(t, e);
|
|
675
675
|
}
|
|
676
|
-
let
|
|
676
|
+
let V = {
|
|
677
677
|
get(t, e, r) {
|
|
678
678
|
if (t instanceof IDBTransaction) {
|
|
679
679
|
if (e === "done")
|
|
680
|
-
return
|
|
680
|
+
return U.get(t);
|
|
681
681
|
if (e === "objectStoreNames")
|
|
682
|
-
return t.objectStoreNames ||
|
|
682
|
+
return t.objectStoreNames || Ce.get(t);
|
|
683
683
|
if (e === "store")
|
|
684
684
|
return r.objectStoreNames[1] ? void 0 : r.objectStore(r.objectStoreNames[0]);
|
|
685
685
|
}
|
|
686
|
-
return
|
|
686
|
+
return E(t[e]);
|
|
687
687
|
},
|
|
688
688
|
set(t, e, r) {
|
|
689
689
|
return t[e] = r, !0;
|
|
@@ -692,35 +692,35 @@ let U = {
|
|
|
692
692
|
return t instanceof IDBTransaction && (e === "done" || e === "store") ? !0 : e in t;
|
|
693
693
|
}
|
|
694
694
|
};
|
|
695
|
-
function
|
|
696
|
-
|
|
695
|
+
function St(t) {
|
|
696
|
+
V = t(V);
|
|
697
697
|
}
|
|
698
|
-
function
|
|
698
|
+
function vt(t) {
|
|
699
699
|
return t === IDBDatabase.prototype.transaction && !("objectStoreNames" in IDBTransaction.prototype) ? function(e, ...r) {
|
|
700
|
-
const n = t.call(
|
|
701
|
-
return
|
|
702
|
-
} :
|
|
703
|
-
return t.apply(
|
|
700
|
+
const n = t.call($(this), e, ...r);
|
|
701
|
+
return Ce.set(n, e.sort ? e.sort() : [e]), E(n);
|
|
702
|
+
} : Ct().includes(t) ? function(...e) {
|
|
703
|
+
return t.apply($(this), e), E(Te.get(this));
|
|
704
704
|
} : function(...e) {
|
|
705
|
-
return
|
|
705
|
+
return E(t.apply($(this), e));
|
|
706
706
|
};
|
|
707
707
|
}
|
|
708
|
-
function
|
|
709
|
-
return typeof t == "function" ?
|
|
708
|
+
function Rt(t) {
|
|
709
|
+
return typeof t == "function" ? vt(t) : (t instanceof IDBTransaction && kt(t), It(t, Tt()) ? new Proxy(t, V) : t);
|
|
710
710
|
}
|
|
711
|
-
function
|
|
711
|
+
function E(t) {
|
|
712
712
|
if (t instanceof IDBRequest)
|
|
713
|
-
return
|
|
714
|
-
if (
|
|
715
|
-
return
|
|
716
|
-
const e =
|
|
717
|
-
return e !== t && (
|
|
718
|
-
}
|
|
719
|
-
const
|
|
720
|
-
function
|
|
721
|
-
const i = indexedDB.open(t, e), c =
|
|
713
|
+
return Dt(t);
|
|
714
|
+
if (N.has(t))
|
|
715
|
+
return N.get(t);
|
|
716
|
+
const e = Rt(t);
|
|
717
|
+
return e !== t && (N.set(t, e), Q.set(e, t)), e;
|
|
718
|
+
}
|
|
719
|
+
const $ = (t) => Q.get(t);
|
|
720
|
+
function Bt(t, e, { blocked: r, upgrade: n, blocking: s, terminated: o } = {}) {
|
|
721
|
+
const i = indexedDB.open(t, e), c = E(i);
|
|
722
722
|
return n && i.addEventListener("upgradeneeded", (a) => {
|
|
723
|
-
n(
|
|
723
|
+
n(E(i.result), a.oldVersion, a.newVersion, E(i.transaction), a);
|
|
724
724
|
}), r && i.addEventListener("blocked", (a) => r(
|
|
725
725
|
// Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405
|
|
726
726
|
a.oldVersion,
|
|
@@ -731,16 +731,16 @@ function vt(t, e, { blocked: r, upgrade: n, blocking: s, terminated: o } = {}) {
|
|
|
731
731
|
}).catch(() => {
|
|
732
732
|
}), c;
|
|
733
733
|
}
|
|
734
|
-
const
|
|
735
|
-
function
|
|
734
|
+
const Pt = ["get", "getKey", "getAll", "getAllKeys", "count"], Mt = ["put", "add", "delete", "clear"], x = /* @__PURE__ */ new Map();
|
|
735
|
+
function ce(t, e) {
|
|
736
736
|
if (!(t instanceof IDBDatabase && !(e in t) && typeof e == "string"))
|
|
737
737
|
return;
|
|
738
|
-
if (
|
|
739
|
-
return
|
|
740
|
-
const r = e.replace(/FromIndex$/, ""), n = e !== r, s =
|
|
738
|
+
if (x.get(e))
|
|
739
|
+
return x.get(e);
|
|
740
|
+
const r = e.replace(/FromIndex$/, ""), n = e !== r, s = Mt.includes(r);
|
|
741
741
|
if (
|
|
742
742
|
// Bail if the target doesn't exist on the target. Eg, getAll isn't in Edge.
|
|
743
|
-
!(r in (n ? IDBIndex : IDBObjectStore).prototype) || !(s ||
|
|
743
|
+
!(r in (n ? IDBIndex : IDBObjectStore).prototype) || !(s || Pt.includes(r))
|
|
744
744
|
)
|
|
745
745
|
return;
|
|
746
746
|
const o = async function(i, ...c) {
|
|
@@ -751,14 +751,14 @@ function ie(t, e) {
|
|
|
751
751
|
s && a.done
|
|
752
752
|
]))[0];
|
|
753
753
|
};
|
|
754
|
-
return
|
|
754
|
+
return x.set(e, o), o;
|
|
755
755
|
}
|
|
756
|
-
|
|
756
|
+
St((t) => ({
|
|
757
757
|
...t,
|
|
758
|
-
get: (e, r, n) =>
|
|
759
|
-
has: (e, r) => !!
|
|
758
|
+
get: (e, r, n) => ce(e, r) || t.get(e, r, n),
|
|
759
|
+
has: (e, r) => !!ce(e, r) || t.has(e, r)
|
|
760
760
|
}));
|
|
761
|
-
class
|
|
761
|
+
class Ot {
|
|
762
762
|
constructor(e) {
|
|
763
763
|
this.container = e;
|
|
764
764
|
}
|
|
@@ -766,7 +766,7 @@ class Pt {
|
|
|
766
766
|
// auth token refresh, and installations will send this string.
|
|
767
767
|
getPlatformInfoString() {
|
|
768
768
|
return this.container.getProviders().map((r) => {
|
|
769
|
-
if (
|
|
769
|
+
if (Nt(r)) {
|
|
770
770
|
const n = r.getImmediate();
|
|
771
771
|
return `${n.library}/${n.version}`;
|
|
772
772
|
} else
|
|
@@ -774,66 +774,66 @@ class Pt {
|
|
|
774
774
|
}).filter((r) => r).join(" ");
|
|
775
775
|
}
|
|
776
776
|
}
|
|
777
|
-
function
|
|
777
|
+
function Nt(t) {
|
|
778
778
|
return t.getComponent()?.type === "VERSION";
|
|
779
779
|
}
|
|
780
|
-
const
|
|
781
|
-
const g = new
|
|
782
|
-
const
|
|
783
|
-
[
|
|
784
|
-
[
|
|
785
|
-
[
|
|
786
|
-
[
|
|
787
|
-
[
|
|
788
|
-
[
|
|
789
|
-
[
|
|
790
|
-
[
|
|
791
|
-
[
|
|
792
|
-
[
|
|
793
|
-
[
|
|
794
|
-
[
|
|
795
|
-
[
|
|
796
|
-
[
|
|
797
|
-
[
|
|
798
|
-
[
|
|
799
|
-
[
|
|
800
|
-
[
|
|
801
|
-
[
|
|
802
|
-
[
|
|
803
|
-
[
|
|
804
|
-
[
|
|
805
|
-
[
|
|
806
|
-
[
|
|
807
|
-
[
|
|
808
|
-
[
|
|
780
|
+
const W = "@firebase/app", le = "0.14.9";
|
|
781
|
+
const g = new Ie("@firebase/app"), $t = "@firebase/app-compat", xt = "@firebase/analytics-compat", Lt = "@firebase/analytics", Ht = "@firebase/app-check-compat", Ft = "@firebase/app-check", zt = "@firebase/auth", Ut = "@firebase/auth-compat", Vt = "@firebase/database", Wt = "@firebase/data-connect", Kt = "@firebase/database-compat", jt = "@firebase/functions", Gt = "@firebase/functions-compat", qt = "@firebase/installations", Xt = "@firebase/installations-compat", Yt = "@firebase/messaging", Jt = "@firebase/messaging-compat", Zt = "@firebase/performance", Qt = "@firebase/performance-compat", er = "@firebase/remote-config", tr = "@firebase/remote-config-compat", rr = "@firebase/storage", nr = "@firebase/storage-compat", sr = "@firebase/firestore", or = "@firebase/ai", ir = "@firebase/firestore-compat", ar = "firebase";
|
|
782
|
+
const K = "[DEFAULT]", cr = {
|
|
783
|
+
[W]: "fire-core",
|
|
784
|
+
[$t]: "fire-core-compat",
|
|
785
|
+
[Lt]: "fire-analytics",
|
|
786
|
+
[xt]: "fire-analytics-compat",
|
|
787
|
+
[Ft]: "fire-app-check",
|
|
788
|
+
[Ht]: "fire-app-check-compat",
|
|
789
|
+
[zt]: "fire-auth",
|
|
790
|
+
[Ut]: "fire-auth-compat",
|
|
791
|
+
[Vt]: "fire-rtdb",
|
|
792
|
+
[Wt]: "fire-data-connect",
|
|
793
|
+
[Kt]: "fire-rtdb-compat",
|
|
794
|
+
[jt]: "fire-fn",
|
|
795
|
+
[Gt]: "fire-fn-compat",
|
|
796
|
+
[qt]: "fire-iid",
|
|
797
|
+
[Xt]: "fire-iid-compat",
|
|
798
|
+
[Yt]: "fire-fcm",
|
|
799
|
+
[Jt]: "fire-fcm-compat",
|
|
800
|
+
[Zt]: "fire-perf",
|
|
801
|
+
[Qt]: "fire-perf-compat",
|
|
802
|
+
[er]: "fire-rc",
|
|
803
|
+
[tr]: "fire-rc-compat",
|
|
804
|
+
[rr]: "fire-gcs",
|
|
805
|
+
[nr]: "fire-gcs-compat",
|
|
806
|
+
[sr]: "fire-fst",
|
|
807
|
+
[ir]: "fire-fst-compat",
|
|
808
|
+
[or]: "fire-vertex",
|
|
809
809
|
"fire-js": "fire-js",
|
|
810
810
|
// Platform identifier for JS SDK.
|
|
811
|
-
[
|
|
811
|
+
[ar]: "fire-js-all"
|
|
812
812
|
};
|
|
813
|
-
const
|
|
814
|
-
function
|
|
813
|
+
const M = /* @__PURE__ */ new Map(), lr = /* @__PURE__ */ new Map(), j = /* @__PURE__ */ new Map();
|
|
814
|
+
function he(t, e) {
|
|
815
815
|
try {
|
|
816
816
|
t.container.addComponent(e);
|
|
817
817
|
} catch (r) {
|
|
818
818
|
g.debug(`Component ${e.name} failed to register with FirebaseApp ${t.name}`, r);
|
|
819
819
|
}
|
|
820
820
|
}
|
|
821
|
-
function
|
|
821
|
+
function T(t) {
|
|
822
822
|
const e = t.name;
|
|
823
|
-
if (
|
|
823
|
+
if (j.has(e))
|
|
824
824
|
return g.debug(`There were multiple attempts to register component ${e}.`), !1;
|
|
825
|
-
|
|
826
|
-
for (const r of
|
|
827
|
-
|
|
828
|
-
for (const r of
|
|
829
|
-
|
|
825
|
+
j.set(e, t);
|
|
826
|
+
for (const r of M.values())
|
|
827
|
+
he(r, t);
|
|
828
|
+
for (const r of lr.values())
|
|
829
|
+
he(r, t);
|
|
830
830
|
return !0;
|
|
831
831
|
}
|
|
832
|
-
function
|
|
832
|
+
function De(t, e) {
|
|
833
833
|
const r = t.container.getProvider("heartbeat").getImmediate({ optional: !0 });
|
|
834
834
|
return r && r.triggerHeartbeat(), t.container.getProvider(e);
|
|
835
835
|
}
|
|
836
|
-
const
|
|
836
|
+
const hr = {
|
|
837
837
|
"no-app": "No Firebase App '{$appName}' has been created - call initializeApp() first",
|
|
838
838
|
"bad-app-name": "Illegal App name: '{$appName}'",
|
|
839
839
|
"duplicate-app": "Firebase App named '{$appName}' already exists with different options or config",
|
|
@@ -848,10 +848,10 @@ const cr = {
|
|
|
848
848
|
"idb-delete": "Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.",
|
|
849
849
|
"finalization-registry-not-supported": "FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.",
|
|
850
850
|
"invalid-server-app-environment": "FirebaseServerApp is not for use in browser environments."
|
|
851
|
-
},
|
|
852
|
-
class
|
|
851
|
+
}, _ = new Z("app", "Firebase", hr);
|
|
852
|
+
class dr {
|
|
853
853
|
constructor(e, r, n) {
|
|
854
|
-
this._isDeleted = !1, this._options = { ...e }, this._config = { ...r }, this._name = r.name, this._automaticDataCollectionEnabled = r.automaticDataCollectionEnabled, this._container = n, this.container.addComponent(new
|
|
854
|
+
this._isDeleted = !1, this._options = { ...e }, this._config = { ...r }, this._name = r.name, this._automaticDataCollectionEnabled = r.automaticDataCollectionEnabled, this._container = n, this.container.addComponent(new A(
|
|
855
855
|
"app",
|
|
856
856
|
() => this,
|
|
857
857
|
"PUBLIC"
|
|
@@ -888,48 +888,48 @@ class lr {
|
|
|
888
888
|
*/
|
|
889
889
|
checkDestroyed() {
|
|
890
890
|
if (this.isDeleted)
|
|
891
|
-
throw
|
|
891
|
+
throw _.create("app-deleted", { appName: this._name });
|
|
892
892
|
}
|
|
893
893
|
}
|
|
894
|
-
function
|
|
894
|
+
function ur(t, e = {}) {
|
|
895
895
|
let r = t;
|
|
896
896
|
typeof e != "object" && (e = { name: e });
|
|
897
897
|
const n = {
|
|
898
|
-
name:
|
|
898
|
+
name: K,
|
|
899
899
|
automaticDataCollectionEnabled: !0,
|
|
900
900
|
...e
|
|
901
901
|
}, s = n.name;
|
|
902
902
|
if (typeof s != "string" || !s)
|
|
903
|
-
throw
|
|
903
|
+
throw _.create("bad-app-name", {
|
|
904
904
|
appName: String(s)
|
|
905
905
|
});
|
|
906
|
-
if (r || (r =
|
|
907
|
-
throw
|
|
906
|
+
if (r || (r = Ae()), !r)
|
|
907
|
+
throw _.create(
|
|
908
908
|
"no-options"
|
|
909
909
|
/* AppError.NO_OPTIONS */
|
|
910
910
|
);
|
|
911
|
-
const o =
|
|
911
|
+
const o = M.get(s);
|
|
912
912
|
if (o) {
|
|
913
|
-
if (
|
|
913
|
+
if (z(r, o.options) && z(n, o.config))
|
|
914
914
|
return o;
|
|
915
|
-
throw
|
|
915
|
+
throw _.create("duplicate-app", { appName: s });
|
|
916
916
|
}
|
|
917
|
-
const i = new
|
|
918
|
-
for (const a of
|
|
917
|
+
const i = new Et(s);
|
|
918
|
+
for (const a of j.values())
|
|
919
919
|
i.addComponent(a);
|
|
920
|
-
const c = new
|
|
921
|
-
return
|
|
920
|
+
const c = new dr(r, n, i);
|
|
921
|
+
return M.set(s, c), c;
|
|
922
922
|
}
|
|
923
|
-
function
|
|
924
|
-
const e =
|
|
925
|
-
if (!e && t ===
|
|
926
|
-
return
|
|
923
|
+
function fr(t = K) {
|
|
924
|
+
const e = M.get(t);
|
|
925
|
+
if (!e && t === K && Ae())
|
|
926
|
+
return ur();
|
|
927
927
|
if (!e)
|
|
928
|
-
throw
|
|
928
|
+
throw _.create("no-app", { appName: t });
|
|
929
929
|
return e;
|
|
930
930
|
}
|
|
931
|
-
function
|
|
932
|
-
let n =
|
|
931
|
+
function P(t, e, r) {
|
|
932
|
+
let n = cr[t] ?? t;
|
|
933
933
|
r && (n += `-${r}`);
|
|
934
934
|
const s = n.match(/\s|\//), o = e.match(/\s|\//);
|
|
935
935
|
if (s || o) {
|
|
@@ -939,72 +939,72 @@ function B(t, e, r) {
|
|
|
939
939
|
s && i.push(`library name "${n}" contains illegal characters (whitespace or "/")`), s && o && i.push("and"), o && i.push(`version name "${e}" contains illegal characters (whitespace or "/")`), g.warn(i.join(" "));
|
|
940
940
|
return;
|
|
941
941
|
}
|
|
942
|
-
|
|
942
|
+
T(new A(
|
|
943
943
|
`${n}-version`,
|
|
944
944
|
() => ({ library: n, version: e }),
|
|
945
945
|
"VERSION"
|
|
946
946
|
/* ComponentType.VERSION */
|
|
947
947
|
));
|
|
948
948
|
}
|
|
949
|
-
const
|
|
950
|
-
let
|
|
951
|
-
function
|
|
952
|
-
return
|
|
949
|
+
const pr = "firebase-heartbeat-database", gr = 1, C = "firebase-heartbeat-store";
|
|
950
|
+
let L = null;
|
|
951
|
+
function ke() {
|
|
952
|
+
return L || (L = Bt(pr, gr, {
|
|
953
953
|
upgrade: (t, e) => {
|
|
954
954
|
switch (e) {
|
|
955
955
|
case 0:
|
|
956
956
|
try {
|
|
957
|
-
t.createObjectStore(
|
|
957
|
+
t.createObjectStore(C);
|
|
958
958
|
} catch (r) {
|
|
959
959
|
console.warn(r);
|
|
960
960
|
}
|
|
961
961
|
}
|
|
962
962
|
}
|
|
963
963
|
}).catch((t) => {
|
|
964
|
-
throw
|
|
964
|
+
throw _.create("idb-open", {
|
|
965
965
|
originalErrorMessage: t.message
|
|
966
966
|
});
|
|
967
|
-
})),
|
|
967
|
+
})), L;
|
|
968
968
|
}
|
|
969
|
-
async function
|
|
969
|
+
async function mr(t) {
|
|
970
970
|
try {
|
|
971
|
-
const r = (await
|
|
971
|
+
const r = (await ke()).transaction(C), n = await r.objectStore(C).get(Se(t));
|
|
972
972
|
return await r.done, n;
|
|
973
973
|
} catch (e) {
|
|
974
|
-
if (e instanceof
|
|
974
|
+
if (e instanceof k)
|
|
975
975
|
g.warn(e.message);
|
|
976
976
|
else {
|
|
977
|
-
const r =
|
|
977
|
+
const r = _.create("idb-get", {
|
|
978
978
|
originalErrorMessage: e?.message
|
|
979
979
|
});
|
|
980
980
|
g.warn(r.message);
|
|
981
981
|
}
|
|
982
982
|
}
|
|
983
983
|
}
|
|
984
|
-
async function
|
|
984
|
+
async function de(t, e) {
|
|
985
985
|
try {
|
|
986
|
-
const n = (await
|
|
987
|
-
await n.objectStore(
|
|
986
|
+
const n = (await ke()).transaction(C, "readwrite");
|
|
987
|
+
await n.objectStore(C).put(e, Se(t)), await n.done;
|
|
988
988
|
} catch (r) {
|
|
989
|
-
if (r instanceof
|
|
989
|
+
if (r instanceof k)
|
|
990
990
|
g.warn(r.message);
|
|
991
991
|
else {
|
|
992
|
-
const n =
|
|
992
|
+
const n = _.create("idb-set", {
|
|
993
993
|
originalErrorMessage: r?.message
|
|
994
994
|
});
|
|
995
995
|
g.warn(n.message);
|
|
996
996
|
}
|
|
997
997
|
}
|
|
998
998
|
}
|
|
999
|
-
function
|
|
999
|
+
function Se(t) {
|
|
1000
1000
|
return `${t.name}!${t.options.appId}`;
|
|
1001
1001
|
}
|
|
1002
|
-
const
|
|
1003
|
-
class
|
|
1002
|
+
const br = 1024, Er = 30;
|
|
1003
|
+
class _r {
|
|
1004
1004
|
constructor(e) {
|
|
1005
1005
|
this.container = e, this._heartbeatsCache = null;
|
|
1006
1006
|
const r = this.container.getProvider("app").getImmediate();
|
|
1007
|
-
this._storage = new
|
|
1007
|
+
this._storage = new yr(r), this._heartbeatsCachePromise = this._storage.read().then((n) => (this._heartbeatsCache = n, n));
|
|
1008
1008
|
}
|
|
1009
1009
|
/**
|
|
1010
1010
|
* Called to report a heartbeat. The function will generate
|
|
@@ -1015,11 +1015,11 @@ class br {
|
|
|
1015
1015
|
*/
|
|
1016
1016
|
async triggerHeartbeat() {
|
|
1017
1017
|
try {
|
|
1018
|
-
const r = this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(), n =
|
|
1018
|
+
const r = this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(), n = ue();
|
|
1019
1019
|
if (this._heartbeatsCache?.heartbeats == null && (this._heartbeatsCache = await this._heartbeatsCachePromise, this._heartbeatsCache?.heartbeats == null) || this._heartbeatsCache.lastSentHeartbeatDate === n || this._heartbeatsCache.heartbeats.some((s) => s.date === n))
|
|
1020
1020
|
return;
|
|
1021
|
-
if (this._heartbeatsCache.heartbeats.push({ date: n, agent: r }), this._heartbeatsCache.heartbeats.length >
|
|
1022
|
-
const s =
|
|
1021
|
+
if (this._heartbeatsCache.heartbeats.push({ date: n, agent: r }), this._heartbeatsCache.heartbeats.length > Er) {
|
|
1022
|
+
const s = Ar(this._heartbeatsCache.heartbeats);
|
|
1023
1023
|
this._heartbeatsCache.heartbeats.splice(s, 1);
|
|
1024
1024
|
}
|
|
1025
1025
|
return this._storage.overwrite(this._heartbeatsCache);
|
|
@@ -1038,30 +1038,30 @@ class br {
|
|
|
1038
1038
|
try {
|
|
1039
1039
|
if (this._heartbeatsCache === null && await this._heartbeatsCachePromise, this._heartbeatsCache?.heartbeats == null || this._heartbeatsCache.heartbeats.length === 0)
|
|
1040
1040
|
return "";
|
|
1041
|
-
const e =
|
|
1041
|
+
const e = ue(), { heartbeatsToSend: r, unsentEntries: n } = wr(this._heartbeatsCache.heartbeats), s = we(JSON.stringify({ version: 2, heartbeats: r }));
|
|
1042
1042
|
return this._heartbeatsCache.lastSentHeartbeatDate = e, n.length > 0 ? (this._heartbeatsCache.heartbeats = n, await this._storage.overwrite(this._heartbeatsCache)) : (this._heartbeatsCache.heartbeats = [], this._storage.overwrite(this._heartbeatsCache)), s;
|
|
1043
1043
|
} catch (e) {
|
|
1044
1044
|
return g.warn(e), "";
|
|
1045
1045
|
}
|
|
1046
1046
|
}
|
|
1047
1047
|
}
|
|
1048
|
-
function
|
|
1048
|
+
function ue() {
|
|
1049
1049
|
return (/* @__PURE__ */ new Date()).toISOString().substring(0, 10);
|
|
1050
1050
|
}
|
|
1051
|
-
function
|
|
1051
|
+
function wr(t, e = br) {
|
|
1052
1052
|
const r = [];
|
|
1053
1053
|
let n = t.slice();
|
|
1054
1054
|
for (const s of t) {
|
|
1055
1055
|
const o = r.find((i) => i.agent === s.agent);
|
|
1056
1056
|
if (o) {
|
|
1057
|
-
if (o.dates.push(s.date),
|
|
1057
|
+
if (o.dates.push(s.date), fe(r) > e) {
|
|
1058
1058
|
o.dates.pop();
|
|
1059
1059
|
break;
|
|
1060
1060
|
}
|
|
1061
1061
|
} else if (r.push({
|
|
1062
1062
|
agent: s.agent,
|
|
1063
1063
|
dates: [s.date]
|
|
1064
|
-
}),
|
|
1064
|
+
}), fe(r) > e) {
|
|
1065
1065
|
r.pop();
|
|
1066
1066
|
break;
|
|
1067
1067
|
}
|
|
@@ -1072,19 +1072,19 @@ function Er(t, e = gr) {
|
|
|
1072
1072
|
unsentEntries: n
|
|
1073
1073
|
};
|
|
1074
1074
|
}
|
|
1075
|
-
class
|
|
1075
|
+
class yr {
|
|
1076
1076
|
constructor(e) {
|
|
1077
1077
|
this.app = e, this._canUseIndexedDBPromise = this.runIndexedDBEnvironmentCheck();
|
|
1078
1078
|
}
|
|
1079
1079
|
async runIndexedDBEnvironmentCheck() {
|
|
1080
|
-
return
|
|
1080
|
+
return J() ? ot().then(() => !0).catch(() => !1) : !1;
|
|
1081
1081
|
}
|
|
1082
1082
|
/**
|
|
1083
1083
|
* Read all heartbeats.
|
|
1084
1084
|
*/
|
|
1085
1085
|
async read() {
|
|
1086
1086
|
if (await this._canUseIndexedDBPromise) {
|
|
1087
|
-
const r = await
|
|
1087
|
+
const r = await mr(this.app);
|
|
1088
1088
|
return r?.heartbeats ? r : { heartbeats: [] };
|
|
1089
1089
|
} else
|
|
1090
1090
|
return { heartbeats: [] };
|
|
@@ -1093,7 +1093,7 @@ class _r {
|
|
|
1093
1093
|
async overwrite(e) {
|
|
1094
1094
|
if (await this._canUseIndexedDBPromise) {
|
|
1095
1095
|
const n = await this.read();
|
|
1096
|
-
return
|
|
1096
|
+
return de(this.app, {
|
|
1097
1097
|
lastSentHeartbeatDate: e.lastSentHeartbeatDate ?? n.lastSentHeartbeatDate,
|
|
1098
1098
|
heartbeats: e.heartbeats
|
|
1099
1099
|
});
|
|
@@ -1104,7 +1104,7 @@ class _r {
|
|
|
1104
1104
|
async add(e) {
|
|
1105
1105
|
if (await this._canUseIndexedDBPromise) {
|
|
1106
1106
|
const n = await this.read();
|
|
1107
|
-
return
|
|
1107
|
+
return de(this.app, {
|
|
1108
1108
|
lastSentHeartbeatDate: e.lastSentHeartbeatDate ?? n.lastSentHeartbeatDate,
|
|
1109
1109
|
heartbeats: [
|
|
1110
1110
|
...n.heartbeats,
|
|
@@ -1115,13 +1115,13 @@ class _r {
|
|
|
1115
1115
|
return;
|
|
1116
1116
|
}
|
|
1117
1117
|
}
|
|
1118
|
-
function
|
|
1119
|
-
return
|
|
1118
|
+
function fe(t) {
|
|
1119
|
+
return we(
|
|
1120
1120
|
// heartbeatsCache wrapper properties
|
|
1121
1121
|
JSON.stringify({ version: 2, heartbeats: t })
|
|
1122
1122
|
).length;
|
|
1123
1123
|
}
|
|
1124
|
-
function
|
|
1124
|
+
function Ar(t) {
|
|
1125
1125
|
if (t.length === 0)
|
|
1126
1126
|
return -1;
|
|
1127
1127
|
let e = 0, r = t[0].date;
|
|
@@ -1129,37 +1129,37 @@ function wr(t) {
|
|
|
1129
1129
|
t[n].date < r && (r = t[n].date, e = n);
|
|
1130
1130
|
return e;
|
|
1131
1131
|
}
|
|
1132
|
-
function
|
|
1133
|
-
|
|
1132
|
+
function Ir(t) {
|
|
1133
|
+
T(new A(
|
|
1134
1134
|
"platform-logger",
|
|
1135
|
-
(e) => new
|
|
1135
|
+
(e) => new Ot(e),
|
|
1136
1136
|
"PRIVATE"
|
|
1137
1137
|
/* ComponentType.PRIVATE */
|
|
1138
|
-
)),
|
|
1138
|
+
)), T(new A(
|
|
1139
1139
|
"heartbeat",
|
|
1140
|
-
(e) => new
|
|
1140
|
+
(e) => new _r(e),
|
|
1141
1141
|
"PRIVATE"
|
|
1142
1142
|
/* ComponentType.PRIVATE */
|
|
1143
|
-
)),
|
|
1143
|
+
)), P(W, le, t), P(W, le, "esm2020"), P("fire-js", "");
|
|
1144
1144
|
}
|
|
1145
|
-
|
|
1146
|
-
const
|
|
1145
|
+
Ir("");
|
|
1146
|
+
const G = /* @__PURE__ */ new Map(), ve = {
|
|
1147
1147
|
activated: !1,
|
|
1148
1148
|
tokenObservers: []
|
|
1149
|
-
},
|
|
1149
|
+
}, Tr = {
|
|
1150
1150
|
initialized: !1,
|
|
1151
1151
|
enabled: !1
|
|
1152
1152
|
};
|
|
1153
1153
|
function d(t) {
|
|
1154
|
-
return
|
|
1154
|
+
return G.get(t) || { ...ve };
|
|
1155
1155
|
}
|
|
1156
|
-
function
|
|
1157
|
-
return
|
|
1156
|
+
function Cr(t, e) {
|
|
1157
|
+
return G.set(t, e), G.get(t);
|
|
1158
1158
|
}
|
|
1159
|
-
function
|
|
1160
|
-
return
|
|
1159
|
+
function O() {
|
|
1160
|
+
return Tr;
|
|
1161
1161
|
}
|
|
1162
|
-
const
|
|
1162
|
+
const Re = "https://content-firebaseappcheck.googleapis.com/v1", Dr = "exchangeRecaptchaEnterpriseToken", kr = "exchangeDebugToken", pe = {
|
|
1163
1163
|
/**
|
|
1164
1164
|
* This is the first retrial wait after an error. This is currently
|
|
1165
1165
|
* 30 seconds.
|
|
@@ -1169,8 +1169,8 @@ const Se = "https://content-firebaseappcheck.googleapis.com/v1", Tr = "exchangeR
|
|
|
1169
1169
|
* This is the maximum retrial wait, currently 16 minutes.
|
|
1170
1170
|
*/
|
|
1171
1171
|
RETRIAL_MAX_WAIT: 960 * 1e3
|
|
1172
|
-
},
|
|
1173
|
-
class
|
|
1172
|
+
}, Sr = 1440 * 60 * 1e3;
|
|
1173
|
+
class vr {
|
|
1174
1174
|
constructor(e, r, n, s, o) {
|
|
1175
1175
|
if (this.operation = e, this.retryPolicy = r, this.getWaitDuration = n, this.lowerBound = s, this.upperBound = o, this.pending = null, this.nextErrorWaitInterval = s, s > o)
|
|
1176
1176
|
throw new Error("Proactive refresh lower bound greater than upper bound!");
|
|
@@ -1188,8 +1188,8 @@ class kr {
|
|
|
1188
1188
|
async process(e) {
|
|
1189
1189
|
this.stop();
|
|
1190
1190
|
try {
|
|
1191
|
-
this.pending = new
|
|
1192
|
-
}), await
|
|
1191
|
+
this.pending = new I(), this.pending.promise.catch((r) => {
|
|
1192
|
+
}), await Rr(this.getNextRun(e)), this.pending.resolve(), await this.pending.promise, this.pending = new I(), this.pending.promise.catch((r) => {
|
|
1193
1193
|
}), await this.operation(), this.pending.resolve(), await this.pending.promise, this.process(!0).catch(() => {
|
|
1194
1194
|
});
|
|
1195
1195
|
} catch (r) {
|
|
@@ -1206,12 +1206,12 @@ class kr {
|
|
|
1206
1206
|
}
|
|
1207
1207
|
}
|
|
1208
1208
|
}
|
|
1209
|
-
function
|
|
1209
|
+
function Rr(t) {
|
|
1210
1210
|
return new Promise((e) => {
|
|
1211
1211
|
setTimeout(e, t);
|
|
1212
1212
|
});
|
|
1213
1213
|
}
|
|
1214
|
-
const
|
|
1214
|
+
const Br = {
|
|
1215
1215
|
"already-initialized": "You have already called initializeAppCheck() for FirebaseApp {$appName} with different options. To avoid this error, call initializeAppCheck() with the same options as when it was originally called. This will return the already initialized instance.",
|
|
1216
1216
|
"use-before-activation": "App Check is being used before initializeAppCheck() is called for FirebaseApp {$appName}. Call initializeAppCheck() before instantiating other Firebase services.",
|
|
1217
1217
|
"fetch-network-error": "Fetch failed to connect to a network. Check Internet connection. Original error: {$originalErrorMessage}.",
|
|
@@ -1223,25 +1223,25 @@ const vr = {
|
|
|
1223
1223
|
"recaptcha-error": "ReCAPTCHA error.",
|
|
1224
1224
|
"initial-throttle": "{$httpStatus} error. Attempts allowed again after {$time}",
|
|
1225
1225
|
throttled: "Requests throttled due to previous {$httpStatus} error. Attempts allowed again after {$time}"
|
|
1226
|
-
}, u = new
|
|
1227
|
-
function
|
|
1226
|
+
}, u = new Z("appCheck", "AppCheck", Br);
|
|
1227
|
+
function ge(t = !1) {
|
|
1228
1228
|
return t ? self.grecaptcha?.enterprise : self.grecaptcha;
|
|
1229
1229
|
}
|
|
1230
|
-
function
|
|
1230
|
+
function ee(t) {
|
|
1231
1231
|
if (!d(t).activated)
|
|
1232
1232
|
throw u.create("use-before-activation", {
|
|
1233
1233
|
appName: t.name
|
|
1234
1234
|
});
|
|
1235
1235
|
}
|
|
1236
|
-
function
|
|
1236
|
+
function Be(t) {
|
|
1237
1237
|
const e = Math.round(t / 1e3), r = Math.floor(e / (3600 * 24)), n = Math.floor((e - r * 3600 * 24) / 3600), s = Math.floor((e - r * 3600 * 24 - n * 3600) / 60), o = e - r * 3600 * 24 - n * 3600 - s * 60;
|
|
1238
1238
|
let i = "";
|
|
1239
|
-
return r && (i +=
|
|
1239
|
+
return r && (i += R(r) + "d:"), n && (i += R(n) + "h:"), i += R(s) + "m:" + R(o) + "s", i;
|
|
1240
1240
|
}
|
|
1241
|
-
function
|
|
1241
|
+
function R(t) {
|
|
1242
1242
|
return t === 0 ? "00" : t >= 10 ? t.toString() : "0" + t;
|
|
1243
1243
|
}
|
|
1244
|
-
async function
|
|
1244
|
+
async function te({ url: t, body: e }, r) {
|
|
1245
1245
|
const n = {
|
|
1246
1246
|
"Content-Type": "application/json"
|
|
1247
1247
|
}, s = r.getImmediate({
|
|
@@ -1288,31 +1288,31 @@ async function Q({ url: t, body: e }, r) {
|
|
|
1288
1288
|
issuedAtTimeMillis: p
|
|
1289
1289
|
};
|
|
1290
1290
|
}
|
|
1291
|
-
function
|
|
1291
|
+
function Pr(t, e) {
|
|
1292
1292
|
const { projectId: r, appId: n, apiKey: s } = t.options;
|
|
1293
1293
|
return {
|
|
1294
|
-
url: `${
|
|
1294
|
+
url: `${Re}/projects/${r}/apps/${n}:${Dr}?key=${s}`,
|
|
1295
1295
|
body: {
|
|
1296
1296
|
recaptcha_enterprise_token: e
|
|
1297
1297
|
}
|
|
1298
1298
|
};
|
|
1299
1299
|
}
|
|
1300
|
-
function
|
|
1300
|
+
function Pe(t, e) {
|
|
1301
1301
|
const { projectId: r, appId: n, apiKey: s } = t.options;
|
|
1302
1302
|
return {
|
|
1303
|
-
url: `${
|
|
1303
|
+
url: `${Re}/projects/${r}/apps/${n}:${kr}?key=${s}`,
|
|
1304
1304
|
body: {
|
|
1305
1305
|
// eslint-disable-next-line
|
|
1306
1306
|
debug_token: e
|
|
1307
1307
|
}
|
|
1308
1308
|
};
|
|
1309
1309
|
}
|
|
1310
|
-
const
|
|
1311
|
-
let
|
|
1312
|
-
function
|
|
1313
|
-
return
|
|
1310
|
+
const Mr = "firebase-app-check-database", Or = 1, D = "firebase-app-check-store", Me = "debug-token";
|
|
1311
|
+
let B = null;
|
|
1312
|
+
function Oe() {
|
|
1313
|
+
return B || (B = new Promise((t, e) => {
|
|
1314
1314
|
try {
|
|
1315
|
-
const r = indexedDB.open(
|
|
1315
|
+
const r = indexedDB.open(Mr, Or);
|
|
1316
1316
|
r.onsuccess = (n) => {
|
|
1317
1317
|
t(n.target.result);
|
|
1318
1318
|
}, r.onerror = (n) => {
|
|
@@ -1321,7 +1321,7 @@ function Pe() {
|
|
|
1321
1321
|
}));
|
|
1322
1322
|
}, r.onupgradeneeded = (n) => {
|
|
1323
1323
|
const s = n.target.result;
|
|
1324
|
-
n.oldVersion === 0 && s.createObjectStore(
|
|
1324
|
+
n.oldVersion === 0 && s.createObjectStore(D, {
|
|
1325
1325
|
keyPath: "compositeKey"
|
|
1326
1326
|
});
|
|
1327
1327
|
};
|
|
@@ -1330,22 +1330,22 @@ function Pe() {
|
|
|
1330
1330
|
originalErrorMessage: r?.message
|
|
1331
1331
|
}));
|
|
1332
1332
|
}
|
|
1333
|
-
}),
|
|
1333
|
+
}), B);
|
|
1334
1334
|
}
|
|
1335
|
-
function
|
|
1336
|
-
return
|
|
1335
|
+
function Nr(t) {
|
|
1336
|
+
return $e(xe(t));
|
|
1337
1337
|
}
|
|
1338
|
-
function
|
|
1339
|
-
return
|
|
1338
|
+
function $r(t, e) {
|
|
1339
|
+
return Ne(xe(t), e);
|
|
1340
1340
|
}
|
|
1341
|
-
function
|
|
1342
|
-
return Me
|
|
1341
|
+
function xr(t) {
|
|
1342
|
+
return Ne(Me, t);
|
|
1343
1343
|
}
|
|
1344
|
-
function
|
|
1345
|
-
return
|
|
1344
|
+
function Lr() {
|
|
1345
|
+
return $e(Me);
|
|
1346
1346
|
}
|
|
1347
|
-
async function
|
|
1348
|
-
const n = (await
|
|
1347
|
+
async function Ne(t, e) {
|
|
1348
|
+
const n = (await Oe()).transaction(D, "readwrite"), o = n.objectStore(D).put({
|
|
1349
1349
|
compositeKey: t,
|
|
1350
1350
|
value: e
|
|
1351
1351
|
});
|
|
@@ -1359,8 +1359,8 @@ async function Me(t, e) {
|
|
|
1359
1359
|
};
|
|
1360
1360
|
});
|
|
1361
1361
|
}
|
|
1362
|
-
async function
|
|
1363
|
-
const r = (await
|
|
1362
|
+
async function $e(t) {
|
|
1363
|
+
const r = (await Oe()).transaction(D, "readonly"), s = r.objectStore(D).get(t);
|
|
1364
1364
|
return new Promise((o, i) => {
|
|
1365
1365
|
s.onsuccess = (c) => {
|
|
1366
1366
|
const a = c.target.result;
|
|
@@ -1372,151 +1372,151 @@ async function Oe(t) {
|
|
|
1372
1372
|
};
|
|
1373
1373
|
});
|
|
1374
1374
|
}
|
|
1375
|
-
function
|
|
1375
|
+
function xe(t) {
|
|
1376
1376
|
return `${t.options.appId}-${t.name}`;
|
|
1377
1377
|
}
|
|
1378
|
-
const
|
|
1379
|
-
async function
|
|
1380
|
-
if (
|
|
1378
|
+
const b = new Ie("@firebase/app-check");
|
|
1379
|
+
async function Hr(t) {
|
|
1380
|
+
if (J()) {
|
|
1381
1381
|
let e;
|
|
1382
1382
|
try {
|
|
1383
|
-
e = await
|
|
1383
|
+
e = await Nr(t);
|
|
1384
1384
|
} catch (r) {
|
|
1385
|
-
|
|
1385
|
+
b.warn(`Failed to read token from IndexedDB. Error: ${r}`);
|
|
1386
1386
|
}
|
|
1387
1387
|
return e;
|
|
1388
1388
|
}
|
|
1389
1389
|
}
|
|
1390
|
-
function
|
|
1391
|
-
return
|
|
1392
|
-
|
|
1390
|
+
function H(t, e) {
|
|
1391
|
+
return J() ? $r(t, e).catch((r) => {
|
|
1392
|
+
b.warn(`Failed to write token to IndexedDB. Error: ${r}`);
|
|
1393
1393
|
}) : Promise.resolve();
|
|
1394
1394
|
}
|
|
1395
|
-
async function
|
|
1395
|
+
async function Fr() {
|
|
1396
1396
|
let t;
|
|
1397
1397
|
try {
|
|
1398
|
-
t = await
|
|
1398
|
+
t = await Lr();
|
|
1399
1399
|
} catch {
|
|
1400
1400
|
}
|
|
1401
1401
|
if (t)
|
|
1402
1402
|
return t;
|
|
1403
1403
|
{
|
|
1404
1404
|
const e = crypto.randomUUID();
|
|
1405
|
-
return
|
|
1405
|
+
return xr(e).catch((r) => b.warn(`Failed to persist debug token to IndexedDB. Error: ${r}`)), e;
|
|
1406
1406
|
}
|
|
1407
1407
|
}
|
|
1408
|
-
function
|
|
1409
|
-
return
|
|
1408
|
+
function re() {
|
|
1409
|
+
return O().enabled;
|
|
1410
1410
|
}
|
|
1411
|
-
async function
|
|
1412
|
-
const t =
|
|
1411
|
+
async function ne() {
|
|
1412
|
+
const t = O();
|
|
1413
1413
|
if (t.enabled && t.token)
|
|
1414
1414
|
return t.token.promise;
|
|
1415
1415
|
throw Error(`
|
|
1416
1416
|
Can't get debug token in production mode.
|
|
1417
1417
|
`);
|
|
1418
1418
|
}
|
|
1419
|
-
function
|
|
1420
|
-
const t =
|
|
1419
|
+
function zr() {
|
|
1420
|
+
const t = ye(), e = O();
|
|
1421
1421
|
if (e.initialized = !0, typeof t.FIREBASE_APPCHECK_DEBUG_TOKEN != "string" && t.FIREBASE_APPCHECK_DEBUG_TOKEN !== !0)
|
|
1422
1422
|
return;
|
|
1423
1423
|
e.enabled = !0;
|
|
1424
|
-
const r = new
|
|
1425
|
-
e.token = r, typeof t.FIREBASE_APPCHECK_DEBUG_TOKEN == "string" ? r.resolve(t.FIREBASE_APPCHECK_DEBUG_TOKEN) : r.resolve(
|
|
1424
|
+
const r = new I();
|
|
1425
|
+
e.token = r, typeof t.FIREBASE_APPCHECK_DEBUG_TOKEN == "string" ? r.resolve(t.FIREBASE_APPCHECK_DEBUG_TOKEN) : r.resolve(Fr());
|
|
1426
1426
|
}
|
|
1427
|
-
const
|
|
1428
|
-
function
|
|
1429
|
-
return
|
|
1427
|
+
const Ur = { error: "UNKNOWN_ERROR" };
|
|
1428
|
+
function Vr(t) {
|
|
1429
|
+
return Y.encodeString(
|
|
1430
1430
|
JSON.stringify(t),
|
|
1431
1431
|
/* webSafe= */
|
|
1432
1432
|
!1
|
|
1433
1433
|
);
|
|
1434
1434
|
}
|
|
1435
|
-
async function
|
|
1435
|
+
async function q(t, e = !1, r = !1) {
|
|
1436
1436
|
const n = t.app;
|
|
1437
|
-
|
|
1437
|
+
ee(n);
|
|
1438
1438
|
const s = d(n);
|
|
1439
1439
|
let o = s.token, i;
|
|
1440
|
-
if (o && !
|
|
1440
|
+
if (o && !y(o) && (s.token = void 0, o = void 0), !o) {
|
|
1441
1441
|
const l = await s.cachedTokenPromise;
|
|
1442
|
-
l && (
|
|
1442
|
+
l && (y(l) ? o = l : await H(n, void 0));
|
|
1443
1443
|
}
|
|
1444
|
-
if (!e && o &&
|
|
1444
|
+
if (!e && o && y(o))
|
|
1445
1445
|
return {
|
|
1446
1446
|
token: o.token
|
|
1447
1447
|
};
|
|
1448
1448
|
let c = !1;
|
|
1449
|
-
if (
|
|
1449
|
+
if (re())
|
|
1450
1450
|
try {
|
|
1451
|
-
const l = await
|
|
1452
|
-
s.exchangeTokenPromise || (s.exchangeTokenPromise =
|
|
1451
|
+
const l = await ne();
|
|
1452
|
+
s.exchangeTokenPromise || (s.exchangeTokenPromise = te(Pe(n, l), t.heartbeatServiceProvider).finally(() => {
|
|
1453
1453
|
s.exchangeTokenPromise = void 0;
|
|
1454
1454
|
}), c = !0);
|
|
1455
1455
|
const p = await s.exchangeTokenPromise;
|
|
1456
|
-
return await
|
|
1456
|
+
return await H(n, p), s.token = p, { token: p.token };
|
|
1457
1457
|
} catch (l) {
|
|
1458
|
-
return l.code === "appCheck/throttled" || l.code === "appCheck/initial-throttle" ?
|
|
1458
|
+
return l.code === "appCheck/throttled" || l.code === "appCheck/initial-throttle" ? b.warn(l.message) : r && b.error(l), F(l);
|
|
1459
1459
|
}
|
|
1460
1460
|
try {
|
|
1461
1461
|
s.exchangeTokenPromise || (s.exchangeTokenPromise = s.provider.getToken().finally(() => {
|
|
1462
1462
|
s.exchangeTokenPromise = void 0;
|
|
1463
1463
|
}), c = !0), o = await d(n).exchangeTokenPromise;
|
|
1464
1464
|
} catch (l) {
|
|
1465
|
-
l.code === "appCheck/throttled" || l.code === "appCheck/initial-throttle" ?
|
|
1465
|
+
l.code === "appCheck/throttled" || l.code === "appCheck/initial-throttle" ? b.warn(l.message) : r && b.error(l), i = l;
|
|
1466
1466
|
}
|
|
1467
1467
|
let a;
|
|
1468
|
-
return o ? i ?
|
|
1468
|
+
return o ? i ? y(o) ? a = {
|
|
1469
1469
|
token: o.token,
|
|
1470
1470
|
internalError: i
|
|
1471
|
-
} : a =
|
|
1471
|
+
} : a = F(i) : (a = {
|
|
1472
1472
|
token: o.token
|
|
1473
|
-
}, s.token = o, await
|
|
1473
|
+
}, s.token = o, await H(n, o)) : a = F(i), c && Fe(n, a), a;
|
|
1474
1474
|
}
|
|
1475
|
-
async function
|
|
1475
|
+
async function Wr(t) {
|
|
1476
1476
|
const e = t.app;
|
|
1477
|
-
|
|
1477
|
+
ee(e);
|
|
1478
1478
|
const { provider: r } = d(e);
|
|
1479
|
-
if (
|
|
1480
|
-
const n = await
|
|
1479
|
+
if (re()) {
|
|
1480
|
+
const n = await ne(), { token: s } = await te(Pe(e, n), t.heartbeatServiceProvider);
|
|
1481
1481
|
return { token: s };
|
|
1482
1482
|
} else {
|
|
1483
1483
|
const { token: n } = await r.getToken();
|
|
1484
1484
|
return { token: n };
|
|
1485
1485
|
}
|
|
1486
1486
|
}
|
|
1487
|
-
function
|
|
1487
|
+
function Le(t, e, r, n) {
|
|
1488
1488
|
const { app: s } = t, o = d(s), i = {
|
|
1489
1489
|
next: r,
|
|
1490
1490
|
error: n,
|
|
1491
1491
|
type: e
|
|
1492
1492
|
};
|
|
1493
|
-
if (o.tokenObservers = [...o.tokenObservers, i], o.token &&
|
|
1493
|
+
if (o.tokenObservers = [...o.tokenObservers, i], o.token && y(o.token)) {
|
|
1494
1494
|
const c = o.token;
|
|
1495
1495
|
Promise.resolve().then(() => {
|
|
1496
|
-
r({ token: c.token }),
|
|
1496
|
+
r({ token: c.token }), me(t);
|
|
1497
1497
|
}).catch(() => {
|
|
1498
1498
|
});
|
|
1499
1499
|
}
|
|
1500
|
-
o.cachedTokenPromise.then(() =>
|
|
1500
|
+
o.cachedTokenPromise.then(() => me(t));
|
|
1501
1501
|
}
|
|
1502
|
-
function
|
|
1502
|
+
function He(t, e) {
|
|
1503
1503
|
const r = d(t), n = r.tokenObservers.filter((s) => s.next !== e);
|
|
1504
1504
|
n.length === 0 && r.tokenRefresher && r.tokenRefresher.isRunning() && r.tokenRefresher.stop(), r.tokenObservers = n;
|
|
1505
1505
|
}
|
|
1506
|
-
function
|
|
1506
|
+
function me(t) {
|
|
1507
1507
|
const { app: e } = t, r = d(e);
|
|
1508
1508
|
let n = r.tokenRefresher;
|
|
1509
|
-
n || (n =
|
|
1509
|
+
n || (n = Kr(t), r.tokenRefresher = n), !n.isRunning() && r.isTokenAutoRefreshEnabled && n.start();
|
|
1510
1510
|
}
|
|
1511
|
-
function
|
|
1511
|
+
function Kr(t) {
|
|
1512
1512
|
const { app: e } = t;
|
|
1513
|
-
return new
|
|
1513
|
+
return new vr(
|
|
1514
1514
|
// Keep in mind when this fails for any reason other than the ones
|
|
1515
1515
|
// for which we should retry, it will effectively stop the proactive refresh.
|
|
1516
1516
|
async () => {
|
|
1517
1517
|
const r = d(e);
|
|
1518
1518
|
let n;
|
|
1519
|
-
if (r.token ? n = await
|
|
1519
|
+
if (r.token ? n = await q(t, !0) : n = await q(t), n.error)
|
|
1520
1520
|
throw n.error;
|
|
1521
1521
|
if (n.internalError)
|
|
1522
1522
|
throw n.internalError;
|
|
@@ -1531,11 +1531,11 @@ function jr(t) {
|
|
|
1531
1531
|
} else
|
|
1532
1532
|
return 0;
|
|
1533
1533
|
},
|
|
1534
|
-
|
|
1535
|
-
|
|
1534
|
+
pe.RETRIAL_MIN_WAIT,
|
|
1535
|
+
pe.RETRIAL_MAX_WAIT
|
|
1536
1536
|
);
|
|
1537
1537
|
}
|
|
1538
|
-
function
|
|
1538
|
+
function Fe(t, e) {
|
|
1539
1539
|
const r = d(t).tokenObservers;
|
|
1540
1540
|
for (const n of r)
|
|
1541
1541
|
try {
|
|
@@ -1543,60 +1543,60 @@ function Le(t, e) {
|
|
|
1543
1543
|
} catch {
|
|
1544
1544
|
}
|
|
1545
1545
|
}
|
|
1546
|
-
function
|
|
1546
|
+
function y(t) {
|
|
1547
1547
|
return t.expireTimeMillis - Date.now() > 0;
|
|
1548
1548
|
}
|
|
1549
|
-
function
|
|
1549
|
+
function F(t) {
|
|
1550
1550
|
return {
|
|
1551
|
-
token:
|
|
1551
|
+
token: Vr(Ur),
|
|
1552
1552
|
error: t
|
|
1553
1553
|
};
|
|
1554
1554
|
}
|
|
1555
|
-
class
|
|
1555
|
+
class jr {
|
|
1556
1556
|
constructor(e, r) {
|
|
1557
1557
|
this.app = e, this.heartbeatServiceProvider = r;
|
|
1558
1558
|
}
|
|
1559
1559
|
_delete() {
|
|
1560
1560
|
const { tokenObservers: e } = d(this.app);
|
|
1561
1561
|
for (const r of e)
|
|
1562
|
-
|
|
1562
|
+
He(this.app, r.next);
|
|
1563
1563
|
return Promise.resolve();
|
|
1564
1564
|
}
|
|
1565
1565
|
}
|
|
1566
|
-
function
|
|
1567
|
-
return new
|
|
1566
|
+
function Gr(t, e) {
|
|
1567
|
+
return new jr(t, e);
|
|
1568
1568
|
}
|
|
1569
|
-
function
|
|
1569
|
+
function qr(t) {
|
|
1570
1570
|
return {
|
|
1571
|
-
getToken: (e) =>
|
|
1572
|
-
getLimitedUseToken: () =>
|
|
1573
|
-
addTokenListener: (e) =>
|
|
1574
|
-
removeTokenListener: (e) =>
|
|
1571
|
+
getToken: (e) => q(t, e),
|
|
1572
|
+
getLimitedUseToken: () => Wr(t),
|
|
1573
|
+
addTokenListener: (e) => Le(t, "INTERNAL", e),
|
|
1574
|
+
removeTokenListener: (e) => He(t.app, e)
|
|
1575
1575
|
};
|
|
1576
1576
|
}
|
|
1577
|
-
const
|
|
1578
|
-
function
|
|
1579
|
-
const r = new
|
|
1577
|
+
const Xr = "@firebase/app-check", Yr = "0.11.1", Jr = "https://www.google.com/recaptcha/enterprise.js";
|
|
1578
|
+
function Zr(t, e) {
|
|
1579
|
+
const r = new I(), n = d(t);
|
|
1580
1580
|
n.reCAPTCHAState = { initialized: r };
|
|
1581
|
-
const s =
|
|
1582
|
-
return o ?
|
|
1583
|
-
const i =
|
|
1581
|
+
const s = Qr(t), o = ge(!0);
|
|
1582
|
+
return o ? be(t, e, o, s, r) : rn(() => {
|
|
1583
|
+
const i = ge(!0);
|
|
1584
1584
|
if (!i)
|
|
1585
1585
|
throw new Error("no recaptcha");
|
|
1586
|
-
|
|
1586
|
+
be(t, e, i, s, r);
|
|
1587
1587
|
}), r.promise;
|
|
1588
1588
|
}
|
|
1589
|
-
function
|
|
1589
|
+
function be(t, e, r, n, s) {
|
|
1590
1590
|
r.ready(() => {
|
|
1591
|
-
|
|
1591
|
+
tn(t, e, r, n), s.resolve(r);
|
|
1592
1592
|
});
|
|
1593
1593
|
}
|
|
1594
|
-
function
|
|
1594
|
+
function Qr(t) {
|
|
1595
1595
|
const e = `fire_app_check_${t.name}`, r = document.createElement("div");
|
|
1596
1596
|
return r.id = e, r.style.display = "none", document.body.appendChild(r), e;
|
|
1597
1597
|
}
|
|
1598
|
-
async function
|
|
1599
|
-
|
|
1598
|
+
async function en(t) {
|
|
1599
|
+
ee(t);
|
|
1600
1600
|
const r = await d(t).reCAPTCHAState.initialized.promise;
|
|
1601
1601
|
return new Promise((n, s) => {
|
|
1602
1602
|
const o = d(t).reCAPTCHAState;
|
|
@@ -1610,7 +1610,7 @@ async function Zr(t) {
|
|
|
1610
1610
|
});
|
|
1611
1611
|
});
|
|
1612
1612
|
}
|
|
1613
|
-
function
|
|
1613
|
+
function tn(t, e, r, n) {
|
|
1614
1614
|
const s = r.render(n, {
|
|
1615
1615
|
sitekey: e,
|
|
1616
1616
|
size: "invisible",
|
|
@@ -1629,11 +1629,11 @@ function Qr(t, e, r, n) {
|
|
|
1629
1629
|
widgetId: s
|
|
1630
1630
|
};
|
|
1631
1631
|
}
|
|
1632
|
-
function
|
|
1632
|
+
function rn(t) {
|
|
1633
1633
|
const e = document.createElement("script");
|
|
1634
|
-
e.src =
|
|
1634
|
+
e.src = Jr, e.onload = t, document.head.appendChild(e);
|
|
1635
1635
|
}
|
|
1636
|
-
class
|
|
1636
|
+
class se {
|
|
1637
1637
|
/**
|
|
1638
1638
|
* Create a ReCaptchaEnterpriseProvider instance.
|
|
1639
1639
|
* @param siteKey - reCAPTCHA Enterprise score-based site key.
|
|
@@ -1646,8 +1646,8 @@ class re {
|
|
|
1646
1646
|
* @internal
|
|
1647
1647
|
*/
|
|
1648
1648
|
async getToken() {
|
|
1649
|
-
|
|
1650
|
-
const e = await
|
|
1649
|
+
sn(this._throttleData);
|
|
1650
|
+
const e = await en(this._app).catch((n) => {
|
|
1651
1651
|
throw u.create(
|
|
1652
1652
|
"recaptcha-error"
|
|
1653
1653
|
/* AppCheckError.RECAPTCHA_ERROR */
|
|
@@ -1660,13 +1660,13 @@ class re {
|
|
|
1660
1660
|
);
|
|
1661
1661
|
let r;
|
|
1662
1662
|
try {
|
|
1663
|
-
r = await
|
|
1663
|
+
r = await te(Pr(this._app, e), this._heartbeatServiceProvider);
|
|
1664
1664
|
} catch (n) {
|
|
1665
1665
|
throw n.code?.includes(
|
|
1666
1666
|
"fetch-status-error"
|
|
1667
1667
|
/* AppCheckError.FETCH_STATUS_ERROR */
|
|
1668
|
-
) ? (this._throttleData =
|
|
1669
|
-
time:
|
|
1668
|
+
) ? (this._throttleData = nn(Number(n.customData?.httpStatus), this._throttleData), u.create("initial-throttle", {
|
|
1669
|
+
time: Be(this._throttleData.allowRequestsAfter - Date.now()),
|
|
1670
1670
|
httpStatus: this._throttleData.httpStatus
|
|
1671
1671
|
})) : n;
|
|
1672
1672
|
}
|
|
@@ -1676,25 +1676,25 @@ class re {
|
|
|
1676
1676
|
* @internal
|
|
1677
1677
|
*/
|
|
1678
1678
|
initialize(e) {
|
|
1679
|
-
this._app = e, this._heartbeatServiceProvider =
|
|
1679
|
+
this._app = e, this._heartbeatServiceProvider = De(e, "heartbeat"), Zr(e, this._siteKey).catch(() => {
|
|
1680
1680
|
});
|
|
1681
1681
|
}
|
|
1682
1682
|
/**
|
|
1683
1683
|
* @internal
|
|
1684
1684
|
*/
|
|
1685
1685
|
isEqual(e) {
|
|
1686
|
-
return e instanceof
|
|
1686
|
+
return e instanceof se ? this._siteKey === e._siteKey : !1;
|
|
1687
1687
|
}
|
|
1688
1688
|
}
|
|
1689
|
-
function
|
|
1689
|
+
function nn(t, e) {
|
|
1690
1690
|
if (t === 404 || t === 403)
|
|
1691
1691
|
return {
|
|
1692
1692
|
backoffCount: 1,
|
|
1693
|
-
allowRequestsAfter: Date.now() +
|
|
1693
|
+
allowRequestsAfter: Date.now() + Sr,
|
|
1694
1694
|
httpStatus: t
|
|
1695
1695
|
};
|
|
1696
1696
|
{
|
|
1697
|
-
const r = e ? e.backoffCount : 0, n =
|
|
1697
|
+
const r = e ? e.backoffCount : 0, n = ft(r, 1e3, 2);
|
|
1698
1698
|
return {
|
|
1699
1699
|
backoffCount: r + 1,
|
|
1700
1700
|
allowRequestsAfter: Date.now() + n,
|
|
@@ -1702,17 +1702,17 @@ function tn(t, e) {
|
|
|
1702
1702
|
};
|
|
1703
1703
|
}
|
|
1704
1704
|
}
|
|
1705
|
-
function
|
|
1705
|
+
function sn(t) {
|
|
1706
1706
|
if (t && Date.now() - t.allowRequestsAfter <= 0)
|
|
1707
1707
|
throw u.create("throttled", {
|
|
1708
|
-
time:
|
|
1708
|
+
time: Be(t.allowRequestsAfter - Date.now()),
|
|
1709
1709
|
httpStatus: t.httpStatus
|
|
1710
1710
|
});
|
|
1711
1711
|
}
|
|
1712
|
-
function
|
|
1713
|
-
t =
|
|
1714
|
-
const r =
|
|
1715
|
-
if (
|
|
1712
|
+
function on(t = fr(), e) {
|
|
1713
|
+
t = pt(t);
|
|
1714
|
+
const r = De(t, "app-check");
|
|
1715
|
+
if (O().initialized || zr(), re() && ne().then((s) => (
|
|
1716
1716
|
// Not using logger because I don't think we ever want this accidentally hidden.
|
|
1717
1717
|
console.log(`App Check debug token: ${s}. You will need to add it to your app's App Check settings in the Firebase console for it to work.`)
|
|
1718
1718
|
)), r.isInitialized()) {
|
|
@@ -1724,20 +1724,20 @@ function nn(t = dr(), e) {
|
|
|
1724
1724
|
});
|
|
1725
1725
|
}
|
|
1726
1726
|
const n = r.initialize({ options: e });
|
|
1727
|
-
return
|
|
1727
|
+
return an(t, e.provider, e.isTokenAutoRefreshEnabled), d(t).isTokenAutoRefreshEnabled && Le(n, "INTERNAL", () => {
|
|
1728
1728
|
}), n;
|
|
1729
1729
|
}
|
|
1730
|
-
function
|
|
1731
|
-
const n =
|
|
1732
|
-
n.activated = !0, n.provider = e, n.cachedTokenPromise =
|
|
1730
|
+
function an(t, e, r = !1) {
|
|
1731
|
+
const n = Cr(t, { ...ve });
|
|
1732
|
+
n.activated = !0, n.provider = e, n.cachedTokenPromise = Hr(t).then((s) => (s && y(s) && (n.token = s, Fe(t, { token: s.token })), s)), n.isTokenAutoRefreshEnabled = r && t.automaticDataCollectionEnabled, !t.automaticDataCollectionEnabled && r && b.warn("`isTokenAutoRefreshEnabled` is true but `automaticDataCollectionEnabled` was set to false during `initializeApp()`. This blocks automatic token refresh."), n.provider.initialize(t);
|
|
1733
1733
|
}
|
|
1734
|
-
const
|
|
1735
|
-
function
|
|
1736
|
-
|
|
1737
|
-
|
|
1734
|
+
const cn = "app-check", Ee = "app-check-internal";
|
|
1735
|
+
function ln() {
|
|
1736
|
+
T(new A(
|
|
1737
|
+
cn,
|
|
1738
1738
|
(t) => {
|
|
1739
1739
|
const e = t.getProvider("app").getImmediate(), r = t.getProvider("heartbeat");
|
|
1740
|
-
return
|
|
1740
|
+
return Gr(e, r);
|
|
1741
1741
|
},
|
|
1742
1742
|
"PUBLIC"
|
|
1743
1743
|
/* ComponentType.PUBLIC */
|
|
@@ -1745,23 +1745,72 @@ function an() {
|
|
|
1745
1745
|
"EXPLICIT"
|
|
1746
1746
|
/* InstantiationMode.EXPLICIT */
|
|
1747
1747
|
).setInstanceCreatedCallback((t, e, r) => {
|
|
1748
|
-
t.getProvider(
|
|
1749
|
-
})),
|
|
1750
|
-
|
|
1748
|
+
t.getProvider(Ee).initialize();
|
|
1749
|
+
})), T(new A(
|
|
1750
|
+
Ee,
|
|
1751
1751
|
(t) => {
|
|
1752
1752
|
const e = t.getProvider("app-check").getImmediate();
|
|
1753
|
-
return
|
|
1753
|
+
return qr(e);
|
|
1754
1754
|
},
|
|
1755
1755
|
"PUBLIC"
|
|
1756
1756
|
/* ComponentType.PUBLIC */
|
|
1757
1757
|
).setInstantiationMode(
|
|
1758
1758
|
"EXPLICIT"
|
|
1759
1759
|
/* InstantiationMode.EXPLICIT */
|
|
1760
|
-
)),
|
|
1760
|
+
)), P(Xr, Yr);
|
|
1761
|
+
}
|
|
1762
|
+
ln();
|
|
1763
|
+
function X(t) {
|
|
1764
|
+
if (!t)
|
|
1765
|
+
return;
|
|
1766
|
+
const e = {
|
|
1767
|
+
description: t.description,
|
|
1768
|
+
nullable: t.nullable || !1,
|
|
1769
|
+
format: t.format
|
|
1770
|
+
};
|
|
1771
|
+
switch (Array.isArray(t.type) && t.type.includes("null") && (e.nullable = !0, t.type = t.type.find((r) => r !== "null")), t.type) {
|
|
1772
|
+
case "string":
|
|
1773
|
+
return t.enum && Array.isArray(t.enum) ? m.enumString({
|
|
1774
|
+
...e,
|
|
1775
|
+
enum: t.enum
|
|
1776
|
+
}) : m.string(e);
|
|
1777
|
+
case "number":
|
|
1778
|
+
return m.number(e);
|
|
1779
|
+
case "integer":
|
|
1780
|
+
return m.integer(e);
|
|
1781
|
+
case "boolean":
|
|
1782
|
+
return m.boolean(e);
|
|
1783
|
+
case "array":
|
|
1784
|
+
return m.array({
|
|
1785
|
+
...e,
|
|
1786
|
+
// Recursively convert the 'items' schema
|
|
1787
|
+
items: X(t.items)
|
|
1788
|
+
});
|
|
1789
|
+
case "object": {
|
|
1790
|
+
const r = {}, n = t.properties ? Object.keys(t.properties) : [];
|
|
1791
|
+
n.forEach((i) => {
|
|
1792
|
+
r[i] = X(
|
|
1793
|
+
t.properties[i]
|
|
1794
|
+
);
|
|
1795
|
+
});
|
|
1796
|
+
const s = t.required || [], o = n.filter(
|
|
1797
|
+
(i) => !s.includes(i)
|
|
1798
|
+
);
|
|
1799
|
+
return m.object({
|
|
1800
|
+
...e,
|
|
1801
|
+
properties: r,
|
|
1802
|
+
optionalProperties: o
|
|
1803
|
+
});
|
|
1804
|
+
}
|
|
1805
|
+
default:
|
|
1806
|
+
return console.warn(
|
|
1807
|
+
`Unsupported type: ${t.type}, defaulting to string.`
|
|
1808
|
+
), m.string(e);
|
|
1809
|
+
}
|
|
1761
1810
|
}
|
|
1762
|
-
|
|
1763
|
-
class dn extends Ke {
|
|
1811
|
+
class fn extends qe {
|
|
1764
1812
|
#e;
|
|
1813
|
+
#t;
|
|
1765
1814
|
constructor(e) {
|
|
1766
1815
|
const {
|
|
1767
1816
|
geminiApiProvider: r,
|
|
@@ -1771,18 +1820,26 @@ class dn extends Ke {
|
|
|
1771
1820
|
useLimitedUseAppCheckTokens: i,
|
|
1772
1821
|
...c
|
|
1773
1822
|
} = e;
|
|
1774
|
-
super(n ||
|
|
1775
|
-
const a =
|
|
1776
|
-
s && o &&
|
|
1777
|
-
provider: new
|
|
1823
|
+
super(n || Xe.firebase.modelName);
|
|
1824
|
+
const a = Ue(c);
|
|
1825
|
+
s && o && on(a, {
|
|
1826
|
+
provider: new se(o),
|
|
1778
1827
|
isTokenAutoRefreshEnabled: !0
|
|
1779
1828
|
});
|
|
1780
|
-
const l = r === "vertex" ? new
|
|
1781
|
-
this
|
|
1829
|
+
const l = r === "vertex" ? new Ve() : new We();
|
|
1830
|
+
this.#t = Ke(a, {
|
|
1782
1831
|
backend: l,
|
|
1783
1832
|
useLimitedUseAppCheckTokens: i || !0
|
|
1784
1833
|
});
|
|
1785
1834
|
}
|
|
1835
|
+
/**
|
|
1836
|
+
* Translates a standard JSON Schema into a backend-specific format.
|
|
1837
|
+
* @param {Object} schema - The standard JSON Schema.
|
|
1838
|
+
* @returns {any} The backend-specific schema.
|
|
1839
|
+
*/
|
|
1840
|
+
convertSchema(e) {
|
|
1841
|
+
return X(e);
|
|
1842
|
+
}
|
|
1786
1843
|
/**
|
|
1787
1844
|
* Creates a model session and stores it.
|
|
1788
1845
|
* @param {Object} _options - LanguageModel options.
|
|
@@ -1790,8 +1847,8 @@ class dn extends Ke {
|
|
|
1790
1847
|
* @returns {any} The created session object.
|
|
1791
1848
|
*/
|
|
1792
1849
|
createSession(e, r) {
|
|
1793
|
-
return this.#e =
|
|
1794
|
-
mode:
|
|
1850
|
+
return this.#e = je(this.#t, {
|
|
1851
|
+
mode: Ge.ONLY_IN_CLOUD,
|
|
1795
1852
|
inCloudParams: r
|
|
1796
1853
|
}), this.#e;
|
|
1797
1854
|
}
|
|
@@ -1825,5 +1882,5 @@ class dn extends Ke {
|
|
|
1825
1882
|
}
|
|
1826
1883
|
}
|
|
1827
1884
|
export {
|
|
1828
|
-
|
|
1885
|
+
fn as default
|
|
1829
1886
|
};
|