@coffre/ui 0.0.0 → 0.1.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 (168) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +7 -3
  3. package/dist/client/.assetsignore +2 -0
  4. package/dist/client/_coffre/assets/account-C3Zo1l5A.js +1 -0
  5. package/dist/client/_coffre/assets/account-C4bNbeO7.js +2 -0
  6. package/dist/client/_coffre/assets/affordances-DiuJIiR2.js +1 -0
  7. package/dist/client/_coffre/assets/audit-1xLyuxGz.js +2 -0
  8. package/dist/client/_coffre/assets/audit-Dab2GuRj.js +1 -0
  9. package/dist/client/_coffre/assets/auth.device-BfCfeBWe.js +2 -0
  10. package/dist/client/_coffre/assets/auth.device-D2pCLF-X.js +1 -0
  11. package/dist/client/_coffre/assets/coffre-C7qL3HGR.js +1 -0
  12. package/dist/client/_coffre/assets/directory-C2Ou4SQv.js +1 -0
  13. package/dist/client/_coffre/assets/globals-Dgq4Jy0x.css +1 -0
  14. package/dist/client/_coffre/assets/grants-fqTtJ-aW.js +1 -0
  15. package/dist/client/_coffre/assets/index-BpGwbjmM.js +12 -0
  16. package/dist/client/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
  17. package/dist/client/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
  18. package/dist/client/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
  19. package/dist/client/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
  20. package/dist/client/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
  21. package/dist/client/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
  22. package/dist/client/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
  23. package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
  24. package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  25. package/dist/client/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  26. package/dist/client/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  27. package/dist/client/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  28. package/dist/client/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  29. package/dist/client/_coffre/assets/login-CR9CBXlw.js +2 -0
  30. package/dist/client/_coffre/assets/login-DZizFxa4.js +1 -0
  31. package/dist/client/_coffre/assets/offboarding-DOLJQcXU.js +1 -0
  32. package/dist/client/_coffre/assets/page-BxW2MwaX.js +1 -0
  33. package/dist/client/_coffre/assets/preload-helper-BHuP8_FL.js +46 -0
  34. package/dist/client/_coffre/assets/principal-page-xnBZVURr.js +1 -0
  35. package/dist/client/_coffre/assets/project-environments-CfIH5kFM.js +1 -0
  36. package/dist/client/_coffre/assets/projects._project._environment-CrWjQmIA.js +2 -0
  37. package/dist/client/_coffre/assets/projects._project._environment-CwRVG9Ne.js +3 -0
  38. package/dist/client/_coffre/assets/projects._project.index-CCDEuE-z.js +2 -0
  39. package/dist/client/_coffre/assets/projects._project.index-DCJsmnD7.js +1 -0
  40. package/dist/client/_coffre/assets/projects.index-B8eV8JIn.js +1 -0
  41. package/dist/client/_coffre/assets/projects.index-BNEC7Oz8.js +2 -0
  42. package/dist/client/_coffre/assets/settings-2BPsenNM.js +2 -0
  43. package/dist/client/_coffre/assets/settings-BrS0-wEt.js +1 -0
  44. package/dist/client/_coffre/assets/signin-errors-CroZWZgm.js +1 -0
  45. package/dist/client/_coffre/assets/tokens._token-B3-YwuKp.js +2 -0
  46. package/dist/client/_coffre/assets/tokens._token-D_hsbHx6.js +1 -0
  47. package/dist/client/_coffre/assets/tokens.index-BdKE2Jv8.js +2 -0
  48. package/dist/client/_coffre/assets/tokens.index-XvA4XRxh.js +1 -0
  49. package/dist/client/_coffre/assets/unregistered-CTRMtBIy.js +1 -0
  50. package/dist/client/_coffre/assets/use-action-DgAf-tiX.js +1 -0
  51. package/dist/client/_coffre/assets/users._user-BFPXcJ4y.js +2 -0
  52. package/dist/client/_coffre/assets/users._user-DEtMeSoh.js +1 -0
  53. package/dist/client/_coffre/assets/users.index-B03beUHq.js +1 -0
  54. package/dist/client/_coffre/assets/users.index-D8hwzM6P.js +2 -0
  55. package/dist/client/_coffre/assets/validation-9Cl_XS-l.js +1 -0
  56. package/dist/index.d.ts +19 -0
  57. package/dist/server/.vite/manifest.json +572 -0
  58. package/dist/server/_coffre/assets/_tanstack-start-manifest_v-B6CZDfrB.js +133 -0
  59. package/dist/server/_coffre/assets/account-B71_b5xc.js +296 -0
  60. package/dist/server/_coffre/assets/account-BoO6ZqMc.js +176 -0
  61. package/dist/server/_coffre/assets/affordances-BNaXjMOb.js +46 -0
  62. package/dist/server/_coffre/assets/async-local-storage-C0cwgkEr.js +3107 -0
  63. package/dist/server/_coffre/assets/audit-CwRFnSAY.js +74 -0
  64. package/dist/server/_coffre/assets/audit-t1sYjtrf.js +964 -0
  65. package/dist/server/_coffre/assets/auth.device-1IcJ475s.js +208 -0
  66. package/dist/server/_coffre/assets/auth.device-CJwZYYtn.js +29 -0
  67. package/dist/server/_coffre/assets/coffre-1hxT2E_U.js +278 -0
  68. package/dist/server/_coffre/assets/directory-wm_JQUfk.js +396 -0
  69. package/dist/server/_coffre/assets/empty-plugin-adapters-Cq4--YW-.js +5 -0
  70. package/dist/server/_coffre/assets/globals-Dgq4Jy0x.css +1 -0
  71. package/dist/server/_coffre/assets/grants-BmhEY1vz.js +243 -0
  72. package/dist/server/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
  73. package/dist/server/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
  74. package/dist/server/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
  75. package/dist/server/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
  76. package/dist/server/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
  77. package/dist/server/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
  78. package/dist/server/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
  79. package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
  80. package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  81. package/dist/server/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  82. package/dist/server/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  83. package/dist/server/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  84. package/dist/server/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  85. package/dist/server/_coffre/assets/login-B5O5LPXV.js +100 -0
  86. package/dist/server/_coffre/assets/login-Bvc4gp0X.js +22 -0
  87. package/dist/server/_coffre/assets/offboarding-CvSilnSm.js +330 -0
  88. package/dist/server/_coffre/assets/page-BjXk0Ehu.js +2003 -0
  89. package/dist/server/_coffre/assets/principal-page-DkwNGzM2.js +617 -0
  90. package/dist/server/_coffre/assets/project-environments-lEzFHUt4.js +9 -0
  91. package/dist/server/_coffre/assets/projects._project._environment-7grhqlgq.js +2227 -0
  92. package/dist/server/_coffre/assets/projects._project._environment-ByEf6pmz.js +55 -0
  93. package/dist/server/_coffre/assets/projects._project.index-B1bjowP-.js +932 -0
  94. package/dist/server/_coffre/assets/projects._project.index-DU8wtoHD.js +22 -0
  95. package/dist/server/_coffre/assets/projects.index-B0DoHbCz.js +280 -0
  96. package/dist/server/_coffre/assets/projects.index-kMDA6pMy.js +54 -0
  97. package/dist/server/_coffre/assets/react-dom-qCTiwGGR.js +1352 -0
  98. package/dist/server/_coffre/assets/router-ChU_CwCX.js +2028 -0
  99. package/dist/server/_coffre/assets/settings-CM9-h7in.js +18 -0
  100. package/dist/server/_coffre/assets/settings-Cg5qOGij.js +60 -0
  101. package/dist/server/_coffre/assets/signin-errors-BEFlVDbQ.js +28 -0
  102. package/dist/server/_coffre/assets/start-DR3rN0St.js +4 -0
  103. package/dist/server/_coffre/assets/tokens._token-CCpaPMAk.js +268 -0
  104. package/dist/server/_coffre/assets/tokens._token-Di4OZdAA.js +18 -0
  105. package/dist/server/_coffre/assets/tokens.index-Do3OHR31.js +34 -0
  106. package/dist/server/_coffre/assets/tokens.index-tDKq4AFh.js +10 -0
  107. package/dist/server/_coffre/assets/ui-BNzhIAQP.js +15710 -0
  108. package/dist/server/_coffre/assets/unregistered-BqaWYFJK.js +51 -0
  109. package/dist/server/_coffre/assets/use-action-BkJXC5JM.js +953 -0
  110. package/dist/server/_coffre/assets/useStore-DWGPqzXR.js +892 -0
  111. package/dist/server/_coffre/assets/users._user-BenYva93.js +15 -0
  112. package/dist/server/_coffre/assets/users._user-Cp039Va-.js +10 -0
  113. package/dist/server/_coffre/assets/users.index-BrzG1Ecq.js +10 -0
  114. package/dist/server/_coffre/assets/users.index-DQ_45DQl.js +34 -0
  115. package/dist/server/_coffre/assets/validation-BQtqPe2V.js +27 -0
  116. package/dist/server/index.js +13910 -0
  117. package/package.json +58 -5
  118. package/src/components/affordances.ts +80 -0
  119. package/src/components/agentation.tsx +34 -0
  120. package/src/components/command-palette.tsx +271 -0
  121. package/src/components/directory.tsx +448 -0
  122. package/src/components/grants.tsx +204 -0
  123. package/src/components/icons.tsx +283 -0
  124. package/src/components/offboarding.tsx +286 -0
  125. package/src/components/page.tsx +128 -0
  126. package/src/components/principal-page.tsx +549 -0
  127. package/src/components/principal-picker.tsx +168 -0
  128. package/src/components/principal.tsx +53 -0
  129. package/src/components/route-states.tsx +60 -0
  130. package/src/components/service-tokens.tsx +212 -0
  131. package/src/components/shell.tsx +641 -0
  132. package/src/components/syncs.tsx +581 -0
  133. package/src/components/theme.tsx +141 -0
  134. package/src/components/tile.tsx +22 -0
  135. package/src/components/ui.tsx +440 -0
  136. package/src/entry.ts +19 -0
  137. package/src/lib/access-plan.ts +201 -0
  138. package/src/lib/audit-sentences.ts +468 -0
  139. package/src/lib/capabilities.ts +45 -0
  140. package/src/lib/coffre.ts +57 -0
  141. package/src/lib/project-access.ts +95 -0
  142. package/src/lib/project-environments.ts +23 -0
  143. package/src/lib/reveal.ts +21 -0
  144. package/src/lib/secret-edit-batch.ts +181 -0
  145. package/src/lib/signin-errors.ts +33 -0
  146. package/src/lib/use-action.ts +50 -0
  147. package/src/lib/validation.ts +27 -0
  148. package/src/routeTree.gen.ts +367 -0
  149. package/src/router.tsx +84 -0
  150. package/src/routes/__root.tsx +192 -0
  151. package/src/routes/access.tsx +11 -0
  152. package/src/routes/account.tsx +359 -0
  153. package/src/routes/audit.tsx +545 -0
  154. package/src/routes/auth.device.tsx +200 -0
  155. package/src/routes/index.tsx +15 -0
  156. package/src/routes/login.tsx +129 -0
  157. package/src/routes/projects.$project.$environment.tsx +1659 -0
  158. package/src/routes/projects.$project.index.tsx +917 -0
  159. package/src/routes/projects.index.tsx +353 -0
  160. package/src/routes/settings.tsx +72 -0
  161. package/src/routes/tokens.$token.tsx +35 -0
  162. package/src/routes/tokens.index.tsx +37 -0
  163. package/src/routes/unregistered.tsx +59 -0
  164. package/src/routes/users.$user.tsx +13 -0
  165. package/src/routes/users.index.tsx +37 -0
  166. package/src/shared/models.ts +55 -0
  167. package/src/styles/globals.css +4118 -0
  168. package/src/types.ts +21 -0
@@ -0,0 +1,359 @@
1
+ import type { IdentityRow, SessionRow } from '@coffre/client';
2
+ import { createFileRoute, useLoaderData } from '@tanstack/react-router';
3
+ import { toast } from 'sonner';
4
+ import { Card, Fact, PageHeader } from '../components/page';
5
+ import { ThemeCards } from '../components/theme';
6
+ import { InstanceRole } from '../components/directory';
7
+ import { ConfirmButton, EmptyState, ErrorLine, Notice, Timestamp } from '../components/ui';
8
+ import { Monitor, ProviderMark, SignOut, Terminal, X } from '../components/icons';
9
+ import { signinErrorMessage } from '../lib/signin-errors';
10
+ import { uiResult, useCoffre } from '../lib/coffre';
11
+ import { useAction } from '../lib/use-action';
12
+
13
+ type Search = { linked?: string; error?: string };
14
+
15
+ /**
16
+ * Your own settings: how coffre looks here, who it takes you for and, when
17
+ * coffre runs its own sign-in, which accounts you sign in with and where you
18
+ * are signed in. The sidebar's Settings is the workspace's; this page is
19
+ * reached from your account at the sidebar's foot.
20
+ */
21
+ export const Route = createFileRoute('/account')({
22
+ validateSearch: (search: Record<string, unknown>): Search => {
23
+ const out: Search = {};
24
+ for (const name of ['linked', 'error'] as const) {
25
+ const value = search[name];
26
+ if (typeof value === 'string' && /^[a-z0-9_-]{1,40}$/.test(value)) out[name] = value;
27
+ }
28
+ return out;
29
+ },
30
+ // The sign-in half: which accounts you sign in with, where you are signed
31
+ // in, and which providers you could link. Absent behind Cloudflare Access,
32
+ // which owns sessions there.
33
+ loader: async ({ context: { client }, parentMatchPromise }) => {
34
+ const auth = (await parentMatchPromise).loaderData?.auth;
35
+ if (auth === undefined || auth.signin === null) {
36
+ return {
37
+ ok: true as const,
38
+ signin: false,
39
+ providers: [] as { id: string; label: string; brand: string }[],
40
+ identities: [] as IdentityRow[],
41
+ sessions: [] as SessionRow[],
42
+ };
43
+ }
44
+ const { providers } = auth.signin;
45
+ return uiResult(async () => {
46
+ const [{ identities }, { sessions }] = await Promise.all([client.identities.list(), client.sessions.list()]);
47
+ return { signin: true, providers, identities, sessions };
48
+ });
49
+ },
50
+ component: AccountPage,
51
+ });
52
+
53
+ function AccountPage() {
54
+ const { principal, instanceRole } = useLoaderData({ from: '__root__' });
55
+ const signin = Route.useLoaderData();
56
+
57
+ return (
58
+ <>
59
+ <PageHeader title="Account" actions={principal !== null && <SignOutButton />} />
60
+
61
+ <Card labelledBy="appearance" title="Appearance">
62
+ <div className="card-body">
63
+ <ThemeCards />
64
+ </div>
65
+ </Card>
66
+
67
+ {principal !== null && (
68
+ <Card labelledBy="identity" title="Identity">
69
+ <dl className="facts">
70
+ <Fact label={principal.type === 'user' ? 'Email' : 'Name'}>
71
+ <span className="mono">{principal.id}</span>
72
+ </Fact>
73
+ <Fact label="Kind">{principal.type === 'user' ? 'User' : 'Token'}</Fact>
74
+ {principal.type === 'user' && (
75
+ <Fact label="Instance role">
76
+ <InstanceRole
77
+ principal={{
78
+ principalType: 'user',
79
+ principalId: principal.id,
80
+ instanceRole: instanceRole ?? 'user',
81
+ isRootAdmin: instanceRole === 'root-admin',
82
+ }}
83
+ />
84
+ </Fact>
85
+ )}
86
+ </dl>
87
+ </Card>
88
+ )}
89
+
90
+ {!signin.ok ? (
91
+ <ErrorLine error={signin.error} />
92
+ ) : (
93
+ signin.signin &&
94
+ principal?.type === 'user' && (
95
+ <>
96
+ <SigninAccounts email={principal.id} {...signin} />
97
+ <Sessions sessions={signin.sessions} providers={signin.providers} />
98
+ </>
99
+ )
100
+ )}
101
+ </>
102
+ );
103
+ }
104
+
105
+ /**
106
+ * Sign-out is a form post: a GET could be triggered by any image tag on any
107
+ * page, and the server's origin check covers form posts.
108
+ */
109
+ function SignOutButton() {
110
+ return (
111
+ <form method="post" action="/auth/signout">
112
+ <button className="btn" type="submit">
113
+ <SignOut size={14} />
114
+ Sign out
115
+ </button>
116
+ </form>
117
+ );
118
+ }
119
+
120
+ type Provider = { id: string; label: string; brand: string };
121
+
122
+ function providerLabel(providers: Provider[], id: string | null) {
123
+ return providers.find((provider) => provider.id === id)?.label ?? id ?? 'unknown';
124
+ }
125
+
126
+ function SigninAccounts({
127
+ email,
128
+ providers,
129
+ identities,
130
+ }: {
131
+ email: string;
132
+ providers: Provider[];
133
+ identities: IdentityRow[];
134
+ }) {
135
+ const { linked, error } = Route.useSearch();
136
+ const message = signinErrorMessage(error);
137
+ const coffre = useCoffre();
138
+ const { pending, error: actionError, run } = useAction();
139
+
140
+ return (
141
+ <Card
142
+ labelledBy="signin-accounts"
143
+ title="Sign-in accounts"
144
+ description="coffre recognises you by these accounts, never by an email address alone. A new account is linked here, while you are signed in."
145
+ >
146
+ {(linked !== undefined || message !== null || actionError !== null) && (
147
+ <div className="card-body">
148
+ {linked !== undefined && (
149
+ <Notice tone="good">{providerLabel(providers, linked)} account linked.</Notice>
150
+ )}
151
+ <ErrorLine error={message ?? actionError} />
152
+ </div>
153
+ )}
154
+
155
+ {identities.length === 0 ? (
156
+ <EmptyState title="No account linked">
157
+ Your next sign-in with a verified <span className="mono">{email}</span> links that
158
+ account.
159
+ </EmptyState>
160
+ ) : (
161
+ <div className="dt-wrap">
162
+ <table className="dt">
163
+ <thead>
164
+ <tr>
165
+ <th>Account</th>
166
+ <th className="col-shrink">Linked (UTC)</th>
167
+ <th className="col-shrink">Last sign-in</th>
168
+ <th className="col-actions">
169
+ <span className="visually-hidden">Actions</span>
170
+ </th>
171
+ </tr>
172
+ </thead>
173
+ <tbody>
174
+ {identities.map((identity) => {
175
+ const label = providerLabel(providers, identity.provider);
176
+ const brand = providers.find((p) => p.id === identity.provider)?.brand ?? 'oidc';
177
+ return (
178
+ <tr key={identity.id}>
179
+ <td>
180
+ <span className="cell-account">
181
+ <ProviderMark brand={brand} />
182
+ <span className="cell-stack">
183
+ <span>{label}</span>
184
+ {identity.email !== null && <small className="mono">{identity.email}</small>}
185
+ </span>
186
+ </span>
187
+ </td>
188
+ <td className="nowrap">
189
+ <Timestamp iso={identity.createdAt} />
190
+ </td>
191
+ <td className="nowrap cell-muted">
192
+ {identity.lastSignInAt === null ? (
193
+ 'Never'
194
+ ) : (
195
+ <Timestamp iso={identity.lastSignInAt} display="relative" />
196
+ )}
197
+ </td>
198
+ <td className="col-actions">
199
+ <ConfirmButton
200
+ trigger={
201
+ <button className="act" disabled={pending}>
202
+ <X size={13} />
203
+ Unlink
204
+ </button>
205
+ }
206
+ title={`Unlink this ${label} account?`}
207
+ body={
208
+ identities.length === 1 ? (
209
+ <>
210
+ It stops signing you in, and every session it opened ends now,
211
+ this one included if you signed in with it. Your next sign-in
212
+ with any account whose verified email is{' '}
213
+ <span className="mono">{email}</span> links that account instead.
214
+ </>
215
+ ) : (
216
+ <>
217
+ It stops signing you in, and every session it opened ends now,
218
+ this one included if you signed in with it.
219
+ </>
220
+ )
221
+ }
222
+ confirmLabel="Unlink"
223
+ onConfirm={() =>
224
+ run(
225
+ () => coffre.identities.unlink(identity.id),
226
+ () => toast.success(`${label} account unlinked`),
227
+ )
228
+ }
229
+ />
230
+ </td>
231
+ </tr>
232
+ );
233
+ })}
234
+ </tbody>
235
+ </table>
236
+ </div>
237
+ )}
238
+
239
+ {providers.length > 0 && (
240
+ <div className="card-foot">
241
+ <span className="hint">Link another account</span>
242
+ <div className="link-providers">
243
+ {providers.map((provider) => (
244
+ <a
245
+ key={provider.id}
246
+ className="btn btn-sm"
247
+ href={`/auth/signin/${encodeURIComponent(provider.id)}?link=1`}
248
+ >
249
+ <ProviderMark brand={provider.brand} size={14} />
250
+ {provider.label}
251
+ </a>
252
+ ))}
253
+ </div>
254
+ </div>
255
+ )}
256
+ </Card>
257
+ );
258
+ }
259
+
260
+ function Sessions({
261
+ sessions,
262
+ providers,
263
+ }: {
264
+ sessions: SessionRow[];
265
+ providers: Provider[];
266
+ }) {
267
+ const coffre = useCoffre();
268
+ const { pending, error, run } = useAction();
269
+
270
+ return (
271
+ <Card
272
+ labelledBy="sessions"
273
+ title="Sessions"
274
+ description="Browsers and command lines signed in as you. Ending one signs it out at its next request."
275
+ >
276
+ {error !== null && (
277
+ <div className="card-body">
278
+ <ErrorLine error={error} />
279
+ </div>
280
+ )}
281
+ {sessions.length === 0 ? (
282
+ <EmptyState title="No sessions">Nothing is signed in as you right now.</EmptyState>
283
+ ) : (
284
+ <div className="dt-wrap">
285
+ <table className="dt">
286
+ <thead>
287
+ <tr>
288
+ <th>Where</th>
289
+ <th className="col-shrink">Last active</th>
290
+ <th className="col-shrink">Expires</th>
291
+ <th className="col-actions">
292
+ <span className="visually-hidden">Actions</span>
293
+ </th>
294
+ </tr>
295
+ </thead>
296
+ <tbody>
297
+ {sessions.map((session) => (
298
+ <tr key={session.id}>
299
+ <td>
300
+ <span className="cell-account">
301
+ {session.kind === 'cli' ? <Terminal size={15} /> : <Monitor size={15} />}
302
+ <span className="cell-stack">
303
+ <span>
304
+ {session.label ?? (session.kind === 'cli' ? 'Command line' : 'Browser')}{' '}
305
+ {session.current && <span className="tag tag-blue">this browser</span>}
306
+ </span>
307
+ <small>
308
+ {session.kind === 'cli'
309
+ ? 'coffre login'
310
+ : `via ${providerLabel(providers, session.provider)}`}
311
+ {session.lastUsedIp !== null && (
312
+ <>
313
+ {' · '}
314
+ <span className="mono">{session.lastUsedIp}</span>
315
+ </>
316
+ )}
317
+ </small>
318
+ </span>
319
+ </span>
320
+ </td>
321
+ <td className="nowrap cell-muted">
322
+ <Timestamp iso={session.lastUsedAt ?? session.createdAt} display="relative" />
323
+ </td>
324
+ <td className="nowrap cell-muted">
325
+ <Timestamp iso={session.expiresAt} display="relative" />
326
+ </td>
327
+ <td className="col-actions">
328
+ {session.current ? (
329
+ <form method="post" action="/auth/signout">
330
+ <button className="act" type="submit">
331
+ <SignOut size={13} />
332
+ Sign out
333
+ </button>
334
+ </form>
335
+ ) : (
336
+ <button
337
+ className="act"
338
+ disabled={pending}
339
+ onClick={() =>
340
+ run(
341
+ () => coffre.sessions.revoke(session.id),
342
+ () => toast.success('Session ended'),
343
+ )
344
+ }
345
+ >
346
+ <X size={13} />
347
+ End
348
+ </button>
349
+ )}
350
+ </td>
351
+ </tr>
352
+ ))}
353
+ </tbody>
354
+ </table>
355
+ </div>
356
+ )}
357
+ </Card>
358
+ );
359
+ }