@coffre/conformance 0.1.2 → 0.1.4
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 +33 -11
- package/package.json +3 -3
- package/src/checks/checkpoints.ts +2 -2
- package/src/checks/people.ts +14 -0
- package/src/fixtures.ts +3 -3
- package/src/harness.ts +7 -7
- package/src/suite.ts +2 -1
package/dist/main.js
CHANGED
|
@@ -824,9 +824,9 @@ async function using(open, use) {
|
|
|
824
824
|
//#endregion
|
|
825
825
|
//#region src/fixtures.ts
|
|
826
826
|
const KEYS = {
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
827
|
+
VAULT_KEY_ID: "vault-conformance-1",
|
|
828
|
+
VAULT_KEY: "Y29mZnJlLWxvY2FsLWRldi1rZWstMzItYnl0ZXMhISE=",
|
|
829
|
+
APP_KEY: "Y29mZnJlLWxvY2FsLWF1ZGl0LWNoYWluLWtleS0zMmI="
|
|
830
830
|
};
|
|
831
831
|
//#endregion
|
|
832
832
|
//#region src/harness.ts
|
|
@@ -964,9 +964,9 @@ async function boot(kind, at, options) {
|
|
|
964
964
|
PUBLIC_URL: origin,
|
|
965
965
|
GITHUB_CLIENT_ID: github.GITHUB_CLIENT_ID,
|
|
966
966
|
GITHUB_CLIENT_SECRET: github.GITHUB_CLIENT_SECRET,
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
967
|
+
APP_KEY: KEYS.APP_KEY,
|
|
968
|
+
VAULT_KEY_ID: KEYS.VAULT_KEY_ID,
|
|
969
|
+
VAULT_KEY: KEYS.VAULT_KEY,
|
|
970
970
|
ROOT_ADMINS: ROOT_ADMIN,
|
|
971
971
|
CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE: runtime,
|
|
972
972
|
CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_VAULT_HYPERDRIVE: vaultRuntime,
|
|
@@ -997,8 +997,8 @@ async function boot(kind, at, options) {
|
|
|
997
997
|
start("vault", process.execPath, ["src/vault.ts"], {
|
|
998
998
|
VAULT_SOCKET: socket,
|
|
999
999
|
DATABASE_URL: `file:${database}`,
|
|
1000
|
-
|
|
1001
|
-
|
|
1000
|
+
VAULT_KEY_ID: KEYS.VAULT_KEY_ID,
|
|
1001
|
+
VAULT_KEY: KEYS.VAULT_KEY,
|
|
1002
1002
|
ROOT_ADMINS: ROOT_ADMIN
|
|
1003
1003
|
});
|
|
1004
1004
|
await until("the vault socket", async () => existsSync(socket), 30, alive);
|
|
@@ -1007,7 +1007,7 @@ async function boot(kind, at, options) {
|
|
|
1007
1007
|
PUBLIC_URL: origin,
|
|
1008
1008
|
DATABASE_URL: `file:${database}`,
|
|
1009
1009
|
VAULT_SOCKET: socket,
|
|
1010
|
-
|
|
1010
|
+
APP_KEY: KEYS.APP_KEY,
|
|
1011
1011
|
...github
|
|
1012
1012
|
});
|
|
1013
1013
|
let server = startServer();
|
|
@@ -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 = [
|
|
@@ -2089,14 +2110,14 @@ async function earlierCheckpoint(deployment, { admin }) {
|
|
|
2089
2110
|
const signed = rows.filter((row) => row.author === "vault" && row.action === "audit.checkpoint" && row.decision === "allow");
|
|
2090
2111
|
expect(signed.length >= 2, "two checkpoints are needed");
|
|
2091
2112
|
const [head] = await sql.query("SELECT * FROM audit_chain_head");
|
|
2092
|
-
const seed = Buffer.from(hkdfSync("sha256", Buffer.from(KEYS.
|
|
2113
|
+
const seed = Buffer.from(hkdfSync("sha256", Buffer.from(KEYS.VAULT_KEY, "base64"), Buffer.alloc(0), "coffre.vault.signing-key.v1", 32));
|
|
2093
2114
|
const signingKey = createPrivateKey({
|
|
2094
2115
|
key: Buffer.concat([Buffer.from("302e020100300506032b657004220420", "hex"), seed]),
|
|
2095
2116
|
format: "der",
|
|
2096
2117
|
type: "pkcs8"
|
|
2097
2118
|
});
|
|
2098
2119
|
const keys = {
|
|
2099
|
-
app: Buffer.from(hkdfSync("sha256", Buffer.from(KEYS.
|
|
2120
|
+
app: Buffer.from(hkdfSync("sha256", Buffer.from(KEYS.APP_KEY, "base64"), Buffer.alloc(0), "coffre.audit.app.v2", 32)),
|
|
2100
2121
|
vault: Buffer.from(hkdfSync("sha256", seed, Buffer.alloc(0), "coffre.audit.vault.v2", 32))
|
|
2101
2122
|
};
|
|
2102
2123
|
const hashes = /* @__PURE__ */ new Map();
|
|
@@ -2467,6 +2488,7 @@ async function conform(deployment, options) {
|
|
|
2467
2488
|
await report.check("health", {}, () => health(deployment));
|
|
2468
2489
|
await anonymousChecks(report, deployment.origin, { health: false });
|
|
2469
2490
|
const admin = await report.check("sign-in", {}, () => signInAdmin(deployment));
|
|
2491
|
+
await report.check("page load", { admin }, ({ admin }) => pageLoad(admin));
|
|
2470
2492
|
const canaries = await report.check("setup", { admin }, ({ admin }) => setUp(admin));
|
|
2471
2493
|
const people = await report.check("personas", {
|
|
2472
2494
|
admin,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coffre/conformance",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
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.4"
|
|
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.4"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "tsdown",
|
|
@@ -18,10 +18,10 @@ export async function earlierCheckpoint(deployment: Deployment, { admin }: Peopl
|
|
|
18
18
|
expect(signed.length >= 2, 'two checkpoints are needed');
|
|
19
19
|
const [head] = await sql.query('SELECT * FROM audit_chain_head');
|
|
20
20
|
// The vault's signing key, which it derives from its KEK: HKDF-SHA-256 under the vault's label.
|
|
21
|
-
const seed = Buffer.from(hkdfSync('sha256', Buffer.from(KEYS.
|
|
21
|
+
const seed = Buffer.from(hkdfSync('sha256', Buffer.from(KEYS.VAULT_KEY, 'base64'), Buffer.alloc(0), 'coffre.vault.signing-key.v1', 32));
|
|
22
22
|
const signingKey = createPrivateKey({ key: Buffer.concat([Buffer.from('302e020100300506032b657004220420', 'hex'), seed]), format: 'der', type: 'pkcs8' });
|
|
23
23
|
const keys = {
|
|
24
|
-
app: Buffer.from(hkdfSync('sha256', Buffer.from(KEYS.
|
|
24
|
+
app: Buffer.from(hkdfSync('sha256', Buffer.from(KEYS.APP_KEY, 'base64'), Buffer.alloc(0), 'coffre.audit.app.v2', 32)),
|
|
25
25
|
vault: Buffer.from(hkdfSync('sha256', seed, Buffer.alloc(0), 'coffre.audit.vault.v2', 32)),
|
|
26
26
|
};
|
|
27
27
|
const hashes = new Map<bigint, string>();
|
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/fixtures.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// The vault derives its signing key from the KEK, as every deployment with
|
|
3
3
|
// a local KEK does.
|
|
4
4
|
export const KEYS = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
VAULT_KEY_ID: 'vault-conformance-1',
|
|
6
|
+
VAULT_KEY: 'Y29mZnJlLWxvY2FsLWRldi1rZWstMzItYnl0ZXMhISE=',
|
|
7
|
+
APP_KEY: 'Y29mZnJlLWxvY2FsLWF1ZGl0LWNoYWluLWtleS0zMmI=',
|
|
8
8
|
};
|
package/src/harness.ts
CHANGED
|
@@ -187,13 +187,13 @@ export async function boot(kind: Kind, at: string, options: HarnessOptions): Pro
|
|
|
187
187
|
...['--var', `GITHUB_URL:${github.GITHUB_URL}`, '--var', `GITHUB_API_URL:${github.GITHUB_API_URL}`],
|
|
188
188
|
], {
|
|
189
189
|
// Wrangler hands each Worker the vars and secrets its own
|
|
190
|
-
// wrangler.jsonc declares, from here: the app never sees
|
|
190
|
+
// wrangler.jsonc declares, from here: the app never sees the vault key.
|
|
191
191
|
PUBLIC_URL: origin,
|
|
192
192
|
GITHUB_CLIENT_ID: github.GITHUB_CLIENT_ID,
|
|
193
193
|
GITHUB_CLIENT_SECRET: github.GITHUB_CLIENT_SECRET,
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
194
|
+
APP_KEY: KEYS.APP_KEY,
|
|
195
|
+
VAULT_KEY_ID: KEYS.VAULT_KEY_ID,
|
|
196
|
+
VAULT_KEY: KEYS.VAULT_KEY,
|
|
197
197
|
ROOT_ADMINS: ROOT_ADMIN,
|
|
198
198
|
CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE: runtime,
|
|
199
199
|
CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_VAULT_HYPERDRIVE: vaultRuntime,
|
|
@@ -225,8 +225,8 @@ export async function boot(kind: Kind, at: string, options: HarnessOptions): Pro
|
|
|
225
225
|
start('vault', process.execPath, ['src/vault.ts'], {
|
|
226
226
|
VAULT_SOCKET: socket,
|
|
227
227
|
DATABASE_URL: `file:${database}`,
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
VAULT_KEY_ID: KEYS.VAULT_KEY_ID,
|
|
229
|
+
VAULT_KEY: KEYS.VAULT_KEY,
|
|
230
230
|
ROOT_ADMINS: ROOT_ADMIN,
|
|
231
231
|
});
|
|
232
232
|
await until('the vault socket', async () => existsSync(socket), 30, alive);
|
|
@@ -236,7 +236,7 @@ export async function boot(kind: Kind, at: string, options: HarnessOptions): Pro
|
|
|
236
236
|
PUBLIC_URL: origin,
|
|
237
237
|
DATABASE_URL: `file:${database}`,
|
|
238
238
|
VAULT_SOCKET: socket,
|
|
239
|
-
|
|
239
|
+
APP_KEY: KEYS.APP_KEY,
|
|
240
240
|
...github,
|
|
241
241
|
});
|
|
242
242
|
let server = startServer();
|
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 };
|