@feedmepos/mf-connect 0.1.38-beta.52 → 0.1.38-beta.53

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