@crawlcheck/sdk 1.9.1 → 1.9.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/gen/openapi.d.ts +1 -1
- package/dist/index.js +9 -1
- package/package.json +1 -1
- package/test/tools.test.js +7 -0
package/dist/gen/openapi.d.ts
CHANGED
|
@@ -1895,7 +1895,7 @@ export interface paths {
|
|
|
1895
1895
|
path?: never;
|
|
1896
1896
|
cookie?: never;
|
|
1897
1897
|
};
|
|
1898
|
-
/** The last reconstruction test: the oldest archived records' evidence paths (record, report node, decision nodes, manifest node, every verifier check) resolved through the 90-day projections and again from the permanent store alone (
|
|
1898
|
+
/** The last reconstruction test: the oldest archived records' evidence paths (record, report node, decision nodes, manifest node, every verifier check) resolved through the 90-day projections and again from the permanent store alone (the sealed archive and seal records), compared byte for byte after canonical serialisation. Public */
|
|
1899
1899
|
get: operations["reconstructionTest"];
|
|
1900
1900
|
put?: never;
|
|
1901
1901
|
post?: never;
|
package/dist/index.js
CHANGED
|
@@ -608,7 +608,11 @@ function atDomain(v) { const s = String(v ?? "").trim(); try {
|
|
|
608
608
|
catch {
|
|
609
609
|
return "";
|
|
610
610
|
} }
|
|
611
|
-
|
|
611
|
+
// 1.9.2: an action that is GIVEN but not one of the five fails closed (it used to fall back to "read", so a crew asking about
|
|
612
|
+
// "pay" got a read decision). An absent action still means read.
|
|
613
|
+
function atAction(v) { if (v === undefined || v === null || v === "")
|
|
614
|
+
return "read"; return AT_ACTIONS.includes(String(v)) ? String(v) : null; }
|
|
615
|
+
const atBadAction = (v) => ({ proceed: false, why: ["unknown action: " + String(v) + " (use read, cite, connect, transact or administer)"] });
|
|
612
616
|
export function agentTools(cc, opts = {}) {
|
|
613
617
|
const max = opts.maxChars ?? 20000;
|
|
614
618
|
return [
|
|
@@ -620,6 +624,8 @@ export function agentTools(cc, opts = {}) {
|
|
|
620
624
|
} },
|
|
621
625
|
execute: async (a) => {
|
|
622
626
|
const domain = atDomain(a?.site), action = atAction(a?.action);
|
|
627
|
+
if (!action)
|
|
628
|
+
return atBadAction(a?.action);
|
|
623
629
|
if (!domain)
|
|
624
630
|
return { proceed: false, why: ["not a public domain name: " + String(a?.site ?? "")] };
|
|
625
631
|
const g = await cc.guard(domain, action, opts);
|
|
@@ -657,6 +663,8 @@ export function agentTools(cc, opts = {}) {
|
|
|
657
663
|
action: { type: "string", enum: ["read", "cite"], description: "read (default) or cite, if the text will be quoted back to someone" }
|
|
658
664
|
} },
|
|
659
665
|
execute: async (a) => {
|
|
666
|
+
if (a?.action !== undefined && a?.action !== null && a?.action !== "" && a.action !== "read" && a.action !== "cite")
|
|
667
|
+
return Object.assign(atBadAction(a.action), { url: String(a?.url ?? "") });
|
|
660
668
|
const r = await cc.guardedFetch(String(a?.url ?? ""), Object.assign({}, opts, { action: (a?.action === "cite" ? "cite" : "read") }));
|
|
661
669
|
const hops = r.hops.map((h) => ({ url: h.url, domain: h.domain, decision: h.decision, proceed: h.proceed, status: h.status ?? null }));
|
|
662
670
|
if (!r.proceed || !r.response)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlcheck/sdk",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.2",
|
|
4
4
|
"description": "Typed client for the CrawlCheck API (generated from its OpenAPI document) and the zero-dependency offline verifier for evidence bundles and remediation receipts.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
package/test/tools.test.js
CHANGED
|
@@ -44,3 +44,10 @@ test("live: verify_fact returns a signed verdict that verifies", async () => {
|
|
|
44
44
|
if (r.ok) { assert.equal(r.kind, "crawlcheck-field-check"); assert.equal(r.verified, true); assert.ok(r.verdict); }
|
|
45
45
|
else assert.ok(r.why.length);
|
|
46
46
|
});
|
|
47
|
+
|
|
48
|
+
test("1.9.2: an unknown action fails closed (no fallback to read), without calling the API", async () => {
|
|
49
|
+
const r = await tools[0].execute({ site: "crawlcheck.io", action: "pay" });
|
|
50
|
+
assert.equal(r.proceed, false); assert.match(r.why[0], /unknown action: pay/);
|
|
51
|
+
const f = await tools[2].execute({ url: "https://crawlcheck.io/", action: "transact" });
|
|
52
|
+
assert.equal(f.proceed, false); assert.match(f.why[0], /unknown action/);
|
|
53
|
+
});
|