@burdenoff/microfe-security 2026.1120.3 → 2026.1123.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generated/global-types.d.ts +5953 -796
- package/dist/generated/wspace-operations.d.ts +315 -3
- package/dist/generated/wspace-operations.js +216 -62
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +74118 -10624
- package/dist/generated/wspace-types.js +3 -1
- package/dist/generated/wspace-types.js.map +1 -1
- package/dist/security/components/BulkPickerDialogs.js.map +1 -1
- package/dist/security/components/ImportWizard.js.map +1 -1
- package/dist/security/components/SecretFormFields.js.map +1 -1
- package/dist/security/components/SecretShareDialog.js.map +1 -1
- package/dist/security/components/SecurityScoreCard.d.ts +2 -1
- package/dist/security/components/SecurityScoreCard.js +9 -3
- package/dist/security/components/SecurityScoreCard.js.map +1 -1
- package/dist/security/components/VaultFormFields.js.map +1 -1
- package/dist/security/components/VaultShareDialog.js.map +1 -1
- package/dist/security/components/ui.js.map +1 -1
- package/dist/security/hooks/useSecurityDashboard.d.ts +10 -1
- package/dist/security/hooks/useSecurityDashboard.js +18 -17
- package/dist/security/hooks/useSecurityDashboard.js.map +1 -1
- package/dist/security/hooks/useShareQueries.js +11 -8
- package/dist/security/hooks/useShareQueries.js.map +1 -1
- package/dist/security/pages/AccessReviewPage.js.map +1 -1
- package/dist/security/pages/AuditLogPage.js.map +1 -1
- package/dist/security/pages/ProviderDetailPage.js.map +1 -1
- package/dist/security/pages/ProvidersPage.js.map +1 -1
- package/dist/security/pages/SecretCreatePage.js.map +1 -1
- package/dist/security/pages/SecretDetailPage.js.map +1 -1
- package/dist/security/pages/SecurityDashboardPage.js.map +1 -1
- package/dist/security/pages/SharedWithMePage.js +48 -26
- package/dist/security/pages/SharedWithMePage.js.map +1 -1
- package/dist/security/pages/VaultCreatePage.js.map +1 -1
- package/dist/security/pages/VaultDetailPage.js.map +1 -1
- package/dist/security/pages/VaultSettingsPage.js.map +1 -1
- package/dist/security/pages/VaultShareViewer.js.map +1 -1
- package/dist/security/pages/VaultsDashboardPage.js.map +1 -1
- package/dist/security/routes/SecurityRoutes.js +50 -44
- package/dist/security/routes/SecurityRoutes.js.map +1 -1
- package/dist/security/v2/SecurityV2Routes.d.ts +15 -0
- package/dist/security/v2/SecurityV2Routes.js +119 -0
- package/dist/security/v2/SecurityV2Routes.js.map +1 -0
- package/dist/security/v2/components/AuditEntries.d.ts +11 -0
- package/dist/security/v2/components/AuditEntries.js +37 -0
- package/dist/security/v2/components/AuditEntries.js.map +1 -0
- package/dist/security/v2/components/MaskedValue.d.ts +15 -0
- package/dist/security/v2/components/MaskedValue.js +109 -0
- package/dist/security/v2/components/MaskedValue.js.map +1 -0
- package/dist/security/v2/components/auditWords.d.ts +32 -0
- package/dist/security/v2/components/auditWords.js +103 -0
- package/dist/security/v2/components/auditWords.js.map +1 -0
- package/dist/security/v2/components/dates.d.ts +9 -0
- package/dist/security/v2/components/dates.js +37 -0
- package/dist/security/v2/components/dates.js.map +1 -0
- package/dist/security/v2/components/healthWords.d.ts +25 -0
- package/dist/security/v2/components/healthWords.js +76 -0
- package/dist/security/v2/components/healthWords.js.map +1 -0
- package/dist/security/v2/components/pieces.d.ts +33 -0
- package/dist/security/v2/components/pieces.js +49 -0
- package/dist/security/v2/components/pieces.js.map +1 -0
- package/dist/security/v2/components/typeWords.d.ts +7 -0
- package/dist/security/v2/components/typeWords.js +26 -0
- package/dist/security/v2/components/typeWords.js.map +1 -0
- package/dist/security/v2/dialogs/AccessReviewDialog.d.ts +20 -0
- package/dist/security/v2/dialogs/AccessReviewDialog.js +196 -0
- package/dist/security/v2/dialogs/AccessReviewDialog.js.map +1 -0
- package/dist/security/v2/dialogs/ImportExportDialog.d.ts +19 -0
- package/dist/security/v2/dialogs/ImportExportDialog.js +85 -0
- package/dist/security/v2/dialogs/ImportExportDialog.js.map +1 -0
- package/dist/security/v2/dialogs/LockedDialog.d.ts +12 -0
- package/dist/security/v2/dialogs/LockedDialog.js +32 -0
- package/dist/security/v2/dialogs/LockedDialog.js.map +1 -0
- package/dist/security/v2/dialogs/SecurityHealthDialog.d.ts +19 -0
- package/dist/security/v2/dialogs/SecurityHealthDialog.js +151 -0
- package/dist/security/v2/dialogs/SecurityHealthDialog.js.map +1 -0
- package/dist/security/v2/dialogs/import-export/ExportPanel.d.ts +25 -0
- package/dist/security/v2/dialogs/import-export/ExportPanel.js +70 -0
- package/dist/security/v2/dialogs/import-export/ExportPanel.js.map +1 -0
- package/dist/security/v2/dialogs/import-export/ImportPanel.d.ts +26 -0
- package/dist/security/v2/dialogs/import-export/ImportPanel.js +240 -0
- package/dist/security/v2/dialogs/import-export/ImportPanel.js.map +1 -0
- package/dist/security/v2/dialogs/import-export/TransferFooters.d.ts +21 -0
- package/dist/security/v2/dialogs/import-export/TransferFooters.js +51 -0
- package/dist/security/v2/dialogs/import-export/TransferFooters.js.map +1 -0
- package/dist/security/v2/dialogs/import-export/useTransfers.d.ts +23 -0
- package/dist/security/v2/dialogs/import-export/useTransfers.js +69 -0
- package/dist/security/v2/dialogs/import-export/useTransfers.js.map +1 -0
- package/dist/security/v2/dialogs/reviewWords.d.ts +15 -0
- package/dist/security/v2/dialogs/reviewWords.js +48 -0
- package/dist/security/v2/dialogs/reviewWords.js.map +1 -0
- package/dist/security/v2/hooks/useActorNames.d.ts +15 -0
- package/dist/security/v2/hooks/useActorNames.js +40 -0
- package/dist/security/v2/hooks/useActorNames.js.map +1 -0
- package/dist/security/v2/hooks/useAuditEvents.d.ts +23 -0
- package/dist/security/v2/hooks/useAuditEvents.js +28 -0
- package/dist/security/v2/hooks/useAuditEvents.js.map +1 -0
- package/dist/security/v2/hooks/useSavedValuesData.d.ts +85 -0
- package/dist/security/v2/hooks/useSavedValuesData.js +111 -0
- package/dist/security/v2/hooks/useSavedValuesData.js.map +1 -0
- package/dist/security/v2/hooks/useSavedValuesGates.d.ts +24 -0
- package/dist/security/v2/hooks/useSavedValuesGates.js +22 -0
- package/dist/security/v2/hooks/useSavedValuesGates.js.map +1 -0
- package/dist/security/v2/hooks/useSavedValuesNav.d.ts +11 -0
- package/dist/security/v2/hooks/useSavedValuesNav.js +26 -0
- package/dist/security/v2/hooks/useSavedValuesNav.js.map +1 -0
- package/dist/security/v2/hooks/useVaultActions.d.ts +12 -0
- package/dist/security/v2/hooks/useVaultActions.js +81 -0
- package/dist/security/v2/hooks/useVaultActions.js.map +1 -0
- package/dist/security/v2/hooks/useVaultPage.d.ts +86 -0
- package/dist/security/v2/hooks/useVaultPage.js +174 -0
- package/dist/security/v2/hooks/useVaultPage.js.map +1 -0
- package/dist/security/v2/model/access.d.ts +63 -0
- package/dist/security/v2/model/access.js +57 -0
- package/dist/security/v2/model/access.js.map +1 -0
- package/dist/security/v2/model/audit.d.ts +43 -0
- package/dist/security/v2/model/audit.js +113 -0
- package/dist/security/v2/model/audit.js.map +1 -0
- package/dist/security/v2/model/health.d.ts +70 -0
- package/dist/security/v2/model/health.js +118 -0
- package/dist/security/v2/model/health.js.map +1 -0
- package/dist/security/v2/model/params.d.ts +40 -0
- package/dist/security/v2/model/params.js +65 -0
- package/dist/security/v2/model/params.js.map +1 -0
- package/dist/security/v2/model/review.d.ts +99 -0
- package/dist/security/v2/model/review.js +141 -0
- package/dist/security/v2/model/review.js.map +1 -0
- package/dist/security/v2/model/shared.d.ts +40 -0
- package/dist/security/v2/model/shared.js +26 -0
- package/dist/security/v2/model/shared.js.map +1 -0
- package/dist/security/v2/model/time.d.ts +24 -0
- package/dist/security/v2/model/time.js +37 -0
- package/dist/security/v2/model/time.js.map +1 -0
- package/dist/security/v2/model/vaults.d.ts +46 -0
- package/dist/security/v2/model/vaults.js +55 -0
- package/dist/security/v2/model/vaults.js.map +1 -0
- package/dist/security/v2/pages/AuditLogPage.d.ts +6 -0
- package/dist/security/v2/pages/AuditLogPage.js +170 -0
- package/dist/security/v2/pages/AuditLogPage.js.map +1 -0
- package/dist/security/v2/pages/SavedValuesPage.d.ts +5 -0
- package/dist/security/v2/pages/SavedValuesPage.js +98 -0
- package/dist/security/v2/pages/SavedValuesPage.js.map +1 -0
- package/dist/security/v2/pages/VaultPage.d.ts +5 -0
- package/dist/security/v2/pages/VaultPage.js +201 -0
- package/dist/security/v2/pages/VaultPage.js.map +1 -0
- package/dist/security/v2/pages/saved/HealthSummary.d.ts +15 -0
- package/dist/security/v2/pages/saved/HealthSummary.js +44 -0
- package/dist/security/v2/pages/saved/HealthSummary.js.map +1 -0
- package/dist/security/v2/pages/saved/RevealSharedDialog.d.ts +11 -0
- package/dist/security/v2/pages/saved/RevealSharedDialog.js +65 -0
- package/dist/security/v2/pages/saved/RevealSharedDialog.js.map +1 -0
- package/dist/security/v2/pages/saved/SavedValuesDialogs.d.ts +14 -0
- package/dist/security/v2/pages/saved/SavedValuesDialogs.js +55 -0
- package/dist/security/v2/pages/saved/SavedValuesDialogs.js.map +1 -0
- package/dist/security/v2/pages/saved/SharedWithMeTab.d.ts +10 -0
- package/dist/security/v2/pages/saved/SharedWithMeTab.js +178 -0
- package/dist/security/v2/pages/saved/SharedWithMeTab.js.map +1 -0
- package/dist/security/v2/pages/saved/VaultCard.d.ts +17 -0
- package/dist/security/v2/pages/saved/VaultCard.js +91 -0
- package/dist/security/v2/pages/saved/VaultCard.js.map +1 -0
- package/dist/security/v2/pages/saved/VaultsTab.d.ts +23 -0
- package/dist/security/v2/pages/saved/VaultsTab.js +133 -0
- package/dist/security/v2/pages/saved/VaultsTab.js.map +1 -0
- package/dist/security/v2/pages/saved/useSavedValuesPage.d.ts +75 -0
- package/dist/security/v2/pages/saved/useSavedValuesPage.js +80 -0
- package/dist/security/v2/pages/saved/useSavedValuesPage.js.map +1 -0
- package/dist/security/v2/pages/vault/AccessTab.d.ts +48 -0
- package/dist/security/v2/pages/vault/AccessTab.js +162 -0
- package/dist/security/v2/pages/vault/AccessTab.js.map +1 -0
- package/dist/security/v2/pages/vault/ActivityTab.d.ts +15 -0
- package/dist/security/v2/pages/vault/ActivityTab.js +50 -0
- package/dist/security/v2/pages/vault/ActivityTab.js.map +1 -0
- package/dist/security/v2/pages/vault/ValuesTab.d.ts +25 -0
- package/dist/security/v2/pages/vault/ValuesTab.js +187 -0
- package/dist/security/v2/pages/vault/ValuesTab.js.map +1 -0
- package/dist/security/v2/pages/vault/VaultHeader.d.ts +40 -0
- package/dist/security/v2/pages/vault/VaultHeader.js +128 -0
- package/dist/security/v2/pages/vault/VaultHeader.js.map +1 -0
- package/package.json +2 -2
- package/dist/security/__tests__/support/dialogDom.d.ts +0 -20
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface ExportVault {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
secretCount: number;
|
|
5
|
+
}
|
|
6
|
+
export interface ExportOutcome {
|
|
7
|
+
exported: string[];
|
|
8
|
+
/** Vaults whose password email could not be sent. */
|
|
9
|
+
undelivered: string[];
|
|
10
|
+
failed: string[];
|
|
11
|
+
}
|
|
12
|
+
export interface ExportPanelProps {
|
|
13
|
+
vaults: readonly ExportVault[];
|
|
14
|
+
selected: readonly string[];
|
|
15
|
+
onToggle: (vaultId: string, checked: boolean) => void;
|
|
16
|
+
locked: boolean;
|
|
17
|
+
busy: boolean;
|
|
18
|
+
outcome: ExportOutcome | null;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Export (BOFF-15820): the vaults to take out, each as an encrypted backup file. The password that
|
|
22
|
+
* opens a file is emailed to the person exporting and is never in the download (the service's
|
|
23
|
+
* backup flow; a passphrase typed here would travel on a query, which BOFF-2225 ruled out).
|
|
24
|
+
*/
|
|
25
|
+
export declare function ExportPanel({ vaults, selected, onToggle, locked, busy, outcome, }: ExportPanelProps): import('react').JSX.Element;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { useTr as e } from "../../../hooks/useTr.js";
|
|
2
|
+
import { useId as t, useMemo as n } from "react";
|
|
3
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
4
|
+
import { Mail as a } from "lucide-react";
|
|
5
|
+
import { Checkbox as o, LockNote as s, Notice as c } from "@burdenoff/fe-libs/ui";
|
|
6
|
+
// src/security/v2/dialogs/import-export/ExportPanel.tsx
|
|
7
|
+
function l({ vaults: l, selected: u, onToggle: d, locked: f, busy: p, outcome: m }) {
|
|
8
|
+
let h = e(), g = t(), _ = n(() => new Set(u), [u]);
|
|
9
|
+
return /* @__PURE__ */ i("div", {
|
|
10
|
+
className: "flex flex-col gap-4",
|
|
11
|
+
children: [
|
|
12
|
+
f ? /* @__PURE__ */ r(s, { children: h("security.v2.export.locked", "Exporting is for people who may export saved values: an export holds every value in the vaults you pick. Ask a workspace admin.") }) : null,
|
|
13
|
+
/* @__PURE__ */ i("fieldset", {
|
|
14
|
+
disabled: f || p,
|
|
15
|
+
className: "flex flex-col gap-2 disabled:opacity-60",
|
|
16
|
+
children: [
|
|
17
|
+
/* @__PURE__ */ r("legend", {
|
|
18
|
+
className: "mb-1 text-sm font-semibold text-text-primary",
|
|
19
|
+
children: h("security.v2.export.which", "Vaults to export")
|
|
20
|
+
}),
|
|
21
|
+
l.length === 0 ? /* @__PURE__ */ r("p", {
|
|
22
|
+
className: "text-sm text-text-secondary",
|
|
23
|
+
children: h("security.v2.export.none", "There are no vaults to export yet.")
|
|
24
|
+
}) : null,
|
|
25
|
+
l.map((e) => {
|
|
26
|
+
let t = `${g}-${e.id}`;
|
|
27
|
+
return /* @__PURE__ */ i("label", {
|
|
28
|
+
htmlFor: t,
|
|
29
|
+
className: "flex min-h-11 cursor-pointer items-center gap-3 rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 hover:bg-bg-sunken",
|
|
30
|
+
children: [/* @__PURE__ */ r(o, {
|
|
31
|
+
id: t,
|
|
32
|
+
checked: _.has(e.id),
|
|
33
|
+
onCheckedChange: (t) => d(e.id, t === !0)
|
|
34
|
+
}), /* @__PURE__ */ i("span", {
|
|
35
|
+
className: "flex min-w-0 flex-col",
|
|
36
|
+
children: [/* @__PURE__ */ r("span", {
|
|
37
|
+
className: "truncate text-sm font-medium text-text-primary",
|
|
38
|
+
children: e.name
|
|
39
|
+
}), /* @__PURE__ */ r("span", {
|
|
40
|
+
className: "text-xs text-text-secondary",
|
|
41
|
+
children: e.secretCount === 1 ? h("security.v2.vaults.oneValue", "1 value") : h("security.v2.vaults.values", "{{count}} values", { count: e.secretCount })
|
|
42
|
+
})]
|
|
43
|
+
})]
|
|
44
|
+
}, e.id);
|
|
45
|
+
})
|
|
46
|
+
]
|
|
47
|
+
}),
|
|
48
|
+
/* @__PURE__ */ r(c, {
|
|
49
|
+
tone: "info",
|
|
50
|
+
icon: a,
|
|
51
|
+
children: h("security.v2.export.how", "Each vault downloads as an encrypted file. The password that opens it is emailed to you; it is never in the download.")
|
|
52
|
+
}),
|
|
53
|
+
m && m.exported.length ? /* @__PURE__ */ r(c, {
|
|
54
|
+
tone: "info",
|
|
55
|
+
children: h("security.v2.export.done", "Exported: {{names}}. Check your email for the passwords.", { names: m.exported.join(", ") })
|
|
56
|
+
}) : null,
|
|
57
|
+
m && m.undelivered.length ? /* @__PURE__ */ r(c, {
|
|
58
|
+
tone: "warn",
|
|
59
|
+
children: h("security.v2.export.undelivered", "The password email for {{names}} could not be sent, so that file can’t be opened. Export it again later.", { names: m.undelivered.join(", ") })
|
|
60
|
+
}) : null,
|
|
61
|
+
m && m.failed.length ? /* @__PURE__ */ r(c, {
|
|
62
|
+
tone: "bad",
|
|
63
|
+
children: h("security.v2.export.failed", "Couldn’t export {{names}}. Try again in a moment.", { names: m.failed.join(", ") })
|
|
64
|
+
}) : null
|
|
65
|
+
]
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
export { l as ExportPanel };
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=ExportPanel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExportPanel.js","names":["ExportPanel","tr","useTr","baseId","useId","picked","useMemo","selected","locked","LockNote","busy","vaults","id","vault","Checkbox","onToggle","checked","Notice","Mail","outcome"],"sources":["../../../../../src/security/v2/dialogs/import-export/ExportPanel.tsx"],"sourcesContent":["import { useId, useMemo } from 'react';\nimport { Mail } from 'lucide-react';\nimport { Checkbox, LockNote, Notice } from '@burdenoff/fe-libs/ui';\nimport { useTr } from '../../../hooks/useTr';\n\nexport interface ExportVault {\n id: string;\n name: string;\n secretCount: number;\n}\n\nexport interface ExportOutcome {\n exported: string[];\n /** Vaults whose password email could not be sent. */\n undelivered: string[];\n failed: string[];\n}\n\nexport interface ExportPanelProps {\n vaults: readonly ExportVault[];\n selected: readonly string[];\n onToggle: (vaultId: string, checked: boolean) => void;\n locked: boolean;\n busy: boolean;\n outcome: ExportOutcome | null;\n}\n\n/**\n * Export (BOFF-15820): the vaults to take out, each as an encrypted backup file. The password that\n * opens a file is emailed to the person exporting and is never in the download (the service's\n * backup flow; a passphrase typed here would travel on a query, which BOFF-2225 ruled out).\n */\nexport function ExportPanel({\n vaults,\n selected,\n onToggle,\n locked,\n busy,\n outcome,\n}: ExportPanelProps) {\n const tr = useTr();\n const baseId = useId();\n const picked = useMemo(() => new Set(selected), [selected]);\n return (\n <div className=\"flex flex-col gap-4\">\n {locked ? (\n <LockNote>\n {tr(\n 'security.v2.export.locked',\n 'Exporting is for people who may export saved values: an export holds every value in the vaults you pick. Ask a workspace admin.'\n )}\n </LockNote>\n ) : null}\n <fieldset disabled={locked || busy} className=\"flex flex-col gap-2 disabled:opacity-60\">\n <legend className=\"mb-1 text-sm font-semibold text-text-primary\">\n {tr('security.v2.export.which', 'Vaults to export')}\n </legend>\n {vaults.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n {tr('security.v2.export.none', 'There are no vaults to export yet.')}\n </p>\n ) : null}\n {vaults.map((vault) => {\n const id = `${baseId}-${vault.id}`;\n return (\n <label\n key={vault.id}\n htmlFor={id}\n className=\"flex min-h-11 cursor-pointer items-center gap-3 rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 hover:bg-bg-sunken\"\n >\n <Checkbox\n id={id}\n checked={picked.has(vault.id)}\n onCheckedChange={(checked) => onToggle(vault.id, checked === true)}\n />\n <span className=\"flex min-w-0 flex-col\">\n <span className=\"truncate text-sm font-medium text-text-primary\">{vault.name}</span>\n <span className=\"text-xs text-text-secondary\">\n {vault.secretCount === 1\n ? tr('security.v2.vaults.oneValue', '1 value')\n : tr('security.v2.vaults.values', '{{count}} values', {\n count: vault.secretCount,\n })}\n </span>\n </span>\n </label>\n );\n })}\n </fieldset>\n <Notice tone=\"info\" icon={Mail}>\n {tr(\n 'security.v2.export.how',\n 'Each vault downloads as an encrypted file. The password that opens it is emailed to you; it is never in the download.'\n )}\n </Notice>\n {outcome && outcome.exported.length ? (\n <Notice tone=\"info\">\n {tr(\n 'security.v2.export.done',\n 'Exported: {{names}}. Check your email for the passwords.',\n {\n names: outcome.exported.join(', '),\n }\n )}\n </Notice>\n ) : null}\n {outcome && outcome.undelivered.length ? (\n <Notice tone=\"warn\">\n {tr(\n 'security.v2.export.undelivered',\n 'The password email for {{names}} could not be sent, so that file can’t be opened. Export it again later.',\n {\n names: outcome.undelivered.join(', '),\n }\n )}\n </Notice>\n ) : null}\n {outcome && outcome.failed.length ? (\n <Notice tone=\"bad\">\n {tr('security.v2.export.failed', 'Couldn’t export {{names}}. Try again in a moment.', {\n names: outcome.failed.join(', '),\n })}\n </Notice>\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;AAgCA,SAAgBA,EAAY,EAC1B,WACA,aACA,aACA,WACA,SACA,cACmB;CACnB,IAAMC,IAAKC,EAAM,GACXC,IAASC,EAAM,GACfC,IAASC,QAAc,IAAI,IAAIC,CAAQ,GAAG,CAACA,CAAQ,CAAC;CAC1D,OACE,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA;GACGC,IACC,kBAACC,GAAD,EAAA,UACGR,EACC,6BACA,iIACF,EACQ,CAAA,IACR;GACJ,kBAAC,YAAD;IAAU,UAAUO,KAAUE;IAAM,WAAU;IAA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,MAAK;IACV,UAAAhB,EAAG,6BAA6B,qDAAqD,EACpF,OAAOkB,EAAQ,OAAO,KAAK,IAAI,EACjC,CAAC;GACK,CAAA,IACN;EACD;;AAET"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ImportState } from '../../../hooks/useImportExport';
|
|
2
|
+
export type ImportFormat = 'env' | 'csv' | 'json' | 'backup';
|
|
3
|
+
export interface RecentTransfer {
|
|
4
|
+
id: string;
|
|
5
|
+
sentence: string;
|
|
6
|
+
when: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ImportPanelProps {
|
|
9
|
+
state: ImportState;
|
|
10
|
+
onFile: (file: File) => void;
|
|
11
|
+
vaults: readonly {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
}[];
|
|
15
|
+
vaultId: string;
|
|
16
|
+
onVaultChange: (vaultId: string) => void;
|
|
17
|
+
password: string;
|
|
18
|
+
onPasswordChange: (value: string) => void;
|
|
19
|
+
recent: readonly RecentTransfer[] | null;
|
|
20
|
+
busy: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Import (BOFF-15820): where the values come from, the file, the vault they go into, and the
|
|
24
|
+
* recent imports and exports. The file is read in the browser first; nothing is saved until Import.
|
|
25
|
+
*/
|
|
26
|
+
export declare function ImportPanel({ state, onFile, vaults, vaultId, onVaultChange, password, onPasswordChange, recent, busy, }: ImportPanelProps): import('react').JSX.Element;
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { useTr as e } from "../../../hooks/useTr.js";
|
|
2
|
+
import { cn as t } from "../../../utils/cn.js";
|
|
3
|
+
import { Tile as n } from "../../components/pieces.js";
|
|
4
|
+
import { useId as r, useMemo as i, useRef as a, useState as o } from "react";
|
|
5
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
6
|
+
import { Check as l, FileArchive as u, FileJson as d, FileSpreadsheet as f, FileText as p, Upload as m } from "lucide-react";
|
|
7
|
+
import { Button as h, Input as g, Label as _, Notice as v, ThemedSelect as y } from "@burdenoff/fe-libs/ui";
|
|
8
|
+
// src/security/v2/dialogs/import-export/ImportPanel.tsx
|
|
9
|
+
var b = {
|
|
10
|
+
env: ".env,text/plain",
|
|
11
|
+
csv: ".csv,text/csv",
|
|
12
|
+
json: ".json,application/json",
|
|
13
|
+
backup: ".boffbackup,.enc"
|
|
14
|
+
};
|
|
15
|
+
function x() {
|
|
16
|
+
let t = e();
|
|
17
|
+
return i(() => [
|
|
18
|
+
{
|
|
19
|
+
id: "env",
|
|
20
|
+
label: t("security.v2.import.format.env", ".env file"),
|
|
21
|
+
help: t("security.v2.import.format.envHelp", "KEY=value lines; lines starting with # are skipped."),
|
|
22
|
+
icon: p
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: "csv",
|
|
26
|
+
label: t("security.v2.import.format.csv", "CSV"),
|
|
27
|
+
help: t("security.v2.import.format.csvHelp", "A header row with name and value columns; key, type and description are optional."),
|
|
28
|
+
icon: f
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: "json",
|
|
32
|
+
label: t("security.v2.import.format.json", "JSON"),
|
|
33
|
+
help: t("security.v2.import.format.jsonHelp", "A list of { \"name\", \"value\" } objects, or one object of names and values."),
|
|
34
|
+
icon: d
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: "backup",
|
|
38
|
+
label: t("security.v2.import.format.backup", "Backup file"),
|
|
39
|
+
help: t("security.v2.import.format.backupHelp", "An encrypted backup from Export, with the password we emailed you."),
|
|
40
|
+
icon: u
|
|
41
|
+
}
|
|
42
|
+
], [t]);
|
|
43
|
+
}
|
|
44
|
+
function S({ formats: n, value: r, onChange: i }) {
|
|
45
|
+
let a = e();
|
|
46
|
+
return /* @__PURE__ */ s("div", {
|
|
47
|
+
role: "radiogroup",
|
|
48
|
+
"aria-label": a("security.v2.import.from", "From"),
|
|
49
|
+
className: "grid grid-cols-2 gap-2",
|
|
50
|
+
children: n.map((e) => {
|
|
51
|
+
let n = e.id === r;
|
|
52
|
+
return /* @__PURE__ */ c("button", {
|
|
53
|
+
type: "button",
|
|
54
|
+
role: "radio",
|
|
55
|
+
"aria-checked": n,
|
|
56
|
+
onClick: () => i(e.id),
|
|
57
|
+
className: t("flex min-h-11 items-center gap-2.5 rounded-lg border px-3 text-start text-sm font-medium text-text-primary outline-none", "focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]", n ? "border-action-primary-bg bg-accent-soft font-semibold" : "border-border-default bg-bg-surface hover:bg-bg-sunken"),
|
|
58
|
+
children: [
|
|
59
|
+
/* @__PURE__ */ s(e.icon, {
|
|
60
|
+
className: "size-4 shrink-0",
|
|
61
|
+
"aria-hidden": "true"
|
|
62
|
+
}),
|
|
63
|
+
/* @__PURE__ */ s("span", {
|
|
64
|
+
className: "flex-1",
|
|
65
|
+
children: e.label
|
|
66
|
+
}),
|
|
67
|
+
n ? /* @__PURE__ */ s(l, {
|
|
68
|
+
className: "size-4 shrink-0 text-action-primary-bg",
|
|
69
|
+
"aria-hidden": "true"
|
|
70
|
+
}) : null
|
|
71
|
+
]
|
|
72
|
+
}, e.id);
|
|
73
|
+
})
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function C({ fileName: r, help: i, accept: l, busy: u, onFile: d }) {
|
|
77
|
+
let f = e(), p = a(null), [g, _] = o(!1);
|
|
78
|
+
return /* @__PURE__ */ c("div", {
|
|
79
|
+
onDragOver: (e) => {
|
|
80
|
+
e.preventDefault(), _(!0);
|
|
81
|
+
},
|
|
82
|
+
onDragLeave: () => _(!1),
|
|
83
|
+
onDrop: (e) => {
|
|
84
|
+
e.preventDefault(), _(!1);
|
|
85
|
+
let t = e.dataTransfer.files[0];
|
|
86
|
+
t && !u && d(t);
|
|
87
|
+
},
|
|
88
|
+
className: t("flex items-center gap-3 rounded-lg border border-dashed p-4", g ? "border-action-primary-bg bg-accent-soft" : "border-border-strong bg-bg-sunken"),
|
|
89
|
+
children: [
|
|
90
|
+
/* @__PURE__ */ s(n, { icon: m }),
|
|
91
|
+
/* @__PURE__ */ c("div", {
|
|
92
|
+
className: "flex min-w-0 flex-1 flex-col gap-1",
|
|
93
|
+
children: [/* @__PURE__ */ s("span", {
|
|
94
|
+
className: "truncate text-sm text-text-primary",
|
|
95
|
+
children: r ? /* @__PURE__ */ s("span", {
|
|
96
|
+
className: "font-semibold",
|
|
97
|
+
children: r
|
|
98
|
+
}) : f("security.v2.import.drop", "Drop the file here, or choose one.")
|
|
99
|
+
}), /* @__PURE__ */ s("span", {
|
|
100
|
+
className: "text-xs text-text-secondary",
|
|
101
|
+
children: i
|
|
102
|
+
})]
|
|
103
|
+
}),
|
|
104
|
+
/* @__PURE__ */ s(h, {
|
|
105
|
+
type: "button",
|
|
106
|
+
variant: "outline",
|
|
107
|
+
size: "sm",
|
|
108
|
+
disabled: u,
|
|
109
|
+
onClick: () => p.current?.click(),
|
|
110
|
+
children: f("security.v2.import.choose", "Choose a file")
|
|
111
|
+
}),
|
|
112
|
+
/* @__PURE__ */ s("input", {
|
|
113
|
+
ref: p,
|
|
114
|
+
type: "file",
|
|
115
|
+
className: "sr-only",
|
|
116
|
+
tabIndex: -1,
|
|
117
|
+
"aria-hidden": "true",
|
|
118
|
+
accept: l,
|
|
119
|
+
onChange: (e) => {
|
|
120
|
+
let t = e.target.files?.[0];
|
|
121
|
+
t && d(t), e.target.value = "";
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
]
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
function w({ names: t }) {
|
|
128
|
+
let n = e(), r = t.slice(0, 5).join(", ") + (t.length > 5 ? "…" : "");
|
|
129
|
+
return /* @__PURE__ */ s(v, {
|
|
130
|
+
tone: "info",
|
|
131
|
+
children: t.length === 1 ? n("security.v2.import.foundOne", "1 value found: {{names}}. Values arrive hidden; nothing is shared.", { names: r }) : n("security.v2.import.found", "{{count}} values found: {{names}}. Values arrive hidden; nothing is shared.", {
|
|
132
|
+
count: t.length,
|
|
133
|
+
names: r
|
|
134
|
+
})
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
function T({ value: t, onChange: n }) {
|
|
138
|
+
let i = e(), a = r();
|
|
139
|
+
return /* @__PURE__ */ c("div", {
|
|
140
|
+
className: "flex flex-col gap-1.5",
|
|
141
|
+
children: [/* @__PURE__ */ s(_, {
|
|
142
|
+
htmlFor: a,
|
|
143
|
+
children: i("security.v2.import.password", "Backup password")
|
|
144
|
+
}), /* @__PURE__ */ s(g, {
|
|
145
|
+
id: a,
|
|
146
|
+
type: "password",
|
|
147
|
+
autoComplete: "off",
|
|
148
|
+
value: t,
|
|
149
|
+
onChange: (e) => n(e.target.value),
|
|
150
|
+
placeholder: i("security.v2.import.passwordHint", "From the email we sent when it was exported")
|
|
151
|
+
})]
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
function E({ state: t }) {
|
|
155
|
+
let n = e();
|
|
156
|
+
return t.status === "completed" && t.results ? /* @__PURE__ */ s(v, {
|
|
157
|
+
tone: "info",
|
|
158
|
+
children: t.results.imported === 1 ? n("security.v2.import.doneOne", "1 value imported, {{skipped}} already there and skipped.", { skipped: t.results.skipped }) : n("security.v2.import.done", "{{count}} values imported, {{skipped}} already there and skipped.", {
|
|
159
|
+
count: t.results.imported,
|
|
160
|
+
skipped: t.results.skipped
|
|
161
|
+
})
|
|
162
|
+
}) : t.status === "error" || t.status === "partial" || t.status === "skipped" ? /* @__PURE__ */ s(v, {
|
|
163
|
+
tone: t.status === "error" ? "bad" : "warn",
|
|
164
|
+
children: t.error ?? n("security.v2.import.failed", "The file could not be imported.")
|
|
165
|
+
}) : null;
|
|
166
|
+
}
|
|
167
|
+
function D({ recent: t }) {
|
|
168
|
+
let n = e(), i = r();
|
|
169
|
+
return /* @__PURE__ */ c("section", {
|
|
170
|
+
className: "flex flex-col gap-2",
|
|
171
|
+
"aria-labelledby": i,
|
|
172
|
+
children: [/* @__PURE__ */ s("h3", {
|
|
173
|
+
id: i,
|
|
174
|
+
className: "text-xs font-semibold uppercase tracking-wide text-text-secondary",
|
|
175
|
+
children: n("security.v2.import.recent", "Recent")
|
|
176
|
+
}), /* @__PURE__ */ s("ul", {
|
|
177
|
+
className: "flex flex-col rounded-lg border border-border-subtle",
|
|
178
|
+
children: t.map((e) => /* @__PURE__ */ c("li", {
|
|
179
|
+
className: "flex flex-col gap-0.5 border-b border-border-subtle p-3 last:border-b-0",
|
|
180
|
+
children: [/* @__PURE__ */ s("span", {
|
|
181
|
+
className: "text-sm font-medium text-text-primary",
|
|
182
|
+
children: e.sentence
|
|
183
|
+
}), /* @__PURE__ */ s("span", {
|
|
184
|
+
className: "text-xs text-text-secondary",
|
|
185
|
+
children: e.when
|
|
186
|
+
})]
|
|
187
|
+
}, e.id))
|
|
188
|
+
})]
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
function O({ state: t, onFile: n, vaults: i, vaultId: a, onVaultChange: l, password: u, onPasswordChange: d, recent: f, busy: p }) {
|
|
192
|
+
let m = e(), h = x(), [g, v] = o("env"), O = r(), k = h.find((e) => e.id === g);
|
|
193
|
+
return /* @__PURE__ */ c("div", {
|
|
194
|
+
className: "flex flex-col gap-4",
|
|
195
|
+
children: [
|
|
196
|
+
/* @__PURE__ */ s(S, {
|
|
197
|
+
formats: h,
|
|
198
|
+
value: g,
|
|
199
|
+
onChange: v
|
|
200
|
+
}),
|
|
201
|
+
/* @__PURE__ */ s(C, {
|
|
202
|
+
fileName: t.fileName,
|
|
203
|
+
help: k?.help ?? "",
|
|
204
|
+
accept: b[g],
|
|
205
|
+
busy: p,
|
|
206
|
+
onFile: n
|
|
207
|
+
}),
|
|
208
|
+
/* @__PURE__ */ c("div", {
|
|
209
|
+
className: "flex flex-col gap-1.5",
|
|
210
|
+
children: [/* @__PURE__ */ s(_, {
|
|
211
|
+
htmlFor: O,
|
|
212
|
+
children: m("security.v2.import.into", "Into vault")
|
|
213
|
+
}), /* @__PURE__ */ c(y, {
|
|
214
|
+
id: O,
|
|
215
|
+
value: a,
|
|
216
|
+
disabled: p || i.length === 0,
|
|
217
|
+
onChange: (e) => l(e.target.value),
|
|
218
|
+
className: "h-10 rounded-lg border border-border-default bg-bg-surface px-3 text-sm text-text-primary",
|
|
219
|
+
children: [i.length === 0 ? /* @__PURE__ */ s("option", {
|
|
220
|
+
value: "",
|
|
221
|
+
children: m("security.v2.import.noVaults", "Make a vault first")
|
|
222
|
+
}) : null, i.map((e) => /* @__PURE__ */ s("option", {
|
|
223
|
+
value: e.id,
|
|
224
|
+
children: e.name
|
|
225
|
+
}, e.id))]
|
|
226
|
+
})]
|
|
227
|
+
}),
|
|
228
|
+
t.status === "ready" && t.sourceType === "plain" ? /* @__PURE__ */ s(w, { names: t.parsedSecrets.map((e) => e.name) }) : null,
|
|
229
|
+
t.sourceType === "backup" && (t.status === "ready" || t.status === "importing") ? /* @__PURE__ */ s(T, {
|
|
230
|
+
value: u,
|
|
231
|
+
onChange: d
|
|
232
|
+
}) : null,
|
|
233
|
+
/* @__PURE__ */ s(E, { state: t }),
|
|
234
|
+
f && f.length ? /* @__PURE__ */ s(D, { recent: f }) : null
|
|
235
|
+
]
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
export { O as ImportPanel };
|
|
239
|
+
|
|
240
|
+
//# sourceMappingURL=ImportPanel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImportPanel.js","names":["ACCEPT","useImportFormats","tr","useTr","useMemo","FileText","FileSpreadsheet","FileJson","FileArchive","FormatPicker","formats","selected","entry","value","onChange","cn","Check","DropZone","inputRef","useRef","dragging","setDragging","useState","event","file","busy","onFile","Tile","Upload","fileName","help","Button","FoundNotice","shown","names","Notice","BackupPassword","id","useId","Label","Input","ImportOutcome","state","RecentList","headingId","recent","ImportPanel","format","setFormat","vaultSelectId","current","ThemedSelect","vaultId","vaults","onVaultChange","vault","secret","password","onPasswordChange"],"sources":["../../../../../src/security/v2/dialogs/import-export/ImportPanel.tsx"],"sourcesContent":["import { useId, useMemo, useRef, useState, type ComponentType, type DragEvent } from 'react';\nimport { Check, FileArchive, FileJson, FileSpreadsheet, FileText, Upload } from 'lucide-react';\nimport { Button, Input, Label, Notice, ThemedSelect } from '@burdenoff/fe-libs/ui';\nimport { useTr } from '../../../hooks/useTr';\nimport type { ImportState } from '../../../hooks/useImportExport';\nimport { cn } from '../../../utils/cn';\nimport { Tile } from '../../components/pieces';\n\nexport type ImportFormat = 'env' | 'csv' | 'json' | 'backup';\n\nconst ACCEPT: Readonly<Record<ImportFormat, string>> = {\n env: '.env,text/plain',\n csv: '.csv,text/csv',\n json: '.json,application/json',\n backup: '.boffbackup,.enc',\n};\n\nexport interface RecentTransfer {\n id: string;\n sentence: string;\n when: string;\n}\n\ninterface FormatChoice {\n id: ImportFormat;\n label: string;\n help: string;\n icon: ComponentType<{ className?: string; 'aria-hidden'?: boolean | 'true' }>;\n}\n\n/** The formats the file reader understands (`utils/fileParser`), in the app's words. */\nfunction useImportFormats(): readonly FormatChoice[] {\n const tr = useTr();\n return useMemo<readonly FormatChoice[]>(\n () => [\n {\n id: 'env',\n label: tr('security.v2.import.format.env', '.env file'),\n help: tr(\n 'security.v2.import.format.envHelp',\n 'KEY=value lines; lines starting with # are skipped.'\n ),\n icon: FileText,\n },\n {\n id: 'csv',\n label: tr('security.v2.import.format.csv', 'CSV'),\n help: tr(\n 'security.v2.import.format.csvHelp',\n 'A header row with name and value columns; key, type and description are optional.'\n ),\n icon: FileSpreadsheet,\n },\n {\n id: 'json',\n label: tr('security.v2.import.format.json', 'JSON'),\n help: tr(\n 'security.v2.import.format.jsonHelp',\n 'A list of { \"name\", \"value\" } objects, or one object of names and values.'\n ),\n icon: FileJson,\n },\n {\n id: 'backup',\n label: tr('security.v2.import.format.backup', 'Backup file'),\n help: tr(\n 'security.v2.import.format.backupHelp',\n 'An encrypted backup from Export, with the password we emailed you.'\n ),\n icon: FileArchive,\n },\n ],\n [tr]\n );\n}\n\nfunction FormatPicker({\n formats,\n value,\n onChange,\n}: {\n formats: readonly FormatChoice[];\n value: ImportFormat;\n onChange: (value: ImportFormat) => void;\n}) {\n const tr = useTr();\n return (\n <div\n role=\"radiogroup\"\n aria-label={tr('security.v2.import.from', 'From')}\n className=\"grid grid-cols-2 gap-2\"\n >\n {formats.map((entry) => {\n const selected = entry.id === value;\n return (\n <button\n key={entry.id}\n type=\"button\"\n role=\"radio\"\n aria-checked={selected}\n onClick={() => onChange(entry.id)}\n className={cn(\n 'flex min-h-11 items-center gap-2.5 rounded-lg border px-3 text-start text-sm font-medium text-text-primary outline-none',\n 'focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]',\n selected\n ? 'border-action-primary-bg bg-accent-soft font-semibold'\n : 'border-border-default bg-bg-surface hover:bg-bg-sunken'\n )}\n >\n <entry.icon className=\"size-4 shrink-0\" aria-hidden=\"true\" />\n <span className=\"flex-1\">{entry.label}</span>\n {selected ? (\n <Check className=\"size-4 shrink-0 text-action-primary-bg\" aria-hidden=\"true\" />\n ) : null}\n </button>\n );\n })}\n </div>\n );\n}\n\nfunction DropZone({\n fileName,\n help,\n accept,\n busy,\n onFile,\n}: {\n fileName: string | null;\n help: string;\n accept: string;\n busy: boolean;\n onFile: (file: File) => void;\n}) {\n const tr = useTr();\n const inputRef = useRef<HTMLInputElement>(null);\n const [dragging, setDragging] = useState(false);\n const drop = (event: DragEvent<HTMLDivElement>) => {\n event.preventDefault();\n setDragging(false);\n const file = event.dataTransfer.files[0];\n if (file && !busy) onFile(file);\n };\n return (\n <div\n onDragOver={(event) => {\n event.preventDefault();\n setDragging(true);\n }}\n onDragLeave={() => setDragging(false)}\n onDrop={drop}\n className={cn(\n 'flex items-center gap-3 rounded-lg border border-dashed p-4',\n dragging ? 'border-action-primary-bg bg-accent-soft' : 'border-border-strong bg-bg-sunken'\n )}\n >\n <Tile icon={Upload} />\n <div className=\"flex min-w-0 flex-1 flex-col gap-1\">\n <span className=\"truncate text-sm text-text-primary\">\n {fileName ? (\n <span className=\"font-semibold\">{fileName}</span>\n ) : (\n tr('security.v2.import.drop', 'Drop the file here, or choose one.')\n )}\n </span>\n <span className=\"text-xs text-text-secondary\">{help}</span>\n </div>\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n disabled={busy}\n onClick={() => inputRef.current?.click()}\n >\n {tr('security.v2.import.choose', 'Choose a file')}\n </Button>\n <input\n ref={inputRef}\n type=\"file\"\n className=\"sr-only\"\n tabIndex={-1}\n aria-hidden=\"true\"\n accept={accept}\n onChange={(event) => {\n const file = event.target.files?.[0];\n if (file) onFile(file);\n event.target.value = '';\n }}\n />\n </div>\n );\n}\n\n/** What the file held: \"6 values found: …\". */\nfunction FoundNotice({ names }: { names: readonly string[] }) {\n const tr = useTr();\n const shown = names.slice(0, 5).join(', ') + (names.length > 5 ? '…' : '');\n return (\n <Notice tone=\"info\">\n {names.length === 1\n ? tr(\n 'security.v2.import.foundOne',\n '1 value found: {{names}}. Values arrive hidden; nothing is shared.',\n {\n names: shown,\n }\n )\n : tr(\n 'security.v2.import.found',\n '{{count}} values found: {{names}}. Values arrive hidden; nothing is shared.',\n {\n count: names.length,\n names: shown,\n }\n )}\n </Notice>\n );\n}\n\n/** A backup's password, from the email sent when it was exported. */\nfunction BackupPassword({ value, onChange }: { value: string; onChange: (value: string) => void }) {\n const tr = useTr();\n const id = useId();\n return (\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={id}>{tr('security.v2.import.password', 'Backup password')}</Label>\n <Input\n id={id}\n type=\"password\"\n autoComplete=\"off\"\n value={value}\n onChange={(event) => onChange(event.target.value)}\n placeholder={tr(\n 'security.v2.import.passwordHint',\n 'From the email we sent when it was exported'\n )}\n />\n </div>\n );\n}\n\n/** How the import went: done, partly done, nothing new, or failed. */\nfunction ImportOutcome({ state }: { state: ImportState }) {\n const tr = useTr();\n if (state.status === 'completed' && state.results) {\n return (\n <Notice tone=\"info\">\n {state.results.imported === 1\n ? tr(\n 'security.v2.import.doneOne',\n '1 value imported, {{skipped}} already there and skipped.',\n {\n skipped: state.results.skipped,\n }\n )\n : tr(\n 'security.v2.import.done',\n '{{count}} values imported, {{skipped}} already there and skipped.',\n {\n count: state.results.imported,\n skipped: state.results.skipped,\n }\n )}\n </Notice>\n );\n }\n if (state.status === 'error' || state.status === 'partial' || state.status === 'skipped') {\n return (\n <Notice tone={state.status === 'error' ? 'bad' : 'warn'}>\n {state.error ?? tr('security.v2.import.failed', 'The file could not be imported.')}\n </Notice>\n );\n }\n return null;\n}\n\nfunction RecentList({ recent }: { recent: readonly RecentTransfer[] }) {\n const tr = useTr();\n const headingId = useId();\n return (\n <section className=\"flex flex-col gap-2\" aria-labelledby={headingId}>\n <h3\n id={headingId}\n className=\"text-xs font-semibold uppercase tracking-wide text-text-secondary\"\n >\n {tr('security.v2.import.recent', 'Recent')}\n </h3>\n <ul className=\"flex flex-col rounded-lg border border-border-subtle\">\n {recent.map((entry) => (\n <li\n key={entry.id}\n className=\"flex flex-col gap-0.5 border-b border-border-subtle p-3 last:border-b-0\"\n >\n <span className=\"text-sm font-medium text-text-primary\">{entry.sentence}</span>\n <span className=\"text-xs text-text-secondary\">{entry.when}</span>\n </li>\n ))}\n </ul>\n </section>\n );\n}\n\nexport interface ImportPanelProps {\n state: ImportState;\n onFile: (file: File) => void;\n vaults: readonly { id: string; name: string }[];\n vaultId: string;\n onVaultChange: (vaultId: string) => void;\n password: string;\n onPasswordChange: (value: string) => void;\n recent: readonly RecentTransfer[] | null;\n busy: boolean;\n}\n\n/**\n * Import (BOFF-15820): where the values come from, the file, the vault they go into, and the\n * recent imports and exports. The file is read in the browser first; nothing is saved until Import.\n */\nexport function ImportPanel({\n state,\n onFile,\n vaults,\n vaultId,\n onVaultChange,\n password,\n onPasswordChange,\n recent,\n busy,\n}: ImportPanelProps) {\n const tr = useTr();\n const formats = useImportFormats();\n const [format, setFormat] = useState<ImportFormat>('env');\n const vaultSelectId = useId();\n const current = formats.find((entry) => entry.id === format);\n\n return (\n <div className=\"flex flex-col gap-4\">\n <FormatPicker formats={formats} value={format} onChange={setFormat} />\n <DropZone\n fileName={state.fileName}\n help={current?.help ?? ''}\n accept={ACCEPT[format]}\n busy={busy}\n onFile={onFile}\n />\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={vaultSelectId}>{tr('security.v2.import.into', 'Into vault')}</Label>\n <ThemedSelect\n id={vaultSelectId}\n value={vaultId}\n disabled={busy || vaults.length === 0}\n onChange={(event) => onVaultChange(event.target.value)}\n className=\"h-10 rounded-lg border border-border-default bg-bg-surface px-3 text-sm text-text-primary\"\n >\n {vaults.length === 0 ? (\n <option value=\"\">{tr('security.v2.import.noVaults', 'Make a vault first')}</option>\n ) : null}\n {vaults.map((vault) => (\n <option key={vault.id} value={vault.id}>\n {vault.name}\n </option>\n ))}\n </ThemedSelect>\n </div>\n {state.status === 'ready' && state.sourceType === 'plain' ? (\n <FoundNotice names={state.parsedSecrets.map((secret) => secret.name)} />\n ) : null}\n {state.sourceType === 'backup' &&\n (state.status === 'ready' || state.status === 'importing') ? (\n <BackupPassword value={password} onChange={onPasswordChange} />\n ) : null}\n <ImportOutcome state={state} />\n {recent && recent.length ? <RecentList recent={recent} /> : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAUA,IAAMA,IAAiD;CACrD,KAAK;CACL,KAAK;CACL,MAAM;CACN,QAAQ;AACV;AAgBA,SAASC,IAA4C;CACnD,IAAMC,IAAKC,EAAM;CACjB,OAAOC,QACC;EACJ;GACE,IAAI;GACJ,OAAOF,EAAG,iCAAiC,WAAW;GACtD,MAAMA,EACJ,qCACA,qDACF;GACA,MAAMG;EACR;EACA;GACE,IAAI;GACJ,OAAOH,EAAG,iCAAiC,KAAK;GAChD,MAAMA,EACJ,qCACA,mFACF;GACA,MAAMI;EACR;EACA;GACE,IAAI;GACJ,OAAOJ,EAAG,kCAAkC,MAAM;GAClD,MAAMA,EACJ,sCACA,+EACF;GACA,MAAMK;EACR;EACA;GACE,IAAI;GACJ,OAAOL,EAAG,oC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UAAS,CAAA,IAAI;EACzD;;AAET"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface ImportFooterProps {
|
|
2
|
+
/** Done (after an import) or Cancel. */
|
|
3
|
+
finished: boolean;
|
|
4
|
+
busy: boolean;
|
|
5
|
+
canImport: boolean;
|
|
6
|
+
canRun: boolean;
|
|
7
|
+
/** Plain values found in the file; 0 for a backup. */
|
|
8
|
+
count: number;
|
|
9
|
+
onClose: () => void;
|
|
10
|
+
onAnother: () => void;
|
|
11
|
+
onRun: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function ImportFooter({ finished, busy, canImport, canRun, count, onClose, onAnother, onRun, }: ImportFooterProps): import('react').JSX.Element;
|
|
14
|
+
export interface ExportFooterProps {
|
|
15
|
+
busy: boolean;
|
|
16
|
+
canExport: boolean;
|
|
17
|
+
count: number;
|
|
18
|
+
onClose: () => void;
|
|
19
|
+
onRun: () => void;
|
|
20
|
+
}
|
|
21
|
+
export declare function ExportFooter({ busy, canExport, count, onClose, onRun }: ExportFooterProps): import('react').JSX.Element;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useTr as e } from "../../../hooks/useTr.js";
|
|
2
|
+
import { Fragment as t, jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
3
|
+
import { Download as i, Import as a } from "lucide-react";
|
|
4
|
+
import { Button as o, LockedButton as s } from "@burdenoff/fe-libs/ui";
|
|
5
|
+
// src/security/v2/dialogs/import-export/TransferFooters.tsx
|
|
6
|
+
function c({ finished: i, busy: c, canImport: l, canRun: u, count: d, onClose: f, onAnother: p, onRun: m }) {
|
|
7
|
+
let h = e(), g = c ? h("security.v2.import.importing", "Importing…") : d === 1 ? h("security.v2.import.runOne", "Import 1 value") : d > 1 ? h("security.v2.import.run", "Import {{count}} values", { count: d }) : h("security.v2.import.runBackup", "Import");
|
|
8
|
+
return /* @__PURE__ */ r(t, { children: [
|
|
9
|
+
/* @__PURE__ */ n("span", { className: "flex-1" }),
|
|
10
|
+
/* @__PURE__ */ n(o, {
|
|
11
|
+
variant: "outline",
|
|
12
|
+
onClick: f,
|
|
13
|
+
disabled: c,
|
|
14
|
+
children: i ? h("security.v2.common.done", "Done") : h("security.v2.common.cancel", "Cancel")
|
|
15
|
+
}),
|
|
16
|
+
i ? /* @__PURE__ */ n(o, {
|
|
17
|
+
onClick: p,
|
|
18
|
+
children: h("security.v2.import.another", "Import another file")
|
|
19
|
+
}) : /* @__PURE__ */ n(s, {
|
|
20
|
+
locked: !l,
|
|
21
|
+
reason: h("security.v2.import.locked", "Importing is for people who may add saved values. Ask a workspace admin."),
|
|
22
|
+
icon: a,
|
|
23
|
+
disabled: !u || c,
|
|
24
|
+
onClick: m,
|
|
25
|
+
children: g
|
|
26
|
+
})
|
|
27
|
+
] });
|
|
28
|
+
}
|
|
29
|
+
function l({ busy: a, canExport: c, count: l, onClose: u, onRun: d }) {
|
|
30
|
+
let f = e();
|
|
31
|
+
return /* @__PURE__ */ r(t, { children: [
|
|
32
|
+
/* @__PURE__ */ n("span", { className: "flex-1" }),
|
|
33
|
+
/* @__PURE__ */ n(o, {
|
|
34
|
+
variant: "outline",
|
|
35
|
+
onClick: u,
|
|
36
|
+
disabled: a,
|
|
37
|
+
children: f("security.v2.common.cancel", "Cancel")
|
|
38
|
+
}),
|
|
39
|
+
/* @__PURE__ */ n(s, {
|
|
40
|
+
locked: !c,
|
|
41
|
+
reason: f("security.v2.export.lockedShort", "Exporting is for people who may export saved values."),
|
|
42
|
+
icon: i,
|
|
43
|
+
disabled: l === 0 || a,
|
|
44
|
+
onClick: d,
|
|
45
|
+
children: a ? f("security.v2.export.exporting", "Exporting…") : l === 1 ? f("security.v2.export.runOne", "Export 1 vault") : f("security.v2.export.run", "Export {{count}} vaults", { count: l })
|
|
46
|
+
})
|
|
47
|
+
] });
|
|
48
|
+
}
|
|
49
|
+
export { l as ExportFooter, c as ImportFooter };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=TransferFooters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransferFooters.js","names":["_Fragment","ImportFooter","tr","useTr","runLabel","busy","count","Fragment","Button","onClose","finished","onAnother","LockedButton","canImport","Import","canRun","onRun","ExportFooter","canExport","Download"],"sources":["../../../../../src/security/v2/dialogs/import-export/TransferFooters.tsx"],"sourcesContent":["import { Download, Import } from 'lucide-react';\nimport { Button, LockedButton } from '@burdenoff/fe-libs/ui';\nimport { useTr } from '../../../hooks/useTr';\n\nexport interface ImportFooterProps {\n /** Done (after an import) or Cancel. */\n finished: boolean;\n busy: boolean;\n canImport: boolean;\n canRun: boolean;\n /** Plain values found in the file; 0 for a backup. */\n count: number;\n onClose: () => void;\n onAnother: () => void;\n onRun: () => void;\n}\n\nexport function ImportFooter({\n finished,\n busy,\n canImport,\n canRun,\n count,\n onClose,\n onAnother,\n onRun,\n}: ImportFooterProps) {\n const tr = useTr();\n const runLabel = busy\n ? tr('security.v2.import.importing', 'Importing…')\n : count === 1\n ? tr('security.v2.import.runOne', 'Import 1 value')\n : count > 1\n ? tr('security.v2.import.run', 'Import {{count}} values', { count })\n : tr('security.v2.import.runBackup', 'Import');\n return (\n <>\n <span className=\"flex-1\" />\n <Button variant=\"outline\" onClick={onClose} disabled={busy}>\n {finished\n ? tr('security.v2.common.done', 'Done')\n : tr('security.v2.common.cancel', 'Cancel')}\n </Button>\n {finished ? (\n <Button onClick={onAnother}>\n {tr('security.v2.import.another', 'Import another file')}\n </Button>\n ) : (\n <LockedButton\n locked={!canImport}\n reason={tr(\n 'security.v2.import.locked',\n 'Importing is for people who may add saved values. Ask a workspace admin.'\n )}\n icon={Import}\n disabled={!canRun || busy}\n onClick={onRun}\n >\n {runLabel}\n </LockedButton>\n )}\n </>\n );\n}\n\nexport interface ExportFooterProps {\n busy: boolean;\n canExport: boolean;\n count: number;\n onClose: () => void;\n onRun: () => void;\n}\n\nexport function ExportFooter({ busy, canExport, count, onClose, onRun }: ExportFooterProps) {\n const tr = useTr();\n return (\n <>\n <span className=\"flex-1\" />\n <Button variant=\"outline\" onClick={onClose} disabled={busy}>\n {tr('security.v2.common.cancel', 'Cancel')}\n </Button>\n <LockedButton\n locked={!canExport}\n reason={tr(\n 'security.v2.export.lockedShort',\n 'Exporting is for people who may export saved values.'\n )}\n icon={Download}\n disabled={count === 0 || busy}\n onClick={onRun}\n >\n {busy\n ? tr('security.v2.export.exporting', 'Exporting…')\n : count === 1\n ? tr('security.v2.export.runOne', 'Export 1 vault')\n : tr('security.v2.export.run', 'Export {{count}} vaults', { count })}\n </LockedButton>\n </>\n );\n}\n"],"mappings":";;;;;AAiBA,SAAgBC,EAAa,EAC3B,aACA,SACA,cACA,WACA,UACA,YACA,cACA,YACoB;CACpB,IAAMC,IAAKC,EAAM,GACXC,IAAWC,IACbH,EAAG,gCAAgC,YAAY,IAC/CI,MAAU,IACRJ,EAAG,6BAA6B,gBAAgB,IAChDI,IAAQ,IACNJ,EAAG,0BAA0B,2BAA2B,EAAE,SAAM,CAAC,IACjEA,EAAG,gCAAgC,QAAQ;CACnD,OACE,kBAAAF,GAAA,EAAA,UAAA;EACE,kBAAC,QAAD,EAAM,WAAU,SAAU,CAAA;EAC1B,kBAACQ,GAAD;GAAQ,SAAQ;GAAU,SAASC;GAAS,UAAUJ;GACnD,UAAAK,IACGR,EAAG,2BAA2B,MAAM,IACpCA,EAAG,6BAA6B,QAAQ;EACtC,CAAA;EACPQ,IACC,kBAACF,GAAD;GAAQ,SAASG;GACd,UAAAT,EAAG,8BAA8B,qBAAqB;EACjD,CAAA,IAER,kBAACU,GAAD;GACE,QAAQ,CAACC;GACT,QAAQX,EACN,6BACA,0EACF;GACA,MAAMY;GACN,UAAU,CAACC,KAAUV;GACrB,SAASW;GAER,UAAAZ;EACW,CAAA;CAEhB,EAAA,CAAA;AAEN;AAUA,SAAgBa,EAAa,EAAE,SAAM,cAAW,UAAO,YAAS,YAA4B;CAC1F,IAAMf,IAAKC,EAAM;CACjB,OACE,kBAAAH,GAAA,EAAA,UAAA;EACE,kBAAC,QAAD,EAAM,WAAU,SAAU,CAAA;EAC1B,kBAACQ,GAAD;GAAQ,SAAQ;GAAU,SAASC;GAAS,UAAUJ;GACnD,UAAAH,EAAG,6BAA6B,QAAQ;EACnC,CAAA;EACR,kBAACU,GAAD;GACE,QAAQ,CAACM;GACT,QAAQhB,EACN,kCACA,sDACF;GACA,MAAMiB;GACN,UAAUb,MAAU,KAAKD;GACzB,SAASW;GAER,UAAAX,IACGH,EAAG,gCAAgC,YAAY,IAC/CI,MAAU,IACRJ,EAAG,6BAA6B,gBAAgB,IAChDA,EAAG,0BAA0B,2BAA2B,EAAE,SAAM,CAAC;EAC3D,CAAA;CACd,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BackupExportResult } from '../../../hooks/useImportExport';
|
|
2
|
+
import { ActorNames } from '../../hooks/useActorNames';
|
|
3
|
+
import { ExportOutcome, ExportVault } from './ExportPanel';
|
|
4
|
+
import { RecentTransfer } from './ImportPanel';
|
|
5
|
+
/** The last few imports and exports, as sentences, for people who may read the audit log. */
|
|
6
|
+
export declare function useRecentTransfers(input: {
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
vaults: readonly ExportVault[];
|
|
9
|
+
names: ActorNames;
|
|
10
|
+
ago: (value: string | null) => string | null;
|
|
11
|
+
}): RecentTransfer[] | null;
|
|
12
|
+
/**
|
|
13
|
+
* Export's state: the vaults picked, and running the export, one encrypted backup per vault. One
|
|
14
|
+
* vault failing leaves the others exported, and the outcome names each.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useVaultExport(vaults: readonly ExportVault[], createBackup: (vaultId: string) => Promise<BackupExportResult>): {
|
|
17
|
+
selected: string[];
|
|
18
|
+
toggle: (vaultId: string, checked: boolean) => void;
|
|
19
|
+
run: () => Promise<void>;
|
|
20
|
+
exporting: boolean;
|
|
21
|
+
outcome: ExportOutcome | null;
|
|
22
|
+
reset: () => void;
|
|
23
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { useAuditWords as e } from "../../components/auditWords.js";
|
|
2
|
+
import { useAuditEvents as t } from "../../hooks/useAuditEvents.js";
|
|
3
|
+
import { useCallback as n, useMemo as r, useState as i } from "react";
|
|
4
|
+
// src/security/v2/dialogs/import-export/useTransfers.ts
|
|
5
|
+
function a(n) {
|
|
6
|
+
let { enabled: i, vaults: a, names: o, ago: s } = n, c = e(), l = t({ enabled: i }), u = r(() => new Map(a.map((e) => [e.id, e.name])), [a]);
|
|
7
|
+
return r(() => i ? l.events.filter((e) => e.what === "transfer").slice(0, 3).map((e) => {
|
|
8
|
+
let t = c.sentence(e, {
|
|
9
|
+
person: o.nameOf,
|
|
10
|
+
isMe: o.isMe,
|
|
11
|
+
vault: (e) => e ? l.vaultNames.get(e) ?? u.get(e) ?? null : null,
|
|
12
|
+
value: (e) => e ? l.valueNames.get(e) ?? null : null
|
|
13
|
+
});
|
|
14
|
+
return {
|
|
15
|
+
id: e.id,
|
|
16
|
+
sentence: [
|
|
17
|
+
t.actor,
|
|
18
|
+
t.verb,
|
|
19
|
+
t.object
|
|
20
|
+
].filter(Boolean).join(" "),
|
|
21
|
+
when: s(e.at) ?? ""
|
|
22
|
+
};
|
|
23
|
+
}) : null, [
|
|
24
|
+
s,
|
|
25
|
+
l.events,
|
|
26
|
+
l.valueNames,
|
|
27
|
+
l.vaultNames,
|
|
28
|
+
i,
|
|
29
|
+
o.isMe,
|
|
30
|
+
o.nameOf,
|
|
31
|
+
u,
|
|
32
|
+
c
|
|
33
|
+
]);
|
|
34
|
+
}
|
|
35
|
+
function o(e, t) {
|
|
36
|
+
let [a, o] = i([]), [s, c] = i(!1), [l, u] = i(null), d = r(() => new Map(e.map((e) => [e.id, e])), [e]);
|
|
37
|
+
return {
|
|
38
|
+
selected: a,
|
|
39
|
+
toggle: n((e, t) => {
|
|
40
|
+
o((n) => t ? [.../* @__PURE__ */ new Set([...n, e])] : n.filter((t) => t !== e));
|
|
41
|
+
}, []),
|
|
42
|
+
run: n(async () => {
|
|
43
|
+
let e = a.flatMap((e) => {
|
|
44
|
+
let t = d.get(e);
|
|
45
|
+
return t ? [t] : [];
|
|
46
|
+
});
|
|
47
|
+
c(!0);
|
|
48
|
+
let n = await Promise.allSettled(e.map((e) => t(e.id))), r = {
|
|
49
|
+
exported: [],
|
|
50
|
+
undelivered: [],
|
|
51
|
+
failed: []
|
|
52
|
+
};
|
|
53
|
+
n.forEach((t, n) => {
|
|
54
|
+
let i = e[n]?.name ?? "";
|
|
55
|
+
t.status === "rejected" ? r.failed.push(i) : (r.exported.push(i), t.value.passwordDelivered || r.undelivered.push(i));
|
|
56
|
+
}), u(r), c(!1), o([]);
|
|
57
|
+
}, [
|
|
58
|
+
d,
|
|
59
|
+
t,
|
|
60
|
+
a
|
|
61
|
+
]),
|
|
62
|
+
exporting: s,
|
|
63
|
+
outcome: l,
|
|
64
|
+
reset: n(() => u(null), [])
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export { a as useRecentTransfers, o as useVaultExport };
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=useTransfers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTransfers.js","names":["useRecentTransfers","input","words","useAuditWords","audit","useAuditEvents","vaultName","useMemo","vaults","vault","enabled","event","parts","names","id","ago","useVaultExport","selected","setSelected","useState","exporting","setExporting","outcome","setOutcome","byId","useCallback","checked","previous","vaultId","entry","picked","results","createBackup","next","name","index","result"],"sources":["../../../../../src/security/v2/dialogs/import-export/useTransfers.ts"],"sourcesContent":["import { useCallback, useMemo, useState } from 'react';\nimport type { BackupExportResult } from '../../../hooks/useImportExport';\nimport { useAuditWords } from '../../components/auditWords';\nimport type { ActorNames } from '../../hooks/useActorNames';\nimport { useAuditEvents } from '../../hooks/useAuditEvents';\nimport type { ExportOutcome, ExportVault } from './ExportPanel';\nimport type { RecentTransfer } from './ImportPanel';\n\n/** The last few imports and exports, as sentences, for people who may read the audit log. */\nexport function useRecentTransfers(input: {\n enabled: boolean;\n vaults: readonly ExportVault[];\n names: ActorNames;\n ago: (value: string | null) => string | null;\n}): RecentTransfer[] | null {\n const { enabled, vaults, names, ago } = input;\n const words = useAuditWords();\n const audit = useAuditEvents({ enabled });\n const vaultName = useMemo(() => new Map(vaults.map((vault) => [vault.id, vault.name])), [vaults]);\n return useMemo(() => {\n if (!enabled) return null;\n return audit.events\n .filter((event) => event.what === 'transfer')\n .slice(0, 3)\n .map((event) => {\n const parts = words.sentence(event, {\n person: names.nameOf,\n isMe: names.isMe,\n vault: (id) => (id ? (audit.vaultNames.get(id) ?? vaultName.get(id) ?? null) : null),\n value: (id) => (id ? (audit.valueNames.get(id) ?? null) : null),\n });\n return {\n id: event.id,\n sentence: [parts.actor, parts.verb, parts.object].filter(Boolean).join(' '),\n when: ago(event.at) ?? '',\n };\n });\n }, [\n ago,\n audit.events,\n audit.valueNames,\n audit.vaultNames,\n enabled,\n names.isMe,\n names.nameOf,\n vaultName,\n words,\n ]);\n}\n\n/**\n * Export's state: the vaults picked, and running the export, one encrypted backup per vault. One\n * vault failing leaves the others exported, and the outcome names each.\n */\nexport function useVaultExport(\n vaults: readonly ExportVault[],\n createBackup: (vaultId: string) => Promise<BackupExportResult>\n) {\n const [selected, setSelected] = useState<string[]>([]);\n const [exporting, setExporting] = useState(false);\n const [outcome, setOutcome] = useState<ExportOutcome | null>(null);\n const byId = useMemo(() => new Map(vaults.map((vault) => [vault.id, vault])), [vaults]);\n\n const toggle = useCallback((vaultId: string, checked: boolean) => {\n setSelected((previous) =>\n checked ? [...new Set([...previous, vaultId])] : previous.filter((entry) => entry !== vaultId)\n );\n }, []);\n\n const run = useCallback(async () => {\n const picked = selected.flatMap((id) => {\n const vault = byId.get(id);\n return vault ? [vault] : [];\n });\n setExporting(true);\n const results = await Promise.allSettled(picked.map((vault) => createBackup(vault.id)));\n const next: ExportOutcome = { exported: [], undelivered: [], failed: [] };\n results.forEach((result, index) => {\n const name = picked[index]?.name ?? '';\n if (result.status === 'rejected') {\n next.failed.push(name);\n return;\n }\n next.exported.push(name);\n if (!result.value.passwordDelivered) next.undelivered.push(name);\n });\n setOutcome(next);\n setExporting(false);\n setSelected([]);\n }, [byId, createBackup, selected]);\n\n const reset = useCallback(() => setOutcome(null), []);\n\n return { selected, toggle, run, exporting, outcome, reset };\n}\n"],"mappings":";;;;AASA,SAAgBA,EAAmB,GAKP;CAC1B,IAAM,EAAE,YAAS,WAAQ,UAAO,WAAQC,GAClCC,IAAQC,EAAc,GACtBC,IAAQC,EAAe,EAAE,WAAQ,CAAC,GAClCC,IAAYC,QAAc,IAAI,IAAIC,EAAO,KAAK,MAAU,CAACC,EAAM,IAAIA,EAAM,IAAI,CAAC,CAAC,GAAG,CAACD,CAAM,CAAC;CAChG,OAAOD,QACAG,IACEN,EAAM,OACV,QAAQ,MAAUO,EAAM,SAAS,UAAU,CAAC,CAC5C,MAAM,GAAG,CAAC,CAAC,CACX,KAAK,MAAU;EACd,IAAMC,IAAQV,EAAM,SAASS,GAAO;GAClC,QAAQE,EAAM;GACd,MAAMA,EAAM;GACZ,QAAQ,MAAQC,IAAMV,EAAM,WAAW,IAAIU,CAAE,KAAKR,EAAU,IAAIQ,CAAE,KAAK,OAAQ;GAC/E,QAAQ,MAAQA,IAAMV,EAAM,WAAW,IAAIU,CAAE,KAAK,OAAQ;EAC5D,CAAC;EACD,OAAO;GACL,IAAIH,EAAM;GACV,UAAU;IAACC,EAAM;IAAOA,EAAM;IAAMA,EAAM;GAAM,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;GAC1E,MAAMG,EAAIJ,EAAM,EAAE,KAAK;EACzB;CACF,CAAC,IAhBkB,MAiBpB;EACDI;EACAX,EAAM;EACNA,EAAM;EACNA,EAAM;EACNM;EACAG,EAAM;EACNA,EAAM;EACNP;EACAJ;CACF,CAAC;AACH;AAMA,SAAgBc,EACd,GACA,GACA;CACA,IAAM,CAACC,GAAUC,KAAeC,EAAmB,CA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
|
|
|
1
|
+
import { useTr } from '../../hooks/useTr';
|
|
2
|
+
import { ReviewRole, ReviewRow } from '../model/review';
|
|
3
|
+
type Tr = ReturnType<typeof useTr>;
|
|
4
|
+
/** What a vault role lets someone do, in plain words. */
|
|
5
|
+
export declare function roleWords(tr: Tr, role: ReviewRole): string;
|
|
6
|
+
/** The access review's words: the line under a name and the suggestion chip. */
|
|
7
|
+
export declare function reviewWords(tr: Tr): {
|
|
8
|
+
line: (row: ReviewRow, ago: (value: string | null) => string | null) => string;
|
|
9
|
+
reason: (row: ReviewRow) => string;
|
|
10
|
+
};
|
|
11
|
+
export declare function useReviewWords(): {
|
|
12
|
+
line: (row: ReviewRow, ago: (value: string | null) => string | null) => string;
|
|
13
|
+
reason: (row: ReviewRow) => string;
|
|
14
|
+
};
|
|
15
|
+
export {};
|