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