@coffre/ui 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/dist/chunks/audit-sentence-BhHmvQX_.js +660 -0
  2. package/dist/chunks/audit-sentence-BhHmvQX_.js.map +1 -0
  3. package/dist/chunks/delete-place-CRX7ntE8.js +206 -0
  4. package/dist/chunks/delete-place-CRX7ntE8.js.map +1 -0
  5. package/dist/chunks/{directory-CSjWWUQ1.js → directory-zr3ek7Mc.js} +175 -60
  6. package/dist/chunks/directory-zr3ek7Mc.js.map +1 -0
  7. package/dist/chunks/folders-DoBmCwOi.js +207 -0
  8. package/dist/chunks/folders-DoBmCwOi.js.map +1 -0
  9. package/dist/chunks/grants-Cw1FyGID.js +669 -0
  10. package/dist/chunks/grants-Cw1FyGID.js.map +1 -0
  11. package/dist/chunks/offboarding-CE6d7um1.js +305 -0
  12. package/dist/chunks/offboarding-CE6d7um1.js.map +1 -0
  13. package/dist/chunks/one-time-DXEl9hbg.js +35 -0
  14. package/dist/chunks/one-time-DXEl9hbg.js.map +1 -0
  15. package/dist/chunks/page-DvsgZ2Hd.js +391 -0
  16. package/dist/chunks/page-DvsgZ2Hd.js.map +1 -0
  17. package/dist/chunks/principal-BIN-xwZw.js +42 -0
  18. package/dist/chunks/principal-BIN-xwZw.js.map +1 -0
  19. package/dist/chunks/{principal-page-D_91OA0l.js → principal-page-DhjO76GH.js} +245 -251
  20. package/dist/chunks/principal-page-DhjO76GH.js.map +1 -0
  21. package/dist/chunks/project-page-SRCtRe2g.js +17 -0
  22. package/dist/chunks/project-page-SRCtRe2g.js.map +1 -0
  23. package/dist/chunks/{queries-CQ81o4so.js → queries-DVR_i3rA.js} +132 -30
  24. package/dist/chunks/queries-DVR_i3rA.js.map +1 -0
  25. package/dist/chunks/references-B6pLT1uQ.js +343 -0
  26. package/dist/chunks/references-B6pLT1uQ.js.map +1 -0
  27. package/dist/chunks/{row-state-0PsrEzOL.js → row-state-DOPUsjQK.js} +3 -3
  28. package/dist/chunks/{row-state-0PsrEzOL.js.map → row-state-DOPUsjQK.js.map} +1 -1
  29. package/dist/chunks/signin-errors--ykMFuqN.js +57 -0
  30. package/dist/chunks/signin-errors--ykMFuqN.js.map +1 -0
  31. package/dist/chunks/tabs-BmwKfUeK.js +22 -0
  32. package/dist/chunks/tabs-BmwKfUeK.js.map +1 -0
  33. package/dist/chunks/{theme-B2vQolVR.js → theme-DJuz-xLM.js} +3 -3
  34. package/dist/chunks/{theme-B2vQolVR.js.map → theme-DJuz-xLM.js.map} +1 -1
  35. package/dist/chunks/{ui-DixXLQvQ.js → ui-DJje3gST.js} +6 -3
  36. package/dist/chunks/ui-DJje3gST.js.map +1 -0
  37. package/dist/chunks/{use-change-c6CeLRin.js → use-change-DUiGO19U.js} +52 -21
  38. package/dist/chunks/use-change-DUiGO19U.js.map +1 -0
  39. package/dist/chunks/{use-shell-jxd7Tzd-.js → use-shell-rNKfGjdj.js} +3 -3
  40. package/dist/chunks/{use-shell-jxd7Tzd-.js.map → use-shell-rNKfGjdj.js.map} +1 -1
  41. package/dist/chunks/validation-D312_NLf.js +87 -0
  42. package/dist/chunks/validation-D312_NLf.js.map +1 -0
  43. package/dist/index.d.ts +361 -27
  44. package/dist/index.js +188 -98
  45. package/dist/index.js.map +1 -1
  46. package/dist/pages/account.d.ts +2 -2
  47. package/dist/pages/account.js +297 -135
  48. package/dist/pages/account.js.map +1 -1
  49. package/dist/pages/approval.d.ts +9 -0
  50. package/dist/pages/approval.js +207 -0
  51. package/dist/pages/approval.js.map +1 -0
  52. package/dist/pages/audit.js +17 -542
  53. package/dist/pages/audit.js.map +1 -1
  54. package/dist/pages/device-login.js +2 -3
  55. package/dist/pages/device-login.js.map +1 -1
  56. package/dist/pages/environment.js +647 -257
  57. package/dist/pages/environment.js.map +1 -1
  58. package/dist/pages/login.js +18 -7
  59. package/dist/pages/login.js.map +1 -1
  60. package/dist/pages/oauth-authorize.d.ts +10 -0
  61. package/dist/pages/oauth-authorize.js +249 -0
  62. package/dist/pages/oauth-authorize.js.map +1 -0
  63. package/dist/pages/project-access.d.ts +6 -0
  64. package/dist/pages/project-access.js +370 -0
  65. package/dist/pages/project-access.js.map +1 -0
  66. package/dist/pages/project-environments.d.ts +4 -0
  67. package/dist/pages/project-environments.js +593 -0
  68. package/dist/pages/project-environments.js.map +1 -0
  69. package/dist/pages/project-settings.d.ts +4 -0
  70. package/dist/pages/project-settings.js +242 -0
  71. package/dist/pages/project-settings.js.map +1 -0
  72. package/dist/pages/project.d.ts +10 -2
  73. package/dist/pages/project.js +57 -934
  74. package/dist/pages/project.js.map +1 -1
  75. package/dist/pages/projects.js +53 -21
  76. package/dist/pages/projects.js.map +1 -1
  77. package/dist/pages/service-account.d.ts +10 -0
  78. package/dist/pages/{token.js → service-account.js} +112 -54
  79. package/dist/pages/service-account.js.map +1 -0
  80. package/dist/pages/service-accounts.d.ts +3 -0
  81. package/dist/pages/service-accounts.js +38 -0
  82. package/dist/pages/service-accounts.js.map +1 -0
  83. package/dist/pages/settings.d.ts +1 -0
  84. package/dist/pages/settings.js +104 -42
  85. package/dist/pages/settings.js.map +1 -1
  86. package/dist/pages/unregistered.js +2 -3
  87. package/dist/pages/unregistered.js.map +1 -1
  88. package/dist/pages/user.d.ts +6 -1
  89. package/dist/pages/user.js +18 -6
  90. package/dist/pages/user.js.map +1 -1
  91. package/dist/pages/users.js +6 -10
  92. package/dist/pages/users.js.map +1 -1
  93. package/package.json +3 -3
  94. package/src/components/actions-log.tsx +117 -0
  95. package/src/components/audit-sentence.tsx +55 -0
  96. package/src/components/command-palette.tsx +4 -4
  97. package/src/components/delete-place.tsx +180 -0
  98. package/src/components/directory.tsx +259 -110
  99. package/src/components/every-project.tsx +287 -0
  100. package/src/components/expiry-field.tsx +42 -0
  101. package/src/components/folders.tsx +219 -0
  102. package/src/components/grants.tsx +11 -4
  103. package/src/components/icons.tsx +2 -0
  104. package/src/components/missing.tsx +110 -0
  105. package/src/components/offboarding.tsx +61 -33
  106. package/src/components/page.tsx +4 -1
  107. package/src/components/principal-page.tsx +136 -106
  108. package/src/components/principal-picker.tsx +5 -5
  109. package/src/components/principal.tsx +4 -4
  110. package/src/components/references.tsx +323 -0
  111. package/src/components/service-tokens.tsx +112 -93
  112. package/src/components/shell.tsx +11 -32
  113. package/src/components/tabs.tsx +18 -0
  114. package/src/components/trusted-workloads.tsx +97 -79
  115. package/src/components/ui.tsx +8 -1
  116. package/src/index.ts +13 -2
  117. package/src/layout.tsx +2 -2
  118. package/src/lib/access-plan.ts +2 -2
  119. package/src/lib/audit-sentences.ts +161 -77
  120. package/src/lib/changes.ts +56 -5
  121. package/src/lib/coffre.ts +3 -2
  122. package/src/lib/one-time.ts +32 -0
  123. package/src/lib/project-access.ts +11 -23
  124. package/src/lib/project-page.ts +14 -0
  125. package/src/lib/queries.ts +126 -32
  126. package/src/lib/search.ts +25 -0
  127. package/src/lib/signin-errors.ts +45 -1
  128. package/src/lib/validation.ts +14 -0
  129. package/src/options.ts +187 -35
  130. package/src/pages/account.tsx +274 -129
  131. package/src/pages/approval.tsx +197 -0
  132. package/src/pages/audit.tsx +9 -61
  133. package/src/pages/environment.tsx +585 -286
  134. package/src/pages/login.tsx +8 -2
  135. package/src/pages/oauth-authorize.tsx +233 -0
  136. package/src/pages/project-access.tsx +219 -0
  137. package/src/pages/project-environments.tsx +582 -0
  138. package/src/pages/project-settings.tsx +259 -0
  139. package/src/pages/project.tsx +52 -879
  140. package/src/pages/projects.tsx +55 -18
  141. package/src/pages/service-account.tsx +50 -0
  142. package/src/pages/{tokens.tsx → service-accounts.tsx} +9 -6
  143. package/src/pages/settings.tsx +62 -8
  144. package/src/pages/user.tsx +16 -4
  145. package/src/pages/users.tsx +2 -2
  146. package/src/parity.ts +160 -0
  147. package/src/register.ts +58 -9
  148. package/src/router.tsx +4 -0
  149. package/src/shared/models.ts +6 -2
  150. package/src/styles/globals.css +536 -31
  151. package/dist/chunks/directory-CSjWWUQ1.js.map +0 -1
  152. package/dist/chunks/grants-saMQagmG.js +0 -160
  153. package/dist/chunks/grants-saMQagmG.js.map +0 -1
  154. package/dist/chunks/icons-D-PfAfnH.js +0 -203
  155. package/dist/chunks/icons-D-PfAfnH.js.map +0 -1
  156. package/dist/chunks/offboarding-C6l30DZR.js +0 -263
  157. package/dist/chunks/offboarding-C6l30DZR.js.map +0 -1
  158. package/dist/chunks/page-C5HcNqf2.js +0 -190
  159. package/dist/chunks/page-C5HcNqf2.js.map +0 -1
  160. package/dist/chunks/principal-page-D_91OA0l.js.map +0 -1
  161. package/dist/chunks/queries-CQ81o4so.js.map +0 -1
  162. package/dist/chunks/signin-errors-BEFlVDbQ.js +0 -30
  163. package/dist/chunks/signin-errors-BEFlVDbQ.js.map +0 -1
  164. package/dist/chunks/ui-DixXLQvQ.js.map +0 -1
  165. package/dist/chunks/use-action-CWsg_YWU.js +0 -49
  166. package/dist/chunks/use-action-CWsg_YWU.js.map +0 -1
  167. package/dist/chunks/use-change-c6CeLRin.js.map +0 -1
  168. package/dist/chunks/validation-BQtqPe2V.js +0 -29
  169. package/dist/chunks/validation-BQtqPe2V.js.map +0 -1
  170. package/dist/pages/token.d.ts +0 -3
  171. package/dist/pages/token.js.map +0 -1
  172. package/dist/pages/tokens.d.ts +0 -3
  173. package/dist/pages/tokens.js +0 -39
  174. package/dist/pages/tokens.js.map +0 -1
  175. package/dist/project-BqIy8gYR.d.ts +0 -5
  176. package/src/lib/instance.ts +0 -13
  177. package/src/pages/token.tsx +0 -34
@@ -1,5 +1,6 @@
1
- import type { IdentityRow, SessionRow } from '@coffre/client';
2
- import { useSuspenseQueries } from '@tanstack/react-query';
1
+ import type { ConnectedApp, IdentityRow, SessionRow } from '@coffre/client';
2
+ import { MCP_SCOPE_INFO } from '@coffre/core/mcp';
3
+ import { useSuspenseQueries, useSuspenseQuery } from '@tanstack/react-query';
3
4
 
4
5
  import { Fragment } from 'react';
5
6
  import { useShell } from '../lib/use-shell';
@@ -7,10 +8,11 @@ import { Card, Fact, PageHeader } from '../components/page';
7
8
  import { ThemeCards } from '../components/theme';
8
9
  import { InstanceRole } from '../components/directory';
9
10
  import { ConfirmButton, EmptyState, ErrorLine, Notice, Timestamp } from '../components/ui';
10
- import { Monitor, ProviderMark, SignOut, Terminal, X } from '../components/icons';
11
+ import { Link as LinkIcon, Monitor, ProviderMark, SignOut, Terminal, X } from '../components/icons';
11
12
  import { signinErrorMessage } from '../lib/signin-errors';
13
+ import { useOneTime } from '../lib/one-time';
12
14
  import { useCoffre } from '../lib/coffre';
13
- import { endSession, unlinkIdentity } from '../lib/changes';
15
+ import { disconnectApp, endSession, unlinkIdentity } from '../lib/changes';
14
16
  import { queries } from '../lib/queries';
15
17
  import { useChange, useChangeStatus } from '../lib/use-change';
16
18
  import { RowFailure, RowPending, rowClass } from '../components/row-state';
@@ -23,13 +25,13 @@ type Search = { linked?: string; error?: string };
23
25
 
24
26
  /**
25
27
  * Your own settings: how coffre looks here, who it takes you for and, when
26
- * coffre runs its own sign-in, which accounts you sign in with and where you
27
- * are signed in. The sidebar's Settings is the instance's; this page is
28
+ * coffre runs its own sign-in, which accounts you sign in with, where you
29
+ * are signed in, and the MCP clients you connected. The sidebar's Settings is the instance's; this page is
28
30
  * reached from your account at the sidebar's foot.
29
31
  */
30
32
 
31
33
  export function AccountPage() {
32
- const { principal, instanceRole, auth } = useShell();
34
+ const { principal, instanceRole, auth, features } = useShell();
33
35
 
34
36
  return (
35
37
  <>
@@ -67,6 +69,8 @@ export function AccountPage() {
67
69
  {auth.signin !== null && principal?.type === 'user' && (
68
70
  <SignIn email={principal.id} providers={auth.signin.providers} />
69
71
  )}
72
+
73
+ {features.mcp && principal?.type === 'user' && <ConnectedApps />}
70
74
  </>
71
75
  );
72
76
  }
@@ -117,101 +121,239 @@ function SigninAccounts({
117
121
  providers: Provider[];
118
122
  identities: IdentityRow[];
119
123
  }) {
120
- const { linked, error } = Route.useSearch();
124
+ // Shown once: a reload shows the accounts, not the last link's outcome again.
125
+ const { linked, error } = useOneTime(Route.useSearch(), ['linked', 'error']);
121
126
  const message = signinErrorMessage(error);
122
127
  const change = unlinkIdentity(useCoffre());
123
128
  const unlink = useChange(change);
124
129
  const { status, dismiss } = useChangeStatus(change.list.queryKey);
125
130
 
126
131
  return (
127
- <Card
128
- labelledBy="signin-accounts"
129
- title="Sign-in accounts"
130
- description="coffre recognises you by these accounts, never by an email address alone. A new account is linked here, while you are signed in."
131
- >
132
- {(linked !== undefined || message !== null) && (
133
- <div className="card-body">
134
- {linked !== undefined && (
135
- <Notice tone="good">{providerLabel(providers, linked)} account linked.</Notice>
136
- )}
137
- <ErrorLine error={message} />
132
+ <>
133
+ <Card
134
+ labelledBy="signin-accounts"
135
+ title="Sign-in accounts"
136
+ description="coffre recognises you by these accounts, never by an email address alone. A new account is linked here, while you are signed in."
137
+ >
138
+ {(linked !== undefined || message !== null) && (
139
+ <div className="card-body">
140
+ {linked !== undefined && (
141
+ <Notice tone="good">{providerLabel(providers, linked)} account linked.</Notice>
142
+ )}
143
+ <ErrorLine error={message} />
144
+ </div>
145
+ )}
146
+
147
+ {identities.length === 0 ? (
148
+ <EmptyState title="No account linked">
149
+ Your next sign-in with a verified <span className="mono">{email}</span> links that
150
+ account.
151
+ </EmptyState>
152
+ ) : (
153
+ <div className="dt-wrap">
154
+ <table className="dt stacks stacks-inline">
155
+ <thead>
156
+ <tr>
157
+ <th>Account</th>
158
+ <th className="col-shrink">Linked (UTC)</th>
159
+ <th className="col-shrink">Last sign-in</th>
160
+ <th className="col-actions">
161
+ <span className="visually-hidden">Actions</span>
162
+ </th>
163
+ </tr>
164
+ </thead>
165
+ <tbody>
166
+ {identities.map((identity) => {
167
+ const label = providerLabel(providers, identity.provider);
168
+ const brand = providers.find((p) => p.id === identity.provider)?.brand ?? 'oidc';
169
+ const state = status(identity.id);
170
+ return (
171
+ <Fragment key={identity.id}>
172
+ <tr className={rowClass(state)}>
173
+ <td>
174
+ <span className="cell-account">
175
+ <ProviderMark brand={brand} />
176
+ <span className="cell-stack">
177
+ <span>{label}</span>
178
+ {identity.email !== null && <small className="mono">{identity.email}</small>}
179
+ </span>
180
+ </span>
181
+ </td>
182
+ <td className="nowrap" data-label="Linked (UTC)">
183
+ <Timestamp iso={identity.createdAt} />
184
+ </td>
185
+ <td className="nowrap cell-muted" data-label="Last sign-in">
186
+ {identity.lastSignInAt === null ? (
187
+ 'Never'
188
+ ) : (
189
+ <Timestamp iso={identity.lastSignInAt} display="relative" />
190
+ )}
191
+ </td>
192
+ <td className="col-actions">
193
+ {state.state === 'pending' ? (
194
+ <RowPending status={state} />
195
+ ) : (
196
+ <ConfirmButton
197
+ trigger={
198
+ <button className="act">
199
+ <X size={13} />
200
+ Unlink
201
+ </button>
202
+ }
203
+ title={`Unlink this ${label} account?`}
204
+ body={
205
+ identities.length === 1 ? (
206
+ <>
207
+ It stops signing you in, and every session it opened ends now,
208
+ this one included if you signed in with it. Your next sign-in
209
+ with any account whose verified email is{' '}
210
+ <span className="mono">{email}</span> links that account instead.
211
+ </>
212
+ ) : (
213
+ <>
214
+ It stops signing you in, and every session it opened ends now,
215
+ this one included if you signed in with it.
216
+ </>
217
+ )
218
+ }
219
+ confirmLabel="Unlink"
220
+ onConfirm={() => unlink({ ...identity, label })}
221
+ />
222
+ )}
223
+ </td>
224
+ </tr>
225
+ <RowFailure
226
+ status={state}
227
+ columns={4}
228
+ onDismiss={() => state.state === 'failed' && dismiss(state.mutationId)}
229
+ />
230
+ </Fragment>
231
+ );
232
+ })}
233
+ </tbody>
234
+ </table>
235
+ </div>
236
+ )}
237
+ </Card>
238
+ {providers.length > 0 && (
239
+ <div className="table-actions">
240
+ <span className="hint">Link another account</span>
241
+ {providers.map((provider) => (
242
+ <a
243
+ key={provider.id}
244
+ className="btn"
245
+ href={`/auth/signin/${encodeURIComponent(provider.id)}?link=1`}
246
+ >
247
+ <ProviderMark brand={provider.brand} size={14} />
248
+ {provider.label}
249
+ </a>
250
+ ))}
138
251
  </div>
139
252
  )}
253
+ </>
254
+ );
255
+ }
140
256
 
141
- {identities.length === 0 ? (
142
- <EmptyState title="No account linked">
143
- Your next sign-in with a verified <span className="mono">{email}</span> links that
144
- account.
145
- </EmptyState>
257
+ function Sessions({
258
+ sessions,
259
+ providers,
260
+ }: {
261
+ sessions: SessionRow[];
262
+ providers: Provider[];
263
+ }) {
264
+ const change = endSession(useCoffre());
265
+ const end = useChange(change);
266
+ const { status, dismiss } = useChangeStatus(change.list.queryKey);
267
+
268
+ return (
269
+ <Card
270
+ labelledBy="sessions"
271
+ title="Sessions"
272
+ description="Browsers and command lines signed in as you. Ending one signs it out at its next request."
273
+ >
274
+ {sessions.length === 0 ? (
275
+ <EmptyState title="No sessions">Nothing is signed in as you right now.</EmptyState>
146
276
  ) : (
147
277
  <div className="dt-wrap">
148
- <table className="dt">
278
+ <table className="dt stacks stacks-inline">
149
279
  <thead>
150
280
  <tr>
151
- <th>Account</th>
152
- <th className="col-shrink">Linked (UTC)</th>
153
- <th className="col-shrink">Last sign-in</th>
281
+ <th>Where</th>
282
+ <th className="col-shrink">Last active</th>
283
+ <th className="col-shrink">Expires</th>
154
284
  <th className="col-actions">
155
285
  <span className="visually-hidden">Actions</span>
156
286
  </th>
157
287
  </tr>
158
288
  </thead>
159
289
  <tbody>
160
- {identities.map((identity) => {
161
- const label = providerLabel(providers, identity.provider);
162
- const brand = providers.find((p) => p.id === identity.provider)?.brand ?? 'oidc';
163
- const state = status(identity.id);
290
+ {sessions.map((session) => {
291
+ const state = status(session.id);
164
292
  return (
165
- <Fragment key={identity.id}>
293
+ <Fragment key={session.id}>
166
294
  <tr className={rowClass(state)}>
167
295
  <td>
168
296
  <span className="cell-account">
169
- <ProviderMark brand={brand} />
297
+ {session.kind === 'cli' ? <Terminal size={15} /> : <Monitor size={15} />}
170
298
  <span className="cell-stack">
171
- <span>{label}</span>
172
- {identity.email !== null && <small className="mono">{identity.email}</small>}
299
+ <span>
300
+ {session.label ?? (session.kind === 'cli' ? 'Command line' : 'Browser')}{' '}
301
+ {session.current && <span className="tag tag-blue">This browser</span>}
302
+ </span>
303
+ <small>
304
+ {session.kind === 'cli'
305
+ ? 'coffre login'
306
+ : `via ${providerLabel(providers, session.provider)}`}
307
+ {session.lastUsedIp !== null && (
308
+ <>
309
+ {' · '}
310
+ <span className="mono">{session.lastUsedIp}</span>
311
+ </>
312
+ )}
313
+ </small>
173
314
  </span>
174
315
  </span>
175
316
  </td>
176
- <td className="nowrap">
177
- <Timestamp iso={identity.createdAt} />
317
+ <td className="nowrap cell-muted" data-label="Last active">
318
+ <Timestamp iso={session.lastUsedAt ?? session.createdAt} display="relative" />
178
319
  </td>
179
- <td className="nowrap cell-muted">
180
- {identity.lastSignInAt === null ? (
181
- 'Never'
182
- ) : (
183
- <Timestamp iso={identity.lastSignInAt} display="relative" />
184
- )}
320
+ <td className="nowrap cell-muted" data-label="Expires">
321
+ <Timestamp iso={session.expiresAt} display="relative" />
185
322
  </td>
186
323
  <td className="col-actions">
187
- {state.state === 'pending' ? (
324
+ {session.current ? (
325
+ <form method="post" action="/auth/signout">
326
+ <button className="act" type="submit">
327
+ <SignOut size={13} />
328
+ Sign out
329
+ </button>
330
+ </form>
331
+ ) : state.state === 'pending' ? (
188
332
  <RowPending status={state} />
189
333
  ) : (
190
334
  <ConfirmButton
191
335
  trigger={
192
336
  <button className="act">
193
337
  <X size={13} />
194
- Unlink
338
+ End
195
339
  </button>
196
340
  }
197
- title={`Unlink this ${label} account?`}
341
+ title={`End this ${session.kind === 'cli' ? 'command line' : 'browser'} session?`}
198
342
  body={
199
- identities.length === 1 ? (
200
- <>
201
- It stops signing you in, and every session it opened ends now,
202
- this one included if you signed in with it. Your next sign-in
203
- with any account whose verified email is{' '}
204
- <span className="mono">{email}</span> links that account instead.
205
- </>
206
- ) : (
207
- <>
208
- It stops signing you in, and every session it opened ends now,
209
- this one included if you signed in with it.
210
- </>
211
- )
343
+ <>
344
+ {session.label ?? (session.kind === 'cli' ? 'The command line' : 'The browser')}
345
+ {session.lastUsedIp !== null && (
346
+ <>
347
+ {' '}at <span className="mono">{session.lastUsedIp}</span>
348
+ </>
349
+ )}
350
+ , last active{' '}
351
+ <Timestamp iso={session.lastUsedAt ?? session.createdAt} display="relative" />, is
352
+ signed out at its next request.
353
+ </>
212
354
  }
213
- confirmLabel="Unlink"
214
- onConfirm={() => unlink({ ...identity, label })}
355
+ confirmLabel="End session"
356
+ onConfirm={() => end(session)}
215
357
  />
216
358
  )}
217
359
  </td>
@@ -228,54 +370,41 @@ function SigninAccounts({
228
370
  </table>
229
371
  </div>
230
372
  )}
231
-
232
- {providers.length > 0 && (
233
- <div className="card-foot">
234
- <span className="hint">Link another account</span>
235
- <div className="link-providers">
236
- {providers.map((provider) => (
237
- <a
238
- key={provider.id}
239
- className="btn btn-sm"
240
- href={`/auth/signin/${encodeURIComponent(provider.id)}?link=1`}
241
- >
242
- <ProviderMark brand={provider.brand} size={14} />
243
- {provider.label}
244
- </a>
245
- ))}
246
- </div>
247
- </div>
248
- )}
249
373
  </Card>
250
374
  );
251
375
  }
252
376
 
253
- function Sessions({
254
- sessions,
255
- providers,
256
- }: {
257
- sessions: SessionRow[];
258
- providers: Provider[];
259
- }) {
260
- const change = endSession(useCoffre());
261
- const end = useChange(change);
377
+ /** The MCP clients you connected, such as Claude: each acts as you until it is disconnected or expires. */
378
+ function ConnectedApps() {
379
+ const client = useCoffre();
380
+ const { data: apps } = useSuspenseQuery(queries.apps(client));
381
+ const change = disconnectApp(client);
382
+ const disconnect = useChange(change);
262
383
  const { status, dismiss } = useChangeStatus(change.list.queryKey);
263
384
 
264
385
  return (
265
386
  <Card
266
- labelledBy="sessions"
267
- title="Sessions"
268
- description="Browsers and command lines signed in as you. Ending one signs it out at its next request."
387
+ labelledBy="apps"
388
+ title="Connected apps"
389
+ description="AI assistants and other MCP clients you connected. Each acts as you, never beyond your access, and every call it makes is in the audit log. Disconnecting one stops it at its next request."
269
390
  >
270
- {sessions.length === 0 ? (
271
- <EmptyState title="No sessions">Nothing is signed in as you right now.</EmptyState>
391
+ {!apps.ok ? (
392
+ <div className="card-body">
393
+ <ErrorLine error={apps.error} />
394
+ </div>
395
+ ) : apps.apps.length === 0 ? (
396
+ <EmptyState title="No connected apps">
397
+ An app such as Claude connects through coffre's MCP endpoint, at{' '}
398
+ <span className="mono">/mcp</span>, after you approve it here.
399
+ </EmptyState>
272
400
  ) : (
273
401
  <div className="dt-wrap">
274
- <table className="dt">
402
+ <table className="dt stacks stacks-inline">
275
403
  <thead>
276
404
  <tr>
277
- <th>Where</th>
278
- <th className="col-shrink">Last active</th>
405
+ <th>App</th>
406
+ <th>May</th>
407
+ <th className="col-shrink">Last used</th>
279
408
  <th className="col-shrink">Expires</th>
280
409
  <th className="col-actions">
281
410
  <span className="visually-hidden">Actions</span>
@@ -283,60 +412,72 @@ function Sessions({
283
412
  </tr>
284
413
  </thead>
285
414
  <tbody>
286
- {sessions.map((session) => {
287
- const state = status(session.id);
415
+ {apps.apps.map((app) => {
416
+ const state = status(app.id);
288
417
  return (
289
- <Fragment key={session.id}>
418
+ <Fragment key={app.id}>
290
419
  <tr className={rowClass(state)}>
291
420
  <td>
292
421
  <span className="cell-account">
293
- {session.kind === 'cli' ? <Terminal size={15} /> : <Monitor size={15} />}
422
+ <LinkIcon size={15} />
294
423
  <span className="cell-stack">
295
424
  <span>
296
- {session.label ?? (session.kind === 'cli' ? 'Command line' : 'Browser')}{' '}
297
- {session.current && <span className="tag tag-blue">this browser</span>}
425
+ {app.name}{' '}
426
+ {app.registration === 'dcr' && (
427
+ <span className="tag tag-amber" title="It registered itself: its name is its own claim">
428
+ Unverified
429
+ </span>
430
+ )}
298
431
  </span>
299
432
  <small>
300
- {session.kind === 'cli'
301
- ? 'coffre login'
302
- : `via ${providerLabel(providers, session.provider)}`}
303
- {session.lastUsedIp !== null && (
304
- <>
305
- {' · '}
306
- <span className="mono">{session.lastUsedIp}</span>
307
- </>
308
- )}
433
+ {app.host === null ? 'no website' : <span className="mono">{app.host}</span>}
434
+ {' · connected '}
435
+ <Timestamp iso={app.createdAt} display="relative" />
309
436
  </small>
310
437
  </span>
311
438
  </span>
312
439
  </td>
313
- <td className="nowrap cell-muted">
314
- <Timestamp iso={session.lastUsedAt ?? session.createdAt} display="relative" />
440
+ <td data-label="May">{scopeLabels(app)}</td>
441
+ <td className="nowrap cell-muted" data-label="Last used">
442
+ {app.lastUsedAt === null ? 'Never' : <Timestamp iso={app.lastUsedAt} display="relative" />}
315
443
  </td>
316
- <td className="nowrap cell-muted">
317
- <Timestamp iso={session.expiresAt} display="relative" />
444
+ <td className="nowrap cell-muted" data-label="Expires">
445
+ <Timestamp iso={app.expiresAt} display="relative" />
318
446
  </td>
319
447
  <td className="col-actions">
320
- {session.current ? (
321
- <form method="post" action="/auth/signout">
322
- <button className="act" type="submit">
323
- <SignOut size={13} />
324
- Sign out
325
- </button>
326
- </form>
327
- ) : state.state === 'pending' ? (
448
+ {state.state === 'pending' ? (
328
449
  <RowPending status={state} />
329
450
  ) : (
330
- <button className="act" onClick={() => end(session)}>
331
- <X size={13} />
332
- End
333
- </button>
451
+ <ConfirmButton
452
+ trigger={
453
+ <button className="act">
454
+ <X size={13} />
455
+ Disconnect
456
+ </button>
457
+ }
458
+ title={`Disconnect ${app.name}?`}
459
+ body={
460
+ <>
461
+ {app.name}
462
+ {app.host !== null && (
463
+ <>
464
+ {' '}at <span className="mono">{app.host}</span>
465
+ </>
466
+ )}
467
+ , last used{' '}
468
+ {app.lastUsedAt === null ? 'never' : <Timestamp iso={app.lastUsedAt} display="relative" />},
469
+ stops at its next request. To use it again, connect it again.
470
+ </>
471
+ }
472
+ confirmLabel="Disconnect"
473
+ onConfirm={() => disconnect(app)}
474
+ />
334
475
  )}
335
476
  </td>
336
477
  </tr>
337
478
  <RowFailure
338
479
  status={state}
339
- columns={4}
480
+ columns={5}
340
481
  onDismiss={() => state.state === 'failed' && dismiss(state.mutationId)}
341
482
  />
342
483
  </Fragment>
@@ -349,3 +490,7 @@ function Sessions({
349
490
  </Card>
350
491
  );
351
492
  }
493
+
494
+ function scopeLabels(app: ConnectedApp): string {
495
+ return app.scopes.map((scope) => MCP_SCOPE_INFO[scope].label).join(', ');
496
+ }