@nice2dev/auth 1.2.1 → 1.3.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.
- package/CHANGELOG.md +43 -0
- package/dist/__tests__/i18n.test.d.ts +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +721 -681
- package/package.json +3 -1
package/dist/index.mjs
CHANGED
|
@@ -1,181 +1,182 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import { jsxs as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { useState as _, useCallback as M, forwardRef as K, useMemo as se, useRef as Q, useEffect as Z, useImperativeHandle as me } from "react";
|
|
2
|
+
import { jsxs as r, jsx as e, Fragment as ce } from "react/jsx-runtime";
|
|
3
|
+
import { useNiceTranslation as q } from "@nice2dev/ui-core";
|
|
4
|
+
function Se(s = {}) {
|
|
5
|
+
const { onLogin: a, onRefresh: n, onLogout: t, storageKey: i = "nice_auth", persistAuth: d = !1 } = s, [l, c] = _(() => {
|
|
6
|
+
if (d && typeof window < "u")
|
|
6
7
|
try {
|
|
7
|
-
const
|
|
8
|
-
if (
|
|
9
|
-
return { ...JSON.parse(
|
|
8
|
+
const m = localStorage.getItem(i);
|
|
9
|
+
if (m)
|
|
10
|
+
return { ...JSON.parse(m), loading: !1, error: null };
|
|
10
11
|
} catch {
|
|
11
12
|
}
|
|
12
13
|
return { isAuthenticated: !1, user: null, tokens: null, loading: !1, error: null };
|
|
13
|
-
}),
|
|
14
|
-
(
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
return
|
|
14
|
+
}), h = M(
|
|
15
|
+
(m) => {
|
|
16
|
+
c((p) => {
|
|
17
|
+
const b = { ...p, ...m };
|
|
18
|
+
return d && typeof window < "u" && (b.isAuthenticated ? localStorage.setItem(
|
|
18
19
|
i,
|
|
19
|
-
JSON.stringify({ isAuthenticated: !0, user:
|
|
20
|
-
) : localStorage.removeItem(i)),
|
|
20
|
+
JSON.stringify({ isAuthenticated: !0, user: b.user })
|
|
21
|
+
) : localStorage.removeItem(i)), b;
|
|
21
22
|
});
|
|
22
23
|
},
|
|
23
|
-
[
|
|
24
|
-
),
|
|
25
|
-
async (
|
|
26
|
-
|
|
24
|
+
[d, i]
|
|
25
|
+
), x = M(
|
|
26
|
+
async (m, p) => {
|
|
27
|
+
h({ loading: !0, error: null });
|
|
27
28
|
try {
|
|
28
|
-
if (
|
|
29
|
-
const
|
|
30
|
-
return
|
|
29
|
+
if (a) {
|
|
30
|
+
const b = await a(m, p);
|
|
31
|
+
return h({
|
|
31
32
|
isAuthenticated: !0,
|
|
32
|
-
user:
|
|
33
|
-
tokens:
|
|
33
|
+
user: b.user,
|
|
34
|
+
tokens: b.tokens,
|
|
34
35
|
loading: !1
|
|
35
36
|
}), !0;
|
|
36
37
|
}
|
|
37
|
-
return
|
|
38
|
-
} catch (
|
|
39
|
-
return
|
|
38
|
+
return h({ loading: !1, error: "No login handler configured" }), !1;
|
|
39
|
+
} catch (b) {
|
|
40
|
+
return h({
|
|
40
41
|
loading: !1,
|
|
41
|
-
error: (
|
|
42
|
+
error: (b == null ? void 0 : b.message) ?? "Login failed"
|
|
42
43
|
}), !1;
|
|
43
44
|
}
|
|
44
45
|
},
|
|
45
|
-
[
|
|
46
|
-
),
|
|
47
|
-
|
|
48
|
-
}, [
|
|
49
|
-
var
|
|
50
|
-
if (!((
|
|
46
|
+
[a, h]
|
|
47
|
+
), f = M(() => {
|
|
48
|
+
t == null || t(), h({ isAuthenticated: !1, user: null, tokens: null, loading: !1, error: null });
|
|
49
|
+
}, [t, h]), g = M(async () => {
|
|
50
|
+
var m;
|
|
51
|
+
if (!((m = l.tokens) != null && m.refreshToken) || !n)
|
|
51
52
|
return !1;
|
|
52
53
|
try {
|
|
53
|
-
const p = await
|
|
54
|
-
return
|
|
54
|
+
const p = await n(l.tokens.refreshToken);
|
|
55
|
+
return h({ tokens: p }), !0;
|
|
55
56
|
} catch {
|
|
56
|
-
return
|
|
57
|
+
return f(), !1;
|
|
57
58
|
}
|
|
58
|
-
}, [l.tokens,
|
|
59
|
-
(
|
|
60
|
-
|
|
59
|
+
}, [l.tokens, n, h, f]), S = M(
|
|
60
|
+
(m, p) => {
|
|
61
|
+
h({ isAuthenticated: !0, user: m, tokens: p, loading: !1, error: null });
|
|
61
62
|
},
|
|
62
|
-
[
|
|
63
|
-
),
|
|
64
|
-
(...
|
|
63
|
+
[h]
|
|
64
|
+
), y = M(
|
|
65
|
+
(...m) => l.user ? m.every((p) => l.user.roles.includes(p)) : !1,
|
|
65
66
|
[l.user]
|
|
66
|
-
),
|
|
67
|
-
(...
|
|
67
|
+
), o = M(
|
|
68
|
+
(...m) => l.user ? m.every((p) => l.user.permissions.includes(p)) : !1,
|
|
68
69
|
[l.user]
|
|
69
|
-
),
|
|
70
|
-
|
|
71
|
-
}, [
|
|
70
|
+
), w = M(() => {
|
|
71
|
+
h({ error: null });
|
|
72
|
+
}, [h]);
|
|
72
73
|
return {
|
|
73
74
|
...l,
|
|
74
|
-
login:
|
|
75
|
-
logout:
|
|
76
|
-
refreshToken:
|
|
77
|
-
setAuth:
|
|
78
|
-
hasRoles:
|
|
79
|
-
hasPermissions:
|
|
80
|
-
clearError:
|
|
75
|
+
login: x,
|
|
76
|
+
logout: f,
|
|
77
|
+
refreshToken: g,
|
|
78
|
+
setAuth: S,
|
|
79
|
+
hasRoles: y,
|
|
80
|
+
hasPermissions: o,
|
|
81
|
+
clearError: w
|
|
81
82
|
};
|
|
82
83
|
}
|
|
83
|
-
const
|
|
84
|
-
/* @__PURE__ */
|
|
84
|
+
const Te = /* @__PURE__ */ Object.assign(
|
|
85
|
+
/* @__PURE__ */ K(
|
|
85
86
|
({
|
|
86
|
-
onSubmit:
|
|
87
|
-
loading:
|
|
88
|
-
error:
|
|
89
|
-
showRememberMe:
|
|
87
|
+
onSubmit: s,
|
|
88
|
+
loading: a = !1,
|
|
89
|
+
error: n,
|
|
90
|
+
showRememberMe: t = !0,
|
|
90
91
|
showForgotPassword: i = !0,
|
|
91
|
-
onForgotPassword:
|
|
92
|
+
onForgotPassword: d,
|
|
92
93
|
showRegisterLink: l = !0,
|
|
93
|
-
onRegisterClick:
|
|
94
|
-
title:
|
|
95
|
-
submitLabel:
|
|
96
|
-
logo:
|
|
97
|
-
footer:
|
|
98
|
-
className:
|
|
99
|
-
style:
|
|
100
|
-
emailLabel:
|
|
101
|
-
passwordLabel:
|
|
102
|
-
tracelessPolicy:
|
|
94
|
+
onRegisterClick: c,
|
|
95
|
+
title: h,
|
|
96
|
+
submitLabel: x,
|
|
97
|
+
logo: f,
|
|
98
|
+
footer: g,
|
|
99
|
+
className: S,
|
|
100
|
+
style: y,
|
|
101
|
+
emailLabel: o,
|
|
102
|
+
passwordLabel: w,
|
|
103
|
+
tracelessPolicy: m,
|
|
103
104
|
privacyMessage: p
|
|
104
|
-
},
|
|
105
|
-
const [
|
|
106
|
-
(
|
|
107
|
-
|
|
108
|
-
const D = (
|
|
109
|
-
|
|
105
|
+
}, b) => {
|
|
106
|
+
const { t: N } = q(), [I, k] = _(""), [T, $] = _(""), [O, v] = _(!1), E = se(() => !(!t || m && !m.cookiesAllowed), [t, m]), L = M(
|
|
107
|
+
(A) => {
|
|
108
|
+
A.preventDefault();
|
|
109
|
+
const D = (m == null ? void 0 : m.cookiesAllowed) === !1 ? !1 : O;
|
|
110
|
+
s == null || s({ email: I, password: T, rememberMe: D });
|
|
110
111
|
},
|
|
111
|
-
[
|
|
112
|
+
[I, T, O, s, m]
|
|
112
113
|
);
|
|
113
|
-
return /* @__PURE__ */
|
|
114
|
+
return /* @__PURE__ */ r(
|
|
114
115
|
"form",
|
|
115
116
|
{
|
|
116
|
-
ref:
|
|
117
|
-
className: `nice-login-form${
|
|
118
|
-
style:
|
|
119
|
-
onSubmit:
|
|
117
|
+
ref: b,
|
|
118
|
+
className: `nice-login-form${S ? ` ${S}` : ""}`,
|
|
119
|
+
style: y,
|
|
120
|
+
onSubmit: L,
|
|
120
121
|
noValidate: !0,
|
|
121
122
|
children: [
|
|
122
|
-
|
|
123
|
-
/* @__PURE__ */ e("h2", { className: "nice-login-form__title", children:
|
|
124
|
-
|
|
125
|
-
/* @__PURE__ */
|
|
126
|
-
/* @__PURE__ */ e("label", { htmlFor: "nice-login-email", children:
|
|
123
|
+
f && /* @__PURE__ */ e("div", { className: "nice-login-form__logo", children: f }),
|
|
124
|
+
/* @__PURE__ */ e("h2", { className: "nice-login-form__title", children: h ?? N("loginForm.title", "Sign In") }),
|
|
125
|
+
n && /* @__PURE__ */ e("div", { className: "nice-login-form__error", role: "alert", children: n }),
|
|
126
|
+
/* @__PURE__ */ r("div", { className: "nice-login-form__field", children: [
|
|
127
|
+
/* @__PURE__ */ e("label", { htmlFor: "nice-login-email", children: o ?? N("loginForm.email", "Email") }),
|
|
127
128
|
/* @__PURE__ */ e(
|
|
128
129
|
"input",
|
|
129
130
|
{
|
|
130
131
|
id: "nice-login-email",
|
|
131
132
|
className: "nice-input",
|
|
132
133
|
type: "email",
|
|
133
|
-
value:
|
|
134
|
-
onChange: (
|
|
134
|
+
value: I,
|
|
135
|
+
onChange: (A) => k(A.target.value),
|
|
135
136
|
autoComplete: "email",
|
|
136
137
|
required: !0,
|
|
137
|
-
disabled:
|
|
138
|
+
disabled: a
|
|
138
139
|
}
|
|
139
140
|
)
|
|
140
141
|
] }),
|
|
141
|
-
/* @__PURE__ */
|
|
142
|
-
/* @__PURE__ */ e("label", { htmlFor: "nice-login-password", children:
|
|
142
|
+
/* @__PURE__ */ r("div", { className: "nice-login-form__field", children: [
|
|
143
|
+
/* @__PURE__ */ e("label", { htmlFor: "nice-login-password", children: w ?? N("loginForm.password", "Password") }),
|
|
143
144
|
/* @__PURE__ */ e(
|
|
144
145
|
"input",
|
|
145
146
|
{
|
|
146
147
|
id: "nice-login-password",
|
|
147
148
|
className: "nice-input",
|
|
148
149
|
type: "password",
|
|
149
|
-
value:
|
|
150
|
-
onChange: (
|
|
150
|
+
value: T,
|
|
151
|
+
onChange: (A) => $(A.target.value),
|
|
151
152
|
autoComplete: "current-password",
|
|
152
153
|
required: !0,
|
|
153
|
-
disabled:
|
|
154
|
+
disabled: a
|
|
154
155
|
}
|
|
155
156
|
)
|
|
156
157
|
] }),
|
|
157
|
-
/* @__PURE__ */
|
|
158
|
-
|
|
158
|
+
/* @__PURE__ */ r("div", { className: "nice-login-form__options", children: [
|
|
159
|
+
E && /* @__PURE__ */ r("label", { className: "nice-login-form__remember", children: [
|
|
159
160
|
/* @__PURE__ */ e(
|
|
160
161
|
"input",
|
|
161
162
|
{
|
|
162
163
|
type: "checkbox",
|
|
163
|
-
checked:
|
|
164
|
-
onChange: (
|
|
165
|
-
disabled:
|
|
164
|
+
checked: O,
|
|
165
|
+
onChange: (A) => v(A.target.checked),
|
|
166
|
+
disabled: a
|
|
166
167
|
}
|
|
167
168
|
),
|
|
168
|
-
/* @__PURE__ */ e("span", { children: "Remember me" })
|
|
169
|
+
/* @__PURE__ */ e("span", { children: N("loginForm.rememberMe", "Remember me") })
|
|
169
170
|
] }),
|
|
170
|
-
!
|
|
171
|
+
!E && t && p && /* @__PURE__ */ e("span", { className: "nice-login-form__privacy-notice", children: p }),
|
|
171
172
|
i && /* @__PURE__ */ e(
|
|
172
173
|
"button",
|
|
173
174
|
{
|
|
174
175
|
type: "button",
|
|
175
176
|
className: "nice-login-form__forgot",
|
|
176
|
-
onClick:
|
|
177
|
-
disabled:
|
|
178
|
-
children: "Forgot password?"
|
|
177
|
+
onClick: d,
|
|
178
|
+
disabled: a,
|
|
179
|
+
children: N("loginForm.forgotPassword", "Forgot password?")
|
|
179
180
|
}
|
|
180
181
|
)
|
|
181
182
|
] }),
|
|
@@ -184,200 +185,197 @@ const xe = /* @__PURE__ */ Object.assign(
|
|
|
184
185
|
{
|
|
185
186
|
type: "submit",
|
|
186
187
|
className: "nice-btn nice-btn--primary nice-login-form__submit",
|
|
187
|
-
disabled:
|
|
188
|
-
children:
|
|
188
|
+
disabled: a || !I || !T,
|
|
189
|
+
children: a ? "…" : x ?? N("loginForm.signIn", "Sign In")
|
|
189
190
|
}
|
|
190
191
|
),
|
|
191
|
-
l && /* @__PURE__ */
|
|
192
|
-
/* @__PURE__ */
|
|
193
|
-
|
|
192
|
+
l && /* @__PURE__ */ r("div", { className: "nice-login-form__register", children: [
|
|
193
|
+
/* @__PURE__ */ r("span", { children: [
|
|
194
|
+
N("loginForm.dontHaveAnAccount", "Don't have an account?"),
|
|
195
|
+
" "
|
|
196
|
+
] }),
|
|
197
|
+
/* @__PURE__ */ e("button", { type: "button", onClick: c, disabled: a, children: N("loginForm.register", "Register") })
|
|
194
198
|
] }),
|
|
195
|
-
|
|
199
|
+
g && /* @__PURE__ */ e("div", { className: "nice-login-form__footer", children: g })
|
|
196
200
|
]
|
|
197
201
|
}
|
|
198
202
|
);
|
|
199
203
|
}
|
|
200
204
|
),
|
|
201
205
|
{ displayName: "NiceLoginForm" }
|
|
202
|
-
),
|
|
206
|
+
), ue = {
|
|
203
207
|
0: "Very weak",
|
|
204
208
|
1: "Weak",
|
|
205
209
|
2: "Fair",
|
|
206
210
|
3: "Strong",
|
|
207
211
|
4: "Very strong"
|
|
208
|
-
},
|
|
212
|
+
}, pe = {
|
|
209
213
|
0: "#d9534f",
|
|
210
214
|
1: "#f0ad4e",
|
|
211
215
|
2: "#5bc0de",
|
|
212
216
|
3: "#5cb85c",
|
|
213
217
|
4: "#2e7d32"
|
|
214
218
|
};
|
|
215
|
-
function
|
|
216
|
-
if (!
|
|
219
|
+
function ee(s) {
|
|
220
|
+
if (!s)
|
|
217
221
|
return 0;
|
|
218
|
-
let
|
|
219
|
-
return
|
|
222
|
+
let a = 0;
|
|
223
|
+
return s.length >= 8 && a++, s.length >= 12 && a++, /[a-z]/.test(s) && /[A-Z]/.test(s) && a++, /\d/.test(s) && a++, /[^a-zA-Z0-9]/.test(s) && a++, Math.min(4, a);
|
|
220
224
|
}
|
|
221
|
-
const
|
|
222
|
-
/* @__PURE__ */
|
|
223
|
-
({
|
|
224
|
-
|
|
225
|
-
strength:
|
|
226
|
-
showLabel: c = !0,
|
|
227
|
-
labels: n = de,
|
|
228
|
-
className: i
|
|
229
|
-
}, h) => {
|
|
230
|
-
const l = t ?? X(r), s = he[l], u = (l + 1) / 5 * 100;
|
|
231
|
-
return /* @__PURE__ */ a("div", { ref: h, className: `nice-password-strength${i ? ` ${i}` : ""}`, children: [
|
|
225
|
+
const te = /* @__PURE__ */ Object.assign(
|
|
226
|
+
/* @__PURE__ */ K(
|
|
227
|
+
({ password: s, strength: a, showLabel: n = !0, labels: t, className: i }, d) => {
|
|
228
|
+
const { t: l } = q(), c = a ?? ee(s), h = pe[c], x = (c + 1) / 5 * 100;
|
|
229
|
+
return /* @__PURE__ */ r("div", { ref: d, className: `nice-password-strength${i ? ` ${i}` : ""}`, children: [
|
|
232
230
|
/* @__PURE__ */ e("div", { className: "nice-password-strength__bar", children: /* @__PURE__ */ e(
|
|
233
231
|
"div",
|
|
234
232
|
{
|
|
235
233
|
className: "nice-password-strength__fill",
|
|
236
|
-
style: { width: `${
|
|
234
|
+
style: { width: `${x}%`, backgroundColor: h }
|
|
237
235
|
}
|
|
238
236
|
) }),
|
|
239
|
-
|
|
237
|
+
n && /* @__PURE__ */ e("span", { className: "nice-password-strength__label", style: { color: h }, children: t ? t[c] : l(`passwordStrength.level.${c}`, ue[c]) })
|
|
240
238
|
] });
|
|
241
239
|
}
|
|
242
240
|
),
|
|
243
241
|
{ displayName: "NicePasswordStrength" }
|
|
244
|
-
),
|
|
245
|
-
/* @__PURE__ */
|
|
242
|
+
), Ae = /* @__PURE__ */ Object.assign(
|
|
243
|
+
/* @__PURE__ */ K(
|
|
246
244
|
({
|
|
247
|
-
onSubmit:
|
|
248
|
-
loading:
|
|
249
|
-
error:
|
|
250
|
-
onLoginClick:
|
|
245
|
+
onSubmit: s,
|
|
246
|
+
loading: a = !1,
|
|
247
|
+
error: n,
|
|
248
|
+
onLoginClick: t,
|
|
251
249
|
showPasswordStrength: i = !0,
|
|
252
|
-
minPasswordStrength:
|
|
250
|
+
minPasswordStrength: d = 2,
|
|
253
251
|
termsUrl: l,
|
|
254
|
-
privacyUrl:
|
|
255
|
-
title:
|
|
256
|
-
logo:
|
|
257
|
-
footer:
|
|
258
|
-
className:
|
|
259
|
-
style:
|
|
260
|
-
},
|
|
261
|
-
const [
|
|
262
|
-
(
|
|
263
|
-
|
|
252
|
+
privacyUrl: c,
|
|
253
|
+
title: h,
|
|
254
|
+
logo: x,
|
|
255
|
+
footer: f,
|
|
256
|
+
className: g,
|
|
257
|
+
style: S
|
|
258
|
+
}, y) => {
|
|
259
|
+
const { t: o } = q(), [w, m] = _(""), [p, b] = _(""), [N, I] = _(""), [k, T] = _(""), [$, O] = _(""), [v, E] = _(!1), L = ee(k), A = k === $, D = w && N && k && A && v && L >= d && !a, u = M(
|
|
260
|
+
(C) => {
|
|
261
|
+
C.preventDefault(), D && (s == null || s({ firstName: w, lastName: p, email: N, password: k, acceptTerms: v }));
|
|
264
262
|
},
|
|
265
|
-
[D,
|
|
263
|
+
[D, w, p, N, k, v, s]
|
|
266
264
|
);
|
|
267
|
-
return /* @__PURE__ */
|
|
265
|
+
return /* @__PURE__ */ r(
|
|
268
266
|
"form",
|
|
269
267
|
{
|
|
270
|
-
ref:
|
|
271
|
-
className: `nice-register-form${
|
|
272
|
-
style:
|
|
273
|
-
onSubmit:
|
|
268
|
+
ref: y,
|
|
269
|
+
className: `nice-register-form${g ? ` ${g}` : ""}`,
|
|
270
|
+
style: S,
|
|
271
|
+
onSubmit: u,
|
|
274
272
|
noValidate: !0,
|
|
275
273
|
children: [
|
|
276
|
-
|
|
277
|
-
/* @__PURE__ */ e("h2", { className: "nice-register-form__title", children:
|
|
278
|
-
|
|
279
|
-
/* @__PURE__ */
|
|
280
|
-
/* @__PURE__ */
|
|
281
|
-
/* @__PURE__ */ e("label", { htmlFor: "nice-reg-first", children: "First name *" }),
|
|
274
|
+
x && /* @__PURE__ */ e("div", { className: "nice-register-form__logo", children: x }),
|
|
275
|
+
/* @__PURE__ */ e("h2", { className: "nice-register-form__title", children: h ?? o("registrationForm.title", "Create Account") }),
|
|
276
|
+
n && /* @__PURE__ */ e("div", { className: "nice-register-form__error", role: "alert", children: n }),
|
|
277
|
+
/* @__PURE__ */ r("div", { className: "nice-register-form__row", children: [
|
|
278
|
+
/* @__PURE__ */ r("div", { className: "nice-register-form__field", children: [
|
|
279
|
+
/* @__PURE__ */ e("label", { htmlFor: "nice-reg-first", children: o("registrationForm.firstName", "First name *") }),
|
|
282
280
|
/* @__PURE__ */ e(
|
|
283
281
|
"input",
|
|
284
282
|
{
|
|
285
283
|
id: "nice-reg-first",
|
|
286
284
|
className: "nice-input",
|
|
287
285
|
type: "text",
|
|
288
|
-
value:
|
|
289
|
-
onChange: (
|
|
286
|
+
value: w,
|
|
287
|
+
onChange: (C) => m(C.target.value),
|
|
290
288
|
required: !0,
|
|
291
|
-
disabled:
|
|
289
|
+
disabled: a,
|
|
292
290
|
autoComplete: "given-name"
|
|
293
291
|
}
|
|
294
292
|
)
|
|
295
293
|
] }),
|
|
296
|
-
/* @__PURE__ */
|
|
297
|
-
/* @__PURE__ */ e("label", { htmlFor: "nice-reg-last", children: "Last name" }),
|
|
294
|
+
/* @__PURE__ */ r("div", { className: "nice-register-form__field", children: [
|
|
295
|
+
/* @__PURE__ */ e("label", { htmlFor: "nice-reg-last", children: o("registrationForm.lastName", "Last name") }),
|
|
298
296
|
/* @__PURE__ */ e(
|
|
299
297
|
"input",
|
|
300
298
|
{
|
|
301
299
|
id: "nice-reg-last",
|
|
302
300
|
className: "nice-input",
|
|
303
301
|
type: "text",
|
|
304
|
-
value:
|
|
305
|
-
onChange: (
|
|
306
|
-
disabled:
|
|
302
|
+
value: p,
|
|
303
|
+
onChange: (C) => b(C.target.value),
|
|
304
|
+
disabled: a,
|
|
307
305
|
autoComplete: "family-name"
|
|
308
306
|
}
|
|
309
307
|
)
|
|
310
308
|
] })
|
|
311
309
|
] }),
|
|
312
|
-
/* @__PURE__ */
|
|
313
|
-
/* @__PURE__ */ e("label", { htmlFor: "nice-reg-email", children: "Email *" }),
|
|
310
|
+
/* @__PURE__ */ r("div", { className: "nice-register-form__field", children: [
|
|
311
|
+
/* @__PURE__ */ e("label", { htmlFor: "nice-reg-email", children: o("registrationForm.email", "Email *") }),
|
|
314
312
|
/* @__PURE__ */ e(
|
|
315
313
|
"input",
|
|
316
314
|
{
|
|
317
315
|
id: "nice-reg-email",
|
|
318
316
|
className: "nice-input",
|
|
319
317
|
type: "email",
|
|
320
|
-
value:
|
|
321
|
-
onChange: (
|
|
318
|
+
value: N,
|
|
319
|
+
onChange: (C) => I(C.target.value),
|
|
322
320
|
required: !0,
|
|
323
|
-
disabled:
|
|
321
|
+
disabled: a,
|
|
324
322
|
autoComplete: "email"
|
|
325
323
|
}
|
|
326
324
|
)
|
|
327
325
|
] }),
|
|
328
|
-
/* @__PURE__ */
|
|
329
|
-
/* @__PURE__ */ e("label", { htmlFor: "nice-reg-pass", children: "Password *" }),
|
|
326
|
+
/* @__PURE__ */ r("div", { className: "nice-register-form__field", children: [
|
|
327
|
+
/* @__PURE__ */ e("label", { htmlFor: "nice-reg-pass", children: o("registrationForm.password", "Password *") }),
|
|
330
328
|
/* @__PURE__ */ e(
|
|
331
329
|
"input",
|
|
332
330
|
{
|
|
333
331
|
id: "nice-reg-pass",
|
|
334
332
|
className: "nice-input",
|
|
335
333
|
type: "password",
|
|
336
|
-
value:
|
|
337
|
-
onChange: (
|
|
334
|
+
value: k,
|
|
335
|
+
onChange: (C) => T(C.target.value),
|
|
338
336
|
required: !0,
|
|
339
|
-
disabled:
|
|
337
|
+
disabled: a,
|
|
340
338
|
autoComplete: "new-password"
|
|
341
339
|
}
|
|
342
340
|
),
|
|
343
|
-
i &&
|
|
341
|
+
i && k.length > 0 && /* @__PURE__ */ e(te, { password: k })
|
|
344
342
|
] }),
|
|
345
|
-
/* @__PURE__ */
|
|
346
|
-
/* @__PURE__ */ e("label", { htmlFor: "nice-reg-confirm", children: "Confirm password *" }),
|
|
343
|
+
/* @__PURE__ */ r("div", { className: "nice-register-form__field", children: [
|
|
344
|
+
/* @__PURE__ */ e("label", { htmlFor: "nice-reg-confirm", children: o("registrationForm.confirmPassword", "Confirm password *") }),
|
|
347
345
|
/* @__PURE__ */ e(
|
|
348
346
|
"input",
|
|
349
347
|
{
|
|
350
348
|
id: "nice-reg-confirm",
|
|
351
349
|
className: "nice-input",
|
|
352
350
|
type: "password",
|
|
353
|
-
value:
|
|
354
|
-
onChange: (
|
|
351
|
+
value: $,
|
|
352
|
+
onChange: (C) => O(C.target.value),
|
|
355
353
|
required: !0,
|
|
356
|
-
disabled:
|
|
354
|
+
disabled: a,
|
|
357
355
|
autoComplete: "new-password"
|
|
358
356
|
}
|
|
359
357
|
),
|
|
360
|
-
|
|
358
|
+
$ && !A && /* @__PURE__ */ e("span", { className: "nice-error-text", children: o("registrationForm.passwordsDoNotMatch", "Passwords do not match") })
|
|
361
359
|
] }),
|
|
362
|
-
/* @__PURE__ */
|
|
360
|
+
/* @__PURE__ */ r("label", { className: "nice-register-form__terms", children: [
|
|
363
361
|
/* @__PURE__ */ e(
|
|
364
362
|
"input",
|
|
365
363
|
{
|
|
366
364
|
type: "checkbox",
|
|
367
|
-
checked:
|
|
368
|
-
onChange: (
|
|
369
|
-
disabled:
|
|
365
|
+
checked: v,
|
|
366
|
+
onChange: (C) => E(C.target.checked),
|
|
367
|
+
disabled: a
|
|
370
368
|
}
|
|
371
369
|
),
|
|
372
|
-
/* @__PURE__ */
|
|
373
|
-
"I accept the",
|
|
370
|
+
/* @__PURE__ */ r("span", { children: [
|
|
371
|
+
o("registrationForm.iAcceptThe", "I accept the"),
|
|
374
372
|
" ",
|
|
375
|
-
l ? /* @__PURE__ */ e("a", { href: l, target: "_blank", rel: "noopener noreferrer", children: "Terms" }) : "Terms",
|
|
376
|
-
|
|
373
|
+
l ? /* @__PURE__ */ e("a", { href: l, target: "_blank", rel: "noopener noreferrer", children: o("registrationForm.terms", "Terms") }) : o("registrationForm.terms", "Terms"),
|
|
374
|
+
c && /* @__PURE__ */ r(ce, { children: [
|
|
377
375
|
" ",
|
|
378
|
-
"and",
|
|
376
|
+
o("registrationForm.and", "and"),
|
|
379
377
|
" ",
|
|
380
|
-
/* @__PURE__ */ e("a", { href:
|
|
378
|
+
/* @__PURE__ */ e("a", { href: c, target: "_blank", rel: "noopener noreferrer", children: o("registrationForm.privacyPolicy", "Privacy Policy") })
|
|
381
379
|
] }),
|
|
382
380
|
" *"
|
|
383
381
|
] })
|
|
@@ -388,21 +386,24 @@ const Y = /* @__PURE__ */ Object.assign(
|
|
|
388
386
|
type: "submit",
|
|
389
387
|
className: "nice-btn nice-btn--primary nice-register-form__submit",
|
|
390
388
|
disabled: !D,
|
|
391
|
-
children:
|
|
389
|
+
children: a ? "…" : o("registrationForm.register", "Register")
|
|
392
390
|
}
|
|
393
391
|
),
|
|
394
|
-
|
|
395
|
-
/* @__PURE__ */
|
|
396
|
-
|
|
392
|
+
t && /* @__PURE__ */ r("div", { className: "nice-register-form__login", children: [
|
|
393
|
+
/* @__PURE__ */ r("span", { children: [
|
|
394
|
+
o("registrationForm.alreadyHaveAnAccount", "Already have an account?"),
|
|
395
|
+
" "
|
|
396
|
+
] }),
|
|
397
|
+
/* @__PURE__ */ e("button", { type: "button", onClick: t, children: o("registrationForm.signIn", "Sign in") })
|
|
397
398
|
] }),
|
|
398
|
-
|
|
399
|
+
f && /* @__PURE__ */ e("div", { className: "nice-register-form__footer", children: f })
|
|
399
400
|
]
|
|
400
401
|
}
|
|
401
402
|
);
|
|
402
403
|
}
|
|
403
404
|
),
|
|
404
405
|
{ displayName: "NiceRegistrationForm" }
|
|
405
|
-
),
|
|
406
|
+
), ge = ({ style: s }) => /* @__PURE__ */ e(
|
|
406
407
|
"span",
|
|
407
408
|
{
|
|
408
409
|
"aria-hidden": "true",
|
|
@@ -414,10 +415,10 @@ const Y = /* @__PURE__ */ Object.assign(
|
|
|
414
415
|
borderRight: "0.12em solid currentColor",
|
|
415
416
|
borderBottom: "0.12em solid currentColor",
|
|
416
417
|
transform: "rotate(45deg)",
|
|
417
|
-
...
|
|
418
|
+
...s
|
|
418
419
|
}
|
|
419
420
|
}
|
|
420
|
-
),
|
|
421
|
+
), ie = ({ style: s }) => /* @__PURE__ */ e(
|
|
421
422
|
"span",
|
|
422
423
|
{
|
|
423
424
|
"aria-hidden": "true",
|
|
@@ -429,22 +430,22 @@ const Y = /* @__PURE__ */ Object.assign(
|
|
|
429
430
|
border: "0.12em solid currentColor",
|
|
430
431
|
borderTopColor: "transparent",
|
|
431
432
|
transform: "rotate(-45deg)",
|
|
432
|
-
...
|
|
433
|
+
...s
|
|
433
434
|
}
|
|
434
435
|
}
|
|
435
|
-
),
|
|
436
|
+
), ae = {
|
|
436
437
|
lowercase: "abcdefghijklmnopqrstuvwxyz",
|
|
437
438
|
uppercase: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
|
438
439
|
digits: "0123456789",
|
|
439
440
|
symbols: "!@#$%^&*()-_=+[]{};:,.?/~"
|
|
440
|
-
},
|
|
441
|
+
}, fe = /[0Oo1lI|]/g, J = {
|
|
441
442
|
length: 16,
|
|
442
443
|
lowercase: !0,
|
|
443
444
|
uppercase: !0,
|
|
444
445
|
digits: !0,
|
|
445
446
|
symbols: !0,
|
|
446
447
|
excludeAmbiguous: !1
|
|
447
|
-
},
|
|
448
|
+
}, ne = {
|
|
448
449
|
password: "Generated password",
|
|
449
450
|
length: "Length",
|
|
450
451
|
lowercase: "Lowercase (a–z)",
|
|
@@ -456,92 +457,100 @@ const Y = /* @__PURE__ */ Object.assign(
|
|
|
456
457
|
copy: "Copy",
|
|
457
458
|
copied: "Copied",
|
|
458
459
|
noCharacterSets: "Pick at least one kind of character."
|
|
459
|
-
},
|
|
460
|
-
const
|
|
461
|
-
if (!
|
|
460
|
+
}, be = (s) => {
|
|
461
|
+
const a = globalThis.crypto;
|
|
462
|
+
if (!a || typeof a.getRandomValues != "function")
|
|
462
463
|
throw new Error("generatePassword: crypto.getRandomValues is not available");
|
|
463
|
-
return
|
|
464
|
+
return a.getRandomValues(s);
|
|
464
465
|
};
|
|
465
|
-
let
|
|
466
|
-
function
|
|
467
|
-
const
|
|
466
|
+
let _e = 0;
|
|
467
|
+
function X(s, a) {
|
|
468
|
+
const n = Math.floor(4294967296 / s) * s, t = new Uint32Array(1);
|
|
468
469
|
for (; ; ) {
|
|
469
|
-
const i = t
|
|
470
|
-
if (i <
|
|
471
|
-
return i %
|
|
470
|
+
const i = a(t)[0];
|
|
471
|
+
if (i < n)
|
|
472
|
+
return i % s;
|
|
472
473
|
}
|
|
473
474
|
}
|
|
474
|
-
function
|
|
475
|
-
const
|
|
476
|
-
if (
|
|
475
|
+
function re(s = {}, a = be) {
|
|
476
|
+
const n = { ...J, ...s }, t = ["lowercase", "uppercase", "digits", "symbols"].filter((c) => n[c]).map((c) => n.excludeAmbiguous ? ae[c].replace(fe, "") : ae[c]).filter((c) => c.length > 0);
|
|
477
|
+
if (t.length === 0)
|
|
477
478
|
return "";
|
|
478
|
-
const i = Math.max(
|
|
479
|
+
const i = Math.max(t.length, Math.min(1024, Math.floor(n.length))), d = t.join(""), l = t.map((c) => c[X(c.length, a)]);
|
|
479
480
|
for (; l.length < i; )
|
|
480
|
-
l.push(
|
|
481
|
-
for (let
|
|
482
|
-
const
|
|
483
|
-
[l[
|
|
481
|
+
l.push(d[X(d.length, a)]);
|
|
482
|
+
for (let c = l.length - 1; c > 0; c--) {
|
|
483
|
+
const h = X(c + 1, a);
|
|
484
|
+
[l[c], l[h]] = [l[h], l[c]];
|
|
484
485
|
}
|
|
485
486
|
return l.join("");
|
|
486
487
|
}
|
|
487
|
-
const
|
|
488
|
-
value:
|
|
489
|
-
defaultValue:
|
|
490
|
-
onChange:
|
|
491
|
-
options:
|
|
488
|
+
const Me = ({
|
|
489
|
+
value: s,
|
|
490
|
+
defaultValue: a = "",
|
|
491
|
+
onChange: n,
|
|
492
|
+
options: t,
|
|
492
493
|
defaultOptions: i,
|
|
493
|
-
onOptionsChange:
|
|
494
|
+
onOptionsChange: d,
|
|
494
495
|
minLength: l = 8,
|
|
495
|
-
maxLength:
|
|
496
|
-
showStrength:
|
|
497
|
-
showCopy:
|
|
498
|
-
onCopy:
|
|
499
|
-
labels:
|
|
500
|
-
disabled:
|
|
501
|
-
className:
|
|
502
|
-
style:
|
|
503
|
-
id:
|
|
496
|
+
maxLength: c = 64,
|
|
497
|
+
showStrength: h = !0,
|
|
498
|
+
showCopy: x = !0,
|
|
499
|
+
onCopy: f,
|
|
500
|
+
labels: g,
|
|
501
|
+
disabled: S = !1,
|
|
502
|
+
className: y,
|
|
503
|
+
style: o,
|
|
504
|
+
id: w
|
|
504
505
|
}) => {
|
|
505
|
-
const
|
|
506
|
-
...
|
|
506
|
+
const { t: m } = q(), p = {
|
|
507
|
+
...Object.fromEntries(
|
|
508
|
+
Object.keys(ne).map((R) => [
|
|
509
|
+
R,
|
|
510
|
+
m(`passwordGenerator.${R}`, ne[R])
|
|
511
|
+
])
|
|
512
|
+
),
|
|
513
|
+
...g
|
|
514
|
+
}, [b] = _(() => `nice-password-generator-${++_e}`), N = w ?? b, [I, k] = _(() => ({
|
|
515
|
+
...J,
|
|
507
516
|
...i
|
|
508
|
-
})),
|
|
509
|
-
() =>
|
|
510
|
-
),
|
|
511
|
-
|
|
512
|
-
const D =
|
|
513
|
-
(
|
|
514
|
-
|
|
517
|
+
})), T = t ? { ...J, ...t } : I, [$, O] = _(
|
|
518
|
+
() => s === void 0 && !a ? re({ ...J, ...i, ...t }) : a
|
|
519
|
+
), v = s ?? $, [E, L] = _(!1), A = Q(void 0);
|
|
520
|
+
Z(() => () => clearTimeout(A.current), []);
|
|
521
|
+
const D = M(
|
|
522
|
+
(R) => {
|
|
523
|
+
s === void 0 && O(R), L(!1), n == null || n(R);
|
|
515
524
|
},
|
|
516
|
-
[
|
|
517
|
-
),
|
|
518
|
-
(
|
|
525
|
+
[s, n]
|
|
526
|
+
), u = M(
|
|
527
|
+
(R) => D(re(R)),
|
|
519
528
|
[D]
|
|
520
|
-
),
|
|
521
|
-
const
|
|
522
|
-
|
|
523
|
-
},
|
|
524
|
-
!
|
|
525
|
-
},
|
|
526
|
-
return /* @__PURE__ */
|
|
529
|
+
), C = (R, j) => {
|
|
530
|
+
const z = { ...T, [R]: j };
|
|
531
|
+
t || k(z), d == null || d(z), u(z);
|
|
532
|
+
}, H = async () => {
|
|
533
|
+
!v || !navigator.clipboard || (await navigator.clipboard.writeText(v), L(!0), clearTimeout(A.current), A.current = setTimeout(() => L(!1), 1500), f == null || f(v));
|
|
534
|
+
}, P = !T.lowercase && !T.uppercase && !T.digits && !T.symbols, U = Math.min(c, Math.max(l, T.length));
|
|
535
|
+
return /* @__PURE__ */ r(
|
|
527
536
|
"div",
|
|
528
537
|
{
|
|
529
|
-
id:
|
|
530
|
-
className: `nice-password-generator${
|
|
531
|
-
style:
|
|
538
|
+
id: w,
|
|
539
|
+
className: `nice-password-generator${y ? ` ${y}` : ""}`,
|
|
540
|
+
style: o,
|
|
532
541
|
children: [
|
|
533
|
-
/* @__PURE__ */
|
|
542
|
+
/* @__PURE__ */ r("div", { className: "nice-password-generator__output", children: [
|
|
534
543
|
/* @__PURE__ */ e(
|
|
535
544
|
"input",
|
|
536
545
|
{
|
|
537
|
-
id: `${
|
|
546
|
+
id: `${N}-value`,
|
|
538
547
|
className: "nice-password-generator__value",
|
|
539
548
|
type: "text",
|
|
540
549
|
readOnly: !0,
|
|
541
550
|
spellCheck: !1,
|
|
542
551
|
autoComplete: "off",
|
|
543
|
-
value:
|
|
544
|
-
"aria-label":
|
|
552
|
+
value: v,
|
|
553
|
+
"aria-label": p.password
|
|
545
554
|
}
|
|
546
555
|
),
|
|
547
556
|
/* @__PURE__ */ e(
|
|
@@ -549,208 +558,224 @@ const Ae = ({
|
|
|
549
558
|
{
|
|
550
559
|
type: "button",
|
|
551
560
|
className: "nice-password-generator__button",
|
|
552
|
-
onClick: () =>
|
|
553
|
-
disabled:
|
|
554
|
-
"aria-label":
|
|
555
|
-
title:
|
|
556
|
-
children: /* @__PURE__ */ e(
|
|
561
|
+
onClick: () => u(T),
|
|
562
|
+
disabled: S || P,
|
|
563
|
+
"aria-label": p.generate,
|
|
564
|
+
title: p.generate,
|
|
565
|
+
children: /* @__PURE__ */ e(ie, {})
|
|
557
566
|
}
|
|
558
567
|
),
|
|
559
|
-
|
|
568
|
+
x && /* @__PURE__ */ e(
|
|
560
569
|
"button",
|
|
561
570
|
{
|
|
562
571
|
type: "button",
|
|
563
572
|
className: "nice-password-generator__button nice-password-generator__button--copy",
|
|
564
|
-
onClick:
|
|
565
|
-
disabled:
|
|
573
|
+
onClick: H,
|
|
574
|
+
disabled: S || !v,
|
|
566
575
|
"aria-live": "polite",
|
|
567
|
-
children:
|
|
568
|
-
/* @__PURE__ */ e(
|
|
576
|
+
children: E ? /* @__PURE__ */ r(ce, { children: [
|
|
577
|
+
/* @__PURE__ */ e(ge, {}),
|
|
569
578
|
" ",
|
|
570
|
-
|
|
571
|
-
] }) :
|
|
579
|
+
p.copied
|
|
580
|
+
] }) : p.copy
|
|
572
581
|
}
|
|
573
582
|
)
|
|
574
583
|
] }),
|
|
575
|
-
|
|
576
|
-
/* @__PURE__ */
|
|
577
|
-
/* @__PURE__ */ e("label", { htmlFor: `${
|
|
584
|
+
h && /* @__PURE__ */ e(te, { password: v }),
|
|
585
|
+
/* @__PURE__ */ r("div", { className: "nice-password-generator__length", children: [
|
|
586
|
+
/* @__PURE__ */ e("label", { htmlFor: `${N}-length`, children: p.length }),
|
|
578
587
|
/* @__PURE__ */ e(
|
|
579
588
|
"input",
|
|
580
589
|
{
|
|
581
|
-
id: `${
|
|
590
|
+
id: `${N}-length`,
|
|
582
591
|
type: "range",
|
|
583
592
|
min: l,
|
|
584
|
-
max:
|
|
585
|
-
value:
|
|
586
|
-
disabled:
|
|
587
|
-
onChange: (
|
|
593
|
+
max: c,
|
|
594
|
+
value: U,
|
|
595
|
+
disabled: S,
|
|
596
|
+
onChange: (R) => C("length", Number(R.target.value))
|
|
588
597
|
}
|
|
589
598
|
),
|
|
590
|
-
/* @__PURE__ */ e("output", { htmlFor: `${
|
|
599
|
+
/* @__PURE__ */ e("output", { htmlFor: `${N}-length`, className: "nice-password-generator__length-value", children: U })
|
|
591
600
|
] }),
|
|
592
601
|
/* @__PURE__ */ e("div", { className: "nice-password-generator__sets", children: ["lowercase", "uppercase", "digits", "symbols", "excludeAmbiguous"].map(
|
|
593
|
-
(
|
|
602
|
+
(R) => /* @__PURE__ */ r("label", { className: "nice-password-generator__option", children: [
|
|
594
603
|
/* @__PURE__ */ e(
|
|
595
604
|
"input",
|
|
596
605
|
{
|
|
597
606
|
type: "checkbox",
|
|
598
|
-
checked:
|
|
599
|
-
disabled:
|
|
600
|
-
onChange: (
|
|
607
|
+
checked: T[R],
|
|
608
|
+
disabled: S,
|
|
609
|
+
onChange: (j) => C(R, j.target.checked)
|
|
601
610
|
}
|
|
602
611
|
),
|
|
603
|
-
|
|
604
|
-
] },
|
|
612
|
+
p[R]
|
|
613
|
+
] }, R)
|
|
605
614
|
) }),
|
|
606
|
-
|
|
615
|
+
P && /* @__PURE__ */ e("p", { className: "nice-password-generator__error", role: "alert", children: p.noCharacterSets })
|
|
607
616
|
]
|
|
608
617
|
}
|
|
609
618
|
);
|
|
610
|
-
},
|
|
611
|
-
/* @__PURE__ */
|
|
619
|
+
}, $e = /* @__PURE__ */ Object.assign(
|
|
620
|
+
/* @__PURE__ */ K(
|
|
612
621
|
({
|
|
613
|
-
requireCurrentPassword:
|
|
614
|
-
onSubmit:
|
|
615
|
-
loading:
|
|
616
|
-
error:
|
|
622
|
+
requireCurrentPassword: s = !0,
|
|
623
|
+
onSubmit: a,
|
|
624
|
+
loading: n = !1,
|
|
625
|
+
error: t,
|
|
617
626
|
success: i,
|
|
618
|
-
minPasswordStrength:
|
|
619
|
-
title: l
|
|
620
|
-
className:
|
|
621
|
-
style:
|
|
622
|
-
},
|
|
623
|
-
const [
|
|
624
|
-
(
|
|
625
|
-
|
|
626
|
-
currentPassword:
|
|
627
|
-
newPassword:
|
|
627
|
+
minPasswordStrength: d = 2,
|
|
628
|
+
title: l,
|
|
629
|
+
className: c,
|
|
630
|
+
style: h
|
|
631
|
+
}, x) => {
|
|
632
|
+
const { t: f } = q(), [g, S] = _(""), [y, o] = _(""), [w, m] = _(""), p = ee(y), b = y === w, N = (!s || g.length > 0) && y.length > 0 && b && p >= d && !n, I = M(
|
|
633
|
+
(k) => {
|
|
634
|
+
k.preventDefault(), N && (a == null || a({
|
|
635
|
+
currentPassword: s ? g : void 0,
|
|
636
|
+
newPassword: y
|
|
628
637
|
}));
|
|
629
638
|
},
|
|
630
|
-
[
|
|
639
|
+
[N, g, y, s, a]
|
|
631
640
|
);
|
|
632
|
-
return /* @__PURE__ */
|
|
641
|
+
return /* @__PURE__ */ r(
|
|
633
642
|
"form",
|
|
634
643
|
{
|
|
635
|
-
ref:
|
|
636
|
-
className: `nice-change-password${
|
|
637
|
-
style:
|
|
638
|
-
onSubmit:
|
|
644
|
+
ref: x,
|
|
645
|
+
className: `nice-change-password${c ? ` ${c}` : ""}`,
|
|
646
|
+
style: h,
|
|
647
|
+
onSubmit: I,
|
|
639
648
|
noValidate: !0,
|
|
640
649
|
children: [
|
|
641
|
-
/* @__PURE__ */ e("h3", { className: "nice-change-password__title", children: l }),
|
|
642
|
-
|
|
650
|
+
/* @__PURE__ */ e("h3", { className: "nice-change-password__title", children: l ?? f("changePassword.title", "Change Password") }),
|
|
651
|
+
t && /* @__PURE__ */ e("div", { className: "nice-change-password__error", role: "alert", children: t }),
|
|
643
652
|
i && /* @__PURE__ */ e("div", { className: "nice-change-password__success", role: "status", children: i }),
|
|
644
|
-
|
|
645
|
-
/* @__PURE__ */ e("label", { htmlFor: "nice-cp-current", children: "Current password" }),
|
|
653
|
+
s && /* @__PURE__ */ r("div", { className: "nice-change-password__field", children: [
|
|
654
|
+
/* @__PURE__ */ e("label", { htmlFor: "nice-cp-current", children: f("changePassword.currentPassword", "Current password") }),
|
|
646
655
|
/* @__PURE__ */ e(
|
|
647
656
|
"input",
|
|
648
657
|
{
|
|
649
658
|
id: "nice-cp-current",
|
|
650
659
|
className: "nice-input",
|
|
651
660
|
type: "password",
|
|
652
|
-
value:
|
|
653
|
-
onChange: (
|
|
661
|
+
value: g,
|
|
662
|
+
onChange: (k) => S(k.target.value),
|
|
654
663
|
autoComplete: "current-password",
|
|
655
|
-
disabled:
|
|
664
|
+
disabled: n,
|
|
656
665
|
required: !0
|
|
657
666
|
}
|
|
658
667
|
)
|
|
659
668
|
] }),
|
|
660
|
-
/* @__PURE__ */
|
|
661
|
-
/* @__PURE__ */ e("label", { htmlFor: "nice-cp-new", children: "New password" }),
|
|
669
|
+
/* @__PURE__ */ r("div", { className: "nice-change-password__field", children: [
|
|
670
|
+
/* @__PURE__ */ e("label", { htmlFor: "nice-cp-new", children: f("changePassword.newPassword", "New password") }),
|
|
662
671
|
/* @__PURE__ */ e(
|
|
663
672
|
"input",
|
|
664
673
|
{
|
|
665
674
|
id: "nice-cp-new",
|
|
666
675
|
className: "nice-input",
|
|
667
676
|
type: "password",
|
|
668
|
-
value:
|
|
669
|
-
onChange: (
|
|
677
|
+
value: y,
|
|
678
|
+
onChange: (k) => o(k.target.value),
|
|
670
679
|
autoComplete: "new-password",
|
|
671
|
-
disabled:
|
|
680
|
+
disabled: n,
|
|
672
681
|
required: !0
|
|
673
682
|
}
|
|
674
683
|
),
|
|
675
|
-
|
|
684
|
+
y.length > 0 && /* @__PURE__ */ e(te, { password: y })
|
|
676
685
|
] }),
|
|
677
|
-
/* @__PURE__ */
|
|
678
|
-
/* @__PURE__ */ e("label", { htmlFor: "nice-cp-confirm", children: "Confirm new password" }),
|
|
686
|
+
/* @__PURE__ */ r("div", { className: "nice-change-password__field", children: [
|
|
687
|
+
/* @__PURE__ */ e("label", { htmlFor: "nice-cp-confirm", children: f("changePassword.confirmNewPassword", "Confirm new password") }),
|
|
679
688
|
/* @__PURE__ */ e(
|
|
680
689
|
"input",
|
|
681
690
|
{
|
|
682
691
|
id: "nice-cp-confirm",
|
|
683
692
|
className: "nice-input",
|
|
684
693
|
type: "password",
|
|
685
|
-
value:
|
|
686
|
-
onChange: (
|
|
694
|
+
value: w,
|
|
695
|
+
onChange: (k) => m(k.target.value),
|
|
687
696
|
autoComplete: "new-password",
|
|
688
|
-
disabled:
|
|
697
|
+
disabled: n,
|
|
689
698
|
required: !0
|
|
690
699
|
}
|
|
691
700
|
),
|
|
692
|
-
|
|
701
|
+
w && !b && /* @__PURE__ */ e("span", { className: "nice-error-text", children: f("changePassword.passwordsDoNotMatch", "Passwords do not match") })
|
|
693
702
|
] }),
|
|
694
|
-
/* @__PURE__ */ e("button", { type: "submit", className: "nice-btn nice-btn--primary", disabled: !
|
|
703
|
+
/* @__PURE__ */ e("button", { type: "submit", className: "nice-btn nice-btn--primary", disabled: !N, children: n ? "…" : f("changePassword.changePassword", "Change Password") })
|
|
695
704
|
]
|
|
696
705
|
}
|
|
697
706
|
);
|
|
698
707
|
}
|
|
699
708
|
),
|
|
700
709
|
{ displayName: "NiceChangePassword" }
|
|
701
|
-
),
|
|
702
|
-
/* @__PURE__ */
|
|
710
|
+
), Pe = /* @__PURE__ */ Object.assign(
|
|
711
|
+
/* @__PURE__ */ K(
|
|
703
712
|
({
|
|
704
|
-
secret:
|
|
705
|
-
qrCodeUrl:
|
|
706
|
-
issuer:
|
|
707
|
-
accountName:
|
|
713
|
+
secret: s,
|
|
714
|
+
qrCodeUrl: a,
|
|
715
|
+
issuer: n,
|
|
716
|
+
accountName: t,
|
|
708
717
|
onVerify: i,
|
|
709
|
-
loading:
|
|
718
|
+
loading: d = !1,
|
|
710
719
|
error: l,
|
|
711
|
-
onCancel:
|
|
712
|
-
recoveryCodes:
|
|
713
|
-
step:
|
|
714
|
-
onStepChange:
|
|
715
|
-
className:
|
|
716
|
-
style:
|
|
717
|
-
},
|
|
718
|
-
const [
|
|
719
|
-
(
|
|
720
|
-
|
|
720
|
+
onCancel: c,
|
|
721
|
+
recoveryCodes: h,
|
|
722
|
+
step: x = "setup",
|
|
723
|
+
onStepChange: f,
|
|
724
|
+
className: g,
|
|
725
|
+
style: S
|
|
726
|
+
}, y) => {
|
|
727
|
+
const { t: o } = q(), [w, m] = _(""), [p, b] = _(!1), [N, I] = _(!1), k = M(
|
|
728
|
+
($) => {
|
|
729
|
+
$.preventDefault(), w.length >= 6 && (i == null || i(w));
|
|
721
730
|
},
|
|
722
|
-
[
|
|
723
|
-
),
|
|
724
|
-
return /* @__PURE__ */
|
|
731
|
+
[w, i]
|
|
732
|
+
), T = `otpauth://totp/${n ? `${n}:` : ""}${t ?? "user"}?secret=${s}${n ? `&issuer=${n}` : ""}&digits=6&period=30`;
|
|
733
|
+
return /* @__PURE__ */ r(
|
|
725
734
|
"div",
|
|
726
735
|
{
|
|
727
|
-
ref:
|
|
728
|
-
className: `nice-2fa-setup${
|
|
729
|
-
style:
|
|
736
|
+
ref: y,
|
|
737
|
+
className: `nice-2fa-setup${g ? ` ${g}` : ""}`,
|
|
738
|
+
style: S,
|
|
730
739
|
children: [
|
|
731
|
-
/* @__PURE__ */ e("h3", { className: "nice-2fa-setup__title", children: "Two-Factor Authentication" }),
|
|
732
|
-
|
|
733
|
-
/* @__PURE__ */ e("p", { className: "nice-2fa-setup__instruction", children:
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
740
|
+
/* @__PURE__ */ e("h3", { className: "nice-2fa-setup__title", children: o("twoFaSetup.twoFactorAuthentication", "Two-Factor Authentication") }),
|
|
741
|
+
x === "setup" && /* @__PURE__ */ r("div", { className: "nice-2fa-setup__step", children: [
|
|
742
|
+
/* @__PURE__ */ e("p", { className: "nice-2fa-setup__instruction", children: o(
|
|
743
|
+
"twoFaSetup.scanThisQrCodeWith",
|
|
744
|
+
"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.):"
|
|
745
|
+
) }),
|
|
746
|
+
a ? /* @__PURE__ */ e(
|
|
747
|
+
"img",
|
|
748
|
+
{
|
|
749
|
+
src: a,
|
|
750
|
+
alt: o("twoFaSetup.n2faQrCode", "2FA QR Code"),
|
|
751
|
+
className: "nice-2fa-setup__qr"
|
|
752
|
+
}
|
|
753
|
+
) : /* @__PURE__ */ r("div", { className: "nice-2fa-setup__qr-placeholder", children: [
|
|
754
|
+
/* @__PURE__ */ e("span", { children: o("twoFaSetup.qrCode", "QR Code") }),
|
|
755
|
+
/* @__PURE__ */ e("code", { className: "nice-2fa-setup__uri", children: T })
|
|
737
756
|
] }),
|
|
738
|
-
/* @__PURE__ */
|
|
739
|
-
/* @__PURE__ */
|
|
740
|
-
|
|
757
|
+
/* @__PURE__ */ r("div", { className: "nice-2fa-setup__secret", children: [
|
|
758
|
+
/* @__PURE__ */ r("span", { children: [
|
|
759
|
+
o("twoFaSetup.orEnterManually", "Or enter manually:"),
|
|
760
|
+
" "
|
|
761
|
+
] }),
|
|
762
|
+
p ? /* @__PURE__ */ e("code", { className: "nice-2fa-setup__secret-key", children: s }) : /* @__PURE__ */ e("button", { type: "button", onClick: () => b(!0), children: o("twoFaSetup.showSecretKey", "Show secret key") })
|
|
741
763
|
] }),
|
|
742
764
|
/* @__PURE__ */ e(
|
|
743
765
|
"button",
|
|
744
766
|
{
|
|
745
767
|
type: "button",
|
|
746
768
|
className: "nice-btn nice-btn--primary",
|
|
747
|
-
onClick: () =>
|
|
748
|
-
children: "Next — Verify"
|
|
769
|
+
onClick: () => f == null ? void 0 : f("verify"),
|
|
770
|
+
children: o("twoFaSetup.nextVerify", "Next — Verify")
|
|
749
771
|
}
|
|
750
772
|
)
|
|
751
773
|
] }),
|
|
752
|
-
|
|
753
|
-
/* @__PURE__ */ e("p", { className: "nice-2fa-setup__instruction", children:
|
|
774
|
+
x === "verify" && /* @__PURE__ */ r("form", { className: "nice-2fa-setup__step", onSubmit: k, children: [
|
|
775
|
+
/* @__PURE__ */ e("p", { className: "nice-2fa-setup__instruction", children: o(
|
|
776
|
+
"twoFaSetup.enterThe6DigitCode",
|
|
777
|
+
"Enter the 6-digit code from your authenticator app:"
|
|
778
|
+
) }),
|
|
754
779
|
l && /* @__PURE__ */ e("div", { className: "nice-2fa-setup__error", role: "alert", children: l }),
|
|
755
780
|
/* @__PURE__ */ e(
|
|
756
781
|
"input",
|
|
@@ -759,216 +784,218 @@ const Ae = ({
|
|
|
759
784
|
type: "text",
|
|
760
785
|
inputMode: "numeric",
|
|
761
786
|
maxLength: 6,
|
|
762
|
-
value:
|
|
763
|
-
onChange: (
|
|
787
|
+
value: w,
|
|
788
|
+
onChange: ($) => m($.target.value.replace(/\D/g, "").slice(0, 6)),
|
|
764
789
|
placeholder: "000000",
|
|
765
790
|
autoFocus: !0,
|
|
766
|
-
disabled:
|
|
791
|
+
disabled: d,
|
|
767
792
|
autoComplete: "one-time-code"
|
|
768
793
|
}
|
|
769
794
|
),
|
|
770
|
-
/* @__PURE__ */
|
|
771
|
-
/* @__PURE__ */ e("button", { type: "button", className: "nice-btn", onClick: () =>
|
|
795
|
+
/* @__PURE__ */ r("div", { className: "nice-2fa-setup__actions", children: [
|
|
796
|
+
/* @__PURE__ */ e("button", { type: "button", className: "nice-btn", onClick: () => f == null ? void 0 : f("setup"), children: o("twoFaSetup.back", "Back") }),
|
|
772
797
|
/* @__PURE__ */ e(
|
|
773
798
|
"button",
|
|
774
799
|
{
|
|
775
800
|
type: "submit",
|
|
776
801
|
className: "nice-btn nice-btn--primary",
|
|
777
|
-
disabled:
|
|
778
|
-
children:
|
|
802
|
+
disabled: d || w.length < 6,
|
|
803
|
+
children: d ? "…" : o("twoFaSetup.verify", "Verify")
|
|
779
804
|
}
|
|
780
805
|
)
|
|
781
806
|
] })
|
|
782
807
|
] }),
|
|
783
|
-
|
|
784
|
-
/* @__PURE__ */ e("p", { className: "nice-2fa-setup__instruction", children:
|
|
785
|
-
|
|
808
|
+
x === "recovery" && h && /* @__PURE__ */ r("div", { className: "nice-2fa-setup__step", children: [
|
|
809
|
+
/* @__PURE__ */ e("p", { className: "nice-2fa-setup__instruction", children: o(
|
|
810
|
+
"twoFaSetup.saveTheseRecoveryCodesIn",
|
|
811
|
+
"Save these recovery codes in a safe place. Each code can only be used once:"
|
|
812
|
+
) }),
|
|
813
|
+
/* @__PURE__ */ e("div", { className: "nice-2fa-setup__recovery-codes", children: h.map(($, O) => /* @__PURE__ */ e("code", { className: "nice-2fa-setup__recovery-code", children: $ }, O)) }),
|
|
786
814
|
/* @__PURE__ */ e(
|
|
787
815
|
"button",
|
|
788
816
|
{
|
|
789
817
|
type: "button",
|
|
790
818
|
className: "nice-btn",
|
|
791
819
|
onClick: () => {
|
|
792
|
-
var
|
|
793
|
-
(
|
|
794
|
-
`)),
|
|
820
|
+
var $;
|
|
821
|
+
($ = navigator.clipboard) == null || $.writeText(h.join(`
|
|
822
|
+
`)), I(!0);
|
|
795
823
|
},
|
|
796
|
-
children:
|
|
824
|
+
children: N ? o("twoFaSetup.copied", "Copied!") : o("twoFaSetup.copyAllCodes", "Copy all codes")
|
|
797
825
|
}
|
|
798
826
|
),
|
|
799
|
-
|
|
827
|
+
c && /* @__PURE__ */ e("button", { type: "button", className: "nice-btn nice-btn--primary", onClick: c, children: o("twoFaSetup.done", "Done") })
|
|
800
828
|
] }),
|
|
801
|
-
|
|
829
|
+
c && x !== "recovery" && /* @__PURE__ */ e("button", { type: "button", className: "nice-2fa-setup__cancel", onClick: c, children: o("twoFaSetup.cancel", "Cancel") })
|
|
802
830
|
]
|
|
803
831
|
}
|
|
804
832
|
);
|
|
805
833
|
}
|
|
806
834
|
),
|
|
807
835
|
{ displayName: "NiceTwoFaSetup" }
|
|
808
|
-
),
|
|
809
|
-
function V(
|
|
810
|
-
return Math.floor(Math.random() * (
|
|
836
|
+
), we = 500;
|
|
837
|
+
function V(s, a) {
|
|
838
|
+
return Math.floor(Math.random() * (a - s + 1)) + s;
|
|
811
839
|
}
|
|
812
|
-
function
|
|
840
|
+
function Ne() {
|
|
813
841
|
return `${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;
|
|
814
842
|
}
|
|
815
|
-
function
|
|
816
|
-
switch (
|
|
843
|
+
function ve(s, a) {
|
|
844
|
+
switch (s) {
|
|
817
845
|
case "math": {
|
|
818
|
-
const
|
|
819
|
-
return { kind: "math", prompt: `${
|
|
846
|
+
const n = a === "easy" ? 5 : a === "hard" ? 20 : 10, t = V(1, n), i = V(1, n), d = a !== "easy" && t >= i && Math.random() < 0.5, l = d ? t - i : t + i;
|
|
847
|
+
return { kind: "math", prompt: `${t} ${d ? "−" : "+"} ${i}`, answer: l };
|
|
820
848
|
}
|
|
821
849
|
case "text": {
|
|
822
|
-
const
|
|
850
|
+
const n = a === "easy" ? 4 : a === "hard" ? 7 : 5, t = "ABCDEFGHJKMNPQRSTUVWXYZ23456789";
|
|
823
851
|
let i = "";
|
|
824
|
-
for (let
|
|
825
|
-
i +=
|
|
852
|
+
for (let d = 0; d < n; d++)
|
|
853
|
+
i += t[V(0, t.length - 1)];
|
|
826
854
|
return { kind: "text", text: i };
|
|
827
855
|
}
|
|
828
856
|
case "slider":
|
|
829
|
-
return { kind: "slider", target: V(70, 92), tolerance:
|
|
857
|
+
return { kind: "slider", target: V(70, 92), tolerance: a === "easy" ? 8 : a === "hard" ? 2 : 4 };
|
|
830
858
|
case "checkbox":
|
|
831
859
|
default:
|
|
832
860
|
return { kind: "checkbox" };
|
|
833
861
|
}
|
|
834
862
|
}
|
|
835
|
-
function
|
|
836
|
-
if (!
|
|
863
|
+
function ye(s, a, n) {
|
|
864
|
+
if (!s)
|
|
837
865
|
return;
|
|
838
|
-
const
|
|
839
|
-
if (!
|
|
866
|
+
const t = s.getContext("2d");
|
|
867
|
+
if (!t)
|
|
840
868
|
return;
|
|
841
|
-
const i =
|
|
842
|
-
|
|
843
|
-
for (let
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
const l = i / (
|
|
847
|
-
for (let
|
|
848
|
-
const
|
|
849
|
-
|
|
869
|
+
const i = s.width, d = s.height;
|
|
870
|
+
t.clearRect(0, 0, i, d), t.fillStyle = n ? "#1a1a1a" : "#f3f4f6", t.fillRect(0, 0, i, d), t.strokeStyle = n ? "rgba(255,255,255,0.18)" : "rgba(0,0,0,0.18)", t.lineWidth = 1;
|
|
871
|
+
for (let c = 0; c < 6; c++)
|
|
872
|
+
t.beginPath(), t.moveTo(V(0, i), V(0, d)), t.lineTo(V(0, i), V(0, d)), t.stroke();
|
|
873
|
+
t.fillStyle = n ? "#e5e7eb" : "#111827", t.textBaseline = "middle";
|
|
874
|
+
const l = i / (a.length + 1);
|
|
875
|
+
for (let c = 0; c < a.length; c++) {
|
|
876
|
+
const h = V(22, 30);
|
|
877
|
+
t.save(), t.translate(l * (c + 1), d / 2 + V(-4, 4)), t.rotate(V(-22, 22) * Math.PI / 180), t.font = `bold ${h}px monospace`, t.fillText(a[c], -h / 3, 0), t.restore();
|
|
850
878
|
}
|
|
851
879
|
}
|
|
852
880
|
const Re = /* @__PURE__ */ Object.assign(
|
|
853
|
-
/* @__PURE__ */
|
|
854
|
-
const {
|
|
855
|
-
variant:
|
|
856
|
-
difficulty:
|
|
857
|
-
refreshable:
|
|
858
|
-
verifyToken:
|
|
859
|
-
expiresMs:
|
|
860
|
-
label:
|
|
861
|
-
provider:
|
|
862
|
-
siteKey:
|
|
863
|
-
onVerify:
|
|
864
|
-
onExpire:
|
|
865
|
-
onError:
|
|
866
|
-
onRefresh:
|
|
867
|
-
theme:
|
|
868
|
-
size:
|
|
869
|
-
customRender:
|
|
870
|
-
className:
|
|
871
|
-
style:
|
|
872
|
-
} =
|
|
873
|
-
()
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
c === "text" && R.kind === "text" && we(w.current, R.text, _ === "dark");
|
|
886
|
-
}, [c, R, _]), Q(() => {
|
|
887
|
-
if (N !== "verified" || !l)
|
|
881
|
+
/* @__PURE__ */ K((s, a) => {
|
|
882
|
+
const { t: n } = q(), {
|
|
883
|
+
variant: t,
|
|
884
|
+
difficulty: i = "medium",
|
|
885
|
+
refreshable: d = !0,
|
|
886
|
+
verifyToken: l,
|
|
887
|
+
expiresMs: c,
|
|
888
|
+
label: h = n("captcha.imNotARobot", "I'm not a robot"),
|
|
889
|
+
provider: x = "custom",
|
|
890
|
+
siteKey: f,
|
|
891
|
+
onVerify: g,
|
|
892
|
+
onExpire: S,
|
|
893
|
+
onError: y,
|
|
894
|
+
onRefresh: o,
|
|
895
|
+
theme: w = "light",
|
|
896
|
+
size: m = "normal",
|
|
897
|
+
customRender: p,
|
|
898
|
+
className: b,
|
|
899
|
+
style: N
|
|
900
|
+
} = s, I = Q(null), k = Q(null), T = Q(void 0), [$, O] = _(0), [v, E] = _("idle"), [L, A] = _(""), [D, u] = _(""), [C, H] = _(0), P = se(() => ve(t ?? "checkbox", i), [t, i, $]), U = M(() => {
|
|
901
|
+
E("idle"), A(""), u(""), H(0), O((F) => F + 1);
|
|
902
|
+
}, []), R = M(() => {
|
|
903
|
+
U(), o == null || o();
|
|
904
|
+
}, [U, o]);
|
|
905
|
+
me(
|
|
906
|
+
a,
|
|
907
|
+
() => ({ reset: U, refresh: R, container: I.current }),
|
|
908
|
+
[U, R]
|
|
909
|
+
), Z(() => {
|
|
910
|
+
t === "text" && P.kind === "text" && ye(k.current, P.text, w === "dark");
|
|
911
|
+
}, [t, P, w]), Z(() => {
|
|
912
|
+
if (v !== "verified" || !c)
|
|
888
913
|
return;
|
|
889
|
-
const
|
|
890
|
-
|
|
891
|
-
},
|
|
892
|
-
return () => clearTimeout(
|
|
893
|
-
}, [
|
|
894
|
-
const
|
|
895
|
-
const
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
914
|
+
const F = setTimeout(() => {
|
|
915
|
+
S == null || S(), U();
|
|
916
|
+
}, c);
|
|
917
|
+
return () => clearTimeout(F);
|
|
918
|
+
}, [v, c, S, U]);
|
|
919
|
+
const j = M(() => {
|
|
920
|
+
const F = `ntd-cap:${t}:${Ne()}`;
|
|
921
|
+
l ? (E("verifying"), A(""), Promise.resolve().then(() => l(F)).then((Y) => {
|
|
922
|
+
Y ? (E("verified"), g == null || g(F)) : (E("error"), A(
|
|
923
|
+
n(
|
|
924
|
+
"captcha.verificationFailedPleaseTryAgain",
|
|
925
|
+
"Verification failed. Please try again."
|
|
926
|
+
)
|
|
927
|
+
), O((he) => he + 1), u(""));
|
|
928
|
+
}).catch((Y) => {
|
|
929
|
+
E("error"), A(
|
|
930
|
+
n("captcha.verificationErrorPleaseTryAgain", "Verification error. Please try again.")
|
|
931
|
+
), y == null || y(Y);
|
|
932
|
+
})) : (E("verified"), g == null || g(F));
|
|
933
|
+
}, [t, l, g, y, n]), z = M(() => {
|
|
934
|
+
E("error"), A(n("captcha.incorrectPleaseTryAgain", "Incorrect, please try again.")), O((F) => F + 1), u("");
|
|
935
|
+
}, [n]), oe = M(() => {
|
|
936
|
+
v === "verifying" || v === "verified" || (E("verifying"), A(""), T.current = setTimeout(j, we));
|
|
937
|
+
}, [v, j]);
|
|
938
|
+
Z(() => () => clearTimeout(T.current), []);
|
|
939
|
+
const W = M(() => {
|
|
940
|
+
P.kind === "math" ? D.trim() !== "" && Number(D) === P.answer ? j() : z() : P.kind === "text" && (D.trim().toUpperCase() === P.text ? j() : z());
|
|
941
|
+
}, [P, D, j, z]), le = M(
|
|
942
|
+
(F) => {
|
|
943
|
+
H(F), !(P.kind !== "slider" || v === "verified" || v === "verifying") && Math.abs(F - P.target) <= P.tolerance && j();
|
|
912
944
|
},
|
|
913
|
-
[
|
|
945
|
+
[P, v, j]
|
|
914
946
|
);
|
|
915
|
-
if (!
|
|
916
|
-
return
|
|
947
|
+
if (!t)
|
|
948
|
+
return x === "custom" && p ? /* @__PURE__ */ e(
|
|
917
949
|
"div",
|
|
918
950
|
{
|
|
919
|
-
ref:
|
|
920
|
-
className: `nice-captcha nice-captcha--custom${
|
|
921
|
-
style:
|
|
922
|
-
children:
|
|
951
|
+
ref: I,
|
|
952
|
+
className: `nice-captcha nice-captcha--custom${b ? ` ${b}` : ""}`,
|
|
953
|
+
style: N,
|
|
954
|
+
children: p
|
|
923
955
|
}
|
|
924
956
|
) : /* @__PURE__ */ e(
|
|
925
957
|
"div",
|
|
926
958
|
{
|
|
927
|
-
ref:
|
|
928
|
-
className: `nice-captcha nice-captcha--${
|
|
929
|
-
style:
|
|
930
|
-
"data-sitekey":
|
|
931
|
-
"data-theme":
|
|
932
|
-
"data-size":
|
|
933
|
-
children: /* @__PURE__ */
|
|
934
|
-
/* @__PURE__ */
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
"
|
|
938
|
-
|
|
939
|
-
/* @__PURE__ */ a("p", { children: [
|
|
940
|
-
"Load the ",
|
|
941
|
-
u,
|
|
942
|
-
" SDK to activate verification."
|
|
943
|
-
] })
|
|
959
|
+
ref: I,
|
|
960
|
+
className: `nice-captcha nice-captcha--${x} nice-captcha--${w}${m === "compact" ? " nice-captcha--compact" : ""}${b ? ` ${b}` : ""}`,
|
|
961
|
+
style: N,
|
|
962
|
+
"data-sitekey": f,
|
|
963
|
+
"data-theme": w,
|
|
964
|
+
"data-size": m,
|
|
965
|
+
children: /* @__PURE__ */ r("div", { className: "nice-captcha__placeholder", children: [
|
|
966
|
+
/* @__PURE__ */ e("span", { children: n("captcha.captcha", "Captcha ({provider})").replace("{provider}", String(x)) }),
|
|
967
|
+
/* @__PURE__ */ e("p", { children: n(
|
|
968
|
+
"captcha.loadTheSdkToActivate",
|
|
969
|
+
"Load the {provider} SDK to activate verification."
|
|
970
|
+
).replace("{provider}", String(x)) })
|
|
944
971
|
] })
|
|
945
972
|
}
|
|
946
973
|
);
|
|
947
|
-
const
|
|
948
|
-
return /* @__PURE__ */
|
|
974
|
+
const B = v === "verifying", G = v === "verified", de = `nice-captcha nice-captcha--${t} nice-captcha--${w} nice-captcha--${v}${m === "compact" ? " nice-captcha--compact" : ""}${b ? ` ${b}` : ""}`;
|
|
975
|
+
return /* @__PURE__ */ r(
|
|
949
976
|
"div",
|
|
950
977
|
{
|
|
951
|
-
ref:
|
|
952
|
-
className:
|
|
953
|
-
style:
|
|
978
|
+
ref: I,
|
|
979
|
+
className: de,
|
|
980
|
+
style: N,
|
|
954
981
|
role: "group",
|
|
955
|
-
"aria-label": "Captcha challenge",
|
|
956
|
-
"data-variant":
|
|
957
|
-
"data-status":
|
|
958
|
-
"data-theme":
|
|
982
|
+
"aria-label": n("captcha.captchaChallenge", "Captcha challenge"),
|
|
983
|
+
"data-variant": t,
|
|
984
|
+
"data-status": v,
|
|
985
|
+
"data-theme": w,
|
|
959
986
|
children: [
|
|
960
|
-
|
|
987
|
+
t === "checkbox" && /* @__PURE__ */ r(
|
|
961
988
|
"button",
|
|
962
989
|
{
|
|
963
990
|
type: "button",
|
|
964
991
|
className: "nice-captcha__checkbox",
|
|
965
992
|
role: "checkbox",
|
|
966
|
-
"aria-checked":
|
|
967
|
-
"aria-busy":
|
|
968
|
-
disabled:
|
|
969
|
-
onClick:
|
|
993
|
+
"aria-checked": G,
|
|
994
|
+
"aria-busy": B,
|
|
995
|
+
disabled: B || G,
|
|
996
|
+
onClick: oe,
|
|
970
997
|
children: [
|
|
971
|
-
/* @__PURE__ */ e("span", { className: "nice-captcha__box", "aria-hidden": "true", children:
|
|
998
|
+
/* @__PURE__ */ e("span", { className: "nice-captcha__box", "aria-hidden": "true", children: B ? "…" : G ? /* @__PURE__ */ e(
|
|
972
999
|
"span",
|
|
973
1000
|
{
|
|
974
1001
|
style: {
|
|
@@ -982,13 +1009,13 @@ const Re = /* @__PURE__ */ Object.assign(
|
|
|
982
1009
|
}
|
|
983
1010
|
}
|
|
984
1011
|
) : "" }),
|
|
985
|
-
/* @__PURE__ */ e("span", { className: "nice-captcha__label", children:
|
|
1012
|
+
/* @__PURE__ */ e("span", { className: "nice-captcha__label", children: h })
|
|
986
1013
|
]
|
|
987
1014
|
}
|
|
988
1015
|
),
|
|
989
|
-
|
|
990
|
-
/* @__PURE__ */
|
|
991
|
-
|
|
1016
|
+
t === "math" && P.kind === "math" && /* @__PURE__ */ r("div", { className: "nice-captcha__challenge", children: [
|
|
1017
|
+
/* @__PURE__ */ r("span", { className: "nice-captcha__prompt", "aria-hidden": "true", children: [
|
|
1018
|
+
P.prompt,
|
|
992
1019
|
" ="
|
|
993
1020
|
] }),
|
|
994
1021
|
/* @__PURE__ */ e(
|
|
@@ -998,11 +1025,14 @@ const Re = /* @__PURE__ */ Object.assign(
|
|
|
998
1025
|
type: "number",
|
|
999
1026
|
inputMode: "numeric",
|
|
1000
1027
|
value: D,
|
|
1001
|
-
"aria-label":
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1028
|
+
"aria-label": n("captcha.whatIs", "What is {prompt}?").replace(
|
|
1029
|
+
"{prompt}",
|
|
1030
|
+
String(P.prompt)
|
|
1031
|
+
),
|
|
1032
|
+
disabled: B || G,
|
|
1033
|
+
onChange: (F) => u(F.target.value),
|
|
1034
|
+
onKeyDown: (F) => {
|
|
1035
|
+
F.key === "Enter" && (F.preventDefault(), W());
|
|
1006
1036
|
}
|
|
1007
1037
|
}
|
|
1008
1038
|
),
|
|
@@ -1011,17 +1041,17 @@ const Re = /* @__PURE__ */ Object.assign(
|
|
|
1011
1041
|
{
|
|
1012
1042
|
type: "button",
|
|
1013
1043
|
className: "nice-btn nice-btn--primary nice-captcha__verify",
|
|
1014
|
-
disabled:
|
|
1015
|
-
onClick:
|
|
1016
|
-
children:
|
|
1044
|
+
disabled: B || G || D.trim() === "",
|
|
1045
|
+
onClick: W,
|
|
1046
|
+
children: B ? "…" : n("captcha.verify", "Verify")
|
|
1017
1047
|
}
|
|
1018
1048
|
)
|
|
1019
1049
|
] }),
|
|
1020
|
-
|
|
1050
|
+
t === "text" && P.kind === "text" && /* @__PURE__ */ r("div", { className: "nice-captcha__challenge", children: [
|
|
1021
1051
|
/* @__PURE__ */ e(
|
|
1022
1052
|
"canvas",
|
|
1023
1053
|
{
|
|
1024
|
-
ref:
|
|
1054
|
+
ref: k,
|
|
1025
1055
|
className: "nice-captcha__canvas",
|
|
1026
1056
|
width: 160,
|
|
1027
1057
|
height: 56,
|
|
@@ -1036,11 +1066,14 @@ const Re = /* @__PURE__ */ Object.assign(
|
|
|
1036
1066
|
autoCapitalize: "characters",
|
|
1037
1067
|
autoComplete: "off",
|
|
1038
1068
|
value: D,
|
|
1039
|
-
"aria-label":
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1069
|
+
"aria-label": n(
|
|
1070
|
+
"captcha.typeTheCharactersShownIn",
|
|
1071
|
+
"Type the characters shown in the image"
|
|
1072
|
+
),
|
|
1073
|
+
disabled: B || G,
|
|
1074
|
+
onChange: (F) => u(F.target.value),
|
|
1075
|
+
onKeyDown: (F) => {
|
|
1076
|
+
F.key === "Enter" && (F.preventDefault(), W());
|
|
1044
1077
|
}
|
|
1045
1078
|
}
|
|
1046
1079
|
),
|
|
@@ -1049,21 +1082,21 @@ const Re = /* @__PURE__ */ Object.assign(
|
|
|
1049
1082
|
{
|
|
1050
1083
|
type: "button",
|
|
1051
1084
|
className: "nice-btn nice-btn--primary nice-captcha__verify",
|
|
1052
|
-
disabled:
|
|
1053
|
-
onClick:
|
|
1054
|
-
children:
|
|
1085
|
+
disabled: B || G || D.trim() === "",
|
|
1086
|
+
onClick: W,
|
|
1087
|
+
children: B ? "…" : n("captcha.verify", "Verify")
|
|
1055
1088
|
}
|
|
1056
1089
|
)
|
|
1057
1090
|
] }),
|
|
1058
|
-
|
|
1059
|
-
/* @__PURE__ */ e("span", { className: "nice-captcha__slider-hint", "aria-hidden": "true", children:
|
|
1060
|
-
/* @__PURE__ */
|
|
1091
|
+
t === "slider" && P.kind === "slider" && /* @__PURE__ */ r("div", { className: "nice-captcha__challenge nice-captcha__challenge--slider", children: [
|
|
1092
|
+
/* @__PURE__ */ e("span", { className: "nice-captcha__slider-hint", "aria-hidden": "true", children: G ? n("captcha.verified", "Verified") : n("captcha.slideToTheMarker", "Slide to the marker") }),
|
|
1093
|
+
/* @__PURE__ */ r("div", { className: "nice-captcha__track", children: [
|
|
1061
1094
|
/* @__PURE__ */ e(
|
|
1062
1095
|
"span",
|
|
1063
1096
|
{
|
|
1064
1097
|
className: "nice-captcha__target",
|
|
1065
1098
|
"aria-hidden": "true",
|
|
1066
|
-
style: { left: `${
|
|
1099
|
+
style: { left: `${P.target}%` }
|
|
1067
1100
|
}
|
|
1068
1101
|
),
|
|
1069
1102
|
/* @__PURE__ */ e(
|
|
@@ -1073,26 +1106,29 @@ const Re = /* @__PURE__ */ Object.assign(
|
|
|
1073
1106
|
type: "range",
|
|
1074
1107
|
min: 0,
|
|
1075
1108
|
max: 100,
|
|
1076
|
-
value:
|
|
1077
|
-
"aria-label":
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1109
|
+
value: C,
|
|
1110
|
+
"aria-label": n(
|
|
1111
|
+
"captcha.slideTheHandleToThe",
|
|
1112
|
+
"Slide the handle to the marker to verify"
|
|
1113
|
+
),
|
|
1114
|
+
"aria-valuetext": `${C}%`,
|
|
1115
|
+
disabled: G || B,
|
|
1116
|
+
onChange: (F) => le(Number(F.target.value))
|
|
1081
1117
|
}
|
|
1082
1118
|
)
|
|
1083
1119
|
] })
|
|
1084
1120
|
] }),
|
|
1085
|
-
/* @__PURE__ */
|
|
1086
|
-
/* @__PURE__ */ e("div", { className: "nice-captcha__message", role: "status", "aria-live": "polite", children:
|
|
1087
|
-
|
|
1121
|
+
/* @__PURE__ */ r("div", { className: "nice-captcha__footer", children: [
|
|
1122
|
+
/* @__PURE__ */ e("div", { className: "nice-captcha__message", role: "status", "aria-live": "polite", children: L }),
|
|
1123
|
+
d && /* @__PURE__ */ e(
|
|
1088
1124
|
"button",
|
|
1089
1125
|
{
|
|
1090
1126
|
type: "button",
|
|
1091
1127
|
className: "nice-captcha__refresh",
|
|
1092
|
-
"aria-label": "Refresh challenge",
|
|
1093
|
-
title: "Refresh challenge",
|
|
1094
|
-
onClick:
|
|
1095
|
-
children: /* @__PURE__ */ e(
|
|
1128
|
+
"aria-label": n("captcha.refreshChallenge", "Refresh challenge"),
|
|
1129
|
+
title: n("captcha.refreshChallenge", "Refresh challenge"),
|
|
1130
|
+
onClick: R,
|
|
1131
|
+
children: /* @__PURE__ */ e(ie, {})
|
|
1096
1132
|
}
|
|
1097
1133
|
)
|
|
1098
1134
|
] })
|
|
@@ -1101,207 +1137,211 @@ const Re = /* @__PURE__ */ Object.assign(
|
|
|
1101
1137
|
);
|
|
1102
1138
|
}),
|
|
1103
1139
|
{ displayName: "NiceCaptcha" }
|
|
1104
|
-
),
|
|
1140
|
+
), ke = [
|
|
1105
1141
|
{ id: "google", label: "Google", color: "#4285f4", textColor: "#fff" },
|
|
1106
1142
|
{ id: "microsoft", label: "Microsoft", color: "#00a4ef", textColor: "#fff" },
|
|
1107
1143
|
{ id: "discord", label: "Discord", color: "#5865f2", textColor: "#fff" },
|
|
1108
1144
|
{ id: "spotify", label: "Spotify", color: "#1db954", textColor: "#fff" },
|
|
1109
1145
|
{ id: "github", label: "GitHub", color: "#24292e", textColor: "#fff" }
|
|
1110
|
-
],
|
|
1111
|
-
/* @__PURE__ */
|
|
1146
|
+
], Ie = /* @__PURE__ */ Object.assign(
|
|
1147
|
+
/* @__PURE__ */ K(
|
|
1112
1148
|
({
|
|
1113
|
-
providers:
|
|
1114
|
-
onProviderClick:
|
|
1115
|
-
disabled:
|
|
1116
|
-
loadingProvider:
|
|
1149
|
+
providers: s = ke,
|
|
1150
|
+
onProviderClick: a,
|
|
1151
|
+
disabled: n = !1,
|
|
1152
|
+
loadingProvider: t,
|
|
1117
1153
|
direction: i = "vertical",
|
|
1118
|
-
separatorText:
|
|
1154
|
+
separatorText: d,
|
|
1119
1155
|
showSeparator: l = !0,
|
|
1120
|
-
className:
|
|
1121
|
-
style:
|
|
1122
|
-
},
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
/* @__PURE__ */
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
{
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1156
|
+
className: c,
|
|
1157
|
+
style: h
|
|
1158
|
+
}, x) => {
|
|
1159
|
+
const { t: f } = q();
|
|
1160
|
+
return /* @__PURE__ */ r(
|
|
1161
|
+
"div",
|
|
1162
|
+
{
|
|
1163
|
+
ref: x,
|
|
1164
|
+
className: `nice-oauth nice-oauth--${i}${c ? ` ${c}` : ""}`,
|
|
1165
|
+
style: h,
|
|
1166
|
+
children: [
|
|
1167
|
+
l && /* @__PURE__ */ r("div", { className: "nice-oauth__separator", children: [
|
|
1168
|
+
/* @__PURE__ */ e("hr", {}),
|
|
1169
|
+
/* @__PURE__ */ e("span", { children: d ?? f("oAuthButtons.orContinueWith", "or continue with") }),
|
|
1170
|
+
/* @__PURE__ */ e("hr", {})
|
|
1171
|
+
] }),
|
|
1172
|
+
/* @__PURE__ */ e("div", { className: "nice-oauth__buttons", children: s.map((g) => /* @__PURE__ */ r(
|
|
1173
|
+
"button",
|
|
1174
|
+
{
|
|
1175
|
+
type: "button",
|
|
1176
|
+
className: `nice-oauth__btn${t === g.id ? " nice-oauth__btn--loading" : ""}`,
|
|
1177
|
+
style: { backgroundColor: g.color, color: g.textColor },
|
|
1178
|
+
onClick: () => a == null ? void 0 : a(g.id),
|
|
1179
|
+
disabled: n || !!t,
|
|
1180
|
+
children: [
|
|
1181
|
+
g.icon && /* @__PURE__ */ e("span", { className: "nice-oauth__btn-icon", children: g.icon }),
|
|
1182
|
+
/* @__PURE__ */ e("span", { className: "nice-oauth__btn-label", children: t === g.id ? "…" : g.label })
|
|
1183
|
+
]
|
|
1184
|
+
},
|
|
1185
|
+
g.id
|
|
1186
|
+
)) })
|
|
1187
|
+
]
|
|
1188
|
+
}
|
|
1189
|
+
);
|
|
1190
|
+
}
|
|
1152
1191
|
),
|
|
1153
1192
|
{ displayName: "NiceOAuthButtons" }
|
|
1154
|
-
),
|
|
1155
|
-
const {
|
|
1156
|
-
tokens:
|
|
1157
|
-
onCreate:
|
|
1158
|
-
onRevoke:
|
|
1159
|
-
availableScopes:
|
|
1160
|
-
maxTokens:
|
|
1161
|
-
title:
|
|
1162
|
-
className:
|
|
1163
|
-
style:
|
|
1164
|
-
} =
|
|
1165
|
-
if (!(!
|
|
1166
|
-
|
|
1193
|
+
), De = /* @__PURE__ */ K(function(a, n) {
|
|
1194
|
+
const { t } = q(), {
|
|
1195
|
+
tokens: i,
|
|
1196
|
+
onCreate: d,
|
|
1197
|
+
onRevoke: l,
|
|
1198
|
+
availableScopes: c = [],
|
|
1199
|
+
maxTokens: h = 10,
|
|
1200
|
+
title: x = t("tokenManagement.apiTokens", "API Tokens"),
|
|
1201
|
+
className: f,
|
|
1202
|
+
style: g
|
|
1203
|
+
} = a, [S, y] = _(!1), [o, w] = _(""), [m, p] = _([]), [b, N] = _("90"), [I, k] = _(null), [T, $] = _(!1), [O, v] = _(null), E = M(async () => {
|
|
1204
|
+
if (!(!d || !o.trim())) {
|
|
1205
|
+
$(!0);
|
|
1167
1206
|
try {
|
|
1168
|
-
const
|
|
1169
|
-
|
|
1207
|
+
const u = b ? parseInt(b, 10) : void 0, C = await d(o.trim(), m, u);
|
|
1208
|
+
k(C), w(""), p([]), y(!1);
|
|
1170
1209
|
} finally {
|
|
1171
|
-
|
|
1210
|
+
$(!1);
|
|
1172
1211
|
}
|
|
1173
1212
|
}
|
|
1174
|
-
}, [
|
|
1175
|
-
async (
|
|
1176
|
-
if (
|
|
1177
|
-
|
|
1213
|
+
}, [d, o, m, b]), L = M(
|
|
1214
|
+
async (u) => {
|
|
1215
|
+
if (l) {
|
|
1216
|
+
v(u);
|
|
1178
1217
|
try {
|
|
1179
|
-
await
|
|
1218
|
+
await l(u);
|
|
1180
1219
|
} finally {
|
|
1181
|
-
|
|
1220
|
+
v(null);
|
|
1182
1221
|
}
|
|
1183
1222
|
}
|
|
1184
1223
|
},
|
|
1185
|
-
[
|
|
1186
|
-
),
|
|
1187
|
-
|
|
1188
|
-
(
|
|
1224
|
+
[l]
|
|
1225
|
+
), A = (u) => {
|
|
1226
|
+
p(
|
|
1227
|
+
(C) => C.includes(u) ? C.filter((H) => H !== u) : [...C, u]
|
|
1189
1228
|
);
|
|
1190
|
-
}, D =
|
|
1191
|
-
return /* @__PURE__ */
|
|
1192
|
-
/* @__PURE__ */
|
|
1193
|
-
/* @__PURE__ */ e("h3", { children:
|
|
1229
|
+
}, D = i.length < h;
|
|
1230
|
+
return /* @__PURE__ */ r("div", { ref: n, className: `nice-token-management ${f ?? ""}`, style: g, children: [
|
|
1231
|
+
/* @__PURE__ */ r("div", { className: "nice-token-management__header", children: [
|
|
1232
|
+
/* @__PURE__ */ e("h3", { children: x }),
|
|
1194
1233
|
D && /* @__PURE__ */ e(
|
|
1195
1234
|
"button",
|
|
1196
1235
|
{
|
|
1197
1236
|
className: "nice-token-management__new-btn",
|
|
1198
|
-
onClick: () =>
|
|
1199
|
-
disabled:
|
|
1200
|
-
children: "+ New Token"
|
|
1237
|
+
onClick: () => y(!0),
|
|
1238
|
+
disabled: S,
|
|
1239
|
+
children: t("tokenManagement.newToken", "+ New Token")
|
|
1201
1240
|
}
|
|
1202
1241
|
)
|
|
1203
1242
|
] }),
|
|
1204
|
-
|
|
1205
|
-
/* @__PURE__ */
|
|
1206
|
-
/* @__PURE__ */ e("strong", { children: "New token created!" }),
|
|
1207
|
-
"
|
|
1243
|
+
I && /* @__PURE__ */ r("div", { className: "nice-token-management__reveal", children: [
|
|
1244
|
+
/* @__PURE__ */ r("p", { children: [
|
|
1245
|
+
/* @__PURE__ */ e("strong", { children: t("tokenManagement.newTokenCreated", "New token created!") }),
|
|
1246
|
+
" ",
|
|
1247
|
+
t("tokenManagement.copyItNowItWont", "Copy it now — it won't be shown again.")
|
|
1208
1248
|
] }),
|
|
1209
|
-
/* @__PURE__ */ e("code", { className: "nice-token-management__token-value", children:
|
|
1210
|
-
/* @__PURE__ */ e("button", { onClick: () =>
|
|
1249
|
+
/* @__PURE__ */ e("code", { className: "nice-token-management__token-value", children: I }),
|
|
1250
|
+
/* @__PURE__ */ e("button", { onClick: () => k(null), children: t("tokenManagement.dismiss", "Dismiss") })
|
|
1211
1251
|
] }),
|
|
1212
|
-
|
|
1213
|
-
/* @__PURE__ */
|
|
1214
|
-
"Name",
|
|
1252
|
+
S && /* @__PURE__ */ r("div", { className: "nice-token-management__create-form", children: [
|
|
1253
|
+
/* @__PURE__ */ r("label", { children: [
|
|
1254
|
+
t("tokenManagement.name", "Name"),
|
|
1215
1255
|
/* @__PURE__ */ e(
|
|
1216
1256
|
"input",
|
|
1217
1257
|
{
|
|
1218
1258
|
type: "text",
|
|
1219
|
-
value:
|
|
1220
|
-
onChange: (
|
|
1221
|
-
placeholder: "My API token",
|
|
1259
|
+
value: o,
|
|
1260
|
+
onChange: (u) => w(u.target.value),
|
|
1261
|
+
placeholder: t("tokenManagement.myApiToken", "My API token"),
|
|
1222
1262
|
maxLength: 64
|
|
1223
1263
|
}
|
|
1224
1264
|
)
|
|
1225
1265
|
] }),
|
|
1226
|
-
|
|
1227
|
-
/* @__PURE__ */ e("legend", { children: "Scopes" }),
|
|
1228
|
-
|
|
1266
|
+
c.length > 0 && /* @__PURE__ */ r("fieldset", { children: [
|
|
1267
|
+
/* @__PURE__ */ e("legend", { children: t("tokenManagement.scopes", "Scopes") }),
|
|
1268
|
+
c.map((u) => /* @__PURE__ */ r("label", { className: "nice-token-management__scope", children: [
|
|
1229
1269
|
/* @__PURE__ */ e(
|
|
1230
1270
|
"input",
|
|
1231
1271
|
{
|
|
1232
1272
|
type: "checkbox",
|
|
1233
|
-
checked:
|
|
1234
|
-
onChange: () =>
|
|
1273
|
+
checked: m.includes(u),
|
|
1274
|
+
onChange: () => A(u)
|
|
1235
1275
|
}
|
|
1236
1276
|
),
|
|
1237
|
-
|
|
1238
|
-
] },
|
|
1277
|
+
u
|
|
1278
|
+
] }, u))
|
|
1239
1279
|
] }),
|
|
1240
|
-
/* @__PURE__ */
|
|
1241
|
-
"Expires in (days)",
|
|
1280
|
+
/* @__PURE__ */ r("label", { children: [
|
|
1281
|
+
t("tokenManagement.expiresInDays", "Expires in (days)"),
|
|
1242
1282
|
/* @__PURE__ */ e(
|
|
1243
1283
|
"input",
|
|
1244
1284
|
{
|
|
1245
1285
|
type: "number",
|
|
1246
|
-
value:
|
|
1247
|
-
onChange: (
|
|
1286
|
+
value: b,
|
|
1287
|
+
onChange: (u) => N(u.target.value),
|
|
1248
1288
|
min: 1,
|
|
1249
1289
|
max: 365
|
|
1250
1290
|
}
|
|
1251
1291
|
)
|
|
1252
1292
|
] }),
|
|
1253
|
-
/* @__PURE__ */
|
|
1254
|
-
/* @__PURE__ */ e("button", { onClick:
|
|
1255
|
-
/* @__PURE__ */ e("button", { onClick: () =>
|
|
1293
|
+
/* @__PURE__ */ r("div", { className: "nice-token-management__create-actions", children: [
|
|
1294
|
+
/* @__PURE__ */ e("button", { onClick: E, disabled: T || !o.trim(), children: T ? t("tokenManagement.creating", "Creating…") : t("tokenManagement.createToken", "Create Token") }),
|
|
1295
|
+
/* @__PURE__ */ e("button", { onClick: () => y(!1), children: t("tokenManagement.cancel", "Cancel") })
|
|
1256
1296
|
] })
|
|
1257
1297
|
] }),
|
|
1258
|
-
|
|
1259
|
-
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */
|
|
1260
|
-
/* @__PURE__ */ e("th", { children: "Name" }),
|
|
1261
|
-
/* @__PURE__ */ e("th", { children: "Prefix" }),
|
|
1262
|
-
/* @__PURE__ */ e("th", { children: "Created" }),
|
|
1263
|
-
/* @__PURE__ */ e("th", { children: "Expires" }),
|
|
1264
|
-
/* @__PURE__ */ e("th", { children: "Last Used" }),
|
|
1265
|
-
/* @__PURE__ */ e("th", { children: "Scopes" }),
|
|
1298
|
+
i.length === 0 ? /* @__PURE__ */ e("p", { className: "nice-token-management__empty", children: t("tokenManagement.noApiTokensYet", "No API tokens yet.") }) : /* @__PURE__ */ r("table", { className: "nice-token-management__table", children: [
|
|
1299
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ r("tr", { children: [
|
|
1300
|
+
/* @__PURE__ */ e("th", { children: t("tokenManagement.name", "Name") }),
|
|
1301
|
+
/* @__PURE__ */ e("th", { children: t("tokenManagement.prefix", "Prefix") }),
|
|
1302
|
+
/* @__PURE__ */ e("th", { children: t("tokenManagement.created", "Created") }),
|
|
1303
|
+
/* @__PURE__ */ e("th", { children: t("tokenManagement.expires", "Expires") }),
|
|
1304
|
+
/* @__PURE__ */ e("th", { children: t("tokenManagement.lastUsed", "Last Used") }),
|
|
1305
|
+
/* @__PURE__ */ e("th", { children: t("tokenManagement.scopes", "Scopes") }),
|
|
1266
1306
|
/* @__PURE__ */ e("th", {})
|
|
1267
1307
|
] }) }),
|
|
1268
|
-
/* @__PURE__ */ e("tbody", { children:
|
|
1269
|
-
var
|
|
1270
|
-
return /* @__PURE__ */
|
|
1271
|
-
/* @__PURE__ */ e("td", { children:
|
|
1272
|
-
/* @__PURE__ */ e("td", { children: /* @__PURE__ */
|
|
1273
|
-
|
|
1308
|
+
/* @__PURE__ */ e("tbody", { children: i.map((u) => {
|
|
1309
|
+
var C;
|
|
1310
|
+
return /* @__PURE__ */ r("tr", { children: [
|
|
1311
|
+
/* @__PURE__ */ e("td", { children: u.name }),
|
|
1312
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ r("code", { children: [
|
|
1313
|
+
u.prefix,
|
|
1274
1314
|
"…"
|
|
1275
1315
|
] }) }),
|
|
1276
|
-
/* @__PURE__ */ e("td", { children:
|
|
1277
|
-
/* @__PURE__ */ e("td", { children:
|
|
1278
|
-
/* @__PURE__ */ e("td", { children:
|
|
1279
|
-
/* @__PURE__ */ e("td", { children: ((
|
|
1316
|
+
/* @__PURE__ */ e("td", { children: u.createdAt }),
|
|
1317
|
+
/* @__PURE__ */ e("td", { children: u.expiresAt ?? "—" }),
|
|
1318
|
+
/* @__PURE__ */ e("td", { children: u.lastUsedAt ?? t("tokenManagement.never", "Never") }),
|
|
1319
|
+
/* @__PURE__ */ e("td", { children: ((C = u.scopes) == null ? void 0 : C.join(", ")) || "—" }),
|
|
1280
1320
|
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e(
|
|
1281
1321
|
"button",
|
|
1282
1322
|
{
|
|
1283
1323
|
className: "nice-token-management__revoke-btn",
|
|
1284
|
-
onClick: () =>
|
|
1285
|
-
disabled:
|
|
1286
|
-
children:
|
|
1324
|
+
onClick: () => L(u.id),
|
|
1325
|
+
disabled: O === u.id,
|
|
1326
|
+
children: O === u.id ? t("tokenManagement.revoking", "Revoking…") : t("tokenManagement.revoke", "Revoke")
|
|
1287
1327
|
}
|
|
1288
1328
|
) })
|
|
1289
|
-
] },
|
|
1329
|
+
] }, u.id);
|
|
1290
1330
|
}) })
|
|
1291
1331
|
] })
|
|
1292
1332
|
] });
|
|
1293
1333
|
});
|
|
1294
1334
|
export {
|
|
1295
1335
|
Re as NiceCaptcha,
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1336
|
+
$e as NiceChangePassword,
|
|
1337
|
+
Te as NiceLoginForm,
|
|
1338
|
+
Ie as NiceOAuthButtons,
|
|
1339
|
+
Me as NicePasswordGenerator,
|
|
1340
|
+
te as NicePasswordStrength,
|
|
1341
|
+
Ae as NiceRegistrationForm,
|
|
1342
|
+
De as NiceTokenManagement,
|
|
1343
|
+
Pe as NiceTwoFaSetup,
|
|
1344
|
+
ee as calcPasswordStrength,
|
|
1345
|
+
re as generatePassword,
|
|
1346
|
+
Se as useAuth
|
|
1307
1347
|
};
|