@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,78 @@
1
+ import { AuthError } from '../types';
2
+ export interface ApiClientConfig {
3
+ baseUrl: string;
4
+ timeoutMs?: number;
5
+ retryAttempts?: number;
6
+ getAccessToken?: () => string | null;
7
+ }
8
+ /**
9
+ * M-02: Response validator function type.
10
+ * Returns the validated data or throws on invalid shape.
11
+ */
12
+ export type ResponseValidator<T> = (data: unknown) => T;
13
+ export interface RequestOptions<T = unknown> {
14
+ method: 'GET' | 'HEAD' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
15
+ path: string;
16
+ body?: unknown;
17
+ credentials?: RequestCredentials;
18
+ skipRetry?: boolean;
19
+ /** M-02: Optional validator to verify response shape at runtime */
20
+ validator?: ResponseValidator<T>;
21
+ }
22
+ /**
23
+ * Creates an authentication error from response data
24
+ */
25
+ export declare function createAuthError(data: {
26
+ code?: string;
27
+ message?: string;
28
+ details?: Record<string, unknown>;
29
+ }, fallbackMessage: string): AuthError;
30
+ /**
31
+ * Creates a network error
32
+ */
33
+ export declare function createNetworkError(): AuthError;
34
+ /**
35
+ * API client for making authenticated requests with timeout and retry support
36
+ */
37
+ export declare class ApiClient {
38
+ private baseUrl;
39
+ private timeoutMs;
40
+ private retryAttempts;
41
+ private getAccessToken?;
42
+ constructor(config: ApiClientConfig);
43
+ /**
44
+ * Make an API request with timeout and optional retry
45
+ */
46
+ request<T>(options: RequestOptions<T>): Promise<T>;
47
+ /**
48
+ * POST request helper
49
+ */
50
+ post<T>(path: string, body: unknown, options?: Partial<RequestOptions<T>>): Promise<T>;
51
+ /**
52
+ * GET request helper
53
+ */
54
+ get<T>(path: string, options?: Partial<RequestOptions<T>>): Promise<T>;
55
+ /**
56
+ * PATCH request helper
57
+ */
58
+ patch<T>(path: string, body: unknown, options?: Partial<RequestOptions<T>>): Promise<T>;
59
+ /**
60
+ * DELETE request helper
61
+ */
62
+ delete<T>(path: string, options?: Partial<RequestOptions<T>>): Promise<T>;
63
+ }
64
+ /**
65
+ * M-02: Helper to create a basic object shape validator.
66
+ * Checks that required keys exist and are of expected types.
67
+ * @example
68
+ * const validateUser = createValidator<User>({
69
+ * id: 'string',
70
+ * email: 'string',
71
+ * role: 'string',
72
+ * });
73
+ */
74
+ export declare function createValidator<T>(shape: Record<keyof T & string, 'string' | 'number' | 'boolean' | 'object'>): ResponseValidator<T>;
75
+ /**
76
+ * Converts API errors to AuthError format
77
+ */
78
+ export declare function handleApiError(err: unknown, fallbackMessage: string): AuthError;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Shim for Node's `crypto` module.
3
+ * Maps `require('crypto')` / `import 'crypto'` to Web Crypto API in the browser.
4
+ * Used by vite.config.ts alias to support CJS dependencies that expect Node crypto.
5
+ */
6
+ declare const _default: Crypto;
7
+ export default _default;
8
+ export declare const webcrypto: Crypto;
9
+ export declare const subtle: SubtleCrypto;
10
+ export declare const getRandomValues: {
11
+ <T extends ArrayBufferView>(array: T): T;
12
+ <T extends ArrayBufferView>(array: T): T;
13
+ };
14
+ export declare const randomUUID: {
15
+ (): `${string}-${string}-${string}-${string}-${string}`;
16
+ (): `${string}-${string}-${string}-${string}-${string}`;
17
+ };
@@ -0,0 +1 @@
1
+ export declare function getCsrfToken(): string | null;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Device detection utilities
3
+ */
4
+ /**
5
+ * Detects if the current device is an Apple device (macOS, iOS, iPadOS).
6
+ * Apple Sign In is most useful on Apple devices where users have Apple ID readily available.
7
+ *
8
+ * @returns true if running on an Apple device
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * if (isAppleDevice()) {
13
+ * // Show Apple Sign In button
14
+ * }
15
+ * ```
16
+ */
17
+ export declare function isAppleDevice(): boolean;
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Embedded wallet detection utilities
3
+ *
4
+ * Allows other Cedros modules (like cedros-pay) to detect if an embedded
5
+ * wallet is available in the current application.
6
+ *
7
+ * @security The window global only exposes availability info, NOT the signing
8
+ * function. Signing must go through React context to prevent unauthorized access.
9
+ */
10
+ /** Window global name for embedded wallet detection */
11
+ declare const GLOBAL_KEY = "__CEDROS_EMBEDDED_WALLET__";
12
+ /**
13
+ * Embedded wallet info exposed via window global
14
+ */
15
+ export interface EmbeddedWalletInfo {
16
+ /** Whether user has enrolled SSS embedded wallet */
17
+ available: boolean;
18
+ /** Solana public key (base58) if available */
19
+ publicKey: string | null;
20
+ }
21
+ declare global {
22
+ interface Window {
23
+ [GLOBAL_KEY]?: EmbeddedWalletInfo;
24
+ }
25
+ }
26
+ /**
27
+ * Set embedded wallet availability on window global
28
+ *
29
+ * Called by CedrosLoginProvider when wallet.exposeAvailability is true.
30
+ *
31
+ * @internal
32
+ */
33
+ export declare function setEmbeddedWalletGlobal(info: EmbeddedWalletInfo): void;
34
+ /**
35
+ * Clear embedded wallet availability from window global
36
+ *
37
+ * Called when user logs out or config changes.
38
+ *
39
+ * @internal
40
+ */
41
+ export declare function clearEmbeddedWalletGlobal(): void;
42
+ /**
43
+ * Check if embedded wallet is available
44
+ *
45
+ * Use this in other Cedros modules (like cedros-pay) to detect
46
+ * if an embedded wallet is available for signing.
47
+ *
48
+ * @example
49
+ * ```tsx
50
+ * import { isEmbeddedWalletAvailable, getEmbeddedWalletInfo } from '@cedros/login-react';
51
+ *
52
+ * // Simple check
53
+ * if (isEmbeddedWalletAvailable()) {
54
+ * // Show "Pay with Crypto" button
55
+ * }
56
+ *
57
+ * // Get full info
58
+ * const walletInfo = getEmbeddedWalletInfo();
59
+ * if (walletInfo?.available && walletInfo.publicKey) {
60
+ * console.log('User wallet:', walletInfo.publicKey);
61
+ * }
62
+ * ```
63
+ *
64
+ * @returns true if embedded wallet is enrolled and available
65
+ */
66
+ export declare function isEmbeddedWalletAvailable(): boolean;
67
+ /**
68
+ * Get embedded wallet info
69
+ *
70
+ * Returns the full wallet info object if available.
71
+ *
72
+ * @returns Wallet info or null if not exposed
73
+ */
74
+ export declare function getEmbeddedWalletInfo(): EmbeddedWalletInfo | null;
75
+ export {};
@@ -0,0 +1,31 @@
1
+ import { Invite, CreateInviteRequest, AcceptInviteRequest, CreateInviteResponse, AcceptInviteResponse } from '../types';
2
+ /**
3
+ * API client for invite operations
4
+ */
5
+ export declare class InviteApiClient {
6
+ private client;
7
+ constructor(baseUrl: string, timeoutMs?: number, retryAttempts?: number, getAccessToken?: () => string | null);
8
+ /**
9
+ * List all pending invites for an organization
10
+ */
11
+ listInvites(orgId: string, limit?: number, offset?: number): Promise<{
12
+ invites: Invite[];
13
+ total: number;
14
+ }>;
15
+ /**
16
+ * Create a new invite
17
+ */
18
+ createInvite(orgId: string, data: CreateInviteRequest): Promise<CreateInviteResponse>;
19
+ /**
20
+ * Cancel a pending invite
21
+ */
22
+ cancelInvite(orgId: string, inviteId: string): Promise<void>;
23
+ /**
24
+ * Resend an invite email
25
+ */
26
+ resendInvite(orgId: string, inviteId: string): Promise<void>;
27
+ /**
28
+ * Accept an invite (public endpoint)
29
+ */
30
+ acceptInvite(data: AcceptInviteRequest): Promise<AcceptInviteResponse>;
31
+ }
@@ -0,0 +1,23 @@
1
+ import { Member, UpdateMemberRoleRequest } from '../types';
2
+ /**
3
+ * API client for member operations within an organization
4
+ */
5
+ export declare class MemberApiClient {
6
+ private client;
7
+ constructor(baseUrl: string, timeoutMs?: number, retryAttempts?: number, getAccessToken?: () => string | null);
8
+ /**
9
+ * List all members of an organization
10
+ */
11
+ listMembers(orgId: string, limit?: number, offset?: number): Promise<{
12
+ members: Member[];
13
+ total: number;
14
+ }>;
15
+ /**
16
+ * Update a member's role
17
+ */
18
+ updateMemberRole(orgId: string, userId: string, data: UpdateMemberRoleRequest): Promise<Member>;
19
+ /**
20
+ * Remove a member from the organization
21
+ */
22
+ removeMember(orgId: string, userId: string): Promise<void>;
23
+ }
@@ -0,0 +1,36 @@
1
+ import { Organization, OrgWithMembership, CreateOrgRequest, UpdateOrgRequest, AuthorizeRequest, AuthorizeResponse, PermissionsResponse } from '../types';
2
+ /**
3
+ * API client for organization operations
4
+ */
5
+ export declare class OrgApiClient {
6
+ private client;
7
+ constructor(baseUrl: string, timeoutMs?: number, retryAttempts?: number, getAccessToken?: () => string | null);
8
+ /**
9
+ * List all organizations the current user belongs to
10
+ */
11
+ listOrgs(): Promise<OrgWithMembership[]>;
12
+ /**
13
+ * Get a single organization by ID
14
+ */
15
+ getOrg(orgId: string): Promise<Organization>;
16
+ /**
17
+ * Create a new organization
18
+ */
19
+ createOrg(data: CreateOrgRequest): Promise<Organization>;
20
+ /**
21
+ * Update an organization
22
+ */
23
+ updateOrg(orgId: string, data: UpdateOrgRequest): Promise<Organization>;
24
+ /**
25
+ * Delete an organization
26
+ */
27
+ deleteOrg(orgId: string): Promise<void>;
28
+ /**
29
+ * Check authorization for an action
30
+ */
31
+ authorize(data: AuthorizeRequest): Promise<AuthorizeResponse>;
32
+ /**
33
+ * Get current user's permissions in an organization
34
+ */
35
+ getPermissions(orgId: string): Promise<PermissionsResponse>;
36
+ }
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Input sanitization utilities for security
3
+ */
4
+ /**
5
+ * Sanitizes an image URL to prevent XSS and other attacks.
6
+ *
7
+ * ## Security Properties
8
+ *
9
+ * - Only allows HTTPS URLs (prevents protocol-based attacks)
10
+ * - Blocks javascript:, data:, vbscript:, file: protocols
11
+ * - Returns undefined for invalid URLs
12
+ *
13
+ * ## Limitations (S-20/SEC-08)
14
+ *
15
+ * This function validates the URL protocol but does NOT validate the domain.
16
+ * Any HTTPS URL will pass validation, including URLs from untrusted domains.
17
+ * This is intentional - domain allowlisting is application-specific and should
18
+ * be implemented at the consumer level (see example below).
19
+ *
20
+ * If your application requires domain validation (e.g., only allowing images
21
+ * from trusted CDNs), implement additional validation:
22
+ *
23
+ * @example Domain allowlisting (application-level)
24
+ * ```ts
25
+ * const ALLOWED_DOMAINS = ['cdn.example.com', 'images.trusted.org'];
26
+ *
27
+ * function isAllowedImageUrl(url: string): boolean {
28
+ * const sanitized = sanitizeImageUrl(url);
29
+ * if (!sanitized) return false;
30
+ *
31
+ * try {
32
+ * const hostname = new URL(sanitized).hostname;
33
+ * return ALLOWED_DOMAINS.some(d => hostname === d || hostname.endsWith('.' + d));
34
+ * } catch {
35
+ * return false;
36
+ * }
37
+ * }
38
+ * ```
39
+ *
40
+ * @param url - The URL to sanitize
41
+ * @returns The sanitized URL or undefined if invalid
42
+ *
43
+ * @example Basic usage
44
+ * ```ts
45
+ * sanitizeImageUrl('https://example.com/avatar.png') // 'https://example.com/avatar.png'
46
+ * sanitizeImageUrl('javascript:alert(1)') // undefined
47
+ * sanitizeImageUrl('data:image/svg+xml,...') // undefined
48
+ * ```
49
+ */
50
+ export declare function sanitizeImageUrl(url: string | undefined | null): string | undefined;
51
+ /**
52
+ * Sanitizes an external link URL for use in href attributes.
53
+ *
54
+ * Security goals:
55
+ * - Block dangerous protocols (javascript:, data:, vbscript:, file:)
56
+ * - Only allow http/https absolute URLs
57
+ */
58
+ export declare function sanitizeExternalUrl(url: string | undefined | null): string | undefined;
59
+ /**
60
+ * Sanitizes user-provided text to prevent XSS in text content.
61
+ * Escapes HTML special characters.
62
+ *
63
+ * @param text - The text to sanitize
64
+ * @returns The sanitized text
65
+ */
66
+ export declare function sanitizeText(text: string | undefined | null): string;
@@ -0,0 +1,16 @@
1
+ import { Session, RevokeAllSessionsResponse } from '../types';
2
+ /**
3
+ * API client for session management operations
4
+ */
5
+ export declare class SessionApiClient {
6
+ private client;
7
+ constructor(baseUrl: string, timeoutMs?: number, retryAttempts?: number, getAccessToken?: () => string | null);
8
+ /**
9
+ * List all active sessions for the current user
10
+ */
11
+ listSessions(): Promise<Session[]>;
12
+ /**
13
+ * Revoke all sessions (logout from all devices)
14
+ */
15
+ revokeAllSessions(): Promise<RevokeAllSessionsResponse>;
16
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Silent wallet enrollment utility
3
+ *
4
+ * Performs wallet enrollment in the background without UI interaction.
5
+ * Used for auto-enrolling wallets during registration.
6
+ *
7
+ * Security: Uses the same Shamir Secret Sharing scheme as manual enrollment.
8
+ * The recovery phrase is not shown - user can retrieve it later if needed.
9
+ */
10
+ export interface SilentEnrollOptions {
11
+ /** User's password for Share A encryption */
12
+ password: string;
13
+ /** Server base URL */
14
+ serverUrl: string;
15
+ /** Access token for authentication (optional if using cookies) */
16
+ accessToken?: string;
17
+ /** Request timeout in ms */
18
+ timeoutMs?: number;
19
+ }
20
+ export interface SilentEnrollResult {
21
+ success: boolean;
22
+ solanaPubkey?: string;
23
+ error?: string;
24
+ }
25
+ /**
26
+ * Silently enroll a wallet for a user
27
+ *
28
+ * This function performs the complete wallet enrollment process:
29
+ * 1. Generate 32-byte seed
30
+ * 2. Split into 3 Shamir shares (threshold 2)
31
+ * 3. Encrypt Share A with password-derived key (Argon2id)
32
+ * 4. Derive Solana public key from seed
33
+ * 5. Upload encrypted Share A + plaintext Share B to server
34
+ *
35
+ * The recovery phrase (Share C) is not returned - user can recover it
36
+ * later through the wallet recovery flow if needed.
37
+ *
38
+ * @param options - Enrollment options
39
+ * @returns Result with success status and Solana public key
40
+ */
41
+ export declare function silentWalletEnroll(options: SilentEnrollOptions): Promise<SilentEnrollResult>;
@@ -0,0 +1,18 @@
1
+ import { ListSystemSettingsResponse, UpdateSettingRequest, UpdateSystemSettingsResponse } from '../types';
2
+ /**
3
+ * API client for system settings operations (admin only)
4
+ */
5
+ export declare class SystemSettingsApiClient {
6
+ private client;
7
+ constructor(baseUrl: string, timeoutMs?: number, retryAttempts?: number, getAccessToken?: () => string | null);
8
+ /**
9
+ * Get all system settings grouped by category
10
+ * Requires system admin privileges
11
+ */
12
+ getSettings(): Promise<ListSystemSettingsResponse>;
13
+ /**
14
+ * Update one or more system settings
15
+ * Requires system admin privileges
16
+ */
17
+ updateSettings(settings: UpdateSettingRequest[]): Promise<UpdateSystemSettingsResponse>;
18
+ }
@@ -0,0 +1,46 @@
1
+ import { AuthUser } from '../types';
2
+ type AuthSyncEvent = {
3
+ type: 'login';
4
+ user: AuthUser;
5
+ } | {
6
+ type: 'logout';
7
+ } | {
8
+ type: 'refresh';
9
+ };
10
+ type AuthSyncCallback = (event: AuthSyncEvent) => void;
11
+ /**
12
+ * Cross-tab synchronization for auth state using BroadcastChannel
13
+ * UI-6 FIX: Use addEventListener/removeEventListener for proper cleanup.
14
+ */
15
+ export declare class TabSync {
16
+ private channel;
17
+ private callback;
18
+ private boundHandler;
19
+ constructor();
20
+ /**
21
+ * Handle incoming sync messages
22
+ */
23
+ private handleMessage;
24
+ /**
25
+ * Set the callback for sync events from other tabs
26
+ */
27
+ setCallback(callback: AuthSyncCallback): void;
28
+ /**
29
+ * Broadcast login event to other tabs
30
+ */
31
+ broadcastLogin(user: AuthUser): void;
32
+ /**
33
+ * Broadcast logout event to other tabs
34
+ */
35
+ broadcastLogout(): void;
36
+ /**
37
+ * Broadcast token refresh event to other tabs
38
+ */
39
+ broadcastRefresh(): void;
40
+ /**
41
+ * Close the channel and clean up references
42
+ * UI-6: Use removeEventListener for proper cleanup
43
+ */
44
+ close(): void;
45
+ }
46
+ export {};
@@ -0,0 +1,107 @@
1
+ import { TokenPair, SessionStorage } from '../types';
2
+ /**
3
+ * Token manager for storing and auto-refreshing tokens
4
+ *
5
+ * ## Security Warning: localStorage Storage
6
+ *
7
+ * When using `localStorage` or `sessionStorage`, tokens are stored in the browser
8
+ * and are **vulnerable to XSS attacks**. Any JavaScript running
9
+ * on your page (including third-party scripts, browser extensions, or malicious
10
+ * code injected via XSS) can read these tokens.
11
+ *
12
+ * **Recommendations:**
13
+ * - Use `cookie` storage with httpOnly cookies (tokens stored server-side)
14
+ * - If localStorage is required, implement strong Content Security Policy (CSP)
15
+ * - Sanitize all user input and output
16
+ * - Regularly audit third-party dependencies
17
+ *
18
+ * @example
19
+ * // Recommended: cookie storage (tokens in httpOnly cookies)
20
+ * const manager = new TokenManager('cookie');
21
+ *
22
+ * // Use with caution: localStorage (XSS vulnerable)
23
+ * const manager = new TokenManager('localStorage');
24
+ */
25
+ export interface TokenManagerOptions {
26
+ /**
27
+ * Allow `localStorage`/`sessionStorage` token persistence.
28
+ *
29
+ * @security This is intentionally opt-in because these storage modes are vulnerable
30
+ * to XSS token theft.
31
+ */
32
+ allowWebStorage?: boolean;
33
+ }
34
+ export declare class TokenManager {
35
+ private storage;
36
+ private requestedStorage;
37
+ private storageKey;
38
+ private tokens;
39
+ private expiresAt;
40
+ private refreshTimer;
41
+ private onRefreshNeeded;
42
+ private onSessionExpired;
43
+ private onRefreshError;
44
+ private isDestroyed;
45
+ private allowWebStorage;
46
+ constructor(storage?: SessionStorage, persistKey?: string, options?: TokenManagerOptions);
47
+ /**
48
+ * S-18/UI-XSS: Warn about localStorage XSS vulnerability in all environments.
49
+ * Security warnings should not be suppressed in production - operators need
50
+ * to be aware of the security implications of their storage choices.
51
+ */
52
+ private warnIfLocalStorage;
53
+ /**
54
+ * Set the callback for when tokens need to be refreshed
55
+ */
56
+ setRefreshCallback(callback: () => Promise<void>): void;
57
+ /**
58
+ * Set the callback for when session expires
59
+ */
60
+ setSessionExpiredCallback(callback: () => void): void;
61
+ /**
62
+ * Set the callback for when token refresh fails
63
+ * This allows the UI to show an error message to the user
64
+ */
65
+ setRefreshErrorCallback(callback: (error: Error) => void): void;
66
+ /**
67
+ * Store tokens and schedule auto-refresh
68
+ */
69
+ setTokens(tokens: TokenPair): void;
70
+ /**
71
+ * Get the current access token
72
+ * UI-4 FIX: Store token in local variable before expiry check to eliminate TOCTOU race.
73
+ * UI-TOK-01 FIX: Check isDestroyed to prevent access after manager is cleaned up.
74
+ */
75
+ getAccessToken(): string | null;
76
+ /**
77
+ * Get the current refresh token
78
+ */
79
+ getRefreshToken(): string | null;
80
+ /**
81
+ * Clear stored tokens
82
+ */
83
+ clear(): void;
84
+ /**
85
+ * Check if tokens are stored
86
+ */
87
+ hasTokens(): boolean;
88
+ /**
89
+ * Destroy the token manager and clean up resources.
90
+ * Call this when unmounting components or cleaning up to prevent memory leaks.
91
+ * P-02: Also sets isDestroyed flag to prevent timer callbacks from executing.
92
+ */
93
+ destroy(): void;
94
+ /**
95
+ * Get time until token expiry in ms
96
+ */
97
+ getTimeUntilExpiry(): number;
98
+ private scheduleRefresh;
99
+ private cancelRefresh;
100
+ private loadFromStorage;
101
+ /**
102
+ * Validate that parsed data matches expected StoredTokenData structure
103
+ */
104
+ private isValidStoredTokenData;
105
+ private saveToStorage;
106
+ private clearStorage;
107
+ }
@@ -0,0 +1,5 @@
1
+ import { UnlockCredential, UnlockCredentialRequest } from '../types/wallet';
2
+ /**
3
+ * Convert UnlockCredential to API request format.
4
+ */
5
+ export declare function toCredentialRequest(credential: UnlockCredential): UnlockCredentialRequest;
@@ -0,0 +1,48 @@
1
+ import { PasswordValidation } from '../types';
2
+ /**
3
+ * Password validation rules:
4
+ * - Minimum 10 characters
5
+ * - At least 1 uppercase letter (A-Z)
6
+ * - At least 1 lowercase letter (a-z)
7
+ * - At least 1 number (0-9)
8
+ * - At least 1 special character (@$!%*?&#^())
9
+ *
10
+ * Note: All checks are performed regardless of early failures to prevent
11
+ * timing attacks that could reveal which requirements are met.
12
+ */
13
+ export declare function validatePassword(password: string): PasswordValidation;
14
+ /**
15
+ * Validate email format with robust validation.
16
+ *
17
+ * Validates:
18
+ * - Proper format with @ symbol
19
+ * - Valid characters in local and domain parts
20
+ * - Domain must have at least one dot (TLD required)
21
+ * - Maximum length per RFC 5321
22
+ *
23
+ * UI-13: Note on case normalization - This function validates format only,
24
+ * it does NOT normalize case. Per RFC 5321, local-part is technically
25
+ * case-sensitive (though most providers ignore case). Callers should
26
+ * normalize emails (e.g., toLowerCase) before API calls and storage.
27
+ *
28
+ * @param email - The email address to validate
29
+ * @returns true if the email format is valid
30
+ */
31
+ export declare function validateEmail(email: string): boolean;
32
+ /**
33
+ * Validate Solana public key format.
34
+ *
35
+ * A valid Solana public key:
36
+ * - Is 43-44 characters long (base58 encoding of 32 bytes)
37
+ * - Contains only valid base58 characters
38
+ *
39
+ * @param publicKey - The public key string to validate
40
+ * @returns true if the public key format is valid
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * validateSolanaPublicKey('DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263') // true
45
+ * validateSolanaPublicKey('invalid') // false
46
+ * ```
47
+ */
48
+ export declare function validateSolanaPublicKey(publicKey: string): boolean;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Wallet detection utilities for Solana browser wallets
3
+ */
4
+ /**
5
+ * Detects if any Solana wallet extensions are installed in the browser.
6
+ * Checks for common wallet adapters like Phantom, Solflare, Backpack, etc.
7
+ *
8
+ * @returns true if at least one Solana wallet is detected
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * if (detectSolanaWallets()) {
13
+ * // Show Solana login button
14
+ * }
15
+ * ```
16
+ */
17
+ export declare function detectSolanaWallets(): boolean;
18
+ /**
19
+ * Returns list of detected Solana wallet names (for debugging/display)
20
+ *
21
+ * @returns Array of detected wallet provider names
22
+ */
23
+ export declare function getDetectedWalletNames(): string[];