@coffre/conformance 0.4.4 → 0.4.6

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
@@ -1270,7 +1270,7 @@ async function mcpRead(deployment, people, canaries) {
1270
1270
  const listed = await modern(deployment, access, "tools/list");
1271
1271
  const result = listed.body.result;
1272
1272
  const names = result?.tools?.map((tool) => tool.name) ?? [];
1273
- expect(names.includes("list_secrets") && names.includes("run_with_secrets") && !names.includes("admit_member") && result?.cacheScope === "private" && typeof result.ttlMs === "number" && result.ttlMs <= 6e5, "tools/list does not list the reader's tools alone, cached for them only and briefly", listed.body);
1273
+ expect(names.includes("list_secrets") && !names.includes("run_with_secrets") && !names.includes("admit_member") && result?.cacheScope === "private" && typeof result.ttlMs === "number" && result.ttlMs <= 6e5, "tools/list does not list the reader's tools alone, cached for them only and briefly", listed.body);
1274
1274
  const callTool = async (tool, args) => {
1275
1275
  const { response, body } = await modern(deployment, access, "tools/call", {
1276
1276
  name: tool,
@@ -1284,11 +1284,6 @@ async function mcpRead(deployment, people, canaries) {
1284
1284
  expect(["API_KEY", "DATABASE_URL"].every((key) => keys.includes(key)), `list_secrets on ${DEV} does not list its keys`, keys);
1285
1285
  const prod = await callTool("list_secrets", { environment: PROD });
1286
1286
  expect(prod.isError === true, `the reader listed ${PROD}'s keys through MCP, which they cannot`, prod);
1287
- const run = await callTool("run_with_secrets", {
1288
- environment: DEV,
1289
- command: "npm test"
1290
- });
1291
- expect(run.content?.[0]?.text?.includes(`coffre run ${DEV} -- npm test`) === true, "run_with_secrets does not say how to run the command", run);
1292
1287
  for (const tool of ["whoami", "list_projects"]) await callTool(tool, {});
1293
1288
  await callTool("secret_history", { secret: `${DEV}/API_KEY` });
1294
1289
  const mismatched = await mcp(deployment, {
@@ -1334,7 +1329,7 @@ async function mcpRead(deployment, people, canaries) {
1334
1329
  const mine = entries.filter((entry) => entry.metadata.via?.clientId === clientId);
1335
1330
  const reads = mine.filter((entry) => entry.action === "mcp.read").length;
1336
1331
  const refused = mine.filter((entry) => entry.action === "mcp.call" && entry.decision === "deny").length;
1337
- expect(reads === 6 && refused === 1, "the log does not hold each call under the client", {
1332
+ expect(reads === 5 && refused === 1, "the log does not hold each call under the client", {
1338
1333
  reads,
1339
1334
  refused
1340
1335
  });
@@ -1352,8 +1347,9 @@ async function mcpRead(deployment, people, canaries) {
1352
1347
  * approves on coffre's page. A client without URL elicitation gets the link
1353
1348
  * and calls again; one with it is asked to open the page, and retries with
1354
1349
  * its requestState, which no other call may use. Only the person decides,
1355
- * with the digest the page showed; the page makes the change, once, and its
1356
- * entries name the client and the approval. A value comes from the page.
1350
+ * in their browser, never with a CLI session, with the digest the page
1351
+ * showed; the page makes the change, once, and its entries name the client
1352
+ * and the approval. A value comes from the page.
1357
1353
  */
1358
1354
  async function mcpChanges(deployment, people, canaries) {
1359
1355
  const { admin } = people;
@@ -1421,15 +1417,27 @@ async function mcpChanges(deployment, people, canaries) {
1421
1417
  })
1422
1418
  });
1423
1419
  expect(forgedSite.status === 403, `another site's approval answered ${forgedSite.status}, not 403`);
1420
+ const cli = bearer(deployment.origin, await deviceLogin(deployment, changer.browser));
1421
+ const fromCli = await cli.approvals.get(approval.id).then(() => null, (error) => error);
1422
+ const decidedFromCli = await cli.approvals.decide(approval.id, {
1423
+ approve: true,
1424
+ digest: shown.digest
1425
+ }).then(() => null, (error) => error);
1426
+ expect(fromCli instanceof CoffreError && fromCli.status === 403 && decidedFromCli instanceof CoffreError && decidedFromCli.status === 403, "a CLI session opened or decided an approval", {
1427
+ fromCli,
1428
+ decidedFromCli
1429
+ });
1424
1430
  expect(!await archived("OLD"), "a refused decision changed something");
1425
1431
  const decided = await changer.api.approvals.decide(approval.id, {
1426
1432
  approve: true,
1427
- digest: shown.digest
1433
+ digest: shown.digest,
1434
+ basis: shown.basis
1428
1435
  });
1429
1436
  expect(decided.status === "approved" && await archived("OLD"), "Approve did not make the change", decided);
1430
1437
  const again = await changer.api.approvals.decide(approval.id, {
1431
1438
  approve: true,
1432
- digest: shown.digest
1439
+ digest: shown.digest,
1440
+ basis: shown.basis
1433
1441
  }).then(() => null, (error) => error);
1434
1442
  expect(again instanceof CoffreError && again.status === 409, "an approval was decided twice", again);
1435
1443
  const reported = await call(write, "archive_secret", { secret: `${place}/OLD` });
@@ -1455,7 +1463,8 @@ async function mcpChanges(deployment, people, canaries) {
1455
1463
  const second = (await changer.api.approvals.get(id)).approval;
1456
1464
  expect((await changer.api.approvals.decide(id, {
1457
1465
  approve: true,
1458
- digest: second.digest
1466
+ digest: second.digest,
1467
+ basis: second.basis
1459
1468
  })).status === "approved", "the second approval was not made");
1460
1469
  const retried = await call(write, "rename_secret", {
1461
1470
  secret: `${place}/KEEP`,
@@ -1473,6 +1482,7 @@ async function mcpChanges(deployment, people, canaries) {
1473
1482
  await changer.api.approvals.decide(valueId, {
1474
1483
  approve: true,
1475
1484
  digest: valuePage.digest,
1485
+ basis: valuePage.basis,
1476
1486
  value: typed
1477
1487
  });
1478
1488
  expect((await admin.api.secrets.reveal(`${place}/TYPED`)).values.TYPED === typed, "the value typed on the page was not written");
@@ -1484,7 +1494,8 @@ async function mcpChanges(deployment, people, canaries) {
1484
1494
  const generatedPage = (await changer.api.approvals.get(generatedId)).approval;
1485
1495
  const generated = await changer.api.approvals.decide(generatedId, {
1486
1496
  approve: true,
1487
- digest: generatedPage.digest
1497
+ digest: generatedPage.digest,
1498
+ basis: generatedPage.basis
1488
1499
  });
1489
1500
  const made = (await admin.api.secrets.reveal(`${place}/GENERATED`)).values.GENERATED ?? "";
1490
1501
  canaries[`${place}/GENERATED`] = made;
@@ -1515,7 +1526,7 @@ async function mcpChanges(deployment, people, canaries) {
1515
1526
  "deny approved",
1516
1527
  "deny changed"
1517
1528
  ]), "the decisions, and the two refused, are not in the log", decisions);
1518
- return `Read stepped up to Write, saying how as its result; Write ticked beyond what was asked; with Write, the link without URL elicitation and an elicitation with it; nothing changed until ${changer.email} approved on coffre's page, another person and another site refused, a replayed requestState refused; each change made once, via the client and its approval; a value typed on the page only, and one coffre made reaching no one`;
1529
+ return `Read stepped up to Write, saying how as its result; Write ticked beyond what was asked; with Write, the link without URL elicitation and an elicitation with it; nothing changed until ${changer.email} approved on coffre's page, another person, another site and a CLI session refused, a replayed requestState refused; each change made once, via the client and its approval; a value typed on the page only, and one coffre made reaching no one`;
1519
1530
  }
1520
1531
  /**
1521
1532
  * Values (design section 14, checks 2 and 4): Read cannot get one, Reveal
@@ -1550,7 +1561,8 @@ async function mcpValues(deployment, people, canaries) {
1550
1561
  expect(page.kind === "reveal", "the approval page does not say it shows a value", page);
1551
1562
  expect((await reader.api.approvals.decide(id, {
1552
1563
  approve: true,
1553
- digest: page.digest
1564
+ digest: page.digest,
1565
+ basis: page.basis
1554
1566
  })).shown.some((line) => line.value === dev.API_KEY), "Reveal did not show the person the value");
1555
1567
  const told = await call(reading, "show_secret_value", { secret: `${DEV}/API_KEY` });
1556
1568
  expect(told.result?.structuredContent?.status === "approved", "show_secret_value does not report the value as shown", told.result);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coffre/conformance",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
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,8 +31,8 @@
31
31
  "dependencies": {
32
32
  "jose": "6.2.3",
33
33
  "pg": "8.16.3",
34
- "@coffre/cli": "0.4.4",
35
- "@coffre/db": "0.4.4"
34
+ "@coffre/cli": "0.4.6",
35
+ "@coffre/db": "0.4.6"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/node": "26.1.1",
@@ -41,7 +41,7 @@
41
41
  "tsdown": "0.23.0",
42
42
  "typescript": "5.9.3",
43
43
  "vite": "8.1.5",
44
- "@coffre/client": "0.4.4"
44
+ "@coffre/client": "0.4.6"
45
45
  },
46
46
  "scripts": {
47
47
  "build": "tsdown",
package/src/checks/mcp.ts CHANGED
@@ -11,7 +11,8 @@ import { CoffreError } from '@coffre/client';
11
11
  import type { Deployment } from '../harness.ts';
12
12
  import { expect } from '../report.ts';
13
13
 
14
- import { canary, DEV, personaOn, PROD, PROJECT, valuesIn, type Canaries, type People, type Person } from './people.ts';
14
+ import { bearer } from '../browser.ts';
15
+ import { canary, deviceLogin, DEV, personaOn, PROD, PROJECT, valuesIn, type Canaries, type People, type Person } from './people.ts';
15
16
 
16
17
  const NAME = 'Conformance MCP client';
17
18
  /** A native client's redirect, on loopback. A custom scheme is left out of a registration (D37). */
@@ -263,7 +264,7 @@ export async function mcpRead(deployment: Deployment, people: People, canaries:
263
264
  const result = listed.body.result as { tools?: { name: string; annotations?: { readOnlyHint?: boolean } }[]; cacheScope?: string; ttlMs?: number } | undefined;
264
265
  const names = result?.tools?.map((tool) => tool.name) ?? [];
265
266
  // The reader's list: their role's tools, and none of an instance owner's; theirs alone to cache, and not for long, so a role's change shows.
266
- expect(names.includes('list_secrets') && names.includes('run_with_secrets') && !names.includes('admit_member') && result?.cacheScope === 'private' && typeof result.ttlMs === 'number' && result.ttlMs <= 600_000,
267
+ expect(names.includes('list_secrets') && !names.includes('run_with_secrets') && !names.includes('admit_member') && result?.cacheScope === 'private' && typeof result.ttlMs === 'number' && result.ttlMs <= 600_000,
267
268
  "tools/list does not list the reader's tools alone, cached for them only and briefly", listed.body);
268
269
  const callTool = async (tool: string, args: Record<string, unknown>) => {
269
270
  const { response, body } = await modern(deployment, access, 'tools/call', { name: tool, arguments: args }, tool);
@@ -276,8 +277,6 @@ export async function mcpRead(deployment: Deployment, people: People, canaries:
276
277
  expect(['API_KEY', 'DATABASE_URL'].every((key) => keys.includes(key)), `list_secrets on ${DEV} does not list its keys`, keys);
277
278
  const prod = await callTool('list_secrets', { environment: PROD });
278
279
  expect(prod.isError === true, `the reader listed ${PROD}'s keys through MCP, which they cannot`, prod);
279
- const run = await callTool('run_with_secrets', { environment: DEV, command: 'npm test' });
280
- expect(run.content?.[0]?.text?.includes(`coffre run ${DEV} -- npm test`) === true, 'run_with_secrets does not say how to run the command', run);
281
280
  for (const tool of ['whoami', 'list_projects']) await callTool(tool, {});
282
281
  await callTool('secret_history', { secret: `${DEV}/API_KEY` });
283
282
 
@@ -310,7 +309,7 @@ export async function mcpRead(deployment: Deployment, people: People, canaries:
310
309
  const mine = entries.filter((entry) => (entry.metadata.via as { clientId?: string } | undefined)?.clientId === clientId);
311
310
  const reads = mine.filter((entry) => entry.action === 'mcp.read').length;
312
311
  const refused = mine.filter((entry) => entry.action === 'mcp.call' && entry.decision === 'deny').length;
313
- expect(reads === 6 && refused === 1, 'the log does not hold each call under the client', { reads, refused });
312
+ expect(reads === 5 && refused === 1, 'the log does not hold each call under the client', { reads, refused });
314
313
  const api = mine.filter((entry) => !entry.action.startsWith('mcp.'));
315
314
  expect(api.length > 0, "the API's own entries for the calls do not name the connection", mine.map((entry) => entry.action));
316
315
  const shown = (await people.admin.api.audit.list({ actor: people.reader.member, limit: 500 })).entries;
@@ -333,8 +332,9 @@ type ToolAnswer = {
333
332
  * approves on coffre's page. A client without URL elicitation gets the link
334
333
  * and calls again; one with it is asked to open the page, and retries with
335
334
  * its requestState, which no other call may use. Only the person decides,
336
- * with the digest the page showed; the page makes the change, once, and its
337
- * entries name the client and the approval. A value comes from the page.
335
+ * in their browser, never with a CLI session, with the digest the page
336
+ * showed; the page makes the change, once, and its entries name the client
337
+ * and the approval. A value comes from the page.
338
338
  */
339
339
  export async function mcpChanges(deployment: Deployment, people: People, canaries: Canaries): Promise<string> {
340
340
  const { admin } = people;
@@ -391,11 +391,17 @@ export async function mcpChanges(deployment: Deployment, people: People, canarie
391
391
  body: JSON.stringify({ approve: true, digest: shown.digest }),
392
392
  });
393
393
  expect(forgedSite.status === 403, `another site's approval answered ${forgedSite.status}, not 403`);
394
+ // On coffre's page only: the person's CLI session, which an app on their machine may hold, can neither open nor decide it.
395
+ const cli = bearer(deployment.origin, await deviceLogin(deployment, changer.browser));
396
+ const fromCli = await cli.approvals.get(approval!.id).then(() => null, (error: unknown) => error);
397
+ const decidedFromCli = await cli.approvals.decide(approval!.id, { approve: true, digest: shown.digest }).then(() => null, (error: unknown) => error);
398
+ expect(fromCli instanceof CoffreError && fromCli.status === 403 && decidedFromCli instanceof CoffreError && decidedFromCli.status === 403,
399
+ 'a CLI session opened or decided an approval', { fromCli, decidedFromCli });
394
400
  expect(!(await archived('OLD')), 'a refused decision changed something');
395
401
 
396
- const decided = await changer.api.approvals.decide(approval!.id, { approve: true, digest: shown.digest });
402
+ const decided = await changer.api.approvals.decide(approval!.id, { approve: true, digest: shown.digest, basis: shown.basis });
397
403
  expect(decided.status === 'approved' && (await archived('OLD')), 'Approve did not make the change', decided);
398
- const again = await changer.api.approvals.decide(approval!.id, { approve: true, digest: shown.digest }).then(() => null, (error: unknown) => error);
404
+ const again = await changer.api.approvals.decide(approval!.id, { approve: true, digest: shown.digest, basis: shown.basis }).then(() => null, (error: unknown) => error);
399
405
  expect(again instanceof CoffreError && again.status === 409, 'an approval was decided twice', again);
400
406
  const reported = await call(write, 'archive_secret', { secret: `${place}/OLD` });
401
407
  expect(reported.result?.structuredContent?.status === 'approved' && reported.result.isError !== true, 'calling again does not report the approved change', reported.result);
@@ -412,7 +418,7 @@ export async function mcpChanges(deployment: Deployment, people: People, canarie
412
418
  const renamedEarly = await admin.api.secrets.list(place);
413
419
  expect(renamedEarly.keys.some((key) => key.key === 'KEEP'), 'a change was made before its approval', renamedEarly.keys);
414
420
  const second = (await changer.api.approvals.get(id)).approval;
415
- expect((await changer.api.approvals.decide(id, { approve: true, digest: second.digest })).status === 'approved', 'the second approval was not made');
421
+ expect((await changer.api.approvals.decide(id, { approve: true, digest: second.digest, basis: second.basis })).status === 'approved', 'the second approval was not made');
416
422
  const retried = await call(write, 'rename_secret', { secret: `${place}/KEEP`, newKey: 'KEPT' }, { requestState: asked.result!.requestState, inputResponses: { approve: { action: 'accept' } } }, elicits);
417
423
  expect(retried.result?.structuredContent?.status === 'approved', 'the retry does not report the approved change', retried.result);
418
424
 
@@ -423,7 +429,7 @@ export async function mcpChanges(deployment: Deployment, people: People, canarie
423
429
  const valueId = valueAsked.result!.structuredContent!.approval!.id;
424
430
  const valuePage = (await changer.api.approvals.get(valueId)).approval;
425
431
  expect(valuePage.asks?.value !== undefined, 'the approval page does not ask for the value');
426
- await changer.api.approvals.decide(valueId, { approve: true, digest: valuePage.digest, value: typed });
432
+ await changer.api.approvals.decide(valueId, { approve: true, digest: valuePage.digest, basis: valuePage.basis, value: typed });
427
433
  expect((await admin.api.secrets.reveal(`${place}/TYPED`)).values.TYPED === typed, 'the value typed on the page was not written');
428
434
  await call(write, 'request_secret_value', { secret: `${place}/TYPED` });
429
435
 
@@ -431,7 +437,7 @@ export async function mcpChanges(deployment: Deployment, people: People, canarie
431
437
  const generating = await call(write, 'generate_secret_value', { secret: `${place}/GENERATED`, alphabet: 'hex' });
432
438
  const generatedId = generating.result!.structuredContent!.approval!.id;
433
439
  const generatedPage = (await changer.api.approvals.get(generatedId)).approval;
434
- const generated = await changer.api.approvals.decide(generatedId, { approve: true, digest: generatedPage.digest });
440
+ const generated = await changer.api.approvals.decide(generatedId, { approve: true, digest: generatedPage.digest, basis: generatedPage.basis });
435
441
  const made = (await admin.api.secrets.reveal(`${place}/GENERATED`)).values.GENERATED ?? '';
436
442
  canaries[`${place}/GENERATED`] = made;
437
443
  expect(/^[0-9a-f]{64}$/.test(made) && generated.shown.length === 0 && !JSON.stringify(generated).includes(made), 'generate_secret_value did not make a 64-character hex value, shown to no one');
@@ -446,7 +452,7 @@ export async function mcpChanges(deployment: Deployment, people: People, canarie
446
452
  expect(once.archive === 1 && once.rename === 1 && once.write === 2, 'the changes are not each made once, via the client and its approval', once);
447
453
  const decisions = entries.filter((entry) => entry.action === 'mcp.approve').map((entry) => `${entry.decision} ${entry.reason ?? ''}`.trim()).sort();
448
454
  expect(JSON.stringify(decisions) === JSON.stringify(['allow', 'allow', 'allow', 'allow', 'deny approved', 'deny changed']), 'the decisions, and the two refused, are not in the log', decisions);
449
- return `Read stepped up to Write, saying how as its result; Write ticked beyond what was asked; with Write, the link without URL elicitation and an elicitation with it; nothing changed until ${changer.email} approved on coffre's page, another person and another site refused, a replayed requestState refused; each change made once, via the client and its approval; a value typed on the page only, and one coffre made reaching no one`;
455
+ return `Read stepped up to Write, saying how as its result; Write ticked beyond what was asked; with Write, the link without URL elicitation and an elicitation with it; nothing changed until ${changer.email} approved on coffre's page, another person, another site and a CLI session refused, a replayed requestState refused; each change made once, via the client and its approval; a value typed on the page only, and one coffre made reaching no one`;
450
456
  }
451
457
 
452
458
  /**
@@ -475,7 +481,7 @@ export async function mcpValues(deployment: Deployment, people: People, canaries
475
481
  expect(show.result?.structuredContent?.status === 'pending' && id !== undefined, 'show_secret_value did not open an approval', show.result);
476
482
  const page = (await reader.api.approvals.get(id!)).approval;
477
483
  expect(page.kind === 'reveal', 'the approval page does not say it shows a value', page);
478
- const shown = await reader.api.approvals.decide(id!, { approve: true, digest: page.digest });
484
+ const shown = await reader.api.approvals.decide(id!, { approve: true, digest: page.digest, basis: page.basis });
479
485
  expect(shown.shown.some((line) => line.value === dev.API_KEY), 'Reveal did not show the person the value');
480
486
  const told = await call(reading, 'show_secret_value', { secret: `${DEV}/API_KEY` });
481
487
  expect(told.result?.structuredContent?.status === 'approved', 'show_secret_value does not report the value as shown', told.result);
@@ -169,7 +169,7 @@ export async function personas(deployment: Deployment, admin: Person) {
169
169
  }
170
170
 
171
171
  /** `coffre login`: a device code, approved in a signed-in browser, for a CLI session. */
172
- async function deviceLogin(deployment: Deployment, browser: Browser): Promise<string> {
172
+ export async function deviceLogin(deployment: Deployment, browser: Browser): Promise<string> {
173
173
  const json = { 'content-type': 'application/json' };
174
174
  const started = await fetch(`${deployment.origin}/api/auth/device`, {
175
175
  method: 'POST',