@cedros/login-react 0.0.1

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.
Files changed (200) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1183 -0
  3. package/dist/EmailRegisterForm-D_uCEdX9.cjs +1 -0
  4. package/dist/EmailRegisterForm-D_uCEdX9.cjs.map +1 -0
  5. package/dist/EmailRegisterForm-m3rX3A6X.js +2923 -0
  6. package/dist/EmailRegisterForm-m3rX3A6X.js.map +1 -0
  7. package/dist/ErrorMessage-Bm1j5mBT.js +2042 -0
  8. package/dist/ErrorMessage-Bm1j5mBT.js.map +1 -0
  9. package/dist/ErrorMessage-CntMyn93.cjs +1 -0
  10. package/dist/ErrorMessage-CntMyn93.cjs.map +1 -0
  11. package/dist/GoogleLoginButton-CJNJ-THo.cjs +1 -0
  12. package/dist/GoogleLoginButton-CJNJ-THo.cjs.map +1 -0
  13. package/dist/GoogleLoginButton-CvDoOc-0.js +227 -0
  14. package/dist/GoogleLoginButton-CvDoOc-0.js.map +1 -0
  15. package/dist/SolanaLoginButton-BlSgPW50.cjs +1 -0
  16. package/dist/SolanaLoginButton-BlSgPW50.cjs.map +1 -0
  17. package/dist/SolanaLoginButton-h32xN2PQ.js +261 -0
  18. package/dist/SolanaLoginButton-h32xN2PQ.js.map +1 -0
  19. package/dist/assets/argon2Worker-Bi5TuQvD.js +1 -0
  20. package/dist/assets/argon2Worker-Bi5TuQvD.js.map +1 -0
  21. package/dist/components/LoginButton.d.ts +23 -0
  22. package/dist/components/LoginForm.d.ts +9 -0
  23. package/dist/components/LoginModal.d.ts +9 -0
  24. package/dist/components/admin/AdminUserDetail.d.ts +21 -0
  25. package/dist/components/admin/AdminUserList.d.ts +25 -0
  26. package/dist/components/admin/CedrosAdminDashboard.d.ts +48 -0
  27. package/dist/components/admin/SystemSettings.d.ts +19 -0
  28. package/dist/components/apple/AppleLoginButton.d.ts +29 -0
  29. package/dist/components/deposit/CreditBalance.d.ts +19 -0
  30. package/dist/components/deposit/DepositFlow.d.ts +118 -0
  31. package/dist/components/deposit/FeeConfigDisplay.d.ts +15 -0
  32. package/dist/components/deposit/History.d.ts +21 -0
  33. package/dist/components/deposit/TieredAmountSlider.d.ts +19 -0
  34. package/dist/components/deposit/TokenSelector.d.ts +23 -0
  35. package/dist/components/deposit/admin/AdminDepositList.d.ts +21 -0
  36. package/dist/components/deposit/admin/AdminDepositStats.d.ts +15 -0
  37. package/dist/components/deposit/admin/AdminPrivacyPeriodDeposits.d.ts +19 -0
  38. package/dist/components/deposit/admin/AdminWithdrawalHistory.d.ts +19 -0
  39. package/dist/components/deposit/admin/AdminWithdrawalQueue.d.ts +23 -0
  40. package/dist/components/deposit/admin/PrivacySystemStatus.d.ts +15 -0
  41. package/dist/components/deposit/admin/index.d.ts +17 -0
  42. package/dist/components/deposit/index.d.ts +12 -0
  43. package/dist/components/deposit/tierUtils.d.ts +8 -0
  44. package/dist/components/deposit/tokens.d.ts +19 -0
  45. package/dist/components/email/EmailLoginForm.d.ts +11 -0
  46. package/dist/components/email/EmailRegisterForm.d.ts +14 -0
  47. package/dist/components/email/ForgotPasswordForm.d.ts +17 -0
  48. package/dist/components/email/PasswordInput.d.ts +14 -0
  49. package/dist/components/email/ResetPasswordForm.d.ts +22 -0
  50. package/dist/components/google/GoogleLoginButton.d.ts +12 -0
  51. package/dist/components/invites/InviteForm.d.ts +38 -0
  52. package/dist/components/invites/InviteList.d.ts +40 -0
  53. package/dist/components/members/MemberList.d.ts +47 -0
  54. package/dist/components/org/CreateOrgForm.d.ts +7 -0
  55. package/dist/components/org/OrgAvatar.d.ts +7 -0
  56. package/dist/components/org/OrgListView.d.ts +9 -0
  57. package/dist/components/org/OrgSelector.d.ts +51 -0
  58. package/dist/components/org/OrgSwitcher.d.ts +47 -0
  59. package/dist/components/org/icons.d.ts +8 -0
  60. package/dist/components/sessions/SessionList.d.ts +33 -0
  61. package/dist/components/shared/ErrorBoundary.d.ts +38 -0
  62. package/dist/components/shared/ErrorMessage.d.ts +14 -0
  63. package/dist/components/shared/LoadingSpinner.d.ts +16 -0
  64. package/dist/components/solana/SolanaLoginButton.d.ts +49 -0
  65. package/dist/components/templates/FullPageLayout.d.ts +40 -0
  66. package/dist/components/templates/SplitPageLayout.d.ts +44 -0
  67. package/dist/components/templates/index.d.ts +4 -0
  68. package/dist/components/totp/OtpInput.d.ts +32 -0
  69. package/dist/components/totp/QrCode.d.ts +21 -0
  70. package/dist/components/totp/TotpSettings.d.ts +38 -0
  71. package/dist/components/totp/TotpSetup.d.ts +23 -0
  72. package/dist/components/totp/TotpVerify.d.ts +25 -0
  73. package/dist/components/totp/index.d.ts +10 -0
  74. package/dist/components/wallet/CapabilityWarning.d.ts +11 -0
  75. package/dist/components/wallet/PasskeyPrompt.d.ts +34 -0
  76. package/dist/components/wallet/RecoveryPhraseDisplay.d.ts +18 -0
  77. package/dist/components/wallet/RecoveryPhraseInput.d.ts +21 -0
  78. package/dist/components/wallet/WalletAddressRow.d.ts +10 -0
  79. package/dist/components/wallet/WalletEnrollment.d.ts +15 -0
  80. package/dist/components/wallet/WalletManager.d.ts +9 -0
  81. package/dist/components/wallet/WalletRecovery.d.ts +19 -0
  82. package/dist/components/wallet/WalletStatus.d.ts +28 -0
  83. package/dist/components/wallet/WalletUnlock.d.ts +23 -0
  84. package/dist/components/wallet/index.d.ts +23 -0
  85. package/dist/components/webauthn/PasskeyLoginButton.d.ts +8 -0
  86. package/dist/context/CedrosLoginContext.d.ts +24 -0
  87. package/dist/context/CedrosLoginProvider.d.ts +17 -0
  88. package/dist/context/EmbeddedWalletExposure.d.ts +19 -0
  89. package/dist/context/useCedrosLogin.d.ts +12 -0
  90. package/dist/crypto/aesGcm.d.ts +89 -0
  91. package/dist/crypto/argon2.d.ts +65 -0
  92. package/dist/crypto/argon2Worker.d.ts +1 -0
  93. package/dist/crypto/argon2WorkerClient.d.ts +28 -0
  94. package/dist/crypto/bip39.d.ts +106 -0
  95. package/dist/crypto/capabilities.d.ts +35 -0
  96. package/dist/crypto/entropy.d.ts +56 -0
  97. package/dist/crypto/hkdf.d.ts +38 -0
  98. package/dist/crypto/index.d.ts +30 -0
  99. package/dist/crypto/secureWipe.d.ts +90 -0
  100. package/dist/crypto/shamir.d.ts +52 -0
  101. package/dist/crypto/solanaKeypair.d.ts +63 -0
  102. package/dist/crypto/types.d.ts +134 -0
  103. package/dist/crypto/webauthnPrf.d.ts +118 -0
  104. package/dist/email-only.cjs +1 -0
  105. package/dist/email-only.cjs.map +1 -0
  106. package/dist/email-only.d.ts +16 -0
  107. package/dist/email-only.js +15 -0
  108. package/dist/email-only.js.map +1 -0
  109. package/dist/google-only.cjs +1 -0
  110. package/dist/google-only.cjs.map +1 -0
  111. package/dist/google-only.d.ts +13 -0
  112. package/dist/google-only.js +11 -0
  113. package/dist/google-only.js.map +1 -0
  114. package/dist/hooks/useAdminDeposits.d.ts +10 -0
  115. package/dist/hooks/useAdminUsers.d.ts +28 -0
  116. package/dist/hooks/useAppleAuth.d.ts +52 -0
  117. package/dist/hooks/useAuth.d.ts +34 -0
  118. package/dist/hooks/useAuthSession.d.ts +19 -0
  119. package/dist/hooks/useAuthorize.d.ts +62 -0
  120. package/dist/hooks/useCredits.d.ts +11 -0
  121. package/dist/hooks/useDeposit.d.ts +16 -0
  122. package/dist/hooks/useEmailAuth.d.ts +60 -0
  123. package/dist/hooks/useGoogleAuth.d.ts +67 -0
  124. package/dist/hooks/useInstantLink.d.ts +42 -0
  125. package/dist/hooks/useInvites.d.ts +57 -0
  126. package/dist/hooks/useMembers.d.ts +52 -0
  127. package/dist/hooks/useOrgs.d.ts +49 -0
  128. package/dist/hooks/usePasswordReset.d.ts +32 -0
  129. package/dist/hooks/usePendingRecovery.d.ts +34 -0
  130. package/dist/hooks/useRateLimiter.d.ts +58 -0
  131. package/dist/hooks/useSessions.d.ts +45 -0
  132. package/dist/hooks/useSolanaAuth.d.ts +30 -0
  133. package/dist/hooks/useSystemSettings.d.ts +47 -0
  134. package/dist/hooks/useThemeManager.d.ts +11 -0
  135. package/dist/hooks/useTotp.d.ts +52 -0
  136. package/dist/hooks/useTotpVerify.d.ts +38 -0
  137. package/dist/hooks/useTransactionSigning.d.ts +45 -0
  138. package/dist/hooks/useWallet.d.ts +10 -0
  139. package/dist/hooks/useWalletDiscovery.d.ts +24 -0
  140. package/dist/hooks/useWalletEnrollment.d.ts +9 -0
  141. package/dist/hooks/useWalletMaterial.d.ts +10 -0
  142. package/dist/hooks/useWalletRecovery.d.ts +9 -0
  143. package/dist/hooks/useWalletSigning.d.ts +31 -0
  144. package/dist/hooks/useWebAuthn.d.ts +25 -0
  145. package/dist/i18n/I18nProvider.d.ts +16 -0
  146. package/dist/i18n/context.d.ts +6 -0
  147. package/dist/i18n/index.d.ts +5 -0
  148. package/dist/i18n/translations.d.ts +66 -0
  149. package/dist/i18n/useI18n.d.ts +9 -0
  150. package/dist/index.cjs +2061 -0
  151. package/dist/index.cjs.map +1 -0
  152. package/dist/index.d.ts +126 -0
  153. package/dist/index.js +14910 -0
  154. package/dist/index.js.map +1 -0
  155. package/dist/login-react.css +1 -0
  156. package/dist/solana-only.cjs +1 -0
  157. package/dist/solana-only.cjs.map +1 -0
  158. package/dist/solana-only.d.ts +13 -0
  159. package/dist/solana-only.js +11 -0
  160. package/dist/solana-only.js.map +1 -0
  161. package/dist/style.cjs +1 -0
  162. package/dist/style.cjs.map +1 -0
  163. package/dist/style.js +1 -0
  164. package/dist/style.js.map +1 -0
  165. package/dist/types/adminUser.d.ts +112 -0
  166. package/dist/types/auth.d.ts +122 -0
  167. package/dist/types/config.d.ts +266 -0
  168. package/dist/types/deposit.d.ts +488 -0
  169. package/dist/types/index.d.ts +11 -0
  170. package/dist/types/invite.d.ts +71 -0
  171. package/dist/types/member.d.ts +45 -0
  172. package/dist/types/org.d.ts +101 -0
  173. package/dist/types/session.d.ts +28 -0
  174. package/dist/types/systemSettings.d.ts +81 -0
  175. package/dist/types/totp.d.ts +52 -0
  176. package/dist/types/wallet.d.ts +309 -0
  177. package/dist/utils/adminUserApi.d.ts +51 -0
  178. package/dist/utils/apiClient.d.ts +78 -0
  179. package/dist/utils/cryptoShim.d.ts +17 -0
  180. package/dist/utils/csrf.d.ts +1 -0
  181. package/dist/utils/deviceDetection.d.ts +17 -0
  182. package/dist/utils/embeddedWallet.d.ts +75 -0
  183. package/dist/utils/inviteApi.d.ts +31 -0
  184. package/dist/utils/memberApi.d.ts +23 -0
  185. package/dist/utils/orgApi.d.ts +36 -0
  186. package/dist/utils/sanitization.d.ts +66 -0
  187. package/dist/utils/sessionApi.d.ts +16 -0
  188. package/dist/utils/silentWalletEnroll.d.ts +41 -0
  189. package/dist/utils/systemSettingsApi.d.ts +18 -0
  190. package/dist/utils/tabSync.d.ts +46 -0
  191. package/dist/utils/tokenManager.d.ts +107 -0
  192. package/dist/utils/unlockCredential.d.ts +5 -0
  193. package/dist/utils/validation.d.ts +48 -0
  194. package/dist/utils/walletDetection.d.ts +23 -0
  195. package/dist/utils/webauthnJson.d.ts +21 -0
  196. package/dist/validation-BeXIfuHB.cjs +1 -0
  197. package/dist/validation-BeXIfuHB.cjs.map +1 -0
  198. package/dist/validation-BebL7hMF.js +56 -0
  199. package/dist/validation-BebL7hMF.js.map +1 -0
  200. package/package.json +109 -0
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Authentication method used for login/registration
3
+ * TYPE-01: Must match backend AuthMethod enum in server/src/models/mod.rs
4
+ */
5
+ export type AuthMethod = 'email' | 'google' | 'apple' | 'solana' | 'webauthn' | 'sso';
6
+ /**
7
+ * Authenticated user information
8
+ */
9
+ export interface AuthUser {
10
+ id: string;
11
+ email?: string;
12
+ name?: string;
13
+ picture?: string;
14
+ walletAddress?: string;
15
+ authMethods: AuthMethod[];
16
+ emailVerified: boolean;
17
+ /** Whether TOTP 2FA is enabled for this user */
18
+ totpEnabled?: boolean;
19
+ createdAt: string;
20
+ updatedAt: string;
21
+ }
22
+ /**
23
+ * JWT token pair returned from authentication
24
+ */
25
+ export interface TokenPair {
26
+ accessToken: string;
27
+ refreshToken: string;
28
+ expiresIn: number;
29
+ }
30
+ /**
31
+ * Authentication error response
32
+ */
33
+ export interface AuthError {
34
+ code: AuthErrorCode;
35
+ message: string;
36
+ details?: Record<string, unknown>;
37
+ }
38
+ /**
39
+ * UI-08: Standardized error prop type for display components.
40
+ *
41
+ * Use this type for component props that display errors to users.
42
+ * Components should handle both AuthError objects and plain strings:
43
+ * - AuthError: structured error from API with code and message
44
+ * - string: simple error message for form validation or local errors
45
+ * - null: no error state
46
+ *
47
+ * @example
48
+ * ```tsx
49
+ * interface MyFormProps {
50
+ * error?: DisplayError;
51
+ * }
52
+ *
53
+ * // In component:
54
+ * const message = typeof error === 'string' ? error : error?.message;
55
+ * ```
56
+ */
57
+ export type DisplayError = AuthError | string | null;
58
+ /**
59
+ * Standard error codes
60
+ */
61
+ export type AuthErrorCode = 'INVALID_CREDENTIALS' | 'ACCOUNT_LOCKED' | 'EMAIL_EXISTS' | 'WALLET_EXISTS' | 'INVALID_TOKEN' | 'TOKEN_EXPIRED' | 'INVALID_SIGNATURE' | 'INVALID_PUBLIC_KEY' | 'CHALLENGE_EXPIRED' | 'VALIDATION_ERROR' | 'RATE_LIMITED' | 'NOT_FOUND' | 'FORBIDDEN' | 'UNAUTHORIZED' | 'STEP_UP_REQUIRED' | 'TOTP_REQUIRED' | 'INVALID_TOTP_CODE' | 'SERVICE_UNAVAILABLE' | 'SERVER_ERROR' | 'NETWORK_ERROR' | 'UNKNOWN_ERROR';
62
+ /**
63
+ * Authentication response from server
64
+ */
65
+ export interface AuthResponse {
66
+ user: AuthUser;
67
+ tokens?: TokenPair;
68
+ isNewUser: boolean;
69
+ callbackData?: Record<string, unknown>;
70
+ }
71
+ /**
72
+ * Solana challenge response
73
+ */
74
+ export interface ChallengeResponse {
75
+ nonce: string;
76
+ message: string;
77
+ expiresAt: string;
78
+ }
79
+ /**
80
+ * Authentication state
81
+ */
82
+ export type AuthState = 'idle' | 'loading' | 'authenticated' | 'unauthenticated' | 'error';
83
+ /**
84
+ * Password validation result
85
+ */
86
+ export interface PasswordValidation {
87
+ isValid: boolean;
88
+ errors: {
89
+ length?: string;
90
+ uppercase?: string;
91
+ lowercase?: string;
92
+ number?: string;
93
+ special?: string;
94
+ };
95
+ strength: 'weak' | 'fair' | 'good' | 'strong';
96
+ }
97
+ /**
98
+ * TYPE-03: Response when MFA is required to complete login
99
+ *
100
+ * When a user with MFA enabled logs in with valid credentials,
101
+ * the server returns this response instead of full tokens.
102
+ * The client must then call /auth/login/mfa with the mfaToken and TOTP code.
103
+ */
104
+ export interface MfaRequiredResponse {
105
+ /** Indicates MFA verification is required (always true) */
106
+ mfaRequired: true;
107
+ /** Temporary token to use for MFA verification (short-lived, ~5 min) */
108
+ mfaToken: string;
109
+ /** User ID (for client reference, e.g., showing "Hi, <user>") */
110
+ userId: string;
111
+ }
112
+ /**
113
+ * TYPE-03: Request to complete MFA during login
114
+ *
115
+ * After receiving MfaRequiredResponse, call POST /auth/login/mfa with this request.
116
+ */
117
+ export interface MfaLoginRequest {
118
+ /** The mfaToken from the initial login response */
119
+ mfaToken: string;
120
+ /** TOTP code from authenticator app (6 digits) */
121
+ code: string;
122
+ }
@@ -0,0 +1,266 @@
1
+ import { AuthUser, AuthMethod, AuthError } from './auth';
2
+ /**
3
+ * Solana network configuration
4
+ */
5
+ export type SolanaNetwork = 'mainnet-beta' | 'devnet';
6
+ /**
7
+ * Session storage mode
8
+ *
9
+ * **Security considerations:**
10
+ * - `cookie`: **Recommended.** HttpOnly cookies managed by server. Immune to XSS.
11
+ * - `memory`: Secure but lost on page refresh. Good for high-security applications.
12
+ * - `localStorage`: **Use with caution.** Tokens are accessible to any JavaScript
13
+ * on the page, making them vulnerable to XSS attacks. Only use when cookie-based
14
+ * auth is not possible (e.g., cross-origin scenarios without proper CORS).
15
+ */
16
+ export type SessionStorage = 'cookie' | 'memory' | 'localStorage' | 'sessionStorage';
17
+ /**
18
+ * Theme mode
19
+ */
20
+ export type ThemeMode = 'light' | 'dark' | 'auto';
21
+ /**
22
+ * Solana configuration options
23
+ */
24
+ export interface SolanaConfig {
25
+ /** Solana network to connect to. Default: 'mainnet-beta' */
26
+ network?: SolanaNetwork;
27
+ /** Auto-reconnect wallet on page load. Default: false */
28
+ autoConnect?: boolean;
29
+ }
30
+ /**
31
+ * Feature flags to enable/disable auth methods
32
+ */
33
+ export interface FeatureFlags {
34
+ /** Enable email/password auth. Default: true */
35
+ email?: boolean;
36
+ /** Enable Google OAuth. Default: true (requires googleClientId) */
37
+ google?: boolean;
38
+ /** Enable Apple Sign In. Default: true (requires appleClientId) */
39
+ apple?: boolean;
40
+ /** Enable Solana wallet sign-in. Default: true */
41
+ solana?: boolean;
42
+ /** Enable WebAuthn passkeys (server-managed). Default: true */
43
+ webauthn?: boolean;
44
+ /** Enable embedded wallet auto-enrollment on registration. Default: true */
45
+ walletEnrollment?: boolean;
46
+ }
47
+ /**
48
+ * Session handling configuration
49
+ *
50
+ * @security For best security, use the default `cookie` storage with `autoRefresh: true`.
51
+ * Avoid `localStorage` in production unless absolutely necessary.
52
+ */
53
+ export interface SessionConfig {
54
+ /**
55
+ * Where to store tokens. Default: 'cookie'
56
+ *
57
+ * @security `cookie` is strongly recommended for production use.
58
+ * See {@link SessionStorage} for security implications of each option.
59
+ */
60
+ storage?: SessionStorage;
61
+ /** Auto-refresh tokens before expiry. Default: true */
62
+ autoRefresh?: boolean;
63
+ /** Sync auth state across browser tabs. Default: true */
64
+ syncTabs?: boolean;
65
+ /** Storage key for tokens when using web storage. Default: 'cedros_tokens' */
66
+ persistKey?: string;
67
+ /**
68
+ * Explicitly allow web storage for tokens.
69
+ *
70
+ * @security This is intentionally opt-in because `localStorage` and
71
+ * `sessionStorage` are vulnerable to XSS token theft.
72
+ *
73
+ * If you enable this, also implement a strict CSP and audit any third-party scripts.
74
+ */
75
+ allowWebStorage?: boolean;
76
+ }
77
+ /**
78
+ * Authentication callbacks
79
+ */
80
+ export interface AuthCallbacks {
81
+ /** Called after successful login */
82
+ onLoginSuccess?: (user: AuthUser, method: AuthMethod) => void;
83
+ /** Called when login fails */
84
+ onLoginError?: (error: AuthError) => void;
85
+ /** Called after logout */
86
+ onLogout?: () => void;
87
+ /** Called when session expires */
88
+ onSessionExpired?: () => void;
89
+ }
90
+ /**
91
+ * CSS variable theme overrides
92
+ */
93
+ export interface ThemeOverrides {
94
+ '--cedros-primary'?: string;
95
+ '--cedros-primary-foreground'?: string;
96
+ '--cedros-background'?: string;
97
+ '--cedros-foreground'?: string;
98
+ '--cedros-muted'?: string;
99
+ '--cedros-muted-foreground'?: string;
100
+ '--cedros-border'?: string;
101
+ '--cedros-input'?: string;
102
+ '--cedros-ring'?: string;
103
+ '--cedros-radius'?: string;
104
+ '--cedros-destructive'?: string;
105
+ '--cedros-destructive-foreground'?: string;
106
+ [key: string]: string | undefined;
107
+ }
108
+ /**
109
+ * Forgot password behavior configuration
110
+ */
111
+ export interface ForgotPasswordConfig {
112
+ /**
113
+ * Mode for handling "forgot password" clicks.
114
+ * - 'reset': Shows ForgotPasswordForm (traditional reset flow)
115
+ * - 'instantLink': Sends an instant link for passwordless sign-in
116
+ * @default 'reset'
117
+ */
118
+ mode?: 'reset' | 'instantLink';
119
+ }
120
+ /**
121
+ * Terms of service checkbox configuration
122
+ */
123
+ export interface TermsOfServiceConfig {
124
+ /** Whether to show the checkbox. @default false */
125
+ show?: boolean;
126
+ /** Whether agreement is required to register. @default true (when shown) */
127
+ required?: boolean;
128
+ /** Default checked state. @default false */
129
+ defaultChecked?: boolean;
130
+ /** URL to terms of service page */
131
+ url?: string;
132
+ /** Custom label text. @default "I agree to the Terms of Service" */
133
+ label?: string;
134
+ }
135
+ /**
136
+ * Email marketing opt-in checkbox configuration
137
+ */
138
+ export interface EmailOptInConfig {
139
+ /** Whether to show the checkbox. @default false */
140
+ show?: boolean;
141
+ /** Default checked state. @default false */
142
+ defaultChecked?: boolean;
143
+ /** Custom label text. @default "Send me updates and news" */
144
+ label?: string;
145
+ }
146
+ /**
147
+ * Form behavior configuration
148
+ */
149
+ export interface FormConfig {
150
+ /** Forgot password behavior on sign in form */
151
+ forgotPassword?: ForgotPasswordConfig;
152
+ /** Terms of service checkbox on register form */
153
+ termsOfService?: TermsOfServiceConfig;
154
+ /** Email marketing opt-in checkbox on register form */
155
+ emailOptIn?: EmailOptInConfig;
156
+ }
157
+ /**
158
+ * Embedded wallet configuration
159
+ *
160
+ * Controls whether the embedded wallet is advertised to other Cedros modules
161
+ * (like cedros-pay) running in the same application.
162
+ */
163
+ export interface WalletConfig {
164
+ /**
165
+ * Expose embedded wallet availability via window global.
166
+ *
167
+ * When enabled, sets `window.__CEDROS_EMBEDDED_WALLET__` with:
168
+ * - `available`: boolean - whether user has enrolled SSS wallet
169
+ * - `publicKey`: string | null - Solana public key if available
170
+ *
171
+ * This allows other modules (e.g., cedros-pay) to detect embedded wallet
172
+ * and offer crypto payment options to users without browser wallet extensions.
173
+ *
174
+ * @security The signing function is NOT exposed on window. Signing must go
175
+ * through React context (useTransactionSigning hook) to prevent unauthorized
176
+ * access by arbitrary scripts.
177
+ *
178
+ * @default false
179
+ */
180
+ exposeAvailability?: boolean;
181
+ /**
182
+ * Whether to include the user's wallet public key in the window global.
183
+ *
184
+ * @security This is a privacy tradeoff: exposing a stable identifier on `window`
185
+ * makes it available to any script on the page.
186
+ *
187
+ * If you only need to know whether an embedded wallet exists, keep this `false`.
188
+ *
189
+ * @default false
190
+ */
191
+ exposePublicKey?: boolean;
192
+ /**
193
+ * SEC-004: Allowed domains for WebAuthn RP ID validation.
194
+ *
195
+ * In production, passkey operations will be rejected if the current hostname
196
+ * is not in this list. This prevents passkey registration on malicious domains
197
+ * that might be serving the app.
198
+ *
199
+ * @security Without this, an attacker could phish users to a lookalike domain
200
+ * and get them to register passkeys that only work on the malicious domain.
201
+ * While this doesn't compromise real credentials, it can be used in social
202
+ * engineering attacks.
203
+ *
204
+ * @example ['myapp.com', 'app.myapp.com']
205
+ * @default [] (localhost/127.0.0.1 always allowed for development)
206
+ */
207
+ allowedRpDomains?: string[];
208
+ }
209
+ /**
210
+ * Two-factor authentication (TOTP) configuration
211
+ *
212
+ * Admin-level settings for app-based 2FA using authenticator apps.
213
+ */
214
+ export interface TotpConfig {
215
+ /**
216
+ * Whether TOTP 2FA is enabled for the application.
217
+ * @default false
218
+ */
219
+ enabled?: boolean;
220
+ /**
221
+ * Whether TOTP 2FA is required for all users.
222
+ * If false, users can optionally enable it for their account.
223
+ * @default false
224
+ */
225
+ required?: boolean;
226
+ /**
227
+ * Issuer name shown in authenticator apps.
228
+ * @default appName or hostname
229
+ */
230
+ issuer?: string;
231
+ }
232
+ /**
233
+ * Full configuration for CedrosLoginProvider
234
+ */
235
+ export interface CedrosLoginConfig {
236
+ /** Auth server base URL */
237
+ serverUrl: string;
238
+ /** App name for Solana message: "Login to {appName}". Default: window.location.hostname */
239
+ appName?: string;
240
+ /** Google OAuth client ID. Required if Google auth enabled */
241
+ googleClientId?: string;
242
+ /** Apple Sign In client ID (Services ID). Required if Apple auth enabled */
243
+ appleClientId?: string;
244
+ /** Solana configuration options */
245
+ solana?: SolanaConfig;
246
+ /** Enable/disable auth methods */
247
+ features?: FeatureFlags;
248
+ /** Form behavior configuration (forgot password, terms, email opt-in) */
249
+ forms?: FormConfig;
250
+ /** TOTP/2FA configuration (app-based authenticator) */
251
+ totp?: TotpConfig;
252
+ /** Embedded wallet configuration */
253
+ wallet?: WalletConfig;
254
+ /** Session/token configuration */
255
+ session?: SessionConfig;
256
+ /** Authentication event callbacks */
257
+ callbacks?: AuthCallbacks;
258
+ /** Theme mode. Default: 'auto' */
259
+ theme?: ThemeMode;
260
+ /** CSS variable overrides for custom theming */
261
+ themeOverrides?: ThemeOverrides;
262
+ /** API request timeout in ms. Default: 10000 */
263
+ requestTimeout?: number;
264
+ /** Retry attempts on transient errors. Default: 2 */
265
+ retryAttempts?: number;
266
+ }