@coffre/ui 0.3.0 → 0.4.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 (180) 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/connected-apps-CUOyEZXR.js +146 -0
  4. package/dist/chunks/connected-apps-CUOyEZXR.js.map +1 -0
  5. package/dist/chunks/delete-place-CRX7ntE8.js +206 -0
  6. package/dist/chunks/delete-place-CRX7ntE8.js.map +1 -0
  7. package/dist/chunks/{directory-CSjWWUQ1.js → directory-CxxrnGUL.js} +177 -60
  8. package/dist/chunks/directory-CxxrnGUL.js.map +1 -0
  9. package/dist/chunks/folders-DoBmCwOi.js +207 -0
  10. package/dist/chunks/folders-DoBmCwOi.js.map +1 -0
  11. package/dist/chunks/grants-CXcmhujY.js +669 -0
  12. package/dist/chunks/grants-CXcmhujY.js.map +1 -0
  13. package/dist/chunks/offboarding-6eAduCsM.js +305 -0
  14. package/dist/chunks/offboarding-6eAduCsM.js.map +1 -0
  15. package/dist/chunks/one-time-DXEl9hbg.js +35 -0
  16. package/dist/chunks/one-time-DXEl9hbg.js.map +1 -0
  17. package/dist/chunks/page-DvsgZ2Hd.js +391 -0
  18. package/dist/chunks/page-DvsgZ2Hd.js.map +1 -0
  19. package/dist/chunks/principal-BIN-xwZw.js +42 -0
  20. package/dist/chunks/principal-BIN-xwZw.js.map +1 -0
  21. package/dist/chunks/{principal-page-D_91OA0l.js → principal-page-B9R2zPlp.js} +259 -251
  22. package/dist/chunks/principal-page-B9R2zPlp.js.map +1 -0
  23. package/dist/chunks/project-page-SRCtRe2g.js +17 -0
  24. package/dist/chunks/project-page-SRCtRe2g.js.map +1 -0
  25. package/dist/chunks/{queries-CQ81o4so.js → queries-DVR_i3rA.js} +132 -30
  26. package/dist/chunks/queries-DVR_i3rA.js.map +1 -0
  27. package/dist/chunks/references-B6pLT1uQ.js +343 -0
  28. package/dist/chunks/references-B6pLT1uQ.js.map +1 -0
  29. package/dist/chunks/{row-state-0PsrEzOL.js → row-state-DOPUsjQK.js} +3 -3
  30. package/dist/chunks/{row-state-0PsrEzOL.js.map → row-state-DOPUsjQK.js.map} +1 -1
  31. package/dist/chunks/signin-errors--ykMFuqN.js +57 -0
  32. package/dist/chunks/signin-errors--ykMFuqN.js.map +1 -0
  33. package/dist/chunks/tabs-BmwKfUeK.js +22 -0
  34. package/dist/chunks/tabs-BmwKfUeK.js.map +1 -0
  35. package/dist/chunks/{theme-B2vQolVR.js → theme-DJuz-xLM.js} +3 -3
  36. package/dist/chunks/{theme-B2vQolVR.js.map → theme-DJuz-xLM.js.map} +1 -1
  37. package/dist/chunks/{ui-DixXLQvQ.js → ui-DJje3gST.js} +6 -3
  38. package/dist/chunks/ui-DJje3gST.js.map +1 -0
  39. package/dist/chunks/{use-change-c6CeLRin.js → use-change-CZdI2MJG.js} +75 -21
  40. package/dist/chunks/use-change-CZdI2MJG.js.map +1 -0
  41. package/dist/chunks/{use-shell-jxd7Tzd-.js → use-shell-rNKfGjdj.js} +3 -3
  42. package/dist/chunks/{use-shell-jxd7Tzd-.js.map → use-shell-rNKfGjdj.js.map} +1 -1
  43. package/dist/chunks/validation-D312_NLf.js +87 -0
  44. package/dist/chunks/validation-D312_NLf.js.map +1 -0
  45. package/dist/index.d.ts +385 -31
  46. package/dist/index.js +188 -102
  47. package/dist/index.js.map +1 -1
  48. package/dist/pages/account.d.ts +2 -2
  49. package/dist/pages/account.js +174 -135
  50. package/dist/pages/account.js.map +1 -1
  51. package/dist/pages/approval.d.ts +9 -0
  52. package/dist/pages/approval.js +207 -0
  53. package/dist/pages/approval.js.map +1 -0
  54. package/dist/pages/audit.js +17 -542
  55. package/dist/pages/audit.js.map +1 -1
  56. package/dist/pages/device-login.js +2 -3
  57. package/dist/pages/device-login.js.map +1 -1
  58. package/dist/pages/environment.js +647 -257
  59. package/dist/pages/environment.js.map +1 -1
  60. package/dist/pages/login.js +18 -7
  61. package/dist/pages/login.js.map +1 -1
  62. package/dist/pages/oauth-authorize.d.ts +10 -0
  63. package/dist/pages/oauth-authorize.js +249 -0
  64. package/dist/pages/oauth-authorize.js.map +1 -0
  65. package/dist/pages/project-access.d.ts +6 -0
  66. package/dist/pages/project-access.js +370 -0
  67. package/dist/pages/project-access.js.map +1 -0
  68. package/dist/pages/project-environments.d.ts +4 -0
  69. package/dist/pages/project-environments.js +593 -0
  70. package/dist/pages/project-environments.js.map +1 -0
  71. package/dist/pages/project-settings.d.ts +4 -0
  72. package/dist/pages/project-settings.js +242 -0
  73. package/dist/pages/project-settings.js.map +1 -0
  74. package/dist/pages/project.d.ts +10 -2
  75. package/dist/pages/project.js +57 -934
  76. package/dist/pages/project.js.map +1 -1
  77. package/dist/pages/projects.js +53 -21
  78. package/dist/pages/projects.js.map +1 -1
  79. package/dist/pages/service-account.d.ts +10 -0
  80. package/dist/pages/{token.js → service-account.js} +112 -54
  81. package/dist/pages/service-account.js.map +1 -0
  82. package/dist/pages/service-accounts.d.ts +3 -0
  83. package/dist/pages/service-accounts.js +38 -0
  84. package/dist/pages/service-accounts.js.map +1 -0
  85. package/dist/pages/settings.d.ts +1 -0
  86. package/dist/pages/settings.js +104 -42
  87. package/dist/pages/settings.js.map +1 -1
  88. package/dist/pages/unregistered.js +2 -3
  89. package/dist/pages/unregistered.js.map +1 -1
  90. package/dist/pages/user.d.ts +6 -1
  91. package/dist/pages/user.js +18 -6
  92. package/dist/pages/user.js.map +1 -1
  93. package/dist/pages/users.js +6 -10
  94. package/dist/pages/users.js.map +1 -1
  95. package/package.json +3 -3
  96. package/src/components/actions-log.tsx +117 -0
  97. package/src/components/audit-sentence.tsx +55 -0
  98. package/src/components/command-palette.tsx +4 -4
  99. package/src/components/connected-apps.tsx +138 -0
  100. package/src/components/delete-place.tsx +180 -0
  101. package/src/components/directory.tsx +266 -110
  102. package/src/components/every-project.tsx +287 -0
  103. package/src/components/expiry-field.tsx +42 -0
  104. package/src/components/folders.tsx +219 -0
  105. package/src/components/grants.tsx +11 -4
  106. package/src/components/icons.tsx +2 -0
  107. package/src/components/missing.tsx +110 -0
  108. package/src/components/offboarding.tsx +62 -34
  109. package/src/components/page.tsx +4 -1
  110. package/src/components/principal-page.tsx +154 -108
  111. package/src/components/principal-picker.tsx +5 -5
  112. package/src/components/principal.tsx +4 -4
  113. package/src/components/references.tsx +323 -0
  114. package/src/components/service-tokens.tsx +112 -93
  115. package/src/components/shell.tsx +11 -32
  116. package/src/components/tabs.tsx +18 -0
  117. package/src/components/trusted-workloads.tsx +97 -79
  118. package/src/components/ui.tsx +8 -1
  119. package/src/index.ts +13 -3
  120. package/src/layout.tsx +2 -2
  121. package/src/lib/access-plan.ts +2 -2
  122. package/src/lib/audit-sentences.ts +161 -77
  123. package/src/lib/changes.ts +77 -5
  124. package/src/lib/coffre.ts +3 -2
  125. package/src/lib/one-time.ts +32 -0
  126. package/src/lib/project-access.ts +11 -23
  127. package/src/lib/project-page.ts +14 -0
  128. package/src/lib/queries.ts +126 -32
  129. package/src/lib/search.ts +25 -0
  130. package/src/lib/signin-errors.ts +45 -1
  131. package/src/lib/validation.ts +14 -0
  132. package/src/options.ts +187 -42
  133. package/src/pages/account.tsx +176 -133
  134. package/src/pages/approval.tsx +197 -0
  135. package/src/pages/audit.tsx +9 -61
  136. package/src/pages/environment.tsx +585 -286
  137. package/src/pages/login.tsx +8 -2
  138. package/src/pages/oauth-authorize.tsx +233 -0
  139. package/src/pages/project-access.tsx +219 -0
  140. package/src/pages/project-environments.tsx +582 -0
  141. package/src/pages/project-settings.tsx +259 -0
  142. package/src/pages/project.tsx +52 -879
  143. package/src/pages/projects.tsx +55 -18
  144. package/src/pages/service-account.tsx +50 -0
  145. package/src/pages/{tokens.tsx → service-accounts.tsx} +9 -6
  146. package/src/pages/settings.tsx +62 -8
  147. package/src/pages/user.tsx +16 -4
  148. package/src/pages/users.tsx +2 -2
  149. package/src/parity.ts +160 -0
  150. package/src/register.ts +57 -10
  151. package/src/router.tsx +4 -0
  152. package/src/shared/models.ts +6 -2
  153. package/src/styles/globals.css +536 -31
  154. package/dist/chunks/directory-CSjWWUQ1.js.map +0 -1
  155. package/dist/chunks/grants-saMQagmG.js +0 -160
  156. package/dist/chunks/grants-saMQagmG.js.map +0 -1
  157. package/dist/chunks/icons-D-PfAfnH.js +0 -203
  158. package/dist/chunks/icons-D-PfAfnH.js.map +0 -1
  159. package/dist/chunks/offboarding-C6l30DZR.js +0 -263
  160. package/dist/chunks/offboarding-C6l30DZR.js.map +0 -1
  161. package/dist/chunks/page-C5HcNqf2.js +0 -190
  162. package/dist/chunks/page-C5HcNqf2.js.map +0 -1
  163. package/dist/chunks/principal-page-D_91OA0l.js.map +0 -1
  164. package/dist/chunks/queries-CQ81o4so.js.map +0 -1
  165. package/dist/chunks/signin-errors-BEFlVDbQ.js +0 -30
  166. package/dist/chunks/signin-errors-BEFlVDbQ.js.map +0 -1
  167. package/dist/chunks/ui-DixXLQvQ.js.map +0 -1
  168. package/dist/chunks/use-action-CWsg_YWU.js +0 -49
  169. package/dist/chunks/use-action-CWsg_YWU.js.map +0 -1
  170. package/dist/chunks/use-change-c6CeLRin.js.map +0 -1
  171. package/dist/chunks/validation-BQtqPe2V.js +0 -29
  172. package/dist/chunks/validation-BQtqPe2V.js.map +0 -1
  173. package/dist/pages/token.d.ts +0 -3
  174. package/dist/pages/token.js.map +0 -1
  175. package/dist/pages/tokens.d.ts +0 -3
  176. package/dist/pages/tokens.js +0 -39
  177. package/dist/pages/tokens.js.map +0 -1
  178. package/dist/project-BqIy8gYR.d.ts +0 -5
  179. package/src/lib/instance.ts +0 -13
  180. 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,13 +8,15 @@ 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';
19
+ import { ConnectedAppsCard } from '../components/connected-apps';
17
20
  import { pageRoute } from '../lib/page-route';
18
21
  import type { account } from '../options';
19
22
 
@@ -23,13 +26,13 @@ type Search = { linked?: string; error?: string };
23
26
 
24
27
  /**
25
28
  * 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
29
+ * coffre runs its own sign-in, which accounts you sign in with, where you
30
+ * are signed in, and the MCP clients you connected. The sidebar's Settings is the instance's; this page is
28
31
  * reached from your account at the sidebar's foot.
29
32
  */
30
33
 
31
34
  export function AccountPage() {
32
- const { principal, instanceRole, auth } = useShell();
35
+ const { principal, instanceRole, auth, features } = useShell();
33
36
 
34
37
  return (
35
38
  <>
@@ -67,6 +70,8 @@ export function AccountPage() {
67
70
  {auth.signin !== null && principal?.type === 'user' && (
68
71
  <SignIn email={principal.id} providers={auth.signin.providers} />
69
72
  )}
73
+
74
+ {features.mcp && principal?.type === 'user' && <ConnectedApps />}
70
75
  </>
71
76
  );
72
77
  }
@@ -117,136 +122,136 @@ function SigninAccounts({
117
122
  providers: Provider[];
118
123
  identities: IdentityRow[];
119
124
  }) {
120
- const { linked, error } = Route.useSearch();
125
+ // Shown once: a reload shows the accounts, not the last link's outcome again.
126
+ const { linked, error } = useOneTime(Route.useSearch(), ['linked', 'error']);
121
127
  const message = signinErrorMessage(error);
122
128
  const change = unlinkIdentity(useCoffre());
123
129
  const unlink = useChange(change);
124
130
  const { status, dismiss } = useChangeStatus(change.list.queryKey);
125
131
 
126
132
  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} />
138
- </div>
139
- )}
133
+ <>
134
+ <Card
135
+ labelledBy="signin-accounts"
136
+ title="Sign-in accounts"
137
+ description="coffre recognises you by these accounts, never by an email address alone. A new account is linked here, while you are signed in."
138
+ >
139
+ {(linked !== undefined || message !== null) && (
140
+ <div className="card-body">
141
+ {linked !== undefined && (
142
+ <Notice tone="good">{providerLabel(providers, linked)} account linked.</Notice>
143
+ )}
144
+ <ErrorLine error={message} />
145
+ </div>
146
+ )}
140
147
 
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>
146
- ) : (
147
- <div className="dt-wrap">
148
- <table className="dt">
149
- <thead>
150
- <tr>
151
- <th>Account</th>
152
- <th className="col-shrink">Linked (UTC)</th>
153
- <th className="col-shrink">Last sign-in</th>
154
- <th className="col-actions">
155
- <span className="visually-hidden">Actions</span>
156
- </th>
157
- </tr>
158
- </thead>
159
- <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);
164
- return (
165
- <Fragment key={identity.id}>
166
- <tr className={rowClass(state)}>
167
- <td>
168
- <span className="cell-account">
169
- <ProviderMark brand={brand} />
170
- <span className="cell-stack">
171
- <span>{label}</span>
172
- {identity.email !== null && <small className="mono">{identity.email}</small>}
148
+ {identities.length === 0 ? (
149
+ <EmptyState title="No account linked">
150
+ Your next sign-in with a verified <span className="mono">{email}</span> links that
151
+ account.
152
+ </EmptyState>
153
+ ) : (
154
+ <div className="dt-wrap">
155
+ <table className="dt stacks stacks-inline">
156
+ <thead>
157
+ <tr>
158
+ <th>Account</th>
159
+ <th className="col-shrink">Linked (UTC)</th>
160
+ <th className="col-shrink">Last sign-in</th>
161
+ <th className="col-actions">
162
+ <span className="visually-hidden">Actions</span>
163
+ </th>
164
+ </tr>
165
+ </thead>
166
+ <tbody>
167
+ {identities.map((identity) => {
168
+ const label = providerLabel(providers, identity.provider);
169
+ const brand = providers.find((p) => p.id === identity.provider)?.brand ?? 'oidc';
170
+ const state = status(identity.id);
171
+ return (
172
+ <Fragment key={identity.id}>
173
+ <tr className={rowClass(state)}>
174
+ <td>
175
+ <span className="cell-account">
176
+ <ProviderMark brand={brand} />
177
+ <span className="cell-stack">
178
+ <span>{label}</span>
179
+ {identity.email !== null && <small className="mono">{identity.email}</small>}
180
+ </span>
173
181
  </span>
174
- </span>
175
- </td>
176
- <td className="nowrap">
177
- <Timestamp iso={identity.createdAt} />
178
- </td>
179
- <td className="nowrap cell-muted">
180
- {identity.lastSignInAt === null ? (
181
- 'Never'
182
- ) : (
183
- <Timestamp iso={identity.lastSignInAt} display="relative" />
184
- )}
185
- </td>
186
- <td className="col-actions">
187
- {state.state === 'pending' ? (
188
- <RowPending status={state} />
189
- ) : (
190
- <ConfirmButton
191
- trigger={
192
- <button className="act">
193
- <X size={13} />
194
- Unlink
195
- </button>
196
- }
197
- title={`Unlink this ${label} account?`}
198
- 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
- )
212
- }
213
- confirmLabel="Unlink"
214
- onConfirm={() => unlink({ ...identity, label })}
215
- />
216
- )}
217
- </td>
218
- </tr>
219
- <RowFailure
220
- status={state}
221
- columns={4}
222
- onDismiss={() => state.state === 'failed' && dismiss(state.mutationId)}
223
- />
224
- </Fragment>
225
- );
226
- })}
227
- </tbody>
228
- </table>
229
- </div>
230
- )}
231
-
182
+ </td>
183
+ <td className="nowrap" data-label="Linked (UTC)">
184
+ <Timestamp iso={identity.createdAt} />
185
+ </td>
186
+ <td className="nowrap cell-muted" data-label="Last sign-in">
187
+ {identity.lastSignInAt === null ? (
188
+ 'Never'
189
+ ) : (
190
+ <Timestamp iso={identity.lastSignInAt} display="relative" />
191
+ )}
192
+ </td>
193
+ <td className="col-actions">
194
+ {state.state === 'pending' ? (
195
+ <RowPending status={state} />
196
+ ) : (
197
+ <ConfirmButton
198
+ trigger={
199
+ <button className="act">
200
+ <X size={13} />
201
+ Unlink
202
+ </button>
203
+ }
204
+ title={`Unlink this ${label} account?`}
205
+ body={
206
+ identities.length === 1 ? (
207
+ <>
208
+ It stops signing you in, and every session it opened ends now,
209
+ this one included if you signed in with it. Your next sign-in
210
+ with any account whose verified email is{' '}
211
+ <span className="mono">{email}</span> links that account instead.
212
+ </>
213
+ ) : (
214
+ <>
215
+ It stops signing you in, and every session it opened ends now,
216
+ this one included if you signed in with it.
217
+ </>
218
+ )
219
+ }
220
+ confirmLabel="Unlink"
221
+ onConfirm={() => unlink({ ...identity, label })}
222
+ />
223
+ )}
224
+ </td>
225
+ </tr>
226
+ <RowFailure
227
+ status={state}
228
+ columns={4}
229
+ onDismiss={() => state.state === 'failed' && dismiss(state.mutationId)}
230
+ />
231
+ </Fragment>
232
+ );
233
+ })}
234
+ </tbody>
235
+ </table>
236
+ </div>
237
+ )}
238
+ </Card>
232
239
  {providers.length > 0 && (
233
- <div className="card-foot">
240
+ <div className="table-actions">
234
241
  <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>
242
+ {providers.map((provider) => (
243
+ <a
244
+ key={provider.id}
245
+ className="btn"
246
+ href={`/auth/signin/${encodeURIComponent(provider.id)}?link=1`}
247
+ >
248
+ <ProviderMark brand={provider.brand} size={14} />
249
+ {provider.label}
250
+ </a>
251
+ ))}
247
252
  </div>
248
253
  )}
249
- </Card>
254
+ </>
250
255
  );
251
256
  }
252
257
 
@@ -271,7 +276,7 @@ function Sessions({
271
276
  <EmptyState title="No sessions">Nothing is signed in as you right now.</EmptyState>
272
277
  ) : (
273
278
  <div className="dt-wrap">
274
- <table className="dt">
279
+ <table className="dt stacks stacks-inline">
275
280
  <thead>
276
281
  <tr>
277
282
  <th>Where</th>
@@ -294,7 +299,7 @@ function Sessions({
294
299
  <span className="cell-stack">
295
300
  <span>
296
301
  {session.label ?? (session.kind === 'cli' ? 'Command line' : 'Browser')}{' '}
297
- {session.current && <span className="tag tag-blue">this browser</span>}
302
+ {session.current && <span className="tag tag-blue">This browser</span>}
298
303
  </span>
299
304
  <small>
300
305
  {session.kind === 'cli'
@@ -310,10 +315,10 @@ function Sessions({
310
315
  </span>
311
316
  </span>
312
317
  </td>
313
- <td className="nowrap cell-muted">
318
+ <td className="nowrap cell-muted" data-label="Last active">
314
319
  <Timestamp iso={session.lastUsedAt ?? session.createdAt} display="relative" />
315
320
  </td>
316
- <td className="nowrap cell-muted">
321
+ <td className="nowrap cell-muted" data-label="Expires">
317
322
  <Timestamp iso={session.expiresAt} display="relative" />
318
323
  </td>
319
324
  <td className="col-actions">
@@ -327,10 +332,30 @@ function Sessions({
327
332
  ) : state.state === 'pending' ? (
328
333
  <RowPending status={state} />
329
334
  ) : (
330
- <button className="act" onClick={() => end(session)}>
331
- <X size={13} />
332
- End
333
- </button>
335
+ <ConfirmButton
336
+ trigger={
337
+ <button className="act">
338
+ <X size={13} />
339
+ End
340
+ </button>
341
+ }
342
+ title={`End this ${session.kind === 'cli' ? 'command line' : 'browser'} session?`}
343
+ body={
344
+ <>
345
+ {session.label ?? (session.kind === 'cli' ? 'The command line' : 'The browser')}
346
+ {session.lastUsedIp !== null && (
347
+ <>
348
+ {' '}at <span className="mono">{session.lastUsedIp}</span>
349
+ </>
350
+ )}
351
+ , last active{' '}
352
+ <Timestamp iso={session.lastUsedAt ?? session.createdAt} display="relative" />, is
353
+ signed out at its next request.
354
+ </>
355
+ }
356
+ confirmLabel="End session"
357
+ onConfirm={() => end(session)}
358
+ />
334
359
  )}
335
360
  </td>
336
361
  </tr>
@@ -349,3 +374,21 @@ function Sessions({
349
374
  </Card>
350
375
  );
351
376
  }
377
+
378
+ /** The MCP clients you connected, such as Claude: each acts as you until it is disconnected or expires. */
379
+ function ConnectedApps() {
380
+ const client = useCoffre();
381
+ const { data: apps } = useSuspenseQuery(queries.apps(client));
382
+ return (
383
+ <ConnectedAppsCard
384
+ apps={apps.ok ? apps.apps : { error: apps.error }}
385
+ change={disconnectApp(client)}
386
+ 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."
387
+ empty={
388
+ <>
389
+ An app such as Claude connects through coffre's MCP endpoint, at <span className="mono">/mcp</span>, after you approve it here.
390
+ </>
391
+ }
392
+ />
393
+ );
394
+ }
@@ -0,0 +1,197 @@
1
+ import { useState } from 'react';
2
+ import type { ApprovalView, Decision } from '@coffre/client';
3
+
4
+ import { failureMessage, statusOf, useCoffre } from '../lib/coffre';
5
+ import { ClosedDoor } from '../components/page';
6
+ import { CopyButton, ErrorLine, Notice, Spinner, Timestamp } from '../components/ui';
7
+ import { CheckCircle, Link as LinkIcon, SlashCircle } from '../components/icons';
8
+ import { pageRoute } from '../lib/page-route';
9
+ import type { approval } from '../options';
10
+
11
+ const Route = pageRoute<typeof approval>();
12
+
13
+ /**
14
+ * Where an MCP client sends you to confirm a change it asked for: what it
15
+ * would do, read afresh, and Approve, which makes it here and now, as you.
16
+ * The app only hears what became of it. Nothing changes until you press
17
+ * Approve, and a value you type goes to coffre and nowhere else.
18
+ */
19
+ export function ApprovalPage() {
20
+ const loaded = Route.useLoaderData();
21
+ const [decided, setDecided] = useState<Decision | null>(null);
22
+
23
+ if (decided !== null) return <Decided decision={decided} reveal={loaded.ok && loaded.approval.kind === 'reveal'} />;
24
+ if (!loaded.ok) {
25
+ return (
26
+ <ClosedDoor icon={<SlashCircle size={18} />} label="Approve a change" title="This approval can't be shown">
27
+ <p>{loaded.error}</p>
28
+ </ClosedDoor>
29
+ );
30
+ }
31
+ const view = loaded.approval;
32
+ if (view.status !== 'pending') return <Settled view={view} />;
33
+ return <Approve view={view} onDecided={setDecided} />;
34
+ }
35
+
36
+ const SETTLED: Record<Exclude<ApprovalView['status'], 'pending'>, string> = {
37
+ approved: 'You approved this',
38
+ denied: 'You denied this',
39
+ cancelled: 'The app cancelled this',
40
+ failed: 'This change failed',
41
+ expired: 'This approval expired',
42
+ };
43
+
44
+ function Settled({ view }: { view: ApprovalView }) {
45
+ const status = view.status as keyof typeof SETTLED;
46
+ return (
47
+ <ClosedDoor
48
+ icon={status === 'approved' ? <CheckCircle size={18} /> : <SlashCircle size={18} />}
49
+ label="Approve a change"
50
+ title={SETTLED[status]}
51
+ >
52
+ <p>
53
+ {view.client.name} asked to {view.summary}.{' '}
54
+ {view.outcome?.text ?? (status === 'expired' ? 'Nothing changed. The app can ask again.' : 'Nothing changed.')}
55
+ </p>
56
+ </ClosedDoor>
57
+ );
58
+ }
59
+
60
+ function Decided({ decision, reveal }: { decision: Decision; reveal: boolean }) {
61
+ const done = decision.status === 'approved';
62
+ return (
63
+ <ClosedDoor
64
+ icon={done ? <CheckCircle size={18} /> : <SlashCircle size={18} />}
65
+ label={reveal ? 'Show a value' : 'Approve a change'}
66
+ title={done ? (reveal ? 'The value' : 'Done') : decision.status === 'denied' ? 'Denied' : reveal ? 'It could not be shown' : 'The change failed'}
67
+ >
68
+ {!(reveal && done) && <p>{decision.outcome.text}</p>}
69
+ {decision.shown.length > 0 && (
70
+ <>
71
+ <Notice tone="warn">{reveal ? 'Shown here only, and logged as your reveal: the app does not get it.' : 'Shown once, here only: copy it now. The app does not get it.'}</Notice>
72
+ <dl className="facts device-facts">
73
+ {decision.shown.map((line) => (
74
+ <div className="fact" key={line.label}>
75
+ <dt>{line.label}</dt>
76
+ <dd className="cell-account">
77
+ <span className="mono approval-shown">{line.value}</span>
78
+ <CopyButton value={line.value} label={`Copy ${line.label.toLowerCase()}`} />
79
+ </dd>
80
+ </div>
81
+ ))}
82
+ </dl>
83
+ </>
84
+ )}
85
+ <p>You can close this tab: the app hears the outcome when it asks.</p>
86
+ </ClosedDoor>
87
+ );
88
+ }
89
+
90
+ function Approve({ view, onDecided }: { view: ApprovalView; onDecided: (decision: Decision) => void }) {
91
+ const coffre = useCoffre();
92
+ const [value, setValue] = useState('');
93
+ const [pending, setPending] = useState<'approve' | 'deny' | null>(null);
94
+ const [error, setError] = useState<string | null>(null);
95
+ const { client } = view;
96
+ const asksValue = view.asks?.value ?? null;
97
+ const reveal = view.kind === 'reveal';
98
+
99
+ async function decide(approve: boolean) {
100
+ setPending(approve ? 'approve' : 'deny');
101
+ try {
102
+ onDecided(
103
+ await coffre.approvals.decide(view.id, {
104
+ approve,
105
+ digest: view.digest,
106
+ ...(approve && asksValue !== null ? { value } : {}),
107
+ }),
108
+ );
109
+ } catch (error) {
110
+ setError(statusOf(error) === undefined ? 'The answer could not be sent. Nothing changed.' : failureMessage(error));
111
+ setPending(null);
112
+ }
113
+ }
114
+
115
+ return (
116
+ <section className="card signin" aria-labelledby="approval-title">
117
+ <div className="signin-head">
118
+ <h1 className="signin-title" id="approval-title">
119
+ {reveal ? 'Show this value?' : 'Approve this change?'}
120
+ </h1>
121
+ <p className="signin-lede">
122
+ {client.name} asks to <strong>{view.summary}</strong>.{' '}
123
+ {reveal
124
+ ? 'Reveal shows it here, to you, logged as your reveal; it is never sent to the app.'
125
+ : 'Read what it does: nothing changes until you approve, and then coffre makes it, as you.'}
126
+ </p>
127
+ </div>
128
+
129
+ <div className="consent-client">
130
+ <LinkIcon size={16} />
131
+ <span className="cell-stack">
132
+ {client.host !== null ? <span className="consent-host mono">{client.host}</span> : <span className="consent-host">{client.name}</span>}
133
+ <span>
134
+ {client.host !== null && <>{client.name} </>}
135
+ {client.registration === 'dcr' && <span className="tag tag-amber">Unverified</span>}
136
+ </span>
137
+ </span>
138
+ </div>
139
+
140
+ <dl className="facts device-facts">
141
+ {view.details.map((line) => (
142
+ <div className="fact" key={line.label}>
143
+ <dt>{line.label}</dt>
144
+ <dd className={line.kind === 'mono' ? 'mono' : undefined}>
145
+ {line.kind === 'time' ? <Timestamp iso={line.value} /> : line.value}
146
+ </dd>
147
+ </div>
148
+ ))}
149
+ <div className="fact">
150
+ <dt>Expires (UTC)</dt>
151
+ <dd>
152
+ <Timestamp iso={view.expiresAt} />
153
+ </dd>
154
+ </div>
155
+ </dl>
156
+
157
+ {asksValue !== null && (
158
+ <label className="field approval-field">
159
+ <span className="label">{asksValue.label}</span>
160
+ <textarea
161
+ className="input mono approval-value"
162
+ name="value"
163
+ rows={3}
164
+ autoComplete="off"
165
+ spellCheck={false}
166
+ value={value}
167
+ disabled={pending !== null}
168
+ onChange={(event) => setValue(event.target.value)}
169
+ />
170
+ <small>{asksValue.note}</small>
171
+ </label>
172
+ )}
173
+
174
+ <div className="consent-notices">
175
+ {client.registration === 'dcr' && (
176
+ <Notice tone="warn">This app registered itself: its name is its own claim. Approve only what you asked it to do.</Notice>
177
+ )}
178
+ <ErrorLine error={error} />
179
+ </div>
180
+
181
+ <div className="device-actions">
182
+ <button className="btn" disabled={pending !== null} onClick={() => void decide(false)}>
183
+ {pending === 'deny' && <Spinner />}
184
+ Deny
185
+ </button>
186
+ <button
187
+ className="btn btn-primary"
188
+ disabled={pending !== null || (asksValue !== null && value === '')}
189
+ onClick={() => void decide(true)}
190
+ >
191
+ {pending === 'approve' && <Spinner />}
192
+ {reveal ? 'Reveal' : 'Approve'}
193
+ </button>
194
+ </div>
195
+ </section>
196
+ );
197
+ }