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