@coffre/ui 0.15.0 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/dist/audit-sentences.d.ts +56 -0
  2. package/dist/audit-sentences.js +886 -0
  3. package/dist/audit-sentences.js.map +1 -0
  4. package/dist/chunks/audit-sentence-C8NnAdjF.js +48 -0
  5. package/dist/chunks/audit-sentence-C8NnAdjF.js.map +1 -0
  6. package/dist/chunks/{connected-apps-CGUQlFMx.js → connected-apps-6sMSgQ9U.js} +5 -5
  7. package/dist/chunks/{connected-apps-CGUQlFMx.js.map → connected-apps-6sMSgQ9U.js.map} +1 -1
  8. package/dist/chunks/{delete-place-CswZ-meh.js → delete-place-T469tSN9.js} +5 -5
  9. package/dist/chunks/{delete-place-CswZ-meh.js.map → delete-place-T469tSN9.js.map} +1 -1
  10. package/dist/chunks/{directory-DrswWQLT.js → directory-B_gVf7UL.js} +18 -17
  11. package/dist/chunks/directory-B_gVf7UL.js.map +1 -0
  12. package/dist/chunks/{folders-A6sbR_PG.js → folders-CVYauIDz.js} +3 -3
  13. package/dist/chunks/{folders-A6sbR_PG.js.map → folders-CVYauIDz.js.map} +1 -1
  14. package/dist/chunks/{grants-C0cb2oii.js → grants-Dn_EW2XW.js} +8 -8
  15. package/dist/chunks/grants-Dn_EW2XW.js.map +1 -0
  16. package/dist/chunks/{multi-combobox-B3SEv1gq.js → multi-combobox-fbBRzi9z.js} +3 -3
  17. package/dist/chunks/{multi-combobox-B3SEv1gq.js.map → multi-combobox-fbBRzi9z.js.map} +1 -1
  18. package/dist/chunks/{offboarding-C1jbG_dk.js → offboarding-CXM464J_.js} +81 -80
  19. package/dist/chunks/offboarding-CXM464J_.js.map +1 -0
  20. package/dist/chunks/{page-CfhC9Hp1.js → page-Cb0ZjGda.js} +7 -12
  21. package/dist/chunks/page-Cb0ZjGda.js.map +1 -0
  22. package/dist/chunks/{personal-tokens-xC9wulhg.js → personal-tokens-CSHMlRHy.js} +7 -7
  23. package/dist/chunks/personal-tokens-CSHMlRHy.js.map +1 -0
  24. package/dist/chunks/{principal-CI17XK13.js → principal-BKJxbAtE.js} +2 -2
  25. package/dist/chunks/{principal-CI17XK13.js.map → principal-BKJxbAtE.js.map} +1 -1
  26. package/dist/chunks/{principal-page-CdSeftGD.js → principal-page-COPmTDVW.js} +132 -19
  27. package/dist/chunks/principal-page-COPmTDVW.js.map +1 -0
  28. package/dist/chunks/{project-page-CHxjBE97.js → project-page-g5_n46Nz.js} +3 -3
  29. package/dist/chunks/{project-page-CHxjBE97.js.map → project-page-g5_n46Nz.js.map} +1 -1
  30. package/dist/chunks/protected-DEWeOrmI.js +77 -0
  31. package/dist/chunks/protected-DEWeOrmI.js.map +1 -0
  32. package/dist/chunks/{queries-D1JuimTu.js → queries-D4_o-bz3.js} +22 -155
  33. package/dist/chunks/queries-D4_o-bz3.js.map +1 -0
  34. package/dist/chunks/{references-D5llUGQL.js → references-wTh_DT0M.js} +27 -23
  35. package/dist/chunks/references-wTh_DT0M.js.map +1 -0
  36. package/dist/chunks/{role-field-CoCv8wse.js → role-field-BiP09qfN.js} +5 -5
  37. package/dist/chunks/role-field-BiP09qfN.js.map +1 -0
  38. package/dist/chunks/{row-state-CYH7kZHl.js → row-state-CYhtmUkc.js} +3 -3
  39. package/dist/chunks/{row-state-CYH7kZHl.js.map → row-state-CYhtmUkc.js.map} +1 -1
  40. package/dist/chunks/{signin-errors-TlQmQe0t.js → signin-errors-BMnox7XD.js} +5 -19
  41. package/dist/chunks/signin-errors-BMnox7XD.js.map +1 -0
  42. package/dist/chunks/{theme-rF44Wbmm.js → theme-imSolE1q.js} +3 -3
  43. package/dist/chunks/{theme-rF44Wbmm.js.map → theme-imSolE1q.js.map} +1 -1
  44. package/dist/chunks/{ui-CGdORVzW.js → ui-Q_Eczt7m.js} +7 -3
  45. package/dist/chunks/{ui-CGdORVzW.js.map → ui-Q_Eczt7m.js.map} +1 -1
  46. package/dist/chunks/{use-action-BxrHTBZw.js → use-action-BfnN-De2.js} +3 -3
  47. package/dist/chunks/{use-action-BxrHTBZw.js.map → use-action-BfnN-De2.js.map} +1 -1
  48. package/dist/chunks/{use-change-BorW2R6C.js → use-change-Cc0X4sF3.js} +6 -4
  49. package/dist/chunks/use-change-Cc0X4sF3.js.map +1 -0
  50. package/dist/chunks/{use-roles-BZnJ9Cq0.js → use-roles-stcv2QFj.js} +13 -56
  51. package/dist/chunks/use-roles-stcv2QFj.js.map +1 -0
  52. package/dist/chunks/{use-shell-CPskgi1k.js → use-shell-DMhLa2sh.js} +3 -3
  53. package/dist/chunks/{use-shell-CPskgi1k.js.map → use-shell-DMhLa2sh.js.map} +1 -1
  54. package/dist/index.d.ts +23 -55
  55. package/dist/index.js +12 -31
  56. package/dist/index.js.map +1 -1
  57. package/dist/pages/account.js +12 -12
  58. package/dist/pages/account.js.map +1 -1
  59. package/dist/pages/approval.js +2 -2
  60. package/dist/pages/audit.js +173 -196
  61. package/dist/pages/audit.js.map +1 -1
  62. package/dist/pages/device-login.js +2 -2
  63. package/dist/pages/environment.js +445 -252
  64. package/dist/pages/environment.js.map +1 -1
  65. package/dist/pages/login.js +6 -15
  66. package/dist/pages/login.js.map +1 -1
  67. package/dist/pages/oauth-authorize.js +2 -2
  68. package/dist/pages/project-access.js +11 -11
  69. package/dist/pages/project-environments.js +359 -28
  70. package/dist/pages/project-environments.js.map +1 -1
  71. package/dist/pages/project-settings.js +8 -8
  72. package/dist/pages/project.js +3 -3
  73. package/dist/pages/projects.js +8 -8
  74. package/dist/pages/service-account.js +19 -16
  75. package/dist/pages/service-account.js.map +1 -1
  76. package/dist/pages/service-accounts.js +6 -7
  77. package/dist/pages/service-accounts.js.map +1 -1
  78. package/dist/pages/settings.d.ts +1 -6
  79. package/dist/pages/settings.js +155 -286
  80. package/dist/pages/settings.js.map +1 -1
  81. package/dist/pages/unregistered.js +2 -2
  82. package/dist/pages/user.js +7 -8
  83. package/dist/pages/user.js.map +1 -1
  84. package/dist/pages/users.js +6 -7
  85. package/dist/pages/users.js.map +1 -1
  86. package/package.json +8 -3
  87. package/src/components/actions-log.tsx +8 -61
  88. package/src/components/directory.tsx +10 -9
  89. package/src/components/grants.tsx +2 -2
  90. package/src/components/icons.tsx +0 -2
  91. package/src/components/offboarding.tsx +9 -16
  92. package/src/components/page.tsx +2 -3
  93. package/src/components/personal-tokens.tsx +5 -2
  94. package/src/components/principal-page.tsx +5 -4
  95. package/src/components/protected.tsx +39 -52
  96. package/src/components/references.tsx +18 -7
  97. package/src/components/role-editor.tsx +68 -99
  98. package/src/components/role-field.tsx +1 -1
  99. package/src/components/trusted-workloads.tsx +6 -5
  100. package/src/components/ui.tsx +5 -0
  101. package/src/lib/audit-proofs.ts +51 -0
  102. package/src/lib/audit-sentences.ts +490 -529
  103. package/src/lib/bindings.ts +6 -0
  104. package/src/lib/changes.ts +3 -1
  105. package/src/lib/coffre.ts +2 -2
  106. package/src/lib/queries.ts +19 -168
  107. package/src/lib/reveal.ts +32 -5
  108. package/src/lib/roles.ts +10 -36
  109. package/src/lib/row-reads.ts +2 -2
  110. package/src/lib/signin-errors.ts +5 -33
  111. package/src/options.ts +3 -19
  112. package/src/pages/account.tsx +1 -1
  113. package/src/pages/audit.tsx +151 -228
  114. package/src/pages/environment.tsx +373 -247
  115. package/src/pages/login.tsx +2 -4
  116. package/src/pages/project-environments.tsx +322 -20
  117. package/src/pages/service-accounts.tsx +1 -1
  118. package/src/pages/settings.tsx +49 -134
  119. package/src/pages/user.tsx +2 -2
  120. package/src/pages/users.tsx +1 -1
  121. package/src/parity.ts +11 -20
  122. package/src/styles/globals.css +107 -273
  123. package/dist/chunks/actions-log-DupYCEyV.js +0 -1134
  124. package/dist/chunks/actions-log-DupYCEyV.js.map +0 -1
  125. package/dist/chunks/directory-DrswWQLT.js.map +0 -1
  126. package/dist/chunks/environment-actions-8rL9Cw6X.js +0 -576
  127. package/dist/chunks/environment-actions-8rL9Cw6X.js.map +0 -1
  128. package/dist/chunks/grants-C0cb2oii.js.map +0 -1
  129. package/dist/chunks/offboarding-C1jbG_dk.js.map +0 -1
  130. package/dist/chunks/page-CfhC9Hp1.js.map +0 -1
  131. package/dist/chunks/personal-tokens-xC9wulhg.js.map +0 -1
  132. package/dist/chunks/principal-page-CdSeftGD.js.map +0 -1
  133. package/dist/chunks/queries-D1JuimTu.js.map +0 -1
  134. package/dist/chunks/references-D5llUGQL.js.map +0 -1
  135. package/dist/chunks/role-field-CoCv8wse.js.map +0 -1
  136. package/dist/chunks/signin-errors-TlQmQe0t.js.map +0 -1
  137. package/dist/chunks/use-change-BorW2R6C.js.map +0 -1
  138. package/dist/chunks/use-roles-BZnJ9Cq0.js.map +0 -1
  139. package/src/components/environment-actions.tsx +0 -508
@@ -1,4 +1,5 @@
1
1
  import { CoffreError, type BindingPlan, type BindingView } from '@coffre/client';
2
+ import { credentialScopeInWords } from '@coffre/core/access';
2
3
  import { claimValues, fullRef, githubReusable, githubWorkflow, gitlabProject, type BearerProfile, type BindingClaims } from '@coffre/core/workloads';
3
4
 
4
5
  /**
@@ -30,6 +31,11 @@ export function summary(binding: Pick<BindingView, 'profile' | 'issuer' | 'claim
30
31
  return { title: issuerName(binding.issuer), detail: `sub ${claims.sub}` };
31
32
  }
32
33
 
34
+ /** What a binding's credentials reach, in words; a null scope, one 0.4 made and never sealed, reaches nothing. */
35
+ export function reached(scope: BindingView['scope']): string {
36
+ return credentialScopeInWords(scope ?? {});
37
+ }
38
+
33
39
  /** An issuer as a title: its host, when it is a URL; a binding that carries its keys may name any string. */
34
40
  function issuerName(issuer: string): string {
35
41
  try {
@@ -564,8 +564,9 @@ export function saveSecrets(
564
564
  reference: null,
565
565
  archived: false,
566
566
  version: inherited ? null : (entry?.version ?? 0) + 1,
567
- // Known once the list is read back: until then, nothing regenerates it.
567
+ // Known once the list is read back: until then, nothing regenerates it, and no value read is shown.
568
568
  versionId: null,
569
+ secret: null,
569
570
  updatedAt: now,
570
571
  updatedBy: author,
571
572
  generated: generations.get(key) ?? null,
@@ -681,6 +682,7 @@ export function regenerateSecret(
681
682
  reference: null,
682
683
  version: inherited ? null : (entry.version ?? 0) + 1,
683
684
  versionId: null,
685
+ secret: null,
684
686
  updatedAt: now,
685
687
  updatedBy: author,
686
688
  generated: vars.generated,
package/src/lib/coffre.ts CHANGED
@@ -31,8 +31,8 @@ export function failureMessage(error: unknown): string {
31
31
  if (!(error instanceof CoffreError)) return 'The request could not be sent. Nothing was changed.';
32
32
  if (error.status === 401) return 'Your session has ended. Sign in again, then retry.';
33
33
  if (error.code === 'cross_origin') return 'coffre refused a change that did not come from this page. Reload, then retry.';
34
- // The vault's own rule, which the app could not foresee (one removed by someone else, say), in its words.
35
- if (error.code === 'vault_refused' && error.reason === 'not_allowed') return error.message.replace(/^the vault refused: /, '');
34
+ // Only an Owner of the whole instance makes, changes or removes an Owner: the API's sentence says so, where a 403's would say a grant is missing.
35
+ if (error.code === 'vault_refused' && error.reason === 'not_allowed') return error.message;
36
36
  if (error.status === 403) {
37
37
  return 'You hold no grant that covers this. Someone with grant.manage on the project can add one.';
38
38
  }
@@ -101,7 +101,7 @@ function grantRows(members: Member[]): GrantRow[] {
101
101
 
102
102
  function listDirectory(client: CoffreClient) {
103
103
  return uiResult(async () => {
104
- const { members, removed, reads } = await client.members.list();
104
+ const { members, removed } = await client.members.list();
105
105
  const principals: DirectoryPrincipal[] = members.map(
106
106
  ({ principalType, principalId, instanceRole, scope, tampered, managed, declared, grants }) => ({
107
107
  principalType,
@@ -114,8 +114,7 @@ function listDirectory(client: CoffreClient) {
114
114
  grants: grants.map(({ project, environment }) => ({ project, environment })),
115
115
  }),
116
116
  );
117
- // How far reads are listed, under 0.15's log, which the counts of what the removed saw are as of (T166).
118
- return { principals, removed, ...(reads === undefined ? {} : { reads }) };
117
+ return { principals, removed };
119
118
  });
120
119
  }
121
120
 
@@ -126,12 +125,6 @@ export type ProjectsResult = Awaited<ReturnType<typeof readProjects>>;
126
125
 
127
126
  export type AuditSearch = { decision?: 'deny'; actorId?: string; detail?: '1' };
128
127
 
129
- /** Settings' tabs past the first, General, by their `?tab=`. */
130
- export const SETTINGS_TABS = ['roles', 'keys'] as const;
131
- export type SettingsTab = (typeof SETTINGS_TABS)[number];
132
- /** Settings' search: its tab, and on Roles, `roles=global` for the global roles rather than the project roles. */
133
- export type SettingsSearch = { tab?: SettingsTab; roles?: 'global' };
134
-
135
128
  export const AUDIT_PAGE_SIZE = 200;
136
129
 
137
130
  export const queries = {
@@ -303,9 +296,9 @@ export const queries = {
303
296
  queryOptions({ queryKey: keys.apps, queryFn: () => uiResult(() => client.apps.list()) }),
304
297
 
305
298
  /**
306
- * What the keys an operator keeps are checked against: the vault's ID and
307
- * the app key's fingerprint, no secret. Null for anyone but owners and root
308
- * admins, who alone may ask.
299
+ * What the keys an operator keeps are checked against: the vault's keys
300
+ * by ID and its signing keys' checks, no secret. Null for anyone but
301
+ * those who run the instance, who alone may ask.
309
302
  */
310
303
  auditKeys: (client: CoffreClient, allowed: boolean) =>
311
304
  queryOptions({
@@ -328,7 +321,7 @@ export const queries = {
328
321
  roles: (client: CoffreClient) =>
329
322
  queryOptions({ queryKey: keys.roles, queryFn: () => uiResult(() => client.roles.list()) }),
330
323
 
331
- /** A page of the log, as filtered: always read fresh. */
324
+ /** A page of the log, as filtered, its entries proven against the head it names: always read fresh. */
332
325
  auditEntries: (client: CoffreClient, search: AuditSearch) =>
333
326
  queryOptions({
334
327
  queryKey: [...keys.audit, 'entries', search],
@@ -341,22 +334,10 @@ export const queries = {
341
334
  decision: search.decision,
342
335
  actor: search.actorId,
343
336
  detail: search.detail,
344
- // What 0.15's sealed log alone records too: sign-ins through trust bindings, tokens' issues, revokes and sign-outs.
345
- sealed: '1',
346
337
  }),
347
338
  ),
348
339
  }),
349
340
 
350
- /**
351
- * Whether the log holds: verified with each visit, and rendered with the
352
- * page, the loader's read to carry to the browser: it is not asked again on
353
- * mount, and not for a filter change or a hover, which `FRESH_MS` covers.
354
- * It reads what was written since the newest checkpoint, so it takes as
355
- * long as five minutes of the log, however long the log. It never rejects:
356
- * a check that could not run is its verdict (`unknown`).
357
- */
358
- auditChain: (client: CoffreClient) =>
359
- queryOptions({ queryKey: [...keys.audit, 'chain'], refetchOnMount: false, queryFn: () => verifyChain(client) }),
360
341
  /** What deleting `market` or `market/prod` would take, asked afresh each time it is shown. */
361
342
  deletion: (client: CoffreClient, path: string) =>
362
343
  queryOptions({
@@ -373,129 +354,6 @@ export const queries = {
373
354
  }),
374
355
  };
375
356
 
376
- /**
377
- * Whether the log holds, or why that is not known. Verifying is for those
378
- * who read the whole log (an Auditor, Admin or Owner whose scope narrows
379
- * nothing): anyone else reads their projects' part of it, and a part cannot be
380
- * checked as a chain, so for them it is a fact about the page, not a fault.
381
- */
382
- async function verifyChain(client: CoffreClient) {
383
- const [chain, trees] = await Promise.allSettled([client.audit.verify(), client.audit.verifyTrees()]);
384
- if (chain.status === 'rejected') return chainUnknown(chain.reason);
385
- return withTrees(chain.value, false, trees);
386
- }
387
-
388
- /**
389
- * 0.14's verdict with 0.15's check beside it, each settled apart: a check
390
- * of 0.15's log that could not run says so beside 0.14's verdict, never in
391
- * its place, on a visit and after a walk alike.
392
- */
393
- export function withTrees(chain: Awaited<ReturnType<CoffreClient['audit']['verify']>>, whole: boolean, trees: PromiseSettledResult<TreesResult>) {
394
- if (trees.status === 'fulfilled') return chainResult(chain, whole, trees.value);
395
- // Whatever turned it away, a refusal included (access narrowed between the two, review r11): not checked, never "Verified".
396
- const failed = chainUnknown(trees.reason);
397
- const problem = failed.integrity === 'unknown' ? failed.problem : 'the request was refused (HTTP 403)';
398
- return { ...chainResult(chain, whole), ...(chain.ok ? { treesFailed: `coffre could not check the sealed log: ${problem}` } : {}) };
399
- }
400
-
401
- /** 0.15's log as its check found it (`audit.verifyTrees`): `kept` false where the instance keeps 0.14's alone. */
402
- export type TreesResult = Awaited<ReturnType<CoffreClient['audit']['verifyTrees']>>;
403
-
404
- /**
405
- * 0.15's log checked whole, as a walk from the first entry has it: its trees
406
- * from the newest checkpoint, and the reads the pages list held to the uses
407
- * it sealed (`audit.verifyReads`, T166), whose problems are the log's.
408
- */
409
- export async function wholeTrees(client: CoffreClient): Promise<TreesResult> {
410
- const [trees, reads] = await Promise.all([client.audit.verifyTrees(), client.audit.verifyReads()]);
411
- if (!trees.kept || !reads.kept || reads.ok) return trees;
412
- return { ...trees, ok: false, problems: [...trees.problems, ...reads.problems.map((problem) => `the reads' listing: ${problem}`)] };
413
- }
414
-
415
- /**
416
- * A verdict as the page shows it: `whole` when it comes from the walk
417
- * from the first entry, which someone asked for, not from the newest
418
- * checkpoint's. Where the instance keeps 0.15's log too, its check
419
- * (`trees`) is part of it: what it finds breaks the log as 0.14's would.
420
- */
421
- export function chainResult(result: Awaited<ReturnType<CoffreClient['audit']['verify']>>, whole: boolean, trees: TreesResult = { kept: false }) {
422
- // More entries above the newest checkpoint than a check reads: a checkpointer behind, not a break (review r4 of W240).
423
- const behind = trees.kept && trees.capped;
424
- if (result.ok && trees.kept && trees.problems.length > 0) {
425
- const more = trees.problems.length - 1;
426
- return {
427
- integrity: 'broken' as const,
428
- through: result.through,
429
- failedAtSeq: null,
430
- author: 'vault' as const,
431
- reason: `the sealed log: ${trees.problems[0]}${more > 0 ? ` (and ${more} more)` : ''}`,
432
- };
433
- }
434
- return result.ok
435
- ? {
436
- integrity: 'intact' as const,
437
- whole,
438
- through: result.through,
439
- entries: result.entries,
440
- // A server older than 0.10.1 checked from the first entry, and reached the head.
441
- from: result.from ?? 0,
442
- remaining: result.remaining ?? 0,
443
- checkpoint: result.checkpoint,
444
- pending: result.pending ?? 0,
445
- /**
446
- * Why the check of 0.15's log could not run, or stopped short of its head (`treesBehind`): the chain's verdict
447
- * stands, the sealed log's is not known.
448
- */
449
- treesFailed: behind
450
- ? `coffre checked the sealed log's first ${trees.unsealed.toLocaleString('en')} entries above its newest checkpoint, not the rest: the checkpointer is behind`
451
- : (null as string | null),
452
- /** The sealed log checked, but not to its head: more entries wait above its newest checkpoint than a check reads. */
453
- treesBehind: behind,
454
- /** 0.15's log, where it is kept: the newest pair its check reached. */
455
- trees: trees.kept ? { checkpoint: trees.checkpoint, pending: trees.capped ? trees.unsealed : 0 } : null,
456
- }
457
- : {
458
- integrity: 'broken' as const,
459
- through: result.through,
460
- failedAtSeq: result.failedAtSeq,
461
- author: result.author,
462
- reason: result.reason,
463
- };
464
- }
465
-
466
- /**
467
- * What the page shows, of the check from the newest checkpoint (`quick`)
468
- * and the walk from the first entry, once someone ran it (`whole`). A break
469
- * the walk found stands; otherwise the newer check says how the log is now,
470
- * broken, partly checked or not checked at all; and only while it found the
471
- * log whole too does the walk's verdict, which read further back, stand
472
- * over it.
473
- *
474
- * whole broken → whole
475
- * whole intact, quick intact, 0 remaining, sealed log checked → whole
476
- * whole intact, quick anything else → quick
477
- *
478
- * A newer check that could not check the sealed log (review r10) is
479
- * "anything else": the walk's seal would stand over a log nobody can now
480
- * say holds.
481
- */
482
- export function shownChain(quick: ChainResult, whole: ChainResult | null): ChainResult {
483
- if (whole === null || whole.integrity === 'broken') return whole ?? quick;
484
- return quick.integrity === 'intact' && quick.remaining === 0 && quick.treesFailed === null && whole.integrity === 'intact' ? whole : quick;
485
- }
486
-
487
- /** Why the log's verdict is not known: closed to the caller, or no answer. */
488
- export function chainUnknown(error: unknown) {
489
- const status = statusOf(error);
490
- if (status === 403) return { integrity: 'owners-only' as const };
491
- return {
492
- integrity: 'unknown' as const,
493
- problem: status === undefined ? 'the request never got an answer' : `the request failed with HTTP ${status}`,
494
- };
495
- }
496
-
497
- export type ChainResult = Awaited<ReturnType<typeof verifyChain>>;
498
-
499
357
  /**
500
358
  * Who is looking, how this instance signs people in, and the projects they
501
359
  * can see: what the shell needs on every screen. For someone signed out or
@@ -611,17 +469,11 @@ export async function loadEnvironment(queryClient: QueryClient, client: CoffreCl
611
469
  }
612
470
 
613
471
  /**
614
- * What the audit page reads: a page of the log and the verification from
615
- * the newest checkpoint, asked together and rendered together, so the badge
616
- * arrives with the page. The verification never fails the load: a check that
617
- * could not run is its verdict.
472
+ * What the audit page reads: a page of the log, each entry with its proof
473
+ * against the head the vault signed, which the same answer carries.
618
474
  */
619
475
  export async function loadAudit(queryClient: QueryClient, client: CoffreClient, search: AuditSearch) {
620
- const [entries] = await Promise.all([
621
- queryClient.fetchQuery(queries.auditEntries(client, search)),
622
- queryClient.fetchQuery(queries.auditChain(client)),
623
- ]);
624
- return entries;
476
+ return queryClient.fetchQuery(queries.auditEntries(client, search));
625
477
  }
626
478
 
627
479
  /** The directory pages' read: the directory, for owners. */
@@ -631,16 +483,14 @@ export async function loadDirectory(queryClient: QueryClient, client: CoffreClie
631
483
  }
632
484
 
633
485
  /** The instance's settings: the directory's counts, where people set up service accounts, and what its keys are checked against. */
634
- /** What a tab of Settings reads, its own alone: General the directory and the instance's settings, Roles the roles, project and global alike, Keys the key checks. */
635
- export async function loadSettings(queryClient: QueryClient, client: CoffreClient, tab: SettingsTab | undefined) {
636
- const { capabilities } = await loadShell(queryClient, client);
637
- if (tab === undefined) {
638
- await Promise.all([loadDirectory(queryClient, client), queryClient.fetchQuery(queries.settings(client, capabilities.runsInstance))]);
639
- } else if (tab === 'keys') {
640
- await queryClient.fetchQuery(queries.auditKeys(client, capabilities.runsInstance));
641
- } else {
642
- await queryClient.fetchQuery(queries.roles(client));
643
- }
486
+ export async function loadSettings(queryClient: QueryClient, client: CoffreClient) {
487
+ const shell = await loadShell(queryClient, client);
488
+ await Promise.all([
489
+ loadDirectory(queryClient, client),
490
+ queryClient.fetchQuery(queries.settings(client, shell.capabilities.runsInstance)),
491
+ queryClient.fetchQuery(queries.auditKeys(client, shell.capabilities.runsInstance)),
492
+ queryClient.fetchQuery(queries.roles(client)),
493
+ ]);
644
494
  }
645
495
 
646
496
  /** Whether the Service accounts page lists anyone: to admins and owners, and to whoever sets one up, those they manage. */
@@ -766,7 +616,8 @@ export function signInWays(shell: Shell, access: MemberAccessResult): { tokens:
766
616
  */
767
617
  export function hasAppsTab(shell: Shell, report: MemberReport): boolean {
768
618
  const found = report?.ok === true ? report.report : null;
769
- return Boolean(shell.features.mcp) && shell.capabilities.runsInstance && found !== null && found.status !== 'removed';
619
+ // A report that does not list their apps (0.16's, so far) has nothing for the tab to show.
620
+ return Boolean(shell.features.mcp) && shell.capabilities.runsInstance && found !== null && found.status !== 'removed' && found.apps !== null;
770
621
  }
771
622
 
772
623
  export function managedProjects(projects: ProjectSummary[]): ProjectSummary[] {
package/src/lib/reveal.ts CHANGED
@@ -10,10 +10,12 @@ export type Reveal = {
10
10
  value: string;
11
11
  version: number | null;
12
12
  /**
13
- * Where the value was held, when that can change under one version
14
- * number: a fork's key reset to its parent's reads another secret's v1.
13
+ * The id of the secret the value was held in. One number can name two
14
+ * values: a fork's key reset to its parent's reads another secret's v1,
15
+ * and an override written after reads its own next number, which the
16
+ * parent's may have too.
15
17
  */
16
- from?: string;
18
+ from: string | null;
17
19
  /** When the read happened, in ms since the epoch; drives the auto-hide. */
18
20
  at: number;
19
21
  };
@@ -21,7 +23,32 @@ export type Reveal = {
21
23
  export function revealIsCurrent(
22
24
  reveal: Reveal | null,
23
25
  currentVersion: number | null,
24
- currentFrom?: string,
26
+ currentFrom: string | null,
25
27
  ): reveal is Reveal {
26
- return reveal !== null && reveal.version === currentVersion && reveal.from === currentFrom;
28
+ return reveal !== null && reveal.from !== null && reveal.version === currentVersion && reveal.from === currentFrom;
29
+ }
30
+
31
+ /** What a read opened: the value, and the version it opened, by number and by the secret it is held in. */
32
+ export type Read = { value: string; version: number | null; from: string | null };
33
+
34
+ /**
35
+ * A value read for the row `row` was when asked, stamped with the version it
36
+ * opened. A read that opened another number than the row's has outrun the
37
+ * listing, or the listing it: `refetch` brings the listing up to date first,
38
+ * so that once the value shows, the row says its number too. If the listing
39
+ * has moved past it by then, the value hides, as it is no longer the value.
40
+ *
41
+ * It is stamped with the secret the read says it opened, never the row's:
42
+ * a read across a reset, an override or a repointed reference opened
43
+ * another secret, maybe at the very number the row shows by then, and
44
+ * hides rather than show that secret's value as this one's.
45
+ */
46
+ export async function stampedRead(
47
+ row: { version: number | null; from: string | null },
48
+ read: () => Promise<Read>,
49
+ refetch: () => Promise<unknown>,
50
+ ): Promise<Reveal> {
51
+ const { value, version, from } = await read();
52
+ if (version !== row.version || from !== row.from) await refetch();
53
+ return { value, version, from, at: Date.now() };
27
54
  }
package/src/lib/roles.ts CHANGED
@@ -17,16 +17,16 @@ import {
17
17
  * `GET /api/roles`; until it is, the roles as they ship stand in.
18
18
  */
19
19
 
20
- /** Every permission in words, in the catalogue's order, what a short label leaves out, and its word on a role's card, under its row's. */
21
- export const PERMISSION_WORDS: Record<Permission, { label: string; note?: string; verb: string; short: string }> = {
22
- 'secret.read': { label: 'Read values', verb: 'read values', short: 'Read' },
23
- 'secret.use': { label: 'Use values', note: 'placeholders, the proxy', verb: 'use values', short: 'Use' },
24
- 'secret.write': { label: 'Write values', verb: 'write values', short: 'Write' },
25
- 'secret.archive': { label: 'Retire values', verb: 'retire values', short: 'Retire' },
26
- 'audit.read': { label: 'Read the log', verb: 'read the log', short: 'Read' },
27
- 'environment.manage': { label: 'Manage environments', verb: 'manage environments', short: 'Environments' },
28
- 'grant.manage': { label: 'Manage access', verb: 'manage access', short: 'Access' },
29
- 'project.manage': { label: 'Manage the project', verb: 'manage the project', short: 'Project' },
20
+ /** Every permission in words, in the catalogue's order, and what a short label leaves out. */
21
+ export const PERMISSION_WORDS: Record<Permission, { label: string; note?: string; verb: string }> = {
22
+ 'secret.read': { label: 'Read values', verb: 'read values' },
23
+ 'secret.use': { label: 'Use values', note: 'placeholders, the proxy', verb: 'use values' },
24
+ 'secret.write': { label: 'Write values', verb: 'write values' },
25
+ 'secret.archive': { label: 'Retire values', verb: 'retire values' },
26
+ 'audit.read': { label: 'Read the log', verb: 'read the log' },
27
+ 'environment.manage': { label: 'Manage environments', verb: 'manage environments' },
28
+ 'grant.manage': { label: 'Manage access', verb: 'manage access' },
29
+ 'project.manage': { label: 'Manage the project', verb: 'manage the project' },
30
30
  };
31
31
 
32
32
  /** The rows of a role's grid: secrets first, as a role is read, then the log, then what only a project holds. */
@@ -45,32 +45,6 @@ export function projectWide(permission: Permission): boolean {
45
45
  return PROJECT_ONLY_PERMISSIONS.includes(permission);
46
46
  }
47
47
 
48
- /**
49
- * A role card's rows, the grid's permissions in its order, each on every
50
- * card, so that a permission sits in the same place on all of them:
51
- *
52
- * Values Read Use Write Retire
53
- * Log Read
54
- * Manage Environments Access Project
55
- */
56
- export const CARD_ROWS: readonly { name: string; permissions: readonly Permission[] }[] = [
57
- { name: 'Values', permissions: ['secret.read', 'secret.use', 'secret.write', 'secret.archive'] },
58
- { name: 'Log', permissions: ['audit.read'] },
59
- { name: 'Manage', permissions: ['environment.manage', 'grant.manage', 'project.manage'] },
60
- ];
61
-
62
- /**
63
- * Where a role holds a permission: everywhere, only outside protected
64
- * environments (Developer's Read values), or nowhere. A project-wide one
65
- * held is held everywhere: a project is never protected.
66
- */
67
- export type Reach = 'everywhere' | 'unprotected' | 'nowhere';
68
-
69
- export function reachOf(role: Pick<RoleDefinition, 'permissions' | 'protected'>, permission: Permission): Reach {
70
- if (!role.permissions.includes(permission)) return 'nowhere';
71
- return projectWide(permission) || role.protected.includes(permission) ? 'everywhere' : 'unprotected';
72
- }
73
-
74
48
  /** A role's two columns, as the grid edits them. */
75
49
  export type Columns = { permissions: Permission[]; protected: Permission[] };
76
50
  export type Column = 'normal' | 'protected';
@@ -70,7 +70,7 @@ export function revealToggleDisabled(state: RowReads, shown: Reveal | null): boo
70
70
  * whose reason the row says. It always opens: writing a value takes no read
71
71
  * of the one it replaces.
72
72
  */
73
- export async function valueToEdit(row: { value: string | null; readable: boolean }, read: () => Promise<string | null>): Promise<string | null> {
74
- if (row.value !== null) return row.value;
73
+ export async function valueToEdit<T>(row: { value: string | null; readable: boolean }, read: () => Promise<T | null>, listed: (value: string) => T): Promise<T | null> {
74
+ if (row.value !== null) return listed(row.value);
75
75
  return row.readable ? read() : null;
76
76
  }
@@ -27,51 +27,23 @@ const MESSAGES: Record<string, string> = {
27
27
  link_session: 'Your session changed while linking. Sign in again, then retry.',
28
28
  };
29
29
 
30
- /**
31
- * Where an email already signs in, for `account_mismatch`: the providers by
32
- * the label the sign-in page shows them under, and the one just tried. What
33
- * the visitor may know: the provider has just verified the email is theirs.
34
- */
35
- export type Already = { providers: readonly string[]; via?: string };
36
-
37
- export function signinErrorMessage(code: string | undefined, already?: Already): string | null {
30
+ export function signinErrorMessage(code: string | undefined): string | null {
38
31
  if (code === undefined) return null;
39
- if (code === 'account_mismatch' && already !== undefined && already.providers.length > 0) return mismatch(already);
40
32
  return MESSAGES[code] ?? 'The sign-in did not complete. Try again.';
41
33
  }
42
34
 
43
- /** "Your email already signs in with GitHub. Sign in with GitHub, then link this account from your account page." */
44
- function mismatch({ providers, via }: Already): string {
45
- const link = 'then link this account from your account page.';
46
- // The same provider, another account of it: a second GitHub account, say.
47
- if (providers.length === 1 && providers[0] === via) {
48
- return `Your email already signs in with another ${via} account. Sign in with that one, ${link}`;
49
- }
50
- const named = providers.map((provider) => (provider === via ? `another ${provider} account` : provider));
51
- const list = named.length < 3 ? named.join(' and ') : `${named.slice(0, -1).join(', ')} and ${named.at(-1)}`;
52
- return named.length === 1
53
- ? `Your email already signs in with ${list}. Sign in with ${list}, ${link}`
54
- : `Your email already signs in with ${list}. Sign in with one of them, ${link}`;
55
- }
56
-
57
- export type LoginSearch = { next?: string; error?: string; with?: string; via?: string };
58
-
59
- /** A sign-in provider's id, as the instance configures it. */
60
- const PROVIDER_ID = /^[a-z0-9_-]{1,40}$/;
35
+ export type LoginSearch = { next?: string; error?: string };
61
36
 
62
37
  /**
63
38
  * `/login`'s search: where to resume after signing in, same-origin paths
64
39
  * only, since an absolute URL accepted here would make the sign-in page an
65
- * open redirect; and the sign-in's `error`, with account_mismatch's `with`
66
- * and `via`, provider ids, shown once, then taken out of the URL.
40
+ * open redirect; and the sign-in's `error`, shown once, then taken out of
41
+ * the URL.
67
42
  */
68
43
  export function loginSearch(search: Record<string, unknown>): LoginSearch {
69
44
  const out: LoginSearch = {};
70
- const { next, error, via } = search;
45
+ const { next, error } = search;
71
46
  if (typeof next === 'string' && next.startsWith('/') && !next.startsWith('//')) out.next = next;
72
47
  if (typeof error === 'string' && /^[a-z_]{1,40}$/.test(error)) out.error = error;
73
- const providers = typeof search.with === 'string' ? search.with.split(',').filter((id) => PROVIDER_ID.test(id)).slice(0, 8) : [];
74
- if (providers.length > 0) out.with = providers.join(',');
75
- if (typeof via === 'string' && PROVIDER_ID.test(via)) out.via = via;
76
48
  return out;
77
49
  }
package/src/options.ts CHANGED
@@ -32,15 +32,12 @@ import {
32
32
  loadProject,
33
33
  loadServiceDirectory,
34
34
  loadSettings,
35
- SETTINGS_TABS,
36
35
  loadSignIn,
37
36
  loadShell,
38
37
  projectOf,
39
38
  queries,
40
39
  tabOpens,
41
40
  type AuditSearch,
42
- type SettingsSearch,
43
- type SettingsTab,
44
41
  type Freshness,
45
42
  } from './lib/queries';
46
43
  import type { Permission } from './shared/models';
@@ -281,27 +278,14 @@ export const serviceAccountActivity = {
281
278
  },
282
279
  };
283
280
 
284
- /**
285
- * `/settings`, its tabs by `?tab=`: General, then Roles, the project roles
286
- * or with `roles=global` the global ones, and Keys. One route, so a
287
- * deployment mounts no file per tab; each tab reads its own alone.
288
- */
281
+ /** `/settings`. */
289
282
  export const settings = {
290
- validateSearch: (search: Record<string, unknown>): SettingsSearch => {
291
- // The old Instance roles tab, a link someone shared.
292
- if (search.tab === 'instance-roles') return { tab: 'roles', roles: 'global' };
293
- const tab = SETTINGS_TABS.find((each) => each === search.tab);
294
- return { tab, roles: tab === 'roles' && search.roles === 'global' ? 'global' : undefined };
295
- },
296
- loaderDeps: ({ search }: { search: { tab?: SettingsTab } }) => ({ tab: search.tab }),
297
283
  // Instance facts come from the directory and the key checks, which only
298
284
  // owners may read. Asking on everyone's behalf would write a refusal to the
299
285
  // audit log for every user who opens the page, so they are only asked for them.
300
- // Keys, a tab they alone see, sends anyone else to the first.
301
- loader: async ({ context, deps }: Loader & { deps: { tab?: SettingsTab } }) => {
286
+ loader: ({ context }: Loader) => {
302
287
  const { coffre, queryClient } = coffreOf(context);
303
- if (deps.tab === 'keys' && !(await loadShell(queryClient, coffre)).capabilities.runsInstance) throw redirect({ to: '/settings' });
304
- return loadSettings(queryClient, coffre, deps.tab);
288
+ return loadSettings(queryClient, coffre);
305
289
  },
306
290
  };
307
291
 
@@ -87,7 +87,7 @@ export function AccountProfilePage() {
87
87
  </Fact>
88
88
  <Fact label="Kind">{principal.type === 'user' ? 'User' : 'Token'}</Fact>
89
89
  {principal.type === 'user' && (
90
- <Fact label="Global role">
90
+ <Fact label="Role">
91
91
  <InstanceRole
92
92
  principal={{
93
93
  principalType: 'user',