@feedmepos/mf-connect 0.1.57-prod → 0.1.58-prod

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