@burdenoff/microfe-security 2026.1120.3 → 2026.1122.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,86 @@
|
|
|
1
|
+
import { SavedValuesVaultQuery } from '../../../generated/wspace-operations';
|
|
2
|
+
import { VaultMemberRole } from '../../../generated/wspace-types';
|
|
3
|
+
/** Values a vault page lists (the service caps a page at 100). */
|
|
4
|
+
export declare const VALUES_LOAD_LIMIT = 100;
|
|
5
|
+
export type VaultPageVault = NonNullable<SavedValuesVaultQuery['getVault']>;
|
|
6
|
+
export type VaultPageValue = SavedValuesVaultQuery['getSecrets']['items'][number];
|
|
7
|
+
/** A vault page's data (the vault, its values, its shares for admins) and its changes. */
|
|
8
|
+
export declare function useVaultPage(vaultId: string | undefined, canManage: boolean): {
|
|
9
|
+
vault: {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
description: string | null;
|
|
13
|
+
status: import('../../../generated/wspace-types').VaultStatus;
|
|
14
|
+
createdBy: string;
|
|
15
|
+
createdAt: string;
|
|
16
|
+
updatedAt: string;
|
|
17
|
+
lastAccessedAt: string | null;
|
|
18
|
+
lockedAt: string | null;
|
|
19
|
+
secretCount: number;
|
|
20
|
+
memberCount: number;
|
|
21
|
+
membersList: {
|
|
22
|
+
total: number;
|
|
23
|
+
items: Array<{
|
|
24
|
+
id: string;
|
|
25
|
+
actorId: string;
|
|
26
|
+
actorType: string;
|
|
27
|
+
role: VaultMemberRole;
|
|
28
|
+
createdAt: string;
|
|
29
|
+
expiresAt: string | null;
|
|
30
|
+
}>;
|
|
31
|
+
};
|
|
32
|
+
} | null;
|
|
33
|
+
values: {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
key: string;
|
|
37
|
+
description: string | null;
|
|
38
|
+
type: import('../../../generated/wspace-types').SecretType;
|
|
39
|
+
status: import('../../../generated/wspace-types').SecretStatus;
|
|
40
|
+
expiresAt: string | null;
|
|
41
|
+
lastRotatedAt: string | null;
|
|
42
|
+
lastAccessedAt: string | null;
|
|
43
|
+
updatedAt: string;
|
|
44
|
+
createdAt: string;
|
|
45
|
+
createdBy: string;
|
|
46
|
+
}[];
|
|
47
|
+
valuesTotal: number;
|
|
48
|
+
shares: {
|
|
49
|
+
id: string;
|
|
50
|
+
kind: import('../../../generated/wspace-types').SecretShareKind;
|
|
51
|
+
role: VaultMemberRole;
|
|
52
|
+
status: import('../../../generated/wspace-types').SecretShareStatus;
|
|
53
|
+
scope: import('../../../generated/wspace-types').SecretShareScope;
|
|
54
|
+
secretId: string | null;
|
|
55
|
+
actorId: string | null;
|
|
56
|
+
actorType: string | null;
|
|
57
|
+
label: string | null;
|
|
58
|
+
expiresAt: string | null;
|
|
59
|
+
createdAt: string;
|
|
60
|
+
lastAccessedAt: string | null;
|
|
61
|
+
}[];
|
|
62
|
+
sharesLoading: boolean;
|
|
63
|
+
sharesError: import('@apollo/client').ErrorLike | undefined;
|
|
64
|
+
loading: boolean;
|
|
65
|
+
error: import('@apollo/client').ErrorLike | undefined;
|
|
66
|
+
refetch: () => void;
|
|
67
|
+
readValue: (secretId: string) => Promise<string>;
|
|
68
|
+
removeValue: (value: {
|
|
69
|
+
id: string;
|
|
70
|
+
name: string;
|
|
71
|
+
}) => Promise<void>;
|
|
72
|
+
removeMember: (member: {
|
|
73
|
+
actorId: string;
|
|
74
|
+
actorType: string;
|
|
75
|
+
name: string;
|
|
76
|
+
}, vaultName: string) => Promise<void>;
|
|
77
|
+
revokeAccountShare: (share: {
|
|
78
|
+
id: string;
|
|
79
|
+
name: string;
|
|
80
|
+
}) => Promise<void>;
|
|
81
|
+
changeMemberRole: (member: {
|
|
82
|
+
actorId: string;
|
|
83
|
+
actorType: string;
|
|
84
|
+
}, role: VaultMemberRole) => Promise<void>;
|
|
85
|
+
changeShareRole: (shareId: string, role: VaultMemberRole) => Promise<void>;
|
|
86
|
+
};
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { DecryptSecretDocument as e, SavedValuesVaultDocument as t, SavedValuesVaultSharesDocument as n } from "../../../generated/wspace-operations.js";
|
|
2
|
+
import { useDeleteSecret as r } from "../../hooks/useSecretQueries.js";
|
|
3
|
+
import { useRevokeSecretShare as i, useUpdateSecretShareRole as a } from "../../hooks/useShareQueries.js";
|
|
4
|
+
import { useUnshareVault as o, useUpdateVaultMemberRole as s } from "../../hooks/useVaultQueries.js";
|
|
5
|
+
import { useTr as c } from "../../hooks/useTr.js";
|
|
6
|
+
import { useCallback as l } from "react";
|
|
7
|
+
import { useLazyQuery as u, useQuery as d } from "@apollo/client/react";
|
|
8
|
+
import { useConfirm as f, useNotify as p } from "@burdenoff/fe-libs/ui";
|
|
9
|
+
function m(e, t) {
|
|
10
|
+
return e instanceof Error && e.message ? e.message : t;
|
|
11
|
+
}
|
|
12
|
+
function h(h, v) {
|
|
13
|
+
let y = c(), b = f(), x = p(), S = d(t, {
|
|
14
|
+
variables: {
|
|
15
|
+
id: h ?? "",
|
|
16
|
+
pagination: { limit: 100 }
|
|
17
|
+
},
|
|
18
|
+
skip: !h,
|
|
19
|
+
fetchPolicy: "cache-and-network"
|
|
20
|
+
}), C = d(n, {
|
|
21
|
+
variables: { vaultId: h ?? "" },
|
|
22
|
+
skip: !h || !v,
|
|
23
|
+
fetchPolicy: "cache-and-network"
|
|
24
|
+
}), [w] = u(e, { fetchPolicy: "no-cache" }), [T] = r(), [E] = o(), [D] = i(), [O] = s(), [k] = a(), A = S.refetch, j = C.refetch, M = l(() => {
|
|
25
|
+
A(), v && j();
|
|
26
|
+
}, [
|
|
27
|
+
v,
|
|
28
|
+
A,
|
|
29
|
+
j
|
|
30
|
+
]), N = l((e, t) => x({
|
|
31
|
+
title: e,
|
|
32
|
+
description: m(t, y("security.v2.common.tryAgain", "Try again in a moment.")),
|
|
33
|
+
tone: "error",
|
|
34
|
+
urgent: !0
|
|
35
|
+
}), [x, y]), P = l(async (e) => {
|
|
36
|
+
let t = await w({ variables: { id: e } });
|
|
37
|
+
if (t.error) throw t.error;
|
|
38
|
+
let n = t.data?.decryptSecret?.value;
|
|
39
|
+
if (n == null) throw Error(y("security.v2.value.notReadable", "The value could not be read."));
|
|
40
|
+
return n;
|
|
41
|
+
}, [w, y]), F = l(async (e) => {
|
|
42
|
+
if (await b({
|
|
43
|
+
title: y("security.v2.values.delete.title", "Delete “{{name}}”?", { name: e.name }),
|
|
44
|
+
description: y("security.v2.values.delete.description", "Steps that use it stop working until it is added again."),
|
|
45
|
+
consequences: [y("security.v2.values.delete.final", "Its earlier versions are deleted too")],
|
|
46
|
+
tone: "danger",
|
|
47
|
+
confirmLabel: y("security.v2.values.delete.confirm", "Delete value")
|
|
48
|
+
})) try {
|
|
49
|
+
await T({ variables: { id: e.id } }), x({
|
|
50
|
+
title: y("security.v2.values.delete.done", "Value deleted"),
|
|
51
|
+
tone: "success"
|
|
52
|
+
}), M();
|
|
53
|
+
} catch (e) {
|
|
54
|
+
N(y("security.v2.values.delete.failed", "Couldn’t delete the value"), e);
|
|
55
|
+
}
|
|
56
|
+
}, [
|
|
57
|
+
b,
|
|
58
|
+
T,
|
|
59
|
+
N,
|
|
60
|
+
x,
|
|
61
|
+
M,
|
|
62
|
+
y
|
|
63
|
+
]), I = l(async (e, t) => {
|
|
64
|
+
if (await b({
|
|
65
|
+
title: y("security.v2.access.remove.title", "Remove {{name}} from “{{vault}}”?", {
|
|
66
|
+
name: e.name,
|
|
67
|
+
vault: t
|
|
68
|
+
}),
|
|
69
|
+
description: y("security.v2.access.remove.description", "They can’t see or use its values any more."),
|
|
70
|
+
tone: "danger",
|
|
71
|
+
confirmLabel: y("security.v2.access.remove.confirm", "Remove access")
|
|
72
|
+
}) && h) try {
|
|
73
|
+
await E({ variables: {
|
|
74
|
+
vaultId: h,
|
|
75
|
+
actorId: e.actorId,
|
|
76
|
+
actorType: e.actorType
|
|
77
|
+
} }), x({
|
|
78
|
+
title: y("security.v2.access.remove.done", "Access removed"),
|
|
79
|
+
tone: "success"
|
|
80
|
+
}), M();
|
|
81
|
+
} catch (e) {
|
|
82
|
+
N(y("security.v2.access.remove.failed", "Couldn’t remove access"), e);
|
|
83
|
+
}
|
|
84
|
+
}, [
|
|
85
|
+
b,
|
|
86
|
+
N,
|
|
87
|
+
x,
|
|
88
|
+
M,
|
|
89
|
+
y,
|
|
90
|
+
E,
|
|
91
|
+
h
|
|
92
|
+
]), L = l(async (e) => {
|
|
93
|
+
if (await b({
|
|
94
|
+
title: y("security.v2.access.revoke.title", "Stop sharing with {{name}}?", { name: e.name }),
|
|
95
|
+
description: y("security.v2.access.revoke.description", "It leaves their Shared with me at once."),
|
|
96
|
+
tone: "danger",
|
|
97
|
+
confirmLabel: y("security.v2.access.revoke.confirm", "Stop sharing")
|
|
98
|
+
})) try {
|
|
99
|
+
await D({ variables: { id: e.id } }), x({
|
|
100
|
+
title: y("security.v2.access.revoke.done", "No longer shared"),
|
|
101
|
+
tone: "success"
|
|
102
|
+
}), M();
|
|
103
|
+
} catch (e) {
|
|
104
|
+
N(y("security.v2.access.revoke.failed", "Couldn’t stop sharing"), e);
|
|
105
|
+
}
|
|
106
|
+
}, [
|
|
107
|
+
b,
|
|
108
|
+
N,
|
|
109
|
+
x,
|
|
110
|
+
M,
|
|
111
|
+
D,
|
|
112
|
+
y
|
|
113
|
+
]), R = l(async (e, t) => {
|
|
114
|
+
if (h) try {
|
|
115
|
+
await O({ variables: {
|
|
116
|
+
vaultId: h,
|
|
117
|
+
actorId: e.actorId,
|
|
118
|
+
actorType: e.actorType,
|
|
119
|
+
role: t
|
|
120
|
+
} }), x({
|
|
121
|
+
title: y("security.v2.access.role.done", "Access changed"),
|
|
122
|
+
tone: "success"
|
|
123
|
+
}), M();
|
|
124
|
+
} catch (e) {
|
|
125
|
+
N(y("security.v2.access.role.failed", "Couldn’t change access"), e);
|
|
126
|
+
}
|
|
127
|
+
}, [
|
|
128
|
+
N,
|
|
129
|
+
x,
|
|
130
|
+
M,
|
|
131
|
+
y,
|
|
132
|
+
O,
|
|
133
|
+
h
|
|
134
|
+
]), z = l(async (e, t) => {
|
|
135
|
+
try {
|
|
136
|
+
await k({ variables: {
|
|
137
|
+
id: e,
|
|
138
|
+
role: t
|
|
139
|
+
} }), x({
|
|
140
|
+
title: y("security.v2.access.role.done", "Access changed"),
|
|
141
|
+
tone: "success"
|
|
142
|
+
}), M();
|
|
143
|
+
} catch (e) {
|
|
144
|
+
N(y("security.v2.access.role.failed", "Couldn’t change access"), e);
|
|
145
|
+
}
|
|
146
|
+
}, [
|
|
147
|
+
N,
|
|
148
|
+
x,
|
|
149
|
+
M,
|
|
150
|
+
y,
|
|
151
|
+
k
|
|
152
|
+
]);
|
|
153
|
+
return {
|
|
154
|
+
vault: S.data?.getVault ?? null,
|
|
155
|
+
values: S.data?.getSecrets.items ?? g,
|
|
156
|
+
valuesTotal: S.data?.getSecrets.total ?? 0,
|
|
157
|
+
shares: C.data?.secretShares.items ?? _,
|
|
158
|
+
sharesLoading: v && C.loading && !C.data,
|
|
159
|
+
sharesError: v ? C.error : void 0,
|
|
160
|
+
loading: S.loading && !S.data,
|
|
161
|
+
error: S.error,
|
|
162
|
+
refetch: M,
|
|
163
|
+
readValue: P,
|
|
164
|
+
removeValue: F,
|
|
165
|
+
removeMember: I,
|
|
166
|
+
revokeAccountShare: L,
|
|
167
|
+
changeMemberRole: R,
|
|
168
|
+
changeShareRole: z
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
var g = [], _ = [];
|
|
172
|
+
export { h as useVaultPage };
|
|
173
|
+
|
|
174
|
+
//# sourceMappingURL=useVaultPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useVaultPage.js","names":["reason","error","fallback","useVaultPage","tr","useTr","confirm","useConfirm","notify","useNotify","query","useQuery","SavedValuesVaultDocument","vaultId","shares","SavedValuesVaultSharesDocument","canManage","decrypt","useLazyQuery","DecryptSecretDocument","deleteSecret","useDeleteSecret","unshareVault","useUnshareVault","revokeShare","useRevokeSecretShare","updateMemberRole","useUpdateVaultMemberRole","updateShareRole","useUpdateSecretShareRole","refetchVault","refetchShares","refetch","useCallback","failed","readValue","result","secretId","value","removeValue","removeMember","member","vaultName","revokeAccountShare","share","changeMemberRole","changeShareRole","shareId","NO_VALUES","NO_SHARES"],"sources":["../../../../src/security/v2/hooks/useVaultPage.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useLazyQuery, useQuery } from '@apollo/client/react';\nimport { useConfirm, useNotify } from '@burdenoff/fe-libs/ui';\nimport {\n DecryptSecretDocument,\n SavedValuesVaultDocument,\n SavedValuesVaultSharesDocument,\n type DecryptSecretQuery,\n type DecryptSecretQueryVariables,\n type SavedValuesVaultQuery,\n type SavedValuesVaultQueryVariables,\n type SavedValuesVaultSharesQuery,\n type SavedValuesVaultSharesQueryVariables,\n} from '../../../generated/wspace-operations';\nimport type { VaultMemberRole } from '../../../generated/wspace-types';\nimport { useDeleteSecret } from '../../hooks/useSecretQueries';\nimport { useRevokeSecretShare, useUpdateSecretShareRole } from '../../hooks/useShareQueries';\nimport { useUnshareVault, useUpdateVaultMemberRole } from '../../hooks/useVaultQueries';\nimport { useTr } from '../../hooks/useTr';\n\n/** Values a vault page lists (the service caps a page at 100). */\nexport const VALUES_LOAD_LIMIT = 100;\n\nexport type VaultPageVault = NonNullable<SavedValuesVaultQuery['getVault']>;\nexport type VaultPageValue = SavedValuesVaultQuery['getSecrets']['items'][number];\n\nfunction reason(error: unknown, fallback: string): string {\n return error instanceof Error && error.message ? error.message : fallback;\n}\n\n/** A vault page's data (the vault, its values, its shares for admins) and its changes. */\nexport function useVaultPage(vaultId: string | undefined, canManage: boolean) {\n const tr = useTr();\n const confirm = useConfirm();\n const notify = useNotify();\n const query = useQuery<SavedValuesVaultQuery, SavedValuesVaultQueryVariables>(\n SavedValuesVaultDocument,\n {\n variables: { id: vaultId ?? '', pagination: { limit: VALUES_LOAD_LIMIT } },\n skip: !vaultId,\n fetchPolicy: 'cache-and-network',\n }\n );\n const shares = useQuery<SavedValuesVaultSharesQuery, SavedValuesVaultSharesQueryVariables>(\n SavedValuesVaultSharesDocument,\n {\n variables: { vaultId: vaultId ?? '' },\n skip: !vaultId || !canManage,\n fetchPolicy: 'cache-and-network',\n }\n );\n const [decrypt] = useLazyQuery<DecryptSecretQuery, DecryptSecretQueryVariables>(\n DecryptSecretDocument,\n {\n fetchPolicy: 'no-cache',\n }\n );\n const [deleteSecret] = useDeleteSecret();\n const [unshareVault] = useUnshareVault();\n const [revokeShare] = useRevokeSecretShare();\n const [updateMemberRole] = useUpdateVaultMemberRole();\n const [updateShareRole] = useUpdateSecretShareRole();\n\n const refetchVault = query.refetch;\n const refetchShares = shares.refetch;\n const refetch = useCallback(() => {\n void refetchVault();\n if (canManage) void refetchShares();\n }, [canManage, refetchVault, refetchShares]);\n\n const failed = useCallback(\n (title: string, error: unknown) =>\n notify({\n title,\n description: reason(error, tr('security.v2.common.tryAgain', 'Try again in a moment.')),\n tone: 'error',\n urgent: true,\n }),\n [notify, tr]\n );\n\n /** Reads one value; the service decrypts it and records who did. */\n const readValue = useCallback(\n async (secretId: string): Promise<string> => {\n const result = await decrypt({ variables: { id: secretId } });\n if (result.error) throw result.error;\n const value = result.data?.decryptSecret?.value;\n if (value === undefined || value === null) {\n throw new Error(tr('security.v2.value.notReadable', 'The value could not be read.'));\n }\n return value;\n },\n [decrypt, tr]\n );\n\n const removeValue = useCallback(\n async (value: { id: string; name: string }) => {\n const yes = await confirm({\n title: tr('security.v2.values.delete.title', 'Delete “{{name}}”?', { name: value.name }),\n description: tr(\n 'security.v2.values.delete.description',\n 'Steps that use it stop working until it is added again.'\n ),\n consequences: [\n tr('security.v2.values.delete.final', 'Its earlier versions are deleted too'),\n ],\n tone: 'danger',\n confirmLabel: tr('security.v2.values.delete.confirm', 'Delete value'),\n });\n if (!yes) return;\n try {\n await deleteSecret({ variables: { id: value.id } });\n notify({ title: tr('security.v2.values.delete.done', 'Value deleted'), tone: 'success' });\n refetch();\n } catch (error) {\n failed(tr('security.v2.values.delete.failed', 'Couldn’t delete the value'), error);\n }\n },\n [confirm, deleteSecret, failed, notify, refetch, tr]\n );\n\n const removeMember = useCallback(\n async (member: { actorId: string; actorType: string; name: string }, vaultName: string) => {\n const yes = await confirm({\n title: tr('security.v2.access.remove.title', 'Remove {{name}} from “{{vault}}”?', {\n name: member.name,\n vault: vaultName,\n }),\n description: tr(\n 'security.v2.access.remove.description',\n 'They can’t see or use its values any more.'\n ),\n tone: 'danger',\n confirmLabel: tr('security.v2.access.remove.confirm', 'Remove access'),\n });\n if (!yes || !vaultId) return;\n try {\n await unshareVault({\n variables: { vaultId, actorId: member.actorId, actorType: member.actorType },\n });\n notify({ title: tr('security.v2.access.remove.done', 'Access removed'), tone: 'success' });\n refetch();\n } catch (error) {\n failed(tr('security.v2.access.remove.failed', 'Couldn’t remove access'), error);\n }\n },\n [confirm, failed, notify, refetch, tr, unshareVault, vaultId]\n );\n\n const revokeAccountShare = useCallback(\n async (share: { id: string; name: string }) => {\n const yes = await confirm({\n title: tr('security.v2.access.revoke.title', 'Stop sharing with {{name}}?', {\n name: share.name,\n }),\n description: tr(\n 'security.v2.access.revoke.description',\n 'It leaves their Shared with me at once.'\n ),\n tone: 'danger',\n confirmLabel: tr('security.v2.access.revoke.confirm', 'Stop sharing'),\n });\n if (!yes) return;\n try {\n await revokeShare({ variables: { id: share.id } });\n notify({\n title: tr('security.v2.access.revoke.done', 'No longer shared'),\n tone: 'success',\n });\n refetch();\n } catch (error) {\n failed(tr('security.v2.access.revoke.failed', 'Couldn’t stop sharing'), error);\n }\n },\n [confirm, failed, notify, refetch, revokeShare, tr]\n );\n\n const changeMemberRole = useCallback(\n async (member: { actorId: string; actorType: string }, role: VaultMemberRole) => {\n if (!vaultId) return;\n try {\n await updateMemberRole({\n variables: { vaultId, actorId: member.actorId, actorType: member.actorType, role },\n });\n notify({ title: tr('security.v2.access.role.done', 'Access changed'), tone: 'success' });\n refetch();\n } catch (error) {\n failed(tr('security.v2.access.role.failed', 'Couldn’t change access'), error);\n }\n },\n [failed, notify, refetch, tr, updateMemberRole, vaultId]\n );\n\n const changeShareRole = useCallback(\n async (shareId: string, role: VaultMemberRole) => {\n try {\n await updateShareRole({ variables: { id: shareId, role } });\n notify({ title: tr('security.v2.access.role.done', 'Access changed'), tone: 'success' });\n refetch();\n } catch (error) {\n failed(tr('security.v2.access.role.failed', 'Couldn’t change access'), error);\n }\n },\n [failed, notify, refetch, tr, updateShareRole]\n );\n\n return {\n vault: query.data?.getVault ?? null,\n values: query.data?.getSecrets.items ?? NO_VALUES,\n valuesTotal: query.data?.getSecrets.total ?? 0,\n shares: shares.data?.secretShares.items ?? NO_SHARES,\n sharesLoading: canManage && shares.loading && !shares.data,\n sharesError: canManage ? shares.error : undefined,\n loading: query.loading && !query.data,\n error: query.error,\n refetch,\n readValue,\n removeValue,\n removeMember,\n revokeAccountShare,\n changeMemberRole,\n changeShareRole,\n };\n}\n\nconst NO_VALUES: VaultPageValue[] = [];\nconst NO_SHARES: SavedValuesVaultSharesQuery['secretShares']['items'] = [];\n"],"mappings":";;;;;;;;AA0BA,SAASA,EAAO,GAAgB,GAA0B;CACxD,OAAOC,aAAiB,SAASA,EAAM,UAAUA,EAAM,UAAUC;AACnE;AAGA,SAAgBC,EAAa,GAA6B,GAAoB;CAC5E,IAAMC,IAAKC,EAAM,GACXC,IAAUC,EAAW,GACrBC,IAASC,EAAU,GACnBC,IAAQC,EACZC,GACA;EACE,WAAW;GAAE,IAAIC,KAAW;GAAI,YAAY,EAAE,OAAA,IAAyB;EAAE;EACzE,MAAM,CAACA;EACP,aAAa;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CAACA,EAAM;EACjC,OAAOA,EAAM;EACb;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF;AAEA,IAAMsC,IAA8B,CAAC,GAC/BC,IAAkE,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ReviewRole } from './review';
|
|
2
|
+
export interface AccessVaultInput {
|
|
3
|
+
createdBy: string;
|
|
4
|
+
createdAt?: string | null;
|
|
5
|
+
members: readonly {
|
|
6
|
+
id: string;
|
|
7
|
+
actorId: string;
|
|
8
|
+
actorType: string;
|
|
9
|
+
role: string;
|
|
10
|
+
createdAt?: string | null;
|
|
11
|
+
expiresAt?: string | null;
|
|
12
|
+
}[];
|
|
13
|
+
}
|
|
14
|
+
export interface AccessShareInput {
|
|
15
|
+
id: string;
|
|
16
|
+
kind: string;
|
|
17
|
+
status: string;
|
|
18
|
+
scope: string;
|
|
19
|
+
role: string;
|
|
20
|
+
actorId?: string | null;
|
|
21
|
+
actorType?: string | null;
|
|
22
|
+
createdAt?: string | null;
|
|
23
|
+
expiresAt?: string | null;
|
|
24
|
+
lastAccessedAt?: string | null;
|
|
25
|
+
}
|
|
26
|
+
export type AccessRow = {
|
|
27
|
+
id: string;
|
|
28
|
+
kind: 'owner';
|
|
29
|
+
actorId: string;
|
|
30
|
+
actorType: string;
|
|
31
|
+
since: string | null;
|
|
32
|
+
} | {
|
|
33
|
+
id: string;
|
|
34
|
+
kind: 'member';
|
|
35
|
+
actorId: string;
|
|
36
|
+
actorType: string;
|
|
37
|
+
role: ReviewRole;
|
|
38
|
+
since: string | null;
|
|
39
|
+
expiresAt: string | null;
|
|
40
|
+
} | {
|
|
41
|
+
id: string;
|
|
42
|
+
kind: 'share';
|
|
43
|
+
shareId: string;
|
|
44
|
+
actorId: string;
|
|
45
|
+
actorType: string;
|
|
46
|
+
role: ReviewRole;
|
|
47
|
+
oneValue: boolean;
|
|
48
|
+
since: string | null;
|
|
49
|
+
expiresAt: string | null;
|
|
50
|
+
lastOpened: string | null;
|
|
51
|
+
};
|
|
52
|
+
export declare function live(expiresAt: string | null | undefined, now: Date): boolean;
|
|
53
|
+
export declare function buildAccessRows(vault: AccessVaultInput, shares: readonly AccessShareInput[], now: Date): {
|
|
54
|
+
rows: AccessRow[];
|
|
55
|
+
openLinks: number;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* How many people can use the vault: each person once, though someone added to the vault may also
|
|
59
|
+
* hold an account share. The tab count, the header and the list's summary all read this.
|
|
60
|
+
*/
|
|
61
|
+
export declare function peopleCount(rows: readonly AccessRow[]): number;
|
|
62
|
+
/** The roles a row can be changed to: shares stop at "Can edit" (the service refuses manage). */
|
|
63
|
+
export declare function roleChoices(row: AccessRow): ReviewRole[];
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { daysUntil as e } from "./time.js";
|
|
2
|
+
// src/security/v2/model/access.ts
|
|
3
|
+
function t(e) {
|
|
4
|
+
return e === "ADMIN" || e === "EDITOR" ? e : "VIEWER";
|
|
5
|
+
}
|
|
6
|
+
function n(t, n) {
|
|
7
|
+
let r = e(t, n);
|
|
8
|
+
return r === null || r > 0;
|
|
9
|
+
}
|
|
10
|
+
function r(e, r, i) {
|
|
11
|
+
let a = [{
|
|
12
|
+
id: `owner:${e.createdBy}`,
|
|
13
|
+
kind: "owner",
|
|
14
|
+
actorId: e.createdBy,
|
|
15
|
+
actorType: "user",
|
|
16
|
+
since: e.createdAt ?? null
|
|
17
|
+
}];
|
|
18
|
+
for (let r of e.members) r.actorId !== e.createdBy && n(r.expiresAt, i) && a.push({
|
|
19
|
+
id: `member:${r.id}`,
|
|
20
|
+
kind: "member",
|
|
21
|
+
actorId: r.actorId,
|
|
22
|
+
actorType: (r.actorType || "user").toLowerCase(),
|
|
23
|
+
role: t(r.role),
|
|
24
|
+
since: r.createdAt ?? null,
|
|
25
|
+
expiresAt: r.expiresAt ?? null
|
|
26
|
+
});
|
|
27
|
+
let o = 0;
|
|
28
|
+
for (let e of r) e.status === "ACTIVE" && n(e.expiresAt, i) && (e.kind === "LINK" ? o += 1 : e.kind === "ACCOUNT" && e.actorId && a.push({
|
|
29
|
+
id: `share:${e.id}`,
|
|
30
|
+
kind: "share",
|
|
31
|
+
shareId: e.id,
|
|
32
|
+
actorId: e.actorId,
|
|
33
|
+
actorType: (e.actorType || "user").toLowerCase(),
|
|
34
|
+
role: t(e.role),
|
|
35
|
+
oneValue: e.scope === "SECRET",
|
|
36
|
+
since: e.createdAt ?? null,
|
|
37
|
+
expiresAt: e.expiresAt ?? null,
|
|
38
|
+
lastOpened: e.lastAccessedAt ?? null
|
|
39
|
+
}));
|
|
40
|
+
return {
|
|
41
|
+
rows: a,
|
|
42
|
+
openLinks: o
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function i(e) {
|
|
46
|
+
return new Set(e.map((e) => e.actorId)).size;
|
|
47
|
+
}
|
|
48
|
+
function a(e) {
|
|
49
|
+
return e.kind === "owner" ? [] : (e.kind === "share" ? ["VIEWER", "EDITOR"] : [
|
|
50
|
+
"VIEWER",
|
|
51
|
+
"EDITOR",
|
|
52
|
+
"ADMIN"
|
|
53
|
+
]).filter((t) => t !== e.role);
|
|
54
|
+
}
|
|
55
|
+
export { r as buildAccessRows, n as live, i as peopleCount, a as roleChoices };
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=access.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access.js","names":["roleOf","value","live","left","daysUntil","expiresAt","now","buildAccessRows","rows","vault","member","openLinks","share","shares","peopleCount","row","roleChoices","role"],"sources":["../../../../src/security/v2/model/access.ts"],"sourcesContent":["/**\n * A vault's \"Who can use it\" (BOFF-15820): the person who made it, the people added to it, and the\n * accounts it (or one of its values) was shared with. Share links are counted, not listed: a link\n * has no person.\n */\nimport { daysUntil } from './time';\nimport type { ReviewRole } from './review';\n\nexport interface AccessVaultInput {\n createdBy: string;\n createdAt?: string | null;\n members: readonly {\n id: string;\n actorId: string;\n actorType: string;\n role: string;\n createdAt?: string | null;\n expiresAt?: string | null;\n }[];\n}\n\nexport interface AccessShareInput {\n id: string;\n kind: string;\n status: string;\n scope: string;\n role: string;\n actorId?: string | null;\n actorType?: string | null;\n createdAt?: string | null;\n expiresAt?: string | null;\n lastAccessedAt?: string | null;\n}\n\nexport type AccessRow =\n | { id: string; kind: 'owner'; actorId: string; actorType: string; since: string | null }\n | {\n id: string;\n kind: 'member';\n actorId: string;\n actorType: string;\n role: ReviewRole;\n since: string | null;\n expiresAt: string | null;\n }\n | {\n id: string;\n kind: 'share';\n shareId: string;\n actorId: string;\n actorType: string;\n role: ReviewRole;\n oneValue: boolean;\n since: string | null;\n expiresAt: string | null;\n lastOpened: string | null;\n };\n\nfunction roleOf(value: string): ReviewRole {\n return value === 'ADMIN' || value === 'EDITOR' ? value : 'VIEWER';\n}\n\nexport function live(expiresAt: string | null | undefined, now: Date): boolean {\n const left = daysUntil(expiresAt, now);\n return left === null || left > 0;\n}\n\nexport function buildAccessRows(\n vault: AccessVaultInput,\n shares: readonly AccessShareInput[],\n now: Date\n): { rows: AccessRow[]; openLinks: number } {\n const rows: AccessRow[] = [\n {\n id: `owner:${vault.createdBy}`,\n kind: 'owner',\n actorId: vault.createdBy,\n actorType: 'user',\n since: vault.createdAt ?? null,\n },\n ];\n for (const member of vault.members) {\n if (member.actorId === vault.createdBy || !live(member.expiresAt, now)) continue;\n rows.push({\n id: `member:${member.id}`,\n kind: 'member',\n actorId: member.actorId,\n actorType: (member.actorType || 'user').toLowerCase(),\n role: roleOf(member.role),\n since: member.createdAt ?? null,\n expiresAt: member.expiresAt ?? null,\n });\n }\n let openLinks = 0;\n for (const share of shares) {\n if (share.status !== 'ACTIVE' || !live(share.expiresAt, now)) continue;\n if (share.kind === 'LINK') {\n openLinks += 1;\n continue;\n }\n if (share.kind !== 'ACCOUNT' || !share.actorId) continue;\n rows.push({\n id: `share:${share.id}`,\n kind: 'share',\n shareId: share.id,\n actorId: share.actorId,\n actorType: (share.actorType || 'user').toLowerCase(),\n role: roleOf(share.role),\n oneValue: share.scope === 'SECRET',\n since: share.createdAt ?? null,\n expiresAt: share.expiresAt ?? null,\n lastOpened: share.lastAccessedAt ?? null,\n });\n }\n return { rows, openLinks };\n}\n\n/**\n * How many people can use the vault: each person once, though someone added to the vault may also\n * hold an account share. The tab count, the header and the list's summary all read this.\n */\nexport function peopleCount(rows: readonly AccessRow[]): number {\n return new Set(rows.map((row) => row.actorId)).size;\n}\n\n/** The roles a row can be changed to: shares stop at \"Can edit\" (the service refuses manage). */\nexport function roleChoices(row: AccessRow): ReviewRole[] {\n if (row.kind === 'owner') return [];\n const all: ReviewRole[] =\n row.kind === 'share' ? ['VIEWER', 'EDITOR'] : ['VIEWER', 'EDITOR', 'ADMIN'];\n return all.filter((role) => role !== row.role);\n}\n"],"mappings":";;AA0DA,SAASA,EAAO,GAA2B;CACzC,OAAOC,MAAU,WAAWA,MAAU,WAAWA,IAAQ;AAC3D;AAEA,SAAgBC,EAAK,GAAsC,GAAoB;CAC7E,IAAMC,IAAOC,EAAUC,GAAWC,CAAG;CACrC,OAAOH,MAAS,QAAQA,IAAO;AACjC;AAEA,SAAgBI,EACd,GACA,GACA,GAC0C;CAC1C,IAAMC,IAAoB,CACxB;EACE,IAAI,SAASC,EAAM;EACnB,MAAM;EACN,SAASA,EAAM;EACf,WAAW;EACX,OAAOA,EAAM,aAAa;CAC5B,CACF;CACA,KAAK,IAAMC,KAAUD,EAAM,SACzB,AAAIC,EAAO,YAAYD,EAAM,aAAcP,EAAKQ,EAAO,WAAWJ,CAAG,KACrEE,EAAK,KAAK;EACR,IAAI,UAAUE,EAAO;EACrB,MAAM;EACN,SAASA,EAAO;EAChB,YAAYA,EAAO,aAAa,OAAA,CAAQ,YAAY;EACpD,MAAMV,EAAOU,EAAO,IAAI;EACxB,OAAOA,EAAO,aAAa;EAC3B,WAAWA,EAAO,aAAa;CACjC,CAAC;CAEH,IAAIC,IAAY;CAChB,KAAK,IAAMC,KAASC,GAClB,AAAID,EAAM,WAAW,YAAaV,EAAKU,EAAM,WAAWN,CAAG,MACvDM,EAAM,SAAS,SACjB,KAAa,IAGXA,EAAM,SAAS,aAAcA,EAAM,WACvCJ,EAAK,KAAK;EACR,IAAI,SAASI,EAAM;EACnB,MAAM;EACN,SAASA,EAAM;EACf,SAASA,EAAM;EACf,YAAYA,EAAM,aAAa,OAAA,CAAQ,YAAY;EACnD,MAAMZ,EAAOY,EAAM,IAAI;EACvB,UAAUA,EAAM,UAAU;EAC1B,OAAOA,EAAM,aAAa;EAC1B,WAAWA,EAAM,aAAa;EAC9B,YAAYA,EAAM,kBAAkB;CACtC,CAAC;CAEH,OAAO;EAAE;EAAM;CAAU;AAC3B;AAMA,SAAgBE,EAAY,GAAoC;CAC9D,OAAO,IAAI,IAAIN,EAAK,KAAK,MAAQO,EAAI,OAAO,CAAC,CAAC,CAAC;AACjD;AAGA,SAAgBC,EAAY,GAA8B;CAIxD,OAHID,EAAI,SAAS,UAAgB,CAAC,KAEhCA,EAAI,SAAS,UAAU,CAAC,UAAU,QAAQ,IAAI;EAAC;EAAU;EAAU;CAAO,EAAA,CACjE,QAAQ,MAASE,MAASF,EAAI,IAAI;AAC/C"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The security service's audit log as sentences (Saved values v2, BOFF-15820). Each row is one
|
|
3
|
+
* action on one thing (`action`, `entityType`, `entityId`, plus what changed); this turns it into
|
|
4
|
+
* the parts of "<who> <did what> <to what>" and the vault it belongs to, for the What and Vault
|
|
5
|
+
* filters. Reveals and copies are recorded per value by the service, not in this log.
|
|
6
|
+
*/
|
|
7
|
+
export interface AuditRow {
|
|
8
|
+
id: string;
|
|
9
|
+
action: string;
|
|
10
|
+
entityType: string;
|
|
11
|
+
entityId?: string | null;
|
|
12
|
+
actorId: string;
|
|
13
|
+
actorType: string;
|
|
14
|
+
timestamp: string;
|
|
15
|
+
metadata?: Record<string, unknown> | null;
|
|
16
|
+
changesAfter?: Record<string, unknown> | null;
|
|
17
|
+
}
|
|
18
|
+
/** The What filter's groups. */
|
|
19
|
+
export type AuditWhat = 'added' | 'changed' | 'removed' | 'access' | 'transfer' | 'lock' | 'other';
|
|
20
|
+
export declare const AUDIT_WHAT: readonly AuditWhat[];
|
|
21
|
+
/** What the sentence says was done; the page words each one. */
|
|
22
|
+
export type AuditVerb = 'vault-created' | 'vault-changed' | 'vault-deleted' | 'vault-archived' | 'vault-restored' | 'vault-locked' | 'vault-unlocked' | 'value-added' | 'value-changed' | 'value-rotated' | 'value-rolled-back' | 'value-deleted' | 'values-imported' | 'values-exported' | 'backup-made' | 'backup-restored' | 'access-given' | 'access-removed' | 'access-changed' | 'outside-vault' | 'other';
|
|
23
|
+
export interface AuditEvent {
|
|
24
|
+
id: string;
|
|
25
|
+
at: string;
|
|
26
|
+
actorId: string;
|
|
27
|
+
actorType: string;
|
|
28
|
+
what: AuditWhat;
|
|
29
|
+
verb: AuditVerb;
|
|
30
|
+
/** The thing the row is about (a vault, a value, a member record). */
|
|
31
|
+
entityId: string | null;
|
|
32
|
+
/** The thing's name when the row carries one (a vault or value name). */
|
|
33
|
+
objectName: string | null;
|
|
34
|
+
vaultId: string | null;
|
|
35
|
+
/** For access rows: who was given or lost access. */
|
|
36
|
+
targetActorId: string | null;
|
|
37
|
+
tone: 'ok' | 'bad' | 'warn' | 'accent' | 'neutral';
|
|
38
|
+
}
|
|
39
|
+
export declare function toAuditEvent(row: AuditRow): AuditEvent;
|
|
40
|
+
/** Vault names from the rows themselves (a created or renamed vault carries its name). */
|
|
41
|
+
export declare function vaultNamesFromRows(rows: readonly AuditRow[]): Map<string, string>;
|
|
42
|
+
/** Value names from the rows (created values carry their name), by value id. */
|
|
43
|
+
export declare function valueNamesFromRows(rows: readonly AuditRow[]): Map<string, string>;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// src/security/v2/model/audit.ts
|
|
2
|
+
var e = [
|
|
3
|
+
"added",
|
|
4
|
+
"changed",
|
|
5
|
+
"removed",
|
|
6
|
+
"access",
|
|
7
|
+
"transfer",
|
|
8
|
+
"lock"
|
|
9
|
+
];
|
|
10
|
+
function t(e, t) {
|
|
11
|
+
let n = e?.[t];
|
|
12
|
+
return typeof n == "string" && n.trim() ? n : null;
|
|
13
|
+
}
|
|
14
|
+
function n(e, t) {
|
|
15
|
+
let n = t.toUpperCase(), r = e.toUpperCase();
|
|
16
|
+
if (n === "VAULT") switch (r) {
|
|
17
|
+
case "CREATE": return "vault-created";
|
|
18
|
+
case "UPDATE": return "vault-changed";
|
|
19
|
+
case "DELETE": return "vault-deleted";
|
|
20
|
+
case "ARCHIVE": return "vault-archived";
|
|
21
|
+
case "RESTORE": return "vault-restored";
|
|
22
|
+
case "LOCK": return "vault-locked";
|
|
23
|
+
case "UNLOCK": return "vault-unlocked";
|
|
24
|
+
case "BACKUP": return "backup-made";
|
|
25
|
+
case "RESTORE_BACKUP": return "backup-restored";
|
|
26
|
+
case "EXPORT": return "values-exported";
|
|
27
|
+
default: return "other";
|
|
28
|
+
}
|
|
29
|
+
if (n === "SECRET") switch (r) {
|
|
30
|
+
case "CREATE": return "value-added";
|
|
31
|
+
case "UPDATE": return "value-changed";
|
|
32
|
+
case "ROTATE": return "value-rotated";
|
|
33
|
+
case "ROLLBACK": return "value-rolled-back";
|
|
34
|
+
case "DELETE":
|
|
35
|
+
case "BULK_DELETE": return "value-deleted";
|
|
36
|
+
case "BULK_CREATE":
|
|
37
|
+
case "IMPORT": return "values-imported";
|
|
38
|
+
case "EXPORT": return "values-exported";
|
|
39
|
+
default: return "other";
|
|
40
|
+
}
|
|
41
|
+
return n === "VAULT_MEMBER" ? r === "SHARE" ? "access-given" : r === "UNSHARE" || r === "REVOKE" ? "access-removed" : r === "ROLE_CHANGE" ? "access-changed" : "other" : n === "EXPORT_JOB" ? "values-exported" : n === "INTEGRATION" || n === "SYNC_CONFIG" ? "outside-vault" : "other";
|
|
42
|
+
}
|
|
43
|
+
var r = {
|
|
44
|
+
"vault-created": "added",
|
|
45
|
+
"value-added": "added",
|
|
46
|
+
"vault-changed": "changed",
|
|
47
|
+
"value-changed": "changed",
|
|
48
|
+
"value-rotated": "changed",
|
|
49
|
+
"value-rolled-back": "changed",
|
|
50
|
+
"vault-deleted": "removed",
|
|
51
|
+
"value-deleted": "removed",
|
|
52
|
+
"vault-archived": "removed",
|
|
53
|
+
"vault-restored": "added",
|
|
54
|
+
"access-given": "access",
|
|
55
|
+
"access-removed": "access",
|
|
56
|
+
"access-changed": "access",
|
|
57
|
+
"values-imported": "transfer",
|
|
58
|
+
"values-exported": "transfer",
|
|
59
|
+
"backup-made": "transfer",
|
|
60
|
+
"backup-restored": "transfer",
|
|
61
|
+
"vault-locked": "lock",
|
|
62
|
+
"vault-unlocked": "lock",
|
|
63
|
+
"outside-vault": "other",
|
|
64
|
+
other: "other"
|
|
65
|
+
}, i = {
|
|
66
|
+
added: "ok",
|
|
67
|
+
changed: "neutral",
|
|
68
|
+
removed: "bad",
|
|
69
|
+
access: "accent",
|
|
70
|
+
transfer: "warn",
|
|
71
|
+
lock: "neutral",
|
|
72
|
+
other: "neutral"
|
|
73
|
+
};
|
|
74
|
+
function a(e, n) {
|
|
75
|
+
return (t(e.changesAfter, "vaultId") ?? t(e.metadata, "vaultId")) || (e.entityType.toUpperCase() === "VAULT" || n === "values-imported" ? e.entityId ?? null : null);
|
|
76
|
+
}
|
|
77
|
+
function o(e) {
|
|
78
|
+
let o = n(e.action, e.entityType), s = r[o], c = t(e.changesAfter, "targetActorId") ?? (o === "access-removed" ? e.entityId ?? null : null);
|
|
79
|
+
return {
|
|
80
|
+
id: e.id,
|
|
81
|
+
at: e.timestamp,
|
|
82
|
+
actorId: e.actorId,
|
|
83
|
+
actorType: (e.actorType || "user").toLowerCase(),
|
|
84
|
+
what: s,
|
|
85
|
+
verb: o,
|
|
86
|
+
entityId: e.entityId ?? null,
|
|
87
|
+
objectName: t(e.changesAfter, "name"),
|
|
88
|
+
vaultId: a(e, o),
|
|
89
|
+
targetActorId: c,
|
|
90
|
+
tone: i[s]
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function s(e) {
|
|
94
|
+
let n = /* @__PURE__ */ new Map();
|
|
95
|
+
for (let r of [...e].reverse()) {
|
|
96
|
+
if (r.entityType.toUpperCase() !== "VAULT" || !r.entityId) continue;
|
|
97
|
+
let e = t(r.changesAfter, "name");
|
|
98
|
+
e && n.set(r.entityId, e);
|
|
99
|
+
}
|
|
100
|
+
return n;
|
|
101
|
+
}
|
|
102
|
+
function c(e) {
|
|
103
|
+
let n = /* @__PURE__ */ new Map();
|
|
104
|
+
for (let r of [...e].reverse()) {
|
|
105
|
+
if (r.entityType.toUpperCase() !== "SECRET" || !r.entityId) continue;
|
|
106
|
+
let e = t(r.changesAfter, "name");
|
|
107
|
+
e && n.set(r.entityId, e);
|
|
108
|
+
}
|
|
109
|
+
return n;
|
|
110
|
+
}
|
|
111
|
+
export { e as AUDIT_WHAT, o as toAuditEvent, c as valueNamesFromRows, s as vaultNamesFromRows };
|
|
112
|
+
|
|
113
|
+
//# sourceMappingURL=audit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.js","names":["AUDIT_WHAT","text","value","record","key","verbFor","entity","entityType","act","action","WHAT_OF","TONE_OF","vaultIdOf","row","verb","toAuditEvent","what","targetActorId","vaultNamesFromRows","names","rows","name","valueNamesFromRows"],"sources":["../../../../src/security/v2/model/audit.ts"],"sourcesContent":["/**\n * The security service's audit log as sentences (Saved values v2, BOFF-15820). Each row is one\n * action on one thing (`action`, `entityType`, `entityId`, plus what changed); this turns it into\n * the parts of \"<who> <did what> <to what>\" and the vault it belongs to, for the What and Vault\n * filters. Reveals and copies are recorded per value by the service, not in this log.\n */\n\nexport interface AuditRow {\n id: string;\n action: string;\n entityType: string;\n entityId?: string | null;\n actorId: string;\n actorType: string;\n timestamp: string;\n metadata?: Record<string, unknown> | null;\n changesAfter?: Record<string, unknown> | null;\n}\n\n/** The What filter's groups. */\nexport type AuditWhat = 'added' | 'changed' | 'removed' | 'access' | 'transfer' | 'lock' | 'other';\n\nexport const AUDIT_WHAT: readonly AuditWhat[] = [\n 'added',\n 'changed',\n 'removed',\n 'access',\n 'transfer',\n 'lock',\n];\n\n/** What the sentence says was done; the page words each one. */\nexport type AuditVerb =\n | 'vault-created'\n | 'vault-changed'\n | 'vault-deleted'\n | 'vault-archived'\n | 'vault-restored'\n | 'vault-locked'\n | 'vault-unlocked'\n | 'value-added'\n | 'value-changed'\n | 'value-rotated'\n | 'value-rolled-back'\n | 'value-deleted'\n | 'values-imported'\n | 'values-exported'\n | 'backup-made'\n | 'backup-restored'\n | 'access-given'\n | 'access-removed'\n | 'access-changed'\n | 'outside-vault'\n | 'other';\n\nexport interface AuditEvent {\n id: string;\n at: string;\n actorId: string;\n actorType: string;\n what: AuditWhat;\n verb: AuditVerb;\n /** The thing the row is about (a vault, a value, a member record). */\n entityId: string | null;\n /** The thing's name when the row carries one (a vault or value name). */\n objectName: string | null;\n vaultId: string | null;\n /** For access rows: who was given or lost access. */\n targetActorId: string | null;\n tone: 'ok' | 'bad' | 'warn' | 'accent' | 'neutral';\n}\n\nfunction text(record: Record<string, unknown> | null | undefined, key: string): string | null {\n const value = record?.[key];\n return typeof value === 'string' && value.trim() ? value : null;\n}\n\nfunction verbFor(action: string, entityType: string): AuditVerb {\n const entity = entityType.toUpperCase();\n const act = action.toUpperCase();\n if (entity === 'VAULT') {\n switch (act) {\n case 'CREATE':\n return 'vault-created';\n case 'UPDATE':\n return 'vault-changed';\n case 'DELETE':\n return 'vault-deleted';\n case 'ARCHIVE':\n return 'vault-archived';\n case 'RESTORE':\n return 'vault-restored';\n case 'LOCK':\n return 'vault-locked';\n case 'UNLOCK':\n return 'vault-unlocked';\n case 'BACKUP':\n return 'backup-made';\n case 'RESTORE_BACKUP':\n return 'backup-restored';\n case 'EXPORT':\n return 'values-exported';\n default:\n return 'other';\n }\n }\n if (entity === 'SECRET') {\n switch (act) {\n case 'CREATE':\n return 'value-added';\n case 'UPDATE':\n return 'value-changed';\n case 'ROTATE':\n return 'value-rotated';\n case 'ROLLBACK':\n return 'value-rolled-back';\n case 'DELETE':\n case 'BULK_DELETE':\n return 'value-deleted';\n case 'BULK_CREATE':\n case 'IMPORT':\n return 'values-imported';\n case 'EXPORT':\n return 'values-exported';\n default:\n return 'other';\n }\n }\n if (entity === 'VAULT_MEMBER') {\n if (act === 'SHARE') return 'access-given';\n if (act === 'UNSHARE' || act === 'REVOKE') return 'access-removed';\n if (act === 'ROLE_CHANGE') return 'access-changed';\n return 'other';\n }\n if (entity === 'EXPORT_JOB') return 'values-exported';\n if (entity === 'INTEGRATION' || entity === 'SYNC_CONFIG') return 'outside-vault';\n return 'other';\n}\n\nconst WHAT_OF: Readonly<Record<AuditVerb, AuditWhat>> = {\n 'vault-created': 'added',\n 'value-added': 'added',\n 'vault-changed': 'changed',\n 'value-changed': 'changed',\n 'value-rotated': 'changed',\n 'value-rolled-back': 'changed',\n 'vault-deleted': 'removed',\n 'value-deleted': 'removed',\n 'vault-archived': 'removed',\n 'vault-restored': 'added',\n 'access-given': 'access',\n 'access-removed': 'access',\n 'access-changed': 'access',\n 'values-imported': 'transfer',\n 'values-exported': 'transfer',\n 'backup-made': 'transfer',\n 'backup-restored': 'transfer',\n 'vault-locked': 'lock',\n 'vault-unlocked': 'lock',\n 'outside-vault': 'other',\n other: 'other',\n};\n\nconst TONE_OF: Readonly<Record<AuditWhat, AuditEvent['tone']>> = {\n added: 'ok',\n changed: 'neutral',\n removed: 'bad',\n access: 'accent',\n transfer: 'warn',\n lock: 'neutral',\n other: 'neutral',\n};\n\nfunction vaultIdOf(row: AuditRow, verb: AuditVerb): string | null {\n const fromData = text(row.changesAfter, 'vaultId') ?? text(row.metadata, 'vaultId');\n if (fromData) return fromData;\n if (row.entityType.toUpperCase() === 'VAULT') return row.entityId ?? null;\n // Imports name the vault as the row's entity.\n if (verb === 'values-imported') return row.entityId ?? null;\n return null;\n}\n\nexport function toAuditEvent(row: AuditRow): AuditEvent {\n const verb = verbFor(row.action, row.entityType);\n const what = WHAT_OF[verb];\n const targetActorId =\n text(row.changesAfter, 'targetActorId') ??\n (verb === 'access-removed' ? (row.entityId ?? null) : null);\n return {\n id: row.id,\n at: row.timestamp,\n actorId: row.actorId,\n actorType: (row.actorType || 'user').toLowerCase(),\n what,\n verb,\n entityId: row.entityId ?? null,\n objectName: text(row.changesAfter, 'name'),\n vaultId: vaultIdOf(row, verb),\n targetActorId,\n tone: TONE_OF[what],\n };\n}\n\n/** Vault names from the rows themselves (a created or renamed vault carries its name). */\nexport function vaultNamesFromRows(rows: readonly AuditRow[]): Map<string, string> {\n const names = new Map<string, string>();\n // Oldest first, so the latest name wins.\n for (const row of [...rows].reverse()) {\n if (row.entityType.toUpperCase() !== 'VAULT' || !row.entityId) continue;\n const name = text(row.changesAfter, 'name');\n if (name) names.set(row.entityId, name);\n }\n return names;\n}\n\n/** Value names from the rows (created values carry their name), by value id. */\nexport function valueNamesFromRows(rows: readonly AuditRow[]): Map<string, string> {\n const names = new Map<string, string>();\n for (const row of [...rows].reverse()) {\n if (row.entityType.toUpperCase() !== 'SECRET' || !row.entityId) continue;\n const name = text(row.changesAfter, 'name');\n if (name) names.set(row.entityId, name);\n }\n return names;\n}\n"],"mappings":";AAsBA,IAAaA,IAAmC;CAC9C;CACA;CACA;CACA;CACA;CACA;AACF;AA2CA,SAASC,EAAK,GAAoD,GAA4B;CAC5F,IAAMC,IAAQC,IAASC;CACvB,OAAO,OAAOF,KAAU,YAAYA,EAAM,KAAK,IAAIA,IAAQ;AAC7D;AAEA,SAASG,EAAQ,GAAgB,GAA+B;CAC9D,IAAMC,IAASC,EAAW,YAAY,GAChCC,IAAMC,EAAO,YAAY;CAC/B,IAAIH,MAAW,SACb,QAAQE,GAAR;EACE,KAAK,UACH,OAAO;EACT,KAAK,UACH,OAAO;EACT,KAAK,UACH,OAAO;EACT,KAAK,WACH,OAAO;EACT,KAAK,WACH,OAAO;EACT,KA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