@ackplus/nest-auth-react 1.1.0 → 1.1.2
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/client/create-client.d.ts +63 -0
- package/client/create-client.d.ts.map +1 -0
- package/context/auth-context.d.ts +50 -0
- package/context/auth-context.d.ts.map +1 -0
- package/context/mfa-service-context.d.ts +5 -0
- package/context/mfa-service-context.d.ts.map +1 -0
- package/hooks/use-auth.d.ts +50 -0
- package/hooks/use-auth.d.ts.map +1 -0
- package/hooks/use-mfa.d.ts +23 -0
- package/hooks/use-mfa.d.ts.map +1 -0
- package/index.cjs +6 -0
- package/index.d.ts +13 -0
- package/index.js +2779 -0
- package/package.json +1 -1
- package/provider/nest-auth-provider.d.ts +15 -0
- package/provider/nest-auth-provider.d.ts.map +1 -0
- package/storage/token-storage.d.ts +3 -0
- package/storage/token-storage.d.ts.map +1 -0
- package/utils/errors.d.ts +6 -0
- package/utils/errors.d.ts.map +1 -0
- package/utils/request.d.ts +10 -0
- package/utils/request.d.ts.map +1 -0
package/index.js
ADDED
|
@@ -0,0 +1,2779 @@
|
|
|
1
|
+
import { jsx as Me } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as it, useContext as at, useRef as oe, useReducer as Ft, useMemo as x, useEffect as Mt, useSyncExternalStore as Bt, useCallback as q } from "react";
|
|
3
|
+
var Ht = /* @__PURE__ */ ((e) => (e.EMAIL = "email", e.PHONE = "phone", e.GOOGLE = "google", e.FACEBOOK = "facebook", e.APPLE = "apple", e.GITHUB = "github", e.MICROSOFT = "microsoft", e))(Ht || {}), ct = /* @__PURE__ */ ((e) => (e.TOTP = "totp", e.SMS = "sms", e.EMAIL = "email", e.BACKUP_CODE = "backup_code", e))(ct || {}), F = /* @__PURE__ */ ((e) => (e.IDLE = "idle", e.LOADING = "loading", e.AUTHENTICATED = "authenticated", e.UNAUTHENTICATED = "unauthenticated", e.MFA_REQUIRED = "mfa_required", e.EXPIRED = "expired", e))(F || {}), Z = /* @__PURE__ */ ((e) => (e.SINGLE = "single", e.MULTI = "multi", e))(Z || {}), _ = /* @__PURE__ */ ((e) => (e.SIGNED_IN = "signed_in", e.SIGNED_OUT = "signed_out", e.REGISTERED = "registered", e.TOKEN_REFRESHED = "token_refreshed", e.MFA_REQUIRED = "mfa_required", e.MFA_VERIFIED = "mfa_verified", e.MFA_SETUP_COMPLETED = "mfa_setup_completed", e.PASSWORD_CHANGED = "password_changed", e.PASSWORD_RESET_REQUESTED = "password_reset_requested", e.PASSWORD_RESET_COMPLETED = "password_reset_completed", e.PROFILE_LOADED = "profile_loaded", e.PROFILE_UPDATED = "profile_updated", e.CONFIG_LOADED = "config_loaded", e.ERROR = "error", e.NETWORK_ERROR = "network_error", e.VALIDATION_ERROR = "validation_error", e))(_ || {});
|
|
4
|
+
const qs = ct, Gs = "email", zs = "phone", $s = "google", Ks = "facebook", Vs = "apple";
|
|
5
|
+
function jt(e) {
|
|
6
|
+
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
7
|
+
}
|
|
8
|
+
var Oe = { exports: {} }, Be;
|
|
9
|
+
function qt() {
|
|
10
|
+
return Be || (Be = 1, (function(e) {
|
|
11
|
+
var t = Object.prototype.hasOwnProperty, n = "~";
|
|
12
|
+
function s() {
|
|
13
|
+
}
|
|
14
|
+
Object.create && (s.prototype = /* @__PURE__ */ Object.create(null), new s().__proto__ || (n = !1));
|
|
15
|
+
function r(f, l, c) {
|
|
16
|
+
this.fn = f, this.context = l, this.once = c || !1;
|
|
17
|
+
}
|
|
18
|
+
function i(f, l, c, p, T) {
|
|
19
|
+
if (typeof c != "function")
|
|
20
|
+
throw new TypeError("The listener must be a function");
|
|
21
|
+
var R = new r(c, p || f, T), d = n ? n + l : l;
|
|
22
|
+
return f._events[d] ? f._events[d].fn ? f._events[d] = [f._events[d], R] : f._events[d].push(R) : (f._events[d] = R, f._eventsCount++), f;
|
|
23
|
+
}
|
|
24
|
+
function o(f, l) {
|
|
25
|
+
--f._eventsCount === 0 ? f._events = new s() : delete f._events[l];
|
|
26
|
+
}
|
|
27
|
+
function a() {
|
|
28
|
+
this._events = new s(), this._eventsCount = 0;
|
|
29
|
+
}
|
|
30
|
+
a.prototype.eventNames = function() {
|
|
31
|
+
var l = [], c, p;
|
|
32
|
+
if (this._eventsCount === 0) return l;
|
|
33
|
+
for (p in c = this._events)
|
|
34
|
+
t.call(c, p) && l.push(n ? p.slice(1) : p);
|
|
35
|
+
return Object.getOwnPropertySymbols ? l.concat(Object.getOwnPropertySymbols(c)) : l;
|
|
36
|
+
}, a.prototype.listeners = function(l) {
|
|
37
|
+
var c = n ? n + l : l, p = this._events[c];
|
|
38
|
+
if (!p) return [];
|
|
39
|
+
if (p.fn) return [p.fn];
|
|
40
|
+
for (var T = 0, R = p.length, d = new Array(R); T < R; T++)
|
|
41
|
+
d[T] = p[T].fn;
|
|
42
|
+
return d;
|
|
43
|
+
}, a.prototype.listenerCount = function(l) {
|
|
44
|
+
var c = n ? n + l : l, p = this._events[c];
|
|
45
|
+
return p ? p.fn ? 1 : p.length : 0;
|
|
46
|
+
}, a.prototype.emit = function(l, c, p, T, R, d) {
|
|
47
|
+
var y = n ? n + l : l;
|
|
48
|
+
if (!this._events[y]) return !1;
|
|
49
|
+
var h = this._events[y], b = arguments.length, A, S;
|
|
50
|
+
if (h.fn) {
|
|
51
|
+
switch (h.once && this.removeListener(l, h.fn, void 0, !0), b) {
|
|
52
|
+
case 1:
|
|
53
|
+
return h.fn.call(h.context), !0;
|
|
54
|
+
case 2:
|
|
55
|
+
return h.fn.call(h.context, c), !0;
|
|
56
|
+
case 3:
|
|
57
|
+
return h.fn.call(h.context, c, p), !0;
|
|
58
|
+
case 4:
|
|
59
|
+
return h.fn.call(h.context, c, p, T), !0;
|
|
60
|
+
case 5:
|
|
61
|
+
return h.fn.call(h.context, c, p, T, R), !0;
|
|
62
|
+
case 6:
|
|
63
|
+
return h.fn.call(h.context, c, p, T, R, d), !0;
|
|
64
|
+
}
|
|
65
|
+
for (S = 1, A = new Array(b - 1); S < b; S++)
|
|
66
|
+
A[S - 1] = arguments[S];
|
|
67
|
+
h.fn.apply(h.context, A);
|
|
68
|
+
} else {
|
|
69
|
+
var C = h.length, k;
|
|
70
|
+
for (S = 0; S < C; S++)
|
|
71
|
+
switch (h[S].once && this.removeListener(l, h[S].fn, void 0, !0), b) {
|
|
72
|
+
case 1:
|
|
73
|
+
h[S].fn.call(h[S].context);
|
|
74
|
+
break;
|
|
75
|
+
case 2:
|
|
76
|
+
h[S].fn.call(h[S].context, c);
|
|
77
|
+
break;
|
|
78
|
+
case 3:
|
|
79
|
+
h[S].fn.call(h[S].context, c, p);
|
|
80
|
+
break;
|
|
81
|
+
case 4:
|
|
82
|
+
h[S].fn.call(h[S].context, c, p, T);
|
|
83
|
+
break;
|
|
84
|
+
default:
|
|
85
|
+
if (!A) for (k = 1, A = new Array(b - 1); k < b; k++)
|
|
86
|
+
A[k - 1] = arguments[k];
|
|
87
|
+
h[S].fn.apply(h[S].context, A);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return !0;
|
|
91
|
+
}, a.prototype.on = function(l, c, p) {
|
|
92
|
+
return i(this, l, c, p, !1);
|
|
93
|
+
}, a.prototype.once = function(l, c, p) {
|
|
94
|
+
return i(this, l, c, p, !0);
|
|
95
|
+
}, a.prototype.removeListener = function(l, c, p, T) {
|
|
96
|
+
var R = n ? n + l : l;
|
|
97
|
+
if (!this._events[R]) return this;
|
|
98
|
+
if (!c)
|
|
99
|
+
return o(this, R), this;
|
|
100
|
+
var d = this._events[R];
|
|
101
|
+
if (d.fn)
|
|
102
|
+
d.fn === c && (!T || d.once) && (!p || d.context === p) && o(this, R);
|
|
103
|
+
else {
|
|
104
|
+
for (var y = 0, h = [], b = d.length; y < b; y++)
|
|
105
|
+
(d[y].fn !== c || T && !d[y].once || p && d[y].context !== p) && h.push(d[y]);
|
|
106
|
+
h.length ? this._events[R] = h.length === 1 ? h[0] : h : o(this, R);
|
|
107
|
+
}
|
|
108
|
+
return this;
|
|
109
|
+
}, a.prototype.removeAllListeners = function(l) {
|
|
110
|
+
var c;
|
|
111
|
+
return l ? (c = n ? n + l : l, this._events[c] && o(this, c)) : (this._events = new s(), this._eventsCount = 0), this;
|
|
112
|
+
}, a.prototype.off = a.prototype.removeListener, a.prototype.addListener = a.prototype.on, a.prefixed = n, a.EventEmitter = a, e.exports = a;
|
|
113
|
+
})(Oe)), Oe.exports;
|
|
114
|
+
}
|
|
115
|
+
var Gt = qt();
|
|
116
|
+
const ut = /* @__PURE__ */ jt(Gt), lt = it(void 0), zt = () => {
|
|
117
|
+
const e = at(lt);
|
|
118
|
+
if (!e)
|
|
119
|
+
throw new Error("useAuth must be used within NestAuthProvider");
|
|
120
|
+
return e;
|
|
121
|
+
}, ft = it(null), $t = () => {
|
|
122
|
+
const e = at(ft);
|
|
123
|
+
if (!e)
|
|
124
|
+
throw new Error("useMfa must be used within NestAuthProvider");
|
|
125
|
+
return e;
|
|
126
|
+
};
|
|
127
|
+
class Kt extends Error {
|
|
128
|
+
status;
|
|
129
|
+
data;
|
|
130
|
+
constructor(t, n, s) {
|
|
131
|
+
super(t), this.name = "AuthClientError", this.status = n, this.data = s;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const Vt = (e, t) => {
|
|
135
|
+
if (!t)
|
|
136
|
+
return e;
|
|
137
|
+
if (/^https?:\/\//i.test(t))
|
|
138
|
+
return t;
|
|
139
|
+
const n = e.endsWith("/") ? e.slice(0, -1) : e, s = t.startsWith("/") ? t : `/${t}`;
|
|
140
|
+
return `${n}${s}`;
|
|
141
|
+
}, He = async (e, t, n = {}) => {
|
|
142
|
+
const { method: s = "POST", body: r, headers: i = {}, tokens: o, signal: a } = n, f = Vt(e.baseUrl, t), l = {
|
|
143
|
+
"Content-Type": "application/json",
|
|
144
|
+
...e.defaultHeaders,
|
|
145
|
+
...i
|
|
146
|
+
};
|
|
147
|
+
o?.accessToken && (l.Authorization = `Bearer ${o.accessToken}`);
|
|
148
|
+
const c = await fetch(f, {
|
|
149
|
+
method: s,
|
|
150
|
+
headers: l,
|
|
151
|
+
body: r !== void 0 ? JSON.stringify(r) : void 0,
|
|
152
|
+
credentials: "include",
|
|
153
|
+
signal: a
|
|
154
|
+
}), p = await c.text(), T = p ? Jt(p) : void 0;
|
|
155
|
+
if (!c.ok)
|
|
156
|
+
throw new Kt(
|
|
157
|
+
T?.message || `Request failed with status ${c.status}`,
|
|
158
|
+
c.status,
|
|
159
|
+
T
|
|
160
|
+
);
|
|
161
|
+
return T;
|
|
162
|
+
}, Jt = (e) => {
|
|
163
|
+
try {
|
|
164
|
+
return JSON.parse(e);
|
|
165
|
+
} catch {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
}, Wt = {
|
|
169
|
+
login: "/auth/login",
|
|
170
|
+
register: "/auth/signup",
|
|
171
|
+
logout: "/auth/logout",
|
|
172
|
+
logoutAll: "/auth/logout-all",
|
|
173
|
+
refresh: "/auth/refresh-token",
|
|
174
|
+
me: "/auth/user",
|
|
175
|
+
session: "/auth/session",
|
|
176
|
+
sendMfaCode: "/auth/send-2fa-code",
|
|
177
|
+
verifyMfa: "/auth/verify-2fa",
|
|
178
|
+
forgotPassword: "/auth/forgot-password",
|
|
179
|
+
verifyForgotPasswordOtp: "/auth/verify-forgot-password-otp",
|
|
180
|
+
resetPasswordWithToken: "/auth/reset-password-with-token",
|
|
181
|
+
changePassword: "/auth/change-password",
|
|
182
|
+
mfaStatus: "/auth/mfa/status",
|
|
183
|
+
toggleMfa: "/auth/mfa/toggle",
|
|
184
|
+
mfaDevices: "/auth/mfa/devices",
|
|
185
|
+
removeMfaDevice: "/auth/mfa/devices",
|
|
186
|
+
setupTotp: "/auth/mfa/setup-totp",
|
|
187
|
+
verifyTotpSetup: "/auth/mfa/verify-totp-setup",
|
|
188
|
+
generateRecoveryCode: "/auth/mfa/generate-recovery-code",
|
|
189
|
+
resetTotp: "/auth/mfa/reset-totp",
|
|
190
|
+
clientConfig: "/auth/client-config",
|
|
191
|
+
config: "/auth/config",
|
|
192
|
+
profile: "/auth/profile",
|
|
193
|
+
tenants: "/auth/tenants",
|
|
194
|
+
sendEmailVerification: "/auth/send-email-verification",
|
|
195
|
+
verifyEmail: "/auth/verify-email"
|
|
196
|
+
}, Xt = {
|
|
197
|
+
providers: {
|
|
198
|
+
email: { enabled: !1 },
|
|
199
|
+
phone: { enabled: !1 }
|
|
200
|
+
},
|
|
201
|
+
emailAuth: { enabled: !1 },
|
|
202
|
+
phoneAuth: { enabled: !1 },
|
|
203
|
+
registration: { enabled: !1 },
|
|
204
|
+
mfa: { enabled: !1, methods: [] },
|
|
205
|
+
tenants: { mode: Z.SINGLE, defaultTenantId: null, options: [] },
|
|
206
|
+
sso: { enabled: !1, providers: [] },
|
|
207
|
+
ui: void 0
|
|
208
|
+
}, Qt = (e) => e !== null && typeof e == "object" && "emailAuth" in e && "phoneAuth" in e, Yt = (e) => ({
|
|
209
|
+
baseUrl: e.baseUrl,
|
|
210
|
+
endpoints: {
|
|
211
|
+
...Wt,
|
|
212
|
+
...e.endpoints || {}
|
|
213
|
+
},
|
|
214
|
+
defaultHeaders: e.defaultHeaders
|
|
215
|
+
}), Zt = (e) => {
|
|
216
|
+
const t = Yt(e), n = (s, r = {}) => {
|
|
217
|
+
const i = t.endpoints[s];
|
|
218
|
+
return He(t, i, {
|
|
219
|
+
method: r.method ?? "POST",
|
|
220
|
+
body: r.body,
|
|
221
|
+
tokens: r.tokens ?? null
|
|
222
|
+
});
|
|
223
|
+
};
|
|
224
|
+
return {
|
|
225
|
+
login: (s) => n("login", {
|
|
226
|
+
body: (() => {
|
|
227
|
+
const { providerName: r, provider: i, providerId: o, ...a } = s;
|
|
228
|
+
return {
|
|
229
|
+
providerName: r ?? i ?? o,
|
|
230
|
+
...a
|
|
231
|
+
};
|
|
232
|
+
})()
|
|
233
|
+
}),
|
|
234
|
+
register: (s) => n("register", { body: s }),
|
|
235
|
+
logout: (s) => n("logout", { tokens: s ?? null }),
|
|
236
|
+
logoutAll: (s) => n("logoutAll", { tokens: s ?? null }),
|
|
237
|
+
refreshToken: (s) => n("refresh", { body: s }),
|
|
238
|
+
getProfile: (s) => n("me", {
|
|
239
|
+
method: "GET",
|
|
240
|
+
tokens: s ?? null
|
|
241
|
+
}),
|
|
242
|
+
getSession: (s) => n("session", {
|
|
243
|
+
method: "GET",
|
|
244
|
+
tokens: s ?? null
|
|
245
|
+
}),
|
|
246
|
+
sendMfaCode: (s, r) => n("sendMfaCode", {
|
|
247
|
+
body: { method: r },
|
|
248
|
+
tokens: s ?? null
|
|
249
|
+
}),
|
|
250
|
+
verifyMfa: (s, r) => n("verifyMfa", {
|
|
251
|
+
body: r,
|
|
252
|
+
tokens: s ?? null
|
|
253
|
+
}),
|
|
254
|
+
forgotPassword: (s) => n("forgotPassword", { body: s }),
|
|
255
|
+
verifyForgotPasswordOtp: (s) => n("verifyForgotPasswordOtp", { body: s }),
|
|
256
|
+
resetPasswordWithToken: (s) => n("resetPasswordWithToken", { body: s }),
|
|
257
|
+
changePassword: (s, r) => n("changePassword", {
|
|
258
|
+
body: s,
|
|
259
|
+
tokens: r ?? null
|
|
260
|
+
}),
|
|
261
|
+
getMfaStatus: (s) => n("mfaStatus", {
|
|
262
|
+
method: "GET",
|
|
263
|
+
tokens: s ?? null
|
|
264
|
+
}),
|
|
265
|
+
toggleMfa: (s, r) => n("toggleMfa", {
|
|
266
|
+
body: r,
|
|
267
|
+
tokens: s ?? null
|
|
268
|
+
}),
|
|
269
|
+
listMfaDevices: (s) => n("mfaDevices", {
|
|
270
|
+
method: "GET",
|
|
271
|
+
tokens: s ?? null
|
|
272
|
+
}),
|
|
273
|
+
removeMfaDevice: (s, r) => He(
|
|
274
|
+
t,
|
|
275
|
+
`${t.endpoints.removeMfaDevice}/${r}`,
|
|
276
|
+
{
|
|
277
|
+
method: "DELETE",
|
|
278
|
+
tokens: s ?? null
|
|
279
|
+
}
|
|
280
|
+
),
|
|
281
|
+
setupTotp: (s) => n("setupTotp", {
|
|
282
|
+
tokens: s ?? null
|
|
283
|
+
}),
|
|
284
|
+
verifyTotpSetup: (s, r) => n("verifyTotpSetup", {
|
|
285
|
+
body: r,
|
|
286
|
+
tokens: s ?? null
|
|
287
|
+
}),
|
|
288
|
+
generateRecoveryCode: (s) => n("generateRecoveryCode", {
|
|
289
|
+
tokens: s ?? null
|
|
290
|
+
}),
|
|
291
|
+
resetTotp: (s, r) => n("resetTotp", {
|
|
292
|
+
body: { code: r },
|
|
293
|
+
tokens: s ?? null
|
|
294
|
+
}),
|
|
295
|
+
fetchClientConfig: async () => {
|
|
296
|
+
const s = await n("clientConfig", {
|
|
297
|
+
method: "GET"
|
|
298
|
+
});
|
|
299
|
+
return Qt(s) ? s : s?.data ?? Xt;
|
|
300
|
+
},
|
|
301
|
+
fetchTenants: async (s) => {
|
|
302
|
+
const r = await n("tenants", {
|
|
303
|
+
method: "GET",
|
|
304
|
+
tokens: s ?? null
|
|
305
|
+
});
|
|
306
|
+
return Array.isArray(r) ? r : r?.data ?? [];
|
|
307
|
+
},
|
|
308
|
+
sendEmailVerification: (s) => n("sendEmailVerification", {
|
|
309
|
+
tokens: s ?? null
|
|
310
|
+
}),
|
|
311
|
+
verifyEmail: (s, r) => n("verifyEmail", {
|
|
312
|
+
body: { otp: r },
|
|
313
|
+
tokens: s ?? null
|
|
314
|
+
})
|
|
315
|
+
};
|
|
316
|
+
}, en = "nest-auth/tokens", tn = (e) => !!e && typeof e.getTokens == "function", nn = (e) => {
|
|
317
|
+
if (typeof window > "u")
|
|
318
|
+
return !1;
|
|
319
|
+
try {
|
|
320
|
+
const t = window[e], n = "__nest-auth-test__";
|
|
321
|
+
return t.setItem(n, "1"), t.removeItem(n), !0;
|
|
322
|
+
} catch {
|
|
323
|
+
return !1;
|
|
324
|
+
}
|
|
325
|
+
}, dt = () => {
|
|
326
|
+
let e = null;
|
|
327
|
+
return {
|
|
328
|
+
getTokens: () => e,
|
|
329
|
+
setTokens: (t) => {
|
|
330
|
+
e = t;
|
|
331
|
+
},
|
|
332
|
+
clear: () => {
|
|
333
|
+
e = null;
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
}, je = (e, t) => {
|
|
337
|
+
const n = dt();
|
|
338
|
+
if (!nn(e))
|
|
339
|
+
return n;
|
|
340
|
+
const s = window[e];
|
|
341
|
+
return {
|
|
342
|
+
getTokens: () => {
|
|
343
|
+
const r = s.getItem(t);
|
|
344
|
+
if (!r)
|
|
345
|
+
return null;
|
|
346
|
+
try {
|
|
347
|
+
return JSON.parse(r);
|
|
348
|
+
} catch {
|
|
349
|
+
return s.removeItem(t), null;
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
setTokens: (r) => {
|
|
353
|
+
if (!r) {
|
|
354
|
+
s.removeItem(t), n.setTokens(null);
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
s.setItem(t, JSON.stringify(r)), n.setTokens(r);
|
|
358
|
+
},
|
|
359
|
+
clear: () => {
|
|
360
|
+
s.removeItem(t), n.clear();
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
}, sn = (e) => {
|
|
364
|
+
if (tn(e))
|
|
365
|
+
return e;
|
|
366
|
+
const { strategy: t = "localStorage", storageKey: n = en } = e ?? {};
|
|
367
|
+
switch (t) {
|
|
368
|
+
case "localStorage":
|
|
369
|
+
return je("localStorage", n);
|
|
370
|
+
case "sessionStorage":
|
|
371
|
+
return je("sessionStorage", n);
|
|
372
|
+
case "memory":
|
|
373
|
+
default:
|
|
374
|
+
return dt();
|
|
375
|
+
}
|
|
376
|
+
}, qe = {
|
|
377
|
+
status: null,
|
|
378
|
+
isLoadingStatus: !1,
|
|
379
|
+
isPerformingAction: !1,
|
|
380
|
+
lastError: null
|
|
381
|
+
}, Ge = (e) => e instanceof Error ? e : typeof e == "string" ? new Error(e) : new Error("An unexpected MFA error occurred");
|
|
382
|
+
class rn {
|
|
383
|
+
client;
|
|
384
|
+
events;
|
|
385
|
+
readTokens;
|
|
386
|
+
state = qe;
|
|
387
|
+
emitter = new ut();
|
|
388
|
+
constructor(t) {
|
|
389
|
+
this.client = t.client, this.events = t.events, this.readTokens = t.readTokens;
|
|
390
|
+
}
|
|
391
|
+
setTokenResolver(t) {
|
|
392
|
+
this.readTokens = t;
|
|
393
|
+
}
|
|
394
|
+
subscribe(t) {
|
|
395
|
+
return this.emitter.on("change", t), t(this.state), () => this.emitter.off("change", t);
|
|
396
|
+
}
|
|
397
|
+
getSnapshot() {
|
|
398
|
+
return this.state;
|
|
399
|
+
}
|
|
400
|
+
reset() {
|
|
401
|
+
this.updateState(qe);
|
|
402
|
+
}
|
|
403
|
+
ensureTokens() {
|
|
404
|
+
const t = this.readTokens();
|
|
405
|
+
if (!t?.accessToken)
|
|
406
|
+
throw new Error("Cannot perform MFA actions without an authenticated session");
|
|
407
|
+
return t;
|
|
408
|
+
}
|
|
409
|
+
updateState(t) {
|
|
410
|
+
this.state = { ...this.state, ...t }, this.emitter.emit("change", this.state);
|
|
411
|
+
}
|
|
412
|
+
async withAction(t) {
|
|
413
|
+
this.updateState({ isPerformingAction: !0, lastError: null });
|
|
414
|
+
try {
|
|
415
|
+
return await t();
|
|
416
|
+
} catch (n) {
|
|
417
|
+
const s = Ge(n);
|
|
418
|
+
throw this.updateState({ lastError: s }), this.dispatchEvent(_.ERROR, s), s;
|
|
419
|
+
} finally {
|
|
420
|
+
this.updateState({ isPerformingAction: !1 });
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
dispatchEvent(t, n) {
|
|
424
|
+
this.events.emit(t, { type: t, payload: n });
|
|
425
|
+
}
|
|
426
|
+
async getStatus(t = !1) {
|
|
427
|
+
if (!t && this.state.status)
|
|
428
|
+
return this.state.status;
|
|
429
|
+
let n;
|
|
430
|
+
try {
|
|
431
|
+
n = this.ensureTokens();
|
|
432
|
+
} catch (s) {
|
|
433
|
+
throw this.updateState({ status: null }), s;
|
|
434
|
+
}
|
|
435
|
+
this.updateState({ isLoadingStatus: !0, lastError: null });
|
|
436
|
+
try {
|
|
437
|
+
const s = await this.client.getMfaStatus(n);
|
|
438
|
+
return this.updateState({ status: s, isLoadingStatus: !1 }), s;
|
|
439
|
+
} catch (s) {
|
|
440
|
+
const r = Ge(s);
|
|
441
|
+
throw this.updateState({ isLoadingStatus: !1, lastError: r }), this.dispatchEvent(_.ERROR, r), r;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
async refreshStatus() {
|
|
445
|
+
return this.getStatus(!0);
|
|
446
|
+
}
|
|
447
|
+
async toggleMfa(t) {
|
|
448
|
+
return this.withAction(async () => {
|
|
449
|
+
const n = this.ensureTokens(), s = await this.client.toggleMfa(n, t);
|
|
450
|
+
return await this.refreshStatus().catch(() => {
|
|
451
|
+
}), s;
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
async setupTotp() {
|
|
455
|
+
return this.withAction(async () => {
|
|
456
|
+
const t = this.ensureTokens();
|
|
457
|
+
return await this.client.setupTotp(t);
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
async verifyTotpSetup(t) {
|
|
461
|
+
return this.withAction(async () => {
|
|
462
|
+
const n = this.ensureTokens(), s = await this.client.verifyTotpSetup(n, t);
|
|
463
|
+
return await this.refreshStatus().catch(() => {
|
|
464
|
+
}), s;
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
async generateRecoveryCode() {
|
|
468
|
+
return this.withAction(async () => {
|
|
469
|
+
const t = this.ensureTokens(), n = await this.client.generateRecoveryCode(t);
|
|
470
|
+
return await this.refreshStatus().catch(() => {
|
|
471
|
+
}), n;
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
async resetTotp(t) {
|
|
475
|
+
return this.withAction(async () => {
|
|
476
|
+
const n = this.ensureTokens(), s = await this.client.resetTotp(n, t);
|
|
477
|
+
return await this.refreshStatus().catch(() => {
|
|
478
|
+
}), s;
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
async removeDevice(t) {
|
|
482
|
+
return this.withAction(async () => {
|
|
483
|
+
const n = this.ensureTokens(), s = await this.client.removeMfaDevice(n, t);
|
|
484
|
+
return await this.refreshStatus().catch(() => {
|
|
485
|
+
}), s;
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
async ensureStatusLoaded() {
|
|
489
|
+
if (!this.state.status && !this.state.isLoadingStatus)
|
|
490
|
+
try {
|
|
491
|
+
await this.getStatus();
|
|
492
|
+
} catch {
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
getAvailableMethods() {
|
|
496
|
+
return this.state.status?.availableMethods ?? [];
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
const P = {
|
|
500
|
+
providers: {
|
|
501
|
+
email: { enabled: !1 },
|
|
502
|
+
phone: { enabled: !1 }
|
|
503
|
+
},
|
|
504
|
+
emailAuth: { enabled: !1 },
|
|
505
|
+
phoneAuth: { enabled: !1 },
|
|
506
|
+
registration: { enabled: !1 },
|
|
507
|
+
mfa: { enabled: !1, methods: [] },
|
|
508
|
+
tenants: { mode: Z.SINGLE, defaultTenantId: null, options: [] },
|
|
509
|
+
sso: { enabled: !1, providers: [] },
|
|
510
|
+
ui: void 0
|
|
511
|
+
}, Ne = (e) => ({
|
|
512
|
+
...P,
|
|
513
|
+
...e,
|
|
514
|
+
emailAuth: { ...P.emailAuth, ...e?.emailAuth },
|
|
515
|
+
phoneAuth: { ...P.phoneAuth, ...e?.phoneAuth },
|
|
516
|
+
registration: { ...P.registration, ...e?.registration },
|
|
517
|
+
mfa: {
|
|
518
|
+
...P.mfa,
|
|
519
|
+
...e?.mfa,
|
|
520
|
+
methods: e?.mfa?.methods ?? P.mfa.methods
|
|
521
|
+
},
|
|
522
|
+
tenants: e?.tenants ? {
|
|
523
|
+
...P.tenants,
|
|
524
|
+
...e.tenants,
|
|
525
|
+
options: e.tenants.options ?? P.tenants?.options ?? []
|
|
526
|
+
} : P.tenants,
|
|
527
|
+
sso: e?.sso ? {
|
|
528
|
+
...P.sso,
|
|
529
|
+
...e.sso,
|
|
530
|
+
providers: e.sso.providers ?? P.sso?.providers ?? []
|
|
531
|
+
} : P.sso,
|
|
532
|
+
ui: e?.ui ?? P.ui
|
|
533
|
+
}), on = (e, t) => {
|
|
534
|
+
const n = e.getTokens(), s = t.initialBackendConfig ? Ne(t.initialBackendConfig) : null, r = s?.tenants?.defaultTenantId ?? null;
|
|
535
|
+
return {
|
|
536
|
+
status: n ? F.LOADING : F.IDLE,
|
|
537
|
+
isLoading: !!n,
|
|
538
|
+
isLoadingUser: !!n,
|
|
539
|
+
user: null,
|
|
540
|
+
session: null,
|
|
541
|
+
tokens: n ?? null,
|
|
542
|
+
error: null,
|
|
543
|
+
isMfaRequired: !1,
|
|
544
|
+
mfaMethods: [],
|
|
545
|
+
backendConfig: s,
|
|
546
|
+
tenantId: r
|
|
547
|
+
};
|
|
548
|
+
}, an = (e, t) => {
|
|
549
|
+
switch (t.type) {
|
|
550
|
+
case "SET_STATUS":
|
|
551
|
+
return { ...e, status: t.status };
|
|
552
|
+
case "SET_LOADING":
|
|
553
|
+
return { ...e, isLoading: t.value };
|
|
554
|
+
case "SET_LOADING_USER":
|
|
555
|
+
return { ...e, isLoadingUser: t.value };
|
|
556
|
+
case "SET_USER":
|
|
557
|
+
return { ...e, user: t.user, isLoadingUser: !1 };
|
|
558
|
+
case "SET_SESSION":
|
|
559
|
+
return { ...e, session: t.session };
|
|
560
|
+
case "SET_TOKENS":
|
|
561
|
+
return { ...e, tokens: t.tokens };
|
|
562
|
+
case "SET_ERROR":
|
|
563
|
+
return { ...e, error: t.error };
|
|
564
|
+
case "SET_MFA_REQUIRED":
|
|
565
|
+
return {
|
|
566
|
+
...e,
|
|
567
|
+
isMfaRequired: !0,
|
|
568
|
+
mfaMethods: t.methods,
|
|
569
|
+
status: F.AUTHENTICATED
|
|
570
|
+
};
|
|
571
|
+
case "CLEAR_MFA":
|
|
572
|
+
return { ...e, isMfaRequired: !1, mfaMethods: [] };
|
|
573
|
+
case "SET_BACKEND_CONFIG":
|
|
574
|
+
return { ...e, backendConfig: t.config };
|
|
575
|
+
case "SET_TENANT":
|
|
576
|
+
return { ...e, tenantId: t.tenantId ?? null };
|
|
577
|
+
case "RESET":
|
|
578
|
+
return {
|
|
579
|
+
status: F.UNAUTHENTICATED,
|
|
580
|
+
isLoading: !1,
|
|
581
|
+
isLoadingUser: !1,
|
|
582
|
+
user: null,
|
|
583
|
+
session: null,
|
|
584
|
+
tokens: null,
|
|
585
|
+
error: null,
|
|
586
|
+
isMfaRequired: !1,
|
|
587
|
+
mfaMethods: [],
|
|
588
|
+
backendConfig: e.backendConfig,
|
|
589
|
+
tenantId: e.backendConfig?.tenants?.defaultTenantId ?? null
|
|
590
|
+
};
|
|
591
|
+
default:
|
|
592
|
+
return e;
|
|
593
|
+
}
|
|
594
|
+
}, N = (e, t, n) => {
|
|
595
|
+
e.emit(t, { type: t, payload: n });
|
|
596
|
+
}, cn = (e) => e && typeof e.getTokens == "function" ? e : sn(e), un = (e) => {
|
|
597
|
+
const t = oe(void 0), n = oe(void 0);
|
|
598
|
+
return (!t.current || n.current !== e.tokenStorage) && (t.current = cn(e.tokenStorage), n.current = e.tokenStorage), t.current;
|
|
599
|
+
}, Js = ({
|
|
600
|
+
config: e,
|
|
601
|
+
children: t,
|
|
602
|
+
loadingFallback: n = null,
|
|
603
|
+
autoLoadProfile: s = !0
|
|
604
|
+
}) => {
|
|
605
|
+
const r = un(e), i = oe(
|
|
606
|
+
new ut()
|
|
607
|
+
), [o, a] = Ft(an, on(r, e)), f = x(
|
|
608
|
+
() => Zt({
|
|
609
|
+
baseUrl: e.baseUrl,
|
|
610
|
+
endpoints: e.endpoints,
|
|
611
|
+
defaultHeaders: e.defaultHeaders
|
|
612
|
+
}),
|
|
613
|
+
[e.baseUrl, e.endpoints, e.defaultHeaders]
|
|
614
|
+
), l = oe(o.tokens);
|
|
615
|
+
l.current = o.tokens;
|
|
616
|
+
const c = () => r.getTokens() ?? l.current ?? null, p = oe(null);
|
|
617
|
+
p.current ? p.current.setTokenResolver(c) : p.current = new rn({
|
|
618
|
+
client: f,
|
|
619
|
+
events: i.current,
|
|
620
|
+
readTokens: c
|
|
621
|
+
});
|
|
622
|
+
const T = p.current, R = (m) => {
|
|
623
|
+
if (!m || !m.accessToken) {
|
|
624
|
+
r.clear(), a({ type: "SET_TOKENS", tokens: null }), l.current = null, T?.reset();
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
r.setTokens(m), a({ type: "SET_TOKENS", tokens: m }), l.current = m, r.getTokens()?.accessToken || console.error("[NestAuth] Warning: Tokens were not persisted correctly to storage");
|
|
628
|
+
}, d = async (m, E = {}) => m.isRequiresMfa ? (a({ type: "SET_MFA_REQUIRED", methods: o.backendConfig?.mfa.methods ?? [] }), N(i.current, _.MFA_REQUIRED, {
|
|
629
|
+
methods: o.backendConfig?.mfa.methods ?? []
|
|
630
|
+
}), m) : (m.accessToken && R({
|
|
631
|
+
accessToken: m.accessToken,
|
|
632
|
+
refreshToken: m.refreshToken ?? null
|
|
633
|
+
}), a({ type: "CLEAR_MFA" }), E.skipProfileFetch ? m.user && (a({ type: "SET_USER", user: m.user ?? null }), a({ type: "SET_STATUS", status: F.AUTHENTICATED }), N(i.current, _.SIGNED_IN, {
|
|
634
|
+
user: m.user,
|
|
635
|
+
tokens: {
|
|
636
|
+
accessToken: m.accessToken ?? "",
|
|
637
|
+
refreshToken: m.refreshToken ?? null
|
|
638
|
+
}
|
|
639
|
+
}), K("login")) : (await y(), K("login")), m), y = async () => {
|
|
640
|
+
const m = c();
|
|
641
|
+
if (!m?.accessToken)
|
|
642
|
+
return null;
|
|
643
|
+
try {
|
|
644
|
+
a({ type: "SET_LOADING", value: !0 }), a({ type: "SET_LOADING_USER", value: !0 });
|
|
645
|
+
const E = await f.getProfile(m), w = await f.getSession(m).catch(() => null);
|
|
646
|
+
a({ type: "SET_USER", user: E }), a({ type: "SET_SESSION", session: w }), a({ type: "SET_STATUS", status: F.AUTHENTICATED }), a({ type: "SET_LOADING", value: !1 }), N(i.current, _.PROFILE_LOADED, { user: E, session: w });
|
|
647
|
+
const j = c();
|
|
648
|
+
return e.onSignedIn?.({
|
|
649
|
+
user: E,
|
|
650
|
+
session: w,
|
|
651
|
+
tokens: j ?? m
|
|
652
|
+
}), T?.ensureStatusLoaded(), E;
|
|
653
|
+
} catch (E) {
|
|
654
|
+
return a({ type: "SET_ERROR", error: E }), a({ type: "SET_LOADING", value: !1 }), a({ type: "SET_LOADING_USER", value: !1 }), E?.status === 401 || E?.status === 403 || E?.message?.includes("Unauthorized") || E?.message?.includes("Forbidden") ? (a({ type: "SET_STATUS", status: F.UNAUTHENTICATED }), r.clear()) : console.warn("[NestAuth] Failed to load profile, but keeping tokens:", E), null;
|
|
655
|
+
}
|
|
656
|
+
}, h = async () => {
|
|
657
|
+
try {
|
|
658
|
+
a({ type: "SET_LOADING", value: !0 });
|
|
659
|
+
const m = await f.fetchClientConfig(), E = Ne(m);
|
|
660
|
+
return a({ type: "SET_BACKEND_CONFIG", config: E }), a({ type: "SET_TENANT", tenantId: E.tenants.defaultTenantId ?? null }), N(i.current, _.CONFIG_LOADED, E), E;
|
|
661
|
+
} catch (m) {
|
|
662
|
+
if (console.error("[NestAuth] Failed to fetch backend config:", m), a({ type: "SET_ERROR", error: m }), e.initialBackendConfig) {
|
|
663
|
+
const E = Ne(e.initialBackendConfig);
|
|
664
|
+
return a({ type: "SET_BACKEND_CONFIG", config: E }), E;
|
|
665
|
+
}
|
|
666
|
+
return o.backendConfig ?? null;
|
|
667
|
+
} finally {
|
|
668
|
+
a({ type: "SET_LOADING", value: !1 });
|
|
669
|
+
}
|
|
670
|
+
};
|
|
671
|
+
Mt(() => {
|
|
672
|
+
let m = !0;
|
|
673
|
+
return m && (async () => {
|
|
674
|
+
e.autoFetchConfig && await h();
|
|
675
|
+
const w = c();
|
|
676
|
+
s && w?.accessToken ? await y() : w || a({ type: "SET_STATUS", status: F.UNAUTHENTICATED });
|
|
677
|
+
})(), () => {
|
|
678
|
+
m = !1;
|
|
679
|
+
};
|
|
680
|
+
}, [e.autoFetchConfig, s, o.tokens?.accessToken]);
|
|
681
|
+
const b = () => a({ type: "SET_ERROR", error: null }), A = async (m) => {
|
|
682
|
+
a({ type: "SET_LOADING", value: !0 }), b();
|
|
683
|
+
try {
|
|
684
|
+
const E = await f.login({
|
|
685
|
+
...m,
|
|
686
|
+
tenantId: m.tenantId ?? o.tenantId ?? void 0
|
|
687
|
+
}), w = await d(E);
|
|
688
|
+
return a({ type: "SET_LOADING", value: !1 }), w;
|
|
689
|
+
} catch (E) {
|
|
690
|
+
throw a({ type: "SET_ERROR", error: E }), a({ type: "SET_LOADING", value: !1 }), N(i.current, _.ERROR, E), E;
|
|
691
|
+
}
|
|
692
|
+
}, S = async (m) => {
|
|
693
|
+
a({ type: "SET_LOADING", value: !0 }), b();
|
|
694
|
+
try {
|
|
695
|
+
const E = await f.register({
|
|
696
|
+
...m,
|
|
697
|
+
tenantId: m.tenantId ?? o.tenantId ?? void 0
|
|
698
|
+
}), w = await d(E);
|
|
699
|
+
return a({ type: "SET_LOADING", value: !1 }), w;
|
|
700
|
+
} catch (E) {
|
|
701
|
+
throw a({ type: "SET_ERROR", error: E }), a({ type: "SET_LOADING", value: !1 }), N(i.current, _.ERROR, E), E;
|
|
702
|
+
}
|
|
703
|
+
}, C = async () => {
|
|
704
|
+
const m = c();
|
|
705
|
+
if (!m) {
|
|
706
|
+
a({ type: "RESET" }), r.clear();
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
a({ type: "SET_LOADING", value: !0 }), b();
|
|
710
|
+
try {
|
|
711
|
+
await f.logout(m), r.clear(), a({ type: "RESET" }), N(i.current, _.SIGNED_OUT), e.onSignedOut?.(), K("logout");
|
|
712
|
+
} catch (E) {
|
|
713
|
+
throw a({ type: "SET_ERROR", error: E }), N(i.current, _.ERROR, E), E;
|
|
714
|
+
} finally {
|
|
715
|
+
a({ type: "SET_LOADING", value: !1 });
|
|
716
|
+
}
|
|
717
|
+
}, k = async () => {
|
|
718
|
+
const m = c();
|
|
719
|
+
if (m) {
|
|
720
|
+
a({ type: "SET_LOADING", value: !0 }), b();
|
|
721
|
+
try {
|
|
722
|
+
await f.logoutAll(m), r.clear(), a({ type: "RESET" }), N(i.current, _.SIGNED_OUT), e.onSignedOut?.(), K("logout");
|
|
723
|
+
} catch (E) {
|
|
724
|
+
throw a({ type: "SET_ERROR", error: E }), N(i.current, _.ERROR, E), E;
|
|
725
|
+
} finally {
|
|
726
|
+
a({ type: "SET_LOADING", value: !1 });
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
}, z = async () => {
|
|
730
|
+
const m = c();
|
|
731
|
+
if (!m?.refreshToken)
|
|
732
|
+
return null;
|
|
733
|
+
try {
|
|
734
|
+
const E = await f.refreshToken({
|
|
735
|
+
refreshToken: m.refreshToken
|
|
736
|
+
}), w = {
|
|
737
|
+
accessToken: E.accessToken,
|
|
738
|
+
refreshToken: E.refreshToken ?? m.refreshToken
|
|
739
|
+
};
|
|
740
|
+
return R(w), N(i.current, _.TOKEN_REFRESHED, w), e.onTokenRefreshed?.(w), s && await y(), E;
|
|
741
|
+
} catch (E) {
|
|
742
|
+
return a({ type: "SET_ERROR", error: E }), r.clear(), a({ type: "RESET" }), N(i.current, _.ERROR, E), null;
|
|
743
|
+
}
|
|
744
|
+
}, D = async (m) => {
|
|
745
|
+
const E = c();
|
|
746
|
+
if (!E)
|
|
747
|
+
throw new Error("Cannot send MFA code without an authenticated session");
|
|
748
|
+
return f.sendMfaCode(E, m);
|
|
749
|
+
}, se = async (m) => {
|
|
750
|
+
const E = c();
|
|
751
|
+
if (!E)
|
|
752
|
+
throw new Error("Cannot verify MFA without an authenticated session");
|
|
753
|
+
a({ type: "SET_LOADING", value: !0 }), b();
|
|
754
|
+
try {
|
|
755
|
+
const w = await f.verifyMfa(E, m);
|
|
756
|
+
a({ type: "CLEAR_MFA" });
|
|
757
|
+
const j = await d(w);
|
|
758
|
+
return a({ type: "SET_LOADING", value: !1 }), K("afterMfa"), j;
|
|
759
|
+
} catch (w) {
|
|
760
|
+
throw a({ type: "SET_ERROR", error: w }), a({ type: "SET_LOADING", value: !1 }), N(i.current, _.ERROR, w), w;
|
|
761
|
+
}
|
|
762
|
+
}, Q = (m) => f.forgotPassword(m), le = (m) => f.verifyForgotPasswordOtp(m), fe = (m) => f.resetPasswordWithToken(m), Y = async (m) => {
|
|
763
|
+
const E = c();
|
|
764
|
+
if (!E?.accessToken)
|
|
765
|
+
throw new Error("Cannot change password without an authenticated session");
|
|
766
|
+
a({ type: "SET_LOADING", value: !0 });
|
|
767
|
+
try {
|
|
768
|
+
const w = await f.changePassword(m, E), j = {
|
|
769
|
+
accessToken: w.accessToken,
|
|
770
|
+
refreshToken: w.refreshToken ?? E.refreshToken ?? null
|
|
771
|
+
};
|
|
772
|
+
return R(j), N(i.current, _.TOKEN_REFRESHED, j), e.onTokenRefreshed?.(j), await y(), a({ type: "SET_LOADING", value: !1 }), w;
|
|
773
|
+
} catch (w) {
|
|
774
|
+
throw a({ type: "SET_ERROR", error: w }), a({ type: "SET_LOADING", value: !1 }), N(i.current, _.ERROR, w), w;
|
|
775
|
+
}
|
|
776
|
+
}, V = async () => {
|
|
777
|
+
const m = c();
|
|
778
|
+
if (!m)
|
|
779
|
+
throw new Error("Cannot send email verification without an authenticated session");
|
|
780
|
+
a({ type: "SET_LOADING", value: !0 });
|
|
781
|
+
try {
|
|
782
|
+
return await f.sendEmailVerification(m);
|
|
783
|
+
} catch (E) {
|
|
784
|
+
throw a({ type: "SET_ERROR", error: E }), N(i.current, _.ERROR, E), E;
|
|
785
|
+
} finally {
|
|
786
|
+
a({ type: "SET_LOADING", value: !1 });
|
|
787
|
+
}
|
|
788
|
+
}, $ = async (m) => {
|
|
789
|
+
const E = c();
|
|
790
|
+
if (!E)
|
|
791
|
+
throw new Error("Cannot verify email without an authenticated session");
|
|
792
|
+
a({ type: "SET_LOADING", value: !0 });
|
|
793
|
+
try {
|
|
794
|
+
const w = await f.verifyEmail(E, m);
|
|
795
|
+
return await y(), w;
|
|
796
|
+
} catch (w) {
|
|
797
|
+
throw a({ type: "SET_ERROR", error: w }), N(i.current, _.ERROR, w), w;
|
|
798
|
+
} finally {
|
|
799
|
+
a({ type: "SET_LOADING", value: !1 });
|
|
800
|
+
}
|
|
801
|
+
}, de = (m, E) => {
|
|
802
|
+
if (E?.persist === !1) {
|
|
803
|
+
a({ type: "SET_TOKENS", tokens: m }), l.current = m, m?.accessToken || T?.reset();
|
|
804
|
+
return;
|
|
805
|
+
}
|
|
806
|
+
R(m);
|
|
807
|
+
}, U = (m) => {
|
|
808
|
+
a({ type: "SET_TENANT", tenantId: m });
|
|
809
|
+
}, he = (m) => {
|
|
810
|
+
a({ type: "SET_USER", user: m });
|
|
811
|
+
}, M = (m) => {
|
|
812
|
+
m && (e.onRedirect ? e.onRedirect(m) : typeof window < "u" && (window.location.href = m));
|
|
813
|
+
}, K = (m) => {
|
|
814
|
+
const E = e.redirects?.[m];
|
|
815
|
+
E && M(E);
|
|
816
|
+
}, Ae = {
|
|
817
|
+
status: o.status,
|
|
818
|
+
user: o.user,
|
|
819
|
+
session: o.session,
|
|
820
|
+
tokens: o.tokens,
|
|
821
|
+
isMfaRequired: o.isMfaRequired,
|
|
822
|
+
mfaMethods: o.mfaMethods,
|
|
823
|
+
backendConfig: o.backendConfig ?? void 0,
|
|
824
|
+
tenantId: o.tenantId ?? void 0,
|
|
825
|
+
error: o.error,
|
|
826
|
+
isLoading: o.isLoading || o.status === F.LOADING,
|
|
827
|
+
isLoadingUser: o.isLoadingUser,
|
|
828
|
+
baseUrl: e.baseUrl,
|
|
829
|
+
events: i.current,
|
|
830
|
+
login: A,
|
|
831
|
+
register: S,
|
|
832
|
+
logout: C,
|
|
833
|
+
logoutAll: k,
|
|
834
|
+
refresh: z,
|
|
835
|
+
sendMfaCode: D,
|
|
836
|
+
verifyMfa: se,
|
|
837
|
+
forgotPassword: Q,
|
|
838
|
+
verifyForgotPasswordOtp: le,
|
|
839
|
+
resetPasswordWithToken: fe,
|
|
840
|
+
changePassword: Y,
|
|
841
|
+
sendEmailVerification: V,
|
|
842
|
+
verifyEmail: $,
|
|
843
|
+
fetchBackendConfig: h,
|
|
844
|
+
setTokens: de,
|
|
845
|
+
setTenantId: U,
|
|
846
|
+
clearError: b,
|
|
847
|
+
setUser: he,
|
|
848
|
+
redirects: e.redirects,
|
|
849
|
+
navigate: M
|
|
850
|
+
}, H = o.isLoading && n ? n : t;
|
|
851
|
+
return /* @__PURE__ */ Me(lt.Provider, { value: Ae, children: /* @__PURE__ */ Me(ft.Provider, { value: T, children: H }) });
|
|
852
|
+
};
|
|
853
|
+
function ht(e, t) {
|
|
854
|
+
return function() {
|
|
855
|
+
return e.apply(t, arguments);
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
const { toString: ln } = Object.prototype, { getPrototypeOf: Ue } = Object, { iterator: ge, toStringTag: pt } = Symbol, Se = /* @__PURE__ */ ((e) => (t) => {
|
|
859
|
+
const n = ln.call(t);
|
|
860
|
+
return e[n] || (e[n] = n.slice(8, -1).toLowerCase());
|
|
861
|
+
})(/* @__PURE__ */ Object.create(null)), B = (e) => (e = e.toLowerCase(), (t) => Se(t) === e), we = (e) => (t) => typeof t === e, { isArray: te } = Array, ee = we("undefined");
|
|
862
|
+
function ie(e) {
|
|
863
|
+
return e !== null && !ee(e) && e.constructor !== null && !ee(e.constructor) && L(e.constructor.isBuffer) && e.constructor.isBuffer(e);
|
|
864
|
+
}
|
|
865
|
+
const mt = B("ArrayBuffer");
|
|
866
|
+
function fn(e) {
|
|
867
|
+
let t;
|
|
868
|
+
return typeof ArrayBuffer < "u" && ArrayBuffer.isView ? t = ArrayBuffer.isView(e) : t = e && e.buffer && mt(e.buffer), t;
|
|
869
|
+
}
|
|
870
|
+
const dn = we("string"), L = we("function"), Et = we("number"), ae = (e) => e !== null && typeof e == "object", hn = (e) => e === !0 || e === !1, me = (e) => {
|
|
871
|
+
if (Se(e) !== "object")
|
|
872
|
+
return !1;
|
|
873
|
+
const t = Ue(e);
|
|
874
|
+
return (t === null || t === Object.prototype || Object.getPrototypeOf(t) === null) && !(pt in e) && !(ge in e);
|
|
875
|
+
}, pn = (e) => {
|
|
876
|
+
if (!ae(e) || ie(e))
|
|
877
|
+
return !1;
|
|
878
|
+
try {
|
|
879
|
+
return Object.keys(e).length === 0 && Object.getPrototypeOf(e) === Object.prototype;
|
|
880
|
+
} catch {
|
|
881
|
+
return !1;
|
|
882
|
+
}
|
|
883
|
+
}, mn = B("Date"), En = B("File"), yn = B("Blob"), Tn = B("FileList"), gn = (e) => ae(e) && L(e.pipe), Sn = (e) => {
|
|
884
|
+
let t;
|
|
885
|
+
return e && (typeof FormData == "function" && e instanceof FormData || L(e.append) && ((t = Se(e)) === "formdata" || // detect form-data instance
|
|
886
|
+
t === "object" && L(e.toString) && e.toString() === "[object FormData]"));
|
|
887
|
+
}, wn = B("URLSearchParams"), [Rn, bn, An, On] = ["ReadableStream", "Request", "Response", "Headers"].map(B), _n = (e) => e.trim ? e.trim() : e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
|
888
|
+
function ce(e, t, { allOwnKeys: n = !1 } = {}) {
|
|
889
|
+
if (e === null || typeof e > "u")
|
|
890
|
+
return;
|
|
891
|
+
let s, r;
|
|
892
|
+
if (typeof e != "object" && (e = [e]), te(e))
|
|
893
|
+
for (s = 0, r = e.length; s < r; s++)
|
|
894
|
+
t.call(null, e[s], s, e);
|
|
895
|
+
else {
|
|
896
|
+
if (ie(e))
|
|
897
|
+
return;
|
|
898
|
+
const i = n ? Object.getOwnPropertyNames(e) : Object.keys(e), o = i.length;
|
|
899
|
+
let a;
|
|
900
|
+
for (s = 0; s < o; s++)
|
|
901
|
+
a = i[s], t.call(null, e[a], a, e);
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
function yt(e, t) {
|
|
905
|
+
if (ie(e))
|
|
906
|
+
return null;
|
|
907
|
+
t = t.toLowerCase();
|
|
908
|
+
const n = Object.keys(e);
|
|
909
|
+
let s = n.length, r;
|
|
910
|
+
for (; s-- > 0; )
|
|
911
|
+
if (r = n[s], t === r.toLowerCase())
|
|
912
|
+
return r;
|
|
913
|
+
return null;
|
|
914
|
+
}
|
|
915
|
+
const J = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global, Tt = (e) => !ee(e) && e !== J;
|
|
916
|
+
function ve() {
|
|
917
|
+
const { caseless: e, skipUndefined: t } = Tt(this) && this || {}, n = {}, s = (r, i) => {
|
|
918
|
+
const o = e && yt(n, i) || i;
|
|
919
|
+
me(n[o]) && me(r) ? n[o] = ve(n[o], r) : me(r) ? n[o] = ve({}, r) : te(r) ? n[o] = r.slice() : (!t || !ee(r)) && (n[o] = r);
|
|
920
|
+
};
|
|
921
|
+
for (let r = 0, i = arguments.length; r < i; r++)
|
|
922
|
+
arguments[r] && ce(arguments[r], s);
|
|
923
|
+
return n;
|
|
924
|
+
}
|
|
925
|
+
const kn = (e, t, n, { allOwnKeys: s } = {}) => (ce(t, (r, i) => {
|
|
926
|
+
n && L(r) ? e[i] = ht(r, n) : e[i] = r;
|
|
927
|
+
}, { allOwnKeys: s }), e), Cn = (e) => (e.charCodeAt(0) === 65279 && (e = e.slice(1)), e), Nn = (e, t, n, s) => {
|
|
928
|
+
e.prototype = Object.create(t.prototype, s), e.prototype.constructor = e, Object.defineProperty(e, "super", {
|
|
929
|
+
value: t.prototype
|
|
930
|
+
}), n && Object.assign(e.prototype, n);
|
|
931
|
+
}, vn = (e, t, n, s) => {
|
|
932
|
+
let r, i, o;
|
|
933
|
+
const a = {};
|
|
934
|
+
if (t = t || {}, e == null) return t;
|
|
935
|
+
do {
|
|
936
|
+
for (r = Object.getOwnPropertyNames(e), i = r.length; i-- > 0; )
|
|
937
|
+
o = r[i], (!s || s(o, e, t)) && !a[o] && (t[o] = e[o], a[o] = !0);
|
|
938
|
+
e = n !== !1 && Ue(e);
|
|
939
|
+
} while (e && (!n || n(e, t)) && e !== Object.prototype);
|
|
940
|
+
return t;
|
|
941
|
+
}, Dn = (e, t, n) => {
|
|
942
|
+
e = String(e), (n === void 0 || n > e.length) && (n = e.length), n -= t.length;
|
|
943
|
+
const s = e.indexOf(t, n);
|
|
944
|
+
return s !== -1 && s === n;
|
|
945
|
+
}, Ln = (e) => {
|
|
946
|
+
if (!e) return null;
|
|
947
|
+
if (te(e)) return e;
|
|
948
|
+
let t = e.length;
|
|
949
|
+
if (!Et(t)) return null;
|
|
950
|
+
const n = new Array(t);
|
|
951
|
+
for (; t-- > 0; )
|
|
952
|
+
n[t] = e[t];
|
|
953
|
+
return n;
|
|
954
|
+
}, In = /* @__PURE__ */ ((e) => (t) => e && t instanceof e)(typeof Uint8Array < "u" && Ue(Uint8Array)), Pn = (e, t) => {
|
|
955
|
+
const s = (e && e[ge]).call(e);
|
|
956
|
+
let r;
|
|
957
|
+
for (; (r = s.next()) && !r.done; ) {
|
|
958
|
+
const i = r.value;
|
|
959
|
+
t.call(e, i[0], i[1]);
|
|
960
|
+
}
|
|
961
|
+
}, Un = (e, t) => {
|
|
962
|
+
let n;
|
|
963
|
+
const s = [];
|
|
964
|
+
for (; (n = e.exec(t)) !== null; )
|
|
965
|
+
s.push(n);
|
|
966
|
+
return s;
|
|
967
|
+
}, xn = B("HTMLFormElement"), Fn = (e) => e.toLowerCase().replace(
|
|
968
|
+
/[-_\s]([a-z\d])(\w*)/g,
|
|
969
|
+
function(n, s, r) {
|
|
970
|
+
return s.toUpperCase() + r;
|
|
971
|
+
}
|
|
972
|
+
), ze = (({ hasOwnProperty: e }) => (t, n) => e.call(t, n))(Object.prototype), Mn = B("RegExp"), gt = (e, t) => {
|
|
973
|
+
const n = Object.getOwnPropertyDescriptors(e), s = {};
|
|
974
|
+
ce(n, (r, i) => {
|
|
975
|
+
let o;
|
|
976
|
+
(o = t(r, i, e)) !== !1 && (s[i] = o || r);
|
|
977
|
+
}), Object.defineProperties(e, s);
|
|
978
|
+
}, Bn = (e) => {
|
|
979
|
+
gt(e, (t, n) => {
|
|
980
|
+
if (L(e) && ["arguments", "caller", "callee"].indexOf(n) !== -1)
|
|
981
|
+
return !1;
|
|
982
|
+
const s = e[n];
|
|
983
|
+
if (L(s)) {
|
|
984
|
+
if (t.enumerable = !1, "writable" in t) {
|
|
985
|
+
t.writable = !1;
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
988
|
+
t.set || (t.set = () => {
|
|
989
|
+
throw Error("Can not rewrite read-only method '" + n + "'");
|
|
990
|
+
});
|
|
991
|
+
}
|
|
992
|
+
});
|
|
993
|
+
}, Hn = (e, t) => {
|
|
994
|
+
const n = {}, s = (r) => {
|
|
995
|
+
r.forEach((i) => {
|
|
996
|
+
n[i] = !0;
|
|
997
|
+
});
|
|
998
|
+
};
|
|
999
|
+
return te(e) ? s(e) : s(String(e).split(t)), n;
|
|
1000
|
+
}, jn = () => {
|
|
1001
|
+
}, qn = (e, t) => e != null && Number.isFinite(e = +e) ? e : t;
|
|
1002
|
+
function Gn(e) {
|
|
1003
|
+
return !!(e && L(e.append) && e[pt] === "FormData" && e[ge]);
|
|
1004
|
+
}
|
|
1005
|
+
const zn = (e) => {
|
|
1006
|
+
const t = new Array(10), n = (s, r) => {
|
|
1007
|
+
if (ae(s)) {
|
|
1008
|
+
if (t.indexOf(s) >= 0)
|
|
1009
|
+
return;
|
|
1010
|
+
if (ie(s))
|
|
1011
|
+
return s;
|
|
1012
|
+
if (!("toJSON" in s)) {
|
|
1013
|
+
t[r] = s;
|
|
1014
|
+
const i = te(s) ? [] : {};
|
|
1015
|
+
return ce(s, (o, a) => {
|
|
1016
|
+
const f = n(o, r + 1);
|
|
1017
|
+
!ee(f) && (i[a] = f);
|
|
1018
|
+
}), t[r] = void 0, i;
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
return s;
|
|
1022
|
+
};
|
|
1023
|
+
return n(e, 0);
|
|
1024
|
+
}, $n = B("AsyncFunction"), Kn = (e) => e && (ae(e) || L(e)) && L(e.then) && L(e.catch), St = ((e, t) => e ? setImmediate : t ? ((n, s) => (J.addEventListener("message", ({ source: r, data: i }) => {
|
|
1025
|
+
r === J && i === n && s.length && s.shift()();
|
|
1026
|
+
}, !1), (r) => {
|
|
1027
|
+
s.push(r), J.postMessage(n, "*");
|
|
1028
|
+
}))(`axios@${Math.random()}`, []) : (n) => setTimeout(n))(
|
|
1029
|
+
typeof setImmediate == "function",
|
|
1030
|
+
L(J.postMessage)
|
|
1031
|
+
), Vn = typeof queueMicrotask < "u" ? queueMicrotask.bind(J) : typeof process < "u" && process.nextTick || St, Jn = (e) => e != null && L(e[ge]), u = {
|
|
1032
|
+
isArray: te,
|
|
1033
|
+
isArrayBuffer: mt,
|
|
1034
|
+
isBuffer: ie,
|
|
1035
|
+
isFormData: Sn,
|
|
1036
|
+
isArrayBufferView: fn,
|
|
1037
|
+
isString: dn,
|
|
1038
|
+
isNumber: Et,
|
|
1039
|
+
isBoolean: hn,
|
|
1040
|
+
isObject: ae,
|
|
1041
|
+
isPlainObject: me,
|
|
1042
|
+
isEmptyObject: pn,
|
|
1043
|
+
isReadableStream: Rn,
|
|
1044
|
+
isRequest: bn,
|
|
1045
|
+
isResponse: An,
|
|
1046
|
+
isHeaders: On,
|
|
1047
|
+
isUndefined: ee,
|
|
1048
|
+
isDate: mn,
|
|
1049
|
+
isFile: En,
|
|
1050
|
+
isBlob: yn,
|
|
1051
|
+
isRegExp: Mn,
|
|
1052
|
+
isFunction: L,
|
|
1053
|
+
isStream: gn,
|
|
1054
|
+
isURLSearchParams: wn,
|
|
1055
|
+
isTypedArray: In,
|
|
1056
|
+
isFileList: Tn,
|
|
1057
|
+
forEach: ce,
|
|
1058
|
+
merge: ve,
|
|
1059
|
+
extend: kn,
|
|
1060
|
+
trim: _n,
|
|
1061
|
+
stripBOM: Cn,
|
|
1062
|
+
inherits: Nn,
|
|
1063
|
+
toFlatObject: vn,
|
|
1064
|
+
kindOf: Se,
|
|
1065
|
+
kindOfTest: B,
|
|
1066
|
+
endsWith: Dn,
|
|
1067
|
+
toArray: Ln,
|
|
1068
|
+
forEachEntry: Pn,
|
|
1069
|
+
matchAll: Un,
|
|
1070
|
+
isHTMLForm: xn,
|
|
1071
|
+
hasOwnProperty: ze,
|
|
1072
|
+
hasOwnProp: ze,
|
|
1073
|
+
// an alias to avoid ESLint no-prototype-builtins detection
|
|
1074
|
+
reduceDescriptors: gt,
|
|
1075
|
+
freezeMethods: Bn,
|
|
1076
|
+
toObjectSet: Hn,
|
|
1077
|
+
toCamelCase: Fn,
|
|
1078
|
+
noop: jn,
|
|
1079
|
+
toFiniteNumber: qn,
|
|
1080
|
+
findKey: yt,
|
|
1081
|
+
global: J,
|
|
1082
|
+
isContextDefined: Tt,
|
|
1083
|
+
isSpecCompliantForm: Gn,
|
|
1084
|
+
toJSONObject: zn,
|
|
1085
|
+
isAsyncFn: $n,
|
|
1086
|
+
isThenable: Kn,
|
|
1087
|
+
setImmediate: St,
|
|
1088
|
+
asap: Vn,
|
|
1089
|
+
isIterable: Jn
|
|
1090
|
+
};
|
|
1091
|
+
function g(e, t, n, s, r) {
|
|
1092
|
+
Error.call(this), Error.captureStackTrace ? Error.captureStackTrace(this, this.constructor) : this.stack = new Error().stack, this.message = e, this.name = "AxiosError", t && (this.code = t), n && (this.config = n), s && (this.request = s), r && (this.response = r, this.status = r.status ? r.status : null);
|
|
1093
|
+
}
|
|
1094
|
+
u.inherits(g, Error, {
|
|
1095
|
+
toJSON: function() {
|
|
1096
|
+
return {
|
|
1097
|
+
// Standard
|
|
1098
|
+
message: this.message,
|
|
1099
|
+
name: this.name,
|
|
1100
|
+
// Microsoft
|
|
1101
|
+
description: this.description,
|
|
1102
|
+
number: this.number,
|
|
1103
|
+
// Mozilla
|
|
1104
|
+
fileName: this.fileName,
|
|
1105
|
+
lineNumber: this.lineNumber,
|
|
1106
|
+
columnNumber: this.columnNumber,
|
|
1107
|
+
stack: this.stack,
|
|
1108
|
+
// Axios
|
|
1109
|
+
config: u.toJSONObject(this.config),
|
|
1110
|
+
code: this.code,
|
|
1111
|
+
status: this.status
|
|
1112
|
+
};
|
|
1113
|
+
}
|
|
1114
|
+
});
|
|
1115
|
+
const wt = g.prototype, Rt = {};
|
|
1116
|
+
[
|
|
1117
|
+
"ERR_BAD_OPTION_VALUE",
|
|
1118
|
+
"ERR_BAD_OPTION",
|
|
1119
|
+
"ECONNABORTED",
|
|
1120
|
+
"ETIMEDOUT",
|
|
1121
|
+
"ERR_NETWORK",
|
|
1122
|
+
"ERR_FR_TOO_MANY_REDIRECTS",
|
|
1123
|
+
"ERR_DEPRECATED",
|
|
1124
|
+
"ERR_BAD_RESPONSE",
|
|
1125
|
+
"ERR_BAD_REQUEST",
|
|
1126
|
+
"ERR_CANCELED",
|
|
1127
|
+
"ERR_NOT_SUPPORT",
|
|
1128
|
+
"ERR_INVALID_URL"
|
|
1129
|
+
// eslint-disable-next-line func-names
|
|
1130
|
+
].forEach((e) => {
|
|
1131
|
+
Rt[e] = { value: e };
|
|
1132
|
+
});
|
|
1133
|
+
Object.defineProperties(g, Rt);
|
|
1134
|
+
Object.defineProperty(wt, "isAxiosError", { value: !0 });
|
|
1135
|
+
g.from = (e, t, n, s, r, i) => {
|
|
1136
|
+
const o = Object.create(wt);
|
|
1137
|
+
u.toFlatObject(e, o, function(c) {
|
|
1138
|
+
return c !== Error.prototype;
|
|
1139
|
+
}, (l) => l !== "isAxiosError");
|
|
1140
|
+
const a = e && e.message ? e.message : "Error", f = t == null && e ? e.code : t;
|
|
1141
|
+
return g.call(o, a, f, n, s, r), e && o.cause == null && Object.defineProperty(o, "cause", { value: e, configurable: !0 }), o.name = e && e.name || "Error", i && Object.assign(o, i), o;
|
|
1142
|
+
};
|
|
1143
|
+
const Wn = null;
|
|
1144
|
+
function De(e) {
|
|
1145
|
+
return u.isPlainObject(e) || u.isArray(e);
|
|
1146
|
+
}
|
|
1147
|
+
function bt(e) {
|
|
1148
|
+
return u.endsWith(e, "[]") ? e.slice(0, -2) : e;
|
|
1149
|
+
}
|
|
1150
|
+
function $e(e, t, n) {
|
|
1151
|
+
return e ? e.concat(t).map(function(r, i) {
|
|
1152
|
+
return r = bt(r), !n && i ? "[" + r + "]" : r;
|
|
1153
|
+
}).join(n ? "." : "") : t;
|
|
1154
|
+
}
|
|
1155
|
+
function Xn(e) {
|
|
1156
|
+
return u.isArray(e) && !e.some(De);
|
|
1157
|
+
}
|
|
1158
|
+
const Qn = u.toFlatObject(u, {}, null, function(t) {
|
|
1159
|
+
return /^is[A-Z]/.test(t);
|
|
1160
|
+
});
|
|
1161
|
+
function Re(e, t, n) {
|
|
1162
|
+
if (!u.isObject(e))
|
|
1163
|
+
throw new TypeError("target must be an object");
|
|
1164
|
+
t = t || new FormData(), n = u.toFlatObject(n, {
|
|
1165
|
+
metaTokens: !0,
|
|
1166
|
+
dots: !1,
|
|
1167
|
+
indexes: !1
|
|
1168
|
+
}, !1, function(y, h) {
|
|
1169
|
+
return !u.isUndefined(h[y]);
|
|
1170
|
+
});
|
|
1171
|
+
const s = n.metaTokens, r = n.visitor || c, i = n.dots, o = n.indexes, f = (n.Blob || typeof Blob < "u" && Blob) && u.isSpecCompliantForm(t);
|
|
1172
|
+
if (!u.isFunction(r))
|
|
1173
|
+
throw new TypeError("visitor must be a function");
|
|
1174
|
+
function l(d) {
|
|
1175
|
+
if (d === null) return "";
|
|
1176
|
+
if (u.isDate(d))
|
|
1177
|
+
return d.toISOString();
|
|
1178
|
+
if (u.isBoolean(d))
|
|
1179
|
+
return d.toString();
|
|
1180
|
+
if (!f && u.isBlob(d))
|
|
1181
|
+
throw new g("Blob is not supported. Use a Buffer instead.");
|
|
1182
|
+
return u.isArrayBuffer(d) || u.isTypedArray(d) ? f && typeof Blob == "function" ? new Blob([d]) : Buffer.from(d) : d;
|
|
1183
|
+
}
|
|
1184
|
+
function c(d, y, h) {
|
|
1185
|
+
let b = d;
|
|
1186
|
+
if (d && !h && typeof d == "object") {
|
|
1187
|
+
if (u.endsWith(y, "{}"))
|
|
1188
|
+
y = s ? y : y.slice(0, -2), d = JSON.stringify(d);
|
|
1189
|
+
else if (u.isArray(d) && Xn(d) || (u.isFileList(d) || u.endsWith(y, "[]")) && (b = u.toArray(d)))
|
|
1190
|
+
return y = bt(y), b.forEach(function(S, C) {
|
|
1191
|
+
!(u.isUndefined(S) || S === null) && t.append(
|
|
1192
|
+
// eslint-disable-next-line no-nested-ternary
|
|
1193
|
+
o === !0 ? $e([y], C, i) : o === null ? y : y + "[]",
|
|
1194
|
+
l(S)
|
|
1195
|
+
);
|
|
1196
|
+
}), !1;
|
|
1197
|
+
}
|
|
1198
|
+
return De(d) ? !0 : (t.append($e(h, y, i), l(d)), !1);
|
|
1199
|
+
}
|
|
1200
|
+
const p = [], T = Object.assign(Qn, {
|
|
1201
|
+
defaultVisitor: c,
|
|
1202
|
+
convertValue: l,
|
|
1203
|
+
isVisitable: De
|
|
1204
|
+
});
|
|
1205
|
+
function R(d, y) {
|
|
1206
|
+
if (!u.isUndefined(d)) {
|
|
1207
|
+
if (p.indexOf(d) !== -1)
|
|
1208
|
+
throw Error("Circular reference detected in " + y.join("."));
|
|
1209
|
+
p.push(d), u.forEach(d, function(b, A) {
|
|
1210
|
+
(!(u.isUndefined(b) || b === null) && r.call(
|
|
1211
|
+
t,
|
|
1212
|
+
b,
|
|
1213
|
+
u.isString(A) ? A.trim() : A,
|
|
1214
|
+
y,
|
|
1215
|
+
T
|
|
1216
|
+
)) === !0 && R(b, y ? y.concat(A) : [A]);
|
|
1217
|
+
}), p.pop();
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
if (!u.isObject(e))
|
|
1221
|
+
throw new TypeError("data must be an object");
|
|
1222
|
+
return R(e), t;
|
|
1223
|
+
}
|
|
1224
|
+
function Ke(e) {
|
|
1225
|
+
const t = {
|
|
1226
|
+
"!": "%21",
|
|
1227
|
+
"'": "%27",
|
|
1228
|
+
"(": "%28",
|
|
1229
|
+
")": "%29",
|
|
1230
|
+
"~": "%7E",
|
|
1231
|
+
"%20": "+",
|
|
1232
|
+
"%00": "\0"
|
|
1233
|
+
};
|
|
1234
|
+
return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g, function(s) {
|
|
1235
|
+
return t[s];
|
|
1236
|
+
});
|
|
1237
|
+
}
|
|
1238
|
+
function xe(e, t) {
|
|
1239
|
+
this._pairs = [], e && Re(e, this, t);
|
|
1240
|
+
}
|
|
1241
|
+
const At = xe.prototype;
|
|
1242
|
+
At.append = function(t, n) {
|
|
1243
|
+
this._pairs.push([t, n]);
|
|
1244
|
+
};
|
|
1245
|
+
At.toString = function(t) {
|
|
1246
|
+
const n = t ? function(s) {
|
|
1247
|
+
return t.call(this, s, Ke);
|
|
1248
|
+
} : Ke;
|
|
1249
|
+
return this._pairs.map(function(r) {
|
|
1250
|
+
return n(r[0]) + "=" + n(r[1]);
|
|
1251
|
+
}, "").join("&");
|
|
1252
|
+
};
|
|
1253
|
+
function Yn(e) {
|
|
1254
|
+
return encodeURIComponent(e).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+");
|
|
1255
|
+
}
|
|
1256
|
+
function Ot(e, t, n) {
|
|
1257
|
+
if (!t)
|
|
1258
|
+
return e;
|
|
1259
|
+
const s = n && n.encode || Yn;
|
|
1260
|
+
u.isFunction(n) && (n = {
|
|
1261
|
+
serialize: n
|
|
1262
|
+
});
|
|
1263
|
+
const r = n && n.serialize;
|
|
1264
|
+
let i;
|
|
1265
|
+
if (r ? i = r(t, n) : i = u.isURLSearchParams(t) ? t.toString() : new xe(t, n).toString(s), i) {
|
|
1266
|
+
const o = e.indexOf("#");
|
|
1267
|
+
o !== -1 && (e = e.slice(0, o)), e += (e.indexOf("?") === -1 ? "?" : "&") + i;
|
|
1268
|
+
}
|
|
1269
|
+
return e;
|
|
1270
|
+
}
|
|
1271
|
+
class Ve {
|
|
1272
|
+
constructor() {
|
|
1273
|
+
this.handlers = [];
|
|
1274
|
+
}
|
|
1275
|
+
/**
|
|
1276
|
+
* Add a new interceptor to the stack
|
|
1277
|
+
*
|
|
1278
|
+
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
1279
|
+
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
1280
|
+
*
|
|
1281
|
+
* @return {Number} An ID used to remove interceptor later
|
|
1282
|
+
*/
|
|
1283
|
+
use(t, n, s) {
|
|
1284
|
+
return this.handlers.push({
|
|
1285
|
+
fulfilled: t,
|
|
1286
|
+
rejected: n,
|
|
1287
|
+
synchronous: s ? s.synchronous : !1,
|
|
1288
|
+
runWhen: s ? s.runWhen : null
|
|
1289
|
+
}), this.handlers.length - 1;
|
|
1290
|
+
}
|
|
1291
|
+
/**
|
|
1292
|
+
* Remove an interceptor from the stack
|
|
1293
|
+
*
|
|
1294
|
+
* @param {Number} id The ID that was returned by `use`
|
|
1295
|
+
*
|
|
1296
|
+
* @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
|
|
1297
|
+
*/
|
|
1298
|
+
eject(t) {
|
|
1299
|
+
this.handlers[t] && (this.handlers[t] = null);
|
|
1300
|
+
}
|
|
1301
|
+
/**
|
|
1302
|
+
* Clear all interceptors from the stack
|
|
1303
|
+
*
|
|
1304
|
+
* @returns {void}
|
|
1305
|
+
*/
|
|
1306
|
+
clear() {
|
|
1307
|
+
this.handlers && (this.handlers = []);
|
|
1308
|
+
}
|
|
1309
|
+
/**
|
|
1310
|
+
* Iterate over all the registered interceptors
|
|
1311
|
+
*
|
|
1312
|
+
* This method is particularly useful for skipping over any
|
|
1313
|
+
* interceptors that may have become `null` calling `eject`.
|
|
1314
|
+
*
|
|
1315
|
+
* @param {Function} fn The function to call for each interceptor
|
|
1316
|
+
*
|
|
1317
|
+
* @returns {void}
|
|
1318
|
+
*/
|
|
1319
|
+
forEach(t) {
|
|
1320
|
+
u.forEach(this.handlers, function(s) {
|
|
1321
|
+
s !== null && t(s);
|
|
1322
|
+
});
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
const _t = {
|
|
1326
|
+
silentJSONParsing: !0,
|
|
1327
|
+
forcedJSONParsing: !0,
|
|
1328
|
+
clarifyTimeoutError: !1
|
|
1329
|
+
}, Zn = typeof URLSearchParams < "u" ? URLSearchParams : xe, es = typeof FormData < "u" ? FormData : null, ts = typeof Blob < "u" ? Blob : null, ns = {
|
|
1330
|
+
isBrowser: !0,
|
|
1331
|
+
classes: {
|
|
1332
|
+
URLSearchParams: Zn,
|
|
1333
|
+
FormData: es,
|
|
1334
|
+
Blob: ts
|
|
1335
|
+
},
|
|
1336
|
+
protocols: ["http", "https", "file", "blob", "url", "data"]
|
|
1337
|
+
}, Fe = typeof window < "u" && typeof document < "u", Le = typeof navigator == "object" && navigator || void 0, ss = Fe && (!Le || ["ReactNative", "NativeScript", "NS"].indexOf(Le.product) < 0), rs = typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef
|
|
1338
|
+
self instanceof WorkerGlobalScope && typeof self.importScripts == "function", os = Fe && window.location.href || "http://localhost", is = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1339
|
+
__proto__: null,
|
|
1340
|
+
hasBrowserEnv: Fe,
|
|
1341
|
+
hasStandardBrowserEnv: ss,
|
|
1342
|
+
hasStandardBrowserWebWorkerEnv: rs,
|
|
1343
|
+
navigator: Le,
|
|
1344
|
+
origin: os
|
|
1345
|
+
}, Symbol.toStringTag, { value: "Module" })), v = {
|
|
1346
|
+
...is,
|
|
1347
|
+
...ns
|
|
1348
|
+
};
|
|
1349
|
+
function as(e, t) {
|
|
1350
|
+
return Re(e, new v.classes.URLSearchParams(), {
|
|
1351
|
+
visitor: function(n, s, r, i) {
|
|
1352
|
+
return v.isNode && u.isBuffer(n) ? (this.append(s, n.toString("base64")), !1) : i.defaultVisitor.apply(this, arguments);
|
|
1353
|
+
},
|
|
1354
|
+
...t
|
|
1355
|
+
});
|
|
1356
|
+
}
|
|
1357
|
+
function cs(e) {
|
|
1358
|
+
return u.matchAll(/\w+|\[(\w*)]/g, e).map((t) => t[0] === "[]" ? "" : t[1] || t[0]);
|
|
1359
|
+
}
|
|
1360
|
+
function us(e) {
|
|
1361
|
+
const t = {}, n = Object.keys(e);
|
|
1362
|
+
let s;
|
|
1363
|
+
const r = n.length;
|
|
1364
|
+
let i;
|
|
1365
|
+
for (s = 0; s < r; s++)
|
|
1366
|
+
i = n[s], t[i] = e[i];
|
|
1367
|
+
return t;
|
|
1368
|
+
}
|
|
1369
|
+
function kt(e) {
|
|
1370
|
+
function t(n, s, r, i) {
|
|
1371
|
+
let o = n[i++];
|
|
1372
|
+
if (o === "__proto__") return !0;
|
|
1373
|
+
const a = Number.isFinite(+o), f = i >= n.length;
|
|
1374
|
+
return o = !o && u.isArray(r) ? r.length : o, f ? (u.hasOwnProp(r, o) ? r[o] = [r[o], s] : r[o] = s, !a) : ((!r[o] || !u.isObject(r[o])) && (r[o] = []), t(n, s, r[o], i) && u.isArray(r[o]) && (r[o] = us(r[o])), !a);
|
|
1375
|
+
}
|
|
1376
|
+
if (u.isFormData(e) && u.isFunction(e.entries)) {
|
|
1377
|
+
const n = {};
|
|
1378
|
+
return u.forEachEntry(e, (s, r) => {
|
|
1379
|
+
t(cs(s), r, n, 0);
|
|
1380
|
+
}), n;
|
|
1381
|
+
}
|
|
1382
|
+
return null;
|
|
1383
|
+
}
|
|
1384
|
+
function ls(e, t, n) {
|
|
1385
|
+
if (u.isString(e))
|
|
1386
|
+
try {
|
|
1387
|
+
return (t || JSON.parse)(e), u.trim(e);
|
|
1388
|
+
} catch (s) {
|
|
1389
|
+
if (s.name !== "SyntaxError")
|
|
1390
|
+
throw s;
|
|
1391
|
+
}
|
|
1392
|
+
return (n || JSON.stringify)(e);
|
|
1393
|
+
}
|
|
1394
|
+
const ue = {
|
|
1395
|
+
transitional: _t,
|
|
1396
|
+
adapter: ["xhr", "http", "fetch"],
|
|
1397
|
+
transformRequest: [function(t, n) {
|
|
1398
|
+
const s = n.getContentType() || "", r = s.indexOf("application/json") > -1, i = u.isObject(t);
|
|
1399
|
+
if (i && u.isHTMLForm(t) && (t = new FormData(t)), u.isFormData(t))
|
|
1400
|
+
return r ? JSON.stringify(kt(t)) : t;
|
|
1401
|
+
if (u.isArrayBuffer(t) || u.isBuffer(t) || u.isStream(t) || u.isFile(t) || u.isBlob(t) || u.isReadableStream(t))
|
|
1402
|
+
return t;
|
|
1403
|
+
if (u.isArrayBufferView(t))
|
|
1404
|
+
return t.buffer;
|
|
1405
|
+
if (u.isURLSearchParams(t))
|
|
1406
|
+
return n.setContentType("application/x-www-form-urlencoded;charset=utf-8", !1), t.toString();
|
|
1407
|
+
let a;
|
|
1408
|
+
if (i) {
|
|
1409
|
+
if (s.indexOf("application/x-www-form-urlencoded") > -1)
|
|
1410
|
+
return as(t, this.formSerializer).toString();
|
|
1411
|
+
if ((a = u.isFileList(t)) || s.indexOf("multipart/form-data") > -1) {
|
|
1412
|
+
const f = this.env && this.env.FormData;
|
|
1413
|
+
return Re(
|
|
1414
|
+
a ? { "files[]": t } : t,
|
|
1415
|
+
f && new f(),
|
|
1416
|
+
this.formSerializer
|
|
1417
|
+
);
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
return i || r ? (n.setContentType("application/json", !1), ls(t)) : t;
|
|
1421
|
+
}],
|
|
1422
|
+
transformResponse: [function(t) {
|
|
1423
|
+
const n = this.transitional || ue.transitional, s = n && n.forcedJSONParsing, r = this.responseType === "json";
|
|
1424
|
+
if (u.isResponse(t) || u.isReadableStream(t))
|
|
1425
|
+
return t;
|
|
1426
|
+
if (t && u.isString(t) && (s && !this.responseType || r)) {
|
|
1427
|
+
const o = !(n && n.silentJSONParsing) && r;
|
|
1428
|
+
try {
|
|
1429
|
+
return JSON.parse(t, this.parseReviver);
|
|
1430
|
+
} catch (a) {
|
|
1431
|
+
if (o)
|
|
1432
|
+
throw a.name === "SyntaxError" ? g.from(a, g.ERR_BAD_RESPONSE, this, null, this.response) : a;
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
return t;
|
|
1436
|
+
}],
|
|
1437
|
+
/**
|
|
1438
|
+
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
1439
|
+
* timeout is not created.
|
|
1440
|
+
*/
|
|
1441
|
+
timeout: 0,
|
|
1442
|
+
xsrfCookieName: "XSRF-TOKEN",
|
|
1443
|
+
xsrfHeaderName: "X-XSRF-TOKEN",
|
|
1444
|
+
maxContentLength: -1,
|
|
1445
|
+
maxBodyLength: -1,
|
|
1446
|
+
env: {
|
|
1447
|
+
FormData: v.classes.FormData,
|
|
1448
|
+
Blob: v.classes.Blob
|
|
1449
|
+
},
|
|
1450
|
+
validateStatus: function(t) {
|
|
1451
|
+
return t >= 200 && t < 300;
|
|
1452
|
+
},
|
|
1453
|
+
headers: {
|
|
1454
|
+
common: {
|
|
1455
|
+
Accept: "application/json, text/plain, */*",
|
|
1456
|
+
"Content-Type": void 0
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
};
|
|
1460
|
+
u.forEach(["delete", "get", "head", "post", "put", "patch"], (e) => {
|
|
1461
|
+
ue.headers[e] = {};
|
|
1462
|
+
});
|
|
1463
|
+
const fs = u.toObjectSet([
|
|
1464
|
+
"age",
|
|
1465
|
+
"authorization",
|
|
1466
|
+
"content-length",
|
|
1467
|
+
"content-type",
|
|
1468
|
+
"etag",
|
|
1469
|
+
"expires",
|
|
1470
|
+
"from",
|
|
1471
|
+
"host",
|
|
1472
|
+
"if-modified-since",
|
|
1473
|
+
"if-unmodified-since",
|
|
1474
|
+
"last-modified",
|
|
1475
|
+
"location",
|
|
1476
|
+
"max-forwards",
|
|
1477
|
+
"proxy-authorization",
|
|
1478
|
+
"referer",
|
|
1479
|
+
"retry-after",
|
|
1480
|
+
"user-agent"
|
|
1481
|
+
]), ds = (e) => {
|
|
1482
|
+
const t = {};
|
|
1483
|
+
let n, s, r;
|
|
1484
|
+
return e && e.split(`
|
|
1485
|
+
`).forEach(function(o) {
|
|
1486
|
+
r = o.indexOf(":"), n = o.substring(0, r).trim().toLowerCase(), s = o.substring(r + 1).trim(), !(!n || t[n] && fs[n]) && (n === "set-cookie" ? t[n] ? t[n].push(s) : t[n] = [s] : t[n] = t[n] ? t[n] + ", " + s : s);
|
|
1487
|
+
}), t;
|
|
1488
|
+
}, Je = Symbol("internals");
|
|
1489
|
+
function re(e) {
|
|
1490
|
+
return e && String(e).trim().toLowerCase();
|
|
1491
|
+
}
|
|
1492
|
+
function Ee(e) {
|
|
1493
|
+
return e === !1 || e == null ? e : u.isArray(e) ? e.map(Ee) : String(e);
|
|
1494
|
+
}
|
|
1495
|
+
function hs(e) {
|
|
1496
|
+
const t = /* @__PURE__ */ Object.create(null), n = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
|
|
1497
|
+
let s;
|
|
1498
|
+
for (; s = n.exec(e); )
|
|
1499
|
+
t[s[1]] = s[2];
|
|
1500
|
+
return t;
|
|
1501
|
+
}
|
|
1502
|
+
const ps = (e) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());
|
|
1503
|
+
function _e(e, t, n, s, r) {
|
|
1504
|
+
if (u.isFunction(s))
|
|
1505
|
+
return s.call(this, t, n);
|
|
1506
|
+
if (r && (t = n), !!u.isString(t)) {
|
|
1507
|
+
if (u.isString(s))
|
|
1508
|
+
return t.indexOf(s) !== -1;
|
|
1509
|
+
if (u.isRegExp(s))
|
|
1510
|
+
return s.test(t);
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
function ms(e) {
|
|
1514
|
+
return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (t, n, s) => n.toUpperCase() + s);
|
|
1515
|
+
}
|
|
1516
|
+
function Es(e, t) {
|
|
1517
|
+
const n = u.toCamelCase(" " + t);
|
|
1518
|
+
["get", "set", "has"].forEach((s) => {
|
|
1519
|
+
Object.defineProperty(e, s + n, {
|
|
1520
|
+
value: function(r, i, o) {
|
|
1521
|
+
return this[s].call(this, t, r, i, o);
|
|
1522
|
+
},
|
|
1523
|
+
configurable: !0
|
|
1524
|
+
});
|
|
1525
|
+
});
|
|
1526
|
+
}
|
|
1527
|
+
let I = class {
|
|
1528
|
+
constructor(t) {
|
|
1529
|
+
t && this.set(t);
|
|
1530
|
+
}
|
|
1531
|
+
set(t, n, s) {
|
|
1532
|
+
const r = this;
|
|
1533
|
+
function i(a, f, l) {
|
|
1534
|
+
const c = re(f);
|
|
1535
|
+
if (!c)
|
|
1536
|
+
throw new Error("header name must be a non-empty string");
|
|
1537
|
+
const p = u.findKey(r, c);
|
|
1538
|
+
(!p || r[p] === void 0 || l === !0 || l === void 0 && r[p] !== !1) && (r[p || f] = Ee(a));
|
|
1539
|
+
}
|
|
1540
|
+
const o = (a, f) => u.forEach(a, (l, c) => i(l, c, f));
|
|
1541
|
+
if (u.isPlainObject(t) || t instanceof this.constructor)
|
|
1542
|
+
o(t, n);
|
|
1543
|
+
else if (u.isString(t) && (t = t.trim()) && !ps(t))
|
|
1544
|
+
o(ds(t), n);
|
|
1545
|
+
else if (u.isObject(t) && u.isIterable(t)) {
|
|
1546
|
+
let a = {}, f, l;
|
|
1547
|
+
for (const c of t) {
|
|
1548
|
+
if (!u.isArray(c))
|
|
1549
|
+
throw TypeError("Object iterator must return a key-value pair");
|
|
1550
|
+
a[l = c[0]] = (f = a[l]) ? u.isArray(f) ? [...f, c[1]] : [f, c[1]] : c[1];
|
|
1551
|
+
}
|
|
1552
|
+
o(a, n);
|
|
1553
|
+
} else
|
|
1554
|
+
t != null && i(n, t, s);
|
|
1555
|
+
return this;
|
|
1556
|
+
}
|
|
1557
|
+
get(t, n) {
|
|
1558
|
+
if (t = re(t), t) {
|
|
1559
|
+
const s = u.findKey(this, t);
|
|
1560
|
+
if (s) {
|
|
1561
|
+
const r = this[s];
|
|
1562
|
+
if (!n)
|
|
1563
|
+
return r;
|
|
1564
|
+
if (n === !0)
|
|
1565
|
+
return hs(r);
|
|
1566
|
+
if (u.isFunction(n))
|
|
1567
|
+
return n.call(this, r, s);
|
|
1568
|
+
if (u.isRegExp(n))
|
|
1569
|
+
return n.exec(r);
|
|
1570
|
+
throw new TypeError("parser must be boolean|regexp|function");
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
has(t, n) {
|
|
1575
|
+
if (t = re(t), t) {
|
|
1576
|
+
const s = u.findKey(this, t);
|
|
1577
|
+
return !!(s && this[s] !== void 0 && (!n || _e(this, this[s], s, n)));
|
|
1578
|
+
}
|
|
1579
|
+
return !1;
|
|
1580
|
+
}
|
|
1581
|
+
delete(t, n) {
|
|
1582
|
+
const s = this;
|
|
1583
|
+
let r = !1;
|
|
1584
|
+
function i(o) {
|
|
1585
|
+
if (o = re(o), o) {
|
|
1586
|
+
const a = u.findKey(s, o);
|
|
1587
|
+
a && (!n || _e(s, s[a], a, n)) && (delete s[a], r = !0);
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
return u.isArray(t) ? t.forEach(i) : i(t), r;
|
|
1591
|
+
}
|
|
1592
|
+
clear(t) {
|
|
1593
|
+
const n = Object.keys(this);
|
|
1594
|
+
let s = n.length, r = !1;
|
|
1595
|
+
for (; s--; ) {
|
|
1596
|
+
const i = n[s];
|
|
1597
|
+
(!t || _e(this, this[i], i, t, !0)) && (delete this[i], r = !0);
|
|
1598
|
+
}
|
|
1599
|
+
return r;
|
|
1600
|
+
}
|
|
1601
|
+
normalize(t) {
|
|
1602
|
+
const n = this, s = {};
|
|
1603
|
+
return u.forEach(this, (r, i) => {
|
|
1604
|
+
const o = u.findKey(s, i);
|
|
1605
|
+
if (o) {
|
|
1606
|
+
n[o] = Ee(r), delete n[i];
|
|
1607
|
+
return;
|
|
1608
|
+
}
|
|
1609
|
+
const a = t ? ms(i) : String(i).trim();
|
|
1610
|
+
a !== i && delete n[i], n[a] = Ee(r), s[a] = !0;
|
|
1611
|
+
}), this;
|
|
1612
|
+
}
|
|
1613
|
+
concat(...t) {
|
|
1614
|
+
return this.constructor.concat(this, ...t);
|
|
1615
|
+
}
|
|
1616
|
+
toJSON(t) {
|
|
1617
|
+
const n = /* @__PURE__ */ Object.create(null);
|
|
1618
|
+
return u.forEach(this, (s, r) => {
|
|
1619
|
+
s != null && s !== !1 && (n[r] = t && u.isArray(s) ? s.join(", ") : s);
|
|
1620
|
+
}), n;
|
|
1621
|
+
}
|
|
1622
|
+
[Symbol.iterator]() {
|
|
1623
|
+
return Object.entries(this.toJSON())[Symbol.iterator]();
|
|
1624
|
+
}
|
|
1625
|
+
toString() {
|
|
1626
|
+
return Object.entries(this.toJSON()).map(([t, n]) => t + ": " + n).join(`
|
|
1627
|
+
`);
|
|
1628
|
+
}
|
|
1629
|
+
getSetCookie() {
|
|
1630
|
+
return this.get("set-cookie") || [];
|
|
1631
|
+
}
|
|
1632
|
+
get [Symbol.toStringTag]() {
|
|
1633
|
+
return "AxiosHeaders";
|
|
1634
|
+
}
|
|
1635
|
+
static from(t) {
|
|
1636
|
+
return t instanceof this ? t : new this(t);
|
|
1637
|
+
}
|
|
1638
|
+
static concat(t, ...n) {
|
|
1639
|
+
const s = new this(t);
|
|
1640
|
+
return n.forEach((r) => s.set(r)), s;
|
|
1641
|
+
}
|
|
1642
|
+
static accessor(t) {
|
|
1643
|
+
const s = (this[Je] = this[Je] = {
|
|
1644
|
+
accessors: {}
|
|
1645
|
+
}).accessors, r = this.prototype;
|
|
1646
|
+
function i(o) {
|
|
1647
|
+
const a = re(o);
|
|
1648
|
+
s[a] || (Es(r, o), s[a] = !0);
|
|
1649
|
+
}
|
|
1650
|
+
return u.isArray(t) ? t.forEach(i) : i(t), this;
|
|
1651
|
+
}
|
|
1652
|
+
};
|
|
1653
|
+
I.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]);
|
|
1654
|
+
u.reduceDescriptors(I.prototype, ({ value: e }, t) => {
|
|
1655
|
+
let n = t[0].toUpperCase() + t.slice(1);
|
|
1656
|
+
return {
|
|
1657
|
+
get: () => e,
|
|
1658
|
+
set(s) {
|
|
1659
|
+
this[n] = s;
|
|
1660
|
+
}
|
|
1661
|
+
};
|
|
1662
|
+
});
|
|
1663
|
+
u.freezeMethods(I);
|
|
1664
|
+
function ke(e, t) {
|
|
1665
|
+
const n = this || ue, s = t || n, r = I.from(s.headers);
|
|
1666
|
+
let i = s.data;
|
|
1667
|
+
return u.forEach(e, function(a) {
|
|
1668
|
+
i = a.call(n, i, r.normalize(), t ? t.status : void 0);
|
|
1669
|
+
}), r.normalize(), i;
|
|
1670
|
+
}
|
|
1671
|
+
function Ct(e) {
|
|
1672
|
+
return !!(e && e.__CANCEL__);
|
|
1673
|
+
}
|
|
1674
|
+
function ne(e, t, n) {
|
|
1675
|
+
g.call(this, e ?? "canceled", g.ERR_CANCELED, t, n), this.name = "CanceledError";
|
|
1676
|
+
}
|
|
1677
|
+
u.inherits(ne, g, {
|
|
1678
|
+
__CANCEL__: !0
|
|
1679
|
+
});
|
|
1680
|
+
function Nt(e, t, n) {
|
|
1681
|
+
const s = n.config.validateStatus;
|
|
1682
|
+
!n.status || !s || s(n.status) ? e(n) : t(new g(
|
|
1683
|
+
"Request failed with status code " + n.status,
|
|
1684
|
+
[g.ERR_BAD_REQUEST, g.ERR_BAD_RESPONSE][Math.floor(n.status / 100) - 4],
|
|
1685
|
+
n.config,
|
|
1686
|
+
n.request,
|
|
1687
|
+
n
|
|
1688
|
+
));
|
|
1689
|
+
}
|
|
1690
|
+
function ys(e) {
|
|
1691
|
+
const t = /^([-+\w]{1,25})(:?\/\/|:)/.exec(e);
|
|
1692
|
+
return t && t[1] || "";
|
|
1693
|
+
}
|
|
1694
|
+
function Ts(e, t) {
|
|
1695
|
+
e = e || 10;
|
|
1696
|
+
const n = new Array(e), s = new Array(e);
|
|
1697
|
+
let r = 0, i = 0, o;
|
|
1698
|
+
return t = t !== void 0 ? t : 1e3, function(f) {
|
|
1699
|
+
const l = Date.now(), c = s[i];
|
|
1700
|
+
o || (o = l), n[r] = f, s[r] = l;
|
|
1701
|
+
let p = i, T = 0;
|
|
1702
|
+
for (; p !== r; )
|
|
1703
|
+
T += n[p++], p = p % e;
|
|
1704
|
+
if (r = (r + 1) % e, r === i && (i = (i + 1) % e), l - o < t)
|
|
1705
|
+
return;
|
|
1706
|
+
const R = c && l - c;
|
|
1707
|
+
return R ? Math.round(T * 1e3 / R) : void 0;
|
|
1708
|
+
};
|
|
1709
|
+
}
|
|
1710
|
+
function gs(e, t) {
|
|
1711
|
+
let n = 0, s = 1e3 / t, r, i;
|
|
1712
|
+
const o = (l, c = Date.now()) => {
|
|
1713
|
+
n = c, r = null, i && (clearTimeout(i), i = null), e(...l);
|
|
1714
|
+
};
|
|
1715
|
+
return [(...l) => {
|
|
1716
|
+
const c = Date.now(), p = c - n;
|
|
1717
|
+
p >= s ? o(l, c) : (r = l, i || (i = setTimeout(() => {
|
|
1718
|
+
i = null, o(r);
|
|
1719
|
+
}, s - p)));
|
|
1720
|
+
}, () => r && o(r)];
|
|
1721
|
+
}
|
|
1722
|
+
const Te = (e, t, n = 3) => {
|
|
1723
|
+
let s = 0;
|
|
1724
|
+
const r = Ts(50, 250);
|
|
1725
|
+
return gs((i) => {
|
|
1726
|
+
const o = i.loaded, a = i.lengthComputable ? i.total : void 0, f = o - s, l = r(f), c = o <= a;
|
|
1727
|
+
s = o;
|
|
1728
|
+
const p = {
|
|
1729
|
+
loaded: o,
|
|
1730
|
+
total: a,
|
|
1731
|
+
progress: a ? o / a : void 0,
|
|
1732
|
+
bytes: f,
|
|
1733
|
+
rate: l || void 0,
|
|
1734
|
+
estimated: l && a && c ? (a - o) / l : void 0,
|
|
1735
|
+
event: i,
|
|
1736
|
+
lengthComputable: a != null,
|
|
1737
|
+
[t ? "download" : "upload"]: !0
|
|
1738
|
+
};
|
|
1739
|
+
e(p);
|
|
1740
|
+
}, n);
|
|
1741
|
+
}, We = (e, t) => {
|
|
1742
|
+
const n = e != null;
|
|
1743
|
+
return [(s) => t[0]({
|
|
1744
|
+
lengthComputable: n,
|
|
1745
|
+
total: e,
|
|
1746
|
+
loaded: s
|
|
1747
|
+
}), t[1]];
|
|
1748
|
+
}, Xe = (e) => (...t) => u.asap(() => e(...t)), Ss = v.hasStandardBrowserEnv ? /* @__PURE__ */ ((e, t) => (n) => (n = new URL(n, v.origin), e.protocol === n.protocol && e.host === n.host && (t || e.port === n.port)))(
|
|
1749
|
+
new URL(v.origin),
|
|
1750
|
+
v.navigator && /(msie|trident)/i.test(v.navigator.userAgent)
|
|
1751
|
+
) : () => !0, ws = v.hasStandardBrowserEnv ? (
|
|
1752
|
+
// Standard browser envs support document.cookie
|
|
1753
|
+
{
|
|
1754
|
+
write(e, t, n, s, r, i) {
|
|
1755
|
+
const o = [e + "=" + encodeURIComponent(t)];
|
|
1756
|
+
u.isNumber(n) && o.push("expires=" + new Date(n).toGMTString()), u.isString(s) && o.push("path=" + s), u.isString(r) && o.push("domain=" + r), i === !0 && o.push("secure"), document.cookie = o.join("; ");
|
|
1757
|
+
},
|
|
1758
|
+
read(e) {
|
|
1759
|
+
const t = document.cookie.match(new RegExp("(^|;\\s*)(" + e + ")=([^;]*)"));
|
|
1760
|
+
return t ? decodeURIComponent(t[3]) : null;
|
|
1761
|
+
},
|
|
1762
|
+
remove(e) {
|
|
1763
|
+
this.write(e, "", Date.now() - 864e5);
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
) : (
|
|
1767
|
+
// Non-standard browser env (web workers, react-native) lack needed support.
|
|
1768
|
+
{
|
|
1769
|
+
write() {
|
|
1770
|
+
},
|
|
1771
|
+
read() {
|
|
1772
|
+
return null;
|
|
1773
|
+
},
|
|
1774
|
+
remove() {
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
);
|
|
1778
|
+
function Rs(e) {
|
|
1779
|
+
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(e);
|
|
1780
|
+
}
|
|
1781
|
+
function bs(e, t) {
|
|
1782
|
+
return t ? e.replace(/\/?\/$/, "") + "/" + t.replace(/^\/+/, "") : e;
|
|
1783
|
+
}
|
|
1784
|
+
function vt(e, t, n) {
|
|
1785
|
+
let s = !Rs(t);
|
|
1786
|
+
return e && (s || n == !1) ? bs(e, t) : t;
|
|
1787
|
+
}
|
|
1788
|
+
const Qe = (e) => e instanceof I ? { ...e } : e;
|
|
1789
|
+
function X(e, t) {
|
|
1790
|
+
t = t || {};
|
|
1791
|
+
const n = {};
|
|
1792
|
+
function s(l, c, p, T) {
|
|
1793
|
+
return u.isPlainObject(l) && u.isPlainObject(c) ? u.merge.call({ caseless: T }, l, c) : u.isPlainObject(c) ? u.merge({}, c) : u.isArray(c) ? c.slice() : c;
|
|
1794
|
+
}
|
|
1795
|
+
function r(l, c, p, T) {
|
|
1796
|
+
if (u.isUndefined(c)) {
|
|
1797
|
+
if (!u.isUndefined(l))
|
|
1798
|
+
return s(void 0, l, p, T);
|
|
1799
|
+
} else return s(l, c, p, T);
|
|
1800
|
+
}
|
|
1801
|
+
function i(l, c) {
|
|
1802
|
+
if (!u.isUndefined(c))
|
|
1803
|
+
return s(void 0, c);
|
|
1804
|
+
}
|
|
1805
|
+
function o(l, c) {
|
|
1806
|
+
if (u.isUndefined(c)) {
|
|
1807
|
+
if (!u.isUndefined(l))
|
|
1808
|
+
return s(void 0, l);
|
|
1809
|
+
} else return s(void 0, c);
|
|
1810
|
+
}
|
|
1811
|
+
function a(l, c, p) {
|
|
1812
|
+
if (p in t)
|
|
1813
|
+
return s(l, c);
|
|
1814
|
+
if (p in e)
|
|
1815
|
+
return s(void 0, l);
|
|
1816
|
+
}
|
|
1817
|
+
const f = {
|
|
1818
|
+
url: i,
|
|
1819
|
+
method: i,
|
|
1820
|
+
data: i,
|
|
1821
|
+
baseURL: o,
|
|
1822
|
+
transformRequest: o,
|
|
1823
|
+
transformResponse: o,
|
|
1824
|
+
paramsSerializer: o,
|
|
1825
|
+
timeout: o,
|
|
1826
|
+
timeoutMessage: o,
|
|
1827
|
+
withCredentials: o,
|
|
1828
|
+
withXSRFToken: o,
|
|
1829
|
+
adapter: o,
|
|
1830
|
+
responseType: o,
|
|
1831
|
+
xsrfCookieName: o,
|
|
1832
|
+
xsrfHeaderName: o,
|
|
1833
|
+
onUploadProgress: o,
|
|
1834
|
+
onDownloadProgress: o,
|
|
1835
|
+
decompress: o,
|
|
1836
|
+
maxContentLength: o,
|
|
1837
|
+
maxBodyLength: o,
|
|
1838
|
+
beforeRedirect: o,
|
|
1839
|
+
transport: o,
|
|
1840
|
+
httpAgent: o,
|
|
1841
|
+
httpsAgent: o,
|
|
1842
|
+
cancelToken: o,
|
|
1843
|
+
socketPath: o,
|
|
1844
|
+
responseEncoding: o,
|
|
1845
|
+
validateStatus: a,
|
|
1846
|
+
headers: (l, c, p) => r(Qe(l), Qe(c), p, !0)
|
|
1847
|
+
};
|
|
1848
|
+
return u.forEach(Object.keys({ ...e, ...t }), function(c) {
|
|
1849
|
+
const p = f[c] || r, T = p(e[c], t[c], c);
|
|
1850
|
+
u.isUndefined(T) && p !== a || (n[c] = T);
|
|
1851
|
+
}), n;
|
|
1852
|
+
}
|
|
1853
|
+
const Dt = (e) => {
|
|
1854
|
+
const t = X({}, e);
|
|
1855
|
+
let { data: n, withXSRFToken: s, xsrfHeaderName: r, xsrfCookieName: i, headers: o, auth: a } = t;
|
|
1856
|
+
if (t.headers = o = I.from(o), t.url = Ot(vt(t.baseURL, t.url, t.allowAbsoluteUrls), e.params, e.paramsSerializer), a && o.set(
|
|
1857
|
+
"Authorization",
|
|
1858
|
+
"Basic " + btoa((a.username || "") + ":" + (a.password ? unescape(encodeURIComponent(a.password)) : ""))
|
|
1859
|
+
), u.isFormData(n)) {
|
|
1860
|
+
if (v.hasStandardBrowserEnv || v.hasStandardBrowserWebWorkerEnv)
|
|
1861
|
+
o.setContentType(void 0);
|
|
1862
|
+
else if (u.isFunction(n.getHeaders)) {
|
|
1863
|
+
const f = n.getHeaders(), l = ["content-type", "content-length"];
|
|
1864
|
+
Object.entries(f).forEach(([c, p]) => {
|
|
1865
|
+
l.includes(c.toLowerCase()) && o.set(c, p);
|
|
1866
|
+
});
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
if (v.hasStandardBrowserEnv && (s && u.isFunction(s) && (s = s(t)), s || s !== !1 && Ss(t.url))) {
|
|
1870
|
+
const f = r && i && ws.read(i);
|
|
1871
|
+
f && o.set(r, f);
|
|
1872
|
+
}
|
|
1873
|
+
return t;
|
|
1874
|
+
}, As = typeof XMLHttpRequest < "u", Os = As && function(e) {
|
|
1875
|
+
return new Promise(function(n, s) {
|
|
1876
|
+
const r = Dt(e);
|
|
1877
|
+
let i = r.data;
|
|
1878
|
+
const o = I.from(r.headers).normalize();
|
|
1879
|
+
let { responseType: a, onUploadProgress: f, onDownloadProgress: l } = r, c, p, T, R, d;
|
|
1880
|
+
function y() {
|
|
1881
|
+
R && R(), d && d(), r.cancelToken && r.cancelToken.unsubscribe(c), r.signal && r.signal.removeEventListener("abort", c);
|
|
1882
|
+
}
|
|
1883
|
+
let h = new XMLHttpRequest();
|
|
1884
|
+
h.open(r.method.toUpperCase(), r.url, !0), h.timeout = r.timeout;
|
|
1885
|
+
function b() {
|
|
1886
|
+
if (!h)
|
|
1887
|
+
return;
|
|
1888
|
+
const S = I.from(
|
|
1889
|
+
"getAllResponseHeaders" in h && h.getAllResponseHeaders()
|
|
1890
|
+
), k = {
|
|
1891
|
+
data: !a || a === "text" || a === "json" ? h.responseText : h.response,
|
|
1892
|
+
status: h.status,
|
|
1893
|
+
statusText: h.statusText,
|
|
1894
|
+
headers: S,
|
|
1895
|
+
config: e,
|
|
1896
|
+
request: h
|
|
1897
|
+
};
|
|
1898
|
+
Nt(function(D) {
|
|
1899
|
+
n(D), y();
|
|
1900
|
+
}, function(D) {
|
|
1901
|
+
s(D), y();
|
|
1902
|
+
}, k), h = null;
|
|
1903
|
+
}
|
|
1904
|
+
"onloadend" in h ? h.onloadend = b : h.onreadystatechange = function() {
|
|
1905
|
+
!h || h.readyState !== 4 || h.status === 0 && !(h.responseURL && h.responseURL.indexOf("file:") === 0) || setTimeout(b);
|
|
1906
|
+
}, h.onabort = function() {
|
|
1907
|
+
h && (s(new g("Request aborted", g.ECONNABORTED, e, h)), h = null);
|
|
1908
|
+
}, h.onerror = function(C) {
|
|
1909
|
+
const k = C && C.message ? C.message : "Network Error", z = new g(k, g.ERR_NETWORK, e, h);
|
|
1910
|
+
z.event = C || null, s(z), h = null;
|
|
1911
|
+
}, h.ontimeout = function() {
|
|
1912
|
+
let C = r.timeout ? "timeout of " + r.timeout + "ms exceeded" : "timeout exceeded";
|
|
1913
|
+
const k = r.transitional || _t;
|
|
1914
|
+
r.timeoutErrorMessage && (C = r.timeoutErrorMessage), s(new g(
|
|
1915
|
+
C,
|
|
1916
|
+
k.clarifyTimeoutError ? g.ETIMEDOUT : g.ECONNABORTED,
|
|
1917
|
+
e,
|
|
1918
|
+
h
|
|
1919
|
+
)), h = null;
|
|
1920
|
+
}, i === void 0 && o.setContentType(null), "setRequestHeader" in h && u.forEach(o.toJSON(), function(C, k) {
|
|
1921
|
+
h.setRequestHeader(k, C);
|
|
1922
|
+
}), u.isUndefined(r.withCredentials) || (h.withCredentials = !!r.withCredentials), a && a !== "json" && (h.responseType = r.responseType), l && ([T, d] = Te(l, !0), h.addEventListener("progress", T)), f && h.upload && ([p, R] = Te(f), h.upload.addEventListener("progress", p), h.upload.addEventListener("loadend", R)), (r.cancelToken || r.signal) && (c = (S) => {
|
|
1923
|
+
h && (s(!S || S.type ? new ne(null, e, h) : S), h.abort(), h = null);
|
|
1924
|
+
}, r.cancelToken && r.cancelToken.subscribe(c), r.signal && (r.signal.aborted ? c() : r.signal.addEventListener("abort", c)));
|
|
1925
|
+
const A = ys(r.url);
|
|
1926
|
+
if (A && v.protocols.indexOf(A) === -1) {
|
|
1927
|
+
s(new g("Unsupported protocol " + A + ":", g.ERR_BAD_REQUEST, e));
|
|
1928
|
+
return;
|
|
1929
|
+
}
|
|
1930
|
+
h.send(i || null);
|
|
1931
|
+
});
|
|
1932
|
+
}, _s = (e, t) => {
|
|
1933
|
+
const { length: n } = e = e ? e.filter(Boolean) : [];
|
|
1934
|
+
if (t || n) {
|
|
1935
|
+
let s = new AbortController(), r;
|
|
1936
|
+
const i = function(l) {
|
|
1937
|
+
if (!r) {
|
|
1938
|
+
r = !0, a();
|
|
1939
|
+
const c = l instanceof Error ? l : this.reason;
|
|
1940
|
+
s.abort(c instanceof g ? c : new ne(c instanceof Error ? c.message : c));
|
|
1941
|
+
}
|
|
1942
|
+
};
|
|
1943
|
+
let o = t && setTimeout(() => {
|
|
1944
|
+
o = null, i(new g(`timeout ${t} of ms exceeded`, g.ETIMEDOUT));
|
|
1945
|
+
}, t);
|
|
1946
|
+
const a = () => {
|
|
1947
|
+
e && (o && clearTimeout(o), o = null, e.forEach((l) => {
|
|
1948
|
+
l.unsubscribe ? l.unsubscribe(i) : l.removeEventListener("abort", i);
|
|
1949
|
+
}), e = null);
|
|
1950
|
+
};
|
|
1951
|
+
e.forEach((l) => l.addEventListener("abort", i));
|
|
1952
|
+
const { signal: f } = s;
|
|
1953
|
+
return f.unsubscribe = () => u.asap(a), f;
|
|
1954
|
+
}
|
|
1955
|
+
}, ks = function* (e, t) {
|
|
1956
|
+
let n = e.byteLength;
|
|
1957
|
+
if (n < t) {
|
|
1958
|
+
yield e;
|
|
1959
|
+
return;
|
|
1960
|
+
}
|
|
1961
|
+
let s = 0, r;
|
|
1962
|
+
for (; s < n; )
|
|
1963
|
+
r = s + t, yield e.slice(s, r), s = r;
|
|
1964
|
+
}, Cs = async function* (e, t) {
|
|
1965
|
+
for await (const n of Ns(e))
|
|
1966
|
+
yield* ks(n, t);
|
|
1967
|
+
}, Ns = async function* (e) {
|
|
1968
|
+
if (e[Symbol.asyncIterator]) {
|
|
1969
|
+
yield* e;
|
|
1970
|
+
return;
|
|
1971
|
+
}
|
|
1972
|
+
const t = e.getReader();
|
|
1973
|
+
try {
|
|
1974
|
+
for (; ; ) {
|
|
1975
|
+
const { done: n, value: s } = await t.read();
|
|
1976
|
+
if (n)
|
|
1977
|
+
break;
|
|
1978
|
+
yield s;
|
|
1979
|
+
}
|
|
1980
|
+
} finally {
|
|
1981
|
+
await t.cancel();
|
|
1982
|
+
}
|
|
1983
|
+
}, Ye = (e, t, n, s) => {
|
|
1984
|
+
const r = Cs(e, t);
|
|
1985
|
+
let i = 0, o, a = (f) => {
|
|
1986
|
+
o || (o = !0, s && s(f));
|
|
1987
|
+
};
|
|
1988
|
+
return new ReadableStream({
|
|
1989
|
+
async pull(f) {
|
|
1990
|
+
try {
|
|
1991
|
+
const { done: l, value: c } = await r.next();
|
|
1992
|
+
if (l) {
|
|
1993
|
+
a(), f.close();
|
|
1994
|
+
return;
|
|
1995
|
+
}
|
|
1996
|
+
let p = c.byteLength;
|
|
1997
|
+
if (n) {
|
|
1998
|
+
let T = i += p;
|
|
1999
|
+
n(T);
|
|
2000
|
+
}
|
|
2001
|
+
f.enqueue(new Uint8Array(c));
|
|
2002
|
+
} catch (l) {
|
|
2003
|
+
throw a(l), l;
|
|
2004
|
+
}
|
|
2005
|
+
},
|
|
2006
|
+
cancel(f) {
|
|
2007
|
+
return a(f), r.return();
|
|
2008
|
+
}
|
|
2009
|
+
}, {
|
|
2010
|
+
highWaterMark: 2
|
|
2011
|
+
});
|
|
2012
|
+
}, Ze = 64 * 1024, { isFunction: pe } = u, vs = (({ Request: e, Response: t }) => ({
|
|
2013
|
+
Request: e,
|
|
2014
|
+
Response: t
|
|
2015
|
+
}))(u.global), {
|
|
2016
|
+
ReadableStream: et,
|
|
2017
|
+
TextEncoder: tt
|
|
2018
|
+
} = u.global, nt = (e, ...t) => {
|
|
2019
|
+
try {
|
|
2020
|
+
return !!e(...t);
|
|
2021
|
+
} catch {
|
|
2022
|
+
return !1;
|
|
2023
|
+
}
|
|
2024
|
+
}, Ds = (e) => {
|
|
2025
|
+
e = u.merge.call({
|
|
2026
|
+
skipUndefined: !0
|
|
2027
|
+
}, vs, e);
|
|
2028
|
+
const { fetch: t, Request: n, Response: s } = e, r = t ? pe(t) : typeof fetch == "function", i = pe(n), o = pe(s);
|
|
2029
|
+
if (!r)
|
|
2030
|
+
return !1;
|
|
2031
|
+
const a = r && pe(et), f = r && (typeof tt == "function" ? /* @__PURE__ */ ((d) => (y) => d.encode(y))(new tt()) : async (d) => new Uint8Array(await new n(d).arrayBuffer())), l = i && a && nt(() => {
|
|
2032
|
+
let d = !1;
|
|
2033
|
+
const y = new n(v.origin, {
|
|
2034
|
+
body: new et(),
|
|
2035
|
+
method: "POST",
|
|
2036
|
+
get duplex() {
|
|
2037
|
+
return d = !0, "half";
|
|
2038
|
+
}
|
|
2039
|
+
}).headers.has("Content-Type");
|
|
2040
|
+
return d && !y;
|
|
2041
|
+
}), c = o && a && nt(() => u.isReadableStream(new s("").body)), p = {
|
|
2042
|
+
stream: c && ((d) => d.body)
|
|
2043
|
+
};
|
|
2044
|
+
r && ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((d) => {
|
|
2045
|
+
!p[d] && (p[d] = (y, h) => {
|
|
2046
|
+
let b = y && y[d];
|
|
2047
|
+
if (b)
|
|
2048
|
+
return b.call(y);
|
|
2049
|
+
throw new g(`Response type '${d}' is not supported`, g.ERR_NOT_SUPPORT, h);
|
|
2050
|
+
});
|
|
2051
|
+
});
|
|
2052
|
+
const T = async (d) => {
|
|
2053
|
+
if (d == null)
|
|
2054
|
+
return 0;
|
|
2055
|
+
if (u.isBlob(d))
|
|
2056
|
+
return d.size;
|
|
2057
|
+
if (u.isSpecCompliantForm(d))
|
|
2058
|
+
return (await new n(v.origin, {
|
|
2059
|
+
method: "POST",
|
|
2060
|
+
body: d
|
|
2061
|
+
}).arrayBuffer()).byteLength;
|
|
2062
|
+
if (u.isArrayBufferView(d) || u.isArrayBuffer(d))
|
|
2063
|
+
return d.byteLength;
|
|
2064
|
+
if (u.isURLSearchParams(d) && (d = d + ""), u.isString(d))
|
|
2065
|
+
return (await f(d)).byteLength;
|
|
2066
|
+
}, R = async (d, y) => {
|
|
2067
|
+
const h = u.toFiniteNumber(d.getContentLength());
|
|
2068
|
+
return h ?? T(y);
|
|
2069
|
+
};
|
|
2070
|
+
return async (d) => {
|
|
2071
|
+
let {
|
|
2072
|
+
url: y,
|
|
2073
|
+
method: h,
|
|
2074
|
+
data: b,
|
|
2075
|
+
signal: A,
|
|
2076
|
+
cancelToken: S,
|
|
2077
|
+
timeout: C,
|
|
2078
|
+
onDownloadProgress: k,
|
|
2079
|
+
onUploadProgress: z,
|
|
2080
|
+
responseType: D,
|
|
2081
|
+
headers: se,
|
|
2082
|
+
withCredentials: Q = "same-origin",
|
|
2083
|
+
fetchOptions: le
|
|
2084
|
+
} = Dt(d), fe = t || fetch;
|
|
2085
|
+
D = D ? (D + "").toLowerCase() : "text";
|
|
2086
|
+
let Y = _s([A, S && S.toAbortSignal()], C), V = null;
|
|
2087
|
+
const $ = Y && Y.unsubscribe && (() => {
|
|
2088
|
+
Y.unsubscribe();
|
|
2089
|
+
});
|
|
2090
|
+
let de;
|
|
2091
|
+
try {
|
|
2092
|
+
if (z && l && h !== "get" && h !== "head" && (de = await R(se, b)) !== 0) {
|
|
2093
|
+
let H = new n(y, {
|
|
2094
|
+
method: "POST",
|
|
2095
|
+
body: b,
|
|
2096
|
+
duplex: "half"
|
|
2097
|
+
}), m;
|
|
2098
|
+
if (u.isFormData(b) && (m = H.headers.get("content-type")) && se.setContentType(m), H.body) {
|
|
2099
|
+
const [E, w] = We(
|
|
2100
|
+
de,
|
|
2101
|
+
Te(Xe(z))
|
|
2102
|
+
);
|
|
2103
|
+
b = Ye(H.body, Ze, E, w);
|
|
2104
|
+
}
|
|
2105
|
+
}
|
|
2106
|
+
u.isString(Q) || (Q = Q ? "include" : "omit");
|
|
2107
|
+
const U = i && "credentials" in n.prototype, he = {
|
|
2108
|
+
...le,
|
|
2109
|
+
signal: Y,
|
|
2110
|
+
method: h.toUpperCase(),
|
|
2111
|
+
headers: se.normalize().toJSON(),
|
|
2112
|
+
body: b,
|
|
2113
|
+
duplex: "half",
|
|
2114
|
+
credentials: U ? Q : void 0
|
|
2115
|
+
};
|
|
2116
|
+
V = i && new n(y, he);
|
|
2117
|
+
let M = await (i ? fe(V, le) : fe(y, he));
|
|
2118
|
+
const K = c && (D === "stream" || D === "response");
|
|
2119
|
+
if (c && (k || K && $)) {
|
|
2120
|
+
const H = {};
|
|
2121
|
+
["status", "statusText", "headers"].forEach((j) => {
|
|
2122
|
+
H[j] = M[j];
|
|
2123
|
+
});
|
|
2124
|
+
const m = u.toFiniteNumber(M.headers.get("content-length")), [E, w] = k && We(
|
|
2125
|
+
m,
|
|
2126
|
+
Te(Xe(k), !0)
|
|
2127
|
+
) || [];
|
|
2128
|
+
M = new s(
|
|
2129
|
+
Ye(M.body, Ze, E, () => {
|
|
2130
|
+
w && w(), $ && $();
|
|
2131
|
+
}),
|
|
2132
|
+
H
|
|
2133
|
+
);
|
|
2134
|
+
}
|
|
2135
|
+
D = D || "text";
|
|
2136
|
+
let Ae = await p[u.findKey(p, D) || "text"](M, d);
|
|
2137
|
+
return !K && $ && $(), await new Promise((H, m) => {
|
|
2138
|
+
Nt(H, m, {
|
|
2139
|
+
data: Ae,
|
|
2140
|
+
headers: I.from(M.headers),
|
|
2141
|
+
status: M.status,
|
|
2142
|
+
statusText: M.statusText,
|
|
2143
|
+
config: d,
|
|
2144
|
+
request: V
|
|
2145
|
+
});
|
|
2146
|
+
});
|
|
2147
|
+
} catch (U) {
|
|
2148
|
+
throw $ && $(), U && U.name === "TypeError" && /Load failed|fetch/i.test(U.message) ? Object.assign(
|
|
2149
|
+
new g("Network Error", g.ERR_NETWORK, d, V),
|
|
2150
|
+
{
|
|
2151
|
+
cause: U.cause || U
|
|
2152
|
+
}
|
|
2153
|
+
) : g.from(U, U && U.code, d, V);
|
|
2154
|
+
}
|
|
2155
|
+
};
|
|
2156
|
+
}, Ls = /* @__PURE__ */ new Map(), Lt = (e) => {
|
|
2157
|
+
let t = e ? e.env : {};
|
|
2158
|
+
const { fetch: n, Request: s, Response: r } = t, i = [
|
|
2159
|
+
s,
|
|
2160
|
+
r,
|
|
2161
|
+
n
|
|
2162
|
+
];
|
|
2163
|
+
let o = i.length, a = o, f, l, c = Ls;
|
|
2164
|
+
for (; a--; )
|
|
2165
|
+
f = i[a], l = c.get(f), l === void 0 && c.set(f, l = a ? /* @__PURE__ */ new Map() : Ds(t)), c = l;
|
|
2166
|
+
return l;
|
|
2167
|
+
};
|
|
2168
|
+
Lt();
|
|
2169
|
+
const Ie = {
|
|
2170
|
+
http: Wn,
|
|
2171
|
+
xhr: Os,
|
|
2172
|
+
fetch: {
|
|
2173
|
+
get: Lt
|
|
2174
|
+
}
|
|
2175
|
+
};
|
|
2176
|
+
u.forEach(Ie, (e, t) => {
|
|
2177
|
+
if (e) {
|
|
2178
|
+
try {
|
|
2179
|
+
Object.defineProperty(e, "name", { value: t });
|
|
2180
|
+
} catch {
|
|
2181
|
+
}
|
|
2182
|
+
Object.defineProperty(e, "adapterName", { value: t });
|
|
2183
|
+
}
|
|
2184
|
+
});
|
|
2185
|
+
const st = (e) => `- ${e}`, Is = (e) => u.isFunction(e) || e === null || e === !1, It = {
|
|
2186
|
+
getAdapter: (e, t) => {
|
|
2187
|
+
e = u.isArray(e) ? e : [e];
|
|
2188
|
+
const { length: n } = e;
|
|
2189
|
+
let s, r;
|
|
2190
|
+
const i = {};
|
|
2191
|
+
for (let o = 0; o < n; o++) {
|
|
2192
|
+
s = e[o];
|
|
2193
|
+
let a;
|
|
2194
|
+
if (r = s, !Is(s) && (r = Ie[(a = String(s)).toLowerCase()], r === void 0))
|
|
2195
|
+
throw new g(`Unknown adapter '${a}'`);
|
|
2196
|
+
if (r && (u.isFunction(r) || (r = r.get(t))))
|
|
2197
|
+
break;
|
|
2198
|
+
i[a || "#" + o] = r;
|
|
2199
|
+
}
|
|
2200
|
+
if (!r) {
|
|
2201
|
+
const o = Object.entries(i).map(
|
|
2202
|
+
([f, l]) => `adapter ${f} ` + (l === !1 ? "is not supported by the environment" : "is not available in the build")
|
|
2203
|
+
);
|
|
2204
|
+
let a = n ? o.length > 1 ? `since :
|
|
2205
|
+
` + o.map(st).join(`
|
|
2206
|
+
`) : " " + st(o[0]) : "as no adapter specified";
|
|
2207
|
+
throw new g(
|
|
2208
|
+
"There is no suitable adapter to dispatch the request " + a,
|
|
2209
|
+
"ERR_NOT_SUPPORT"
|
|
2210
|
+
);
|
|
2211
|
+
}
|
|
2212
|
+
return r;
|
|
2213
|
+
},
|
|
2214
|
+
adapters: Ie
|
|
2215
|
+
};
|
|
2216
|
+
function Ce(e) {
|
|
2217
|
+
if (e.cancelToken && e.cancelToken.throwIfRequested(), e.signal && e.signal.aborted)
|
|
2218
|
+
throw new ne(null, e);
|
|
2219
|
+
}
|
|
2220
|
+
function rt(e) {
|
|
2221
|
+
return Ce(e), e.headers = I.from(e.headers), e.data = ke.call(
|
|
2222
|
+
e,
|
|
2223
|
+
e.transformRequest
|
|
2224
|
+
), ["post", "put", "patch"].indexOf(e.method) !== -1 && e.headers.setContentType("application/x-www-form-urlencoded", !1), It.getAdapter(e.adapter || ue.adapter, e)(e).then(function(s) {
|
|
2225
|
+
return Ce(e), s.data = ke.call(
|
|
2226
|
+
e,
|
|
2227
|
+
e.transformResponse,
|
|
2228
|
+
s
|
|
2229
|
+
), s.headers = I.from(s.headers), s;
|
|
2230
|
+
}, function(s) {
|
|
2231
|
+
return Ct(s) || (Ce(e), s && s.response && (s.response.data = ke.call(
|
|
2232
|
+
e,
|
|
2233
|
+
e.transformResponse,
|
|
2234
|
+
s.response
|
|
2235
|
+
), s.response.headers = I.from(s.response.headers))), Promise.reject(s);
|
|
2236
|
+
});
|
|
2237
|
+
}
|
|
2238
|
+
const Pt = "1.12.2", be = {};
|
|
2239
|
+
["object", "boolean", "number", "function", "string", "symbol"].forEach((e, t) => {
|
|
2240
|
+
be[e] = function(s) {
|
|
2241
|
+
return typeof s === e || "a" + (t < 1 ? "n " : " ") + e;
|
|
2242
|
+
};
|
|
2243
|
+
});
|
|
2244
|
+
const ot = {};
|
|
2245
|
+
be.transitional = function(t, n, s) {
|
|
2246
|
+
function r(i, o) {
|
|
2247
|
+
return "[Axios v" + Pt + "] Transitional option '" + i + "'" + o + (s ? ". " + s : "");
|
|
2248
|
+
}
|
|
2249
|
+
return (i, o, a) => {
|
|
2250
|
+
if (t === !1)
|
|
2251
|
+
throw new g(
|
|
2252
|
+
r(o, " has been removed" + (n ? " in " + n : "")),
|
|
2253
|
+
g.ERR_DEPRECATED
|
|
2254
|
+
);
|
|
2255
|
+
return n && !ot[o] && (ot[o] = !0, console.warn(
|
|
2256
|
+
r(
|
|
2257
|
+
o,
|
|
2258
|
+
" has been deprecated since v" + n + " and will be removed in the near future"
|
|
2259
|
+
)
|
|
2260
|
+
)), t ? t(i, o, a) : !0;
|
|
2261
|
+
};
|
|
2262
|
+
};
|
|
2263
|
+
be.spelling = function(t) {
|
|
2264
|
+
return (n, s) => (console.warn(`${s} is likely a misspelling of ${t}`), !0);
|
|
2265
|
+
};
|
|
2266
|
+
function Ps(e, t, n) {
|
|
2267
|
+
if (typeof e != "object")
|
|
2268
|
+
throw new g("options must be an object", g.ERR_BAD_OPTION_VALUE);
|
|
2269
|
+
const s = Object.keys(e);
|
|
2270
|
+
let r = s.length;
|
|
2271
|
+
for (; r-- > 0; ) {
|
|
2272
|
+
const i = s[r], o = t[i];
|
|
2273
|
+
if (o) {
|
|
2274
|
+
const a = e[i], f = a === void 0 || o(a, i, e);
|
|
2275
|
+
if (f !== !0)
|
|
2276
|
+
throw new g("option " + i + " must be " + f, g.ERR_BAD_OPTION_VALUE);
|
|
2277
|
+
continue;
|
|
2278
|
+
}
|
|
2279
|
+
if (n !== !0)
|
|
2280
|
+
throw new g("Unknown option " + i, g.ERR_BAD_OPTION);
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
const ye = {
|
|
2284
|
+
assertOptions: Ps,
|
|
2285
|
+
validators: be
|
|
2286
|
+
}, G = ye.validators;
|
|
2287
|
+
let W = class {
|
|
2288
|
+
constructor(t) {
|
|
2289
|
+
this.defaults = t || {}, this.interceptors = {
|
|
2290
|
+
request: new Ve(),
|
|
2291
|
+
response: new Ve()
|
|
2292
|
+
};
|
|
2293
|
+
}
|
|
2294
|
+
/**
|
|
2295
|
+
* Dispatch a request
|
|
2296
|
+
*
|
|
2297
|
+
* @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
|
|
2298
|
+
* @param {?Object} config
|
|
2299
|
+
*
|
|
2300
|
+
* @returns {Promise} The Promise to be fulfilled
|
|
2301
|
+
*/
|
|
2302
|
+
async request(t, n) {
|
|
2303
|
+
try {
|
|
2304
|
+
return await this._request(t, n);
|
|
2305
|
+
} catch (s) {
|
|
2306
|
+
if (s instanceof Error) {
|
|
2307
|
+
let r = {};
|
|
2308
|
+
Error.captureStackTrace ? Error.captureStackTrace(r) : r = new Error();
|
|
2309
|
+
const i = r.stack ? r.stack.replace(/^.+\n/, "") : "";
|
|
2310
|
+
try {
|
|
2311
|
+
s.stack ? i && !String(s.stack).endsWith(i.replace(/^.+\n.+\n/, "")) && (s.stack += `
|
|
2312
|
+
` + i) : s.stack = i;
|
|
2313
|
+
} catch {
|
|
2314
|
+
}
|
|
2315
|
+
}
|
|
2316
|
+
throw s;
|
|
2317
|
+
}
|
|
2318
|
+
}
|
|
2319
|
+
_request(t, n) {
|
|
2320
|
+
typeof t == "string" ? (n = n || {}, n.url = t) : n = t || {}, n = X(this.defaults, n);
|
|
2321
|
+
const { transitional: s, paramsSerializer: r, headers: i } = n;
|
|
2322
|
+
s !== void 0 && ye.assertOptions(s, {
|
|
2323
|
+
silentJSONParsing: G.transitional(G.boolean),
|
|
2324
|
+
forcedJSONParsing: G.transitional(G.boolean),
|
|
2325
|
+
clarifyTimeoutError: G.transitional(G.boolean)
|
|
2326
|
+
}, !1), r != null && (u.isFunction(r) ? n.paramsSerializer = {
|
|
2327
|
+
serialize: r
|
|
2328
|
+
} : ye.assertOptions(r, {
|
|
2329
|
+
encode: G.function,
|
|
2330
|
+
serialize: G.function
|
|
2331
|
+
}, !0)), n.allowAbsoluteUrls !== void 0 || (this.defaults.allowAbsoluteUrls !== void 0 ? n.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls : n.allowAbsoluteUrls = !0), ye.assertOptions(n, {
|
|
2332
|
+
baseUrl: G.spelling("baseURL"),
|
|
2333
|
+
withXsrfToken: G.spelling("withXSRFToken")
|
|
2334
|
+
}, !0), n.method = (n.method || this.defaults.method || "get").toLowerCase();
|
|
2335
|
+
let o = i && u.merge(
|
|
2336
|
+
i.common,
|
|
2337
|
+
i[n.method]
|
|
2338
|
+
);
|
|
2339
|
+
i && u.forEach(
|
|
2340
|
+
["delete", "get", "head", "post", "put", "patch", "common"],
|
|
2341
|
+
(d) => {
|
|
2342
|
+
delete i[d];
|
|
2343
|
+
}
|
|
2344
|
+
), n.headers = I.concat(o, i);
|
|
2345
|
+
const a = [];
|
|
2346
|
+
let f = !0;
|
|
2347
|
+
this.interceptors.request.forEach(function(y) {
|
|
2348
|
+
typeof y.runWhen == "function" && y.runWhen(n) === !1 || (f = f && y.synchronous, a.unshift(y.fulfilled, y.rejected));
|
|
2349
|
+
});
|
|
2350
|
+
const l = [];
|
|
2351
|
+
this.interceptors.response.forEach(function(y) {
|
|
2352
|
+
l.push(y.fulfilled, y.rejected);
|
|
2353
|
+
});
|
|
2354
|
+
let c, p = 0, T;
|
|
2355
|
+
if (!f) {
|
|
2356
|
+
const d = [rt.bind(this), void 0];
|
|
2357
|
+
for (d.unshift(...a), d.push(...l), T = d.length, c = Promise.resolve(n); p < T; )
|
|
2358
|
+
c = c.then(d[p++], d[p++]);
|
|
2359
|
+
return c;
|
|
2360
|
+
}
|
|
2361
|
+
T = a.length;
|
|
2362
|
+
let R = n;
|
|
2363
|
+
for (; p < T; ) {
|
|
2364
|
+
const d = a[p++], y = a[p++];
|
|
2365
|
+
try {
|
|
2366
|
+
R = d(R);
|
|
2367
|
+
} catch (h) {
|
|
2368
|
+
y.call(this, h);
|
|
2369
|
+
break;
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
try {
|
|
2373
|
+
c = rt.call(this, R);
|
|
2374
|
+
} catch (d) {
|
|
2375
|
+
return Promise.reject(d);
|
|
2376
|
+
}
|
|
2377
|
+
for (p = 0, T = l.length; p < T; )
|
|
2378
|
+
c = c.then(l[p++], l[p++]);
|
|
2379
|
+
return c;
|
|
2380
|
+
}
|
|
2381
|
+
getUri(t) {
|
|
2382
|
+
t = X(this.defaults, t);
|
|
2383
|
+
const n = vt(t.baseURL, t.url, t.allowAbsoluteUrls);
|
|
2384
|
+
return Ot(n, t.params, t.paramsSerializer);
|
|
2385
|
+
}
|
|
2386
|
+
};
|
|
2387
|
+
u.forEach(["delete", "get", "head", "options"], function(t) {
|
|
2388
|
+
W.prototype[t] = function(n, s) {
|
|
2389
|
+
return this.request(X(s || {}, {
|
|
2390
|
+
method: t,
|
|
2391
|
+
url: n,
|
|
2392
|
+
data: (s || {}).data
|
|
2393
|
+
}));
|
|
2394
|
+
};
|
|
2395
|
+
});
|
|
2396
|
+
u.forEach(["post", "put", "patch"], function(t) {
|
|
2397
|
+
function n(s) {
|
|
2398
|
+
return function(i, o, a) {
|
|
2399
|
+
return this.request(X(a || {}, {
|
|
2400
|
+
method: t,
|
|
2401
|
+
headers: s ? {
|
|
2402
|
+
"Content-Type": "multipart/form-data"
|
|
2403
|
+
} : {},
|
|
2404
|
+
url: i,
|
|
2405
|
+
data: o
|
|
2406
|
+
}));
|
|
2407
|
+
};
|
|
2408
|
+
}
|
|
2409
|
+
W.prototype[t] = n(), W.prototype[t + "Form"] = n(!0);
|
|
2410
|
+
});
|
|
2411
|
+
let Us = class Ut {
|
|
2412
|
+
constructor(t) {
|
|
2413
|
+
if (typeof t != "function")
|
|
2414
|
+
throw new TypeError("executor must be a function.");
|
|
2415
|
+
let n;
|
|
2416
|
+
this.promise = new Promise(function(i) {
|
|
2417
|
+
n = i;
|
|
2418
|
+
});
|
|
2419
|
+
const s = this;
|
|
2420
|
+
this.promise.then((r) => {
|
|
2421
|
+
if (!s._listeners) return;
|
|
2422
|
+
let i = s._listeners.length;
|
|
2423
|
+
for (; i-- > 0; )
|
|
2424
|
+
s._listeners[i](r);
|
|
2425
|
+
s._listeners = null;
|
|
2426
|
+
}), this.promise.then = (r) => {
|
|
2427
|
+
let i;
|
|
2428
|
+
const o = new Promise((a) => {
|
|
2429
|
+
s.subscribe(a), i = a;
|
|
2430
|
+
}).then(r);
|
|
2431
|
+
return o.cancel = function() {
|
|
2432
|
+
s.unsubscribe(i);
|
|
2433
|
+
}, o;
|
|
2434
|
+
}, t(function(i, o, a) {
|
|
2435
|
+
s.reason || (s.reason = new ne(i, o, a), n(s.reason));
|
|
2436
|
+
});
|
|
2437
|
+
}
|
|
2438
|
+
/**
|
|
2439
|
+
* Throws a `CanceledError` if cancellation has been requested.
|
|
2440
|
+
*/
|
|
2441
|
+
throwIfRequested() {
|
|
2442
|
+
if (this.reason)
|
|
2443
|
+
throw this.reason;
|
|
2444
|
+
}
|
|
2445
|
+
/**
|
|
2446
|
+
* Subscribe to the cancel signal
|
|
2447
|
+
*/
|
|
2448
|
+
subscribe(t) {
|
|
2449
|
+
if (this.reason) {
|
|
2450
|
+
t(this.reason);
|
|
2451
|
+
return;
|
|
2452
|
+
}
|
|
2453
|
+
this._listeners ? this._listeners.push(t) : this._listeners = [t];
|
|
2454
|
+
}
|
|
2455
|
+
/**
|
|
2456
|
+
* Unsubscribe from the cancel signal
|
|
2457
|
+
*/
|
|
2458
|
+
unsubscribe(t) {
|
|
2459
|
+
if (!this._listeners)
|
|
2460
|
+
return;
|
|
2461
|
+
const n = this._listeners.indexOf(t);
|
|
2462
|
+
n !== -1 && this._listeners.splice(n, 1);
|
|
2463
|
+
}
|
|
2464
|
+
toAbortSignal() {
|
|
2465
|
+
const t = new AbortController(), n = (s) => {
|
|
2466
|
+
t.abort(s);
|
|
2467
|
+
};
|
|
2468
|
+
return this.subscribe(n), t.signal.unsubscribe = () => this.unsubscribe(n), t.signal;
|
|
2469
|
+
}
|
|
2470
|
+
/**
|
|
2471
|
+
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
|
2472
|
+
* cancels the `CancelToken`.
|
|
2473
|
+
*/
|
|
2474
|
+
static source() {
|
|
2475
|
+
let t;
|
|
2476
|
+
return {
|
|
2477
|
+
token: new Ut(function(r) {
|
|
2478
|
+
t = r;
|
|
2479
|
+
}),
|
|
2480
|
+
cancel: t
|
|
2481
|
+
};
|
|
2482
|
+
}
|
|
2483
|
+
};
|
|
2484
|
+
function xs(e) {
|
|
2485
|
+
return function(n) {
|
|
2486
|
+
return e.apply(null, n);
|
|
2487
|
+
};
|
|
2488
|
+
}
|
|
2489
|
+
function Fs(e) {
|
|
2490
|
+
return u.isObject(e) && e.isAxiosError === !0;
|
|
2491
|
+
}
|
|
2492
|
+
const Pe = {
|
|
2493
|
+
Continue: 100,
|
|
2494
|
+
SwitchingProtocols: 101,
|
|
2495
|
+
Processing: 102,
|
|
2496
|
+
EarlyHints: 103,
|
|
2497
|
+
Ok: 200,
|
|
2498
|
+
Created: 201,
|
|
2499
|
+
Accepted: 202,
|
|
2500
|
+
NonAuthoritativeInformation: 203,
|
|
2501
|
+
NoContent: 204,
|
|
2502
|
+
ResetContent: 205,
|
|
2503
|
+
PartialContent: 206,
|
|
2504
|
+
MultiStatus: 207,
|
|
2505
|
+
AlreadyReported: 208,
|
|
2506
|
+
ImUsed: 226,
|
|
2507
|
+
MultipleChoices: 300,
|
|
2508
|
+
MovedPermanently: 301,
|
|
2509
|
+
Found: 302,
|
|
2510
|
+
SeeOther: 303,
|
|
2511
|
+
NotModified: 304,
|
|
2512
|
+
UseProxy: 305,
|
|
2513
|
+
Unused: 306,
|
|
2514
|
+
TemporaryRedirect: 307,
|
|
2515
|
+
PermanentRedirect: 308,
|
|
2516
|
+
BadRequest: 400,
|
|
2517
|
+
Unauthorized: 401,
|
|
2518
|
+
PaymentRequired: 402,
|
|
2519
|
+
Forbidden: 403,
|
|
2520
|
+
NotFound: 404,
|
|
2521
|
+
MethodNotAllowed: 405,
|
|
2522
|
+
NotAcceptable: 406,
|
|
2523
|
+
ProxyAuthenticationRequired: 407,
|
|
2524
|
+
RequestTimeout: 408,
|
|
2525
|
+
Conflict: 409,
|
|
2526
|
+
Gone: 410,
|
|
2527
|
+
LengthRequired: 411,
|
|
2528
|
+
PreconditionFailed: 412,
|
|
2529
|
+
PayloadTooLarge: 413,
|
|
2530
|
+
UriTooLong: 414,
|
|
2531
|
+
UnsupportedMediaType: 415,
|
|
2532
|
+
RangeNotSatisfiable: 416,
|
|
2533
|
+
ExpectationFailed: 417,
|
|
2534
|
+
ImATeapot: 418,
|
|
2535
|
+
MisdirectedRequest: 421,
|
|
2536
|
+
UnprocessableEntity: 422,
|
|
2537
|
+
Locked: 423,
|
|
2538
|
+
FailedDependency: 424,
|
|
2539
|
+
TooEarly: 425,
|
|
2540
|
+
UpgradeRequired: 426,
|
|
2541
|
+
PreconditionRequired: 428,
|
|
2542
|
+
TooManyRequests: 429,
|
|
2543
|
+
RequestHeaderFieldsTooLarge: 431,
|
|
2544
|
+
UnavailableForLegalReasons: 451,
|
|
2545
|
+
InternalServerError: 500,
|
|
2546
|
+
NotImplemented: 501,
|
|
2547
|
+
BadGateway: 502,
|
|
2548
|
+
ServiceUnavailable: 503,
|
|
2549
|
+
GatewayTimeout: 504,
|
|
2550
|
+
HttpVersionNotSupported: 505,
|
|
2551
|
+
VariantAlsoNegotiates: 506,
|
|
2552
|
+
InsufficientStorage: 507,
|
|
2553
|
+
LoopDetected: 508,
|
|
2554
|
+
NotExtended: 510,
|
|
2555
|
+
NetworkAuthenticationRequired: 511
|
|
2556
|
+
};
|
|
2557
|
+
Object.entries(Pe).forEach(([e, t]) => {
|
|
2558
|
+
Pe[t] = e;
|
|
2559
|
+
});
|
|
2560
|
+
function xt(e) {
|
|
2561
|
+
const t = new W(e), n = ht(W.prototype.request, t);
|
|
2562
|
+
return u.extend(n, W.prototype, t, { allOwnKeys: !0 }), u.extend(n, t, null, { allOwnKeys: !0 }), n.create = function(r) {
|
|
2563
|
+
return xt(X(e, r));
|
|
2564
|
+
}, n;
|
|
2565
|
+
}
|
|
2566
|
+
const O = xt(ue);
|
|
2567
|
+
O.Axios = W;
|
|
2568
|
+
O.CanceledError = ne;
|
|
2569
|
+
O.CancelToken = Us;
|
|
2570
|
+
O.isCancel = Ct;
|
|
2571
|
+
O.VERSION = Pt;
|
|
2572
|
+
O.toFormData = Re;
|
|
2573
|
+
O.AxiosError = g;
|
|
2574
|
+
O.Cancel = O.CanceledError;
|
|
2575
|
+
O.all = function(t) {
|
|
2576
|
+
return Promise.all(t);
|
|
2577
|
+
};
|
|
2578
|
+
O.spread = xs;
|
|
2579
|
+
O.isAxiosError = Fs;
|
|
2580
|
+
O.mergeConfig = X;
|
|
2581
|
+
O.AxiosHeaders = I;
|
|
2582
|
+
O.formToJSON = (e) => kt(u.isHTMLForm(e) ? new FormData(e) : e);
|
|
2583
|
+
O.getAdapter = It.getAdapter;
|
|
2584
|
+
O.HttpStatusCode = Pe;
|
|
2585
|
+
O.default = O;
|
|
2586
|
+
const {
|
|
2587
|
+
Axios: Qs,
|
|
2588
|
+
AxiosError: Ys,
|
|
2589
|
+
CanceledError: Zs,
|
|
2590
|
+
isCancel: er,
|
|
2591
|
+
CancelToken: tr,
|
|
2592
|
+
VERSION: nr,
|
|
2593
|
+
all: sr,
|
|
2594
|
+
Cancel: rr,
|
|
2595
|
+
isAxiosError: or,
|
|
2596
|
+
spread: ir,
|
|
2597
|
+
toFormData: ar,
|
|
2598
|
+
AxiosHeaders: cr,
|
|
2599
|
+
HttpStatusCode: ur,
|
|
2600
|
+
formToJSON: lr,
|
|
2601
|
+
getAdapter: fr,
|
|
2602
|
+
mergeConfig: dr
|
|
2603
|
+
} = O;
|
|
2604
|
+
class Ms {
|
|
2605
|
+
instance;
|
|
2606
|
+
getAccessToken;
|
|
2607
|
+
constructor(t) {
|
|
2608
|
+
this.getAccessToken = t.getAccessToken, this.instance = O.create({
|
|
2609
|
+
baseURL: t.baseUrl,
|
|
2610
|
+
headers: {
|
|
2611
|
+
"Content-Type": "application/json",
|
|
2612
|
+
...t.defaultHeaders
|
|
2613
|
+
}
|
|
2614
|
+
}), this.instance.interceptors.request.use(
|
|
2615
|
+
(n) => {
|
|
2616
|
+
const s = this.getAccessToken();
|
|
2617
|
+
return s ? n.headers.Authorization = `Bearer ${s}` : delete n.headers.Authorization, n;
|
|
2618
|
+
},
|
|
2619
|
+
(n) => Promise.reject(n)
|
|
2620
|
+
), this.instance.interceptors.response.use(
|
|
2621
|
+
(n) => n,
|
|
2622
|
+
async (n) => (n.response?.status === 401 && console.warn("[AuthApiService] Unauthorized request - token may be expired"), Promise.reject(n))
|
|
2623
|
+
);
|
|
2624
|
+
}
|
|
2625
|
+
/**
|
|
2626
|
+
* Generic GET request
|
|
2627
|
+
*/
|
|
2628
|
+
async get(t, n) {
|
|
2629
|
+
return (await this.instance.get(t, n)).data;
|
|
2630
|
+
}
|
|
2631
|
+
/**
|
|
2632
|
+
* Generic POST request
|
|
2633
|
+
*/
|
|
2634
|
+
async post(t, n, s) {
|
|
2635
|
+
return (await this.instance.post(t, n, s)).data;
|
|
2636
|
+
}
|
|
2637
|
+
/**
|
|
2638
|
+
* Generic PATCH request
|
|
2639
|
+
*/
|
|
2640
|
+
async patch(t, n, s) {
|
|
2641
|
+
return (await this.instance.patch(t, n, s)).data;
|
|
2642
|
+
}
|
|
2643
|
+
/**
|
|
2644
|
+
* Generic PUT request
|
|
2645
|
+
*/
|
|
2646
|
+
async put(t, n, s) {
|
|
2647
|
+
return (await this.instance.put(t, n, s)).data;
|
|
2648
|
+
}
|
|
2649
|
+
/**
|
|
2650
|
+
* Generic DELETE request
|
|
2651
|
+
*/
|
|
2652
|
+
async delete(t, n) {
|
|
2653
|
+
return (await this.instance.delete(t, n)).data;
|
|
2654
|
+
}
|
|
2655
|
+
/**
|
|
2656
|
+
* Get current user profile
|
|
2657
|
+
*/
|
|
2658
|
+
async getUser() {
|
|
2659
|
+
return this.get("/auth/user");
|
|
2660
|
+
}
|
|
2661
|
+
/**
|
|
2662
|
+
* Update user profile
|
|
2663
|
+
*/
|
|
2664
|
+
async updateUser(t) {
|
|
2665
|
+
return this.patch("/auth/user", t);
|
|
2666
|
+
}
|
|
2667
|
+
/**
|
|
2668
|
+
* Get raw axios instance if needed
|
|
2669
|
+
*/
|
|
2670
|
+
getInstance() {
|
|
2671
|
+
return this.instance;
|
|
2672
|
+
}
|
|
2673
|
+
}
|
|
2674
|
+
const Bs = {
|
|
2675
|
+
providers: {
|
|
2676
|
+
email: { enabled: !1 },
|
|
2677
|
+
phone: { enabled: !1 }
|
|
2678
|
+
},
|
|
2679
|
+
emailAuth: { enabled: !1 },
|
|
2680
|
+
phoneAuth: { enabled: !1 },
|
|
2681
|
+
registration: { enabled: !1 },
|
|
2682
|
+
mfa: { enabled: !1, methods: [] },
|
|
2683
|
+
tenants: { mode: Z.SINGLE, defaultTenantId: null, options: [] },
|
|
2684
|
+
sso: { enabled: !1, providers: [] },
|
|
2685
|
+
ui: void 0
|
|
2686
|
+
}, hr = () => {
|
|
2687
|
+
const e = zt(), t = x(
|
|
2688
|
+
() => e.status === F.AUTHENTICATED,
|
|
2689
|
+
[e.status]
|
|
2690
|
+
), n = x(
|
|
2691
|
+
() => e.status === F.UNAUTHENTICATED,
|
|
2692
|
+
[e.status]
|
|
2693
|
+
), s = x(
|
|
2694
|
+
() => e.backendConfig ?? Bs,
|
|
2695
|
+
[e.backendConfig]
|
|
2696
|
+
), r = x(
|
|
2697
|
+
() => e.backendConfig !== null && e.backendConfig !== void 0,
|
|
2698
|
+
[e.backendConfig]
|
|
2699
|
+
), i = x(
|
|
2700
|
+
() => !r && e.isLoading,
|
|
2701
|
+
[r, e.isLoading]
|
|
2702
|
+
), o = x(
|
|
2703
|
+
() => !!e.session?.id,
|
|
2704
|
+
[e.session]
|
|
2705
|
+
), a = x(
|
|
2706
|
+
() => e.backendConfig?.tenants?.options ?? [],
|
|
2707
|
+
[e.backendConfig?.tenants?.options]
|
|
2708
|
+
), f = x(
|
|
2709
|
+
() => e.backendConfig?.tenants?.mode ?? Z.SINGLE,
|
|
2710
|
+
[e.backendConfig?.tenants?.mode]
|
|
2711
|
+
), l = x(
|
|
2712
|
+
() => f === Z.MULTI,
|
|
2713
|
+
[f]
|
|
2714
|
+
), c = x(() => !e.tokens?.accessToken || !e.baseUrl ? null : new Ms({
|
|
2715
|
+
baseUrl: e.baseUrl,
|
|
2716
|
+
getAccessToken: () => e.tokens?.accessToken || null
|
|
2717
|
+
}), [e.tokens?.accessToken, e.baseUrl]);
|
|
2718
|
+
return {
|
|
2719
|
+
// Core auth state
|
|
2720
|
+
...e,
|
|
2721
|
+
// Status helpers
|
|
2722
|
+
isAuthenticated: t,
|
|
2723
|
+
isUnauthenticated: n,
|
|
2724
|
+
// Config helpers
|
|
2725
|
+
config: s,
|
|
2726
|
+
isConfigLoaded: r,
|
|
2727
|
+
isConfigLoading: i,
|
|
2728
|
+
// Session helpers
|
|
2729
|
+
hasSession: o,
|
|
2730
|
+
// Tenant helpers
|
|
2731
|
+
tenantOptions: a,
|
|
2732
|
+
tenantMode: f,
|
|
2733
|
+
isMultiTenant: l,
|
|
2734
|
+
// API Service
|
|
2735
|
+
api: c
|
|
2736
|
+
};
|
|
2737
|
+
}, pr = () => {
|
|
2738
|
+
const e = $t(), t = Bt(
|
|
2739
|
+
(T) => e.subscribe(T),
|
|
2740
|
+
() => e.getSnapshot(),
|
|
2741
|
+
() => e.getSnapshot()
|
|
2742
|
+
), n = q((T) => e.getStatus(T), [e]), s = q(() => e.refreshStatus(), [e]), r = q(() => e.ensureStatusLoaded(), [e]), i = q((T) => e.toggleMfa(T), [e]), o = q(() => e.setupTotp(), [e]), a = q((T) => e.verifyTotpSetup(T), [e]), f = q(() => e.generateRecoveryCode(), [e]), l = q((T) => e.resetTotp(T), [e]), c = q((T) => e.removeDevice(T), [e]), p = q(() => e.getAvailableMethods(), [e]);
|
|
2743
|
+
return x(
|
|
2744
|
+
() => ({
|
|
2745
|
+
...t,
|
|
2746
|
+
getStatus: n,
|
|
2747
|
+
refreshStatus: s,
|
|
2748
|
+
ensureStatusLoaded: r,
|
|
2749
|
+
toggleMfa: i,
|
|
2750
|
+
setupTotp: o,
|
|
2751
|
+
verifyTotpSetup: a,
|
|
2752
|
+
generateRecoveryCode: f,
|
|
2753
|
+
resetTotp: l,
|
|
2754
|
+
removeDevice: c,
|
|
2755
|
+
getAvailableMethods: p
|
|
2756
|
+
}),
|
|
2757
|
+
[t, n, s, r, i, o, a, f, l, c, p]
|
|
2758
|
+
);
|
|
2759
|
+
};
|
|
2760
|
+
export {
|
|
2761
|
+
Vs as APPLE_AUTH_PROVIDER,
|
|
2762
|
+
Ms as AuthApiService,
|
|
2763
|
+
_ as AuthEventType,
|
|
2764
|
+
Ht as AuthProvider,
|
|
2765
|
+
F as AuthStatus,
|
|
2766
|
+
Gs as EMAIL_AUTH_PROVIDER,
|
|
2767
|
+
Ks as FACEBOOK_AUTH_PROVIDER,
|
|
2768
|
+
$s as GOOGLE_AUTH_PROVIDER,
|
|
2769
|
+
qs as MFAMethodEnum,
|
|
2770
|
+
ct as MfaMethod,
|
|
2771
|
+
rn as MfaService,
|
|
2772
|
+
Js as NestAuthProvider,
|
|
2773
|
+
zs as PHONE_AUTH_PROVIDER,
|
|
2774
|
+
Z as TenantMode,
|
|
2775
|
+
Zt as createAuthClient,
|
|
2776
|
+
sn as createTokenStorage,
|
|
2777
|
+
hr as useAuth,
|
|
2778
|
+
pr as useMfa
|
|
2779
|
+
};
|