@coffre/ui 0.10.0 → 0.10.2

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 (73) hide show
  1. package/dist/chunks/{audit-sentence-Bjhg00cn.js → audit-sentence-CtO2oJ4E.js} +7 -3
  2. package/dist/chunks/{audit-sentence-Bjhg00cn.js.map → audit-sentence-CtO2oJ4E.js.map} +1 -1
  3. package/dist/chunks/{connected-apps-CZI7xxUq.js → connected-apps-D48SFJsG.js} +4 -4
  4. package/dist/chunks/{connected-apps-CZI7xxUq.js.map → connected-apps-D48SFJsG.js.map} +1 -1
  5. package/dist/chunks/{delete-place-D3UQGl3b.js → delete-place-Cg_M6rAq.js} +4 -4
  6. package/dist/chunks/{delete-place-D3UQGl3b.js.map → delete-place-Cg_M6rAq.js.map} +1 -1
  7. package/dist/chunks/{directory-CyHmxYP-.js → directory-_LTgdiIM.js} +8 -8
  8. package/dist/chunks/{directory-CyHmxYP-.js.map → directory-_LTgdiIM.js.map} +1 -1
  9. package/dist/chunks/{folders-Dw240WMJ.js → folders-D3A1NGpt.js} +2 -2
  10. package/dist/chunks/{folders-Dw240WMJ.js.map → folders-D3A1NGpt.js.map} +1 -1
  11. package/dist/chunks/{grants-CEIdNqJU.js → grants-CNM913EY.js} +5 -5
  12. package/dist/chunks/{grants-CEIdNqJU.js.map → grants-CNM913EY.js.map} +1 -1
  13. package/dist/chunks/{multi-combobox-CsIXihuc.js → multi-combobox-B0JzP1QN.js} +2 -2
  14. package/dist/chunks/{multi-combobox-CsIXihuc.js.map → multi-combobox-B0JzP1QN.js.map} +1 -1
  15. package/dist/chunks/{offboarding-CvGgTmHi.js → offboarding-BeaNM3sf.js} +3 -3
  16. package/dist/chunks/{offboarding-CvGgTmHi.js.map → offboarding-BeaNM3sf.js.map} +1 -1
  17. package/dist/chunks/{personal-tokens-BX97oX4a.js → personal-tokens-KsXajpx4.js} +4 -4
  18. package/dist/chunks/{personal-tokens-BX97oX4a.js.map → personal-tokens-KsXajpx4.js.map} +1 -1
  19. package/dist/chunks/{principal-page-Bp2O8kIW.js → principal-page-C0U4T6le.js} +13 -13
  20. package/dist/chunks/{principal-page-Bp2O8kIW.js.map → principal-page-C0U4T6le.js.map} +1 -1
  21. package/dist/chunks/{project-page-CUXV4FDR.js → project-page-CYZ_MkfX.js} +2 -2
  22. package/dist/chunks/{project-page-CUXV4FDR.js.map → project-page-CYZ_MkfX.js.map} +1 -1
  23. package/dist/chunks/{protected-YYW3U-Sq.js → protected-BL_DsZO6.js} +2 -2
  24. package/dist/chunks/{protected-YYW3U-Sq.js.map → protected-BL_DsZO6.js.map} +1 -1
  25. package/dist/chunks/{queries-DEOPOpsT.js → queries-Danu0o75.js} +73 -29
  26. package/dist/chunks/queries-Danu0o75.js.map +1 -0
  27. package/dist/chunks/{references-DsXkt064.js → references-BK2aPXae.js} +4 -4
  28. package/dist/chunks/{references-DsXkt064.js.map → references-BK2aPXae.js.map} +1 -1
  29. package/dist/chunks/{role-field-CCUeZd1a.js → role-field-DIJiRz9B.js} +3 -3
  30. package/dist/chunks/{role-field-CCUeZd1a.js.map → role-field-DIJiRz9B.js.map} +1 -1
  31. package/dist/chunks/{row-state-BsIHspy4.js → row-state-xtRGFnDc.js} +2 -2
  32. package/dist/chunks/{row-state-BsIHspy4.js.map → row-state-xtRGFnDc.js.map} +1 -1
  33. package/dist/chunks/{theme-3b4DnCow.js → theme-Ck45wzWB.js} +2 -2
  34. package/dist/chunks/{theme-3b4DnCow.js.map → theme-Ck45wzWB.js.map} +1 -1
  35. package/dist/chunks/{ui-2kwXXfrX.js → ui-D-blFWfx.js} +29 -5
  36. package/dist/chunks/{ui-2kwXXfrX.js.map → ui-D-blFWfx.js.map} +1 -1
  37. package/dist/chunks/{use-action-COW-XFw8.js → use-action-BafZVwux.js} +2 -2
  38. package/dist/chunks/{use-action-COW-XFw8.js.map → use-action-BafZVwux.js.map} +1 -1
  39. package/dist/chunks/{use-change-hfqE7baE.js → use-change-DhV6i_Ge.js} +3 -3
  40. package/dist/chunks/{use-change-hfqE7baE.js.map → use-change-DhV6i_Ge.js.map} +1 -1
  41. package/dist/chunks/{use-roles-C_Tj5wBH.js → use-roles-Daje0ikO.js} +2 -2
  42. package/dist/chunks/{use-roles-C_Tj5wBH.js.map → use-roles-Daje0ikO.js.map} +1 -1
  43. package/dist/chunks/{use-shell-DBLG80kk.js → use-shell-BX9mzfaL.js} +2 -2
  44. package/dist/chunks/{use-shell-DBLG80kk.js.map → use-shell-BX9mzfaL.js.map} +1 -1
  45. package/dist/index.js +6 -6
  46. package/dist/index.js.map +1 -1
  47. package/dist/pages/account.js +9 -9
  48. package/dist/pages/approval.js +1 -1
  49. package/dist/pages/audit.js +96 -34
  50. package/dist/pages/audit.js.map +1 -1
  51. package/dist/pages/device-login.js +1 -1
  52. package/dist/pages/environment.js +10 -10
  53. package/dist/pages/login.js +2 -2
  54. package/dist/pages/oauth-authorize.js +1 -1
  55. package/dist/pages/project-access.js +9 -9
  56. package/dist/pages/project-environments.js +11 -11
  57. package/dist/pages/project-settings.js +7 -7
  58. package/dist/pages/project.js +2 -2
  59. package/dist/pages/projects.js +7 -7
  60. package/dist/pages/service-account.js +9 -9
  61. package/dist/pages/service-accounts.js +4 -4
  62. package/dist/pages/settings.js +6 -6
  63. package/dist/pages/unregistered.js +1 -1
  64. package/dist/pages/user.js +5 -5
  65. package/dist/pages/users.js +4 -4
  66. package/package.json +3 -3
  67. package/src/components/ui.tsx +25 -2
  68. package/src/lib/audit-sentences.ts +6 -2
  69. package/src/lib/queries.ts +81 -29
  70. package/src/options.ts +2 -3
  71. package/src/pages/audit.tsx +99 -26
  72. package/src/parity.ts +1 -1
  73. package/dist/chunks/queries-DEOPOpsT.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"principal-page-Bp2O8kIW.js","names":[],"sources":["../../src/components/actions-log.tsx","../../src/lib/service-setup.ts","../../src/lib/access-plan.ts","../../src/components/expiry-field.tsx","../../src/components/principal-page.tsx"],"sourcesContent":["import { useInfiniteQuery } from '@tanstack/react-query';\nimport { uiResult, useCoffre } from '../lib/coffre';\nimport { keys } from '../lib/queries';\nimport { describe, lines } from '../lib/audit-sentences';\nimport { Sentence } from './audit-sentence';\nimport { EmptyState, Notice, Spinner, Timestamp } from './ui';\nimport { Activity, Clock, ShieldCheck, SlashCircle } from './icons';\n\nconst PAGE_SIZE = 50;\n\n/**\n * Everything one member did, newest first, from the audit log: the same\n * entries `coffre audit --actor` lists, said as the audit page says them.\n * Older pages come on request.\n */\nexport function ActionsLog({ member }: { member: string }) {\n const client = useCoffre();\n const log = useInfiniteQuery({\n queryKey: [...keys.audit, 'actor', member],\n staleTime: 0,\n initialPageParam: undefined as number | undefined,\n queryFn: ({ pageParam }) =>\n uiResult(() => client.audit.list({ actor: member, limit: PAGE_SIZE, before: pageParam })),\n // A page lists fewer entries where they name many secrets: `more` says whether older ones follow.\n getNextPageParam: (page) =>\n page.ok && page.more && page.entries.length > 0 ? page.entries.at(-1)!.seq : undefined,\n });\n\n if (log.isPending) {\n return (\n <p className=\"hint\">\n <Spinner size={13} /> Reading the log…\n </p>\n );\n }\n const failed = log.data?.pages.find((page) => !page.ok);\n if (failed !== undefined && !failed.ok) return <Notice tone=\"bad\">{failed.error}</Notice>;\n const entries = (log.data?.pages ?? []).flatMap((page) => (page.ok ? page.entries : []));\n const shown = lines(entries);\n\n return (\n <>\n <section className=\"card\" aria-label=\"Actions log\">\n {shown.length === 0 ? (\n <EmptyState title=\"Nothing yet\" />\n ) : (\n <div className=\"dt-wrap\">\n <table className=\"dt actions-log stacks stacks-inline\">\n <thead>\n <tr>\n <th className=\"col-shrink\">\n <span className=\"th\">\n <Clock size={14} />\n When\n </span>\n </th>\n <th>\n <span className=\"th\">\n <Activity size={14} />\n Action\n </span>\n </th>\n <th className=\"col-shrink\">\n <span className=\"th\">\n <ShieldCheck size={14} />\n Outcome\n </span>\n </th>\n </tr>\n </thead>\n <tbody>\n {shown.map((batch) => {\n const lead = batch[0]!;\n const sentence = describe(batch);\n return (\n <tr key={lead.seq} className={sentence.refused ? 'is-denied' : undefined}>\n <td className=\"nowrap cell-muted\" title={lead.occurredAt}>\n <Timestamp iso={lead.occurredAt} display=\"relative\" />\n </td>\n <td className=\"cell-sentence\">\n <span className=\"sentence\">\n <Sentence parts={sentence.parts} />\n </span>\n </td>\n <td className=\"nowrap\" data-label=\"Outcome\">\n {sentence.refused ? (\n <span className=\"decided decided-refused\">\n <SlashCircle size={13} />\n Refused\n </span>\n ) : (\n <span className=\"cell-muted\">Allowed</span>\n )}\n </td>\n </tr>\n );\n })}\n </tbody>\n </table>\n </div>\n )}\n </section>\n {log.hasNextPage && (\n <div className=\"table-actions\">\n <button\n type=\"button\"\n className=\"btn\"\n disabled={log.isFetchingNextPage}\n onClick={() => void log.fetchNextPage()}\n >\n {log.isFetchingNextPage && <Spinner />}\n Show older\n </button>\n </div>\n )}\n </>\n );\n}\n","import { inScope, PROJECT_ONLY_PERMISSIONS, type Permission, type Role, type Scope } from '@coffre/core/access';\nimport type { RoleView } from '@coffre/client';\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 /** The instance's roles, as the policy defines them (`useRoles`). */\n roles: readonly Pick<RoleView, 'id' | 'permissions' | 'assignableToEnvironment'>[];\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. An\n * environment takes only the roles that hold nothing project-wide. A\n * project's role reaches its protected environments too, where the service\n * holds the role's normal column and you your protected one: you hold that\n * normal column there as well, or give none.\n *\n * a Developer of every dev, at market/dev viewer, contributor, developer\n * the same, at market none: a project takes holding all of it\n * a Developer of market, prod protected contributor: viewer and developer read prod, which you only use\n */\nexport function givable(holder: Holder, project: ProjectSummary, environment: string | null): Role[] {\n const heldIn = (slug: string) => holder.environments.find((entry) => entry.project === project.slug && entry.environment === slug)?.permissions ?? [];\n const held = environment === null ? project.permissions : heldIn(environment);\n const roles = holder.roles.filter((role) => environment === null || role.assignableToEnvironment);\n if (held.includes('grant.manage')) return roles.map((role) => role.id);\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 const reached = environment === null ? project.environments.filter((candidate) => candidate.protected && !candidate.personal).map((candidate) => heldIn(candidate.slug)) : [];\n const gives = (permission: Permission) =>\n held.includes(permission) && (PROJECT_ONLY_PERMISSIONS.includes(permission) || reached.every((there) => there.includes(permission)));\n // A role that holds nothing is given where its giver manages access alone, as the server decides (`givesService`).\n return roles.filter((role) => role.permissions.length > 0 && role.permissions.every(gives)).map((role) => role.id);\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 { assignableToEnvironment, type Role } from '@coffre/core/access';\n\nimport type { GrantRow } from '../shared/models';\n\n/** A role on one environment, and when it ends: an ISO instant, or null for never. */\nexport type EnvironmentAccess = { role: Role; expiresAt: string | null };\n\n/**\n * What one project is set to in a principal's access editor: nothing, one\n * role on the whole project, or a role 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 -- read everywhere plus\n * write on one environment, or a grant on an environment the editor does not\n * list. The editor shows them and leaves them alone unless another setting\n * is picked.\n */\nexport type AccessPlan = {\n level: 'none' | 'project' | 'env' | 'custom';\n /** The role on the whole project, at level `project`. */\n role: Role | null;\n /** When the project-wide role 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\nconst NONE: AccessPlan = { level: 'none', role: null, expiresAt: null, environments: {} };\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 NONE;\n\n const [only] = grants;\n if (grants.length === 1 && only.environmentSlug === null) {\n return { level: 'project', role: 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 (slug === null || !environments.includes(slug) || Object.hasOwn(perEnvironment, slug)) {\n return { ...NONE, level: 'custom' };\n }\n perEnvironment[slug] = { role: grant.role, expiresAt: grant.expiresAt };\n }\n return { level: 'env', role: null, expiresAt: null, environments: perEnvironment };\n}\n\n/**\n * Switch a plan's level, with its role for `project`. Going from one role\n * on the whole project to per environment starts every environment at that\n * role and expiry, where an environment takes it, so the switch alone keeps\n * the same reach.\n */\nexport function withLevel(\n plan: AccessPlan,\n level: AccessPlan['level'],\n environments: readonly string[],\n { role = null, assignable = (each) => assignableToEnvironment(each) }: { role?: Role | null; assignable?: (role: Role) => boolean } = {},\n): AccessPlan {\n if (\n level === 'env' &&\n plan.level === 'project' &&\n plan.role !== null &&\n assignable(plan.role) &&\n Object.keys(plan.environments).length === 0\n ) {\n const access = { role: plan.role, expiresAt: plan.expiresAt };\n return {\n ...plan,\n level,\n role: null,\n environments: Object.fromEntries(environments.map((slug) => [slug, access])),\n };\n }\n return { ...plan, level, role: level === 'project' ? role : null };\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 'project':\n return plan.role === null ? [] : [{ role: plan.role, 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 : { 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 { scopeInWords, unscoped, type Role } from '@coffre/core/access';\nimport { useShell } from '../lib/use-shell';\nimport { toast } from 'sonner';\nimport { memberRef, useCoffre } from '../lib/coffre';\nimport { directoryList, revokeMemberToken } from '../lib/changes';\nimport { affects, hasAppsTab, keys, listsAccess, managedProjects, queries, signInWays } from '../lib/queries';\nimport { useChangeStatus } from '../lib/use-change';\nimport { useMounted } from '../lib/mounted';\nimport { ItemFailure } from './row-state';\nimport { useAction } from '../lib/use-action';\nimport { accessRows, projectAccessLabel, type ProjectAccess } from '../lib/project-access';\nimport { givable, serviceProjects } from '../lib/service-setup';\nimport { roleNameOf } from '../lib/roles';\nimport { useRoles } from '../lib/use-roles';\nimport {\n accessChanges,\n accessPatch,\n dateFromExpiry,\n environmentAccess,\n expiryFromDate,\n planFromGrants,\n withEnvironment,\n withLevel,\n type AccessChange,\n type AccessPlan,\n} from '../lib/access-plan';\nimport type { MemberAccess, TokenRow } from '@coffre/client';\nimport type { DirectoryPrincipal, ProjectSummary } from '../shared/models';\nimport { ClosedDoor, PageHeader } from './page';\nimport { EmptyState, ErrorLine, Modal, Notice, Spinner } from './ui';\nimport { GrantRowView, GrantsTable } from './grants';\nimport { ExpiryField } from './expiry-field';\nimport { InstanceRole, KIND, PrincipalActions } from './directory';\nimport { PrincipalReportCards, RemovedNotice } from './offboarding';\nimport { PersonalTokensCard } from './personal-tokens';\nimport { PrincipalAvatar } from './principal';\nimport { Tile } from './tile';\nimport { Activity, Archive, Clock, Folder, Key, Link as LinkIcon, Pencil, Users, X } from './icons';\nimport { PageTabs } from './tabs';\n\ntype PrincipalType = DirectoryPrincipal['principalType'];\n\n/** The roles you may give at a project, or one of its environments: any where you manage access (`givable`). */\ntype Offers = (project: ProjectSummary, environment: string | null) => readonly Role[];\n\n/** Who a user or service account is to the instance, as an owner reads it; null for anyone else. */\nfunction useReport(principalType: PrincipalType, principalId: string) {\n const { capabilities } = useShell();\n return useSuspenseQuery(queries.report(useCoffre(), memberRef(principalType, principalId), capabilities.runsInstance)).data;\n}\n\n/**\n * What `loadAccess` read in one request: their role and scope, and, for each\n * project where you manage access, the grants they hold there. For a\n * service account you manage, each project where you may give it\n * something, and what (`offers`).\n */\nfunction useMemberAccess(principalType: PrincipalType, principalId: string): {\n access: MemberAccess | null;\n error: string | null;\n projects: ProjectAccess[];\n offers: Offers;\n} {\n const shell = useShell();\n const { roles } = useRoles();\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 holder = { ...shell, roles };\n const listed = yours ? serviceProjects(holder) : managedProjects(shell.projects);\n return {\n access,\n error,\n offers: yours\n ? (project, environment) => givable(holder, project, environment)\n : (_project, environment) => roles.filter((role) => environment === null || role.assignableToEnvironment).map((role) => role.id),\n projects: listed.map((project) => ({\n project,\n grants: (access?.grants ?? []).filter((grant) => grant.project === project.slug).map((grant) => ({\n id: grant.id,\n principalType,\n principalId,\n role: grant.role,\n roleName: grant.roleName,\n permissions: grant.permissions,\n scope: grant.environment === null ? 'project' : 'environment',\n environmentSlug: grant.environment,\n expiresAt: grant.expiresAt,\n })),\n grantsError: error,\n })),\n };\n}\n\n/**\n * A user's or service account's page: who it is, its menu, and its tabs,\n * each a page of its own under this one. Access is a user's first tab; a\n * service account's is how it signs in, while it shows one. A tab the\n * deployment left out is not offered.\n */\nexport function PrincipalLayout({ principalType, principalId }: { principalType: PrincipalType; principalId: string }) {\n const shell = useShell();\n const mounted = useMounted();\n const { capabilities } = shell;\n const report = useReport(principalType, principalId);\n // A service account you manage, though you do not run the instance: what it holds, from its access.\n const { data: held } = useSuspenseQuery(queries.memberAccess(useCoffre(), memberRef(principalType, principalId), listsAccess(shell)));\n const yours = principalType === 'service' && held?.ok === true && held.managed;\n // A role change or removal made from this page's menu, refused.\n const { status, dismiss } = useChangeStatus(directoryList.queryKey);\n const change = status(memberRef(principalType, principalId));\n const kind = KIND[principalType];\n const people = principalType === 'user';\n const found = report?.ok === true ? report.report : null;\n const removed = found?.status === 'removed';\n const entry =\n found !== null && !removed\n ? {\n principalType,\n principalId,\n instanceRole: found.instanceRole,\n scope: found.scope,\n tampered: found.status === 'tampered',\n managed: principalType === 'service',\n declared: found.declared,\n }\n : yours\n ? { principalType, principalId, instanceRole: 'member' as const, scope: null, tampered: false, managed: true }\n : undefined;\n\n // Owners get a report about anyone ever registered, removed or not, so a\n // miss there means there is no such user. Everyone else only reaches this\n // page through projects they manage, or a service account they manage.\n const unknown = report?.ok === true && found === null;\n if (unknown || (report === null && managedProjects(shell.projects).length === 0 && !yours)) {\n return (\n <ClosedDoor\n icon={people ? <Users size={18} /> : <Key size={18} />}\n label={<span className=\"mono\">{people ? principalId : `service:${principalId}`}</span>}\n title={people ? 'No such user for you' : 'No such service account for you'}\n actions={\n <Link className=\"btn\" to={people ? '/users' : '/service-accounts'}>\n All {people ? 'users' : 'service accounts'}\n </Link>\n }\n >\n {report === null\n ? `A ${kind}'s page lists its access to the projects where you manage access, and you manage none.`\n : `No ${kind} by that name has ever been registered here.`}\n </ClosedDoor>\n );\n }\n\n const access = (\n <>\n {removed ? <Archive size={15} /> : <Folder size={15} />}\n {removed ? 'Offboarding' : 'Access'}\n </>\n );\n const activity = (\n <>\n <Activity size={15} />\n Activity\n </>\n );\n const tabs = people\n ? [\n <Link key=\"access\" to=\"/users/$user\" params={{ user: principalId }} activeOptions={{ exact: true, includeSearch: false }}>\n {access}\n </Link>,\n // Only an owner reads the report that lists them; removal disconnects them.\n hasAppsTab(shell, report) && mounted('/users/$user/apps') && (\n <Link key=\"apps\" to=\"/users/$user/apps\" params={{ user: principalId }}>\n <LinkIcon size={15} />\n Connected apps\n </Link>\n ),\n capabilities.canReadAudit && mounted('/users/$user/activity') && (\n <Link key=\"activity\" to=\"/users/$user/activity\" params={{ user: principalId }}>\n {activity}\n </Link>\n ),\n ]\n : [\n signInWays(shell, held) !== null && (\n <Link key=\"sign-in\" to=\"/service-accounts/$account\" params={{ account: principalId }} activeOptions={{ exact: true, includeSearch: false }}>\n <LinkIcon size={15} />\n Sign-in\n </Link>\n ),\n mounted('/service-accounts/$account/access') && (\n <Link key=\"access\" to=\"/service-accounts/$account/access\" params={{ account: principalId }}>\n {access}\n </Link>\n ),\n capabilities.canReadAudit && mounted('/service-accounts/$account/activity') && (\n <Link key=\"activity\" to=\"/service-accounts/$account/activity\" params={{ account: principalId }}>\n {activity}\n </Link>\n ),\n ];\n\n return (\n <>\n <PageHeader\n lead={<PrincipalAvatar type={principalType} id={principalId} size=\"lg\" />}\n title={principalType === 'service' ? `service:${principalId}` : principalId}\n description={\n principalType === 'service'\n ? 'A service account: an identity for CI and other automation.'\n : undefined\n }\n meta={\n removed ? (\n <span className=\"tag tag-red\">Removed</span>\n ) : (\n entry?.principalType === 'user' && <InstanceRole principal={entry} />\n )\n }\n actions={entry !== undefined && <PrincipalActions principal={entry} trigger=\"btn btn-icon\" />}\n />\n\n {change.state === 'failed' && (\n <div className=\"report-notice\">\n <ItemFailure status={change} onDismiss={() => dismiss(change.mutationId)} />\n </div>\n )}\n {report?.ok === false && (\n <div className=\"report-notice\">\n <Notice tone=\"bad\">{report.error}</Notice>\n </div>\n )}\n <PageTabs label={people ? 'User sections' : 'Service account sections'}>{tabs}</PageTabs>\n\n <Outlet />\n </>\n );\n}\n\n/**\n * A user's or service account's Access tab: its grants on every project\n * where you manage access, and on every project; once it is removed, what\n * its offboarding did instead.\n */\nexport function PrincipalAccess({ principalType, principalId }: { principalType: PrincipalType; principalId: string }) {\n const report = useReport(principalType, principalId);\n const { access: held, error, projects: access, offers } = useMemberAccess(principalType, principalId);\n const kind = KIND[principalType];\n const people = principalType === 'user';\n const found = report?.ok === true ? report.report : null;\n const removed = found?.status === 'removed';\n\n // One request, so one error, said once in place of the rows (`UnreadAccess`).\n const rows = accessRows(access).flatMap((row) => (row.grant === null ? [] : [row]));\n // Grants to someone removed are refused until they are added back.\n const editable = removed\n ? []\n : access.filter(\n ({ project, grantsError }) => project.archivedAt === null && grantsError === null,\n );\n\n return (\n <>\n {removed && found !== null && <RemovedNotice report={found} />}\n\n {/* Removal ends every grant, so there is no access left to show. */}\n {!removed && (\n <>\n {people && held !== null && <InstanceRoleNote access={held} />}\n\n <section className=\"card\" aria-label=\"Project access\">\n {error !== null ? (\n <UnreadAccess member={memberRef(principalType, principalId)} error={error} />\n ) : rows.length === 0 ? (\n <EmptyState title=\"No project access yet\">\n {editable.length > 0 ? undefined : `None of the projects where you manage access has a grant for this ${kind}.`}\n </EmptyState>\n ) : (\n <GrantsTable\n lead={\n <span className=\"th\">\n <Folder size={14} />\n Project\n </span>\n }\n >\n {rows.map(({ project, grant }, index) => (\n <GrantRowView\n key={grant.id}\n number={index + 1}\n project={project.slug}\n grant={grant}\n leadLabel=\"Project\"\n lead={\n <span className=\"cell-project\">\n <Tile name={project.slug} />\n <Link\n className=\"cell-link\"\n to={people ? '/projects/$project/users' : '/projects/$project/service-accounts'}\n params={{ project: project.slug }}\n >\n {project.slug}\n </Link>\n {project.archivedAt !== null && <span className=\"tag tag-red\">Archived</span>}\n </span>\n }\n />\n ))}\n </GrantsTable>\n )}\n </section>\n\n {editable.length > 0 && (\n <div className=\"table-actions\">\n <EditAccess principalType={principalType} principalId={principalId} access={editable} offers={offers} />\n </div>\n )}\n\n {!(held?.managed === true && principalType === 'service') && (\n <p className=\"hint section-foot\">Only projects where you manage access are listed.</p>\n )}\n\n </>\n )}\n\n {found !== null && <PrincipalReportCards report={found} />}\n {/* A report from an instance before 0.7, mid-deploy or rolled back, lists none. */}\n {found !== null && !removed && (found.personalTokens ?? []).length > 0 && (\n <MemberPersonalTokens member={memberRef(principalType, principalId)} tokens={found.personalTokens} />\n )}\n </>\n );\n}\n\n/** A person's personal tokens, for whoever runs the instance, who reads their report and may revoke any of them. */\nfunction MemberPersonalTokens({ member, tokens }: { member: string; tokens: TokenRow[] }) {\n return (\n <PersonalTokensCard\n tokens={tokens}\n change={revokeMemberToken(useCoffre(), member)}\n description=\"Tokens they made, each acting as them within what it reaches. Removing them from coffre revokes every one.\"\n />\n );\n}\n\n/** What a person's instance role gives them, above the grants that add to it: nothing for a Member. */\nfunction InstanceRoleNote({ access }: { access: MemberAccess }) {\n const { instanceRoles } = useRoles();\n if (access.instanceRole === 'member') return null;\n const name = roleNameOf(instanceRoles, 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 { roles } = useRoles();\n const kind = KIND[principalType];\n const nameOf = (role: Role) => roleNameOf(roles, role);\n const assignable = (role: Role) => roles.some((each) => each.id === role && each.assignableToEnvironment);\n\n const rows = access.map(({ project, grants }) => {\n const environments = project.environments\n .filter(\n // Your personal config takes no grant: it is no place to give access to.\n (environment) => environment.details !== null && environment.details.archivedAt === null && !environment.personal,\n )\n .map((environment) => environment.slug);\n const held = planFromGrants(grants, environments);\n const plan = Object.hasOwn(edits, project.slug) ? edits[project.slug] : held;\n // What you may give here: every role where you manage access; a service account you manage, what you hold.\n const whole = offers(project, null);\n const each = Object.fromEntries(environments.map((slug) => [slug, offers(project, slug)]));\n return { project, grants, environments, held, plan, whole, each, changes: accessChanges(grants, plan) };\n });\n const changed = rows.filter((row) => row.changes.length > 0);\n\n function close() {\n setOpen(false);\n setEdits({});\n setError(null);\n }\n\n return (\n <>\n <button className=\"btn btn-primary\" onClick={() => setOpen(true)}>\n <Pencil size={14} />\n Edit access\n </button>\n\n <Modal\n open={open}\n onOpenChange={(next) => (next ? setOpen(true) : close())}\n title={\n <>\n Edit access for <span className=\"mono\">{principalId}</span>\n </>\n }\n description={`Set what this ${kind} can reach on each project you ${principalType === 'service' ? 'may give it access to' : 'manage'}, and until when.`}\n wide\n >\n <form\n className=\"form\"\n onSubmit={(event) => {\n event.preventDefault();\n run(\n () =>\n coffre.access.set(\n memberRef(principalType, principalId),\n Object.assign({}, ...changed.map(({ project, changes }) => accessPatch(project.slug, changes))),\n ),\n {\n affects: changed.flatMap(({ project }) =>\n affects.access(project.slug, memberRef(principalType, principalId)),\n ),\n onSuccess: () => {\n toast.success(\n `Updated ${principalId}’s access on ${changed.length} project${changed.length === 1 ? '' : 's'}`,\n );\n close();\n },\n },\n );\n }}\n >\n <ul className=\"plan-list\">\n <li className=\"plan-head\" aria-hidden=\"true\">\n <span>Project</span>\n <span>Access</span>\n <span>Expires</span>\n </li>\n {rows.map(({ project, grants, environments, held, plan, whole, each, changes }) => {\n const id = `plan-${project.slug}`;\n const edit = (next: AccessPlan) =>\n setEdits((current) => ({ ...current, [project.slug]: next }));\n return (\n <li\n key={project.slug}\n className={`plan-row${changes.length > 0 ? ' is-changed' : ''}`}\n >\n <label className=\"plan-project\" htmlFor={id}>\n <Tile name={project.slug} />\n <span className=\"plan-project-text\">\n <span className=\"plan-project-name\">{project.slug}</span>\n {held.level === 'custom' && (\n <span className=\"plan-project-held\">\n Holds {grants.map((grant) => projectAccessLabel(grant)).join(', ')}\n </span>\n )}\n </span>\n </label>\n <select\n id={id}\n className=\"select select-sm\"\n value={plan.level === 'project' ? `role:${plan.role}` : plan.level}\n onChange={(event) => {\n const value = event.target.value;\n edit(\n value.startsWith('role:')\n ? withLevel(plan, 'project', environments, { role: value.slice('role:'.length), assignable })\n : withLevel(plan, value as AccessPlan['level'], environments, { assignable }),\n );\n }}\n >\n {held.level === 'custom' && <option value=\"custom\">Keep as is</option>}\n <option value=\"none\">No access</option>\n {/* What you may give on the whole project, and what they hold there already, given or not. */}\n {[...new Set([...whole, ...(plan.level === 'project' && plan.role !== null ? [plan.role] : [])])].map((role) => (\n <option key={role} value={`role:${role}`}>\n {role === 'owner' ? nameOf(role) : `${nameOf(role)}: all`}\n </option>\n ))}\n {environments.some((slug) => each[slug]!.length > 0) && <option value=\"env\">Per environment…</option>}\n </select>\n {plan.level === 'project' && (\n <ExpiryField\n label={`${project.slug} expires`}\n expiresAt={plan.expiresAt}\n onChange={(expiresAt) => edit({ ...plan, expiresAt })}\n />\n )}\n\n {plan.level === 'env' && (\n <ul className=\"plan-envs\" aria-label={`Environments of ${project.slug}`}>\n {environments.map((slug) => {\n const current = environmentAccess(plan, slug);\n return (\n <li key={slug} className=\"plan-env\">\n <label className=\"mono\" htmlFor={`${id}-${slug}`}>\n {slug}\n </label>\n <select\n id={`${id}-${slug}`}\n className=\"select select-sm\"\n value={current?.role ?? ''}\n onChange={(event) => {\n const role = event.target.value;\n edit(\n withEnvironment(\n plan,\n slug,\n role === '' ? null : { role, expiresAt: current?.expiresAt ?? null },\n ),\n );\n }}\n >\n <option value=\"\">No access</option>\n {[...new Set([...each[slug]!, ...(current === null ? [] : [current.role])])].map((role) => (\n <option key={role} value={role}>\n {nameOf(role)}\n </option>\n ))}\n </select>\n {current !== null && (\n <ExpiryField\n label={`${slug} of ${project.slug} expires`}\n expiresAt={current.expiresAt}\n onChange={(expiresAt) =>\n edit(withEnvironment(plan, slug, { ...current, expiresAt }))\n }\n />\n )}\n </li>\n );\n })}\n </ul>\n )}\n\n {changes.length > 0 && (\n <ul className=\"plan-changes\" aria-label={`Changes to ${project.slug}`}>\n {changes.map((change) => (\n <li\n key={\n change.kind === 'create'\n ? `+${change.role}@${change.environmentSlug ?? ''}`\n : change.grant.id\n }\n >\n <AccessChangeTag change={change} roleName={nameOf} />\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, roleName }: { change: AccessChange; roleName: (role: Role) => string }) {\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: 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,CAAC,CAAC;EAE1F,mBAAmB,SACjB,KAAK,MAAM,KAAK,QAAQ,KAAK,QAAQ,SAAS,IAAI,KAAK,QAAQ,GAAG,EAAE,CAAC,CAAE,MAAM,KAAA;CACjF,CAAC;CAED,IAAI,IAAI,WACN,OACE,qBAAC,KAAD;EAAG,WAAU;YAAb,CACE,oBAAC,SAAD,EAAS,MAAM,GAAK,CAAA,GAAC,mBACpB;;CAGP,MAAM,SAAS,IAAI,MAAM,MAAM,MAAM,SAAS,CAAC,KAAK,EAAE;CACtD,IAAI,WAAW,KAAA,KAAa,CAAC,OAAO,IAAI,OAAO,oBAAC,QAAD;EAAQ,MAAK;YAAO,OAAO;CAAc,CAAA;CAExF,MAAM,QAAQ,OADG,IAAI,MAAM,SAAS,CAAC,EAAA,CAAG,SAAS,SAAU,KAAK,KAAK,KAAK,UAAU,CAAC,CACjE,CAAO;CAE3B,OACE,qBAAA,YAAA,EAAA,UAAA,CACE,oBAAC,WAAD;EAAS,WAAU;EAAO,cAAW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,oBAAC,SAAD,CAAU,CAAA,GAAE,cAElB;OACL;;GACD;;CACD,CAAA,CACP,EAAA,CAAA;AAEN;AAEA,SAAS,gBAAgB,EAAE,QAAQ,YAAwE;CACzG,MAAM,SAAS,cACb,cAAc,OAAO,KAAK,UAAU,eAAe,SAAS;CAC9D,QAAQ,OAAO,MAAf;EACE,KAAK,UACH,OACE,qBAAC,QAAD;GAAM,WAAU;aAAhB;IACE,oBAAC,QAAD;KAAM,eAAY;eAAO;IAAO,CAAA;IAChC,oBAAC,QAAD;KAAM,WAAU;eAAkB;IAAU,CAAA;IAC3C,mBAAmB;KAAE,GAAG;KAAQ,UAAU,SAAS,OAAO,IAAI;IAAE,CAAC;IACjE,MAAM,OAAO,SAAS;GACnB;;EAEV,KAAK,UACH,OACE,qBAAC,QAAD;GAAM,WAAU;aAAhB;IACE,oBAAC,OAAD,EAAO,MAAM,GAAK,CAAA;IAClB,oBAAC,QAAD;KAAM,WAAU;eAAkB;IAAyB,CAAA;IAC1D,mBAAmB,OAAO,KAAK;IAC/B,OAAO,cAAc,OAAO,gBAAgB,MAAM,OAAO,SAAS;GAC/D;;EAEV,KAAK,UACH,OACE,qBAAC,QAAD;GAAM,WAAU;aAAhB;IACE,oBAAC,QAAD;KAAM,eAAY;eAAO;IAAO,CAAA;IAChC,oBAAC,QAAD;KAAM,WAAU;eAAkB;IAAa,CAAA;IAC9C,mBAAmB,OAAO,KAAK;GAC5B;;CAEZ;AACF"}
1
+ {"version":3,"file":"principal-page-C0U4T6le.js","names":[],"sources":["../../src/components/actions-log.tsx","../../src/lib/service-setup.ts","../../src/lib/access-plan.ts","../../src/components/expiry-field.tsx","../../src/components/principal-page.tsx"],"sourcesContent":["import { useInfiniteQuery } from '@tanstack/react-query';\nimport { uiResult, useCoffre } from '../lib/coffre';\nimport { keys } from '../lib/queries';\nimport { describe, lines } from '../lib/audit-sentences';\nimport { Sentence } from './audit-sentence';\nimport { EmptyState, Notice, Spinner, Timestamp } from './ui';\nimport { Activity, Clock, ShieldCheck, SlashCircle } from './icons';\n\nconst PAGE_SIZE = 50;\n\n/**\n * Everything one member did, newest first, from the audit log: the same\n * entries `coffre audit --actor` lists, said as the audit page says them.\n * Older pages come on request.\n */\nexport function ActionsLog({ member }: { member: string }) {\n const client = useCoffre();\n const log = useInfiniteQuery({\n queryKey: [...keys.audit, 'actor', member],\n staleTime: 0,\n initialPageParam: undefined as number | undefined,\n queryFn: ({ pageParam }) =>\n uiResult(() => client.audit.list({ actor: member, limit: PAGE_SIZE, before: pageParam })),\n // A page lists fewer entries where they name many secrets: `more` says whether older ones follow.\n getNextPageParam: (page) =>\n page.ok && page.more && page.entries.length > 0 ? page.entries.at(-1)!.seq : undefined,\n });\n\n if (log.isPending) {\n return (\n <p className=\"hint\">\n <Spinner size={13} /> Reading the log…\n </p>\n );\n }\n const failed = log.data?.pages.find((page) => !page.ok);\n if (failed !== undefined && !failed.ok) return <Notice tone=\"bad\">{failed.error}</Notice>;\n const entries = (log.data?.pages ?? []).flatMap((page) => (page.ok ? page.entries : []));\n const shown = lines(entries);\n\n return (\n <>\n <section className=\"card\" aria-label=\"Actions log\">\n {shown.length === 0 ? (\n <EmptyState title=\"Nothing yet\" />\n ) : (\n <div className=\"dt-wrap\">\n <table className=\"dt actions-log stacks stacks-inline\">\n <thead>\n <tr>\n <th className=\"col-shrink\">\n <span className=\"th\">\n <Clock size={14} />\n When\n </span>\n </th>\n <th>\n <span className=\"th\">\n <Activity size={14} />\n Action\n </span>\n </th>\n <th className=\"col-shrink\">\n <span className=\"th\">\n <ShieldCheck size={14} />\n Outcome\n </span>\n </th>\n </tr>\n </thead>\n <tbody>\n {shown.map((batch) => {\n const lead = batch[0]!;\n const sentence = describe(batch);\n return (\n <tr key={lead.seq} className={sentence.refused ? 'is-denied' : undefined}>\n <td className=\"nowrap cell-muted\" title={lead.occurredAt}>\n <Timestamp iso={lead.occurredAt} display=\"relative\" />\n </td>\n <td className=\"cell-sentence\">\n <span className=\"sentence\">\n <Sentence parts={sentence.parts} />\n </span>\n </td>\n <td className=\"nowrap\" data-label=\"Outcome\">\n {sentence.refused ? (\n <span className=\"decided decided-refused\">\n <SlashCircle size={13} />\n Refused\n </span>\n ) : (\n <span className=\"cell-muted\">Allowed</span>\n )}\n </td>\n </tr>\n );\n })}\n </tbody>\n </table>\n </div>\n )}\n </section>\n {log.hasNextPage && (\n <div className=\"table-actions\">\n <button\n type=\"button\"\n className=\"btn\"\n disabled={log.isFetchingNextPage}\n onClick={() => void log.fetchNextPage()}\n >\n {log.isFetchingNextPage && <Spinner />}\n Show older\n </button>\n </div>\n )}\n </>\n );\n}\n","import { inScope, PROJECT_ONLY_PERMISSIONS, type Permission, type Role, type Scope } from '@coffre/core/access';\nimport type { RoleView } from '@coffre/client';\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 /** The instance's roles, as the policy defines them (`useRoles`). */\n roles: readonly Pick<RoleView, 'id' | 'permissions' | 'assignableToEnvironment'>[];\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. An\n * environment takes only the roles that hold nothing project-wide. A\n * project's role reaches its protected environments too, where the service\n * holds the role's normal column and you your protected one: you hold that\n * normal column there as well, or give none.\n *\n * a Developer of every dev, at market/dev viewer, contributor, developer\n * the same, at market none: a project takes holding all of it\n * a Developer of market, prod protected contributor: viewer and developer read prod, which you only use\n */\nexport function givable(holder: Holder, project: ProjectSummary, environment: string | null): Role[] {\n const heldIn = (slug: string) => holder.environments.find((entry) => entry.project === project.slug && entry.environment === slug)?.permissions ?? [];\n const held = environment === null ? project.permissions : heldIn(environment);\n const roles = holder.roles.filter((role) => environment === null || role.assignableToEnvironment);\n if (held.includes('grant.manage')) return roles.map((role) => role.id);\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 const reached = environment === null ? project.environments.filter((candidate) => candidate.protected && !candidate.personal).map((candidate) => heldIn(candidate.slug)) : [];\n const gives = (permission: Permission) =>\n held.includes(permission) && (PROJECT_ONLY_PERMISSIONS.includes(permission) || reached.every((there) => there.includes(permission)));\n // A role that holds nothing is given where its giver manages access alone, as the server decides (`givesService`).\n return roles.filter((role) => role.permissions.length > 0 && role.permissions.every(gives)).map((role) => role.id);\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 { assignableToEnvironment, type Role } from '@coffre/core/access';\n\nimport type { GrantRow } from '../shared/models';\n\n/** A role on one environment, and when it ends: an ISO instant, or null for never. */\nexport type EnvironmentAccess = { role: Role; expiresAt: string | null };\n\n/**\n * What one project is set to in a principal's access editor: nothing, one\n * role on the whole project, or a role 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 -- read everywhere plus\n * write on one environment, or a grant on an environment the editor does not\n * list. The editor shows them and leaves them alone unless another setting\n * is picked.\n */\nexport type AccessPlan = {\n level: 'none' | 'project' | 'env' | 'custom';\n /** The role on the whole project, at level `project`. */\n role: Role | null;\n /** When the project-wide role 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\nconst NONE: AccessPlan = { level: 'none', role: null, expiresAt: null, environments: {} };\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 NONE;\n\n const [only] = grants;\n if (grants.length === 1 && only.environmentSlug === null) {\n return { level: 'project', role: 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 (slug === null || !environments.includes(slug) || Object.hasOwn(perEnvironment, slug)) {\n return { ...NONE, level: 'custom' };\n }\n perEnvironment[slug] = { role: grant.role, expiresAt: grant.expiresAt };\n }\n return { level: 'env', role: null, expiresAt: null, environments: perEnvironment };\n}\n\n/**\n * Switch a plan's level, with its role for `project`. Going from one role\n * on the whole project to per environment starts every environment at that\n * role and expiry, where an environment takes it, so the switch alone keeps\n * the same reach.\n */\nexport function withLevel(\n plan: AccessPlan,\n level: AccessPlan['level'],\n environments: readonly string[],\n { role = null, assignable = (each) => assignableToEnvironment(each) }: { role?: Role | null; assignable?: (role: Role) => boolean } = {},\n): AccessPlan {\n if (\n level === 'env' &&\n plan.level === 'project' &&\n plan.role !== null &&\n assignable(plan.role) &&\n Object.keys(plan.environments).length === 0\n ) {\n const access = { role: plan.role, expiresAt: plan.expiresAt };\n return {\n ...plan,\n level,\n role: null,\n environments: Object.fromEntries(environments.map((slug) => [slug, access])),\n };\n }\n return { ...plan, level, role: level === 'project' ? role : null };\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 'project':\n return plan.role === null ? [] : [{ role: plan.role, 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 : { 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 { scopeInWords, unscoped, type Role } from '@coffre/core/access';\nimport { useShell } from '../lib/use-shell';\nimport { toast } from 'sonner';\nimport { memberRef, useCoffre } from '../lib/coffre';\nimport { directoryList, revokeMemberToken } from '../lib/changes';\nimport { affects, hasAppsTab, keys, listsAccess, managedProjects, queries, signInWays } from '../lib/queries';\nimport { useChangeStatus } from '../lib/use-change';\nimport { useMounted } from '../lib/mounted';\nimport { ItemFailure } from './row-state';\nimport { useAction } from '../lib/use-action';\nimport { accessRows, projectAccessLabel, type ProjectAccess } from '../lib/project-access';\nimport { givable, serviceProjects } from '../lib/service-setup';\nimport { roleNameOf } from '../lib/roles';\nimport { useRoles } from '../lib/use-roles';\nimport {\n accessChanges,\n accessPatch,\n dateFromExpiry,\n environmentAccess,\n expiryFromDate,\n planFromGrants,\n withEnvironment,\n withLevel,\n type AccessChange,\n type AccessPlan,\n} from '../lib/access-plan';\nimport type { MemberAccess, TokenRow } from '@coffre/client';\nimport type { DirectoryPrincipal, ProjectSummary } from '../shared/models';\nimport { ClosedDoor, PageHeader } from './page';\nimport { EmptyState, ErrorLine, Modal, Notice, Spinner } from './ui';\nimport { GrantRowView, GrantsTable } from './grants';\nimport { ExpiryField } from './expiry-field';\nimport { InstanceRole, KIND, PrincipalActions } from './directory';\nimport { PrincipalReportCards, RemovedNotice } from './offboarding';\nimport { PersonalTokensCard } from './personal-tokens';\nimport { PrincipalAvatar } from './principal';\nimport { Tile } from './tile';\nimport { Activity, Archive, Clock, Folder, Key, Link as LinkIcon, Pencil, Users, X } from './icons';\nimport { PageTabs } from './tabs';\n\ntype PrincipalType = DirectoryPrincipal['principalType'];\n\n/** The roles you may give at a project, or one of its environments: any where you manage access (`givable`). */\ntype Offers = (project: ProjectSummary, environment: string | null) => readonly Role[];\n\n/** Who a user or service account is to the instance, as an owner reads it; null for anyone else. */\nfunction useReport(principalType: PrincipalType, principalId: string) {\n const { capabilities } = useShell();\n return useSuspenseQuery(queries.report(useCoffre(), memberRef(principalType, principalId), capabilities.runsInstance)).data;\n}\n\n/**\n * What `loadAccess` read in one request: their role and scope, and, for each\n * project where you manage access, the grants they hold there. For a\n * service account you manage, each project where you may give it\n * something, and what (`offers`).\n */\nfunction useMemberAccess(principalType: PrincipalType, principalId: string): {\n access: MemberAccess | null;\n error: string | null;\n projects: ProjectAccess[];\n offers: Offers;\n} {\n const shell = useShell();\n const { roles } = useRoles();\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 holder = { ...shell, roles };\n const listed = yours ? serviceProjects(holder) : managedProjects(shell.projects);\n return {\n access,\n error,\n offers: yours\n ? (project, environment) => givable(holder, project, environment)\n : (_project, environment) => roles.filter((role) => environment === null || role.assignableToEnvironment).map((role) => role.id),\n projects: listed.map((project) => ({\n project,\n grants: (access?.grants ?? []).filter((grant) => grant.project === project.slug).map((grant) => ({\n id: grant.id,\n principalType,\n principalId,\n role: grant.role,\n roleName: grant.roleName,\n permissions: grant.permissions,\n scope: grant.environment === null ? 'project' : 'environment',\n environmentSlug: grant.environment,\n expiresAt: grant.expiresAt,\n })),\n grantsError: error,\n })),\n };\n}\n\n/**\n * A user's or service account's page: who it is, its menu, and its tabs,\n * each a page of its own under this one. Access is a user's first tab; a\n * service account's is how it signs in, while it shows one. A tab the\n * deployment left out is not offered.\n */\nexport function PrincipalLayout({ principalType, principalId }: { principalType: PrincipalType; principalId: string }) {\n const shell = useShell();\n const mounted = useMounted();\n const { capabilities } = shell;\n const report = useReport(principalType, principalId);\n // A service account you manage, though you do not run the instance: what it holds, from its access.\n const { data: held } = useSuspenseQuery(queries.memberAccess(useCoffre(), memberRef(principalType, principalId), listsAccess(shell)));\n const yours = principalType === 'service' && held?.ok === true && held.managed;\n // A role change or removal made from this page's menu, refused.\n const { status, dismiss } = useChangeStatus(directoryList.queryKey);\n const change = status(memberRef(principalType, principalId));\n const kind = KIND[principalType];\n const people = principalType === 'user';\n const found = report?.ok === true ? report.report : null;\n const removed = found?.status === 'removed';\n const entry =\n found !== null && !removed\n ? {\n principalType,\n principalId,\n instanceRole: found.instanceRole,\n scope: found.scope,\n tampered: found.status === 'tampered',\n managed: principalType === 'service',\n declared: found.declared,\n }\n : yours\n ? { principalType, principalId, instanceRole: 'member' as const, scope: null, tampered: false, managed: true }\n : undefined;\n\n // Owners get a report about anyone ever registered, removed or not, so a\n // miss there means there is no such user. Everyone else only reaches this\n // page through projects they manage, or a service account they manage.\n const unknown = report?.ok === true && found === null;\n if (unknown || (report === null && managedProjects(shell.projects).length === 0 && !yours)) {\n return (\n <ClosedDoor\n icon={people ? <Users size={18} /> : <Key size={18} />}\n label={<span className=\"mono\">{people ? principalId : `service:${principalId}`}</span>}\n title={people ? 'No such user for you' : 'No such service account for you'}\n actions={\n <Link className=\"btn\" to={people ? '/users' : '/service-accounts'}>\n All {people ? 'users' : 'service accounts'}\n </Link>\n }\n >\n {report === null\n ? `A ${kind}'s page lists its access to the projects where you manage access, and you manage none.`\n : `No ${kind} by that name has ever been registered here.`}\n </ClosedDoor>\n );\n }\n\n const access = (\n <>\n {removed ? <Archive size={15} /> : <Folder size={15} />}\n {removed ? 'Offboarding' : 'Access'}\n </>\n );\n const activity = (\n <>\n <Activity size={15} />\n Activity\n </>\n );\n const tabs = people\n ? [\n <Link key=\"access\" to=\"/users/$user\" params={{ user: principalId }} activeOptions={{ exact: true, includeSearch: false }}>\n {access}\n </Link>,\n // Only an owner reads the report that lists them; removal disconnects them.\n hasAppsTab(shell, report) && mounted('/users/$user/apps') && (\n <Link key=\"apps\" to=\"/users/$user/apps\" params={{ user: principalId }}>\n <LinkIcon size={15} />\n Connected apps\n </Link>\n ),\n capabilities.canReadAudit && mounted('/users/$user/activity') && (\n <Link key=\"activity\" to=\"/users/$user/activity\" params={{ user: principalId }}>\n {activity}\n </Link>\n ),\n ]\n : [\n signInWays(shell, held) !== null && (\n <Link key=\"sign-in\" to=\"/service-accounts/$account\" params={{ account: principalId }} activeOptions={{ exact: true, includeSearch: false }}>\n <LinkIcon size={15} />\n Sign-in\n </Link>\n ),\n mounted('/service-accounts/$account/access') && (\n <Link key=\"access\" to=\"/service-accounts/$account/access\" params={{ account: principalId }}>\n {access}\n </Link>\n ),\n capabilities.canReadAudit && mounted('/service-accounts/$account/activity') && (\n <Link key=\"activity\" to=\"/service-accounts/$account/activity\" params={{ account: principalId }}>\n {activity}\n </Link>\n ),\n ];\n\n return (\n <>\n <PageHeader\n lead={<PrincipalAvatar type={principalType} id={principalId} size=\"lg\" />}\n title={principalType === 'service' ? `service:${principalId}` : principalId}\n description={\n principalType === 'service'\n ? 'A service account: an identity for CI and other automation.'\n : undefined\n }\n meta={\n removed ? (\n <span className=\"tag tag-red\">Removed</span>\n ) : (\n entry?.principalType === 'user' && <InstanceRole principal={entry} />\n )\n }\n actions={entry !== undefined && <PrincipalActions principal={entry} trigger=\"btn btn-icon\" />}\n />\n\n {change.state === 'failed' && (\n <div className=\"report-notice\">\n <ItemFailure status={change} onDismiss={() => dismiss(change.mutationId)} />\n </div>\n )}\n {report?.ok === false && (\n <div className=\"report-notice\">\n <Notice tone=\"bad\">{report.error}</Notice>\n </div>\n )}\n <PageTabs label={people ? 'User sections' : 'Service account sections'}>{tabs}</PageTabs>\n\n <Outlet />\n </>\n );\n}\n\n/**\n * A user's or service account's Access tab: its grants on every project\n * where you manage access, and on every project; once it is removed, what\n * its offboarding did instead.\n */\nexport function PrincipalAccess({ principalType, principalId }: { principalType: PrincipalType; principalId: string }) {\n const report = useReport(principalType, principalId);\n const { access: held, error, projects: access, offers } = useMemberAccess(principalType, principalId);\n const kind = KIND[principalType];\n const people = principalType === 'user';\n const found = report?.ok === true ? report.report : null;\n const removed = found?.status === 'removed';\n\n // One request, so one error, said once in place of the rows (`UnreadAccess`).\n const rows = accessRows(access).flatMap((row) => (row.grant === null ? [] : [row]));\n // Grants to someone removed are refused until they are added back.\n const editable = removed\n ? []\n : access.filter(\n ({ project, grantsError }) => project.archivedAt === null && grantsError === null,\n );\n\n return (\n <>\n {removed && found !== null && <RemovedNotice report={found} />}\n\n {/* Removal ends every grant, so there is no access left to show. */}\n {!removed && (\n <>\n {people && held !== null && <InstanceRoleNote access={held} />}\n\n <section className=\"card\" aria-label=\"Project access\">\n {error !== null ? (\n <UnreadAccess member={memberRef(principalType, principalId)} error={error} />\n ) : rows.length === 0 ? (\n <EmptyState title=\"No project access yet\">\n {editable.length > 0 ? undefined : `None of the projects where you manage access has a grant for this ${kind}.`}\n </EmptyState>\n ) : (\n <GrantsTable\n lead={\n <span className=\"th\">\n <Folder size={14} />\n Project\n </span>\n }\n >\n {rows.map(({ project, grant }, index) => (\n <GrantRowView\n key={grant.id}\n number={index + 1}\n project={project.slug}\n grant={grant}\n leadLabel=\"Project\"\n lead={\n <span className=\"cell-project\">\n <Tile name={project.slug} />\n <Link\n className=\"cell-link\"\n to={people ? '/projects/$project/users' : '/projects/$project/service-accounts'}\n params={{ project: project.slug }}\n >\n {project.slug}\n </Link>\n {project.archivedAt !== null && <span className=\"tag tag-red\">Archived</span>}\n </span>\n }\n />\n ))}\n </GrantsTable>\n )}\n </section>\n\n {editable.length > 0 && (\n <div className=\"table-actions\">\n <EditAccess principalType={principalType} principalId={principalId} access={editable} offers={offers} />\n </div>\n )}\n\n {!(held?.managed === true && principalType === 'service') && (\n <p className=\"hint section-foot\">Only projects where you manage access are listed.</p>\n )}\n\n </>\n )}\n\n {found !== null && <PrincipalReportCards report={found} />}\n {/* A report from an instance before 0.7, mid-deploy or rolled back, lists none. */}\n {found !== null && !removed && (found.personalTokens ?? []).length > 0 && (\n <MemberPersonalTokens member={memberRef(principalType, principalId)} tokens={found.personalTokens} />\n )}\n </>\n );\n}\n\n/** A person's personal tokens, for whoever runs the instance, who reads their report and may revoke any of them. */\nfunction MemberPersonalTokens({ member, tokens }: { member: string; tokens: TokenRow[] }) {\n return (\n <PersonalTokensCard\n tokens={tokens}\n change={revokeMemberToken(useCoffre(), member)}\n description=\"Tokens they made, each acting as them within what it reaches. Removing them from coffre revokes every one.\"\n />\n );\n}\n\n/** What a person's instance role gives them, above the grants that add to it: nothing for a Member. */\nfunction InstanceRoleNote({ access }: { access: MemberAccess }) {\n const { instanceRoles } = useRoles();\n if (access.instanceRole === 'member') return null;\n const name = roleNameOf(instanceRoles, 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 { roles } = useRoles();\n const kind = KIND[principalType];\n const nameOf = (role: Role) => roleNameOf(roles, role);\n const assignable = (role: Role) => roles.some((each) => each.id === role && each.assignableToEnvironment);\n\n const rows = access.map(({ project, grants }) => {\n const environments = project.environments\n .filter(\n // Your personal config takes no grant: it is no place to give access to.\n (environment) => environment.details !== null && environment.details.archivedAt === null && !environment.personal,\n )\n .map((environment) => environment.slug);\n const held = planFromGrants(grants, environments);\n const plan = Object.hasOwn(edits, project.slug) ? edits[project.slug] : held;\n // What you may give here: every role where you manage access; a service account you manage, what you hold.\n const whole = offers(project, null);\n const each = Object.fromEntries(environments.map((slug) => [slug, offers(project, slug)]));\n return { project, grants, environments, held, plan, whole, each, changes: accessChanges(grants, plan) };\n });\n const changed = rows.filter((row) => row.changes.length > 0);\n\n function close() {\n setOpen(false);\n setEdits({});\n setError(null);\n }\n\n return (\n <>\n <button className=\"btn btn-primary\" onClick={() => setOpen(true)}>\n <Pencil size={14} />\n Edit access\n </button>\n\n <Modal\n open={open}\n onOpenChange={(next) => (next ? setOpen(true) : close())}\n title={\n <>\n Edit access for <span className=\"mono\">{principalId}</span>\n </>\n }\n description={`Set what this ${kind} can reach on each project you ${principalType === 'service' ? 'may give it access to' : 'manage'}, and until when.`}\n wide\n >\n <form\n className=\"form\"\n onSubmit={(event) => {\n event.preventDefault();\n run(\n () =>\n coffre.access.set(\n memberRef(principalType, principalId),\n Object.assign({}, ...changed.map(({ project, changes }) => accessPatch(project.slug, changes))),\n ),\n {\n affects: changed.flatMap(({ project }) =>\n affects.access(project.slug, memberRef(principalType, principalId)),\n ),\n onSuccess: () => {\n toast.success(\n `Updated ${principalId}’s access on ${changed.length} project${changed.length === 1 ? '' : 's'}`,\n );\n close();\n },\n },\n );\n }}\n >\n <ul className=\"plan-list\">\n <li className=\"plan-head\" aria-hidden=\"true\">\n <span>Project</span>\n <span>Access</span>\n <span>Expires</span>\n </li>\n {rows.map(({ project, grants, environments, held, plan, whole, each, changes }) => {\n const id = `plan-${project.slug}`;\n const edit = (next: AccessPlan) =>\n setEdits((current) => ({ ...current, [project.slug]: next }));\n return (\n <li\n key={project.slug}\n className={`plan-row${changes.length > 0 ? ' is-changed' : ''}`}\n >\n <label className=\"plan-project\" htmlFor={id}>\n <Tile name={project.slug} />\n <span className=\"plan-project-text\">\n <span className=\"plan-project-name\">{project.slug}</span>\n {held.level === 'custom' && (\n <span className=\"plan-project-held\">\n Holds {grants.map((grant) => projectAccessLabel(grant)).join(', ')}\n </span>\n )}\n </span>\n </label>\n <select\n id={id}\n className=\"select select-sm\"\n value={plan.level === 'project' ? `role:${plan.role}` : plan.level}\n onChange={(event) => {\n const value = event.target.value;\n edit(\n value.startsWith('role:')\n ? withLevel(plan, 'project', environments, { role: value.slice('role:'.length), assignable })\n : withLevel(plan, value as AccessPlan['level'], environments, { assignable }),\n );\n }}\n >\n {held.level === 'custom' && <option value=\"custom\">Keep as is</option>}\n <option value=\"none\">No access</option>\n {/* What you may give on the whole project, and what they hold there already, given or not. */}\n {[...new Set([...whole, ...(plan.level === 'project' && plan.role !== null ? [plan.role] : [])])].map((role) => (\n <option key={role} value={`role:${role}`}>\n {role === 'owner' ? nameOf(role) : `${nameOf(role)}: all`}\n </option>\n ))}\n {environments.some((slug) => each[slug]!.length > 0) && <option value=\"env\">Per environment…</option>}\n </select>\n {plan.level === 'project' && (\n <ExpiryField\n label={`${project.slug} expires`}\n expiresAt={plan.expiresAt}\n onChange={(expiresAt) => edit({ ...plan, expiresAt })}\n />\n )}\n\n {plan.level === 'env' && (\n <ul className=\"plan-envs\" aria-label={`Environments of ${project.slug}`}>\n {environments.map((slug) => {\n const current = environmentAccess(plan, slug);\n return (\n <li key={slug} className=\"plan-env\">\n <label className=\"mono\" htmlFor={`${id}-${slug}`}>\n {slug}\n </label>\n <select\n id={`${id}-${slug}`}\n className=\"select select-sm\"\n value={current?.role ?? ''}\n onChange={(event) => {\n const role = event.target.value;\n edit(\n withEnvironment(\n plan,\n slug,\n role === '' ? null : { role, expiresAt: current?.expiresAt ?? null },\n ),\n );\n }}\n >\n <option value=\"\">No access</option>\n {[...new Set([...each[slug]!, ...(current === null ? [] : [current.role])])].map((role) => (\n <option key={role} value={role}>\n {nameOf(role)}\n </option>\n ))}\n </select>\n {current !== null && (\n <ExpiryField\n label={`${slug} of ${project.slug} expires`}\n expiresAt={current.expiresAt}\n onChange={(expiresAt) =>\n edit(withEnvironment(plan, slug, { ...current, expiresAt }))\n }\n />\n )}\n </li>\n );\n })}\n </ul>\n )}\n\n {changes.length > 0 && (\n <ul className=\"plan-changes\" aria-label={`Changes to ${project.slug}`}>\n {changes.map((change) => (\n <li\n key={\n change.kind === 'create'\n ? `+${change.role}@${change.environmentSlug ?? ''}`\n : change.grant.id\n }\n >\n <AccessChangeTag change={change} roleName={nameOf} />\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, roleName }: { change: AccessChange; roleName: (role: Role) => string }) {\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: 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,CAAC,CAAC;EAE1F,mBAAmB,SACjB,KAAK,MAAM,KAAK,QAAQ,KAAK,QAAQ,SAAS,IAAI,KAAK,QAAQ,GAAG,EAAE,CAAC,CAAE,MAAM,KAAA;CACjF,CAAC;CAED,IAAI,IAAI,WACN,OACE,qBAAC,KAAD;EAAG,WAAU;YAAb,CACE,oBAAC,SAAD,EAAS,MAAM,GAAK,CAAA,GAAC,mBACpB;;CAGP,MAAM,SAAS,IAAI,MAAM,MAAM,MAAM,SAAS,CAAC,KAAK,EAAE;CACtD,IAAI,WAAW,KAAA,KAAa,CAAC,OAAO,IAAI,OAAO,oBAAC,QAAD;EAAQ,MAAK;YAAO,OAAO;CAAc,CAAA;CAExF,MAAM,QAAQ,OADG,IAAI,MAAM,SAAS,CAAC,EAAA,CAAG,SAAS,SAAU,KAAK,KAAK,KAAK,UAAU,CAAC,CACjE,CAAO;CAE3B,OACE,qBAAA,YAAA,EAAA,UAAA,CACE,oBAAC,WAAD;EAAS,WAAU;EAAO,cAAW;YAClC,MAAM,WAAW,IAChB,oBAAC,YAAD,EAAY,OAAM,cAAe,CAAA,IAEjC,oBAAC,OAAD;GAAK,WAAU;aACb,qBAAC,SAAD;IAAO,WAAU;cAAjB,CACE,oBAAC,SAAD,EAAA,UACE,qBAAC,MAAD,EAAA,UAAA;KACE,oBA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Q,OAAO,MAAf;EACE,KAAK,UACH,OACE,qBAAC,QAAD;GAAM,WAAU;aAAhB;IACE,oBAAC,QAAD;KAAM,eAAY;eAAO;IAAO,CAAA;IAChC,oBAAC,QAAD;KAAM,WAAU;eAAkB;IAAU,CAAA;IAC3C,mBAAmB;KAAE,GAAG;KAAQ,UAAU,SAAS,OAAO,IAAI;IAAE,CAAC;IACjE,MAAM,OAAO,SAAS;GACnB;;EAEV,KAAK,UACH,OACE,qBAAC,QAAD;GAAM,WAAU;aAAhB;IACE,oBAAC,OAAD,EAAO,MAAM,GAAK,CAAA;IAClB,oBAAC,QAAD;KAAM,WAAU;eAAkB;IAAyB,CAAA;IAC1D,mBAAmB,OAAO,KAAK;IAC/B,OAAO,cAAc,OAAO,gBAAgB,MAAM,OAAO,SAAS;GAC/D;;EAEV,KAAK,UACH,OACE,qBAAC,QAAD;GAAM,WAAU;aAAhB;IACE,oBAAC,QAAD;KAAM,eAAY;eAAO;IAAO,CAAA;IAChC,oBAAC,QAAD;KAAM,WAAU;eAAkB;IAAa,CAAA;IAC9C,mBAAmB,OAAO,KAAK;GAC5B;;CAEZ;AACF"}
@@ -1,4 +1,4 @@
1
- import { _ as projectOf, v as queries } from "./queries-DEOPOpsT.js";
1
+ import { b as projectOf, x as queries } from "./queries-Danu0o75.js";
2
2
  import { u as useCoffre } from "./page-JTORvh-N.js";
3
3
  import { useSuspenseQuery } from "@tanstack/react-query";
4
4
  //#region src/lib/project-page.ts
@@ -14,4 +14,4 @@ function useProject(slug) {
14
14
  //#endregion
15
15
  export { useProject as t };
16
16
 
17
- //# sourceMappingURL=project-page-CUXV4FDR.js.map
17
+ //# sourceMappingURL=project-page-CYZ_MkfX.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"project-page-CUXV4FDR.js","names":[],"sources":["../../src/lib/project-page.ts"],"sourcesContent":["import { useSuspenseQuery } from '@tanstack/react-query';\n\nimport { useCoffre } from './coffre';\nimport { projectOf, queries } from './queries';\n\n/**\n * The project one of its tabs shows, as its layout found it: the layout\n * renders a tab only once the project is there for its visitor.\n */\nexport function useProject(slug: string) {\n const found = projectOf(useSuspenseQuery(queries.projects(useCoffre())).data, slug);\n if (!found.ok) throw new Error(`no project \"${slug}\" for this tab`);\n return found;\n}\n"],"mappings":";;;;;;;;AASA,SAAgB,WAAW,MAAc;CACvC,MAAM,QAAQ,UAAU,iBAAiB,QAAQ,SAAS,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI;CAClF,IAAI,CAAC,MAAM,IAAI,MAAM,IAAI,MAAM,eAAe,KAAK,eAAe;CAClE,OAAO;AACT"}
1
+ {"version":3,"file":"project-page-CYZ_MkfX.js","names":[],"sources":["../../src/lib/project-page.ts"],"sourcesContent":["import { useSuspenseQuery } from '@tanstack/react-query';\n\nimport { useCoffre } from './coffre';\nimport { projectOf, queries } from './queries';\n\n/**\n * The project one of its tabs shows, as its layout found it: the layout\n * renders a tab only once the project is there for its visitor.\n */\nexport function useProject(slug: string) {\n const found = projectOf(useSuspenseQuery(queries.projects(useCoffre())).data, slug);\n if (!found.ok) throw new Error(`no project \"${slug}\" for this tab`);\n return found;\n}\n"],"mappings":";;;;;;;;AASA,SAAgB,WAAW,MAAc;CACvC,MAAM,QAAQ,UAAU,iBAAiB,QAAQ,SAAS,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI;CAClF,IAAI,CAAC,MAAM,IAAI,MAAM,IAAI,MAAM,eAAe,KAAK,eAAe;CAClE,OAAO;AACT"}
@@ -1,4 +1,4 @@
1
- import { f as Toggletip } from "./ui-2kwXXfrX.js";
1
+ import { f as Toggletip } from "./ui-D-blFWfx.js";
2
2
  import { L as Lock } from "./page-JTORvh-N.js";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  //#region src/components/protected.tsx
@@ -19,4 +19,4 @@ function ProtectedTag() {
19
19
  //#endregion
20
20
  export { ProtectedTag as t };
21
21
 
22
- //# sourceMappingURL=protected-YYW3U-Sq.js.map
22
+ //# sourceMappingURL=protected-BL_DsZO6.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"protected-YYW3U-Sq.js","names":[],"sources":["../../src/components/protected.tsx"],"sourcesContent":["import { Lock } from './icons';\nimport { Toggletip } from './ui';\n\n/**\n * An environment's protection, by its name (docs/design/roles.md): a tag\n * whose note says what it means, on a tap too.\n */\nexport function ProtectedTag() {\n return (\n <Toggletip label=\"Protected: each person here holds their role’s protected column, which an Owner sets in Settings › Roles. Service accounts hold their role as anywhere else.\">\n <button type=\"button\" className=\"tag tag-button\">\n <Lock size={11} />\n Protected\n </button>\n </Toggletip>\n );\n}\n"],"mappings":";;;;;;;;AAOA,SAAgB,eAAe;CAC7B,OACE,oBAAC,WAAD;EAAW,OAAM;YACf,qBAAC,UAAD;GAAQ,MAAK;GAAS,WAAU;aAAhC,CACE,oBAAC,MAAD,EAAM,MAAM,GAAK,CAAA,GAAC,WAEZ;;CACC,CAAA;AAEf"}
1
+ {"version":3,"file":"protected-BL_DsZO6.js","names":[],"sources":["../../src/components/protected.tsx"],"sourcesContent":["import { Lock } from './icons';\nimport { Toggletip } from './ui';\n\n/**\n * An environment's protection, by its name (docs/design/roles.md): a tag\n * whose note says what it means, on a tap too.\n */\nexport function ProtectedTag() {\n return (\n <Toggletip label=\"Protected: each person here holds their role’s protected column, which an Owner sets in Settings › Roles. Service accounts hold their role as anywhere else.\">\n <button type=\"button\" className=\"tag tag-button\">\n <Lock size={11} />\n Protected\n </button>\n </Toggletip>\n );\n}\n"],"mappings":";;;;;;;;AAOA,SAAgB,eAAe;CAC7B,OACE,oBAAC,WAAD;EAAW,OAAM;YACf,qBAAC,UAAD;GAAQ,MAAK;GAAS,WAAU;aAAhC,CACE,oBAAC,MAAD,EAAM,MAAM,GAAK,CAAA,GAAC,WAEZ;;CACC,CAAA;AAEf"}
@@ -53,9 +53,10 @@ function canRevealSecrets(permissions) {
53
53
  * names what it touches (`affects`), so your own changes always show.
54
54
  * Someone else's change shows within that window. Nothing is decided on a
55
55
  * cached read: the server authorizes every call, so a stale screen can offer
56
- * an action the server then refuses, never grant one. The audit log and the
57
- * chain's verification are the exception, read fresh on every visit: their
58
- * whole point is to be current.
56
+ * an action the server then refuses, never grant one. The audit log is the
57
+ * exception, read fresh on every visit: its whole point is to be current.
58
+ * The chain's verification is read once a visit like the rest, and again
59
+ * after any change made here.
59
60
  */
60
61
  var FRESH_MS = 1e4;
61
62
  function createQueryClient() {
@@ -310,13 +311,16 @@ var queries = {
310
311
  }))
311
312
  }),
312
313
  /**
313
- * Whether the log holds: verified on every visit, and never waited for.
314
- * It re-reads the whole log, so it takes as long as the log is long; the
315
- * page shows the entries first and the verdict when it comes.
314
+ * Whether the log holds: verified with each visit, and rendered with the
315
+ * page, the loader's read to carry to the browser: it is not asked again on
316
+ * mount, and not for a filter change or a hover, which `FRESH_MS` covers.
317
+ * It reads what was written since the newest checkpoint, so it takes as
318
+ * long as five minutes of the log, however long the log. It never rejects:
319
+ * a check that could not run is its verdict (`unknown`).
316
320
  */
317
321
  auditChain: (client) => queryOptions({
318
322
  queryKey: [...keys.audit, "chain"],
319
- staleTime: 0,
323
+ refetchOnMount: false,
320
324
  queryFn: () => verifyChain(client)
321
325
  }),
322
326
  /** What deleting `market` or `market/prod` would take, asked afresh each time it is shown. */
@@ -338,30 +342,60 @@ var queries = {
338
342
  */
339
343
  async function verifyChain(client) {
340
344
  try {
341
- const result = await client.audit.verify();
342
- return result.ok ? {
343
- integrity: "intact",
344
- through: result.through,
345
- entries: result.entries,
346
- checkpoint: result.checkpoint,
347
- pending: result.pending ?? 0
348
- } : {
349
- integrity: "broken",
350
- through: result.through,
351
- failedAtSeq: result.failedAtSeq,
352
- author: result.author,
353
- reason: result.reason
354
- };
345
+ return chainResult(await client.audit.verify(), false);
355
346
  } catch (error) {
356
- const status = statusOf(error);
357
- if (status === 403) return { integrity: "owners-only" };
358
- return {
359
- integrity: "unknown",
360
- problem: status === void 0 ? "the request never got an answer" : `the request failed with HTTP ${status}`
361
- };
347
+ return chainUnknown(error);
362
348
  }
363
349
  }
364
350
  /**
351
+ * A verdict as the page shows it: `whole` when it comes from the walk
352
+ * from the first entry, which someone asked for, not from the newest
353
+ * checkpoint's.
354
+ */
355
+ function chainResult(result, whole) {
356
+ return result.ok ? {
357
+ integrity: "intact",
358
+ whole,
359
+ through: result.through,
360
+ entries: result.entries,
361
+ from: result.from ?? 0,
362
+ remaining: result.remaining ?? 0,
363
+ checkpoint: result.checkpoint,
364
+ pending: result.pending ?? 0
365
+ } : {
366
+ integrity: "broken",
367
+ through: result.through,
368
+ failedAtSeq: result.failedAtSeq,
369
+ author: result.author,
370
+ reason: result.reason
371
+ };
372
+ }
373
+ /**
374
+ * What the page shows, of the check from the newest checkpoint (`quick`)
375
+ * and the walk from the first entry, once someone ran it (`whole`). A break
376
+ * the walk found stands; otherwise the newer check says how the log is now,
377
+ * broken, partly checked or not checked at all; and only while it found the
378
+ * log whole too does the walk's verdict, which read further back, stand
379
+ * over it.
380
+ *
381
+ * whole broken → whole
382
+ * whole intact, quick intact with 0 remaining → whole
383
+ * whole intact, quick anything else → quick
384
+ */
385
+ function shownChain(quick, whole) {
386
+ if (whole === null || whole.integrity === "broken") return whole ?? quick;
387
+ return quick.integrity === "intact" && quick.remaining === 0 && whole.integrity === "intact" ? whole : quick;
388
+ }
389
+ /** Why the log's verdict is not known: closed to the caller, or no answer. */
390
+ function chainUnknown(error) {
391
+ const status = statusOf(error);
392
+ if (status === 403) return { integrity: "owners-only" };
393
+ return {
394
+ integrity: "unknown",
395
+ problem: status === void 0 ? "the request never got an answer" : `the request failed with HTTP ${status}`
396
+ };
397
+ }
398
+ /**
365
399
  * Who is looking, how this instance signs people in, and the projects they
366
400
  * can see: what the shell needs on every screen. For someone signed out or
367
401
  * not yet a member the project list is refused, and they get the sign-in or
@@ -459,6 +493,16 @@ async function loadEnvironment(queryClient, client, place) {
459
493
  if (secrets.ok) await others();
460
494
  return secrets;
461
495
  }
496
+ /**
497
+ * What the audit page reads: a page of the log and the verification from
498
+ * the newest checkpoint, asked together and rendered together, so the badge
499
+ * arrives with the page. The verification never fails the load: a check that
500
+ * could not run is its verdict.
501
+ */
502
+ async function loadAudit(queryClient, client, search) {
503
+ const [entries] = await Promise.all([queryClient.fetchQuery(queries.auditEntries(client, search)), queryClient.fetchQuery(queries.auditChain(client))]);
504
+ return entries;
505
+ }
462
506
  /** The directory pages' read: the directory, for owners. */
463
507
  async function loadDirectory(queryClient, client) {
464
508
  const shell = await loadShell(queryClient, client);
@@ -675,6 +719,6 @@ async function refresh(queryClient, touched) {
675
719
  await Promise.all([...touched, keys.audit].map((queryKey) => queryClient.invalidateQueries({ queryKey })));
676
720
  }
677
721
  //#endregion
678
- export { waysFor as C, isActiveAccessibleEnvironment as E, tabOpens as S, hasEnvironmentDetails as T, projectOf as _, listsAccess as a, shellOf as b, loadEnvironment as c, loadProject as d, loadServiceDirectory as f, managedProjects as g, loadSignIn as h, keys as i, loadMember as l, loadShell as m, createQueryClient as n, listsServices as o, loadSettings as p, hasAppsTab as r, loadDirectory as s, affects as t, loadPrincipal as u, queries as v, canRevealSecrets as w, signInWays as x, refresh as y };
722
+ export { isActiveAccessibleEnvironment as A, shellOf as C, waysFor as D, tabOpens as E, canRevealSecrets as O, refresh as S, signInWays as T, loadShell as _, hasAppsTab as a, projectOf as b, listsServices as c, loadEnvironment as d, loadMember as f, loadSettings as g, loadServiceDirectory as h, createQueryClient as i, hasEnvironmentDetails as k, loadAudit as l, loadProject as m, chainResult as n, keys as o, loadPrincipal as p, chainUnknown as r, listsAccess as s, affects as t, loadDirectory as u, loadSignIn as v, shownChain as w, queries as x, managedProjects as y };
679
723
 
680
- //# sourceMappingURL=queries-DEOPOpsT.js.map
724
+ //# sourceMappingURL=queries-Danu0o75.js.map