@agent-custody/receipts 0.16.10 → 0.16.12
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 +32 -12
- package/dist/approval-requests.d.ts +114 -0
- package/dist/approval-requests.js +198 -0
- package/dist/approval.d.ts +8 -0
- package/dist/approval.js +10 -3
- package/dist/check.js +14 -0
- package/dist/cli.js +184 -5
- package/dist/completeness.d.ts +11 -2
- package/dist/completeness.js +45 -9
- package/dist/config.d.ts +6 -0
- package/dist/config.js +19 -1
- package/dist/console-page.js +87 -2
- package/dist/console.js +72 -0
- package/dist/crypto.d.ts +2 -0
- package/dist/crypto.js +2 -1
- package/dist/delegation.d.ts +1 -1
- package/dist/delegation.js +19 -2
- package/dist/did-key.d.ts +2 -0
- package/dist/did-key.js +21 -1
- package/dist/door-app.js +1 -1
- package/dist/door-core.d.ts +385 -0
- package/dist/door-core.js +757 -0
- package/dist/door-error-rates.d.ts +102 -0
- package/dist/door-error-rates.js +178 -0
- package/dist/door-form.d.ts +7 -2
- package/dist/door-form.js +52 -4
- package/dist/door-measure.d.ts +153 -0
- package/dist/door-measure.js +325 -0
- package/dist/door-signals.d.ts +414 -0
- package/dist/door-signals.js +555 -0
- package/dist/door-test-set.d.ts +43 -0
- package/dist/door-test-set.js +117 -0
- package/dist/door-worker.d.ts +148 -0
- package/dist/door-worker.js +283 -0
- package/dist/door.d.ts +11 -293
- package/dist/door.js +45 -755
- package/dist/gateway-http.d.ts +1 -6
- package/dist/gateway-http.js +2 -19
- package/dist/gateway.js +24 -3
- package/dist/grant-header.d.ts +8 -0
- package/dist/grant-header.js +19 -0
- package/dist/index.d.ts +11 -2
- package/dist/index.js +6 -1
- package/dist/issue.d.ts +2 -16
- package/dist/issue.js +2 -12
- package/dist/lock.d.ts +5 -0
- package/dist/lock.js +1 -1
- package/dist/log-http.d.ts +37 -0
- package/dist/log-http.js +74 -0
- package/dist/log-sink.d.ts +3 -37
- package/dist/log-sink.js +5 -71
- package/dist/log.d.ts +2 -27
- package/dist/log.js +2 -173
- package/dist/merkle.d.ts +27 -0
- package/dist/merkle.js +175 -0
- package/dist/object-issuer.d.ts +29 -0
- package/dist/object-issuer.js +172 -0
- package/dist/receipt-pending.d.ts +16 -0
- package/dist/receipt-pending.js +14 -0
- package/dist/web-bot-auth.d.ts +26 -6
- package/dist/web-bot-auth.js +116 -56
- package/docs/approvals.md +33 -0
- package/docs/completeness.md +44 -5
- package/docs/console.md +11 -4
- package/docs/door-error-rates.md +490 -0
- package/docs/door-languages.md +3 -1
- package/docs/door-middleware.md +6 -1
- package/docs/door-quickstart.md +53 -17
- package/docs/door-signals.md +117 -7
- package/docs/door-worker.md +94 -0
- package/docs/door.md +41 -12
- package/docs/github-action.md +2 -2
- package/docs/tutorials.md +6 -0
- package/docs/verification.md +1 -1
- package/package.json +4 -1
- package/vectors/audit.json +27 -27
- package/vectors/canonical.json +5 -5
- package/vectors/receipts.json +1645 -1549
package/dist/console.js
CHANGED
|
@@ -8,6 +8,8 @@ import { createHash, timingSafeEqual } from "node:crypto";
|
|
|
8
8
|
import { appendFileSync, closeSync, existsSync, mkdirSync, openSync, readdirSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
9
9
|
import { createServer } from "node:http";
|
|
10
10
|
import { basename, dirname, join } from "node:path";
|
|
11
|
+
import { DEFAULT_APPROVAL_LIFETIME_SECONDS } from "./approval.js";
|
|
12
|
+
import { approvalRequestPayload, denyApprovalRequest, listApprovalRequests, signApprovalRequest } from "./approval-requests.js";
|
|
11
13
|
import { checkConfig } from "./check.js";
|
|
12
14
|
import { loadConfig } from "./config.js";
|
|
13
15
|
import { loadPrivateKey, loadPublicKey } from "./crypto.js";
|
|
@@ -425,6 +427,54 @@ export async function serveConsole(options) {
|
|
|
425
427
|
audit("grant.revoke", { agent: decoded.agent, principal: decoded.principal, digest, already: list.includes(digest) }, by);
|
|
426
428
|
return { digest, agent: decoded.agent, note: "the gateway refuses this grant, and every grant delegated from it, on its next call" };
|
|
427
429
|
},
|
|
430
|
+
"GET /api/approvals": async () => {
|
|
431
|
+
const cfg = loadConfig(options.configFile);
|
|
432
|
+
const dir = cfg.approvals?.requests?.dir;
|
|
433
|
+
if (!dir)
|
|
434
|
+
return { configured: false };
|
|
435
|
+
const all = listApprovalRequests(dir);
|
|
436
|
+
const shown = [...all.filter((r) => r.status === "pending"), ...all.filter((r) => r.status !== "pending").reverse().slice(0, 50)];
|
|
437
|
+
return {
|
|
438
|
+
configured: true,
|
|
439
|
+
maxLifetimeSeconds: cfg.approvals.maxLifetimeSeconds ?? DEFAULT_APPROVAL_LIFETIME_SECONDS,
|
|
440
|
+
trustedKeyids: approverKeys(cfg).map((k) => k.keyid),
|
|
441
|
+
requests: shown.map((r) => ({
|
|
442
|
+
requestId: r.requestId, status: r.status, createdAt: r.createdAt, decidedAt: r.decidedAt ?? null, receiptId: r.receiptId,
|
|
443
|
+
principal: r.binding.principal, agent: r.binding.agent, tool: r.binding.tool, arguments: r.binding.args, fields: r.binding.fields ?? null,
|
|
444
|
+
requiredApprovers: r.requiredApprovers, signedBy: r.envelope?.signatures.map((s) => s.keyid) ?? [], reason: r.reason ?? null,
|
|
445
|
+
})),
|
|
446
|
+
};
|
|
447
|
+
},
|
|
448
|
+
// The console signs nothing: the browser signs these bytes with the approver's key, which never reaches the server.
|
|
449
|
+
"POST /api/approvals/prepare": async (req) => {
|
|
450
|
+
const body = object(await readBody(req));
|
|
451
|
+
const { dir, cfg } = requestsDir();
|
|
452
|
+
const max = cfg.approvals.maxLifetimeSeconds ?? DEFAULT_APPROVAL_LIFETIME_SECONDS;
|
|
453
|
+
const seconds = body.expiresInSeconds;
|
|
454
|
+
if (typeof seconds !== "number" || !Number.isInteger(seconds) || seconds <= 0 || seconds > max)
|
|
455
|
+
throw new HttpError(400, `expiresInSeconds is a whole number of seconds from 1 to ${max}, the gateway's approvals.maxLifetimeSeconds`);
|
|
456
|
+
return decided(() => approvalRequestPayload(dir, requestIdOf(body), { expiresAt: new Date(Date.now() + seconds * 1000).toISOString() }));
|
|
457
|
+
},
|
|
458
|
+
"POST /api/approvals/sign": async (req, _url, by) => {
|
|
459
|
+
const body = object(await readBody(req));
|
|
460
|
+
const { dir, cfg } = requestsDir();
|
|
461
|
+
const requestId = requestIdOf(body);
|
|
462
|
+
for (const f of ["payload", "keyid", "sig"])
|
|
463
|
+
if (typeof body[f] !== "string" || !body[f])
|
|
464
|
+
throw new HttpError(400, `send ${f} as a string`);
|
|
465
|
+
const r = decided(() => signApprovalRequest(dir, requestId, { payload: body.payload, keyid: body.keyid, sig: body.sig }, approverKeys(cfg), { maxLifetimeSeconds: cfg.approvals.maxLifetimeSeconds ?? DEFAULT_APPROVAL_LIFETIME_SECONDS }));
|
|
466
|
+
audit("approval.sign", { requestId, agent: r.binding.agent, tool: r.binding.tool, keyid: body.keyid, status: r.status }, by);
|
|
467
|
+
return { status: r.status, note: r.status === "approved" ? `Approved. ${r.binding.agent} may send ${r.binding.tool} with exactly these arguments, once.` : "Signed. It needs a second approver with a different key." };
|
|
468
|
+
},
|
|
469
|
+
"POST /api/approvals/deny": async (req, _url, by) => {
|
|
470
|
+
const body = object(await readBody(req));
|
|
471
|
+
const { dir } = requestsDir();
|
|
472
|
+
const requestId = requestIdOf(body);
|
|
473
|
+
const reason = typeof body.reason === "string" && body.reason.trim() ? body.reason.trim() : undefined;
|
|
474
|
+
const r = decided(() => denyApprovalRequest(dir, requestId, reason ? { reason } : {}));
|
|
475
|
+
audit("approval.deny", { requestId, agent: r.binding.agent, tool: r.binding.tool, ...(reason ? { reason } : {}) }, by);
|
|
476
|
+
return { status: r.status, note: "Denied. The gateway refuses that exact call, and tells the agent so, until the request is deleted." };
|
|
477
|
+
},
|
|
428
478
|
"GET /api/revocations": async () => ({ digests: revokedList(loadConfig(options.configFile)) }),
|
|
429
479
|
"GET /api/receipts": async (_req, url) => {
|
|
430
480
|
const cfg = loadConfig(options.configFile);
|
|
@@ -437,6 +487,28 @@ export async function serveConsole(options) {
|
|
|
437
487
|
entries: existsSync(auditFile) ? readFileSync(auditFile, "utf8").trim().split("\n").filter(Boolean).slice(-200).reverse().map((l) => JSON.parse(l)) : [],
|
|
438
488
|
}),
|
|
439
489
|
};
|
|
490
|
+
const approverKeys = (cfg) => (cfg.approvals?.trustedKeys ?? []).map(loadPublicKey);
|
|
491
|
+
const requestsDir = () => {
|
|
492
|
+
const cfg = loadConfig(options.configFile);
|
|
493
|
+
const dir = cfg.approvals?.requests?.dir;
|
|
494
|
+
if (!dir)
|
|
495
|
+
throw new HttpError(409, "the config has no approvals.requests.dir, which is where the gateway leaves approval requests");
|
|
496
|
+
return { dir, cfg };
|
|
497
|
+
};
|
|
498
|
+
const requestIdOf = (body) => {
|
|
499
|
+
if (typeof body.requestId !== "string" || !/^[0-9a-f]{32}$/.test(body.requestId))
|
|
500
|
+
throw new HttpError(400, "a request id is 32 hex characters");
|
|
501
|
+
return body.requestId;
|
|
502
|
+
};
|
|
503
|
+
// a request that is gone, already decided, or a signature that does not verify is the caller's conflict, not a crash
|
|
504
|
+
const decided = (f) => {
|
|
505
|
+
try {
|
|
506
|
+
return f();
|
|
507
|
+
}
|
|
508
|
+
catch (e) {
|
|
509
|
+
throw new HttpError(409, e instanceof Error ? e.message : String(e));
|
|
510
|
+
}
|
|
511
|
+
};
|
|
440
512
|
const safeJson = (s) => {
|
|
441
513
|
try {
|
|
442
514
|
return JSON.parse(s);
|
package/dist/crypto.d.ts
CHANGED
|
@@ -33,6 +33,8 @@ export interface Envelope {
|
|
|
33
33
|
sig: string;
|
|
34
34
|
}[];
|
|
35
35
|
}
|
|
36
|
+
/** The DSSE pre-authentication encoding: the bytes a DSSE signature is made over. */
|
|
37
|
+
export declare function pae(payloadType: string, payload: Buffer): Buffer;
|
|
36
38
|
export declare function dsseSign(payloadType: string, payloadObj: unknown, kp: KeyPair): Envelope;
|
|
37
39
|
/** Adds a signature over the same payload: a countersignature, the DSSE way. The envelope keeps every earlier signature. */
|
|
38
40
|
export declare function dsseCountersign(env: Envelope, kp: KeyPair): Envelope;
|
package/dist/crypto.js
CHANGED
|
@@ -64,7 +64,8 @@ export function publicKeyFromPem(pem) {
|
|
|
64
64
|
const publicKey = createPublicKey(pem);
|
|
65
65
|
return { publicKey, keyid: keyidOf(publicKey) };
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
/** The DSSE pre-authentication encoding: the bytes a DSSE signature is made over. */
|
|
68
|
+
export function pae(payloadType, payload) {
|
|
68
69
|
const header = `DSSEv1 ${Buffer.byteLength(payloadType)} ${payloadType} ${payload.length} `;
|
|
69
70
|
return Buffer.concat([Buffer.from(header), payload]);
|
|
70
71
|
}
|
package/dist/delegation.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ export type DelegationVerifyResult = {
|
|
|
52
52
|
error: string;
|
|
53
53
|
};
|
|
54
54
|
/** Verifies a grant, walking its chain to a grant signed by one of the trusted principal keys. */
|
|
55
|
-
export declare function verifyDelegation(env: Envelope, trustedPrincipals: PublicKeyRef[]
|
|
55
|
+
export declare function verifyDelegation(env: Envelope, trustedPrincipals: PublicKeyRef[]): DelegationVerifyResult;
|
|
56
56
|
/** True when `at` (ISO) lies inside the grant's validity window. */
|
|
57
57
|
/**
|
|
58
58
|
* What names a grant for revocation: sha256 over the payload its signature covers. Extra signatures or envelope fields
|
package/dist/delegation.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
// parent's, and the principal is the same throughout. The receipt then names the sub-agent as the agent and the
|
|
7
7
|
// principal as the principal, exactly as with a direct grant, and the whole chain travels inside the receipt.
|
|
8
8
|
import { z } from "zod";
|
|
9
|
+
import { DID_KEY_PREFIX, didKeyAgentFault } from "./did-key.js";
|
|
9
10
|
import { dsseSign, dsseVerify, publicKeyFromPem, sha256Hex } from "./crypto.js";
|
|
10
11
|
export const DELEGATION_TYPE = "application/vnd.agent-custody.delegation+json";
|
|
11
12
|
/** the longest chain a verifier walks: the principal's grant and up to three delegations below it */
|
|
@@ -68,7 +69,23 @@ export function delegateFrom(parent, agentKey, sub) {
|
|
|
68
69
|
return createDelegation(agentKey, { version: "0.1", principal: p.principal, agent: sub.agent, scopes: sub.scopes, issuedAt, expiresAt, ...(sub.agentKey ? { agentKey: sub.agentKey } : {}), parent });
|
|
69
70
|
}
|
|
70
71
|
/** Verifies a grant, walking its chain to a grant signed by one of the trusted principal keys. */
|
|
71
|
-
export function verifyDelegation(env, trustedPrincipals
|
|
72
|
+
export function verifyDelegation(env, trustedPrincipals) {
|
|
73
|
+
const checked = verifyChain(env, trustedPrincipals, 1);
|
|
74
|
+
if (!checked.ok)
|
|
75
|
+
return checked;
|
|
76
|
+
// An agent named by a did:key is its key: the identifier must decode to an Ed25519 key, and the grant's agentKey, if
|
|
77
|
+
// it names one, must be that key, or the grant says two things about who the agent is. Every link of a chain, since a
|
|
78
|
+
// parent's agentKey is what verified the link below it.
|
|
79
|
+
for (const [i, link] of checked.chain.entries()) {
|
|
80
|
+
if (!link.agent.startsWith(DID_KEY_PREFIX))
|
|
81
|
+
continue;
|
|
82
|
+
const fault = didKeyAgentFault(link.agent, link.agentKey);
|
|
83
|
+
if (fault)
|
|
84
|
+
return { ok: false, error: (i === checked.chain.length - 1 ? "" : `link ${i} (${link.agent}): `) + fault };
|
|
85
|
+
}
|
|
86
|
+
return checked;
|
|
87
|
+
}
|
|
88
|
+
function verifyChain(env, trustedPrincipals, depth) {
|
|
72
89
|
if (env.payloadType !== DELEGATION_TYPE)
|
|
73
90
|
return { ok: false, error: `unexpected payloadType ${env.payloadType}` };
|
|
74
91
|
if (depth > MAX_DELEGATION_DEPTH)
|
|
@@ -85,7 +102,7 @@ export function verifyDelegation(env, trustedPrincipals, depth = 1) {
|
|
|
85
102
|
return { ok: false, error: `invalid delegation: ${parsed.error.message}` };
|
|
86
103
|
return { ok: true, delegation: parsed.data, keyid: r.keyid, chain: [parsed.data] };
|
|
87
104
|
}
|
|
88
|
-
const up =
|
|
105
|
+
const up = verifyChain(unverified.parent, trustedPrincipals, depth + 1);
|
|
89
106
|
if (!up.ok)
|
|
90
107
|
return { ok: false, error: `link ${depth}: ${up.error}` };
|
|
91
108
|
const parent = up.delegation;
|
package/dist/did-key.d.ts
CHANGED
|
@@ -7,3 +7,5 @@ export declare function base58btcDecode(text: string): Uint8Array;
|
|
|
7
7
|
export declare function didKeyOf(publicKey: KeyObject): string;
|
|
8
8
|
/** The Ed25519 key a did:key names; throws, saying why, when it does not decode to one. */
|
|
9
9
|
export declare function publicKeyFromDidKey(did: string): PublicKeyRef;
|
|
10
|
+
/** Why a did:key agent does not check out, or null when it decodes and agrees with the grant's agentKey. */
|
|
11
|
+
export declare function didKeyAgentFault(did: string, agentKey: string | undefined): string | null;
|
package/dist/did-key.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// multicodec prefix for ed25519-pub (0xed 0x01) and the 32-byte public key. The identifier is the key: anyone can
|
|
3
3
|
// derive the key from it, and nothing about it says who holds the key or whether a principal trusts it.
|
|
4
4
|
import { createPublicKey } from "node:crypto";
|
|
5
|
-
import { keyidOf } from "./crypto.js";
|
|
5
|
+
import { keyidOf, publicKeyFromPem } from "./crypto.js";
|
|
6
6
|
const ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
7
7
|
const ED25519_PUB = [0xed, 0x01];
|
|
8
8
|
export const DID_KEY_PREFIX = "did:key:";
|
|
@@ -64,3 +64,23 @@ export function publicKeyFromDidKey(did) {
|
|
|
64
64
|
const publicKey = createPublicKey({ key: { kty: "OKP", crv: "Ed25519", x: Buffer.from(bytes.subarray(2)).toString("base64url") }, format: "jwk" });
|
|
65
65
|
return { publicKey, keyid: keyidOf(publicKey) };
|
|
66
66
|
}
|
|
67
|
+
/** Why a did:key agent does not check out, or null when it decodes and agrees with the grant's agentKey. */
|
|
68
|
+
export function didKeyAgentFault(did, agentKey) {
|
|
69
|
+
let named;
|
|
70
|
+
try {
|
|
71
|
+
named = publicKeyFromDidKey(did);
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
return `the grant's did:key agent does not decode: ${e instanceof Error ? e.message : String(e)}`;
|
|
75
|
+
}
|
|
76
|
+
if (agentKey === undefined)
|
|
77
|
+
return null;
|
|
78
|
+
try {
|
|
79
|
+
if (publicKeyFromPem(agentKey).keyid === named.keyid)
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return "the grant's agentKey is not a public key";
|
|
84
|
+
}
|
|
85
|
+
return "the grant's agentKey is not the key its did:key agent names";
|
|
86
|
+
}
|
package/dist/door-app.js
CHANGED
|
@@ -113,7 +113,7 @@ export function door(config, options = {}) {
|
|
|
113
113
|
if (cfg.authz)
|
|
114
114
|
throw new Error("the in-process door passes an allowed request to the app it runs in; authz is for the door answering nginx or Envoy checks (`agent-custody door`)");
|
|
115
115
|
const core = createDoorCore(cfg, { ...options, autoFlush: options.autoFlush ?? true }, MIDDLEWARE_FRAMEWORK);
|
|
116
|
-
const script = cfg.challenge ? formScript(cfg.challenge) : null;
|
|
116
|
+
const script = cfg.challenge ? formScript(cfg.challenge, !!cfg.behaviour) : null;
|
|
117
117
|
const middleware = (req, res, next) => {
|
|
118
118
|
// the script is public and the same for every arrival: served, not decided or receipted
|
|
119
119
|
if (script && req.method === "GET" && (req.url ?? "").split("?")[0] === FORM_SCRIPT_PATH) {
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
import type { IncomingHttpHeaders } from "node:http";
|
|
2
|
+
import type { CaptureConfig } from "./capture.ts";
|
|
3
|
+
import type { DoorConfig, DoorRouteConfig } from "./config.ts";
|
|
4
|
+
import { type Envelope, type KeyPair, type PublicKeyRef } from "./crypto.ts";
|
|
5
|
+
import { type Delegation } from "./delegation.ts";
|
|
6
|
+
import type { Issuer } from "./issue.ts";
|
|
7
|
+
import { type FlushResult } from "./receipt-pending.ts";
|
|
8
|
+
import { type NonceStore, type SignatureCheck, type SignedRequest } from "./web-bot-auth.ts";
|
|
9
|
+
import { type ArrivalBehaviour, type ArrivalFingerprint, type TlsObservation } from "./door-signals.ts";
|
|
10
|
+
import { type ArrivalPartner } from "./door-partner.ts";
|
|
11
|
+
import type { AuthorizationBundle, ReceiptPredicate } from "./receipt.ts";
|
|
12
|
+
export declare const DOOR_VERSION = "0.1.0";
|
|
13
|
+
/** on every answer the door gives: the receipt that records the decision */
|
|
14
|
+
export declare const RECEIPT_HEADER = "x-agent-custody-receipt";
|
|
15
|
+
/** on every answer: `verified`, `claimed`, or `unknown`, what the door made of the arrival */
|
|
16
|
+
export declare const CLASS_HEADER = "x-agent-custody-class";
|
|
17
|
+
/** the fact the door records for every arrival, and the policy reads as `context.facts.arrival` */
|
|
18
|
+
export declare const ARRIVAL_FACT = "arrival";
|
|
19
|
+
/** the header an agent may use to name itself without a grant; recorded as claimed, never checked */
|
|
20
|
+
export declare const AGENT_HEADER = "x-agent-custody-agent";
|
|
21
|
+
/** in authz mode: the original request's method and target, as nginx `auth_request` and Envoy `ext_authz` are configured to send them */
|
|
22
|
+
export declare const ORIGINAL_METHOD_HEADER = "x-original-method";
|
|
23
|
+
export declare const ORIGINAL_URI_HEADER = "x-original-uri";
|
|
24
|
+
/** the reason an allowed authz receipt carries: the door decided, and the proxy, not the door, relays */
|
|
25
|
+
export declare const AUTHZ_ALLOWED_REASON = "allowed; the door answered the proxy's authz check and relays nothing: the proxy relays the request, and the door sees neither its body nor the origin's answer";
|
|
26
|
+
export type ArrivalClass = "verified" | "claimed" | "unknown";
|
|
27
|
+
/** What the door observed about one arrival. Every field is the door's own observation; none is the caller's claim about itself except `declared`, which says so. */
|
|
28
|
+
export interface Arrival {
|
|
29
|
+
class: ArrivalClass;
|
|
30
|
+
/** the agent named in a verified grant, else the signature agent of a verified signature, else the name the caller declared, else "unknown" */
|
|
31
|
+
subject: string;
|
|
32
|
+
/**
|
|
33
|
+
* What became of the grant header: a trusted grant in scope for this route, one out of scope, one that did not verify,
|
|
34
|
+
* one revoked (`revoked`: it, or a grant above it in its chain, is in `revokedGrants`, or that file cannot be read),
|
|
35
|
+
* one presented by another agent (`wrong-sender`: the request is signed by a signature agent, or a did:key, the grant does not name),
|
|
36
|
+
* or none.
|
|
37
|
+
*/
|
|
38
|
+
grant: "verified" | "out-of-scope" | "invalid" | "revoked" | "wrong-sender" | "absent";
|
|
39
|
+
grantError?: string;
|
|
40
|
+
/** What became of an RFC 9421 signature tagged `web-bot-auth`: see `SignatureCheck`. `unchecked` when the door has no `webBotAuth` config */
|
|
41
|
+
signature: SignatureCheck["outcome"];
|
|
42
|
+
/** the `Signature-Agent` origin, or the did:key that is the signature's keyid; checked only when `signature` is `verified` */
|
|
43
|
+
signatureAgent?: string;
|
|
44
|
+
/** the signature's keyid, the RFC 7638 thumbprint of the agent's key, or a did:key; checked only when `signature` is `verified` */
|
|
45
|
+
signatureKeyid?: string;
|
|
46
|
+
signatureError?: string;
|
|
47
|
+
/** the agent name from the `x-agent-custody-agent` header, when sent; a claim */
|
|
48
|
+
declared?: string;
|
|
49
|
+
remote: string;
|
|
50
|
+
method: string;
|
|
51
|
+
path: string;
|
|
52
|
+
route: string;
|
|
53
|
+
/** how often this source has arrived lately, counted by this door process; set by the door, absent from `classifyArrival` alone */
|
|
54
|
+
rate?: ArrivalRate;
|
|
55
|
+
/** what became of the challenge token, when the door is configured to challenge; absent otherwise, and from `classifyArrival` alone */
|
|
56
|
+
challenge?: ArrivalChallenge;
|
|
57
|
+
/** what became of the question to the partner engine, when the door asks one about this route; absent otherwise, and from `classifyArrival` alone. The verdict itself is the `partner` fact, present only when `outcome` is `verified` */
|
|
58
|
+
partner?: ArrivalPartner;
|
|
59
|
+
/** what the request and its connection look like, when the door has `behaviour` configured; absent otherwise, and from `classifyArrival` alone. Signals, never a verdict (door-signals.ts) */
|
|
60
|
+
fingerprint?: ArrivalFingerprint;
|
|
61
|
+
/** how the source acts over time, when the door has `behaviour` configured; absent otherwise, and from `classifyArrival` alone */
|
|
62
|
+
behaviour?: ArrivalBehaviour;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The outcome of a human challenge. `passed`: the provider confirmed the token, so the provider judged a person present
|
|
66
|
+
* at the time it was solved. `failed`: the provider refused it, with its error codes. `unavailable`: the provider did
|
|
67
|
+
* not answer in time. `absent`: no token was sent. A passed challenge does not change `class`: it says nothing about who
|
|
68
|
+
* the arrival is, only that a provider's test was passed in front of it.
|
|
69
|
+
*/
|
|
70
|
+
export interface ArrivalChallenge {
|
|
71
|
+
provider: "turnstile" | "hcaptcha";
|
|
72
|
+
outcome: "passed" | "failed" | "unavailable" | "absent";
|
|
73
|
+
error?: string;
|
|
74
|
+
}
|
|
75
|
+
/** a provider token is about 2 KB; a longer value is refused as failed without calling the provider */
|
|
76
|
+
export declare const MAX_CHALLENGE_TOKEN = 4096;
|
|
77
|
+
export interface ChallengeCheck {
|
|
78
|
+
provider: "turnstile" | "hcaptcha";
|
|
79
|
+
secret: string;
|
|
80
|
+
token: string;
|
|
81
|
+
/** the client's address, sent as `remoteip` only when the door knows it is the client's and not a proxy's */
|
|
82
|
+
remoteIp?: string;
|
|
83
|
+
/** the hostnames of the pages that render the widget, lowercase */
|
|
84
|
+
hostnames: string[];
|
|
85
|
+
/** the widget's action, when one is required (Turnstile) */
|
|
86
|
+
action?: string;
|
|
87
|
+
/** the public site key; sent to hCaptcha, whose secret belongs to the account, so a token from another of its site keys is refused */
|
|
88
|
+
siteKey?: string;
|
|
89
|
+
timeoutMs: number;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Asks the provider whether the token is good. The token and the secret go to the provider only; neither is recorded,
|
|
93
|
+
* and a redirect is never followed, since it would resend both to the Location's host. `success` is not enough: the
|
|
94
|
+
* token must have been issued on one of the site's own hostnames, and for the configured action, or a token solved on
|
|
95
|
+
* another site with this site key, or for another widget, would pass.
|
|
96
|
+
*/
|
|
97
|
+
export declare function verifyChallengeToken(check: ChallengeCheck, f: typeof fetch): Promise<ArrivalChallenge>;
|
|
98
|
+
/**
|
|
99
|
+
* Arrivals from one source in the last 10 seconds (`burst`) and 60 seconds (`minute`), this one included, whatever the
|
|
100
|
+
* policy decided about them. The source is the agent a verified grant names, else the arrival's address. One process's
|
|
101
|
+
* memory: the count starts at one when the door starts, and two doors do not share it.
|
|
102
|
+
*/
|
|
103
|
+
export interface ArrivalRate {
|
|
104
|
+
by: "agent" | "remote";
|
|
105
|
+
burst: number;
|
|
106
|
+
minute: number;
|
|
107
|
+
}
|
|
108
|
+
export declare const RATE_BURST_MS = 10000;
|
|
109
|
+
export declare const RATE_MINUTE_MS = 60000;
|
|
110
|
+
export interface RateTrackerLimits {
|
|
111
|
+
/** sources kept at once; past this the least recently seen is forgotten. Default 10000 */
|
|
112
|
+
maxSources?: number;
|
|
113
|
+
/** a source key longer than this is kept as its sha256. Default 256 */
|
|
114
|
+
maxKeyLength?: number;
|
|
115
|
+
/** false where a process-wide timer cannot run (a Worker): the sweep then runs from `hit`, at most once a minute. Default true */
|
|
116
|
+
sweepTimer?: boolean;
|
|
117
|
+
}
|
|
118
|
+
export interface RateTracker {
|
|
119
|
+
hit(source: string): {
|
|
120
|
+
burst: number;
|
|
121
|
+
minute: number;
|
|
122
|
+
};
|
|
123
|
+
/** sources kept now */
|
|
124
|
+
size(): number;
|
|
125
|
+
/** stops the sweep */
|
|
126
|
+
close(): void;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Counts arrivals per source over the two windows. Each source keeps its arrival times in order with two heads that only
|
|
130
|
+
* move forward, so one arrival costs the same however many came before it in the window; the array is compacted once
|
|
131
|
+
* half of it is behind the minute head. The source key comes from the arrival, and with `trustProxy` the client may
|
|
132
|
+
* choose it, so the map bounds itself: at most `maxSources` keys, none longer than `maxKeyLength`, and a source with no
|
|
133
|
+
* arrival in the last minute is dropped every minute whether or not traffic goes on. A source forgotten early counts
|
|
134
|
+
* again from 1, which only lowers what a pace rule sees for a client that floods the map. The clock is monotonic
|
|
135
|
+
* (`performance.now`), so a step of the wall clock (an NTP correction, a VM resume) neither keeps old arrivals inside
|
|
136
|
+
* the windows nor drops new ones; an injected clock that goes back is held at the last time seen. `now` is for tests.
|
|
137
|
+
*/
|
|
138
|
+
export declare function createRateTracker(now?: () => number, limits?: RateTrackerLimits): RateTracker;
|
|
139
|
+
export interface Classified {
|
|
140
|
+
arrival: Arrival;
|
|
141
|
+
/** set when the arrival is verified by a grant: the grant, as presented */
|
|
142
|
+
delegation?: {
|
|
143
|
+
envelope: Envelope;
|
|
144
|
+
grant: Delegation;
|
|
145
|
+
principalKeyid: string;
|
|
146
|
+
};
|
|
147
|
+
/** set when a verified signature names the arrival's agent: alone, or bound to the grant that names the same agent */
|
|
148
|
+
signer?: {
|
|
149
|
+
agent: string;
|
|
150
|
+
keyid: string;
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* The record of the call keeps what arrived; the policy reads a copy Cedar accepts. Cedar has no `null` and no
|
|
155
|
+
* non-integer number, and refuses the whole request on either, so a body with `"coupon": null` or `"price": 9.99` would
|
|
156
|
+
* be denied whatever the policy says. In the copy a `null` is dropped and a number that is not a safe integer becomes its
|
|
157
|
+
* string; a rule that compares `price` as a number then errors, and the call is denied by that rule rather than by Cedar.
|
|
158
|
+
*/
|
|
159
|
+
export declare function cedarArgs(value: unknown): unknown;
|
|
160
|
+
/**
|
|
161
|
+
* What a receipt records of an arrival when the config gives its route no capture rule: the method, the path, the
|
|
162
|
+
* recorded headers, and the body's size in clear; the query and the body withheld, each a salted commitment. A query can
|
|
163
|
+
* carry an API key and a form body a password. Set a rule for the route (or `"*"`) to record more in clear.
|
|
164
|
+
*/
|
|
165
|
+
export declare const DOOR_DEFAULT_CAPTURE: {
|
|
166
|
+
args: {
|
|
167
|
+
mode: "digest";
|
|
168
|
+
clear: string[];
|
|
169
|
+
};
|
|
170
|
+
result: {
|
|
171
|
+
mode: "clear";
|
|
172
|
+
};
|
|
173
|
+
facts: {
|
|
174
|
+
mode: "clear";
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* The path as the origin will read it: each segment percent-decoded once, so that `/%61dmin` falls under `/admin/*`, and
|
|
179
|
+
* empty segments merged, so that `//admin/users` and `/admin//users` fall under it too (nginx, Apache, and many
|
|
180
|
+
* frameworks merge them, and the origin would serve the admin page to an arrival the door matched as something else).
|
|
181
|
+
* A trailing slash is kept. Refused when a segment does not decode, or decodes to a slash, a backslash, or a dot
|
|
182
|
+
* segment: the origin would then read a path the door did not match. `relay` is the merged, decoded path encoded once
|
|
183
|
+
* more, the form the origin is sent, so the door and the origin read one path.
|
|
184
|
+
*/
|
|
185
|
+
export declare function normalizePath(pathname: string): {
|
|
186
|
+
path: string;
|
|
187
|
+
relay: string;
|
|
188
|
+
} | {
|
|
189
|
+
problem: string;
|
|
190
|
+
};
|
|
191
|
+
/** What the door reads of a request: its method, its target, its headers, and the socket's address. A Node `IncomingMessage` is one; the in-process door builds one from a fetch `Request`. */
|
|
192
|
+
export interface DoorRequest {
|
|
193
|
+
method?: string | undefined;
|
|
194
|
+
url?: string | undefined;
|
|
195
|
+
headers: IncomingHttpHeaders;
|
|
196
|
+
/** every value of each field, as Node keeps them; read for an HTTP message signature */
|
|
197
|
+
headersDistinct?: Record<string, string[] | undefined>;
|
|
198
|
+
/** names and values in turn, in the order received, as Node keeps them; read for the header fingerprint */
|
|
199
|
+
rawHeaders?: string[] | undefined;
|
|
200
|
+
/** what the host knows of the client's connection (a Worker reads it from `request.cf`); never read from a header */
|
|
201
|
+
transport?: {
|
|
202
|
+
secure?: boolean;
|
|
203
|
+
tls?: TlsObservation;
|
|
204
|
+
} | undefined;
|
|
205
|
+
socket: {
|
|
206
|
+
remoteAddress?: string | undefined;
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* The original request an authz check asks about, from `X-Original-Method` and `X-Original-URI`, with the check's own
|
|
211
|
+
* headers and address. The check request's own method and path are the proxy's (nginx sends GET to a fixed location),
|
|
212
|
+
* so both headers are required, and a check without them is refused rather than decided on the proxy's request.
|
|
213
|
+
*/
|
|
214
|
+
export declare function authzTarget(req: DoorRequest): DoorRequest | {
|
|
215
|
+
problem: string;
|
|
216
|
+
};
|
|
217
|
+
/** The route an arrival falls under: the first configured route whose methods and decoded path match, else the unmatched name. A trailing slash matches as no trailing slash. */
|
|
218
|
+
export declare function matchRoute(routes: DoorRouteConfig[], unmatched: string, method: string, pathname: string): string;
|
|
219
|
+
/**
|
|
220
|
+
* The arrival's address: the socket's, or with trustProxy the last address in `X-Forwarded-For`, the one the proxy in
|
|
221
|
+
* front of the door appended. Everything before it was sent by the client, which may write what it likes there.
|
|
222
|
+
*/
|
|
223
|
+
export declare function remoteOf(req: DoorRequest, trustProxy: boolean): string;
|
|
224
|
+
/**
|
|
225
|
+
* The request as RFC 9421 reads it: the target as received, the `Host` as the authority, and every value of each field.
|
|
226
|
+
* A request without `headersDistinct` (a fetch request, which joins repeated fields with ", ") gives each field's value as
|
|
227
|
+
* it holds it.
|
|
228
|
+
*/
|
|
229
|
+
export declare function signedRequestOf(req: DoorRequest): SignedRequest;
|
|
230
|
+
/**
|
|
231
|
+
* What the arrival presented, checked where it can be. A grant signed by a trusted principal, in its window, naming this
|
|
232
|
+
* route among its scopes, makes the arrival `verified` and its principal attested. A grant that is out of scope, expired,
|
|
233
|
+
* or signed by a stranger leaves the arrival `claimed`: it asserted an identity the door could not accept for this route.
|
|
234
|
+
* Without a grant, a Web Bot Auth signature the door verified (`signature`, from `createWebBotAuthVerifier`) makes the
|
|
235
|
+
* arrival `verified` as its signature agent. With both, the signature binds the grant to its sender when the grant names
|
|
236
|
+
* that signature agent; a grant presented under another agent's signature is `wrong-sender` and the arrival `claimed`.
|
|
237
|
+
* A signature by a did:key's own key binds a grant that names that did:key in the same way, and counts for nothing else.
|
|
238
|
+
* An `x-agent-custody-agent` header or a signature that did not verify alone is `claimed`. Nothing at all is `unknown`.
|
|
239
|
+
* Without `signature`, a `Signature-Input` header is recorded as `unchecked`. `revoked`, when given, says why a grant
|
|
240
|
+
* that verified is revoked (from its chain's digests, leaf first), or null when it is not; a revoked grant is `claimed`.
|
|
241
|
+
*/
|
|
242
|
+
export declare function classifyArrival(req: DoorRequest, trusted: PublicKeyRef[], route: string, trustProxy: boolean, at: string, signature?: SignatureCheck, revoked?: (chainDigests: string[]) => string | null): Classified;
|
|
243
|
+
/** The body as the door read it: whole, or how many bytes had arrived when it passed the limit. */
|
|
244
|
+
export type BodyRead = {
|
|
245
|
+
body: Buffer;
|
|
246
|
+
} | {
|
|
247
|
+
oversized: true;
|
|
248
|
+
bytes: number;
|
|
249
|
+
};
|
|
250
|
+
/** A fetch body, or how many bytes had arrived when it passed the limit; the rest is not read. */
|
|
251
|
+
export declare function readStream(stream: ReadableStream<Uint8Array> | null, max: number): Promise<BodyRead>;
|
|
252
|
+
/** The query as own properties: a parameter named `constructor` or `__proto__` is a parameter, never an inherited member or the prototype. */
|
|
253
|
+
export declare function queryOf(url: URL): Record<string, string | string[]>;
|
|
254
|
+
export type Execution = ReceiptPredicate["execution"];
|
|
255
|
+
type ReceiptHead = Omit<ReceiptPredicate, "session" | "model" | "execution" | "authorization">;
|
|
256
|
+
/** A fact the runtime observed for itself: the tool the receipt names as its source, and the value. Not signed by anyone: the door's own observation. */
|
|
257
|
+
export interface ObservedFact {
|
|
258
|
+
tool: string;
|
|
259
|
+
value: unknown;
|
|
260
|
+
}
|
|
261
|
+
/** One arrival as the door decided it, before anything was relayed or passed on. */
|
|
262
|
+
export interface DoorDecision {
|
|
263
|
+
receiptId: string;
|
|
264
|
+
arrival: Arrival;
|
|
265
|
+
method: string;
|
|
266
|
+
url: URL;
|
|
267
|
+
route: string;
|
|
268
|
+
/** the path decoded and encoded once, the form the origin is sent; absent when the path did not decode cleanly */
|
|
269
|
+
relay?: string;
|
|
270
|
+
/** the body, or null when it passed `maxBodyBytes` */
|
|
271
|
+
body: Buffer | null;
|
|
272
|
+
/** set when the door refuses the arrival: what the receipt records, and the status the arrival is answered */
|
|
273
|
+
refused?: {
|
|
274
|
+
execution: Execution;
|
|
275
|
+
status: number;
|
|
276
|
+
};
|
|
277
|
+
head: ReceiptHead;
|
|
278
|
+
authorization?: AuthorizationBundle;
|
|
279
|
+
}
|
|
280
|
+
/** An answer the door gives itself, in place of the origin's or the app's. */
|
|
281
|
+
export interface DoorAnswer {
|
|
282
|
+
status: number;
|
|
283
|
+
headers: Record<string, string>;
|
|
284
|
+
body: string;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* The door's decision loop, shared by the proxy and the in-process door: classify the arrival, read its body, run the
|
|
288
|
+
* policy, commit the authorization of a request that can change something, and write the receipt once the outcome is
|
|
289
|
+
* known. What happens between the decision and the receipt, relaying to an origin or passing the request to the app in
|
|
290
|
+
* the same process, is the caller's.
|
|
291
|
+
*/
|
|
292
|
+
export interface DoorCore {
|
|
293
|
+
keyid: string;
|
|
294
|
+
policyDigest(): string;
|
|
295
|
+
/** false when `maxInFlight` arrivals are already being handled: answer `busy()` before the body is read. Every admitted arrival is released */
|
|
296
|
+
admit(): boolean;
|
|
297
|
+
release(): void;
|
|
298
|
+
busy(): DoorAnswer;
|
|
299
|
+
/**
|
|
300
|
+
* `framework`, when given, is the receipt's `issuer.framework` in place of the core's. `read` is null when the door never
|
|
301
|
+
* sees the body (an authz check): the receipt then records none. `observed` are facts the runtime saw for itself (a
|
|
302
|
+
* Worker's Cloudflare Bot Management score), by name: each enters the receipt labelled `observed` and the policy as
|
|
303
|
+
* `context.facts.<name>`. A name the door uses itself (`arrival`, `partner`) is refused.
|
|
304
|
+
*/
|
|
305
|
+
decide(req: DoorRequest, receiptId: string, read: ((max: number) => Promise<BodyRead>) | null, framework?: string, observed?: Record<string, ObservedFact>): Promise<DoorDecision>;
|
|
306
|
+
/** a header the door consumed and never passes on: the grant (and `Authorization` when it carried it), the declared agent, the challenge token, and with `behaviour` the form report */
|
|
307
|
+
consumed(name: string, req: DoorRequest, arrival: Arrival): boolean;
|
|
308
|
+
/** writes the receipt; null when it could not be written, after saying why on stderr */
|
|
309
|
+
record(d: DoorDecision, execution: Execution): Promise<{
|
|
310
|
+
logPending: boolean;
|
|
311
|
+
} | null>;
|
|
312
|
+
/** the door's headers on every answer */
|
|
313
|
+
mark(d: DoorDecision, logPending: boolean): Record<string, string>;
|
|
314
|
+
/** the answer to an arrival the door refused */
|
|
315
|
+
refusal(d: DoorDecision, logPending: boolean): DoorAnswer;
|
|
316
|
+
/** the answer when the receipt could not be written: what happened, so that nobody retries a refund that went through */
|
|
317
|
+
unrecorded(d: DoorDecision, execution: Execution, notSent: boolean): DoorAnswer;
|
|
318
|
+
flushOutbox(): Promise<FlushResult>;
|
|
319
|
+
pendingReceipts(): number;
|
|
320
|
+
close(): void;
|
|
321
|
+
}
|
|
322
|
+
/** A JSON answer the door gives itself, with the headers every such answer carries. */
|
|
323
|
+
export declare const jsonAnswer: (status: number, headers: Record<string, string>, body: unknown) => DoorAnswer;
|
|
324
|
+
/** What the door core needs from where it runs. The Node door reads its files and environment; a Worker reads its bindings. */
|
|
325
|
+
export interface DoorIO {
|
|
326
|
+
/** the key that signs the door's receipts */
|
|
327
|
+
key: KeyPair;
|
|
328
|
+
/** principal keys whose grants are a passport */
|
|
329
|
+
trustedPrincipalKeys: PublicKeyRef[];
|
|
330
|
+
/** the policy text, and a value that changes whenever the text may have; read on every arrival. Throws when it cannot be read: the policy in force stays */
|
|
331
|
+
readPolicy(): {
|
|
332
|
+
text: string;
|
|
333
|
+
key: string;
|
|
334
|
+
};
|
|
335
|
+
/** names the policy in messages: its file, or the variable it came from */
|
|
336
|
+
policySource: string;
|
|
337
|
+
/** why a grant with these chain digests (leaf first) is revoked, or null when it is not. A list that cannot be read must revoke: return the reason */
|
|
338
|
+
revoked(chainDigests: string[]): string | null;
|
|
339
|
+
/** a secret by the name the config gives it (`captureKeyEnv`, `challenge.secretEnv`), or undefined when it is not set */
|
|
340
|
+
secret(name: string): string | undefined;
|
|
341
|
+
/** the receipt issuer, given the capture rules the core settled and the capture key */
|
|
342
|
+
issuer(capture: {
|
|
343
|
+
rules: CaptureConfig;
|
|
344
|
+
key: Buffer | undefined;
|
|
345
|
+
}): Issuer;
|
|
346
|
+
fetch: typeof fetch;
|
|
347
|
+
/** false where a process-wide timer cannot run (a Worker) */
|
|
348
|
+
timers: boolean;
|
|
349
|
+
/** where Web Bot Auth nonces are kept; this process's memory when absent */
|
|
350
|
+
nonceStore?: NonceStore;
|
|
351
|
+
}
|
|
352
|
+
/** The decision loop for a door config over the given I/O; `framework` is the receipt's `issuer.framework`. Throws when the config cannot be served. */
|
|
353
|
+
export declare function createDoorCoreWith(cfg: DoorConfig, io: DoorIO, framework: string, opts?: {
|
|
354
|
+
autoFlush?: boolean | undefined;
|
|
355
|
+
}): DoorCore;
|
|
356
|
+
/** Where the door relays an allowed arrival: the origin, the headers that are its credentials, and how long it may take. */
|
|
357
|
+
export interface OriginTarget {
|
|
358
|
+
url: URL;
|
|
359
|
+
headers: Record<string, string>;
|
|
360
|
+
timeoutMs: number;
|
|
361
|
+
/** `X-Forwarded-Proto` for an arrival not behind a trusted proxy: the scheme the door itself serves */
|
|
362
|
+
proto: string;
|
|
363
|
+
}
|
|
364
|
+
/** What became of the relay: the execution the receipt records, the origin's answer when it arrived whole, and whether the request never left the door. */
|
|
365
|
+
export interface Relayed {
|
|
366
|
+
execution: Execution;
|
|
367
|
+
answer?: {
|
|
368
|
+
status: number;
|
|
369
|
+
headers: Record<string, string | string[]>;
|
|
370
|
+
body: Buffer;
|
|
371
|
+
};
|
|
372
|
+
notSent: boolean;
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Relays a decided arrival to the origin with fetch, unless the door refused it, and says what happened. Each arrival
|
|
376
|
+
* also holds the origin's answer (up to `maxResponseBytes`) in memory until it is answered.
|
|
377
|
+
*/
|
|
378
|
+
export declare function relayToOrigin(core: DoorCore, cfg: DoorConfig, d: DoorDecision, req: DoorRequest, origin: OriginTarget, f: typeof fetch): Promise<Relayed>;
|
|
379
|
+
/** The answer to a relayed arrival once its receipt is written: the refusal, the relay's failure, or the origin's answer with the door's headers. */
|
|
380
|
+
export declare function relayedAnswer(core: DoorCore, cfg: DoorConfig, d: DoorDecision, r: Relayed, logPending: boolean): {
|
|
381
|
+
status: number;
|
|
382
|
+
headers: Record<string, string | string[]>;
|
|
383
|
+
body: Buffer | string;
|
|
384
|
+
};
|
|
385
|
+
export {};
|