@coffre/conformance 0.1.0 → 0.1.2

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 CHANGED
@@ -8,6 +8,7 @@ import { existsSync, mkdtempSync, readFileSync, rmSync } from "node:fs";
8
8
  import { tmpdir } from "node:os";
9
9
  import { DatabaseSync } from "node:sqlite";
10
10
  import pg from "pg";
11
+ import { postgresConnection } from "@coffre/db/connect";
11
12
  //#region ../client/dist/index.js
12
13
  /** The API's error shape, `{ error, message }`, with the HTTP status. */
13
14
  const COFFRE_ERROR = Symbol.for("@coffre/client:CoffreError");
@@ -793,7 +794,7 @@ function sameKeys(value, keys) {
793
794
  //#endregion
794
795
  //#region src/database.ts
795
796
  async function postgres(url) {
796
- const client = new pg.Client(url);
797
+ const client = new pg.Client(postgresConnection(url));
797
798
  await client.connect();
798
799
  return {
799
800
  engine: "postgres",
@@ -825,7 +826,6 @@ async function using(open, use) {
825
826
  const KEYS = {
826
827
  KEK_ID: "conformance-1",
827
828
  KEK: "Y29mZnJlLWxvY2FsLWRldi1rZWstMzItYnl0ZXMhISE=",
828
- SIGNING_KEY: "Y29mZnJlLWxvY2FsLXZhdWx0LXNpZ25pbmctc2VlZCE=",
829
829
  AUDIT_CHAIN_KEY: "Y29mZnJlLWxvY2FsLWF1ZGl0LWNoYWluLWtleS0zMmI="
830
830
  };
831
831
  //#endregion
@@ -967,7 +967,6 @@ async function boot(kind, at, options) {
967
967
  AUDIT_CHAIN_KEY: KEYS.AUDIT_CHAIN_KEY,
968
968
  KEK_ID: KEYS.KEK_ID,
969
969
  KEK: KEYS.KEK,
970
- SIGNING_KEY: KEYS.SIGNING_KEY,
971
970
  ROOT_ADMINS: ROOT_ADMIN,
972
971
  CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE: runtime,
973
972
  CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_VAULT_HYPERDRIVE: vaultRuntime,
@@ -1000,7 +999,6 @@ async function boot(kind, at, options) {
1000
999
  DATABASE_URL: `file:${database}`,
1001
1000
  KEK_ID: KEYS.KEK_ID,
1002
1001
  KEK: KEYS.KEK,
1003
- SIGNING_KEY: KEYS.SIGNING_KEY,
1004
1002
  ROOT_ADMINS: ROOT_ADMIN
1005
1003
  });
1006
1004
  await until("the vault socket", async () => existsSync(socket), 30, alive);
@@ -2091,7 +2089,7 @@ async function earlierCheckpoint(deployment, { admin }) {
2091
2089
  const signed = rows.filter((row) => row.author === "vault" && row.action === "audit.checkpoint" && row.decision === "allow");
2092
2090
  expect(signed.length >= 2, "two checkpoints are needed");
2093
2091
  const [head] = await sql.query("SELECT * FROM audit_chain_head");
2094
- const seed = Buffer.from(KEYS.SIGNING_KEY, "base64");
2092
+ const seed = Buffer.from(hkdfSync("sha256", Buffer.from(KEYS.KEK, "base64"), Buffer.alloc(0), "coffre.vault.signing-key.v1", 32));
2095
2093
  const signingKey = createPrivateKey({
2096
2094
  key: Buffer.concat([Buffer.from("302e020100300506032b657004220420", "hex"), seed]),
2097
2095
  format: "der",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coffre/conformance",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
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": {
@@ -30,7 +30,8 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "jose": "6.2.3",
33
- "pg": "8.16.3"
33
+ "pg": "8.16.3",
34
+ "@coffre/db": "0.1.2"
34
35
  },
35
36
  "devDependencies": {
36
37
  "@types/node": "26.1.1",
@@ -38,7 +39,7 @@
38
39
  "oauth4webapi": "3.8.8",
39
40
  "tsdown": "0.23.0",
40
41
  "typescript": "5.9.3",
41
- "@coffre/client": "0.1.0"
42
+ "@coffre/client": "0.1.2"
42
43
  },
43
44
  "scripts": {
44
45
  "build": "tsdown",
@@ -17,7 +17,8 @@ export async function earlierCheckpoint(deployment: Deployment, { admin }: Peopl
17
17
  const signed = rows.filter((row) => row.author === 'vault' && row.action === 'audit.checkpoint' && row.decision === 'allow');
18
18
  expect(signed.length >= 2, 'two checkpoints are needed');
19
19
  const [head] = await sql.query('SELECT * FROM audit_chain_head');
20
- const seed = Buffer.from(KEYS.SIGNING_KEY, 'base64');
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.KEK, 'base64'), Buffer.alloc(0), 'coffre.vault.signing-key.v1', 32));
21
22
  const signingKey = createPrivateKey({ key: Buffer.concat([Buffer.from('302e020100300506032b657004220420', 'hex'), seed]), format: 'der', type: 'pkcs8' });
22
23
  const keys = {
23
24
  app: Buffer.from(hkdfSync('sha256', Buffer.from(KEYS.AUDIT_CHAIN_KEY, 'base64'), Buffer.alloc(0), 'coffre.audit.app.v2', 32)),
package/src/database.ts CHANGED
@@ -4,6 +4,7 @@
4
4
  import { DatabaseSync } from 'node:sqlite';
5
5
 
6
6
  import pg from 'pg';
7
+ import { postgresConnection } from '@coffre/db/connect';
7
8
 
8
9
  export type Sql = {
9
10
  readonly engine: 'postgres' | 'sqlite';
@@ -15,7 +16,7 @@ export type Sql = {
15
16
  };
16
17
 
17
18
  export async function postgres(url: string): Promise<Sql> {
18
- const client = new pg.Client(url);
19
+ const client = new pg.Client(postgresConnection(url));
19
20
  await client.connect();
20
21
  return {
21
22
  engine: 'postgres',
package/src/fixtures.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  // Local fixtures, as in .env.dev: none of them is a secret anywhere else.
2
+ // The vault derives its signing key from the KEK, as every deployment with
3
+ // a local KEK does.
2
4
  export const KEYS = {
3
5
  KEK_ID: 'conformance-1',
4
6
  KEK: 'Y29mZnJlLWxvY2FsLWRldi1rZWstMzItYnl0ZXMhISE=',
5
- SIGNING_KEY: 'Y29mZnJlLWxvY2FsLXZhdWx0LXNpZ25pbmctc2VlZCE=',
6
7
  AUDIT_CHAIN_KEY: 'Y29mZnJlLWxvY2FsLWF1ZGl0LWNoYWluLWtleS0zMmI=',
7
8
  };
package/src/harness.ts CHANGED
@@ -194,7 +194,6 @@ export async function boot(kind: Kind, at: string, options: HarnessOptions): Pro
194
194
  AUDIT_CHAIN_KEY: KEYS.AUDIT_CHAIN_KEY,
195
195
  KEK_ID: KEYS.KEK_ID,
196
196
  KEK: KEYS.KEK,
197
- SIGNING_KEY: KEYS.SIGNING_KEY,
198
197
  ROOT_ADMINS: ROOT_ADMIN,
199
198
  CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE: runtime,
200
199
  CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_VAULT_HYPERDRIVE: vaultRuntime,
@@ -228,7 +227,6 @@ export async function boot(kind: Kind, at: string, options: HarnessOptions): Pro
228
227
  DATABASE_URL: `file:${database}`,
229
228
  KEK_ID: KEYS.KEK_ID,
230
229
  KEK: KEYS.KEK,
231
- SIGNING_KEY: KEYS.SIGNING_KEY,
232
230
  ROOT_ADMINS: ROOT_ADMIN,
233
231
  });
234
232
  await until('the vault socket', async () => existsSync(socket), 30, alive);