@coffre/conformance 0.1.4 → 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 +20 -9
- package/package.json +3 -3
- package/src/checks/canaries.ts +15 -7
package/dist/main.js
CHANGED
|
@@ -2437,17 +2437,28 @@ async function canaryScan(deployment, people, canaries) {
|
|
|
2437
2437
|
["the leaver's CLI, removed", token(people.leaver.cliToken)],
|
|
2438
2438
|
["the service, removed", token(people.service.token)]
|
|
2439
2439
|
];
|
|
2440
|
-
|
|
2440
|
+
const reads = [];
|
|
2441
2441
|
const routes = calls(people);
|
|
2442
|
-
for (const { key, url } of getUrls(deployment.origin, routes)) for (const [name, fetchAs] of callers) {
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
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
|
+
});
|
|
2446
2447
|
const paths = pages(people);
|
|
2447
|
-
for (const path of paths) for (const [name, fetchAs] of callers.slice(0, 1 + Object.keys(browsers).length)) {
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
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;
|
|
2451
2462
|
const stored = [];
|
|
2452
2463
|
await using(deployment.database(), async (sql) => {
|
|
2453
2464
|
const names = await tables(sql);
|
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) => {
|