@coffre/ui 0.5.1 → 0.6.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 (120) hide show
  1. package/dist/chunks/{affordances-Bqdevf7w.js → affordances-Dtyha68j.js} +11 -3
  2. package/dist/chunks/affordances-Dtyha68j.js.map +1 -0
  3. package/dist/chunks/{audit-sentence-Cm5nby5k.js → audit-sentence-CUUMshIp.js} +22 -6
  4. package/dist/chunks/audit-sentence-CUUMshIp.js.map +1 -0
  5. package/dist/chunks/{connected-apps-DTNS7YmY.js → connected-apps-DTpatjge.js} +5 -5
  6. package/dist/chunks/{connected-apps-DTNS7YmY.js.map → connected-apps-DTpatjge.js.map} +1 -1
  7. package/dist/chunks/{delete-place-CIaOq0mt.js → delete-place-SOOYVt6A.js} +5 -5
  8. package/dist/chunks/{delete-place-CIaOq0mt.js.map → delete-place-SOOYVt6A.js.map} +1 -1
  9. package/dist/chunks/{directory-DSVt5Tya.js → directory-DrtdKny2.js} +60 -37
  10. package/dist/chunks/directory-DrtdKny2.js.map +1 -0
  11. package/dist/chunks/{folders-CoGK9oqg.js → folders-hR2Lnk0k.js} +3 -3
  12. package/dist/chunks/{folders-CoGK9oqg.js.map → folders-hR2Lnk0k.js.map} +1 -1
  13. package/dist/chunks/{grants-CRU7yZhL.js → grants-DDBui9YD.js} +6 -6
  14. package/dist/chunks/{grants-CRU7yZhL.js.map → grants-DDBui9YD.js.map} +1 -1
  15. package/dist/chunks/{offboarding-DVBSiJRZ.js → offboarding-C7ECW5o0.js} +5 -5
  16. package/dist/chunks/{offboarding-DVBSiJRZ.js.map → offboarding-C7ECW5o0.js.map} +1 -1
  17. package/dist/chunks/{page-DvsgZ2Hd.js → page-JTORvh-N.js} +7 -3
  18. package/dist/chunks/page-JTORvh-N.js.map +1 -0
  19. package/dist/chunks/{principal-BIN-xwZw.js → principal-DFBswTBr.js} +2 -2
  20. package/dist/chunks/{principal-BIN-xwZw.js.map → principal-DFBswTBr.js.map} +1 -1
  21. package/dist/chunks/{principal-page-BEBr_zW7.js → principal-page-CB6dAABC.js} +17 -19
  22. package/dist/chunks/principal-page-CB6dAABC.js.map +1 -0
  23. package/dist/chunks/{project-page-B3TZ5_ig.js → project-page-BHNUvr2L.js} +3 -3
  24. package/dist/chunks/{project-page-B3TZ5_ig.js.map → project-page-BHNUvr2L.js.map} +1 -1
  25. package/dist/chunks/{queries-DE5nK2y4.js → queries-DgQo3mC-.js} +27 -12
  26. package/dist/chunks/queries-DgQo3mC-.js.map +1 -0
  27. package/dist/chunks/{references-uv4Mli9z.js → references-BQc35Q9g.js} +5 -5
  28. package/dist/chunks/{references-uv4Mli9z.js.map → references-BQc35Q9g.js.map} +1 -1
  29. package/dist/chunks/{role-field-DWhkRY6n.js → role-field-BfWRCqzl.js} +14 -7
  30. package/dist/chunks/role-field-BfWRCqzl.js.map +1 -0
  31. package/dist/chunks/{row-state-DOPUsjQK.js → row-state-Zf3kZVhd.js} +13 -5
  32. package/dist/chunks/row-state-Zf3kZVhd.js.map +1 -0
  33. package/dist/chunks/{signin-errors--ykMFuqN.js → signin-errors-TlQmQe0t.js} +2 -2
  34. package/dist/chunks/signin-errors-TlQmQe0t.js.map +1 -0
  35. package/dist/chunks/{theme-DJuz-xLM.js → theme-B6-V9JvY.js} +3 -3
  36. package/dist/chunks/{theme-DJuz-xLM.js.map → theme-B6-V9JvY.js.map} +1 -1
  37. package/dist/chunks/{ui-DJje3gST.js → ui-Br-dNUTc.js} +2 -2
  38. package/dist/chunks/{ui-DJje3gST.js.map → ui-Br-dNUTc.js.map} +1 -1
  39. package/dist/chunks/{use-action-BRgvbUWt.js → use-action-DthL5hL8.js} +3 -3
  40. package/dist/chunks/{use-action-BRgvbUWt.js.map → use-action-DthL5hL8.js.map} +1 -1
  41. package/dist/chunks/{use-change-BJ3dCFHb.js → use-change-By4cG8bT.js} +31 -19
  42. package/dist/chunks/use-change-By4cG8bT.js.map +1 -0
  43. package/dist/chunks/{use-shell-BO4ZTr1y.js → use-shell-D6kjSPls.js} +3 -3
  44. package/dist/chunks/{use-shell-BO4ZTr1y.js.map → use-shell-D6kjSPls.js.map} +1 -1
  45. package/dist/index.d.ts +6 -7
  46. package/dist/index.js +8 -9
  47. package/dist/index.js.map +1 -1
  48. package/dist/pages/account.js +12 -13
  49. package/dist/pages/account.js.map +1 -1
  50. package/dist/pages/approval.js +2 -2
  51. package/dist/pages/audit.js +5 -5
  52. package/dist/pages/audit.js.map +1 -1
  53. package/dist/pages/device-login.js +2 -2
  54. package/dist/pages/environment.js +837 -155
  55. package/dist/pages/environment.js.map +1 -1
  56. package/dist/pages/login.js +4 -4
  57. package/dist/pages/oauth-authorize.js +2 -2
  58. package/dist/pages/project-access.js +160 -80
  59. package/dist/pages/project-access.js.map +1 -1
  60. package/dist/pages/project-environments.js +10 -10
  61. package/dist/pages/project-settings.js +8 -8
  62. package/dist/pages/project.js +3 -3
  63. package/dist/pages/projects.js +10 -10
  64. package/dist/pages/projects.js.map +1 -1
  65. package/dist/pages/service-account.js +537 -109
  66. package/dist/pages/service-account.js.map +1 -1
  67. package/dist/pages/service-accounts.js +5 -5
  68. package/dist/pages/settings.js +8 -18
  69. package/dist/pages/settings.js.map +1 -1
  70. package/dist/pages/unregistered.js +3 -3
  71. package/dist/pages/unregistered.js.map +1 -1
  72. package/dist/pages/user.js +6 -6
  73. package/dist/pages/users.js +5 -5
  74. package/package.json +3 -3
  75. package/src/components/affordances.ts +13 -1
  76. package/src/components/directory.tsx +50 -36
  77. package/src/components/generate-value.tsx +362 -0
  78. package/src/components/github-picker.tsx +83 -0
  79. package/src/components/icons.tsx +4 -0
  80. package/src/components/masked.tsx +60 -0
  81. package/src/components/missing.tsx +3 -3
  82. package/src/components/multi-combobox.tsx +94 -0
  83. package/src/components/principal-page.tsx +8 -12
  84. package/src/components/principal-picker.tsx +68 -18
  85. package/src/components/role-field.tsx +7 -5
  86. package/src/components/row-state.tsx +7 -3
  87. package/src/components/shell.tsx +0 -1
  88. package/src/components/trusted-workloads.tsx +157 -62
  89. package/src/lib/audit-sentences.ts +25 -3
  90. package/src/lib/bindings.ts +125 -14
  91. package/src/lib/capabilities.ts +15 -9
  92. package/src/lib/changes.ts +15 -9
  93. package/src/lib/coffre.ts +2 -0
  94. package/src/lib/generate.ts +160 -0
  95. package/src/lib/queries.ts +19 -5
  96. package/src/lib/secret-edit-batch.ts +38 -5
  97. package/src/lib/secret-order.ts +23 -0
  98. package/src/lib/shortcuts.ts +9 -0
  99. package/src/lib/signin-errors.ts +1 -1
  100. package/src/lib/use-github-lookup.ts +70 -0
  101. package/src/pages/account.tsx +1 -2
  102. package/src/pages/audit.tsx +1 -1
  103. package/src/pages/environment.tsx +241 -119
  104. package/src/pages/project-access.tsx +19 -8
  105. package/src/pages/projects.tsx +3 -3
  106. package/src/pages/settings.tsx +0 -10
  107. package/src/pages/unregistered.tsx +1 -1
  108. package/src/parity.ts +3 -1
  109. package/src/shared/models.ts +2 -2
  110. package/src/styles/globals.css +303 -19
  111. package/dist/chunks/affordances-Bqdevf7w.js.map +0 -1
  112. package/dist/chunks/audit-sentence-Cm5nby5k.js.map +0 -1
  113. package/dist/chunks/directory-DSVt5Tya.js.map +0 -1
  114. package/dist/chunks/page-DvsgZ2Hd.js.map +0 -1
  115. package/dist/chunks/principal-page-BEBr_zW7.js.map +0 -1
  116. package/dist/chunks/queries-DE5nK2y4.js.map +0 -1
  117. package/dist/chunks/role-field-DWhkRY6n.js.map +0 -1
  118. package/dist/chunks/row-state-DOPUsjQK.js.map +0 -1
  119. package/dist/chunks/signin-errors--ykMFuqN.js.map +0 -1
  120. package/dist/chunks/use-change-BJ3dCFHb.js.map +0 -1
@@ -17,7 +17,7 @@ function administrationEntries(capabilities, { users, services, audit }) {
17
17
  ];
18
18
  }
19
19
  /** Project creation exists before a grantable resource, so it follows the instance role and its scope (`makesProjects`). */
20
- function RootAdminOnly({ capabilities, children }) {
20
+ function MakesProjectsOnly({ capabilities, children }) {
21
21
  return capabilities.canCreateProject ? children : null;
22
22
  }
23
23
  /** Empty project copy must distinguish an empty instance from archived-only state. */
@@ -30,7 +30,15 @@ function ProjectEmptyStateCopy({ capabilities, hasArchivedProjects }) {
30
30
  function SecretReadOnly({ canReveal, children }) {
31
31
  return canReveal ? children : null;
32
32
  }
33
+ /**
34
+ * Whether an Owner's tag greys out with "Set by deployment": the deployment names
35
+ * this Owner, and the viewer is someone who could otherwise change Owners. Anyone
36
+ * else sees the plain Owner tag, as nothing is theirs to change.
37
+ */
38
+ function setByDeployment(principal, capabilities) {
39
+ return principal.declared === true && principal.instanceRole === "owner" && capabilities.ownsInstance;
40
+ }
33
41
  //#endregion
34
- export { administrationEntries as a, SecretReadOnly as i, ProjectEmptyStateCopy as n, RootAdminOnly as r, AdministrationItems as t };
42
+ export { administrationEntries as a, SecretReadOnly as i, MakesProjectsOnly as n, setByDeployment as o, ProjectEmptyStateCopy as r, AdministrationItems as t };
35
43
 
36
- //# sourceMappingURL=affordances-Bqdevf7w.js.map
44
+ //# sourceMappingURL=affordances-Dtyha68j.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"affordances-Dtyha68j.js","names":[],"sources":["../../src/components/affordances.ts"],"sourcesContent":["import {\n createElement,\n Fragment,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport type { UiCapabilities } from '../lib/capabilities';\n\ntype AdministrationItemsProps = {\n capabilities: UiCapabilities;\n users: ReactNode;\n services: ReactNode;\n audit: ReactNode;\n};\n\n/** The shared ordering and visibility rule for administration destinations. */\nexport function AdministrationItems({\n capabilities,\n users,\n services,\n audit,\n}: AdministrationItemsProps): ReactElement {\n return createElement(\n Fragment,\n null,\n ...administrationEntries(capabilities, { users: [users], services: [services], audit: [audit] }),\n );\n}\n\n/** The same rule, for destinations kept as data (the command palette's). */\nexport function administrationEntries<T>(\n capabilities: UiCapabilities,\n { users, services, audit }: { users: T[]; services: T[]; audit: T[] },\n): T[] {\n return [\n ...(capabilities.canManageGrants ? users : []),\n // Service accounts, to whoever sets one up too: they see those they manage.\n ...(capabilities.canManageGrants || capabilities.setsUpServices ? services : []),\n ...(capabilities.canReadAudit ? audit : []),\n ];\n}\n\n/** Project creation exists before a grantable resource, so it follows the instance role and its scope (`makesProjects`). */\nexport function MakesProjectsOnly({\n capabilities,\n children,\n}: {\n capabilities: UiCapabilities;\n children: ReactNode;\n}): ReactNode {\n return capabilities.canCreateProject ? children : null;\n}\n\n/** Empty project copy must distinguish an empty instance from archived-only state. */\nexport function ProjectEmptyStateCopy({\n capabilities,\n hasArchivedProjects,\n}: {\n capabilities: UiCapabilities;\n hasArchivedProjects: boolean;\n}): ReactNode {\n if (hasArchivedProjects) {\n return capabilities.canCreateProject\n ? 'No active projects. Start a new one, or restore one from the archive below.'\n : 'No active projects. Your archived projects appear below.';\n }\n\n if (capabilities.canCreateProject) {\n return 'No projects exist yet. Start the first one with New project.';\n }\n\n return createElement(\n Fragment,\n null,\n 'No project is visible to you. Someone holding ',\n createElement('span', { className: 'mono' }, 'grant.manage'),\n ' on a project can add you.',\n );\n}\n\n/** Reveal- and history-shaped controls require secret.read in this environment. */\nexport function SecretReadOnly({\n canReveal,\n children,\n}: {\n canReveal: boolean;\n children: ReactNode;\n}): ReactNode {\n return canReveal ? children : null;\n}\n\n/**\n * Whether an Owner's tag greys out with \"Set by deployment\": the deployment names\n * this Owner, and the viewer is someone who could otherwise change Owners. Anyone\n * else sees the plain Owner tag, as nothing is theirs to change.\n */\nexport function setByDeployment(\n principal: { instanceRole: string; declared?: boolean },\n capabilities: Pick<UiCapabilities, 'ownsInstance'>,\n): boolean {\n return principal.declared === true && principal.instanceRole === 'owner' && capabilities.ownsInstance;\n}\n"],"mappings":";;;AAgBA,SAAgB,oBAAoB,EAClC,cACA,OACA,UACA,SACyC;CACzC,OAAO,cACL,UACA,MACA,GAAG,sBAAsB,cAAc;EAAE,OAAO,CAAC,KAAK;EAAG,UAAU,CAAC,QAAQ;EAAG,OAAO,CAAC,KAAK;CAAE,CAAC,CACjG;AACF;;AAGA,SAAgB,sBACd,cACA,EAAE,OAAO,UAAU,SACd;CACL,OAAO;EACL,GAAI,aAAa,kBAAkB,QAAQ,CAAC;EAE5C,GAAI,aAAa,mBAAmB,aAAa,iBAAiB,WAAW,CAAC;EAC9E,GAAI,aAAa,eAAe,QAAQ,CAAC;CAC3C;AACF;;AAGA,SAAgB,kBAAkB,EAChC,cACA,YAIY;CACZ,OAAO,aAAa,mBAAmB,WAAW;AACpD;;AAGA,SAAgB,sBAAsB,EACpC,cACA,uBAIY;CACZ,IAAI,qBACF,OAAO,aAAa,mBAChB,gFACA;CAGN,IAAI,aAAa,kBACf,OAAO;CAGT,OAAO,cACL,UACA,MACA,kDACA,cAAc,QAAQ,EAAE,WAAW,OAAO,GAAG,cAAc,GAC3D,4BACF;AACF;;AAGA,SAAgB,eAAe,EAC7B,WACA,YAIY;CACZ,OAAO,YAAY,WAAW;AAChC;;;;;;AAOA,SAAgB,gBACd,WACA,cACS;CACT,OAAO,UAAU,aAAa,QAAQ,UAAU,iBAAiB,WAAW,aAAa;AAC3F"}
@@ -1,4 +1,4 @@
1
- import { m as breakAfterUnderscores } from "./ui-DJje3gST.js";
1
+ import { m as breakAfterUnderscores } from "./ui-Br-dNUTc.js";
2
2
  import { Fragment } from "react";
3
3
  import { Link } from "@tanstack/react-router";
4
4
  import { INSTANCE_ROLES, isInstanceRole, isScope, scopeInWords } from "@coffre/core/access";
@@ -30,6 +30,10 @@ function subject(entry) {
30
30
  if (id === null) return ["someone"];
31
31
  return [{ member: `${entry.metadata.principalType === "service" ? "token" : "user"}:${id}` }];
32
32
  }
33
+ /** Why the vault made someone an Owner itself, said after it. */
34
+ function owned(entry) {
35
+ return entry.metadata.reason === "owners" ? [": the deployment names them one"] : [];
36
+ }
33
37
  /** An MCP client, by the name it connected under. */
34
38
  function app(entry) {
35
39
  return [text(entry.metadata.clientName) ?? "an app"];
@@ -279,7 +283,8 @@ var TEMPLATES = {
279
283
  "member.add": {
280
284
  did: "added",
281
285
  tried: "add",
282
- what: ({ entry }) => [...subject(entry), ...entry.metadata.rootAdmin === true ? [" as a root admin"] : entry.metadata.owner === true ? [" as an owner"] : asRole(entry)]
286
+ what: ({ entry }) => [...subject(entry), ...entry.metadata.rootAdmin === true ? [" as a root admin"] : entry.metadata.owner === true ? [" as an owner"] : asRole(entry)],
287
+ then: ({ entry }) => owned(entry)
283
288
  },
284
289
  "member.remove": {
285
290
  did: "removed",
@@ -290,7 +295,8 @@ var TEMPLATES = {
290
295
  "member.restore": {
291
296
  did: "brought back",
292
297
  tried: "bring back",
293
- what: ({ entry }) => [...subject(entry), ...asRole(entry)]
298
+ what: ({ entry }) => [...subject(entry), ...asRole(entry)],
299
+ then: ({ entry }) => owned(entry)
294
300
  },
295
301
  "member.role": {
296
302
  did: "made",
@@ -302,7 +308,11 @@ var TEMPLATES = {
302
308
  ],
303
309
  then: ({ entry }) => {
304
310
  const before = roleName(text(entry.metadata.previousRole) ?? "");
305
- return [...before === null ? [] : [`, was ${before}`], ...entry.metadata.reason === "every-project" ? [", for their grants on every project"] : []];
311
+ return [
312
+ ...before === null ? [] : [`, was ${before}`],
313
+ ...entry.metadata.reason === "every-project" ? [", for their grants on every project"] : [],
314
+ ...owned(entry)
315
+ ];
306
316
  }
307
317
  },
308
318
  "member.owner": {
@@ -323,7 +333,7 @@ var TEMPLATES = {
323
333
  did: "trusted CI runs to sign in as",
324
334
  tried: "trust CI runs to sign in as",
325
335
  what: (facts) => subject(facts.entry),
326
- then: ({ entry }) => reaching(entry)
336
+ then: ({ entry }) => [...inGitHubEnvironment(entry), ...reaching(entry)]
327
337
  },
328
338
  "token.seal": {
329
339
  did: "sealed",
@@ -521,6 +531,11 @@ function reaching(entry, none = "") {
521
531
  }
522
532
  return [`, reaching ${[...byRole].map(([role, count]) => `${role} on ${plural(count, "place")}`).join(", ")}`];
523
533
  }
534
+ /** The GitHub environment a binding takes its runs from, when it names one. */
535
+ function inGitHubEnvironment(entry) {
536
+ const environment = text(entry.metadata.claims?.environment);
537
+ return environment === null || !String(entry.metadata.profile).startsWith("github") ? [] : [`, in GitHub environment ${environment}`];
538
+ }
524
539
  /** The tokens and trust bindings a `token.seal` names, counted: `2 tokens and a trust binding`. */
525
540
  function sealedOf(entry) {
526
541
  const count = (key) => Array.isArray(entry.metadata[key]) ? entry.metadata[key].length : 0;
@@ -574,6 +589,7 @@ var REASONS = {
574
589
  deleted: "the place was deleted",
575
590
  not_allowed: "not allowed",
576
591
  root_admin: "root admins are set by the deployment",
592
+ last_owner: "they are the last Owner of the whole instance",
577
593
  requires_instance_admin: "requires an admin or owner of the whole instance",
578
594
  requires_instance_owner: "requires an instance owner",
579
595
  own_role: "nobody changes their own role",
@@ -764,4 +780,4 @@ function memberName(member) {
764
780
  //#endregion
765
781
  export { lines as a, describe as i, memberName as n, runLabel as o, decidedBy as r, who as s, Sentence as t };
766
782
 
767
- //# sourceMappingURL=audit-sentence-Cm5nby5k.js.map
783
+ //# sourceMappingURL=audit-sentence-CUUMshIp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit-sentence-CUUMshIp.js","names":[],"sources":["../../src/lib/audit-sentences.ts","../../src/components/audit-sentence.tsx"],"sourcesContent":["/**\n * The audit log in sentences: who did what, to what. One entry is one\n * human action, named for it (`secret.read`, `access.grant`, …); a batch of\n * them, one reveal of twelve secrets, shares an operation and reads as one\n * line, \"ran market/prod: 12 secrets\".\n *\n * A sentence is parts rather than a string, so the page can make the people\n * and places in it links. `plain` flattens it, for tests and titles.\n */\nimport { shownMember, type AuditEntryView } from '@coffre/client';\nimport { INSTANCE_ROLES, isInstanceRole, isScope, scopeInWords, type Scope } from '@coffre/core/access';\n\n/** What a sentence is made from: an entry of the log, as `GET /api/audit` gives it. */\nexport type AuditEntry = Pick<\n AuditEntryView,\n | 'seq'\n | 'author'\n | 'actorType'\n | 'actorId'\n | 'action'\n | 'decision'\n | 'reason'\n | 'detail'\n | 'subject'\n | 'project'\n | 'environment'\n | 'key'\n | 'version'\n | 'operationId'\n | 'metadata'\n>;\n\n/**\n * Text, a place (`market`, `market/prod`, `market/prod/KEY`), or a member,\n * as the log stores it (`user:…`, `token:…`): `shownMember` says it as people\n * read it, `service:…`, where it is shown.\n */\nexport type Part = string | { place: string } | { member: string };\n\nexport type Sentence = { parts: Part[]; refused: boolean };\n\n/** What one template needs: the line's leading entry, its batch, and how it was decided. */\ntype Facts = {\n entry: AuditEntry;\n /** Every entry of the batch, the lead included. */\n batch: AuditEntry[];\n /** Secrets the batch was about. */\n count: number;\n refused: boolean;\n};\n\ntype Template = {\n /** What they did: \"revealed\". */\n did: string | ((facts: Facts) => string);\n /** What they tried, after \"tried to\": \"reveal\". */\n tried: string | ((facts: Facts) => string);\n /** To what: \"market/prod/API_KEY\". */\n what: (facts: Facts) => Part[];\n /** Said only of what happened: \", now version 5\". */\n then?: (facts: Facts) => Part[];\n};\n\n// --- the pieces of a sentence ---------------------------------------------------\n\nconst text = (value: unknown): string | null => (typeof value === 'string' && value !== '' ? value : null);\nconst number = (value: unknown): number | null => (typeof value === 'number' ? value : null);\n\n/** The entry's place, as deep as it goes. */\nfunction place({ project, environment, key }: AuditEntry): Part[] {\n const path = [project, environment, key].filter((part): part is string => part !== null);\n return path.length === 0 ? ['coffre'] : [{ place: path.join('/') }];\n}\n\nfunction environmentOf({ project, environment }: AuditEntry): Part[] {\n return place({ project, environment, key: null } as AuditEntry);\n}\n\n/** The member an entry is about: its subject, or the principal a token entry names. */\nfunction subject(entry: AuditEntry): Part[] {\n if (entry.subject !== null) return [{ member: entry.subject }];\n const id = text(entry.metadata.principalId);\n if (id === null) return ['someone'];\n return [{ member: `${entry.metadata.principalType === 'service' ? 'token' : 'user'}:${id}` }];\n}\n\n/** Why the vault made someone an Owner itself, said after it. */\nfunction owned(entry: AuditEntry): Part[] {\n return entry.metadata.reason === 'owners' ? [': the deployment names them one'] : [];\n}\n\n/** An MCP client, by the name it connected under. */\nfunction app(entry: AuditEntry): Part[] {\n return [text(entry.metadata.clientName) ?? 'an app'];\n}\n\n/** A tool's call: its name, and what it named. */\nfunction tool(entry: AuditEntry): Part[] {\n const names = Array.isArray(entry.metadata.names) ? entry.metadata.names.filter((name): name is string => typeof name === 'string') : [];\n return [text(entry.metadata.tool) ?? 'a tool', ...(names.length === 0 ? [] : [` on ${names.join(', ')}`])];\n}\n\n/** The client a request came through, said after what it did: \"via Claude\". */\nfunction via(entry: AuditEntry): Part[] {\n const client = (entry.metadata.via as { clientName?: unknown } | undefined)?.clientName;\n return typeof client === 'string' ? [` via ${client}`] : [];\n}\n\n/** Why coffre itself ended a connection, said after it. */\nconst DISCONNECTED: Record<string, string> = {\n code_reused: ': its sign-in code was used twice',\n refresh_reused: ': a refresh token it had replaced was used again',\n revocation_endpoint: ', at its own request',\n superseded: ': a connection with more scopes replaced it',\n};\n\nfunction plural(count: number, one: string, many = `${one}s`): string {\n return `${count} ${count === 1 ? one : many}`;\n}\n\n/** A batch reads as its environment and a count; one entry as its secret. */\n/**\n * The secrets a read or write was about. A read through a reference is a\n * read of its source, \"market/prod/DATABASE_URL through\n * billing/prod/DATABASE_URL\"; a run that read some that way is a run of\n * the environment that holds them.\n */\nfunction secrets(facts: Facts): Part[] {\n const through = (entry: AuditEntry) => text((entry.metadata.via as { path?: unknown } | undefined)?.path);\n if (facts.batch.length === 1) {\n const held = through(facts.entry);\n return held === null ? place(facts.entry) : [...place(facts.entry), ' through ', { place: held }];\n }\n const own = facts.batch.find((entry) => through(entry) === null);\n const held = facts.batch.map(through).filter((path): path is string => path !== null);\n const where = own !== undefined ? environmentOf(own) : [{ place: held[0]!.split('/').slice(0, 2).join('/') }];\n return [\n ...where,\n facts.refused ? ', ' : ': ',\n plural(facts.count, 'secret'),\n ...(held.length === 0 ? [] : [`, ${held.length} through ${held.length === 1 ? 'a reference' : 'references'}`]),\n ];\n}\n\n/** \"market/prod/OLD\", or \"OLD and STALE in market/prod\" for an archive of several keys refused. */\nfunction archivedKeys(entry: AuditEntry): Part[] {\n const keys = Array.isArray(entry.metadata.keys) ? entry.metadata.keys.filter((key): key is string => text(key) !== null) : [];\n if (entry.key !== null || keys.length === 0) return place(entry);\n return [keys.length === 1 ? keys[0]! : `${keys.slice(0, -1).join(', ')} and ${keys.at(-1)!}`, ' in ', ...environmentOf(entry)];\n}\n\n/** \"SENTRY_DSN in market/dev\", or \"3 keys in market/dev\" for a Dismiss all. */\nfunction missingKeys(facts: Facts): Part[] {\n const key = text(facts.entry.metadata.key);\n return [facts.batch.length === 1 && key !== null ? key : plural(facts.count, 'key'), ' in ', ...environmentOf(facts.entry)];\n}\n\n/** \"billing/prod/DATABASE_URL a reference to market/prod/DATABASE_URL\", from either author's entry. */\nfunction referenceTo(entry: AuditEntry): Part[] {\n const holder = text(entry.metadata.subject);\n const key = text(entry.metadata.key);\n const source = text(entry.metadata.source) ?? text((entry.metadata.source as { path?: unknown } | undefined)?.path);\n return [\n ...(holder !== null ? [{ place: holder }] : key !== null ? place(entry) : environmentOf(entry)),\n ...(source === null ? [] : [' a reference to ', { place: source }]),\n ];\n}\n\nconst READ_VERBS: Record<string, [did: string, tried: string]> = {\n reveal: ['revealed', 'reveal'],\n run: ['ran', 'run'],\n compare: ['compared', 'compare'],\n copy: ['copied', 'copy'],\n};\n\nfunction readVerb({ entry }: Facts): [string, string] {\n return READ_VERBS[text(entry.metadata.purpose) ?? 'reveal'] ?? READ_VERBS.reveal!;\n}\n\nconst placeTemplates = (kind: 'project' | 'environment'): Record<string, Template> => {\n const what = (facts: Facts): Part[] => [`${kind} `, ...(kind === 'project' ? place({ ...facts.entry, environment: null, key: null }) : environmentOf(facts.entry))];\n return {\n [`${kind}.create`]: {\n did: 'created',\n tried: 'create',\n what,\n // A fork names the environment it copied.\n then: ({ entry }) => (text(entry.metadata.from) === null ? [] : [`, a fork of ${text(entry.metadata.from)}`]),\n },\n [`${kind}.update`]: { did: 'changed', tried: 'change', what },\n [`${kind}.archive`]: { did: 'archived', tried: 'archive', what },\n [`${kind}.restore`]: { did: 'restored', tried: 'restore', what },\n // Named by its tombstone from then on, `market~deleted-2026-10-05`, as every entry about it is.\n [`${kind}.delete`]: { did: 'deleted', tried: 'delete', what },\n };\n};\n\n// --- one template per action ----------------------------------------------------\n\nconst TEMPLATES: Record<string, Template> = {\n 'secret.read': {\n did: (facts) => readVerb(facts)[0],\n tried: (facts) => readVerb(facts)[1],\n what: secrets,\n },\n 'secret.write': {\n // New secrets are added, others changed; a batch of both is written.\n did: ({ batch }) => {\n const firsts = batch.filter((entry) => entry.version === 1).length;\n return firsts === batch.length ? 'added' : firsts === 0 ? 'changed' : 'wrote';\n },\n tried: 'change',\n what: secrets,\n then: ({ entry, batch }) =>\n batch.length > 1 || entry.version === null || entry.version === 1 ? [] : [`, now version ${entry.version}`],\n },\n 'secret.restore': {\n did: 'restored',\n tried: 'restore',\n what: ({ entry }) => [...place(entry), ...(number(entry.metadata.from) === null ? [] : [` to version ${number(entry.metadata.from)}`])],\n then: ({ entry }) => (entry.version === null ? [] : [`, now ${entry.version}`]),\n },\n 'secret.rename': {\n did: 'renamed',\n tried: 'rename',\n what: ({ entry }) => [...place(entry), ...(text(entry.metadata.nextKey) === null ? [] : [` to ${text(entry.metadata.nextKey)}`])],\n },\n 'secret.archive': { did: 'archived', tried: 'archive', what: ({ entry }) => archivedKeys(entry) },\n 'missing.dismiss': {\n did: 'dismissed',\n tried: 'dismiss',\n what: (facts) => missingKeys(facts),\n then: () => [' as not needed'],\n },\n 'missing.restore': { did: 'restored', tried: 'restore', what: (facts) => missingKeys(facts), then: () => [' to the missing keys'] },\n 'secret.reference': { did: 'made', tried: 'make', what: ({ entry }) => referenceTo(entry) },\n 'reference.create': { did: 'made', tried: 'make', what: ({ entry }) => referenceTo(entry) },\n 'reference.end': {\n did: ({ entry }) => (entry.metadata.reason === 'replaced' ? 'gave a value of its own to' : entry.metadata.reason === 'abandoned' ? 'abandoned' : 'broke'),\n tried: ({ entry }) => (entry.metadata.reason === 'replaced' ? 'replace' : entry.metadata.reason === 'abandoned' ? 'abandon' : 'break'),\n what: ({ entry }) => {\n const source = text((entry.metadata.source as { path?: unknown } | undefined)?.path);\n const holder = text(entry.metadata.subject);\n if (entry.metadata.reason === 'replaced') return [...(holder === null ? ['a reference'] : [{ place: holder }]), ...(source === null ? [] : [', no longer a reference to ', { place: source }])];\n return ['the reference ', ...(holder === null ? [] : [{ place: holder }]), ...(source === null ? [] : [' to ', { place: source }])];\n },\n then: ({ entry }) => (entry.metadata.reason === 'abandoned' ? [', which its write never stored'] : []),\n },\n 'secret.unarchive': { did: 'brought back', tried: 'bring back', what: (facts) => place(facts.entry) },\n 'secret.move': { did: 'moved', tried: 'move', what: (facts) => place(facts.entry), then: ({ entry }) => intoFolder(entry) },\n ...placeTemplates('project'),\n 'project.move': {\n did: 'moved',\n tried: 'move',\n what: ({ entry }) => ['project ', ...place({ ...entry, environment: null, key: null })],\n then: ({ entry }) => intoFolder(entry),\n },\n ...placeTemplates('environment'),\n 'environment.fork': {\n did: 'forked',\n tried: 'fork',\n what: ({ entry }) => [...environmentOf(entry), ...(text(entry.metadata.slug) === null ? [] : [` into ${text(entry.metadata.slug)}`])],\n },\n 'access.grant': {\n did: 'gave',\n tried: 'give',\n what: ({ entry }) => [...subject(entry), ` ${text(entry.metadata.role) ?? 'a role'} on `, ...placeOnly(entry)],\n then: ({ entry }) => [\n ...(text(entry.metadata.previousRole) === null ? [] : [`, was ${text(entry.metadata.previousRole)}`]),\n ...(text(entry.metadata.expiresAt) === null ? [] : [`, until ${text(entry.metadata.expiresAt)!.slice(0, 10)}`]),\n ...(entry.metadata.reason === 'every-project' ? [', for a grant on every project'] : []),\n ],\n },\n 'access.revoke': {\n did: 'took',\n tried: 'take',\n what: ({ entry }) => [\n ...(text(entry.metadata.previousRole ?? entry.metadata.role) === null ? ['access to '] : [`${text(entry.metadata.previousRole ?? entry.metadata.role)} on `]),\n ...placeOnly(entry),\n ' from ',\n ...subject(entry),\n ],\n // The vault replacing a grant on every project of 0.4: by what, an instance role or project grants.\n then: ({ entry }) => {\n const by = entry.metadata.replacedBy as { role?: unknown } | undefined;\n if (by === undefined) return [];\n const role = typeof by.role === 'string' ? roleName(by.role) : null;\n return [role === null || role === 'Member' ? ', replaced by project grants' : `, replaced by the instance role ${role}`];\n },\n },\n 'member.add': {\n did: 'added',\n tried: 'add',\n what: ({ entry }) => [\n ...subject(entry),\n ...(entry.metadata.rootAdmin === true ? [' as a root admin'] : entry.metadata.owner === true ? [' as an owner'] : asRole(entry)),\n ],\n then: ({ entry }) => owned(entry),\n },\n 'member.remove': {\n did: 'removed',\n tried: 'remove',\n what: (facts) => subject(facts.entry),\n then: ({ entry }) => (number(entry.metadata.revoked) === null ? [] : [`, who held ${plural(number(entry.metadata.revoked)!, 'grant')}`]),\n },\n 'member.restore': {\n did: 'brought back',\n tried: 'bring back',\n what: ({ entry }) => [...subject(entry), ...asRole(entry)],\n then: ({ entry }) => owned(entry),\n },\n 'member.role': {\n did: 'made',\n tried: 'make',\n what: ({ entry }) => [...subject(entry), ` ${article(roleName(text(entry.metadata.role) ?? 'member') ?? 'Member')}`, ...scoped(entry)],\n then: ({ entry }) => {\n const before = roleName(text(entry.metadata.previousRole) ?? '');\n return [\n ...(before === null ? [] : [`, was ${before}`]),\n ...(entry.metadata.reason === 'every-project' ? [', for their grants on every project'] : []),\n ...owned(entry),\n ];\n },\n },\n 'member.owner': {\n did: ({ entry }) => (entry.metadata.owner === false ? 'took owner from' : 'made'),\n tried: ({ entry }) => (entry.metadata.owner === false ? 'take owner from' : 'make'),\n what: ({ entry }) => [...subject(entry), ...(entry.metadata.owner === false ? [] : [' an owner'])],\n },\n // Where people set up service accounts themselves, which those who run the instance set.\n 'settings.change': {\n did: 'set',\n tried: 'set',\n what: ({ entry }) => ['where people set up service accounts', ...setting(entry.metadata.serviceAccounts).map((words) => `: ${words}`)],\n then: ({ entry }) => {\n const previous = (entry.metadata.previous as { serviceAccounts?: unknown } | undefined)?.serviceAccounts;\n return setting(previous).map((words) => `, was ${words}`);\n },\n },\n // A binding trusts CI runs to sign in as a service; removing one is its tombstone.\n 'token.bind': {\n did: 'trusted CI runs to sign in as',\n tried: 'trust CI runs to sign in as',\n what: (facts) => subject(facts.entry),\n then: ({ entry }) => [...inGitHubEnvironment(entry), ...reaching(entry)],\n },\n // The tokens and bindings 0.4 made, given their own scope when 0.5 first checked a credential: what their account held then.\n 'token.seal': {\n did: 'sealed',\n tried: 'seal',\n what: ({ entry }) => [`${sealedOf(entry)} of `, ...subject(entry)],\n then: ({ entry }) => reaching(entry, ', reaching nothing'),\n },\n 'token.unbind': {\n did: 'stopped trusting CI runs to sign in as',\n tried: 'stop trusting CI runs to sign in as',\n what: (facts) => subject(facts.entry),\n },\n 'vault.tampered': {\n did: 'found',\n tried: 'check',\n what: ({ entry }) => [\n ...(entry.subject === null ? ['an entry'] : [...subject(entry), \"'s record\"]),\n ` tampered with: ${TAMPERING[entry.reason ?? ''] ?? 'it fails its seal'}`,\n ],\n },\n 'key.rotate': { did: 'rotated its key', tried: 'rotate its key', what: () => [] },\n // An MCP client a person connected, such as Claude: named as the consent page showed it.\n 'mcp.connect': { did: 'connected', tried: 'connect', what: ({ entry }) => app(entry) },\n // A tool an MCP client called, by its name, and the places it named.\n 'mcp.call': { did: 'used', tried: 'use', what: ({ entry }) => tool(entry), then: ({ entry }) => via(entry) },\n // A person's decision, on coffre's page, on a change an MCP client asked for; the change's own entries follow, via the client.\n 'mcp.approve': { did: 'approved', tried: 'approve', what: ({ entry }) => tool(entry), then: ({ entry }) => [` for ${text(entry.metadata.clientName) ?? 'an app'}`] },\n 'mcp.deny': { did: 'turned down', tried: 'turn down', what: ({ entry }) => tool(entry), then: ({ entry }) => [` for ${text(entry.metadata.clientName) ?? 'an app'}`] },\n 'mcp.view': { did: 'opened an approval', tried: 'open an approval', what: () => [] },\n // The app's prompt declined, which cancels the approval it would have opened.\n 'mcp.cancel': { did: 'cancelled', tried: 'cancel', what: ({ entry }) => tool(entry), then: ({ entry }) => via(entry) },\n 'mcp.disconnect': {\n did: 'disconnected',\n tried: 'disconnect',\n what: ({ entry }) => [...app(entry), ...(entry.metadata.principalId === undefined ? [] : [' of ', ...subject(entry)])],\n then: ({ entry }) => [DISCONNECTED[text(entry.metadata.reason) ?? ''] ?? ''],\n },\n\n // Detail, hidden unless asked for.\n sign_in: {\n did: ({ entry }) => (entry.metadata.kind === 'cli' ? 'signed in to the CLI' : 'signed in'),\n tried: 'sign in',\n what: ({ entry }) => (text(entry.metadata.provider) === null ? [] : [`with ${text(entry.metadata.provider)}`]),\n },\n sign_out: { did: 'signed out', tried: 'sign out', what: () => [] },\n 'token.create': { did: 'issued a bearer token to', tried: 'issue a bearer token to', what: (facts) => subject(facts.entry), then: ({ entry }) => reaching(entry) },\n 'token.revoke': { did: 'revoked a bearer token of', tried: 'revoke a bearer token of', what: (facts) => subject(facts.entry) },\n 'device.approve': { did: 'approved a CLI sign-in', tried: 'approve a CLI sign-in', what: () => [] },\n 'device.deny': { did: 'turned down a CLI sign-in', tried: 'turn down a CLI sign-in', what: () => [] },\n 'mcp.read': { did: 'used', tried: 'use', what: ({ entry }) => tool(entry), then: ({ entry }) => via(entry) },\n 'mcp.token': {\n did: ({ entry }) => (entry.metadata.grant === 'refresh_token' ? 'refreshed the tokens of' : 'gave its first tokens to'),\n tried: 'give tokens to',\n what: ({ entry }) => app(entry),\n },\n 'account.link': {\n did: 'linked',\n tried: 'link',\n what: ({ entry }) => [`a ${text(entry.metadata.provider) ?? 'sign-in'} account`],\n },\n 'account.unlink': {\n did: 'unlinked',\n tried: 'unlink',\n what: ({ entry }) => [`a ${text(entry.metadata.provider) ?? 'sign-in'} account`],\n },\n 'key.wrap': { did: 'sealed the key of', tried: 'seal the key of', what: (facts) => versioned(facts.entry) },\n 'key.rewrap': { did: 'resealed the key of', tried: 'reseal the key of', what: (facts) => versioned(facts.entry) },\n 'key.intent': { did: 'asked KMS about', tried: 'ask KMS about', what: (facts) => secrets(facts) },\n 'key.check': {\n did: 'recorded the check value of',\n tried: 'check',\n what: ({ entry }) => [['the', text(entry.metadata.kekProvider) === 'local' ? null : text(entry.metadata.kekProvider), 'vault key', text(entry.metadata.kekId)].filter((word) => word !== null).join(' ')],\n },\n 'audit.heartbeat': { did: 'checked in', tried: 'check in', what: () => [] },\n 'audit.checkpoint': {\n did: 'signed the log',\n tried: 'sign the log',\n what: ({ entry }) => (number(entry.metadata.seq) === null ? [] : [`through entry ${number(entry.metadata.seq)}`]),\n },\n\n // Only ever refused: a read of a list, which is not logged when allowed.\n 'secret.list': { did: 'listed', tried: 'list', what: ({ entry }) => environmentOf(entry) },\n 'secret.history': { did: 'read the history of', tried: 'read the history of', what: (facts) => place(facts.entry) },\n 'secret.update': { did: 'changed', tried: 'change', what: (facts) => place(facts.entry) },\n};\n\n/** \" to the folder stripe\", or \" out of its folder\". */\nfunction intoFolder(entry: AuditEntry): Part[] {\n const folder = text(entry.metadata.to);\n return [folder === null ? ' out of its folder' : ` to the folder ${folder}`];\n}\n\n/** An instance role's name, from its slug; null for none it knows. */\nfunction roleName(role: string): string | null {\n return isInstanceRole(role) ? INSTANCE_ROLES[role].name : null;\n}\n\nfunction article(name: string): string {\n return `${/^[AEIOU]/.test(name) ? 'an' : 'a'} ${name}`;\n}\n\n/** Whether an entry's scope narrows the role; its projects are ids, which a sentence cannot name. */\nfunction scoped(entry: AuditEntry): Part[] {\n const scope = entry.metadata.scope as { projects?: unknown; environments?: unknown } | undefined;\n return scope === undefined || (scope.projects === 'all' && scope.environments === 'all') ? [] : [', with a scope'];\n}\n\n/**\n * What a token or binding reaches, its scope, each role with the places it\n * holds, counted, as the log names them by id: `, reaching developer on 2 places`.\n */\nfunction reaching(entry: AuditEntry, none = ''): Part[] {\n const scope = entry.metadata.scope;\n if (!Array.isArray(scope)) return [];\n if (scope.length === 0) return none === '' ? [] : [none];\n const byRole = new Map<string, number>();\n for (const grant of scope as { role?: unknown }[]) {\n const role = text(grant.role);\n if (role !== null) byRole.set(role, (byRole.get(role) ?? 0) + 1);\n }\n return [`, reaching ${[...byRole].map(([role, count]) => `${role} on ${plural(count, 'place')}`).join(', ')}`];\n}\n\n/** The GitHub environment a binding takes its runs from, when it names one. */\nfunction inGitHubEnvironment(entry: AuditEntry): Part[] {\n const environment = text((entry.metadata.claims as Record<string, unknown> | undefined)?.environment);\n return environment === null || !String(entry.metadata.profile).startsWith('github') ? [] : [`, in GitHub environment ${environment}`];\n}\n\n/** The tokens and trust bindings a `token.seal` names, counted: `2 tokens and a trust binding`. */\nfunction sealedOf(entry: AuditEntry): string {\n const count = (key: string) => (Array.isArray(entry.metadata[key]) ? (entry.metadata[key] as unknown[]).length : 0);\n const parts = [[count('tokens'), 'token'], [count('bindings'), 'trust binding']] as const;\n return parts.filter(([n]) => n > 0).map(([n, one]) => plural(n, one)).join(' and ') || 'nothing';\n}\n\n/**\n * The setting of where people set up service accounts, in words: its\n * projects counted, as the log names them by id, its environments by name.\n *\n * All projects · all but prod 2 projects · dev only\n */\nfunction setting(scope: unknown): string[] {\n if (!isScope(scope)) return [];\n const { projects } = scope;\n const counted: Scope = projects === 'all'\n ? scope\n : { ...scope, projects: 'only' in projects ? { only: [plural(projects.only.length, 'project')] } : { except: [plural(projects.except.length, 'project')] } };\n return [scopeInWords(counted)];\n}\n\n/** The role a member is added or brought back with, said when it is more than Member. */\nfunction asRole(entry: AuditEntry): Part[] {\n const role = roleName(text(entry.metadata.role) ?? '');\n return role === null || role === 'Member' ? [] : [` as ${article(role)}`, ...scoped(entry)];\n}\n\nfunction placeOnly(entry: AuditEntry): Part[] {\n // A grant on every project names no project: its place is a path in its payload, `*` or `*/dev`.\n const everywhere = entry.project === null ? text(entry.metadata.place) : null;\n if (everywhere !== null) return [everywhere === '*' ? 'every project' : `${everywhere.slice('*/'.length)} in every project`];\n return place({ ...entry, key: null });\n}\n\nfunction versioned(entry: AuditEntry): Part[] {\n return [...place(entry), ...(entry.version === null ? [] : [`, version ${entry.version}`])];\n}\n\nconst TAMPERING: Record<string, string> = {\n mac: \"it does not carry the vault's seal\",\n stale: 'an older copy was put back',\n forged_entry: 'the vault did not write it',\n};\n\n/** Why something was refused, in words. Codes from the vault and the app. */\nconst REASONS: Record<string, string> = {\n no_grant: 'no grant',\n bulk_limit: 'bulk limit',\n expired: 'grant expired',\n removed: 'removed from coffre',\n not_a_member: 'not a member',\n not_registered: 'not invited',\n tampered: 'their record was tampered with',\n bad_claim: 'the key did not match the secret',\n deleted: 'the place was deleted',\n not_allowed: 'not allowed',\n root_admin: 'root admins are set by the deployment',\n last_owner: 'they are the last Owner of the whole instance',\n requires_instance_admin: 'requires an admin or owner of the whole instance',\n requires_instance_owner: 'requires an instance owner',\n own_role: 'nobody changes their own role',\n own_grant: 'nobody grants themselves a role',\n service_cannot_hold_role: 'service accounts hold project grants only',\n not_service_manager: 'they hold less than the service account, or than they gave it',\n unknown_environment: 'no such environment',\n unknown_secret: 'no such secret',\n no_value: 'it holds no value',\n unknown_project: 'no such project',\n not_archived: 'it was not archived',\n referenced: 'references read it',\n kms_unavailable: 'KMS did not answer',\n wrong_kek: \"the vault's key is not the one that wrapped the data\",\n person_denied: 'they said no',\n too_many_connections: 'too many connected apps',\n unknown_connection: 'no such connected app',\n not_yours: \"it was someone else's\",\n too_many_approvals: 'too many changes waiting for approval',\n request_state: 'its retry did not match its call',\n changed: 'the change was not the one shown',\n replaced: 'what it replaces changed since it was shown',\n unconfirmed: 'what it replaces could not be read',\n disconnected: 'the app was disconnected',\n};\n\n/** What a missing permission meant, from the app's `missing_<permission>`. */\nconst MISSING: Record<string, string> = {\n secret_read: 'no grant to read it',\n secret_write: 'no grant to write',\n secret_archive: 'no grant to archive',\n audit_read: 'no grant to read the audit log',\n environment_manage: 'no grant to manage environments',\n grant_manage: 'no grant to manage access',\n project_manage: 'no grant to manage the project',\n};\n\nexport function reasonInWords(reason: string | null): string {\n if (reason === null) return 'refused';\n if (reason.startsWith('missing_')) return MISSING[reason.slice('missing_'.length)] ?? 'no grant';\n return REASONS[reason] ?? reason.replace(/_/g, ' ');\n}\n\n// --- lines ----------------------------------------------------------------------\n\n/** In a batch of mixed actions, the one the line is named for: a write, not its reads. */\nconst LEAD = ['secret.write', 'secret.read'];\n\nexport function leadOf(batch: AuditEntry[]): AuditEntry {\n for (const action of LEAD) {\n const found = batch.find((entry) => entry.action === action);\n if (found !== undefined) return found;\n }\n return batch[0]!;\n}\n\n/** What a line says: one entry, or a batch that shares an operation. */\nexport function describe(batch: AuditEntry[]): Sentence {\n const entry = leadOf(batch);\n const same = batch.filter((other) => other.action === entry.action);\n const denied = same.filter((other) => other.decision === 'deny');\n const refused = denied.length === same.length;\n const facts: Facts = {\n entry,\n batch: same,\n count: new Set(same.map((other) => `${other.project}/${other.environment}/${other.key}`)).size,\n refused,\n };\n const template = TEMPLATES[entry.action];\n if (template === undefined) return { parts: [entry.action, ' ', ...place(entry)], refused };\n const say = (verb: Template['did']) => (typeof verb === 'string' ? verb : verb(facts));\n const what = template.what(facts);\n const gap = what.length === 0 ? [] : [' '];\n if (refused) {\n const reason = reasonInWords((denied[0] ?? entry).reason);\n return { parts: ['tried to ', say(template.tried), ...gap, ...what, `: ${reason}`], refused };\n }\n const partly = denied.length === 0 ? [] : [`, ${denied.length} refused: ${reasonInWords(denied[0]!.reason)}`];\n return { parts: [say(template.did), ...gap, ...what, ...(template.then?.(facts) ?? []), ...partly], refused };\n}\n\n/** Who acted, as a part: a member links to their page; coffre itself is text. */\nexport function who(entry: Pick<AuditEntry, 'actorType' | 'actorId'>): string | { member: string } {\n if (entry.actorType === 'user') return { member: `user:${entry.actorId}` };\n if (entry.actorType === 'service') return { member: `token:${entry.actorId}` };\n return SYSTEM[entry.actorId] ?? entry.actorId;\n}\n\nconst SYSTEM: Record<string, string> = {\n scheduler: 'the scheduler',\n cron: 'the scheduler',\n vault: 'the vault',\n app: 'coffre',\n};\n\n/** Which components wrote the line, the vault first: \"vault\", \"app\", \"vault, app\". */\nexport function decidedBy(batch: Pick<AuditEntry, 'author'>[]): string {\n return (['vault', 'app'] as const).filter((author) => batch.some((entry) => entry.author === author)).join(', ');\n}\n\n/**\n * Entries in the order the page shows them, newest first, each batch as one\n * line at its newest entry. The server leaves detail out unless asked.\n */\nexport function lines<T extends AuditEntry>(entries: T[]): T[][] {\n const shown: T[][] = [];\n const batches = new Map<string, T[]>();\n for (const entry of entries) {\n const batch = entry.operationId === null ? undefined : batches.get(entry.operationId);\n if (batch !== undefined) {\n batch.push(entry);\n continue;\n }\n const fresh = [entry];\n if (entry.operationId !== null) batches.set(entry.operationId, fresh);\n shown.push(fresh);\n }\n return shown;\n}\n\n/** A sentence as text. */\nexport function plain(parts: Part[]): string {\n return parts\n .map((part) =>\n typeof part === 'string' ? part : 'place' in part ? part.place : part.member.startsWith('user:') ? part.member.slice(5) : shownMember(part.member),\n )\n .join('');\n}\n\n/**\n * The CI run an entry was written for, as its issuer stated it at the\n * exchange: `acme/api run 7001 at 3f2a9c1`, a GitLab pipeline, or the\n * token's subject. Null for an entry no trust binding's credential wrote.\n */\nexport function runLabel(run: { claims: Record<string, string | number> } | null): string | null {\n if (run === null) return null;\n const { claims } = run;\n const text = (name: string) => (typeof claims[name] === 'string' || typeof claims[name] === 'number' ? String(claims[name]) : null);\n const at = text('sha') === null ? '' : ` at ${text('sha')!.slice(0, 7)}`;\n if (text('repository') !== null && text('run_id') !== null) return `${text('repository')} run ${text('run_id')}${at}`;\n if (text('project_path') !== null && text('pipeline_id') !== null) return `${text('project_path')} pipeline ${text('pipeline_id')}${at}`;\n return text('sub') === null ? 'a CI run' : `CI run ${text('sub')}`;\n}\n","import { serviceName, shownMember } from '@coffre/client';\nimport { Fragment } from 'react';\nimport { Link } from '@tanstack/react-router';\nimport type { Part } from '../lib/audit-sentences';\nimport { breakAfterUnderscores } from './ui';\n\n/** A sentence, its people and places links to their pages. */\nexport function Sentence({ parts }: { parts: Part[] }) {\n return (\n <>\n {parts.map((part, index) => (\n <Fragment key={index}>\n {typeof part === 'string' ? (\n part\n ) : 'place' in part ? (\n <PlaceLink path={part.place} />\n ) : (\n <MemberLink member={part.member} />\n )}\n </Fragment>\n ))}\n </>\n );\n}\n\nfunction PlaceLink({ path }: { path: string }) {\n const [project, environment] = path.split('/') as [string, string | undefined];\n const text = <span className=\"mono\">{breakAfterUnderscores(path)}</span>;\n return environment === undefined ? (\n <Link to=\"/projects/$project\" params={{ project }}>\n {text}\n </Link>\n ) : (\n <Link to=\"/projects/$project/$environment\" params={{ project, environment }}>\n {text}\n </Link>\n );\n}\n\n/** A member from the log, which keeps `token:<name>`, shown as people read it: `service:<name>`, to its page. */\nfunction MemberLink({ member }: { member: string }) {\n return member.startsWith('token:') ? (\n <Link to=\"/service-accounts/$account\" params={{ account: serviceName(member) }}>\n {shownMember(member)}\n </Link>\n ) : (\n <Link to=\"/users/$user\" params={{ user: memberName(member) }}>\n {memberName(member)}\n </Link>\n );\n}\n\nexport function memberName(member: string): string {\n return member.startsWith('user:') ? member.slice('user:'.length) : shownMember(member);\n}\n"],"mappings":";;;;;;;AAgEA,IAAM,QAAQ,UAAmC,OAAO,UAAU,YAAY,UAAU,KAAK,QAAQ;AACrG,IAAM,UAAU,UAAmC,OAAO,UAAU,WAAW,QAAQ;;AAGvF,SAAS,MAAM,EAAE,SAAS,aAAa,OAA2B;CAChE,MAAM,OAAO;EAAC;EAAS;EAAa;CAAG,CAAC,CAAC,QAAQ,SAAyB,SAAS,IAAI;CACvF,OAAO,KAAK,WAAW,IAAI,CAAC,QAAQ,IAAI,CAAC,EAAE,OAAO,KAAK,KAAK,GAAG,EAAE,CAAC;AACpE;AAEA,SAAS,cAAc,EAAE,SAAS,eAAmC;CACnE,OAAO,MAAM;EAAE;EAAS;EAAa,KAAK;CAAK,CAAe;AAChE;;AAGA,SAAS,QAAQ,OAA2B;CAC1C,IAAI,MAAM,YAAY,MAAM,OAAO,CAAC,EAAE,QAAQ,MAAM,QAAQ,CAAC;CAC7D,MAAM,KAAK,KAAK,MAAM,SAAS,WAAW;CAC1C,IAAI,OAAO,MAAM,OAAO,CAAC,SAAS;CAClC,OAAO,CAAC,E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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-BJ3dCFHb.js";
1
+ import { a as ErrorLine, i as EmptyState, t as ConfirmButton, u as Timestamp } from "./ui-Br-dNUTc.js";
2
+ import { F as Link, st as X, t as Card } from "./page-JTORvh-N.js";
3
+ import { a as rowClass, i as RowPending, r as RowFailure } from "./row-state-Zf3kZVhd.js";
4
+ import { n as useChangeStatus, t as useChange } from "./use-change-By4cG8bT.js";
5
5
  import { Fragment } from "react";
6
6
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
7
7
  import { MCP_SCOPE_INFO } from "@coffre/core/mcp";
@@ -143,4 +143,4 @@ function scopeLabels(app) {
143
143
  //#endregion
144
144
  export { ConnectedAppsCard as t };
145
145
 
146
- //# sourceMappingURL=connected-apps-DTNS7YmY.js.map
146
+ //# sourceMappingURL=connected-apps-DTpatjge.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"connected-apps-DTNS7YmY.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 will stop working. 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;aAAqB;EAAkB,CAAA,IAEzD,oBAAC,OAAD;GAAK,WAAU;aACb,qBAAC,SAAD;IAAO,WAAU;cAAjB,CACE,oBAAC,SAAD,EAAA,UACE,qBAAC,MAAD,EAAA,UAAA;KACE,oBAAC,MAAD,EAAA,UAAI,MAAO,CAAA;KACX,oBAAC,MAAD,EAAA,UAAI,MAAO,CAAA;KACX,oBAAC,MAAD;MAAI,WAAU;gBAAa;KAAa,CAAA;KACxC,oBAAC,MAAD;MAAI,WAAU;gBAAa;KAAW,CAAA;KACtC,oBAAC,MAAD;MAAI,WAAU;gBACZ,oBAAC,QAAD;OAAM,WAAU;iBAAkB;MAAa,CAAA;KAC7C,CAAA;IACF,EAAA,CAAA,EACC,CAAA,GACP,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,OAAO,cAAc,IAAI,KAAK;SAC9B,MACE,qBAAA,YAAA,EAAA,UAAA;UACG,IAAI;UACJ,IAAI,SAAS,QACZ,qBAAA,YAAA,EAAA,UAAA;WACG;WAAI;WAAG,oBAAC,QAAD;YAAM,WAAU;sBAAQ,IAAI;WAAW,CAAA;UAC/C,EAAA,CAAA;UACF;UACU;UACX,IAAI,eAAe,OAAO,UAAU,oBAAC,WAAD;WAAW,KAAK,IAAI;WAAY,SAAQ;UAAY,CAAA;UAAE;SAE3F,EAAA,CAAA;SAEJ,cAAa;SACb,iBAAiB,WAAW,GAAG;QAChC,CAAA;OAED,CAAA;MACF;SACJ,oBAAC,YAAD;MACE,QAAQ;MACR,SAAS;MACT,iBAAiB,MAAM,UAAU,YAAY,QAAQ,MAAM,UAAU;KACtE,CAAA,CACO,EAAA,GAjEK,IAAI,EAiET;IAEd,CAAC,EACI,CAAA,CACF;;EACJ,CAAA;CAEH,CAAA;AAEV;AAEA,SAAS,YAAY,KAA2B;CAC9C,OAAO,IAAI,OAAO,KAAK,UAAU,eAAe,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI;AACzE"}
1
+ {"version":3,"file":"connected-apps-DTpatjge.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 will stop working. 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;aAAqB;EAAkB,CAAA,IAEzD,oBAAC,OAAD;GAAK,WAAU;aACb,qBAAC,SAAD;IAAO,WAAU;cAAjB,CACE,oBAAC,SAAD,EAAA,UACE,qBAAC,MAAD,EAAA,UAAA;KACE,oBAAC,MAAD,EAAA,UAAI,MAAO,CAAA;KACX,oBAAC,MAAD,EAAA,UAAI,MAAO,CAAA;KACX,oBAAC,MAAD;MAAI,WAAU;gBAAa;KAAa,CAAA;KACxC,oBAAC,MAAD;MAAI,WAAU;gBAAa;KAAW,CAAA;KACtC,oBAAC,MAAD;MAAI,WAAU;gBACZ,oBAAC,QAAD;OAAM,WAAU;iBAAkB;MAAa,CAAA;KAC7C,CAAA;IACF,EAAA,CAAA,EACC,CAAA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;SAEV,OAAO,cAAc,IAAI,KAAK;SAC9B,MACE,qBAAA,YAAA,EAAA,UAAA;UACG,IAAI;UACJ,IAAI,SAAS,QACZ,qBAAA,YAAA,EAAA,UAAA;WACG;WAAI;WAAG,oBAAC,QAAD;YAAM,WAAU;sBAAQ,IAAI;WAAW,CAAA;UAC/C,EAAA,CAAA;UACF;UACU;UACX,IAAI,eAAe,OAAO,UAAU,oBAAC,WAAD;WAAW,KAAK,IAAI;WAAY,SAAQ;UAAY,CAAA;UAAE;SAE3F,EAAA,CAAA;SAEJ,cAAa;SACb,iBAAiB,WAAW,GAAG;QAChC,CAAA;OAED,CAAA;MACF;SACJ,oBAAC,YAAD;MACE,QAAQ;MACR,SAAS;MACT,iBAAiB,MAAM,UAAU,YAAY,QAAQ,MAAM,UAAU;KACtE,CAAA,CACO,EAAA,GAjEK,IAAI,EAiET;IAEd,CAAC,EACI,CAAA,CACF;;EACJ,CAAA;CAEH,CAAA;AAEV;AAEA,SAAS,YAAY,KAA2B;CAC9C,OAAO,IAAI,OAAO,KAAK,UAAU,eAAe,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI;AACzE"}
@@ -1,7 +1,7 @@
1
- import { a as ErrorLine, c as Notice, l as Spinner, s as Modal } from "./ui-DJje3gST.js";
2
- import { $ as Trash, u as useCoffre } from "./page-DvsgZ2Hd.js";
3
- import { g as queries, t as affects } from "./queries-DE5nK2y4.js";
4
- import { t as useAction } from "./use-action-BRgvbUWt.js";
1
+ import { a as ErrorLine, c as Notice, l as Spinner, s as Modal } from "./ui-Br-dNUTc.js";
2
+ import { nt as Trash, u as useCoffre } from "./page-JTORvh-N.js";
3
+ import { g as queries, t as affects } from "./queries-DgQo3mC-.js";
4
+ import { t as useAction } from "./use-action-DthL5hL8.js";
5
5
  import { useEffect, useState } from "react";
6
6
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
7
7
  import { useQuery } from "@tanstack/react-query";
@@ -203,4 +203,4 @@ function DeletionSummary({ deletion, what }) {
203
203
  //#endregion
204
204
  export { DeletePlaceDialog as t };
205
205
 
206
- //# sourceMappingURL=delete-place-CIaOq0mt.js.map
206
+ //# sourceMappingURL=delete-place-SOOYVt6A.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"delete-place-CIaOq0mt.js","names":[],"sources":["../../src/components/delete-place.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { useQuery } from '@tanstack/react-query';\nimport { shownMember, type Deletion } from '@coffre/client';\n\nimport { useCoffre } from '../lib/coffre';\nimport { affects, queries } from '../lib/queries';\nimport { useAction } from '../lib/use-action';\nimport { Trash } from './icons';\nimport { ErrorLine, Modal, Notice, Spinner } from './ui';\n\n/**\n * Deleting an archived project or environment for good, `market` or\n * `market/prod`. The dialog first asks the server what the deletion would\n * take, then needs the place's path typed out before it deletes: nothing\n * brings it back, so the one click a slip can make is never enough.\n */\nexport function DeletePlaceDialog({\n path,\n open,\n onOpenChange,\n onDeleted,\n}: {\n path: string;\n open: boolean;\n onOpenChange: (open: boolean) => void;\n onDeleted: (deletion: Deletion) => unknown;\n}) {\n const coffre = useCoffre();\n const plan = useQuery({ ...queries.deletion(coffre, path), enabled: open });\n const [typed, setTyped] = useState('');\n const { pending, error, setError, run } = useAction();\n const what = path.includes('/') ? 'environment' : 'project';\n\n useEffect(() => {\n if (!open) return;\n setTyped('');\n setError(null);\n }, [open, setError]);\n\n const deletion = plan.data?.ok === true ? plan.data.deletion : null;\n\n return (\n <Modal\n open={open}\n onOpenChange={onOpenChange}\n title={\n <>\n Delete <span className=\"mono\">{path}</span> for good?\n </>\n }\n >\n <div className=\"dialog-body\">\n {plan.data === undefined ? (\n <Spinner />\n ) : plan.data.ok ? (\n <DeletionSummary deletion={plan.data.deletion} what={what} />\n ) : (\n <ErrorLine error={plan.data.error} />\n )}\n </div>\n <div className=\"dialog-body\">\n <Notice tone=\"bad\">\n Nothing brings it back, except a database backup from before now, with the vault key.\n </Notice>\n </div>\n <form\n className=\"form\"\n onSubmit={(event) => {\n event.preventDefault();\n if (typed !== path || deletion === null) return;\n run(\n () => (what === 'project' ? coffre.projects.delete(path) : coffre.environments.delete(path)),\n {\n affects: affects.places(),\n onSuccess: (result) => {\n onOpenChange(false);\n return onDeleted(result.deletion);\n },\n },\n );\n }}\n >\n <label className=\"field\">\n <span className=\"label\">\n Type <span className=\"mono\">{path}</span> to confirm\n </span>\n <input\n className=\"input input-mono\"\n autoFocus\n spellCheck={false}\n autoComplete=\"off\"\n value={typed}\n onChange={(event) => setTyped(event.target.value)}\n />\n </label>\n <ErrorLine error={error} />\n <div className=\"dialog-actions\">\n <button className=\"btn\" type=\"button\" onClick={() => onOpenChange(false)}>\n Cancel\n </button>\n <button\n className=\"btn btn-danger\"\n type=\"submit\"\n disabled={typed !== path || deletion === null || pending}\n >\n {pending ? <Spinner /> : <Trash size={14} />}\n Delete {what}\n </button>\n </div>\n </form>\n </Modal>\n );\n}\n\n/** What the deletion takes and what it keeps, in the server's numbers. */\nfunction DeletionSummary({ deletion, what }: { deletion: Deletion; what: 'project' | 'environment' }) {\n const count = (n: number, one: string) => `${n} ${one}${n === 1 ? '' : 's'}`;\n const environments = what === 'project' && deletion.environments.length > 0 ? (\n <>\n {' '}\n in <span className=\"mono\">{deletion.environments.join(', ')}</span>\n </>\n ) : null;\n return (\n <ul className=\"deletion-summary\">\n <li>\n <strong>Erased:</strong> the values of {count(deletion.versions, 'secret version')}\n {environments}.\n </li>\n <li>\n <strong>Revoked:</strong> {count(deletion.grants.length, 'grant')}\n {deletion.grants.length > 0 && (\n <>\n {', '}\n {deletion.grants.map((grant, index) => (\n <span key={`${grant.member} ${grant.place}`}>\n {index > 0 && ', '}\n <span className=\"mono\">{shownMember(grant.member)}</span> on{' '}\n <span className=\"mono\">{grant.place}</span>\n </span>\n ))}\n </>\n )}\n .\n </li>\n {deletion.references.length > 0 && (\n <li>\n <strong>Ended:</strong> {count(deletion.references.length, 'reference')}, which read it from\n elsewhere or which it reads:{' '}\n {deletion.references.map((reference, index) => (\n <span key={`${reference.holder} ${reference.source}`}>\n {index > 0 && ', '}\n <span className=\"mono\">{reference.holder}</span> from{' '}\n <span className=\"mono\">{reference.source}</span>\n </span>\n ))}\n .\n </li>\n )}\n <li>\n <strong>Kept, names only:</strong> the {what} and its {count(deletion.keys, 'key')}, as{' '}\n <span className=\"mono\">{deletion.tombstone}</span>, for the audit log. Its name is free\n to use again.\n </li>\n {deletion.stranded.length > 0 && (\n <li>\n <strong>Left with no access:</strong>{' '}\n {deletion.stranded.map((member, index) => (\n <span key={member}>\n {index > 0 && ', '}\n <span className=\"mono\">{shownMember(member)}</span>\n </span>\n ))}\n . Offboard them on the Users or Service accounts page if they are no longer needed.\n </li>\n )}\n </ul>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAAgB,kBAAkB,EAChC,MACA,MACA,cACA,aAMC;CACD,MAAM,SAAS,UAAU;CACzB,MAAM,OAAO,SAAS;EAAE,GAAG,QAAQ,SAAS,QAAQ,IAAI;EAAG,SAAS;CAAK,CAAC;CAC1E,MAAM,CAAC,OAAO,YAAY,SAAS,EAAE;CACrC,MAAM,EAAE,SAAS,OAAO,UAAU,QAAQ,UAAU;CACpD,MAAM,OAAO,KAAK,SAAS,GAAG,IAAI,gBAAgB;CAElD,gBAAgB;EACd,IAAI,CAAC,MAAM;EACX,SAAS,EAAE;EACX,SAAS,IAAI;CACf,GAAG,CAAC,MAAM,QAAQ,CAAC;CAEnB,MAAM,WAAW,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,WAAW;CAE/D,OACE,qBAAC,OAAD;EACQ;EACQ;EACd,OACE,qBAAA,YAAA,EAAA,UAAA;GAAE;GACO,oBAAC,QAAD;IAAM,WAAU;cAAQ;GAAW,CAAA;GAAC;EAC3C,EAAA,CAAA;YANN;GASE,oBAAC,OAAD;IAAK,WAAU;cACZ,KAAK,SAAS,KAAA,IACb,oBAAC,SAAD,CAAU,CAAA,IACR,KAAK,KAAK,KACZ,oBAAC,iB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D,oBAAC,QAAD;MAAM,WAAU;gBAAQ,UAAU;KAAa,CAAA;IAC3C,EAAA,GAJK,GAAG,UAAU,OAAO,GAAG,UAAU,QAItC,CACP;IAAE;GAED,EAAA,CAAA;GAEN,qBAAC,MAAD,EAAA,UAAA;IACE,oBAAC,UAAD,EAAA,UAAQ,oBAAyB,CAAA;IAAC;IAAM;IAAK;IAAU,MAAM,SAAS,MAAM,KAAK;IAAE;IAAK;IACxF,oBAAC,QAAD;KAAM,WAAU;eAAQ,SAAS;IAAgB,CAAA;IAAC;GAEhD,EAAA,CAAA;GACH,SAAS,SAAS,SAAS,KAC1B,qBAAC,MAAD,EAAA,UAAA;IACE,oBAAC,UAAD,EAAA,UAAQ,uBAA4B,CAAA;IAAE;IACrC,SAAS,SAAS,KAAK,QAAQ,UAC9B,qBAAC,QAAD,EAAA,UAAA,CACG,QAAQ,KAAK,MACd,oBAAC,QAAD;KAAM,WAAU;eAAQ,YAAY,MAAM;IAAQ,CAAA,CAC9C,EAAA,GAHK,MAGL,CACP;IAAE;GAED,EAAA,CAAA;EAEJ;;AAER"}
1
+ {"version":3,"file":"delete-place-SOOYVt6A.js","names":[],"sources":["../../src/components/delete-place.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { useQuery } from '@tanstack/react-query';\nimport { shownMember, type Deletion } from '@coffre/client';\n\nimport { useCoffre } from '../lib/coffre';\nimport { affects, queries } from '../lib/queries';\nimport { useAction } from '../lib/use-action';\nimport { Trash } from './icons';\nimport { ErrorLine, Modal, Notice, Spinner } from './ui';\n\n/**\n * Deleting an archived project or environment for good, `market` or\n * `market/prod`. The dialog first asks the server what the deletion would\n * take, then needs the place's path typed out before it deletes: nothing\n * brings it back, so the one click a slip can make is never enough.\n */\nexport function DeletePlaceDialog({\n path,\n open,\n onOpenChange,\n onDeleted,\n}: {\n path: string;\n open: boolean;\n onOpenChange: (open: boolean) => void;\n onDeleted: (deletion: Deletion) => unknown;\n}) {\n const coffre = useCoffre();\n const plan = useQuery({ ...queries.deletion(coffre, path), enabled: open });\n const [typed, setTyped] = useState('');\n const { pending, error, setError, run } = useAction();\n const what = path.includes('/') ? 'environment' : 'project';\n\n useEffect(() => {\n if (!open) return;\n setTyped('');\n setError(null);\n }, [open, setError]);\n\n const deletion = plan.data?.ok === true ? plan.data.deletion : null;\n\n return (\n <Modal\n open={open}\n onOpenChange={onOpenChange}\n title={\n <>\n Delete <span className=\"mono\">{path}</span> for good?\n </>\n }\n >\n <div className=\"dialog-body\">\n {plan.data === undefined ? (\n <Spinner />\n ) : plan.data.ok ? (\n <DeletionSummary deletion={plan.data.deletion} what={what} />\n ) : (\n <ErrorLine error={plan.data.error} />\n )}\n </div>\n <div className=\"dialog-body\">\n <Notice tone=\"bad\">\n Nothing brings it back, except a database backup from before now, with the vault key.\n </Notice>\n </div>\n <form\n className=\"form\"\n onSubmit={(event) => {\n event.preventDefault();\n if (typed !== path || deletion === null) return;\n run(\n () => (what === 'project' ? coffre.projects.delete(path) : coffre.environments.delete(path)),\n {\n affects: affects.places(),\n onSuccess: (result) => {\n onOpenChange(false);\n return onDeleted(result.deletion);\n },\n },\n );\n }}\n >\n <label className=\"field\">\n <span className=\"label\">\n Type <span className=\"mono\">{path}</span> to confirm\n </span>\n <input\n className=\"input input-mono\"\n autoFocus\n spellCheck={false}\n autoComplete=\"off\"\n value={typed}\n onChange={(event) => setTyped(event.target.value)}\n />\n </label>\n <ErrorLine error={error} />\n <div className=\"dialog-actions\">\n <button className=\"btn\" type=\"button\" onClick={() => onOpenChange(false)}>\n Cancel\n </button>\n <button\n className=\"btn btn-danger\"\n type=\"submit\"\n disabled={typed !== path || deletion === null || pending}\n >\n {pending ? <Spinner /> : <Trash size={14} />}\n Delete {what}\n </button>\n </div>\n </form>\n </Modal>\n );\n}\n\n/** What the deletion takes and what it keeps, in the server's numbers. */\nfunction DeletionSummary({ deletion, what }: { deletion: Deletion; what: 'project' | 'environment' }) {\n const count = (n: number, one: string) => `${n} ${one}${n === 1 ? '' : 's'}`;\n const environments = what === 'project' && deletion.environments.length > 0 ? (\n <>\n {' '}\n in <span className=\"mono\">{deletion.environments.join(', ')}</span>\n </>\n ) : null;\n return (\n <ul className=\"deletion-summary\">\n <li>\n <strong>Erased:</strong> the values of {count(deletion.versions, 'secret version')}\n {environments}.\n </li>\n <li>\n <strong>Revoked:</strong> {count(deletion.grants.length, 'grant')}\n {deletion.grants.length > 0 && (\n <>\n {', '}\n {deletion.grants.map((grant, index) => (\n <span key={`${grant.member} ${grant.place}`}>\n {index > 0 && ', '}\n <span className=\"mono\">{shownMember(grant.member)}</span> on{' '}\n <span className=\"mono\">{grant.place}</span>\n </span>\n ))}\n </>\n )}\n .\n </li>\n {deletion.references.length > 0 && (\n <li>\n <strong>Ended:</strong> {count(deletion.references.length, 'reference')}, which read it from\n elsewhere or which it reads:{' '}\n {deletion.references.map((reference, index) => (\n <span key={`${reference.holder} ${reference.source}`}>\n {index > 0 && ', '}\n <span className=\"mono\">{reference.holder}</span> from{' '}\n <span className=\"mono\">{reference.source}</span>\n </span>\n ))}\n .\n </li>\n )}\n <li>\n <strong>Kept, names only:</strong> the {what} and its {count(deletion.keys, 'key')}, as{' '}\n <span className=\"mono\">{deletion.tombstone}</span>, for the audit log. Its name is free\n to use again.\n </li>\n {deletion.stranded.length > 0 && (\n <li>\n <strong>Left with no access:</strong>{' '}\n {deletion.stranded.map((member, index) => (\n <span key={member}>\n {index > 0 && ', '}\n <span className=\"mono\">{shownMember(member)}</span>\n </span>\n ))}\n . Offboard them on the Users or Service accounts page if they are no longer needed.\n </li>\n )}\n </ul>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAAgB,kBAAkB,EAChC,MACA,MACA,cACA,aAMC;CACD,MAAM,SAAS,UAAU;CACzB,MAAM,OAAO,SAAS;EAAE,GAAG,QAAQ,SAAS,QAAQ,IAAI;EAAG,SAAS;CAAK,CAAC;CAC1E,MAAM,CAAC,OAAO,YAAY,SAAS,EAAE;CACrC,MAAM,EAAE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toggletip, i as EmptyState, l as Spinner, n as ConfirmDialog, o as MenuPopup, s as Modal, u as Timestamp } from "./ui-DJje3gST.js";
2
- import { A as Key, B as MoreHorizontal, E as GitHub, F as Lock, H as Pencil, J as ShieldCheck, N as Link, T as Folder, U as Plus, it as X, s as memberRef, tt as User, u as useCoffre, x as Clock } from "./page-DvsgZ2Hd.js";
3
- import { a as rowClass, i as RowPending, r as RowFailure } from "./row-state-DOPUsjQK.js";
4
- import { b as waysFor, g as queries } from "./queries-DE5nK2y4.js";
5
- import { t as useShell } from "./use-shell-BO4ZTr1y.js";
6
- import { b as removeMember, g as invite, l as directoryList, n as useChangeStatus, o as changeRole, t as useChange } from "./use-change-BJ3dCFHb.js";
1
+ import { f as Toggletip, i as EmptyState, l as Spinner, n as ConfirmDialog, o as MenuPopup, s as Modal, u as Timestamp } from "./ui-Br-dNUTc.js";
2
+ import { o as setByDeployment } from "./affordances-Dtyha68j.js";
3
+ import { E as Folder, F as Link, G as Plus, H as MoreHorizontal, L as Lock, M as Key, O as GitHub, S as Clock, W as Pencil, X as ShieldCheck, it as User, s as memberRef, st as X, u as useCoffre } from "./page-JTORvh-N.js";
4
+ import { a as rowClass, i as RowPending, r as RowFailure } from "./row-state-Zf3kZVhd.js";
5
+ import { b as waysFor, g as queries } from "./queries-DgQo3mC-.js";
6
+ import { t as useShell } from "./use-shell-D6kjSPls.js";
7
+ import { b as removeMember, g as invite, l as directoryList, n as useChangeStatus, o as changeRole, t as useChange } from "./use-change-By4cG8bT.js";
7
8
  import { r as scopeComplete } from "./validation-DiHIwZRA.js";
8
- import { n as PrincipalLink } from "./principal-BIN-xwZw.js";
9
- import { t as RoleField } from "./role-field-DWhkRY6n.js";
9
+ import { n as PrincipalLink } from "./principal-DFBswTBr.js";
10
+ import { t as RoleField } from "./role-field-BfWRCqzl.js";
10
11
  import { Fragment, useState } from "react";
11
12
  import { Menu } from "@base-ui/react/menu";
12
13
  import { EVERYWHERE, INSTANCE_ROLES, scopeInWords, unscoped } from "@coffre/core/access";
@@ -15,20 +16,16 @@ import { useQuery } from "@tanstack/react-query";
15
16
  //#region src/components/directory.tsx
16
17
  /** How the directory, and its changes, name someone to the API: `user:…`, `token:…` (shown `service:…`). */
17
18
  var memberOf = (principal) => memberRef(principal.principalType, principal.principalId);
18
- var ROLE_LABEL = {
19
- "root-admin": "Root admin",
20
- ...Object.fromEntries(Object.entries(INSTANCE_ROLES).map(([role, { name }]) => [role, name]))
21
- };
22
19
  /** A new person's role: a Member, everywhere. */
23
20
  var MEMBER = {
24
21
  role: "member",
25
22
  scope: EVERYWHERE
26
23
  };
27
24
  /** The role a principal holds, as the role field edits it. */
28
- var roleOf = (principal) => principal.instanceRole === "root-admin" ? MEMBER : {
25
+ var roleOf = (principal) => ({
29
26
  role: principal.instanceRole,
30
27
  scope: principal.scope ?? EVERYWHERE
31
- };
28
+ });
32
29
  /** What each kind of principal is called in the interface. */
33
30
  var KIND = {
34
31
  user: "user",
@@ -66,7 +63,7 @@ function DirectoryTable({ principalType, principals, hasRemoved = false }) {
66
63
  className: "col-role",
67
64
  children: /* @__PURE__ */ jsxs("span", {
68
65
  className: "th",
69
- children: [/* @__PURE__ */ jsx(ShieldCheck, { size: 14 }), "Instance role"]
66
+ children: [/* @__PURE__ */ jsx(ShieldCheck, { size: 14 }), "Role"]
70
67
  })
71
68
  }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
72
69
  /* @__PURE__ */ jsx("th", {
@@ -118,7 +115,7 @@ function DirectoryTable({ principalType, principals, hasRemoved = false }) {
118
115
  }),
119
116
  users ? /* @__PURE__ */ jsx("td", {
120
117
  className: "col-role",
121
- "data-label": "Instance role",
118
+ "data-label": "Role",
122
119
  children: /* @__PURE__ */ jsx(InstanceRole, { principal })
123
120
  }) : /* @__PURE__ */ jsx(ServiceCells, { principal }),
124
121
  /* @__PURE__ */ jsx("td", {
@@ -227,10 +224,10 @@ function ServiceCells({ principal }) {
227
224
  }
228
225
  /**
229
226
  * A user's instance role. Service accounts have none worth showing: every one is a
230
- * plain member. A root admin's role comes from the deployment, so its tag says
231
- * so on hover or tap instead of offering a menu that could not work.
227
+ * plain member.
232
228
  */
233
229
  function InstanceRole({ principal }) {
230
+ const { capabilities } = useShell();
234
231
  if (principal.tampered === true) return /* @__PURE__ */ jsx(Toggletip, {
235
232
  label: /* @__PURE__ */ jsx(Fragment$1, { children: "Their record was changed outside coffre, so the vault refuses them everything. To start over, remove them and add them again." }),
236
233
  children: /* @__PURE__ */ jsxs("button", {
@@ -239,21 +236,18 @@ function InstanceRole({ principal }) {
239
236
  children: [/* @__PURE__ */ jsx(Lock, { size: 11 }), "Integrity check failed"]
240
237
  })
241
238
  });
242
- if (principal.isRootAdmin) return /* @__PURE__ */ jsx(Toggletip, {
243
- label: /* @__PURE__ */ jsxs(Fragment$1, { children: [
244
- "Set by ",
245
- /* @__PURE__ */ jsx("code", { children: "rootAdmins" }),
246
- " in the vault's configuration, not here."
247
- ] }),
248
- children: /* @__PURE__ */ jsxs("button", {
239
+ const name = INSTANCE_ROLES[principal.instanceRole].name;
240
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [setByDeployment(principal, capabilities) ? /* @__PURE__ */ jsx(Toggletip, {
241
+ label: "Set by deployment",
242
+ children: /* @__PURE__ */ jsx("button", {
249
243
  type: "button",
250
- className: "tag tag-violet tag-button",
251
- children: [/* @__PURE__ */ jsx(Lock, { size: 11 }), "Root admin"]
244
+ className: "tag tag-button",
245
+ "aria-label": `${name}, set by deployment`,
246
+ children: name
252
247
  })
253
- });
254
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
248
+ }) : /* @__PURE__ */ jsx("span", {
255
249
  className: `tag${principal.instanceRole === "member" ? "" : " tag-violet"}`,
256
- children: ROLE_LABEL[principal.instanceRole]
250
+ children: name
257
251
  }), principal.instanceRole !== "member" && principal.scope !== null && !unscoped(principal.scope) && /* @__PURE__ */ jsx("span", {
258
252
  className: "role-scope",
259
253
  children: scopeInWords(principal.scope)
@@ -261,8 +255,10 @@ function InstanceRole({ principal }) {
261
255
  }
262
256
  /**
263
257
  * Change role and Remove, behind one menu, for those who run the instance;
264
- * Remove, for a service account you manage. Root admins get none: the
265
- * deployment's configuration owns them. Nobody changes their own role.
258
+ * Remove, for a service account you manage. Nobody changes their own role
259
+ * but an Owner of the whole instance, who alone changes or removes an
260
+ * Owner: to anyone else, an Owner's row says so instead. Nobody changes or
261
+ * removes an Owner the deployment names: their row says where they are named.
266
262
  */
267
263
  function PrincipalActions({ principal, trigger = "act act-quiet act-menu" }) {
268
264
  const [editing, setEditing] = useState(false);
@@ -277,7 +273,34 @@ function PrincipalActions({ principal, trigger = "act act-quiet act-menu" }) {
277
273
  const kind = KIND[principal.principalType];
278
274
  const self = me?.type === principal.principalType && me.id === principal.principalId;
279
275
  const yours = principal.principalType === "service" && principal.managed === true;
280
- if (principal.isRootAdmin || !(capabilities.runsInstance || yours)) return null;
276
+ if (!(capabilities.runsInstance || yours)) return null;
277
+ if (principal.declared === true) return /* @__PURE__ */ jsx(Toggletip, {
278
+ label: /* @__PURE__ */ jsxs(Fragment$1, { children: [
279
+ "The deployment names them an Owner: ",
280
+ /* @__PURE__ */ jsx("span", {
281
+ className: "mono",
282
+ children: "owners"
283
+ }),
284
+ " in the vault's configuration. To change or remove them, take them off that list and deploy."
285
+ ] }),
286
+ align: "end",
287
+ children: /* @__PURE__ */ jsx("button", {
288
+ type: "button",
289
+ className: trigger,
290
+ "aria-label": `Why ${principal.principalId} can't be changed`,
291
+ children: /* @__PURE__ */ jsx(Lock, { size: 14 })
292
+ })
293
+ });
294
+ if (principal.instanceRole === "owner" && !capabilities.ownsInstance) return /* @__PURE__ */ jsx(Toggletip, {
295
+ label: "Only an Owner of the whole instance changes or removes an Owner.",
296
+ align: "end",
297
+ children: /* @__PURE__ */ jsx("button", {
298
+ type: "button",
299
+ className: trigger,
300
+ "aria-label": `Why ${principal.principalId} can't be changed`,
301
+ children: /* @__PURE__ */ jsx(Lock, { size: 14 })
302
+ })
303
+ });
281
304
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
282
305
  /* @__PURE__ */ jsxs(Menu.Root, { children: [/* @__PURE__ */ jsx(Menu.Trigger, {
283
306
  className: trigger,
@@ -286,7 +309,7 @@ function PrincipalActions({ principal, trigger = "act act-quiet act-menu" }) {
286
309
  children: pending ? /* @__PURE__ */ jsx(Spinner, { size: 13 }) : /* @__PURE__ */ jsx(MoreHorizontal, { size: 16 })
287
310
  }), /* @__PURE__ */ jsxs(MenuPopup, {
288
311
  align: "end",
289
- children: [principal.principalType === "user" && !self && capabilities.runsInstance && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(Menu.Item, {
312
+ children: [principal.principalType === "user" && (!self || capabilities.ownsInstance) && capabilities.runsInstance && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(Menu.Item, {
290
313
  className: "menu-item",
291
314
  onClick: () => {
292
315
  setRole(roleOf(principal));
@@ -425,7 +448,7 @@ function AddPrincipal({ principalType }) {
425
448
  open,
426
449
  onOpenChange: (next) => next ? setOpen(true) : close(),
427
450
  title: `Add a ${kind}`,
428
- description: principalType === "user" ? "Their instance role reaches every project in its scope. Grant more afterwards, from their page or a project's." : "This gives the service account no project access. Grant it afterwards, from its page or a project's.",
451
+ description: principalType === "user" ? void 0 : "This gives the service account no project access. Grant it afterwards, from its page or a project's.",
429
452
  children: /* @__PURE__ */ jsxs("form", {
430
453
  className: "form",
431
454
  onSubmit: (event) => {
@@ -442,7 +465,7 @@ function AddPrincipal({ principalType }) {
442
465
  className: "field",
443
466
  children: [/* @__PURE__ */ jsx("span", {
444
467
  className: "label",
445
- children: principalType === "user" ? "Cloudflare Access email" : "Service account name"
468
+ children: principalType === "user" ? "Email" : "Service account name"
446
469
  }), /* @__PURE__ */ jsx("input", {
447
470
  className: "input input-mono",
448
471
  autoFocus: true,
@@ -478,4 +501,4 @@ function AddPrincipal({ principalType }) {
478
501
  //#endregion
479
502
  export { PrincipalActions as i, InstanceRole as n, KIND as r, DirectoryTable as t };
480
503
 
481
- //# sourceMappingURL=directory-DSVt5Tya.js.map
504
+ //# sourceMappingURL=directory-DrtdKny2.js.map