@coffre/ui 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/audit-sentence-BhHmvQX_.js +660 -0
- package/dist/chunks/audit-sentence-BhHmvQX_.js.map +1 -0
- package/dist/chunks/connected-apps-CUOyEZXR.js +146 -0
- package/dist/chunks/connected-apps-CUOyEZXR.js.map +1 -0
- package/dist/chunks/delete-place-CRX7ntE8.js +206 -0
- package/dist/chunks/delete-place-CRX7ntE8.js.map +1 -0
- package/dist/chunks/{directory-CSjWWUQ1.js → directory-CxxrnGUL.js} +177 -60
- package/dist/chunks/directory-CxxrnGUL.js.map +1 -0
- package/dist/chunks/folders-DoBmCwOi.js +207 -0
- package/dist/chunks/folders-DoBmCwOi.js.map +1 -0
- package/dist/chunks/grants-CXcmhujY.js +669 -0
- package/dist/chunks/grants-CXcmhujY.js.map +1 -0
- package/dist/chunks/offboarding-6eAduCsM.js +305 -0
- package/dist/chunks/offboarding-6eAduCsM.js.map +1 -0
- package/dist/chunks/one-time-DXEl9hbg.js +35 -0
- package/dist/chunks/one-time-DXEl9hbg.js.map +1 -0
- package/dist/chunks/page-DvsgZ2Hd.js +391 -0
- package/dist/chunks/page-DvsgZ2Hd.js.map +1 -0
- package/dist/chunks/principal-BIN-xwZw.js +42 -0
- package/dist/chunks/principal-BIN-xwZw.js.map +1 -0
- package/dist/chunks/{principal-page-D_91OA0l.js → principal-page-B9R2zPlp.js} +259 -251
- package/dist/chunks/principal-page-B9R2zPlp.js.map +1 -0
- package/dist/chunks/project-page-SRCtRe2g.js +17 -0
- package/dist/chunks/project-page-SRCtRe2g.js.map +1 -0
- package/dist/chunks/{queries-CQ81o4so.js → queries-DVR_i3rA.js} +132 -30
- package/dist/chunks/queries-DVR_i3rA.js.map +1 -0
- package/dist/chunks/references-B6pLT1uQ.js +343 -0
- package/dist/chunks/references-B6pLT1uQ.js.map +1 -0
- package/dist/chunks/{row-state-0PsrEzOL.js → row-state-DOPUsjQK.js} +3 -3
- package/dist/chunks/{row-state-0PsrEzOL.js.map → row-state-DOPUsjQK.js.map} +1 -1
- package/dist/chunks/signin-errors--ykMFuqN.js +57 -0
- package/dist/chunks/signin-errors--ykMFuqN.js.map +1 -0
- package/dist/chunks/tabs-BmwKfUeK.js +22 -0
- package/dist/chunks/tabs-BmwKfUeK.js.map +1 -0
- package/dist/chunks/{theme-B2vQolVR.js → theme-DJuz-xLM.js} +3 -3
- package/dist/chunks/{theme-B2vQolVR.js.map → theme-DJuz-xLM.js.map} +1 -1
- package/dist/chunks/{ui-DixXLQvQ.js → ui-DJje3gST.js} +6 -3
- package/dist/chunks/ui-DJje3gST.js.map +1 -0
- package/dist/chunks/{use-change-c6CeLRin.js → use-change-CZdI2MJG.js} +75 -21
- package/dist/chunks/use-change-CZdI2MJG.js.map +1 -0
- package/dist/chunks/{use-shell-jxd7Tzd-.js → use-shell-rNKfGjdj.js} +3 -3
- package/dist/chunks/{use-shell-jxd7Tzd-.js.map → use-shell-rNKfGjdj.js.map} +1 -1
- package/dist/chunks/validation-D312_NLf.js +87 -0
- package/dist/chunks/validation-D312_NLf.js.map +1 -0
- package/dist/index.d.ts +385 -31
- package/dist/index.js +188 -102
- package/dist/index.js.map +1 -1
- package/dist/pages/account.d.ts +2 -2
- package/dist/pages/account.js +174 -135
- package/dist/pages/account.js.map +1 -1
- package/dist/pages/approval.d.ts +9 -0
- package/dist/pages/approval.js +207 -0
- package/dist/pages/approval.js.map +1 -0
- package/dist/pages/audit.js +17 -542
- package/dist/pages/audit.js.map +1 -1
- package/dist/pages/device-login.js +2 -3
- package/dist/pages/device-login.js.map +1 -1
- package/dist/pages/environment.js +647 -257
- package/dist/pages/environment.js.map +1 -1
- package/dist/pages/login.js +18 -7
- package/dist/pages/login.js.map +1 -1
- package/dist/pages/oauth-authorize.d.ts +10 -0
- package/dist/pages/oauth-authorize.js +249 -0
- package/dist/pages/oauth-authorize.js.map +1 -0
- package/dist/pages/project-access.d.ts +6 -0
- package/dist/pages/project-access.js +370 -0
- package/dist/pages/project-access.js.map +1 -0
- package/dist/pages/project-environments.d.ts +4 -0
- package/dist/pages/project-environments.js +593 -0
- package/dist/pages/project-environments.js.map +1 -0
- package/dist/pages/project-settings.d.ts +4 -0
- package/dist/pages/project-settings.js +242 -0
- package/dist/pages/project-settings.js.map +1 -0
- package/dist/pages/project.d.ts +10 -2
- package/dist/pages/project.js +57 -934
- package/dist/pages/project.js.map +1 -1
- package/dist/pages/projects.js +53 -21
- package/dist/pages/projects.js.map +1 -1
- package/dist/pages/service-account.d.ts +10 -0
- package/dist/pages/{token.js → service-account.js} +112 -54
- package/dist/pages/service-account.js.map +1 -0
- package/dist/pages/service-accounts.d.ts +3 -0
- package/dist/pages/service-accounts.js +38 -0
- package/dist/pages/service-accounts.js.map +1 -0
- package/dist/pages/settings.d.ts +1 -0
- package/dist/pages/settings.js +104 -42
- package/dist/pages/settings.js.map +1 -1
- package/dist/pages/unregistered.js +2 -3
- package/dist/pages/unregistered.js.map +1 -1
- package/dist/pages/user.d.ts +6 -1
- package/dist/pages/user.js +18 -6
- package/dist/pages/user.js.map +1 -1
- package/dist/pages/users.js +6 -10
- package/dist/pages/users.js.map +1 -1
- package/package.json +3 -3
- package/src/components/actions-log.tsx +117 -0
- package/src/components/audit-sentence.tsx +55 -0
- package/src/components/command-palette.tsx +4 -4
- package/src/components/connected-apps.tsx +138 -0
- package/src/components/delete-place.tsx +180 -0
- package/src/components/directory.tsx +266 -110
- package/src/components/every-project.tsx +287 -0
- package/src/components/expiry-field.tsx +42 -0
- package/src/components/folders.tsx +219 -0
- package/src/components/grants.tsx +11 -4
- package/src/components/icons.tsx +2 -0
- package/src/components/missing.tsx +110 -0
- package/src/components/offboarding.tsx +62 -34
- package/src/components/page.tsx +4 -1
- package/src/components/principal-page.tsx +154 -108
- package/src/components/principal-picker.tsx +5 -5
- package/src/components/principal.tsx +4 -4
- package/src/components/references.tsx +323 -0
- package/src/components/service-tokens.tsx +112 -93
- package/src/components/shell.tsx +11 -32
- package/src/components/tabs.tsx +18 -0
- package/src/components/trusted-workloads.tsx +97 -79
- package/src/components/ui.tsx +8 -1
- package/src/index.ts +13 -3
- package/src/layout.tsx +2 -2
- package/src/lib/access-plan.ts +2 -2
- package/src/lib/audit-sentences.ts +161 -77
- package/src/lib/changes.ts +77 -5
- package/src/lib/coffre.ts +3 -2
- package/src/lib/one-time.ts +32 -0
- package/src/lib/project-access.ts +11 -23
- package/src/lib/project-page.ts +14 -0
- package/src/lib/queries.ts +126 -32
- package/src/lib/search.ts +25 -0
- package/src/lib/signin-errors.ts +45 -1
- package/src/lib/validation.ts +14 -0
- package/src/options.ts +187 -42
- package/src/pages/account.tsx +176 -133
- package/src/pages/approval.tsx +197 -0
- package/src/pages/audit.tsx +9 -61
- package/src/pages/environment.tsx +585 -286
- package/src/pages/login.tsx +8 -2
- package/src/pages/oauth-authorize.tsx +233 -0
- package/src/pages/project-access.tsx +219 -0
- package/src/pages/project-environments.tsx +582 -0
- package/src/pages/project-settings.tsx +259 -0
- package/src/pages/project.tsx +52 -879
- package/src/pages/projects.tsx +55 -18
- package/src/pages/service-account.tsx +50 -0
- package/src/pages/{tokens.tsx → service-accounts.tsx} +9 -6
- package/src/pages/settings.tsx +62 -8
- package/src/pages/user.tsx +16 -4
- package/src/pages/users.tsx +2 -2
- package/src/parity.ts +160 -0
- package/src/register.ts +57 -10
- package/src/router.tsx +4 -0
- package/src/shared/models.ts +6 -2
- package/src/styles/globals.css +536 -31
- package/dist/chunks/directory-CSjWWUQ1.js.map +0 -1
- package/dist/chunks/grants-saMQagmG.js +0 -160
- package/dist/chunks/grants-saMQagmG.js.map +0 -1
- package/dist/chunks/icons-D-PfAfnH.js +0 -203
- package/dist/chunks/icons-D-PfAfnH.js.map +0 -1
- package/dist/chunks/offboarding-C6l30DZR.js +0 -263
- package/dist/chunks/offboarding-C6l30DZR.js.map +0 -1
- package/dist/chunks/page-C5HcNqf2.js +0 -190
- package/dist/chunks/page-C5HcNqf2.js.map +0 -1
- package/dist/chunks/principal-page-D_91OA0l.js.map +0 -1
- package/dist/chunks/queries-CQ81o4so.js.map +0 -1
- package/dist/chunks/signin-errors-BEFlVDbQ.js +0 -30
- package/dist/chunks/signin-errors-BEFlVDbQ.js.map +0 -1
- package/dist/chunks/ui-DixXLQvQ.js.map +0 -1
- package/dist/chunks/use-action-CWsg_YWU.js +0 -49
- package/dist/chunks/use-action-CWsg_YWU.js.map +0 -1
- package/dist/chunks/use-change-c6CeLRin.js.map +0 -1
- package/dist/chunks/validation-BQtqPe2V.js +0 -29
- package/dist/chunks/validation-BQtqPe2V.js.map +0 -1
- package/dist/pages/token.d.ts +0 -3
- package/dist/pages/token.js.map +0 -1
- package/dist/pages/tokens.d.ts +0 -3
- package/dist/pages/tokens.js +0 -39
- package/dist/pages/tokens.js.map +0 -1
- package/dist/project-BqIy8gYR.d.ts +0 -5
- package/src/lib/instance.ts +0 -13
- package/src/pages/token.tsx +0 -34
package/src/options.ts
CHANGED
|
@@ -17,12 +17,26 @@
|
|
|
17
17
|
// another path is one the links do not reach.
|
|
18
18
|
import { redirect, type ParsedLocation } from '@tanstack/react-router';
|
|
19
19
|
import type { QueryClient } from '@tanstack/react-query';
|
|
20
|
-
import type { CoffreClient } from '@coffre/client';
|
|
20
|
+
import type { CoffreClient, RouteInput } from '@coffre/client';
|
|
21
21
|
|
|
22
22
|
import { ShellLayout, SoloLayout } from './layout';
|
|
23
|
-
import { uiResult } from './lib/coffre';
|
|
24
|
-
import {
|
|
25
|
-
import
|
|
23
|
+
import { memberRef, uiResult } from './lib/coffre';
|
|
24
|
+
import { stringsOf } from './lib/search';
|
|
25
|
+
import {
|
|
26
|
+
loadAccess,
|
|
27
|
+
loadDirectory,
|
|
28
|
+
loadMember,
|
|
29
|
+
loadProject,
|
|
30
|
+
loadServiceDirectory,
|
|
31
|
+
loadSettings,
|
|
32
|
+
loadShell,
|
|
33
|
+
projectOf,
|
|
34
|
+
queries,
|
|
35
|
+
signInWays,
|
|
36
|
+
type AuditSearch,
|
|
37
|
+
} from './lib/queries';
|
|
38
|
+
import type { Permission } from './shared/models';
|
|
39
|
+
import { loginSearch } from './lib/signin-errors';
|
|
26
40
|
|
|
27
41
|
/**
|
|
28
42
|
* What coffre's routes read through the router: the API as the visitor
|
|
@@ -73,28 +87,85 @@ export const projects = {
|
|
|
73
87
|
},
|
|
74
88
|
};
|
|
75
89
|
|
|
76
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* `/projects/$project`, the layout of a project's tabs: its header, and the
|
|
92
|
+
* tabs its visitor may open. Each tab is a page under it that reads its own.
|
|
93
|
+
*/
|
|
77
94
|
export const project = {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
95
|
+
loader: ({ context }: Loader<{ project: string }>) => {
|
|
96
|
+
const { coffre, queryClient } = coffreOf(context);
|
|
97
|
+
return queryClient.fetchQuery(queries.projects(coffre));
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/** `/projects/$project/`, its environments, and who can open each when you manage its access. */
|
|
102
|
+
export const projectEnvironments = {
|
|
83
103
|
loader: ({ context, params }: Loader<{ project: string }>) => {
|
|
84
104
|
const { coffre, queryClient } = coffreOf(context);
|
|
85
105
|
return loadProject(queryClient, coffre, params.project);
|
|
86
106
|
},
|
|
87
107
|
};
|
|
88
108
|
|
|
109
|
+
/** `/projects/$project/users`: who holds access, and what others read of it through references. */
|
|
110
|
+
export const projectUsers = {
|
|
111
|
+
loader: async ({ context, params }: Loader<{ project: string }>) => {
|
|
112
|
+
const { coffre, queryClient } = coffreOf(context);
|
|
113
|
+
if (!(await projectTab(context, params.project, 'grant.manage'))) return;
|
|
114
|
+
await Promise.all([
|
|
115
|
+
queryClient.fetchQuery(queries.grants(coffre, params.project)),
|
|
116
|
+
queryClient.fetchQuery(queries.references(coffre, params.project)),
|
|
117
|
+
]);
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/** `/projects/$project/service-accounts`. */
|
|
122
|
+
export const projectServiceAccounts = {
|
|
123
|
+
loader: async ({ context, params }: Loader<{ project: string }>) => {
|
|
124
|
+
const { coffre, queryClient } = coffreOf(context);
|
|
125
|
+
if (await projectTab(context, params.project, 'grant.manage')) await queryClient.fetchQuery(queries.grants(coffre, params.project));
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/** `/projects/$project/settings`: the project itself, which its layout read. */
|
|
130
|
+
export const projectSettings = {
|
|
131
|
+
loader: async ({ context, params }: Loader<{ project: string }>) => {
|
|
132
|
+
await projectTab(context, params.project, 'project.manage');
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Whether a project's tab reads anything: not for a project its visitor
|
|
138
|
+
* cannot see, whose layout shows a closed door instead; and a tab they may
|
|
139
|
+
* not open sends them to the first, so a link someone shared still lands
|
|
140
|
+
* somewhere useful.
|
|
141
|
+
*/
|
|
142
|
+
async function projectTab(context: unknown, slug: string, permission: Permission): Promise<boolean> {
|
|
143
|
+
const { coffre, queryClient } = coffreOf(context);
|
|
144
|
+
const found = projectOf(await queryClient.fetchQuery(queries.projects(coffre)), slug);
|
|
145
|
+
if (!found.ok) return false;
|
|
146
|
+
if (!found.project.permissions.includes(permission)) throw redirect({ to: '/projects/$project', params: { project: slug } });
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
|
|
89
150
|
/** `/projects/$project/$environment`. */
|
|
90
151
|
export const environment = {
|
|
91
152
|
// `?filter=KEY` opens the ledger narrowed to matching keys, for links to one secret.
|
|
92
153
|
validateSearch: (search: Record<string, unknown>): { filter?: string } => ({
|
|
93
154
|
filter: typeof search.filter === 'string' && search.filter !== '' ? search.filter : undefined,
|
|
94
155
|
}),
|
|
95
|
-
loader: ({ context, params }: Loader<{ project: string; environment: string }>) => {
|
|
156
|
+
loader: async ({ context, params }: Loader<{ project: string; environment: string }>) => {
|
|
96
157
|
const { coffre, queryClient } = coffreOf(context);
|
|
97
|
-
|
|
158
|
+
const secrets = await queryClient.fetchQuery(queries.secrets(coffre, params));
|
|
159
|
+
// Then, for whoever reads it, the references that read its secrets from
|
|
160
|
+
// elsewhere and the keys it lacks, rendered with them. Asked only then,
|
|
161
|
+
// so a refused visit is one refusal in the log, not three.
|
|
162
|
+
if (secrets.ok) {
|
|
163
|
+
await Promise.all([
|
|
164
|
+
queryClient.fetchQuery(queries.references(coffre, `${params.project}/${params.environment}`)),
|
|
165
|
+
queryClient.fetchQuery(queries.missing(coffre, params)),
|
|
166
|
+
]);
|
|
167
|
+
}
|
|
168
|
+
return secrets;
|
|
98
169
|
},
|
|
99
170
|
};
|
|
100
171
|
|
|
@@ -104,7 +175,7 @@ export const audit = {
|
|
|
104
175
|
validateSearch: (search: Record<string, unknown>): AuditSearch => ({
|
|
105
176
|
decision: search.decision === 'deny' ? 'deny' : undefined,
|
|
106
177
|
actorId: typeof search.actorId === 'string' && search.actorId !== '' ? search.actorId : undefined,
|
|
107
|
-
detail: search.detail === '1'
|
|
178
|
+
detail: search.detail === '1' ? '1' : undefined,
|
|
108
179
|
}),
|
|
109
180
|
loaderDeps: ({ search }: { search: AuditSearch }) => search,
|
|
110
181
|
// The entries only: the verification is asked for once the page is up
|
|
@@ -115,13 +186,6 @@ export const audit = {
|
|
|
115
186
|
},
|
|
116
187
|
};
|
|
117
188
|
|
|
118
|
-
/** `/access`: the access page became the users page, and old links land there. */
|
|
119
|
-
export const access = {
|
|
120
|
-
beforeLoad: () => {
|
|
121
|
-
throw redirect({ to: '/users' });
|
|
122
|
-
},
|
|
123
|
-
};
|
|
124
|
-
|
|
125
189
|
/** `/users`. */
|
|
126
190
|
export const users = {
|
|
127
191
|
loader: ({ context }: Loader) => {
|
|
@@ -130,38 +194,91 @@ export const users = {
|
|
|
130
194
|
},
|
|
131
195
|
};
|
|
132
196
|
|
|
133
|
-
/** `/users/$user
|
|
197
|
+
/** `/users/$user`, the layout of a user's tabs: who they are to the instance, for owners. */
|
|
134
198
|
export const user = {
|
|
135
199
|
loader: ({ context, params }: Loader<{ user: string }>) => {
|
|
136
200
|
const { coffre, queryClient } = coffreOf(context);
|
|
137
|
-
return
|
|
201
|
+
return loadMember(queryClient, coffre, memberRef('user', params.user));
|
|
138
202
|
},
|
|
139
203
|
};
|
|
140
204
|
|
|
141
|
-
/** `/
|
|
142
|
-
export const
|
|
205
|
+
/** `/users/$user/`, their access on every project where you manage it. */
|
|
206
|
+
export const userAccess = {
|
|
143
207
|
loader: ({ context }: Loader) => {
|
|
144
208
|
const { coffre, queryClient } = coffreOf(context);
|
|
145
|
-
return
|
|
209
|
+
return loadAccess(queryClient, coffre);
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
/** `/users/$user/activity`, for whoever reads the audit log; the others are sent to the first tab. */
|
|
214
|
+
export const userActivity = {
|
|
215
|
+
loader: async ({ context, params }: Loader<{ user: string }>) => {
|
|
216
|
+
const { coffre, queryClient } = coffreOf(context);
|
|
217
|
+
const shell = await loadShell(queryClient, coffre);
|
|
218
|
+
if (!shell.capabilities.canReadAudit) throw redirect({ to: '/users/$user', params });
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
/** `/service-accounts`. */
|
|
223
|
+
export const serviceAccounts = {
|
|
224
|
+
loader: ({ context }: Loader) => {
|
|
225
|
+
const { coffre, queryClient } = coffreOf(context);
|
|
226
|
+
return loadServiceDirectory(queryClient, coffre);
|
|
146
227
|
},
|
|
147
228
|
};
|
|
148
229
|
|
|
149
|
-
/** `/
|
|
150
|
-
export const
|
|
151
|
-
loader: ({ context, params }: Loader<{
|
|
230
|
+
/** `/service-accounts/$account`, the layout of a service account's tabs: who it is to the instance, for owners. */
|
|
231
|
+
export const serviceAccount = {
|
|
232
|
+
loader: ({ context, params }: Loader<{ account: string }>) => {
|
|
152
233
|
const { coffre, queryClient } = coffreOf(context);
|
|
153
|
-
return
|
|
234
|
+
return loadMember(queryClient, coffre, memberRef('service', params.account));
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* `/service-accounts/$account/`, how it signs in: its trusted workloads and
|
|
240
|
+
* bearer tokens. Only an owner manages them, and only while it is active;
|
|
241
|
+
* anyone else is sent to its access.
|
|
242
|
+
*/
|
|
243
|
+
export const serviceAccountSignIn = {
|
|
244
|
+
loader: async ({ context, params }: Loader<{ account: string }>) => {
|
|
245
|
+
const { coffre, queryClient } = coffreOf(context);
|
|
246
|
+
const member = memberRef('service', params.account);
|
|
247
|
+
const [shell, report] = await Promise.all([loadShell(queryClient, coffre), loadMember(queryClient, coffre, member)]);
|
|
248
|
+
const ways = signInWays(shell, report);
|
|
249
|
+
if (ways === null) throw redirect({ to: '/service-accounts/$account/access', params });
|
|
250
|
+
await Promise.all([
|
|
251
|
+
queryClient.fetchQuery(queries.credentials(coffre, member, ways.tokens)),
|
|
252
|
+
queryClient.fetchQuery(queries.bindings(coffre, member, ways.workloads)),
|
|
253
|
+
]);
|
|
254
|
+
},
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
/** `/service-accounts/$account/access`. */
|
|
258
|
+
export const serviceAccountAccess = {
|
|
259
|
+
loader: ({ context }: Loader) => {
|
|
260
|
+
const { coffre, queryClient } = coffreOf(context);
|
|
261
|
+
return loadAccess(queryClient, coffre);
|
|
262
|
+
},
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
/** `/service-accounts/$account/activity`, as a user's. */
|
|
266
|
+
export const serviceAccountActivity = {
|
|
267
|
+
loader: async ({ context, params }: Loader<{ account: string }>) => {
|
|
268
|
+
const { coffre, queryClient } = coffreOf(context);
|
|
269
|
+
const shell = await loadShell(queryClient, coffre);
|
|
270
|
+
if (!shell.capabilities.canReadAudit) throw redirect({ to: '/service-accounts/$account', params });
|
|
154
271
|
},
|
|
155
272
|
};
|
|
156
273
|
|
|
157
274
|
/** `/settings`. */
|
|
158
275
|
export const settings = {
|
|
159
|
-
// Instance facts come from the directory, which only
|
|
160
|
-
// Asking on everyone's behalf would write a refusal to the
|
|
161
|
-
// every user who opens the page, so
|
|
276
|
+
// Instance facts come from the directory and the key checks, which only
|
|
277
|
+
// owners may read. Asking on everyone's behalf would write a refusal to the
|
|
278
|
+
// audit log for every user who opens the page, so they are only asked for them.
|
|
162
279
|
loader: ({ context }: Loader) => {
|
|
163
280
|
const { coffre, queryClient } = coffreOf(context);
|
|
164
|
-
return
|
|
281
|
+
return loadSettings(queryClient, coffre);
|
|
165
282
|
},
|
|
166
283
|
};
|
|
167
284
|
|
|
@@ -191,15 +308,8 @@ export const account = {
|
|
|
191
308
|
|
|
192
309
|
/** `/login`. */
|
|
193
310
|
export const login = {
|
|
194
|
-
// Where to resume after signing in
|
|
195
|
-
|
|
196
|
-
validateSearch: (search: Record<string, unknown>): { next?: string; error?: string } => {
|
|
197
|
-
const out: { next?: string; error?: string } = {};
|
|
198
|
-
const { next, error } = search;
|
|
199
|
-
if (typeof next === 'string' && next.startsWith('/') && !next.startsWith('//')) out.next = next;
|
|
200
|
-
if (typeof error === 'string' && /^[a-z_]{1,40}$/.test(error)) out.error = error;
|
|
201
|
-
return out;
|
|
202
|
-
},
|
|
311
|
+
// Where to resume after signing in, and the sign-in's error, shown once (`loginSearch`).
|
|
312
|
+
validateSearch: loginSearch,
|
|
203
313
|
loader: async ({ context }: Loader) => {
|
|
204
314
|
const { coffre, queryClient } = coffreOf(context);
|
|
205
315
|
const shell = await loadShell(queryClient, coffre);
|
|
@@ -238,3 +348,38 @@ export const deviceLogin = {
|
|
|
238
348
|
return uiResult(() => coffre.deviceLogins.get(code));
|
|
239
349
|
},
|
|
240
350
|
};
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* `/approvals/$approval`: a change an MCP client asked for, which its person
|
|
354
|
+
* decides here. Its own read: the page shows what the change would do now.
|
|
355
|
+
*/
|
|
356
|
+
export const approval = {
|
|
357
|
+
loader: async ({ context, params, location }: Loader<{ approval: string }>) => {
|
|
358
|
+
const { coffre, queryClient } = coffreOf(context);
|
|
359
|
+
const shell = await loadShell(queryClient, coffre);
|
|
360
|
+
if (shell.registrationRequired) throw redirect({ to: '/unregistered' });
|
|
361
|
+
if (shell.principal === null) throw redirect({ to: '/login', search: { next: location.href } });
|
|
362
|
+
return uiResult(() => coffre.approvals.get(params.approval));
|
|
363
|
+
},
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
type AuthorizationSearch = RouteInput<'GET /oauth/authorizations'>;
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* `/oauth/authorize`: an MCP client asking to connect. Its parameters go to
|
|
370
|
+
* the API as sent, which says which it takes; the router keeps them strings,
|
|
371
|
+
* so a `state` of `1e5` goes back as `1e5`.
|
|
372
|
+
*/
|
|
373
|
+
export const oauthAuthorize = {
|
|
374
|
+
validateSearch: (search: Record<string, unknown>): AuthorizationSearch => stringsOf(search),
|
|
375
|
+
loaderDeps: ({ search }: { search: AuthorizationSearch }) => ({ request: search }),
|
|
376
|
+
// Its own read, as the device login's: every authorization is checked afresh.
|
|
377
|
+
loader: async ({ context, deps, location }: Loader & { deps: { request: AuthorizationSearch } }) => {
|
|
378
|
+
const { coffre, queryClient } = coffreOf(context);
|
|
379
|
+
const shell = await loadShell(queryClient, coffre);
|
|
380
|
+
if (shell.registrationRequired) throw redirect({ to: '/unregistered' });
|
|
381
|
+
if (shell.principal === null) throw redirect({ to: '/login', search: { next: location.href } });
|
|
382
|
+
const { request } = deps;
|
|
383
|
+
return { request, email: shell.principal.id, result: await uiResult(() => coffre.oauth.describe(request)) };
|
|
384
|
+
},
|
|
385
|
+
};
|