@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,70 @@
|
|
|
1
|
+
export interface HealthSecret {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
status?: string | null;
|
|
5
|
+
expiresAt?: string | null;
|
|
6
|
+
updatedAt?: string | null;
|
|
7
|
+
lastRotatedAt?: string | null;
|
|
8
|
+
createdAt?: string | null;
|
|
9
|
+
}
|
|
10
|
+
export interface HealthVault {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
secrets: readonly HealthSecret[];
|
|
14
|
+
/** How many values the vault holds; more than `secrets` means only some were checked. */
|
|
15
|
+
secretsTotal?: number;
|
|
16
|
+
/** Live share links on the vault; undefined while unknown (not loaded, or not allowed). */
|
|
17
|
+
publicLinks?: number;
|
|
18
|
+
}
|
|
19
|
+
export type HealthIssueId = 'expired' | 'stale-year' | 'stale' | 'public-links';
|
|
20
|
+
export type HealthTone = 'ok' | 'warn' | 'bad';
|
|
21
|
+
export interface HealthIssue {
|
|
22
|
+
id: HealthIssueId;
|
|
23
|
+
tone: Exclude<HealthTone, 'ok'>;
|
|
24
|
+
/** Values (or links) affected. */
|
|
25
|
+
count: number;
|
|
26
|
+
vaultIds: string[];
|
|
27
|
+
vaultNames: string[];
|
|
28
|
+
/** Up to three of the values' names, for the sentence. */
|
|
29
|
+
itemNames: string[];
|
|
30
|
+
/** Points it takes off the score. */
|
|
31
|
+
penalty: number;
|
|
32
|
+
}
|
|
33
|
+
export type PassingCheckId = 'encrypted' | 'none-expired' | 'all-fresh' | 'no-public-links';
|
|
34
|
+
export type HealthGrade = 'none' | 'good' | 'fair' | 'weak' | 'poor';
|
|
35
|
+
export interface HealthReport {
|
|
36
|
+
/** 0–100, or null when there is nothing to score (no vaults, or no values yet). */
|
|
37
|
+
score: number | null;
|
|
38
|
+
grade: HealthGrade;
|
|
39
|
+
tone: HealthTone;
|
|
40
|
+
/** Most urgent first. */
|
|
41
|
+
issues: HealthIssue[];
|
|
42
|
+
passing: PassingCheckId[];
|
|
43
|
+
worst: HealthIssue | null;
|
|
44
|
+
/** The score once the worst issue is fixed. */
|
|
45
|
+
scoreAfterWorst: number | null;
|
|
46
|
+
vaultCount: number;
|
|
47
|
+
valueCount: number;
|
|
48
|
+
/** Vaults with more values than were checked. */
|
|
49
|
+
partialVaultNames: string[];
|
|
50
|
+
/** Share links were known for every vault, so the link check ran. */
|
|
51
|
+
linksKnown: boolean;
|
|
52
|
+
}
|
|
53
|
+
export declare function gradeOf(score: number | null): HealthGrade;
|
|
54
|
+
/** What is wrong with one value, if anything: expired wins over old. */
|
|
55
|
+
export declare function secretProblem(secret: HealthSecret, now: Date): Extract<HealthIssueId, 'expired' | 'stale-year' | 'stale'> | null;
|
|
56
|
+
export declare function buildHealthReport(vaults: readonly HealthVault[], now: Date): HealthReport;
|
|
57
|
+
export type VaultHealthReason = {
|
|
58
|
+
id: 'expired' | 'stale-year' | 'stale';
|
|
59
|
+
count: number;
|
|
60
|
+
} | {
|
|
61
|
+
id: 'public-links';
|
|
62
|
+
count: number;
|
|
63
|
+
};
|
|
64
|
+
export interface VaultHealth {
|
|
65
|
+
tone: HealthTone;
|
|
66
|
+
/** The most urgent reason, for the card's message line. */
|
|
67
|
+
reason: VaultHealthReason | null;
|
|
68
|
+
}
|
|
69
|
+
/** One vault's card tone and the reason it needs a look. */
|
|
70
|
+
export declare function vaultHealth(vault: HealthVault, now: Date): VaultHealth;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { daysSince as e, isExpired as t, lastChangedAt as n, stalenessOf as r } from "./time.js";
|
|
2
|
+
// src/security/v2/model/health.ts
|
|
3
|
+
var i = {
|
|
4
|
+
expired: 0,
|
|
5
|
+
"stale-year": 1,
|
|
6
|
+
stale: 2,
|
|
7
|
+
"public-links": 3
|
|
8
|
+
};
|
|
9
|
+
function a(e, t) {
|
|
10
|
+
let n = Math.max(0, t - 1);
|
|
11
|
+
switch (e) {
|
|
12
|
+
case "expired": return Math.min(40, 20 + 5 * n);
|
|
13
|
+
case "stale-year": return Math.min(25, 12 + 3 * n);
|
|
14
|
+
case "stale": return Math.min(15, 6 + 2 * n);
|
|
15
|
+
case "public-links": return Math.min(15, 8 + 2 * n);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function o(e) {
|
|
19
|
+
return e === null ? "none" : e >= 90 ? "good" : e >= 70 ? "fair" : e >= 40 ? "weak" : "poor";
|
|
20
|
+
}
|
|
21
|
+
function s(i, a) {
|
|
22
|
+
if (t(i, a)) return "expired";
|
|
23
|
+
let o = r(e(n(i), a));
|
|
24
|
+
return o === "bad" ? "stale-year" : o === "warn" ? "stale" : null;
|
|
25
|
+
}
|
|
26
|
+
function c() {
|
|
27
|
+
return {
|
|
28
|
+
count: 0,
|
|
29
|
+
vaults: /* @__PURE__ */ new Map(),
|
|
30
|
+
items: []
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function l(e, t) {
|
|
34
|
+
let n = {
|
|
35
|
+
expired: c(),
|
|
36
|
+
"stale-year": c(),
|
|
37
|
+
stale: c(),
|
|
38
|
+
"public-links": c()
|
|
39
|
+
}, r = 0, l = e.length > 0, u = [];
|
|
40
|
+
for (let i of e) {
|
|
41
|
+
r += Math.max(i.secretsTotal ?? 0, i.secrets.length), (i.secretsTotal ?? 0) > i.secrets.length && u.push(i.name);
|
|
42
|
+
for (let e of i.secrets) {
|
|
43
|
+
let r = s(e, t);
|
|
44
|
+
if (!r) continue;
|
|
45
|
+
let a = n[r];
|
|
46
|
+
a.count += 1, a.vaults.set(i.id, i.name), a.items.length < 3 && a.items.push(e.name);
|
|
47
|
+
}
|
|
48
|
+
if (i.publicLinks === void 0) l = !1;
|
|
49
|
+
else if (i.publicLinks > 0) {
|
|
50
|
+
let e = n["public-links"];
|
|
51
|
+
e.count += i.publicLinks, e.vaults.set(i.id, i.name);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
let d = Object.keys(n).filter((e) => n[e].count > 0).map((e) => ({
|
|
55
|
+
id: e,
|
|
56
|
+
tone: e === "expired" || e === "stale-year" ? "bad" : "warn",
|
|
57
|
+
count: n[e].count,
|
|
58
|
+
vaultIds: [...n[e].vaults.keys()],
|
|
59
|
+
vaultNames: [...n[e].vaults.values()],
|
|
60
|
+
itemNames: n[e].items,
|
|
61
|
+
penalty: a(e, n[e].count)
|
|
62
|
+
})).sort((e, t) => i[e.id] - i[t.id]), f = e.length > 0 && r > 0, p = f ? Math.max(0, 100 - d.reduce((e, t) => e + t.penalty, 0)) : null, m = d[0] ?? null, h = f ? ["encrypted"] : [];
|
|
63
|
+
return f && !n.expired.count && h.push("none-expired"), f && !n.stale.count && !n["stale-year"].count && h.push("all-fresh"), f && l && !n["public-links"].count && h.push("no-public-links"), {
|
|
64
|
+
score: p,
|
|
65
|
+
grade: o(p),
|
|
66
|
+
tone: d.some((e) => e.tone === "bad") ? "bad" : d.length ? "warn" : "ok",
|
|
67
|
+
issues: d,
|
|
68
|
+
passing: h,
|
|
69
|
+
worst: m,
|
|
70
|
+
scoreAfterWorst: p !== null && m ? Math.min(100, p + m.penalty) : p,
|
|
71
|
+
vaultCount: e.length,
|
|
72
|
+
valueCount: r,
|
|
73
|
+
partialVaultNames: u,
|
|
74
|
+
linksKnown: l
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function u(e, t) {
|
|
78
|
+
let n = {
|
|
79
|
+
expired: 0,
|
|
80
|
+
"stale-year": 0,
|
|
81
|
+
stale: 0
|
|
82
|
+
};
|
|
83
|
+
for (let r of e.secrets) {
|
|
84
|
+
let e = s(r, t);
|
|
85
|
+
e && (n[e] += 1);
|
|
86
|
+
}
|
|
87
|
+
return n.expired ? {
|
|
88
|
+
tone: "bad",
|
|
89
|
+
reason: {
|
|
90
|
+
id: "expired",
|
|
91
|
+
count: n.expired
|
|
92
|
+
}
|
|
93
|
+
} : n["stale-year"] ? {
|
|
94
|
+
tone: "bad",
|
|
95
|
+
reason: {
|
|
96
|
+
id: "stale-year",
|
|
97
|
+
count: n["stale-year"]
|
|
98
|
+
}
|
|
99
|
+
} : n.stale ? {
|
|
100
|
+
tone: "warn",
|
|
101
|
+
reason: {
|
|
102
|
+
id: "stale",
|
|
103
|
+
count: n.stale
|
|
104
|
+
}
|
|
105
|
+
} : e.publicLinks ? {
|
|
106
|
+
tone: "warn",
|
|
107
|
+
reason: {
|
|
108
|
+
id: "public-links",
|
|
109
|
+
count: e.publicLinks
|
|
110
|
+
}
|
|
111
|
+
} : {
|
|
112
|
+
tone: "ok",
|
|
113
|
+
reason: null
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
export { l as buildHealthReport, o as gradeOf, s as secretProblem, u as vaultHealth };
|
|
117
|
+
|
|
118
|
+
//# sourceMappingURL=health.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.js","names":["ISSUE_ORDER","penaltyFor","extra","count","id","gradeOf","score","secretProblem","isExpired","secret","now","staleness","stalenessOf","daysSince","lastChangedAt","emptyBucket","buildHealthReport","buckets","valueCount","linksKnown","vaults","partialVaultNames","vault","problem","bucket","issues","a","b","scored","sum","issue","worst","passing","vaultHealth","counts"],"sources":["../../../../src/security/v2/model/health.ts"],"sourcesContent":["/**\n * Security health for Saved values v2 (BOFF-15820): what needs fixing in the vaults a person can\n * open, worked out from what the security service returns (values' expiry and change dates, and\n * the vaults' share links). It replaces the old dashboard score, which started at 100 and stayed\n * there with nothing to score (BOFF-15645 §7 B12): with no values there is no score at all.\n */\nimport { daysSince, isExpired, lastChangedAt, stalenessOf } from './time';\n\nexport interface HealthSecret {\n id: string;\n name: string;\n status?: string | null;\n expiresAt?: string | null;\n updatedAt?: string | null;\n lastRotatedAt?: string | null;\n createdAt?: string | null;\n}\n\nexport interface HealthVault {\n id: string;\n name: string;\n secrets: readonly HealthSecret[];\n /** How many values the vault holds; more than `secrets` means only some were checked. */\n secretsTotal?: number;\n /** Live share links on the vault; undefined while unknown (not loaded, or not allowed). */\n publicLinks?: number;\n}\n\nexport type HealthIssueId = 'expired' | 'stale-year' | 'stale' | 'public-links';\nexport type HealthTone = 'ok' | 'warn' | 'bad';\n\nexport interface HealthIssue {\n id: HealthIssueId;\n tone: Exclude<HealthTone, 'ok'>;\n /** Values (or links) affected. */\n count: number;\n vaultIds: string[];\n vaultNames: string[];\n /** Up to three of the values' names, for the sentence. */\n itemNames: string[];\n /** Points it takes off the score. */\n penalty: number;\n}\n\nexport type PassingCheckId = 'encrypted' | 'none-expired' | 'all-fresh' | 'no-public-links';\n\nexport type HealthGrade = 'none' | 'good' | 'fair' | 'weak' | 'poor';\n\nexport interface HealthReport {\n /** 0–100, or null when there is nothing to score (no vaults, or no values yet). */\n score: number | null;\n grade: HealthGrade;\n tone: HealthTone;\n /** Most urgent first. */\n issues: HealthIssue[];\n passing: PassingCheckId[];\n worst: HealthIssue | null;\n /** The score once the worst issue is fixed. */\n scoreAfterWorst: number | null;\n vaultCount: number;\n valueCount: number;\n /** Vaults with more values than were checked. */\n partialVaultNames: string[];\n /** Share links were known for every vault, so the link check ran. */\n linksKnown: boolean;\n}\n\nconst ISSUE_ORDER: Readonly<Record<HealthIssueId, number>> = {\n expired: 0,\n 'stale-year': 1,\n stale: 2,\n 'public-links': 3,\n};\n\n/** Points off for an issue of `count` items: a base for the first, a little for each more, a cap. */\nfunction penaltyFor(id: HealthIssueId, count: number): number {\n const extra = Math.max(0, count - 1);\n switch (id) {\n case 'expired':\n return Math.min(40, 20 + 5 * extra);\n case 'stale-year':\n return Math.min(25, 12 + 3 * extra);\n case 'stale':\n return Math.min(15, 6 + 2 * extra);\n case 'public-links':\n return Math.min(15, 8 + 2 * extra);\n }\n}\n\nexport function gradeOf(score: number | null): HealthGrade {\n if (score === null) return 'none';\n if (score >= 90) return 'good';\n if (score >= 70) return 'fair';\n if (score >= 40) return 'weak';\n return 'poor';\n}\n\n/** What is wrong with one value, if anything: expired wins over old. */\nexport function secretProblem(\n secret: HealthSecret,\n now: Date\n): Extract<HealthIssueId, 'expired' | 'stale-year' | 'stale'> | null {\n if (isExpired(secret, now)) return 'expired';\n const staleness = stalenessOf(daysSince(lastChangedAt(secret), now));\n if (staleness === 'bad') return 'stale-year';\n if (staleness === 'warn') return 'stale';\n return null;\n}\n\ninterface Bucket {\n count: number;\n vaults: Map<string, string>;\n items: string[];\n}\n\nfunction emptyBucket(): Bucket {\n return { count: 0, vaults: new Map(), items: [] };\n}\n\nexport function buildHealthReport(vaults: readonly HealthVault[], now: Date): HealthReport {\n const buckets: Record<HealthIssueId, Bucket> = {\n expired: emptyBucket(),\n 'stale-year': emptyBucket(),\n stale: emptyBucket(),\n 'public-links': emptyBucket(),\n };\n let valueCount = 0;\n let linksKnown = vaults.length > 0;\n const partialVaultNames: string[] = [];\n\n for (const vault of vaults) {\n valueCount += Math.max(vault.secretsTotal ?? 0, vault.secrets.length);\n if ((vault.secretsTotal ?? 0) > vault.secrets.length) partialVaultNames.push(vault.name);\n for (const secret of vault.secrets) {\n const problem = secretProblem(secret, now);\n if (!problem) continue;\n const bucket = buckets[problem];\n bucket.count += 1;\n bucket.vaults.set(vault.id, vault.name);\n if (bucket.items.length < 3) bucket.items.push(secret.name);\n }\n if (vault.publicLinks === undefined) {\n linksKnown = false;\n } else if (vault.publicLinks > 0) {\n const bucket = buckets['public-links'];\n bucket.count += vault.publicLinks;\n bucket.vaults.set(vault.id, vault.name);\n }\n }\n\n const issues: HealthIssue[] = (Object.keys(buckets) as HealthIssueId[])\n .filter((id) => buckets[id].count > 0)\n .map((id) => ({\n id,\n tone: id === 'expired' || id === 'stale-year' ? ('bad' as const) : ('warn' as const),\n count: buckets[id].count,\n vaultIds: [...buckets[id].vaults.keys()],\n vaultNames: [...buckets[id].vaults.values()],\n itemNames: buckets[id].items,\n penalty: penaltyFor(id, buckets[id].count),\n }))\n .sort((a, b) => ISSUE_ORDER[a.id] - ISSUE_ORDER[b.id]);\n\n const scored = vaults.length > 0 && valueCount > 0;\n const score = scored\n ? Math.max(0, 100 - issues.reduce((sum, issue) => sum + issue.penalty, 0))\n : null;\n const worst = issues[0] ?? null;\n const passing: PassingCheckId[] = scored ? ['encrypted'] : [];\n if (scored && !buckets.expired.count) passing.push('none-expired');\n if (scored && !buckets.stale.count && !buckets['stale-year'].count) passing.push('all-fresh');\n if (scored && linksKnown && !buckets['public-links'].count) passing.push('no-public-links');\n\n return {\n score,\n grade: gradeOf(score),\n tone: issues.some((issue) => issue.tone === 'bad') ? 'bad' : issues.length ? 'warn' : 'ok',\n issues,\n passing,\n worst,\n scoreAfterWorst: score !== null && worst ? Math.min(100, score + worst.penalty) : score,\n vaultCount: vaults.length,\n valueCount,\n partialVaultNames,\n linksKnown,\n };\n}\n\nexport type VaultHealthReason =\n { id: 'expired' | 'stale-year' | 'stale'; count: number } | { id: 'public-links'; count: number };\n\nexport interface VaultHealth {\n tone: HealthTone;\n /** The most urgent reason, for the card's message line. */\n reason: VaultHealthReason | null;\n}\n\n/** One vault's card tone and the reason it needs a look. */\nexport function vaultHealth(vault: HealthVault, now: Date): VaultHealth {\n const counts = { expired: 0, 'stale-year': 0, stale: 0 };\n for (const secret of vault.secrets) {\n const problem = secretProblem(secret, now);\n if (problem) counts[problem] += 1;\n }\n if (counts.expired) return { tone: 'bad', reason: { id: 'expired', count: counts.expired } };\n if (counts['stale-year'])\n return { tone: 'bad', reason: { id: 'stale-year', count: counts['stale-year'] } };\n if (counts.stale) return { tone: 'warn', reason: { id: 'stale', count: counts.stale } };\n if (vault.publicLinks)\n return { tone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
2
|
+
* Saved values v2 keeps its tabs and dialogs in the address (BOFF-15820, plan §5.4), so the old
|
|
3
|
+
* sub-row links, bookmarks, notifications, Ctrl K and the assistant still land in the right place:
|
|
4
|
+
*
|
|
5
|
+
* /security/shared-with-me → /security?tab=shared
|
|
6
|
+
* /security/import → /security?dialog=import-export
|
|
7
|
+
* /security/dashboard → /security?dialog=health
|
|
8
|
+
* /security/access-review → /security?dialog=review
|
|
9
|
+
*
|
|
10
|
+
* The old landing's `?tab=` values (the tabbed landing before BOFF-11871) are honoured too.
|
|
11
|
+
*/
|
|
12
|
+
export declare const TAB_PARAM = "tab";
|
|
13
|
+
export declare const DIALOG_PARAM = "dialog";
|
|
14
|
+
export type SavedValuesTab = 'vaults' | 'shared';
|
|
15
|
+
export type SavedValuesDialog = 'import-export' | 'health' | 'review';
|
|
16
|
+
export type VaultTab = 'values' | 'access' | 'activity';
|
|
17
|
+
export declare function savedValuesTabFrom(params: URLSearchParams): SavedValuesTab;
|
|
18
|
+
export declare function savedValuesDialogFrom(params: URLSearchParams): SavedValuesDialog | null;
|
|
19
|
+
export declare function vaultTabFrom(params: URLSearchParams): VaultTab;
|
|
20
|
+
/** The address with `key` set (or removed with `null`, or with the default value). */
|
|
21
|
+
export declare function withParam(params: URLSearchParams, key: string, value: string | null, defaultValue?: string): URLSearchParams;
|
|
22
|
+
/**
|
|
23
|
+
* Where an old landing `?tab=` value goes now: a tab or dialog of this page, the audit log page,
|
|
24
|
+
* or the providers page (only while its preview flag is on). Null: nothing to do.
|
|
25
|
+
*/
|
|
26
|
+
export type LegacyTabTarget = {
|
|
27
|
+
kind: 'params';
|
|
28
|
+
tab?: SavedValuesTab;
|
|
29
|
+
dialog?: SavedValuesDialog;
|
|
30
|
+
} | {
|
|
31
|
+
kind: 'route';
|
|
32
|
+
path: string;
|
|
33
|
+
};
|
|
34
|
+
export declare function legacyLandingTarget(tab: string | null, providersEnabled: boolean): LegacyTabTarget | null;
|
|
35
|
+
/** The address after a legacy target that stays on this page: the old `tab` value replaced. */
|
|
36
|
+
export declare function applyLegacyParams(params: URLSearchParams, target: Extract<LegacyTabTarget, {
|
|
37
|
+
kind: 'params';
|
|
38
|
+
}>): URLSearchParams;
|
|
39
|
+
/** `basePath` joined with a path under it, without doubled or missing slashes. */
|
|
40
|
+
export declare function joinPath(basePath: string | undefined, path?: string): string;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var e = "dialog", t = [
|
|
2
|
+
"import-export",
|
|
3
|
+
"health",
|
|
4
|
+
"review"
|
|
5
|
+
], n = [
|
|
6
|
+
"values",
|
|
7
|
+
"access",
|
|
8
|
+
"activity"
|
|
9
|
+
];
|
|
10
|
+
function r(e) {
|
|
11
|
+
return e.get("tab") === "shared" ? "shared" : "vaults";
|
|
12
|
+
}
|
|
13
|
+
function i(n) {
|
|
14
|
+
let r = n.get(e);
|
|
15
|
+
return t.find((e) => e === r) ?? null;
|
|
16
|
+
}
|
|
17
|
+
function a(e) {
|
|
18
|
+
let t = e.get("tab");
|
|
19
|
+
return n.find((e) => e === t) ?? "values";
|
|
20
|
+
}
|
|
21
|
+
function o(e, t, n, r) {
|
|
22
|
+
let i = new URLSearchParams(e);
|
|
23
|
+
return n === null || n === r ? i.delete(t) : i.set(t, n), i;
|
|
24
|
+
}
|
|
25
|
+
function s(e, t) {
|
|
26
|
+
switch (e) {
|
|
27
|
+
case "shared-with-me": return {
|
|
28
|
+
kind: "params",
|
|
29
|
+
tab: "shared"
|
|
30
|
+
};
|
|
31
|
+
case "import":
|
|
32
|
+
case "import-export": return {
|
|
33
|
+
kind: "params",
|
|
34
|
+
dialog: "import-export"
|
|
35
|
+
};
|
|
36
|
+
case "dashboard": return {
|
|
37
|
+
kind: "params",
|
|
38
|
+
dialog: "health"
|
|
39
|
+
};
|
|
40
|
+
case "access-review": return {
|
|
41
|
+
kind: "params",
|
|
42
|
+
dialog: "review"
|
|
43
|
+
};
|
|
44
|
+
case "audit": return {
|
|
45
|
+
kind: "route",
|
|
46
|
+
path: "audit"
|
|
47
|
+
};
|
|
48
|
+
case "providers": return t ? {
|
|
49
|
+
kind: "route",
|
|
50
|
+
path: "providers"
|
|
51
|
+
} : { kind: "params" };
|
|
52
|
+
default: return null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function c(t, n) {
|
|
56
|
+
let r = new URLSearchParams(t);
|
|
57
|
+
return r.delete("tab"), n.tab && n.tab !== "vaults" && r.set("tab", n.tab), n.dialog && r.set(e, n.dialog), r;
|
|
58
|
+
}
|
|
59
|
+
function l(e, t = "") {
|
|
60
|
+
let n = (e ?? "").replace(/\/+$/, ""), r = t.replace(/^\/+/, "");
|
|
61
|
+
return r ? `${n}/${r}` : n || "/";
|
|
62
|
+
}
|
|
63
|
+
export { e as DIALOG_PARAM, c as applyLegacyParams, l as joinPath, s as legacyLandingTarget, i as savedValuesDialogFrom, r as savedValuesTabFrom, a as vaultTabFrom, o as withParam };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=params.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"params.js","names":["DIALOG_PARAM","DIALOGS","VAULT_TABS","savedValuesTabFrom","params","savedValuesDialogFrom","value","dialog","vaultTabFrom","tab","withParam","next","defaultValue","key","legacyLandingTarget","providersEnabled","applyLegacyParams","target","joinPath","base","basePath","rest","path"],"sources":["../../../../src/security/v2/model/params.ts"],"sourcesContent":["/**\n * Saved values v2 keeps its tabs and dialogs in the address (BOFF-15820, plan §5.4), so the old\n * sub-row links, bookmarks, notifications, Ctrl K and the assistant still land in the right place:\n *\n * /security/shared-with-me → /security?tab=shared\n * /security/import → /security?dialog=import-export\n * /security/dashboard → /security?dialog=health\n * /security/access-review → /security?dialog=review\n *\n * The old landing's `?tab=` values (the tabbed landing before BOFF-11871) are honoured too.\n */\n\nexport const TAB_PARAM = 'tab';\nexport const DIALOG_PARAM = 'dialog';\n\nexport type SavedValuesTab = 'vaults' | 'shared';\nexport type SavedValuesDialog = 'import-export' | 'health' | 'review';\nexport type VaultTab = 'values' | 'access' | 'activity';\n\nconst DIALOGS: readonly SavedValuesDialog[] = ['import-export', 'health', 'review'];\nconst VAULT_TABS: readonly VaultTab[] = ['values', 'access', 'activity'];\n\nexport function savedValuesTabFrom(params: URLSearchParams): SavedValuesTab {\n return params.get(TAB_PARAM) === 'shared' ? 'shared' : 'vaults';\n}\n\nexport function savedValuesDialogFrom(params: URLSearchParams): SavedValuesDialog | null {\n const value = params.get(DIALOG_PARAM);\n return DIALOGS.find((dialog) => dialog === value) ?? null;\n}\n\nexport function vaultTabFrom(params: URLSearchParams): VaultTab {\n const value = params.get(TAB_PARAM);\n return VAULT_TABS.find((tab) => tab === value) ?? 'values';\n}\n\n/** The address with `key` set (or removed with `null`, or with the default value). */\nexport function withParam(\n params: URLSearchParams,\n key: string,\n value: string | null,\n defaultValue?: string\n): URLSearchParams {\n const next = new URLSearchParams(params);\n if (value === null || value === defaultValue) next.delete(key);\n else next.set(key, value);\n return next;\n}\n\n/**\n * Where an old landing `?tab=` value goes now: a tab or dialog of this page, the audit log page,\n * or the providers page (only while its preview flag is on). Null: nothing to do.\n */\nexport type LegacyTabTarget =\n | { kind: 'params'; tab?: SavedValuesTab; dialog?: SavedValuesDialog }\n | { kind: 'route'; path: string };\n\nexport function legacyLandingTarget(\n tab: string | null,\n providersEnabled: boolean\n): LegacyTabTarget | null {\n switch (tab) {\n case 'shared-with-me':\n return { kind: 'params', tab: 'shared' };\n case 'import':\n case 'import-export':\n return { kind: 'params', dialog: 'import-export' };\n case 'dashboard':\n return { kind: 'params', dialog: 'health' };\n case 'access-review':\n return { kind: 'params', dialog: 'review' };\n case 'audit':\n return { kind: 'route', path: 'audit' };\n case 'providers':\n return providersEnabled ? { kind: 'route', path: 'providers' } : { kind: 'params' };\n default:\n return null;\n }\n}\n\n/** The address after a legacy target that stays on this page: the old `tab` value replaced. */\nexport function applyLegacyParams(\n params: URLSearchParams,\n target: Extract<LegacyTabTarget, { kind: 'params' }>\n): URLSearchParams {\n const next = new URLSearchParams(params);\n next.delete(TAB_PARAM);\n if (target.tab && target.tab !== 'vaults') next.set(TAB_PARAM, target.tab);\n if (target.dialog) next.set(DIALOG_PARAM, target.dialog);\n return next;\n}\n\n/** `basePath` joined with a path under it, without doubled or missing slashes. */\nexport function joinPath(basePath: string | undefined, path = ''): string {\n const base = (basePath ?? '').replace(/\\/+$/, '');\n const rest = path.replace(/^\\/+/, '');\n if (!rest) return base || '/';\n return `${base}/${rest}`;\n}\n"],"mappings":"AAaA,IAAaA,IAAe,UAMtBC,IAAwC;CAAC;CAAiB;CAAU;AAAQ,GAC5EC,IAAkC;CAAC;CAAU;CAAU;AAAU;AAEvE,SAAgBC,EAAmB,GAAyC;CAC1E,OAAOC,EAAO,IAAA,KAAa,MAAM,WAAW,WAAW;AACzD;AAEA,SAAgBC,EAAsB,GAAmD;CACvF,IAAMC,IAAQF,EAAO,IAAIJ,CAAY;CACrC,OAAOC,EAAQ,MAAM,MAAWM,MAAWD,CAAK,KAAK;AACvD;AAEA,SAAgBE,EAAa,GAAmC;CAC9D,IAAMF,IAAQF,EAAO,IAAA,KAAa;CAClC,OAAOF,EAAW,MAAM,MAAQO,MAAQH,CAAK,KAAK;AACpD;AAGA,SAAgBI,EACd,GACA,GACA,GACA,GACiB;CACjB,IAAMC,IAAO,IAAI,gBAAgBP,CAAM;CAGvC,OAFIE,MAAU,QAAQA,MAAUM,IAAcD,EAAK,OAAOE,CAAG,IACxDF,EAAK,IAAIE,GAAKP,CAAK,GACjBK;AACT;AAUA,SAAgBG,EACd,GACA,GACwB;CACxB,QAAQL,GAAR;EACE,KAAK,kBACH,OAAO;GAAE,MAAM;GAAU,KAAK;EAAS;EACzC,KAAK;EACL,KAAK,iBACH,OAAO;GAAE,MAAM;GAAU,QAAQ;EAAgB;EACnD,KAAK,aACH,OAAO;GAAE,MAAM;GAAU,QAAQ;EAAS;EAC5C,KAAK,iBACH,OAAO;GAAE,MAAM;GAAU,QAAQ;EAAS;EAC5C,KAAK,SACH,OAAO;GAAE,MAAM;GAAS,MAAM;EAAQ;EACxC,KAAK,aACH,OAAOM,IAAmB;GAAE,MAAM;GAAS,MAAM;EAAY,IAAI,EAAE,MAAM,SAAS;EACpF,SACE,OAAO;CACX;AACF;AAGA,SAAgBC,EACd,GACA,GACiB;CACjB,IAAML,IAAO,IAAI,gBAAgBP,CAAM;CAIvC,OAHAO,EAAK,OAAA,KAAgB,GACjBM,EAAO,OAAOA,EAAO,QAAQ,YAAUN,EAAK,IAAA,OAAeM,EAAO,GAAG,GACrEA,EAAO,UAAQN,EAAK,IAAIX,GAAciB,EAAO,MAAM,GAChDN;AACT;AAGA,SAAgBO,EAAS,GAA8B,IAAO,IAAY;CACxE,IAAMC,KAAQC,KAAY,GAAA,CAAI,QAAQ,QAAQ,EAAE,GAC1CC,IAAOC,EAAK,QAAQ,QAAQ,EAAE;CAEpC,OADKD,IACE,GAAGF,EAAK,GAAGE,MADAF,KAAQ;AAE5B"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export type ReviewRole = 'VIEWER' | 'EDITOR' | 'ADMIN';
|
|
2
|
+
export interface ReviewMemberInput {
|
|
3
|
+
id: string;
|
|
4
|
+
actorId: string;
|
|
5
|
+
actorType: string;
|
|
6
|
+
role: string;
|
|
7
|
+
createdAt?: string | null;
|
|
8
|
+
expiresAt?: string | null;
|
|
9
|
+
}
|
|
10
|
+
export interface ReviewShareInput {
|
|
11
|
+
id: string;
|
|
12
|
+
kind: string;
|
|
13
|
+
status: string;
|
|
14
|
+
actorId?: string | null;
|
|
15
|
+
actorType?: string | null;
|
|
16
|
+
role: string;
|
|
17
|
+
scope: string;
|
|
18
|
+
createdAt?: string | null;
|
|
19
|
+
expiresAt?: string | null;
|
|
20
|
+
lastAccessedAt?: string | null;
|
|
21
|
+
}
|
|
22
|
+
export interface ReviewVaultInput {
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
createdBy?: string | null;
|
|
26
|
+
members: readonly ReviewMemberInput[];
|
|
27
|
+
/** Undefined while the vault's shares are not known. */
|
|
28
|
+
shares?: readonly ReviewShareInput[];
|
|
29
|
+
}
|
|
30
|
+
/** Why a row is there, in the words the chip says. */
|
|
31
|
+
export type ReviewReason = {
|
|
32
|
+
id: 'never-opened';
|
|
33
|
+
days: number;
|
|
34
|
+
} | {
|
|
35
|
+
id: 'not-opened';
|
|
36
|
+
days: number;
|
|
37
|
+
} | {
|
|
38
|
+
id: 'manager';
|
|
39
|
+
} | {
|
|
40
|
+
id: 'ends-soon';
|
|
41
|
+
days: number;
|
|
42
|
+
} | {
|
|
43
|
+
id: 'opened-recently';
|
|
44
|
+
days: number;
|
|
45
|
+
} | {
|
|
46
|
+
id: 'added-recently';
|
|
47
|
+
days: number;
|
|
48
|
+
} | {
|
|
49
|
+
id: 'member';
|
|
50
|
+
};
|
|
51
|
+
export type ReviewSuggestion = 'remove' | 'check' | 'keep';
|
|
52
|
+
export type ReviewDecision = 'keep' | 'remove';
|
|
53
|
+
export interface ReviewRow {
|
|
54
|
+
/** `member:<vault>:<actor>` or `share:<id>`. */
|
|
55
|
+
id: string;
|
|
56
|
+
kind: 'member' | 'share';
|
|
57
|
+
vaultId: string;
|
|
58
|
+
vaultName: string;
|
|
59
|
+
actorId: string;
|
|
60
|
+
actorType: string;
|
|
61
|
+
role: ReviewRole;
|
|
62
|
+
/** A share of one value, not the whole vault. */
|
|
63
|
+
oneValue: boolean;
|
|
64
|
+
since: string | null;
|
|
65
|
+
lastOpened: string | null;
|
|
66
|
+
expiresAt: string | null;
|
|
67
|
+
suggestion: ReviewSuggestion;
|
|
68
|
+
reason: ReviewReason;
|
|
69
|
+
/** The share to revoke (shares only). */
|
|
70
|
+
shareId?: string;
|
|
71
|
+
}
|
|
72
|
+
/** A share nobody opened for this long is suggested for removal … */
|
|
73
|
+
export declare const NEVER_OPENED_DAYS = 30;
|
|
74
|
+
/** … and so is one not opened for this long. */
|
|
75
|
+
export declare const NOT_OPENED_DAYS = 90;
|
|
76
|
+
/** An end date this close is mentioned. */
|
|
77
|
+
export declare const ENDS_SOON_DAYS = 14;
|
|
78
|
+
export declare function reasonFor(input: {
|
|
79
|
+
kind: 'member' | 'share';
|
|
80
|
+
role: ReviewRole;
|
|
81
|
+
since: string | null;
|
|
82
|
+
lastOpened: string | null;
|
|
83
|
+
expiresAt: string | null;
|
|
84
|
+
}, now: Date): {
|
|
85
|
+
suggestion: ReviewSuggestion;
|
|
86
|
+
reason: ReviewReason;
|
|
87
|
+
};
|
|
88
|
+
/** Every access to review, removals first, then by vault. */
|
|
89
|
+
export declare function buildReviewRows(vaults: readonly ReviewVaultInput[], reviewerId: string | null | undefined, now: Date): ReviewRow[];
|
|
90
|
+
export interface ReviewProgress {
|
|
91
|
+
decided: number;
|
|
92
|
+
total: number;
|
|
93
|
+
toRemove: ReviewRow[];
|
|
94
|
+
}
|
|
95
|
+
export declare function reviewProgress(rows: readonly ReviewRow[], decisions: Readonly<Record<string, ReviewDecision>>): ReviewProgress;
|
|
96
|
+
/** The rows still to decide, or the decided ones. */
|
|
97
|
+
export declare function rowsFor(rows: readonly ReviewRow[], decisions: Readonly<Record<string, ReviewDecision>>, tab: 'todo' | 'done'): ReviewRow[];
|
|
98
|
+
/** Decisions for rows that are still there (a refetch can drop rows). */
|
|
99
|
+
export declare function pruneDecisions(rows: readonly ReviewRow[], decisions: Readonly<Record<string, ReviewDecision>>): Record<string, ReviewDecision>;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { daysSince as e, daysUntil as t } from "./time.js";
|
|
2
|
+
function n(e) {
|
|
3
|
+
return e === "ADMIN" || e === "EDITOR" ? e : "VIEWER";
|
|
4
|
+
}
|
|
5
|
+
function r(e, n) {
|
|
6
|
+
if (e.kind !== "ACCOUNT" || e.status !== "ACTIVE" || !e.actorId) return !1;
|
|
7
|
+
let r = t(e.expiresAt, n);
|
|
8
|
+
return r === null || r > 0;
|
|
9
|
+
}
|
|
10
|
+
function i(n, r) {
|
|
11
|
+
if (n.kind === "share") {
|
|
12
|
+
let t = e(n.lastOpened, r), i = e(n.since, r) ?? 0;
|
|
13
|
+
if (t === null && i >= 30) return {
|
|
14
|
+
suggestion: "remove",
|
|
15
|
+
reason: {
|
|
16
|
+
id: "never-opened",
|
|
17
|
+
days: i
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
if (t !== null && t >= 90) return {
|
|
21
|
+
suggestion: "remove",
|
|
22
|
+
reason: {
|
|
23
|
+
id: "not-opened",
|
|
24
|
+
days: t
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
if (n.role === "ADMIN") return {
|
|
29
|
+
suggestion: "check",
|
|
30
|
+
reason: { id: "manager" }
|
|
31
|
+
};
|
|
32
|
+
let i = t(n.expiresAt, r);
|
|
33
|
+
if (i !== null && i > 0 && i <= 14) return {
|
|
34
|
+
suggestion: "keep",
|
|
35
|
+
reason: {
|
|
36
|
+
id: "ends-soon",
|
|
37
|
+
days: i
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
if (n.kind === "share") {
|
|
41
|
+
let t = e(n.lastOpened, r);
|
|
42
|
+
if (t !== null) return {
|
|
43
|
+
suggestion: "keep",
|
|
44
|
+
reason: {
|
|
45
|
+
id: "opened-recently",
|
|
46
|
+
days: t
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
let a = e(n.since, r);
|
|
51
|
+
return a !== null && a < 30 ? {
|
|
52
|
+
suggestion: "keep",
|
|
53
|
+
reason: {
|
|
54
|
+
id: "added-recently",
|
|
55
|
+
days: a
|
|
56
|
+
}
|
|
57
|
+
} : {
|
|
58
|
+
suggestion: "keep",
|
|
59
|
+
reason: { id: "member" }
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
var a = {
|
|
63
|
+
remove: 0,
|
|
64
|
+
check: 1,
|
|
65
|
+
keep: 2
|
|
66
|
+
};
|
|
67
|
+
function o(e, o, s) {
|
|
68
|
+
let c = [];
|
|
69
|
+
for (let a of e) {
|
|
70
|
+
for (let e of a.members) {
|
|
71
|
+
if (e.actorId === a.createdBy || e.actorId === o) continue;
|
|
72
|
+
let r = t(e.expiresAt, s);
|
|
73
|
+
if (r !== null && r <= 0) continue;
|
|
74
|
+
let l = n(e.role), u = e.createdAt ?? null, d = e.expiresAt ?? null;
|
|
75
|
+
c.push({
|
|
76
|
+
id: `member:${a.id}:${e.actorId}`,
|
|
77
|
+
kind: "member",
|
|
78
|
+
vaultId: a.id,
|
|
79
|
+
vaultName: a.name,
|
|
80
|
+
actorId: e.actorId,
|
|
81
|
+
actorType: (e.actorType || "user").toLowerCase(),
|
|
82
|
+
role: l,
|
|
83
|
+
oneValue: !1,
|
|
84
|
+
since: u,
|
|
85
|
+
lastOpened: null,
|
|
86
|
+
expiresAt: d,
|
|
87
|
+
...i({
|
|
88
|
+
kind: "member",
|
|
89
|
+
role: l,
|
|
90
|
+
since: u,
|
|
91
|
+
lastOpened: null,
|
|
92
|
+
expiresAt: d
|
|
93
|
+
}, s)
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
for (let e of a.shares ?? []) {
|
|
97
|
+
if (!r(e, s) || e.actorId === o) continue;
|
|
98
|
+
let t = n(e.role), l = e.createdAt ?? null, u = e.lastAccessedAt ?? null, d = e.expiresAt ?? null;
|
|
99
|
+
c.push({
|
|
100
|
+
id: `share:${e.id}`,
|
|
101
|
+
kind: "share",
|
|
102
|
+
vaultId: a.id,
|
|
103
|
+
vaultName: a.name,
|
|
104
|
+
actorId: e.actorId ?? "",
|
|
105
|
+
actorType: (e.actorType || "user").toLowerCase(),
|
|
106
|
+
role: t,
|
|
107
|
+
oneValue: e.scope === "SECRET",
|
|
108
|
+
since: l,
|
|
109
|
+
lastOpened: u,
|
|
110
|
+
expiresAt: d,
|
|
111
|
+
shareId: e.id,
|
|
112
|
+
...i({
|
|
113
|
+
kind: "share",
|
|
114
|
+
role: t,
|
|
115
|
+
since: l,
|
|
116
|
+
lastOpened: u,
|
|
117
|
+
expiresAt: d
|
|
118
|
+
}, s)
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return c.sort((e, t) => a[e.suggestion] - a[t.suggestion] || e.vaultName.localeCompare(t.vaultName) || e.id.localeCompare(t.id));
|
|
123
|
+
}
|
|
124
|
+
function s(e, t) {
|
|
125
|
+
let n = e.filter((e) => t[e.id] === "remove");
|
|
126
|
+
return {
|
|
127
|
+
decided: e.filter((e) => t[e.id] !== void 0).length,
|
|
128
|
+
total: e.length,
|
|
129
|
+
toRemove: n
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function c(e, t, n) {
|
|
133
|
+
return e.filter((e) => n === "done" == (t[e.id] !== void 0));
|
|
134
|
+
}
|
|
135
|
+
function l(e, t) {
|
|
136
|
+
let n = new Set(e.map((e) => e.id));
|
|
137
|
+
return Object.fromEntries(Object.entries(t).filter(([e]) => n.has(e)));
|
|
138
|
+
}
|
|
139
|
+
export { o as buildReviewRows, l as pruneDecisions, i as reasonFor, s as reviewProgress, c as rowsFor };
|
|
140
|
+
|
|
141
|
+
//# sourceMappingURL=review.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review.js","names":["roleOf","value","liveShare","share","left","daysUntil","now","reasonFor","input","opened","daysSince","age","added","SUGGESTION_ORDER","buildReviewRows","rows","vault","vaults","member","reviewerId","role","since","expiresAt","lastOpened","a","b","reviewProgress","toRemove","decisions","row","rowsFor","tab","pruneDecisions","ids","id"],"sources":["../../../../src/security/v2/model/review.ts"],"sourcesContent":["/**\n * Access review for Saved values v2 (BOFF-15820): everyone who can still use each vault, with a\n * suggestion from what the service knows (when a share was last opened, how much the access\n * allows, when it ends), a Keep / Remove decision per row, and what Finish removes.\n *\n * A vault's creator always keeps access (the service grants it by `createdBy`), so creators are not\n * rows; neither is the reviewer, who could otherwise lock themselves out mid-review.\n */\nimport { daysSince, daysUntil } from './time';\n\nexport type ReviewRole = 'VIEWER' | 'EDITOR' | 'ADMIN';\n\nexport interface ReviewMemberInput {\n id: string;\n actorId: string;\n actorType: string;\n role: string;\n createdAt?: string | null;\n expiresAt?: string | null;\n}\n\nexport interface ReviewShareInput {\n id: string;\n kind: string;\n status: string;\n actorId?: string | null;\n actorType?: string | null;\n role: string;\n scope: string;\n createdAt?: string | null;\n expiresAt?: string | null;\n lastAccessedAt?: string | null;\n}\n\nexport interface ReviewVaultInput {\n id: string;\n name: string;\n createdBy?: string | null;\n members: readonly ReviewMemberInput[];\n /** Undefined while the vault's shares are not known. */\n shares?: readonly ReviewShareInput[];\n}\n\n/** Why a row is there, in the words the chip says. */\nexport type ReviewReason =\n | { id: 'never-opened'; days: number }\n | { id: 'not-opened'; days: number }\n | { id: 'manager' }\n | { id: 'ends-soon'; days: number }\n | { id: 'opened-recently'; days: number }\n | { id: 'added-recently'; days: number }\n | { id: 'member' };\n\nexport type ReviewSuggestion = 'remove' | 'check' | 'keep';\nexport type ReviewDecision = 'keep' | 'remove';\n\nexport interface ReviewRow {\n /** `member:<vault>:<actor>` or `share:<id>`. */\n id: string;\n kind: 'member' | 'share';\n vaultId: string;\n vaultName: string;\n actorId: string;\n actorType: string;\n role: ReviewRole;\n /** A share of one value, not the whole vault. */\n oneValue: boolean;\n since: string | null;\n lastOpened: string | null;\n expiresAt: string | null;\n suggestion: ReviewSuggestion;\n reason: ReviewReason;\n /** The share to revoke (shares only). */\n shareId?: string;\n}\n\n/** A share nobody opened for this long is suggested for removal … */\nexport const NEVER_OPENED_DAYS = 30;\n/** … and so is one not opened for this long. */\nexport const NOT_OPENED_DAYS = 90;\n/** An end date this close is mentioned. */\nexport const ENDS_SOON_DAYS = 14;\n\nfunction roleOf(value: string): ReviewRole {\n return value === 'ADMIN' || value === 'EDITOR' ? value : 'VIEWER';\n}\n\nfunction liveShare(share: ReviewShareInput, now: Date): boolean {\n if (share.kind !== 'ACCOUNT' || share.status !== 'ACTIVE' || !share.actorId) return false;\n const left = daysUntil(share.expiresAt, now);\n return left === null || left > 0;\n}\n\nexport function reasonFor(\n input: {\n kind: 'member' | 'share';\n role: ReviewRole;\n since: string | null;\n lastOpened: string | null;\n expiresAt: string | null;\n },\n now: Date\n): { suggestion: ReviewSuggestion; reason: ReviewReason } {\n if (input.kind === 'share') {\n const opened = daysSince(input.lastOpened, now);\n const age = daysSince(input.since, now) ?? 0;\n if (opened === null && age >= NEVER_OPENED_DAYS) {\n return { suggestion: 'remove', reason: { id: 'never-opened', days: age } };\n }\n if (opened !== null && opened >= NOT_OPENED_DAYS) {\n return { suggestion: 'remove', reason: { id: 'not-opened', days: opened } };\n }\n }\n if (input.role === 'ADMIN') return { suggestion: 'check', reason: { id: 'manager' } };\n const left = daysUntil(input.expiresAt, now);\n if (left !== null && left > 0 && left <= ENDS_SOON_DAYS) {\n return { suggestion: 'keep', reason: { id: 'ends-soon', days: left } };\n }\n if (input.kind === 'share') {\n const opened = daysSince(input.lastOpened, now);\n if (opened !== null)\n return { suggestion: 'keep', reason: { id: 'opened-recently', days: opened } };\n }\n const added = daysSince(input.since, now);\n if (added !== null && added < NEVER_OPENED_DAYS) {\n return { suggestion: 'keep', reason: { id: 'added-recently', days: added } };\n }\n return { suggestion: 'keep', reason: { id: 'member' } };\n}\n\nconst SUGGESTION_ORDER: Readonly<Record<ReviewSuggestion, number>> = {\n remove: 0,\n check: 1,\n keep: 2,\n};\n\n/** Every access to review, removals first, then by vault. */\nexport function buildReviewRows(\n vaults: readonly ReviewVaultInput[],\n reviewerId: string | null | undefined,\n now: Date\n): ReviewRow[] {\n const rows: ReviewRow[] = [];\n for (const vault of vaults) {\n for (const member of vault.members) {\n if (member.actorId === vault.createdBy || member.actorId === reviewerId) continue;\n const left = daysUntil(member.expiresAt, now);\n if (left !== null && left <= 0) continue;\n const role = roleOf(member.role);\n const since = member.createdAt ?? null;\n const expiresAt = member.expiresAt ?? null;\n rows.push({\n id: `member:${vault.id}:${member.actorId}`,\n kind: 'member',\n vaultId: vault.id,\n vaultName: vault.name,\n actorId: member.actorId,\n actorType: (member.actorType || 'user').toLowerCase(),\n role,\n oneValue: false,\n since,\n lastOpened: null,\n expiresAt,\n ...reasonFor({ kind: 'member', role, since, lastOpened: null, expiresAt }, now),\n });\n }\n for (const share of vault.shares ?? []) {\n if (!liveShare(share, now) || share.actorId === reviewerId) continue;\n const role = roleOf(share.role);\n const since = share.createdAt ?? null;\n const lastOpened = share.lastAccessedAt ?? null;\n const expiresAt = share.expiresAt ?? null;\n rows.push({\n id: `share:${share.id}`,\n kind: 'share',\n vaultId: vault.id,\n vaultName: vault.name,\n actorId: share.actorId ?? '',\n actorType: (share.actorType || 'user').toLowerCase(),\n role,\n oneValue: share.scope === 'SECRET',\n since,\n lastOpened,\n expiresAt,\n shareId: share.id,\n ...reasonFor({ kind: 'share', role, since, lastOpened, expiresAt }, now),\n });\n }\n }\n return rows.sort(\n (a, b) =>\n SUGGESTION_ORDER[a.suggestion] - SUGGESTION_ORDER[b.suggestion] ||\n a.vaultName.localeCompare(b.vaultName) ||\n a.id.localeCompare(b.id)\n );\n}\n\nexport interface ReviewProgress {\n decided: number;\n total: number;\n toRemove: ReviewRow[];\n}\n\nexport function reviewProgress(\n rows: readonly ReviewRow[],\n decisions: Readonly<Record<string, ReviewDecision>>\n): ReviewProgress {\n const toRemove = rows.filter((row) => decisions[row.id] === 'remove');\n return {\n decided: rows.filter((row) => decisions[row.id] !== undefined).length,\n total: rows.length,\n toRemove,\n };\n}\n\n/** The rows still to decide, or the decided ones. */\nexport function rowsFor(\n rows: readonly ReviewRow[],\n decisions: Readonly<Record<string, ReviewDecision>>,\n tab: 'todo' | 'done'\n): ReviewRow[] {\n return rows.filter((row) => (tab === 'done') === (decisions[row.id] !== undefined));\n}\n\n/** Decisions for rows that are still there (a refetch can drop rows). */\nexport function pruneDecisions(\n rows: readonly ReviewRow[],\n decisions: Readonly<Record<string, ReviewDecision>>\n): Record<string, ReviewDecision> {\n const ids = new Set(rows.map((row) => row.id));\n return Object.fromEntries(Object.entries(decis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M,aAAa,OAAA,CAAQ,YAAY;IACnD;IACA,UAAUA,EAAM,UAAU;IAC1B;IACA;IACA;IACA,SAASA,EAAM;IACf,GAAGI,EAAU;KAAE,MAAM;KAAS;KAAM;KAAO;KAAY;IAAU,GAAGD,CAAG;GACzE,CAAC;EACH;CACF;CACA,OAAOS,EAAK,MACT,GAAG,MACFF,EAAiBW,EAAE,cAAcX,EAAiBY,EAAE,eACpDD,EAAE,UAAU,cAAcC,EAAE,SAAS,KACrCD,EAAE,GAAG,cAAcC,EAAE,EAAE,CAC3B;AACF;AAQA,SAAgBC,EACd,GACA,GACgB;CAChB,IAAMC,IAAWZ,EAAK,QAAQ,MAAQa,EAAUC,EAAI,QAAQ,QAAQ;CACpE,OAAO;EACL,SAASd,EAAK,QAAQ,MAAQa,EAAUC,EAAI,QAAQ,KAAA,CAAS,CAAC,CAAC;EAC/D,OAAOd,EAAK;EACZ;CACF;AACF;AAGA,SAAgBe,EACd,GACA,GACA,GACa;CACb,OAAOf,EAAK,QAAQ,MAASgB,MAAQ,WAAaH,EAAUC,EAAI,QAAQ,KAAA,EAAU;AACpF;AAGA,SAAgBG,EACd,GACA,GACgC;CAChC,IAAMC,IAAM,IAAI,IAAIlB,EAAK,KAAK,MAAQc,EAAI,EAAE,CAAC;CAC7C,OAAO,OAAO,YAAY,OAAO,QAAQD,CAAS,CAAC,CAAC,QAAQ,CAACM,OAAQD,EAAI,IAAIC,CAAE,CAAC,CAAC;AACnF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface SharedInput {
|
|
2
|
+
id: string;
|
|
3
|
+
vaultId: string;
|
|
4
|
+
secretId?: string | null;
|
|
5
|
+
scope: string;
|
|
6
|
+
role: string;
|
|
7
|
+
label?: string | null;
|
|
8
|
+
expiresAt?: string | null;
|
|
9
|
+
createdAt?: string | null;
|
|
10
|
+
createdBy?: string | null;
|
|
11
|
+
}
|
|
12
|
+
export type SharedKind = 'vault' | 'value';
|
|
13
|
+
export type SharedEnds = {
|
|
14
|
+
id: 'never';
|
|
15
|
+
} | {
|
|
16
|
+
id: 'soon';
|
|
17
|
+
days: number;
|
|
18
|
+
} | {
|
|
19
|
+
id: 'later';
|
|
20
|
+
date: string;
|
|
21
|
+
} | {
|
|
22
|
+
id: 'ended';
|
|
23
|
+
};
|
|
24
|
+
export interface SharedRow {
|
|
25
|
+
id: string;
|
|
26
|
+
kind: SharedKind;
|
|
27
|
+
/** The sharer's label, if they gave one. */
|
|
28
|
+
label: string | null;
|
|
29
|
+
canEdit: boolean;
|
|
30
|
+
ends: SharedEnds;
|
|
31
|
+
sharedAt: string | null;
|
|
32
|
+
sharedBy: string | null;
|
|
33
|
+
vaultId: string;
|
|
34
|
+
}
|
|
35
|
+
/** An end this close shows as a warning. */
|
|
36
|
+
export declare const SHARE_ENDS_SOON_DAYS = 7;
|
|
37
|
+
export declare function sharedEnds(expiresAt: string | null | undefined, now: Date): SharedEnds;
|
|
38
|
+
export declare function toSharedRow(share: SharedInput, now: Date): SharedRow;
|
|
39
|
+
/** The search text of a row: its label and kind words, in the page's language. */
|
|
40
|
+
export declare function sharedSearchText(row: SharedRow, kindWord: string): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { daysUntil as e } from "./time.js";
|
|
2
|
+
function t(t, n) {
|
|
3
|
+
let r = e(t, n);
|
|
4
|
+
return r === null || !t ? { id: "never" } : r <= 0 ? { id: "ended" } : r <= 7 ? {
|
|
5
|
+
id: "soon",
|
|
6
|
+
days: r
|
|
7
|
+
} : {
|
|
8
|
+
id: "later",
|
|
9
|
+
date: t
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function n(e, n) {
|
|
13
|
+
return {
|
|
14
|
+
id: e.id,
|
|
15
|
+
kind: e.scope === "VAULT" || !e.secretId ? "vault" : "value",
|
|
16
|
+
label: e.label?.trim() ? e.label.trim() : null,
|
|
17
|
+
canEdit: e.role === "EDITOR" || e.role === "ADMIN",
|
|
18
|
+
ends: t(e.expiresAt, n),
|
|
19
|
+
sharedAt: e.createdAt ?? null,
|
|
20
|
+
sharedBy: e.createdBy ?? null,
|
|
21
|
+
vaultId: e.vaultId
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export { t as sharedEnds, n as toSharedRow };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=shared.js.map
|