@coffre/conformance 0.4.5 → 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 +25 -8
- package/package.json +4 -4
- package/src/checks/mcp.ts +18 -10
- package/src/checks/people.ts +1 -1
package/dist/main.js
CHANGED
|
@@ -1347,8 +1347,9 @@ async function mcpRead(deployment, people, canaries) {
|
|
|
1347
1347
|
* approves on coffre's page. A client without URL elicitation gets the link
|
|
1348
1348
|
* and calls again; one with it is asked to open the page, and retries with
|
|
1349
1349
|
* its requestState, which no other call may use. Only the person decides,
|
|
1350
|
-
*
|
|
1351
|
-
*
|
|
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.
|
|
1352
1353
|
*/
|
|
1353
1354
|
async function mcpChanges(deployment, people, canaries) {
|
|
1354
1355
|
const { admin } = people;
|
|
@@ -1416,15 +1417,27 @@ async function mcpChanges(deployment, people, canaries) {
|
|
|
1416
1417
|
})
|
|
1417
1418
|
});
|
|
1418
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
|
+
});
|
|
1419
1430
|
expect(!await archived("OLD"), "a refused decision changed something");
|
|
1420
1431
|
const decided = await changer.api.approvals.decide(approval.id, {
|
|
1421
1432
|
approve: true,
|
|
1422
|
-
digest: shown.digest
|
|
1433
|
+
digest: shown.digest,
|
|
1434
|
+
basis: shown.basis
|
|
1423
1435
|
});
|
|
1424
1436
|
expect(decided.status === "approved" && await archived("OLD"), "Approve did not make the change", decided);
|
|
1425
1437
|
const again = await changer.api.approvals.decide(approval.id, {
|
|
1426
1438
|
approve: true,
|
|
1427
|
-
digest: shown.digest
|
|
1439
|
+
digest: shown.digest,
|
|
1440
|
+
basis: shown.basis
|
|
1428
1441
|
}).then(() => null, (error) => error);
|
|
1429
1442
|
expect(again instanceof CoffreError && again.status === 409, "an approval was decided twice", again);
|
|
1430
1443
|
const reported = await call(write, "archive_secret", { secret: `${place}/OLD` });
|
|
@@ -1450,7 +1463,8 @@ async function mcpChanges(deployment, people, canaries) {
|
|
|
1450
1463
|
const second = (await changer.api.approvals.get(id)).approval;
|
|
1451
1464
|
expect((await changer.api.approvals.decide(id, {
|
|
1452
1465
|
approve: true,
|
|
1453
|
-
digest: second.digest
|
|
1466
|
+
digest: second.digest,
|
|
1467
|
+
basis: second.basis
|
|
1454
1468
|
})).status === "approved", "the second approval was not made");
|
|
1455
1469
|
const retried = await call(write, "rename_secret", {
|
|
1456
1470
|
secret: `${place}/KEEP`,
|
|
@@ -1468,6 +1482,7 @@ async function mcpChanges(deployment, people, canaries) {
|
|
|
1468
1482
|
await changer.api.approvals.decide(valueId, {
|
|
1469
1483
|
approve: true,
|
|
1470
1484
|
digest: valuePage.digest,
|
|
1485
|
+
basis: valuePage.basis,
|
|
1471
1486
|
value: typed
|
|
1472
1487
|
});
|
|
1473
1488
|
expect((await admin.api.secrets.reveal(`${place}/TYPED`)).values.TYPED === typed, "the value typed on the page was not written");
|
|
@@ -1479,7 +1494,8 @@ async function mcpChanges(deployment, people, canaries) {
|
|
|
1479
1494
|
const generatedPage = (await changer.api.approvals.get(generatedId)).approval;
|
|
1480
1495
|
const generated = await changer.api.approvals.decide(generatedId, {
|
|
1481
1496
|
approve: true,
|
|
1482
|
-
digest: generatedPage.digest
|
|
1497
|
+
digest: generatedPage.digest,
|
|
1498
|
+
basis: generatedPage.basis
|
|
1483
1499
|
});
|
|
1484
1500
|
const made = (await admin.api.secrets.reveal(`${place}/GENERATED`)).values.GENERATED ?? "";
|
|
1485
1501
|
canaries[`${place}/GENERATED`] = made;
|
|
@@ -1510,7 +1526,7 @@ async function mcpChanges(deployment, people, canaries) {
|
|
|
1510
1526
|
"deny approved",
|
|
1511
1527
|
"deny changed"
|
|
1512
1528
|
]), "the decisions, and the two refused, are not in the log", decisions);
|
|
1513
|
-
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
|
|
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`;
|
|
1514
1530
|
}
|
|
1515
1531
|
/**
|
|
1516
1532
|
* Values (design section 14, checks 2 and 4): Read cannot get one, Reveal
|
|
@@ -1545,7 +1561,8 @@ async function mcpValues(deployment, people, canaries) {
|
|
|
1545
1561
|
expect(page.kind === "reveal", "the approval page does not say it shows a value", page);
|
|
1546
1562
|
expect((await reader.api.approvals.decide(id, {
|
|
1547
1563
|
approve: true,
|
|
1548
|
-
digest: page.digest
|
|
1564
|
+
digest: page.digest,
|
|
1565
|
+
basis: page.basis
|
|
1549
1566
|
})).shown.some((line) => line.value === dev.API_KEY), "Reveal did not show the person the value");
|
|
1550
1567
|
const told = await call(reading, "show_secret_value", { secret: `${DEV}/API_KEY` });
|
|
1551
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.
|
|
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.
|
|
35
|
-
"@coffre/db": "0.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.
|
|
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 {
|
|
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). */
|
|
@@ -331,8 +332,9 @@ type ToolAnswer = {
|
|
|
331
332
|
* approves on coffre's page. A client without URL elicitation gets the link
|
|
332
333
|
* and calls again; one with it is asked to open the page, and retries with
|
|
333
334
|
* its requestState, which no other call may use. Only the person decides,
|
|
334
|
-
*
|
|
335
|
-
*
|
|
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.
|
|
336
338
|
*/
|
|
337
339
|
export async function mcpChanges(deployment: Deployment, people: People, canaries: Canaries): Promise<string> {
|
|
338
340
|
const { admin } = people;
|
|
@@ -389,11 +391,17 @@ export async function mcpChanges(deployment: Deployment, people: People, canarie
|
|
|
389
391
|
body: JSON.stringify({ approve: true, digest: shown.digest }),
|
|
390
392
|
});
|
|
391
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 });
|
|
392
400
|
expect(!(await archived('OLD')), 'a refused decision changed something');
|
|
393
401
|
|
|
394
|
-
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 });
|
|
395
403
|
expect(decided.status === 'approved' && (await archived('OLD')), 'Approve did not make the change', decided);
|
|
396
|
-
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);
|
|
397
405
|
expect(again instanceof CoffreError && again.status === 409, 'an approval was decided twice', again);
|
|
398
406
|
const reported = await call(write, 'archive_secret', { secret: `${place}/OLD` });
|
|
399
407
|
expect(reported.result?.structuredContent?.status === 'approved' && reported.result.isError !== true, 'calling again does not report the approved change', reported.result);
|
|
@@ -410,7 +418,7 @@ export async function mcpChanges(deployment: Deployment, people: People, canarie
|
|
|
410
418
|
const renamedEarly = await admin.api.secrets.list(place);
|
|
411
419
|
expect(renamedEarly.keys.some((key) => key.key === 'KEEP'), 'a change was made before its approval', renamedEarly.keys);
|
|
412
420
|
const second = (await changer.api.approvals.get(id)).approval;
|
|
413
|
-
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');
|
|
414
422
|
const retried = await call(write, 'rename_secret', { secret: `${place}/KEEP`, newKey: 'KEPT' }, { requestState: asked.result!.requestState, inputResponses: { approve: { action: 'accept' } } }, elicits);
|
|
415
423
|
expect(retried.result?.structuredContent?.status === 'approved', 'the retry does not report the approved change', retried.result);
|
|
416
424
|
|
|
@@ -421,7 +429,7 @@ export async function mcpChanges(deployment: Deployment, people: People, canarie
|
|
|
421
429
|
const valueId = valueAsked.result!.structuredContent!.approval!.id;
|
|
422
430
|
const valuePage = (await changer.api.approvals.get(valueId)).approval;
|
|
423
431
|
expect(valuePage.asks?.value !== undefined, 'the approval page does not ask for the value');
|
|
424
|
-
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 });
|
|
425
433
|
expect((await admin.api.secrets.reveal(`${place}/TYPED`)).values.TYPED === typed, 'the value typed on the page was not written');
|
|
426
434
|
await call(write, 'request_secret_value', { secret: `${place}/TYPED` });
|
|
427
435
|
|
|
@@ -429,7 +437,7 @@ export async function mcpChanges(deployment: Deployment, people: People, canarie
|
|
|
429
437
|
const generating = await call(write, 'generate_secret_value', { secret: `${place}/GENERATED`, alphabet: 'hex' });
|
|
430
438
|
const generatedId = generating.result!.structuredContent!.approval!.id;
|
|
431
439
|
const generatedPage = (await changer.api.approvals.get(generatedId)).approval;
|
|
432
|
-
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 });
|
|
433
441
|
const made = (await admin.api.secrets.reveal(`${place}/GENERATED`)).values.GENERATED ?? '';
|
|
434
442
|
canaries[`${place}/GENERATED`] = made;
|
|
435
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');
|
|
@@ -444,7 +452,7 @@ export async function mcpChanges(deployment: Deployment, people: People, canarie
|
|
|
444
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);
|
|
445
453
|
const decisions = entries.filter((entry) => entry.action === 'mcp.approve').map((entry) => `${entry.decision} ${entry.reason ?? ''}`.trim()).sort();
|
|
446
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);
|
|
447
|
-
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
|
|
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`;
|
|
448
456
|
}
|
|
449
457
|
|
|
450
458
|
/**
|
|
@@ -473,7 +481,7 @@ export async function mcpValues(deployment: Deployment, people: People, canaries
|
|
|
473
481
|
expect(show.result?.structuredContent?.status === 'pending' && id !== undefined, 'show_secret_value did not open an approval', show.result);
|
|
474
482
|
const page = (await reader.api.approvals.get(id!)).approval;
|
|
475
483
|
expect(page.kind === 'reveal', 'the approval page does not say it shows a value', page);
|
|
476
|
-
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 });
|
|
477
485
|
expect(shown.shown.some((line) => line.value === dev.API_KEY), 'Reveal did not show the person the value');
|
|
478
486
|
const told = await call(reading, 'show_secret_value', { secret: `${DEV}/API_KEY` });
|
|
479
487
|
expect(told.result?.structuredContent?.status === 'approved', 'show_secret_value does not report the value as shown', told.result);
|
package/src/checks/people.ts
CHANGED
|
@@ -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',
|