@coffre/ui 0.0.0 → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +7 -3
- package/dist/client/.assetsignore +2 -0
- package/dist/client/_coffre/assets/account-C3Zo1l5A.js +1 -0
- package/dist/client/_coffre/assets/account-C4bNbeO7.js +2 -0
- package/dist/client/_coffre/assets/affordances-DiuJIiR2.js +1 -0
- package/dist/client/_coffre/assets/audit-1xLyuxGz.js +2 -0
- package/dist/client/_coffre/assets/audit-Dab2GuRj.js +1 -0
- package/dist/client/_coffre/assets/auth.device-BfCfeBWe.js +2 -0
- package/dist/client/_coffre/assets/auth.device-D2pCLF-X.js +1 -0
- package/dist/client/_coffre/assets/coffre-C7qL3HGR.js +1 -0
- package/dist/client/_coffre/assets/directory-C2Ou4SQv.js +1 -0
- package/dist/client/_coffre/assets/globals-Dgq4Jy0x.css +1 -0
- package/dist/client/_coffre/assets/grants-fqTtJ-aW.js +1 -0
- package/dist/client/_coffre/assets/index-BpGwbjmM.js +12 -0
- package/dist/client/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/client/_coffre/assets/login-CR9CBXlw.js +2 -0
- package/dist/client/_coffre/assets/login-DZizFxa4.js +1 -0
- package/dist/client/_coffre/assets/offboarding-DOLJQcXU.js +1 -0
- package/dist/client/_coffre/assets/page-BxW2MwaX.js +1 -0
- package/dist/client/_coffre/assets/preload-helper-BHuP8_FL.js +46 -0
- package/dist/client/_coffre/assets/principal-page-xnBZVURr.js +1 -0
- package/dist/client/_coffre/assets/project-environments-CfIH5kFM.js +1 -0
- package/dist/client/_coffre/assets/projects._project._environment-CrWjQmIA.js +2 -0
- package/dist/client/_coffre/assets/projects._project._environment-CwRVG9Ne.js +3 -0
- package/dist/client/_coffre/assets/projects._project.index-CCDEuE-z.js +2 -0
- package/dist/client/_coffre/assets/projects._project.index-DCJsmnD7.js +1 -0
- package/dist/client/_coffre/assets/projects.index-B8eV8JIn.js +1 -0
- package/dist/client/_coffre/assets/projects.index-BNEC7Oz8.js +2 -0
- package/dist/client/_coffre/assets/settings-2BPsenNM.js +2 -0
- package/dist/client/_coffre/assets/settings-BrS0-wEt.js +1 -0
- package/dist/client/_coffre/assets/signin-errors-CroZWZgm.js +1 -0
- package/dist/client/_coffre/assets/tokens._token-B3-YwuKp.js +2 -0
- package/dist/client/_coffre/assets/tokens._token-D_hsbHx6.js +1 -0
- package/dist/client/_coffre/assets/tokens.index-BdKE2Jv8.js +2 -0
- package/dist/client/_coffre/assets/tokens.index-XvA4XRxh.js +1 -0
- package/dist/client/_coffre/assets/unregistered-CTRMtBIy.js +1 -0
- package/dist/client/_coffre/assets/use-action-DgAf-tiX.js +1 -0
- package/dist/client/_coffre/assets/users._user-BFPXcJ4y.js +2 -0
- package/dist/client/_coffre/assets/users._user-DEtMeSoh.js +1 -0
- package/dist/client/_coffre/assets/users.index-B03beUHq.js +1 -0
- package/dist/client/_coffre/assets/users.index-D8hwzM6P.js +2 -0
- package/dist/client/_coffre/assets/validation-9Cl_XS-l.js +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/server/.vite/manifest.json +572 -0
- package/dist/server/_coffre/assets/_tanstack-start-manifest_v-B6CZDfrB.js +133 -0
- package/dist/server/_coffre/assets/account-B71_b5xc.js +296 -0
- package/dist/server/_coffre/assets/account-BoO6ZqMc.js +176 -0
- package/dist/server/_coffre/assets/affordances-BNaXjMOb.js +46 -0
- package/dist/server/_coffre/assets/async-local-storage-C0cwgkEr.js +3107 -0
- package/dist/server/_coffre/assets/audit-CwRFnSAY.js +74 -0
- package/dist/server/_coffre/assets/audit-t1sYjtrf.js +964 -0
- package/dist/server/_coffre/assets/auth.device-1IcJ475s.js +208 -0
- package/dist/server/_coffre/assets/auth.device-CJwZYYtn.js +29 -0
- package/dist/server/_coffre/assets/coffre-1hxT2E_U.js +278 -0
- package/dist/server/_coffre/assets/directory-wm_JQUfk.js +396 -0
- package/dist/server/_coffre/assets/empty-plugin-adapters-Cq4--YW-.js +5 -0
- package/dist/server/_coffre/assets/globals-Dgq4Jy0x.css +1 -0
- package/dist/server/_coffre/assets/grants-BmhEY1vz.js +243 -0
- package/dist/server/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/server/_coffre/assets/login-B5O5LPXV.js +100 -0
- package/dist/server/_coffre/assets/login-Bvc4gp0X.js +22 -0
- package/dist/server/_coffre/assets/offboarding-CvSilnSm.js +330 -0
- package/dist/server/_coffre/assets/page-BjXk0Ehu.js +2003 -0
- package/dist/server/_coffre/assets/principal-page-DkwNGzM2.js +617 -0
- package/dist/server/_coffre/assets/project-environments-lEzFHUt4.js +9 -0
- package/dist/server/_coffre/assets/projects._project._environment-7grhqlgq.js +2227 -0
- package/dist/server/_coffre/assets/projects._project._environment-ByEf6pmz.js +55 -0
- package/dist/server/_coffre/assets/projects._project.index-B1bjowP-.js +932 -0
- package/dist/server/_coffre/assets/projects._project.index-DU8wtoHD.js +22 -0
- package/dist/server/_coffre/assets/projects.index-B0DoHbCz.js +280 -0
- package/dist/server/_coffre/assets/projects.index-kMDA6pMy.js +54 -0
- package/dist/server/_coffre/assets/react-dom-qCTiwGGR.js +1352 -0
- package/dist/server/_coffre/assets/router-ChU_CwCX.js +2028 -0
- package/dist/server/_coffre/assets/settings-CM9-h7in.js +18 -0
- package/dist/server/_coffre/assets/settings-Cg5qOGij.js +60 -0
- package/dist/server/_coffre/assets/signin-errors-BEFlVDbQ.js +28 -0
- package/dist/server/_coffre/assets/start-DR3rN0St.js +4 -0
- package/dist/server/_coffre/assets/tokens._token-CCpaPMAk.js +268 -0
- package/dist/server/_coffre/assets/tokens._token-Di4OZdAA.js +18 -0
- package/dist/server/_coffre/assets/tokens.index-Do3OHR31.js +34 -0
- package/dist/server/_coffre/assets/tokens.index-tDKq4AFh.js +10 -0
- package/dist/server/_coffre/assets/ui-BNzhIAQP.js +15710 -0
- package/dist/server/_coffre/assets/unregistered-BqaWYFJK.js +51 -0
- package/dist/server/_coffre/assets/use-action-BkJXC5JM.js +953 -0
- package/dist/server/_coffre/assets/useStore-DWGPqzXR.js +892 -0
- package/dist/server/_coffre/assets/users._user-BenYva93.js +15 -0
- package/dist/server/_coffre/assets/users._user-Cp039Va-.js +10 -0
- package/dist/server/_coffre/assets/users.index-BrzG1Ecq.js +10 -0
- package/dist/server/_coffre/assets/users.index-DQ_45DQl.js +34 -0
- package/dist/server/_coffre/assets/validation-BQtqPe2V.js +27 -0
- package/dist/server/index.js +13910 -0
- package/package.json +58 -5
- package/src/components/affordances.ts +80 -0
- package/src/components/agentation.tsx +34 -0
- package/src/components/command-palette.tsx +271 -0
- package/src/components/directory.tsx +448 -0
- package/src/components/grants.tsx +204 -0
- package/src/components/icons.tsx +283 -0
- package/src/components/offboarding.tsx +286 -0
- package/src/components/page.tsx +128 -0
- package/src/components/principal-page.tsx +549 -0
- package/src/components/principal-picker.tsx +168 -0
- package/src/components/principal.tsx +53 -0
- package/src/components/route-states.tsx +60 -0
- package/src/components/service-tokens.tsx +212 -0
- package/src/components/shell.tsx +641 -0
- package/src/components/syncs.tsx +581 -0
- package/src/components/theme.tsx +141 -0
- package/src/components/tile.tsx +22 -0
- package/src/components/ui.tsx +440 -0
- package/src/entry.ts +19 -0
- package/src/lib/access-plan.ts +201 -0
- package/src/lib/audit-sentences.ts +468 -0
- package/src/lib/capabilities.ts +45 -0
- package/src/lib/coffre.ts +57 -0
- package/src/lib/project-access.ts +95 -0
- package/src/lib/project-environments.ts +23 -0
- package/src/lib/reveal.ts +21 -0
- package/src/lib/secret-edit-batch.ts +181 -0
- package/src/lib/signin-errors.ts +33 -0
- package/src/lib/use-action.ts +50 -0
- package/src/lib/validation.ts +27 -0
- package/src/routeTree.gen.ts +367 -0
- package/src/router.tsx +84 -0
- package/src/routes/__root.tsx +192 -0
- package/src/routes/access.tsx +11 -0
- package/src/routes/account.tsx +359 -0
- package/src/routes/audit.tsx +545 -0
- package/src/routes/auth.device.tsx +200 -0
- package/src/routes/index.tsx +15 -0
- package/src/routes/login.tsx +129 -0
- package/src/routes/projects.$project.$environment.tsx +1659 -0
- package/src/routes/projects.$project.index.tsx +917 -0
- package/src/routes/projects.index.tsx +353 -0
- package/src/routes/settings.tsx +72 -0
- package/src/routes/tokens.$token.tsx +35 -0
- package/src/routes/tokens.index.tsx +37 -0
- package/src/routes/unregistered.tsx +59 -0
- package/src/routes/users.$user.tsx +13 -0
- package/src/routes/users.index.tsx +37 -0
- package/src/shared/models.ts +55 -0
- package/src/styles/globals.css +4118 -0
- package/src/types.ts +21 -0
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import type { CoffreClient } from '@coffre/client';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { createFileRoute, Link } from '@tanstack/react-router';
|
|
4
|
+
import { toast } from 'sonner';
|
|
5
|
+
import { deriveUiCapabilities } from '../lib/capabilities';
|
|
6
|
+
import { Refusal, uiResult, useCoffre } from '../lib/coffre';
|
|
7
|
+
import { useAction } from '../lib/use-action';
|
|
8
|
+
import type { ProjectSummary } from '../shared/models';
|
|
9
|
+
import { isActiveAccessibleEnvironment } from '../lib/project-environments';
|
|
10
|
+
import { slugProblem } from '../lib/validation';
|
|
11
|
+
import { EmptyState, ErrorLine, Modal, Spinner } from '../components/ui';
|
|
12
|
+
import { ClosedDoor, PageHeader } from '../components/page';
|
|
13
|
+
import { Tile } from '../components/tile';
|
|
14
|
+
import { AlertTriangle, Folder, Hash, Layers, Plus } from '../components/icons';
|
|
15
|
+
import {
|
|
16
|
+
ProjectEmptyStateCopy,
|
|
17
|
+
RootAdminOnly,
|
|
18
|
+
} from '../components/affordances';
|
|
19
|
+
|
|
20
|
+
export const Route = createFileRoute('/projects/')({
|
|
21
|
+
loader: async ({ context: { client } }) => {
|
|
22
|
+
const result = await uiResult(async () => {
|
|
23
|
+
const [me, { projects }] = await Promise.all([client.me(), client.projects.list()]);
|
|
24
|
+
return { projects, capabilities: deriveUiCapabilities(me, projects) };
|
|
25
|
+
});
|
|
26
|
+
return { result, secrets: result.ok ? await countSecrets(client, result.projects) : {} };
|
|
27
|
+
},
|
|
28
|
+
component: ProjectsPage,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Distinct secret names per project, across the environments you can open.
|
|
33
|
+
*
|
|
34
|
+
* The project summary only counts secrets per environment, and the same key
|
|
35
|
+
* in dev and prod is one secret, not two. So this lists the keys of every
|
|
36
|
+
* environment you can open and counts the names. Listing keys reads no value
|
|
37
|
+
* and writes no audit row. Environments you cannot open are not asked: the
|
|
38
|
+
* refusal would be audited.
|
|
39
|
+
*
|
|
40
|
+
* A project whose keys could not all be listed gets no count rather than a
|
|
41
|
+
* short one.
|
|
42
|
+
*/
|
|
43
|
+
async function countSecrets(
|
|
44
|
+
client: CoffreClient,
|
|
45
|
+
projects: ProjectSummary[],
|
|
46
|
+
): Promise<Record<string, number | null>> {
|
|
47
|
+
const counts = await Promise.all(
|
|
48
|
+
projects
|
|
49
|
+
.filter((project) => project.archivedAt === null)
|
|
50
|
+
.map(async (project) => {
|
|
51
|
+
const environments = project.environments.filter(isActiveAccessibleEnvironment);
|
|
52
|
+
if (environments.length === 0) return [project.slug, null] as const;
|
|
53
|
+
const lists = await Promise.all(
|
|
54
|
+
environments.map((environment) => uiResult(() => client.secrets.list(`${project.slug}/${environment.slug}`))),
|
|
55
|
+
);
|
|
56
|
+
const names = new Set<string>();
|
|
57
|
+
for (const list of lists) {
|
|
58
|
+
if (!list.ok) return [project.slug, null] as const;
|
|
59
|
+
for (const key of list.keys) if (!key.archived) names.add(key.key);
|
|
60
|
+
}
|
|
61
|
+
return [project.slug, names.size] as const;
|
|
62
|
+
}),
|
|
63
|
+
);
|
|
64
|
+
return Object.fromEntries(counts);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function ProjectsPage() {
|
|
68
|
+
const { result, secrets } = Route.useLoaderData();
|
|
69
|
+
|
|
70
|
+
if (!result.ok) {
|
|
71
|
+
return (
|
|
72
|
+
<ClosedDoor
|
|
73
|
+
icon={<AlertTriangle size={18} />}
|
|
74
|
+
title="Projects could not be listed"
|
|
75
|
+
actions={
|
|
76
|
+
<Link className="btn" to="/login">
|
|
77
|
+
Sign in again
|
|
78
|
+
</Link>
|
|
79
|
+
}
|
|
80
|
+
>
|
|
81
|
+
{result.error}
|
|
82
|
+
</ClosedDoor>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const active = result.projects.filter((project) => project.archivedAt === null);
|
|
87
|
+
const archived = result.projects.filter((project) => project.archivedAt !== null);
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<>
|
|
91
|
+
<PageHeader
|
|
92
|
+
title="Projects"
|
|
93
|
+
actions={
|
|
94
|
+
<RootAdminOnly capabilities={result.capabilities}>
|
|
95
|
+
<NewProject />
|
|
96
|
+
</RootAdminOnly>
|
|
97
|
+
}
|
|
98
|
+
/>
|
|
99
|
+
|
|
100
|
+
{active.length === 0 ? (
|
|
101
|
+
<div className="card">
|
|
102
|
+
<EmptyState title="Nothing here for you yet">
|
|
103
|
+
<ProjectEmptyStateCopy
|
|
104
|
+
capabilities={result.capabilities}
|
|
105
|
+
hasArchivedProjects={archived.length > 0}
|
|
106
|
+
/>
|
|
107
|
+
</EmptyState>
|
|
108
|
+
</div>
|
|
109
|
+
) : (
|
|
110
|
+
<section className="card" aria-label="Projects">
|
|
111
|
+
<ProjectTable projects={active} secrets={secrets} />
|
|
112
|
+
</section>
|
|
113
|
+
)}
|
|
114
|
+
|
|
115
|
+
{archived.length > 0 && (
|
|
116
|
+
<section aria-labelledby="archived-projects">
|
|
117
|
+
<h2 className="section-title" id="archived-projects">
|
|
118
|
+
Archived
|
|
119
|
+
</h2>
|
|
120
|
+
<div className="card">
|
|
121
|
+
<ProjectTable projects={archived} secrets={secrets} />
|
|
122
|
+
</div>
|
|
123
|
+
</section>
|
|
124
|
+
)}
|
|
125
|
+
</>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function ProjectTable({
|
|
130
|
+
projects,
|
|
131
|
+
secrets,
|
|
132
|
+
}: {
|
|
133
|
+
projects: ProjectSummary[];
|
|
134
|
+
secrets: Record<string, number | null>;
|
|
135
|
+
}) {
|
|
136
|
+
return (
|
|
137
|
+
<div className="dt-wrap">
|
|
138
|
+
<table className="dt projects stacks">
|
|
139
|
+
<thead>
|
|
140
|
+
<tr>
|
|
141
|
+
<th className="n">#</th>
|
|
142
|
+
<th className="col-project">
|
|
143
|
+
<span className="th">
|
|
144
|
+
<Folder size={14} />
|
|
145
|
+
Project
|
|
146
|
+
</span>
|
|
147
|
+
</th>
|
|
148
|
+
<th>
|
|
149
|
+
<span className="th">
|
|
150
|
+
<Layers size={14} />
|
|
151
|
+
Environments
|
|
152
|
+
</span>
|
|
153
|
+
</th>
|
|
154
|
+
<th className="col-shrink col-secrets">
|
|
155
|
+
<span className="th">
|
|
156
|
+
<Hash size={14} />
|
|
157
|
+
Secrets
|
|
158
|
+
</span>
|
|
159
|
+
</th>
|
|
160
|
+
</tr>
|
|
161
|
+
</thead>
|
|
162
|
+
<tbody>
|
|
163
|
+
{projects.map((project, index) => (
|
|
164
|
+
<ProjectRow
|
|
165
|
+
key={project.slug}
|
|
166
|
+
number={index + 1}
|
|
167
|
+
project={project}
|
|
168
|
+
secrets={secrets[project.slug] ?? null}
|
|
169
|
+
/>
|
|
170
|
+
))}
|
|
171
|
+
</tbody>
|
|
172
|
+
</table>
|
|
173
|
+
</div>
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* One project. The whole row opens it; the environment links inside it sit
|
|
179
|
+
* above that and go straight to the environment.
|
|
180
|
+
*/
|
|
181
|
+
function ProjectRow({
|
|
182
|
+
number,
|
|
183
|
+
project,
|
|
184
|
+
secrets,
|
|
185
|
+
}: {
|
|
186
|
+
number: number;
|
|
187
|
+
project: ProjectSummary;
|
|
188
|
+
secrets: number | null;
|
|
189
|
+
}) {
|
|
190
|
+
const isArchived = project.archivedAt !== null;
|
|
191
|
+
const listedEnvironments = project.environments.filter(
|
|
192
|
+
(environment) =>
|
|
193
|
+
environment.details === null || environment.details.archivedAt === null,
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
return (
|
|
197
|
+
<tr className="row-link">
|
|
198
|
+
<td className="n">{number}</td>
|
|
199
|
+
<td className="col-project">
|
|
200
|
+
<span className="cell-project">
|
|
201
|
+
<Tile name={project.slug} />
|
|
202
|
+
<span className="cell-stack">
|
|
203
|
+
<Link
|
|
204
|
+
className="cell-link stretch"
|
|
205
|
+
to="/projects/$project"
|
|
206
|
+
params={{ project: project.slug }}
|
|
207
|
+
>
|
|
208
|
+
{project.name}
|
|
209
|
+
</Link>
|
|
210
|
+
<small className="mono">{project.slug}</small>
|
|
211
|
+
</span>
|
|
212
|
+
</span>
|
|
213
|
+
</td>
|
|
214
|
+
<td className="col-envs" data-label="Environments">
|
|
215
|
+
{isArchived || listedEnvironments.length === 0 ? (
|
|
216
|
+
<span className="cell-muted">
|
|
217
|
+
{listedEnvironments.length === 0
|
|
218
|
+
? 'No environments yet'
|
|
219
|
+
: `${listedEnvironments.length} environment${listedEnvironments.length === 1 ? '' : 's'}`}
|
|
220
|
+
</span>
|
|
221
|
+
) : (
|
|
222
|
+
<span className="env-links" aria-label={`Environments in ${project.slug}`}>
|
|
223
|
+
{listedEnvironments.map((environment) =>
|
|
224
|
+
isActiveAccessibleEnvironment(environment) ? (
|
|
225
|
+
<Link
|
|
226
|
+
key={environment.slug}
|
|
227
|
+
className="env-link"
|
|
228
|
+
to="/projects/$project/$environment"
|
|
229
|
+
params={{ project: project.slug, environment: environment.slug }}
|
|
230
|
+
>
|
|
231
|
+
{environment.slug}
|
|
232
|
+
<span className="count">{environment.details.secretCount}</span>
|
|
233
|
+
</Link>
|
|
234
|
+
) : (
|
|
235
|
+
<span
|
|
236
|
+
key={environment.slug}
|
|
237
|
+
className="env-link"
|
|
238
|
+
title="You can see this environment exists, but not open it"
|
|
239
|
+
>
|
|
240
|
+
{environment.slug}
|
|
241
|
+
</span>
|
|
242
|
+
),
|
|
243
|
+
)}
|
|
244
|
+
</span>
|
|
245
|
+
)}
|
|
246
|
+
</td>
|
|
247
|
+
<td className="col-secrets num nowrap">
|
|
248
|
+
{secrets !== null && !isArchived ? (
|
|
249
|
+
<>
|
|
250
|
+
{secrets}
|
|
251
|
+
<span className="narrow-only"> secret{secrets === 1 ? '' : 's'}</span>
|
|
252
|
+
</>
|
|
253
|
+
) : (
|
|
254
|
+
<span className="cell-muted wide-only">—</span>
|
|
255
|
+
)}
|
|
256
|
+
</td>
|
|
257
|
+
</tr>
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function NewProject() {
|
|
262
|
+
const [slug, setSlug] = useState('');
|
|
263
|
+
const [name, setName] = useState('');
|
|
264
|
+
const [open, setOpen] = useState(false);
|
|
265
|
+
const coffre = useCoffre();
|
|
266
|
+
const { pending, error, setError, run } = useAction();
|
|
267
|
+
const slugError = slug === '' ? null : slugProblem(slug);
|
|
268
|
+
|
|
269
|
+
function close() {
|
|
270
|
+
setOpen(false);
|
|
271
|
+
setError(null);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return (
|
|
275
|
+
<>
|
|
276
|
+
<button className="btn btn-primary" onClick={() => setOpen(true)}>
|
|
277
|
+
<Plus size={14} />
|
|
278
|
+
New project
|
|
279
|
+
</button>
|
|
280
|
+
|
|
281
|
+
<Modal
|
|
282
|
+
open={open}
|
|
283
|
+
onOpenChange={(next) => (next ? setOpen(true) : close())}
|
|
284
|
+
title="New project"
|
|
285
|
+
description="A project holds environments, and access is granted on it or on one of its environments. You become its owner."
|
|
286
|
+
>
|
|
287
|
+
<form
|
|
288
|
+
className="form"
|
|
289
|
+
onSubmit={(event) => {
|
|
290
|
+
event.preventDefault();
|
|
291
|
+
run(
|
|
292
|
+
async () => {
|
|
293
|
+
// Creating is an idempotent PUT; the form reports a slug that is taken.
|
|
294
|
+
const { created } = await coffre.projects.create(slug, { name });
|
|
295
|
+
if (!created) throw new Refusal(`A project named "${slug}" already exists.`);
|
|
296
|
+
},
|
|
297
|
+
() => {
|
|
298
|
+
toast.success(`Project ${slug} created`);
|
|
299
|
+
setSlug('');
|
|
300
|
+
setName('');
|
|
301
|
+
setOpen(false);
|
|
302
|
+
},
|
|
303
|
+
);
|
|
304
|
+
}}
|
|
305
|
+
>
|
|
306
|
+
<label className="field">
|
|
307
|
+
<span className="label">Slug</span>
|
|
308
|
+
<input
|
|
309
|
+
className="input input-mono"
|
|
310
|
+
autoFocus
|
|
311
|
+
spellCheck={false}
|
|
312
|
+
autoComplete="off"
|
|
313
|
+
placeholder="market"
|
|
314
|
+
value={slug}
|
|
315
|
+
aria-invalid={slugError !== null}
|
|
316
|
+
aria-describedby="new-project-slug-hint"
|
|
317
|
+
onChange={(event) => setSlug(event.target.value)}
|
|
318
|
+
/>
|
|
319
|
+
<span className={`hint${slugError !== null ? ' edit-note-error' : ''}`} id="new-project-slug-hint">
|
|
320
|
+
{slugError ?? 'Used in paths, as in market/prod. Renaming it later is safe.'}
|
|
321
|
+
</span>
|
|
322
|
+
</label>
|
|
323
|
+
|
|
324
|
+
<label className="field">
|
|
325
|
+
<span className="label">Display name</span>
|
|
326
|
+
<input
|
|
327
|
+
className="input"
|
|
328
|
+
placeholder="Market data platform"
|
|
329
|
+
value={name}
|
|
330
|
+
onChange={(event) => setName(event.target.value)}
|
|
331
|
+
/>
|
|
332
|
+
</label>
|
|
333
|
+
|
|
334
|
+
<ErrorLine error={error} />
|
|
335
|
+
|
|
336
|
+
<div className="dialog-actions">
|
|
337
|
+
<button className="btn" type="button" onClick={close}>
|
|
338
|
+
Cancel
|
|
339
|
+
</button>
|
|
340
|
+
<button
|
|
341
|
+
className="btn btn-primary"
|
|
342
|
+
type="submit"
|
|
343
|
+
disabled={pending || slug === '' || slugError !== null || name.trim() === ''}
|
|
344
|
+
>
|
|
345
|
+
{pending && <Spinner />}
|
|
346
|
+
Create project
|
|
347
|
+
</button>
|
|
348
|
+
</div>
|
|
349
|
+
</form>
|
|
350
|
+
</Modal>
|
|
351
|
+
</>
|
|
352
|
+
);
|
|
353
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { createFileRoute, Link } from '@tanstack/react-router';
|
|
2
|
+
import { loadDirectory } from '../components/directory';
|
|
3
|
+
import { Card, Fact, PageHeader } from '../components/page';
|
|
4
|
+
|
|
5
|
+
/** The workspace's settings. Your own are under Account, at the sidebar's foot. */
|
|
6
|
+
export const Route = createFileRoute('/settings')({
|
|
7
|
+
// Instance facts come from the directory, which only owners may list.
|
|
8
|
+
// Asking on everyone's behalf would write a refusal to the audit log for
|
|
9
|
+
// every user who opens the page, so it is only asked for them.
|
|
10
|
+
loader: async ({ context: { client }, parentMatchPromise }) => {
|
|
11
|
+
const root = (await parentMatchPromise).loaderData;
|
|
12
|
+
const canManage = root?.capabilities.canManageGrants ?? false;
|
|
13
|
+
return { auth: root?.auth, directory: canManage ? await loadDirectory(client, true) : null };
|
|
14
|
+
},
|
|
15
|
+
component: SettingsPage,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const listFormat = new Intl.ListFormat('en', { type: 'disjunction' });
|
|
19
|
+
|
|
20
|
+
function SettingsPage() {
|
|
21
|
+
const { auth, directory } = Route.useLoaderData();
|
|
22
|
+
const providers = auth?.signin?.providers.map((provider) => provider.label) ?? [];
|
|
23
|
+
|
|
24
|
+
const principals = directory?.ok === true ? directory.principals : null;
|
|
25
|
+
const rootAdmins = principals?.filter((entry) => entry.isRootAdmin) ?? [];
|
|
26
|
+
const users = principals?.filter((entry) => entry.principalType === 'user').length ?? 0;
|
|
27
|
+
const tokens = principals?.filter((entry) => entry.principalType === 'service').length ?? 0;
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<>
|
|
31
|
+
<PageHeader title="Settings" />
|
|
32
|
+
|
|
33
|
+
<Card
|
|
34
|
+
labelledBy="instance"
|
|
35
|
+
title="Instance"
|
|
36
|
+
description="Set in the deployment's configuration, so shown here rather than edited."
|
|
37
|
+
>
|
|
38
|
+
<dl className="facts">
|
|
39
|
+
<Fact label="Sign-in">
|
|
40
|
+
{auth?.signin
|
|
41
|
+
? `coffre’s own sign-in, with ${listFormat.format(providers)}. Only invited members get in.`
|
|
42
|
+
: 'Cloudflare Access. coffre has no sign-in of its own; every request carries an Access assertion that is verified at the origin.'}
|
|
43
|
+
</Fact>
|
|
44
|
+
{principals !== null && (
|
|
45
|
+
<>
|
|
46
|
+
<Fact label="Root admins">
|
|
47
|
+
<span className="fact-list">
|
|
48
|
+
{rootAdmins.map((admin) => (
|
|
49
|
+
<span key={admin.principalId} className="mono">
|
|
50
|
+
{admin.principalId}
|
|
51
|
+
</span>
|
|
52
|
+
))}
|
|
53
|
+
</span>
|
|
54
|
+
</Fact>
|
|
55
|
+
<Fact label="Directory">
|
|
56
|
+
<span>
|
|
57
|
+
<Link to="/users">
|
|
58
|
+
{users} user{users === 1 ? '' : 's'}
|
|
59
|
+
</Link>
|
|
60
|
+
{' · '}
|
|
61
|
+
<Link to="/tokens">
|
|
62
|
+
{tokens} token{tokens === 1 ? '' : 's'}
|
|
63
|
+
</Link>
|
|
64
|
+
</span>
|
|
65
|
+
</Fact>
|
|
66
|
+
</>
|
|
67
|
+
)}
|
|
68
|
+
</dl>
|
|
69
|
+
</Card>
|
|
70
|
+
</>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createFileRoute } from '@tanstack/react-router';
|
|
2
|
+
import { loadPrincipalPage, PrincipalPage } from '../components/principal-page';
|
|
3
|
+
import { ServiceTokens } from '../components/service-tokens';
|
|
4
|
+
import { memberRef, uiResult } from '../lib/coffre';
|
|
5
|
+
|
|
6
|
+
export const Route = createFileRoute('/tokens/$token')({
|
|
7
|
+
loader: async ({ context: { client }, params, parentMatchPromise }) => {
|
|
8
|
+
const root = (await parentMatchPromise).loaderData;
|
|
9
|
+
// Only owners issue and see credentials; asking as anyone else would
|
|
10
|
+
// only earn a refusal. Only coffre's own sign-in issues any.
|
|
11
|
+
const [page, credentials] = await Promise.all([
|
|
12
|
+
loadPrincipalPage(client, 'service', params.token, root),
|
|
13
|
+
root?.capabilities.canManageGrants && root.auth.signin !== null
|
|
14
|
+
? uiResult(() => client.tokens.list(memberRef('service', params.token)))
|
|
15
|
+
: Promise.resolve(null),
|
|
16
|
+
]);
|
|
17
|
+
return { page, credentials };
|
|
18
|
+
},
|
|
19
|
+
component: TokenPage,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
function TokenPage() {
|
|
23
|
+
const { token } = Route.useParams();
|
|
24
|
+
const { page, credentials } = Route.useLoaderData();
|
|
25
|
+
// A removed service can be issued nothing; its page shows what it left behind.
|
|
26
|
+
const active = page.report?.ok === true && page.report.report?.status === 'active';
|
|
27
|
+
return (
|
|
28
|
+
<>
|
|
29
|
+
<PrincipalPage principalType="service" principalId={token} data={page} />
|
|
30
|
+
{active && credentials?.ok === true && (
|
|
31
|
+
<ServiceTokens serviceId={token} tokens={credentials.tokens} />
|
|
32
|
+
)}
|
|
33
|
+
</>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createFileRoute } from '@tanstack/react-router';
|
|
2
|
+
import { AddPrincipal, DirectoryTable, loadDirectory } from '../components/directory';
|
|
3
|
+
import { ClosedDoor, PageHeader } from '../components/page';
|
|
4
|
+
import { RemovedList } from '../components/offboarding';
|
|
5
|
+
import { Key } from '../components/icons';
|
|
6
|
+
|
|
7
|
+
export const Route = createFileRoute('/tokens/')({
|
|
8
|
+
loader: async ({ context: { client }, parentMatchPromise }) =>
|
|
9
|
+
loadDirectory(client, (await parentMatchPromise).loaderData?.capabilities.canManageGrants ?? false),
|
|
10
|
+
component: TokensPage,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
function TokensPage() {
|
|
14
|
+
const result = Route.useLoaderData();
|
|
15
|
+
|
|
16
|
+
if (!result.ok) {
|
|
17
|
+
return (
|
|
18
|
+
<ClosedDoor icon={<Key size={18} />} label="Tokens" title="Tokens are closed to you">
|
|
19
|
+
{result.error}
|
|
20
|
+
</ClosedDoor>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const tokens = result.principals.filter((principal) => principal.principalType === 'service');
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<>
|
|
28
|
+
<PageHeader title="Tokens" actions={<AddPrincipal principalType="service" />} />
|
|
29
|
+
<DirectoryTable
|
|
30
|
+
principalType="service"
|
|
31
|
+
principals={tokens}
|
|
32
|
+
hasRemoved={result.removed.some((principal) => principal.principalType === 'service')}
|
|
33
|
+
/>
|
|
34
|
+
<RemovedList principalType="service" removed={result.removed} />
|
|
35
|
+
</>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { createFileRoute, useLoaderData } from '@tanstack/react-router';
|
|
2
|
+
|
|
3
|
+
import { ClosedDoor } from '../components/page';
|
|
4
|
+
import { User } from '../components/icons';
|
|
5
|
+
|
|
6
|
+
export const Route = createFileRoute('/unregistered')({
|
|
7
|
+
component: UnregisteredPage,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Cloudflare Access has authenticated this person, but Coffre has not
|
|
12
|
+
* registered them as a member. Keep this deliberately actionless: registration is
|
|
13
|
+
* an owner decision, not a self-service privilege escalation path.
|
|
14
|
+
*/
|
|
15
|
+
function UnregisteredPage() {
|
|
16
|
+
const { principal, accessTampered } = useLoaderData({ from: '__root__' });
|
|
17
|
+
|
|
18
|
+
if (accessTampered) {
|
|
19
|
+
return (
|
|
20
|
+
<ClosedDoor icon={<User size={18} />} label="Integrity check failed" title="Your access is on hold">
|
|
21
|
+
<p>
|
|
22
|
+
Your access record
|
|
23
|
+
{principal !== null && (
|
|
24
|
+
<>
|
|
25
|
+
{' '}
|
|
26
|
+
(<span className="mono">{principal.id}</span>)
|
|
27
|
+
</>
|
|
28
|
+
)}{' '}
|
|
29
|
+
was changed outside coffre, so its vault refuses it until someone looks. Nothing you
|
|
30
|
+
held is available meanwhile.
|
|
31
|
+
</p>
|
|
32
|
+
<p>Ask a coffre owner to remove you under Users and add you again, which starts your access over.</p>
|
|
33
|
+
</ClosedDoor>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<ClosedDoor
|
|
39
|
+
icon={<User size={18} />}
|
|
40
|
+
label="Registration required"
|
|
41
|
+
title="You are not a member yet"
|
|
42
|
+
>
|
|
43
|
+
<p>
|
|
44
|
+
Cloudflare Access knows who you are
|
|
45
|
+
{principal !== null && (
|
|
46
|
+
<>
|
|
47
|
+
{' '}
|
|
48
|
+
(<span className="mono">{principal.id}</span>)
|
|
49
|
+
</>
|
|
50
|
+
)}
|
|
51
|
+
, but this coffre instance has not registered that identity. Until it does, no
|
|
52
|
+
projects, secrets, audit entries or API operations are available to you.
|
|
53
|
+
</p>
|
|
54
|
+
<p>
|
|
55
|
+
Ask a coffre owner or root admin to add your Access email under Users.
|
|
56
|
+
</p>
|
|
57
|
+
</ClosedDoor>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createFileRoute } from '@tanstack/react-router';
|
|
2
|
+
import { loadPrincipalPage, PrincipalPage } from '../components/principal-page';
|
|
3
|
+
|
|
4
|
+
export const Route = createFileRoute('/users/$user')({
|
|
5
|
+
loader: async ({ context: { client }, params, parentMatchPromise }) =>
|
|
6
|
+
loadPrincipalPage(client, 'user', params.user, (await parentMatchPromise).loaderData),
|
|
7
|
+
component: UserPage,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
function UserPage() {
|
|
11
|
+
const { user } = Route.useParams();
|
|
12
|
+
return <PrincipalPage principalType="user" principalId={user} data={Route.useLoaderData()} />;
|
|
13
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createFileRoute } from '@tanstack/react-router';
|
|
2
|
+
import { AddPrincipal, DirectoryTable, loadDirectory } from '../components/directory';
|
|
3
|
+
import { ClosedDoor, PageHeader } from '../components/page';
|
|
4
|
+
import { RemovedList } from '../components/offboarding';
|
|
5
|
+
import { Users } from '../components/icons';
|
|
6
|
+
|
|
7
|
+
export const Route = createFileRoute('/users/')({
|
|
8
|
+
loader: async ({ context: { client }, parentMatchPromise }) =>
|
|
9
|
+
loadDirectory(client, (await parentMatchPromise).loaderData?.capabilities.canManageGrants ?? false),
|
|
10
|
+
component: UsersPage,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
function UsersPage() {
|
|
14
|
+
const result = Route.useLoaderData();
|
|
15
|
+
|
|
16
|
+
if (!result.ok) {
|
|
17
|
+
return (
|
|
18
|
+
<ClosedDoor icon={<Users size={18} />} label="Users" title="Users are closed to you">
|
|
19
|
+
{result.error}
|
|
20
|
+
</ClosedDoor>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const users = result.principals.filter((principal) => principal.principalType === 'user');
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<>
|
|
28
|
+
<PageHeader title="Users" actions={<AddPrincipal principalType="user" />} />
|
|
29
|
+
<DirectoryTable
|
|
30
|
+
principalType="user"
|
|
31
|
+
principals={users}
|
|
32
|
+
hasRemoved={result.removed.some((principal) => principal.principalType === 'user')}
|
|
33
|
+
/>
|
|
34
|
+
<RemovedList principalType="user" removed={result.removed} />
|
|
35
|
+
</>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ImportAction,
|
|
3
|
+
Me as ApiMe,
|
|
4
|
+
Member,
|
|
5
|
+
OffboardingReport,
|
|
6
|
+
ProjectSummary as ApiProjectSummary,
|
|
7
|
+
RemovedMember,
|
|
8
|
+
RunOutcome as ApiRunOutcome,
|
|
9
|
+
SecretKey as ApiSecretKey,
|
|
10
|
+
SecretVersion as ApiSecretVersion,
|
|
11
|
+
SyncView as ApiSyncView,
|
|
12
|
+
} from '@coffre/client';
|
|
13
|
+
import type { Permission as CorePermission } from '@coffre/core/access';
|
|
14
|
+
|
|
15
|
+
/** Browser-safe projections of what the API returns. */
|
|
16
|
+
export type Permission = CorePermission;
|
|
17
|
+
export type Me = ApiMe;
|
|
18
|
+
export type SecretKey = ApiSecretKey;
|
|
19
|
+
export type ProjectSummary = ApiProjectSummary;
|
|
20
|
+
export type SecretVersion = ApiSecretVersion;
|
|
21
|
+
export type SyncView = ApiSyncView;
|
|
22
|
+
export type RunOutcome = ApiRunOutcome;
|
|
23
|
+
|
|
24
|
+
/** One member's role at one place in a project, as the project page lists them. */
|
|
25
|
+
export type GrantRow = {
|
|
26
|
+
id: string;
|
|
27
|
+
principalType: 'user' | 'service';
|
|
28
|
+
principalId: string;
|
|
29
|
+
role: string;
|
|
30
|
+
roleName: string;
|
|
31
|
+
permissions: Permission[];
|
|
32
|
+
scope: 'project' | 'environment';
|
|
33
|
+
environmentSlug: string | null;
|
|
34
|
+
expiresAt: string | null;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type RoleRow = {
|
|
38
|
+
slug: string;
|
|
39
|
+
name: string;
|
|
40
|
+
description: string;
|
|
41
|
+
permissions: Permission[];
|
|
42
|
+
/** False when the role contains a project-only permission. */
|
|
43
|
+
assignableToEnvironment: boolean;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type DirectoryPrincipal = Pick<Member, 'principalType' | 'principalId' | 'instanceRole' | 'isRootAdmin'> &
|
|
47
|
+
Partial<Pick<Member, 'tampered'>>;
|
|
48
|
+
|
|
49
|
+
export type ImportPlanEntry = { key: string; action: ImportAction; version: number | null };
|
|
50
|
+
|
|
51
|
+
/** What someone can still reach and what they have seen, with the syncs they set up. */
|
|
52
|
+
export type PrincipalReport = OffboardingReport;
|
|
53
|
+
export type RemovedPrincipal = RemovedMember;
|
|
54
|
+
|
|
55
|
+
export type ImportProblem = { line: number; text: string; reason: string };
|