@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,200 @@
1
+ import { useState } from 'react';
2
+ import { createFileRoute, Link, useNavigate } from '@tanstack/react-router';
3
+ import { failureMessage, statusOf, uiResult, useCoffre } from '../lib/coffre';
4
+ import { ClosedDoor } from '../components/page';
5
+ import { ErrorLine, Spinner, Timestamp } from '../components/ui';
6
+ import { CheckCircle, SlashCircle, Terminal } from '../components/icons';
7
+
8
+ /**
9
+ * Where `coffre login` sends you: approve a terminal's sign-in with the
10
+ * session this browser already has. The terminal shows a code; this page
11
+ * shows the same code and where the request came from, and nothing happens
12
+ * until you press Approve.
13
+ */
14
+ export const Route = createFileRoute('/auth/device')({
15
+ validateSearch: (search: Record<string, unknown>): { code?: string } => {
16
+ const code = search.code;
17
+ return typeof code === 'string' && code.length <= 16 ? { code } : {};
18
+ },
19
+ loaderDeps: ({ search }) => ({ code: search.code }),
20
+ loader: async ({ context: { client }, deps, parentMatchPromise }) => {
21
+ if (deps.code === undefined) return null;
22
+ if (!(await parentMatchPromise).loaderData?.auth.signin) {
23
+ return { ok: false as const, error: 'This instance has no CLI sign-in.' };
24
+ }
25
+ const code = deps.code;
26
+ return uiResult(() => client.deviceLogins.get(code));
27
+ },
28
+ component: DevicePage,
29
+ });
30
+
31
+ function DevicePage() {
32
+ const loaded = Route.useLoaderData();
33
+ const [decided, setDecided] = useState<'approved' | 'denied' | null>(null);
34
+
35
+ if (decided === 'approved') {
36
+ return (
37
+ <ClosedDoor icon={<CheckCircle size={18} />} label="coffre CLI" title="Your terminal is signed in">
38
+ <p>You can close this tab and go back to the terminal.</p>
39
+ </ClosedDoor>
40
+ );
41
+ }
42
+ if (decided === 'denied') {
43
+ return (
44
+ <ClosedDoor icon={<SlashCircle size={18} />} label="coffre CLI" title="Sign-in refused">
45
+ <p>
46
+ The terminal that asked gets nothing. If you did not run <span className="mono">coffre
47
+ login</span> yourself, someone may be trying to get you to approve theirs; the refusal is
48
+ in the audit log.
49
+ </p>
50
+ </ClosedDoor>
51
+ );
52
+ }
53
+
54
+ if (loaded === null) return <CodeEntry />;
55
+ if (!loaded.ok) return <CodeEntry error={loaded.error} />;
56
+ if (loaded.request === null) {
57
+ return <CodeEntry error="That code is unknown, already used, or expired. Run coffre login again for a new one." />;
58
+ }
59
+ return <Approve request={loaded.request} sessionDays={loaded.sessionDays} onDecided={setDecided} />;
60
+ }
61
+
62
+ function CodeEntry({ error = null }: { error?: string | null }) {
63
+ const navigate = useNavigate();
64
+ const [code, setCode] = useState('');
65
+ return (
66
+ <section className="card signin" aria-labelledby="device-title">
67
+ <div className="signin-head">
68
+ <h1 className="signin-title" id="device-title">
69
+ Sign in the coffre CLI
70
+ </h1>
71
+ <p className="signin-lede">
72
+ Enter the code your terminal shows after <span className="mono">coffre login</span>.
73
+ </p>
74
+ </div>
75
+ <form
76
+ className="signin-form"
77
+ onSubmit={(event) => {
78
+ event.preventDefault();
79
+ void navigate({ to: '/auth/device', search: { code: code.trim() } });
80
+ }}
81
+ >
82
+ <label className="field">
83
+ <span className="label">Code</span>
84
+ <input
85
+ className="input mono device-code-input"
86
+ name="code"
87
+ autoComplete="off"
88
+ autoCapitalize="characters"
89
+ spellCheck={false}
90
+ placeholder="XXXX-XXXX"
91
+ maxLength={16}
92
+ value={code}
93
+ onChange={(event) => setCode(event.target.value)}
94
+ />
95
+ </label>
96
+ <button className="btn btn-primary" type="submit" style={{ height: '2.125rem' }} disabled={code.trim() === ''}>
97
+ Continue
98
+ </button>
99
+ </form>
100
+ {error !== null && (
101
+ <div className="signin-error">
102
+ <ErrorLine error={error} />
103
+ </div>
104
+ )}
105
+ </section>
106
+ );
107
+ }
108
+
109
+ function Approve({
110
+ request,
111
+ sessionDays,
112
+ onDecided,
113
+ }: {
114
+ request: { userCode: string; clientLabel: string | null; clientIp: string | null; createdAt: string };
115
+ sessionDays: number;
116
+ onDecided: (decision: 'approved' | 'denied') => void;
117
+ }) {
118
+ const coffre = useCoffre();
119
+ const [pending, setPending] = useState<'approve' | 'deny' | null>(null);
120
+ const [error, setError] = useState<string | null>(null);
121
+
122
+ async function decide(approve: boolean) {
123
+ setPending(approve ? 'approve' : 'deny');
124
+ try {
125
+ await coffre.deviceLogins.decide(request.userCode, approve);
126
+ onDecided(approve ? 'approved' : 'denied');
127
+ } catch (error) {
128
+ setError(
129
+ statusOf(error) === 404
130
+ ? 'That code is unknown, already used, or expired. Run coffre login again.'
131
+ : statusOf(error) === undefined
132
+ ? 'The decision could not be sent. Nothing was approved.'
133
+ : failureMessage(error),
134
+ );
135
+ } finally {
136
+ setPending(null);
137
+ }
138
+ }
139
+
140
+ return (
141
+ <section className="card signin" aria-labelledby="device-title">
142
+ <div className="signin-head">
143
+ <h1 className="signin-title" id="device-title">
144
+ Approve this terminal?
145
+ </h1>
146
+ <p className="signin-lede">
147
+ Only if you just ran <span className="mono">coffre login</span> yourself and it shows
148
+ this code. It gets your access, in your name, for {sessionDays} days or until you end it
149
+ from your account page.
150
+ </p>
151
+ </div>
152
+
153
+ <p className="device-code" aria-label="Code">
154
+ {request.userCode}
155
+ </p>
156
+
157
+ <dl className="facts device-facts">
158
+ <div className="fact">
159
+ <dt>Client</dt>
160
+ <dd>
161
+ <span className="cell-account">
162
+ <Terminal size={14} />
163
+ {request.clientLabel ?? 'coffre CLI'}
164
+ </span>
165
+ </dd>
166
+ </div>
167
+ <div className="fact">
168
+ <dt>Requested from</dt>
169
+ <dd className="mono">{request.clientIp ?? 'an unknown address'}</dd>
170
+ </div>
171
+ <div className="fact">
172
+ <dt>Requested (UTC)</dt>
173
+ <dd>
174
+ <Timestamp iso={request.createdAt} />
175
+ </dd>
176
+ </div>
177
+ </dl>
178
+
179
+ {error !== null && (
180
+ <div className="signin-error">
181
+ <ErrorLine error={error} />
182
+ </div>
183
+ )}
184
+
185
+ <div className="device-actions">
186
+ <Link className="btn btn-quiet" to="/projects">
187
+ Cancel
188
+ </Link>
189
+ <button className="btn" disabled={pending !== null} onClick={() => void decide(false)}>
190
+ {pending === 'deny' && <Spinner />}
191
+ Deny
192
+ </button>
193
+ <button className="btn btn-primary" disabled={pending !== null} onClick={() => void decide(true)}>
194
+ {pending === 'approve' && <Spinner />}
195
+ Approve
196
+ </button>
197
+ </div>
198
+ </section>
199
+ );
200
+ }
@@ -0,0 +1,15 @@
1
+ import { createFileRoute, redirect } from '@tanstack/react-router';
2
+
3
+ /**
4
+ * The root is the project list, one level up.
5
+ *
6
+ * Projects live under `/projects/:slug` rather than at `/:slug` so that a
7
+ * project may be called `audit` or `login` without shadowing the page of that
8
+ * name. Nothing renders here; `/` only exists so the obvious URL still lands
9
+ * somewhere.
10
+ */
11
+ export const Route = createFileRoute('/')({
12
+ beforeLoad: () => {
13
+ throw redirect({ to: '/projects' });
14
+ },
15
+ });
@@ -0,0 +1,129 @@
1
+ import { useState } from 'react';
2
+ import { createFileRoute, useLoaderData } from '@tanstack/react-router';
3
+ import { signinErrorMessage } from '../lib/signin-errors';
4
+ import { ErrorLine, Spinner } from '../components/ui';
5
+ import { ClosedDoor } from '../components/page';
6
+ import { Lock, ProviderMark, ShieldCheck } from '../components/icons';
7
+
8
+ export const Route = createFileRoute('/login')({
9
+ // Where to resume after signing in. Same-origin paths only: an absolute URL
10
+ // accepted here would make the sign-in page an open redirect.
11
+ validateSearch: (search: Record<string, unknown>): { next?: string; error?: string } => {
12
+ const out: { next?: string; error?: string } = {};
13
+ const { next, error } = search;
14
+ if (typeof next === 'string' && next.startsWith('/') && !next.startsWith('//')) {
15
+ out.next = next;
16
+ }
17
+ if (typeof error === 'string' && /^[a-z_]{1,40}$/.test(error)) out.error = error;
18
+ return out;
19
+ },
20
+ component: LoginPage,
21
+ });
22
+
23
+ /**
24
+ * The front door, as `GET /api/auth` describes it.
25
+ *
26
+ * With coffre's own sign-in, one button per provider. Behind Cloudflare
27
+ * Access, Access authenticates people before any request arrives, so this
28
+ * page only explains why it is showing at all.
29
+ */
30
+ function LoginPage() {
31
+ const { signin, access } = useLoaderData({ from: '__root__' }).auth;
32
+ if (signin !== null) return <ProviderLoginPage {...signin} />;
33
+ return access?.assertion ? <CloudflareAuthenticationFailed /> : <CloudflareAccessRequired />;
34
+ }
35
+
36
+ function CloudflareAccessRequired() {
37
+ return (
38
+ <ClosedDoor icon={<Lock size={18} />} label="Cloudflare Access" title="Open coffre through Access">
39
+ <p>
40
+ This instance has no sign-in of its own. Cloudflare Access authenticates you before
41
+ a request ever reaches coffre, and this request arrived without an Access
42
+ assertion.
43
+ </p>
44
+ <p>
45
+ Use the Access-protected hostname. A request straight to the origin is refused by
46
+ design.
47
+ </p>
48
+ </ClosedDoor>
49
+ );
50
+ }
51
+
52
+ function CloudflareAuthenticationFailed() {
53
+ return (
54
+ <ClosedDoor
55
+ icon={<ShieldCheck size={18} />}
56
+ label="Cloudflare Access"
57
+ title="Your identity could not be confirmed"
58
+ >
59
+ <p>
60
+ Cloudflare Access forwarded an identity assertion, but coffre could not verify it.
61
+ The Access session may have expired, or the identity verifier may be unavailable.
62
+ </p>
63
+ <p>
64
+ Reopen coffre through its Access-protected hostname. If this keeps happening, tell
65
+ whoever operates coffre.
66
+ </p>
67
+ </ClosedDoor>
68
+ );
69
+ }
70
+
71
+ function ProviderLoginPage({
72
+ title,
73
+ note,
74
+ providers,
75
+ }: {
76
+ title: string;
77
+ note: string | null;
78
+ providers: { id: string; label: string; brand: string }[];
79
+ }) {
80
+ const { next, error } = Route.useSearch();
81
+ const message = signinErrorMessage(error);
82
+ const [leaving, setLeaving] = useState<string | null>(null);
83
+ const query = next === undefined ? '' : `?next=${encodeURIComponent(next)}`;
84
+
85
+ return (
86
+ <section className="card signin" aria-labelledby="signin-title">
87
+ <div className="signin-head">
88
+ <h1 className="signin-title" id="signin-title">
89
+ {title}
90
+ </h1>
91
+ <p className="signin-lede">
92
+ {note ?? 'Sign in with your organization’s account. Only people an owner has invited can get in.'}
93
+ </p>
94
+ </div>
95
+
96
+ {message !== null && (
97
+ <div className="signin-error">
98
+ <ErrorLine error={message} />
99
+ </div>
100
+ )}
101
+
102
+ {providers.length === 0 ? (
103
+ <p className="signin-empty">
104
+ No sign-in provider is configured. Whoever runs coffre lists them in{' '}
105
+ <span className="mono">signin({'{'} providers {'}'})</span>.
106
+ </p>
107
+ ) : (
108
+ <ul className="providers">
109
+ {providers.map((provider) => (
110
+ <li key={provider.id}>
111
+ {/* A plain link: the provider's page is a full navigation away. */}
112
+ <a
113
+ className="btn provider"
114
+ href={`/auth/signin/${encodeURIComponent(provider.id)}${query}`}
115
+ aria-busy={leaving === provider.id}
116
+ onClick={() => setLeaving(provider.id)}
117
+ >
118
+ <span className="provider-mark" aria-hidden>
119
+ {leaving === provider.id ? <Spinner /> : <ProviderMark brand={provider.brand} />}
120
+ </span>
121
+ Continue with {provider.label}
122
+ </a>
123
+ </li>
124
+ ))}
125
+ </ul>
126
+ )}
127
+ </section>
128
+ );
129
+ }