@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
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# @marinoscar/vault-web
|
|
2
|
+
|
|
3
|
+
## 0.1.0-next.4
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- ffd128f: Agent release of payment cards and identity fields, with per-merchant rules (ADR-0003, #195).
|
|
8
|
+
|
|
9
|
+
- `@marinoscar/vault-contract`: card and identity agent schemas (`agentCardFillRequestSchema`, `agentCardSummarySchema`, `agentCardGrantRequestCreateSchema`, `agentIdentityFillRequestSchema`, `agentIdentitySummarySchema`), the owner's merchant grant and grant request shapes (`createCardGrantSchema`, `cardGrantSchema`, `cardGrantRequestSchema`), amount and currency schemas and helpers, scopes `vault:cards_read|fill` and `vault:identity_read|fill`, new error codes, the `cards` and `identity` blocks of the `agentAccess` settings (both off by default) with `resolveAgentAccessSettings`, the `Identity` system secret type and the Card's optional `billing_postal_code`.
|
|
10
|
+
- `@marinoscar/vault-db`: migration `add_agent_card_grants` (tables `agent_card_grants`, `agent_card_grant_requests`, `agent_card_releases`; column `secrets.agent_origins`).
|
|
11
|
+
- `@marinoscar/vault-api`: `AgentReleasePort` / `AGENT_RELEASE_PORT` / `AgentReleaseService`, the in-process port an embedding host calls, shared with the HTTP controllers; `AgentCallPipeline`; card routes (`GET /api/agent/v1/cards`, `POST /cards/:id/fill`, `POST /cards/:id/grant-requests`) and identity routes (`GET /identity`, `POST /identity/:id/fill`) with merchant grants (registrable-domain match, payment frames, amount and currency, period limit, per-card daily cap, security code flag), their own rate-limit buckets and kill switches; the owner's grant routes under `/api/secrets/:id/card-grants` and `/card-grant-requests` (browser session only); a Card or Identity can be opened to agents (browser session only) and an Identity takes allowed origins; card notifications and activity; permissions `agent_cards:*` and `agent_identity:*`.
|
|
12
|
+
- `@marinoscar/vault-web`: the card's Agent access panel (open or closed, merchant grants with limits and use, pending requests with Approve and Decline, the allow-a-shop form), the identity panel (open or closed, allowed websites), card and identity switches and limits on the Agent access settings page, and the new activity actions with amounts.
|
|
13
|
+
|
|
14
|
+
- e4ad39d: A stated and tested range of platform versions instead of one exact pre-release. `@marinoscar/vault-api` and `@marinoscar/vault-web` peer on `@marinoscar/platform-api`, `@marinoscar/platform-contract` and `@marinoscar/platform-web` `>=0.1.0-next.36 <=0.1.0-next.39`, the lowest and highest platform pre-release CI builds, typechecks and tests the packages against. `VaultApiModule.forRoot` now checks the installed `@marinoscar/platform-api` at boot and throws one error naming the installed and the supported versions when it is outside the range; `SUPPORTED_PLATFORM_RANGE`, `assertSupportedPlatform`, `readInstalledPlatformVersion`, `satisfiesRange` and `compareVersions` are exported from `@marinoscar/vault-api/core`. `@marinoscar/vault-db` adds `@marinoscar/platform-db` as a development dependency of its real-database test (no runtime change). Policy and compatibility table: docs/PACKAGES.md, "Platform compatibility".
|
|
15
|
+
- 218483b: Make the packages embeddable in a host that is not Vault (issue #194; guide: `docs/EMBEDDING.md`). `@marinoscar/vault-api`: a new optional `VAULT_HOST` binding (`host: { appUrl }`) replaces the backup and card-expiry notifications' reads of `APP_URL`; `vaultPermissionDeclarations(roleMapping)` gives Vault's default grants to a host's own roles; `VAULT_RESERVED_NAMES` and `findVaultNameCollisions` list and check every route prefix, permission resource, settings namespace, job, notification, template, OAuth scope, audit prefix and OpenAPI tag the packages own; `VAULT_USER_OWNED_MODELS`, `VAULT_MODEL_OWNERSHIP`, `VAULT_CARDS_SETTINGS_DEFAULTS` and `VAULT_BACKUPS_SETTINGS_DEFAULTS` move into `core`; `seedVaultSystemSecretTypes` (`/secret-types`) seeds the built-in types; `runVaultHostConformance` (`/testing`) is the host conformance kit. `@marinoscar/vault-db`: `checkVaultInstall` no longer defaults `databaseUrl` to `process.env.DATABASE_URL` and `runVaultDb` requires its context (the `vault-db` command passes both, unchanged). `@marinoscar/vault-web`: `configureVaultWeb` takes `productName` (default `Vault`), shown by the pages' copy.
|
|
16
|
+
|
|
17
|
+
## 0.1.0-next.3
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- d16fe7b: The package READMEs say how to install from npm (the `next` dist-tag, the peers, provenance) for the first published release (#192). No code change.
|
|
22
|
+
|
|
23
|
+
## 0.1.0-next.2
|
|
24
|
+
|
|
25
|
+
### Minor Changes
|
|
26
|
+
|
|
27
|
+
- 14f844c: Add the `agent` slice (`@marinoscar/vault-web/agent/headless` and `/agent/ui`): the per-user `AgentActivityPage` (what apps did with your logins, filterable, with a link to Connected apps) and the admin `AgentAccessSettingsPage` (the agent API's kill switch and per-minute limits). `SystemSettings` carries `agentAccess`.
|
|
28
|
+
- 60b975f: Add per-secret agent access to the secrets UI: an "Allow agents to use this login" switch on the Credential detail page, an "Agents" chip in the list and an "Agent access" filter (`?agent=fill|none`). `SecretListItem` carries `agentAccess` and `agentAccessChangedAt`; new `updateSecretAgentAccess` client and `useSecretDetail().setAgentAccess`.
|
|
29
|
+
- d85c2f9: Add authenticator codes (TOTP) to Credential secrets: the form validates a pasted `otpauth://` link or base32 key (and shows the API's field error), and the detail page has an "Authenticator code" card that fetches the code on demand (`POST /secrets/:id/totp`), shows it grouped with a countdown ring and a copy button, and refreshes it on expiry. New `getSecretTotp`, `useTotpCode`, `groupTotpCode`, `TotpCodeCard`, `TOTP_FIELD_NAME`, `fieldErrorsFromApiError`.
|
|
30
|
+
- 2318f0a: Card scanning availability now comes from the platform's `GET /api/ai/config` instead of the removed `GET /api/ai/status` alias. `useAiStatus` reads it through `useAiConfig` of `@marinoscar/platform-web/ai/headless` (the host's shared copy when one is mounted) and applies the new pure helper `isCardScanAvailable(config)`, the same rule as the API. Its result keeps `cardExtractEnabled`, `canUseAi`, `isLoading`, `error` and `refresh`; `status` is replaced by `config` (the platform's `AiPublicConfig`). Breaking: the exported `getAiStatus` and the `AiStatus` type are removed.
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- 92dae83: vault-api: the `agent` OAuth protected resource (`/api/agent/v1`) with the scopes `vault:items_read`, `vault:items_fill` and `vault:items_write` (`registerVaultAgentOAuth`, `./agent` export), the `secrets:fill` permission and `GET /api/agent/v1/whoami`. vault-web: `/oauth/consent` and `/oauth/error` are unowned routes.
|
|
35
|
+
- 1934687: Require `@marinoscar/platform-api`, `@marinoscar/platform-contract` and `@marinoscar/platform-web` `0.1.0-next.37` (peer and dev dependencies). No API change in the Vault packages.
|
|
36
|
+
- 7bb426b: The Secrets list's table layout no longer expects a host `DataTablePreferencesProvider`: without one it takes the platform datatable's default port, the `dataTables` namespace of `/api/user-settings` over the host's client (#153). Docs and the test harness follow; no runtime change for a host that still mounts a provider.
|
|
37
|
+
|
|
38
|
+
## 0.1.0-next.1
|
|
39
|
+
|
|
40
|
+
### Minor Changes
|
|
41
|
+
|
|
42
|
+
- 1486f4f: Add `@marinoscar/vault-web`: the Vault domain pages, components, hooks, navigation destinations and brand, moved out of `apps/web` (E12.3, #104).
|
|
43
|
+
|
|
44
|
+
## 0.1.0-next.0
|
|
45
|
+
|
|
46
|
+
- Initial version (E12.3, issue 104). The domain pages, components and hooks, the navigation destinations and the brand moved out of `apps/web` without a visual or behaviour change; see the README.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Oscar Marin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,99 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @marinoscar/vault-web
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The React side of the Vault domain: the pages, components and hooks of secrets, secret types, payment cards, media folders, backups and Home, Vault's own settings card pages, the navigation destinations and the brand (tokens, themes, mark). ESM only, `sideEffects: false`, one subpath per slice. `apps/web` is the host: it routes to these pages, mounts the providers and binds the platform ([ADR-0001](../../docs/decisions/0001-packages-first.md)).
|
|
4
|
+
|
|
5
|
+
## Purpose and scope
|
|
6
|
+
|
|
7
|
+
The package holds the domain's user interface written once, so a second host (a desktop edition, a kiosk build) mounts the same pages instead of copying them. It does not hold the shell, the routes, the settings registries or hubs, the identity, AI, telemetry, notification or database-backup bindings, the service worker or the Vite configuration: those are the host's. Platform slices (`DataTable`, `SettingsHub`, identity guards, the AI config page) come from `@marinoscar/platform-web`, never copied here.
|
|
8
|
+
|
|
9
|
+
Status: experimental. Introduced in E12.3 (issue 104) by moving the domain code out of `apps/web/src` with no visual or behaviour change (the visual baselines are unchanged); `apps/web` imports it from these subpaths.
|
|
10
|
+
|
|
11
|
+
Entry points (`<slice>/headless` holds hooks, calls and helpers; `<slice>/ui` holds components and pages; pages are named exports, `SecretsPage` and so on):
|
|
12
|
+
|
|
13
|
+
- `@marinoscar/vault-web`: the root, `VAULT_WEB_PACKAGE` only.
|
|
14
|
+
- `@marinoscar/vault-web/core/headless`: `configureVaultWeb` (the HTTP port), the domain calls (`getSecrets`, `getBackupSchedule`, ...), the wire types, `useCopyToClipboard`, `useDashboardResource`, `useAiStatus` (card scanning from the platform's `GET /api/ai/config`) with its pure rule `isCardScanAvailable`, `useSystemSettings`, `useUserSettings`, `saveBlobAsFile`, `formatRelativeTime`.
|
|
15
|
+
- `@marinoscar/vault-web/core/ui`: `LoadingSpinner`, `ErrorBoundary`, `SettingsPageFrame`, `StorageSettingsLink`.
|
|
16
|
+
- `@marinoscar/vault-web/secrets/headless`, `@marinoscar/vault-web/secrets/ui`: secrets and secret types (list, detail, create, edit, versions, attachments, the type builder and its pages).
|
|
17
|
+
- `@marinoscar/vault-web/cards/headless`, `@marinoscar/vault-web/cards/ui`: payment cards (Cards, scan import, renewal, the card-scanning model section and the AI settings page that carries it).
|
|
18
|
+
- `@marinoscar/vault-web/media/headless`, `@marinoscar/vault-web/media/ui`: media folders and files.
|
|
19
|
+
- `@marinoscar/vault-web/backups/headless`, `@marinoscar/vault-web/backups/ui`: scheduled (admin) and personal backups, the My backups and Backups settings pages.
|
|
20
|
+
- `@marinoscar/vault-web/agent/headless`: `getAgentActivity` (the caller's agent activity, `GET /api/agent-activity`), `useAgentActivity`, the `AgentActivityItem` type (local to the package until the contract type is imported), the query and page types, `AGENT_ACTIVITY_ACTIONS`, `AGENT_ACTION_LABELS`, `agentAppLabel`; the card grant client (ADR-0003: `listCardGrants`, `createCardGrant`, `revokeCardGrant`, `listCardGrantRequests`, `approveCardGrantRequest`, `declineCardGrantRequest`, `describeGrantLimits`, `cardGrantErrorMessage`) and `useCardGrants`. The `AgentAccessSettings` type and `AGENT_ACCESS_DEFAULTS` live in `core/headless`, not here.
|
|
21
|
+
- `@marinoscar/vault-web/agent/ui`: `AgentActivityPage` (route `/settings/agent-activity`, card permission `secrets:read`), `AgentActivityTable`, `AgentAccessSettingsPage` (route `/admin/settings/agent-access`, card permission `system_settings:read`; saving needs `system_settings:write`; reads and writes the `agentAccess` system-settings namespace, the card and identity switches included), and the ADR-0003 panels the secret detail page shows: `CardAgentAccessPanel` (open or closed, pending requests with Approve and Decline, the merchant grants with their limits and use, and `CardGrantDialog` to allow a shop) on a Card, `IdentityAgentAccessPanel` (open or closed, the websites for the sensitive fields) on an Identity.
|
|
22
|
+
- `@marinoscar/vault-web/home/headless`, `@marinoscar/vault-web/home/ui`: the Home dashboard.
|
|
23
|
+
- `@marinoscar/vault-web/settings/ui`: Vault's General, Profile and Appearance settings card pages.
|
|
24
|
+
- `@marinoscar/vault-web/brand`: `BRAND_TOKENS`, `PRODUCT_NAME`, `PRODUCT_TAGLINE`, `VAULT_THEMES`, `vaultLightTheme`, `vaultDarkTheme`, `contrastRatio`, `BrandLockup`, `VAULT_MARK_URL`.
|
|
25
|
+
- `@marinoscar/vault-web/brand/assets/vault-mark.png`: the mark image itself.
|
|
26
|
+
- `@marinoscar/vault-web/navigation`: `DESTINATIONS`, `DESTINATION_ROUTES`, `UNOWNED_ROUTES`, `owns`, `isDestinationVisible`.
|
|
27
|
+
|
|
28
|
+
## Install and peer dependencies
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install @marinoscar/vault-web@next @marinoscar/vault-contract@next
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Published to npm under the `next` dist-tag until 1.0, with a provenance attestation; the install, the dist-tag policy and the current publication status are in [docs/PACKAGES.md](../../docs/PACKAGES.md#installing-from-npm). npm 7 or later installs the peers below by itself; list them in the host's `package.json` to choose their versions. The package is ESM only.
|
|
35
|
+
|
|
36
|
+
Everything React and MUI is a peer, so the host keeps one copy of each (two Reacts or two MUI theme contexts break hooks and theming):
|
|
37
|
+
|
|
38
|
+
| Package | Range | Needed by |
|
|
39
|
+
|---|---|---|
|
|
40
|
+
| `react`, `react-dom` | `^19.2.7` | every slice |
|
|
41
|
+
| `react-router-dom` | `^7.17.0` | pages and navigation |
|
|
42
|
+
| `@mui/material`, `@mui/icons-material`, `@mui/utils` | `^9.1.0` / `^9.0.0` | every `ui` subpath and `brand` |
|
|
43
|
+
| `@marinoscar/platform-web` | `>=0.1.0-next.36 <=0.1.0-next.39`, the tested range in `peerDependencies` ([PACKAGES.md](../../docs/PACKAGES.md#platform-compatibility)) | the shell, identity, data table, settings and AI pieces the pages use |
|
|
44
|
+
| `@marinoscar/vault-contract` | `>=0.0.0-0 \|\| >=0.1.0-0` | wire constants and types |
|
|
45
|
+
|
|
46
|
+
The host's bundler must understand an image import (Vite does): `BrandLockup` imports the PNG next to it.
|
|
47
|
+
|
|
48
|
+
## Quick start
|
|
49
|
+
|
|
50
|
+
```tsx
|
|
51
|
+
// The host, once, before the first render (apps/web/src/services/api.ts).
|
|
52
|
+
import { PlatformHttpClient } from '@marinoscar/platform-web/core';
|
|
53
|
+
import { configureVaultWeb } from '@marinoscar/vault-web/core/headless';
|
|
54
|
+
|
|
55
|
+
export const api = new PlatformHttpClient({ baseUrl: '/api', refreshLockName: 'vault-auth-refresh' });
|
|
56
|
+
configureVaultWeb({ http: api, apiBaseUrl: '/api' });
|
|
57
|
+
|
|
58
|
+
// A route (apps/web/src/App.tsx).
|
|
59
|
+
const SecretsPage = lazy(() => import('@marinoscar/vault-web/secrets/ui').then((m) => ({ default: m.SecretsPage })));
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The pages expect what the host mounts above them: a router, `ShellRoot` with `VAULT_THEMES`, the platform identity `AuthProvider` (for `useAuth` / `usePermissions`), and a `PlatformHostProvider`. A `DataTablePreferencesProvider` is optional: without one the Secrets list uses the platform's default port, the `dataTables` namespace of `/api/user-settings` over the host's client.
|
|
63
|
+
|
|
64
|
+
## Configuration
|
|
65
|
+
|
|
66
|
+
`configureVaultWeb({ http, apiBaseUrl?, productName? })` is the only configuration. `http` is the host's `PlatformHttpClient` (the same instance the platform's `AuthProvider` drives, so the bearer token and the refresh are shared); `apiBaseUrl` (default `/api`) is read only by the two raw `fetch` calls that stream an attachment; `productName` (default `Vault`) is the name the pages' copy shows (`getVaultProductName()`), so a second host shows its own ([docs/EMBEDDING.md](../../docs/EMBEDDING.md#web-slices)). A slice that calls the API before it is configured throws `VaultWebNotConfiguredError`. The package reads no environment or build-time variable.
|
|
67
|
+
|
|
68
|
+
## Extension-point catalog
|
|
69
|
+
|
|
70
|
+
| Extension point | Where | What a host varies |
|
|
71
|
+
|---|---|---|
|
|
72
|
+
| HTTP port | `configureVaultWeb` (`core/headless`) | the transport, base URL and refresh lock |
|
|
73
|
+
| Table layout store | the host's `DataTablePreferencesProvider`, else the platform default (`/user-settings`, `dataTables`) | where the Secrets list keeps its column, sort and page-size layout |
|
|
74
|
+
| Platform host | the host's `PlatformHostProvider` | the viewer, permissions and features the packaged platform pieces read |
|
|
75
|
+
| Theme | `VAULT_THEMES` passed to `ShellRoot` | the host may extend or replace the themes |
|
|
76
|
+
|
|
77
|
+
## Build and test
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
npm run build -w @marinoscar/vault-web # tsc (NodeNext) to dist/, then copies the brand image
|
|
81
|
+
npm run typecheck -w @marinoscar/vault-web # src and test (bundler resolution) plus the NodeNext build check
|
|
82
|
+
npm run test:run -w @marinoscar/vault-web # Vitest + React Testing Library + MSW, jsdom
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
The suites render through `test/utils/test-utils.tsx`, which mounts what the host mounts without importing the host; `test/setup.ts` configures the HTTP port against the MSW handlers in `test/mocks/`.
|
|
86
|
+
|
|
87
|
+
## Security notes
|
|
88
|
+
|
|
89
|
+
- The browser never calls an AI provider: card scanning posts to `POST /api/secrets/cards/extract` and shows `AiEgressNotice`; the CVV is never sent, returned or seeded into the review form.
|
|
90
|
+
- Secret values come only from the detail view, are copied through `useCopyToClipboard` and are never written to `localStorage`, logs or error reports. Backup passwords live in component state only.
|
|
91
|
+
- The UI presents and the API authorizes: a hidden button is not a permission check.
|
|
92
|
+
|
|
93
|
+
## Links
|
|
94
|
+
|
|
95
|
+
- [ADR-0001, packages first](../../docs/decisions/0001-packages-first.md)
|
|
96
|
+
- [The Vault packages](../../docs/PACKAGES.md)
|
|
97
|
+
- [The host's rules](../../apps/web/AGENTS.md)
|
|
98
|
+
- [UX refresh spec](../../docs/specs/ux-refresh.md)
|
|
99
|
+
- [Changelog](CHANGELOG.md)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/** What an agent did: the audit actions of the agent API (logins, cards, identity) and the owner's decisions. */
|
|
2
|
+
export type AgentActivityAction = 'lookup' | 'fill' | 'totp' | 'create' | 'rotate' | 'agent_access' | 'card_lookup' | 'card_fill' | 'card_grant_request' | 'identity_lookup' | 'identity_fill' | 'card_grant';
|
|
3
|
+
/** The credential an agent call authenticated with (`embedded`: a host that embeds Vault, by its label). */
|
|
4
|
+
export type AgentCredentialKind = 'oauth' | 'pat' | 'session' | 'embedded';
|
|
5
|
+
/**
|
|
6
|
+
* One row of `GET /api/agent-activity`. Never carries a value, code or seed: only who, what, where and why.
|
|
7
|
+
* (The contract type moves to `@marinoscar/vault-contract/agent` later; this is the same shape.)
|
|
8
|
+
*/
|
|
9
|
+
export interface AgentActivityItem {
|
|
10
|
+
id: string;
|
|
11
|
+
/** ISO timestamp. */
|
|
12
|
+
at: string;
|
|
13
|
+
action: AgentActivityAction;
|
|
14
|
+
result: 'ok' | 'denied';
|
|
15
|
+
/** The denial reason when `result` is `denied`. */
|
|
16
|
+
reason?: string;
|
|
17
|
+
secretId: string | null;
|
|
18
|
+
secretName: string | null;
|
|
19
|
+
/** The field name touched (never its value). */
|
|
20
|
+
field: string | null;
|
|
21
|
+
/** The website the agent was acting on. */
|
|
22
|
+
origin: string | null;
|
|
23
|
+
/** The agent's stated purpose. */
|
|
24
|
+
purpose: string | null;
|
|
25
|
+
credentialKind: AgentCredentialKind | null;
|
|
26
|
+
clientId: string | null;
|
|
27
|
+
clientName: string | null;
|
|
28
|
+
/** A card call's stated amount (`"42.50"`); absent otherwise. */
|
|
29
|
+
amount?: string | null;
|
|
30
|
+
/** A card call's currency. */
|
|
31
|
+
currency?: string | null;
|
|
32
|
+
}
|
|
33
|
+
export declare const AGENT_ACTIVITY_ACTIONS: readonly AgentActivityAction[];
|
|
34
|
+
export declare const AGENT_ACTION_LABELS: Record<AgentActivityAction, string>;
|
|
35
|
+
export interface AgentActivityQuery {
|
|
36
|
+
/** 1-based. */
|
|
37
|
+
page?: number;
|
|
38
|
+
pageSize?: number;
|
|
39
|
+
action?: AgentActivityAction;
|
|
40
|
+
secretId?: string;
|
|
41
|
+
clientId?: string;
|
|
42
|
+
/** ISO. */
|
|
43
|
+
from?: string;
|
|
44
|
+
/** ISO. */
|
|
45
|
+
to?: string;
|
|
46
|
+
}
|
|
47
|
+
export interface AgentActivityPage {
|
|
48
|
+
items: AgentActivityItem[];
|
|
49
|
+
total: number;
|
|
50
|
+
}
|
|
51
|
+
/** The name shown for the app behind a row. */
|
|
52
|
+
export declare function agentAppLabel(item: Pick<AgentActivityItem, 'clientName' | 'credentialKind'>): string;
|
|
53
|
+
/**
|
|
54
|
+
* One page of the caller's agent activity. Read through the raw body (the shared client drops
|
|
55
|
+
* `meta` when it unwraps `{ data }`), and tolerant of both list envelopes the API uses.
|
|
56
|
+
*/
|
|
57
|
+
export declare function getAgentActivity(query?: AgentActivityQuery): Promise<AgentActivityPage>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { api } from '../../core/headless/http.js';
|
|
2
|
+
export const AGENT_ACTIVITY_ACTIONS = [
|
|
3
|
+
'lookup',
|
|
4
|
+
'fill',
|
|
5
|
+
'totp',
|
|
6
|
+
'create',
|
|
7
|
+
'rotate',
|
|
8
|
+
'agent_access',
|
|
9
|
+
'card_lookup',
|
|
10
|
+
'card_fill',
|
|
11
|
+
'card_grant_request',
|
|
12
|
+
'identity_lookup',
|
|
13
|
+
'identity_fill',
|
|
14
|
+
'card_grant',
|
|
15
|
+
];
|
|
16
|
+
export const AGENT_ACTION_LABELS = {
|
|
17
|
+
lookup: 'Looked up',
|
|
18
|
+
fill: 'Filled',
|
|
19
|
+
totp: 'One-time code',
|
|
20
|
+
create: 'Created',
|
|
21
|
+
rotate: 'Rotated',
|
|
22
|
+
agent_access: 'Access changed',
|
|
23
|
+
card_lookup: 'Cards looked up',
|
|
24
|
+
card_fill: 'Card filled',
|
|
25
|
+
card_grant_request: 'Asked for a shop',
|
|
26
|
+
identity_lookup: 'Identity looked up',
|
|
27
|
+
identity_fill: 'Identity filled',
|
|
28
|
+
card_grant: 'Shop permission',
|
|
29
|
+
};
|
|
30
|
+
/** The name shown for the app behind a row. */
|
|
31
|
+
export function agentAppLabel(item) {
|
|
32
|
+
if (item.clientName)
|
|
33
|
+
return item.clientName;
|
|
34
|
+
if (item.credentialKind === 'pat')
|
|
35
|
+
return 'Personal access token';
|
|
36
|
+
if (item.credentialKind === 'session')
|
|
37
|
+
return 'Vault session';
|
|
38
|
+
return 'Unknown app';
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* One page of the caller's agent activity. Read through the raw body (the shared client drops
|
|
42
|
+
* `meta` when it unwraps `{ data }`), and tolerant of both list envelopes the API uses.
|
|
43
|
+
*/
|
|
44
|
+
export async function getAgentActivity(query = {}) {
|
|
45
|
+
const params = new URLSearchParams();
|
|
46
|
+
if (query.page)
|
|
47
|
+
params.set('page', String(query.page));
|
|
48
|
+
if (query.pageSize)
|
|
49
|
+
params.set('pageSize', String(query.pageSize));
|
|
50
|
+
if (query.action)
|
|
51
|
+
params.set('action', query.action);
|
|
52
|
+
if (query.secretId)
|
|
53
|
+
params.set('secretId', query.secretId);
|
|
54
|
+
if (query.clientId)
|
|
55
|
+
params.set('clientId', query.clientId);
|
|
56
|
+
if (query.from)
|
|
57
|
+
params.set('from', query.from);
|
|
58
|
+
if (query.to)
|
|
59
|
+
params.set('to', query.to);
|
|
60
|
+
const qs = params.toString();
|
|
61
|
+
const { blob } = await api.get(`/agent-activity${qs ? `?${qs}` : ''}`, {
|
|
62
|
+
responseType: 'blobWithHeaders',
|
|
63
|
+
});
|
|
64
|
+
const body = JSON.parse(await blob.text());
|
|
65
|
+
const data = body.data;
|
|
66
|
+
const items = Array.isArray(data) ? data : (data?.items ?? []);
|
|
67
|
+
const meta = body.meta ?? (Array.isArray(data) ? undefined : data?.meta);
|
|
68
|
+
const total = meta?.total ?? meta?.totalItems ?? items.length;
|
|
69
|
+
return { items, total };
|
|
70
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CardGrant, CardGrantRequest, CardGrantRequestStatus, CreateCardGrant } from '@marinoscar/vault-contract/agent';
|
|
2
|
+
export type { CardGrant, CardGrantRequest, CardGrantRequestStatus, CreateCardGrant };
|
|
3
|
+
/**
|
|
4
|
+
* The owner's merchant grants of a card and the requests agents made (ADR-0003). Every write needs
|
|
5
|
+
* the owner's browser session; the API refuses a token with `OWNER_SESSION_REQUIRED`. Nothing here
|
|
6
|
+
* ever carries a card number or code.
|
|
7
|
+
*/
|
|
8
|
+
/** Every grant of a card: active first, then expired and revoked. */
|
|
9
|
+
export declare function listCardGrants(secretId: string): Promise<CardGrant[]>;
|
|
10
|
+
/** Allows agents to use the card at one merchant. */
|
|
11
|
+
export declare function createCardGrant(secretId: string, body: CreateCardGrant): Promise<CardGrant>;
|
|
12
|
+
/** Revokes a grant (agents can no longer use the card at that merchant). */
|
|
13
|
+
export declare function revokeCardGrant(secretId: string, grantId: string): Promise<CardGrant>;
|
|
14
|
+
/** The requests agents made for a card, newest first. */
|
|
15
|
+
export declare function listCardGrantRequests(secretId: string, status?: CardGrantRequestStatus): Promise<CardGrantRequest[]>;
|
|
16
|
+
/** Approves a request: creates exactly the requested grant. */
|
|
17
|
+
export declare function approveCardGrantRequest(secretId: string, requestId: string): Promise<{
|
|
18
|
+
request: CardGrantRequest;
|
|
19
|
+
grant: CardGrant;
|
|
20
|
+
}>;
|
|
21
|
+
/** Declines a request. */
|
|
22
|
+
export declare function declineCardGrantRequest(secretId: string, requestId: string): Promise<CardGrantRequest>;
|
|
23
|
+
/** `42.50 USD`. */
|
|
24
|
+
export declare function formatGrantAmount(amount: number, currency: string): string;
|
|
25
|
+
/** A one-line summary of a grant's limits, e.g. `Up to 100.00 USD per purchase · 3 per month`. */
|
|
26
|
+
export declare function describeGrantLimits(grant: Pick<CardGrant, 'maxAmount' | 'currency' | 'periodLimit'>): string;
|
|
27
|
+
/** A friendly message for a failed grant action. */
|
|
28
|
+
export declare function cardGrantErrorMessage(err: unknown): string;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { api } from '../../core/headless/http.js';
|
|
2
|
+
/**
|
|
3
|
+
* The owner's merchant grants of a card and the requests agents made (ADR-0003). Every write needs
|
|
4
|
+
* the owner's browser session; the API refuses a token with `OWNER_SESSION_REQUIRED`. Nothing here
|
|
5
|
+
* ever carries a card number or code.
|
|
6
|
+
*/
|
|
7
|
+
/** Every grant of a card: active first, then expired and revoked. */
|
|
8
|
+
export function listCardGrants(secretId) {
|
|
9
|
+
return api.get(`/secrets/${secretId}/card-grants`);
|
|
10
|
+
}
|
|
11
|
+
/** Allows agents to use the card at one merchant. */
|
|
12
|
+
export function createCardGrant(secretId, body) {
|
|
13
|
+
return api.post(`/secrets/${secretId}/card-grants`, body);
|
|
14
|
+
}
|
|
15
|
+
/** Revokes a grant (agents can no longer use the card at that merchant). */
|
|
16
|
+
export function revokeCardGrant(secretId, grantId) {
|
|
17
|
+
return api.delete(`/secrets/${secretId}/card-grants/${grantId}`);
|
|
18
|
+
}
|
|
19
|
+
/** The requests agents made for a card, newest first. */
|
|
20
|
+
export function listCardGrantRequests(secretId, status) {
|
|
21
|
+
return api.get(`/secrets/${secretId}/card-grant-requests${status ? `?status=${status}` : ''}`);
|
|
22
|
+
}
|
|
23
|
+
/** Approves a request: creates exactly the requested grant. */
|
|
24
|
+
export function approveCardGrantRequest(secretId, requestId) {
|
|
25
|
+
return api.post(`/secrets/${secretId}/card-grant-requests/${requestId}/approve`, {});
|
|
26
|
+
}
|
|
27
|
+
/** Declines a request. */
|
|
28
|
+
export function declineCardGrantRequest(secretId, requestId) {
|
|
29
|
+
return api.post(`/secrets/${secretId}/card-grant-requests/${requestId}/decline`, {});
|
|
30
|
+
}
|
|
31
|
+
/** `42.50 USD`. */
|
|
32
|
+
export function formatGrantAmount(amount, currency) {
|
|
33
|
+
return `${amount.toFixed(2)} ${currency}`;
|
|
34
|
+
}
|
|
35
|
+
/** A one-line summary of a grant's limits, e.g. `Up to 100.00 USD per purchase · 3 per month`. */
|
|
36
|
+
export function describeGrantLimits(grant) {
|
|
37
|
+
const parts = [`Up to ${formatGrantAmount(grant.maxAmount, grant.currency)} per purchase`];
|
|
38
|
+
const limit = grant.periodLimit;
|
|
39
|
+
if (limit) {
|
|
40
|
+
const per = limit.period === 'day' ? 'day' : 'month';
|
|
41
|
+
if (limit.maxReleases !== null)
|
|
42
|
+
parts.push(`${limit.maxReleases} per ${per}`);
|
|
43
|
+
if (limit.maxAmount !== null)
|
|
44
|
+
parts.push(`${formatGrantAmount(limit.maxAmount, grant.currency)} per ${per}`);
|
|
45
|
+
}
|
|
46
|
+
return parts.join(' · ');
|
|
47
|
+
}
|
|
48
|
+
/** A friendly message for a failed grant action. */
|
|
49
|
+
export function cardGrantErrorMessage(err) {
|
|
50
|
+
const code = err?.code;
|
|
51
|
+
switch (code) {
|
|
52
|
+
case 'CARD_GRANT_EXISTS':
|
|
53
|
+
return 'This card already has a live permission for that shop. Revoke it first.';
|
|
54
|
+
case 'CARD_GRANT_REQUEST_NOT_PENDING':
|
|
55
|
+
return 'This request was already approved or declined.';
|
|
56
|
+
case 'OWNER_SESSION_REQUIRED':
|
|
57
|
+
return 'Sign in to Vault to change what agents may do with this card.';
|
|
58
|
+
default:
|
|
59
|
+
return err instanceof Error ? err.message : 'Something went wrong';
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type AgentActivityItem, type AgentActivityQuery } from './agentActivity.js';
|
|
2
|
+
export interface UseAgentActivityResult {
|
|
3
|
+
items: AgentActivityItem[];
|
|
4
|
+
total: number;
|
|
5
|
+
loading: boolean;
|
|
6
|
+
error: string | null;
|
|
7
|
+
}
|
|
8
|
+
/** Loads one page of agent activity whenever the query changes; only the latest request writes state. */
|
|
9
|
+
export declare function useAgentActivity(query: AgentActivityQuery): UseAgentActivityResult;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { getAgentActivity } from './agentActivity.js';
|
|
3
|
+
/** Loads one page of agent activity whenever the query changes; only the latest request writes state. */
|
|
4
|
+
export function useAgentActivity(query) {
|
|
5
|
+
const [state, setState] = useState({ items: [], total: 0, loading: true, error: null });
|
|
6
|
+
const key = JSON.stringify(query);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
let current = true;
|
|
9
|
+
setState((s) => ({ ...s, loading: true, error: null }));
|
|
10
|
+
getAgentActivity(JSON.parse(key))
|
|
11
|
+
.then((page) => {
|
|
12
|
+
if (current)
|
|
13
|
+
setState({ items: page.items, total: page.total, loading: false, error: null });
|
|
14
|
+
})
|
|
15
|
+
.catch((err) => {
|
|
16
|
+
if (current) {
|
|
17
|
+
setState({
|
|
18
|
+
items: [],
|
|
19
|
+
total: 0,
|
|
20
|
+
loading: false,
|
|
21
|
+
error: err instanceof Error ? err.message : 'Failed to load agent activity',
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return () => {
|
|
26
|
+
current = false;
|
|
27
|
+
};
|
|
28
|
+
}, [key]);
|
|
29
|
+
return state;
|
|
30
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type CardGrant, type CardGrantRequest, type CreateCardGrant } from './cardGrants.js';
|
|
2
|
+
export interface UseCardGrantsResult {
|
|
3
|
+
grants: CardGrant[];
|
|
4
|
+
/** Pending requests only, newest first. */
|
|
5
|
+
requests: CardGrantRequest[];
|
|
6
|
+
loading: boolean;
|
|
7
|
+
error: string | null;
|
|
8
|
+
refresh: () => Promise<void>;
|
|
9
|
+
create: (body: CreateCardGrant) => Promise<void>;
|
|
10
|
+
revoke: (grantId: string) => Promise<void>;
|
|
11
|
+
approve: (requestId: string) => Promise<void>;
|
|
12
|
+
decline: (requestId: string) => Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The merchant grants and the pending grant requests of one card (ADR-0003). Every action reloads
|
|
16
|
+
* both lists, so the use counters and statuses are the server's. Actions throw; the caller shows
|
|
17
|
+
* the message (`cardGrantErrorMessage`).
|
|
18
|
+
*/
|
|
19
|
+
export declare function useCardGrants(secretId: string | undefined): UseCardGrantsResult;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { approveCardGrantRequest, createCardGrant, declineCardGrantRequest, listCardGrantRequests, listCardGrants, revokeCardGrant, } from './cardGrants.js';
|
|
3
|
+
/**
|
|
4
|
+
* The merchant grants and the pending grant requests of one card (ADR-0003). Every action reloads
|
|
5
|
+
* both lists, so the use counters and statuses are the server's. Actions throw; the caller shows
|
|
6
|
+
* the message (`cardGrantErrorMessage`).
|
|
7
|
+
*/
|
|
8
|
+
export function useCardGrants(secretId) {
|
|
9
|
+
const [grants, setGrants] = useState([]);
|
|
10
|
+
const [requests, setRequests] = useState([]);
|
|
11
|
+
const [loading, setLoading] = useState(true);
|
|
12
|
+
const [error, setError] = useState(null);
|
|
13
|
+
const refresh = useCallback(async () => {
|
|
14
|
+
if (!secretId)
|
|
15
|
+
return;
|
|
16
|
+
setLoading(true);
|
|
17
|
+
try {
|
|
18
|
+
const [nextGrants, nextRequests] = await Promise.all([
|
|
19
|
+
listCardGrants(secretId),
|
|
20
|
+
listCardGrantRequests(secretId, 'pending'),
|
|
21
|
+
]);
|
|
22
|
+
setGrants(nextGrants);
|
|
23
|
+
setRequests(nextRequests);
|
|
24
|
+
setError(null);
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
setError(err instanceof Error ? err.message : 'Failed to load the agent permissions of this card');
|
|
28
|
+
}
|
|
29
|
+
finally {
|
|
30
|
+
setLoading(false);
|
|
31
|
+
}
|
|
32
|
+
}, [secretId]);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
void refresh();
|
|
35
|
+
}, [refresh]);
|
|
36
|
+
const act = useCallback(async (work) => {
|
|
37
|
+
await work();
|
|
38
|
+
await refresh();
|
|
39
|
+
}, [refresh]);
|
|
40
|
+
return {
|
|
41
|
+
grants,
|
|
42
|
+
requests,
|
|
43
|
+
loading,
|
|
44
|
+
error,
|
|
45
|
+
refresh,
|
|
46
|
+
create: (body) => act(() => createCardGrant(secretId, body)),
|
|
47
|
+
revoke: (grantId) => act(() => revokeCardGrant(secretId, grantId)),
|
|
48
|
+
approve: (requestId) => act(() => approveCardGrantRequest(secretId, requestId)),
|
|
49
|
+
decline: (requestId) => act(() => declineCardGrantRequest(secretId, requestId)),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DataTableRendererMode } from '@marinoscar/platform-web/datatable/headless';
|
|
2
|
+
import { type AgentActivityItem } from '../../headless/agentActivity.js';
|
|
3
|
+
export declare const AGENT_ACTIVITY_TABLE_ID = "agent-activity";
|
|
4
|
+
export declare const AGENT_ACTIVITY_PAGE_SIZES: number[];
|
|
5
|
+
export interface AgentActivityTableProps {
|
|
6
|
+
rows: AgentActivityItem[];
|
|
7
|
+
total: number;
|
|
8
|
+
/** 0-based, as the platform table counts. */
|
|
9
|
+
page: number;
|
|
10
|
+
pageSize: number;
|
|
11
|
+
loading: boolean;
|
|
12
|
+
error: string | null;
|
|
13
|
+
onPaginationChange: (next: {
|
|
14
|
+
page: number;
|
|
15
|
+
pageSize: number;
|
|
16
|
+
}) => void;
|
|
17
|
+
/** True when a filter is active, so the empty state says "no match". */
|
|
18
|
+
filtered?: boolean;
|
|
19
|
+
renderer?: DataTableRendererMode;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The agent activity list on the platform `DataTable`: a grid on desktop, cards on a phone (the
|
|
23
|
+
* table measures its own container). Server-paged; no value, code or seed is ever in a row.
|
|
24
|
+
*/
|
|
25
|
+
export declare function AgentActivityTable(props: AgentActivityTableProps): import("react").JSX.Element;
|