@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,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one port every Vault slice reaches the API through.
|
|
3
|
+
*
|
|
4
|
+
* The host builds the transport (the platform's `PlatformHttpClient`: the
|
|
5
|
+
* access-token holder, the 401 -> refresh -> retry, the refresh lock) and hands
|
|
6
|
+
* it over ONCE, before the first render, with {@link configureVaultWeb}. The
|
|
7
|
+
* package never builds a client and never reads a build-time variable: the base
|
|
8
|
+
* URL and the lock name are the host's to choose.
|
|
9
|
+
*
|
|
10
|
+
* A module-level port (like `configureNotificationsWeb` of
|
|
11
|
+
* `@marinoscar/platform-web/notifications`) rather than a React provider,
|
|
12
|
+
* because the domain calls are plain async functions (`api.ts`) used from
|
|
13
|
+
* hooks, effects and event handlers alike.
|
|
14
|
+
*/
|
|
15
|
+
/** Thrown when a slice calls the API before the host configured the package. */
|
|
16
|
+
export class VaultWebNotConfiguredError extends Error {
|
|
17
|
+
constructor() {
|
|
18
|
+
super('@marinoscar/vault-web is not configured: call configureVaultWeb({ http }) before the first render.');
|
|
19
|
+
this.name = 'VaultWebNotConfiguredError';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
let config = null;
|
|
23
|
+
/** Hands the package its transport. Call once, at start-up; a later call replaces it. */
|
|
24
|
+
export function configureVaultWeb(options) {
|
|
25
|
+
config = { http: options.http, apiBaseUrl: options.apiBaseUrl ?? '/api' };
|
|
26
|
+
}
|
|
27
|
+
/** The configured client. Throws {@link VaultWebNotConfiguredError} before {@link configureVaultWeb}. */
|
|
28
|
+
export function getVaultHttp() {
|
|
29
|
+
if (!config)
|
|
30
|
+
throw new VaultWebNotConfiguredError();
|
|
31
|
+
return config.http;
|
|
32
|
+
}
|
|
33
|
+
/** The configured API base URL (`/api` by default). */
|
|
34
|
+
export function getVaultApiBaseUrl() {
|
|
35
|
+
if (!config)
|
|
36
|
+
throw new VaultWebNotConfiguredError();
|
|
37
|
+
return config.apiBaseUrl;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The configured client, resolved on every member access, so call sites keep
|
|
41
|
+
* writing `api.get(...)` and a module may import it before the host configures
|
|
42
|
+
* the package.
|
|
43
|
+
*/
|
|
44
|
+
export const api = new Proxy({}, {
|
|
45
|
+
get(_target, prop) {
|
|
46
|
+
const client = getVaultHttp();
|
|
47
|
+
const value = Reflect.get(client, prop, client);
|
|
48
|
+
return typeof value === 'function' ? value.bind(client) : value;
|
|
49
|
+
},
|
|
50
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './api.js';
|
|
2
|
+
export * from './cardScanAvailability.js';
|
|
3
|
+
export * from './clipboard.js';
|
|
4
|
+
export * from './http.js';
|
|
5
|
+
export * from './relativeTime.js';
|
|
6
|
+
export * from './saveBlob.js';
|
|
7
|
+
export * from './types.js';
|
|
8
|
+
export * from './useAiStatus.js';
|
|
9
|
+
export * from './useCopyToClipboard.js';
|
|
10
|
+
export * from './useDashboardResource.js';
|
|
11
|
+
export * from './useSystemSettings.js';
|
|
12
|
+
export * from './useUserSettings.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// The host-neutral half of the `core` slice: the HTTP port (`configureVaultWeb`), the domain calls, the wire types and the hooks and helpers every slice uses. No component.
|
|
2
|
+
export * from './api.js';
|
|
3
|
+
export * from './cardScanAvailability.js';
|
|
4
|
+
export * from './clipboard.js';
|
|
5
|
+
export * from './http.js';
|
|
6
|
+
export * from './relativeTime.js';
|
|
7
|
+
export * from './saveBlob.js';
|
|
8
|
+
export * from './types.js';
|
|
9
|
+
export * from './useAiStatus.js';
|
|
10
|
+
export * from './useCopyToClipboard.js';
|
|
11
|
+
export * from './useDashboardResource.js';
|
|
12
|
+
export * from './useSystemSettings.js';
|
|
13
|
+
export * from './useUserSettings.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compact relative time ("5m ago", "in 3h") for dashboard rows.
|
|
3
|
+
*
|
|
4
|
+
* `now` is injectable so a whole panel formats against one instant and tests
|
|
5
|
+
* stay deterministic. Invalid input yields an empty string, never "NaN ago".
|
|
6
|
+
*/
|
|
7
|
+
export declare function formatRelativeTime(iso: string | null | undefined, now?: Date): string;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compact relative time ("5m ago", "in 3h") for dashboard rows.
|
|
3
|
+
*
|
|
4
|
+
* `now` is injectable so a whole panel formats against one instant and tests
|
|
5
|
+
* stay deterministic. Invalid input yields an empty string, never "NaN ago".
|
|
6
|
+
*/
|
|
7
|
+
export function formatRelativeTime(iso, now = new Date()) {
|
|
8
|
+
if (!iso)
|
|
9
|
+
return '';
|
|
10
|
+
const date = new Date(iso);
|
|
11
|
+
const diffMs = now.getTime() - date.getTime();
|
|
12
|
+
if (Number.isNaN(diffMs))
|
|
13
|
+
return '';
|
|
14
|
+
const future = diffMs < 0;
|
|
15
|
+
const minutes = Math.floor(Math.abs(diffMs) / 60000);
|
|
16
|
+
const wrap = (value) => (future ? `in ${value}` : `${value} ago`);
|
|
17
|
+
if (minutes < 1)
|
|
18
|
+
return future ? 'in under a minute' : 'just now';
|
|
19
|
+
if (minutes < 60)
|
|
20
|
+
return wrap(`${minutes}m`);
|
|
21
|
+
const hours = Math.floor(minutes / 60);
|
|
22
|
+
if (hours < 24)
|
|
23
|
+
return wrap(`${hours}h`);
|
|
24
|
+
const days = Math.floor(hours / 24);
|
|
25
|
+
if (days < 30)
|
|
26
|
+
return wrap(`${days}d`);
|
|
27
|
+
return date.toLocaleDateString(undefined, { month: 'short', day: 'numeric' });
|
|
28
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trigger a browser download of an in-memory Blob under `filename`.
|
|
3
|
+
* The object URL is revoked on the next tick, after the click has been
|
|
4
|
+
* dispatched, so the blob can be garbage collected.
|
|
5
|
+
*/
|
|
6
|
+
export declare function saveBlobAsFile(blob: Blob, filename: string): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trigger a browser download of an in-memory Blob under `filename`.
|
|
3
|
+
* The object URL is revoked on the next tick, after the click has been
|
|
4
|
+
* dispatched, so the blob can be garbage collected.
|
|
5
|
+
*/
|
|
6
|
+
export function saveBlobAsFile(blob, filename) {
|
|
7
|
+
const url = URL.createObjectURL(blob);
|
|
8
|
+
const link = document.createElement('a');
|
|
9
|
+
link.href = url;
|
|
10
|
+
link.download = filename;
|
|
11
|
+
link.rel = 'noopener';
|
|
12
|
+
link.style.display = 'none';
|
|
13
|
+
document.body.appendChild(link);
|
|
14
|
+
try {
|
|
15
|
+
link.click();
|
|
16
|
+
}
|
|
17
|
+
finally {
|
|
18
|
+
document.body.removeChild(link);
|
|
19
|
+
setTimeout(() => URL.revokeObjectURL(url), 0);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
import type { AttachmentRole, SecretAgentAccess } from '@marinoscar/vault-contract/secrets';
|
|
2
|
+
export type { SecretAgentAccess };
|
|
3
|
+
import type { BackupFrequency, BackupRunStatus, BackupRunTrigger } from '@marinoscar/vault-contract/backups';
|
|
4
|
+
export interface Role {
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
export interface User {
|
|
8
|
+
id: string;
|
|
9
|
+
email: string;
|
|
10
|
+
displayName: string | null;
|
|
11
|
+
profileImageUrl: string | null;
|
|
12
|
+
roles: Role[];
|
|
13
|
+
permissions: string[];
|
|
14
|
+
isActive: boolean;
|
|
15
|
+
createdAt: string;
|
|
16
|
+
}
|
|
17
|
+
export interface UserSettings {
|
|
18
|
+
theme: 'light' | 'dark' | 'system';
|
|
19
|
+
profile: {
|
|
20
|
+
displayName?: string;
|
|
21
|
+
useProviderImage: boolean;
|
|
22
|
+
customImageUrl?: string | null;
|
|
23
|
+
};
|
|
24
|
+
updatedAt: string;
|
|
25
|
+
version: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The `ai` namespace of `GET /api/system-settings` (E8.1, #87): the platform AI
|
|
29
|
+
* slice's policy (`enabled`, `keyPolicy`, `providers`, `limits`, `defaults`, ...)
|
|
30
|
+
* plus Vault's one extension, `cardExtractModel`, the model `card_extract` runs on.
|
|
31
|
+
*
|
|
32
|
+
* Only the two fields Vault's own UI reads are typed; the rest of the policy is
|
|
33
|
+
* edited on the packaged AI page (`PUT /api/admin/ai/config`) and passed through
|
|
34
|
+
* untouched. No field here can hold a provider key: keys are credentials, set and
|
|
35
|
+
* cleared only through `/api/admin/ai/*`, and never returned.
|
|
36
|
+
*/
|
|
37
|
+
export interface VaultAiPolicy {
|
|
38
|
+
enabled: boolean;
|
|
39
|
+
cardExtractModel: string;
|
|
40
|
+
[field: string]: unknown;
|
|
41
|
+
}
|
|
42
|
+
/** Bounds of `ai.cardExtractModel` (`vaultAiExtensionSchema` in the API). */
|
|
43
|
+
export declare const CARD_EXTRACT_MODEL_MAX_LENGTH = 128;
|
|
44
|
+
/**
|
|
45
|
+
* Error codes `POST /api/secrets/cards/extract` answers with, defined once in
|
|
46
|
+
* `@marinoscar/vault-contract/errors` (`AI_ERROR_CODES`). Client code branches on
|
|
47
|
+
* `code` first and falls back to `status` (see `describeCardExtractionError` in
|
|
48
|
+
* `hooks/useCardImport.ts`).
|
|
49
|
+
*
|
|
50
|
+
* `AI_NOT_CONFIGURED` (503) means AI is on but the provider, model or key is not
|
|
51
|
+
* set up. AI switched OFF is a different answer: the platform kill switch
|
|
52
|
+
* (`AiEnabledGuard`) refuses with `403`, top-level code `FORBIDDEN` and
|
|
53
|
+
* `details.reason` {@link AI_DISABLED_REASON}.
|
|
54
|
+
*/
|
|
55
|
+
export { AI_ERROR_CODES, type AiErrorCode } from '@marinoscar/vault-contract/errors';
|
|
56
|
+
/** `details.reason` of the platform kill switch's `403` (AI switched off). */
|
|
57
|
+
export declare const AI_DISABLED_REASON = "AI_DISABLED";
|
|
58
|
+
/**
|
|
59
|
+
* Fields the extraction endpoint can return, mirroring `EXTRACTED_FIELD_NAMES`
|
|
60
|
+
* in the API.
|
|
61
|
+
*
|
|
62
|
+
* `notes` is auxiliary text read off the card that fits no structured field —
|
|
63
|
+
* support phone numbers, "Member Since", usage instructions — and seeds the
|
|
64
|
+
* review form's Notes input.
|
|
65
|
+
*
|
|
66
|
+
* `cvv` and `security_code_2` stay in the list because the response shape keeps
|
|
67
|
+
* them, but since E8.1 (#87) they are ALWAYS `null` with confidence 0: the model
|
|
68
|
+
* is told not to read a security code, its schema has no field for one, and the
|
|
69
|
+
* API forces both to null. The review form never seeds them; the user types them.
|
|
70
|
+
*/
|
|
71
|
+
export declare const EXTRACTED_CARD_FIELD_NAMES: readonly ["cardholder_name", "number", "exp_month", "exp_year", "cvv", "card_network", "card_kind", "issuing_bank", "security_code_2", "notes"];
|
|
72
|
+
export type ExtractedCardFieldName = (typeof EXTRACTED_CARD_FIELD_NAMES)[number];
|
|
73
|
+
/**
|
|
74
|
+
* Body of `POST /api/secrets/cards/extract`: FULL, uncropped photos as base64
|
|
75
|
+
* data URLs (downscaled client-side only when very large — see
|
|
76
|
+
* `prepareCardPhoto` in `utils/cardImage.ts`). The model locates the card in
|
|
77
|
+
* each frame and reports where in {@link CardExtractionResult.crops}; the
|
|
78
|
+
* client crops the stored attachment from those boxes afterwards. The full
|
|
79
|
+
* photos go to the AI only — they are never uploaded to storage.
|
|
80
|
+
*/
|
|
81
|
+
export interface ExtractCardRequest {
|
|
82
|
+
front: string;
|
|
83
|
+
back?: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Where the model found the card in one submitted photo.
|
|
87
|
+
*
|
|
88
|
+
* `x`/`y`/`width`/`height` are fractions (0-1) of the image EXACTLY as it was
|
|
89
|
+
* sent — they apply to the prepared (possibly downscaled) photo, and equally
|
|
90
|
+
* to the raw capture, since fractions survive uniform scaling.
|
|
91
|
+
*/
|
|
92
|
+
export interface CardCropBox {
|
|
93
|
+
x: number;
|
|
94
|
+
y: number;
|
|
95
|
+
width: number;
|
|
96
|
+
height: number;
|
|
97
|
+
/** Clockwise 90° rotations (0-3) that make the card upright. */
|
|
98
|
+
quarterTurns: number;
|
|
99
|
+
/** 0-1 confidence that the box tightly bounds a card. */
|
|
100
|
+
confidence: number;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Response of `POST /api/secrets/cards/extract`.
|
|
104
|
+
*
|
|
105
|
+
* Nothing here is persisted server-side — the values exist only in this
|
|
106
|
+
* response until the user confirms them on the review step.
|
|
107
|
+
*/
|
|
108
|
+
export interface CardExtractionResult {
|
|
109
|
+
fields: Record<ExtractedCardFieldName, string | null>;
|
|
110
|
+
/** 0..1 per field; 0 whenever the field came back null. */
|
|
111
|
+
confidence: Record<ExtractedCardFieldName, number>;
|
|
112
|
+
warnings: string[];
|
|
113
|
+
model: string;
|
|
114
|
+
/** True when the call succeeded but nothing legible came back. */
|
|
115
|
+
partial: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Card locations, one per submitted side. A side is `null` when no image
|
|
118
|
+
* was sent for it or no card was visible in the frame.
|
|
119
|
+
*/
|
|
120
|
+
crops: {
|
|
121
|
+
front: CardCropBox | null;
|
|
122
|
+
back: CardCropBox | null;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/** The `agentAccess` system settings namespace (same shape as `@marinoscar/vault-contract/agent`). */
|
|
126
|
+
export interface AgentAccessSettings {
|
|
127
|
+
enabled: boolean;
|
|
128
|
+
lookupPerMinute: number;
|
|
129
|
+
fillPerMinute: number;
|
|
130
|
+
totpPerMinute: number;
|
|
131
|
+
writePerMinute: number;
|
|
132
|
+
}
|
|
133
|
+
/** What the API answers until an administrator changes it: off, with the default limits. */
|
|
134
|
+
export declare const AGENT_ACCESS_DEFAULTS: AgentAccessSettings;
|
|
135
|
+
export interface SystemSettings {
|
|
136
|
+
ui: {
|
|
137
|
+
allowUserThemeOverride: boolean;
|
|
138
|
+
};
|
|
139
|
+
features: Record<string, boolean>;
|
|
140
|
+
/** The platform AI policy plus `cardExtractModel`; `null` only before the first read. */
|
|
141
|
+
ai: VaultAiPolicy | null;
|
|
142
|
+
/** The agent credential API's kill switch and limits (E14.6); absent from an older API. */
|
|
143
|
+
agentAccess?: AgentAccessSettings;
|
|
144
|
+
updatedAt: string;
|
|
145
|
+
updatedBy: {
|
|
146
|
+
id: string;
|
|
147
|
+
email: string;
|
|
148
|
+
} | null;
|
|
149
|
+
version: number;
|
|
150
|
+
}
|
|
151
|
+
export interface FieldDefinition {
|
|
152
|
+
name: string;
|
|
153
|
+
label: string;
|
|
154
|
+
type: 'string' | 'number' | 'date' | 'select';
|
|
155
|
+
required: boolean;
|
|
156
|
+
sensitive: boolean;
|
|
157
|
+
/** Allowed values; only meaningful when type is 'select'. */
|
|
158
|
+
options?: string[];
|
|
159
|
+
}
|
|
160
|
+
export interface SecretType {
|
|
161
|
+
id: string;
|
|
162
|
+
name: string;
|
|
163
|
+
description: string | null;
|
|
164
|
+
icon: string | null;
|
|
165
|
+
fields: FieldDefinition[];
|
|
166
|
+
allowAttachments: boolean;
|
|
167
|
+
isSystem: boolean;
|
|
168
|
+
createdAt: string;
|
|
169
|
+
}
|
|
170
|
+
export interface SecretListItem {
|
|
171
|
+
id: string;
|
|
172
|
+
name: string;
|
|
173
|
+
description: string | null;
|
|
174
|
+
type: SecretType;
|
|
175
|
+
currentVersion: number;
|
|
176
|
+
createdAt: string;
|
|
177
|
+
updatedAt: string;
|
|
178
|
+
/** Whether agents may use this secret (`none` by default). */
|
|
179
|
+
agentAccess: SecretAgentAccess;
|
|
180
|
+
agentAccessChangedAt: string | null;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Role of an attachment within its secret version, mirroring
|
|
184
|
+
* `attachmentRoleSchema` in the API. `null` is a generic attachment, of which a
|
|
185
|
+
* version may have many; a role-bearing attachment is unique per version.
|
|
186
|
+
*/
|
|
187
|
+
export type { AttachmentRole } from '@marinoscar/vault-contract/secrets';
|
|
188
|
+
export interface SecretAttachment {
|
|
189
|
+
id: string;
|
|
190
|
+
label: string | null;
|
|
191
|
+
/** `null` for generic (role-less) attachments. */
|
|
192
|
+
role: AttachmentRole | null;
|
|
193
|
+
storageObject: {
|
|
194
|
+
id: string;
|
|
195
|
+
name: string;
|
|
196
|
+
mimeType: string;
|
|
197
|
+
size: number;
|
|
198
|
+
};
|
|
199
|
+
createdAt: string;
|
|
200
|
+
}
|
|
201
|
+
export interface SecretDetail extends SecretListItem {
|
|
202
|
+
values: Record<string, unknown>;
|
|
203
|
+
createdBy: {
|
|
204
|
+
id: string;
|
|
205
|
+
email: string;
|
|
206
|
+
} | null;
|
|
207
|
+
attachments: SecretAttachment[];
|
|
208
|
+
}
|
|
209
|
+
export interface SecretVersion {
|
|
210
|
+
id: string;
|
|
211
|
+
version: number;
|
|
212
|
+
createdAt: string;
|
|
213
|
+
createdBy: {
|
|
214
|
+
id: string;
|
|
215
|
+
email: string;
|
|
216
|
+
} | null;
|
|
217
|
+
isCurrent: boolean;
|
|
218
|
+
}
|
|
219
|
+
export interface SecretVersionDetail extends SecretVersion {
|
|
220
|
+
values: Record<string, unknown>;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* One file supplied with a renewal, mirroring `renewAttachmentSchema` in the
|
|
224
|
+
* API.
|
|
225
|
+
*
|
|
226
|
+
* A role-bearing entry REPLACES the same-role file on the outgoing version; a
|
|
227
|
+
* role-less entry is simply added. Anything whose role is absent from the
|
|
228
|
+
* request is carried forward onto the new version untouched, which is what
|
|
229
|
+
* keeps the old card's photos viewable in its own version.
|
|
230
|
+
*/
|
|
231
|
+
export interface RenewSecretAttachment {
|
|
232
|
+
storageObjectId: string;
|
|
233
|
+
role?: AttachmentRole;
|
|
234
|
+
label?: string;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Body of `POST /api/secrets/:id/renew`, mirroring `renewSecretSchema`.
|
|
238
|
+
*
|
|
239
|
+
* `data` is a REPLACEMENT, not a patch: the API validates it against the whole
|
|
240
|
+
* secret type exactly as `PUT /secrets/:id` does, so every field the renewed
|
|
241
|
+
* secret should keep must be present — including the ones the user did not
|
|
242
|
+
* change. Sending a partial object silently drops the omitted fields from the
|
|
243
|
+
* new version.
|
|
244
|
+
*/
|
|
245
|
+
export interface RenewSecretRequest {
|
|
246
|
+
data: Record<string, string>;
|
|
247
|
+
attachments?: RenewSecretAttachment[];
|
|
248
|
+
/**
|
|
249
|
+
* Whether the values were read off a photo by the AI rather than typed.
|
|
250
|
+
*
|
|
251
|
+
* Recorded in the audit trail as `extractionMethod` and nothing else — it has
|
|
252
|
+
* no effect on validation or on what is stored. It exists so an AI-assisted
|
|
253
|
+
* renewal can be told apart from a manual one after the fact, so it must
|
|
254
|
+
* report what actually happened rather than whether AI was merely available.
|
|
255
|
+
*/
|
|
256
|
+
aiAssisted?: boolean;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Response of `POST /api/secrets/:id/renew`: the secret as it now stands, at
|
|
260
|
+
* its new current version. Shape-identical to `GET /api/secrets/:id`.
|
|
261
|
+
*/
|
|
262
|
+
export type RenewSecretResponse = SecretDetail;
|
|
263
|
+
export interface SecretsResponse {
|
|
264
|
+
items: SecretListItem[];
|
|
265
|
+
meta: {
|
|
266
|
+
page: number;
|
|
267
|
+
pageSize: number;
|
|
268
|
+
totalItems: number;
|
|
269
|
+
totalPages: number;
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* One card from `GET /api/secrets/cards/summary` (#118): decrypted server-side
|
|
274
|
+
* down to the last four digits and the expiry. Never the CVV or the full
|
|
275
|
+
* number. A malformed card comes back with null fields.
|
|
276
|
+
*/
|
|
277
|
+
export interface CardSummaryItem {
|
|
278
|
+
id: string;
|
|
279
|
+
name: string;
|
|
280
|
+
last4: string | null;
|
|
281
|
+
expMonth: number | null;
|
|
282
|
+
expYear: number | null;
|
|
283
|
+
/** Issuing network, e.g. 'Visa'; null when not stored. */
|
|
284
|
+
network: string | null;
|
|
285
|
+
/** 'Credit' / 'Debit'; null when not stored. */
|
|
286
|
+
kind: string | null;
|
|
287
|
+
issuingBank: string | null;
|
|
288
|
+
cardholderName: string | null;
|
|
289
|
+
/** True when the current version has card photos attached. */
|
|
290
|
+
hasPhotos: boolean;
|
|
291
|
+
updatedAt: string;
|
|
292
|
+
}
|
|
293
|
+
/** A page of card summaries, soonest expiry first, unknown expiry last. */
|
|
294
|
+
export interface CardSummaryResponse {
|
|
295
|
+
items: CardSummaryItem[];
|
|
296
|
+
meta: {
|
|
297
|
+
page: number;
|
|
298
|
+
pageSize: number;
|
|
299
|
+
totalItems: number;
|
|
300
|
+
totalPages: number;
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
export interface MediaFolder {
|
|
304
|
+
id: string;
|
|
305
|
+
name: string;
|
|
306
|
+
userId: string;
|
|
307
|
+
fileCount: number;
|
|
308
|
+
createdAt: string;
|
|
309
|
+
updatedAt: string;
|
|
310
|
+
}
|
|
311
|
+
export interface MediaFoldersResponse {
|
|
312
|
+
items: MediaFolder[];
|
|
313
|
+
meta: {
|
|
314
|
+
page: number;
|
|
315
|
+
pageSize: number;
|
|
316
|
+
totalItems: number;
|
|
317
|
+
totalPages: number;
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
export interface MediaFile {
|
|
321
|
+
id: string;
|
|
322
|
+
name: string;
|
|
323
|
+
size: number;
|
|
324
|
+
mimeType: string;
|
|
325
|
+
status: string;
|
|
326
|
+
metadata: Record<string, unknown> | null;
|
|
327
|
+
createdAt: string;
|
|
328
|
+
updatedAt: string;
|
|
329
|
+
}
|
|
330
|
+
export interface MediaFilesResponse {
|
|
331
|
+
items: MediaFile[];
|
|
332
|
+
meta: {
|
|
333
|
+
page: number;
|
|
334
|
+
pageSize: number;
|
|
335
|
+
totalItems: number;
|
|
336
|
+
totalPages: number;
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
export type { BackupFrequency, BackupRunStatus, BackupRunTrigger, } from '@marinoscar/vault-contract/backups';
|
|
340
|
+
/** Editable fields of the backup schedule (PUT /admin/backups/schedule). */
|
|
341
|
+
export interface BackupScheduleFields {
|
|
342
|
+
enabled: boolean;
|
|
343
|
+
frequency: BackupFrequency;
|
|
344
|
+
/** Hourly only: 1, 2, 3, 4, 6, 8 or 12. */
|
|
345
|
+
intervalHours: number | null;
|
|
346
|
+
/** 'HH:mm' wall-clock time in `timezone` (daily, weekly, monthly). */
|
|
347
|
+
timeOfDay: string;
|
|
348
|
+
/** Weekly only: 0-6, 0 = Sunday. */
|
|
349
|
+
dayOfWeek: number | null;
|
|
350
|
+
/** Monthly only: 1-28. */
|
|
351
|
+
dayOfMonth: number | null;
|
|
352
|
+
/** IANA time zone. */
|
|
353
|
+
timezone: string;
|
|
354
|
+
/** How many successful backups to keep (1-365). */
|
|
355
|
+
keepCount: number;
|
|
356
|
+
/** Back up every user's current secret values. */
|
|
357
|
+
includeSecrets: boolean;
|
|
358
|
+
/** Requires includeSecrets. */
|
|
359
|
+
includeAttachments: boolean;
|
|
360
|
+
/** Requires includeSecrets. */
|
|
361
|
+
includeVersions: boolean;
|
|
362
|
+
/** Every user's media library (folders and files). */
|
|
363
|
+
includeMedia: boolean;
|
|
364
|
+
/** Users and roles, allowlist, custom secret types, redacted system settings. */
|
|
365
|
+
includeSystem: boolean;
|
|
366
|
+
}
|
|
367
|
+
/** GET/PUT /admin/backups/schedule response. Never carries the password. */
|
|
368
|
+
export interface BackupSchedule extends BackupScheduleFields {
|
|
369
|
+
passwordConfigured: boolean;
|
|
370
|
+
passwordUpdatedAt: string | null;
|
|
371
|
+
nextRunAt: string | null;
|
|
372
|
+
lastRunAt: string | null;
|
|
373
|
+
storageConfigured: boolean;
|
|
374
|
+
/** Null when no schedule has been saved yet (server defaults). */
|
|
375
|
+
updatedAt: string | null;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* PUT body. `password` is write-only: omit it to keep the stored password,
|
|
379
|
+
* send a 6-256 character string to replace it.
|
|
380
|
+
*/
|
|
381
|
+
export interface UpdateBackupScheduleRequest extends BackupScheduleFields {
|
|
382
|
+
password?: string;
|
|
383
|
+
}
|
|
384
|
+
export interface BackupRun {
|
|
385
|
+
id: string;
|
|
386
|
+
status: BackupRunStatus;
|
|
387
|
+
trigger: BackupRunTrigger;
|
|
388
|
+
triggeredBy: {
|
|
389
|
+
id: string;
|
|
390
|
+
email: string;
|
|
391
|
+
displayName: string | null;
|
|
392
|
+
} | null;
|
|
393
|
+
sizeBytes: number | null;
|
|
394
|
+
userCount: number;
|
|
395
|
+
secretCount: number;
|
|
396
|
+
attachmentCount: number;
|
|
397
|
+
mediaFileCount: number;
|
|
398
|
+
/**
|
|
399
|
+
* Content keys selected for this run: 'secrets', 'attachments',
|
|
400
|
+
* 'versions', 'media', 'system'. Empty for runs from before the choice existed.
|
|
401
|
+
*/
|
|
402
|
+
contents: string[];
|
|
403
|
+
warningCount: number;
|
|
404
|
+
error: string | null;
|
|
405
|
+
startedAt: string;
|
|
406
|
+
finishedAt: string | null;
|
|
407
|
+
deletedAt: string | null;
|
|
408
|
+
/** succeeded && !deletedAt */
|
|
409
|
+
downloadable: boolean;
|
|
410
|
+
}
|
|
411
|
+
export interface BackupRunsResponse {
|
|
412
|
+
items: BackupRun[];
|
|
413
|
+
total: number;
|
|
414
|
+
page: number;
|
|
415
|
+
pageSize: number;
|
|
416
|
+
totalPages: number;
|
|
417
|
+
}
|
|
418
|
+
export interface BackupDownloadLink {
|
|
419
|
+
url: string;
|
|
420
|
+
expiresAt: string;
|
|
421
|
+
fileName: string;
|
|
422
|
+
}
|
|
423
|
+
/** GET /backups/me/config: whether "Save to the storage account" can be offered. */
|
|
424
|
+
export interface MyBackupsConfig {
|
|
425
|
+
storageConfigured: boolean;
|
|
426
|
+
/** How many saved backups are kept per user (newest first). */
|
|
427
|
+
keepCount: number;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* POST /admin/backups/export body. Exactly one of `password` (6-256
|
|
431
|
+
* characters) or `useScheduledPassword: true` is sent.
|
|
432
|
+
*/
|
|
433
|
+
export interface AdminBackupExportRequest {
|
|
434
|
+
password?: string;
|
|
435
|
+
useScheduledPassword?: boolean;
|
|
436
|
+
includeSecrets: boolean;
|
|
437
|
+
includeAttachments: boolean;
|
|
438
|
+
includeVersions: boolean;
|
|
439
|
+
includeMedia: boolean;
|
|
440
|
+
includeSystem: boolean;
|
|
441
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** Bounds of `ai.cardExtractModel` (`vaultAiExtensionSchema` in the API). */
|
|
2
|
+
export const CARD_EXTRACT_MODEL_MAX_LENGTH = 128;
|
|
3
|
+
/**
|
|
4
|
+
* Error codes `POST /api/secrets/cards/extract` answers with, defined once in
|
|
5
|
+
* `@marinoscar/vault-contract/errors` (`AI_ERROR_CODES`). Client code branches on
|
|
6
|
+
* `code` first and falls back to `status` (see `describeCardExtractionError` in
|
|
7
|
+
* `hooks/useCardImport.ts`).
|
|
8
|
+
*
|
|
9
|
+
* `AI_NOT_CONFIGURED` (503) means AI is on but the provider, model or key is not
|
|
10
|
+
* set up. AI switched OFF is a different answer: the platform kill switch
|
|
11
|
+
* (`AiEnabledGuard`) refuses with `403`, top-level code `FORBIDDEN` and
|
|
12
|
+
* `details.reason` {@link AI_DISABLED_REASON}.
|
|
13
|
+
*/
|
|
14
|
+
export { AI_ERROR_CODES } from '@marinoscar/vault-contract/errors';
|
|
15
|
+
/** `details.reason` of the platform kill switch's `403` (AI switched off). */
|
|
16
|
+
export const AI_DISABLED_REASON = 'AI_DISABLED';
|
|
17
|
+
/**
|
|
18
|
+
* Fields the extraction endpoint can return, mirroring `EXTRACTED_FIELD_NAMES`
|
|
19
|
+
* in the API.
|
|
20
|
+
*
|
|
21
|
+
* `notes` is auxiliary text read off the card that fits no structured field —
|
|
22
|
+
* support phone numbers, "Member Since", usage instructions — and seeds the
|
|
23
|
+
* review form's Notes input.
|
|
24
|
+
*
|
|
25
|
+
* `cvv` and `security_code_2` stay in the list because the response shape keeps
|
|
26
|
+
* them, but since E8.1 (#87) they are ALWAYS `null` with confidence 0: the model
|
|
27
|
+
* is told not to read a security code, its schema has no field for one, and the
|
|
28
|
+
* API forces both to null. The review form never seeds them; the user types them.
|
|
29
|
+
*/
|
|
30
|
+
export const EXTRACTED_CARD_FIELD_NAMES = [
|
|
31
|
+
'cardholder_name',
|
|
32
|
+
'number',
|
|
33
|
+
'exp_month',
|
|
34
|
+
'exp_year',
|
|
35
|
+
'cvv',
|
|
36
|
+
'card_network',
|
|
37
|
+
'card_kind',
|
|
38
|
+
'issuing_bank',
|
|
39
|
+
'security_code_2',
|
|
40
|
+
'notes',
|
|
41
|
+
];
|
|
42
|
+
/** What the API answers until an administrator changes it: off, with the default limits. */
|
|
43
|
+
export const AGENT_ACCESS_DEFAULTS = {
|
|
44
|
+
enabled: false,
|
|
45
|
+
lookupPerMinute: 60,
|
|
46
|
+
fillPerMinute: 30,
|
|
47
|
+
totpPerMinute: 10,
|
|
48
|
+
writePerMinute: 10,
|
|
49
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { AiPublicConfig } from '@marinoscar/platform-web/ai/headless';
|
|
2
|
+
interface UseAiStatusResult {
|
|
3
|
+
/**
|
|
4
|
+
* The platform's public AI config (`GET /api/ai/config`). Never null: until the
|
|
5
|
+
* first answer, and when it failed, it is the platform's "AI off" answer.
|
|
6
|
+
*/
|
|
7
|
+
config: AiPublicConfig;
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
/** Set when the config call itself failed, not when AI is merely disabled. */
|
|
10
|
+
error: string | null;
|
|
11
|
+
/**
|
|
12
|
+
* True only when card extraction is actually usable BY THIS VIEWER: card
|
|
13
|
+
* scanning is available (`isCardScanAvailable`: AI on, the deployment's OpenAI
|
|
14
|
+
* key serving everyone) and the viewer holds `ai:use` (the extract route needs
|
|
15
|
+
* it; a Viewer does not hold it, so the scan entry points stay hidden).
|
|
16
|
+
*/
|
|
17
|
+
cardExtractEnabled: boolean;
|
|
18
|
+
/** The viewer holds `ai:use` (independent of whether AI is switched on). */
|
|
19
|
+
canUseAi: boolean;
|
|
20
|
+
refresh: () => Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Whether AI-backed features are available to the current user.
|
|
24
|
+
*
|
|
25
|
+
* Reads the platform's `GET /api/ai/config` through `useAiConfig`
|
|
26
|
+
* (`@marinoscar/platform-web/ai/headless`): the shell's shared copy when the host
|
|
27
|
+
* mounts an `AiConfigContext` provider (apps/web's `VaultAiConfigProvider`), so no
|
|
28
|
+
* second request is made; otherwise its own fetch through this package's client.
|
|
29
|
+
* Card-scan availability is derived on the client with the server's rule
|
|
30
|
+
* (`isCardScanAvailable`).
|
|
31
|
+
*
|
|
32
|
+
* FAILS CLOSED. A network error, a 500, or a malformed body all resolve to
|
|
33
|
+
* "not enabled". Gating an entry point on this hook must never open the gate
|
|
34
|
+
* because the check itself broke — the alternative is offering a card scan that
|
|
35
|
+
* can only end in an error the user cannot act on.
|
|
36
|
+
*
|
|
37
|
+
* The UI presents, the API authorizes: hiding the scan option from a caller
|
|
38
|
+
* without `ai:use` saves them a 403, it is not the gate.
|
|
39
|
+
*/
|
|
40
|
+
export declare function useAiStatus(): UseAiStatusResult;
|
|
41
|
+
export {};
|