@crawlcheck/sdk 1.1.0 → 1.2.0
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/index.d.ts +14 -2
- package/dist/index.js +12 -4
- package/package.json +1 -1
- package/test/fixtures/guard-acceptance.json +1534 -761
- package/test/guard-acceptance.test.js +2 -0
|
@@ -18,6 +18,7 @@ function fakeFetch(c, log) {
|
|
|
18
18
|
if (p === "/.well-known/http-message-signatures-directory") return new Response(JSON.stringify(suite.directory), { headers: { "content-type": "application/json" } });
|
|
19
19
|
if (p === "/api/v1/preflight") {
|
|
20
20
|
const b = JSON.parse(init.body || "{}"); log.asked.push(b.domain);
|
|
21
|
+
if (cc.by_op) { const o = b.operation || {}; const r = cc.by_op[o.method + " " + o.url]; return r ? new Response(JSON.stringify(r), { headers: { "content-type": "application/json" } }) : new Response("{\"error\":\"none\"}", { status: 404 }); }
|
|
21
22
|
if (cc.by_domain) { const r = cc.by_domain[b.domain]; return r ? new Response(JSON.stringify(r), { headers: { "content-type": "application/json" } }) : new Response("{\"error\":\"none\"}", { status: 404 }); }
|
|
22
23
|
return new Response(cc.text !== undefined ? cc.text : JSON.stringify(cc.body), { status: cc.status || 200, headers: { "content-type": "application/json" } });
|
|
23
24
|
}
|
|
@@ -36,6 +37,7 @@ for (const c of suite.cases) {
|
|
|
36
37
|
const log = { fetched: [], header_to: [], asked: [] };
|
|
37
38
|
const cc = new CrawlCheck({ base: BASE, fetch: fakeFetch(c, log) });
|
|
38
39
|
const q = c.request, opts = { nonce: q.nonce, now: Date.parse(q.now), allowWarn: q.allow_warn };
|
|
40
|
+
if (q.operation) opts.operation = q.operation;
|
|
39
41
|
if (q.confirm !== null) opts.confirm = async () => q.confirm;
|
|
40
42
|
if (q.url) {
|
|
41
43
|
assert.equal(typeof cc.guardedFetch, "function", "this SDK has no guarded fetch, so nothing re-checks redirects");
|