@payez/next-mvp 3.0.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/README.md +782 -0
- package/dist/api/auth-handler.d.ts +67 -0
- package/dist/api/auth-handler.js +397 -0
- package/dist/api/index.d.ts +10 -0
- package/dist/api/index.js +19 -0
- package/dist/api-handlers/account/change-password.d.ts +9 -0
- package/dist/api-handlers/account/change-password.js +112 -0
- package/dist/api-handlers/account/masked-info.d.ts +2 -0
- package/dist/api-handlers/account/masked-info.js +41 -0
- package/dist/api-handlers/account/profile.d.ts +3 -0
- package/dist/api-handlers/account/profile.js +63 -0
- package/dist/api-handlers/account/recovery/initiate.d.ts +2 -0
- package/dist/api-handlers/account/recovery/initiate.js +26 -0
- package/dist/api-handlers/account/recovery/send-code.d.ts +2 -0
- package/dist/api-handlers/account/recovery/send-code.js +28 -0
- package/dist/api-handlers/account/recovery/verify-code.d.ts +2 -0
- package/dist/api-handlers/account/recovery/verify-code.js +28 -0
- package/dist/api-handlers/account/reset-password.d.ts +2 -0
- package/dist/api-handlers/account/reset-password.js +26 -0
- package/dist/api-handlers/account/send-code.d.ts +24 -0
- package/dist/api-handlers/account/send-code.js +60 -0
- package/dist/api-handlers/account/update-phone.d.ts +27 -0
- package/dist/api-handlers/account/update-phone.js +64 -0
- package/dist/api-handlers/account/validate-password.d.ts +17 -0
- package/dist/api-handlers/account/validate-password.js +81 -0
- package/dist/api-handlers/account/verify-email.d.ts +26 -0
- package/dist/api-handlers/account/verify-email.js +106 -0
- package/dist/api-handlers/account/verify-sms.d.ts +26 -0
- package/dist/api-handlers/account/verify-sms.js +106 -0
- package/dist/api-handlers/admin/analytics.d.ts +20 -0
- package/dist/api-handlers/admin/analytics.js +379 -0
- package/dist/api-handlers/admin/audit.d.ts +20 -0
- package/dist/api-handlers/admin/audit.js +214 -0
- package/dist/api-handlers/admin/index.d.ts +21 -0
- package/dist/api-handlers/admin/index.js +41 -0
- package/dist/api-handlers/admin/redis-sessions.d.ts +36 -0
- package/dist/api-handlers/admin/redis-sessions.js +204 -0
- package/dist/api-handlers/admin/sessions.d.ts +21 -0
- package/dist/api-handlers/admin/sessions.js +284 -0
- package/dist/api-handlers/admin/site-logs.d.ts +46 -0
- package/dist/api-handlers/admin/site-logs.js +318 -0
- package/dist/api-handlers/admin/users.d.ts +20 -0
- package/dist/api-handlers/admin/users.js +222 -0
- package/dist/api-handlers/admin/vibe-data.d.ts +80 -0
- package/dist/api-handlers/admin/vibe-data.js +268 -0
- package/dist/api-handlers/anon/preferences.d.ts +37 -0
- package/dist/api-handlers/anon/preferences.js +96 -0
- package/dist/api-handlers/auth/jwks.d.ts +2 -0
- package/dist/api-handlers/auth/jwks.js +24 -0
- package/dist/api-handlers/auth/login.d.ts +42 -0
- package/dist/api-handlers/auth/login.js +178 -0
- package/dist/api-handlers/auth/refresh.d.ts +74 -0
- package/dist/api-handlers/auth/refresh.js +635 -0
- package/dist/api-handlers/auth/signout.d.ts +37 -0
- package/dist/api-handlers/auth/signout.js +187 -0
- package/dist/api-handlers/auth/status.d.ts +8 -0
- package/dist/api-handlers/auth/status.js +26 -0
- package/dist/api-handlers/auth/update-session.d.ts +37 -0
- package/dist/api-handlers/auth/update-session.js +95 -0
- package/dist/api-handlers/auth/validate.d.ts +6 -0
- package/dist/api-handlers/auth/validate.js +43 -0
- package/dist/api-handlers/auth/verify-code.d.ts +43 -0
- package/dist/api-handlers/auth/verify-code.js +94 -0
- package/dist/api-handlers/session/refresh-viability.d.ts +14 -0
- package/dist/api-handlers/session/refresh-viability.js +39 -0
- package/dist/api-handlers/session/viability.d.ts +13 -0
- package/dist/api-handlers/session/viability.js +146 -0
- package/dist/api-handlers/test/force-expire.d.ts +23 -0
- package/dist/api-handlers/test/force-expire.js +65 -0
- package/dist/auth/auth-decision.d.ts +39 -0
- package/dist/auth/auth-decision.js +182 -0
- package/dist/auth/auth-options.d.ts +57 -0
- package/dist/auth/auth-options.js +213 -0
- package/dist/auth/callbacks/index.d.ts +6 -0
- package/dist/auth/callbacks/index.js +12 -0
- package/dist/auth/callbacks/jwt.d.ts +45 -0
- package/dist/auth/callbacks/jwt.js +305 -0
- package/dist/auth/callbacks/session.d.ts +60 -0
- package/dist/auth/callbacks/session.js +170 -0
- package/dist/auth/callbacks/signin.d.ts +23 -0
- package/dist/auth/callbacks/signin.js +44 -0
- package/dist/auth/events/index.d.ts +4 -0
- package/dist/auth/events/index.js +8 -0
- package/dist/auth/events/signout.d.ts +17 -0
- package/dist/auth/events/signout.js +32 -0
- package/dist/auth/providers/credentials.d.ts +32 -0
- package/dist/auth/providers/credentials.js +223 -0
- package/dist/auth/providers/index.d.ts +5 -0
- package/dist/auth/providers/index.js +21 -0
- package/dist/auth/providers/oauth.d.ts +26 -0
- package/dist/auth/providers/oauth.js +105 -0
- package/dist/auth/route-config.d.ts +66 -0
- package/dist/auth/route-config.js +190 -0
- package/dist/auth/types/auth-types.d.ts +417 -0
- package/dist/auth/types/auth-types.js +53 -0
- package/dist/auth/types/index.d.ts +6 -0
- package/dist/auth/types/index.js +22 -0
- package/dist/auth/unauthenticated-routes.d.ts +1 -0
- package/dist/auth/unauthenticated-routes.js +19 -0
- package/dist/auth/utils/idp-client.d.ts +94 -0
- package/dist/auth/utils/idp-client.js +383 -0
- package/dist/auth/utils/index.d.ts +5 -0
- package/dist/auth/utils/index.js +21 -0
- package/dist/auth/utils/token-utils.d.ts +84 -0
- package/dist/auth/utils/token-utils.js +219 -0
- package/dist/client/AuthContext.d.ts +19 -0
- package/dist/client/AuthContext.js +112 -0
- package/dist/client/fetch-with-auth.d.ts +11 -0
- package/dist/client/fetch-with-auth.js +44 -0
- package/dist/client/fetchWithSession.d.ts +3 -0
- package/dist/client/fetchWithSession.js +24 -0
- package/dist/client/index.d.ts +9 -0
- package/dist/client/index.js +20 -0
- package/dist/client/useAnonSession.d.ts +36 -0
- package/dist/client/useAnonSession.js +99 -0
- package/dist/components/SessionSync.d.ts +13 -0
- package/dist/components/SessionSync.js +119 -0
- package/dist/components/SignalRHealthCheck.d.ts +10 -0
- package/dist/components/SignalRHealthCheck.js +97 -0
- package/dist/components/account/UserAvatarMenu.d.ts +20 -0
- package/dist/components/account/UserAvatarMenu.js +80 -0
- package/dist/components/account/index.d.ts +7 -0
- package/dist/components/account/index.js +10 -0
- package/dist/components/admin/AlertSettingsTab.d.ts +48 -0
- package/dist/components/admin/AlertSettingsTab.js +351 -0
- package/dist/components/admin/AnalyticsTab.d.ts +22 -0
- package/dist/components/admin/AnalyticsTab.js +167 -0
- package/dist/components/admin/DataBrowserTab.d.ts +19 -0
- package/dist/components/admin/DataBrowserTab.js +252 -0
- package/dist/components/admin/LoggingSettingsTab.d.ts +73 -0
- package/dist/components/admin/LoggingSettingsTab.js +339 -0
- package/dist/components/admin/SessionsTab.d.ts +37 -0
- package/dist/components/admin/SessionsTab.js +165 -0
- package/dist/components/admin/StatsTab.d.ts +53 -0
- package/dist/components/admin/StatsTab.js +161 -0
- package/dist/components/admin/VibeAdminContext.d.ts +32 -0
- package/dist/components/admin/VibeAdminContext.js +38 -0
- package/dist/components/admin/VibeAdminLayout.d.ts +11 -0
- package/dist/components/admin/VibeAdminLayout.js +69 -0
- package/dist/components/admin/index.d.ts +29 -0
- package/dist/components/admin/index.js +44 -0
- package/dist/components/auth/FederatedAuthSection.d.ts +8 -0
- package/dist/components/auth/FederatedAuthSection.js +45 -0
- package/dist/components/auth/ModeAwareLoginPage.d.ts +10 -0
- package/dist/components/auth/ModeAwareLoginPage.js +42 -0
- package/dist/components/auth/ModeAwareSignupPage.d.ts +9 -0
- package/dist/components/auth/ModeAwareSignupPage.js +78 -0
- package/dist/components/auth/TraditionalAuthSection.d.ts +14 -0
- package/dist/components/auth/TraditionalAuthSection.js +20 -0
- package/dist/components/recovery/CompleteStep.d.ts +5 -0
- package/dist/components/recovery/CompleteStep.js +8 -0
- package/dist/components/recovery/InitiateRecoveryStep.d.ts +8 -0
- package/dist/components/recovery/InitiateRecoveryStep.js +20 -0
- package/dist/components/recovery/SelectMethodStep.d.ts +8 -0
- package/dist/components/recovery/SelectMethodStep.js +8 -0
- package/dist/components/recovery/SetPasswordStep.d.ts +6 -0
- package/dist/components/recovery/SetPasswordStep.js +20 -0
- package/dist/components/recovery/VerifyCodeStep.d.ts +10 -0
- package/dist/components/recovery/VerifyCodeStep.js +24 -0
- package/dist/components/reserved/ReservedRecoveryWarning.d.ts +38 -0
- package/dist/components/reserved/ReservedRecoveryWarning.js +92 -0
- package/dist/components/reserved/ReservedStatusBox.d.ts +30 -0
- package/dist/components/reserved/ReservedStatusBox.js +71 -0
- package/dist/components/ui/BetaBadge.d.ts +29 -0
- package/dist/components/ui/BetaBadge.js +38 -0
- package/dist/components/ui/Footer.d.ts +37 -0
- package/dist/components/ui/Footer.js +41 -0
- package/dist/config/env.d.ts +66 -0
- package/dist/config/env.js +57 -0
- package/dist/config/logger.d.ts +57 -0
- package/dist/config/logger.js +73 -0
- package/dist/config/logging-config.d.ts +30 -0
- package/dist/config/logging-config.js +122 -0
- package/dist/config/unauthenticated-routes.d.ts +17 -0
- package/dist/config/unauthenticated-routes.js +24 -0
- package/dist/config/vibe-log-transport.d.ts +79 -0
- package/dist/config/vibe-log-transport.js +203 -0
- package/dist/edge/internal-api-url.d.ts +53 -0
- package/dist/edge/internal-api-url.js +63 -0
- package/dist/edge/middleware.d.ts +14 -0
- package/dist/edge/middleware.js +32 -0
- package/dist/hooks/useAuth.d.ts +23 -0
- package/dist/hooks/useAuth.js +81 -0
- package/dist/hooks/useAuthSettings.d.ts +59 -0
- package/dist/hooks/useAuthSettings.js +93 -0
- package/dist/hooks/useAvailableProviders.d.ts +45 -0
- package/dist/hooks/useAvailableProviders.js +108 -0
- package/dist/hooks/usePasswordValidation.d.ts +27 -0
- package/dist/hooks/usePasswordValidation.js +102 -0
- package/dist/hooks/useProfile.d.ts +15 -0
- package/dist/hooks/useProfile.js +59 -0
- package/dist/hooks/usePublicAuthSettings.d.ts +56 -0
- package/dist/hooks/usePublicAuthSettings.js +131 -0
- package/dist/hooks/useSessionExpiration.d.ts +57 -0
- package/dist/hooks/useSessionExpiration.js +72 -0
- package/dist/hooks/useViabilitySession.d.ts +75 -0
- package/dist/hooks/useViabilitySession.js +268 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +54 -0
- package/dist/lib/anon-session.d.ts +74 -0
- package/dist/lib/anon-session.js +169 -0
- package/dist/lib/api-handler.d.ts +123 -0
- package/dist/lib/api-handler.js +478 -0
- package/dist/lib/app-slug.d.ts +95 -0
- package/dist/lib/app-slug.js +172 -0
- package/dist/lib/demo-mode.d.ts +6 -0
- package/dist/lib/demo-mode.js +16 -0
- package/dist/lib/geolocation.d.ts +64 -0
- package/dist/lib/geolocation.js +235 -0
- package/dist/lib/idp-client-config.d.ts +75 -0
- package/dist/lib/idp-client-config.js +351 -0
- package/dist/lib/idp-fetch.d.ts +14 -0
- package/dist/lib/idp-fetch.js +91 -0
- package/dist/lib/internal-api.d.ts +87 -0
- package/dist/lib/internal-api.js +122 -0
- package/dist/lib/jwt-decode-client.d.ts +10 -0
- package/dist/lib/jwt-decode-client.js +46 -0
- package/dist/lib/jwt-decode.d.ts +48 -0
- package/dist/lib/jwt-decode.js +57 -0
- package/dist/lib/nextauth-secret.d.ts +10 -0
- package/dist/lib/nextauth-secret.js +104 -0
- package/dist/lib/rate-limit-service.d.ts +23 -0
- package/dist/lib/rate-limit-service.js +6 -0
- package/dist/lib/redis.d.ts +5 -0
- package/dist/lib/redis.js +28 -0
- package/dist/lib/refresh-token-validator.d.ts +13 -0
- package/dist/lib/refresh-token-validator.js +117 -0
- package/dist/lib/roles.d.ts +145 -0
- package/dist/lib/roles.js +168 -0
- package/dist/lib/secret-validation.d.ts +4 -0
- package/dist/lib/secret-validation.js +14 -0
- package/dist/lib/session-store.d.ts +166 -0
- package/dist/lib/session-store.js +537 -0
- package/dist/lib/session.d.ts +21 -0
- package/dist/lib/session.js +26 -0
- package/dist/lib/site-logger.d.ts +214 -0
- package/dist/lib/site-logger.js +210 -0
- package/dist/lib/standardized-client-api.d.ts +161 -0
- package/dist/lib/standardized-client-api.js +786 -0
- package/dist/lib/startup-init.d.ts +40 -0
- package/dist/lib/startup-init.js +261 -0
- package/dist/lib/test-aware-get-token.d.ts +2 -0
- package/dist/lib/test-aware-get-token.js +81 -0
- package/dist/lib/token-expiry.d.ts +14 -0
- package/dist/lib/token-expiry.js +39 -0
- package/dist/lib/token-lifecycle.d.ts +52 -0
- package/dist/lib/token-lifecycle.js +398 -0
- package/dist/lib/types/api-responses.d.ts +128 -0
- package/dist/lib/types/api-responses.js +171 -0
- package/dist/lib/user-agent-parser.d.ts +50 -0
- package/dist/lib/user-agent-parser.js +220 -0
- package/dist/logging/api/admin-analytics.d.ts +3 -0
- package/dist/logging/api/admin-analytics.js +45 -0
- package/dist/logging/api/audit-log.d.ts +3 -0
- package/dist/logging/api/audit-log.js +52 -0
- package/dist/logging/components/AdminAnalyticsLayout.d.ts +10 -0
- package/dist/logging/components/AdminAnalyticsLayout.js +11 -0
- package/dist/logging/components/AuditLogViewer.d.ts +7 -0
- package/dist/logging/components/AuditLogViewer.js +51 -0
- package/dist/logging/components/ErrorMetricsCard.d.ts +7 -0
- package/dist/logging/components/ErrorMetricsCard.js +16 -0
- package/dist/logging/components/HealthMetricsCard.d.ts +7 -0
- package/dist/logging/components/HealthMetricsCard.js +19 -0
- package/dist/logging/hooks/useAdminAnalytics.d.ts +24 -0
- package/dist/logging/hooks/useAdminAnalytics.js +22 -0
- package/dist/logging/hooks/useAuditLog.d.ts +6 -0
- package/dist/logging/hooks/useAuditLog.js +25 -0
- package/dist/logging/hooks/useErrorMetrics.d.ts +6 -0
- package/dist/logging/hooks/useErrorMetrics.js +38 -0
- package/dist/logging/hooks/useHealthMetrics.d.ts +6 -0
- package/dist/logging/hooks/useHealthMetrics.js +41 -0
- package/dist/logging/index.d.ts +11 -0
- package/dist/logging/index.js +40 -0
- package/dist/logging/types/analytics.d.ts +68 -0
- package/dist/logging/types/analytics.js +3 -0
- package/dist/logging/types/audit.d.ts +29 -0
- package/dist/logging/types/audit.js +2 -0
- package/dist/logging/types/index.d.ts +2 -0
- package/dist/logging/types/index.js +19 -0
- package/dist/middleware/auth-decision.d.ts +33 -0
- package/dist/middleware/auth-decision.js +65 -0
- package/dist/middleware/create-middleware.d.ts +100 -0
- package/dist/middleware/create-middleware.js +445 -0
- package/dist/middleware/rbac-check.d.ts +44 -0
- package/dist/middleware/rbac-check.js +191 -0
- package/dist/middleware/twofa-presets.d.ts +134 -0
- package/dist/middleware/twofa-presets.js +175 -0
- package/dist/models/DecodedAccessToken.d.ts +17 -0
- package/dist/models/DecodedAccessToken.js +2 -0
- package/dist/models/SessionModel.d.ts +122 -0
- package/dist/models/SessionModel.js +136 -0
- package/dist/pages/admin-login/page.d.ts +31 -0
- package/dist/pages/admin-login/page.js +83 -0
- package/dist/pages/admin-roles/RolesAdminPage.d.ts +15 -0
- package/dist/pages/admin-roles/RolesAdminPage.js +78 -0
- package/dist/pages/admin-roles/index.d.ts +8 -0
- package/dist/pages/admin-roles/index.js +15 -0
- package/dist/pages/admin-roles/modals.d.ts +72 -0
- package/dist/pages/admin-roles/modals.js +154 -0
- package/dist/pages/client-admin/ClientSiteAdminPage.d.ts +79 -0
- package/dist/pages/client-admin/ClientSiteAdminPage.js +177 -0
- package/dist/pages/client-admin/index.d.ts +32 -0
- package/dist/pages/client-admin/index.js +37 -0
- package/dist/pages/login/page.d.ts +22 -0
- package/dist/pages/login/page.js +239 -0
- package/dist/pages/profile/EnhancedProfilePage.d.ts +13 -0
- package/dist/pages/profile/EnhancedProfilePage.js +150 -0
- package/dist/pages/profile/index.d.ts +8 -0
- package/dist/pages/profile/index.js +16 -0
- package/dist/pages/profile/page.d.ts +19 -0
- package/dist/pages/profile/page.js +47 -0
- package/dist/pages/profile/profile-patch.d.ts +1 -0
- package/dist/pages/profile/profile-patch.js +281 -0
- package/dist/pages/recovery/page.d.ts +1 -0
- package/dist/pages/recovery/page.js +142 -0
- package/dist/pages/roles/MyRolesPage.d.ts +24 -0
- package/dist/pages/roles/MyRolesPage.js +71 -0
- package/dist/pages/roles/components.d.ts +63 -0
- package/dist/pages/roles/components.js +108 -0
- package/dist/pages/roles/index.d.ts +8 -0
- package/dist/pages/roles/index.js +19 -0
- package/dist/pages/security/EnhancedSecurityPage.d.ts +14 -0
- package/dist/pages/security/EnhancedSecurityPage.js +248 -0
- package/dist/pages/security/index.d.ts +8 -0
- package/dist/pages/security/index.js +16 -0
- package/dist/pages/security/page.d.ts +21 -0
- package/dist/pages/security/page.js +212 -0
- package/dist/pages/security/security-patch.d.ts +1 -0
- package/dist/pages/security/security-patch.js +302 -0
- package/dist/pages/settings/EnhancedSettingsPage.d.ts +46 -0
- package/dist/pages/settings/EnhancedSettingsPage.js +231 -0
- package/dist/pages/settings/index.d.ts +8 -0
- package/dist/pages/settings/index.js +16 -0
- package/dist/pages/settings/page.d.ts +7 -0
- package/dist/pages/settings/page.js +26 -0
- package/dist/pages/showcase/ShowcasePage.d.ts +13 -0
- package/dist/pages/showcase/ShowcasePage.js +140 -0
- package/dist/pages/showcase/index.d.ts +12 -0
- package/dist/pages/showcase/index.js +17 -0
- package/dist/pages/test-env/EmergencyLogoutPage.d.ts +14 -0
- package/dist/pages/test-env/EmergencyLogoutPage.js +98 -0
- package/dist/pages/test-env/JwtInspectPage.d.ts +14 -0
- package/dist/pages/test-env/JwtInspectPage.js +114 -0
- package/dist/pages/test-env/RefreshTokenPage.d.ts +15 -0
- package/dist/pages/test-env/RefreshTokenPage.js +91 -0
- package/dist/pages/test-env/TestEnvPage.d.ts +13 -0
- package/dist/pages/test-env/TestEnvPage.js +49 -0
- package/dist/pages/test-env/index.d.ts +24 -0
- package/dist/pages/test-env/index.js +32 -0
- package/dist/pages/verify-code/page.d.ts +30 -0
- package/dist/pages/verify-code/page.js +408 -0
- package/dist/routes/account/index.d.ts +28 -0
- package/dist/routes/account/index.js +71 -0
- package/dist/routes/account/masked-info.d.ts +33 -0
- package/dist/routes/account/masked-info.js +39 -0
- package/dist/routes/account/send-code.d.ts +37 -0
- package/dist/routes/account/send-code.js +42 -0
- package/dist/routes/account/update-phone.d.ts +13 -0
- package/dist/routes/account/update-phone.js +17 -0
- package/dist/routes/account/verify-email.d.ts +38 -0
- package/dist/routes/account/verify-email.js +43 -0
- package/dist/routes/account/verify-sms.d.ts +38 -0
- package/dist/routes/account/verify-sms.js +43 -0
- package/dist/routes/auth/index.d.ts +19 -0
- package/dist/routes/auth/index.js +64 -0
- package/dist/routes/auth/logout.d.ts +31 -0
- package/dist/routes/auth/logout.js +113 -0
- package/dist/routes/auth/nextauth.d.ts +19 -0
- package/dist/routes/auth/nextauth.js +72 -0
- package/dist/routes/auth/refresh.d.ts +30 -0
- package/dist/routes/auth/refresh.js +51 -0
- package/dist/routes/auth/session.d.ts +72 -0
- package/dist/routes/auth/session.js +180 -0
- package/dist/routes/auth/settings.d.ts +25 -0
- package/dist/routes/auth/settings.js +55 -0
- package/dist/routes/auth/viability.d.ts +52 -0
- package/dist/routes/auth/viability.js +201 -0
- package/dist/routes/index.d.ts +12 -0
- package/dist/routes/index.js +54 -0
- package/dist/routes/session/index.d.ts +6 -0
- package/dist/routes/session/index.js +10 -0
- package/dist/routes/session/refresh-viability.d.ts +16 -0
- package/dist/routes/session/refresh-viability.js +20 -0
- package/dist/services/signalrActivityService.d.ts +44 -0
- package/dist/services/signalrActivityService.js +257 -0
- package/dist/stores/authStore.d.ts +154 -0
- package/dist/stores/authStore.js +1531 -0
- package/dist/theme/ThemeProvider.d.ts +14 -0
- package/dist/theme/ThemeProvider.js +28 -0
- package/dist/theme/default.d.ts +8 -0
- package/dist/theme/default.js +33 -0
- package/dist/theme/index.d.ts +15 -0
- package/dist/theme/index.js +25 -0
- package/dist/theme/types.d.ts +56 -0
- package/dist/theme/types.js +8 -0
- package/dist/theme/useTheme.d.ts +60 -0
- package/dist/theme/useTheme.js +63 -0
- package/dist/theme/utils.d.ts +13 -0
- package/dist/theme/utils.js +39 -0
- package/dist/types/api.d.ts +134 -0
- package/dist/types/api.js +44 -0
- package/dist/types/auth.d.ts +19 -0
- package/dist/types/auth.js +2 -0
- package/dist/types/logging.d.ts +42 -0
- package/dist/types/logging.js +2 -0
- package/dist/types/recovery.d.ts +48 -0
- package/dist/types/recovery.js +2 -0
- package/dist/types/security.d.ts +1 -0
- package/dist/types/security.js +2 -0
- package/dist/utils/api.d.ts +85 -0
- package/dist/utils/api.js +287 -0
- package/dist/utils/circuitBreaker.d.ts +43 -0
- package/dist/utils/circuitBreaker.js +91 -0
- package/dist/utils/error-message.d.ts +1 -0
- package/dist/utils/error-message.js +103 -0
- package/dist/utils/layout/reservedSpace.d.ts +59 -0
- package/dist/utils/layout/reservedSpace.js +102 -0
- package/dist/utils/logout.d.ts +14 -0
- package/dist/utils/logout.js +32 -0
- package/dist/vibe/client.d.ts +261 -0
- package/dist/vibe/client.js +445 -0
- package/dist/vibe/errors.d.ts +83 -0
- package/dist/vibe/errors.js +146 -0
- package/dist/vibe/generic.d.ts +234 -0
- package/dist/vibe/generic.js +369 -0
- package/dist/vibe/hooks/index.d.ts +169 -0
- package/dist/vibe/hooks/index.js +252 -0
- package/dist/vibe/index.d.ts +23 -0
- package/dist/vibe/index.js +67 -0
- package/dist/vibe/sessions.d.ts +161 -0
- package/dist/vibe/sessions.js +391 -0
- package/dist/vibe/types.d.ts +353 -0
- package/dist/vibe/types.js +315 -0
- package/package.json +855 -0
- package/scripts/check-internal-url-usage.sh +73 -0
- package/scripts/dev-broker.ps1 +35 -0
- package/scripts/dev-local.ps1 +45 -0
- package/src/api/auth-handler.ts +550 -0
- package/src/api/index.ts +18 -0
- package/src/api-handlers/account/change-password.ts +145 -0
- package/src/api-handlers/account/masked-info.ts +45 -0
- package/src/api-handlers/account/profile.ts +80 -0
- package/src/api-handlers/account/recovery/initiate.ts +23 -0
- package/src/api-handlers/account/recovery/send-code.ts +25 -0
- package/src/api-handlers/account/recovery/verify-code.ts +25 -0
- package/src/api-handlers/account/reset-password.ts +23 -0
- package/src/api-handlers/account/send-code.ts +76 -0
- package/src/api-handlers/account/update-phone.ts +79 -0
- package/src/api-handlers/account/validate-password.ts +118 -0
- package/src/api-handlers/account/verify-email.ts +125 -0
- package/src/api-handlers/account/verify-sms.ts +125 -0
- package/src/api-handlers/admin/analytics.ts +445 -0
- package/src/api-handlers/admin/audit.ts +225 -0
- package/src/api-handlers/admin/index.ts +59 -0
- package/src/api-handlers/admin/redis-sessions.ts +253 -0
- package/src/api-handlers/admin/sessions.ts +320 -0
- package/src/api-handlers/admin/site-logs.ts +367 -0
- package/src/api-handlers/admin/users.ts +244 -0
- package/src/api-handlers/admin/vibe-data.ts +326 -0
- package/src/api-handlers/anon/preferences.ts +123 -0
- package/src/api-handlers/auth/jwks.ts +20 -0
- package/src/api-handlers/auth/login.ts +240 -0
- package/src/api-handlers/auth/refresh.ts +687 -0
- package/src/api-handlers/auth/signout.ts +212 -0
- package/src/api-handlers/auth/status.ts +23 -0
- package/src/api-handlers/auth/update-session.ts +125 -0
- package/src/api-handlers/auth/validate.ts +44 -0
- package/src/api-handlers/auth/verify-code.ts +129 -0
- package/src/api-handlers/session/refresh-viability.ts +36 -0
- package/src/api-handlers/session/viability.ts +166 -0
- package/src/api-handlers/test/force-expire.ts +67 -0
- package/src/auth/auth-decision.ts +230 -0
- package/src/auth/auth-options.ts +237 -0
- package/src/auth/callbacks/index.ts +7 -0
- package/src/auth/callbacks/jwt.ts +382 -0
- package/src/auth/callbacks/session.ts +243 -0
- package/src/auth/callbacks/signin.ts +56 -0
- package/src/auth/events/index.ts +5 -0
- package/src/auth/events/signout.ts +33 -0
- package/src/auth/providers/credentials.ts +256 -0
- package/src/auth/providers/index.ts +6 -0
- package/src/auth/providers/oauth.ts +114 -0
- package/src/auth/route-config.ts +220 -0
- package/src/auth/types/auth-types.ts +555 -0
- package/src/auth/types/index.ts +7 -0
- package/src/auth/unauthenticated-routes.ts +3 -0
- package/src/auth/utils/idp-client.ts +444 -0
- package/src/auth/utils/index.ts +6 -0
- package/src/auth/utils/token-utils.ts +244 -0
- package/src/client/AuthContext.tsx +140 -0
- package/src/client/fetch-with-auth.ts +48 -0
- package/src/client/fetchWithSession.ts +21 -0
- package/src/client/index.ts +13 -0
- package/src/client/useAnonSession.ts +131 -0
- package/src/components/SessionSync.tsx +137 -0
- package/src/components/SignalRHealthCheck.tsx +131 -0
- package/src/components/account/UserAvatarMenu.tsx +217 -0
- package/src/components/account/index.ts +8 -0
- package/src/components/admin/AlertSettingsTab.tsx +728 -0
- package/src/components/admin/AnalyticsTab.tsx +703 -0
- package/src/components/admin/DataBrowserTab.tsx +505 -0
- package/src/components/admin/LoggingSettingsTab.tsx +665 -0
- package/src/components/admin/SessionsTab.tsx +414 -0
- package/src/components/admin/StatsTab.tsx +379 -0
- package/src/components/admin/VibeAdminContext.tsx +87 -0
- package/src/components/admin/VibeAdminLayout.tsx +185 -0
- package/src/components/admin/index.ts +59 -0
- package/src/components/auth/FederatedAuthSection.tsx +95 -0
- package/src/components/auth/ModeAwareLoginPage.tsx +135 -0
- package/src/components/auth/ModeAwareSignupPage.tsx +267 -0
- package/src/components/auth/TraditionalAuthSection.tsx +99 -0
- package/src/components/recovery/CompleteStep.tsx +36 -0
- package/src/components/recovery/InitiateRecoveryStep.tsx +68 -0
- package/src/components/recovery/SelectMethodStep.tsx +73 -0
- package/src/components/recovery/SetPasswordStep.tsx +97 -0
- package/src/components/recovery/VerifyCodeStep.tsx +90 -0
- package/src/components/reserved/ReservedRecoveryWarning.tsx +160 -0
- package/src/components/reserved/ReservedStatusBox.tsx +118 -0
- package/src/components/ui/BetaBadge.tsx +58 -0
- package/src/components/ui/Footer.tsx +93 -0
- package/src/config/env.ts +57 -0
- package/src/config/logger.ts +62 -0
- package/src/config/logging-config.ts +82 -0
- package/src/config/unauthenticated-routes.ts +19 -0
- package/src/config/vibe-log-transport.ts +250 -0
- package/src/edge/internal-api-url.ts +65 -0
- package/src/edge/middleware.ts +42 -0
- package/src/hooks/useAuth.ts +115 -0
- package/src/hooks/useAuthSettings.ts +97 -0
- package/src/hooks/useAvailableProviders.ts +118 -0
- package/src/hooks/usePasswordValidation.ts +127 -0
- package/src/hooks/useProfile.ts +75 -0
- package/src/hooks/usePublicAuthSettings.ts +149 -0
- package/src/hooks/useSessionExpiration.ts +102 -0
- package/src/hooks/useViabilitySession.ts +335 -0
- package/src/index.ts +63 -0
- package/src/lib/anon-session.ts +213 -0
- package/src/lib/api-handler.ts +625 -0
- package/src/lib/app-slug.ts +178 -0
- package/src/lib/demo-mode.ts +13 -0
- package/src/lib/geolocation.ts +265 -0
- package/src/lib/idp-client-config.ts +442 -0
- package/src/lib/idp-fetch.ts +101 -0
- package/src/lib/internal-api.ts +171 -0
- package/src/lib/jwt-decode-client.ts +45 -0
- package/src/lib/jwt-decode.ts +83 -0
- package/src/lib/nextauth-secret.ts +126 -0
- package/src/lib/rate-limit-service.ts +9 -0
- package/src/lib/redis.ts +27 -0
- package/src/lib/refresh-token-validator.ts +64 -0
- package/src/lib/roles.ts +177 -0
- package/src/lib/secret-validation.ts +8 -0
- package/src/lib/session-store.ts +637 -0
- package/src/lib/session.ts +34 -0
- package/src/lib/site-logger.ts +245 -0
- package/src/lib/standardized-client-api.ts +896 -0
- package/src/lib/startup-init.ts +247 -0
- package/src/lib/test-aware-get-token.ts +30 -0
- package/src/lib/token-expiry.ts +40 -0
- package/src/lib/token-lifecycle.ts +477 -0
- package/src/lib/types/api-responses.ts +336 -0
- package/src/lib/user-agent-parser.ts +252 -0
- package/src/logging/api/admin-analytics.ts +51 -0
- package/src/logging/api/audit-log.ts +53 -0
- package/src/logging/components/AdminAnalyticsLayout.tsx +49 -0
- package/src/logging/components/AuditLogViewer.tsx +125 -0
- package/src/logging/components/ErrorMetricsCard.tsx +98 -0
- package/src/logging/components/HealthMetricsCard.tsx +70 -0
- package/src/logging/hooks/useAdminAnalytics.ts +22 -0
- package/src/logging/hooks/useAuditLog.ts +24 -0
- package/src/logging/hooks/useErrorMetrics.ts +40 -0
- package/src/logging/hooks/useHealthMetrics.ts +44 -0
- package/src/logging/index.ts +18 -0
- package/src/logging/types/analytics.ts +81 -0
- package/src/logging/types/audit.ts +31 -0
- package/src/logging/types/index.ts +3 -0
- package/src/middleware/auth-decision.ts +43 -0
- package/src/middleware/create-middleware.ts +626 -0
- package/src/middleware/rbac-check.ts +244 -0
- package/src/middleware/twofa-presets.ts +224 -0
- package/src/models/DecodedAccessToken.ts +17 -0
- package/src/models/SessionModel.ts +258 -0
- package/src/pages/admin-login/page.tsx +229 -0
- package/src/pages/admin-roles/RolesAdminPage.tsx +357 -0
- package/src/pages/admin-roles/index.ts +9 -0
- package/src/pages/admin-roles/modals.tsx +469 -0
- package/src/pages/client-admin/ClientSiteAdminPage.tsx +380 -0
- package/src/pages/client-admin/index.ts +33 -0
- package/src/pages/login/page.tsx +463 -0
- package/src/pages/profile/EnhancedProfilePage.tsx +479 -0
- package/src/pages/profile/index.ts +9 -0
- package/src/pages/profile/page.tsx +166 -0
- package/src/pages/recovery/page.tsx +234 -0
- package/src/pages/roles/MyRolesPage.tsx +211 -0
- package/src/pages/roles/components.tsx +294 -0
- package/src/pages/roles/index.ts +17 -0
- package/src/pages/security/EnhancedSecurityPage.tsx +574 -0
- package/src/pages/security/index.ts +9 -0
- package/src/pages/security/page.tsx +507 -0
- package/src/pages/settings/EnhancedSettingsPage.tsx +642 -0
- package/src/pages/settings/index.ts +9 -0
- package/src/pages/settings/page.tsx +47 -0
- package/src/pages/showcase/ShowcasePage.tsx +530 -0
- package/src/pages/showcase/index.ts +13 -0
- package/src/pages/test-env/EmergencyLogoutPage.tsx +179 -0
- package/src/pages/test-env/JwtInspectPage.tsx +418 -0
- package/src/pages/test-env/RefreshTokenPage.tsx +155 -0
- package/src/pages/test-env/TestEnvPage.tsx +116 -0
- package/src/pages/test-env/index.ts +25 -0
- package/src/pages/verify-code/page.tsx +648 -0
- package/src/routes/account/index.ts +32 -0
- package/src/routes/account/masked-info.ts +37 -0
- package/src/routes/account/send-code.ts +40 -0
- package/src/routes/account/update-phone.ts +13 -0
- package/src/routes/account/verify-email.ts +41 -0
- package/src/routes/account/verify-sms.ts +41 -0
- package/src/routes/auth/index.ts +23 -0
- package/src/routes/auth/logout.ts +127 -0
- package/src/routes/auth/nextauth.ts +71 -0
- package/src/routes/auth/refresh.ts +54 -0
- package/src/routes/auth/session.ts +193 -0
- package/src/routes/auth/settings.ts +75 -0
- package/src/routes/auth/viability.ts +220 -0
- package/src/routes/index.ts +18 -0
- package/src/routes/session/index.ts +7 -0
- package/src/routes/session/refresh-viability.ts +17 -0
- package/src/services/signalrActivityService.ts +258 -0
- package/src/stores/authStore.ts +1904 -0
- package/src/templates/instrumentation.ts +41 -0
- package/src/theme/ThemeProvider.tsx +39 -0
- package/src/theme/default.ts +33 -0
- package/src/theme/index.ts +31 -0
- package/src/theme/types.ts +69 -0
- package/src/theme/useTheme.ts +57 -0
- package/src/theme/utils.ts +40 -0
- package/src/types/api.ts +13 -0
- package/src/types/auth.d.ts +15 -0
- package/src/types/auth.ts +22 -0
- package/src/types/logging.ts +11 -0
- package/src/types/next-auth.d.ts +15 -0
- package/src/types/recovery.ts +54 -0
- package/src/types/security.ts +1 -0
- package/src/utils/api.ts +353 -0
- package/src/utils/circuitBreaker.ts +40 -0
- package/src/utils/error-message.ts +108 -0
- package/src/utils/layout/reservedSpace.ts +124 -0
- package/src/utils/logout.ts +30 -0
- package/src/vibe/client.ts +590 -0
- package/src/vibe/errors.ts +185 -0
- package/src/vibe/generic.ts +429 -0
- package/src/vibe/hooks/index.ts +367 -0
- package/src/vibe/index.ts +121 -0
- package/src/vibe/sessions.ts +551 -0
- package/src/vibe/types.ts +577 -0
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Themed Login Page for @payez/next-mvp
|
|
3
|
+
*
|
|
4
|
+
* DEPENDENCIES: Only React, Next.js, next-auth, and Tailwind CSS
|
|
5
|
+
* NO shadcn/ui or other UI library required!
|
|
6
|
+
*
|
|
7
|
+
* FEATURES:
|
|
8
|
+
* ✅ Atomic state management with visual feedback (submitting/error/success)
|
|
9
|
+
* ✅ Enhanced error handling with user-friendly messages
|
|
10
|
+
* ✅ Show/hide password toggle
|
|
11
|
+
* ✅ Loading state management with timeouts
|
|
12
|
+
* ✅ Proper autofill styling
|
|
13
|
+
* ✅ Session expiration handling
|
|
14
|
+
* ✅ Themeable styling via ThemeProvider
|
|
15
|
+
* ✅ Placeholder for health check component
|
|
16
|
+
*
|
|
17
|
+
* USAGE:
|
|
18
|
+
* 1. Import from @payez/next-mvp/pages/login
|
|
19
|
+
* 2. Wrap your app with ThemeProvider to customize branding
|
|
20
|
+
* 3. Optionally add your health check component
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
'use client';
|
|
24
|
+
|
|
25
|
+
import React, { useState, useEffect } from 'react';
|
|
26
|
+
import { signIn, useSession, getSession } from 'next-auth/react';
|
|
27
|
+
import { useSearchParams } from 'next/navigation';
|
|
28
|
+
import { Suspense } from 'react';
|
|
29
|
+
import ReservedStatusBox from '../../components/reserved/ReservedStatusBox';
|
|
30
|
+
import ReservedRecoveryWarning from '../../components/reserved/ReservedRecoveryWarning';
|
|
31
|
+
import { useBranding, useColors, useLayout } from '../../theme/useTheme';
|
|
32
|
+
|
|
33
|
+
function LoginForm() {
|
|
34
|
+
const searchParams = useSearchParams();
|
|
35
|
+
const callbackUrl = searchParams?.get('callbackUrl') || '/dashboard';
|
|
36
|
+
const urlError = searchParams?.get('error');
|
|
37
|
+
|
|
38
|
+
const { data: session, status } = useSession();
|
|
39
|
+
const branding = useBranding();
|
|
40
|
+
const colors = useColors();
|
|
41
|
+
const layout = useLayout();
|
|
42
|
+
|
|
43
|
+
// Helper to create lighter/darker shades for hover states
|
|
44
|
+
const adjustBrightness = (hex: string, percent: number) => {
|
|
45
|
+
const num = parseInt(hex.replace('#', ''), 16);
|
|
46
|
+
const amt = Math.round(2.55 * percent);
|
|
47
|
+
const R = (num >> 16) + amt;
|
|
48
|
+
const G = (num >> 8 & 0x00FF) + amt;
|
|
49
|
+
const B = (num & 0x0000FF) + amt;
|
|
50
|
+
return '#' + (0x1000000 + (R < 255 ? R < 1 ? 0 : R : 255) * 0x10000 +
|
|
51
|
+
(G < 255 ? G < 1 ? 0 : G : 255) * 0x100 +
|
|
52
|
+
(B < 255 ? B < 1 ? 0 : B : 255))
|
|
53
|
+
.toString(16).slice(1);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// Get the primary button color from theme (defaults to primary, or uses component override)
|
|
57
|
+
const buttonColor = colors.secondary || colors.primary || '#3b82f6';
|
|
58
|
+
const buttonHoverColor = adjustBrightness(buttonColor, -10);
|
|
59
|
+
|
|
60
|
+
// Form fields
|
|
61
|
+
const [email, setEmail] = useState('');
|
|
62
|
+
const [password, setPassword] = useState('');
|
|
63
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
64
|
+
|
|
65
|
+
// Atomic state management - only ONE can be true at a time
|
|
66
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
67
|
+
const [loginSuccess, setLoginSuccess] = useState(false);
|
|
68
|
+
const [loginError, setLoginError] = useState<string | null>(null);
|
|
69
|
+
const [loading, setLoading] = useState(false);
|
|
70
|
+
const [showRecoveryOptions, setShowRecoveryOptions] = useState(false);
|
|
71
|
+
|
|
72
|
+
// Force show form after timeout if stuck in loading
|
|
73
|
+
const [forceShowForm, setForceShowForm] = useState(false);
|
|
74
|
+
|
|
75
|
+
// Handle URL errors with user-friendly messages
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (urlError) {
|
|
78
|
+
let friendlyError: string | null = urlError;
|
|
79
|
+
|
|
80
|
+
if (urlError === 'SessionExpired') {
|
|
81
|
+
// Session expiration is normal - don't show as error
|
|
82
|
+
console.log('[LOGIN] SessionExpired detected - normal behavior');
|
|
83
|
+
friendlyError = null;
|
|
84
|
+
} else if (urlError === 'ServiceUnavailable') {
|
|
85
|
+
friendlyError = 'Authentication service is temporarily unavailable. Please try again in a few minutes.';
|
|
86
|
+
} else if (urlError.startsWith("Unexpected token")) {
|
|
87
|
+
friendlyError = 'An authentication error occurred. Please try signing in again.';
|
|
88
|
+
} else if (urlError.includes('not valid JSON')) {
|
|
89
|
+
friendlyError = 'An authentication error occurred. Please try signing in again.';
|
|
90
|
+
} else if (urlError === 'CredentialsSignin') {
|
|
91
|
+
friendlyError = 'Invalid email or password. Please try again.';
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
setLoginError(friendlyError);
|
|
95
|
+
}
|
|
96
|
+
}, [urlError]);
|
|
97
|
+
|
|
98
|
+
// Timeout to prevent infinite loading states
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (status === 'loading') {
|
|
101
|
+
const timeout = setTimeout(() => {
|
|
102
|
+
console.warn('[LOGIN] NextAuth status stuck in loading, forcing form display');
|
|
103
|
+
setForceShowForm(true);
|
|
104
|
+
}, 3000);
|
|
105
|
+
return () => clearTimeout(timeout);
|
|
106
|
+
}
|
|
107
|
+
}, [status]);
|
|
108
|
+
|
|
109
|
+
// Force show form after 1 second if no session
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
const immediateTimeout = setTimeout(() => {
|
|
112
|
+
if (status === 'loading' && !session) {
|
|
113
|
+
console.log('[LOGIN] Force showing form after 1 second');
|
|
114
|
+
setForceShowForm(true);
|
|
115
|
+
}
|
|
116
|
+
}, 1000);
|
|
117
|
+
return () => clearTimeout(immediateTimeout);
|
|
118
|
+
}, [status, session]);
|
|
119
|
+
|
|
120
|
+
const handleSubmit = async (e: React.FormEvent) => {
|
|
121
|
+
e.preventDefault();
|
|
122
|
+
|
|
123
|
+
// Atomic state: set to submitting (clears error and success)
|
|
124
|
+
setIsSubmitting(true);
|
|
125
|
+
setLoading(true);
|
|
126
|
+
setLoginError(null);
|
|
127
|
+
setLoginSuccess(false);
|
|
128
|
+
|
|
129
|
+
try {
|
|
130
|
+
console.log('[LOGIN] Starting authentication...');
|
|
131
|
+
const result = await signIn('credentials', {
|
|
132
|
+
email,
|
|
133
|
+
password,
|
|
134
|
+
redirect: false,
|
|
135
|
+
callbackUrl,
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
if (result?.error) {
|
|
139
|
+
console.log('[LOGIN] Authentication failed:', result.error);
|
|
140
|
+
|
|
141
|
+
setIsSubmitting(false);
|
|
142
|
+
setLoading(false);
|
|
143
|
+
setLoginSuccess(false);
|
|
144
|
+
|
|
145
|
+
try {
|
|
146
|
+
const errorData = JSON.parse(result.error);
|
|
147
|
+
const passwordError = errorData.error?.details?.errors?.find((e: any) => e.field_name === 'password');
|
|
148
|
+
|
|
149
|
+
if (passwordError) {
|
|
150
|
+
// Show recovery options on ANY password error
|
|
151
|
+
console.log('[LOGIN] Password error detected - showing recovery options');
|
|
152
|
+
setShowRecoveryOptions(true);
|
|
153
|
+
setLoginError(passwordError.message);
|
|
154
|
+
} else {
|
|
155
|
+
setLoginError(result.error);
|
|
156
|
+
}
|
|
157
|
+
} catch {
|
|
158
|
+
if (result.error.includes('Unable to connect')) {
|
|
159
|
+
setLoginError('The authentication service is currently unavailable. Please try again later.');
|
|
160
|
+
} else if (result.error === 'CredentialsSignin') {
|
|
161
|
+
setLoginError('Invalid email or password. Please try again.');
|
|
162
|
+
} else {
|
|
163
|
+
setLoginError(result.error);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Atomic state: set to success
|
|
170
|
+
console.log('[LOGIN] Authentication successful!');
|
|
171
|
+
setLoginSuccess(true);
|
|
172
|
+
setLoginError(null);
|
|
173
|
+
setIsSubmitting(false);
|
|
174
|
+
|
|
175
|
+
// Get updated session
|
|
176
|
+
const freshSession = await getSession();
|
|
177
|
+
console.log('[LOGIN] Fresh session obtained, redirecting to 2FA...');
|
|
178
|
+
|
|
179
|
+
// Redirect to verify-code for 2FA
|
|
180
|
+
const verifyUrl = `/account-auth/verify-code?callbackUrl=${encodeURIComponent(callbackUrl)}`;
|
|
181
|
+
console.log('[LOGIN] Redirecting to:', verifyUrl);
|
|
182
|
+
window.location.href = verifyUrl;
|
|
183
|
+
|
|
184
|
+
} catch (err) {
|
|
185
|
+
console.error('[LOGIN] Unexpected error:', err);
|
|
186
|
+
|
|
187
|
+
// Atomic state: set to error
|
|
188
|
+
setIsSubmitting(false);
|
|
189
|
+
setLoading(false);
|
|
190
|
+
setLoginSuccess(false);
|
|
191
|
+
setLoginError(err instanceof Error ? err.message : 'An error occurred during login');
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
// Show loading spinner for initial loads
|
|
196
|
+
if (!forceShowForm && !loginError && (loading || (status === 'loading' && !session))) {
|
|
197
|
+
return (
|
|
198
|
+
<div className={`flex flex-col items-center justify-center min-h-screen ${colors.background}`}>
|
|
199
|
+
<svg className="animate-spin h-6 w-6" style={{ color: buttonColor }} viewBox="0 0 24 24" fill="none">
|
|
200
|
+
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" />
|
|
201
|
+
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z" />
|
|
202
|
+
</svg>
|
|
203
|
+
<p className={`mt-4 text-sm ${colors.muted}`}>
|
|
204
|
+
{status === 'loading' ? 'Loading...' : 'Authenticating...'}
|
|
205
|
+
</p>
|
|
206
|
+
</div>
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return (
|
|
211
|
+
<>
|
|
212
|
+
{/* Dynamic styles for theme colors */}
|
|
213
|
+
<style dangerouslySetInnerHTML={{__html: `
|
|
214
|
+
.themed-input:focus {
|
|
215
|
+
outline: none;
|
|
216
|
+
border-color: ${buttonColor} !important;
|
|
217
|
+
box-shadow: 0 0 0 2px ${buttonColor}40 !important;
|
|
218
|
+
}
|
|
219
|
+
.themed-button {
|
|
220
|
+
background-color: ${buttonColor} !important;
|
|
221
|
+
}
|
|
222
|
+
.themed-button:hover:not(:disabled) {
|
|
223
|
+
background-color: ${buttonHoverColor} !important;
|
|
224
|
+
}
|
|
225
|
+
.themed-link {
|
|
226
|
+
color: ${buttonColor} !important;
|
|
227
|
+
}
|
|
228
|
+
.themed-link:hover {
|
|
229
|
+
color: ${buttonHoverColor} !important;
|
|
230
|
+
}
|
|
231
|
+
.themed-status-submitting {
|
|
232
|
+
background-color: ${buttonColor}1A !important;
|
|
233
|
+
border-color: ${buttonColor}33 !important;
|
|
234
|
+
}
|
|
235
|
+
.themed-status-submitting-text {
|
|
236
|
+
color: ${buttonColor} !important;
|
|
237
|
+
}
|
|
238
|
+
.themed-status-submitting svg {
|
|
239
|
+
color: ${buttonColor} !important;
|
|
240
|
+
}
|
|
241
|
+
`}} />
|
|
242
|
+
<div className={`min-h-screen flex items-center justify-center px-4 ${colors.background}`}>
|
|
243
|
+
<div className="max-w-md w-full">
|
|
244
|
+
{/* Card */}
|
|
245
|
+
<div className={`rounded-2xl shadow-xl p-8 ${colors.card} ${colors.border} text-gray-800`}>
|
|
246
|
+
{/* Header */}
|
|
247
|
+
<div className="text-center mb-8">
|
|
248
|
+
<h1 className="text-3xl font-bold mb-2" style={{ color: 'inherit' }}>
|
|
249
|
+
{branding.tagline || 'Welcome Back'}
|
|
250
|
+
</h1>
|
|
251
|
+
<p className={colors.muted}>
|
|
252
|
+
Sign in to your account
|
|
253
|
+
</p>
|
|
254
|
+
</div>
|
|
255
|
+
|
|
256
|
+
{/* Login Form */}
|
|
257
|
+
<form onSubmit={handleSubmit} className="space-y-6" data-testid="login-form">
|
|
258
|
+
{/* Email Field */}
|
|
259
|
+
<div>
|
|
260
|
+
<label htmlFor="email" className="block text-sm font-medium mb-2" style={{ color: 'inherit' }}>
|
|
261
|
+
Email Address
|
|
262
|
+
</label>
|
|
263
|
+
<input
|
|
264
|
+
id="email"
|
|
265
|
+
type="email"
|
|
266
|
+
required
|
|
267
|
+
autoFocus
|
|
268
|
+
autoComplete="email"
|
|
269
|
+
value={email}
|
|
270
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
271
|
+
className={`themed-input w-full px-4 py-3 border border-gray-300 rounded-lg transition-colors`}
|
|
272
|
+
placeholder="you@example.com"
|
|
273
|
+
disabled={isSubmitting}
|
|
274
|
+
style={{ backgroundColor: 'white', color: '#1f2937' }}
|
|
275
|
+
/>
|
|
276
|
+
</div>
|
|
277
|
+
|
|
278
|
+
{/* Password Field with Show/Hide Toggle */}
|
|
279
|
+
<div>
|
|
280
|
+
<label htmlFor="password" className="block text-sm font-medium mb-2" style={{ color: 'inherit' }}>
|
|
281
|
+
Password
|
|
282
|
+
</label>
|
|
283
|
+
<div className="relative">
|
|
284
|
+
<input
|
|
285
|
+
id="password"
|
|
286
|
+
type={showPassword ? "text" : "password"}
|
|
287
|
+
required
|
|
288
|
+
autoComplete="current-password"
|
|
289
|
+
value={password}
|
|
290
|
+
onChange={(e) => setPassword(e.target.value)}
|
|
291
|
+
className={`themed-input w-full px-4 py-3 pr-12 border border-gray-300 rounded-lg transition-colors`}
|
|
292
|
+
placeholder="••••••••"
|
|
293
|
+
disabled={isSubmitting}
|
|
294
|
+
style={{ backgroundColor: 'white', color: '#1f2937' }}
|
|
295
|
+
/>
|
|
296
|
+
<button
|
|
297
|
+
type="button"
|
|
298
|
+
onClick={() => setShowPassword(!showPassword)}
|
|
299
|
+
className="absolute right-3 top-1/2 transform -translate-y-1/2 hover:opacity-70"
|
|
300
|
+
style={{ color: 'inherit', opacity: 0.7 }}
|
|
301
|
+
aria-label={showPassword ? "Hide password" : "Show password"}
|
|
302
|
+
>
|
|
303
|
+
{showPassword ? (
|
|
304
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" className="w-5 h-5">
|
|
305
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.878 9.878L6.464 6.464m7.535 7.535l3.415 3.414M3 3l3.464 3.464M21 21l-3.415-3.414" />
|
|
306
|
+
</svg>
|
|
307
|
+
) : (
|
|
308
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" className="w-5 h-5">
|
|
309
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
|
310
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
|
|
311
|
+
</svg>
|
|
312
|
+
)}
|
|
313
|
+
</button>
|
|
314
|
+
</div>
|
|
315
|
+
</div>
|
|
316
|
+
|
|
317
|
+
{/* Atomic Status Display - Deterministic Reserved Space (zero layout shift) */}
|
|
318
|
+
<ReservedStatusBox
|
|
319
|
+
candidates={[
|
|
320
|
+
"Ready",
|
|
321
|
+
"Authenticating...",
|
|
322
|
+
"The authentication service is currently unavailable. Please try again later.",
|
|
323
|
+
"Invalid email or password. Please try again.",
|
|
324
|
+
"Login successful! Redirecting..."
|
|
325
|
+
]}
|
|
326
|
+
containerClass="p-3 text-sm leading-relaxed rounded-lg border"
|
|
327
|
+
iconSizePx={16}
|
|
328
|
+
>
|
|
329
|
+
{isSubmitting ? (
|
|
330
|
+
/* Themed: Submitting */
|
|
331
|
+
<div className="themed-status-submitting flex items-start space-x-2 p-3 rounded-lg">
|
|
332
|
+
<svg className="animate-spin w-4 h-4 mt-0.5 flex-shrink-0" fill="none" viewBox="0 0 24 24" style={{ color: buttonColor }}>
|
|
333
|
+
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4"></circle>
|
|
334
|
+
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
|
335
|
+
</svg>
|
|
336
|
+
<span className="themed-status-submitting-text text-sm leading-relaxed" style={{ color: buttonColor }}>Authenticating...</span>
|
|
337
|
+
</div>
|
|
338
|
+
) : loginError ? (
|
|
339
|
+
/* Red: Error */
|
|
340
|
+
<div className="flex items-start space-x-2 p-3 rounded-lg bg-red-500/10 border border-red-500/20">
|
|
341
|
+
<div className="w-4 h-4 bg-red-500 rounded-full mt-0.5 flex-shrink-0"></div>
|
|
342
|
+
<span className="text-red-600 text-sm leading-relaxed">{loginError}</span>
|
|
343
|
+
</div>
|
|
344
|
+
) : loginSuccess ? (
|
|
345
|
+
/* Green: Success */
|
|
346
|
+
<div className="flex items-start space-x-2 p-3 rounded-lg bg-green-500/10 border border-green-500/20">
|
|
347
|
+
<div className="w-4 h-4 bg-green-500 rounded-full mt-0.5 flex-shrink-0"></div>
|
|
348
|
+
<span className="text-green-600 text-sm leading-relaxed">Login successful! Redirecting...</span>
|
|
349
|
+
</div>
|
|
350
|
+
) : (
|
|
351
|
+
/* Ready State / Health Check Placeholder */
|
|
352
|
+
<div className="flex items-start space-x-2 p-3 rounded-lg bg-green-500/10 border border-green-500/20">
|
|
353
|
+
<div className="w-4 h-4 bg-green-500 rounded-full mt-0.5 flex-shrink-0"></div>
|
|
354
|
+
<span className="text-green-600 text-sm leading-relaxed">Ready</span>
|
|
355
|
+
{/*
|
|
356
|
+
CUSTOMIZATION: Replace above with your health check component
|
|
357
|
+
Example: <SignalRHealthCheck />
|
|
358
|
+
Or any real-time health status component
|
|
359
|
+
*/}
|
|
360
|
+
</div>
|
|
361
|
+
)}
|
|
362
|
+
</ReservedStatusBox>
|
|
363
|
+
|
|
364
|
+
{/* Account Recovery Options - Deterministic Reserved Space (zero layout shift) */}
|
|
365
|
+
<ReservedRecoveryWarning
|
|
366
|
+
show={showRecoveryOptions}
|
|
367
|
+
titleText="Account Lockout Warning"
|
|
368
|
+
bodyText="Your account will be locked after one more failed attempt. Need help?"
|
|
369
|
+
actionLabel="Start Account Recovery"
|
|
370
|
+
containerClass="p-4 bg-amber-50 border border-amber-200 rounded-lg"
|
|
371
|
+
titleClass="text-amber-900 font-medium mb-2"
|
|
372
|
+
bodyClass="text-amber-800 text-sm mb-3"
|
|
373
|
+
buttonClass="w-full bg-amber-600 hover:bg-amber-700 text-white font-medium py-2 px-4 rounded-md text-sm transition-colors"
|
|
374
|
+
iconSizePx={20}
|
|
375
|
+
>
|
|
376
|
+
{showRecoveryOptions && (
|
|
377
|
+
<div className="p-4 bg-amber-50 border border-amber-200 rounded-lg">
|
|
378
|
+
<div className="flex items-start space-x-3">
|
|
379
|
+
<svg className="w-5 h-5 text-amber-600 mt-0.5 flex-shrink-0" fill="currentColor" viewBox="0 0 20 20">
|
|
380
|
+
<path fillRule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clipRule="evenodd" />
|
|
381
|
+
</svg>
|
|
382
|
+
<div className="flex-1">
|
|
383
|
+
<h3 className="text-amber-900 font-medium mb-2">Account Lockout Warning</h3>
|
|
384
|
+
<p className="text-amber-800 text-sm mb-3">
|
|
385
|
+
Your account will be locked after one more failed attempt. Need help?
|
|
386
|
+
</p>
|
|
387
|
+
<button
|
|
388
|
+
type="button"
|
|
389
|
+
onClick={() => window.location.href = `/account-auth/recovery?email=${encodeURIComponent(email)}`}
|
|
390
|
+
className="w-full bg-amber-600 hover:bg-amber-700 text-white font-medium py-2 px-4 rounded-md text-sm transition-colors"
|
|
391
|
+
>
|
|
392
|
+
Start Account Recovery
|
|
393
|
+
</button>
|
|
394
|
+
</div>
|
|
395
|
+
</div>
|
|
396
|
+
</div>
|
|
397
|
+
)}
|
|
398
|
+
</ReservedRecoveryWarning>
|
|
399
|
+
|
|
400
|
+
{/* Submit Button */}
|
|
401
|
+
<button
|
|
402
|
+
type="submit"
|
|
403
|
+
disabled={isSubmitting}
|
|
404
|
+
className="themed-button w-full text-white font-semibold py-3 px-4 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center"
|
|
405
|
+
>
|
|
406
|
+
{isSubmitting ? (
|
|
407
|
+
<>
|
|
408
|
+
<svg className="animate-spin -ml-1 mr-3 h-5 w-5 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
|
409
|
+
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4"></circle>
|
|
410
|
+
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
|
411
|
+
</svg>
|
|
412
|
+
Signing in...
|
|
413
|
+
</>
|
|
414
|
+
) : (
|
|
415
|
+
'Sign In'
|
|
416
|
+
)}
|
|
417
|
+
</button>
|
|
418
|
+
</form>
|
|
419
|
+
|
|
420
|
+
{/* Footer Links */}
|
|
421
|
+
<div className={`mt-6 text-center text-sm ${colors.muted}`}>
|
|
422
|
+
<a href="/account-auth/recovery" className="themed-link hover:underline">
|
|
423
|
+
Start account recovery
|
|
424
|
+
</a>
|
|
425
|
+
</div>
|
|
426
|
+
</div>
|
|
427
|
+
|
|
428
|
+
{/* Additional Info */}
|
|
429
|
+
<p className={`mt-4 text-center text-sm ${colors.muted}`}>
|
|
430
|
+
Don't have an account?{' '}
|
|
431
|
+
<a href="/account-auth/register" className="themed-link font-medium hover:underline">
|
|
432
|
+
Sign up
|
|
433
|
+
</a>
|
|
434
|
+
</p>
|
|
435
|
+
</div>
|
|
436
|
+
</div>
|
|
437
|
+
</>
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
function LoginPageFallback() {
|
|
442
|
+
const colors = useColors();
|
|
443
|
+
const buttonColor = colors.secondary || colors.primary || '#11B588';
|
|
444
|
+
return (
|
|
445
|
+
<div className={`min-h-screen flex items-center justify-center ${colors.background}`}>
|
|
446
|
+
<div className="text-center">
|
|
447
|
+
<svg className="animate-spin h-10 w-10 mx-auto" style={{ color: buttonColor }} xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
|
448
|
+
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4"></circle>
|
|
449
|
+
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
|
450
|
+
</svg>
|
|
451
|
+
<p className={`mt-4 ${colors.muted}`}>Loading...</p>
|
|
452
|
+
</div>
|
|
453
|
+
</div>
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
export default function LoginPage() {
|
|
458
|
+
return (
|
|
459
|
+
<Suspense fallback={<LoginPageFallback />}>
|
|
460
|
+
<LoginForm />
|
|
461
|
+
</Suspense>
|
|
462
|
+
);
|
|
463
|
+
}
|