@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,75 @@
|
|
|
1
1
|
# @nice2dev/auth — Changelog
|
|
2
2
|
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 3a4939d: 1.2.0 — the API cleanup announced for this version, dictionaries per language by default, and
|
|
8
|
+
three new controls. **Breaking:** every removal has a replacement, listed name by name in
|
|
9
|
+
`documentation/omniverk/OMNIVERK_UPGRADE_1.2.0.md`.
|
|
10
|
+
|
|
11
|
+
**Removed (breaking).** All 118 `@deprecated` names: the aliases without the `Nice` prefix in
|
|
12
|
+
`ui-audio`, `ui-graphics` and `ui-3d`; `NiceBarcodeGenerator` (→ `NiceBarcode`), `NiceFloorPlanCanvas`
|
|
13
|
+
(→ `NiceSpatialEditor` in `@nice2dev/ui-buildings`), the v2 props and types of `NiceTopNav`,
|
|
14
|
+
`NiceProgress.showLabel`, `NiceCountryPicker.showDialCode` / `showFlag`, `type` on
|
|
15
|
+
`NiceDateTimePicker` / `NiceDateRangeBox` (→ `dateFormatPreset`); `ZoneOccupancy` in
|
|
16
|
+
`ui-buildings` and `events`, the `SmartHome*` types; the icon variant `flat` (→ `cutout`) and
|
|
17
|
+
`NiceIconEditor` (→ `NiceVectorEditor`); `NiceSizeLegacy`; the `snapGrid` module of `ui-diagrams` (→
|
|
18
|
+
`@nice2dev/spatial-core`); the opt-in stylesheet `@nice2dev/ui/css/legacy-bg-text-aliases.css`, which
|
|
19
|
+
formed an alias cycle with `style.css`. Props that were accepted and never read — 19 on
|
|
20
|
+
`NiceModuleGrid`, and more on `NiceAutocomplete`, `NiceTaskInbox`, `NiceConsentBanner`, the
|
|
21
|
+
building and communication controls, four `ui-audio` panels and `NiceStreamDashboard` — are gone
|
|
22
|
+
from the types. `NiceResourceAllocation` in `ui-erp` is `NiceCapacityPlanner` (the one in `ui`
|
|
23
|
+
keeps its name); `NiceGenericPlayerStageVisualizer` (→ `NiceStageVisualizer`) and
|
|
24
|
+
`NiceCubeBrowserProps` are removed. The `@nice2dev/ui/overlays` entry calls its modal, drawer,
|
|
25
|
+
bottom sheet and context menu `NiceOverlayModal`, `NiceOverlayDrawer`, `NiceOverlayBottomSheet` and
|
|
26
|
+
`NiceOverlayContextMenu`: the old names belonged to different components of `@nice2dev/ui`.
|
|
27
|
+
|
|
28
|
+
**Dictionaries per language.** `NiceI18nProvider` loads only the language in use, with `import()`
|
|
29
|
+
(it was `NiceI18nLazyProvider` in 1.1.10, which stays as the same component); the controls show their
|
|
30
|
+
built-in English until it arrives — `await loadNiceDictionary(lang)` before the first render to start
|
|
31
|
+
in the language. Nothing on the main entry of `@nice2dev/i18n` imports a dictionary any more:
|
|
32
|
+
`NICE_I18N_DICTIONARIES`, `createTranslator`, `NICE_I18N_VARIANTS` / `resolvePlVariant` and the
|
|
33
|
+
translation tooling moved to the new entry `@nice2dev/i18n/all`, and `@nice2dev/ui-core` no longer
|
|
34
|
+
re-exports the dictionary map. `@nice2dev/ui` with what it bundles: 1283 kB → 952 kB gzip loaded up
|
|
35
|
+
front. The `ui-audio` controls read the app's `NiceI18nProvider` now; their own provider overrides it.
|
|
36
|
+
|
|
37
|
+
**New controls.** `NiceRecurrenceEditor`, `NiceStopwatch`, `NiceCountdownTimer` (`@nice2dev/ui`) and
|
|
38
|
+
`NicePasswordGenerator` (`@nice2dev/auth`), plus `recurrenceDates()` and `generatePassword()`.
|
|
39
|
+
`NiceScheduler` honours a weekly rule's `byDay`, which it ignored.
|
|
40
|
+
|
|
41
|
+
**Visible changes.** The palette meets WCAG AA for text on every fill: darker fills in the light
|
|
42
|
+
theme, dark text on the fills of the dark theme (new `--nice-text-on-success` / `-error` / `-info` /
|
|
43
|
+
`-accent` / `-warning`; `NiceThemeText` takes `onSuccess`, `onError`, `onInfo`, `onWarning`). Mobile
|
|
44
|
+
and platform panels follow the app theme instead of `prefers-color-scheme`. Swipes in
|
|
45
|
+
`NiceSwipeActions`, `NiceTouchTable` and `NiceMobileCalendar` work with a mouse and a pen. The
|
|
46
|
+
`ui-forms` editors have the intended spacing (it was four times too large). `NiceMAM`,
|
|
47
|
+
`NiceTranscoder`, `NiceVideoAnnotator` and `NiceStreamDashboard` use `nice-`-prefixed BEM classes.
|
|
48
|
+
|
|
49
|
+
**Fixes.** Controls that invented results ask the host instead: `NiceIntegrationHub`,
|
|
50
|
+
`NiceMLStudio` (`onExperimentRun` may return metrics), `NiceRemoteManagement`
|
|
51
|
+
(`onCaptureScreenshot`), `NicePoseDetector` (`detector`), `NiceBatchScannerProvider`,
|
|
52
|
+
`NiceCacheStrategies`; `NiceLowCodeStudio` accepts dropped components. Controls that did nothing
|
|
53
|
+
work or say why they are off: `NiceStreamDashboard` adds sources, sends chat and runs the chosen
|
|
54
|
+
transition (new `onAddPlatform`, `onSendChatMessage`, `onTransition`, `onScreenshot`,
|
|
55
|
+
`onOpenAudioMixer`, `onOpenSettings`; `receiveChatMessage` feeds incoming chat), `NiceMLStudio`
|
|
56
|
+
downloads through `onModelDownload`, `NiceETLBuilder` saves through `onSave` (its Save button had
|
|
57
|
+
no handler), `NiceTranscoder` makes jobs of picked and dropped files, `NiceAutomationEditor` offers
|
|
58
|
+
the trigger types its model has. Texts of about fifty components go
|
|
59
|
+
through `t()` in six languages, among them the AI data grid, chart and form builders, the ML
|
|
60
|
+
studio, the report designer, the song picker, `NiceProtocolConfig`, `NiceETLBuilder` and
|
|
61
|
+
`NiceInlineHelp` — every key the controls pass to `t()` now has a dictionary entry, so none of
|
|
62
|
+
them stays English under another language; `NiceDataGridAI` sorts on a query in any language, not
|
|
63
|
+
only in English. `NiceWindow`, `NiceConsole`, `NiceFileManager` and `NiceGitManager` no longer
|
|
64
|
+
crash when `accessMode` switches to or from `'hidden'`. Ids come from `createId()` (`@nice2dev/ui-core`), so nothing throws
|
|
65
|
+
outside a secure context as `crypto.randomUUID()` did on plain http. `ui-3d` runs on three r183
|
|
66
|
+
without its deprecation warnings. `NiceRemoteManagement` calls the handlers of the latest render.
|
|
67
|
+
The AI hint popover and the `ui-platform` panels follow the app theme, not the system's or a
|
|
68
|
+
`.dark` class on the host. `NiceCommandPalette` has styles and its search filters;
|
|
69
|
+
`NiceTimeoutFeedback` starts its clock; `NiceOfflineBanner` takes `online`; Monaco's workers in
|
|
70
|
+
`NiceCodeEditor` load; the `ui-audio` panels that used Bootstrap classes use Nice controls; colours
|
|
71
|
+
that reached a canvas as `var(…)` (karaoke lanes and notes) are resolved first.
|
|
72
|
+
|
|
3
73
|
## 1.1.10
|
|
4
74
|
|
|
5
75
|
### Patch Changes
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/** What {@link generatePassword} draws from. */
|
|
3
|
+
export interface NicePasswordGeneratorOptions {
|
|
4
|
+
/** Number of characters. */
|
|
5
|
+
length: number;
|
|
6
|
+
/** a–z */
|
|
7
|
+
lowercase: boolean;
|
|
8
|
+
/** A–Z */
|
|
9
|
+
uppercase: boolean;
|
|
10
|
+
/** 0–9 */
|
|
11
|
+
digits: boolean;
|
|
12
|
+
/** `!@#$%^&*()-_=+[]{};:,.?/~` */
|
|
13
|
+
symbols: boolean;
|
|
14
|
+
/** Leave out characters that are easy to misread: `0 O o 1 l I |`. */
|
|
15
|
+
excludeAmbiguous: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** Texts of {@link NicePasswordGenerator}; every one has an English default. */
|
|
18
|
+
export interface NicePasswordGeneratorLabels {
|
|
19
|
+
password?: string;
|
|
20
|
+
length?: string;
|
|
21
|
+
lowercase?: string;
|
|
22
|
+
uppercase?: string;
|
|
23
|
+
digits?: string;
|
|
24
|
+
symbols?: string;
|
|
25
|
+
excludeAmbiguous?: string;
|
|
26
|
+
generate?: string;
|
|
27
|
+
copy?: string;
|
|
28
|
+
copied?: string;
|
|
29
|
+
noCharacterSets?: string;
|
|
30
|
+
}
|
|
31
|
+
/** Props for {@link NicePasswordGenerator}. */
|
|
32
|
+
export interface NicePasswordGeneratorProps {
|
|
33
|
+
/** The generated password (controlled). */
|
|
34
|
+
value?: string;
|
|
35
|
+
/** Initial password (uncontrolled). When empty, one is generated on mount. */
|
|
36
|
+
defaultValue?: string;
|
|
37
|
+
/** Fires with every new password. */
|
|
38
|
+
onChange?: (password: string) => void;
|
|
39
|
+
/** Generation settings (controlled). Missing fields take the defaults. */
|
|
40
|
+
options?: Partial<NicePasswordGeneratorOptions>;
|
|
41
|
+
/** Initial settings (uncontrolled). Default: 16 characters, all four sets, ambiguous kept. */
|
|
42
|
+
defaultOptions?: Partial<NicePasswordGeneratorOptions>;
|
|
43
|
+
/** Fires when the user changes a setting. */
|
|
44
|
+
onOptionsChange?: (options: NicePasswordGeneratorOptions) => void;
|
|
45
|
+
/** Shortest length the slider offers. Default `8`. */
|
|
46
|
+
minLength?: number;
|
|
47
|
+
/** Longest length the slider offers. Default `64`. */
|
|
48
|
+
maxLength?: number;
|
|
49
|
+
/** Show the strength bar under the password. Default `true`. */
|
|
50
|
+
showStrength?: boolean;
|
|
51
|
+
/** Show the copy button. Default `true`. */
|
|
52
|
+
showCopy?: boolean;
|
|
53
|
+
/** Fires after the password was copied to the clipboard. */
|
|
54
|
+
onCopy?: (password: string) => void;
|
|
55
|
+
/** Overrides for the texts (e.g. from the host's translations). */
|
|
56
|
+
labels?: NicePasswordGeneratorLabels;
|
|
57
|
+
/** Disables every control. */
|
|
58
|
+
disabled?: boolean;
|
|
59
|
+
className?: string;
|
|
60
|
+
style?: React.CSSProperties;
|
|
61
|
+
id?: string;
|
|
62
|
+
}
|
|
63
|
+
/** Fills `out` with cryptographically strong random values. */
|
|
64
|
+
type RandomSource = (out: Uint32Array) => Uint32Array;
|
|
65
|
+
/**
|
|
66
|
+
* A password from `crypto.getRandomValues`, with at least one character of every chosen set
|
|
67
|
+
* (so a length shorter than the number of sets grows to fit them). Returns `''` when no set is
|
|
68
|
+
* chosen. `random` replaces the source of randomness — for tests.
|
|
69
|
+
*/
|
|
70
|
+
export declare function generatePassword(options?: Partial<NicePasswordGeneratorOptions>, random?: RandomSource): string;
|
|
71
|
+
/**
|
|
72
|
+
* {@link NicePasswordGenerator} — generates a password with `crypto.getRandomValues`: length,
|
|
73
|
+
* character sets, look-alikes left out on request, a strength bar and a copy button. A new
|
|
74
|
+
* password is drawn whenever a setting changes and on the Generate button.
|
|
75
|
+
*/
|
|
76
|
+
export declare const NicePasswordGenerator: React.FC<NicePasswordGeneratorProps>;
|
|
77
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),e=require("react/jsx-runtime");function ae(c={}){const{onLogin:s,onRefresh:n,onLogout:a,storageKey:r="nice_auth",persistAuth:l=!1}=c,[o,p]=t.useState(()=>{if(l&&typeof window<"u")try{const u=localStorage.getItem(r);if(u)return{...JSON.parse(u),loading:!1,error:null}}catch{}return{isAuthenticated:!1,user:null,tokens:null,loading:!1,error:null}}),d=t.useCallback(u=>{p(m=>{const f={...m,...u};return l&&typeof window<"u"&&(f.isAuthenticated?localStorage.setItem(r,JSON.stringify({isAuthenticated:!0,user:f.user})):localStorage.removeItem(r)),f})},[l,r]),y=t.useCallback(async(u,m)=>{d({loading:!0,error:null});try{if(s){const f=await s(u,m);return d({isAuthenticated:!0,user:f.user,tokens:f.tokens,loading:!1}),!0}return d({loading:!1,error:"No login handler configured"}),!1}catch(f){return d({loading:!1,error:(f==null?void 0:f.message)??"Login failed"}),!1}},[s,d]),i=t.useCallback(()=>{a==null||a(),d({isAuthenticated:!1,user:null,tokens:null,loading:!1,error:null})},[a,d]),k=t.useCallback(async()=>{var u;if(!((u=o.tokens)!=null&&u.refreshToken)||!n)return!1;try{const m=await n(o.tokens.refreshToken);return d({tokens:m}),!0}catch{return i(),!1}},[o.tokens,n,d,i]),g=t.useCallback((u,m)=>{d({isAuthenticated:!0,user:u,tokens:m,loading:!1,error:null})},[d]),v=t.useCallback((...u)=>o.user?u.every(m=>o.user.roles.includes(m)):!1,[o.user]),x=t.useCallback((...u)=>o.user?u.every(m=>o.user.permissions.includes(m)):!1,[o.user]),R=t.useCallback(()=>{d({error:null})},[d]);return{...o,login:y,logout:i,refreshToken:k,setAuth:g,hasRoles:v,hasPermissions:x,clearError:R}}const Q=t.forwardRef(({onSubmit:c,loading:s=!1,error:n,showRememberMe:a=!0,showForgotPassword:r=!0,onForgotPassword:l,showRegisterLink:o=!0,onRegisterClick:p,title:d="Sign In",submitLabel:y="Sign In",logo:i,footer:k,className:g,style:v,emailLabel:x="Email",passwordLabel:R="Password",tracelessPolicy:u,privacyMessage:m},f)=>{const[S,b]=t.useState(""),[F,w]=t.useState(""),[M,N]=t.useState(!1),A=t.useMemo(()=>!(!a||u&&!u.cookiesAllowed),[a,u]),I=t.useCallback(C=>{C.preventDefault();const T=(u==null?void 0:u.cookiesAllowed)===!1?!1:M;c==null||c({email:S,password:F,rememberMe:T})},[S,F,M,c,u]);return e.jsxs("form",{ref:f,className:`nice-login-form${g?` ${g}`:""}`,style:v,onSubmit:I,noValidate:!0,children:[i&&e.jsx("div",{className:"nice-login-form__logo",children:i}),e.jsx("h2",{className:"nice-login-form__title",children:d}),n&&e.jsx("div",{className:"nice-login-form__error",role:"alert",children:n}),e.jsxs("div",{className:"nice-login-form__field",children:[e.jsx("label",{htmlFor:"nice-login-email",children:x}),e.jsx("input",{id:"nice-login-email",className:"nice-input",type:"email",value:S,onChange:C=>b(C.target.value),autoComplete:"email",required:!0,disabled:s})]}),e.jsxs("div",{className:"nice-login-form__field",children:[e.jsx("label",{htmlFor:"nice-login-password",children:R}),e.jsx("input",{id:"nice-login-password",className:"nice-input",type:"password",value:F,onChange:C=>w(C.target.value),autoComplete:"current-password",required:!0,disabled:s})]}),e.jsxs("div",{className:"nice-login-form__options",children:[A&&e.jsxs("label",{className:"nice-login-form__remember",children:[e.jsx("input",{type:"checkbox",checked:M,onChange:C=>N(C.target.checked),disabled:s}),e.jsx("span",{children:"Remember me"})]}),!A&&a&&m&&e.jsx("span",{className:"nice-login-form__privacy-notice",children:m}),r&&e.jsx("button",{type:"button",className:"nice-login-form__forgot",onClick:l,disabled:s,children:"Forgot password?"})]}),e.jsx("button",{type:"submit",className:"nice-btn nice-btn--primary nice-login-form__submit",disabled:s||!S||!F,children:s?"…":y}),o&&e.jsxs("div",{className:"nice-login-form__register",children:[e.jsx("span",{children:"Don't have an account? "}),e.jsx("button",{type:"button",onClick:p,disabled:s,children:"Register"})]}),k&&e.jsx("div",{className:"nice-login-form__footer",children:k})]})});Q.displayName="NiceLoginForm";const ne={0:"Very weak",1:"Weak",2:"Fair",3:"Strong",4:"Very strong"},ce={0:"#d9534f",1:"#f0ad4e",2:"#5bc0de",3:"#5cb85c",4:"#2e7d32"};function q(c){if(!c)return 0;let s=0;return c.length>=8&&s++,c.length>=12&&s++,/[a-z]/.test(c)&&/[A-Z]/.test(c)&&s++,/\d/.test(c)&&s++,/[^a-zA-Z0-9]/.test(c)&&s++,Math.min(4,s)}const K=t.forwardRef(({password:c,strength:s,showLabel:n=!0,labels:a=ne,className:r},l)=>{const o=s??q(c),p=ce[o],d=(o+1)/5*100;return e.jsxs("div",{ref:l,className:`nice-password-strength${r?` ${r}`:""}`,children:[e.jsx("div",{className:"nice-password-strength__bar",children:e.jsx("div",{className:"nice-password-strength__fill",style:{width:`${d}%`,backgroundColor:p}})}),n&&e.jsx("span",{className:"nice-password-strength__label",style:{color:p},children:a[o]})]})});K.displayName="NicePasswordStrength";const U=t.forwardRef(({onSubmit:c,loading:s=!1,error:n,onLoginClick:a,showPasswordStrength:r=!0,minPasswordStrength:l=2,termsUrl:o,privacyUrl:p,title:d="Create Account",logo:y,footer:i,className:k,style:g},v)=>{const[x,R]=t.useState(""),[u,m]=t.useState(""),[f,S]=t.useState(""),[b,F]=t.useState(""),[w,M]=t.useState(""),[N,A]=t.useState(!1),I=q(b),C=b===w,T=x&&f&&b&&C&&N&&I>=l&&!s,h=t.useCallback(j=>{j.preventDefault(),T&&(c==null||c({firstName:x,lastName:u,email:f,password:b,acceptTerms:N}))},[T,x,u,f,b,N,c]);return e.jsxs("form",{ref:v,className:`nice-register-form${k?` ${k}`:""}`,style:g,onSubmit:h,noValidate:!0,children:[y&&e.jsx("div",{className:"nice-register-form__logo",children:y}),e.jsx("h2",{className:"nice-register-form__title",children:d}),n&&e.jsx("div",{className:"nice-register-form__error",role:"alert",children:n}),e.jsxs("div",{className:"nice-register-form__row",children:[e.jsxs("div",{className:"nice-register-form__field",children:[e.jsx("label",{htmlFor:"nice-reg-first",children:"First name *"}),e.jsx("input",{id:"nice-reg-first",className:"nice-input",type:"text",value:x,onChange:j=>R(j.target.value),required:!0,disabled:s,autoComplete:"given-name"})]}),e.jsxs("div",{className:"nice-register-form__field",children:[e.jsx("label",{htmlFor:"nice-reg-last",children:"Last name"}),e.jsx("input",{id:"nice-reg-last",className:"nice-input",type:"text",value:u,onChange:j=>m(j.target.value),disabled:s,autoComplete:"family-name"})]})]}),e.jsxs("div",{className:"nice-register-form__field",children:[e.jsx("label",{htmlFor:"nice-reg-email",children:"Email *"}),e.jsx("input",{id:"nice-reg-email",className:"nice-input",type:"email",value:f,onChange:j=>S(j.target.value),required:!0,disabled:s,autoComplete:"email"})]}),e.jsxs("div",{className:"nice-register-form__field",children:[e.jsx("label",{htmlFor:"nice-reg-pass",children:"Password *"}),e.jsx("input",{id:"nice-reg-pass",className:"nice-input",type:"password",value:b,onChange:j=>F(j.target.value),required:!0,disabled:s,autoComplete:"new-password"}),r&&b.length>0&&e.jsx(K,{password:b})]}),e.jsxs("div",{className:"nice-register-form__field",children:[e.jsx("label",{htmlFor:"nice-reg-confirm",children:"Confirm password *"}),e.jsx("input",{id:"nice-reg-confirm",className:"nice-input",type:"password",value:w,onChange:j=>M(j.target.value),required:!0,disabled:s,autoComplete:"new-password"}),w&&!C&&e.jsx("span",{className:"nice-error-text",children:"Passwords do not match"})]}),e.jsxs("label",{className:"nice-register-form__terms",children:[e.jsx("input",{type:"checkbox",checked:N,onChange:j=>A(j.target.checked),disabled:s}),e.jsxs("span",{children:["I accept the"," ",o?e.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:"Terms"}):"Terms",p&&e.jsxs(e.Fragment,{children:[" ","and"," ",e.jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer",children:"Privacy Policy"})]})," *"]})]}),e.jsx("button",{type:"submit",className:"nice-btn nice-btn--primary nice-register-form__submit",disabled:!T,children:s?"…":"Register"}),a&&e.jsxs("div",{className:"nice-register-form__login",children:[e.jsx("span",{children:"Already have an account? "}),e.jsx("button",{type:"button",onClick:a,children:"Sign in"})]}),i&&e.jsx("div",{className:"nice-register-form__footer",children:i})]})});U.displayName="NiceRegistrationForm";const W=t.forwardRef(({requireCurrentPassword:c=!0,onSubmit:s,loading:n=!1,error:a,success:r,minPasswordStrength:l=2,title:o="Change Password",className:p,style:d},y)=>{const[i,k]=t.useState(""),[g,v]=t.useState(""),[x,R]=t.useState(""),u=q(g),m=g===x,f=(!c||i.length>0)&&g.length>0&&m&&u>=l&&!n,S=t.useCallback(b=>{b.preventDefault(),f&&(s==null||s({currentPassword:c?i:void 0,newPassword:g}))},[f,i,g,c,s]);return e.jsxs("form",{ref:y,className:`nice-change-password${p?` ${p}`:""}`,style:d,onSubmit:S,noValidate:!0,children:[e.jsx("h3",{className:"nice-change-password__title",children:o}),a&&e.jsx("div",{className:"nice-change-password__error",role:"alert",children:a}),r&&e.jsx("div",{className:"nice-change-password__success",role:"status",children:r}),c&&e.jsxs("div",{className:"nice-change-password__field",children:[e.jsx("label",{htmlFor:"nice-cp-current",children:"Current password"}),e.jsx("input",{id:"nice-cp-current",className:"nice-input",type:"password",value:i,onChange:b=>k(b.target.value),autoComplete:"current-password",disabled:n,required:!0})]}),e.jsxs("div",{className:"nice-change-password__field",children:[e.jsx("label",{htmlFor:"nice-cp-new",children:"New password"}),e.jsx("input",{id:"nice-cp-new",className:"nice-input",type:"password",value:g,onChange:b=>v(b.target.value),autoComplete:"new-password",disabled:n,required:!0}),g.length>0&&e.jsx(K,{password:g})]}),e.jsxs("div",{className:"nice-change-password__field",children:[e.jsx("label",{htmlFor:"nice-cp-confirm",children:"Confirm new password"}),e.jsx("input",{id:"nice-cp-confirm",className:"nice-input",type:"password",value:x,onChange:b=>R(b.target.value),autoComplete:"new-password",disabled:n,required:!0}),x&&!m&&e.jsx("span",{className:"nice-error-text",children:"Passwords do not match"})]}),e.jsx("button",{type:"submit",className:"nice-btn nice-btn--primary",disabled:!f,children:n?"…":"Change Password"})]})});W.displayName="NiceChangePassword";const J=t.forwardRef(({secret:c,qrCodeUrl:s,issuer:n,accountName:a,onVerify:r,loading:l=!1,error:o,onCancel:p,recoveryCodes:d,step:y="setup",onStepChange:i,className:k,style:g},v)=>{const[x,R]=t.useState(""),[u,m]=t.useState(!1),[f,S]=t.useState(!1),b=t.useCallback(w=>{w.preventDefault(),x.length>=6&&(r==null||r(x))},[x,r]),F=`otpauth://totp/${n?`${n}:`:""}${a??"user"}?secret=${c}${n?`&issuer=${n}`:""}&digits=6&period=30`;return e.jsxs("div",{ref:v,className:`nice-2fa-setup${k?` ${k}`:""}`,style:g,children:[e.jsx("h3",{className:"nice-2fa-setup__title",children:"Two-Factor Authentication"}),y==="setup"&&e.jsxs("div",{className:"nice-2fa-setup__step",children:[e.jsx("p",{className:"nice-2fa-setup__instruction",children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.):"}),s?e.jsx("img",{src:s,alt:"2FA QR Code",className:"nice-2fa-setup__qr"}):e.jsxs("div",{className:"nice-2fa-setup__qr-placeholder",children:[e.jsx("span",{children:"QR Code"}),e.jsx("code",{className:"nice-2fa-setup__uri",children:F})]}),e.jsxs("div",{className:"nice-2fa-setup__secret",children:[e.jsx("span",{children:"Or enter manually: "}),u?e.jsx("code",{className:"nice-2fa-setup__secret-key",children:c}):e.jsx("button",{type:"button",onClick:()=>m(!0),children:"Show secret key"})]}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--primary",onClick:()=>i==null?void 0:i("verify"),children:"Next — Verify"})]}),y==="verify"&&e.jsxs("form",{className:"nice-2fa-setup__step",onSubmit:b,children:[e.jsx("p",{className:"nice-2fa-setup__instruction",children:"Enter the 6-digit code from your authenticator app:"}),o&&e.jsx("div",{className:"nice-2fa-setup__error",role:"alert",children:o}),e.jsx("input",{className:"nice-input nice-2fa-setup__code-input",type:"text",inputMode:"numeric",maxLength:6,value:x,onChange:w=>R(w.target.value.replace(/\D/g,"").slice(0,6)),placeholder:"000000",autoFocus:!0,disabled:l,autoComplete:"one-time-code"}),e.jsxs("div",{className:"nice-2fa-setup__actions",children:[e.jsx("button",{type:"button",className:"nice-btn",onClick:()=>i==null?void 0:i("setup"),children:"Back"}),e.jsx("button",{type:"submit",className:"nice-btn nice-btn--primary",disabled:l||x.length<6,children:l?"…":"Verify"})]})]}),y==="recovery"&&d&&e.jsxs("div",{className:"nice-2fa-setup__step",children:[e.jsx("p",{className:"nice-2fa-setup__instruction",children:"Save these recovery codes in a safe place. Each code can only be used once:"}),e.jsx("div",{className:"nice-2fa-setup__recovery-codes",children:d.map((w,M)=>e.jsx("code",{className:"nice-2fa-setup__recovery-code",children:w},M))}),e.jsx("button",{type:"button",className:"nice-btn",onClick:()=>{var w;(w=navigator.clipboard)==null||w.writeText(d.join(`
|
|
2
|
-
`)),S(!0)},children:f?"Copied!":"Copy all codes"}),p&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--primary",onClick:p,children:"Done"})]}),p&&y!=="recovery"&&e.jsx("button",{type:"button",className:"nice-2fa-setup__cancel",onClick:p,children:"Cancel"})]})});J.displayName="NiceTwoFaSetup";const re=({style:c})=>e.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:"0.85em",height:"0.85em",borderRadius:"50%",border:"0.12em solid currentColor",borderTopColor:"transparent",transform:"rotate(-45deg)",...c}}),ie=500;function P(c,s){return Math.floor(Math.random()*(s-c+1))+c}function le(){return`${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`}function oe(c,s){switch(c){case"math":{const n=s==="easy"?5:s==="hard"?20:10,a=P(1,n),r=P(1,n),l=s!=="easy"&&a>=r&&Math.random()<.5,o=l?a-r:a+r;return{kind:"math",prompt:`${a} ${l?"−":"+"} ${r}`,answer:o}}case"text":{const n=s==="easy"?4:s==="hard"?7:5,a="ABCDEFGHJKMNPQRSTUVWXYZ23456789";let r="";for(let l=0;l<n;l++)r+=a[P(0,a.length-1)];return{kind:"text",text:r}}case"slider":return{kind:"slider",target:P(70,92),tolerance:s==="easy"?8:s==="hard"?2:4};case"checkbox":default:return{kind:"checkbox"}}}function de(c,s,n){if(!c)return;const a=c.getContext("2d");if(!a)return;const r=c.width,l=c.height;a.clearRect(0,0,r,l),a.fillStyle=n?"#1a1a1a":"#f3f4f6",a.fillRect(0,0,r,l),a.strokeStyle=n?"rgba(255,255,255,0.18)":"rgba(0,0,0,0.18)",a.lineWidth=1;for(let p=0;p<6;p++)a.beginPath(),a.moveTo(P(0,r),P(0,l)),a.lineTo(P(0,r),P(0,l)),a.stroke();a.fillStyle=n?"#e5e7eb":"#111827",a.textBaseline="middle";const o=r/(s.length+1);for(let p=0;p<s.length;p++){const d=P(22,30);a.save(),a.translate(o*(p+1),l/2+P(-4,4)),a.rotate(P(-22,22)*Math.PI/180),a.font=`bold ${d}px monospace`,a.fillText(s[p],-d/3,0),a.restore()}}const Z=t.forwardRef((c,s)=>{const{variant:n,difficulty:a="medium",refreshable:r=!0,verifyToken:l,expiresMs:o,label:p="I'm not a robot",provider:d="custom",siteKey:y,onVerify:i,onExpire:k,onError:g,onRefresh:v,theme:x="light",size:R="normal",customRender:u,className:m,style:f}=c,S=t.useRef(null),b=t.useRef(null),F=t.useRef(void 0),[w,M]=t.useState(0),[N,A]=t.useState("idle"),[I,C]=t.useState(""),[T,h]=t.useState(""),[j,V]=t.useState(0),$=t.useMemo(()=>oe(n??"checkbox",a),[n,a,w]),O=t.useCallback(()=>{A("idle"),C(""),h(""),V(0),M(_=>_+1)},[]),z=t.useCallback(()=>{O(),v==null||v()},[O,v]);t.useImperativeHandle(s,()=>({reset:O,refresh:z,container:S.current}),[O,z]),t.useEffect(()=>{n==="text"&&$.kind==="text"&&de(b.current,$.text,x==="dark")},[n,$,x]),t.useEffect(()=>{if(N!=="verified"||!o)return;const _=setTimeout(()=>{k==null||k(),O()},o);return()=>clearTimeout(_)},[N,o,k,O]);const L=t.useCallback(()=>{const _=`ntd-cap:${n}:${le()}`;l?(A("verifying"),C(""),Promise.resolve().then(()=>l(_)).then(H=>{H?(A("verified"),i==null||i(_)):(A("error"),C("Verification failed. Please try again."),M(se=>se+1),h(""))}).catch(H=>{A("error"),C("Verification error. Please try again."),g==null||g(H)})):(A("verified"),i==null||i(_))},[n,l,i,g]),G=t.useCallback(()=>{A("error"),C("Incorrect, please try again."),M(_=>_+1),h("")},[]),Y=t.useCallback(()=>{N==="verifying"||N==="verified"||(A("verifying"),C(""),F.current=setTimeout(L,ie))},[N,L]);t.useEffect(()=>()=>clearTimeout(F.current),[]);const B=t.useCallback(()=>{$.kind==="math"?T.trim()!==""&&Number(T)===$.answer?L():G():$.kind==="text"&&(T.trim().toUpperCase()===$.text?L():G())},[$,T,L,G]),ee=t.useCallback(_=>{V(_),!($.kind!=="slider"||N==="verified"||N==="verifying")&&Math.abs(_-$.target)<=$.tolerance&&L()},[$,N,L]);if(!n)return d==="custom"&&u?e.jsx("div",{ref:S,className:`nice-captcha nice-captcha--custom${m?` ${m}`:""}`,style:f,children:u}):e.jsx("div",{ref:S,className:`nice-captcha nice-captcha--${d} nice-captcha--${x}${R==="compact"?" nice-captcha--compact":""}${m?` ${m}`:""}`,style:f,"data-sitekey":y,"data-theme":x,"data-size":R,children:e.jsxs("div",{className:"nice-captcha__placeholder",children:[e.jsxs("span",{children:["Captcha (",d,")"]}),e.jsxs("p",{children:["Load the ",d," SDK to activate verification."]})]})});const D=N==="verifying",E=N==="verified",te=`nice-captcha nice-captcha--${n} nice-captcha--${x} nice-captcha--${N}${R==="compact"?" nice-captcha--compact":""}${m?` ${m}`:""}`;return e.jsxs("div",{ref:S,className:te,style:f,role:"group","aria-label":"Captcha challenge","data-variant":n,"data-status":N,"data-theme":x,children:[n==="checkbox"&&e.jsxs("button",{type:"button",className:"nice-captcha__checkbox",role:"checkbox","aria-checked":E,"aria-busy":D,disabled:D||E,onClick:Y,children:[e.jsx("span",{className:"nice-captcha__box","aria-hidden":"true",children:D?"…":E?e.jsx("span",{style:{display:"inline-block",width:"0.3em",height:"0.6em",marginBottom:"0.15em",borderRight:"0.12em solid currentColor",borderBottom:"0.12em solid currentColor",transform:"rotate(45deg)"}}):""}),e.jsx("span",{className:"nice-captcha__label",children:p})]}),n==="math"&&$.kind==="math"&&e.jsxs("div",{className:"nice-captcha__challenge",children:[e.jsxs("span",{className:"nice-captcha__prompt","aria-hidden":"true",children:[$.prompt," ="]}),e.jsx("input",{className:"nice-input nice-captcha__answer",type:"number",inputMode:"numeric",value:T,"aria-label":`What is ${$.prompt}?`,disabled:D||E,onChange:_=>h(_.target.value),onKeyDown:_=>{_.key==="Enter"&&(_.preventDefault(),B())}}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--primary nice-captcha__verify",disabled:D||E||T.trim()==="",onClick:B,children:D?"…":"Verify"})]}),n==="text"&&$.kind==="text"&&e.jsxs("div",{className:"nice-captcha__challenge",children:[e.jsx("canvas",{ref:b,className:"nice-captcha__canvas",width:160,height:56,"aria-hidden":"true"}),e.jsx("input",{className:"nice-input nice-captcha__answer",type:"text",autoCapitalize:"characters",autoComplete:"off",value:T,"aria-label":"Type the characters shown in the image",disabled:D||E,onChange:_=>h(_.target.value),onKeyDown:_=>{_.key==="Enter"&&(_.preventDefault(),B())}}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--primary nice-captcha__verify",disabled:D||E||T.trim()==="",onClick:B,children:D?"…":"Verify"})]}),n==="slider"&&$.kind==="slider"&&e.jsxs("div",{className:"nice-captcha__challenge nice-captcha__challenge--slider",children:[e.jsx("span",{className:"nice-captcha__slider-hint","aria-hidden":"true",children:E?"Verified":"Slide to the marker"}),e.jsxs("div",{className:"nice-captcha__track",children:[e.jsx("span",{className:"nice-captcha__target","aria-hidden":"true",style:{left:`${$.target}%`}}),e.jsx("input",{className:"nice-captcha__slider",type:"range",min:0,max:100,value:j,"aria-label":"Slide the handle to the marker to verify","aria-valuetext":`${j}%`,disabled:E||D,onChange:_=>ee(Number(_.target.value))})]})]}),e.jsxs("div",{className:"nice-captcha__footer",children:[e.jsx("div",{className:"nice-captcha__message",role:"status","aria-live":"polite",children:I}),r&&e.jsx("button",{type:"button",className:"nice-captcha__refresh","aria-label":"Refresh challenge",title:"Refresh challenge",onClick:z,children:e.jsx(re,{})})]})]})});Z.displayName="NiceCaptcha";const ue=[{id:"google",label:"Google",color:"#4285f4",textColor:"#fff"},{id:"microsoft",label:"Microsoft",color:"#00a4ef",textColor:"#fff"},{id:"discord",label:"Discord",color:"#5865f2",textColor:"#fff"},{id:"spotify",label:"Spotify",color:"#1db954",textColor:"#fff"},{id:"github",label:"GitHub",color:"#24292e",textColor:"#fff"}],X=t.forwardRef(({providers:c=ue,onProviderClick:s,disabled:n=!1,loadingProvider:a,direction:r="vertical",separatorText:l="or continue with",showSeparator:o=!0,className:p,style:d},y)=>e.jsxs("div",{ref:y,className:`nice-oauth nice-oauth--${r}${p?` ${p}`:""}`,style:d,children:[o&&e.jsxs("div",{className:"nice-oauth__separator",children:[e.jsx("hr",{}),e.jsx("span",{children:l}),e.jsx("hr",{})]}),e.jsx("div",{className:"nice-oauth__buttons",children:c.map(i=>e.jsxs("button",{type:"button",className:`nice-oauth__btn${a===i.id?" nice-oauth__btn--loading":""}`,style:{backgroundColor:i.color,color:i.textColor},onClick:()=>s==null?void 0:s(i.id),disabled:n||!!a,children:[i.icon&&e.jsx("span",{className:"nice-oauth__btn-icon",children:i.icon}),e.jsx("span",{className:"nice-oauth__btn-label",children:a===i.id?"…":i.label})]},i.id))})]}));X.displayName="NiceOAuthButtons";const he=t.forwardRef(function(s,n){const{tokens:a,onCreate:r,onRevoke:l,availableScopes:o=[],maxTokens:p=10,title:d="API Tokens",className:y,style:i}=s,[k,g]=t.useState(!1),[v,x]=t.useState(""),[R,u]=t.useState([]),[m,f]=t.useState("90"),[S,b]=t.useState(null),[F,w]=t.useState(!1),[M,N]=t.useState(null),A=t.useCallback(async()=>{if(!(!r||!v.trim())){w(!0);try{const h=m?parseInt(m,10):void 0,j=await r(v.trim(),R,h);b(j),x(""),u([]),g(!1)}finally{w(!1)}}},[r,v,R,m]),I=t.useCallback(async h=>{if(l){N(h);try{await l(h)}finally{N(null)}}},[l]),C=h=>{u(j=>j.includes(h)?j.filter(V=>V!==h):[...j,h])},T=a.length<p;return e.jsxs("div",{ref:n,className:`nice-token-management ${y??""}`,style:i,children:[e.jsxs("div",{className:"nice-token-management__header",children:[e.jsx("h3",{children:d}),T&&e.jsx("button",{className:"nice-token-management__new-btn",onClick:()=>g(!0),disabled:k,children:"+ New Token"})]}),S&&e.jsxs("div",{className:"nice-token-management__reveal",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"New token created!"})," Copy it now — it won't be shown again."]}),e.jsx("code",{className:"nice-token-management__token-value",children:S}),e.jsx("button",{onClick:()=>b(null),children:"Dismiss"})]}),k&&e.jsxs("div",{className:"nice-token-management__create-form",children:[e.jsxs("label",{children:["Name",e.jsx("input",{type:"text",value:v,onChange:h=>x(h.target.value),placeholder:"My API token",maxLength:64})]}),o.length>0&&e.jsxs("fieldset",{children:[e.jsx("legend",{children:"Scopes"}),o.map(h=>e.jsxs("label",{className:"nice-token-management__scope",children:[e.jsx("input",{type:"checkbox",checked:R.includes(h),onChange:()=>C(h)}),h]},h))]}),e.jsxs("label",{children:["Expires in (days)",e.jsx("input",{type:"number",value:m,onChange:h=>f(h.target.value),min:1,max:365})]}),e.jsxs("div",{className:"nice-token-management__create-actions",children:[e.jsx("button",{onClick:A,disabled:F||!v.trim(),children:F?"Creating…":"Create Token"}),e.jsx("button",{onClick:()=>g(!1),children:"Cancel"})]})]}),a.length===0?e.jsx("p",{className:"nice-token-management__empty",children:"No API tokens yet."}):e.jsxs("table",{className:"nice-token-management__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),e.jsx("th",{children:"Prefix"}),e.jsx("th",{children:"Created"}),e.jsx("th",{children:"Expires"}),e.jsx("th",{children:"Last Used"}),e.jsx("th",{children:"Scopes"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:a.map(h=>{var j;return e.jsxs("tr",{children:[e.jsx("td",{children:h.name}),e.jsx("td",{children:e.jsxs("code",{children:[h.prefix,"…"]})}),e.jsx("td",{children:h.createdAt}),e.jsx("td",{children:h.expiresAt??"—"}),e.jsx("td",{children:h.lastUsedAt??"Never"}),e.jsx("td",{children:((j=h.scopes)==null?void 0:j.join(", "))||"—"}),e.jsx("td",{children:e.jsx("button",{className:"nice-token-management__revoke-btn",onClick:()=>I(h.id),disabled:M===h.id,children:M===h.id?"Revoking…":"Revoke"})})]},h.id)})})]})]})});exports.NiceCaptcha=Z;exports.NiceChangePassword=W;exports.NiceLoginForm=Q;exports.NiceOAuthButtons=X;exports.NicePasswordStrength=K;exports.NiceRegistrationForm=U;exports.NiceTokenManagement=he;exports.NiceTwoFaSetup=J;exports.calcPasswordStrength=q;exports.useAuth=ae;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),e=require("react/jsx-runtime");function le(n={}){const{onLogin:s,onRefresh:r,onLogout:a,storageKey:i="nice_auth",persistAuth:u=!1}=n,[l,c]=t.useState(()=>{if(u&&typeof window<"u")try{const o=localStorage.getItem(i);if(o)return{...JSON.parse(o),loading:!1,error:null}}catch{}return{isAuthenticated:!1,user:null,tokens:null,loading:!1,error:null}}),h=t.useCallback(o=>{c(p=>{const f={...p,...o};return u&&typeof window<"u"&&(f.isAuthenticated?localStorage.setItem(i,JSON.stringify({isAuthenticated:!0,user:f.user})):localStorage.removeItem(i)),f})},[u,i]),C=t.useCallback(async(o,p)=>{h({loading:!0,error:null});try{if(s){const f=await s(o,p);return h({isAuthenticated:!0,user:f.user,tokens:f.tokens,loading:!1}),!0}return h({loading:!1,error:"No login handler configured"}),!1}catch(f){return h({loading:!1,error:(f==null?void 0:f.message)??"Login failed"}),!1}},[s,h]),d=t.useCallback(()=>{a==null||a(),h({isAuthenticated:!1,user:null,tokens:null,loading:!1,error:null})},[a,h]),y=t.useCallback(async()=>{var o;if(!((o=l.tokens)!=null&&o.refreshToken)||!r)return!1;try{const p=await r(l.tokens.refreshToken);return h({tokens:p}),!0}catch{return d(),!1}},[l.tokens,r,h,d]),g=t.useCallback((o,p)=>{h({isAuthenticated:!0,user:o,tokens:p,loading:!1,error:null})},[h]),w=t.useCallback((...o)=>l.user?o.every(p=>l.user.roles.includes(p)):!1,[l.user]),x=t.useCallback((...o)=>l.user?o.every(p=>l.user.permissions.includes(p)):!1,[l.user]),A=t.useCallback(()=>{h({error:null})},[h]);return{...l,login:C,logout:d,refreshToken:y,setAuth:g,hasRoles:w,hasPermissions:x,clearError:A}}const J=t.forwardRef(({onSubmit:n,loading:s=!1,error:r,showRememberMe:a=!0,showForgotPassword:i=!0,onForgotPassword:u,showRegisterLink:l=!0,onRegisterClick:c,title:h="Sign In",submitLabel:C="Sign In",logo:d,footer:y,className:g,style:w,emailLabel:x="Email",passwordLabel:A="Password",tracelessPolicy:o,privacyMessage:p},f)=>{const[R,_]=t.useState(""),[v,S]=t.useState(""),[P,b]=t.useState(!1),F=t.useMemo(()=>!(!a||o&&!o.cookiesAllowed),[a,o]),E=t.useCallback(k=>{k.preventDefault();const T=(o==null?void 0:o.cookiesAllowed)===!1?!1:P;n==null||n({email:R,password:v,rememberMe:T})},[R,v,P,n,o]);return e.jsxs("form",{ref:f,className:`nice-login-form${g?` ${g}`:""}`,style:w,onSubmit:E,noValidate:!0,children:[d&&e.jsx("div",{className:"nice-login-form__logo",children:d}),e.jsx("h2",{className:"nice-login-form__title",children:h}),r&&e.jsx("div",{className:"nice-login-form__error",role:"alert",children:r}),e.jsxs("div",{className:"nice-login-form__field",children:[e.jsx("label",{htmlFor:"nice-login-email",children:x}),e.jsx("input",{id:"nice-login-email",className:"nice-input",type:"email",value:R,onChange:k=>_(k.target.value),autoComplete:"email",required:!0,disabled:s})]}),e.jsxs("div",{className:"nice-login-form__field",children:[e.jsx("label",{htmlFor:"nice-login-password",children:A}),e.jsx("input",{id:"nice-login-password",className:"nice-input",type:"password",value:v,onChange:k=>S(k.target.value),autoComplete:"current-password",required:!0,disabled:s})]}),e.jsxs("div",{className:"nice-login-form__options",children:[F&&e.jsxs("label",{className:"nice-login-form__remember",children:[e.jsx("input",{type:"checkbox",checked:P,onChange:k=>b(k.target.checked),disabled:s}),e.jsx("span",{children:"Remember me"})]}),!F&&a&&p&&e.jsx("span",{className:"nice-login-form__privacy-notice",children:p}),i&&e.jsx("button",{type:"button",className:"nice-login-form__forgot",onClick:u,disabled:s,children:"Forgot password?"})]}),e.jsx("button",{type:"submit",className:"nice-btn nice-btn--primary nice-login-form__submit",disabled:s||!R||!v,children:s?"…":C}),l&&e.jsxs("div",{className:"nice-login-form__register",children:[e.jsx("span",{children:"Don't have an account? "}),e.jsx("button",{type:"button",onClick:c,disabled:s,children:"Register"})]}),y&&e.jsx("div",{className:"nice-login-form__footer",children:y})]})});J.displayName="NiceLoginForm";const oe={0:"Very weak",1:"Weak",2:"Fair",3:"Strong",4:"Very strong"},de={0:"#d9534f",1:"#f0ad4e",2:"#5bc0de",3:"#5cb85c",4:"#2e7d32"};function K(n){if(!n)return 0;let s=0;return n.length>=8&&s++,n.length>=12&&s++,/[a-z]/.test(n)&&/[A-Z]/.test(n)&&s++,/\d/.test(n)&&s++,/[^a-zA-Z0-9]/.test(n)&&s++,Math.min(4,s)}const q=t.forwardRef(({password:n,strength:s,showLabel:r=!0,labels:a=oe,className:i},u)=>{const l=s??K(n),c=de[l],h=(l+1)/5*100;return e.jsxs("div",{ref:u,className:`nice-password-strength${i?` ${i}`:""}`,children:[e.jsx("div",{className:"nice-password-strength__bar",children:e.jsx("div",{className:"nice-password-strength__fill",style:{width:`${h}%`,backgroundColor:c}})}),r&&e.jsx("span",{className:"nice-password-strength__label",style:{color:c},children:a[l]})]})});q.displayName="NicePasswordStrength";const X=t.forwardRef(({onSubmit:n,loading:s=!1,error:r,onLoginClick:a,showPasswordStrength:i=!0,minPasswordStrength:u=2,termsUrl:l,privacyUrl:c,title:h="Create Account",logo:C,footer:d,className:y,style:g},w)=>{const[x,A]=t.useState(""),[o,p]=t.useState(""),[f,R]=t.useState(""),[_,v]=t.useState(""),[S,P]=t.useState(""),[b,F]=t.useState(!1),E=K(_),k=_===S,T=x&&f&&_&&k&&b&&E>=u&&!s,m=t.useCallback(j=>{j.preventDefault(),T&&(n==null||n({firstName:x,lastName:o,email:f,password:_,acceptTerms:b}))},[T,x,o,f,_,b,n]);return e.jsxs("form",{ref:w,className:`nice-register-form${y?` ${y}`:""}`,style:g,onSubmit:m,noValidate:!0,children:[C&&e.jsx("div",{className:"nice-register-form__logo",children:C}),e.jsx("h2",{className:"nice-register-form__title",children:h}),r&&e.jsx("div",{className:"nice-register-form__error",role:"alert",children:r}),e.jsxs("div",{className:"nice-register-form__row",children:[e.jsxs("div",{className:"nice-register-form__field",children:[e.jsx("label",{htmlFor:"nice-reg-first",children:"First name *"}),e.jsx("input",{id:"nice-reg-first",className:"nice-input",type:"text",value:x,onChange:j=>A(j.target.value),required:!0,disabled:s,autoComplete:"given-name"})]}),e.jsxs("div",{className:"nice-register-form__field",children:[e.jsx("label",{htmlFor:"nice-reg-last",children:"Last name"}),e.jsx("input",{id:"nice-reg-last",className:"nice-input",type:"text",value:o,onChange:j=>p(j.target.value),disabled:s,autoComplete:"family-name"})]})]}),e.jsxs("div",{className:"nice-register-form__field",children:[e.jsx("label",{htmlFor:"nice-reg-email",children:"Email *"}),e.jsx("input",{id:"nice-reg-email",className:"nice-input",type:"email",value:f,onChange:j=>R(j.target.value),required:!0,disabled:s,autoComplete:"email"})]}),e.jsxs("div",{className:"nice-register-form__field",children:[e.jsx("label",{htmlFor:"nice-reg-pass",children:"Password *"}),e.jsx("input",{id:"nice-reg-pass",className:"nice-input",type:"password",value:_,onChange:j=>v(j.target.value),required:!0,disabled:s,autoComplete:"new-password"}),i&&_.length>0&&e.jsx(q,{password:_})]}),e.jsxs("div",{className:"nice-register-form__field",children:[e.jsx("label",{htmlFor:"nice-reg-confirm",children:"Confirm password *"}),e.jsx("input",{id:"nice-reg-confirm",className:"nice-input",type:"password",value:S,onChange:j=>P(j.target.value),required:!0,disabled:s,autoComplete:"new-password"}),S&&!k&&e.jsx("span",{className:"nice-error-text",children:"Passwords do not match"})]}),e.jsxs("label",{className:"nice-register-form__terms",children:[e.jsx("input",{type:"checkbox",checked:b,onChange:j=>F(j.target.checked),disabled:s}),e.jsxs("span",{children:["I accept the"," ",l?e.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",children:"Terms"}):"Terms",c&&e.jsxs(e.Fragment,{children:[" ","and"," ",e.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",children:"Privacy Policy"})]})," *"]})]}),e.jsx("button",{type:"submit",className:"nice-btn nice-btn--primary nice-register-form__submit",disabled:!T,children:s?"…":"Register"}),a&&e.jsxs("div",{className:"nice-register-form__login",children:[e.jsx("span",{children:"Already have an account? "}),e.jsx("button",{type:"button",onClick:a,children:"Sign in"})]}),d&&e.jsx("div",{className:"nice-register-form__footer",children:d})]})});X.displayName="NiceRegistrationForm";const ue=({style:n})=>e.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:"0.3em",height:"0.6em",margin:"0 0.35em 0.15em 0.1em",borderRight:"0.12em solid currentColor",borderBottom:"0.12em solid currentColor",transform:"rotate(45deg)",...n}}),Y=({style:n})=>e.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:"0.85em",height:"0.85em",borderRadius:"50%",border:"0.12em solid currentColor",borderTopColor:"transparent",transform:"rotate(-45deg)",...n}}),Z={lowercase:"abcdefghijklmnopqrstuvwxyz",uppercase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",digits:"0123456789",symbols:"!@#$%^&*()-_=+[]{};:,.?/~"},he=/[0Oo1lI|]/g,z={length:16,lowercase:!0,uppercase:!0,digits:!0,symbols:!0,excludeAmbiguous:!1},me={password:"Generated password",length:"Length",lowercase:"Lowercase (a–z)",uppercase:"Uppercase (A–Z)",digits:"Digits (0–9)",symbols:"Symbols (!@#…)",excludeAmbiguous:"Avoid look-alikes (0 O 1 l I)",generate:"Generate",copy:"Copy",copied:"Copied",noCharacterSets:"Pick at least one kind of character."},pe=n=>{const s=globalThis.crypto;if(!s||typeof s.getRandomValues!="function")throw new Error("generatePassword: crypto.getRandomValues is not available");return s.getRandomValues(n)};let fe=0;function Q(n,s){const r=Math.floor(4294967296/n)*n,a=new Uint32Array(1);for(;;){const i=s(a)[0];if(i<r)return i%n}}function W(n={},s=pe){const r={...z,...n},a=["lowercase","uppercase","digits","symbols"].filter(c=>r[c]).map(c=>r.excludeAmbiguous?Z[c].replace(he,""):Z[c]).filter(c=>c.length>0);if(a.length===0)return"";const i=Math.max(a.length,Math.min(1024,Math.floor(r.length))),u=a.join(""),l=a.map(c=>c[Q(c.length,s)]);for(;l.length<i;)l.push(u[Q(u.length,s)]);for(let c=l.length-1;c>0;c--){const h=Q(c+1,s);[l[c],l[h]]=[l[h],l[c]]}return l.join("")}const ge=({value:n,defaultValue:s="",onChange:r,options:a,defaultOptions:i,onOptionsChange:u,minLength:l=8,maxLength:c=64,showStrength:h=!0,showCopy:C=!0,onCopy:d,labels:y,disabled:g=!1,className:w,style:x,id:A})=>{const o={...me,...y},[p]=t.useState(()=>`nice-password-generator-${++fe}`),f=A??p,[R,_]=t.useState(()=>({...z,...i})),v=a?{...z,...a}:R,[S,P]=t.useState(()=>n===void 0&&!s?W({...z,...i,...a}):s),b=n??S,[F,E]=t.useState(!1),k=t.useRef(void 0);t.useEffect(()=>()=>clearTimeout(k.current),[]);const T=t.useCallback(M=>{n===void 0&&P(M),E(!1),r==null||r(M)},[n,r]),m=t.useCallback(M=>T(W(M)),[T]),j=(M,D)=>{const B={...v,[M]:D};a||_(B),u==null||u(B),m(B)},U=async()=>{!b||!navigator.clipboard||(await navigator.clipboard.writeText(b),E(!0),clearTimeout(k.current),k.current=setTimeout(()=>E(!1),1500),d==null||d(b))},$=!v.lowercase&&!v.uppercase&&!v.digits&&!v.symbols,O=Math.min(c,Math.max(l,v.length));return e.jsxs("div",{id:A,className:`nice-password-generator${w?` ${w}`:""}`,style:x,children:[e.jsxs("div",{className:"nice-password-generator__output",children:[e.jsx("input",{id:`${f}-value`,className:"nice-password-generator__value",type:"text",readOnly:!0,spellCheck:!1,autoComplete:"off",value:b,"aria-label":o.password}),e.jsx("button",{type:"button",className:"nice-password-generator__button",onClick:()=>m(v),disabled:g||$,"aria-label":o.generate,title:o.generate,children:e.jsx(Y,{})}),C&&e.jsx("button",{type:"button",className:"nice-password-generator__button nice-password-generator__button--copy",onClick:U,disabled:g||!b,"aria-live":"polite",children:F?e.jsxs(e.Fragment,{children:[e.jsx(ue,{})," ",o.copied]}):o.copy})]}),h&&e.jsx(q,{password:b}),e.jsxs("div",{className:"nice-password-generator__length",children:[e.jsx("label",{htmlFor:`${f}-length`,children:o.length}),e.jsx("input",{id:`${f}-length`,type:"range",min:l,max:c,value:O,disabled:g,onChange:M=>j("length",Number(M.target.value))}),e.jsx("output",{htmlFor:`${f}-length`,className:"nice-password-generator__length-value",children:O})]}),e.jsx("div",{className:"nice-password-generator__sets",children:["lowercase","uppercase","digits","symbols","excludeAmbiguous"].map(M=>e.jsxs("label",{className:"nice-password-generator__option",children:[e.jsx("input",{type:"checkbox",checked:v[M],disabled:g,onChange:D=>j(M,D.target.checked)}),o[M]]},M))}),$&&e.jsx("p",{className:"nice-password-generator__error",role:"alert",children:o.noCharacterSets})]})},ee=t.forwardRef(({requireCurrentPassword:n=!0,onSubmit:s,loading:r=!1,error:a,success:i,minPasswordStrength:u=2,title:l="Change Password",className:c,style:h},C)=>{const[d,y]=t.useState(""),[g,w]=t.useState(""),[x,A]=t.useState(""),o=K(g),p=g===x,f=(!n||d.length>0)&&g.length>0&&p&&o>=u&&!r,R=t.useCallback(_=>{_.preventDefault(),f&&(s==null||s({currentPassword:n?d:void 0,newPassword:g}))},[f,d,g,n,s]);return e.jsxs("form",{ref:C,className:`nice-change-password${c?` ${c}`:""}`,style:h,onSubmit:R,noValidate:!0,children:[e.jsx("h3",{className:"nice-change-password__title",children:l}),a&&e.jsx("div",{className:"nice-change-password__error",role:"alert",children:a}),i&&e.jsx("div",{className:"nice-change-password__success",role:"status",children:i}),n&&e.jsxs("div",{className:"nice-change-password__field",children:[e.jsx("label",{htmlFor:"nice-cp-current",children:"Current password"}),e.jsx("input",{id:"nice-cp-current",className:"nice-input",type:"password",value:d,onChange:_=>y(_.target.value),autoComplete:"current-password",disabled:r,required:!0})]}),e.jsxs("div",{className:"nice-change-password__field",children:[e.jsx("label",{htmlFor:"nice-cp-new",children:"New password"}),e.jsx("input",{id:"nice-cp-new",className:"nice-input",type:"password",value:g,onChange:_=>w(_.target.value),autoComplete:"new-password",disabled:r,required:!0}),g.length>0&&e.jsx(q,{password:g})]}),e.jsxs("div",{className:"nice-change-password__field",children:[e.jsx("label",{htmlFor:"nice-cp-confirm",children:"Confirm new password"}),e.jsx("input",{id:"nice-cp-confirm",className:"nice-input",type:"password",value:x,onChange:_=>A(_.target.value),autoComplete:"new-password",disabled:r,required:!0}),x&&!p&&e.jsx("span",{className:"nice-error-text",children:"Passwords do not match"})]}),e.jsx("button",{type:"submit",className:"nice-btn nice-btn--primary",disabled:!f,children:r?"…":"Change Password"})]})});ee.displayName="NiceChangePassword";const te=t.forwardRef(({secret:n,qrCodeUrl:s,issuer:r,accountName:a,onVerify:i,loading:u=!1,error:l,onCancel:c,recoveryCodes:h,step:C="setup",onStepChange:d,className:y,style:g},w)=>{const[x,A]=t.useState(""),[o,p]=t.useState(!1),[f,R]=t.useState(!1),_=t.useCallback(S=>{S.preventDefault(),x.length>=6&&(i==null||i(x))},[x,i]),v=`otpauth://totp/${r?`${r}:`:""}${a??"user"}?secret=${n}${r?`&issuer=${r}`:""}&digits=6&period=30`;return e.jsxs("div",{ref:w,className:`nice-2fa-setup${y?` ${y}`:""}`,style:g,children:[e.jsx("h3",{className:"nice-2fa-setup__title",children:"Two-Factor Authentication"}),C==="setup"&&e.jsxs("div",{className:"nice-2fa-setup__step",children:[e.jsx("p",{className:"nice-2fa-setup__instruction",children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.):"}),s?e.jsx("img",{src:s,alt:"2FA QR Code",className:"nice-2fa-setup__qr"}):e.jsxs("div",{className:"nice-2fa-setup__qr-placeholder",children:[e.jsx("span",{children:"QR Code"}),e.jsx("code",{className:"nice-2fa-setup__uri",children:v})]}),e.jsxs("div",{className:"nice-2fa-setup__secret",children:[e.jsx("span",{children:"Or enter manually: "}),o?e.jsx("code",{className:"nice-2fa-setup__secret-key",children:n}):e.jsx("button",{type:"button",onClick:()=>p(!0),children:"Show secret key"})]}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--primary",onClick:()=>d==null?void 0:d("verify"),children:"Next — Verify"})]}),C==="verify"&&e.jsxs("form",{className:"nice-2fa-setup__step",onSubmit:_,children:[e.jsx("p",{className:"nice-2fa-setup__instruction",children:"Enter the 6-digit code from your authenticator app:"}),l&&e.jsx("div",{className:"nice-2fa-setup__error",role:"alert",children:l}),e.jsx("input",{className:"nice-input nice-2fa-setup__code-input",type:"text",inputMode:"numeric",maxLength:6,value:x,onChange:S=>A(S.target.value.replace(/\D/g,"").slice(0,6)),placeholder:"000000",autoFocus:!0,disabled:u,autoComplete:"one-time-code"}),e.jsxs("div",{className:"nice-2fa-setup__actions",children:[e.jsx("button",{type:"button",className:"nice-btn",onClick:()=>d==null?void 0:d("setup"),children:"Back"}),e.jsx("button",{type:"submit",className:"nice-btn nice-btn--primary",disabled:u||x.length<6,children:u?"…":"Verify"})]})]}),C==="recovery"&&h&&e.jsxs("div",{className:"nice-2fa-setup__step",children:[e.jsx("p",{className:"nice-2fa-setup__instruction",children:"Save these recovery codes in a safe place. Each code can only be used once:"}),e.jsx("div",{className:"nice-2fa-setup__recovery-codes",children:h.map((S,P)=>e.jsx("code",{className:"nice-2fa-setup__recovery-code",children:S},P))}),e.jsx("button",{type:"button",className:"nice-btn",onClick:()=>{var S;(S=navigator.clipboard)==null||S.writeText(h.join(`
|
|
2
|
+
`)),R(!0)},children:f?"Copied!":"Copy all codes"}),c&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--primary",onClick:c,children:"Done"})]}),c&&C!=="recovery"&&e.jsx("button",{type:"button",className:"nice-2fa-setup__cancel",onClick:c,children:"Cancel"})]})});te.displayName="NiceTwoFaSetup";const xe=500;function I(n,s){return Math.floor(Math.random()*(s-n+1))+n}function be(){return`${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`}function _e(n,s){switch(n){case"math":{const r=s==="easy"?5:s==="hard"?20:10,a=I(1,r),i=I(1,r),u=s!=="easy"&&a>=i&&Math.random()<.5,l=u?a-i:a+i;return{kind:"math",prompt:`${a} ${u?"−":"+"} ${i}`,answer:l}}case"text":{const r=s==="easy"?4:s==="hard"?7:5,a="ABCDEFGHJKMNPQRSTUVWXYZ23456789";let i="";for(let u=0;u<r;u++)i+=a[I(0,a.length-1)];return{kind:"text",text:i}}case"slider":return{kind:"slider",target:I(70,92),tolerance:s==="easy"?8:s==="hard"?2:4};case"checkbox":default:return{kind:"checkbox"}}}function je(n,s,r){if(!n)return;const a=n.getContext("2d");if(!a)return;const i=n.width,u=n.height;a.clearRect(0,0,i,u),a.fillStyle=r?"#1a1a1a":"#f3f4f6",a.fillRect(0,0,i,u),a.strokeStyle=r?"rgba(255,255,255,0.18)":"rgba(0,0,0,0.18)",a.lineWidth=1;for(let c=0;c<6;c++)a.beginPath(),a.moveTo(I(0,i),I(0,u)),a.lineTo(I(0,i),I(0,u)),a.stroke();a.fillStyle=r?"#e5e7eb":"#111827",a.textBaseline="middle";const l=i/(s.length+1);for(let c=0;c<s.length;c++){const h=I(22,30);a.save(),a.translate(l*(c+1),u/2+I(-4,4)),a.rotate(I(-22,22)*Math.PI/180),a.font=`bold ${h}px monospace`,a.fillText(s[c],-h/3,0),a.restore()}}const se=t.forwardRef((n,s)=>{const{variant:r,difficulty:a="medium",refreshable:i=!0,verifyToken:u,expiresMs:l,label:c="I'm not a robot",provider:h="custom",siteKey:C,onVerify:d,onExpire:y,onError:g,onRefresh:w,theme:x="light",size:A="normal",customRender:o,className:p,style:f}=n,R=t.useRef(null),_=t.useRef(null),v=t.useRef(void 0),[S,P]=t.useState(0),[b,F]=t.useState("idle"),[E,k]=t.useState(""),[T,m]=t.useState(""),[j,U]=t.useState(0),$=t.useMemo(()=>_e(r??"checkbox",a),[r,a,S]),O=t.useCallback(()=>{F("idle"),k(""),m(""),U(0),P(N=>N+1)},[]),M=t.useCallback(()=>{O(),w==null||w()},[O,w]);t.useImperativeHandle(s,()=>({reset:O,refresh:M,container:R.current}),[O,M]),t.useEffect(()=>{r==="text"&&$.kind==="text"&&je(_.current,$.text,x==="dark")},[r,$,x]),t.useEffect(()=>{if(b!=="verified"||!l)return;const N=setTimeout(()=>{y==null||y(),O()},l);return()=>clearTimeout(N)},[b,l,y,O]);const D=t.useCallback(()=>{const N=`ntd-cap:${r}:${be()}`;u?(F("verifying"),k(""),Promise.resolve().then(()=>u(N)).then(H=>{H?(F("verified"),d==null||d(N)):(F("error"),k("Verification failed. Please try again."),P(ie=>ie+1),m(""))}).catch(H=>{F("error"),k("Verification error. Please try again."),g==null||g(H)})):(F("verified"),d==null||d(N))},[r,u,d,g]),B=t.useCallback(()=>{F("error"),k("Incorrect, please try again."),P(N=>N+1),m("")},[]),ne=t.useCallback(()=>{b==="verifying"||b==="verified"||(F("verifying"),k(""),v.current=setTimeout(D,xe))},[b,D]);t.useEffect(()=>()=>clearTimeout(v.current),[]);const G=t.useCallback(()=>{$.kind==="math"?T.trim()!==""&&Number(T)===$.answer?D():B():$.kind==="text"&&(T.trim().toUpperCase()===$.text?D():B())},[$,T,D,B]),re=t.useCallback(N=>{U(N),!($.kind!=="slider"||b==="verified"||b==="verifying")&&Math.abs(N-$.target)<=$.tolerance&&D()},[$,b,D]);if(!r)return h==="custom"&&o?e.jsx("div",{ref:R,className:`nice-captcha nice-captcha--custom${p?` ${p}`:""}`,style:f,children:o}):e.jsx("div",{ref:R,className:`nice-captcha nice-captcha--${h} nice-captcha--${x}${A==="compact"?" nice-captcha--compact":""}${p?` ${p}`:""}`,style:f,"data-sitekey":C,"data-theme":x,"data-size":A,children:e.jsxs("div",{className:"nice-captcha__placeholder",children:[e.jsxs("span",{children:["Captcha (",h,")"]}),e.jsxs("p",{children:["Load the ",h," SDK to activate verification."]})]})});const L=b==="verifying",V=b==="verified",ce=`nice-captcha nice-captcha--${r} nice-captcha--${x} nice-captcha--${b}${A==="compact"?" nice-captcha--compact":""}${p?` ${p}`:""}`;return e.jsxs("div",{ref:R,className:ce,style:f,role:"group","aria-label":"Captcha challenge","data-variant":r,"data-status":b,"data-theme":x,children:[r==="checkbox"&&e.jsxs("button",{type:"button",className:"nice-captcha__checkbox",role:"checkbox","aria-checked":V,"aria-busy":L,disabled:L||V,onClick:ne,children:[e.jsx("span",{className:"nice-captcha__box","aria-hidden":"true",children:L?"…":V?e.jsx("span",{style:{display:"inline-block",width:"0.3em",height:"0.6em",marginBottom:"0.15em",borderRight:"0.12em solid currentColor",borderBottom:"0.12em solid currentColor",transform:"rotate(45deg)"}}):""}),e.jsx("span",{className:"nice-captcha__label",children:c})]}),r==="math"&&$.kind==="math"&&e.jsxs("div",{className:"nice-captcha__challenge",children:[e.jsxs("span",{className:"nice-captcha__prompt","aria-hidden":"true",children:[$.prompt," ="]}),e.jsx("input",{className:"nice-input nice-captcha__answer",type:"number",inputMode:"numeric",value:T,"aria-label":`What is ${$.prompt}?`,disabled:L||V,onChange:N=>m(N.target.value),onKeyDown:N=>{N.key==="Enter"&&(N.preventDefault(),G())}}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--primary nice-captcha__verify",disabled:L||V||T.trim()==="",onClick:G,children:L?"…":"Verify"})]}),r==="text"&&$.kind==="text"&&e.jsxs("div",{className:"nice-captcha__challenge",children:[e.jsx("canvas",{ref:_,className:"nice-captcha__canvas",width:160,height:56,"aria-hidden":"true"}),e.jsx("input",{className:"nice-input nice-captcha__answer",type:"text",autoCapitalize:"characters",autoComplete:"off",value:T,"aria-label":"Type the characters shown in the image",disabled:L||V,onChange:N=>m(N.target.value),onKeyDown:N=>{N.key==="Enter"&&(N.preventDefault(),G())}}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--primary nice-captcha__verify",disabled:L||V||T.trim()==="",onClick:G,children:L?"…":"Verify"})]}),r==="slider"&&$.kind==="slider"&&e.jsxs("div",{className:"nice-captcha__challenge nice-captcha__challenge--slider",children:[e.jsx("span",{className:"nice-captcha__slider-hint","aria-hidden":"true",children:V?"Verified":"Slide to the marker"}),e.jsxs("div",{className:"nice-captcha__track",children:[e.jsx("span",{className:"nice-captcha__target","aria-hidden":"true",style:{left:`${$.target}%`}}),e.jsx("input",{className:"nice-captcha__slider",type:"range",min:0,max:100,value:j,"aria-label":"Slide the handle to the marker to verify","aria-valuetext":`${j}%`,disabled:V||L,onChange:N=>re(Number(N.target.value))})]})]}),e.jsxs("div",{className:"nice-captcha__footer",children:[e.jsx("div",{className:"nice-captcha__message",role:"status","aria-live":"polite",children:E}),i&&e.jsx("button",{type:"button",className:"nice-captcha__refresh","aria-label":"Refresh challenge",title:"Refresh challenge",onClick:M,children:e.jsx(Y,{})})]})]})});se.displayName="NiceCaptcha";const Ne=[{id:"google",label:"Google",color:"#4285f4",textColor:"#fff"},{id:"microsoft",label:"Microsoft",color:"#00a4ef",textColor:"#fff"},{id:"discord",label:"Discord",color:"#5865f2",textColor:"#fff"},{id:"spotify",label:"Spotify",color:"#1db954",textColor:"#fff"},{id:"github",label:"GitHub",color:"#24292e",textColor:"#fff"}],ae=t.forwardRef(({providers:n=Ne,onProviderClick:s,disabled:r=!1,loadingProvider:a,direction:i="vertical",separatorText:u="or continue with",showSeparator:l=!0,className:c,style:h},C)=>e.jsxs("div",{ref:C,className:`nice-oauth nice-oauth--${i}${c?` ${c}`:""}`,style:h,children:[l&&e.jsxs("div",{className:"nice-oauth__separator",children:[e.jsx("hr",{}),e.jsx("span",{children:u}),e.jsx("hr",{})]}),e.jsx("div",{className:"nice-oauth__buttons",children:n.map(d=>e.jsxs("button",{type:"button",className:`nice-oauth__btn${a===d.id?" nice-oauth__btn--loading":""}`,style:{backgroundColor:d.color,color:d.textColor},onClick:()=>s==null?void 0:s(d.id),disabled:r||!!a,children:[d.icon&&e.jsx("span",{className:"nice-oauth__btn-icon",children:d.icon}),e.jsx("span",{className:"nice-oauth__btn-label",children:a===d.id?"…":d.label})]},d.id))})]}));ae.displayName="NiceOAuthButtons";const we=t.forwardRef(function(s,r){const{tokens:a,onCreate:i,onRevoke:u,availableScopes:l=[],maxTokens:c=10,title:h="API Tokens",className:C,style:d}=s,[y,g]=t.useState(!1),[w,x]=t.useState(""),[A,o]=t.useState([]),[p,f]=t.useState("90"),[R,_]=t.useState(null),[v,S]=t.useState(!1),[P,b]=t.useState(null),F=t.useCallback(async()=>{if(!(!i||!w.trim())){S(!0);try{const m=p?parseInt(p,10):void 0,j=await i(w.trim(),A,m);_(j),x(""),o([]),g(!1)}finally{S(!1)}}},[i,w,A,p]),E=t.useCallback(async m=>{if(u){b(m);try{await u(m)}finally{b(null)}}},[u]),k=m=>{o(j=>j.includes(m)?j.filter(U=>U!==m):[...j,m])},T=a.length<c;return e.jsxs("div",{ref:r,className:`nice-token-management ${C??""}`,style:d,children:[e.jsxs("div",{className:"nice-token-management__header",children:[e.jsx("h3",{children:h}),T&&e.jsx("button",{className:"nice-token-management__new-btn",onClick:()=>g(!0),disabled:y,children:"+ New Token"})]}),R&&e.jsxs("div",{className:"nice-token-management__reveal",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"New token created!"})," Copy it now — it won't be shown again."]}),e.jsx("code",{className:"nice-token-management__token-value",children:R}),e.jsx("button",{onClick:()=>_(null),children:"Dismiss"})]}),y&&e.jsxs("div",{className:"nice-token-management__create-form",children:[e.jsxs("label",{children:["Name",e.jsx("input",{type:"text",value:w,onChange:m=>x(m.target.value),placeholder:"My API token",maxLength:64})]}),l.length>0&&e.jsxs("fieldset",{children:[e.jsx("legend",{children:"Scopes"}),l.map(m=>e.jsxs("label",{className:"nice-token-management__scope",children:[e.jsx("input",{type:"checkbox",checked:A.includes(m),onChange:()=>k(m)}),m]},m))]}),e.jsxs("label",{children:["Expires in (days)",e.jsx("input",{type:"number",value:p,onChange:m=>f(m.target.value),min:1,max:365})]}),e.jsxs("div",{className:"nice-token-management__create-actions",children:[e.jsx("button",{onClick:F,disabled:v||!w.trim(),children:v?"Creating…":"Create Token"}),e.jsx("button",{onClick:()=>g(!1),children:"Cancel"})]})]}),a.length===0?e.jsx("p",{className:"nice-token-management__empty",children:"No API tokens yet."}):e.jsxs("table",{className:"nice-token-management__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),e.jsx("th",{children:"Prefix"}),e.jsx("th",{children:"Created"}),e.jsx("th",{children:"Expires"}),e.jsx("th",{children:"Last Used"}),e.jsx("th",{children:"Scopes"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:a.map(m=>{var j;return e.jsxs("tr",{children:[e.jsx("td",{children:m.name}),e.jsx("td",{children:e.jsxs("code",{children:[m.prefix,"…"]})}),e.jsx("td",{children:m.createdAt}),e.jsx("td",{children:m.expiresAt??"—"}),e.jsx("td",{children:m.lastUsedAt??"Never"}),e.jsx("td",{children:((j=m.scopes)==null?void 0:j.join(", "))||"—"}),e.jsx("td",{children:e.jsx("button",{className:"nice-token-management__revoke-btn",onClick:()=>E(m.id),disabled:P===m.id,children:P===m.id?"Revoking…":"Revoke"})})]},m.id)})})]})]})});exports.NiceCaptcha=se;exports.NiceChangePassword=ee;exports.NiceLoginForm=J;exports.NiceOAuthButtons=ae;exports.NicePasswordGenerator=ge;exports.NicePasswordStrength=q;exports.NiceRegistrationForm=X;exports.NiceTokenManagement=we;exports.NiceTwoFaSetup=te;exports.calcPasswordStrength=K;exports.generatePassword=W;exports.useAuth=le;
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export { NiceRegistrationForm } from './NiceRegistrationForm';
|
|
|
6
6
|
export type { RegistrationData, NiceRegistrationFormProps } from './NiceRegistrationForm';
|
|
7
7
|
export { NicePasswordStrength, calcPasswordStrength } from './NicePasswordStrength';
|
|
8
8
|
export type { PasswordStrengthLevel, NicePasswordStrengthProps } from './NicePasswordStrength';
|
|
9
|
+
export { NicePasswordGenerator, generatePassword } from './NicePasswordGenerator';
|
|
10
|
+
export type { NicePasswordGeneratorOptions, NicePasswordGeneratorLabels, NicePasswordGeneratorProps, } from './NicePasswordGenerator';
|
|
9
11
|
export { NiceChangePassword } from './NiceChangePassword';
|
|
10
12
|
export type { NiceChangePasswordProps } from './NiceChangePassword';
|
|
11
13
|
export { NiceTwoFaSetup } from './NiceTwoFaSetup';
|