@marinoscar/vault-web 0.0.0-bootstrap → 0.1.0-next.3
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/CHANGELOG.md +32 -0
- package/LICENSE +21 -0
- package/README.md +99 -0
- package/dist/agent/headless/agentActivity.d.ts +53 -0
- package/dist/agent/headless/agentActivity.js +58 -0
- package/dist/agent/headless/index.d.ts +2 -0
- package/dist/agent/headless/index.js +3 -0
- package/dist/agent/headless/useAgentActivity.d.ts +9 -0
- package/dist/agent/headless/useAgentActivity.js +30 -0
- package/dist/agent/ui/components/AgentActivityTable.d.ts +25 -0
- package/dist/agent/ui/components/AgentActivityTable.js +114 -0
- package/dist/agent/ui/index.d.ts +3 -0
- package/dist/agent/ui/index.js +4 -0
- package/dist/agent/ui/pages/AgentAccessSettingsPage.d.ts +7 -0
- package/dist/agent/ui/pages/AgentAccessSettingsPage.js +70 -0
- package/dist/agent/ui/pages/AgentActivityPage.d.ts +6 -0
- package/dist/agent/ui/pages/AgentActivityPage.js +61 -0
- package/dist/backups/headless/backupContents.d.ts +69 -0
- package/dist/backups/headless/backupContents.js +133 -0
- package/dist/backups/headless/backupPassword.d.ts +34 -0
- package/dist/backups/headless/backupPassword.js +80 -0
- package/dist/backups/headless/backupSchedule.d.ts +56 -0
- package/dist/backups/headless/backupSchedule.js +189 -0
- package/dist/backups/headless/index.d.ts +4 -0
- package/dist/backups/headless/index.js +5 -0
- package/dist/backups/headless/useBackupRunHistory.d.ts +36 -0
- package/dist/backups/headless/useBackupRunHistory.js +83 -0
- package/dist/backups/ui/components/AdminBackupDownloadDialog.d.ts +20 -0
- package/dist/backups/ui/components/AdminBackupDownloadDialog.js +65 -0
- package/dist/backups/ui/components/BackupContentsGroup.d.ts +17 -0
- package/dist/backups/ui/components/BackupContentsGroup.js +21 -0
- package/dist/backups/ui/components/BackupPasswordFields.d.ts +18 -0
- package/dist/backups/ui/components/BackupPasswordFields.js +40 -0
- package/dist/backups/ui/components/BackupRunsTable.d.ts +44 -0
- package/dist/backups/ui/components/BackupRunsTable.js +61 -0
- package/dist/backups/ui/components/DataBackup.d.ts +14 -0
- package/dist/backups/ui/components/DataBackup.js +169 -0
- package/dist/backups/ui/components/ScheduledBackups.d.ts +13 -0
- package/dist/backups/ui/components/ScheduledBackups.js +304 -0
- package/dist/backups/ui/index.d.ts +8 -0
- package/dist/backups/ui/index.js +9 -0
- package/dist/backups/ui/pages/BackupSettingsPage.d.ts +8 -0
- package/dist/backups/ui/pages/BackupSettingsPage.js +19 -0
- package/dist/backups/ui/pages/MyBackupsPage.d.ts +8 -0
- package/dist/backups/ui/pages/MyBackupsPage.js +19 -0
- package/dist/brand/BrandLockup.d.ts +14 -0
- package/dist/brand/BrandLockup.js +13 -0
- package/dist/brand/assets/vault-mark.png +0 -0
- package/dist/brand/contrast.d.ts +8 -0
- package/dist/brand/contrast.js +21 -0
- package/dist/brand/index.d.ts +7 -0
- package/dist/brand/index.js +8 -0
- package/dist/brand/mark.d.ts +6 -0
- package/dist/brand/mark.js +7 -0
- package/dist/brand/theme.d.ts +25 -0
- package/dist/brand/theme.js +84 -0
- package/dist/brand/tokens.d.ts +52 -0
- package/dist/brand/tokens.js +54 -0
- package/dist/cards/headless/cardExpiry.d.ts +57 -0
- package/dist/cards/headless/cardExpiry.js +138 -0
- package/dist/cards/headless/cardFormat.d.ts +60 -0
- package/dist/cards/headless/cardFormat.js +135 -0
- package/dist/cards/headless/cardImage.d.ts +293 -0
- package/dist/cards/headless/cardImage.js +518 -0
- package/dist/cards/headless/index.d.ts +6 -0
- package/dist/cards/headless/index.js +7 -0
- package/dist/cards/headless/useCardImport.d.ts +137 -0
- package/dist/cards/headless/useCardImport.js +391 -0
- package/dist/cards/headless/useCardRenewal.d.ts +102 -0
- package/dist/cards/headless/useCardRenewal.js +305 -0
- package/dist/cards/headless/useCards.d.ts +80 -0
- package/dist/cards/headless/useCards.js +114 -0
- package/dist/cards/ui/components/AiEgressNotice.d.ts +13 -0
- package/dist/cards/ui/components/AiEgressNotice.js +18 -0
- package/dist/cards/ui/components/CardCaptureStep.d.ts +59 -0
- package/dist/cards/ui/components/CardCaptureStep.js +96 -0
- package/dist/cards/ui/components/CardCropAdjuster.d.ts +43 -0
- package/dist/cards/ui/components/CardCropAdjuster.js +215 -0
- package/dist/cards/ui/components/CardCropReview.d.ts +51 -0
- package/dist/cards/ui/components/CardCropReview.js +88 -0
- package/dist/cards/ui/components/CardExpiryBadge.d.ts +8 -0
- package/dist/cards/ui/components/CardExpiryBadge.js +43 -0
- package/dist/cards/ui/components/CardFieldDiff.d.ts +37 -0
- package/dist/cards/ui/components/CardFieldDiff.js +66 -0
- package/dist/cards/ui/components/CardFlowStepper.d.ts +24 -0
- package/dist/cards/ui/components/CardFlowStepper.js +23 -0
- package/dist/cards/ui/components/CardReviewForm.d.ts +44 -0
- package/dist/cards/ui/components/CardReviewForm.js +102 -0
- package/dist/cards/ui/components/CardScanModelSection.d.ts +23 -0
- package/dist/cards/ui/components/CardScanModelSection.js +81 -0
- package/dist/cards/ui/components/CardTile.d.ts +40 -0
- package/dist/cards/ui/components/CardTile.js +94 -0
- package/dist/cards/ui/index.d.ts +15 -0
- package/dist/cards/ui/index.js +16 -0
- package/dist/cards/ui/pages/AiSettingsPage.d.ts +12 -0
- package/dist/cards/ui/pages/AiSettingsPage.js +24 -0
- package/dist/cards/ui/pages/CardsPage.d.ts +26 -0
- package/dist/cards/ui/pages/CardsPage.js +160 -0
- package/dist/cards/ui/pages/ImportCardPage.d.ts +24 -0
- package/dist/cards/ui/pages/ImportCardPage.js +343 -0
- package/dist/cards/ui/pages/RenewCardPage.d.ts +35 -0
- package/dist/cards/ui/pages/RenewCardPage.js +350 -0
- package/dist/core/headless/api.d.ts +272 -0
- package/dist/core/headless/api.js +425 -0
- package/dist/core/headless/cardScanAvailability.d.ts +20 -0
- package/dist/core/headless/cardScanAvailability.js +27 -0
- package/dist/core/headless/clipboard.d.ts +60 -0
- package/dist/core/headless/clipboard.js +101 -0
- package/dist/core/headless/http.d.ts +41 -0
- package/dist/core/headless/http.js +50 -0
- package/dist/core/headless/index.d.ts +12 -0
- package/dist/core/headless/index.js +13 -0
- package/dist/core/headless/relativeTime.d.ts +7 -0
- package/dist/core/headless/relativeTime.js +28 -0
- package/dist/core/headless/saveBlob.d.ts +6 -0
- package/dist/core/headless/saveBlob.js +21 -0
- package/dist/core/headless/types.d.ts +441 -0
- package/dist/core/headless/types.js +49 -0
- package/dist/core/headless/useAiStatus.d.ts +41 -0
- package/dist/core/headless/useAiStatus.js +42 -0
- package/dist/core/headless/useCopyToClipboard.d.ts +20 -0
- package/dist/core/headless/useCopyToClipboard.js +52 -0
- package/dist/core/headless/useDashboardResource.d.ts +22 -0
- package/dist/core/headless/useDashboardResource.js +52 -0
- package/dist/core/headless/useSystemSettings.d.ts +17 -0
- package/dist/core/headless/useSystemSettings.js +106 -0
- package/dist/core/headless/useUserSettings.d.ts +13 -0
- package/dist/core/headless/useUserSettings.js +103 -0
- package/dist/core/ui/ErrorBoundary.d.ts +15 -0
- package/dist/core/ui/ErrorBoundary.js +27 -0
- package/dist/core/ui/LoadingSpinner.d.ts +6 -0
- package/dist/core/ui/LoadingSpinner.js +14 -0
- package/dist/core/ui/SettingsPageFrame.d.ts +19 -0
- package/dist/core/ui/SettingsPageFrame.js +12 -0
- package/dist/core/ui/StorageSettingsLink.d.ts +19 -0
- package/dist/core/ui/StorageSettingsLink.js +26 -0
- package/dist/core/ui/index.d.ts +4 -0
- package/dist/core/ui/index.js +5 -0
- package/dist/home/headless/homeLinks.d.ts +24 -0
- package/dist/home/headless/homeLinks.js +24 -0
- package/dist/home/headless/index.d.ts +1 -0
- package/dist/home/headless/index.js +2 -0
- package/dist/home/ui/components/BackupStatusPanel.d.ts +28 -0
- package/dist/home/ui/components/BackupStatusPanel.js +99 -0
- package/dist/home/ui/components/DashboardPanel.d.ts +33 -0
- package/dist/home/ui/components/DashboardPanel.js +21 -0
- package/dist/home/ui/components/ExpiringCardsPanel.d.ts +31 -0
- package/dist/home/ui/components/ExpiringCardsPanel.js +35 -0
- package/dist/home/ui/components/FirstRunPanel.d.ts +7 -0
- package/dist/home/ui/components/FirstRunPanel.js +21 -0
- package/dist/home/ui/components/QuickActions.d.ts +14 -0
- package/dist/home/ui/components/QuickActions.js +40 -0
- package/dist/home/ui/components/RecentSecretsPanel.d.ts +19 -0
- package/dist/home/ui/components/RecentSecretsPanel.js +20 -0
- package/dist/home/ui/components/StatsRow.d.ts +19 -0
- package/dist/home/ui/components/StatsRow.js +46 -0
- package/dist/home/ui/components/WelcomeHeader.d.ts +11 -0
- package/dist/home/ui/components/WelcomeHeader.js +15 -0
- package/dist/home/ui/index.d.ts +9 -0
- package/dist/home/ui/index.js +10 -0
- package/dist/home/ui/pages/HomePage.d.ts +14 -0
- package/dist/home/ui/pages/HomePage.js +121 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/media/headless/index.d.ts +2 -0
- package/dist/media/headless/index.js +3 -0
- package/dist/media/headless/useMediaFiles.d.ts +20 -0
- package/dist/media/headless/useMediaFiles.js +82 -0
- package/dist/media/headless/useMediaFolders.d.ts +22 -0
- package/dist/media/headless/useMediaFolders.js +81 -0
- package/dist/media/ui/components/FolderList.d.ts +19 -0
- package/dist/media/ui/components/FolderList.js +36 -0
- package/dist/media/ui/components/MediaList.d.ts +20 -0
- package/dist/media/ui/components/MediaList.js +55 -0
- package/dist/media/ui/components/MediaPlayer.d.ts +7 -0
- package/dist/media/ui/components/MediaPlayer.js +361 -0
- package/dist/media/ui/index.d.ts +10 -0
- package/dist/media/ui/index.js +11 -0
- package/dist/media/ui/pages/CreateFolderPage.d.ts +1 -0
- package/dist/media/ui/pages/CreateFolderPage.js +39 -0
- package/dist/media/ui/pages/EditFolderPage.d.ts +1 -0
- package/dist/media/ui/pages/EditFolderPage.js +59 -0
- package/dist/media/ui/pages/MediaFolderPage.d.ts +1 -0
- package/dist/media/ui/pages/MediaFolderPage.js +68 -0
- package/dist/media/ui/pages/MediaFoldersPage.d.ts +1 -0
- package/dist/media/ui/pages/MediaFoldersPage.js +58 -0
- package/dist/media/ui/pages/MediaPlayerPage.d.ts +1 -0
- package/dist/media/ui/pages/MediaPlayerPage.js +76 -0
- package/dist/media/ui/pages/MediaUploadPage.d.ts +1 -0
- package/dist/media/ui/pages/MediaUploadPage.js +88 -0
- package/dist/media/ui/pages/RenameMediaFilePage.d.ts +1 -0
- package/dist/media/ui/pages/RenameMediaFilePage.js +63 -0
- package/dist/navigation/destinations.d.ts +50 -0
- package/dist/navigation/destinations.js +109 -0
- package/dist/navigation/index.d.ts +1 -0
- package/dist/navigation/index.js +4 -0
- package/dist/secrets/headless/fieldOptionsValidation.d.ts +45 -0
- package/dist/secrets/headless/fieldOptionsValidation.js +79 -0
- package/dist/secrets/headless/index.d.ts +6 -0
- package/dist/secrets/headless/index.js +7 -0
- package/dist/secrets/headless/secretFields.d.ts +86 -0
- package/dist/secrets/headless/secretFields.js +190 -0
- package/dist/secrets/headless/useSecretDetail.d.ts +33 -0
- package/dist/secrets/headless/useSecretDetail.js +87 -0
- package/dist/secrets/headless/useSecretTypes.d.ts +16 -0
- package/dist/secrets/headless/useSecretTypes.js +62 -0
- package/dist/secrets/headless/useSecrets.d.ts +24 -0
- package/dist/secrets/headless/useSecrets.js +59 -0
- package/dist/secrets/headless/useTotpCode.d.ts +24 -0
- package/dist/secrets/headless/useTotpCode.js +116 -0
- package/dist/secrets/ui/components/CardImages.d.ts +31 -0
- package/dist/secrets/ui/components/CardImages.js +208 -0
- package/dist/secrets/ui/components/DynamicSecretFields.d.ts +10 -0
- package/dist/secrets/ui/components/DynamicSecretFields.js +90 -0
- package/dist/secrets/ui/components/FieldDefinitionBuilder.d.ts +13 -0
- package/dist/secrets/ui/components/FieldDefinitionBuilder.js +114 -0
- package/dist/secrets/ui/components/FieldOptionsEditor.d.ts +15 -0
- package/dist/secrets/ui/components/FieldOptionsEditor.js +45 -0
- package/dist/secrets/ui/components/SecretAttachments.d.ts +15 -0
- package/dist/secrets/ui/components/SecretAttachments.js +106 -0
- package/dist/secrets/ui/components/SecretForm.d.ts +34 -0
- package/dist/secrets/ui/components/SecretForm.js +83 -0
- package/dist/secrets/ui/components/SecretFormDialog.d.ts +15 -0
- package/dist/secrets/ui/components/SecretFormDialog.js +95 -0
- package/dist/secrets/ui/components/SecretTypeFormDialog.d.ts +15 -0
- package/dist/secrets/ui/components/SecretTypeFormDialog.js +92 -0
- package/dist/secrets/ui/components/SecretTypeIcon.d.ts +8 -0
- package/dist/secrets/ui/components/SecretTypeIcon.js +16 -0
- package/dist/secrets/ui/components/SecretTypesList.d.ts +10 -0
- package/dist/secrets/ui/components/SecretTypesList.js +13 -0
- package/dist/secrets/ui/components/SecretValueField.d.ts +20 -0
- package/dist/secrets/ui/components/SecretValueField.js +52 -0
- package/dist/secrets/ui/components/SecretVersionDrawer.d.ts +22 -0
- package/dist/secrets/ui/components/SecretVersionDrawer.js +131 -0
- package/dist/secrets/ui/components/SecretsTable.d.ts +49 -0
- package/dist/secrets/ui/components/SecretsTable.js +174 -0
- package/dist/secrets/ui/components/TotpCodeCard.d.ts +8 -0
- package/dist/secrets/ui/components/TotpCodeCard.js +34 -0
- package/dist/secrets/ui/index.d.ts +20 -0
- package/dist/secrets/ui/index.js +21 -0
- package/dist/secrets/ui/pages/CreateSecretPage.d.ts +2 -0
- package/dist/secrets/ui/pages/CreateSecretPage.js +25 -0
- package/dist/secrets/ui/pages/CreateSecretTypePage.d.ts +1 -0
- package/dist/secrets/ui/pages/CreateSecretTypePage.js +62 -0
- package/dist/secrets/ui/pages/EditSecretPage.d.ts +5 -0
- package/dist/secrets/ui/pages/EditSecretPage.js +55 -0
- package/dist/secrets/ui/pages/EditSecretTypePage.d.ts +1 -0
- package/dist/secrets/ui/pages/EditSecretTypePage.js +88 -0
- package/dist/secrets/ui/pages/SecretDetailPage.d.ts +7 -0
- package/dist/secrets/ui/pages/SecretDetailPage.js +182 -0
- package/dist/secrets/ui/pages/SecretTypesPage.d.ts +1 -0
- package/dist/secrets/ui/pages/SecretTypesPage.js +23 -0
- package/dist/secrets/ui/pages/SecretsPage.d.ts +6 -0
- package/dist/secrets/ui/pages/SecretsPage.js +179 -0
- package/dist/settings/ui/components/FeatureFlagsList.d.ts +7 -0
- package/dist/settings/ui/components/FeatureFlagsList.js +46 -0
- package/dist/settings/ui/components/ImageUpload.d.ts +6 -0
- package/dist/settings/ui/components/ImageUpload.js +61 -0
- package/dist/settings/ui/components/ProfileSettings.d.ts +11 -0
- package/dist/settings/ui/components/ProfileSettings.js +55 -0
- package/dist/settings/ui/components/ThemeSettings.d.ts +7 -0
- package/dist/settings/ui/components/ThemeSettings.js +24 -0
- package/dist/settings/ui/components/UISettings.d.ts +9 -0
- package/dist/settings/ui/components/UISettings.js +25 -0
- package/dist/settings/ui/components/UserProfileCard.d.ts +1 -0
- package/dist/settings/ui/components/UserProfileCard.js +39 -0
- package/dist/settings/ui/components/UserSettingsSection.d.ts +23 -0
- package/dist/settings/ui/components/UserSettingsSection.js +29 -0
- package/dist/settings/ui/index.d.ts +10 -0
- package/dist/settings/ui/index.js +11 -0
- package/dist/settings/ui/pages/AppearanceSettingsPage.d.ts +6 -0
- package/dist/settings/ui/pages/AppearanceSettingsPage.js +11 -0
- package/dist/settings/ui/pages/GeneralSettingsPage.d.ts +9 -0
- package/dist/settings/ui/pages/GeneralSettingsPage.js +41 -0
- package/dist/settings/ui/pages/ProfileSettingsPage.d.ts +6 -0
- package/dist/settings/ui/pages/ProfileSettingsPage.js +11 -0
- package/package.json +146 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
import { useParams, useNavigate } from 'react-router-dom';
|
|
4
|
+
import { Container, Typography, Breadcrumbs, Link, Alert, CircularProgress, Box, Button, } from '@mui/material';
|
|
5
|
+
import { Download as DownloadIcon } from '@mui/icons-material';
|
|
6
|
+
import { getMediaFolder, getMediaFile, getMediaFileDownloadUrl } from '../../../core/headless/api.js';
|
|
7
|
+
import MediaPlayer from '../components/MediaPlayer.js';
|
|
8
|
+
function getPlayerMode(mimeType) {
|
|
9
|
+
if (mimeType.startsWith('video/'))
|
|
10
|
+
return 'video';
|
|
11
|
+
if (mimeType.startsWith('audio/'))
|
|
12
|
+
return 'audio';
|
|
13
|
+
return 'image';
|
|
14
|
+
}
|
|
15
|
+
export default function MediaPlayerPage() {
|
|
16
|
+
const { folderId, fileId } = useParams();
|
|
17
|
+
const navigate = useNavigate();
|
|
18
|
+
const [folderName, setFolderName] = useState('');
|
|
19
|
+
const [fileName, setFileName] = useState('');
|
|
20
|
+
const [mimeType, setMimeType] = useState('');
|
|
21
|
+
const [downloadUrl, setDownloadUrl] = useState('');
|
|
22
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
23
|
+
const [error, setError] = useState(null);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (!folderId || !fileId)
|
|
26
|
+
return;
|
|
27
|
+
setIsLoading(true);
|
|
28
|
+
Promise.all([
|
|
29
|
+
getMediaFolder(folderId),
|
|
30
|
+
getMediaFile(folderId, fileId),
|
|
31
|
+
getMediaFileDownloadUrl(folderId, fileId),
|
|
32
|
+
])
|
|
33
|
+
.then(([folder, file, { url }]) => {
|
|
34
|
+
setFolderName(folder.name);
|
|
35
|
+
setFileName(file.name);
|
|
36
|
+
setMimeType(file.mimeType);
|
|
37
|
+
setDownloadUrl(url);
|
|
38
|
+
})
|
|
39
|
+
.catch((err) => {
|
|
40
|
+
setError(err instanceof Error ? err.message : 'Failed to load media');
|
|
41
|
+
})
|
|
42
|
+
.finally(() => setIsLoading(false));
|
|
43
|
+
}, [folderId, fileId]);
|
|
44
|
+
const handleDownload = () => {
|
|
45
|
+
if (!downloadUrl)
|
|
46
|
+
return;
|
|
47
|
+
window.open(downloadUrl, '_blank', 'noopener,noreferrer');
|
|
48
|
+
};
|
|
49
|
+
if (isLoading) {
|
|
50
|
+
return (_jsx(Container, { maxWidth: "lg", sx: { py: 3, display: 'flex', justifyContent: 'center' }, children: _jsx(Box, { sx: { pt: 6 }, children: _jsx(CircularProgress, {}) }) }));
|
|
51
|
+
}
|
|
52
|
+
if (error) {
|
|
53
|
+
return (_jsx(Container, { maxWidth: "lg", sx: { py: 3 }, children: _jsx(Alert, { severity: "error", children: error }) }));
|
|
54
|
+
}
|
|
55
|
+
const mode = getPlayerMode(mimeType);
|
|
56
|
+
return (_jsxs(Container, { maxWidth: "lg", sx: { py: 2 }, children: [_jsxs(Breadcrumbs, { sx: { mb: 2 }, children: [_jsx(Link, { color: "inherit", href: "/", onClick: (e) => {
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
navigate('/');
|
|
59
|
+
}, children: "Home" }), _jsx(Link, { color: "inherit", href: "/media", onClick: (e) => {
|
|
60
|
+
e.preventDefault();
|
|
61
|
+
navigate('/media');
|
|
62
|
+
}, children: "Media" }), _jsx(Link, { color: "inherit", href: `/media/${folderId}`, onClick: (e) => {
|
|
63
|
+
e.preventDefault();
|
|
64
|
+
navigate(`/media/${folderId}`);
|
|
65
|
+
}, children: folderName }), _jsx(Typography, { noWrap: true, sx: {
|
|
66
|
+
color: "text.primary",
|
|
67
|
+
maxWidth: 200
|
|
68
|
+
}, children: fileName })] }), _jsxs(Box, { sx: {
|
|
69
|
+
display: 'flex',
|
|
70
|
+
alignItems: 'center',
|
|
71
|
+
justifyContent: 'space-between',
|
|
72
|
+
mb: 1,
|
|
73
|
+
flexWrap: 'wrap',
|
|
74
|
+
gap: 1,
|
|
75
|
+
}, children: [_jsx(Typography, { variant: "h6", noWrap: true, sx: { flex: 1, minWidth: 0 }, children: fileName }), _jsx(Button, { variant: "outlined", size: "small", startIcon: _jsx(DownloadIcon, {}), onClick: handleDownload, disabled: !downloadUrl, children: "Download" })] }), downloadUrl && (_jsx(MediaPlayer, { src: downloadUrl, mode: mode, fileName: fileName }))] }));
|
|
76
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function MediaUploadPage(): import("react").JSX.Element;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
import { useParams, useNavigate } from 'react-router-dom';
|
|
4
|
+
import { Container, Typography, Breadcrumbs, Link, Paper, Button, Box, Alert, CircularProgress, } from '@mui/material';
|
|
5
|
+
import { CloudUpload as CloudUploadIcon } from '@mui/icons-material';
|
|
6
|
+
import { getMediaFolder } from '../../../core/headless/api.js';
|
|
7
|
+
import { useMediaFiles } from '../../headless/useMediaFiles.js';
|
|
8
|
+
function formatFileSize(bytes) {
|
|
9
|
+
if (bytes < 1024)
|
|
10
|
+
return `${bytes} B`;
|
|
11
|
+
if (bytes < 1024 * 1024)
|
|
12
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
13
|
+
if (bytes < 1024 * 1024 * 1024)
|
|
14
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
15
|
+
return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
|
|
16
|
+
}
|
|
17
|
+
export default function MediaUploadPage() {
|
|
18
|
+
const { folderId } = useParams();
|
|
19
|
+
const navigate = useNavigate();
|
|
20
|
+
const { uploadFile } = useMediaFiles();
|
|
21
|
+
const [folderName, setFolderName] = useState('');
|
|
22
|
+
const [selectedFile, setSelectedFile] = useState(null);
|
|
23
|
+
const [isUploading, setIsUploading] = useState(false);
|
|
24
|
+
const [formError, setFormError] = useState(null);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (!folderId)
|
|
27
|
+
return;
|
|
28
|
+
getMediaFolder(folderId)
|
|
29
|
+
.then((folder) => setFolderName(folder.name))
|
|
30
|
+
.catch(() => setFolderName('Folder'));
|
|
31
|
+
}, [folderId]);
|
|
32
|
+
const handleFileChange = (e) => {
|
|
33
|
+
const file = e.target.files?.[0];
|
|
34
|
+
if (!file)
|
|
35
|
+
return;
|
|
36
|
+
setFormError(null);
|
|
37
|
+
setSelectedFile(file);
|
|
38
|
+
};
|
|
39
|
+
const handleUpload = async () => {
|
|
40
|
+
if (!folderId || !selectedFile)
|
|
41
|
+
return;
|
|
42
|
+
setFormError(null);
|
|
43
|
+
setIsUploading(true);
|
|
44
|
+
try {
|
|
45
|
+
await uploadFile(folderId, selectedFile);
|
|
46
|
+
navigate(`/media/${folderId}`);
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
setFormError(err instanceof Error ? err.message : 'Upload failed');
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
setIsUploading(false);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
return (_jsxs(Container, { maxWidth: "sm", sx: { py: 3 }, children: [_jsxs(Breadcrumbs, { sx: { mb: 2 }, children: [_jsx(Link, { color: "inherit", href: "/", onClick: (e) => {
|
|
56
|
+
e.preventDefault();
|
|
57
|
+
navigate('/');
|
|
58
|
+
}, children: "Home" }), _jsx(Link, { color: "inherit", href: "/media", onClick: (e) => {
|
|
59
|
+
e.preventDefault();
|
|
60
|
+
navigate('/media');
|
|
61
|
+
}, children: "Media" }), _jsx(Link, { color: "inherit", href: `/media/${folderId}`, onClick: (e) => {
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
navigate(`/media/${folderId}`);
|
|
64
|
+
}, children: folderName }), _jsx(Typography, { sx: {
|
|
65
|
+
color: "text.primary"
|
|
66
|
+
}, children: "Upload" })] }), _jsx(Typography, { variant: "h4", gutterBottom: true, children: "Upload File" }), _jsx(Paper, { sx: { p: 3 }, children: _jsxs(Box, { sx: { display: 'flex', flexDirection: 'column', gap: 2 }, children: [formError && _jsx(Alert, { severity: "error", children: formError }), _jsxs(Box, { sx: {
|
|
67
|
+
border: '2px dashed',
|
|
68
|
+
borderColor: 'divider',
|
|
69
|
+
borderRadius: 1,
|
|
70
|
+
p: 4,
|
|
71
|
+
textAlign: 'center',
|
|
72
|
+
bgcolor: 'action.hover',
|
|
73
|
+
}, children: [_jsx(CloudUploadIcon, { sx: { fontSize: 48, color: 'text.secondary', mb: 1 } }), _jsx(Typography, { variant: "body1", gutterBottom: true, sx: {
|
|
74
|
+
color: "text.secondary"
|
|
75
|
+
}, children: "Select a video, audio, or image file" }), _jsxs(Button, { variant: "outlined", component: "label", disabled: isUploading, children: ["Choose File", _jsx("input", { type: "file", hidden: true, accept: "video/*,audio/*,image/*", onChange: handleFileChange })] })] }), selectedFile && (_jsxs(Box, { sx: {
|
|
76
|
+
p: 2,
|
|
77
|
+
bgcolor: 'background.default',
|
|
78
|
+
borderRadius: 1,
|
|
79
|
+
border: '1px solid',
|
|
80
|
+
borderColor: 'divider',
|
|
81
|
+
}, children: [_jsx(Typography, { variant: "body2", noWrap: true, sx: {
|
|
82
|
+
fontWeight: 500
|
|
83
|
+
}, children: selectedFile.name }), _jsxs(Typography, { variant: "caption", sx: {
|
|
84
|
+
color: "text.secondary"
|
|
85
|
+
}, children: [selectedFile.type, " \u2022 ", formatFileSize(selectedFile.size)] })] })), isUploading && (_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: [_jsx(CircularProgress, { size: 20 }), _jsx(Typography, { variant: "body2", sx: {
|
|
86
|
+
color: "text.secondary"
|
|
87
|
+
}, children: "Uploading..." })] })), _jsxs(Box, { sx: { display: 'flex', justifyContent: 'flex-end', gap: 1, mt: 1 }, children: [_jsx(Button, { onClick: () => navigate(`/media/${folderId}`), disabled: isUploading, children: "Cancel" }), _jsx(Button, { variant: "contained", disabled: !selectedFile || isUploading, onClick: handleUpload, children: isUploading ? 'Uploading...' : 'Upload' })] })] }) })] }));
|
|
88
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function RenameMediaFilePage(): import("react").JSX.Element;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
import { useParams, useNavigate } from 'react-router-dom';
|
|
4
|
+
import { Container, Typography, Breadcrumbs, Link, Paper, TextField, Button, Box, Alert, CircularProgress, } from '@mui/material';
|
|
5
|
+
import { getMediaFolder, getMediaFile, renameMediaFile } from '../../../core/headless/api.js';
|
|
6
|
+
export default function RenameMediaFilePage() {
|
|
7
|
+
const { folderId, fileId } = useParams();
|
|
8
|
+
const navigate = useNavigate();
|
|
9
|
+
const [folderName, setFolderName] = useState('');
|
|
10
|
+
const [name, setName] = useState('');
|
|
11
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
12
|
+
const [formError, setFormError] = useState(null);
|
|
13
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (!folderId || !fileId)
|
|
16
|
+
return;
|
|
17
|
+
Promise.all([getMediaFolder(folderId), getMediaFile(folderId, fileId)])
|
|
18
|
+
.then(([folder, file]) => {
|
|
19
|
+
setFolderName(folder.name);
|
|
20
|
+
setName(file.name);
|
|
21
|
+
})
|
|
22
|
+
.catch((err) => {
|
|
23
|
+
setFormError(err instanceof Error ? err.message : 'Failed to load file');
|
|
24
|
+
})
|
|
25
|
+
.finally(() => setIsLoading(false));
|
|
26
|
+
}, [folderId, fileId]);
|
|
27
|
+
const handleSubmit = async (e) => {
|
|
28
|
+
e.preventDefault();
|
|
29
|
+
if (!folderId || !fileId)
|
|
30
|
+
return;
|
|
31
|
+
setFormError(null);
|
|
32
|
+
if (!name.trim()) {
|
|
33
|
+
setFormError('File name is required');
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
setIsSubmitting(true);
|
|
37
|
+
try {
|
|
38
|
+
await renameMediaFile(folderId, fileId, name.trim());
|
|
39
|
+
navigate(`/media/${folderId}`);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
setFormError(err instanceof Error ? err.message : 'Failed to rename file');
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
setIsSubmitting(false);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
if (isLoading) {
|
|
49
|
+
return (_jsx(Container, { maxWidth: "sm", sx: { py: 3, display: 'flex', justifyContent: 'center' }, children: _jsx(CircularProgress, {}) }));
|
|
50
|
+
}
|
|
51
|
+
return (_jsxs(Container, { maxWidth: "sm", sx: { py: 3 }, children: [_jsxs(Breadcrumbs, { sx: { mb: 2 }, children: [_jsx(Link, { color: "inherit", href: "/", onClick: (e) => {
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
navigate('/');
|
|
54
|
+
}, children: "Home" }), _jsx(Link, { color: "inherit", href: "/media", onClick: (e) => {
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
navigate('/media');
|
|
57
|
+
}, children: "Media" }), _jsx(Link, { color: "inherit", href: `/media/${folderId}`, onClick: (e) => {
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
navigate(`/media/${folderId}`);
|
|
60
|
+
}, children: folderName }), _jsx(Typography, { sx: {
|
|
61
|
+
color: "text.primary"
|
|
62
|
+
}, children: "Rename" })] }), _jsx(Typography, { variant: "h4", gutterBottom: true, children: "Rename File" }), _jsx(Paper, { sx: { p: 3 }, children: _jsx("form", { onSubmit: handleSubmit, children: _jsxs(Box, { sx: { display: 'flex', flexDirection: 'column', gap: 2 }, children: [formError && _jsx(Alert, { severity: "error", children: formError }), _jsx(TextField, { label: "File Name", fullWidth: true, required: true, value: name, onChange: (e) => setName(e.target.value), disabled: isSubmitting, autoFocus: true }), _jsxs(Box, { sx: { display: 'flex', justifyContent: 'flex-end', gap: 1, mt: 1 }, children: [_jsx(Button, { onClick: () => navigate(`/media/${folderId}`), disabled: isSubmitting, children: "Cancel" }), _jsx(Button, { type: "submit", variant: "contained", disabled: isSubmitting, children: isSubmitting ? 'Saving...' : 'Save' })] })] }) }) })] }));
|
|
63
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vault's navigation destinations: the SINGLE table the platform shell's rail,
|
|
3
|
+
* phone bottom bar and avatar menu draw (E10.2, issue #93; spec:
|
|
4
|
+
* docs/specs/ux-refresh.md §2).
|
|
5
|
+
*
|
|
6
|
+
* Rules this table keeps (each asserted by the host's
|
|
7
|
+
* `apps/web/src/__tests__/config/destinations.test.ts`, which reads its `App.tsx`):
|
|
8
|
+
*
|
|
9
|
+
* 1. Every route in `App.tsx` is owned by EXACTLY ONE destination, or is listed
|
|
10
|
+
* in `UNOWNED_ROUTES` (reached from outside the signed-in shell).
|
|
11
|
+
* 2. At most FOUR non-pinned destinations: Home, Secrets, Cards, Media. A fifth
|
|
12
|
+
* is a redesign of the phone bar, not an addition.
|
|
13
|
+
* 3. `settings` and `console` are `pinned`: a MODE, not a peer. They sit at the
|
|
14
|
+
* rail's foot and in the avatar menu, never on the bottom bar
|
|
15
|
+
* (`BOTTOM_BAR_NAVIGATION` in the host's `config/shell.ts` drops them).
|
|
16
|
+
* 4. A gate is the exact permission string the API controller enforces, never
|
|
17
|
+
* a role: `secrets:read` (`secrets.controller.ts`, and cards are secrets of
|
|
18
|
+
* the Card type), `media:read` (`media.controller.ts`), and for the Console
|
|
19
|
+
* `system_settings:read` (`system-settings.controller.ts`), `users:read`
|
|
20
|
+
* (`users.controller.ts`), `push:read` (the platform `push-config.controller`)
|
|
21
|
+
* or `broadcasts:read` (the platform `broadcasts.controller`).
|
|
22
|
+
*
|
|
23
|
+
* Matching (`owns`, longest prefix wins, segment boundaries) and visibility
|
|
24
|
+
* (`isDestinationVisible`) are the platform's; re-exported here so callers and
|
|
25
|
+
* tests ask one function.
|
|
26
|
+
*/
|
|
27
|
+
import type { ShellDestination } from '@marinoscar/platform-web/shell/headless';
|
|
28
|
+
export { isDestinationVisible, owns, resolveActiveDestination } from '@marinoscar/platform-web/shell/headless';
|
|
29
|
+
export type DestinationKey = 'home' | 'secrets' | 'cards' | 'media' | 'settings' | 'console';
|
|
30
|
+
export type Destination = ShellDestination<DestinationKey>;
|
|
31
|
+
/** The six destinations, in navigation order (declaration order is the order everywhere). */
|
|
32
|
+
export declare const DESTINATIONS: readonly Destination[];
|
|
33
|
+
/**
|
|
34
|
+
* The route prefixes each destination OWNS (lights up on). Child routes are
|
|
35
|
+
* covered by their prefix.
|
|
36
|
+
*
|
|
37
|
+
* - `settings` also owns `/secret-types`: since E10.3 the secret types pages
|
|
38
|
+
* live under their card (`/settings/secret-types/*`) and the old routes are
|
|
39
|
+
* redirects kept for bookmarks; they still light up Settings.
|
|
40
|
+
* - `console` navigates to `/admin/settings` but owns all of `/admin` (the
|
|
41
|
+
* `/admin` and `/admin/users` redirects too), which is also the prefix of
|
|
42
|
+
* the rail's Console mode.
|
|
43
|
+
*/
|
|
44
|
+
export declare const DESTINATION_ROUTES: Readonly<Record<DestinationKey, readonly string[]>>;
|
|
45
|
+
/**
|
|
46
|
+
* Routes deliberately owned by NO destination: reached from outside the
|
|
47
|
+
* signed-in shell (sign-in, the sign-in callback, the OAuth consent and error pages, the full-screen device
|
|
48
|
+
* activation, the dev-only test login) . No row lights up there, by design.
|
|
49
|
+
*/
|
|
50
|
+
export declare const UNOWNED_ROUTES: readonly string[];
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vault's navigation destinations: the SINGLE table the platform shell's rail,
|
|
3
|
+
* phone bottom bar and avatar menu draw (E10.2, issue #93; spec:
|
|
4
|
+
* docs/specs/ux-refresh.md §2).
|
|
5
|
+
*
|
|
6
|
+
* Rules this table keeps (each asserted by the host's
|
|
7
|
+
* `apps/web/src/__tests__/config/destinations.test.ts`, which reads its `App.tsx`):
|
|
8
|
+
*
|
|
9
|
+
* 1. Every route in `App.tsx` is owned by EXACTLY ONE destination, or is listed
|
|
10
|
+
* in `UNOWNED_ROUTES` (reached from outside the signed-in shell).
|
|
11
|
+
* 2. At most FOUR non-pinned destinations: Home, Secrets, Cards, Media. A fifth
|
|
12
|
+
* is a redesign of the phone bar, not an addition.
|
|
13
|
+
* 3. `settings` and `console` are `pinned`: a MODE, not a peer. They sit at the
|
|
14
|
+
* rail's foot and in the avatar menu, never on the bottom bar
|
|
15
|
+
* (`BOTTOM_BAR_NAVIGATION` in the host's `config/shell.ts` drops them).
|
|
16
|
+
* 4. A gate is the exact permission string the API controller enforces, never
|
|
17
|
+
* a role: `secrets:read` (`secrets.controller.ts`, and cards are secrets of
|
|
18
|
+
* the Card type), `media:read` (`media.controller.ts`), and for the Console
|
|
19
|
+
* `system_settings:read` (`system-settings.controller.ts`), `users:read`
|
|
20
|
+
* (`users.controller.ts`), `push:read` (the platform `push-config.controller`)
|
|
21
|
+
* or `broadcasts:read` (the platform `broadcasts.controller`).
|
|
22
|
+
*
|
|
23
|
+
* Matching (`owns`, longest prefix wins, segment boundaries) and visibility
|
|
24
|
+
* (`isDestinationVisible`) are the platform's; re-exported here so callers and
|
|
25
|
+
* tests ask one function.
|
|
26
|
+
*/
|
|
27
|
+
import HomeIcon from '@mui/icons-material/HomeOutlined';
|
|
28
|
+
import KeyIcon from '@mui/icons-material/VpnKeyOutlined';
|
|
29
|
+
import CardIcon from '@mui/icons-material/CreditCardOutlined';
|
|
30
|
+
import MediaIcon from '@mui/icons-material/PermMediaOutlined';
|
|
31
|
+
import SettingsIcon from '@mui/icons-material/SettingsOutlined';
|
|
32
|
+
import ConsoleIcon from '@mui/icons-material/AdminPanelSettingsOutlined';
|
|
33
|
+
export { isDestinationVisible, owns, resolveActiveDestination } from '@marinoscar/platform-web/shell/headless';
|
|
34
|
+
/** The six destinations, in navigation order (declaration order is the order everywhere). */
|
|
35
|
+
export const DESTINATIONS = [
|
|
36
|
+
{ key: 'home', label: 'Home', compactLabel: 'Home', Icon: HomeIcon, path: '/' },
|
|
37
|
+
{
|
|
38
|
+
key: 'secrets',
|
|
39
|
+
label: 'Secrets',
|
|
40
|
+
compactLabel: 'Secrets',
|
|
41
|
+
Icon: KeyIcon,
|
|
42
|
+
path: '/secrets',
|
|
43
|
+
permission: 'secrets:read',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
key: 'cards',
|
|
47
|
+
label: 'Cards',
|
|
48
|
+
compactLabel: 'Cards',
|
|
49
|
+
Icon: CardIcon,
|
|
50
|
+
path: '/cards',
|
|
51
|
+
permission: 'secrets:read',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
key: 'media',
|
|
55
|
+
label: 'Media',
|
|
56
|
+
compactLabel: 'Media',
|
|
57
|
+
Icon: MediaIcon,
|
|
58
|
+
path: '/media',
|
|
59
|
+
permission: 'media:read',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
key: 'settings',
|
|
63
|
+
label: 'Settings',
|
|
64
|
+
compactLabel: 'Settings',
|
|
65
|
+
Icon: SettingsIcon,
|
|
66
|
+
path: '/settings',
|
|
67
|
+
// Any signed-in user; the cards inside are gated. Declared before Console so
|
|
68
|
+
// the rail's foot reads Settings, then the operator surface.
|
|
69
|
+
pinned: true,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
key: 'console',
|
|
73
|
+
label: 'Console',
|
|
74
|
+
compactLabel: 'Console',
|
|
75
|
+
Icon: ConsoleIcon,
|
|
76
|
+
path: '/admin/settings',
|
|
77
|
+
// Any-of: every Console card is reachable by a holder of one of these
|
|
78
|
+
// (push:read and broadcasts:read are the E7.2 Web Push and Broadcasts cards,
|
|
79
|
+
// ai_config:read the E8.2 AI, AI models and AI usage cards, db_backup:read the E9.1 Database Backup card,
|
|
80
|
+
// storage_config:read the E6.1 Storage card).
|
|
81
|
+
anyPermission: ['system_settings:read', 'users:read', 'push:read', 'broadcasts:read', 'ai_config:read', 'db_backup:read', 'storage_config:read'],
|
|
82
|
+
pinned: true,
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
/**
|
|
86
|
+
* The route prefixes each destination OWNS (lights up on). Child routes are
|
|
87
|
+
* covered by their prefix.
|
|
88
|
+
*
|
|
89
|
+
* - `settings` also owns `/secret-types`: since E10.3 the secret types pages
|
|
90
|
+
* live under their card (`/settings/secret-types/*`) and the old routes are
|
|
91
|
+
* redirects kept for bookmarks; they still light up Settings.
|
|
92
|
+
* - `console` navigates to `/admin/settings` but owns all of `/admin` (the
|
|
93
|
+
* `/admin` and `/admin/users` redirects too), which is also the prefix of
|
|
94
|
+
* the rail's Console mode.
|
|
95
|
+
*/
|
|
96
|
+
export const DESTINATION_ROUTES = {
|
|
97
|
+
home: ['/'],
|
|
98
|
+
secrets: ['/secrets'],
|
|
99
|
+
cards: ['/cards'],
|
|
100
|
+
media: ['/media'],
|
|
101
|
+
settings: ['/settings', '/secret-types'],
|
|
102
|
+
console: ['/admin'],
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Routes deliberately owned by NO destination: reached from outside the
|
|
106
|
+
* signed-in shell (sign-in, the sign-in callback, the OAuth consent and error pages, the full-screen device
|
|
107
|
+
* activation, the dev-only test login) . No row lights up there, by design.
|
|
108
|
+
*/
|
|
109
|
+
export const UNOWNED_ROUTES = ['/login', '/auth/callback', '/activate', '/oauth/consent', '/oauth/error', '/testing/login'];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './destinations.js';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { FieldDefinition } from '../../core/headless/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Client-side mirror of the API's `fieldDefinitionSchema`
|
|
4
|
+
* (`apps/api/src/secret-types/dto/create-secret-type.dto.ts`).
|
|
5
|
+
*
|
|
6
|
+
* The server is the authority; this module exists so the builder can never
|
|
7
|
+
* produce a definition the server would reject — an admin should not fill in a
|
|
8
|
+
* whole type definition only to be told about a bad option list by a 400.
|
|
9
|
+
*
|
|
10
|
+
* Server rules encoded here:
|
|
11
|
+
* - `options` is required and non-empty when `type === 'select'`
|
|
12
|
+
* - `options` is rejected for every other type
|
|
13
|
+
* - each option is 1–100 characters
|
|
14
|
+
* - at most 50 options
|
|
15
|
+
* - duplicate values are rejected
|
|
16
|
+
*
|
|
17
|
+
* The only place this is deliberately stricter than the server is whitespace:
|
|
18
|
+
* `" "` satisfies the server's `min(1)` but is a useless choice in a
|
|
19
|
+
* dropdown, so it is treated as blank. Stricter is safe — it can only reject
|
|
20
|
+
* definitions the server would have accepted, never accept ones it refuses.
|
|
21
|
+
*/
|
|
22
|
+
export declare const MAX_OPTIONS = 50;
|
|
23
|
+
export declare const MAX_OPTION_LENGTH = 100;
|
|
24
|
+
export declare const OPTION_ERRORS: {
|
|
25
|
+
readonly emptyList: "Add at least one option";
|
|
26
|
+
readonly blank: "Option cannot be empty";
|
|
27
|
+
readonly duplicate: "This option is already in the list";
|
|
28
|
+
readonly tooLong: "Options must be 100 characters or less";
|
|
29
|
+
readonly tooMany: "A field can have at most 50 options";
|
|
30
|
+
readonly notAllowed: "Options are only allowed on Select fields";
|
|
31
|
+
};
|
|
32
|
+
export interface FieldOptionsValidation {
|
|
33
|
+
/** Per-option message, index-aligned with `field.options` (null = valid). */
|
|
34
|
+
optionErrors: (string | null)[];
|
|
35
|
+
/** Message that applies to the option list as a whole. */
|
|
36
|
+
listError: string | null;
|
|
37
|
+
isValid: boolean;
|
|
38
|
+
}
|
|
39
|
+
export declare function validateFieldOptions(field: FieldDefinition): FieldOptionsValidation;
|
|
40
|
+
/**
|
|
41
|
+
* Returns the first options problem across all fields as a human-readable
|
|
42
|
+
* message, or null when every field's options would be accepted by the API.
|
|
43
|
+
* Consumers use this to block save.
|
|
44
|
+
*/
|
|
45
|
+
export declare function validateFieldDefinitions(fields: FieldDefinition[]): string | null;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side mirror of the API's `fieldDefinitionSchema`
|
|
3
|
+
* (`apps/api/src/secret-types/dto/create-secret-type.dto.ts`).
|
|
4
|
+
*
|
|
5
|
+
* The server is the authority; this module exists so the builder can never
|
|
6
|
+
* produce a definition the server would reject — an admin should not fill in a
|
|
7
|
+
* whole type definition only to be told about a bad option list by a 400.
|
|
8
|
+
*
|
|
9
|
+
* Server rules encoded here:
|
|
10
|
+
* - `options` is required and non-empty when `type === 'select'`
|
|
11
|
+
* - `options` is rejected for every other type
|
|
12
|
+
* - each option is 1–100 characters
|
|
13
|
+
* - at most 50 options
|
|
14
|
+
* - duplicate values are rejected
|
|
15
|
+
*
|
|
16
|
+
* The only place this is deliberately stricter than the server is whitespace:
|
|
17
|
+
* `" "` satisfies the server's `min(1)` but is a useless choice in a
|
|
18
|
+
* dropdown, so it is treated as blank. Stricter is safe — it can only reject
|
|
19
|
+
* definitions the server would have accepted, never accept ones it refuses.
|
|
20
|
+
*/
|
|
21
|
+
export const MAX_OPTIONS = 50;
|
|
22
|
+
export const MAX_OPTION_LENGTH = 100;
|
|
23
|
+
export const OPTION_ERRORS = {
|
|
24
|
+
emptyList: 'Add at least one option',
|
|
25
|
+
blank: 'Option cannot be empty',
|
|
26
|
+
duplicate: 'This option is already in the list',
|
|
27
|
+
tooLong: `Options must be ${MAX_OPTION_LENGTH} characters or less`,
|
|
28
|
+
tooMany: `A field can have at most ${MAX_OPTIONS} options`,
|
|
29
|
+
notAllowed: 'Options are only allowed on Select fields',
|
|
30
|
+
};
|
|
31
|
+
export function validateFieldOptions(field) {
|
|
32
|
+
// Non-select fields must not carry options at all — the API rejects them.
|
|
33
|
+
if (field.type !== 'select') {
|
|
34
|
+
const listError = field.options === undefined ? null : OPTION_ERRORS.notAllowed;
|
|
35
|
+
return { optionErrors: [], listError, isValid: listError === null };
|
|
36
|
+
}
|
|
37
|
+
const options = field.options ?? [];
|
|
38
|
+
const seen = new Set();
|
|
39
|
+
const optionErrors = options.map((option) => {
|
|
40
|
+
if (option.trim().length === 0)
|
|
41
|
+
return OPTION_ERRORS.blank;
|
|
42
|
+
if (option.length > MAX_OPTION_LENGTH)
|
|
43
|
+
return OPTION_ERRORS.tooLong;
|
|
44
|
+
if (seen.has(option))
|
|
45
|
+
return OPTION_ERRORS.duplicate;
|
|
46
|
+
seen.add(option);
|
|
47
|
+
return null;
|
|
48
|
+
});
|
|
49
|
+
let listError = null;
|
|
50
|
+
if (options.length === 0) {
|
|
51
|
+
listError = OPTION_ERRORS.emptyList;
|
|
52
|
+
}
|
|
53
|
+
else if (options.length > MAX_OPTIONS) {
|
|
54
|
+
listError = OPTION_ERRORS.tooMany;
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
optionErrors,
|
|
58
|
+
listError,
|
|
59
|
+
isValid: listError === null && optionErrors.every((e) => e === null),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function describeField(field, index) {
|
|
63
|
+
return field.label.trim() || field.name.trim() || `Field ${index + 1}`;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Returns the first options problem across all fields as a human-readable
|
|
67
|
+
* message, or null when every field's options would be accepted by the API.
|
|
68
|
+
* Consumers use this to block save.
|
|
69
|
+
*/
|
|
70
|
+
export function validateFieldDefinitions(fields) {
|
|
71
|
+
for (let i = 0; i < fields.length; i++) {
|
|
72
|
+
const { isValid, listError, optionErrors } = validateFieldOptions(fields[i]);
|
|
73
|
+
if (isValid)
|
|
74
|
+
continue;
|
|
75
|
+
const message = listError ?? optionErrors.find((e) => e !== null) ?? 'Invalid options';
|
|
76
|
+
return `${describeField(fields[i], i)}: ${message}`;
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Secrets and secret types: the list, detail and type hooks and the field helpers. No component.
|
|
2
|
+
export * from './fieldOptionsValidation.js';
|
|
3
|
+
export * from './secretFields.js';
|
|
4
|
+
export * from './useSecretDetail.js';
|
|
5
|
+
export * from './useSecretTypes.js';
|
|
6
|
+
export * from './useSecrets.js';
|
|
7
|
+
export * from './useTotpCode.js';
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers for the secrets UI (E10.4, issue #95): form validation that
|
|
3
|
+
* mirrors the API, copy formatting, the version diff and date labels.
|
|
4
|
+
*
|
|
5
|
+
* Nothing here holds a secret value beyond the call that receives it.
|
|
6
|
+
*/
|
|
7
|
+
import type { FieldDefinition, SecretType } from '../../core/headless/types.js';
|
|
8
|
+
/** Bounds of `createSecretSchema` / `updateSecretSchema` in the API. */
|
|
9
|
+
export declare const SECRET_NAME_MAX = 255;
|
|
10
|
+
export declare const SECRET_DESCRIPTION_MAX = 1000;
|
|
11
|
+
/** How long a copied secret value may stay on the clipboard (best effort). */
|
|
12
|
+
export declare const SECRET_CLIPBOARD_CLEAR_MS = 30000;
|
|
13
|
+
/** How long a revealed value stays on screen before it is masked again. */
|
|
14
|
+
export declare const SECRET_REVEAL_TIMEOUT_MS = 30000;
|
|
15
|
+
/** True for the system Card type, whose secrets also live in the Cards flows. */
|
|
16
|
+
export declare function isCardType(type: Pick<SecretType, 'isSystem' | 'name'> | null | undefined): boolean;
|
|
17
|
+
/** The Credential field that holds the authenticator key. */
|
|
18
|
+
export declare const TOTP_FIELD_NAME = "totp";
|
|
19
|
+
/** Shown under the authenticator-key field when the pasted text is not a usable key. */
|
|
20
|
+
export declare const TOTP_FIELD_HELP = "Paste the setup key or the otpauth:// link from the site's QR code setup";
|
|
21
|
+
/**
|
|
22
|
+
* Map a failed save to per-field messages. The API answers 400 with
|
|
23
|
+
* `details.errors` entries such as `Field "totp" ...`; the totp one becomes the
|
|
24
|
+
* friendly help text, any other field's message is kept as sent. Empty when the
|
|
25
|
+
* error carries nothing field-specific.
|
|
26
|
+
*/
|
|
27
|
+
export declare function fieldErrorsFromApiError(err: unknown, fields: FieldDefinition[]): Record<string, string>;
|
|
28
|
+
/**
|
|
29
|
+
* Validate field values against the type's field definitions, with the same
|
|
30
|
+
* rules `SecretsService.validateDataAgainstType` applies on the server: a
|
|
31
|
+
* required field is non-empty, a number parses, a date is a real date and a
|
|
32
|
+
* select value is one of its options (when options exist). Empty optional
|
|
33
|
+
* fields are fine.
|
|
34
|
+
*
|
|
35
|
+
* @returns field name to message; empty when valid.
|
|
36
|
+
*/
|
|
37
|
+
export declare function validateSecretFields(fields: FieldDefinition[], data: Record<string, unknown>): Record<string, string>;
|
|
38
|
+
export interface SecretFormErrors {
|
|
39
|
+
name?: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
typeId?: string;
|
|
42
|
+
fields: Record<string, string>;
|
|
43
|
+
}
|
|
44
|
+
/** Validate the whole create/edit form; `hasErrors` tells whether to submit. */
|
|
45
|
+
export declare function validateSecretForm(input: {
|
|
46
|
+
name: string;
|
|
47
|
+
description: string;
|
|
48
|
+
typeId?: string;
|
|
49
|
+
requireType?: boolean;
|
|
50
|
+
fields: FieldDefinition[];
|
|
51
|
+
data: Record<string, unknown>;
|
|
52
|
+
}): {
|
|
53
|
+
errors: SecretFormErrors;
|
|
54
|
+
hasErrors: boolean;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Drop keys the type does not declare and empty optional values, so the body
|
|
58
|
+
* never carries a field the API would refuse as unknown.
|
|
59
|
+
*/
|
|
60
|
+
export declare function cleanSecretData(fields: FieldDefinition[], data: Record<string, unknown>): Record<string, unknown>;
|
|
61
|
+
/** The text a field's copy button puts on the clipboard. */
|
|
62
|
+
export declare function formatSecretValueForCopy(value: string, fieldName?: string): string;
|
|
63
|
+
export type FieldChange = 'unchanged' | 'changed' | 'added' | 'removed';
|
|
64
|
+
export interface FieldDiff {
|
|
65
|
+
field: FieldDefinition;
|
|
66
|
+
change: FieldChange;
|
|
67
|
+
/** The value in the version being inspected ('' when absent). */
|
|
68
|
+
version: string;
|
|
69
|
+
/** The value in the current version ('' when absent). */
|
|
70
|
+
current: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Compare a historical version's values with the current ones, field by
|
|
74
|
+
* field, in the type's field order. "added" means the current version has a
|
|
75
|
+
* value the inspected one lacks; "removed" the reverse.
|
|
76
|
+
*/
|
|
77
|
+
export declare function diffSecretValues(fields: FieldDefinition[], versionValues: Record<string, unknown>, currentValues: Record<string, unknown>): FieldDiff[];
|
|
78
|
+
/** "just now", "5m ago", "3h ago", "2d ago", then a locale date past 30 days. */
|
|
79
|
+
export declare function formatRelativeTime(dateString: string, now?: Date): string;
|
|
80
|
+
/** True for the system `Credential` type, the only one that may be opened to agents. */
|
|
81
|
+
export declare function supportsAgentAccess(type: {
|
|
82
|
+
name: string;
|
|
83
|
+
isSystem?: boolean;
|
|
84
|
+
} | null | undefined): boolean;
|
|
85
|
+
/** A friendly message for a failed agent-access toggle. */
|
|
86
|
+
export declare function agentAccessErrorMessage(err: unknown): string;
|