@marinoscar/vault-web 0.0.0-stage → 0.1.0-next.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/CHANGELOG.md +46 -0
- package/LICENSE +21 -0
- package/README.md +98 -2
- package/dist/agent/headless/agentActivity.d.ts +57 -0
- package/dist/agent/headless/agentActivity.js +70 -0
- package/dist/agent/headless/cardGrants.d.ts +28 -0
- package/dist/agent/headless/cardGrants.js +61 -0
- package/dist/agent/headless/index.d.ts +4 -0
- package/dist/agent/headless/index.js +5 -0
- package/dist/agent/headless/useAgentActivity.d.ts +9 -0
- package/dist/agent/headless/useAgentActivity.js +30 -0
- package/dist/agent/headless/useCardGrants.d.ts +19 -0
- package/dist/agent/headless/useCardGrants.js +51 -0
- package/dist/agent/ui/components/AgentActivityTable.d.ts +25 -0
- package/dist/agent/ui/components/AgentActivityTable.js +122 -0
- package/dist/agent/ui/components/CardAgentAccessPanel.d.ts +17 -0
- package/dist/agent/ui/components/CardAgentAccessPanel.js +44 -0
- package/dist/agent/ui/components/CardGrantDialog.d.ts +16 -0
- package/dist/agent/ui/components/CardGrantDialog.js +101 -0
- package/dist/agent/ui/components/IdentityAgentAccessPanel.d.ts +20 -0
- package/dist/agent/ui/components/IdentityAgentAccessPanel.js +61 -0
- package/dist/agent/ui/index.d.ts +6 -0
- package/dist/agent/ui/index.js +7 -0
- package/dist/agent/ui/pages/AgentAccessSettingsPage.d.ts +7 -0
- package/dist/agent/ui/pages/AgentAccessSettingsPage.js +105 -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 +82 -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 +161 -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 +276 -0
- package/dist/core/headless/api.js +432 -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 +53 -0
- package/dist/core/headless/http.js +59 -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 +458 -0
- package/dist/core/headless/types.js +51 -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 +91 -0
- package/dist/secrets/headless/secretFields.js +197 -0
- package/dist/secrets/headless/useSecretDetail.d.ts +34 -0
- package/dist/secrets/headless/useSecretDetail.js +88 -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 +191 -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 +12 -0
- package/package.json +144 -4
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useEffect, useState } from 'react';
|
|
3
|
+
import { Link as RouterLink } from 'react-router-dom';
|
|
4
|
+
import { Box, Chip, Link, Tooltip, Typography } from '@mui/material';
|
|
5
|
+
import { SmartToyOutlined as EmptyIcon } from '@mui/icons-material';
|
|
6
|
+
import { DataTable } from '@marinoscar/platform-web/datatable/ui';
|
|
7
|
+
import { AGENT_ACTION_LABELS, agentAppLabel, } from '../../headless/agentActivity.js';
|
|
8
|
+
export const AGENT_ACTIVITY_TABLE_ID = 'agent-activity';
|
|
9
|
+
export const AGENT_ACTIVITY_PAGE_SIZES = [10, 25, 50, 100];
|
|
10
|
+
const LayoutReport = createContext(null);
|
|
11
|
+
function LayoutProbe({ layout }) {
|
|
12
|
+
const report = useContext(LayoutReport);
|
|
13
|
+
useEffect(() => report?.(layout), [report, layout]);
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const SLOTS = { Toolbar: LayoutProbe };
|
|
17
|
+
function Dash() {
|
|
18
|
+
return (_jsx(Typography, { variant: "body2", component: "span", sx: { color: 'text.disabled' }, "aria-label": "None", children: "\u2014" }));
|
|
19
|
+
}
|
|
20
|
+
function ResultChip({ row }) {
|
|
21
|
+
if (row.result === 'ok')
|
|
22
|
+
return _jsx(Chip, { size: "small", color: "success", variant: "outlined", label: "OK" });
|
|
23
|
+
const chip = _jsx(Chip, { size: "small", color: "error", variant: "outlined", label: "Denied" });
|
|
24
|
+
return row.reason ? (_jsx(Tooltip, { title: row.reason, children: _jsx("span", { tabIndex: 0, "aria-label": `Denied: ${row.reason}`, children: chip }) })) : (chip);
|
|
25
|
+
}
|
|
26
|
+
function SecretLink({ row }) {
|
|
27
|
+
if (!row.secretId)
|
|
28
|
+
return _jsx(Dash, {});
|
|
29
|
+
return (_jsx(Link, { component: RouterLink, to: `/secrets/${row.secretId}`, underline: "hover", sx: { overflowWrap: 'anywhere' }, children: row.secretName ?? 'Secret' }));
|
|
30
|
+
}
|
|
31
|
+
function TimeLabel({ iso }) {
|
|
32
|
+
return _jsx("time", { dateTime: iso, children: new Date(iso).toLocaleString() });
|
|
33
|
+
}
|
|
34
|
+
const COLUMNS = [
|
|
35
|
+
{
|
|
36
|
+
id: 'at',
|
|
37
|
+
label: 'Time',
|
|
38
|
+
priority: 'primary',
|
|
39
|
+
hideable: false,
|
|
40
|
+
width: 180,
|
|
41
|
+
value: (row) => new Date(row.at).toLocaleString(),
|
|
42
|
+
render: (row) => _jsx(TimeLabel, { iso: row.at }),
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 'app',
|
|
46
|
+
label: 'App',
|
|
47
|
+
priority: 'primary',
|
|
48
|
+
flex: 1,
|
|
49
|
+
minWidth: 140,
|
|
50
|
+
value: (row) => agentAppLabel(row),
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: 'action',
|
|
54
|
+
label: 'Action',
|
|
55
|
+
priority: 'secondary',
|
|
56
|
+
width: 130,
|
|
57
|
+
value: (row) => AGENT_ACTION_LABELS[row.action] ?? row.action,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: 'secret',
|
|
61
|
+
label: 'Secret',
|
|
62
|
+
priority: 'secondary',
|
|
63
|
+
flex: 1,
|
|
64
|
+
minWidth: 140,
|
|
65
|
+
value: (row) => row.secretName ?? '',
|
|
66
|
+
render: (row) => _jsx(SecretLink, { row: row }),
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: 'origin',
|
|
70
|
+
label: 'Website',
|
|
71
|
+
priority: 'secondary',
|
|
72
|
+
flex: 1,
|
|
73
|
+
minWidth: 140,
|
|
74
|
+
truncate: true,
|
|
75
|
+
value: (row) => row.origin ?? '',
|
|
76
|
+
render: (row) => (row.origin ? _jsx("span", { children: row.origin }) : _jsx(Dash, {})),
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: 'amount',
|
|
80
|
+
label: 'Amount',
|
|
81
|
+
priority: 'detail',
|
|
82
|
+
width: 120,
|
|
83
|
+
value: (row) => (row.amount ? `${row.amount} ${row.currency ?? ''}`.trim() : ''),
|
|
84
|
+
render: (row) => (row.amount ? _jsx("span", { children: `${row.amount} ${row.currency ?? ''}`.trim() }) : _jsx(Dash, {})),
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: 'purpose',
|
|
88
|
+
label: 'Purpose',
|
|
89
|
+
priority: 'detail',
|
|
90
|
+
flex: 1.2,
|
|
91
|
+
minWidth: 160,
|
|
92
|
+
truncate: true,
|
|
93
|
+
value: (row) => row.purpose ?? '',
|
|
94
|
+
render: (row) => (row.purpose ? _jsx("span", { children: row.purpose }) : _jsx(Dash, {})),
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
id: 'result',
|
|
98
|
+
label: 'Result',
|
|
99
|
+
priority: 'primary',
|
|
100
|
+
width: 110,
|
|
101
|
+
value: (row) => (row.result === 'ok' ? 'OK' : 'Denied'),
|
|
102
|
+
render: (row) => _jsx(ResultChip, { row: row }),
|
|
103
|
+
},
|
|
104
|
+
];
|
|
105
|
+
/**
|
|
106
|
+
* The agent activity list on the platform `DataTable`: a grid on desktop, cards on a phone (the
|
|
107
|
+
* table measures its own container). Server-paged; no value, code or seed is ever in a row.
|
|
108
|
+
*/
|
|
109
|
+
export function AgentActivityTable(props) {
|
|
110
|
+
const { rows, total, page, pageSize, loading, error, onPaginationChange, filtered = false, renderer } = props;
|
|
111
|
+
const [, setLayout] = useState('desktop');
|
|
112
|
+
const emptyState = (_jsxs(Box, { sx: { py: 4, display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 1, textAlign: 'center' }, children: [_jsx(EmptyIcon, { sx: { fontSize: 40, color: 'text.secondary' } }), _jsx(Typography, { variant: "body2", sx: { color: 'text.secondary', maxWidth: 420 }, children: filtered
|
|
113
|
+
? 'No agent activity matches your filters.'
|
|
114
|
+
: "No agent activity yet. Agents only see the logins, cards and identity details you allow on the secret's page." })] }));
|
|
115
|
+
return (_jsx(Box, { sx: { minWidth: 0 }, children: _jsx(LayoutReport.Provider, { value: setLayout, children: _jsx(DataTable, { tableId: AGENT_ACTIVITY_TABLE_ID, ariaLabel: "Agent activity", columns: COLUMNS, rows: rows, rowId: (row) => row.id, loading: loading, error: error, emptyState: emptyState, pagination: {
|
|
116
|
+
page,
|
|
117
|
+
pageSize,
|
|
118
|
+
total,
|
|
119
|
+
onPaginationChange,
|
|
120
|
+
pageSizeOptions: AGENT_ACTIVITY_PAGE_SIZES,
|
|
121
|
+
}, disableExport: true, renderer: renderer, tabletBreakpoint: 840, slots: SLOTS }) }) }));
|
|
122
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface CardAgentAccessPanelProps {
|
|
2
|
+
secretId: string;
|
|
3
|
+
cardName: string;
|
|
4
|
+
/** `fill` when the card is opened to agents. */
|
|
5
|
+
agentAccess: 'none' | 'fill';
|
|
6
|
+
/** The viewer holds `secrets:write`. Writes also need a browser session, which the web app always is. */
|
|
7
|
+
canWrite: boolean;
|
|
8
|
+
/** Opens or closes the card to agents (the page's `setAgentAccess`). */
|
|
9
|
+
onToggle: (enabled: boolean) => Promise<void> | void;
|
|
10
|
+
toggling?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* "Agent access" on a card (ADR-0003): open or closed, the pending requests agents made with
|
|
14
|
+
* Approve and Decline, the merchant grants with their limits and use, and the form to allow a shop.
|
|
15
|
+
* Never shows a card number: grants and requests carry none.
|
|
16
|
+
*/
|
|
17
|
+
export declare function CardAgentAccessPanel({ secretId, cardName, agentAccess, canWrite, onToggle, toggling }: CardAgentAccessPanelProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Alert, Box, Button, Chip, Divider, FormControlLabel, Paper, Stack, Switch, Typography, } from '@mui/material';
|
|
4
|
+
import { AddOutlined as AddIcon } from '@mui/icons-material';
|
|
5
|
+
import { cardGrantErrorMessage, describeGrantLimits, formatGrantAmount, } from '../../headless/cardGrants.js';
|
|
6
|
+
import { useCardGrants } from '../../headless/useCardGrants.js';
|
|
7
|
+
import { CardGrantDialog } from './CardGrantDialog.js';
|
|
8
|
+
const STATUS_COLOR = { active: 'success', expired: 'default', revoked: 'default' };
|
|
9
|
+
const STATUS_LABEL = { active: 'Active', expired: 'Expired', revoked: 'Revoked' };
|
|
10
|
+
function GrantRow({ grant, canWrite, busy, onRevoke }) {
|
|
11
|
+
const per = grant.periodLimit?.period ?? 'day';
|
|
12
|
+
return (_jsxs(Box, { sx: { py: 1.5, display: 'flex', flexDirection: 'column', gap: 0.75, minWidth: 0 }, "data-testid": "card-grant", children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1, flexWrap: 'wrap', minWidth: 0 }, children: [_jsx(Typography, { variant: "body2", sx: { fontWeight: 600, overflowWrap: 'anywhere', minWidth: 0 }, children: grant.merchantOrigin }), _jsx(Chip, { size: "small", variant: "outlined", color: STATUS_COLOR[grant.status], label: STATUS_LABEL[grant.status] }), grant.includeSecurityCode && _jsx(Chip, { size: "small", variant: "outlined", label: "Security code" })] }), _jsxs(Typography, { variant: "caption", sx: { color: 'text.secondary' }, children: [describeGrantLimits(grant), grant.expiresAt ? ` · until ${new Date(grant.expiresAt).toLocaleDateString()}` : ''] }), grant.frameOrigins.length > 0 && (_jsxs(Typography, { variant: "caption", sx: { color: 'text.secondary', overflowWrap: 'anywhere' }, children: ["Payment frames: ", grant.frameOrigins.join(', ')] })), _jsx(Typography, { variant: "caption", sx: { color: 'text.secondary' }, children: grant.usage.totalReleases === 0
|
|
13
|
+
? 'Not used yet'
|
|
14
|
+
: `Used ${grant.usage.periodReleases} ${grant.usage.periodReleases === 1 ? 'time' : 'times'} this ${per} (${formatGrantAmount(grant.usage.periodAmount, grant.currency)}), ${grant.usage.totalReleases} in all` }), grant.status === 'active' && canWrite && (_jsx(Box, { children: _jsx(Button, { size: "small", color: "error", onClick: onRevoke, disabled: busy, "aria-label": `Revoke ${grant.merchantOrigin}`, children: "Revoke" }) }))] }));
|
|
15
|
+
}
|
|
16
|
+
function RequestRow({ request, canWrite, busy, onApprove, onDecline, }) {
|
|
17
|
+
return (_jsxs(Box, { sx: { py: 1.5, display: 'flex', flexDirection: 'column', gap: 0.75, minWidth: 0 }, "data-testid": "card-grant-request", children: [_jsxs(Typography, { variant: "body2", sx: { overflowWrap: 'anywhere' }, children: [_jsx(Box, { component: "span", sx: { fontWeight: 600 }, children: request.clientName ?? 'An app' }), ' ', "asks to use this card at ", _jsx(Box, { component: "span", sx: { fontWeight: 600 }, children: request.origin }), " for up to", ' ', formatGrantAmount(request.amount, request.currency), "."] }), _jsxs(Typography, { variant: "caption", sx: { color: 'text.secondary', overflowWrap: 'anywhere' }, children: ["\u201C", request.reason, "\u201D \u00B7 ", new Date(request.createdAt).toLocaleString()] }), canWrite && (_jsxs(Stack, { direction: "row", spacing: 1, children: [_jsx(Button, { size: "small", variant: "contained", onClick: onApprove, disabled: busy, "aria-label": `Approve ${request.origin}`, children: "Approve" }), _jsx(Button, { size: "small", onClick: onDecline, disabled: busy, "aria-label": `Decline ${request.origin}`, children: "Decline" })] }))] }));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* "Agent access" on a card (ADR-0003): open or closed, the pending requests agents made with
|
|
21
|
+
* Approve and Decline, the merchant grants with their limits and use, and the form to allow a shop.
|
|
22
|
+
* Never shows a card number: grants and requests carry none.
|
|
23
|
+
*/
|
|
24
|
+
export function CardAgentAccessPanel({ secretId, cardName, agentAccess, canWrite, onToggle, toggling = false }) {
|
|
25
|
+
const { grants, requests, loading, error, create, revoke, approve, decline } = useCardGrants(secretId);
|
|
26
|
+
const [dialogOpen, setDialogOpen] = useState(false);
|
|
27
|
+
const [busy, setBusy] = useState(false);
|
|
28
|
+
const [failure, setFailure] = useState(null);
|
|
29
|
+
const run = async (work) => {
|
|
30
|
+
setBusy(true);
|
|
31
|
+
setFailure(null);
|
|
32
|
+
try {
|
|
33
|
+
await work();
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
setFailure(cardGrantErrorMessage(err));
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
setBusy(false);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const opened = agentAccess === 'fill';
|
|
43
|
+
return (_jsxs(Paper, { variant: "outlined", sx: { borderRadius: 2, px: 2, py: 1.5, mt: 2, minWidth: 0 }, "aria-label": "Agent access", children: [_jsx(FormControlLabel, { sx: { alignItems: 'flex-start', m: 0, gap: 1, minWidth: 0 }, control: _jsx(Switch, { checked: opened, onChange: (e) => void onToggle(e.target.checked), disabled: !canWrite || toggling, slotProps: { input: { 'aria-describedby': 'card-agent-access-help' } } }), label: _jsx(Typography, { variant: "body2", sx: { fontWeight: 600, pt: 0.75 }, children: "Allow agents to use this card" }) }), _jsx(Typography, { id: "card-agent-access-help", variant: "caption", component: "p", sx: { color: 'text.secondary', mt: 0.5 }, children: "Agents you connect can type this card only at the shops you allow below, one field at a time and up to the amount you set. They never see it in chat. Prefer a virtual card with its own limit." }), failure && (_jsx(Alert, { severity: "error", sx: { mt: 1.5 }, onClose: () => setFailure(null), children: failure })), error && (_jsx(Alert, { severity: "error", sx: { mt: 1.5 }, children: error })), requests.length > 0 && (_jsxs(Box, { sx: { mt: 2 }, children: [_jsxs(Typography, { variant: "subtitle2", component: "h3", children: ["Requests (", requests.length, ")"] }), requests.map((request, index) => (_jsxs(Box, { children: [index > 0 && _jsx(Divider, {}), _jsx(RequestRow, { request: request, canWrite: canWrite, busy: busy, onApprove: () => void run(() => approve(request.id)), onDecline: () => void run(() => decline(request.id)) })] }, request.id)))] })), _jsxs(Box, { sx: { mt: 2 }, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 1, flexWrap: 'wrap' }, children: [_jsx(Typography, { variant: "subtitle2", component: "h3", children: "Allowed shops" }), canWrite && (_jsx(Button, { size: "small", startIcon: _jsx(AddIcon, {}), onClick: () => setDialogOpen(true), children: "Allow a shop" }))] }), !loading && grants.length === 0 && (_jsxs(Typography, { variant: "caption", component: "p", sx: { color: 'text.secondary', mt: 0.5 }, children: ["No shop yet. ", opened ? 'Agents cannot use this card until you allow one.' : ''] })), grants.map((grant, index) => (_jsxs(Box, { children: [index > 0 && _jsx(Divider, {}), _jsx(GrantRow, { grant: grant, canWrite: canWrite, busy: busy, onRevoke: () => void run(() => revoke(grant.id)) })] }, grant.id)))] }), _jsx(CardGrantDialog, { open: dialogOpen, cardName: cardName, onClose: () => setDialogOpen(false), onSubmit: create, errorMessage: cardGrantErrorMessage })] }));
|
|
44
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CreateCardGrant } from '../../headless/cardGrants.js';
|
|
2
|
+
export interface CardGrantDialogProps {
|
|
3
|
+
open: boolean;
|
|
4
|
+
/** The card's name, shown in the title. */
|
|
5
|
+
cardName: string;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
/** Creates the grant; throws on failure (the dialog shows `errorMessage(err)`). */
|
|
8
|
+
onSubmit: (body: CreateCardGrant) => Promise<void>;
|
|
9
|
+
errorMessage: (err: unknown) => string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The "Allow a shop" form of a card (ADR-0003): the merchant, the maximum per purchase and its
|
|
13
|
+
* currency (required), optional payment frames, an optional limit per day or month, an optional
|
|
14
|
+
* end date and the security code (off by default). Validates before it sends; the API validates again.
|
|
15
|
+
*/
|
|
16
|
+
export declare function CardGrantDialog({ open, cardName, onClose, onSubmit, errorMessage }: CardGrantDialogProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Alert, Box, Button, Dialog, DialogActions, DialogContent, DialogTitle, FormControlLabel, MenuItem, Switch, TextField, Typography, } from '@mui/material';
|
|
4
|
+
const AMOUNT = /^\d{1,8}(\.\d{1,2})?$/;
|
|
5
|
+
const CURRENCY = /^[A-Za-z]{3}$/;
|
|
6
|
+
const WHOLE = /^\d{1,4}$/;
|
|
7
|
+
/** `https://shop.example.test` or `shop.example.test`; the API normalizes and has the last word. */
|
|
8
|
+
function looksLikeOrigin(text) {
|
|
9
|
+
const value = text.trim();
|
|
10
|
+
if (!value || /\s/.test(value))
|
|
11
|
+
return false;
|
|
12
|
+
try {
|
|
13
|
+
const url = new URL(/^[a-z][a-z0-9+.-]*:\/\//i.test(value) ? value : `https://${value}`);
|
|
14
|
+
return url.protocol === 'https:' && !!url.hostname;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const splitOrigins = (text) => text.split(/[\s,;]+/).map((s) => s.trim()).filter(Boolean);
|
|
21
|
+
/**
|
|
22
|
+
* The "Allow a shop" form of a card (ADR-0003): the merchant, the maximum per purchase and its
|
|
23
|
+
* currency (required), optional payment frames, an optional limit per day or month, an optional
|
|
24
|
+
* end date and the security code (off by default). Validates before it sends; the API validates again.
|
|
25
|
+
*/
|
|
26
|
+
export function CardGrantDialog({ open, cardName, onClose, onSubmit, errorMessage }) {
|
|
27
|
+
const [merchant, setMerchant] = useState('');
|
|
28
|
+
const [maxAmount, setMaxAmount] = useState('');
|
|
29
|
+
const [currency, setCurrency] = useState('USD');
|
|
30
|
+
const [frames, setFrames] = useState('');
|
|
31
|
+
const [period, setPeriod] = useState('none');
|
|
32
|
+
const [periodReleases, setPeriodReleases] = useState('');
|
|
33
|
+
const [periodAmount, setPeriodAmount] = useState('');
|
|
34
|
+
const [expires, setExpires] = useState('');
|
|
35
|
+
const [securityCode, setSecurityCode] = useState(false);
|
|
36
|
+
const [touched, setTouched] = useState(false);
|
|
37
|
+
const [saving, setSaving] = useState(false);
|
|
38
|
+
const [failure, setFailure] = useState(null);
|
|
39
|
+
const errors = {
|
|
40
|
+
merchant: looksLikeOrigin(merchant) ? null : 'Enter the shop\'s website, for example shop.example.test.',
|
|
41
|
+
maxAmount: AMOUNT.test(maxAmount) && Number(maxAmount) > 0 ? null : 'Enter an amount greater than 0, with at most two decimals.',
|
|
42
|
+
currency: CURRENCY.test(currency) ? null : 'Enter a three-letter currency code, for example USD.',
|
|
43
|
+
frames: splitOrigins(frames).every(looksLikeOrigin) ? null : 'Each payment frame must be a website, separated by spaces or commas.',
|
|
44
|
+
periodReleases: period === 'none' || periodReleases === '' || (WHOLE.test(periodReleases) && Number(periodReleases) > 0) ? null : 'Enter a whole number.',
|
|
45
|
+
periodAmount: period === 'none' || periodAmount === '' || (AMOUNT.test(periodAmount) && Number(periodAmount) > 0) ? null : 'Enter an amount greater than 0.',
|
|
46
|
+
periodAny: period === 'none' || periodReleases !== '' || periodAmount !== '' ? null : 'Set a number of uses, a total, or both.',
|
|
47
|
+
expires: expires === '' || new Date(`${expires}T23:59:59`).getTime() > Date.now() ? null : 'Choose a date in the future.',
|
|
48
|
+
};
|
|
49
|
+
const valid = Object.values(errors).every((e) => e === null);
|
|
50
|
+
const show = (key) => (touched ? errors[key] : null);
|
|
51
|
+
const reset = () => {
|
|
52
|
+
setMerchant('');
|
|
53
|
+
setMaxAmount('');
|
|
54
|
+
setCurrency('USD');
|
|
55
|
+
setFrames('');
|
|
56
|
+
setPeriod('none');
|
|
57
|
+
setPeriodReleases('');
|
|
58
|
+
setPeriodAmount('');
|
|
59
|
+
setExpires('');
|
|
60
|
+
setSecurityCode(false);
|
|
61
|
+
setTouched(false);
|
|
62
|
+
setFailure(null);
|
|
63
|
+
};
|
|
64
|
+
const close = () => {
|
|
65
|
+
reset();
|
|
66
|
+
onClose();
|
|
67
|
+
};
|
|
68
|
+
const submit = async () => {
|
|
69
|
+
setTouched(true);
|
|
70
|
+
if (!valid)
|
|
71
|
+
return;
|
|
72
|
+
setSaving(true);
|
|
73
|
+
setFailure(null);
|
|
74
|
+
try {
|
|
75
|
+
await onSubmit({
|
|
76
|
+
merchantOrigin: merchant.trim(),
|
|
77
|
+
frameOrigins: splitOrigins(frames),
|
|
78
|
+
maxAmount: Number(maxAmount),
|
|
79
|
+
currency: currency.toUpperCase(),
|
|
80
|
+
periodLimit: period === 'none'
|
|
81
|
+
? null
|
|
82
|
+
: {
|
|
83
|
+
period,
|
|
84
|
+
...(periodReleases ? { maxReleases: Number(periodReleases) } : {}),
|
|
85
|
+
...(periodAmount ? { maxAmount: Number(periodAmount) } : {}),
|
|
86
|
+
},
|
|
87
|
+
expiresAt: expires ? new Date(`${expires}T23:59:59`).toISOString() : null,
|
|
88
|
+
includeSecurityCode: securityCode,
|
|
89
|
+
});
|
|
90
|
+
reset();
|
|
91
|
+
onClose();
|
|
92
|
+
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
setFailure(errorMessage(err));
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
setSaving(false);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
return (_jsxs(Dialog, { open: open, onClose: saving ? undefined : close, fullWidth: true, maxWidth: "sm", "aria-labelledby": "card-grant-dialog-title", children: [_jsxs(DialogTitle, { id: "card-grant-dialog-title", children: ["Allow a shop for ", cardName] }), _jsxs(DialogContent, { children: [_jsx(Typography, { variant: "body2", sx: { color: 'text.secondary', mb: 2 }, children: "Agents can use this card only at this shop and its subdomains, up to the amount you set. A use is not a payment: the shop still charges the card." }), failure && (_jsx(Alert, { severity: "error", sx: { mb: 2 }, children: failure })), _jsxs(Box, { sx: { display: 'grid', gap: 2, gridTemplateColumns: { xs: '1fr', sm: '2fr 1fr' } }, children: [_jsx(TextField, { label: "Shop website", value: merchant, onChange: (e) => setMerchant(e.target.value), error: !!show('merchant'), helperText: show('merchant') ?? 'The address of the checkout page, for example https://shop.example.test', required: true, sx: { gridColumn: { sm: '1 / -1' } } }), _jsx(TextField, { label: "Most per purchase", value: maxAmount, onChange: (e) => setMaxAmount(e.target.value), error: !!show('maxAmount'), helperText: show('maxAmount') ?? ' ', required: true, slotProps: { htmlInput: { inputMode: 'decimal' } } }), _jsx(TextField, { label: "Currency", value: currency, onChange: (e) => setCurrency(e.target.value.toUpperCase()), error: !!show('currency'), helperText: show('currency') ?? ' ', required: true, slotProps: { htmlInput: { maxLength: 3, autoCapitalize: 'characters' } } }), _jsx(TextField, { label: "Payment frames (optional)", value: frames, onChange: (e) => setFrames(e.target.value), error: !!show('frames'), helperText: show('frames') ?? 'Websites of embedded payment forms this shop uses, if any', sx: { gridColumn: { sm: '1 / -1' } } }), _jsxs(TextField, { select: true, label: "Limit", value: period, onChange: (e) => setPeriod(e.target.value), helperText: show('periodAny') ?? ' ', error: !!show('periodAny'), sx: { gridColumn: { sm: '1 / -1' } }, children: [_jsx(MenuItem, { value: "none", children: "No limit beyond the amount per purchase" }), _jsx(MenuItem, { value: "day", children: "Per day" }), _jsx(MenuItem, { value: "month", children: "Per month" })] }), period !== 'none' && (_jsxs(_Fragment, { children: [_jsx(TextField, { label: `Uses per ${period}`, value: periodReleases, onChange: (e) => setPeriodReleases(e.target.value), error: !!show('periodReleases'), helperText: show('periodReleases') ?? ' ', slotProps: { htmlInput: { inputMode: 'numeric' } } }), _jsx(TextField, { label: `Total per ${period}`, value: periodAmount, onChange: (e) => setPeriodAmount(e.target.value), error: !!show('periodAmount'), helperText: show('periodAmount') ?? ' ', slotProps: { htmlInput: { inputMode: 'decimal' } } })] })), _jsx(TextField, { label: "Ends on (optional)", type: "date", value: expires, onChange: (e) => setExpires(e.target.value), error: !!show('expires'), helperText: show('expires') ?? ' ', slotProps: { inputLabel: { shrink: true } }, sx: { gridColumn: { sm: '1 / -1' } } })] }), _jsx(FormControlLabel, { sx: { alignItems: 'flex-start', m: 0, mt: 1, gap: 1 }, control: _jsx(Switch, { checked: securityCode, onChange: (e) => setSecurityCode(e.target.checked) }), label: _jsxs(Box, { sx: { pt: 0.75 }, children: [_jsx(Typography, { variant: "body2", sx: { fontWeight: 600 }, children: "Include the security code" }), _jsx(Typography, { variant: "caption", sx: { color: 'text.secondary' }, children: "Off unless this shop asks for it at every purchase." })] }) })] }), _jsxs(DialogActions, { sx: { px: 3, pb: 2 }, children: [_jsx(Button, { onClick: close, disabled: saving, children: "Cancel" }), _jsx(Button, { variant: "contained", onClick: () => void submit(), disabled: saving, children: "Allow shop" })] })] }));
|
|
101
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface IdentityAgentAccessPanelProps {
|
|
2
|
+
/** `fill` when the item is opened to agents. */
|
|
3
|
+
agentAccess: 'none' | 'fill';
|
|
4
|
+
/** The origins its sensitive fields may be filled on (as stored: normalized). */
|
|
5
|
+
agentOrigins: string[];
|
|
6
|
+
/** The viewer holds `secrets:write`. */
|
|
7
|
+
canWrite: boolean;
|
|
8
|
+
/** Saves the access and, when given, the allowed origins. Throws on failure. */
|
|
9
|
+
onSave: (agentAccess: 'none' | 'fill', allowedOrigins?: string[]) => Promise<void>;
|
|
10
|
+
/** A friendly message for a failure. */
|
|
11
|
+
errorMessage: (err: unknown) => string;
|
|
12
|
+
}
|
|
13
|
+
/** A website as typed (`form.example.test`, `https://form.example.test/apply`) to its origin, or null. */
|
|
14
|
+
export declare function toOrigin(text: string): string | null;
|
|
15
|
+
/**
|
|
16
|
+
* "Agent access" on an Identity item (ADR-0003): open or closed, and the websites its sensitive
|
|
17
|
+
* fields (date of birth, id number) may be filled on. Name, address and phone are filled on any
|
|
18
|
+
* website once the item is opened.
|
|
19
|
+
*/
|
|
20
|
+
export declare function IdentityAgentAccessPanel({ agentAccess, agentOrigins, canWrite, onSave, errorMessage }: IdentityAgentAccessPanelProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { Alert, Box, Button, Chip, FormControlLabel, Paper, Switch, TextField, Typography } from '@mui/material';
|
|
4
|
+
/** A website as typed (`form.example.test`, `https://form.example.test/apply`) to its origin, or null. */
|
|
5
|
+
export function toOrigin(text) {
|
|
6
|
+
const value = text.trim();
|
|
7
|
+
if (!value || /\s/.test(value))
|
|
8
|
+
return null;
|
|
9
|
+
try {
|
|
10
|
+
const url = new URL(/^[a-z][a-z0-9+.-]*:\/\//i.test(value) ? value : `https://${value}`);
|
|
11
|
+
if (url.protocol !== 'https:' || !url.hostname)
|
|
12
|
+
return null;
|
|
13
|
+
return url.origin.toLowerCase();
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* "Agent access" on an Identity item (ADR-0003): open or closed, and the websites its sensitive
|
|
21
|
+
* fields (date of birth, id number) may be filled on. Name, address and phone are filled on any
|
|
22
|
+
* website once the item is opened.
|
|
23
|
+
*/
|
|
24
|
+
export function IdentityAgentAccessPanel({ agentAccess, agentOrigins, canWrite, onSave, errorMessage }) {
|
|
25
|
+
const [origins, setOrigins] = useState(agentOrigins);
|
|
26
|
+
const [draft, setDraft] = useState('');
|
|
27
|
+
const [saving, setSaving] = useState(false);
|
|
28
|
+
const [failure, setFailure] = useState(null);
|
|
29
|
+
const key = agentOrigins.join(' ');
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
setOrigins(key ? key.split(' ') : []);
|
|
32
|
+
}, [key]);
|
|
33
|
+
const draftOrigin = toOrigin(draft);
|
|
34
|
+
const dirty = origins.join(' ') !== key;
|
|
35
|
+
const save = async (access, allowed) => {
|
|
36
|
+
setSaving(true);
|
|
37
|
+
setFailure(null);
|
|
38
|
+
try {
|
|
39
|
+
await onSave(access, allowed);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
setFailure(errorMessage(err));
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
setSaving(false);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const add = () => {
|
|
49
|
+
if (!draftOrigin)
|
|
50
|
+
return;
|
|
51
|
+
if (!origins.includes(draftOrigin))
|
|
52
|
+
setOrigins([...origins, draftOrigin].sort());
|
|
53
|
+
setDraft('');
|
|
54
|
+
};
|
|
55
|
+
return (_jsxs(Paper, { variant: "outlined", sx: { borderRadius: 2, px: 2, py: 1.5, mt: 2, minWidth: 0 }, "aria-label": "Agent access", children: [_jsx(FormControlLabel, { sx: { alignItems: 'flex-start', m: 0, gap: 1, minWidth: 0 }, control: _jsx(Switch, { checked: agentAccess === 'fill', onChange: (e) => void save(e.target.checked ? 'fill' : 'none'), disabled: !canWrite || saving, slotProps: { input: { 'aria-describedby': 'identity-agent-access-help' } } }), label: _jsx(Typography, { variant: "body2", sx: { fontWeight: 600, pt: 0.75 }, children: "Allow agents to fill these details" }) }), _jsx(Typography, { id: "identity-agent-access-help", variant: "caption", component: "p", sx: { color: 'text.secondary', mt: 0.5 }, children: "Agents you connect can type your name, address and phone into forms, one field at a time. Your date of birth and id number only on the websites below." }), failure && (_jsx(Alert, { severity: "error", sx: { mt: 1.5 }, onClose: () => setFailure(null), children: failure })), _jsx(Typography, { variant: "subtitle2", component: "h3", sx: { mt: 2 }, children: "Websites for date of birth and id number" }), _jsxs(Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: 1, mt: 1 }, "aria-label": "Allowed websites", children: [origins.length === 0 && (_jsx(Typography, { variant: "caption", sx: { color: 'text.secondary' }, children: "None: these two fields are never filled." })), origins.map((origin) => (_jsx(Chip, { label: origin, size: "small", sx: { maxWidth: '100%' }, onDelete: canWrite ? () => setOrigins(origins.filter((o) => o !== origin)) : undefined }, origin)))] }), canWrite && (_jsxs(Box, { sx: { display: 'flex', gap: 1, mt: 1.5, flexWrap: { xs: 'wrap', sm: 'nowrap' }, alignItems: 'flex-start' }, children: [_jsx(TextField, { size: "small", label: "Add a website", value: draft, onChange: (e) => setDraft(e.target.value), onKeyDown: (e) => {
|
|
56
|
+
if (e.key === 'Enter') {
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
add();
|
|
59
|
+
}
|
|
60
|
+
}, error: draft !== '' && !draftOrigin, helperText: draft !== '' && !draftOrigin ? 'Enter an https website, for example form.example.test.' : ' ', sx: { flex: 1, minWidth: 0 } }), _jsx(Button, { onClick: add, disabled: !draftOrigin || saving, children: "Add" }), _jsx(Button, { variant: "contained", onClick: () => void save(agentAccess, origins), disabled: !dirty || saving, children: "Save" })] }))] }));
|
|
61
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './components/AgentActivityTable.js';
|
|
2
|
+
export { default as AgentAccessSettingsPage } from './pages/AgentAccessSettingsPage.js';
|
|
3
|
+
export { default as AgentActivityPage } from './pages/AgentActivityPage.js';
|
|
4
|
+
export * from './components/CardAgentAccessPanel.js';
|
|
5
|
+
export * from './components/CardGrantDialog.js';
|
|
6
|
+
export * from './components/IdentityAgentAccessPanel.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Agent access: the per-user Agent activity page and the admin kill switch page.
|
|
2
|
+
export * from './components/AgentActivityTable.js';
|
|
3
|
+
export { default as AgentAccessSettingsPage } from './pages/AgentAccessSettingsPage.js';
|
|
4
|
+
export { default as AgentActivityPage } from './pages/AgentActivityPage.js';
|
|
5
|
+
export * from './components/CardAgentAccessPanel.js';
|
|
6
|
+
export * from './components/CardGrantDialog.js';
|
|
7
|
+
export * from './components/IdentityAgentAccessPanel.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `Agent access` card of the Console (`/admin/settings/agent-access`, E14.7, ADR-0003): the
|
|
3
|
+
* deployment kill switch, the card and identity switches (both off by default) and the limits of
|
|
4
|
+
* the agent credential API (`agentAccess` system settings). Read needs `system_settings:read` (the
|
|
5
|
+
* route gates on it); every control is disabled without `system_settings:write`.
|
|
6
|
+
*/
|
|
7
|
+
export default function AgentAccessSettingsPage(): import("react").JSX.Element;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { Navigate } from 'react-router-dom';
|
|
4
|
+
import { Alert, Box, Button, Divider, FormControlLabel, Paper, Snackbar, Switch, TextField, Typography } from '@mui/material';
|
|
5
|
+
import { usePermissions } from '@marinoscar/platform-web/identity/headless';
|
|
6
|
+
import { useSystemSettings } from '../../../core/headless/useSystemSettings.js';
|
|
7
|
+
import { LoadingSpinner } from '../../../core/ui/LoadingSpinner.js';
|
|
8
|
+
import { SettingsPageFrame } from '../../../core/ui/SettingsPageFrame.js';
|
|
9
|
+
import { AGENT_ACCESS_DEFAULTS } from '../../../core/headless/types.js';
|
|
10
|
+
const LOGIN_LIMITS = [
|
|
11
|
+
{ key: 'lookupPerMinute', label: 'Lookups per minute', help: 'Finding a login, card or identity for a website.', max: 600 },
|
|
12
|
+
{ key: 'fillPerMinute', label: 'Fills per minute', help: 'Handing a login to an agent.', max: 600 },
|
|
13
|
+
{ key: 'totpPerMinute', label: 'One-time codes per minute', help: 'Reading a one-time code.', max: 600 },
|
|
14
|
+
{ key: 'writePerMinute', label: 'Writes per minute', help: 'Creating or rotating a login, or asking for a shop.', max: 600 },
|
|
15
|
+
];
|
|
16
|
+
const CARD_LIMITS = [
|
|
17
|
+
{ key: 'cardFillPerMinute', label: 'Card fills per minute', help: 'Handing one card field to an agent.', max: 600 },
|
|
18
|
+
{ key: 'cardReleasesPerDay', label: 'Card uses per card per day', help: 'Card numbers handed out, per card, per day.', max: 1000 },
|
|
19
|
+
];
|
|
20
|
+
const IDENTITY_LIMITS = [
|
|
21
|
+
{ key: 'identityFillPerMinute', label: 'Identity fills per minute', help: 'Handing one identity field to an agent.', max: 600 },
|
|
22
|
+
];
|
|
23
|
+
const ALL_LIMITS = [...LOGIN_LIMITS, ...CARD_LIMITS, ...IDENTITY_LIMITS];
|
|
24
|
+
const MIN = 1;
|
|
25
|
+
const validLimit = (text, max) => /^\d+$/.test(text) && Number(text) >= MIN && Number(text) <= max;
|
|
26
|
+
/** The stored namespace with the ADR-0003 blocks filled in (an older API has neither). */
|
|
27
|
+
function resolve(s) {
|
|
28
|
+
return {
|
|
29
|
+
...AGENT_ACCESS_DEFAULTS,
|
|
30
|
+
...s,
|
|
31
|
+
cards: { ...AGENT_ACCESS_DEFAULTS.cards, ...(s.cards ?? {}) },
|
|
32
|
+
identity: { ...AGENT_ACCESS_DEFAULTS.identity, ...(s.identity ?? {}) },
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function toText(s) {
|
|
36
|
+
return {
|
|
37
|
+
lookupPerMinute: String(s.lookupPerMinute),
|
|
38
|
+
fillPerMinute: String(s.fillPerMinute),
|
|
39
|
+
totpPerMinute: String(s.totpPerMinute),
|
|
40
|
+
writePerMinute: String(s.writePerMinute),
|
|
41
|
+
cardFillPerMinute: String(s.cards.fillPerMinute),
|
|
42
|
+
cardReleasesPerDay: String(s.cards.releasesPerCardPerDay),
|
|
43
|
+
identityFillPerMinute: String(s.identity.fillPerMinute),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The `Agent access` card of the Console (`/admin/settings/agent-access`, E14.7, ADR-0003): the
|
|
48
|
+
* deployment kill switch, the card and identity switches (both off by default) and the limits of
|
|
49
|
+
* the agent credential API (`agentAccess` system settings). Read needs `system_settings:read` (the
|
|
50
|
+
* route gates on it); every control is disabled without `system_settings:write`.
|
|
51
|
+
*/
|
|
52
|
+
export default function AgentAccessSettingsPage() {
|
|
53
|
+
const { hasPermission } = usePermissions();
|
|
54
|
+
const { settings, isLoading, error, isSaving, updateSettings } = useSystemSettings();
|
|
55
|
+
const current = resolve(settings?.agentAccess ?? AGENT_ACCESS_DEFAULTS);
|
|
56
|
+
const [enabled, setEnabled] = useState(current.enabled);
|
|
57
|
+
const [cardsEnabled, setCardsEnabled] = useState(current.cards.enabled);
|
|
58
|
+
const [identityEnabled, setIdentityEnabled] = useState(current.identity.enabled);
|
|
59
|
+
const [limits, setLimits] = useState(() => toText(current));
|
|
60
|
+
const [success, setSuccess] = useState(null);
|
|
61
|
+
const [failure, setFailure] = useState(null);
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
setEnabled(current.enabled);
|
|
64
|
+
setCardsEnabled(current.cards.enabled);
|
|
65
|
+
setIdentityEnabled(current.identity.enabled);
|
|
66
|
+
setLimits(toText(current));
|
|
67
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
68
|
+
}, [settings?.version]);
|
|
69
|
+
if (!hasPermission('system_settings:read'))
|
|
70
|
+
return _jsx(Navigate, { to: "/", replace: true });
|
|
71
|
+
const canWrite = hasPermission('system_settings:write');
|
|
72
|
+
if (isLoading)
|
|
73
|
+
return _jsx(LoadingSpinner, {});
|
|
74
|
+
const allValid = ALL_LIMITS.every(({ key, max }) => validLimit(limits[key], max));
|
|
75
|
+
const saved = toText(current);
|
|
76
|
+
const dirty = enabled !== current.enabled ||
|
|
77
|
+
cardsEnabled !== current.cards.enabled ||
|
|
78
|
+
identityEnabled !== current.identity.enabled ||
|
|
79
|
+
ALL_LIMITS.some(({ key }) => Number(limits[key]) !== Number(saved[key]));
|
|
80
|
+
const save = async () => {
|
|
81
|
+
try {
|
|
82
|
+
const next = {
|
|
83
|
+
enabled,
|
|
84
|
+
lookupPerMinute: Number(limits.lookupPerMinute),
|
|
85
|
+
fillPerMinute: Number(limits.fillPerMinute),
|
|
86
|
+
totpPerMinute: Number(limits.totpPerMinute),
|
|
87
|
+
writePerMinute: Number(limits.writePerMinute),
|
|
88
|
+
cards: {
|
|
89
|
+
enabled: cardsEnabled,
|
|
90
|
+
fillPerMinute: Number(limits.cardFillPerMinute),
|
|
91
|
+
releasesPerCardPerDay: Number(limits.cardReleasesPerDay),
|
|
92
|
+
},
|
|
93
|
+
identity: { enabled: identityEnabled, fillPerMinute: Number(limits.identityFillPerMinute) },
|
|
94
|
+
};
|
|
95
|
+
await updateSettings({ agentAccess: next });
|
|
96
|
+
setSuccess('Settings saved');
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
setFailure(err instanceof Error ? err.message : 'Failed to save');
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const limitFields = (defs) => (_jsx(Box, { sx: { display: 'grid', gap: 2, gridTemplateColumns: { xs: '1fr', sm: '1fr 1fr' } }, children: defs.map(({ key, label, help, max }) => (_jsx(TextField, { label: label, value: limits[key], onChange: (e) => setLimits((l) => ({ ...l, [key]: e.target.value })), disabled: !canWrite || isSaving, error: !validLimit(limits[key], max), helperText: validLimit(limits[key], max) ? help : `Enter a whole number from ${MIN} to ${max}.`, slotProps: { htmlInput: { inputMode: 'numeric', min: MIN, max } }, type: "number" }, key))) }));
|
|
103
|
+
const toggle = (checked, onChange, label, help) => (_jsxs(_Fragment, { children: [_jsx(FormControlLabel, { control: _jsx(Switch, { checked: checked, onChange: (e) => onChange(e.target.checked), disabled: !canWrite || isSaving }), label: label }), _jsx(Typography, { variant: "body2", sx: { color: 'text.secondary', mt: 0.5, mb: 2 }, children: help })] }));
|
|
104
|
+
return (_jsxs(SettingsPageFrame, { title: "Agent access", description: `The kill switches and rate limits for apps that use logins, cards and identity details on a person's behalf${canWrite ? '' : ' (read-only)'}`, children: [error && (_jsx(Alert, { severity: "error", sx: { mb: 3 }, children: error })), _jsxs(Paper, { sx: { p: { xs: 2, sm: 3 } }, children: [toggle(enabled, setEnabled, 'Allow agents to use opened logins', "When off, every agent request is refused for everyone, whatever each person has allowed on a login, a card or an identity item. Agents can only use what their owner opened to agents on the secret's page."), limitFields(LOGIN_LIMITS), _jsx(Typography, { variant: "caption", sx: { display: 'block', color: 'text.secondary', mt: 1 }, children: "Each limit counts per app and person." }), _jsx(Divider, { sx: { my: 3 } }), _jsx(Typography, { variant: "subtitle1", component: "h2", sx: { fontWeight: 600, mb: 1 }, children: "Cards" }), toggle(cardsEnabled, setCardsEnabled, 'Allow agents to use cards', 'Off by default. When on, an agent can use a card only at a shop its owner allowed, up to the amount they set, one field at a time.'), limitFields(CARD_LIMITS), _jsx(Divider, { sx: { my: 3 } }), _jsx(Typography, { variant: "subtitle1", component: "h2", sx: { fontWeight: 600, mb: 1 }, children: "Identity" }), toggle(identityEnabled, setIdentityEnabled, 'Allow agents to fill identity details', 'Off by default. When on, an agent can fill the identity details a person opened; the date of birth and id number only on websites they allowed.'), limitFields(IDENTITY_LIMITS), canWrite && (_jsx(Button, { variant: "contained", sx: { mt: 3 }, onClick: save, disabled: !dirty || !allValid || isSaving, children: "Save" }))] }), _jsx(Snackbar, { open: !!success, autoHideDuration: 3000, onClose: () => setSuccess(null), message: success }), _jsx(Snackbar, { open: !!failure, autoHideDuration: 5000, onClose: () => setFailure(null), children: _jsx(Alert, { severity: "error", onClose: () => setFailure(null), children: failure }) })] }));
|
|
105
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `Agent activity` card (`/settings/agent-activity`, E14.7): what apps did with the caller's
|
|
3
|
+
* logins, with filters and a link to Connected apps to revoke one. Read needs `secrets:read`
|
|
4
|
+
* (the route gates on it).
|
|
5
|
+
*/
|
|
6
|
+
export default function AgentActivityPage(): import("react").JSX.Element;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
3
|
+
import { Link as RouterLink } from 'react-router-dom';
|
|
4
|
+
import { Box, Button, MenuItem, TextField } from '@mui/material';
|
|
5
|
+
import { AppsOutlined as AppsIcon } from '@mui/icons-material';
|
|
6
|
+
import { SettingsPageFrame } from '../../../core/ui/SettingsPageFrame.js';
|
|
7
|
+
import { AGENT_ACTION_LABELS, AGENT_ACTIVITY_ACTIONS, } from '../../headless/agentActivity.js';
|
|
8
|
+
import { useAgentActivity } from '../../headless/useAgentActivity.js';
|
|
9
|
+
import { AgentActivityTable, AGENT_ACTIVITY_PAGE_SIZES } from '../components/AgentActivityTable.js';
|
|
10
|
+
/** A `YYYY-MM-DD` input value as the start (or end) of that local day, ISO. */
|
|
11
|
+
function dayBound(value, end) {
|
|
12
|
+
if (!value)
|
|
13
|
+
return undefined;
|
|
14
|
+
const d = new Date(`${value}${end ? 'T23:59:59.999' : 'T00:00:00'}`);
|
|
15
|
+
return Number.isNaN(d.getTime()) ? undefined : d.toISOString();
|
|
16
|
+
}
|
|
17
|
+
const FIELD_SX = { flex: '1 1 160px', minWidth: 0, '& .MuiInputBase-root': { minHeight: 44 } };
|
|
18
|
+
/**
|
|
19
|
+
* The `Agent activity` card (`/settings/agent-activity`, E14.7): what apps did with the caller's
|
|
20
|
+
* logins, with filters and a link to Connected apps to revoke one. Read needs `secrets:read`
|
|
21
|
+
* (the route gates on it).
|
|
22
|
+
*/
|
|
23
|
+
export default function AgentActivityPage() {
|
|
24
|
+
const [action, setAction] = useState('');
|
|
25
|
+
const [clientId, setClientId] = useState('');
|
|
26
|
+
const [from, setFrom] = useState('');
|
|
27
|
+
const [to, setTo] = useState('');
|
|
28
|
+
const [page, setPage] = useState(0);
|
|
29
|
+
const [pageSize, setPageSize] = useState(AGENT_ACTIVITY_PAGE_SIZES[1]);
|
|
30
|
+
// Apps seen so far, so the filter keeps offering one after it narrows the list to itself.
|
|
31
|
+
const [apps, setApps] = useState(new Map());
|
|
32
|
+
const query = useMemo(() => ({
|
|
33
|
+
page: page + 1,
|
|
34
|
+
pageSize,
|
|
35
|
+
action: action || undefined,
|
|
36
|
+
clientId: clientId || undefined,
|
|
37
|
+
from: dayBound(from, false),
|
|
38
|
+
to: dayBound(to, true),
|
|
39
|
+
}), [page, pageSize, action, clientId, from, to]);
|
|
40
|
+
const { items, total, loading, error } = useAgentActivity(query);
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
const additions = items.filter((i) => i.clientId && !apps.has(i.clientId));
|
|
43
|
+
if (additions.length === 0)
|
|
44
|
+
return;
|
|
45
|
+
setApps((prev) => {
|
|
46
|
+
const next = new Map(prev);
|
|
47
|
+
for (const i of additions)
|
|
48
|
+
next.set(i.clientId, i.clientName ?? 'Unknown app');
|
|
49
|
+
return next;
|
|
50
|
+
});
|
|
51
|
+
}, [items, apps]);
|
|
52
|
+
const filtered = Boolean(action || clientId || from || to);
|
|
53
|
+
const reset = (fn) => {
|
|
54
|
+
fn();
|
|
55
|
+
setPage(0);
|
|
56
|
+
};
|
|
57
|
+
return (_jsxs(SettingsPageFrame, { title: "Agent activity", description: "Which apps used or changed your logins, on which website and why. Never a password or code.", maxWidth: "lg", children: [_jsx(Box, { sx: { mb: 2 }, children: _jsx(Button, { component: RouterLink, to: "/settings/connected-apps", variant: "outlined", startIcon: _jsx(AppsIcon, {}), children: "Manage connected apps" }) }), _jsxs(Box, { role: "search", "aria-label": "Filter agent activity", sx: { display: 'flex', flexWrap: 'wrap', gap: 1.5, mb: 2, minWidth: 0 }, children: [_jsxs(TextField, { select: true, size: "small", label: "Action", value: action, onChange: (e) => reset(() => setAction(e.target.value)), sx: FIELD_SX, slotProps: { select: { displayEmpty: true }, inputLabel: { shrink: true } }, children: [_jsx(MenuItem, { value: "", children: "All actions" }), AGENT_ACTIVITY_ACTIONS.map((a) => (_jsx(MenuItem, { value: a, children: AGENT_ACTION_LABELS[a] }, a)))] }), _jsxs(TextField, { select: true, size: "small", label: "App", value: clientId, onChange: (e) => reset(() => setClientId(e.target.value)), sx: FIELD_SX, slotProps: { select: { displayEmpty: true }, inputLabel: { shrink: true } }, children: [_jsx(MenuItem, { value: "", children: "All apps" }), [...apps.entries()].map(([id, name]) => (_jsx(MenuItem, { value: id, children: name }, id)))] }), _jsx(TextField, { size: "small", type: "date", label: "From", value: from, onChange: (e) => reset(() => setFrom(e.target.value)), sx: FIELD_SX, slotProps: { inputLabel: { shrink: true } } }), _jsx(TextField, { size: "small", type: "date", label: "To", value: to, onChange: (e) => reset(() => setTo(e.target.value)), sx: FIELD_SX, slotProps: { inputLabel: { shrink: true } } })] }), _jsx(AgentActivityTable, { rows: items, total: total, page: page, pageSize: pageSize, loading: loading, error: error, filtered: filtered, onPaginationChange: (next) => {
|
|
58
|
+
setPage(next.page);
|
|
59
|
+
setPageSize(next.pageSize);
|
|
60
|
+
} })] }));
|
|
61
|
+
}
|