@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,35 @@
1
+ import { CryptoCapabilities } from './types';
2
+ /**
3
+ * Check all required crypto capabilities
4
+ *
5
+ * @returns Capability check results
6
+ */
7
+ export declare function checkCryptoCapabilities(): Promise<CryptoCapabilities>;
8
+ /**
9
+ * Get a human-readable message about missing capabilities
10
+ *
11
+ * @param capabilities - Capability check results
12
+ * @returns Error message describing what's missing, or null if all supported
13
+ */
14
+ export declare function getMissingCapabilitiesMessage(capabilities: CryptoCapabilities): string | null;
15
+ /**
16
+ * Check if the browser is known to support all required features
17
+ *
18
+ * @returns Object with browser info and support status
19
+ */
20
+ export declare function getBrowserSupportInfo(): {
21
+ browser: string;
22
+ version: string;
23
+ likelySupported: boolean;
24
+ };
25
+ /**
26
+ * Get cached capabilities or check if not cached
27
+ *
28
+ * @param forceRefresh - If true, bypass cache and recheck
29
+ * @returns Capability check results
30
+ */
31
+ export declare function getCryptoCapabilities(forceRefresh?: boolean): Promise<CryptoCapabilities>;
32
+ /**
33
+ * Clear the capability cache (useful for testing)
34
+ */
35
+ export declare function clearCapabilityCache(): void;
@@ -0,0 +1,56 @@
1
+ import { Seed, AesNonce, Argon2Salt, PrfSalt } from './types';
2
+ /**
3
+ * Get cryptographically secure random bytes
4
+ *
5
+ * @param length - Number of bytes to generate
6
+ * @returns Random bytes
7
+ * @throws Error if WebCrypto is not available
8
+ */
9
+ export declare function getRandomBytes(length: number): Uint8Array;
10
+ /**
11
+ * Generate a cryptographically secure 16-byte seed for wallet derivation
12
+ *
13
+ * Note: 16 bytes (128 bits) matches standard Solana wallet format.
14
+ *
15
+ * @returns 16-byte seed
16
+ * @throws Error if WebCrypto is not available
17
+ */
18
+ export declare function generateSeed(): Seed;
19
+ /**
20
+ * Generate a 12-byte nonce for AES-GCM encryption
21
+ *
22
+ * Security: AES-GCM requires a unique nonce per encryption with the same key.
23
+ * Using random nonces is safe for reasonable message counts (< 2^32).
24
+ *
25
+ * CRYPTO-03: For high-volume encryption scenarios (>2^30 messages with same key),
26
+ * the birthday bound risk of nonce collision increases. Recommendations:
27
+ * 1. Rotate encryption keys periodically (e.g., every 2^20 encryptions)
28
+ * 2. Use counter-based nonces instead of random for sequential encryption
29
+ * 3. Monitor encryption count and trigger re-keying before limits are reached
30
+ *
31
+ * For typical wallet use cases (encrypting seed once), random nonces are safe.
32
+ *
33
+ * @returns 12-byte nonce
34
+ * @throws Error if WebCrypto is not available
35
+ */
36
+ export declare function generateNonce(): AesNonce;
37
+ /**
38
+ * Generate a 16-byte salt for Argon2id KDF
39
+ *
40
+ * Security: Salt must be unique per user/password combination.
41
+ * 16 bytes provides sufficient uniqueness.
42
+ *
43
+ * @returns 16-byte salt
44
+ * @throws Error if WebCrypto is not available
45
+ */
46
+ export declare function generateArgon2Salt(): Argon2Salt;
47
+ /**
48
+ * Generate a 32-byte salt for WebAuthn PRF extension
49
+ *
50
+ * Security: PRF salt is used as input to the PRF to derive unique
51
+ * per-credential keys. Must be stored alongside encrypted share.
52
+ *
53
+ * @returns 32-byte PRF salt
54
+ * @throws Error if WebCrypto is not available
55
+ */
56
+ export declare function generatePrfSalt(): PrfSalt;
@@ -0,0 +1,38 @@
1
+ import { EncryptionKey } from './types';
2
+ /**
3
+ * Derive an encryption key using HKDF-SHA256
4
+ *
5
+ * @param inputKeyMaterial - Raw key material (e.g., from PRF)
6
+ * @param salt - Optional salt (if not provided, uses zero-filled buffer)
7
+ * @param info - Context/application-specific info string
8
+ * @param outputLength - Desired output key length in bytes (default: 32)
9
+ * @returns Derived key
10
+ */
11
+ export declare function hkdfDerive(inputKeyMaterial: Uint8Array, salt: Uint8Array | undefined, info: string, outputLength?: number): Promise<Uint8Array>;
12
+ /**
13
+ * Derive a 256-bit encryption key from PRF output
14
+ *
15
+ * @param prfOutput - Output from WebAuthn PRF extension (typically 32 bytes)
16
+ * @param prfSalt - Salt used with PRF (stored with encrypted share)
17
+ * @returns 32-byte encryption key suitable for AES-256-GCM
18
+ */
19
+ export declare function deriveKeyFromPrf(prfOutput: Uint8Array, prfSalt: Uint8Array): Promise<EncryptionKey>;
20
+ /**
21
+ * Derive a key with domain separation for different purposes
22
+ *
23
+ * @param inputKeyMaterial - Base key material
24
+ * @param domain - Domain separator string (e.g., 'signing', 'encryption')
25
+ * @param salt - Optional salt
26
+ * @returns Derived key
27
+ *
28
+ * @security Domain strings MUST be unique across the codebase. Using the same
29
+ * domain with the same input key material will produce identical keys, which
30
+ * could lead to key reuse vulnerabilities. See module-level docs for reserved domains.
31
+ */
32
+ export declare function deriveKeyWithDomain(inputKeyMaterial: Uint8Array, domain: string, salt?: Uint8Array): Promise<Uint8Array>;
33
+ /**
34
+ * Check if HKDF is supported in the current environment
35
+ *
36
+ * @returns true if HKDF is available
37
+ */
38
+ export declare function isHkdfSupported(): Promise<boolean>;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Crypto module exports for SSS wallet implementation
3
+ *
4
+ * This module provides all cryptographic primitives needed for the
5
+ * non-custodial Solana wallet feature using Shamir Secret Sharing.
6
+ *
7
+ * Key components:
8
+ * - Entropy: Secure random number generation
9
+ * - Shamir: Secret splitting and reconstruction
10
+ * - AES-GCM: Authenticated encryption
11
+ * - Argon2: Password-based key derivation
12
+ * - HKDF: Key derivation from PRF output
13
+ * - BIP-39: Mnemonic encoding for recovery phrase
14
+ * - WebAuthn PRF: Device key derivation via passkeys
15
+ * - Solana Keypair: Ed25519 keypair derivation
16
+ * - Secure Wipe: Memory cleanup utilities
17
+ * - Capabilities: Feature detection
18
+ */
19
+ export * from './types';
20
+ export { getRandomBytes, generateSeed, generateNonce, generateArgon2Salt, generatePrfSalt, } from './entropy';
21
+ export { wipeBytes, wipeAll, withSecureCleanup, withSecureCleanupSync, createSecureContainer, type SecureContainer, } from './secureWipe';
22
+ export { aesGcmEncrypt, aesGcmDecrypt, aesGcmEncryptToBase64, aesGcmDecryptFromBase64, encryptWithPasswordKey, decryptWithPasswordKey, encryptAndWipe, uint8ArrayToBase64, base64ToUint8Array, type AesGcmEncryptResult, } from './aesGcm';
23
+ export { hkdfDerive, deriveKeyFromPrf, deriveKeyWithDomain, isHkdfSupported } from './hkdf';
24
+ export { argon2Derive, argon2DeriveFromBytes, validateKdfParams, isArgon2Supported, verifyPassword, getRecommendedParams, } from './argon2';
25
+ export { argon2DeriveInWorker } from './argon2WorkerClient';
26
+ export { splitSecret, combineShares, verifyShares, getShareIndex, padToLength, SHAMIR_THRESHOLD, SHAMIR_TOTAL, type ShareId, type ShamirSplitResult, } from './shamir';
27
+ export { shareToMnemonic, mnemonicToShare, seedToMnemonic, mnemonicToSeed, isValidMnemonic, isValidWord, getWordSuggestions, generateRandomMnemonic, formatMnemonicForDisplay, parseMnemonicInput, wipeMnemonic, getWordlist, getWordIndex, MNEMONIC_WORD_COUNT, } from './bip39';
28
+ export { isWebAuthnAvailable, isPrfSupported, registerPasskeyWithPrf, authenticateWithPrf, authenticateWithDiscoverablePrf, getEncryptionKeyFromPasskey, isCredentialAvailable, type PasskeyRegistrationResult, type PasskeyAuthResult, } from './webauthnPrf';
29
+ export { deriveKeypairFromSeed, getPublicKeyFromSeed, publicKeyToBase58, base58ToPublicKey, isValidSolanaAddress, type SolanaKeypair, } from './solanaKeypair';
30
+ export { checkCryptoCapabilities, getMissingCapabilitiesMessage, getBrowserSupportInfo, getCryptoCapabilities, clearCapabilityCache, } from './capabilities';
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Secure memory wiping utilities
3
+ *
4
+ * Security: JavaScript does not guarantee memory clearing due to GC and
5
+ * JIT optimization. These functions provide best-effort clearing of
6
+ * sensitive data. For truly sensitive operations, consider using
7
+ * WebAssembly with explicit memory management.
8
+ *
9
+ * IMPORTANT - String vs Uint8Array:
10
+ * - Uint8Array CAN be wiped (wipeBytes) - use for keys, seeds, passwords
11
+ * - Strings CANNOT be wiped in JavaScript - they are immutable
12
+ * - The wipeString() function returns '' but does NOT clear memory
13
+ * - Always prefer Uint8Array for sensitive cryptographic material
14
+ *
15
+ * Best practices:
16
+ * - Call wipe functions as soon as sensitive data is no longer needed
17
+ * - Use try/finally blocks to ensure wiping on errors
18
+ * - Keep sensitive data lifetime as short as possible
19
+ * - Convert sensitive strings to Uint8Array immediately, wipe after use
20
+ */
21
+ /**
22
+ * Best-effort wipe of a Uint8Array by zeroing all bytes
23
+ *
24
+ * Warning: JavaScript JIT may optimize away this operation. This provides
25
+ * defense-in-depth but is not a guarantee against memory inspection.
26
+ *
27
+ * @param data - Array to wipe
28
+ */
29
+ export declare function wipeBytes(data: Uint8Array): void;
30
+ /**
31
+ * Wipe multiple byte arrays
32
+ *
33
+ * @param arrays - Arrays to wipe
34
+ */
35
+ export declare function wipeAll(...arrays: (Uint8Array | undefined | null)[]): void;
36
+ /**
37
+ * Best-effort wipe of a string by replacing with spaces
38
+ *
39
+ * @security CRYPTO-2: JavaScript strings are immutable - this is a BEST-EFFORT
40
+ * operation only. The original string content WILL persist in memory until
41
+ * garbage collected, and may be copied by the JS engine's string interning.
42
+ * There is NO WAY to securely wipe strings in JavaScript.
43
+ *
44
+ * DO NOT rely on this for security-critical wiping. Always prefer Uint8Array
45
+ * for sensitive data (keys, passwords, seeds) which CAN be securely wiped.
46
+ *
47
+ * @deprecated This function provides NO security guarantee. It exists only
48
+ * for API completeness. Use Uint8Array + wipeBytes() for sensitive data.
49
+ *
50
+ * @param _str - String to "wipe" (cannot actually be cleared)
51
+ * @returns Empty string (original cannot be modified)
52
+ */
53
+ export declare function wipeString(_str: string): string;
54
+ /**
55
+ * Execute a function with automatic cleanup of byte arrays
56
+ *
57
+ * @param arrays - Arrays to wipe after function completes
58
+ * @param fn - Function to execute
59
+ * @returns Result of function
60
+ */
61
+ export declare function withSecureCleanup<T>(arrays: Uint8Array[], fn: () => Promise<T>): Promise<T>;
62
+ /**
63
+ * Execute a synchronous function with automatic cleanup of byte arrays
64
+ *
65
+ * @param arrays - Arrays to wipe after function completes
66
+ * @param fn - Function to execute
67
+ * @returns Result of function
68
+ */
69
+ export declare function withSecureCleanupSync<T>(arrays: Uint8Array[], fn: () => T): T;
70
+ /**
71
+ * Create a scoped container for sensitive byte data with automatic cleanup
72
+ *
73
+ * Usage:
74
+ * ```typescript
75
+ * const container = createSecureContainer();
76
+ * try {
77
+ * const key = container.track(generateKey());
78
+ * // use key...
79
+ * } finally {
80
+ * container.wipeAll();
81
+ * }
82
+ * ```
83
+ */
84
+ export declare function createSecureContainer(): SecureContainer;
85
+ export interface SecureContainer {
86
+ /** Track a byte array for later cleanup */
87
+ track<T extends Uint8Array>(data: T): T;
88
+ /** Wipe all tracked arrays */
89
+ wipeAll(): void;
90
+ }
@@ -0,0 +1,52 @@
1
+ import { Seed, ShamirShare } from './types';
2
+ /** Shamir threshold (minimum shares to reconstruct) */
3
+ export declare const SHAMIR_THRESHOLD = 2;
4
+ /** Total number of shares */
5
+ export declare const SHAMIR_TOTAL = 3;
6
+ /** Share identifiers */
7
+ export type ShareId = 'A' | 'B' | 'C';
8
+ /** Result of splitting a secret into shares */
9
+ export interface ShamirSplitResult {
10
+ /** Share A (for password encryption) */
11
+ shareA: ShamirShare;
12
+ /** Share B (for device PRF encryption) */
13
+ shareB: ShamirShare;
14
+ /** Share C (for recovery phrase) */
15
+ shareC: ShamirShare;
16
+ }
17
+ /**
18
+ * Split a 16-byte seed into 3 shares using Shamir's Secret Sharing
19
+ *
20
+ * @param seed - 16-byte seed to split
21
+ * @returns Three shares (any 2 can reconstruct the seed)
22
+ */
23
+ export declare function splitSecret(seed: Seed): ShamirSplitResult;
24
+ /**
25
+ * Combine 2 shares to reconstruct the original seed
26
+ *
27
+ * @param share1 - First share
28
+ * @param share2 - Second share (must be different from first)
29
+ * @returns Reconstructed 16-byte seed (MAINT-03: fixed from incorrect "32-byte")
30
+ * @throws Error if shares are invalid or cannot reconstruct
31
+ */
32
+ export declare function combineShares(share1: ShamirShare, share2: ShamirShare): Seed;
33
+ /**
34
+ * Verify that shares can successfully reconstruct a seed
35
+ *
36
+ * @param share1 - First share
37
+ * @param share2 - Second share
38
+ * @param expectedSeed - Expected seed after reconstruction
39
+ * @returns true if shares reconstruct to expected seed
40
+ */
41
+ export declare function verifyShares(share1: ShamirShare, share2: ShamirShare, expectedSeed: Seed): boolean;
42
+ /**
43
+ * Extract share index from a share (useful for debugging)
44
+ *
45
+ * @param share - Share to inspect
46
+ * @returns Share index (1-based)
47
+ */
48
+ export declare function getShareIndex(share: ShamirShare): number;
49
+ /**
50
+ * Pad a Uint8Array to a specific length
51
+ */
52
+ export declare function padToLength(data: Uint8Array, targetLength: number): Uint8Array;
@@ -0,0 +1,63 @@
1
+ import { Seed } from './types';
2
+ /** Solana keypair with public and secret key */
3
+ export interface SolanaKeypair {
4
+ /** 32-byte Ed25519 public key */
5
+ publicKey: Uint8Array;
6
+ /** 64-byte Ed25519 secret key (32-byte expanded seed + 32-byte public key) */
7
+ secretKey: Uint8Array;
8
+ }
9
+ /**
10
+ * Derive an Ed25519 keypair from a 16-byte seed
11
+ *
12
+ * The 16-byte seed is expanded to 32 bytes using SHA-256, then used for
13
+ * Ed25519 derivation which internally:
14
+ * - Hashes expanded seed with SHA-512
15
+ * - Clamps lower 32 bytes to form scalar
16
+ * - Multiplies by Ed25519 base point
17
+ *
18
+ * @param seed - 16-byte seed (128-bit entropy)
19
+ * @returns Keypair with 32-byte public key and 64-byte secret key
20
+ *
21
+ * @security **CALLER MUST WIPE secretKey AFTER USE**
22
+ * The returned `secretKey` contains sensitive cryptographic material.
23
+ * Callers are responsible for wiping it when no longer needed:
24
+ * ```ts
25
+ * const keypair = deriveKeypairFromSeed(seed);
26
+ * try {
27
+ * // use keypair.secretKey for signing
28
+ * } finally {
29
+ * wipeBytes(keypair.secretKey);
30
+ * }
31
+ * ```
32
+ * Failure to wipe may leave key material in memory, vulnerable to memory
33
+ * dump attacks. The internal `expandedSeed` is automatically wiped.
34
+ */
35
+ export declare function deriveKeypairFromSeed(seed: Seed): SolanaKeypair;
36
+ /**
37
+ * Get the public key from a seed without returning the secret key
38
+ *
39
+ * @param seed - 32-byte seed
40
+ * @returns 32-byte Ed25519 public key
41
+ */
42
+ export declare function getPublicKeyFromSeed(seed: Seed): Uint8Array;
43
+ /**
44
+ * Encode a public key as a Base58 Solana address
45
+ *
46
+ * @param publicKey - 32-byte public key
47
+ * @returns Base58-encoded address string
48
+ */
49
+ export declare function publicKeyToBase58(publicKey: Uint8Array): string;
50
+ /**
51
+ * Decode a Base58 Solana address to public key bytes
52
+ *
53
+ * @param address - Base58-encoded address
54
+ * @returns 32-byte public key
55
+ */
56
+ export declare function base58ToPublicKey(address: string): Uint8Array;
57
+ /**
58
+ * Validate a Solana address format
59
+ *
60
+ * @param address - Address string to validate
61
+ * @returns true if valid Base58 and correct length
62
+ */
63
+ export declare function isValidSolanaAddress(address: string): boolean;
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Cryptographic type definitions for SSS wallet implementation
3
+ *
4
+ * Security: These types define the structure for client-side key material.
5
+ * The server never receives plaintext seeds or derived keys.
6
+ */
7
+ /** 16-byte seed for wallet derivation (128 bits, standard Solana format) */
8
+ export type Seed = Uint8Array & {
9
+ readonly _brand: 'Seed';
10
+ };
11
+ /** 16-byte Shamir share (128 bits) */
12
+ export type ShamirShare = Uint8Array & {
13
+ readonly _brand: 'ShamirShare';
14
+ };
15
+ /** 32-byte encryption key */
16
+ export type EncryptionKey = Uint8Array & {
17
+ readonly _brand: 'EncryptionKey';
18
+ };
19
+ /** 12-byte AES-GCM nonce */
20
+ export type AesNonce = Uint8Array & {
21
+ readonly _brand: 'AesNonce';
22
+ };
23
+ /** 16+ byte Argon2 salt */
24
+ export type Argon2Salt = Uint8Array & {
25
+ readonly _brand: 'Argon2Salt';
26
+ };
27
+ /** 32-byte PRF salt */
28
+ export type PrfSalt = Uint8Array & {
29
+ readonly _brand: 'PrfSalt';
30
+ };
31
+ /** Argon2id KDF parameters (OWASP recommended) */
32
+ export interface KdfParams {
33
+ /** Memory cost in KiB (default: 19456 = 19 MiB) */
34
+ mCost: number;
35
+ /** Time cost / iterations (default: 2) */
36
+ tCost: number;
37
+ /** Parallelism (default: 1) */
38
+ pCost: number;
39
+ }
40
+ /** Default OWASP-recommended Argon2id parameters */
41
+ export declare const DEFAULT_KDF_PARAMS: KdfParams;
42
+ /** Encrypted data with nonce for AES-GCM */
43
+ export interface EncryptedData {
44
+ /** Base64-encoded ciphertext */
45
+ ciphertext: string;
46
+ /** Base64-encoded 12-byte nonce */
47
+ nonce: string;
48
+ }
49
+ /** Enrollment flow state */
50
+ export type EnrollmentStep = 'idle' | 'generating_seed' | 'splitting_shares' | 'encrypting_shares' | 'registering_passkey' | 'uploading' | 'showing_recovery' | 'complete' | 'error';
51
+ /** Enrollment flow state machine */
52
+ export interface EnrollmentState {
53
+ step: EnrollmentStep;
54
+ error?: string;
55
+ /** BIP-39 mnemonic words (only during showing_recovery step) */
56
+ recoveryPhrase?: string[];
57
+ /** Solana public key (after complete) */
58
+ solanaPubkey?: string;
59
+ }
60
+ /** Recovery flow state */
61
+ export type RecoveryStep = 'idle' | 'entering_phrase' | 'validating' | 'prompting_password' | 'registering_passkey' | 'encrypting' | 'uploading' | 'complete' | 'error';
62
+ /** Recovery flow state machine */
63
+ export interface RecoveryState {
64
+ step: RecoveryStep;
65
+ error?: string;
66
+ /**
67
+ * New recovery phrase (12 words) shown ONLY on successful completion.
68
+ * SECURITY: Must be displayed to user immediately and never logged.
69
+ * User should write down and securely store this phrase.
70
+ */
71
+ recoveryPhrase?: string[];
72
+ }
73
+ /** Crypto capability detection results */
74
+ export interface CryptoCapabilities {
75
+ /** WebCrypto API available */
76
+ webCrypto: boolean;
77
+ /** AES-GCM supported */
78
+ aesGcm: boolean;
79
+ /** HKDF supported */
80
+ hkdf: boolean;
81
+ /** Ed25519 signing supported */
82
+ ed25519: boolean;
83
+ /** WebAuthn available */
84
+ webAuthn: boolean;
85
+ /** WebAuthn PRF extension supported */
86
+ webAuthnPrf: boolean;
87
+ /** Argon2 WASM can be loaded */
88
+ argon2: boolean;
89
+ /** All required capabilities available */
90
+ allSupported: boolean;
91
+ }
92
+ /** Wallet status */
93
+ export type WalletStatus = 'loading' | 'not_enrolled' | 'enrolled_locked' | 'enrolled_unlocked' | 'unlocked' | 'error';
94
+ /** Type guard: verify Seed length (16 bytes) */
95
+ export declare function isSeed(data: Uint8Array): data is Seed;
96
+ /** Type guard: verify ShamirShare is valid
97
+ * CRYPTO-4: Improved validation to check secrets.js format markers.
98
+ * secrets.js produces shares with format: {bits}{id}{data}
99
+ *
100
+ * Note: BIP-39 mnemonic system stores 16-byte entropy without secrets.js
101
+ * metadata, so we also accept exactly 16-byte arrays for compatibility.
102
+ */
103
+ export declare function isShamirShare(data: Uint8Array): data is ShamirShare;
104
+ /** Type guard: verify EncryptionKey length */
105
+ export declare function isEncryptionKey(data: Uint8Array): data is EncryptionKey;
106
+ /** Type guard: verify AesNonce length */
107
+ export declare function isAesNonce(data: Uint8Array): data is AesNonce;
108
+ /** Type guard: verify Argon2Salt length (16+ bytes) */
109
+ export declare function isArgon2Salt(data: Uint8Array): data is Argon2Salt;
110
+ /** Type guard: verify PrfSalt length */
111
+ export declare function isPrfSalt(data: Uint8Array): data is PrfSalt;
112
+ /** Create branded Seed from Uint8Array (throws if invalid) */
113
+ export declare function toSeed(data: Uint8Array): Seed;
114
+ /** Create branded ShamirShare from Uint8Array (throws if invalid) */
115
+ export declare function toShamirShare(data: Uint8Array): ShamirShare;
116
+ /** Create branded EncryptionKey from Uint8Array (throws if invalid) */
117
+ export declare function toEncryptionKey(data: Uint8Array): EncryptionKey;
118
+ /** Create branded AesNonce from Uint8Array (throws if invalid) */
119
+ export declare function toAesNonce(data: Uint8Array): AesNonce;
120
+ /** Create branded Argon2Salt from Uint8Array (throws if invalid) */
121
+ export declare function toArgon2Salt(data: Uint8Array): Argon2Salt;
122
+ /** Create branded PrfSalt from Uint8Array (throws if invalid) */
123
+ export declare function toPrfSalt(data: Uint8Array): PrfSalt;
124
+ /**
125
+ * Cast branded Uint8Array types to BufferSource for Web Crypto API compatibility.
126
+ *
127
+ * Web Crypto APIs (importKey, encrypt, decrypt, etc.) expect BufferSource which only
128
+ * accepts plain Uint8Array with ArrayBuffer (not ArrayBufferLike), not our branded types.
129
+ * This function returns a new Uint8Array backed by a plain ArrayBuffer to satisfy the type.
130
+ *
131
+ * @param data - Any branded Uint8Array type (Seed, EncryptionKey, AesNonce, etc.)
132
+ * @returns BufferSource suitable for Web Crypto APIs
133
+ */
134
+ export declare function toBufferSource<T extends Uint8Array>(data: T): BufferSource;
@@ -0,0 +1,118 @@
1
+ import { PrfSalt } from './types';
2
+ /**
3
+ * SEC-004: Validate the current hostname against allowed RP domains.
4
+ *
5
+ * This prevents WebAuthn credential creation/usage on unexpected domains,
6
+ * which could be used in phishing attacks.
7
+ *
8
+ * @param allowedDomains - List of allowed domain names. Empty means validation is skipped.
9
+ * @throws Error if hostname is not in allowed list (production only)
10
+ */
11
+ export declare function validateRpDomain(allowedDomains?: string[]): void;
12
+ /** Result of registering a new passkey with PRF */
13
+ export interface PasskeyRegistrationResult {
14
+ /** Base64-encoded credential ID */
15
+ credentialId: string;
16
+ /** Base64-encoded PRF salt */
17
+ prfSalt: string;
18
+ /** PRF output (32 bytes) for key derivation */
19
+ prfOutput: Uint8Array;
20
+ }
21
+ /** Result of authenticating with an existing passkey */
22
+ export interface PasskeyAuthResult {
23
+ /** PRF output (32 bytes) for key derivation */
24
+ prfOutput: Uint8Array;
25
+ }
26
+ /**
27
+ * Check if WebAuthn is available in this browser
28
+ */
29
+ export declare function isWebAuthnAvailable(): boolean;
30
+ /**
31
+ * Check if the PRF extension is supported
32
+ *
33
+ * Note: This only checks for API support, not actual authenticator support.
34
+ * The actual PRF availability depends on the user's authenticator.
35
+ */
36
+ export declare function isPrfSupported(): Promise<boolean>;
37
+ /** Options for passkey operations */
38
+ export interface PasskeyOptions {
39
+ /** SEC-004: Allowed domains for RP ID validation */
40
+ allowedDomains?: string[];
41
+ }
42
+ /**
43
+ * Register a new passkey with PRF extension for wallet encryption
44
+ *
45
+ * @param userId - User ID bytes (from authenticated user)
46
+ * @param userName - Display name for the passkey
47
+ * @param displayName - User's display name
48
+ * @param prfSalt - Optional PRF salt (generated if not provided)
49
+ * @param options - Optional configuration including allowed domains
50
+ * @returns Registration result with credential ID and PRF output
51
+ * @throws Error if registration fails or PRF is not supported
52
+ */
53
+ export declare function registerPasskeyWithPrf(userId: Uint8Array, userName: string, displayName: string, prfSalt?: PrfSalt, options?: PasskeyOptions): Promise<PasskeyRegistrationResult>;
54
+ /**
55
+ * Authenticate with an existing passkey and get PRF output
56
+ *
57
+ * @param credentialId - Base64-encoded credential ID
58
+ * @param prfSalt - Base64-encoded PRF salt
59
+ * @param options - Optional configuration including allowed domains
60
+ * @returns Authentication result with PRF output
61
+ * @throws Error if authentication fails
62
+ */
63
+ export declare function authenticateWithPrf(credentialId: string, prfSalt: string, options?: PasskeyOptions): Promise<PasskeyAuthResult>;
64
+ /**
65
+ * Get encryption key from passkey via PRF extension
66
+ *
67
+ * This combines authentication and key derivation in a single operation.
68
+ *
69
+ * ## SEC-03: Key Lifecycle Management
70
+ *
71
+ * **IMPORTANT**: The returned encryption key is sensitive cryptographic material.
72
+ * Callers are responsible for:
73
+ *
74
+ * 1. Using the key only for its intended purpose (Share B decryption)
75
+ * 2. Wiping the key from memory after use by calling `key.fill(0)`
76
+ * 3. Not storing the key in persistent storage (localStorage, IndexedDB, etc.)
77
+ * 4. Not logging or transmitting the key
78
+ *
79
+ * The PRF output used to derive this key is automatically wiped in the finally
80
+ * block, but the derived key must be managed by the caller.
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * const key = await getEncryptionKeyFromPasskey(credentialId, prfSalt);
85
+ * try {
86
+ * const plaintext = await decryptShareB(ciphertext, key);
87
+ * // ... use plaintext
88
+ * } finally {
89
+ * key.fill(0); // Wipe key after use
90
+ * }
91
+ * ```
92
+ *
93
+ * @param credentialId - Base64-encoded credential ID
94
+ * @param prfSalt - Base64-encoded PRF salt
95
+ * @param options - Optional configuration including allowed domains
96
+ * @returns 32-byte encryption key derived from PRF output. **Caller must wipe after use.**
97
+ */
98
+ export declare function getEncryptionKeyFromPasskey(credentialId: string, prfSalt: string, options?: PasskeyOptions): Promise<Uint8Array>;
99
+ /**
100
+ * Check if a credential ID is valid for this user
101
+ *
102
+ * @param credentialId - Base64-encoded credential ID to check
103
+ * @param options - Optional configuration including allowed domains
104
+ * @returns true if credential exists and can be used
105
+ */
106
+ export declare function isCredentialAvailable(credentialId: string, options?: PasskeyOptions): Promise<boolean>;
107
+ /**
108
+ * Authenticate with any discoverable passkey and get PRF output
109
+ *
110
+ * This allows authentication without specifying a credential ID, letting
111
+ * the browser present all available passkeys for this domain.
112
+ *
113
+ * @param prfSalt - Base64-encoded PRF salt
114
+ * @param options - Optional configuration including allowed domains
115
+ * @returns Authentication result with PRF output
116
+ * @throws Error if authentication fails
117
+ */
118
+ export declare function authenticateWithDiscoverablePrf(prfSalt: string, options?: PasskeyOptions): Promise<PasskeyAuthResult>;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./ErrorMessage-CntMyn93.cjs"),r=require("./EmailRegisterForm-D_uCEdX9.cjs"),o=require("./validation-BeXIfuHB.cjs");exports.CedrosLoginProvider=e.CedrosLoginProvider;exports.ErrorMessage=e.ErrorMessage;exports.LoadingSpinner=e.LoadingSpinner;exports.useAuth=e.useAuth;exports.useCedrosLogin=e.useCedrosLogin;exports.EmailLoginForm=r.EmailLoginForm;exports.EmailRegisterForm=r.EmailRegisterForm;exports.PasswordInput=r.PasswordInput;exports.useEmailAuth=r.useEmailAuth;exports.validatePassword=o.validatePassword;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email-only.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @cedros/login-react/email-only
3
+ *
4
+ * Minimal bundle with only email/password authentication (~15KB).
5
+ */
6
+ export { CedrosLoginProvider } from './context/CedrosLoginProvider';
7
+ export { useCedrosLogin } from './context/useCedrosLogin';
8
+ export { EmailLoginForm } from './components/email/EmailLoginForm';
9
+ export { EmailRegisterForm } from './components/email/EmailRegisterForm';
10
+ export { PasswordInput } from './components/email/PasswordInput';
11
+ export { LoadingSpinner } from './components/shared/LoadingSpinner';
12
+ export { ErrorMessage } from './components/shared/ErrorMessage';
13
+ export { useAuth } from './hooks/useAuth';
14
+ export { useEmailAuth } from './hooks/useEmailAuth';
15
+ export type { AuthMethod, AuthUser, TokenPair, AuthError, AuthErrorCode, AuthResponse, AuthState, PasswordValidation, SessionStorage, ThemeMode, FeatureFlags, SessionConfig, AuthCallbacks, ThemeOverrides, CedrosLoginConfig, } from './types';
16
+ export { validatePassword } from './utils/validation';
@@ -0,0 +1,15 @@
1
+ import { C as r, E as o, L as e, a as i, u as m } from "./ErrorMessage-Bm1j5mBT.js";
2
+ import { E as u, a as d, P as n, u as g } from "./EmailRegisterForm-m3rX3A6X.js";
3
+ import { v as p } from "./validation-BebL7hMF.js";
4
+ export {
5
+ r as CedrosLoginProvider,
6
+ u as EmailLoginForm,
7
+ d as EmailRegisterForm,
8
+ o as ErrorMessage,
9
+ e as LoadingSpinner,
10
+ n as PasswordInput,
11
+ i as useAuth,
12
+ m as useCedrosLogin,
13
+ g as useEmailAuth,
14
+ p as validatePassword
15
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email-only.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./ErrorMessage-CntMyn93.cjs"),e=require("./GoogleLoginButton-CJNJ-THo.cjs");exports.CedrosLoginProvider=o.CedrosLoginProvider;exports.ErrorMessage=o.ErrorMessage;exports.LoadingSpinner=o.LoadingSpinner;exports.useAuth=o.useAuth;exports.useCedrosLogin=o.useCedrosLogin;exports.GoogleLoginButton=e.GoogleLoginButton;exports.useGoogleAuth=e.useGoogleAuth;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-only.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}