@nice2dev/auth 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/NiceLoginForm.d.ts +14 -0
- package/dist/NiceLoginForm.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +332 -297
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,148 +1,183 @@
|
|
|
1
|
-
import { useState as _, useCallback as
|
|
2
|
-
import { jsxs as t, jsx as e, Fragment as
|
|
3
|
-
function
|
|
4
|
-
const { onLogin: n, onRefresh:
|
|
1
|
+
import { useState as _, useCallback as x, forwardRef as E, useMemo as q } from "react";
|
|
2
|
+
import { jsxs as t, jsx as e, Fragment as V } from "react/jsx-runtime";
|
|
3
|
+
function X(a = {}) {
|
|
4
|
+
const { onLogin: n, onRefresh: o, onLogout: d, storageKey: u = "nice_auth", persistAuth: f = !1 } = a, [r, m] = _(() => {
|
|
5
5
|
if (f && typeof window < "u")
|
|
6
6
|
try {
|
|
7
|
-
const
|
|
8
|
-
if (
|
|
9
|
-
return { ...JSON.parse(
|
|
7
|
+
const s = localStorage.getItem(u);
|
|
8
|
+
if (s)
|
|
9
|
+
return { ...JSON.parse(s), loading: !1, error: null };
|
|
10
10
|
} catch {
|
|
11
11
|
}
|
|
12
12
|
return { isAuthenticated: !1, user: null, tokens: null, loading: !1, error: null };
|
|
13
|
-
}),
|
|
14
|
-
m((
|
|
15
|
-
const p = { ...
|
|
16
|
-
return f && typeof window < "u" && (p.isAuthenticated ? localStorage.setItem(
|
|
13
|
+
}), c = x((s) => {
|
|
14
|
+
m((h) => {
|
|
15
|
+
const p = { ...h, ...s };
|
|
16
|
+
return f && typeof window < "u" && (p.isAuthenticated ? localStorage.setItem(u, JSON.stringify({ isAuthenticated: !0, user: p.user })) : localStorage.removeItem(u)), p;
|
|
17
17
|
});
|
|
18
|
-
}, [f,
|
|
19
|
-
|
|
18
|
+
}, [f, u]), v = x(async (s, h) => {
|
|
19
|
+
c({ loading: !0, error: null });
|
|
20
20
|
try {
|
|
21
21
|
if (n) {
|
|
22
|
-
const p = await n(
|
|
23
|
-
return
|
|
22
|
+
const p = await n(s, h);
|
|
23
|
+
return c({ isAuthenticated: !0, user: p.user, tokens: p.tokens, loading: !1 }), !0;
|
|
24
24
|
}
|
|
25
|
-
return
|
|
25
|
+
return c({ loading: !1, error: "No login handler configured" }), !1;
|
|
26
26
|
} catch (p) {
|
|
27
|
-
return
|
|
27
|
+
return c({ loading: !1, error: (p == null ? void 0 : p.message) ?? "Login failed" }), !1;
|
|
28
28
|
}
|
|
29
|
-
}, [n,
|
|
30
|
-
|
|
31
|
-
}, [
|
|
32
|
-
var
|
|
33
|
-
if (!((
|
|
29
|
+
}, [n, c]), i = x(() => {
|
|
30
|
+
d == null || d(), c({ isAuthenticated: !1, user: null, tokens: null, loading: !1, error: null });
|
|
31
|
+
}, [d, c]), k = x(async () => {
|
|
32
|
+
var s;
|
|
33
|
+
if (!((s = r.tokens) != null && s.refreshToken) || !o) return !1;
|
|
34
34
|
try {
|
|
35
|
-
const
|
|
36
|
-
return
|
|
35
|
+
const h = await o(r.tokens.refreshToken);
|
|
36
|
+
return c({ tokens: h }), !0;
|
|
37
37
|
} catch {
|
|
38
|
-
return
|
|
38
|
+
return i(), !1;
|
|
39
39
|
}
|
|
40
|
-
}, [
|
|
41
|
-
|
|
42
|
-
}, [
|
|
43
|
-
|
|
44
|
-
}, [
|
|
40
|
+
}, [r.tokens, o, c, i]), b = x((s, h) => {
|
|
41
|
+
c({ isAuthenticated: !0, user: s, tokens: h, loading: !1, error: null });
|
|
42
|
+
}, [c]), C = x((...s) => r.user ? s.every((h) => r.user.roles.includes(h)) : !1, [r.user]), w = x((...s) => r.user ? s.every((h) => r.user.permissions.includes(h)) : !1, [r.user]), A = x(() => {
|
|
43
|
+
c({ error: null });
|
|
44
|
+
}, [c]);
|
|
45
45
|
return {
|
|
46
|
-
...
|
|
47
|
-
login:
|
|
48
|
-
logout:
|
|
46
|
+
...r,
|
|
47
|
+
login: v,
|
|
48
|
+
logout: i,
|
|
49
49
|
refreshToken: k,
|
|
50
50
|
setAuth: b,
|
|
51
51
|
hasRoles: C,
|
|
52
|
-
hasPermissions:
|
|
53
|
-
clearError:
|
|
52
|
+
hasPermissions: w,
|
|
53
|
+
clearError: A
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
56
|
+
const j = E(
|
|
57
|
+
({
|
|
58
|
+
onSubmit: a,
|
|
59
|
+
loading: n = !1,
|
|
60
|
+
error: o,
|
|
61
|
+
showRememberMe: d = !0,
|
|
62
|
+
showForgotPassword: u = !0,
|
|
63
|
+
onForgotPassword: f,
|
|
64
|
+
showRegisterLink: r = !0,
|
|
65
|
+
onRegisterClick: m,
|
|
66
|
+
title: c = "Sign In",
|
|
67
|
+
submitLabel: v = "Sign In",
|
|
68
|
+
logo: i,
|
|
69
|
+
footer: k,
|
|
70
|
+
className: b,
|
|
71
|
+
style: C,
|
|
72
|
+
emailLabel: w = "Email",
|
|
73
|
+
passwordLabel: A = "Password",
|
|
74
|
+
tracelessPolicy: s,
|
|
75
|
+
privacyMessage: h
|
|
76
|
+
}, p) => {
|
|
77
|
+
const [$, g] = _(""), [S, y] = _(""), [T, R] = _(!1), L = q(() => !(!d || s && !s.cookiesAllowed), [d, s]), P = x(
|
|
78
|
+
(F) => {
|
|
79
|
+
F.preventDefault();
|
|
80
|
+
const D = (s == null ? void 0 : s.cookiesAllowed) === !1 ? !1 : T;
|
|
81
|
+
a == null || a({ email: $, password: S, rememberMe: D });
|
|
82
|
+
},
|
|
83
|
+
[$, S, T, a, s]
|
|
84
|
+
);
|
|
85
|
+
return /* @__PURE__ */ t(
|
|
86
|
+
"form",
|
|
87
|
+
{
|
|
88
|
+
ref: p,
|
|
89
|
+
className: `nice-login-form${b ? ` ${b}` : ""}`,
|
|
90
|
+
style: C,
|
|
91
|
+
onSubmit: P,
|
|
92
|
+
noValidate: !0,
|
|
93
|
+
children: [
|
|
94
|
+
i && /* @__PURE__ */ e("div", { className: "nice-login-form__logo", children: i }),
|
|
95
|
+
/* @__PURE__ */ e("h2", { className: "nice-login-form__title", children: c }),
|
|
96
|
+
o && /* @__PURE__ */ e("div", { className: "nice-login-form__error", role: "alert", children: o }),
|
|
97
|
+
/* @__PURE__ */ t("div", { className: "nice-login-form__field", children: [
|
|
98
|
+
/* @__PURE__ */ e("label", { htmlFor: "nice-login-email", children: w }),
|
|
99
|
+
/* @__PURE__ */ e(
|
|
100
|
+
"input",
|
|
101
|
+
{
|
|
102
|
+
id: "nice-login-email",
|
|
103
|
+
className: "nice-input",
|
|
104
|
+
type: "email",
|
|
105
|
+
value: $,
|
|
106
|
+
onChange: (F) => g(F.target.value),
|
|
107
|
+
autoComplete: "email",
|
|
108
|
+
required: !0,
|
|
109
|
+
disabled: n
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
] }),
|
|
113
|
+
/* @__PURE__ */ t("div", { className: "nice-login-form__field", children: [
|
|
114
|
+
/* @__PURE__ */ e("label", { htmlFor: "nice-login-password", children: A }),
|
|
115
|
+
/* @__PURE__ */ e(
|
|
116
|
+
"input",
|
|
117
|
+
{
|
|
118
|
+
id: "nice-login-password",
|
|
119
|
+
className: "nice-input",
|
|
120
|
+
type: "password",
|
|
121
|
+
value: S,
|
|
122
|
+
onChange: (F) => y(F.target.value),
|
|
123
|
+
autoComplete: "current-password",
|
|
124
|
+
required: !0,
|
|
125
|
+
disabled: n
|
|
126
|
+
}
|
|
127
|
+
)
|
|
128
|
+
] }),
|
|
129
|
+
/* @__PURE__ */ t("div", { className: "nice-login-form__options", children: [
|
|
130
|
+
L && /* @__PURE__ */ t("label", { className: "nice-login-form__remember", children: [
|
|
131
|
+
/* @__PURE__ */ e(
|
|
132
|
+
"input",
|
|
133
|
+
{
|
|
134
|
+
type: "checkbox",
|
|
135
|
+
checked: T,
|
|
136
|
+
onChange: (F) => R(F.target.checked),
|
|
137
|
+
disabled: n
|
|
138
|
+
}
|
|
139
|
+
),
|
|
140
|
+
/* @__PURE__ */ e("span", { children: "Remember me" })
|
|
141
|
+
] }),
|
|
142
|
+
!L && d && h && /* @__PURE__ */ e("span", { className: "nice-login-form__privacy-notice", children: h }),
|
|
143
|
+
u && /* @__PURE__ */ e(
|
|
144
|
+
"button",
|
|
145
|
+
{
|
|
146
|
+
type: "button",
|
|
147
|
+
className: "nice-login-form__forgot",
|
|
148
|
+
onClick: f,
|
|
149
|
+
disabled: n,
|
|
150
|
+
children: "Forgot password?"
|
|
151
|
+
}
|
|
152
|
+
)
|
|
153
|
+
] }),
|
|
107
154
|
/* @__PURE__ */ e(
|
|
108
|
-
"
|
|
155
|
+
"button",
|
|
109
156
|
{
|
|
110
|
-
|
|
111
|
-
className: "nice-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
onChange: (x) => g(x.target.value),
|
|
115
|
-
autoComplete: "current-password",
|
|
116
|
-
required: !0,
|
|
117
|
-
disabled: n
|
|
157
|
+
type: "submit",
|
|
158
|
+
className: "nice-btn nice-btn--primary nice-login-form__submit",
|
|
159
|
+
disabled: n || !$ || !S,
|
|
160
|
+
children: n ? "…" : v
|
|
118
161
|
}
|
|
119
|
-
)
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
/* @__PURE__ */ e("input", { type: "checkbox", checked: P, onChange: (x) => v(x.target.checked), disabled: n }),
|
|
124
|
-
/* @__PURE__ */ e("span", { children: "Remember me" })
|
|
162
|
+
),
|
|
163
|
+
r && /* @__PURE__ */ t("div", { className: "nice-login-form__register", children: [
|
|
164
|
+
/* @__PURE__ */ e("span", { children: "Don't have an account? " }),
|
|
165
|
+
/* @__PURE__ */ e("button", { type: "button", onClick: m, disabled: n, children: "Register" })
|
|
125
166
|
] }),
|
|
126
|
-
|
|
127
|
-
]
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
]
|
|
135
|
-
}
|
|
136
|
-
);
|
|
137
|
-
});
|
|
138
|
-
V.displayName = "NiceLoginForm";
|
|
139
|
-
const j = {
|
|
167
|
+
k && /* @__PURE__ */ e("div", { className: "nice-login-form__footer", children: k })
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
j.displayName = "NiceLoginForm";
|
|
174
|
+
const B = {
|
|
140
175
|
0: "Very weak",
|
|
141
176
|
1: "Weak",
|
|
142
177
|
2: "Fair",
|
|
143
178
|
3: "Strong",
|
|
144
179
|
4: "Very strong"
|
|
145
|
-
},
|
|
180
|
+
}, G = {
|
|
146
181
|
0: "#d9534f",
|
|
147
182
|
1: "#f0ad4e",
|
|
148
183
|
2: "#5bc0de",
|
|
@@ -154,127 +189,127 @@ function I(a) {
|
|
|
154
189
|
let n = 0;
|
|
155
190
|
return a.length >= 8 && n++, a.length >= 12 && n++, /[a-z]/.test(a) && /[A-Z]/.test(a) && n++, /\d/.test(a) && n++, /[^a-zA-Z0-9]/.test(a) && n++, Math.min(4, n);
|
|
156
191
|
}
|
|
157
|
-
const M =
|
|
192
|
+
const M = E(({
|
|
158
193
|
password: a,
|
|
159
194
|
strength: n,
|
|
160
|
-
showLabel:
|
|
161
|
-
labels:
|
|
162
|
-
className:
|
|
195
|
+
showLabel: o = !0,
|
|
196
|
+
labels: d = B,
|
|
197
|
+
className: u
|
|
163
198
|
}, f) => {
|
|
164
|
-
const
|
|
165
|
-
return /* @__PURE__ */ t("div", { ref: f, className: `nice-password-strength${
|
|
166
|
-
/* @__PURE__ */ e("div", { className: "nice-password-strength__bar", children: /* @__PURE__ */ e("div", { className: "nice-password-strength__fill", style: { width: `${
|
|
167
|
-
|
|
199
|
+
const r = n ?? I(a), m = G[r], c = (r + 1) / 5 * 100;
|
|
200
|
+
return /* @__PURE__ */ t("div", { ref: f, className: `nice-password-strength${u ? ` ${u}` : ""}`, children: [
|
|
201
|
+
/* @__PURE__ */ e("div", { className: "nice-password-strength__bar", children: /* @__PURE__ */ e("div", { className: "nice-password-strength__fill", style: { width: `${c}%`, backgroundColor: m } }) }),
|
|
202
|
+
o && /* @__PURE__ */ e("span", { className: "nice-password-strength__label", style: { color: m }, children: d[r] })
|
|
168
203
|
] });
|
|
169
204
|
});
|
|
170
205
|
M.displayName = "NicePasswordStrength";
|
|
171
|
-
const
|
|
206
|
+
const Q = E(({
|
|
172
207
|
onSubmit: a,
|
|
173
208
|
loading: n = !1,
|
|
174
|
-
error:
|
|
175
|
-
onLoginClick:
|
|
176
|
-
showPasswordStrength:
|
|
209
|
+
error: o,
|
|
210
|
+
onLoginClick: d,
|
|
211
|
+
showPasswordStrength: u = !0,
|
|
177
212
|
minPasswordStrength: f = 2,
|
|
178
|
-
termsUrl:
|
|
213
|
+
termsUrl: r,
|
|
179
214
|
privacyUrl: m,
|
|
180
|
-
title:
|
|
181
|
-
logo:
|
|
182
|
-
footer:
|
|
215
|
+
title: c = "Create Account",
|
|
216
|
+
logo: v,
|
|
217
|
+
footer: i,
|
|
183
218
|
className: k,
|
|
184
219
|
style: b
|
|
185
220
|
}, C) => {
|
|
186
|
-
const [
|
|
187
|
-
N.preventDefault(),
|
|
188
|
-
}, [
|
|
221
|
+
const [w, A] = _(""), [s, h] = _(""), [p, $] = _(""), [g, S] = _(""), [y, T] = _(""), [R, L] = _(!1), P = I(g), F = g === y, D = w && p && g && F && R && P >= f && !n, l = x((N) => {
|
|
222
|
+
N.preventDefault(), D && (a == null || a({ firstName: w, lastName: s, email: p, password: g, acceptTerms: R }));
|
|
223
|
+
}, [D, w, s, p, g, R, a]);
|
|
189
224
|
return /* @__PURE__ */ t(
|
|
190
225
|
"form",
|
|
191
226
|
{
|
|
192
227
|
ref: C,
|
|
193
228
|
className: `nice-register-form${k ? ` ${k}` : ""}`,
|
|
194
229
|
style: b,
|
|
195
|
-
onSubmit:
|
|
230
|
+
onSubmit: l,
|
|
196
231
|
noValidate: !0,
|
|
197
232
|
children: [
|
|
198
|
-
|
|
199
|
-
/* @__PURE__ */ e("h2", { className: "nice-register-form__title", children:
|
|
200
|
-
|
|
233
|
+
v && /* @__PURE__ */ e("div", { className: "nice-register-form__logo", children: v }),
|
|
234
|
+
/* @__PURE__ */ e("h2", { className: "nice-register-form__title", children: c }),
|
|
235
|
+
o && /* @__PURE__ */ e("div", { className: "nice-register-form__error", role: "alert", children: o }),
|
|
201
236
|
/* @__PURE__ */ t("div", { className: "nice-register-form__row", children: [
|
|
202
237
|
/* @__PURE__ */ t("div", { className: "nice-register-form__field", children: [
|
|
203
238
|
/* @__PURE__ */ e("label", { htmlFor: "nice-reg-first", children: "First name *" }),
|
|
204
|
-
/* @__PURE__ */ e("input", { id: "nice-reg-first", className: "nice-input", type: "text", value:
|
|
239
|
+
/* @__PURE__ */ e("input", { id: "nice-reg-first", className: "nice-input", type: "text", value: w, onChange: (N) => A(N.target.value), required: !0, disabled: n, autoComplete: "given-name" })
|
|
205
240
|
] }),
|
|
206
241
|
/* @__PURE__ */ t("div", { className: "nice-register-form__field", children: [
|
|
207
242
|
/* @__PURE__ */ e("label", { htmlFor: "nice-reg-last", children: "Last name" }),
|
|
208
|
-
/* @__PURE__ */ e("input", { id: "nice-reg-last", className: "nice-input", type: "text", value:
|
|
243
|
+
/* @__PURE__ */ e("input", { id: "nice-reg-last", className: "nice-input", type: "text", value: s, onChange: (N) => h(N.target.value), disabled: n, autoComplete: "family-name" })
|
|
209
244
|
] })
|
|
210
245
|
] }),
|
|
211
246
|
/* @__PURE__ */ t("div", { className: "nice-register-form__field", children: [
|
|
212
247
|
/* @__PURE__ */ e("label", { htmlFor: "nice-reg-email", children: "Email *" }),
|
|
213
|
-
/* @__PURE__ */ e("input", { id: "nice-reg-email", className: "nice-input", type: "email", value: p, onChange: (N) =>
|
|
248
|
+
/* @__PURE__ */ e("input", { id: "nice-reg-email", className: "nice-input", type: "email", value: p, onChange: (N) => $(N.target.value), required: !0, disabled: n, autoComplete: "email" })
|
|
214
249
|
] }),
|
|
215
250
|
/* @__PURE__ */ t("div", { className: "nice-register-form__field", children: [
|
|
216
251
|
/* @__PURE__ */ e("label", { htmlFor: "nice-reg-pass", children: "Password *" }),
|
|
217
|
-
/* @__PURE__ */ e("input", { id: "nice-reg-pass", className: "nice-input", type: "password", value: g, onChange: (N) =>
|
|
218
|
-
|
|
252
|
+
/* @__PURE__ */ e("input", { id: "nice-reg-pass", className: "nice-input", type: "password", value: g, onChange: (N) => S(N.target.value), required: !0, disabled: n, autoComplete: "new-password" }),
|
|
253
|
+
u && g.length > 0 && /* @__PURE__ */ e(M, { password: g })
|
|
219
254
|
] }),
|
|
220
255
|
/* @__PURE__ */ t("div", { className: "nice-register-form__field", children: [
|
|
221
256
|
/* @__PURE__ */ e("label", { htmlFor: "nice-reg-confirm", children: "Confirm password *" }),
|
|
222
|
-
/* @__PURE__ */ e("input", { id: "nice-reg-confirm", className: "nice-input", type: "password", value:
|
|
223
|
-
|
|
257
|
+
/* @__PURE__ */ e("input", { id: "nice-reg-confirm", className: "nice-input", type: "password", value: y, onChange: (N) => T(N.target.value), required: !0, disabled: n, autoComplete: "new-password" }),
|
|
258
|
+
y && !F && /* @__PURE__ */ e("span", { className: "nice-error-text", children: "Passwords do not match" })
|
|
224
259
|
] }),
|
|
225
260
|
/* @__PURE__ */ t("label", { className: "nice-register-form__terms", children: [
|
|
226
|
-
/* @__PURE__ */ e("input", { type: "checkbox", checked:
|
|
261
|
+
/* @__PURE__ */ e("input", { type: "checkbox", checked: R, onChange: (N) => L(N.target.checked), disabled: n }),
|
|
227
262
|
/* @__PURE__ */ t("span", { children: [
|
|
228
263
|
"I accept the",
|
|
229
264
|
" ",
|
|
230
|
-
|
|
231
|
-
m && /* @__PURE__ */ t(
|
|
265
|
+
r ? /* @__PURE__ */ e("a", { href: r, target: "_blank", rel: "noopener noreferrer", children: "Terms" }) : "Terms",
|
|
266
|
+
m && /* @__PURE__ */ t(V, { children: [
|
|
232
267
|
" and ",
|
|
233
268
|
/* @__PURE__ */ e("a", { href: m, target: "_blank", rel: "noopener noreferrer", children: "Privacy Policy" })
|
|
234
269
|
] }),
|
|
235
270
|
" *"
|
|
236
271
|
] })
|
|
237
272
|
] }),
|
|
238
|
-
/* @__PURE__ */ e("button", { type: "submit", className: "nice-btn nice-btn--primary nice-register-form__submit", disabled: !
|
|
239
|
-
|
|
273
|
+
/* @__PURE__ */ e("button", { type: "submit", className: "nice-btn nice-btn--primary nice-register-form__submit", disabled: !D, children: n ? "…" : "Register" }),
|
|
274
|
+
d && /* @__PURE__ */ t("div", { className: "nice-register-form__login", children: [
|
|
240
275
|
/* @__PURE__ */ e("span", { children: "Already have an account? " }),
|
|
241
|
-
/* @__PURE__ */ e("button", { type: "button", onClick:
|
|
276
|
+
/* @__PURE__ */ e("button", { type: "button", onClick: d, children: "Sign in" })
|
|
242
277
|
] }),
|
|
243
|
-
|
|
278
|
+
i && /* @__PURE__ */ e("div", { className: "nice-register-form__footer", children: i })
|
|
244
279
|
]
|
|
245
280
|
}
|
|
246
281
|
);
|
|
247
282
|
});
|
|
248
|
-
|
|
249
|
-
const
|
|
283
|
+
Q.displayName = "NiceRegistrationForm";
|
|
284
|
+
const z = E(({
|
|
250
285
|
requireCurrentPassword: a = !0,
|
|
251
286
|
onSubmit: n,
|
|
252
|
-
loading:
|
|
253
|
-
error:
|
|
254
|
-
success:
|
|
287
|
+
loading: o = !1,
|
|
288
|
+
error: d,
|
|
289
|
+
success: u,
|
|
255
290
|
minPasswordStrength: f = 2,
|
|
256
|
-
title:
|
|
291
|
+
title: r = "Change Password",
|
|
257
292
|
className: m,
|
|
258
|
-
style:
|
|
259
|
-
},
|
|
260
|
-
const [
|
|
293
|
+
style: c
|
|
294
|
+
}, v) => {
|
|
295
|
+
const [i, k] = _(""), [b, C] = _(""), [w, A] = _(""), s = I(b), h = b === w, p = (!a || i.length > 0) && b.length > 0 && h && s >= f && !o, $ = x((g) => {
|
|
261
296
|
g.preventDefault(), p && (n == null || n({
|
|
262
|
-
currentPassword: a ?
|
|
297
|
+
currentPassword: a ? i : void 0,
|
|
263
298
|
newPassword: b
|
|
264
299
|
}));
|
|
265
|
-
}, [p,
|
|
300
|
+
}, [p, i, b, a, n]);
|
|
266
301
|
return /* @__PURE__ */ t(
|
|
267
302
|
"form",
|
|
268
303
|
{
|
|
269
|
-
ref:
|
|
304
|
+
ref: v,
|
|
270
305
|
className: `nice-change-password${m ? ` ${m}` : ""}`,
|
|
271
|
-
style:
|
|
272
|
-
onSubmit:
|
|
306
|
+
style: c,
|
|
307
|
+
onSubmit: $,
|
|
273
308
|
noValidate: !0,
|
|
274
309
|
children: [
|
|
275
|
-
/* @__PURE__ */ e("h3", { className: "nice-change-password__title", children:
|
|
276
|
-
|
|
277
|
-
|
|
310
|
+
/* @__PURE__ */ e("h3", { className: "nice-change-password__title", children: r }),
|
|
311
|
+
d && /* @__PURE__ */ e("div", { className: "nice-change-password__error", role: "alert", children: d }),
|
|
312
|
+
u && /* @__PURE__ */ e("div", { className: "nice-change-password__success", role: "status", children: u }),
|
|
278
313
|
a && /* @__PURE__ */ t("div", { className: "nice-change-password__field", children: [
|
|
279
314
|
/* @__PURE__ */ e("label", { htmlFor: "nice-cp-current", children: "Current password" }),
|
|
280
315
|
/* @__PURE__ */ e(
|
|
@@ -283,10 +318,10 @@ const Q = T(({
|
|
|
283
318
|
id: "nice-cp-current",
|
|
284
319
|
className: "nice-input",
|
|
285
320
|
type: "password",
|
|
286
|
-
value:
|
|
321
|
+
value: i,
|
|
287
322
|
onChange: (g) => k(g.target.value),
|
|
288
323
|
autoComplete: "current-password",
|
|
289
|
-
disabled:
|
|
324
|
+
disabled: o,
|
|
290
325
|
required: !0
|
|
291
326
|
}
|
|
292
327
|
)
|
|
@@ -302,7 +337,7 @@ const Q = T(({
|
|
|
302
337
|
value: b,
|
|
303
338
|
onChange: (g) => C(g.target.value),
|
|
304
339
|
autoComplete: "new-password",
|
|
305
|
-
disabled:
|
|
340
|
+
disabled: o,
|
|
306
341
|
required: !0
|
|
307
342
|
}
|
|
308
343
|
),
|
|
@@ -316,56 +351,56 @@ const Q = T(({
|
|
|
316
351
|
id: "nice-cp-confirm",
|
|
317
352
|
className: "nice-input",
|
|
318
353
|
type: "password",
|
|
319
|
-
value:
|
|
320
|
-
onChange: (g) =>
|
|
354
|
+
value: w,
|
|
355
|
+
onChange: (g) => A(g.target.value),
|
|
321
356
|
autoComplete: "new-password",
|
|
322
|
-
disabled:
|
|
357
|
+
disabled: o,
|
|
323
358
|
required: !0
|
|
324
359
|
}
|
|
325
360
|
),
|
|
326
|
-
|
|
361
|
+
w && !h && /* @__PURE__ */ e("span", { className: "nice-error-text", children: "Passwords do not match" })
|
|
327
362
|
] }),
|
|
328
|
-
/* @__PURE__ */ e("button", { type: "submit", className: "nice-btn nice-btn--primary", disabled: !p, children:
|
|
363
|
+
/* @__PURE__ */ e("button", { type: "submit", className: "nice-btn nice-btn--primary", disabled: !p, children: o ? "…" : "Change Password" })
|
|
329
364
|
]
|
|
330
365
|
}
|
|
331
366
|
);
|
|
332
367
|
});
|
|
333
|
-
|
|
334
|
-
const
|
|
368
|
+
z.displayName = "NiceChangePassword";
|
|
369
|
+
const J = E(({
|
|
335
370
|
secret: a,
|
|
336
371
|
qrCodeUrl: n,
|
|
337
|
-
issuer:
|
|
338
|
-
accountName:
|
|
339
|
-
onVerify:
|
|
372
|
+
issuer: o,
|
|
373
|
+
accountName: d,
|
|
374
|
+
onVerify: u,
|
|
340
375
|
loading: f = !1,
|
|
341
|
-
error:
|
|
376
|
+
error: r,
|
|
342
377
|
onCancel: m,
|
|
343
|
-
recoveryCodes:
|
|
344
|
-
step:
|
|
345
|
-
onStepChange:
|
|
378
|
+
recoveryCodes: c,
|
|
379
|
+
step: v = "setup",
|
|
380
|
+
onStepChange: i,
|
|
346
381
|
className: k,
|
|
347
382
|
style: b
|
|
348
383
|
}, C) => {
|
|
349
|
-
const [
|
|
350
|
-
|
|
351
|
-
}, [
|
|
384
|
+
const [w, A] = _(""), [s, h] = _(!1), [p, $] = _(!1), g = x((y) => {
|
|
385
|
+
y.preventDefault(), w.length >= 6 && (u == null || u(w));
|
|
386
|
+
}, [w, u]), S = `otpauth://totp/${o ? `${o}:` : ""}${d ?? "user"}?secret=${a}${o ? `&issuer=${o}` : ""}&digits=6&period=30`;
|
|
352
387
|
return /* @__PURE__ */ t("div", { ref: C, className: `nice-2fa-setup${k ? ` ${k}` : ""}`, style: b, children: [
|
|
353
388
|
/* @__PURE__ */ e("h3", { className: "nice-2fa-setup__title", children: "Two-Factor Authentication" }),
|
|
354
|
-
|
|
389
|
+
v === "setup" && /* @__PURE__ */ t("div", { className: "nice-2fa-setup__step", children: [
|
|
355
390
|
/* @__PURE__ */ e("p", { className: "nice-2fa-setup__instruction", children: "Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.):" }),
|
|
356
391
|
n ? /* @__PURE__ */ e("img", { src: n, alt: "2FA QR Code", className: "nice-2fa-setup__qr" }) : /* @__PURE__ */ t("div", { className: "nice-2fa-setup__qr-placeholder", children: [
|
|
357
392
|
/* @__PURE__ */ e("span", { children: "QR Code" }),
|
|
358
|
-
/* @__PURE__ */ e("code", { className: "nice-2fa-setup__uri", children:
|
|
393
|
+
/* @__PURE__ */ e("code", { className: "nice-2fa-setup__uri", children: S })
|
|
359
394
|
] }),
|
|
360
395
|
/* @__PURE__ */ t("div", { className: "nice-2fa-setup__secret", children: [
|
|
361
396
|
/* @__PURE__ */ e("span", { children: "Or enter manually: " }),
|
|
362
|
-
|
|
397
|
+
s ? /* @__PURE__ */ e("code", { className: "nice-2fa-setup__secret-key", children: a }) : /* @__PURE__ */ e("button", { type: "button", onClick: () => h(!0), children: "Show secret key" })
|
|
363
398
|
] }),
|
|
364
|
-
/* @__PURE__ */ e("button", { type: "button", className: "nice-btn nice-btn--primary", onClick: () =>
|
|
399
|
+
/* @__PURE__ */ e("button", { type: "button", className: "nice-btn nice-btn--primary", onClick: () => i == null ? void 0 : i("verify"), children: "Next — Verify" })
|
|
365
400
|
] }),
|
|
366
|
-
|
|
401
|
+
v === "verify" && /* @__PURE__ */ t("form", { className: "nice-2fa-setup__step", onSubmit: g, children: [
|
|
367
402
|
/* @__PURE__ */ e("p", { className: "nice-2fa-setup__instruction", children: "Enter the 6-digit code from your authenticator app:" }),
|
|
368
|
-
|
|
403
|
+
r && /* @__PURE__ */ e("div", { className: "nice-2fa-setup__error", role: "alert", children: r }),
|
|
369
404
|
/* @__PURE__ */ e(
|
|
370
405
|
"input",
|
|
371
406
|
{
|
|
@@ -373,8 +408,8 @@ const z = T(({
|
|
|
373
408
|
type: "text",
|
|
374
409
|
inputMode: "numeric",
|
|
375
410
|
maxLength: 6,
|
|
376
|
-
value:
|
|
377
|
-
onChange: (
|
|
411
|
+
value: w,
|
|
412
|
+
onChange: (y) => A(y.target.value.replace(/\D/g, "").slice(0, 6)),
|
|
378
413
|
placeholder: "000000",
|
|
379
414
|
autoFocus: !0,
|
|
380
415
|
disabled: f,
|
|
@@ -382,52 +417,52 @@ const z = T(({
|
|
|
382
417
|
}
|
|
383
418
|
),
|
|
384
419
|
/* @__PURE__ */ t("div", { className: "nice-2fa-setup__actions", children: [
|
|
385
|
-
/* @__PURE__ */ e("button", { type: "button", className: "nice-btn", onClick: () =>
|
|
386
|
-
/* @__PURE__ */ e("button", { type: "submit", className: "nice-btn nice-btn--primary", disabled: f ||
|
|
420
|
+
/* @__PURE__ */ e("button", { type: "button", className: "nice-btn", onClick: () => i == null ? void 0 : i("setup"), children: "Back" }),
|
|
421
|
+
/* @__PURE__ */ e("button", { type: "submit", className: "nice-btn nice-btn--primary", disabled: f || w.length < 6, children: f ? "…" : "Verify" })
|
|
387
422
|
] })
|
|
388
423
|
] }),
|
|
389
|
-
|
|
424
|
+
v === "recovery" && c && /* @__PURE__ */ t("div", { className: "nice-2fa-setup__step", children: [
|
|
390
425
|
/* @__PURE__ */ e("p", { className: "nice-2fa-setup__instruction", children: "Save these recovery codes in a safe place. Each code can only be used once:" }),
|
|
391
|
-
/* @__PURE__ */ e("div", { className: "nice-2fa-setup__recovery-codes", children:
|
|
426
|
+
/* @__PURE__ */ e("div", { className: "nice-2fa-setup__recovery-codes", children: c.map((y, T) => /* @__PURE__ */ e("code", { className: "nice-2fa-setup__recovery-code", children: y }, T)) }),
|
|
392
427
|
/* @__PURE__ */ e(
|
|
393
428
|
"button",
|
|
394
429
|
{
|
|
395
430
|
type: "button",
|
|
396
431
|
className: "nice-btn",
|
|
397
432
|
onClick: () => {
|
|
398
|
-
var
|
|
399
|
-
(
|
|
400
|
-
`)),
|
|
433
|
+
var y;
|
|
434
|
+
(y = navigator.clipboard) == null || y.writeText(c.join(`
|
|
435
|
+
`)), $(!0);
|
|
401
436
|
},
|
|
402
437
|
children: p ? "Copied!" : "Copy all codes"
|
|
403
438
|
}
|
|
404
439
|
),
|
|
405
440
|
m && /* @__PURE__ */ e("button", { type: "button", className: "nice-btn nice-btn--primary", onClick: m, children: "Done" })
|
|
406
441
|
] }),
|
|
407
|
-
m &&
|
|
442
|
+
m && v !== "recovery" && /* @__PURE__ */ e("button", { type: "button", className: "nice-2fa-setup__cancel", onClick: m, children: "Cancel" })
|
|
408
443
|
] });
|
|
409
444
|
});
|
|
410
|
-
|
|
411
|
-
const
|
|
445
|
+
J.displayName = "NiceTwoFaSetup";
|
|
446
|
+
const K = E(({
|
|
412
447
|
provider: a = "custom",
|
|
413
448
|
siteKey: n,
|
|
414
|
-
onVerify:
|
|
415
|
-
onExpire:
|
|
416
|
-
onError:
|
|
449
|
+
onVerify: o,
|
|
450
|
+
onExpire: d,
|
|
451
|
+
onError: u,
|
|
417
452
|
theme: f = "light",
|
|
418
|
-
size:
|
|
453
|
+
size: r = "normal",
|
|
419
454
|
customRender: m,
|
|
420
|
-
className:
|
|
421
|
-
style:
|
|
422
|
-
},
|
|
455
|
+
className: c,
|
|
456
|
+
style: v
|
|
457
|
+
}, i) => a === "custom" && m ? /* @__PURE__ */ e("div", { ref: i, className: `nice-captcha nice-captcha--custom${c ? ` ${c}` : ""}`, style: v, children: m }) : /* @__PURE__ */ e(
|
|
423
458
|
"div",
|
|
424
459
|
{
|
|
425
|
-
ref:
|
|
426
|
-
className: `nice-captcha nice-captcha--${a} nice-captcha--${f}${
|
|
427
|
-
style:
|
|
460
|
+
ref: i,
|
|
461
|
+
className: `nice-captcha nice-captcha--${a} nice-captcha--${f}${r === "compact" ? " nice-captcha--compact" : ""}${c ? ` ${c}` : ""}`,
|
|
462
|
+
style: v,
|
|
428
463
|
"data-sitekey": n,
|
|
429
464
|
"data-theme": f,
|
|
430
|
-
"data-size":
|
|
465
|
+
"data-size": r,
|
|
431
466
|
children: /* @__PURE__ */ t("div", { className: "nice-captcha__placeholder", children: [
|
|
432
467
|
/* @__PURE__ */ t("span", { children: [
|
|
433
468
|
"🔒 Captcha (",
|
|
@@ -442,97 +477,97 @@ const J = T(({
|
|
|
442
477
|
] })
|
|
443
478
|
}
|
|
444
479
|
));
|
|
445
|
-
|
|
446
|
-
const
|
|
480
|
+
K.displayName = "NiceCaptcha";
|
|
481
|
+
const U = [
|
|
447
482
|
{ id: "google", label: "Google", icon: "🔵", color: "#4285f4", textColor: "#fff" },
|
|
448
483
|
{ id: "microsoft", label: "Microsoft", icon: "🟦", color: "#00a4ef", textColor: "#fff" },
|
|
449
484
|
{ id: "discord", label: "Discord", icon: "💬", color: "#5865f2", textColor: "#fff" },
|
|
450
485
|
{ id: "spotify", label: "Spotify", icon: "🎵", color: "#1db954", textColor: "#fff" },
|
|
451
486
|
{ id: "github", label: "GitHub", icon: "🐙", color: "#24292e", textColor: "#fff" }
|
|
452
|
-
],
|
|
453
|
-
providers: a =
|
|
487
|
+
], Z = E(({
|
|
488
|
+
providers: a = U,
|
|
454
489
|
onProviderClick: n,
|
|
455
|
-
disabled:
|
|
456
|
-
loadingProvider:
|
|
457
|
-
direction:
|
|
490
|
+
disabled: o = !1,
|
|
491
|
+
loadingProvider: d,
|
|
492
|
+
direction: u = "vertical",
|
|
458
493
|
separatorText: f = "or continue with",
|
|
459
|
-
showSeparator:
|
|
494
|
+
showSeparator: r = !0,
|
|
460
495
|
className: m,
|
|
461
|
-
style:
|
|
462
|
-
},
|
|
496
|
+
style: c
|
|
497
|
+
}, v) => /* @__PURE__ */ t(
|
|
463
498
|
"div",
|
|
464
499
|
{
|
|
465
|
-
ref:
|
|
466
|
-
className: `nice-oauth nice-oauth--${
|
|
467
|
-
style:
|
|
500
|
+
ref: v,
|
|
501
|
+
className: `nice-oauth nice-oauth--${u}${m ? ` ${m}` : ""}`,
|
|
502
|
+
style: c,
|
|
468
503
|
children: [
|
|
469
|
-
|
|
504
|
+
r && /* @__PURE__ */ t("div", { className: "nice-oauth__separator", children: [
|
|
470
505
|
/* @__PURE__ */ e("hr", {}),
|
|
471
506
|
/* @__PURE__ */ e("span", { children: f }),
|
|
472
507
|
/* @__PURE__ */ e("hr", {})
|
|
473
508
|
] }),
|
|
474
|
-
/* @__PURE__ */ e("div", { className: "nice-oauth__buttons", children: a.map((
|
|
509
|
+
/* @__PURE__ */ e("div", { className: "nice-oauth__buttons", children: a.map((i) => /* @__PURE__ */ t(
|
|
475
510
|
"button",
|
|
476
511
|
{
|
|
477
512
|
type: "button",
|
|
478
|
-
className: `nice-oauth__btn${
|
|
479
|
-
style: { backgroundColor:
|
|
480
|
-
onClick: () => n == null ? void 0 : n(
|
|
481
|
-
disabled:
|
|
513
|
+
className: `nice-oauth__btn${d === i.id ? " nice-oauth__btn--loading" : ""}`,
|
|
514
|
+
style: { backgroundColor: i.color, color: i.textColor },
|
|
515
|
+
onClick: () => n == null ? void 0 : n(i.id),
|
|
516
|
+
disabled: o || !!d,
|
|
482
517
|
children: [
|
|
483
|
-
|
|
484
|
-
/* @__PURE__ */ e("span", { className: "nice-oauth__btn-label", children:
|
|
518
|
+
i.icon && /* @__PURE__ */ e("span", { className: "nice-oauth__btn-icon", children: i.icon }),
|
|
519
|
+
/* @__PURE__ */ e("span", { className: "nice-oauth__btn-label", children: d === i.id ? "…" : i.label })
|
|
485
520
|
]
|
|
486
521
|
},
|
|
487
|
-
|
|
522
|
+
i.id
|
|
488
523
|
)) })
|
|
489
524
|
]
|
|
490
525
|
}
|
|
491
526
|
));
|
|
492
|
-
|
|
493
|
-
const
|
|
527
|
+
Z.displayName = "NiceOAuthButtons";
|
|
528
|
+
const Y = E(function(n, o) {
|
|
494
529
|
const {
|
|
495
|
-
tokens:
|
|
496
|
-
onCreate:
|
|
530
|
+
tokens: d,
|
|
531
|
+
onCreate: u,
|
|
497
532
|
onRevoke: f,
|
|
498
|
-
availableScopes:
|
|
533
|
+
availableScopes: r = [],
|
|
499
534
|
maxTokens: m = 10,
|
|
500
|
-
title:
|
|
501
|
-
className:
|
|
502
|
-
style:
|
|
503
|
-
} = n, [k, b] = _(!1), [C,
|
|
504
|
-
if (!(!
|
|
505
|
-
|
|
535
|
+
title: c = "API Tokens",
|
|
536
|
+
className: v,
|
|
537
|
+
style: i
|
|
538
|
+
} = n, [k, b] = _(!1), [C, w] = _(""), [A, s] = _([]), [h, p] = _("90"), [$, g] = _(null), [S, y] = _(!1), [T, R] = _(null), L = x(async () => {
|
|
539
|
+
if (!(!u || !C.trim())) {
|
|
540
|
+
y(!0);
|
|
506
541
|
try {
|
|
507
|
-
const
|
|
508
|
-
g(N),
|
|
542
|
+
const l = h ? parseInt(h, 10) : void 0, N = await u(C.trim(), A, l);
|
|
543
|
+
g(N), w(""), s([]), b(!1);
|
|
509
544
|
} finally {
|
|
510
|
-
|
|
545
|
+
y(!1);
|
|
511
546
|
}
|
|
512
547
|
}
|
|
513
|
-
}, [
|
|
548
|
+
}, [u, C, A, h]), P = x(async (l) => {
|
|
514
549
|
if (f) {
|
|
515
|
-
|
|
550
|
+
R(l);
|
|
516
551
|
try {
|
|
517
|
-
await f(
|
|
552
|
+
await f(l);
|
|
518
553
|
} finally {
|
|
519
|
-
|
|
554
|
+
R(null);
|
|
520
555
|
}
|
|
521
556
|
}
|
|
522
|
-
}, [f]),
|
|
523
|
-
|
|
524
|
-
},
|
|
525
|
-
return /* @__PURE__ */ t("div", { ref:
|
|
557
|
+
}, [f]), F = (l) => {
|
|
558
|
+
s((N) => N.includes(l) ? N.filter((O) => O !== l) : [...N, l]);
|
|
559
|
+
}, D = d.length < m;
|
|
560
|
+
return /* @__PURE__ */ t("div", { ref: o, className: `nice-token-management ${v ?? ""}`, style: i, children: [
|
|
526
561
|
/* @__PURE__ */ t("div", { className: "nice-token-management__header", children: [
|
|
527
|
-
/* @__PURE__ */ e("h3", { children:
|
|
528
|
-
|
|
562
|
+
/* @__PURE__ */ e("h3", { children: c }),
|
|
563
|
+
D && /* @__PURE__ */ e("button", { className: "nice-token-management__new-btn", onClick: () => b(!0), disabled: k, children: "+ New Token" })
|
|
529
564
|
] }),
|
|
530
|
-
|
|
565
|
+
$ && /* @__PURE__ */ t("div", { className: "nice-token-management__reveal", children: [
|
|
531
566
|
/* @__PURE__ */ t("p", { children: [
|
|
532
567
|
/* @__PURE__ */ e("strong", { children: "New token created!" }),
|
|
533
568
|
" Copy it now — it won't be shown again."
|
|
534
569
|
] }),
|
|
535
|
-
/* @__PURE__ */ e("code", { className: "nice-token-management__token-value", children:
|
|
570
|
+
/* @__PURE__ */ e("code", { className: "nice-token-management__token-value", children: $ }),
|
|
536
571
|
/* @__PURE__ */ e("button", { onClick: () => g(null), children: "Dismiss" })
|
|
537
572
|
] }),
|
|
538
573
|
k && /* @__PURE__ */ t("div", { className: "nice-token-management__create-form", children: [
|
|
@@ -543,25 +578,25 @@ const X = T(function(n, d) {
|
|
|
543
578
|
{
|
|
544
579
|
type: "text",
|
|
545
580
|
value: C,
|
|
546
|
-
onChange: (
|
|
581
|
+
onChange: (l) => w(l.target.value),
|
|
547
582
|
placeholder: "My API token",
|
|
548
583
|
maxLength: 64
|
|
549
584
|
}
|
|
550
585
|
)
|
|
551
586
|
] }),
|
|
552
|
-
|
|
587
|
+
r.length > 0 && /* @__PURE__ */ t("fieldset", { children: [
|
|
553
588
|
/* @__PURE__ */ e("legend", { children: "Scopes" }),
|
|
554
|
-
|
|
589
|
+
r.map((l) => /* @__PURE__ */ t("label", { className: "nice-token-management__scope", children: [
|
|
555
590
|
/* @__PURE__ */ e(
|
|
556
591
|
"input",
|
|
557
592
|
{
|
|
558
593
|
type: "checkbox",
|
|
559
|
-
checked:
|
|
560
|
-
onChange: () =>
|
|
594
|
+
checked: A.includes(l),
|
|
595
|
+
onChange: () => F(l)
|
|
561
596
|
}
|
|
562
597
|
),
|
|
563
|
-
|
|
564
|
-
] },
|
|
598
|
+
l
|
|
599
|
+
] }, l))
|
|
565
600
|
] }),
|
|
566
601
|
/* @__PURE__ */ t("label", { children: [
|
|
567
602
|
"Expires in (days)",
|
|
@@ -569,19 +604,19 @@ const X = T(function(n, d) {
|
|
|
569
604
|
"input",
|
|
570
605
|
{
|
|
571
606
|
type: "number",
|
|
572
|
-
value:
|
|
573
|
-
onChange: (
|
|
607
|
+
value: h,
|
|
608
|
+
onChange: (l) => p(l.target.value),
|
|
574
609
|
min: 1,
|
|
575
610
|
max: 365
|
|
576
611
|
}
|
|
577
612
|
)
|
|
578
613
|
] }),
|
|
579
614
|
/* @__PURE__ */ t("div", { className: "nice-token-management__create-actions", children: [
|
|
580
|
-
/* @__PURE__ */ e("button", { onClick:
|
|
615
|
+
/* @__PURE__ */ e("button", { onClick: L, disabled: S || !C.trim(), children: S ? "Creating…" : "Create Token" }),
|
|
581
616
|
/* @__PURE__ */ e("button", { onClick: () => b(!1), children: "Cancel" })
|
|
582
617
|
] })
|
|
583
618
|
] }),
|
|
584
|
-
|
|
619
|
+
d.length === 0 ? /* @__PURE__ */ e("p", { className: "nice-token-management__empty", children: "No API tokens yet." }) : /* @__PURE__ */ t("table", { className: "nice-token-management__table", children: [
|
|
585
620
|
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ t("tr", { children: [
|
|
586
621
|
/* @__PURE__ */ e("th", { children: "Name" }),
|
|
587
622
|
/* @__PURE__ */ e("th", { children: "Prefix" }),
|
|
@@ -591,42 +626,42 @@ const X = T(function(n, d) {
|
|
|
591
626
|
/* @__PURE__ */ e("th", { children: "Scopes" }),
|
|
592
627
|
/* @__PURE__ */ e("th", {})
|
|
593
628
|
] }) }),
|
|
594
|
-
/* @__PURE__ */ e("tbody", { children:
|
|
629
|
+
/* @__PURE__ */ e("tbody", { children: d.map((l) => {
|
|
595
630
|
var N;
|
|
596
631
|
return /* @__PURE__ */ t("tr", { children: [
|
|
597
|
-
/* @__PURE__ */ e("td", { children:
|
|
632
|
+
/* @__PURE__ */ e("td", { children: l.name }),
|
|
598
633
|
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ t("code", { children: [
|
|
599
|
-
|
|
634
|
+
l.prefix,
|
|
600
635
|
"…"
|
|
601
636
|
] }) }),
|
|
602
|
-
/* @__PURE__ */ e("td", { children:
|
|
603
|
-
/* @__PURE__ */ e("td", { children:
|
|
604
|
-
/* @__PURE__ */ e("td", { children:
|
|
605
|
-
/* @__PURE__ */ e("td", { children: ((N =
|
|
637
|
+
/* @__PURE__ */ e("td", { children: l.createdAt }),
|
|
638
|
+
/* @__PURE__ */ e("td", { children: l.expiresAt ?? "—" }),
|
|
639
|
+
/* @__PURE__ */ e("td", { children: l.lastUsedAt ?? "Never" }),
|
|
640
|
+
/* @__PURE__ */ e("td", { children: ((N = l.scopes) == null ? void 0 : N.join(", ")) || "—" }),
|
|
606
641
|
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e(
|
|
607
642
|
"button",
|
|
608
643
|
{
|
|
609
644
|
className: "nice-token-management__revoke-btn",
|
|
610
|
-
onClick: () =>
|
|
611
|
-
disabled:
|
|
612
|
-
children:
|
|
645
|
+
onClick: () => P(l.id),
|
|
646
|
+
disabled: T === l.id,
|
|
647
|
+
children: T === l.id ? "Revoking…" : "Revoke"
|
|
613
648
|
}
|
|
614
649
|
) })
|
|
615
|
-
] },
|
|
650
|
+
] }, l.id);
|
|
616
651
|
}) })
|
|
617
652
|
] })
|
|
618
653
|
] });
|
|
619
654
|
});
|
|
620
655
|
export {
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
656
|
+
K as NiceCaptcha,
|
|
657
|
+
z as NiceChangePassword,
|
|
658
|
+
j as NiceLoginForm,
|
|
659
|
+
Z as NiceOAuthButtons,
|
|
625
660
|
M as NicePasswordStrength,
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
661
|
+
Q as NiceRegistrationForm,
|
|
662
|
+
Y as NiceTokenManagement,
|
|
663
|
+
J as NiceTwoFaSetup,
|
|
629
664
|
I as calcPasswordStrength,
|
|
630
|
-
|
|
665
|
+
X as useAuth
|
|
631
666
|
};
|
|
632
667
|
//# sourceMappingURL=index.mjs.map
|