@knownagents/sdk 2.2.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -14
- package/dist/KnownAgents.d.ts.map +1 -1
- package/dist/KnownAgents.js +4 -2
- package/dist/types.d.ts +45 -15
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/KnownAgents.ts +4 -2
- package/src/types.ts +51 -15
package/README.md
CHANGED
|
@@ -137,29 +137,56 @@ Call `identifyAgents` to identify multiple requests at once:
|
|
|
137
137
|
```ts
|
|
138
138
|
const identifications = await knownAgents.identifyAgents([
|
|
139
139
|
{
|
|
140
|
-
|
|
141
|
-
request_headers: request1.headers
|
|
140
|
+
request_id: "request-1",
|
|
141
|
+
request_headers: request1.headers,
|
|
142
|
+
request_path: request1.url
|
|
142
143
|
},
|
|
143
144
|
{
|
|
144
|
-
|
|
145
|
-
request_headers: request2.headers
|
|
145
|
+
request_id: "request-2",
|
|
146
|
+
request_headers: request2.headers,
|
|
147
|
+
request_path: request2.url
|
|
146
148
|
}
|
|
147
149
|
])
|
|
148
150
|
```
|
|
149
151
|
|
|
152
|
+
Identification requests accept the following fields:
|
|
153
|
+
|
|
154
|
+
- `request_id`: A string identifier that will be echoed back in the response. Include this when sending an array to match each result to its request.
|
|
155
|
+
- `request_headers` (required): An object containing all available HTTP request headers, including `user-agent` when present, any IP-related headers like `x-forwarded-for` or `x-real-ip`, and HTTP message signature headers like `signature-input`, `signature`, and `signature-agent`.
|
|
156
|
+
- `request_ip`: The transport-level IP address of the incoming request. Used as a fallback when a valid client IP address cannot be derived from `request_headers`.
|
|
157
|
+
- `request_path`: The path of the incoming request (e.g. `"/products/123"`).
|
|
158
|
+
|
|
150
159
|
These methods return an object (or array of objects) with the following fields:
|
|
151
160
|
|
|
152
|
-
- `
|
|
161
|
+
- `request_id`: The identifier from the request (if provided).
|
|
153
162
|
- `result`: The identification result:
|
|
154
|
-
- `"verified"`:
|
|
155
|
-
- `"verification_failed"`:
|
|
156
|
-
- `"not_verifiable"`:
|
|
157
|
-
- `"
|
|
158
|
-
- `agent_id`: The unique ID of the agent
|
|
159
|
-
- `agent_token`: The name of the agent (e.g. `"Claude-User"`) (if identified)
|
|
160
|
-
- `agent_url`: The documentation URL of the agent (if identified)
|
|
161
|
-
- `agent_type_name`: The type of agent (e.g. `"AI Assistant"`) (if identified)
|
|
162
|
-
- `operator_name`: The company operating the agent (e.g. `"Anthropic"`) (if identified)
|
|
163
|
+
- `"verified"`: A known agent was identified and verified (its identity was confirmed as authentic)
|
|
164
|
+
- `"verification_failed"`: A known agent was identified, but failed verification (its identity may have been spoofed)
|
|
165
|
+
- `"not_verifiable"`: A known agent was identified, but its operator does not provide a known verification method
|
|
166
|
+
- `"not_identified"`: No known agent was identified (the request may have come from a human)
|
|
167
|
+
- `agent_id`: The unique ID of the identified agent.
|
|
168
|
+
- `agent_token`: The name of the agent (e.g. `"Claude-User"`) (if identified).
|
|
169
|
+
- `agent_url`: The documentation URL of the agent (if identified).
|
|
170
|
+
- `agent_type_name`: The type of agent (e.g. `"AI Assistant"`) (if identified).
|
|
171
|
+
- `operator_name`: The company operating the agent (e.g. `"Anthropic"`) (if identified).
|
|
172
|
+
- `is_disallowed_by_robots_txt`: Whether the identified agent is disallowed by robots.txt from accessing the `request_path`.
|
|
173
|
+
- `asn`: The autonomous system number associated with the request's IP address.
|
|
174
|
+
- `asn_operator`: The operator of the recognized autonomous system associated with the request's IP address.
|
|
175
|
+
- `asn_type`: The type of the recognized autonomous system associated with the request's IP address:
|
|
176
|
+
- `"isp"`
|
|
177
|
+
- `"hosting"`
|
|
178
|
+
- `"business"`
|
|
179
|
+
- `"education"`
|
|
180
|
+
- `"government"`
|
|
181
|
+
- `automation_score`: An integer from `0` to `99` indicating the strength of heuristic evidence that the request was made by an automated client. Higher scores indicate stronger detected automation signals. A score of `0` means that no automation signals were detected, not that the client is certainly human.
|
|
182
|
+
- `automation_signals`: Specific automation signals detected for the request. Available to Enterprise plans upon request:
|
|
183
|
+
- `"known_agent_ip"`: The request came from an IP address associated with a known agent, although no specific agent was identified
|
|
184
|
+
- `"inconsistency"`: The request contained inconsistent client or browser attributes
|
|
185
|
+
- `"non_browser"`: The request appears to have been made by a non-browser HTTP client
|
|
186
|
+
- `"automated_browser"`: The request contains indicators of browser automation
|
|
187
|
+
- `"cloud_service_provider"`: The request came from cloud or hosting infrastructure
|
|
188
|
+
|
|
189
|
+
See the [Agent Identification REST API documentation](https://knownagents.com/docs/identification/rest-api) for the canonical API reference.
|
|
163
190
|
|
|
164
191
|
## Requirements
|
|
165
192
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KnownAgents.d.ts","sourceRoot":"","sources":["../src/KnownAgents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAA;AAC3D,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAA;AAGvG,OAAO,KAAK,EACR,SAAS,EACT,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,8BAA8B,EAC9B,YAAY,EACf,MAAM,SAAS,CAAA;AAKhB;;GAEG;AACH,qBAAa,WAAW;IACpB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAQ;IACpC,OAAO,CAAC,QAAQ,CAAC,2BAA2B,CAAQ;IACpD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAQ;IACvC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAqB;IAChD,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,mBAAmB,CAAmC;IAE9D;;;;;OAKG;gBACS,WAAW,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB;IAMjE;;;;;;;;OAQG;IACH,uBAAuB,CAAC,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,8BAA8B,GAAG,IAAI;IAoC3H;;;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,CAAC,EAAE,8BAA8B,GAAG,IAAI;IAoC3H;;;;;;;;;OASG;IACH,YAAY,CAAC,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,6BAA6B,GAAG,IAAI;IAoEhH;;;;;;OAMG;IACH,WAAW,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,IAAI;IA2B3C;;;;;OAKG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAmBtB;;;;;;;;;OASG;IACG,iBAAiB,CAAC,UAAU,EAAE,SAAS,EAAE,EAAE,QAAQ,GAAE,MAAY,GAAG,OAAO,CAAC,MAAM,CAAC;IAoBzF;;;;;;;OAOG;IACG,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAqB5E;;;;;;;OAOG;IACG,cAAc,CAAC,QAAQ,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAsBxF,OAAO,CAAC,aAAa;YAaP,UAAU;CAmB3B"}
|
package/dist/KnownAgents.js
CHANGED
|
@@ -221,7 +221,9 @@ class KnownAgents {
|
|
|
221
221
|
"Content-Type": "application/json"
|
|
222
222
|
},
|
|
223
223
|
body: JSON.stringify({
|
|
224
|
-
request_headers: (0, headers_1.getFilteredHeaders)(request.headers)
|
|
224
|
+
request_headers: (0, headers_1.getFilteredHeaders)(request.headers),
|
|
225
|
+
request_ip: request.socket.remoteAddress,
|
|
226
|
+
request_path: request.url
|
|
225
227
|
})
|
|
226
228
|
});
|
|
227
229
|
if (response.ok) {
|
|
@@ -246,7 +248,7 @@ class KnownAgents {
|
|
|
246
248
|
"Authorization": `Bearer ${this.accessToken}`,
|
|
247
249
|
"Content-Type": "application/json"
|
|
248
250
|
},
|
|
249
|
-
body: JSON.stringify(requests.map(request => {
|
|
251
|
+
body: JSON.stringify(requests.map((request) => {
|
|
250
252
|
return {
|
|
251
253
|
...request,
|
|
252
254
|
request_headers: (0, headers_1.getFilteredHeaders)(request.request_headers),
|
package/dist/types.d.ts
CHANGED
|
@@ -60,35 +60,65 @@ export interface VisitRequest {
|
|
|
60
60
|
* Used for batch agent identification with `identifyAgents()`.
|
|
61
61
|
*/
|
|
62
62
|
export interface IdentificationRequest {
|
|
63
|
-
/**
|
|
64
|
-
|
|
65
|
-
/**
|
|
63
|
+
/** A string identifier that will be echoed back in the response. Include this when sending an array to match each result to its request. */
|
|
64
|
+
request_id?: string;
|
|
65
|
+
/** An object containing all available HTTP request headers, including `user-agent` when present, any IP-related headers like `x-forwarded-for` or `x-real-ip`, and HTTP message signature headers like `signature-input`, `signature`, and `signature-agent`. */
|
|
66
66
|
request_headers: IncomingHttpHeaders;
|
|
67
|
+
/** The transport-level IP address of the incoming request. Used as a fallback when a valid client IP address cannot be derived from `request_headers`. */
|
|
68
|
+
request_ip?: string;
|
|
69
|
+
/** The path of the incoming request (e.g. `"/products/123"`). */
|
|
70
|
+
request_path?: string;
|
|
67
71
|
}
|
|
68
72
|
/**
|
|
69
73
|
* The result of an agent identification request.
|
|
70
74
|
*/
|
|
71
75
|
export interface IdentificationResult {
|
|
72
|
-
/** The identifier from the request (if provided) */
|
|
73
|
-
|
|
76
|
+
/** The identifier from the request (if provided). */
|
|
77
|
+
request_id?: string;
|
|
74
78
|
/**
|
|
75
79
|
* The identification result:
|
|
76
|
-
* - "verified":
|
|
77
|
-
* - "verification_failed":
|
|
78
|
-
* - "
|
|
79
|
-
* - "
|
|
80
|
+
* - "verified": A known agent was identified and verified (its identity was confirmed as authentic)
|
|
81
|
+
* - "verification_failed": A known agent was identified, but failed verification (its identity may have been spoofed)
|
|
82
|
+
* - "not_verifiable": A known agent was identified, but its operator does not provide a known verification method
|
|
83
|
+
* - "not_identified": No known agent was identified (the request may have come from a human)
|
|
80
84
|
*/
|
|
81
|
-
result: "verified" | "verification_failed" | "
|
|
82
|
-
/** The unique ID of the identified agent */
|
|
85
|
+
result: "verified" | "verification_failed" | "not_verifiable" | "not_identified";
|
|
86
|
+
/** The unique ID of the identified agent. */
|
|
83
87
|
agent_id?: string;
|
|
84
|
-
/** The name of the
|
|
88
|
+
/** The name of the agent (e.g. `"Claude-User"`) (if identified). */
|
|
85
89
|
agent_token?: string;
|
|
86
|
-
/** The documentation URL
|
|
90
|
+
/** The documentation URL of the agent (if identified). */
|
|
87
91
|
agent_url?: string;
|
|
88
|
-
/** The type of
|
|
92
|
+
/** The type of agent (e.g. `"AI Assistant"`) (if identified). */
|
|
89
93
|
agent_type_name?: string;
|
|
90
|
-
/** The company
|
|
94
|
+
/** The company operating the agent (e.g. `"Anthropic"`) (if identified). */
|
|
91
95
|
operator_name?: string;
|
|
96
|
+
/** Whether the identified agent is disallowed by robots.txt from accessing the `request_path`. */
|
|
97
|
+
is_disallowed_by_robots_txt?: boolean;
|
|
98
|
+
/** The autonomous system number associated with the request's IP address. */
|
|
99
|
+
asn?: number;
|
|
100
|
+
/** The operator of the recognized autonomous system associated with the request's IP address. */
|
|
101
|
+
asn_operator?: string;
|
|
102
|
+
/**
|
|
103
|
+
* The type of the recognized autonomous system associated with the request's IP address:
|
|
104
|
+
* - "isp"
|
|
105
|
+
* - "hosting"
|
|
106
|
+
* - "business"
|
|
107
|
+
* - "education"
|
|
108
|
+
* - "government"
|
|
109
|
+
*/
|
|
110
|
+
asn_type?: "isp" | "hosting" | "business" | "education" | "government";
|
|
111
|
+
/** An integer from `0` to `99` indicating the strength of heuristic evidence that the request was made by an automated client. Higher scores indicate stronger detected automation signals. A score of `0` means that no automation signals were detected, not that the client is certainly human. */
|
|
112
|
+
automation_score?: number;
|
|
113
|
+
/**
|
|
114
|
+
* Specific automation signals detected for the request. Available to Enterprise plans upon request:
|
|
115
|
+
* - "known_agent_ip": The request came from an IP address associated with a known agent, although no specific agent was identified
|
|
116
|
+
* - "inconsistency": The request contained inconsistent client or browser attributes
|
|
117
|
+
* - "non_browser": The request appears to have been made by a non-browser HTTP client
|
|
118
|
+
* - "automated_browser": The request contains indicators of browser automation
|
|
119
|
+
* - "cloud_service_provider": The request came from cloud or hosting infrastructure
|
|
120
|
+
*/
|
|
121
|
+
automation_signals?: Array<"known_agent_ip" | "inconsistency" | "non_browser" | "automated_browser" | "cloud_service_provider">;
|
|
92
122
|
}
|
|
93
123
|
/**
|
|
94
124
|
* Agent types that can be controlled with robots.txt rules.
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAA;AAEpE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B,yGAAyG;IACzG,2BAA2B,CAAC,EAAE,MAAM,CAAA;IACpC,sFAAsF;IACtF,cAAc,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC3C,6BAA6B;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACzC,6BAA6B;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC5C;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IACzB,2EAA2E;IAC3E,YAAY,EAAE,MAAM,CAAA;IACpB,2CAA2C;IAC3C,cAAc,EAAE,MAAM,CAAA;IACtB,8EAA8E;IAC9E,eAAe,EAAE,mBAAmB,CAAA;IACpC,oDAAoD;IACpD,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,+EAA+E;IAC/E,gBAAgB,CAAC,EAAE,mBAAmB,CAAA;IACtC,4CAA4C;IAC5C,iCAAiC,CAAC,EAAE,MAAM,CAAA;IAC1C,sCAAsC;IACtC,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,gCAAgC;IAChC,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,kCAAkC;IAClC,4BAA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W,CAAC,EAAE,MAAM,CAAA;IACpB,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,iEAAiE;IACjE,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,4EAA4E;IAC5E,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,kGAAkG;IAClG,2BAA2B,CAAC,EAAE,OAAO,CAAA;IACrC,6EAA6E;IAC7E,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,iGAAiG;IACjG,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,KAAK,GAAG,SAAS,GAAG,UAAU,GAAG,WAAW,GAAG,YAAY,CAAA;IACtE,sSAAsS;IACtS,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,KAAK,CACtB,gBAAgB,GACd,eAAe,GACf,aAAa,GACb,mBAAmB,GACnB,wBAAwB,CAC7B,CAAA;CACJ;AAED;;GAEG;AACH,oBAAY,SAAS;IACjB,OAAO,aAAa;IACpB,WAAW,iBAAiB;IAC5B,aAAa,oBAAoB;IACjC,cAAc,qBAAqB;IACnC,aAAa,oBAAoB;IACjC,eAAe,sBAAsB;IACrC,QAAQ,aAAa;IACrB,cAAc,oBAAoB;IAClC,eAAe,qBAAqB;IACpC,OAAO,YAAY;IACnB,oBAAoB,0BAA0B;IAC9C,OAAO,YAAY;IACnB,UAAU,gBAAgB;IAC1B,mBAAmB,0BAA0B;IAC7C,eAAe,qBAAqB;IACpC,mBAAmB,0BAA0B;CAChD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knownagents/sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "The official Node.js SDK for Known Agents: AI agent analytics (bot traffic), LLM referral tracking, automatic robots.txt, agent identification",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
package/src/KnownAgents.ts
CHANGED
|
@@ -265,7 +265,9 @@ export class KnownAgents {
|
|
|
265
265
|
"Content-Type": "application/json"
|
|
266
266
|
},
|
|
267
267
|
body: JSON.stringify({
|
|
268
|
-
request_headers: getFilteredHeaders(request.headers)
|
|
268
|
+
request_headers: getFilteredHeaders(request.headers),
|
|
269
|
+
request_ip: request.socket.remoteAddress,
|
|
270
|
+
request_path: request.url
|
|
269
271
|
})
|
|
270
272
|
})
|
|
271
273
|
|
|
@@ -291,7 +293,7 @@ export class KnownAgents {
|
|
|
291
293
|
"Authorization": `Bearer ${this.accessToken}`,
|
|
292
294
|
"Content-Type": "application/json"
|
|
293
295
|
},
|
|
294
|
-
body: JSON.stringify(requests.map(request => {
|
|
296
|
+
body: JSON.stringify(requests.map((request) => {
|
|
295
297
|
return {
|
|
296
298
|
...request,
|
|
297
299
|
request_headers: getFilteredHeaders(request.request_headers),
|
package/src/types.ts
CHANGED
|
@@ -64,36 +64,72 @@ export interface VisitRequest {
|
|
|
64
64
|
* Used for batch agent identification with `identifyAgents()`.
|
|
65
65
|
*/
|
|
66
66
|
export interface IdentificationRequest {
|
|
67
|
-
/**
|
|
68
|
-
|
|
69
|
-
/**
|
|
67
|
+
/** A string identifier that will be echoed back in the response. Include this when sending an array to match each result to its request. */
|
|
68
|
+
request_id?: string
|
|
69
|
+
/** An object containing all available HTTP request headers, including `user-agent` when present, any IP-related headers like `x-forwarded-for` or `x-real-ip`, and HTTP message signature headers like `signature-input`, `signature`, and `signature-agent`. */
|
|
70
70
|
request_headers: IncomingHttpHeaders
|
|
71
|
+
/** The transport-level IP address of the incoming request. Used as a fallback when a valid client IP address cannot be derived from `request_headers`. */
|
|
72
|
+
request_ip?: string
|
|
73
|
+
/** The path of the incoming request (e.g. `"/products/123"`). */
|
|
74
|
+
request_path?: string
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
/**
|
|
74
78
|
* The result of an agent identification request.
|
|
75
79
|
*/
|
|
76
80
|
export interface IdentificationResult {
|
|
77
|
-
/** The identifier from the request (if provided) */
|
|
78
|
-
|
|
81
|
+
/** The identifier from the request (if provided). */
|
|
82
|
+
request_id?: string
|
|
79
83
|
/**
|
|
80
84
|
* The identification result:
|
|
81
|
-
* - "verified":
|
|
82
|
-
* - "verification_failed":
|
|
83
|
-
* - "
|
|
84
|
-
* - "
|
|
85
|
+
* - "verified": A known agent was identified and verified (its identity was confirmed as authentic)
|
|
86
|
+
* - "verification_failed": A known agent was identified, but failed verification (its identity may have been spoofed)
|
|
87
|
+
* - "not_verifiable": A known agent was identified, but its operator does not provide a known verification method
|
|
88
|
+
* - "not_identified": No known agent was identified (the request may have come from a human)
|
|
85
89
|
*/
|
|
86
|
-
result: "verified" | "verification_failed" | "
|
|
87
|
-
/** The unique ID of the identified agent */
|
|
90
|
+
result: "verified" | "verification_failed" | "not_verifiable" | "not_identified"
|
|
91
|
+
/** The unique ID of the identified agent. */
|
|
88
92
|
agent_id?: string
|
|
89
|
-
/** The name of the
|
|
93
|
+
/** The name of the agent (e.g. `"Claude-User"`) (if identified). */
|
|
90
94
|
agent_token?: string
|
|
91
|
-
/** The documentation URL
|
|
95
|
+
/** The documentation URL of the agent (if identified). */
|
|
92
96
|
agent_url?: string
|
|
93
|
-
/** The type of
|
|
97
|
+
/** The type of agent (e.g. `"AI Assistant"`) (if identified). */
|
|
94
98
|
agent_type_name?: string
|
|
95
|
-
/** The company
|
|
99
|
+
/** The company operating the agent (e.g. `"Anthropic"`) (if identified). */
|
|
96
100
|
operator_name?: string
|
|
101
|
+
/** Whether the identified agent is disallowed by robots.txt from accessing the `request_path`. */
|
|
102
|
+
is_disallowed_by_robots_txt?: boolean
|
|
103
|
+
/** The autonomous system number associated with the request's IP address. */
|
|
104
|
+
asn?: number
|
|
105
|
+
/** The operator of the recognized autonomous system associated with the request's IP address. */
|
|
106
|
+
asn_operator?: string
|
|
107
|
+
/**
|
|
108
|
+
* The type of the recognized autonomous system associated with the request's IP address:
|
|
109
|
+
* - "isp"
|
|
110
|
+
* - "hosting"
|
|
111
|
+
* - "business"
|
|
112
|
+
* - "education"
|
|
113
|
+
* - "government"
|
|
114
|
+
*/
|
|
115
|
+
asn_type?: "isp" | "hosting" | "business" | "education" | "government"
|
|
116
|
+
/** An integer from `0` to `99` indicating the strength of heuristic evidence that the request was made by an automated client. Higher scores indicate stronger detected automation signals. A score of `0` means that no automation signals were detected, not that the client is certainly human. */
|
|
117
|
+
automation_score?: number
|
|
118
|
+
/**
|
|
119
|
+
* Specific automation signals detected for the request. Available to Enterprise plans upon request:
|
|
120
|
+
* - "known_agent_ip": The request came from an IP address associated with a known agent, although no specific agent was identified
|
|
121
|
+
* - "inconsistency": The request contained inconsistent client or browser attributes
|
|
122
|
+
* - "non_browser": The request appears to have been made by a non-browser HTTP client
|
|
123
|
+
* - "automated_browser": The request contains indicators of browser automation
|
|
124
|
+
* - "cloud_service_provider": The request came from cloud or hosting infrastructure
|
|
125
|
+
*/
|
|
126
|
+
automation_signals?: Array<
|
|
127
|
+
"known_agent_ip"
|
|
128
|
+
| "inconsistency"
|
|
129
|
+
| "non_browser"
|
|
130
|
+
| "automated_browser"
|
|
131
|
+
| "cloud_service_provider"
|
|
132
|
+
>
|
|
97
133
|
}
|
|
98
134
|
|
|
99
135
|
/**
|