@coffre/ui 0.14.5 → 0.15.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 (115) hide show
  1. package/dist/chunks/{audit-sentence-JgJEwQEC.js → actions-log-DupYCEyV.js} +186 -21
  2. package/dist/chunks/actions-log-DupYCEyV.js.map +1 -0
  3. package/dist/chunks/{connected-apps-IJdunsu8.js → connected-apps-CGUQlFMx.js} +5 -5
  4. package/dist/chunks/{connected-apps-IJdunsu8.js.map → connected-apps-CGUQlFMx.js.map} +1 -1
  5. package/dist/chunks/{delete-place-dIVoK87I.js → delete-place-CswZ-meh.js} +5 -5
  6. package/dist/chunks/{delete-place-dIVoK87I.js.map → delete-place-CswZ-meh.js.map} +1 -1
  7. package/dist/chunks/{directory-BM8yoiJN.js → directory-DrswWQLT.js} +15 -15
  8. package/dist/chunks/directory-DrswWQLT.js.map +1 -0
  9. package/dist/chunks/environment-actions-8rL9Cw6X.js +576 -0
  10. package/dist/chunks/environment-actions-8rL9Cw6X.js.map +1 -0
  11. package/dist/chunks/{folders-D3A1NGpt.js → folders-A6sbR_PG.js} +3 -3
  12. package/dist/chunks/{folders-D3A1NGpt.js.map → folders-A6sbR_PG.js.map} +1 -1
  13. package/dist/chunks/{grants-CjVmOgb2.js → grants-C0cb2oii.js} +8 -8
  14. package/dist/chunks/grants-C0cb2oii.js.map +1 -0
  15. package/dist/chunks/{multi-combobox-B0JzP1QN.js → multi-combobox-B3SEv1gq.js} +3 -3
  16. package/dist/chunks/{multi-combobox-B0JzP1QN.js.map → multi-combobox-B3SEv1gq.js.map} +1 -1
  17. package/dist/chunks/{offboarding-DbozhPym.js → offboarding-C1jbG_dk.js} +72 -67
  18. package/dist/chunks/offboarding-C1jbG_dk.js.map +1 -0
  19. package/dist/chunks/{page-JTORvh-N.js → page-CfhC9Hp1.js} +11 -6
  20. package/dist/chunks/page-CfhC9Hp1.js.map +1 -0
  21. package/dist/chunks/{personal-tokens-zWZOzLIC.js → personal-tokens-xC9wulhg.js} +5 -5
  22. package/dist/chunks/{personal-tokens-zWZOzLIC.js.map → personal-tokens-xC9wulhg.js.map} +1 -1
  23. package/dist/chunks/{principal-DFBswTBr.js → principal-CI17XK13.js} +2 -2
  24. package/dist/chunks/{principal-DFBswTBr.js.map → principal-CI17XK13.js.map} +1 -1
  25. package/dist/chunks/{principal-page-jJ0RVFg8.js → principal-page-CdSeftGD.js} +17 -127
  26. package/dist/chunks/principal-page-CdSeftGD.js.map +1 -0
  27. package/dist/chunks/{project-page-BjwEoXfU.js → project-page-CHxjBE97.js} +3 -3
  28. package/dist/chunks/{project-page-BjwEoXfU.js.map → project-page-CHxjBE97.js.map} +1 -1
  29. package/dist/chunks/{queries-2jdgTwfZ.js → queries-D1JuimTu.js} +82 -26
  30. package/dist/chunks/queries-D1JuimTu.js.map +1 -0
  31. package/dist/chunks/{references-CRT2BsOS.js → references-D5llUGQL.js} +5 -5
  32. package/dist/chunks/{references-CRT2BsOS.js.map → references-D5llUGQL.js.map} +1 -1
  33. package/dist/chunks/{role-field-DswIpPqY.js → role-field-CoCv8wse.js} +5 -5
  34. package/dist/chunks/role-field-CoCv8wse.js.map +1 -0
  35. package/dist/chunks/{row-state-xtRGFnDc.js → row-state-CYH7kZHl.js} +3 -3
  36. package/dist/chunks/{row-state-xtRGFnDc.js.map → row-state-CYH7kZHl.js.map} +1 -1
  37. package/dist/chunks/{theme-Ck45wzWB.js → theme-rF44Wbmm.js} +3 -3
  38. package/dist/chunks/{theme-Ck45wzWB.js.map → theme-rF44Wbmm.js.map} +1 -1
  39. package/dist/chunks/{ui-D-blFWfx.js → ui-CGdORVzW.js} +2 -2
  40. package/dist/chunks/{ui-D-blFWfx.js.map → ui-CGdORVzW.js.map} +1 -1
  41. package/dist/chunks/{use-action-CXEFFjx5.js → use-action-BxrHTBZw.js} +3 -3
  42. package/dist/chunks/{use-action-CXEFFjx5.js.map → use-action-BxrHTBZw.js.map} +1 -1
  43. package/dist/chunks/{use-change-BC4xo02c.js → use-change-BorW2R6C.js} +4 -4
  44. package/dist/chunks/{use-change-BC4xo02c.js.map → use-change-BorW2R6C.js.map} +1 -1
  45. package/dist/chunks/{use-roles-DswiNxBk.js → use-roles-BZnJ9Cq0.js} +56 -13
  46. package/dist/chunks/use-roles-BZnJ9Cq0.js.map +1 -0
  47. package/dist/chunks/{use-shell-zpjE_MKh.js → use-shell-CPskgi1k.js} +3 -3
  48. package/dist/chunks/{use-shell-zpjE_MKh.js.map → use-shell-CPskgi1k.js.map} +1 -1
  49. package/dist/index.d.ts +46 -2
  50. package/dist/index.js +30 -11
  51. package/dist/index.js.map +1 -1
  52. package/dist/pages/account.js +11 -11
  53. package/dist/pages/account.js.map +1 -1
  54. package/dist/pages/approval.js +2 -2
  55. package/dist/pages/audit.js +55 -21
  56. package/dist/pages/audit.js.map +1 -1
  57. package/dist/pages/device-login.js +2 -2
  58. package/dist/pages/environment.js +228 -389
  59. package/dist/pages/environment.js.map +1 -1
  60. package/dist/pages/login.js +3 -3
  61. package/dist/pages/oauth-authorize.js +2 -2
  62. package/dist/pages/project-access.js +11 -11
  63. package/dist/pages/project-environments.js +28 -359
  64. package/dist/pages/project-environments.js.map +1 -1
  65. package/dist/pages/project-settings.js +8 -8
  66. package/dist/pages/project.js +3 -3
  67. package/dist/pages/projects.js +8 -8
  68. package/dist/pages/service-account.js +11 -10
  69. package/dist/pages/service-account.js.map +1 -1
  70. package/dist/pages/service-accounts.js +7 -6
  71. package/dist/pages/service-accounts.js.map +1 -1
  72. package/dist/pages/settings.d.ts +6 -1
  73. package/dist/pages/settings.js +284 -164
  74. package/dist/pages/settings.js.map +1 -1
  75. package/dist/pages/unregistered.js +2 -2
  76. package/dist/pages/user.js +7 -6
  77. package/dist/pages/user.js.map +1 -1
  78. package/dist/pages/users.js +7 -6
  79. package/dist/pages/users.js.map +1 -1
  80. package/package.json +3 -3
  81. package/src/components/actions-log.tsx +61 -8
  82. package/src/components/directory.tsx +5 -5
  83. package/src/components/environment-actions.tsx +508 -0
  84. package/src/components/grants.tsx +2 -2
  85. package/src/components/icons.tsx +2 -0
  86. package/src/components/offboarding.tsx +7 -0
  87. package/src/components/page.tsx +3 -2
  88. package/src/components/principal-page.tsx +1 -1
  89. package/src/components/protected.tsx +52 -39
  90. package/src/components/role-editor.tsx +99 -68
  91. package/src/components/role-field.tsx +1 -1
  92. package/src/lib/audit-sentences.ts +21 -18
  93. package/src/lib/queries.ts +85 -21
  94. package/src/lib/roles.ts +36 -10
  95. package/src/options.ts +19 -3
  96. package/src/pages/account.tsx +1 -1
  97. package/src/pages/audit.tsx +56 -16
  98. package/src/pages/environment.tsx +227 -352
  99. package/src/pages/project-environments.tsx +20 -322
  100. package/src/pages/service-accounts.tsx +1 -1
  101. package/src/pages/settings.tsx +129 -48
  102. package/src/pages/users.tsx +1 -1
  103. package/src/parity.ts +18 -11
  104. package/src/styles/globals.css +271 -89
  105. package/dist/chunks/audit-sentence-JgJEwQEC.js.map +0 -1
  106. package/dist/chunks/directory-BM8yoiJN.js.map +0 -1
  107. package/dist/chunks/grants-CjVmOgb2.js.map +0 -1
  108. package/dist/chunks/offboarding-DbozhPym.js.map +0 -1
  109. package/dist/chunks/page-JTORvh-N.js.map +0 -1
  110. package/dist/chunks/principal-page-jJ0RVFg8.js.map +0 -1
  111. package/dist/chunks/protected-y7KVhtHd.js +0 -77
  112. package/dist/chunks/protected-y7KVhtHd.js.map +0 -1
  113. package/dist/chunks/queries-2jdgTwfZ.js.map +0 -1
  114. package/dist/chunks/role-field-DswIpPqY.js.map +0 -1
  115. package/dist/chunks/use-roles-DswiNxBk.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"queries-2jdgTwfZ.js","names":[],"sources":["../../src/lib/project-environments.ts","../../src/lib/capabilities.ts","../../src/lib/queries.ts"],"sourcesContent":["import type { ProjectSummary } from '../shared/models';\n\nexport type ProjectEnvironment = ProjectSummary['environments'][number];\nexport type DetailedProjectEnvironment = ProjectEnvironment & {\n details: NonNullable<ProjectEnvironment['details']>;\n};\n\nexport function hasEnvironmentDetails(\n environment: ProjectEnvironment,\n): environment is DetailedProjectEnvironment {\n return environment.details !== null;\n}\n\nexport function isActiveAccessibleEnvironment(\n environment: ProjectEnvironment,\n): environment is ProjectEnvironment & {\n accessible: true;\n details: { archivedAt: null; secretCount: number };\n} {\n return environment.accessible\n && environment.details !== null\n && environment.details.archivedAt === null;\n}\n","import { administers, makesProjects, ownsInstance } 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: the Users and Service accounts pages. */\n canManageGrants: boolean;\n /**\n * Admins and owners whose scope narrows nothing: adding and removing\n * people and service accounts, instance roles, tokens and trust bindings,\n * offboarding reports, the instance's keys.\n */\n runsInstance: boolean;\n /**\n * Owners whose scope narrows nothing: they alone make someone an Owner,\n * and change or remove one, their own role included.\n */\n ownsInstance: 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 ownsInstance: 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 role = 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: administers(role),\n runsInstance: me.runsInstance,\n ownsInstance: ownsInstance({ role, scope: me.scope }),\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({ 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 FetchQueryOptions, type QueryKey } from '@tanstack/react-query';\n\nimport { deriveUiCapabilities } from './capabilities.ts';\nimport { memberRef, statusOf, uiResult } from './coffre.ts';\nimport { isActiveAccessibleEnvironment } from './project-environments.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 is the\n * exception, read fresh on every visit: its whole point is to be current.\n * The chain's verification is read once a visit like the rest, and again\n * after any change made here.\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 personal: (project: string) => ['personal', project],\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 githubRepositories: ['github-repositories'],\n tokenPlan: (member: string, scope: Record<string, string>) => ['token-plan', member, scope],\n identities: ['identities'],\n sessions: ['sessions'],\n apps: ['apps'],\n audit: ['audit'],\n auditKeys: ['audit', 'keys'],\n settings: ['settings'],\n roles: ['roles'],\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\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, tampered, managed, declared, grants }) => ({\n principalType,\n principalId,\n instanceRole,\n scope,\n tampered,\n managed,\n declared,\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 /**\n * The repositories the deployment's GitHub App is installed on, for the\n * Trust dialog's picker; `{ app: null }` without one. Each listing asks\n * GitHub, so it is kept a minute, and not asked again on focus.\n */\n githubRepositories: (client: CoffreClient) =>\n queryOptions({\n queryKey: keys.githubRepositories,\n queryFn: () => client.bindings.repositories(),\n staleTime: 60_000,\n refetchOnWindowFocus: false,\n }),\n\n /**\n * What a service's token would reach, as the server would issue it now,\n * and the sensitive values it would not read (`withheld`); issues\n * nothing. A scope the server refuses plans nothing: issuing says why.\n * Any other failure is one, asked once.\n */\n tokenPlan: (client: CoffreClient, member: string, scope: Record<string, string>) =>\n queryOptions({\n queryKey: keys.tokenPlan(member, scope),\n queryFn: () => client.tokens.preview(member, { label: null, expiresInDays: 1, scope }).catch((failure: unknown) => {\n const status = statusOf(failure);\n if (status !== undefined && status >= 400 && status < 500) return null;\n throw failure;\n }),\n staleTime: 60_000,\n refetchOnWindowFocus: false,\n retry: false,\n }),\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, read or not, 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 /** A project's personal configs, for whoever manages its environments: whose, of what, and their key names. */\n personal: (client: CoffreClient, project: string) =>\n queryOptions({\n queryKey: keys.personal(project),\n queryFn: () => uiResult(() => client.environments.personal(project)),\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 /**\n * The instance's roles and instance roles, as an Owner edited and made\n * them (docs/design/roles.md), and whether the caller edits them. Any\n * member reads them: they are what every grant picker offers.\n */\n roles: (client: CoffreClient) =>\n queryOptions({ queryKey: keys.roles, queryFn: () => uiResult(() => client.roles.list()) }),\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 with each visit, and rendered with the\n * page, the loader's read to carry to the browser: it is not asked again on\n * mount, and not for a filter change or a hover, which `FRESH_MS` covers.\n * It reads what was written since the newest checkpoint, so it takes as\n * long as five minutes of the log, however long the log. It never rejects:\n * a check that could not run is its verdict (`unknown`).\n */\n auditChain: (client: CoffreClient) =>\n queryOptions({ queryKey: [...keys.audit, 'chain'], refetchOnMount: false, 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): 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 return chainResult(await client.audit.verify(), false);\n } catch (error) {\n return chainUnknown(error);\n }\n}\n\n/**\n * A verdict as the page shows it: `whole` when it comes from the walk\n * from the first entry, which someone asked for, not from the newest\n * checkpoint's.\n */\nexport function chainResult(result: Awaited<ReturnType<CoffreClient['audit']['verify']>>, whole: boolean) {\n return result.ok\n ? {\n integrity: 'intact' as const,\n whole,\n through: result.through,\n entries: result.entries,\n // A server older than 0.10.1 checked from the first entry, and reached the head.\n from: result.from ?? 0,\n remaining: result.remaining ?? 0,\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}\n\n/**\n * What the page shows, of the check from the newest checkpoint (`quick`)\n * and the walk from the first entry, once someone ran it (`whole`). A break\n * the walk found stands; otherwise the newer check says how the log is now,\n * broken, partly checked or not checked at all; and only while it found the\n * log whole too does the walk's verdict, which read further back, stand\n * over it.\n *\n * whole broken → whole\n * whole intact, quick intact with 0 remaining → whole\n * whole intact, quick anything else → quick\n */\nexport function shownChain(quick: ChainResult, whole: ChainResult | null): ChainResult {\n if (whole === null || whole.integrity === 'broken') return whole ?? quick;\n return quick.integrity === 'intact' && quick.remaining === 0 && whole.integrity === 'intact' ? whole : quick;\n}\n\n/** Why the log's verdict is not known: closed to the caller, or no answer. */\nexport function chainUnknown(error: unknown) {\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\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 * How a loader reads. `fresh`, a page's own reads: the cached answer within\n * `FRESH_MS`, else the network's, waited for. `cached`, a tab's: its page's\n * layout has read the same, so it takes the cached answer at once, however\n * old, and refetches behind it, and switching tabs never waits on the\n * network. A read the cache lacks is waited for either way.\n */\nexport type Freshness = 'fresh' | 'cached';\n\nfunction read<T, TKey extends QueryKey>(queryClient: QueryClient, options: FetchQueryOptions<T, Error, T, TKey>, freshness: Freshness): Promise<T> {\n return freshness === 'fresh' ? queryClient.fetchQuery(options) : queryClient.ensureQueryData({ ...options, revalidateIfStale: true });\n}\n\n/**\n * Whether a tab may open: from the cache, and where the cache says no, from\n * the network, which a no needs before the tab sends anyone away. A stale\n * no could be an account since added back, or a role since given.\n */\nexport async function tabOpens(opens: (freshness: Freshness) => Promise<boolean>): Promise<boolean> {\n return (await opens('cached')) || opens('fresh');\n}\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, freshness: Freshness = 'fresh'): Promise<Shell> {\n const [auth, me, projects] = await Promise.all([\n read(queryClient, queries.auth(client), freshness),\n read(queryClient, queries.me(client), freshness),\n read(queryClient, queries.projects(client), freshness),\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/**\n * What an environment's page reads: its secrets and, for whoever reads them,\n * the references that read them from elsewhere and the keys it lacks,\n * rendered with them. Where the project tree the shell holds says you read\n * it, all three are asked at once, one round trip; elsewhere the others wait\n * for the secrets, so a refused visit is one refusal in the log, not three.\n */\nexport async function loadEnvironment(queryClient: QueryClient, client: CoffreClient, place: Place) {\n const others = () =>\n Promise.all([\n queryClient.fetchQuery(queries.references(client, `${place.project}/${place.environment}`)),\n queryClient.fetchQuery(queries.missing(client, place)),\n ]);\n const found = projectOf(await queryClient.ensureQueryData(queries.projects(client)), place.project);\n // Neither in an archived project nor archived itself: the API serves neither.\n const here = found.ok && found.project.archivedAt === null\n ? found.project.environments.find((environment) => environment.slug === place.environment)\n : undefined;\n if (here !== undefined && isActiveAccessibleEnvironment(here)) {\n const [secrets] = await Promise.all([queryClient.fetchQuery(queries.secrets(client, place)), others()]);\n return secrets;\n }\n const secrets = await queryClient.fetchQuery(queries.secrets(client, place));\n if (secrets.ok) await others();\n return secrets;\n}\n\n/**\n * What the audit page reads: a page of the log and the verification from\n * the newest checkpoint, asked together and rendered together, so the badge\n * arrives with the page. The verification never fails the load: a check that\n * could not run is its verdict.\n */\nexport async function loadAudit(queryClient: QueryClient, client: CoffreClient, search: AuditSearch) {\n const [entries] = await Promise.all([\n queryClient.fetchQuery(queries.auditEntries(client, search)),\n queryClient.fetchQuery(queries.auditChain(client)),\n ]);\n return entries;\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 queryClient.fetchQuery(queries.roles(client)),\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, freshness: Freshness = 'fresh') {\n const shell = await loadShell(queryClient, client, freshness);\n return read(queryClient, queries.report(client, member, shell.capabilities.runsInstance), freshness);\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, freshness: Freshness = 'fresh') {\n const shell = await loadShell(queryClient, client, freshness);\n return read(queryClient, queries.memberAccess(client, member, listsAccess(shell)), freshness);\n}\n\n/**\n * A user's or service account's page: what every tab but Activity shows,\n * read once by its layout, so its tabs open at once. Who they are, what they\n * hold and, for a service account, how it signs in.\n */\nexport async function loadPrincipal(queryClient: QueryClient, client: CoffreClient, principalType: 'user' | 'service', principalId: string) {\n const member = memberRef(principalType, principalId);\n await Promise.all([\n loadMember(queryClient, client, member),\n principalType === 'service' ? loadSignIn(queryClient, client, member) : loadAccess(queryClient, client, member),\n ]);\n}\n\n/**\n * A service account's Sign-in tab: its bearer tokens and trust bindings, as\n * far as its page shows them (`signInWays`), which it returns: null where it\n * shows neither.\n */\nexport async function loadSignIn(queryClient: QueryClient, client: CoffreClient, member: string, freshness: Freshness = 'fresh') {\n const [shell, access] = await Promise.all([\n loadShell(queryClient, client, freshness),\n loadAccess(queryClient, client, member, freshness),\n ]);\n const ways = signInWays(shell, access);\n if (ways !== null) {\n await Promise.all([\n read(queryClient, queries.credentials(client, member, ways.tokens), freshness),\n read(queryClient, queries.bindings(client, member, ways.workloads), freshness),\n ]);\n }\n return ways;\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 /**\n * A project or environment made, renamed or archived: the tree, where you\n * hold access, and the personal configs listed of it, which go with it.\n */\n places: (): QueryKey[] => [keys.projects, keys.me, ['personal']],\n /** Secrets written, renamed, restored or archived: the environment, the counts, and the personal configs' key names. */\n secrets: (place: Place): QueryKey[] => [keys.secrets(place), keys.projects, ['references'], ['missing'], ['personal']],\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 /**\n * Someone let in: the directory, and whatever was read of them before\n * they were there, which said there was no such member: a new service\n * account's row asks how it signs in as soon as it shows.\n */\n admission: (member: string): QueryKey[] => [\n keys.directory,\n keys.report(member),\n keys.memberAccess(member),\n keys.credentials(member),\n keys.bindings(member),\n ],\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 /**\n * A role edited, made, reset or deleted, or an environment protected:\n * what everyone holds may change, so the roles, what you hold, and every\n * grant and environment read with what it holds.\n */\n roles: (): QueryKey[] => [keys.roles, keys.me, keys.projects, ['grants'], ['member-access'], ['secrets']],\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":";;;;AAOA,SAAgB,sBACd,aAC2C;CAC3C,OAAO,YAAY,YAAY;AACjC;AAEA,SAAgB,8BACd,aAIA;CACA,OAAO,YAAY,cACd,YAAY,YAAY,QACxB,YAAY,QAAQ,eAAe;AAC1C;;;ACaA,IAAM,OAAuB;CAC3B,iBAAiB;CACjB,cAAc;CACd,cAAc;CACd,gBAAgB;CAChB,cAAc;CACd,kBAAkB;AACpB;AAEA,SAAgB,qBACd,IACA,UACgB;CAChB,IAAI,OAAO,MAAM,OAAO;CAExB,MAAM,OAAO,GAAG;CAEhB,OAAO;EAIL,iBAAiB,YAAY,IAAI;EACjC,cAAc,GAAG;EACjB,cAAc,aAAa;GAAE;GAAM,OAAO,GAAG;EAAM,CAAC;EACpD,gBAAgB,GAAG;EACnB,cAAc,GAAG;EAGjB,kBAAkB,cAAc;GAAE;GAAM,OAAO,GAAG;GAAO,Q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oC;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-DswIpPqY.js","names":[],"sources":["../../src/components/role-field.tsx"],"sourcesContent":["import { useId, useState } from 'react';\nimport { INSTANCE_ROLE_NAMES, type Filter, type InstanceRole, type Scope } from '@coffre/core/access';\nimport type { RoleVars } from '../lib/changes';\nimport { useShell } from '../lib/use-shell';\nimport { useRoles } from '../lib/use-roles';\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. Owner is offered only\n * to an Owner of the whole instance, who alone makes one.\n */\nexport function RoleField({ value, onChange }: { value: RoleVars; onChange: (value: RoleVars) => void }) {\n const { role, scope } = value;\n const owners = useShell().capabilities.ownsInstance;\n // As the instance defines them: an Owner may have renamed or redescribed one.\n const { instanceRoles } = useRoles();\n const shown = (name: InstanceRole) => instanceRoles.find((each) => each.id === name);\n return (\n <>\n <label className=\"field\">\n <span className=\"label\">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.filter((name) => owners || name !== 'owner').map((name) => (\n <option key={name} value={name}>\n {shown(name)?.name ?? name}\n </option>\n ))}\n </select>\n <span className=\"hint\">\n Default permissions: {shown(role)?.description} Project grants add more.\n {!owners && ' Only an Owner makes someone an Owner.'}\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":";;;;;;;;;;;;;;;AAeA,SAAgB,UAAU,EAAE,OAAO,YAAsE;CACvG,MAAM,EAAE,MAAM,UAAU;CACxB,MAAM,SAAS,SAAS,CAAC,CAAC,aAAa;CAEvC,MAAM,EAAE,kBAAkB,SAAS;CACnC,MAAM,SAAS,SAAuB,cAAc,MAAM,SAAS,KAAK,OAAO,IAAI;CACnF,OACE,qBAAA,YAAA,EAAA,UAAA,CACE,qBAA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
- {"version":3,"file":"use-roles-DswiNxBk.js","names":[],"sources":["../../src/lib/roles.ts","../../src/lib/use-roles.ts"],"sourcesContent":["import type { ImpactLine, RolesView, RoleView } from '@coffre/client';\nimport {\n assignableToEnvironment,\n FIXED_ROLES,\n INSTANCE_ROLES,\n PERMISSIONS,\n PROJECT_ONLY_PERMISSIONS,\n ROLES,\n type Permission,\n type RoleDefinition,\n} from '@coffre/core/access';\n\n/**\n * The instance's roles as the pages offer and name them (docs/design/roles.md):\n * each in two columns, what it holds in an environment and what a person\n * holds of it in a protected one. The policy is the vault's, read from\n * `GET /api/roles`; until it is, the roles as they ship stand in.\n */\n\n/** Every permission in words, in the catalogue's order, and what a short label leaves out. */\nexport const PERMISSION_WORDS: Record<Permission, { label: string; note?: string; verb: string }> = {\n 'secret.read': { label: 'Read values', verb: 'read values' },\n 'secret.use': { label: 'Use values', note: 'placeholders, the proxy', verb: 'use values' },\n 'secret.write': { label: 'Write values', verb: 'write values' },\n 'secret.archive': { label: 'Retire values', verb: 'retire values' },\n 'audit.read': { label: 'Read the log', verb: 'read the log' },\n 'environment.manage': { label: 'Manage environments', verb: 'manage environments' },\n 'grant.manage': { label: 'Manage access', verb: 'manage access' },\n 'project.manage': { label: 'Manage the project', verb: 'manage the project' },\n};\n\n/** The rows of a role's grid: secrets first, as a role is read, then the log, then what only a project holds. */\nexport const GRID_PERMISSIONS: readonly Permission[] = [\n 'secret.read',\n 'secret.use',\n 'secret.write',\n 'secret.archive',\n 'audit.read',\n 'environment.manage',\n 'grant.manage',\n 'project.manage',\n];\n\nexport function projectWide(permission: Permission): boolean {\n return PROJECT_ONLY_PERMISSIONS.includes(permission);\n}\n\n/** A role's two columns, as the grid edits them. */\nexport type Columns = { permissions: Permission[]; protected: Permission[] };\nexport type Column = 'normal' | 'protected';\n\n/**\n * One checkbox of the grid flipped, and the rules the vault holds a role to\n * kept true by the boxes it takes along (`definitionProblem`):\n *\n * checking Read checks Use unchecking Use unchecks Read\n * checking a protected box checks its unchecking a normal box unchecks\n * normal one its protected one\n *\n * A project-wide permission has no protected box: flipping one is no change.\n */\nexport function toggle(columns: Pick<RoleDefinition, 'permissions' | 'protected'>, permission: Permission, column: Column, on: boolean): Columns {\n if (column === 'protected' && projectWide(permission)) return ordered(columns);\n const normal = new Set(columns.permissions);\n const guarded = new Set(columns.protected);\n // Reading takes using; giving up using gives up reading.\n const along: Permission[] = on ? (permission === 'secret.read' ? ['secret.use'] : []) : permission === 'secret.use' ? ['secret.read'] : [];\n for (const each of [permission, ...along]) {\n if (on) {\n normal.add(each);\n if (column === 'protected') guarded.add(each);\n } else {\n guarded.delete(each);\n if (column === 'normal') normal.delete(each);\n }\n }\n return ordered({ permissions: [...normal], protected: [...guarded] });\n}\n\n/** Each column in catalogue order, as the vault keeps it, so that comparing two says whether they differ. */\nexport function ordered(columns: Pick<RoleDefinition, 'permissions' | 'protected'>): Columns {\n return {\n permissions: PERMISSIONS.filter((permission) => columns.permissions.includes(permission)),\n protected: PERMISSIONS.filter((permission) => columns.protected.includes(permission)),\n };\n}\n\n/** Whether two definitions hold the same, named and described the same. */\nexport function sameDefinition(a: RoleDefinition, b: RoleDefinition): boolean {\n const [x, y] = [ordered(a), ordered(b)];\n return a.name.trim() === b.name.trim() && a.description === b.description\n && x.permissions.join() === y.permissions.join() && x.protected.join() === y.protected.join();\n}\n\n/** A column in words, for a role's row: \"read, use and write values\", or \"nothing\". */\nexport function columnInWords(permissions: readonly Permission[]): string {\n const values = ['secret.read', 'secret.use', 'secret.write', 'secret.archive'] as const;\n const held = values.filter((permission) => permissions.includes(permission));\n const verbs = { 'secret.read': 'read', 'secret.use': 'use', 'secret.write': 'write', 'secret.archive': 'retire' } as const;\n const parts = [\n ...(held.length === 0 ? [] : [`${list(held.map((permission) => verbs[permission]))} values`]),\n ...GRID_PERMISSIONS.filter((permission) => !(values as readonly string[]).includes(permission) && permissions.includes(permission)).map((permission) => PERMISSION_WORDS[permission].verb),\n ];\n return parts.length === 0 ? 'nothing' : list(parts);\n}\n\nfunction list(words: readonly string[]): string {\n return words.length <= 1 ? (words[0] ?? '') : `${words.slice(0, -1).join(', ')} and ${words.at(-1)}`;\n}\n\n/** A role's id, made from its name as it is typed: \"Release manager\" is `release-manager`. */\nexport function roleIdFrom(name: string): string {\n return name\n .toLowerCase()\n .normalize('NFKD')\n .replace(/[\\u0300-\\u036f]/g, '')\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^[^a-z]+/, '')\n .replace(/-+$/, '')\n .slice(0, 32)\n .replace(/-+$/, '');\n}\n\n/** What is wrong with a new role's id, or null: its shape, and not one the instance has. */\nexport function roleIdProblem(id: string, taken: readonly string[]): string | null {\n if (id === '') return 'A role needs an id.';\n if (!/^[a-z0-9-]+$/.test(id)) return 'An id is lowercase letters, digits and dashes.';\n if (!/^[a-z]/.test(id)) return 'An id starts with a letter.';\n if (id.length < 2 || id.length > 32) return 'An id is 2 to 32 characters.';\n if (taken.includes(id)) return `There is a role ${id} already.`;\n return null;\n}\n\n/** The roles as they ship: what the pages offer and name until the instance's are read, or where they cannot be. */\nexport const SHIPPED_ROLES: RolesView = {\n roles: Object.entries(ROLES).map(([id, definition]) => shippedView(id, definition, FIXED_ROLES.roles.includes(id), assignableToEnvironment(id))),\n instanceRoles: Object.entries(INSTANCE_ROLES).map(([id, definition]) =>\n shippedView(id, definition, (FIXED_ROLES.instanceRoles as readonly string[]).includes(id), false)),\n editable: false,\n};\n\nfunction shippedView(id: string, definition: RoleDefinition, fixed: boolean, assignable: boolean): RoleView {\n const shipped = { name: definition.name, description: definition.description, ...ordered(definition) };\n return { id, ...shipped, builtin: true, edited: false, fixed, default: shipped, assignableToEnvironment: assignable, grants: 0 };\n}\n\n/** A role's name by its id, as the instance defines it; one it does not know, as itself. */\nexport function roleNameOf(roles: readonly Pick<RoleView, 'id' | 'name'>[], id: string): string {\n return roles.find((role) => role.id === id)?.name ?? id;\n}\n\n/**\n * One line of a change's impact, in words, from the dry run's count:\n *\n * widens secret.read, protected, 6 people, 4 environments\n * 6 people can now read values in 4 protected environments\n * narrows secret.write, 2 people, 1 environment, [\"ada@… on market/dev\", …]\n * 2 people can no longer write values in market/dev\n *\n * One place is named, from its examples; more are counted.\n */\nexport function impactInWords(line: ImpactLine): string {\n const people = [\n line.people > 0 ? (line.people === 1 ? '1 person' : `${line.people} people`) : null,\n line.services > 0 ? (line.services === 1 ? '1 service account' : `${line.services} service accounts`) : null,\n ].filter((part) => part !== null).join(' and ');\n const can = line.change === 'widens' ? 'can now' : 'can no longer';\n const wide = projectWide(line.permission);\n const count = wide ? line.projects : line.environments;\n const only = count === 1 ? placeOf(line.examples[0]) : null;\n const where = only !== null\n ? `${wide ? 'on' : 'in'} ${only}${line.protected ? ', protected' : ''}`\n : `${wide ? 'on' : 'in'} ${count} ${line.protected ? 'protected ' : ''}${wide ? (count === 1 ? 'project' : 'projects') : count === 1 ? 'environment' : 'environments'}`;\n return `${people} ${can} ${PERMISSION_WORDS[line.permission].verb} ${where}`;\n}\n\n/** The place of an impact's example, `ada@acme.example on market/prod`: `market/prod`. */\nfunction placeOf(example: string | undefined): string | null {\n const at = example?.lastIndexOf(' on ') ?? -1;\n return example === undefined || at < 0 ? null : example.slice(at + ' on '.length);\n}\n\n/** Who an impact line reaches, for its note: `ada@acme.example on market/prod, bo@acme.example on market/prod`. */\nexport function impactExamples(line: ImpactLine): string | null {\n return line.examples.length === 0 ? null : `${line.examples.join(', ')}${line.people + line.services > line.examples.length ? ', …' : ''}`;\n}\n\n/**\n * What protecting an environment does, said by a role whose two columns\n * differ, Developer first: \"Developers use and write values, and read\n * none\". Null where no role's do, so protecting changes nothing.\n */\nexport function protectionInWords(roles: readonly Pick<RoleView, 'id' | 'name' | 'permissions' | 'protected'>[]): string | null {\n const differs = (role: Pick<RoleView, 'permissions' | 'protected'>) =>\n role.permissions.some((permission) => !projectWide(permission) && !role.protected.includes(permission));\n const role = roles.find((each) => each.id === 'developer' && differs(each)) ?? roles.find(differs);\n if (role === undefined) return null;\n const held = columnInWords(role.protected);\n const loses = role.permissions.includes('secret.read') && !role.protected.includes('secret.read') && role.protected.length > 0;\n return `${role.name}s ${held === 'nothing' ? 'hold nothing' : held}${loses ? ', and read none' : ''}`;\n}\n","import type { RolesView } from '@coffre/client';\nimport { useQuery } from '@tanstack/react-query';\n\nimport { useCoffre } from './coffre';\nimport { queries } from './queries';\nimport { SHIPPED_ROLES } from './roles';\n\n/**\n * The instance's roles, for a picker or a name: as an Owner edited and made\n * them once read, and as they ship until then, or where they cannot be read,\n * so a picker never waits for them. The server decides every grant: a role\n * shown here a moment stale is one it refuses, never one it gives.\n */\nexport function useRoles(): RolesView {\n const { data } = useQuery({ ...queries.roles(useCoffre()), placeholderData: { ok: true as const, ...SHIPPED_ROLES } });\n return data?.ok === true ? data : SHIPPED_ROLES;\n}\n"],"mappings":";;;;;;;;;;;;AAoBA,IAAa,mBAAuF;CAClG,eAAe;EAAE,OAAO;EAAe,MAAM;CAAc;CAC3D,cAAc;EAAE,OAAO;EAAc,MAAM;EAA2B,MAAM;CAAa;CACzF,gBAAgB;EAAE,OAAO;EAAgB,MAAM;CAAe;CAC9D,kBAAkB;EAAE,OAAO;EAAiB,MAAM;CAAgB;CAClE,cAAc;EAAE,OAAO;EAAgB,MAAM;CAAe;CAC5D,sBAAsB;EAAE,OAAO;EAAuB,MAAM;CAAsB;CAClF,gBAAgB;EAAE,OAAO;EAAiB,MAAM;CAAgB;CAChE,kBAAkB;EAAE,OAAO;EAAsB,MAAM;CAAqB;AAC9E;;AAGA,IAAa,mBAA0C;CACrD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAgB,YAAY,YAAiC;CAC3D,OAAO,yBAAyB,SAAS,UAAU;AACrD;;;;;;;;;;;AAgBA,SAAgB,OAAO,SAA4D,YAAwB,QAAgB,IAAsB;CAC/I,IAAI,WAAW,eAAe,YAAY,UAAU,GAAG,OAAO,QAAQ,OAAO;CAC7E,MAAM,SAAS,IAAI,IAAI,QAAQ,WAAW;CAC1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