@agent-custody/receipts 0.16.6 → 0.16.7
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/README.md +22 -9
- package/dist/capture.d.ts +2 -0
- package/dist/capture.js +13 -2
- package/dist/check.d.ts +1 -1
- package/dist/check.js +34 -10
- package/dist/cli.js +4 -2
- package/dist/config.d.ts +27 -2
- package/dist/config.js +66 -2
- package/dist/door-app.d.ts +28 -0
- package/dist/door-app.js +244 -0
- package/dist/door-partner.d.ts +66 -0
- package/dist/door-partner.js +94 -0
- package/dist/door.d.ts +139 -10
- package/dist/door.js +297 -137
- package/dist/gateway-http.d.ts +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +2 -1
- package/dist/perathos.js +3 -2
- package/dist/receipt.d.ts +4 -1
- package/dist/verify.js +44 -4
- package/dist/web-bot-auth.d.ts +105 -0
- package/dist/web-bot-auth.js +508 -0
- package/docs/door-languages.md +168 -0
- package/docs/door-middleware.md +216 -0
- package/docs/door-quickstart.md +1 -1
- package/docs/door-signals.md +42 -5
- package/docs/door.md +124 -15
- package/docs/github-action.md +2 -2
- package/docs/perathos.md +13 -10
- package/docs/tutorials.md +4 -0
- package/docs/verification.md +2 -0
- package/package.json +7 -1
- package/vectors/audit.json +27 -27
- package/vectors/canonical.json +5 -5
- package/vectors/receipts.json +1701 -1210
package/dist/gateway-http.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { type GatewayHost } from "./gateway.ts";
|
|
|
4
4
|
export declare const GRANT_HEADER = "x-agent-custody-grant";
|
|
5
5
|
/** The header value that presents a grant: the DSSE envelope as base64url JSON. Send it as `Authorization: Bearer <value>` or as `X-Agent-Custody-Grant`. */
|
|
6
6
|
export declare function grantHeader(envelope: Envelope): string;
|
|
7
|
-
export declare function parseGrantHeader(req: IncomingMessage): Envelope | null;
|
|
7
|
+
export declare function parseGrantHeader(req: Pick<IncomingMessage, "headers">): Envelope | null;
|
|
8
8
|
export interface HttpGatewayOptions {
|
|
9
9
|
port: number;
|
|
10
10
|
host?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ export { hecEvent, splunkExporter } from "./splunk.ts";
|
|
|
7
7
|
export { serveConsole, type ConsoleOptions, type RunningConsole } from "./console.ts";
|
|
8
8
|
export { checkConfig, formatFindings, type CheckFinding, type CheckOptions } from "./check.ts";
|
|
9
9
|
export { GRANT_HEADER, grantHeader, parseGrantHeader, serveHttp } from "./gateway-http.ts";
|
|
10
|
-
export { AGENT_HEADER, ARRIVAL_FACT, CLASS_HEADER, DOOR_DEFAULT_CAPTURE, DOOR_VERSION, MAX_CHALLENGE_TOKEN, RECEIPT_HEADER, RATE_BURST_MS, RATE_MINUTE_MS, cedarArgs, classifyArrival, createDoorHost, createRateTracker, matchRoute, normalizePath, remoteOf, serveDoor, verifyChallengeToken } from "./door.ts";
|
|
10
|
+
export { AGENT_HEADER, ARRIVAL_FACT, CLASS_HEADER, DOOR_DEFAULT_CAPTURE, DOOR_VERSION, MAX_CHALLENGE_TOKEN, RECEIPT_HEADER, RATE_BURST_MS, RATE_MINUTE_MS, cedarArgs, classifyArrival, createDoorHost, createRateTracker, matchRoute, normalizePath, remoteOf, serveDoor, signedRequestOf, verifyChallengeToken } from "./door.ts";
|
|
11
|
+
export { DIRECTORY_MEDIA_TYPE, DIRECTORY_PATH, WEB_BOT_AUTH_TAG, agentOrigin, createWebBotAuthVerifier, jwkThumbprint, normalizeAuthority, parseDictionary, signatureBase } from "./web-bot-auth.ts";
|
|
11
12
|
export { DESTINATION_FACT, EGRESS_VERSION, PROXY_REALM, checkProxyCredential, createEgressHost, destinationName, normalizeHost, parseAuthority, publicOnlyLookup, serveEgress } from "./egress.ts";
|
|
12
13
|
export { internalAddress } from "./addresses.ts";
|
|
13
14
|
export { DRAFT_WARNING, draftEgressPolicy } from "./egress-draft.ts";
|
|
@@ -19,7 +20,8 @@ export { formatPerathosReport, PERATHOS_RECEIPT_V1, perathosHead, perathosReceip
|
|
|
19
20
|
export type { PerathosCheck, PerathosOptions, PerathosReport } from "./perathos.ts";
|
|
20
21
|
export { loadAcsGuardianConfig } from "./config.ts";
|
|
21
22
|
export type { AcsGuardianConfig } from "./config.ts";
|
|
22
|
-
export type { Arrival, ArrivalChallenge, ArrivalClass, ArrivalRate, ChallengeCheck, Classified, DoorHost, DoorOptions, DoorServerOptions, RateTracker, RateTrackerLimits, RunningDoor } from "./door.ts";
|
|
23
|
+
export type { Arrival, ArrivalChallenge, ArrivalClass, ArrivalRate, ChallengeCheck, Classified, DoorHost, DoorOptions, DoorRequest, DoorServerOptions, RateTracker, RateTrackerLimits, RunningDoor } from "./door.ts";
|
|
24
|
+
export type { SignatureCheck, SignedRequest, WebBotAuthOptions, WebBotAuthVerifier } from "./web-bot-auth.ts";
|
|
23
25
|
export * from "./capture.ts";
|
|
24
26
|
export { A2A_CARD_PATH, A2A_RECEIPT_METADATA_KEY, A2A_STREAM_META_KEY, a2aUpstream, fetchAgentCard, serveA2a, textOf } from "./a2a.ts";
|
|
25
27
|
export { deliverMail, founderNote, PortalStore, portalHandler, readSession, readSessionVia, sendFollowUps, servePortal, signSession, SsoRefusedError, stripeRequest, verifyStripeSignature } from "./portal.ts";
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,8 @@ export { hecEvent, splunkExporter } from "./splunk.js";
|
|
|
6
6
|
export { serveConsole } from "./console.js";
|
|
7
7
|
export { checkConfig, formatFindings } from "./check.js";
|
|
8
8
|
export { GRANT_HEADER, grantHeader, parseGrantHeader, serveHttp } from "./gateway-http.js";
|
|
9
|
-
export { AGENT_HEADER, ARRIVAL_FACT, CLASS_HEADER, DOOR_DEFAULT_CAPTURE, DOOR_VERSION, MAX_CHALLENGE_TOKEN, RECEIPT_HEADER, RATE_BURST_MS, RATE_MINUTE_MS, cedarArgs, classifyArrival, createDoorHost, createRateTracker, matchRoute, normalizePath, remoteOf, serveDoor, verifyChallengeToken } from "./door.js";
|
|
9
|
+
export { AGENT_HEADER, ARRIVAL_FACT, CLASS_HEADER, DOOR_DEFAULT_CAPTURE, DOOR_VERSION, MAX_CHALLENGE_TOKEN, RECEIPT_HEADER, RATE_BURST_MS, RATE_MINUTE_MS, cedarArgs, classifyArrival, createDoorHost, createRateTracker, matchRoute, normalizePath, remoteOf, serveDoor, signedRequestOf, verifyChallengeToken } from "./door.js";
|
|
10
|
+
export { DIRECTORY_MEDIA_TYPE, DIRECTORY_PATH, WEB_BOT_AUTH_TAG, agentOrigin, createWebBotAuthVerifier, jwkThumbprint, normalizeAuthority, parseDictionary, signatureBase } from "./web-bot-auth.js";
|
|
10
11
|
export { DESTINATION_FACT, EGRESS_VERSION, PROXY_REALM, checkProxyCredential, createEgressHost, destinationName, normalizeHost, parseAuthority, publicOnlyLookup, serveEgress } from "./egress.js";
|
|
11
12
|
export { internalAddress } from "./addresses.js";
|
|
12
13
|
export { DRAFT_WARNING, draftEgressPolicy } from "./egress-draft.js";
|
package/dist/perathos.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* verification rules of their published spec (docs/specs/RECEIPT_V1.md in perathos-protocol/perathos). Written from
|
|
4
4
|
* that spec alone, so a Perathos log and an agent-custody receipt can be checked with one tool, each for what it proves.
|
|
5
5
|
*
|
|
6
|
-
* A Perathos log is recorded
|
|
6
|
+
* A Perathos log is recorded on the agent's host, by hooks or an MCP proxy, and sealed by checkpoints signed with a key
|
|
7
|
+
* that is on that host or, with a remote signer, usable from it.
|
|
7
8
|
* A valid log shows that the key holder sealed this sequence and nothing up to the last checkpoint changed since. It
|
|
8
9
|
* does not show that an enforcement point outside the agent saw each call, which is what an agent-custody receipt
|
|
9
10
|
* attests, so the report says which kind of evidence it is. RFC 3161 anchors are not checked here.
|
|
@@ -166,7 +167,7 @@ export function verifyPerathosLog(text, opts = {}) {
|
|
|
166
167
|
signerFailures,
|
|
167
168
|
firstTs: typeof receipts[0]?.ts === "string" ? receipts[0].ts : null,
|
|
168
169
|
lastTs: typeof receipts.at(-1)?.ts === "string" ? receipts.at(-1).ts : null,
|
|
169
|
-
provenance: `perathos.receipt/v1, recorded
|
|
170
|
+
provenance: `perathos.receipt/v1, recorded on the agent's host (${agent ?? "unknown"}) by hooks or an MCP proxy; the checkpoint key, or the credential for a remote signer, is on that host, so a valid log shows that the key holder sealed this sequence, not that an enforcement point outside the agent saw each call; times are the host's clock, and RFC 3161 anchors were not checked`,
|
|
170
171
|
};
|
|
171
172
|
}
|
|
172
173
|
/** The report as text, in the style of `verify`. */
|
package/dist/receipt.d.ts
CHANGED
|
@@ -36,7 +36,10 @@ export interface FactRecord {
|
|
|
36
36
|
value: unknown;
|
|
37
37
|
/** the digest of the lookup's full result; under a capture rule a commitment to that result (the receipt shows only the selected value, the rest is private), named in the `capture` note */
|
|
38
38
|
resultDigest: string | Commitment;
|
|
39
|
-
|
|
39
|
+
/** `attested` only when `attestation` carries its source's signature over `value` for this receipt and tool, checked by the issuer; a verifier checks it again under the source's key */
|
|
40
|
+
provenance: "observed" | "attested";
|
|
41
|
+
/** the source's attestation envelope (upstream.ts format, over the digest of `value`); the door's partner verdict carries one. Withheld unless it is exactly that plain attestation beside a value in clear */
|
|
42
|
+
attestation?: Envelope | Commitment;
|
|
40
43
|
}
|
|
41
44
|
/** A gateway's durable financial operation identity; execution still describes only the tool/API call. */
|
|
42
45
|
export interface OperationEvidence {
|
package/dist/verify.js
CHANGED
|
@@ -211,6 +211,11 @@ export function verifyBundle(bundle, opts) {
|
|
|
211
211
|
// A door decides every arrival by policy; an arrival carries a grant only when it chose to present one.
|
|
212
212
|
if (p.issuer.kind === "door")
|
|
213
213
|
add("door receipt carries a policy decision", p.policy !== null);
|
|
214
|
+
// In authz mode the door answers a proxy's check and relays nothing: the receipt is a decision, never a result.
|
|
215
|
+
if (p.issuer.kind === "door" && p.issuer.framework === "authz") {
|
|
216
|
+
const decided = p.execution.status === "withheld" || (p.execution.status === "denied" && p.policy?.decision === "deny");
|
|
217
|
+
add("door authz decided, relayed nothing", decided, decided ? `${p.policy?.decision}; a decision for the proxy, which relays: the door saw neither the body nor the origin's answer` : `the receipt says ${p.execution.status} with a policy ${p.policy?.decision ?? "absent"}`);
|
|
218
|
+
}
|
|
214
219
|
// An egress witness saw a connection that went around the gateway: where it went and how much, never what was sent.
|
|
215
220
|
// Its destination is its own observation; its agent is only as good as the proxy credential it checked.
|
|
216
221
|
if (p.issuer.kind === "egress") {
|
|
@@ -373,6 +378,32 @@ export function verifyBundle(bundle, opts) {
|
|
|
373
378
|
const how = back.restored.get(pathKey(w));
|
|
374
379
|
add(`withheld ${pathText(w)}`, !problem, problem ?? (how ? `holds against the ${how} value` : committedNote([w])));
|
|
375
380
|
}
|
|
381
|
+
// A fact its source signed (the door's partner verdict): the issuer marks it attested after checking the signature
|
|
382
|
+
// under its configured key, and the reader checks it again under the key it trusts for that source. The signature
|
|
383
|
+
// binds this receipt and route, so a verdict moved from another arrival fails here.
|
|
384
|
+
for (const [name, f] of Object.entries(p.facts)) {
|
|
385
|
+
if (f.provenance !== "attested")
|
|
386
|
+
continue;
|
|
387
|
+
const label = `fact ${name} signature (upstream key)`;
|
|
388
|
+
const value = region(["facts", name, "value"]);
|
|
389
|
+
const envPath = ["facts", name, "attestation"];
|
|
390
|
+
const stillWithheld = (note?.withheld ?? []).some((w) => pathKey(w) === pathKey(envPath)) && back.missing.some((w) => pathKey(w) === pathKey(envPath));
|
|
391
|
+
const restored = full.facts[name];
|
|
392
|
+
const env = restored?.attestation;
|
|
393
|
+
const wellFormed = !!env && typeof env === "object" && typeof env.payload === "string" && Array.isArray(env.signatures);
|
|
394
|
+
if (value.problem || value.missing.length)
|
|
395
|
+
add(`fact ${name} signature not checked`, true, "the value is withheld; disclose it or give the capture key to check its signature");
|
|
396
|
+
else if (stillWithheld)
|
|
397
|
+
add(label, false, "the value is in clear but its signature is withheld; disclose it or give the capture key to check it");
|
|
398
|
+
else if (!wellFormed)
|
|
399
|
+
add(label, false, "the fact is marked attested and carries no signature, and the capture note does not say it is withheld");
|
|
400
|
+
else if (!opts.upstreamKeys?.length)
|
|
401
|
+
add(label, false, "the fact is marked attested; give the signer's public key (--upstream-key) to check it");
|
|
402
|
+
else {
|
|
403
|
+
const u = checkUpstream(env, opts.upstreamKeys, { receiptId: p.receiptId, tool: p.tool.name, contentDigest: digestOf(restored.value) });
|
|
404
|
+
add(label, u.ok, u.ok ? `keyid ${short(u.keyid)}` : u.error);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
376
407
|
const evidence = executedOrFailed && "upstream" in p.execution ? p.execution.upstream : undefined;
|
|
377
408
|
if (executedOrFailed && evidence) {
|
|
378
409
|
// The evidence as restored: the delivery body or the signed envelope may have been withheld with the result. A
|
|
@@ -567,10 +598,13 @@ export function auditExtends(older, newer, proof, keys, logId, opts = {}) {
|
|
|
567
598
|
}
|
|
568
599
|
return { ok: checks.every((c) => c.ok), checks, older: a, newer: b };
|
|
569
600
|
}
|
|
601
|
+
/** What kind of evidence the issuer gives; a door answering a proxy's authz check gives a decision only. */
|
|
602
|
+
const issuerNote = (issuer) => (issuer.kind === "door" && issuer.framework === "authz" ? ISSUER_NOTE["door/authz"] : ISSUER_NOTE[issuer.kind] ?? "unknown issuer kind");
|
|
570
603
|
const ISSUER_NOTE = {
|
|
571
604
|
gateway: "enforced outside the agent's process; the agent could neither skip nor forge this receipt",
|
|
572
605
|
sdk: "self-reported by the agent's own process; tamper-evident after issue, but nothing here was enforced outside the agent",
|
|
573
606
|
door: "enforced in front of the business's own HTTP surface; the arriving party could not forge this receipt and is attested only when it presented a grant, and a request that reached the origin some other way leaves no receipt",
|
|
607
|
+
"door/authz": "decided by the door for a proxy in front of the business's own HTTP surface (nginx auth_request or Envoy ext_authz): the receipt records the decision, not the result, since the proxy relayed an allowed request and the door saw neither its body nor the origin's answer; the arriving party could not forge this receipt and is attested only when it presented a grant",
|
|
574
608
|
guardian: "decided by an ACS Guardian outside the agent's process and signed with its own key, so the decision is attributable to it; the call is the agent's own report, and the agent could skip the Guardian or ignore its answer",
|
|
575
609
|
egress: "observed by a forward proxy in the agent's network path, for a connection that went around the gateway: where it went and how much, never what was sent; the agent is known only by the proxy credential the witness checked, and a connection that skipped the proxy (no lockdown) leaves no receipt at all",
|
|
576
610
|
};
|
|
@@ -585,7 +619,7 @@ export function formatReport(r) {
|
|
|
585
619
|
return lines.join("\n");
|
|
586
620
|
const p = r.statement.predicate;
|
|
587
621
|
lines.push("");
|
|
588
|
-
lines.push(`ISSUER: ${p.issuer.kind}${p.issuer.framework ? ` (${p.issuer.framework})` : ""}${p.issuer.strict ? ", strict mode" : ""}, ${
|
|
622
|
+
lines.push(`ISSUER: ${p.issuer.kind}${p.issuer.framework ? ` (${p.issuer.framework})` : ""}${p.issuer.strict ? ", strict mode" : ""}, ${issuerNote(p.issuer)}`);
|
|
589
623
|
lines.push("");
|
|
590
624
|
lines.push("field provenance value");
|
|
591
625
|
const row = (f, prov, v) => lines.push(`${f.padEnd(15)} ${prov.padEnd(11)} ${typeof v === "string" ? v : JSON.stringify(v)}`);
|
|
@@ -597,8 +631,14 @@ export function formatReport(r) {
|
|
|
597
631
|
row("model", p.model.provenance, p.model.id === null ? "(none supplied)" : idText(p.model.id));
|
|
598
632
|
row("tool", p.tool.provenance, p.tool.name);
|
|
599
633
|
row("args", p.request.provenance, p.request.args);
|
|
600
|
-
for (const [k, f] of Object.entries(p.facts))
|
|
601
|
-
|
|
634
|
+
for (const [k, f] of Object.entries(p.facts)) {
|
|
635
|
+
if (f.provenance !== "attested") {
|
|
636
|
+
row(`fact.${k}`, f.provenance, f.value);
|
|
637
|
+
continue;
|
|
638
|
+
}
|
|
639
|
+
const signed = r.checks.find((c) => c.name === `fact ${k} signature (upstream key)`);
|
|
640
|
+
row(`fact.${k}`, f.provenance, `${JSON.stringify(f.value)}${signed ? (signed.ok ? ` (signed by ${signed.detail})` : " (signature FAILED)") : " (signature not checked)"}`);
|
|
641
|
+
}
|
|
602
642
|
if (p.reconciliation)
|
|
603
643
|
row("policy", "-", "(none evaluated: a provider read, not a call)");
|
|
604
644
|
else if (p.policy)
|
|
@@ -611,7 +651,7 @@ export function formatReport(r) {
|
|
|
611
651
|
const committed = r.checks.filter((c) => c.name.startsWith("authorization ")).every((c) => c.ok);
|
|
612
652
|
row("authorization", "observed", committed ? `committed to the log as leaf ${p.authorization.inclusion.leafIndex}, before the call was forwarded` : "carried, but its checks FAILED");
|
|
613
653
|
}
|
|
614
|
-
else if (p.execution.status === "withheld" && p.issuer.kind !== "guardian")
|
|
654
|
+
else if (p.execution.status === "withheld" && p.issuer.kind !== "guardian" && !(p.issuer.kind === "door" && p.issuer.framework === "authz"))
|
|
615
655
|
row("authorization", "observed", "the log would not commit it; the call was not forwarded");
|
|
616
656
|
if (p.approval)
|
|
617
657
|
row("approval", p.approval.provenance, `${p.approval.status}; ${p.approval.requiredApprovers} approver(s) required${p.approval.consumedAt ? `; consumed ${p.approval.consumedAt}` : ""}${typeof p.approval.reason === "string" ? `; ${p.approval.reason}` : ""}`);
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
export declare const DIRECTORY_PATH = "/.well-known/http-message-signatures-directory";
|
|
2
|
+
export declare const DIRECTORY_MEDIA_TYPE = "application/http-message-signatures-directory+json";
|
|
3
|
+
export declare const WEB_BOT_AUTH_TAG = "web-bot-auth";
|
|
4
|
+
export type BareItem = {
|
|
5
|
+
t: "string";
|
|
6
|
+
v: string;
|
|
7
|
+
} | {
|
|
8
|
+
t: "token";
|
|
9
|
+
v: string;
|
|
10
|
+
} | {
|
|
11
|
+
t: "integer";
|
|
12
|
+
v: number;
|
|
13
|
+
} | {
|
|
14
|
+
t: "decimal";
|
|
15
|
+
v: number;
|
|
16
|
+
} | {
|
|
17
|
+
t: "bytes";
|
|
18
|
+
v: Buffer;
|
|
19
|
+
} | {
|
|
20
|
+
t: "boolean";
|
|
21
|
+
v: boolean;
|
|
22
|
+
};
|
|
23
|
+
export type Params = [string, BareItem][];
|
|
24
|
+
export interface SfItem {
|
|
25
|
+
item: BareItem;
|
|
26
|
+
params: Params;
|
|
27
|
+
}
|
|
28
|
+
export interface SfInnerList {
|
|
29
|
+
list: SfItem[];
|
|
30
|
+
params: Params;
|
|
31
|
+
}
|
|
32
|
+
export type SfMember = SfItem | SfInnerList;
|
|
33
|
+
/** An RFC 8941 dictionary. A later member of the same name replaces an earlier one, as the RFC says. */
|
|
34
|
+
export declare function parseDictionary(text: string): Map<string, SfMember>;
|
|
35
|
+
/** An RFC 8941 item on its own, such as a legacy `Signature-Agent: "https://..."`. */
|
|
36
|
+
export declare function parseItem(text: string): SfItem;
|
|
37
|
+
export declare const serializeMember: (m: SfMember) => string;
|
|
38
|
+
/** What a signature base is built from: the request as the door received it. */
|
|
39
|
+
export interface SignedRequest {
|
|
40
|
+
method: string;
|
|
41
|
+
/** the request target as received, path and query, never decoded */
|
|
42
|
+
target: string;
|
|
43
|
+
/** the authority the request was sent to, normalised (`normalizeAuthority`) */
|
|
44
|
+
authority: string;
|
|
45
|
+
/** every value of a header field, lowercase name; undefined when the field is absent */
|
|
46
|
+
header(name: string): string[] | undefined;
|
|
47
|
+
}
|
|
48
|
+
/** A host as RFC 9421 compares it: lowercase, without the default port of https or http. */
|
|
49
|
+
export declare function normalizeAuthority(host: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* The RFC 9421 signature base (section 2.5) for the covered components and their parameters. Supports `@method`,
|
|
52
|
+
* `@authority`, `@path`, `@query`, and header fields, whole or one dictionary member (`;key`). Any other derived
|
|
53
|
+
* component or component parameter is refused rather than guessed at.
|
|
54
|
+
*/
|
|
55
|
+
export declare function signatureBase(req: SignedRequest, input: SfInnerList): string;
|
|
56
|
+
/** The RFC 7638 thumbprint of an Ed25519 JWK (RFC 8037 appendix A.3): the base64url SHA-256 of `{"crv","kty","x"}`. */
|
|
57
|
+
export declare function jwkThumbprint(x: string): string;
|
|
58
|
+
export interface WebBotAuthOptions {
|
|
59
|
+
/** the signature agents, as https origins, whose directories the door may fetch; any other is refused unfetched */
|
|
60
|
+
agents: string[];
|
|
61
|
+
/** the authorities this door serves; a signature covering any other `@authority` is refused */
|
|
62
|
+
authorities: string[];
|
|
63
|
+
requireNonce: boolean;
|
|
64
|
+
maxAgeSeconds: number;
|
|
65
|
+
clockSkewSeconds: number;
|
|
66
|
+
timeoutMs: number;
|
|
67
|
+
maxDirectoryBytes: number;
|
|
68
|
+
cacheSeconds: number;
|
|
69
|
+
maxNonces: number;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* What the door made of a request's signature. `verified`: a signature tagged `web-bot-auth` checked against a key
|
|
73
|
+
* that `agent`'s directory publishes. `invalid`: the signature, its parameters, its agent, or the directory was wrong.
|
|
74
|
+
* `unavailable`: the directory could not be fetched, or the door could not record the nonce. `unchecked`: a signature
|
|
75
|
+
* arrived and the door has no `webBotAuth` config. `absent`: no `Signature-Input`.
|
|
76
|
+
*/
|
|
77
|
+
export type SignatureCheck = {
|
|
78
|
+
outcome: "verified";
|
|
79
|
+
agent: string;
|
|
80
|
+
keyid: string;
|
|
81
|
+
label: string;
|
|
82
|
+
} | {
|
|
83
|
+
outcome: "invalid" | "unavailable";
|
|
84
|
+
error: string;
|
|
85
|
+
agent?: string;
|
|
86
|
+
keyid?: string;
|
|
87
|
+
} | {
|
|
88
|
+
outcome: "unchecked" | "absent";
|
|
89
|
+
};
|
|
90
|
+
export interface WebBotAuthVerifier {
|
|
91
|
+
verify(req: SignedRequest): Promise<SignatureCheck>;
|
|
92
|
+
/** nonces held now */
|
|
93
|
+
nonces(): number;
|
|
94
|
+
}
|
|
95
|
+
/** A response body up to `max` bytes; null when it passes that, and the rest is not read. */
|
|
96
|
+
export declare function readCapped(res: Response, max: number): Promise<Buffer | null>;
|
|
97
|
+
/** An https origin with nothing after it, as the config holds it; throws on anything else. */
|
|
98
|
+
export declare function agentOrigin(uri: string): string;
|
|
99
|
+
/**
|
|
100
|
+
* Checks Web Bot Auth signatures. The directory of each configured agent is fetched from
|
|
101
|
+
* `<origin>/.well-known/http-message-signatures-directory` over https, never following a redirect, within `timeoutMs`
|
|
102
|
+
* and `maxDirectoryBytes`, and kept for `cacheSeconds` (a failure for 30 seconds). A nonce is remembered until the
|
|
103
|
+
* signature it came with could no longer be accepted, so a signature serves one request. `now` is for tests.
|
|
104
|
+
*/
|
|
105
|
+
export declare function createWebBotAuthVerifier(opts: WebBotAuthOptions, f: typeof fetch, now?: () => number): WebBotAuthVerifier;
|