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