@feedmepos/mf-connect 0.1.38-beta.6 → 0.1.38-beta.60

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