@kya-os/checkpoint-shared 1.10.0 → 1.11.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/CHANGELOG.md +89 -0
- package/dist/base64url-BbVG8f-v.js +65 -0
- package/dist/base64url-D2MvsR20.mjs +49 -0
- package/dist/base64url-D2MvsR20.mjs.map +1 -0
- package/dist/beacon-forward-secret/index.d.mts +4 -0
- package/dist/beacon-forward-secret/index.d.mts.map +1 -0
- package/dist/beacon-forward-secret/index.d.ts +4 -0
- package/dist/beacon-forward-secret/index.d.ts.map +1 -0
- package/dist/beacon-forward-secret/index.js +15 -0
- package/dist/beacon-forward-secret/index.mjs +15 -0
- package/dist/beacon-forward-secret/index.mjs.map +1 -0
- package/dist/beacon-types/index.d.mts +53 -1
- package/dist/beacon-types/index.d.mts.map +1 -1
- package/dist/beacon-types/index.d.ts +53 -1
- package/dist/beacon-types/index.d.ts.map +1 -1
- package/dist/beacon-types/index.js +86 -1
- package/dist/beacon-types/index.mjs +77 -2
- package/dist/beacon-types/index.mjs.map +1 -1
- package/dist/{browser-posture-5fPrsxx7.d.mts → browser-posture-WPk0kl9u.d.mts} +18 -1
- package/dist/browser-posture-WPk0kl9u.d.mts.map +1 -0
- package/dist/{browser-posture-CCR1kh5e.d.ts → browser-posture-_y6BcdXw.d.ts} +18 -1
- package/dist/browser-posture-_y6BcdXw.d.ts.map +1 -0
- package/dist/browser-posture-cookie.mjs.map +1 -1
- package/dist/browser-posture-proof-verifier.js +136 -5
- package/dist/browser-posture-proof-verifier.mjs +134 -2
- package/dist/browser-posture-proof-verifier.mjs.map +1 -0
- package/dist/browser-posture-proof.d.mts +1 -1
- package/dist/browser-posture-proof.d.ts +1 -1
- package/dist/browser-posture-proof.js +1 -1
- package/dist/browser-posture-proof.mjs +1 -1
- package/dist/browser-posture-report.d.mts +17 -0
- package/dist/browser-posture-report.d.mts.map +1 -1
- package/dist/browser-posture-report.d.ts +17 -0
- package/dist/browser-posture-report.d.ts.map +1 -1
- package/dist/browser-posture.d.mts +1 -1
- package/dist/browser-posture.d.ts +1 -1
- package/dist/browser-posture.js +18 -1
- package/dist/browser-posture.mjs +18 -1
- package/dist/browser-posture.mjs.map +1 -1
- package/dist/browser.d.mts +10 -0
- package/dist/browser.d.mts.map +1 -1
- package/dist/browser.d.ts +10 -0
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +1 -1
- package/dist/browser.mjs +1 -1
- package/dist/browser.mjs.map +1 -1
- package/dist/canonical-signer/index.d.mts.map +1 -1
- package/dist/canonical-signer/index.d.ts.map +1 -1
- package/dist/canonical-signer/index.js +0 -4
- package/dist/canonical-signer/index.mjs +0 -4
- package/dist/canonical-signer/index.mjs.map +1 -1
- package/dist/{client-ip-B7w-uHfS.d.ts → client-ip-8KneiMK0.d.mts} +12 -2
- package/dist/{client-ip-B7w-uHfS.d.mts.map → client-ip-8KneiMK0.d.mts.map} +1 -1
- package/dist/{client-ip-B7w-uHfS.d.mts → client-ip-8KneiMK0.d.ts} +12 -2
- package/dist/{client-ip-B7w-uHfS.d.ts.map → client-ip-8KneiMK0.d.ts.map} +1 -1
- package/dist/{client-ip-B8wFzJ5f.js → client-ip-BEmLC4I4.js} +71 -0
- package/dist/{client-ip-DIJyr6px.mjs → client-ip-DlHx7GGh.mjs} +61 -2
- package/dist/client-ip-DlHx7GGh.mjs.map +1 -0
- package/dist/client-ip.d.mts +2 -2
- package/dist/client-ip.d.ts +2 -2
- package/dist/client-ip.js +3 -1
- package/dist/client-ip.mjs +2 -2
- package/dist/deploy/index.d.mts.map +1 -1
- package/dist/deploy/index.d.ts.map +1 -1
- package/dist/deploy/index.js +5 -1
- package/dist/deploy/index.mjs +5 -1
- package/dist/deploy/index.mjs.map +1 -1
- package/dist/{detection-reason-mapping-CQexNvR7.d.ts → detection-reason-mapping-BemDaDED.d.mts} +5 -2
- package/dist/detection-reason-mapping-BemDaDED.d.mts.map +1 -0
- package/dist/{detection-reason-mapping-CQexNvR7.d.mts → detection-reason-mapping-BemDaDED.d.ts} +5 -2
- package/dist/detection-reason-mapping-BemDaDED.d.ts.map +1 -0
- package/dist/{detection-reason-mapping-B9RSkOs8.js → detection-reason-mapping-BxYaQ8kb.js} +33 -8
- package/dist/{detection-reason-mapping-BGymWIPl.mjs → detection-reason-mapping-j-7bXsVb.mjs} +29 -10
- package/dist/detection-reason-mapping-j-7bXsVb.mjs.map +1 -0
- package/dist/errors/index.d.mts +4 -0
- package/dist/errors/index.d.mts.map +1 -1
- package/dist/errors/index.d.ts +4 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +24 -8
- package/dist/errors/index.mjs +24 -8
- package/dist/errors/index.mjs.map +1 -1
- package/dist/{fetcher-CZfLcbRZ.d.mts → fetcher-CTKz07jg.d.mts} +12 -2
- package/dist/fetcher-CTKz07jg.d.mts.map +1 -0
- package/dist/{fetcher-CCw4Q95g.d.ts → fetcher-DCr920hx.d.ts} +12 -2
- package/dist/fetcher-DCr920hx.d.ts.map +1 -0
- package/dist/gateway-client-ip.js +1 -1
- package/dist/gateway-client-ip.mjs +1 -1
- package/dist/identity-cookie/index.d.mts +14 -0
- package/dist/identity-cookie/index.d.mts.map +1 -0
- package/dist/identity-cookie/index.d.ts +14 -0
- package/dist/identity-cookie/index.d.ts.map +1 -0
- package/dist/identity-cookie/index.js +45 -0
- package/dist/identity-cookie/index.mjs +43 -0
- package/dist/identity-cookie/index.mjs.map +1 -0
- package/dist/index.d.mts +598 -142
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +598 -142
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +793 -198
- package/dist/index.mjs +743 -188
- package/dist/index.mjs.map +1 -1
- package/dist/kya-http.d.mts +2 -2
- package/dist/kya-http.d.ts +2 -2
- package/dist/kya-http.js +2 -1
- package/dist/kya-http.mjs +2 -2
- package/dist/mcpi/dashboard-config/index.mjs.map +1 -1
- package/dist/patterns-CdTh7LU2.d.mts +35 -0
- package/dist/patterns-CdTh7LU2.d.mts.map +1 -0
- package/dist/patterns-CdTh7LU2.d.ts +35 -0
- package/dist/patterns-CdTh7LU2.d.ts.map +1 -0
- package/dist/{patterns-CiMpbdAF.js → patterns-CnNxRnaK.js} +3 -130
- package/dist/{patterns-D4OAsNQY.mjs → patterns-CpRk9R3M.mjs} +5 -96
- package/dist/patterns-CpRk9R3M.mjs.map +1 -0
- package/dist/patterns.d.mts +2 -2
- package/dist/patterns.d.ts +2 -2
- package/dist/patterns.js +1 -7
- package/dist/patterns.mjs +2 -2
- package/dist/policy/fetcher.d.mts +2 -2
- package/dist/policy/fetcher.d.ts +2 -2
- package/dist/policy/fetcher.js +100 -8
- package/dist/policy/fetcher.mjs +99 -9
- package/dist/policy/fetcher.mjs.map +1 -1
- package/dist/proxy-assertion-mapping-BVwXVSMZ.mjs +81 -0
- package/dist/proxy-assertion-mapping-BVwXVSMZ.mjs.map +1 -0
- package/dist/proxy-assertion-mapping-BxhENrcY.d.mts +70 -0
- package/dist/proxy-assertion-mapping-BxhENrcY.d.mts.map +1 -0
- package/dist/proxy-assertion-mapping-D64AyZfG.js +85 -0
- package/dist/proxy-assertion-mapping-DhAynFqG.d.ts +70 -0
- package/dist/proxy-assertion-mapping-DhAynFqG.d.ts.map +1 -0
- package/dist/proxy-assertions.d.mts +2 -0
- package/dist/proxy-assertions.d.ts +2 -0
- package/dist/proxy-assertions.js +4 -0
- package/dist/proxy-assertions.mjs +3 -0
- package/dist/reason-codes.d.mts +2 -2
- package/dist/reason-codes.d.ts +2 -2
- package/dist/reason-codes.js +3 -2
- package/dist/reason-codes.mjs +2 -2
- package/dist/{registered-sid-CnWIU_l1.d.ts → registered-sid-BgDhdj2l.d.mts} +13 -2
- package/dist/registered-sid-BgDhdj2l.d.mts.map +1 -0
- package/dist/{registered-sid-CnWIU_l1.d.mts → registered-sid-BgDhdj2l.d.ts} +13 -2
- package/dist/registered-sid-BgDhdj2l.d.ts.map +1 -0
- package/dist/{registered-sid-BZfDOfXy.js → registered-sid-DG1tSSvl.js} +67 -12
- package/dist/{registered-sid-CS9V8nPr.mjs → registered-sid-D__xiDPu.mjs} +63 -14
- package/dist/registered-sid-D__xiDPu.mjs.map +1 -0
- package/dist/timezone-country-B6PkDyNP.d.mts +15 -0
- package/dist/timezone-country-B6PkDyNP.d.mts.map +1 -0
- package/dist/timezone-country-B6PkDyNP.d.ts +15 -0
- package/dist/timezone-country-B6PkDyNP.d.ts.map +1 -0
- package/dist/timezone-country-CROxU2Tl.js +505 -0
- package/dist/timezone-country-CrrnkOdy.mjs +489 -0
- package/dist/timezone-country-CrrnkOdy.mjs.map +1 -0
- package/dist/timezone-country.d.mts +2 -0
- package/dist/timezone-country.d.ts +2 -0
- package/dist/timezone-country.js +6 -0
- package/dist/timezone-country.mjs +3 -0
- package/dist/tool-protection/index.mjs.map +1 -1
- package/fixtures/detection/cloudflare-alias-parity.json +383 -0
- package/fixtures/detection/reason-codes.json +3 -1
- package/fixtures/detection/signal-exposure-example.json +1 -1
- package/fixtures/iana-tzdata/backward +375 -0
- package/fixtures/iana-tzdata/renamed-zones.json +21 -0
- package/fixtures/iana-tzdata/version +1 -0
- package/fixtures/iana-tzdata/zone.tab +448 -0
- package/fixtures/workbench/management-session.v1.json +20 -0
- package/fixtures/workbench/model-credentials.v1.json +8 -0
- package/fixtures/workbench/task-grant.v1.json +37 -0
- package/package.json +25 -3
- package/src/data/compiled/merged-rules.json +9 -7
- package/dist/browser-posture-5fPrsxx7.d.mts.map +0 -1
- package/dist/browser-posture-CCR1kh5e.d.ts.map +0 -1
- package/dist/browser-posture-proof-verifier-DvsOmFrM.js +0 -202
- package/dist/browser-posture-proof-verifier-I0HP2Ics.mjs +0 -180
- package/dist/browser-posture-proof-verifier-I0HP2Ics.mjs.map +0 -1
- package/dist/client-ip-DIJyr6px.mjs.map +0 -1
- package/dist/detection-reason-mapping-BGymWIPl.mjs.map +0 -1
- package/dist/detection-reason-mapping-CQexNvR7.d.mts.map +0 -1
- package/dist/detection-reason-mapping-CQexNvR7.d.ts.map +0 -1
- package/dist/fetcher-CCw4Q95g.d.ts.map +0 -1
- package/dist/fetcher-CZfLcbRZ.d.mts.map +0 -1
- package/dist/patterns-Bp40cwh2.d.mts +0 -110
- package/dist/patterns-Bp40cwh2.d.mts.map +0 -1
- package/dist/patterns-Bp40cwh2.d.ts +0 -110
- package/dist/patterns-Bp40cwh2.d.ts.map +0 -1
- package/dist/patterns-D4OAsNQY.mjs.map +0 -1
- package/dist/registered-sid-CS9V8nPr.mjs.map +0 -1
- package/dist/registered-sid-CnWIU_l1.d.mts.map +0 -1
- package/dist/registered-sid-CnWIU_l1.d.ts.map +0 -1
|
@@ -55,7 +55,7 @@ const DETECTION_REASON_CODES = {
|
|
|
55
55
|
VERIFICATION_ERROR: "detection/verification-error",
|
|
56
56
|
/** A `signals[]` entry with `source === 'user_agent_pattern'`: the User-Agent matched a known pattern. */
|
|
57
57
|
UA_PATTERN_MATCH: "detection/ua-pattern-match",
|
|
58
|
-
/** `source === 'header_heuristic'
|
|
58
|
+
/** `source === 'header_heuristic'` or a request header contradiction: a header shape/combination heuristic matched. */
|
|
59
59
|
HEADER_HEURISTIC: "detection/header-heuristic",
|
|
60
60
|
/** `source === 'ip_heuristic'`: an IP-based heuristic matched. */
|
|
61
61
|
IP_HEURISTIC: "detection/ip-heuristic",
|
|
@@ -71,7 +71,7 @@ const DETECTION_REASON_CODES = {
|
|
|
71
71
|
UA_TLS_MISMATCH: "detection/ua-tls-mismatch",
|
|
72
72
|
/** `source === 'client.attributes'`: a pixel/beacon-reported client attribute contributed. */
|
|
73
73
|
CLIENT_ATTRIBUTE_SIGNAL: "detection/client-attribute-signal",
|
|
74
|
-
/** `source === 'behavioural.interaction'`: a behavioral/interaction signal contributed. */
|
|
74
|
+
/** `source === 'behavioural.interaction'`: a behavioral/interaction signal contributed, or the `no_human_proof` request flag: no verified human posture came with the call. */
|
|
75
75
|
BEHAVIORAL_SIGNAL: "detection/behavioral-signal",
|
|
76
76
|
/** `source === 'mcp_i'`: an MCP-I header was present (evidence short of a completed handshake). */
|
|
77
77
|
MCP_I_SIGNAL: "detection/mcp-i-signal",
|
|
@@ -85,6 +85,10 @@ const DETECTION_REASON_CODES = {
|
|
|
85
85
|
SCANNER_MISCLASSIFICATION_HINT_SIGNAL: "detection/scanner-misclassification-hint-signal",
|
|
86
86
|
/** `source === 'client_headless_escalation'`: the beacon disclosed `navigator.webdriver`, or reported corroborating automation evidence (CDP/plugin/WebGL consistency, a distinctive property), escalating the classification. */
|
|
87
87
|
CLIENT_HEADLESS_ESCALATION_SIGNAL: "detection/client-headless-escalation-signal",
|
|
88
|
+
/** `source === 'client_viewport_tell'`: an automation tool's default viewport (800x600) with reported behaviour and no interaction classified the request as a bot. */
|
|
89
|
+
AUTOMATION_DEFAULT_VIEWPORT: "detection/automation-default-viewport",
|
|
90
|
+
/** `source === 'client_interaction'`: the engine classified the request as human on client-reported interaction with nothing pointing the other way (basis `client_interaction`): client evidence, not proven identity. */
|
|
91
|
+
CLIENT_INTERACTION_HUMAN: "detection/client-interaction-human",
|
|
88
92
|
/** `source === 'transport.cloudflare_bot_management'`: Cloudflare's bot-management score or verified-bot determination contributed. */
|
|
89
93
|
CLOUDFLARE_BOT_MANAGEMENT_SIGNAL: "detection/cloudflare-bot-management-signal",
|
|
90
94
|
/** `source === 'session_velocity'`: the edge-computed request-velocity heuristic contributed. */
|
|
@@ -163,18 +167,34 @@ const SIGNAL_SOURCE_CODES = {
|
|
|
163
167
|
user_agent_pattern: DETECTION_REASON_CODES.UA_PATTERN_MATCH,
|
|
164
168
|
ua_tls_mismatch: DETECTION_REASON_CODES.UA_TLS_MISMATCH,
|
|
165
169
|
header_heuristic: DETECTION_REASON_CODES.HEADER_HEURISTIC,
|
|
170
|
+
page_load_on_json_post: DETECTION_REASON_CODES.HEADER_HEURISTIC,
|
|
171
|
+
client_hint_contradiction: DETECTION_REASON_CODES.HEADER_HEURISTIC,
|
|
172
|
+
browser_headers_without_user_agent: DETECTION_REASON_CODES.HEADER_HEURISTIC,
|
|
173
|
+
upgrade_insecure_requests_on_json_post: DETECTION_REASON_CODES.HEADER_HEURISTIC,
|
|
174
|
+
request_origin_mismatch: DETECTION_REASON_CODES.HEADER_HEURISTIC,
|
|
175
|
+
sec_fetch_user_on_background_request: DETECTION_REASON_CODES.HEADER_HEURISTIC,
|
|
176
|
+
grease_brand_mismatch: DETECTION_REASON_CODES.HEADER_HEURISTIC,
|
|
177
|
+
compression_headers_contradict_browser: DETECTION_REASON_CODES.HEADER_HEURISTIC,
|
|
178
|
+
accept_language_format_unusual: DETECTION_REASON_CODES.HEADER_HEURISTIC,
|
|
166
179
|
ip_heuristic: DETECTION_REASON_CODES.IP_HEURISTIC,
|
|
167
180
|
scanner_misclassification_hint: DETECTION_REASON_CODES.SCANNER_MISCLASSIFICATION_HINT_SIGNAL,
|
|
168
181
|
client_headless_escalation: DETECTION_REASON_CODES.CLIENT_HEADLESS_ESCALATION_SIGNAL,
|
|
182
|
+
client_viewport_tell: DETECTION_REASON_CODES.AUTOMATION_DEFAULT_VIEWPORT,
|
|
169
183
|
vendor_ip_feed: DETECTION_REASON_CODES.VENDOR_IP_CORROBORATED,
|
|
170
184
|
ip_intelligence: DETECTION_REASON_CODES.IP_INTELLIGENCE_PROXY_SIGNAL,
|
|
171
185
|
"transport.ja4": DETECTION_REASON_CODES.JA4_FINGERPRINT_MATCH,
|
|
172
186
|
"transport.cloudflare_bot_management": DETECTION_REASON_CODES.CLOUDFLARE_BOT_MANAGEMENT_SIGNAL,
|
|
173
187
|
client_integrity: DETECTION_REASON_CODES.CLIENT_INTEGRITY_FAILURE,
|
|
188
|
+
client_interaction: DETECTION_REASON_CODES.CLIENT_INTERACTION_HUMAN,
|
|
174
189
|
"client.attributes": DETECTION_REASON_CODES.CLIENT_ATTRIBUTE_SIGNAL,
|
|
175
190
|
"behavioural.interaction": DETECTION_REASON_CODES.BEHAVIORAL_SIGNAL,
|
|
176
191
|
session_velocity: DETECTION_REASON_CODES.SESSION_VELOCITY_SIGNAL
|
|
177
192
|
};
|
|
193
|
+
const isHeaderContradiction = (source) => source !== "header_heuristic" && reasonCodeForSignalSource(source) === DETECTION_REASON_CODES.HEADER_HEURISTIC;
|
|
194
|
+
function reasonCodeForSignalSource(source) {
|
|
195
|
+
if (source.startsWith("tier1_")) return DETECTION_REASON_CODES.TIER1_ATTRIBUTION_SIGNAL;
|
|
196
|
+
return Object.prototype.hasOwnProperty.call(SIGNAL_SOURCE_CODES, source) ? SIGNAL_SOURCE_CODES[source] : void 0;
|
|
197
|
+
}
|
|
178
198
|
/**
|
|
179
199
|
* Maps a detection's structured facts to an ordered, deduplicated list of
|
|
180
200
|
* `detection/*` reason codes, most-significant-evidence first:
|
|
@@ -205,14 +225,13 @@ function mapDetectionToReasonCodes(detail) {
|
|
|
205
225
|
else if (require_verification.isKyaOsWireMethod(verificationMethod) || require_verification.isKyaOsHandshakeMethod(verificationMethod)) push(DETECTION_REASON_CODES.MCP_I_VERIFIED);
|
|
206
226
|
else push(VERIFICATION_METHOD_CODES[verificationMethod]);
|
|
207
227
|
}
|
|
208
|
-
const
|
|
209
|
-
let hasTier1Signal = false;
|
|
228
|
+
const presentCodes = /* @__PURE__ */ new Set();
|
|
210
229
|
for (const signal of detail.signals ?? []) {
|
|
211
|
-
|
|
212
|
-
|
|
230
|
+
if (detail.detectionClass === "human" && isHeaderContradiction(signal.source)) continue;
|
|
231
|
+
presentCodes.add(reasonCodeForSignalSource(signal.source));
|
|
213
232
|
}
|
|
214
|
-
for (const
|
|
215
|
-
if (
|
|
233
|
+
for (const code of Object.values(SIGNAL_SOURCE_CODES)) if (presentCodes.has(code)) push(code);
|
|
234
|
+
if (presentCodes.has(DETECTION_REASON_CODES.TIER1_ATTRIBUTION_SIGNAL)) push(DETECTION_REASON_CODES.TIER1_ATTRIBUTION_SIGNAL);
|
|
216
235
|
if (detail.isAiCrawler) push(DETECTION_REASON_CODES.AI_CRAWLER_FLAG);
|
|
217
236
|
if (codes.length === 0) {
|
|
218
237
|
if (detail.detectionClass === "human") push(DETECTION_REASON_CODES.ZERO_EVIDENCE_HUMAN);
|
|
@@ -274,4 +293,10 @@ Object.defineProperty(exports, 'mapDetectionToReasonCodes', {
|
|
|
274
293
|
get: function () {
|
|
275
294
|
return mapDetectionToReasonCodes;
|
|
276
295
|
}
|
|
296
|
+
});
|
|
297
|
+
Object.defineProperty(exports, 'reasonCodeForSignalSource', {
|
|
298
|
+
enumerable: true,
|
|
299
|
+
get: function () {
|
|
300
|
+
return reasonCodeForSignalSource;
|
|
301
|
+
}
|
|
277
302
|
});
|
package/dist/{detection-reason-mapping-BGymWIPl.mjs → detection-reason-mapping-j-7bXsVb.mjs}
RENAMED
|
@@ -55,7 +55,7 @@ const DETECTION_REASON_CODES = {
|
|
|
55
55
|
VERIFICATION_ERROR: "detection/verification-error",
|
|
56
56
|
/** A `signals[]` entry with `source === 'user_agent_pattern'`: the User-Agent matched a known pattern. */
|
|
57
57
|
UA_PATTERN_MATCH: "detection/ua-pattern-match",
|
|
58
|
-
/** `source === 'header_heuristic'
|
|
58
|
+
/** `source === 'header_heuristic'` or a request header contradiction: a header shape/combination heuristic matched. */
|
|
59
59
|
HEADER_HEURISTIC: "detection/header-heuristic",
|
|
60
60
|
/** `source === 'ip_heuristic'`: an IP-based heuristic matched. */
|
|
61
61
|
IP_HEURISTIC: "detection/ip-heuristic",
|
|
@@ -71,7 +71,7 @@ const DETECTION_REASON_CODES = {
|
|
|
71
71
|
UA_TLS_MISMATCH: "detection/ua-tls-mismatch",
|
|
72
72
|
/** `source === 'client.attributes'`: a pixel/beacon-reported client attribute contributed. */
|
|
73
73
|
CLIENT_ATTRIBUTE_SIGNAL: "detection/client-attribute-signal",
|
|
74
|
-
/** `source === 'behavioural.interaction'`: a behavioral/interaction signal contributed. */
|
|
74
|
+
/** `source === 'behavioural.interaction'`: a behavioral/interaction signal contributed, or the `no_human_proof` request flag: no verified human posture came with the call. */
|
|
75
75
|
BEHAVIORAL_SIGNAL: "detection/behavioral-signal",
|
|
76
76
|
/** `source === 'mcp_i'`: an MCP-I header was present (evidence short of a completed handshake). */
|
|
77
77
|
MCP_I_SIGNAL: "detection/mcp-i-signal",
|
|
@@ -85,6 +85,10 @@ const DETECTION_REASON_CODES = {
|
|
|
85
85
|
SCANNER_MISCLASSIFICATION_HINT_SIGNAL: "detection/scanner-misclassification-hint-signal",
|
|
86
86
|
/** `source === 'client_headless_escalation'`: the beacon disclosed `navigator.webdriver`, or reported corroborating automation evidence (CDP/plugin/WebGL consistency, a distinctive property), escalating the classification. */
|
|
87
87
|
CLIENT_HEADLESS_ESCALATION_SIGNAL: "detection/client-headless-escalation-signal",
|
|
88
|
+
/** `source === 'client_viewport_tell'`: an automation tool's default viewport (800x600) with reported behaviour and no interaction classified the request as a bot. */
|
|
89
|
+
AUTOMATION_DEFAULT_VIEWPORT: "detection/automation-default-viewport",
|
|
90
|
+
/** `source === 'client_interaction'`: the engine classified the request as human on client-reported interaction with nothing pointing the other way (basis `client_interaction`): client evidence, not proven identity. */
|
|
91
|
+
CLIENT_INTERACTION_HUMAN: "detection/client-interaction-human",
|
|
88
92
|
/** `source === 'transport.cloudflare_bot_management'`: Cloudflare's bot-management score or verified-bot determination contributed. */
|
|
89
93
|
CLOUDFLARE_BOT_MANAGEMENT_SIGNAL: "detection/cloudflare-bot-management-signal",
|
|
90
94
|
/** `source === 'session_velocity'`: the edge-computed request-velocity heuristic contributed. */
|
|
@@ -163,18 +167,34 @@ const SIGNAL_SOURCE_CODES = {
|
|
|
163
167
|
user_agent_pattern: DETECTION_REASON_CODES.UA_PATTERN_MATCH,
|
|
164
168
|
ua_tls_mismatch: DETECTION_REASON_CODES.UA_TLS_MISMATCH,
|
|
165
169
|
header_heuristic: DETECTION_REASON_CODES.HEADER_HEURISTIC,
|
|
170
|
+
page_load_on_json_post: DETECTION_REASON_CODES.HEADER_HEURISTIC,
|
|
171
|
+
client_hint_contradiction: DETECTION_REASON_CODES.HEADER_HEURISTIC,
|
|
172
|
+
browser_headers_without_user_agent: DETECTION_REASON_CODES.HEADER_HEURISTIC,
|
|
173
|
+
upgrade_insecure_requests_on_json_post: DETECTION_REASON_CODES.HEADER_HEURISTIC,
|
|
174
|
+
request_origin_mismatch: DETECTION_REASON_CODES.HEADER_HEURISTIC,
|
|
175
|
+
sec_fetch_user_on_background_request: DETECTION_REASON_CODES.HEADER_HEURISTIC,
|
|
176
|
+
grease_brand_mismatch: DETECTION_REASON_CODES.HEADER_HEURISTIC,
|
|
177
|
+
compression_headers_contradict_browser: DETECTION_REASON_CODES.HEADER_HEURISTIC,
|
|
178
|
+
accept_language_format_unusual: DETECTION_REASON_CODES.HEADER_HEURISTIC,
|
|
166
179
|
ip_heuristic: DETECTION_REASON_CODES.IP_HEURISTIC,
|
|
167
180
|
scanner_misclassification_hint: DETECTION_REASON_CODES.SCANNER_MISCLASSIFICATION_HINT_SIGNAL,
|
|
168
181
|
client_headless_escalation: DETECTION_REASON_CODES.CLIENT_HEADLESS_ESCALATION_SIGNAL,
|
|
182
|
+
client_viewport_tell: DETECTION_REASON_CODES.AUTOMATION_DEFAULT_VIEWPORT,
|
|
169
183
|
vendor_ip_feed: DETECTION_REASON_CODES.VENDOR_IP_CORROBORATED,
|
|
170
184
|
ip_intelligence: DETECTION_REASON_CODES.IP_INTELLIGENCE_PROXY_SIGNAL,
|
|
171
185
|
"transport.ja4": DETECTION_REASON_CODES.JA4_FINGERPRINT_MATCH,
|
|
172
186
|
"transport.cloudflare_bot_management": DETECTION_REASON_CODES.CLOUDFLARE_BOT_MANAGEMENT_SIGNAL,
|
|
173
187
|
client_integrity: DETECTION_REASON_CODES.CLIENT_INTEGRITY_FAILURE,
|
|
188
|
+
client_interaction: DETECTION_REASON_CODES.CLIENT_INTERACTION_HUMAN,
|
|
174
189
|
"client.attributes": DETECTION_REASON_CODES.CLIENT_ATTRIBUTE_SIGNAL,
|
|
175
190
|
"behavioural.interaction": DETECTION_REASON_CODES.BEHAVIORAL_SIGNAL,
|
|
176
191
|
session_velocity: DETECTION_REASON_CODES.SESSION_VELOCITY_SIGNAL
|
|
177
192
|
};
|
|
193
|
+
const isHeaderContradiction = (source) => source !== "header_heuristic" && reasonCodeForSignalSource(source) === DETECTION_REASON_CODES.HEADER_HEURISTIC;
|
|
194
|
+
function reasonCodeForSignalSource(source) {
|
|
195
|
+
if (source.startsWith("tier1_")) return DETECTION_REASON_CODES.TIER1_ATTRIBUTION_SIGNAL;
|
|
196
|
+
return Object.prototype.hasOwnProperty.call(SIGNAL_SOURCE_CODES, source) ? SIGNAL_SOURCE_CODES[source] : void 0;
|
|
197
|
+
}
|
|
178
198
|
/**
|
|
179
199
|
* Maps a detection's structured facts to an ordered, deduplicated list of
|
|
180
200
|
* `detection/*` reason codes, most-significant-evidence first:
|
|
@@ -205,14 +225,13 @@ function mapDetectionToReasonCodes(detail) {
|
|
|
205
225
|
else if (isKyaOsWireMethod(verificationMethod) || isKyaOsHandshakeMethod(verificationMethod)) push(DETECTION_REASON_CODES.MCP_I_VERIFIED);
|
|
206
226
|
else push(VERIFICATION_METHOD_CODES[verificationMethod]);
|
|
207
227
|
}
|
|
208
|
-
const
|
|
209
|
-
let hasTier1Signal = false;
|
|
228
|
+
const presentCodes = /* @__PURE__ */ new Set();
|
|
210
229
|
for (const signal of detail.signals ?? []) {
|
|
211
|
-
|
|
212
|
-
|
|
230
|
+
if (detail.detectionClass === "human" && isHeaderContradiction(signal.source)) continue;
|
|
231
|
+
presentCodes.add(reasonCodeForSignalSource(signal.source));
|
|
213
232
|
}
|
|
214
|
-
for (const
|
|
215
|
-
if (
|
|
233
|
+
for (const code of Object.values(SIGNAL_SOURCE_CODES)) if (presentCodes.has(code)) push(code);
|
|
234
|
+
if (presentCodes.has(DETECTION_REASON_CODES.TIER1_ATTRIBUTION_SIGNAL)) push(DETECTION_REASON_CODES.TIER1_ATTRIBUTION_SIGNAL);
|
|
216
235
|
if (detail.isAiCrawler) push(DETECTION_REASON_CODES.AI_CRAWLER_FLAG);
|
|
217
236
|
if (codes.length === 0) {
|
|
218
237
|
if (detail.detectionClass === "human") push(DETECTION_REASON_CODES.ZERO_EVIDENCE_HUMAN);
|
|
@@ -245,5 +264,5 @@ function formatReasonCodesHeader(codes) {
|
|
|
245
264
|
}
|
|
246
265
|
|
|
247
266
|
//#endregion
|
|
248
|
-
export {
|
|
249
|
-
//# sourceMappingURL=detection-reason-mapping-
|
|
267
|
+
export { reasonCodeForSignalSource as a, mapDetectionToReasonCodes as i, MAX_REASON_CODES_ON_WIRE as n, DETECTION_REASON_CODES as o, formatReasonCodesHeader as r, MAX_REASON_CODES_HEADER_BYTES as t };
|
|
268
|
+
//# sourceMappingURL=detection-reason-mapping-j-7bXsVb.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detection-reason-mapping-j-7bXsVb.mjs","names":[],"sources":["../src/core/detection-reason-codes.ts","../src/core/detection-reason-mapping.ts"],"sourcesContent":["/**\n * Detection reason code registry — machine-readable \"why\" behind a\n * `kya-confidence` verdict (companion to the `kya-http-error-codes.ts` /\n * `bespoke-policy.ts` registries; same `as const satisfies` + namespaced\n * string-literal convention).\n *\n * The engine already emits everything needed to derive these in structured\n * form — `DetectionSignalDetail[]` (`signal_type` / `source`),\n * `detection_class`, `verification_method`, and the AI-crawler flag (see\n * `rust/crates/kya-os-engine/src/types.rs` + `api.rs`) — but until now the\n * only wire-level \"why\" was `reasons[]`, free English prose, and only ever\n * on a block/claim-rejection response. Downstream dashboards, alerts, and\n * customer integrations were left string-matching that prose (see\n * `apps/web/app/api/v1/pixel/route.ts` `validateDetectionResult`,\n * `detection-cache.service.ts`, and `agent-classification.service.ts` for\n * three live examples of exactly that pattern).\n *\n * `detection/*` codes are a PROJECTION of the engine's own fields: see\n * `mapDetectionToReasonCodes` in the sibling `detection-reason-mapping.ts`,\n * the single place that turns a detection's structured facts into an\n * ordered list of these codes (consumed by the gateway worker via\n * `apps/web/workers/gateway/src/detection/reason-codes.ts` and by the\n * `/api/v1/enforce` signal exposure, KYA-1107). This registry never\n * changes a verdict; it only labels one that already happened.\n *\n * The golden fixture `packages/checkpoint-shared/fixtures/detection/reason-codes.json`\n * is the source of truth; the parity test in\n * `__tests__/detection-reason-codes.test.ts` asserts this map is byte-exact\n * against it (no drift, no omissions) — same guard shape as\n * `kya-http-error-codes.test.ts`.\n *\n * `as const satisfies Record<string, \\`detection/${string}\\`>` keeps the\n * narrow literal value types (autocomplete + a compile error on a typo'd\n * code) while proving every value is a well-formed `detection/…` string.\n */\nexport const DETECTION_REASON_CODES = {\n // ── Cryptographic / verified attribution (strongest evidence, first) ────\n /** `verificationMethod === 'kya-http'`: a kya-http/RFC 9421 signature verified. */\n SIGNATURE_VERIFIED: 'detection/signature-verified',\n /** `verificationMethod === 'kya-http-delegated'`: a verified delegation credential rode the request. */\n DELEGATION_VERIFIED: 'detection/delegation-verified',\n /** `verificationMethod === 'mcp-i' | 'kya-os'` (the wire values; `isKyaOsWireMethod`): the MCP-I/KYA-OS handshake verified. */\n MCP_I_VERIFIED: 'detection/mcp-i-verified',\n /** `verificationMethod === 'did'`: the retired `KYA-Agent-DID` header scheme verified a signature. Historical records only; the gateway no longer emits it. */\n DID_SIGNATURE_VERIFIED: 'detection/did-signature-verified',\n /** `verificationMethod === 'signature'`: the worker's RFC 9421 signature verifier (ChatGPT et al.) verified against the DB-refreshed key directory. */\n RFC9421_SIGNATURE_VERIFIED: 'detection/rfc9421-signature-verified',\n /** `verificationMethod` starts with `tier1_` (e.g. `tier1_rfc9421`): the engine's Tier-1 protocol attribution verified. */\n TIER1_ATTRIBUTION_VERIFIED: 'detection/tier1-attribution-verified',\n /** `verificationMethod === 'a2a'`: an A2A Agent Card's declared security scheme (RFC 9421 keyid, or a JWT bearer against resolved JWKS) cryptographically verified. */\n A2A_VERIFIED: 'detection/a2a-verified',\n /** `verificationMethod === 'error'`: a presented credential was demoted/rejected during verification; see the sibling `kyaErrorCode`. */\n VERIFICATION_ERROR: 'detection/verification-error',\n\n // ── Structured evidence signals (one per distinct `signals[].source`) ───\n /** A `signals[]` entry with `source === 'user_agent_pattern'`: the User-Agent matched a known pattern. */\n UA_PATTERN_MATCH: 'detection/ua-pattern-match',\n /** `source === 'header_heuristic'` or a request header contradiction: a header shape/combination heuristic matched. */\n HEADER_HEURISTIC: 'detection/header-heuristic',\n /** `source === 'ip_heuristic'`: an IP-based heuristic matched. */\n IP_HEURISTIC: 'detection/ip-heuristic',\n /** `source === 'vendor_ip_feed'`: the request IP matched a known vendor's published IP range. */\n VENDOR_IP_CORROBORATED: 'detection/vendor-ip-corroborated',\n /** `source === 'ip_intelligence'`: the host's IP-intelligence provider flagged the request's true IP as a proxy/VPN/Tor/anonymization exit. */\n IP_INTELLIGENCE_PROXY_SIGNAL: 'detection/ip-intelligence-proxy-signal',\n /** `source === 'transport.ja4'`: a TLS JA4 fingerprint was observed at the terminating proxy (emit-only observation marker; it matches no list). */\n JA4_FINGERPRINT_MATCH: 'detection/ja4-fingerprint-match',\n /** `source === 'client_integrity'`: the pixel/beacon ingest's own nonce-binding or pairwise-contradiction check flagged this request as not coming from the client it claims to. */\n CLIENT_INTEGRITY_FAILURE: 'detection/client-integrity-failure',\n /** `source === 'ua_tls_mismatch'`: the User-Agent claims a browser but the JA4 cipher-list hash (JA4_b) belongs to known non-browser tooling. */\n UA_TLS_MISMATCH: 'detection/ua-tls-mismatch',\n /** `source === 'client.attributes'`: a pixel/beacon-reported client attribute contributed. */\n CLIENT_ATTRIBUTE_SIGNAL: 'detection/client-attribute-signal',\n /** `source === 'behavioural.interaction'`: a behavioral/interaction signal contributed, or the `no_human_proof` request flag: no verified human posture came with the call. */\n BEHAVIORAL_SIGNAL: 'detection/behavioral-signal',\n /** `source === 'mcp_i'`: an MCP-I header was present (evidence short of a completed handshake). */\n MCP_I_SIGNAL: 'detection/mcp-i-signal',\n /** `source === 'kya_http_binding'`: a kya-http binding was presented (evidence short of full verification). */\n KYA_HTTP_BINDING_SIGNAL: 'detection/kya-http-binding-signal',\n /** `source === 'kya_delegation_bearer'`: a delegation bearer credential was presented. */\n KYA_DELEGATION_BEARER_SIGNAL: 'detection/kya-delegation-bearer-signal',\n /** A `signals[]` entry with `source === 'a2a_agent_card'`: an A2A Agent Card was presented (evidence short of, or alongside, full verification). */\n A2A_CARD_SIGNAL: 'detection/a2a-card-signal',\n /** `source === 'scanner_misclassification_hint'`: Cloudflare's bot score contradicted a zero-evidence Human verdict, overriding it to Unknown. */\n SCANNER_MISCLASSIFICATION_HINT_SIGNAL: 'detection/scanner-misclassification-hint-signal',\n /** `source === 'client_headless_escalation'`: the beacon disclosed `navigator.webdriver`, or reported corroborating automation evidence (CDP/plugin/WebGL consistency, a distinctive property), escalating the classification. */\n CLIENT_HEADLESS_ESCALATION_SIGNAL: 'detection/client-headless-escalation-signal',\n /** `source === 'client_viewport_tell'`: an automation tool's default viewport (800x600) with reported behaviour and no interaction classified the request as a bot. */\n AUTOMATION_DEFAULT_VIEWPORT: 'detection/automation-default-viewport',\n /** `source === 'client_interaction'`: the engine classified the request as human on client-reported interaction with nothing pointing the other way (basis `client_interaction`): client evidence, not proven identity. */\n CLIENT_INTERACTION_HUMAN: 'detection/client-interaction-human',\n /** `source === 'transport.cloudflare_bot_management'`: Cloudflare's bot-management score or verified-bot determination contributed. */\n CLOUDFLARE_BOT_MANAGEMENT_SIGNAL: 'detection/cloudflare-bot-management-signal',\n /** `source === 'session_velocity'`: the edge-computed request-velocity heuristic contributed. */\n SESSION_VELOCITY_SIGNAL: 'detection/session-velocity-signal',\n /** A `signals[]` entry whose `source` starts with `tier1_`: raw Tier-1 protocol evidence, short of (or alongside) full verification. */\n TIER1_ATTRIBUTION_SIGNAL: 'detection/tier1-attribution-signal',\n\n // ── Classification flags ─────────────────────────────────────────────────\n /** `isAiCrawler === true`: classified as an AI training crawler (GPTBot, ClaudeBot, etc.), not an interactive agent. */\n AI_CRAWLER_FLAG: 'detection/ai-crawler-flag',\n\n // ── Zero-evidence fallbacks — an assumed verdict deserves a code saying so\n // (in the spirit of #4800): these fire ONLY when nothing above matched,\n // so the mapping never returns an empty list. ───────────────────────────\n /** `detectionClass === 'human'` with no contributing signals and no verification: the baseline \"nothing matched\" human path. */\n ZERO_EVIDENCE_HUMAN: 'detection/zero-evidence-human',\n /** `detectionClass === 'incomplete_data' | 'unknown'` (or absent): the engine could not classify confidently. */\n INCOMPLETE_DATA_OVERRIDE: 'detection/incomplete-data-override',\n /** A non-human, non-incomplete-data class (`ai_agent` / `bot` / `automation`) reached with zero contributing signals and no verification: classified on prior/heuristic grounds alone. */\n CLASSIFIED_WITHOUT_SIGNAL_EVIDENCE: 'detection/classified-without-signal-evidence',\n} as const satisfies Record<string, `detection/${string}`>;\n\n/** A `detection/*` registry code (the value side of {@link DETECTION_REASON_CODES}). */\nexport type DetectionReasonCode =\n (typeof DETECTION_REASON_CODES)[keyof typeof DETECTION_REASON_CODES];\n","/**\n * Detection reason-code mapping: the single pure projection of a\n * detection's structured facts onto the `DETECTION_REASON_CODES` registry\n * (#4874).\n *\n * The engine already emits structured evidence (`signals[]` with a typed\n * `source`, `verificationMethod`, `detectionClass`, `isAiCrawler`) but the\n * only wire-level \"why\" used to be `reasons[]`, free English prose. This\n * module turns that structured evidence into an ordered list of stable,\n * namespaced codes, most-significant-evidence first.\n *\n * Consumers (all invoke this SAME pure function, so their codes can never\n * diverge):\n * - the gateway worker's `addDetectionHeaders` (`KYA-Reason-Codes` on\n * EVERY proxied response, including allow) and `log-detection.ts`\n * (persisted alongside the detection row), both via the re-export in\n * `apps/web/workers/gateway/src/detection/reason-codes.ts`;\n * - the `/api/v1/enforce` response's signal exposure\n * (KYA-1107) via `apps/web/lib/detection/signal-exposure.ts`.\n *\n * This module NEVER changes a verdict; it only labels one that already\n * happened (same non-negotiable as the registry doc comment).\n */\nimport { DETECTION_REASON_CODES, type DetectionReasonCode } from './detection-reason-codes';\nimport { isKyaOsHandshakeMethod, isKyaOsWireMethod } from '../utils/verification';\n\n/**\n * The structural subset of a detection detail the mapping actually reads.\n * Both the gateway's `GatewayDetectionDetail` (wire value space) and the\n * enforce route's engine-refined detail (engine value space) are assignable\n * since the mapping dual-accepts both value spaces where they differ (see the\n * handshake branch below).\n */\nexport interface ReasonCodeDetectionFacts {\n /** Verification method: WIRE (`mcp-i`/`kya-os`, `kya-http`, …) or ENGINE (`mcp_i_handshake`, …) value space. */\n verificationMethod?: string | null;\n /** The engine's per-signal evidence breakdown; only each entry's `source` is read. */\n signals?: ReadonlyArray<{ source: string }> | null;\n /** The engine's AI-training-crawler classification flag. */\n isAiCrawler?: boolean | null;\n /** Flat wire-form detection class (`human` | `ai_agent` | `bot` | `automation` | `incomplete_data` | `unknown`). */\n detectionClass?: string | null;\n}\n\n/**\n * `verificationMethod` → the single strongest code it proves. Keys are the\n * WIRE value space; the KYA-OS handshake/delegation alias pairs are handled\n * as explicit branches in `mapDetectionToReasonCodes` via the shared\n * `isKyaOs*Method` predicates (the SSOT for those alias pairs; Bugbot on\n * PR #4874 caught this table keyed on engine values instead, silently\n * missing every verified MCP-I/KYA-OS handshake) rather than hardcoding the\n * alias strings a second time in this map.\n */\nconst VERIFICATION_METHOD_CODES: Readonly<Record<string, DetectionReasonCode>> = {\n 'kya-http-delegated': DETECTION_REASON_CODES.DELEGATION_VERIFIED,\n 'kya-http': DETECTION_REASON_CODES.SIGNATURE_VERIFIED,\n did: DETECTION_REASON_CODES.DID_SIGNATURE_VERIFIED,\n signature: DETECTION_REASON_CODES.RFC9421_SIGNATURE_VERIFIED,\n a2a: DETECTION_REASON_CODES.A2A_VERIFIED,\n error: DETECTION_REASON_CODES.VERIFICATION_ERROR,\n};\n\n/**\n * A `signals[].source` value → the code naming that raw evidence.\n *\n * Declaration order IS the consideration order `mapDetectionToReasonCodes`\n * iterates (object key insertion order is guaranteed for string keys), NOT\n * the raw `signals[]` array order, which the engine assembles differently\n * per detection path (mirrors `buildVerdictEvidence`'s own doc comment on\n * the same nondeterminism). Roughly the engine's own construction order in\n * `api.rs` (identity/delegation evidence before UA/IP heuristics). Keeping\n * one map (rather than a map plus a separate priority-order array) means a\n * new signal source is added in exactly one place.\n */\nconst SIGNAL_SOURCE_CODES: Readonly<Record<string, DetectionReasonCode>> = {\n mcp_i: DETECTION_REASON_CODES.MCP_I_SIGNAL,\n kya_http_binding: DETECTION_REASON_CODES.KYA_HTTP_BINDING_SIGNAL,\n kya_delegation_bearer: DETECTION_REASON_CODES.KYA_DELEGATION_BEARER_SIGNAL,\n a2a_agent_card: DETECTION_REASON_CODES.A2A_CARD_SIGNAL,\n user_agent_pattern: DETECTION_REASON_CODES.UA_PATTERN_MATCH,\n ua_tls_mismatch: DETECTION_REASON_CODES.UA_TLS_MISMATCH,\n header_heuristic: DETECTION_REASON_CODES.HEADER_HEURISTIC,\n page_load_on_json_post: DETECTION_REASON_CODES.HEADER_HEURISTIC,\n client_hint_contradiction: DETECTION_REASON_CODES.HEADER_HEURISTIC,\n browser_headers_without_user_agent: DETECTION_REASON_CODES.HEADER_HEURISTIC,\n upgrade_insecure_requests_on_json_post: DETECTION_REASON_CODES.HEADER_HEURISTIC,\n request_origin_mismatch: DETECTION_REASON_CODES.HEADER_HEURISTIC,\n sec_fetch_user_on_background_request: DETECTION_REASON_CODES.HEADER_HEURISTIC,\n grease_brand_mismatch: DETECTION_REASON_CODES.HEADER_HEURISTIC,\n compression_headers_contradict_browser: DETECTION_REASON_CODES.HEADER_HEURISTIC,\n accept_language_format_unusual: DETECTION_REASON_CODES.HEADER_HEURISTIC,\n ip_heuristic: DETECTION_REASON_CODES.IP_HEURISTIC,\n scanner_misclassification_hint: DETECTION_REASON_CODES.SCANNER_MISCLASSIFICATION_HINT_SIGNAL,\n client_headless_escalation: DETECTION_REASON_CODES.CLIENT_HEADLESS_ESCALATION_SIGNAL,\n client_viewport_tell: DETECTION_REASON_CODES.AUTOMATION_DEFAULT_VIEWPORT,\n vendor_ip_feed: DETECTION_REASON_CODES.VENDOR_IP_CORROBORATED,\n ip_intelligence: DETECTION_REASON_CODES.IP_INTELLIGENCE_PROXY_SIGNAL,\n 'transport.ja4': DETECTION_REASON_CODES.JA4_FINGERPRINT_MATCH,\n 'transport.cloudflare_bot_management': DETECTION_REASON_CODES.CLOUDFLARE_BOT_MANAGEMENT_SIGNAL,\n client_integrity: DETECTION_REASON_CODES.CLIENT_INTEGRITY_FAILURE,\n // Before the client attribute and behavioural echoes a human verdict also\n // carries, so the header's first five codes always name its basis.\n client_interaction: DETECTION_REASON_CODES.CLIENT_INTERACTION_HUMAN,\n 'client.attributes': DETECTION_REASON_CODES.CLIENT_ATTRIBUTE_SIGNAL,\n 'behavioural.interaction': DETECTION_REASON_CODES.BEHAVIORAL_SIGNAL,\n session_velocity: DETECTION_REASON_CODES.SESSION_VELOCITY_SIGNAL,\n};\n\nconst isHeaderContradiction = (source: string): boolean =>\n source !== 'header_heuristic' &&\n reasonCodeForSignalSource(source) === DETECTION_REASON_CODES.HEADER_HEURISTIC;\n\nexport function reasonCodeForSignalSource(source: string): DetectionReasonCode | undefined {\n if (source.startsWith('tier1_')) return DETECTION_REASON_CODES.TIER1_ATTRIBUTION_SIGNAL;\n return Object.prototype.hasOwnProperty.call(SIGNAL_SOURCE_CODES, source)\n ? SIGNAL_SOURCE_CODES[source]\n : undefined;\n}\n\n/**\n * Maps a detection's structured facts to an ordered, deduplicated list of\n * `detection/*` reason codes, most-significant-evidence first:\n *\n * 1. Verification-method-derived (cryptographic proof, strongest).\n * 2. Signal-source-derived (raw structured evidence), one code per\n * distinct source actually present, deduplicated.\n * 3. The AI-crawler classification flag.\n * 4. A zero-evidence fallback, ONLY when nothing above matched, so this\n * function never returns an empty list. An assumed verdict (e.g. the\n * baseline \"no known agent indicators matched\" human path) deserves a\n * code saying so, in the spirit of #4800, rather than silence.\n *\n * Pure: no I/O, no mutation of `detail`.\n */\nexport function mapDetectionToReasonCodes(detail: ReasonCodeDetectionFacts): DetectionReasonCode[] {\n const codes: DetectionReasonCode[] = [];\n const seen = new Set<DetectionReasonCode>();\n const push = (code: DetectionReasonCode | undefined): void => {\n if (code && !seen.has(code)) {\n seen.add(code);\n codes.push(code);\n }\n };\n\n // 1. Verification method.\n const verificationMethod = detail.verificationMethod;\n if (verificationMethod) {\n if (verificationMethod.startsWith('tier1_')) {\n push(DETECTION_REASON_CODES.TIER1_ATTRIBUTION_VERIFIED);\n } else if (\n // Dual-accept BOTH value spaces for the KYA-OS handshake: the gateway\n // worker normalizes to the WIRE values (`mcp-i`/`kya-os`) before\n // calling in, while the enforce route's engine-refined detail carries\n // the ENGINE values (`mcp_i_handshake`/`kyaos_handshake`). Routing\n // both through the shared predicates keeps the alias pairs in exactly\n // one place and closes the exact single-value-space gap Bugbot\n // caught on PR #4874.\n isKyaOsWireMethod(verificationMethod) ||\n isKyaOsHandshakeMethod(verificationMethod)\n ) {\n push(DETECTION_REASON_CODES.MCP_I_VERIFIED);\n } else {\n push(VERIFICATION_METHOD_CODES[verificationMethod]);\n }\n }\n\n const presentCodes = new Set<DetectionReasonCode | undefined>();\n for (const signal of detail.signals ?? []) {\n if (detail.detectionClass === 'human' && isHeaderContradiction(signal.source)) continue;\n presentCodes.add(reasonCodeForSignalSource(signal.source));\n }\n for (const code of Object.values(SIGNAL_SOURCE_CODES)) {\n if (presentCodes.has(code)) push(code);\n }\n if (presentCodes.has(DETECTION_REASON_CODES.TIER1_ATTRIBUTION_SIGNAL)) {\n push(DETECTION_REASON_CODES.TIER1_ATTRIBUTION_SIGNAL);\n }\n\n // 3. AI-crawler flag: additive, independent of the codes above.\n if (detail.isAiCrawler) {\n push(DETECTION_REASON_CODES.AI_CRAWLER_FLAG);\n }\n\n // 4. Zero-evidence fallback: only when nothing above fired.\n if (codes.length === 0) {\n if (detail.detectionClass === 'human') {\n push(DETECTION_REASON_CODES.ZERO_EVIDENCE_HUMAN);\n } else if (\n detail.detectionClass === 'incomplete_data' ||\n detail.detectionClass === 'unknown' ||\n !detail.detectionClass\n ) {\n push(DETECTION_REASON_CODES.INCOMPLETE_DATA_OVERRIDE);\n } else {\n push(DETECTION_REASON_CODES.CLASSIFIED_WITHOUT_SIGNAL_EVIDENCE);\n }\n }\n\n return codes;\n}\n\n/** Wire cap: at most this many codes on the `KYA-Reason-Codes` header. */\nexport const MAX_REASON_CODES_ON_WIRE = 5;\n/** Wire cap: the header's serialized UTF-8 byte budget. */\nexport const MAX_REASON_CODES_HEADER_BYTES = 256;\n\nconst HEADER_BYTES_ENCODER = new TextEncoder();\n\n/**\n * Formats an ordered reason-code list into the `KYA-Reason-Codes` header\n * value: comma-separated, capped at {@link MAX_REASON_CODES_ON_WIRE} codes,\n * then trimmed from the end (never mid-string) until the UTF-8 byte length\n * fits {@link MAX_REASON_CODES_HEADER_BYTES}. `codes` is assumed already\n * ordered most-significant-first (mapDetectionToReasonCodes's contract);\n * this function only truncates, it never reorders.\n */\nexport function formatReasonCodesHeader(codes: readonly DetectionReasonCode[]): string {\n const capped = codes.slice(0, MAX_REASON_CODES_ON_WIRE);\n while (capped.length > 0) {\n const joined = capped.join(',');\n if (HEADER_BYTES_ENCODER.encode(joined).byteLength <= MAX_REASON_CODES_HEADER_BYTES) {\n return joined;\n }\n capped.pop();\n }\n return '';\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,yBAAyB;;CAGpC,oBAAoB;;CAEpB,qBAAqB;;CAErB,gBAAgB;;CAEhB,wBAAwB;;CAExB,4BAA4B;;CAE5B,4BAA4B;;CAE5B,cAAc;;CAEd,oBAAoB;;CAIpB,kBAAkB;;CAElB,kBAAkB;;CAElB,cAAc;;CAEd,wBAAwB;;CAExB,8BAA8B;;CAE9B,uBAAuB;;CAEvB,0BAA0B;;CAE1B,iBAAiB;;CAEjB,yBAAyB;;CAEzB,mBAAmB;;CAEnB,cAAc;;CAEd,yBAAyB;;CAEzB,8BAA8B;;CAE9B,iBAAiB;;CAEjB,uCAAuC;;CAEvC,mCAAmC;;CAEnC,6BAA6B;;CAE7B,0BAA0B;;CAE1B,kCAAkC;;CAElC,yBAAyB;;CAEzB,0BAA0B;;CAI1B,iBAAiB;;CAMjB,qBAAqB;;CAErB,0BAA0B;;CAE1B,oCAAoC;AACtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC1DA,MAAM,4BAA2E;CAC/E,sBAAsB,uBAAuB;CAC7C,YAAY,uBAAuB;CACnC,KAAK,uBAAuB;CAC5B,WAAW,uBAAuB;CAClC,KAAK,uBAAuB;CAC5B,OAAO,uBAAuB;AAChC;;;;;;;;;;;;;AAcA,MAAM,sBAAqE;CACzE,OAAO,uBAAuB;CAC9B,kBAAkB,uBAAuB;CACzC,uBAAuB,uBAAuB;CAC9C,gBAAgB,uBAAuB;CACvC,oBAAoB,uBAAuB;CAC3C,iBAAiB,uBAAuB;CACxC,kBAAkB,uBAAuB;CACzC,wBAAwB,uBAAuB;CAC/C,2BAA2B,uBAAuB;CAClD,oCAAoC,uBAAuB;CAC3D,wCAAwC,uBAAuB;CAC/D,yBAAyB,uBAAuB;CAChD,sCAAsC,uBAAuB;CAC7D,uBAAuB,uBAAuB;CAC9C,wCAAwC,uBAAuB;CAC/D,gCAAgC,uBAAuB;CACvD,cAAc,uBAAuB;CACrC,gCAAgC,uBAAuB;CACvD,4BAA4B,uBAAuB;CACnD,sBAAsB,uBAAuB;CAC7C,gBAAgB,uBAAuB;CACvC,iBAAiB,uBAAuB;CACxC,iBAAiB,uBAAuB;CACxC,uCAAuC,uBAAuB;CAC9D,kBAAkB,uBAAuB;CAGzC,oBAAoB,uBAAuB;CAC3C,qBAAqB,uBAAuB;CAC5C,2BAA2B,uBAAuB;CAClD,kBAAkB,uBAAuB;AAC3C;AAEA,MAAM,yBAAyB,WAC7B,WAAW,sBACX,0BAA0B,MAAM,MAAM,uBAAuB;AAE/D,SAAgB,0BAA0B,QAAiD;CACzF,IAAI,OAAO,WAAW,QAAQ,GAAG,OAAO,uBAAuB;CAC/D,OAAO,OAAO,UAAU,eAAe,KAAK,qBAAqB,MAAM,IACnE,oBAAoB,UACpB;AACN;;;;;;;;;;;;;;;;AAiBA,SAAgB,0BAA0B,QAAyD;CACjG,MAAM,QAA+B,CAAC;CACtC,MAAM,uBAAO,IAAI,IAAyB;CAC1C,MAAM,QAAQ,SAAgD;EAC5D,IAAI,QAAQ,CAAC,KAAK,IAAI,IAAI,GAAG;GAC3B,KAAK,IAAI,IAAI;GACb,MAAM,KAAK,IAAI;EACjB;CACF;CAGA,MAAM,qBAAqB,OAAO;CAClC,IAAI,oBAAoB;EACtB,IAAI,mBAAmB,WAAW,QAAQ,GACxC,KAAK,uBAAuB,0BAA0B;OACjD,IAQL,kBAAkB,kBAAkB,KACpC,uBAAuB,kBAAkB,GAEzC,KAAK,uBAAuB,cAAc;OAE1C,KAAK,0BAA0B,mBAAmB;CAEtD;CAEA,MAAM,+BAAe,IAAI,IAAqC;CAC9D,KAAK,MAAM,UAAU,OAAO,WAAW,CAAC,GAAG;EACzC,IAAI,OAAO,mBAAmB,WAAW,sBAAsB,OAAO,MAAM,GAAG;EAC/E,aAAa,IAAI,0BAA0B,OAAO,MAAM,CAAC;CAC3D;CACA,KAAK,MAAM,QAAQ,OAAO,OAAO,mBAAmB,GAClD,IAAI,aAAa,IAAI,IAAI,GAAG,KAAK,IAAI;CAEvC,IAAI,aAAa,IAAI,uBAAuB,wBAAwB,GAClE,KAAK,uBAAuB,wBAAwB;CAItD,IAAI,OAAO,aACT,KAAK,uBAAuB,eAAe;CAI7C,IAAI,MAAM,WAAW,GAAG;EACtB,IAAI,OAAO,mBAAmB,SAC5B,KAAK,uBAAuB,mBAAmB;OAC1C,IACL,OAAO,mBAAmB,qBAC1B,OAAO,mBAAmB,aAC1B,CAAC,OAAO,gBAER,KAAK,uBAAuB,wBAAwB;OAEpD,KAAK,uBAAuB,kCAAkC;CAElE;CAEA,OAAO;AACT;;AAGA,MAAa,2BAA2B;;AAExC,MAAa,gCAAgC;AAE7C,MAAM,uBAAuB,IAAI,YAAY;;;;;;;;;AAU7C,SAAgB,wBAAwB,OAA+C;CACrF,MAAM,SAAS,MAAM,MAAM,IAA2B;CACtD,OAAO,OAAO,SAAS,GAAG;EACxB,MAAM,SAAS,OAAO,KAAK,GAAG;EAC9B,IAAI,qBAAqB,OAAO,MAAM,CAAC,CAAC,mBACtC,OAAO;EAET,OAAO,IAAI;CACb;CACA,OAAO;AACT"}
|
package/dist/errors/index.d.mts
CHANGED
|
@@ -76,6 +76,7 @@ export declare const ERROR_CODES: {
|
|
|
76
76
|
readonly AUDIT_CREDENTIAL_REQUIRED: "AUDIT_CREDENTIAL_REQUIRED";
|
|
77
77
|
readonly AUDIT_REQUEST_TOO_LARGE: "AUDIT_REQUEST_TOO_LARGE";
|
|
78
78
|
readonly AUDIT_INVALID_JSON: "AUDIT_INVALID_JSON";
|
|
79
|
+
readonly AUDIT_REQUEST_TIMEOUT: "AUDIT_REQUEST_TIMEOUT";
|
|
79
80
|
readonly AUDIT_INVALID_CREDENTIAL: "AUDIT_INVALID_CREDENTIAL";
|
|
80
81
|
readonly AUDIT_RATE_LIMITED: "AUDIT_RATE_LIMITED";
|
|
81
82
|
readonly AUDIT_INVALID_SUBMISSION: "AUDIT_INVALID_SUBMISSION";
|
|
@@ -127,6 +128,7 @@ export declare const ERROR_CODES: {
|
|
|
127
128
|
readonly LOWERCASE_PROOF_VALIDATION_ERROR: "proof_validation_error";
|
|
128
129
|
readonly LOWERCASE_INSUFFICIENT_SCOPES: "insufficient_scopes";
|
|
129
130
|
readonly LOWERCASE_DELEGATION_VALIDATION_ERROR: "delegation_validation_error";
|
|
131
|
+
readonly LOWERCASE_AUTHORIZATION_TOO_WEAK: "authorization_too_weak";
|
|
130
132
|
readonly GRANT_PREDATES_ISSUANCE_CORE: "grant_predates_issuance_core";
|
|
131
133
|
readonly LOWERCASE_INVALID_HTTP_REGISTRATION: "invalid_http_registration";
|
|
132
134
|
readonly LOWERCASE_POLICY_REVISION_MISMATCH: "policy_revision_mismatch";
|
|
@@ -170,6 +172,7 @@ export declare const ERROR_CODES: {
|
|
|
170
172
|
readonly RESPONSE_TOO_LARGE: "API_RESPONSE_TOO_LARGE";
|
|
171
173
|
readonly REQUEST_TOO_LARGE: "API_REQUEST_TOO_LARGE";
|
|
172
174
|
readonly ENDPOINT_RETIRED: "API_ENDPOINT_RETIRED";
|
|
175
|
+
readonly VERDICT_NOT_STORED: "VERDICT_NOT_STORED";
|
|
173
176
|
readonly PIXEL_NOT_FOUND: "PIXEL_NOT_FOUND";
|
|
174
177
|
readonly PIXEL_DISABLED: "PIXEL_DISABLED";
|
|
175
178
|
readonly PIXEL_CONFIGURATION_ERROR: "PIXEL_CONFIGURATION_ERROR";
|
|
@@ -199,6 +202,7 @@ export declare const ERROR_CODES: {
|
|
|
199
202
|
readonly DELETE_FAILED: "DELETE_FAILED";
|
|
200
203
|
readonly PARTITION_RETIREMENT_IN_PROGRESS: "PARTITION_RETIREMENT_IN_PROGRESS";
|
|
201
204
|
readonly FLY_CLEANUP_FAILED: "FLY_CLEANUP_FAILED";
|
|
205
|
+
readonly REQUEST_TIMEOUT: "REQUEST_TIMEOUT";
|
|
202
206
|
readonly CONNECTION_FAILED: "NETWORK_CONNECTION_FAILED";
|
|
203
207
|
readonly TIMEOUT: "NETWORK_TIMEOUT";
|
|
204
208
|
readonly DNS_RESOLUTION_FAILED: "NETWORK_DNS_FAILED";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/constants/errors.ts","../../src/constants/pick-error-codes.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/constants/errors.ts","../../src/constants/pick-error-codes.ts"],"mappings":";qBAwYa;;;;;;;;;;;;;;;;;;;;;;qBA4FA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4BD,oBAAoB,0BAA0B;qBAK7C,gBAAgB,OAAO;qBA8VvB,oBAAoB,QAAQ,OAAO;;;KCj2BpC,4BAA4B;KAE5B,iBAAiB,mBAAmB,8BACpC,KAAK,oBAAoB,aAAa;wBAUlC,qBAAqB,mBAAmB,gBACtD,MAAM,IACL,iBAAiB"}
|
package/dist/errors/index.d.ts
CHANGED
|
@@ -76,6 +76,7 @@ export declare const ERROR_CODES: {
|
|
|
76
76
|
readonly AUDIT_CREDENTIAL_REQUIRED: "AUDIT_CREDENTIAL_REQUIRED";
|
|
77
77
|
readonly AUDIT_REQUEST_TOO_LARGE: "AUDIT_REQUEST_TOO_LARGE";
|
|
78
78
|
readonly AUDIT_INVALID_JSON: "AUDIT_INVALID_JSON";
|
|
79
|
+
readonly AUDIT_REQUEST_TIMEOUT: "AUDIT_REQUEST_TIMEOUT";
|
|
79
80
|
readonly AUDIT_INVALID_CREDENTIAL: "AUDIT_INVALID_CREDENTIAL";
|
|
80
81
|
readonly AUDIT_RATE_LIMITED: "AUDIT_RATE_LIMITED";
|
|
81
82
|
readonly AUDIT_INVALID_SUBMISSION: "AUDIT_INVALID_SUBMISSION";
|
|
@@ -127,6 +128,7 @@ export declare const ERROR_CODES: {
|
|
|
127
128
|
readonly LOWERCASE_PROOF_VALIDATION_ERROR: "proof_validation_error";
|
|
128
129
|
readonly LOWERCASE_INSUFFICIENT_SCOPES: "insufficient_scopes";
|
|
129
130
|
readonly LOWERCASE_DELEGATION_VALIDATION_ERROR: "delegation_validation_error";
|
|
131
|
+
readonly LOWERCASE_AUTHORIZATION_TOO_WEAK: "authorization_too_weak";
|
|
130
132
|
readonly GRANT_PREDATES_ISSUANCE_CORE: "grant_predates_issuance_core";
|
|
131
133
|
readonly LOWERCASE_INVALID_HTTP_REGISTRATION: "invalid_http_registration";
|
|
132
134
|
readonly LOWERCASE_POLICY_REVISION_MISMATCH: "policy_revision_mismatch";
|
|
@@ -170,6 +172,7 @@ export declare const ERROR_CODES: {
|
|
|
170
172
|
readonly RESPONSE_TOO_LARGE: "API_RESPONSE_TOO_LARGE";
|
|
171
173
|
readonly REQUEST_TOO_LARGE: "API_REQUEST_TOO_LARGE";
|
|
172
174
|
readonly ENDPOINT_RETIRED: "API_ENDPOINT_RETIRED";
|
|
175
|
+
readonly VERDICT_NOT_STORED: "VERDICT_NOT_STORED";
|
|
173
176
|
readonly PIXEL_NOT_FOUND: "PIXEL_NOT_FOUND";
|
|
174
177
|
readonly PIXEL_DISABLED: "PIXEL_DISABLED";
|
|
175
178
|
readonly PIXEL_CONFIGURATION_ERROR: "PIXEL_CONFIGURATION_ERROR";
|
|
@@ -199,6 +202,7 @@ export declare const ERROR_CODES: {
|
|
|
199
202
|
readonly DELETE_FAILED: "DELETE_FAILED";
|
|
200
203
|
readonly PARTITION_RETIREMENT_IN_PROGRESS: "PARTITION_RETIREMENT_IN_PROGRESS";
|
|
201
204
|
readonly FLY_CLEANUP_FAILED: "FLY_CLEANUP_FAILED";
|
|
205
|
+
readonly REQUEST_TIMEOUT: "REQUEST_TIMEOUT";
|
|
202
206
|
readonly CONNECTION_FAILED: "NETWORK_CONNECTION_FAILED";
|
|
203
207
|
readonly TIMEOUT: "NETWORK_TIMEOUT";
|
|
204
208
|
readonly DNS_RESOLUTION_FAILED: "NETWORK_DNS_FAILED";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/constants/errors.ts","../../src/constants/pick-error-codes.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/constants/errors.ts","../../src/constants/pick-error-codes.ts"],"mappings":";qBAwYa;;;;;;;;;;;;;;;;;;;;;;qBA4FA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4BD,oBAAoB,0BAA0B;qBAK7C,gBAAgB,OAAO;qBA8VvB,oBAAoB,QAAQ,OAAO;;;KCj2BpC,4BAA4B;KAE5B,iBAAiB,mBAAmB,8BACpC,KAAK,oBAAoB,aAAa;wBAUlC,qBAAqB,mBAAmB,gBACtD,MAAM,IACL,iBAAiB"}
|
package/dist/errors/index.js
CHANGED
|
@@ -97,7 +97,8 @@ const INTERNAL_ERRORS = {
|
|
|
97
97
|
TRANSACTION_FAILED: "TRANSACTION_FAILED",
|
|
98
98
|
DELETE_FAILED: "DELETE_FAILED",
|
|
99
99
|
PARTITION_RETIREMENT_IN_PROGRESS: "PARTITION_RETIREMENT_IN_PROGRESS",
|
|
100
|
-
FLY_CLEANUP_FAILED: "FLY_CLEANUP_FAILED"
|
|
100
|
+
FLY_CLEANUP_FAILED: "FLY_CLEANUP_FAILED",
|
|
101
|
+
REQUEST_TIMEOUT: "REQUEST_TIMEOUT"
|
|
101
102
|
};
|
|
102
103
|
/**
|
|
103
104
|
* Session Error Codes
|
|
@@ -136,7 +137,8 @@ const API_ERRORS = {
|
|
|
136
137
|
CONTENT_TYPE_NOT_SUPPORTED: "API_CONTENT_TYPE_NOT_SUPPORTED",
|
|
137
138
|
RESPONSE_TOO_LARGE: "API_RESPONSE_TOO_LARGE",
|
|
138
139
|
REQUEST_TOO_LARGE: "API_REQUEST_TOO_LARGE",
|
|
139
|
-
ENDPOINT_RETIRED: "API_ENDPOINT_RETIRED"
|
|
140
|
+
ENDPOINT_RETIRED: "API_ENDPOINT_RETIRED",
|
|
141
|
+
VERDICT_NOT_STORED: "VERDICT_NOT_STORED"
|
|
140
142
|
};
|
|
141
143
|
/**
|
|
142
144
|
* Billing Error Codes
|
|
@@ -256,6 +258,7 @@ const BOUNCER_LOWERCASE_ERRORS = {
|
|
|
256
258
|
LOWERCASE_PROOF_VALIDATION_ERROR: "proof_validation_error",
|
|
257
259
|
LOWERCASE_INSUFFICIENT_SCOPES: "insufficient_scopes",
|
|
258
260
|
LOWERCASE_DELEGATION_VALIDATION_ERROR: "delegation_validation_error",
|
|
261
|
+
LOWERCASE_AUTHORIZATION_TOO_WEAK: "authorization_too_weak",
|
|
259
262
|
GRANT_PREDATES_ISSUANCE_CORE: "grant_predates_issuance_core",
|
|
260
263
|
LOWERCASE_INVALID_HTTP_REGISTRATION: "invalid_http_registration",
|
|
261
264
|
LOWERCASE_POLICY_REVISION_MISMATCH: "policy_revision_mismatch",
|
|
@@ -265,11 +268,15 @@ const BOUNCER_LOWERCASE_ERRORS = {
|
|
|
265
268
|
/**
|
|
266
269
|
* Delegation OAuth Error Codes (lower-case wire format)
|
|
267
270
|
*
|
|
268
|
-
* Emitted by the bouncer authorize,
|
|
269
|
-
*
|
|
270
|
-
* 6749 vocabulary (`invalid_request`,
|
|
271
|
-
* `
|
|
272
|
-
*
|
|
271
|
+
* Emitted by the bouncer v1 routes (authorize, the OAuth and credential
|
|
272
|
+
* starts, the OAuth callback, sessions and delegations) and the shared OAuth
|
|
273
|
+
* rate limiter. Several reuse RFC 6749 vocabulary (`invalid_request`,
|
|
274
|
+
* `invalid_grant`) but travel in the bouncer `{success, error}` envelope,
|
|
275
|
+
* not an RFC 6749 body. Keyed by value with a LOWERCASE_ prefix.
|
|
276
|
+
*
|
|
277
|
+
* `unsupported_grant_type` and `invalid_delegation` belonged to the bouncer
|
|
278
|
+
* `oauth/token` code exchange, which is gone; nothing emits them, and they
|
|
279
|
+
* stay published until a deprecation removes them.
|
|
273
280
|
*/
|
|
274
281
|
const OAUTH_LOWERCASE_ERRORS = {
|
|
275
282
|
LOWERCASE_INVALID_REQUEST: "invalid_request",
|
|
@@ -314,6 +321,7 @@ const AUDIT_ERRORS = {
|
|
|
314
321
|
AUDIT_CREDENTIAL_REQUIRED: "AUDIT_CREDENTIAL_REQUIRED",
|
|
315
322
|
AUDIT_REQUEST_TOO_LARGE: "AUDIT_REQUEST_TOO_LARGE",
|
|
316
323
|
AUDIT_INVALID_JSON: "AUDIT_INVALID_JSON",
|
|
324
|
+
AUDIT_REQUEST_TIMEOUT: "AUDIT_REQUEST_TIMEOUT",
|
|
317
325
|
AUDIT_INVALID_CREDENTIAL: "AUDIT_INVALID_CREDENTIAL",
|
|
318
326
|
AUDIT_RATE_LIMITED: "AUDIT_RATE_LIMITED",
|
|
319
327
|
AUDIT_INVALID_SUBMISSION: "AUDIT_INVALID_SUBMISSION",
|
|
@@ -512,6 +520,7 @@ const ERROR_MESSAGES = {
|
|
|
512
520
|
[INTERNAL_ERRORS.DELETE_FAILED]: "Failed to delete project",
|
|
513
521
|
[INTERNAL_ERRORS.PARTITION_RETIREMENT_IN_PROGRESS]: "The project data is being archived. Retry shortly.",
|
|
514
522
|
[INTERNAL_ERRORS.FLY_CLEANUP_FAILED]: "Couldn't stop a managed agent's machine, so the delete was refused. Retry the delete.",
|
|
523
|
+
[INTERNAL_ERRORS.REQUEST_TIMEOUT]: "The request body did not arrive in time",
|
|
515
524
|
[SESSION_ERRORS.SESSION_NOT_FOUND]: "Session not found",
|
|
516
525
|
[SESSION_ERRORS.SESSION_EXPIRED]: "Session has expired",
|
|
517
526
|
[SESSION_ERRORS.SESSION_INVALID]: "Session is invalid",
|
|
@@ -536,6 +545,7 @@ const ERROR_MESSAGES = {
|
|
|
536
545
|
[API_ERRORS.RESPONSE_TOO_LARGE]: "Response exceeds maximum size",
|
|
537
546
|
[API_ERRORS.REQUEST_TOO_LARGE]: "Request exceeds maximum size",
|
|
538
547
|
[API_ERRORS.ENDPOINT_RETIRED]: "This endpoint has been retired",
|
|
548
|
+
[API_ERRORS.VERDICT_NOT_STORED]: "The verdict could not be stored",
|
|
539
549
|
[BILLING_ERRORS.LIMIT_EXCEEDED]: "Billing limit exceeded",
|
|
540
550
|
[BILLING_ERRORS.BILLING_SUSPENDED]: "Account billing suspended",
|
|
541
551
|
[BILLING_ERRORS.BILLING_GRACE_PERIOD]: "Account in billing grace period",
|
|
@@ -592,6 +602,7 @@ const ERROR_MESSAGES = {
|
|
|
592
602
|
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_PROOF_VALIDATION_ERROR]: "Proof validation failed",
|
|
593
603
|
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_INSUFFICIENT_SCOPES]: "Missing required scopes",
|
|
594
604
|
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_DELEGATION_VALIDATION_ERROR]: "Delegation validation failed",
|
|
605
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_AUTHORIZATION_TOO_WEAK]: "A tool these scopes open needs a sign-in, so a consent-only grant cannot open it",
|
|
595
606
|
[BOUNCER_LOWERCASE_ERRORS.GRANT_PREDATES_ISSUANCE_CORE]: "The grant predates the issuance core; authorize again",
|
|
596
607
|
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_INVALID_HTTP_REGISTRATION]: "Invalid or unsupported native HTTP registration",
|
|
597
608
|
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_POLICY_REVISION_MISMATCH]: "The registered tool protection revision is not the one served to this project",
|
|
@@ -622,6 +633,7 @@ const ERROR_MESSAGES = {
|
|
|
622
633
|
[AUDIT_ERRORS.AUDIT_CREDENTIAL_REQUIRED]: "A source-bound audit ingest credential is required",
|
|
623
634
|
[AUDIT_ERRORS.AUDIT_REQUEST_TOO_LARGE]: "Audit submission exceeds 6291456 bytes",
|
|
624
635
|
[AUDIT_ERRORS.AUDIT_INVALID_JSON]: "Request body must be valid JSON",
|
|
636
|
+
[AUDIT_ERRORS.AUDIT_REQUEST_TIMEOUT]: "Audit submission body did not arrive in time",
|
|
625
637
|
[AUDIT_ERRORS.AUDIT_INVALID_CREDENTIAL]: "Invalid audit ingest credential",
|
|
626
638
|
[AUDIT_ERRORS.AUDIT_RATE_LIMITED]: "Audit ingest rate limit exceeded",
|
|
627
639
|
[AUDIT_ERRORS.AUDIT_INVALID_SUBMISSION]: "Invalid audit recorder submission envelope",
|
|
@@ -755,6 +767,7 @@ const ERROR_STATUS_CODES = {
|
|
|
755
767
|
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_FORBIDDEN]: 403,
|
|
756
768
|
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_AGENT_DENIED]: 403,
|
|
757
769
|
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_INSUFFICIENT_SCOPES]: 403,
|
|
770
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_AUTHORIZATION_TOO_WEAK]: 403,
|
|
758
771
|
[BOUNCER_LOWERCASE_ERRORS.GRANT_PREDATES_ISSUANCE_CORE]: 409,
|
|
759
772
|
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_POLICY_REVISION_MISMATCH]: 409,
|
|
760
773
|
[AUDIT_PROTOCOL_ERRORS.AUDIT_UNAUTHORIZED_SUBMISSION]: 403,
|
|
@@ -798,6 +811,8 @@ const ERROR_STATUS_CODES = {
|
|
|
798
811
|
[GATEWAY_VAULT_ERRORS.CREDENTIALS_NOT_CONFIGURED]: 404,
|
|
799
812
|
[VAULT_ERRORS.NO_AGENT_KEY]: 404,
|
|
800
813
|
[API_ERRORS.METHOD_NOT_ALLOWED]: 405,
|
|
814
|
+
[AUDIT_ERRORS.AUDIT_REQUEST_TIMEOUT]: 408,
|
|
815
|
+
[INTERNAL_ERRORS.REQUEST_TIMEOUT]: 408,
|
|
801
816
|
[RESOURCE_ERRORS.CONFLICT]: 409,
|
|
802
817
|
[AUDIT_PROTOCOL_ERRORS.AUDIT_LEDGER_MISMATCH]: 409,
|
|
803
818
|
[AUDIT_PROTOCOL_ERRORS.AUDIT_EPOCH_MISMATCH]: 409,
|
|
@@ -862,7 +877,8 @@ const ERROR_STATUS_CODES = {
|
|
|
862
877
|
[AUDIT_PROTOCOL_ERRORS.AUDIT_APPEND_CONFLICT_EXHAUSTED]: 503,
|
|
863
878
|
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_AUTHORIZATION_HOST_UNAVAILABLE]: 503,
|
|
864
879
|
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_POLICY_UNAVAILABLE]: 503,
|
|
865
|
-
[NETWORK_ERRORS.TIMEOUT]: 504
|
|
880
|
+
[NETWORK_ERRORS.TIMEOUT]: 504,
|
|
881
|
+
[API_ERRORS.VERDICT_NOT_STORED]: 504
|
|
866
882
|
};
|
|
867
883
|
|
|
868
884
|
//#endregion
|
package/dist/errors/index.mjs
CHANGED
|
@@ -96,7 +96,8 @@ const INTERNAL_ERRORS = {
|
|
|
96
96
|
TRANSACTION_FAILED: "TRANSACTION_FAILED",
|
|
97
97
|
DELETE_FAILED: "DELETE_FAILED",
|
|
98
98
|
PARTITION_RETIREMENT_IN_PROGRESS: "PARTITION_RETIREMENT_IN_PROGRESS",
|
|
99
|
-
FLY_CLEANUP_FAILED: "FLY_CLEANUP_FAILED"
|
|
99
|
+
FLY_CLEANUP_FAILED: "FLY_CLEANUP_FAILED",
|
|
100
|
+
REQUEST_TIMEOUT: "REQUEST_TIMEOUT"
|
|
100
101
|
};
|
|
101
102
|
/**
|
|
102
103
|
* Session Error Codes
|
|
@@ -135,7 +136,8 @@ const API_ERRORS = {
|
|
|
135
136
|
CONTENT_TYPE_NOT_SUPPORTED: "API_CONTENT_TYPE_NOT_SUPPORTED",
|
|
136
137
|
RESPONSE_TOO_LARGE: "API_RESPONSE_TOO_LARGE",
|
|
137
138
|
REQUEST_TOO_LARGE: "API_REQUEST_TOO_LARGE",
|
|
138
|
-
ENDPOINT_RETIRED: "API_ENDPOINT_RETIRED"
|
|
139
|
+
ENDPOINT_RETIRED: "API_ENDPOINT_RETIRED",
|
|
140
|
+
VERDICT_NOT_STORED: "VERDICT_NOT_STORED"
|
|
139
141
|
};
|
|
140
142
|
/**
|
|
141
143
|
* Billing Error Codes
|
|
@@ -255,6 +257,7 @@ const BOUNCER_LOWERCASE_ERRORS = {
|
|
|
255
257
|
LOWERCASE_PROOF_VALIDATION_ERROR: "proof_validation_error",
|
|
256
258
|
LOWERCASE_INSUFFICIENT_SCOPES: "insufficient_scopes",
|
|
257
259
|
LOWERCASE_DELEGATION_VALIDATION_ERROR: "delegation_validation_error",
|
|
260
|
+
LOWERCASE_AUTHORIZATION_TOO_WEAK: "authorization_too_weak",
|
|
258
261
|
GRANT_PREDATES_ISSUANCE_CORE: "grant_predates_issuance_core",
|
|
259
262
|
LOWERCASE_INVALID_HTTP_REGISTRATION: "invalid_http_registration",
|
|
260
263
|
LOWERCASE_POLICY_REVISION_MISMATCH: "policy_revision_mismatch",
|
|
@@ -264,11 +267,15 @@ const BOUNCER_LOWERCASE_ERRORS = {
|
|
|
264
267
|
/**
|
|
265
268
|
* Delegation OAuth Error Codes (lower-case wire format)
|
|
266
269
|
*
|
|
267
|
-
* Emitted by the bouncer authorize,
|
|
268
|
-
*
|
|
269
|
-
* 6749 vocabulary (`invalid_request`,
|
|
270
|
-
* `
|
|
271
|
-
*
|
|
270
|
+
* Emitted by the bouncer v1 routes (authorize, the OAuth and credential
|
|
271
|
+
* starts, the OAuth callback, sessions and delegations) and the shared OAuth
|
|
272
|
+
* rate limiter. Several reuse RFC 6749 vocabulary (`invalid_request`,
|
|
273
|
+
* `invalid_grant`) but travel in the bouncer `{success, error}` envelope,
|
|
274
|
+
* not an RFC 6749 body. Keyed by value with a LOWERCASE_ prefix.
|
|
275
|
+
*
|
|
276
|
+
* `unsupported_grant_type` and `invalid_delegation` belonged to the bouncer
|
|
277
|
+
* `oauth/token` code exchange, which is gone; nothing emits them, and they
|
|
278
|
+
* stay published until a deprecation removes them.
|
|
272
279
|
*/
|
|
273
280
|
const OAUTH_LOWERCASE_ERRORS = {
|
|
274
281
|
LOWERCASE_INVALID_REQUEST: "invalid_request",
|
|
@@ -313,6 +320,7 @@ const AUDIT_ERRORS = {
|
|
|
313
320
|
AUDIT_CREDENTIAL_REQUIRED: "AUDIT_CREDENTIAL_REQUIRED",
|
|
314
321
|
AUDIT_REQUEST_TOO_LARGE: "AUDIT_REQUEST_TOO_LARGE",
|
|
315
322
|
AUDIT_INVALID_JSON: "AUDIT_INVALID_JSON",
|
|
323
|
+
AUDIT_REQUEST_TIMEOUT: "AUDIT_REQUEST_TIMEOUT",
|
|
316
324
|
AUDIT_INVALID_CREDENTIAL: "AUDIT_INVALID_CREDENTIAL",
|
|
317
325
|
AUDIT_RATE_LIMITED: "AUDIT_RATE_LIMITED",
|
|
318
326
|
AUDIT_INVALID_SUBMISSION: "AUDIT_INVALID_SUBMISSION",
|
|
@@ -511,6 +519,7 @@ const ERROR_MESSAGES = {
|
|
|
511
519
|
[INTERNAL_ERRORS.DELETE_FAILED]: "Failed to delete project",
|
|
512
520
|
[INTERNAL_ERRORS.PARTITION_RETIREMENT_IN_PROGRESS]: "The project data is being archived. Retry shortly.",
|
|
513
521
|
[INTERNAL_ERRORS.FLY_CLEANUP_FAILED]: "Couldn't stop a managed agent's machine, so the delete was refused. Retry the delete.",
|
|
522
|
+
[INTERNAL_ERRORS.REQUEST_TIMEOUT]: "The request body did not arrive in time",
|
|
514
523
|
[SESSION_ERRORS.SESSION_NOT_FOUND]: "Session not found",
|
|
515
524
|
[SESSION_ERRORS.SESSION_EXPIRED]: "Session has expired",
|
|
516
525
|
[SESSION_ERRORS.SESSION_INVALID]: "Session is invalid",
|
|
@@ -535,6 +544,7 @@ const ERROR_MESSAGES = {
|
|
|
535
544
|
[API_ERRORS.RESPONSE_TOO_LARGE]: "Response exceeds maximum size",
|
|
536
545
|
[API_ERRORS.REQUEST_TOO_LARGE]: "Request exceeds maximum size",
|
|
537
546
|
[API_ERRORS.ENDPOINT_RETIRED]: "This endpoint has been retired",
|
|
547
|
+
[API_ERRORS.VERDICT_NOT_STORED]: "The verdict could not be stored",
|
|
538
548
|
[BILLING_ERRORS.LIMIT_EXCEEDED]: "Billing limit exceeded",
|
|
539
549
|
[BILLING_ERRORS.BILLING_SUSPENDED]: "Account billing suspended",
|
|
540
550
|
[BILLING_ERRORS.BILLING_GRACE_PERIOD]: "Account in billing grace period",
|
|
@@ -591,6 +601,7 @@ const ERROR_MESSAGES = {
|
|
|
591
601
|
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_PROOF_VALIDATION_ERROR]: "Proof validation failed",
|
|
592
602
|
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_INSUFFICIENT_SCOPES]: "Missing required scopes",
|
|
593
603
|
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_DELEGATION_VALIDATION_ERROR]: "Delegation validation failed",
|
|
604
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_AUTHORIZATION_TOO_WEAK]: "A tool these scopes open needs a sign-in, so a consent-only grant cannot open it",
|
|
594
605
|
[BOUNCER_LOWERCASE_ERRORS.GRANT_PREDATES_ISSUANCE_CORE]: "The grant predates the issuance core; authorize again",
|
|
595
606
|
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_INVALID_HTTP_REGISTRATION]: "Invalid or unsupported native HTTP registration",
|
|
596
607
|
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_POLICY_REVISION_MISMATCH]: "The registered tool protection revision is not the one served to this project",
|
|
@@ -621,6 +632,7 @@ const ERROR_MESSAGES = {
|
|
|
621
632
|
[AUDIT_ERRORS.AUDIT_CREDENTIAL_REQUIRED]: "A source-bound audit ingest credential is required",
|
|
622
633
|
[AUDIT_ERRORS.AUDIT_REQUEST_TOO_LARGE]: "Audit submission exceeds 6291456 bytes",
|
|
623
634
|
[AUDIT_ERRORS.AUDIT_INVALID_JSON]: "Request body must be valid JSON",
|
|
635
|
+
[AUDIT_ERRORS.AUDIT_REQUEST_TIMEOUT]: "Audit submission body did not arrive in time",
|
|
624
636
|
[AUDIT_ERRORS.AUDIT_INVALID_CREDENTIAL]: "Invalid audit ingest credential",
|
|
625
637
|
[AUDIT_ERRORS.AUDIT_RATE_LIMITED]: "Audit ingest rate limit exceeded",
|
|
626
638
|
[AUDIT_ERRORS.AUDIT_INVALID_SUBMISSION]: "Invalid audit recorder submission envelope",
|
|
@@ -754,6 +766,7 @@ const ERROR_STATUS_CODES = {
|
|
|
754
766
|
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_FORBIDDEN]: 403,
|
|
755
767
|
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_AGENT_DENIED]: 403,
|
|
756
768
|
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_INSUFFICIENT_SCOPES]: 403,
|
|
769
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_AUTHORIZATION_TOO_WEAK]: 403,
|
|
757
770
|
[BOUNCER_LOWERCASE_ERRORS.GRANT_PREDATES_ISSUANCE_CORE]: 409,
|
|
758
771
|
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_POLICY_REVISION_MISMATCH]: 409,
|
|
759
772
|
[AUDIT_PROTOCOL_ERRORS.AUDIT_UNAUTHORIZED_SUBMISSION]: 403,
|
|
@@ -797,6 +810,8 @@ const ERROR_STATUS_CODES = {
|
|
|
797
810
|
[GATEWAY_VAULT_ERRORS.CREDENTIALS_NOT_CONFIGURED]: 404,
|
|
798
811
|
[VAULT_ERRORS.NO_AGENT_KEY]: 404,
|
|
799
812
|
[API_ERRORS.METHOD_NOT_ALLOWED]: 405,
|
|
813
|
+
[AUDIT_ERRORS.AUDIT_REQUEST_TIMEOUT]: 408,
|
|
814
|
+
[INTERNAL_ERRORS.REQUEST_TIMEOUT]: 408,
|
|
800
815
|
[RESOURCE_ERRORS.CONFLICT]: 409,
|
|
801
816
|
[AUDIT_PROTOCOL_ERRORS.AUDIT_LEDGER_MISMATCH]: 409,
|
|
802
817
|
[AUDIT_PROTOCOL_ERRORS.AUDIT_EPOCH_MISMATCH]: 409,
|
|
@@ -861,7 +876,8 @@ const ERROR_STATUS_CODES = {
|
|
|
861
876
|
[AUDIT_PROTOCOL_ERRORS.AUDIT_APPEND_CONFLICT_EXHAUSTED]: 503,
|
|
862
877
|
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_AUTHORIZATION_HOST_UNAVAILABLE]: 503,
|
|
863
878
|
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_POLICY_UNAVAILABLE]: 503,
|
|
864
|
-
[NETWORK_ERRORS.TIMEOUT]: 504
|
|
879
|
+
[NETWORK_ERRORS.TIMEOUT]: 504,
|
|
880
|
+
[API_ERRORS.VERDICT_NOT_STORED]: 504
|
|
865
881
|
};
|
|
866
882
|
|
|
867
883
|
//#endregion
|