@coffre/ui 0.6.1 → 0.7.0
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/chunks/{audit-sentence-CUUMshIp.js → audit-sentence-C1_gRxWW.js} +91 -26
- package/dist/chunks/audit-sentence-C1_gRxWW.js.map +1 -0
- package/dist/chunks/{connected-apps-DTpatjge.js → connected-apps-Bn5rEoV2.js} +4 -4
- package/dist/chunks/{connected-apps-DTpatjge.js.map → connected-apps-Bn5rEoV2.js.map} +1 -1
- package/dist/chunks/{delete-place-SOOYVt6A.js → delete-place-CQCDHkne.js} +4 -4
- package/dist/chunks/{delete-place-SOOYVt6A.js.map → delete-place-CQCDHkne.js.map} +1 -1
- package/dist/chunks/{directory-DrtdKny2.js → directory-BQNOdze_.js} +22 -19
- package/dist/chunks/directory-BQNOdze_.js.map +1 -0
- package/dist/chunks/{folders-hR2Lnk0k.js → folders-Dw240WMJ.js} +2 -2
- package/dist/chunks/{folders-hR2Lnk0k.js.map → folders-Dw240WMJ.js.map} +1 -1
- package/dist/chunks/{grants-DDBui9YD.js → grants-CJIBrkod.js} +5 -5
- package/dist/chunks/{grants-DDBui9YD.js.map → grants-CJIBrkod.js.map} +1 -1
- package/dist/chunks/multi-combobox-CsIXihuc.js +99 -0
- package/dist/chunks/multi-combobox-CsIXihuc.js.map +1 -0
- package/dist/chunks/{offboarding-C7ECW5o0.js → offboarding-CrgwaetA.js} +4 -4
- package/dist/chunks/offboarding-CrgwaetA.js.map +1 -0
- package/dist/chunks/personal-tokens-B8rkT-DI.js +138 -0
- package/dist/chunks/personal-tokens-B8rkT-DI.js.map +1 -0
- package/dist/chunks/{principal-page-CB6dAABC.js → principal-page-DDmmV1KQ.js} +37 -27
- package/dist/chunks/principal-page-DDmmV1KQ.js.map +1 -0
- package/dist/chunks/{project-page-BHNUvr2L.js → project-page-BI--vjt3.js} +2 -2
- package/dist/chunks/{project-page-BHNUvr2L.js.map → project-page-BI--vjt3.js.map} +1 -1
- package/dist/chunks/{queries-DgQo3mC-.js → queries-epz4MIuW.js} +103 -18
- package/dist/chunks/queries-epz4MIuW.js.map +1 -0
- package/dist/chunks/{references-BQc35Q9g.js → references-DImfw0cz.js} +4 -4
- package/dist/chunks/{references-BQc35Q9g.js.map → references-DImfw0cz.js.map} +1 -1
- package/dist/chunks/{role-field-BfWRCqzl.js → role-field-C1KhNaIR.js} +2 -2
- package/dist/chunks/{role-field-BfWRCqzl.js.map → role-field-C1KhNaIR.js.map} +1 -1
- package/dist/chunks/{row-state-Zf3kZVhd.js → row-state-BsIHspy4.js} +2 -2
- package/dist/chunks/{row-state-Zf3kZVhd.js.map → row-state-BsIHspy4.js.map} +1 -1
- package/dist/chunks/{theme-B6-V9JvY.js → theme-3b4DnCow.js} +2 -2
- package/dist/chunks/{theme-B6-V9JvY.js.map → theme-3b4DnCow.js.map} +1 -1
- package/dist/chunks/{ui-Br-dNUTc.js → ui-2kwXXfrX.js} +95 -22
- package/dist/chunks/ui-2kwXXfrX.js.map +1 -0
- package/dist/chunks/{use-action-DthL5hL8.js → use-action-BB-RcHo1.js} +2 -2
- package/dist/chunks/{use-action-DthL5hL8.js.map → use-action-BB-RcHo1.js.map} +1 -1
- package/dist/chunks/{use-change-By4cG8bT.js → use-change-CQyDpCqw.js} +323 -31
- package/dist/chunks/use-change-CQyDpCqw.js.map +1 -0
- package/dist/chunks/{use-shell-D6kjSPls.js → use-shell-C_NmvCt_.js} +2 -2
- package/dist/chunks/{use-shell-D6kjSPls.js.map → use-shell-C_NmvCt_.js.map} +1 -1
- package/dist/index.d.ts +46 -164
- package/dist/index.js +143 -129
- package/dist/index.js.map +1 -1
- package/dist/pages/account.d.ts +1 -1
- package/dist/pages/account.js +29 -12
- package/dist/pages/account.js.map +1 -1
- package/dist/pages/approval.js +1 -1
- package/dist/pages/audit.js +96 -90
- package/dist/pages/audit.js.map +1 -1
- package/dist/pages/device-login.js +1 -1
- package/dist/pages/environment.js +949 -412
- package/dist/pages/environment.js.map +1 -1
- package/dist/pages/login.js +2 -2
- package/dist/pages/oauth-authorize.js +1 -1
- package/dist/pages/project-access.js +9 -9
- package/dist/pages/project-access.js.map +1 -1
- package/dist/pages/project-environments.js +112 -64
- package/dist/pages/project-environments.js.map +1 -1
- package/dist/pages/project-settings.d.ts +1 -1
- package/dist/pages/project-settings.js +54 -75
- package/dist/pages/project-settings.js.map +1 -1
- package/dist/pages/project.js +3 -7
- package/dist/pages/project.js.map +1 -1
- package/dist/pages/projects.js +50 -77
- package/dist/pages/projects.js.map +1 -1
- package/dist/pages/service-account.js +284 -160
- package/dist/pages/service-account.js.map +1 -1
- package/dist/pages/service-accounts.js +4 -4
- package/dist/pages/settings.js +5 -5
- package/dist/pages/unregistered.js +1 -1
- package/dist/pages/user.js +5 -5
- package/dist/pages/users.js +4 -4
- package/package.json +3 -3
- package/src/components/actions-log.tsx +3 -2
- package/src/components/command-palette.tsx +4 -5
- package/src/components/directory.tsx +7 -14
- package/src/components/generate-value.tsx +15 -7
- package/src/components/missing.tsx +63 -67
- package/src/components/offboarding.tsx +1 -1
- package/src/components/personal-tokens.tsx +131 -0
- package/src/components/principal-page.tsx +30 -17
- package/src/components/regenerate.tsx +72 -0
- package/src/components/service-tokens.tsx +5 -14
- package/src/components/shell.tsx +79 -75
- package/src/components/trusted-workloads.tsx +179 -19
- package/src/components/ui.tsx +35 -25
- package/src/lib/audit-sentences.ts +100 -12
- package/src/lib/bindings.ts +41 -3
- package/src/lib/changes.ts +215 -29
- package/src/lib/clipboard.ts +40 -0
- package/src/lib/copy-attempts.ts +103 -0
- package/src/lib/dismissal.ts +24 -0
- package/src/lib/generate.ts +3 -146
- package/src/lib/optimistic.ts +3 -1
- package/src/lib/queries.ts +121 -17
- package/src/lib/recipes.ts +63 -0
- package/src/lib/reveal.ts +7 -1
- package/src/lib/row-reads.ts +64 -0
- package/src/lib/secret-edit-batch.ts +64 -5
- package/src/options.ts +43 -51
- package/src/pages/account.tsx +27 -5
- package/src/pages/audit.tsx +38 -31
- package/src/pages/environment.tsx +655 -121
- package/src/pages/project-access.tsx +1 -1
- package/src/pages/project-environments.tsx +92 -45
- package/src/pages/project-settings.tsx +9 -20
- package/src/pages/project.tsx +1 -5
- package/src/pages/projects.tsx +13 -28
- package/src/parity.ts +20 -4
- package/src/styles/globals.css +143 -131
- package/dist/chunks/audit-sentence-CUUMshIp.js.map +0 -1
- package/dist/chunks/directory-DrtdKny2.js.map +0 -1
- package/dist/chunks/offboarding-C7ECW5o0.js.map +0 -1
- package/dist/chunks/principal-page-CB6dAABC.js.map +0 -1
- package/dist/chunks/project-environments-lEzFHUt4.js +0 -11
- package/dist/chunks/project-environments-lEzFHUt4.js.map +0 -1
- package/dist/chunks/queries-DgQo3mC-.js.map +0 -1
- package/dist/chunks/ui-Br-dNUTc.js.map +0 -1
- package/dist/chunks/use-change-By4cG8bT.js.map +0 -1
|
@@ -1,17 +1,18 @@
|
|
|
1
|
+
import { a as listsAccess, g as managedProjects, i as keys, r as hasAppsTab, t as affects, v as queries, x as signInWays } from "./queries-epz4MIuW.js";
|
|
1
2
|
import { t as useMounted } from "./mounted-jJmqqV_n.js";
|
|
2
|
-
import { a as ErrorLine, c as Notice, i as EmptyState, l as Spinner, s as Modal, u as Timestamp } from "./ui-
|
|
3
|
+
import { a as ErrorLine, c as Notice, i as EmptyState, l as Spinner, s as Modal, u as Timestamp } from "./ui-2kwXXfrX.js";
|
|
3
4
|
import { $ as SlashCircle, E as Folder, F as Link$1, M as Key, S as Clock, W as Pencil, X as ShieldCheck, d as Tile, f as Activity, h as Archive, i as PageHeader, l as uiResult, n as ClosedDoor, ot as Users, s as memberRef, st as X, u as useCoffre } from "./page-JTORvh-N.js";
|
|
4
|
-
import { t as ItemFailure } from "./row-state-
|
|
5
|
-
import {
|
|
6
|
-
import { t as useShell } from "./use-shell-D6kjSPls.js";
|
|
5
|
+
import { t as ItemFailure } from "./row-state-BsIHspy4.js";
|
|
6
|
+
import { t as useShell } from "./use-shell-C_NmvCt_.js";
|
|
7
7
|
import { t as PageTabs } from "./tabs-BmwKfUeK.js";
|
|
8
|
-
import {
|
|
8
|
+
import { M as revokeMemberToken, U as projectAccessLabel, V as accessRows, d as directoryList, n as useChangeStatus } from "./use-change-CQyDpCqw.js";
|
|
9
9
|
import { t as PrincipalAvatar } from "./principal-DFBswTBr.js";
|
|
10
|
-
import { i as PrincipalActions, n as InstanceRole, r as KIND } from "./directory-
|
|
11
|
-
import {
|
|
12
|
-
import { t as
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
10
|
+
import { i as PrincipalActions, n as InstanceRole, r as KIND } from "./directory-BQNOdze_.js";
|
|
11
|
+
import { t as PersonalTokensCard } from "./personal-tokens-B8rkT-DI.js";
|
|
12
|
+
import { a as lines, i as describe, t as Sentence } from "./audit-sentence-C1_gRxWW.js";
|
|
13
|
+
import { t as useAction } from "./use-action-BB-RcHo1.js";
|
|
14
|
+
import { n as GrantsTable, t as GrantRowView } from "./grants-CJIBrkod.js";
|
|
15
|
+
import { r as RemovedNotice, t as PrincipalReportCards } from "./offboarding-CrgwaetA.js";
|
|
15
16
|
import { useState } from "react";
|
|
16
17
|
import { Link, Outlet } from "@tanstack/react-router";
|
|
17
18
|
import { toast } from "sonner";
|
|
@@ -40,7 +41,7 @@ function ActionsLog({ member }) {
|
|
|
40
41
|
limit: PAGE_SIZE,
|
|
41
42
|
before: pageParam
|
|
42
43
|
})),
|
|
43
|
-
getNextPageParam: (page) => page.ok && page.entries.length
|
|
44
|
+
getNextPageParam: (page) => page.ok && page.more && page.entries.length > 0 ? page.entries.at(-1).seq : void 0
|
|
44
45
|
});
|
|
45
46
|
if (log.isPending) return /* @__PURE__ */ jsxs("p", {
|
|
46
47
|
className: "hint",
|
|
@@ -55,10 +56,7 @@ function ActionsLog({ member }) {
|
|
|
55
56
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("section", {
|
|
56
57
|
className: "card",
|
|
57
58
|
"aria-label": "Actions log",
|
|
58
|
-
children: shown.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
|
|
59
|
-
title: "Nothing done yet",
|
|
60
|
-
children: "Every read, write and change they make is listed here."
|
|
61
|
-
}) : /* @__PURE__ */ jsx("div", {
|
|
59
|
+
children: shown.length === 0 ? /* @__PURE__ */ jsx(EmptyState, { title: "Nothing yet" }) : /* @__PURE__ */ jsx("div", {
|
|
62
60
|
className: "dt-wrap",
|
|
63
61
|
children: /* @__PURE__ */ jsxs("table", {
|
|
64
62
|
className: "dt actions-log stacks stacks-inline",
|
|
@@ -544,7 +542,7 @@ function PrincipalAccess({ principalType, principalId }) {
|
|
|
544
542
|
error
|
|
545
543
|
}) : rows.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
|
|
546
544
|
title: "No project access yet",
|
|
547
|
-
children: editable.length > 0 ?
|
|
545
|
+
children: editable.length > 0 ? void 0 : `None of the projects where you manage access has a grant for this ${kind}.`
|
|
548
546
|
}) : /* @__PURE__ */ jsx(GrantsTable, {
|
|
549
547
|
lead: /* @__PURE__ */ jsxs("span", {
|
|
550
548
|
className: "th",
|
|
@@ -563,7 +561,7 @@ function PrincipalAccess({ principalType, principalId }) {
|
|
|
563
561
|
className: "cell-link",
|
|
564
562
|
to: people ? "/projects/$project/users" : "/projects/$project/service-accounts",
|
|
565
563
|
params: { project: project.slug },
|
|
566
|
-
children: project.
|
|
564
|
+
children: project.slug
|
|
567
565
|
}),
|
|
568
566
|
project.archivedAt !== null && /* @__PURE__ */ jsx("span", {
|
|
569
567
|
className: "tag tag-red",
|
|
@@ -583,14 +581,26 @@ function PrincipalAccess({ principalType, principalId }) {
|
|
|
583
581
|
offers
|
|
584
582
|
})
|
|
585
583
|
}),
|
|
586
|
-
/* @__PURE__ */ jsx("p", {
|
|
584
|
+
!(held?.managed === true && principalType === "service") && /* @__PURE__ */ jsx("p", {
|
|
587
585
|
className: "hint section-foot",
|
|
588
|
-
children:
|
|
586
|
+
children: "Only projects where you manage access are listed."
|
|
589
587
|
})
|
|
590
588
|
] }),
|
|
591
|
-
found !== null && /* @__PURE__ */ jsx(PrincipalReportCards, { report: found })
|
|
589
|
+
found !== null && /* @__PURE__ */ jsx(PrincipalReportCards, { report: found }),
|
|
590
|
+
found !== null && !removed && (found.personalTokens ?? []).length > 0 && /* @__PURE__ */ jsx(MemberPersonalTokens, {
|
|
591
|
+
member: memberRef(principalType, principalId),
|
|
592
|
+
tokens: found.personalTokens
|
|
593
|
+
})
|
|
592
594
|
] });
|
|
593
595
|
}
|
|
596
|
+
/** A person's personal tokens, for whoever runs the instance, who reads their report and may revoke any of them. */
|
|
597
|
+
function MemberPersonalTokens({ member, tokens }) {
|
|
598
|
+
return /* @__PURE__ */ jsx(PersonalTokensCard, {
|
|
599
|
+
tokens,
|
|
600
|
+
change: revokeMemberToken(useCoffre(), member),
|
|
601
|
+
description: "Tokens they made, each acting as them within what it reaches. Removing them from coffre revokes every one."
|
|
602
|
+
});
|
|
603
|
+
}
|
|
594
604
|
/** What a person's instance role gives them, above the grants that add to it: nothing for a Member. */
|
|
595
605
|
function InstanceRoleNote({ access }) {
|
|
596
606
|
if (access.instanceRole === "member") return null;
|
|
@@ -640,7 +650,7 @@ function EditAccess({ principalType, principalId, access, offers }) {
|
|
|
640
650
|
const { pending, error, setError, run } = useAction();
|
|
641
651
|
const kind = KIND[principalType];
|
|
642
652
|
const rows = access.map(({ project, grants }) => {
|
|
643
|
-
const environments = project.environments.filter((environment) => environment.details !== null && environment.details.archivedAt === null).map((environment) => environment.slug);
|
|
653
|
+
const environments = project.environments.filter((environment) => environment.details !== null && environment.details.archivedAt === null && !environment.personal).map((environment) => environment.slug);
|
|
644
654
|
const held = planFromGrants(grants, environments);
|
|
645
655
|
const plan = Object.hasOwn(edits, project.slug) ? edits[project.slug] : held;
|
|
646
656
|
return {
|
|
@@ -712,7 +722,7 @@ function EditAccess({ principalType, principalId, access, offers }) {
|
|
|
712
722
|
className: "plan-project-text",
|
|
713
723
|
children: [/* @__PURE__ */ jsx("span", {
|
|
714
724
|
className: "plan-project-name",
|
|
715
|
-
children: project.
|
|
725
|
+
children: project.slug
|
|
716
726
|
}), held.level === "custom" && /* @__PURE__ */ jsxs("span", {
|
|
717
727
|
className: "plan-project-held",
|
|
718
728
|
children: ["Holds ", grants.map((grant) => projectAccessLabel(grant)).join(", ")]
|
|
@@ -752,7 +762,7 @@ function EditAccess({ principalType, principalId, access, offers }) {
|
|
|
752
762
|
]
|
|
753
763
|
}),
|
|
754
764
|
(plan.level === "owner" || plan.level === "viewer" || plan.level === "developer") && /* @__PURE__ */ jsx(ExpiryField, {
|
|
755
|
-
label: `${project.
|
|
765
|
+
label: `${project.slug} expires`,
|
|
756
766
|
expiresAt: plan.expiresAt,
|
|
757
767
|
onChange: (expiresAt) => edit({
|
|
758
768
|
...plan,
|
|
@@ -761,7 +771,7 @@ function EditAccess({ principalType, principalId, access, offers }) {
|
|
|
761
771
|
}),
|
|
762
772
|
plan.level === "env" && /* @__PURE__ */ jsx("ul", {
|
|
763
773
|
className: "plan-envs",
|
|
764
|
-
"aria-label": `Environments of ${project.
|
|
774
|
+
"aria-label": `Environments of ${project.slug}`,
|
|
765
775
|
children: environments.map((slug) => {
|
|
766
776
|
const current = environmentAccess(plan, slug);
|
|
767
777
|
return /* @__PURE__ */ jsxs("li", {
|
|
@@ -799,7 +809,7 @@ function EditAccess({ principalType, principalId, access, offers }) {
|
|
|
799
809
|
]
|
|
800
810
|
}),
|
|
801
811
|
current !== null && /* @__PURE__ */ jsx(ExpiryField, {
|
|
802
|
-
label: `${slug} of ${project.
|
|
812
|
+
label: `${slug} of ${project.slug} expires`,
|
|
803
813
|
expiresAt: current.expiresAt,
|
|
804
814
|
onChange: (expiresAt) => edit(withEnvironment(plan, slug, {
|
|
805
815
|
...current,
|
|
@@ -812,7 +822,7 @@ function EditAccess({ principalType, principalId, access, offers }) {
|
|
|
812
822
|
}),
|
|
813
823
|
changes.length > 0 && /* @__PURE__ */ jsx("ul", {
|
|
814
824
|
className: "plan-changes",
|
|
815
|
-
"aria-label": `Changes to ${project.
|
|
825
|
+
"aria-label": `Changes to ${project.slug}`,
|
|
816
826
|
children: changes.map((change) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(AccessChangeTag, { change }) }, change.kind === "create" ? `+${change.role}@${change.environmentSlug ?? ""}` : change.grant.id))
|
|
817
827
|
})
|
|
818
828
|
]
|
|
@@ -890,4 +900,4 @@ function AccessChangeTag({ change }) {
|
|
|
890
900
|
//#endregion
|
|
891
901
|
export { PrincipalLayout as n, ActionsLog as r, PrincipalAccess as t };
|
|
892
902
|
|
|
893
|
-
//# sourceMappingURL=principal-page-
|
|
903
|
+
//# sourceMappingURL=principal-page-DDmmV1KQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"principal-page-DDmmV1KQ.js","names":[],"sources":["../../src/components/actions-log.tsx","../../src/lib/service-setup.ts","../../src/lib/access-plan.ts","../../src/components/expiry-field.tsx","../../src/components/principal-page.tsx"],"sourcesContent":["import { useInfiniteQuery } from '@tanstack/react-query';\nimport { uiResult, useCoffre } from '../lib/coffre';\nimport { keys } from '../lib/queries';\nimport { describe, lines } from '../lib/audit-sentences';\nimport { Sentence } from './audit-sentence';\nimport { EmptyState, Notice, Spinner, Timestamp } from './ui';\nimport { Activity, Clock, ShieldCheck, SlashCircle } from './icons';\n\nconst PAGE_SIZE = 50;\n\n/**\n * Everything one member did, newest first, from the audit log: the same\n * entries `coffre audit --actor` lists, said as the audit page says them.\n * Older pages come on request.\n */\nexport function ActionsLog({ member }: { member: string }) {\n const client = useCoffre();\n const log = useInfiniteQuery({\n queryKey: [...keys.audit, 'actor', member],\n staleTime: 0,\n initialPageParam: undefined as number | undefined,\n queryFn: ({ pageParam }) =>\n uiResult(() => client.audit.list({ actor: member, limit: PAGE_SIZE, before: pageParam })),\n // A page lists fewer entries where they name many secrets: `more` says whether older ones follow.\n getNextPageParam: (page) =>\n page.ok && page.more && page.entries.length > 0 ? page.entries.at(-1)!.seq : undefined,\n });\n\n if (log.isPending) {\n return (\n <p className=\"hint\">\n <Spinner size={13} /> Reading the log…\n </p>\n );\n }\n const failed = log.data?.pages.find((page) => !page.ok);\n if (failed !== undefined && !failed.ok) return <Notice tone=\"bad\">{failed.error}</Notice>;\n const entries = (log.data?.pages ?? []).flatMap((page) => (page.ok ? page.entries : []));\n const shown = lines(entries);\n\n return (\n <>\n <section className=\"card\" aria-label=\"Actions log\">\n {shown.length === 0 ? (\n <EmptyState title=\"Nothing yet\" />\n ) : (\n <div className=\"dt-wrap\">\n <table className=\"dt actions-log stacks stacks-inline\">\n <thead>\n <tr>\n <th className=\"col-shrink\">\n <span className=\"th\">\n <Clock size={14} />\n When\n </span>\n </th>\n <th>\n <span className=\"th\">\n <Activity size={14} />\n Action\n </span>\n </th>\n <th className=\"col-shrink\">\n <span className=\"th\">\n <ShieldCheck size={14} />\n Outcome\n </span>\n </th>\n </tr>\n </thead>\n <tbody>\n {shown.map((batch) => {\n const lead = batch[0]!;\n const sentence = describe(batch);\n return (\n <tr key={lead.seq} className={sentence.refused ? 'is-denied' : undefined}>\n <td className=\"nowrap cell-muted\" title={lead.occurredAt}>\n <Timestamp iso={lead.occurredAt} display=\"relative\" />\n </td>\n <td className=\"cell-sentence\">\n <span className=\"sentence\">\n <Sentence parts={sentence.parts} />\n </span>\n </td>\n <td className=\"nowrap\" data-label=\"Outcome\">\n {sentence.refused ? (\n <span className=\"decided decided-refused\">\n <SlashCircle size={13} />\n Refused\n </span>\n ) : (\n <span className=\"cell-muted\">Allowed</span>\n )}\n </td>\n </tr>\n );\n })}\n </tbody>\n </table>\n </div>\n )}\n </section>\n {log.hasNextPage && (\n <div className=\"table-actions\">\n <button\n type=\"button\"\n className=\"btn\"\n disabled={log.isFetchingNextPage}\n onClick={() => void log.fetchNextPage()}\n >\n {log.isFetchingNextPage && <Spinner />}\n Show older\n </button>\n </div>\n )}\n </>\n );\n}\n","import { inScope, ROLE_NAMES, ROLES, type Permission, type Role, type Scope } from '@coffre/core/access';\n\nimport type { ProjectSummary } from '../shared/models';\n\n/** What `givable` reads of the shell: the projects, what you hold in each environment, and the setting. */\ntype Holder = {\n projects: readonly ProjectSummary[];\n environments: readonly { project: string; environment: string; permissions: Permission[] }[];\n /** The instance's setting as `/me` says it, projects by slug, those you see; null for a service account. */\n serviceSetup: Scope | null;\n};\n\n/**\n * The roles you may give a service account at a project, or one of its\n * environments, as the server decides it (`givesService` in\n * @coffre/core/access): any, where you manage access; otherwise, inside the\n * instance's setting, those whose every permission you hold there.\n *\n * a Developer of every dev, at market/dev viewer, developer\n * the same, at market none: a project takes holding all of it\n */\nexport function givable(holder: Holder, project: ProjectSummary, environment: string | null): Role[] {\n const held = environment === null\n ? project.permissions\n : holder.environments.find((entry) => entry.project === project.slug && entry.environment === environment)?.permissions ?? [];\n if (held.includes('grant.manage')) return [...ROLE_NAMES];\n const setting = holder.serviceSetup;\n // The setting names projects by slug here, so a place is matched by its slugs.\n const place = environment === null\n ? { projectId: project.slug }\n : { projectId: project.slug, environmentId: environment, environmentSlug: environment };\n if (setting === null || !inScope(setting, place)) return [];\n return ROLE_NAMES.filter((role) => ROLES[role].permissions.every((permission) => held.includes(permission)));\n}\n\n/** The projects where you may give a service account something: on the project, or on one of its environments. */\nexport function serviceProjects(holder: Holder): ProjectSummary[] {\n return holder.projects.filter((project) =>\n givable(holder, project, null).length > 0 ||\n project.environments.some((environment) => givable(holder, project, environment.slug).length > 0));\n}\n","import type { AccessValue } from '@coffre/client';\nimport type { Role } from '@coffre/core/access';\n\nimport type { GrantRow } from '../shared/models';\n\n/** Read or write on one environment, and when it ends: an ISO instant, or null for never. */\nexport type EnvironmentAccess = { role: Extract<Role, 'viewer' | 'developer'>; expiresAt: string | null };\n\n/**\n * What one project is set to in a principal's access editor: nothing, owner,\n * read or write everywhere, or read or write per environment. Every grant the\n * plan asks for carries its own expiry.\n *\n * `custom` is for grants that do not fit that shape -- an auditor grant, or\n * read everywhere plus write on one environment. The editor shows them and\n * leaves them alone unless another setting is picked.\n */\nexport type AccessPlan = {\n level: 'none' | Extract<Role, 'owner' | 'viewer' | 'developer'> | 'env' | 'custom';\n /** When the project-wide level ends. */\n expiresAt: string | null;\n /** Environments without an entry get no access. */\n environments: Record<string, EnvironmentAccess>;\n};\n\nexport type HeldGrant = Pick<\n GrantRow,\n 'id' | 'role' | 'roleName' | 'environmentSlug' | 'expiresAt'\n>;\n\nexport type AccessChange =\n | { kind: 'create'; role: string; environmentSlug: string | null; expiresAt: string | null }\n | { kind: 'expiry'; grant: HeldGrant; expiresAt: string | null }\n | { kind: 'revoke'; grant: HeldGrant };\n\n/** An environment's access in a plan; slugs like `constructor` are not inherited. */\nexport function environmentAccess(plan: AccessPlan, slug: string): EnvironmentAccess | null {\n return Object.hasOwn(plan.environments, slug) ? plan.environments[slug] : null;\n}\n\n/**\n * Read what a principal holds on a project back into the editor's terms.\n * `environments` are the ones the editor can set: live, and not archived.\n */\nexport function planFromGrants(\n grants: readonly HeldGrant[],\n environments: readonly string[],\n): AccessPlan {\n if (grants.length === 0) return { level: 'none', expiresAt: null, environments: {} };\n\n const [only] = grants;\n if (\n grants.length === 1 &&\n only.environmentSlug === null &&\n (only.role === 'owner' || only.role === 'viewer' || only.role === 'developer')\n ) {\n return { level: only.role, expiresAt: only.expiresAt, environments: {} };\n }\n\n const perEnvironment: Record<string, EnvironmentAccess> = {};\n for (const grant of grants) {\n const slug = grant.environmentSlug;\n if (\n slug === null ||\n !environments.includes(slug) ||\n Object.hasOwn(perEnvironment, slug) ||\n (grant.role !== 'viewer' && grant.role !== 'developer')\n ) {\n return { level: 'custom', expiresAt: null, environments: {} };\n }\n perEnvironment[slug] = { role: grant.role, expiresAt: grant.expiresAt };\n }\n return { level: 'env', expiresAt: null, environments: perEnvironment };\n}\n\n/**\n * Switch a plan's level. Going from read or write everywhere to per\n * environment starts every environment at that level and expiry, so the\n * switch alone keeps the same reach.\n */\nexport function withLevel(\n plan: AccessPlan,\n level: AccessPlan['level'],\n environments: readonly string[],\n): AccessPlan {\n if (\n level === 'env' &&\n (plan.level === 'viewer' || plan.level === 'developer') &&\n Object.keys(plan.environments).length === 0\n ) {\n const access = { role: plan.level, expiresAt: plan.expiresAt };\n return {\n ...plan,\n level,\n environments: Object.fromEntries(environments.map((slug) => [slug, access])),\n };\n }\n return { ...plan, level };\n}\n\n/** Set one environment's access, or take it away with `null`. */\nexport function withEnvironment(\n plan: AccessPlan,\n slug: string,\n access: EnvironmentAccess | null,\n): AccessPlan {\n const environments = { ...plan.environments };\n if (access === null) delete environments[slug];\n else environments[slug] = access;\n return { ...plan, environments };\n}\n\nfunction grantsFor(\n plan: AccessPlan,\n): { role: string; environmentSlug: string | null; expiresAt: string | null }[] {\n switch (plan.level) {\n case 'none':\n case 'custom':\n return [];\n case 'owner':\n case 'viewer':\n case 'developer':\n return [{ role: plan.level, environmentSlug: null, expiresAt: plan.expiresAt }];\n case 'env':\n return Object.entries(plan.environments).map(([environmentSlug, access]) => ({\n environmentSlug,\n ...access,\n }));\n }\n}\n\n/** The server and the date field spell the same instant differently. */\nfunction sameExpiry(a: string | null, b: string | null): boolean {\n return a === b || (a !== null && b !== null && Date.parse(a) === Date.parse(b));\n}\n\n/**\n * The changes that take what is held to the plan: grants to create, grants\n * whose expiry moves, and grants to revoke, in that order. Asking for what is\n * already held yields nothing, so applying the same plan twice is a no-op.\n */\nexport function accessChanges(grants: readonly HeldGrant[], plan: AccessPlan): AccessChange[] {\n if (plan.level === 'custom') return [];\n\n const key = (grant: { role: string; environmentSlug: string | null }) =>\n `${grant.role}@${grant.environmentSlug ?? ''}`;\n const wanted = new Map(grantsFor(plan).map((grant) => [key(grant), grant]));\n const held = new Map(grants.map((grant) => [key(grant), grant]));\n\n const changes: AccessChange[] = [];\n for (const [id, grant] of wanted) {\n if (!held.has(id)) changes.push({ kind: 'create', ...grant });\n }\n for (const [id, grant] of held) {\n const want = wanted.get(id);\n if (want !== undefined && !sameExpiry(grant.expiresAt, want.expiresAt)) {\n changes.push({ kind: 'expiry', grant, expiresAt: want.expiresAt });\n }\n }\n for (const [id, grant] of held) {\n if (!wanted.has(id)) changes.push({ kind: 'revoke', grant });\n }\n return changes;\n}\n\n/**\n * The changes as the API's access patch for one project: each place it\n * touches, and the role to hold there until when, or `null` for none.\n *\n * { \"market\": null, \"market/dev\": { \"role\": \"developer\", \"until\": \"2026-12-31T23:59:59.000Z\" } }\n *\n * A place holds one role, so where a level changes, the revoke of the old\n * role and the create of the new land on the same place, and the new role\n * wins: the server replaces one with the other, never passing through none.\n */\nexport function accessPatch(project: string, changes: readonly AccessChange[]): Record<string, AccessValue> {\n const place = (environmentSlug: string | null) =>\n environmentSlug === null ? project : `${project}/${environmentSlug}`;\n const holding = (role: string, expiresAt: string | null): AccessValue =>\n expiresAt === null ? (role as Role) : { role: role as Role, until: expiresAt };\n\n const patch: Record<string, AccessValue> = {};\n for (const change of changes) {\n if (change.kind === 'revoke') patch[place(change.grant.environmentSlug)] = null;\n }\n for (const change of changes) {\n if (change.kind === 'expiry') patch[place(change.grant.environmentSlug)] = holding(change.grant.role, change.expiresAt);\n if (change.kind === 'create') patch[place(change.environmentSlug)] = holding(change.role, change.expiresAt);\n }\n return patch;\n}\n\n/** A date field's value as the instant access ends: the close of that day, UTC. */\nexport function expiryFromDate(date: string): string | null {\n return date === '' ? null : new Date(`${date}T23:59:59Z`).toISOString();\n}\n\n/** A date field's value for an expiry. Expiries are shown as UTC dates everywhere. */\nexport function dateFromExpiry(expiresAt: string | null): string {\n return expiresAt === null ? '' : expiresAt.slice(0, 10);\n}\n","import { dateFromExpiry, expiryFromDate } from '../lib/access-plan';\nimport { X } from './icons';\n\n/**\n * When one grant ends, as a date: access lasts through that day, UTC. Blank\n * reads \"Never\" where the browser lets the empty field be restyled.\n */\nexport function ExpiryField({\n label,\n expiresAt,\n onChange,\n}: {\n label: string;\n expiresAt: string | null;\n onChange: (expiresAt: string | null) => void;\n}) {\n const date = dateFromExpiry(expiresAt);\n return (\n <span className={`expiry${date === '' ? ' is-never' : ''}`}>\n <input\n className=\"input select-sm\"\n type=\"date\"\n aria-label={label}\n min={new Date().toISOString().slice(0, 10)}\n value={date}\n onChange={(event) => onChange(expiryFromDate(event.target.value))}\n />\n <span className=\"expiry-never\" aria-hidden=\"true\">\n Never\n </span>\n <button\n className=\"btn btn-quiet btn-sm btn-icon\"\n type=\"button\"\n aria-label={`${label}: never`}\n title=\"Never expires\"\n onClick={() => onChange(null)}\n >\n <X size={12} />\n </button>\n </span>\n );\n}\n","import { useState } from 'react';\nimport { useQueryClient, useSuspenseQuery } from '@tanstack/react-query';\nimport { Link, Outlet } from '@tanstack/react-router';\nimport { INSTANCE_ROLES, ROLE_NAMES, ROLES, scopeInWords, unscoped, type Role } from '@coffre/core/access';\nimport { useShell } from '../lib/use-shell';\nimport { toast } from 'sonner';\nimport { memberRef, useCoffre } from '../lib/coffre';\nimport { directoryList, revokeMemberToken } from '../lib/changes';\nimport { affects, hasAppsTab, keys, listsAccess, managedProjects, queries, signInWays } from '../lib/queries';\nimport { useChangeStatus } from '../lib/use-change';\nimport { useMounted } from '../lib/mounted';\nimport { ItemFailure } from './row-state';\nimport { useAction } from '../lib/use-action';\nimport { accessRows, projectAccessLabel, type ProjectAccess } from '../lib/project-access';\nimport { givable, serviceProjects } from '../lib/service-setup';\nimport {\n accessChanges,\n accessPatch,\n dateFromExpiry,\n environmentAccess,\n expiryFromDate,\n planFromGrants,\n withEnvironment,\n withLevel,\n type AccessChange,\n type AccessPlan,\n} from '../lib/access-plan';\nimport type { MemberAccess, TokenRow } from '@coffre/client';\nimport type { DirectoryPrincipal, ProjectSummary } from '../shared/models';\nimport { ClosedDoor, PageHeader } from './page';\nimport { EmptyState, ErrorLine, Modal, Notice, Spinner } from './ui';\nimport { GrantRowView, GrantsTable } from './grants';\nimport { ExpiryField } from './expiry-field';\nimport { InstanceRole, KIND, PrincipalActions } from './directory';\nimport { PrincipalReportCards, RemovedNotice } from './offboarding';\nimport { PersonalTokensCard } from './personal-tokens';\nimport { PrincipalAvatar } from './principal';\nimport { Tile } from './tile';\nimport { Activity, Archive, Clock, Folder, Key, Link as LinkIcon, Pencil, Users, X } from './icons';\nimport { PageTabs } from './tabs';\n\ntype PrincipalType = DirectoryPrincipal['principalType'];\n\n/** The roles you may give at a project, or one of its environments: any where you manage access (`givable`). */\ntype Offers = (project: ProjectSummary, environment: string | null) => readonly Role[];\n\n/** Who a user or service account is to the instance, as an owner reads it; null for anyone else. */\nfunction useReport(principalType: PrincipalType, principalId: string) {\n const { capabilities } = useShell();\n return useSuspenseQuery(queries.report(useCoffre(), memberRef(principalType, principalId), capabilities.runsInstance)).data;\n}\n\n/**\n * What `loadAccess` read in one request: their role and scope, and, for each\n * project where you manage access, the grants they hold there. For a\n * service account you manage, each project where you may give it\n * something, and what (`offers`).\n */\nfunction useMemberAccess(principalType: PrincipalType, principalId: string): {\n access: MemberAccess | null;\n error: string | null;\n projects: ProjectAccess[];\n offers: Offers;\n} {\n const shell = useShell();\n const { data } = useSuspenseQuery(queries.memberAccess(useCoffre(), memberRef(principalType, principalId), listsAccess(shell)));\n const error = data !== null && !data.ok ? data.error : null;\n const access = data?.ok === true ? data : null;\n const yours = principalType === 'service' && access?.managed === true;\n const listed = yours ? serviceProjects(shell) : managedProjects(shell.projects);\n return {\n access,\n error,\n offers: yours ? (project, environment) => givable(shell, project, environment) : () => ROLE_NAMES,\n projects: listed.map((project) => ({\n project,\n grants: (access?.grants ?? []).filter((grant) => grant.project === project.slug).map((grant) => ({\n id: grant.id,\n principalType,\n principalId,\n role: grant.role,\n roleName: grant.roleName,\n permissions: grant.permissions,\n scope: grant.environment === null ? 'project' : 'environment',\n environmentSlug: grant.environment,\n expiresAt: grant.expiresAt,\n })),\n grantsError: error,\n })),\n };\n}\n\n/**\n * A user's or service account's page: who it is, its menu, and its tabs,\n * each a page of its own under this one. Access is a user's first tab; a\n * service account's is how it signs in, while it shows one. A tab the\n * deployment left out is not offered.\n */\nexport function PrincipalLayout({ principalType, principalId }: { principalType: PrincipalType; principalId: string }) {\n const shell = useShell();\n const mounted = useMounted();\n const { capabilities } = shell;\n const report = useReport(principalType, principalId);\n // A service account you manage, though you do not run the instance: what it holds, from its access.\n const { data: held } = useSuspenseQuery(queries.memberAccess(useCoffre(), memberRef(principalType, principalId), listsAccess(shell)));\n const yours = principalType === 'service' && held?.ok === true && held.managed;\n // A role change or removal made from this page's menu, refused.\n const { status, dismiss } = useChangeStatus(directoryList.queryKey);\n const change = status(memberRef(principalType, principalId));\n const kind = KIND[principalType];\n const people = principalType === 'user';\n const found = report?.ok === true ? report.report : null;\n const removed = found?.status === 'removed';\n const entry =\n found !== null && !removed\n ? {\n principalType,\n principalId,\n instanceRole: found.instanceRole,\n scope: found.scope,\n tampered: found.status === 'tampered',\n managed: principalType === 'service',\n declared: found.declared,\n }\n : yours\n ? { principalType, principalId, instanceRole: 'member' as const, scope: null, tampered: false, managed: true }\n : undefined;\n\n // Owners get a report about anyone ever registered, removed or not, so a\n // miss there means there is no such user. Everyone else only reaches this\n // page through projects they manage, or a service account they manage.\n const unknown = report?.ok === true && found === null;\n if (unknown || (report === null && managedProjects(shell.projects).length === 0 && !yours)) {\n return (\n <ClosedDoor\n icon={people ? <Users size={18} /> : <Key size={18} />}\n label={<span className=\"mono\">{people ? principalId : `service:${principalId}`}</span>}\n title={people ? 'No such user for you' : 'No such service account for you'}\n actions={\n <Link className=\"btn\" to={people ? '/users' : '/service-accounts'}>\n All {people ? 'users' : 'service accounts'}\n </Link>\n }\n >\n {report === null\n ? `A ${kind}'s page lists its access to the projects where you manage access, and you manage none.`\n : `No ${kind} by that name has ever been registered here.`}\n </ClosedDoor>\n );\n }\n\n const access = (\n <>\n {removed ? <Archive size={15} /> : <Folder size={15} />}\n {removed ? 'Offboarding' : 'Access'}\n </>\n );\n const activity = (\n <>\n <Activity size={15} />\n Activity\n </>\n );\n const tabs = people\n ? [\n <Link key=\"access\" to=\"/users/$user\" params={{ user: principalId }} activeOptions={{ exact: true, includeSearch: false }}>\n {access}\n </Link>,\n // Only an owner reads the report that lists them; removal disconnects them.\n hasAppsTab(shell, report) && mounted('/users/$user/apps') && (\n <Link key=\"apps\" to=\"/users/$user/apps\" params={{ user: principalId }}>\n <LinkIcon size={15} />\n Connected apps\n </Link>\n ),\n capabilities.canReadAudit && mounted('/users/$user/activity') && (\n <Link key=\"activity\" to=\"/users/$user/activity\" params={{ user: principalId }}>\n {activity}\n </Link>\n ),\n ]\n : [\n signInWays(shell, held) !== null && (\n <Link key=\"sign-in\" to=\"/service-accounts/$account\" params={{ account: principalId }} activeOptions={{ exact: true, includeSearch: false }}>\n <LinkIcon size={15} />\n Sign-in\n </Link>\n ),\n mounted('/service-accounts/$account/access') && (\n <Link key=\"access\" to=\"/service-accounts/$account/access\" params={{ account: principalId }}>\n {access}\n </Link>\n ),\n capabilities.canReadAudit && mounted('/service-accounts/$account/activity') && (\n <Link key=\"activity\" to=\"/service-accounts/$account/activity\" params={{ account: principalId }}>\n {activity}\n </Link>\n ),\n ];\n\n return (\n <>\n <PageHeader\n lead={<PrincipalAvatar type={principalType} id={principalId} size=\"lg\" />}\n title={principalType === 'service' ? `service:${principalId}` : principalId}\n description={\n principalType === 'service'\n ? 'A service account: an identity for CI and other automation.'\n : undefined\n }\n meta={\n removed ? (\n <span className=\"tag tag-red\">Removed</span>\n ) : (\n entry?.principalType === 'user' && <InstanceRole principal={entry} />\n )\n }\n actions={entry !== undefined && <PrincipalActions principal={entry} trigger=\"btn btn-icon\" />}\n />\n\n {change.state === 'failed' && (\n <div className=\"report-notice\">\n <ItemFailure status={change} onDismiss={() => dismiss(change.mutationId)} />\n </div>\n )}\n {report?.ok === false && (\n <div className=\"report-notice\">\n <Notice tone=\"bad\">{report.error}</Notice>\n </div>\n )}\n <PageTabs label={people ? 'User sections' : 'Service account sections'}>{tabs}</PageTabs>\n\n <Outlet />\n </>\n );\n}\n\n/**\n * A user's or service account's Access tab: its grants on every project\n * where you manage access, and on every project; once it is removed, what\n * its offboarding did instead.\n */\nexport function PrincipalAccess({ principalType, principalId }: { principalType: PrincipalType; principalId: string }) {\n const report = useReport(principalType, principalId);\n const { access: held, error, projects: access, offers } = useMemberAccess(principalType, principalId);\n const kind = KIND[principalType];\n const people = principalType === 'user';\n const found = report?.ok === true ? report.report : null;\n const removed = found?.status === 'removed';\n\n // One request, so one error, said once in place of the rows (`UnreadAccess`).\n const rows = accessRows(access).flatMap((row) => (row.grant === null ? [] : [row]));\n // Grants to someone removed are refused until they are added back.\n const editable = removed\n ? []\n : access.filter(\n ({ project, grantsError }) => project.archivedAt === null && grantsError === null,\n );\n\n return (\n <>\n {removed && found !== null && <RemovedNotice report={found} />}\n\n {/* Removal ends every grant, so there is no access left to show. */}\n {!removed && (\n <>\n {people && held !== null && <InstanceRoleNote access={held} />}\n\n <section className=\"card\" aria-label=\"Project access\">\n {error !== null ? (\n <UnreadAccess member={memberRef(principalType, principalId)} error={error} />\n ) : rows.length === 0 ? (\n <EmptyState title=\"No project access yet\">\n {editable.length > 0 ? undefined : `None of the projects where you manage access has a grant for this ${kind}.`}\n </EmptyState>\n ) : (\n <GrantsTable\n lead={\n <span className=\"th\">\n <Folder size={14} />\n Project\n </span>\n }\n >\n {rows.map(({ project, grant }, index) => (\n <GrantRowView\n key={grant.id}\n number={index + 1}\n project={project.slug}\n grant={grant}\n leadLabel=\"Project\"\n lead={\n <span className=\"cell-project\">\n <Tile name={project.slug} />\n <Link\n className=\"cell-link\"\n to={people ? '/projects/$project/users' : '/projects/$project/service-accounts'}\n params={{ project: project.slug }}\n >\n {project.slug}\n </Link>\n {project.archivedAt !== null && <span className=\"tag tag-red\">Archived</span>}\n </span>\n }\n />\n ))}\n </GrantsTable>\n )}\n </section>\n\n {editable.length > 0 && (\n <div className=\"table-actions\">\n <EditAccess principalType={principalType} principalId={principalId} access={editable} offers={offers} />\n </div>\n )}\n\n {!(held?.managed === true && principalType === 'service') && (\n <p className=\"hint section-foot\">Only projects where you manage access are listed.</p>\n )}\n\n </>\n )}\n\n {found !== null && <PrincipalReportCards report={found} />}\n {/* A report from an instance before 0.7, mid-deploy or rolled back, lists none. */}\n {found !== null && !removed && (found.personalTokens ?? []).length > 0 && (\n <MemberPersonalTokens member={memberRef(principalType, principalId)} tokens={found.personalTokens} />\n )}\n </>\n );\n}\n\n/** A person's personal tokens, for whoever runs the instance, who reads their report and may revoke any of them. */\nfunction MemberPersonalTokens({ member, tokens }: { member: string; tokens: TokenRow[] }) {\n return (\n <PersonalTokensCard\n tokens={tokens}\n change={revokeMemberToken(useCoffre(), member)}\n description=\"Tokens they made, each acting as them within what it reaches. Removing them from coffre revokes every one.\"\n />\n );\n}\n\n/** What a person's instance role gives them, above the grants that add to it: nothing for a Member. */\nfunction InstanceRoleNote({ access }: { access: MemberAccess }) {\n if (access.instanceRole === 'member') return null;\n const { name } = INSTANCE_ROLES[access.instanceRole];\n return (\n <div className=\"report-notice\">\n <Notice tone=\"info\">\n <strong>{name}</strong>\n {access.scope === null ? '' : unscoped(access.scope) ? ' in every project' : `: ${scopeInWords(access.scope)}`}, from their instance role. The\n grants below add to it.\n </Notice>\n </div>\n );\n}\n\n/** Their access could not be read: why, and another try, never an empty list that reads as no access. */\nfunction UnreadAccess({ member, error }: { member: string; error: string }) {\n const queryClient = useQueryClient();\n const [retrying, setRetrying] = useState(false);\n return (\n <div className=\"row-failure-line unread-access\">\n <ErrorLine error={`Their access could not be read. ${error}`} />\n <button\n type=\"button\"\n className=\"act\"\n disabled={retrying}\n onClick={() => {\n setRetrying(true);\n void queryClient.refetchQueries({ queryKey: keys.memberAccess(member) }).finally(() => setRetrying(false));\n }}\n >\n {retrying && <Spinner size={13} />}\n Retry\n </button>\n </div>\n );\n}\n\n/**\n * One principal's access to every project you manage, edited in one place.\n *\n * Each project opens set to what the principal holds: a project-wide level,\n * or read or write per environment, each with its own expiry. Saving sends\n * only the difference, every project in one `access.set`: the server applies\n * all of it in one transaction, or none of it.\n */\nfunction EditAccess({\n principalType,\n principalId,\n access,\n offers,\n}: {\n principalType: PrincipalType;\n principalId: string;\n access: ProjectAccess[];\n offers: Offers;\n}) {\n const coffre = useCoffre();\n const [open, setOpen] = useState(false);\n const [edits, setEdits] = useState<Record<string, AccessPlan>>({});\n const { pending, error, setError, run } = useAction();\n const kind = KIND[principalType];\n\n const rows = access.map(({ project, grants }) => {\n const environments = project.environments\n .filter(\n // Your personal config takes no grant: it is no place to give access to.\n (environment) => environment.details !== null && environment.details.archivedAt === null && !environment.personal,\n )\n .map((environment) => environment.slug);\n const held = planFromGrants(grants, environments);\n const plan = Object.hasOwn(edits, project.slug) ? edits[project.slug] : held;\n // What you may give here: every role where you manage access; a service account you manage, what you hold.\n const whole = offers(project, null);\n const each = Object.fromEntries(environments.map((slug) => [slug, offers(project, slug)]));\n return { project, grants, environments, held, plan, whole, each, changes: accessChanges(grants, plan) };\n });\n const changed = rows.filter((row) => row.changes.length > 0);\n\n function close() {\n setOpen(false);\n setEdits({});\n setError(null);\n }\n\n return (\n <>\n <button className=\"btn btn-primary\" onClick={() => setOpen(true)}>\n <Pencil size={14} />\n Edit access\n </button>\n\n <Modal\n open={open}\n onOpenChange={(next) => (next ? setOpen(true) : close())}\n title={\n <>\n Edit access for <span className=\"mono\">{principalId}</span>\n </>\n }\n description={`Set what this ${kind} can reach on each project you ${principalType === 'service' ? 'may give it access to' : 'manage'}, and until when.`}\n wide\n >\n <form\n className=\"form\"\n onSubmit={(event) => {\n event.preventDefault();\n run(\n () =>\n coffre.access.set(\n memberRef(principalType, principalId),\n Object.assign({}, ...changed.map(({ project, changes }) => accessPatch(project.slug, changes))),\n ),\n {\n affects: changed.flatMap(({ project }) =>\n affects.access(project.slug, memberRef(principalType, principalId)),\n ),\n onSuccess: () => {\n toast.success(\n `Updated ${principalId}’s access on ${changed.length} project${changed.length === 1 ? '' : 's'}`,\n );\n close();\n },\n },\n );\n }}\n >\n <ul className=\"plan-list\">\n <li className=\"plan-head\" aria-hidden=\"true\">\n <span>Project</span>\n <span>Access</span>\n <span>Expires</span>\n </li>\n {rows.map(({ project, grants, environments, held, plan, whole, each, changes }) => {\n const id = `plan-${project.slug}`;\n const edit = (next: AccessPlan) =>\n setEdits((current) => ({ ...current, [project.slug]: next }));\n return (\n <li\n key={project.slug}\n className={`plan-row${changes.length > 0 ? ' is-changed' : ''}`}\n >\n <label className=\"plan-project\" htmlFor={id}>\n <Tile name={project.slug} />\n <span className=\"plan-project-text\">\n <span className=\"plan-project-name\">{project.slug}</span>\n {held.level === 'custom' && (\n <span className=\"plan-project-held\">\n Holds {grants.map((grant) => projectAccessLabel(grant)).join(', ')}\n </span>\n )}\n </span>\n </label>\n <select\n id={id}\n className=\"select select-sm\"\n value={plan.level}\n onChange={(event) =>\n edit(\n withLevel(plan, event.target.value as AccessPlan['level'], environments),\n )\n }\n >\n {held.level === 'custom' && <option value=\"custom\">Keep as is</option>}\n <option value=\"none\">No access</option>\n {whole.includes('owner') && <option value=\"owner\">{ROLES.owner.name}</option>}\n {whole.includes('viewer') && <option value=\"viewer\">{ROLES.viewer.name}: all</option>}\n {whole.includes('developer') && <option value=\"developer\">{ROLES.developer.name}: all</option>}\n {environments.some((slug) => each[slug]!.length > 0) && <option value=\"env\">Per environment…</option>}\n </select>\n {(plan.level === 'owner' ||\n plan.level === 'viewer' ||\n plan.level === 'developer') && (\n <ExpiryField\n label={`${project.slug} expires`}\n expiresAt={plan.expiresAt}\n onChange={(expiresAt) => edit({ ...plan, expiresAt })}\n />\n )}\n\n {plan.level === 'env' && (\n <ul className=\"plan-envs\" aria-label={`Environments of ${project.slug}`}>\n {environments.map((slug) => {\n const current = environmentAccess(plan, slug);\n return (\n <li key={slug} className=\"plan-env\">\n <label className=\"mono\" htmlFor={`${id}-${slug}`}>\n {slug}\n </label>\n <select\n id={`${id}-${slug}`}\n className=\"select select-sm\"\n value={current?.role ?? ''}\n onChange={(event) => {\n const role = event.target.value;\n edit(\n withEnvironment(\n plan,\n slug,\n role === 'viewer' || role === 'developer'\n ? { role, expiresAt: current?.expiresAt ?? null }\n : null,\n ),\n );\n }}\n >\n <option value=\"\">No access</option>\n {each[slug]!.includes('viewer') && <option value=\"viewer\">{ROLES.viewer.name}</option>}\n {each[slug]!.includes('developer') && <option value=\"developer\">{ROLES.developer.name}</option>}\n </select>\n {current !== null && (\n <ExpiryField\n label={`${slug} of ${project.slug} expires`}\n expiresAt={current.expiresAt}\n onChange={(expiresAt) =>\n edit(withEnvironment(plan, slug, { ...current, expiresAt }))\n }\n />\n )}\n </li>\n );\n })}\n </ul>\n )}\n\n {changes.length > 0 && (\n <ul className=\"plan-changes\" aria-label={`Changes to ${project.slug}`}>\n {changes.map((change) => (\n <li\n key={\n change.kind === 'create'\n ? `+${change.role}@${change.environmentSlug ?? ''}`\n : change.grant.id\n }\n >\n <AccessChangeTag change={change} />\n </li>\n ))}\n </ul>\n )}\n </li>\n );\n })}\n </ul>\n\n <ErrorLine error={error} />\n\n <div className=\"dialog-actions\">\n <button className=\"btn\" type=\"button\" onClick={close}>\n Cancel\n </button>\n <button\n className=\"btn btn-primary\"\n type=\"submit\"\n disabled={pending || changed.length === 0}\n >\n {pending && <Spinner />}\n Save changes\n </button>\n </div>\n </form>\n </Modal>\n </>\n );\n}\n\nfunction AccessChangeTag({ change }: { change: AccessChange }) {\n const until = (expiresAt: string | null) =>\n expiresAt === null ? '' : ` until ${dateFromExpiry(expiresAt)}`;\n switch (change.kind) {\n case 'create':\n return (\n <span className=\"tag tag-green\">\n <span aria-hidden=\"true\">+</span>\n <span className=\"visually-hidden\">Adds</span>\n {projectAccessLabel({ ...change, roleName: change.role })}\n {until(change.expiresAt)}\n </span>\n );\n case 'expiry':\n return (\n <span className=\"tag tag-blue\">\n <Clock size={12} />\n <span className=\"visually-hidden\">Moves the expiry of</span>\n {projectAccessLabel(change.grant)}\n {change.expiresAt === null ? ', no expiry' : until(change.expiresAt)}\n </span>\n );\n case 'revoke':\n return (\n <span className=\"tag tag-red\">\n <span aria-hidden=\"true\">−</span>\n <span className=\"visually-hidden\">Removes</span>\n {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;;GACD;;CACD,CAAA,CACP,EAAA,CAAA;AAEN;AAEA,SAAS,gBAAgB,EAAE,UAAoC;CAC7D,MAAM,SAAS,cACb,cAAc,OAAO,KAAK,UAAU,eAAe,SAAS;CAC9D,QAAQ,OAAO,MAAf;EACE,KAAK,UACH,OACE,qBAAC,QAAD;GAAM,WAAU;aAAhB;IACE,oBAAC,QAAD;KAAM,eAAY;eAAO;IAAO,CAAA;IAChC,oBAAC,QAAD;KAAM,WAAU;eAAkB;IAAU,CAAA;IAC3C,mBAAmB;KAAE,GAAG;KAAQ,UAAU,OAAO;IAAK,CAAC;IACvD,MAAM,OAAO,SAAS;GACnB;;EAEV,KAAK,UACH,OACE,qBAAC,QAAD;GAAM,WAAU;aAAhB;IACE,oBAAC,OAAD,EAAO,MAAM,GAAK,CAAA;IAClB,oBAAC,QAAD;KAAM,WAAU;eAAkB;IAAyB,CAAA;IAC1D,mBAAmB,OAAO,KAAK;IAC/B,OAAO,cAAc,OAAO,gBAAgB,MAAM,OAAO,SAAS;GAC/D;;EAEV,KAAK,UACH,OACE,qBAAC,QAAD;GAAM,WAAU;aAAhB;IACE,oBAAC,QAAD;KAAM,eAAY;eAAO;IAAO,CAAA;IAChC,oBAAC,QAAD;KAAM,WAAU;eAAkB;IAAa,CAAA;IAC9C,mBAAmB,OAAO,KAAK;GAC5B;;CAEZ;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { _ as projectOf, v as queries } from "./queries-epz4MIuW.js";
|
|
1
2
|
import { u as useCoffre } from "./page-JTORvh-N.js";
|
|
2
|
-
import { g as queries, h as projectOf } from "./queries-DgQo3mC-.js";
|
|
3
3
|
import { useSuspenseQuery } from "@tanstack/react-query";
|
|
4
4
|
//#region src/lib/project-page.ts
|
|
5
5
|
/**
|
|
@@ -14,4 +14,4 @@ function useProject(slug) {
|
|
|
14
14
|
//#endregion
|
|
15
15
|
export { useProject as t };
|
|
16
16
|
|
|
17
|
-
//# sourceMappingURL=project-page-
|
|
17
|
+
//# sourceMappingURL=project-page-BI--vjt3.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-page-
|
|
1
|
+
{"version":3,"file":"project-page-BI--vjt3.js","names":[],"sources":["../../src/lib/project-page.ts"],"sourcesContent":["import { useSuspenseQuery } from '@tanstack/react-query';\n\nimport { useCoffre } from './coffre';\nimport { projectOf, queries } from './queries';\n\n/**\n * The project one of its tabs shows, as its layout found it: the layout\n * renders a tab only once the project is there for its visitor.\n */\nexport function useProject(slug: string) {\n const found = projectOf(useSuspenseQuery(queries.projects(useCoffre())).data, slug);\n if (!found.ok) throw new Error(`no project \"${slug}\" for this tab`);\n return found;\n}\n"],"mappings":";;;;;;;;AASA,SAAgB,WAAW,MAAc;CACvC,MAAM,QAAQ,UAAU,iBAAiB,QAAQ,SAAS,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI;CAClF,IAAI,CAAC,MAAM,IAAI,MAAM,IAAI,MAAM,eAAe,KAAK,eAAe;CAClE,OAAO;AACT"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { c as statusOf, l as uiResult, s as memberRef } from "./page-JTORvh-N.js";
|
|
2
2
|
import { EVERYWHERE, INSTANCE_ROLES, administers, makesProjects, ownsInstance } from "@coffre/core/access";
|
|
3
3
|
import { QueryClient, queryOptions } from "@tanstack/react-query";
|
|
4
|
+
//#region src/lib/project-environments.ts
|
|
5
|
+
function hasEnvironmentDetails(environment) {
|
|
6
|
+
return environment.details !== null;
|
|
7
|
+
}
|
|
8
|
+
function isActiveAccessibleEnvironment(environment) {
|
|
9
|
+
return environment.accessible && environment.details !== null && environment.details.archivedAt === null;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
4
12
|
//#region src/lib/capabilities.ts
|
|
5
13
|
var NONE = {
|
|
6
14
|
canManageGrants: false,
|
|
@@ -77,6 +85,7 @@ var keys = {
|
|
|
77
85
|
project,
|
|
78
86
|
environment
|
|
79
87
|
],
|
|
88
|
+
personal: (project) => ["personal", project],
|
|
80
89
|
directory: ["directory"],
|
|
81
90
|
report: (member) => ["report", member],
|
|
82
91
|
memberAccess: (member) => ["member-access", member],
|
|
@@ -184,6 +193,11 @@ var queries = {
|
|
|
184
193
|
queryKey: keys.missing(place),
|
|
185
194
|
queryFn: () => uiResult(() => client.environments.missing(`${place.project}/${place.environment}`))
|
|
186
195
|
}),
|
|
196
|
+
/** A project's personal configs, for whoever manages its environments: whose, of what, and their key names. */
|
|
197
|
+
personal: (client, project) => queryOptions({
|
|
198
|
+
queryKey: keys.personal(project),
|
|
199
|
+
queryFn: () => uiResult(() => client.environments.personal(project))
|
|
200
|
+
}),
|
|
187
201
|
/** The live references into and out of a place, and who reads through them, for whoever manages its access. */
|
|
188
202
|
references: (client, path) => queryOptions({
|
|
189
203
|
queryKey: keys.references(path),
|
|
@@ -368,15 +382,29 @@ function shellOf(auth, me, projects) {
|
|
|
368
382
|
serviceSetup: member?.serviceSetup ?? null
|
|
369
383
|
};
|
|
370
384
|
}
|
|
385
|
+
function read(queryClient, options, freshness) {
|
|
386
|
+
return freshness === "fresh" ? queryClient.fetchQuery(options) : queryClient.ensureQueryData({
|
|
387
|
+
...options,
|
|
388
|
+
revalidateIfStale: true
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Whether a tab may open: from the cache, and where the cache says no, from
|
|
393
|
+
* the network, which a no needs before the tab sends anyone away. A stale
|
|
394
|
+
* no could be an account since added back, or a role since given.
|
|
395
|
+
*/
|
|
396
|
+
async function tabOpens(opens) {
|
|
397
|
+
return await opens("cached") || opens("fresh");
|
|
398
|
+
}
|
|
371
399
|
/**
|
|
372
400
|
* The shell, as every loader reads it: from the cache while fresh, so a
|
|
373
401
|
* child route never asks again for what the root has.
|
|
374
402
|
*/
|
|
375
|
-
async function loadShell(queryClient, client) {
|
|
403
|
+
async function loadShell(queryClient, client, freshness = "fresh") {
|
|
376
404
|
const [auth, me, projects] = await Promise.all([
|
|
377
|
-
queryClient
|
|
378
|
-
queryClient
|
|
379
|
-
queryClient
|
|
405
|
+
read(queryClient, queries.auth(client), freshness),
|
|
406
|
+
read(queryClient, queries.me(client), freshness),
|
|
407
|
+
read(queryClient, queries.projects(client), freshness)
|
|
380
408
|
]);
|
|
381
409
|
return shellOf(auth, me, projects);
|
|
382
410
|
}
|
|
@@ -402,6 +430,25 @@ async function loadProject(queryClient, client, slug) {
|
|
|
402
430
|
const found = projectOf(await queryClient.fetchQuery(queries.projects(client)), slug);
|
|
403
431
|
if (found.ok && found.managesAccess) await queryClient.fetchQuery(queries.grants(client, slug));
|
|
404
432
|
}
|
|
433
|
+
/**
|
|
434
|
+
* What an environment's page reads: its secrets and, for whoever reads them,
|
|
435
|
+
* the references that read them from elsewhere and the keys it lacks,
|
|
436
|
+
* rendered with them. Where the project tree the shell holds says you read
|
|
437
|
+
* it, all three are asked at once, one round trip; elsewhere the others wait
|
|
438
|
+
* for the secrets, so a refused visit is one refusal in the log, not three.
|
|
439
|
+
*/
|
|
440
|
+
async function loadEnvironment(queryClient, client, place) {
|
|
441
|
+
const others = () => Promise.all([queryClient.fetchQuery(queries.references(client, `${place.project}/${place.environment}`)), queryClient.fetchQuery(queries.missing(client, place))]);
|
|
442
|
+
const found = projectOf(await queryClient.ensureQueryData(queries.projects(client)), place.project);
|
|
443
|
+
const here = found.ok && found.project.archivedAt === null ? found.project.environments.find((environment) => environment.slug === place.environment) : void 0;
|
|
444
|
+
if (here !== void 0 && isActiveAccessibleEnvironment(here)) {
|
|
445
|
+
const [secrets] = await Promise.all([queryClient.fetchQuery(queries.secrets(client, place)), others()]);
|
|
446
|
+
return secrets;
|
|
447
|
+
}
|
|
448
|
+
const secrets = await queryClient.fetchQuery(queries.secrets(client, place));
|
|
449
|
+
if (secrets.ok) await others();
|
|
450
|
+
return secrets;
|
|
451
|
+
}
|
|
405
452
|
/** The directory pages' read: the directory, for owners. */
|
|
406
453
|
async function loadDirectory(queryClient, client) {
|
|
407
454
|
const shell = await loadShell(queryClient, client);
|
|
@@ -450,18 +497,38 @@ async function loadServiceDirectory(queryClient, client) {
|
|
|
450
497
|
return directory;
|
|
451
498
|
}
|
|
452
499
|
/** Who a user or service account is to the instance, its pages' header: null to anyone who does not run it. */
|
|
453
|
-
async function loadMember(queryClient, client, member) {
|
|
454
|
-
const shell = await loadShell(queryClient, client);
|
|
455
|
-
return queryClient
|
|
500
|
+
async function loadMember(queryClient, client, member, freshness = "fresh") {
|
|
501
|
+
const shell = await loadShell(queryClient, client, freshness);
|
|
502
|
+
return read(queryClient, queries.report(client, member, shell.capabilities.runsInstance), freshness);
|
|
456
503
|
}
|
|
457
504
|
/**
|
|
458
505
|
* What a user's or service account's Access tab reads: their role, scope
|
|
459
506
|
* and the grants you manage, in one request, which the server answers in
|
|
460
507
|
* one query, however many projects they hold grants in.
|
|
461
508
|
*/
|
|
462
|
-
async function loadAccess(queryClient, client, member) {
|
|
463
|
-
const shell = await loadShell(queryClient, client);
|
|
464
|
-
return queryClient
|
|
509
|
+
async function loadAccess(queryClient, client, member, freshness = "fresh") {
|
|
510
|
+
const shell = await loadShell(queryClient, client, freshness);
|
|
511
|
+
return read(queryClient, queries.memberAccess(client, member, listsAccess(shell)), freshness);
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* A user's or service account's page: what every tab but Activity shows,
|
|
515
|
+
* read once by its layout, so its tabs open at once. Who they are, what they
|
|
516
|
+
* hold and, for a service account, how it signs in.
|
|
517
|
+
*/
|
|
518
|
+
async function loadPrincipal(queryClient, client, principalType, principalId) {
|
|
519
|
+
const member = memberRef(principalType, principalId);
|
|
520
|
+
await Promise.all([loadMember(queryClient, client, member), principalType === "service" ? loadSignIn(queryClient, client, member) : loadAccess(queryClient, client, member)]);
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* A service account's Sign-in tab: its bearer tokens and trust bindings, as
|
|
524
|
+
* far as its page shows them (`signInWays`), which it returns: null where it
|
|
525
|
+
* shows neither.
|
|
526
|
+
*/
|
|
527
|
+
async function loadSignIn(queryClient, client, member, freshness = "fresh") {
|
|
528
|
+
const [shell, access] = await Promise.all([loadShell(queryClient, client, freshness), loadAccess(queryClient, client, member, freshness)]);
|
|
529
|
+
const ways = signInWays(shell, access);
|
|
530
|
+
if (ways !== null) await Promise.all([read(queryClient, queries.credentials(client, member, ways.tokens), freshness), read(queryClient, queries.bindings(client, member, ways.workloads), freshness)]);
|
|
531
|
+
return ways;
|
|
465
532
|
}
|
|
466
533
|
/**
|
|
467
534
|
* Whether the caller may ask what someone holds: admins and owners,
|
|
@@ -500,14 +567,22 @@ function managedProjects(projects) {
|
|
|
500
567
|
* change also lands in the audit log, which is always read fresh.
|
|
501
568
|
*/
|
|
502
569
|
var affects = {
|
|
503
|
-
/**
|
|
504
|
-
|
|
505
|
-
|
|
570
|
+
/**
|
|
571
|
+
* A project or environment made, renamed or archived: the tree, where you
|
|
572
|
+
* hold access, and the personal configs listed of it, which go with it.
|
|
573
|
+
*/
|
|
574
|
+
places: () => [
|
|
575
|
+
keys.projects,
|
|
576
|
+
keys.me,
|
|
577
|
+
["personal"]
|
|
578
|
+
],
|
|
579
|
+
/** Secrets written, renamed, restored or archived: the environment, the counts, and the personal configs' key names. */
|
|
506
580
|
secrets: (place) => [
|
|
507
581
|
keys.secrets(place),
|
|
508
582
|
keys.projects,
|
|
509
583
|
["references"],
|
|
510
|
-
["missing"]
|
|
584
|
+
["missing"],
|
|
585
|
+
["personal"]
|
|
511
586
|
],
|
|
512
587
|
/**
|
|
513
588
|
* Someone's access in a project changed: its grants, their report, and, as
|
|
@@ -520,8 +595,18 @@ var affects = {
|
|
|
520
595
|
keys.projects,
|
|
521
596
|
keys.me
|
|
522
597
|
],
|
|
523
|
-
/**
|
|
524
|
-
|
|
598
|
+
/**
|
|
599
|
+
* Someone let in: the directory, and whatever was read of them before
|
|
600
|
+
* they were there, which said there was no such member: a new service
|
|
601
|
+
* account's row asks how it signs in as soon as it shows.
|
|
602
|
+
*/
|
|
603
|
+
admission: (member) => [
|
|
604
|
+
keys.directory,
|
|
605
|
+
keys.report(member),
|
|
606
|
+
keys.memberAccess(member),
|
|
607
|
+
keys.credentials(member),
|
|
608
|
+
keys.bindings(member)
|
|
609
|
+
],
|
|
525
610
|
/**
|
|
526
611
|
* An instance role changed: the directory, their report, and, as it may be
|
|
527
612
|
* your own, what you can see and do.
|
|
@@ -566,6 +651,6 @@ async function refresh(queryClient, touched) {
|
|
|
566
651
|
await Promise.all([...touched, keys.audit].map((queryKey) => queryClient.invalidateQueries({ queryKey })));
|
|
567
652
|
}
|
|
568
653
|
//#endregion
|
|
569
|
-
export {
|
|
654
|
+
export { waysFor as C, isActiveAccessibleEnvironment as E, tabOpens as S, hasEnvironmentDetails as T, projectOf as _, listsAccess as a, shellOf as b, loadEnvironment as c, loadProject as d, loadServiceDirectory as f, managedProjects as g, loadSignIn as h, keys as i, loadMember as l, loadShell as m, createQueryClient as n, listsServices as o, loadSettings as p, hasAppsTab as r, loadDirectory as s, affects as t, loadPrincipal as u, queries as v, canRevealSecrets as w, signInWays as x, refresh as y };
|
|
570
655
|
|
|
571
|
-
//# sourceMappingURL=queries-
|
|
656
|
+
//# sourceMappingURL=queries-epz4MIuW.js.map
|