@redzone/taunt-logins-ui-react 0.0.12 → 0.0.13
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/cjs/cc-D-353NYd.cjs +63 -0
- package/dist/cjs/index.cjs +647 -0
- package/dist/cjs/index.d.cts +112 -0
- package/dist/es/cc-D6TRVNtd.js +61 -0
- package/dist/es/index.d.ts +112 -0
- package/dist/es/index.js +636 -0
- package/package.json +39 -29
- package/README.md +0 -73
- package/dist/LoadingView.d.ts +0 -1
- package/dist/LoginUIComplete.d.ts +0 -7
- package/dist/LoginView.d.ts +0 -41
- package/dist/ModalView.d.ts +0 -7
- package/dist/assets/fonts/DrukTextWide-Bold-Trial.otf +0 -0
- package/dist/coinbase.d.ts +0 -5
- package/dist/index.d.ts +0 -11
- package/dist/magic.d.ts +0 -4
- package/dist/meta.d.ts +0 -5
- package/dist/metamask.d.ts +0 -5
- package/dist/taunt-logins-ui-react.css +0 -1
- package/dist/taunt-logins-ui-react.d.ts +0 -2
- package/dist/taunt-logins-ui-react.js +0 -3639
- package/dist/taunt-logins-ui-react.js.map +0 -1
- package/dist/taunt-logins-ui-react.umd.cjs +0 -12
- package/dist/taunt-logins-ui-react.umd.cjs.map +0 -1
- package/dist/tauntContext.d.ts +0 -18
- package/dist/tauntProvider.d.ts +0 -5
- package/dist/telegram.d.ts +0 -5
|
@@ -1,3639 +0,0 @@
|
|
|
1
|
-
import { jsx as D, jsxs as ge, Fragment as dt } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback as me, createContext as Wn, useContext as qn, useState as Ye, useMemo as Bn, useEffect as Vn } from "react";
|
|
3
|
-
const zn = "https://res.cloudinary.com/dz0wa3qbj/image/upload/v1760030923/coinbase_kyknjr.png", Hn = ({
|
|
4
|
-
openCoinbase: e,
|
|
5
|
-
disabled: t = !1
|
|
6
|
-
}) => {
|
|
7
|
-
const r = me(() => {
|
|
8
|
-
t || (e ? e() : console.log("Coinbase login not yet implemented"));
|
|
9
|
-
}, [e, t]);
|
|
10
|
-
return /* @__PURE__ */ D(
|
|
11
|
-
"button",
|
|
12
|
-
{
|
|
13
|
-
className: `rdz-icon-button ${t ? "rdz-icon-button-disabled" : ""}`,
|
|
14
|
-
onClick: r,
|
|
15
|
-
disabled: t,
|
|
16
|
-
children: /* @__PURE__ */ D("img", { src: zn, alt: "Coinbase" })
|
|
17
|
-
}
|
|
18
|
-
);
|
|
19
|
-
};
|
|
20
|
-
function Xn() {
|
|
21
|
-
return /* @__PURE__ */ ge(
|
|
22
|
-
"div",
|
|
23
|
-
{
|
|
24
|
-
className: "rzd-loginview",
|
|
25
|
-
style: {
|
|
26
|
-
display: "flex",
|
|
27
|
-
flexDirection: "column",
|
|
28
|
-
alignItems: "center",
|
|
29
|
-
gap: 20
|
|
30
|
-
},
|
|
31
|
-
children: [
|
|
32
|
-
/* @__PURE__ */ D("h1", { children: "Processing..." }),
|
|
33
|
-
/* @__PURE__ */ D(
|
|
34
|
-
"div",
|
|
35
|
-
{
|
|
36
|
-
style: {
|
|
37
|
-
width: "60px",
|
|
38
|
-
height: "60px",
|
|
39
|
-
border: "4px solid #009df3",
|
|
40
|
-
borderTop: "4px solid transparent",
|
|
41
|
-
borderRadius: "50%",
|
|
42
|
-
animation: "spin 1s linear infinite"
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
),
|
|
46
|
-
/* @__PURE__ */ D("style", { children: `
|
|
47
|
-
@keyframes spin {
|
|
48
|
-
0% { transform: rotate(0deg); }
|
|
49
|
-
100% { transform: rotate(360deg); }
|
|
50
|
-
}
|
|
51
|
-
` }),
|
|
52
|
-
/* @__PURE__ */ D(
|
|
53
|
-
"p",
|
|
54
|
-
{
|
|
55
|
-
style: {
|
|
56
|
-
fontFamily: "Futura PT, sans-serif",
|
|
57
|
-
fontSize: "1.2em",
|
|
58
|
-
color: "white"
|
|
59
|
-
},
|
|
60
|
-
children: "Please wait while we authenticate you..."
|
|
61
|
-
}
|
|
62
|
-
)
|
|
63
|
-
]
|
|
64
|
-
}
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
const ss = ({
|
|
68
|
-
className: e,
|
|
69
|
-
extLoading: t = !1,
|
|
70
|
-
...r
|
|
71
|
-
}) => {
|
|
72
|
-
const { loggedIn: n, isLoading: i } = Qe();
|
|
73
|
-
return /* @__PURE__ */ D("div", { className: `rzd-loginview rzd-loginui-complete ${e || ""}`, children: t || i ? /* @__PURE__ */ D(Xn, {}) : n ? /* @__PURE__ */ D(Kn, {}) : /* @__PURE__ */ ge(dt, { children: [
|
|
74
|
-
/* @__PURE__ */ D("h1", { className: "header-login", children: "login" }),
|
|
75
|
-
/* @__PURE__ */ D(io, { ...r })
|
|
76
|
-
] }) });
|
|
77
|
-
};
|
|
78
|
-
function Kn() {
|
|
79
|
-
return /* @__PURE__ */ ge(dt, { children: [
|
|
80
|
-
/* @__PURE__ */ D("h1", { children: "Successfully Logged In" }),
|
|
81
|
-
/* @__PURE__ */ D("p", { style: { fontFamily: "Futura PT, sans-serif", fontSize: "1.2em" }, children: "You are now logged in!" }),
|
|
82
|
-
/* @__PURE__ */ D(Yn, {})
|
|
83
|
-
] });
|
|
84
|
-
}
|
|
85
|
-
function Yn() {
|
|
86
|
-
const { logout: e } = Qe();
|
|
87
|
-
return /* @__PURE__ */ D("button", { onClick: e, className: "rdz-logout-button", type: "button", children: "Logout" });
|
|
88
|
-
}
|
|
89
|
-
const Ir = Wn({
|
|
90
|
-
tauntServiceEndpoint: "",
|
|
91
|
-
isLoading: !1,
|
|
92
|
-
loggedIn: !1,
|
|
93
|
-
metamaskLogin: () => {
|
|
94
|
-
},
|
|
95
|
-
otpMagicLogin: () => {
|
|
96
|
-
},
|
|
97
|
-
telegramLogin: () => {
|
|
98
|
-
},
|
|
99
|
-
metaLogin: () => {
|
|
100
|
-
},
|
|
101
|
-
coinbaseLogin: () => {
|
|
102
|
-
},
|
|
103
|
-
logout: () => {
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
function Qe() {
|
|
107
|
-
const e = qn(Ir);
|
|
108
|
-
if (!e)
|
|
109
|
-
throw new Error("useTaunt must be used within a TauntProvider");
|
|
110
|
-
return e;
|
|
111
|
-
}
|
|
112
|
-
const Jn = "https://res.cloudinary.com/dz0wa3qbj/image/upload/v1760030925/btn_ioay6n.png", Qn = ({ onEmail: e }) => {
|
|
113
|
-
const { otpMagicLogin: t } = Qe(), [r, n] = Ye(), [i, a] = Ye(!1), h = Bn(() => {
|
|
114
|
-
const y = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
|
|
115
|
-
return r?.match(y) ? r : void 0;
|
|
116
|
-
}, [r]);
|
|
117
|
-
return /* @__PURE__ */ ge("div", { className: "rdz-magic-email-container", children: [
|
|
118
|
-
i && /* @__PURE__ */ D("div", { className: "rdz-magic-email-error", children: "Please enter a valid email" }),
|
|
119
|
-
/* @__PURE__ */ D(
|
|
120
|
-
"input",
|
|
121
|
-
{
|
|
122
|
-
className: "rdz-input",
|
|
123
|
-
onChange: (y) => n(y.target.value ? y.target.value : void 0),
|
|
124
|
-
placeholder: "Email address",
|
|
125
|
-
type: "email",
|
|
126
|
-
value: r
|
|
127
|
-
}
|
|
128
|
-
),
|
|
129
|
-
/* @__PURE__ */ D(
|
|
130
|
-
"button",
|
|
131
|
-
{
|
|
132
|
-
onClick: () => {
|
|
133
|
-
if (!h) {
|
|
134
|
-
a(!0);
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
a(!1), e ? e(r) : t(r);
|
|
138
|
-
},
|
|
139
|
-
type: "button",
|
|
140
|
-
className: "rdz-magic-email-button",
|
|
141
|
-
style: {
|
|
142
|
-
backgroundImage: `url(${Jn})`
|
|
143
|
-
},
|
|
144
|
-
children: "LOG IN / SIGN UP"
|
|
145
|
-
}
|
|
146
|
-
)
|
|
147
|
-
] });
|
|
148
|
-
}, Zn = "https://res.cloudinary.com/dz0wa3qbj/image/upload/v1760030923/meta_rhrjov.png", eo = ({
|
|
149
|
-
openMeta: e,
|
|
150
|
-
disabled: t = !1
|
|
151
|
-
}) => {
|
|
152
|
-
const r = me(() => {
|
|
153
|
-
t || (e ? e() : console.log("Meta login not yet implemented"));
|
|
154
|
-
}, [e, t]);
|
|
155
|
-
return /* @__PURE__ */ D(
|
|
156
|
-
"button",
|
|
157
|
-
{
|
|
158
|
-
className: `rdz-icon-button ${t ? "rdz-icon-button-disabled" : ""}`,
|
|
159
|
-
onClick: r,
|
|
160
|
-
disabled: t,
|
|
161
|
-
children: /* @__PURE__ */ D("img", { src: Zn, alt: "Meta" })
|
|
162
|
-
}
|
|
163
|
-
);
|
|
164
|
-
}, to = "https://res.cloudinary.com/dz0wa3qbj/image/upload/v1760030924/metamask_asjtmi.png", ro = ({
|
|
165
|
-
openMetamask: e,
|
|
166
|
-
disabled: t = !1
|
|
167
|
-
}) => {
|
|
168
|
-
const { metamaskLogin: r } = Qe(), n = me(() => {
|
|
169
|
-
t || (e ? e() : r());
|
|
170
|
-
}, [r, e, t]);
|
|
171
|
-
return /* @__PURE__ */ D(
|
|
172
|
-
"button",
|
|
173
|
-
{
|
|
174
|
-
className: `rdz-icon-button ${t ? "rdz-icon-button-disabled" : ""}`,
|
|
175
|
-
onClick: n,
|
|
176
|
-
disabled: t,
|
|
177
|
-
children: /* @__PURE__ */ D("img", { src: to, alt: "MetaMask" })
|
|
178
|
-
}
|
|
179
|
-
);
|
|
180
|
-
}, no = "https://res.cloudinary.com/dz0wa3qbj/image/upload/v1760030924/tel_vcs64d.png", oo = ({
|
|
181
|
-
openTelegram: e,
|
|
182
|
-
disabled: t = !1
|
|
183
|
-
}) => {
|
|
184
|
-
const { telegramLogin: r } = Qe(), n = me(() => {
|
|
185
|
-
t || (e ? e() : r());
|
|
186
|
-
}, [r, e, t]);
|
|
187
|
-
return /* @__PURE__ */ D(
|
|
188
|
-
"button",
|
|
189
|
-
{
|
|
190
|
-
className: `rdz-icon-button ${t ? "rdz-icon-button-disabled" : ""}`,
|
|
191
|
-
onClick: n,
|
|
192
|
-
disabled: t,
|
|
193
|
-
children: /* @__PURE__ */ D("img", { src: no, alt: "Telegram" })
|
|
194
|
-
}
|
|
195
|
-
);
|
|
196
|
-
}, io = ({
|
|
197
|
-
providers: e = ["email", "metamask", "telegram", "meta", "coinbase"],
|
|
198
|
-
showEmail: t = !0,
|
|
199
|
-
showDisabled: r = !1,
|
|
200
|
-
dividerText: n = "Or Sign Up Using",
|
|
201
|
-
providerGap: i = 20,
|
|
202
|
-
showTerms: a = !1,
|
|
203
|
-
termsContent: h,
|
|
204
|
-
privacyContent: u,
|
|
205
|
-
onTermsClick: y,
|
|
206
|
-
onPrivacyClick: m,
|
|
207
|
-
ModalComponent: E,
|
|
208
|
-
magicEmailProps: p = {},
|
|
209
|
-
coinbaseProps: S = {},
|
|
210
|
-
metamaskProps: M = {},
|
|
211
|
-
metaProps: P = {},
|
|
212
|
-
telegramProps: G = {}
|
|
213
|
-
}) => {
|
|
214
|
-
const [O, K] = Ye(null), q = t || e.includes("email"), B = [
|
|
215
|
-
"coinbase",
|
|
216
|
-
"metamask",
|
|
217
|
-
"meta",
|
|
218
|
-
"telegram"
|
|
219
|
-
], ee = r ? B : B.filter((F) => e.includes(F)), N = ee.length > 0, j = () => {
|
|
220
|
-
console.log("Terms clicked", { onTermsClick: y, termsContent: !!h }), y ? y() : h && K({ title: "Terms of Service", content: h });
|
|
221
|
-
}, x = () => {
|
|
222
|
-
console.log("Privacy clicked", {
|
|
223
|
-
onPrivacyClick: m,
|
|
224
|
-
privacyContent: !!u
|
|
225
|
-
}), m ? m() : u && K({ title: "Privacy Policy", content: u });
|
|
226
|
-
};
|
|
227
|
-
return /* @__PURE__ */ ge(dt, { children: [
|
|
228
|
-
q && /* @__PURE__ */ D(Qn, { ...p }),
|
|
229
|
-
q && N && /* @__PURE__ */ D("p", { className: "rdz-sign-up-text", children: n }),
|
|
230
|
-
N && /* @__PURE__ */ ge(
|
|
231
|
-
"div",
|
|
232
|
-
{
|
|
233
|
-
style: {
|
|
234
|
-
display: "flex",
|
|
235
|
-
flexDirection: "row",
|
|
236
|
-
gap: i,
|
|
237
|
-
alignItems: "center"
|
|
238
|
-
},
|
|
239
|
-
children: [
|
|
240
|
-
ee.includes("coinbase") && /* @__PURE__ */ D(
|
|
241
|
-
Hn,
|
|
242
|
-
{
|
|
243
|
-
disabled: !e.includes("coinbase"),
|
|
244
|
-
...S
|
|
245
|
-
}
|
|
246
|
-
),
|
|
247
|
-
ee.includes("metamask") && /* @__PURE__ */ D(
|
|
248
|
-
ro,
|
|
249
|
-
{
|
|
250
|
-
disabled: !e.includes("metamask"),
|
|
251
|
-
...M
|
|
252
|
-
}
|
|
253
|
-
),
|
|
254
|
-
ee.includes("meta") && /* @__PURE__ */ D(eo, { disabled: !e.includes("meta"), ...P }),
|
|
255
|
-
ee.includes("telegram") && /* @__PURE__ */ D(
|
|
256
|
-
oo,
|
|
257
|
-
{
|
|
258
|
-
disabled: !e.includes("telegram"),
|
|
259
|
-
...G
|
|
260
|
-
}
|
|
261
|
-
)
|
|
262
|
-
]
|
|
263
|
-
}
|
|
264
|
-
),
|
|
265
|
-
console.log("Terms render check:", {
|
|
266
|
-
showTerms: a,
|
|
267
|
-
hasTermsContent: !!h,
|
|
268
|
-
hasPrivacyContent: !!u,
|
|
269
|
-
hasTermsClick: !!y,
|
|
270
|
-
hasPrivacyClick: !!m
|
|
271
|
-
}),
|
|
272
|
-
a && (h || u || y || m) && /* @__PURE__ */ ge(
|
|
273
|
-
"p",
|
|
274
|
-
{
|
|
275
|
-
style: {
|
|
276
|
-
fontFamily: "Futura PT, sans-serif",
|
|
277
|
-
fontSize: "1.3em"
|
|
278
|
-
},
|
|
279
|
-
children: [
|
|
280
|
-
"By connecting you are agreeing to our",
|
|
281
|
-
" ",
|
|
282
|
-
(h || y) && /* @__PURE__ */ D(
|
|
283
|
-
"a",
|
|
284
|
-
{
|
|
285
|
-
href: "#",
|
|
286
|
-
onClick: (F) => {
|
|
287
|
-
F.preventDefault(), j();
|
|
288
|
-
},
|
|
289
|
-
style: {
|
|
290
|
-
color: "#0099ff",
|
|
291
|
-
textDecoration: "none",
|
|
292
|
-
cursor: "pointer"
|
|
293
|
-
},
|
|
294
|
-
children: "Terms of Service"
|
|
295
|
-
}
|
|
296
|
-
),
|
|
297
|
-
(h || y) && (u || m) && " and ",
|
|
298
|
-
(u || m) && /* @__PURE__ */ D(
|
|
299
|
-
"a",
|
|
300
|
-
{
|
|
301
|
-
href: "#",
|
|
302
|
-
onClick: (F) => {
|
|
303
|
-
F.preventDefault(), x();
|
|
304
|
-
},
|
|
305
|
-
style: {
|
|
306
|
-
color: "#0099ff",
|
|
307
|
-
textDecoration: "none",
|
|
308
|
-
cursor: "pointer"
|
|
309
|
-
},
|
|
310
|
-
children: "Privacy Policy"
|
|
311
|
-
}
|
|
312
|
-
)
|
|
313
|
-
]
|
|
314
|
-
}
|
|
315
|
-
),
|
|
316
|
-
O && E && /* @__PURE__ */ ge(dt, { children: [
|
|
317
|
-
console.log("Rendering modal", {
|
|
318
|
-
modalContent: O,
|
|
319
|
-
ModalComponent: !!E
|
|
320
|
-
}),
|
|
321
|
-
/* @__PURE__ */ D(
|
|
322
|
-
E,
|
|
323
|
-
{
|
|
324
|
-
title: O.title,
|
|
325
|
-
content: O.content,
|
|
326
|
-
onClose: () => K(null)
|
|
327
|
-
}
|
|
328
|
-
)
|
|
329
|
-
] })
|
|
330
|
-
] });
|
|
331
|
-
};
|
|
332
|
-
function cs({ title: e, content: t, onClose: r }) {
|
|
333
|
-
return Vn(() => {
|
|
334
|
-
const i = (a) => {
|
|
335
|
-
a.key === "Escape" && r();
|
|
336
|
-
};
|
|
337
|
-
return document.addEventListener("keydown", i), () => document.removeEventListener("keydown", i);
|
|
338
|
-
}, [r]), /* @__PURE__ */ D(
|
|
339
|
-
"div",
|
|
340
|
-
{
|
|
341
|
-
style: {
|
|
342
|
-
position: "fixed",
|
|
343
|
-
top: 0,
|
|
344
|
-
left: 0,
|
|
345
|
-
right: 0,
|
|
346
|
-
bottom: 0,
|
|
347
|
-
backgroundColor: "rgba(0, 0, 0, 0.8)",
|
|
348
|
-
display: "flex",
|
|
349
|
-
alignItems: "center",
|
|
350
|
-
justifyContent: "center",
|
|
351
|
-
zIndex: 1e3,
|
|
352
|
-
padding: "20px"
|
|
353
|
-
},
|
|
354
|
-
onClick: r,
|
|
355
|
-
children: /* @__PURE__ */ ge(
|
|
356
|
-
"div",
|
|
357
|
-
{
|
|
358
|
-
style: {
|
|
359
|
-
backgroundColor: "#1a1a1a",
|
|
360
|
-
borderRadius: "12px",
|
|
361
|
-
border: "2px solid #009df3",
|
|
362
|
-
maxWidth: "800px",
|
|
363
|
-
maxHeight: "80vh",
|
|
364
|
-
width: "100%",
|
|
365
|
-
display: "flex",
|
|
366
|
-
flexDirection: "column",
|
|
367
|
-
overflow: "hidden"
|
|
368
|
-
},
|
|
369
|
-
onClick: (i) => i.stopPropagation(),
|
|
370
|
-
children: [
|
|
371
|
-
/* @__PURE__ */ ge(
|
|
372
|
-
"div",
|
|
373
|
-
{
|
|
374
|
-
style: {
|
|
375
|
-
padding: "20px 24px",
|
|
376
|
-
borderBottom: "1px solid #009df3",
|
|
377
|
-
display: "flex",
|
|
378
|
-
justifyContent: "space-between",
|
|
379
|
-
alignItems: "center"
|
|
380
|
-
},
|
|
381
|
-
children: [
|
|
382
|
-
/* @__PURE__ */ D("h2", { style: { fontFamily: "Futura PT, sans-serif", margin: 0, color: "white", fontSize: "24px" }, children: e }),
|
|
383
|
-
/* @__PURE__ */ D(
|
|
384
|
-
"button",
|
|
385
|
-
{
|
|
386
|
-
onClick: r,
|
|
387
|
-
style: {
|
|
388
|
-
background: "transparent",
|
|
389
|
-
border: "none",
|
|
390
|
-
color: "white",
|
|
391
|
-
fontSize: "32px",
|
|
392
|
-
cursor: "pointer",
|
|
393
|
-
padding: "0 10px",
|
|
394
|
-
lineHeight: 1
|
|
395
|
-
},
|
|
396
|
-
children: "×"
|
|
397
|
-
}
|
|
398
|
-
)
|
|
399
|
-
]
|
|
400
|
-
}
|
|
401
|
-
),
|
|
402
|
-
/* @__PURE__ */ D(
|
|
403
|
-
"div",
|
|
404
|
-
{
|
|
405
|
-
style: {
|
|
406
|
-
padding: "24px",
|
|
407
|
-
overflow: "auto",
|
|
408
|
-
flex: 1,
|
|
409
|
-
fontFamily: "Futura PT, sans-serif",
|
|
410
|
-
fontSize: "15px",
|
|
411
|
-
lineHeight: "1.6",
|
|
412
|
-
color: "white",
|
|
413
|
-
textAlign: "left"
|
|
414
|
-
},
|
|
415
|
-
children: ((i) => {
|
|
416
|
-
const a = i.split(`
|
|
417
|
-
`);
|
|
418
|
-
return a.map((h, u) => {
|
|
419
|
-
const y = h.trim();
|
|
420
|
-
if (u === 0 && y)
|
|
421
|
-
return /* @__PURE__ */ D("h1", { style: { marginTop: 0, marginBottom: "20px", fontSize: "28px" }, children: y }, u);
|
|
422
|
-
if (y && y.length < 100 && !y.includes(".") && u < a.length - 1 && a[u + 1].trim()) {
|
|
423
|
-
const m = a[u + 1].trim();
|
|
424
|
-
if (m && (m[0] === m[0].toUpperCase() || m.startsWith("We ")))
|
|
425
|
-
return /* @__PURE__ */ D("h3", { style: { marginTop: "24px", marginBottom: "12px", fontSize: "18px", fontWeight: "600" }, children: y }, u);
|
|
426
|
-
}
|
|
427
|
-
return y ? /* @__PURE__ */ D("p", { style: { marginBottom: "12px" }, children: y }, u) : /* @__PURE__ */ D("br", {}, u);
|
|
428
|
-
});
|
|
429
|
-
})(t)
|
|
430
|
-
}
|
|
431
|
-
)
|
|
432
|
-
]
|
|
433
|
-
}
|
|
434
|
-
)
|
|
435
|
-
}
|
|
436
|
-
);
|
|
437
|
-
}
|
|
438
|
-
var Me = ((e) => (e.MissingApiKey = "MISSING_API_KEY", e.ModalNotReady = "MODAL_NOT_READY", e.ConnectionLost = "CONNECTION_WAS_LOST", e.MalformedResponse = "MALFORMED_RESPONSE", e.InvalidArgument = "INVALID_ARGUMENT", e.ExtensionNotInitialized = "EXTENSION_NOT_INITIALIZED", e.IncompatibleExtensions = "INCOMPATIBLE_EXTENSIONS", e))(Me || {}), Ue = ((e) => (e.SyncWeb3Method = "SYNC_WEB3_METHOD", e.DuplicateIframe = "DUPLICATE_IFRAME", e.ReactNativeEndpointConfiguration = "REACT_NATIVE_ENDPOINT_CONFIGURATION", e.DeprecationNotice = "DEPRECATION_NOTICE", e.ProductAnnouncement = "ANNOUNCEMENT", e))(Ue || {}), gt = ((e) => (e[e.ParseError = -32700] = "ParseError", e[e.InvalidRequest = -32600] = "InvalidRequest", e[e.MethodNotFound = -32601] = "MethodNotFound", e[e.InvalidParams = -32602] = "InvalidParams", e[e.InternalError = -32603] = "InternalError", e[e.MagicLinkFailedVerification = -1e4] = "MagicLinkFailedVerification", e[e.MagicLinkExpired = -10001] = "MagicLinkExpired", e[e.MagicLinkRateLimited = -10002] = "MagicLinkRateLimited", e[e.MagicLinkInvalidRedirectURL = -10006] = "MagicLinkInvalidRedirectURL", e[e.UserAlreadyLoggedIn = -10003] = "UserAlreadyLoggedIn", e[e.UpdateEmailFailed = -10004] = "UpdateEmailFailed", e[e.UserRequestEditEmail = -10005] = "UserRequestEditEmail", e[e.InactiveRecipient = -10010] = "InactiveRecipient", e[e.AccessDeniedToUser = -10011] = "AccessDeniedToUser", e[e.RedirectLoginComplete = -10015] = "RedirectLoginComplete", e[e.DpopInvalidated = -10019] = "DpopInvalidated", e))(gt || {}), be = ((e) => (e.PROVIDER = "magic_3pw_provider", e.ADDRESS = "magic_3pw_address", e.CHAIN_ID = "magic_3pw_chainId", e))(be || {}), ao = ((e) => (e.WalletConnected = "wallet_connected", e.WalletRejected = "wallet_rejected", e.Web3ModalSelected = "web3modal_selected", e))(ao || {}), C = ((e) => (e.LoginWithSms = "magic_auth_login_with_sms", e.LoginWithEmailOTP = "magic_auth_login_with_email_otp", e.LoginWithMagicLink = "magic_auth_login_with_magic_link", e.LoginWithCredential = "magic_auth_login_with_credential", e.SetAuthorizationToken = "magic_auth_set_authorization_token", e.GetIdToken = "magic_auth_get_id_token", e.GenerateIdToken = "magic_auth_generate_id_token", e.GetMetadata = "magic_auth_get_metadata", e.IsLoggedIn = "magic_is_logged_in", e.Logout = "magic_auth_logout", e.UpdateEmail = "magic_auth_update_email", e.UserSettings = "magic_auth_settings", e.UserSettingsTestMode = "magic_auth_settings_testing_mode", e.LoginWithSmsTestMode = "magic_auth_login_with_sms_testing_mode", e.LoginWithEmailOTPTestMode = "magic_auth_login_with_email_otp_testing_mode", e.LoginWithMagicLinkTestMode = "magic_login_with_magic_link_testing_mode", e.LoginWithCredentialTestMode = "magic_auth_login_with_credential_testing_mode", e.GetIdTokenTestMode = "magic_auth_get_id_token_testing_mode", e.GenerateIdTokenTestMode = "magic_auth_generate_id_token_testing_mode", e.GetMetadataTestMode = "magic_auth_get_metadata_testing_mode", e.IsLoggedInTestMode = "magic_auth_is_logged_in_testing_mode", e.LogoutTestMode = "magic_auth_logout_testing_mode", e.UpdateEmailTestMode = "magic_auth_update_email_testing_mode", e.IntermediaryEvent = "magic_intermediary_event", e.RequestAccounts = "eth_requestAccounts", e.GetInfo = "magic_get_info", e.ShowUI = "magic_wallet", e.NFTPurchase = "magic_nft_purchase", e.NFTCheckout = "magic_nft_checkout", e.NFTTransfer = "magic_nft_transfer", e.RequestUserInfoWithUI = "mc_request_user_info", e.Disconnect = "mc_disconnect", e.RecoverAccount = "magic_auth_recover_account", e.RecoverAccountTestMode = "magic_auth_recover_account_testing_mode", e.MagicBoxHeartBeat = "magic_box_heart_beat", e.AutoConnect = "mc_auto_connect", e.Login = "mc_login", e.EncryptV1 = "magic_auth_encrypt_v1", e.DecryptV1 = "magic_auth_decrypt_v1", e.ShowNFTs = "magic_show_nfts", e.ShowOnRamp = "magic_show_fiat_onramp", e.ShowSendTokensUI = "magic_show_send_tokens_ui", e.ShowAddress = "magic_show_address", e.ShowBalances = "magic_show_balances", e.SendGaslessTransaction = "eth_sendGaslessTransaction", e.RevealPK = "magic_reveal_key", e.EnableMFA = "magic_auth_enable_mfa_flow", e.DisableMFA = "magic_auth_disable_mfa_flow", e.GetMultichainPublicAddress = "magic_get_multichain_public_address", e))(C || {}), so = ["magic_intermediary_event", "magic_nft_checkout", "mc_login"], Re = ((e) => (e.MAGIC_HANDLE_RESPONSE = "MAGIC_HANDLE_RESPONSE", e.MAGIC_OVERLAY_READY = "MAGIC_OVERLAY_READY", e.MAGIC_SHOW_OVERLAY = "MAGIC_SHOW_OVERLAY", e.MAGIC_HIDE_OVERLAY = "MAGIC_HIDE_OVERLAY", e.MAGIC_HANDLE_EVENT = "MAGIC_HANDLE_EVENT", e.MAGIC_MG_BOX_SEND_RECEIPT = "MAGIC_MG_BOX_SEND_RECEIPT", e.MAGIC_SEND_PRODUCT_ANNOUNCEMENT = "MAGIC_SEND_PRODUCT_ANNOUNCEMENT", e.MAGIC_PONG = "MAGIC_PONG", e.MAGIC_POPUP_RESPONSE = "MAGIC_POPUP_RESPONSE", e.MAGIC_POPUP_OAUTH_VERIFY_RESPONSE = "MAGIC_POPUP_OAUTH_VERIFY_RESPONSE", e))(Re || {}), Je = ((e) => (e.MAGIC_HANDLE_REQUEST = "MAGIC_HANDLE_REQUEST", e.MAGIC_PING = "MAGIC_PING", e))(Je || {}), co = ((e) => (e.UpdateEmail = "update-email", e.MFA = "mfa", e.Recovery = "recovery", e))(co || {}), lo = ((e) => (e.Retry = "retry", e))(lo || {}), uo = ((e) => (e.EmailSent = "email-sent", e.EmailNotDeliverable = "email-not-deliverable", e))(uo || {}), fe = ((e) => (e.VerifyEmailOtp = "verify-email-otp", e.VerifyMFACode = "verify-mfa-code", e.LostDevice = "lost-device", e.VerifyRecoveryCode = "verify-recovery-code", e.Cancel = "cancel", e))(fe || {}), ze = ((e) => (e.VerifySmsOtp = "verify-sms-otp", e.Cancel = "cancel", e.Retry = "retry", e))(ze || {}), fo = ((e) => (e.SmsOTPSent = "sms-otp-sent", e.InvalidSmsOtp = "invalid-sms-otp", e.ExpiredSmsOtp = "expired-sms-otp", e))(fo || {}), ho = ((e) => (e.EmailOTPSent = "email-otp-sent", e.InvalidEmailOtp = "invalid-email-otp", e.InvalidMfaOtp = "invalid-mfa-otp", e.ExpiredEmailOtp = "expired-email-otp", e.MfaSentHandle = "mfa-sent-handle", e.RecoveryCodeSentHandle = "recovery-code-sent-handle", e.InvalidRecoveryCode = "invalid-recovery-code", e.RecoveryCodeSuccess = "recovery-code-success", e.LoginThrottled = "login-throttled", e))(ho || {}), Tt = ((e) => (e.Retry = "device-retry", e))(Tt || {}), po = ((e) => (e.DeviceApproved = "device-approved", e.DeviceNeedsApproval = "device-needs-approval", e.DeviceVerificationLinkExpired = "device-verification-link-expired", e.DeviceVerificationEmailSent = "device-verification-email-sent", e))(po || {}), he = ((e) => (e.Retry = "Recency/auth-factor-retry", e.Cancel = "Recency/auth-factor-verification-cancel", e.VerifyEmailOtp = "Recency/auth-factor-verify-email-otp", e.VerifyMFACode = "Recency/verify-mfa-code", e))(he || {}), mo = ((e) => (e.PrimaryAuthFactorNeedsVerification = "Recency/auth-factor-needs-verification", e.PrimaryAuthFactorVerified = "Recency/auth-factor-verified", e.InvalidEmailOtp = "Recency/auth-factor-invalid-email-otp", e.EmailExpired = "Recency/auth-factor-verification-email-expired", e.EmailSent = "Recency/auth-factor-verification-email-sent", e.EmailNotDeliverable = "Recency/auth-factor-verification-email-not-deliverable", e))(mo || {}), ce = ((e) => (e.RetryWithNewEmail = "UpdateEmail/retry-with-new-email", e.Cancel = "UpdateEmail/new-email-verification-cancel", e.VerifyEmailOtp = "UpdateEmail/new-email-verify-otp", e))(ce || {}), go = ((e) => (e.NewAuthFactorNeedsVerification = "UpdateEmail/new-email-needs-verification", e.EmailUpdated = "UpdateEmail/email-updated", e.InvalidEmailOtp = "UpdateEmail/new-email-invalid-email-otp", e.EmailExpired = "UpdateEmail/new-email-verification-email-expired", e.EmailSent = "UpdateEmail/new-email-verification-email-sent", e.EmailNotDeliverable = "UpdateEmail/new-email-verification-email-not-deliverable", e.InvalidEmail = "UpdateEmail/new-email-invalid", e.EmailAlreadyExists = "UpdateEmail/new-email-already-exists", e))(go || {}), vo = ((e) => (e.IDTokenCreated = "Auth/id-token-created", e))(vo || {}), yo = ((e) => (e.Cancel = "Farcaster/cancel", e))(yo || {}), Eo = ((e) => (e.MFASecretGenerated = "mfa-secret-generated", e.InvalidMFAOtp = "invalid-mfa-otp", e.MFARecoveryCodes = "mfa-recovery-codes", e))(Eo || {}), He = ((e) => (e.VerifyMFACode = "verify-mfa-code", e.Cancel = "cancel-mfa-setup", e))(He || {}), wo = ((e) => (e.MFACodeRequested = "mfa-code-requested", e.InvalidMFAOtp = "invalid-mfa-otp", e.InvalidRecoveryCode = "invalid-recovery-code", e))(wo || {}), $e = ((e) => (e.VerifyMFACode = "verify-mfa-code", e.LostDevice = "lost-device", e.Cancel = "cancel-mfa-disable", e))($e || {}), _o = ((e) => (e.Harmony = "HARMONY", e))(_o || {}), br = ((e) => (e.ClosedByUser = "closed-by-user", e))(br || {}), Rr = ((e) => (e.ClosedByUser = "closed-by-user-on-received", e))(Rr || {}), Io = ((e) => (e.EnterNewPhoneNumber = "enter-new-phone-number", e.EnterOtpCode = "enter-otp-code", e.RecoveryFactorAlreadyExists = "recovery-factor-already-exists", e.MalformedPhoneNumber = "malformed-phone-number", e.InvalidOtpCode = "invalid-otp-code", e.RecoveryFactorUpdated = "recovery-factor-updated", e.RecoveryFactorDeleted = "recovery-factor-deleted", e))(Io || {}), ye = ((e) => (e.SendNewPhoneNumber = "send-new-phone-number", e.SendOtpCode = "send-otp-code", e.Cancel = "cancel", e.StartEditPhoneNumber = "start-edit-phone-number", e))(ye || {}), bo = ((e) => (e.PhoneNumber = "phone_number", e))(bo || {}), Ro = ((e) => (e.SmsOtpSent = "sms-otp-sent", e.LoginThrottled = "login-throttled", e.InvalidSmsOtp = "invalid-sms-otp", e.SmsVerified = "sms-verified", e.AccountRecovered = "account-recovered", e.UpdateEmailRequired = "update-email-required", e))(Ro || {}), Ee = ((e) => (e.Cancel = "cancel", e.VerifyOtp = "verify-otp-code", e.ResendSms = "resend-sms-otp", e.UpdateEmail = "update-email", e))(Ee || {}), Xe = ((e) => (e.Success = "nft-checkout-success", e.Failure = "nft-checkout-failure", e.Initiated = "nft-checkout-initiated", e.Disconnect = "disconnect", e))(Xe || {}), No = ((e) => (e.WalletInfoFetched = "Wallet/wallet-info-fetched", e))(No || {}), So = ((e) => (e.CloseMagicWindow = "close-magic-window", e))(So || {}), Ao = Object.create, Pt = Object.defineProperty, Oo = Object.getOwnPropertyDescriptor, To = Object.getOwnPropertyNames, Lo = Object.getPrototypeOf, $o = Object.prototype.hasOwnProperty, Mo = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), Co = (e, t) => {
|
|
439
|
-
for (var r in t) Pt(e, r, { get: t[r], enumerable: !0 });
|
|
440
|
-
}, Po = (e, t, r, n) => {
|
|
441
|
-
if (t && typeof t == "object" || typeof t == "function") for (let i of To(t)) !$o.call(e, i) && i !== r && Pt(e, i, { get: () => t[i], enumerable: !(n = Oo(t, i)) || n.enumerable });
|
|
442
|
-
return e;
|
|
443
|
-
}, ko = (e, t, r) => (r = e != null ? Ao(Lo(e)) : {}, Po(!e || !e.__esModule ? Pt(r, "default", { value: e, enumerable: !0 }) : r, e)), Do = Mo((e, t) => {
|
|
444
|
-
var r = Object.prototype.hasOwnProperty, n = "~";
|
|
445
|
-
function i() {
|
|
446
|
-
}
|
|
447
|
-
Object.create && (i.prototype = /* @__PURE__ */ Object.create(null), new i().__proto__ || (n = !1));
|
|
448
|
-
function a(m, E, p) {
|
|
449
|
-
this.fn = m, this.context = E, this.once = p || !1;
|
|
450
|
-
}
|
|
451
|
-
function h(m, E, p, S, M) {
|
|
452
|
-
if (typeof p != "function") throw new TypeError("The listener must be a function");
|
|
453
|
-
var P = new a(p, S || m, M), G = n ? n + E : E;
|
|
454
|
-
return m._events[G] ? m._events[G].fn ? m._events[G] = [m._events[G], P] : m._events[G].push(P) : (m._events[G] = P, m._eventsCount++), m;
|
|
455
|
-
}
|
|
456
|
-
function u(m, E) {
|
|
457
|
-
--m._eventsCount === 0 ? m._events = new i() : delete m._events[E];
|
|
458
|
-
}
|
|
459
|
-
function y() {
|
|
460
|
-
this._events = new i(), this._eventsCount = 0;
|
|
461
|
-
}
|
|
462
|
-
y.prototype.eventNames = function() {
|
|
463
|
-
var m = [], E, p;
|
|
464
|
-
if (this._eventsCount === 0) return m;
|
|
465
|
-
for (p in E = this._events) r.call(E, p) && m.push(n ? p.slice(1) : p);
|
|
466
|
-
return Object.getOwnPropertySymbols ? m.concat(Object.getOwnPropertySymbols(E)) : m;
|
|
467
|
-
}, y.prototype.listeners = function(m) {
|
|
468
|
-
var E = n ? n + m : m, p = this._events[E];
|
|
469
|
-
if (!p) return [];
|
|
470
|
-
if (p.fn) return [p.fn];
|
|
471
|
-
for (var S = 0, M = p.length, P = new Array(M); S < M; S++) P[S] = p[S].fn;
|
|
472
|
-
return P;
|
|
473
|
-
}, y.prototype.listenerCount = function(m) {
|
|
474
|
-
var E = n ? n + m : m, p = this._events[E];
|
|
475
|
-
return p ? p.fn ? 1 : p.length : 0;
|
|
476
|
-
}, y.prototype.emit = function(m, E, p, S, M, P) {
|
|
477
|
-
var G = n ? n + m : m;
|
|
478
|
-
if (!this._events[G]) return !1;
|
|
479
|
-
var O = this._events[G], K = arguments.length, q, B;
|
|
480
|
-
if (O.fn) {
|
|
481
|
-
switch (O.once && this.removeListener(m, O.fn, void 0, !0), K) {
|
|
482
|
-
case 1:
|
|
483
|
-
return O.fn.call(O.context), !0;
|
|
484
|
-
case 2:
|
|
485
|
-
return O.fn.call(O.context, E), !0;
|
|
486
|
-
case 3:
|
|
487
|
-
return O.fn.call(O.context, E, p), !0;
|
|
488
|
-
case 4:
|
|
489
|
-
return O.fn.call(O.context, E, p, S), !0;
|
|
490
|
-
case 5:
|
|
491
|
-
return O.fn.call(O.context, E, p, S, M), !0;
|
|
492
|
-
case 6:
|
|
493
|
-
return O.fn.call(O.context, E, p, S, M, P), !0;
|
|
494
|
-
}
|
|
495
|
-
for (B = 1, q = new Array(K - 1); B < K; B++) q[B - 1] = arguments[B];
|
|
496
|
-
O.fn.apply(O.context, q);
|
|
497
|
-
} else {
|
|
498
|
-
var ee = O.length, N;
|
|
499
|
-
for (B = 0; B < ee; B++) switch (O[B].once && this.removeListener(m, O[B].fn, void 0, !0), K) {
|
|
500
|
-
case 1:
|
|
501
|
-
O[B].fn.call(O[B].context);
|
|
502
|
-
break;
|
|
503
|
-
case 2:
|
|
504
|
-
O[B].fn.call(O[B].context, E);
|
|
505
|
-
break;
|
|
506
|
-
case 3:
|
|
507
|
-
O[B].fn.call(O[B].context, E, p);
|
|
508
|
-
break;
|
|
509
|
-
case 4:
|
|
510
|
-
O[B].fn.call(O[B].context, E, p, S);
|
|
511
|
-
break;
|
|
512
|
-
default:
|
|
513
|
-
if (!q) for (N = 1, q = new Array(K - 1); N < K; N++) q[N - 1] = arguments[N];
|
|
514
|
-
O[B].fn.apply(O[B].context, q);
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
return !0;
|
|
518
|
-
}, y.prototype.on = function(m, E, p) {
|
|
519
|
-
return h(this, m, E, p, !1);
|
|
520
|
-
}, y.prototype.once = function(m, E, p) {
|
|
521
|
-
return h(this, m, E, p, !0);
|
|
522
|
-
}, y.prototype.removeListener = function(m, E, p, S) {
|
|
523
|
-
var M = n ? n + m : m;
|
|
524
|
-
if (!this._events[M]) return this;
|
|
525
|
-
if (!E) return u(this, M), this;
|
|
526
|
-
var P = this._events[M];
|
|
527
|
-
if (P.fn) P.fn === E && (!S || P.once) && (!p || P.context === p) && u(this, M);
|
|
528
|
-
else {
|
|
529
|
-
for (var G = 0, O = [], K = P.length; G < K; G++) (P[G].fn !== E || S && !P[G].once || p && P[G].context !== p) && O.push(P[G]);
|
|
530
|
-
O.length ? this._events[M] = O.length === 1 ? O[0] : O : u(this, M);
|
|
531
|
-
}
|
|
532
|
-
return this;
|
|
533
|
-
}, y.prototype.removeAllListeners = function(m) {
|
|
534
|
-
var E;
|
|
535
|
-
return m ? (E = n ? n + m : m, this._events[E] && u(this, E)) : (this._events = new i(), this._eventsCount = 0), this;
|
|
536
|
-
}, y.prototype.off = y.prototype.removeListener, y.prototype.addListener = y.prototype.on, y.prefixed = n, y.EventEmitter = y, typeof t < "u" && (t.exports = y);
|
|
537
|
-
});
|
|
538
|
-
function xo(e) {
|
|
539
|
-
let t = { exports: {} };
|
|
540
|
-
return e(t, t.exports), t.exports;
|
|
541
|
-
}
|
|
542
|
-
var Uo = Number.MAX_SAFE_INTEGER || 9007199254740991, kt = { MAX_LENGTH: 256, MAX_SAFE_INTEGER: Uo, MAX_SAFE_COMPONENT_LENGTH: 16 }, jo = typeof process == "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...e) => console.error("SEMVER", ...e) : () => {
|
|
543
|
-
}, z = jo, Ze = xo(function(e, t) {
|
|
544
|
-
let { MAX_SAFE_COMPONENT_LENGTH: r } = kt, n = (t = e.exports = {}).re = [], i = t.src = [], a = t.t = {}, h = 0, u = (y, m, E) => {
|
|
545
|
-
let p = h++;
|
|
546
|
-
z(p, m), a[y] = p, i[p] = m, n[p] = new RegExp(m, E ? "g" : void 0);
|
|
547
|
-
};
|
|
548
|
-
u("NUMERICIDENTIFIER", "0|[1-9]\\d*"), u("NUMERICIDENTIFIERLOOSE", "[0-9]+"), u("NONNUMERICIDENTIFIER", "\\d*[a-zA-Z-][a-zA-Z0-9-]*"), u("MAINVERSION", `(${i[a.NUMERICIDENTIFIER]})\\.(${i[a.NUMERICIDENTIFIER]})\\.(${i[a.NUMERICIDENTIFIER]})`), u("MAINVERSIONLOOSE", `(${i[a.NUMERICIDENTIFIERLOOSE]})\\.(${i[a.NUMERICIDENTIFIERLOOSE]})\\.(${i[a.NUMERICIDENTIFIERLOOSE]})`), u("PRERELEASEIDENTIFIER", `(?:${i[a.NUMERICIDENTIFIER]}|${i[a.NONNUMERICIDENTIFIER]})`), u("PRERELEASEIDENTIFIERLOOSE", `(?:${i[a.NUMERICIDENTIFIERLOOSE]}|${i[a.NONNUMERICIDENTIFIER]})`), u("PRERELEASE", `(?:-(${i[a.PRERELEASEIDENTIFIER]}(?:\\.${i[a.PRERELEASEIDENTIFIER]})*))`), u("PRERELEASELOOSE", `(?:-?(${i[a.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${i[a.PRERELEASEIDENTIFIERLOOSE]})*))`), u("BUILDIDENTIFIER", "[0-9A-Za-z-]+"), u("BUILD", `(?:\\+(${i[a.BUILDIDENTIFIER]}(?:\\.${i[a.BUILDIDENTIFIER]})*))`), u("FULLPLAIN", `v?${i[a.MAINVERSION]}${i[a.PRERELEASE]}?${i[a.BUILD]}?`), u("FULL", `^${i[a.FULLPLAIN]}$`), u("LOOSEPLAIN", `[v=\\s]*${i[a.MAINVERSIONLOOSE]}${i[a.PRERELEASELOOSE]}?${i[a.BUILD]}?`), u("LOOSE", `^${i[a.LOOSEPLAIN]}$`), u("GTLT", "((?:<|>)?=?)"), u("XRANGEIDENTIFIERLOOSE", `${i[a.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`), u("XRANGEIDENTIFIER", `${i[a.NUMERICIDENTIFIER]}|x|X|\\*`), u("XRANGEPLAIN", `[v=\\s]*(${i[a.XRANGEIDENTIFIER]})(?:\\.(${i[a.XRANGEIDENTIFIER]})(?:\\.(${i[a.XRANGEIDENTIFIER]})(?:${i[a.PRERELEASE]})?${i[a.BUILD]}?)?)?`), u("XRANGEPLAINLOOSE", `[v=\\s]*(${i[a.XRANGEIDENTIFIERLOOSE]})(?:\\.(${i[a.XRANGEIDENTIFIERLOOSE]})(?:\\.(${i[a.XRANGEIDENTIFIERLOOSE]})(?:${i[a.PRERELEASELOOSE]})?${i[a.BUILD]}?)?)?`), u("XRANGE", `^${i[a.GTLT]}\\s*${i[a.XRANGEPLAIN]}$`), u("XRANGELOOSE", `^${i[a.GTLT]}\\s*${i[a.XRANGEPLAINLOOSE]}$`), u("COERCE", `(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?(?:$|[^\\d])`), u("COERCERTL", i[a.COERCE], !0), u("LONETILDE", "(?:~>?)"), u("TILDETRIM", `(\\s*)${i[a.LONETILDE]}\\s+`, !0), t.tildeTrimReplace = "$1~", u("TILDE", `^${i[a.LONETILDE]}${i[a.XRANGEPLAIN]}$`), u("TILDELOOSE", `^${i[a.LONETILDE]}${i[a.XRANGEPLAINLOOSE]}$`), u("LONECARET", "(?:\\^)"), u("CARETTRIM", `(\\s*)${i[a.LONECARET]}\\s+`, !0), t.caretTrimReplace = "$1^", u("CARET", `^${i[a.LONECARET]}${i[a.XRANGEPLAIN]}$`), u("CARETLOOSE", `^${i[a.LONECARET]}${i[a.XRANGEPLAINLOOSE]}$`), u("COMPARATORLOOSE", `^${i[a.GTLT]}\\s*(${i[a.LOOSEPLAIN]})$|^$`), u("COMPARATOR", `^${i[a.GTLT]}\\s*(${i[a.FULLPLAIN]})$|^$`), u("COMPARATORTRIM", `(\\s*)${i[a.GTLT]}\\s*(${i[a.LOOSEPLAIN]}|${i[a.XRANGEPLAIN]})`, !0), t.comparatorTrimReplace = "$1$2$3", u("HYPHENRANGE", `^\\s*(${i[a.XRANGEPLAIN]})\\s+-\\s+(${i[a.XRANGEPLAIN]})\\s*$`), u("HYPHENRANGELOOSE", `^\\s*(${i[a.XRANGEPLAINLOOSE]})\\s+-\\s+(${i[a.XRANGEPLAINLOOSE]})\\s*$`), u("STAR", "(<|>)?=?\\s*\\*"), u("GTE0", "^\\s*>=\\s*0.0.0\\s*$"), u("GTE0PRE", "^\\s*>=\\s*0.0.0-0\\s*$");
|
|
549
|
-
}), sr = /^[0-9]+$/, Fo = (e, t) => {
|
|
550
|
-
let r = sr.test(e), n = sr.test(t);
|
|
551
|
-
return r && n && (e = +e, t = +t), e === t ? 0 : r && !n ? -1 : n && !r ? 1 : e < t ? -1 : 1;
|
|
552
|
-
}, Go = { compareIdentifiers: Fo }, { MAX_LENGTH: cr, MAX_SAFE_INTEGER: nt } = kt, { re: lr, t: ur } = Ze, { compareIdentifiers: Be } = Go, Se = class pe {
|
|
553
|
-
constructor(t, r) {
|
|
554
|
-
if (r && typeof r == "object" || (r = { loose: !!r, includePrerelease: !1 }), t instanceof pe) {
|
|
555
|
-
if (t.loose === !!r.loose && t.includePrerelease === !!r.includePrerelease) return t;
|
|
556
|
-
t = t.version;
|
|
557
|
-
} else if (typeof t != "string") throw new TypeError(`Invalid Version: ${t}`);
|
|
558
|
-
if (t.length > cr) throw new TypeError(`version is longer than ${cr} characters`);
|
|
559
|
-
z("SemVer", t, r), this.options = r, this.loose = !!r.loose, this.includePrerelease = !!r.includePrerelease;
|
|
560
|
-
let n = t.trim().match(r.loose ? lr[ur.LOOSE] : lr[ur.FULL]);
|
|
561
|
-
if (!n) throw new TypeError(`Invalid Version: ${t}`);
|
|
562
|
-
if (this.raw = t, this.major = +n[1], this.minor = +n[2], this.patch = +n[3], this.major > nt || this.major < 0) throw new TypeError("Invalid major version");
|
|
563
|
-
if (this.minor > nt || this.minor < 0) throw new TypeError("Invalid minor version");
|
|
564
|
-
if (this.patch > nt || this.patch < 0) throw new TypeError("Invalid patch version");
|
|
565
|
-
n[4] ? this.prerelease = n[4].split(".").map((i) => {
|
|
566
|
-
if (/^[0-9]+$/.test(i)) {
|
|
567
|
-
let a = +i;
|
|
568
|
-
if (a >= 0 && a < nt) return a;
|
|
569
|
-
}
|
|
570
|
-
return i;
|
|
571
|
-
}) : this.prerelease = [], this.build = n[5] ? n[5].split(".") : [], this.format();
|
|
572
|
-
}
|
|
573
|
-
format() {
|
|
574
|
-
return this.version = `${this.major}.${this.minor}.${this.patch}`, this.prerelease.length && (this.version += `-${this.prerelease.join(".")}`), this.version;
|
|
575
|
-
}
|
|
576
|
-
toString() {
|
|
577
|
-
return this.version;
|
|
578
|
-
}
|
|
579
|
-
compare(t) {
|
|
580
|
-
if (z("SemVer.compare", this.version, this.options, t), !(t instanceof pe)) {
|
|
581
|
-
if (typeof t == "string" && t === this.version) return 0;
|
|
582
|
-
t = new pe(t, this.options);
|
|
583
|
-
}
|
|
584
|
-
return t.version === this.version ? 0 : this.compareMain(t) || this.comparePre(t);
|
|
585
|
-
}
|
|
586
|
-
compareMain(t) {
|
|
587
|
-
return t instanceof pe || (t = new pe(t, this.options)), Be(this.major, t.major) || Be(this.minor, t.minor) || Be(this.patch, t.patch);
|
|
588
|
-
}
|
|
589
|
-
comparePre(t) {
|
|
590
|
-
if (t instanceof pe || (t = new pe(t, this.options)), this.prerelease.length && !t.prerelease.length) return -1;
|
|
591
|
-
if (!this.prerelease.length && t.prerelease.length) return 1;
|
|
592
|
-
if (!this.prerelease.length && !t.prerelease.length) return 0;
|
|
593
|
-
let r = 0;
|
|
594
|
-
do {
|
|
595
|
-
let n = this.prerelease[r], i = t.prerelease[r];
|
|
596
|
-
if (z("prerelease compare", r, n, i), n === void 0 && i === void 0) return 0;
|
|
597
|
-
if (i === void 0) return 1;
|
|
598
|
-
if (n === void 0) return -1;
|
|
599
|
-
if (n !== i) return Be(n, i);
|
|
600
|
-
} while (++r);
|
|
601
|
-
}
|
|
602
|
-
compareBuild(t) {
|
|
603
|
-
t instanceof pe || (t = new pe(t, this.options));
|
|
604
|
-
let r = 0;
|
|
605
|
-
do {
|
|
606
|
-
let n = this.build[r], i = t.build[r];
|
|
607
|
-
if (z("prerelease compare", r, n, i), n === void 0 && i === void 0) return 0;
|
|
608
|
-
if (i === void 0) return 1;
|
|
609
|
-
if (n === void 0) return -1;
|
|
610
|
-
if (n !== i) return Be(n, i);
|
|
611
|
-
} while (++r);
|
|
612
|
-
}
|
|
613
|
-
inc(t, r) {
|
|
614
|
-
switch (t) {
|
|
615
|
-
case "premajor":
|
|
616
|
-
this.prerelease.length = 0, this.patch = 0, this.minor = 0, this.major++, this.inc("pre", r);
|
|
617
|
-
break;
|
|
618
|
-
case "preminor":
|
|
619
|
-
this.prerelease.length = 0, this.patch = 0, this.minor++, this.inc("pre", r);
|
|
620
|
-
break;
|
|
621
|
-
case "prepatch":
|
|
622
|
-
this.prerelease.length = 0, this.inc("patch", r), this.inc("pre", r);
|
|
623
|
-
break;
|
|
624
|
-
case "prerelease":
|
|
625
|
-
this.prerelease.length === 0 && this.inc("patch", r), this.inc("pre", r);
|
|
626
|
-
break;
|
|
627
|
-
case "major":
|
|
628
|
-
this.minor === 0 && this.patch === 0 && this.prerelease.length !== 0 || this.major++, this.minor = 0, this.patch = 0, this.prerelease = [];
|
|
629
|
-
break;
|
|
630
|
-
case "minor":
|
|
631
|
-
this.patch === 0 && this.prerelease.length !== 0 || this.minor++, this.patch = 0, this.prerelease = [];
|
|
632
|
-
break;
|
|
633
|
-
case "patch":
|
|
634
|
-
this.prerelease.length === 0 && this.patch++, this.prerelease = [];
|
|
635
|
-
break;
|
|
636
|
-
case "pre":
|
|
637
|
-
if (this.prerelease.length === 0) this.prerelease = [0];
|
|
638
|
-
else {
|
|
639
|
-
let n = this.prerelease.length;
|
|
640
|
-
for (; --n >= 0; ) typeof this.prerelease[n] == "number" && (this.prerelease[n]++, n = -2);
|
|
641
|
-
n === -1 && this.prerelease.push(0);
|
|
642
|
-
}
|
|
643
|
-
r && (this.prerelease[0] === r ? isNaN(this.prerelease[1]) && (this.prerelease = [r, 0]) : this.prerelease = [r, 0]);
|
|
644
|
-
break;
|
|
645
|
-
default:
|
|
646
|
-
throw new Error(`invalid increment argument: ${t}`);
|
|
647
|
-
}
|
|
648
|
-
return this.format(), this.raw = this.version, this;
|
|
649
|
-
}
|
|
650
|
-
}, Wo = (e, t, r) => new Se(e, r).compare(new Se(t, r)), je = Wo, qo = (e, t, r) => je(e, t, r) === 0, Bo = qo, Vo = (e, t, r) => je(e, t, r) !== 0, zo = Vo, Ho = (e, t, r) => je(e, t, r) > 0, Xo = Ho, Ko = (e, t, r) => je(e, t, r) >= 0, Yo = Ko, Jo = (e, t, r) => je(e, t, r) < 0, Qo = Jo, Zo = (e, t, r) => je(e, t, r) <= 0, ei = Zo, ti = (e, t, r, n) => {
|
|
651
|
-
switch (t) {
|
|
652
|
-
case "===":
|
|
653
|
-
return typeof e == "object" && (e = e.version), typeof r == "object" && (r = r.version), e === r;
|
|
654
|
-
case "!==":
|
|
655
|
-
return typeof e == "object" && (e = e.version), typeof r == "object" && (r = r.version), e !== r;
|
|
656
|
-
case "":
|
|
657
|
-
case "=":
|
|
658
|
-
case "==":
|
|
659
|
-
return Bo(e, r, n);
|
|
660
|
-
case "!=":
|
|
661
|
-
return zo(e, r, n);
|
|
662
|
-
case ">":
|
|
663
|
-
return Xo(e, r, n);
|
|
664
|
-
case ">=":
|
|
665
|
-
return Yo(e, r, n);
|
|
666
|
-
case "<":
|
|
667
|
-
return Qo(e, r, n);
|
|
668
|
-
case "<=":
|
|
669
|
-
return ei(e, r, n);
|
|
670
|
-
default:
|
|
671
|
-
throw new TypeError(`Invalid operator: ${t}`);
|
|
672
|
-
}
|
|
673
|
-
}, At = ti, Ve = Symbol("SemVer ANY"), Lt = class $t {
|
|
674
|
-
static get ANY() {
|
|
675
|
-
return Ve;
|
|
676
|
-
}
|
|
677
|
-
constructor(t, r) {
|
|
678
|
-
if (r && typeof r == "object" || (r = { loose: !!r, includePrerelease: !1 }), t instanceof $t) {
|
|
679
|
-
if (t.loose === !!r.loose) return t;
|
|
680
|
-
t = t.value;
|
|
681
|
-
}
|
|
682
|
-
z("comparator", t, r), this.options = r, this.loose = !!r.loose, this.parse(t), this.semver === Ve ? this.value = "" : this.value = this.operator + this.semver.version, z("comp", this);
|
|
683
|
-
}
|
|
684
|
-
parse(t) {
|
|
685
|
-
let r = this.options.loose ? dr[fr.COMPARATORLOOSE] : dr[fr.COMPARATOR], n = t.match(r);
|
|
686
|
-
if (!n) throw new TypeError(`Invalid comparator: ${t}`);
|
|
687
|
-
this.operator = n[1] !== void 0 ? n[1] : "", this.operator === "=" && (this.operator = ""), n[2] ? this.semver = new Se(n[2], this.options.loose) : this.semver = Ve;
|
|
688
|
-
}
|
|
689
|
-
toString() {
|
|
690
|
-
return this.value;
|
|
691
|
-
}
|
|
692
|
-
test(t) {
|
|
693
|
-
if (z("Comparator.test", t, this.options.loose), this.semver === Ve || t === Ve) return !0;
|
|
694
|
-
if (typeof t == "string") try {
|
|
695
|
-
t = new Se(t, this.options);
|
|
696
|
-
} catch {
|
|
697
|
-
return !1;
|
|
698
|
-
}
|
|
699
|
-
return At(t, this.operator, this.semver, this.options);
|
|
700
|
-
}
|
|
701
|
-
intersects(t, r) {
|
|
702
|
-
if (!(t instanceof $t)) throw new TypeError("a Comparator is required");
|
|
703
|
-
if (r && typeof r == "object" || (r = { loose: !!r, includePrerelease: !1 }), this.operator === "") return this.value === "" || new Mt(t.value, r).test(this.value);
|
|
704
|
-
if (t.operator === "") return t.value === "" || new Mt(this.value, r).test(t.semver);
|
|
705
|
-
let n = !(this.operator !== ">=" && this.operator !== ">" || t.operator !== ">=" && t.operator !== ">"), i = !(this.operator !== "<=" && this.operator !== "<" || t.operator !== "<=" && t.operator !== "<"), a = this.semver.version === t.semver.version, h = !(this.operator !== ">=" && this.operator !== "<=" || t.operator !== ">=" && t.operator !== "<="), u = At(this.semver, "<", t.semver, r) && (this.operator === ">=" || this.operator === ">") && (t.operator === "<=" || t.operator === "<"), y = At(this.semver, ">", t.semver, r) && (this.operator === "<=" || this.operator === "<") && (t.operator === ">=" || t.operator === ">");
|
|
706
|
-
return n || i || a && h || u || y;
|
|
707
|
-
}
|
|
708
|
-
}, { re: dr, t: fr } = Ze, Mt = class lt {
|
|
709
|
-
constructor(t, r) {
|
|
710
|
-
if (r && typeof r == "object" || (r = { loose: !!r, includePrerelease: !1 }), t instanceof lt) return t.loose === !!r.loose && t.includePrerelease === !!r.includePrerelease ? t : new lt(t.raw, r);
|
|
711
|
-
if (t instanceof Lt) return this.raw = t.value, this.set = [[t]], this.format(), this;
|
|
712
|
-
if (this.options = r, this.loose = !!r.loose, this.includePrerelease = !!r.includePrerelease, this.raw = t, this.set = t.split(/\s*\|\|\s*/).map((n) => this.parseRange(n.trim())).filter((n) => n.length), !this.set.length) throw new TypeError(`Invalid SemVer Range: ${t}`);
|
|
713
|
-
this.format();
|
|
714
|
-
}
|
|
715
|
-
format() {
|
|
716
|
-
return this.range = this.set.map((t) => t.join(" ").trim()).join("||").trim(), this.range;
|
|
717
|
-
}
|
|
718
|
-
toString() {
|
|
719
|
-
return this.range;
|
|
720
|
-
}
|
|
721
|
-
parseRange(t) {
|
|
722
|
-
let { loose: r } = this.options;
|
|
723
|
-
t = t.trim();
|
|
724
|
-
let n = r ? ne[te.HYPHENRANGELOOSE] : ne[te.HYPHENRANGE];
|
|
725
|
-
t = t.replace(n, pi(this.options.includePrerelease)), z("hyphen replace", t), t = t.replace(ne[te.COMPARATORTRIM], ri), z("comparator trim", t, ne[te.COMPARATORTRIM]), t = (t = (t = t.replace(ne[te.TILDETRIM], ni)).replace(ne[te.CARETTRIM], oi)).split(/\s+/).join(" ");
|
|
726
|
-
let i = r ? ne[te.COMPARATORLOOSE] : ne[te.COMPARATOR];
|
|
727
|
-
return t.split(" ").map((a) => ii(a, this.options)).join(" ").split(/\s+/).map((a) => hi(a, this.options)).filter(this.options.loose ? (a) => !!a.match(i) : () => !0).map((a) => new Lt(a, this.options));
|
|
728
|
-
}
|
|
729
|
-
intersects(t, r) {
|
|
730
|
-
if (!(t instanceof lt)) throw new TypeError("a Range is required");
|
|
731
|
-
return this.set.some((n) => hr(n, r) && t.set.some((i) => hr(i, r) && n.every((a) => i.every((h) => a.intersects(h, r)))));
|
|
732
|
-
}
|
|
733
|
-
test(t) {
|
|
734
|
-
if (!t) return !1;
|
|
735
|
-
if (typeof t == "string") try {
|
|
736
|
-
t = new Se(t, this.options);
|
|
737
|
-
} catch {
|
|
738
|
-
return !1;
|
|
739
|
-
}
|
|
740
|
-
for (let r = 0; r < this.set.length; r++) if (mi(this.set[r], t, this.options)) return !0;
|
|
741
|
-
return !1;
|
|
742
|
-
}
|
|
743
|
-
}, { re: ne, t: te, comparatorTrimReplace: ri, tildeTrimReplace: ni, caretTrimReplace: oi } = Ze, hr = (e, t) => {
|
|
744
|
-
let r = !0, n = e.slice(), i = n.pop();
|
|
745
|
-
for (; r && n.length; ) r = n.every((a) => i.intersects(a, t)), i = n.pop();
|
|
746
|
-
return r;
|
|
747
|
-
}, ii = (e, t) => (z("comp", e, t), e = ci(e, t), z("caret", e), e = ai(e, t), z("tildes", e), e = ui(e, t), z("xrange", e), e = fi(e, t), z("stars", e), e), ie = (e) => !e || e.toLowerCase() === "x" || e === "*", ai = (e, t) => e.trim().split(/\s+/).map((r) => si(r, t)).join(" "), si = (e, t) => {
|
|
748
|
-
let r = t.loose ? ne[te.TILDELOOSE] : ne[te.TILDE];
|
|
749
|
-
return e.replace(r, (n, i, a, h, u) => {
|
|
750
|
-
let y;
|
|
751
|
-
return z("tilde", e, n, i, a, h, u), ie(i) ? y = "" : ie(a) ? y = `>=${i}.0.0 <${+i + 1}.0.0-0` : ie(h) ? y = `>=${i}.${a}.0 <${i}.${+a + 1}.0-0` : u ? (z("replaceTilde pr", u), y = `>=${i}.${a}.${h}-${u} <${i}.${+a + 1}.0-0`) : y = `>=${i}.${a}.${h} <${i}.${+a + 1}.0-0`, z("tilde return", y), y;
|
|
752
|
-
});
|
|
753
|
-
}, ci = (e, t) => e.trim().split(/\s+/).map((r) => li(r, t)).join(" "), li = (e, t) => {
|
|
754
|
-
z("caret", e, t);
|
|
755
|
-
let r = t.loose ? ne[te.CARETLOOSE] : ne[te.CARET], n = t.includePrerelease ? "-0" : "";
|
|
756
|
-
return e.replace(r, (i, a, h, u, y) => {
|
|
757
|
-
let m;
|
|
758
|
-
return z("caret", e, i, a, h, u, y), ie(a) ? m = "" : ie(h) ? m = `>=${a}.0.0${n} <${+a + 1}.0.0-0` : ie(u) ? m = a === "0" ? `>=${a}.${h}.0${n} <${a}.${+h + 1}.0-0` : `>=${a}.${h}.0${n} <${+a + 1}.0.0-0` : y ? (z("replaceCaret pr", y), m = a === "0" ? h === "0" ? `>=${a}.${h}.${u}-${y} <${a}.${h}.${+u + 1}-0` : `>=${a}.${h}.${u}-${y} <${a}.${+h + 1}.0-0` : `>=${a}.${h}.${u}-${y} <${+a + 1}.0.0-0`) : (z("no pr"), m = a === "0" ? h === "0" ? `>=${a}.${h}.${u}${n} <${a}.${h}.${+u + 1}-0` : `>=${a}.${h}.${u}${n} <${a}.${+h + 1}.0-0` : `>=${a}.${h}.${u} <${+a + 1}.0.0-0`), z("caret return", m), m;
|
|
759
|
-
});
|
|
760
|
-
}, ui = (e, t) => (z("replaceXRanges", e, t), e.split(/\s+/).map((r) => di(r, t)).join(" ")), di = (e, t) => {
|
|
761
|
-
e = e.trim();
|
|
762
|
-
let r = t.loose ? ne[te.XRANGELOOSE] : ne[te.XRANGE];
|
|
763
|
-
return e.replace(r, (n, i, a, h, u, y) => {
|
|
764
|
-
z("xRange", e, n, i, a, h, u, y);
|
|
765
|
-
let m = ie(a), E = m || ie(h), p = E || ie(u), S = p;
|
|
766
|
-
return i === "=" && S && (i = ""), y = t.includePrerelease ? "-0" : "", m ? n = i === ">" || i === "<" ? "<0.0.0-0" : "*" : i && S ? (E && (h = 0), u = 0, i === ">" ? (i = ">=", E ? (a = +a + 1, h = 0, u = 0) : (h = +h + 1, u = 0)) : i === "<=" && (i = "<", E ? a = +a + 1 : h = +h + 1), i === "<" && (y = "-0"), n = `${i + a}.${h}.${u}${y}`) : E ? n = `>=${a}.0.0${y} <${+a + 1}.0.0-0` : p && (n = `>=${a}.${h}.0${y} <${a}.${+h + 1}.0-0`), z("xRange return", n), n;
|
|
767
|
-
});
|
|
768
|
-
}, fi = (e, t) => (z("replaceStars", e, t), e.trim().replace(ne[te.STAR], "")), hi = (e, t) => (z("replaceGTE0", e, t), e.trim().replace(ne[t.includePrerelease ? te.GTE0PRE : te.GTE0], "")), pi = (e) => (t, r, n, i, a, h, u, y, m, E, p, S, M) => `${r = ie(n) ? "" : ie(i) ? `>=${n}.0.0${e ? "-0" : ""}` : ie(a) ? `>=${n}.${i}.0${e ? "-0" : ""}` : h ? `>=${r}` : `>=${r}${e ? "-0" : ""}`} ${y = ie(m) ? "" : ie(E) ? `<${+m + 1}.0.0-0` : ie(p) ? `<${m}.${+E + 1}.0-0` : S ? `<=${m}.${E}.${p}-${S}` : e ? `<${m}.${E}.${+p + 1}-0` : `<=${y}`}`.trim(), mi = (e, t, r) => {
|
|
769
|
-
for (let n = 0; n < e.length; n++) if (!e[n].test(t)) return !1;
|
|
770
|
-
if (t.prerelease.length && !r.includePrerelease) {
|
|
771
|
-
for (let n = 0; n < e.length; n++) if (z(e[n].semver), e[n].semver !== Lt.ANY && e[n].semver.prerelease.length > 0) {
|
|
772
|
-
let i = e[n].semver;
|
|
773
|
-
if (i.major === t.major && i.minor === t.minor && i.patch === t.patch) return !0;
|
|
774
|
-
}
|
|
775
|
-
return !1;
|
|
776
|
-
}
|
|
777
|
-
return !0;
|
|
778
|
-
}, gi = (e, t, r) => {
|
|
779
|
-
try {
|
|
780
|
-
t = new Mt(t, r);
|
|
781
|
-
} catch {
|
|
782
|
-
return !1;
|
|
783
|
-
}
|
|
784
|
-
return t.test(e);
|
|
785
|
-
}, { MAX_LENGTH: vi } = kt, { re: pr, t: mr } = Ze, yi = (e, t) => {
|
|
786
|
-
if (t && typeof t == "object" || (t = { loose: !!t, includePrerelease: !1 }), e instanceof Se) return e;
|
|
787
|
-
if (typeof e != "string" || e.length > vi || !(t.loose ? pr[mr.LOOSE] : pr[mr.FULL]).test(e)) return null;
|
|
788
|
-
try {
|
|
789
|
-
return new Se(e, t);
|
|
790
|
-
} catch {
|
|
791
|
-
return null;
|
|
792
|
-
}
|
|
793
|
-
}, Ei = yi, { re: ot, t: it } = Ze, wi = (e, t) => {
|
|
794
|
-
if (e instanceof Se) return e;
|
|
795
|
-
if (typeof e == "number" && (e = String(e)), typeof e != "string") return null;
|
|
796
|
-
let r = null;
|
|
797
|
-
if ((t = t || {}).rtl) {
|
|
798
|
-
let n;
|
|
799
|
-
for (; (n = ot[it.COERCERTL].exec(e)) && (!r || r.index + r[0].length !== e.length); ) r && n.index + n[0].length === r.index + r[0].length || (r = n), ot[it.COERCERTL].lastIndex = n.index + n[1].length + n[2].length;
|
|
800
|
-
ot[it.COERCERTL].lastIndex = -1;
|
|
801
|
-
} else r = e.match(ot[it.COERCE]);
|
|
802
|
-
return r === null ? null : Ei(`${r[2]}.${r[3] || "0"}.${r[4] || "0"}`, t);
|
|
803
|
-
};
|
|
804
|
-
function _i(e) {
|
|
805
|
-
return String.fromCharCode(parseInt(e.slice(1), 16));
|
|
806
|
-
}
|
|
807
|
-
function Ii(e) {
|
|
808
|
-
return `%${`00${e.charCodeAt(0).toString(16)}`.slice(-2)}`;
|
|
809
|
-
}
|
|
810
|
-
function bi(e) {
|
|
811
|
-
return btoa(encodeURIComponent(e).replace(/%[0-9A-F]{2}/g, _i));
|
|
812
|
-
}
|
|
813
|
-
function Ri(e) {
|
|
814
|
-
return decodeURIComponent(Array.from(atob(e), Ii).join(""));
|
|
815
|
-
}
|
|
816
|
-
function Nr(e) {
|
|
817
|
-
return bi(JSON.stringify(e));
|
|
818
|
-
}
|
|
819
|
-
function Ni(e) {
|
|
820
|
-
return JSON.parse(Ri(e));
|
|
821
|
-
}
|
|
822
|
-
function Ke(e) {
|
|
823
|
-
return typeof e > "u";
|
|
824
|
-
}
|
|
825
|
-
function Si(e) {
|
|
826
|
-
return e === null;
|
|
827
|
-
}
|
|
828
|
-
function Sr(e) {
|
|
829
|
-
return Si(e) || Ke(e);
|
|
830
|
-
}
|
|
831
|
-
function Ai(e) {
|
|
832
|
-
return Sr(e) ? !1 : !Ke(e.jsonrpc) && !Ke(e.id) && (!Ke(e.result) || !Ke(e.error));
|
|
833
|
-
}
|
|
834
|
-
function Oi(e) {
|
|
835
|
-
return Sr(e) ? !1 : typeof e == "number" && Object.values(gt).includes(e);
|
|
836
|
-
}
|
|
837
|
-
function ft(e) {
|
|
838
|
-
if (!e) return !0;
|
|
839
|
-
for (let t in e) if (Object.hasOwnProperty.call(e, t)) return !1;
|
|
840
|
-
return !0;
|
|
841
|
-
}
|
|
842
|
-
var X = {};
|
|
843
|
-
function Ti(e, t) {
|
|
844
|
-
return Object.assign(X, t), e;
|
|
845
|
-
}
|
|
846
|
-
var Li = { "magic-sdk": "magic-sdk", "@magic-sdk/react-native": "magic-sdk-rn", "@magic-sdk/react-native-bare": "magic-sdk-rn-bare", "@magic-sdk/react-native-expo": "magic-sdk-rn-expo" }, Fe = class Ar extends Error {
|
|
847
|
-
constructor(t, r) {
|
|
848
|
-
super(`Magic SDK Error: [${t}] ${r}`), this.code = t, this.rawMessage = r, Object.setPrototypeOf(this, Ar.prototype);
|
|
849
|
-
}
|
|
850
|
-
__proto__ = Error;
|
|
851
|
-
}, Ct = class Or extends Error {
|
|
852
|
-
__proto__ = Error;
|
|
853
|
-
code;
|
|
854
|
-
rawMessage;
|
|
855
|
-
data;
|
|
856
|
-
constructor(t) {
|
|
857
|
-
super();
|
|
858
|
-
let r = Number(t?.code);
|
|
859
|
-
this.rawMessage = t?.message || "Internal error", this.code = Oi(r) ? r : gt.InternalError, this.message = `Magic RPC Error: [${this.code}] ${this.rawMessage}`, this.data = t?.data || void 0, Object.setPrototypeOf(this, Or.prototype);
|
|
860
|
-
}
|
|
861
|
-
}, et = class {
|
|
862
|
-
constructor(e, t) {
|
|
863
|
-
this.code = e, this.rawMessage = t, this.message = `Magic SDK Warning: [${e}] ${t}`;
|
|
864
|
-
}
|
|
865
|
-
message;
|
|
866
|
-
log() {
|
|
867
|
-
console.warn(this.message);
|
|
868
|
-
}
|
|
869
|
-
}, $i = class Tr extends Error {
|
|
870
|
-
constructor(t, r, n, i) {
|
|
871
|
-
super(`Magic Extension Error (${t.name}): [${r}] ${n}`), this.code = r, this.rawMessage = n, this.data = i, Object.setPrototypeOf(this, Tr.prototype);
|
|
872
|
-
}
|
|
873
|
-
__proto__ = Error;
|
|
874
|
-
}, gr = class {
|
|
875
|
-
constructor(e, t, r) {
|
|
876
|
-
this.code = t, this.rawMessage = r, this.message = `Magic Extension Warning (${e.name}): [${t}] ${r}`;
|
|
877
|
-
}
|
|
878
|
-
message;
|
|
879
|
-
log() {
|
|
880
|
-
console.warn(this.message);
|
|
881
|
-
}
|
|
882
|
-
};
|
|
883
|
-
function Mi() {
|
|
884
|
-
return new Fe(Me.MissingApiKey, "Please provide an API key that you acquired from the Magic developer dashboard.");
|
|
885
|
-
}
|
|
886
|
-
function Lr() {
|
|
887
|
-
return new Fe(Me.ModalNotReady, "Modal is not ready");
|
|
888
|
-
}
|
|
889
|
-
function Ci() {
|
|
890
|
-
return new Fe(Me.MalformedResponse, "Response from the Magic iframe is malformed.");
|
|
891
|
-
}
|
|
892
|
-
function Pi(e) {
|
|
893
|
-
return new Fe(Me.ExtensionNotInitialized, `Extensions must be initialized with a Magic SDK instance before \`Extension.${e}\` can be accessed. Do not invoke \`Extension.${e}\` inside an extension constructor.`);
|
|
894
|
-
}
|
|
895
|
-
function ki(e) {
|
|
896
|
-
let t = `Some extensions are incompatible with \`${X.sdkName}@${X.version}\`:`;
|
|
897
|
-
return e.filter((r) => typeof r.compat < "u" && r.compat !== null).forEach((r) => {
|
|
898
|
-
let n = r.compat[X.sdkName];
|
|
899
|
-
typeof n == "string" ? t += `
|
|
900
|
-
- Extension \`${r.name}\` supports version(s) \`${n}\`` : n || (t += `
|
|
901
|
-
- Extension \`${r.name}\` does not support ${X.platform} environments.`);
|
|
902
|
-
}), new Fe(Me.IncompatibleExtensions, t);
|
|
903
|
-
}
|
|
904
|
-
function Di(e) {
|
|
905
|
-
let t = (r) => {
|
|
906
|
-
let n = r + 1, i = n % 10, a = n % 100;
|
|
907
|
-
return i === 1 && a !== 11 ? `${n}st` : i === 2 && a !== 12 ? `${n}nd` : i === 3 && a !== 13 ? `${n}rd` : `${n}th`;
|
|
908
|
-
};
|
|
909
|
-
return new Fe(Me.InvalidArgument, `Invalid ${t(e.argument)} argument given to \`${e.procedure}\`.
|
|
910
|
-
Expected: \`${e.expected}\`
|
|
911
|
-
Received: \`${e.received}\``);
|
|
912
|
-
}
|
|
913
|
-
function xi() {
|
|
914
|
-
return new et(Ue.DuplicateIframe, "Duplicate iframes found.");
|
|
915
|
-
}
|
|
916
|
-
function Ui() {
|
|
917
|
-
return new et(Ue.SyncWeb3Method, "Non-async web3 methods are deprecated in web3 > 1.0 and are not supported by the Magic web3 provider. Please use an async method instead.");
|
|
918
|
-
}
|
|
919
|
-
function ji() {
|
|
920
|
-
return new et(Ue.ReactNativeEndpointConfiguration, `CUSTOM DOMAINS ARE NOT SUPPORTED WHEN USING MAGIC SDK WITH REACT NATIVE! The \`endpoint\` parameter SHOULD NOT be provided. The Magic \`<iframe>\` is automatically wrapped by a WebView pointed at \`${X.defaultEndpoint}\`. Changing this default behavior will lead to unexpected results and potentially security-threatening bugs.`);
|
|
921
|
-
}
|
|
922
|
-
function Fi(e) {
|
|
923
|
-
let { method: t, removalVersions: r, useInstead: n } = e, i = r[X.sdkName], a = n ? ` Use \`${n}\` instead.` : "", h = `\`${t}\` will be removed from \`${X.sdkName}\` in version \`${i}\`.${a}`;
|
|
924
|
-
return new et(Ue.DeprecationNotice, h);
|
|
925
|
-
}
|
|
926
|
-
function* Gi() {
|
|
927
|
-
let e = 0;
|
|
928
|
-
for (; ; ) e < Number.MAX_SAFE_INTEGER ? yield ++e : e = 0;
|
|
929
|
-
}
|
|
930
|
-
var Wi = Gi();
|
|
931
|
-
function $r() {
|
|
932
|
-
return Wi.next().value;
|
|
933
|
-
}
|
|
934
|
-
var Mr = {};
|
|
935
|
-
Co(Mr, { clear: () => qi, getItem: () => ue, iterate: () => Cr, key: () => Vi, keys: () => zi, length: () => Bi, removeItem: () => xe, setItem: () => Ne });
|
|
936
|
-
var at;
|
|
937
|
-
function Ae(e) {
|
|
938
|
-
return async (...t) => (at || (at = await X.configureStorage()), await at.ready(), at[e](...t));
|
|
939
|
-
}
|
|
940
|
-
var ue = Ae("getItem"), Ne = Ae("setItem"), xe = Ae("removeItem"), qi = Ae("clear"), Bi = Ae("length"), Vi = Ae("key"), zi = Ae("keys"), Cr = Ae("iterate");
|
|
941
|
-
function Hi() {
|
|
942
|
-
let e = window.crypto.getRandomValues(new Uint8Array(16));
|
|
943
|
-
e[6] = e[6] & 15 | 64, e[8] = e[8] & 191 | 128;
|
|
944
|
-
let t = "";
|
|
945
|
-
return t += e[0].toString(16), t += e[1].toString(16), t += e[2].toString(16), t += e[3].toString(16), t += "-", t += e[4].toString(16), t += e[5].toString(16), t += "-", t += e[6].toString(16), t += e[7].toString(16), t += "-", t += e[8].toString(16), t += e[9].toString(16), t += "-", t += e[10].toString(16), t += e[11].toString(16), t += e[12].toString(16), t += e[13].toString(16), t += e[14].toString(16), t += e[15].toString(16), t;
|
|
946
|
-
}
|
|
947
|
-
var Dt = "STORE_KEY_PRIVATE_KEY", ht = "STORE_KEY_PUBLIC_JWK", Pr = "ECDSA", Xi = "P-256", Ki = { name: Pr, namedCurve: Xi };
|
|
948
|
-
function vt() {
|
|
949
|
-
let e = typeof window < "u" && !!window.crypto, t = e && !!window.crypto.subtle;
|
|
950
|
-
return e && t;
|
|
951
|
-
}
|
|
952
|
-
function Yi() {
|
|
953
|
-
xe(ht), xe(Dt);
|
|
954
|
-
}
|
|
955
|
-
async function Ji() {
|
|
956
|
-
let e = await Qi();
|
|
957
|
-
if (!e) {
|
|
958
|
-
console.info("unable to create public key or webcrypto is unsupported");
|
|
959
|
-
return;
|
|
960
|
-
}
|
|
961
|
-
let { subtle: t } = window.crypto, r = await ue(Dt);
|
|
962
|
-
if (!r || !t) {
|
|
963
|
-
console.info("unable to find private key or webcrypto unsupported");
|
|
964
|
-
return;
|
|
965
|
-
}
|
|
966
|
-
let n = { iat: Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3), jti: Hi() }, i = { protected: vr(JSON.stringify({ typ: "dpop+jwt", alg: "ES256", jwk: e })), claims: vr(JSON.stringify(n)) }, a = ea(`${i.protected}.${i.claims}`), h = { name: Pr, hash: { name: "SHA-256" } }, u = ra(new Uint8Array(await t.sign(h, r, a)));
|
|
967
|
-
return `${i.protected}.${i.claims}.${u}`;
|
|
968
|
-
}
|
|
969
|
-
async function Qi() {
|
|
970
|
-
if (!vt()) {
|
|
971
|
-
console.info("webcrypto is not supported");
|
|
972
|
-
return;
|
|
973
|
-
}
|
|
974
|
-
return await ue(ht) || await Zi(), ue(ht);
|
|
975
|
-
}
|
|
976
|
-
async function Zi() {
|
|
977
|
-
let { subtle: e } = window.crypto, t = await e.generateKey(Ki, !1, ["sign"]), r = await e.exportKey("jwk", t.publicKey);
|
|
978
|
-
await Ne(Dt, t.privateKey), await Ne(ht, r);
|
|
979
|
-
}
|
|
980
|
-
function vr(e) {
|
|
981
|
-
return kr(ta(e));
|
|
982
|
-
}
|
|
983
|
-
function ea(e) {
|
|
984
|
-
return new TextEncoder().encode(e);
|
|
985
|
-
}
|
|
986
|
-
function kr(e) {
|
|
987
|
-
return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+/g, "");
|
|
988
|
-
}
|
|
989
|
-
function ta(e) {
|
|
990
|
-
return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, (t, r) => String.fromCharCode(parseInt(r, 16)));
|
|
991
|
-
}
|
|
992
|
-
function ra(e) {
|
|
993
|
-
let t = "";
|
|
994
|
-
return e.forEach((r) => {
|
|
995
|
-
t += String.fromCharCode(r);
|
|
996
|
-
}), kr(t);
|
|
997
|
-
}
|
|
998
|
-
var Dr = Symbol("Payload pre-processed by Magic SDK");
|
|
999
|
-
function xr(e) {
|
|
1000
|
-
return Object.defineProperty(e, Dr, { value: !0, enumerable: !1 }), e;
|
|
1001
|
-
}
|
|
1002
|
-
function na(e) {
|
|
1003
|
-
return !!e[Dr];
|
|
1004
|
-
}
|
|
1005
|
-
function pt(e) {
|
|
1006
|
-
return na(e) || (e.jsonrpc = e.jsonrpc ?? "2.0", e.id = $r(), e.method = e.method ?? "noop", e.params = e.params ?? [], xr(e)), e;
|
|
1007
|
-
}
|
|
1008
|
-
function W(e, t = []) {
|
|
1009
|
-
return xr({ params: t, method: e, jsonrpc: "2.0", id: $r() });
|
|
1010
|
-
}
|
|
1011
|
-
var Ur = class jr {
|
|
1012
|
-
_jsonrpc;
|
|
1013
|
-
_id;
|
|
1014
|
-
_result;
|
|
1015
|
-
_error;
|
|
1016
|
-
constructor(t) {
|
|
1017
|
-
t instanceof jr ? (this._jsonrpc = t.payload.jsonrpc, this._id = t.payload.id, this._result = t.payload.result, this._error = t.payload.error) : Ai(t) ? (this._jsonrpc = t.jsonrpc, this._id = t.id, this._result = t.result, this._error = t.error) : (this._jsonrpc = t.jsonrpc, this._id = t.id, this._result = void 0, this._error = void 0);
|
|
1018
|
-
}
|
|
1019
|
-
applyError(t) {
|
|
1020
|
-
return this._error = t, this;
|
|
1021
|
-
}
|
|
1022
|
-
applyResult(t) {
|
|
1023
|
-
return this._result = t, this;
|
|
1024
|
-
}
|
|
1025
|
-
get hasError() {
|
|
1026
|
-
return this._error?.code === gt.DpopInvalidated && Yi(), typeof this._error < "u" && this._error !== null;
|
|
1027
|
-
}
|
|
1028
|
-
get hasResult() {
|
|
1029
|
-
return typeof this._result < "u";
|
|
1030
|
-
}
|
|
1031
|
-
get payload() {
|
|
1032
|
-
return { jsonrpc: this._jsonrpc, id: this._id, result: this._result, error: this._error };
|
|
1033
|
-
}
|
|
1034
|
-
}, oa = ko(Do()), ia = class extends oa.default {
|
|
1035
|
-
};
|
|
1036
|
-
function Fr() {
|
|
1037
|
-
let e = new ia();
|
|
1038
|
-
return { emitter: e, createChainingEmitterMethod: (t, r) => (...n) => (e[t].apply(e, n), r), createBoundEmitterMethod: (t) => (...r) => e[t].apply(e, r) };
|
|
1039
|
-
}
|
|
1040
|
-
var Gr = Symbol("isPromiEvent");
|
|
1041
|
-
function aa(e) {
|
|
1042
|
-
return !!e[Gr];
|
|
1043
|
-
}
|
|
1044
|
-
function ve(e) {
|
|
1045
|
-
let t = Wr(e), { createBoundEmitterMethod: r, createChainingEmitterMethod: n } = Fr(), i = Symbol("Promise.then"), a = Symbol("Promise.catch"), h = Symbol("Promise.finally"), u = (E, p) => (...S) => {
|
|
1046
|
-
let M = p[E].apply(p, S);
|
|
1047
|
-
return y(M);
|
|
1048
|
-
}, y = (E) => Object.assign(E, { [Gr]: !0, [i]: E[i] || E.then, [a]: E[a] || E.catch, [h]: E[h] || E.finally, then: u(i, E), catch: u(a, E), finally: u(h, E), on: n("on", E), once: n("once", E), addListener: n("addListener", E), off: n("off", E), removeListener: n("removeListener", E), removeAllListeners: n("removeAllListeners", E), emit: r("emit"), eventNames: r("eventNames"), listeners: r("listeners"), listenerCount: r("listenerCount") }), m = y(t.then((E) => (m.emit("done", E), m.emit("settled"), E), (E) => {
|
|
1049
|
-
throw m.emit("error", E), m.emit("settled"), E;
|
|
1050
|
-
}));
|
|
1051
|
-
return m.on(Rr.ClosedByUser, () => {
|
|
1052
|
-
m.emit(br.ClosedByUser);
|
|
1053
|
-
}), m;
|
|
1054
|
-
}
|
|
1055
|
-
function Wr(e) {
|
|
1056
|
-
return new Promise((t, r) => {
|
|
1057
|
-
let n = e(t, r);
|
|
1058
|
-
Promise.resolve(n).catch(r);
|
|
1059
|
-
});
|
|
1060
|
-
}
|
|
1061
|
-
var Oe = class {
|
|
1062
|
-
constructor(t) {
|
|
1063
|
-
this.sdk = t;
|
|
1064
|
-
}
|
|
1065
|
-
get overlay() {
|
|
1066
|
-
return this.sdk.overlay;
|
|
1067
|
-
}
|
|
1068
|
-
request(t) {
|
|
1069
|
-
if (this.sdk.thirdPartyWallets.isConnected && !so.includes(t.method)) return ve((a, h) => {
|
|
1070
|
-
this.sdk.thirdPartyWallets.requestOverride(t).then(a).catch(h);
|
|
1071
|
-
});
|
|
1072
|
-
let r = this.overlay.post(Je.MAGIC_HANDLE_REQUEST, pt(t)), n = ve((a, h) => {
|
|
1073
|
-
r.then((u) => {
|
|
1074
|
-
if (i(), u.hasError) h(new Ct(u.payload.error));
|
|
1075
|
-
else if (u.hasResult) a(u.payload.result);
|
|
1076
|
-
else throw Ci();
|
|
1077
|
-
}).catch((u) => {
|
|
1078
|
-
i(), h(u);
|
|
1079
|
-
});
|
|
1080
|
-
}), i = this.overlay.on(Re.MAGIC_HANDLE_EVENT, (a) => {
|
|
1081
|
-
let { response: h } = a.data;
|
|
1082
|
-
if (h.id === t.id && h.result?.event) {
|
|
1083
|
-
let { event: u, params: y = [] } = h.result;
|
|
1084
|
-
n.emit(u, ...y);
|
|
1085
|
-
}
|
|
1086
|
-
});
|
|
1087
|
-
return n;
|
|
1088
|
-
}
|
|
1089
|
-
createIntermediaryEvent(t, r) {
|
|
1090
|
-
return (n) => {
|
|
1091
|
-
let i = W(C.IntermediaryEvent, [{ payloadId: r, eventType: t, args: n }]);
|
|
1092
|
-
this.request(i);
|
|
1093
|
-
};
|
|
1094
|
-
}
|
|
1095
|
-
};
|
|
1096
|
-
function sa(e, t) {
|
|
1097
|
-
let [r] = e.split(".").map(Number);
|
|
1098
|
-
return r >= t;
|
|
1099
|
-
}
|
|
1100
|
-
var ca = { "magic-sdk": "v18.0.0", "@magic-sdk/react-native": "v14.0.0", "@magic-sdk/react-native-bare": "v19.0.0", "@magic-sdk/react-native-expo": "v19.0.0" }, la = class extends Oe {
|
|
1101
|
-
loginWithMagicLink(t) {
|
|
1102
|
-
let r = X.sdkName === "@magic-sdk/react-native" || X.sdkName === "@magic-sdk/react-native-bare" || X.sdkName === "@magic-sdk/react-native-expo";
|
|
1103
|
-
if (r && sa(X.version, 19)) throw new Error("loginWithMagicLink() is deprecated for this package, please utilize a passcode method like loginWithSMS or loginWithEmailOTP instead.");
|
|
1104
|
-
r && Fi({ method: "auth.loginWithMagicLink()", removalVersions: ca, useInstead: "auth.loginWithEmailOTP()" }).log();
|
|
1105
|
-
let { email: n, showUI: i = !0, redirectURI: a, overrides: h, lifespan: u } = t, y = W(this.sdk.testMode ? C.LoginWithMagicLinkTestMode : C.LoginWithMagicLink, [{ email: n, showUI: i, redirectURI: a, overrides: h, lifespan: u }]);
|
|
1106
|
-
return this.request(y);
|
|
1107
|
-
}
|
|
1108
|
-
loginWithSMS(t) {
|
|
1109
|
-
let { phoneNumber: r, showUI: n = !0, lifespan: i } = t, a = W(this.sdk.testMode ? C.LoginWithSmsTestMode : C.LoginWithSms, [{ phoneNumber: r, showUI: n, lifespan: i }]), h = this.request(a);
|
|
1110
|
-
return !n && h && (h.on(ze.VerifySmsOtp, (u) => {
|
|
1111
|
-
this.createIntermediaryEvent(ze.VerifySmsOtp, a.id)(u);
|
|
1112
|
-
}), h.on(ze.Cancel, () => {
|
|
1113
|
-
this.createIntermediaryEvent(ze.Cancel, a.id)();
|
|
1114
|
-
})), h;
|
|
1115
|
-
}
|
|
1116
|
-
loginWithEmailOTP(t) {
|
|
1117
|
-
let { email: r, showUI: n, deviceCheckUI: i, overrides: a, lifespan: h } = t, u = W(this.sdk.testMode ? C.LoginWithEmailOTPTestMode : C.LoginWithEmailOTP, [{ email: r, showUI: n, deviceCheckUI: i, overrides: a, lifespan: h }]), y = this.request(u);
|
|
1118
|
-
return !i && y && y.on(Tt.Retry, () => {
|
|
1119
|
-
this.createIntermediaryEvent(Tt.Retry, u.id)();
|
|
1120
|
-
}), !n && y && (y.on(fe.VerifyEmailOtp, (m) => {
|
|
1121
|
-
this.createIntermediaryEvent(fe.VerifyEmailOtp, u.id)(m);
|
|
1122
|
-
}), y.on(fe.VerifyMFACode, (m) => {
|
|
1123
|
-
this.createIntermediaryEvent(fe.VerifyMFACode, u.id)(m);
|
|
1124
|
-
}), y.on(fe.LostDevice, () => {
|
|
1125
|
-
this.createIntermediaryEvent(fe.LostDevice, u.id)();
|
|
1126
|
-
}), y.on(fe.VerifyRecoveryCode, (m) => {
|
|
1127
|
-
this.createIntermediaryEvent(fe.VerifyRecoveryCode, u.id)(m);
|
|
1128
|
-
}), y.on(fe.Cancel, () => {
|
|
1129
|
-
this.createIntermediaryEvent(fe.Cancel, u.id)();
|
|
1130
|
-
})), y;
|
|
1131
|
-
}
|
|
1132
|
-
loginWithCredential(t) {
|
|
1133
|
-
let { credentialOrQueryString: r, lifespan: n } = t || {}, i = r ?? "";
|
|
1134
|
-
if (!r && X.platform === "web") {
|
|
1135
|
-
i = window.location.search;
|
|
1136
|
-
let h = window.location.origin + window.location.pathname;
|
|
1137
|
-
window.history.replaceState(null, "", h);
|
|
1138
|
-
}
|
|
1139
|
-
let a = W(this.sdk.testMode ? C.LoginWithCredentialTestMode : C.LoginWithCredential, [i, n]);
|
|
1140
|
-
return this.request(a);
|
|
1141
|
-
}
|
|
1142
|
-
setAuthorizationToken(t) {
|
|
1143
|
-
let r = W(C.SetAuthorizationToken, [{ jwt: t }]);
|
|
1144
|
-
return this.request(r);
|
|
1145
|
-
}
|
|
1146
|
-
updateEmailWithUI(t) {
|
|
1147
|
-
let { email: r, showUI: n = !0 } = t, i = W(this.sdk.testMode ? C.UpdateEmailTestMode : C.UpdateEmail, [{ email: r, showUI: n }]), a = this.request(i);
|
|
1148
|
-
return n || (a.on(he.Retry, () => {
|
|
1149
|
-
this.createIntermediaryEvent(he.Retry, i.id)();
|
|
1150
|
-
}), a.on(he.Cancel, () => {
|
|
1151
|
-
this.createIntermediaryEvent(he.Cancel, i.id)();
|
|
1152
|
-
}), a.on(he.VerifyEmailOtp, (h) => {
|
|
1153
|
-
this.createIntermediaryEvent(he.VerifyEmailOtp, i.id)(h);
|
|
1154
|
-
}), a.on(he.VerifyMFACode, (h) => {
|
|
1155
|
-
this.createIntermediaryEvent(he.VerifyMFACode, i.id)(h);
|
|
1156
|
-
}), a.on(ce.RetryWithNewEmail, (h) => {
|
|
1157
|
-
this.createIntermediaryEvent(ce.RetryWithNewEmail, i.id)(h);
|
|
1158
|
-
}), a.on(ce.Cancel, () => {
|
|
1159
|
-
this.createIntermediaryEvent(ce.Cancel, i.id)();
|
|
1160
|
-
}), a.on(ce.VerifyEmailOtp, (h) => {
|
|
1161
|
-
this.createIntermediaryEvent(ce.VerifyEmailOtp, i.id)(h);
|
|
1162
|
-
})), a;
|
|
1163
|
-
}
|
|
1164
|
-
}, xt = "ds", Ut = "ek", jt = "iv", Ft = "AES-GCM", ua = 256;
|
|
1165
|
-
async function qr() {
|
|
1166
|
-
let e = [];
|
|
1167
|
-
await Cr((t, r, n) => {
|
|
1168
|
-
r.startsWith(`${xt}_`) && e.push(r);
|
|
1169
|
-
});
|
|
1170
|
-
for (let t of e) await xe(t);
|
|
1171
|
-
}
|
|
1172
|
-
function Br(e) {
|
|
1173
|
-
let t = "", r = new Uint8Array(e), n = r.byteLength;
|
|
1174
|
-
for (let i = 0; i < n; i++) t += String.fromCharCode(r[i]);
|
|
1175
|
-
return window.btoa(t);
|
|
1176
|
-
}
|
|
1177
|
-
function Vr(e) {
|
|
1178
|
-
let t = window.atob(e), r = t.length, n = new Uint8Array(r);
|
|
1179
|
-
for (let i = 0; i < r; i++) n[i] = t.charCodeAt(i);
|
|
1180
|
-
return n.buffer;
|
|
1181
|
-
}
|
|
1182
|
-
async function da() {
|
|
1183
|
-
if (!vt()) {
|
|
1184
|
-
console.info("webcrypto is not supported");
|
|
1185
|
-
return;
|
|
1186
|
-
}
|
|
1187
|
-
let { crypto: e } = window;
|
|
1188
|
-
return await ue(jt) || e.getRandomValues(new Uint8Array(12));
|
|
1189
|
-
}
|
|
1190
|
-
async function fa() {
|
|
1191
|
-
if (!vt()) {
|
|
1192
|
-
console.info("webcrypto is not supported");
|
|
1193
|
-
return;
|
|
1194
|
-
}
|
|
1195
|
-
let { subtle: e } = window.crypto;
|
|
1196
|
-
return await ue(Ut) || await e.generateKey({ name: Ft, length: ua }, !1, ["encrypt", "decrypt"]);
|
|
1197
|
-
}
|
|
1198
|
-
async function ha(e, t) {
|
|
1199
|
-
let r = await da(), n = await fa();
|
|
1200
|
-
if (!r || !n || !e) return;
|
|
1201
|
-
let i = Vr(e), { subtle: a } = window.crypto, h = await a.encrypt({ name: Ft, iv: r }, n, i), u = Br(h);
|
|
1202
|
-
await Ne(`${xt}_${t}`, u), await Ne(Ut, n), await Ne(jt, r);
|
|
1203
|
-
}
|
|
1204
|
-
async function pa(e) {
|
|
1205
|
-
let t = await ue(`${xt}_${e}`), r = await ue(jt), n = await ue(Ut);
|
|
1206
|
-
if (!r || !t || !n || !vt()) return;
|
|
1207
|
-
let { subtle: i } = window.crypto, a = await i.decrypt({ name: Ft, iv: r }, n, Vr(t));
|
|
1208
|
-
return Br(a);
|
|
1209
|
-
}
|
|
1210
|
-
function mt(e, t) {
|
|
1211
|
-
return t ? new URL(e, t) : new URL(e);
|
|
1212
|
-
}
|
|
1213
|
-
var ma = class extends Oe {
|
|
1214
|
-
getIdToken(t) {
|
|
1215
|
-
let r = W(this.sdk.testMode ? C.GetIdTokenTestMode : C.GetIdToken, [t]);
|
|
1216
|
-
return this.request(r);
|
|
1217
|
-
}
|
|
1218
|
-
generateIdToken(t) {
|
|
1219
|
-
let r = W(this.sdk.testMode ? C.GenerateIdTokenTestMode : C.GenerateIdToken, [t]);
|
|
1220
|
-
return this.request(r);
|
|
1221
|
-
}
|
|
1222
|
-
getInfo() {
|
|
1223
|
-
let t = W(C.GetInfo, []);
|
|
1224
|
-
return this.request(t);
|
|
1225
|
-
}
|
|
1226
|
-
isLoggedIn() {
|
|
1227
|
-
return ve(async (t, r) => {
|
|
1228
|
-
try {
|
|
1229
|
-
let n = !1;
|
|
1230
|
-
this.sdk.useStorageCache && (n = await ue(this.localForageIsLoggedInKey) === "true", n && t(!0));
|
|
1231
|
-
let i = W(this.sdk.testMode ? C.IsLoggedInTestMode : C.IsLoggedIn), a = await this.request(i);
|
|
1232
|
-
this.sdk.useStorageCache && (a ? Ne(this.localForageIsLoggedInKey, !0) : xe(this.localForageIsLoggedInKey), n && !a && this.emitUserLoggedOut(!0)), t(a);
|
|
1233
|
-
} catch (n) {
|
|
1234
|
-
r(n);
|
|
1235
|
-
}
|
|
1236
|
-
});
|
|
1237
|
-
}
|
|
1238
|
-
logout() {
|
|
1239
|
-
return xe(this.localForageIsLoggedInKey), qr(), ve(async (t, r) => {
|
|
1240
|
-
try {
|
|
1241
|
-
let n = W(this.sdk.testMode ? C.LogoutTestMode : C.Logout), i = await this.request(n);
|
|
1242
|
-
this.sdk.useStorageCache && this.emitUserLoggedOut(i), t(i);
|
|
1243
|
-
} catch (n) {
|
|
1244
|
-
r(n);
|
|
1245
|
-
}
|
|
1246
|
-
});
|
|
1247
|
-
}
|
|
1248
|
-
requestInfoWithUI(t) {
|
|
1249
|
-
let r = W(C.RequestUserInfoWithUI, t ? [t] : []);
|
|
1250
|
-
return this.request(r);
|
|
1251
|
-
}
|
|
1252
|
-
showSettings(t) {
|
|
1253
|
-
let { showUI: r = !0 } = t || {}, n = W(this.sdk.testMode ? C.UserSettingsTestMode : C.UserSettings, [t]), i = this.request(n);
|
|
1254
|
-
return !r && i && (i.on(ye.SendNewPhoneNumber, (a) => {
|
|
1255
|
-
this.createIntermediaryEvent(ye.SendNewPhoneNumber, n.id)(a);
|
|
1256
|
-
}), i.on(ye.SendOtpCode, (a) => {
|
|
1257
|
-
this.createIntermediaryEvent(ye.SendOtpCode, n.id)(a);
|
|
1258
|
-
}), i.on(ye.StartEditPhoneNumber, () => {
|
|
1259
|
-
this.createIntermediaryEvent(ye.StartEditPhoneNumber, n.id)();
|
|
1260
|
-
}), i.on(ye.Cancel, () => {
|
|
1261
|
-
this.createIntermediaryEvent(ye.Cancel, n.id)();
|
|
1262
|
-
}), i.on(he.VerifyEmailOtp, (a) => {
|
|
1263
|
-
this.createIntermediaryEvent(he.VerifyEmailOtp, n.id)(a);
|
|
1264
|
-
})), i;
|
|
1265
|
-
}
|
|
1266
|
-
recoverAccount(t) {
|
|
1267
|
-
let { email: r, showUI: n } = t, i = W(this.sdk.testMode ? C.RecoverAccountTestMode : C.RecoverAccount, [{ email: r, showUI: n }]), a = this.request(i);
|
|
1268
|
-
return !n && a && (a.on(Ee.Cancel, () => {
|
|
1269
|
-
this.createIntermediaryEvent(Ee.Cancel, i.id)();
|
|
1270
|
-
}), a.on(Ee.ResendSms, () => {
|
|
1271
|
-
this.createIntermediaryEvent(Ee.ResendSms, i.id)();
|
|
1272
|
-
}), a.on(Ee.VerifyOtp, (h) => {
|
|
1273
|
-
this.createIntermediaryEvent(Ee.VerifyOtp, i.id)(h);
|
|
1274
|
-
}), a.on(Ee.UpdateEmail, (h) => {
|
|
1275
|
-
this.createIntermediaryEvent(Ee.UpdateEmail, i.id)(h);
|
|
1276
|
-
}), a.on(ce.Cancel, () => {
|
|
1277
|
-
this.createIntermediaryEvent(ce.Cancel, i.id)();
|
|
1278
|
-
}), a.on(ce.RetryWithNewEmail, (h) => {
|
|
1279
|
-
this.createIntermediaryEvent(ce.RetryWithNewEmail, i.id)(h);
|
|
1280
|
-
}), a.on(ce.VerifyEmailOtp, (h) => {
|
|
1281
|
-
this.createIntermediaryEvent(ce.VerifyEmailOtp, i.id)(h);
|
|
1282
|
-
})), a;
|
|
1283
|
-
}
|
|
1284
|
-
revealPrivateKey() {
|
|
1285
|
-
let t = W(C.RevealPK);
|
|
1286
|
-
return this.request(t);
|
|
1287
|
-
}
|
|
1288
|
-
onUserLoggedOut(t) {
|
|
1289
|
-
this.userLoggedOutCallbacks.push(t);
|
|
1290
|
-
}
|
|
1291
|
-
enableMFA(t) {
|
|
1292
|
-
let { showUI: r = !0 } = t, n = W(C.EnableMFA, [{ showUI: r }]), i = this.request(n);
|
|
1293
|
-
return !r && i && (i.on(He.VerifyMFACode, (a) => {
|
|
1294
|
-
this.createIntermediaryEvent(He.VerifyMFACode, n.id)(a);
|
|
1295
|
-
}), i.on(He.Cancel, () => {
|
|
1296
|
-
this.createIntermediaryEvent(He.Cancel, n.id)();
|
|
1297
|
-
})), i;
|
|
1298
|
-
}
|
|
1299
|
-
disableMFA(t) {
|
|
1300
|
-
let { showUI: r = !0 } = t, n = W(C.DisableMFA, [{ showUI: r }]), i = this.request(n);
|
|
1301
|
-
return !r && i && (i.on($e.VerifyMFACode, (a) => {
|
|
1302
|
-
this.createIntermediaryEvent($e.VerifyMFACode, n.id)(a);
|
|
1303
|
-
}), i.on($e.LostDevice, (a) => {
|
|
1304
|
-
this.createIntermediaryEvent($e.LostDevice, n.id)(a);
|
|
1305
|
-
}), i.on($e.Cancel, () => {
|
|
1306
|
-
this.createIntermediaryEvent($e.Cancel, n.id)();
|
|
1307
|
-
})), i;
|
|
1308
|
-
}
|
|
1309
|
-
emitUserLoggedOut(t) {
|
|
1310
|
-
this.userLoggedOutCallbacks.forEach((r) => {
|
|
1311
|
-
r(t);
|
|
1312
|
-
});
|
|
1313
|
-
}
|
|
1314
|
-
localForageIsLoggedInKey = "magic_auth_is_logged_in";
|
|
1315
|
-
userLoggedOutCallbacks = [];
|
|
1316
|
-
}, ga = class extends Oe {
|
|
1317
|
-
connectWithUI(e) {
|
|
1318
|
-
let t = ve(async (r, n) => {
|
|
1319
|
-
try {
|
|
1320
|
-
let i = W(C.Login, [{ enabledWallets: this.sdk.thirdPartyWallets.enabledWallets, ...e }]), a = this.request(i);
|
|
1321
|
-
this.sdk.thirdPartyWallets.eventListeners.forEach(({ event: u, callback: y }) => {
|
|
1322
|
-
a.on(u, () => y(i.id));
|
|
1323
|
-
}), a.on("id-token-created", (u) => {
|
|
1324
|
-
t.emit("id-token-created", u);
|
|
1325
|
-
});
|
|
1326
|
-
let h = await a;
|
|
1327
|
-
h.error && n(h), r(h);
|
|
1328
|
-
} catch (i) {
|
|
1329
|
-
n(i);
|
|
1330
|
-
}
|
|
1331
|
-
});
|
|
1332
|
-
return t;
|
|
1333
|
-
}
|
|
1334
|
-
showUI(e) {
|
|
1335
|
-
return this.request(W(C.ShowUI, [e]));
|
|
1336
|
-
}
|
|
1337
|
-
showAddress() {
|
|
1338
|
-
return this.request(W(C.ShowAddress));
|
|
1339
|
-
}
|
|
1340
|
-
showSendTokensUI() {
|
|
1341
|
-
return this.request(W(C.ShowSendTokensUI));
|
|
1342
|
-
}
|
|
1343
|
-
showOnRamp() {
|
|
1344
|
-
return this.request(W(C.ShowOnRamp));
|
|
1345
|
-
}
|
|
1346
|
-
showNFTs() {
|
|
1347
|
-
return this.request(W(C.ShowNFTs));
|
|
1348
|
-
}
|
|
1349
|
-
showBalances() {
|
|
1350
|
-
return this.request(W(C.ShowBalances));
|
|
1351
|
-
}
|
|
1352
|
-
sendGaslessTransaction(e, t) {
|
|
1353
|
-
return this.request(W(C.SendGaslessTransaction, [e, t]));
|
|
1354
|
-
}
|
|
1355
|
-
}, va = class extends Oe {
|
|
1356
|
-
eventListeners = [];
|
|
1357
|
-
enabledWallets = {};
|
|
1358
|
-
isConnected = !1;
|
|
1359
|
-
resetThirdPartyWalletState() {
|
|
1360
|
-
localStorage.removeItem(be.PROVIDER), localStorage.removeItem(be.ADDRESS), localStorage.removeItem(be.CHAIN_ID), this.isConnected = !1;
|
|
1361
|
-
}
|
|
1362
|
-
requestOverride(e) {
|
|
1363
|
-
if (e.method === C.Login) return this.resetThirdPartyWalletState(), super.request(e);
|
|
1364
|
-
if (e.method === C.GetInfo) return this.getInfo(e);
|
|
1365
|
-
if (e.method === C.IsLoggedIn) return this.isLoggedIn(e);
|
|
1366
|
-
if (e.method === C.Logout) return this.logout(e);
|
|
1367
|
-
switch (localStorage.getItem(be.PROVIDER)) {
|
|
1368
|
-
case "web3modal":
|
|
1369
|
-
return this.web3modalRequest(e);
|
|
1370
|
-
default:
|
|
1371
|
-
return this.resetThirdPartyWalletState(), super.request(e);
|
|
1372
|
-
}
|
|
1373
|
-
}
|
|
1374
|
-
isLoggedIn(e) {
|
|
1375
|
-
switch (localStorage.getItem(be.PROVIDER)) {
|
|
1376
|
-
case "web3modal":
|
|
1377
|
-
return this.web3modalIsLoggedIn();
|
|
1378
|
-
default:
|
|
1379
|
-
return this.resetThirdPartyWalletState(), super.request(e);
|
|
1380
|
-
}
|
|
1381
|
-
}
|
|
1382
|
-
getInfo(e) {
|
|
1383
|
-
switch (localStorage.getItem(be.PROVIDER)) {
|
|
1384
|
-
case "web3modal":
|
|
1385
|
-
return this.web3modalGetInfo();
|
|
1386
|
-
default:
|
|
1387
|
-
return this.resetThirdPartyWalletState(), super.request(e);
|
|
1388
|
-
}
|
|
1389
|
-
}
|
|
1390
|
-
logout(e) {
|
|
1391
|
-
let t = localStorage.getItem(be.PROVIDER);
|
|
1392
|
-
switch (this.resetThirdPartyWalletState(), t) {
|
|
1393
|
-
case "web3modal":
|
|
1394
|
-
return this.web3modalLogout();
|
|
1395
|
-
default:
|
|
1396
|
-
return super.request(e);
|
|
1397
|
-
}
|
|
1398
|
-
}
|
|
1399
|
-
web3modalRequest(e) {
|
|
1400
|
-
return ve((t, r) => {
|
|
1401
|
-
this.sdk.web3modal.modal.getWalletProvider().request(e).then(t).catch(r);
|
|
1402
|
-
});
|
|
1403
|
-
}
|
|
1404
|
-
web3modalIsLoggedIn() {
|
|
1405
|
-
return ve((e) => {
|
|
1406
|
-
let t = this.sdk.web3modal.modal.getStatus();
|
|
1407
|
-
if (t === "connected" && e(!0), t === "disconnected" && (this.resetThirdPartyWalletState(), e(!1)), t === "reconnecting") {
|
|
1408
|
-
let r = this.sdk.web3modal.modal.subscribeProvider(({ status: n }) => {
|
|
1409
|
-
n === "connected" && (r(), e(!0)), n === "disconnected" && (r(), this.resetThirdPartyWalletState(), e(!1));
|
|
1410
|
-
});
|
|
1411
|
-
}
|
|
1412
|
-
});
|
|
1413
|
-
}
|
|
1414
|
-
formatWeb3modalGetInfoResponse() {
|
|
1415
|
-
let e = this.sdk.web3modal.modal.getWalletInfo()?.name, t = this.sdk.web3modal.modal.getAddress();
|
|
1416
|
-
return { publicAddress: t, email: null, issuer: `did:ethr:${t}`, phoneNumber: null, isMfaEnabled: !1, recoveryFactors: [], walletType: e || "web3modal", firstLoginAt: null };
|
|
1417
|
-
}
|
|
1418
|
-
web3modalGetInfo() {
|
|
1419
|
-
return ve((e, t) => {
|
|
1420
|
-
let r = this.sdk.web3modal.modal.getStatus();
|
|
1421
|
-
if (r === "connected" && e(this.formatWeb3modalGetInfoResponse()), r === "disconnected" && (this.resetThirdPartyWalletState(), t("Magic RPC Error: [-32603] Internal error: User denied account access.")), r === "reconnecting") {
|
|
1422
|
-
let n = this.sdk.web3modal.modal.subscribeProvider(({ status: i }) => {
|
|
1423
|
-
i === "connected" && (n(), e(this.formatWeb3modalGetInfoResponse())), i === "disconnected" && (n(), this.resetThirdPartyWalletState(), t("Magic RPC Error: [-32603] Internal error: User denied account access."));
|
|
1424
|
-
});
|
|
1425
|
-
}
|
|
1426
|
-
});
|
|
1427
|
-
}
|
|
1428
|
-
web3modalLogout() {
|
|
1429
|
-
return ve(async (e) => {
|
|
1430
|
-
try {
|
|
1431
|
-
await this.sdk.web3modal.modal.disconnect();
|
|
1432
|
-
} catch (t) {
|
|
1433
|
-
console.error(t);
|
|
1434
|
-
}
|
|
1435
|
-
e(!0);
|
|
1436
|
-
});
|
|
1437
|
-
}
|
|
1438
|
-
}, { createBoundEmitterMethod: st, createChainingEmitterMethod: De } = Fr(), ya = class extends Oe {
|
|
1439
|
-
isMagic = !0;
|
|
1440
|
-
sendAsync(e, t) {
|
|
1441
|
-
if (!t) throw Di({ procedure: "Magic.rpcProvider.sendAsync", argument: 1, expected: "function", received: t === null ? "null" : typeof t });
|
|
1442
|
-
if (Array.isArray(e)) this.overlay.post(Je.MAGIC_HANDLE_REQUEST, e.map((r) => {
|
|
1443
|
-
let n = pt(r);
|
|
1444
|
-
return this.prefixPayloadMethodForTestMode(n), n;
|
|
1445
|
-
})).then((r) => {
|
|
1446
|
-
t(null, r.map((n) => ({ ...n.payload, error: n.hasError ? new Ct(n.payload.error) : null })));
|
|
1447
|
-
});
|
|
1448
|
-
else {
|
|
1449
|
-
let r = pt(e);
|
|
1450
|
-
this.prefixPayloadMethodForTestMode(r), this.overlay.post(Je.MAGIC_HANDLE_REQUEST, r).then((n) => {
|
|
1451
|
-
t(n.hasError ? new Ct(n.payload.error) : null, n.payload);
|
|
1452
|
-
});
|
|
1453
|
-
}
|
|
1454
|
-
}
|
|
1455
|
-
send(e, t) {
|
|
1456
|
-
if (typeof e == "string") {
|
|
1457
|
-
let n = W(e, Array.isArray(t) ? t : []);
|
|
1458
|
-
return this.request(n);
|
|
1459
|
-
}
|
|
1460
|
-
if (Array.isArray(e) || t) {
|
|
1461
|
-
this.sendAsync(e, t);
|
|
1462
|
-
return;
|
|
1463
|
-
}
|
|
1464
|
-
let r = Ui();
|
|
1465
|
-
return r.log(), new Ur(e).applyError({ code: -32603, message: r.rawMessage }).payload;
|
|
1466
|
-
}
|
|
1467
|
-
enable() {
|
|
1468
|
-
let e = W(C.Login);
|
|
1469
|
-
return this.request(e);
|
|
1470
|
-
}
|
|
1471
|
-
request(e) {
|
|
1472
|
-
return this.prefixPayloadMethodForTestMode(e), super.request(e);
|
|
1473
|
-
}
|
|
1474
|
-
prefixPayloadMethodForTestMode(e) {
|
|
1475
|
-
let t = "testMode/eth/";
|
|
1476
|
-
this.sdk.testMode && (e.method = `${t}${e.method}`);
|
|
1477
|
-
}
|
|
1478
|
-
on = De("on", this);
|
|
1479
|
-
once = De("once", this);
|
|
1480
|
-
addListener = De("addListener", this);
|
|
1481
|
-
off = De("off", this);
|
|
1482
|
-
removeListener = De("removeListener", this);
|
|
1483
|
-
removeAllListeners = De("removeAllListeners", this);
|
|
1484
|
-
emit = st("emit");
|
|
1485
|
-
eventNames = st("eventNames");
|
|
1486
|
-
listeners = st("listeners");
|
|
1487
|
-
listenerCount = st("listenerCount");
|
|
1488
|
-
}, Ea = class extends Oe {
|
|
1489
|
-
purchase(e) {
|
|
1490
|
-
let t = W(C.NFTPurchase, [e]);
|
|
1491
|
-
return this.request(t);
|
|
1492
|
-
}
|
|
1493
|
-
checkout(e) {
|
|
1494
|
-
let t = this.sdk.thirdPartyWallets.isConnected, r = W(C.NFTCheckout, [{ ...e, walletProvider: t ? "web3modal" : "magic" }]), n = this.request(r);
|
|
1495
|
-
return t && (n.on(Xe.Initiated, async (i) => {
|
|
1496
|
-
try {
|
|
1497
|
-
let a = await this.request({ method: "eth_sendTransaction", params: [i] });
|
|
1498
|
-
this.createIntermediaryEvent(Xe.Success, r.id)(a);
|
|
1499
|
-
} catch {
|
|
1500
|
-
this.createIntermediaryEvent(Xe.Failure, r.id)();
|
|
1501
|
-
}
|
|
1502
|
-
}), n.on(Xe.Disconnect, () => {
|
|
1503
|
-
this.sdk.thirdPartyWallets.resetThirdPartyWalletState(), n.emit("disconnect");
|
|
1504
|
-
})), n;
|
|
1505
|
-
}
|
|
1506
|
-
transfer(e) {
|
|
1507
|
-
let t = W(C.NFTTransfer, [e]);
|
|
1508
|
-
return this.request(t);
|
|
1509
|
-
}
|
|
1510
|
-
};
|
|
1511
|
-
function yr(e) {
|
|
1512
|
-
return e.compat && e.compat[X.sdkName] != null ? typeof e.compat[X.sdkName] == "string" ? gi(wi(X.version), e.compat[X.sdkName]) : !!e.compat[X.sdkName] : !0;
|
|
1513
|
-
}
|
|
1514
|
-
function wa(e, t, r) {
|
|
1515
|
-
return !t && !r ? `${e}_eth_mainnet` : r ? `${e}_${JSON.stringify(r)}` : t ? typeof t == "string" ? `${e}_eth_${t}` : `${e}_${t.rpcUrl}_${t.chainId}_${t.chainType}` : `${e}_unknown`;
|
|
1516
|
-
}
|
|
1517
|
-
function _a(e) {
|
|
1518
|
-
let t = e?.extensions ?? [], r = {}, n = [];
|
|
1519
|
-
if (Array.isArray(t) ? t.forEach((i) => {
|
|
1520
|
-
yr(i) ? (i.init(this), i.name && (this[i.name] = i), ft(i.config) || (r[i.name] = i.config)) : n.push(i);
|
|
1521
|
-
}) : Object.keys(t).forEach((i) => {
|
|
1522
|
-
if (yr(t[i])) {
|
|
1523
|
-
t[i].init(this);
|
|
1524
|
-
let a = t[i];
|
|
1525
|
-
this[i] = a, ft(a.config) || (r[t[i].name] = a.config);
|
|
1526
|
-
} else n.push(t[i]);
|
|
1527
|
-
}), n.length) throw ki(n);
|
|
1528
|
-
return r;
|
|
1529
|
-
}
|
|
1530
|
-
var Ia = class ut {
|
|
1531
|
-
constructor(t, r) {
|
|
1532
|
-
if (this.apiKey = t, !t) throw Mi();
|
|
1533
|
-
X.platform === "react-native" && r?.endpoint && ji().log();
|
|
1534
|
-
let { defaultEndpoint: n, version: i } = X;
|
|
1535
|
-
this.testMode = !!r?.testMode, this.useStorageCache = !!r?.useStorageCache, this.endpoint = mt(r?.endpoint ?? n).origin, this.auth = new la(this), this.user = new ma(this), this.wallet = new ga(this), this.nft = new Ea(this), this.thirdPartyWallets = new va(this), this.rpcProvider = new ya(this);
|
|
1536
|
-
let a = _a.call(this, r);
|
|
1537
|
-
this.parameters = Nr({ API_KEY: this.apiKey, DOMAIN_ORIGIN: typeof window < "u" && window?.location ? window?.location.origin : "", ETH_NETWORK: r?.network, host: mt(this.endpoint).host, sdk: Li[X.sdkName], version: i, ext: ft(a) ? void 0 : a, locale: r?.locale || "en_US", authConfig: r?.authConfig ? { ...r.authConfig } : void 0, ...X.bundleId ? { bundleId: X.bundleId } : {}, meta: r?.meta }), this.networkHash = wa(this.apiKey, r?.network, ft(a) ? void 0 : a), r?.deferPreload || this.preload();
|
|
1538
|
-
}
|
|
1539
|
-
static __overlays__ = /* @__PURE__ */ new Map();
|
|
1540
|
-
endpoint;
|
|
1541
|
-
parameters;
|
|
1542
|
-
networkHash;
|
|
1543
|
-
testMode;
|
|
1544
|
-
useStorageCache;
|
|
1545
|
-
auth;
|
|
1546
|
-
user;
|
|
1547
|
-
wallet;
|
|
1548
|
-
nft;
|
|
1549
|
-
thirdPartyWallets;
|
|
1550
|
-
rpcProvider;
|
|
1551
|
-
get overlay() {
|
|
1552
|
-
if (!ut.__overlays__.has(this.parameters)) {
|
|
1553
|
-
let t = new X.ViewController(this.endpoint, this.parameters, this.networkHash);
|
|
1554
|
-
t.init(), ut.__overlays__.set(this.parameters, t);
|
|
1555
|
-
}
|
|
1556
|
-
return ut.__overlays__.get(this.parameters);
|
|
1557
|
-
}
|
|
1558
|
-
async preload() {
|
|
1559
|
-
await this.overlay.waitForReady();
|
|
1560
|
-
}
|
|
1561
|
-
};
|
|
1562
|
-
function ba(e, t) {
|
|
1563
|
-
return t && Array.isArray(e) ? e.find((r) => r.id === t) : e;
|
|
1564
|
-
}
|
|
1565
|
-
function Ra(e, t) {
|
|
1566
|
-
let r = t.data.response?.id, n = ba(e, r);
|
|
1567
|
-
if (r && n) {
|
|
1568
|
-
let i = new Ur(n).applyResult(t.data.response.result).applyError(t.data.response.error);
|
|
1569
|
-
return { id: r, response: i };
|
|
1570
|
-
}
|
|
1571
|
-
return {};
|
|
1572
|
-
}
|
|
1573
|
-
async function Na(e, t, r) {
|
|
1574
|
-
let n = await ue("rt"), i;
|
|
1575
|
-
if (X.platform === "web") try {
|
|
1576
|
-
i = await ue("jwt") ?? await Ji();
|
|
1577
|
-
} catch (u) {
|
|
1578
|
-
console.error("webcrypto error", u);
|
|
1579
|
-
}
|
|
1580
|
-
let a = { msgType: e, payload: t };
|
|
1581
|
-
i && (a.jwt = i), i && n && (a.rt = n);
|
|
1582
|
-
let h = await pa(r);
|
|
1583
|
-
return h && (a.deviceShare = h), a;
|
|
1584
|
-
}
|
|
1585
|
-
async function Sa(e) {
|
|
1586
|
-
e.data.rt && await Ne("rt", e.data.rt);
|
|
1587
|
-
}
|
|
1588
|
-
function Aa(e, t) {
|
|
1589
|
-
let r = null;
|
|
1590
|
-
return function(...n) {
|
|
1591
|
-
r && clearTimeout(r), r = setTimeout(() => {
|
|
1592
|
-
e(...n);
|
|
1593
|
-
}, t);
|
|
1594
|
-
};
|
|
1595
|
-
}
|
|
1596
|
-
var Oa = 1e3, zr = 60 * Oa, Er = 5 * zr, Ta = 60 * zr, La = class {
|
|
1597
|
-
constructor(e, t, r) {
|
|
1598
|
-
this.endpoint = e, this.parameters = t, this.networkHash = r, this.listen();
|
|
1599
|
-
}
|
|
1600
|
-
isReadyForRequest = !1;
|
|
1601
|
-
messageHandlers = /* @__PURE__ */ new Set();
|
|
1602
|
-
isConnectedToInternet = !0;
|
|
1603
|
-
lastPongTime = null;
|
|
1604
|
-
heartbeatIntervalTimer = null;
|
|
1605
|
-
heartbeatDebounce = Aa(() => {
|
|
1606
|
-
this.endpoint === "https://auth.magic.link/" && this.heartBeatCheck();
|
|
1607
|
-
}, Ta);
|
|
1608
|
-
async post(e, t) {
|
|
1609
|
-
return Wr(async (r, n) => {
|
|
1610
|
-
if (!this.isConnectedToInternet) {
|
|
1611
|
-
let m = Lr();
|
|
1612
|
-
n(m);
|
|
1613
|
-
}
|
|
1614
|
-
await this.checkRelayerExistsInDOM() || (this.isReadyForRequest = !1, await this.reloadRelayer()), this.isReadyForRequest || await this.waitForReady();
|
|
1615
|
-
let i = [], a = Array.isArray(t) ? t.map((m) => m.id) : [], h = await Na(`${e}-${this.parameters}`, t, this.networkHash);
|
|
1616
|
-
await this._post(h);
|
|
1617
|
-
let u = (m) => (E) => {
|
|
1618
|
-
let { id: p, response: S } = Ra(t, E);
|
|
1619
|
-
if (Sa(E), S?.payload.error?.message === "User denied account access.") qr();
|
|
1620
|
-
else if (E.data.deviceShare) {
|
|
1621
|
-
let { deviceShare: M } = E.data;
|
|
1622
|
-
ha(M, this.networkHash);
|
|
1623
|
-
}
|
|
1624
|
-
p && S && Array.isArray(t) && a.includes(p) ? (i.push(S), i.length === t.length && (m(), r(i))) : p && S && !Array.isArray(t) && p === t.id && (m(), r(S));
|
|
1625
|
-
}, y = this.on(Re.MAGIC_HANDLE_RESPONSE, u(() => y()));
|
|
1626
|
-
});
|
|
1627
|
-
}
|
|
1628
|
-
on(e, t) {
|
|
1629
|
-
let r = t.bind(window), n = (i) => {
|
|
1630
|
-
i.data.msgType === `${e}-${this.parameters}` && r(i);
|
|
1631
|
-
};
|
|
1632
|
-
return this.messageHandlers.add(n), () => this.messageHandlers.delete(n);
|
|
1633
|
-
}
|
|
1634
|
-
waitForReady() {
|
|
1635
|
-
return new Promise((e) => {
|
|
1636
|
-
let t = this.on(Re.MAGIC_OVERLAY_READY, () => {
|
|
1637
|
-
this.isReadyForRequest = !0, e(), t();
|
|
1638
|
-
});
|
|
1639
|
-
});
|
|
1640
|
-
}
|
|
1641
|
-
listen() {
|
|
1642
|
-
this.on(Re.MAGIC_HIDE_OVERLAY, () => {
|
|
1643
|
-
this.hideOverlay();
|
|
1644
|
-
}), this.on(Re.MAGIC_SHOW_OVERLAY, () => {
|
|
1645
|
-
this.showOverlay();
|
|
1646
|
-
}), this.on(Re.MAGIC_SEND_PRODUCT_ANNOUNCEMENT, (e) => {
|
|
1647
|
-
e.data.response.result.product_announcement && new et(Ue.ProductAnnouncement, e.data.response.result.product_announcement).log();
|
|
1648
|
-
});
|
|
1649
|
-
}
|
|
1650
|
-
heartBeatCheck() {
|
|
1651
|
-
let e = !0, t = async () => {
|
|
1652
|
-
let r = { msgType: `${Je.MAGIC_PING}-${this.parameters}`, payload: [] };
|
|
1653
|
-
await this._post(r);
|
|
1654
|
-
};
|
|
1655
|
-
this.heartbeatIntervalTimer = setInterval(async () => {
|
|
1656
|
-
if (this.lastPongTime) {
|
|
1657
|
-
if (Date.now() - this.lastPongTime > Er * 2) {
|
|
1658
|
-
this.reloadRelayer(), e = !0;
|
|
1659
|
-
return;
|
|
1660
|
-
}
|
|
1661
|
-
} else if (!e) {
|
|
1662
|
-
this.reloadRelayer(), e = !0;
|
|
1663
|
-
return;
|
|
1664
|
-
}
|
|
1665
|
-
await t(), e = !1;
|
|
1666
|
-
}, Er);
|
|
1667
|
-
}
|
|
1668
|
-
stopHeartBeat() {
|
|
1669
|
-
this.heartbeatDebounce(), this.lastPongTime = null, this.heartbeatIntervalTimer && (clearInterval(this.heartbeatIntervalTimer), this.heartbeatIntervalTimer = null);
|
|
1670
|
-
}
|
|
1671
|
-
}, wr = ["request", "overlay", "sdk"];
|
|
1672
|
-
function $a(e) {
|
|
1673
|
-
let t = Object.getPrototypeOf(e), r = [t];
|
|
1674
|
-
for (; t !== Oe.prototype; ) t = Object.getPrototypeOf(t), r.push(t);
|
|
1675
|
-
return r;
|
|
1676
|
-
}
|
|
1677
|
-
var Ma = class extends Oe {
|
|
1678
|
-
compat;
|
|
1679
|
-
__sdk_access_field_descriptors__ = /* @__PURE__ */ new Map();
|
|
1680
|
-
__is_initialized__ = !1;
|
|
1681
|
-
utils = { createPromiEvent: ve, isPromiEvent: aa, encodeJSON: Nr, decodeJSON: Ni, createJsonRpcRequestPayload: W, standardizeJsonRpcRequestPayload: pt, storage: Mr };
|
|
1682
|
-
constructor() {
|
|
1683
|
-
super(void 0);
|
|
1684
|
-
let e = [this, ...$a(this)];
|
|
1685
|
-
wr.forEach((t) => {
|
|
1686
|
-
let r = e.map((h) => Object.getOwnPropertyDescriptor(h, t)), n = r.findIndex((h) => !!h), i = n > 0, a = r[n];
|
|
1687
|
-
a && (this.__sdk_access_field_descriptors__.set(t, { descriptor: a, isPrototypeField: i }), Object.defineProperty(this, t, { configurable: !0, get: () => {
|
|
1688
|
-
throw Pi(t);
|
|
1689
|
-
} }));
|
|
1690
|
-
});
|
|
1691
|
-
}
|
|
1692
|
-
init(e) {
|
|
1693
|
-
this.__is_initialized__ || (wr.forEach((t) => {
|
|
1694
|
-
if (this.__sdk_access_field_descriptors__.has(t)) {
|
|
1695
|
-
let { descriptor: r, isPrototypeField: n } = this.__sdk_access_field_descriptors__.get(t);
|
|
1696
|
-
n ? delete this[t] : Object.defineProperty(this, t, r);
|
|
1697
|
-
}
|
|
1698
|
-
}), this.sdk = e, this.__is_initialized__ = !0);
|
|
1699
|
-
}
|
|
1700
|
-
createDeprecationWarning(e) {
|
|
1701
|
-
let { method: t, removalVersion: r, useInstead: n } = e, i = n ? ` Use \`${n}\` instead.` : "", a = `\`${t}\` will be removed from this Extension in version \`${r}\`.${i}`;
|
|
1702
|
-
return new gr(this, "DEPRECATION_NOTICE", a);
|
|
1703
|
-
}
|
|
1704
|
-
createWarning(e, t) {
|
|
1705
|
-
return new gr(this, e, t);
|
|
1706
|
-
}
|
|
1707
|
-
createError(e, t, r) {
|
|
1708
|
-
return new $i(this, e, t, r);
|
|
1709
|
-
}
|
|
1710
|
-
}, Ca = class extends Ma {
|
|
1711
|
-
}, Pa = class {
|
|
1712
|
-
static Internal = Ca;
|
|
1713
|
-
}, ka = ((e) => (e.Start = "magic_oauth_login_with_redirect_start", e.Verify = "magic_oauth_login_with_redirect_verify", e.Popup = "magic_oauth_login_with_popup", e.VerifyTelegramData = "magic_oauth_verify_telegram_data", e))(ka || {}), Da = ((e) => (e.InvalidRequest = "invalid_request", e.InvalidClient = "invalid_client", e.InvalidScope = "invalid_scope", e.InvalidGrant = "invalid_grant", e.UnauthorizedClient = "unauthorized_client", e.UnsupportedResponseType = "unsupported_response_type", e.UnsupportedGrantType = "unsupported_grant_type", e.UnsupportedTokenType = "unsupported_token_type", e.AccessDenied = "access_denied", e.ServerError = "server_error", e.TemporarilyUnavailable = "temporarily_unavailable", e))(Da || {}), xa = class extends Pa.Internal {
|
|
1714
|
-
name = "oauth2";
|
|
1715
|
-
config = {};
|
|
1716
|
-
compat = { "magic-sdk": ">=2.4.6", "@magic-sdk/react-native": !1, "@magic-sdk/react-native-bare": !1, "@magic-sdk/react-native-expo": !1 };
|
|
1717
|
-
constructor() {
|
|
1718
|
-
super(), this.seamlessTelegramLogin();
|
|
1719
|
-
}
|
|
1720
|
-
loginWithRedirect(e) {
|
|
1721
|
-
return this.utils.createPromiEvent(async (t, r) => {
|
|
1722
|
-
let n = this.utils.createJsonRpcRequestPayload("magic_oauth_login_with_redirect_start", [{ ...e, apiKey: this.sdk.apiKey, platform: "web" }]), i = await this.request(n), a = i, h = i;
|
|
1723
|
-
if (h.error && r(this.createError(h.error, h.error_description ?? "An error occurred.", { errorURI: h.error_uri, provider: h.provider })), a?.oauthAuthoriationURI) {
|
|
1724
|
-
let u = a.useMagicServerCallback ? new URL(a.oauthAuthoriationURI, this.sdk.endpoint).href : a.oauthAuthoriationURI;
|
|
1725
|
-
a?.shouldReturnURI ? t(u) : window.location.href = u;
|
|
1726
|
-
}
|
|
1727
|
-
t(null);
|
|
1728
|
-
});
|
|
1729
|
-
}
|
|
1730
|
-
getRedirectResult(e) {
|
|
1731
|
-
let t = e.optionalQueryString || window.location.search, r = window.location.origin + window.location.pathname;
|
|
1732
|
-
return window.history.replaceState(null, "", r), Ua.call(this, e, t);
|
|
1733
|
-
}
|
|
1734
|
-
loginWithPopup(e) {
|
|
1735
|
-
let t = this.utils.createJsonRpcRequestPayload("magic_oauth_login_with_popup", [{ ...e, apiKey: this.sdk.apiKey, platform: "web" }]);
|
|
1736
|
-
return this.request(t);
|
|
1737
|
-
}
|
|
1738
|
-
seamlessTelegramLogin() {
|
|
1739
|
-
try {
|
|
1740
|
-
if (!window.location.hash.toString().includes("#tgWebAppData")) return;
|
|
1741
|
-
let e = document.createElement("script");
|
|
1742
|
-
e.src = "https://telegram.org/js/telegram-web-app.js", document.head.prepend(e), e.onload = async () => {
|
|
1743
|
-
try {
|
|
1744
|
-
let t = window.Telegram?.WebApp.initData, r = this.utils.createJsonRpcRequestPayload("magic_oauth_verify_telegram_data", [{ userData: t, isMiniApp: !0 }]);
|
|
1745
|
-
await this.request(r);
|
|
1746
|
-
} catch (t) {
|
|
1747
|
-
console.log("Error while verifying telegram data", t);
|
|
1748
|
-
}
|
|
1749
|
-
};
|
|
1750
|
-
} catch (e) {
|
|
1751
|
-
console.log("Error while loading telegram-web-app script", e);
|
|
1752
|
-
}
|
|
1753
|
-
}
|
|
1754
|
-
};
|
|
1755
|
-
function Ua(e, t) {
|
|
1756
|
-
return this.utils.createPromiEvent(async (r, n) => {
|
|
1757
|
-
let i = this.utils.createJsonRpcRequestPayload("magic_oauth_login_with_redirect_verify", [{ authorizationResponseParams: t, magicApiKey: this.sdk.apiKey, platform: "web", ...e }]), a = await this.request(i), h = a, u = a;
|
|
1758
|
-
u.error && n(this.createError(u.error, u.error_description ?? "An error occurred.", { errorURI: u.error_uri, provider: u.provider })), r(h);
|
|
1759
|
-
});
|
|
1760
|
-
}
|
|
1761
|
-
var ja = Object.create, Hr = Object.defineProperty, Fa = Object.getOwnPropertyDescriptor, Ga = Object.getOwnPropertyNames, Wa = Object.getPrototypeOf, qa = Object.prototype.hasOwnProperty, ct = ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (t, r) => (typeof require < "u" ? require : t)[r] }) : e)(function(e) {
|
|
1762
|
-
if (typeof require < "u") return require.apply(this, arguments);
|
|
1763
|
-
throw Error('Dynamic require of "' + e + '" is not supported');
|
|
1764
|
-
}), Xr = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), Ba = (e, t, r, n) => {
|
|
1765
|
-
if (t && typeof t == "object" || typeof t == "function") for (let i of Ga(t)) !qa.call(e, i) && i !== r && Hr(e, i, { get: () => t[i], enumerable: !(n = Fa(t, i)) || n.enumerable });
|
|
1766
|
-
return e;
|
|
1767
|
-
}, Kr = (e, t, r) => (r = e != null ? ja(Wa(e)) : {}, Ba(!e || !e.__esModule ? Hr(r, "default", { value: e, enumerable: !0 }) : r, e)), Va = Xr((e, t) => {
|
|
1768
|
-
(function(r) {
|
|
1769
|
-
if (typeof e == "object" && typeof t < "u") t.exports = r();
|
|
1770
|
-
else if (typeof define == "function" && define.amd) define([], r);
|
|
1771
|
-
else {
|
|
1772
|
-
var n;
|
|
1773
|
-
typeof window < "u" ? n = window : typeof global < "u" ? n = global : typeof self < "u" ? n = self : n = this, n.localforage = r();
|
|
1774
|
-
}
|
|
1775
|
-
})(function() {
|
|
1776
|
-
return (function r(n, i, a) {
|
|
1777
|
-
function h(m, E) {
|
|
1778
|
-
if (!i[m]) {
|
|
1779
|
-
if (!n[m]) {
|
|
1780
|
-
var p = typeof ct == "function" && ct;
|
|
1781
|
-
if (!E && p) return p(m, !0);
|
|
1782
|
-
if (u) return u(m, !0);
|
|
1783
|
-
var S = new Error("Cannot find module '" + m + "'");
|
|
1784
|
-
throw S.code = "MODULE_NOT_FOUND", S;
|
|
1785
|
-
}
|
|
1786
|
-
var M = i[m] = { exports: {} };
|
|
1787
|
-
n[m][0].call(M.exports, function(P) {
|
|
1788
|
-
var G = n[m][1][P];
|
|
1789
|
-
return h(G || P);
|
|
1790
|
-
}, M, M.exports, r, n, i, a);
|
|
1791
|
-
}
|
|
1792
|
-
return i[m].exports;
|
|
1793
|
-
}
|
|
1794
|
-
for (var u = typeof ct == "function" && ct, y = 0; y < a.length; y++) h(a[y]);
|
|
1795
|
-
return h;
|
|
1796
|
-
})({ 1: [function(r, n, i) {
|
|
1797
|
-
(function(a) {
|
|
1798
|
-
var h = a.MutationObserver || a.WebKitMutationObserver, u;
|
|
1799
|
-
if (h) {
|
|
1800
|
-
var y = 0, m = new h(P), E = a.document.createTextNode("");
|
|
1801
|
-
m.observe(E, { characterData: !0 }), u = function() {
|
|
1802
|
-
E.data = y = ++y % 2;
|
|
1803
|
-
};
|
|
1804
|
-
} else if (!a.setImmediate && typeof a.MessageChannel < "u") {
|
|
1805
|
-
var p = new a.MessageChannel();
|
|
1806
|
-
p.port1.onmessage = P, u = function() {
|
|
1807
|
-
p.port2.postMessage(0);
|
|
1808
|
-
};
|
|
1809
|
-
} else "document" in a && "onreadystatechange" in a.document.createElement("script") ? u = function() {
|
|
1810
|
-
var O = a.document.createElement("script");
|
|
1811
|
-
O.onreadystatechange = function() {
|
|
1812
|
-
P(), O.onreadystatechange = null, O.parentNode.removeChild(O), O = null;
|
|
1813
|
-
}, a.document.documentElement.appendChild(O);
|
|
1814
|
-
} : u = function() {
|
|
1815
|
-
setTimeout(P, 0);
|
|
1816
|
-
};
|
|
1817
|
-
var S, M = [];
|
|
1818
|
-
function P() {
|
|
1819
|
-
S = !0;
|
|
1820
|
-
for (var O, K, q = M.length; q; ) {
|
|
1821
|
-
for (K = M, M = [], O = -1; ++O < q; ) K[O]();
|
|
1822
|
-
q = M.length;
|
|
1823
|
-
}
|
|
1824
|
-
S = !1;
|
|
1825
|
-
}
|
|
1826
|
-
n.exports = G;
|
|
1827
|
-
function G(O) {
|
|
1828
|
-
M.push(O) === 1 && !S && u();
|
|
1829
|
-
}
|
|
1830
|
-
}).call(this, typeof global < "u" ? global : typeof self < "u" ? self : typeof window < "u" ? window : {});
|
|
1831
|
-
}, {}], 2: [function(r, n, i) {
|
|
1832
|
-
var a = r(1);
|
|
1833
|
-
function h() {
|
|
1834
|
-
}
|
|
1835
|
-
var u = {}, y = ["REJECTED"], m = ["FULFILLED"], E = ["PENDING"];
|
|
1836
|
-
n.exports = p;
|
|
1837
|
-
function p(N) {
|
|
1838
|
-
if (typeof N != "function") throw new TypeError("resolver must be a function");
|
|
1839
|
-
this.state = E, this.queue = [], this.outcome = void 0, N !== h && G(this, N);
|
|
1840
|
-
}
|
|
1841
|
-
p.prototype.catch = function(N) {
|
|
1842
|
-
return this.then(null, N);
|
|
1843
|
-
}, p.prototype.then = function(N, j) {
|
|
1844
|
-
if (typeof N != "function" && this.state === m || typeof j != "function" && this.state === y) return this;
|
|
1845
|
-
var x = new this.constructor(h);
|
|
1846
|
-
if (this.state !== E) {
|
|
1847
|
-
var F = this.state === m ? N : j;
|
|
1848
|
-
M(x, F, this.outcome);
|
|
1849
|
-
} else this.queue.push(new S(x, N, j));
|
|
1850
|
-
return x;
|
|
1851
|
-
};
|
|
1852
|
-
function S(N, j, x) {
|
|
1853
|
-
this.promise = N, typeof j == "function" && (this.onFulfilled = j, this.callFulfilled = this.otherCallFulfilled), typeof x == "function" && (this.onRejected = x, this.callRejected = this.otherCallRejected);
|
|
1854
|
-
}
|
|
1855
|
-
S.prototype.callFulfilled = function(N) {
|
|
1856
|
-
u.resolve(this.promise, N);
|
|
1857
|
-
}, S.prototype.otherCallFulfilled = function(N) {
|
|
1858
|
-
M(this.promise, this.onFulfilled, N);
|
|
1859
|
-
}, S.prototype.callRejected = function(N) {
|
|
1860
|
-
u.reject(this.promise, N);
|
|
1861
|
-
}, S.prototype.otherCallRejected = function(N) {
|
|
1862
|
-
M(this.promise, this.onRejected, N);
|
|
1863
|
-
};
|
|
1864
|
-
function M(N, j, x) {
|
|
1865
|
-
a(function() {
|
|
1866
|
-
var F;
|
|
1867
|
-
try {
|
|
1868
|
-
F = j(x);
|
|
1869
|
-
} catch (Z) {
|
|
1870
|
-
return u.reject(N, Z);
|
|
1871
|
-
}
|
|
1872
|
-
F === N ? u.reject(N, new TypeError("Cannot resolve promise with itself")) : u.resolve(N, F);
|
|
1873
|
-
});
|
|
1874
|
-
}
|
|
1875
|
-
u.resolve = function(N, j) {
|
|
1876
|
-
var x = O(P, j);
|
|
1877
|
-
if (x.status === "error") return u.reject(N, x.value);
|
|
1878
|
-
var F = x.value;
|
|
1879
|
-
if (F) G(N, F);
|
|
1880
|
-
else {
|
|
1881
|
-
N.state = m, N.outcome = j;
|
|
1882
|
-
for (var Z = -1, oe = N.queue.length; ++Z < oe; ) N.queue[Z].callFulfilled(j);
|
|
1883
|
-
}
|
|
1884
|
-
return N;
|
|
1885
|
-
}, u.reject = function(N, j) {
|
|
1886
|
-
N.state = y, N.outcome = j;
|
|
1887
|
-
for (var x = -1, F = N.queue.length; ++x < F; ) N.queue[x].callRejected(j);
|
|
1888
|
-
return N;
|
|
1889
|
-
};
|
|
1890
|
-
function P(N) {
|
|
1891
|
-
var j = N && N.then;
|
|
1892
|
-
if (N && (typeof N == "object" || typeof N == "function") && typeof j == "function") return function() {
|
|
1893
|
-
j.apply(N, arguments);
|
|
1894
|
-
};
|
|
1895
|
-
}
|
|
1896
|
-
function G(N, j) {
|
|
1897
|
-
var x = !1;
|
|
1898
|
-
function F(se) {
|
|
1899
|
-
x || (x = !0, u.reject(N, se));
|
|
1900
|
-
}
|
|
1901
|
-
function Z(se) {
|
|
1902
|
-
x || (x = !0, u.resolve(N, se));
|
|
1903
|
-
}
|
|
1904
|
-
function oe() {
|
|
1905
|
-
j(Z, F);
|
|
1906
|
-
}
|
|
1907
|
-
var ae = O(oe);
|
|
1908
|
-
ae.status === "error" && F(ae.value);
|
|
1909
|
-
}
|
|
1910
|
-
function O(N, j) {
|
|
1911
|
-
var x = {};
|
|
1912
|
-
try {
|
|
1913
|
-
x.value = N(j), x.status = "success";
|
|
1914
|
-
} catch (F) {
|
|
1915
|
-
x.status = "error", x.value = F;
|
|
1916
|
-
}
|
|
1917
|
-
return x;
|
|
1918
|
-
}
|
|
1919
|
-
p.resolve = K;
|
|
1920
|
-
function K(N) {
|
|
1921
|
-
return N instanceof this ? N : u.resolve(new this(h), N);
|
|
1922
|
-
}
|
|
1923
|
-
p.reject = q;
|
|
1924
|
-
function q(N) {
|
|
1925
|
-
var j = new this(h);
|
|
1926
|
-
return u.reject(j, N);
|
|
1927
|
-
}
|
|
1928
|
-
p.all = B;
|
|
1929
|
-
function B(N) {
|
|
1930
|
-
var j = this;
|
|
1931
|
-
if (Object.prototype.toString.call(N) !== "[object Array]") return this.reject(new TypeError("must be an array"));
|
|
1932
|
-
var x = N.length, F = !1;
|
|
1933
|
-
if (!x) return this.resolve([]);
|
|
1934
|
-
for (var Z = new Array(x), oe = 0, ae = -1, se = new this(h); ++ae < x; ) de(N[ae], ae);
|
|
1935
|
-
return se;
|
|
1936
|
-
function de(Te, Ce) {
|
|
1937
|
-
j.resolve(Te).then(Ge, function(we) {
|
|
1938
|
-
F || (F = !0, u.reject(se, we));
|
|
1939
|
-
});
|
|
1940
|
-
function Ge(we) {
|
|
1941
|
-
Z[Ce] = we, ++oe === x && !F && (F = !0, u.resolve(se, Z));
|
|
1942
|
-
}
|
|
1943
|
-
}
|
|
1944
|
-
}
|
|
1945
|
-
p.race = ee;
|
|
1946
|
-
function ee(N) {
|
|
1947
|
-
var j = this;
|
|
1948
|
-
if (Object.prototype.toString.call(N) !== "[object Array]") return this.reject(new TypeError("must be an array"));
|
|
1949
|
-
var x = N.length, F = !1;
|
|
1950
|
-
if (!x) return this.resolve([]);
|
|
1951
|
-
for (var Z = -1, oe = new this(h); ++Z < x; ) ae(N[Z]);
|
|
1952
|
-
return oe;
|
|
1953
|
-
function ae(se) {
|
|
1954
|
-
j.resolve(se).then(function(de) {
|
|
1955
|
-
F || (F = !0, u.resolve(oe, de));
|
|
1956
|
-
}, function(de) {
|
|
1957
|
-
F || (F = !0, u.reject(oe, de));
|
|
1958
|
-
});
|
|
1959
|
-
}
|
|
1960
|
-
}
|
|
1961
|
-
}, { 1: 1 }], 3: [function(r, n, i) {
|
|
1962
|
-
(function(a) {
|
|
1963
|
-
typeof a.Promise != "function" && (a.Promise = r(2));
|
|
1964
|
-
}).call(this, typeof global < "u" ? global : typeof self < "u" ? self : typeof window < "u" ? window : {});
|
|
1965
|
-
}, { 2: 2 }], 4: [function(r, n, i) {
|
|
1966
|
-
var a = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(o) {
|
|
1967
|
-
return typeof o;
|
|
1968
|
-
} : function(o) {
|
|
1969
|
-
return o && typeof Symbol == "function" && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
1970
|
-
};
|
|
1971
|
-
function h(o, s) {
|
|
1972
|
-
if (!(o instanceof s)) throw new TypeError("Cannot call a class as a function");
|
|
1973
|
-
}
|
|
1974
|
-
function u() {
|
|
1975
|
-
try {
|
|
1976
|
-
if (typeof indexedDB < "u") return indexedDB;
|
|
1977
|
-
if (typeof webkitIndexedDB < "u") return webkitIndexedDB;
|
|
1978
|
-
if (typeof mozIndexedDB < "u") return mozIndexedDB;
|
|
1979
|
-
if (typeof OIndexedDB < "u") return OIndexedDB;
|
|
1980
|
-
if (typeof msIndexedDB < "u") return msIndexedDB;
|
|
1981
|
-
} catch {
|
|
1982
|
-
return;
|
|
1983
|
-
}
|
|
1984
|
-
}
|
|
1985
|
-
var y = u();
|
|
1986
|
-
function m() {
|
|
1987
|
-
try {
|
|
1988
|
-
if (!y || !y.open) return !1;
|
|
1989
|
-
var o = typeof openDatabase < "u" && /(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent) && !/BlackBerry/.test(navigator.platform), s = typeof fetch == "function" && fetch.toString().indexOf("[native code") !== -1;
|
|
1990
|
-
return (!o || s) && typeof indexedDB < "u" && typeof IDBKeyRange < "u";
|
|
1991
|
-
} catch {
|
|
1992
|
-
return !1;
|
|
1993
|
-
}
|
|
1994
|
-
}
|
|
1995
|
-
function E(o, s) {
|
|
1996
|
-
o = o || [], s = s || {};
|
|
1997
|
-
try {
|
|
1998
|
-
return new Blob(o, s);
|
|
1999
|
-
} catch (f) {
|
|
2000
|
-
if (f.name !== "TypeError") throw f;
|
|
2001
|
-
for (var c = typeof BlobBuilder < "u" ? BlobBuilder : typeof MSBlobBuilder < "u" ? MSBlobBuilder : typeof MozBlobBuilder < "u" ? MozBlobBuilder : WebKitBlobBuilder, d = new c(), l = 0; l < o.length; l += 1) d.append(o[l]);
|
|
2002
|
-
return d.getBlob(s.type);
|
|
2003
|
-
}
|
|
2004
|
-
}
|
|
2005
|
-
typeof Promise > "u" && r(3);
|
|
2006
|
-
var p = Promise;
|
|
2007
|
-
function S(o, s) {
|
|
2008
|
-
s && o.then(function(c) {
|
|
2009
|
-
s(null, c);
|
|
2010
|
-
}, function(c) {
|
|
2011
|
-
s(c);
|
|
2012
|
-
});
|
|
2013
|
-
}
|
|
2014
|
-
function M(o, s, c) {
|
|
2015
|
-
typeof s == "function" && o.then(s), typeof c == "function" && o.catch(c);
|
|
2016
|
-
}
|
|
2017
|
-
function P(o) {
|
|
2018
|
-
return typeof o != "string" && (console.warn(o + " used as a key, but it is not a string."), o = String(o)), o;
|
|
2019
|
-
}
|
|
2020
|
-
function G() {
|
|
2021
|
-
if (arguments.length && typeof arguments[arguments.length - 1] == "function") return arguments[arguments.length - 1];
|
|
2022
|
-
}
|
|
2023
|
-
var O = "local-forage-detect-blob-support", K = void 0, q = {}, B = Object.prototype.toString, ee = "readonly", N = "readwrite";
|
|
2024
|
-
function j(o) {
|
|
2025
|
-
for (var s = o.length, c = new ArrayBuffer(s), d = new Uint8Array(c), l = 0; l < s; l++) d[l] = o.charCodeAt(l);
|
|
2026
|
-
return c;
|
|
2027
|
-
}
|
|
2028
|
-
function x(o) {
|
|
2029
|
-
return new p(function(s) {
|
|
2030
|
-
var c = o.transaction(O, N), d = E([""]);
|
|
2031
|
-
c.objectStore(O).put(d, "key"), c.onabort = function(l) {
|
|
2032
|
-
l.preventDefault(), l.stopPropagation(), s(!1);
|
|
2033
|
-
}, c.oncomplete = function() {
|
|
2034
|
-
var l = navigator.userAgent.match(/Chrome\/(\d+)/), f = navigator.userAgent.match(/Edge\//);
|
|
2035
|
-
s(f || !l || parseInt(l[1], 10) >= 43);
|
|
2036
|
-
};
|
|
2037
|
-
}).catch(function() {
|
|
2038
|
-
return !1;
|
|
2039
|
-
});
|
|
2040
|
-
}
|
|
2041
|
-
function F(o) {
|
|
2042
|
-
return typeof K == "boolean" ? p.resolve(K) : x(o).then(function(s) {
|
|
2043
|
-
return K = s, K;
|
|
2044
|
-
});
|
|
2045
|
-
}
|
|
2046
|
-
function Z(o) {
|
|
2047
|
-
var s = q[o.name], c = {};
|
|
2048
|
-
c.promise = new p(function(d, l) {
|
|
2049
|
-
c.resolve = d, c.reject = l;
|
|
2050
|
-
}), s.deferredOperations.push(c), s.dbReady ? s.dbReady = s.dbReady.then(function() {
|
|
2051
|
-
return c.promise;
|
|
2052
|
-
}) : s.dbReady = c.promise;
|
|
2053
|
-
}
|
|
2054
|
-
function oe(o) {
|
|
2055
|
-
var s = q[o.name], c = s.deferredOperations.pop();
|
|
2056
|
-
if (c) return c.resolve(), c.promise;
|
|
2057
|
-
}
|
|
2058
|
-
function ae(o, s) {
|
|
2059
|
-
var c = q[o.name], d = c.deferredOperations.pop();
|
|
2060
|
-
if (d) return d.reject(s), d.promise;
|
|
2061
|
-
}
|
|
2062
|
-
function se(o, s) {
|
|
2063
|
-
return new p(function(c, d) {
|
|
2064
|
-
if (q[o.name] = q[o.name] || $(), o.db) if (s) Z(o), o.db.close();
|
|
2065
|
-
else return c(o.db);
|
|
2066
|
-
var l = [o.name];
|
|
2067
|
-
s && l.push(o.version);
|
|
2068
|
-
var f = y.open.apply(y, l);
|
|
2069
|
-
s && (f.onupgradeneeded = function(v) {
|
|
2070
|
-
var w = f.result;
|
|
2071
|
-
try {
|
|
2072
|
-
w.createObjectStore(o.storeName), v.oldVersion <= 1 && w.createObjectStore(O);
|
|
2073
|
-
} catch (R) {
|
|
2074
|
-
if (R.name === "ConstraintError") console.warn('The database "' + o.name + '" has been upgraded from version ' + v.oldVersion + " to version " + v.newVersion + ', but the storage "' + o.storeName + '" already exists.');
|
|
2075
|
-
else throw R;
|
|
2076
|
-
}
|
|
2077
|
-
}), f.onerror = function(v) {
|
|
2078
|
-
v.preventDefault(), d(f.error);
|
|
2079
|
-
}, f.onsuccess = function() {
|
|
2080
|
-
var v = f.result;
|
|
2081
|
-
v.onversionchange = function(w) {
|
|
2082
|
-
w.target.close();
|
|
2083
|
-
}, c(v), oe(o);
|
|
2084
|
-
};
|
|
2085
|
-
});
|
|
2086
|
-
}
|
|
2087
|
-
function de(o) {
|
|
2088
|
-
return se(o, !1);
|
|
2089
|
-
}
|
|
2090
|
-
function Te(o) {
|
|
2091
|
-
return se(o, !0);
|
|
2092
|
-
}
|
|
2093
|
-
function Ce(o, s) {
|
|
2094
|
-
if (!o.db) return !0;
|
|
2095
|
-
var c = !o.db.objectStoreNames.contains(o.storeName), d = o.version < o.db.version, l = o.version > o.db.version;
|
|
2096
|
-
if (d && (o.version !== s && console.warn('The database "' + o.name + `" can't be downgraded from version ` + o.db.version + " to version " + o.version + "."), o.version = o.db.version), l || c) {
|
|
2097
|
-
if (c) {
|
|
2098
|
-
var f = o.db.version + 1;
|
|
2099
|
-
f > o.version && (o.version = f);
|
|
2100
|
-
}
|
|
2101
|
-
return !0;
|
|
2102
|
-
}
|
|
2103
|
-
return !1;
|
|
2104
|
-
}
|
|
2105
|
-
function Ge(o) {
|
|
2106
|
-
return new p(function(s, c) {
|
|
2107
|
-
var d = new FileReader();
|
|
2108
|
-
d.onerror = c, d.onloadend = function(l) {
|
|
2109
|
-
var f = btoa(l.target.result || "");
|
|
2110
|
-
s({ __local_forage_encoded_blob: !0, data: f, type: o.type });
|
|
2111
|
-
}, d.readAsBinaryString(o);
|
|
2112
|
-
});
|
|
2113
|
-
}
|
|
2114
|
-
function we(o) {
|
|
2115
|
-
var s = j(atob(o.data));
|
|
2116
|
-
return E([s], { type: o.type });
|
|
2117
|
-
}
|
|
2118
|
-
function g(o) {
|
|
2119
|
-
return o && o.__local_forage_encoded_blob;
|
|
2120
|
-
}
|
|
2121
|
-
function _(o) {
|
|
2122
|
-
var s = this, c = s._initReady().then(function() {
|
|
2123
|
-
var d = q[s._dbInfo.name];
|
|
2124
|
-
if (d && d.dbReady) return d.dbReady;
|
|
2125
|
-
});
|
|
2126
|
-
return M(c, o, o), c;
|
|
2127
|
-
}
|
|
2128
|
-
function A(o) {
|
|
2129
|
-
Z(o);
|
|
2130
|
-
for (var s = q[o.name], c = s.forages, d = 0; d < c.length; d++) {
|
|
2131
|
-
var l = c[d];
|
|
2132
|
-
l._dbInfo.db && (l._dbInfo.db.close(), l._dbInfo.db = null);
|
|
2133
|
-
}
|
|
2134
|
-
return o.db = null, de(o).then(function(f) {
|
|
2135
|
-
return o.db = f, Ce(o) ? Te(o) : f;
|
|
2136
|
-
}).then(function(f) {
|
|
2137
|
-
o.db = s.db = f;
|
|
2138
|
-
for (var v = 0; v < c.length; v++) c[v]._dbInfo.db = f;
|
|
2139
|
-
}).catch(function(f) {
|
|
2140
|
-
throw ae(o, f), f;
|
|
2141
|
-
});
|
|
2142
|
-
}
|
|
2143
|
-
function T(o, s, c, d) {
|
|
2144
|
-
d === void 0 && (d = 1);
|
|
2145
|
-
try {
|
|
2146
|
-
var l = o.db.transaction(o.storeName, s);
|
|
2147
|
-
c(null, l);
|
|
2148
|
-
} catch (f) {
|
|
2149
|
-
if (d > 0 && (!o.db || f.name === "InvalidStateError" || f.name === "NotFoundError")) return p.resolve().then(function() {
|
|
2150
|
-
if (!o.db || f.name === "NotFoundError" && !o.db.objectStoreNames.contains(o.storeName) && o.version <= o.db.version) return o.db && (o.version = o.db.version + 1), Te(o);
|
|
2151
|
-
}).then(function() {
|
|
2152
|
-
return A(o).then(function() {
|
|
2153
|
-
T(o, s, c, d - 1);
|
|
2154
|
-
});
|
|
2155
|
-
}).catch(c);
|
|
2156
|
-
c(f);
|
|
2157
|
-
}
|
|
2158
|
-
}
|
|
2159
|
-
function $() {
|
|
2160
|
-
return { forages: [], db: null, dbReady: null, deferredOperations: [] };
|
|
2161
|
-
}
|
|
2162
|
-
function k(o) {
|
|
2163
|
-
var s = this, c = { db: null };
|
|
2164
|
-
if (o) for (var d in o) c[d] = o[d];
|
|
2165
|
-
var l = q[c.name];
|
|
2166
|
-
l || (l = $(), q[c.name] = l), l.forages.push(s), s._initReady || (s._initReady = s.ready, s.ready = _);
|
|
2167
|
-
var f = [];
|
|
2168
|
-
function v() {
|
|
2169
|
-
return p.resolve();
|
|
2170
|
-
}
|
|
2171
|
-
for (var w = 0; w < l.forages.length; w++) {
|
|
2172
|
-
var R = l.forages[w];
|
|
2173
|
-
R !== s && f.push(R._initReady().catch(v));
|
|
2174
|
-
}
|
|
2175
|
-
var b = l.forages.slice(0);
|
|
2176
|
-
return p.all(f).then(function() {
|
|
2177
|
-
return c.db = l.db, de(c);
|
|
2178
|
-
}).then(function(I) {
|
|
2179
|
-
return c.db = I, Ce(c, s._defaultConfig.version) ? Te(c) : I;
|
|
2180
|
-
}).then(function(I) {
|
|
2181
|
-
c.db = l.db = I, s._dbInfo = c;
|
|
2182
|
-
for (var L = 0; L < b.length; L++) {
|
|
2183
|
-
var U = b[L];
|
|
2184
|
-
U !== s && (U._dbInfo.db = c.db, U._dbInfo.version = c.version);
|
|
2185
|
-
}
|
|
2186
|
-
});
|
|
2187
|
-
}
|
|
2188
|
-
function Y(o, s) {
|
|
2189
|
-
var c = this;
|
|
2190
|
-
o = P(o);
|
|
2191
|
-
var d = new p(function(l, f) {
|
|
2192
|
-
c.ready().then(function() {
|
|
2193
|
-
T(c._dbInfo, ee, function(v, w) {
|
|
2194
|
-
if (v) return f(v);
|
|
2195
|
-
try {
|
|
2196
|
-
var R = w.objectStore(c._dbInfo.storeName), b = R.get(o);
|
|
2197
|
-
b.onsuccess = function() {
|
|
2198
|
-
var I = b.result;
|
|
2199
|
-
I === void 0 && (I = null), g(I) && (I = we(I)), l(I);
|
|
2200
|
-
}, b.onerror = function() {
|
|
2201
|
-
f(b.error);
|
|
2202
|
-
};
|
|
2203
|
-
} catch (I) {
|
|
2204
|
-
f(I);
|
|
2205
|
-
}
|
|
2206
|
-
});
|
|
2207
|
-
}).catch(f);
|
|
2208
|
-
});
|
|
2209
|
-
return S(d, s), d;
|
|
2210
|
-
}
|
|
2211
|
-
function re(o, s) {
|
|
2212
|
-
var c = this, d = new p(function(l, f) {
|
|
2213
|
-
c.ready().then(function() {
|
|
2214
|
-
T(c._dbInfo, ee, function(v, w) {
|
|
2215
|
-
if (v) return f(v);
|
|
2216
|
-
try {
|
|
2217
|
-
var R = w.objectStore(c._dbInfo.storeName), b = R.openCursor(), I = 1;
|
|
2218
|
-
b.onsuccess = function() {
|
|
2219
|
-
var L = b.result;
|
|
2220
|
-
if (L) {
|
|
2221
|
-
var U = L.value;
|
|
2222
|
-
g(U) && (U = we(U));
|
|
2223
|
-
var H = o(U, L.key, I++);
|
|
2224
|
-
H !== void 0 ? l(H) : L.continue();
|
|
2225
|
-
} else l();
|
|
2226
|
-
}, b.onerror = function() {
|
|
2227
|
-
f(b.error);
|
|
2228
|
-
};
|
|
2229
|
-
} catch (L) {
|
|
2230
|
-
f(L);
|
|
2231
|
-
}
|
|
2232
|
-
});
|
|
2233
|
-
}).catch(f);
|
|
2234
|
-
});
|
|
2235
|
-
return S(d, s), d;
|
|
2236
|
-
}
|
|
2237
|
-
function Pe(o, s, c) {
|
|
2238
|
-
var d = this;
|
|
2239
|
-
o = P(o);
|
|
2240
|
-
var l = new p(function(f, v) {
|
|
2241
|
-
var w;
|
|
2242
|
-
d.ready().then(function() {
|
|
2243
|
-
return w = d._dbInfo, B.call(s) === "[object Blob]" ? F(w.db).then(function(R) {
|
|
2244
|
-
return R ? s : Ge(s);
|
|
2245
|
-
}) : s;
|
|
2246
|
-
}).then(function(R) {
|
|
2247
|
-
T(d._dbInfo, N, function(b, I) {
|
|
2248
|
-
if (b) return v(b);
|
|
2249
|
-
try {
|
|
2250
|
-
var L = I.objectStore(d._dbInfo.storeName);
|
|
2251
|
-
R === null && (R = void 0);
|
|
2252
|
-
var U = L.put(R, o);
|
|
2253
|
-
I.oncomplete = function() {
|
|
2254
|
-
R === void 0 && (R = null), f(R);
|
|
2255
|
-
}, I.onabort = I.onerror = function() {
|
|
2256
|
-
var H = U.error ? U.error : U.transaction.error;
|
|
2257
|
-
v(H);
|
|
2258
|
-
};
|
|
2259
|
-
} catch (H) {
|
|
2260
|
-
v(H);
|
|
2261
|
-
}
|
|
2262
|
-
});
|
|
2263
|
-
}).catch(v);
|
|
2264
|
-
});
|
|
2265
|
-
return S(l, c), l;
|
|
2266
|
-
}
|
|
2267
|
-
function Le(o, s) {
|
|
2268
|
-
var c = this;
|
|
2269
|
-
o = P(o);
|
|
2270
|
-
var d = new p(function(l, f) {
|
|
2271
|
-
c.ready().then(function() {
|
|
2272
|
-
T(c._dbInfo, N, function(v, w) {
|
|
2273
|
-
if (v) return f(v);
|
|
2274
|
-
try {
|
|
2275
|
-
var R = w.objectStore(c._dbInfo.storeName), b = R.delete(o);
|
|
2276
|
-
w.oncomplete = function() {
|
|
2277
|
-
l();
|
|
2278
|
-
}, w.onerror = function() {
|
|
2279
|
-
f(b.error);
|
|
2280
|
-
}, w.onabort = function() {
|
|
2281
|
-
var I = b.error ? b.error : b.transaction.error;
|
|
2282
|
-
f(I);
|
|
2283
|
-
};
|
|
2284
|
-
} catch (I) {
|
|
2285
|
-
f(I);
|
|
2286
|
-
}
|
|
2287
|
-
});
|
|
2288
|
-
}).catch(f);
|
|
2289
|
-
});
|
|
2290
|
-
return S(d, s), d;
|
|
2291
|
-
}
|
|
2292
|
-
function We(o) {
|
|
2293
|
-
var s = this, c = new p(function(d, l) {
|
|
2294
|
-
s.ready().then(function() {
|
|
2295
|
-
T(s._dbInfo, N, function(f, v) {
|
|
2296
|
-
if (f) return l(f);
|
|
2297
|
-
try {
|
|
2298
|
-
var w = v.objectStore(s._dbInfo.storeName), R = w.clear();
|
|
2299
|
-
v.oncomplete = function() {
|
|
2300
|
-
d();
|
|
2301
|
-
}, v.onabort = v.onerror = function() {
|
|
2302
|
-
var b = R.error ? R.error : R.transaction.error;
|
|
2303
|
-
l(b);
|
|
2304
|
-
};
|
|
2305
|
-
} catch (b) {
|
|
2306
|
-
l(b);
|
|
2307
|
-
}
|
|
2308
|
-
});
|
|
2309
|
-
}).catch(l);
|
|
2310
|
-
});
|
|
2311
|
-
return S(c, o), c;
|
|
2312
|
-
}
|
|
2313
|
-
function Jr(o) {
|
|
2314
|
-
var s = this, c = new p(function(d, l) {
|
|
2315
|
-
s.ready().then(function() {
|
|
2316
|
-
T(s._dbInfo, ee, function(f, v) {
|
|
2317
|
-
if (f) return l(f);
|
|
2318
|
-
try {
|
|
2319
|
-
var w = v.objectStore(s._dbInfo.storeName), R = w.count();
|
|
2320
|
-
R.onsuccess = function() {
|
|
2321
|
-
d(R.result);
|
|
2322
|
-
}, R.onerror = function() {
|
|
2323
|
-
l(R.error);
|
|
2324
|
-
};
|
|
2325
|
-
} catch (b) {
|
|
2326
|
-
l(b);
|
|
2327
|
-
}
|
|
2328
|
-
});
|
|
2329
|
-
}).catch(l);
|
|
2330
|
-
});
|
|
2331
|
-
return S(c, o), c;
|
|
2332
|
-
}
|
|
2333
|
-
function Qr(o, s) {
|
|
2334
|
-
var c = this, d = new p(function(l, f) {
|
|
2335
|
-
if (o < 0) {
|
|
2336
|
-
l(null);
|
|
2337
|
-
return;
|
|
2338
|
-
}
|
|
2339
|
-
c.ready().then(function() {
|
|
2340
|
-
T(c._dbInfo, ee, function(v, w) {
|
|
2341
|
-
if (v) return f(v);
|
|
2342
|
-
try {
|
|
2343
|
-
var R = w.objectStore(c._dbInfo.storeName), b = !1, I = R.openKeyCursor();
|
|
2344
|
-
I.onsuccess = function() {
|
|
2345
|
-
var L = I.result;
|
|
2346
|
-
if (!L) {
|
|
2347
|
-
l(null);
|
|
2348
|
-
return;
|
|
2349
|
-
}
|
|
2350
|
-
o === 0 || b ? l(L.key) : (b = !0, L.advance(o));
|
|
2351
|
-
}, I.onerror = function() {
|
|
2352
|
-
f(I.error);
|
|
2353
|
-
};
|
|
2354
|
-
} catch (L) {
|
|
2355
|
-
f(L);
|
|
2356
|
-
}
|
|
2357
|
-
});
|
|
2358
|
-
}).catch(f);
|
|
2359
|
-
});
|
|
2360
|
-
return S(d, s), d;
|
|
2361
|
-
}
|
|
2362
|
-
function Zr(o) {
|
|
2363
|
-
var s = this, c = new p(function(d, l) {
|
|
2364
|
-
s.ready().then(function() {
|
|
2365
|
-
T(s._dbInfo, ee, function(f, v) {
|
|
2366
|
-
if (f) return l(f);
|
|
2367
|
-
try {
|
|
2368
|
-
var w = v.objectStore(s._dbInfo.storeName), R = w.openKeyCursor(), b = [];
|
|
2369
|
-
R.onsuccess = function() {
|
|
2370
|
-
var I = R.result;
|
|
2371
|
-
if (!I) {
|
|
2372
|
-
d(b);
|
|
2373
|
-
return;
|
|
2374
|
-
}
|
|
2375
|
-
b.push(I.key), I.continue();
|
|
2376
|
-
}, R.onerror = function() {
|
|
2377
|
-
l(R.error);
|
|
2378
|
-
};
|
|
2379
|
-
} catch (I) {
|
|
2380
|
-
l(I);
|
|
2381
|
-
}
|
|
2382
|
-
});
|
|
2383
|
-
}).catch(l);
|
|
2384
|
-
});
|
|
2385
|
-
return S(c, o), c;
|
|
2386
|
-
}
|
|
2387
|
-
function en(o, s) {
|
|
2388
|
-
s = G.apply(this, arguments);
|
|
2389
|
-
var c = this.config();
|
|
2390
|
-
o = typeof o != "function" && o || {}, o.name || (o.name = o.name || c.name, o.storeName = o.storeName || c.storeName);
|
|
2391
|
-
var d = this, l;
|
|
2392
|
-
if (!o.name) l = p.reject("Invalid arguments");
|
|
2393
|
-
else {
|
|
2394
|
-
var f = o.name === c.name && d._dbInfo.db, v = f ? p.resolve(d._dbInfo.db) : de(o).then(function(w) {
|
|
2395
|
-
var R = q[o.name], b = R.forages;
|
|
2396
|
-
R.db = w;
|
|
2397
|
-
for (var I = 0; I < b.length; I++) b[I]._dbInfo.db = w;
|
|
2398
|
-
return w;
|
|
2399
|
-
});
|
|
2400
|
-
o.storeName ? l = v.then(function(w) {
|
|
2401
|
-
if (w.objectStoreNames.contains(o.storeName)) {
|
|
2402
|
-
var R = w.version + 1;
|
|
2403
|
-
Z(o);
|
|
2404
|
-
var b = q[o.name], I = b.forages;
|
|
2405
|
-
w.close();
|
|
2406
|
-
for (var L = 0; L < I.length; L++) {
|
|
2407
|
-
var U = I[L];
|
|
2408
|
-
U._dbInfo.db = null, U._dbInfo.version = R;
|
|
2409
|
-
}
|
|
2410
|
-
var H = new p(function(V, Q) {
|
|
2411
|
-
var J = y.open(o.name, R);
|
|
2412
|
-
J.onerror = function(le) {
|
|
2413
|
-
var Nt = J.result;
|
|
2414
|
-
Nt.close(), Q(le);
|
|
2415
|
-
}, J.onupgradeneeded = function() {
|
|
2416
|
-
var le = J.result;
|
|
2417
|
-
le.deleteObjectStore(o.storeName);
|
|
2418
|
-
}, J.onsuccess = function() {
|
|
2419
|
-
var le = J.result;
|
|
2420
|
-
le.close(), V(le);
|
|
2421
|
-
};
|
|
2422
|
-
});
|
|
2423
|
-
return H.then(function(V) {
|
|
2424
|
-
b.db = V;
|
|
2425
|
-
for (var Q = 0; Q < I.length; Q++) {
|
|
2426
|
-
var J = I[Q];
|
|
2427
|
-
J._dbInfo.db = V, oe(J._dbInfo);
|
|
2428
|
-
}
|
|
2429
|
-
}).catch(function(V) {
|
|
2430
|
-
throw (ae(o, V) || p.resolve()).catch(function() {
|
|
2431
|
-
}), V;
|
|
2432
|
-
});
|
|
2433
|
-
}
|
|
2434
|
-
}) : l = v.then(function(w) {
|
|
2435
|
-
Z(o);
|
|
2436
|
-
var R = q[o.name], b = R.forages;
|
|
2437
|
-
w.close();
|
|
2438
|
-
for (var I = 0; I < b.length; I++) {
|
|
2439
|
-
var L = b[I];
|
|
2440
|
-
L._dbInfo.db = null;
|
|
2441
|
-
}
|
|
2442
|
-
var U = new p(function(H, V) {
|
|
2443
|
-
var Q = y.deleteDatabase(o.name);
|
|
2444
|
-
Q.onerror = function() {
|
|
2445
|
-
var J = Q.result;
|
|
2446
|
-
J && J.close(), V(Q.error);
|
|
2447
|
-
}, Q.onblocked = function() {
|
|
2448
|
-
console.warn('dropInstance blocked for database "' + o.name + '" until all open connections are closed');
|
|
2449
|
-
}, Q.onsuccess = function() {
|
|
2450
|
-
var J = Q.result;
|
|
2451
|
-
J && J.close(), H(J);
|
|
2452
|
-
};
|
|
2453
|
-
});
|
|
2454
|
-
return U.then(function(H) {
|
|
2455
|
-
R.db = H;
|
|
2456
|
-
for (var V = 0; V < b.length; V++) {
|
|
2457
|
-
var Q = b[V];
|
|
2458
|
-
oe(Q._dbInfo);
|
|
2459
|
-
}
|
|
2460
|
-
}).catch(function(H) {
|
|
2461
|
-
throw (ae(o, H) || p.resolve()).catch(function() {
|
|
2462
|
-
}), H;
|
|
2463
|
-
});
|
|
2464
|
-
});
|
|
2465
|
-
}
|
|
2466
|
-
return S(l, s), l;
|
|
2467
|
-
}
|
|
2468
|
-
var tn = { _driver: "asyncStorage", _initStorage: k, _support: m(), iterate: re, getItem: Y, setItem: Pe, removeItem: Le, clear: We, length: Jr, key: Qr, keys: Zr, dropInstance: en };
|
|
2469
|
-
function rn() {
|
|
2470
|
-
return typeof openDatabase == "function";
|
|
2471
|
-
}
|
|
2472
|
-
var _e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", nn = "~~local_forage_type~", Wt = /^~~local_forage_type~([^~]+)~/, tt = "__lfsc__:", yt = tt.length, Et = "arbf", wt = "blob", qt = "si08", Bt = "ui08", Vt = "uic8", zt = "si16", Ht = "si32", Xt = "ur16", Kt = "ui32", Yt = "fl32", Jt = "fl64", Qt = yt + Et.length, Zt = Object.prototype.toString;
|
|
2473
|
-
function er(o) {
|
|
2474
|
-
var s = o.length * 0.75, c = o.length, d, l = 0, f, v, w, R;
|
|
2475
|
-
o[o.length - 1] === "=" && (s--, o[o.length - 2] === "=" && s--);
|
|
2476
|
-
var b = new ArrayBuffer(s), I = new Uint8Array(b);
|
|
2477
|
-
for (d = 0; d < c; d += 4) f = _e.indexOf(o[d]), v = _e.indexOf(o[d + 1]), w = _e.indexOf(o[d + 2]), R = _e.indexOf(o[d + 3]), I[l++] = f << 2 | v >> 4, I[l++] = (v & 15) << 4 | w >> 2, I[l++] = (w & 3) << 6 | R & 63;
|
|
2478
|
-
return b;
|
|
2479
|
-
}
|
|
2480
|
-
function _t(o) {
|
|
2481
|
-
var s = new Uint8Array(o), c = "", d;
|
|
2482
|
-
for (d = 0; d < s.length; d += 3) c += _e[s[d] >> 2], c += _e[(s[d] & 3) << 4 | s[d + 1] >> 4], c += _e[(s[d + 1] & 15) << 2 | s[d + 2] >> 6], c += _e[s[d + 2] & 63];
|
|
2483
|
-
return s.length % 3 === 2 ? c = c.substring(0, c.length - 1) + "=" : s.length % 3 === 1 && (c = c.substring(0, c.length - 2) + "=="), c;
|
|
2484
|
-
}
|
|
2485
|
-
function on(o, s) {
|
|
2486
|
-
var c = "";
|
|
2487
|
-
if (o && (c = Zt.call(o)), o && (c === "[object ArrayBuffer]" || o.buffer && Zt.call(o.buffer) === "[object ArrayBuffer]")) {
|
|
2488
|
-
var d, l = tt;
|
|
2489
|
-
o instanceof ArrayBuffer ? (d = o, l += Et) : (d = o.buffer, c === "[object Int8Array]" ? l += qt : c === "[object Uint8Array]" ? l += Bt : c === "[object Uint8ClampedArray]" ? l += Vt : c === "[object Int16Array]" ? l += zt : c === "[object Uint16Array]" ? l += Xt : c === "[object Int32Array]" ? l += Ht : c === "[object Uint32Array]" ? l += Kt : c === "[object Float32Array]" ? l += Yt : c === "[object Float64Array]" ? l += Jt : s(new Error("Failed to get type for BinaryArray"))), s(l + _t(d));
|
|
2490
|
-
} else if (c === "[object Blob]") {
|
|
2491
|
-
var f = new FileReader();
|
|
2492
|
-
f.onload = function() {
|
|
2493
|
-
var v = nn + o.type + "~" + _t(this.result);
|
|
2494
|
-
s(tt + wt + v);
|
|
2495
|
-
}, f.readAsArrayBuffer(o);
|
|
2496
|
-
} else try {
|
|
2497
|
-
s(JSON.stringify(o));
|
|
2498
|
-
} catch (v) {
|
|
2499
|
-
console.error("Couldn't convert value into a JSON string: ", o), s(null, v);
|
|
2500
|
-
}
|
|
2501
|
-
}
|
|
2502
|
-
function an(o) {
|
|
2503
|
-
if (o.substring(0, yt) !== tt) return JSON.parse(o);
|
|
2504
|
-
var s = o.substring(Qt), c = o.substring(yt, Qt), d;
|
|
2505
|
-
if (c === wt && Wt.test(s)) {
|
|
2506
|
-
var l = s.match(Wt);
|
|
2507
|
-
d = l[1], s = s.substring(l[0].length);
|
|
2508
|
-
}
|
|
2509
|
-
var f = er(s);
|
|
2510
|
-
switch (c) {
|
|
2511
|
-
case Et:
|
|
2512
|
-
return f;
|
|
2513
|
-
case wt:
|
|
2514
|
-
return E([f], { type: d });
|
|
2515
|
-
case qt:
|
|
2516
|
-
return new Int8Array(f);
|
|
2517
|
-
case Bt:
|
|
2518
|
-
return new Uint8Array(f);
|
|
2519
|
-
case Vt:
|
|
2520
|
-
return new Uint8ClampedArray(f);
|
|
2521
|
-
case zt:
|
|
2522
|
-
return new Int16Array(f);
|
|
2523
|
-
case Xt:
|
|
2524
|
-
return new Uint16Array(f);
|
|
2525
|
-
case Ht:
|
|
2526
|
-
return new Int32Array(f);
|
|
2527
|
-
case Kt:
|
|
2528
|
-
return new Uint32Array(f);
|
|
2529
|
-
case Yt:
|
|
2530
|
-
return new Float32Array(f);
|
|
2531
|
-
case Jt:
|
|
2532
|
-
return new Float64Array(f);
|
|
2533
|
-
default:
|
|
2534
|
-
throw new Error("Unkown type: " + c);
|
|
2535
|
-
}
|
|
2536
|
-
}
|
|
2537
|
-
var It = { serialize: on, deserialize: an, stringToBuffer: er, bufferToString: _t };
|
|
2538
|
-
function tr(o, s, c, d) {
|
|
2539
|
-
o.executeSql("CREATE TABLE IF NOT EXISTS " + s.storeName + " (id INTEGER PRIMARY KEY, key unique, value)", [], c, d);
|
|
2540
|
-
}
|
|
2541
|
-
function sn(o) {
|
|
2542
|
-
var s = this, c = { db: null };
|
|
2543
|
-
if (o) for (var d in o) c[d] = typeof o[d] != "string" ? o[d].toString() : o[d];
|
|
2544
|
-
var l = new p(function(f, v) {
|
|
2545
|
-
try {
|
|
2546
|
-
c.db = openDatabase(c.name, String(c.version), c.description, c.size);
|
|
2547
|
-
} catch (w) {
|
|
2548
|
-
return v(w);
|
|
2549
|
-
}
|
|
2550
|
-
c.db.transaction(function(w) {
|
|
2551
|
-
tr(w, c, function() {
|
|
2552
|
-
s._dbInfo = c, f();
|
|
2553
|
-
}, function(R, b) {
|
|
2554
|
-
v(b);
|
|
2555
|
-
});
|
|
2556
|
-
}, v);
|
|
2557
|
-
});
|
|
2558
|
-
return c.serializer = It, l;
|
|
2559
|
-
}
|
|
2560
|
-
function Ie(o, s, c, d, l, f) {
|
|
2561
|
-
o.executeSql(c, d, l, function(v, w) {
|
|
2562
|
-
w.code === w.SYNTAX_ERR ? v.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?", [s.storeName], function(R, b) {
|
|
2563
|
-
b.rows.length ? f(R, w) : tr(R, s, function() {
|
|
2564
|
-
R.executeSql(c, d, l, f);
|
|
2565
|
-
}, f);
|
|
2566
|
-
}, f) : f(v, w);
|
|
2567
|
-
}, f);
|
|
2568
|
-
}
|
|
2569
|
-
function cn(o, s) {
|
|
2570
|
-
var c = this;
|
|
2571
|
-
o = P(o);
|
|
2572
|
-
var d = new p(function(l, f) {
|
|
2573
|
-
c.ready().then(function() {
|
|
2574
|
-
var v = c._dbInfo;
|
|
2575
|
-
v.db.transaction(function(w) {
|
|
2576
|
-
Ie(w, v, "SELECT * FROM " + v.storeName + " WHERE key = ? LIMIT 1", [o], function(R, b) {
|
|
2577
|
-
var I = b.rows.length ? b.rows.item(0).value : null;
|
|
2578
|
-
I && (I = v.serializer.deserialize(I)), l(I);
|
|
2579
|
-
}, function(R, b) {
|
|
2580
|
-
f(b);
|
|
2581
|
-
});
|
|
2582
|
-
});
|
|
2583
|
-
}).catch(f);
|
|
2584
|
-
});
|
|
2585
|
-
return S(d, s), d;
|
|
2586
|
-
}
|
|
2587
|
-
function ln(o, s) {
|
|
2588
|
-
var c = this, d = new p(function(l, f) {
|
|
2589
|
-
c.ready().then(function() {
|
|
2590
|
-
var v = c._dbInfo;
|
|
2591
|
-
v.db.transaction(function(w) {
|
|
2592
|
-
Ie(w, v, "SELECT * FROM " + v.storeName, [], function(R, b) {
|
|
2593
|
-
for (var I = b.rows, L = I.length, U = 0; U < L; U++) {
|
|
2594
|
-
var H = I.item(U), V = H.value;
|
|
2595
|
-
if (V && (V = v.serializer.deserialize(V)), V = o(V, H.key, U + 1), V !== void 0) {
|
|
2596
|
-
l(V);
|
|
2597
|
-
return;
|
|
2598
|
-
}
|
|
2599
|
-
}
|
|
2600
|
-
l();
|
|
2601
|
-
}, function(R, b) {
|
|
2602
|
-
f(b);
|
|
2603
|
-
});
|
|
2604
|
-
});
|
|
2605
|
-
}).catch(f);
|
|
2606
|
-
});
|
|
2607
|
-
return S(d, s), d;
|
|
2608
|
-
}
|
|
2609
|
-
function rr(o, s, c, d) {
|
|
2610
|
-
var l = this;
|
|
2611
|
-
o = P(o);
|
|
2612
|
-
var f = new p(function(v, w) {
|
|
2613
|
-
l.ready().then(function() {
|
|
2614
|
-
s === void 0 && (s = null);
|
|
2615
|
-
var R = s, b = l._dbInfo;
|
|
2616
|
-
b.serializer.serialize(s, function(I, L) {
|
|
2617
|
-
L ? w(L) : b.db.transaction(function(U) {
|
|
2618
|
-
Ie(U, b, "INSERT OR REPLACE INTO " + b.storeName + " (key, value) VALUES (?, ?)", [o, I], function() {
|
|
2619
|
-
v(R);
|
|
2620
|
-
}, function(H, V) {
|
|
2621
|
-
w(V);
|
|
2622
|
-
});
|
|
2623
|
-
}, function(U) {
|
|
2624
|
-
if (U.code === U.QUOTA_ERR) {
|
|
2625
|
-
if (d > 0) {
|
|
2626
|
-
v(rr.apply(l, [o, R, c, d - 1]));
|
|
2627
|
-
return;
|
|
2628
|
-
}
|
|
2629
|
-
w(U);
|
|
2630
|
-
}
|
|
2631
|
-
});
|
|
2632
|
-
});
|
|
2633
|
-
}).catch(w);
|
|
2634
|
-
});
|
|
2635
|
-
return S(f, c), f;
|
|
2636
|
-
}
|
|
2637
|
-
function un(o, s, c) {
|
|
2638
|
-
return rr.apply(this, [o, s, c, 1]);
|
|
2639
|
-
}
|
|
2640
|
-
function dn(o, s) {
|
|
2641
|
-
var c = this;
|
|
2642
|
-
o = P(o);
|
|
2643
|
-
var d = new p(function(l, f) {
|
|
2644
|
-
c.ready().then(function() {
|
|
2645
|
-
var v = c._dbInfo;
|
|
2646
|
-
v.db.transaction(function(w) {
|
|
2647
|
-
Ie(w, v, "DELETE FROM " + v.storeName + " WHERE key = ?", [o], function() {
|
|
2648
|
-
l();
|
|
2649
|
-
}, function(R, b) {
|
|
2650
|
-
f(b);
|
|
2651
|
-
});
|
|
2652
|
-
});
|
|
2653
|
-
}).catch(f);
|
|
2654
|
-
});
|
|
2655
|
-
return S(d, s), d;
|
|
2656
|
-
}
|
|
2657
|
-
function fn(o) {
|
|
2658
|
-
var s = this, c = new p(function(d, l) {
|
|
2659
|
-
s.ready().then(function() {
|
|
2660
|
-
var f = s._dbInfo;
|
|
2661
|
-
f.db.transaction(function(v) {
|
|
2662
|
-
Ie(v, f, "DELETE FROM " + f.storeName, [], function() {
|
|
2663
|
-
d();
|
|
2664
|
-
}, function(w, R) {
|
|
2665
|
-
l(R);
|
|
2666
|
-
});
|
|
2667
|
-
});
|
|
2668
|
-
}).catch(l);
|
|
2669
|
-
});
|
|
2670
|
-
return S(c, o), c;
|
|
2671
|
-
}
|
|
2672
|
-
function hn(o) {
|
|
2673
|
-
var s = this, c = new p(function(d, l) {
|
|
2674
|
-
s.ready().then(function() {
|
|
2675
|
-
var f = s._dbInfo;
|
|
2676
|
-
f.db.transaction(function(v) {
|
|
2677
|
-
Ie(v, f, "SELECT COUNT(key) as c FROM " + f.storeName, [], function(w, R) {
|
|
2678
|
-
var b = R.rows.item(0).c;
|
|
2679
|
-
d(b);
|
|
2680
|
-
}, function(w, R) {
|
|
2681
|
-
l(R);
|
|
2682
|
-
});
|
|
2683
|
-
});
|
|
2684
|
-
}).catch(l);
|
|
2685
|
-
});
|
|
2686
|
-
return S(c, o), c;
|
|
2687
|
-
}
|
|
2688
|
-
function pn(o, s) {
|
|
2689
|
-
var c = this, d = new p(function(l, f) {
|
|
2690
|
-
c.ready().then(function() {
|
|
2691
|
-
var v = c._dbInfo;
|
|
2692
|
-
v.db.transaction(function(w) {
|
|
2693
|
-
Ie(w, v, "SELECT key FROM " + v.storeName + " WHERE id = ? LIMIT 1", [o + 1], function(R, b) {
|
|
2694
|
-
var I = b.rows.length ? b.rows.item(0).key : null;
|
|
2695
|
-
l(I);
|
|
2696
|
-
}, function(R, b) {
|
|
2697
|
-
f(b);
|
|
2698
|
-
});
|
|
2699
|
-
});
|
|
2700
|
-
}).catch(f);
|
|
2701
|
-
});
|
|
2702
|
-
return S(d, s), d;
|
|
2703
|
-
}
|
|
2704
|
-
function mn(o) {
|
|
2705
|
-
var s = this, c = new p(function(d, l) {
|
|
2706
|
-
s.ready().then(function() {
|
|
2707
|
-
var f = s._dbInfo;
|
|
2708
|
-
f.db.transaction(function(v) {
|
|
2709
|
-
Ie(v, f, "SELECT key FROM " + f.storeName, [], function(w, R) {
|
|
2710
|
-
for (var b = [], I = 0; I < R.rows.length; I++) b.push(R.rows.item(I).key);
|
|
2711
|
-
d(b);
|
|
2712
|
-
}, function(w, R) {
|
|
2713
|
-
l(R);
|
|
2714
|
-
});
|
|
2715
|
-
});
|
|
2716
|
-
}).catch(l);
|
|
2717
|
-
});
|
|
2718
|
-
return S(c, o), c;
|
|
2719
|
-
}
|
|
2720
|
-
function gn(o) {
|
|
2721
|
-
return new p(function(s, c) {
|
|
2722
|
-
o.transaction(function(d) {
|
|
2723
|
-
d.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'", [], function(l, f) {
|
|
2724
|
-
for (var v = [], w = 0; w < f.rows.length; w++) v.push(f.rows.item(w).name);
|
|
2725
|
-
s({ db: o, storeNames: v });
|
|
2726
|
-
}, function(l, f) {
|
|
2727
|
-
c(f);
|
|
2728
|
-
});
|
|
2729
|
-
}, function(d) {
|
|
2730
|
-
c(d);
|
|
2731
|
-
});
|
|
2732
|
-
});
|
|
2733
|
-
}
|
|
2734
|
-
function vn(o, s) {
|
|
2735
|
-
s = G.apply(this, arguments);
|
|
2736
|
-
var c = this.config();
|
|
2737
|
-
o = typeof o != "function" && o || {}, o.name || (o.name = o.name || c.name, o.storeName = o.storeName || c.storeName);
|
|
2738
|
-
var d = this, l;
|
|
2739
|
-
return o.name ? l = new p(function(f) {
|
|
2740
|
-
var v;
|
|
2741
|
-
o.name === c.name ? v = d._dbInfo.db : v = openDatabase(o.name, "", "", 0), o.storeName ? f({ db: v, storeNames: [o.storeName] }) : f(gn(v));
|
|
2742
|
-
}).then(function(f) {
|
|
2743
|
-
return new p(function(v, w) {
|
|
2744
|
-
f.db.transaction(function(R) {
|
|
2745
|
-
function b(H) {
|
|
2746
|
-
return new p(function(V, Q) {
|
|
2747
|
-
R.executeSql("DROP TABLE IF EXISTS " + H, [], function() {
|
|
2748
|
-
V();
|
|
2749
|
-
}, function(J, le) {
|
|
2750
|
-
Q(le);
|
|
2751
|
-
});
|
|
2752
|
-
});
|
|
2753
|
-
}
|
|
2754
|
-
for (var I = [], L = 0, U = f.storeNames.length; L < U; L++) I.push(b(f.storeNames[L]));
|
|
2755
|
-
p.all(I).then(function() {
|
|
2756
|
-
v();
|
|
2757
|
-
}).catch(function(H) {
|
|
2758
|
-
w(H);
|
|
2759
|
-
});
|
|
2760
|
-
}, function(R) {
|
|
2761
|
-
w(R);
|
|
2762
|
-
});
|
|
2763
|
-
});
|
|
2764
|
-
}) : l = p.reject("Invalid arguments"), S(l, s), l;
|
|
2765
|
-
}
|
|
2766
|
-
var yn = { _driver: "webSQLStorage", _initStorage: sn, _support: rn(), iterate: ln, getItem: cn, setItem: un, removeItem: dn, clear: fn, length: hn, key: pn, keys: mn, dropInstance: vn };
|
|
2767
|
-
function En() {
|
|
2768
|
-
try {
|
|
2769
|
-
return typeof localStorage < "u" && "setItem" in localStorage && !!localStorage.setItem;
|
|
2770
|
-
} catch {
|
|
2771
|
-
return !1;
|
|
2772
|
-
}
|
|
2773
|
-
}
|
|
2774
|
-
function nr(o, s) {
|
|
2775
|
-
var c = o.name + "/";
|
|
2776
|
-
return o.storeName !== s.storeName && (c += o.storeName + "/"), c;
|
|
2777
|
-
}
|
|
2778
|
-
function wn() {
|
|
2779
|
-
var o = "_localforage_support_test";
|
|
2780
|
-
try {
|
|
2781
|
-
return localStorage.setItem(o, !0), localStorage.removeItem(o), !1;
|
|
2782
|
-
} catch {
|
|
2783
|
-
return !0;
|
|
2784
|
-
}
|
|
2785
|
-
}
|
|
2786
|
-
function _n() {
|
|
2787
|
-
return !wn() || localStorage.length > 0;
|
|
2788
|
-
}
|
|
2789
|
-
function In(o) {
|
|
2790
|
-
var s = this, c = {};
|
|
2791
|
-
if (o) for (var d in o) c[d] = o[d];
|
|
2792
|
-
return c.keyPrefix = nr(o, s._defaultConfig), _n() ? (s._dbInfo = c, c.serializer = It, p.resolve()) : p.reject();
|
|
2793
|
-
}
|
|
2794
|
-
function bn(o) {
|
|
2795
|
-
var s = this, c = s.ready().then(function() {
|
|
2796
|
-
for (var d = s._dbInfo.keyPrefix, l = localStorage.length - 1; l >= 0; l--) {
|
|
2797
|
-
var f = localStorage.key(l);
|
|
2798
|
-
f.indexOf(d) === 0 && localStorage.removeItem(f);
|
|
2799
|
-
}
|
|
2800
|
-
});
|
|
2801
|
-
return S(c, o), c;
|
|
2802
|
-
}
|
|
2803
|
-
function Rn(o, s) {
|
|
2804
|
-
var c = this;
|
|
2805
|
-
o = P(o);
|
|
2806
|
-
var d = c.ready().then(function() {
|
|
2807
|
-
var l = c._dbInfo, f = localStorage.getItem(l.keyPrefix + o);
|
|
2808
|
-
return f && (f = l.serializer.deserialize(f)), f;
|
|
2809
|
-
});
|
|
2810
|
-
return S(d, s), d;
|
|
2811
|
-
}
|
|
2812
|
-
function Nn(o, s) {
|
|
2813
|
-
var c = this, d = c.ready().then(function() {
|
|
2814
|
-
for (var l = c._dbInfo, f = l.keyPrefix, v = f.length, w = localStorage.length, R = 1, b = 0; b < w; b++) {
|
|
2815
|
-
var I = localStorage.key(b);
|
|
2816
|
-
if (I.indexOf(f) === 0) {
|
|
2817
|
-
var L = localStorage.getItem(I);
|
|
2818
|
-
if (L && (L = l.serializer.deserialize(L)), L = o(L, I.substring(v), R++), L !== void 0) return L;
|
|
2819
|
-
}
|
|
2820
|
-
}
|
|
2821
|
-
});
|
|
2822
|
-
return S(d, s), d;
|
|
2823
|
-
}
|
|
2824
|
-
function Sn(o, s) {
|
|
2825
|
-
var c = this, d = c.ready().then(function() {
|
|
2826
|
-
var l = c._dbInfo, f;
|
|
2827
|
-
try {
|
|
2828
|
-
f = localStorage.key(o);
|
|
2829
|
-
} catch {
|
|
2830
|
-
f = null;
|
|
2831
|
-
}
|
|
2832
|
-
return f && (f = f.substring(l.keyPrefix.length)), f;
|
|
2833
|
-
});
|
|
2834
|
-
return S(d, s), d;
|
|
2835
|
-
}
|
|
2836
|
-
function An(o) {
|
|
2837
|
-
var s = this, c = s.ready().then(function() {
|
|
2838
|
-
for (var d = s._dbInfo, l = localStorage.length, f = [], v = 0; v < l; v++) {
|
|
2839
|
-
var w = localStorage.key(v);
|
|
2840
|
-
w.indexOf(d.keyPrefix) === 0 && f.push(w.substring(d.keyPrefix.length));
|
|
2841
|
-
}
|
|
2842
|
-
return f;
|
|
2843
|
-
});
|
|
2844
|
-
return S(c, o), c;
|
|
2845
|
-
}
|
|
2846
|
-
function On(o) {
|
|
2847
|
-
var s = this, c = s.keys().then(function(d) {
|
|
2848
|
-
return d.length;
|
|
2849
|
-
});
|
|
2850
|
-
return S(c, o), c;
|
|
2851
|
-
}
|
|
2852
|
-
function Tn(o, s) {
|
|
2853
|
-
var c = this;
|
|
2854
|
-
o = P(o);
|
|
2855
|
-
var d = c.ready().then(function() {
|
|
2856
|
-
var l = c._dbInfo;
|
|
2857
|
-
localStorage.removeItem(l.keyPrefix + o);
|
|
2858
|
-
});
|
|
2859
|
-
return S(d, s), d;
|
|
2860
|
-
}
|
|
2861
|
-
function Ln(o, s, c) {
|
|
2862
|
-
var d = this;
|
|
2863
|
-
o = P(o);
|
|
2864
|
-
var l = d.ready().then(function() {
|
|
2865
|
-
s === void 0 && (s = null);
|
|
2866
|
-
var f = s;
|
|
2867
|
-
return new p(function(v, w) {
|
|
2868
|
-
var R = d._dbInfo;
|
|
2869
|
-
R.serializer.serialize(s, function(b, I) {
|
|
2870
|
-
if (I) w(I);
|
|
2871
|
-
else try {
|
|
2872
|
-
localStorage.setItem(R.keyPrefix + o, b), v(f);
|
|
2873
|
-
} catch (L) {
|
|
2874
|
-
(L.name === "QuotaExceededError" || L.name === "NS_ERROR_DOM_QUOTA_REACHED") && w(L), w(L);
|
|
2875
|
-
}
|
|
2876
|
-
});
|
|
2877
|
-
});
|
|
2878
|
-
});
|
|
2879
|
-
return S(l, c), l;
|
|
2880
|
-
}
|
|
2881
|
-
function $n(o, s) {
|
|
2882
|
-
if (s = G.apply(this, arguments), o = typeof o != "function" && o || {}, !o.name) {
|
|
2883
|
-
var c = this.config();
|
|
2884
|
-
o.name = o.name || c.name, o.storeName = o.storeName || c.storeName;
|
|
2885
|
-
}
|
|
2886
|
-
var d = this, l;
|
|
2887
|
-
return o.name ? l = new p(function(f) {
|
|
2888
|
-
o.storeName ? f(nr(o, d._defaultConfig)) : f(o.name + "/");
|
|
2889
|
-
}).then(function(f) {
|
|
2890
|
-
for (var v = localStorage.length - 1; v >= 0; v--) {
|
|
2891
|
-
var w = localStorage.key(v);
|
|
2892
|
-
w.indexOf(f) === 0 && localStorage.removeItem(w);
|
|
2893
|
-
}
|
|
2894
|
-
}) : l = p.reject("Invalid arguments"), S(l, s), l;
|
|
2895
|
-
}
|
|
2896
|
-
var Mn = { _driver: "localStorageWrapper", _initStorage: In, _support: En(), iterate: Nn, getItem: Rn, setItem: Ln, removeItem: Tn, clear: bn, length: On, key: Sn, keys: An, dropInstance: $n }, Cn = function(o, s) {
|
|
2897
|
-
return o === s || typeof o == "number" && typeof s == "number" && isNaN(o) && isNaN(s);
|
|
2898
|
-
}, Pn = function(o, s) {
|
|
2899
|
-
for (var c = o.length, d = 0; d < c; ) {
|
|
2900
|
-
if (Cn(o[d], s)) return !0;
|
|
2901
|
-
d++;
|
|
2902
|
-
}
|
|
2903
|
-
return !1;
|
|
2904
|
-
}, or = Array.isArray || function(o) {
|
|
2905
|
-
return Object.prototype.toString.call(o) === "[object Array]";
|
|
2906
|
-
}, qe = {}, ir = {}, ke = { INDEXEDDB: tn, WEBSQL: yn, LOCALSTORAGE: Mn }, kn = [ke.INDEXEDDB._driver, ke.WEBSQL._driver, ke.LOCALSTORAGE._driver], rt = ["dropInstance"], bt = ["clear", "getItem", "iterate", "key", "keys", "length", "removeItem", "setItem"].concat(rt), Dn = { description: "", driver: kn.slice(), name: "localforage", size: 4980736, storeName: "keyvaluepairs", version: 1 };
|
|
2907
|
-
function xn(o, s) {
|
|
2908
|
-
o[s] = function() {
|
|
2909
|
-
var c = arguments;
|
|
2910
|
-
return o.ready().then(function() {
|
|
2911
|
-
return o[s].apply(o, c);
|
|
2912
|
-
});
|
|
2913
|
-
};
|
|
2914
|
-
}
|
|
2915
|
-
function Rt() {
|
|
2916
|
-
for (var o = 1; o < arguments.length; o++) {
|
|
2917
|
-
var s = arguments[o];
|
|
2918
|
-
if (s) for (var c in s) s.hasOwnProperty(c) && (or(s[c]) ? arguments[0][c] = s[c].slice() : arguments[0][c] = s[c]);
|
|
2919
|
-
}
|
|
2920
|
-
return arguments[0];
|
|
2921
|
-
}
|
|
2922
|
-
var Un = (function() {
|
|
2923
|
-
function o(s) {
|
|
2924
|
-
h(this, o);
|
|
2925
|
-
for (var c in ke) if (ke.hasOwnProperty(c)) {
|
|
2926
|
-
var d = ke[c], l = d._driver;
|
|
2927
|
-
this[c] = l, qe[l] || this.defineDriver(d);
|
|
2928
|
-
}
|
|
2929
|
-
this._defaultConfig = Rt({}, Dn), this._config = Rt({}, this._defaultConfig, s), this._driverSet = null, this._initDriver = null, this._ready = !1, this._dbInfo = null, this._wrapLibraryMethodsWithReady(), this.setDriver(this._config.driver).catch(function() {
|
|
2930
|
-
});
|
|
2931
|
-
}
|
|
2932
|
-
return o.prototype.config = function(s) {
|
|
2933
|
-
if ((typeof s > "u" ? "undefined" : a(s)) === "object") {
|
|
2934
|
-
if (this._ready) return new Error("Can't call config() after localforage has been used.");
|
|
2935
|
-
for (var c in s) {
|
|
2936
|
-
if (c === "storeName" && (s[c] = s[c].replace(/\W/g, "_")), c === "version" && typeof s[c] != "number") return new Error("Database version must be a number.");
|
|
2937
|
-
this._config[c] = s[c];
|
|
2938
|
-
}
|
|
2939
|
-
return "driver" in s && s.driver ? this.setDriver(this._config.driver) : !0;
|
|
2940
|
-
} else return typeof s == "string" ? this._config[s] : this._config;
|
|
2941
|
-
}, o.prototype.defineDriver = function(s, c, d) {
|
|
2942
|
-
var l = new p(function(f, v) {
|
|
2943
|
-
try {
|
|
2944
|
-
var w = s._driver, R = new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");
|
|
2945
|
-
if (!s._driver) {
|
|
2946
|
-
v(R);
|
|
2947
|
-
return;
|
|
2948
|
-
}
|
|
2949
|
-
for (var b = bt.concat("_initStorage"), I = 0, L = b.length; I < L; I++) {
|
|
2950
|
-
var U = b[I], H = !Pn(rt, U);
|
|
2951
|
-
if ((H || s[U]) && typeof s[U] != "function") {
|
|
2952
|
-
v(R);
|
|
2953
|
-
return;
|
|
2954
|
-
}
|
|
2955
|
-
}
|
|
2956
|
-
var V = function() {
|
|
2957
|
-
for (var J = function(Fn) {
|
|
2958
|
-
return function() {
|
|
2959
|
-
var Gn = new Error("Method " + Fn + " is not implemented by the current driver"), ar = p.reject(Gn);
|
|
2960
|
-
return S(ar, arguments[arguments.length - 1]), ar;
|
|
2961
|
-
};
|
|
2962
|
-
}, le = 0, Nt = rt.length; le < Nt; le++) {
|
|
2963
|
-
var St = rt[le];
|
|
2964
|
-
s[St] || (s[St] = J(St));
|
|
2965
|
-
}
|
|
2966
|
-
};
|
|
2967
|
-
V();
|
|
2968
|
-
var Q = function(J) {
|
|
2969
|
-
qe[w] && console.info("Redefining LocalForage driver: " + w), qe[w] = s, ir[w] = J, f();
|
|
2970
|
-
};
|
|
2971
|
-
"_support" in s ? s._support && typeof s._support == "function" ? s._support().then(Q, v) : Q(!!s._support) : Q(!0);
|
|
2972
|
-
} catch (J) {
|
|
2973
|
-
v(J);
|
|
2974
|
-
}
|
|
2975
|
-
});
|
|
2976
|
-
return M(l, c, d), l;
|
|
2977
|
-
}, o.prototype.driver = function() {
|
|
2978
|
-
return this._driver || null;
|
|
2979
|
-
}, o.prototype.getDriver = function(s, c, d) {
|
|
2980
|
-
var l = qe[s] ? p.resolve(qe[s]) : p.reject(new Error("Driver not found."));
|
|
2981
|
-
return M(l, c, d), l;
|
|
2982
|
-
}, o.prototype.getSerializer = function(s) {
|
|
2983
|
-
var c = p.resolve(It);
|
|
2984
|
-
return M(c, s), c;
|
|
2985
|
-
}, o.prototype.ready = function(s) {
|
|
2986
|
-
var c = this, d = c._driverSet.then(function() {
|
|
2987
|
-
return c._ready === null && (c._ready = c._initDriver()), c._ready;
|
|
2988
|
-
});
|
|
2989
|
-
return M(d, s, s), d;
|
|
2990
|
-
}, o.prototype.setDriver = function(s, c, d) {
|
|
2991
|
-
var l = this;
|
|
2992
|
-
or(s) || (s = [s]);
|
|
2993
|
-
var f = this._getSupportedDrivers(s);
|
|
2994
|
-
function v() {
|
|
2995
|
-
l._config.driver = l.driver();
|
|
2996
|
-
}
|
|
2997
|
-
function w(I) {
|
|
2998
|
-
return l._extend(I), v(), l._ready = l._initStorage(l._config), l._ready;
|
|
2999
|
-
}
|
|
3000
|
-
function R(I) {
|
|
3001
|
-
return function() {
|
|
3002
|
-
var L = 0;
|
|
3003
|
-
function U() {
|
|
3004
|
-
for (; L < I.length; ) {
|
|
3005
|
-
var H = I[L];
|
|
3006
|
-
return L++, l._dbInfo = null, l._ready = null, l.getDriver(H).then(w).catch(U);
|
|
3007
|
-
}
|
|
3008
|
-
v();
|
|
3009
|
-
var V = new Error("No available storage method found.");
|
|
3010
|
-
return l._driverSet = p.reject(V), l._driverSet;
|
|
3011
|
-
}
|
|
3012
|
-
return U();
|
|
3013
|
-
};
|
|
3014
|
-
}
|
|
3015
|
-
var b = this._driverSet !== null ? this._driverSet.catch(function() {
|
|
3016
|
-
return p.resolve();
|
|
3017
|
-
}) : p.resolve();
|
|
3018
|
-
return this._driverSet = b.then(function() {
|
|
3019
|
-
var I = f[0];
|
|
3020
|
-
return l._dbInfo = null, l._ready = null, l.getDriver(I).then(function(L) {
|
|
3021
|
-
l._driver = L._driver, v(), l._wrapLibraryMethodsWithReady(), l._initDriver = R(f);
|
|
3022
|
-
});
|
|
3023
|
-
}).catch(function() {
|
|
3024
|
-
v();
|
|
3025
|
-
var I = new Error("No available storage method found.");
|
|
3026
|
-
return l._driverSet = p.reject(I), l._driverSet;
|
|
3027
|
-
}), M(this._driverSet, c, d), this._driverSet;
|
|
3028
|
-
}, o.prototype.supports = function(s) {
|
|
3029
|
-
return !!ir[s];
|
|
3030
|
-
}, o.prototype._extend = function(s) {
|
|
3031
|
-
Rt(this, s);
|
|
3032
|
-
}, o.prototype._getSupportedDrivers = function(s) {
|
|
3033
|
-
for (var c = [], d = 0, l = s.length; d < l; d++) {
|
|
3034
|
-
var f = s[d];
|
|
3035
|
-
this.supports(f) && c.push(f);
|
|
3036
|
-
}
|
|
3037
|
-
return c;
|
|
3038
|
-
}, o.prototype._wrapLibraryMethodsWithReady = function() {
|
|
3039
|
-
for (var s = 0, c = bt.length; s < c; s++) xn(this, bt[s]);
|
|
3040
|
-
}, o.prototype.createInstance = function(s) {
|
|
3041
|
-
return new o(s);
|
|
3042
|
-
}, o;
|
|
3043
|
-
})(), jn = new Un();
|
|
3044
|
-
n.exports = jn;
|
|
3045
|
-
}, { 3: 3 }] }, {}, [4])(4);
|
|
3046
|
-
});
|
|
3047
|
-
}), za = Xr((e, t) => {
|
|
3048
|
-
(function(r, n) {
|
|
3049
|
-
typeof e == "object" && typeof t < "u" ? n(e) : typeof define == "function" && define.amd ? define("localforage-driver-memory", ["exports"], n) : n(r.LocalforageDriverMemory = {});
|
|
3050
|
-
})(typeof self < "u" ? self : e, function(r) {
|
|
3051
|
-
var n = "localforage-driver-memory";
|
|
3052
|
-
function i(g) {
|
|
3053
|
-
var _ = typeof Symbol == "function" && g[Symbol.iterator], A = 0;
|
|
3054
|
-
return _ ? _.call(g) : { next: function() {
|
|
3055
|
-
return g && A >= g.length && (g = void 0), { value: g && g[A++], done: !g };
|
|
3056
|
-
} };
|
|
3057
|
-
}
|
|
3058
|
-
function a(g, _) {
|
|
3059
|
-
g = g || [], _ = _ || {};
|
|
3060
|
-
try {
|
|
3061
|
-
return new Blob(g, _);
|
|
3062
|
-
} catch (k) {
|
|
3063
|
-
if (k.name !== "TypeError") throw k;
|
|
3064
|
-
for (var A = typeof BlobBuilder < "u" ? BlobBuilder : typeof MSBlobBuilder < "u" ? MSBlobBuilder : typeof MozBlobBuilder < "u" ? MozBlobBuilder : WebKitBlobBuilder, T = new A(), $ = 0; $ < g.length; $ += 1) T.append(g[$]);
|
|
3065
|
-
return T.getBlob(_.type);
|
|
3066
|
-
}
|
|
3067
|
-
}
|
|
3068
|
-
var h = /^~~local_forage_type~([^~]+)~/, u = 9, y = u + 4, m = Object.prototype.toString;
|
|
3069
|
-
function E(g) {
|
|
3070
|
-
var _ = g.length * 0.75, A = g.length;
|
|
3071
|
-
g[g.length - 1] === "=" && (_--, g[g.length - 2] === "=" && _--);
|
|
3072
|
-
for (var T = new ArrayBuffer(_), $ = new Uint8Array(T), k = 0, Y = 0; k < A; k += 4) {
|
|
3073
|
-
var re = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(g[k]), Pe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(g[k + 1]), Le = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(g[k + 2]), We = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(g[k + 3]);
|
|
3074
|
-
$[Y++] = re << 2 | Pe >> 4, $[Y++] = (Pe & 15) << 4 | Le >> 2, $[Y++] = (Le & 3) << 6 | We & 63;
|
|
3075
|
-
}
|
|
3076
|
-
return T;
|
|
3077
|
-
}
|
|
3078
|
-
function p(g) {
|
|
3079
|
-
for (var _ = new Uint8Array(g), A = "", T = 0; T < _.length; T += 3) A += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[_[T] >> 2], A += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(_[T] & 3) << 4 | _[T + 1] >> 4], A += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(_[T + 1] & 15) << 2 | _[T + 2] >> 6], A += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[_[T + 2] & 63];
|
|
3080
|
-
return _.length % 3 === 2 ? A = A.substring(0, A.length - 1) + "=" : _.length % 3 === 1 && (A = A.substring(0, A.length - 2) + "=="), A;
|
|
3081
|
-
}
|
|
3082
|
-
function S(g, _) {
|
|
3083
|
-
var A = "";
|
|
3084
|
-
if (g && (A = m.call(g)), g && (A === "[object ArrayBuffer]" || g.buffer && m.call(g.buffer) === "[object ArrayBuffer]")) {
|
|
3085
|
-
var T = void 0, $ = "__lfsc__:";
|
|
3086
|
-
g instanceof ArrayBuffer ? (T = g, $ += "arbf") : (T = g.buffer, A === "[object Int8Array]" ? $ += "si08" : A === "[object Uint8Array]" ? $ += "ui08" : A === "[object Uint8ClampedArray]" ? $ += "uic8" : A === "[object Int16Array]" ? $ += "si16" : A === "[object Uint16Array]" ? $ += "ur16" : A === "[object Int32Array]" ? $ += "si32" : A === "[object Uint32Array]" ? $ += "ui32" : A === "[object Float32Array]" ? $ += "fl32" : A === "[object Float64Array]" ? $ += "fl64" : _(new Error("Failed to get type for BinaryArray"))), _($ + p(T));
|
|
3087
|
-
} else if (A === "[object Blob]") {
|
|
3088
|
-
var k = new FileReader();
|
|
3089
|
-
k.onload = function() {
|
|
3090
|
-
var Y = "~~local_forage_type~" + g.type + "~" + p(this.result);
|
|
3091
|
-
_("__lfsc__:blob" + Y);
|
|
3092
|
-
}, k.readAsArrayBuffer(g);
|
|
3093
|
-
} else try {
|
|
3094
|
-
_(JSON.stringify(g));
|
|
3095
|
-
} catch (Y) {
|
|
3096
|
-
console.error("Couldn't convert value into a JSON string: ", g), _(null, Y);
|
|
3097
|
-
}
|
|
3098
|
-
}
|
|
3099
|
-
function M(g) {
|
|
3100
|
-
if (g.substring(0, u) !== "__lfsc__:") return JSON.parse(g);
|
|
3101
|
-
var _ = g.substring(y), A = g.substring(u, y), T;
|
|
3102
|
-
if (A === "blob" && h.test(_)) {
|
|
3103
|
-
var $ = _.match(h);
|
|
3104
|
-
T = $[1], _ = _.substring($[0].length);
|
|
3105
|
-
}
|
|
3106
|
-
var k = E(_);
|
|
3107
|
-
switch (A) {
|
|
3108
|
-
case "arbf":
|
|
3109
|
-
return k;
|
|
3110
|
-
case "blob":
|
|
3111
|
-
return a([k], { type: T });
|
|
3112
|
-
case "si08":
|
|
3113
|
-
return new Int8Array(k);
|
|
3114
|
-
case "ui08":
|
|
3115
|
-
return new Uint8Array(k);
|
|
3116
|
-
case "uic8":
|
|
3117
|
-
return new Uint8ClampedArray(k);
|
|
3118
|
-
case "si16":
|
|
3119
|
-
return new Int16Array(k);
|
|
3120
|
-
case "ur16":
|
|
3121
|
-
return new Uint16Array(k);
|
|
3122
|
-
case "si32":
|
|
3123
|
-
return new Int32Array(k);
|
|
3124
|
-
case "ui32":
|
|
3125
|
-
return new Uint32Array(k);
|
|
3126
|
-
case "fl32":
|
|
3127
|
-
return new Float32Array(k);
|
|
3128
|
-
case "fl64":
|
|
3129
|
-
return new Float64Array(k);
|
|
3130
|
-
default:
|
|
3131
|
-
throw new Error("Unkown type: " + A);
|
|
3132
|
-
}
|
|
3133
|
-
}
|
|
3134
|
-
function P(g) {
|
|
3135
|
-
var _, A;
|
|
3136
|
-
if (g === null || typeof g != "object" || "isActiveClone" in g) return g;
|
|
3137
|
-
var T = g instanceof Date ? new Date(g) : g.constructor();
|
|
3138
|
-
try {
|
|
3139
|
-
for (var $ = i(Object.keys(g)), k = $.next(); !k.done; k = $.next()) {
|
|
3140
|
-
var Y = k.value;
|
|
3141
|
-
Object.prototype.hasOwnProperty.call(g, Y) && (g.isActiveClone = null, T[Y] = P(g[Y]), delete g.isActiveClone);
|
|
3142
|
-
}
|
|
3143
|
-
} catch (re) {
|
|
3144
|
-
_ = { error: re };
|
|
3145
|
-
} finally {
|
|
3146
|
-
try {
|
|
3147
|
-
k && !k.done && (A = $.return) && A.call($);
|
|
3148
|
-
} finally {
|
|
3149
|
-
if (_) throw _.error;
|
|
3150
|
-
}
|
|
3151
|
-
}
|
|
3152
|
-
return T;
|
|
3153
|
-
}
|
|
3154
|
-
function G(g, _) {
|
|
3155
|
-
return (g.name || _.name) + "/" + (g.storeName || _.storeName) + "/";
|
|
3156
|
-
}
|
|
3157
|
-
function O(g, _) {
|
|
3158
|
-
_ && g.then(function(A) {
|
|
3159
|
-
_(null, A);
|
|
3160
|
-
}, function(A) {
|
|
3161
|
-
_(A);
|
|
3162
|
-
});
|
|
3163
|
-
}
|
|
3164
|
-
function K() {
|
|
3165
|
-
for (var g = [], _ = 0; _ < arguments.length; _++) g[_] = arguments[_];
|
|
3166
|
-
if (arguments.length && typeof arguments[arguments.length - 1] == "function") return arguments[arguments.length - 1];
|
|
3167
|
-
}
|
|
3168
|
-
function q(g, _) {
|
|
3169
|
-
var A = this;
|
|
3170
|
-
if (_ = K.apply(this, arguments), g = typeof g != "function" && g || {}, !g.name) {
|
|
3171
|
-
var T = this.config();
|
|
3172
|
-
g.name = g.name || T.name, g.storeName = g.storeName || T.storeName;
|
|
3173
|
-
}
|
|
3174
|
-
var $;
|
|
3175
|
-
return g.name ? $ = new Promise(function(k) {
|
|
3176
|
-
g.storeName ? k(G(g, A._defaultConfig)) : k(g.name + "/");
|
|
3177
|
-
}) : $ = Promise.reject("Invalid arguments"), { promise: $, callback: _ };
|
|
3178
|
-
}
|
|
3179
|
-
function B(g) {
|
|
3180
|
-
return typeof g != "string" && (console.warn(g + " used as a key, but it is not a string."), g = String(g)), g;
|
|
3181
|
-
}
|
|
3182
|
-
var ee = { bufferToString: p, deserialize: M, serialize: S, stringToBuffer: E }, N = {}, j = (function() {
|
|
3183
|
-
function g(_) {
|
|
3184
|
-
this.kp = _, this.data = {};
|
|
3185
|
-
}
|
|
3186
|
-
return g.resolve = function(_) {
|
|
3187
|
-
return N[_] || (N[_] = new g(_)), N[_];
|
|
3188
|
-
}, g.prototype.clear = function() {
|
|
3189
|
-
this.data = {};
|
|
3190
|
-
}, g.prototype.drop = function() {
|
|
3191
|
-
this.clear(), delete N[this.kp];
|
|
3192
|
-
}, g.prototype.get = function(_) {
|
|
3193
|
-
return this.data[_];
|
|
3194
|
-
}, g.prototype.key = function(_) {
|
|
3195
|
-
return this.keys()[_];
|
|
3196
|
-
}, g.prototype.keys = function() {
|
|
3197
|
-
return Object.keys(this.data);
|
|
3198
|
-
}, g.prototype.rm = function(_) {
|
|
3199
|
-
delete this.data[_];
|
|
3200
|
-
}, g.prototype.set = function(_, A) {
|
|
3201
|
-
this.data[_] = A;
|
|
3202
|
-
}, g;
|
|
3203
|
-
})();
|
|
3204
|
-
function x(g) {
|
|
3205
|
-
var _ = g ? P(g) : {}, A = G(_, this._defaultConfig), T = j.resolve(A);
|
|
3206
|
-
return this._dbInfo = _, this._dbInfo.serializer = ee, this._dbInfo.keyPrefix = A, this._dbInfo.mStore = T, Promise.resolve();
|
|
3207
|
-
}
|
|
3208
|
-
function F(g) {
|
|
3209
|
-
var _ = this, A = this.ready().then(function() {
|
|
3210
|
-
_._dbInfo.mStore.clear();
|
|
3211
|
-
});
|
|
3212
|
-
return O(A, g), A;
|
|
3213
|
-
}
|
|
3214
|
-
function Z(g, _) {
|
|
3215
|
-
var A = q.apply(this, arguments), T = A.promise, $ = A.callback, k = T.then(function(Y) {
|
|
3216
|
-
j.resolve(Y).drop();
|
|
3217
|
-
});
|
|
3218
|
-
return O(k, $), T;
|
|
3219
|
-
}
|
|
3220
|
-
function oe(g, _) {
|
|
3221
|
-
var A = this;
|
|
3222
|
-
g = B(g);
|
|
3223
|
-
var T = this.ready().then(function() {
|
|
3224
|
-
var $ = A._dbInfo.mStore.get(g);
|
|
3225
|
-
return $ == null ? null : A._dbInfo.serializer.deserialize($);
|
|
3226
|
-
});
|
|
3227
|
-
return O(T, _), T;
|
|
3228
|
-
}
|
|
3229
|
-
function ae(g, _) {
|
|
3230
|
-
var A = this, T = this.ready().then(function() {
|
|
3231
|
-
for (var $ = A._dbInfo.mStore, k = $.keys(), Y = 0; Y < k.length; Y++) {
|
|
3232
|
-
var re = $.get(k[Y]);
|
|
3233
|
-
if (re && (re = A._dbInfo.serializer.deserialize(re)), re = g(re, k[Y], Y + 1), re !== void 0) return re;
|
|
3234
|
-
}
|
|
3235
|
-
});
|
|
3236
|
-
return O(T, _), T;
|
|
3237
|
-
}
|
|
3238
|
-
function se(g, _) {
|
|
3239
|
-
var A = this, T = this.ready().then(function() {
|
|
3240
|
-
var $;
|
|
3241
|
-
try {
|
|
3242
|
-
$ = A._dbInfo.mStore.key(g), $ === void 0 && ($ = null);
|
|
3243
|
-
} catch {
|
|
3244
|
-
$ = null;
|
|
3245
|
-
}
|
|
3246
|
-
return $;
|
|
3247
|
-
});
|
|
3248
|
-
return O(T, _), T;
|
|
3249
|
-
}
|
|
3250
|
-
function de(g) {
|
|
3251
|
-
var _ = this, A = this.ready().then(function() {
|
|
3252
|
-
return _._dbInfo.mStore.keys();
|
|
3253
|
-
});
|
|
3254
|
-
return O(A, g), A;
|
|
3255
|
-
}
|
|
3256
|
-
function Te(g) {
|
|
3257
|
-
var _ = this.keys().then(function(A) {
|
|
3258
|
-
return A.length;
|
|
3259
|
-
});
|
|
3260
|
-
return O(_, g), _;
|
|
3261
|
-
}
|
|
3262
|
-
function Ce(g, _) {
|
|
3263
|
-
var A = this;
|
|
3264
|
-
g = B(g);
|
|
3265
|
-
var T = this.ready().then(function() {
|
|
3266
|
-
A._dbInfo.mStore.rm(g);
|
|
3267
|
-
});
|
|
3268
|
-
return O(T, _), T;
|
|
3269
|
-
}
|
|
3270
|
-
function Ge(g, _, A) {
|
|
3271
|
-
var T = this;
|
|
3272
|
-
g = B(g);
|
|
3273
|
-
var $ = this.ready().then(function() {
|
|
3274
|
-
_ === void 0 && (_ = null);
|
|
3275
|
-
var k = _;
|
|
3276
|
-
return new Promise(function(Y, re) {
|
|
3277
|
-
T._dbInfo.serializer.serialize(_, function(Pe, Le) {
|
|
3278
|
-
if (Le) re(Le);
|
|
3279
|
-
else try {
|
|
3280
|
-
T._dbInfo.mStore.set(g, Pe), Y(k);
|
|
3281
|
-
} catch (We) {
|
|
3282
|
-
re(We);
|
|
3283
|
-
}
|
|
3284
|
-
});
|
|
3285
|
-
});
|
|
3286
|
-
});
|
|
3287
|
-
return O($, A), $;
|
|
3288
|
-
}
|
|
3289
|
-
var we = !0;
|
|
3290
|
-
r._support = we, r._driver = n, r._initStorage = x, r.clear = F, r.dropInstance = Z, r.getItem = oe, r.iterate = ae, r.key = se, r.keys = de, r.length = Te, r.removeItem = Ce, r.setItem = Ge, Object.defineProperty(r, "__esModule", { value: !0 });
|
|
3291
|
-
});
|
|
3292
|
-
}), Ot = Kr(Va()), _r = Kr(za()), Ha = { display: "none", position: "fixed", top: "0", right: "0", width: "100%", height: "100%", borderRadius: "0", border: "none", opacity: "0", zIndex: "-1" };
|
|
3293
|
-
function Xa(e) {
|
|
3294
|
-
for (let [t, r] of Object.entries(Ha)) e.style[t] = r;
|
|
3295
|
-
}
|
|
3296
|
-
function Ka(e) {
|
|
3297
|
-
return !![].slice.call(document.querySelectorAll(".magic-iframe")).find((t) => t.src.includes(e));
|
|
3298
|
-
}
|
|
3299
|
-
var Ya = class extends La {
|
|
3300
|
-
activeElement = null;
|
|
3301
|
-
iframe;
|
|
3302
|
-
relayerSrc = mt(`/send?params=${encodeURIComponent(this.parameters)}`, this.endpoint).href;
|
|
3303
|
-
init() {
|
|
3304
|
-
this.test = "hello", this.iframe = new Promise((e) => {
|
|
3305
|
-
let t = () => {
|
|
3306
|
-
if (Ka(encodeURIComponent(this.parameters))) xi().log();
|
|
3307
|
-
else {
|
|
3308
|
-
let r = document.createElement("iframe");
|
|
3309
|
-
r.classList.add("magic-iframe"), r.dataset.magicIframeLabel = mt(this.endpoint).host, r.title = "Secure Modal", r.src = this.relayerSrc, r.allow = "clipboard-read; clipboard-write", Xa(r), document.body.appendChild(r), e(r);
|
|
3310
|
-
}
|
|
3311
|
-
};
|
|
3312
|
-
["loaded", "interactive", "complete"].includes(document.readyState) ? t() : window.addEventListener("load", t, !1);
|
|
3313
|
-
}), this.iframe.then((e) => {
|
|
3314
|
-
e instanceof HTMLIFrameElement && e.addEventListener("load", async () => {
|
|
3315
|
-
this.heartbeatDebounce();
|
|
3316
|
-
});
|
|
3317
|
-
}), window.addEventListener("message", (e) => {
|
|
3318
|
-
if (e.origin === this.endpoint && e.data.msgType && (e.data.msgType.includes(Re.MAGIC_PONG) && (this.lastPongTime = Date.now()), e.data && this.messageHandlers.size)) {
|
|
3319
|
-
e.data.response = e.data.response ?? {}, this.stopHeartBeat();
|
|
3320
|
-
for (let t of this.messageHandlers.values()) t(e);
|
|
3321
|
-
}
|
|
3322
|
-
}), window.addEventListener("beforeunload", () => {
|
|
3323
|
-
this.stopHeartBeat();
|
|
3324
|
-
});
|
|
3325
|
-
}
|
|
3326
|
-
async showOverlay() {
|
|
3327
|
-
let e = await this.iframe;
|
|
3328
|
-
e.style.display = "block", e.style.zIndex = "2147483647", e.style.opacity = "1", this.activeElement = document.activeElement, e.focus();
|
|
3329
|
-
}
|
|
3330
|
-
async hideOverlay() {
|
|
3331
|
-
let e = await this.iframe;
|
|
3332
|
-
e.style.display = "none", e.style.zIndex = "-1", e.style.opacity = "0", this.activeElement?.focus && this.activeElement.focus(), this.activeElement = null;
|
|
3333
|
-
}
|
|
3334
|
-
async _post(e) {
|
|
3335
|
-
let t = await this.iframe;
|
|
3336
|
-
if (t && t.contentWindow) t.contentWindow.postMessage(e, this.endpoint);
|
|
3337
|
-
else throw Lr();
|
|
3338
|
-
}
|
|
3339
|
-
async checkRelayerExistsInDOM() {
|
|
3340
|
-
let e = await this.iframe;
|
|
3341
|
-
return !e || !e.contentWindow ? !1 : !![].slice.call(document.querySelectorAll(".magic-iframe")).find((t) => t.src.includes(encodeURIComponent(this.parameters)));
|
|
3342
|
-
}
|
|
3343
|
-
async reloadRelayer() {
|
|
3344
|
-
let e = await this.iframe;
|
|
3345
|
-
if (this.stopHeartBeat(), !e) {
|
|
3346
|
-
this.init(), console.warn("Magic SDK: Modal lost, re-initiating");
|
|
3347
|
-
return;
|
|
3348
|
-
}
|
|
3349
|
-
if (!e.contentWindow) {
|
|
3350
|
-
document.body.appendChild(e), console.warn("Magic SDK: Modal did not append in the iframe, re-initiating");
|
|
3351
|
-
return;
|
|
3352
|
-
}
|
|
3353
|
-
e && (e.src = this.relayerSrc);
|
|
3354
|
-
}
|
|
3355
|
-
}, Ja = Ti(Ia, { platform: "web", sdkName: "magic-sdk", version: "30.0.0", defaultEndpoint: "https://auth.magic.link/", ViewController: Ya, configureStorage: async () => {
|
|
3356
|
-
let e = Ot.default.createInstance({ name: "MagicAuthLocalStorageDB", storeName: "MagicAuthLocalStorage" });
|
|
3357
|
-
return await e.defineDriver(_r), await e.setDriver([Ot.default.INDEXEDDB, Ot.default.LOCALSTORAGE, _r._driver]), e;
|
|
3358
|
-
} });
|
|
3359
|
-
class Gt {
|
|
3360
|
-
constructor(t, r = this) {
|
|
3361
|
-
this.endpoint = t, this.api = r;
|
|
3362
|
-
}
|
|
3363
|
-
async stdPGET(t, r, n, i = {}) {
|
|
3364
|
-
const a = await fetch(this.endpoint + r, {
|
|
3365
|
-
method: t,
|
|
3366
|
-
headers: {
|
|
3367
|
-
"Content-Type": "application/json",
|
|
3368
|
-
// Include credentials (cookies) in the request
|
|
3369
|
-
Accept: "application/json",
|
|
3370
|
-
...i
|
|
3371
|
-
},
|
|
3372
|
-
body: n ? JSON.stringify(n) : null,
|
|
3373
|
-
credentials: "include"
|
|
3374
|
-
// This ensures cookies are sent with the request
|
|
3375
|
-
});
|
|
3376
|
-
return this.withResp(a);
|
|
3377
|
-
}
|
|
3378
|
-
async withResp(t) {
|
|
3379
|
-
if (!t.ok) {
|
|
3380
|
-
const r = await t.json().catch(() => ({})), n = new Error("Network response was not ok");
|
|
3381
|
-
throw Object.assign(n, { response: t, data: r }), n;
|
|
3382
|
-
}
|
|
3383
|
-
return t.json().then((r) => ({ data: r, response: t }));
|
|
3384
|
-
}
|
|
3385
|
-
async post(t, r = {}) {
|
|
3386
|
-
return this.stdPGET("POST", t, r);
|
|
3387
|
-
}
|
|
3388
|
-
async get(t, r = {}) {
|
|
3389
|
-
return this.stdPGET("GET", t, void 0, r);
|
|
3390
|
-
}
|
|
3391
|
-
async loginWithMagicDid(t) {
|
|
3392
|
-
const { data: r } = await this.api.post("/v1/auth/login/did", { did: t });
|
|
3393
|
-
return r;
|
|
3394
|
-
}
|
|
3395
|
-
async loginWithWeb3WalletSignature(t) {
|
|
3396
|
-
const { data: r } = await this.api.post("/v1/auth/login/signature", t);
|
|
3397
|
-
return r;
|
|
3398
|
-
}
|
|
3399
|
-
async loginExtWithWeb3WalletSignature(t) {
|
|
3400
|
-
const { data: r } = await this.api.post("/v1/auth/login/ext-signature", t);
|
|
3401
|
-
return r;
|
|
3402
|
-
}
|
|
3403
|
-
// Logout of the backend with access token. Assumes user is currently logged in and has a cookie with the access token
|
|
3404
|
-
async logout(t) {
|
|
3405
|
-
await this.api.post("/v1/auth/logout", { accessToken: t }), await this.writePlayerEvent("player_logged_out");
|
|
3406
|
-
}
|
|
3407
|
-
// Use the cookie stored in the browser to get the user and save user model in state and local storage
|
|
3408
|
-
// This assumes that the user is logged to backend in and has a cookie jwt
|
|
3409
|
-
async getLoggedInUser(t) {
|
|
3410
|
-
const { data: r } = await this.api.get("/v1/auth/me", {
|
|
3411
|
-
Authorization: `Bearer ${t}`
|
|
3412
|
-
});
|
|
3413
|
-
return r;
|
|
3414
|
-
}
|
|
3415
|
-
// async loginPlayFabPlayer() {}
|
|
3416
|
-
/*async loginPlayFabPlayer() {
|
|
3417
|
-
try {
|
|
3418
|
-
// Get the user's playfab id from taunt api
|
|
3419
|
-
let id = null;
|
|
3420
|
-
if (!this.user && !this.user?.id) {
|
|
3421
|
-
id = this.getPlayfabAnonId()
|
|
3422
|
-
if (!id) {
|
|
3423
|
-
const { data: playFabResponse } = await this.api.get('/v1/auth/playfab', {})
|
|
3424
|
-
id = playFabResponse.playFabId
|
|
3425
|
-
this.setAnonPlayfabUserId(playFabResponse.playFabId);
|
|
3426
|
-
}
|
|
3427
|
-
} else {
|
|
3428
|
-
const { data: playFabResponse } = await this.api.get('/v1/auth/playfab', {})
|
|
3429
|
-
id = playFabResponse.playFabId
|
|
3430
|
-
}
|
|
3431
|
-
// Login with playfab via the unique id from taunt api
|
|
3432
|
-
const { data: playFabLoginResults } = await Axios.post(loginEndpoint, {
|
|
3433
|
-
CustomId: id,
|
|
3434
|
-
CreateAccount: true,
|
|
3435
|
-
titleId: playFabTitleId,
|
|
3436
|
-
})
|
|
3437
|
-
const playFabSession = JSON.stringify(playFabLoginResults.data)
|
|
3438
|
-
this.setPlayFabSession(playFabSession)
|
|
3439
|
-
}
|
|
3440
|
-
catch (error) {
|
|
3441
|
-
const err = error as AxiosError
|
|
3442
|
-
if (err?.response) {
|
|
3443
|
-
console.log(err.response.status, err.response.data)
|
|
3444
|
-
}
|
|
3445
|
-
else {
|
|
3446
|
-
console.log(error)
|
|
3447
|
-
}
|
|
3448
|
-
}
|
|
3449
|
-
}*/
|
|
3450
|
-
// async getCToken() {
|
|
3451
|
-
// try {
|
|
3452
|
-
// const url = "v1/claimr/token"
|
|
3453
|
-
// const { data } = await this.api.get<{ data: { token: string } }>(`${url}`)
|
|
3454
|
-
// this.claimrToken = data.data.token
|
|
3455
|
-
// this.setClaimrToken(this.claimrToken)
|
|
3456
|
-
// } catch (e) {
|
|
3457
|
-
// console.error(e)
|
|
3458
|
-
// }
|
|
3459
|
-
// }
|
|
3460
|
-
// setLastWalletConnection(lastWalletConnection: string) {
|
|
3461
|
-
// localStorage.setItem("lastWalletConnection", lastWalletConnection)
|
|
3462
|
-
// }
|
|
3463
|
-
// setRefId(ref = "") {
|
|
3464
|
-
// this.refId = ref
|
|
3465
|
-
// }
|
|
3466
|
-
// clearLocalAuthStorage() {
|
|
3467
|
-
// localStorage.removeItem("user")
|
|
3468
|
-
// localStorage.removeItem("refreshToken")
|
|
3469
|
-
// localStorage.removeItem("playFabSession")
|
|
3470
|
-
// this.user = null
|
|
3471
|
-
// }
|
|
3472
|
-
// setAccessToken(accessToken: string) {
|
|
3473
|
-
// localStorage.setItem("accessToken", accessToken)
|
|
3474
|
-
// }
|
|
3475
|
-
// setRefreshToken(refreshToken: string) {
|
|
3476
|
-
// localStorage.setItem("refreshToken", refreshToken)
|
|
3477
|
-
// }
|
|
3478
|
-
// setIsFirsTimeLogin(isFirstTimeLogin: string) {
|
|
3479
|
-
// localStorage.setItem("isFirstTimeLogin", isFirstTimeLogin)
|
|
3480
|
-
// }
|
|
3481
|
-
// setPlayFabSession(playFabSession: string) {
|
|
3482
|
-
// localStorage.setItem("playFabSession", playFabSession)
|
|
3483
|
-
// }
|
|
3484
|
-
// setAnonPlayfabUserId(id: string) {
|
|
3485
|
-
// localStorage.setItem("playfabAnonId", id)
|
|
3486
|
-
// }
|
|
3487
|
-
// setClaimrToken(token: string) {
|
|
3488
|
-
// localStorage.setItem("ctoken", token)
|
|
3489
|
-
// }
|
|
3490
|
-
// getAccessToken() {
|
|
3491
|
-
// return localStorage.getItem("accessToken")
|
|
3492
|
-
// }
|
|
3493
|
-
// getRefreshToken() {
|
|
3494
|
-
// return localStorage.getItem("refreshToken")
|
|
3495
|
-
// }
|
|
3496
|
-
// getPlayfabAnonId() {
|
|
3497
|
-
// return localStorage.getItem("playfabAnonId")
|
|
3498
|
-
// }
|
|
3499
|
-
// Write a playfab event. retryfIfLoginNeeded should not be set by caller. It's used for stopping recursive calls when login is needed.
|
|
3500
|
-
// If login is needed, for example, if the web browser has been open longer than playfab session timeout, we'll try to login again at most
|
|
3501
|
-
// one time. Then we'll retry the event.
|
|
3502
|
-
async writePlayerEvent(t, r = null, n = !0) {
|
|
3503
|
-
return console.log("writePlayerEvent", {
|
|
3504
|
-
eventName: t,
|
|
3505
|
-
eventData: r,
|
|
3506
|
-
retryIfLoginNeeded: n
|
|
3507
|
-
}), Promise.resolve();
|
|
3508
|
-
}
|
|
3509
|
-
}
|
|
3510
|
-
const Qa = {
|
|
3511
|
-
rpcUrl: "https://polygon-rpc.com",
|
|
3512
|
-
// your ethereum, polygon, or optimism mainnet/testnet rpc URL
|
|
3513
|
-
chainId: 137
|
|
3514
|
-
}, Yr = (e) => new Ja(e, {
|
|
3515
|
-
network: Qa,
|
|
3516
|
-
extensions: [new xa()]
|
|
3517
|
-
});
|
|
3518
|
-
function Za(e, t) {
|
|
3519
|
-
return Yr(e).auth.loginWithEmailOTP({ email: t });
|
|
3520
|
-
}
|
|
3521
|
-
function es(e) {
|
|
3522
|
-
return Yr(e).oauth2.loginWithPopup({
|
|
3523
|
-
provider: "telegram"
|
|
3524
|
-
});
|
|
3525
|
-
}
|
|
3526
|
-
async function ts(e, t) {
|
|
3527
|
-
const r = new Gt(e);
|
|
3528
|
-
try {
|
|
3529
|
-
let n = await es(t);
|
|
3530
|
-
const i = n;
|
|
3531
|
-
if (i.error)
|
|
3532
|
-
throw new Error(`No ID token returned ${i.error}`);
|
|
3533
|
-
return n = n, console.log("Magic telegram login", { result: n }), r.loginWithMagicDid(n.magic.idToken);
|
|
3534
|
-
} catch (n) {
|
|
3535
|
-
throw console.error("Magic login error:", n), n;
|
|
3536
|
-
}
|
|
3537
|
-
}
|
|
3538
|
-
async function rs(e, t, r) {
|
|
3539
|
-
const n = new Gt(e);
|
|
3540
|
-
try {
|
|
3541
|
-
const i = await Za(t, r);
|
|
3542
|
-
if (!i) throw new Error("No DID returned");
|
|
3543
|
-
return console.log("Magic email OTP login", { did: i }), n.loginWithMagicDid(i);
|
|
3544
|
-
} catch (i) {
|
|
3545
|
-
throw console.error("Magic login error:", i), i;
|
|
3546
|
-
}
|
|
3547
|
-
}
|
|
3548
|
-
async function ns(e, t) {
|
|
3549
|
-
if (t = t || window.ethereum, !t) throw new Error("MetaMask provider not found");
|
|
3550
|
-
const r = await t.request({
|
|
3551
|
-
method: "eth_requestAccounts"
|
|
3552
|
-
});
|
|
3553
|
-
if (!r.length) throw new Error("No accounts returned");
|
|
3554
|
-
console.log("MetaMask", { accounts: r });
|
|
3555
|
-
const n = r[0], i = `${e}/v1/auth`, a = new Uint32Array(3), h = crypto.getRandomValues(a).toString(), u = await fetch(`${i}/nonce/login`, {
|
|
3556
|
-
method: "POST",
|
|
3557
|
-
body: JSON.stringify({ walletAddress: n, clientNonce: h }),
|
|
3558
|
-
headers: { "Content-Type": "application/json" }
|
|
3559
|
-
}).then((E) => E.text()), y = `Sign this message with your wallet to connect to Taunt Battleworld ::: ${JSON.stringify({ clientNonce: h, serverNonce: u })}`;
|
|
3560
|
-
let m;
|
|
3561
|
-
try {
|
|
3562
|
-
m = await t.request({
|
|
3563
|
-
method: "personal_sign",
|
|
3564
|
-
params: [y, n]
|
|
3565
|
-
});
|
|
3566
|
-
} catch {
|
|
3567
|
-
throw new Error("User denied message signature");
|
|
3568
|
-
}
|
|
3569
|
-
if (!m) throw new Error("No signature returned");
|
|
3570
|
-
return { walletAddress: n, message: y, signature: m };
|
|
3571
|
-
}
|
|
3572
|
-
async function os(e, t) {
|
|
3573
|
-
const r = new Gt(e), { walletAddress: n, message: i, signature: a } = await ns(
|
|
3574
|
-
e,
|
|
3575
|
-
t
|
|
3576
|
-
);
|
|
3577
|
-
return r.loginWithWeb3WalletSignature({
|
|
3578
|
-
walletAddress: n,
|
|
3579
|
-
message: i,
|
|
3580
|
-
signature: a
|
|
3581
|
-
});
|
|
3582
|
-
}
|
|
3583
|
-
const fs = ({
|
|
3584
|
-
children: e,
|
|
3585
|
-
tauntServiceEndpoint: t,
|
|
3586
|
-
magicKey: r
|
|
3587
|
-
}) => {
|
|
3588
|
-
const [n, i] = Ye(), [a, h] = Ye(!1), u = me(
|
|
3589
|
-
(M) => {
|
|
3590
|
-
if (!r) throw new Error("magicKey is required for OTP login");
|
|
3591
|
-
h(!0), rs(t, r, M).then(i).finally(() => h(!1));
|
|
3592
|
-
},
|
|
3593
|
-
[t, r]
|
|
3594
|
-
), y = me(() => {
|
|
3595
|
-
h(!0), os(t).then(i).finally(() => h(!1));
|
|
3596
|
-
}, [t]), m = me(() => {
|
|
3597
|
-
if (!r) throw new Error("magicKey is required for Telegram login");
|
|
3598
|
-
h(!0), ts(t, r).then(i).finally(() => h(!1));
|
|
3599
|
-
}, [t, r]), E = me(() => {
|
|
3600
|
-
h(!0), console.log("Meta login not yet implemented"), setTimeout(() => h(!1), 1e3);
|
|
3601
|
-
}, []), p = me(() => {
|
|
3602
|
-
h(!0), console.log("Coinbase login not yet implemented"), setTimeout(() => h(!1), 1e3);
|
|
3603
|
-
}, []), S = me(() => {
|
|
3604
|
-
i(void 0);
|
|
3605
|
-
}, []);
|
|
3606
|
-
return t ? /* @__PURE__ */ D(
|
|
3607
|
-
Ir.Provider,
|
|
3608
|
-
{
|
|
3609
|
-
value: {
|
|
3610
|
-
tauntServiceEndpoint: t,
|
|
3611
|
-
isLoading: a,
|
|
3612
|
-
loggedIn: !!n,
|
|
3613
|
-
deets: n,
|
|
3614
|
-
otpMagicLogin: u,
|
|
3615
|
-
metamaskLogin: y,
|
|
3616
|
-
telegramLogin: m,
|
|
3617
|
-
metaLogin: E,
|
|
3618
|
-
coinbaseLogin: p,
|
|
3619
|
-
logout: S
|
|
3620
|
-
},
|
|
3621
|
-
children: e
|
|
3622
|
-
}
|
|
3623
|
-
) : /* @__PURE__ */ D("div", { children: "tauntServiceEndpoint is required" });
|
|
3624
|
-
};
|
|
3625
|
-
export {
|
|
3626
|
-
Hn as CoinbaseButton,
|
|
3627
|
-
Xn as LoadingView,
|
|
3628
|
-
ss as LoginUIComplete,
|
|
3629
|
-
io as LoginView,
|
|
3630
|
-
Qn as MagicEmailInput,
|
|
3631
|
-
eo as MetaButton,
|
|
3632
|
-
ro as MetaMaskButton,
|
|
3633
|
-
cs as ModalView,
|
|
3634
|
-
Ir as TauntContext,
|
|
3635
|
-
fs as TauntProvider,
|
|
3636
|
-
oo as TelegramButton,
|
|
3637
|
-
Qe as useTaunt
|
|
3638
|
-
};
|
|
3639
|
-
//# sourceMappingURL=taunt-logins-ui-react.js.map
|