@tokenoftrust/cli 7.14.2 → 7.14.3
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/cli",
|
|
3
|
-
"version": "7.14.
|
|
3
|
+
"version": "7.14.3",
|
|
4
4
|
"description": "Token of Trust developer CLI — clone a tenant store, run it locally with save→reload, and submit it for preview. Installs the `tot` command.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Token of Trust",
|
|
@@ -16,7 +16,7 @@ const MAX_MOCK_BODY_BYTES = 65_536;
|
|
|
16
16
|
const CURRENCY = "USD";
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* @typedef {{ method: string, path: string, idempotencyKey: string | null, body: string }} MockRequest
|
|
19
|
+
* @typedef {{ method: string, path: string, idempotencyKey: string | null, body: string, status?: number }} MockRequest
|
|
20
20
|
* @typedef {{ status: number, headers: Record<string, string>, body: string }} MockResponse
|
|
21
21
|
* @typedef {{ log: MockRequest[], mark: number }} StepContext
|
|
22
22
|
* @typedef {{
|
|
@@ -24,6 +24,7 @@ const CURRENCY = "USD";
|
|
|
24
24
|
* body: string,
|
|
25
25
|
* acknowledgment?: "initial" | "replay",
|
|
26
26
|
* tamper?: boolean,
|
|
27
|
+
* observed?: (context: StepContext) => string | undefined,
|
|
27
28
|
* expect?: (ack: any, context: StepContext) => string | undefined,
|
|
28
29
|
* rejected?: (status: number) => string,
|
|
29
30
|
* refusal?: string,
|
|
@@ -196,7 +197,10 @@ function marketingEsp() {
|
|
|
196
197
|
evaluate(log) {
|
|
197
198
|
const push = log.find((request) => request.path.startsWith(`${API_PREFIX}customers`) && request.method !== "GET"
|
|
198
199
|
&& !(request.method === "POST" && request.path.endsWith("/marketing-opt-out")));
|
|
199
|
-
|
|
200
|
+
if (!push) return undefined;
|
|
201
|
+
// The path is connector-chosen and may carry a contact value, so only the reviewed operation name is reported.
|
|
202
|
+
const operation = /\/(marketing-contact|consent|marketing-opt-out)$/.exec(push.path)?.[1] ?? "customer route";
|
|
203
|
+
return `contact push refused: ${push.method} ${operation}`;
|
|
200
204
|
},
|
|
201
205
|
},
|
|
202
206
|
{
|
|
@@ -373,8 +377,9 @@ function accountingGl() {
|
|
|
373
377
|
expect(ack) {
|
|
374
378
|
const debit = ack?.journal?.debitMinor;
|
|
375
379
|
const credit = ack?.journal?.creditMinor;
|
|
376
|
-
|
|
377
|
-
|
|
380
|
+
// Only validated integers reach the finding: an acknowledgment field is connector-chosen and may hold anything.
|
|
381
|
+
if (!Number.isSafeInteger(debit) || !Number.isSafeInteger(credit)) return "acknowledgment carries no integer journal.debitMinor and journal.creditMinor";
|
|
382
|
+
return debit === credit && debit > 0 ? undefined : `unbalanced journal (debitMinor ${debit}, creditMinor ${credit})`;
|
|
378
383
|
},
|
|
379
384
|
}),
|
|
380
385
|
step("Settlement replay", {
|
|
@@ -564,10 +569,19 @@ function biExport() {
|
|
|
564
569
|
}
|
|
565
570
|
|
|
566
571
|
const statusPath = `${API_PREFIX}exports/${scopeDenied.id}`;
|
|
572
|
+
const scopeDeniedPaths = [statusPath, `${statusPath}/download`];
|
|
573
|
+
/** A verdict on digest counts only when this delivery fetched that fixture's bytes. @param {{ id: string }} fixture */
|
|
574
|
+
const bytesDownloaded = (fixture) => (/** @type {StepContext} */ { log, mark }) => {
|
|
575
|
+
const path = `${DOWNLOAD_PREFIX}${fixture.id}/0`;
|
|
576
|
+
return log.slice(mark).some((request) => request.method === "GET" && request.path === path && request.status === 200)
|
|
577
|
+
? undefined
|
|
578
|
+
: "export bytes not downloaded (fetch the download URL and hash those bytes before acknowledging)";
|
|
579
|
+
};
|
|
567
580
|
const steps = [
|
|
568
581
|
step("Signature tamper refused", { id: "export-tampered", topic: "export.completed", data: tampered.event, minute: 10, tamper: true }),
|
|
569
582
|
step("Export verified", {
|
|
570
583
|
id: "export-verified", topic: "export.completed", data: verified.event, minute: 11, acknowledgment: "initial",
|
|
584
|
+
observed: bytesDownloaded(verified),
|
|
571
585
|
expect(ack) {
|
|
572
586
|
if (ack?.verified !== true) return "export not verified (acknowledge {\"verified\":true} after the bytes match sha256Digest)";
|
|
573
587
|
return ack?.watermark === verified.event.watermarkMaxUpdatedAt
|
|
@@ -578,6 +592,7 @@ function biExport() {
|
|
|
578
592
|
step("Export replay", { id: "export-verified", topic: "export.completed", data: verified.event, minute: 12, acknowledgment: "replay" }),
|
|
579
593
|
step("Digest mismatch refused", {
|
|
580
594
|
id: "export-mismatch", topic: "export.completed", data: mismatch.event, minute: 13, refusal: "digest mismatch refused",
|
|
595
|
+
observed: bytesDownloaded(mismatch),
|
|
581
596
|
expect(ack) {
|
|
582
597
|
if (ack?.verified === true) return "digest mismatch accepted";
|
|
583
598
|
return ack?.verified === false ? undefined : "acknowledgment carries no verified:false for a digest mismatch";
|
|
@@ -586,9 +601,13 @@ function biExport() {
|
|
|
586
601
|
step("Scope-denied export handled", {
|
|
587
602
|
id: "export-scope-denied", topic: "export.completed", data: scopeDenied.event, minute: 14,
|
|
588
603
|
rejected: (status) => `HTTP ${status} scope_denied refusal not handled; answer 2xx with {"verified":false} so the platform does not retry`,
|
|
604
|
+
observed({ log, mark }) {
|
|
605
|
+
const denied = log.slice(mark).some((request) => scopeDeniedPaths.includes(request.path) && request.status === 403);
|
|
606
|
+
return denied ? undefined : "no 403 scope_denied read observed (read the export before acknowledging)";
|
|
607
|
+
},
|
|
589
608
|
expect(ack, { log, mark }) {
|
|
590
609
|
if (ack?.verified !== false) return "scope-denied export loaded (acknowledge {\"verified\":false})";
|
|
591
|
-
return retriedRead(log.slice(mark),
|
|
610
|
+
return retriedRead(log.slice(mark), scopeDeniedPaths);
|
|
592
611
|
},
|
|
593
612
|
}),
|
|
594
613
|
];
|
|
@@ -615,7 +634,9 @@ export function createArchetypePlan(archetype) {
|
|
|
615
634
|
/** @type {MockRequest} */
|
|
616
635
|
const request = { method, path: parsed.pathname, idempotencyKey: typeof key === "string" ? key : null, body };
|
|
617
636
|
log.push(request);
|
|
618
|
-
|
|
637
|
+
const response = route(request, parsed);
|
|
638
|
+
request.status = response.status;
|
|
639
|
+
return response;
|
|
619
640
|
},
|
|
620
641
|
};
|
|
621
642
|
}
|
|
@@ -667,8 +688,12 @@ export function judgeDelivery(step, { status, ack, initialAccepted, log, mark })
|
|
|
667
688
|
return { finding: `HTTP ${status} tampered delivery not refused with 4xx`, initial: false };
|
|
668
689
|
}
|
|
669
690
|
if (status >= 300 && status < 400) return { finding: `HTTP ${status} redirect refused`, initial: false };
|
|
691
|
+
// Evidence the connector did the work, judged from the mock platform API log before any verdict it states.
|
|
692
|
+
const missing = step.observed?.({ log, mark });
|
|
670
693
|
if (!success) {
|
|
671
|
-
if (step.refusal && status >= 400 && status < 500)
|
|
694
|
+
if (step.refusal && status >= 400 && status < 500) {
|
|
695
|
+
return missing ? { finding: `HTTP ${status} ${missing}`, initial: false } : { detail: step.refusal, initial: false };
|
|
696
|
+
}
|
|
672
697
|
return { finding: step.rejected ? step.rejected(status) : `HTTP ${status} delivery rejected`, initial: false };
|
|
673
698
|
}
|
|
674
699
|
const duplicate = ack?.accepted === true && ack?.duplicate === true;
|
|
@@ -677,7 +702,7 @@ export function judgeDelivery(step, { status, ack, initialAccepted, log, mark })
|
|
|
677
702
|
if (replay && !duplicate) return { finding: `HTTP ${status} delivery acknowledged without duplicate confirmation`, initial: false };
|
|
678
703
|
if (replay && !initialAccepted) return { finding: `HTTP ${status} duplicate reported without a successful initial delivery`, initial: false };
|
|
679
704
|
const initial = step.acknowledgment === "initial";
|
|
680
|
-
const finding = step.expect?.(ack, { log, mark });
|
|
705
|
+
const finding = missing ?? step.expect?.(ack, { log, mark });
|
|
681
706
|
if (finding) return { finding: `HTTP ${status} ${finding}`, initial };
|
|
682
707
|
return { detail: replay ? "duplicate acknowledged" : "delivery acknowledged", initial };
|
|
683
708
|
}
|