@feedmepos/mf-settings 0.0.63-beta.1 → 0.0.64-beta.1

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.
@@ -1,4352 +0,0 @@
1
- import { defineComponent as Ye, computed as Pe, ref as xt, watchEffect as Vt, resolveComponent as Wt, openBlock as Xe, createBlock as Qe, onMounted as Ht, unref as $t } from "vue";
2
- import { useRouter as jt, RouterView as Bt } from "vue-router";
3
- import { useI18n as Kt, useCoreStore as Ze, FeedMeAuth as qt } from "@feedmepos/mf-common";
4
- import { c as Gt } from "./index-f3cc5dbf.js";
5
- import { e as zt } from "./index-79b36905.js";
6
- import { r as Jt } from "./app-b3105281.js";
7
- import { r as de, g as et, i as Yt, a as Xt, _ as Ne, C as Oe, b as Qt, S as F, c as O, E as pe, d as Zt, e as tt, f as en, h as tn, L as nt, j as f, k as nn, l as rn, F as ge, q as x, m as sn, n as on, o as an, p as cn, s as ln, t as un, u as dn, v as hn } from "./map-695afd6f.js";
8
- import "@feedmepos/mf-mdm";
9
- import "@feedmepos/ui-library";
10
- import "@feedmepos/mf-e-invoice";
11
- function me(n, e) {
12
- var t = {};
13
- for (var i in n)
14
- Object.prototype.hasOwnProperty.call(n, i) && e.indexOf(i) < 0 && (t[i] = n[i]);
15
- if (n != null && typeof Object.getOwnPropertySymbols == "function")
16
- for (var r = 0, i = Object.getOwnPropertySymbols(n); r < i.length; r++)
17
- e.indexOf(i[r]) < 0 && Object.prototype.propertyIsEnumerable.call(n, i[r]) && (t[i[r]] = n[i[r]]);
18
- return t;
19
- }
20
- const fn = /* @__PURE__ */ Ye({
21
- __name: "NavigationTab",
22
- emits: ["close-navigation"],
23
- setup(n, { emit: e }) {
24
- const t = e, { t: i } = Kt(), r = jt(), s = Ze(), o = Pe(() => s.restaurants.value.some(({ posVersion: l }) => Gt.Pos.canUse({ feature: zt.F_FEATURE.Enum.templateBuilder, posVersion: l ?? "" }))), c = Pe(() => Jt.filter((d) => {
25
- var h;
26
- return d.redirect || (h = d.meta) != null && h.hideNavigation ? !1 : !(d.name === "$settings-template-builder" && !o.value);
27
- }).map((d) => {
28
- var h;
29
- return {
30
- label: i((h = d.meta) == null ? void 0 : h.i18nKey),
31
- value: d.name,
32
- action: () => {
33
- d.name === "$settings-e-invoice" ? r.push({ name: "SUBMISSION" }) : d.name === "$settings-device" ? r.push({ name: "$devices" }) : r.push({ name: d.name }), t("close-navigation");
34
- }
35
- };
36
- })), a = xt();
37
- return Vt(() => {
38
- var d;
39
- const l = (d = r.currentRoute.value) == null ? void 0 : d.name;
40
- l === "SUBMISSION" ? a.value = "$settings-e-invoice" : l === "$devices" ? a.value = "$settings-device" : a.value = l;
41
- }), (l, d) => {
42
- const h = Wt("fm-collapsible-tabs");
43
- return Xe(), Qe(h, {
44
- modelValue: a.value,
45
- "onUpdate:modelValue": d[0] || (d[0] = (p) => a.value = p),
46
- items: c.value,
47
- class: "py-16 px-8"
48
- }, null, 8, ["modelValue", "items"]);
49
- };
50
- }
51
- });
52
- var pn = "firebase", gn = "9.23.0";
53
- /**
54
- * @license
55
- * Copyright 2020 Google LLC
56
- *
57
- * Licensed under the Apache License, Version 2.0 (the "License");
58
- * you may not use this file except in compliance with the License.
59
- * You may obtain a copy of the License at
60
- *
61
- * http://www.apache.org/licenses/LICENSE-2.0
62
- *
63
- * Unless required by applicable law or agreed to in writing, software
64
- * distributed under the License is distributed on an "AS IS" BASIS,
65
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
66
- * See the License for the specific language governing permissions and
67
- * limitations under the License.
68
- */
69
- de(pn, gn, "app");
70
- function it() {
71
- return {
72
- "dependent-sdk-initialized-before-auth": "Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."
73
- };
74
- }
75
- const mn = it, rt = new pe("auth", "Firebase", it());
76
- /**
77
- * @license
78
- * Copyright 2020 Google LLC
79
- *
80
- * Licensed under the Apache License, Version 2.0 (the "License");
81
- * you may not use this file except in compliance with the License.
82
- * You may obtain a copy of the License at
83
- *
84
- * http://www.apache.org/licenses/LICENSE-2.0
85
- *
86
- * Unless required by applicable law or agreed to in writing, software
87
- * distributed under the License is distributed on an "AS IS" BASIS,
88
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
89
- * See the License for the specific language governing permissions and
90
- * limitations under the License.
91
- */
92
- const X = new rn("@firebase/auth");
93
- function _n(n, ...e) {
94
- X.logLevel <= nt.WARN && X.warn(`Auth (${F}): ${n}`, ...e);
95
- }
96
- function G(n, ...e) {
97
- X.logLevel <= nt.ERROR && X.error(`Auth (${F}): ${n}`, ...e);
98
- }
99
- /**
100
- * @license
101
- * Copyright 2020 Google LLC
102
- *
103
- * Licensed under the Apache License, Version 2.0 (the "License");
104
- * you may not use this file except in compliance with the License.
105
- * You may obtain a copy of the License at
106
- *
107
- * http://www.apache.org/licenses/LICENSE-2.0
108
- *
109
- * Unless required by applicable law or agreed to in writing, software
110
- * distributed under the License is distributed on an "AS IS" BASIS,
111
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
112
- * See the License for the specific language governing permissions and
113
- * limitations under the License.
114
- */
115
- function I(n, ...e) {
116
- throw _e(n, ...e);
117
- }
118
- function g(n, ...e) {
119
- return _e(n, ...e);
120
- }
121
- function vn(n, e, t) {
122
- const i = Object.assign(Object.assign({}, mn()), { [e]: t });
123
- return new pe("auth", "Firebase", i).create(e, {
124
- appName: n.name
125
- });
126
- }
127
- function _e(n, ...e) {
128
- if (typeof n != "string") {
129
- const t = e[0], i = [...e.slice(1)];
130
- return i[0] && (i[0].appName = n.name), n._errorFactory.create(t, ...i);
131
- }
132
- return rt.create(n, ...e);
133
- }
134
- function u(n, e, ...t) {
135
- if (!n)
136
- throw _e(e, ...t);
137
- }
138
- function _(n) {
139
- const e = "INTERNAL ASSERTION FAILED: " + n;
140
- throw G(e), new Error(e);
141
- }
142
- function y(n, e) {
143
- n || _(e);
144
- }
145
- /**
146
- * @license
147
- * Copyright 2020 Google LLC
148
- *
149
- * Licensed under the Apache License, Version 2.0 (the "License");
150
- * you may not use this file except in compliance with the License.
151
- * You may obtain a copy of the License at
152
- *
153
- * http://www.apache.org/licenses/LICENSE-2.0
154
- *
155
- * Unless required by applicable law or agreed to in writing, software
156
- * distributed under the License is distributed on an "AS IS" BASIS,
157
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
158
- * See the License for the specific language governing permissions and
159
- * limitations under the License.
160
- */
161
- function he() {
162
- var n;
163
- return typeof self < "u" && ((n = self.location) === null || n === void 0 ? void 0 : n.href) || "";
164
- }
165
- function In() {
166
- return Le() === "http:" || Le() === "https:";
167
- }
168
- function Le() {
169
- var n;
170
- return typeof self < "u" && ((n = self.location) === null || n === void 0 ? void 0 : n.protocol) || null;
171
- }
172
- /**
173
- * @license
174
- * Copyright 2020 Google LLC
175
- *
176
- * Licensed under the Apache License, Version 2.0 (the "License");
177
- * you may not use this file except in compliance with the License.
178
- * You may obtain a copy of the License at
179
- *
180
- * http://www.apache.org/licenses/LICENSE-2.0
181
- *
182
- * Unless required by applicable law or agreed to in writing, software
183
- * distributed under the License is distributed on an "AS IS" BASIS,
184
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
185
- * See the License for the specific language governing permissions and
186
- * limitations under the License.
187
- */
188
- function yn() {
189
- return typeof navigator < "u" && navigator && "onLine" in navigator && typeof navigator.onLine == "boolean" && // Apply only for traditional web apps and Chrome extensions.
190
- // This is especially true for Cordova apps which have unreliable
191
- // navigator.onLine behavior unless cordova-plugin-network-information is
192
- // installed which overwrites the native navigator.onLine value and
193
- // defines navigator.connection.
194
- (In() || Qt() || "connection" in navigator) ? navigator.onLine : !0;
195
- }
196
- function Tn() {
197
- if (typeof navigator > "u")
198
- return null;
199
- const n = navigator;
200
- return (
201
- // Most reliable, but only supported in Chrome/Firefox.
202
- n.languages && n.languages[0] || // Supported in most browsers, but returns the language of the browser
203
- // UI, not the language set in browser settings.
204
- n.language || // Couldn't determine language.
205
- null
206
- );
207
- }
208
- /**
209
- * @license
210
- * Copyright 2020 Google LLC
211
- *
212
- * Licensed under the Apache License, Version 2.0 (the "License");
213
- * you may not use this file except in compliance with the License.
214
- * You may obtain a copy of the License at
215
- *
216
- * http://www.apache.org/licenses/LICENSE-2.0
217
- *
218
- * Unless required by applicable law or agreed to in writing, software
219
- * distributed under the License is distributed on an "AS IS" BASIS,
220
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
221
- * See the License for the specific language governing permissions and
222
- * limitations under the License.
223
- */
224
- class V {
225
- constructor(e, t) {
226
- this.shortDelay = e, this.longDelay = t, y(t > e, "Short delay should be less than long delay!"), this.isMobile = Yt() || Xt();
227
- }
228
- get() {
229
- return yn() ? this.isMobile ? this.longDelay : this.shortDelay : Math.min(5e3, this.shortDelay);
230
- }
231
- }
232
- /**
233
- * @license
234
- * Copyright 2020 Google LLC
235
- *
236
- * Licensed under the Apache License, Version 2.0 (the "License");
237
- * you may not use this file except in compliance with the License.
238
- * You may obtain a copy of the License at
239
- *
240
- * http://www.apache.org/licenses/LICENSE-2.0
241
- *
242
- * Unless required by applicable law or agreed to in writing, software
243
- * distributed under the License is distributed on an "AS IS" BASIS,
244
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
245
- * See the License for the specific language governing permissions and
246
- * limitations under the License.
247
- */
248
- function ve(n, e) {
249
- y(n.emulator, "Emulator should always be set here");
250
- const { url: t } = n.emulator;
251
- return e ? `${t}${e.startsWith("/") ? e.slice(1) : e}` : t;
252
- }
253
- /**
254
- * @license
255
- * Copyright 2020 Google LLC
256
- *
257
- * Licensed under the Apache License, Version 2.0 (the "License");
258
- * you may not use this file except in compliance with the License.
259
- * You may obtain a copy of the License at
260
- *
261
- * http://www.apache.org/licenses/LICENSE-2.0
262
- *
263
- * Unless required by applicable law or agreed to in writing, software
264
- * distributed under the License is distributed on an "AS IS" BASIS,
265
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
266
- * See the License for the specific language governing permissions and
267
- * limitations under the License.
268
- */
269
- class st {
270
- static initialize(e, t, i) {
271
- this.fetchImpl = e, t && (this.headersImpl = t), i && (this.responseImpl = i);
272
- }
273
- static fetch() {
274
- if (this.fetchImpl)
275
- return this.fetchImpl;
276
- if (typeof self < "u" && "fetch" in self)
277
- return self.fetch;
278
- _("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill");
279
- }
280
- static headers() {
281
- if (this.headersImpl)
282
- return this.headersImpl;
283
- if (typeof self < "u" && "Headers" in self)
284
- return self.Headers;
285
- _("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill");
286
- }
287
- static response() {
288
- if (this.responseImpl)
289
- return this.responseImpl;
290
- if (typeof self < "u" && "Response" in self)
291
- return self.Response;
292
- _("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill");
293
- }
294
- }
295
- /**
296
- * @license
297
- * Copyright 2020 Google LLC
298
- *
299
- * Licensed under the Apache License, Version 2.0 (the "License");
300
- * you may not use this file except in compliance with the License.
301
- * You may obtain a copy of the License at
302
- *
303
- * http://www.apache.org/licenses/LICENSE-2.0
304
- *
305
- * Unless required by applicable law or agreed to in writing, software
306
- * distributed under the License is distributed on an "AS IS" BASIS,
307
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
308
- * See the License for the specific language governing permissions and
309
- * limitations under the License.
310
- */
311
- const wn = {
312
- // Custom token errors.
313
- CREDENTIAL_MISMATCH: "custom-token-mismatch",
314
- // This can only happen if the SDK sends a bad request.
315
- MISSING_CUSTOM_TOKEN: "internal-error",
316
- // Create Auth URI errors.
317
- INVALID_IDENTIFIER: "invalid-email",
318
- // This can only happen if the SDK sends a bad request.
319
- MISSING_CONTINUE_URI: "internal-error",
320
- // Sign in with email and password errors (some apply to sign up too).
321
- INVALID_PASSWORD: "wrong-password",
322
- // This can only happen if the SDK sends a bad request.
323
- MISSING_PASSWORD: "missing-password",
324
- // Sign up with email and password errors.
325
- EMAIL_EXISTS: "email-already-in-use",
326
- PASSWORD_LOGIN_DISABLED: "operation-not-allowed",
327
- // Verify assertion for sign in with credential errors:
328
- INVALID_IDP_RESPONSE: "invalid-credential",
329
- INVALID_PENDING_TOKEN: "invalid-credential",
330
- FEDERATED_USER_ID_ALREADY_LINKED: "credential-already-in-use",
331
- // This can only happen if the SDK sends a bad request.
332
- MISSING_REQ_TYPE: "internal-error",
333
- // Send Password reset email errors:
334
- EMAIL_NOT_FOUND: "user-not-found",
335
- RESET_PASSWORD_EXCEED_LIMIT: "too-many-requests",
336
- EXPIRED_OOB_CODE: "expired-action-code",
337
- INVALID_OOB_CODE: "invalid-action-code",
338
- // This can only happen if the SDK sends a bad request.
339
- MISSING_OOB_CODE: "internal-error",
340
- // Operations that require ID token in request:
341
- CREDENTIAL_TOO_OLD_LOGIN_AGAIN: "requires-recent-login",
342
- INVALID_ID_TOKEN: "invalid-user-token",
343
- TOKEN_EXPIRED: "user-token-expired",
344
- USER_NOT_FOUND: "user-token-expired",
345
- // Other errors.
346
- TOO_MANY_ATTEMPTS_TRY_LATER: "too-many-requests",
347
- // Phone Auth related errors.
348
- INVALID_CODE: "invalid-verification-code",
349
- INVALID_SESSION_INFO: "invalid-verification-id",
350
- INVALID_TEMPORARY_PROOF: "invalid-credential",
351
- MISSING_SESSION_INFO: "missing-verification-id",
352
- SESSION_EXPIRED: "code-expired",
353
- // Other action code errors when additional settings passed.
354
- // MISSING_CONTINUE_URI is getting mapped to INTERNAL_ERROR above.
355
- // This is OK as this error will be caught by client side validation.
356
- MISSING_ANDROID_PACKAGE_NAME: "missing-android-pkg-name",
357
- UNAUTHORIZED_DOMAIN: "unauthorized-continue-uri",
358
- // getProjectConfig errors when clientId is passed.
359
- INVALID_OAUTH_CLIENT_ID: "invalid-oauth-client-id",
360
- // User actions (sign-up or deletion) disabled errors.
361
- ADMIN_ONLY_OPERATION: "admin-restricted-operation",
362
- // Multi factor related errors.
363
- INVALID_MFA_PENDING_CREDENTIAL: "invalid-multi-factor-session",
364
- MFA_ENROLLMENT_NOT_FOUND: "multi-factor-info-not-found",
365
- MISSING_MFA_ENROLLMENT_ID: "missing-multi-factor-info",
366
- MISSING_MFA_PENDING_CREDENTIAL: "missing-multi-factor-session",
367
- SECOND_FACTOR_EXISTS: "second-factor-already-in-use",
368
- SECOND_FACTOR_LIMIT_EXCEEDED: "maximum-second-factor-count-exceeded",
369
- // Blocking functions related errors.
370
- BLOCKING_FUNCTION_ERROR_RESPONSE: "internal-error",
371
- // Recaptcha related errors.
372
- RECAPTCHA_NOT_ENABLED: "recaptcha-not-enabled",
373
- MISSING_RECAPTCHA_TOKEN: "missing-recaptcha-token",
374
- INVALID_RECAPTCHA_TOKEN: "invalid-recaptcha-token",
375
- INVALID_RECAPTCHA_ACTION: "invalid-recaptcha-action",
376
- MISSING_CLIENT_TYPE: "missing-client-type",
377
- MISSING_RECAPTCHA_VERSION: "missing-recaptcha-version",
378
- INVALID_RECAPTCHA_VERSION: "invalid-recaptcha-version",
379
- INVALID_REQ_TYPE: "invalid-req-type"
380
- /* AuthErrorCode.INVALID_REQ_TYPE */
381
- };
382
- /**
383
- * @license
384
- * Copyright 2020 Google LLC
385
- *
386
- * Licensed under the Apache License, Version 2.0 (the "License");
387
- * you may not use this file except in compliance with the License.
388
- * You may obtain a copy of the License at
389
- *
390
- * http://www.apache.org/licenses/LICENSE-2.0
391
- *
392
- * Unless required by applicable law or agreed to in writing, software
393
- * distributed under the License is distributed on an "AS IS" BASIS,
394
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
395
- * See the License for the specific language governing permissions and
396
- * limitations under the License.
397
- */
398
- const En = new V(3e4, 6e4);
399
- function Ie(n, e) {
400
- return n.tenantId && !e.tenantId ? Object.assign(Object.assign({}, e), { tenantId: n.tenantId }) : e;
401
- }
402
- async function W(n, e, t, i, r = {}) {
403
- return ot(n, r, async () => {
404
- let s = {}, o = {};
405
- i && (e === "GET" ? o = i : s = {
406
- body: JSON.stringify(i)
407
- });
408
- const c = x(Object.assign({ key: n.config.apiKey }, o)).slice(1), a = await n._getAdditionalHeaders();
409
- return a[
410
- "Content-Type"
411
- /* HttpHeader.CONTENT_TYPE */
412
- ] = "application/json", n.languageCode && (a[
413
- "X-Firebase-Locale"
414
- /* HttpHeader.X_FIREBASE_LOCALE */
415
- ] = n.languageCode), st.fetch()(ct(n, n.config.apiHost, t, c), Object.assign({
416
- method: e,
417
- headers: a,
418
- referrerPolicy: "no-referrer"
419
- }, s));
420
- });
421
- }
422
- async function ot(n, e, t) {
423
- n._canInitEmulator = !1;
424
- const i = Object.assign(Object.assign({}, wn), e);
425
- try {
426
- const r = new kn(n), s = await Promise.race([
427
- t(),
428
- r.promise
429
- ]);
430
- r.clearNetworkTimeout();
431
- const o = await s.json();
432
- if ("needConfirmation" in o)
433
- throw q(n, "account-exists-with-different-credential", o);
434
- if (s.ok && !("errorMessage" in o))
435
- return o;
436
- {
437
- const c = s.ok ? o.errorMessage : o.error.message, [a, l] = c.split(" : ");
438
- if (a === "FEDERATED_USER_ID_ALREADY_LINKED")
439
- throw q(n, "credential-already-in-use", o);
440
- if (a === "EMAIL_EXISTS")
441
- throw q(n, "email-already-in-use", o);
442
- if (a === "USER_DISABLED")
443
- throw q(n, "user-disabled", o);
444
- const d = i[a] || a.toLowerCase().replace(/[_\s]+/g, "-");
445
- if (l)
446
- throw vn(n, d, l);
447
- I(n, d);
448
- }
449
- } catch (r) {
450
- if (r instanceof ge)
451
- throw r;
452
- I(n, "network-request-failed", { message: String(r) });
453
- }
454
- }
455
- async function at(n, e, t, i, r = {}) {
456
- const s = await W(n, e, t, i, r);
457
- return "mfaPendingCredential" in s && I(n, "multi-factor-auth-required", {
458
- _serverResponse: s
459
- }), s;
460
- }
461
- function ct(n, e, t, i) {
462
- const r = `${e}${t}?${i}`;
463
- return n.config.emulator ? ve(n.config, r) : `${n.config.apiScheme}://${r}`;
464
- }
465
- class kn {
466
- constructor(e) {
467
- this.auth = e, this.timer = null, this.promise = new Promise((t, i) => {
468
- this.timer = setTimeout(() => i(g(
469
- this.auth,
470
- "network-request-failed"
471
- /* AuthErrorCode.NETWORK_REQUEST_FAILED */
472
- )), En.get());
473
- });
474
- }
475
- clearNetworkTimeout() {
476
- clearTimeout(this.timer);
477
- }
478
- }
479
- function q(n, e, t) {
480
- const i = {
481
- appName: n.name
482
- };
483
- t.email && (i.email = t.email), t.phoneNumber && (i.phoneNumber = t.phoneNumber);
484
- const r = g(n, e, i);
485
- return r.customData._tokenResponse = t, r;
486
- }
487
- /**
488
- * @license
489
- * Copyright 2020 Google LLC
490
- *
491
- * Licensed under the Apache License, Version 2.0 (the "License");
492
- * you may not use this file except in compliance with the License.
493
- * You may obtain a copy of the License at
494
- *
495
- * http://www.apache.org/licenses/LICENSE-2.0
496
- *
497
- * Unless required by applicable law or agreed to in writing, software
498
- * distributed under the License is distributed on an "AS IS" BASIS,
499
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
500
- * See the License for the specific language governing permissions and
501
- * limitations under the License.
502
- */
503
- async function Rn(n, e) {
504
- return W(n, "POST", "/v1/accounts:delete", e);
505
- }
506
- async function bn(n, e) {
507
- return W(n, "POST", "/v1/accounts:lookup", e);
508
- }
509
- /**
510
- * @license
511
- * Copyright 2020 Google LLC
512
- *
513
- * Licensed under the Apache License, Version 2.0 (the "License");
514
- * you may not use this file except in compliance with the License.
515
- * You may obtain a copy of the License at
516
- *
517
- * http://www.apache.org/licenses/LICENSE-2.0
518
- *
519
- * Unless required by applicable law or agreed to in writing, software
520
- * distributed under the License is distributed on an "AS IS" BASIS,
521
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
522
- * See the License for the specific language governing permissions and
523
- * limitations under the License.
524
- */
525
- function L(n) {
526
- if (n)
527
- try {
528
- const e = new Date(Number(n));
529
- if (!isNaN(e.getTime()))
530
- return e.toUTCString();
531
- } catch {
532
- }
533
- }
534
- async function Sn(n, e = !1) {
535
- const t = O(n), i = await t.getIdToken(e), r = ye(i);
536
- u(
537
- r && r.exp && r.auth_time && r.iat,
538
- t.auth,
539
- "internal-error"
540
- /* AuthErrorCode.INTERNAL_ERROR */
541
- );
542
- const s = typeof r.firebase == "object" ? r.firebase : void 0, o = s == null ? void 0 : s.sign_in_provider;
543
- return {
544
- claims: r,
545
- token: i,
546
- authTime: L(le(r.auth_time)),
547
- issuedAtTime: L(le(r.iat)),
548
- expirationTime: L(le(r.exp)),
549
- signInProvider: o || null,
550
- signInSecondFactor: (s == null ? void 0 : s.sign_in_second_factor) || null
551
- };
552
- }
553
- function le(n) {
554
- return Number(n) * 1e3;
555
- }
556
- function ye(n) {
557
- const [e, t, i] = n.split(".");
558
- if (e === void 0 || t === void 0 || i === void 0)
559
- return G("JWT malformed, contained fewer than 3 sections"), null;
560
- try {
561
- const r = sn(t);
562
- return r ? JSON.parse(r) : (G("Failed to decode base64 JWT payload"), null);
563
- } catch (r) {
564
- return G("Caught error parsing JWT payload as JSON", r == null ? void 0 : r.toString()), null;
565
- }
566
- }
567
- function An(n) {
568
- const e = ye(n);
569
- return u(
570
- e,
571
- "internal-error"
572
- /* AuthErrorCode.INTERNAL_ERROR */
573
- ), u(
574
- typeof e.exp < "u",
575
- "internal-error"
576
- /* AuthErrorCode.INTERNAL_ERROR */
577
- ), u(
578
- typeof e.iat < "u",
579
- "internal-error"
580
- /* AuthErrorCode.INTERNAL_ERROR */
581
- ), Number(e.exp) - Number(e.iat);
582
- }
583
- /**
584
- * @license
585
- * Copyright 2020 Google LLC
586
- *
587
- * Licensed under the Apache License, Version 2.0 (the "License");
588
- * you may not use this file except in compliance with the License.
589
- * You may obtain a copy of the License at
590
- *
591
- * http://www.apache.org/licenses/LICENSE-2.0
592
- *
593
- * Unless required by applicable law or agreed to in writing, software
594
- * distributed under the License is distributed on an "AS IS" BASIS,
595
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
596
- * See the License for the specific language governing permissions and
597
- * limitations under the License.
598
- */
599
- async function M(n, e, t = !1) {
600
- if (t)
601
- return e;
602
- try {
603
- return await e;
604
- } catch (i) {
605
- throw i instanceof ge && Cn(i) && n.auth.currentUser === n && await n.auth.signOut(), i;
606
- }
607
- }
608
- function Cn({ code: n }) {
609
- return n === "auth/user-disabled" || n === "auth/user-token-expired";
610
- }
611
- /**
612
- * @license
613
- * Copyright 2020 Google LLC
614
- *
615
- * Licensed under the Apache License, Version 2.0 (the "License");
616
- * you may not use this file except in compliance with the License.
617
- * You may obtain a copy of the License at
618
- *
619
- * http://www.apache.org/licenses/LICENSE-2.0
620
- *
621
- * Unless required by applicable law or agreed to in writing, software
622
- * distributed under the License is distributed on an "AS IS" BASIS,
623
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
624
- * See the License for the specific language governing permissions and
625
- * limitations under the License.
626
- */
627
- class Pn {
628
- constructor(e) {
629
- this.user = e, this.isRunning = !1, this.timerId = null, this.errorBackoff = 3e4;
630
- }
631
- _start() {
632
- this.isRunning || (this.isRunning = !0, this.schedule());
633
- }
634
- _stop() {
635
- this.isRunning && (this.isRunning = !1, this.timerId !== null && clearTimeout(this.timerId));
636
- }
637
- getInterval(e) {
638
- var t;
639
- if (e) {
640
- const i = this.errorBackoff;
641
- return this.errorBackoff = Math.min(
642
- this.errorBackoff * 2,
643
- 96e4
644
- /* Duration.RETRY_BACKOFF_MAX */
645
- ), i;
646
- } else {
647
- this.errorBackoff = 3e4;
648
- const r = ((t = this.user.stsTokenManager.expirationTime) !== null && t !== void 0 ? t : 0) - Date.now() - 3e5;
649
- return Math.max(0, r);
650
- }
651
- }
652
- schedule(e = !1) {
653
- if (!this.isRunning)
654
- return;
655
- const t = this.getInterval(e);
656
- this.timerId = setTimeout(async () => {
657
- await this.iteration();
658
- }, t);
659
- }
660
- async iteration() {
661
- try {
662
- await this.user.getIdToken(!0);
663
- } catch (e) {
664
- (e == null ? void 0 : e.code) === "auth/network-request-failed" && this.schedule(
665
- /* wasError */
666
- !0
667
- );
668
- return;
669
- }
670
- this.schedule();
671
- }
672
- }
673
- /**
674
- * @license
675
- * Copyright 2020 Google LLC
676
- *
677
- * Licensed under the Apache License, Version 2.0 (the "License");
678
- * you may not use this file except in compliance with the License.
679
- * You may obtain a copy of the License at
680
- *
681
- * http://www.apache.org/licenses/LICENSE-2.0
682
- *
683
- * Unless required by applicable law or agreed to in writing, software
684
- * distributed under the License is distributed on an "AS IS" BASIS,
685
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
686
- * See the License for the specific language governing permissions and
687
- * limitations under the License.
688
- */
689
- class lt {
690
- constructor(e, t) {
691
- this.createdAt = e, this.lastLoginAt = t, this._initializeTime();
692
- }
693
- _initializeTime() {
694
- this.lastSignInTime = L(this.lastLoginAt), this.creationTime = L(this.createdAt);
695
- }
696
- _copy(e) {
697
- this.createdAt = e.createdAt, this.lastLoginAt = e.lastLoginAt, this._initializeTime();
698
- }
699
- toJSON() {
700
- return {
701
- createdAt: this.createdAt,
702
- lastLoginAt: this.lastLoginAt
703
- };
704
- }
705
- }
706
- /**
707
- * @license
708
- * Copyright 2019 Google LLC
709
- *
710
- * Licensed under the Apache License, Version 2.0 (the "License");
711
- * you may not use this file except in compliance with the License.
712
- * You may obtain a copy of the License at
713
- *
714
- * http://www.apache.org/licenses/LICENSE-2.0
715
- *
716
- * Unless required by applicable law or agreed to in writing, software
717
- * distributed under the License is distributed on an "AS IS" BASIS,
718
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
719
- * See the License for the specific language governing permissions and
720
- * limitations under the License.
721
- */
722
- async function Q(n) {
723
- var e;
724
- const t = n.auth, i = await n.getIdToken(), r = await M(n, bn(t, { idToken: i }));
725
- u(
726
- r == null ? void 0 : r.users.length,
727
- t,
728
- "internal-error"
729
- /* AuthErrorCode.INTERNAL_ERROR */
730
- );
731
- const s = r.users[0];
732
- n._notifyReloadListener(s);
733
- const o = !((e = s.providerUserInfo) === null || e === void 0) && e.length ? Ln(s.providerUserInfo) : [], c = On(n.providerData, o), a = n.isAnonymous, l = !(n.email && s.passwordHash) && !(c != null && c.length), d = a ? l : !1, h = {
734
- uid: s.localId,
735
- displayName: s.displayName || null,
736
- photoURL: s.photoUrl || null,
737
- email: s.email || null,
738
- emailVerified: s.emailVerified || !1,
739
- phoneNumber: s.phoneNumber || null,
740
- tenantId: s.tenantId || null,
741
- providerData: c,
742
- metadata: new lt(s.createdAt, s.lastLoginAt),
743
- isAnonymous: d
744
- };
745
- Object.assign(n, h);
746
- }
747
- async function Nn(n) {
748
- const e = O(n);
749
- await Q(e), await e.auth._persistUserIfCurrent(e), e.auth._notifyListenersIfCurrent(e);
750
- }
751
- function On(n, e) {
752
- return [...n.filter((i) => !e.some((r) => r.providerId === i.providerId)), ...e];
753
- }
754
- function Ln(n) {
755
- return n.map((e) => {
756
- var { providerId: t } = e, i = me(e, ["providerId"]);
757
- return {
758
- providerId: t,
759
- uid: i.rawId || "",
760
- displayName: i.displayName || null,
761
- email: i.email || null,
762
- phoneNumber: i.phoneNumber || null,
763
- photoURL: i.photoUrl || null
764
- };
765
- });
766
- }
767
- /**
768
- * @license
769
- * Copyright 2020 Google LLC
770
- *
771
- * Licensed under the Apache License, Version 2.0 (the "License");
772
- * you may not use this file except in compliance with the License.
773
- * You may obtain a copy of the License at
774
- *
775
- * http://www.apache.org/licenses/LICENSE-2.0
776
- *
777
- * Unless required by applicable law or agreed to in writing, software
778
- * distributed under the License is distributed on an "AS IS" BASIS,
779
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
780
- * See the License for the specific language governing permissions and
781
- * limitations under the License.
782
- */
783
- async function Mn(n, e) {
784
- const t = await ot(n, {}, async () => {
785
- const i = x({
786
- grant_type: "refresh_token",
787
- refresh_token: e
788
- }).slice(1), { tokenApiHost: r, apiKey: s } = n.config, o = ct(n, r, "/v1/token", `key=${s}`), c = await n._getAdditionalHeaders();
789
- return c[
790
- "Content-Type"
791
- /* HttpHeader.CONTENT_TYPE */
792
- ] = "application/x-www-form-urlencoded", st.fetch()(o, {
793
- method: "POST",
794
- headers: c,
795
- body: i
796
- });
797
- });
798
- return {
799
- accessToken: t.access_token,
800
- expiresIn: t.expires_in,
801
- refreshToken: t.refresh_token
802
- };
803
- }
804
- /**
805
- * @license
806
- * Copyright 2020 Google LLC
807
- *
808
- * Licensed under the Apache License, Version 2.0 (the "License");
809
- * you may not use this file except in compliance with the License.
810
- * You may obtain a copy of the License at
811
- *
812
- * http://www.apache.org/licenses/LICENSE-2.0
813
- *
814
- * Unless required by applicable law or agreed to in writing, software
815
- * distributed under the License is distributed on an "AS IS" BASIS,
816
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
817
- * See the License for the specific language governing permissions and
818
- * limitations under the License.
819
- */
820
- class U {
821
- constructor() {
822
- this.refreshToken = null, this.accessToken = null, this.expirationTime = null;
823
- }
824
- get isExpired() {
825
- return !this.expirationTime || Date.now() > this.expirationTime - 3e4;
826
- }
827
- updateFromServerResponse(e) {
828
- u(
829
- e.idToken,
830
- "internal-error"
831
- /* AuthErrorCode.INTERNAL_ERROR */
832
- ), u(
833
- typeof e.idToken < "u",
834
- "internal-error"
835
- /* AuthErrorCode.INTERNAL_ERROR */
836
- ), u(
837
- typeof e.refreshToken < "u",
838
- "internal-error"
839
- /* AuthErrorCode.INTERNAL_ERROR */
840
- );
841
- const t = "expiresIn" in e && typeof e.expiresIn < "u" ? Number(e.expiresIn) : An(e.idToken);
842
- this.updateTokensAndExpiration(e.idToken, e.refreshToken, t);
843
- }
844
- async getToken(e, t = !1) {
845
- return u(
846
- !this.accessToken || this.refreshToken,
847
- e,
848
- "user-token-expired"
849
- /* AuthErrorCode.TOKEN_EXPIRED */
850
- ), !t && this.accessToken && !this.isExpired ? this.accessToken : this.refreshToken ? (await this.refresh(e, this.refreshToken), this.accessToken) : null;
851
- }
852
- clearRefreshToken() {
853
- this.refreshToken = null;
854
- }
855
- async refresh(e, t) {
856
- const { accessToken: i, refreshToken: r, expiresIn: s } = await Mn(e, t);
857
- this.updateTokensAndExpiration(i, r, Number(s));
858
- }
859
- updateTokensAndExpiration(e, t, i) {
860
- this.refreshToken = t || null, this.accessToken = e || null, this.expirationTime = Date.now() + i * 1e3;
861
- }
862
- static fromJSON(e, t) {
863
- const { refreshToken: i, accessToken: r, expirationTime: s } = t, o = new U();
864
- return i && (u(typeof i == "string", "internal-error", {
865
- appName: e
866
- }), o.refreshToken = i), r && (u(typeof r == "string", "internal-error", {
867
- appName: e
868
- }), o.accessToken = r), s && (u(typeof s == "number", "internal-error", {
869
- appName: e
870
- }), o.expirationTime = s), o;
871
- }
872
- toJSON() {
873
- return {
874
- refreshToken: this.refreshToken,
875
- accessToken: this.accessToken,
876
- expirationTime: this.expirationTime
877
- };
878
- }
879
- _assign(e) {
880
- this.accessToken = e.accessToken, this.refreshToken = e.refreshToken, this.expirationTime = e.expirationTime;
881
- }
882
- _clone() {
883
- return Object.assign(new U(), this.toJSON());
884
- }
885
- _performRefresh() {
886
- return _("not implemented");
887
- }
888
- }
889
- /**
890
- * @license
891
- * Copyright 2020 Google LLC
892
- *
893
- * Licensed under the Apache License, Version 2.0 (the "License");
894
- * you may not use this file except in compliance with the License.
895
- * You may obtain a copy of the License at
896
- *
897
- * http://www.apache.org/licenses/LICENSE-2.0
898
- *
899
- * Unless required by applicable law or agreed to in writing, software
900
- * distributed under the License is distributed on an "AS IS" BASIS,
901
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
902
- * See the License for the specific language governing permissions and
903
- * limitations under the License.
904
- */
905
- function T(n, e) {
906
- u(typeof n == "string" || typeof n > "u", "internal-error", { appName: e });
907
- }
908
- class b {
909
- constructor(e) {
910
- var { uid: t, auth: i, stsTokenManager: r } = e, s = me(e, ["uid", "auth", "stsTokenManager"]);
911
- this.providerId = "firebase", this.proactiveRefresh = new Pn(this), this.reloadUserInfo = null, this.reloadListener = null, this.uid = t, this.auth = i, this.stsTokenManager = r, this.accessToken = r.accessToken, this.displayName = s.displayName || null, this.email = s.email || null, this.emailVerified = s.emailVerified || !1, this.phoneNumber = s.phoneNumber || null, this.photoURL = s.photoURL || null, this.isAnonymous = s.isAnonymous || !1, this.tenantId = s.tenantId || null, this.providerData = s.providerData ? [...s.providerData] : [], this.metadata = new lt(s.createdAt || void 0, s.lastLoginAt || void 0);
912
- }
913
- async getIdToken(e) {
914
- const t = await M(this, this.stsTokenManager.getToken(this.auth, e));
915
- return u(
916
- t,
917
- this.auth,
918
- "internal-error"
919
- /* AuthErrorCode.INTERNAL_ERROR */
920
- ), this.accessToken !== t && (this.accessToken = t, await this.auth._persistUserIfCurrent(this), this.auth._notifyListenersIfCurrent(this)), t;
921
- }
922
- getIdTokenResult(e) {
923
- return Sn(this, e);
924
- }
925
- reload() {
926
- return Nn(this);
927
- }
928
- _assign(e) {
929
- this !== e && (u(
930
- this.uid === e.uid,
931
- this.auth,
932
- "internal-error"
933
- /* AuthErrorCode.INTERNAL_ERROR */
934
- ), this.displayName = e.displayName, this.photoURL = e.photoURL, this.email = e.email, this.emailVerified = e.emailVerified, this.phoneNumber = e.phoneNumber, this.isAnonymous = e.isAnonymous, this.tenantId = e.tenantId, this.providerData = e.providerData.map((t) => Object.assign({}, t)), this.metadata._copy(e.metadata), this.stsTokenManager._assign(e.stsTokenManager));
935
- }
936
- _clone(e) {
937
- const t = new b(Object.assign(Object.assign({}, this), { auth: e, stsTokenManager: this.stsTokenManager._clone() }));
938
- return t.metadata._copy(this.metadata), t;
939
- }
940
- _onReload(e) {
941
- u(
942
- !this.reloadListener,
943
- this.auth,
944
- "internal-error"
945
- /* AuthErrorCode.INTERNAL_ERROR */
946
- ), this.reloadListener = e, this.reloadUserInfo && (this._notifyReloadListener(this.reloadUserInfo), this.reloadUserInfo = null);
947
- }
948
- _notifyReloadListener(e) {
949
- this.reloadListener ? this.reloadListener(e) : this.reloadUserInfo = e;
950
- }
951
- _startProactiveRefresh() {
952
- this.proactiveRefresh._start();
953
- }
954
- _stopProactiveRefresh() {
955
- this.proactiveRefresh._stop();
956
- }
957
- async _updateTokensIfNecessary(e, t = !1) {
958
- let i = !1;
959
- e.idToken && e.idToken !== this.stsTokenManager.accessToken && (this.stsTokenManager.updateFromServerResponse(e), i = !0), t && await Q(this), await this.auth._persistUserIfCurrent(this), i && this.auth._notifyListenersIfCurrent(this);
960
- }
961
- async delete() {
962
- const e = await this.getIdToken();
963
- return await M(this, Rn(this.auth, { idToken: e })), this.stsTokenManager.clearRefreshToken(), this.auth.signOut();
964
- }
965
- toJSON() {
966
- return Object.assign(Object.assign({
967
- uid: this.uid,
968
- email: this.email || void 0,
969
- emailVerified: this.emailVerified,
970
- displayName: this.displayName || void 0,
971
- isAnonymous: this.isAnonymous,
972
- photoURL: this.photoURL || void 0,
973
- phoneNumber: this.phoneNumber || void 0,
974
- tenantId: this.tenantId || void 0,
975
- providerData: this.providerData.map((e) => Object.assign({}, e)),
976
- stsTokenManager: this.stsTokenManager.toJSON(),
977
- // Redirect event ID must be maintained in case there is a pending
978
- // redirect event.
979
- _redirectEventId: this._redirectEventId
980
- }, this.metadata.toJSON()), {
981
- // Required for compatibility with the legacy SDK (go/firebase-auth-sdk-persistence-parsing):
982
- apiKey: this.auth.config.apiKey,
983
- appName: this.auth.name
984
- });
985
- }
986
- get refreshToken() {
987
- return this.stsTokenManager.refreshToken || "";
988
- }
989
- static _fromJSON(e, t) {
990
- var i, r, s, o, c, a, l, d;
991
- const h = (i = t.displayName) !== null && i !== void 0 ? i : void 0, p = (r = t.email) !== null && r !== void 0 ? r : void 0, B = (s = t.phoneNumber) !== null && s !== void 0 ? s : void 0, K = (o = t.photoURL) !== null && o !== void 0 ? o : void 0, ke = (c = t.tenantId) !== null && c !== void 0 ? c : void 0, se = (a = t._redirectEventId) !== null && a !== void 0 ? a : void 0, Re = (l = t.createdAt) !== null && l !== void 0 ? l : void 0, be = (d = t.lastLoginAt) !== null && d !== void 0 ? d : void 0, { uid: oe, emailVerified: Se, isAnonymous: Ae, providerData: ae, stsTokenManager: Ce } = t;
992
- u(
993
- oe && Ce,
994
- e,
995
- "internal-error"
996
- /* AuthErrorCode.INTERNAL_ERROR */
997
- );
998
- const Dt = U.fromJSON(this.name, Ce);
999
- u(
1000
- typeof oe == "string",
1001
- e,
1002
- "internal-error"
1003
- /* AuthErrorCode.INTERNAL_ERROR */
1004
- ), T(h, e.name), T(p, e.name), u(
1005
- typeof Se == "boolean",
1006
- e,
1007
- "internal-error"
1008
- /* AuthErrorCode.INTERNAL_ERROR */
1009
- ), u(
1010
- typeof Ae == "boolean",
1011
- e,
1012
- "internal-error"
1013
- /* AuthErrorCode.INTERNAL_ERROR */
1014
- ), T(B, e.name), T(K, e.name), T(ke, e.name), T(se, e.name), T(Re, e.name), T(be, e.name);
1015
- const ce = new b({
1016
- uid: oe,
1017
- auth: e,
1018
- email: p,
1019
- emailVerified: Se,
1020
- displayName: h,
1021
- isAnonymous: Ae,
1022
- photoURL: K,
1023
- phoneNumber: B,
1024
- tenantId: ke,
1025
- stsTokenManager: Dt,
1026
- createdAt: Re,
1027
- lastLoginAt: be
1028
- });
1029
- return ae && Array.isArray(ae) && (ce.providerData = ae.map((Ft) => Object.assign({}, Ft))), se && (ce._redirectEventId = se), ce;
1030
- }
1031
- /**
1032
- * Initialize a User from an idToken server response
1033
- * @param auth
1034
- * @param idTokenResponse
1035
- */
1036
- static async _fromIdTokenResponse(e, t, i = !1) {
1037
- const r = new U();
1038
- r.updateFromServerResponse(t);
1039
- const s = new b({
1040
- uid: t.localId,
1041
- auth: e,
1042
- stsTokenManager: r,
1043
- isAnonymous: i
1044
- });
1045
- return await Q(s), s;
1046
- }
1047
- }
1048
- /**
1049
- * @license
1050
- * Copyright 2020 Google LLC
1051
- *
1052
- * Licensed under the Apache License, Version 2.0 (the "License");
1053
- * you may not use this file except in compliance with the License.
1054
- * You may obtain a copy of the License at
1055
- *
1056
- * http://www.apache.org/licenses/LICENSE-2.0
1057
- *
1058
- * Unless required by applicable law or agreed to in writing, software
1059
- * distributed under the License is distributed on an "AS IS" BASIS,
1060
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1061
- * See the License for the specific language governing permissions and
1062
- * limitations under the License.
1063
- */
1064
- const Me = /* @__PURE__ */ new Map();
1065
- function v(n) {
1066
- y(n instanceof Function, "Expected a class definition");
1067
- let e = Me.get(n);
1068
- return e ? (y(e instanceof n, "Instance stored in cache mismatched with class"), e) : (e = new n(), Me.set(n, e), e);
1069
- }
1070
- /**
1071
- * @license
1072
- * Copyright 2019 Google LLC
1073
- *
1074
- * Licensed under the Apache License, Version 2.0 (the "License");
1075
- * you may not use this file except in compliance with the License.
1076
- * You may obtain a copy of the License at
1077
- *
1078
- * http://www.apache.org/licenses/LICENSE-2.0
1079
- *
1080
- * Unless required by applicable law or agreed to in writing, software
1081
- * distributed under the License is distributed on an "AS IS" BASIS,
1082
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1083
- * See the License for the specific language governing permissions and
1084
- * limitations under the License.
1085
- */
1086
- class ut {
1087
- constructor() {
1088
- this.type = "NONE", this.storage = {};
1089
- }
1090
- async _isAvailable() {
1091
- return !0;
1092
- }
1093
- async _set(e, t) {
1094
- this.storage[e] = t;
1095
- }
1096
- async _get(e) {
1097
- const t = this.storage[e];
1098
- return t === void 0 ? null : t;
1099
- }
1100
- async _remove(e) {
1101
- delete this.storage[e];
1102
- }
1103
- _addListener(e, t) {
1104
- }
1105
- _removeListener(e, t) {
1106
- }
1107
- }
1108
- ut.type = "NONE";
1109
- const Ue = ut;
1110
- /**
1111
- * @license
1112
- * Copyright 2019 Google LLC
1113
- *
1114
- * Licensed under the Apache License, Version 2.0 (the "License");
1115
- * you may not use this file except in compliance with the License.
1116
- * You may obtain a copy of the License at
1117
- *
1118
- * http://www.apache.org/licenses/LICENSE-2.0
1119
- *
1120
- * Unless required by applicable law or agreed to in writing, software
1121
- * distributed under the License is distributed on an "AS IS" BASIS,
1122
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1123
- * See the License for the specific language governing permissions and
1124
- * limitations under the License.
1125
- */
1126
- function z(n, e, t) {
1127
- return `firebase:${n}:${e}:${t}`;
1128
- }
1129
- class P {
1130
- constructor(e, t, i) {
1131
- this.persistence = e, this.auth = t, this.userKey = i;
1132
- const { config: r, name: s } = this.auth;
1133
- this.fullUserKey = z(this.userKey, r.apiKey, s), this.fullPersistenceKey = z("persistence", r.apiKey, s), this.boundEventHandler = t._onStorageEvent.bind(t), this.persistence._addListener(this.fullUserKey, this.boundEventHandler);
1134
- }
1135
- setCurrentUser(e) {
1136
- return this.persistence._set(this.fullUserKey, e.toJSON());
1137
- }
1138
- async getCurrentUser() {
1139
- const e = await this.persistence._get(this.fullUserKey);
1140
- return e ? b._fromJSON(this.auth, e) : null;
1141
- }
1142
- removeCurrentUser() {
1143
- return this.persistence._remove(this.fullUserKey);
1144
- }
1145
- savePersistenceForRedirect() {
1146
- return this.persistence._set(this.fullPersistenceKey, this.persistence.type);
1147
- }
1148
- async setPersistence(e) {
1149
- if (this.persistence === e)
1150
- return;
1151
- const t = await this.getCurrentUser();
1152
- if (await this.removeCurrentUser(), this.persistence = e, t)
1153
- return this.setCurrentUser(t);
1154
- }
1155
- delete() {
1156
- this.persistence._removeListener(this.fullUserKey, this.boundEventHandler);
1157
- }
1158
- static async create(e, t, i = "authUser") {
1159
- if (!t.length)
1160
- return new P(v(Ue), e, i);
1161
- const r = (await Promise.all(t.map(async (l) => {
1162
- if (await l._isAvailable())
1163
- return l;
1164
- }))).filter((l) => l);
1165
- let s = r[0] || v(Ue);
1166
- const o = z(i, e.config.apiKey, e.name);
1167
- let c = null;
1168
- for (const l of t)
1169
- try {
1170
- const d = await l._get(o);
1171
- if (d) {
1172
- const h = b._fromJSON(e, d);
1173
- l !== s && (c = h), s = l;
1174
- break;
1175
- }
1176
- } catch {
1177
- }
1178
- const a = r.filter((l) => l._shouldAllowMigration);
1179
- return !s._shouldAllowMigration || !a.length ? new P(s, e, i) : (s = a[0], c && await s._set(o, c.toJSON()), await Promise.all(t.map(async (l) => {
1180
- if (l !== s)
1181
- try {
1182
- await l._remove(o);
1183
- } catch {
1184
- }
1185
- })), new P(s, e, i));
1186
- }
1187
- }
1188
- /**
1189
- * @license
1190
- * Copyright 2020 Google LLC
1191
- *
1192
- * Licensed under the Apache License, Version 2.0 (the "License");
1193
- * you may not use this file except in compliance with the License.
1194
- * You may obtain a copy of the License at
1195
- *
1196
- * http://www.apache.org/licenses/LICENSE-2.0
1197
- *
1198
- * Unless required by applicable law or agreed to in writing, software
1199
- * distributed under the License is distributed on an "AS IS" BASIS,
1200
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1201
- * See the License for the specific language governing permissions and
1202
- * limitations under the License.
1203
- */
1204
- function De(n) {
1205
- const e = n.toLowerCase();
1206
- if (e.includes("opera/") || e.includes("opr/") || e.includes("opios/"))
1207
- return "Opera";
1208
- if (ft(e))
1209
- return "IEMobile";
1210
- if (e.includes("msie") || e.includes("trident/"))
1211
- return "IE";
1212
- if (e.includes("edge/"))
1213
- return "Edge";
1214
- if (dt(e))
1215
- return "Firefox";
1216
- if (e.includes("silk/"))
1217
- return "Silk";
1218
- if (gt(e))
1219
- return "Blackberry";
1220
- if (mt(e))
1221
- return "Webos";
1222
- if (Te(e))
1223
- return "Safari";
1224
- if ((e.includes("chrome/") || ht(e)) && !e.includes("edge/"))
1225
- return "Chrome";
1226
- if (pt(e))
1227
- return "Android";
1228
- {
1229
- const t = /([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/, i = n.match(t);
1230
- if ((i == null ? void 0 : i.length) === 2)
1231
- return i[1];
1232
- }
1233
- return "Other";
1234
- }
1235
- function dt(n = f()) {
1236
- return /firefox\//i.test(n);
1237
- }
1238
- function Te(n = f()) {
1239
- const e = n.toLowerCase();
1240
- return e.includes("safari/") && !e.includes("chrome/") && !e.includes("crios/") && !e.includes("android");
1241
- }
1242
- function ht(n = f()) {
1243
- return /crios\//i.test(n);
1244
- }
1245
- function ft(n = f()) {
1246
- return /iemobile/i.test(n);
1247
- }
1248
- function pt(n = f()) {
1249
- return /android/i.test(n);
1250
- }
1251
- function gt(n = f()) {
1252
- return /blackberry/i.test(n);
1253
- }
1254
- function mt(n = f()) {
1255
- return /webos/i.test(n);
1256
- }
1257
- function ne(n = f()) {
1258
- return /iphone|ipad|ipod/i.test(n) || /macintosh/i.test(n) && /mobile/i.test(n);
1259
- }
1260
- function Un(n = f()) {
1261
- var e;
1262
- return ne(n) && !!(!((e = window.navigator) === null || e === void 0) && e.standalone);
1263
- }
1264
- function Dn() {
1265
- return on() && document.documentMode === 10;
1266
- }
1267
- function _t(n = f()) {
1268
- return ne(n) || pt(n) || mt(n) || gt(n) || /windows phone/i.test(n) || ft(n);
1269
- }
1270
- function Fn() {
1271
- try {
1272
- return !!(window && window !== window.top);
1273
- } catch {
1274
- return !1;
1275
- }
1276
- }
1277
- /**
1278
- * @license
1279
- * Copyright 2020 Google LLC
1280
- *
1281
- * Licensed under the Apache License, Version 2.0 (the "License");
1282
- * you may not use this file except in compliance with the License.
1283
- * You may obtain a copy of the License at
1284
- *
1285
- * http://www.apache.org/licenses/LICENSE-2.0
1286
- *
1287
- * Unless required by applicable law or agreed to in writing, software
1288
- * distributed under the License is distributed on an "AS IS" BASIS,
1289
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1290
- * See the License for the specific language governing permissions and
1291
- * limitations under the License.
1292
- */
1293
- function vt(n, e = []) {
1294
- let t;
1295
- switch (n) {
1296
- case "Browser":
1297
- t = De(f());
1298
- break;
1299
- case "Worker":
1300
- t = `${De(f())}-${n}`;
1301
- break;
1302
- default:
1303
- t = n;
1304
- }
1305
- const i = e.length ? e.join(",") : "FirebaseCore-web";
1306
- return `${t}/JsCore/${F}/${i}`;
1307
- }
1308
- async function It(n, e) {
1309
- return W(n, "GET", "/v2/recaptchaConfig", Ie(n, e));
1310
- }
1311
- function Fe(n) {
1312
- return n !== void 0 && n.enterprise !== void 0;
1313
- }
1314
- class yt {
1315
- constructor(e) {
1316
- if (this.siteKey = "", this.emailPasswordEnabled = !1, e.recaptchaKey === void 0)
1317
- throw new Error("recaptchaKey undefined");
1318
- this.siteKey = e.recaptchaKey.split("/")[3], this.emailPasswordEnabled = e.recaptchaEnforcementState.some((t) => t.provider === "EMAIL_PASSWORD_PROVIDER" && t.enforcementState !== "OFF");
1319
- }
1320
- }
1321
- /**
1322
- * @license
1323
- * Copyright 2020 Google LLC
1324
- *
1325
- * Licensed under the Apache License, Version 2.0 (the "License");
1326
- * you may not use this file except in compliance with the License.
1327
- * You may obtain a copy of the License at
1328
- *
1329
- * http://www.apache.org/licenses/LICENSE-2.0
1330
- *
1331
- * Unless required by applicable law or agreed to in writing, software
1332
- * distributed under the License is distributed on an "AS IS" BASIS,
1333
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1334
- * See the License for the specific language governing permissions and
1335
- * limitations under the License.
1336
- */
1337
- function xn() {
1338
- var n, e;
1339
- return (e = (n = document.getElementsByTagName("head")) === null || n === void 0 ? void 0 : n[0]) !== null && e !== void 0 ? e : document;
1340
- }
1341
- function Tt(n) {
1342
- return new Promise((e, t) => {
1343
- const i = document.createElement("script");
1344
- i.setAttribute("src", n), i.onload = e, i.onerror = (r) => {
1345
- const s = g(
1346
- "internal-error"
1347
- /* AuthErrorCode.INTERNAL_ERROR */
1348
- );
1349
- s.customData = r, t(s);
1350
- }, i.type = "text/javascript", i.charset = "UTF-8", xn().appendChild(i);
1351
- });
1352
- }
1353
- function Vn(n) {
1354
- return `__${n}${Math.floor(Math.random() * 1e6)}`;
1355
- }
1356
- const Wn = "https://www.google.com/recaptcha/enterprise.js?render=", Hn = "recaptcha-enterprise", $n = "NO_RECAPTCHA";
1357
- class jn {
1358
- /**
1359
- *
1360
- * @param authExtern - The corresponding Firebase {@link Auth} instance.
1361
- *
1362
- */
1363
- constructor(e) {
1364
- this.type = Hn, this.auth = H(e);
1365
- }
1366
- /**
1367
- * Executes the verification process.
1368
- *
1369
- * @returns A Promise for a token that can be used to assert the validity of a request.
1370
- */
1371
- async verify(e = "verify", t = !1) {
1372
- async function i(s) {
1373
- if (!t) {
1374
- if (s.tenantId == null && s._agentRecaptchaConfig != null)
1375
- return s._agentRecaptchaConfig.siteKey;
1376
- if (s.tenantId != null && s._tenantRecaptchaConfigs[s.tenantId] !== void 0)
1377
- return s._tenantRecaptchaConfigs[s.tenantId].siteKey;
1378
- }
1379
- return new Promise(async (o, c) => {
1380
- It(s, {
1381
- clientType: "CLIENT_TYPE_WEB",
1382
- version: "RECAPTCHA_ENTERPRISE"
1383
- /* RecaptchaVersion.ENTERPRISE */
1384
- }).then((a) => {
1385
- if (a.recaptchaKey === void 0)
1386
- c(new Error("recaptcha Enterprise site key undefined"));
1387
- else {
1388
- const l = new yt(a);
1389
- return s.tenantId == null ? s._agentRecaptchaConfig = l : s._tenantRecaptchaConfigs[s.tenantId] = l, o(l.siteKey);
1390
- }
1391
- }).catch((a) => {
1392
- c(a);
1393
- });
1394
- });
1395
- }
1396
- function r(s, o, c) {
1397
- const a = window.grecaptcha;
1398
- Fe(a) ? a.enterprise.ready(() => {
1399
- a.enterprise.execute(s, { action: e }).then((l) => {
1400
- o(l);
1401
- }).catch(() => {
1402
- o($n);
1403
- });
1404
- }) : c(Error("No reCAPTCHA enterprise script loaded."));
1405
- }
1406
- return new Promise((s, o) => {
1407
- i(this.auth).then((c) => {
1408
- if (!t && Fe(window.grecaptcha))
1409
- r(c, s, o);
1410
- else {
1411
- if (typeof window > "u") {
1412
- o(new Error("RecaptchaVerifier is only supported in browser"));
1413
- return;
1414
- }
1415
- Tt(Wn + c).then(() => {
1416
- r(c, s, o);
1417
- }).catch((a) => {
1418
- o(a);
1419
- });
1420
- }
1421
- }).catch((c) => {
1422
- o(c);
1423
- });
1424
- });
1425
- }
1426
- }
1427
- /**
1428
- * @license
1429
- * Copyright 2022 Google LLC
1430
- *
1431
- * Licensed under the Apache License, Version 2.0 (the "License");
1432
- * you may not use this file except in compliance with the License.
1433
- * You may obtain a copy of the License at
1434
- *
1435
- * http://www.apache.org/licenses/LICENSE-2.0
1436
- *
1437
- * Unless required by applicable law or agreed to in writing, software
1438
- * distributed under the License is distributed on an "AS IS" BASIS,
1439
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1440
- * See the License for the specific language governing permissions and
1441
- * limitations under the License.
1442
- */
1443
- class Bn {
1444
- constructor(e) {
1445
- this.auth = e, this.queue = [];
1446
- }
1447
- pushCallback(e, t) {
1448
- const i = (s) => new Promise((o, c) => {
1449
- try {
1450
- const a = e(s);
1451
- o(a);
1452
- } catch (a) {
1453
- c(a);
1454
- }
1455
- });
1456
- i.onAbort = t, this.queue.push(i);
1457
- const r = this.queue.length - 1;
1458
- return () => {
1459
- this.queue[r] = () => Promise.resolve();
1460
- };
1461
- }
1462
- async runMiddleware(e) {
1463
- if (this.auth.currentUser === e)
1464
- return;
1465
- const t = [];
1466
- try {
1467
- for (const i of this.queue)
1468
- await i(e), i.onAbort && t.push(i.onAbort);
1469
- } catch (i) {
1470
- t.reverse();
1471
- for (const r of t)
1472
- try {
1473
- r();
1474
- } catch {
1475
- }
1476
- throw this.auth._errorFactory.create("login-blocked", {
1477
- originalMessage: i == null ? void 0 : i.message
1478
- });
1479
- }
1480
- }
1481
- }
1482
- /**
1483
- * @license
1484
- * Copyright 2020 Google LLC
1485
- *
1486
- * Licensed under the Apache License, Version 2.0 (the "License");
1487
- * you may not use this file except in compliance with the License.
1488
- * You may obtain a copy of the License at
1489
- *
1490
- * http://www.apache.org/licenses/LICENSE-2.0
1491
- *
1492
- * Unless required by applicable law or agreed to in writing, software
1493
- * distributed under the License is distributed on an "AS IS" BASIS,
1494
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1495
- * See the License for the specific language governing permissions and
1496
- * limitations under the License.
1497
- */
1498
- class Kn {
1499
- constructor(e, t, i, r) {
1500
- this.app = e, this.heartbeatServiceProvider = t, this.appCheckServiceProvider = i, this.config = r, this.currentUser = null, this.emulatorConfig = null, this.operations = Promise.resolve(), this.authStateSubscription = new xe(this), this.idTokenSubscription = new xe(this), this.beforeStateQueue = new Bn(this), this.redirectUser = null, this.isProactiveRefreshEnabled = !1, this._canInitEmulator = !0, this._isInitialized = !1, this._deleted = !1, this._initializationPromise = null, this._popupRedirectResolver = null, this._errorFactory = rt, this._agentRecaptchaConfig = null, this._tenantRecaptchaConfigs = {}, this.lastNotifiedUid = void 0, this.languageCode = null, this.tenantId = null, this.settings = { appVerificationDisabledForTesting: !1 }, this.frameworks = [], this.name = e.name, this.clientVersion = r.sdkClientVersion;
1501
- }
1502
- _initializeWithPersistence(e, t) {
1503
- return t && (this._popupRedirectResolver = v(t)), this._initializationPromise = this.queue(async () => {
1504
- var i, r;
1505
- if (!this._deleted && (this.persistenceManager = await P.create(this, e), !this._deleted)) {
1506
- if (!((i = this._popupRedirectResolver) === null || i === void 0) && i._shouldInitProactively)
1507
- try {
1508
- await this._popupRedirectResolver._initialize(this);
1509
- } catch {
1510
- }
1511
- await this.initializeCurrentUser(t), this.lastNotifiedUid = ((r = this.currentUser) === null || r === void 0 ? void 0 : r.uid) || null, !this._deleted && (this._isInitialized = !0);
1512
- }
1513
- }), this._initializationPromise;
1514
- }
1515
- /**
1516
- * If the persistence is changed in another window, the user manager will let us know
1517
- */
1518
- async _onStorageEvent() {
1519
- if (this._deleted)
1520
- return;
1521
- const e = await this.assertedPersistence.getCurrentUser();
1522
- if (!(!this.currentUser && !e)) {
1523
- if (this.currentUser && e && this.currentUser.uid === e.uid) {
1524
- this._currentUser._assign(e), await this.currentUser.getIdToken();
1525
- return;
1526
- }
1527
- await this._updateCurrentUser(
1528
- e,
1529
- /* skipBeforeStateCallbacks */
1530
- !0
1531
- );
1532
- }
1533
- }
1534
- async initializeCurrentUser(e) {
1535
- var t;
1536
- const i = await this.assertedPersistence.getCurrentUser();
1537
- let r = i, s = !1;
1538
- if (e && this.config.authDomain) {
1539
- await this.getOrInitRedirectPersistenceManager();
1540
- const o = (t = this.redirectUser) === null || t === void 0 ? void 0 : t._redirectEventId, c = r == null ? void 0 : r._redirectEventId, a = await this.tryRedirectSignIn(e);
1541
- (!o || o === c) && (a != null && a.user) && (r = a.user, s = !0);
1542
- }
1543
- if (!r)
1544
- return this.directlySetCurrentUser(null);
1545
- if (!r._redirectEventId) {
1546
- if (s)
1547
- try {
1548
- await this.beforeStateQueue.runMiddleware(r);
1549
- } catch (o) {
1550
- r = i, this._popupRedirectResolver._overrideRedirectResult(this, () => Promise.reject(o));
1551
- }
1552
- return r ? this.reloadAndSetCurrentUserOrClear(r) : this.directlySetCurrentUser(null);
1553
- }
1554
- return u(
1555
- this._popupRedirectResolver,
1556
- this,
1557
- "argument-error"
1558
- /* AuthErrorCode.ARGUMENT_ERROR */
1559
- ), await this.getOrInitRedirectPersistenceManager(), this.redirectUser && this.redirectUser._redirectEventId === r._redirectEventId ? this.directlySetCurrentUser(r) : this.reloadAndSetCurrentUserOrClear(r);
1560
- }
1561
- async tryRedirectSignIn(e) {
1562
- let t = null;
1563
- try {
1564
- t = await this._popupRedirectResolver._completeRedirectFn(this, e, !0);
1565
- } catch {
1566
- await this._setRedirectUser(null);
1567
- }
1568
- return t;
1569
- }
1570
- async reloadAndSetCurrentUserOrClear(e) {
1571
- try {
1572
- await Q(e);
1573
- } catch (t) {
1574
- if ((t == null ? void 0 : t.code) !== "auth/network-request-failed")
1575
- return this.directlySetCurrentUser(null);
1576
- }
1577
- return this.directlySetCurrentUser(e);
1578
- }
1579
- useDeviceLanguage() {
1580
- this.languageCode = Tn();
1581
- }
1582
- async _delete() {
1583
- this._deleted = !0;
1584
- }
1585
- async updateCurrentUser(e) {
1586
- const t = e ? O(e) : null;
1587
- return t && u(
1588
- t.auth.config.apiKey === this.config.apiKey,
1589
- this,
1590
- "invalid-user-token"
1591
- /* AuthErrorCode.INVALID_AUTH */
1592
- ), this._updateCurrentUser(t && t._clone(this));
1593
- }
1594
- async _updateCurrentUser(e, t = !1) {
1595
- if (!this._deleted)
1596
- return e && u(
1597
- this.tenantId === e.tenantId,
1598
- this,
1599
- "tenant-id-mismatch"
1600
- /* AuthErrorCode.TENANT_ID_MISMATCH */
1601
- ), t || await this.beforeStateQueue.runMiddleware(e), this.queue(async () => {
1602
- await this.directlySetCurrentUser(e), this.notifyAuthListeners();
1603
- });
1604
- }
1605
- async signOut() {
1606
- return await this.beforeStateQueue.runMiddleware(null), (this.redirectPersistenceManager || this._popupRedirectResolver) && await this._setRedirectUser(null), this._updateCurrentUser(
1607
- null,
1608
- /* skipBeforeStateCallbacks */
1609
- !0
1610
- );
1611
- }
1612
- setPersistence(e) {
1613
- return this.queue(async () => {
1614
- await this.assertedPersistence.setPersistence(v(e));
1615
- });
1616
- }
1617
- async initializeRecaptchaConfig() {
1618
- const e = await It(this, {
1619
- clientType: "CLIENT_TYPE_WEB",
1620
- version: "RECAPTCHA_ENTERPRISE"
1621
- /* RecaptchaVersion.ENTERPRISE */
1622
- }), t = new yt(e);
1623
- this.tenantId == null ? this._agentRecaptchaConfig = t : this._tenantRecaptchaConfigs[this.tenantId] = t, t.emailPasswordEnabled && new jn(this).verify();
1624
- }
1625
- _getRecaptchaConfig() {
1626
- return this.tenantId == null ? this._agentRecaptchaConfig : this._tenantRecaptchaConfigs[this.tenantId];
1627
- }
1628
- _getPersistence() {
1629
- return this.assertedPersistence.persistence.type;
1630
- }
1631
- _updateErrorMap(e) {
1632
- this._errorFactory = new pe("auth", "Firebase", e());
1633
- }
1634
- onAuthStateChanged(e, t, i) {
1635
- return this.registerStateListener(this.authStateSubscription, e, t, i);
1636
- }
1637
- beforeAuthStateChanged(e, t) {
1638
- return this.beforeStateQueue.pushCallback(e, t);
1639
- }
1640
- onIdTokenChanged(e, t, i) {
1641
- return this.registerStateListener(this.idTokenSubscription, e, t, i);
1642
- }
1643
- toJSON() {
1644
- var e;
1645
- return {
1646
- apiKey: this.config.apiKey,
1647
- authDomain: this.config.authDomain,
1648
- appName: this.name,
1649
- currentUser: (e = this._currentUser) === null || e === void 0 ? void 0 : e.toJSON()
1650
- };
1651
- }
1652
- async _setRedirectUser(e, t) {
1653
- const i = await this.getOrInitRedirectPersistenceManager(t);
1654
- return e === null ? i.removeCurrentUser() : i.setCurrentUser(e);
1655
- }
1656
- async getOrInitRedirectPersistenceManager(e) {
1657
- if (!this.redirectPersistenceManager) {
1658
- const t = e && v(e) || this._popupRedirectResolver;
1659
- u(
1660
- t,
1661
- this,
1662
- "argument-error"
1663
- /* AuthErrorCode.ARGUMENT_ERROR */
1664
- ), this.redirectPersistenceManager = await P.create(
1665
- this,
1666
- [v(t._redirectPersistence)],
1667
- "redirectUser"
1668
- /* KeyName.REDIRECT_USER */
1669
- ), this.redirectUser = await this.redirectPersistenceManager.getCurrentUser();
1670
- }
1671
- return this.redirectPersistenceManager;
1672
- }
1673
- async _redirectUserForId(e) {
1674
- var t, i;
1675
- return this._isInitialized && await this.queue(async () => {
1676
- }), ((t = this._currentUser) === null || t === void 0 ? void 0 : t._redirectEventId) === e ? this._currentUser : ((i = this.redirectUser) === null || i === void 0 ? void 0 : i._redirectEventId) === e ? this.redirectUser : null;
1677
- }
1678
- async _persistUserIfCurrent(e) {
1679
- if (e === this.currentUser)
1680
- return this.queue(async () => this.directlySetCurrentUser(e));
1681
- }
1682
- /** Notifies listeners only if the user is current */
1683
- _notifyListenersIfCurrent(e) {
1684
- e === this.currentUser && this.notifyAuthListeners();
1685
- }
1686
- _key() {
1687
- return `${this.config.authDomain}:${this.config.apiKey}:${this.name}`;
1688
- }
1689
- _startProactiveRefresh() {
1690
- this.isProactiveRefreshEnabled = !0, this.currentUser && this._currentUser._startProactiveRefresh();
1691
- }
1692
- _stopProactiveRefresh() {
1693
- this.isProactiveRefreshEnabled = !1, this.currentUser && this._currentUser._stopProactiveRefresh();
1694
- }
1695
- /** Returns the current user cast as the internal type */
1696
- get _currentUser() {
1697
- return this.currentUser;
1698
- }
1699
- notifyAuthListeners() {
1700
- var e, t;
1701
- if (!this._isInitialized)
1702
- return;
1703
- this.idTokenSubscription.next(this.currentUser);
1704
- const i = (t = (e = this.currentUser) === null || e === void 0 ? void 0 : e.uid) !== null && t !== void 0 ? t : null;
1705
- this.lastNotifiedUid !== i && (this.lastNotifiedUid = i, this.authStateSubscription.next(this.currentUser));
1706
- }
1707
- registerStateListener(e, t, i, r) {
1708
- if (this._deleted)
1709
- return () => {
1710
- };
1711
- const s = typeof t == "function" ? t : t.next.bind(t), o = this._isInitialized ? Promise.resolve() : this._initializationPromise;
1712
- return u(
1713
- o,
1714
- this,
1715
- "internal-error"
1716
- /* AuthErrorCode.INTERNAL_ERROR */
1717
- ), o.then(() => s(this.currentUser)), typeof t == "function" ? e.addObserver(t, i, r) : e.addObserver(t);
1718
- }
1719
- /**
1720
- * Unprotected (from race conditions) method to set the current user. This
1721
- * should only be called from within a queued callback. This is necessary
1722
- * because the queue shouldn't rely on another queued callback.
1723
- */
1724
- async directlySetCurrentUser(e) {
1725
- this.currentUser && this.currentUser !== e && this._currentUser._stopProactiveRefresh(), e && this.isProactiveRefreshEnabled && e._startProactiveRefresh(), this.currentUser = e, e ? await this.assertedPersistence.setCurrentUser(e) : await this.assertedPersistence.removeCurrentUser();
1726
- }
1727
- queue(e) {
1728
- return this.operations = this.operations.then(e, e), this.operations;
1729
- }
1730
- get assertedPersistence() {
1731
- return u(
1732
- this.persistenceManager,
1733
- this,
1734
- "internal-error"
1735
- /* AuthErrorCode.INTERNAL_ERROR */
1736
- ), this.persistenceManager;
1737
- }
1738
- _logFramework(e) {
1739
- !e || this.frameworks.includes(e) || (this.frameworks.push(e), this.frameworks.sort(), this.clientVersion = vt(this.config.clientPlatform, this._getFrameworks()));
1740
- }
1741
- _getFrameworks() {
1742
- return this.frameworks;
1743
- }
1744
- async _getAdditionalHeaders() {
1745
- var e;
1746
- const t = {
1747
- "X-Client-Version": this.clientVersion
1748
- };
1749
- this.app.options.appId && (t[
1750
- "X-Firebase-gmpid"
1751
- /* HttpHeader.X_FIREBASE_GMPID */
1752
- ] = this.app.options.appId);
1753
- const i = await ((e = this.heartbeatServiceProvider.getImmediate({
1754
- optional: !0
1755
- })) === null || e === void 0 ? void 0 : e.getHeartbeatsHeader());
1756
- i && (t[
1757
- "X-Firebase-Client"
1758
- /* HttpHeader.X_FIREBASE_CLIENT */
1759
- ] = i);
1760
- const r = await this._getAppCheckToken();
1761
- return r && (t[
1762
- "X-Firebase-AppCheck"
1763
- /* HttpHeader.X_FIREBASE_APP_CHECK */
1764
- ] = r), t;
1765
- }
1766
- async _getAppCheckToken() {
1767
- var e;
1768
- const t = await ((e = this.appCheckServiceProvider.getImmediate({ optional: !0 })) === null || e === void 0 ? void 0 : e.getToken());
1769
- return t != null && t.error && _n(`Error while retrieving App Check token: ${t.error}`), t == null ? void 0 : t.token;
1770
- }
1771
- }
1772
- function H(n) {
1773
- return O(n);
1774
- }
1775
- class xe {
1776
- constructor(e) {
1777
- this.auth = e, this.observer = null, this.addObserver = Zt((t) => this.observer = t);
1778
- }
1779
- get next() {
1780
- return u(
1781
- this.observer,
1782
- this.auth,
1783
- "internal-error"
1784
- /* AuthErrorCode.INTERNAL_ERROR */
1785
- ), this.observer.next.bind(this.observer);
1786
- }
1787
- }
1788
- /**
1789
- * @license
1790
- * Copyright 2020 Google LLC
1791
- *
1792
- * Licensed under the Apache License, Version 2.0 (the "License");
1793
- * you may not use this file except in compliance with the License.
1794
- * You may obtain a copy of the License at
1795
- *
1796
- * http://www.apache.org/licenses/LICENSE-2.0
1797
- *
1798
- * Unless required by applicable law or agreed to in writing, software
1799
- * distributed under the License is distributed on an "AS IS" BASIS,
1800
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1801
- * See the License for the specific language governing permissions and
1802
- * limitations under the License.
1803
- */
1804
- function qn(n, e) {
1805
- const t = tt(n, "auth");
1806
- if (t.isInitialized()) {
1807
- const r = t.getImmediate(), s = t.getOptions();
1808
- if (nn(s, e ?? {}))
1809
- return r;
1810
- I(
1811
- r,
1812
- "already-initialized"
1813
- /* AuthErrorCode.ALREADY_INITIALIZED */
1814
- );
1815
- }
1816
- return t.initialize({ options: e });
1817
- }
1818
- function Gn(n, e) {
1819
- const t = (e == null ? void 0 : e.persistence) || [], i = (Array.isArray(t) ? t : [t]).map(v);
1820
- e != null && e.errorMap && n._updateErrorMap(e.errorMap), n._initializeWithPersistence(i, e == null ? void 0 : e.popupRedirectResolver);
1821
- }
1822
- function zn(n, e, t) {
1823
- const i = H(n);
1824
- u(
1825
- i._canInitEmulator,
1826
- i,
1827
- "emulator-config-failed"
1828
- /* AuthErrorCode.EMULATOR_CONFIG_FAILED */
1829
- ), u(
1830
- /^https?:\/\//.test(e),
1831
- i,
1832
- "invalid-emulator-scheme"
1833
- /* AuthErrorCode.INVALID_EMULATOR_SCHEME */
1834
- );
1835
- const r = !!(t != null && t.disableWarnings), s = wt(e), { host: o, port: c } = Jn(e), a = c === null ? "" : `:${c}`;
1836
- i.config.emulator = { url: `${s}//${o}${a}/` }, i.settings.appVerificationDisabledForTesting = !0, i.emulatorConfig = Object.freeze({
1837
- host: o,
1838
- port: c,
1839
- protocol: s.replace(":", ""),
1840
- options: Object.freeze({ disableWarnings: r })
1841
- }), r || Yn();
1842
- }
1843
- function wt(n) {
1844
- const e = n.indexOf(":");
1845
- return e < 0 ? "" : n.substr(0, e + 1);
1846
- }
1847
- function Jn(n) {
1848
- const e = wt(n), t = /(\/\/)?([^?#/]+)/.exec(n.substr(e.length));
1849
- if (!t)
1850
- return { host: "", port: null };
1851
- const i = t[2].split("@").pop() || "", r = /^(\[[^\]]+\])(:|$)/.exec(i);
1852
- if (r) {
1853
- const s = r[1];
1854
- return { host: s, port: Ve(i.substr(s.length + 1)) };
1855
- } else {
1856
- const [s, o] = i.split(":");
1857
- return { host: s, port: Ve(o) };
1858
- }
1859
- }
1860
- function Ve(n) {
1861
- if (!n)
1862
- return null;
1863
- const e = Number(n);
1864
- return isNaN(e) ? null : e;
1865
- }
1866
- function Yn() {
1867
- function n() {
1868
- const e = document.createElement("p"), t = e.style;
1869
- e.innerText = "Running in emulator mode. Do not use with production credentials.", t.position = "fixed", t.width = "100%", t.backgroundColor = "#ffffff", t.border = ".1em solid #000000", t.color = "#b50000", t.bottom = "0px", t.left = "0px", t.margin = "0px", t.zIndex = "10000", t.textAlign = "center", e.classList.add("firebase-emulator-warning"), document.body.appendChild(e);
1870
- }
1871
- typeof console < "u" && typeof console.info == "function" && console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials."), typeof window < "u" && typeof document < "u" && (document.readyState === "loading" ? window.addEventListener("DOMContentLoaded", n) : n());
1872
- }
1873
- /**
1874
- * @license
1875
- * Copyright 2020 Google LLC
1876
- *
1877
- * Licensed under the Apache License, Version 2.0 (the "License");
1878
- * you may not use this file except in compliance with the License.
1879
- * You may obtain a copy of the License at
1880
- *
1881
- * http://www.apache.org/licenses/LICENSE-2.0
1882
- *
1883
- * Unless required by applicable law or agreed to in writing, software
1884
- * distributed under the License is distributed on an "AS IS" BASIS,
1885
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1886
- * See the License for the specific language governing permissions and
1887
- * limitations under the License.
1888
- */
1889
- class Et {
1890
- /** @internal */
1891
- constructor(e, t) {
1892
- this.providerId = e, this.signInMethod = t;
1893
- }
1894
- /**
1895
- * Returns a JSON-serializable representation of this object.
1896
- *
1897
- * @returns a JSON-serializable representation of this object.
1898
- */
1899
- toJSON() {
1900
- return _("not implemented");
1901
- }
1902
- /** @internal */
1903
- _getIdTokenResponse(e) {
1904
- return _("not implemented");
1905
- }
1906
- /** @internal */
1907
- _linkToIdToken(e, t) {
1908
- return _("not implemented");
1909
- }
1910
- /** @internal */
1911
- _getReauthenticationResolver(e) {
1912
- return _("not implemented");
1913
- }
1914
- }
1915
- /**
1916
- * @license
1917
- * Copyright 2020 Google LLC
1918
- *
1919
- * Licensed under the Apache License, Version 2.0 (the "License");
1920
- * you may not use this file except in compliance with the License.
1921
- * You may obtain a copy of the License at
1922
- *
1923
- * http://www.apache.org/licenses/LICENSE-2.0
1924
- *
1925
- * Unless required by applicable law or agreed to in writing, software
1926
- * distributed under the License is distributed on an "AS IS" BASIS,
1927
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1928
- * See the License for the specific language governing permissions and
1929
- * limitations under the License.
1930
- */
1931
- async function N(n, e) {
1932
- return at(n, "POST", "/v1/accounts:signInWithIdp", Ie(n, e));
1933
- }
1934
- /**
1935
- * @license
1936
- * Copyright 2020 Google LLC
1937
- *
1938
- * Licensed under the Apache License, Version 2.0 (the "License");
1939
- * you may not use this file except in compliance with the License.
1940
- * You may obtain a copy of the License at
1941
- *
1942
- * http://www.apache.org/licenses/LICENSE-2.0
1943
- *
1944
- * Unless required by applicable law or agreed to in writing, software
1945
- * distributed under the License is distributed on an "AS IS" BASIS,
1946
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1947
- * See the License for the specific language governing permissions and
1948
- * limitations under the License.
1949
- */
1950
- const Xn = "http://localhost";
1951
- class S extends Et {
1952
- constructor() {
1953
- super(...arguments), this.pendingToken = null;
1954
- }
1955
- /** @internal */
1956
- static _fromParams(e) {
1957
- const t = new S(e.providerId, e.signInMethod);
1958
- return e.idToken || e.accessToken ? (e.idToken && (t.idToken = e.idToken), e.accessToken && (t.accessToken = e.accessToken), e.nonce && !e.pendingToken && (t.nonce = e.nonce), e.pendingToken && (t.pendingToken = e.pendingToken)) : e.oauthToken && e.oauthTokenSecret ? (t.accessToken = e.oauthToken, t.secret = e.oauthTokenSecret) : I(
1959
- "argument-error"
1960
- /* AuthErrorCode.ARGUMENT_ERROR */
1961
- ), t;
1962
- }
1963
- /** {@inheritdoc AuthCredential.toJSON} */
1964
- toJSON() {
1965
- return {
1966
- idToken: this.idToken,
1967
- accessToken: this.accessToken,
1968
- secret: this.secret,
1969
- nonce: this.nonce,
1970
- pendingToken: this.pendingToken,
1971
- providerId: this.providerId,
1972
- signInMethod: this.signInMethod
1973
- };
1974
- }
1975
- /**
1976
- * Static method to deserialize a JSON representation of an object into an
1977
- * {@link AuthCredential}.
1978
- *
1979
- * @param json - Input can be either Object or the stringified representation of the object.
1980
- * When string is provided, JSON.parse would be called first.
1981
- *
1982
- * @returns If the JSON input does not represent an {@link AuthCredential}, null is returned.
1983
- */
1984
- static fromJSON(e) {
1985
- const t = typeof e == "string" ? JSON.parse(e) : e, { providerId: i, signInMethod: r } = t, s = me(t, ["providerId", "signInMethod"]);
1986
- if (!i || !r)
1987
- return null;
1988
- const o = new S(i, r);
1989
- return o.idToken = s.idToken || void 0, o.accessToken = s.accessToken || void 0, o.secret = s.secret, o.nonce = s.nonce, o.pendingToken = s.pendingToken || null, o;
1990
- }
1991
- /** @internal */
1992
- _getIdTokenResponse(e) {
1993
- const t = this.buildRequest();
1994
- return N(e, t);
1995
- }
1996
- /** @internal */
1997
- _linkToIdToken(e, t) {
1998
- const i = this.buildRequest();
1999
- return i.idToken = t, N(e, i);
2000
- }
2001
- /** @internal */
2002
- _getReauthenticationResolver(e) {
2003
- const t = this.buildRequest();
2004
- return t.autoCreate = !1, N(e, t);
2005
- }
2006
- buildRequest() {
2007
- const e = {
2008
- requestUri: Xn,
2009
- returnSecureToken: !0
2010
- };
2011
- if (this.pendingToken)
2012
- e.pendingToken = this.pendingToken;
2013
- else {
2014
- const t = {};
2015
- this.idToken && (t.id_token = this.idToken), this.accessToken && (t.access_token = this.accessToken), this.secret && (t.oauth_token_secret = this.secret), t.providerId = this.providerId, this.nonce && !this.pendingToken && (t.nonce = this.nonce), e.postBody = x(t);
2016
- }
2017
- return e;
2018
- }
2019
- }
2020
- /**
2021
- * @license
2022
- * Copyright 2020 Google LLC
2023
- *
2024
- * Licensed under the Apache License, Version 2.0 (the "License");
2025
- * you may not use this file except in compliance with the License.
2026
- * You may obtain a copy of the License at
2027
- *
2028
- * http://www.apache.org/licenses/LICENSE-2.0
2029
- *
2030
- * Unless required by applicable law or agreed to in writing, software
2031
- * distributed under the License is distributed on an "AS IS" BASIS,
2032
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2033
- * See the License for the specific language governing permissions and
2034
- * limitations under the License.
2035
- */
2036
- class kt {
2037
- /**
2038
- * Constructor for generic OAuth providers.
2039
- *
2040
- * @param providerId - Provider for which credentials should be generated.
2041
- */
2042
- constructor(e) {
2043
- this.providerId = e, this.defaultLanguageCode = null, this.customParameters = {};
2044
- }
2045
- /**
2046
- * Set the language gode.
2047
- *
2048
- * @param languageCode - language code
2049
- */
2050
- setDefaultLanguage(e) {
2051
- this.defaultLanguageCode = e;
2052
- }
2053
- /**
2054
- * Sets the OAuth custom parameters to pass in an OAuth request for popup and redirect sign-in
2055
- * operations.
2056
- *
2057
- * @remarks
2058
- * For a detailed list, check the reserved required OAuth 2.0 parameters such as `client_id`,
2059
- * `redirect_uri`, `scope`, `response_type`, and `state` are not allowed and will be ignored.
2060
- *
2061
- * @param customOAuthParameters - The custom OAuth parameters to pass in the OAuth request.
2062
- */
2063
- setCustomParameters(e) {
2064
- return this.customParameters = e, this;
2065
- }
2066
- /**
2067
- * Retrieve the current list of {@link CustomParameters}.
2068
- */
2069
- getCustomParameters() {
2070
- return this.customParameters;
2071
- }
2072
- }
2073
- /**
2074
- * @license
2075
- * Copyright 2019 Google LLC
2076
- *
2077
- * Licensed under the Apache License, Version 2.0 (the "License");
2078
- * you may not use this file except in compliance with the License.
2079
- * You may obtain a copy of the License at
2080
- *
2081
- * http://www.apache.org/licenses/LICENSE-2.0
2082
- *
2083
- * Unless required by applicable law or agreed to in writing, software
2084
- * distributed under the License is distributed on an "AS IS" BASIS,
2085
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2086
- * See the License for the specific language governing permissions and
2087
- * limitations under the License.
2088
- */
2089
- class $ extends kt {
2090
- constructor() {
2091
- super(...arguments), this.scopes = [];
2092
- }
2093
- /**
2094
- * Add an OAuth scope to the credential.
2095
- *
2096
- * @param scope - Provider OAuth scope to add.
2097
- */
2098
- addScope(e) {
2099
- return this.scopes.includes(e) || this.scopes.push(e), this;
2100
- }
2101
- /**
2102
- * Retrieve the current list of OAuth scopes.
2103
- */
2104
- getScopes() {
2105
- return [...this.scopes];
2106
- }
2107
- }
2108
- /**
2109
- * @license
2110
- * Copyright 2020 Google LLC
2111
- *
2112
- * Licensed under the Apache License, Version 2.0 (the "License");
2113
- * you may not use this file except in compliance with the License.
2114
- * You may obtain a copy of the License at
2115
- *
2116
- * http://www.apache.org/licenses/LICENSE-2.0
2117
- *
2118
- * Unless required by applicable law or agreed to in writing, software
2119
- * distributed under the License is distributed on an "AS IS" BASIS,
2120
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2121
- * See the License for the specific language governing permissions and
2122
- * limitations under the License.
2123
- */
2124
- class w extends $ {
2125
- constructor() {
2126
- super(
2127
- "facebook.com"
2128
- /* ProviderId.FACEBOOK */
2129
- );
2130
- }
2131
- /**
2132
- * Creates a credential for Facebook.
2133
- *
2134
- * @example
2135
- * ```javascript
2136
- * // `event` from the Facebook auth.authResponseChange callback.
2137
- * const credential = FacebookAuthProvider.credential(event.authResponse.accessToken);
2138
- * const result = await signInWithCredential(credential);
2139
- * ```
2140
- *
2141
- * @param accessToken - Facebook access token.
2142
- */
2143
- static credential(e) {
2144
- return S._fromParams({
2145
- providerId: w.PROVIDER_ID,
2146
- signInMethod: w.FACEBOOK_SIGN_IN_METHOD,
2147
- accessToken: e
2148
- });
2149
- }
2150
- /**
2151
- * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
2152
- *
2153
- * @param userCredential - The user credential.
2154
- */
2155
- static credentialFromResult(e) {
2156
- return w.credentialFromTaggedObject(e);
2157
- }
2158
- /**
2159
- * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
2160
- * thrown during a sign-in, link, or reauthenticate operation.
2161
- *
2162
- * @param userCredential - The user credential.
2163
- */
2164
- static credentialFromError(e) {
2165
- return w.credentialFromTaggedObject(e.customData || {});
2166
- }
2167
- static credentialFromTaggedObject({ _tokenResponse: e }) {
2168
- if (!e || !("oauthAccessToken" in e) || !e.oauthAccessToken)
2169
- return null;
2170
- try {
2171
- return w.credential(e.oauthAccessToken);
2172
- } catch {
2173
- return null;
2174
- }
2175
- }
2176
- }
2177
- w.FACEBOOK_SIGN_IN_METHOD = "facebook.com";
2178
- w.PROVIDER_ID = "facebook.com";
2179
- /**
2180
- * @license
2181
- * Copyright 2020 Google LLC
2182
- *
2183
- * Licensed under the Apache License, Version 2.0 (the "License");
2184
- * you may not use this file except in compliance with the License.
2185
- * You may obtain a copy of the License at
2186
- *
2187
- * http://www.apache.org/licenses/LICENSE-2.0
2188
- *
2189
- * Unless required by applicable law or agreed to in writing, software
2190
- * distributed under the License is distributed on an "AS IS" BASIS,
2191
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2192
- * See the License for the specific language governing permissions and
2193
- * limitations under the License.
2194
- */
2195
- class E extends $ {
2196
- constructor() {
2197
- super(
2198
- "google.com"
2199
- /* ProviderId.GOOGLE */
2200
- ), this.addScope("profile");
2201
- }
2202
- /**
2203
- * Creates a credential for Google. At least one of ID token and access token is required.
2204
- *
2205
- * @example
2206
- * ```javascript
2207
- * // \`googleUser\` from the onsuccess Google Sign In callback.
2208
- * const credential = GoogleAuthProvider.credential(googleUser.getAuthResponse().id_token);
2209
- * const result = await signInWithCredential(credential);
2210
- * ```
2211
- *
2212
- * @param idToken - Google ID token.
2213
- * @param accessToken - Google access token.
2214
- */
2215
- static credential(e, t) {
2216
- return S._fromParams({
2217
- providerId: E.PROVIDER_ID,
2218
- signInMethod: E.GOOGLE_SIGN_IN_METHOD,
2219
- idToken: e,
2220
- accessToken: t
2221
- });
2222
- }
2223
- /**
2224
- * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
2225
- *
2226
- * @param userCredential - The user credential.
2227
- */
2228
- static credentialFromResult(e) {
2229
- return E.credentialFromTaggedObject(e);
2230
- }
2231
- /**
2232
- * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
2233
- * thrown during a sign-in, link, or reauthenticate operation.
2234
- *
2235
- * @param userCredential - The user credential.
2236
- */
2237
- static credentialFromError(e) {
2238
- return E.credentialFromTaggedObject(e.customData || {});
2239
- }
2240
- static credentialFromTaggedObject({ _tokenResponse: e }) {
2241
- if (!e)
2242
- return null;
2243
- const { oauthIdToken: t, oauthAccessToken: i } = e;
2244
- if (!t && !i)
2245
- return null;
2246
- try {
2247
- return E.credential(t, i);
2248
- } catch {
2249
- return null;
2250
- }
2251
- }
2252
- }
2253
- E.GOOGLE_SIGN_IN_METHOD = "google.com";
2254
- E.PROVIDER_ID = "google.com";
2255
- /**
2256
- * @license
2257
- * Copyright 2020 Google LLC
2258
- *
2259
- * Licensed under the Apache License, Version 2.0 (the "License");
2260
- * you may not use this file except in compliance with the License.
2261
- * You may obtain a copy of the License at
2262
- *
2263
- * http://www.apache.org/licenses/LICENSE-2.0
2264
- *
2265
- * Unless required by applicable law or agreed to in writing, software
2266
- * distributed under the License is distributed on an "AS IS" BASIS,
2267
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2268
- * See the License for the specific language governing permissions and
2269
- * limitations under the License.
2270
- */
2271
- class k extends $ {
2272
- constructor() {
2273
- super(
2274
- "github.com"
2275
- /* ProviderId.GITHUB */
2276
- );
2277
- }
2278
- /**
2279
- * Creates a credential for Github.
2280
- *
2281
- * @param accessToken - Github access token.
2282
- */
2283
- static credential(e) {
2284
- return S._fromParams({
2285
- providerId: k.PROVIDER_ID,
2286
- signInMethod: k.GITHUB_SIGN_IN_METHOD,
2287
- accessToken: e
2288
- });
2289
- }
2290
- /**
2291
- * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
2292
- *
2293
- * @param userCredential - The user credential.
2294
- */
2295
- static credentialFromResult(e) {
2296
- return k.credentialFromTaggedObject(e);
2297
- }
2298
- /**
2299
- * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
2300
- * thrown during a sign-in, link, or reauthenticate operation.
2301
- *
2302
- * @param userCredential - The user credential.
2303
- */
2304
- static credentialFromError(e) {
2305
- return k.credentialFromTaggedObject(e.customData || {});
2306
- }
2307
- static credentialFromTaggedObject({ _tokenResponse: e }) {
2308
- if (!e || !("oauthAccessToken" in e) || !e.oauthAccessToken)
2309
- return null;
2310
- try {
2311
- return k.credential(e.oauthAccessToken);
2312
- } catch {
2313
- return null;
2314
- }
2315
- }
2316
- }
2317
- k.GITHUB_SIGN_IN_METHOD = "github.com";
2318
- k.PROVIDER_ID = "github.com";
2319
- /**
2320
- * @license
2321
- * Copyright 2020 Google LLC
2322
- *
2323
- * Licensed under the Apache License, Version 2.0 (the "License");
2324
- * you may not use this file except in compliance with the License.
2325
- * You may obtain a copy of the License at
2326
- *
2327
- * http://www.apache.org/licenses/LICENSE-2.0
2328
- *
2329
- * Unless required by applicable law or agreed to in writing, software
2330
- * distributed under the License is distributed on an "AS IS" BASIS,
2331
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2332
- * See the License for the specific language governing permissions and
2333
- * limitations under the License.
2334
- */
2335
- class R extends $ {
2336
- constructor() {
2337
- super(
2338
- "twitter.com"
2339
- /* ProviderId.TWITTER */
2340
- );
2341
- }
2342
- /**
2343
- * Creates a credential for Twitter.
2344
- *
2345
- * @param token - Twitter access token.
2346
- * @param secret - Twitter secret.
2347
- */
2348
- static credential(e, t) {
2349
- return S._fromParams({
2350
- providerId: R.PROVIDER_ID,
2351
- signInMethod: R.TWITTER_SIGN_IN_METHOD,
2352
- oauthToken: e,
2353
- oauthTokenSecret: t
2354
- });
2355
- }
2356
- /**
2357
- * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
2358
- *
2359
- * @param userCredential - The user credential.
2360
- */
2361
- static credentialFromResult(e) {
2362
- return R.credentialFromTaggedObject(e);
2363
- }
2364
- /**
2365
- * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
2366
- * thrown during a sign-in, link, or reauthenticate operation.
2367
- *
2368
- * @param userCredential - The user credential.
2369
- */
2370
- static credentialFromError(e) {
2371
- return R.credentialFromTaggedObject(e.customData || {});
2372
- }
2373
- static credentialFromTaggedObject({ _tokenResponse: e }) {
2374
- if (!e)
2375
- return null;
2376
- const { oauthAccessToken: t, oauthTokenSecret: i } = e;
2377
- if (!t || !i)
2378
- return null;
2379
- try {
2380
- return R.credential(t, i);
2381
- } catch {
2382
- return null;
2383
- }
2384
- }
2385
- }
2386
- R.TWITTER_SIGN_IN_METHOD = "twitter.com";
2387
- R.PROVIDER_ID = "twitter.com";
2388
- /**
2389
- * @license
2390
- * Copyright 2020 Google LLC
2391
- *
2392
- * Licensed under the Apache License, Version 2.0 (the "License");
2393
- * you may not use this file except in compliance with the License.
2394
- * You may obtain a copy of the License at
2395
- *
2396
- * http://www.apache.org/licenses/LICENSE-2.0
2397
- *
2398
- * Unless required by applicable law or agreed to in writing, software
2399
- * distributed under the License is distributed on an "AS IS" BASIS,
2400
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2401
- * See the License for the specific language governing permissions and
2402
- * limitations under the License.
2403
- */
2404
- class A {
2405
- constructor(e) {
2406
- this.user = e.user, this.providerId = e.providerId, this._tokenResponse = e._tokenResponse, this.operationType = e.operationType;
2407
- }
2408
- static async _fromIdTokenResponse(e, t, i, r = !1) {
2409
- const s = await b._fromIdTokenResponse(e, i, r), o = We(i);
2410
- return new A({
2411
- user: s,
2412
- providerId: o,
2413
- _tokenResponse: i,
2414
- operationType: t
2415
- });
2416
- }
2417
- static async _forOperation(e, t, i) {
2418
- await e._updateTokensIfNecessary(
2419
- i,
2420
- /* reload */
2421
- !0
2422
- );
2423
- const r = We(i);
2424
- return new A({
2425
- user: e,
2426
- providerId: r,
2427
- _tokenResponse: i,
2428
- operationType: t
2429
- });
2430
- }
2431
- }
2432
- function We(n) {
2433
- return n.providerId ? n.providerId : "phoneNumber" in n ? "phone" : null;
2434
- }
2435
- /**
2436
- * @license
2437
- * Copyright 2020 Google LLC
2438
- *
2439
- * Licensed under the Apache License, Version 2.0 (the "License");
2440
- * you may not use this file except in compliance with the License.
2441
- * You may obtain a copy of the License at
2442
- *
2443
- * http://www.apache.org/licenses/LICENSE-2.0
2444
- *
2445
- * Unless required by applicable law or agreed to in writing, software
2446
- * distributed under the License is distributed on an "AS IS" BASIS,
2447
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2448
- * See the License for the specific language governing permissions and
2449
- * limitations under the License.
2450
- */
2451
- class Z extends ge {
2452
- constructor(e, t, i, r) {
2453
- var s;
2454
- super(t.code, t.message), this.operationType = i, this.user = r, Object.setPrototypeOf(this, Z.prototype), this.customData = {
2455
- appName: e.name,
2456
- tenantId: (s = e.tenantId) !== null && s !== void 0 ? s : void 0,
2457
- _serverResponse: t.customData._serverResponse,
2458
- operationType: i
2459
- };
2460
- }
2461
- static _fromErrorAndOperation(e, t, i, r) {
2462
- return new Z(e, t, i, r);
2463
- }
2464
- }
2465
- function Rt(n, e, t, i) {
2466
- return (e === "reauthenticate" ? t._getReauthenticationResolver(n) : t._getIdTokenResponse(n)).catch((s) => {
2467
- throw s.code === "auth/multi-factor-auth-required" ? Z._fromErrorAndOperation(n, s, e, i) : s;
2468
- });
2469
- }
2470
- async function Qn(n, e, t = !1) {
2471
- const i = await M(n, e._linkToIdToken(n.auth, await n.getIdToken()), t);
2472
- return A._forOperation(n, "link", i);
2473
- }
2474
- /**
2475
- * @license
2476
- * Copyright 2019 Google LLC
2477
- *
2478
- * Licensed under the Apache License, Version 2.0 (the "License");
2479
- * you may not use this file except in compliance with the License.
2480
- * You may obtain a copy of the License at
2481
- *
2482
- * http://www.apache.org/licenses/LICENSE-2.0
2483
- *
2484
- * Unless required by applicable law or agreed to in writing, software
2485
- * distributed under the License is distributed on an "AS IS" BASIS,
2486
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2487
- * See the License for the specific language governing permissions and
2488
- * limitations under the License.
2489
- */
2490
- async function Zn(n, e, t = !1) {
2491
- const { auth: i } = n, r = "reauthenticate";
2492
- try {
2493
- const s = await M(n, Rt(i, r, e, n), t);
2494
- u(
2495
- s.idToken,
2496
- i,
2497
- "internal-error"
2498
- /* AuthErrorCode.INTERNAL_ERROR */
2499
- );
2500
- const o = ye(s.idToken);
2501
- u(
2502
- o,
2503
- i,
2504
- "internal-error"
2505
- /* AuthErrorCode.INTERNAL_ERROR */
2506
- );
2507
- const { sub: c } = o;
2508
- return u(
2509
- n.uid === c,
2510
- i,
2511
- "user-mismatch"
2512
- /* AuthErrorCode.USER_MISMATCH */
2513
- ), A._forOperation(n, r, s);
2514
- } catch (s) {
2515
- throw (s == null ? void 0 : s.code) === "auth/user-not-found" && I(
2516
- i,
2517
- "user-mismatch"
2518
- /* AuthErrorCode.USER_MISMATCH */
2519
- ), s;
2520
- }
2521
- }
2522
- /**
2523
- * @license
2524
- * Copyright 2020 Google LLC
2525
- *
2526
- * Licensed under the Apache License, Version 2.0 (the "License");
2527
- * you may not use this file except in compliance with the License.
2528
- * You may obtain a copy of the License at
2529
- *
2530
- * http://www.apache.org/licenses/LICENSE-2.0
2531
- *
2532
- * Unless required by applicable law or agreed to in writing, software
2533
- * distributed under the License is distributed on an "AS IS" BASIS,
2534
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2535
- * See the License for the specific language governing permissions and
2536
- * limitations under the License.
2537
- */
2538
- async function ei(n, e, t = !1) {
2539
- const i = "signIn", r = await Rt(n, i, e), s = await A._fromIdTokenResponse(n, i, r);
2540
- return t || await n._updateCurrentUser(s.user), s;
2541
- }
2542
- /**
2543
- * @license
2544
- * Copyright 2020 Google LLC
2545
- *
2546
- * Licensed under the Apache License, Version 2.0 (the "License");
2547
- * you may not use this file except in compliance with the License.
2548
- * You may obtain a copy of the License at
2549
- *
2550
- * http://www.apache.org/licenses/LICENSE-2.0
2551
- *
2552
- * Unless required by applicable law or agreed to in writing, software
2553
- * distributed under the License is distributed on an "AS IS" BASIS,
2554
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2555
- * See the License for the specific language governing permissions and
2556
- * limitations under the License.
2557
- */
2558
- async function ti(n, e) {
2559
- return at(n, "POST", "/v1/accounts:signInWithCustomToken", Ie(n, e));
2560
- }
2561
- /**
2562
- * @license
2563
- * Copyright 2020 Google LLC
2564
- *
2565
- * Licensed under the Apache License, Version 2.0 (the "License");
2566
- * you may not use this file except in compliance with the License.
2567
- * You may obtain a copy of the License at
2568
- *
2569
- * http://www.apache.org/licenses/LICENSE-2.0
2570
- *
2571
- * Unless required by applicable law or agreed to in writing, software
2572
- * distributed under the License is distributed on an "AS IS" BASIS,
2573
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2574
- * See the License for the specific language governing permissions and
2575
- * limitations under the License.
2576
- */
2577
- async function ni(n, e) {
2578
- const t = H(n), i = await ti(t, {
2579
- token: e,
2580
- returnSecureToken: !0
2581
- }), r = await A._fromIdTokenResponse(t, "signIn", i);
2582
- return await t._updateCurrentUser(r.user), r;
2583
- }
2584
- function ii(n, e, t, i) {
2585
- return O(n).onIdTokenChanged(e, t, i);
2586
- }
2587
- function ri(n, e, t) {
2588
- return O(n).beforeAuthStateChanged(e, t);
2589
- }
2590
- const ee = "__sak";
2591
- /**
2592
- * @license
2593
- * Copyright 2019 Google LLC
2594
- *
2595
- * Licensed under the Apache License, Version 2.0 (the "License");
2596
- * you may not use this file except in compliance with the License.
2597
- * You may obtain a copy of the License at
2598
- *
2599
- * http://www.apache.org/licenses/LICENSE-2.0
2600
- *
2601
- * Unless required by applicable law or agreed to in writing, software
2602
- * distributed under the License is distributed on an "AS IS" BASIS,
2603
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2604
- * See the License for the specific language governing permissions and
2605
- * limitations under the License.
2606
- */
2607
- class bt {
2608
- constructor(e, t) {
2609
- this.storageRetriever = e, this.type = t;
2610
- }
2611
- _isAvailable() {
2612
- try {
2613
- return this.storage ? (this.storage.setItem(ee, "1"), this.storage.removeItem(ee), Promise.resolve(!0)) : Promise.resolve(!1);
2614
- } catch {
2615
- return Promise.resolve(!1);
2616
- }
2617
- }
2618
- _set(e, t) {
2619
- return this.storage.setItem(e, JSON.stringify(t)), Promise.resolve();
2620
- }
2621
- _get(e) {
2622
- const t = this.storage.getItem(e);
2623
- return Promise.resolve(t ? JSON.parse(t) : null);
2624
- }
2625
- _remove(e) {
2626
- return this.storage.removeItem(e), Promise.resolve();
2627
- }
2628
- get storage() {
2629
- return this.storageRetriever();
2630
- }
2631
- }
2632
- /**
2633
- * @license
2634
- * Copyright 2020 Google LLC
2635
- *
2636
- * Licensed under the Apache License, Version 2.0 (the "License");
2637
- * you may not use this file except in compliance with the License.
2638
- * You may obtain a copy of the License at
2639
- *
2640
- * http://www.apache.org/licenses/LICENSE-2.0
2641
- *
2642
- * Unless required by applicable law or agreed to in writing, software
2643
- * distributed under the License is distributed on an "AS IS" BASIS,
2644
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2645
- * See the License for the specific language governing permissions and
2646
- * limitations under the License.
2647
- */
2648
- function si() {
2649
- const n = f();
2650
- return Te(n) || ne(n);
2651
- }
2652
- const oi = 1e3, ai = 10;
2653
- class St extends bt {
2654
- constructor() {
2655
- super(
2656
- () => window.localStorage,
2657
- "LOCAL"
2658
- /* PersistenceType.LOCAL */
2659
- ), this.boundEventHandler = (e, t) => this.onStorageEvent(e, t), this.listeners = {}, this.localCache = {}, this.pollTimer = null, this.safariLocalStorageNotSynced = si() && Fn(), this.fallbackToPolling = _t(), this._shouldAllowMigration = !0;
2660
- }
2661
- forAllChangedKeys(e) {
2662
- for (const t of Object.keys(this.listeners)) {
2663
- const i = this.storage.getItem(t), r = this.localCache[t];
2664
- i !== r && e(t, r, i);
2665
- }
2666
- }
2667
- onStorageEvent(e, t = !1) {
2668
- if (!e.key) {
2669
- this.forAllChangedKeys((o, c, a) => {
2670
- this.notifyListeners(o, a);
2671
- });
2672
- return;
2673
- }
2674
- const i = e.key;
2675
- if (t ? this.detachListener() : this.stopPolling(), this.safariLocalStorageNotSynced) {
2676
- const o = this.storage.getItem(i);
2677
- if (e.newValue !== o)
2678
- e.newValue !== null ? this.storage.setItem(i, e.newValue) : this.storage.removeItem(i);
2679
- else if (this.localCache[i] === e.newValue && !t)
2680
- return;
2681
- }
2682
- const r = () => {
2683
- const o = this.storage.getItem(i);
2684
- !t && this.localCache[i] === o || this.notifyListeners(i, o);
2685
- }, s = this.storage.getItem(i);
2686
- Dn() && s !== e.newValue && e.newValue !== e.oldValue ? setTimeout(r, ai) : r();
2687
- }
2688
- notifyListeners(e, t) {
2689
- this.localCache[e] = t;
2690
- const i = this.listeners[e];
2691
- if (i)
2692
- for (const r of Array.from(i))
2693
- r(t && JSON.parse(t));
2694
- }
2695
- startPolling() {
2696
- this.stopPolling(), this.pollTimer = setInterval(() => {
2697
- this.forAllChangedKeys((e, t, i) => {
2698
- this.onStorageEvent(
2699
- new StorageEvent("storage", {
2700
- key: e,
2701
- oldValue: t,
2702
- newValue: i
2703
- }),
2704
- /* poll */
2705
- !0
2706
- );
2707
- });
2708
- }, oi);
2709
- }
2710
- stopPolling() {
2711
- this.pollTimer && (clearInterval(this.pollTimer), this.pollTimer = null);
2712
- }
2713
- attachListener() {
2714
- window.addEventListener("storage", this.boundEventHandler);
2715
- }
2716
- detachListener() {
2717
- window.removeEventListener("storage", this.boundEventHandler);
2718
- }
2719
- _addListener(e, t) {
2720
- Object.keys(this.listeners).length === 0 && (this.fallbackToPolling ? this.startPolling() : this.attachListener()), this.listeners[e] || (this.listeners[e] = /* @__PURE__ */ new Set(), this.localCache[e] = this.storage.getItem(e)), this.listeners[e].add(t);
2721
- }
2722
- _removeListener(e, t) {
2723
- this.listeners[e] && (this.listeners[e].delete(t), this.listeners[e].size === 0 && delete this.listeners[e]), Object.keys(this.listeners).length === 0 && (this.detachListener(), this.stopPolling());
2724
- }
2725
- // Update local cache on base operations:
2726
- async _set(e, t) {
2727
- await super._set(e, t), this.localCache[e] = JSON.stringify(t);
2728
- }
2729
- async _get(e) {
2730
- const t = await super._get(e);
2731
- return this.localCache[e] = JSON.stringify(t), t;
2732
- }
2733
- async _remove(e) {
2734
- await super._remove(e), delete this.localCache[e];
2735
- }
2736
- }
2737
- St.type = "LOCAL";
2738
- const ci = St;
2739
- /**
2740
- * @license
2741
- * Copyright 2020 Google LLC
2742
- *
2743
- * Licensed under the Apache License, Version 2.0 (the "License");
2744
- * you may not use this file except in compliance with the License.
2745
- * You may obtain a copy of the License at
2746
- *
2747
- * http://www.apache.org/licenses/LICENSE-2.0
2748
- *
2749
- * Unless required by applicable law or agreed to in writing, software
2750
- * distributed under the License is distributed on an "AS IS" BASIS,
2751
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2752
- * See the License for the specific language governing permissions and
2753
- * limitations under the License.
2754
- */
2755
- class At extends bt {
2756
- constructor() {
2757
- super(
2758
- () => window.sessionStorage,
2759
- "SESSION"
2760
- /* PersistenceType.SESSION */
2761
- );
2762
- }
2763
- _addListener(e, t) {
2764
- }
2765
- _removeListener(e, t) {
2766
- }
2767
- }
2768
- At.type = "SESSION";
2769
- const Ct = At;
2770
- /**
2771
- * @license
2772
- * Copyright 2019 Google LLC
2773
- *
2774
- * Licensed under the Apache License, Version 2.0 (the "License");
2775
- * you may not use this file except in compliance with the License.
2776
- * You may obtain a copy of the License at
2777
- *
2778
- * http://www.apache.org/licenses/LICENSE-2.0
2779
- *
2780
- * Unless required by applicable law or agreed to in writing, software
2781
- * distributed under the License is distributed on an "AS IS" BASIS,
2782
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2783
- * See the License for the specific language governing permissions and
2784
- * limitations under the License.
2785
- */
2786
- function li(n) {
2787
- return Promise.all(n.map(async (e) => {
2788
- try {
2789
- return {
2790
- fulfilled: !0,
2791
- value: await e
2792
- };
2793
- } catch (t) {
2794
- return {
2795
- fulfilled: !1,
2796
- reason: t
2797
- };
2798
- }
2799
- }));
2800
- }
2801
- /**
2802
- * @license
2803
- * Copyright 2019 Google LLC
2804
- *
2805
- * Licensed under the Apache License, Version 2.0 (the "License");
2806
- * you may not use this file except in compliance with the License.
2807
- * You may obtain a copy of the License at
2808
- *
2809
- * http://www.apache.org/licenses/LICENSE-2.0
2810
- *
2811
- * Unless required by applicable law or agreed to in writing, software
2812
- * distributed under the License is distributed on an "AS IS" BASIS,
2813
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2814
- * See the License for the specific language governing permissions and
2815
- * limitations under the License.
2816
- */
2817
- class ie {
2818
- constructor(e) {
2819
- this.eventTarget = e, this.handlersMap = {}, this.boundEventHandler = this.handleEvent.bind(this);
2820
- }
2821
- /**
2822
- * Obtain an instance of a Receiver for a given event target, if none exists it will be created.
2823
- *
2824
- * @param eventTarget - An event target (such as window or self) through which the underlying
2825
- * messages will be received.
2826
- */
2827
- static _getInstance(e) {
2828
- const t = this.receivers.find((r) => r.isListeningto(e));
2829
- if (t)
2830
- return t;
2831
- const i = new ie(e);
2832
- return this.receivers.push(i), i;
2833
- }
2834
- isListeningto(e) {
2835
- return this.eventTarget === e;
2836
- }
2837
- /**
2838
- * Fans out a MessageEvent to the appropriate listeners.
2839
- *
2840
- * @remarks
2841
- * Sends an {@link Status.ACK} upon receipt and a {@link Status.DONE} once all handlers have
2842
- * finished processing.
2843
- *
2844
- * @param event - The MessageEvent.
2845
- *
2846
- */
2847
- async handleEvent(e) {
2848
- const t = e, { eventId: i, eventType: r, data: s } = t.data, o = this.handlersMap[r];
2849
- if (!(o != null && o.size))
2850
- return;
2851
- t.ports[0].postMessage({
2852
- status: "ack",
2853
- eventId: i,
2854
- eventType: r
2855
- });
2856
- const c = Array.from(o).map(async (l) => l(t.origin, s)), a = await li(c);
2857
- t.ports[0].postMessage({
2858
- status: "done",
2859
- eventId: i,
2860
- eventType: r,
2861
- response: a
2862
- });
2863
- }
2864
- /**
2865
- * Subscribe an event handler for a particular event.
2866
- *
2867
- * @param eventType - Event name to subscribe to.
2868
- * @param eventHandler - The event handler which should receive the events.
2869
- *
2870
- */
2871
- _subscribe(e, t) {
2872
- Object.keys(this.handlersMap).length === 0 && this.eventTarget.addEventListener("message", this.boundEventHandler), this.handlersMap[e] || (this.handlersMap[e] = /* @__PURE__ */ new Set()), this.handlersMap[e].add(t);
2873
- }
2874
- /**
2875
- * Unsubscribe an event handler from a particular event.
2876
- *
2877
- * @param eventType - Event name to unsubscribe from.
2878
- * @param eventHandler - Optinoal event handler, if none provided, unsubscribe all handlers on this event.
2879
- *
2880
- */
2881
- _unsubscribe(e, t) {
2882
- this.handlersMap[e] && t && this.handlersMap[e].delete(t), (!t || this.handlersMap[e].size === 0) && delete this.handlersMap[e], Object.keys(this.handlersMap).length === 0 && this.eventTarget.removeEventListener("message", this.boundEventHandler);
2883
- }
2884
- }
2885
- ie.receivers = [];
2886
- /**
2887
- * @license
2888
- * Copyright 2020 Google LLC
2889
- *
2890
- * Licensed under the Apache License, Version 2.0 (the "License");
2891
- * you may not use this file except in compliance with the License.
2892
- * You may obtain a copy of the License at
2893
- *
2894
- * http://www.apache.org/licenses/LICENSE-2.0
2895
- *
2896
- * Unless required by applicable law or agreed to in writing, software
2897
- * distributed under the License is distributed on an "AS IS" BASIS,
2898
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2899
- * See the License for the specific language governing permissions and
2900
- * limitations under the License.
2901
- */
2902
- function we(n = "", e = 10) {
2903
- let t = "";
2904
- for (let i = 0; i < e; i++)
2905
- t += Math.floor(Math.random() * 10);
2906
- return n + t;
2907
- }
2908
- /**
2909
- * @license
2910
- * Copyright 2019 Google LLC
2911
- *
2912
- * Licensed under the Apache License, Version 2.0 (the "License");
2913
- * you may not use this file except in compliance with the License.
2914
- * You may obtain a copy of the License at
2915
- *
2916
- * http://www.apache.org/licenses/LICENSE-2.0
2917
- *
2918
- * Unless required by applicable law or agreed to in writing, software
2919
- * distributed under the License is distributed on an "AS IS" BASIS,
2920
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2921
- * See the License for the specific language governing permissions and
2922
- * limitations under the License.
2923
- */
2924
- class ui {
2925
- constructor(e) {
2926
- this.target = e, this.handlers = /* @__PURE__ */ new Set();
2927
- }
2928
- /**
2929
- * Unsubscribe the handler and remove it from our tracking Set.
2930
- *
2931
- * @param handler - The handler to unsubscribe.
2932
- */
2933
- removeMessageHandler(e) {
2934
- e.messageChannel && (e.messageChannel.port1.removeEventListener("message", e.onMessage), e.messageChannel.port1.close()), this.handlers.delete(e);
2935
- }
2936
- /**
2937
- * Send a message to the Receiver located at {@link target}.
2938
- *
2939
- * @remarks
2940
- * We'll first wait a bit for an ACK , if we get one we will wait significantly longer until the
2941
- * receiver has had a chance to fully process the event.
2942
- *
2943
- * @param eventType - Type of event to send.
2944
- * @param data - The payload of the event.
2945
- * @param timeout - Timeout for waiting on an ACK from the receiver.
2946
- *
2947
- * @returns An array of settled promises from all the handlers that were listening on the receiver.
2948
- */
2949
- async _send(e, t, i = 50) {
2950
- const r = typeof MessageChannel < "u" ? new MessageChannel() : null;
2951
- if (!r)
2952
- throw new Error(
2953
- "connection_unavailable"
2954
- /* _MessageError.CONNECTION_UNAVAILABLE */
2955
- );
2956
- let s, o;
2957
- return new Promise((c, a) => {
2958
- const l = we("", 20);
2959
- r.port1.start();
2960
- const d = setTimeout(() => {
2961
- a(new Error(
2962
- "unsupported_event"
2963
- /* _MessageError.UNSUPPORTED_EVENT */
2964
- ));
2965
- }, i);
2966
- o = {
2967
- messageChannel: r,
2968
- onMessage(h) {
2969
- const p = h;
2970
- if (p.data.eventId === l)
2971
- switch (p.data.status) {
2972
- case "ack":
2973
- clearTimeout(d), s = setTimeout(
2974
- () => {
2975
- a(new Error(
2976
- "timeout"
2977
- /* _MessageError.TIMEOUT */
2978
- ));
2979
- },
2980
- 3e3
2981
- /* _TimeoutDuration.COMPLETION */
2982
- );
2983
- break;
2984
- case "done":
2985
- clearTimeout(s), c(p.data.response);
2986
- break;
2987
- default:
2988
- clearTimeout(d), clearTimeout(s), a(new Error(
2989
- "invalid_response"
2990
- /* _MessageError.INVALID_RESPONSE */
2991
- ));
2992
- break;
2993
- }
2994
- }
2995
- }, this.handlers.add(o), r.port1.addEventListener("message", o.onMessage), this.target.postMessage({
2996
- eventType: e,
2997
- eventId: l,
2998
- data: t
2999
- }, [r.port2]);
3000
- }).finally(() => {
3001
- o && this.removeMessageHandler(o);
3002
- });
3003
- }
3004
- }
3005
- /**
3006
- * @license
3007
- * Copyright 2020 Google LLC
3008
- *
3009
- * Licensed under the Apache License, Version 2.0 (the "License");
3010
- * you may not use this file except in compliance with the License.
3011
- * You may obtain a copy of the License at
3012
- *
3013
- * http://www.apache.org/licenses/LICENSE-2.0
3014
- *
3015
- * Unless required by applicable law or agreed to in writing, software
3016
- * distributed under the License is distributed on an "AS IS" BASIS,
3017
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3018
- * See the License for the specific language governing permissions and
3019
- * limitations under the License.
3020
- */
3021
- function m() {
3022
- return window;
3023
- }
3024
- function di(n) {
3025
- m().location.href = n;
3026
- }
3027
- /**
3028
- * @license
3029
- * Copyright 2020 Google LLC.
3030
- *
3031
- * Licensed under the Apache License, Version 2.0 (the "License");
3032
- * you may not use this file except in compliance with the License.
3033
- * You may obtain a copy of the License at
3034
- *
3035
- * http://www.apache.org/licenses/LICENSE-2.0
3036
- *
3037
- * Unless required by applicable law or agreed to in writing, software
3038
- * distributed under the License is distributed on an "AS IS" BASIS,
3039
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3040
- * See the License for the specific language governing permissions and
3041
- * limitations under the License.
3042
- */
3043
- function Pt() {
3044
- return typeof m().WorkerGlobalScope < "u" && typeof m().importScripts == "function";
3045
- }
3046
- async function hi() {
3047
- if (!(navigator != null && navigator.serviceWorker))
3048
- return null;
3049
- try {
3050
- return (await navigator.serviceWorker.ready).active;
3051
- } catch {
3052
- return null;
3053
- }
3054
- }
3055
- function fi() {
3056
- var n;
3057
- return ((n = navigator == null ? void 0 : navigator.serviceWorker) === null || n === void 0 ? void 0 : n.controller) || null;
3058
- }
3059
- function pi() {
3060
- return Pt() ? self : null;
3061
- }
3062
- /**
3063
- * @license
3064
- * Copyright 2019 Google LLC
3065
- *
3066
- * Licensed under the Apache License, Version 2.0 (the "License");
3067
- * you may not use this file except in compliance with the License.
3068
- * You may obtain a copy of the License at
3069
- *
3070
- * http://www.apache.org/licenses/LICENSE-2.0
3071
- *
3072
- * Unless required by applicable law or agreed to in writing, software
3073
- * distributed under the License is distributed on an "AS IS" BASIS,
3074
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3075
- * See the License for the specific language governing permissions and
3076
- * limitations under the License.
3077
- */
3078
- const Nt = "firebaseLocalStorageDb", gi = 1, te = "firebaseLocalStorage", Ot = "fbase_key";
3079
- class j {
3080
- constructor(e) {
3081
- this.request = e;
3082
- }
3083
- toPromise() {
3084
- return new Promise((e, t) => {
3085
- this.request.addEventListener("success", () => {
3086
- e(this.request.result);
3087
- }), this.request.addEventListener("error", () => {
3088
- t(this.request.error);
3089
- });
3090
- });
3091
- }
3092
- }
3093
- function re(n, e) {
3094
- return n.transaction([te], e ? "readwrite" : "readonly").objectStore(te);
3095
- }
3096
- function mi() {
3097
- const n = indexedDB.deleteDatabase(Nt);
3098
- return new j(n).toPromise();
3099
- }
3100
- function fe() {
3101
- const n = indexedDB.open(Nt, gi);
3102
- return new Promise((e, t) => {
3103
- n.addEventListener("error", () => {
3104
- t(n.error);
3105
- }), n.addEventListener("upgradeneeded", () => {
3106
- const i = n.result;
3107
- try {
3108
- i.createObjectStore(te, { keyPath: Ot });
3109
- } catch (r) {
3110
- t(r);
3111
- }
3112
- }), n.addEventListener("success", async () => {
3113
- const i = n.result;
3114
- i.objectStoreNames.contains(te) ? e(i) : (i.close(), await mi(), e(await fe()));
3115
- });
3116
- });
3117
- }
3118
- async function He(n, e, t) {
3119
- const i = re(n, !0).put({
3120
- [Ot]: e,
3121
- value: t
3122
- });
3123
- return new j(i).toPromise();
3124
- }
3125
- async function _i(n, e) {
3126
- const t = re(n, !1).get(e), i = await new j(t).toPromise();
3127
- return i === void 0 ? null : i.value;
3128
- }
3129
- function $e(n, e) {
3130
- const t = re(n, !0).delete(e);
3131
- return new j(t).toPromise();
3132
- }
3133
- const vi = 800, Ii = 3;
3134
- class Lt {
3135
- constructor() {
3136
- this.type = "LOCAL", this._shouldAllowMigration = !0, this.listeners = {}, this.localCache = {}, this.pollTimer = null, this.pendingWrites = 0, this.receiver = null, this.sender = null, this.serviceWorkerReceiverAvailable = !1, this.activeServiceWorker = null, this._workerInitializationPromise = this.initializeServiceWorkerMessaging().then(() => {
3137
- }, () => {
3138
- });
3139
- }
3140
- async _openDb() {
3141
- return this.db ? this.db : (this.db = await fe(), this.db);
3142
- }
3143
- async _withRetries(e) {
3144
- let t = 0;
3145
- for (; ; )
3146
- try {
3147
- const i = await this._openDb();
3148
- return await e(i);
3149
- } catch (i) {
3150
- if (t++ > Ii)
3151
- throw i;
3152
- this.db && (this.db.close(), this.db = void 0);
3153
- }
3154
- }
3155
- /**
3156
- * IndexedDB events do not propagate from the main window to the worker context. We rely on a
3157
- * postMessage interface to send these events to the worker ourselves.
3158
- */
3159
- async initializeServiceWorkerMessaging() {
3160
- return Pt() ? this.initializeReceiver() : this.initializeSender();
3161
- }
3162
- /**
3163
- * As the worker we should listen to events from the main window.
3164
- */
3165
- async initializeReceiver() {
3166
- this.receiver = ie._getInstance(pi()), this.receiver._subscribe("keyChanged", async (e, t) => ({
3167
- keyProcessed: (await this._poll()).includes(t.key)
3168
- })), this.receiver._subscribe("ping", async (e, t) => [
3169
- "keyChanged"
3170
- /* _EventType.KEY_CHANGED */
3171
- ]);
3172
- }
3173
- /**
3174
- * As the main window, we should let the worker know when keys change (set and remove).
3175
- *
3176
- * @remarks
3177
- * {@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/ready | ServiceWorkerContainer.ready}
3178
- * may not resolve.
3179
- */
3180
- async initializeSender() {
3181
- var e, t;
3182
- if (this.activeServiceWorker = await hi(), !this.activeServiceWorker)
3183
- return;
3184
- this.sender = new ui(this.activeServiceWorker);
3185
- const i = await this.sender._send(
3186
- "ping",
3187
- {},
3188
- 800
3189
- /* _TimeoutDuration.LONG_ACK */
3190
- );
3191
- i && !((e = i[0]) === null || e === void 0) && e.fulfilled && !((t = i[0]) === null || t === void 0) && t.value.includes(
3192
- "keyChanged"
3193
- /* _EventType.KEY_CHANGED */
3194
- ) && (this.serviceWorkerReceiverAvailable = !0);
3195
- }
3196
- /**
3197
- * Let the worker know about a changed key, the exact key doesn't technically matter since the
3198
- * worker will just trigger a full sync anyway.
3199
- *
3200
- * @remarks
3201
- * For now, we only support one service worker per page.
3202
- *
3203
- * @param key - Storage key which changed.
3204
- */
3205
- async notifyServiceWorker(e) {
3206
- if (!(!this.sender || !this.activeServiceWorker || fi() !== this.activeServiceWorker))
3207
- try {
3208
- await this.sender._send(
3209
- "keyChanged",
3210
- { key: e },
3211
- // Use long timeout if receiver has previously responded to a ping from us.
3212
- this.serviceWorkerReceiverAvailable ? 800 : 50
3213
- /* _TimeoutDuration.ACK */
3214
- );
3215
- } catch {
3216
- }
3217
- }
3218
- async _isAvailable() {
3219
- try {
3220
- if (!indexedDB)
3221
- return !1;
3222
- const e = await fe();
3223
- return await He(e, ee, "1"), await $e(e, ee), !0;
3224
- } catch {
3225
- }
3226
- return !1;
3227
- }
3228
- async _withPendingWrite(e) {
3229
- this.pendingWrites++;
3230
- try {
3231
- await e();
3232
- } finally {
3233
- this.pendingWrites--;
3234
- }
3235
- }
3236
- async _set(e, t) {
3237
- return this._withPendingWrite(async () => (await this._withRetries((i) => He(i, e, t)), this.localCache[e] = t, this.notifyServiceWorker(e)));
3238
- }
3239
- async _get(e) {
3240
- const t = await this._withRetries((i) => _i(i, e));
3241
- return this.localCache[e] = t, t;
3242
- }
3243
- async _remove(e) {
3244
- return this._withPendingWrite(async () => (await this._withRetries((t) => $e(t, e)), delete this.localCache[e], this.notifyServiceWorker(e)));
3245
- }
3246
- async _poll() {
3247
- const e = await this._withRetries((r) => {
3248
- const s = re(r, !1).getAll();
3249
- return new j(s).toPromise();
3250
- });
3251
- if (!e)
3252
- return [];
3253
- if (this.pendingWrites !== 0)
3254
- return [];
3255
- const t = [], i = /* @__PURE__ */ new Set();
3256
- for (const { fbase_key: r, value: s } of e)
3257
- i.add(r), JSON.stringify(this.localCache[r]) !== JSON.stringify(s) && (this.notifyListeners(r, s), t.push(r));
3258
- for (const r of Object.keys(this.localCache))
3259
- this.localCache[r] && !i.has(r) && (this.notifyListeners(r, null), t.push(r));
3260
- return t;
3261
- }
3262
- notifyListeners(e, t) {
3263
- this.localCache[e] = t;
3264
- const i = this.listeners[e];
3265
- if (i)
3266
- for (const r of Array.from(i))
3267
- r(t);
3268
- }
3269
- startPolling() {
3270
- this.stopPolling(), this.pollTimer = setInterval(async () => this._poll(), vi);
3271
- }
3272
- stopPolling() {
3273
- this.pollTimer && (clearInterval(this.pollTimer), this.pollTimer = null);
3274
- }
3275
- _addListener(e, t) {
3276
- Object.keys(this.listeners).length === 0 && this.startPolling(), this.listeners[e] || (this.listeners[e] = /* @__PURE__ */ new Set(), this._get(e)), this.listeners[e].add(t);
3277
- }
3278
- _removeListener(e, t) {
3279
- this.listeners[e] && (this.listeners[e].delete(t), this.listeners[e].size === 0 && delete this.listeners[e]), Object.keys(this.listeners).length === 0 && this.stopPolling();
3280
- }
3281
- }
3282
- Lt.type = "LOCAL";
3283
- const yi = Lt;
3284
- new V(3e4, 6e4);
3285
- /**
3286
- * @license
3287
- * Copyright 2021 Google LLC
3288
- *
3289
- * Licensed under the Apache License, Version 2.0 (the "License");
3290
- * you may not use this file except in compliance with the License.
3291
- * You may obtain a copy of the License at
3292
- *
3293
- * http://www.apache.org/licenses/LICENSE-2.0
3294
- *
3295
- * Unless required by applicable law or agreed to in writing, software
3296
- * distributed under the License is distributed on an "AS IS" BASIS,
3297
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3298
- * See the License for the specific language governing permissions and
3299
- * limitations under the License.
3300
- */
3301
- function Ti(n, e) {
3302
- return e ? v(e) : (u(
3303
- n._popupRedirectResolver,
3304
- n,
3305
- "argument-error"
3306
- /* AuthErrorCode.ARGUMENT_ERROR */
3307
- ), n._popupRedirectResolver);
3308
- }
3309
- /**
3310
- * @license
3311
- * Copyright 2019 Google LLC
3312
- *
3313
- * Licensed under the Apache License, Version 2.0 (the "License");
3314
- * you may not use this file except in compliance with the License.
3315
- * You may obtain a copy of the License at
3316
- *
3317
- * http://www.apache.org/licenses/LICENSE-2.0
3318
- *
3319
- * Unless required by applicable law or agreed to in writing, software
3320
- * distributed under the License is distributed on an "AS IS" BASIS,
3321
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3322
- * See the License for the specific language governing permissions and
3323
- * limitations under the License.
3324
- */
3325
- class Ee extends Et {
3326
- constructor(e) {
3327
- super(
3328
- "custom",
3329
- "custom"
3330
- /* ProviderId.CUSTOM */
3331
- ), this.params = e;
3332
- }
3333
- _getIdTokenResponse(e) {
3334
- return N(e, this._buildIdpRequest());
3335
- }
3336
- _linkToIdToken(e, t) {
3337
- return N(e, this._buildIdpRequest(t));
3338
- }
3339
- _getReauthenticationResolver(e) {
3340
- return N(e, this._buildIdpRequest());
3341
- }
3342
- _buildIdpRequest(e) {
3343
- const t = {
3344
- requestUri: this.params.requestUri,
3345
- sessionId: this.params.sessionId,
3346
- postBody: this.params.postBody,
3347
- tenantId: this.params.tenantId,
3348
- pendingToken: this.params.pendingToken,
3349
- returnSecureToken: !0,
3350
- returnIdpCredential: !0
3351
- };
3352
- return e && (t.idToken = e), t;
3353
- }
3354
- }
3355
- function wi(n) {
3356
- return ei(n.auth, new Ee(n), n.bypassAuthState);
3357
- }
3358
- function Ei(n) {
3359
- const { auth: e, user: t } = n;
3360
- return u(
3361
- t,
3362
- e,
3363
- "internal-error"
3364
- /* AuthErrorCode.INTERNAL_ERROR */
3365
- ), Zn(t, new Ee(n), n.bypassAuthState);
3366
- }
3367
- async function ki(n) {
3368
- const { auth: e, user: t } = n;
3369
- return u(
3370
- t,
3371
- e,
3372
- "internal-error"
3373
- /* AuthErrorCode.INTERNAL_ERROR */
3374
- ), Qn(t, new Ee(n), n.bypassAuthState);
3375
- }
3376
- /**
3377
- * @license
3378
- * Copyright 2020 Google LLC
3379
- *
3380
- * Licensed under the Apache License, Version 2.0 (the "License");
3381
- * you may not use this file except in compliance with the License.
3382
- * You may obtain a copy of the License at
3383
- *
3384
- * http://www.apache.org/licenses/LICENSE-2.0
3385
- *
3386
- * Unless required by applicable law or agreed to in writing, software
3387
- * distributed under the License is distributed on an "AS IS" BASIS,
3388
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3389
- * See the License for the specific language governing permissions and
3390
- * limitations under the License.
3391
- */
3392
- class Mt {
3393
- constructor(e, t, i, r, s = !1) {
3394
- this.auth = e, this.resolver = i, this.user = r, this.bypassAuthState = s, this.pendingPromise = null, this.eventManager = null, this.filter = Array.isArray(t) ? t : [t];
3395
- }
3396
- execute() {
3397
- return new Promise(async (e, t) => {
3398
- this.pendingPromise = { resolve: e, reject: t };
3399
- try {
3400
- this.eventManager = await this.resolver._initialize(this.auth), await this.onExecution(), this.eventManager.registerConsumer(this);
3401
- } catch (i) {
3402
- this.reject(i);
3403
- }
3404
- });
3405
- }
3406
- async onAuthEvent(e) {
3407
- const { urlResponse: t, sessionId: i, postBody: r, tenantId: s, error: o, type: c } = e;
3408
- if (o) {
3409
- this.reject(o);
3410
- return;
3411
- }
3412
- const a = {
3413
- auth: this.auth,
3414
- requestUri: t,
3415
- sessionId: i,
3416
- tenantId: s || void 0,
3417
- postBody: r || void 0,
3418
- user: this.user,
3419
- bypassAuthState: this.bypassAuthState
3420
- };
3421
- try {
3422
- this.resolve(await this.getIdpTask(c)(a));
3423
- } catch (l) {
3424
- this.reject(l);
3425
- }
3426
- }
3427
- onError(e) {
3428
- this.reject(e);
3429
- }
3430
- getIdpTask(e) {
3431
- switch (e) {
3432
- case "signInViaPopup":
3433
- case "signInViaRedirect":
3434
- return wi;
3435
- case "linkViaPopup":
3436
- case "linkViaRedirect":
3437
- return ki;
3438
- case "reauthViaPopup":
3439
- case "reauthViaRedirect":
3440
- return Ei;
3441
- default:
3442
- I(
3443
- this.auth,
3444
- "internal-error"
3445
- /* AuthErrorCode.INTERNAL_ERROR */
3446
- );
3447
- }
3448
- }
3449
- resolve(e) {
3450
- y(this.pendingPromise, "Pending promise was never set"), this.pendingPromise.resolve(e), this.unregisterAndCleanUp();
3451
- }
3452
- reject(e) {
3453
- y(this.pendingPromise, "Pending promise was never set"), this.pendingPromise.reject(e), this.unregisterAndCleanUp();
3454
- }
3455
- unregisterAndCleanUp() {
3456
- this.eventManager && this.eventManager.unregisterConsumer(this), this.pendingPromise = null, this.cleanUp();
3457
- }
3458
- }
3459
- /**
3460
- * @license
3461
- * Copyright 2020 Google LLC
3462
- *
3463
- * Licensed under the Apache License, Version 2.0 (the "License");
3464
- * you may not use this file except in compliance with the License.
3465
- * You may obtain a copy of the License at
3466
- *
3467
- * http://www.apache.org/licenses/LICENSE-2.0
3468
- *
3469
- * Unless required by applicable law or agreed to in writing, software
3470
- * distributed under the License is distributed on an "AS IS" BASIS,
3471
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3472
- * See the License for the specific language governing permissions and
3473
- * limitations under the License.
3474
- */
3475
- const Ri = new V(2e3, 1e4);
3476
- class C extends Mt {
3477
- constructor(e, t, i, r, s) {
3478
- super(e, t, r, s), this.provider = i, this.authWindow = null, this.pollId = null, C.currentPopupAction && C.currentPopupAction.cancel(), C.currentPopupAction = this;
3479
- }
3480
- async executeNotNull() {
3481
- const e = await this.execute();
3482
- return u(
3483
- e,
3484
- this.auth,
3485
- "internal-error"
3486
- /* AuthErrorCode.INTERNAL_ERROR */
3487
- ), e;
3488
- }
3489
- async onExecution() {
3490
- y(this.filter.length === 1, "Popup operations only handle one event");
3491
- const e = we();
3492
- this.authWindow = await this.resolver._openPopup(
3493
- this.auth,
3494
- this.provider,
3495
- this.filter[0],
3496
- // There's always one, see constructor
3497
- e
3498
- ), this.authWindow.associatedEvent = e, this.resolver._originValidation(this.auth).catch((t) => {
3499
- this.reject(t);
3500
- }), this.resolver._isIframeWebStorageSupported(this.auth, (t) => {
3501
- t || this.reject(g(
3502
- this.auth,
3503
- "web-storage-unsupported"
3504
- /* AuthErrorCode.WEB_STORAGE_UNSUPPORTED */
3505
- ));
3506
- }), this.pollUserCancellation();
3507
- }
3508
- get eventId() {
3509
- var e;
3510
- return ((e = this.authWindow) === null || e === void 0 ? void 0 : e.associatedEvent) || null;
3511
- }
3512
- cancel() {
3513
- this.reject(g(
3514
- this.auth,
3515
- "cancelled-popup-request"
3516
- /* AuthErrorCode.EXPIRED_POPUP_REQUEST */
3517
- ));
3518
- }
3519
- cleanUp() {
3520
- this.authWindow && this.authWindow.close(), this.pollId && window.clearTimeout(this.pollId), this.authWindow = null, this.pollId = null, C.currentPopupAction = null;
3521
- }
3522
- pollUserCancellation() {
3523
- const e = () => {
3524
- var t, i;
3525
- if (!((i = (t = this.authWindow) === null || t === void 0 ? void 0 : t.window) === null || i === void 0) && i.closed) {
3526
- this.pollId = window.setTimeout(
3527
- () => {
3528
- this.pollId = null, this.reject(g(
3529
- this.auth,
3530
- "popup-closed-by-user"
3531
- /* AuthErrorCode.POPUP_CLOSED_BY_USER */
3532
- ));
3533
- },
3534
- 8e3
3535
- /* _Timeout.AUTH_EVENT */
3536
- );
3537
- return;
3538
- }
3539
- this.pollId = window.setTimeout(e, Ri.get());
3540
- };
3541
- e();
3542
- }
3543
- }
3544
- C.currentPopupAction = null;
3545
- /**
3546
- * @license
3547
- * Copyright 2020 Google LLC
3548
- *
3549
- * Licensed under the Apache License, Version 2.0 (the "License");
3550
- * you may not use this file except in compliance with the License.
3551
- * You may obtain a copy of the License at
3552
- *
3553
- * http://www.apache.org/licenses/LICENSE-2.0
3554
- *
3555
- * Unless required by applicable law or agreed to in writing, software
3556
- * distributed under the License is distributed on an "AS IS" BASIS,
3557
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3558
- * See the License for the specific language governing permissions and
3559
- * limitations under the License.
3560
- */
3561
- const bi = "pendingRedirect", J = /* @__PURE__ */ new Map();
3562
- class Si extends Mt {
3563
- constructor(e, t, i = !1) {
3564
- super(e, [
3565
- "signInViaRedirect",
3566
- "linkViaRedirect",
3567
- "reauthViaRedirect",
3568
- "unknown"
3569
- /* AuthEventType.UNKNOWN */
3570
- ], t, void 0, i), this.eventId = null;
3571
- }
3572
- /**
3573
- * Override the execute function; if we already have a redirect result, then
3574
- * just return it.
3575
- */
3576
- async execute() {
3577
- let e = J.get(this.auth._key());
3578
- if (!e) {
3579
- try {
3580
- const i = await Ai(this.resolver, this.auth) ? await super.execute() : null;
3581
- e = () => Promise.resolve(i);
3582
- } catch (t) {
3583
- e = () => Promise.reject(t);
3584
- }
3585
- J.set(this.auth._key(), e);
3586
- }
3587
- return this.bypassAuthState || J.set(this.auth._key(), () => Promise.resolve(null)), e();
3588
- }
3589
- async onAuthEvent(e) {
3590
- if (e.type === "signInViaRedirect")
3591
- return super.onAuthEvent(e);
3592
- if (e.type === "unknown") {
3593
- this.resolve(null);
3594
- return;
3595
- }
3596
- if (e.eventId) {
3597
- const t = await this.auth._redirectUserForId(e.eventId);
3598
- if (t)
3599
- return this.user = t, super.onAuthEvent(e);
3600
- this.resolve(null);
3601
- }
3602
- }
3603
- async onExecution() {
3604
- }
3605
- cleanUp() {
3606
- }
3607
- }
3608
- async function Ai(n, e) {
3609
- const t = Ni(e), i = Pi(n);
3610
- if (!await i._isAvailable())
3611
- return !1;
3612
- const r = await i._get(t) === "true";
3613
- return await i._remove(t), r;
3614
- }
3615
- function Ci(n, e) {
3616
- J.set(n._key(), e);
3617
- }
3618
- function Pi(n) {
3619
- return v(n._redirectPersistence);
3620
- }
3621
- function Ni(n) {
3622
- return z(bi, n.config.apiKey, n.name);
3623
- }
3624
- async function Oi(n, e, t = !1) {
3625
- const i = H(n), r = Ti(i, e), o = await new Si(i, r, t).execute();
3626
- return o && !t && (delete o.user._redirectEventId, await i._persistUserIfCurrent(o.user), await i._setRedirectUser(null, e)), o;
3627
- }
3628
- /**
3629
- * @license
3630
- * Copyright 2020 Google LLC
3631
- *
3632
- * Licensed under the Apache License, Version 2.0 (the "License");
3633
- * you may not use this file except in compliance with the License.
3634
- * You may obtain a copy of the License at
3635
- *
3636
- * http://www.apache.org/licenses/LICENSE-2.0
3637
- *
3638
- * Unless required by applicable law or agreed to in writing, software
3639
- * distributed under the License is distributed on an "AS IS" BASIS,
3640
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3641
- * See the License for the specific language governing permissions and
3642
- * limitations under the License.
3643
- */
3644
- const Li = 10 * 60 * 1e3;
3645
- class Mi {
3646
- constructor(e) {
3647
- this.auth = e, this.cachedEventUids = /* @__PURE__ */ new Set(), this.consumers = /* @__PURE__ */ new Set(), this.queuedRedirectEvent = null, this.hasHandledPotentialRedirect = !1, this.lastProcessedEventTime = Date.now();
3648
- }
3649
- registerConsumer(e) {
3650
- this.consumers.add(e), this.queuedRedirectEvent && this.isEventForConsumer(this.queuedRedirectEvent, e) && (this.sendToConsumer(this.queuedRedirectEvent, e), this.saveEventToCache(this.queuedRedirectEvent), this.queuedRedirectEvent = null);
3651
- }
3652
- unregisterConsumer(e) {
3653
- this.consumers.delete(e);
3654
- }
3655
- onEvent(e) {
3656
- if (this.hasEventBeenHandled(e))
3657
- return !1;
3658
- let t = !1;
3659
- return this.consumers.forEach((i) => {
3660
- this.isEventForConsumer(e, i) && (t = !0, this.sendToConsumer(e, i), this.saveEventToCache(e));
3661
- }), this.hasHandledPotentialRedirect || !Ui(e) || (this.hasHandledPotentialRedirect = !0, t || (this.queuedRedirectEvent = e, t = !0)), t;
3662
- }
3663
- sendToConsumer(e, t) {
3664
- var i;
3665
- if (e.error && !Ut(e)) {
3666
- const r = ((i = e.error.code) === null || i === void 0 ? void 0 : i.split("auth/")[1]) || "internal-error";
3667
- t.onError(g(this.auth, r));
3668
- } else
3669
- t.onAuthEvent(e);
3670
- }
3671
- isEventForConsumer(e, t) {
3672
- const i = t.eventId === null || !!e.eventId && e.eventId === t.eventId;
3673
- return t.filter.includes(e.type) && i;
3674
- }
3675
- hasEventBeenHandled(e) {
3676
- return Date.now() - this.lastProcessedEventTime >= Li && this.cachedEventUids.clear(), this.cachedEventUids.has(je(e));
3677
- }
3678
- saveEventToCache(e) {
3679
- this.cachedEventUids.add(je(e)), this.lastProcessedEventTime = Date.now();
3680
- }
3681
- }
3682
- function je(n) {
3683
- return [n.type, n.eventId, n.sessionId, n.tenantId].filter((e) => e).join("-");
3684
- }
3685
- function Ut({ type: n, error: e }) {
3686
- return n === "unknown" && (e == null ? void 0 : e.code) === "auth/no-auth-event";
3687
- }
3688
- function Ui(n) {
3689
- switch (n.type) {
3690
- case "signInViaRedirect":
3691
- case "linkViaRedirect":
3692
- case "reauthViaRedirect":
3693
- return !0;
3694
- case "unknown":
3695
- return Ut(n);
3696
- default:
3697
- return !1;
3698
- }
3699
- }
3700
- /**
3701
- * @license
3702
- * Copyright 2020 Google LLC
3703
- *
3704
- * Licensed under the Apache License, Version 2.0 (the "License");
3705
- * you may not use this file except in compliance with the License.
3706
- * You may obtain a copy of the License at
3707
- *
3708
- * http://www.apache.org/licenses/LICENSE-2.0
3709
- *
3710
- * Unless required by applicable law or agreed to in writing, software
3711
- * distributed under the License is distributed on an "AS IS" BASIS,
3712
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3713
- * See the License for the specific language governing permissions and
3714
- * limitations under the License.
3715
- */
3716
- async function Di(n, e = {}) {
3717
- return W(n, "GET", "/v1/projects", e);
3718
- }
3719
- /**
3720
- * @license
3721
- * Copyright 2020 Google LLC
3722
- *
3723
- * Licensed under the Apache License, Version 2.0 (the "License");
3724
- * you may not use this file except in compliance with the License.
3725
- * You may obtain a copy of the License at
3726
- *
3727
- * http://www.apache.org/licenses/LICENSE-2.0
3728
- *
3729
- * Unless required by applicable law or agreed to in writing, software
3730
- * distributed under the License is distributed on an "AS IS" BASIS,
3731
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3732
- * See the License for the specific language governing permissions and
3733
- * limitations under the License.
3734
- */
3735
- const Fi = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/, xi = /^https?/;
3736
- async function Vi(n) {
3737
- if (n.config.emulator)
3738
- return;
3739
- const { authorizedDomains: e } = await Di(n);
3740
- for (const t of e)
3741
- try {
3742
- if (Wi(t))
3743
- return;
3744
- } catch {
3745
- }
3746
- I(
3747
- n,
3748
- "unauthorized-domain"
3749
- /* AuthErrorCode.INVALID_ORIGIN */
3750
- );
3751
- }
3752
- function Wi(n) {
3753
- const e = he(), { protocol: t, hostname: i } = new URL(e);
3754
- if (n.startsWith("chrome-extension://")) {
3755
- const o = new URL(n);
3756
- return o.hostname === "" && i === "" ? t === "chrome-extension:" && n.replace("chrome-extension://", "") === e.replace("chrome-extension://", "") : t === "chrome-extension:" && o.hostname === i;
3757
- }
3758
- if (!xi.test(t))
3759
- return !1;
3760
- if (Fi.test(n))
3761
- return i === n;
3762
- const r = n.replace(/\./g, "\\.");
3763
- return new RegExp("^(.+\\." + r + "|" + r + ")$", "i").test(i);
3764
- }
3765
- /**
3766
- * @license
3767
- * Copyright 2020 Google LLC.
3768
- *
3769
- * Licensed under the Apache License, Version 2.0 (the "License");
3770
- * you may not use this file except in compliance with the License.
3771
- * You may obtain a copy of the License at
3772
- *
3773
- * http://www.apache.org/licenses/LICENSE-2.0
3774
- *
3775
- * Unless required by applicable law or agreed to in writing, software
3776
- * distributed under the License is distributed on an "AS IS" BASIS,
3777
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3778
- * See the License for the specific language governing permissions and
3779
- * limitations under the License.
3780
- */
3781
- const Hi = new V(3e4, 6e4);
3782
- function Be() {
3783
- const n = m().___jsl;
3784
- if (n != null && n.H) {
3785
- for (const e of Object.keys(n.H))
3786
- if (n.H[e].r = n.H[e].r || [], n.H[e].L = n.H[e].L || [], n.H[e].r = [...n.H[e].L], n.CP)
3787
- for (let t = 0; t < n.CP.length; t++)
3788
- n.CP[t] = null;
3789
- }
3790
- }
3791
- function $i(n) {
3792
- return new Promise((e, t) => {
3793
- var i, r, s;
3794
- function o() {
3795
- Be(), gapi.load("gapi.iframes", {
3796
- callback: () => {
3797
- e(gapi.iframes.getContext());
3798
- },
3799
- ontimeout: () => {
3800
- Be(), t(g(
3801
- n,
3802
- "network-request-failed"
3803
- /* AuthErrorCode.NETWORK_REQUEST_FAILED */
3804
- ));
3805
- },
3806
- timeout: Hi.get()
3807
- });
3808
- }
3809
- if (!((r = (i = m().gapi) === null || i === void 0 ? void 0 : i.iframes) === null || r === void 0) && r.Iframe)
3810
- e(gapi.iframes.getContext());
3811
- else if (!((s = m().gapi) === null || s === void 0) && s.load)
3812
- o();
3813
- else {
3814
- const c = Vn("iframefcb");
3815
- return m()[c] = () => {
3816
- gapi.load ? o() : t(g(
3817
- n,
3818
- "network-request-failed"
3819
- /* AuthErrorCode.NETWORK_REQUEST_FAILED */
3820
- ));
3821
- }, Tt(`https://apis.google.com/js/api.js?onload=${c}`).catch((a) => t(a));
3822
- }
3823
- }).catch((e) => {
3824
- throw Y = null, e;
3825
- });
3826
- }
3827
- let Y = null;
3828
- function ji(n) {
3829
- return Y = Y || $i(n), Y;
3830
- }
3831
- /**
3832
- * @license
3833
- * Copyright 2020 Google LLC.
3834
- *
3835
- * Licensed under the Apache License, Version 2.0 (the "License");
3836
- * you may not use this file except in compliance with the License.
3837
- * You may obtain a copy of the License at
3838
- *
3839
- * http://www.apache.org/licenses/LICENSE-2.0
3840
- *
3841
- * Unless required by applicable law or agreed to in writing, software
3842
- * distributed under the License is distributed on an "AS IS" BASIS,
3843
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3844
- * See the License for the specific language governing permissions and
3845
- * limitations under the License.
3846
- */
3847
- const Bi = new V(5e3, 15e3), Ki = "__/auth/iframe", qi = "emulator/auth/iframe", Gi = {
3848
- style: {
3849
- position: "absolute",
3850
- top: "-100px",
3851
- width: "1px",
3852
- height: "1px"
3853
- },
3854
- "aria-hidden": "true",
3855
- tabindex: "-1"
3856
- }, zi = /* @__PURE__ */ new Map([
3857
- ["identitytoolkit.googleapis.com", "p"],
3858
- ["staging-identitytoolkit.sandbox.googleapis.com", "s"],
3859
- ["test-identitytoolkit.sandbox.googleapis.com", "t"]
3860
- // test
3861
- ]);
3862
- function Ji(n) {
3863
- const e = n.config;
3864
- u(
3865
- e.authDomain,
3866
- n,
3867
- "auth-domain-config-required"
3868
- /* AuthErrorCode.MISSING_AUTH_DOMAIN */
3869
- );
3870
- const t = e.emulator ? ve(e, qi) : `https://${n.config.authDomain}/${Ki}`, i = {
3871
- apiKey: e.apiKey,
3872
- appName: n.name,
3873
- v: F
3874
- }, r = zi.get(n.config.apiHost);
3875
- r && (i.eid = r);
3876
- const s = n._getFrameworks();
3877
- return s.length && (i.fw = s.join(",")), `${t}?${x(i).slice(1)}`;
3878
- }
3879
- async function Yi(n) {
3880
- const e = await ji(n), t = m().gapi;
3881
- return u(
3882
- t,
3883
- n,
3884
- "internal-error"
3885
- /* AuthErrorCode.INTERNAL_ERROR */
3886
- ), e.open({
3887
- where: document.body,
3888
- url: Ji(n),
3889
- messageHandlersFilter: t.iframes.CROSS_ORIGIN_IFRAMES_FILTER,
3890
- attributes: Gi,
3891
- dontclear: !0
3892
- }, (i) => new Promise(async (r, s) => {
3893
- await i.restyle({
3894
- // Prevent iframe from closing on mouse out.
3895
- setHideOnLeave: !1
3896
- });
3897
- const o = g(
3898
- n,
3899
- "network-request-failed"
3900
- /* AuthErrorCode.NETWORK_REQUEST_FAILED */
3901
- ), c = m().setTimeout(() => {
3902
- s(o);
3903
- }, Bi.get());
3904
- function a() {
3905
- m().clearTimeout(c), r(i);
3906
- }
3907
- i.ping(a).then(a, () => {
3908
- s(o);
3909
- });
3910
- }));
3911
- }
3912
- /**
3913
- * @license
3914
- * Copyright 2020 Google LLC.
3915
- *
3916
- * Licensed under the Apache License, Version 2.0 (the "License");
3917
- * you may not use this file except in compliance with the License.
3918
- * You may obtain a copy of the License at
3919
- *
3920
- * http://www.apache.org/licenses/LICENSE-2.0
3921
- *
3922
- * Unless required by applicable law or agreed to in writing, software
3923
- * distributed under the License is distributed on an "AS IS" BASIS,
3924
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3925
- * See the License for the specific language governing permissions and
3926
- * limitations under the License.
3927
- */
3928
- const Xi = {
3929
- location: "yes",
3930
- resizable: "yes",
3931
- statusbar: "yes",
3932
- toolbar: "no"
3933
- }, Qi = 500, Zi = 600, er = "_blank", tr = "http://localhost";
3934
- class Ke {
3935
- constructor(e) {
3936
- this.window = e, this.associatedEvent = null;
3937
- }
3938
- close() {
3939
- if (this.window)
3940
- try {
3941
- this.window.close();
3942
- } catch {
3943
- }
3944
- }
3945
- }
3946
- function nr(n, e, t, i = Qi, r = Zi) {
3947
- const s = Math.max((window.screen.availHeight - r) / 2, 0).toString(), o = Math.max((window.screen.availWidth - i) / 2, 0).toString();
3948
- let c = "";
3949
- const a = Object.assign(Object.assign({}, Xi), {
3950
- width: i.toString(),
3951
- height: r.toString(),
3952
- top: s,
3953
- left: o
3954
- }), l = f().toLowerCase();
3955
- t && (c = ht(l) ? er : t), dt(l) && (e = e || tr, a.scrollbars = "yes");
3956
- const d = Object.entries(a).reduce((p, [B, K]) => `${p}${B}=${K},`, "");
3957
- if (Un(l) && c !== "_self")
3958
- return ir(e || "", c), new Ke(null);
3959
- const h = window.open(e || "", c, d);
3960
- u(
3961
- h,
3962
- n,
3963
- "popup-blocked"
3964
- /* AuthErrorCode.POPUP_BLOCKED */
3965
- );
3966
- try {
3967
- h.focus();
3968
- } catch {
3969
- }
3970
- return new Ke(h);
3971
- }
3972
- function ir(n, e) {
3973
- const t = document.createElement("a");
3974
- t.href = n, t.target = e;
3975
- const i = document.createEvent("MouseEvent");
3976
- i.initMouseEvent("click", !0, !0, window, 1, 0, 0, 0, 0, !1, !1, !1, !1, 1, null), t.dispatchEvent(i);
3977
- }
3978
- /**
3979
- * @license
3980
- * Copyright 2021 Google LLC
3981
- *
3982
- * Licensed under the Apache License, Version 2.0 (the "License");
3983
- * you may not use this file except in compliance with the License.
3984
- * You may obtain a copy of the License at
3985
- *
3986
- * http://www.apache.org/licenses/LICENSE-2.0
3987
- *
3988
- * Unless required by applicable law or agreed to in writing, software
3989
- * distributed under the License is distributed on an "AS IS" BASIS,
3990
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3991
- * See the License for the specific language governing permissions and
3992
- * limitations under the License.
3993
- */
3994
- const rr = "__/auth/handler", sr = "emulator/auth/handler", or = encodeURIComponent("fac");
3995
- async function qe(n, e, t, i, r, s) {
3996
- u(
3997
- n.config.authDomain,
3998
- n,
3999
- "auth-domain-config-required"
4000
- /* AuthErrorCode.MISSING_AUTH_DOMAIN */
4001
- ), u(
4002
- n.config.apiKey,
4003
- n,
4004
- "invalid-api-key"
4005
- /* AuthErrorCode.INVALID_API_KEY */
4006
- );
4007
- const o = {
4008
- apiKey: n.config.apiKey,
4009
- appName: n.name,
4010
- authType: t,
4011
- redirectUrl: i,
4012
- v: F,
4013
- eventId: r
4014
- };
4015
- if (e instanceof kt) {
4016
- e.setDefaultLanguage(n.languageCode), o.providerId = e.providerId || "", an(e.getCustomParameters()) || (o.customParameters = JSON.stringify(e.getCustomParameters()));
4017
- for (const [d, h] of Object.entries(s || {}))
4018
- o[d] = h;
4019
- }
4020
- if (e instanceof $) {
4021
- const d = e.getScopes().filter((h) => h !== "");
4022
- d.length > 0 && (o.scopes = d.join(","));
4023
- }
4024
- n.tenantId && (o.tid = n.tenantId);
4025
- const c = o;
4026
- for (const d of Object.keys(c))
4027
- c[d] === void 0 && delete c[d];
4028
- const a = await n._getAppCheckToken(), l = a ? `#${or}=${encodeURIComponent(a)}` : "";
4029
- return `${ar(n)}?${x(c).slice(1)}${l}`;
4030
- }
4031
- function ar({ config: n }) {
4032
- return n.emulator ? ve(n, sr) : `https://${n.authDomain}/${rr}`;
4033
- }
4034
- /**
4035
- * @license
4036
- * Copyright 2020 Google LLC
4037
- *
4038
- * Licensed under the Apache License, Version 2.0 (the "License");
4039
- * you may not use this file except in compliance with the License.
4040
- * You may obtain a copy of the License at
4041
- *
4042
- * http://www.apache.org/licenses/LICENSE-2.0
4043
- *
4044
- * Unless required by applicable law or agreed to in writing, software
4045
- * distributed under the License is distributed on an "AS IS" BASIS,
4046
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4047
- * See the License for the specific language governing permissions and
4048
- * limitations under the License.
4049
- */
4050
- const ue = "webStorageSupport";
4051
- class cr {
4052
- constructor() {
4053
- this.eventManagers = {}, this.iframes = {}, this.originValidationPromises = {}, this._redirectPersistence = Ct, this._completeRedirectFn = Oi, this._overrideRedirectResult = Ci;
4054
- }
4055
- // Wrapping in async even though we don't await anywhere in order
4056
- // to make sure errors are raised as promise rejections
4057
- async _openPopup(e, t, i, r) {
4058
- var s;
4059
- y((s = this.eventManagers[e._key()]) === null || s === void 0 ? void 0 : s.manager, "_initialize() not called before _openPopup()");
4060
- const o = await qe(e, t, i, he(), r);
4061
- return nr(e, o, we());
4062
- }
4063
- async _openRedirect(e, t, i, r) {
4064
- await this._originValidation(e);
4065
- const s = await qe(e, t, i, he(), r);
4066
- return di(s), new Promise(() => {
4067
- });
4068
- }
4069
- _initialize(e) {
4070
- const t = e._key();
4071
- if (this.eventManagers[t]) {
4072
- const { manager: r, promise: s } = this.eventManagers[t];
4073
- return r ? Promise.resolve(r) : (y(s, "If manager is not set, promise should be"), s);
4074
- }
4075
- const i = this.initAndGetManager(e);
4076
- return this.eventManagers[t] = { promise: i }, i.catch(() => {
4077
- delete this.eventManagers[t];
4078
- }), i;
4079
- }
4080
- async initAndGetManager(e) {
4081
- const t = await Yi(e), i = new Mi(e);
4082
- return t.register("authEvent", (r) => (u(
4083
- r == null ? void 0 : r.authEvent,
4084
- e,
4085
- "invalid-auth-event"
4086
- /* AuthErrorCode.INVALID_AUTH_EVENT */
4087
- ), {
4088
- status: i.onEvent(r.authEvent) ? "ACK" : "ERROR"
4089
- /* GapiOutcome.ERROR */
4090
- }), gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER), this.eventManagers[e._key()] = { manager: i }, this.iframes[e._key()] = t, i;
4091
- }
4092
- _isIframeWebStorageSupported(e, t) {
4093
- this.iframes[e._key()].send(ue, { type: ue }, (r) => {
4094
- var s;
4095
- const o = (s = r == null ? void 0 : r[0]) === null || s === void 0 ? void 0 : s[ue];
4096
- o !== void 0 && t(!!o), I(
4097
- e,
4098
- "internal-error"
4099
- /* AuthErrorCode.INTERNAL_ERROR */
4100
- );
4101
- }, gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER);
4102
- }
4103
- _originValidation(e) {
4104
- const t = e._key();
4105
- return this.originValidationPromises[t] || (this.originValidationPromises[t] = Vi(e)), this.originValidationPromises[t];
4106
- }
4107
- get _shouldInitProactively() {
4108
- return _t() || Te() || ne();
4109
- }
4110
- }
4111
- const lr = cr;
4112
- var Ge = "@firebase/auth", ze = "0.23.2";
4113
- /**
4114
- * @license
4115
- * Copyright 2020 Google LLC
4116
- *
4117
- * Licensed under the Apache License, Version 2.0 (the "License");
4118
- * you may not use this file except in compliance with the License.
4119
- * You may obtain a copy of the License at
4120
- *
4121
- * http://www.apache.org/licenses/LICENSE-2.0
4122
- *
4123
- * Unless required by applicable law or agreed to in writing, software
4124
- * distributed under the License is distributed on an "AS IS" BASIS,
4125
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4126
- * See the License for the specific language governing permissions and
4127
- * limitations under the License.
4128
- */
4129
- class ur {
4130
- constructor(e) {
4131
- this.auth = e, this.internalListeners = /* @__PURE__ */ new Map();
4132
- }
4133
- getUid() {
4134
- var e;
4135
- return this.assertAuthConfigured(), ((e = this.auth.currentUser) === null || e === void 0 ? void 0 : e.uid) || null;
4136
- }
4137
- async getToken(e) {
4138
- return this.assertAuthConfigured(), await this.auth._initializationPromise, this.auth.currentUser ? { accessToken: await this.auth.currentUser.getIdToken(e) } : null;
4139
- }
4140
- addAuthTokenListener(e) {
4141
- if (this.assertAuthConfigured(), this.internalListeners.has(e))
4142
- return;
4143
- const t = this.auth.onIdTokenChanged((i) => {
4144
- e((i == null ? void 0 : i.stsTokenManager.accessToken) || null);
4145
- });
4146
- this.internalListeners.set(e, t), this.updateProactiveRefresh();
4147
- }
4148
- removeAuthTokenListener(e) {
4149
- this.assertAuthConfigured();
4150
- const t = this.internalListeners.get(e);
4151
- t && (this.internalListeners.delete(e), t(), this.updateProactiveRefresh());
4152
- }
4153
- assertAuthConfigured() {
4154
- u(
4155
- this.auth._initializationPromise,
4156
- "dependent-sdk-initialized-before-auth"
4157
- /* AuthErrorCode.DEPENDENT_SDK_INIT_BEFORE_AUTH */
4158
- );
4159
- }
4160
- updateProactiveRefresh() {
4161
- this.internalListeners.size > 0 ? this.auth._startProactiveRefresh() : this.auth._stopProactiveRefresh();
4162
- }
4163
- }
4164
- /**
4165
- * @license
4166
- * Copyright 2020 Google LLC
4167
- *
4168
- * Licensed under the Apache License, Version 2.0 (the "License");
4169
- * you may not use this file except in compliance with the License.
4170
- * You may obtain a copy of the License at
4171
- *
4172
- * http://www.apache.org/licenses/LICENSE-2.0
4173
- *
4174
- * Unless required by applicable law or agreed to in writing, software
4175
- * distributed under the License is distributed on an "AS IS" BASIS,
4176
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4177
- * See the License for the specific language governing permissions and
4178
- * limitations under the License.
4179
- */
4180
- function dr(n) {
4181
- switch (n) {
4182
- case "Node":
4183
- return "node";
4184
- case "ReactNative":
4185
- return "rn";
4186
- case "Worker":
4187
- return "webworker";
4188
- case "Cordova":
4189
- return "cordova";
4190
- default:
4191
- return;
4192
- }
4193
- }
4194
- function hr(n) {
4195
- Ne(new Oe(
4196
- "auth",
4197
- (e, { options: t }) => {
4198
- const i = e.getProvider("app").getImmediate(), r = e.getProvider("heartbeat"), s = e.getProvider("app-check-internal"), { apiKey: o, authDomain: c } = i.options;
4199
- u(o && !o.includes(":"), "invalid-api-key", { appName: i.name });
4200
- const a = {
4201
- apiKey: o,
4202
- authDomain: c,
4203
- clientPlatform: n,
4204
- apiHost: "identitytoolkit.googleapis.com",
4205
- tokenApiHost: "securetoken.googleapis.com",
4206
- apiScheme: "https",
4207
- sdkClientVersion: vt(n)
4208
- }, l = new Kn(i, r, s, a);
4209
- return Gn(l, t), l;
4210
- },
4211
- "PUBLIC"
4212
- /* ComponentType.PUBLIC */
4213
- ).setInstantiationMode(
4214
- "EXPLICIT"
4215
- /* InstantiationMode.EXPLICIT */
4216
- ).setInstanceCreatedCallback((e, t, i) => {
4217
- e.getProvider(
4218
- "auth-internal"
4219
- /* _ComponentName.AUTH_INTERNAL */
4220
- ).initialize();
4221
- })), Ne(new Oe(
4222
- "auth-internal",
4223
- (e) => {
4224
- const t = H(e.getProvider(
4225
- "auth"
4226
- /* _ComponentName.AUTH */
4227
- ).getImmediate());
4228
- return ((i) => new ur(i))(t);
4229
- },
4230
- "PRIVATE"
4231
- /* ComponentType.PRIVATE */
4232
- ).setInstantiationMode(
4233
- "EXPLICIT"
4234
- /* InstantiationMode.EXPLICIT */
4235
- )), de(Ge, ze, dr(n)), de(Ge, ze, "esm2017");
4236
- }
4237
- /**
4238
- * @license
4239
- * Copyright 2021 Google LLC
4240
- *
4241
- * Licensed under the Apache License, Version 2.0 (the "License");
4242
- * you may not use this file except in compliance with the License.
4243
- * You may obtain a copy of the License at
4244
- *
4245
- * http://www.apache.org/licenses/LICENSE-2.0
4246
- *
4247
- * Unless required by applicable law or agreed to in writing, software
4248
- * distributed under the License is distributed on an "AS IS" BASIS,
4249
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4250
- * See the License for the specific language governing permissions and
4251
- * limitations under the License.
4252
- */
4253
- const fr = 5 * 60, pr = et("authIdTokenMaxAge") || fr;
4254
- let Je = null;
4255
- const gr = (n) => async (e) => {
4256
- const t = e && await e.getIdTokenResult(), i = t && ((/* @__PURE__ */ new Date()).getTime() - Date.parse(t.issuedAtTime)) / 1e3;
4257
- if (i && i > pr)
4258
- return;
4259
- const r = t == null ? void 0 : t.token;
4260
- Je !== r && (Je = r, await fetch(n, {
4261
- method: r ? "POST" : "DELETE",
4262
- headers: r ? {
4263
- Authorization: `Bearer ${r}`
4264
- } : {}
4265
- }));
4266
- };
4267
- function mr(n = tn()) {
4268
- const e = tt(n, "auth");
4269
- if (e.isInitialized())
4270
- return e.getImmediate();
4271
- const t = qn(n, {
4272
- popupRedirectResolver: lr,
4273
- persistence: [
4274
- yi,
4275
- ci,
4276
- Ct
4277
- ]
4278
- }), i = et("authTokenSyncURL");
4279
- if (i) {
4280
- const s = gr(i);
4281
- ri(t, s, () => s(t.currentUser)), ii(t, (o) => s(o));
4282
- }
4283
- const r = en("auth");
4284
- return r && zn(t, `http://${r}`), t;
4285
- }
4286
- hr(
4287
- "Browser"
4288
- /* ClientPlatform.BROWSER */
4289
- );
4290
- class D {
4291
- constructor(e = null, t = {}) {
4292
- if (this.apiKey = e, this.options = t, typeof window > "u")
4293
- throw new Error("google-maps is supported only in browser environment");
4294
- }
4295
- load() {
4296
- return typeof this.api < "u" ? Promise.resolve(this.api) : typeof this.loader < "u" ? this.loader : (window[D.CALLBACK_NAME] = () => {
4297
- if (this.api = window.google, typeof this.resolve > "u")
4298
- throw new Error("Should not happen");
4299
- this.resolve(this.api);
4300
- }, window.gm_authFailure = () => {
4301
- if (typeof this.reject > "u")
4302
- throw new Error("Should not happen");
4303
- this.reject(new Error("google-maps: authentication error"));
4304
- }, this.loader = new Promise((e, t) => {
4305
- this.resolve = e, this.reject = t;
4306
- const i = document.createElement("script");
4307
- i.src = this.createUrl(), i.async = !0, i.onerror = (r) => t(r), document.head.appendChild(i);
4308
- }));
4309
- }
4310
- createUrl() {
4311
- const e = [
4312
- `callback=${D.CALLBACK_NAME}`
4313
- ];
4314
- this.apiKey && e.push(`key=${this.apiKey}`);
4315
- for (let t in this.options)
4316
- if (this.options.hasOwnProperty(t)) {
4317
- let i = this.options[t];
4318
- t === "version" && (t = "v"), t === "libraries" && (i = i.join(",")), e.push(`${t}=${i}`);
4319
- }
4320
- return `https://maps.googleapis.com/maps/api/js?${e.join("&")}`;
4321
- }
4322
- }
4323
- D.CALLBACK_NAME = "_dk_google_maps_loader_cb";
4324
- async function _r() {
4325
- if (cn().length)
4326
- return;
4327
- const n = ln({ apiKey: "AIzaSyAj8JdCHtP0Vc5vZobCfgoLzWxPIn0WUG4", authDomain: "feedme-dev-4c3ef.firebaseapp.com", databaseURL: "https://feedme-dev-4c3ef.firebaseio.com", projectId: "feedme-dev-4c3ef", storageBucket: "feedme-dev-4c3ef.appspot.com", messagingSenderId: "458797803788", appId: "1:458797803788:web:37f2af2926a84288f0c129", measurementId: "G-J2QG09D2Q7" }), e = await qt.getCustomToken(), t = mr();
4328
- await ni(t, e), un(n);
4329
- }
4330
- async function vr() {
4331
- if (dn())
4332
- return;
4333
- const e = await new D("AIzaSyA_isPR1-9bX7UmRiJIhsIRNNwdn6DdmW4", {
4334
- libraries: ["places"]
4335
- }).load();
4336
- hn(e);
4337
- }
4338
- async function Ir() {
4339
- await _r(), await vr();
4340
- }
4341
- const Pr = /* @__PURE__ */ Ye({
4342
- __name: "App",
4343
- setup(n) {
4344
- const e = Ze();
4345
- return Ht(() => {
4346
- e.registerSidebarComponent(fn), Ir();
4347
- }), (t, i) => (Xe(), Qe($t(Bt)));
4348
- }
4349
- });
4350
- export {
4351
- Pr as default
4352
- };