@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.
- package/LICENSE +21 -0
- package/README.md +1183 -0
- package/dist/EmailRegisterForm-D_uCEdX9.cjs +1 -0
- package/dist/EmailRegisterForm-D_uCEdX9.cjs.map +1 -0
- package/dist/EmailRegisterForm-m3rX3A6X.js +2923 -0
- package/dist/EmailRegisterForm-m3rX3A6X.js.map +1 -0
- package/dist/ErrorMessage-Bm1j5mBT.js +2042 -0
- package/dist/ErrorMessage-Bm1j5mBT.js.map +1 -0
- package/dist/ErrorMessage-CntMyn93.cjs +1 -0
- package/dist/ErrorMessage-CntMyn93.cjs.map +1 -0
- package/dist/GoogleLoginButton-CJNJ-THo.cjs +1 -0
- package/dist/GoogleLoginButton-CJNJ-THo.cjs.map +1 -0
- package/dist/GoogleLoginButton-CvDoOc-0.js +227 -0
- package/dist/GoogleLoginButton-CvDoOc-0.js.map +1 -0
- package/dist/SolanaLoginButton-BlSgPW50.cjs +1 -0
- package/dist/SolanaLoginButton-BlSgPW50.cjs.map +1 -0
- package/dist/SolanaLoginButton-h32xN2PQ.js +261 -0
- package/dist/SolanaLoginButton-h32xN2PQ.js.map +1 -0
- package/dist/assets/argon2Worker-Bi5TuQvD.js +1 -0
- package/dist/assets/argon2Worker-Bi5TuQvD.js.map +1 -0
- package/dist/components/LoginButton.d.ts +23 -0
- package/dist/components/LoginForm.d.ts +9 -0
- package/dist/components/LoginModal.d.ts +9 -0
- package/dist/components/admin/AdminUserDetail.d.ts +21 -0
- package/dist/components/admin/AdminUserList.d.ts +25 -0
- package/dist/components/admin/CedrosAdminDashboard.d.ts +48 -0
- package/dist/components/admin/SystemSettings.d.ts +19 -0
- package/dist/components/apple/AppleLoginButton.d.ts +29 -0
- package/dist/components/deposit/CreditBalance.d.ts +19 -0
- package/dist/components/deposit/DepositFlow.d.ts +118 -0
- package/dist/components/deposit/FeeConfigDisplay.d.ts +15 -0
- package/dist/components/deposit/History.d.ts +21 -0
- package/dist/components/deposit/TieredAmountSlider.d.ts +19 -0
- package/dist/components/deposit/TokenSelector.d.ts +23 -0
- package/dist/components/deposit/admin/AdminDepositList.d.ts +21 -0
- package/dist/components/deposit/admin/AdminDepositStats.d.ts +15 -0
- package/dist/components/deposit/admin/AdminPrivacyPeriodDeposits.d.ts +19 -0
- package/dist/components/deposit/admin/AdminWithdrawalHistory.d.ts +19 -0
- package/dist/components/deposit/admin/AdminWithdrawalQueue.d.ts +23 -0
- package/dist/components/deposit/admin/PrivacySystemStatus.d.ts +15 -0
- package/dist/components/deposit/admin/index.d.ts +17 -0
- package/dist/components/deposit/index.d.ts +12 -0
- package/dist/components/deposit/tierUtils.d.ts +8 -0
- package/dist/components/deposit/tokens.d.ts +19 -0
- package/dist/components/email/EmailLoginForm.d.ts +11 -0
- package/dist/components/email/EmailRegisterForm.d.ts +14 -0
- package/dist/components/email/ForgotPasswordForm.d.ts +17 -0
- package/dist/components/email/PasswordInput.d.ts +14 -0
- package/dist/components/email/ResetPasswordForm.d.ts +22 -0
- package/dist/components/google/GoogleLoginButton.d.ts +12 -0
- package/dist/components/invites/InviteForm.d.ts +38 -0
- package/dist/components/invites/InviteList.d.ts +40 -0
- package/dist/components/members/MemberList.d.ts +47 -0
- package/dist/components/org/CreateOrgForm.d.ts +7 -0
- package/dist/components/org/OrgAvatar.d.ts +7 -0
- package/dist/components/org/OrgListView.d.ts +9 -0
- package/dist/components/org/OrgSelector.d.ts +51 -0
- package/dist/components/org/OrgSwitcher.d.ts +47 -0
- package/dist/components/org/icons.d.ts +8 -0
- package/dist/components/sessions/SessionList.d.ts +33 -0
- package/dist/components/shared/ErrorBoundary.d.ts +38 -0
- package/dist/components/shared/ErrorMessage.d.ts +14 -0
- package/dist/components/shared/LoadingSpinner.d.ts +16 -0
- package/dist/components/solana/SolanaLoginButton.d.ts +49 -0
- package/dist/components/templates/FullPageLayout.d.ts +40 -0
- package/dist/components/templates/SplitPageLayout.d.ts +44 -0
- package/dist/components/templates/index.d.ts +4 -0
- package/dist/components/totp/OtpInput.d.ts +32 -0
- package/dist/components/totp/QrCode.d.ts +21 -0
- package/dist/components/totp/TotpSettings.d.ts +38 -0
- package/dist/components/totp/TotpSetup.d.ts +23 -0
- package/dist/components/totp/TotpVerify.d.ts +25 -0
- package/dist/components/totp/index.d.ts +10 -0
- package/dist/components/wallet/CapabilityWarning.d.ts +11 -0
- package/dist/components/wallet/PasskeyPrompt.d.ts +34 -0
- package/dist/components/wallet/RecoveryPhraseDisplay.d.ts +18 -0
- package/dist/components/wallet/RecoveryPhraseInput.d.ts +21 -0
- package/dist/components/wallet/WalletAddressRow.d.ts +10 -0
- package/dist/components/wallet/WalletEnrollment.d.ts +15 -0
- package/dist/components/wallet/WalletManager.d.ts +9 -0
- package/dist/components/wallet/WalletRecovery.d.ts +19 -0
- package/dist/components/wallet/WalletStatus.d.ts +28 -0
- package/dist/components/wallet/WalletUnlock.d.ts +23 -0
- package/dist/components/wallet/index.d.ts +23 -0
- package/dist/components/webauthn/PasskeyLoginButton.d.ts +8 -0
- package/dist/context/CedrosLoginContext.d.ts +24 -0
- package/dist/context/CedrosLoginProvider.d.ts +17 -0
- package/dist/context/EmbeddedWalletExposure.d.ts +19 -0
- package/dist/context/useCedrosLogin.d.ts +12 -0
- package/dist/crypto/aesGcm.d.ts +89 -0
- package/dist/crypto/argon2.d.ts +65 -0
- package/dist/crypto/argon2Worker.d.ts +1 -0
- package/dist/crypto/argon2WorkerClient.d.ts +28 -0
- package/dist/crypto/bip39.d.ts +106 -0
- package/dist/crypto/capabilities.d.ts +35 -0
- package/dist/crypto/entropy.d.ts +56 -0
- package/dist/crypto/hkdf.d.ts +38 -0
- package/dist/crypto/index.d.ts +30 -0
- package/dist/crypto/secureWipe.d.ts +90 -0
- package/dist/crypto/shamir.d.ts +52 -0
- package/dist/crypto/solanaKeypair.d.ts +63 -0
- package/dist/crypto/types.d.ts +134 -0
- package/dist/crypto/webauthnPrf.d.ts +118 -0
- package/dist/email-only.cjs +1 -0
- package/dist/email-only.cjs.map +1 -0
- package/dist/email-only.d.ts +16 -0
- package/dist/email-only.js +15 -0
- package/dist/email-only.js.map +1 -0
- package/dist/google-only.cjs +1 -0
- package/dist/google-only.cjs.map +1 -0
- package/dist/google-only.d.ts +13 -0
- package/dist/google-only.js +11 -0
- package/dist/google-only.js.map +1 -0
- package/dist/hooks/useAdminDeposits.d.ts +10 -0
- package/dist/hooks/useAdminUsers.d.ts +28 -0
- package/dist/hooks/useAppleAuth.d.ts +52 -0
- package/dist/hooks/useAuth.d.ts +34 -0
- package/dist/hooks/useAuthSession.d.ts +19 -0
- package/dist/hooks/useAuthorize.d.ts +62 -0
- package/dist/hooks/useCredits.d.ts +11 -0
- package/dist/hooks/useDeposit.d.ts +16 -0
- package/dist/hooks/useEmailAuth.d.ts +60 -0
- package/dist/hooks/useGoogleAuth.d.ts +67 -0
- package/dist/hooks/useInstantLink.d.ts +42 -0
- package/dist/hooks/useInvites.d.ts +57 -0
- package/dist/hooks/useMembers.d.ts +52 -0
- package/dist/hooks/useOrgs.d.ts +49 -0
- package/dist/hooks/usePasswordReset.d.ts +32 -0
- package/dist/hooks/usePendingRecovery.d.ts +34 -0
- package/dist/hooks/useRateLimiter.d.ts +58 -0
- package/dist/hooks/useSessions.d.ts +45 -0
- package/dist/hooks/useSolanaAuth.d.ts +30 -0
- package/dist/hooks/useSystemSettings.d.ts +47 -0
- package/dist/hooks/useThemeManager.d.ts +11 -0
- package/dist/hooks/useTotp.d.ts +52 -0
- package/dist/hooks/useTotpVerify.d.ts +38 -0
- package/dist/hooks/useTransactionSigning.d.ts +45 -0
- package/dist/hooks/useWallet.d.ts +10 -0
- package/dist/hooks/useWalletDiscovery.d.ts +24 -0
- package/dist/hooks/useWalletEnrollment.d.ts +9 -0
- package/dist/hooks/useWalletMaterial.d.ts +10 -0
- package/dist/hooks/useWalletRecovery.d.ts +9 -0
- package/dist/hooks/useWalletSigning.d.ts +31 -0
- package/dist/hooks/useWebAuthn.d.ts +25 -0
- package/dist/i18n/I18nProvider.d.ts +16 -0
- package/dist/i18n/context.d.ts +6 -0
- package/dist/i18n/index.d.ts +5 -0
- package/dist/i18n/translations.d.ts +66 -0
- package/dist/i18n/useI18n.d.ts +9 -0
- package/dist/index.cjs +2061 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +126 -0
- package/dist/index.js +14910 -0
- package/dist/index.js.map +1 -0
- package/dist/login-react.css +1 -0
- package/dist/solana-only.cjs +1 -0
- package/dist/solana-only.cjs.map +1 -0
- package/dist/solana-only.d.ts +13 -0
- package/dist/solana-only.js +11 -0
- package/dist/solana-only.js.map +1 -0
- package/dist/style.cjs +1 -0
- package/dist/style.cjs.map +1 -0
- package/dist/style.js +1 -0
- package/dist/style.js.map +1 -0
- package/dist/types/adminUser.d.ts +112 -0
- package/dist/types/auth.d.ts +122 -0
- package/dist/types/config.d.ts +266 -0
- package/dist/types/deposit.d.ts +488 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/invite.d.ts +71 -0
- package/dist/types/member.d.ts +45 -0
- package/dist/types/org.d.ts +101 -0
- package/dist/types/session.d.ts +28 -0
- package/dist/types/systemSettings.d.ts +81 -0
- package/dist/types/totp.d.ts +52 -0
- package/dist/types/wallet.d.ts +309 -0
- package/dist/utils/adminUserApi.d.ts +51 -0
- package/dist/utils/apiClient.d.ts +78 -0
- package/dist/utils/cryptoShim.d.ts +17 -0
- package/dist/utils/csrf.d.ts +1 -0
- package/dist/utils/deviceDetection.d.ts +17 -0
- package/dist/utils/embeddedWallet.d.ts +75 -0
- package/dist/utils/inviteApi.d.ts +31 -0
- package/dist/utils/memberApi.d.ts +23 -0
- package/dist/utils/orgApi.d.ts +36 -0
- package/dist/utils/sanitization.d.ts +66 -0
- package/dist/utils/sessionApi.d.ts +16 -0
- package/dist/utils/silentWalletEnroll.d.ts +41 -0
- package/dist/utils/systemSettingsApi.d.ts +18 -0
- package/dist/utils/tabSync.d.ts +46 -0
- package/dist/utils/tokenManager.d.ts +107 -0
- package/dist/utils/unlockCredential.d.ts +5 -0
- package/dist/utils/validation.d.ts +48 -0
- package/dist/utils/walletDetection.d.ts +23 -0
- package/dist/utils/webauthnJson.d.ts +21 -0
- package/dist/validation-BeXIfuHB.cjs +1 -0
- package/dist/validation-BeXIfuHB.cjs.map +1 -0
- package/dist/validation-BebL7hMF.js +56 -0
- package/dist/validation-BebL7hMF.js.map +1 -0
- 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
|
+
}
|