@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,58 @@
1
+ export interface UseRateLimiterOptions {
2
+ /** Maximum number of attempts allowed within the window */
3
+ maxAttempts?: number;
4
+ /** Time window in milliseconds */
5
+ windowMs?: number;
6
+ }
7
+ export interface UseRateLimiterReturn {
8
+ /**
9
+ * Check if an action is allowed. Throws an error if rate limited.
10
+ * Call this before performing the action.
11
+ */
12
+ checkLimit: () => void;
13
+ /**
14
+ * Check if an action is allowed without throwing.
15
+ * Returns true if allowed, false if rate limited.
16
+ */
17
+ isAllowed: () => boolean;
18
+ /**
19
+ * Get remaining attempts in current window
20
+ */
21
+ getRemainingAttempts: () => number;
22
+ /**
23
+ * Get time until rate limit resets (in ms)
24
+ */
25
+ getTimeUntilReset: () => number;
26
+ /**
27
+ * Reset the rate limiter (e.g., after successful action)
28
+ */
29
+ reset: () => void;
30
+ }
31
+ /**
32
+ * Rate limiting hook to prevent excessive API calls from the client.
33
+ *
34
+ * @param options - Rate limiter configuration
35
+ * @returns Rate limiter functions
36
+ *
37
+ * @example
38
+ * ```tsx
39
+ * function LoginForm() {
40
+ * const { checkLimit, getRemainingAttempts } = useRateLimiter({
41
+ * maxAttempts: 5,
42
+ * windowMs: 60000, // 1 minute
43
+ * });
44
+ *
45
+ * const handleLogin = async () => {
46
+ * try {
47
+ * checkLimit(); // Throws if rate limited
48
+ * await login(email, password);
49
+ * } catch (err) {
50
+ * if (err.message.includes('Too many attempts')) {
51
+ * // Show rate limit message
52
+ * }
53
+ * }
54
+ * };
55
+ * }
56
+ * ```
57
+ */
58
+ export declare function useRateLimiter(options?: UseRateLimiterOptions): UseRateLimiterReturn;
@@ -0,0 +1,45 @@
1
+ import { Session, AuthError, RevokeAllSessionsResponse } from '../types';
2
+ export interface UseSessionsReturn {
3
+ /** List of active sessions */
4
+ sessions: Session[];
5
+ /** Loading state */
6
+ isLoading: boolean;
7
+ /** Error state */
8
+ error: AuthError | null;
9
+ /** Fetch/refresh sessions list */
10
+ fetchSessions: () => Promise<void>;
11
+ /** Revoke all sessions (logout everywhere) */
12
+ revokeAllSessions: () => Promise<RevokeAllSessionsResponse>;
13
+ /** Number of other active sessions (excluding current) */
14
+ otherSessionCount: number;
15
+ }
16
+ /**
17
+ * Hook for managing user sessions across devices.
18
+ *
19
+ * @example
20
+ * ```tsx
21
+ * function SessionManager() {
22
+ * const { sessions, isLoading, revokeAllSessions, otherSessionCount } = useSessions();
23
+ *
24
+ * return (
25
+ * <div>
26
+ * <h3>Active Sessions ({sessions.length})</h3>
27
+ * <ul>
28
+ * {sessions.map(session => (
29
+ * <li key={session.id}>
30
+ * {session.userAgent}
31
+ * {session.isCurrent && ' (current)'}
32
+ * </li>
33
+ * ))}
34
+ * </ul>
35
+ * {otherSessionCount > 0 && (
36
+ * <button onClick={revokeAllSessions}>
37
+ * Sign out of {otherSessionCount} other device(s)
38
+ * </button>
39
+ * )}
40
+ * </div>
41
+ * );
42
+ * }
43
+ * ```
44
+ */
45
+ export declare function useSessions(): UseSessionsReturn;
@@ -0,0 +1,30 @@
1
+ import { AuthResponse, AuthError, ChallengeResponse } from '../types';
2
+ export interface UseSolanaAuthReturn {
3
+ requestChallenge: (publicKey: string) => Promise<ChallengeResponse>;
4
+ signIn: (publicKey: string, signature: string, message: string) => Promise<AuthResponse>;
5
+ isLoading: boolean;
6
+ error: AuthError | null;
7
+ clearError: () => void;
8
+ }
9
+ /**
10
+ * Hook for Solana wallet authentication.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * function SolanaLogin() {
15
+ * const { requestChallenge, signIn, isLoading } = useSolanaAuth();
16
+ * const { publicKey, signMessage } = useWallet();
17
+ *
18
+ * const handleLogin = async () => {
19
+ * const challenge = await requestChallenge(publicKey.toBase58());
20
+ * const signature = await signMessage(new TextEncoder().encode(challenge.message));
21
+ * const result = await signIn(
22
+ * publicKey.toBase58(),
23
+ * Buffer.from(signature).toString('base64'),
24
+ * challenge.message
25
+ * );
26
+ * };
27
+ * }
28
+ * ```
29
+ */
30
+ export declare function useSolanaAuth(): UseSolanaAuthReturn;
@@ -0,0 +1,47 @@
1
+ import { UseSystemSettingsReturn } from '../types';
2
+ /**
3
+ * Hook for managing system settings (admin only).
4
+ *
5
+ * Provides CRUD operations for system-wide configuration settings
6
+ * stored in the database. Only accessible to system administrators.
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * function SystemSettingsPanel() {
11
+ * const {
12
+ * settings,
13
+ * isLoading,
14
+ * error,
15
+ * fetchSettings,
16
+ * updateSettings,
17
+ * getValue,
18
+ * } = useSystemSettings();
19
+ *
20
+ * useEffect(() => {
21
+ * fetchSettings();
22
+ * }, [fetchSettings]);
23
+ *
24
+ * const handleSave = async () => {
25
+ * await updateSettings([
26
+ * { key: 'privacy_period_secs', value: '1209600' },
27
+ * ]);
28
+ * };
29
+ *
30
+ * return (
31
+ * <div>
32
+ * {Object.entries(settings).map(([category, items]) => (
33
+ * <section key={category}>
34
+ * <h3>{category}</h3>
35
+ * {items.map(item => (
36
+ * <div key={item.key}>
37
+ * {item.key}: {item.value}
38
+ * </div>
39
+ * ))}
40
+ * </section>
41
+ * ))}
42
+ * </div>
43
+ * );
44
+ * }
45
+ * ```
46
+ */
47
+ export declare function useSystemSettings(): UseSystemSettingsReturn;
@@ -0,0 +1,11 @@
1
+ import { ThemeMode, ThemeOverrides } from '../types';
2
+ export interface UseThemeManagerOptions {
3
+ theme?: ThemeMode;
4
+ themeOverrides?: ThemeOverrides;
5
+ }
6
+ /**
7
+ * Hook that manages theme application to the document root.
8
+ * Handles light/dark/auto themes and custom CSS variable overrides.
9
+ * Properly cleans up styles on unmount to prevent memory leaks.
10
+ */
11
+ export declare function useThemeManager({ theme, themeOverrides }: UseThemeManagerOptions): void;
@@ -0,0 +1,52 @@
1
+ import { AuthError, TotpStatus, TotpSetupResponse, TotpBackupCodesResponse, TotpSetupState } from '../types';
2
+ export interface UseTotpReturn {
3
+ /** Current TOTP status for the user */
4
+ status: TotpStatus | null;
5
+ /** Setup state for the enrollment flow */
6
+ setupState: TotpSetupState;
7
+ /** Setup data (secret, QR URL, backup codes) */
8
+ setupData: TotpSetupResponse | null;
9
+ /** Whether a request is in progress */
10
+ isLoading: boolean;
11
+ /** Error from the last request */
12
+ error: AuthError | null;
13
+ /** Fetch current TOTP status */
14
+ getStatus: () => Promise<TotpStatus>;
15
+ /** Start TOTP setup (generates secret and backup codes) */
16
+ beginSetup: () => Promise<TotpSetupResponse>;
17
+ /** Verify code and enable TOTP */
18
+ enableTotp: (code: string) => Promise<void>;
19
+ /** Disable TOTP (requires password confirmation) */
20
+ disableTotp: (password: string) => Promise<void>;
21
+ /** Regenerate recovery codes (requires current authenticator code) */
22
+ regenerateBackupCodes: (code: string) => Promise<TotpBackupCodesResponse>;
23
+ /** Clear error state */
24
+ clearError: () => void;
25
+ /** Reset to initial state */
26
+ reset: () => void;
27
+ }
28
+ /**
29
+ * Hook for TOTP (Time-based One-Time Password) two-factor authentication.
30
+ *
31
+ * Provides methods for:
32
+ * - Setting up TOTP with authenticator apps
33
+ * - Enabling/disabling TOTP for the user's account
34
+ * - Managing backup codes
35
+ *
36
+ * @example
37
+ * ```tsx
38
+ * function TotpSettings() {
39
+ * const { status, beginSetup, enableTotp, setupData } = useTotp();
40
+ *
41
+ * if (status?.enabled) {
42
+ * return <p>2FA is enabled</p>;
43
+ * }
44
+ *
45
+ * const handleSetup = async () => {
46
+ * const data = await beginSetup();
47
+ * // Show QR code from data.otpauthUri
48
+ * };
49
+ * }
50
+ * ```
51
+ */
52
+ export declare function useTotp(): UseTotpReturn;
@@ -0,0 +1,38 @@
1
+ import { AuthError, AuthResponse, TotpVerifyState } from '../types';
2
+ export interface UseTotpVerifyReturn {
3
+ /** Verification state */
4
+ state: TotpVerifyState;
5
+ /** Whether verification is in progress */
6
+ isLoading: boolean;
7
+ /** Error from the last request */
8
+ error: AuthError | null;
9
+ /** Verify MFA code during login */
10
+ verifyTotp: (mfaToken: string, code: string) => Promise<AuthResponse>;
11
+ /** Clear error state */
12
+ clearError: () => void;
13
+ /** Reset to initial state */
14
+ reset: () => void;
15
+ /** Number of remaining verification attempts before rate limiting */
16
+ remainingAttempts: number;
17
+ /** Time in ms until rate limit resets (0 if not rate limited) */
18
+ timeUntilReset: number;
19
+ }
20
+ /**
21
+ * Hook for verifying TOTP codes during the login flow.
22
+ *
23
+ * Used when a user has TOTP enabled and needs to provide
24
+ * their 6-digit code after password authentication.
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * function TotpVerifyStep({ mfaToken }) {
29
+ * const { verifyTotp, isLoading, error } = useTotpVerify();
30
+ *
31
+ * const handleVerify = async (code: string) => {
32
+ * const response = await verifyTotp(mfaToken, code);
33
+ * // User is now authenticated
34
+ * };
35
+ * }
36
+ * ```
37
+ */
38
+ export declare function useTotpVerify(): UseTotpVerifyReturn;
@@ -0,0 +1,45 @@
1
+ import { UnlockCredential } from '../types/wallet';
2
+ /** Signing method in use */
3
+ export type SigningMethod = 'external' | 'sss' | 'none';
4
+ /** Options for external wallet signing */
5
+ export interface ExternalSignOptions {
6
+ /**
7
+ * Callback to sign transaction with external wallet adapter.
8
+ * Only called when user has external Solana wallet.
9
+ *
10
+ * @param transaction - Transaction bytes to sign
11
+ * @returns Signature bytes (64 bytes Ed25519)
12
+ */
13
+ onExternalSign?: (transaction: Uint8Array) => Promise<Uint8Array>;
14
+ }
15
+ /** Return type for useTransactionSigning hook */
16
+ export interface UseTransactionSigningReturn {
17
+ /** Sign a transaction (routes to appropriate method) */
18
+ signTransaction: (transaction: Uint8Array, credential?: UnlockCredential) => Promise<Uint8Array>;
19
+ /** Which signing method is available */
20
+ signingMethod: SigningMethod;
21
+ /** Whether user can sign transactions */
22
+ canSign: boolean;
23
+ /** Whether signing is in progress */
24
+ isSigning: boolean;
25
+ /** Solana public key (from either wallet type) */
26
+ publicKey: string | null;
27
+ /** Whether user has external Solana wallet */
28
+ hasExternalWallet: boolean;
29
+ /** Whether SSS wallet is enrolled */
30
+ hasSssWallet: boolean;
31
+ /** Whether SSS wallet is unlocked (for session-based signing) */
32
+ isSssUnlocked: boolean;
33
+ /** Error from last signing attempt */
34
+ error: string | null;
35
+ /** Clear error */
36
+ clearError: () => void;
37
+ }
38
+ /**
39
+ * Unified transaction signing hook
40
+ *
41
+ * Automatically routes signing requests to the appropriate method:
42
+ * - External wallet: Uses provided callback
43
+ * - SSS wallet: Uses server-side signing
44
+ */
45
+ export declare function useTransactionSigning(options?: ExternalSignOptions): UseTransactionSigningReturn;
@@ -0,0 +1,10 @@
1
+ import { WalletContextValue } from '../types/wallet';
2
+ /**
3
+ * Main wallet hook
4
+ *
5
+ * Provides wallet status, capabilities, and refresh functionality.
6
+ * Distinguishes between external Solana wallet and SSS embedded wallet.
7
+ *
8
+ * Returns safe defaults when called outside CedrosLoginProvider.
9
+ */
10
+ export declare function useWallet(): WalletContextValue;
@@ -0,0 +1,24 @@
1
+ import { WalletRecoveryMode } from '../types/wallet';
2
+ /** Return type for useWalletDiscovery hook */
3
+ export interface UseWalletDiscoveryReturn {
4
+ /** Whether wallet feature is enabled on server */
5
+ walletEnabled: boolean;
6
+ /** Recovery mode: share_c_only or full_seed */
7
+ recoveryMode: WalletRecoveryMode;
8
+ /** Session unlock TTL in seconds */
9
+ unlockTtlSeconds: number;
10
+ /** Whether config is still loading */
11
+ isLoading: boolean;
12
+ /** Error message if fetch failed */
13
+ error: string | null;
14
+ /** Refetch the config */
15
+ refetch: () => Promise<void>;
16
+ }
17
+ /**
18
+ * Hook to fetch wallet discovery configuration from server
19
+ *
20
+ * Automatically fetches on mount and caches the result.
21
+ * Default values are used if fetch fails or wallet is not enabled.
22
+ * Returns defaults when used outside CedrosLoginProvider.
23
+ */
24
+ export declare function useWalletDiscovery(): UseWalletDiscoveryReturn;
@@ -0,0 +1,9 @@
1
+ import { UseWalletEnrollmentReturn } from '../types/wallet';
2
+ /**
3
+ * Hook for wallet enrollment
4
+ *
5
+ * Supports auth methods:
6
+ * - password: User sets a wallet password (Argon2id KDF)
7
+ * - passkey: Uses passkey PRF extension
8
+ */
9
+ export declare function useWalletEnrollment(): UseWalletEnrollmentReturn;
@@ -0,0 +1,10 @@
1
+ import { UseWalletMaterialReturn } from '../types/wallet';
2
+ /**
3
+ * Hook for wallet material API operations
4
+ *
5
+ * Signing happens server-side: server stores Share A (encrypted) and Share B
6
+ * (plaintext), combines shares JIT for signing, and wipes immediately after.
7
+ *
8
+ * Safe to call outside CedrosLoginProvider - returns no-op functions that throw.
9
+ */
10
+ export declare function useWalletMaterial(): UseWalletMaterialReturn;
@@ -0,0 +1,9 @@
1
+ import { UseWalletRecoveryReturn } from '../types/wallet';
2
+ /**
3
+ * Hook for wallet recovery
4
+ *
5
+ * Supports two recovery modes based on server config:
6
+ * - full_seed: User enters the full 12-word seed phrase (portable)
7
+ * - share_c_only: User enters 12-word Share C phrase, server provides Share B (app-locked)
8
+ */
9
+ export declare function useWalletRecovery(): UseWalletRecoveryReturn;
@@ -0,0 +1,31 @@
1
+ import { UseWalletSigningReturn, UnlockCredential } from '../types/wallet';
2
+ /**
3
+ * Hook for wallet transaction signing
4
+ *
5
+ * Usage:
6
+ * ```tsx
7
+ * const { signTransaction, isSigning, error } = useWalletSigning();
8
+ *
9
+ * // Sign with password
10
+ * const signature = await signTransaction(txBytes, { type: 'password', password: 'xxx' });
11
+ *
12
+ * // Sign with PIN
13
+ * const signature = await signTransaction(txBytes, { type: 'password', password: 'secret' });
14
+ *
15
+ * // Sign with passkey (PRF)
16
+ * const signature = await signTransaction(txBytes, { type: 'prfOutput', prfOutput: 'base64...' });
17
+ * ```
18
+ */
19
+ export declare function useWalletSigning(): UseWalletSigningReturn;
20
+ /**
21
+ * Helper hook to get PRF output for passkey signing
22
+ *
23
+ * This handles the WebAuthn PRF flow and returns a credential
24
+ * that can be used with useWalletSigning.
25
+ */
26
+ export declare function usePasskeySigning(): {
27
+ getPasskeyCredential: () => Promise<UnlockCredential | null>;
28
+ isAuthenticating: boolean;
29
+ error: string | null;
30
+ clearError: () => void;
31
+ };
@@ -0,0 +1,25 @@
1
+ import { AuthError, AuthResponse } from '../types';
2
+ export interface UseWebAuthnReturn {
3
+ isSupported: boolean;
4
+ isLoading: boolean;
5
+ error: AuthError | null;
6
+ clearError: () => void;
7
+ /** Start a server-managed WebAuthn authentication ceremony (login). */
8
+ authenticatePasskey: (params?: {
9
+ email?: string;
10
+ }) => Promise<AuthResponse>;
11
+ /** Register a new passkey for the currently authenticated user. */
12
+ registerPasskey: (params?: {
13
+ label?: string;
14
+ }) => Promise<{
15
+ credentialId: string;
16
+ label?: string;
17
+ }>;
18
+ }
19
+ /**
20
+ * Server-managed WebAuthn (passkey) authentication + registration.
21
+ *
22
+ * - Login: /webauthn/auth/options -> navigator.credentials.get -> /webauthn/auth/verify
23
+ * - Registration: /webauthn/register/options -> navigator.credentials.create -> /webauthn/register/verify
24
+ */
25
+ export declare function useWebAuthn(): UseWebAuthnReturn;
@@ -0,0 +1,16 @@
1
+ import { ReactNode } from 'react';
2
+ import { Translations } from './translations';
3
+ type DeepPartial<T> = {
4
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
5
+ };
6
+ export interface I18nProviderProps {
7
+ children: ReactNode;
8
+ locale?: string;
9
+ translations?: DeepPartial<Translations>;
10
+ }
11
+ /**
12
+ * Provider for internationalization support.
13
+ * Allows overriding default English translations with custom strings.
14
+ */
15
+ export declare function I18nProvider({ children, locale, translations: customTranslations, }: I18nProviderProps): import("react/jsx-runtime").JSX.Element;
16
+ export {};
@@ -0,0 +1,6 @@
1
+ import { Translations } from './translations';
2
+ export interface I18nContextValue {
3
+ t: Translations;
4
+ locale: string;
5
+ }
6
+ export declare const I18nContext: import('react').Context<I18nContextValue | null>;
@@ -0,0 +1,5 @@
1
+ export { I18nProvider } from './I18nProvider';
2
+ export type { I18nProviderProps } from './I18nProvider';
3
+ export { useTranslations, useLocale } from './useI18n';
4
+ export { defaultTranslations, mergeTranslations } from './translations';
5
+ export type { Translations } from './translations';
@@ -0,0 +1,66 @@
1
+ export interface Translations {
2
+ auth: {
3
+ email: string;
4
+ password: string;
5
+ confirmPassword: string;
6
+ name: string;
7
+ optional: string;
8
+ createPassword: string;
9
+ confirmYourPassword: string;
10
+ emailPlaceholder: string;
11
+ namePlaceholder: string;
12
+ };
13
+ buttons: {
14
+ signIn: string;
15
+ signUp: string;
16
+ signOut: string;
17
+ createAccount: string;
18
+ continueWithGoogle: string;
19
+ continueWithSolana: string;
20
+ forgotPassword: string;
21
+ resetPassword: string;
22
+ sendVerification: string;
23
+ };
24
+ messages: {
25
+ signingIn: string;
26
+ signingUp: string;
27
+ creatingAccount: string;
28
+ connectingWallet: string;
29
+ verifyingSignature: string;
30
+ passwordsDoNotMatch: string;
31
+ alreadyHaveAccount: string;
32
+ dontHaveAccount: string;
33
+ orContinueWith: string;
34
+ };
35
+ errors: {
36
+ invalidCredentials: string;
37
+ emailExists: string;
38
+ invalidEmail: string;
39
+ weakPassword: string;
40
+ networkError: string;
41
+ unknownError: string;
42
+ walletNotFound: string;
43
+ signatureRejected: string;
44
+ challengeExpired: string;
45
+ };
46
+ passwordValidation: {
47
+ minLength: string;
48
+ uppercase: string;
49
+ lowercase: string;
50
+ number: string;
51
+ special: string;
52
+ weak: string;
53
+ fair: string;
54
+ good: string;
55
+ strong: string;
56
+ };
57
+ }
58
+ export declare const defaultTranslations: Translations;
59
+ /**
60
+ * Deep merge translations, allowing partial overrides
61
+ */
62
+ export declare function mergeTranslations(base: Translations, overrides: DeepPartial<Translations>): Translations;
63
+ type DeepPartial<T> = {
64
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
65
+ };
66
+ export {};
@@ -0,0 +1,9 @@
1
+ import { Translations } from './translations';
2
+ /**
3
+ * Hook to access translations
4
+ */
5
+ export declare function useTranslations(): Translations;
6
+ /**
7
+ * Hook to access current locale
8
+ */
9
+ export declare function useLocale(): string;