@agent-custody/receipts 0.16.11 → 0.16.13
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 +23 -5
- package/dist/admission.d.ts +62 -0
- package/dist/admission.js +101 -0
- package/dist/check.js +42 -3
- package/dist/cli.js +179 -7
- package/dist/config.d.ts +6 -1
- package/dist/config.js +21 -2
- package/dist/door-app.js +1 -1
- package/dist/door-core.d.ts +81 -3
- package/dist/door-core.js +113 -13
- 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 +20 -1
- package/dist/door-worker.js +30 -2
- package/dist/door.js +18 -2
- package/dist/erc8004-link.d.ts +24 -0
- package/dist/erc8004-link.js +11 -0
- package/dist/erc8004.d.ts +26 -0
- package/dist/erc8004.js +208 -0
- package/dist/index.d.ts +17 -3
- package/dist/index.js +9 -2
- package/dist/lock.d.ts +5 -0
- package/dist/lock.js +1 -1
- package/dist/log-store.d.ts +3 -1
- package/dist/log-store.js +2 -2
- package/dist/passport.d.ts +53 -0
- package/dist/passport.js +87 -0
- package/dist/portal.d.ts +14 -0
- package/dist/portal.js +102 -0
- package/dist/registry.d.ts +145 -0
- package/dist/registry.js +294 -0
- package/dist/web-bot-auth.d.ts +9 -3
- package/dist/web-bot-auth.js +31 -4
- package/docs/admission-lists.md +89 -0
- package/docs/agent-registry.md +173 -0
- 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 +2 -2
- package/docs/door-signals.md +112 -2
- package/docs/door-worker.md +14 -1
- package/docs/door.md +37 -6
- package/docs/github-action.md +2 -2
- package/docs/tutorials.md +7 -0
- package/docs/usage.md +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
/** the request header in which the form protector script sends its form report; a claim by the client */
|
|
2
|
+
export declare const FORM_REPORT_HEADER = "x-agent-custody-form";
|
|
3
|
+
/** how long a source's arrivals and its last page load are remembered */
|
|
4
|
+
export declare const HISTORY_WINDOW_MS: number;
|
|
5
|
+
/** arrival times kept per source, so the timing signals read at most one gap fewer */
|
|
6
|
+
export declare const HISTORY_MAX_ARRIVALS = 17;
|
|
7
|
+
/** `timing.regular` needs at least this many gaps */
|
|
8
|
+
export declare const TIMING_MIN_GAPS = 5;
|
|
9
|
+
/** `timing.regular`: the longest gap minus the shortest gap is at most this percentage of the median gap */
|
|
10
|
+
export declare const TIMING_REGULAR_SPREAD_PERCENT = 10;
|
|
11
|
+
/** `timing.regular` needs a median gap of at least this; faster arrivals are a burst, which `rate` counts */
|
|
12
|
+
export declare const TIMING_REGULAR_MIN_MEDIAN_MS = 100;
|
|
13
|
+
/** `form.fast` needs at least this many key presses */
|
|
14
|
+
export declare const FORM_FAST_MIN_KEYS = 8;
|
|
15
|
+
/** `form.fast`: the fill took less than this many milliseconds for each key press */
|
|
16
|
+
export declare const FORM_FAST_MS_PER_KEY = 20;
|
|
17
|
+
/** a form report longer than this is malformed */
|
|
18
|
+
export declare const MAX_FORM_REPORT = 96;
|
|
19
|
+
/** the largest fill time a form report can state: one day */
|
|
20
|
+
export declare const MAX_FORM_FILL_MS = 86400000;
|
|
21
|
+
/** the largest event count a form report can state */
|
|
22
|
+
export declare const MAX_FORM_EVENTS = 99999;
|
|
23
|
+
/** header names read from one arrival; the rest are not counted or hashed */
|
|
24
|
+
export declare const MAX_HEADER_NAMES = 128;
|
|
25
|
+
/** a header name longer than this is cut */
|
|
26
|
+
export declare const MAX_HEADER_NAME_LENGTH = 64;
|
|
27
|
+
/** the User-Agent is read up to this length */
|
|
28
|
+
export declare const MAX_USER_AGENT = 512;
|
|
29
|
+
/** a TLS fingerprint value longer than this is cut, and is then malformed */
|
|
30
|
+
export declare const MAX_TLS_VALUE = 64;
|
|
31
|
+
export type BrowserFamily = "chromium" | "firefox" | "safari";
|
|
32
|
+
/** the first major version of each browser family that sends `sec-fetch-site`, `sec-fetch-mode`, and `sec-fetch-dest` on every request to an https site */
|
|
33
|
+
export declare const SEC_FETCH_SINCE: Record<BrowserFamily, number>;
|
|
34
|
+
/** the Chromium major version from which `headers.mismatch` expects `sec-ch-ua` on every request to an https site */
|
|
35
|
+
export declare const SEC_CH_UA_SINCE = 100;
|
|
36
|
+
/** the major version of each browser family from which `tls.mismatch` expects TLS 1.3 and ALPN in the ClientHello */
|
|
37
|
+
export declare const TLS13_SINCE: Record<BrowserFamily, number>;
|
|
38
|
+
/** the header that every browser family sends on every request */
|
|
39
|
+
export declare const BROWSER_HEADERS: string[];
|
|
40
|
+
/** the header that a browser from `SEC_FETCH_SINCE` sends on every POST, PUT, PATCH, and DELETE; its value can be `null` */
|
|
41
|
+
export declare const WRITE_HEADERS: string[];
|
|
42
|
+
/** the `sec-fetch-dest` values of a navigation; `sec-fetch-mode: navigate` with another one is not a browser's */
|
|
43
|
+
export declare const NAVIGATE_DESTS: ReadonlySet<string>;
|
|
44
|
+
/** how long `fingerprint.seen` counts arrivals with the same fingerprint */
|
|
45
|
+
export declare const SEEN_WINDOW_MS = 60000;
|
|
46
|
+
/** a `sec-ch-ua` value is read up to this length */
|
|
47
|
+
export declare const MAX_CLIENT_HINT = 256;
|
|
48
|
+
export declare const SEC_FETCH_HEADERS: string[];
|
|
49
|
+
/**
|
|
50
|
+
* Only the JA4 TLS client fingerprint is used here and in scripts/ja4.ts: it is BSD-3-Clause. JA4H, JA4S, JA4T, and
|
|
51
|
+
* the rest of JA4+ are under the FoxIO License 1.1, which restricts commercial use, so the header fingerprint is the
|
|
52
|
+
* door's own hash and not JA4H.
|
|
53
|
+
*
|
|
54
|
+
* JA4 fingerprints of known tools, each with the tool's family. Every value was recorded by the labelled capture
|
|
55
|
+
* (scripts/door-capture.ts, labelled/capture.meta.json), never taken from memory. A fingerprint belongs to one build of
|
|
56
|
+
* the tool's TLS library, so another version of the tool can have another fingerprint, and the table misses it.
|
|
57
|
+
*/
|
|
58
|
+
export declare const KNOWN_TOOL_JA4: ReadonlyMap<string, string>;
|
|
59
|
+
/** What the host knows of the client's TLS ClientHello. The door never reads it from a header that a client can set. */
|
|
60
|
+
export interface TlsObservation {
|
|
61
|
+
/** the JA4 string, as the operator's proxy or Cloudflare gives it */
|
|
62
|
+
ja4?: string;
|
|
63
|
+
/** the negotiated version, as Cloudflare names it (`TLSv1.3`) */
|
|
64
|
+
negotiated?: string;
|
|
65
|
+
/** the negotiated cipher, as Cloudflare names it */
|
|
66
|
+
cipher?: string;
|
|
67
|
+
/** Cloudflare's `tlsClientExtensionsSha1` */
|
|
68
|
+
extensionsSha1?: string;
|
|
69
|
+
/** the length of the ClientHello in bytes */
|
|
70
|
+
helloLength?: number;
|
|
71
|
+
}
|
|
72
|
+
/** The network that the client's address belongs to, as the host gives it. */
|
|
73
|
+
export interface NetworkObservation {
|
|
74
|
+
/** the autonomous system number */
|
|
75
|
+
asn?: number;
|
|
76
|
+
/** the name of the organisation that holds it */
|
|
77
|
+
organization?: string;
|
|
78
|
+
}
|
|
79
|
+
export type RefererRelation = "same-origin" | "cross-origin" | "absent";
|
|
80
|
+
/** What the door saw of one arrival: all that the signals read. It holds no cookie, no query, no body, and no address. */
|
|
81
|
+
export interface Observation {
|
|
82
|
+
/** the time of the arrival in milliseconds on a monotonic clock; the caller supplies it, so a replay supplies the recorded time */
|
|
83
|
+
at: number;
|
|
84
|
+
method: string;
|
|
85
|
+
path: string;
|
|
86
|
+
/**
|
|
87
|
+
* The header names that the door received, lowercase, without the door's own headers. `ordered` is false when the
|
|
88
|
+
* host cannot see the order (a fetch `Request`, a Worker). Absent when the host does not receive the client's full
|
|
89
|
+
* header set: in authz mode the proxy selects the headers of a check.
|
|
90
|
+
*/
|
|
91
|
+
headers?: {
|
|
92
|
+
names: string[];
|
|
93
|
+
ordered: boolean;
|
|
94
|
+
};
|
|
95
|
+
/** true only when the host knows that the client used https */
|
|
96
|
+
secure?: boolean;
|
|
97
|
+
userAgent?: string;
|
|
98
|
+
accept?: string;
|
|
99
|
+
referer: RefererRelation;
|
|
100
|
+
/** the relation of the `Origin` header to the host; `Origin: null` is `cross-origin`. Absent in a recording made before the door read it */
|
|
101
|
+
origin?: RefererRelation;
|
|
102
|
+
/** `sec-fetch-site`, `sec-fetch-mode`, `sec-fetch-dest`, and `sec-fetch-user`, as sent */
|
|
103
|
+
secFetch: {
|
|
104
|
+
site?: string;
|
|
105
|
+
mode?: string;
|
|
106
|
+
dest?: string;
|
|
107
|
+
user?: string;
|
|
108
|
+
};
|
|
109
|
+
/** the `sec-ch-ua` header, as sent: brand names and major versions. It names a browser build, not a person */
|
|
110
|
+
clientHints?: string;
|
|
111
|
+
/** the HTTP version between the client and the edge (`HTTP/2`), when the host knows it: a Worker's `request.cf` */
|
|
112
|
+
http?: string;
|
|
113
|
+
/** the network of the client's address, when the host knows it: a Worker's `request.cf` */
|
|
114
|
+
network?: NetworkObservation;
|
|
115
|
+
tls?: TlsObservation;
|
|
116
|
+
/** the form report header, as sent; a claim by the client */
|
|
117
|
+
form?: string;
|
|
118
|
+
}
|
|
119
|
+
/** The part of a request that `observationOf` reads. A Node `IncomingMessage` and a `DoorRequest` are each one. */
|
|
120
|
+
export interface ObservedRequest {
|
|
121
|
+
headers: Record<string, string | string[] | undefined>;
|
|
122
|
+
/** names and values in turn, in the order received, as Node keeps them */
|
|
123
|
+
rawHeaders?: string[] | undefined;
|
|
124
|
+
/** set by the host from the connection, never from a client header */
|
|
125
|
+
transport?: {
|
|
126
|
+
secure?: boolean;
|
|
127
|
+
tls?: TlsObservation;
|
|
128
|
+
http?: string;
|
|
129
|
+
network?: NetworkObservation;
|
|
130
|
+
} | undefined;
|
|
131
|
+
}
|
|
132
|
+
export interface ObserveOptions {
|
|
133
|
+
/** the door's `trustProxy`: `x-forwarded-proto`, `x-forwarded-host`, and `tlsHeader` are then the proxy's */
|
|
134
|
+
trustProxy?: boolean;
|
|
135
|
+
/** the header in which the operator's proxy puts the JA4 string; read only with `trustProxy` */
|
|
136
|
+
tlsHeader?: string;
|
|
137
|
+
/** more header names that are the door's own, left out of the header fingerprint */
|
|
138
|
+
own?: string[];
|
|
139
|
+
/** true when the host receives only the headers that a proxy selected */
|
|
140
|
+
partialHeaders?: boolean;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The relation of a `Referer` to the host that the request names. The scheme is not compared, because the door does
|
|
144
|
+
* not always know it, so a default port on one side and none on the other is the same host.
|
|
145
|
+
*/
|
|
146
|
+
export declare function refererRelation(referer: string | undefined, host: string | undefined): RefererRelation;
|
|
147
|
+
/**
|
|
148
|
+
* The observation of one request. Every value is cut to a fixed length, so a hostile header cannot make it large. The
|
|
149
|
+
* TLS fingerprint comes from `transport`, or from `tlsHeader` when `trustProxy` is set; without both, a header that
|
|
150
|
+
* names a fingerprint is the client's word and is not read.
|
|
151
|
+
*/
|
|
152
|
+
export declare function observationOf(req: ObservedRequest, at: number, method: string, path: string, opts?: ObserveOptions): Observation;
|
|
153
|
+
/** the methods that `directWrite` and the `origin` rule read as a write */
|
|
154
|
+
export declare const STATE_CHANGING: ReadonlySet<string>;
|
|
155
|
+
export type ClientKind = "browser" | "agent" | "tool" | "other" | "unstated";
|
|
156
|
+
/** What a vendor says its agent fetches for: to train a model, to build a search index, or because one user asked. */
|
|
157
|
+
export type AgentPurpose = "training" | "search" | "user";
|
|
158
|
+
/**
|
|
159
|
+
* AI agents that name themselves in the User-Agent, by product token. Each entry is from the vendor's own page, read on
|
|
160
|
+
* 2026-11-23, and never from memory. A token that a vendor documents for another purpose (an ads check, a crawl that the
|
|
161
|
+
* site owner asked for) is not here, and reads as a crawler. A claim: any client can send any of these names.
|
|
162
|
+
*/
|
|
163
|
+
export declare const AI_AGENTS: ReadonlyMap<string, {
|
|
164
|
+
vendor: string;
|
|
165
|
+
purpose: AgentPurpose;
|
|
166
|
+
}>;
|
|
167
|
+
/** The client that a User-Agent states. A claim: any client can send any User-Agent. */
|
|
168
|
+
export interface StatedClient {
|
|
169
|
+
kind: ClientKind;
|
|
170
|
+
/** a `BrowserFamily` for a browser, the tool's name for a tool, else `other` or `unstated` */
|
|
171
|
+
family: string;
|
|
172
|
+
/** the browser's major version, when the User-Agent states the version of its engine */
|
|
173
|
+
version?: number;
|
|
174
|
+
/** for an `agent`: the vendor, and what the vendor says the agent fetches for */
|
|
175
|
+
vendor?: string;
|
|
176
|
+
purpose?: AgentPurpose;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* The client family that the User-Agent states. A browser on iOS is `safari` whatever its name, because it runs
|
|
180
|
+
* WebKit; without a `Version/` token its version is unknown, and the rules that depend on a version do not apply.
|
|
181
|
+
*/
|
|
182
|
+
export declare function statedClient(userAgent: string | undefined): StatedClient;
|
|
183
|
+
export interface HeaderFingerprint {
|
|
184
|
+
/** a hash of the header names in the order received; absent when the host cannot see the order */
|
|
185
|
+
order?: string;
|
|
186
|
+
/** how many headers the door received, without its own; absent when the host does not receive the full set */
|
|
187
|
+
count?: number;
|
|
188
|
+
client: ClientKind;
|
|
189
|
+
family: string;
|
|
190
|
+
version?: number;
|
|
191
|
+
/** for a client that states an AI agent: the vendor and the purpose that the vendor documents. A claim, like the User-Agent */
|
|
192
|
+
vendor?: string;
|
|
193
|
+
purpose?: AgentPurpose;
|
|
194
|
+
/** true when the User-Agent states a browser and the request lacks a header that this browser always sends */
|
|
195
|
+
mismatch: boolean;
|
|
196
|
+
/** the missing header names, separated by a space; only when `mismatch` is true */
|
|
197
|
+
missing?: string;
|
|
198
|
+
/** from `sec-ch-ua`, when the arrival sent it: the major version of the `Chromium` brand, when there is one */
|
|
199
|
+
hints?: {
|
|
200
|
+
version?: number;
|
|
201
|
+
};
|
|
202
|
+
/** true when `sec-ch-ua` and the User-Agent do not state the same browser */
|
|
203
|
+
hintsMismatch: boolean;
|
|
204
|
+
/** true when the `sec-fetch-*` headers have a combination that no browser sends */
|
|
205
|
+
fetchInvalid: boolean;
|
|
206
|
+
/** the HTTP version between the client and the edge (`1.1`, `2`, `3`), when the host knows it */
|
|
207
|
+
http?: string;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* The header fingerprint. `mismatch` reads only rules that hold for every request of a browser family, so that a real
|
|
211
|
+
* browser is not flagged: `accept-language` always, and, when the host knows that the client used https, `sec-fetch-*`
|
|
212
|
+
* and (Chromium) `sec-ch-ua` from the versions in `SEC_FETCH_SINCE` and `SEC_CH_UA_SINCE`. Browsers send these only to
|
|
213
|
+
* an https site. On a write, a browser from `SEC_FETCH_SINCE` also sends `origin`, to any site. For an OPTIONS request and an upgrade, only `accept-language` is checked. A proxy in front of the door that drops one of
|
|
214
|
+
* these headers makes every browser a mismatch: the door records what it received.
|
|
215
|
+
*/
|
|
216
|
+
export declare function headerFingerprint(o: Observation): HeaderFingerprint;
|
|
217
|
+
export interface TlsFingerprint {
|
|
218
|
+
/** the JA4 string, when a well-formed one arrived */
|
|
219
|
+
ja4?: string;
|
|
220
|
+
/** true when a JA4 value arrived that does not have the shape of a JA4; the proxy did not set it, or did not overwrite the client's */
|
|
221
|
+
malformed: boolean;
|
|
222
|
+
/** from the JA4: the transport of the ClientHello */
|
|
223
|
+
protocol?: "tcp" | "quic" | "dtls";
|
|
224
|
+
/** from the JA4: the highest TLS version that the client offered, as JA4 writes it (`13`, `12`) */
|
|
225
|
+
version?: string;
|
|
226
|
+
/** from the JA4: true when the ClientHello named a domain */
|
|
227
|
+
sni?: boolean;
|
|
228
|
+
/** from the JA4: how many cipher suites the client offered */
|
|
229
|
+
ciphers?: number;
|
|
230
|
+
/** from the JA4: how many extensions the client sent */
|
|
231
|
+
extensions?: number;
|
|
232
|
+
/** from the JA4: the first and last character of the first ALPN value, `00` when there is none */
|
|
233
|
+
alpn?: string;
|
|
234
|
+
/** the negotiated TLS version in the same form as `version`, when the host gives it */
|
|
235
|
+
negotiated?: string;
|
|
236
|
+
cipher?: string;
|
|
237
|
+
extensionsSha1?: string;
|
|
238
|
+
helloLength?: number;
|
|
239
|
+
/** true when the User-Agent states a browser and the JA4 shows a ClientHello that this browser does not send */
|
|
240
|
+
mismatch: boolean;
|
|
241
|
+
/** true when the JA4 is in `KNOWN_TOOL_JA4` */
|
|
242
|
+
knownTool: boolean;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* The TLS fingerprint, or undefined when the host gave nothing that has the right shape. `mismatch` needs no
|
|
246
|
+
* fingerprint database: a browser at or after `TLS13_SINCE` offers TLS 1.3 and sends ALPN, and the first section of a
|
|
247
|
+
* JA4 states both. A TLS-inspecting proxy between the person and the site (a company network, some antivirus products)
|
|
248
|
+
* sends its own ClientHello, so a real browser behind one can be a mismatch.
|
|
249
|
+
*/
|
|
250
|
+
export declare function tlsFingerprint(o: Observation): TlsFingerprint | undefined;
|
|
251
|
+
/**
|
|
252
|
+
* The key of an unverified source in the history: the address, and for IPv6 its /64, because one client uses many
|
|
253
|
+
* addresses of its /64 (privacy extensions). An IPv4-mapped address and anything that is not an IPv6 address stay as
|
|
254
|
+
* they are. The door keys by address alone, not by address and User-Agent: a client that changes its User-Agent would
|
|
255
|
+
* else look new each time. So clients behind one address (NAT) share one history.
|
|
256
|
+
*/
|
|
257
|
+
export declare function historySource(address: string): string;
|
|
258
|
+
/** What the door remembers of one source when an arrival comes. */
|
|
259
|
+
export interface SourceHistory {
|
|
260
|
+
/** the times of the source's latest arrivals inside the window, oldest first, this arrival included */
|
|
261
|
+
times: number[];
|
|
262
|
+
/** the time of the source's latest page load before this arrival, when it is inside the window */
|
|
263
|
+
pageAt?: number;
|
|
264
|
+
/** how many GET requests that are not page loads the source sent after that page load and before this arrival, at most `HISTORY_MAX_ARRIVALS` */
|
|
265
|
+
subresources?: number;
|
|
266
|
+
}
|
|
267
|
+
export interface HistoryLimits {
|
|
268
|
+
/** sources kept at once; past this the least recently seen is forgotten. Default 10000 */
|
|
269
|
+
maxSources?: number;
|
|
270
|
+
/** a source key longer than this is kept as its sha256. Default 256 */
|
|
271
|
+
maxKeyLength?: number;
|
|
272
|
+
}
|
|
273
|
+
export interface HistoryTracker {
|
|
274
|
+
/** records the arrival and returns the source's history as the signals read it */
|
|
275
|
+
record(source: string, o: Observation): SourceHistory;
|
|
276
|
+
/** sources kept now */
|
|
277
|
+
size(): number;
|
|
278
|
+
}
|
|
279
|
+
/** True when the arrival loads an HTML document: a GET that names `document` in `sec-fetch-dest`, or without that header accepts `text/html`. */
|
|
280
|
+
export declare function isPageLoad(o: Observation): boolean;
|
|
281
|
+
/**
|
|
282
|
+
* Keeps each source's history, with the same limits style as the rate tracker: at most `maxSources` keys, none longer
|
|
283
|
+
* than `maxKeyLength`, the least recently seen forgotten first, at most `HISTORY_MAX_ARRIVALS` times per source, and
|
|
284
|
+
* nothing older than `HISTORY_WINDOW_MS`. One process's memory: the history starts empty when the door starts, two doors
|
|
285
|
+
* do not share it, and in a Worker each isolate has its own. A source forgotten early starts again, so a client that
|
|
286
|
+
* sends from many new addresses can make another source look new. The time is `Observation.at`; a time that goes back
|
|
287
|
+
* is held at the last time seen. No timer runs: stale sources are dropped from `record`, at most once a minute.
|
|
288
|
+
*/
|
|
289
|
+
export declare function createHistoryTracker(limits?: HistoryLimits): HistoryTracker;
|
|
290
|
+
export interface TimingSignals {
|
|
291
|
+
/** how many gaps between the source's remembered arrivals, at most `HISTORY_MAX_ARRIVALS - 1` */
|
|
292
|
+
gaps: number;
|
|
293
|
+
/** the median gap in milliseconds; absent when there is no gap */
|
|
294
|
+
medianGapMs?: number;
|
|
295
|
+
/** the shortest and the longest gap in milliseconds; absent when there is no gap */
|
|
296
|
+
minGapMs?: number;
|
|
297
|
+
maxGapMs?: number;
|
|
298
|
+
/** true when the source arrives at a steady pace */
|
|
299
|
+
regular: boolean;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* The pace of the source. `regular` is true when there are at least `TIMING_MIN_GAPS` gaps, the median gap is at least
|
|
303
|
+
* `TIMING_REGULAR_MIN_MEDIAN_MS`, and the longest gap minus the shortest is at most `TIMING_REGULAR_SPREAD_PERCENT` of
|
|
304
|
+
* the median. A page that polls on a timer in a person's browser is regular too.
|
|
305
|
+
*/
|
|
306
|
+
export declare function timingSignals(history: SourceHistory): TimingSignals;
|
|
307
|
+
export interface NavigationSignals {
|
|
308
|
+
/** true when the source loaded an HTML document earlier, inside `HISTORY_WINDOW_MS` */
|
|
309
|
+
pageLoaded: boolean;
|
|
310
|
+
/** milliseconds from that page load to this arrival; only when `pageLoaded` is true */
|
|
311
|
+
sincePageMs?: number;
|
|
312
|
+
/** GET requests that are not page loads, from the source, after that page load and before this arrival; only when `pageLoaded` is true. It counts only what goes through the door */
|
|
313
|
+
subresources?: number;
|
|
314
|
+
referer: RefererRelation;
|
|
315
|
+
/** the relation of the `Origin` header to the host; `Origin: null` is `cross-origin` */
|
|
316
|
+
origin: RefererRelation;
|
|
317
|
+
/** `sec-fetch-site` as sent, lowercase; `other` when it is not a token */
|
|
318
|
+
site?: string;
|
|
319
|
+
mode?: string;
|
|
320
|
+
dest?: string;
|
|
321
|
+
/** true when a POST, PUT, PATCH, or DELETE arrives with no earlier page load from the source, no same-origin referer, no same-origin `Origin`, and no `sec-fetch-site: same-origin` */
|
|
322
|
+
directWrite: boolean;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* How the arrival fits the source's navigation. `directWrite` is true for every API client that never loads a page,
|
|
326
|
+
* a verified agent included. A person whose page load came from another address, another door process, or before the
|
|
327
|
+
* window is not flagged when the browser sends a same-origin `Referer`, a same-origin `Origin`, or
|
|
328
|
+
* `Sec-Fetch-Site: same-origin`; a site with `Referrer-Policy: no-referrer` still gets the last. The three headers are
|
|
329
|
+
* the client's word: a program can send them. A program that loads the page first is not flagged; `sincePageMs` is
|
|
330
|
+
* then the time that it took to read and fill the page.
|
|
331
|
+
*/
|
|
332
|
+
export declare function navigationSignals(o: Observation, history: SourceHistory): NavigationSignals;
|
|
333
|
+
/** What a well-formed form report states. Counts only: the script reads no field value and no key identity. */
|
|
334
|
+
export interface FormReport {
|
|
335
|
+
/** milliseconds from the first key press, pointer press, click, or paste in the form to the submit; 0 when there was none */
|
|
336
|
+
fillMs: number;
|
|
337
|
+
keys: number;
|
|
338
|
+
pointers: number;
|
|
339
|
+
pasted: boolean;
|
|
340
|
+
/** false when one of the events did not come from the browser's own input handling (`event.isTrusted`) */
|
|
341
|
+
trusted: boolean;
|
|
342
|
+
/** pointer and touch moves over the form */
|
|
343
|
+
moves: number;
|
|
344
|
+
/** the longest gap between two key presses minus the shortest, in milliseconds; 0 with fewer than three key presses */
|
|
345
|
+
keySpreadMs: number;
|
|
346
|
+
/** milliseconds from the start of the script to the first key press, pointer press, click, or paste; 0 when there was none */
|
|
347
|
+
readyMs: number;
|
|
348
|
+
}
|
|
349
|
+
/** The form report from its header value, or null when the value is not exactly a report: its length, its fields, and its ranges are fixed. */
|
|
350
|
+
export declare function parseFormReport(value: unknown): FormReport | null;
|
|
351
|
+
export interface FormSignals extends Partial<FormReport> {
|
|
352
|
+
/** `claimed`: the form protector script reports from the client's browser, and any client can send the header */
|
|
353
|
+
report: "claimed" | "malformed";
|
|
354
|
+
/** true when the report states more key presses than a person makes in the stated time */
|
|
355
|
+
fast: boolean;
|
|
356
|
+
/** true when the report states a submit with no key press and no pointer press */
|
|
357
|
+
noInput: boolean;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* What the form report says, or undefined when the arrival sent none. A claim by the client: a program can send any
|
|
361
|
+
* report, so the flags catch only a client that runs the script and does not act as a person does. `fast` is true when
|
|
362
|
+
* there are at least `FORM_FAST_MIN_KEYS` key presses and the fill took less than `FORM_FAST_MS_PER_KEY` for each; a
|
|
363
|
+
* device that types for a person (a security key, a scanner) is fast too. `noInput` is true when there is no key press
|
|
364
|
+
* and no pointer press. A malformed report sets no flag.
|
|
365
|
+
*/
|
|
366
|
+
export declare function formSignals(o: Observation): FormSignals | undefined;
|
|
367
|
+
/** `arrival.fingerprint`: what the request and its connection look like */
|
|
368
|
+
export interface ArrivalFingerprint {
|
|
369
|
+
headers: HeaderFingerprint;
|
|
370
|
+
/** present only when the host gave a TLS fingerprint */
|
|
371
|
+
tls?: TlsFingerprint;
|
|
372
|
+
/** present only when the host knows the network of the address: `asn`, and `organization` cut to 64 characters */
|
|
373
|
+
network?: NetworkObservation;
|
|
374
|
+
/**
|
|
375
|
+
* How many arrivals in the last `SEEN_WINDOW_MS` had this fingerprint, from every source, this one included. A number
|
|
376
|
+
* for the policy and not a flag: thousands of people share the fingerprint of one browser build.
|
|
377
|
+
*/
|
|
378
|
+
seen?: number;
|
|
379
|
+
}
|
|
380
|
+
/** The key of `fingerprint.seen`: the JA4 and the header order. Undefined when the arrival has neither. */
|
|
381
|
+
export declare function fingerprintKey(f: ArrivalFingerprint): string | undefined;
|
|
382
|
+
export interface SeenCounter {
|
|
383
|
+
/** counts the arrival and returns how many arrivals had the key in the last `SEEN_WINDOW_MS` */
|
|
384
|
+
hit(key: string, at: number): number;
|
|
385
|
+
size(): number;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Counts arrivals for each fingerprint across sources, so that a client that changes its address and keeps its TLS
|
|
389
|
+
* stack and header order is still counted as one. One process's memory, with the limits of the history: at most
|
|
390
|
+
* `maxKeys` fingerprints, the least recently seen forgotten first, and at most `maxPerKey` times for each, so the
|
|
391
|
+
* count stops there.
|
|
392
|
+
*/
|
|
393
|
+
export declare function createSeenCounter(limits?: {
|
|
394
|
+
maxKeys?: number;
|
|
395
|
+
maxPerKey?: number;
|
|
396
|
+
}): SeenCounter;
|
|
397
|
+
/** `arrival.behaviour`: how the source acts over time */
|
|
398
|
+
export interface ArrivalBehaviour {
|
|
399
|
+
timing: TimingSignals;
|
|
400
|
+
navigation: NavigationSignals;
|
|
401
|
+
/** present only when the arrival sent a form report */
|
|
402
|
+
form?: FormSignals;
|
|
403
|
+
}
|
|
404
|
+
export interface Signals {
|
|
405
|
+
fingerprint: ArrivalFingerprint;
|
|
406
|
+
behaviour: ArrivalBehaviour;
|
|
407
|
+
}
|
|
408
|
+
/** Every signal of one arrival, from its observation and the history that `HistoryTracker.record` returned for it. */
|
|
409
|
+
export declare function signalsOf(o: Observation, history: SourceHistory): Signals;
|
|
410
|
+
/** The boolean signals that mark an arrival, by their path in the arrival fact. */
|
|
411
|
+
export declare const FLAG_SIGNALS: readonly ["fingerprint.headers.mismatch", "fingerprint.headers.hintsMismatch", "fingerprint.headers.fetchInvalid", "fingerprint.tls.mismatch", "fingerprint.tls.knownTool", "behaviour.timing.regular", "behaviour.navigation.directWrite", "behaviour.form.fast", "behaviour.form.noInput"];
|
|
412
|
+
export type FlagSignal = (typeof FLAG_SIGNALS)[number];
|
|
413
|
+
/** The value of a flag in the signals, or undefined when its group is absent (no TLS fingerprint, no form report). */
|
|
414
|
+
export declare function flagOf(signals: Signals, name: FlagSignal): boolean | undefined;
|