auramaxx 1.0.0-alpha.4
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 +26 -0
- package/README.md +112 -0
- package/bin/aurawallet.js +121 -0
- package/docs/ADAPTERS.md +467 -0
- package/docs/API.md +2679 -0
- package/docs/APPS.md +198 -0
- package/docs/ARCHITECTURE.md +350 -0
- package/docs/AUTH.md +698 -0
- package/docs/BEST-PRACTICES.md +121 -0
- package/docs/CLI.md +61 -0
- package/docs/DEVELOPING-APPS.md +452 -0
- package/docs/EXTENSION.md +97 -0
- package/docs/JOBS.md +33 -0
- package/docs/MCP.md +76 -0
- package/docs/PROTOCOL.md +142 -0
- package/docs/SETUP.md +219 -0
- package/docs/WORKSPACE.md +672 -0
- package/docs/agent-auth.md +63 -0
- package/docs/aura-file.md +48 -0
- package/docs/credentials.md +53 -0
- package/docs/external/getting-started.md +65 -0
- package/docs/external/overview.md +45 -0
- package/docs/external/use-cases.md +48 -0
- package/docs/external/why-aura.md +35 -0
- package/docs/jobs/connect-agent.md +77 -0
- package/docs/jobs/migrate-from-dotenv.md +79 -0
- package/docs/jobs/recover-from-lockout.md +72 -0
- package/docs/jobs/secure-ci.md +63 -0
- package/docs/oauth2.md +42 -0
- package/docs/passkeys.md +60 -0
- package/docs/security.md +540 -0
- package/docs/specs/aura-open-protocol.md +61 -0
- package/docs/specs/aura-provider-plugin.md +24 -0
- package/docs/specs/aura-registry-model.md +31 -0
- package/docs/specs/fixtures/invalid-bad-key.aura +1 -0
- package/docs/specs/fixtures/invalid-bad-unicode-escape.aura +1 -0
- package/docs/specs/fixtures/invalid-duplicate-key.aura +2 -0
- package/docs/specs/fixtures/valid-basic.aura +4 -0
- package/docs/specs/fixtures/valid-provider-ref.aura +1 -0
- package/docs/specs/fixtures/valid-quoted-escapes.aura +2 -0
- package/docs/templates/RELEASE_NOTES_TEMPLATE.md +22 -0
- package/docs/totp.md +40 -0
- package/docs/wallet/AI.md +508 -0
- package/docs/wallet/DEVELOPING-STRATEGIES.md +713 -0
- package/docs/wallet/README.md +47 -0
- package/docs/wallet/STRATEGY.md +89 -0
- package/next.config.ts +21 -0
- package/package.json +151 -0
- package/postcss.config.mjs +8 -0
- package/prisma/migrations/20260214170000_baseline/migration.sql +511 -0
- package/prisma/migrations/20260216214537_add_passkey_model/migration.sql +18 -0
- package/prisma/migrations/20260217150500_add_credential_access_audit/migration.sql +31 -0
- package/prisma/migrations/migration_lock.toml +3 -0
- package/prisma/schema.prisma +447 -0
- package/public/logo-chevron.svg +31 -0
- package/public/logo-concentric.svg +31 -0
- package/public/logo-crosshatch.svg +39 -0
- package/public/logo-dashed.svg +39 -0
- package/public/logo-horizontal.svg +31 -0
- package/public/logo-m56.svg +64 -0
- package/public/logo.webp +0 -0
- package/scripts/add-app.js +245 -0
- package/scripts/init.sh +57 -0
- package/scripts/migrate-apikeys-to-credentials.ts +35 -0
- package/scripts/sandbox-agent-flow.sh +235 -0
- package/scripts/sandbox.sh +175 -0
- package/scripts/validate-job-docs.mjs +125 -0
- package/server/abi/SwapHelper.json +438 -0
- package/server/cli/approval.ts +447 -0
- package/server/cli/commands/app.ts +204 -0
- package/server/cli/commands/cron.ts +24 -0
- package/server/cli/commands/doctor.ts +1007 -0
- package/server/cli/commands/env.ts +456 -0
- package/server/cli/commands/init.ts +752 -0
- package/server/cli/commands/mcp.ts +125 -0
- package/server/cli/commands/restore.ts +314 -0
- package/server/cli/commands/shell-hook.ts +468 -0
- package/server/cli/commands/start.ts +62 -0
- package/server/cli/commands/status.ts +59 -0
- package/server/cli/commands/stop.ts +14 -0
- package/server/cli/commands/token.ts +180 -0
- package/server/cli/commands/unlock.ts +49 -0
- package/server/cli/commands/vault.ts +417 -0
- package/server/cli/index.ts +328 -0
- package/server/cli/lib/aura-parser.ts +64 -0
- package/server/cli/lib/credential-create.ts +74 -0
- package/server/cli/lib/credential-resolve.ts +254 -0
- package/server/cli/lib/dotenv-migrate.ts +116 -0
- package/server/cli/lib/dotenv-parser.ts +146 -0
- package/server/cli/lib/http.ts +91 -0
- package/server/cli/lib/init-steps.ts +76 -0
- package/server/cli/lib/local-agent-trust.ts +45 -0
- package/server/cli/lib/process.ts +136 -0
- package/server/cli/lib/prompt.ts +85 -0
- package/server/cli/lib/theme.ts +240 -0
- package/server/cli/socket.ts +570 -0
- package/server/cli/transport-client.ts +50 -0
- package/server/cron/index.ts +137 -0
- package/server/cron/job.ts +31 -0
- package/server/cron/jobs/balance-sync.ts +436 -0
- package/server/cron/jobs/incoming-scan.ts +506 -0
- package/server/cron/jobs/native-price.ts +70 -0
- package/server/cron/jobs/orphan-cleanup.ts +40 -0
- package/server/cron/jobs/strategy-runner.ts +175 -0
- package/server/cron/scheduler.ts +125 -0
- package/server/index.ts +406 -0
- package/server/lib/adapters/factory.ts +110 -0
- package/server/lib/adapters/index.ts +19 -0
- package/server/lib/adapters/router.ts +297 -0
- package/server/lib/adapters/telegram.ts +645 -0
- package/server/lib/adapters/types.ts +89 -0
- package/server/lib/adapters/webhook.ts +95 -0
- package/server/lib/address.ts +49 -0
- package/server/lib/agent-auth/contracts.ts +1194 -0
- package/server/lib/agent-profiles.ts +328 -0
- package/server/lib/ai.ts +285 -0
- package/server/lib/api-registry/contracts.ts +86 -0
- package/server/lib/api-registry/validation.ts +172 -0
- package/server/lib/apikey-migration.ts +189 -0
- package/server/lib/app-installer.ts +505 -0
- package/server/lib/app-tokens.ts +247 -0
- package/server/lib/auth.ts +314 -0
- package/server/lib/batch.ts +242 -0
- package/server/lib/cold.ts +874 -0
- package/server/lib/config.ts +381 -0
- package/server/lib/credential-access-audit.ts +85 -0
- package/server/lib/credential-access-policy.ts +110 -0
- package/server/lib/credential-health.ts +343 -0
- package/server/lib/credential-import.ts +487 -0
- package/server/lib/credential-scope.ts +87 -0
- package/server/lib/credential-shares.ts +190 -0
- package/server/lib/credential-transport.ts +342 -0
- package/server/lib/credential-vault.ts +77 -0
- package/server/lib/credentials.ts +333 -0
- package/server/lib/crypto.ts +8 -0
- package/server/lib/db.ts +15 -0
- package/server/lib/defaults.ts +366 -0
- package/server/lib/dex/index.ts +80 -0
- package/server/lib/dex/relay.ts +235 -0
- package/server/lib/dex/types.ts +59 -0
- package/server/lib/dex/uniswap.ts +370 -0
- package/server/lib/e2e-agent/artifacts.ts +36 -0
- package/server/lib/e2e-agent/contracts.ts +112 -0
- package/server/lib/e2e-agent/validation.ts +135 -0
- package/server/lib/encrypt.ts +128 -0
- package/server/lib/error.ts +20 -0
- package/server/lib/events.ts +205 -0
- package/server/lib/hot.ts +357 -0
- package/server/lib/key-fingerprint.ts +28 -0
- package/server/lib/logger.ts +331 -0
- package/server/lib/network.ts +137 -0
- package/server/lib/notifications.ts +219 -0
- package/server/lib/oauth2-refresh.ts +241 -0
- package/server/lib/oursecret.ts +54 -0
- package/server/lib/passkey-credential.ts +360 -0
- package/server/lib/passkey.ts +68 -0
- package/server/lib/permissions.ts +248 -0
- package/server/lib/pino.ts +24 -0
- package/server/lib/policy-preview.ts +138 -0
- package/server/lib/price.ts +338 -0
- package/server/lib/prices.ts +34 -0
- package/server/lib/project-scope.ts +239 -0
- package/server/lib/resolve-action.ts +427 -0
- package/server/lib/resolve.ts +36 -0
- package/server/lib/sessions.ts +632 -0
- package/server/lib/solana/connection.ts +26 -0
- package/server/lib/solana/jupiter.ts +128 -0
- package/server/lib/solana/transfer.ts +108 -0
- package/server/lib/solana/wallet.ts +136 -0
- package/server/lib/strategy/emits.ts +21 -0
- package/server/lib/strategy/engine.ts +1305 -0
- package/server/lib/strategy/executor.ts +115 -0
- package/server/lib/strategy/hook-context.ts +158 -0
- package/server/lib/strategy/hooks.ts +990 -0
- package/server/lib/strategy/index.ts +28 -0
- package/server/lib/strategy/installer.ts +305 -0
- package/server/lib/strategy/loader.ts +256 -0
- package/server/lib/strategy/message.ts +235 -0
- package/server/lib/strategy/repository.ts +218 -0
- package/server/lib/strategy/session-logger.ts +693 -0
- package/server/lib/strategy/sources.ts +288 -0
- package/server/lib/strategy/state.ts +189 -0
- package/server/lib/strategy/templates.ts +403 -0
- package/server/lib/strategy/tick.ts +404 -0
- package/server/lib/strategy/types.ts +230 -0
- package/server/lib/swap.ts +3 -0
- package/server/lib/temp.ts +86 -0
- package/server/lib/token-metadata.ts +86 -0
- package/server/lib/token-safety.ts +200 -0
- package/server/lib/token-search.ts +444 -0
- package/server/lib/totp.ts +194 -0
- package/server/lib/transactions.ts +123 -0
- package/server/lib/transport.ts +75 -0
- package/server/lib/txhistory/decoder.ts +262 -0
- package/server/lib/txhistory/enricher.ts +652 -0
- package/server/lib/txhistory/index.ts +391 -0
- package/server/lib/txhistory/signatures.ts +59 -0
- package/server/lib/verified-summary.ts +421 -0
- package/server/mcp/profile-policy.ts +30 -0
- package/server/mcp/server.ts +619 -0
- package/server/mcp/tools.ts +523 -0
- package/server/middleware/auth.ts +119 -0
- package/server/middleware/requestLogger.ts +84 -0
- package/server/routes/actions.ts +459 -0
- package/server/routes/adapters.ts +703 -0
- package/server/routes/addressbook.ts +113 -0
- package/server/routes/ai.ts +34 -0
- package/server/routes/apikeys.ts +295 -0
- package/server/routes/apps.ts +601 -0
- package/server/routes/auth.ts +457 -0
- package/server/routes/backup.ts +340 -0
- package/server/routes/batch.ts +270 -0
- package/server/routes/bookmarks.ts +162 -0
- package/server/routes/credential-shares.ts +198 -0
- package/server/routes/credential-vaults.ts +154 -0
- package/server/routes/credentials.ts +1290 -0
- package/server/routes/dashboard.ts +71 -0
- package/server/routes/defaults.ts +124 -0
- package/server/routes/fund.ts +229 -0
- package/server/routes/import.ts +352 -0
- package/server/routes/launch.ts +665 -0
- package/server/routes/lock.ts +54 -0
- package/server/routes/logs.ts +68 -0
- package/server/routes/nuke.ts +111 -0
- package/server/routes/passkey-credentials.ts +99 -0
- package/server/routes/passkey.ts +346 -0
- package/server/routes/portfolio.ts +217 -0
- package/server/routes/price.ts +63 -0
- package/server/routes/resolve.ts +31 -0
- package/server/routes/security.ts +45 -0
- package/server/routes/send-evm.ts +241 -0
- package/server/routes/send-solana.ts +281 -0
- package/server/routes/send.ts +178 -0
- package/server/routes/setup.ts +210 -0
- package/server/routes/strategy.ts +894 -0
- package/server/routes/swap-evm.ts +353 -0
- package/server/routes/swap-solana.ts +177 -0
- package/server/routes/swap.ts +356 -0
- package/server/routes/token.ts +247 -0
- package/server/routes/unlock.ts +403 -0
- package/server/routes/wallet-assets.ts +361 -0
- package/server/routes/wallet-transactions.ts +515 -0
- package/server/routes/wallet.ts +710 -0
- package/server/types.ts +146 -0
- package/skills/aurawallet/SKILL.md +739 -0
- package/skills/aurawallet-setup/SKILL.md +74 -0
- package/skills/security-review/SKILL.md +148 -0
- package/src/app/api/agent-requests/route.ts +30 -0
- package/src/app/api/apps/install/route.ts +126 -0
- package/src/app/api/apps/manifests/route.ts +16 -0
- package/src/app/api/apps/static/[...path]/route.ts +57 -0
- package/src/app/api/events/route.ts +92 -0
- package/src/app/api/page.tsx +212 -0
- package/src/app/api/workspace/[id]/apps/[wid]/route.ts +119 -0
- package/src/app/api/workspace/[id]/apps/route.ts +81 -0
- package/src/app/api/workspace/[id]/export/route.ts +67 -0
- package/src/app/api/workspace/[id]/route.ts +168 -0
- package/src/app/api/workspace/auth.ts +34 -0
- package/src/app/api/workspace/config/route.ts +106 -0
- package/src/app/api/workspace/import/route.ts +127 -0
- package/src/app/api/workspace/route.ts +116 -0
- package/src/app/app/page.tsx +2122 -0
- package/src/app/apple-icon.png +0 -0
- package/src/app/docs/page.tsx +178 -0
- package/src/app/favicon.ico +0 -0
- package/src/app/globals.css +572 -0
- package/src/app/health/page.tsx +5 -0
- package/src/app/hello/page.tsx +15 -0
- package/src/app/icon.png +0 -0
- package/src/app/layout.tsx +34 -0
- package/src/app/page.tsx +986 -0
- package/src/app/providers.tsx +90 -0
- package/src/app/share/[token]/page.tsx +295 -0
- package/src/components/ChainSelector.tsx +144 -0
- package/src/components/HumanActionBar.tsx +695 -0
- package/src/components/NotificationDrawer.tsx +129 -0
- package/src/components/apps/AgentKeysApp.tsx +490 -0
- package/src/components/apps/App.tsx +153 -0
- package/src/components/apps/AppGrid.tsx +15 -0
- package/src/components/apps/DetailedAddressDrawer.tsx +325 -0
- package/src/components/apps/DraggableApp.tsx +562 -0
- package/src/components/apps/IFrameApp.tsx +73 -0
- package/src/components/apps/LogsApp.tsx +360 -0
- package/src/components/apps/SendApp.tsx +394 -0
- package/src/components/apps/SetupWizardApp.tsx +1004 -0
- package/src/components/apps/SystemDefaultsApp.tsx +845 -0
- package/src/components/apps/ThirdPartyApp.tsx +428 -0
- package/src/components/apps/TokenApp.tsx +319 -0
- package/src/components/apps/TransactionsApp.tsx +438 -0
- package/src/components/apps/WalletDetailApp.tsx +1505 -0
- package/src/components/apps/index.ts +13 -0
- package/src/components/design-system/Button.tsx +53 -0
- package/src/components/design-system/ChainIndicator.tsx +65 -0
- package/src/components/design-system/ChainSelector.tsx +137 -0
- package/src/components/design-system/ConfirmationModal.tsx +106 -0
- package/src/components/design-system/ConfirmationPopover.tsx +81 -0
- package/src/components/design-system/Drawer.tsx +123 -0
- package/src/components/design-system/FilterDropdown.tsx +72 -0
- package/src/components/design-system/Modal.tsx +206 -0
- package/src/components/design-system/Popover.tsx +142 -0
- package/src/components/design-system/TextInput.tsx +85 -0
- package/src/components/design-system/Toggle.tsx +58 -0
- package/src/components/design-system/index.ts +11 -0
- package/src/components/docs/DocsThemeToggle.tsx +49 -0
- package/src/components/health/CredentialHealthDashboard.tsx +214 -0
- package/src/components/icons/ChainIcons.tsx +72 -0
- package/src/components/layout/AppStoreDrawer.tsx +369 -0
- package/src/components/layout/ContentArea.tsx +21 -0
- package/src/components/layout/TabBar.tsx +278 -0
- package/src/components/layout/WalletSidebar.tsx +1033 -0
- package/src/components/layout/index.ts +4 -0
- package/src/components/marketing/AuraWalletSpecOverlay.tsx +635 -0
- package/src/components/marketing/DeviceMorphExperience.tsx +216 -0
- package/src/components/vault/ApiKeysConsole.tsx +1080 -0
- package/src/components/vault/AuditConsole.tsx +584 -0
- package/src/components/vault/CredentialDetail.tsx +455 -0
- package/src/components/vault/CredentialEmpty.tsx +55 -0
- package/src/components/vault/CredentialField.tsx +361 -0
- package/src/components/vault/CredentialForm.tsx +1212 -0
- package/src/components/vault/CredentialList.tsx +165 -0
- package/src/components/vault/CredentialRow.tsx +97 -0
- package/src/components/vault/CredentialShareModal.tsx +178 -0
- package/src/components/vault/CredentialVault.tsx +754 -0
- package/src/components/vault/CredentialWalletWidget.tsx +103 -0
- package/src/components/vault/ImportCredentialsModal.tsx +515 -0
- package/src/components/vault/LargeTypeModal.tsx +64 -0
- package/src/components/vault/PasswordGenerator.tsx +224 -0
- package/src/components/vault/TOTPDisplay.tsx +123 -0
- package/src/components/vault/VaultSidebar.tsx +413 -0
- package/src/components/vault/types.ts +54 -0
- package/src/context/AuthContext.tsx +337 -0
- package/src/context/PriceContext.tsx +113 -0
- package/src/context/ThemeContext.tsx +164 -0
- package/src/context/WebSocketContext.tsx +269 -0
- package/src/context/WorkspaceContext.tsx +668 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useAgentActions.ts +368 -0
- package/src/hooks/useBalance.ts +103 -0
- package/src/hooks/useBalances.ts +129 -0
- package/src/instrumentation.ts +12 -0
- package/src/lib/api.ts +449 -0
- package/src/lib/app-loader.ts +148 -0
- package/src/lib/app-registry.ts +178 -0
- package/src/lib/app-sdk.ts +157 -0
- package/src/lib/audit-console-adapter.ts +151 -0
- package/src/lib/auth-client.ts +75 -0
- package/src/lib/config.ts +74 -0
- package/src/lib/crypto.ts +112 -0
- package/src/lib/db.ts +21 -0
- package/src/lib/docs.ts +390 -0
- package/src/lib/events.ts +361 -0
- package/src/lib/pino.ts +24 -0
- package/src/lib/theme-handlers.ts +168 -0
- package/src/lib/theme.ts +351 -0
- package/src/lib/tokenData.ts +378 -0
- package/src/lib/vault-crypto.ts +129 -0
- package/src/lib/websocket-server.ts +302 -0
- package/src/lib/websocket-setup.ts +79 -0
- package/src/lib/wordlist.ts +2050 -0
- package/src/lib/workspace-handlers.ts +285 -0
- package/start.sh +80 -0
- package/tailwind.config.ts +99 -0
- package/tsconfig.json +42 -0
|
@@ -0,0 +1,754 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React, { useState, useEffect, useCallback, useMemo, useRef } from 'react';
|
|
4
|
+
import { Menu } from 'lucide-react';
|
|
5
|
+
import { useAuth } from '@/context/AuthContext';
|
|
6
|
+
import { api, Api, getWalletBaseUrl } from '@/lib/api';
|
|
7
|
+
import { encryptPassword } from '@/lib/crypto';
|
|
8
|
+
import { Modal, TextInput, Button, Drawer, FilterDropdown } from '@/components/design-system';
|
|
9
|
+
import { VaultSidebar } from './VaultSidebar';
|
|
10
|
+
import { CredentialList } from './CredentialList';
|
|
11
|
+
import { CredentialDetail } from './CredentialDetail';
|
|
12
|
+
import { CredentialEmpty } from './CredentialEmpty';
|
|
13
|
+
import { CredentialForm } from './CredentialForm';
|
|
14
|
+
import { ImportCredentialsModal } from './ImportCredentialsModal';
|
|
15
|
+
import { PasswordGenerator } from './PasswordGenerator';
|
|
16
|
+
import { AuditConsole } from './AuditConsole';
|
|
17
|
+
import { ApiKeysConsole } from './ApiKeysConsole';
|
|
18
|
+
import { HumanActionBar } from '@/components/HumanActionBar';
|
|
19
|
+
import { useAgentActions } from '@/hooks/useAgentActions';
|
|
20
|
+
import { useWebSocket } from '@/context/WebSocketContext';
|
|
21
|
+
import { WALLET_EVENTS, type WalletEvent, type CredentialChangedData } from '@/lib/events';
|
|
22
|
+
import type { CredentialMeta, VaultInfo, VaultFilters } from './types';
|
|
23
|
+
|
|
24
|
+
interface CredentialVaultProps {
|
|
25
|
+
onLock: () => void;
|
|
26
|
+
onSettings?: () => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type ViewportMode = 'desktop' | 'tablet' | 'mobile';
|
|
30
|
+
type VaultSurface = 'credentials' | 'audit' | 'apiKeys';
|
|
31
|
+
|
|
32
|
+
const DEFAULT_FILTERS: VaultFilters = {
|
|
33
|
+
vaultId: null,
|
|
34
|
+
category: 'all',
|
|
35
|
+
tag: null,
|
|
36
|
+
search: '',
|
|
37
|
+
favoritesOnly: false,
|
|
38
|
+
lifecycle: 'active',
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const VAULT_MODE_OPTIONS: { value: 'linked' | 'independent'; label: string }[] = [
|
|
42
|
+
{ value: 'linked', label: 'Linked (primary unlock)' },
|
|
43
|
+
{ value: 'independent', label: 'Independent (separate password)' },
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
function getViewportMode(width: number): ViewportMode {
|
|
47
|
+
if (width < 768) return 'mobile';
|
|
48
|
+
if (width < 1024) return 'tablet';
|
|
49
|
+
return 'desktop';
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const CredentialVault: React.FC<CredentialVaultProps> = ({ onLock, onSettings }) => {
|
|
53
|
+
const { clearToken } = useAuth();
|
|
54
|
+
const { subscribe } = useWebSocket();
|
|
55
|
+
|
|
56
|
+
// Core state
|
|
57
|
+
const [credentials, setCredentials] = useState<CredentialMeta[]>([]);
|
|
58
|
+
const [vaults, setVaults] = useState<VaultInfo[]>([]);
|
|
59
|
+
const [selectedId, setSelectedId] = useState<string | null>(null);
|
|
60
|
+
const [filters, setFilters] = useState<VaultFilters>(DEFAULT_FILTERS);
|
|
61
|
+
const [loading, setLoading] = useState(true);
|
|
62
|
+
const [surface, setSurface] = useState<VaultSurface>('credentials');
|
|
63
|
+
|
|
64
|
+
// Viewport + mobile interactions
|
|
65
|
+
const [viewportMode, setViewportMode] = useState<ViewportMode>(() => {
|
|
66
|
+
if (typeof window === 'undefined') return 'desktop';
|
|
67
|
+
return getViewportMode(window.innerWidth);
|
|
68
|
+
});
|
|
69
|
+
const [mobileSidebarOpen, setMobileSidebarOpen] = useState(false);
|
|
70
|
+
const [mobileDetailOpen, setMobileDetailOpen] = useState(false);
|
|
71
|
+
|
|
72
|
+
// Modal flags
|
|
73
|
+
const [showCreateForm, setShowCreateForm] = useState(false);
|
|
74
|
+
const [editCredentialId, setEditCredentialId] = useState<string | null>(null);
|
|
75
|
+
const [showCreateVault, setShowCreateVault] = useState(false);
|
|
76
|
+
const [newVaultName, setNewVaultName] = useState('');
|
|
77
|
+
const [newVaultMode, setNewVaultMode] = useState<'linked' | 'independent'>('linked');
|
|
78
|
+
const [newVaultPassword, setNewVaultPassword] = useState('');
|
|
79
|
+
const [creatingVault, setCreatingVault] = useState(false);
|
|
80
|
+
const [showImportModal, setShowImportModal] = useState(false);
|
|
81
|
+
const [showGenerator, setShowGenerator] = useState(false);
|
|
82
|
+
|
|
83
|
+
// Agent actions (approvals + notifications)
|
|
84
|
+
const {
|
|
85
|
+
requests,
|
|
86
|
+
notifications,
|
|
87
|
+
dismissNotification,
|
|
88
|
+
resolveAction,
|
|
89
|
+
revokeToken = async () => false,
|
|
90
|
+
activeTokens = [],
|
|
91
|
+
inactiveTokens = [],
|
|
92
|
+
actionLoading,
|
|
93
|
+
} = useAgentActions({ autoFetch: true });
|
|
94
|
+
|
|
95
|
+
// Refs for keyboard navigation
|
|
96
|
+
const searchRef = useRef<HTMLInputElement>(null);
|
|
97
|
+
const refreshTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
98
|
+
|
|
99
|
+
const isMobile = viewportMode === 'mobile';
|
|
100
|
+
const isTablet = viewportMode === 'tablet';
|
|
101
|
+
|
|
102
|
+
// Fetch data
|
|
103
|
+
const fetchData = useCallback(async () => {
|
|
104
|
+
try {
|
|
105
|
+
const [credRes, vaultRes] = await Promise.all([
|
|
106
|
+
api.get<{ success: boolean; credentials: CredentialMeta[] }>(Api.Wallet, '/credentials', {
|
|
107
|
+
location: filters.lifecycle,
|
|
108
|
+
}),
|
|
109
|
+
api.get<{ success: boolean; vaults: VaultInfo[] }>(Api.Wallet, '/vaults/credential'),
|
|
110
|
+
]);
|
|
111
|
+
if (credRes.success) setCredentials(credRes.credentials);
|
|
112
|
+
if (vaultRes.success) setVaults(vaultRes.vaults);
|
|
113
|
+
} catch (err) {
|
|
114
|
+
console.error('[CredentialVault] fetch error:', err);
|
|
115
|
+
} finally {
|
|
116
|
+
setLoading(false);
|
|
117
|
+
}
|
|
118
|
+
}, [filters.lifecycle]);
|
|
119
|
+
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
fetchData();
|
|
122
|
+
}, [fetchData]);
|
|
123
|
+
|
|
124
|
+
const scheduleRealtimeRefresh = useCallback(() => {
|
|
125
|
+
if (refreshTimerRef.current) return;
|
|
126
|
+
refreshTimerRef.current = setTimeout(() => {
|
|
127
|
+
refreshTimerRef.current = null;
|
|
128
|
+
void fetchData();
|
|
129
|
+
}, 120);
|
|
130
|
+
}, [fetchData]);
|
|
131
|
+
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
const unsubscribe = subscribe(WALLET_EVENTS.CREDENTIAL_CHANGED, (event) => {
|
|
134
|
+
const data = (event as WalletEvent).data as CredentialChangedData;
|
|
135
|
+
if (!data?.credentialId) return;
|
|
136
|
+
scheduleRealtimeRefresh();
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
return () => {
|
|
140
|
+
unsubscribe();
|
|
141
|
+
if (refreshTimerRef.current) {
|
|
142
|
+
clearTimeout(refreshTimerRef.current);
|
|
143
|
+
refreshTimerRef.current = null;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}, [scheduleRealtimeRefresh, subscribe]);
|
|
147
|
+
|
|
148
|
+
useEffect(() => {
|
|
149
|
+
if (selectedId && !credentials.some((credential) => credential.id === selectedId)) {
|
|
150
|
+
setSelectedId(null);
|
|
151
|
+
setMobileDetailOpen(false);
|
|
152
|
+
}
|
|
153
|
+
}, [credentials, selectedId]);
|
|
154
|
+
|
|
155
|
+
useEffect(() => {
|
|
156
|
+
const handleResize = () => setViewportMode(getViewportMode(window.innerWidth));
|
|
157
|
+
handleResize();
|
|
158
|
+
window.addEventListener('resize', handleResize);
|
|
159
|
+
return () => window.removeEventListener('resize', handleResize);
|
|
160
|
+
}, []);
|
|
161
|
+
|
|
162
|
+
useEffect(() => {
|
|
163
|
+
if (!isMobile) {
|
|
164
|
+
setMobileSidebarOpen(false);
|
|
165
|
+
setMobileDetailOpen(false);
|
|
166
|
+
}
|
|
167
|
+
}, [isMobile]);
|
|
168
|
+
|
|
169
|
+
// Derived data
|
|
170
|
+
const selectedVaultGroupIds = useMemo<Set<string> | null>(() => {
|
|
171
|
+
if (!filters.vaultId) return null;
|
|
172
|
+
const selectedVault = vaults.find((v) => v.id === filters.vaultId);
|
|
173
|
+
if (!selectedVault) return new Set([filters.vaultId]);
|
|
174
|
+
if (selectedVault.mode === 'independent') return new Set([selectedVault.id]);
|
|
175
|
+
|
|
176
|
+
const rootId = selectedVault.mode === 'linked'
|
|
177
|
+
? (selectedVault.linkedTo || selectedVault.id)
|
|
178
|
+
: selectedVault.id;
|
|
179
|
+
const linkedGroup = vaults
|
|
180
|
+
.filter((v) => v.id === rootId || (v.mode === 'linked' && v.linkedTo === rootId))
|
|
181
|
+
.map((v) => v.id);
|
|
182
|
+
return new Set(linkedGroup.length > 0 ? linkedGroup : [selectedVault.id]);
|
|
183
|
+
}, [filters.vaultId, vaults]);
|
|
184
|
+
|
|
185
|
+
const applyVaultGroupFilter = useCallback((items: CredentialMeta[]): CredentialMeta[] => {
|
|
186
|
+
if (!selectedVaultGroupIds) return items;
|
|
187
|
+
return items.filter((credential) => selectedVaultGroupIds.has(credential.vaultId));
|
|
188
|
+
}, [selectedVaultGroupIds]);
|
|
189
|
+
|
|
190
|
+
const filteredCredentials = useMemo(() => {
|
|
191
|
+
let result = applyVaultGroupFilter(credentials);
|
|
192
|
+
|
|
193
|
+
// Category filter
|
|
194
|
+
if (filters.category !== 'all') {
|
|
195
|
+
result = result.filter((c) => c.type === filters.category);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Favorites
|
|
199
|
+
if (filters.favoritesOnly) {
|
|
200
|
+
result = result.filter((c) => c.meta.favorite);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Tag filter
|
|
204
|
+
if (filters.tag) {
|
|
205
|
+
const tag = filters.tag;
|
|
206
|
+
result = result.filter((c) => c.meta.tags?.includes(tag));
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Search
|
|
210
|
+
if (filters.search) {
|
|
211
|
+
const q = filters.search.toLowerCase();
|
|
212
|
+
result = result.filter(
|
|
213
|
+
(c) =>
|
|
214
|
+
c.name.toLowerCase().includes(q) ||
|
|
215
|
+
c.meta.url?.toLowerCase().includes(q) ||
|
|
216
|
+
c.meta.username?.toLowerCase().includes(q) ||
|
|
217
|
+
c.meta.tags?.some((t) => t.toLowerCase().includes(q)) ||
|
|
218
|
+
c.type.toLowerCase().includes(q),
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return result;
|
|
223
|
+
}, [credentials, filters, applyVaultGroupFilter]);
|
|
224
|
+
|
|
225
|
+
const categoryCounts = useMemo(() => {
|
|
226
|
+
// Counts apply to vault-group filtered (not category/search filtered) credentials
|
|
227
|
+
let base = applyVaultGroupFilter(credentials);
|
|
228
|
+
if (filters.tag) {
|
|
229
|
+
const tag = filters.tag;
|
|
230
|
+
base = base.filter((c) => c.meta.tags?.includes(tag));
|
|
231
|
+
}
|
|
232
|
+
if (filters.favoritesOnly) {
|
|
233
|
+
base = base.filter((c) => c.meta.favorite);
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
all: base.length,
|
|
237
|
+
login: base.filter((c) => c.type === 'login').length,
|
|
238
|
+
card: base.filter((c) => c.type === 'card').length,
|
|
239
|
+
note: base.filter((c) => c.type === 'note').length,
|
|
240
|
+
api: base.filter((c) => c.type === 'api').length,
|
|
241
|
+
apikey: base.filter((c) => c.type === 'apikey').length,
|
|
242
|
+
custom: base.filter((c) => c.type === 'custom').length,
|
|
243
|
+
passkey: base.filter((c) => c.type === 'passkey').length,
|
|
244
|
+
oauth2: base.filter((c) => c.type === 'oauth2').length,
|
|
245
|
+
ssh: base.filter((c) => c.type === 'ssh').length,
|
|
246
|
+
gpg: base.filter((c) => c.type === 'gpg').length,
|
|
247
|
+
};
|
|
248
|
+
}, [credentials, filters.tag, filters.favoritesOnly, applyVaultGroupFilter]);
|
|
249
|
+
|
|
250
|
+
const allTags = useMemo(() => {
|
|
251
|
+
const tagSet = new Set<string>();
|
|
252
|
+
credentials.forEach((c) => c.meta.tags?.forEach((t) => tagSet.add(t)));
|
|
253
|
+
return Array.from(tagSet).sort();
|
|
254
|
+
}, [credentials]);
|
|
255
|
+
|
|
256
|
+
const favoritesCount = useMemo(() => {
|
|
257
|
+
const base = applyVaultGroupFilter(credentials);
|
|
258
|
+
return base.filter((c) => c.meta.favorite).length;
|
|
259
|
+
}, [credentials, applyVaultGroupFilter]);
|
|
260
|
+
|
|
261
|
+
const selectedCredential = useMemo(
|
|
262
|
+
() => credentials.find((c) => c.id === selectedId) || null,
|
|
263
|
+
[credentials, selectedId],
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
const selectedVaultName = useMemo(() => {
|
|
267
|
+
if (!selectedCredential) return '';
|
|
268
|
+
const vault = vaults.find((v) => v.id === selectedCredential.vaultId);
|
|
269
|
+
if (vault) return vault.name || (vault.isPrimary ? 'Primary' : vault.id.slice(0, 8));
|
|
270
|
+
return selectedCredential.vaultId === 'primary'
|
|
271
|
+
? 'Primary'
|
|
272
|
+
: selectedCredential.vaultId.slice(0, 8);
|
|
273
|
+
}, [selectedCredential, vaults]);
|
|
274
|
+
|
|
275
|
+
const importVaultId = filters.vaultId || (vaults.find((v) => v.isPrimary)?.id ?? 'primary');
|
|
276
|
+
const importVaultName = useMemo(() => {
|
|
277
|
+
if (filters.vaultId) {
|
|
278
|
+
const v = vaults.find((vault) => vault.id === filters.vaultId);
|
|
279
|
+
if (v) return v.name || (v.isPrimary ? 'Primary' : v.id.slice(0, 8));
|
|
280
|
+
}
|
|
281
|
+
const primary = vaults.find((v) => v.isPrimary);
|
|
282
|
+
return primary?.name || 'Primary';
|
|
283
|
+
}, [filters.vaultId, vaults]);
|
|
284
|
+
|
|
285
|
+
const hasActiveFilters = useMemo(
|
|
286
|
+
() =>
|
|
287
|
+
filters.vaultId !== null ||
|
|
288
|
+
filters.category !== 'all' ||
|
|
289
|
+
filters.tag !== null ||
|
|
290
|
+
filters.search.trim() !== '' ||
|
|
291
|
+
filters.favoritesOnly,
|
|
292
|
+
[filters],
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
// Handlers
|
|
296
|
+
const handleFilterChange = useCallback((partial: Partial<VaultFilters>) => {
|
|
297
|
+
setFilters((prev) => ({ ...prev, ...partial }));
|
|
298
|
+
}, []);
|
|
299
|
+
|
|
300
|
+
const clearAllFilters = useCallback(() => {
|
|
301
|
+
setFilters(DEFAULT_FILTERS);
|
|
302
|
+
}, []);
|
|
303
|
+
|
|
304
|
+
const handleLock = useCallback(() => {
|
|
305
|
+
clearToken();
|
|
306
|
+
onLock();
|
|
307
|
+
}, [clearToken, onLock]);
|
|
308
|
+
|
|
309
|
+
const handleDelete = useCallback(async () => {
|
|
310
|
+
if (!selectedId) return;
|
|
311
|
+
try {
|
|
312
|
+
const location = encodeURIComponent(filters.lifecycle);
|
|
313
|
+
await api.delete(Api.Wallet, `/credentials/${selectedId}?location=${location}`);
|
|
314
|
+
setSelectedId(null);
|
|
315
|
+
setMobileDetailOpen(false);
|
|
316
|
+
fetchData();
|
|
317
|
+
} catch (err) {
|
|
318
|
+
console.error('[CredentialVault] delete error:', err);
|
|
319
|
+
}
|
|
320
|
+
}, [selectedId, filters.lifecycle, fetchData]);
|
|
321
|
+
|
|
322
|
+
const handleRestore = useCallback(async () => {
|
|
323
|
+
if (!selectedId || filters.lifecycle === 'active') return;
|
|
324
|
+
try {
|
|
325
|
+
await api.post(Api.Wallet, `/credentials/${selectedId}/restore`, { from: filters.lifecycle });
|
|
326
|
+
setSelectedId(null);
|
|
327
|
+
setMobileDetailOpen(false);
|
|
328
|
+
fetchData();
|
|
329
|
+
} catch (err) {
|
|
330
|
+
console.error('[CredentialVault] restore error:', err);
|
|
331
|
+
}
|
|
332
|
+
}, [selectedId, filters.lifecycle, fetchData]);
|
|
333
|
+
|
|
334
|
+
const handleCreateVault = useCallback(async () => {
|
|
335
|
+
if (!newVaultName.trim()) return;
|
|
336
|
+
if (newVaultMode === 'independent' && newVaultPassword.length < 8) return;
|
|
337
|
+
|
|
338
|
+
setCreatingVault(true);
|
|
339
|
+
try {
|
|
340
|
+
const payload: Record<string, unknown> = {
|
|
341
|
+
name: newVaultName.trim(),
|
|
342
|
+
mode: newVaultMode,
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
if (newVaultMode === 'independent') {
|
|
346
|
+
const connectRes = await api.get<{ publicKey: string }>(Api.Wallet, '/auth/connect');
|
|
347
|
+
payload.encrypted = await encryptPassword(newVaultPassword, connectRes.publicKey);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
await api.post(Api.Wallet, '/vaults/credential', payload);
|
|
351
|
+
setNewVaultName('');
|
|
352
|
+
setNewVaultMode('linked');
|
|
353
|
+
setNewVaultPassword('');
|
|
354
|
+
setShowCreateVault(false);
|
|
355
|
+
fetchData();
|
|
356
|
+
} catch (err) {
|
|
357
|
+
console.error('[CredentialVault] create vault error:', err);
|
|
358
|
+
} finally {
|
|
359
|
+
setCreatingVault(false);
|
|
360
|
+
}
|
|
361
|
+
}, [newVaultName, newVaultMode, newVaultPassword, fetchData]);
|
|
362
|
+
|
|
363
|
+
const handleFormSaved = useCallback(() => {
|
|
364
|
+
setShowCreateForm(false);
|
|
365
|
+
setEditCredentialId(null);
|
|
366
|
+
fetchData();
|
|
367
|
+
}, [fetchData]);
|
|
368
|
+
|
|
369
|
+
const handleSelectCredential = useCallback(
|
|
370
|
+
(id: string) => {
|
|
371
|
+
setSelectedId(id);
|
|
372
|
+
if (isMobile) {
|
|
373
|
+
setMobileDetailOpen(true);
|
|
374
|
+
}
|
|
375
|
+
},
|
|
376
|
+
[isMobile],
|
|
377
|
+
);
|
|
378
|
+
|
|
379
|
+
// Keyboard shortcuts
|
|
380
|
+
useEffect(() => {
|
|
381
|
+
const handleKeyDown = (e: KeyboardEvent) => {
|
|
382
|
+
// Don't intercept when typing in inputs (unless it's our shortcuts)
|
|
383
|
+
const target = e.target as HTMLElement;
|
|
384
|
+
const isInput = target.tagName === 'INPUT' || target.tagName === 'TEXTAREA';
|
|
385
|
+
|
|
386
|
+
// Cmd+K or / → focus search
|
|
387
|
+
if ((e.metaKey && e.key === 'k') || (!isInput && e.key === '/')) {
|
|
388
|
+
e.preventDefault();
|
|
389
|
+
searchRef.current?.focus();
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// Cmd+N → new credential
|
|
394
|
+
if (e.metaKey && e.key === 'n') {
|
|
395
|
+
e.preventDefault();
|
|
396
|
+
setShowCreateForm(true);
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// Arrow navigation in list (only when not in input)
|
|
401
|
+
if (!isInput && (e.key === 'ArrowDown' || e.key === 'ArrowUp')) {
|
|
402
|
+
e.preventDefault();
|
|
403
|
+
const currentIndex = filteredCredentials.findIndex((c) => c.id === selectedId);
|
|
404
|
+
if (e.key === 'ArrowDown') {
|
|
405
|
+
const next = currentIndex + 1;
|
|
406
|
+
if (next < filteredCredentials.length) {
|
|
407
|
+
setSelectedId(filteredCredentials[next].id);
|
|
408
|
+
}
|
|
409
|
+
} else {
|
|
410
|
+
const prev = currentIndex - 1;
|
|
411
|
+
if (prev >= 0) {
|
|
412
|
+
setSelectedId(filteredCredentials[prev].id);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// Enter → select first item if none selected; on mobile this opens detail
|
|
418
|
+
if (!isInput && e.key === 'Enter' && filteredCredentials.length > 0) {
|
|
419
|
+
e.preventDefault();
|
|
420
|
+
const nextId = selectedId ?? filteredCredentials[0].id;
|
|
421
|
+
setSelectedId(nextId);
|
|
422
|
+
if (isMobile) {
|
|
423
|
+
setMobileDetailOpen(true);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
window.addEventListener('keydown', handleKeyDown);
|
|
429
|
+
return () => window.removeEventListener('keydown', handleKeyDown);
|
|
430
|
+
}, [filteredCredentials, selectedId, isMobile]);
|
|
431
|
+
|
|
432
|
+
if (loading) {
|
|
433
|
+
return (
|
|
434
|
+
<div className="h-screen w-screen flex items-center justify-center bg-[var(--color-background,#f4f4f5)] relative">
|
|
435
|
+
<div className="fixed inset-0 pointer-events-none z-0 overflow-hidden">
|
|
436
|
+
<div className="absolute inset-0 bg-[linear-gradient(to_right,var(--color-border-muted,#e5e5e5)_1px,transparent_1px),linear-gradient(to_bottom,var(--color-border-muted,#e5e5e5)_1px,transparent_1px)] bg-[size:4rem_4rem] opacity-30" />
|
|
437
|
+
<div className="absolute inset-0 tyvek-texture opacity-40 mix-blend-multiply" />
|
|
438
|
+
</div>
|
|
439
|
+
<div className="flex flex-col items-center relative z-10">
|
|
440
|
+
<div className="w-6 h-6 border-2 border-[var(--color-border,#d4d4d8)] border-t-[var(--color-text,#0a0a0a)] animate-spin" />
|
|
441
|
+
<div className="mt-4 font-mono text-[10px] text-[var(--color-text-muted,#6b7280)] tracking-widest">
|
|
442
|
+
LOADING VAULT
|
|
443
|
+
</div>
|
|
444
|
+
</div>
|
|
445
|
+
</div>
|
|
446
|
+
);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
return (
|
|
450
|
+
<div className="relative h-screen w-screen overflow-hidden flex flex-col bg-[var(--color-background,#f4f4f5)]">
|
|
451
|
+
{/* Background — sterile tyvek field (matches /app) */}
|
|
452
|
+
<div className="fixed inset-0 pointer-events-none z-0 overflow-hidden">
|
|
453
|
+
<div className="absolute inset-0 bg-[linear-gradient(to_right,var(--color-border-muted,#e5e5e5)_1px,transparent_1px),linear-gradient(to_bottom,var(--color-border-muted,#e5e5e5)_1px,transparent_1px)] bg-[size:4rem_4rem] opacity-30" />
|
|
454
|
+
<div className="absolute inset-0 tyvek-texture opacity-40 mix-blend-multiply" />
|
|
455
|
+
<div className="absolute top-[5%] left-[30%] opacity-[0.03] select-none">
|
|
456
|
+
<div className="text-[15vw] font-black leading-none text-[var(--color-text,#0a0a0a)] font-mono tracking-tighter">AURA</div>
|
|
457
|
+
</div>
|
|
458
|
+
<div className="absolute bottom-[5%] right-[5%] opacity-[0.03] select-none">
|
|
459
|
+
<div className="text-[12vw] font-black leading-none text-[var(--color-text,#0a0a0a)] font-mono tracking-tighter text-right">VAULT</div>
|
|
460
|
+
</div>
|
|
461
|
+
<div className="absolute top-10 left-[200px] w-24 h-24 border-l-4 border-t-4 border-[var(--color-text,#0a0a0a)] opacity-10">
|
|
462
|
+
<div className="absolute top-2 left-2 w-3 h-3 bg-[var(--color-text,#0a0a0a)]" />
|
|
463
|
+
</div>
|
|
464
|
+
<div className="absolute bottom-10 right-10 w-24 h-24 border-r-4 border-b-4 border-[var(--color-text,#0a0a0a)] opacity-10 flex items-end justify-end">
|
|
465
|
+
<div className="absolute bottom-2 right-2 w-3 h-3 bg-[var(--color-text,#0a0a0a)]" />
|
|
466
|
+
</div>
|
|
467
|
+
</div>
|
|
468
|
+
|
|
469
|
+
{/* Main content area */}
|
|
470
|
+
<div className="flex-1 flex overflow-hidden">
|
|
471
|
+
{/* Desktop / tablet sidebar */}
|
|
472
|
+
{!isMobile && (
|
|
473
|
+
<VaultSidebar
|
|
474
|
+
vaults={vaults}
|
|
475
|
+
filters={filters}
|
|
476
|
+
categoryCounts={categoryCounts}
|
|
477
|
+
tags={allTags}
|
|
478
|
+
favoritesCount={favoritesCount}
|
|
479
|
+
onFilterChange={handleFilterChange}
|
|
480
|
+
onLock={handleLock}
|
|
481
|
+
onCreateCredential={() => setShowCreateForm(true)}
|
|
482
|
+
onCreateVault={() => setShowCreateVault(true)}
|
|
483
|
+
onImport={() => setShowImportModal(true)}
|
|
484
|
+
mode={isTablet ? 'tablet' : 'desktop'}
|
|
485
|
+
notifications={notifications}
|
|
486
|
+
onDismissNotification={dismissNotification}
|
|
487
|
+
pendingActionCount={requests.filter(r => r.status === 'pending' && r.type !== 'notify').length}
|
|
488
|
+
surface={surface}
|
|
489
|
+
onSurfaceChange={setSurface}
|
|
490
|
+
onSettings={onSettings}
|
|
491
|
+
/>
|
|
492
|
+
)}
|
|
493
|
+
|
|
494
|
+
{surface === 'audit' ? (
|
|
495
|
+
<div className="flex-1 h-full overflow-hidden">
|
|
496
|
+
<AuditConsole />
|
|
497
|
+
</div>
|
|
498
|
+
) : surface === 'apiKeys' ? (
|
|
499
|
+
<div className="flex-1 h-full overflow-hidden">
|
|
500
|
+
<ApiKeysConsole
|
|
501
|
+
requests={requests}
|
|
502
|
+
activeTokens={activeTokens}
|
|
503
|
+
inactiveTokens={inactiveTokens}
|
|
504
|
+
actionLoading={actionLoading}
|
|
505
|
+
onResolveAction={resolveAction}
|
|
506
|
+
onRevokeToken={revokeToken}
|
|
507
|
+
/>
|
|
508
|
+
</div>
|
|
509
|
+
) : (
|
|
510
|
+
<>
|
|
511
|
+
{/* Credential list */}
|
|
512
|
+
<CredentialList
|
|
513
|
+
credentials={filteredCredentials}
|
|
514
|
+
selectedId={selectedId}
|
|
515
|
+
searchQuery={filters.search}
|
|
516
|
+
onSearchChange={(search) => handleFilterChange({ search })}
|
|
517
|
+
onSelect={handleSelectCredential}
|
|
518
|
+
onAdd={() => setShowCreateForm(true)}
|
|
519
|
+
canAdd={filters.lifecycle === 'active'}
|
|
520
|
+
onOpenGenerator={() => setShowGenerator(true)}
|
|
521
|
+
onClearFilters={clearAllFilters}
|
|
522
|
+
hasActiveFilters={hasActiveFilters}
|
|
523
|
+
searchInputRef={searchRef}
|
|
524
|
+
className={
|
|
525
|
+
isMobile
|
|
526
|
+
? 'flex-1 h-full flex flex-col'
|
|
527
|
+
: isTablet
|
|
528
|
+
? 'w-[320px] h-full flex flex-col border-r border-[var(--color-border,#d4d4d8)]'
|
|
529
|
+
: 'w-[300px] h-full flex flex-col border-r border-[var(--color-border,#d4d4d8)]'
|
|
530
|
+
}
|
|
531
|
+
leadingAction={
|
|
532
|
+
isMobile ? (
|
|
533
|
+
<Button
|
|
534
|
+
variant="ghost"
|
|
535
|
+
size="sm"
|
|
536
|
+
icon={<Menu size={12} />}
|
|
537
|
+
onClick={() => setMobileSidebarOpen(true)}
|
|
538
|
+
className="!px-1.5 !h-8 !w-8"
|
|
539
|
+
aria-label="Open sidebar"
|
|
540
|
+
title="Open sidebar"
|
|
541
|
+
/>
|
|
542
|
+
) : undefined
|
|
543
|
+
}
|
|
544
|
+
/>
|
|
545
|
+
|
|
546
|
+
{/* Detail panel (desktop + tablet) */}
|
|
547
|
+
{!isMobile && (
|
|
548
|
+
<div className="flex-1 h-full overflow-hidden">
|
|
549
|
+
{selectedCredential ? (
|
|
550
|
+
<CredentialDetail
|
|
551
|
+
credential={selectedCredential}
|
|
552
|
+
vaultName={selectedVaultName}
|
|
553
|
+
lifecycle={filters.lifecycle}
|
|
554
|
+
onEdit={() => setEditCredentialId(selectedCredential.id)}
|
|
555
|
+
onDelete={handleDelete}
|
|
556
|
+
onRestore={handleRestore}
|
|
557
|
+
/>
|
|
558
|
+
) : (
|
|
559
|
+
<CredentialEmpty
|
|
560
|
+
variant={
|
|
561
|
+
filters.lifecycle !== 'active'
|
|
562
|
+
? 'empty-lifecycle'
|
|
563
|
+
: credentials.length === 0
|
|
564
|
+
? 'empty-vault'
|
|
565
|
+
: 'no-selection'
|
|
566
|
+
}
|
|
567
|
+
onAdd={filters.lifecycle === 'active' ? () => setShowCreateForm(true) : undefined}
|
|
568
|
+
/>
|
|
569
|
+
)}
|
|
570
|
+
</div>
|
|
571
|
+
)}
|
|
572
|
+
</>
|
|
573
|
+
)}
|
|
574
|
+
</div>
|
|
575
|
+
|
|
576
|
+
{/* Agent action approval footer */}
|
|
577
|
+
<HumanActionBar requests={requests} resolveAction={resolveAction} actionLoading={actionLoading} />
|
|
578
|
+
|
|
579
|
+
{/* Mobile detail drawer */}
|
|
580
|
+
{isMobile && (
|
|
581
|
+
<Drawer
|
|
582
|
+
isOpen={mobileDetailOpen && selectedCredential != null}
|
|
583
|
+
onClose={() => setMobileDetailOpen(false)}
|
|
584
|
+
title={selectedCredential?.name || 'Credential'}
|
|
585
|
+
subtitle={selectedVaultName || 'Credential_Detail'}
|
|
586
|
+
width="full"
|
|
587
|
+
>
|
|
588
|
+
{selectedCredential ? (
|
|
589
|
+
<>
|
|
590
|
+
<Button
|
|
591
|
+
variant="ghost"
|
|
592
|
+
size="sm"
|
|
593
|
+
onClick={() => setMobileDetailOpen(false)}
|
|
594
|
+
className="mb-3"
|
|
595
|
+
>
|
|
596
|
+
BACK
|
|
597
|
+
</Button>
|
|
598
|
+
<CredentialDetail
|
|
599
|
+
credential={selectedCredential}
|
|
600
|
+
vaultName={selectedVaultName}
|
|
601
|
+
lifecycle={filters.lifecycle}
|
|
602
|
+
onEdit={() => setEditCredentialId(selectedCredential.id)}
|
|
603
|
+
onDelete={handleDelete}
|
|
604
|
+
onRestore={handleRestore}
|
|
605
|
+
/>
|
|
606
|
+
</>
|
|
607
|
+
) : (
|
|
608
|
+
<CredentialEmpty
|
|
609
|
+
variant={
|
|
610
|
+
filters.lifecycle !== 'active'
|
|
611
|
+
? 'empty-lifecycle'
|
|
612
|
+
: credentials.length === 0
|
|
613
|
+
? 'empty-vault'
|
|
614
|
+
: 'no-selection'
|
|
615
|
+
}
|
|
616
|
+
onAdd={filters.lifecycle === 'active' ? () => setShowCreateForm(true) : undefined}
|
|
617
|
+
/>
|
|
618
|
+
)}
|
|
619
|
+
</Drawer>
|
|
620
|
+
)}
|
|
621
|
+
|
|
622
|
+
{/* Mobile sidebar overlay */}
|
|
623
|
+
{isMobile && mobileSidebarOpen && (
|
|
624
|
+
<div className="absolute inset-0 z-40">
|
|
625
|
+
<button
|
|
626
|
+
type="button"
|
|
627
|
+
aria-label="Close sidebar"
|
|
628
|
+
onClick={() => setMobileSidebarOpen(false)}
|
|
629
|
+
className="absolute inset-0 bg-[var(--color-text,#0a0a0a)]/20"
|
|
630
|
+
/>
|
|
631
|
+
<div className="absolute left-0 top-0 h-full">
|
|
632
|
+
<VaultSidebar
|
|
633
|
+
vaults={vaults}
|
|
634
|
+
filters={filters}
|
|
635
|
+
categoryCounts={categoryCounts}
|
|
636
|
+
tags={allTags}
|
|
637
|
+
favoritesCount={favoritesCount}
|
|
638
|
+
onFilterChange={handleFilterChange}
|
|
639
|
+
onLock={handleLock}
|
|
640
|
+
onCreateCredential={() => setShowCreateForm(true)}
|
|
641
|
+
onCreateVault={() => setShowCreateVault(true)}
|
|
642
|
+
onImport={() => setShowImportModal(true)}
|
|
643
|
+
mode="mobile"
|
|
644
|
+
onNavigate={() => setMobileSidebarOpen(false)}
|
|
645
|
+
notifications={notifications}
|
|
646
|
+
onDismissNotification={dismissNotification}
|
|
647
|
+
pendingActionCount={requests.filter(r => r.status === 'pending' && r.type !== 'notify').length}
|
|
648
|
+
surface={surface}
|
|
649
|
+
onSurfaceChange={setSurface}
|
|
650
|
+
onSettings={onSettings}
|
|
651
|
+
/>
|
|
652
|
+
</div>
|
|
653
|
+
</div>
|
|
654
|
+
)}
|
|
655
|
+
|
|
656
|
+
{/* Create / Edit credential modal */}
|
|
657
|
+
<CredentialForm
|
|
658
|
+
isOpen={showCreateForm || !!editCredentialId}
|
|
659
|
+
onClose={() => {
|
|
660
|
+
setShowCreateForm(false);
|
|
661
|
+
setEditCredentialId(null);
|
|
662
|
+
}}
|
|
663
|
+
onSaved={handleFormSaved}
|
|
664
|
+
editCredentialId={editCredentialId ?? undefined}
|
|
665
|
+
vaults={vaults}
|
|
666
|
+
/>
|
|
667
|
+
|
|
668
|
+
{/* Import credentials modal */}
|
|
669
|
+
<ImportCredentialsModal
|
|
670
|
+
isOpen={showImportModal}
|
|
671
|
+
onClose={() => setShowImportModal(false)}
|
|
672
|
+
onComplete={fetchData}
|
|
673
|
+
vaultId={importVaultId}
|
|
674
|
+
vaultName={importVaultName}
|
|
675
|
+
walletBaseUrl={getWalletBaseUrl()}
|
|
676
|
+
/>
|
|
677
|
+
|
|
678
|
+
{/* Password generator modal */}
|
|
679
|
+
<PasswordGenerator
|
|
680
|
+
isOpen={showGenerator}
|
|
681
|
+
onClose={() => setShowGenerator(false)}
|
|
682
|
+
onUse={(password) => {
|
|
683
|
+
setShowGenerator(false);
|
|
684
|
+
navigator.clipboard.writeText(password).catch(() => {});
|
|
685
|
+
}}
|
|
686
|
+
/>
|
|
687
|
+
|
|
688
|
+
{/* Create vault modal */}
|
|
689
|
+
<Modal
|
|
690
|
+
isOpen={showCreateVault}
|
|
691
|
+
onClose={() => {
|
|
692
|
+
setShowCreateVault(false);
|
|
693
|
+
setNewVaultMode('linked');
|
|
694
|
+
setNewVaultPassword('');
|
|
695
|
+
}}
|
|
696
|
+
title="New Vault"
|
|
697
|
+
subtitle="Credential_Vault"
|
|
698
|
+
size="sm"
|
|
699
|
+
contentClassName="overflow-visible"
|
|
700
|
+
>
|
|
701
|
+
<div className="space-y-4">
|
|
702
|
+
<TextInput
|
|
703
|
+
label="Vault Name"
|
|
704
|
+
placeholder="e.g. Work, Personal"
|
|
705
|
+
value={newVaultName}
|
|
706
|
+
onChange={(e) => setNewVaultName(e.target.value)}
|
|
707
|
+
autoFocus
|
|
708
|
+
/>
|
|
709
|
+
<FilterDropdown
|
|
710
|
+
label="Mode"
|
|
711
|
+
options={VAULT_MODE_OPTIONS}
|
|
712
|
+
value={newVaultMode}
|
|
713
|
+
onChange={(value) => {
|
|
714
|
+
const mode = value as 'linked' | 'independent';
|
|
715
|
+
setNewVaultMode(mode);
|
|
716
|
+
if (mode !== 'independent') setNewVaultPassword('');
|
|
717
|
+
}}
|
|
718
|
+
compact
|
|
719
|
+
/>
|
|
720
|
+
{newVaultMode === 'independent' && (
|
|
721
|
+
<TextInput
|
|
722
|
+
label="Vault Password"
|
|
723
|
+
type="password"
|
|
724
|
+
placeholder="At least 8 characters"
|
|
725
|
+
value={newVaultPassword}
|
|
726
|
+
onChange={(e) => setNewVaultPassword(e.target.value)}
|
|
727
|
+
/>
|
|
728
|
+
)}
|
|
729
|
+
<div className="flex gap-2 justify-end">
|
|
730
|
+
<Button
|
|
731
|
+
variant="secondary"
|
|
732
|
+
size="sm"
|
|
733
|
+
onClick={() => {
|
|
734
|
+
setShowCreateVault(false);
|
|
735
|
+
setNewVaultMode('linked');
|
|
736
|
+
setNewVaultPassword('');
|
|
737
|
+
}}
|
|
738
|
+
>
|
|
739
|
+
CANCEL
|
|
740
|
+
</Button>
|
|
741
|
+
<Button
|
|
742
|
+
size="sm"
|
|
743
|
+
onClick={handleCreateVault}
|
|
744
|
+
loading={creatingVault}
|
|
745
|
+
disabled={!newVaultName.trim() || (newVaultMode === 'independent' && newVaultPassword.length < 8)}
|
|
746
|
+
>
|
|
747
|
+
CREATE
|
|
748
|
+
</Button>
|
|
749
|
+
</div>
|
|
750
|
+
</div>
|
|
751
|
+
</Modal>
|
|
752
|
+
</div>
|
|
753
|
+
);
|
|
754
|
+
};
|