@coffre/ui 0.6.0 → 0.6.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 (103) hide show
  1. package/dist/chunks/{affordances-D0GyCT-I.js → affordances-Dtyha68j.js} +10 -2
  2. package/dist/chunks/{affordances-D0GyCT-I.js.map → affordances-Dtyha68j.js.map} +1 -1
  3. package/dist/chunks/{audit-sentence-CUUMshIp.js → audit-sentence-BVv_9_nq.js} +2 -2
  4. package/dist/chunks/{audit-sentence-CUUMshIp.js.map → audit-sentence-BVv_9_nq.js.map} +1 -1
  5. package/dist/chunks/{connected-apps-IP0KfUjo.js → connected-apps-rBF9XUob.js} +4 -4
  6. package/dist/chunks/{connected-apps-IP0KfUjo.js.map → connected-apps-rBF9XUob.js.map} +1 -1
  7. package/dist/chunks/{delete-place-CVv6CN5y.js → delete-place-CkGezx5R.js} +4 -4
  8. package/dist/chunks/{delete-place-CVv6CN5y.js.map → delete-place-CkGezx5R.js.map} +1 -1
  9. package/dist/chunks/{directory-pMVS1m-c.js → directory-SRN01yP6.js} +38 -32
  10. package/dist/chunks/directory-SRN01yP6.js.map +1 -0
  11. package/dist/chunks/{folders-hR2Lnk0k.js → folders-Dw240WMJ.js} +2 -2
  12. package/dist/chunks/{folders-hR2Lnk0k.js.map → folders-Dw240WMJ.js.map} +1 -1
  13. package/dist/chunks/{grants-CgC8Ybhu.js → grants-1E1vqkM0.js} +5 -5
  14. package/dist/chunks/{grants-CgC8Ybhu.js.map → grants-1E1vqkM0.js.map} +1 -1
  15. package/dist/chunks/multi-combobox-CsIXihuc.js +99 -0
  16. package/dist/chunks/multi-combobox-CsIXihuc.js.map +1 -0
  17. package/dist/chunks/{offboarding-3fzRjKla.js → offboarding-Bt7KSixm.js} +3 -3
  18. package/dist/chunks/{offboarding-3fzRjKla.js.map → offboarding-Bt7KSixm.js.map} +1 -1
  19. package/dist/chunks/{principal-page-CYJIJAdp.js → principal-page-Cbx2l6XL.js} +21 -24
  20. package/dist/chunks/principal-page-Cbx2l6XL.js.map +1 -0
  21. package/dist/chunks/{project-page-lO5P6iCb.js → project-page-DKo2AFYg.js} +2 -2
  22. package/dist/chunks/{project-page-lO5P6iCb.js.map → project-page-DKo2AFYg.js.map} +1 -1
  23. package/dist/chunks/{queries-gigcQOO_.js → queries-BvSw1xBN.js} +87 -15
  24. package/dist/chunks/queries-BvSw1xBN.js.map +1 -0
  25. package/dist/chunks/{references-DZ179hTJ.js → references-DCoSPtvw.js} +4 -4
  26. package/dist/chunks/{references-DZ179hTJ.js.map → references-DCoSPtvw.js.map} +1 -1
  27. package/dist/chunks/{role-field-DiqiFwm_.js → role-field-D98CvNEg.js} +2 -2
  28. package/dist/chunks/{role-field-DiqiFwm_.js.map → role-field-D98CvNEg.js.map} +1 -1
  29. package/dist/chunks/{row-state-Zf3kZVhd.js → row-state-BsIHspy4.js} +2 -2
  30. package/dist/chunks/{row-state-Zf3kZVhd.js.map → row-state-BsIHspy4.js.map} +1 -1
  31. package/dist/chunks/{theme-B6-V9JvY.js → theme-3b4DnCow.js} +2 -2
  32. package/dist/chunks/{theme-B6-V9JvY.js.map → theme-3b4DnCow.js.map} +1 -1
  33. package/dist/chunks/{ui-Br-dNUTc.js → ui-2kwXXfrX.js} +95 -22
  34. package/dist/chunks/ui-2kwXXfrX.js.map +1 -0
  35. package/dist/chunks/{use-action-CQGGNqWb.js → use-action-Bv7yQ0DW.js} +2 -2
  36. package/dist/chunks/{use-action-CQGGNqWb.js.map → use-action-Bv7yQ0DW.js.map} +1 -1
  37. package/dist/chunks/{use-change-BdS1gzyo.js → use-change-DIQTGXER.js} +58 -17
  38. package/dist/chunks/use-change-DIQTGXER.js.map +1 -0
  39. package/dist/chunks/{use-shell-BCU505bx.js → use-shell-DhFoHjDS.js} +2 -2
  40. package/dist/chunks/{use-shell-BCU505bx.js.map → use-shell-DhFoHjDS.js.map} +1 -1
  41. package/dist/index.d.ts +13 -164
  42. package/dist/index.js +142 -129
  43. package/dist/index.js.map +1 -1
  44. package/dist/pages/account.js +8 -8
  45. package/dist/pages/approval.js +1 -1
  46. package/dist/pages/audit.js +46 -60
  47. package/dist/pages/audit.js.map +1 -1
  48. package/dist/pages/device-login.js +1 -1
  49. package/dist/pages/environment.js +458 -241
  50. package/dist/pages/environment.js.map +1 -1
  51. package/dist/pages/login.js +2 -2
  52. package/dist/pages/oauth-authorize.js +1 -1
  53. package/dist/pages/project-access.js +8 -8
  54. package/dist/pages/project-environments.js +19 -58
  55. package/dist/pages/project-environments.js.map +1 -1
  56. package/dist/pages/project-settings.d.ts +1 -1
  57. package/dist/pages/project-settings.js +54 -75
  58. package/dist/pages/project-settings.js.map +1 -1
  59. package/dist/pages/project.js +3 -7
  60. package/dist/pages/project.js.map +1 -1
  61. package/dist/pages/projects.js +51 -78
  62. package/dist/pages/projects.js.map +1 -1
  63. package/dist/pages/service-account.js +11 -136
  64. package/dist/pages/service-account.js.map +1 -1
  65. package/dist/pages/service-accounts.js +4 -4
  66. package/dist/pages/settings.js +5 -5
  67. package/dist/pages/unregistered.js +1 -1
  68. package/dist/pages/user.js +5 -5
  69. package/dist/pages/users.js +4 -4
  70. package/package.json +3 -3
  71. package/src/components/actions-log.tsx +1 -1
  72. package/src/components/affordances.ts +12 -0
  73. package/src/components/command-palette.tsx +4 -5
  74. package/src/components/directory.tsx +18 -18
  75. package/src/components/missing.tsx +63 -67
  76. package/src/components/principal-page.tsx +10 -14
  77. package/src/components/service-tokens.tsx +2 -11
  78. package/src/components/shell.tsx +79 -75
  79. package/src/components/trusted-workloads.tsx +2 -11
  80. package/src/components/ui.tsx +35 -25
  81. package/src/lib/changes.ts +63 -12
  82. package/src/lib/clipboard.ts +40 -0
  83. package/src/lib/copy-attempts.ts +103 -0
  84. package/src/lib/dismissal.ts +24 -0
  85. package/src/lib/optimistic.ts +3 -1
  86. package/src/lib/queries.ts +108 -14
  87. package/src/lib/row-reads.ts +64 -0
  88. package/src/options.ts +38 -50
  89. package/src/pages/audit.tsx +15 -24
  90. package/src/pages/environment.tsx +326 -97
  91. package/src/pages/project-environments.tsx +8 -34
  92. package/src/pages/project-settings.tsx +9 -20
  93. package/src/pages/project.tsx +1 -5
  94. package/src/pages/projects.tsx +13 -28
  95. package/src/parity.ts +3 -3
  96. package/src/styles/globals.css +87 -128
  97. package/dist/chunks/directory-pMVS1m-c.js.map +0 -1
  98. package/dist/chunks/principal-page-CYJIJAdp.js.map +0 -1
  99. package/dist/chunks/project-environments-lEzFHUt4.js +0 -11
  100. package/dist/chunks/project-environments-lEzFHUt4.js.map +0 -1
  101. package/dist/chunks/queries-gigcQOO_.js.map +0 -1
  102. package/dist/chunks/ui-Br-dNUTc.js.map +0 -1
  103. package/dist/chunks/use-change-BdS1gzyo.js.map +0 -1
@@ -0,0 +1,64 @@
1
+ import type { Reveal } from './reveal';
2
+
3
+ /**
4
+ * What a secret's row knows about reading its value.
5
+ *
6
+ * Two things read it, and they must not share state. Reveal (and Edit, which
7
+ * opens on the current value) put the value on screen: `reveal` holds it,
8
+ * `revealing` says a read is out, `error` is its refusal. Copy hands the value
9
+ * to the clipboard and keeps nothing: `copyError` is all of it that the row
10
+ * holds, because Copy's in-flight state belongs to its button. So a Copy never
11
+ * changes whether a value is shown or whether Hide can be pressed, and a Reveal
12
+ * never touches Copy's error, whichever of the two finishes first.
13
+ */
14
+ export type RowReads = {
15
+ reveal: Reveal | null;
16
+ revealing: boolean;
17
+ error: string | null;
18
+ copyError: string | null;
19
+ };
20
+
21
+ export const noReads: RowReads = { reveal: null, revealing: false, error: null, copyError: null };
22
+
23
+ export type RowReadsAction =
24
+ | { type: 'set-reveal'; reveal: Reveal | null }
25
+ /** Reveal or Edit asked for the value. */
26
+ | { type: 'read-started' }
27
+ /** It arrived; `reveal` is null when it was only wanted to edit from. */
28
+ | { type: 'read-succeeded'; reveal: Reveal | null }
29
+ | { type: 'read-failed'; message: string }
30
+ | { type: 'copy-started' }
31
+ | { type: 'copy-succeeded' }
32
+ | { type: 'copy-failed'; message: string };
33
+
34
+ export function rowReads(state: RowReads, action: RowReadsAction): RowReads {
35
+ switch (action.type) {
36
+ case 'set-reveal':
37
+ return { ...state, reveal: action.reveal };
38
+ case 'read-started':
39
+ return { ...state, revealing: true };
40
+ case 'read-succeeded':
41
+ return {
42
+ ...state,
43
+ revealing: false,
44
+ error: null,
45
+ reveal: action.reveal ?? state.reveal,
46
+ };
47
+ case 'read-failed':
48
+ return { ...state, revealing: false, error: action.message };
49
+ case 'copy-started':
50
+ case 'copy-succeeded':
51
+ return { ...state, copyError: null };
52
+ case 'copy-failed':
53
+ return { ...state, copyError: action.message };
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Whether the eye button is out of reach: while a read is on its way and there
59
+ * is nothing on screen yet. Once a value is shown, Hide is always available,
60
+ * whatever else is being read.
61
+ */
62
+ export function revealToggleDisabled(state: RowReads, shown: Reveal | null): boolean {
63
+ return shown === null && state.revealing;
64
+ }
package/src/options.ts CHANGED
@@ -24,17 +24,20 @@ import { memberRef, uiResult } from './lib/coffre';
24
24
  import { stringsOf } from './lib/search';
25
25
  import {
26
26
  hasAppsTab,
27
- loadAccess,
28
27
  loadDirectory,
28
+ loadEnvironment,
29
29
  loadMember,
30
+ loadPrincipal,
30
31
  loadProject,
31
32
  loadServiceDirectory,
32
33
  loadSettings,
34
+ loadSignIn,
33
35
  loadShell,
34
36
  projectOf,
35
37
  queries,
36
- signInWays,
38
+ tabOpens,
37
39
  type AuditSearch,
40
+ type Freshness,
38
41
  } from './lib/queries';
39
42
  import type { Permission } from './shared/models';
40
43
  import { loginSearch } from './lib/signin-errors';
@@ -154,29 +157,20 @@ export const environment = {
154
157
  validateSearch: (search: Record<string, unknown>): { filter?: string } => ({
155
158
  filter: typeof search.filter === 'string' && search.filter !== '' ? search.filter : undefined,
156
159
  }),
157
- loader: async ({ context, params }: Loader<{ project: string; environment: string }>) => {
160
+ loader: ({ context, params }: Loader<{ project: string; environment: string }>) => {
158
161
  const { coffre, queryClient } = coffreOf(context);
159
- const secrets = await queryClient.fetchQuery(queries.secrets(coffre, params));
160
- // Then, for whoever reads it, the references that read its secrets from
161
- // elsewhere and the keys it lacks, rendered with them. Asked only then,
162
- // so a refused visit is one refusal in the log, not three.
163
- if (secrets.ok) {
164
- await Promise.all([
165
- queryClient.fetchQuery(queries.references(coffre, `${params.project}/${params.environment}`)),
166
- queryClient.fetchQuery(queries.missing(coffre, params)),
167
- ]);
168
- }
169
- return secrets;
162
+ return loadEnvironment(queryClient, coffre, params);
170
163
  },
171
164
  };
172
165
 
173
166
  /** `/audit`. */
174
167
  export const audit = {
175
168
  // Filters live in the URL so a finding can cite the exact view it came from.
169
+ // Denials always include detail: a refused sign-in is one.
176
170
  validateSearch: (search: Record<string, unknown>): AuditSearch => ({
177
171
  decision: search.decision === 'deny' ? 'deny' : undefined,
178
172
  actorId: typeof search.actorId === 'string' && search.actorId !== '' ? search.actorId : undefined,
179
- detail: search.detail === '1' ? '1' : undefined,
173
+ detail: search.detail === '1' || search.decision === 'deny' ? '1' : undefined,
180
174
  }),
181
175
  loaderDeps: ({ search }: { search: AuditSearch }) => search,
182
176
  // The entries only: the verification is asked for once the page is up
@@ -195,28 +189,27 @@ export const users = {
195
189
  },
196
190
  };
197
191
 
198
- /** `/users/$user`, the layout of a user's tabs: who they are to the instance, for owners. */
192
+ /**
193
+ * `/users/$user`, the layout of a user's tabs: who they are to the instance,
194
+ * for owners, and their access, for whoever manages it. Its tabs read what
195
+ * it read from the cache (`Freshness`), so each opens at once.
196
+ */
199
197
  export const user = {
200
198
  loader: ({ context, params }: Loader<{ user: string }>) => {
201
199
  const { coffre, queryClient } = coffreOf(context);
202
- return loadMember(queryClient, coffre, memberRef('user', params.user));
200
+ return loadPrincipal(queryClient, coffre, 'user', params.user);
203
201
  },
204
202
  };
205
203
 
206
- /** `/users/$user/`, their access on every project where you manage it. */
207
- export const userAccess = {
208
- loader: ({ context, params }: Loader<{ user: string }>) => {
209
- const { coffre, queryClient } = coffreOf(context);
210
- return loadAccess(queryClient, coffre, memberRef('user', params.user));
211
- },
212
- };
204
+ /** `/users/$user/`, their access on every project where you manage it, which its layout reads. */
205
+ export const userAccess = {};
213
206
 
214
207
  /** `/users/$user/activity`, for whoever reads the audit log; the others are sent to the first tab. */
215
208
  export const userActivity = {
216
209
  loader: async ({ context, params }: Loader<{ user: string }>) => {
217
210
  const { coffre, queryClient } = coffreOf(context);
218
- const shell = await loadShell(queryClient, coffre);
219
- if (!shell.capabilities.canReadAudit) throw redirect({ to: '/users/$user', params });
211
+ const reads = async (freshness: Freshness) => (await loadShell(queryClient, coffre, freshness)).capabilities.canReadAudit;
212
+ if (!(await tabOpens(reads))) throw redirect({ to: '/users/$user', params });
220
213
  },
221
214
  };
222
215
 
@@ -229,9 +222,14 @@ export const userActivity = {
229
222
  export const userApps = {
230
223
  loader: async ({ context, params }: Loader<{ user: string }>) => {
231
224
  const { coffre, queryClient } = coffreOf(context);
232
- const shell = await loadShell(queryClient, coffre);
233
- const report = await loadMember(queryClient, coffre, memberRef('user', params.user));
234
- if (!hasAppsTab(shell, report)) throw redirect({ to: '/users/$user', params });
225
+ const has = async (freshness: Freshness) => {
226
+ const [shell, report] = await Promise.all([
227
+ loadShell(queryClient, coffre, freshness),
228
+ loadMember(queryClient, coffre, memberRef('user', params.user), freshness),
229
+ ]);
230
+ return hasAppsTab(shell, report);
231
+ };
232
+ if (!(await tabOpens(has))) throw redirect({ to: '/users/$user', params });
235
233
  },
236
234
  };
237
235
 
@@ -245,13 +243,14 @@ export const serviceAccounts = {
245
243
 
246
244
  /**
247
245
  * `/service-accounts/$account`, the layout of a service account's tabs: who
248
- * it is to the instance, for owners, and what it holds, for whoever manages it.
246
+ * it is to the instance, for owners, what it holds, and how it signs in, for
247
+ * whoever manages it. Its tabs read what it read from the cache
248
+ * (`Freshness`), so each opens at once.
249
249
  */
250
250
  export const serviceAccount = {
251
- loader: async ({ context, params }: Loader<{ account: string }>) => {
251
+ loader: ({ context, params }: Loader<{ account: string }>) => {
252
252
  const { coffre, queryClient } = coffreOf(context);
253
- const member = memberRef('service', params.account);
254
- await Promise.all([loadMember(queryClient, coffre, member), loadAccess(queryClient, coffre, member)]);
253
+ return loadPrincipal(queryClient, coffre, 'service', params.account);
255
254
  },
256
255
  };
257
256
 
@@ -263,31 +262,20 @@ export const serviceAccount = {
263
262
  export const serviceAccountSignIn = {
264
263
  loader: async ({ context, params }: Loader<{ account: string }>) => {
265
264
  const { coffre, queryClient } = coffreOf(context);
266
- const member = memberRef('service', params.account);
267
- const [shell, access] = await Promise.all([loadShell(queryClient, coffre), loadAccess(queryClient, coffre, member)]);
268
- const ways = signInWays(shell, access);
269
- if (ways === null) throw redirect({ to: '/service-accounts/$account/access', params });
270
- await Promise.all([
271
- queryClient.fetchQuery(queries.credentials(coffre, member, ways.tokens)),
272
- queryClient.fetchQuery(queries.bindings(coffre, member, ways.workloads)),
273
- ]);
265
+ const shows = async (freshness: Freshness) => (await loadSignIn(queryClient, coffre, memberRef('service', params.account), freshness)) !== null;
266
+ if (!(await tabOpens(shows))) throw redirect({ to: '/service-accounts/$account/access', params });
274
267
  },
275
268
  };
276
269
 
277
- /** `/service-accounts/$account/access`. */
278
- export const serviceAccountAccess = {
279
- loader: ({ context, params }: Loader<{ account: string }>) => {
280
- const { coffre, queryClient } = coffreOf(context);
281
- return loadAccess(queryClient, coffre, memberRef('service', params.account));
282
- },
283
- };
270
+ /** `/service-accounts/$account/access`, which its layout reads. */
271
+ export const serviceAccountAccess = {};
284
272
 
285
273
  /** `/service-accounts/$account/activity`, as a user's. */
286
274
  export const serviceAccountActivity = {
287
275
  loader: async ({ context, params }: Loader<{ account: string }>) => {
288
276
  const { coffre, queryClient } = coffreOf(context);
289
- const shell = await loadShell(queryClient, coffre);
290
- if (!shell.capabilities.canReadAudit) throw redirect({ to: '/service-accounts/$account', params });
277
+ const reads = async (freshness: Freshness) => (await loadShell(queryClient, coffre, freshness)).capabilities.canReadAudit;
278
+ if (!(await tabOpens(reads))) throw redirect({ to: '/service-accounts/$account', params });
291
279
  },
292
280
  };
293
281
 
@@ -12,7 +12,7 @@ import {
12
12
  who,
13
13
  type Part,
14
14
  } from '../lib/audit-sentences';
15
- import { EmptyState, Notice, Spinner, Timestamp, Toggletip } from '../components/ui';
15
+ import { absolute, EmptyState, Notice, Spinner, Timestamp, Toggletip } from '../components/ui';
16
16
  import { memberName, Sentence } from '../components/audit-sentence';
17
17
  import { ClosedDoor, PageHeader } from '../components/page';
18
18
  import {
@@ -87,7 +87,7 @@ export function AuditPage() {
87
87
  ; <code>coffre audit</code> lists them all.
88
88
  </>
89
89
  ) : (
90
- ': it may be detail, which Show detail lists.'
90
+ ': it may be detail, which Everything lists.'
91
91
  )}
92
92
  </>
93
93
  )}
@@ -96,16 +96,18 @@ export function AuditPage() {
96
96
  )}
97
97
 
98
98
  <div className="toolbar">
99
- <nav className="segmented" aria-label="Filter by decision">
100
- {/* `exact` compares the whole search, not a subset of it: otherwise
101
- "All events" for one actor also counts as active while that
102
- actor's denials are showing, and both halves light up. */}
103
- <Link to="/audit" search={{ ...filters, decision: undefined, detail: search.detail }} activeOptions={{ exact: true, includeSearch: false }}>
104
- All events
99
+ {/* One control for what the log lists. `exact` holds each link to the
100
+ whole search, so only the view shown lights up. */}
101
+ <nav className="segmented" aria-label="Show">
102
+ <Link to="/audit" search={{ actorId }} activeOptions={{ exact: true }}>
103
+ Actions
105
104
  </Link>
106
- <Link to="/audit" search={{ ...filters, decision: 'deny', detail: search.detail }} activeOptions={{ exact: true, includeSearch: false }}>
105
+ <Link to="/audit" search={{ actorId, detail: '1' }} activeOptions={{ exact: true }}>
106
+ Everything
107
+ </Link>
108
+ <Link to="/audit" search={{ actorId, decision: 'deny', detail: '1' }} activeOptions={{ exact: true }}>
107
109
  <SlashCircle size={13} />
108
- Denials only
110
+ Denials
109
111
  </Link>
110
112
  </nav>
111
113
 
@@ -120,16 +122,6 @@ export function AuditPage() {
120
122
  <X size={13} />
121
123
  </Link>
122
124
  )}
123
-
124
- <Link
125
- className="detail-toggle"
126
- to="/audit"
127
- search={{ ...filters, detail: detail ? undefined : '1' }}
128
- aria-pressed={detail}
129
- >
130
- <span className="switch" aria-hidden="true" />
131
- Show detail
132
- </Link>
133
125
  </div>
134
126
 
135
127
  <section className="card card-wide" aria-label="Audit entries">
@@ -431,10 +423,9 @@ function ChainStatus({ chain, onRetry }: { chain: ChainResult | undefined; onRet
431
423
  <Toggletip
432
424
  align="end"
433
425
  label={
434
- `Every entry through ${chain.through ?? 0} holds, under the app's key and the vault's.` +
435
- (chain.checkpoint === null
436
- ? ' Not checkpointed yet: the vault signs the log every few minutes.'
437
- : ` The vault last signed it through entry ${chain.checkpoint.seq}, at ${chain.checkpoint.signedAt}.`)
426
+ chain.checkpoint === null
427
+ ? 'Audit log verified by the app and vault keys, not signed yet.'
428
+ : `Audit log verified by the app and vault keys, last signature at ${absolute(chain.checkpoint.signedAt, false)} UTC.`
438
429
  }
439
430
  >
440
431
  <button type="button" className="chain-seal">