@coffre/ui 0.4.0 → 0.4.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.
Files changed (38) hide show
  1. package/dist/chunks/connected-apps-CUOyEZXR.js +146 -0
  2. package/dist/chunks/connected-apps-CUOyEZXR.js.map +1 -0
  3. package/dist/chunks/{directory-zr3ek7Mc.js → directory-CxxrnGUL.js} +6 -4
  4. package/dist/chunks/{directory-zr3ek7Mc.js.map → directory-CxxrnGUL.js.map} +1 -1
  5. package/dist/chunks/{grants-Cw1FyGID.js → grants-CXcmhujY.js} +2 -2
  6. package/dist/chunks/{grants-Cw1FyGID.js.map → grants-CXcmhujY.js.map} +1 -1
  7. package/dist/chunks/{offboarding-CE6d7um1.js → offboarding-6eAduCsM.js} +2 -2
  8. package/dist/chunks/offboarding-6eAduCsM.js.map +1 -0
  9. package/dist/chunks/{principal-page-DhjO76GH.js → principal-page-B9R2zPlp.js} +20 -6
  10. package/dist/chunks/principal-page-B9R2zPlp.js.map +1 -0
  11. package/dist/chunks/{use-change-DUiGO19U.js → use-change-CZdI2MJG.js} +30 -7
  12. package/dist/chunks/use-change-CZdI2MJG.js.map +1 -0
  13. package/dist/index.d.ts +24 -4
  14. package/dist/index.js +1 -5
  15. package/dist/index.js.map +1 -1
  16. package/dist/pages/account.js +15 -138
  17. package/dist/pages/account.js.map +1 -1
  18. package/dist/pages/environment.js +1 -1
  19. package/dist/pages/project-access.js +3 -3
  20. package/dist/pages/project-environments.js +2 -2
  21. package/dist/pages/projects.js +2 -2
  22. package/dist/pages/service-account.js +2 -2
  23. package/dist/pages/service-accounts.js +2 -2
  24. package/dist/pages/user.js +1 -1
  25. package/dist/pages/users.js +2 -2
  26. package/package.json +3 -3
  27. package/src/components/connected-apps.tsx +138 -0
  28. package/src/components/directory.tsx +9 -2
  29. package/src/components/offboarding.tsx +1 -1
  30. package/src/components/principal-page.tsx +19 -3
  31. package/src/index.ts +0 -1
  32. package/src/lib/changes.ts +23 -2
  33. package/src/options.ts +0 -7
  34. package/src/pages/account.tsx +10 -112
  35. package/src/register.ts +0 -2
  36. package/dist/chunks/offboarding-CE6d7um1.js.map +0 -1
  37. package/dist/chunks/principal-page-DhjO76GH.js.map +0 -1
  38. package/dist/chunks/use-change-DUiGO19U.js.map +0 -1
@@ -0,0 +1,146 @@
1
+ import { a as ErrorLine, i as EmptyState, t as ConfirmButton, u as Timestamp } from "./ui-DJje3gST.js";
2
+ import { N as Link, it as X, t as Card } from "./page-DvsgZ2Hd.js";
3
+ import { a as rowClass, i as RowPending, r as RowFailure } from "./row-state-DOPUsjQK.js";
4
+ import { n as useChangeStatus, t as useChange } from "./use-change-CZdI2MJG.js";
5
+ import { Fragment } from "react";
6
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
7
+ import { MCP_SCOPE_INFO } from "@coffre/core/mcp";
8
+ //#region src/components/connected-apps.tsx
9
+ /**
10
+ * MCP clients connected as someone: your own on your account page, or a
11
+ * person's on theirs, for an owner. Each row says what the app is, what it
12
+ * may do, and when it was last used; Disconnect stops it at its next request.
13
+ */
14
+ function ConnectedAppsCard({ apps, change, description, empty }) {
15
+ const disconnect = useChange(change);
16
+ const { status, dismiss } = useChangeStatus(change.list.queryKey);
17
+ return /* @__PURE__ */ jsx(Card, {
18
+ labelledBy: "apps",
19
+ title: "Connected apps",
20
+ description,
21
+ children: "error" in apps ? /* @__PURE__ */ jsx("div", {
22
+ className: "card-body",
23
+ children: /* @__PURE__ */ jsx(ErrorLine, { error: apps.error })
24
+ }) : apps.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
25
+ title: "No connected apps",
26
+ children: empty
27
+ }) : /* @__PURE__ */ jsx("div", {
28
+ className: "dt-wrap",
29
+ children: /* @__PURE__ */ jsxs("table", {
30
+ className: "dt stacks stacks-inline",
31
+ children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
32
+ /* @__PURE__ */ jsx("th", { children: "App" }),
33
+ /* @__PURE__ */ jsx("th", { children: "May" }),
34
+ /* @__PURE__ */ jsx("th", {
35
+ className: "col-shrink",
36
+ children: "Last used"
37
+ }),
38
+ /* @__PURE__ */ jsx("th", {
39
+ className: "col-shrink",
40
+ children: "Expires"
41
+ }),
42
+ /* @__PURE__ */ jsx("th", {
43
+ className: "col-actions",
44
+ children: /* @__PURE__ */ jsx("span", {
45
+ className: "visually-hidden",
46
+ children: "Actions"
47
+ })
48
+ })
49
+ ] }) }), /* @__PURE__ */ jsx("tbody", { children: apps.map((app) => {
50
+ const state = status(app.id);
51
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("tr", {
52
+ className: rowClass(state),
53
+ children: [
54
+ /* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsxs("span", {
55
+ className: "cell-account",
56
+ children: [/* @__PURE__ */ jsx(Link, { size: 15 }), /* @__PURE__ */ jsxs("span", {
57
+ className: "cell-stack",
58
+ children: [/* @__PURE__ */ jsxs("span", { children: [
59
+ app.name,
60
+ " ",
61
+ app.registration === "dcr" && /* @__PURE__ */ jsx("span", {
62
+ className: "tag tag-amber",
63
+ title: "It registered itself: its name is its own claim",
64
+ children: "Unverified"
65
+ })
66
+ ] }), /* @__PURE__ */ jsxs("small", { children: [
67
+ app.host === null ? "no website" : /* @__PURE__ */ jsx("span", {
68
+ className: "mono",
69
+ children: app.host
70
+ }),
71
+ " · connected ",
72
+ /* @__PURE__ */ jsx(Timestamp, {
73
+ iso: app.createdAt,
74
+ display: "relative"
75
+ })
76
+ ] })]
77
+ })]
78
+ }) }),
79
+ /* @__PURE__ */ jsx("td", {
80
+ "data-label": "May",
81
+ children: scopeLabels(app)
82
+ }),
83
+ /* @__PURE__ */ jsx("td", {
84
+ className: "nowrap cell-muted",
85
+ "data-label": "Last used",
86
+ children: app.lastUsedAt === null ? "Never" : /* @__PURE__ */ jsx(Timestamp, {
87
+ iso: app.lastUsedAt,
88
+ display: "relative"
89
+ })
90
+ }),
91
+ /* @__PURE__ */ jsx("td", {
92
+ className: "nowrap cell-muted",
93
+ "data-label": "Expires",
94
+ children: /* @__PURE__ */ jsx(Timestamp, {
95
+ iso: app.expiresAt,
96
+ display: "relative"
97
+ })
98
+ }),
99
+ /* @__PURE__ */ jsx("td", {
100
+ className: "col-actions",
101
+ children: state.state === "pending" ? /* @__PURE__ */ jsx(RowPending, { status: state }) : /* @__PURE__ */ jsx(ConfirmButton, {
102
+ trigger: /* @__PURE__ */ jsxs("button", {
103
+ className: "act",
104
+ children: [/* @__PURE__ */ jsx(X, { size: 13 }), "Disconnect"]
105
+ }),
106
+ title: `Disconnect ${app.name}?`,
107
+ body: /* @__PURE__ */ jsxs(Fragment$1, { children: [
108
+ app.name,
109
+ app.host !== null && /* @__PURE__ */ jsxs(Fragment$1, { children: [
110
+ " ",
111
+ "at ",
112
+ /* @__PURE__ */ jsx("span", {
113
+ className: "mono",
114
+ children: app.host
115
+ })
116
+ ] }),
117
+ ", last used",
118
+ " ",
119
+ app.lastUsedAt === null ? "never" : /* @__PURE__ */ jsx(Timestamp, {
120
+ iso: app.lastUsedAt,
121
+ display: "relative"
122
+ }),
123
+ ", stops at its next request. To use it again, connect it again."
124
+ ] }),
125
+ confirmLabel: "Disconnect",
126
+ onConfirm: () => disconnect(app)
127
+ })
128
+ })
129
+ ]
130
+ }), /* @__PURE__ */ jsx(RowFailure, {
131
+ status: state,
132
+ columns: 5,
133
+ onDismiss: () => state.state === "failed" && dismiss(state.mutationId)
134
+ })] }, app.id);
135
+ }) })]
136
+ })
137
+ })
138
+ });
139
+ }
140
+ function scopeLabels(app) {
141
+ return app.scopes.map((scope) => MCP_SCOPE_INFO[scope].label).join(", ");
142
+ }
143
+ //#endregion
144
+ export { ConnectedAppsCard as t };
145
+
146
+ //# sourceMappingURL=connected-apps-CUOyEZXR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connected-apps-CUOyEZXR.js","names":[],"sources":["../../src/components/connected-apps.tsx"],"sourcesContent":["import type { ConnectedApp } from '@coffre/client';\nimport { MCP_SCOPE_INFO } from '@coffre/core/mcp';\nimport { Fragment, type ReactNode } from 'react';\n\nimport type { Change } from '../lib/optimistic';\nimport { useChange, useChangeStatus } from '../lib/use-change';\nimport { Link as LinkIcon, X } from './icons';\nimport { Card } from './page';\nimport { RowFailure, RowPending, rowClass } from './row-state';\nimport { ConfirmButton, EmptyState, ErrorLine, Timestamp } from './ui';\n\n/**\n * MCP clients connected as someone: your own on your account page, or a\n * person's on theirs, for an owner. Each row says what the app is, what it\n * may do, and when it was last used; Disconnect stops it at its next request.\n */\nexport function ConnectedAppsCard<TData>({\n apps,\n change,\n description,\n empty,\n}: {\n apps: ConnectedApp[] | { error: string };\n change: Change<TData, ConnectedApp, ConnectedApp, unknown>;\n description: ReactNode;\n empty: ReactNode;\n}) {\n const disconnect = useChange(change);\n const { status, dismiss } = useChangeStatus(change.list.queryKey);\n return (\n <Card\n labelledBy=\"apps\"\n title=\"Connected apps\"\n description={description}\n >\n {'error' in apps ? (\n <div className=\"card-body\">\n <ErrorLine error={apps.error} />\n </div>\n ) : apps.length === 0 ? (\n <EmptyState title=\"No connected apps\">{empty}</EmptyState>\n ) : (\n <div className=\"dt-wrap\">\n <table className=\"dt stacks stacks-inline\">\n <thead>\n <tr>\n <th>App</th>\n <th>May</th>\n <th className=\"col-shrink\">Last used</th>\n <th className=\"col-shrink\">Expires</th>\n <th className=\"col-actions\">\n <span className=\"visually-hidden\">Actions</span>\n </th>\n </tr>\n </thead>\n <tbody>\n {apps.map((app) => {\n const state = status(app.id);\n return (\n <Fragment key={app.id}>\n <tr className={rowClass(state)}>\n <td>\n <span className=\"cell-account\">\n <LinkIcon size={15} />\n <span className=\"cell-stack\">\n <span>\n {app.name}{' '}\n {app.registration === 'dcr' && (\n <span className=\"tag tag-amber\" title=\"It registered itself: its name is its own claim\">\n Unverified\n </span>\n )}\n </span>\n <small>\n {app.host === null ? 'no website' : <span className=\"mono\">{app.host}</span>}\n {' · connected '}\n <Timestamp iso={app.createdAt} display=\"relative\" />\n </small>\n </span>\n </span>\n </td>\n <td data-label=\"May\">{scopeLabels(app)}</td>\n <td className=\"nowrap cell-muted\" data-label=\"Last used\">\n {app.lastUsedAt === null ? 'Never' : <Timestamp iso={app.lastUsedAt} display=\"relative\" />}\n </td>\n <td className=\"nowrap cell-muted\" data-label=\"Expires\">\n <Timestamp iso={app.expiresAt} display=\"relative\" />\n </td>\n <td className=\"col-actions\">\n {state.state === 'pending' ? (\n <RowPending status={state} />\n ) : (\n <ConfirmButton\n trigger={\n <button className=\"act\">\n <X size={13} />\n Disconnect\n </button>\n }\n title={`Disconnect ${app.name}?`}\n body={\n <>\n {app.name}\n {app.host !== null && (\n <>\n {' '}at <span className=\"mono\">{app.host}</span>\n </>\n )}\n , last used{' '}\n {app.lastUsedAt === null ? 'never' : <Timestamp iso={app.lastUsedAt} display=\"relative\" />},\n stops at its next request. To use it again, connect it again.\n </>\n }\n confirmLabel=\"Disconnect\"\n onConfirm={() => disconnect(app)}\n />\n )}\n </td>\n </tr>\n <RowFailure\n status={state}\n columns={5}\n onDismiss={() => state.state === 'failed' && dismiss(state.mutationId)}\n />\n </Fragment>\n );\n })}\n </tbody>\n </table>\n </div>\n )}\n </Card>\n );\n}\n\nfunction scopeLabels(app: ConnectedApp): string {\n return app.scopes.map((scope) => MCP_SCOPE_INFO[scope].label).join(', ');\n}\n"],"mappings":";;;;;;;;;;;;;AAgBA,SAAgB,kBAAyB,EACvC,MACA,QACA,aACA,SAMC;CACD,MAAM,aAAa,UAAU,MAAM;CACnC,MAAM,EAAE,QAAQ,YAAY,gBAAgB,OAAO,KAAK,QAAQ;CAChE,OACE,oBAAC,MAAD;EACE,YAAW;EACX,OAAM;EACO;YAEZ,WAAW,OACV,oBAAC,OAAD;GAAK,WAAU;aACb,oBAAC,WAAD,EAAW,OAAO,KAAK,MAAQ,CAAA;EAC5B,CAAA,IACH,KAAK,WAAW,IAClB,oBAAC,YAAD;GAAY,OAAM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il, J a
3
3
  import { a as rowClass, i as RowPending, r as RowFailure } from "./row-state-DOPUsjQK.js";
4
4
  import { p as queries } from "./queries-DVR_i3rA.js";
5
5
  import { t as useShell } from "./use-shell-rNKfGjdj.js";
6
- import { h as invite, l as directoryList, n as useChangeStatus, o as changeRole, t as useChange, y as removeMember } from "./use-change-DUiGO19U.js";
6
+ import { b as removeMember, g as invite, l as directoryList, n as useChangeStatus, o as changeRole, t as useChange } from "./use-change-CZdI2MJG.js";
7
7
  import { n as PrincipalLink } from "./principal-BIN-xwZw.js";
8
8
  import { Fragment, useState } from "react";
9
9
  import { Menu } from "@base-ui/react/menu";
@@ -346,7 +346,7 @@ var plural = (count, one) => `${count} ${one}${count === 1 ? "" : "s"}`;
346
346
  * they leave behind to rotate.
347
347
  */
348
348
  function RemovalPreview({ principal, open }) {
349
- const { capabilities } = useShell();
349
+ const { capabilities, features } = useShell();
350
350
  const person = principal.principalType === "user";
351
351
  const { data, isPending } = useQuery({
352
352
  ...queries.report(useCoffre(), memberOf(principal), capabilities.canManageGrants),
@@ -361,12 +361,14 @@ function RemovalPreview({ principal, open }) {
361
361
  ] });
362
362
  if (report === null) return person ? "They are signed out everywhere, and their sign-in accounts and project access are revoked at once." : "Its bearer tokens and trust bindings stop working, and its project access is revoked at once.";
363
363
  const { live } = report;
364
+ const apps = `${plural(live.apps, "connected app")}${report.apps.length > 0 ? ` (${report.apps.map((app) => app.name).join(", ")})` : ""}`;
364
365
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
365
366
  "Removing revokes ",
366
367
  (person ? [
367
368
  plural(live.grants, "grant"),
368
369
  plural(live.sessions, "session"),
369
- plural(live.identities, "linked sign-in account")
370
+ plural(live.identities, "linked sign-in account"),
371
+ ...features.mcp ? [apps] : []
370
372
  ] : [plural(live.grants, "grant"), plural(live.tokens, "bearer token")]).join(", "),
371
373
  " at once",
372
374
  person ? "" : ", and its trust bindings, including for anything running as it now",
@@ -482,4 +484,4 @@ function RoleField({ value, onChange }) {
482
484
  //#endregion
483
485
  export { PrincipalActions as i, InstanceRole as n, KIND as r, DirectoryTable as t };
484
486
 
485
- //# sourceMappingURL=directory-zr3ek7Mc.js.map
487
+ //# sourceMappingURL=directory-CxxrnGUL.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"directory-zr3ek7Mc.js","names":[],"sources":["../../src/components/directory.tsx"],"sourcesContent":["import { Fragment, useState } from 'react';\nimport { useQuery } from '@tanstack/react-query';\nimport { Menu } from '@base-ui/react/menu';\nimport { changeRole, directoryList, invite, removeMember, type InviteVars } from '../lib/changes';\nimport { memberRef, useCoffre } from '../lib/coffre';\nimport { queries } from '../lib/queries';\nimport { useShell } from '../lib/use-shell';\nimport { useChange, useChangeStatus } from '../lib/use-change';\nimport type { DirectoryPrincipal } from '../shared/models';\nimport { RowFailure, RowPending, rowClass } from './row-state';\nimport { ConfirmDialog, EmptyState, MenuPopup, Modal, Spinner, Timestamp, Toggletip } from './ui';\nimport { PrincipalLink } from './principal';\nimport { Clock, Folder, GitHub, Key, Link, Lock, MoreHorizontal, Pencil, Plus, ShieldCheck, User, X } from './icons';\n\n/**\n * The instance directory, shared by the Users and Service accounts pages.\n *\n * Both are rows in the same table on the server (principals, typed user or\n * service); the pages split them because people and machines are looked after\n * differently, not because the model does.\n */\n\ntype PrincipalType = DirectoryPrincipal['principalType'];\n\n/** How the directory, and its changes, name someone to the API: `user:…`, `token:…` (shown `service:…`). */\nexport const memberOf = (principal: Pick<DirectoryPrincipal, 'principalType' | 'principalId'>) =>\n memberRef(principal.principalType, principal.principalId);\n\nexport const ROLE_LABEL: Record<DirectoryPrincipal['instanceRole'], string> = {\n 'root-admin': 'Root admin',\n owner: 'Owner',\n user: 'Member',\n};\n\n/** What each kind of principal is called in the interface. */\nexport const KIND: Record<PrincipalType, string> = {\n user: 'user',\n service: 'service account',\n};\n\nexport function DirectoryTable({\n principalType,\n principals,\n hasRemoved = false,\n}: {\n principalType: PrincipalType;\n principals: DirectoryPrincipal[];\n /** Whether some were removed, listed beneath, so an empty table is not \"yet\". */\n hasRemoved?: boolean;\n}) {\n const users = principalType === 'user';\n const columns = users ? 4 : 6;\n const { status, failedAdds, dismiss } = useChangeStatus(directoryList.queryKey);\n const refused = failedAdds<InviteVars>(principals.map(memberOf)).filter(\n ({ vars }) => vars.principalType === principalType,\n );\n return (\n <>\n <section className=\"card\" aria-label={users ? 'Users' : 'Service accounts'}>\n {principals.length === 0 && refused.length === 0 ? (\n <EmptyState\n title={\n hasRemoved\n ? `No active ${KIND[principalType]}s`\n : users\n ? 'Nobody is registered'\n : 'No service accounts yet'\n }\n >\n {hasRemoved ? `Add a ${KIND[principalType]}` : `Add the first ${KIND[principalType]}`} to let\n it through the door. Project access is a separate step, granted from each project's page.\n </EmptyState>\n ) : (\n <div className=\"dt-wrap\">\n <table className={`dt directory directory-${principalType} stacks${users ? '' : ' stacks-inline'}`}>\n <thead>\n <tr>\n <th className=\"n\">#</th>\n <th className=\"col-principal\">\n <span className=\"th\">\n {users ? <User size={14} /> : <Key size={14} />}\n {users ? 'Email' : 'Name'}\n </span>\n </th>\n {users ? (\n <th className=\"col-role\">\n <span className=\"th\">\n <ShieldCheck size={14} />\n Instance role\n </span>\n </th>\n ) : (\n <>\n <th className=\"col-signin\">\n <span className=\"th\">\n <Link size={14} />\n Signs in with\n </span>\n </th>\n <th className=\"col-access\">\n <span className=\"th\">\n <Folder size={14} />\n Access\n </span>\n </th>\n <th className=\"col-used\">\n <span className=\"th\">\n <Clock size={14} />\n Last used\n </span>\n </th>\n </>\n )}\n <th className=\"col-actions\">\n <span className=\"visually-hidden\">Actions</span>\n </th>\n </tr>\n </thead>\n <tbody>\n {principals.map((principal, index) => {\n const state = status(memberOf(principal));\n return (\n <Fragment key={principal.principalId}>\n <tr className={`row-link ${rowClass(state)}`}>\n <td className=\"n\">{index + 1}</td>\n <td\n className=\"col-lead\"\n data-label={principal.principalType === 'user' ? 'Email' : 'Name'}\n >\n <PrincipalLink\n type={principal.principalType}\n id={principal.principalId}\n stretch\n />\n </td>\n {users ? (\n <td className=\"col-role\" data-label=\"Instance role\">\n <InstanceRole principal={principal} />\n </td>\n ) : (\n <ServiceCells principal={principal} />\n )}\n <td className=\"col-actions\">\n {state.state === 'pending' ? (\n <RowPending status={state} />\n ) : (\n <PrincipalActions principal={principal} />\n )}\n </td>\n </tr>\n <RowFailure\n status={state}\n columns={columns}\n onDismiss={() => state.state === 'failed' && dismiss(state.mutationId)}\n />\n </Fragment>\n );\n })}\n {refused.map(({ mutationId, vars, status: failed }) => (\n <RowFailure\n key={mutationId}\n status={failed}\n columns={columns}\n onDismiss={() => dismiss(mutationId)}\n >\n {vars.principalId} was not added.\n </RowFailure>\n ))}\n </tbody>\n </table>\n </div>\n )}\n </section>\n <div className=\"table-actions\">\n <AddPrincipal principalType={principalType} />\n </div>\n </>\n );\n}\n\nconst PLATFORM: Record<string, string> = {\n github: 'GitHub',\n 'github-reusable': 'GitHub',\n 'github-reusable-organization': 'GitHub',\n gitlab: 'GitLab',\n custom: 'OIDC',\n};\n\n/**\n * What someone scanning service accounts wants of each: how it signs in, where\n * it reaches, and whether it is still in use. Access comes with the list; the\n * bindings and tokens are read per row, as its own page reads them.\n */\nfunction ServiceCells({ principal }: { principal: DirectoryPrincipal }) {\n const client = useCoffre();\n const { auth, capabilities, features } = useShell();\n const member = memberOf(principal);\n // As `loadServiceDirectory` read them, so these come from its cache.\n const allowed = capabilities.canManageGrants && auth.signin !== null;\n // Not suspended: an account added here is shown at once, its facts when they come.\n const { data: bindings } = useQuery(queries.bindings(client, member, capabilities.canManageGrants && features.workloads));\n const { data: credentials } = useQuery(queries.credentials(client, member, allowed));\n\n const platforms = new Map<string, number>();\n const bindingList = bindings?.ok === true ? bindings.bindings : [];\n for (const binding of bindingList) {\n const platform = PLATFORM[binding.profile] ?? 'OIDC';\n platforms.set(platform, (platforms.get(platform) ?? 0) + 1);\n }\n const now = Date.now();\n const tokenList = credentials?.ok === true ? credentials.tokens : [];\n const activeTokens = tokenList.filter((token) => new Date(token.expiresAt).getTime() > now).length;\n const lastUsed = [...bindingList, ...tokenList]\n .map((credential) => credential.lastUsedAt)\n .filter((at): at is string => at !== null)\n .sort()\n .at(-1);\n\n const places = [\n ...new Set(\n (principal.grants ?? []).map(({ project, environment }) =>\n environment === null ? project : `${project}/${environment}`,\n ),\n ),\n ];\n const projects = new Set((principal.grants ?? []).map((grant) => grant.project));\n const loaded = bindings !== undefined && credentials !== undefined;\n\n return (\n <>\n <td className=\"col-signin\" data-label=\"Signs in with\">\n {!loaded ? null : platforms.size === 0 && activeTokens === 0 ? (\n <span className=\"cell-muted\">Nothing yet</span>\n ) : (\n <span className=\"signin-list\">\n {[...platforms].map(([platform, count]) => (\n <span key={platform} className=\"signin-item\">\n {platform === 'GitHub' && <GitHub size={12} />}\n {platform}\n {count > 1 && ` ×${count}`}\n </span>\n ))}\n {activeTokens > 0 && (\n <span className=\"signin-item\">\n <Key size={12} />\n {activeTokens} token{activeTokens === 1 ? '' : 's'}\n </span>\n )}\n </span>\n )}\n </td>\n <td className=\"col-access\" data-label=\"Access\" title={places.join(', ')}>\n {places.length === 0 ? (\n <span className=\"cell-muted\">None</span>\n ) : places.length <= 2 ? (\n <span className=\"mono\">{places.join(', ')}</span>\n ) : (\n `${projects.size} project${projects.size === 1 ? '' : 's'}`\n )}\n </td>\n <td className=\"col-used cell-muted\" data-label=\"Last used\">\n {!loaded ? null : lastUsed === undefined ? 'Never' : <Timestamp iso={lastUsed} display=\"relative\" />}\n </td>\n </>\n );\n}\n\n/**\n * A user's instance role. Service accounts have none worth showing: every one is a\n * plain member. A root admin's role comes from the deployment, so its tag says\n * so on hover or tap instead of offering a menu that could not work.\n */\nexport function InstanceRole({ principal }: { principal: DirectoryPrincipal }) {\n if (principal.tampered === true) {\n return (\n <Toggletip\n label={\n <>\n Their record was changed outside coffre, so the vault refuses them\n everything. Remove them to start them over, then add them again.\n </>\n }\n >\n <button type=\"button\" className=\"tag tag-red tag-button\">\n <Lock size={11} />\n Integrity check failed\n </button>\n </Toggletip>\n );\n }\n if (principal.isRootAdmin) {\n return (\n <Toggletip\n label={\n <>\n Set by <code>rootAdmins</code> in the vault's configuration, so it\n cannot be changed or removed here.\n </>\n }\n >\n <button type=\"button\" className=\"tag tag-violet tag-button\">\n <Lock size={11} />\n Root admin\n </button>\n </Toggletip>\n );\n }\n return (\n <span className={`tag${principal.instanceRole === 'user' ? '' : ' tag-violet'}`}>\n {ROLE_LABEL[principal.instanceRole]}\n </span>\n );\n}\n\n/**\n * Change role and Remove, behind one menu. Root admins get none: the\n * deployment's configuration owns them.\n */\nexport function PrincipalActions({\n principal,\n trigger = 'act act-quiet act-menu',\n}: {\n principal: DirectoryPrincipal;\n /** The menu button's classes: a row action in tables, a button in a page head. */\n trigger?: string;\n}) {\n const [editing, setEditing] = useState(false);\n const [confirming, setConfirming] = useState(false);\n const [instanceRole, setInstanceRole] = useState<'user' | 'owner'>(\n principal.instanceRole === 'owner' ? 'owner' : 'user',\n );\n const coffre = useCoffre();\n const setRole = useChange(changeRole(coffre));\n const remove = useChange(removeMember(coffre));\n const { status } = useChangeStatus(directoryList.queryKey);\n const pending = status(memberOf(principal)).state === 'pending';\n const kind = KIND[principal.principalType];\n\n if (principal.isRootAdmin) return null;\n\n return (\n <>\n <Menu.Root>\n <Menu.Trigger\n className={trigger}\n aria-label={`Actions for ${principal.principalId}`}\n disabled={pending}\n >\n {pending ? <Spinner size={13} /> : <MoreHorizontal size={16} />}\n </Menu.Trigger>\n <MenuPopup align=\"end\">\n {principal.principalType === 'user' && (\n <>\n <Menu.Item\n className=\"menu-item\"\n onClick={() => {\n setInstanceRole(principal.instanceRole === 'owner' ? 'owner' : 'user');\n setEditing(true);\n }}\n >\n <Pencil size={14} />\n Change role\n </Menu.Item>\n <Menu.Separator className=\"menu-sep\" />\n </>\n )}\n <Menu.Item\n className=\"menu-item menu-item-danger\"\n onClick={() => setConfirming(true)}\n >\n <X size={14} />\n Remove {kind}…\n </Menu.Item>\n </MenuPopup>\n </Menu.Root>\n\n {principal.principalType === 'user' && (\n <Modal\n open={editing}\n onOpenChange={setEditing}\n title={\n <>\n Role of <span className=\"mono\">{principal.principalId}</span>\n </>\n }\n >\n <form\n className=\"form\"\n onSubmit={(event) => {\n event.preventDefault();\n // Shown in the list at once; the row says if the server refuses.\n setRole({ principalId: principal.principalId, owner: instanceRole === 'owner' });\n setEditing(false);\n }}\n >\n <RoleField value={instanceRole} onChange={setInstanceRole} />\n <div className=\"dialog-actions\">\n <button className=\"btn\" type=\"button\" onClick={() => setEditing(false)}>\n Cancel\n </button>\n <button className=\"btn btn-primary\" type=\"submit\">\n Save\n </button>\n </div>\n </form>\n </Modal>\n )}\n\n <ConfirmDialog\n open={confirming}\n onOpenChange={setConfirming}\n title={\n <>\n Remove <span className=\"mono\">{principal.principalId}</span>?\n </>\n }\n body={<RemovalPreview principal={principal} open={confirming} />}\n confirmLabel={`Remove ${kind}`}\n onConfirm={() => remove(principal)}\n />\n </>\n );\n}\n\nconst plural = (count: number, one: string) => `${count} ${one}${count === 1 ? '' : 's'}`;\n\n/**\n * What removing someone would do, read when its dialog opens, as `coffre\n * offboard` previews it before `--apply`: every way in it revokes, and what\n * they leave behind to rotate.\n */\nfunction RemovalPreview({ principal, open }: { principal: DirectoryPrincipal; open: boolean }) {\n const { capabilities } = useShell();\n const person = principal.principalType === 'user';\n const { data, isPending } = useQuery({\n ...queries.report(useCoffre(), memberOf(principal), capabilities.canManageGrants),\n enabled: open,\n });\n const report = data?.ok === true ? data.report : null;\n if (isPending) {\n return (\n <>\n <Spinner size={13} /> Reading what {person ? 'they hold' : 'it holds'}…\n </>\n );\n }\n if (report === null) {\n return person\n ? 'They are signed out everywhere, and their sign-in accounts and project access are revoked at once.'\n : 'Its bearer tokens and trust bindings stop working, and its project access is revoked at once.';\n }\n const { live } = report;\n const revokes = person\n ? [plural(live.grants, 'grant'), plural(live.sessions, 'session'), plural(live.identities, 'linked sign-in account')]\n : [plural(live.grants, 'grant'), plural(live.tokens, 'bearer token')];\n return (\n <>\n Removing revokes {revokes.join(', ')} at once\n {person ? '' : ', and its trust bindings, including for anything running as it now'}.{' '}\n {report.exposed.length === 0\n ? `No value ${person ? 'they' : 'it'} saw is still current.`\n : `${plural(report.exposed.length, 'value')} ${person ? 'they' : 'it'} saw ${report.exposed.length === 1 ? 'is' : 'are'} still current: ${person ? 'their' : 'its'} page lists them, to rotate.`}\n {report.issuedTokens.length > 0 &&\n ` ${plural(report.issuedTokens.length, 'bearer token')} ${person ? 'they' : 'it'} issued still ${report.issuedTokens.length === 1 ? 'works' : 'work'}.`}{' '}\n {person ? 'Their' : 'Its'} past actions stay in the audit log.\n </>\n );\n}\n\nexport function AddPrincipal({ principalType }: { principalType: PrincipalType }) {\n const [open, setOpen] = useState(false);\n const [principalId, setPrincipalId] = useState('');\n const [instanceRole, setInstanceRole] = useState<'user' | 'owner'>('user');\n const add = useChange(invite(useCoffre()));\n const kind = KIND[principalType];\n\n function close() {\n setOpen(false);\n setPrincipalId('');\n setInstanceRole('user');\n }\n\n return (\n <>\n <button className=\"btn btn-primary\" onClick={() => setOpen(true)}>\n <Plus size={14} />\n Add {kind}\n </button>\n\n <Modal\n open={open}\n onOpenChange={(next) => (next ? setOpen(true) : close())}\n title={`Add a ${kind}`}\n description={`This lets the ${kind} through the door and nothing more. Grant project access from its page or from each project's.`}\n >\n <form\n className=\"form\"\n onSubmit={(event) => {\n event.preventDefault();\n // Shown in the list at once; the list says if the server refuses.\n add({ principalType, principalId: principalId.trim(), owner: instanceRole === 'owner' });\n close();\n }}\n >\n <label className=\"field\">\n <span className=\"label\">\n {principalType === 'user' ? 'Cloudflare Access email' : 'Service account name'}\n </span>\n <input\n className=\"input input-mono\"\n autoFocus\n spellCheck={false}\n autoComplete=\"off\"\n value={principalId}\n placeholder={\n principalType === 'user' ? 'someone@acme.example' : 'ci-deploy'\n }\n onChange={(event) => setPrincipalId(event.target.value)}\n />\n </label>\n\n {principalType === 'user' && (\n <RoleField value={instanceRole} onChange={setInstanceRole} />\n )}\n\n <div className=\"dialog-actions\">\n <button className=\"btn\" type=\"button\" onClick={close}>\n Cancel\n </button>\n <button className=\"btn btn-primary\" type=\"submit\" disabled={principalId.trim() === ''}>\n Add {kind}\n </button>\n </div>\n </form>\n </Modal>\n </>\n );\n}\n\nfunction RoleField({\n value,\n onChange,\n}: {\n value: 'user' | 'owner';\n onChange: (value: 'user' | 'owner') => void;\n}) {\n return (\n <label className=\"field\">\n <span className=\"label\">Instance role</span>\n <select\n className=\"select\"\n value={value}\n onChange={(event) => onChange(event.target.value as 'user' | 'owner')}\n >\n <option value=\"user\">Member</option>\n <option value=\"owner\">Owner</option>\n </select>\n <span className=\"hint\">\n Owners manage users and service accounts, can create projects, and read the whole audit log.\n Neither role reads a secret without a project grant.\n </span>\n </label>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAyBA,IAAa,YAAY,cACvB,UAAU,UAAU,eAAe,UAAU,WAAW;AAE1D,IAAa,aAAiE;CAC5E,cAAc;CACd,OAAO;CACP,MAAM;AACR;;AAGA,IAAa,OAAsC;CACjD,MAAM;CACN,SAAS;AACX;AAEA,SAAgB,eAAe,EAC7B,eACA,YACA,aAAa,SAMZ;CACD,MAAM,QAAQ,kBAAkB;CAChC,MAAM,UAAU,QAAQ,IAAI;CAC5B,MAAM,EAAE,QAAQ,YAAY,YAAY,gBAAgB,cAAc,QAAQ;CAC9E,MAAM,UAAU,WAAuB,WAAW,IAAI,QAAQ,CAAC,CAAC,CAAC,QAC9D,EAAE,WAAW,KAAK,kBAAkB,aACvC;CACA,OACE,qBAAA,YAAA,EAAA,UAAA,CACE,oBAAC,WAAD;EAAS,WAAU;EAAO,cAAY,QAAQ,UAAU;YACrD,WAAW,WAAW,KAAK,QAAQ,WAAW,IAC7C,qBAAC,YAAD;GACE,OACE,aACI,aAAa,KAAK,eAAe,KACjC,QACE,yBACA;aANV,CASG,aAAa,SAAS,KAAK,mBAAmB,iBAAiB,KAAK,kBAAiB,mGAE5E;OAEZ,oBA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AU;MAAM,MAAK;MAAS,SAAS;gBAAO;KAE9C,CAAA,GACR,qBAAC,UAAD;MAAQ,WAAU;MAAkB,MAAK;MAAS,UAAU,YAAY,KAAK,MAAM;gBAAnF,CAAuF,QAChF,IACC;OACL;;GACD;;CACD,CAAA,CACP,EAAA,CAAA;AAEN;AAEA,SAAS,UAAU,EACjB,OACA,YAIC;CACD,OACE,qBAAC,SAAD;EAAO,WAAU;YAAjB;GACE,oBAAC,QAAD;IAAM,WAAU;cAAQ;GAAmB,CAAA;GAC3C,qBAAC,UAAD;IACE,WAAU;IACH;IACP,WAAW,UAAU,SAAS,MAAM,OAAO,KAAyB;cAHtE,CAKE,oBAAC,UAAD;KAAQ,OAAM;eAAO;IAAc,CAAA,GACnC,oBAAC,UAAD;KAAQ,OAAM;eAAQ;IAAa,CAAA,CAC7B;;GACR,oBAAC,QAAD;IAAM,WAAU;cAAO;GAGjB,CAAA;EACD;;AAEX"}
1
+ {"version":3,"file":"directory-CxxrnGUL.js","names":[],"sources":["../../src/components/directory.tsx"],"sourcesContent":["import { Fragment, useState } from 'react';\nimport { useQuery } from '@tanstack/react-query';\nimport { Menu } from '@base-ui/react/menu';\nimport { changeRole, directoryList, invite, removeMember, type InviteVars } from '../lib/changes';\nimport { memberRef, useCoffre } from '../lib/coffre';\nimport { queries } from '../lib/queries';\nimport { useShell } from '../lib/use-shell';\nimport { useChange, useChangeStatus } from '../lib/use-change';\nimport type { DirectoryPrincipal } from '../shared/models';\nimport { RowFailure, RowPending, rowClass } from './row-state';\nimport { ConfirmDialog, EmptyState, MenuPopup, Modal, Spinner, Timestamp, Toggletip } from './ui';\nimport { PrincipalLink } from './principal';\nimport { Clock, Folder, GitHub, Key, Link, Lock, MoreHorizontal, Pencil, Plus, ShieldCheck, User, X } from './icons';\n\n/**\n * The instance directory, shared by the Users and Service accounts pages.\n *\n * Both are rows in the same table on the server (principals, typed user or\n * service); the pages split them because people and machines are looked after\n * differently, not because the model does.\n */\n\ntype PrincipalType = DirectoryPrincipal['principalType'];\n\n/** How the directory, and its changes, name someone to the API: `user:…`, `token:…` (shown `service:…`). */\nexport const memberOf = (principal: Pick<DirectoryPrincipal, 'principalType' | 'principalId'>) =>\n memberRef(principal.principalType, principal.principalId);\n\nexport const ROLE_LABEL: Record<DirectoryPrincipal['instanceRole'], string> = {\n 'root-admin': 'Root admin',\n owner: 'Owner',\n user: 'Member',\n};\n\n/** What each kind of principal is called in the interface. */\nexport const KIND: Record<PrincipalType, string> = {\n user: 'user',\n service: 'service account',\n};\n\nexport function DirectoryTable({\n principalType,\n principals,\n hasRemoved = false,\n}: {\n principalType: PrincipalType;\n principals: DirectoryPrincipal[];\n /** Whether some were removed, listed beneath, so an empty table is not \"yet\". */\n hasRemoved?: boolean;\n}) {\n const users = principalType === 'user';\n const columns = users ? 4 : 6;\n const { status, failedAdds, dismiss } = useChangeStatus(directoryList.queryKey);\n const refused = failedAdds<InviteVars>(principals.map(memberOf)).filter(\n ({ vars }) => vars.principalType === principalType,\n );\n return (\n <>\n <section className=\"card\" aria-label={users ? 'Users' : 'Service accounts'}>\n {principals.length === 0 && refused.length === 0 ? (\n <EmptyState\n title={\n hasRemoved\n ? `No active ${KIND[principalType]}s`\n : users\n ? 'Nobody is registered'\n : 'No service accounts yet'\n }\n >\n {hasRemoved ? `Add a ${KIND[principalType]}` : `Add the first ${KIND[principalType]}`} to let\n it through the door. Project access is a separate step, granted from each project's page.\n </EmptyState>\n ) : (\n <div className=\"dt-wrap\">\n <table className={`dt directory directory-${principalType} stacks${users ? '' : ' stacks-inline'}`}>\n <thead>\n <tr>\n <th className=\"n\">#</th>\n <th className=\"col-principal\">\n <span className=\"th\">\n {users ? <User size={14} /> : <Key size={14} />}\n {users ? 'Email' : 'Name'}\n </span>\n </th>\n {users ? (\n <th className=\"col-role\">\n <span className=\"th\">\n <ShieldCheck size={14} />\n Instance role\n </span>\n </th>\n ) : (\n <>\n <th className=\"col-signin\">\n <span className=\"th\">\n <Link size={14} />\n Signs in with\n </span>\n </th>\n <th className=\"col-access\">\n <span className=\"th\">\n <Folder size={14} />\n Access\n </span>\n </th>\n <th className=\"col-used\">\n <span className=\"th\">\n <Clock size={14} />\n Last used\n </span>\n </th>\n </>\n )}\n <th className=\"col-actions\">\n <span className=\"visually-hidden\">Actions</span>\n </th>\n </tr>\n </thead>\n <tbody>\n {principals.map((principal, index) => {\n const state = status(memberOf(principal));\n return (\n <Fragment key={principal.principalId}>\n <tr className={`row-link ${rowClass(state)}`}>\n <td className=\"n\">{index + 1}</td>\n <td\n className=\"col-lead\"\n data-label={principal.principalType === 'user' ? 'Email' : 'Name'}\n >\n <PrincipalLink\n type={principal.principalType}\n id={principal.principalId}\n stretch\n />\n </td>\n {users ? (\n <td className=\"col-role\" data-label=\"Instance role\">\n <InstanceRole principal={principal} />\n </td>\n ) : (\n <ServiceCells principal={principal} />\n )}\n <td className=\"col-actions\">\n {state.state === 'pending' ? (\n <RowPending status={state} />\n ) : (\n <PrincipalActions principal={principal} />\n )}\n </td>\n </tr>\n <RowFailure\n status={state}\n columns={columns}\n onDismiss={() => state.state === 'failed' && dismiss(state.mutationId)}\n />\n </Fragment>\n );\n })}\n {refused.map(({ mutationId, vars, status: failed }) => (\n <RowFailure\n key={mutationId}\n status={failed}\n columns={columns}\n onDismiss={() => dismiss(mutationId)}\n >\n {vars.principalId} was not added.\n </RowFailure>\n ))}\n </tbody>\n </table>\n </div>\n )}\n </section>\n <div className=\"table-actions\">\n <AddPrincipal principalType={principalType} />\n </div>\n </>\n );\n}\n\nconst PLATFORM: Record<string, string> = {\n github: 'GitHub',\n 'github-reusable': 'GitHub',\n 'github-reusable-organization': 'GitHub',\n gitlab: 'GitLab',\n custom: 'OIDC',\n};\n\n/**\n * What someone scanning service accounts wants of each: how it signs in, where\n * it reaches, and whether it is still in use. Access comes with the list; the\n * bindings and tokens are read per row, as its own page reads them.\n */\nfunction ServiceCells({ principal }: { principal: DirectoryPrincipal }) {\n const client = useCoffre();\n const { auth, capabilities, features } = useShell();\n const member = memberOf(principal);\n // As `loadServiceDirectory` read them, so these come from its cache.\n const allowed = capabilities.canManageGrants && auth.signin !== null;\n // Not suspended: an account added here is shown at once, its facts when they come.\n const { data: bindings } = useQuery(queries.bindings(client, member, capabilities.canManageGrants && features.workloads));\n const { data: credentials } = useQuery(queries.credentials(client, member, allowed));\n\n const platforms = new Map<string, number>();\n const bindingList = bindings?.ok === true ? bindings.bindings : [];\n for (const binding of bindingList) {\n const platform = PLATFORM[binding.profile] ?? 'OIDC';\n platforms.set(platform, (platforms.get(platform) ?? 0) + 1);\n }\n const now = Date.now();\n const tokenList = credentials?.ok === true ? credentials.tokens : [];\n const activeTokens = tokenList.filter((token) => new Date(token.expiresAt).getTime() > now).length;\n const lastUsed = [...bindingList, ...tokenList]\n .map((credential) => credential.lastUsedAt)\n .filter((at): at is string => at !== null)\n .sort()\n .at(-1);\n\n const places = [\n ...new Set(\n (principal.grants ?? []).map(({ project, environment }) =>\n environment === null ? project : `${project}/${environment}`,\n ),\n ),\n ];\n const projects = new Set((principal.grants ?? []).map((grant) => grant.project));\n const loaded = bindings !== undefined && credentials !== undefined;\n\n return (\n <>\n <td className=\"col-signin\" data-label=\"Signs in with\">\n {!loaded ? null : platforms.size === 0 && activeTokens === 0 ? (\n <span className=\"cell-muted\">Nothing yet</span>\n ) : (\n <span className=\"signin-list\">\n {[...platforms].map(([platform, count]) => (\n <span key={platform} className=\"signin-item\">\n {platform === 'GitHub' && <GitHub size={12} />}\n {platform}\n {count > 1 && ` ×${count}`}\n </span>\n ))}\n {activeTokens > 0 && (\n <span className=\"signin-item\">\n <Key size={12} />\n {activeTokens} token{activeTokens === 1 ? '' : 's'}\n </span>\n )}\n </span>\n )}\n </td>\n <td className=\"col-access\" data-label=\"Access\" title={places.join(', ')}>\n {places.length === 0 ? (\n <span className=\"cell-muted\">None</span>\n ) : places.length <= 2 ? (\n <span className=\"mono\">{places.join(', ')}</span>\n ) : (\n `${projects.size} project${projects.size === 1 ? '' : 's'}`\n )}\n </td>\n <td className=\"col-used cell-muted\" data-label=\"Last used\">\n {!loaded ? null : lastUsed === undefined ? 'Never' : <Timestamp iso={lastUsed} display=\"relative\" />}\n </td>\n </>\n );\n}\n\n/**\n * A user's instance role. Service accounts have none worth showing: every one is a\n * plain member. A root admin's role comes from the deployment, so its tag says\n * so on hover or tap instead of offering a menu that could not work.\n */\nexport function InstanceRole({ principal }: { principal: DirectoryPrincipal }) {\n if (principal.tampered === true) {\n return (\n <Toggletip\n label={\n <>\n Their record was changed outside coffre, so the vault refuses them\n everything. Remove them to start them over, then add them again.\n </>\n }\n >\n <button type=\"button\" className=\"tag tag-red tag-button\">\n <Lock size={11} />\n Integrity check failed\n </button>\n </Toggletip>\n );\n }\n if (principal.isRootAdmin) {\n return (\n <Toggletip\n label={\n <>\n Set by <code>rootAdmins</code> in the vault's configuration, so it\n cannot be changed or removed here.\n </>\n }\n >\n <button type=\"button\" className=\"tag tag-violet tag-button\">\n <Lock size={11} />\n Root admin\n </button>\n </Toggletip>\n );\n }\n return (\n <span className={`tag${principal.instanceRole === 'user' ? '' : ' tag-violet'}`}>\n {ROLE_LABEL[principal.instanceRole]}\n </span>\n );\n}\n\n/**\n * Change role and Remove, behind one menu. Root admins get none: the\n * deployment's configuration owns them.\n */\nexport function PrincipalActions({\n principal,\n trigger = 'act act-quiet act-menu',\n}: {\n principal: DirectoryPrincipal;\n /** The menu button's classes: a row action in tables, a button in a page head. */\n trigger?: string;\n}) {\n const [editing, setEditing] = useState(false);\n const [confirming, setConfirming] = useState(false);\n const [instanceRole, setInstanceRole] = useState<'user' | 'owner'>(\n principal.instanceRole === 'owner' ? 'owner' : 'user',\n );\n const coffre = useCoffre();\n const setRole = useChange(changeRole(coffre));\n const remove = useChange(removeMember(coffre));\n const { status } = useChangeStatus(directoryList.queryKey);\n const pending = status(memberOf(principal)).state === 'pending';\n const kind = KIND[principal.principalType];\n\n if (principal.isRootAdmin) return null;\n\n return (\n <>\n <Menu.Root>\n <Menu.Trigger\n className={trigger}\n aria-label={`Actions for ${principal.principalId}`}\n disabled={pending}\n >\n {pending ? <Spinner size={13} /> : <MoreHorizontal size={16} />}\n </Menu.Trigger>\n <MenuPopup align=\"end\">\n {principal.principalType === 'user' && (\n <>\n <Menu.Item\n className=\"menu-item\"\n onClick={() => {\n setInstanceRole(principal.instanceRole === 'owner' ? 'owner' : 'user');\n setEditing(true);\n }}\n >\n <Pencil size={14} />\n Change role\n </Menu.Item>\n <Menu.Separator className=\"menu-sep\" />\n </>\n )}\n <Menu.Item\n className=\"menu-item menu-item-danger\"\n onClick={() => setConfirming(true)}\n >\n <X size={14} />\n Remove {kind}…\n </Menu.Item>\n </MenuPopup>\n </Menu.Root>\n\n {principal.principalType === 'user' && (\n <Modal\n open={editing}\n onOpenChange={setEditing}\n title={\n <>\n Role of <span className=\"mono\">{principal.principalId}</span>\n </>\n }\n >\n <form\n className=\"form\"\n onSubmit={(event) => {\n event.preventDefault();\n // Shown in the list at once; the row says if the server refuses.\n setRole({ principalId: principal.principalId, owner: instanceRole === 'owner' });\n setEditing(false);\n }}\n >\n <RoleField value={instanceRole} onChange={setInstanceRole} />\n <div className=\"dialog-actions\">\n <button className=\"btn\" type=\"button\" onClick={() => setEditing(false)}>\n Cancel\n </button>\n <button className=\"btn btn-primary\" type=\"submit\">\n Save\n </button>\n </div>\n </form>\n </Modal>\n )}\n\n <ConfirmDialog\n open={confirming}\n onOpenChange={setConfirming}\n title={\n <>\n Remove <span className=\"mono\">{principal.principalId}</span>?\n </>\n }\n body={<RemovalPreview principal={principal} open={confirming} />}\n confirmLabel={`Remove ${kind}`}\n onConfirm={() => remove(principal)}\n />\n </>\n );\n}\n\nconst plural = (count: number, one: string) => `${count} ${one}${count === 1 ? '' : 's'}`;\n\n/**\n * What removing someone would do, read when its dialog opens, as `coffre\n * offboard` previews it before `--apply`: every way in it revokes, and what\n * they leave behind to rotate.\n */\nfunction RemovalPreview({ principal, open }: { principal: DirectoryPrincipal; open: boolean }) {\n const { capabilities, features } = useShell();\n const person = principal.principalType === 'user';\n const { data, isPending } = useQuery({\n ...queries.report(useCoffre(), memberOf(principal), capabilities.canManageGrants),\n enabled: open,\n });\n const report = data?.ok === true ? data.report : null;\n if (isPending) {\n return (\n <>\n <Spinner size={13} /> Reading what {person ? 'they hold' : 'it holds'}…\n </>\n );\n }\n if (report === null) {\n return person\n ? 'They are signed out everywhere, and their sign-in accounts and project access are revoked at once.'\n : 'Its bearer tokens and trust bindings stop working, and its project access is revoked at once.';\n }\n const { live } = report;\n // Named, as an app's name is what its person knows it by: \"2 connected apps (Claude, Cursor)\".\n const apps = `${plural(live.apps, 'connected app')}${report.apps.length > 0 ? ` (${report.apps.map((app) => app.name).join(', ')})` : ''}`;\n const revokes = person\n ? [\n plural(live.grants, 'grant'),\n plural(live.sessions, 'session'),\n plural(live.identities, 'linked sign-in account'),\n ...(features.mcp ? [apps] : []),\n ]\n : [plural(live.grants, 'grant'), plural(live.tokens, 'bearer token')];\n return (\n <>\n Removing revokes {revokes.join(', ')} at once\n {person ? '' : ', and its trust bindings, including for anything running as it now'}.{' '}\n {report.exposed.length === 0\n ? `No value ${person ? 'they' : 'it'} saw is still current.`\n : `${plural(report.exposed.length, 'value')} ${person ? 'they' : 'it'} saw ${report.exposed.length === 1 ? 'is' : 'are'} still current: ${person ? 'their' : 'its'} page lists them, to rotate.`}\n {report.issuedTokens.length > 0 &&\n ` ${plural(report.issuedTokens.length, 'bearer token')} ${person ? 'they' : 'it'} issued still ${report.issuedTokens.length === 1 ? 'works' : 'work'}.`}{' '}\n {person ? 'Their' : 'Its'} past actions stay in the audit log.\n </>\n );\n}\n\nexport function AddPrincipal({ principalType }: { principalType: PrincipalType }) {\n const [open, setOpen] = useState(false);\n const [principalId, setPrincipalId] = useState('');\n const [instanceRole, setInstanceRole] = useState<'user' | 'owner'>('user');\n const add = useChange(invite(useCoffre()));\n const kind = KIND[principalType];\n\n function close() {\n setOpen(false);\n setPrincipalId('');\n setInstanceRole('user');\n }\n\n return (\n <>\n <button className=\"btn btn-primary\" onClick={() => setOpen(true)}>\n <Plus size={14} />\n Add {kind}\n </button>\n\n <Modal\n open={open}\n onOpenChange={(next) => (next ? setOpen(true) : close())}\n title={`Add a ${kind}`}\n description={`This lets the ${kind} through the door and nothing more. Grant project access from its page or from each project's.`}\n >\n <form\n className=\"form\"\n onSubmit={(event) => {\n event.preventDefault();\n // Shown in the list at once; the list says if the server refuses.\n add({ principalType, principalId: principalId.trim(), owner: instanceRole === 'owner' });\n close();\n }}\n >\n <label className=\"field\">\n <span className=\"label\">\n {principalType === 'user' ? 'Cloudflare Access email' : 'Service account name'}\n </span>\n <input\n className=\"input input-mono\"\n autoFocus\n spellCheck={false}\n autoComplete=\"off\"\n value={principalId}\n placeholder={\n principalType === 'user' ? 'someone@acme.example' : 'ci-deploy'\n }\n onChange={(event) => setPrincipalId(event.target.value)}\n />\n </label>\n\n {principalType === 'user' && (\n <RoleField value={instanceRole} onChange={setInstanceRole} />\n )}\n\n <div className=\"dialog-actions\">\n <button className=\"btn\" type=\"button\" onClick={close}>\n Cancel\n </button>\n <button className=\"btn btn-primary\" type=\"submit\" disabled={principalId.trim() === ''}>\n Add {kind}\n </button>\n </div>\n </form>\n </Modal>\n </>\n );\n}\n\nfunction RoleField({\n value,\n onChange,\n}: {\n value: 'user' | 'owner';\n onChange: (value: 'user' | 'owner') => void;\n}) {\n return (\n <label className=\"field\">\n <span className=\"label\">Instance role</span>\n <select\n className=\"select\"\n value={value}\n onChange={(event) => onChange(event.target.value as 'user' | 'owner')}\n >\n <option value=\"user\">Member</option>\n <option value=\"owner\">Owner</option>\n </select>\n <span className=\"hint\">\n Owners manage users and service accounts, can create projects, and read the whole audit log.\n Neither role reads a secret without a project grant.\n </span>\n </label>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAyBA,IAAa,YAAY,cACvB,UAAU,UAAU,eAAe,UAAU,WAAW;AAE1D,IAAa,aAAiE;CAC5E,cAAc;CACd,OAAO;CACP,MAAM;AACR;;AAGA,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OAAM;eAAO;IAAc,CAAA,GACnC,oBAAC,UAAD;KAAQ,OAAM;eAAQ;IAAa,CAAA,CAC7B;;GACR,oBAAC,QAAD;IAAM,WAAU;cAAO;GAGjB,CAAA;EACD;;AAEX"}
@@ -3,7 +3,7 @@ import { J as ShieldCheck, U as Plus, it as X, j as Layers, s as memberRef, u as
3
3
  import { a as rowClass, i as RowPending, r as RowFailure } from "./row-state-DOPUsjQK.js";
4
4
  import { p as queries, r as keys, t as affects } from "./queries-DVR_i3rA.js";
5
5
  import { t as useShell } from "./use-shell-rNKfGjdj.js";
6
- import { C as revokeGrant, k as projectAccessLabel, m as grantId, n as useChangeStatus, t as useChange } from "./use-change-DUiGO19U.js";
6
+ import { A as projectAccessLabel, h as grantId, n as useChangeStatus, t as useChange, w as revokeGrant } from "./use-change-CZdI2MJG.js";
7
7
  import { a as useAction, i as slugProblem } from "./validation-D312_NLf.js";
8
8
  import { useState } from "react";
9
9
  import { toast } from "sonner";
@@ -666,4 +666,4 @@ function useRefusedGrants(project, grants, principalType) {
666
666
  //#endregion
667
667
  export { EveryProjectGrants as a, useEveryProject as c, accessPatch as d, dateFromExpiry as f, withLevel as g, withEnvironment as h, useRefusedGrants as i, ExpiryField as l, planFromGrants as m, GrantsTable as n, ReachedBy as o, environmentAccess as p, RefusedGrants as r, reaching as s, GrantRowView as t, accessChanges as u };
668
668
 
669
- //# sourceMappingURL=grants-Cw1FyGID.js.map
669
+ //# sourceMappingURL=grants-CXcmhujY.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"grants-Cw1FyGID.js","names":[],"sources":["../../src/lib/access-plan.ts","../../src/components/expiry-field.tsx","../../src/components/every-project.tsx","../../src/components/grants.tsx"],"sourcesContent":["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 { useSuspenseQuery } from '@tanstack/react-query';\nimport { toast } from 'sonner';\nimport type { InheritedGrant } from '@coffre/client';\nimport { assignableToEnvironment, EVERY_PROJECT, ROLE_NAMES, ROLES, type Role } from '@coffre/core/access';\nimport { memberRef, useCoffre } from '../lib/coffre';\nimport { affects, queries } from '../lib/queries';\nimport { useAction } from '../lib/use-action';\nimport { useShell } from '../lib/use-shell';\nimport { slugProblem } from '../lib/validation';\nimport { ExpiryField } from './expiry-field';\nimport { GrantsTable } from './grants';\nimport { Layers, Plus } from './icons';\nimport { ConfirmButton, ErrorLine, Modal, Notice, Spinner } from './ui';\n\n/**\n * Grants on every project (`*`, the projects made later too) and on one\n * environment slug in every project (`*` and the slug): only owners give\n * and take them, here, from the CLI or the API; the pages show who holds\n * them to whoever sees the grants of a project they reach.\n */\n\n/** Where a grant on every project is, as people read it: \"All projects\", or \"dev in every project\". */\nexport function everyProjectPlace(environmentSlug: string | null): string {\n return environmentSlug === null ? 'All projects' : `${environmentSlug} in every project`;\n}\n\n/** The slug a grant on every project covers, from its path: null for `*`. */\nfunction slugOf(place: string): string | null {\n return place === '*' ? null : place.slice('*/'.length);\n}\n\n/** The grants on every project, for those shown them: who makes places, and who manages access. */\nexport function useEveryProject(): InheritedGrant[] {\n const { data } = useSuspenseQuery(queries.projects(useCoffre()));\n return data.ok ? data.everyProject : [];\n}\n\n/** Those grants that reach a place: a project (`environment` null), or an environment of that slug. */\nexport function reaching(grants: InheritedGrant[], environment: string | null): InheritedGrant[] {\n return grants.filter((grant) => grant.place === '*' || (environment !== null && slugOf(grant.place) === environment));\n}\n\n/** A member as a line names them: `ada@acme.example`, or a token's name. */\nfunction who(member: string): string {\n return member.slice(member.indexOf(':') + 1);\n}\n\n/**\n * Who reaches a place through grants on every project, said in its dialog\n * before it is made or renamed: making a place there gives them access at once.\n */\nexport function ReachedBy({ grants, lead }: { grants: InheritedGrant[]; lead: string }) {\n if (grants.length === 0) return null;\n return (\n <Notice tone=\"info\">\n {lead}{' '}\n {grants.map((grant, index) => (\n <span key={`${grant.member} ${grant.place}`}>\n {index > 0 && ', '}\n <strong className=\"mono\">{who(grant.member)}</strong> ({grant.roleName.toLowerCase()},{' '}\n {everyProjectPlace(slugOf(grant.place)).toLowerCase()})\n </span>\n ))}\n .\n </Notice>\n );\n}\n\n/**\n * One member's grants on every project, on their Access tab: \"All projects ·\n * Developer\". Owners grant and revoke them here; whoever else sees them, as\n * on a project they reach, sees them only.\n */\nexport function EveryProjectGrants({ principalType, principalId }: { principalType: 'user' | 'service'; principalId: string }) {\n const member = memberRef(principalType, principalId);\n const { capabilities } = useShell();\n const owner = capabilities.canManageGrants;\n const grants = useEveryProject().filter((grant) => grant.member === member);\n if (grants.length === 0 && !owner) return null;\n return (\n <section className=\"every-project\" aria-label=\"Access to every project\">\n <h2 className=\"section-title\">Every project</h2>\n {grants.length > 0 && (\n <section className=\"card\">\n <GrantsTable\n lead={\n <span className=\"th\">\n <Layers size={14} />\n Where\n </span>\n }\n >\n {grants.map((grant, index) => (\n <EveryProjectRow key={grant.place} number={index + 1} grant={grant} principalId={principalId} owner={owner} />\n ))}\n </GrantsTable>\n </section>\n )}\n {owner ? (\n <div className=\"table-actions\">\n <GrantEveryProject principalType={principalType} principalId={principalId} />\n </div>\n ) : (\n <p className=\"hint section-foot\">Only owners grant or revoke on every project.</p>\n )}\n </section>\n );\n}\n\nfunction EveryProjectRow({ number, grant, principalId, owner }: { number: number; grant: InheritedGrant; principalId: string; owner: boolean }) {\n const coffre = useCoffre();\n const { pending, error, run } = useAction();\n const where = everyProjectPlace(slugOf(grant.place));\n return (\n <>\n <tr>\n <td className=\"n\">{number}</td>\n <td className=\"col-lead\" data-label=\"Where\">\n {where}\n </td>\n <td className=\"col-access\" data-label=\"Permissions\">\n <span className={`tag${grant.role === 'owner' ? ' tag-violet' : ''}`}>{grant.roleName}</span>\n </td>\n <td className={`col-expires cell-mono cell-muted${grant.expiresAt === null ? ' is-never' : ''}`} data-label=\"Expires\">\n {grant.expiresAt === null ? 'Never' : grant.expiresAt.slice(0, 10)}\n </td>\n <td className=\"col-actions\">\n {owner && (\n <ConfirmButton\n trigger={\n <button className=\"act act-danger\" disabled={pending}>\n Revoke\n </button>\n }\n title={\n <>\n Revoke {grant.roleName.toLowerCase()} on {where.toLowerCase()} from <span className=\"mono\">{principalId}</span>?\n </>\n }\n body={\n <>\n They lose it at once, wherever it reaches, including any process using it right now.\n Grants they hold on projects themselves still apply.\n </>\n }\n confirmLabel=\"Revoke access\"\n onConfirm={() =>\n run(() => coffre.access.set(grant.member, { [grant.place]: null }), {\n affects: affects.everyProject(grant.member),\n onSuccess: () => toast.success(`Revoked ${grant.roleName.toLowerCase()} on ${where.toLowerCase()}`),\n })\n }\n />\n )}\n </td>\n </tr>\n {error !== null && (\n <tr>\n <td colSpan={5}>\n <ErrorLine error={error} />\n </td>\n </tr>\n )}\n </>\n );\n}\n\n/** The roles a grant on every project takes: all of them, or, on one environment name, those an environment can hold. */\nconst ROLE_CHOICES: { role: Role; name: string; environment: boolean }[] = ROLE_NAMES.map((role) => ({\n role,\n name: ROLES[role].name,\n environment: assignableToEnvironment(role),\n}));\n\n/**\n * Give a member a role on every project, the ones created later too, or on\n * one environment name in every project. Owners only, as the API.\n */\nfunction GrantEveryProject({ principalType, principalId }: { principalType: 'user' | 'service'; principalId: string }) {\n const coffre = useCoffre();\n const member = memberRef(principalType, principalId);\n const [open, setOpen] = useState(false);\n const [environment, setEnvironment] = useState('');\n const [role, setRole] = useState<Role>('viewer');\n const [expiresAt, setExpiresAt] = useState<string | null>(null);\n const { pending, error, setError, run } = useAction();\n const slug = environment.trim();\n const slugError = slug === '' ? null : slugProblem(slug);\n const roles = ROLE_CHOICES.filter((choice) => slug === '' || choice.environment);\n const chosen = roles.some((choice) => choice.role === role) ? role : 'viewer';\n const where = everyProjectPlace(slug === '' ? null : slug);\n\n function close() {\n setOpen(false);\n setEnvironment('');\n setRole('viewer');\n setExpiresAt(null);\n setError(null);\n }\n\n return (\n <>\n <button className=\"btn\" onClick={() => setOpen(true)}>\n <Plus size={14} />\n Grant on every project\n </button>\n\n <Modal\n open={open}\n onOpenChange={(next) => (next ? setOpen(true) : close())}\n title={\n <>\n Grant <span className=\"mono\">{principalId}</span> on every project\n </>\n }\n description=\"A role on every project, including ones created later. With an environment name, only the environment of that name in each project.\"\n >\n <form\n className=\"form\"\n onSubmit={(event) => {\n event.preventDefault();\n const place = slug === '' ? EVERY_PROJECT : `${EVERY_PROJECT}/${slug}`;\n run(() => coffre.access.set(member, { [place]: expiresAt === null ? chosen : { role: chosen, until: expiresAt } }), {\n affects: affects.everyProject(member),\n onSuccess: () => {\n toast.success(`Granted ${ROLES[chosen].name.toLowerCase()} on ${where.toLowerCase()}`);\n close();\n },\n });\n }}\n >\n <label className=\"field\">\n <span className=\"label\">Environment name</span>\n <input\n className=\"input input-mono\"\n spellCheck={false}\n autoComplete=\"off\"\n placeholder=\"Every environment\"\n value={environment}\n aria-invalid={slugError !== null}\n aria-describedby=\"every-project-environment-hint\"\n onChange={(event) => setEnvironment(event.target.value)}\n />\n <span className={`hint${slugError !== null ? ' edit-note-error' : ''}`} id=\"every-project-environment-hint\">\n {slugError ??\n (slug === ''\n ? 'Every environment of every project.'\n : `Only the environment named ${slug} in each project, including projects created later.`)}\n </span>\n </label>\n\n <div className=\"form-row\">\n <label className=\"field\" style={{ flexGrow: 2 }}>\n <span className=\"label\">Role</span>\n <select className=\"select\" value={chosen} onChange={(event) => setRole(event.target.value as Role)}>\n {roles.map((choice) => (\n <option key={choice.role} value={choice.role}>\n {choice.name}\n </option>\n ))}\n </select>\n </label>\n <label className=\"field\">\n <span className=\"label\">Expires</span>\n <ExpiryField label=\"Expires\" expiresAt={expiresAt} onChange={setExpiresAt} />\n </label>\n </div>\n\n <p className=\"hint\">\n {where} · {ROLES[chosen].name}: {ROLES[chosen].description}\n </p>\n <ErrorLine error={error} />\n\n <div className=\"dialog-actions\">\n <button className=\"btn\" type=\"button\" onClick={close}>\n Cancel\n </button>\n <button className=\"btn btn-primary\" type=\"submit\" disabled={pending || slugError !== null}>\n {pending ? <Spinner /> : 'Grant'}\n </button>\n </div>\n </form>\n </Modal>\n </>\n );\n}\n","import type { ReactNode } from 'react';\nimport { grantId, revokeGrant, type GrantVars } from '../lib/changes';\nimport type { FailedAdd } from '../lib/optimistic';\nimport { useCoffre } from '../lib/coffre';\nimport { projectAccessLabel } from '../lib/project-access';\nimport { everyProjectPlace } from './every-project';\nimport { keys } from '../lib/queries';\nimport { useChange, useChangeStatus } from '../lib/use-change';\nimport type { GrantRow } from '../shared/models';\nimport { RowFailure, RowPending, rowClass } from './row-state';\nimport { ConfirmButton } from './ui';\nimport { Clock, ShieldCheck } from './icons';\n\n/**\n * Grants as a table: who or where in the first column, then the access, when\n * it lapses, and a revoke.\n *\n * A project's page leads each row with the principal; a user's page leads with\n * the project. Everything after the first column is the same grant either way.\n */\nexport function GrantsTable({ lead, children }: { lead: ReactNode; children: ReactNode }) {\n return (\n <div className=\"dt-wrap\">\n <table className=\"dt grants stacks\">\n <thead>\n <tr>\n <th className=\"n\">#</th>\n <th className=\"col-principal\">{lead}</th>\n <th>\n <span className=\"th\">\n <ShieldCheck size={14} />\n Permissions\n </span>\n </th>\n <th className=\"col-expires\">\n <span className=\"th\">\n <Clock size={14} />\n Expires\n </span>\n </th>\n <th className=\"col-actions\">\n <span className=\"visually-hidden\">Actions</span>\n </th>\n </tr>\n </thead>\n <tbody>{children}</tbody>\n </table>\n </div>\n );\n}\n\nexport function GrantRowView({\n number,\n project,\n grant,\n lead,\n leadLabel,\n}: {\n number: number;\n project: string;\n grant: GrantRow;\n lead: ReactNode;\n leadLabel: string;\n}) {\n const revoke = useChange(revokeGrant(useCoffre(), project));\n const { status, dismiss } = useChangeStatus(keys.grants(project));\n const state = status(grantId(grant));\n // A grant on every project is shown where it reaches, and changed only by owners, with the CLI.\n const everywhere = grant.scope === 'every-project';\n const label = everywhere ? `${everyProjectPlace(grant.environmentSlug)} · ${grant.roleName}` : projectAccessLabel(grant);\n const expired = grant.expiresAt !== null && new Date(grant.expiresAt).getTime() < Date.now();\n\n return (\n <>\n <tr className={rowClass(state)}>\n <td className=\"n\">{number}</td>\n <td className=\"col-lead\" data-label={leadLabel}>\n {lead}\n </td>\n <td className=\"col-access\" data-label=\"Permissions\">\n <span className={`tag${grant.role === 'owner' ? ' tag-violet' : ''}`}>{label}</span>\n </td>\n <td\n className={`col-expires cell-mono cell-muted${grant.expiresAt === null ? ' is-never' : ''}`}\n data-label=\"Expires\"\n >\n {grant.expiresAt === null ? (\n 'Never'\n ) : (\n <>\n <span className=\"narrow-only\">Expires </span>\n {grant.expiresAt.slice(0, 10)}\n {expired && (\n <>\n {' '}\n <span className=\"tag tag-red\">Expired</span>\n </>\n )}\n </>\n )}\n </td>\n <td className=\"col-actions\">\n {state.state === 'pending' ? (\n <RowPending status={state} />\n ) : everywhere ? (\n <span className=\"cell-muted every-project-note\" title=\"Owners change grants on every project with coffre grant '*' and coffre revoke '*'\">\n every project\n </span>\n ) : (\n <ConfirmButton\n trigger={<button className=\"act act-danger\">Revoke</button>}\n title={\n <>\n Revoke {label} from <span className=\"mono\">{grant.principalId}</span>?\n </>\n }\n body={\n <>\n They lose <strong>{label}</strong> on <span className=\"mono\">{project}</span>{' '}\n immediately, including any process using it right now. Other grants they hold\n still apply.\n </>\n }\n confirmLabel=\"Revoke access\"\n onConfirm={() => revoke(grant)}\n />\n )}\n </td>\n </tr>\n <RowFailure\n status={state}\n columns={5}\n onDismiss={() => state.state === 'failed' && dismiss(state.mutationId)}\n />\n </>\n );\n}\n\n/**\n * Grants the server refused to give: rolled back, so no row of theirs is\n * left, and listed here, after the table's rows, saying why.\n */\nexport function RefusedGrants({ refused }: { refused: RefusedGrant[] }) {\n return refused.map(({ mutationId, vars, status, dismiss }) => (\n <RowFailure key={mutationId} status={status} columns={5} onDismiss={dismiss}>\n {vars.principalId} was not given {vars.roleName.toLowerCase()}.\n </RowFailure>\n ));\n}\n\ntype RefusedGrant = FailedAdd<GrantVars> & { dismiss: () => void };\n\n/** The grants of one kind the server refused to give in a project, still to be said. */\nexport function useRefusedGrants(project: string, grants: GrantRow[], principalType?: GrantRow['principalType']): RefusedGrant[] {\n const { failedAdds, dismiss } = useChangeStatus(keys.grants(project));\n return failedAdds<GrantVars>(grants.map(grantId))\n .filter(({ vars }) => principalType === undefined || vars.principalType === principalType)\n .map((refused) => ({ ...refused, dismiss: () => dismiss(refused.mutationId) }));\n}\n"],"mappings":";;;;;;;;;;;;;;AAoCA,SAAgB,kBAAkB,MAAkB,MAAwC;CAC1F,OAAO,OAAO,OAAO,KAAK,cAAc,IAAI,IAAI,KAAK,aAAa,QAAQ;AAC5E;;;;;AAMA,SAAgB,eACd,QACA,cACY;CACZ,IAAI,OAAO,WAAW,GAAG,OAAO;EAAE,OAAO;EAAQ,WAAW;EAAM,cAAc,CAAC;CAAE;CAEnF,MAAM,CAAC,QAAQ;CACf,IACE,OAAO,WAAW,KAClB,KAAK,oBAAoB,SACxB,KAAK,SAAS,WAAW,KAAK,SAAS,YAAY,KAAK,SAAS,cAElE,OAAO;EAAE,OAAO,KAAK;EAAM,WAAW,KAAK;EAAW,cAAc,CAAC;CAAE;CAGzE,MAA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AAQ,MAAM,UAAU;CACtE,CAAA,CACD,EAAA,CAAA;AAEN;;;;;AAMA,SAAgB,cAAc,EAAE,WAAwC;CACtE,OAAO,QAAQ,KAAK,EAAE,YAAY,MAAM,QAAQ,cAC9C,qBAAC,YAAD;EAAqC;EAAQ,SAAS;EAAG,WAAW;YAApE;GACG,KAAK;GAAY;GAAgB,KAAK,SAAS,YAAY;GAAE;EACpD;IAFK,UAEL,CACb;AACH;;AAKA,SAAgB,iBAAiB,SAAiB,QAAoB,eAA2D;CAC/H,MAAM,EAAE,YAAY,YAAY,gBAAgB,KAAK,OAAO,OAAO,CAAC;CACpE,OAAO,WAAsB,OAAO,IAAI,OAAO,CAAC,CAAC,CAC9C,QAAQ,EAAE,WAAW,kBAAkB,KAAA,KAAa,KAAK,kBAAkB,aAAa,CAAC,CACzF,KAAK,aAAa;EAAE,GAAG;EAAS,eAAe,QAAQ,QAAQ,UAAU;CAAE,EAAE;AAClF"}
1
+ {"version":3,"file":"grants-CXcmhujY.js","names":[],"sources":["../../src/lib/access-plan.ts","../../src/components/expiry-field.tsx","../../src/components/every-project.tsx","../../src/components/grants.tsx"],"sourcesContent":["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 { useSuspenseQuery } from '@tanstack/react-query';\nimport { toast } from 'sonner';\nimport type { InheritedGrant } from '@coffre/client';\nimport { assignableToEnvironment, EVERY_PROJECT, ROLE_NAMES, ROLES, type Role } from '@coffre/core/access';\nimport { memberRef, useCoffre } from '../lib/coffre';\nimport { affects, queries } from '../lib/queries';\nimport { useAction } from '../lib/use-action';\nimport { useShell } from '../lib/use-shell';\nimport { slugProblem } from '../lib/validation';\nimport { ExpiryField } from './expiry-field';\nimport { GrantsTable } from './grants';\nimport { Layers, Plus } from './icons';\nimport { ConfirmButton, ErrorLine, Modal, Notice, Spinner } from './ui';\n\n/**\n * Grants on every project (`*`, the projects made later too) and on one\n * environment slug in every project (`*` and the slug): only owners give\n * and take them, here, from the CLI or the API; the pages show who holds\n * them to whoever sees the grants of a project they reach.\n */\n\n/** Where a grant on every project is, as people read it: \"All projects\", or \"dev in every project\". */\nexport function everyProjectPlace(environmentSlug: string | null): string {\n return environmentSlug === null ? 'All projects' : `${environmentSlug} in every project`;\n}\n\n/** The slug a grant on every project covers, from its path: null for `*`. */\nfunction slugOf(place: string): string | null {\n return place === '*' ? null : place.slice('*/'.length);\n}\n\n/** The grants on every project, for those shown them: who makes places, and who manages access. */\nexport function useEveryProject(): InheritedGrant[] {\n const { data } = useSuspenseQuery(queries.projects(useCoffre()));\n return data.ok ? data.everyProject : [];\n}\n\n/** Those grants that reach a place: a project (`environment` null), or an environment of that slug. */\nexport function reaching(grants: InheritedGrant[], environment: string | null): InheritedGrant[] {\n return grants.filter((grant) => grant.place === '*' || (environment !== null && slugOf(grant.place) === environment));\n}\n\n/** A member as a line names them: `ada@acme.example`, or a token's name. */\nfunction who(member: string): string {\n return member.slice(member.indexOf(':') + 1);\n}\n\n/**\n * Who reaches a place through grants on every project, said in its dialog\n * before it is made or renamed: making a place there gives them access at once.\n */\nexport function ReachedBy({ grants, lead }: { grants: InheritedGrant[]; lead: string }) {\n if (grants.length === 0) return null;\n return (\n <Notice tone=\"info\">\n {lead}{' '}\n {grants.map((grant, index) => (\n <span key={`${grant.member} ${grant.place}`}>\n {index > 0 && ', '}\n <strong className=\"mono\">{who(grant.member)}</strong> ({grant.roleName.toLowerCase()},{' '}\n {everyProjectPlace(slugOf(grant.place)).toLowerCase()})\n </span>\n ))}\n .\n </Notice>\n );\n}\n\n/**\n * One member's grants on every project, on their Access tab: \"All projects ·\n * Developer\". Owners grant and revoke them here; whoever else sees them, as\n * on a project they reach, sees them only.\n */\nexport function EveryProjectGrants({ principalType, principalId }: { principalType: 'user' | 'service'; principalId: string }) {\n const member = memberRef(principalType, principalId);\n const { capabilities } = useShell();\n const owner = capabilities.canManageGrants;\n const grants = useEveryProject().filter((grant) => grant.member === member);\n if (grants.length === 0 && !owner) return null;\n return (\n <section className=\"every-project\" aria-label=\"Access to every project\">\n <h2 className=\"section-title\">Every project</h2>\n {grants.length > 0 && (\n <section className=\"card\">\n <GrantsTable\n lead={\n <span className=\"th\">\n <Layers size={14} />\n Where\n </span>\n }\n >\n {grants.map((grant, index) => (\n <EveryProjectRow key={grant.place} number={index + 1} grant={grant} principalId={principalId} owner={owner} />\n ))}\n </GrantsTable>\n </section>\n )}\n {owner ? (\n <div className=\"table-actions\">\n <GrantEveryProject principalType={principalType} principalId={principalId} />\n </div>\n ) : (\n <p className=\"hint section-foot\">Only owners grant or revoke on every project.</p>\n )}\n </section>\n );\n}\n\nfunction EveryProjectRow({ number, grant, principalId, owner }: { number: number; grant: InheritedGrant; principalId: string; owner: boolean }) {\n const coffre = useCoffre();\n const { pending, error, run } = useAction();\n const where = everyProjectPlace(slugOf(grant.place));\n return (\n <>\n <tr>\n <td className=\"n\">{number}</td>\n <td className=\"col-lead\" data-label=\"Where\">\n {where}\n </td>\n <td className=\"col-access\" data-label=\"Permissions\">\n <span className={`tag${grant.role === 'owner' ? ' tag-violet' : ''}`}>{grant.roleName}</span>\n </td>\n <td className={`col-expires cell-mono cell-muted${grant.expiresAt === null ? ' is-never' : ''}`} data-label=\"Expires\">\n {grant.expiresAt === null ? 'Never' : grant.expiresAt.slice(0, 10)}\n </td>\n <td className=\"col-actions\">\n {owner && (\n <ConfirmButton\n trigger={\n <button className=\"act act-danger\" disabled={pending}>\n Revoke\n </button>\n }\n title={\n <>\n Revoke {grant.roleName.toLowerCase()} on {where.toLowerCase()} from <span className=\"mono\">{principalId}</span>?\n </>\n }\n body={\n <>\n They lose it at once, wherever it reaches, including any process using it right now.\n Grants they hold on projects themselves still apply.\n </>\n }\n confirmLabel=\"Revoke access\"\n onConfirm={() =>\n run(() => coffre.access.set(grant.member, { [grant.place]: null }), {\n affects: affects.everyProject(grant.member),\n onSuccess: () => toast.success(`Revoked ${grant.roleName.toLowerCase()} on ${where.toLowerCase()}`),\n })\n }\n />\n )}\n </td>\n </tr>\n {error !== null && (\n <tr>\n <td colSpan={5}>\n <ErrorLine error={error} />\n </td>\n </tr>\n )}\n </>\n );\n}\n\n/** The roles a grant on every project takes: all of them, or, on one environment name, those an environment can hold. */\nconst ROLE_CHOICES: { role: Role; name: string; environment: boolean }[] = ROLE_NAMES.map((role) => ({\n role,\n name: ROLES[role].name,\n environment: assignableToEnvironment(role),\n}));\n\n/**\n * Give a member a role on every project, the ones created later too, or on\n * one environment name in every project. Owners only, as the API.\n */\nfunction GrantEveryProject({ principalType, principalId }: { principalType: 'user' | 'service'; principalId: string }) {\n const coffre = useCoffre();\n const member = memberRef(principalType, principalId);\n const [open, setOpen] = useState(false);\n const [environment, setEnvironment] = useState('');\n const [role, setRole] = useState<Role>('viewer');\n const [expiresAt, setExpiresAt] = useState<string | null>(null);\n const { pending, error, setError, run } = useAction();\n const slug = environment.trim();\n const slugError = slug === '' ? null : slugProblem(slug);\n const roles = ROLE_CHOICES.filter((choice) => slug === '' || choice.environment);\n const chosen = roles.some((choice) => choice.role === role) ? role : 'viewer';\n const where = everyProjectPlace(slug === '' ? null : slug);\n\n function close() {\n setOpen(false);\n setEnvironment('');\n setRole('viewer');\n setExpiresAt(null);\n setError(null);\n }\n\n return (\n <>\n <button className=\"btn\" onClick={() => setOpen(true)}>\n <Plus size={14} />\n Grant on every project\n </button>\n\n <Modal\n open={open}\n onOpenChange={(next) => (next ? setOpen(true) : close())}\n title={\n <>\n Grant <span className=\"mono\">{principalId}</span> on every project\n </>\n }\n description=\"A role on every project, including ones created later. With an environment name, only the environment of that name in each project.\"\n >\n <form\n className=\"form\"\n onSubmit={(event) => {\n event.preventDefault();\n const place = slug === '' ? EVERY_PROJECT : `${EVERY_PROJECT}/${slug}`;\n run(() => coffre.access.set(member, { [place]: expiresAt === null ? chosen : { role: chosen, until: expiresAt } }), {\n affects: affects.everyProject(member),\n onSuccess: () => {\n toast.success(`Granted ${ROLES[chosen].name.toLowerCase()} on ${where.toLowerCase()}`);\n close();\n },\n });\n }}\n >\n <label className=\"field\">\n <span className=\"label\">Environment name</span>\n <input\n className=\"input input-mono\"\n spellCheck={false}\n autoComplete=\"off\"\n placeholder=\"Every environment\"\n value={environment}\n aria-invalid={slugError !== null}\n aria-describedby=\"every-project-environment-hint\"\n onChange={(event) => setEnvironment(event.target.value)}\n />\n <span className={`hint${slugError !== null ? ' edit-note-error' : ''}`} id=\"every-project-environment-hint\">\n {slugError ??\n (slug === ''\n ? 'Every environment of every project.'\n : `Only the environment named ${slug} in each project, including projects created later.`)}\n </span>\n </label>\n\n <div className=\"form-row\">\n <label className=\"field\" style={{ flexGrow: 2 }}>\n <span className=\"label\">Role</span>\n <select className=\"select\" value={chosen} onChange={(event) => setRole(event.target.value as Role)}>\n {roles.map((choice) => (\n <option key={choice.role} value={choice.role}>\n {choice.name}\n </option>\n ))}\n </select>\n </label>\n <label className=\"field\">\n <span className=\"label\">Expires</span>\n <ExpiryField label=\"Expires\" expiresAt={expiresAt} onChange={setExpiresAt} />\n </label>\n </div>\n\n <p className=\"hint\">\n {where} · {ROLES[chosen].name}: {ROLES[chosen].description}\n </p>\n <ErrorLine error={error} />\n\n <div className=\"dialog-actions\">\n <button className=\"btn\" type=\"button\" onClick={close}>\n Cancel\n </button>\n <button className=\"btn btn-primary\" type=\"submit\" disabled={pending || slugError !== null}>\n {pending ? <Spinner /> : 'Grant'}\n </button>\n </div>\n </form>\n </Modal>\n </>\n );\n}\n","import type { ReactNode } from 'react';\nimport { grantId, revokeGrant, type GrantVars } from '../lib/changes';\nimport type { FailedAdd } from '../lib/optimistic';\nimport { useCoffre } from '../lib/coffre';\nimport { projectAccessLabel } from '../lib/project-access';\nimport { everyProjectPlace } from './every-project';\nimport { keys } from '../lib/queries';\nimport { useChange, useChangeStatus } from '../lib/use-change';\nimport type { GrantRow } from '../shared/models';\nimport { RowFailure, RowPending, rowClass } from './row-state';\nimport { ConfirmButton } from './ui';\nimport { Clock, ShieldCheck } from './icons';\n\n/**\n * Grants as a table: who or where in the first column, then the access, when\n * it lapses, and a revoke.\n *\n * A project's page leads each row with the principal; a user's page leads with\n * the project. Everything after the first column is the same grant either way.\n */\nexport function GrantsTable({ lead, children }: { lead: ReactNode; children: ReactNode }) {\n return (\n <div className=\"dt-wrap\">\n <table className=\"dt grants stacks\">\n <thead>\n <tr>\n <th className=\"n\">#</th>\n <th className=\"col-principal\">{lead}</th>\n <th>\n <span className=\"th\">\n <ShieldCheck size={14} />\n Permissions\n </span>\n </th>\n <th className=\"col-expires\">\n <span className=\"th\">\n <Clock size={14} />\n Expires\n </span>\n </th>\n <th className=\"col-actions\">\n <span className=\"visually-hidden\">Actions</span>\n </th>\n </tr>\n </thead>\n <tbody>{children}</tbody>\n </table>\n </div>\n );\n}\n\nexport function GrantRowView({\n number,\n project,\n grant,\n lead,\n leadLabel,\n}: {\n number: number;\n project: string;\n grant: GrantRow;\n lead: ReactNode;\n leadLabel: string;\n}) {\n const revoke = useChange(revokeGrant(useCoffre(), project));\n const { status, dismiss } = useChangeStatus(keys.grants(project));\n const state = status(grantId(grant));\n // A grant on every project is shown where it reaches, and changed only by owners, with the CLI.\n const everywhere = grant.scope === 'every-project';\n const label = everywhere ? `${everyProjectPlace(grant.environmentSlug)} · ${grant.roleName}` : projectAccessLabel(grant);\n const expired = grant.expiresAt !== null && new Date(grant.expiresAt).getTime() < Date.now();\n\n return (\n <>\n <tr className={rowClass(state)}>\n <td className=\"n\">{number}</td>\n <td className=\"col-lead\" data-label={leadLabel}>\n {lead}\n </td>\n <td className=\"col-access\" data-label=\"Permissions\">\n <span className={`tag${grant.role === 'owner' ? ' tag-violet' : ''}`}>{label}</span>\n </td>\n <td\n className={`col-expires cell-mono cell-muted${grant.expiresAt === null ? ' is-never' : ''}`}\n data-label=\"Expires\"\n >\n {grant.expiresAt === null ? (\n 'Never'\n ) : (\n <>\n <span className=\"narrow-only\">Expires </span>\n {grant.expiresAt.slice(0, 10)}\n {expired && (\n <>\n {' '}\n <span className=\"tag tag-red\">Expired</span>\n </>\n )}\n </>\n )}\n </td>\n <td className=\"col-actions\">\n {state.state === 'pending' ? (\n <RowPending status={state} />\n ) : everywhere ? (\n <span className=\"cell-muted every-project-note\" title=\"Owners change grants on every project with coffre grant '*' and coffre revoke '*'\">\n every project\n </span>\n ) : (\n <ConfirmButton\n trigger={<button className=\"act act-danger\">Revoke</button>}\n title={\n <>\n Revoke {label} from <span className=\"mono\">{grant.principalId}</span>?\n </>\n }\n body={\n <>\n They lose <strong>{label}</strong> on <span className=\"mono\">{project}</span>{' '}\n immediately, including any process using it right now. Other grants they hold\n still apply.\n </>\n }\n confirmLabel=\"Revoke access\"\n onConfirm={() => revoke(grant)}\n />\n )}\n </td>\n </tr>\n <RowFailure\n status={state}\n columns={5}\n onDismiss={() => state.state === 'failed' && dismiss(state.mutationId)}\n />\n </>\n );\n}\n\n/**\n * Grants the server refused to give: rolled back, so no row of theirs is\n * left, and listed here, after the table's rows, saying why.\n */\nexport function RefusedGrants({ refused }: { refused: RefusedGrant[] }) {\n return refused.map(({ mutationId, vars, status, dismiss }) => (\n <RowFailure key={mutationId} status={status} columns={5} onDismiss={dismiss}>\n {vars.principalId} was not given {vars.roleName.toLowerCase()}.\n </RowFailure>\n ));\n}\n\ntype RefusedGrant = FailedAdd<GrantVars> & { dismiss: () => void };\n\n/** The grants of one kind the server refused to give in a project, still to be said. */\nexport function useRefusedGrants(project: string, grants: GrantRow[], principalType?: GrantRow['principalType']): RefusedGrant[] {\n const { failedAdds, dismiss } = useChangeStatus(keys.grants(project));\n return failedAdds<GrantVars>(grants.map(grantId))\n .filter(({ vars }) => principalType === undefined || vars.principalType === principalType)\n .map((refused) => ({ ...refused, dismiss: () => dismiss(refused.mutationId) }));\n}\n"],"mappings":";;;;;;;;;;;;;;AAoCA,SAAgB,kBAAkB,MAAkB,MAAwC;CAC1F,OAAO,OAAO,OAAO,KAAK,cAAc,IAAI,IAAI,KAAK,aAAa,QAAQ;AAC5E;;;;;AAMA,SAAgB,eACd,QACA,cACY;CACZ,IAAI,OAAO,WAAW,GAAG,OAAO;EAAE,OAAO;EAAQ,WAAW;EAAM,cAAc,CAAC;CAAE;CAEnF,MAAM,CAAC,QAAQ;CACf,IACE,OAAO,WAAW,KAClB,KAAK,oBAAoB,SACxB,KAAK,SAAS,WAAW,KAAK,SAAS,YAAY,KAAK,SAAS,cAElE,OAAO;EAAE,OAAO,KAAK;EAAM,WAAW,KAAK;EAAW,cAAc,CAAC;CAAE;CAGzE,MAAM,iBAAoD,CAAC;CAC3D,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,OAAO,MAAM;EACnB,IACE,SAAS,QACT,CAAC,aAAa,SAAS,IAAI,KAC3B,OAAO,OAAO,gBAAgB,IAAI,KACjC,MAAM,SAAS,YAAY,MAAM,SAAS,aAE3C,OAAO;GAAE,OAAO;GAAU,WAAW;GAAM,cAAc,CAAC;EAAE;EAE9D,eAAe,QAAQ;GAAE,MAAM,MAAM;GAAM,WAAW,MAAM;EAAU;CACxE;CACA,OAAO;EAAE,OAAO;EAA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AAY,gBAAgB,KAAK,OAAO,OAAO,CAAC;CACpE,OAAO,WAAsB,OAAO,IAAI,OAAO,CAAC,CAAC,CAC9C,QAAQ,EAAE,WAAW,kBAAkB,KAAA,KAAa,KAAK,kBAAkB,aAAa,CAAC,CACzF,KAAK,aAAa;EAAE,GAAG;EAAS,eAAe,QAAQ,QAAQ,UAAU;CAAE,EAAE;AAClF"}
@@ -43,7 +43,7 @@ function RemovedNotice({ report }) {
43
43
  ] }),
44
44
  ".",
45
45
  " ",
46
- person ? "Their project access, sessions, CLI logins and linked sign-in accounts were revoked at the same time, so adding them again starts from nothing." : "Its project access and every token issued to it were revoked at the same time, so adding it again starts from nothing."
46
+ person ? "Their project access, sessions, CLI logins, linked sign-in accounts and connected apps were revoked at the same time, so adding them again starts from nothing." : "Its project access and every token issued to it were revoked at the same time, so adding it again starts from nothing."
47
47
  ] })
48
48
  });
49
49
  }
@@ -302,4 +302,4 @@ function IssuedTokens({ report }) {
302
302
  //#endregion
303
303
  export { RemovedList as n, RemovedNotice as r, PrincipalReportCards as t };
304
304
 
305
- //# sourceMappingURL=offboarding-CE6d7um1.js.map
305
+ //# sourceMappingURL=offboarding-6eAduCsM.js.map