@entropy-softworks/ui 2026.7.31
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 +96 -0
- package/LICENSE +21 -0
- package/README.md +115 -0
- package/lib/components/auth/LockOverlay.d.ts +22 -0
- package/lib/components/auth/LockOverlay.d.ts.map +1 -0
- package/lib/components/auth/LockOverlay.jsx +82 -0
- package/lib/components/auth/LockOverlay.jsx.map +1 -0
- package/lib/components/auth/PasswordStrengthMeter.d.ts +12 -0
- package/lib/components/auth/PasswordStrengthMeter.d.ts.map +1 -0
- package/lib/components/auth/PasswordStrengthMeter.jsx +81 -0
- package/lib/components/auth/PasswordStrengthMeter.jsx.map +1 -0
- package/lib/components/auth/ProtectedRoute.d.ts +24 -0
- package/lib/components/auth/ProtectedRoute.d.ts.map +1 -0
- package/lib/components/auth/ProtectedRoute.jsx +56 -0
- package/lib/components/auth/ProtectedRoute.jsx.map +1 -0
- package/lib/components/auth/PwnedPasswordWarning.d.ts +13 -0
- package/lib/components/auth/PwnedPasswordWarning.d.ts.map +1 -0
- package/lib/components/auth/PwnedPasswordWarning.jsx +29 -0
- package/lib/components/auth/PwnedPasswordWarning.jsx.map +1 -0
- package/lib/components/auth/index.d.ts +5 -0
- package/lib/components/auth/index.d.ts.map +1 -0
- package/lib/components/auth/index.js +5 -0
- package/lib/components/auth/index.js.map +1 -0
- package/lib/components/bottom-nav.d.ts +25 -0
- package/lib/components/bottom-nav.d.ts.map +1 -0
- package/lib/components/bottom-nav.jsx +51 -0
- package/lib/components/bottom-nav.jsx.map +1 -0
- package/lib/components/button.d.ts +16 -0
- package/lib/components/button.d.ts.map +1 -0
- package/lib/components/button.jsx +73 -0
- package/lib/components/button.jsx.map +1 -0
- package/lib/components/card.d.ts +22 -0
- package/lib/components/card.d.ts.map +1 -0
- package/lib/components/card.jsx +36 -0
- package/lib/components/card.jsx.map +1 -0
- package/lib/components/checkbox.d.ts +12 -0
- package/lib/components/checkbox.d.ts.map +1 -0
- package/lib/components/checkbox.jsx +16 -0
- package/lib/components/checkbox.jsx.map +1 -0
- package/lib/components/connection-settings.d.ts +41 -0
- package/lib/components/connection-settings.d.ts.map +1 -0
- package/lib/components/connection-settings.jsx +354 -0
- package/lib/components/connection-settings.jsx.map +1 -0
- package/lib/components/context-menu.d.ts +52 -0
- package/lib/components/context-menu.d.ts.map +1 -0
- package/lib/components/context-menu.jsx +24 -0
- package/lib/components/context-menu.jsx.map +1 -0
- package/lib/components/data-table.d.ts +59 -0
- package/lib/components/data-table.d.ts.map +1 -0
- package/lib/components/data-table.jsx +101 -0
- package/lib/components/data-table.jsx.map +1 -0
- package/lib/components/dialog.d.ts +58 -0
- package/lib/components/dialog.d.ts.map +1 -0
- package/lib/components/dialog.jsx +197 -0
- package/lib/components/dialog.jsx.map +1 -0
- package/lib/components/dropdown-menu.d.ts +55 -0
- package/lib/components/dropdown-menu.d.ts.map +1 -0
- package/lib/components/dropdown-menu.jsx +38 -0
- package/lib/components/dropdown-menu.jsx.map +1 -0
- package/lib/components/entropy-boot-splash.d.ts +24 -0
- package/lib/components/entropy-boot-splash.d.ts.map +1 -0
- package/lib/components/entropy-boot-splash.jsx +83 -0
- package/lib/components/entropy-boot-splash.jsx.map +1 -0
- package/lib/components/entropy-mark-animated.d.ts +20 -0
- package/lib/components/entropy-mark-animated.d.ts.map +1 -0
- package/lib/components/entropy-mark-animated.jsx +148 -0
- package/lib/components/entropy-mark-animated.jsx.map +1 -0
- package/lib/components/entropy-mark-geometry.d.ts +8 -0
- package/lib/components/entropy-mark-geometry.d.ts.map +1 -0
- package/lib/components/entropy-mark-geometry.js +10 -0
- package/lib/components/entropy-mark-geometry.js.map +1 -0
- package/lib/components/entropy-mark-sequential.d.ts +12 -0
- package/lib/components/entropy-mark-sequential.d.ts.map +1 -0
- package/lib/components/entropy-mark-sequential.jsx +53 -0
- package/lib/components/entropy-mark-sequential.jsx.map +1 -0
- package/lib/components/entropy-mark.d.ts +29 -0
- package/lib/components/entropy-mark.d.ts.map +1 -0
- package/lib/components/entropy-mark.jsx +66 -0
- package/lib/components/entropy-mark.jsx.map +1 -0
- package/lib/components/error-boundary.d.ts +31 -0
- package/lib/components/error-boundary.d.ts.map +1 -0
- package/lib/components/error-boundary.jsx +40 -0
- package/lib/components/error-boundary.jsx.map +1 -0
- package/lib/components/index.d.ts +41 -0
- package/lib/components/index.d.ts.map +1 -0
- package/lib/components/index.js +43 -0
- package/lib/components/index.js.map +1 -0
- package/lib/components/input.d.ts +26 -0
- package/lib/components/input.d.ts.map +1 -0
- package/lib/components/input.jsx +95 -0
- package/lib/components/input.jsx.map +1 -0
- package/lib/components/item-icon.d.ts +32 -0
- package/lib/components/item-icon.d.ts.map +1 -0
- package/lib/components/item-icon.jsx +54 -0
- package/lib/components/item-icon.jsx.map +1 -0
- package/lib/components/label.d.ts +13 -0
- package/lib/components/label.d.ts.map +1 -0
- package/lib/components/label.jsx +9 -0
- package/lib/components/label.jsx.map +1 -0
- package/lib/components/legal-dialog.d.ts +18 -0
- package/lib/components/legal-dialog.d.ts.map +1 -0
- package/lib/components/legal-dialog.jsx +31 -0
- package/lib/components/legal-dialog.jsx.map +1 -0
- package/lib/components/license-gate.d.ts +17 -0
- package/lib/components/license-gate.d.ts.map +1 -0
- package/lib/components/license-gate.jsx +21 -0
- package/lib/components/license-gate.jsx.map +1 -0
- package/lib/components/logo.d.ts +15 -0
- package/lib/components/logo.d.ts.map +1 -0
- package/lib/components/logo.jsx +20 -0
- package/lib/components/logo.jsx.map +1 -0
- package/lib/components/onboarding-wizard.d.ts +89 -0
- package/lib/components/onboarding-wizard.d.ts.map +1 -0
- package/lib/components/onboarding-wizard.jsx +185 -0
- package/lib/components/onboarding-wizard.jsx.map +1 -0
- package/lib/components/pagination.d.ts +43 -0
- package/lib/components/pagination.d.ts.map +1 -0
- package/lib/components/pagination.jsx +72 -0
- package/lib/components/pagination.jsx.map +1 -0
- package/lib/components/password-generator.d.ts +15 -0
- package/lib/components/password-generator.d.ts.map +1 -0
- package/lib/components/password-generator.jsx +273 -0
- package/lib/components/password-generator.jsx.map +1 -0
- package/lib/components/pin-pad.d.ts +20 -0
- package/lib/components/pin-pad.d.ts.map +1 -0
- package/lib/components/pin-pad.jsx +93 -0
- package/lib/components/pin-pad.jsx.map +1 -0
- package/lib/components/popover.d.ts +27 -0
- package/lib/components/popover.d.ts.map +1 -0
- package/lib/components/popover.jsx +18 -0
- package/lib/components/popover.jsx.map +1 -0
- package/lib/components/profile/ProfileDialog.d.ts +25 -0
- package/lib/components/profile/ProfileDialog.d.ts.map +1 -0
- package/lib/components/profile/ProfileDialog.jsx +71 -0
- package/lib/components/profile/ProfileDialog.jsx.map +1 -0
- package/lib/components/profile/ProfileTab.d.ts +12 -0
- package/lib/components/profile/ProfileTab.d.ts.map +1 -0
- package/lib/components/profile/ProfileTab.jsx +112 -0
- package/lib/components/profile/ProfileTab.jsx.map +1 -0
- package/lib/components/profile/SecurityTab.d.ts +32 -0
- package/lib/components/profile/SecurityTab.d.ts.map +1 -0
- package/lib/components/profile/SecurityTab.jsx +145 -0
- package/lib/components/profile/SecurityTab.jsx.map +1 -0
- package/lib/components/profile/index.d.ts +4 -0
- package/lib/components/profile/index.d.ts.map +1 -0
- package/lib/components/profile/index.js +4 -0
- package/lib/components/profile/index.js.map +1 -0
- package/lib/components/segmented-toggle.d.ts +28 -0
- package/lib/components/segmented-toggle.d.ts.map +1 -0
- package/lib/components/segmented-toggle.jsx +64 -0
- package/lib/components/segmented-toggle.jsx.map +1 -0
- package/lib/components/separator.d.ts +13 -0
- package/lib/components/separator.d.ts.map +1 -0
- package/lib/components/separator.jsx +16 -0
- package/lib/components/separator.jsx.map +1 -0
- package/lib/components/server-settings.d.ts +27 -0
- package/lib/components/server-settings.d.ts.map +1 -0
- package/lib/components/server-settings.jsx +307 -0
- package/lib/components/server-settings.jsx.map +1 -0
- package/lib/components/settings/AccountSection.d.ts +26 -0
- package/lib/components/settings/AccountSection.d.ts.map +1 -0
- package/lib/components/settings/AccountSection.jsx +32 -0
- package/lib/components/settings/AccountSection.jsx.map +1 -0
- package/lib/components/settings/DangerZoneSection.d.ts +13 -0
- package/lib/components/settings/DangerZoneSection.d.ts.map +1 -0
- package/lib/components/settings/DangerZoneSection.jsx +16 -0
- package/lib/components/settings/DangerZoneSection.jsx.map +1 -0
- package/lib/components/settings/GeneralSection.d.ts +11 -0
- package/lib/components/settings/GeneralSection.d.ts.map +1 -0
- package/lib/components/settings/GeneralSection.jsx +12 -0
- package/lib/components/settings/GeneralSection.jsx.map +1 -0
- package/lib/components/settings/SupportSection.d.ts +11 -0
- package/lib/components/settings/SupportSection.d.ts.map +1 -0
- package/lib/components/settings/SupportSection.jsx +22 -0
- package/lib/components/settings/SupportSection.jsx.map +1 -0
- package/lib/components/settings/index.d.ts +5 -0
- package/lib/components/settings/index.d.ts.map +1 -0
- package/lib/components/settings/index.js +5 -0
- package/lib/components/settings/index.js.map +1 -0
- package/lib/components/settings-row.d.ts +28 -0
- package/lib/components/settings-row.d.ts.map +1 -0
- package/lib/components/settings-row.jsx +68 -0
- package/lib/components/settings-row.jsx.map +1 -0
- package/lib/components/skeleton.d.ts +8 -0
- package/lib/components/skeleton.d.ts.map +1 -0
- package/lib/components/skeleton.jsx +24 -0
- package/lib/components/skeleton.jsx.map +1 -0
- package/lib/components/social-connections.d.ts +15 -0
- package/lib/components/social-connections.d.ts.map +1 -0
- package/lib/components/social-connections.jsx +31 -0
- package/lib/components/social-connections.jsx.map +1 -0
- package/lib/components/stat-card.d.ts +29 -0
- package/lib/components/stat-card.d.ts.map +1 -0
- package/lib/components/stat-card.jsx +36 -0
- package/lib/components/stat-card.jsx.map +1 -0
- package/lib/components/tag-chip.d.ts +18 -0
- package/lib/components/tag-chip.d.ts.map +1 -0
- package/lib/components/tag-chip.jsx +54 -0
- package/lib/components/tag-chip.jsx.map +1 -0
- package/lib/components/tag-multi-select.d.ts +27 -0
- package/lib/components/tag-multi-select.d.ts.map +1 -0
- package/lib/components/tag-multi-select.jsx +65 -0
- package/lib/components/tag-multi-select.jsx.map +1 -0
- package/lib/components/text.d.ts +22 -0
- package/lib/components/text.d.ts.map +1 -0
- package/lib/components/text.jsx +43 -0
- package/lib/components/text.jsx.map +1 -0
- package/lib/components/toast/ToastPortal.d.ts +11 -0
- package/lib/components/toast/ToastPortal.d.ts.map +1 -0
- package/lib/components/toast/ToastPortal.jsx +15 -0
- package/lib/components/toast/ToastPortal.jsx.map +1 -0
- package/lib/components/toast/ToastPortal.web.d.ts +14 -0
- package/lib/components/toast/ToastPortal.web.d.ts.map +1 -0
- package/lib/components/toast/ToastPortal.web.jsx +39 -0
- package/lib/components/toast/ToastPortal.web.jsx.map +1 -0
- package/lib/components/toast/index.d.ts +3 -0
- package/lib/components/toast/index.d.ts.map +1 -0
- package/lib/components/toast/index.js +3 -0
- package/lib/components/toast/index.js.map +1 -0
- package/lib/components/toast/toast-config.d.ts +14 -0
- package/lib/components/toast/toast-config.d.ts.map +1 -0
- package/lib/components/toast/toast-config.jsx +24 -0
- package/lib/components/toast/toast-config.jsx.map +1 -0
- package/lib/components/tooltip.d.ts +30 -0
- package/lib/components/tooltip.d.ts.map +1 -0
- package/lib/components/tooltip.jsx +14 -0
- package/lib/components/tooltip.jsx.map +1 -0
- package/lib/components/totp-display.d.ts +23 -0
- package/lib/components/totp-display.d.ts.map +1 -0
- package/lib/components/totp-display.jsx +132 -0
- package/lib/components/totp-display.jsx.map +1 -0
- package/lib/components/user-avatar.d.ts +18 -0
- package/lib/components/user-avatar.d.ts.map +1 -0
- package/lib/components/user-avatar.jsx +25 -0
- package/lib/components/user-avatar.jsx.map +1 -0
- package/lib/context/AppConfigContext.d.ts +56 -0
- package/lib/context/AppConfigContext.d.ts.map +1 -0
- package/lib/context/AppConfigContext.jsx +14 -0
- package/lib/context/AppConfigContext.jsx.map +1 -0
- package/lib/context/NavigationContext.d.ts +42 -0
- package/lib/context/NavigationContext.d.ts.map +1 -0
- package/lib/context/NavigationContext.jsx +53 -0
- package/lib/context/NavigationContext.jsx.map +1 -0
- package/lib/context/NotificationContext.d.ts +32 -0
- package/lib/context/NotificationContext.d.ts.map +1 -0
- package/lib/context/NotificationContext.jsx +49 -0
- package/lib/context/NotificationContext.jsx.map +1 -0
- package/lib/context/ThemeContext.d.ts +12 -0
- package/lib/context/ThemeContext.d.ts.map +1 -0
- package/lib/context/ThemeContext.jsx +66 -0
- package/lib/context/ThemeContext.jsx.map +1 -0
- package/lib/context/index.d.ts +5 -0
- package/lib/context/index.d.ts.map +1 -0
- package/lib/context/index.js +5 -0
- package/lib/context/index.js.map +1 -0
- package/lib/flags.d.ts +9 -0
- package/lib/flags.d.ts.map +1 -0
- package/lib/flags.js +37 -0
- package/lib/flags.js.map +1 -0
- package/lib/forms/form-error.d.ts +12 -0
- package/lib/forms/form-error.d.ts.map +1 -0
- package/lib/forms/form-error.jsx +14 -0
- package/lib/forms/form-error.jsx.map +1 -0
- package/lib/forms/index.d.ts +3 -0
- package/lib/forms/index.d.ts.map +1 -0
- package/lib/forms/index.js +3 -0
- package/lib/forms/index.js.map +1 -0
- package/lib/forms/shake-field.d.ts +18 -0
- package/lib/forms/shake-field.d.ts.map +1 -0
- package/lib/forms/shake-field.jsx +30 -0
- package/lib/forms/shake-field.jsx.map +1 -0
- package/lib/hooks/index.d.ts +6 -0
- package/lib/hooks/index.d.ts.map +1 -0
- package/lib/hooks/index.js +6 -0
- package/lib/hooks/index.js.map +1 -0
- package/lib/hooks/useAuth.d.ts +109 -0
- package/lib/hooks/useAuth.d.ts.map +1 -0
- package/lib/hooks/useAuth.jsx +404 -0
- package/lib/hooks/useAuth.jsx.map +1 -0
- package/lib/hooks/useAutoLock.d.ts +22 -0
- package/lib/hooks/useAutoLock.d.ts.map +1 -0
- package/lib/hooks/useAutoLock.js +85 -0
- package/lib/hooks/useAutoLock.js.map +1 -0
- package/lib/hooks/useDebouncedValue.d.ts +19 -0
- package/lib/hooks/useDebouncedValue.d.ts.map +1 -0
- package/lib/hooks/useDebouncedValue.js +29 -0
- package/lib/hooks/useDebouncedValue.js.map +1 -0
- package/lib/hooks/useShakeAnimation.d.ts +17 -0
- package/lib/hooks/useShakeAnimation.d.ts.map +1 -0
- package/lib/hooks/useShakeAnimation.js +22 -0
- package/lib/hooks/useShakeAnimation.js.map +1 -0
- package/lib/hooks/useUploadBlobUrl.d.ts +13 -0
- package/lib/hooks/useUploadBlobUrl.d.ts.map +1 -0
- package/lib/hooks/useUploadBlobUrl.js +60 -0
- package/lib/hooks/useUploadBlobUrl.js.map +1 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +47 -0
- package/lib/index.js.map +1 -0
- package/lib/screens/auth/AccountPickerScreen.d.ts +24 -0
- package/lib/screens/auth/AccountPickerScreen.d.ts.map +1 -0
- package/lib/screens/auth/AccountPickerScreen.jsx +47 -0
- package/lib/screens/auth/AccountPickerScreen.jsx.map +1 -0
- package/lib/screens/auth/AuthScreen.d.ts +59 -0
- package/lib/screens/auth/AuthScreen.d.ts.map +1 -0
- package/lib/screens/auth/AuthScreen.jsx +594 -0
- package/lib/screens/auth/AuthScreen.jsx.map +1 -0
- package/lib/screens/auth/ConsentScreen.d.ts +27 -0
- package/lib/screens/auth/ConsentScreen.d.ts.map +1 -0
- package/lib/screens/auth/ConsentScreen.jsx +55 -0
- package/lib/screens/auth/ConsentScreen.jsx.map +1 -0
- package/lib/screens/auth/ErrorScreen.d.ts +20 -0
- package/lib/screens/auth/ErrorScreen.d.ts.map +1 -0
- package/lib/screens/auth/ErrorScreen.jsx +43 -0
- package/lib/screens/auth/ErrorScreen.jsx.map +1 -0
- package/lib/screens/auth/ExpiredLinkScreen.d.ts +19 -0
- package/lib/screens/auth/ExpiredLinkScreen.d.ts.map +1 -0
- package/lib/screens/auth/ExpiredLinkScreen.jsx +38 -0
- package/lib/screens/auth/ExpiredLinkScreen.jsx.map +1 -0
- package/lib/screens/auth/ForgotPasswordScreen.d.ts +4 -0
- package/lib/screens/auth/ForgotPasswordScreen.d.ts.map +1 -0
- package/lib/screens/auth/ForgotPasswordScreen.jsx +123 -0
- package/lib/screens/auth/ForgotPasswordScreen.jsx.map +1 -0
- package/lib/screens/auth/ImportDataScreen.d.ts +17 -0
- package/lib/screens/auth/ImportDataScreen.d.ts.map +1 -0
- package/lib/screens/auth/ImportDataScreen.jsx +73 -0
- package/lib/screens/auth/ImportDataScreen.jsx.map +1 -0
- package/lib/screens/auth/LoginScreen.d.ts +38 -0
- package/lib/screens/auth/LoginScreen.d.ts.map +1 -0
- package/lib/screens/auth/LoginScreen.jsx +326 -0
- package/lib/screens/auth/LoginScreen.jsx.map +1 -0
- package/lib/screens/auth/MfaChallengeScreen.d.ts +4 -0
- package/lib/screens/auth/MfaChallengeScreen.d.ts.map +1 -0
- package/lib/screens/auth/MfaChallengeScreen.jsx +139 -0
- package/lib/screens/auth/MfaChallengeScreen.jsx.map +1 -0
- package/lib/screens/auth/MfaEnrollScreen.d.ts +12 -0
- package/lib/screens/auth/MfaEnrollScreen.d.ts.map +1 -0
- package/lib/screens/auth/MfaEnrollScreen.jsx +267 -0
- package/lib/screens/auth/MfaEnrollScreen.jsx.map +1 -0
- package/lib/screens/auth/PasskeyEnrollScreen.d.ts +18 -0
- package/lib/screens/auth/PasskeyEnrollScreen.d.ts.map +1 -0
- package/lib/screens/auth/PasskeyEnrollScreen.jsx +51 -0
- package/lib/screens/auth/PasskeyEnrollScreen.jsx.map +1 -0
- package/lib/screens/auth/PrivacyPolicyScreen.d.ts +19 -0
- package/lib/screens/auth/PrivacyPolicyScreen.d.ts.map +1 -0
- package/lib/screens/auth/PrivacyPolicyScreen.jsx +143 -0
- package/lib/screens/auth/PrivacyPolicyScreen.jsx.map +1 -0
- package/lib/screens/auth/RegisterScreen.d.ts +14 -0
- package/lib/screens/auth/RegisterScreen.d.ts.map +1 -0
- package/lib/screens/auth/RegisterScreen.jsx +296 -0
- package/lib/screens/auth/RegisterScreen.jsx.map +1 -0
- package/lib/screens/auth/ResetPasswordScreen.d.ts +12 -0
- package/lib/screens/auth/ResetPasswordScreen.d.ts.map +1 -0
- package/lib/screens/auth/ResetPasswordScreen.jsx +276 -0
- package/lib/screens/auth/ResetPasswordScreen.jsx.map +1 -0
- package/lib/screens/auth/ServerConfigScreen.d.ts +18 -0
- package/lib/screens/auth/ServerConfigScreen.d.ts.map +1 -0
- package/lib/screens/auth/ServerConfigScreen.jsx +259 -0
- package/lib/screens/auth/ServerConfigScreen.jsx.map +1 -0
- package/lib/screens/auth/TermsOfServiceScreen.d.ts +30 -0
- package/lib/screens/auth/TermsOfServiceScreen.d.ts.map +1 -0
- package/lib/screens/auth/TermsOfServiceScreen.jsx +130 -0
- package/lib/screens/auth/TermsOfServiceScreen.jsx.map +1 -0
- package/lib/screens/auth/VerifyEmailScreen.d.ts +4 -0
- package/lib/screens/auth/VerifyEmailScreen.d.ts.map +1 -0
- package/lib/screens/auth/VerifyEmailScreen.jsx +249 -0
- package/lib/screens/auth/VerifyEmailScreen.jsx.map +1 -0
- package/lib/screens/auth/WelcomeScreen.d.ts +17 -0
- package/lib/screens/auth/WelcomeScreen.d.ts.map +1 -0
- package/lib/screens/auth/WelcomeScreen.jsx +58 -0
- package/lib/screens/auth/WelcomeScreen.jsx.map +1 -0
- package/lib/screens/auth/index.d.ts +19 -0
- package/lib/screens/auth/index.d.ts.map +1 -0
- package/lib/screens/auth/index.js +19 -0
- package/lib/screens/auth/index.js.map +1 -0
- package/lib/screens/index.d.ts +2 -0
- package/lib/screens/index.d.ts.map +1 -0
- package/lib/screens/index.js +2 -0
- package/lib/screens/index.js.map +1 -0
- package/lib/services/api-config.d.ts +87 -0
- package/lib/services/api-config.d.ts.map +1 -0
- package/lib/services/api-config.js +202 -0
- package/lib/services/api-config.js.map +1 -0
- package/lib/services/auth.service.d.ts +140 -0
- package/lib/services/auth.service.d.ts.map +1 -0
- package/lib/services/auth.service.js +376 -0
- package/lib/services/auth.service.js.map +1 -0
- package/lib/services/favicon.d.ts +46 -0
- package/lib/services/favicon.d.ts.map +1 -0
- package/lib/services/favicon.js +84 -0
- package/lib/services/favicon.js.map +1 -0
- package/lib/services/hibp-cache.d.ts +23 -0
- package/lib/services/hibp-cache.d.ts.map +1 -0
- package/lib/services/hibp-cache.js +56 -0
- package/lib/services/hibp-cache.js.map +1 -0
- package/lib/services/hibp.d.ts +28 -0
- package/lib/services/hibp.d.ts.map +1 -0
- package/lib/services/hibp.js +92 -0
- package/lib/services/hibp.js.map +1 -0
- package/lib/services/index.d.ts +8 -0
- package/lib/services/index.d.ts.map +1 -0
- package/lib/services/index.js +7 -0
- package/lib/services/index.js.map +1 -0
- package/lib/services/passkey.d.ts +10 -0
- package/lib/services/passkey.d.ts.map +1 -0
- package/lib/services/passkey.js +192 -0
- package/lib/services/passkey.js.map +1 -0
- package/lib/utils/api-fetch.d.ts +11 -0
- package/lib/utils/api-fetch.d.ts.map +1 -0
- package/lib/utils/api-fetch.js +52 -0
- package/lib/utils/api-fetch.js.map +1 -0
- package/lib/utils/clipboard.d.ts +31 -0
- package/lib/utils/clipboard.d.ts.map +1 -0
- package/lib/utils/clipboard.js +66 -0
- package/lib/utils/clipboard.js.map +1 -0
- package/lib/utils/cn.d.ts +9 -0
- package/lib/utils/cn.d.ts.map +1 -0
- package/lib/utils/cn.js +12 -0
- package/lib/utils/cn.js.map +1 -0
- package/lib/utils/debounce.d.ts +13 -0
- package/lib/utils/debounce.d.ts.map +1 -0
- package/lib/utils/debounce.js +28 -0
- package/lib/utils/debounce.js.map +1 -0
- package/lib/utils/error.d.ts +9 -0
- package/lib/utils/error.d.ts.map +1 -0
- package/lib/utils/error.js +11 -0
- package/lib/utils/error.js.map +1 -0
- package/lib/utils/fetch.d.ts +17 -0
- package/lib/utils/fetch.d.ts.map +1 -0
- package/lib/utils/fetch.js +29 -0
- package/lib/utils/fetch.js.map +1 -0
- package/lib/utils/http-error.d.ts +41 -0
- package/lib/utils/http-error.d.ts.map +1 -0
- package/lib/utils/http-error.js +63 -0
- package/lib/utils/http-error.js.map +1 -0
- package/lib/utils/index.d.ts +11 -0
- package/lib/utils/index.d.ts.map +1 -0
- package/lib/utils/index.js +11 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/palette.d.ts +46 -0
- package/lib/utils/palette.d.ts.map +1 -0
- package/lib/utils/palette.js +75 -0
- package/lib/utils/palette.js.map +1 -0
- package/lib/utils/password.d.ts +20 -0
- package/lib/utils/password.d.ts.map +1 -0
- package/lib/utils/password.js +51 -0
- package/lib/utils/password.js.map +1 -0
- package/lib/utils/settings-storage.d.ts +3 -0
- package/lib/utils/settings-storage.d.ts.map +1 -0
- package/lib/utils/settings-storage.js +62 -0
- package/lib/utils/settings-storage.js.map +1 -0
- package/lib/utils/validation.d.ts +29 -0
- package/lib/utils/validation.d.ts.map +1 -0
- package/lib/utils/validation.js +58 -0
- package/lib/utils/validation.js.map +1 -0
- package/package.json +204 -0
- package/src/components/__tests__/data-table.test.ts +94 -0
- package/src/components/__tests__/pagination.test.ts +73 -0
- package/src/components/__tests__/stat-card.test.ts +21 -0
- package/src/components/auth/LockOverlay.tsx +122 -0
- package/src/components/auth/PasswordStrengthMeter.tsx +96 -0
- package/src/components/auth/ProtectedRoute.tsx +91 -0
- package/src/components/auth/PwnedPasswordWarning.tsx +54 -0
- package/src/components/auth/index.ts +10 -0
- package/src/components/bottom-nav.tsx +99 -0
- package/src/components/button.tsx +144 -0
- package/src/components/card.tsx +82 -0
- package/src/components/checkbox.tsx +48 -0
- package/src/components/connection-settings.tsx +583 -0
- package/src/components/context-menu.tsx +95 -0
- package/src/components/data-table.tsx +223 -0
- package/src/components/dialog.tsx +376 -0
- package/src/components/dropdown-menu.tsx +120 -0
- package/src/components/entropy-boot-splash.tsx +114 -0
- package/src/components/entropy-mark-animated.tsx +260 -0
- package/src/components/entropy-mark-geometry.ts +11 -0
- package/src/components/entropy-mark-sequential.tsx +132 -0
- package/src/components/entropy-mark.tsx +135 -0
- package/src/components/error-boundary.tsx +70 -0
- package/src/components/index.ts +156 -0
- package/src/components/input.tsx +246 -0
- package/src/components/item-icon.tsx +111 -0
- package/src/components/label.tsx +25 -0
- package/src/components/legal-dialog.tsx +47 -0
- package/src/components/license-gate.tsx +28 -0
- package/src/components/logo.tsx +34 -0
- package/src/components/onboarding-wizard.tsx +353 -0
- package/src/components/pagination.tsx +154 -0
- package/src/components/password-generator.tsx +393 -0
- package/src/components/pin-pad.tsx +156 -0
- package/src/components/popover.tsx +38 -0
- package/src/components/profile/ProfileDialog.tsx +129 -0
- package/src/components/profile/ProfileTab.tsx +151 -0
- package/src/components/profile/SecurityTab.tsx +229 -0
- package/src/components/profile/index.ts +3 -0
- package/src/components/segmented-toggle.tsx +119 -0
- package/src/components/separator.tsx +41 -0
- package/src/components/server-settings.tsx +442 -0
- package/src/components/settings/AccountSection.tsx +76 -0
- package/src/components/settings/DangerZoneSection.tsx +37 -0
- package/src/components/settings/GeneralSection.tsx +39 -0
- package/src/components/settings/SupportSection.tsx +53 -0
- package/src/components/settings/index.ts +4 -0
- package/src/components/settings-row.tsx +126 -0
- package/src/components/skeleton.tsx +48 -0
- package/src/components/social-connections.tsx +55 -0
- package/src/components/stat-card.tsx +64 -0
- package/src/components/tag-chip.tsx +78 -0
- package/src/components/tag-multi-select.tsx +136 -0
- package/src/components/text.tsx +77 -0
- package/src/components/toast/ToastPortal.tsx +16 -0
- package/src/components/toast/ToastPortal.web.tsx +47 -0
- package/src/components/toast/index.ts +2 -0
- package/src/components/toast/toast-config.tsx +31 -0
- package/src/components/tooltip.tsx +30 -0
- package/src/components/totp-display.tsx +207 -0
- package/src/components/user-avatar.tsx +46 -0
- package/src/context/AppConfigContext.tsx +76 -0
- package/src/context/NavigationContext.tsx +75 -0
- package/src/context/NotificationContext.tsx +69 -0
- package/src/context/ThemeContext.tsx +83 -0
- package/src/context/__tests__/NavigationContext.test.tsx +53 -0
- package/src/context/index.ts +24 -0
- package/src/flags.ts +44 -0
- package/src/forms/form-error.tsx +20 -0
- package/src/forms/index.ts +2 -0
- package/src/forms/shake-field.tsx +52 -0
- package/src/hooks/__tests__/useUploadBlobUrl.test.tsx +77 -0
- package/src/hooks/index.ts +18 -0
- package/src/hooks/useAuth.tsx +567 -0
- package/src/hooks/useAutoLock.ts +110 -0
- package/src/hooks/useDebouncedValue.ts +32 -0
- package/src/hooks/useShakeAnimation.ts +42 -0
- package/src/hooks/useUploadBlobUrl.ts +75 -0
- package/src/index.ts +48 -0
- package/src/screens/auth/AccountPickerScreen.tsx +103 -0
- package/src/screens/auth/AuthScreen.tsx +941 -0
- package/src/screens/auth/ConsentScreen.tsx +118 -0
- package/src/screens/auth/ErrorScreen.tsx +96 -0
- package/src/screens/auth/ExpiredLinkScreen.tsx +87 -0
- package/src/screens/auth/ForgotPasswordScreen.tsx +182 -0
- package/src/screens/auth/ImportDataScreen.tsx +112 -0
- package/src/screens/auth/LoginScreen.tsx +484 -0
- package/src/screens/auth/MfaChallengeScreen.tsx +216 -0
- package/src/screens/auth/MfaEnrollScreen.tsx +388 -0
- package/src/screens/auth/PasskeyEnrollScreen.tsx +96 -0
- package/src/screens/auth/PrivacyPolicyScreen.tsx +249 -0
- package/src/screens/auth/RegisterScreen.tsx +430 -0
- package/src/screens/auth/ResetPasswordScreen.tsx +377 -0
- package/src/screens/auth/ServerConfigScreen.tsx +388 -0
- package/src/screens/auth/TermsOfServiceScreen.tsx +236 -0
- package/src/screens/auth/VerifyEmailScreen.tsx +310 -0
- package/src/screens/auth/WelcomeScreen.tsx +78 -0
- package/src/screens/auth/index.ts +36 -0
- package/src/screens/index.ts +1 -0
- package/src/services/__tests__/api-config.test.ts +67 -0
- package/src/services/__tests__/favicon.test.ts +88 -0
- package/src/services/__tests__/hibp-cache.test.ts +37 -0
- package/src/services/__tests__/hibp.test.ts +39 -0
- package/src/services/api-config.ts +260 -0
- package/src/services/auth.service.ts +498 -0
- package/src/services/favicon.ts +102 -0
- package/src/services/hibp-cache.ts +71 -0
- package/src/services/hibp.ts +120 -0
- package/src/services/index.ts +52 -0
- package/src/services/passkey.ts +213 -0
- package/src/types/external.d.ts +24 -0
- package/src/utils/__tests__/clipboard.test.ts +59 -0
- package/src/utils/__tests__/cn.test.ts +24 -0
- package/src/utils/__tests__/debounce.test.ts +42 -0
- package/src/utils/__tests__/error.test.ts +18 -0
- package/src/utils/__tests__/http-error.test.ts +33 -0
- package/src/utils/__tests__/palette.test.ts +22 -0
- package/src/utils/__tests__/password.test.ts +55 -0
- package/src/utils/__tests__/settings-storage.test.ts +15 -0
- package/src/utils/__tests__/validation.test.ts +52 -0
- package/src/utils/api-fetch.ts +61 -0
- package/src/utils/clipboard.ts +69 -0
- package/src/utils/cn.ts +12 -0
- package/src/utils/debounce.ts +33 -0
- package/src/utils/error.ts +10 -0
- package/src/utils/fetch.ts +33 -0
- package/src/utils/http-error.ts +81 -0
- package/src/utils/index.ts +23 -0
- package/src/utils/palette.ts +105 -0
- package/src/utils/password.ts +64 -0
- package/src/utils/settings-storage.ts +68 -0
- package/src/utils/validation.ts +71 -0
- package/styles/globals.css +262 -0
- package/tailwind-preset.js +163 -0
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
import React, { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from "react";
|
|
2
|
+
import { useNavigation } from "../context/NavigationContext";
|
|
3
|
+
import { useAppConfig } from "../context/AppConfigContext";
|
|
4
|
+
import AuthService from "../services/auth.service";
|
|
5
|
+
const AuthContext = createContext(undefined);
|
|
6
|
+
export function AuthProvider({ children, onAfterLogin, onAfterRegister, onBeforeLogout, onBeforeCheckAuth, loginWithPasskey: providedLoginWithPasskey, unlockWithPassword: providedUnlockWithPassword, onError, }) {
|
|
7
|
+
// Stable wrapper so `console.warn`-then-onError stays a single
|
|
8
|
+
// pattern across every silent catch in this provider.
|
|
9
|
+
const reportError = useCallback((error, context) => {
|
|
10
|
+
if (__DEV__) {
|
|
11
|
+
console.warn(`[auth:${context}]`, error);
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
onError?.(error, context);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
// Telemetry must never crash the auth flow.
|
|
18
|
+
}
|
|
19
|
+
}, [onError]);
|
|
20
|
+
const [user, setUser] = useState(null);
|
|
21
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
22
|
+
const [isAuthenticated, setIsAuthenticated] = useState(false);
|
|
23
|
+
const [error, setError] = useState(null);
|
|
24
|
+
const router = useNavigation();
|
|
25
|
+
const { routes } = useAppConfig();
|
|
26
|
+
const authCheckRef = useRef(false);
|
|
27
|
+
const sessionGenRef = useRef(0);
|
|
28
|
+
const clearError = useCallback(() => {
|
|
29
|
+
setError(null);
|
|
30
|
+
}, []);
|
|
31
|
+
const routeAfterAuth = useCallback((response, email) => {
|
|
32
|
+
const step = response.user.onboarding_step;
|
|
33
|
+
if (step === "email_verification") {
|
|
34
|
+
router.replace({ pathname: routes.verifyEmail, params: { email } });
|
|
35
|
+
}
|
|
36
|
+
else if (step === "mfa_enrollment") {
|
|
37
|
+
router.replace(routes.mfaEnroll);
|
|
38
|
+
}
|
|
39
|
+
else if (step === "import") {
|
|
40
|
+
router.replace(routes.importData);
|
|
41
|
+
}
|
|
42
|
+
else if (step === "complete" || step == null) {
|
|
43
|
+
router.replace(routes.home);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
// Unknown step (server added a new onboarding step the
|
|
47
|
+
// client doesn't recognize). Route home — the consumer's
|
|
48
|
+
// route guards will catch the still-incomplete state and
|
|
49
|
+
// either prompt an app update or re-route to welcome.
|
|
50
|
+
// Don't strand the user in the auth flow.
|
|
51
|
+
router.replace(routes.home);
|
|
52
|
+
}
|
|
53
|
+
}, [router, routes]);
|
|
54
|
+
const checkAuth = useCallback(async () => {
|
|
55
|
+
if (authCheckRef.current) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
authCheckRef.current = true;
|
|
59
|
+
const gen = ++sessionGenRef.current;
|
|
60
|
+
try {
|
|
61
|
+
setIsLoading(true);
|
|
62
|
+
const isAuth = await AuthService.isAuthenticated();
|
|
63
|
+
if (gen !== sessionGenRef.current) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (isAuth) {
|
|
67
|
+
const userData = await AuthService.getCurrentUser();
|
|
68
|
+
if (gen !== sessionGenRef.current) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (userData) {
|
|
72
|
+
// Unblock navigation immediately with cached data.
|
|
73
|
+
setUser(userData);
|
|
74
|
+
setIsAuthenticated(true);
|
|
75
|
+
setIsLoading(false);
|
|
76
|
+
authCheckRef.current = false;
|
|
77
|
+
// Refresh from the server in the background.
|
|
78
|
+
AuthService.refreshUserData()
|
|
79
|
+
.then((fresh) => {
|
|
80
|
+
if (fresh && gen === sessionGenRef.current) {
|
|
81
|
+
setUser(fresh);
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
.catch((e) => reportError(e, "background-refresh"));
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
await AuthService.logout();
|
|
89
|
+
if (gen !== sessionGenRef.current) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
setUser(null);
|
|
93
|
+
setIsAuthenticated(false);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
setUser(null);
|
|
98
|
+
setIsAuthenticated(false);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
catch (e) {
|
|
102
|
+
// Distinguish a transport failure (server unreachable on cold
|
|
103
|
+
// start) from a real auth failure. Falling through to
|
|
104
|
+
// "logged out" on transient network errors paints the welcome
|
|
105
|
+
// screen unjustly to a user whose cookie is still valid, then
|
|
106
|
+
// flips back the moment a request lands. Keep any persisted
|
|
107
|
+
// user record while we wait for the next probe.
|
|
108
|
+
if (gen !== sessionGenRef.current) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const persisted = await AuthService.getCurrentUser().catch(() => null);
|
|
112
|
+
if (gen !== sessionGenRef.current) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (persisted) {
|
|
116
|
+
setUser(persisted);
|
|
117
|
+
setIsAuthenticated(true);
|
|
118
|
+
reportError(e instanceof Error ? e : new Error(String(e)), "check-auth-transient");
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
setUser(null);
|
|
122
|
+
setIsAuthenticated(false);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
finally {
|
|
126
|
+
if (gen === sessionGenRef.current) {
|
|
127
|
+
setIsLoading(false);
|
|
128
|
+
}
|
|
129
|
+
authCheckRef.current = false;
|
|
130
|
+
}
|
|
131
|
+
}, [reportError]);
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
AuthService.loadServerUrlOverride()
|
|
134
|
+
.then(() => (onBeforeCheckAuth ? onBeforeCheckAuth() : undefined))
|
|
135
|
+
.catch((e) => reportError(e, "pre-check-auth"))
|
|
136
|
+
.then(() => checkAuth());
|
|
137
|
+
}, [checkAuth, onBeforeCheckAuth, reportError]);
|
|
138
|
+
const login = useCallback(async (email, password) => {
|
|
139
|
+
try {
|
|
140
|
+
setIsLoading(true);
|
|
141
|
+
setError(null);
|
|
142
|
+
const response = await AuthService.login(email, password);
|
|
143
|
+
if (onAfterLogin) {
|
|
144
|
+
try {
|
|
145
|
+
await onAfterLogin(password, response);
|
|
146
|
+
}
|
|
147
|
+
catch (hookErr) {
|
|
148
|
+
await AuthService.logout();
|
|
149
|
+
const message = hookErr instanceof Error ? hookErr.message : "Post-login hook failed";
|
|
150
|
+
// Deliberately do NOT attach `cause: hookErr` — the inner
|
|
151
|
+
// error from the consumer's post-login hook may carry
|
|
152
|
+
// key-derivation context (raw masterPassword references,
|
|
153
|
+
// server payloads) that would be exposed if downstream
|
|
154
|
+
// logging surfaces `err.cause` (Sentry, devtools, …).
|
|
155
|
+
throw new Error(message);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
setUser(response.user);
|
|
159
|
+
setIsAuthenticated(true);
|
|
160
|
+
routeAfterAuth(response, email);
|
|
161
|
+
}
|
|
162
|
+
catch (err) {
|
|
163
|
+
const message = err instanceof Error ? err.message : "Login failed";
|
|
164
|
+
setError(message);
|
|
165
|
+
throw err;
|
|
166
|
+
}
|
|
167
|
+
finally {
|
|
168
|
+
setIsLoading(false);
|
|
169
|
+
}
|
|
170
|
+
}, [onAfterLogin, routeAfterAuth]);
|
|
171
|
+
const register = useCallback(async (email, username, password, displayName) => {
|
|
172
|
+
try {
|
|
173
|
+
setIsLoading(true);
|
|
174
|
+
setError(null);
|
|
175
|
+
const response = await AuthService.register(email, username, password, displayName);
|
|
176
|
+
if (onAfterRegister) {
|
|
177
|
+
try {
|
|
178
|
+
await onAfterRegister(password, response);
|
|
179
|
+
}
|
|
180
|
+
catch (hookErr) {
|
|
181
|
+
await AuthService.logout();
|
|
182
|
+
const message = hookErr instanceof Error ? hookErr.message : "Post-register hook failed";
|
|
183
|
+
// No `cause` chain — see login() above for rationale.
|
|
184
|
+
throw new Error(message);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
setUser(response.user);
|
|
188
|
+
setIsAuthenticated(true);
|
|
189
|
+
routeAfterAuth(response, email);
|
|
190
|
+
}
|
|
191
|
+
catch (err) {
|
|
192
|
+
const message = err instanceof Error ? err.message : "Registration failed";
|
|
193
|
+
setError(message);
|
|
194
|
+
throw err;
|
|
195
|
+
}
|
|
196
|
+
finally {
|
|
197
|
+
setIsLoading(false);
|
|
198
|
+
}
|
|
199
|
+
}, [onAfterRegister, routeAfterAuth]);
|
|
200
|
+
const logout = useCallback(async () => {
|
|
201
|
+
sessionGenRef.current++;
|
|
202
|
+
setIsLoading(true);
|
|
203
|
+
// Flip React auth state FIRST so any in-flight queries that
|
|
204
|
+
// re-render against `user` / `isAuthenticated` see "logged out"
|
|
205
|
+
// immediately. Previously this happened after `AuthService.logout()`
|
|
206
|
+
// resolved, opening a window where the pre-logout hook had already
|
|
207
|
+
// torn down KeyManager / queryClient / WS but components still
|
|
208
|
+
// rendered as authenticated — any React-Query refetch in that
|
|
209
|
+
// window would hit a half-disassembled client.
|
|
210
|
+
setUser(null);
|
|
211
|
+
setIsAuthenticated(false);
|
|
212
|
+
if (onBeforeLogout) {
|
|
213
|
+
try {
|
|
214
|
+
await onBeforeLogout();
|
|
215
|
+
}
|
|
216
|
+
catch (e) {
|
|
217
|
+
// pre-logout hook errors are non-fatal — proceed to clear
|
|
218
|
+
// state. Telemetry sees it via the onError surface.
|
|
219
|
+
reportError(e, "pre-logout-hook");
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
router.replace(routes.login);
|
|
223
|
+
// Server-side revoke runs in the background. Failure is also
|
|
224
|
+
// surfaced through the onError hook so consumers can detect
|
|
225
|
+
// half-broken logouts (server session still alive after the
|
|
226
|
+
// user thinks they're gone).
|
|
227
|
+
try {
|
|
228
|
+
await AuthService.logout();
|
|
229
|
+
}
|
|
230
|
+
catch (e) {
|
|
231
|
+
reportError(e, "logout-revoke");
|
|
232
|
+
}
|
|
233
|
+
setIsLoading(false);
|
|
234
|
+
}, [onBeforeLogout, router, routes, reportError]);
|
|
235
|
+
const refreshUser = useCallback(async () => {
|
|
236
|
+
try {
|
|
237
|
+
const userData = await AuthService.refreshUserData();
|
|
238
|
+
if (userData) {
|
|
239
|
+
setUser(userData);
|
|
240
|
+
setIsAuthenticated(true);
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
setUser(null);
|
|
244
|
+
setIsAuthenticated(false);
|
|
245
|
+
router.replace(routes.login);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
catch {
|
|
249
|
+
// Refresh failed — try again on next interval.
|
|
250
|
+
}
|
|
251
|
+
}, [router, routes]);
|
|
252
|
+
const deleteAccount = useCallback(async (password) => {
|
|
253
|
+
sessionGenRef.current++;
|
|
254
|
+
try {
|
|
255
|
+
setIsLoading(true);
|
|
256
|
+
await AuthService.deleteAccount(password);
|
|
257
|
+
if (onBeforeLogout) {
|
|
258
|
+
try {
|
|
259
|
+
await onBeforeLogout();
|
|
260
|
+
}
|
|
261
|
+
catch {
|
|
262
|
+
// ignore
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
setUser(null);
|
|
266
|
+
setIsAuthenticated(false);
|
|
267
|
+
router.replace(routes.welcome);
|
|
268
|
+
}
|
|
269
|
+
catch (err) {
|
|
270
|
+
const message = err instanceof Error ? err.message : "Failed to delete account";
|
|
271
|
+
setError(message);
|
|
272
|
+
throw err;
|
|
273
|
+
}
|
|
274
|
+
finally {
|
|
275
|
+
setIsLoading(false);
|
|
276
|
+
}
|
|
277
|
+
}, [onBeforeLogout, router, routes]);
|
|
278
|
+
const loginWithPasskey = useCallback(async (email, signal) => {
|
|
279
|
+
if (!providedLoginWithPasskey) {
|
|
280
|
+
throw new Error("entropy-ui: loginWithPasskey() called but AuthProvider wasn't given a loginWithPasskey handler.");
|
|
281
|
+
}
|
|
282
|
+
try {
|
|
283
|
+
setIsLoading(true);
|
|
284
|
+
setError(null);
|
|
285
|
+
const result = await providedLoginWithPasskey(email, signal);
|
|
286
|
+
setUser(result.user);
|
|
287
|
+
setIsAuthenticated(true);
|
|
288
|
+
return result;
|
|
289
|
+
}
|
|
290
|
+
catch (err) {
|
|
291
|
+
const message = err instanceof Error ? err.message : "Passkey sign-in failed";
|
|
292
|
+
setError(message);
|
|
293
|
+
throw err;
|
|
294
|
+
}
|
|
295
|
+
finally {
|
|
296
|
+
setIsLoading(false);
|
|
297
|
+
}
|
|
298
|
+
}, [providedLoginWithPasskey]);
|
|
299
|
+
const unlockWithPassword = useCallback(async (password) => {
|
|
300
|
+
if (!providedUnlockWithPassword) {
|
|
301
|
+
throw new Error("entropy-ui: unlockWithPassword() called but AuthProvider wasn't given an unlockWithPassword handler.");
|
|
302
|
+
}
|
|
303
|
+
await providedUnlockWithPassword(password);
|
|
304
|
+
}, [providedUnlockWithPassword]);
|
|
305
|
+
const value = useMemo(() => ({
|
|
306
|
+
user,
|
|
307
|
+
isLoading,
|
|
308
|
+
isAuthenticated,
|
|
309
|
+
login,
|
|
310
|
+
loginWithPasskey,
|
|
311
|
+
unlockWithPassword,
|
|
312
|
+
register,
|
|
313
|
+
logout,
|
|
314
|
+
refreshUser,
|
|
315
|
+
deleteAccount,
|
|
316
|
+
checkAuth,
|
|
317
|
+
error,
|
|
318
|
+
clearError,
|
|
319
|
+
}), [
|
|
320
|
+
user,
|
|
321
|
+
isLoading,
|
|
322
|
+
isAuthenticated,
|
|
323
|
+
login,
|
|
324
|
+
loginWithPasskey,
|
|
325
|
+
unlockWithPassword,
|
|
326
|
+
register,
|
|
327
|
+
logout,
|
|
328
|
+
refreshUser,
|
|
329
|
+
deleteAccount,
|
|
330
|
+
checkAuth,
|
|
331
|
+
error,
|
|
332
|
+
clearError,
|
|
333
|
+
]);
|
|
334
|
+
return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
|
|
335
|
+
}
|
|
336
|
+
export function useAuth() {
|
|
337
|
+
const context = useContext(AuthContext);
|
|
338
|
+
if (context === undefined) {
|
|
339
|
+
throw new Error("useAuth must be used within an AuthProvider");
|
|
340
|
+
}
|
|
341
|
+
return context;
|
|
342
|
+
}
|
|
343
|
+
export function useRole(requiredRole) {
|
|
344
|
+
const { user } = useAuth();
|
|
345
|
+
if (!user) {
|
|
346
|
+
return false;
|
|
347
|
+
}
|
|
348
|
+
if (requiredRole === "User") {
|
|
349
|
+
return true;
|
|
350
|
+
}
|
|
351
|
+
return user.role === "Admin";
|
|
352
|
+
}
|
|
353
|
+
export function useRequireAuth(redirectTo) {
|
|
354
|
+
const { isAuthenticated, isLoading } = useAuth();
|
|
355
|
+
const router = useNavigation();
|
|
356
|
+
const { routes } = useAppConfig();
|
|
357
|
+
const target = redirectTo ?? routes.login;
|
|
358
|
+
useEffect(() => {
|
|
359
|
+
if (!isLoading && !isAuthenticated) {
|
|
360
|
+
router.replace(target);
|
|
361
|
+
}
|
|
362
|
+
}, [isAuthenticated, isLoading, router, target]);
|
|
363
|
+
return { isAuthenticated, isLoading };
|
|
364
|
+
}
|
|
365
|
+
export function useSession() {
|
|
366
|
+
const { user, refreshUser, isAuthenticated } = useAuth();
|
|
367
|
+
const intervalRef = useRef(undefined);
|
|
368
|
+
const refreshingRef = useRef(false);
|
|
369
|
+
useEffect(() => {
|
|
370
|
+
if (isAuthenticated) {
|
|
371
|
+
intervalRef.current = setInterval(() => {
|
|
372
|
+
if (refreshingRef.current) {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
refreshingRef.current = true;
|
|
376
|
+
refreshUser()
|
|
377
|
+
.catch((e) => {
|
|
378
|
+
// `useSession` lives outside the provider's
|
|
379
|
+
// reportError closure; auto-refresh failures only
|
|
380
|
+
// surface in dev. The `refreshUser()` impl itself
|
|
381
|
+
// reports via onError when wired.
|
|
382
|
+
if (__DEV__) {
|
|
383
|
+
console.warn("[auth:session-refresh-interval]", e);
|
|
384
|
+
}
|
|
385
|
+
})
|
|
386
|
+
.finally(() => {
|
|
387
|
+
refreshingRef.current = false;
|
|
388
|
+
});
|
|
389
|
+
}, 10 * 60 * 1000);
|
|
390
|
+
}
|
|
391
|
+
return () => {
|
|
392
|
+
if (intervalRef.current) {
|
|
393
|
+
clearInterval(intervalRef.current);
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
}, [isAuthenticated, refreshUser]);
|
|
397
|
+
return { user };
|
|
398
|
+
}
|
|
399
|
+
// Validators live in `utils/validation` and are re-exported via the
|
|
400
|
+
// utils barrel. Existing consumers that imported them from this module
|
|
401
|
+
// pull them from the package root barrel instead.
|
|
402
|
+
export { validateEmail, validatePassword, validateUsername } from "../utils/validation";
|
|
403
|
+
export default useAuth;
|
|
404
|
+
//# sourceMappingURL=useAuth.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAuth.jsx","sourceRoot":"","sources":["../../src/hooks/useAuth.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK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AG,EAAE;YACV,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;gBACxB,aAAa,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YACrC,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC,CAAC;IAEnC,OAAO,EAAE,IAAI,EAAE,CAAC;AAClB,CAAC;AAED,oEAAoE;AACpE,uEAAuE;AACvE,kDAAkD;AAClD,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAExF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface UseAutoLockOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Reports whether the session is currently "unlocked" (vault-style
|
|
4
|
+
* apps) or any other state where the auto-lock should still fire.
|
|
5
|
+
* Returning `false` short-circuits the lock call.
|
|
6
|
+
*/
|
|
7
|
+
isUnlocked: () => boolean;
|
|
8
|
+
/** Called when the lock should fire. App owns side-effects. */
|
|
9
|
+
onLock: () => void;
|
|
10
|
+
/** Reports whether auto-lock is enabled for this user (settings flag). */
|
|
11
|
+
isEnabled?: () => boolean | Promise<boolean>;
|
|
12
|
+
/** Idle threshold in milliseconds. Defaults to 10 minutes. */
|
|
13
|
+
idleLockMs?: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Auto-lock a session after a period of inactivity. Generic over the
|
|
17
|
+
* lock predicate — vault wires `KeyManager.isUnlocked` / `KeyManager.lock`,
|
|
18
|
+
* other apps wire their own state. Web uses an idle-timer only; native
|
|
19
|
+
* additionally locks immediately when the app goes to the background.
|
|
20
|
+
*/
|
|
21
|
+
export declare function useAutoLock(options: UseAutoLockOptions): void;
|
|
22
|
+
//# sourceMappingURL=useAutoLock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAutoLock.d.ts","sourceRoot":"","sources":["../../src/hooks/useAutoLock.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,UAAU,EAAE,MAAM,OAAO,CAAC;IAC1B,+DAA+D;IAC/D,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,0EAA0E;IAC1E,SAAS,CAAC,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7C,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAmF7D"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { AppState as RNAppState, Platform } from "react-native";
|
|
3
|
+
const DEFAULT_IDLE_LOCK_MS = 10 * 60 * 1000;
|
|
4
|
+
/**
|
|
5
|
+
* Auto-lock a session after a period of inactivity. Generic over the
|
|
6
|
+
* lock predicate — vault wires `KeyManager.isUnlocked` / `KeyManager.lock`,
|
|
7
|
+
* other apps wire their own state. Web uses an idle-timer only; native
|
|
8
|
+
* additionally locks immediately when the app goes to the background.
|
|
9
|
+
*/
|
|
10
|
+
export function useAutoLock(options) {
|
|
11
|
+
const { isUnlocked, onLock, isEnabled, idleLockMs = DEFAULT_IDLE_LOCK_MS } = options;
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
let idleTimer = null;
|
|
14
|
+
let lastActivityAt = Date.now();
|
|
15
|
+
const lockIfEnabled = () => {
|
|
16
|
+
if (idleTimer !== null) {
|
|
17
|
+
clearTimeout(idleTimer);
|
|
18
|
+
idleTimer = null;
|
|
19
|
+
}
|
|
20
|
+
if (!isUnlocked()) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
Promise.resolve(isEnabled ? isEnabled() : true)
|
|
24
|
+
.then((enabled) => {
|
|
25
|
+
if (enabled && isUnlocked()) {
|
|
26
|
+
onLock();
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
.catch(() => { });
|
|
30
|
+
};
|
|
31
|
+
const armIdleTimer = () => {
|
|
32
|
+
if (idleTimer !== null) {
|
|
33
|
+
clearTimeout(idleTimer);
|
|
34
|
+
}
|
|
35
|
+
const remaining = idleLockMs - (Date.now() - lastActivityAt);
|
|
36
|
+
if (remaining <= 0) {
|
|
37
|
+
lockIfEnabled();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
idleTimer = setTimeout(lockIfEnabled, remaining);
|
|
41
|
+
};
|
|
42
|
+
const onActivity = () => {
|
|
43
|
+
lastActivityAt = Date.now();
|
|
44
|
+
armIdleTimer();
|
|
45
|
+
};
|
|
46
|
+
// On web, RN Web's AppState mirrors document visibility — tab-hidden
|
|
47
|
+
// becomes 'background', which would otherwise fire an immediate lock.
|
|
48
|
+
// Only treat 'background' as a lock signal on real native platforms.
|
|
49
|
+
const subscription = RNAppState.addEventListener("change", (nextState) => {
|
|
50
|
+
if (nextState === "background" && Platform.OS !== "web") {
|
|
51
|
+
lockIfEnabled();
|
|
52
|
+
}
|
|
53
|
+
else if (nextState === "active") {
|
|
54
|
+
armIdleTimer();
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
const cleanups = [];
|
|
58
|
+
if (Platform.OS === "web" && typeof document !== "undefined") {
|
|
59
|
+
const onVisibility = () => {
|
|
60
|
+
if (document.visibilityState === "visible") {
|
|
61
|
+
armIdleTimer();
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
document.addEventListener("visibilitychange", onVisibility);
|
|
65
|
+
cleanups.push(() => document.removeEventListener("visibilitychange", onVisibility));
|
|
66
|
+
const activityEvents = ["mousemove", "mousedown", "keydown", "touchstart", "scroll"];
|
|
67
|
+
for (const e of activityEvents) {
|
|
68
|
+
window.addEventListener(e, onActivity, { passive: true });
|
|
69
|
+
cleanups.push(() => window.removeEventListener(e, onActivity));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
armIdleTimer();
|
|
73
|
+
return () => {
|
|
74
|
+
subscription.remove();
|
|
75
|
+
for (const fn of cleanups) {
|
|
76
|
+
fn();
|
|
77
|
+
}
|
|
78
|
+
if (idleTimer !== null) {
|
|
79
|
+
clearTimeout(idleTimer);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
83
|
+
}, []);
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=useAutoLock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAutoLock.js","sourceRoot":"","sources":["../../src/hooks/useAutoLock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEhE,MAAM,oBAAoB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAiB5C;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,OAA2B;IACrD,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,GAAG,oBAAoB,EAAE,GAAG,OAAO,CAAC;IAErF,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,GAAyC,IAAI,CAAC;QAC3D,IAAI,cAAc,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAEhC,MAAM,aAAa,GAAG,GAAG,EAAE;YACzB,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;gBACvB,YAAY,CAAC,SAAS,CAAC,CAAC;gBACxB,SAAS,GAAG,IAAI,CAAC;YACnB,CAAC;YACD,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC;gBAClB,OAAO;YACT,CAAC;YACD,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;iBAC5C,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;gBAChB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e,KAAK,SAAS,EAAE,CAAC;oBAC3C,YAAY,EAAE,CAAC;gBACjB,CAAC;YACH,CAAC,CAAC;YACF,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,YAAY,CAAC,CAAC;YAC5D,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,YAAY,CAAC,CAAC,CAAC;YAEpF,MAAM,cAAc,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,CAAU,CAAC;YAC9F,KAAK,MAAM,CAAC,IAAI,cAAc,EAAE,CAAC;gBAC/B,MAAM,CAAC,gBAAgB,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC1D,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC;YACjE,CAAC;QACH,CAAC;QAED,YAAY,EAAE,CAAC;QAEf,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,MAAM,EAAE,CAAC;YACtB,KAAK,MAAM,EAAE,IAAI,QAAQ,EAAE,CAAC;gBAC1B,EAAE,EAAE,CAAC;YACP,CAAC;YACD,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;gBACvB,YAAY,CAAC,SAAS,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC,CAAC;QACF,uDAAuD;IACzD,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a debounced copy of `value` that only updates after `value` has
|
|
3
|
+
* stopped changing for `delayMs`. Use it to keep a controlled input
|
|
4
|
+
* responsive (bind the input to the raw value) while throttling the
|
|
5
|
+
* expensive work it drives — a network query, a react-query cache key, a
|
|
6
|
+
* filter over a large list.
|
|
7
|
+
*
|
|
8
|
+
* The pending update is cancelled on unmount and whenever `value` changes
|
|
9
|
+
* again, so a fast typer never fires an update per keystroke and there is no
|
|
10
|
+
* setState-after-unmount on the trailing edge.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const [term, setTerm] = useState("");
|
|
14
|
+
* const debouncedTerm = useDebouncedValue(term, 300);
|
|
15
|
+
* // <Input value={term} onChangeText={setTerm} /> — instant feedback
|
|
16
|
+
* // useQuery({ queryKey: ["search", debouncedTerm], ... }) — one fetch per pause
|
|
17
|
+
*/
|
|
18
|
+
export declare function useDebouncedValue<T>(value: T, delayMs?: number): T;
|
|
19
|
+
//# sourceMappingURL=useDebouncedValue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDebouncedValue.d.ts","sourceRoot":"","sources":["../../src/hooks/useDebouncedValue.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,SAAM,GAAG,CAAC,CAU/D"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { debounce } from "../utils/debounce";
|
|
3
|
+
/**
|
|
4
|
+
* Returns a debounced copy of `value` that only updates after `value` has
|
|
5
|
+
* stopped changing for `delayMs`. Use it to keep a controlled input
|
|
6
|
+
* responsive (bind the input to the raw value) while throttling the
|
|
7
|
+
* expensive work it drives — a network query, a react-query cache key, a
|
|
8
|
+
* filter over a large list.
|
|
9
|
+
*
|
|
10
|
+
* The pending update is cancelled on unmount and whenever `value` changes
|
|
11
|
+
* again, so a fast typer never fires an update per keystroke and there is no
|
|
12
|
+
* setState-after-unmount on the trailing edge.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const [term, setTerm] = useState("");
|
|
16
|
+
* const debouncedTerm = useDebouncedValue(term, 300);
|
|
17
|
+
* // <Input value={term} onChangeText={setTerm} /> — instant feedback
|
|
18
|
+
* // useQuery({ queryKey: ["search", debouncedTerm], ... }) — one fetch per pause
|
|
19
|
+
*/
|
|
20
|
+
export function useDebouncedValue(value, delayMs = 300) {
|
|
21
|
+
const [debounced, setDebounced] = useState(value);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const update = debounce((next) => setDebounced(next), delayMs);
|
|
24
|
+
update(value);
|
|
25
|
+
return update.cancel;
|
|
26
|
+
}, [value, delayMs]);
|
|
27
|
+
return debounced;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=useDebouncedValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDebouncedValue.js","sourceRoot":"","sources":["../../src/hooks/useDebouncedValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,iBAAiB,CAAI,KAAQ,EAAE,OAAO,GAAG,GAAG;IAC1D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAElD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,IAAO,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;QAClE,MAAM,CAAC,KAAK,CAAC,CAAC;QACd,OAAO,MAAM,CAAC,MAAM,CAAC;IACvB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;IAErB,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Horizontal-shake animation for invalid-input feedback. Wrap the target
|
|
3
|
+
* in an `Animated.View` with the returned `animatedStyle`, then call
|
|
4
|
+
* `shake()` to trigger.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useShakeAnimation(): {
|
|
7
|
+
animatedStyle: import("react-native-reanimated/lib/typescript/hook/commonTypes").AnimatedStyleHandle<{
|
|
8
|
+
transform: {
|
|
9
|
+
rotate: string;
|
|
10
|
+
}[];
|
|
11
|
+
}>;
|
|
12
|
+
flashStyle: import("react-native-reanimated/lib/typescript/hook/commonTypes").AnimatedStyleHandle<{
|
|
13
|
+
opacity: number;
|
|
14
|
+
}>;
|
|
15
|
+
shake: () => void;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=useShakeAnimation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useShakeAnimation.d.ts","sourceRoot":"","sources":["../../src/hooks/useShakeAnimation.ts"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,wBAAgB,iBAAiB;;;;;;;;;;EA4BhC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useSharedValue, useAnimatedStyle, withSequence, withTiming, Easing, } from "react-native-reanimated";
|
|
2
|
+
/**
|
|
3
|
+
* Horizontal-shake animation for invalid-input feedback. Wrap the target
|
|
4
|
+
* in an `Animated.View` with the returned `animatedStyle`, then call
|
|
5
|
+
* `shake()` to trigger.
|
|
6
|
+
*/
|
|
7
|
+
export function useShakeAnimation() {
|
|
8
|
+
const rotation = useSharedValue(0);
|
|
9
|
+
const flash = useSharedValue(0);
|
|
10
|
+
const animatedStyle = useAnimatedStyle(() => ({
|
|
11
|
+
transform: [{ rotate: `${rotation.value}deg` }],
|
|
12
|
+
}));
|
|
13
|
+
const flashStyle = useAnimatedStyle(() => ({
|
|
14
|
+
opacity: flash.value,
|
|
15
|
+
}));
|
|
16
|
+
const shake = () => {
|
|
17
|
+
rotation.value = withSequence(withTiming(-2.5, { duration: 55, easing: Easing.linear }), withTiming(2.5, { duration: 55, easing: Easing.linear }), withTiming(-2, { duration: 55, easing: Easing.linear }), withTiming(2, { duration: 55, easing: Easing.linear }), withTiming(-1, { duration: 45, easing: Easing.linear }), withTiming(0, { duration: 45, easing: Easing.linear }));
|
|
18
|
+
flash.value = withSequence(withTiming(0.18, { duration: 120, easing: Easing.out(Easing.quad) }), withTiming(0, { duration: 380, easing: Easing.out(Easing.quad) }));
|
|
19
|
+
};
|
|
20
|
+
return { animatedStyle, flashStyle, shake };
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=useShakeAnimation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useShakeAnimation.js","sourceRoot":"","sources":["../../src/hooks/useShakeAnimation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,MAAM,GACP,MAAM,yBAAyB,CAAC;AAEjC;;;;GAIG;AACH,MAAM,UAAU,iBAAiB;IAC/B,MAAM,QAAQ,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,KAAK,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC;IAEhC,MAAM,aAAa,GAAG,gBAAgB,CAAC,GAAG,EAAE,CAAC,CAAC;QAC5C,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC,KAAK,KAAK,EAAE,CAAC;KAChD,CAAC,CAAC,CAAC;IAEJ,MAAM,UAAU,GAAG,gBAAgB,CAAC,GAAG,EAAE,CAAC,CAAC;QACzC,OAAO,EAAE,KAAK,CAAC,KAAK;KACrB,CAAC,CAAC,CAAC;IAEJ,MAAM,KAAK,GAAG,GAAG,EAAE;QACjB,QAAQ,CAAC,KAAK,GAAG,YAAY,CAC3B,UAAU,CAAC,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,EACzD,UAAU,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,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