@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.
Files changed (277) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/LICENSE +21 -0
  3. package/README.md +99 -0
  4. package/dist/agent/headless/agentActivity.d.ts +53 -0
  5. package/dist/agent/headless/agentActivity.js +58 -0
  6. package/dist/agent/headless/index.d.ts +2 -0
  7. package/dist/agent/headless/index.js +3 -0
  8. package/dist/agent/headless/useAgentActivity.d.ts +9 -0
  9. package/dist/agent/headless/useAgentActivity.js +30 -0
  10. package/dist/agent/ui/components/AgentActivityTable.d.ts +25 -0
  11. package/dist/agent/ui/components/AgentActivityTable.js +114 -0
  12. package/dist/agent/ui/index.d.ts +3 -0
  13. package/dist/agent/ui/index.js +4 -0
  14. package/dist/agent/ui/pages/AgentAccessSettingsPage.d.ts +7 -0
  15. package/dist/agent/ui/pages/AgentAccessSettingsPage.js +70 -0
  16. package/dist/agent/ui/pages/AgentActivityPage.d.ts +6 -0
  17. package/dist/agent/ui/pages/AgentActivityPage.js +61 -0
  18. package/dist/backups/headless/backupContents.d.ts +69 -0
  19. package/dist/backups/headless/backupContents.js +133 -0
  20. package/dist/backups/headless/backupPassword.d.ts +34 -0
  21. package/dist/backups/headless/backupPassword.js +80 -0
  22. package/dist/backups/headless/backupSchedule.d.ts +56 -0
  23. package/dist/backups/headless/backupSchedule.js +189 -0
  24. package/dist/backups/headless/index.d.ts +4 -0
  25. package/dist/backups/headless/index.js +5 -0
  26. package/dist/backups/headless/useBackupRunHistory.d.ts +36 -0
  27. package/dist/backups/headless/useBackupRunHistory.js +83 -0
  28. package/dist/backups/ui/components/AdminBackupDownloadDialog.d.ts +20 -0
  29. package/dist/backups/ui/components/AdminBackupDownloadDialog.js +65 -0
  30. package/dist/backups/ui/components/BackupContentsGroup.d.ts +17 -0
  31. package/dist/backups/ui/components/BackupContentsGroup.js +21 -0
  32. package/dist/backups/ui/components/BackupPasswordFields.d.ts +18 -0
  33. package/dist/backups/ui/components/BackupPasswordFields.js +40 -0
  34. package/dist/backups/ui/components/BackupRunsTable.d.ts +44 -0
  35. package/dist/backups/ui/components/BackupRunsTable.js +61 -0
  36. package/dist/backups/ui/components/DataBackup.d.ts +14 -0
  37. package/dist/backups/ui/components/DataBackup.js +169 -0
  38. package/dist/backups/ui/components/ScheduledBackups.d.ts +13 -0
  39. package/dist/backups/ui/components/ScheduledBackups.js +304 -0
  40. package/dist/backups/ui/index.d.ts +8 -0
  41. package/dist/backups/ui/index.js +9 -0
  42. package/dist/backups/ui/pages/BackupSettingsPage.d.ts +8 -0
  43. package/dist/backups/ui/pages/BackupSettingsPage.js +19 -0
  44. package/dist/backups/ui/pages/MyBackupsPage.d.ts +8 -0
  45. package/dist/backups/ui/pages/MyBackupsPage.js +19 -0
  46. package/dist/brand/BrandLockup.d.ts +14 -0
  47. package/dist/brand/BrandLockup.js +13 -0
  48. package/dist/brand/assets/vault-mark.png +0 -0
  49. package/dist/brand/contrast.d.ts +8 -0
  50. package/dist/brand/contrast.js +21 -0
  51. package/dist/brand/index.d.ts +7 -0
  52. package/dist/brand/index.js +8 -0
  53. package/dist/brand/mark.d.ts +6 -0
  54. package/dist/brand/mark.js +7 -0
  55. package/dist/brand/theme.d.ts +25 -0
  56. package/dist/brand/theme.js +84 -0
  57. package/dist/brand/tokens.d.ts +52 -0
  58. package/dist/brand/tokens.js +54 -0
  59. package/dist/cards/headless/cardExpiry.d.ts +57 -0
  60. package/dist/cards/headless/cardExpiry.js +138 -0
  61. package/dist/cards/headless/cardFormat.d.ts +60 -0
  62. package/dist/cards/headless/cardFormat.js +135 -0
  63. package/dist/cards/headless/cardImage.d.ts +293 -0
  64. package/dist/cards/headless/cardImage.js +518 -0
  65. package/dist/cards/headless/index.d.ts +6 -0
  66. package/dist/cards/headless/index.js +7 -0
  67. package/dist/cards/headless/useCardImport.d.ts +137 -0
  68. package/dist/cards/headless/useCardImport.js +391 -0
  69. package/dist/cards/headless/useCardRenewal.d.ts +102 -0
  70. package/dist/cards/headless/useCardRenewal.js +305 -0
  71. package/dist/cards/headless/useCards.d.ts +80 -0
  72. package/dist/cards/headless/useCards.js +114 -0
  73. package/dist/cards/ui/components/AiEgressNotice.d.ts +13 -0
  74. package/dist/cards/ui/components/AiEgressNotice.js +18 -0
  75. package/dist/cards/ui/components/CardCaptureStep.d.ts +59 -0
  76. package/dist/cards/ui/components/CardCaptureStep.js +96 -0
  77. package/dist/cards/ui/components/CardCropAdjuster.d.ts +43 -0
  78. package/dist/cards/ui/components/CardCropAdjuster.js +215 -0
  79. package/dist/cards/ui/components/CardCropReview.d.ts +51 -0
  80. package/dist/cards/ui/components/CardCropReview.js +88 -0
  81. package/dist/cards/ui/components/CardExpiryBadge.d.ts +8 -0
  82. package/dist/cards/ui/components/CardExpiryBadge.js +43 -0
  83. package/dist/cards/ui/components/CardFieldDiff.d.ts +37 -0
  84. package/dist/cards/ui/components/CardFieldDiff.js +66 -0
  85. package/dist/cards/ui/components/CardFlowStepper.d.ts +24 -0
  86. package/dist/cards/ui/components/CardFlowStepper.js +23 -0
  87. package/dist/cards/ui/components/CardReviewForm.d.ts +44 -0
  88. package/dist/cards/ui/components/CardReviewForm.js +102 -0
  89. package/dist/cards/ui/components/CardScanModelSection.d.ts +23 -0
  90. package/dist/cards/ui/components/CardScanModelSection.js +81 -0
  91. package/dist/cards/ui/components/CardTile.d.ts +40 -0
  92. package/dist/cards/ui/components/CardTile.js +94 -0
  93. package/dist/cards/ui/index.d.ts +15 -0
  94. package/dist/cards/ui/index.js +16 -0
  95. package/dist/cards/ui/pages/AiSettingsPage.d.ts +12 -0
  96. package/dist/cards/ui/pages/AiSettingsPage.js +24 -0
  97. package/dist/cards/ui/pages/CardsPage.d.ts +26 -0
  98. package/dist/cards/ui/pages/CardsPage.js +160 -0
  99. package/dist/cards/ui/pages/ImportCardPage.d.ts +24 -0
  100. package/dist/cards/ui/pages/ImportCardPage.js +343 -0
  101. package/dist/cards/ui/pages/RenewCardPage.d.ts +35 -0
  102. package/dist/cards/ui/pages/RenewCardPage.js +350 -0
  103. package/dist/core/headless/api.d.ts +272 -0
  104. package/dist/core/headless/api.js +425 -0
  105. package/dist/core/headless/cardScanAvailability.d.ts +20 -0
  106. package/dist/core/headless/cardScanAvailability.js +27 -0
  107. package/dist/core/headless/clipboard.d.ts +60 -0
  108. package/dist/core/headless/clipboard.js +101 -0
  109. package/dist/core/headless/http.d.ts +41 -0
  110. package/dist/core/headless/http.js +50 -0
  111. package/dist/core/headless/index.d.ts +12 -0
  112. package/dist/core/headless/index.js +13 -0
  113. package/dist/core/headless/relativeTime.d.ts +7 -0
  114. package/dist/core/headless/relativeTime.js +28 -0
  115. package/dist/core/headless/saveBlob.d.ts +6 -0
  116. package/dist/core/headless/saveBlob.js +21 -0
  117. package/dist/core/headless/types.d.ts +441 -0
  118. package/dist/core/headless/types.js +49 -0
  119. package/dist/core/headless/useAiStatus.d.ts +41 -0
  120. package/dist/core/headless/useAiStatus.js +42 -0
  121. package/dist/core/headless/useCopyToClipboard.d.ts +20 -0
  122. package/dist/core/headless/useCopyToClipboard.js +52 -0
  123. package/dist/core/headless/useDashboardResource.d.ts +22 -0
  124. package/dist/core/headless/useDashboardResource.js +52 -0
  125. package/dist/core/headless/useSystemSettings.d.ts +17 -0
  126. package/dist/core/headless/useSystemSettings.js +106 -0
  127. package/dist/core/headless/useUserSettings.d.ts +13 -0
  128. package/dist/core/headless/useUserSettings.js +103 -0
  129. package/dist/core/ui/ErrorBoundary.d.ts +15 -0
  130. package/dist/core/ui/ErrorBoundary.js +27 -0
  131. package/dist/core/ui/LoadingSpinner.d.ts +6 -0
  132. package/dist/core/ui/LoadingSpinner.js +14 -0
  133. package/dist/core/ui/SettingsPageFrame.d.ts +19 -0
  134. package/dist/core/ui/SettingsPageFrame.js +12 -0
  135. package/dist/core/ui/StorageSettingsLink.d.ts +19 -0
  136. package/dist/core/ui/StorageSettingsLink.js +26 -0
  137. package/dist/core/ui/index.d.ts +4 -0
  138. package/dist/core/ui/index.js +5 -0
  139. package/dist/home/headless/homeLinks.d.ts +24 -0
  140. package/dist/home/headless/homeLinks.js +24 -0
  141. package/dist/home/headless/index.d.ts +1 -0
  142. package/dist/home/headless/index.js +2 -0
  143. package/dist/home/ui/components/BackupStatusPanel.d.ts +28 -0
  144. package/dist/home/ui/components/BackupStatusPanel.js +99 -0
  145. package/dist/home/ui/components/DashboardPanel.d.ts +33 -0
  146. package/dist/home/ui/components/DashboardPanel.js +21 -0
  147. package/dist/home/ui/components/ExpiringCardsPanel.d.ts +31 -0
  148. package/dist/home/ui/components/ExpiringCardsPanel.js +35 -0
  149. package/dist/home/ui/components/FirstRunPanel.d.ts +7 -0
  150. package/dist/home/ui/components/FirstRunPanel.js +21 -0
  151. package/dist/home/ui/components/QuickActions.d.ts +14 -0
  152. package/dist/home/ui/components/QuickActions.js +40 -0
  153. package/dist/home/ui/components/RecentSecretsPanel.d.ts +19 -0
  154. package/dist/home/ui/components/RecentSecretsPanel.js +20 -0
  155. package/dist/home/ui/components/StatsRow.d.ts +19 -0
  156. package/dist/home/ui/components/StatsRow.js +46 -0
  157. package/dist/home/ui/components/WelcomeHeader.d.ts +11 -0
  158. package/dist/home/ui/components/WelcomeHeader.js +15 -0
  159. package/dist/home/ui/index.d.ts +9 -0
  160. package/dist/home/ui/index.js +10 -0
  161. package/dist/home/ui/pages/HomePage.d.ts +14 -0
  162. package/dist/home/ui/pages/HomePage.js +121 -0
  163. package/dist/index.d.ts +5 -0
  164. package/dist/index.js +5 -0
  165. package/dist/media/headless/index.d.ts +2 -0
  166. package/dist/media/headless/index.js +3 -0
  167. package/dist/media/headless/useMediaFiles.d.ts +20 -0
  168. package/dist/media/headless/useMediaFiles.js +82 -0
  169. package/dist/media/headless/useMediaFolders.d.ts +22 -0
  170. package/dist/media/headless/useMediaFolders.js +81 -0
  171. package/dist/media/ui/components/FolderList.d.ts +19 -0
  172. package/dist/media/ui/components/FolderList.js +36 -0
  173. package/dist/media/ui/components/MediaList.d.ts +20 -0
  174. package/dist/media/ui/components/MediaList.js +55 -0
  175. package/dist/media/ui/components/MediaPlayer.d.ts +7 -0
  176. package/dist/media/ui/components/MediaPlayer.js +361 -0
  177. package/dist/media/ui/index.d.ts +10 -0
  178. package/dist/media/ui/index.js +11 -0
  179. package/dist/media/ui/pages/CreateFolderPage.d.ts +1 -0
  180. package/dist/media/ui/pages/CreateFolderPage.js +39 -0
  181. package/dist/media/ui/pages/EditFolderPage.d.ts +1 -0
  182. package/dist/media/ui/pages/EditFolderPage.js +59 -0
  183. package/dist/media/ui/pages/MediaFolderPage.d.ts +1 -0
  184. package/dist/media/ui/pages/MediaFolderPage.js +68 -0
  185. package/dist/media/ui/pages/MediaFoldersPage.d.ts +1 -0
  186. package/dist/media/ui/pages/MediaFoldersPage.js +58 -0
  187. package/dist/media/ui/pages/MediaPlayerPage.d.ts +1 -0
  188. package/dist/media/ui/pages/MediaPlayerPage.js +76 -0
  189. package/dist/media/ui/pages/MediaUploadPage.d.ts +1 -0
  190. package/dist/media/ui/pages/MediaUploadPage.js +88 -0
  191. package/dist/media/ui/pages/RenameMediaFilePage.d.ts +1 -0
  192. package/dist/media/ui/pages/RenameMediaFilePage.js +63 -0
  193. package/dist/navigation/destinations.d.ts +50 -0
  194. package/dist/navigation/destinations.js +109 -0
  195. package/dist/navigation/index.d.ts +1 -0
  196. package/dist/navigation/index.js +4 -0
  197. package/dist/secrets/headless/fieldOptionsValidation.d.ts +45 -0
  198. package/dist/secrets/headless/fieldOptionsValidation.js +79 -0
  199. package/dist/secrets/headless/index.d.ts +6 -0
  200. package/dist/secrets/headless/index.js +7 -0
  201. package/dist/secrets/headless/secretFields.d.ts +86 -0
  202. package/dist/secrets/headless/secretFields.js +190 -0
  203. package/dist/secrets/headless/useSecretDetail.d.ts +33 -0
  204. package/dist/secrets/headless/useSecretDetail.js +87 -0
  205. package/dist/secrets/headless/useSecretTypes.d.ts +16 -0
  206. package/dist/secrets/headless/useSecretTypes.js +62 -0
  207. package/dist/secrets/headless/useSecrets.d.ts +24 -0
  208. package/dist/secrets/headless/useSecrets.js +59 -0
  209. package/dist/secrets/headless/useTotpCode.d.ts +24 -0
  210. package/dist/secrets/headless/useTotpCode.js +116 -0
  211. package/dist/secrets/ui/components/CardImages.d.ts +31 -0
  212. package/dist/secrets/ui/components/CardImages.js +208 -0
  213. package/dist/secrets/ui/components/DynamicSecretFields.d.ts +10 -0
  214. package/dist/secrets/ui/components/DynamicSecretFields.js +90 -0
  215. package/dist/secrets/ui/components/FieldDefinitionBuilder.d.ts +13 -0
  216. package/dist/secrets/ui/components/FieldDefinitionBuilder.js +114 -0
  217. package/dist/secrets/ui/components/FieldOptionsEditor.d.ts +15 -0
  218. package/dist/secrets/ui/components/FieldOptionsEditor.js +45 -0
  219. package/dist/secrets/ui/components/SecretAttachments.d.ts +15 -0
  220. package/dist/secrets/ui/components/SecretAttachments.js +106 -0
  221. package/dist/secrets/ui/components/SecretForm.d.ts +34 -0
  222. package/dist/secrets/ui/components/SecretForm.js +83 -0
  223. package/dist/secrets/ui/components/SecretFormDialog.d.ts +15 -0
  224. package/dist/secrets/ui/components/SecretFormDialog.js +95 -0
  225. package/dist/secrets/ui/components/SecretTypeFormDialog.d.ts +15 -0
  226. package/dist/secrets/ui/components/SecretTypeFormDialog.js +92 -0
  227. package/dist/secrets/ui/components/SecretTypeIcon.d.ts +8 -0
  228. package/dist/secrets/ui/components/SecretTypeIcon.js +16 -0
  229. package/dist/secrets/ui/components/SecretTypesList.d.ts +10 -0
  230. package/dist/secrets/ui/components/SecretTypesList.js +13 -0
  231. package/dist/secrets/ui/components/SecretValueField.d.ts +20 -0
  232. package/dist/secrets/ui/components/SecretValueField.js +52 -0
  233. package/dist/secrets/ui/components/SecretVersionDrawer.d.ts +22 -0
  234. package/dist/secrets/ui/components/SecretVersionDrawer.js +131 -0
  235. package/dist/secrets/ui/components/SecretsTable.d.ts +49 -0
  236. package/dist/secrets/ui/components/SecretsTable.js +174 -0
  237. package/dist/secrets/ui/components/TotpCodeCard.d.ts +8 -0
  238. package/dist/secrets/ui/components/TotpCodeCard.js +34 -0
  239. package/dist/secrets/ui/index.d.ts +20 -0
  240. package/dist/secrets/ui/index.js +21 -0
  241. package/dist/secrets/ui/pages/CreateSecretPage.d.ts +2 -0
  242. package/dist/secrets/ui/pages/CreateSecretPage.js +25 -0
  243. package/dist/secrets/ui/pages/CreateSecretTypePage.d.ts +1 -0
  244. package/dist/secrets/ui/pages/CreateSecretTypePage.js +62 -0
  245. package/dist/secrets/ui/pages/EditSecretPage.d.ts +5 -0
  246. package/dist/secrets/ui/pages/EditSecretPage.js +55 -0
  247. package/dist/secrets/ui/pages/EditSecretTypePage.d.ts +1 -0
  248. package/dist/secrets/ui/pages/EditSecretTypePage.js +88 -0
  249. package/dist/secrets/ui/pages/SecretDetailPage.d.ts +7 -0
  250. package/dist/secrets/ui/pages/SecretDetailPage.js +182 -0
  251. package/dist/secrets/ui/pages/SecretTypesPage.d.ts +1 -0
  252. package/dist/secrets/ui/pages/SecretTypesPage.js +23 -0
  253. package/dist/secrets/ui/pages/SecretsPage.d.ts +6 -0
  254. package/dist/secrets/ui/pages/SecretsPage.js +179 -0
  255. package/dist/settings/ui/components/FeatureFlagsList.d.ts +7 -0
  256. package/dist/settings/ui/components/FeatureFlagsList.js +46 -0
  257. package/dist/settings/ui/components/ImageUpload.d.ts +6 -0
  258. package/dist/settings/ui/components/ImageUpload.js +61 -0
  259. package/dist/settings/ui/components/ProfileSettings.d.ts +11 -0
  260. package/dist/settings/ui/components/ProfileSettings.js +55 -0
  261. package/dist/settings/ui/components/ThemeSettings.d.ts +7 -0
  262. package/dist/settings/ui/components/ThemeSettings.js +24 -0
  263. package/dist/settings/ui/components/UISettings.d.ts +9 -0
  264. package/dist/settings/ui/components/UISettings.js +25 -0
  265. package/dist/settings/ui/components/UserProfileCard.d.ts +1 -0
  266. package/dist/settings/ui/components/UserProfileCard.js +39 -0
  267. package/dist/settings/ui/components/UserSettingsSection.d.ts +23 -0
  268. package/dist/settings/ui/components/UserSettingsSection.js +29 -0
  269. package/dist/settings/ui/index.d.ts +10 -0
  270. package/dist/settings/ui/index.js +11 -0
  271. package/dist/settings/ui/pages/AppearanceSettingsPage.d.ts +6 -0
  272. package/dist/settings/ui/pages/AppearanceSettingsPage.js +11 -0
  273. package/dist/settings/ui/pages/GeneralSettingsPage.d.ts +9 -0
  274. package/dist/settings/ui/pages/GeneralSettingsPage.js +41 -0
  275. package/dist/settings/ui/pages/ProfileSettingsPage.d.ts +6 -0
  276. package/dist/settings/ui/pages/ProfileSettingsPage.js +11 -0
  277. package/package.json +146 -1
@@ -0,0 +1,350 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
+ import { Link as RouterLink, useNavigate, useParams } from 'react-router-dom';
4
+ import { usePermissions } from '@marinoscar/platform-web/identity/headless';
5
+ import { Alert, AlertTitle, Box, Breadcrumbs, Button, Chip, CircularProgress, Container, Link, Paper, Typography, } from '@mui/material';
6
+ import { AiEgressNotice } from '../components/AiEgressNotice.js';
7
+ import { CardCaptureStep } from '../components/CardCaptureStep.js';
8
+ import { CardCropReview } from '../components/CardCropReview.js';
9
+ import { CardFlowStepper } from '../components/CardFlowStepper.js';
10
+ import { CardReviewForm } from '../components/CardReviewForm.js';
11
+ import { useAiStatus } from '../../../core/headless/useAiStatus.js';
12
+ import { LOW_CONFIDENCE_THRESHOLD, aiSeededFields, } from '../../headless/useCardImport.js';
13
+ import { CVV_FIELD, diffCardFields, toRenewalValues, useCardRenewal, } from '../../headless/useCardRenewal.js';
14
+ import { cropImageFileToBox, cropImageFileToCard, prepareCardPhoto, } from '../../headless/cardImage.js';
15
+ /** Where each stage sits on the Capture → Crop → Review → Save stepper. */
16
+ const STAGE_STEP = {
17
+ front: 'capture',
18
+ back: 'capture',
19
+ processing: 'crop',
20
+ crop: 'crop',
21
+ review: 'review',
22
+ };
23
+ /**
24
+ * Renew a card in place, creating a new version.
25
+ *
26
+ * Capture (both photos optional) -> Crop (only when a photo was taken; the AI
27
+ * reads the new card first when it is on) -> Review (per-field diff) -> Save.
28
+ * The same four-step stepper as the import wizard (E10.5, #96).
29
+ *
30
+ * The capture steps collect FULL photos, exactly as the import wizard now
31
+ * does: the prepared full frame goes to the extraction endpoint, the AI
32
+ * returns a bounding box per side, and the stored attachment is cropped from
33
+ * that box (adjustable on the diff step). With AI off, any photo is cropped by
34
+ * the centred auto-fit instead — still adjustable. Only the cropped version is
35
+ * ever uploaded to storage.
36
+ *
37
+ * Three things separate this from the import wizard, and each one is load-bearing:
38
+ *
39
+ * 1. THE DIFF. The user is not entering a card, they are replacing one they
40
+ * already hold. The review step therefore shows current-vs-proposed per
41
+ * field, so what changes (number, expiry, code) and what does not
42
+ * (cardholder, network) is visible before anything is committed.
43
+ * 2. IT WORKS WITHOUT AI. Only the extraction step is gated on `useAiStatus`.
44
+ * A reissued card arrives whether or not an administrator has configured an
45
+ * OpenAI key, so with AI off the same wizard runs with the photo steps
46
+ * optional and every value typed by hand. Gating the page itself would make
47
+ * the feature unreachable for exactly the users who cannot fix it.
48
+ * 3. PHOTOS ARE OPTIONAL THROUGHOUT. A renewal with no new photos carries the
49
+ * old version's images forward server-side, which is what keeps the old
50
+ * card readable in its own version of the history.
51
+ *
52
+ * The CVV is typed by hand, always: the OUTGOING card's code is never carried
53
+ * forward (a reissued card always has a new one) and nothing read from the new
54
+ * card's photo seeds it either. Saving stays blocked until the field holds
55
+ * something.
56
+ */
57
+ export default function RenewCardPage() {
58
+ const navigate = useNavigate();
59
+ const { id: secretId } = useParams();
60
+ const { cardExtractEnabled, isLoading: isAiStatusLoading } = useAiStatus();
61
+ const canOpenAiSettings = usePermissions().hasPermission('ai_config:read');
62
+ const { secret, fields, currentValues, isLoading, loadError, extraction, extractionError, isExtracting, runExtraction, isSubmitting, submitError, submitRenewal, abandonRenewal, } = useCardRenewal(secretId);
63
+ const [stage, setStage] = useState('front');
64
+ const [frontPhoto, setFrontPhoto] = useState(null);
65
+ const [backPhoto, setBackPhoto] = useState(null);
66
+ const [frontCrop, setFrontCrop] = useState(null);
67
+ const [backCrop, setBackCrop] = useState(null);
68
+ const [isPreparing, setIsPreparing] = useState(false);
69
+ const [captureError, setCaptureError] = useState(null);
70
+ const [values, setValues] = useState(null);
71
+ const [fieldErrors, setFieldErrors] = useState({});
72
+ const [editedFields, setEditedFields] = useState(new Set());
73
+ // Object URLs (full-photo previews AND crop previews) are revoked
74
+ // explicitly, and tracked in a ref so the unmount cleanup sees the current
75
+ // set rather than a stale closure.
76
+ const previewUrlsRef = useRef(new Set());
77
+ const trackUrl = useCallback((url) => {
78
+ previewUrlsRef.current.add(url);
79
+ }, []);
80
+ const releaseUrl = useCallback((url) => {
81
+ if (!url)
82
+ return;
83
+ previewUrlsRef.current.delete(url);
84
+ URL.revokeObjectURL(url);
85
+ }, []);
86
+ useEffect(() => {
87
+ const urls = previewUrlsRef.current;
88
+ return () => {
89
+ urls.forEach((url) => URL.revokeObjectURL(url));
90
+ urls.clear();
91
+ };
92
+ }, []);
93
+ /**
94
+ * Extraction is available only when the feature is on AND the check has
95
+ * resolved. Treating "still loading" as unavailable fails closed on the only
96
+ * thing that matters here — nothing is sent to OpenAI on an unresolved check
97
+ * — and costs nothing, because reaching the read step takes two deliberate
98
+ * clicks by which time the two-boolean status call has landed.
99
+ */
100
+ const canExtract = !isAiStatusLoading && cardExtractEnabled;
101
+ // What gets uploaded on renew: the CROPPED images, never the full photos.
102
+ const capturedSides = useMemo(() => {
103
+ const sides = [];
104
+ if (frontCrop)
105
+ sides.push({ role: 'card_front', image: frontCrop.image });
106
+ if (backCrop)
107
+ sides.push({ role: 'card_back', image: backCrop.image });
108
+ return sides;
109
+ }, [frontCrop, backCrop]);
110
+ const handleFileSelected = async (side, file) => {
111
+ setCaptureError(null);
112
+ if (!file.type.startsWith('image/')) {
113
+ setCaptureError('Please choose an image file.');
114
+ return;
115
+ }
116
+ setIsPreparing(true);
117
+ try {
118
+ // Full frame only — the crop for the stored attachment happens after
119
+ // the AI locates the card (or via the auto-fit when AI is off). The
120
+ // full photo goes to the extraction endpoint and nowhere else; it is
121
+ // never uploaded to storage.
122
+ const prepared = await prepareCardPhoto(file);
123
+ const previewUrl = URL.createObjectURL(file);
124
+ trackUrl(previewUrl);
125
+ const photo = { file, prepared, previewUrl };
126
+ if (side === 'front') {
127
+ releaseUrl(frontPhoto?.previewUrl);
128
+ setFrontPhoto(photo);
129
+ }
130
+ else {
131
+ releaseUrl(backPhoto?.previewUrl);
132
+ setBackPhoto(photo);
133
+ }
134
+ }
135
+ catch (err) {
136
+ setCaptureError(err instanceof Error ? err.message : 'That photo could not be processed.');
137
+ }
138
+ finally {
139
+ setIsPreparing(false);
140
+ }
141
+ };
142
+ const handleRetake = (side) => {
143
+ setCaptureError(null);
144
+ if (side === 'front') {
145
+ releaseUrl(frontPhoto?.previewUrl);
146
+ setFrontPhoto(null);
147
+ }
148
+ else {
149
+ releaseUrl(backPhoto?.previewUrl);
150
+ setBackPhoto(null);
151
+ }
152
+ };
153
+ /**
154
+ * Render the initial stored-attachment crop for one side: from the AI's box
155
+ * when one came back, otherwise the centred auto-fit. A failed box crop
156
+ * falls back to the auto-fit rather than losing the side.
157
+ */
158
+ const renderInitialCrop = useCallback(async (side, photo, box) => {
159
+ const fileName = `card-${side}.jpg`;
160
+ if (box) {
161
+ try {
162
+ const image = await cropImageFileToBox(photo.file, box, { fileName });
163
+ trackUrl(image.previewUrl);
164
+ return { image, box, adjustments: null };
165
+ }
166
+ catch {
167
+ // Degenerate or unusable box — fall through to the auto-fit crop.
168
+ }
169
+ }
170
+ try {
171
+ const image = await cropImageFileToCard(photo.file, { fileName });
172
+ trackUrl(image.previewUrl);
173
+ return { image, box: null, adjustments: null };
174
+ }
175
+ catch {
176
+ return null;
177
+ }
178
+ }, [trackUrl]);
179
+ /**
180
+ * Move to the diff, reading the card first when that is possible.
181
+ *
182
+ * The read is skipped — silently and without an error — when the feature is
183
+ * off or when there is no front photo to read. Either way any photo taken is
184
+ * cropped for the new version's attachment, the form is seeded from the
185
+ * outgoing card, and the user edits by hand.
186
+ */
187
+ const goToReview = async (front, back) => {
188
+ setStage('processing');
189
+ const result = canExtract && front
190
+ ? await runExtraction({
191
+ front: front.prepared.dataUrl,
192
+ back: back?.prepared.dataUrl,
193
+ })
194
+ : null;
195
+ const nextFront = front
196
+ ? await renderInitialCrop('front', front, result?.crops?.front ?? null)
197
+ : null;
198
+ const nextBack = back
199
+ ? await renderInitialCrop('back', back, result?.crops?.back ?? null)
200
+ : null;
201
+ releaseUrl(frontCrop?.image.previewUrl);
202
+ releaseUrl(backCrop?.image.previewUrl);
203
+ setFrontCrop(nextFront);
204
+ setBackCrop(nextBack);
205
+ setValues(toRenewalValues(currentValues, result));
206
+ setEditedFields(new Set());
207
+ setFieldErrors({});
208
+ // The Crop step only exists when there is a photo to crop.
209
+ setStage(nextFront || nextBack ? 'crop' : 'review');
210
+ };
211
+ /** The user re-cropped a side in the diff step's adjuster. */
212
+ const handleCropChange = (side, image, adjustments) => {
213
+ trackUrl(image.previewUrl);
214
+ if (side === 'front') {
215
+ releaseUrl(frontCrop?.image.previewUrl);
216
+ setFrontCrop((prev) => ({ image, box: prev?.box ?? null, adjustments }));
217
+ }
218
+ else {
219
+ releaseUrl(backCrop?.image.previewUrl);
220
+ setBackCrop((prev) => ({ image, box: prev?.box ?? null, adjustments }));
221
+ }
222
+ };
223
+ const handleCancel = async () => {
224
+ // Nothing is created until the single renew call, so abandoning only has to
225
+ // drop uploads — there is never a half-made version to remove.
226
+ await abandonRenewal();
227
+ navigate(secretId ? `/secrets/${secretId}` : '/cards');
228
+ };
229
+ const handleFieldChange = (field, value) => {
230
+ setValues((prev) => ({ ...(prev ?? {}), [field]: value }));
231
+ setEditedFields((prev) => new Set(prev).add(field));
232
+ setFieldErrors((prev) => {
233
+ if (!prev[field])
234
+ return prev;
235
+ const next = { ...prev };
236
+ delete next[field];
237
+ return next;
238
+ });
239
+ };
240
+ const lowConfidenceFields = useMemo(() => {
241
+ const flagged = new Set();
242
+ if (!extraction?.confidence || !values)
243
+ return flagged;
244
+ for (const [field, score] of Object.entries(extraction.confidence)) {
245
+ if (editedFields.has(field))
246
+ continue;
247
+ if ((values[field] ?? '') === '')
248
+ continue;
249
+ // A value the extraction was unsure about but which matches the card we
250
+ // already hold needs no checking — the old version corroborates it.
251
+ if (values[field] === currentValues[field])
252
+ continue;
253
+ if (score <= LOW_CONFIDENCE_THRESHOLD)
254
+ flagged.add(field);
255
+ }
256
+ return flagged;
257
+ }, [extraction, values, editedFields, currentValues]);
258
+ const changes = useMemo(() => (values ? diffCardFields(fields, currentValues, values) : []), [fields, currentValues, values]);
259
+ const changedCount = changes.filter((change) => change.changed).length;
260
+ // Fields the AI supplied (and that differ from the card held, so it actually
261
+ // contributed them) and the user has not touched since.
262
+ const aiFields = useMemo(() => {
263
+ const seeded = aiSeededFields(extraction);
264
+ for (const field of editedFields)
265
+ seeded.delete(field);
266
+ for (const field of [...seeded]) {
267
+ if ((values?.[field] ?? '') === (currentValues[field] ?? ''))
268
+ seeded.delete(field);
269
+ }
270
+ return seeded;
271
+ }, [extraction, editedFields, values, currentValues]);
272
+ const cvvEntered = (values?.[CVV_FIELD] ?? '').trim() !== '';
273
+ const hasCvvField = fields.some((field) => field.name === CVV_FIELD);
274
+ const canSubmit = !isSubmitting && (!hasCvvField || cvvEntered);
275
+ const handleSubmit = async () => {
276
+ if (!values || !secret)
277
+ return;
278
+ const errors = {};
279
+ for (const field of fields) {
280
+ if (field.required && (values[field.name] ?? '').trim() === '') {
281
+ errors[field.name] = `${field.label} is required`;
282
+ }
283
+ }
284
+ if (Object.keys(errors).length > 0) {
285
+ setFieldErrors(errors);
286
+ return;
287
+ }
288
+ const renewed = await submitRenewal({
289
+ values,
290
+ images: capturedSides,
291
+ // The extraction actually used, so `aiAssisted` reports what happened
292
+ // rather than what was available. Null on a manual renewal.
293
+ extraction,
294
+ });
295
+ if (!renewed)
296
+ return;
297
+ // Land on the detail page: it shows the new current version AND the version
298
+ // history, which is where the old card's number and photos remain readable.
299
+ navigate(`/secrets/${renewed.id ?? secretId}`, {
300
+ state: { renewed: true },
301
+ });
302
+ };
303
+ // ---------------------------------------------------------------------------
304
+ // Loading / failure
305
+ // ---------------------------------------------------------------------------
306
+ const breadcrumbs = (_jsxs(Breadcrumbs, { sx: { mb: 1 }, children: [_jsx(Link, { color: "inherit", href: "/cards", onClick: (e) => {
307
+ e.preventDefault();
308
+ navigate('/cards');
309
+ }, children: "Cards" }), _jsx(Typography, { sx: {
310
+ color: "text.primary"
311
+ }, children: "Renew" })] }));
312
+ // NOTE: there is deliberately no AI availability gate here. The only thing
313
+ // `cardExtractEnabled` decides is whether the photos are read automatically.
314
+ if (isLoading) {
315
+ return (_jsx(Container, { maxWidth: "md", sx: { py: 6, textAlign: 'center' }, children: _jsx(CircularProgress, { "aria-label": "Loading the card" }) }));
316
+ }
317
+ if (loadError || !secret) {
318
+ return (_jsxs(Container, { maxWidth: "md", disableGutters: true, children: [breadcrumbs, _jsxs(Alert, { severity: "error", children: [_jsx(AlertTitle, { children: "This card could not be loaded" }), loadError ?? 'The card was not found.', _jsx(Box, { sx: { mt: 2 }, children: _jsx(Button, { variant: "outlined", onClick: () => navigate('/cards'), children: "Back to cards" }) })] })] }));
319
+ }
320
+ // ---------------------------------------------------------------------------
321
+ // Wizard
322
+ // ---------------------------------------------------------------------------
323
+ const photoSides = [
324
+ ...(frontPhoto ? [{ side: 'front', file: frontPhoto.file, crop: frontCrop }] : []),
325
+ ...(backPhoto ? [{ side: 'back', file: backPhoto.file, crop: backCrop }] : []),
326
+ ];
327
+ const activeStep = isSubmitting ? 'save' : STAGE_STEP[stage];
328
+ const skippedSteps = new Set(photoSides.length === 0 ? ['crop'] : []);
329
+ return (_jsxs(Container, { maxWidth: "md", disableGutters: true, children: [breadcrumbs, _jsxs(Typography, { variant: "h4", component: "h1", sx: { overflowWrap: 'anywhere', fontSize: { xs: '1.75rem', sm: '2.125rem' } }, children: ["Renew ", secret.name] }), _jsx(Typography, { variant: "body2", sx: { color: 'text.secondary', mt: 0.5 }, children: "Saves a new version. The current card \u2014 its number, name and photos \u2014 stays readable in this card's version history." }), _jsx(CardFlowStepper, { active: activeStep, skipped: skippedSteps }), stage === 'front' || stage === 'back' ? (_jsxs(_Fragment, { children: [canExtract ? (_jsx(AiEgressNotice, {})) : (_jsxs(Alert, { severity: "info", sx: { mb: 2 }, children: [_jsx(AlertTitle, { children: "Photos are not read automatically" }), "AI card reading is off, so nothing is sent to OpenAI. Any photo you add is cropped to the card and stored with the new version, and you type the new details yourself on the next step."] })), stage === 'front' ? (_jsx(CardCaptureStep, { side: "front", photo: frontPhoto, isProcessing: isPreparing, error: captureError, heading: "Photograph the front of the new card (optional)", helpText: canExtract
330
+ ? 'Make sure every corner of the card is in the shot and the text is readable. The new photo replaces the front image on this card; the old version keeps its own. Skip it to type the details instead.'
331
+ : 'Make sure every corner of the card is in the shot and the text is readable. The new photo replaces the front image on this card; the old version keeps its own. Skip it if you are only updating the details.', continueLabel: "Continue", skipLabel: "Skip the photo", onFileSelected: (file) => void handleFileSelected('front', file), onRetake: () => handleRetake('front'), onContinue: () => setStage('back'),
332
+ // Present on the FRONT step too, unlike import: a renewal with no
333
+ // new photos at all is a legitimate, common case (a reissued card
334
+ // with the same design, or a user who would rather not photograph
335
+ // it), and it is the only way the flow works with AI off and no
336
+ // camera to hand.
337
+ onSkip: () => {
338
+ releaseUrl(frontPhoto?.previewUrl);
339
+ setFrontPhoto(null);
340
+ setStage('back');
341
+ }, onCancel: () => void handleCancel() })) : (_jsx(CardCaptureStep, { side: "back", photo: backPhoto, isProcessing: isPreparing, error: captureError, heading: "Photograph the back of the new card (optional)", helpText: "Make sure every corner of the card is in the shot. The new photo replaces the back image on this card; the old version keeps its own.", continueLabel: canExtract && frontPhoto ? 'Read the card' : 'Continue', skipLabel: "Skip the photo", onFileSelected: (file) => void handleFileSelected('back', file), onRetake: () => handleRetake('back'), onContinue: () => void goToReview(frontPhoto, backPhoto), onSkip: () => {
342
+ releaseUrl(backPhoto?.previewUrl);
343
+ setBackPhoto(null);
344
+ void goToReview(frontPhoto, null);
345
+ }, onCancel: () => void handleCancel() }))] })) : stage === 'processing' ? (_jsxs(Paper, { variant: "outlined", sx: { p: 4, textAlign: 'center' }, "aria-live": "polite", children: [_jsx(CircularProgress, { sx: { mb: 2 } }), _jsx(Typography, { variant: "h6", component: "h2", gutterBottom: true, children: isExtracting ? 'Reading the new card…' : 'Preparing the photos…' }), _jsx(Typography, { variant: "body2", sx: { color: 'text.secondary' }, children: isExtracting
346
+ ? 'Your photos have been sent to OpenAI, which locates the card and reads the printed details. This usually takes a few seconds.'
347
+ : 'Cropping the photos to the card…' })] })) : stage === 'crop' ? (_jsxs(Paper, { variant: "outlined", sx: { p: { xs: 2, md: 3 } }, children: [_jsx(Typography, { variant: "h6", component: "h2", gutterBottom: true, children: "Check the crop" }), _jsx(CardCropReview, { sides: photoSides, onCropChange: handleCropChange }), _jsxs(Box, { sx: { display: 'flex', flexDirection: { xs: 'column', sm: 'row' }, gap: 1 }, children: [_jsx(Button, { variant: "contained", onClick: () => setStage('review'), sx: { minHeight: 44 }, children: "Continue to changes" }), _jsx(Button, { variant: "outlined", onClick: () => setStage('front'), sx: { minHeight: 44 }, children: "Retake photos" }), _jsx(Box, { sx: { flexGrow: 1, display: { xs: 'none', sm: 'block' } } }), _jsx(Button, { color: "inherit", onClick: () => void handleCancel(), sx: { minHeight: 44 }, children: "Cancel" })] })] })) : (_jsxs(Paper, { variant: "outlined", sx: { p: { xs: 2, md: 3 } }, children: [_jsx(Typography, { variant: "h6", component: "h2", gutterBottom: true, children: "Check what changes" }), _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1, mb: 2, flexWrap: 'wrap' }, children: [_jsx(Chip, { size: "small", color: changedCount > 0 ? 'primary' : 'default', label: changedCount === 0
348
+ ? 'Nothing changes yet'
349
+ : `${changedCount} field${changedCount === 1 ? '' : 's'} change` }), _jsx(Typography, { variant: "body2", sx: { color: 'text.secondary' }, children: "Everything else is saved exactly as it is now." })] }), extractionError && (_jsxs(Alert, { severity: extractionError.adminActionRequired ? 'warning' : 'error', sx: { mb: 2 }, action: extractionError.retryable ? (_jsx(Button, { color: "inherit", size: "small", onClick: () => void goToReview(frontPhoto, backPhoto), children: "Try again" })) : undefined, children: [_jsx(AlertTitle, { children: extractionError.title }), extractionError.detail, extractionError.adminLink && canOpenAiSettings && (_jsx(Box, { sx: { mt: 1 }, children: _jsx(Link, { component: RouterLink, to: extractionError.adminLink.to, children: extractionError.adminLink.label }) })), _jsx(Typography, { variant: "body2", sx: { mt: 1 }, children: "The current card's details are still below \u2014 edit whatever the new card changed and renew as normal." })] })), extraction?.partial && !extractionError && (_jsx(Alert, { severity: "warning", sx: { mb: 2 }, children: "Nothing legible came back from the photos. Edit the details below by hand." })), submitError && (_jsx(Alert, { severity: "error", sx: { mb: 2 }, children: submitError })), _jsx(CardCropReview, { compact: true, sides: photoSides, disabled: isSubmitting, onEdit: () => setStage('crop'), onCropChange: handleCropChange }), _jsx(CardReviewForm, { fields: fields, values: values ?? {}, onChange: handleFieldChange, lowConfidenceFields: lowConfidenceFields, aiFields: aiFields, warnings: extraction?.warnings ?? [], errors: fieldErrors, disabled: isSubmitting, currentValues: currentValues, notCarriedForwardField: CVV_FIELD }), hasCvvField && !cvvEntered && (_jsx(Alert, { severity: "info", sx: { mt: 2 }, children: "Enter the CVV / CVC from the new card to renew. It is never read from a photo, and the old card's code is never reused, so type it from the new card yourself." })), _jsxs(Box, { sx: { display: 'flex', flexDirection: { xs: 'column', sm: 'row' }, gap: 1, mt: 3 }, children: [_jsx(Button, { variant: "contained", onClick: () => void handleSubmit(), disabled: !canSubmit, sx: { minHeight: 44 }, children: isSubmitting ? 'Renewing…' : 'Renew card' }), _jsx(Box, { sx: { flexGrow: 1, display: { xs: 'none', sm: 'block' } } }), _jsx(Button, { color: "inherit", onClick: () => void handleCancel(), disabled: isSubmitting, sx: { minHeight: 44 }, children: "Cancel" })] })] }))] }));
350
+ }
@@ -0,0 +1,272 @@
1
+ /**
2
+ * The Vault domain calls, made through the host's one HTTP client.
3
+ *
4
+ * E3.3 (#78): the transport is the platform's `PlatformHttpClient`
5
+ * (`@marinoscar/platform-web/core`): the access-token holder, the one-shot
6
+ * 401 -> refresh -> retry, the cross-page refresh lock and the "session
7
+ * expired" signal the packaged `AuthProvider` drives sessions through.
8
+ * E12.3 (#104): the host builds that client (`apps/web/src/services/api.ts`)
9
+ * and hands it to this package with `configureVaultWeb` (`http.ts`); `api`
10
+ * below is that client.
11
+ *
12
+ * `ApiError` is re-exported so the call sites that import it from here keep
13
+ * doing so; it is the platform's class (same `message`, `status`, `code`,
14
+ * `details`), so `instanceof` still matches.
15
+ */
16
+ import { ApiError } from '@marinoscar/platform-web/core';
17
+ import type { PlatformHttpRequestOptions } from '@marinoscar/platform-web/core';
18
+ import { api } from './http.js';
19
+ export { ApiError, api };
20
+ /** Request options of {@link api}, for the few callers that name the type. */
21
+ export type RequestOptions = PlatformHttpRequestOptions;
22
+ import type { FieldDefinition, SecretType, SecretDetail, SecretVersion, SecretVersionDetail, SecretAttachment, SecretsResponse, CardSummaryResponse, RenewSecretRequest, RenewSecretResponse, MediaFolder, MediaFoldersResponse, MediaFile, MediaFilesResponse, AttachmentRole, SecretAgentAccess, CardExtractionResult, ExtractCardRequest, SystemSettings, BackupSchedule, UpdateBackupScheduleRequest, BackupRun, BackupRunsResponse, BackupDownloadLink, MyBackupsConfig, AdminBackupExportRequest } from './types.js';
23
+ /**
24
+ * Locate a card in FULL photos and read its fields.
25
+ *
26
+ * The transport is base64 JSON rather than multipart because `request()` above
27
+ * force-sets `Content-Type: application/json` whenever a body is present — a
28
+ * multipart endpoint would be unreachable through this client. Preparing the
29
+ * photos (downscale, size cap — see `prepareCardPhoto` in `utils/cardImage.ts`)
30
+ * is the caller's job; whatever is passed here is what leaves the device. The
31
+ * response's `crops` boxes are what the client then crops the stored
32
+ * attachments from — the full photos themselves are never uploaded to storage.
33
+ *
34
+ * The response carries card values (never a security code: `cvv` and
35
+ * `security_code_2` are always null since E8.1), so nothing here may log or
36
+ * persist the payload — it is handed straight to the review form and lives only
37
+ * in component state until the user saves.
38
+ */
39
+ export declare function extractCardFromImages(images: ExtractCardRequest): Promise<CardExtractionResult>;
40
+ /**
41
+ * Set the model card scanning runs on: `PATCH /api/system-settings` with
42
+ * `{ ai: { cardExtractModel } }` (Vault's extension of the platform AI policy,
43
+ * E8.2 #88). Everything else in the `ai` namespace is the platform's and is
44
+ * edited on the packaged AI page (`/api/admin/ai/*`); the provider key is never
45
+ * sent through system settings (the API ignores `ai.apiKey`).
46
+ *
47
+ * `version` goes as `If-Match`; the API answers 409 when the settings changed
48
+ * underneath us.
49
+ */
50
+ export declare function patchCardExtractModel(cardExtractModel: string, version: number): Promise<SystemSettings>;
51
+ export declare function getSecretTypes(params?: {
52
+ search?: string;
53
+ includeSystem?: boolean;
54
+ }): Promise<SecretType[]>;
55
+ export declare function getSecretType(id: string): Promise<SecretType>;
56
+ export declare function createSecretType(data: {
57
+ name: string;
58
+ description?: string;
59
+ icon?: string;
60
+ fields: FieldDefinition[];
61
+ allowAttachments: boolean;
62
+ }): Promise<SecretType>;
63
+ export declare function updateSecretType(id: string, data: {
64
+ name?: string;
65
+ description?: string | null;
66
+ icon?: string | null;
67
+ fields?: FieldDefinition[];
68
+ allowAttachments?: boolean;
69
+ }): Promise<SecretType>;
70
+ export declare function deleteSecretType(id: string): Promise<void>;
71
+ export declare function getSecrets(params?: {
72
+ page?: number;
73
+ pageSize?: number;
74
+ typeId?: string;
75
+ search?: string;
76
+ sortBy?: string;
77
+ sortOrder?: string;
78
+ agentAccess?: SecretAgentAccess;
79
+ }): Promise<SecretsResponse>;
80
+ /**
81
+ * One page of the caller's card summaries (#118), sorted soonest expiry first.
82
+ * `pageSize` is capped at 100 by the API.
83
+ */
84
+ export declare function getCardSummaries(params?: {
85
+ page?: number;
86
+ pageSize?: number;
87
+ }): Promise<CardSummaryResponse>;
88
+ export declare function getSecret(id: string): Promise<SecretDetail>;
89
+ /** The current one-time code of a secret's authenticator key (`POST /secrets/:id/totp`); never the seed. */
90
+ export interface SecretTotpCode {
91
+ code: string;
92
+ /** ISO time at which `code` stops being valid. */
93
+ expiresAt: string;
94
+ /** Seconds a code lives. */
95
+ period: number;
96
+ }
97
+ /** Fetch the current code on demand. Rejects with a 404 ApiError when the secret has no authenticator key. */
98
+ export declare function getSecretTotp(id: string): Promise<SecretTotpCode>;
99
+ export declare function createSecret(data: {
100
+ name: string;
101
+ description?: string;
102
+ typeId: string;
103
+ data: Record<string, unknown>;
104
+ }): Promise<SecretDetail>;
105
+ export declare function updateSecret(id: string, data: {
106
+ name?: string;
107
+ description?: string | null;
108
+ data?: Record<string, unknown>;
109
+ }): Promise<SecretDetail>;
110
+ /** Opens (`fill`) or closes (`none`) a Credential secret to agents; returns the updated detail. */
111
+ export declare function updateSecretAgentAccess(id: string, agentAccess: SecretAgentAccess): Promise<SecretDetail>;
112
+ export declare function deleteSecret(id: string): Promise<void>;
113
+ export declare function getSecretVersions(secretId: string): Promise<SecretVersion[]>;
114
+ export declare function getSecretVersion(secretId: string, versionId: string): Promise<SecretVersionDetail>;
115
+ export declare function rollbackSecretVersion(secretId: string, versionId: string): Promise<SecretDetail>;
116
+ /**
117
+ * Renew a secret: create the next version from a new full field set, swapping
118
+ * only the attachment roles named in the request.
119
+ *
120
+ * This is the ONE call the renewal flow makes to commit. It is atomic on the
121
+ * server — version bump, attachment carry-forward and replacement insert all
122
+ * happen in a single transaction — so there is no half-renewed state to unwind
123
+ * on failure, unlike creating a secret and then linking files to it.
124
+ *
125
+ * `body.data` must be the COMPLETE field set for the renewed secret. The API
126
+ * replaces rather than merges, so any field left out is gone from the new
127
+ * version even though it was present on the old one.
128
+ */
129
+ export declare function renewSecret(secretId: string, body: RenewSecretRequest): Promise<RenewSecretResponse>;
130
+ /**
131
+ * Link an already-uploaded storage object to a secret.
132
+ *
133
+ * `role` marks the object as a card face. The API enforces one attachment per
134
+ * role per secret version and applies image mime/size constraints to
135
+ * role-bearing attachments, so passing a role is not cosmetic — it changes what
136
+ * the server will accept.
137
+ */
138
+ export declare function linkSecretAttachment(secretId: string, storageObjectId: string, label?: string, role?: AttachmentRole): Promise<SecretAttachment>;
139
+ export declare function unlinkSecretAttachment(secretId: string, attachmentId: string): Promise<void>;
140
+ export declare function getMediaFolders(params?: {
141
+ page?: number;
142
+ pageSize?: number;
143
+ search?: string;
144
+ sortBy?: string;
145
+ sortOrder?: string;
146
+ }): Promise<MediaFoldersResponse>;
147
+ export declare function getMediaFolder(folderId: string): Promise<MediaFolder>;
148
+ export declare function createMediaFolder(name: string): Promise<MediaFolder>;
149
+ export declare function updateMediaFolder(folderId: string, name: string): Promise<MediaFolder>;
150
+ export declare function deleteMediaFolder(folderId: string): Promise<void>;
151
+ export declare function getMediaFiles(folderId: string, params?: {
152
+ page?: number;
153
+ pageSize?: number;
154
+ search?: string;
155
+ }): Promise<MediaFilesResponse>;
156
+ export declare function getMediaFile(folderId: string, fileId: string): Promise<MediaFile>;
157
+ export declare function linkMediaFile(folderId: string, storageObjectId: string): Promise<MediaFile>;
158
+ export declare function renameMediaFile(folderId: string, fileId: string, name: string): Promise<MediaFile>;
159
+ export declare function deleteMediaFile(folderId: string, fileId: string): Promise<void>;
160
+ export declare function getMediaFileDownloadUrl(folderId: string, fileId: string): Promise<{
161
+ url: string;
162
+ expiresIn: number;
163
+ }>;
164
+ /**
165
+ * Signed download URL for any storage object the caller owns.
166
+ *
167
+ * The media variant above is scoped to a folder and cannot address an object
168
+ * linked as a secret attachment, which is what card face images are.
169
+ */
170
+ export declare function getStorageObjectDownloadUrl(objectId: string, expiresIn?: number): Promise<{
171
+ url: string;
172
+ expiresIn: number;
173
+ }>;
174
+ /**
175
+ * Delete a storage object outright.
176
+ *
177
+ * Used to clean up after an abandoned or half-failed card import: an image
178
+ * uploaded before the flow was cancelled would otherwise sit in storage with
179
+ * nothing pointing at it and no UI able to reach it.
180
+ */
181
+ export declare function deleteStorageObject(objectId: string): Promise<void>;
182
+ export declare function simpleStorageUpload(file: File): Promise<{
183
+ id: string;
184
+ name: string;
185
+ mimeType: string;
186
+ size: number;
187
+ }>;
188
+ export interface SecretsBackupOptions {
189
+ password: string;
190
+ /** Default true. */
191
+ includeSecrets?: boolean;
192
+ /** Default true; only sent as true while includeSecrets is on. */
193
+ includeAttachments?: boolean;
194
+ /** Default false; only sent as true while includeSecrets is on. */
195
+ includeVersions?: boolean;
196
+ /** Default false: the user's own media library. */
197
+ includeMedia?: boolean;
198
+ }
199
+ export interface SecretsBackupResult {
200
+ blob: Blob;
201
+ filename: string;
202
+ secretCount: number | null;
203
+ attachmentCount: number | null;
204
+ mediaFileCount: number | null;
205
+ }
206
+ /** `vault-backup-YYYY-MM-DD.zip` for the given date (UTC, matching the server). */
207
+ export declare function defaultBackupFilename(date?: Date): string;
208
+ /**
209
+ * Extract the file name from a Content-Disposition header. Supports the
210
+ * RFC 5987 `filename*=UTF-8''...` form and quoted/unquoted `filename=`.
211
+ * Path separators are stripped so the value can only name a file.
212
+ */
213
+ export declare function parseContentDispositionFilename(header: string | null | undefined): string | null;
214
+ /** The streamed zip of a backup export, with the counts the server reports. */
215
+ export interface BackupStreamResult {
216
+ blob: Blob;
217
+ filename: string;
218
+ /** Admin downloads only (X-Vault-Export-Users); null when absent. */
219
+ userCount: number | null;
220
+ secretCount: number | null;
221
+ attachmentCount: number | null;
222
+ mediaFileCount: number | null;
223
+ }
224
+ /**
225
+ * Download a password-protected (AES-256 zip) backup of what the current
226
+ * user owns: secrets (with attachments / old versions) and/or their media
227
+ * library. The password travels only in the request body; it is
228
+ * never logged or stored here.
229
+ */
230
+ export declare function downloadSecretsBackup(options: SecretsBackupOptions): Promise<SecretsBackupResult>;
231
+ /** Whether saving to storage is available, and how many saved backups are kept. */
232
+ export declare function getMyBackupsConfig(): Promise<MyBackupsConfig>;
233
+ /**
234
+ * Build the same zip as `downloadSecretsBackup` on the server and save it to
235
+ * object storage (202, runs in the background). The password is used only
236
+ * while building and never stored. Rejects with a 409 ApiError while one of
237
+ * the user's backups is running, 400 when storage is not configured.
238
+ */
239
+ export declare function saveMyBackupToStorage(options: SecretsBackupOptions): Promise<BackupRun>;
240
+ /** The current user's saved backups, newest first. */
241
+ export declare function getMyBackups(params?: {
242
+ page?: number;
243
+ pageSize?: number;
244
+ }): Promise<BackupRunsResponse>;
245
+ /** Short-lived signed download URL for one of the user's saved backups. */
246
+ export declare function getMyBackupDownloadUrl(id: string): Promise<BackupDownloadLink>;
247
+ /** Delete one of the user's saved backups from storage (the row stays, marked deleted). */
248
+ export declare function deleteMyBackup(id: string): Promise<void>;
249
+ /** Current backup schedule (server defaults when none was saved). Never the password. */
250
+ export declare function getBackupSchedule(): Promise<BackupSchedule>;
251
+ /**
252
+ * Replace the backup schedule. `password` is write-only: leave it out to keep
253
+ * the stored one. The password travels only in this request body.
254
+ */
255
+ export declare function updateBackupSchedule(data: UpdateBackupScheduleRequest): Promise<BackupSchedule>;
256
+ /** Start a manual backup run (202). Rejects with a 409 ApiError while one is running. */
257
+ export declare function runBackupNow(): Promise<BackupRun>;
258
+ /** Backup run history, newest first. */
259
+ export declare function getBackupRuns(params?: {
260
+ page?: number;
261
+ pageSize?: number;
262
+ }): Promise<BackupRunsResponse>;
263
+ /** Short-lived signed download URL for a succeeded, not deleted backup. */
264
+ export declare function getBackupDownloadUrl(id: string): Promise<BackupDownloadLink>;
265
+ /** Delete a backup's archive from storage (the run row stays, marked deleted). */
266
+ export declare function deleteBackupRun(id: string): Promise<void>;
267
+ /**
268
+ * Build a backup now and stream it to the browser; nothing is stored. Send
269
+ * either a `password` or `useScheduledPassword: true` (the stored schedule
270
+ * password), never both. The password travels only in the request body.
271
+ */
272
+ export declare function downloadAdminBackup(request: AdminBackupExportRequest): Promise<BackupStreamResult>;