@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,101 @@
1
+ /**
2
+ * Organization role in RBAC hierarchy
3
+ * owner > admin > member > viewer
4
+ */
5
+ export type OrgRole = 'owner' | 'admin' | 'member' | 'viewer';
6
+ /**
7
+ * Organization entity
8
+ */
9
+ export interface Organization {
10
+ id: string;
11
+ name: string;
12
+ slug: string;
13
+ logoUrl?: string;
14
+ isPersonal: boolean;
15
+ createdAt: string;
16
+ updatedAt: string;
17
+ }
18
+ /**
19
+ * Membership - user's relationship to an organization
20
+ */
21
+ export interface Membership {
22
+ id?: string;
23
+ userId?: string;
24
+ orgId?: string;
25
+ role: OrgRole;
26
+ joinedAt?: string;
27
+ }
28
+ /**
29
+ * Organization with membership details for the current user
30
+ */
31
+ export interface OrgWithMembership extends Organization {
32
+ membership: Membership;
33
+ }
34
+ /**
35
+ * Permission types for RBAC
36
+ */
37
+ export type Permission = 'org:delete' | 'org:update' | 'org:read' | 'member:invite' | 'member:remove' | 'member:role_change' | 'member:read' | 'invite:create' | 'invite:cancel' | 'invite:read' | 'audit:read';
38
+ /**
39
+ * Create organization request
40
+ */
41
+ export interface CreateOrgRequest {
42
+ name: string;
43
+ slug?: string;
44
+ }
45
+ /**
46
+ * Update organization request
47
+ */
48
+ export interface UpdateOrgRequest {
49
+ name?: string;
50
+ slug?: string;
51
+ logoUrl?: string;
52
+ }
53
+ /**
54
+ * List organizations response
55
+ */
56
+ export interface ListOrgsResponse {
57
+ orgs: Array<Organization & {
58
+ role: OrgRole;
59
+ }>;
60
+ total?: number;
61
+ limit?: number;
62
+ offset?: number;
63
+ }
64
+ /**
65
+ * Authorization check request
66
+ */
67
+ export interface AuthorizeRequest {
68
+ orgId: string;
69
+ action: string;
70
+ resource?: string;
71
+ resourceId?: string;
72
+ }
73
+ /**
74
+ * Authorization check response
75
+ */
76
+ export interface AuthorizeResponse {
77
+ allowed: boolean;
78
+ reason?: string;
79
+ }
80
+ /**
81
+ * Permissions response
82
+ */
83
+ export interface PermissionsResponse {
84
+ permissions: Permission[];
85
+ role: OrgRole;
86
+ }
87
+ /**
88
+ * Organization state for context
89
+ */
90
+ export interface OrgState {
91
+ /** Currently active organization */
92
+ activeOrg: OrgWithMembership | null;
93
+ /** All organizations the user belongs to */
94
+ orgs: OrgWithMembership[];
95
+ /** User's permissions in the active org */
96
+ permissions: Permission[];
97
+ /** User's role in the active org */
98
+ role: OrgRole | null;
99
+ /** Loading state for org operations */
100
+ isLoading: boolean;
101
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Active session information
3
+ */
4
+ export interface Session {
5
+ id: string;
6
+ ipAddress?: string;
7
+ userAgent?: string;
8
+ createdAt: string;
9
+ expiresAt: string;
10
+ /** Whether this is the current session */
11
+ isCurrent: boolean;
12
+ }
13
+ /**
14
+ * Response from listing sessions
15
+ */
16
+ export interface ListSessionsResponse {
17
+ sessions: Session[];
18
+ total: number;
19
+ limit: number;
20
+ offset: number;
21
+ }
22
+ /**
23
+ * Response from revoking all sessions
24
+ */
25
+ export interface RevokeAllSessionsResponse {
26
+ revokedCount: number;
27
+ message: string;
28
+ }
@@ -0,0 +1,81 @@
1
+ /**
2
+ * System settings types for admin configuration management
3
+ */
4
+ /** Individual system setting */
5
+ export interface SystemSetting {
6
+ key: string;
7
+ value: string;
8
+ description: string | null;
9
+ updatedAt: string;
10
+ updatedBy: string | null;
11
+ }
12
+ /** Response from GET /admin/settings */
13
+ export interface ListSystemSettingsResponse {
14
+ /** Settings grouped by category (privacy, withdrawal, rate_limit) */
15
+ settings: Record<string, SystemSetting[]>;
16
+ }
17
+ /** Request to update a single setting */
18
+ export interface UpdateSettingRequest {
19
+ key: string;
20
+ value: string;
21
+ }
22
+ /** Request body for PATCH /admin/settings */
23
+ export interface UpdateSystemSettingsRequest {
24
+ settings: UpdateSettingRequest[];
25
+ }
26
+ /** Response from PATCH /admin/settings */
27
+ export interface UpdateSystemSettingsResponse {
28
+ updated: SystemSetting[];
29
+ }
30
+ /** Category metadata for UI display */
31
+ export interface SettingCategoryMeta {
32
+ label: string;
33
+ description: string;
34
+ }
35
+ /** Preset option for settings with suggested values */
36
+ export interface SettingPreset {
37
+ label: string;
38
+ value: string;
39
+ }
40
+ /** Setting metadata for UI rendering */
41
+ export interface SettingMeta {
42
+ key: string;
43
+ label: string;
44
+ /** Detailed description explaining what this setting does */
45
+ description: string;
46
+ /** Unit for display (e.g., 'seconds', 'requests', '%') */
47
+ unit?: string;
48
+ /** Minimum allowed value */
49
+ min?: number;
50
+ /** Maximum allowed value */
51
+ max?: number;
52
+ /** Input type determines how the setting is rendered */
53
+ inputType: 'number' | 'duration' | 'percentage' | 'select' | 'text' | 'tokenSymbolList' | 'tokenList';
54
+ /** Preset values for quick selection (used with 'select' or as suggestions) */
55
+ presets?: SettingPreset[];
56
+ /** Value threshold that triggers a warning */
57
+ warningThreshold?: {
58
+ above?: number;
59
+ below?: number;
60
+ message: string;
61
+ };
62
+ /** Step for number inputs */
63
+ step?: number;
64
+ }
65
+ /** Return type for useSystemSettings hook */
66
+ export interface UseSystemSettingsReturn {
67
+ /** Settings grouped by category */
68
+ settings: Record<string, SystemSetting[]>;
69
+ /** Whether data is loading */
70
+ isLoading: boolean;
71
+ /** Whether an update is in progress */
72
+ isUpdating: boolean;
73
+ /** Error state */
74
+ error: Error | null;
75
+ /** Fetch settings from server */
76
+ fetchSettings: () => Promise<void>;
77
+ /** Update one or more settings */
78
+ updateSettings: (updates: UpdateSettingRequest[]) => Promise<void>;
79
+ /** Get a setting value by key */
80
+ getValue: (key: string) => string | undefined;
81
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * TOTP (Time-based One-Time Password) types for two-factor authentication
3
+ */
4
+ /**
5
+ * User's TOTP status
6
+ */
7
+ export interface TotpStatus {
8
+ /** Whether TOTP is enabled for this user */
9
+ enabled: boolean;
10
+ /** Number of unused recovery codes remaining */
11
+ recoveryCodesRemaining: number;
12
+ }
13
+ /**
14
+ * Response from TOTP setup initiation
15
+ */
16
+ export interface TotpSetupResponse {
17
+ /** Base32-encoded secret for manual entry */
18
+ secret: string;
19
+ /** otpauth:// URI for QR code generation */
20
+ otpauthUri: string;
21
+ /** One-time recovery codes (shown only once) */
22
+ recoveryCodes: string[];
23
+ }
24
+ /**
25
+ * Request to verify and enable TOTP
26
+ */
27
+ export interface TotpEnableRequest {
28
+ /** 6-digit code from authenticator app */
29
+ code: string;
30
+ }
31
+ /**
32
+ * Request to verify TOTP during login
33
+ */
34
+ export interface TotpVerifyRequest {
35
+ /** 6-digit code from authenticator app or recovery code */
36
+ code: string;
37
+ }
38
+ /**
39
+ * Response with new backup codes
40
+ */
41
+ export interface TotpBackupCodesResponse {
42
+ /** New one-time recovery codes */
43
+ recoveryCodes: string[];
44
+ }
45
+ /**
46
+ * TOTP setup state for the enrollment flow
47
+ */
48
+ export type TotpSetupState = 'idle' | 'loading' | 'setup' | 'verifying' | 'success' | 'error';
49
+ /**
50
+ * TOTP verification state for the login flow
51
+ */
52
+ export type TotpVerifyState = 'idle' | 'verifying' | 'success' | 'error';
@@ -0,0 +1,309 @@
1
+ import { WalletStatus, CryptoCapabilities, EnrollmentState, RecoveryState, KdfParams } from '../crypto';
2
+ export type { WalletStatus, CryptoCapabilities, EnrollmentState, RecoveryState, KdfParams };
3
+ /**
4
+ * Wallet recovery mode (configured server-side via WALLET_RECOVERY_MODE)
5
+ * - share_c_only: User gets Share C only. Recovery within app, not portable.
6
+ * - full_seed: User gets full seed. Can use wallet elsewhere (portable).
7
+ * - none: No recovery option. Used for Privacy Cash deposits to prevent front-running.
8
+ */
9
+ export type WalletRecoveryMode = 'share_c_only' | 'full_seed' | 'none';
10
+ /**
11
+ * Wallet discovery config from server
12
+ */
13
+ export interface WalletDiscoveryConfig {
14
+ /** Whether wallet feature is enabled */
15
+ enabled: boolean;
16
+ /** Recovery mode: share_c_only or full_seed */
17
+ recoveryMode: WalletRecoveryMode;
18
+ /** Session unlock TTL in seconds */
19
+ unlockTtlSeconds: number;
20
+ }
21
+ /**
22
+ * Authentication method for Share A encryption
23
+ * - password: Email users use their login password (Argon2id KDF)
24
+ * - passkey: Users with passkey login use PRF extension (HKDF)
25
+ */
26
+ export type ShareAAuthMethod = 'password' | 'passkey';
27
+ /**
28
+ * Wallet material response from server
29
+ * Note: Server no longer returns share ciphertexts - shares stay on server
30
+ */
31
+ export interface WalletMaterialResponse {
32
+ solanaPubkey: string;
33
+ schemeVersion: number;
34
+ shareAAuthMethod: ShareAAuthMethod;
35
+ /** PRF salt for passkey auth method (base64, 32 bytes) */
36
+ prfSalt?: string;
37
+ createdAt: string;
38
+ updatedAt: string;
39
+ }
40
+ /** Request to enroll wallet */
41
+ export interface WalletEnrollRequest {
42
+ solanaPubkey: string;
43
+ /** Auth method for Share A encryption */
44
+ shareAAuthMethod: ShareAAuthMethod;
45
+ /** Encrypted Share A (base64) */
46
+ shareACiphertext: string;
47
+ /** Nonce for Share A encryption (base64, 12 bytes) */
48
+ shareANonce: string;
49
+ /** KDF salt for password/PIN method (base64) */
50
+ shareAKdfSalt?: string;
51
+ /** KDF params for password/PIN method */
52
+ shareAKdfParams?: KdfParams;
53
+ /** PRF salt for passkey method (base64, 32 bytes) */
54
+ prfSalt?: string;
55
+ /** Plaintext Share B (base64) - SSS math protects it */
56
+ shareB: string;
57
+ /**
58
+ * Recovery data (base64) - sent when recovery mode is enabled
59
+ * Contains the full seed for server-side storage until user acknowledges
60
+ */
61
+ recoveryData?: string;
62
+ }
63
+ /** Request to get Share B for Share C recovery mode */
64
+ export interface ShareCRecoveryRequest {
65
+ /** Share C data (base64, 32 bytes decoded from mnemonic) */
66
+ shareC: string;
67
+ }
68
+ /** Response from Share C recovery endpoint */
69
+ export interface ShareCRecoveryResponse {
70
+ /** Share B (base64) */
71
+ shareB: string;
72
+ /** Solana pubkey (for verification) */
73
+ solanaPubkey: string;
74
+ }
75
+ /** Request to recover wallet (replace existing with new credentials) */
76
+ export interface WalletRecoverRequest {
77
+ /** Solana pubkey (must match existing wallet to prove ownership) */
78
+ solanaPubkey: string;
79
+ /** Auth method for Share A encryption */
80
+ shareAAuthMethod: ShareAAuthMethod;
81
+ /** Encrypted Share A (base64) */
82
+ shareACiphertext: string;
83
+ /** Nonce for Share A encryption (base64, 12 bytes) */
84
+ shareANonce: string;
85
+ /** KDF salt for password/PIN method (base64) */
86
+ shareAKdfSalt?: string;
87
+ /** KDF params for password/PIN method */
88
+ shareAKdfParams?: KdfParams;
89
+ /** PRF salt for passkey method (base64, 32 bytes) */
90
+ prfSalt?: string;
91
+ /** Plaintext Share B (base64) */
92
+ shareB: string;
93
+ }
94
+ /**
95
+ * Credential for unlocking wallet / signing transactions (frontend internal use)
96
+ *
97
+ * TYPE-02: This type uses explicit `type` discriminator for TypeScript narrowing.
98
+ * When sending to server API, convert to `UnlockCredentialRequest` which uses
99
+ * the flattened format expected by the backend (`{ password: '...' }` not
100
+ * `{ type: 'password', password: '...' }`).
101
+ *
102
+ * @see UnlockCredentialRequest for API request format
103
+ */
104
+ export type UnlockCredential = {
105
+ type: 'password';
106
+ password: string;
107
+ } | {
108
+ type: 'prfOutput';
109
+ prfOutput: string;
110
+ };
111
+ /** Request to sign a transaction */
112
+ export interface SignTransactionRequest {
113
+ /** Transaction bytes (base64) */
114
+ transaction: string;
115
+ /** Unlock credential */
116
+ credential?: UnlockCredentialRequest;
117
+ }
118
+ /**
119
+ * Credential for API request (flattened format matching server)
120
+ *
121
+ * TYPE-02: Server uses Serde's flattened enum format, so only ONE of these
122
+ * fields should be present in the request object. Do NOT include `type` field.
123
+ *
124
+ * @example { password: 'secret' }
125
+ * @example { prfOutput: 'base64...' }
126
+ */
127
+ export type UnlockCredentialRequest = {
128
+ password: string;
129
+ } | {
130
+ prfOutput: string;
131
+ };
132
+ /** Response from transaction signing */
133
+ export interface SignTransactionResponse {
134
+ /** Ed25519 signature (base64, 64 bytes) */
135
+ signature: string;
136
+ /** Solana pubkey that signed */
137
+ pubkey: string;
138
+ }
139
+ /**
140
+ * Request to rotate user secret (re-encrypt Share A)
141
+ *
142
+ * TYPE-04: Current credential fields are FLATTENED into this struct (not nested).
143
+ * The server uses `#[serde(flatten)]` so credential fields appear at root level.
144
+ * E.g., send `{ password: "xxx", newAuthMethod: "passkey", ... }` not `{ currentCredential: {...} }`
145
+ *
146
+ * BUILD-01: Uses intersection type instead of interface-extends because
147
+ * UnlockCredentialRequest is a union type (TypeScript doesn't allow interfaces
148
+ * to extend union types).
149
+ */
150
+ export type RotateUserSecretRequest = UnlockCredentialRequest & {
151
+ /** New auth method */
152
+ newAuthMethod: ShareAAuthMethod;
153
+ /** New encrypted Share A (base64) */
154
+ shareACiphertext: string;
155
+ /** New nonce (base64, 12 bytes) */
156
+ shareANonce: string;
157
+ /** New KDF salt for password/PIN (base64) */
158
+ shareAKdfSalt?: string;
159
+ /** New KDF params for password/PIN */
160
+ shareAKdfParams?: KdfParams;
161
+ /** New PRF salt for passkey (base64, 32 bytes) */
162
+ prfSalt?: string;
163
+ };
164
+ /** Message response from server */
165
+ export interface MessageResponse {
166
+ message: string;
167
+ }
168
+ /** Request to unlock wallet for session-based signing */
169
+ export interface WalletUnlockRequest {
170
+ /** Unlock credential (flattened format) */
171
+ credential: UnlockCredentialRequest;
172
+ }
173
+ /** Response from wallet unlock */
174
+ export interface WalletUnlockResponse {
175
+ /** Whether wallet is now unlocked */
176
+ unlocked: boolean;
177
+ /** TTL in seconds until auto-lock */
178
+ ttlSeconds: number;
179
+ }
180
+ /** Wallet status response from server */
181
+ export interface WalletStatusApiResponse {
182
+ /** Whether SSS embedded wallet is enrolled */
183
+ enrolled: boolean;
184
+ /** Whether wallet is currently unlocked for signing */
185
+ unlocked: boolean;
186
+ /** Solana public key (from SSS wallet if enrolled, or external wallet if connected) */
187
+ solanaPubkey?: string;
188
+ /** Auth method for SSS wallet (if enrolled) */
189
+ authMethod?: ShareAAuthMethod;
190
+ /** Whether user signed in with external Solana wallet (not SSS) */
191
+ hasExternalWallet: boolean;
192
+ }
193
+ /** Wallet context value */
194
+ export interface WalletContextValue {
195
+ /** Current wallet status */
196
+ status: WalletStatus;
197
+ /** Solana public key (from SSS wallet if enrolled, or external wallet) */
198
+ solanaPubkey: string | null;
199
+ /** Auth method for Share A (if enrolled in SSS wallet) */
200
+ authMethod: ShareAAuthMethod | null;
201
+ /** Whether user signed in with external Solana wallet (not SSS) */
202
+ hasExternalWallet: boolean;
203
+ /** Whether SSS wallet is unlocked for signing */
204
+ isUnlocked: boolean;
205
+ /** Crypto capabilities */
206
+ capabilities: CryptoCapabilities | null;
207
+ /** Whether all required capabilities are available */
208
+ isSupported: boolean;
209
+ /** Error message if any */
210
+ error: string | null;
211
+ /** Refresh wallet status */
212
+ refresh: () => Promise<void>;
213
+ /** Clear error */
214
+ clearError: () => void;
215
+ }
216
+ /** Enrollment hook return value */
217
+ export interface UseWalletEnrollmentReturn {
218
+ /** Current enrollment state */
219
+ state: EnrollmentState;
220
+ /** Start enrollment with password (email users) */
221
+ startEnrollmentWithPassword: (password: string) => Promise<void>;
222
+ /** Start enrollment with passkey PRF */
223
+ startEnrollmentWithPasskey: () => Promise<void>;
224
+ /** Confirm user has saved recovery phrase */
225
+ confirmRecoveryPhrase: () => void;
226
+ /** Cancel enrollment */
227
+ cancel: () => void;
228
+ /** Whether enrollment is in progress */
229
+ isEnrolling: boolean;
230
+ }
231
+ /**
232
+ * Signing hook return value
233
+ * Signing is server-side. Client just provides credential.
234
+ */
235
+ export interface UseWalletSigningReturn {
236
+ /** Sign a transaction */
237
+ signTransaction: (transaction: Uint8Array, credential?: UnlockCredential) => Promise<Uint8Array>;
238
+ /** Whether signing is in progress */
239
+ isSigning: boolean;
240
+ /** Error from last signing attempt */
241
+ error: string | null;
242
+ /** Clear error */
243
+ clearError: () => void;
244
+ }
245
+ /** Recovery hook return value */
246
+ export interface UseWalletRecoveryReturn {
247
+ /** Current recovery state */
248
+ state: RecoveryState;
249
+ /** Start recovery: validate phrase, then set new credential */
250
+ startRecovery: (words: string[], method: ShareAAuthMethod, credential: string) => Promise<void>;
251
+ /** Cancel recovery */
252
+ cancel: () => void;
253
+ /** Whether recovery is in progress */
254
+ isRecovering: boolean;
255
+ }
256
+ /** Wallet material hook return value */
257
+ export interface UseWalletMaterialReturn {
258
+ /** Fetch wallet status (enrolled, unlocked, external wallet) */
259
+ getStatus: () => Promise<WalletStatusApiResponse>;
260
+ /** Fetch wallet material (for SSS wallet details) */
261
+ getMaterial: () => Promise<WalletMaterialResponse | null>;
262
+ /** Enroll new SSS wallet */
263
+ enroll: (request: WalletEnrollRequest) => Promise<void>;
264
+ /** Recover wallet (replace existing with new credentials) */
265
+ recover: (request: WalletRecoverRequest) => Promise<void>;
266
+ /** Sign a transaction (SSS wallet) */
267
+ signTransaction: (request: SignTransactionRequest) => Promise<SignTransactionResponse>;
268
+ /** Rotate user secret */
269
+ rotateUserSecret: (request: RotateUserSecretRequest) => Promise<void>;
270
+ /** Unlock wallet for session-based signing (credential cached server-side) */
271
+ unlock: (credential: UnlockCredential) => Promise<WalletUnlockResponse>;
272
+ /** Lock wallet (clear cached credential) */
273
+ lock: () => Promise<void>;
274
+ /** Get Share B for Share C recovery mode (proves ownership via Share C) */
275
+ getShareBForRecovery: (request: ShareCRecoveryRequest) => Promise<ShareCRecoveryResponse>;
276
+ /** Whether request is in progress */
277
+ isLoading: boolean;
278
+ /** Error from last request */
279
+ error: string | null;
280
+ /** Clear error */
281
+ clearError: () => void;
282
+ }
283
+ /** PRF capability hook return value */
284
+ export interface UsePrfCapabilityReturn {
285
+ /** Whether PRF is supported */
286
+ isSupported: boolean;
287
+ /** Whether check is in progress */
288
+ isChecking: boolean;
289
+ /** Error message if check failed */
290
+ error: string | null;
291
+ /** Recheck PRF support */
292
+ recheck: () => Promise<void>;
293
+ }
294
+ /** Response from pending wallet recovery check */
295
+ export interface PendingWalletRecoveryResponse {
296
+ /** Whether there is pending recovery data to acknowledge */
297
+ hasPendingRecovery: boolean;
298
+ /** Type of recovery data: "share_c" or "full_seed" */
299
+ recoveryType?: string;
300
+ /** Recovery phrase (BIP-39 mnemonic or base64 seed) */
301
+ recoveryPhrase?: string;
302
+ /** When the recovery data expires */
303
+ expiresAt?: string;
304
+ }
305
+ /** Request to acknowledge receipt of recovery phrase */
306
+ export interface AcknowledgeRecoveryRequest {
307
+ /** Confirmation that user has saved the recovery phrase */
308
+ confirmed: boolean;
309
+ }
@@ -0,0 +1,51 @@
1
+ import { AdminUser, AdminUserCreditsResponse, AdjustCreditsRequest, ListAdminUsersResponse, ListUsersParams, UpdateUserRequest } from '../types';
2
+ import { AdminDepositListResponse, AdminUserWithdrawalHistoryResponse } from '../types/deposit';
3
+ /**
4
+ * API client for admin user operations
5
+ *
6
+ * Requires system admin privileges.
7
+ */
8
+ export declare class AdminUserApiClient {
9
+ private client;
10
+ constructor(baseUrl: string, timeoutMs?: number, retryAttempts?: number, getAccessToken?: () => string | null);
11
+ /**
12
+ * List all users in the system
13
+ */
14
+ listUsers(params?: ListUsersParams): Promise<ListAdminUsersResponse>;
15
+ /**
16
+ * Get a specific user by ID
17
+ */
18
+ getUser(userId: string): Promise<AdminUser>;
19
+ /**
20
+ * Set a user's system admin status
21
+ */
22
+ setSystemAdmin(userId: string, isAdmin: boolean): Promise<void>;
23
+ /**
24
+ * Update a user's profile
25
+ */
26
+ updateUser(userId: string, data: UpdateUserRequest): Promise<AdminUser>;
27
+ /**
28
+ * Delete a user
29
+ */
30
+ deleteUser(userId: string): Promise<void>;
31
+ /**
32
+ * Send a password reset email to a user
33
+ */
34
+ forcePasswordReset(userId: string): Promise<void>;
35
+ /**
36
+ * Adjust a user's credits
37
+ */
38
+ adjustCredits(userId: string, data: AdjustCreditsRequest): Promise<void>;
39
+ /**
40
+ * Get a user's deposit history
41
+ */
42
+ getUserDeposits(userId: string, params?: ListUsersParams): Promise<AdminDepositListResponse>;
43
+ /**
44
+ * Get a user's credit stats and transaction history
45
+ */
46
+ getUserCredits(userId: string, params?: ListUsersParams): Promise<AdminUserCreditsResponse>;
47
+ /**
48
+ * Get a user's withdrawal history
49
+ */
50
+ getUserWithdrawalHistory(userId: string, params?: ListUsersParams): Promise<AdminUserWithdrawalHistoryResponse>;
51
+ }