@marinoscar/vault-web 0.0.0-stage → 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 +98 -2
  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 +144 -4
@@ -0,0 +1,42 @@
1
+ import { createPlatformApiClient } from '@marinoscar/platform-web/core';
2
+ import { useAiConfig } from '@marinoscar/platform-web/ai/headless';
3
+ import { usePermissions } from '@marinoscar/platform-web/identity/headless';
4
+ import { api } from './http.js';
5
+ import { isCardScanAvailable } from './cardScanAvailability.js';
6
+ /**
7
+ * The package's own transport for `GET /api/ai/config` when no shared copy is
8
+ * mounted. A module constant (the hook keys its fetch on the identity); `api` is
9
+ * a lazy proxy, so nothing is read before `configureVaultWeb`.
10
+ */
11
+ const vaultAiApi = createPlatformApiClient(api);
12
+ /**
13
+ * Whether AI-backed features are available to the current user.
14
+ *
15
+ * Reads the platform's `GET /api/ai/config` through `useAiConfig`
16
+ * (`@marinoscar/platform-web/ai/headless`): the shell's shared copy when the host
17
+ * mounts an `AiConfigContext` provider (apps/web's `VaultAiConfigProvider`), so no
18
+ * second request is made; otherwise its own fetch through this package's client.
19
+ * Card-scan availability is derived on the client with the server's rule
20
+ * (`isCardScanAvailable`).
21
+ *
22
+ * FAILS CLOSED. A network error, a 500, or a malformed body all resolve to
23
+ * "not enabled". Gating an entry point on this hook must never open the gate
24
+ * because the check itself broke — the alternative is offering a card scan that
25
+ * can only end in an error the user cannot act on.
26
+ *
27
+ * The UI presents, the API authorizes: hiding the scan option from a caller
28
+ * without `ai:use` saves them a 403, it is not the gate.
29
+ */
30
+ export function useAiStatus() {
31
+ const { hasPermission } = usePermissions();
32
+ const canUseAi = hasPermission('ai:use');
33
+ const { config, isLoading, error, refresh } = useAiConfig({ api: vaultAiApi });
34
+ return {
35
+ config,
36
+ isLoading,
37
+ error,
38
+ cardExtractEnabled: canUseAi && error === null && isCardScanAvailable(config),
39
+ canUseAi,
40
+ refresh,
41
+ };
42
+ }
@@ -0,0 +1,20 @@
1
+ import { type CopyToClipboardOptions } from './clipboard.js';
2
+ /** How long the `copied` acknowledgement stays true, in milliseconds. */
3
+ export declare const COPIED_RESET_MS = 1500;
4
+ interface UseCopyToClipboardResult {
5
+ /** Copy `text`; resolves to true on success. Never throws. */
6
+ copy: (text: string) => Promise<boolean>;
7
+ /** True for a short window after a successful copy. */
8
+ copied: boolean;
9
+ /** True for a short window after a failed copy. */
10
+ failed: boolean;
11
+ }
12
+ /**
13
+ * Clipboard copying with the transient acknowledgement state a button needs.
14
+ *
15
+ * `copied` and `failed` are mutually exclusive and both reset after
16
+ * {@link COPIED_RESET_MS}. Pending timers are cancelled on unmount so a copy
17
+ * from a row that then disappears cannot set state on an unmounted component.
18
+ */
19
+ export declare function useCopyToClipboard(options?: CopyToClipboardOptions): UseCopyToClipboardResult;
20
+ export {};
@@ -0,0 +1,52 @@
1
+ import { useState, useCallback, useEffect, useRef } from 'react';
2
+ import { copyToClipboard } from './clipboard.js';
3
+ /** How long the `copied` acknowledgement stays true, in milliseconds. */
4
+ export const COPIED_RESET_MS = 1500;
5
+ /**
6
+ * Clipboard copying with the transient acknowledgement state a button needs.
7
+ *
8
+ * `copied` and `failed` are mutually exclusive and both reset after
9
+ * {@link COPIED_RESET_MS}. Pending timers are cancelled on unmount so a copy
10
+ * from a row that then disappears cannot set state on an unmounted component.
11
+ */
12
+ export function useCopyToClipboard(options = {}) {
13
+ const [copied, setCopied] = useState(false);
14
+ const [failed, setFailed] = useState(false);
15
+ const resetTimerRef = useRef(null);
16
+ const isMountedRef = useRef(true);
17
+ // Held in a ref so callers can pass an inline options object without
18
+ // invalidating `copy` on every render.
19
+ const optionsRef = useRef(options);
20
+ optionsRef.current = options;
21
+ useEffect(() => {
22
+ isMountedRef.current = true;
23
+ return () => {
24
+ isMountedRef.current = false;
25
+ if (resetTimerRef.current !== null) {
26
+ clearTimeout(resetTimerRef.current);
27
+ resetTimerRef.current = null;
28
+ }
29
+ };
30
+ }, []);
31
+ const copy = useCallback(async (text) => {
32
+ const success = await copyToClipboard(text, optionsRef.current);
33
+ if (!isMountedRef.current) {
34
+ return success;
35
+ }
36
+ setCopied(success);
37
+ setFailed(!success);
38
+ // Restart the window on every copy so rapid clicks don't clear early.
39
+ if (resetTimerRef.current !== null) {
40
+ clearTimeout(resetTimerRef.current);
41
+ }
42
+ resetTimerRef.current = setTimeout(() => {
43
+ resetTimerRef.current = null;
44
+ if (isMountedRef.current) {
45
+ setCopied(false);
46
+ setFailed(false);
47
+ }
48
+ }, COPIED_RESET_MS);
49
+ return success;
50
+ }, []);
51
+ return { copy, copied, failed };
52
+ }
@@ -0,0 +1,22 @@
1
+ export type DashboardResourceStatus = 'idle' | 'loading' | 'ready' | 'error';
2
+ export interface DashboardResource<T> {
3
+ /** `idle` while disabled (the user lacks the permission), so nothing is fetched. */
4
+ status: DashboardResourceStatus;
5
+ data: T | null;
6
+ error: string | null;
7
+ /** Fetch again (the error state's "Try again"). */
8
+ reload: () => void;
9
+ }
10
+ /**
11
+ * One independently loaded dashboard source.
12
+ *
13
+ * Each Home panel owns one of these, so every source starts on mount in
14
+ * parallel, a slow or failing source never holds back the others, and each
15
+ * panel has its own loading, error and retry. A disabled resource issues no
16
+ * request at all: the API would answer 403, and hiding the panel is the UI's
17
+ * half of the same gate.
18
+ *
19
+ * `fetcher` must be stable (a module-level function or a `useCallback`).
20
+ * Responses that arrive after a newer request (or after unmount) are dropped.
21
+ */
22
+ export declare function useDashboardResource<T>(fetcher: () => Promise<T>, enabled: boolean, errorFallback?: string): DashboardResource<T>;
@@ -0,0 +1,52 @@
1
+ import { useCallback, useEffect, useRef, useState } from 'react';
2
+ /**
3
+ * One independently loaded dashboard source.
4
+ *
5
+ * Each Home panel owns one of these, so every source starts on mount in
6
+ * parallel, a slow or failing source never holds back the others, and each
7
+ * panel has its own loading, error and retry. A disabled resource issues no
8
+ * request at all: the API would answer 403, and hiding the panel is the UI's
9
+ * half of the same gate.
10
+ *
11
+ * `fetcher` must be stable (a module-level function or a `useCallback`).
12
+ * Responses that arrive after a newer request (or after unmount) are dropped.
13
+ */
14
+ export function useDashboardResource(fetcher, enabled, errorFallback = 'Something went wrong') {
15
+ const [state, setState] = useState(() => ({
16
+ status: enabled ? 'loading' : 'idle',
17
+ data: null,
18
+ error: null,
19
+ }));
20
+ const requestId = useRef(0);
21
+ const load = useCallback(async () => {
22
+ const id = ++requestId.current;
23
+ setState((prev) => ({ status: 'loading', data: prev.data, error: null }));
24
+ try {
25
+ const data = await fetcher();
26
+ if (id === requestId.current)
27
+ setState({ status: 'ready', data, error: null });
28
+ }
29
+ catch (err) {
30
+ if (id !== requestId.current)
31
+ return;
32
+ const message = err instanceof Error && err.message ? err.message : errorFallback;
33
+ setState({ status: 'error', data: null, error: message });
34
+ }
35
+ }, [fetcher, errorFallback]);
36
+ useEffect(() => {
37
+ if (!enabled) {
38
+ requestId.current++;
39
+ setState({ status: 'idle', data: null, error: null });
40
+ return;
41
+ }
42
+ void load();
43
+ return () => {
44
+ // Invalidate in-flight responses on unmount or when the source changes.
45
+ requestId.current++;
46
+ };
47
+ }, [enabled, load]);
48
+ const reload = useCallback(() => {
49
+ void load();
50
+ }, [load]);
51
+ return { ...state, reload };
52
+ }
@@ -0,0 +1,17 @@
1
+ import type { SystemSettings } from './types.js';
2
+ interface UseSystemSettingsReturn {
3
+ settings: SystemSettings | null;
4
+ isLoading: boolean;
5
+ error: string | null;
6
+ isSaving: boolean;
7
+ updateSettings: (updates: Partial<SystemSettings>) => Promise<void>;
8
+ /**
9
+ * Set `ai.cardExtractModel`, the model card scanning runs on (E8.2). The rest
10
+ * of the `ai` namespace is the platform's AI page's (`/api/admin/ai/*`).
11
+ */
12
+ updateCardExtractModel: (model: string) => Promise<void>;
13
+ replaceSettings: (settings: Omit<SystemSettings, 'updatedAt' | 'updatedBy' | 'version'>) => Promise<void>;
14
+ refresh: () => Promise<void>;
15
+ }
16
+ export declare function useSystemSettings(): UseSystemSettingsReturn;
17
+ export {};
@@ -0,0 +1,106 @@
1
+ import { useState, useEffect, useCallback } from 'react';
2
+ import { api, ApiError, patchCardExtractModel } from './api.js';
3
+ const CONFLICT_MESSAGE = 'Settings were updated elsewhere. Please review and try again.';
4
+ export function useSystemSettings() {
5
+ const [settings, setSettings] = useState(null);
6
+ const [isLoading, setIsLoading] = useState(true);
7
+ const [error, setError] = useState(null);
8
+ const [isSaving, setIsSaving] = useState(false);
9
+ const fetchSettings = useCallback(async () => {
10
+ try {
11
+ setIsLoading(true);
12
+ setError(null);
13
+ const data = await api.get('/system-settings');
14
+ setSettings(data);
15
+ }
16
+ catch (err) {
17
+ if (err instanceof ApiError && err.status === 403) {
18
+ setError('You do not have permission to view system settings');
19
+ }
20
+ else {
21
+ const message = err instanceof ApiError ? err.message : 'Failed to load settings';
22
+ setError(message);
23
+ }
24
+ }
25
+ finally {
26
+ setIsLoading(false);
27
+ }
28
+ }, []);
29
+ useEffect(() => {
30
+ fetchSettings();
31
+ }, [fetchSettings]);
32
+ const updateSettings = useCallback(async (updates) => {
33
+ if (!settings)
34
+ return;
35
+ try {
36
+ setIsSaving(true);
37
+ setError(null);
38
+ const data = await api.patch('/system-settings', updates, {
39
+ headers: {
40
+ 'If-Match': settings.version.toString(),
41
+ },
42
+ });
43
+ setSettings(data);
44
+ }
45
+ catch (err) {
46
+ if (err instanceof ApiError && err.status === 409) {
47
+ await fetchSettings();
48
+ throw new Error(CONFLICT_MESSAGE);
49
+ }
50
+ const message = err instanceof ApiError ? err.message : 'Failed to save settings';
51
+ setError(message);
52
+ throw err;
53
+ }
54
+ finally {
55
+ setIsSaving(false);
56
+ }
57
+ }, [settings, fetchSettings]);
58
+ const updateCardExtractModel = useCallback(async (model) => {
59
+ if (!settings)
60
+ return;
61
+ try {
62
+ setIsSaving(true);
63
+ setError(null);
64
+ const data = await patchCardExtractModel(model, settings.version);
65
+ setSettings(data);
66
+ }
67
+ catch (err) {
68
+ if (err instanceof ApiError && err.status === 409) {
69
+ await fetchSettings();
70
+ throw new Error(CONFLICT_MESSAGE);
71
+ }
72
+ const message = err instanceof ApiError ? err.message : 'Failed to save settings';
73
+ setError(message);
74
+ throw err;
75
+ }
76
+ finally {
77
+ setIsSaving(false);
78
+ }
79
+ }, [settings, fetchSettings]);
80
+ const replaceSettings = useCallback(async (newSettings) => {
81
+ try {
82
+ setIsSaving(true);
83
+ setError(null);
84
+ const data = await api.put('/system-settings', newSettings);
85
+ setSettings(data);
86
+ }
87
+ catch (err) {
88
+ const message = err instanceof ApiError ? err.message : 'Failed to save settings';
89
+ setError(message);
90
+ throw err;
91
+ }
92
+ finally {
93
+ setIsSaving(false);
94
+ }
95
+ }, []);
96
+ return {
97
+ settings,
98
+ isLoading,
99
+ error,
100
+ isSaving,
101
+ updateSettings,
102
+ updateCardExtractModel,
103
+ replaceSettings,
104
+ refresh: fetchSettings,
105
+ };
106
+ }
@@ -0,0 +1,13 @@
1
+ import { UserSettings } from './types.js';
2
+ interface UseUserSettingsReturn {
3
+ settings: UserSettings | null;
4
+ isLoading: boolean;
5
+ error: string | null;
6
+ isSaving: boolean;
7
+ updateSettings: (updates: Partial<UserSettings>) => Promise<void>;
8
+ updateTheme: (theme: 'light' | 'dark' | 'system') => Promise<void>;
9
+ updateProfile: (profile: UserSettings['profile']) => Promise<void>;
10
+ refresh: () => Promise<void>;
11
+ }
12
+ export declare function useUserSettings(): UseUserSettingsReturn;
13
+ export {};
@@ -0,0 +1,103 @@
1
+ import { useState, useEffect, useCallback } from 'react';
2
+ import { api, ApiError } from './api.js';
3
+ import { useOptionalShellTheme } from '@marinoscar/platform-web/shell/headless';
4
+ function fromWire(data) {
5
+ const profile = (data.profile ?? {});
6
+ const { imageSource, ...rest } = profile;
7
+ return {
8
+ ...data,
9
+ profile: { ...rest, useProviderImage: rest.useProviderImage ?? imageSource !== 'none' },
10
+ };
11
+ }
12
+ function toWire(updates) {
13
+ if (!updates.profile)
14
+ return updates;
15
+ const { useProviderImage, customImageUrl, ...rest } = updates.profile;
16
+ return {
17
+ ...updates,
18
+ profile: {
19
+ ...rest,
20
+ imageSource: useProviderImage === false ? 'none' : 'provider',
21
+ // `null` deletes the stored URL (JSON Merge Patch).
22
+ customImageUrl: customImageUrl ? customImageUrl : null,
23
+ },
24
+ };
25
+ }
26
+ export function useUserSettings() {
27
+ const [settings, setSettings] = useState(null);
28
+ const [isLoading, setIsLoading] = useState(true);
29
+ const [error, setError] = useState(null);
30
+ const [isSaving, setIsSaving] = useState(false);
31
+ // The stored `theme` setting drives the shell's light / dark / system choice.
32
+ // Optional: a hook test may render without a ShellRoot.
33
+ // Keyed on the stable setter, not the context value: a theme change must not refetch.
34
+ const setShellMode = useOptionalShellTheme()?.setMode;
35
+ const setMode = useCallback((mode) => setShellMode?.(mode), [setShellMode]);
36
+ const fetchSettings = useCallback(async () => {
37
+ try {
38
+ setIsLoading(true);
39
+ setError(null);
40
+ const data = fromWire(await api.get('/user-settings'));
41
+ setSettings(data);
42
+ // Sync theme with settings
43
+ setMode(data.theme);
44
+ }
45
+ catch (err) {
46
+ const message = err instanceof ApiError ? err.message : 'Failed to load settings';
47
+ setError(message);
48
+ }
49
+ finally {
50
+ setIsLoading(false);
51
+ }
52
+ }, [setMode]);
53
+ useEffect(() => {
54
+ fetchSettings();
55
+ }, [fetchSettings]);
56
+ const updateSettings = useCallback(async (updates) => {
57
+ if (!settings)
58
+ return;
59
+ try {
60
+ setIsSaving(true);
61
+ setError(null);
62
+ const data = fromWire(await api.patch('/user-settings', toWire(updates), {
63
+ headers: {
64
+ 'If-Match': settings.version.toString(),
65
+ },
66
+ }));
67
+ setSettings(data);
68
+ // Sync theme if changed
69
+ if (updates.theme) {
70
+ setMode(updates.theme);
71
+ }
72
+ }
73
+ catch (err) {
74
+ if (err instanceof ApiError && err.status === 409) {
75
+ // Version conflict - refresh and retry
76
+ await fetchSettings();
77
+ throw new Error('Settings were updated elsewhere. Please try again.');
78
+ }
79
+ const message = err instanceof ApiError ? err.message : 'Failed to save settings';
80
+ setError(message);
81
+ throw err;
82
+ }
83
+ finally {
84
+ setIsSaving(false);
85
+ }
86
+ }, [settings, setMode, fetchSettings]);
87
+ const updateTheme = useCallback(async (theme) => {
88
+ await updateSettings({ theme });
89
+ }, [updateSettings]);
90
+ const updateProfile = useCallback(async (profile) => {
91
+ await updateSettings({ profile });
92
+ }, [updateSettings]);
93
+ return {
94
+ settings,
95
+ isLoading,
96
+ error,
97
+ isSaving,
98
+ updateSettings,
99
+ updateTheme,
100
+ updateProfile,
101
+ refresh: fetchSettings,
102
+ };
103
+ }
@@ -0,0 +1,15 @@
1
+ import { Component, ErrorInfo, ReactNode } from 'react';
2
+ interface Props {
3
+ children: ReactNode;
4
+ }
5
+ interface State {
6
+ hasError: boolean;
7
+ error?: Error;
8
+ }
9
+ export declare class ErrorBoundary extends Component<Props, State> {
10
+ state: State;
11
+ static getDerivedStateFromError(error: Error): State;
12
+ componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
13
+ render(): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined;
14
+ }
15
+ export {};
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Component } from 'react';
3
+ import { Box, Typography, Button } from '@mui/material';
4
+ export class ErrorBoundary extends Component {
5
+ state = { hasError: false };
6
+ static getDerivedStateFromError(error) {
7
+ return { hasError: true, error };
8
+ }
9
+ componentDidCatch(error, errorInfo) {
10
+ console.error('Uncaught error:', error, errorInfo);
11
+ }
12
+ render() {
13
+ if (this.state.hasError) {
14
+ return (_jsxs(Box, { sx: {
15
+ display: 'flex',
16
+ flexDirection: 'column',
17
+ alignItems: 'center',
18
+ justifyContent: 'center',
19
+ height: '100vh',
20
+ gap: 2,
21
+ }, children: [_jsx(Typography, { variant: "h4", children: "Something went wrong" }), _jsx(Typography, { sx: {
22
+ color: "text.secondary"
23
+ }, children: this.state.error?.message || 'An unexpected error occurred' }), _jsx(Button, { variant: "contained", onClick: () => window.location.reload(), children: "Reload Page" })] }));
24
+ }
25
+ return this.props.children;
26
+ }
27
+ }
@@ -0,0 +1,6 @@
1
+ interface LoadingSpinnerProps {
2
+ fullScreen?: boolean;
3
+ size?: number;
4
+ }
5
+ export declare function LoadingSpinner({ fullScreen, size }: LoadingSpinnerProps): import("react").JSX.Element;
6
+ export {};
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Box, CircularProgress } from '@mui/material';
3
+ export function LoadingSpinner({ fullScreen = false, size = 40 }) {
4
+ if (fullScreen) {
5
+ return (_jsx(Box, { sx: {
6
+ display: 'flex',
7
+ justifyContent: 'center',
8
+ alignItems: 'center',
9
+ height: '100vh',
10
+ width: '100vw',
11
+ }, children: _jsx(CircularProgress, { size: size }) }));
12
+ }
13
+ return (_jsx(Box, { sx: { display: 'flex', justifyContent: 'center', p: 3 }, children: _jsx(CircularProgress, { size: size }) }));
14
+ }
@@ -0,0 +1,19 @@
1
+ import type { ReactNode } from 'react';
2
+ interface SettingsPageFrameProps {
3
+ /** The page's `h1`: the card's title, word for word. */
4
+ title: string;
5
+ /** The line under the title. */
6
+ description: ReactNode;
7
+ /** `md` for a single-column form, `lg` for tables. */
8
+ maxWidth?: 'md' | 'lg';
9
+ children: ReactNode;
10
+ }
11
+ /**
12
+ * The chrome every settings card page shares (E10.3, issue #94): the same
13
+ * container, padding and heading as the packaged Doctor, About and Maintenance
14
+ * pages, so a card opened from either hub looks like its neighbours. Below
15
+ * 600px the shell's compact AppBar also shows the title with a back arrow to
16
+ * the hub; the heading stays for the document outline.
17
+ */
18
+ export declare function SettingsPageFrame({ title, description, maxWidth, children }: SettingsPageFrameProps): import("react").JSX.Element;
19
+ export {};
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Container, Typography } from '@mui/material';
3
+ /**
4
+ * The chrome every settings card page shares (E10.3, issue #94): the same
5
+ * container, padding and heading as the packaged Doctor, About and Maintenance
6
+ * pages, so a card opened from either hub looks like its neighbours. Below
7
+ * 600px the shell's compact AppBar also shows the title with a back arrow to
8
+ * the hub; the heading stays for the document outline.
9
+ */
10
+ export function SettingsPageFrame({ title, description, maxWidth = 'md', children }) {
11
+ return (_jsx(Container, { maxWidth: maxWidth, children: _jsxs(Box, { sx: { py: { xs: 2, sm: 4 } }, children: [_jsx(Typography, { variant: "h4", component: "h1", gutterBottom: true, children: title }), _jsx(Typography, { component: "div", sx: { color: 'text.secondary', mb: 3 }, children: description }), children] }) }));
12
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The Console's Storage card (E6.1 web follow-up): the packaged
3
+ * `StorageConfigPage`, where an administrator sets the bucket and its key.
4
+ * Since E6.1 (#84) object storage is runtime configuration, never environment
5
+ * variables, so every "storage is not configured" hint points here.
6
+ */
7
+ export declare const STORAGE_SETTINGS_PATH = "/admin/settings/storage";
8
+ /** The exact string the platform's storage-config controller enforces on its GET. */
9
+ export declare const STORAGE_SETTINGS_PERMISSION = "storage_config:read";
10
+ export declare const STORAGE_SETTINGS_LINK_LABEL = "Set up storage in Console \u2192 Storage";
11
+ /**
12
+ * A link to the Storage card, rendered only for a viewer who can open it
13
+ * (`storage_config:read`); for anyone else it renders nothing, so the hint
14
+ * around it reads as "ask an administrator". Hiding it is presentation only:
15
+ * the route and the API enforce the permission.
16
+ */
17
+ export declare function StorageSettingsLink({ label }: {
18
+ label?: string;
19
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,26 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Link } from '@mui/material';
3
+ import { Link as RouterLink } from 'react-router-dom';
4
+ import { usePermissions } from '@marinoscar/platform-web/identity/headless';
5
+ /**
6
+ * The Console's Storage card (E6.1 web follow-up): the packaged
7
+ * `StorageConfigPage`, where an administrator sets the bucket and its key.
8
+ * Since E6.1 (#84) object storage is runtime configuration, never environment
9
+ * variables, so every "storage is not configured" hint points here.
10
+ */
11
+ export const STORAGE_SETTINGS_PATH = '/admin/settings/storage';
12
+ /** The exact string the platform's storage-config controller enforces on its GET. */
13
+ export const STORAGE_SETTINGS_PERMISSION = 'storage_config:read';
14
+ export const STORAGE_SETTINGS_LINK_LABEL = 'Set up storage in Console → Storage';
15
+ /**
16
+ * A link to the Storage card, rendered only for a viewer who can open it
17
+ * (`storage_config:read`); for anyone else it renders nothing, so the hint
18
+ * around it reads as "ask an administrator". Hiding it is presentation only:
19
+ * the route and the API enforce the permission.
20
+ */
21
+ export function StorageSettingsLink({ label = STORAGE_SETTINGS_LINK_LABEL }) {
22
+ const { hasPermission } = usePermissions();
23
+ if (!hasPermission(STORAGE_SETTINGS_PERMISSION))
24
+ return null;
25
+ return (_jsx(Link, { component: RouterLink, to: STORAGE_SETTINGS_PATH, "data-testid": "storage-settings-link", children: label }));
26
+ }
@@ -0,0 +1,4 @@
1
+ export * from './ErrorBoundary.js';
2
+ export * from './LoadingSpinner.js';
3
+ export * from './SettingsPageFrame.js';
4
+ export * from './StorageSettingsLink.js';
@@ -0,0 +1,5 @@
1
+ // Components every slice uses: the spinner, the error boundary, the settings-page frame and the storage-settings link.
2
+ export * from './ErrorBoundary.js';
3
+ export * from './LoadingSpinner.js';
4
+ export * from './SettingsPageFrame.js';
5
+ export * from './StorageSettingsLink.js';
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Where the Home dashboard links to, in one place.
3
+ *
4
+ * The backup links point at their settings cards (E10.3, #94): the user's
5
+ * My backups card and the Console's Backups card.
6
+ */
7
+ export declare const HOME_LINKS: {
8
+ readonly secrets: "/secrets";
9
+ readonly newSecret: "/secrets/new";
10
+ readonly secretDetail: (id: string) => string;
11
+ readonly cards: "/cards";
12
+ /**
13
+ * The Cards gallery filtered to cards that need attention (expired or
14
+ * expiring within 60 days). The gallery reads `?filter=attention` (E10.5).
15
+ */
16
+ readonly cardsNeedingAttention: "/cards?filter=attention";
17
+ readonly scanCard: "/cards/import";
18
+ readonly renewCard: (id: string) => string;
19
+ readonly media: "/media";
20
+ /** The user's My backups card (`USER_SETTINGS_SECTIONS`). */
21
+ readonly myBackups: "/settings/backups";
22
+ /** The Console's Backups card (`ADMIN_SECTIONS`): the scheduled system backups. */
23
+ readonly systemBackups: "/admin/settings/backups";
24
+ };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Where the Home dashboard links to, in one place.
3
+ *
4
+ * The backup links point at their settings cards (E10.3, #94): the user's
5
+ * My backups card and the Console's Backups card.
6
+ */
7
+ export const HOME_LINKS = {
8
+ secrets: '/secrets',
9
+ newSecret: '/secrets/new',
10
+ secretDetail: (id) => `/secrets/${encodeURIComponent(id)}`,
11
+ cards: '/cards',
12
+ /**
13
+ * The Cards gallery filtered to cards that need attention (expired or
14
+ * expiring within 60 days). The gallery reads `?filter=attention` (E10.5).
15
+ */
16
+ cardsNeedingAttention: '/cards?filter=attention',
17
+ scanCard: '/cards/import',
18
+ renewCard: (id) => `/cards/${encodeURIComponent(id)}/renew`,
19
+ media: '/media',
20
+ /** The user's My backups card (`USER_SETTINGS_SECTIONS`). */
21
+ myBackups: '/settings/backups',
22
+ /** The Console's Backups card (`ADMIN_SECTIONS`): the scheduled system backups. */
23
+ systemBackups: '/admin/settings/backups',
24
+ };
@@ -0,0 +1 @@
1
+ export * from './homeLinks.js';
@@ -0,0 +1,2 @@
1
+ // Home: the links the dashboard panels share. No component.
2
+ export * from './homeLinks.js';