@coffre/ui 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/dist/chunks/{affordances-Bqdevf7w.js → affordances-D0GyCT-I.js} +3 -3
  2. package/dist/chunks/affordances-D0GyCT-I.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-IP0KfUjo.js} +5 -5
  6. package/dist/chunks/{connected-apps-DTNS7YmY.js.map → connected-apps-IP0KfUjo.js.map} +1 -1
  7. package/dist/chunks/{delete-place-CIaOq0mt.js → delete-place-CVv6CN5y.js} +5 -5
  8. package/dist/chunks/{delete-place-CIaOq0mt.js.map → delete-place-CVv6CN5y.js.map} +1 -1
  9. package/dist/chunks/{directory-DSVt5Tya.js → directory-pMVS1m-c.js} +62 -43
  10. package/dist/chunks/directory-pMVS1m-c.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-CgC8Ybhu.js} +6 -6
  14. package/dist/chunks/{grants-CRU7yZhL.js.map → grants-CgC8Ybhu.js.map} +1 -1
  15. package/dist/chunks/{offboarding-DVBSiJRZ.js → offboarding-3fzRjKla.js} +5 -5
  16. package/dist/chunks/{offboarding-DVBSiJRZ.js.map → offboarding-3fzRjKla.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-CYJIJAdp.js} +17 -19
  22. package/dist/chunks/principal-page-CYJIJAdp.js.map +1 -0
  23. package/dist/chunks/{project-page-B3TZ5_ig.js → project-page-lO5P6iCb.js} +3 -3
  24. package/dist/chunks/{project-page-B3TZ5_ig.js.map → project-page-lO5P6iCb.js.map} +1 -1
  25. package/dist/chunks/{queries-DE5nK2y4.js → queries-gigcQOO_.js} +26 -12
  26. package/dist/chunks/queries-gigcQOO_.js.map +1 -0
  27. package/dist/chunks/{references-uv4Mli9z.js → references-DZ179hTJ.js} +5 -5
  28. package/dist/chunks/{references-uv4Mli9z.js.map → references-DZ179hTJ.js.map} +1 -1
  29. package/dist/chunks/{role-field-DWhkRY6n.js → role-field-DiqiFwm_.js} +14 -7
  30. package/dist/chunks/role-field-DiqiFwm_.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-CQGGNqWb.js} +3 -3
  40. package/dist/chunks/{use-action-BRgvbUWt.js.map → use-action-CQGGNqWb.js.map} +1 -1
  41. package/dist/chunks/{use-change-BJ3dCFHb.js → use-change-BdS1gzyo.js} +31 -19
  42. package/dist/chunks/use-change-BdS1gzyo.js.map +1 -0
  43. package/dist/chunks/{use-shell-BO4ZTr1y.js → use-shell-BCU505bx.js} +3 -3
  44. package/dist/chunks/{use-shell-BO4ZTr1y.js.map → use-shell-BCU505bx.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 +829 -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 +1 -1
  76. package/src/components/directory.tsx +40 -34
  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 +18 -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 +228 -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
@@ -1 +0,0 @@
1
- {"version":3,"file":"audit-sentence-Cm5nby5k.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/** 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 },\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': { did: 'brought back', tried: 'bring back', what: ({ entry }) => [...subject(entry), ...asRole(entry)] },\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 [...(before === null ? [] : [`, was ${before}`]), ...(entry.metadata.reason === 'every-project' ? [', for their grants on every project'] : [])];\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 }) => 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 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 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,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,GARK,KAQL,CACX,EACD,CAAA;AAEN;AAEA,SAAS,UAAU,EAAE,QAA0B;CAC7C,MAAM,CAAC,SAAS,eAAe,KAAK,MAAM,GAAG;CAC7C,MAAM,OAAO,oBAAC,QAAD;EAAM,WAAU;YAAQ,sBAAsB,IAAI;CAAQ,CAAA;CACvE,OAAO,gBAAgB,KAAA,IACrB,oBAAC,MAAD;EAAM,IAAG;EAAqB,QAAQ,EAAE,QAAQ;YAC7C;CACG,CAAA,IAEN,oBAAC,MAAD;EAAM,IAAG;EAAkC,QAAQ;GAAE;GAAS;EAAY;YACvE;CACG,CAAA;AAEV;;AAGA,SAAS,WAAW,EAAE,UAA8B;CAClD,OAAO,OAAO,WAAW,QAAQ,IAC/B,oBAAC,MAAD;EAAM,IAAG;EAA6B,QAAQ,EAAE,SAAS,YAAY,MAAM,EAAE;YAC1E,YAAY,MAAM;CACf,CAAA,IAEN,oBAAC,MAAD;EAAM,IAAG;EAAe,QAAQ,EAAE,MAAM,WAAW,MAAM,EAAE;YACxD,WAAW,MAAM;CACd,CAAA;AAEV;AAEA,SAAgB,WAAW,QAAwB;CACjD,OAAO,OAAO,WAAW,OAAO,IAAI,OAAO,MAAM,CAAc,IAAI,YAAY,MAAM;AACvF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"directory-DSVt5Tya.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 { EVERYWHERE, INSTANCE_ROLES, scopeInWords, unscoped } from '@coffre/core/access';\nimport { changeRole, directoryList, invite, removeMember, type InviteVars, type RoleVars } from '../lib/changes';\nimport { memberRef, useCoffre } from '../lib/coffre';\nimport { scopeComplete } from '../lib/validation';\nimport { queries, waysFor } 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 { RoleField } from './role-field';\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 ...Object.fromEntries(Object.entries(INSTANCE_ROLES).map(([role, { name }]) => [role, name])),\n} as Record<DirectoryPrincipal['instanceRole'], string>;\n\n/** A new person's role: a Member, everywhere. */\nconst MEMBER: RoleVars = { role: 'member', scope: EVERYWHERE };\n\n/** The role a principal holds, as the role field edits it. */\nconst roleOf = (principal: DirectoryPrincipal): RoleVars =>\n principal.instanceRole === 'root-admin' ? MEMBER : { role: principal.instanceRole, scope: principal.scope ?? EVERYWHERE };\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 { capabilities } = useShell();\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]}`}, then\n grant it project access 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 {(capabilities.runsInstance || (!users && capabilities.setsUpServices)) && (\n <div className=\"table-actions\">\n <AddPrincipal principalType={principalType} />\n </div>\n )}\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 shell = useShell();\n const member = memberOf(principal);\n // As `loadServiceDirectory` read them, so these come from its cache; an account just added is yours.\n const ways = waysFor(shell, principal.managed !== false);\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, ways.workloads));\n const { data: credentials } = useQuery(queries.credentials(client, member, ways.tokens));\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. To start over, remove them and 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, not 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 <>\n <span className={`tag${principal.instanceRole === 'member' ? '' : ' tag-violet'}`}>\n {ROLE_LABEL[principal.instanceRole]}\n </span>\n {principal.instanceRole !== 'member' && principal.scope !== null && !unscoped(principal.scope) && (\n <span className=\"role-scope\">{scopeInWords(principal.scope)}</span>\n )}\n </>\n );\n}\n\n/**\n * Change role and Remove, behind one menu, for those who run the instance;\n * Remove, for a service account you manage. Root admins get none: the\n * deployment's configuration owns them. Nobody changes their own role.\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 [role, setRole] = useState<RoleVars>(roleOf(principal));\n const { capabilities, principal: me } = useShell();\n const coffre = useCoffre();\n const saveRole = 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 const self = me?.type === principal.principalType && me.id === principal.principalId;\n const yours = principal.principalType === 'service' && principal.managed === true;\n if (principal.isRootAdmin || !(capabilities.runsInstance || yours)) 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' && !self && capabilities.runsInstance && (\n <>\n <Menu.Item\n className=\"menu-item\"\n onClick={() => {\n setRole(roleOf(principal));\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 saveRole({ principalId: principal.principalId, ...role });\n setEditing(false);\n }}\n >\n <RoleField value={role} onChange={setRole} />\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\" disabled={!scopeComplete(role)}>\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.runsInstance),\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 [role, setRole] = useState<RoleVars>(MEMBER);\n const add = useChange(invite(useCoffre()));\n const kind = KIND[principalType];\n\n function close() {\n setOpen(false);\n setPrincipalId('');\n setRole(MEMBER);\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={\n principalType === 'user'\n ? 'Their instance role reaches every project in its scope. Grant more afterwards, from their page or a project\\'s.'\n : 'This gives the service account no project access. Grant it afterwards, from its page or a project\\'s.'\n }\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(), ...role });\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' && <RoleField value={role} onChange={setRole} />}\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() === '' || !scopeComplete(role)}>\n Add {kind}\n </button>\n </div>\n </form>\n </Modal>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA4BA,IAAa,YAAY,cACvB,UAAU,UAAU,eAAe,UAAU,WAAW;AAE1D,IAAa,aAAiE;CAC5E,cAAc;CACd,GAAG,OAAO,YAAY,OAAO,QAAQ,cAAc,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,YAAY,CAAC,MAAM,IAAI,CAAC,CAAC;AAC9F;;AAGA,IAAM,SAAmB;CAAE,MAAM;CAAU,OAAO;AAAW;;AAG7D,IAAM,UAAU,cACd,UAAU,iBAAiB,eAAe,SAAS;CAAE,MAAM,UAAU;CAAc,OAAO,UAAU,SAAS;AAAW;;AAG1H,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,iBAAiB,SAAS;CAClC,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,Q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eAAe,QAAQ,IAAI;YAA/D;GACE,oBAAC,MAAD,EAAM,MAAM,GAAK,CAAA;GAAC;GACb;EACC;KAER,oBAAC,OAAD;EACQ;EACN,eAAe,SAAU,OAAO,QAAQ,IAAI,IAAI,MAAM;EACtD,OAAO,SAAS;EAChB,aACE,kBAAkB,SACd,mHACA;YAGN,qBAAC,QAAD;GACE,WAAU;GACV,WAAW,UAAU;IACnB,MAAM,eAAe;IAErB,IAAI;KAAE;KAAe,aAAa,YAAY,KAAK;KAAG,GAAG;IAAK,CAAC;IAC/D,MAAM;GACR;aAPF;IASE,qBAAC,SAAD;KAAO,WAAU;eAAjB,CACE,oBAAC,QAAD;MAAM,WAAU;gBACb,kBAAkB,SAAS,4BAA4B;KACpD,CAAA,GACN,oBAAC,SAAD;MACE,WAAU;MACV,WAAA;MACA,YAAY;MACZ,cAAa;MACb,OAAO;MACP,aACE,kBAAkB,SAAS,yBAAyB;MAEtD,WAAW,UAAU,eAAe,MAAM,OAAO,KAAK;KACvD,CAAA,CACI;;IAEN,kBAAkB,UAAU,oBAAC,WAAD;KAAW,OAAO;KAAM,UAAU;IAAU,CAAA;IAEzE,qBAAC,OAAD;KAAK,WAAU;eAAf,CACE,oBAAC,UAAD;MAAQ,WAAU;MAAM,MAAK;MAAS,SAAS;gBAAO;KAE9C,CAAA,GACR,qBAAC,UAAD;MAAQ,WAAU;MAAkB,MAAK;MAAS,UAAU,YAAY,KAAK,MAAM,MAAM,CAAC,cAAc,IAAI;gBAA5G,CAA+G,QACxG,IACC;OACL;;GACD;;CACD,CAAA,CACP,EAAA,CAAA;AAEN"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"page-DvsgZ2Hd.js","names":[],"sources":["../../src/components/mark.ts","../../src/components/icons.tsx","../../src/components/tile.tsx","../../src/lib/coffre.ts","../../src/components/page.tsx"],"sourcesContent":["/**\n * coffre's mark: a keyhole cut from a disc, which leaves a lowercase c, its\n * slot tilted up 14°. Drawn on a 32-unit grid, where 2 units are a pixel at\n * 16px.\n *\n * Everything that draws it reads this file: `Mark` in the app, the favicon,\n * and `scripts/icons.ts`, which renders the PNGs and the README's mark from\n * it. The colours stand in until the brand has its own: change them here,\n * then run `pnpm --filter @coffre/ui icons`.\n */\n\n/** 64px and up. */\nexport const MARK_PATH = 'M24.17 12.23A9 9 0 1 0 24.93 14.91L18.39 16.27A3.6 3.6 0 1 1 17.84 14.07Z';\n\n/** 48px and below: a larger disc, the hole on the pixel grid, a thicker slot, so both stay open at 16px. */\nexport const MARK_PATH_SMALL = 'M25.77 10.94A11 11 0 1 0 26.95 14.9L17.92 16.81A4 4 0 1 1 17.08 13.45Z';\n\n/** The tile behind the mark wherever it stands alone: the favicon, app icons, the README. */\nexport const TILE = '#000';\n\n/** The mark on its tile. */\nexport const INK = '#fff';\n\n/** The tile's corner radius, on the 32-unit grid. */\nexport const TILE_RADIUS = 7;\n\nexport function markPath(size: number): string {\n return size <= 48 ? MARK_PATH_SMALL : MARK_PATH;\n}\n\n/**\n * The mark on its tile, as an SVG document, drawn for `size` pixels.\n * `square` leaves the corners for the platform to round (iOS, GitHub);\n * `adaptive` swaps the colours in a dark browser, for the favicon.\n */\nexport function markSvg(size: number, { square = false, adaptive = false } = {}): string {\n const dark = adaptive ? `<style>@media (prefers-color-scheme:dark){rect{fill:${INK}}path{fill:${TILE}}}</style>` : '';\n const radius = square ? '' : ` rx=\"${TILE_RADIUS}\"`;\n return (\n `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 32 32\">${dark}` +\n `<rect width=\"32\" height=\"32\"${radius} fill=\"${TILE}\"/>` +\n `<path d=\"${markPath(size)}\" fill=\"${INK}\"/></svg>`\n );\n}\n","import type { LucideIcon } from 'lucide-react';\nimport {\n Activity as ActivityGlyph,\n ArrowRight as ArrowRightGlyph,\n Archive as ArchiveGlyph,\n Ban,\n Check as CheckGlyph,\n ChevronDown as ChevronDownGlyph,\n ChevronRight as ChevronRightGlyph,\n ChevronsUpDown as ChevronsUpDownGlyph,\n CircleAlert,\n CircleCheck,\n Clock as ClockGlyph,\n Copy as CopyGlyph,\n Ellipsis,\n Eye as EyeGlyph,\n EyeOff as EyeOffGlyph,\n Folder as FolderGlyph,\n Hash as HashGlyph,\n History as HistoryGlyph,\n Inbox as InboxGlyph,\n Info as InfoGlyph,\n KeyRound,\n Layers as LayersGlyph,\n Link as LinkGlyph,\n LoaderCircle,\n Lock as LockGlyph,\n LogOut,\n Menu as MenuGlyph,\n Monitor as MonitorGlyph,\n Moon as MoonGlyph,\n PanelLeft as PanelLeftGlyph,\n Pause as PauseGlyph,\n Pencil as PencilGlyph,\n Play as PlayGlyph,\n Plus as PlusGlyph,\n RotateCcw,\n ScrollText,\n Search as SearchGlyph,\n Settings as SettingsGlyph,\n ShieldCheck as ShieldCheckGlyph,\n Sun as SunGlyph,\n Terminal as TerminalGlyph,\n Trash2,\n TriangleAlert,\n Upload as UploadGlyph,\n User as UserGlyph,\n UserRoundCog,\n Users as UsersGlyph,\n X as XGlyph,\n} from 'lucide-react';\nimport { markPath } from './mark';\n\n/**\n * One icon vocabulary for the whole app: Lucide, at one stroke weight.\n *\n * Mixing icon families is the fastest way to make a product UI feel assembled\n * rather than designed, so every glyph comes through here and call sites never\n * import Lucide themselves: changing one is a line in this file. The\n * exceptions are marks that are not ours to redraw: coffre's mark and the\n * sign-in providers' logos.\n */\n\ntype IconProps = {\n size?: number;\n className?: string;\n style?: React.CSSProperties;\n /** Icons are decorative by default; pass a label when one carries meaning. */\n label?: string;\n};\n\nfunction Svg({\n size = 16,\n className,\n style,\n label,\n children,\n}: IconProps & { children: React.ReactNode }) {\n return (\n <svg\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={1.6}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={className}\n style={style}\n aria-hidden={label === undefined}\n aria-label={label}\n role={label === undefined ? undefined : 'img'}\n >\n {children}\n </svg>\n );\n}\n\n/**\n * The mark, bare, in the text's colour, so it follows the theme. The tiled\n * favicon and app icons are drawn from the same paths, in `./mark`.\n */\nexport function Mark({ size = 16, className, style, label }: IconProps) {\n return (\n <svg\n width={size}\n height={size}\n viewBox=\"0 0 32 32\"\n className={className}\n style={style}\n aria-hidden={label === undefined}\n aria-label={label}\n role={label === undefined ? undefined : 'img'}\n >\n <path d={markPath(size)} fill=\"currentColor\" />\n </svg>\n );\n}\n\n/**\n * Lucide draws on a 24-unit grid with a 2-unit stroke. At the 14-16px these\n * are shown, 1.75 sits closer to Inter's weight beside them.\n */\nconst STROKE = 1.75;\n\nfunction lucide(Glyph: LucideIcon) {\n // Lucide hides a glyph from assistive technology unless it is labelled.\n return function Icon({ size = 16, className, style, label }: IconProps) {\n return (\n <Glyph\n size={size}\n strokeWidth={STROKE}\n className={className}\n style={style}\n {...(label === undefined ? {} : { 'aria-label': label, role: 'img' })}\n />\n );\n };\n}\n\n// Places\nexport const Folder = lucide(FolderGlyph);\nexport const Layers = lucide(LayersGlyph);\nexport const Users = lucide(UsersGlyph);\nexport const User = lucide(UserGlyph);\n/** Your own settings, so they never share the instance's gear. */\nexport const UserCog = lucide(UserRoundCog);\nexport const Key = lucide(KeyRound);\nexport const Ledger = lucide(ScrollText);\nexport const Settings = lucide(SettingsGlyph);\n\n// Secrets\nexport const Eye = lucide(EyeGlyph);\nexport const EyeOff = lucide(EyeOffGlyph);\nexport const Copy = lucide(CopyGlyph);\nexport const Pencil = lucide(PencilGlyph);\nexport const Archive = lucide(ArchiveGlyph);\nexport const Trash = lucide(Trash2);\nexport const History = lucide(HistoryGlyph);\nexport const RotateBack = lucide(RotateCcw);\nexport const Upload = lucide(UploadGlyph);\nexport const Pause = lucide(PauseGlyph);\nexport const Play = lucide(PlayGlyph);\nexport const Lock = lucide(LockGlyph);\nexport const Terminal = lucide(TerminalGlyph);\nexport const Hash = lucide(HashGlyph);\nexport const Clock = lucide(ClockGlyph);\n\n// Outcomes\nexport const Check = lucide(CheckGlyph);\nexport const CheckCircle = lucide(CircleCheck);\nexport const SlashCircle = lucide(Ban);\nexport const ShieldCheck = lucide(ShieldCheckGlyph);\nexport const AlertTriangle = lucide(TriangleAlert);\nexport const AlertCircle = lucide(CircleAlert);\nexport const Info = lucide(InfoGlyph);\nexport const Activity = lucide(ActivityGlyph);\nexport const Inbox = lucide(InboxGlyph);\nexport const Loader = lucide(LoaderCircle);\n\n// Controls\nexport const X = lucide(XGlyph);\nexport const Plus = lucide(PlusGlyph);\nexport const Search = lucide(SearchGlyph);\nexport const Menu = lucide(MenuGlyph);\nexport const PanelLeft = lucide(PanelLeftGlyph);\nexport const MoreHorizontal = lucide(Ellipsis);\nexport const ChevronRight = lucide(ChevronRightGlyph);\nexport const ChevronDown = lucide(ChevronDownGlyph);\nexport const ChevronsUpDown = lucide(ChevronsUpDownGlyph);\nexport const ArrowRight = lucide(ArrowRightGlyph);\nexport const Link = lucide(LinkGlyph);\nexport const SignOut = lucide(LogOut);\n\n// Theme\nexport const Sun = lucide(SunGlyph);\nexport const Moon = lucide(MoonGlyph);\nexport const Monitor = lucide(MonitorGlyph);\n\n/**\n * GitHub's mark, drawn as GitHub publishes it: a filled shape on its own\n * 16-unit grid, since a brand is not ours to redraw in the stroke style.\n */\nexport function GitHub({ size = 16, className, style }: IconProps) {\n return (\n <svg\n width={size}\n height={size}\n viewBox=\"0 0 16 16\"\n fill=\"currentColor\"\n className={className}\n style={style}\n aria-hidden\n >\n <path d=\"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8Z\" />\n </svg>\n );\n}\n\n/** Google's \"G\", in its four colours, as Google's sign-in guidelines require. */\nexport function Google({ size = 16, className, style }: IconProps) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 48 48\" className={className} style={style} aria-hidden>\n <path fill=\"#EA4335\" d=\"M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z\" />\n <path fill=\"#4285F4\" d=\"M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z\" />\n <path fill=\"#FBBC05\" d=\"M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z\" />\n <path fill=\"#34A853\" d=\"M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z\" />\n </svg>\n );\n}\n\n/** Microsoft's four squares. */\nexport function Microsoft({ size = 16, className, style }: IconProps) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 21 21\" className={className} style={style} aria-hidden>\n <rect x=\"0\" y=\"0\" width=\"10\" height=\"10\" fill=\"#F25022\" />\n <rect x=\"11\" y=\"0\" width=\"10\" height=\"10\" fill=\"#7FBA00\" />\n <rect x=\"0\" y=\"11\" width=\"10\" height=\"10\" fill=\"#00A4EF\" />\n <rect x=\"11\" y=\"11\" width=\"10\" height=\"10\" fill=\"#FFB900\" />\n </svg>\n );\n}\n\n/** The mark on a provider's button; any other OpenID Connect issuer gets a key. */\nexport function ProviderMark({ brand, size = 16 }: { brand: string; size?: number }) {\n switch (brand) {\n case 'github':\n return <GitHub size={size} />;\n case 'google':\n return <Google size={size} />;\n case 'microsoft':\n return <Microsoft size={size} />;\n default:\n return <Key size={size} />;\n }\n}\n","const HUES = ['blue', 'green', 'amber', 'violet'] as const;\n\n/** The same name always lands on the same tint, on every screen (FNV-1a). */\nexport function tileHue(name: string): (typeof HUES)[number] {\n let hash = 0x811c9dc5;\n for (const char of name) hash = Math.imul(hash ^ char.charCodeAt(0), 0x01000193) >>> 0;\n return HUES[hash % HUES.length];\n}\n\n/**\n * A letter on a tint, standing in for a project wherever its name appears.\n *\n * It is a recognition aid, not information: the name is always beside it, so\n * the tile is hidden from assistive technology.\n */\nexport function Tile({ name, size = 'sm' }: { name: string; size?: 'sm' | 'lg' }) {\n return (\n <span className={`tile tile-${tileHue(name)}${size === 'lg' ? ' tile-lg' : ''}`} aria-hidden>\n {name.slice(0, 1)}\n </span>\n );\n}\n","import { CoffreError, type CoffreClient } from '@coffre/client';\nimport { useRouter } from '@tanstack/react-router';\n\nimport type { CoffreContext } from '../options';\n\n/**\n * The API as whoever is looking at the page, with their permissions: what\n * coffre's pages call, and a deployment's own may too. In the browser this\n * is plain `fetch` to `/api`, carrying the session cookie; on the server,\n * the API in process. Components call it from event handlers; loaders read\n * the same client as `context.coffre`.\n */\nexport function useCoffre(): CoffreClient {\n return (useRouter().options.context as CoffreContext).coffre;\n}\n\n/** A refusal the page words itself, shown as it is. */\nexport class Refusal extends Error {}\n\n/** A call that failed: what to say, and whether signing in again would help, which it does only for an ended session. */\ntype Failure = { ok: false; error: string; signedOut: boolean };\n\n/** The HTTP status of an API error; undefined when the request never got an answer. */\nexport function statusOf(error: unknown): number | undefined {\n return error instanceof CoffreError ? error.status : undefined;\n}\n\n/** What to tell the person when a call fails. */\nexport function failureMessage(error: unknown): string {\n if (error instanceof Refusal) return error.message;\n if (!(error instanceof CoffreError)) return 'The request could not be sent. Nothing was changed.';\n if (error.status === 401) return 'Your session has ended. Sign in again, then retry.';\n if (error.code === 'cross_origin') return 'coffre refused a change that did not come from this page. Reload, then retry.';\n if (error.status === 403) {\n return 'You hold no grant that covers this. Someone with grant.manage on the project can add one.';\n }\n if (error.status === 404) return 'Not found. It may have been renamed or archived.';\n // A 400 or 409 carries a sentence written for the person, such as which\n // field of a request is wrong, which names a service account as people\n // do, service:<name>. Anything unexpected stays generic.\n if (error.status === 400 || error.status === 409) return error.message;\n return 'coffre is unavailable. Nothing was read or written.';\n}\n\nexport function uiFailure(error: unknown): Failure {\n return { ok: false, error: failureMessage(error), signedOut: statusOf(error) === 401 };\n}\n\n/** A loader's answer: what it read, or what to say instead. */\nexport async function uiResult<T extends object>(\n operation: () => Promise<T>,\n): Promise<({ ok: true } & T) | Failure> {\n try {\n return { ok: true, ...(await operation()) };\n } catch (error) {\n return uiFailure(error);\n }\n}\n\n/** How the API names a member: `user:ada@acme.example`, `token:ci-deploy` (which people read as `service:ci-deploy`). */\nexport function memberRef(principalType: 'user' | 'service', principalId: string): string {\n return `${principalType === 'user' ? 'user' : 'token'}:${principalId}`;\n}\n","import type { ReactNode } from 'react';\nimport { Tile } from './tile';\n\n/**\n * The head of every page: an optional project tile, the title with a muted\n * aside, one line of description or facts, and the page's own actions.\n *\n * Where you are is already in the top bar's path, so the head does not repeat\n * it; it says what this page is.\n */\nexport function PageHeader({\n tile,\n lead,\n title,\n aside,\n description,\n meta,\n actions,\n}: {\n tile?: string;\n /** Stands where the tile would, for pages that are not about a project. */\n lead?: ReactNode;\n title: ReactNode;\n aside?: ReactNode;\n description?: ReactNode;\n meta?: ReactNode;\n actions?: ReactNode;\n}) {\n return (\n <header className=\"page-head\">\n <div className=\"page-head-text\">\n {tile !== undefined && <Tile name={tile} size=\"lg\" />}\n {lead}\n <div style={{ minWidth: 0 }}>\n <h1 className=\"page-title\">\n <span>{title}</span>\n {aside !== undefined && aside !== null && (\n <span className=\"page-title-aside\">{aside}</span>\n )}\n </h1>\n {description !== undefined && <p className=\"page-desc\">{description}</p>}\n {meta !== undefined && <div className=\"page-meta\">{meta}</div>}\n </div>\n </div>\n {actions !== undefined && actions !== false && (\n <div className=\"page-actions\">{actions}</div>\n )}\n </header>\n );\n}\n\n/** A bordered panel with a titled head; tables inside it run edge to edge. */\nexport function Card({\n title,\n description,\n actions,\n children,\n labelledBy,\n tone,\n wide = false,\n}: {\n title: ReactNode;\n description?: ReactNode;\n actions?: ReactNode;\n children: ReactNode;\n labelledBy: string;\n tone?: 'danger';\n /** Takes the content column whole, for a table of many or long columns. */\n wide?: boolean;\n}) {\n return (\n <section\n className={`card${tone === 'danger' ? ' card-danger' : ''}${wide ? ' card-wide' : ''}`}\n aria-labelledby={labelledBy}\n >\n <div className=\"card-head\">\n <div>\n <h2 className=\"card-title\" id={labelledBy}>\n {title}\n </h2>\n {description !== undefined && <p className=\"card-desc\">{description}</p>}\n </div>\n {actions}\n </div>\n {children}\n </section>\n );\n}\n\n/** One labelled fact in a card's `dl.facts`. */\nexport function Fact({ label, children }: { label: string; children: ReactNode }) {\n return (\n <div className=\"fact\">\n <dt>{label}</dt>\n <dd>{children}</dd>\n </div>\n );\n}\n\n/**\n * A page that cannot be shown: no access, no such thing, or no session.\n *\n * It says which page, why in a sentence, and offers the one useful way out.\n */\nexport function ClosedDoor({\n icon,\n label,\n title,\n children,\n actions,\n}: {\n icon?: ReactNode;\n label?: ReactNode;\n title: ReactNode;\n children: ReactNode;\n actions?: ReactNode;\n}) {\n return (\n <div className=\"closed\" role=\"status\">\n {icon !== undefined && (\n <div className=\"closed-icon\" aria-hidden>\n {icon}\n </div>\n )}\n {label !== undefined && <p className=\"closed-label\">{label}</p>}\n <h1 className=\"closed-title\">{title}</h1>\n <div className=\"closed-body\">{children}</div>\n {actions !== undefined && <div className=\"closed-actions\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D,OACE,qBAAC,OAAD;EAAK,WAAU;EAAS,MAAK;YAA7B;GACG,SAAS,KAAA,KACR,oBAAC,OAAD;IAAK,WAAU;IAAc,eAAA;cAC1B;GACE,CAAA;GAEN,UAAU,KAAA,KAAa,oBAAC,KAAD;IAAG,WAAU;cAAgB;GAAS,CAAA;GAC9D,oBAAC,MAAD;IAAI,WAAU;cAAgB;GAAU,CAAA;GACxC,oBAAC,OAAD;IAAK,WAAU;IAAe;GAAc,CAAA;GAC3C,YAAY,KAAA,KAAa,oBAAC,OAAD;IAAK,WAAU;cAAkB;GAAa,CAAA;EACrE;;AAET"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"principal-page-BEBr_zW7.js","names":[],"sources":["../../src/components/actions-log.tsx","../../src/lib/service-setup.ts","../../src/lib/access-plan.ts","../../src/components/expiry-field.tsx","../../src/components/principal-page.tsx"],"sourcesContent":["import { useInfiniteQuery } from '@tanstack/react-query';\nimport { uiResult, useCoffre } from '../lib/coffre';\nimport { keys } from '../lib/queries';\nimport { describe, lines } from '../lib/audit-sentences';\nimport { Sentence } from './audit-sentence';\nimport { EmptyState, Notice, Spinner, Timestamp } from './ui';\nimport { Activity, Clock, ShieldCheck, SlashCircle } from './icons';\n\nconst PAGE_SIZE = 50;\n\n/**\n * Everything one member did, newest first, from the audit log: the same\n * entries `coffre audit --actor` lists, said as the audit page says them.\n * Older pages come on request.\n */\nexport function ActionsLog({ member }: { member: string }) {\n const client = useCoffre();\n const log = useInfiniteQuery({\n queryKey: [...keys.audit, 'actor', member],\n staleTime: 0,\n initialPageParam: undefined as number | undefined,\n queryFn: ({ pageParam }) =>\n uiResult(() => client.audit.list({ actor: member, limit: PAGE_SIZE, before: pageParam })),\n getNextPageParam: (page) =>\n page.ok && page.entries.length === PAGE_SIZE ? page.entries.at(-1)!.seq : undefined,\n });\n\n if (log.isPending) {\n return (\n <p className=\"hint\">\n <Spinner size={13} /> Reading the log…\n </p>\n );\n }\n const failed = log.data?.pages.find((page) => !page.ok);\n if (failed !== undefined && !failed.ok) return <Notice tone=\"bad\">{failed.error}</Notice>;\n const entries = (log.data?.pages ?? []).flatMap((page) => (page.ok ? page.entries : []));\n const shown = lines(entries);\n\n return (\n <>\n <section className=\"card\" aria-label=\"Actions log\">\n {shown.length === 0 ? (\n <EmptyState title=\"Nothing done yet\">Every read, write and change they make is listed here.</EmptyState>\n ) : (\n <div className=\"dt-wrap\">\n <table className=\"dt actions-log stacks stacks-inline\">\n <thead>\n <tr>\n <th className=\"col-shrink\">\n <span className=\"th\">\n <Clock size={14} />\n When\n </span>\n </th>\n <th>\n <span className=\"th\">\n <Activity size={14} />\n Action\n </span>\n </th>\n <th className=\"col-shrink\">\n <span className=\"th\">\n <ShieldCheck size={14} />\n Outcome\n </span>\n </th>\n </tr>\n </thead>\n <tbody>\n {shown.map((batch) => {\n const lead = batch[0]!;\n const sentence = describe(batch);\n return (\n <tr key={lead.seq} className={sentence.refused ? 'is-denied' : undefined}>\n <td className=\"nowrap cell-muted\" title={lead.occurredAt}>\n <Timestamp iso={lead.occurredAt} display=\"relative\" />\n </td>\n <td className=\"cell-sentence\">\n <span className=\"sentence\">\n <Sentence parts={sentence.parts} />\n </span>\n </td>\n <td className=\"nowrap\" data-label=\"Outcome\">\n {sentence.refused ? (\n <span className=\"decided decided-refused\">\n <SlashCircle size={13} />\n Refused\n </span>\n ) : (\n <span className=\"cell-muted\">Allowed</span>\n )}\n </td>\n </tr>\n );\n })}\n </tbody>\n </table>\n </div>\n )}\n </section>\n {log.hasNextPage && (\n <div className=\"table-actions\">\n <button\n type=\"button\"\n className=\"btn\"\n disabled={log.isFetchingNextPage}\n onClick={() => void log.fetchNextPage()}\n >\n {log.isFetchingNextPage && <Spinner />}\n Show older\n </button>\n </div>\n )}\n </>\n );\n}\n","import { inScope, ROLE_NAMES, ROLES, type Permission, type Role, type Scope } from '@coffre/core/access';\n\nimport type { ProjectSummary } from '../shared/models';\n\n/** What `givable` reads of the shell: the projects, what you hold in each environment, and the setting. */\ntype Holder = {\n projects: readonly ProjectSummary[];\n environments: readonly { project: string; environment: string; permissions: Permission[] }[];\n /** The instance's setting as `/me` says it, projects by slug, those you see; null for a service account. */\n serviceSetup: Scope | null;\n};\n\n/**\n * The roles you may give a service account at a project, or one of its\n * environments, as the server decides it (`givesService` in\n * @coffre/core/access): any, where you manage access; otherwise, inside the\n * instance's setting, those whose every permission you hold there.\n *\n * a Developer of every dev, at market/dev viewer, developer\n * the same, at market none: a project takes holding all of it\n */\nexport function givable(holder: Holder, project: ProjectSummary, environment: string | null): Role[] {\n const held = environment === null\n ? project.permissions\n : holder.environments.find((entry) => entry.project === project.slug && entry.environment === environment)?.permissions ?? [];\n if (held.includes('grant.manage')) return [...ROLE_NAMES];\n const setting = holder.serviceSetup;\n // The setting names projects by slug here, so a place is matched by its slugs.\n const place = environment === null\n ? { projectId: project.slug }\n : { projectId: project.slug, environmentId: environment, environmentSlug: environment };\n if (setting === null || !inScope(setting, place)) return [];\n return ROLE_NAMES.filter((role) => ROLES[role].permissions.every((permission) => held.includes(permission)));\n}\n\n/** The projects where you may give a service account something: on the project, or on one of its environments. */\nexport function serviceProjects(holder: Holder): ProjectSummary[] {\n return holder.projects.filter((project) =>\n givable(holder, project, null).length > 0 ||\n project.environments.some((environment) => givable(holder, project, environment.slug).length > 0));\n}\n","import type { AccessValue } from '@coffre/client';\nimport type { Role } from '@coffre/core/access';\n\nimport type { GrantRow } from '../shared/models';\n\n/** Read or write on one environment, and when it ends: an ISO instant, or null for never. */\nexport type EnvironmentAccess = { role: Extract<Role, 'viewer' | 'developer'>; expiresAt: string | null };\n\n/**\n * What one project is set to in a principal's access editor: nothing, owner,\n * read or write everywhere, or read or write per environment. Every grant the\n * plan asks for carries its own expiry.\n *\n * `custom` is for grants that do not fit that shape -- an auditor grant, or\n * read everywhere plus write on one environment. The editor shows them and\n * leaves them alone unless another setting is picked.\n */\nexport type AccessPlan = {\n level: 'none' | Extract<Role, 'owner' | 'viewer' | 'developer'> | 'env' | 'custom';\n /** When the project-wide level ends. */\n expiresAt: string | null;\n /** Environments without an entry get no access. */\n environments: Record<string, EnvironmentAccess>;\n};\n\nexport type HeldGrant = Pick<\n GrantRow,\n 'id' | 'role' | 'roleName' | 'environmentSlug' | 'expiresAt'\n>;\n\nexport type AccessChange =\n | { kind: 'create'; role: string; environmentSlug: string | null; expiresAt: string | null }\n | { kind: 'expiry'; grant: HeldGrant; expiresAt: string | null }\n | { kind: 'revoke'; grant: HeldGrant };\n\n/** An environment's access in a plan; slugs like `constructor` are not inherited. */\nexport function environmentAccess(plan: AccessPlan, slug: string): EnvironmentAccess | null {\n return Object.hasOwn(plan.environments, slug) ? plan.environments[slug] : null;\n}\n\n/**\n * Read what a principal holds on a project back into the editor's terms.\n * `environments` are the ones the editor can set: live, and not archived.\n */\nexport function planFromGrants(\n grants: readonly HeldGrant[],\n environments: readonly string[],\n): AccessPlan {\n if (grants.length === 0) return { level: 'none', expiresAt: null, environments: {} };\n\n const [only] = grants;\n if (\n grants.length === 1 &&\n only.environmentSlug === null &&\n (only.role === 'owner' || only.role === 'viewer' || only.role === 'developer')\n ) {\n return { level: only.role, expiresAt: only.expiresAt, environments: {} };\n }\n\n const perEnvironment: Record<string, EnvironmentAccess> = {};\n for (const grant of grants) {\n const slug = grant.environmentSlug;\n if (\n slug === null ||\n !environments.includes(slug) ||\n Object.hasOwn(perEnvironment, slug) ||\n (grant.role !== 'viewer' && grant.role !== 'developer')\n ) {\n return { level: 'custom', expiresAt: null, environments: {} };\n }\n perEnvironment[slug] = { role: grant.role, expiresAt: grant.expiresAt };\n }\n return { level: 'env', expiresAt: null, environments: perEnvironment };\n}\n\n/**\n * Switch a plan's level. Going from read or write everywhere to per\n * environment starts every environment at that level and expiry, so the\n * switch alone keeps the same reach.\n */\nexport function withLevel(\n plan: AccessPlan,\n level: AccessPlan['level'],\n environments: readonly string[],\n): AccessPlan {\n if (\n level === 'env' &&\n (plan.level === 'viewer' || plan.level === 'developer') &&\n Object.keys(plan.environments).length === 0\n ) {\n const access = { role: plan.level, expiresAt: plan.expiresAt };\n return {\n ...plan,\n level,\n environments: Object.fromEntries(environments.map((slug) => [slug, access])),\n };\n }\n return { ...plan, level };\n}\n\n/** Set one environment's access, or take it away with `null`. */\nexport function withEnvironment(\n plan: AccessPlan,\n slug: string,\n access: EnvironmentAccess | null,\n): AccessPlan {\n const environments = { ...plan.environments };\n if (access === null) delete environments[slug];\n else environments[slug] = access;\n return { ...plan, environments };\n}\n\nfunction grantsFor(\n plan: AccessPlan,\n): { role: string; environmentSlug: string | null; expiresAt: string | null }[] {\n switch (plan.level) {\n case 'none':\n case 'custom':\n return [];\n case 'owner':\n case 'viewer':\n case 'developer':\n return [{ role: plan.level, environmentSlug: null, expiresAt: plan.expiresAt }];\n case 'env':\n return Object.entries(plan.environments).map(([environmentSlug, access]) => ({\n environmentSlug,\n ...access,\n }));\n }\n}\n\n/** The server and the date field spell the same instant differently. */\nfunction sameExpiry(a: string | null, b: string | null): boolean {\n return a === b || (a !== null && b !== null && Date.parse(a) === Date.parse(b));\n}\n\n/**\n * The changes that take what is held to the plan: grants to create, grants\n * whose expiry moves, and grants to revoke, in that order. Asking for what is\n * already held yields nothing, so applying the same plan twice is a no-op.\n */\nexport function accessChanges(grants: readonly HeldGrant[], plan: AccessPlan): AccessChange[] {\n if (plan.level === 'custom') return [];\n\n const key = (grant: { role: string; environmentSlug: string | null }) =>\n `${grant.role}@${grant.environmentSlug ?? ''}`;\n const wanted = new Map(grantsFor(plan).map((grant) => [key(grant), grant]));\n const held = new Map(grants.map((grant) => [key(grant), grant]));\n\n const changes: AccessChange[] = [];\n for (const [id, grant] of wanted) {\n if (!held.has(id)) changes.push({ kind: 'create', ...grant });\n }\n for (const [id, grant] of held) {\n const want = wanted.get(id);\n if (want !== undefined && !sameExpiry(grant.expiresAt, want.expiresAt)) {\n changes.push({ kind: 'expiry', grant, expiresAt: want.expiresAt });\n }\n }\n for (const [id, grant] of held) {\n if (!wanted.has(id)) changes.push({ kind: 'revoke', grant });\n }\n return changes;\n}\n\n/**\n * The changes as the API's access patch for one project: each place it\n * touches, and the role to hold there until when, or `null` for none.\n *\n * { \"market\": null, \"market/dev\": { \"role\": \"developer\", \"until\": \"2026-12-31T23:59:59.000Z\" } }\n *\n * A place holds one role, so where a level changes, the revoke of the old\n * role and the create of the new land on the same place, and the new role\n * wins: the server replaces one with the other, never passing through none.\n */\nexport function accessPatch(project: string, changes: readonly AccessChange[]): Record<string, AccessValue> {\n const place = (environmentSlug: string | null) =>\n environmentSlug === null ? project : `${project}/${environmentSlug}`;\n const holding = (role: string, expiresAt: string | null): AccessValue =>\n expiresAt === null ? (role as Role) : { role: role as Role, until: expiresAt };\n\n const patch: Record<string, AccessValue> = {};\n for (const change of changes) {\n if (change.kind === 'revoke') patch[place(change.grant.environmentSlug)] = null;\n }\n for (const change of changes) {\n if (change.kind === 'expiry') patch[place(change.grant.environmentSlug)] = holding(change.grant.role, change.expiresAt);\n if (change.kind === 'create') patch[place(change.environmentSlug)] = holding(change.role, change.expiresAt);\n }\n return patch;\n}\n\n/** A date field's value as the instant access ends: the close of that day, UTC. */\nexport function expiryFromDate(date: string): string | null {\n return date === '' ? null : new Date(`${date}T23:59:59Z`).toISOString();\n}\n\n/** A date field's value for an expiry. Expiries are shown as UTC dates everywhere. */\nexport function dateFromExpiry(expiresAt: string | null): string {\n return expiresAt === null ? '' : expiresAt.slice(0, 10);\n}\n","import { dateFromExpiry, expiryFromDate } from '../lib/access-plan';\nimport { X } from './icons';\n\n/**\n * When one grant ends, as a date: access lasts through that day, UTC. Blank\n * reads \"Never\" where the browser lets the empty field be restyled.\n */\nexport function ExpiryField({\n label,\n expiresAt,\n onChange,\n}: {\n label: string;\n expiresAt: string | null;\n onChange: (expiresAt: string | null) => void;\n}) {\n const date = dateFromExpiry(expiresAt);\n return (\n <span className={`expiry${date === '' ? ' is-never' : ''}`}>\n <input\n className=\"input select-sm\"\n type=\"date\"\n aria-label={label}\n min={new Date().toISOString().slice(0, 10)}\n value={date}\n onChange={(event) => onChange(expiryFromDate(event.target.value))}\n />\n <span className=\"expiry-never\" aria-hidden=\"true\">\n Never\n </span>\n <button\n className=\"btn btn-quiet btn-sm btn-icon\"\n type=\"button\"\n aria-label={`${label}: never`}\n title=\"Never expires\"\n onClick={() => onChange(null)}\n >\n <X size={12} />\n </button>\n </span>\n );\n}\n","import { useState } from 'react';\nimport { useQueryClient, useSuspenseQuery } from '@tanstack/react-query';\nimport { Link, Outlet } from '@tanstack/react-router';\nimport { INSTANCE_ROLES, ROLE_NAMES, ROLES, scopeInWords, unscoped, type Role } from '@coffre/core/access';\nimport { useShell } from '../lib/use-shell';\nimport { toast } from 'sonner';\nimport { memberRef, useCoffre } from '../lib/coffre';\nimport { directoryList } from '../lib/changes';\nimport { affects, hasAppsTab, keys, listsAccess, managedProjects, queries, signInWays } from '../lib/queries';\nimport { useChangeStatus } from '../lib/use-change';\nimport { useMounted } from '../lib/mounted';\nimport { ItemFailure } from './row-state';\nimport { useAction } from '../lib/use-action';\nimport { accessRows, projectAccessLabel, type ProjectAccess } from '../lib/project-access';\nimport { givable, serviceProjects } from '../lib/service-setup';\nimport {\n accessChanges,\n accessPatch,\n dateFromExpiry,\n environmentAccess,\n expiryFromDate,\n planFromGrants,\n withEnvironment,\n withLevel,\n type AccessChange,\n type AccessPlan,\n} from '../lib/access-plan';\nimport type { MemberAccess } from '@coffre/client';\nimport type { DirectoryPrincipal, ProjectSummary } from '../shared/models';\nimport { ClosedDoor, PageHeader } from './page';\nimport { EmptyState, ErrorLine, Modal, Notice, Spinner } from './ui';\nimport { GrantRowView, GrantsTable } from './grants';\nimport { ExpiryField } from './expiry-field';\nimport { InstanceRole, KIND, PrincipalActions } from './directory';\nimport { PrincipalReportCards, RemovedNotice } from './offboarding';\nimport { PrincipalAvatar } from './principal';\nimport { Tile } from './tile';\nimport { Activity, Archive, Clock, Folder, Key, Link as LinkIcon, Pencil, Users, X } from './icons';\nimport { PageTabs } from './tabs';\n\ntype PrincipalType = DirectoryPrincipal['principalType'];\n\n/** The roles you may give at a project, or one of its environments: any where you manage access (`givable`). */\ntype Offers = (project: ProjectSummary, environment: string | null) => readonly Role[];\n\n/** Who a user or service account is to the instance, as an owner reads it; null for anyone else. */\nfunction useReport(principalType: PrincipalType, principalId: string) {\n const { capabilities } = useShell();\n return useSuspenseQuery(queries.report(useCoffre(), memberRef(principalType, principalId), capabilities.runsInstance)).data;\n}\n\n/**\n * What `loadAccess` read in one request: their role and scope, and, for each\n * project where you manage access, the grants they hold there. For a\n * service account you manage, each project where you may give it\n * something, and what (`offers`).\n */\nfunction useMemberAccess(principalType: PrincipalType, principalId: string): {\n access: MemberAccess | null;\n error: string | null;\n projects: ProjectAccess[];\n offers: Offers;\n} {\n const shell = useShell();\n const { data } = useSuspenseQuery(queries.memberAccess(useCoffre(), memberRef(principalType, principalId), listsAccess(shell)));\n const error = data !== null && !data.ok ? data.error : null;\n const access = data?.ok === true ? data : null;\n const yours = principalType === 'service' && access?.managed === true;\n const listed = yours ? serviceProjects(shell) : managedProjects(shell.projects);\n return {\n access,\n error,\n offers: yours ? (project, environment) => givable(shell, project, environment) : () => ROLE_NAMES,\n projects: listed.map((project) => ({\n project,\n grants: (access?.grants ?? []).filter((grant) => grant.project === project.slug).map((grant) => ({\n id: grant.id,\n principalType,\n principalId,\n role: grant.role,\n roleName: grant.roleName,\n permissions: grant.permissions,\n scope: grant.environment === null ? 'project' : 'environment',\n environmentSlug: grant.environment,\n expiresAt: grant.expiresAt,\n })),\n grantsError: error,\n })),\n };\n}\n\n/**\n * A user's or service account's page: who it is, its menu, and its tabs,\n * each a page of its own under this one. Access is a user's first tab; a\n * service account's is how it signs in, while it shows one. A tab the\n * deployment left out is not offered.\n */\nexport function PrincipalLayout({ principalType, principalId }: { principalType: PrincipalType; principalId: string }) {\n const shell = useShell();\n const mounted = useMounted();\n const { capabilities } = shell;\n const report = useReport(principalType, principalId);\n // A service account you manage, though you do not run the instance: what it holds, from its access.\n const { data: held } = useSuspenseQuery(queries.memberAccess(useCoffre(), memberRef(principalType, principalId), listsAccess(shell)));\n const yours = principalType === 'service' && held?.ok === true && held.managed;\n // A role change or removal made from this page's menu, refused.\n const { status, dismiss } = useChangeStatus(directoryList.queryKey);\n const change = status(memberRef(principalType, principalId));\n const kind = KIND[principalType];\n const people = principalType === 'user';\n const found = report?.ok === true ? report.report : null;\n const removed = found?.status === 'removed';\n const entry =\n found !== null && !removed\n ? {\n principalType,\n principalId,\n instanceRole: found.instanceRole,\n scope: found.scope,\n isRootAdmin: found.isRootAdmin,\n tampered: found.status === 'tampered',\n managed: principalType === 'service',\n }\n : yours\n ? { principalType, principalId, instanceRole: 'member' as const, scope: null, isRootAdmin: false, tampered: false, managed: true }\n : undefined;\n\n // Owners get a report about anyone ever registered, removed or not, so a\n // miss there means there is no such user. Everyone else only reaches this\n // page through projects they manage, or a service account they manage.\n const unknown = report?.ok === true && found === null;\n if (unknown || (report === null && managedProjects(shell.projects).length === 0 && !yours)) {\n return (\n <ClosedDoor\n icon={people ? <Users size={18} /> : <Key size={18} />}\n label={<span className=\"mono\">{people ? principalId : `service:${principalId}`}</span>}\n title={people ? 'No such user for you' : 'No such service account for you'}\n actions={\n <Link className=\"btn\" to={people ? '/users' : '/service-accounts'}>\n All {people ? 'users' : 'service accounts'}\n </Link>\n }\n >\n {report === null\n ? `A ${kind}'s page lists its access to the projects where you manage access, and you manage none.`\n : `No ${kind} by that name has ever been registered here.`}\n </ClosedDoor>\n );\n }\n\n const access = (\n <>\n {removed ? <Archive size={15} /> : <Folder size={15} />}\n {removed ? 'Offboarding' : 'Access'}\n </>\n );\n const activity = (\n <>\n <Activity size={15} />\n Activity\n </>\n );\n const tabs = people\n ? [\n <Link key=\"access\" to=\"/users/$user\" params={{ user: principalId }} activeOptions={{ exact: true, includeSearch: false }}>\n {access}\n </Link>,\n // Only an owner reads the report that lists them; removal disconnects them.\n hasAppsTab(shell, report) && mounted('/users/$user/apps') && (\n <Link key=\"apps\" to=\"/users/$user/apps\" params={{ user: principalId }}>\n <LinkIcon size={15} />\n Connected apps\n </Link>\n ),\n capabilities.canReadAudit && mounted('/users/$user/activity') && (\n <Link key=\"activity\" to=\"/users/$user/activity\" params={{ user: principalId }}>\n {activity}\n </Link>\n ),\n ]\n : [\n signInWays(shell, held) !== null && (\n <Link key=\"sign-in\" to=\"/service-accounts/$account\" params={{ account: principalId }} activeOptions={{ exact: true, includeSearch: false }}>\n <LinkIcon size={15} />\n Sign-in\n </Link>\n ),\n mounted('/service-accounts/$account/access') && (\n <Link key=\"access\" to=\"/service-accounts/$account/access\" params={{ account: principalId }}>\n {access}\n </Link>\n ),\n capabilities.canReadAudit && mounted('/service-accounts/$account/activity') && (\n <Link key=\"activity\" to=\"/service-accounts/$account/activity\" params={{ account: principalId }}>\n {activity}\n </Link>\n ),\n ];\n\n return (\n <>\n <PageHeader\n lead={<PrincipalAvatar type={principalType} id={principalId} size=\"lg\" />}\n title={principalType === 'service' ? `service:${principalId}` : principalId}\n description={\n principalType === 'service'\n ? 'A service account: an identity for CI and other automation.'\n : undefined\n }\n meta={\n removed ? (\n <span className=\"tag tag-red\">Removed</span>\n ) : (\n entry?.principalType === 'user' && <InstanceRole principal={entry} />\n )\n }\n actions={entry !== undefined && <PrincipalActions principal={entry} trigger=\"btn btn-icon\" />}\n />\n\n {change.state === 'failed' && (\n <div className=\"report-notice\">\n <ItemFailure status={change} onDismiss={() => dismiss(change.mutationId)} />\n </div>\n )}\n {report?.ok === false && (\n <div className=\"report-notice\">\n <Notice tone=\"bad\">{report.error}</Notice>\n </div>\n )}\n <PageTabs label={people ? 'User sections' : 'Service account sections'}>{tabs}</PageTabs>\n\n <Outlet />\n </>\n );\n}\n\n/**\n * A user's or service account's Access tab: its grants on every project\n * where you manage access, and on every project; once it is removed, what\n * its offboarding did instead.\n */\nexport function PrincipalAccess({ principalType, principalId }: { principalType: PrincipalType; principalId: string }) {\n const { instanceRole } = useShell();\n const report = useReport(principalType, principalId);\n const { access: held, error, projects: access, offers } = useMemberAccess(principalType, principalId);\n const kind = KIND[principalType];\n const people = principalType === 'user';\n const found = report?.ok === true ? report.report : null;\n const removed = found?.status === 'removed';\n\n // One request, so one error, said once in place of the rows (`UnreadAccess`).\n const rows = accessRows(access).flatMap((row) => (row.grant === null ? [] : [row]));\n // Grants to someone removed are refused until they are added back.\n const editable = removed\n ? []\n : access.filter(\n ({ project, grantsError }) => project.archivedAt === null && grantsError === null,\n );\n\n return (\n <>\n {removed && found !== null && <RemovedNotice report={found} />}\n\n {/* Removal ends every grant, so there is no access left to show. */}\n {!removed && (\n <>\n {people && held !== null && <InstanceRoleNote access={held} />}\n\n <section className=\"card\" aria-label=\"Project access\">\n {error !== null ? (\n <UnreadAccess member={memberRef(principalType, principalId)} error={error} />\n ) : rows.length === 0 ? (\n <EmptyState title=\"No project access yet\">\n {editable.length > 0\n ? `Edit access gives this ${kind} access to several projects at once.`\n : `None of the projects where you manage access has a grant for this ${kind}.`}\n </EmptyState>\n ) : (\n <GrantsTable\n lead={\n <span className=\"th\">\n <Folder size={14} />\n Project\n </span>\n }\n >\n {rows.map(({ project, grant }, index) => (\n <GrantRowView\n key={grant.id}\n number={index + 1}\n project={project.slug}\n grant={grant}\n leadLabel=\"Project\"\n lead={\n <span className=\"cell-project\">\n <Tile name={project.slug} />\n <Link\n className=\"cell-link\"\n to={people ? '/projects/$project/users' : '/projects/$project/service-accounts'}\n params={{ project: project.slug }}\n >\n {project.name}\n </Link>\n {project.archivedAt !== null && <span className=\"tag tag-red\">Archived</span>}\n </span>\n }\n />\n ))}\n </GrantsTable>\n )}\n </section>\n\n {editable.length > 0 && (\n <div className=\"table-actions\">\n <EditAccess principalType={principalType} principalId={principalId} access={editable} offers={offers} />\n </div>\n )}\n\n {/* A root admin manages every project, so nothing is out of view. */}\n {instanceRole !== 'root-admin' && (\n <p className=\"hint section-foot\">\n {held?.managed === true && principalType === 'service'\n ? 'Only projects where you may give it access are listed: what you hold there, where the instance lets you.'\n : 'Only projects where you manage access are listed.'}\n </p>\n )}\n\n </>\n )}\n\n {found !== null && <PrincipalReportCards report={found} />}\n </>\n );\n}\n\n/** What a person's instance role gives them, above the grants that add to it: nothing for a Member. */\nfunction InstanceRoleNote({ access }: { access: MemberAccess }) {\n if (access.instanceRole === 'member' || access.instanceRole === 'root-admin') return null;\n const { name } = INSTANCE_ROLES[access.instanceRole];\n return (\n <div className=\"report-notice\">\n <Notice tone=\"info\">\n <strong>{name}</strong>\n {access.scope === null ? '' : unscoped(access.scope) ? ' in every project' : `: ${scopeInWords(access.scope)}`}, from their instance role. The\n grants below add to it.\n </Notice>\n </div>\n );\n}\n\n/** Their access could not be read: why, and another try, never an empty list that reads as no access. */\nfunction UnreadAccess({ member, error }: { member: string; error: string }) {\n const queryClient = useQueryClient();\n const [retrying, setRetrying] = useState(false);\n return (\n <div className=\"row-failure-line unread-access\">\n <ErrorLine error={`Their access could not be read. ${error}`} />\n <button\n type=\"button\"\n className=\"act\"\n disabled={retrying}\n onClick={() => {\n setRetrying(true);\n void queryClient.refetchQueries({ queryKey: keys.memberAccess(member) }).finally(() => setRetrying(false));\n }}\n >\n {retrying && <Spinner size={13} />}\n Retry\n </button>\n </div>\n );\n}\n\n/**\n * One principal's access to every project you manage, edited in one place.\n *\n * Each project opens set to what the principal holds: a project-wide level,\n * or read or write per environment, each with its own expiry. Saving sends\n * only the difference, every project in one `access.set`: the server applies\n * all of it in one transaction, or none of it.\n */\nfunction EditAccess({\n principalType,\n principalId,\n access,\n offers,\n}: {\n principalType: PrincipalType;\n principalId: string;\n access: ProjectAccess[];\n offers: Offers;\n}) {\n const coffre = useCoffre();\n const [open, setOpen] = useState(false);\n const [edits, setEdits] = useState<Record<string, AccessPlan>>({});\n const { pending, error, setError, run } = useAction();\n const kind = KIND[principalType];\n\n const rows = access.map(({ project, grants }) => {\n const environments = project.environments\n .filter(\n (environment) => environment.details !== null && environment.details.archivedAt === null,\n )\n .map((environment) => environment.slug);\n const held = planFromGrants(grants, environments);\n const plan = Object.hasOwn(edits, project.slug) ? edits[project.slug] : held;\n // What you may give here: every role where you manage access; a service account you manage, what you hold.\n const whole = offers(project, null);\n const each = Object.fromEntries(environments.map((slug) => [slug, offers(project, slug)]));\n return { project, grants, environments, held, plan, whole, each, changes: accessChanges(grants, plan) };\n });\n const changed = rows.filter((row) => row.changes.length > 0);\n\n function close() {\n setOpen(false);\n setEdits({});\n setError(null);\n }\n\n return (\n <>\n <button className=\"btn btn-primary\" onClick={() => setOpen(true)}>\n <Pencil size={14} />\n Edit access\n </button>\n\n <Modal\n open={open}\n onOpenChange={(next) => (next ? setOpen(true) : close())}\n title={\n <>\n Edit access for <span className=\"mono\">{principalId}</span>\n </>\n }\n description={`Set what this ${kind} can reach on each project you ${principalType === 'service' ? 'may give it access to' : 'manage'}, and until when.`}\n wide\n >\n <form\n className=\"form\"\n onSubmit={(event) => {\n event.preventDefault();\n run(\n () =>\n coffre.access.set(\n memberRef(principalType, principalId),\n Object.assign({}, ...changed.map(({ project, changes }) => accessPatch(project.slug, changes))),\n ),\n {\n affects: changed.flatMap(({ project }) =>\n affects.access(project.slug, memberRef(principalType, principalId)),\n ),\n onSuccess: () => {\n toast.success(\n `Updated ${principalId}’s access on ${changed.length} project${changed.length === 1 ? '' : 's'}`,\n );\n close();\n },\n },\n );\n }}\n >\n <ul className=\"plan-list\">\n <li className=\"plan-head\" aria-hidden=\"true\">\n <span>Project</span>\n <span>Access</span>\n <span>Expires</span>\n </li>\n {rows.map(({ project, grants, environments, held, plan, whole, each, changes }) => {\n const id = `plan-${project.slug}`;\n const edit = (next: AccessPlan) =>\n setEdits((current) => ({ ...current, [project.slug]: next }));\n return (\n <li\n key={project.slug}\n className={`plan-row${changes.length > 0 ? ' is-changed' : ''}`}\n >\n <label className=\"plan-project\" htmlFor={id}>\n <Tile name={project.slug} />\n <span className=\"plan-project-text\">\n <span className=\"plan-project-name\">{project.name}</span>\n {held.level === 'custom' && (\n <span className=\"plan-project-held\">\n Holds {grants.map((grant) => projectAccessLabel(grant)).join(', ')}\n </span>\n )}\n </span>\n </label>\n <select\n id={id}\n className=\"select select-sm\"\n value={plan.level}\n onChange={(event) =>\n edit(\n withLevel(plan, event.target.value as AccessPlan['level'], environments),\n )\n }\n >\n {held.level === 'custom' && <option value=\"custom\">Keep as is</option>}\n <option value=\"none\">No access</option>\n {whole.includes('owner') && <option value=\"owner\">{ROLES.owner.name}</option>}\n {whole.includes('viewer') && <option value=\"viewer\">{ROLES.viewer.name}: all</option>}\n {whole.includes('developer') && <option value=\"developer\">{ROLES.developer.name}: all</option>}\n {environments.some((slug) => each[slug]!.length > 0) && <option value=\"env\">Per environment…</option>}\n </select>\n {(plan.level === 'owner' ||\n plan.level === 'viewer' ||\n plan.level === 'developer') && (\n <ExpiryField\n label={`${project.name} expires`}\n expiresAt={plan.expiresAt}\n onChange={(expiresAt) => edit({ ...plan, expiresAt })}\n />\n )}\n\n {plan.level === 'env' && (\n <ul className=\"plan-envs\" aria-label={`Environments of ${project.name}`}>\n {environments.map((slug) => {\n const current = environmentAccess(plan, slug);\n return (\n <li key={slug} className=\"plan-env\">\n <label className=\"mono\" htmlFor={`${id}-${slug}`}>\n {slug}\n </label>\n <select\n id={`${id}-${slug}`}\n className=\"select select-sm\"\n value={current?.role ?? ''}\n onChange={(event) => {\n const role = event.target.value;\n edit(\n withEnvironment(\n plan,\n slug,\n role === 'viewer' || role === 'developer'\n ? { role, expiresAt: current?.expiresAt ?? null }\n : null,\n ),\n );\n }}\n >\n <option value=\"\">No access</option>\n {each[slug]!.includes('viewer') && <option value=\"viewer\">{ROLES.viewer.name}</option>}\n {each[slug]!.includes('developer') && <option value=\"developer\">{ROLES.developer.name}</option>}\n </select>\n {current !== null && (\n <ExpiryField\n label={`${slug} of ${project.name} expires`}\n expiresAt={current.expiresAt}\n onChange={(expiresAt) =>\n edit(withEnvironment(plan, slug, { ...current, expiresAt }))\n }\n />\n )}\n </li>\n );\n })}\n </ul>\n )}\n\n {changes.length > 0 && (\n <ul className=\"plan-changes\" aria-label={`Changes to ${project.name}`}>\n {changes.map((change) => (\n <li\n key={\n change.kind === 'create'\n ? `+${change.role}@${change.environmentSlug ?? ''}`\n : change.grant.id\n }\n >\n <AccessChangeTag change={change} />\n </li>\n ))}\n </ul>\n )}\n </li>\n );\n })}\n </ul>\n\n <ErrorLine error={error} />\n\n <div className=\"dialog-actions\">\n <button className=\"btn\" type=\"button\" onClick={close}>\n Cancel\n </button>\n <button\n className=\"btn btn-primary\"\n type=\"submit\"\n disabled={pending || changed.length === 0}\n >\n {pending && <Spinner />}\n Save changes\n </button>\n </div>\n </form>\n </Modal>\n </>\n );\n}\n\nfunction AccessChangeTag({ change }: { change: AccessChange }) {\n const until = (expiresAt: string | null) =>\n expiresAt === null ? '' : ` until ${dateFromExpiry(expiresAt)}`;\n switch (change.kind) {\n case 'create':\n return (\n <span className=\"tag tag-green\">\n <span aria-hidden=\"true\">+</span>\n <span className=\"visually-hidden\">Adds</span>\n {projectAccessLabel({ ...change, roleName: change.role })}\n {until(change.expiresAt)}\n </span>\n );\n case 'expiry':\n return (\n <span className=\"tag tag-blue\">\n <Clock size={12} />\n <span className=\"visually-hidden\">Moves the expiry of</span>\n {projectAccessLabel(change.grant)}\n {change.expiresAt === null ? ', no expiry' : until(change.expiresAt)}\n </span>\n );\n case 'revoke':\n return (\n <span className=\"tag tag-red\">\n <span aria-hidden=\"true\">−</span>\n <span className=\"visually-hidden\">Removes</span>\n {projectAccessLabel(change.grant)}\n </span>\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAQA,IAAM,YAAY;;;;;;AAOlB,SAAgB,WAAW,EAAE,UAA8B;CACzD,MAAM,SAAS,UAAU;CACzB,MAAM,MAAM,iBAAiB;EAC3B,UAAU;GAAC,GAAG,KAAK;GAAO;GAAS;EAAM;EACzC,WAAW;EACX,kBAAkB,KAAA;EAClB,UAAU,EAAE,gBACV,eAAe,OAAO,MAAM,KAAK;GAAE,OAAO;GAAQ,OAAO;GAAW,QAAQ;EAAU,C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AAc,OAAO,gBAAgB,MAAM,OAAO,SAAS;GAC/D;;EAEV,KAAK,UACH,OACE,qBAAC,QAAD;GAAM,WAAU;aAAhB;IACE,oBAAC,QAAD;KAAM,eAAY;eAAO;IAAO,CAAA;IAChC,oBAAC,QAAD;KAAM,WAAU;eAAkB;IAAa,CAAA;IAC9C,mBAAmB,OAAO,KAAK;GAC5B;;CAEZ;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"queries-DE5nK2y4.js","names":[],"sources":["../../src/lib/capabilities.ts","../../src/lib/queries.ts"],"sourcesContent":["import { administers, makesProjects, type InstanceRole } from '@coffre/core/access';\n\nimport type { Me, Permission, ProjectSummary } from '../shared/models';\n\n/**\n * The small set of instance-wide decisions the shell has to make.\n *\n * Resource-specific controls still use the permissions returned for that\n * project or environment. These are only the capabilities whose affordances\n * live outside one resource page.\n */\nexport type UiCapabilities = {\n /** Admins and owners, scoped or not, and root admins: the Users and Service accounts pages. */\n canManageGrants: boolean;\n /**\n * Admins and owners whose scope narrows nothing, and root admins: adding\n * and removing people and service accounts, instance roles, tokens and\n * trust bindings, offboarding reports, the instance's keys.\n */\n runsInstance: boolean;\n /**\n * Who sets up service accounts: those who run the instance, and a person\n * who holds access somewhere the instance's setting takes in. The Service\n * accounts page lists them the ones they manage.\n */\n setsUpServices: boolean;\n canReadAudit: boolean;\n canCreateProject: boolean;\n};\n\nconst NONE: UiCapabilities = {\n canManageGrants: false,\n runsInstance: false,\n setsUpServices: false,\n canReadAudit: false,\n canCreateProject: false,\n};\n\nexport function deriveUiCapabilities(\n me: Me | null,\n projects: readonly ProjectSummary[],\n): UiCapabilities {\n if (me === null) return NONE;\n\n const isRootAdmin = me.instanceRole === 'root-admin';\n const role: InstanceRole = me.instanceRole === 'root-admin' ? 'owner' : me.instanceRole;\n\n return {\n // Users and Service accounts list the instance's directory, for those\n // who manage access across projects. Project access managers keep their\n // grant controls on each project page.\n canManageGrants: isRootAdmin || administers(role),\n runsInstance: me.runsInstance,\n setsUpServices: me.setsUpServices,\n canReadAudit: me.canReadAudit,\n // A new project is one no `only` list names: as the server decides,\n // from the role and the scope, projects by slug.\n canCreateProject: makesProjects({ isRootAdmin, role, scope: me.scope, grants: [] }),\n };\n}\n\n/** Secret values are available only where the API reports secret.read. */\nexport function canRevealSecrets(permissions: readonly Permission[]): boolean {\n return permissions.includes('secret.read');\n}\n","import type { AuthInfo, CoffreClient, Member } from '@coffre/client';\nimport { EVERYWHERE, INSTANCE_ROLES } from '@coffre/core/access';\nimport { QueryClient, queryOptions, type QueryKey } from '@tanstack/react-query';\n\nimport { deriveUiCapabilities } from './capabilities.ts';\nimport { memberRef, statusOf, uiResult } from './coffre.ts';\nimport type { DirectoryPrincipal, GrantRow, Me, ProjectSummary } from '../shared/models';\n\n/**\n * Every read the pages make, cached by TanStack Query: one cache per request\n * on the server, whose reads the page carries to the browser's, and one in the\n * browser for the whole visit.\n *\n * How fresh a page is. A read is reused for `FRESH_MS`, refetched when the\n * window regains focus, and refetched at once by any change made here, which\n * names what it touches (`affects`), so your own changes always show.\n * Someone else's change shows within that window. Nothing is decided on a\n * cached read: the server authorizes every call, so a stale screen can offer\n * an action the server then refuses, never grant one. The audit log and the\n * chain's verification are the exception, read fresh on every visit: their\n * whole point is to be current.\n */\nexport const FRESH_MS = 10_000;\n\nexport function createQueryClient(): QueryClient {\n return new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: FRESH_MS,\n refetchOnWindowFocus: true,\n // A read either answers or says why it cannot (`uiResult`), so a\n // throw is a fault, and asking again would only repeat it.\n retry: false,\n },\n },\n });\n}\n\ntype Place = { project: string; environment: string };\n\n/**\n * The keys, which `affects` names too. A project's keys start with it, so\n * one invalidation covers everything read under it.\n */\nexport const keys = {\n me: ['me'],\n auth: ['auth'],\n projects: ['projects'],\n grants: (project: string) => ['grants', project],\n secrets: ({ project, environment }: Place) => ['secrets', project, environment],\n references: (path: string) => ['references', path],\n missing: ({ project, environment }: Place) => ['missing', project, environment],\n directory: ['directory'],\n report: (member: string) => ['report', member],\n memberAccess: (member: string) => ['member-access', member],\n credentials: (member: string) => ['credentials', member],\n bindings: (member: string) => ['bindings', member],\n identities: ['identities'],\n sessions: ['sessions'],\n apps: ['apps'],\n audit: ['audit'],\n auditKeys: ['audit', 'keys'],\n settings: ['settings'],\n} satisfies Record<string, QueryKey | ((...args: never[]) => QueryKey)>;\n\n/** Members' grants, as rows, and a row for each one whose instance role reaches the place listed. */\nfunction grantRows(members: Member[]): GrantRow[] {\n return members.flatMap((member): GrantRow[] => [\n ...(member.reachesByRole && member.instanceRole !== 'root-admin'\n ? [{\n id: `${member.member}/instance-role`,\n principalType: member.principalType,\n principalId: member.principalId,\n role: member.instanceRole,\n roleName: INSTANCE_ROLES[member.instanceRole].name,\n permissions: [...INSTANCE_ROLES[member.instanceRole].permissions],\n scope: 'instance-role' as const,\n environmentSlug: null,\n expiresAt: null,\n }]\n : []),\n ...member.grants.map((grant) => ({\n id: grant.id,\n principalType: member.principalType,\n principalId: member.principalId,\n role: grant.role,\n roleName: grant.roleName,\n permissions: grant.permissions,\n scope: grant.environment === null ? ('project' as const) : ('environment' as const),\n environmentSlug: grant.environment,\n expiresAt: grant.expiresAt,\n })),\n ]);\n}\n\nfunction listDirectory(client: CoffreClient) {\n return uiResult(async () => {\n const { members, removed } = await client.members.list();\n const principals: DirectoryPrincipal[] = members.map(\n ({ principalType, principalId, instanceRole, scope, isRootAdmin, tampered, managed, grants }) => ({\n principalType,\n principalId,\n instanceRole,\n scope,\n isRootAdmin,\n tampered,\n managed,\n grants: grants.map(({ project, environment }) => ({ project, environment })),\n }),\n );\n return { principals, removed };\n });\n}\n\nconst readProjects = (client: CoffreClient) => uiResult(() => client.projects.list());\n\n/** The projects you can see, or why they could not be listed. */\nexport type ProjectsResult = Awaited<ReturnType<typeof readProjects>>;\n\nexport type AuditSearch = { decision?: 'deny'; actorId?: string; detail?: '1' };\n\nexport const AUDIT_PAGE_SIZE = 200;\n\nexport const queries = {\n /** Who is looking; null when nobody is signed in. */\n me: (client: CoffreClient) =>\n queryOptions({\n queryKey: keys.me,\n queryFn: async (): Promise<Me | null> => {\n try {\n return await client.me();\n } catch (error) {\n if (statusOf(error) === 401) return null;\n throw error;\n }\n },\n }),\n\n /** How this instance signs people in. */\n auth: (client: CoffreClient) => queryOptions({ queryKey: keys.auth, queryFn: (): Promise<AuthInfo> => client.auth() }),\n\n /** The projects you can see, each with its distinct secret count. */\n projects: (client: CoffreClient) =>\n queryOptions({ queryKey: keys.projects, queryFn: () => readProjects(client) }),\n\n /** Who holds what in a project, for those who manage its access. */\n grants: (client: CoffreClient, project: string) =>\n queryOptions({\n queryKey: keys.grants(project),\n queryFn: () => uiResult(async () => ({ grants: grantRows((await client.members.list(project)).members) })),\n }),\n\n secrets: (client: CoffreClient, place: Place) =>\n queryOptions({\n queryKey: keys.secrets(place),\n queryFn: () => uiResult(() => client.secrets.list(`${place.project}/${place.environment}`)),\n }),\n\n /** What an environment lacks of its siblings' keys, those you read, and what its team dismissed. */\n missing: (client: CoffreClient, place: Place) =>\n queryOptions({\n queryKey: keys.missing(place),\n queryFn: () => uiResult(() => client.environments.missing(`${place.project}/${place.environment}`)),\n }),\n\n /** The live references into and out of a place, and who reads through them, for whoever manages its access. */\n references: (client: CoffreClient, path: string) =>\n queryOptions({\n queryKey: keys.references(path),\n queryFn: () => uiResult(() => client.references.list(path)),\n }),\n\n /**\n * Everyone in the directory, and who was removed. The API shows grant\n * managers the members of their projects; the directory pages are admins'\n * and owners', and asking for anyone else would only log a refusal, so\n * nobody else is asked.\n */\n directory: (client: CoffreClient, owner: boolean) =>\n queryOptions({\n queryKey: [...keys.directory, { owner }],\n queryFn: () =>\n owner\n ? listDirectory(client)\n : Promise.resolve({\n ok: false as const,\n error: 'Only admins and owners manage users, and service accounts are set up by those who hold access where the instance lets them.',\n signedOut: false,\n }),\n }),\n\n /**\n * One member's instance role and scope, and the grants you manage, in one\n * read: their page's Access tab. Null for whoever may list nobody, which\n * asking would only log as a refusal.\n */\n memberAccess: (client: CoffreClient, member: string, allowed: boolean) =>\n queryOptions({\n queryKey: [...keys.memberAccess(member), { allowed }],\n queryFn: () => (allowed ? uiResult(() => client.members.access(member)) : Promise.resolve(null)),\n }),\n\n /** What one member can reach and has seen; null for anyone but owners, who alone may ask. */\n report: (client: CoffreClient, member: string, owner: boolean) =>\n queryOptions({\n queryKey: [...keys.report(member), { owner }],\n queryFn: () =>\n owner\n ? uiResult(async () => {\n try {\n return { report: await client.members.get(member) };\n } catch (error) {\n // No such member is an answer, not a failure.\n if (statusOf(error) === 404) return { report: null };\n throw error;\n }\n })\n : Promise.resolve(null),\n }),\n\n /**\n * A token's credentials; null where they cannot be listed. Only owners\n * issue and see them, and only coffre's own sign-in issues any.\n */\n credentials: (client: CoffreClient, member: string, allowed: boolean) =>\n queryOptions({\n queryKey: [...keys.credentials(member), { allowed }],\n queryFn: () => (allowed ? uiResult(() => client.tokens.list(member)) : Promise.resolve(null)),\n }),\n\n /**\n * A token's trust bindings: the CI runs that may sign in as it. Null for\n * anyone but an owner, and where the deployment trusts no workloads\n * (`features.workloads`), so there is nothing to ask.\n */\n bindings: (client: CoffreClient, member: string, allowed: boolean) =>\n queryOptions({\n queryKey: [...keys.bindings(member), { allowed }],\n queryFn: () => (allowed ? uiResult(() => client.bindings.list(member)) : Promise.resolve(null)),\n }),\n\n /** The accounts you sign in with, under coffre's own sign-in. */\n identities: (client: CoffreClient) =>\n queryOptions({ queryKey: keys.identities, queryFn: () => uiResult(() => client.identities.list()) }),\n\n /** Where you are signed in, under coffre's own sign-in. */\n sessions: (client: CoffreClient) =>\n queryOptions({ queryKey: keys.sessions, queryFn: () => uiResult(() => client.sessions.list()) }),\n /** The MCP clients I connected, where the deployment serves MCP (`features.mcp`). */\n apps: (client: CoffreClient) =>\n queryOptions({ queryKey: keys.apps, queryFn: () => uiResult(() => client.apps.list()) }),\n\n /**\n * What the keys an operator keeps are checked against: the vault's ID and\n * the app key's fingerprint, no secret. Null for anyone but owners and root\n * admins, who alone may ask.\n */\n auditKeys: (client: CoffreClient, allowed: boolean) =>\n queryOptions({\n queryKey: [...keys.auditKeys, { allowed }],\n queryFn: () => (allowed ? uiResult(() => client.audit.keys()) : Promise.resolve(null)),\n }),\n\n /** The instance's settings: null for anyone but those who run it, who alone may ask. */\n settings: (client: CoffreClient, allowed: boolean) =>\n queryOptions({\n queryKey: [...keys.settings, { allowed }],\n queryFn: () => (allowed ? uiResult(() => client.settings.get()) : Promise.resolve(null)),\n }),\n\n /** A page of the log, as filtered: always read fresh. */\n auditEntries: (client: CoffreClient, search: AuditSearch) =>\n queryOptions({\n queryKey: [...keys.audit, 'entries', search],\n staleTime: 0,\n // Detail is left out by the server unless asked for, and counted.\n queryFn: () =>\n uiResult(() =>\n client.audit.list({\n limit: AUDIT_PAGE_SIZE,\n decision: search.decision,\n actor: search.actorId,\n detail: search.detail,\n }),\n ),\n }),\n\n /**\n * Whether the log holds: verified on every visit, and never waited for.\n * It re-reads the whole log, so it takes as long as the log is long; the\n * page shows the entries first and the verdict when it comes.\n */\n auditChain: (client: CoffreClient) =>\n queryOptions({ queryKey: [...keys.audit, 'chain'], staleTime: 0, queryFn: () => verifyChain(client) }),\n /** What deleting `market` or `market/prod` would take, asked afresh each time it is shown. */\n deletion: (client: CoffreClient, path: string) =>\n queryOptions({\n queryKey: ['deletion', path],\n staleTime: 0,\n gcTime: 0,\n queryFn: () =>\n uiResult(async () => {\n const { deletion } = path.includes('/')\n ? await client.environments.previewDelete(path)\n : await client.projects.previewDelete(path);\n return { deletion };\n }),\n }),\n};\n\n/**\n * Whether the log holds, or why that is not known. Verifying is for those\n * who read the whole log (an Auditor, Admin or Owner whose scope narrows\n * nothing, a root admin): anyone else reads their projects' part of it, and a part cannot be\n * checked as a chain, so for them it is a fact about the page, not a fault.\n */\nasync function verifyChain(client: CoffreClient) {\n try {\n const result = await client.audit.verify();\n return result.ok\n ? {\n integrity: 'intact' as const,\n through: result.through,\n entries: result.entries,\n checkpoint: result.checkpoint,\n pending: result.pending ?? 0,\n }\n : {\n integrity: 'broken' as const,\n through: result.through,\n failedAtSeq: result.failedAtSeq,\n author: result.author,\n reason: result.reason,\n };\n } catch (error) {\n const status = statusOf(error);\n if (status === 403) return { integrity: 'owners-only' as const };\n return {\n integrity: 'unknown' as const,\n problem: status === undefined ? 'the request never got an answer' : `the request failed with HTTP ${status}`,\n };\n }\n}\n\nexport type ChainResult = Awaited<ReturnType<typeof verifyChain>>;\n\n/**\n * Who is looking, how this instance signs people in, and the projects they\n * can see: what the shell needs on every screen. For someone signed out or\n * not yet a member the project list is refused, and they get the sign-in or\n * closed-door page.\n */\nexport function shellOf(\n auth: AuthInfo,\n me: Me | null,\n projects: ProjectsResult,\n) {\n const listed = projects.ok ? projects.projects : [];\n const member: Me | null = me?.registered === true ? me : null;\n return {\n auth,\n principal: me === null ? null : me.principal,\n instanceRole: member?.instanceRole ?? null,\n /** Where their instance role applies, projects by slug. */\n scope: member?.scope ?? EVERYWHERE,\n projects: listed,\n capabilities: deriveUiCapabilities(member, listed),\n registrationRequired: me !== null && !me.registered,\n /** A member the vault refuses: their record failed its integrity check. */\n accessTampered: me?.tampered === true,\n /** What the deployment's configuration turns on: MCP clients, as their endpoint's URL, and CI runs signing in by their ID tokens. */\n features: member?.features ?? { mcp: null, workloads: false },\n /** Every environment you hold something in, and what: what you may give a service account there (`givable`). */\n environments: member?.environments ?? [],\n /** Where you set up service accounts yourself, the instance's setting, projects by slug. */\n serviceSetup: member?.serviceSetup ?? null,\n };\n}\n\nexport type Shell = ReturnType<typeof shellOf>;\n\n/**\n * The shell, as every loader reads it: from the cache while fresh, so a\n * child route never asks again for what the root has.\n */\nexport async function loadShell(queryClient: QueryClient, client: CoffreClient): Promise<Shell> {\n const [auth, me, projects] = await Promise.all([\n queryClient.fetchQuery(queries.auth(client)),\n queryClient.fetchQuery(queries.me(client)),\n queryClient.fetchQuery(queries.projects(client)),\n ]);\n return shellOf(auth, me, projects);\n}\n\n/**\n * One project and, when you manage its access, its grants. A project that is\n * not there for you fails with no message: the page words that itself.\n */\nexport function projectOf(projects: ProjectsResult, slug: string) {\n if (!projects.ok) return projects;\n const project = projects.projects.find((entry) => entry.slug === slug);\n if (project === undefined) return { ok: false as const, error: null };\n return { ok: true as const, project, managesAccess: project.permissions.includes('grant.manage') };\n}\n\n/** What a project page reads: the project list, and its grants when you manage them. */\nexport async function loadProject(queryClient: QueryClient, client: CoffreClient, slug: string) {\n const found = projectOf(await queryClient.fetchQuery(queries.projects(client)), slug);\n if (found.ok && found.managesAccess) await queryClient.fetchQuery(queries.grants(client, slug));\n}\n\n/** The directory pages' read: the directory, for owners. */\nexport async function loadDirectory(queryClient: QueryClient, client: CoffreClient) {\n const shell = await loadShell(queryClient, client);\n return queryClient.fetchQuery(queries.directory(client, shell.capabilities.canManageGrants));\n}\n\n/** The instance's settings: the directory's counts, where people set up service accounts, and what its keys are checked against. */\nexport async function loadSettings(queryClient: QueryClient, client: CoffreClient) {\n const shell = await loadShell(queryClient, client);\n await Promise.all([\n loadDirectory(queryClient, client),\n queryClient.fetchQuery(queries.settings(client, shell.capabilities.runsInstance)),\n queryClient.fetchQuery(queries.auditKeys(client, shell.capabilities.runsInstance)),\n ]);\n}\n\n/** Whether the Service accounts page lists anyone: to admins and owners, and to whoever sets one up, those they manage. */\nexport function listsServices(shell: Shell): boolean {\n return shell.capabilities.canManageGrants || shell.capabilities.setsUpServices;\n}\n\n/**\n * How the caller may have a service account sign in, from its list entry\n * or its access: bearer tokens under coffre's own sign-in, trusted\n * workloads where the deployment trusts them, each only for an account they\n * manage.\n */\nexport function waysFor(shell: Shell, managed: boolean): { tokens: boolean; workloads: boolean } {\n return { tokens: managed && shell.auth.signin !== null, workloads: managed && shell.features.workloads };\n}\n\n/**\n * The service accounts page: the directory, and each account's bindings and\n * tokens, read here as its own page reads them, so the list shows how each\n * signs in from the first paint and the browser asks for nothing that may be\n * refused (a deployment that trusts no workloads answers bindings with one).\n */\nexport async function loadServiceDirectory(queryClient: QueryClient, client: CoffreClient) {\n const shell = await loadShell(queryClient, client);\n const directory = await queryClient.fetchQuery(queries.directory(client, listsServices(shell)));\n if (!directory.ok) return directory;\n await Promise.all(\n directory.principals\n .filter((principal) => principal.principalType === 'service')\n .flatMap((principal) => {\n const member = memberRef('service', principal.principalId);\n const ways = waysFor(shell, principal.managed === true);\n return [\n queryClient.fetchQuery(queries.credentials(client, member, ways.tokens)),\n queryClient.fetchQuery(queries.bindings(client, member, ways.workloads)),\n ];\n }),\n );\n return directory;\n}\n\n/** Who a user or service account is to the instance, its pages' header: null to anyone who does not run it. */\nexport async function loadMember(queryClient: QueryClient, client: CoffreClient, member: string) {\n const shell = await loadShell(queryClient, client);\n return queryClient.fetchQuery(queries.report(client, member, shell.capabilities.runsInstance));\n}\n\nexport type MemberReport = Awaited<ReturnType<typeof loadMember>>;\n\n/**\n * What a user's or service account's Access tab reads: their role, scope\n * and the grants you manage, in one request, which the server answers in\n * one query, however many projects they hold grants in.\n */\nexport async function loadAccess(queryClient: QueryClient, client: CoffreClient, member: string) {\n const shell = await loadShell(queryClient, client);\n return queryClient.fetchQuery(queries.memberAccess(client, member, listsAccess(shell)));\n}\n\n/**\n * Whether the caller may ask what someone holds: admins and owners,\n * whoever manages a project's access, and whoever sets up service accounts,\n * of those they manage.\n */\nexport function listsAccess(shell: Shell): boolean {\n return shell.capabilities.canManageGrants || shell.capabilities.setsUpServices || managedProjects(shell.projects).length > 0;\n}\n\nexport type MemberAccessResult = Awaited<ReturnType<typeof loadAccess>>;\n\n/**\n * How a service account's page lets it sign in: bearer tokens under\n * coffre's own sign-in, trusted workloads where the deployment trusts them.\n * Null where it shows neither: to anyone who does not manage it (its access\n * says, `managed`), and for an account that is not active, which can be\n * issued nothing.\n */\nexport function signInWays(shell: Shell, access: MemberAccessResult): { tokens: boolean; workloads: boolean } | null {\n const managed = access?.ok === true && access.managed && access.status === 'active';\n const ways = waysFor(shell, managed);\n return ways.tokens || ways.workloads ? ways : null;\n}\n\n/**\n * Whether a user has a Connected apps tab: for an owner, where the\n * deployment serves MCP, and while the user is registered and not removed,\n * since removal disconnects every app. The tab, and the route under it,\n * both ask.\n */\nexport function hasAppsTab(shell: Shell, report: MemberReport): boolean {\n const found = report?.ok === true ? report.report : null;\n return Boolean(shell.features.mcp) && shell.capabilities.runsInstance && found !== null && found.status !== 'removed';\n}\n\nexport function managedProjects(projects: ProjectSummary[]): ProjectSummary[] {\n return projects.filter((project) => project.permissions.includes('grant.manage'));\n}\n\n/**\n * What each change touches, which `useAction` refetches when it lands. Every\n * change also lands in the audit log, which is always read fresh.\n */\nexport const affects = {\n /** A project or environment made, renamed or archived: the tree, and where you hold access. */\n places: (): QueryKey[] => [keys.projects, keys.me],\n /** Secrets written, renamed, restored or archived: the environment and the counts. */\n secrets: (place: Place): QueryKey[] => [keys.secrets(place), keys.projects, ['references'], ['missing']],\n /**\n * Someone's access in a project changed: its grants, their report, and, as\n * it may be your own, what you can see.\n */\n access: (project: string, member: string): QueryKey[] => [\n keys.grants(project),\n keys.memberAccess(member),\n keys.report(member),\n keys.projects,\n keys.me,\n ],\n /** Someone let in: the directory. */\n admission: (): QueryKey[] => [keys.directory],\n /**\n * An instance role changed: the directory, their report, and, as it may be\n * your own, what you can see and do.\n */\n role: (member: string): QueryKey[] => [keys.directory, keys.report(member), keys.memberAccess(member), keys.me, keys.projects],\n /** Someone removed: the directory, their report, and every grant, which removal ends, those on every project too. */\n removal: (member: string): QueryKey[] => [keys.directory, keys.report(member), keys.memberAccess(member), ['grants'], keys.projects],\n /**\n * Where people set up service accounts changed: the setting, and what you\n * may do, which the directory and `/me` say.\n */\n settings: (): QueryKey[] => [keys.settings, keys.me, keys.directory],\n credentials: (member: string): QueryKey[] => [keys.credentials(member)],\n bindings: (member: string): QueryKey[] => [keys.bindings(member)],\n /** Unlinking an account also ends the sessions it signed in. */\n identities: (): QueryKey[] => [keys.identities, keys.sessions],\n sessions: (): QueryKey[] => [keys.sessions],\n apps: (): QueryKey[] => [keys.apps],\n};\n\n/**\n * Refetch what a change touched: at once where it is on screen, on next use\n * elsewhere. Every change lands in the audit log, so the log and its\n * verification are always among them.\n */\nexport async function refresh(queryClient: QueryClient, touched: QueryKey[]): Promise<void> {\n await Promise.all([...touched, keys.audit].map((queryKey) => queryClient.invalidateQueries({ queryKey })));\n}\n"],"mappings":";;;;AA8BA,IAAM,OAAuB;CAC3B,iBAAiB;CACjB,cAAc;CACd,gBAAgB;CAChB,cAAc;CACd,kBAAkB;AACpB;AAEA,SAAgB,qBACd,IACA,UACgB;CAChB,IAAI,OAAO,MAAM,OAAO;CAExB,MAAM,cAAc,GAAG,iBAAiB;CACxC,MAAM,OAAqB,GAAG,iBAAiB,eAAe,UAAU,GAAG;CAE3E,OAAO;EAIL,iBAAiB,eAAe,YAAY,IAAI;EAChD,cAAc,GAAG;EACjB,gBAAgB,GAAG;EACnB,cAAc,GAAG;EAGjB,kBAAkB,cAAc;GAAE;GAAa;GAAM,OAAO,GAAG;GAAO,QAAQ,CAAC;EAAE,CAAC;CACpF;AACF;;AAGA,SAAgB,iBAAiB,aAA6C;CAC5E,OAAO,YAAY,SAAS,aAAa;AAC3C;;;;;;;;;;;;;;;;;AC1CA,IAAa,WAAW;AAExB,SAAgB,oBAAiC;CAC/C,OAAO,IAAI,YAAY,EACrB,gBAAgB,EACd,SAAS;EACP,WAAW;EACX,sBAAsB;EAGtB,OAAO;CACT,EACF,EACF,CAAC;AACH;;;;;AAQA,IAAa,OAAO;CAClB,IAAI,CAAC,IAAI;CACT,MAAM,CAAC,MAAM;CACb,UAAU,CAAC,UAAU;CACrB,SAAS,YAAoB,CAAC,UAAU,OAAO;CAC/C,UAAU,EAAE,SAAS,kBAAyB;EAAC;EAAW;EAAS;CAAW;CAC9E,aAAa,SAAiB,CAAC,cAAc,IAAI;CACjD,UAAU,EAAE,SAAS,kBAAyB;EAAC;EAAW;EAAS;CAAW;CAC9E,WAAW,CAAC,WAAW;CACvB,SAAS,WAAmB,CAAC,UAAU,MAAM;CAC7C,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,KAAK,EAAE;;CAEjD,UAAU,UAA6B;EAAC,KAAK,QAAQ,KAAK;EAAG,KAAK;EAAU,CAAC,YAAY;EAAG,CAAC,SAAS;CAAC;;;;;CAKvG,SAAS,SAAiB,WAA+B;EACvD,KAAK,OAAO,OAAO;EACnB,KAAK,aAAa,MAAM;EACxB,KAAK,OAAO,MAAM;EAClB,KAAK;EACL,KAAK;CACP;;CAEA,iBAA6B,CAAC,KAAK,SAAS;;;;;CAK5C,OAAO,WAA+B;EAAC,KAAK;EAAW,KAAK,OAAO,MAAM;EAAG,KAAK,aAAa,MAAM;EAAG,KAAK;EAAI,KAAK;CAAQ;;CAE7H,UAAU,WAA+B;EAAC,KAAK;EAAW,KAAK,OAAO,MAAM;EAAG,KAAK,aAAa,MAAM;EAAG,CAAC,QAAQ;EAAG,KAAK;CAAQ;;;;;CAKnI,gBAA4B;EAAC,KAAK;EAAU,KAAK;EAAI,KAAK;CAAS;CACnE,cAAc,WAA+B,CAAC,KAAK,YAAY,MAAM,CAAC;CACtE,WAAW,WAA+B,CAAC,KAAK,SAAS,MAAM,CAAC;;CAEhE,kBAA8B,CAAC,KAAK,YAAY,KAAK,QAAQ;CAC7D,gBAA4B,CAAC,KAAK,QAAQ;CAC1C,YAAwB,CAAC,KAAK,IAAI;AACpC;;;;;;AAOA,eAAsB,QAAQ,aAA0B,SAAoC;CAC1F,MAAM,QAAQ,IAAI,CAAC,GAAG,SAAS,KAAK,KAAK,CAAC,CAAC,KAAK,aAAa,YAAY,kBAAkB,EAAE,SAAS,CAAC,CAAC,CAAC;AAC3G"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"role-field-DWhkRY6n.js","names":[],"sources":["../../src/components/role-field.tsx"],"sourcesContent":["import { useId, useState } from 'react';\nimport { INSTANCE_ROLE_NAMES, INSTANCE_ROLES, type Filter, type InstanceRole, type Scope } from '@coffre/core/access';\nimport type { RoleVars } from '../lib/changes';\nimport { useShell } from '../lib/use-shell';\nimport { slugProblem } from '../lib/validation';\nimport { X } from './icons';\n\n/**\n * A person's instance role, one dropdown, and under it, for every role but\n * Member, where it applies: projects and environments, each All, Only or\n * All except. Projects are picked from those there are; environments are\n * names, so any slug goes, the ones made later too.\n */\nexport function RoleField({ value, onChange }: { value: RoleVars; onChange: (value: RoleVars) => void }) {\n const { role, scope } = value;\n return (\n <>\n <label className=\"field\">\n <span className=\"label\">Instance role</span>\n <select\n className=\"select\"\n value={role}\n onChange={(event) => onChange({ role: event.target.value as InstanceRole, scope })}\n >\n {INSTANCE_ROLE_NAMES.map((name) => (\n <option key={name} value={name}>\n {INSTANCE_ROLES[name].name}\n </option>\n ))}\n </select>\n <span className=\"hint\">\n {INSTANCE_ROLES[role].description}\n {role === 'member' ? '' : ' Project grants add to it.'}\n </span>\n </label>\n {role !== 'member' && <ScopeField scope={scope} onChange={(next) => onChange({ role, scope: next })} />}\n </>\n );\n}\n\n/**\n * Where something applies: projects and environments, each All, Only or All\n * except. A role's scope, and the instance's setting of where people set\n * up service accounts, which has the same shape.\n */\nexport function ScopeField({ scope, onChange, legend = 'Where' }: { scope: Scope; onChange: (scope: Scope) => void; legend?: string }) {\n const { projects } = useShell();\n const slugs = [...new Set(projects.flatMap((project) => project.environments.map((environment) => environment.slug)))].sort();\n return (\n <fieldset className=\"field scope-field\">\n <legend className=\"label\">{legend}</legend>\n <FilterRow\n label=\"Projects\"\n filter={scope.projects}\n options={projects.map((project) => project.slug)}\n onChange={(filter) => onChange({ ...scope, projects: filter })}\n />\n <FilterRow\n label=\"Environments\"\n filter={scope.environments}\n options={slugs}\n free\n onChange={(filter) => onChange({ ...scope, environments: filter })}\n />\n {scope.environments !== 'all' && <span className=\"hint\">Environments match by name in every project, new ones included.</span>}\n </fieldset>\n );\n}\n\ntype Mode = 'all' | 'only' | 'except';\n\nconst namesOf = (filter: Filter): string[] => (filter === 'all' ? [] : 'only' in filter ? filter.only : filter.except);\n\nfunction filterOf(mode: Mode, names: string[]): Filter {\n return mode === 'all' ? 'all' : mode === 'only' ? { only: names } : { except: names };\n}\n\n/** One filter: All, Only or All except, and the names it lists. */\nfunction FilterRow({\n label,\n filter,\n options,\n free = false,\n onChange,\n}: {\n label: string;\n filter: Filter;\n options: string[];\n /** Whether a name need not be among `options`: an environment's slug, which may come later. */\n free?: boolean;\n onChange: (filter: Filter) => void;\n}) {\n const mode: Mode = filter === 'all' ? 'all' : 'only' in filter ? 'only' : 'except';\n const names = namesOf(filter);\n return (\n <div className=\"scope-row\">\n <span className=\"scope-label\">{label}</span>\n <select\n className=\"select select-sm\"\n aria-label={`${label}: which`}\n value={mode}\n onChange={(event) => onChange(filterOf(event.target.value as Mode, names))}\n >\n <option value=\"all\">All</option>\n <option value=\"only\">Only</option>\n <option value=\"except\">All except</option>\n </select>\n {mode !== 'all' && (\n <NamePicker label={label} names={names} options={options} free={free} onChange={(next) => onChange(filterOf(mode, next))} />\n )}\n </div>\n );\n}\n\n/** Names as chips, and a field to add one: picked from the list, or, where any name goes, typed and entered. */\nfunction NamePicker({\n label,\n names,\n options,\n free,\n onChange,\n}: {\n label: string;\n names: string[];\n options: string[];\n free: boolean;\n onChange: (names: string[]) => void;\n}) {\n const [draft, setDraft] = useState('');\n const list = useId();\n const add = (raw: string) => {\n const name = raw.trim();\n setDraft('');\n if (name === '' || names.includes(name)) return;\n if (free ? slugProblem(name) !== null : !options.includes(name)) return;\n onChange([...names, name]);\n };\n const offered = options.filter((option) => !names.includes(option));\n return (\n <span className=\"scope-names\">\n {names.map((name) => (\n <span key={name} className=\"tag scope-chip\">\n <span className=\"mono\">{name}</span>\n <button type=\"button\" aria-label={`Remove ${name}`} onClick={() => onChange(names.filter((other) => other !== name))}>\n <X size={11} />\n </button>\n </span>\n ))}\n <input\n className=\"input input-mono scope-input\"\n list={list}\n value={draft}\n spellCheck={false}\n autoComplete=\"off\"\n placeholder={names.length === 0 ? (free ? 'dev' : 'Pick a project') : 'Add'}\n aria-label={`Add to ${label}`}\n aria-invalid={draft !== '' && free && slugProblem(draft.trim()) !== null}\n onChange={(event) => {\n // A name picked from the list goes in at once; one typed, on Enter.\n if ((event.nativeEvent as InputEvent).inputType === 'insertReplacementText' || (!free && options.includes(event.target.value))) {\n add(event.target.value);\n } else {\n setDraft(event.target.value);\n }\n }}\n onKeyDown={(event) => {\n if (event.key === 'Enter' || event.key === ',') {\n event.preventDefault();\n add(draft);\n } else if (event.key === 'Backspace' && draft === '' && names.length > 0) {\n onChange(names.slice(0, -1));\n }\n }}\n onBlur={() => add(draft)}\n />\n <datalist id={list}>\n {offered.map((option) => (\n <option key={option} value={option} />\n ))}\n </datalist>\n </span>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,SAAgB,UAAU,EAAE,OAAO,YAAsE;CACvG,MAAM,EAAE,MAAM,UAAU;CACxB,OACE,qBAAA,YAAA,EAAA,UAAA,CACE,qBAAC,SAAD;EAAO,WAAU;YAAjB;GACE,oBAAC,QAAD;IAAM,WAAU;cAAQ;GAAmB,CAAA;GAC3C,oBAAC,UAAD;IACE,WAAU;IACV,OAAO;IACP,WAAW,UAAU,SAAS;KAAE,MAAM,MAAM,OAAO;KAAuB;IAAM,CAAC;cAEhF,oBAAoB,KAAK,SACxB,oBAAC,UAAD;KAAmB,OAAO;eACvB,eAAe,KAAK,CAAC;IAChB,GAFK,IAEL,CACT;GACK,CAAA;GACR,qBAAC,QAAD;IAAM,WAAU;cAAhB,CACG,eAAe,KAAK,CAAC,aACrB,SAAS,WAAW,KAAK,4BACtB;;EACD;KACN,SAAS,YAAY,oBAAC,YAAD;EAAmB;EAAO,WAAW,SAAS,SAAS;GAAE;GAAM,OAAO;EAAK,CAAC;CAAI,CAAA,CACtG,EAAA,CAAA;AAEN;;;;;;AAOA,SAAgB,WAAW,EAAE,OAAO,UAAU,SAAS,WAAgF;CACrI,MAAM,EAAE,aAAa,SAAS;CAC9B,MAAM,QAAQ,CAAC,GAAG,IAAI,IAAI,SAAS,SAAS,YAAY,QAAQ,aAAa,KAAK,gBAAgB,YAAY,IAAI,CAAC,CAA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KAAK;UAEtB,SAAS,MAAM,OAAO,KAAK;IAE/B;IACA,YAAY,UAAU;KACpB,IAAI,MAAM,QAAQ,WAAW,MAAM,QAAQ,KAAK;MAC9C,MAAM,eAAe;MACrB,IAAI,KAAK;KACX,OAAO,IAAI,MAAM,QAAQ,eAAe,UAAU,MAAM,MAAM,SAAS,GACrE,SAAS,MAAM,MAAM,GAAG,EAAE,CAAC;IAE/B;IACA,cAAc,IAAI,KAAK;GACxB,CAAA;GACD,oBAAC,YAAD;IAAU,IAAI;cACX,QAAQ,KAAK,WACZ,oBAAC,UAAD,EAAqB,OAAO,OAAS,GAAxB,MAAwB,CACtC;GACO,CAAA;EACN;;AAEV"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"row-state-DOPUsjQK.js","names":[],"sources":["../../src/lib/announce.ts","../../src/components/row-state.tsx"],"sourcesContent":["/**\n * What a screen reader hears of a change: that it is on its way, that it\n * landed, or why it did not. Changes show on screen as dimmed or struck-out\n * rows; this says the same in words, through two live regions in the shell\n * (`LiveRegion`), one polite and one for failures, which interrupts.\n */\nexport type Announcement = { text: string; id: number };\n\ntype Heard = { polite: Announcement | null; urgent: Announcement | null };\n\nlet heard: Heard = { polite: null, urgent: null };\nlet next = 0;\nconst listeners = new Set<() => void>();\n\nexport function announce(text: string, { urgent = false }: { urgent?: boolean } = {}): void {\n // A fresh id, so the same words said twice are heard twice.\n const said = { text, id: next++ };\n heard = urgent ? { ...heard, urgent: said } : { ...heard, polite: said };\n for (const listener of listeners) listener();\n}\n\nexport function subscribeAnnouncements(listener: () => void): () => void {\n listeners.add(listener);\n return () => listeners.delete(listener);\n}\n\nexport function announcements(): Heard {\n return heard;\n}\n\nconst nobody: Heard = { polite: null, urgent: null };\n\n/** On the server nothing has been said yet. */\nexport function serverAnnouncements(): Heard {\n return nobody;\n}\n","import { useSyncExternalStore, type ReactNode } from 'react';\n\nimport { announcements, serverAnnouncements, subscribeAnnouncements } from '../lib/announce';\nimport type { ItemStatus } from '../lib/optimistic';\nimport { Spinner } from './ui';\nimport { AlertCircle, X } from './icons';\n\n/**\n * How a row looks while a change to it is on its way, or after the server\n * refused it. Never colour alone: a waiting row is quieter and says what it\n * waits for, a row being removed is struck through as well, and a refused\n * change says so in words beneath its row.\n */\nexport function rowClass(status: ItemStatus): string {\n if (status.state === 'pending') return status.kind === 'removing' ? 'is-removing' : 'is-saving';\n if (status.state === 'failed') return 'is-failed';\n return '';\n}\n\n/** In place of a row's actions while its change is on its way. */\nexport function RowPending({ status }: { status: ItemStatus }) {\n if (status.state !== 'pending') return null;\n return (\n <span className=\"row-pending\">\n <Spinner size={13} />\n {status.words.pending}\n </span>\n );\n}\n\n/** Beneath a row whose change the server refused: why, until dismissed. */\nexport function RowFailure({\n status,\n columns,\n onDismiss,\n children,\n}: {\n status: ItemStatus;\n columns: number;\n onDismiss: () => void;\n /** Said before the reason; by default, what did not happen. */\n children?: ReactNode;\n}) {\n if (status.state !== 'failed') return null;\n return (\n <tr className=\"row-error row-failure\">\n <td colSpan={columns}>\n <ItemFailure status={status} onDismiss={onDismiss}>\n {children}\n </ItemFailure>\n </td>\n </tr>\n );\n}\n\n/** Why the server refused a change, where it shows: under a row, or in a card. */\nexport function ItemFailure({\n status,\n onDismiss,\n children,\n}: {\n status: ItemStatus;\n onDismiss: () => void;\n children?: ReactNode;\n}) {\n if (status.state !== 'failed') return null;\n return (\n <div className=\"row-failure-line\">\n <p className=\"error-line\">\n <AlertCircle size={14} />\n <span>\n <strong>{children ?? status.words.failed}</strong> {status.error}\n </span>\n </p>\n <button type=\"button\" className=\"act act-quiet\" onClick={onDismiss} aria-label=\"Dismiss\">\n <X size={13} />\n </button>\n </div>\n );\n}\n\n/** Where changes are announced to screen readers (`lib/announce.ts`). */\nexport function LiveRegion() {\n const { polite, urgent } = useSyncExternalStore(subscribeAnnouncements, announcements, serverAnnouncements);\n return (\n <>\n <div className=\"visually-hidden\" role=\"status\" aria-live=\"polite\" aria-atomic=\"true\">\n {polite !== null && <span key={polite.id}>{polite.text}</span>}\n </div>\n <div className=\"visually-hidden\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\">\n {urgent !== null && <span key={urgent.id}>{urgent.text}</span>}\n </div>\n </>\n );\n}\n"],"mappings":";;;;;AAUA,IAAI,QAAe;CAAE,QAAQ;CAAM,QAAQ;AAAK;AAChD,IAAI,OAAO;AACX,IAAM,4BAAY,IAAI,IAAgB;AAEtC,SAAgB,SAAS,MAAc,EAAE,SAAS,UAAgC,CAAC,GAAS;CAE1F,MAAM,OAAO;EAAE;EAAM,IAAI;CAAO;CAChC,QAAQ,SAAS;EAAE,GAAG;EAAO,QAAQ;CAAK,IAAI;EAAE,GAAG;EAAO,QAAQ;CAAK;CACvE,KAAK,MAAM,YAAY,WAAW,SAAS;AAC7C;AAEA,SAAgB,uBAAuB,UAAkC;CACvE,UAAU,IAAI,QAAQ;CACtB,aAAa,UAAU,OAAO,QAAQ;AACxC;AAEA,SAAgB,gBAAuB;CACrC,OAAO;AACT;AAEA,IAAM,SAAgB;CAAE,QAAQ;CAAM,QAAQ;AAAK;;AAGnD,SAAgB,sBAA6B;CAC3C,OAAO;AACT;;;;;;;;;ACtBA,SAAgB,SAAS,QAA4B;CACnD,IAAI,OAAO,UAAU,WAAW,OAAO,OAAO,SAAS,aAAa,gBAAgB;CACpF,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,OAAO;AACT;;AAGA,SAAgB,WAAW,EAAE,UAAkC;CAC7D,IAAI,OAAO,UAAU,WAAW,OAAO;CACvC,OACE,qBAAC,QAAD;EAAM,WAAU;YAAhB,CACE,oBAAC,SAAD,EAAS,MAAM,GAAK,CAAA,GACnB,OAAO,MAAM,OACV;;AAEV;;AAGA,SAAgB,WAAW,EACzB,QACA,SACA,WACA,YAOC;CACD,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,OACE,oBAAC,MAAD;EAAI,WAAU;YACZ,oBAAC,MAAD;GAAI,SAAS;aACX,oBAAC,aAAD;IAAqB;IAAmB;IACrC;GACU,CAAA;EACX,CAAA;CACF,CAAA;AAER;;AAGA,SAAgB,YAAY,EAC1B,QACA,WACA,YAKC;CACD,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,OACE,qBAAC,OAAD;EAAK,WAAU;YAAf,CACE,qBAAC,KAAD;GAAG,WAAU;aAAb,CACE,oBAAC,aAAD,EAAa,MAAM,GAAK,CAAA,GACxB,qBAAC,QAAD,EAAA,UAAA;IACE,oBAAC,UAAD,EAAA,UAAS,YAAY,OAAO,MAAM,OAAe,CAAA;IAAC;IAAE,OAAO;GACvD,EAAA,CAAA,CACL;MACH,oBAAC,UAAD;GAAQ,MAAK;GAAS,WAAU;GAAgB,SAAS;GAAW,cAAW;aAC7E,oBAAC,GAAD,EAAG,MAAM,GAAK,CAAA;EACR,CAAA,CACL;;AAET;;AAGA,SAAgB,aAAa;CAC3B,MAAM,EAAE,QAAQ,WAAW,qBAAqB,wBAAwB,eAAe,mBAAmB;CAC1G,OACE,qBAAA,YAAA,EAAA,UAAA,CACE,oBAAC,OAAD;EAAK,WAAU;EAAkB,MAAK;EAAS,aAAU;EAAS,eAAY;YAC3E,WAAW,QAAQ,oBAAC,QAAD,EAAA,UAAuB,OAAO,KAAW,GAA9B,OAAO,EAAuB;CAC1D,CAAA,GACL,oBAAC,OAAD;EAAK,WAAU;EAAkB,MAAK;EAAQ,aAAU;EAAY,eAAY;YAC7E,WAAW,QAAQ,oBAAC,QAAD,EAAA,UAAuB,OAAO,KAAW,GAA9B,OAAO,EAAuB;CAC1D,CAAA,CACL,EAAA,CAAA;AAEN"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"signin-errors--ykMFuqN.js","names":[],"sources":["../../src/lib/signin-errors.ts"],"sourcesContent":["/**\n * What went wrong with a sign-in, in words. The callback redirects with a\n * code rather than a sentence so the URL stays short and nothing the provider\n * said is reflected into the page.\n */\nconst MESSAGES: Record<string, string> = {\n provider_denied: 'The sign-in was cancelled, or the provider refused it.',\n state_mismatch:\n 'This sign-in expired or was started in another tab. Start again from this page.',\n invalid_response:\n 'The provider answered in a way coffre could not verify. Try again; if it keeps happening, tell whoever runs coffre.',\n provider_unavailable: 'The provider could not be reached. Try again in a moment.',\n no_verified_email:\n 'That account has no verified email address, so coffre cannot match it to an invitation.',\n wrong_domain: 'That account is outside the organization this instance belongs to.',\n not_in_organization:\n 'That GitHub account is not a member of the required organization. If it is, grant coffre access to the organization when GitHub asks.',\n not_registered:\n 'Nobody has invited that account’s email address. Ask an owner to add you under Users, then sign in again.',\n deactivated: 'Your access to this coffre was removed. Ask an owner if that is a mistake.',\n account_mismatch:\n 'Your email already signs in with a different account. Use that one, then link this account from your account page.',\n already_linked: 'That account is already linked to someone else.',\n tampered:\n 'Your access record failed coffre’s integrity check: it was changed outside coffre. An owner must remove you and add you again.',\n unknown_provider: 'That sign-in option is not configured here.',\n link_session: 'Your session changed while linking. Sign in again, then retry.',\n};\n\n/**\n * Where an email already signs in, for `account_mismatch`: the providers by\n * the label the sign-in page shows them under, and the one just tried. What\n * the visitor may know: the provider has just verified the email is theirs.\n */\nexport type Already = { providers: readonly string[]; via?: string };\n\nexport function signinErrorMessage(code: string | undefined, already?: Already): string | null {\n if (code === undefined) return null;\n if (code === 'account_mismatch' && already !== undefined && already.providers.length > 0) return mismatch(already);\n return MESSAGES[code] ?? 'The sign-in did not complete. Try again.';\n}\n\n/** \"Your email already signs in with GitHub. Sign in with GitHub, then link this account from your account page.\" */\nfunction mismatch({ providers, via }: Already): string {\n const link = 'then link this account from your account page.';\n // The same provider, another account of it: a second GitHub account, say.\n if (providers.length === 1 && providers[0] === via) {\n return `Your email already signs in with another ${via} account. Sign in with that one, ${link}`;\n }\n const named = providers.map((provider) => (provider === via ? `another ${provider} account` : provider));\n const list = named.length < 3 ? named.join(' and ') : `${named.slice(0, -1).join(', ')} and ${named.at(-1)}`;\n return named.length === 1\n ? `Your email already signs in with ${list}. Sign in with ${list}, ${link}`\n : `Your email already signs in with ${list}. Sign in with one of them, ${link}`;\n}\n\nexport type LoginSearch = { next?: string; error?: string; with?: string; via?: string };\n\n/** A sign-in provider's id, as the instance configures it. */\nconst PROVIDER_ID = /^[a-z0-9_-]{1,40}$/;\n\n/**\n * `/login`'s search: where to resume after signing in, same-origin paths\n * only, since an absolute URL accepted here would make the sign-in page an\n * open redirect; and the sign-in's `error`, with account_mismatch's `with`\n * and `via`, provider ids, shown once, then taken out of the URL.\n */\nexport function loginSearch(search: Record<string, unknown>): LoginSearch {\n const out: LoginSearch = {};\n const { next, error, via } = search;\n if (typeof next === 'string' && next.startsWith('/') && !next.startsWith('//')) out.next = next;\n if (typeof error === 'string' && /^[a-z_]{1,40}$/.test(error)) out.error = error;\n const providers = typeof search.with === 'string' ? search.with.split(',').filter((id) => PROVIDER_ID.test(id)).slice(0, 8) : [];\n if (providers.length > 0) out.with = providers.join(',');\n if (typeof via === 'string' && PROVIDER_ID.test(via)) out.via = via;\n return out;\n}\n"],"mappings":";;;;;;AAKA,IAAM,WAAmC;CACvC,iBAAiB;CACjB,gBACE;CACF,kBACE;CACF,sBAAsB;CACtB,mBACE;CACF,cAAc;CACd,qBACE;CACF,gBACE;CACF,aAAa;CACb,kBACE;CACF,gBAAgB;CAChB,UACE;CACF,kBAAkB;CAClB,cAAc;AAChB;AASA,SAAgB,mBAAmB,MAA0B,SAAkC;CAC7F,IAAI,SAAS,KAAA,GAAW,OAAO;CAC/B,IAAI,SAAS,sBAAsB,YAAY,KAAA,KAAa,QAAQ,UAAU,SAAS,GAAG,OAAO,SAAS,OAAO;CACjH,OAAO,SAAS,SAAS;AAC3B;;AAGA,SAAS,SAAS,EAAE,WAAW,OAAwB;CACrD,MAAM,OAAO;CAEb,IAAI,UAAU,WAAW,KAAK,UAAU,OAAO,KAC7C,OAAO,4CAA4C,IAAI,mCAAmC;CAE5F,MAAM,QAAQ,UAAU,KAAK,aAAc,aAAa,MAAM,WAAW,SAAS,YAAY,QAAS;CACvG,MAAM,OAAO,MAAM,SAAS,IAAI,MAAM,KAAK,OAAO,I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