@coffre/conformance 0.1.3 → 0.1.5
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/main.js +42 -9
- package/package.json +3 -3
- package/src/checks/canaries.ts +15 -7
- package/src/checks/people.ts +14 -0
- package/src/suite.ts +2 -1
package/dist/main.js
CHANGED
|
@@ -1219,6 +1219,27 @@ async function deviceLogin(deployment, browser) {
|
|
|
1219
1219
|
expect(polled.ok && session.access_token, `the approved device login gave no token: ${polled.status}`, session);
|
|
1220
1220
|
return session.access_token;
|
|
1221
1221
|
}
|
|
1222
|
+
/**
|
|
1223
|
+
* A page's worth of API calls at once, as the pages fire them on a load,
|
|
1224
|
+
* right after sign-in, while the vault is fresh: every one answers. A call
|
|
1225
|
+
* that waited on another's work in the vault would be cancelled on
|
|
1226
|
+
* Cloudflare as hung, and the page would read the 503 or 401 as signed out.
|
|
1227
|
+
*/
|
|
1228
|
+
async function pageLoad(person) {
|
|
1229
|
+
const paths = [
|
|
1230
|
+
"/api/me",
|
|
1231
|
+
"/api/sessions",
|
|
1232
|
+
"/api/projects",
|
|
1233
|
+
"/api/members",
|
|
1234
|
+
"/api/audit",
|
|
1235
|
+
"/api/identities",
|
|
1236
|
+
"/api/me",
|
|
1237
|
+
"/api/projects"
|
|
1238
|
+
];
|
|
1239
|
+
const failed = (await Promise.all(paths.map(async (path) => [path, (await person.browser.fetch(path)).status]))).filter(([, status]) => status !== 200);
|
|
1240
|
+
expect(failed.length === 0, "a call of the page load did not answer 200", failed.map(([path, status]) => `${path}: ${status}`).join(", "));
|
|
1241
|
+
return `${paths.length} calls at once, each answered`;
|
|
1242
|
+
}
|
|
1222
1243
|
//#endregion
|
|
1223
1244
|
//#region src/checks/storage.ts
|
|
1224
1245
|
const TABLES = [
|
|
@@ -2416,17 +2437,28 @@ async function canaryScan(deployment, people, canaries) {
|
|
|
2416
2437
|
["the leaver's CLI, removed", token(people.leaver.cliToken)],
|
|
2417
2438
|
["the service, removed", token(people.service.token)]
|
|
2418
2439
|
];
|
|
2419
|
-
|
|
2440
|
+
const reads = [];
|
|
2420
2441
|
const routes = calls(people);
|
|
2421
|
-
for (const { key, url } of getUrls(deployment.origin, routes)) for (const [name, fetchAs] of callers) {
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2442
|
+
for (const { key, url } of getUrls(deployment.origin, routes)) for (const [name, fetchAs] of callers) reads.push({
|
|
2443
|
+
where: `${key} as ${name}`,
|
|
2444
|
+
url,
|
|
2445
|
+
fetchAs
|
|
2446
|
+
});
|
|
2425
2447
|
const paths = pages(people);
|
|
2426
|
-
for (const path of paths) for (const [name, fetchAs] of callers.slice(0, 1 + Object.keys(browsers).length)) {
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2448
|
+
for (const path of paths) for (const [name, fetchAs] of callers.slice(0, 1 + Object.keys(browsers).length)) reads.push({
|
|
2449
|
+
where: `the page ${path} as ${name}`,
|
|
2450
|
+
url: `${deployment.origin}${path}`,
|
|
2451
|
+
fetchAs
|
|
2452
|
+
});
|
|
2453
|
+
let next = 0;
|
|
2454
|
+
const workers = await Promise.allSettled(Array.from({ length: 4 }, async () => {
|
|
2455
|
+
while (next < reads.length) {
|
|
2456
|
+
const { where, url, fetchAs } = reads[next++];
|
|
2457
|
+
look(where, await (await fetchAs(url)).text());
|
|
2458
|
+
}
|
|
2459
|
+
}));
|
|
2460
|
+
for (const worker of workers) if (worker.status === "rejected") throw worker.reason;
|
|
2461
|
+
const answers = reads.length;
|
|
2430
2462
|
const stored = [];
|
|
2431
2463
|
await using(deployment.database(), async (sql) => {
|
|
2432
2464
|
const names = await tables(sql);
|
|
@@ -2467,6 +2499,7 @@ async function conform(deployment, options) {
|
|
|
2467
2499
|
await report.check("health", {}, () => health(deployment));
|
|
2468
2500
|
await anonymousChecks(report, deployment.origin, { health: false });
|
|
2469
2501
|
const admin = await report.check("sign-in", {}, () => signInAdmin(deployment));
|
|
2502
|
+
await report.check("page load", { admin }, ({ admin }) => pageLoad(admin));
|
|
2470
2503
|
const canaries = await report.check("setup", { admin }, ({ admin }) => setUp(admin));
|
|
2471
2504
|
const people = await report.check("personas", {
|
|
2472
2505
|
admin,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coffre/conformance",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Checks a coffre deployment from outside: what it must never do, whatever code it runs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"jose": "6.2.3",
|
|
33
33
|
"pg": "8.16.3",
|
|
34
|
-
"@coffre/db": "0.1.
|
|
34
|
+
"@coffre/db": "0.1.5"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/node": "26.1.1",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"oauth4webapi": "3.8.8",
|
|
40
40
|
"tsdown": "0.23.0",
|
|
41
41
|
"typescript": "5.9.3",
|
|
42
|
-
"@coffre/client": "0.1.
|
|
42
|
+
"@coffre/client": "0.1.5"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "tsdown",
|
package/src/checks/canaries.ts
CHANGED
|
@@ -68,21 +68,29 @@ export async function canaryScan(deployment: Deployment, people: People, canarie
|
|
|
68
68
|
['the service, removed', token(people.service.token)],
|
|
69
69
|
];
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
// These GETs are independent. Keep every route/caller pair, with a small
|
|
72
|
+
// number in flight so latency does not add up across all 320 answers.
|
|
73
|
+
const reads: { where: string; url: string; fetchAs: (url: string) => Promise<Response> }[] = [];
|
|
72
74
|
const routes = calls(people);
|
|
73
75
|
for (const { key, url } of getUrls(deployment.origin, routes)) {
|
|
74
|
-
for (const [name, fetchAs] of callers) {
|
|
75
|
-
look(`${key} as ${name}`, await (await fetchAs(url)).text());
|
|
76
|
-
answers++;
|
|
77
|
-
}
|
|
76
|
+
for (const [name, fetchAs] of callers) reads.push({ where: `${key} as ${name}`, url, fetchAs });
|
|
78
77
|
}
|
|
79
78
|
const paths = pages(people);
|
|
80
79
|
for (const path of paths) {
|
|
81
80
|
for (const [name, fetchAs] of callers.slice(0, 1 + Object.keys(browsers).length)) {
|
|
82
|
-
|
|
83
|
-
answers++;
|
|
81
|
+
reads.push({ where: `the page ${path} as ${name}`, url: `${deployment.origin}${path}`, fetchAs });
|
|
84
82
|
}
|
|
85
83
|
}
|
|
84
|
+
let next = 0;
|
|
85
|
+
const workers = await Promise.allSettled(Array.from({ length: 4 }, async () => {
|
|
86
|
+
while (next < reads.length) {
|
|
87
|
+
const { where, url, fetchAs } = reads[next++]!;
|
|
88
|
+
look(where, await (await fetchAs(url)).text());
|
|
89
|
+
}
|
|
90
|
+
}));
|
|
91
|
+
// Drain in-flight reads even on an error: none may overlap the next check.
|
|
92
|
+
for (const worker of workers) if (worker.status === 'rejected') throw worker.reason;
|
|
93
|
+
const answers = reads.length;
|
|
86
94
|
|
|
87
95
|
const stored: string[] = [];
|
|
88
96
|
await using(deployment.database(), async (sql) => {
|
package/src/checks/people.ts
CHANGED
|
@@ -184,3 +184,17 @@ async function deviceLogin(deployment: Deployment, browser: Browser): Promise<st
|
|
|
184
184
|
expect(polled.ok && session.access_token, `the approved device login gave no token: ${polled.status}`, session);
|
|
185
185
|
return session.access_token;
|
|
186
186
|
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* A page's worth of API calls at once, as the pages fire them on a load,
|
|
190
|
+
* right after sign-in, while the vault is fresh: every one answers. A call
|
|
191
|
+
* that waited on another's work in the vault would be cancelled on
|
|
192
|
+
* Cloudflare as hung, and the page would read the 503 or 401 as signed out.
|
|
193
|
+
*/
|
|
194
|
+
export async function pageLoad(person: Person): Promise<string> {
|
|
195
|
+
const paths = ['/api/me', '/api/sessions', '/api/projects', '/api/members', '/api/audit', '/api/identities', '/api/me', '/api/projects'];
|
|
196
|
+
const statuses = await Promise.all(paths.map(async (path) => [path, (await person.browser.fetch(path)).status] as const));
|
|
197
|
+
const failed = statuses.filter(([, status]) => status !== 200);
|
|
198
|
+
expect(failed.length === 0, 'a call of the page load did not answer 200', failed.map(([path, status]) => `${path}: ${status}`).join(', '));
|
|
199
|
+
return `${paths.length} calls at once, each answered`;
|
|
200
|
+
}
|
package/src/suite.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { refusedCheckpoint, missingCheckpoint, middleCut } from './checks/readin
|
|
|
12
12
|
import { editedGeneration, forgedCredential, forgedIdentity, forgedApproval } from './checks/signin.ts';
|
|
13
13
|
import { canaryScan } from './checks/canaries.ts';
|
|
14
14
|
import { anonymousChecks, tokenChecks, type Canary } from './checks/live.ts';
|
|
15
|
-
import { personas, setUp, setUpLive, signInAdmin } from './checks/people.ts';
|
|
15
|
+
import { pageLoad, personas, setUp, setUpLive, signInAdmin } from './checks/people.ts';
|
|
16
16
|
import { health } from './checks/surface.ts';
|
|
17
17
|
|
|
18
18
|
/** The names of the checks that failed. */
|
|
@@ -24,6 +24,7 @@ export async function conform(deployment: Deployment, options: { bulkLimit: numb
|
|
|
24
24
|
// database and processes.
|
|
25
25
|
await anonymousChecks(report, deployment.origin, { health: false });
|
|
26
26
|
const admin = await report.check('sign-in', {}, () => signInAdmin(deployment));
|
|
27
|
+
await report.check('page load', { admin }, ({ admin }) => pageLoad(admin));
|
|
27
28
|
const canaries = await report.check('setup', { admin }, ({ admin }) => setUp(admin));
|
|
28
29
|
const people = await report.check('personas', { admin, canaries }, ({ admin }) => personas(deployment, admin));
|
|
29
30
|
const all = { people, canaries };
|