@memobit/libs 3.5.0 → 3.7.0

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.
@@ -1,122 +1,118 @@
1
1
  import './ChangePasswordModal.css';
2
- import { Modal as k } from "../../Modal/Modal2.js";
3
- import { InputPassword as m } from "../../InputPassword/InputPassword2.js";
4
- import { Toast as T } from "../../Toast/Toast2.js";
2
+ import { Modal as y } from "../../Modal/Modal2.js";
3
+ import { InputPassword as h } from "../../InputPassword/InputPassword2.js";
4
+ import { Toast as v } from "../../Toast/Toast2.js";
5
+ import { HttpMethod as C, buildRequestHeaders as E, readErrorMessage as x } from "../../../helpers/Http.js";
5
6
  import { useAuth as F } from "../../../hooks/useAuth/useAuth.js";
6
7
  /* empty css */
7
- import { useEffect as E, useState as o } from "react";
8
- import { jsx as e, jsxs as d } from "react/jsx-runtime";
9
- function U({ isOpen: l, onClose: c }) {
10
- const { config: b } = F(), [i, u] = o(""), [n, f] = o(""), [w, p] = o(""), [g, a] = o(""), [r, C] = o(!1), [h, P] = o(null);
11
- E(() => {
12
- l && (u(""), f(""), p(""), a(""));
13
- }, [l]);
14
- const y = async () => {
15
- if (!i || !n || !w) {
8
+ import { useEffect as k, useState as o } from "react";
9
+ import { jsx as e, jsxs as t } from "react/jsx-runtime";
10
+ function z({ isOpen: n, onClose: l }) {
11
+ const { config: b } = F(), [i, m] = o(""), [d, u] = o(""), [c, f] = o(""), [g, a] = o(""), [r, p] = o(!1), [w, P] = o(null);
12
+ k(() => {
13
+ n && (m(""), u(""), f(""), a(""));
14
+ }, [n]);
15
+ const N = async () => {
16
+ if (!i || !d || !c) {
16
17
  a("All fields are required");
17
18
  return;
18
19
  }
19
- if (n !== w) {
20
+ if (d !== c) {
20
21
  a("New passwords do not match");
21
22
  return;
22
23
  }
23
- if (n.length < 8) {
24
+ if (d.length < 8) {
24
25
  a("New password must be at least 8 characters long");
25
26
  return;
26
27
  }
27
- C(!0), a("");
28
+ p(!0), a("");
28
29
  try {
29
- const s = document.cookie.match(/(?:^|;\s*)csrf_token=([^;]+)/), t = s ? decodeURIComponent(s[1]) : null, _ = { "Content-Type": "application/json" };
30
- t && (_["X-CSRF-Token"] = t);
31
- const N = await fetch(`${b.apiBaseUrl}/auth/changePassword`, {
32
- method: "POST",
30
+ const s = await fetch(`${b.apiBaseUrl}/auth/changePassword`, {
31
+ method: C.Post,
33
32
  credentials: "include",
34
- headers: _,
33
+ headers: E(C.Post),
35
34
  body: JSON.stringify({
36
35
  currentPassword: i,
37
- newPassword: n
36
+ newPassword: d
38
37
  })
39
38
  });
40
- if (!N.ok) {
41
- const v = await N.json();
42
- throw new Error(v.error || "Failed to change password");
43
- }
39
+ if (!s.ok) throw new Error(await x(s));
44
40
  P({
45
41
  message: "Password changed successfully!",
46
42
  type: "success"
47
43
  }), setTimeout(() => {
48
- c();
44
+ l();
49
45
  }, 2e3);
50
46
  } catch (s) {
51
- const t = s instanceof Error ? s.message : "Failed to change password";
52
- a(t);
47
+ const M = s instanceof Error ? s.message : "Failed to change password";
48
+ a(M);
53
49
  } finally {
54
- C(!1);
50
+ p(!1);
55
51
  }
56
- }, M = () => {
52
+ }, _ = () => {
57
53
  P(null);
58
54
  };
59
- return /* @__PURE__ */ d(k, {
60
- isOpen: l,
61
- onClose: c,
55
+ return /* @__PURE__ */ t(y, {
56
+ isOpen: n,
57
+ onClose: l,
62
58
  title: "Change Password",
63
59
  size: "medium",
64
60
  primary: {
65
61
  text: r ? "Changing..." : "Change Password",
66
- onClick: y,
62
+ onClick: N,
67
63
  icon: "lock",
68
64
  variant: "success",
69
65
  disabled: r
70
66
  },
71
67
  secondary: {
72
68
  text: "Cancel",
73
- onClick: c,
69
+ onClick: l,
74
70
  icon: "clear",
75
71
  variant: "default",
76
72
  disabled: r
77
73
  },
78
- children: [/* @__PURE__ */ d("div", {
74
+ children: [/* @__PURE__ */ t("div", {
79
75
  className: "ChangePasswordModal",
80
76
  children: [
81
- /* @__PURE__ */ d("div", {
77
+ /* @__PURE__ */ t("div", {
82
78
  className: "ChangePasswordModal__field",
83
79
  children: [/* @__PURE__ */ e("label", {
84
80
  htmlFor: "current-password",
85
81
  className: "ChangePasswordModal__label",
86
82
  children: "Current Password"
87
- }), /* @__PURE__ */ e(m, {
83
+ }), /* @__PURE__ */ e(h, {
88
84
  id: "current-password",
89
85
  value: i,
90
- onChange: (s) => u(s),
86
+ onChange: (s) => m(s),
91
87
  placeholder: "Enter current password",
92
88
  disabled: r,
93
89
  autoFocus: !0
94
90
  })]
95
91
  }),
96
- /* @__PURE__ */ d("div", {
92
+ /* @__PURE__ */ t("div", {
97
93
  className: "ChangePasswordModal__field",
98
94
  children: [/* @__PURE__ */ e("label", {
99
95
  htmlFor: "new-password",
100
96
  className: "ChangePasswordModal__label",
101
97
  children: "New Password"
102
- }), /* @__PURE__ */ e(m, {
98
+ }), /* @__PURE__ */ e(h, {
103
99
  id: "new-password",
104
- value: n,
105
- onChange: (s) => f(s),
100
+ value: d,
101
+ onChange: (s) => u(s),
106
102
  placeholder: "Enter new password",
107
103
  disabled: r
108
104
  })]
109
105
  }),
110
- /* @__PURE__ */ d("div", {
106
+ /* @__PURE__ */ t("div", {
111
107
  className: "ChangePasswordModal__field",
112
108
  children: [/* @__PURE__ */ e("label", {
113
109
  htmlFor: "confirm-password",
114
110
  className: "ChangePasswordModal__label",
115
111
  children: "Confirm New Password"
116
- }), /* @__PURE__ */ e(m, {
112
+ }), /* @__PURE__ */ e(h, {
117
113
  id: "confirm-password",
118
- value: w,
119
- onChange: (s) => p(s),
114
+ value: c,
115
+ onChange: (s) => f(s),
120
116
  placeholder: "Confirm new password",
121
117
  disabled: r
122
118
  })]
@@ -126,13 +122,13 @@ function U({ isOpen: l, onClose: c }) {
126
122
  children: g
127
123
  })
128
124
  ]
129
- }), h && /* @__PURE__ */ e(T, {
130
- message: h.message,
131
- type: h.type,
132
- onClose: M
125
+ }), w && /* @__PURE__ */ e(v, {
126
+ message: w.message,
127
+ type: w.type,
128
+ onClose: _
133
129
  })]
134
130
  });
135
131
  }
136
132
  export {
137
- U as ChangePasswordModal
133
+ z as ChangePasswordModal
138
134
  };
@@ -1,39 +1,38 @@
1
1
  import './MfaSetupModal.css';
2
2
  import { Button as o } from "../../Button/Button2.js";
3
- import { Modal as Y } from "../../Modal/Modal2.js";
4
- import { InputText as U } from "../../InputText/InputText2.js";
5
- import { InputPassword as j } from "../../InputPassword/InputPassword2.js";
6
- import { Toast as Z } from "../../Toast/Toast2.js";
7
- import { useAuth as ee } from "../../../hooks/useAuth/useAuth.js";
8
- import { QRCodeSVG as ae } from "../../../node_modules/qrcode.react/lib/esm/index.js";
3
+ import { Modal as O } from "../../Modal/Modal2.js";
4
+ import { InputText as R } from "../../InputText/InputText2.js";
5
+ import { InputPassword as B } from "../../InputPassword/InputPassword2.js";
6
+ import { Toast as X } from "../../Toast/Toast2.js";
7
+ import { HttpMethod as F, buildRequestHeaders as Y } from "../../../helpers/Http.js";
8
+ import { useAuth as Z } from "../../../hooks/useAuth/useAuth.js";
9
+ import { QRCodeSVG as ee } from "../../../node_modules/qrcode.react/lib/esm/index.js";
9
10
  /* empty css */
10
- import { useCallback as A, useEffect as te, useState as n } from "react";
11
- import { Fragment as D, jsx as e, jsxs as s } from "react/jsx-runtime";
12
- function pe({ isOpen: M, onClose: $ }) {
13
- const { config: f } = ee(), [x, i] = n("loading"), [C, I] = n(!1), [_, P] = n(null), [V, z] = n(""), [S, G] = n(""), [p, l] = n(""), [m, d] = n(""), [b, v] = n([]), [k, u] = n(""), [a, N] = n(!1), [g, y] = n(null), c = A(async (t, h) => {
14
- const W = document.cookie.match(/(?:^|;\s*)csrf_token=([^;]+)/), E = W ? decodeURIComponent(W[1]) : null, R = { "Content-Type": "application/json" };
15
- E && (R["X-CSRF-Token"] = E);
16
- const F = await fetch(`${f.apiBaseUrl}${t}`, {
17
- method: "POST",
11
+ import { useCallback as U, useEffect as ae, useState as r } from "react";
12
+ import { Fragment as A, jsx as e, jsxs as s } from "react/jsx-runtime";
13
+ function pe({ isOpen: M, onClose: D }) {
14
+ const { config: f } = Z(), [$, i] = r("loading"), [C, j] = r(!1), [_, x] = r(null), [P, I] = r(""), [b, V] = r(""), [p, c] = r(""), [m, d] = r(""), [S, v] = r([]), [k, u] = r(""), [a, N] = r(!1), [g, y] = r(null), l = U(async (t, h) => {
15
+ const E = await fetch(`${f.apiBaseUrl}${t}`, {
16
+ method: F.Post,
18
17
  credentials: "include",
19
- headers: R,
18
+ headers: Y(F.Post),
20
19
  body: h ? JSON.stringify(h) : void 0
21
- }), B = await F.json().catch(() => ({}));
22
- if (!F.ok) throw new Error(B.error || "Request failed");
23
- return B;
24
- }, [f.apiBaseUrl]), w = A(async () => {
20
+ }), T = await E.json().catch(() => ({}));
21
+ if (!E.ok) throw new Error(T.error || "Request failed");
22
+ return T;
23
+ }, [f.apiBaseUrl]), w = U(async () => {
25
24
  i("loading"), u("");
26
25
  try {
27
26
  const t = await (await fetch(`${f.apiBaseUrl}/auth/mfaStatus`, { credentials: "include" })).json();
28
- I(!!t.enabled), P(t.method ?? null), i("overview");
27
+ j(!!t.enabled), x(t.method ?? null), i("overview");
29
28
  } catch {
30
29
  u("Could not load MFA status."), i("overview");
31
30
  }
32
31
  }, [f.apiBaseUrl]);
33
- te(() => {
34
- M && (l(""), d(""), u(""), v([]), w());
32
+ ae(() => {
33
+ M && (c(""), d(""), u(""), v([]), w());
35
34
  }, [M, w]);
36
- const r = async (t) => {
35
+ const n = async (t) => {
37
36
  N(!0), u("");
38
37
  try {
39
38
  await t();
@@ -42,47 +41,47 @@ function pe({ isOpen: M, onClose: $ }) {
42
41
  } finally {
43
42
  N(!1);
44
43
  }
45
- }, q = () => r(async () => {
46
- const t = await c("/auth/mfaSetupTotp");
47
- z(t.secret || ""), G(t.otpauthUri || ""), l(""), i("totp-setup");
48
- }), J = () => r(async () => {
49
- const t = await c("/auth/mfaConfirmTotp", { code: p.trim() });
44
+ }, q = () => n(async () => {
45
+ const t = await l("/auth/mfaSetupTotp");
46
+ I(t.secret || ""), V(t.otpauthUri || ""), c(""), i("totp-setup");
47
+ }), z = () => n(async () => {
48
+ const t = await l("/auth/mfaConfirmTotp", { code: p.trim() });
50
49
  v(t.recoveryCodes || []), i("recovery");
51
- }), T = () => r(async () => {
52
- await c("/auth/mfaEnableEmail"), l(""), i("email-setup");
53
- }), L = () => r(async () => {
54
- const t = await c("/auth/mfaConfirmEmail", { code: p.trim() });
50
+ }), W = () => n(async () => {
51
+ await l("/auth/mfaEnableEmail"), c(""), i("email-setup");
52
+ }), G = () => n(async () => {
53
+ const t = await l("/auth/mfaConfirmEmail", { code: p.trim() });
55
54
  v(t.recoveryCodes || []), i("recovery");
56
- }), O = () => r(async () => {
57
- await c("/auth/mfaDisable", { password: m }), y({
55
+ }), H = () => n(async () => {
56
+ await l("/auth/mfaDisable", { password: m }), y({
58
57
  message: "Two-factor authentication disabled.",
59
58
  type: "success"
60
59
  }), d(""), await w();
61
- }), Q = () => r(async () => {
62
- const t = await c("/auth/mfaRegenRecovery", { password: m });
60
+ }), J = () => n(async () => {
61
+ const t = await l("/auth/mfaRegenRecovery", { password: m });
63
62
  v(t.recoveryCodes || []), d(""), i("recovery");
64
- }), X = () => r(async () => {
65
- await c("/auth/mfaForgetDevices"), y({
63
+ }), L = () => n(async () => {
64
+ await l("/auth/mfaForgetDevices"), y({
66
65
  message: "All trusted devices have been signed out.",
67
66
  type: "success"
68
67
  });
69
- }), H = () => {
70
- navigator.clipboard?.writeText(b.join(`
68
+ }), Q = () => {
69
+ navigator.clipboard?.writeText(S.join(`
71
70
  `)), y({
72
71
  message: "Recovery codes copied.",
73
72
  type: "success"
74
73
  });
75
- }, K = V.replace(/(.{4})/g, "$1 ").trim();
76
- return /* @__PURE__ */ s(Y, {
74
+ }, K = P.replace(/(.{4})/g, "$1 ").trim();
75
+ return /* @__PURE__ */ s(O, {
77
76
  isOpen: M,
78
- onClose: $,
77
+ onClose: D,
79
78
  title: "Two-factor authentication",
80
79
  titleIcon: "key",
81
80
  size: "medium",
82
81
  children: [/* @__PURE__ */ s("div", {
83
82
  className: "MfaSetupModal",
84
83
  children: [(() => {
85
- switch (x) {
84
+ switch ($) {
86
85
  case "loading":
87
86
  return /* @__PURE__ */ e("p", {
88
87
  className: "MfaSetupModal__hint",
@@ -94,7 +93,7 @@ function pe({ isOpen: M, onClose: $ }) {
94
93
  children: [/* @__PURE__ */ s("p", {
95
94
  className: "MfaSetupModal__status",
96
95
  children: ["Status: ", /* @__PURE__ */ e("strong", { children: C ? `Enabled (${_ === "email" ? "email codes" : "authenticator app"})` : "Disabled" })]
97
- }), C ? /* @__PURE__ */ s(D, { children: [
96
+ }), C ? /* @__PURE__ */ s(A, { children: [
98
97
  /* @__PURE__ */ e(o, {
99
98
  variant: "default",
100
99
  fullWidth: !0,
@@ -106,7 +105,7 @@ function pe({ isOpen: M, onClose: $ }) {
106
105
  variant: "default",
107
106
  fullWidth: !0,
108
107
  disabled: a,
109
- onClick: () => r(X),
108
+ onClick: () => n(L),
110
109
  children: "Sign out trusted devices"
111
110
  }),
112
111
  /* @__PURE__ */ e(o, {
@@ -117,7 +116,7 @@ function pe({ isOpen: M, onClose: $ }) {
117
116
  onClick: () => i("disable"),
118
117
  children: "Disable two-factor"
119
118
  })
120
- ] }) : /* @__PURE__ */ s(D, { children: [
119
+ ] }) : /* @__PURE__ */ s(A, { children: [
121
120
  /* @__PURE__ */ e("p", {
122
121
  className: "MfaSetupModal__hint",
123
122
  children: "Add a second step at sign-in. Choose a method:"
@@ -133,7 +132,7 @@ function pe({ isOpen: M, onClose: $ }) {
133
132
  variant: "default",
134
133
  fullWidth: !0,
135
134
  disabled: a,
136
- onClick: T,
135
+ onClick: W,
137
136
  children: "Set up email codes"
138
137
  })
139
138
  ] })]
@@ -146,10 +145,10 @@ function pe({ isOpen: M, onClose: $ }) {
146
145
  className: "MfaSetupModal__hint",
147
146
  children: "Scan this with your authenticator app (Google Authenticator, Aegis, 1Password…)."
148
147
  }),
149
- S && /* @__PURE__ */ e("div", {
148
+ b && /* @__PURE__ */ e("div", {
150
149
  className: "MfaSetupModal__qr",
151
- children: /* @__PURE__ */ e(ae, {
152
- value: S,
150
+ children: /* @__PURE__ */ e(ee, {
151
+ value: b,
153
152
  size: 192,
154
153
  marginSize: 2
155
154
  })
@@ -162,10 +161,10 @@ function pe({ isOpen: M, onClose: $ }) {
162
161
  className: "MfaSetupModal__secret",
163
162
  children: K
164
163
  }),
165
- /* @__PURE__ */ e(U, {
164
+ /* @__PURE__ */ e(R, {
166
165
  placeholder: "6-digit code from the app",
167
166
  value: p,
168
- onChange: l,
167
+ onChange: c,
169
168
  autoFocus: !0,
170
169
  disabled: a
171
170
  }),
@@ -174,7 +173,7 @@ function pe({ isOpen: M, onClose: $ }) {
174
173
  icon: "key",
175
174
  fullWidth: !0,
176
175
  loading: a,
177
- onClick: J,
176
+ onClick: z,
178
177
  children: "Verify & enable"
179
178
  })
180
179
  ]
@@ -187,10 +186,10 @@ function pe({ isOpen: M, onClose: $ }) {
187
186
  className: "MfaSetupModal__hint",
188
187
  children: "We emailed you a 6-digit code. Enter it below to enable email verification."
189
188
  }),
190
- /* @__PURE__ */ e(U, {
189
+ /* @__PURE__ */ e(R, {
191
190
  placeholder: "6-digit code",
192
191
  value: p,
193
- onChange: l,
192
+ onChange: c,
194
193
  autoFocus: !0,
195
194
  disabled: a
196
195
  }),
@@ -199,14 +198,14 @@ function pe({ isOpen: M, onClose: $ }) {
199
198
  icon: "key",
200
199
  fullWidth: !0,
201
200
  loading: a,
202
- onClick: L,
201
+ onClick: G,
203
202
  children: "Verify & enable"
204
203
  }),
205
204
  /* @__PURE__ */ e(o, {
206
205
  variant: "default",
207
206
  fullWidth: !0,
208
207
  disabled: a,
209
- onClick: T,
208
+ onClick: W,
210
209
  children: "Resend code"
211
210
  })
212
211
  ]
@@ -226,13 +225,13 @@ function pe({ isOpen: M, onClose: $ }) {
226
225
  }),
227
226
  /* @__PURE__ */ e("ul", {
228
227
  className: "MfaSetupModal__codes",
229
- children: b.map((t) => /* @__PURE__ */ e("li", { children: t }, t))
228
+ children: S.map((t) => /* @__PURE__ */ e("li", { children: t }, t))
230
229
  }),
231
230
  /* @__PURE__ */ e(o, {
232
231
  variant: "default",
233
232
  fullWidth: !0,
234
233
  disabled: a,
235
- onClick: H,
234
+ onClick: Q,
236
235
  children: "Copy codes"
237
236
  }),
238
237
  /* @__PURE__ */ e(o, {
@@ -252,7 +251,7 @@ function pe({ isOpen: M, onClose: $ }) {
252
251
  className: "MfaSetupModal__hint",
253
252
  children: "Confirm your password to disable two-factor authentication."
254
253
  }),
255
- /* @__PURE__ */ e(j, {
254
+ /* @__PURE__ */ e(B, {
256
255
  placeholder: "Current password",
257
256
  value: m,
258
257
  onChange: d,
@@ -264,7 +263,7 @@ function pe({ isOpen: M, onClose: $ }) {
264
263
  icon: "lock",
265
264
  fullWidth: !0,
266
265
  loading: a,
267
- onClick: O,
266
+ onClick: H,
268
267
  children: "Disable two-factor"
269
268
  }),
270
269
  /* @__PURE__ */ e(o, {
@@ -285,7 +284,7 @@ function pe({ isOpen: M, onClose: $ }) {
285
284
  className: "MfaSetupModal__hint",
286
285
  children: "Confirm your password to generate a new set of recovery codes. The old codes stop working."
287
286
  }),
288
- /* @__PURE__ */ e(j, {
287
+ /* @__PURE__ */ e(B, {
289
288
  placeholder: "Current password",
290
289
  value: m,
291
290
  onChange: d,
@@ -297,7 +296,7 @@ function pe({ isOpen: M, onClose: $ }) {
297
296
  icon: "key",
298
297
  fullWidth: !0,
299
298
  loading: a,
300
- onClick: Q,
299
+ onClick: J,
301
300
  children: "Generate new codes"
302
301
  }),
303
302
  /* @__PURE__ */ e(o, {
@@ -315,7 +314,7 @@ function pe({ isOpen: M, onClose: $ }) {
315
314
  className: "MfaSetupModal__error",
316
315
  children: k
317
316
  })]
318
- }), g && /* @__PURE__ */ e(Z, {
317
+ }), g && /* @__PURE__ */ e(X, {
319
318
  message: g.message,
320
319
  type: g.type,
321
320
  onClose: () => y(null)
@@ -0,0 +1 @@
1
+ .ProtectedRoute__loading{min-height:100vh;font-size:var(--font-size-xl);justify-content:center;align-items:center;display:flex}
@@ -0,0 +1,19 @@
1
+ import './ProtectedRoute.css';
2
+ import { Loading as n } from "../Loading/Loading2.js";
3
+ import { useAuth as m } from "../../hooks/useAuth/useAuth.js";
4
+ /* empty css */
5
+ import { Fragment as a, jsx as t } from "react/jsx-runtime";
6
+ import { Navigate as u } from "react-router";
7
+ function g({ children: r, loginPath: o = "/login" }) {
8
+ const { isAuthenticated: e, isLoading: i } = m();
9
+ return i ? /* @__PURE__ */ t("div", {
10
+ className: "ProtectedRoute__loading",
11
+ children: /* @__PURE__ */ t(n, {})
12
+ }) : e ? /* @__PURE__ */ t(a, { children: r }) : /* @__PURE__ */ t(u, {
13
+ to: o,
14
+ replace: !0
15
+ });
16
+ }
17
+ export {
18
+ g as ProtectedRoute
19
+ };
@@ -1,19 +1,20 @@
1
- import { createContext as m, useCallback as n, useEffect as w, useState as c } from "react";
1
+ import { HttpMethod as s, buildRequestHeaders as w } from "../../helpers/Http.js";
2
+ import { createContext as A, useCallback as i, useEffect as U, useState as d } from "react";
2
3
  import { jsx as j } from "react/jsx-runtime";
3
- var A = m(void 0);
4
- function T({ children: d, config: a }) {
5
- const [u, i] = c(null), [h, o] = c(!0);
6
- w(() => {
4
+ var v = A(void 0);
5
+ function P({ children: h, config: a }) {
6
+ const [c, l] = d(null), [f, o] = d(!0);
7
+ U(() => {
7
8
  (async () => {
8
9
  try {
9
10
  const t = await fetch(`${a.apiBaseUrl}/auth/verify`, {
10
- method: "GET",
11
+ method: s.Get,
11
12
  credentials: "include",
12
13
  headers: { "Content-Type": "application/json" }
13
14
  });
14
15
  if (t.ok) {
15
16
  const e = await t.json();
16
- i({
17
+ l({
17
18
  id: e.user.id,
18
19
  username: e.user.username,
19
20
  createdAt: new Date(e.user.createdAt)
@@ -26,17 +27,17 @@ function T({ children: d, config: a }) {
26
27
  }
27
28
  })();
28
29
  }, [a.apiBaseUrl]);
29
- const s = n((r) => {
30
- r.user && i({
30
+ const n = i((r) => {
31
+ r.user && l({
31
32
  id: r.user.id,
32
33
  username: r.user.username,
33
34
  createdAt: new Date(r.user.createdAt)
34
35
  });
35
- }, []), f = n(async (r) => {
36
+ }, []), p = i(async (r) => {
36
37
  o(!0);
37
38
  try {
38
39
  const t = await fetch(`${a.apiBaseUrl}/auth/login`, {
39
- method: "POST",
40
+ method: s.Post,
40
41
  credentials: "include",
41
42
  headers: { "Content-Type": "application/json" },
42
43
  body: JSON.stringify({
@@ -46,24 +47,24 @@ function T({ children: d, config: a }) {
46
47
  })
47
48
  });
48
49
  if (!t.ok) {
49
- const l = await t.json();
50
- throw new Error(l.error || "Login failed");
50
+ const u = await t.json();
51
+ throw new Error(u.error || "Login failed");
51
52
  }
52
53
  const e = await t.json();
53
54
  return e.mfaRequired ? {
54
55
  mfaRequired: !0,
55
56
  method: e.method
56
- } : (s(e), { mfaRequired: !1 });
57
+ } : (n(e), { mfaRequired: !1 });
57
58
  } catch (t) {
58
59
  throw console.error("Login failed:", t), t;
59
60
  } finally {
60
61
  o(!1);
61
62
  }
62
- }, [a.apiBaseUrl, s]), p = n(async (r, t) => {
63
+ }, [a.apiBaseUrl, n]), m = i(async (r, t) => {
63
64
  o(!0);
64
65
  try {
65
66
  const e = await fetch(`${a.apiBaseUrl}/auth/verifyMfa`, {
66
- method: "POST",
67
+ method: s.Post,
67
68
  credentials: "include",
68
69
  headers: { "Content-Type": "application/json" },
69
70
  body: JSON.stringify({
@@ -72,42 +73,42 @@ function T({ children: d, config: a }) {
72
73
  })
73
74
  });
74
75
  if (!e.ok) {
75
- const l = await e.json();
76
- throw new Error(l.error || "Verification failed");
76
+ const u = await e.json();
77
+ throw new Error(u.error || "Verification failed");
77
78
  }
78
- s(await e.json());
79
+ n(await e.json());
79
80
  } catch (e) {
80
81
  throw console.error("MFA verification failed:", e), e;
81
82
  } finally {
82
83
  o(!1);
83
84
  }
84
- }, [a.apiBaseUrl, s]), y = n(async () => {
85
+ }, [a.apiBaseUrl, n]), y = i(async () => {
85
86
  try {
86
87
  await fetch(`${a.apiBaseUrl}/auth/logout`, {
87
- method: "POST",
88
+ method: s.Post,
88
89
  credentials: "include",
89
- headers: { "Content-Type": "application/json" }
90
+ headers: w(s.Post)
90
91
  });
91
92
  } catch (r) {
92
93
  console.error("Logout error:", r);
93
94
  } finally {
94
- i(null);
95
+ l(null);
95
96
  }
96
97
  }, [a.apiBaseUrl]);
97
- return /* @__PURE__ */ j(A.Provider, {
98
+ return /* @__PURE__ */ j(v.Provider, {
98
99
  value: {
99
- user: u,
100
- isAuthenticated: !!u,
101
- isLoading: h,
100
+ user: c,
101
+ isAuthenticated: !!c,
102
+ isLoading: f,
102
103
  config: a,
103
- login: f,
104
- verifyMfa: p,
104
+ login: p,
105
+ verifyMfa: m,
105
106
  logout: y
106
107
  },
107
- children: d
108
+ children: h
108
109
  });
109
110
  }
110
111
  export {
111
- A as AuthContext,
112
- T as AuthProvider
112
+ v as AuthContext,
113
+ P as AuthProvider
113
114
  };
@@ -0,0 +1,18 @@
1
+ var o = {
2
+ contentStyle: {
3
+ backgroundColor: "var(--tooltip-background-color)",
4
+ border: "1px solid var(--tooltip-border-color)",
5
+ borderRadius: "var(--radius-sm)",
6
+ color: "var(--tooltip-color)"
7
+ },
8
+ itemStyle: { color: "var(--tooltip-color)" },
9
+ labelStyle: { color: "var(--tooltip-color)" }
10
+ }, r = {
11
+ axis: "var(--body-color-muted)",
12
+ grid: "var(--border-color)",
13
+ text: "var(--body-color)"
14
+ };
15
+ export {
16
+ r as chartColors,
17
+ o as chartTooltipStyle
18
+ };