@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,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @cedros/login-react/google-only
|
|
3
|
+
*
|
|
4
|
+
* Bundle with only Google OAuth authentication (~25KB).
|
|
5
|
+
*/
|
|
6
|
+
export { CedrosLoginProvider } from './context/CedrosLoginProvider';
|
|
7
|
+
export { useCedrosLogin } from './context/useCedrosLogin';
|
|
8
|
+
export { GoogleLoginButton } from './components/google/GoogleLoginButton';
|
|
9
|
+
export { LoadingSpinner } from './components/shared/LoadingSpinner';
|
|
10
|
+
export { ErrorMessage } from './components/shared/ErrorMessage';
|
|
11
|
+
export { useAuth } from './hooks/useAuth';
|
|
12
|
+
export { useGoogleAuth } from './hooks/useGoogleAuth';
|
|
13
|
+
export type { AuthMethod, AuthUser, TokenPair, AuthError, AuthErrorCode, AuthResponse, AuthState, SessionStorage, ThemeMode, FeatureFlags, SessionConfig, AuthCallbacks, ThemeOverrides, CedrosLoginConfig, } from './types';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { C as e, E as r, L as a, a as u, u as g } from "./ErrorMessage-Bm1j5mBT.js";
|
|
2
|
+
import { G as i, u as t } from "./GoogleLoginButton-CvDoOc-0.js";
|
|
3
|
+
export {
|
|
4
|
+
e as CedrosLoginProvider,
|
|
5
|
+
r as ErrorMessage,
|
|
6
|
+
i as GoogleLoginButton,
|
|
7
|
+
a as LoadingSpinner,
|
|
8
|
+
u as useAuth,
|
|
9
|
+
g as useCedrosLogin,
|
|
10
|
+
t as useGoogleAuth
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-only.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { UseAdminDepositsReturn } from '../types/deposit';
|
|
2
|
+
export type { UseAdminDepositsReturn } from '../types/deposit';
|
|
3
|
+
/**
|
|
4
|
+
* Hook for admin Privacy Cash deposit operations
|
|
5
|
+
*
|
|
6
|
+
* Requires system admin privileges. All methods will fail with 403 if not admin.
|
|
7
|
+
*
|
|
8
|
+
* Safe to call outside CedrosLoginProvider - returns no-op functions that throw.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useAdminDeposits(): UseAdminDepositsReturn;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { UseAdminUsersReturn } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Hook for admin user management operations
|
|
4
|
+
*
|
|
5
|
+
* Provides methods to list all users, get individual users,
|
|
6
|
+
* and manage system admin status. Requires system admin privileges.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* function UserManagement() {
|
|
11
|
+
* const { users, total, isLoading, listUsers, setSystemAdmin } = useAdminUsers();
|
|
12
|
+
*
|
|
13
|
+
* useEffect(() => {
|
|
14
|
+
* listUsers({ limit: 20 });
|
|
15
|
+
* }, [listUsers]);
|
|
16
|
+
*
|
|
17
|
+
* return (
|
|
18
|
+
* <AdminUserList
|
|
19
|
+
* users={users}
|
|
20
|
+
* total={total}
|
|
21
|
+
* isLoading={isLoading}
|
|
22
|
+
* onToggleAdmin={(userId, isAdmin) => setSystemAdmin(userId, isAdmin)}
|
|
23
|
+
* />
|
|
24
|
+
* );
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function useAdminUsers(): UseAdminUsersReturn;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { AuthResponse, AuthError } from '../types';
|
|
2
|
+
export interface UseAppleAuthReturn {
|
|
3
|
+
signIn: () => Promise<AuthResponse>;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
isInitialized: boolean;
|
|
6
|
+
error: AuthError | null;
|
|
7
|
+
clearError: () => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Hook for Apple Sign In authentication.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* function AppleButton() {
|
|
15
|
+
* const { signIn, isLoading, isInitialized, error } = useAppleAuth();
|
|
16
|
+
*
|
|
17
|
+
* return (
|
|
18
|
+
* <button onClick={signIn} disabled={!isInitialized || isLoading}>
|
|
19
|
+
* {isLoading ? 'Signing in...' : 'Sign in with Apple'}
|
|
20
|
+
* </button>
|
|
21
|
+
* );
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function useAppleAuth(): UseAppleAuthReturn;
|
|
26
|
+
declare global {
|
|
27
|
+
interface Window {
|
|
28
|
+
AppleID?: {
|
|
29
|
+
auth?: {
|
|
30
|
+
init: (config: {
|
|
31
|
+
clientId: string;
|
|
32
|
+
scope: string;
|
|
33
|
+
redirectURI: string;
|
|
34
|
+
usePopup?: boolean;
|
|
35
|
+
}) => void;
|
|
36
|
+
signIn: () => Promise<{
|
|
37
|
+
authorization?: {
|
|
38
|
+
id_token?: string;
|
|
39
|
+
code?: string;
|
|
40
|
+
};
|
|
41
|
+
user?: {
|
|
42
|
+
email?: string;
|
|
43
|
+
name?: {
|
|
44
|
+
firstName?: string;
|
|
45
|
+
lastName?: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
}>;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AuthUser, AuthState, AuthError } from '../types';
|
|
2
|
+
export interface UseAuthReturn {
|
|
3
|
+
user: AuthUser | null;
|
|
4
|
+
authState: AuthState;
|
|
5
|
+
error: AuthError | null;
|
|
6
|
+
isAuthenticated: boolean;
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
logout: () => Promise<void>;
|
|
9
|
+
refreshUser: () => Promise<void>;
|
|
10
|
+
openLoginModal: () => void;
|
|
11
|
+
closeLoginModal: () => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Main authentication hook providing user state and actions.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* function MyComponent() {
|
|
19
|
+
* const { user, isAuthenticated, logout, openLoginModal } = useAuth();
|
|
20
|
+
*
|
|
21
|
+
* if (!isAuthenticated) {
|
|
22
|
+
* return <button onClick={openLoginModal}>Login</button>;
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* return (
|
|
26
|
+
* <div>
|
|
27
|
+
* <p>Welcome, {user?.name}</p>
|
|
28
|
+
* <button onClick={logout}>Logout</button>
|
|
29
|
+
* </div>
|
|
30
|
+
* );
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function useAuth(): UseAuthReturn;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AuthUser, AuthState, TokenPair, SessionConfig, AuthCallbacks } from '../types';
|
|
2
|
+
export interface UseAuthSessionOptions {
|
|
3
|
+
serverUrl: string;
|
|
4
|
+
session?: SessionConfig;
|
|
5
|
+
callbacks?: AuthCallbacks;
|
|
6
|
+
requestTimeoutMs?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface UseAuthSessionReturn {
|
|
9
|
+
user: AuthUser | null;
|
|
10
|
+
authState: AuthState;
|
|
11
|
+
handleLoginSuccess: (user: AuthUser, tokens?: TokenPair) => void;
|
|
12
|
+
logout: () => Promise<void>;
|
|
13
|
+
refreshUser: () => Promise<void>;
|
|
14
|
+
getAccessToken: () => string | null;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Hook that manages authentication session state, token refresh, and tab sync.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useAuthSession({ serverUrl, session, callbacks, requestTimeoutMs, }: UseAuthSessionOptions): UseAuthSessionReturn;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { AuthorizeRequest, AuthError } from '../types';
|
|
2
|
+
export interface AuthorizationCheck {
|
|
3
|
+
allowed: boolean;
|
|
4
|
+
reason?: string;
|
|
5
|
+
isLoading: boolean;
|
|
6
|
+
error: AuthError | null;
|
|
7
|
+
}
|
|
8
|
+
export interface UseAuthorizeReturn {
|
|
9
|
+
/**
|
|
10
|
+
* Check if an action is authorized server-side.
|
|
11
|
+
* Use this for dynamic authorization checks.
|
|
12
|
+
*/
|
|
13
|
+
authorize: (request: AuthorizeRequest) => Promise<boolean>;
|
|
14
|
+
/**
|
|
15
|
+
* Authorization state for the last check
|
|
16
|
+
*/
|
|
17
|
+
lastCheck: AuthorizationCheck;
|
|
18
|
+
/**
|
|
19
|
+
* Clear the last authorization check
|
|
20
|
+
*/
|
|
21
|
+
clearCheck: () => void;
|
|
22
|
+
/**
|
|
23
|
+
* Check authorization and return detailed result
|
|
24
|
+
*/
|
|
25
|
+
checkAuthorization: (request: AuthorizeRequest) => Promise<AuthorizationCheck>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Hook for server-side authorization checks.
|
|
29
|
+
*
|
|
30
|
+
* This hook allows you to check if a specific action is authorized
|
|
31
|
+
* by making a request to the server's /authorize endpoint.
|
|
32
|
+
*
|
|
33
|
+
* For simple permission checks based on the user's role, use `useOrgs().hasPermission()` instead.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```tsx
|
|
37
|
+
* function DeleteButton({ resourceId }: { resourceId: string }) {
|
|
38
|
+
* const { authorize, lastCheck } = useAuthorize();
|
|
39
|
+
* const { activeOrg } = useOrgs();
|
|
40
|
+
*
|
|
41
|
+
* const handleDelete = async () => {
|
|
42
|
+
* const allowed = await authorize({
|
|
43
|
+
* orgId: activeOrg?.id!,
|
|
44
|
+
* action: 'delete',
|
|
45
|
+
* resource: 'document',
|
|
46
|
+
* resourceId,
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* if (allowed) {
|
|
50
|
+
* // Proceed with delete
|
|
51
|
+
* }
|
|
52
|
+
* };
|
|
53
|
+
*
|
|
54
|
+
* return (
|
|
55
|
+
* <button onClick={handleDelete} disabled={lastCheck.isLoading}>
|
|
56
|
+
* Delete
|
|
57
|
+
* </button>
|
|
58
|
+
* );
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare function useAuthorize(): UseAuthorizeReturn;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UseCreditsReturn } from '../types/deposit';
|
|
2
|
+
export type { UseCreditsReturn } from '../types/deposit';
|
|
3
|
+
/**
|
|
4
|
+
* Hook for credit balance and transaction history
|
|
5
|
+
*
|
|
6
|
+
* Credits represent the user's balance from Privacy Cash deposits.
|
|
7
|
+
* The balance can be used for services within the application.
|
|
8
|
+
*
|
|
9
|
+
* Safe to call outside CedrosLoginProvider - returns no-op functions that throw.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useCredits(): UseCreditsReturn;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { UseDepositReturn } from '../types/deposit';
|
|
2
|
+
export type { UseDepositReturn } from '../types/deposit';
|
|
3
|
+
/**
|
|
4
|
+
* Hook for Privacy Cash deposit operations
|
|
5
|
+
*
|
|
6
|
+
* Deposits go to the user's Privacy Cash account (user's pubkey is owner).
|
|
7
|
+
* Credits are issued immediately, withdrawal to company wallet happens later.
|
|
8
|
+
*
|
|
9
|
+
* Requirements:
|
|
10
|
+
* - User must have SSS wallet enrolled
|
|
11
|
+
* - Wallet must be unlocked (call POST /wallet/unlock first)
|
|
12
|
+
* - Wallet must be in "no recovery" mode
|
|
13
|
+
*
|
|
14
|
+
* Safe to call outside CedrosLoginProvider - returns no-op functions that throw.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useDeposit(): UseDepositReturn;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { AuthResponse, AuthError } from '../types';
|
|
2
|
+
/** Result when MFA verification is required */
|
|
3
|
+
export interface MfaRequiredResult {
|
|
4
|
+
mfaRequired: true;
|
|
5
|
+
mfaToken: string;
|
|
6
|
+
email: string;
|
|
7
|
+
userId: string;
|
|
8
|
+
}
|
|
9
|
+
/** Result of successful login (no TOTP required or after TOTP verification) */
|
|
10
|
+
export interface LoginSuccessResult {
|
|
11
|
+
mfaRequired: false;
|
|
12
|
+
response: AuthResponse;
|
|
13
|
+
}
|
|
14
|
+
/** Union type for login result */
|
|
15
|
+
export type LoginResult = MfaRequiredResult | LoginSuccessResult;
|
|
16
|
+
export interface UseEmailAuthReturn {
|
|
17
|
+
/** Login - may return mfaRequired if 2FA is enabled */
|
|
18
|
+
login: (email: string, password: string) => Promise<LoginResult>;
|
|
19
|
+
register: (email: string, password: string, name?: string) => Promise<AuthResponse>;
|
|
20
|
+
isLoading: boolean;
|
|
21
|
+
error: AuthError | null;
|
|
22
|
+
clearError: () => void;
|
|
23
|
+
/**
|
|
24
|
+
* Number of remaining login attempts before rate limiting.
|
|
25
|
+
*
|
|
26
|
+
* M-10: Snapshot Behavior
|
|
27
|
+
* This value is a point-in-time snapshot computed at render time.
|
|
28
|
+
* It may be briefly stale during rapid requests or concurrent renders.
|
|
29
|
+
* For UI display only - actual rate limiting is enforced inside login/register.
|
|
30
|
+
*/
|
|
31
|
+
remainingAttempts: number;
|
|
32
|
+
/**
|
|
33
|
+
* Time in ms until rate limit resets (0 if not rate limited).
|
|
34
|
+
*
|
|
35
|
+
* M-10: Snapshot Behavior
|
|
36
|
+
* This value is a point-in-time snapshot computed at render time.
|
|
37
|
+
* It may be briefly stale - use for UI display, not for logic decisions.
|
|
38
|
+
*/
|
|
39
|
+
timeUntilReset: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Hook for email/password authentication.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```tsx
|
|
46
|
+
* function LoginForm() {
|
|
47
|
+
* const { login, isLoading, error } = useEmailAuth();
|
|
48
|
+
*
|
|
49
|
+
* const handleSubmit = async (e) => {
|
|
50
|
+
* e.preventDefault();
|
|
51
|
+
* try {
|
|
52
|
+
* await login(email, password);
|
|
53
|
+
* } catch (err) {
|
|
54
|
+
* // Handle error
|
|
55
|
+
* }
|
|
56
|
+
* };
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare function useEmailAuth(): UseEmailAuthReturn;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { AuthResponse, AuthError } from '../types';
|
|
2
|
+
/** @internal */
|
|
3
|
+
export declare const _internalGoogleScriptLoader: {
|
|
4
|
+
loading: boolean;
|
|
5
|
+
loaded: boolean;
|
|
6
|
+
error: Error | null;
|
|
7
|
+
callbacks: Array<{
|
|
8
|
+
resolve: () => void;
|
|
9
|
+
reject: (err: Error) => void;
|
|
10
|
+
}>;
|
|
11
|
+
load(): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Reset singleton state for test isolation (F-08)
|
|
14
|
+
* @internal - Only use in test setup/teardown
|
|
15
|
+
*/
|
|
16
|
+
_reset(): void;
|
|
17
|
+
};
|
|
18
|
+
export interface UseGoogleAuthReturn {
|
|
19
|
+
signIn: () => Promise<AuthResponse>;
|
|
20
|
+
isLoading: boolean;
|
|
21
|
+
isInitialized: boolean;
|
|
22
|
+
error: AuthError | null;
|
|
23
|
+
clearError: () => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Hook for Google OAuth authentication.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* function GoogleButton() {
|
|
31
|
+
* const { signIn, isLoading, isInitialized, error } = useGoogleAuth();
|
|
32
|
+
*
|
|
33
|
+
* return (
|
|
34
|
+
* <button onClick={signIn} disabled={!isInitialized || isLoading}>
|
|
35
|
+
* {isLoading ? 'Signing in...' : 'Sign in with Google'}
|
|
36
|
+
* </button>
|
|
37
|
+
* );
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function useGoogleAuth(): UseGoogleAuthReturn;
|
|
42
|
+
declare global {
|
|
43
|
+
interface Window {
|
|
44
|
+
google?: {
|
|
45
|
+
accounts?: {
|
|
46
|
+
id?: {
|
|
47
|
+
initialize: (config: {
|
|
48
|
+
client_id: string;
|
|
49
|
+
callback: (response: {
|
|
50
|
+
credential: string;
|
|
51
|
+
}) => void;
|
|
52
|
+
auto_select?: boolean;
|
|
53
|
+
cancel_on_tap_outside?: boolean;
|
|
54
|
+
}) => void;
|
|
55
|
+
prompt: (callback: (notification: {
|
|
56
|
+
isNotDisplayed: () => boolean;
|
|
57
|
+
isSkippedMoment: () => boolean;
|
|
58
|
+
isDismissedMoment: () => boolean;
|
|
59
|
+
getMomentType: () => string;
|
|
60
|
+
}) => void) => void;
|
|
61
|
+
renderButton: (element: HTMLElement, config: object) => void;
|
|
62
|
+
disableAutoSelect: () => void;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { AuthError, AuthResponse, MfaRequiredResponse } from '../types';
|
|
2
|
+
export interface UseInstantLinkReturn {
|
|
3
|
+
/** Send an instant link email to the given address */
|
|
4
|
+
sendInstantLink: (email: string) => Promise<void>;
|
|
5
|
+
/** Verify an instant link token and sign in */
|
|
6
|
+
verifyInstantLink: (token: string) => Promise<AuthResponse | MfaRequiredResponse>;
|
|
7
|
+
/** Whether a request is in progress */
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
/** Whether the instant link was sent successfully */
|
|
10
|
+
isSuccess: boolean;
|
|
11
|
+
/** Error from the last request */
|
|
12
|
+
error: AuthError | null;
|
|
13
|
+
/** Clear the error state */
|
|
14
|
+
clearError: () => void;
|
|
15
|
+
/** Reset to initial state */
|
|
16
|
+
reset: () => void;
|
|
17
|
+
/** Number of remaining attempts before rate limiting */
|
|
18
|
+
remainingAttempts: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Hook for instant link (passwordless) authentication.
|
|
22
|
+
*
|
|
23
|
+
* Sends an instant link email that allows the user to sign in
|
|
24
|
+
* without entering their password.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* function InstantLinkForm() {
|
|
29
|
+
* const { sendInstantLink, isLoading, isSuccess, error } = useInstantLink();
|
|
30
|
+
*
|
|
31
|
+
* const handleSubmit = async (e) => {
|
|
32
|
+
* e.preventDefault();
|
|
33
|
+
* await sendInstantLink(email);
|
|
34
|
+
* };
|
|
35
|
+
*
|
|
36
|
+
* if (isSuccess) {
|
|
37
|
+
* return <p>Check your email for the sign-in link</p>;
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function useInstantLink(): UseInstantLinkReturn;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Invite, OrgRole, AuthError, AcceptInviteResponse } from '../types';
|
|
2
|
+
export interface UseInvitesReturn {
|
|
3
|
+
/** List of pending invites */
|
|
4
|
+
invites: Invite[];
|
|
5
|
+
/** Total pending invites available on the server */
|
|
6
|
+
total: number;
|
|
7
|
+
/** Loading state */
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
/** Error state */
|
|
10
|
+
error: AuthError | null;
|
|
11
|
+
/** Fetch/refresh invites list */
|
|
12
|
+
fetchInvites: (options?: {
|
|
13
|
+
limit?: number;
|
|
14
|
+
offset?: number;
|
|
15
|
+
}) => Promise<void>;
|
|
16
|
+
/** Create a new invite */
|
|
17
|
+
createInvite: (email: string, role?: Exclude<OrgRole, 'owner'>) => Promise<void>;
|
|
18
|
+
/** Cancel a pending invite */
|
|
19
|
+
cancelInvite: (inviteId: string) => Promise<void>;
|
|
20
|
+
/** Resend an invite email */
|
|
21
|
+
resendInvite: (inviteId: string) => Promise<void>;
|
|
22
|
+
/** Accept an invite (public) */
|
|
23
|
+
acceptInvite: (token: string) => Promise<AcceptInviteResponse>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Hook for managing organization invites.
|
|
27
|
+
*
|
|
28
|
+
* @param orgId - The organization ID to manage invites for
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* function InviteManager() {
|
|
33
|
+
* const { activeOrg } = useOrgs();
|
|
34
|
+
* const { invites, createInvite, cancelInvite, resendInvite } = useInvites(activeOrg?.id);
|
|
35
|
+
*
|
|
36
|
+
* const handleInvite = async (email: string) => {
|
|
37
|
+
* await createInvite(email, 'member');
|
|
38
|
+
* };
|
|
39
|
+
*
|
|
40
|
+
* return (
|
|
41
|
+
* <div>
|
|
42
|
+
* <InviteForm onSubmit={handleInvite} />
|
|
43
|
+
* <ul>
|
|
44
|
+
* {invites.map(invite => (
|
|
45
|
+
* <li key={invite.id}>
|
|
46
|
+
* {invite.email} ({invite.role})
|
|
47
|
+
* <button onClick={() => resendInvite(invite.id)}>Resend</button>
|
|
48
|
+
* <button onClick={() => cancelInvite(invite.id)}>Cancel</button>
|
|
49
|
+
* </li>
|
|
50
|
+
* ))}
|
|
51
|
+
* </ul>
|
|
52
|
+
* </div>
|
|
53
|
+
* );
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function useInvites(orgId: string | undefined): UseInvitesReturn;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Member, OrgRole, AuthError } from '../types';
|
|
2
|
+
export interface UseMembersReturn {
|
|
3
|
+
/** List of members */
|
|
4
|
+
members: Member[];
|
|
5
|
+
/** Total members available on the server */
|
|
6
|
+
total: number;
|
|
7
|
+
/** Loading state */
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
/** Error state */
|
|
10
|
+
error: AuthError | null;
|
|
11
|
+
/** Fetch/refresh members list */
|
|
12
|
+
fetchMembers: (options?: {
|
|
13
|
+
limit?: number;
|
|
14
|
+
offset?: number;
|
|
15
|
+
}) => Promise<void>;
|
|
16
|
+
/** Update a member's role */
|
|
17
|
+
updateMemberRole: (userId: string, role: OrgRole) => Promise<void>;
|
|
18
|
+
/** Remove a member */
|
|
19
|
+
removeMember: (userId: string) => Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Hook for managing organization members.
|
|
23
|
+
*
|
|
24
|
+
* @param orgId - The organization ID to manage members for
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* function MembersList() {
|
|
29
|
+
* const { activeOrg } = useOrgs();
|
|
30
|
+
* const { members, isLoading, updateMemberRole, removeMember } = useMembers(activeOrg?.id);
|
|
31
|
+
*
|
|
32
|
+
* if (!activeOrg) return null;
|
|
33
|
+
*
|
|
34
|
+
* return (
|
|
35
|
+
* <ul>
|
|
36
|
+
* {members.map(member => (
|
|
37
|
+
* <li key={member.id}>
|
|
38
|
+
* {member.user.name} - {member.role}
|
|
39
|
+
* <button onClick={() => updateMemberRole(member.userId, 'admin')}>
|
|
40
|
+
* Make Admin
|
|
41
|
+
* </button>
|
|
42
|
+
* <button onClick={() => removeMember(member.userId)}>
|
|
43
|
+
* Remove
|
|
44
|
+
* </button>
|
|
45
|
+
* </li>
|
|
46
|
+
* ))}
|
|
47
|
+
* </ul>
|
|
48
|
+
* );
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function useMembers(orgId: string | undefined): UseMembersReturn;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { OrgWithMembership, Organization, CreateOrgRequest, UpdateOrgRequest, Permission, OrgRole, AuthError } from '../types';
|
|
2
|
+
export interface UseOrgsReturn {
|
|
3
|
+
/** All organizations the user belongs to */
|
|
4
|
+
orgs: OrgWithMembership[];
|
|
5
|
+
/** Currently active organization */
|
|
6
|
+
activeOrg: OrgWithMembership | null;
|
|
7
|
+
/** User's permissions in the active org */
|
|
8
|
+
permissions: Permission[];
|
|
9
|
+
/** User's role in the active org */
|
|
10
|
+
role: OrgRole | null;
|
|
11
|
+
/** Loading state */
|
|
12
|
+
isLoading: boolean;
|
|
13
|
+
/** Error state */
|
|
14
|
+
error: AuthError | null;
|
|
15
|
+
/** Fetch/refresh organizations list */
|
|
16
|
+
fetchOrgs: () => Promise<void>;
|
|
17
|
+
/** Switch to a different organization */
|
|
18
|
+
switchOrg: (orgId: string) => Promise<void>;
|
|
19
|
+
/** Create a new organization */
|
|
20
|
+
createOrg: (data: CreateOrgRequest) => Promise<Organization>;
|
|
21
|
+
/** Update an organization */
|
|
22
|
+
updateOrg: (orgId: string, data: UpdateOrgRequest) => Promise<Organization>;
|
|
23
|
+
/** Delete an organization */
|
|
24
|
+
deleteOrg: (orgId: string) => Promise<void>;
|
|
25
|
+
/** Check if user has a specific permission */
|
|
26
|
+
hasPermission: (permission: Permission) => boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Hook for managing organizations, memberships, and permissions.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* function OrgSelector() {
|
|
34
|
+
* const { orgs, activeOrg, switchOrg, hasPermission } = useOrgs();
|
|
35
|
+
*
|
|
36
|
+
* return (
|
|
37
|
+
* <select
|
|
38
|
+
* value={activeOrg?.id}
|
|
39
|
+
* onChange={(e) => switchOrg(e.target.value)}
|
|
40
|
+
* >
|
|
41
|
+
* {orgs.map(org => (
|
|
42
|
+
* <option key={org.id} value={org.id}>{org.name}</option>
|
|
43
|
+
* ))}
|
|
44
|
+
* </select>
|
|
45
|
+
* );
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function useOrgs(): UseOrgsReturn;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AuthError } from '../types';
|
|
2
|
+
export interface UsePasswordResetReturn {
|
|
3
|
+
forgotPassword: (email: string) => Promise<void>;
|
|
4
|
+
resetPassword: (token: string, newPassword: string) => Promise<void>;
|
|
5
|
+
isLoading: boolean;
|
|
6
|
+
isSuccess: boolean;
|
|
7
|
+
error: AuthError | null;
|
|
8
|
+
clearError: () => void;
|
|
9
|
+
reset: () => void;
|
|
10
|
+
/** Number of remaining attempts before rate limiting */
|
|
11
|
+
remainingAttempts: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Hook for password reset functionality.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* function ForgotPasswordForm() {
|
|
19
|
+
* const { forgotPassword, isLoading, isSuccess, error } = usePasswordReset();
|
|
20
|
+
*
|
|
21
|
+
* const handleSubmit = async (e) => {
|
|
22
|
+
* e.preventDefault();
|
|
23
|
+
* await forgotPassword(email);
|
|
24
|
+
* };
|
|
25
|
+
*
|
|
26
|
+
* if (isSuccess) {
|
|
27
|
+
* return <p>Check your email for reset instructions</p>;
|
|
28
|
+
* }
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function usePasswordReset(): UsePasswordResetReturn;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook for pending wallet recovery management
|
|
3
|
+
*
|
|
4
|
+
* After wallet enrollment, if recovery mode is enabled, the server stores
|
|
5
|
+
* recovery data temporarily. This hook fetches that data and allows the
|
|
6
|
+
* user to acknowledge receipt (after which the data is deleted from server).
|
|
7
|
+
*/
|
|
8
|
+
export interface UsePendingRecoveryReturn {
|
|
9
|
+
/** Whether there is pending recovery data */
|
|
10
|
+
hasPendingRecovery: boolean;
|
|
11
|
+
/** Recovery type: 'share_c' or 'full_seed' */
|
|
12
|
+
recoveryType: string | null;
|
|
13
|
+
/** Recovery phrase (base64-encoded seed) */
|
|
14
|
+
recoveryPhrase: string | null;
|
|
15
|
+
/** When the recovery data expires */
|
|
16
|
+
expiresAt: Date | null;
|
|
17
|
+
/** Fetch pending recovery data from server */
|
|
18
|
+
fetchPendingRecovery: () => Promise<void>;
|
|
19
|
+
/** Acknowledge that user has saved the recovery phrase (deletes from server) */
|
|
20
|
+
acknowledgeRecovery: () => Promise<void>;
|
|
21
|
+
/** Whether request is in progress */
|
|
22
|
+
isLoading: boolean;
|
|
23
|
+
/** Error from last request */
|
|
24
|
+
error: string | null;
|
|
25
|
+
/** Clear error */
|
|
26
|
+
clearError: () => void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Hook for managing pending wallet recovery data
|
|
30
|
+
*
|
|
31
|
+
* Use this after wallet enrollment to show the user their recovery phrase
|
|
32
|
+
* and allow them to acknowledge receipt.
|
|
33
|
+
*/
|
|
34
|
+
export declare function usePendingRecovery(): UsePendingRecoveryReturn;
|