@feedmepos/mf-settings 0.0.75-dev.1 → 0.0.75-dev.3

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