@coffre/ui 0.4.0 → 0.4.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 (72) hide show
  1. package/dist/chunks/connected-apps-D8Df97-F.js +146 -0
  2. package/dist/chunks/connected-apps-D8Df97-F.js.map +1 -0
  3. package/dist/chunks/{delete-place-CRX7ntE8.js → delete-place-LYN7z7xb.js} +3 -3
  4. package/dist/chunks/{delete-place-CRX7ntE8.js.map → delete-place-LYN7z7xb.js.map} +1 -1
  5. package/dist/chunks/{directory-zr3ek7Mc.js → directory-v87HGjEn.js} +8 -6
  6. package/dist/chunks/{directory-zr3ek7Mc.js.map → directory-v87HGjEn.js.map} +1 -1
  7. package/dist/chunks/{folders-DoBmCwOi.js → folders-CbGU0xOz.js} +2 -2
  8. package/dist/chunks/{folders-DoBmCwOi.js.map → folders-CbGU0xOz.js.map} +1 -1
  9. package/dist/chunks/{grants-Cw1FyGID.js → grants-9kIV6uZ7.js} +5 -5
  10. package/dist/chunks/{grants-Cw1FyGID.js.map → grants-9kIV6uZ7.js.map} +1 -1
  11. package/dist/chunks/{offboarding-CE6d7um1.js → offboarding-DdnmRV1f.js} +3 -3
  12. package/dist/chunks/offboarding-DdnmRV1f.js.map +1 -0
  13. package/dist/chunks/{principal-page-DhjO76GH.js → principal-page-BubEO6-b.js} +24 -10
  14. package/dist/chunks/principal-page-BubEO6-b.js.map +1 -0
  15. package/dist/chunks/{project-page-SRCtRe2g.js → project-page-C4cEaRFa.js} +2 -2
  16. package/dist/chunks/{project-page-SRCtRe2g.js.map → project-page-C4cEaRFa.js.map} +1 -1
  17. package/dist/chunks/{queries-DVR_i3rA.js → queries-Dew8mIeo.js} +3 -3
  18. package/dist/chunks/queries-Dew8mIeo.js.map +1 -0
  19. package/dist/chunks/{references-B6pLT1uQ.js → references-DPSYdWOk.js} +3 -3
  20. package/dist/chunks/{references-B6pLT1uQ.js.map → references-DPSYdWOk.js.map} +1 -1
  21. package/dist/chunks/{use-change-DUiGO19U.js → use-change-C4bGRhHY.js} +31 -8
  22. package/dist/chunks/use-change-C4bGRhHY.js.map +1 -0
  23. package/dist/chunks/{use-shell-rNKfGjdj.js → use-shell-Dkv89nW1.js} +2 -2
  24. package/dist/chunks/{use-shell-rNKfGjdj.js.map → use-shell-Dkv89nW1.js.map} +1 -1
  25. package/dist/chunks/{validation-D312_NLf.js → validation-DvPinn8V.js} +2 -2
  26. package/dist/chunks/{validation-D312_NLf.js.map → validation-DvPinn8V.js.map} +1 -1
  27. package/dist/index.d.ts +47 -8
  28. package/dist/index.js +36 -12
  29. package/dist/index.js.map +1 -1
  30. package/dist/pages/account.d.ts +13 -3
  31. package/dist/pages/account.js +164 -198
  32. package/dist/pages/account.js.map +1 -1
  33. package/dist/pages/audit.js +1 -1
  34. package/dist/pages/environment.js +9 -10
  35. package/dist/pages/environment.js.map +1 -1
  36. package/dist/pages/login.js +1 -1
  37. package/dist/pages/oauth-authorize.d.ts +2 -1
  38. package/dist/pages/oauth-authorize.js +12 -8
  39. package/dist/pages/oauth-authorize.js.map +1 -1
  40. package/dist/pages/project-access.js +7 -7
  41. package/dist/pages/project-environments.js +8 -8
  42. package/dist/pages/project-settings.js +6 -6
  43. package/dist/pages/project.js +2 -2
  44. package/dist/pages/projects.js +6 -6
  45. package/dist/pages/service-account.js +6 -6
  46. package/dist/pages/service-account.js.map +1 -1
  47. package/dist/pages/service-accounts.js +4 -4
  48. package/dist/pages/settings.js +2 -2
  49. package/dist/pages/unregistered.js +1 -1
  50. package/dist/pages/user.js +1 -1
  51. package/dist/pages/users.js +4 -4
  52. package/package.json +3 -3
  53. package/src/components/connected-apps.tsx +138 -0
  54. package/src/components/directory.tsx +9 -2
  55. package/src/components/offboarding.tsx +1 -1
  56. package/src/components/principal-page.tsx +19 -3
  57. package/src/components/service-tokens.tsx +1 -1
  58. package/src/index.ts +4 -1
  59. package/src/lib/changes.ts +23 -2
  60. package/src/lib/queries.ts +2 -2
  61. package/src/options.ts +41 -13
  62. package/src/pages/account.tsx +142 -166
  63. package/src/pages/environment.tsx +2 -2
  64. package/src/pages/oauth-authorize.tsx +10 -7
  65. package/src/parity.ts +4 -4
  66. package/src/register.ts +13 -5
  67. package/src/shared/models.ts +1 -1
  68. package/src/styles/globals.css +9 -4
  69. package/dist/chunks/offboarding-CE6d7um1.js.map +0 -1
  70. package/dist/chunks/principal-page-DhjO76GH.js.map +0 -1
  71. package/dist/chunks/queries-DVR_i3rA.js.map +0 -1
  72. package/dist/chunks/use-change-DUiGO19U.js.map +0 -1
@@ -1,8 +1,8 @@
1
1
  import { i as PageHeader, n as ClosedDoor, rt as Users, u as useCoffre } from "../chunks/page-DvsgZ2Hd.js";
2
- import { p as queries } from "../chunks/queries-DVR_i3rA.js";
3
- import { t as useShell } from "../chunks/use-shell-rNKfGjdj.js";
4
- import { t as DirectoryTable } from "../chunks/directory-zr3ek7Mc.js";
5
- import { n as RemovedList } from "../chunks/offboarding-CE6d7um1.js";
2
+ import { p as queries } from "../chunks/queries-Dew8mIeo.js";
3
+ import { t as useShell } from "../chunks/use-shell-Dkv89nW1.js";
4
+ import { t as DirectoryTable } from "../chunks/directory-v87HGjEn.js";
5
+ import { n as RemovedList } from "../chunks/offboarding-DdnmRV1f.js";
6
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
7
  import { useSuspenseQuery } from "@tanstack/react-query";
8
8
  //#region src/pages/users.tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coffre/ui",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "coffre's pages, for a deployment's own TanStack Start app: its router, and a Vite plugin for its build.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -44,8 +44,8 @@
44
44
  "@tanstack/router-core": "1.171.15",
45
45
  "lucide-react": "1.47.0",
46
46
  "sonner": "2.0.7",
47
- "@coffre/client": "0.4.0",
48
- "@coffre/core": "0.4.0"
47
+ "@coffre/client": "0.4.2",
48
+ "@coffre/core": "0.4.2"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@tanstack/react-query": "5.103.1",
@@ -0,0 +1,138 @@
1
+ import type { ConnectedApp } from '@coffre/client';
2
+ import { MCP_SCOPE_INFO } from '@coffre/core/mcp';
3
+ import { Fragment, type ReactNode } from 'react';
4
+
5
+ import type { Change } from '../lib/optimistic';
6
+ import { useChange, useChangeStatus } from '../lib/use-change';
7
+ import { Link as LinkIcon, X } from './icons';
8
+ import { Card } from './page';
9
+ import { RowFailure, RowPending, rowClass } from './row-state';
10
+ import { ConfirmButton, EmptyState, ErrorLine, Timestamp } from './ui';
11
+
12
+ /**
13
+ * MCP clients connected as someone: your own on your account page, or a
14
+ * person's on theirs, for an owner. Each row says what the app is, what it
15
+ * may do, and when it was last used; Disconnect stops it at its next request.
16
+ */
17
+ export function ConnectedAppsCard<TData>({
18
+ apps,
19
+ change,
20
+ description,
21
+ empty,
22
+ }: {
23
+ apps: ConnectedApp[] | { error: string };
24
+ change: Change<TData, ConnectedApp, ConnectedApp, unknown>;
25
+ description: ReactNode;
26
+ empty: ReactNode;
27
+ }) {
28
+ const disconnect = useChange(change);
29
+ const { status, dismiss } = useChangeStatus(change.list.queryKey);
30
+ return (
31
+ <Card
32
+ labelledBy="apps"
33
+ title="Connected apps"
34
+ description={description}
35
+ >
36
+ {'error' in apps ? (
37
+ <div className="card-body">
38
+ <ErrorLine error={apps.error} />
39
+ </div>
40
+ ) : apps.length === 0 ? (
41
+ <EmptyState title="No connected apps">{empty}</EmptyState>
42
+ ) : (
43
+ <div className="dt-wrap">
44
+ <table className="dt stacks stacks-inline">
45
+ <thead>
46
+ <tr>
47
+ <th>App</th>
48
+ <th>May</th>
49
+ <th className="col-shrink">Last used</th>
50
+ <th className="col-shrink">Expires</th>
51
+ <th className="col-actions">
52
+ <span className="visually-hidden">Actions</span>
53
+ </th>
54
+ </tr>
55
+ </thead>
56
+ <tbody>
57
+ {apps.map((app) => {
58
+ const state = status(app.id);
59
+ return (
60
+ <Fragment key={app.id}>
61
+ <tr className={rowClass(state)}>
62
+ <td>
63
+ <span className="cell-account">
64
+ <LinkIcon size={15} />
65
+ <span className="cell-stack">
66
+ <span>
67
+ {app.name}{' '}
68
+ {app.registration === 'dcr' && (
69
+ <span className="tag tag-amber" title="It registered itself: its name is its own claim">
70
+ Unverified
71
+ </span>
72
+ )}
73
+ </span>
74
+ <small>
75
+ {app.host === null ? 'no website' : <span className="mono">{app.host}</span>}
76
+ {' · connected '}
77
+ <Timestamp iso={app.createdAt} display="relative" />
78
+ </small>
79
+ </span>
80
+ </span>
81
+ </td>
82
+ <td data-label="May">{scopeLabels(app)}</td>
83
+ <td className="nowrap cell-muted" data-label="Last used">
84
+ {app.lastUsedAt === null ? 'Never' : <Timestamp iso={app.lastUsedAt} display="relative" />}
85
+ </td>
86
+ <td className="nowrap cell-muted" data-label="Expires">
87
+ <Timestamp iso={app.expiresAt} display="relative" />
88
+ </td>
89
+ <td className="col-actions">
90
+ {state.state === 'pending' ? (
91
+ <RowPending status={state} />
92
+ ) : (
93
+ <ConfirmButton
94
+ trigger={
95
+ <button className="act">
96
+ <X size={13} />
97
+ Disconnect
98
+ </button>
99
+ }
100
+ title={`Disconnect ${app.name}?`}
101
+ body={
102
+ <>
103
+ {app.name}
104
+ {app.host !== null && (
105
+ <>
106
+ {' '}at <span className="mono">{app.host}</span>
107
+ </>
108
+ )}
109
+ , last used{' '}
110
+ {app.lastUsedAt === null ? 'never' : <Timestamp iso={app.lastUsedAt} display="relative" />},
111
+ stops at its next request. To use it again, connect it again.
112
+ </>
113
+ }
114
+ confirmLabel="Disconnect"
115
+ onConfirm={() => disconnect(app)}
116
+ />
117
+ )}
118
+ </td>
119
+ </tr>
120
+ <RowFailure
121
+ status={state}
122
+ columns={5}
123
+ onDismiss={() => state.state === 'failed' && dismiss(state.mutationId)}
124
+ />
125
+ </Fragment>
126
+ );
127
+ })}
128
+ </tbody>
129
+ </table>
130
+ </div>
131
+ )}
132
+ </Card>
133
+ );
134
+ }
135
+
136
+ function scopeLabels(app: ConnectedApp): string {
137
+ return app.scopes.map((scope) => MCP_SCOPE_INFO[scope].label).join(', ');
138
+ }
@@ -430,7 +430,7 @@ const plural = (count: number, one: string) => `${count} ${one}${count === 1 ? '
430
430
  * they leave behind to rotate.
431
431
  */
432
432
  function RemovalPreview({ principal, open }: { principal: DirectoryPrincipal; open: boolean }) {
433
- const { capabilities } = useShell();
433
+ const { capabilities, features } = useShell();
434
434
  const person = principal.principalType === 'user';
435
435
  const { data, isPending } = useQuery({
436
436
  ...queries.report(useCoffre(), memberOf(principal), capabilities.canManageGrants),
@@ -450,8 +450,15 @@ function RemovalPreview({ principal, open }: { principal: DirectoryPrincipal; op
450
450
  : 'Its bearer tokens and trust bindings stop working, and its project access is revoked at once.';
451
451
  }
452
452
  const { live } = report;
453
+ // Named, as an app's name is what its person knows it by: "2 connected apps (Claude, Cursor)".
454
+ const apps = `${plural(live.apps, 'connected app')}${report.apps.length > 0 ? ` (${report.apps.map((app) => app.name).join(', ')})` : ''}`;
453
455
  const revokes = person
454
- ? [plural(live.grants, 'grant'), plural(live.sessions, 'session'), plural(live.identities, 'linked sign-in account')]
456
+ ? [
457
+ plural(live.grants, 'grant'),
458
+ plural(live.sessions, 'session'),
459
+ plural(live.identities, 'linked sign-in account'),
460
+ ...(features.mcp ? [apps] : []),
461
+ ]
455
462
  : [plural(live.grants, 'grant'), plural(live.tokens, 'bearer token')];
456
463
  return (
457
464
  <>
@@ -41,7 +41,7 @@ export function RemovedNotice({ report }: { report: PrincipalReport }) {
41
41
  )}
42
42
  .{' '}
43
43
  {person
44
- ? 'Their project access, sessions, CLI logins and linked sign-in accounts were revoked at the same time, so adding them again starts from nothing.'
44
+ ? 'Their project access, sessions, CLI logins, linked sign-in accounts and connected apps were revoked at the same time, so adding them again starts from nothing.'
45
45
  : 'Its project access and every token issued to it were revoked at the same time, so adding it again starts from nothing.'}
46
46
  </Notice>
47
47
  </div>
@@ -5,7 +5,7 @@ import { ROLES } from '@coffre/core/access';
5
5
  import { useShell } from '../lib/use-shell';
6
6
  import { toast } from 'sonner';
7
7
  import { memberRef, useCoffre } from '../lib/coffre';
8
- import { directoryList } from '../lib/changes';
8
+ import { directoryList, disconnectMemberApp } from '../lib/changes';
9
9
  import { affects, managedProjects, queries, signInWays } from '../lib/queries';
10
10
  import { useChangeStatus } from '../lib/use-change';
11
11
  import { useMounted } from '../lib/mounted';
@@ -24,7 +24,7 @@ import {
24
24
  type AccessChange,
25
25
  type AccessPlan,
26
26
  } from '../lib/access-plan';
27
- import type { DirectoryPrincipal, GrantRow, ProjectSummary } from '../shared/models';
27
+ import type { DirectoryPrincipal, GrantRow, PrincipalReport, ProjectSummary } from '../shared/models';
28
28
  import { ClosedDoor, PageHeader } from './page';
29
29
  import { EmptyState, ErrorLine, Modal, Notice, Spinner } from './ui';
30
30
  import { GrantRowView, GrantsTable } from './grants';
@@ -32,6 +32,7 @@ import { EveryProjectGrants } from './every-project';
32
32
  import { ExpiryField } from './expiry-field';
33
33
  import { InstanceRole, KIND, PrincipalActions } from './directory';
34
34
  import { PrincipalReportCards, RemovedNotice } from './offboarding';
35
+ import { ConnectedAppsCard } from './connected-apps';
35
36
  import { PrincipalAvatar } from './principal';
36
37
  import { Tile } from './tile';
37
38
  import { Activity, Archive, Clock, Folder, Key, Link as LinkIcon, Pencil, Users, X } from './icons';
@@ -212,7 +213,7 @@ export function PrincipalLayout({ principalType, principalId }: { principalType:
212
213
  * its offboarding did instead.
213
214
  */
214
215
  export function PrincipalAccess({ principalType, principalId }: { principalType: PrincipalType; principalId: string }) {
215
- const { instanceRole } = useShell();
216
+ const { instanceRole, features } = useShell();
216
217
  const report = useReport(principalType, principalId);
217
218
  const access = useProjectAccess(principalType, principalId);
218
219
  const kind = KIND[principalType];
@@ -302,6 +303,9 @@ export function PrincipalAccess({ principalType, principalId }: { principalType:
302
303
  )}
303
304
 
304
305
  <EveryProjectGrants principalType={principalType} principalId={principalId} />
306
+
307
+ {/* Only an owner reads the report that lists them; removal disconnects them. */}
308
+ {features.mcp && people && found !== null && <MemberApps principalId={principalId} apps={found.apps} />}
305
309
  </>
306
310
  )}
307
311
 
@@ -310,6 +314,18 @@ export function PrincipalAccess({ principalType, principalId }: { principalType:
310
314
  );
311
315
  }
312
316
 
317
+ /** A person's connected apps, for an owner, who may disconnect any of them. */
318
+ function MemberApps({ principalId, apps }: { principalId: string; apps: PrincipalReport['apps'] }) {
319
+ return (
320
+ <ConnectedAppsCard
321
+ apps={apps}
322
+ change={disconnectMemberApp(useCoffre(), memberRef('user', principalId))}
323
+ description="AI assistants and other MCP clients they connected. Each acts as them, never beyond their access. Disconnecting one stops it at its next request; removing them disconnects every one."
324
+ empty="They have connected none. An app connects only after they approve it on coffre's page."
325
+ />
326
+ );
327
+ }
328
+
313
329
  /**
314
330
  * One principal's access to every project you manage, edited in one place.
315
331
  *
@@ -222,7 +222,7 @@ function IssueToken({ serviceId }: { serviceId: string }) {
222
222
  secrets; a CI run signs the CLI in with it, piped to{' '}
223
223
  <span className="mono">coffre login &lt;url&gt; --token</span>.
224
224
  </Notice>
225
- <div className="token-once">
225
+ <div className="copy-line">
226
226
  <code className="mono">{issued.token}</code>
227
227
  <CopyButton value={issued.token} label="Copy token" />
228
228
  </div>
package/src/index.ts CHANGED
@@ -8,8 +8,11 @@ export { CoffreProvider } from './layout.tsx';
8
8
  export { useCoffre } from './lib/coffre.ts';
9
9
  export { createRouter } from './router.tsx';
10
10
  export {
11
- access,
12
11
  account,
12
+ accountAppearance,
13
+ accountApps,
14
+ accountProfile,
15
+ accountSessions,
13
16
  approval,
14
17
  audit,
15
18
  deviceLogin,
@@ -1,4 +1,4 @@
1
- import type { CoffreClient, ConnectedApp, IdentityRow, SecretKey, SessionRow } from '@coffre/client';
1
+ import type { CoffreClient, ConnectedApp, IdentityRow, OffboardingReport, SecretKey, SessionRow } from '@coffre/client';
2
2
  import type { Role } from '@coffre/core/access';
3
3
  import type { QueryKey } from '@tanstack/react-query';
4
4
 
@@ -33,6 +33,7 @@ function listOf<TItem, TData extends { ok: boolean } | null>(
33
33
 
34
34
  const ARCHIVING: Words = { pending: 'Archiving…', done: 'archived', failed: 'Not archived.' };
35
35
  const REVOKING: Words = { pending: 'Revoking…', done: 'revoked', failed: 'Not revoked.' };
36
+ const DISCONNECTING: Words = { pending: 'Disconnecting…', done: 'disconnected', failed: 'Not disconnected.' };
36
37
 
37
38
  const saving = (id: string): Target => ({ id, kind: 'saving' });
38
39
  const removing = (id: string): Target => ({ id, kind: 'removing' });
@@ -237,12 +238,32 @@ export function disconnectApp(client: CoffreClient): Change<Apps, ConnectedApp,
237
238
  list: listOf<ConnectedApp, Apps>(keys.apps, 'apps', (app) => app.id),
238
239
  label: (app) => app.name,
239
240
  targets: (app) => [removing(app.id)],
240
- removing: { pending: 'Disconnecting…', done: 'disconnected', failed: 'Not disconnected.' },
241
+ removing: DISCONNECTING,
241
242
  affects: () => affects.apps(),
242
243
  run: (app) => client.apps.disconnect(app.id),
243
244
  };
244
245
  }
245
246
 
247
+ type Report = { ok: true; report: OffboardingReport | null } | Failure | null;
248
+
249
+ /** An owner disconnecting someone's app, on their page: their report lists it, as the owner reads it. */
250
+ export function disconnectMemberApp(client: CoffreClient, member: string): Change<Report, ConnectedApp, ConnectedApp, unknown> {
251
+ return {
252
+ list: {
253
+ queryKey: [...keys.report(member), { owner: true }],
254
+ items: (data) => (data?.ok === true ? (data.report?.apps ?? []) : []),
255
+ withItems: (data, apps) => (data?.ok === true && data.report !== null ? { ...data, report: { ...data.report, apps } } : data),
256
+ id: (app) => app.id,
257
+ },
258
+ label: (app) => app.name,
259
+ targets: (app) => [removing(app.id)],
260
+ removing: DISCONNECTING,
261
+ // Their report counts what removing them would end; an owner's own apps may be among them.
262
+ affects: () => [keys.report(member), ...affects.apps()],
263
+ run: (app) => client.apps.disconnect(app.id),
264
+ };
265
+ }
266
+
246
267
  type Identities = ({ ok: true; identities: IdentityRow[] } | Failure);
247
268
 
248
269
  export function unlinkIdentity(client: CoffreClient): Change<Identities, IdentityRow, IdentityRow & { label: string }, unknown> {
@@ -329,8 +329,8 @@ export function shellOf(
329
329
  registrationRequired: me !== null && !me.registered,
330
330
  /** A member the vault refuses: their record failed its integrity check. */
331
331
  accessTampered: me?.tampered === true,
332
- /** What the deployment's configuration turns on: MCP clients, and CI runs signing in by their ID tokens. */
333
- features: member?.features ?? { mcp: false, workloads: false },
332
+ /** What the deployment's configuration turns on: MCP clients, as their endpoint's URL, and CI runs signing in by their ID tokens. */
333
+ features: member?.features ?? { mcp: null, workloads: false },
334
334
  };
335
335
  }
336
336
 
package/src/options.ts CHANGED
@@ -186,13 +186,6 @@ export const audit = {
186
186
  },
187
187
  };
188
188
 
189
- /** `/access`: the access page became the users page, and old links land there. */
190
- export const access = {
191
- beforeLoad: () => {
192
- throw redirect({ to: '/users' });
193
- },
194
- };
195
-
196
189
  /** `/users`. */
197
190
  export const users = {
198
191
  loader: ({ context }: Loader) => {
@@ -289,10 +282,20 @@ export const settings = {
289
282
  },
290
283
  };
291
284
 
285
+ /**
286
+ * `/account`, the layout of your own account's tabs: its header, Sign out,
287
+ * and the tabs you may open. Each tab is a page under it that reads its own.
288
+ */
289
+ export const account = {};
290
+
292
291
  type AccountSearch = { linked?: string; error?: string };
293
292
 
294
- /** `/account`. */
295
- export const account = {
293
+ /**
294
+ * `/account/`, who coffre takes you for and, when coffre runs its own
295
+ * sign-in, the accounts you sign in with. Linking one comes back here, with
296
+ * its outcome in `?linked=` or `?error=`.
297
+ */
298
+ export const accountProfile = {
296
299
  validateSearch: (search: Record<string, unknown>): AccountSearch => {
297
300
  const out: AccountSearch = {};
298
301
  for (const name of ['linked', 'error'] as const) {
@@ -301,16 +304,41 @@ export const account = {
301
304
  }
302
305
  return out;
303
306
  },
304
- // The sign-in half: which accounts you sign in with and where you are
305
- // signed in. Absent behind Cloudflare Access, which owns sessions there.
307
+ loader: async ({ context }: Loader) => {
308
+ const { coffre, queryClient } = coffreOf(context);
309
+ if (await ownSignIn(context)) await queryClient.fetchQuery(queries.identities(coffre));
310
+ },
311
+ };
312
+
313
+ /** `/account/sessions`, where you are signed in: absent behind Cloudflare Access, which owns sessions there. */
314
+ export const accountSessions = {
315
+ loader: async ({ context }: Loader) => {
316
+ const { coffre, queryClient } = coffreOf(context);
317
+ if (!(await ownSignIn(context))) throw redirect({ to: '/account' });
318
+ await queryClient.fetchQuery(queries.sessions(coffre));
319
+ },
320
+ };
321
+
322
+ /** `/account/apps`, how to connect an MCP client and the ones you connected, where the deployment serves MCP. */
323
+ export const accountApps = {
306
324
  loader: async ({ context }: Loader) => {
307
325
  const { coffre, queryClient } = coffreOf(context);
308
326
  const shell = await loadShell(queryClient, coffre);
309
- if (shell.auth.signin === null || shell.principal?.type !== 'user') return;
310
- await Promise.all([queryClient.fetchQuery(queries.identities(coffre)), queryClient.fetchQuery(queries.sessions(coffre))]);
327
+ if (!shell.features.mcp || shell.principal?.type !== 'user') throw redirect({ to: '/account' });
328
+ await queryClient.fetchQuery(queries.apps(coffre));
311
329
  },
312
330
  };
313
331
 
332
+ /** `/account/appearance`, how coffre looks here, kept in this browser. */
333
+ export const accountAppearance = {};
334
+
335
+ /** Whether you are a person signed in by coffre's own sign-in, whose accounts and sessions are coffre's to show. */
336
+ async function ownSignIn(context: unknown): Promise<boolean> {
337
+ const { coffre, queryClient } = coffreOf(context);
338
+ const shell = await loadShell(queryClient, coffre);
339
+ return shell.auth.signin !== null && shell.principal?.type === 'user';
340
+ }
341
+
314
342
  // --- in the solo frame ----------------------------------------------------------------
315
343
 
316
344
  /** `/login`. */