@nice2dev/auth 1.1.6 → 1.1.9
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 +125 -0
- package/dist/NiceOAuthButtons.d.ts +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +286 -235
- package/dist/marks.d.ts +40 -0
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/NiceCaptcha.d.ts.map +0 -1
- package/dist/NiceChangePassword.d.ts.map +0 -1
- package/dist/NiceLoginForm.d.ts.map +0 -1
- package/dist/NiceOAuthButtons.d.ts.map +0 -1
- package/dist/NicePasswordStrength.d.ts.map +0 -1
- package/dist/NiceRegistrationForm.d.ts.map +0 -1
- package/dist/NiceTokenManagement.d.ts.map +0 -1
- package/dist/NiceTwoFaSetup.d.ts.map +0 -1
- package/dist/__tests__/NiceCaptcha.test.d.ts.map +0 -1
- package/dist/__tests__/NiceChangePassword.test.d.ts.map +0 -1
- package/dist/__tests__/NiceLoginForm.test.d.ts.map +0 -1
- package/dist/__tests__/NiceOAuthButtons.test.d.ts.map +0 -1
- package/dist/__tests__/NicePasswordStrength.test.d.ts.map +0 -1
- package/dist/__tests__/NiceRegistrationForm.test.d.ts.map +0 -1
- package/dist/__tests__/NiceTokenManagement.test.d.ts.map +0 -1
- package/dist/__tests__/NiceTwoFaSetup.test.d.ts.map +0 -1
- package/dist/__tests__/setup.d.ts.map +0 -1
- package/dist/__tests__/useAuth.test.d.ts.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/useAuth.d.ts.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useState as _, useCallback as w, forwardRef as
|
|
2
|
-
import { jsxs as a, jsx as e, Fragment as
|
|
3
|
-
function
|
|
4
|
-
const { onLogin: t, onRefresh:
|
|
1
|
+
import { useState as _, useCallback as w, forwardRef as B, useMemo as X, useRef as U, useImperativeHandle as ae, useEffect as W } from "react";
|
|
2
|
+
import { jsxs as a, jsx as e, Fragment as ie } from "react/jsx-runtime";
|
|
3
|
+
function ye(c = {}) {
|
|
4
|
+
const { onLogin: t, onRefresh: i, onLogout: n, storageKey: r = "nice_auth", persistAuth: l = !1 } = c, [o, p] = _(() => {
|
|
5
5
|
if (l && typeof window < "u")
|
|
6
6
|
try {
|
|
7
7
|
const h = localStorage.getItem(r);
|
|
@@ -47,15 +47,15 @@ function ve(i = {}) {
|
|
|
47
47
|
n == null || n(), d({ isAuthenticated: !1, user: null, tokens: null, loading: !1, error: null });
|
|
48
48
|
}, [n, d]), C = w(async () => {
|
|
49
49
|
var h;
|
|
50
|
-
if (!((h = o.tokens) != null && h.refreshToken) || !
|
|
50
|
+
if (!((h = o.tokens) != null && h.refreshToken) || !i)
|
|
51
51
|
return !1;
|
|
52
52
|
try {
|
|
53
|
-
const m = await
|
|
53
|
+
const m = await i(o.tokens.refreshToken);
|
|
54
54
|
return d({ tokens: m }), !0;
|
|
55
55
|
} catch {
|
|
56
56
|
return s(), !1;
|
|
57
57
|
}
|
|
58
|
-
}, [o.tokens,
|
|
58
|
+
}, [o.tokens, i, d, s]), b = w(
|
|
59
59
|
(h, m) => {
|
|
60
60
|
d({ isAuthenticated: !0, user: h, tokens: m, loading: !1, error: null });
|
|
61
61
|
},
|
|
@@ -80,11 +80,11 @@ function ve(i = {}) {
|
|
|
80
80
|
clearError: F
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
const
|
|
83
|
+
const ce = B(
|
|
84
84
|
({
|
|
85
|
-
onSubmit:
|
|
85
|
+
onSubmit: c,
|
|
86
86
|
loading: t = !1,
|
|
87
|
-
error:
|
|
87
|
+
error: i,
|
|
88
88
|
showRememberMe: n = !0,
|
|
89
89
|
showForgotPassword: r = !0,
|
|
90
90
|
onForgotPassword: l,
|
|
@@ -101,13 +101,13 @@ const ie = O(
|
|
|
101
101
|
tracelessPolicy: h,
|
|
102
102
|
privacyMessage: m
|
|
103
103
|
}, f) => {
|
|
104
|
-
const [T, N] = _(""), [P, S] = _(""), [E, k] = _(!1),
|
|
104
|
+
const [T, N] = _(""), [P, S] = _(""), [E, k] = _(!1), D = X(() => !(!n || h && !h.cookiesAllowed), [n, h]), O = w(
|
|
105
105
|
(A) => {
|
|
106
106
|
A.preventDefault();
|
|
107
|
-
const
|
|
108
|
-
|
|
107
|
+
const M = (h == null ? void 0 : h.cookiesAllowed) === !1 ? !1 : E;
|
|
108
|
+
c == null || c({ email: T, password: P, rememberMe: M });
|
|
109
109
|
},
|
|
110
|
-
[T, P, E,
|
|
110
|
+
[T, P, E, c, h]
|
|
111
111
|
);
|
|
112
112
|
return /* @__PURE__ */ a(
|
|
113
113
|
"form",
|
|
@@ -115,12 +115,12 @@ const ie = O(
|
|
|
115
115
|
ref: f,
|
|
116
116
|
className: `nice-login-form${b ? ` ${b}` : ""}`,
|
|
117
117
|
style: x,
|
|
118
|
-
onSubmit:
|
|
118
|
+
onSubmit: O,
|
|
119
119
|
noValidate: !0,
|
|
120
120
|
children: [
|
|
121
121
|
s && /* @__PURE__ */ e("div", { className: "nice-login-form__logo", children: s }),
|
|
122
122
|
/* @__PURE__ */ e("h2", { className: "nice-login-form__title", children: d }),
|
|
123
|
-
|
|
123
|
+
i && /* @__PURE__ */ e("div", { className: "nice-login-form__error", role: "alert", children: i }),
|
|
124
124
|
/* @__PURE__ */ a("div", { className: "nice-login-form__field", children: [
|
|
125
125
|
/* @__PURE__ */ e("label", { htmlFor: "nice-login-email", children: g }),
|
|
126
126
|
/* @__PURE__ */ e(
|
|
@@ -154,7 +154,7 @@ const ie = O(
|
|
|
154
154
|
)
|
|
155
155
|
] }),
|
|
156
156
|
/* @__PURE__ */ a("div", { className: "nice-login-form__options", children: [
|
|
157
|
-
|
|
157
|
+
D && /* @__PURE__ */ a("label", { className: "nice-login-form__remember", children: [
|
|
158
158
|
/* @__PURE__ */ e(
|
|
159
159
|
"input",
|
|
160
160
|
{
|
|
@@ -166,7 +166,7 @@ const ie = O(
|
|
|
166
166
|
),
|
|
167
167
|
/* @__PURE__ */ e("span", { children: "Remember me" })
|
|
168
168
|
] }),
|
|
169
|
-
!
|
|
169
|
+
!D && n && m && /* @__PURE__ */ e("span", { className: "nice-login-form__privacy-notice", children: m }),
|
|
170
170
|
r && /* @__PURE__ */ e(
|
|
171
171
|
"button",
|
|
172
172
|
{
|
|
@@ -197,7 +197,7 @@ const ie = O(
|
|
|
197
197
|
);
|
|
198
198
|
}
|
|
199
199
|
);
|
|
200
|
-
|
|
200
|
+
ce.displayName = "NiceLoginForm";
|
|
201
201
|
const re = {
|
|
202
202
|
0: "Very weak",
|
|
203
203
|
1: "Weak",
|
|
@@ -211,15 +211,15 @@ const re = {
|
|
|
211
211
|
3: "#5cb85c",
|
|
212
212
|
4: "#2e7d32"
|
|
213
213
|
};
|
|
214
|
-
function J(
|
|
215
|
-
if (!
|
|
214
|
+
function J(c) {
|
|
215
|
+
if (!c)
|
|
216
216
|
return 0;
|
|
217
217
|
let t = 0;
|
|
218
|
-
return
|
|
218
|
+
return c.length >= 8 && t++, c.length >= 12 && t++, /[a-z]/.test(c) && /[A-Z]/.test(c) && t++, /\d/.test(c) && t++, /[^a-zA-Z0-9]/.test(c) && t++, Math.min(4, t);
|
|
219
219
|
}
|
|
220
|
-
const Z =
|
|
221
|
-
({ password:
|
|
222
|
-
const o = t ?? J(
|
|
220
|
+
const Z = B(
|
|
221
|
+
({ password: c, strength: t, showLabel: i = !0, labels: n = re, className: r }, l) => {
|
|
222
|
+
const o = t ?? J(c), p = se[o], d = (o + 1) / 5 * 100;
|
|
223
223
|
return /* @__PURE__ */ a("div", { ref: l, className: `nice-password-strength${r ? ` ${r}` : ""}`, children: [
|
|
224
224
|
/* @__PURE__ */ e("div", { className: "nice-password-strength__bar", children: /* @__PURE__ */ e(
|
|
225
225
|
"div",
|
|
@@ -228,16 +228,16 @@ const Z = O(
|
|
|
228
228
|
style: { width: `${d}%`, backgroundColor: p }
|
|
229
229
|
}
|
|
230
230
|
) }),
|
|
231
|
-
|
|
231
|
+
i && /* @__PURE__ */ e("span", { className: "nice-password-strength__label", style: { color: p }, children: n[o] })
|
|
232
232
|
] });
|
|
233
233
|
}
|
|
234
234
|
);
|
|
235
235
|
Z.displayName = "NicePasswordStrength";
|
|
236
|
-
const le =
|
|
236
|
+
const le = B(
|
|
237
237
|
({
|
|
238
|
-
onSubmit:
|
|
238
|
+
onSubmit: c,
|
|
239
239
|
loading: t = !1,
|
|
240
|
-
error:
|
|
240
|
+
error: i,
|
|
241
241
|
onLoginClick: n,
|
|
242
242
|
showPasswordStrength: r = !0,
|
|
243
243
|
minPasswordStrength: l = 2,
|
|
@@ -249,11 +249,11 @@ const le = O(
|
|
|
249
249
|
className: C,
|
|
250
250
|
style: b
|
|
251
251
|
}, x) => {
|
|
252
|
-
const [g, F] = _(""), [h, m] = _(""), [f, T] = _(""), [N, P] = _(""), [S, E] = _(""), [k,
|
|
252
|
+
const [g, F] = _(""), [h, m] = _(""), [f, T] = _(""), [N, P] = _(""), [S, E] = _(""), [k, D] = _(!1), O = J(N), A = N === S, M = g && f && N && A && k && O >= l && !t, u = w(
|
|
253
253
|
(v) => {
|
|
254
|
-
v.preventDefault(),
|
|
254
|
+
v.preventDefault(), M && (c == null || c({ firstName: g, lastName: h, email: f, password: N, acceptTerms: k }));
|
|
255
255
|
},
|
|
256
|
-
[
|
|
256
|
+
[M, g, h, f, N, k, c]
|
|
257
257
|
);
|
|
258
258
|
return /* @__PURE__ */ a(
|
|
259
259
|
"form",
|
|
@@ -266,7 +266,7 @@ const le = O(
|
|
|
266
266
|
children: [
|
|
267
267
|
$ && /* @__PURE__ */ e("div", { className: "nice-register-form__logo", children: $ }),
|
|
268
268
|
/* @__PURE__ */ e("h2", { className: "nice-register-form__title", children: d }),
|
|
269
|
-
|
|
269
|
+
i && /* @__PURE__ */ e("div", { className: "nice-register-form__error", role: "alert", children: i }),
|
|
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 *" }),
|
|
@@ -356,7 +356,7 @@ const le = O(
|
|
|
356
356
|
{
|
|
357
357
|
type: "checkbox",
|
|
358
358
|
checked: k,
|
|
359
|
-
onChange: (v) =>
|
|
359
|
+
onChange: (v) => D(v.target.checked),
|
|
360
360
|
disabled: t
|
|
361
361
|
}
|
|
362
362
|
),
|
|
@@ -364,7 +364,7 @@ const le = O(
|
|
|
364
364
|
"I accept the",
|
|
365
365
|
" ",
|
|
366
366
|
o ? /* @__PURE__ */ e("a", { href: o, target: "_blank", rel: "noopener noreferrer", children: "Terms" }) : "Terms",
|
|
367
|
-
p && /* @__PURE__ */ a(
|
|
367
|
+
p && /* @__PURE__ */ a(ie, { children: [
|
|
368
368
|
" ",
|
|
369
369
|
"and",
|
|
370
370
|
" ",
|
|
@@ -378,7 +378,7 @@ const le = O(
|
|
|
378
378
|
{
|
|
379
379
|
type: "submit",
|
|
380
380
|
className: "nice-btn nice-btn--primary nice-register-form__submit",
|
|
381
|
-
disabled: !
|
|
381
|
+
disabled: !M,
|
|
382
382
|
children: t ? "…" : "Register"
|
|
383
383
|
}
|
|
384
384
|
),
|
|
@@ -393,11 +393,11 @@ const le = O(
|
|
|
393
393
|
}
|
|
394
394
|
);
|
|
395
395
|
le.displayName = "NiceRegistrationForm";
|
|
396
|
-
const oe =
|
|
396
|
+
const oe = B(
|
|
397
397
|
({
|
|
398
|
-
requireCurrentPassword:
|
|
398
|
+
requireCurrentPassword: c = !0,
|
|
399
399
|
onSubmit: t,
|
|
400
|
-
loading:
|
|
400
|
+
loading: i = !1,
|
|
401
401
|
error: n,
|
|
402
402
|
success: r,
|
|
403
403
|
minPasswordStrength: l = 2,
|
|
@@ -405,14 +405,14 @@ const oe = O(
|
|
|
405
405
|
className: p,
|
|
406
406
|
style: d
|
|
407
407
|
}, $) => {
|
|
408
|
-
const [s, C] = _(""), [b, x] = _(""), [g, F] = _(""), h = J(b), m = b === g, f = (!
|
|
408
|
+
const [s, C] = _(""), [b, x] = _(""), [g, F] = _(""), h = J(b), m = b === g, f = (!c || s.length > 0) && b.length > 0 && m && h >= l && !i, T = w(
|
|
409
409
|
(N) => {
|
|
410
410
|
N.preventDefault(), f && (t == null || t({
|
|
411
|
-
currentPassword:
|
|
411
|
+
currentPassword: c ? s : void 0,
|
|
412
412
|
newPassword: b
|
|
413
413
|
}));
|
|
414
414
|
},
|
|
415
|
-
[f, s, b,
|
|
415
|
+
[f, s, b, c, t]
|
|
416
416
|
);
|
|
417
417
|
return /* @__PURE__ */ a(
|
|
418
418
|
"form",
|
|
@@ -426,7 +426,7 @@ const oe = O(
|
|
|
426
426
|
/* @__PURE__ */ e("h3", { className: "nice-change-password__title", children: o }),
|
|
427
427
|
n && /* @__PURE__ */ e("div", { className: "nice-change-password__error", role: "alert", children: n }),
|
|
428
428
|
r && /* @__PURE__ */ e("div", { className: "nice-change-password__success", role: "status", children: r }),
|
|
429
|
-
|
|
429
|
+
c && /* @__PURE__ */ a("div", { className: "nice-change-password__field", children: [
|
|
430
430
|
/* @__PURE__ */ e("label", { htmlFor: "nice-cp-current", children: "Current password" }),
|
|
431
431
|
/* @__PURE__ */ e(
|
|
432
432
|
"input",
|
|
@@ -437,7 +437,7 @@ const oe = O(
|
|
|
437
437
|
value: s,
|
|
438
438
|
onChange: (N) => C(N.target.value),
|
|
439
439
|
autoComplete: "current-password",
|
|
440
|
-
disabled:
|
|
440
|
+
disabled: i,
|
|
441
441
|
required: !0
|
|
442
442
|
}
|
|
443
443
|
)
|
|
@@ -453,7 +453,7 @@ const oe = O(
|
|
|
453
453
|
value: b,
|
|
454
454
|
onChange: (N) => x(N.target.value),
|
|
455
455
|
autoComplete: "new-password",
|
|
456
|
-
disabled:
|
|
456
|
+
disabled: i,
|
|
457
457
|
required: !0
|
|
458
458
|
}
|
|
459
459
|
),
|
|
@@ -470,113 +470,149 @@ const oe = O(
|
|
|
470
470
|
value: g,
|
|
471
471
|
onChange: (N) => F(N.target.value),
|
|
472
472
|
autoComplete: "new-password",
|
|
473
|
-
disabled:
|
|
473
|
+
disabled: i,
|
|
474
474
|
required: !0
|
|
475
475
|
}
|
|
476
476
|
),
|
|
477
477
|
g && !m && /* @__PURE__ */ e("span", { className: "nice-error-text", children: "Passwords do not match" })
|
|
478
478
|
] }),
|
|
479
|
-
/* @__PURE__ */ e("button", { type: "submit", className: "nice-btn nice-btn--primary", disabled: !f, children:
|
|
479
|
+
/* @__PURE__ */ e("button", { type: "submit", className: "nice-btn nice-btn--primary", disabled: !f, children: i ? "…" : "Change Password" })
|
|
480
480
|
]
|
|
481
481
|
}
|
|
482
482
|
);
|
|
483
483
|
}
|
|
484
484
|
);
|
|
485
485
|
oe.displayName = "NiceChangePassword";
|
|
486
|
-
const de =
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
486
|
+
const de = B(
|
|
487
|
+
({
|
|
488
|
+
secret: c,
|
|
489
|
+
qrCodeUrl: t,
|
|
490
|
+
issuer: i,
|
|
491
|
+
accountName: n,
|
|
492
|
+
onVerify: r,
|
|
493
|
+
loading: l = !1,
|
|
494
|
+
error: o,
|
|
495
|
+
onCancel: p,
|
|
496
|
+
recoveryCodes: d,
|
|
497
|
+
step: $ = "setup",
|
|
498
|
+
onStepChange: s,
|
|
499
|
+
className: C,
|
|
500
|
+
style: b
|
|
501
|
+
}, x) => {
|
|
502
|
+
const [g, F] = _(""), [h, m] = _(!1), [f, T] = _(!1), N = w(
|
|
503
|
+
(S) => {
|
|
504
|
+
S.preventDefault(), g.length >= 6 && (r == null || r(g));
|
|
505
|
+
},
|
|
506
|
+
[g, r]
|
|
507
|
+
), P = `otpauth://totp/${i ? `${i}:` : ""}${n ?? "user"}?secret=${c}${i ? `&issuer=${i}` : ""}&digits=6&period=30`;
|
|
508
|
+
return /* @__PURE__ */ a("div", { ref: x, className: `nice-2fa-setup${C ? ` ${C}` : ""}`, style: b, children: [
|
|
509
|
+
/* @__PURE__ */ e("h3", { className: "nice-2fa-setup__title", children: "Two-Factor Authentication" }),
|
|
510
|
+
$ === "setup" && /* @__PURE__ */ a("div", { className: "nice-2fa-setup__step", children: [
|
|
511
|
+
/* @__PURE__ */ e("p", { className: "nice-2fa-setup__instruction", children: "Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.):" }),
|
|
512
|
+
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
|
+
/* @__PURE__ */ e("span", { children: "QR Code" }),
|
|
514
|
+
/* @__PURE__ */ e("code", { className: "nice-2fa-setup__uri", children: P })
|
|
515
|
+
] }),
|
|
516
|
+
/* @__PURE__ */ a("div", { className: "nice-2fa-setup__secret", children: [
|
|
517
|
+
/* @__PURE__ */ e("span", { children: "Or enter manually: " }),
|
|
518
|
+
h ? /* @__PURE__ */ e("code", { className: "nice-2fa-setup__secret-key", children: c }) : /* @__PURE__ */ e("button", { type: "button", onClick: () => m(!0), children: "Show secret key" })
|
|
519
|
+
] }),
|
|
520
|
+
/* @__PURE__ */ e(
|
|
521
|
+
"button",
|
|
522
|
+
{
|
|
523
|
+
type: "button",
|
|
524
|
+
className: "nice-btn nice-btn--primary",
|
|
525
|
+
onClick: () => s == null ? void 0 : s("verify"),
|
|
526
|
+
children: "Next — Verify"
|
|
527
|
+
}
|
|
528
|
+
)
|
|
511
529
|
] }),
|
|
512
|
-
/* @__PURE__ */ a("
|
|
513
|
-
/* @__PURE__ */ e("
|
|
514
|
-
|
|
530
|
+
$ === "verify" && /* @__PURE__ */ a("form", { className: "nice-2fa-setup__step", onSubmit: N, children: [
|
|
531
|
+
/* @__PURE__ */ e("p", { className: "nice-2fa-setup__instruction", children: "Enter the 6-digit code from your authenticator app:" }),
|
|
532
|
+
o && /* @__PURE__ */ e("div", { className: "nice-2fa-setup__error", role: "alert", children: o }),
|
|
533
|
+
/* @__PURE__ */ e(
|
|
534
|
+
"input",
|
|
535
|
+
{
|
|
536
|
+
className: "nice-input nice-2fa-setup__code-input",
|
|
537
|
+
type: "text",
|
|
538
|
+
inputMode: "numeric",
|
|
539
|
+
maxLength: 6,
|
|
540
|
+
value: g,
|
|
541
|
+
onChange: (S) => F(S.target.value.replace(/\D/g, "").slice(0, 6)),
|
|
542
|
+
placeholder: "000000",
|
|
543
|
+
autoFocus: !0,
|
|
544
|
+
disabled: l,
|
|
545
|
+
autoComplete: "one-time-code"
|
|
546
|
+
}
|
|
547
|
+
),
|
|
548
|
+
/* @__PURE__ */ a("div", { className: "nice-2fa-setup__actions", children: [
|
|
549
|
+
/* @__PURE__ */ e("button", { type: "button", className: "nice-btn", onClick: () => s == null ? void 0 : s("setup"), children: "Back" }),
|
|
550
|
+
/* @__PURE__ */ e(
|
|
551
|
+
"button",
|
|
552
|
+
{
|
|
553
|
+
type: "submit",
|
|
554
|
+
className: "nice-btn nice-btn--primary",
|
|
555
|
+
disabled: l || g.length < 6,
|
|
556
|
+
children: l ? "…" : "Verify"
|
|
557
|
+
}
|
|
558
|
+
)
|
|
559
|
+
] })
|
|
515
560
|
] }),
|
|
516
|
-
/* @__PURE__ */
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
maxLength: 6,
|
|
528
|
-
value: g,
|
|
529
|
-
onChange: (S) => F(S.target.value.replace(/\D/g, "").slice(0, 6)),
|
|
530
|
-
placeholder: "000000",
|
|
531
|
-
autoFocus: !0,
|
|
532
|
-
disabled: l,
|
|
533
|
-
autoComplete: "one-time-code"
|
|
534
|
-
}
|
|
535
|
-
),
|
|
536
|
-
/* @__PURE__ */ a("div", { className: "nice-2fa-setup__actions", children: [
|
|
537
|
-
/* @__PURE__ */ e("button", { type: "button", className: "nice-btn", onClick: () => s == null ? void 0 : s("setup"), children: "Back" }),
|
|
538
|
-
/* @__PURE__ */ e("button", { type: "submit", className: "nice-btn nice-btn--primary", disabled: l || g.length < 6, children: l ? "…" : "Verify" })
|
|
539
|
-
] })
|
|
540
|
-
] }),
|
|
541
|
-
$ === "recovery" && d && /* @__PURE__ */ a("div", { className: "nice-2fa-setup__step", children: [
|
|
542
|
-
/* @__PURE__ */ e("p", { className: "nice-2fa-setup__instruction", children: "Save these recovery codes in a safe place. Each code can only be used once:" }),
|
|
543
|
-
/* @__PURE__ */ e("div", { className: "nice-2fa-setup__recovery-codes", children: d.map((S, E) => /* @__PURE__ */ e("code", { className: "nice-2fa-setup__recovery-code", children: S }, E)) }),
|
|
544
|
-
/* @__PURE__ */ e(
|
|
545
|
-
"button",
|
|
546
|
-
{
|
|
547
|
-
type: "button",
|
|
548
|
-
className: "nice-btn",
|
|
549
|
-
onClick: () => {
|
|
550
|
-
var S;
|
|
551
|
-
(S = navigator.clipboard) == null || S.writeText(d.join(`
|
|
561
|
+
$ === "recovery" && d && /* @__PURE__ */ a("div", { className: "nice-2fa-setup__step", children: [
|
|
562
|
+
/* @__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: d.map((S, E) => /* @__PURE__ */ e("code", { className: "nice-2fa-setup__recovery-code", children: S }, E)) }),
|
|
564
|
+
/* @__PURE__ */ e(
|
|
565
|
+
"button",
|
|
566
|
+
{
|
|
567
|
+
type: "button",
|
|
568
|
+
className: "nice-btn",
|
|
569
|
+
onClick: () => {
|
|
570
|
+
var S;
|
|
571
|
+
(S = navigator.clipboard) == null || S.writeText(d.join(`
|
|
552
572
|
`)), T(!0);
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
}
|
|
573
|
+
},
|
|
574
|
+
children: f ? "Copied!" : "Copy all codes"
|
|
575
|
+
}
|
|
576
|
+
),
|
|
577
|
+
p && /* @__PURE__ */ e("button", { type: "button", className: "nice-btn nice-btn--primary", onClick: p, children: "Done" })
|
|
578
|
+
] }),
|
|
579
|
+
p && $ !== "recovery" && /* @__PURE__ */ e("button", { type: "button", className: "nice-2fa-setup__cancel", onClick: p, children: "Cancel" })
|
|
580
|
+
] });
|
|
581
|
+
}
|
|
582
|
+
);
|
|
562
583
|
de.displayName = "NiceTwoFaSetup";
|
|
563
|
-
const he =
|
|
564
|
-
|
|
565
|
-
|
|
584
|
+
const he = ({ style: c }) => /* @__PURE__ */ e(
|
|
585
|
+
"span",
|
|
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;
|
|
566
602
|
}
|
|
567
|
-
function
|
|
603
|
+
function me() {
|
|
568
604
|
return `${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;
|
|
569
605
|
}
|
|
570
|
-
function
|
|
571
|
-
switch (
|
|
606
|
+
function pe(c, t) {
|
|
607
|
+
switch (c) {
|
|
572
608
|
case "math": {
|
|
573
|
-
const
|
|
609
|
+
const i = t === "easy" ? 5 : t === "hard" ? 20 : 10, n = I(1, i), r = I(1, i), l = t !== "easy" && n >= r && Math.random() < 0.5, o = l ? n - r : n + r;
|
|
574
610
|
return { kind: "math", prompt: `${n} ${l ? "−" : "+"} ${r}`, answer: o };
|
|
575
611
|
}
|
|
576
612
|
case "text": {
|
|
577
|
-
const
|
|
613
|
+
const i = t === "easy" ? 4 : t === "hard" ? 7 : 5, n = "ABCDEFGHJKMNPQRSTUVWXYZ23456789";
|
|
578
614
|
let r = "";
|
|
579
|
-
for (let l = 0; l <
|
|
615
|
+
for (let l = 0; l < i; l++)
|
|
580
616
|
r += n[I(0, n.length - 1)];
|
|
581
617
|
return { kind: "text", text: r };
|
|
582
618
|
}
|
|
@@ -587,26 +623,26 @@ function me(i, t) {
|
|
|
587
623
|
return { kind: "checkbox" };
|
|
588
624
|
}
|
|
589
625
|
}
|
|
590
|
-
function
|
|
591
|
-
if (!
|
|
626
|
+
function fe(c, t, i) {
|
|
627
|
+
if (!c)
|
|
592
628
|
return;
|
|
593
|
-
const n =
|
|
629
|
+
const n = c.getContext("2d");
|
|
594
630
|
if (!n)
|
|
595
631
|
return;
|
|
596
|
-
const r =
|
|
597
|
-
n.clearRect(0, 0, r, l), n.fillStyle =
|
|
632
|
+
const r = c.width, l = c.height;
|
|
633
|
+
n.clearRect(0, 0, r, l), n.fillStyle = i ? "#1a1a1a" : "#f3f4f6", n.fillRect(0, 0, r, l), n.strokeStyle = i ? "rgba(255,255,255,0.18)" : "rgba(0,0,0,0.18)", n.lineWidth = 1;
|
|
598
634
|
for (let p = 0; p < 6; p++)
|
|
599
635
|
n.beginPath(), n.moveTo(I(0, r), I(0, l)), n.lineTo(I(0, r), I(0, l)), n.stroke();
|
|
600
|
-
n.fillStyle =
|
|
636
|
+
n.fillStyle = i ? "#e5e7eb" : "#111827", n.textBaseline = "middle";
|
|
601
637
|
const o = r / (t.length + 1);
|
|
602
638
|
for (let p = 0; p < t.length; p++) {
|
|
603
639
|
const d = I(22, 30);
|
|
604
640
|
n.save(), n.translate(o * (p + 1), l / 2 + I(-4, 4)), n.rotate(I(-22, 22) * Math.PI / 180), n.font = `bold ${d}px monospace`, n.fillText(t[p], -d / 3, 0), n.restore();
|
|
605
641
|
}
|
|
606
642
|
}
|
|
607
|
-
const
|
|
643
|
+
const ge = B((c, t) => {
|
|
608
644
|
const {
|
|
609
|
-
variant:
|
|
645
|
+
variant: i,
|
|
610
646
|
difficulty: n = "medium",
|
|
611
647
|
refreshable: r = !0,
|
|
612
648
|
verifyToken: l,
|
|
@@ -623,11 +659,11 @@ const fe = O((i, t) => {
|
|
|
623
659
|
customRender: h,
|
|
624
660
|
className: m,
|
|
625
661
|
style: f
|
|
626
|
-
} =
|
|
627
|
-
() =>
|
|
628
|
-
[
|
|
662
|
+
} = c, T = U(null), N = U(null), P = U(void 0), [S, E] = _(0), [k, D] = _("idle"), [O, A] = _(""), [M, u] = _(""), [v, z] = _(0), R = X(
|
|
663
|
+
() => pe(i ?? "checkbox", n),
|
|
664
|
+
[i, n, S]
|
|
629
665
|
), K = w(() => {
|
|
630
|
-
|
|
666
|
+
D("idle"), A(""), u(""), z(0), E((y) => y + 1);
|
|
631
667
|
}, []), G = w(() => {
|
|
632
668
|
K(), x == null || x();
|
|
633
669
|
}, [K, x]);
|
|
@@ -636,8 +672,8 @@ const fe = O((i, t) => {
|
|
|
636
672
|
() => ({ reset: K, refresh: G, container: T.current }),
|
|
637
673
|
[K, G]
|
|
638
674
|
), W(() => {
|
|
639
|
-
|
|
640
|
-
}, [
|
|
675
|
+
i === "text" && R.kind === "text" && fe(N.current, R.text, g === "dark");
|
|
676
|
+
}, [i, R, g]), W(() => {
|
|
641
677
|
if (k !== "verified" || !o)
|
|
642
678
|
return;
|
|
643
679
|
const y = setTimeout(() => {
|
|
@@ -645,28 +681,28 @@ const fe = O((i, t) => {
|
|
|
645
681
|
}, o);
|
|
646
682
|
return () => clearTimeout(y);
|
|
647
683
|
}, [k, o, C, K]);
|
|
648
|
-
const
|
|
649
|
-
const y = `ntd-cap:${
|
|
650
|
-
l ? (
|
|
651
|
-
Q ? (
|
|
684
|
+
const q = w(() => {
|
|
685
|
+
const y = `ntd-cap:${i}:${me()}`;
|
|
686
|
+
l ? (D("verifying"), A(""), Promise.resolve().then(() => l(y)).then((Q) => {
|
|
687
|
+
Q ? (D("verified"), s == null || s(y)) : (D("error"), A("Verification failed. Please try again."), E((ne) => ne + 1), u(""));
|
|
652
688
|
}).catch((Q) => {
|
|
653
|
-
|
|
654
|
-
})) : (
|
|
655
|
-
}, [
|
|
656
|
-
|
|
689
|
+
D("error"), A("Verification error. Please try again."), b == null || b(Q);
|
|
690
|
+
})) : (D("verified"), s == null || s(y));
|
|
691
|
+
}, [i, l, s, b]), H = w(() => {
|
|
692
|
+
D("error"), A("Incorrect, please try again."), E((y) => y + 1), u("");
|
|
657
693
|
}, []), Y = w(() => {
|
|
658
|
-
k === "verifying" || k === "verified" || (
|
|
659
|
-
}, [k,
|
|
694
|
+
k === "verifying" || k === "verified" || (D("verifying"), A(""), P.current = setTimeout(q, ue));
|
|
695
|
+
}, [k, q]);
|
|
660
696
|
W(() => () => clearTimeout(P.current), []);
|
|
661
697
|
const j = w(() => {
|
|
662
|
-
R.kind === "math" ?
|
|
663
|
-
}, [R,
|
|
698
|
+
R.kind === "math" ? M.trim() !== "" && Number(M) === R.answer ? q() : H() : R.kind === "text" && (M.trim().toUpperCase() === R.text ? q() : H());
|
|
699
|
+
}, [R, M, q, H]), ee = w(
|
|
664
700
|
(y) => {
|
|
665
|
-
z(y), !(R.kind !== "slider" || k === "verified" || k === "verifying") && Math.abs(y - R.target) <= R.tolerance &&
|
|
701
|
+
z(y), !(R.kind !== "slider" || k === "verified" || k === "verifying") && Math.abs(y - R.target) <= R.tolerance && q();
|
|
666
702
|
},
|
|
667
|
-
[R, k,
|
|
703
|
+
[R, k, q]
|
|
668
704
|
);
|
|
669
|
-
if (!
|
|
705
|
+
if (!i)
|
|
670
706
|
return d === "custom" && h ? /* @__PURE__ */ e(
|
|
671
707
|
"div",
|
|
672
708
|
{
|
|
@@ -686,7 +722,7 @@ const fe = O((i, t) => {
|
|
|
686
722
|
"data-size": F,
|
|
687
723
|
children: /* @__PURE__ */ a("div", { className: "nice-captcha__placeholder", children: [
|
|
688
724
|
/* @__PURE__ */ a("span", { children: [
|
|
689
|
-
"
|
|
725
|
+
"Captcha (",
|
|
690
726
|
d,
|
|
691
727
|
")"
|
|
692
728
|
] }),
|
|
@@ -698,7 +734,7 @@ const fe = O((i, t) => {
|
|
|
698
734
|
] })
|
|
699
735
|
}
|
|
700
736
|
);
|
|
701
|
-
const L = k === "verifying", V = k === "verified", te = `nice-captcha nice-captcha--${
|
|
737
|
+
const L = k === "verifying", V = k === "verified", te = `nice-captcha nice-captcha--${i} nice-captcha--${g} nice-captcha--${k}${F === "compact" ? " nice-captcha--compact" : ""}${m ? ` ${m}` : ""}`;
|
|
702
738
|
return /* @__PURE__ */ a(
|
|
703
739
|
"div",
|
|
704
740
|
{
|
|
@@ -707,11 +743,11 @@ const fe = O((i, t) => {
|
|
|
707
743
|
style: f,
|
|
708
744
|
role: "group",
|
|
709
745
|
"aria-label": "Captcha challenge",
|
|
710
|
-
"data-variant":
|
|
746
|
+
"data-variant": i,
|
|
711
747
|
"data-status": k,
|
|
712
748
|
"data-theme": g,
|
|
713
749
|
children: [
|
|
714
|
-
|
|
750
|
+
i === "checkbox" && /* @__PURE__ */ a(
|
|
715
751
|
"button",
|
|
716
752
|
{
|
|
717
753
|
type: "button",
|
|
@@ -722,12 +758,25 @@ const fe = O((i, t) => {
|
|
|
722
758
|
disabled: L || V,
|
|
723
759
|
onClick: Y,
|
|
724
760
|
children: [
|
|
725
|
-
/* @__PURE__ */ e("span", { className: "nice-captcha__box", "aria-hidden": "true", children: L ? "…" : V ?
|
|
761
|
+
/* @__PURE__ */ e("span", { className: "nice-captcha__box", "aria-hidden": "true", children: L ? "…" : V ? /* @__PURE__ */ e(
|
|
762
|
+
"span",
|
|
763
|
+
{
|
|
764
|
+
style: {
|
|
765
|
+
display: "inline-block",
|
|
766
|
+
width: "0.3em",
|
|
767
|
+
height: "0.6em",
|
|
768
|
+
marginBottom: "0.15em",
|
|
769
|
+
borderRight: "0.12em solid currentColor",
|
|
770
|
+
borderBottom: "0.12em solid currentColor",
|
|
771
|
+
transform: "rotate(45deg)"
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
) : "" }),
|
|
726
775
|
/* @__PURE__ */ e("span", { className: "nice-captcha__label", children: p })
|
|
727
776
|
]
|
|
728
777
|
}
|
|
729
778
|
),
|
|
730
|
-
|
|
779
|
+
i === "math" && R.kind === "math" && /* @__PURE__ */ a("div", { className: "nice-captcha__challenge", children: [
|
|
731
780
|
/* @__PURE__ */ a("span", { className: "nice-captcha__prompt", "aria-hidden": "true", children: [
|
|
732
781
|
R.prompt,
|
|
733
782
|
" ="
|
|
@@ -738,7 +787,7 @@ const fe = O((i, t) => {
|
|
|
738
787
|
className: "nice-input nice-captcha__answer",
|
|
739
788
|
type: "number",
|
|
740
789
|
inputMode: "numeric",
|
|
741
|
-
value:
|
|
790
|
+
value: M,
|
|
742
791
|
"aria-label": `What is ${R.prompt}?`,
|
|
743
792
|
disabled: L || V,
|
|
744
793
|
onChange: (y) => u(y.target.value),
|
|
@@ -752,13 +801,13 @@ const fe = O((i, t) => {
|
|
|
752
801
|
{
|
|
753
802
|
type: "button",
|
|
754
803
|
className: "nice-btn nice-btn--primary nice-captcha__verify",
|
|
755
|
-
disabled: L || V ||
|
|
804
|
+
disabled: L || V || M.trim() === "",
|
|
756
805
|
onClick: j,
|
|
757
806
|
children: L ? "…" : "Verify"
|
|
758
807
|
}
|
|
759
808
|
)
|
|
760
809
|
] }),
|
|
761
|
-
|
|
810
|
+
i === "text" && R.kind === "text" && /* @__PURE__ */ a("div", { className: "nice-captcha__challenge", children: [
|
|
762
811
|
/* @__PURE__ */ e(
|
|
763
812
|
"canvas",
|
|
764
813
|
{
|
|
@@ -776,7 +825,7 @@ const fe = O((i, t) => {
|
|
|
776
825
|
type: "text",
|
|
777
826
|
autoCapitalize: "characters",
|
|
778
827
|
autoComplete: "off",
|
|
779
|
-
value:
|
|
828
|
+
value: M,
|
|
780
829
|
"aria-label": "Type the characters shown in the image",
|
|
781
830
|
disabled: L || V,
|
|
782
831
|
onChange: (y) => u(y.target.value),
|
|
@@ -790,14 +839,14 @@ const fe = O((i, t) => {
|
|
|
790
839
|
{
|
|
791
840
|
type: "button",
|
|
792
841
|
className: "nice-btn nice-btn--primary nice-captcha__verify",
|
|
793
|
-
disabled: L || V ||
|
|
842
|
+
disabled: L || V || M.trim() === "",
|
|
794
843
|
onClick: j,
|
|
795
844
|
children: L ? "…" : "Verify"
|
|
796
845
|
}
|
|
797
846
|
)
|
|
798
847
|
] }),
|
|
799
|
-
|
|
800
|
-
/* @__PURE__ */ e("span", { className: "nice-captcha__slider-hint", "aria-hidden": "true", children: V ? "Verified
|
|
848
|
+
i === "slider" && R.kind === "slider" && /* @__PURE__ */ a("div", { className: "nice-captcha__challenge nice-captcha__challenge--slider", children: [
|
|
849
|
+
/* @__PURE__ */ e("span", { className: "nice-captcha__slider-hint", "aria-hidden": "true", children: V ? "Verified" : "Slide to the marker" }),
|
|
801
850
|
/* @__PURE__ */ a("div", { className: "nice-captcha__track", children: [
|
|
802
851
|
/* @__PURE__ */ e(
|
|
803
852
|
"span",
|
|
@@ -824,7 +873,7 @@ const fe = O((i, t) => {
|
|
|
824
873
|
] })
|
|
825
874
|
] }),
|
|
826
875
|
/* @__PURE__ */ a("div", { className: "nice-captcha__footer", children: [
|
|
827
|
-
/* @__PURE__ */ e("div", { className: "nice-captcha__message", role: "status", "aria-live": "polite", children:
|
|
876
|
+
/* @__PURE__ */ e("div", { className: "nice-captcha__message", role: "status", "aria-live": "polite", children: O }),
|
|
828
877
|
r && /* @__PURE__ */ e(
|
|
829
878
|
"button",
|
|
830
879
|
{
|
|
@@ -833,7 +882,7 @@ const fe = O((i, t) => {
|
|
|
833
882
|
"aria-label": "Refresh challenge",
|
|
834
883
|
title: "Refresh challenge",
|
|
835
884
|
onClick: G,
|
|
836
|
-
children:
|
|
885
|
+
children: /* @__PURE__ */ e(he, {})
|
|
837
886
|
}
|
|
838
887
|
)
|
|
839
888
|
] })
|
|
@@ -841,56 +890,58 @@ const fe = O((i, t) => {
|
|
|
841
890
|
}
|
|
842
891
|
);
|
|
843
892
|
});
|
|
844
|
-
|
|
845
|
-
const
|
|
846
|
-
{ id: "google", label: "Google",
|
|
847
|
-
{ id: "microsoft", label: "Microsoft",
|
|
848
|
-
{ id: "discord", label: "Discord",
|
|
849
|
-
{ id: "spotify", label: "Spotify",
|
|
850
|
-
{ id: "github", label: "GitHub",
|
|
851
|
-
],
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
/* @__PURE__ */
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
"
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
893
|
+
ge.displayName = "NiceCaptcha";
|
|
894
|
+
const _e = [
|
|
895
|
+
{ id: "google", label: "Google", color: "#4285f4", textColor: "#fff" },
|
|
896
|
+
{ id: "microsoft", label: "Microsoft", color: "#00a4ef", textColor: "#fff" },
|
|
897
|
+
{ id: "discord", label: "Discord", color: "#5865f2", textColor: "#fff" },
|
|
898
|
+
{ id: "spotify", label: "Spotify", color: "#1db954", textColor: "#fff" },
|
|
899
|
+
{ id: "github", label: "GitHub", color: "#24292e", textColor: "#fff" }
|
|
900
|
+
], be = B(
|
|
901
|
+
({
|
|
902
|
+
providers: c = _e,
|
|
903
|
+
onProviderClick: t,
|
|
904
|
+
disabled: i = !1,
|
|
905
|
+
loadingProvider: n,
|
|
906
|
+
direction: r = "vertical",
|
|
907
|
+
separatorText: l = "or continue with",
|
|
908
|
+
showSeparator: o = !0,
|
|
909
|
+
className: p,
|
|
910
|
+
style: d
|
|
911
|
+
}, $) => /* @__PURE__ */ a(
|
|
912
|
+
"div",
|
|
913
|
+
{
|
|
914
|
+
ref: $,
|
|
915
|
+
className: `nice-oauth nice-oauth--${r}${p ? ` ${p}` : ""}`,
|
|
916
|
+
style: d,
|
|
917
|
+
children: [
|
|
918
|
+
o && /* @__PURE__ */ a("div", { className: "nice-oauth__separator", children: [
|
|
919
|
+
/* @__PURE__ */ e("hr", {}),
|
|
920
|
+
/* @__PURE__ */ e("span", { children: l }),
|
|
921
|
+
/* @__PURE__ */ e("hr", {})
|
|
922
|
+
] }),
|
|
923
|
+
/* @__PURE__ */ e("div", { className: "nice-oauth__buttons", children: c.map((s) => /* @__PURE__ */ a(
|
|
924
|
+
"button",
|
|
925
|
+
{
|
|
926
|
+
type: "button",
|
|
927
|
+
className: `nice-oauth__btn${n === s.id ? " nice-oauth__btn--loading" : ""}`,
|
|
928
|
+
style: { backgroundColor: s.color, color: s.textColor },
|
|
929
|
+
onClick: () => t == null ? void 0 : t(s.id),
|
|
930
|
+
disabled: i || !!n,
|
|
931
|
+
children: [
|
|
932
|
+
s.icon && /* @__PURE__ */ e("span", { className: "nice-oauth__btn-icon", children: s.icon }),
|
|
933
|
+
/* @__PURE__ */ e("span", { className: "nice-oauth__btn-label", children: n === s.id ? "…" : s.label })
|
|
934
|
+
]
|
|
935
|
+
},
|
|
936
|
+
s.id
|
|
937
|
+
)) })
|
|
938
|
+
]
|
|
939
|
+
}
|
|
940
|
+
)
|
|
941
|
+
);
|
|
942
|
+
be.displayName = "NiceOAuthButtons";
|
|
943
|
+
const ke = B(
|
|
944
|
+
function(t, i) {
|
|
894
945
|
const {
|
|
895
946
|
tokens: n,
|
|
896
947
|
onCreate: r,
|
|
@@ -900,7 +951,7 @@ const ye = O(
|
|
|
900
951
|
title: d = "API Tokens",
|
|
901
952
|
className: $,
|
|
902
953
|
style: s
|
|
903
|
-
} = t, [C, b] = _(!1), [x, g] = _(""), [F, h] = _([]), [m, f] = _("90"), [T, N] = _(null), [P, S] = _(!1), [E, k] = _(null),
|
|
954
|
+
} = t, [C, b] = _(!1), [x, g] = _(""), [F, h] = _([]), [m, f] = _("90"), [T, N] = _(null), [P, S] = _(!1), [E, k] = _(null), D = w(async () => {
|
|
904
955
|
if (!(!r || !x.trim())) {
|
|
905
956
|
S(!0);
|
|
906
957
|
try {
|
|
@@ -910,7 +961,7 @@ const ye = O(
|
|
|
910
961
|
S(!1);
|
|
911
962
|
}
|
|
912
963
|
}
|
|
913
|
-
}, [r, x, F, m]),
|
|
964
|
+
}, [r, x, F, m]), O = w(
|
|
914
965
|
async (u) => {
|
|
915
966
|
if (l) {
|
|
916
967
|
k(u);
|
|
@@ -926,11 +977,11 @@ const ye = O(
|
|
|
926
977
|
h(
|
|
927
978
|
(v) => v.includes(u) ? v.filter((z) => z !== u) : [...v, u]
|
|
928
979
|
);
|
|
929
|
-
},
|
|
930
|
-
return /* @__PURE__ */ a("div", { ref:
|
|
980
|
+
}, M = n.length < p;
|
|
981
|
+
return /* @__PURE__ */ a("div", { ref: i, className: `nice-token-management ${$ ?? ""}`, style: s, children: [
|
|
931
982
|
/* @__PURE__ */ a("div", { className: "nice-token-management__header", children: [
|
|
932
983
|
/* @__PURE__ */ e("h3", { children: d }),
|
|
933
|
-
|
|
984
|
+
M && /* @__PURE__ */ e(
|
|
934
985
|
"button",
|
|
935
986
|
{
|
|
936
987
|
className: "nice-token-management__new-btn",
|
|
@@ -990,7 +1041,7 @@ const ye = O(
|
|
|
990
1041
|
)
|
|
991
1042
|
] }),
|
|
992
1043
|
/* @__PURE__ */ a("div", { className: "nice-token-management__create-actions", children: [
|
|
993
|
-
/* @__PURE__ */ e("button", { onClick:
|
|
1044
|
+
/* @__PURE__ */ e("button", { onClick: D, disabled: P || !x.trim(), children: P ? "Creating…" : "Create Token" }),
|
|
994
1045
|
/* @__PURE__ */ e("button", { onClick: () => b(!1), children: "Cancel" })
|
|
995
1046
|
] })
|
|
996
1047
|
] }),
|
|
@@ -1020,7 +1071,7 @@ const ye = O(
|
|
|
1020
1071
|
"button",
|
|
1021
1072
|
{
|
|
1022
1073
|
className: "nice-token-management__revoke-btn",
|
|
1023
|
-
onClick: () =>
|
|
1074
|
+
onClick: () => O(u.id),
|
|
1024
1075
|
disabled: E === u.id,
|
|
1025
1076
|
children: E === u.id ? "Revoking…" : "Revoke"
|
|
1026
1077
|
}
|
|
@@ -1032,14 +1083,14 @@ const ye = O(
|
|
|
1032
1083
|
}
|
|
1033
1084
|
);
|
|
1034
1085
|
export {
|
|
1035
|
-
|
|
1086
|
+
ge as NiceCaptcha,
|
|
1036
1087
|
oe as NiceChangePassword,
|
|
1037
|
-
|
|
1038
|
-
|
|
1088
|
+
ce as NiceLoginForm,
|
|
1089
|
+
be as NiceOAuthButtons,
|
|
1039
1090
|
Z as NicePasswordStrength,
|
|
1040
1091
|
le as NiceRegistrationForm,
|
|
1041
|
-
|
|
1092
|
+
ke as NiceTokenManagement,
|
|
1042
1093
|
de as NiceTwoFaSetup,
|
|
1043
1094
|
J as calcPasswordStrength,
|
|
1044
|
-
|
|
1095
|
+
ye as useAuth
|
|
1045
1096
|
};
|