@kya-os/checkpoint-shared 1.5.0 → 1.5.2
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 +129 -0
- package/dist/beacon-nonce/index.d.mts +36 -0
- package/dist/beacon-nonce/index.d.mts.map +1 -0
- package/dist/beacon-nonce/index.d.ts +36 -0
- package/dist/beacon-nonce/index.d.ts.map +1 -0
- package/dist/beacon-nonce/index.js +305 -0
- package/dist/beacon-nonce/index.mjs +294 -0
- package/dist/beacon-nonce/index.mjs.map +1 -0
- package/dist/beacon-types/index.d.mts +50 -14
- package/dist/beacon-types/index.d.mts.map +1 -1
- package/dist/beacon-types/index.d.ts +50 -14
- package/dist/beacon-types/index.d.ts.map +1 -1
- package/dist/beacon-types/index.js +127 -8
- package/dist/beacon-types/index.mjs +122 -9
- package/dist/beacon-types/index.mjs.map +1 -1
- package/dist/browser-posture-D4j2a5gi.d.ts +169 -0
- package/dist/browser-posture-D4j2a5gi.d.ts.map +1 -0
- package/dist/browser-posture-DVoHMHjY.d.mts +169 -0
- package/dist/browser-posture-DVoHMHjY.d.mts.map +1 -0
- package/dist/browser-posture-cookie.d.mts +4 -2
- package/dist/browser-posture-cookie.d.mts.map +1 -0
- package/dist/browser-posture-cookie.d.ts +4 -2
- package/dist/browser-posture-cookie.d.ts.map +1 -0
- package/dist/browser-posture-cookie.mjs.map +1 -1
- package/dist/browser-posture-proof.d.mts +18 -0
- package/dist/browser-posture-proof.d.mts.map +1 -0
- package/dist/browser-posture-proof.d.ts +18 -0
- package/dist/browser-posture-proof.d.ts.map +1 -0
- package/dist/browser-posture-proof.js +66 -0
- package/dist/browser-posture-proof.mjs +63 -0
- package/dist/browser-posture-proof.mjs.map +1 -0
- package/dist/browser-posture-report.d.mts +59 -2
- package/dist/browser-posture-report.d.mts.map +1 -1
- package/dist/browser-posture-report.d.ts +59 -2
- package/dist/browser-posture-report.d.ts.map +1 -1
- package/dist/browser-posture-report.js +1 -1
- package/dist/browser-posture-report.mjs +1 -1
- package/dist/browser-posture-report.mjs.map +1 -1
- package/dist/browser-posture.d.mts +2 -83
- package/dist/browser-posture.d.ts +2 -83
- package/dist/browser-posture.js +214 -44
- package/dist/browser-posture.mjs +203 -45
- package/dist/browser-posture.mjs.map +1 -1
- package/dist/browser.d.mts +3 -11
- package/dist/browser.d.mts.map +1 -1
- package/dist/browser.d.ts +3 -11
- 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/clearance.d.mts +1 -1
- package/dist/clearance.d.ts +1 -1
- package/dist/{client-ip-HOfe6ucV.mjs → client-ip-B2Xeo-GK.mjs} +2 -2
- package/dist/{client-ip-HOfe6ucV.mjs.map → client-ip-B2Xeo-GK.mjs.map} +1 -1
- package/dist/{client-ip-1y2iXAYW.js → client-ip-CW6pRyLf.js} +1 -1
- package/dist/consent-handoff.d.mts +41 -0
- package/dist/consent-handoff.d.mts.map +1 -0
- package/dist/consent-handoff.d.ts +41 -0
- package/dist/consent-handoff.d.ts.map +1 -0
- package/dist/consent-handoff.js +1 -0
- package/dist/consent-handoff.mjs +2 -0
- package/dist/consent-handoff.mjs.map +1 -0
- package/dist/errors/index.d.mts +138 -0
- package/dist/errors/index.d.mts.map +1 -1
- package/dist/errors/index.d.ts +138 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +441 -9
- package/dist/errors/index.mjs +441 -10
- package/dist/errors/index.mjs.map +1 -1
- package/dist/{external-jr_S4iSS.d.mts → external-Ct8j_hto.d.mts} +2 -2
- package/dist/{external-jr_S4iSS.d.mts.map → external-Ct8j_hto.d.mts.map} +1 -1
- package/dist/{external-jr_S4iSS.d.ts → external-Ct8j_hto.d.ts} +2 -2
- package/dist/{external-jr_S4iSS.d.ts.map → external-Ct8j_hto.d.ts.map} +1 -1
- package/dist/gateway-client-ip.d.mts +1 -1
- package/dist/gateway-client-ip.d.ts +1 -1
- package/dist/gateway-client-ip.js +1 -1
- package/dist/gateway-client-ip.mjs +1 -1
- package/dist/index.d.mts +5227 -1063
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +5227 -1063
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3678 -546
- package/dist/index.mjs +3446 -534
- package/dist/index.mjs.map +1 -1
- package/dist/mcpi/approval-grant/index.d.mts +1 -1
- package/dist/mcpi/approval-grant/index.d.mts.map +1 -1
- package/dist/mcpi/approval-grant/index.d.ts +1 -1
- package/dist/mcpi/approval-grant/index.d.ts.map +1 -1
- package/dist/mcpi/approval-grant/index.js +48 -48
- package/dist/mcpi/approval-grant/index.mjs +48 -48
- package/dist/mcpi/approval-grant/index.mjs.map +1 -1
- package/dist/posture-origins/index.d.mts +41 -0
- package/dist/posture-origins/index.d.mts.map +1 -0
- package/dist/posture-origins/index.d.ts +41 -0
- package/dist/posture-origins/index.d.ts.map +1 -0
- package/dist/posture-origins/index.js +441 -0
- package/dist/posture-origins/index.mjs +430 -0
- package/dist/posture-origins/index.mjs.map +1 -0
- package/dist/posture-origins-CEm83u4D.js +621 -0
- package/dist/posture-origins-Dl7i8j93.mjs +533 -0
- package/dist/posture-origins-Dl7i8j93.mjs.map +1 -0
- package/dist/rules.json +0 -1
- package/dist/signals/index.d.mts +75 -55
- package/dist/signals/index.d.mts.map +1 -1
- package/dist/signals/index.d.ts +75 -55
- package/dist/signals/index.d.ts.map +1 -1
- package/dist/signals/index.js +246 -2
- package/dist/signals/index.mjs +236 -3
- package/dist/signals/index.mjs.map +1 -1
- package/fixtures/browser-integrity/captured-java-0.2.1-missing-score.json +10 -0
- package/fixtures/browser-integrity/null-score.json +11 -0
- package/fixtures/browser-integrity/numeric-score.json +11 -0
- package/fixtures/browser-posture-claims.json +168 -0
- package/fixtures/browser-posture-headers.json +6 -0
- package/fixtures/kya-http/README.md +1 -0
- package/fixtures/kya-http/consent-handoff.codes.json +34 -0
- package/fixtures/workbench/a2a-signed-request.v1.json +255 -0
- package/fixtures/workbench/artifact-bindings.v1.json +1003 -0
- package/fixtures/workbench/delegation-management.v1.json +507 -0
- package/fixtures/workbench/didcomm-task-source.v1.json +191 -0
- package/fixtures/workbench/graph-interfaces.v1.json +1887 -0
- package/fixtures/workbench/identity-provisioning.v1.json +643 -0
- package/fixtures/workbench/linear-installation.v1.json +484 -0
- package/fixtures/workbench/management-session.v1.json +716 -0
- package/fixtures/workbench/model-credentials.v1.json +630 -0
- package/fixtures/workbench/source-claim-pooled.v1.json +50 -0
- package/fixtures/workbench/task-grant.v1.json +695 -0
- package/fixtures/workbench/task-status-projection.v1.json +591 -0
- package/fixtures/workbench/workload-enrollment.v1.json +580 -0
- package/package.json +21 -2
- package/src/data/compiled/merged-rules.json +2 -9
- package/src/data/default-rules.json +0 -1
- package/dist/browser-posture-cookie-Dmq9Brf_.d.mts +0 -5
- package/dist/browser-posture-cookie-Dmq9Brf_.d.mts.map +0 -1
- package/dist/browser-posture-cookie-Dmq9Brf_.d.ts +0 -5
- package/dist/browser-posture-cookie-Dmq9Brf_.d.ts.map +0 -1
- package/dist/browser-posture.d.mts.map +0 -1
- package/dist/browser-posture.d.ts.map +0 -1
- package/dist/patterns-CkRVOdtV.js +0 -243
- package/dist/patterns-DzkGy_qk.mjs +0 -173
- package/dist/patterns-DzkGy_qk.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { t as __commonJSMin } from "./rolldown-runtime-iY2fYEqi.mjs";
|
|
2
|
-
import { C as unknown, D as _coercedNumber, E as _coercedDate, O as NEVER, S as union, T as _coercedBoolean, _ as number$1, a as _instanceof, b as record, c as boolean$1, d as discriminatedUnion, h as literal, i as _enum, l as custom, m as ipv6, n as ZodDate, o as any, p as ipv4, r as ZodNumber, s as array, t as ZodBoolean, u as date$1, v as object, w as ZodError, x as string, y as partialRecord } from "./schemas-DxY-dk9y.mjs";
|
|
3
|
-
import { a as
|
|
4
|
-
import { i as resolveClientIp, n as normalizeClientIp, r as parseIpv6, t as compressIpv6 } from "./client-ip-
|
|
5
|
-
import { AUTH_MODES, CredentialProviderConfigSchema, OAuthProviderConfigSchema, PROVIDER_AUTH_TYPES, ProviderConfigSchema, ProviderDefinitionSchema as ProviderRegistryDefinitionSchema, validateProviderConfig, validateProviderDefinition } from "@kya-os/provider-registry";
|
|
6
|
-
import * as yaml from "js-yaml";
|
|
2
|
+
import { C as unknown, D as _coercedNumber, E as _coercedDate, O as NEVER, S as union, T as _coercedBoolean, _ as number$1, a as _instanceof, b as record, c as boolean$1, d as discriminatedUnion, g as never, h as literal, i as _enum, l as custom, m as ipv6, n as ZodDate, o as any, p as ipv4, r as ZodNumber, s as array, t as ZodBoolean, u as date$1, v as object, w as ZodError, x as string, y as partialRecord } from "./schemas-DxY-dk9y.mjs";
|
|
3
|
+
import { a as HEADER_PATTERNS, c as SUSPICIOUS_PATTERNS, d as VALIDATION_PATTERNS, f as extractMatch, h as testPatterns, i as BROWSER_PATTERNS, l as USER_AGENT_PATTERNS, m as testPattern, o as MOBILE_PATTERNS, p as findMatchingPattern, r as validatePostureOrigins, s as OS_PATTERNS, u as UUID_PATTERN } from "./posture-origins-Dl7i8j93.mjs";
|
|
4
|
+
import { i as resolveClientIp, n as normalizeClientIp, r as parseIpv6, t as compressIpv6 } from "./client-ip-B2Xeo-GK.mjs";
|
|
7
5
|
import { sha256 } from "@noble/hashes/sha2.js";
|
|
8
6
|
import { bytesToHex } from "@noble/hashes/utils.js";
|
|
7
|
+
import { AUTH_MODES, CredentialProviderConfigSchema, OAuthProviderConfigSchema, PROVIDER_AUTH_TYPES, ProviderConfigSchema, ProviderDefinitionSchema as ProviderRegistryDefinitionSchema, validateProviderConfig, validateProviderDefinition } from "@kya-os/provider-registry";
|
|
8
|
+
import * as yaml from "js-yaml";
|
|
9
9
|
|
|
10
10
|
//#region ../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/classic/compat.js
|
|
11
11
|
/** @deprecated Use the raw string literal codes instead, e.g. "invalid_type". */
|
|
@@ -38,6 +38,96 @@ function date(params) {
|
|
|
38
38
|
return _coercedDate(ZodDate, params);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/core/risk-score.ts
|
|
43
|
+
/**
|
|
44
|
+
* `riskScore` (P58/PR-A): the Noisy-Or probability that a request is
|
|
45
|
+
* automated, on the wire, in the DB, and across every SDK.
|
|
46
|
+
*
|
|
47
|
+
* Defined once here so every consumer (pixel/enforce/detect responses, the
|
|
48
|
+
* `detections.risk_score` column, the TS/.NET/Java SDK result projections,
|
|
49
|
+
* the delta report) rescales the SAME source value the SAME way. Distinct
|
|
50
|
+
* from `confidence`: `riskScore` is purely additive and NEVER derived from
|
|
51
|
+
* or fed back into it.
|
|
52
|
+
*
|
|
53
|
+
* `shadow_noisy_or_confidence` is the engine's raw, UNCALIBRATED Noisy-Or
|
|
54
|
+
* combiner score, on a 0-100 scale, stamped onto `detectionDetail.metadata`
|
|
55
|
+
* only under `NoisyOrShadowMode.Shadow`/`Live`
|
|
56
|
+
* (`rust/crates/kya-os-engine/src/api.rs::stamp_scoring_metadata`). Distinct
|
|
57
|
+
* from `shadow_calibrated_confidence`, which the engine also stamps once a
|
|
58
|
+
* curve is configured — `riskScoreFromMetadata` never reads that key
|
|
59
|
+
* (bestbrian, PR #4999: earlier revisions of this comment called
|
|
60
|
+
* `riskScore` "calibrated", which was wrong — see `riskScoreSourceFromMetadata`
|
|
61
|
+
* below, which makes that choice an observable wire field instead of a
|
|
62
|
+
* comment). Once a curve is published in production, `PR B` is where the
|
|
63
|
+
* platform reconsiders which metadata key `riskScore` reads from for the
|
|
64
|
+
* live-cutover semantics — this module does not change without a matching
|
|
65
|
+
* decision recorded there.
|
|
66
|
+
*/
|
|
67
|
+
/** Wire shape: 0-1, two decimals, `null` when the combiner did not run. */
|
|
68
|
+
const RiskScoreSchema = number$1().min(0).max(1).nullable().describe("The Noisy-Or probability that the request is automated (0-1, two decimals), uncalibrated (see riskScoreSource). Null when the combiner did not run (NoisyOrShadowMode.Off, an engine fault, or skipDetection).");
|
|
69
|
+
/**
|
|
70
|
+
* Which metadata key `riskScore` was derived from. Always `'uncalibrated'`
|
|
71
|
+
* today: `riskScoreFromMetadata` reads only `shadow_noisy_or_confidence`,
|
|
72
|
+
* the combiner's raw score, never `shadow_calibrated_confidence` — even
|
|
73
|
+
* when a calibration curve is configured and the engine has stamped a
|
|
74
|
+
* calibrated preview alongside it. `riskScore` moving to read the
|
|
75
|
+
* calibrated key is a decision this module's own doc comment says a later
|
|
76
|
+
* PR makes explicitly (bestbrian, PR #4999); this field exists so that
|
|
77
|
+
* switch is an observable wire change the day it happens, not a silent one.
|
|
78
|
+
*/
|
|
79
|
+
const RiskScoreSourceSchema = _enum(["uncalibrated", "calibrated"]).nullable().describe("Which metadata key riskScore was derived from: 'uncalibrated' (shadow_noisy_or_confidence, the combiner's raw score — always true today) or 'calibrated' (shadow_calibrated_confidence, not yet wired). Null exactly when riskScore is null.");
|
|
80
|
+
/** The `detectionDetail.metadata` key `riskScore` derives from. */
|
|
81
|
+
const SHADOW_NOISY_OR_CONFIDENCE_KEY = "shadow_noisy_or_confidence";
|
|
82
|
+
/**
|
|
83
|
+
* Derives `riskScore` from a raw detection-metadata bag (the engine's
|
|
84
|
+
* `detectionDetail.metadata`, or an ingest route's forwarded copy of the
|
|
85
|
+
* `shadow_*`-filtered subset — both carry `shadow_noisy_or_confidence`
|
|
86
|
+
* under the same key when the combiner ran). Returns `null` — never
|
|
87
|
+
* `0` — when the key is absent, non-numeric, or the input isn't an object:
|
|
88
|
+
* an actual `0` score is a real (if rare) combiner output and must stay
|
|
89
|
+
* distinguishable from "the combiner did not run".
|
|
90
|
+
*
|
|
91
|
+
* Clamps to [0, 100] before rounding — a value outside that range (a bad
|
|
92
|
+
* combiner input, a future engine bug) would otherwise overflow the wire
|
|
93
|
+
* schema's [0, 1] domain and the DB column's `numeric(3, 2)` domain
|
|
94
|
+
* (±9.99); Postgres raises 22003 on the latter, and since
|
|
95
|
+
* `persistDetections` batches rows into one multi-row INSERT, a single
|
|
96
|
+
* bad value fails every detection in that batch (bestbrian, PR #4999).
|
|
97
|
+
*
|
|
98
|
+
* Rounds the raw 0-100 value to the nearest whole number before dividing by
|
|
99
|
+
* 100 — equivalent to rounding the final 0-1 value to two decimal places,
|
|
100
|
+
* kept in this exact form so the same formula reads identically next to
|
|
101
|
+
* the .NET (`Math.Round(raw) / 100.0`) and Java (`Math.round(raw) / 100.0`)
|
|
102
|
+
* projections, which must stay in lockstep with this one (both clamp the
|
|
103
|
+
* same way).
|
|
104
|
+
*/
|
|
105
|
+
function riskScoreFromMetadata(metadata) {
|
|
106
|
+
if (metadata === null || typeof metadata !== "object" || Array.isArray(metadata)) return null;
|
|
107
|
+
const raw = metadata[SHADOW_NOISY_OR_CONFIDENCE_KEY];
|
|
108
|
+
if (typeof raw !== "number" || !Number.isFinite(raw)) return null;
|
|
109
|
+
return Math.round(Math.min(100, Math.max(0, raw))) / 100;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Companion to `riskScoreFromMetadata`: `null` exactly when `riskScore`
|
|
113
|
+
* is `null` (the combiner did not run), `'uncalibrated'` otherwise — see
|
|
114
|
+
* `RiskScoreSourceSchema`'s doc comment for why this is the only value
|
|
115
|
+
* this function can return today.
|
|
116
|
+
*/
|
|
117
|
+
function riskScoreSourceFromMetadata(metadata) {
|
|
118
|
+
return riskScoreFromMetadata(metadata) === null ? null : "uncalibrated";
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* `riskScoreFromMetadata`, stringified for a Drizzle `numeric(3, 2)` insert
|
|
122
|
+
* column — Drizzle types Postgres `numeric` as `string` (never `number`) to
|
|
123
|
+
* avoid float precision loss, so every `detections.riskScore` insert site
|
|
124
|
+
* needs this rather than the bare wire/`number` value above.
|
|
125
|
+
*/
|
|
126
|
+
function riskScoreColumnValue(metadata) {
|
|
127
|
+
const score = riskScoreFromMetadata(metadata);
|
|
128
|
+
return score === null ? null : score.toFixed(2);
|
|
129
|
+
}
|
|
130
|
+
|
|
41
131
|
//#endregion
|
|
42
132
|
//#region src/core/detection-reason-codes.ts
|
|
43
133
|
/**
|
|
@@ -76,47 +166,47 @@ function date(params) {
|
|
|
76
166
|
* code) while proving every value is a well-formed `detection/…` string.
|
|
77
167
|
*/
|
|
78
168
|
const DETECTION_REASON_CODES = {
|
|
79
|
-
/** `verificationMethod === 'kya-http'
|
|
169
|
+
/** `verificationMethod === 'kya-http'`: a kya-http/RFC 9421 signature verified. */
|
|
80
170
|
SIGNATURE_VERIFIED: "detection/signature-verified",
|
|
81
|
-
/** `verificationMethod === 'kya-http-delegated'
|
|
171
|
+
/** `verificationMethod === 'kya-http-delegated'`: a verified delegation credential rode the request. */
|
|
82
172
|
DELEGATION_VERIFIED: "detection/delegation-verified",
|
|
83
|
-
/** `verificationMethod === 'mcp-i' | 'kya-os'` (the wire values; `isKyaOsWireMethod`)
|
|
173
|
+
/** `verificationMethod === 'mcp-i' | 'kya-os'` (the wire values; `isKyaOsWireMethod`): the MCP-I/KYA-OS handshake verified. */
|
|
84
174
|
MCP_I_VERIFIED: "detection/mcp-i-verified",
|
|
85
|
-
/** `verificationMethod === 'did'
|
|
175
|
+
/** `verificationMethod === 'did'`: the worker's DID-header scheme verified an Ed25519 signature against the agent's DID Document. */
|
|
86
176
|
DID_SIGNATURE_VERIFIED: "detection/did-signature-verified",
|
|
87
|
-
/** `verificationMethod === 'signature'
|
|
177
|
+
/** `verificationMethod === 'signature'`: the worker's RFC 9421 signature verifier (ChatGPT et al.) verified against the DB-refreshed key directory. */
|
|
88
178
|
RFC9421_SIGNATURE_VERIFIED: "detection/rfc9421-signature-verified",
|
|
89
|
-
/** `verificationMethod` starts with `tier1_` (e.g. `tier1_rfc9421`)
|
|
179
|
+
/** `verificationMethod` starts with `tier1_` (e.g. `tier1_rfc9421`): the engine's Tier-1 protocol attribution verified. */
|
|
90
180
|
TIER1_ATTRIBUTION_VERIFIED: "detection/tier1-attribution-verified",
|
|
91
|
-
/** `verificationMethod === 'a2a'
|
|
181
|
+
/** `verificationMethod === 'a2a'`: an A2A Agent Card's declared security scheme (RFC 9421 keyid, or a JWT bearer against resolved JWKS) cryptographically verified. */
|
|
92
182
|
A2A_VERIFIED: "detection/a2a-verified",
|
|
93
|
-
/** `verificationMethod === 'error'
|
|
183
|
+
/** `verificationMethod === 'error'`: a presented credential was demoted/rejected during verification; see the sibling `kyaErrorCode`. */
|
|
94
184
|
VERIFICATION_ERROR: "detection/verification-error",
|
|
95
|
-
/** A `signals[]` entry with `source === 'user_agent_pattern'
|
|
185
|
+
/** A `signals[]` entry with `source === 'user_agent_pattern'`: the User-Agent matched a known pattern. */
|
|
96
186
|
UA_PATTERN_MATCH: "detection/ua-pattern-match",
|
|
97
|
-
/** `source === 'header_heuristic'
|
|
187
|
+
/** `source === 'header_heuristic'`: a header shape/combination heuristic matched. */
|
|
98
188
|
HEADER_HEURISTIC: "detection/header-heuristic",
|
|
99
|
-
/** `source === 'ip_heuristic'
|
|
189
|
+
/** `source === 'ip_heuristic'`: an IP-based heuristic matched. */
|
|
100
190
|
IP_HEURISTIC: "detection/ip-heuristic",
|
|
101
|
-
/** `source === 'vendor_ip_feed'
|
|
191
|
+
/** `source === 'vendor_ip_feed'`: the request IP matched a known vendor's published IP range. */
|
|
102
192
|
VENDOR_IP_CORROBORATED: "detection/vendor-ip-corroborated",
|
|
103
|
-
/** `source === 'ip_intelligence'
|
|
193
|
+
/** `source === 'ip_intelligence'`: the host's IP-intelligence provider flagged the request's true IP as a proxy/VPN/Tor/anonymization exit. */
|
|
104
194
|
IP_INTELLIGENCE_PROXY_SIGNAL: "detection/ip-intelligence-proxy-signal",
|
|
105
|
-
/** `source === 'transport.ja4'
|
|
195
|
+
/** `source === 'transport.ja4'`: a TLS JA4 fingerprint was observed at the terminating proxy (emit-only observation marker; it matches no list). */
|
|
106
196
|
JA4_FINGERPRINT_MATCH: "detection/ja4-fingerprint-match",
|
|
107
|
-
/** `source === 'client_integrity'
|
|
197
|
+
/** `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. */
|
|
108
198
|
CLIENT_INTEGRITY_FAILURE: "detection/client-integrity-failure",
|
|
109
|
-
/** `source === 'ua_tls_mismatch'
|
|
199
|
+
/** `source === 'ua_tls_mismatch'`: the User-Agent claims a browser but the JA4 cipher-list hash (JA4_b) belongs to known non-browser tooling. */
|
|
110
200
|
UA_TLS_MISMATCH: "detection/ua-tls-mismatch",
|
|
111
|
-
/** `source === 'client.attributes'
|
|
201
|
+
/** `source === 'client.attributes'`: a pixel/beacon-reported client attribute contributed. */
|
|
112
202
|
CLIENT_ATTRIBUTE_SIGNAL: "detection/client-attribute-signal",
|
|
113
|
-
/** `source === 'behavioural.interaction'
|
|
203
|
+
/** `source === 'behavioural.interaction'`: a behavioral/interaction signal contributed. */
|
|
114
204
|
BEHAVIORAL_SIGNAL: "detection/behavioral-signal",
|
|
115
|
-
/** `source === 'mcp_i'
|
|
205
|
+
/** `source === 'mcp_i'`: an MCP-I header was present (evidence short of a completed handshake). */
|
|
116
206
|
MCP_I_SIGNAL: "detection/mcp-i-signal",
|
|
117
|
-
/** `source === 'kya_http_binding'
|
|
207
|
+
/** `source === 'kya_http_binding'`: a kya-http binding was presented (evidence short of full verification). */
|
|
118
208
|
KYA_HTTP_BINDING_SIGNAL: "detection/kya-http-binding-signal",
|
|
119
|
-
/** `source === 'kya_delegation_bearer'
|
|
209
|
+
/** `source === 'kya_delegation_bearer'`: a delegation bearer credential was presented. */
|
|
120
210
|
KYA_DELEGATION_BEARER_SIGNAL: "detection/kya-delegation-bearer-signal",
|
|
121
211
|
/** A `signals[]` entry with `source === 'a2a_agent_card'`: an A2A Agent Card was presented (evidence short of, or alongside, full verification). */
|
|
122
212
|
A2A_CARD_SIGNAL: "detection/a2a-card-signal",
|
|
@@ -126,17 +216,17 @@ const DETECTION_REASON_CODES = {
|
|
|
126
216
|
CLIENT_HEADLESS_ESCALATION_SIGNAL: "detection/client-headless-escalation-signal",
|
|
127
217
|
/** `source === 'transport.cloudflare_bot_management'`: Cloudflare's bot-management score or verified-bot determination contributed. */
|
|
128
218
|
CLOUDFLARE_BOT_MANAGEMENT_SIGNAL: "detection/cloudflare-bot-management-signal",
|
|
129
|
-
/** `source === 'session_velocity'`: the edge-computed request-velocity heuristic contributed
|
|
219
|
+
/** `source === 'session_velocity'`: the edge-computed request-velocity heuristic contributed. */
|
|
130
220
|
SESSION_VELOCITY_SIGNAL: "detection/session-velocity-signal",
|
|
131
|
-
/** A `signals[]` entry whose `source` starts with `tier1_
|
|
221
|
+
/** A `signals[]` entry whose `source` starts with `tier1_`: raw Tier-1 protocol evidence, short of (or alongside) full verification. */
|
|
132
222
|
TIER1_ATTRIBUTION_SIGNAL: "detection/tier1-attribution-signal",
|
|
133
|
-
/** `isAiCrawler === true
|
|
223
|
+
/** `isAiCrawler === true`: classified as an AI training crawler (GPTBot, ClaudeBot, etc.), not an interactive agent. */
|
|
134
224
|
AI_CRAWLER_FLAG: "detection/ai-crawler-flag",
|
|
135
|
-
/** `detectionClass === 'human'` with no contributing signals and no verification
|
|
225
|
+
/** `detectionClass === 'human'` with no contributing signals and no verification: the baseline "nothing matched" human path. */
|
|
136
226
|
ZERO_EVIDENCE_HUMAN: "detection/zero-evidence-human",
|
|
137
|
-
/** `detectionClass === 'incomplete_data' | 'unknown'` (or absent)
|
|
227
|
+
/** `detectionClass === 'incomplete_data' | 'unknown'` (or absent): the engine could not classify confidently. */
|
|
138
228
|
INCOMPLETE_DATA_OVERRIDE: "detection/incomplete-data-override",
|
|
139
|
-
/** A non-human, non-incomplete-data class (`ai_agent` / `bot` / `automation`) reached with zero contributing signals and no verification
|
|
229
|
+
/** 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. */
|
|
140
230
|
CLASSIFIED_WITHOUT_SIGNAL_EVIDENCE: "detection/classified-without-signal-evidence"
|
|
141
231
|
};
|
|
142
232
|
/** The registry's value tuple, for z.enum. */
|
|
@@ -435,6 +525,16 @@ const DetectionDetailSchema = object({
|
|
|
435
525
|
* - 91-100: Very high confidence
|
|
436
526
|
*/
|
|
437
527
|
confidence: number$1().min(0).max(100),
|
|
528
|
+
/**
|
|
529
|
+
* P58/PR-A: the Noisy-Or probability that the request is automated
|
|
530
|
+
* (0-1, two decimals), uncalibrated (see `riskScoreSource` below).
|
|
531
|
+
* `null` when the combiner did not run. See `RiskScoreSchema` /
|
|
532
|
+
* `riskScoreFromMetadata` — always additive, never derived from or fed
|
|
533
|
+
* back into `confidence` above.
|
|
534
|
+
*/
|
|
535
|
+
riskScore: RiskScoreSchema.optional(),
|
|
536
|
+
/** Which metadata key `riskScore` was derived from. See `RiskScoreSourceSchema`. */
|
|
537
|
+
riskScoreSource: RiskScoreSourceSchema.optional(),
|
|
438
538
|
detectionClass: DetectionClassSchema,
|
|
439
539
|
confidenceLevel: _enum([
|
|
440
540
|
"low",
|
|
@@ -1033,13 +1133,6 @@ function buildVerdictEvidence(signals) {
|
|
|
1033
1133
|
* verified by hand against `TWO_SIGNAL_EVIDENCE_FIXTURE` — the un-primed
|
|
1034
1134
|
* formula returns 94.2, the real engine returns 94.78).
|
|
1035
1135
|
*
|
|
1036
|
-
* NOT auto-synced with the Rust constant — there is no cross-language
|
|
1037
|
-
* value-extraction mechanism for a single scalar like there is for the
|
|
1038
|
-
* Tier-3 pattern tables (`tests/tier3_pattern_drift.rs`). If
|
|
1039
|
-
* `UNCALIBRATED_NOISY_OR_PRIOR` ever changes on the Rust side (P17
|
|
1040
|
-
* calibration landing, most likely), this constant must change with it —
|
|
1041
|
-
* grep both for `UNCALIBRATED_NOISY_OR_PRIOR` in a sibling-sweep before
|
|
1042
|
-
* touching either one.
|
|
1043
1136
|
*/
|
|
1044
1137
|
const UNCALIBRATED_NOISY_OR_PRIOR = .1;
|
|
1045
1138
|
/**
|
|
@@ -1346,23 +1439,25 @@ const CacheConfigSchema = object({
|
|
|
1346
1439
|
]).default("lru")
|
|
1347
1440
|
});
|
|
1348
1441
|
/**
|
|
1442
|
+
* A setting with no runtime behind it: any defined value fails parsing with
|
|
1443
|
+
* this message, so a caller who sets it does not believe it took effect.
|
|
1444
|
+
*/
|
|
1445
|
+
const unsupportedSetting = (name, guidance) => never({ error: `\`${name}\` is not supported and was never enforced. ${guidance}` }).optional();
|
|
1446
|
+
const NO_PER_REQUEST_IP_INTELLIGENCE = "No Checkpoint runtime classifies VPN/proxy traffic per request from SDK config.";
|
|
1447
|
+
const NO_SDK_IP_FILTER = "Filter by IP in your own middleware or at your edge/WAF; Checkpoint SDKs do not enforce IP lists.";
|
|
1448
|
+
const NO_SDK_NETWORK_TOGGLES = "The engine always evaluates cloud and datacenter ranges; no runtime reads network settings from SDK config.";
|
|
1449
|
+
const NO_SDK_AGENT_LISTS = "Checkpoint SDKs do not enforce agent allow/block lists from this config; set them in the project policy.";
|
|
1450
|
+
const NO_SDK_CUSTOM_DETECTION = "No Checkpoint runtime reads custom rules or patterns from this config.";
|
|
1451
|
+
/**
|
|
1349
1452
|
* Network analysis configuration
|
|
1350
1453
|
*/
|
|
1351
1454
|
const NetworkConfigSchema = object({
|
|
1352
|
-
enabled:
|
|
1353
|
-
checkCloudProviders:
|
|
1354
|
-
checkDataCenters:
|
|
1355
|
-
checkVpn:
|
|
1356
|
-
checkProxy:
|
|
1357
|
-
customIpRanges:
|
|
1358
|
-
name: string(),
|
|
1359
|
-
ranges: array(string()),
|
|
1360
|
-
action: _enum([
|
|
1361
|
-
"allow",
|
|
1362
|
-
"block",
|
|
1363
|
-
"flag"
|
|
1364
|
-
])
|
|
1365
|
-
})).optional()
|
|
1455
|
+
enabled: unsupportedSetting("enabled", NO_SDK_NETWORK_TOGGLES),
|
|
1456
|
+
checkCloudProviders: unsupportedSetting("checkCloudProviders", NO_SDK_NETWORK_TOGGLES),
|
|
1457
|
+
checkDataCenters: unsupportedSetting("checkDataCenters", NO_SDK_NETWORK_TOGGLES),
|
|
1458
|
+
checkVpn: unsupportedSetting("checkVpn", NO_PER_REQUEST_IP_INTELLIGENCE),
|
|
1459
|
+
checkProxy: unsupportedSetting("checkProxy", NO_PER_REQUEST_IP_INTELLIGENCE),
|
|
1460
|
+
customIpRanges: unsupportedSetting("customIpRanges", NO_SDK_IP_FILTER)
|
|
1366
1461
|
});
|
|
1367
1462
|
/**
|
|
1368
1463
|
* Logging configuration
|
|
@@ -1407,12 +1502,12 @@ const AgentShieldConfigSchema = object({
|
|
|
1407
1502
|
network: NetworkConfigSchema.optional(),
|
|
1408
1503
|
logging: LoggingConfigSchema.optional(),
|
|
1409
1504
|
wasm: WasmConfigSchema.optional(),
|
|
1410
|
-
customRules:
|
|
1411
|
-
customPatterns:
|
|
1412
|
-
allowedAgents:
|
|
1413
|
-
blockedAgents:
|
|
1414
|
-
allowedIps:
|
|
1415
|
-
blockedIps:
|
|
1505
|
+
customRules: unsupportedSetting("customRules", NO_SDK_CUSTOM_DETECTION),
|
|
1506
|
+
customPatterns: unsupportedSetting("customPatterns", NO_SDK_CUSTOM_DETECTION),
|
|
1507
|
+
allowedAgents: unsupportedSetting("allowedAgents", NO_SDK_AGENT_LISTS),
|
|
1508
|
+
blockedAgents: unsupportedSetting("blockedAgents", NO_SDK_AGENT_LISTS),
|
|
1509
|
+
allowedIps: unsupportedSetting("allowedIps", NO_SDK_IP_FILTER),
|
|
1510
|
+
blockedIps: unsupportedSetting("blockedIps", NO_SDK_IP_FILTER)
|
|
1416
1511
|
});
|
|
1417
1512
|
/**
|
|
1418
1513
|
* Default configuration
|
|
@@ -1565,14 +1660,7 @@ const KNOWN_AGENT_PATTERNS = [
|
|
|
1565
1660
|
id: "openai-chatgpt",
|
|
1566
1661
|
type: "openai",
|
|
1567
1662
|
name: "ChatGPT",
|
|
1568
|
-
patterns: [
|
|
1569
|
-
"ChatGPT-User",
|
|
1570
|
-
"OAI-SearchBot",
|
|
1571
|
-
"gpt-4",
|
|
1572
|
-
"gpt-3.5",
|
|
1573
|
-
"gpt-4-turbo",
|
|
1574
|
-
"gpt-4o"
|
|
1575
|
-
],
|
|
1663
|
+
patterns: ["ChatGPT-User", "OAI-SearchBot"],
|
|
1576
1664
|
headers: { "X-OpenAI-Assistant": "*" },
|
|
1577
1665
|
confidence: .95,
|
|
1578
1666
|
category: "ai_assistant",
|
|
@@ -1606,13 +1694,7 @@ const KNOWN_AGENT_PATTERNS = [
|
|
|
1606
1694
|
"Claude-User",
|
|
1607
1695
|
"Claude-SearchBot",
|
|
1608
1696
|
"claude-code",
|
|
1609
|
-
"claude code"
|
|
1610
|
-
"claude-3",
|
|
1611
|
-
"claude-2",
|
|
1612
|
-
"claude-instant",
|
|
1613
|
-
"claude-3-opus",
|
|
1614
|
-
"claude-3-sonnet",
|
|
1615
|
-
"claude-3-haiku"
|
|
1697
|
+
"claude code"
|
|
1616
1698
|
],
|
|
1617
1699
|
headers: { "X-Anthropic-Client": "*" },
|
|
1618
1700
|
confidence: .95,
|
|
@@ -1659,11 +1741,7 @@ const KNOWN_AGENT_PATTERNS = [
|
|
|
1659
1741
|
id: "perplexity-user",
|
|
1660
1742
|
type: "perplexity",
|
|
1661
1743
|
name: "Perplexity",
|
|
1662
|
-
patterns: [
|
|
1663
|
-
"Perplexity-User",
|
|
1664
|
-
"Perplexity-AI",
|
|
1665
|
-
"Comet"
|
|
1666
|
-
],
|
|
1744
|
+
patterns: ["Perplexity-User", "Perplexity-AI"],
|
|
1667
1745
|
confidence: .95,
|
|
1668
1746
|
category: "ai_assistant",
|
|
1669
1747
|
isLegitimate: true
|
|
@@ -1677,15 +1755,6 @@ const KNOWN_AGENT_PATTERNS = [
|
|
|
1677
1755
|
category: "ai_assistant",
|
|
1678
1756
|
isLegitimate: true
|
|
1679
1757
|
},
|
|
1680
|
-
{
|
|
1681
|
-
id: "google-extended",
|
|
1682
|
-
type: "google",
|
|
1683
|
-
name: "Google-Extended",
|
|
1684
|
-
patterns: ["Google-Extended"],
|
|
1685
|
-
confidence: .9,
|
|
1686
|
-
category: "scraper",
|
|
1687
|
-
isLegitimate: true
|
|
1688
|
-
},
|
|
1689
1758
|
{
|
|
1690
1759
|
id: "gemini-deep-research",
|
|
1691
1760
|
type: "google",
|
|
@@ -1702,27 +1771,29 @@ const KNOWN_AGENT_PATTERNS = [
|
|
|
1702
1771
|
patterns: [
|
|
1703
1772
|
"Bard",
|
|
1704
1773
|
"\\bgemini\\b",
|
|
1705
|
-
"gemini-pro",
|
|
1706
|
-
"gemini-1.5",
|
|
1707
|
-
"gemini-1.5-pro",
|
|
1708
|
-
"gemini-ultra",
|
|
1709
|
-
"\\bpalm\\b",
|
|
1710
|
-
"palm2",
|
|
1711
|
-
"LaMDA",
|
|
1712
1774
|
"GoogleAgent-Mariner"
|
|
1713
1775
|
],
|
|
1714
1776
|
confidence: .9,
|
|
1715
1777
|
category: "ai_assistant",
|
|
1716
1778
|
isLegitimate: true
|
|
1717
1779
|
},
|
|
1780
|
+
{
|
|
1781
|
+
id: "google-notebooklm",
|
|
1782
|
+
type: "google",
|
|
1783
|
+
name: "Google NotebookLM",
|
|
1784
|
+
patterns: ["Google-GeminiNotebook"],
|
|
1785
|
+
confidence: .95,
|
|
1786
|
+
category: "ai_assistant",
|
|
1787
|
+
isLegitimate: true
|
|
1788
|
+
},
|
|
1718
1789
|
{
|
|
1719
1790
|
id: "microsoft-copilot",
|
|
1720
1791
|
type: "microsoft",
|
|
1721
1792
|
name: "Microsoft Copilot",
|
|
1722
1793
|
patterns: [
|
|
1723
|
-
"copilot",
|
|
1724
1794
|
"github-copilot",
|
|
1725
1795
|
"microsoft-copilot",
|
|
1796
|
+
"\\bcopilot\\b",
|
|
1726
1797
|
"BingPreview/.*ChatGPT"
|
|
1727
1798
|
],
|
|
1728
1799
|
confidence: .9,
|
|
@@ -1738,6 +1809,15 @@ const KNOWN_AGENT_PATTERNS = [
|
|
|
1738
1809
|
category: "ai_assistant",
|
|
1739
1810
|
isLegitimate: true
|
|
1740
1811
|
},
|
|
1812
|
+
{
|
|
1813
|
+
id: "meta-muse",
|
|
1814
|
+
type: "meta",
|
|
1815
|
+
name: "Meta Muse",
|
|
1816
|
+
patterns: ["Meta-Muse"],
|
|
1817
|
+
confidence: .9,
|
|
1818
|
+
category: "ai_assistant",
|
|
1819
|
+
isLegitimate: true
|
|
1820
|
+
},
|
|
1741
1821
|
{
|
|
1742
1822
|
id: "meta-externalagent",
|
|
1743
1823
|
type: "meta",
|
|
@@ -1747,6 +1827,24 @@ const KNOWN_AGENT_PATTERNS = [
|
|
|
1747
1827
|
category: "scraper",
|
|
1748
1828
|
isLegitimate: true
|
|
1749
1829
|
},
|
|
1830
|
+
{
|
|
1831
|
+
id: "meta-externalfetcher",
|
|
1832
|
+
type: "meta",
|
|
1833
|
+
name: "Meta-ExternalFetcher",
|
|
1834
|
+
patterns: ["Meta-ExternalFetcher"],
|
|
1835
|
+
confidence: .95,
|
|
1836
|
+
category: "ai_assistant",
|
|
1837
|
+
isLegitimate: true
|
|
1838
|
+
},
|
|
1839
|
+
{
|
|
1840
|
+
id: "meta-webindexer",
|
|
1841
|
+
type: "meta",
|
|
1842
|
+
name: "Meta-WebIndexer",
|
|
1843
|
+
patterns: ["meta-webindexer"],
|
|
1844
|
+
confidence: .95,
|
|
1845
|
+
category: "scraper",
|
|
1846
|
+
isLegitimate: true
|
|
1847
|
+
},
|
|
1750
1848
|
{
|
|
1751
1849
|
id: "cohere-bot",
|
|
1752
1850
|
type: "cohere",
|
|
@@ -1765,96 +1863,15 @@ const KNOWN_AGENT_PATTERNS = [
|
|
|
1765
1863
|
category: "scraper",
|
|
1766
1864
|
isLegitimate: true
|
|
1767
1865
|
},
|
|
1768
|
-
{
|
|
1769
|
-
id: "meta-llama",
|
|
1770
|
-
type: "meta",
|
|
1771
|
-
name: "LLaMA",
|
|
1772
|
-
patterns: [
|
|
1773
|
-
"llama",
|
|
1774
|
-
"llama-2",
|
|
1775
|
-
"llama-3",
|
|
1776
|
-
"llama2",
|
|
1777
|
-
"llama3",
|
|
1778
|
-
"codellama",
|
|
1779
|
-
"alpaca"
|
|
1780
|
-
],
|
|
1781
|
-
confidence: .85,
|
|
1782
|
-
category: "ai_assistant",
|
|
1783
|
-
isLegitimate: true
|
|
1784
|
-
},
|
|
1785
1866
|
{
|
|
1786
1867
|
id: "mistral-ai",
|
|
1787
1868
|
type: "mistral",
|
|
1788
1869
|
name: "MistralBot",
|
|
1789
|
-
patterns: [
|
|
1790
|
-
"mistral",
|
|
1791
|
-
"mixtral",
|
|
1792
|
-
"mistral-7b",
|
|
1793
|
-
"mixtral-8x7b",
|
|
1794
|
-
"mistral-medium",
|
|
1795
|
-
"mistral-large"
|
|
1796
|
-
],
|
|
1797
|
-
confidence: .85,
|
|
1798
|
-
category: "ai_assistant",
|
|
1799
|
-
isLegitimate: true
|
|
1800
|
-
},
|
|
1801
|
-
{
|
|
1802
|
-
id: "cohere-command",
|
|
1803
|
-
type: "cohere",
|
|
1804
|
-
name: "CommandBot",
|
|
1805
|
-
patterns: [
|
|
1806
|
-
"command",
|
|
1807
|
-
"command-r",
|
|
1808
|
-
"command-r-plus",
|
|
1809
|
-
"commandr"
|
|
1810
|
-
],
|
|
1870
|
+
patterns: ["mistral"],
|
|
1811
1871
|
confidence: .85,
|
|
1812
1872
|
category: "ai_assistant",
|
|
1813
1873
|
isLegitimate: true
|
|
1814
1874
|
},
|
|
1815
|
-
{
|
|
1816
|
-
id: "microsoft-phi",
|
|
1817
|
-
type: "microsoft",
|
|
1818
|
-
name: "PhiBot",
|
|
1819
|
-
patterns: [
|
|
1820
|
-
"phi-2",
|
|
1821
|
-
"phi-3",
|
|
1822
|
-
"phi-3-mini",
|
|
1823
|
-
"phi-3-medium"
|
|
1824
|
-
],
|
|
1825
|
-
confidence: .8,
|
|
1826
|
-
category: "ai_assistant",
|
|
1827
|
-
isLegitimate: true
|
|
1828
|
-
},
|
|
1829
|
-
{
|
|
1830
|
-
id: "alibaba-qwen",
|
|
1831
|
-
type: "alibaba",
|
|
1832
|
-
name: "QwenBot",
|
|
1833
|
-
patterns: [
|
|
1834
|
-
"qwen",
|
|
1835
|
-
"qwen-7b",
|
|
1836
|
-
"qwen-14b",
|
|
1837
|
-
"qwen-72b",
|
|
1838
|
-
"qwen1.5",
|
|
1839
|
-
"qwen2"
|
|
1840
|
-
],
|
|
1841
|
-
confidence: .8,
|
|
1842
|
-
category: "ai_assistant",
|
|
1843
|
-
isLegitimate: true
|
|
1844
|
-
},
|
|
1845
|
-
{
|
|
1846
|
-
id: "01ai-yi",
|
|
1847
|
-
type: "01ai",
|
|
1848
|
-
name: "YiBot",
|
|
1849
|
-
patterns: [
|
|
1850
|
-
"yi-6b",
|
|
1851
|
-
"yi-34b",
|
|
1852
|
-
"yi-large"
|
|
1853
|
-
],
|
|
1854
|
-
confidence: .8,
|
|
1855
|
-
category: "ai_assistant",
|
|
1856
|
-
isLegitimate: true
|
|
1857
|
-
},
|
|
1858
1875
|
{
|
|
1859
1876
|
id: "inflection-pi",
|
|
1860
1877
|
type: "inflection",
|
|
@@ -1872,11 +1889,7 @@ const KNOWN_AGENT_PATTERNS = [
|
|
|
1872
1889
|
id: "stability-ai",
|
|
1873
1890
|
type: "stability",
|
|
1874
1891
|
name: "StabilityBot",
|
|
1875
|
-
patterns: [
|
|
1876
|
-
"stablelm",
|
|
1877
|
-
"stable-lm",
|
|
1878
|
-
"stability-ai"
|
|
1879
|
-
],
|
|
1892
|
+
patterns: ["stability-ai"],
|
|
1880
1893
|
confidence: .8,
|
|
1881
1894
|
category: "ai_assistant",
|
|
1882
1895
|
isLegitimate: true
|
|
@@ -1885,7 +1898,7 @@ const KNOWN_AGENT_PATTERNS = [
|
|
|
1885
1898
|
id: "writer-ai",
|
|
1886
1899
|
type: "writer",
|
|
1887
1900
|
name: "WriterBot",
|
|
1888
|
-
patterns: ["writerai"
|
|
1901
|
+
patterns: ["writerai"],
|
|
1889
1902
|
confidence: .8,
|
|
1890
1903
|
category: "ai_assistant",
|
|
1891
1904
|
isLegitimate: true
|
|
@@ -1975,6 +1988,51 @@ const KNOWN_AGENT_PATTERNS = [
|
|
|
1975
1988
|
category: "scraper",
|
|
1976
1989
|
isLegitimate: true
|
|
1977
1990
|
},
|
|
1991
|
+
{
|
|
1992
|
+
id: "exa-search-bot",
|
|
1993
|
+
type: "unknown",
|
|
1994
|
+
name: "ExaSearchBot",
|
|
1995
|
+
patterns: ["ExaSearchBot"],
|
|
1996
|
+
confidence: .95,
|
|
1997
|
+
category: "scraper",
|
|
1998
|
+
isLegitimate: true
|
|
1999
|
+
},
|
|
2000
|
+
{
|
|
2001
|
+
id: "ai2-bot",
|
|
2002
|
+
type: "unknown",
|
|
2003
|
+
name: "AI2Bot",
|
|
2004
|
+
patterns: ["AI2Bot"],
|
|
2005
|
+
confidence: .95,
|
|
2006
|
+
category: "scraper",
|
|
2007
|
+
isLegitimate: true
|
|
2008
|
+
},
|
|
2009
|
+
{
|
|
2010
|
+
id: "diffbot",
|
|
2011
|
+
type: "unknown",
|
|
2012
|
+
name: "Diffbot",
|
|
2013
|
+
patterns: ["Diffbot"],
|
|
2014
|
+
confidence: .9,
|
|
2015
|
+
category: "scraper",
|
|
2016
|
+
isLegitimate: true
|
|
2017
|
+
},
|
|
2018
|
+
{
|
|
2019
|
+
id: "kimi-user",
|
|
2020
|
+
type: "unknown",
|
|
2021
|
+
name: "Kimi",
|
|
2022
|
+
patterns: ["Kimi-User"],
|
|
2023
|
+
confidence: .95,
|
|
2024
|
+
category: "ai_assistant",
|
|
2025
|
+
isLegitimate: true
|
|
2026
|
+
},
|
|
2027
|
+
{
|
|
2028
|
+
id: "kimi-bot",
|
|
2029
|
+
type: "unknown",
|
|
2030
|
+
name: "KimiBot",
|
|
2031
|
+
patterns: ["KimiBot", "Kimi-SearchBot"],
|
|
2032
|
+
confidence: .95,
|
|
2033
|
+
category: "scraper",
|
|
2034
|
+
isLegitimate: true
|
|
2035
|
+
},
|
|
1978
2036
|
{
|
|
1979
2037
|
id: "amazon-quick",
|
|
1980
2038
|
type: "amazon",
|
|
@@ -2029,8 +2087,8 @@ const CLOUD_PROVIDER_RANGES = {
|
|
|
2029
2087
|
]
|
|
2030
2088
|
};
|
|
2031
2089
|
/**
|
|
2032
|
-
* Common bot user agent patterns
|
|
2033
|
-
*
|
|
2090
|
+
* Common bot user agent patterns. Model-version names (gpt-4, claude-3,
|
|
2091
|
+
* llama-3, ...) are not UA tokens and are not listed.
|
|
2034
2092
|
*/
|
|
2035
2093
|
const BOT_USER_AGENT_PATTERNS = [
|
|
2036
2094
|
/bot/i,
|
|
@@ -2039,26 +2097,15 @@ const BOT_USER_AGENT_PATTERNS = [
|
|
|
2039
2097
|
/scraper/i,
|
|
2040
2098
|
/agent/i,
|
|
2041
2099
|
/ai\//i,
|
|
2042
|
-
/gpt(-?[0-9])?/i,
|
|
2043
2100
|
/chatgpt/i,
|
|
2044
2101
|
/openai/i,
|
|
2045
|
-
/claude
|
|
2102
|
+
/claude/i,
|
|
2046
2103
|
/anthropic/i,
|
|
2047
|
-
/gemini
|
|
2104
|
+
/gemini/i,
|
|
2048
2105
|
/bard/i,
|
|
2049
|
-
/palm[0-9]?/i,
|
|
2050
|
-
/llama(-?[0-9])?/i,
|
|
2051
|
-
/codellama/i,
|
|
2052
|
-
/alpaca/i,
|
|
2053
2106
|
/mistral/i,
|
|
2054
|
-
/mixtral/i,
|
|
2055
|
-
/phi(-?[0-9])?/i,
|
|
2056
2107
|
/copilot/i,
|
|
2057
2108
|
/perplexity/i,
|
|
2058
|
-
/command(-?r)?/i,
|
|
2059
|
-
/qwen[0-9.]?/i,
|
|
2060
|
-
/yi(-?[0-9]+b)?/i,
|
|
2061
|
-
/stablelm/i,
|
|
2062
2109
|
/\bphind\b/i,
|
|
2063
2110
|
/\byou\.com\b/i,
|
|
2064
2111
|
/\bneeva\b/i,
|
|
@@ -2277,13 +2324,7 @@ const DEFAULT_AGENTSHIELD_CONFIG = {
|
|
|
2277
2324
|
},
|
|
2278
2325
|
network: void 0,
|
|
2279
2326
|
logging: void 0,
|
|
2280
|
-
wasm: void 0
|
|
2281
|
-
customRules: void 0,
|
|
2282
|
-
customPatterns: void 0,
|
|
2283
|
-
allowedAgents: void 0,
|
|
2284
|
-
blockedAgents: void 0,
|
|
2285
|
-
allowedIps: void 0,
|
|
2286
|
-
blockedIps: void 0
|
|
2327
|
+
wasm: void 0
|
|
2287
2328
|
};
|
|
2288
2329
|
/**
|
|
2289
2330
|
* Default Detection Options
|
|
@@ -2444,7 +2485,16 @@ const DEFAULT_RESPONSE_HEADERS = {
|
|
|
2444
2485
|
"X-Frame-Options": "DENY"
|
|
2445
2486
|
};
|
|
2446
2487
|
/**
|
|
2447
|
-
* Default CORS Configuration
|
|
2488
|
+
* Default CORS Configuration.
|
|
2489
|
+
*
|
|
2490
|
+
* `origin: '*'` with `credentials: true` is the exact combination the fetch
|
|
2491
|
+
* spec rejects for a credentialed request (and most CORS middleware, e.g.
|
|
2492
|
+
* the `cors` npm package, either throws or silently drops the credentials
|
|
2493
|
+
* header rather than honor it) — this constant has no environment/origin
|
|
2494
|
+
* awareness of its own, so a wildcard origin is the only safe default it
|
|
2495
|
+
* can offer. A consumer that needs credentialed cross-origin access must
|
|
2496
|
+
* replace `origin` with its own allow-list, matching the pattern in
|
|
2497
|
+
* `apps/web/lib/api/cors.ts`'s `getCorsHeaders()`.
|
|
2448
2498
|
*/
|
|
2449
2499
|
const DEFAULT_CORS_CONFIG = {
|
|
2450
2500
|
origin: "*",
|
|
@@ -2462,7 +2512,7 @@ const DEFAULT_CORS_CONFIG = {
|
|
|
2462
2512
|
"X-Pixel-ID"
|
|
2463
2513
|
],
|
|
2464
2514
|
exposedHeaders: ["KYA-Detection", "X-Rate-Limit-Remaining"],
|
|
2465
|
-
credentials:
|
|
2515
|
+
credentials: false,
|
|
2466
2516
|
maxAge: 86400
|
|
2467
2517
|
};
|
|
2468
2518
|
/**
|
|
@@ -2558,6 +2608,7 @@ const AUTH_ERRORS = {
|
|
|
2558
2608
|
EXPIRED_TOKEN: "AUTH_EXPIRED_TOKEN",
|
|
2559
2609
|
MISSING_CREDENTIALS: "AUTH_MISSING_CREDENTIALS",
|
|
2560
2610
|
UNAUTHORIZED: "AUTH_UNAUTHORIZED",
|
|
2611
|
+
MANAGEMENT_TOKEN_NOT_ACCEPTED: "AUTH_MANAGEMENT_TOKEN_NOT_ACCEPTED",
|
|
2561
2612
|
INVALID_PIXEL_ID: "AUTH_INVALID_PIXEL_ID",
|
|
2562
2613
|
INVALID_SECRET_KEY: "AUTH_INVALID_SECRET_KEY"
|
|
2563
2614
|
};
|
|
@@ -2602,7 +2653,8 @@ const RATE_LIMIT_ERRORS = {
|
|
|
2602
2653
|
DAILY_LIMIT_EXCEEDED: "RATE_LIMIT_DAILY_EXCEEDED",
|
|
2603
2654
|
MONTHLY_LIMIT_EXCEEDED: "RATE_LIMIT_MONTHLY_EXCEEDED",
|
|
2604
2655
|
CONCURRENT_LIMIT_EXCEEDED: "RATE_LIMIT_CONCURRENT_EXCEEDED",
|
|
2605
|
-
QUOTA_EXCEEDED: "RATE_LIMIT_QUOTA_EXCEEDED"
|
|
2656
|
+
QUOTA_EXCEEDED: "RATE_LIMIT_QUOTA_EXCEEDED",
|
|
2657
|
+
RATE_LIMITED: "RATE_LIMITED"
|
|
2606
2658
|
};
|
|
2607
2659
|
/**
|
|
2608
2660
|
* Permission Error Codes
|
|
@@ -2614,7 +2666,8 @@ const PERMISSION_ERRORS = {
|
|
|
2614
2666
|
OPERATION_NOT_ALLOWED: "PERMISSION_OPERATION_NOT_ALLOWED",
|
|
2615
2667
|
PROJECT_ACCESS_DENIED: "PERMISSION_PROJECT_ACCESS_DENIED",
|
|
2616
2668
|
PIXEL_ACCESS_DENIED: "PERMISSION_PIXEL_ACCESS_DENIED",
|
|
2617
|
-
FORBIDDEN: "PERMISSION_FORBIDDEN"
|
|
2669
|
+
FORBIDDEN: "PERMISSION_FORBIDDEN",
|
|
2670
|
+
PERMISSION_DENIED: "PERMISSION_DENIED"
|
|
2618
2671
|
};
|
|
2619
2672
|
/**
|
|
2620
2673
|
* Network Error Codes
|
|
@@ -2638,7 +2691,10 @@ const INTERNAL_ERRORS = {
|
|
|
2638
2691
|
INITIALIZATION_ERROR: "INTERNAL_INITIALIZATION_ERROR",
|
|
2639
2692
|
PROCESSING_ERROR: "INTERNAL_PROCESSING_ERROR",
|
|
2640
2693
|
UNKNOWN_ERROR: "INTERNAL_UNKNOWN_ERROR",
|
|
2641
|
-
SERVICE_UNAVAILABLE_TRANSIENT: "SERVICE_UNAVAILABLE_TRANSIENT"
|
|
2694
|
+
SERVICE_UNAVAILABLE_TRANSIENT: "SERVICE_UNAVAILABLE_TRANSIENT",
|
|
2695
|
+
TRANSACTION_FAILED: "TRANSACTION_FAILED",
|
|
2696
|
+
DELETE_FAILED: "DELETE_FAILED",
|
|
2697
|
+
PARTITION_RETIREMENT_IN_PROGRESS: "PARTITION_RETIREMENT_IN_PROGRESS"
|
|
2642
2698
|
};
|
|
2643
2699
|
/**
|
|
2644
2700
|
* Session Error Codes
|
|
@@ -2664,7 +2720,8 @@ const PIXEL_ERRORS = {
|
|
|
2664
2720
|
PIXEL_EVENT_INVALID: "PIXEL_EVENT_INVALID",
|
|
2665
2721
|
PIXEL_BATCH_TOO_LARGE: "PIXEL_BATCH_TOO_LARGE",
|
|
2666
2722
|
MISSING_PIXEL_ID: "MISSING_PIXEL_ID",
|
|
2667
|
-
DETECTION_STORAGE_FAILED: "DETECTION_STORAGE_FAILED"
|
|
2723
|
+
DETECTION_STORAGE_FAILED: "DETECTION_STORAGE_FAILED",
|
|
2724
|
+
PIXEL_CREATION_FAILED: "PIXEL_CREATION_FAILED"
|
|
2668
2725
|
};
|
|
2669
2726
|
/**
|
|
2670
2727
|
* API Error Codes
|
|
@@ -2698,15 +2755,49 @@ const RESOURCE_ERRORS = {
|
|
|
2698
2755
|
*/
|
|
2699
2756
|
const POLICY_ERRORS = { POLICY_FETCH_FAILED: "POLICY_FETCH_FAILED" };
|
|
2700
2757
|
/**
|
|
2758
|
+
* Analytics Error Codes
|
|
2759
|
+
*
|
|
2760
|
+
* Emitted by the project analytics and shopify stats read routes.
|
|
2761
|
+
*/
|
|
2762
|
+
const ANALYTICS_ERRORS = {
|
|
2763
|
+
INVALID_PERIOD: "INVALID_PERIOD",
|
|
2764
|
+
ANALYTICS_FETCH_ERROR: "ANALYTICS_FETCH_ERROR",
|
|
2765
|
+
STATS_FETCH_ERROR: "STATS_FETCH_ERROR"
|
|
2766
|
+
};
|
|
2767
|
+
/**
|
|
2768
|
+
* Deploy Error Codes
|
|
2769
|
+
*
|
|
2770
|
+
* Emitted by the managed deploy route and the managed deploy service it
|
|
2771
|
+
* wraps. The service-computed codes have no fixed status here (see the
|
|
2772
|
+
* NOTE in ERROR_STATUS_CODES).
|
|
2773
|
+
*/
|
|
2774
|
+
const DEPLOY_ERRORS = {
|
|
2775
|
+
MISSING_USER_IDENTIFIER: "MISSING_USER_IDENTIFIER",
|
|
2776
|
+
USER_NOT_FOUND: "USER_NOT_FOUND",
|
|
2777
|
+
NO_ORGANIZATION: "NO_ORGANIZATION",
|
|
2778
|
+
DEPLOY_FAILED: "DEPLOY_FAILED",
|
|
2779
|
+
WFP_NOT_CONFIGURED: "WFP_NOT_CONFIGURED",
|
|
2780
|
+
NATIVE_ISSUER_PROVISIONING_BUSY: "NATIVE_ISSUER_PROVISIONING_BUSY",
|
|
2781
|
+
NATIVE_ISSUER_PROVISIONING_FAILED: "NATIVE_ISSUER_PROVISIONING_FAILED"
|
|
2782
|
+
};
|
|
2783
|
+
/**
|
|
2701
2784
|
* Bare Error Codes
|
|
2702
2785
|
*
|
|
2703
2786
|
* Un-prefixed upper-case wire strings shared by several surfaces (pixel,
|
|
2704
|
-
* pixel/track, openclaw, deploy, shopify, bouncer).
|
|
2705
|
-
* BARE_ prefix so the key cannot collide with the
|
|
2787
|
+
* pixel/track, openclaw, deploy, shopify, bouncer, project analytics).
|
|
2788
|
+
* Keyed by value with a BARE_ prefix so the key cannot collide with the
|
|
2789
|
+
* prefixed groups.
|
|
2706
2790
|
*/
|
|
2707
2791
|
const BARE_ERRORS = {
|
|
2708
2792
|
BARE_VALIDATION_ERROR: "VALIDATION_ERROR",
|
|
2709
|
-
BARE_INTERNAL_ERROR: "INTERNAL_ERROR"
|
|
2793
|
+
BARE_INTERNAL_ERROR: "INTERNAL_ERROR",
|
|
2794
|
+
BARE_INVALID_REQUEST: "INVALID_REQUEST",
|
|
2795
|
+
BARE_INVALID_JSON: "INVALID_JSON",
|
|
2796
|
+
BARE_INVALID_START_DATE: "INVALID_START_DATE",
|
|
2797
|
+
BARE_INVALID_END_DATE: "INVALID_END_DATE",
|
|
2798
|
+
BARE_INVALID_DATE_RANGE: "INVALID_DATE_RANGE",
|
|
2799
|
+
BARE_INVALID_DATE: "INVALID_DATE",
|
|
2800
|
+
BARE_UNKNOWN_ERROR: "UNKNOWN_ERROR"
|
|
2710
2801
|
};
|
|
2711
2802
|
/**
|
|
2712
2803
|
* Lowercase Error Codes
|
|
@@ -2720,6 +2811,162 @@ const LOWERCASE_ERRORS = {
|
|
|
2720
2811
|
LOWERCASE_VALIDATION_ERROR: "validation_error"
|
|
2721
2812
|
};
|
|
2722
2813
|
/**
|
|
2814
|
+
* Bouncer Error Codes (lower-case wire format)
|
|
2815
|
+
*
|
|
2816
|
+
* Emitted by the /api/v1/bouncer routes, either inline by the route or via
|
|
2817
|
+
* a `BouncerError` subclass thrown from a bouncer service. Only subclass
|
|
2818
|
+
* codes that a bouncer route can actually put on the wire are registered
|
|
2819
|
+
* here; classes that exist but are never thrown are deliberately absent.
|
|
2820
|
+
* Keyed by value with a LOWERCASE_ prefix.
|
|
2821
|
+
*/
|
|
2822
|
+
const BOUNCER_LOWERCASE_ERRORS = {
|
|
2823
|
+
LOWERCASE_NO_PROJECT: "no_project",
|
|
2824
|
+
LOWERCASE_MISSING_AGENT_DID: "missing_agent_did",
|
|
2825
|
+
LOWERCASE_NOT_CONFIGURED: "not_configured",
|
|
2826
|
+
LOWERCASE_INVALID_CREDENTIAL_CONFIG: "invalid_credential_config",
|
|
2827
|
+
LOWERCASE_PROJECT_NOT_FOUND: "project_not_found",
|
|
2828
|
+
LOWERCASE_PROJECT_MISMATCH: "project_mismatch",
|
|
2829
|
+
LOWERCASE_MISSING_DELEGATION_ID: "missing_delegation_id",
|
|
2830
|
+
LOWERCASE_INVALID_TOKEN: "invalid_token",
|
|
2831
|
+
LOWERCASE_DELEGATION_MISMATCH: "delegation_mismatch",
|
|
2832
|
+
LOWERCASE_TOKENS_NOT_FOUND: "tokens_not_found",
|
|
2833
|
+
LOWERCASE_DECRYPTION_ERROR: "decryption_error",
|
|
2834
|
+
LOWERCASE_NO_PROOFS: "no_proofs",
|
|
2835
|
+
LOWERCASE_BATCH_TOO_LARGE: "batch_too_large",
|
|
2836
|
+
LOWERCASE_NO_PROOFS_PROCESSED: "no_proofs_processed",
|
|
2837
|
+
LOWERCASE_ALL_PROOFS_REJECTED: "all_proofs_rejected",
|
|
2838
|
+
LOWERCASE_UNAUTHORIZED: "unauthorized",
|
|
2839
|
+
LOWERCASE_FORBIDDEN: "forbidden",
|
|
2840
|
+
LOWERCASE_NOT_FOUND: "not_found",
|
|
2841
|
+
LOWERCASE_CONFIG_NOT_FOUND: "config_not_found",
|
|
2842
|
+
LOWERCASE_AGENT_DENIED: "agent_denied",
|
|
2843
|
+
LOWERCASE_DELEGATION_NOT_FOUND: "delegation_not_found",
|
|
2844
|
+
LOWERCASE_SESSION_NOT_FOUND: "session_not_found",
|
|
2845
|
+
LOWERCASE_PROOF_VALIDATION_ERROR: "proof_validation_error",
|
|
2846
|
+
LOWERCASE_INSUFFICIENT_SCOPES: "insufficient_scopes",
|
|
2847
|
+
LOWERCASE_DELEGATION_VALIDATION_ERROR: "delegation_validation_error",
|
|
2848
|
+
LOWERCASE_INVALID_HTTP_REGISTRATION: "invalid_http_registration",
|
|
2849
|
+
LOWERCASE_AUTHORIZATION_HOST_UNAVAILABLE: "authorization_host_unavailable"
|
|
2850
|
+
};
|
|
2851
|
+
/**
|
|
2852
|
+
* Delegation OAuth Error Codes (lower-case wire format)
|
|
2853
|
+
*
|
|
2854
|
+
* Emitted by the bouncer authorize, oauth/start, oauth/callback and
|
|
2855
|
+
* oauth/token routes and the shared OAuth rate limiter. Several reuse RFC
|
|
2856
|
+
* 6749 vocabulary (`invalid_request`, `invalid_grant`,
|
|
2857
|
+
* `unsupported_grant_type`) but travel in the bouncer `{success, error}`
|
|
2858
|
+
* envelope, not an RFC 6749 body. Keyed by value with a LOWERCASE_ prefix.
|
|
2859
|
+
*/
|
|
2860
|
+
const OAUTH_LOWERCASE_ERRORS = {
|
|
2861
|
+
LOWERCASE_INVALID_REQUEST: "invalid_request",
|
|
2862
|
+
LOWERCASE_UNSUPPORTED_GRANT_TYPE: "unsupported_grant_type",
|
|
2863
|
+
LOWERCASE_INVALID_GRANT: "invalid_grant",
|
|
2864
|
+
LOWERCASE_INVALID_DELEGATION: "invalid_delegation",
|
|
2865
|
+
LOWERCASE_INTERNAL_ERROR: "internal_error",
|
|
2866
|
+
LOWERCASE_INVALID_STATE: "invalid_state",
|
|
2867
|
+
LOWERCASE_INVALID_TRANSACTION: "invalid_transaction",
|
|
2868
|
+
LOWERCASE_OAUTH_UNAVAILABLE: "oauth_unavailable",
|
|
2869
|
+
LOWERCASE_OAUTH_NOT_CONFIGURED: "oauth_not_configured",
|
|
2870
|
+
LOWERCASE_OAUTH_CONFIGURATION_UNSUPPORTED: "oauth_configuration_unsupported",
|
|
2871
|
+
LOWERCASE_INVALID_PROVIDER_CONFIG: "invalid_provider_config",
|
|
2872
|
+
LOWERCASE_RATE_LIMIT_EXCEEDED: "rate_limit_exceeded"
|
|
2873
|
+
};
|
|
2874
|
+
/**
|
|
2875
|
+
* Bouncer Error Codes (upper-case wire format)
|
|
2876
|
+
*
|
|
2877
|
+
* Emitted by the /api/v1/bouncer/projects/{projectId}/* routes and the
|
|
2878
|
+
* delegation request status route through `ApiError` / `v1ErrorResponse`.
|
|
2879
|
+
*/
|
|
2880
|
+
const BOUNCER_UPPERCASE_ERRORS = {
|
|
2881
|
+
INVALID_REQUEST_BODY: "INVALID_REQUEST_BODY",
|
|
2882
|
+
MCPI_CONFIG_NOT_FOUND: "MCPI_CONFIG_NOT_FOUND",
|
|
2883
|
+
CONSENT_CONFIG_NOT_FOUND: "CONSENT_CONFIG_NOT_FOUND",
|
|
2884
|
+
PROJECT_LOOKUP_FAILED: "PROJECT_LOOKUP_FAILED",
|
|
2885
|
+
CONFIG_VALIDATION_ERROR: "CONFIG_VALIDATION_ERROR",
|
|
2886
|
+
CONFIG_FETCH_FAILED: "CONFIG_FETCH_FAILED",
|
|
2887
|
+
CONFIG_UPDATE_FAILED: "CONFIG_UPDATE_FAILED",
|
|
2888
|
+
DEPLOYMENT_NOT_FOUND: "DEPLOYMENT_NOT_FOUND",
|
|
2889
|
+
INVALID_REQUEST_ID: "INVALID_REQUEST_ID",
|
|
2890
|
+
DELEGATION_REQUEST_NOT_FOUND: "DELEGATION_REQUEST_NOT_FOUND"
|
|
2891
|
+
};
|
|
2892
|
+
/**
|
|
2893
|
+
* Audit Ingest Error Codes
|
|
2894
|
+
*
|
|
2895
|
+
* Route-owned codes of POST /api/v1/audit/entries: credential, size, JSON,
|
|
2896
|
+
* rate-limit and submission-envelope failures raised before or around the
|
|
2897
|
+
* audit protocol itself.
|
|
2898
|
+
*/
|
|
2899
|
+
const AUDIT_ERRORS = {
|
|
2900
|
+
AUDIT_CREDENTIAL_REQUIRED: "AUDIT_CREDENTIAL_REQUIRED",
|
|
2901
|
+
AUDIT_REQUEST_TOO_LARGE: "AUDIT_REQUEST_TOO_LARGE",
|
|
2902
|
+
AUDIT_INVALID_JSON: "AUDIT_INVALID_JSON",
|
|
2903
|
+
AUDIT_INVALID_CREDENTIAL: "AUDIT_INVALID_CREDENTIAL",
|
|
2904
|
+
AUDIT_RATE_LIMITED: "AUDIT_RATE_LIMITED",
|
|
2905
|
+
AUDIT_INVALID_SUBMISSION: "AUDIT_INVALID_SUBMISSION",
|
|
2906
|
+
AUDIT_INTERNAL_ERROR: "AUDIT_INTERNAL_ERROR"
|
|
2907
|
+
};
|
|
2908
|
+
/**
|
|
2909
|
+
* Audit Protocol Error Codes
|
|
2910
|
+
*
|
|
2911
|
+
* The `AUDIT_ERROR_CODES` vocabulary of `@kya-os/mcp`, relayed verbatim as
|
|
2912
|
+
* `error.code` by POST /api/v1/audit/entries when the recorder throws an
|
|
2913
|
+
* `AuditProtocolError`. This package does not depend on `@kya-os/mcp`, so
|
|
2914
|
+
* the strings are copied by hand; a lock test in apps/web asserts the two
|
|
2915
|
+
* sets stay equal. The route maps each code to one fixed status. For codes
|
|
2916
|
+
* at 500 and above the route replaces the protocol message with a generic
|
|
2917
|
+
* one, so ERROR_MESSAGES carries that generic text; below 500 the wire
|
|
2918
|
+
* message is protocol-owned and ERROR_MESSAGES is descriptive only.
|
|
2919
|
+
*/
|
|
2920
|
+
const AUDIT_PROTOCOL_ERRORS = {
|
|
2921
|
+
AUDIT_UNAUTHORIZED_SUBMISSION: "AUDIT_UNAUTHORIZED_SUBMISSION",
|
|
2922
|
+
AUDIT_LEDGER_MISMATCH: "AUDIT_LEDGER_MISMATCH",
|
|
2923
|
+
AUDIT_EPOCH_MISMATCH: "AUDIT_EPOCH_MISMATCH",
|
|
2924
|
+
AUDIT_EVENT_ID_CONFLICT: "AUDIT_EVENT_ID_CONFLICT",
|
|
2925
|
+
AUDIT_INVALID_EVENT: "AUDIT_INVALID_EVENT",
|
|
2926
|
+
AUDIT_EVIDENCE_FAILURE: "AUDIT_EVIDENCE_FAILURE",
|
|
2927
|
+
AUDIT_EVIDENCE_INTEGRITY: "AUDIT_EVIDENCE_INTEGRITY",
|
|
2928
|
+
AUDIT_INVALID_CONFIGURATION: "AUDIT_INVALID_CONFIGURATION",
|
|
2929
|
+
AUDIT_JOURNAL_FAILURE: "AUDIT_JOURNAL_FAILURE",
|
|
2930
|
+
AUDIT_APPEND_CONFLICT_EXHAUSTED: "AUDIT_APPEND_CONFLICT_EXHAUSTED",
|
|
2931
|
+
AUDIT_EVIDENCE_LEGAL_HOLD: "AUDIT_EVIDENCE_LEGAL_HOLD",
|
|
2932
|
+
AUDIT_EVIDENCE_ACCESS_DENIED: "AUDIT_EVIDENCE_ACCESS_DENIED",
|
|
2933
|
+
AUDIT_CHECKPOINT_INVALID: "AUDIT_CHECKPOINT_INVALID",
|
|
2934
|
+
AUDIT_CHECKPOINT_ROLLBACK: "AUDIT_CHECKPOINT_ROLLBACK",
|
|
2935
|
+
AUDIT_CHECKPOINT_CONFLICT: "AUDIT_CHECKPOINT_CONFLICT",
|
|
2936
|
+
AUDIT_CHECKPOINT_PUBLICATION_FAILED: "AUDIT_CHECKPOINT_PUBLICATION_FAILED",
|
|
2937
|
+
AUDIT_PROJECTION_CONFLICT: "AUDIT_PROJECTION_CONFLICT",
|
|
2938
|
+
AUDIT_MIRROR_VERIFICATION_FAILED: "AUDIT_MIRROR_VERIFICATION_FAILED",
|
|
2939
|
+
AUDIT_MIRROR_CONTINUITY_FAILED: "AUDIT_MIRROR_CONTINUITY_FAILED",
|
|
2940
|
+
AUDIT_MIRROR_OUT_OF_ORDER: "AUDIT_MIRROR_OUT_OF_ORDER"
|
|
2941
|
+
};
|
|
2942
|
+
/**
|
|
2943
|
+
* KYA-OS Native HTTP Protocol Error Codes (`kyaos/*`)
|
|
2944
|
+
*
|
|
2945
|
+
* Emitted by the /api/v1/bouncer/native-http/* handlers and the managed
|
|
2946
|
+
* native issuer and propagation-proof services. The wire body is
|
|
2947
|
+
* `{ error: "<code>" }` with no message, so ERROR_MESSAGES text for these
|
|
2948
|
+
* codes is documentation only. Keyed by value with a KYAOS_SLASH_ prefix
|
|
2949
|
+
* because the wire strings carry a `/`.
|
|
2950
|
+
*/
|
|
2951
|
+
const KYAOS_PROTOCOL_ERRORS = {
|
|
2952
|
+
KYAOS_SLASH_ISSUER_FORBIDDEN: "kyaos/issuer-forbidden",
|
|
2953
|
+
KYAOS_SLASH_PROFILE_VIOLATION: "kyaos/profile-violation",
|
|
2954
|
+
KYAOS_SLASH_INVALID_SESSION: "kyaos/invalid-session",
|
|
2955
|
+
KYAOS_SLASH_SESSION_CONFLICT: "kyaos/session-conflict",
|
|
2956
|
+
KYAOS_SLASH_PICKUP_EXPIRED: "kyaos/pickup-expired",
|
|
2957
|
+
KYAOS_SLASH_SCOPE_INSUFFICIENT: "kyaos/scope-insufficient",
|
|
2958
|
+
KYAOS_SLASH_CONSENT_REQUIRED: "kyaos/consent-required",
|
|
2959
|
+
KYAOS_SLASH_PICKUP_PINNED: "kyaos/pickup-pinned",
|
|
2960
|
+
KYAOS_SLASH_AUTHORIZATION_HOST_UNAVAILABLE: "kyaos/authorization-host-unavailable",
|
|
2961
|
+
KYAOS_SLASH_CHAIN_BROKEN: "kyaos/chain-broken",
|
|
2962
|
+
KYAOS_SLASH_DELEGATION_REVOKED: "kyaos/delegation-revoked",
|
|
2963
|
+
KYAOS_SLASH_EXPIRED: "kyaos/expired",
|
|
2964
|
+
KYAOS_SLASH_HOLDER_MISMATCH: "kyaos/holder-mismatch",
|
|
2965
|
+
KYAOS_SLASH_INVALID_SIGNATURE: "kyaos/invalid-signature",
|
|
2966
|
+
KYAOS_SLASH_SESSION_MISMATCH: "kyaos/session-mismatch",
|
|
2967
|
+
KYAOS_SLASH_POLICY_UNAVAILABLE: "kyaos/policy-unavailable"
|
|
2968
|
+
};
|
|
2969
|
+
/**
|
|
2723
2970
|
* All Error Codes
|
|
2724
2971
|
*/
|
|
2725
2972
|
const ERROR_CODES = {
|
|
@@ -2736,8 +2983,16 @@ const ERROR_CODES = {
|
|
|
2736
2983
|
...BILLING_ERRORS,
|
|
2737
2984
|
...RESOURCE_ERRORS,
|
|
2738
2985
|
...POLICY_ERRORS,
|
|
2986
|
+
...ANALYTICS_ERRORS,
|
|
2987
|
+
...DEPLOY_ERRORS,
|
|
2739
2988
|
...BARE_ERRORS,
|
|
2740
|
-
...LOWERCASE_ERRORS
|
|
2989
|
+
...LOWERCASE_ERRORS,
|
|
2990
|
+
...BOUNCER_LOWERCASE_ERRORS,
|
|
2991
|
+
...OAUTH_LOWERCASE_ERRORS,
|
|
2992
|
+
...BOUNCER_UPPERCASE_ERRORS,
|
|
2993
|
+
...AUDIT_ERRORS,
|
|
2994
|
+
...AUDIT_PROTOCOL_ERRORS,
|
|
2995
|
+
...KYAOS_PROTOCOL_ERRORS
|
|
2741
2996
|
};
|
|
2742
2997
|
/**
|
|
2743
2998
|
* Error Messages
|
|
@@ -2748,6 +3003,7 @@ const ERROR_MESSAGES = {
|
|
|
2748
3003
|
[AUTH_ERRORS.INVALID_TOKEN]: "The provided token is invalid",
|
|
2749
3004
|
[AUTH_ERRORS.EXPIRED_TOKEN]: "The token has expired",
|
|
2750
3005
|
[AUTH_ERRORS.MISSING_CREDENTIALS]: "Authentication credentials are required",
|
|
3006
|
+
[AUTH_ERRORS.MANAGEMENT_TOKEN_NOT_ACCEPTED]: "Management session tokens are accepted only by /api/cli/management routes",
|
|
2751
3007
|
[AUTH_ERRORS.UNAUTHORIZED]: "You are not authorized to perform this action",
|
|
2752
3008
|
[AUTH_ERRORS.INVALID_PIXEL_ID]: "The provided pixel ID is invalid",
|
|
2753
3009
|
[AUTH_ERRORS.INVALID_SECRET_KEY]: "The provided secret key is invalid",
|
|
@@ -2779,6 +3035,7 @@ const ERROR_MESSAGES = {
|
|
|
2779
3035
|
[RATE_LIMIT_ERRORS.MONTHLY_LIMIT_EXCEEDED]: "Monthly request limit exceeded",
|
|
2780
3036
|
[RATE_LIMIT_ERRORS.CONCURRENT_LIMIT_EXCEEDED]: "Concurrent request limit exceeded",
|
|
2781
3037
|
[RATE_LIMIT_ERRORS.QUOTA_EXCEEDED]: "Account quota exceeded",
|
|
3038
|
+
[RATE_LIMIT_ERRORS.RATE_LIMITED]: "Too many requests",
|
|
2782
3039
|
[PERMISSION_ERRORS.INSUFFICIENT_PERMISSIONS]: "Insufficient permissions",
|
|
2783
3040
|
[PERMISSION_ERRORS.RESOURCE_NOT_FOUND]: "Resource not found",
|
|
2784
3041
|
[PERMISSION_ERRORS.RESOURCE_ACCESS_DENIED]: "Access to resource denied",
|
|
@@ -2786,6 +3043,7 @@ const ERROR_MESSAGES = {
|
|
|
2786
3043
|
[PERMISSION_ERRORS.PROJECT_ACCESS_DENIED]: "Project access denied",
|
|
2787
3044
|
[PERMISSION_ERRORS.PIXEL_ACCESS_DENIED]: "Pixel access denied",
|
|
2788
3045
|
[PERMISSION_ERRORS.FORBIDDEN]: "Access denied",
|
|
3046
|
+
[PERMISSION_ERRORS.PERMISSION_DENIED]: "Permission denied",
|
|
2789
3047
|
[NETWORK_ERRORS.CONNECTION_FAILED]: "Connection failed",
|
|
2790
3048
|
[NETWORK_ERRORS.TIMEOUT]: "Request timeout",
|
|
2791
3049
|
[NETWORK_ERRORS.DNS_RESOLUTION_FAILED]: "DNS resolution failed",
|
|
@@ -2800,6 +3058,9 @@ const ERROR_MESSAGES = {
|
|
|
2800
3058
|
[INTERNAL_ERRORS.PROCESSING_ERROR]: "Processing error",
|
|
2801
3059
|
[INTERNAL_ERRORS.UNKNOWN_ERROR]: "An unknown error occurred",
|
|
2802
3060
|
[INTERNAL_ERRORS.SERVICE_UNAVAILABLE_TRANSIENT]: "A dependency is temporarily unavailable. Retry shortly.",
|
|
3061
|
+
[INTERNAL_ERRORS.TRANSACTION_FAILED]: "The deletion failed because of a database error. Nothing was deleted.",
|
|
3062
|
+
[INTERNAL_ERRORS.DELETE_FAILED]: "Failed to delete project",
|
|
3063
|
+
[INTERNAL_ERRORS.PARTITION_RETIREMENT_IN_PROGRESS]: "The project data is being archived. Retry shortly.",
|
|
2803
3064
|
[SESSION_ERRORS.SESSION_NOT_FOUND]: "Session not found",
|
|
2804
3065
|
[SESSION_ERRORS.SESSION_EXPIRED]: "Session has expired",
|
|
2805
3066
|
[SESSION_ERRORS.SESSION_INVALID]: "Session is invalid",
|
|
@@ -2816,6 +3077,7 @@ const ERROR_MESSAGES = {
|
|
|
2816
3077
|
[PIXEL_ERRORS.PIXEL_BATCH_TOO_LARGE]: "Event batch exceeds maximum size",
|
|
2817
3078
|
[PIXEL_ERRORS.MISSING_PIXEL_ID]: "Project ID is required",
|
|
2818
3079
|
[PIXEL_ERRORS.DETECTION_STORAGE_FAILED]: "Failed to store detection data",
|
|
3080
|
+
[PIXEL_ERRORS.PIXEL_CREATION_FAILED]: "Failed to create pixel for project",
|
|
2819
3081
|
[API_ERRORS.ENDPOINT_NOT_FOUND]: "API endpoint not found",
|
|
2820
3082
|
[API_ERRORS.METHOD_NOT_ALLOWED]: "HTTP method not allowed",
|
|
2821
3083
|
[API_ERRORS.VERSION_NOT_SUPPORTED]: "API version not supported",
|
|
@@ -2829,10 +3091,119 @@ const ERROR_MESSAGES = {
|
|
|
2829
3091
|
[RESOURCE_ERRORS.PROJECT_NOT_FOUND]: "Project not found",
|
|
2830
3092
|
[RESOURCE_ERRORS.REVIEW_REQUIRED]: "Deploy requires explicit confirmation of the consequential writes it will perform.",
|
|
2831
3093
|
[POLICY_ERRORS.POLICY_FETCH_FAILED]: "Failed to fetch policy",
|
|
3094
|
+
[ANALYTICS_ERRORS.INVALID_PERIOD]: "Period must be one of: hour, day, week, month",
|
|
3095
|
+
[ANALYTICS_ERRORS.ANALYTICS_FETCH_ERROR]: "Failed to retrieve analytics data",
|
|
3096
|
+
[ANALYTICS_ERRORS.STATS_FETCH_ERROR]: "Failed to retrieve stats",
|
|
3097
|
+
[DEPLOY_ERRORS.MISSING_USER_IDENTIFIER]: "Either userEmail or userGithubId is required to identify the user",
|
|
3098
|
+
[DEPLOY_ERRORS.USER_NOT_FOUND]: "User not found in Checkpoint. The user must have an existing Checkpoint account to deploy.",
|
|
3099
|
+
[DEPLOY_ERRORS.NO_ORGANIZATION]: "User has no organization in Checkpoint. Please complete onboarding first at https://kya.vouched.id",
|
|
3100
|
+
[DEPLOY_ERRORS.DEPLOY_FAILED]: "Deployment failed",
|
|
3101
|
+
[DEPLOY_ERRORS.WFP_NOT_CONFIGURED]: "Managed hosting is not configured",
|
|
3102
|
+
[DEPLOY_ERRORS.NATIVE_ISSUER_PROVISIONING_BUSY]: "Native issuer provisioning is busy or temporarily unavailable; retry deployment",
|
|
3103
|
+
[DEPLOY_ERRORS.NATIVE_ISSUER_PROVISIONING_FAILED]: "Native issuer provisioning failed; deployment retained for retry",
|
|
2832
3104
|
[BARE_ERRORS.BARE_VALIDATION_ERROR]: "Invalid request data",
|
|
2833
3105
|
[BARE_ERRORS.BARE_INTERNAL_ERROR]: "Internal server error",
|
|
3106
|
+
[BARE_ERRORS.BARE_INVALID_REQUEST]: "Invalid JSON body",
|
|
3107
|
+
[BARE_ERRORS.BARE_INVALID_JSON]: "Request body must be valid JSON",
|
|
3108
|
+
[BARE_ERRORS.BARE_INVALID_START_DATE]: "Invalid startDate format. Use ISO 8601 format (YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss.sssZ)",
|
|
3109
|
+
[BARE_ERRORS.BARE_INVALID_END_DATE]: "Invalid endDate format. Use ISO 8601 format (YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss.sssZ)",
|
|
3110
|
+
[BARE_ERRORS.BARE_INVALID_DATE_RANGE]: "startDate must be before endDate",
|
|
3111
|
+
[BARE_ERRORS.BARE_INVALID_DATE]: "Invalid date format. Use ISO 8601 format (YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss.sssZ)",
|
|
3112
|
+
[BARE_ERRORS.BARE_UNKNOWN_ERROR]: "Failed to delete project",
|
|
2834
3113
|
[LOWERCASE_ERRORS.LOWERCASE_INVALID_JSON]: "Request body must be valid JSON",
|
|
2835
|
-
[LOWERCASE_ERRORS.LOWERCASE_VALIDATION_ERROR]: "Invalid request body"
|
|
3114
|
+
[LOWERCASE_ERRORS.LOWERCASE_VALIDATION_ERROR]: "Invalid request body",
|
|
3115
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_NO_PROJECT]: "API key is not associated with a project",
|
|
3116
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_MISSING_AGENT_DID]: "agent_did query parameter is required",
|
|
3117
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_NOT_CONFIGURED]: "Bouncer is not configured for this project",
|
|
3118
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_INVALID_CREDENTIAL_CONFIG]: "Credential provider missing required fields: authEndpoint and responseFields",
|
|
3119
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_PROJECT_NOT_FOUND]: "Project not found",
|
|
3120
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_PROJECT_MISMATCH]: "API key does not have access to this project",
|
|
3121
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_MISSING_DELEGATION_ID]: "Delegation ID is required",
|
|
3122
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_INVALID_TOKEN]: "Invalid or expired delegation token",
|
|
3123
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_DELEGATION_MISMATCH]: "Delegation ID does not match token",
|
|
3124
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_TOKENS_NOT_FOUND]: "OAuth tokens not available for this delegation",
|
|
3125
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_DECRYPTION_ERROR]: "Failed to decrypt OAuth tokens",
|
|
3126
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_NO_PROOFS]: "At least one proof is required",
|
|
3127
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_BATCH_TOO_LARGE]: "Maximum batch size is 100 proofs",
|
|
3128
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_NO_PROOFS_PROCESSED]: "No proofs were processed. This indicates a server error.",
|
|
3129
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_ALL_PROOFS_REJECTED]: "All proofs were rejected due to validation failures",
|
|
3130
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_UNAUTHORIZED]: "API key is not associated with a project",
|
|
3131
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_FORBIDDEN]: "API key does not have access to this project",
|
|
3132
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_NOT_FOUND]: "Session not found",
|
|
3133
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_CONFIG_NOT_FOUND]: "Bouncer config not found for project",
|
|
3134
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_AGENT_DENIED]: "Agent is on the deny list",
|
|
3135
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_DELEGATION_NOT_FOUND]: "Delegation not found",
|
|
3136
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_SESSION_NOT_FOUND]: "Session not found",
|
|
3137
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_PROOF_VALIDATION_ERROR]: "Proof validation failed",
|
|
3138
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_INSUFFICIENT_SCOPES]: "Missing required scopes",
|
|
3139
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_DELEGATION_VALIDATION_ERROR]: "Delegation validation failed",
|
|
3140
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_INVALID_HTTP_REGISTRATION]: "Invalid or unsupported native HTTP registration",
|
|
3141
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_AUTHORIZATION_HOST_UNAVAILABLE]: "Authorization host is a project deployment that cannot currently serve consent",
|
|
3142
|
+
[OAUTH_LOWERCASE_ERRORS.LOWERCASE_INVALID_REQUEST]: "Invalid request body",
|
|
3143
|
+
[OAUTH_LOWERCASE_ERRORS.LOWERCASE_UNSUPPORTED_GRANT_TYPE]: "Only authorization_code grant type is supported",
|
|
3144
|
+
[OAUTH_LOWERCASE_ERRORS.LOWERCASE_INVALID_GRANT]: "Invalid or expired authorization code",
|
|
3145
|
+
[OAUTH_LOWERCASE_ERRORS.LOWERCASE_INVALID_DELEGATION]: "Delegation not found or inactive",
|
|
3146
|
+
[OAUTH_LOWERCASE_ERRORS.LOWERCASE_INTERNAL_ERROR]: "An internal error occurred during token exchange",
|
|
3147
|
+
[OAUTH_LOWERCASE_ERRORS.LOWERCASE_INVALID_STATE]: "Restart authorization from the requesting agent.",
|
|
3148
|
+
[OAUTH_LOWERCASE_ERRORS.LOWERCASE_INVALID_TRANSACTION]: "Restart authorization from the requesting agent.",
|
|
3149
|
+
[OAUTH_LOWERCASE_ERRORS.LOWERCASE_OAUTH_UNAVAILABLE]: "OAuth is temporarily unavailable. Please request a new authorization link.",
|
|
3150
|
+
[OAUTH_LOWERCASE_ERRORS.LOWERCASE_OAUTH_NOT_CONFIGURED]: "OAuth provider is not configured. Please configure OAuth in the dashboard.",
|
|
3151
|
+
[OAUTH_LOWERCASE_ERRORS.LOWERCASE_OAUTH_CONFIGURATION_UNSUPPORTED]: "The selected provider is not configured for the platform delegation callback.",
|
|
3152
|
+
[OAUTH_LOWERCASE_ERRORS.LOWERCASE_INVALID_PROVIDER_CONFIG]: "OAuth provider is missing authorization endpoint",
|
|
3153
|
+
[OAUTH_LOWERCASE_ERRORS.LOWERCASE_RATE_LIMIT_EXCEEDED]: "Too many requests. Please try again later.",
|
|
3154
|
+
[BOUNCER_UPPERCASE_ERRORS.INVALID_REQUEST_BODY]: "Invalid JSON in request body",
|
|
3155
|
+
[BOUNCER_UPPERCASE_ERRORS.MCPI_CONFIG_NOT_FOUND]: "KYA-OS configuration not found",
|
|
3156
|
+
[BOUNCER_UPPERCASE_ERRORS.CONSENT_CONFIG_NOT_FOUND]: "Consent configuration not found for this project",
|
|
3157
|
+
[BOUNCER_UPPERCASE_ERRORS.PROJECT_LOOKUP_FAILED]: "Failed to lookup project",
|
|
3158
|
+
[BOUNCER_UPPERCASE_ERRORS.CONFIG_VALIDATION_ERROR]: "Configuration validation failed",
|
|
3159
|
+
[BOUNCER_UPPERCASE_ERRORS.CONFIG_FETCH_FAILED]: "Failed to fetch configuration",
|
|
3160
|
+
[BOUNCER_UPPERCASE_ERRORS.CONFIG_UPDATE_FAILED]: "Failed to update configuration",
|
|
3161
|
+
[BOUNCER_UPPERCASE_ERRORS.DEPLOYMENT_NOT_FOUND]: "No active deployment for this project",
|
|
3162
|
+
[BOUNCER_UPPERCASE_ERRORS.INVALID_REQUEST_ID]: "Invalid delegation request ID format",
|
|
3163
|
+
[BOUNCER_UPPERCASE_ERRORS.DELEGATION_REQUEST_NOT_FOUND]: "No delegation request exists for this ID. It may have expired, or it was never issued.",
|
|
3164
|
+
[AUDIT_ERRORS.AUDIT_CREDENTIAL_REQUIRED]: "A source-bound audit ingest credential is required",
|
|
3165
|
+
[AUDIT_ERRORS.AUDIT_REQUEST_TOO_LARGE]: "Audit submission exceeds 6291456 bytes",
|
|
3166
|
+
[AUDIT_ERRORS.AUDIT_INVALID_JSON]: "Request body must be valid JSON",
|
|
3167
|
+
[AUDIT_ERRORS.AUDIT_INVALID_CREDENTIAL]: "Invalid audit ingest credential",
|
|
3168
|
+
[AUDIT_ERRORS.AUDIT_RATE_LIMITED]: "Audit ingest rate limit exceeded",
|
|
3169
|
+
[AUDIT_ERRORS.AUDIT_INVALID_SUBMISSION]: "Invalid audit recorder submission envelope",
|
|
3170
|
+
[AUDIT_ERRORS.AUDIT_INTERNAL_ERROR]: "Audit recorder is temporarily unavailable",
|
|
3171
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_UNAUTHORIZED_SUBMISSION]: "Audit producer is not authorized for this ledger",
|
|
3172
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_LEDGER_MISMATCH]: "Submission belongs to a different audit ledger than the credential binding",
|
|
3173
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_EPOCH_MISMATCH]: "Submission belongs to a different ledger epoch",
|
|
3174
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_EVENT_ID_CONFLICT]: "Producer event identity was reused with different content",
|
|
3175
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_INVALID_EVENT]: "Audit event failed protocol validation",
|
|
3176
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_EVIDENCE_FAILURE]: "Submitted evidence could not be matched or persisted",
|
|
3177
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_EVIDENCE_INTEGRITY]: "Evidence ciphertext or metadata digest does not verify",
|
|
3178
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_INVALID_CONFIGURATION]: "Audit recorder is temporarily unavailable",
|
|
3179
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_JOURNAL_FAILURE]: "Audit recorder is temporarily unavailable",
|
|
3180
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_APPEND_CONFLICT_EXHAUSTED]: "Audit recorder is temporarily unavailable",
|
|
3181
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_EVIDENCE_LEGAL_HOLD]: "Audit recorder is temporarily unavailable",
|
|
3182
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_EVIDENCE_ACCESS_DENIED]: "Audit recorder is temporarily unavailable",
|
|
3183
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_CHECKPOINT_INVALID]: "Audit recorder is temporarily unavailable",
|
|
3184
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_CHECKPOINT_ROLLBACK]: "Audit recorder is temporarily unavailable",
|
|
3185
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_CHECKPOINT_CONFLICT]: "Audit recorder is temporarily unavailable",
|
|
3186
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_CHECKPOINT_PUBLICATION_FAILED]: "Audit recorder is temporarily unavailable",
|
|
3187
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_PROJECTION_CONFLICT]: "Audit recorder is temporarily unavailable",
|
|
3188
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_MIRROR_VERIFICATION_FAILED]: "Audit recorder is temporarily unavailable",
|
|
3189
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_MIRROR_CONTINUITY_FAILED]: "Audit recorder is temporarily unavailable",
|
|
3190
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_MIRROR_OUT_OF_ORDER]: "Audit recorder is temporarily unavailable",
|
|
3191
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_ISSUER_FORBIDDEN]: "The caller is not an authorized native issuer for this project",
|
|
3192
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_PROFILE_VIOLATION]: "The request does not conform to the KYA-OS native HTTP profile",
|
|
3193
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_INVALID_SESSION]: "The session is unknown, expired, or not owned by this project",
|
|
3194
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_SESSION_CONFLICT]: "The session is already bound to a different registration or grant",
|
|
3195
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_PICKUP_EXPIRED]: "The pickup anchor has expired",
|
|
3196
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_SCOPE_INSUFFICIENT]: "The requested scopes exceed what the session allows",
|
|
3197
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_CONSENT_REQUIRED]: "Consent terms must be accepted before a delegation can be issued",
|
|
3198
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_PICKUP_PINNED]: "The pickup anchor is pinned to a different holder key",
|
|
3199
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_AUTHORIZATION_HOST_UNAVAILABLE]: "The authorization host cannot currently serve this request",
|
|
3200
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_CHAIN_BROKEN]: "The propagation chain could not be verified",
|
|
3201
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_DELEGATION_REVOKED]: "The delegation has been revoked",
|
|
3202
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_EXPIRED]: "The credential or proof has expired",
|
|
3203
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_HOLDER_MISMATCH]: "The holder does not match the delegation or grant",
|
|
3204
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_INVALID_SIGNATURE]: "The signature could not be verified",
|
|
3205
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_SESSION_MISMATCH]: "The session does not match the delegation or proof",
|
|
3206
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_POLICY_UNAVAILABLE]: "The policy revision is currently unavailable"
|
|
2836
3207
|
};
|
|
2837
3208
|
/**
|
|
2838
3209
|
* HTTP Status Codes for Errors
|
|
@@ -2848,43 +3219,153 @@ const ERROR_STATUS_CODES = {
|
|
|
2848
3219
|
[VALIDATION_ERRORS.INVALID_END_DATE]: 400,
|
|
2849
3220
|
[VALIDATION_ERRORS.INVALID_DATE_RANGE]: 400,
|
|
2850
3221
|
[PIXEL_ERRORS.MISSING_PIXEL_ID]: 400,
|
|
3222
|
+
[ANALYTICS_ERRORS.INVALID_PERIOD]: 400,
|
|
3223
|
+
[DEPLOY_ERRORS.MISSING_USER_IDENTIFIER]: 400,
|
|
3224
|
+
[DEPLOY_ERRORS.NO_ORGANIZATION]: 400,
|
|
2851
3225
|
[BARE_ERRORS.BARE_VALIDATION_ERROR]: 400,
|
|
3226
|
+
[BARE_ERRORS.BARE_INVALID_REQUEST]: 400,
|
|
3227
|
+
[BARE_ERRORS.BARE_INVALID_JSON]: 400,
|
|
3228
|
+
[BARE_ERRORS.BARE_INVALID_START_DATE]: 400,
|
|
3229
|
+
[BARE_ERRORS.BARE_INVALID_END_DATE]: 400,
|
|
3230
|
+
[BARE_ERRORS.BARE_INVALID_DATE_RANGE]: 400,
|
|
3231
|
+
[BARE_ERRORS.BARE_INVALID_DATE]: 400,
|
|
2852
3232
|
[LOWERCASE_ERRORS.LOWERCASE_INVALID_JSON]: 400,
|
|
2853
3233
|
[LOWERCASE_ERRORS.LOWERCASE_VALIDATION_ERROR]: 400,
|
|
3234
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_NO_PROJECT]: 400,
|
|
3235
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_MISSING_AGENT_DID]: 400,
|
|
3236
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_NOT_CONFIGURED]: 400,
|
|
3237
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_INVALID_CREDENTIAL_CONFIG]: 400,
|
|
3238
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_MISSING_DELEGATION_ID]: 400,
|
|
3239
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_NO_PROOFS]: 400,
|
|
3240
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_BATCH_TOO_LARGE]: 400,
|
|
3241
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_NO_PROOFS_PROCESSED]: 400,
|
|
3242
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_ALL_PROOFS_REJECTED]: 400,
|
|
3243
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_PROOF_VALIDATION_ERROR]: 400,
|
|
3244
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_DELEGATION_VALIDATION_ERROR]: 400,
|
|
3245
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_INVALID_HTTP_REGISTRATION]: 400,
|
|
3246
|
+
[OAUTH_LOWERCASE_ERRORS.LOWERCASE_INVALID_REQUEST]: 400,
|
|
3247
|
+
[OAUTH_LOWERCASE_ERRORS.LOWERCASE_UNSUPPORTED_GRANT_TYPE]: 400,
|
|
3248
|
+
[OAUTH_LOWERCASE_ERRORS.LOWERCASE_INVALID_STATE]: 400,
|
|
3249
|
+
[OAUTH_LOWERCASE_ERRORS.LOWERCASE_INVALID_TRANSACTION]: 400,
|
|
3250
|
+
[OAUTH_LOWERCASE_ERRORS.LOWERCASE_OAUTH_NOT_CONFIGURED]: 400,
|
|
3251
|
+
[OAUTH_LOWERCASE_ERRORS.LOWERCASE_OAUTH_CONFIGURATION_UNSUPPORTED]: 400,
|
|
3252
|
+
[OAUTH_LOWERCASE_ERRORS.LOWERCASE_INVALID_PROVIDER_CONFIG]: 400,
|
|
3253
|
+
[BOUNCER_UPPERCASE_ERRORS.INVALID_REQUEST_BODY]: 400,
|
|
3254
|
+
[BOUNCER_UPPERCASE_ERRORS.CONFIG_VALIDATION_ERROR]: 400,
|
|
3255
|
+
[BOUNCER_UPPERCASE_ERRORS.INVALID_REQUEST_ID]: 400,
|
|
3256
|
+
[AUDIT_ERRORS.AUDIT_INVALID_JSON]: 400,
|
|
3257
|
+
[AUDIT_ERRORS.AUDIT_INVALID_SUBMISSION]: 400,
|
|
2854
3258
|
[AUTH_ERRORS.INVALID_API_KEY]: 401,
|
|
2855
3259
|
[AUTH_ERRORS.EXPIRED_API_KEY]: 401,
|
|
2856
3260
|
[AUTH_ERRORS.INVALID_TOKEN]: 401,
|
|
2857
3261
|
[AUTH_ERRORS.EXPIRED_TOKEN]: 401,
|
|
2858
3262
|
[AUTH_ERRORS.MISSING_CREDENTIALS]: 401,
|
|
3263
|
+
[AUTH_ERRORS.MANAGEMENT_TOKEN_NOT_ACCEPTED]: 401,
|
|
2859
3264
|
[AUTH_ERRORS.UNAUTHORIZED]: 401,
|
|
3265
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_INVALID_TOKEN]: 401,
|
|
3266
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_UNAUTHORIZED]: 401,
|
|
3267
|
+
[AUDIT_ERRORS.AUDIT_CREDENTIAL_REQUIRED]: 401,
|
|
3268
|
+
[AUDIT_ERRORS.AUDIT_INVALID_CREDENTIAL]: 401,
|
|
2860
3269
|
[BILLING_ERRORS.LIMIT_EXCEEDED]: 402,
|
|
2861
3270
|
[BILLING_ERRORS.BILLING_SUSPENDED]: 402,
|
|
2862
3271
|
[PERMISSION_ERRORS.INSUFFICIENT_PERMISSIONS]: 403,
|
|
2863
3272
|
[PERMISSION_ERRORS.RESOURCE_ACCESS_DENIED]: 403,
|
|
2864
3273
|
[PERMISSION_ERRORS.OPERATION_NOT_ALLOWED]: 403,
|
|
2865
3274
|
[PERMISSION_ERRORS.FORBIDDEN]: 403,
|
|
3275
|
+
[PERMISSION_ERRORS.PERMISSION_DENIED]: 403,
|
|
3276
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_PROJECT_MISMATCH]: 403,
|
|
3277
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_DELEGATION_MISMATCH]: 403,
|
|
3278
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_FORBIDDEN]: 403,
|
|
3279
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_AGENT_DENIED]: 403,
|
|
3280
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_INSUFFICIENT_SCOPES]: 403,
|
|
3281
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_UNAUTHORIZED_SUBMISSION]: 403,
|
|
3282
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_ISSUER_FORBIDDEN]: 403,
|
|
3283
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_SCOPE_INSUFFICIENT]: 403,
|
|
3284
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_CONSENT_REQUIRED]: 403,
|
|
3285
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_PICKUP_PINNED]: 403,
|
|
3286
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_CHAIN_BROKEN]: 403,
|
|
3287
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_DELEGATION_REVOKED]: 403,
|
|
3288
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_HOLDER_MISMATCH]: 403,
|
|
3289
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_INVALID_SIGNATURE]: 403,
|
|
2866
3290
|
[PERMISSION_ERRORS.RESOURCE_NOT_FOUND]: 404,
|
|
2867
3291
|
[API_ERRORS.ENDPOINT_NOT_FOUND]: 404,
|
|
2868
3292
|
[PIXEL_ERRORS.PIXEL_NOT_FOUND]: 404,
|
|
2869
3293
|
[SESSION_ERRORS.SESSION_NOT_FOUND]: 404,
|
|
3294
|
+
[DEPLOY_ERRORS.USER_NOT_FOUND]: 404,
|
|
3295
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_PROJECT_NOT_FOUND]: 404,
|
|
3296
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_TOKENS_NOT_FOUND]: 404,
|
|
3297
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_NOT_FOUND]: 404,
|
|
3298
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_CONFIG_NOT_FOUND]: 404,
|
|
3299
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_DELEGATION_NOT_FOUND]: 404,
|
|
3300
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_SESSION_NOT_FOUND]: 404,
|
|
3301
|
+
[OAUTH_LOWERCASE_ERRORS.LOWERCASE_INVALID_DELEGATION]: 404,
|
|
3302
|
+
[BOUNCER_UPPERCASE_ERRORS.MCPI_CONFIG_NOT_FOUND]: 404,
|
|
3303
|
+
[BOUNCER_UPPERCASE_ERRORS.CONSENT_CONFIG_NOT_FOUND]: 404,
|
|
3304
|
+
[BOUNCER_UPPERCASE_ERRORS.DEPLOYMENT_NOT_FOUND]: 404,
|
|
3305
|
+
[BOUNCER_UPPERCASE_ERRORS.DELEGATION_REQUEST_NOT_FOUND]: 404,
|
|
3306
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_INVALID_SESSION]: 404,
|
|
2870
3307
|
[API_ERRORS.METHOD_NOT_ALLOWED]: 405,
|
|
2871
3308
|
[RESOURCE_ERRORS.CONFLICT]: 409,
|
|
3309
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_LEDGER_MISMATCH]: 409,
|
|
3310
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_EPOCH_MISMATCH]: 409,
|
|
3311
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_EVENT_ID_CONFLICT]: 409,
|
|
3312
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_SESSION_CONFLICT]: 409,
|
|
3313
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_SESSION_MISMATCH]: 409,
|
|
3314
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_PICKUP_EXPIRED]: 410,
|
|
3315
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_EXPIRED]: 410,
|
|
2872
3316
|
[API_ERRORS.REQUEST_TOO_LARGE]: 413,
|
|
2873
3317
|
[PIXEL_ERRORS.PIXEL_BATCH_TOO_LARGE]: 413,
|
|
3318
|
+
[AUDIT_ERRORS.AUDIT_REQUEST_TOO_LARGE]: 413,
|
|
2874
3319
|
[API_ERRORS.CONTENT_TYPE_NOT_SUPPORTED]: 415,
|
|
2875
3320
|
[RESOURCE_ERRORS.REVIEW_REQUIRED]: 422,
|
|
3321
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_INVALID_EVENT]: 422,
|
|
3322
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_EVIDENCE_FAILURE]: 422,
|
|
3323
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_EVIDENCE_INTEGRITY]: 422,
|
|
2876
3324
|
[RATE_LIMIT_ERRORS.RATE_LIMIT_EXCEEDED]: 429,
|
|
2877
3325
|
[RATE_LIMIT_ERRORS.BURST_LIMIT_EXCEEDED]: 429,
|
|
2878
3326
|
[RATE_LIMIT_ERRORS.DAILY_LIMIT_EXCEEDED]: 429,
|
|
3327
|
+
[RATE_LIMIT_ERRORS.RATE_LIMITED]: 429,
|
|
3328
|
+
[OAUTH_LOWERCASE_ERRORS.LOWERCASE_RATE_LIMIT_EXCEEDED]: 429,
|
|
3329
|
+
[AUDIT_ERRORS.AUDIT_RATE_LIMITED]: 429,
|
|
2879
3330
|
[INTERNAL_ERRORS.INTERNAL_SERVER_ERROR]: 500,
|
|
2880
3331
|
[INTERNAL_ERRORS.DATABASE_ERROR]: 500,
|
|
2881
3332
|
[INTERNAL_ERRORS.PROCESSING_ERROR]: 500,
|
|
3333
|
+
[INTERNAL_ERRORS.TRANSACTION_FAILED]: 500,
|
|
3334
|
+
[INTERNAL_ERRORS.DELETE_FAILED]: 500,
|
|
2882
3335
|
[PIXEL_ERRORS.DETECTION_STORAGE_FAILED]: 500,
|
|
3336
|
+
[PIXEL_ERRORS.PIXEL_CREATION_FAILED]: 500,
|
|
2883
3337
|
[POLICY_ERRORS.POLICY_FETCH_FAILED]: 500,
|
|
3338
|
+
[ANALYTICS_ERRORS.ANALYTICS_FETCH_ERROR]: 500,
|
|
3339
|
+
[ANALYTICS_ERRORS.STATS_FETCH_ERROR]: 500,
|
|
2884
3340
|
[BARE_ERRORS.BARE_INTERNAL_ERROR]: 500,
|
|
3341
|
+
[BARE_ERRORS.BARE_UNKNOWN_ERROR]: 500,
|
|
3342
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_DECRYPTION_ERROR]: 500,
|
|
3343
|
+
[OAUTH_LOWERCASE_ERRORS.LOWERCASE_INTERNAL_ERROR]: 500,
|
|
3344
|
+
[BOUNCER_UPPERCASE_ERRORS.PROJECT_LOOKUP_FAILED]: 500,
|
|
3345
|
+
[BOUNCER_UPPERCASE_ERRORS.CONFIG_FETCH_FAILED]: 500,
|
|
3346
|
+
[BOUNCER_UPPERCASE_ERRORS.CONFIG_UPDATE_FAILED]: 500,
|
|
3347
|
+
[AUDIT_ERRORS.AUDIT_INTERNAL_ERROR]: 500,
|
|
3348
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_EVIDENCE_LEGAL_HOLD]: 500,
|
|
3349
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_EVIDENCE_ACCESS_DENIED]: 500,
|
|
3350
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_CHECKPOINT_INVALID]: 500,
|
|
3351
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_CHECKPOINT_ROLLBACK]: 500,
|
|
3352
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_CHECKPOINT_CONFLICT]: 500,
|
|
3353
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_CHECKPOINT_PUBLICATION_FAILED]: 500,
|
|
3354
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_PROJECTION_CONFLICT]: 500,
|
|
3355
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_MIRROR_VERIFICATION_FAILED]: 500,
|
|
3356
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_MIRROR_CONTINUITY_FAILED]: 500,
|
|
3357
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_MIRROR_OUT_OF_ORDER]: 500,
|
|
2885
3358
|
[NETWORK_ERRORS.UPSTREAM_ERROR]: 502,
|
|
2886
3359
|
[INTERNAL_ERRORS.INITIALIZATION_ERROR]: 503,
|
|
2887
3360
|
[INTERNAL_ERRORS.SERVICE_UNAVAILABLE_TRANSIENT]: 503,
|
|
3361
|
+
[INTERNAL_ERRORS.PARTITION_RETIREMENT_IN_PROGRESS]: 503,
|
|
3362
|
+
[BOUNCER_LOWERCASE_ERRORS.LOWERCASE_AUTHORIZATION_HOST_UNAVAILABLE]: 503,
|
|
3363
|
+
[OAUTH_LOWERCASE_ERRORS.LOWERCASE_OAUTH_UNAVAILABLE]: 503,
|
|
3364
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_INVALID_CONFIGURATION]: 503,
|
|
3365
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_JOURNAL_FAILURE]: 503,
|
|
3366
|
+
[AUDIT_PROTOCOL_ERRORS.AUDIT_APPEND_CONFLICT_EXHAUSTED]: 503,
|
|
3367
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_AUTHORIZATION_HOST_UNAVAILABLE]: 503,
|
|
3368
|
+
[KYAOS_PROTOCOL_ERRORS.KYAOS_SLASH_POLICY_UNAVAILABLE]: 503,
|
|
2888
3369
|
[NETWORK_ERRORS.TIMEOUT]: 504
|
|
2889
3370
|
};
|
|
2890
3371
|
/**
|
|
@@ -3165,36 +3646,6 @@ function getRateLimitWindow(windowType) {
|
|
|
3165
3646
|
*/
|
|
3166
3647
|
const RULE_VERSION = "1.0.0";
|
|
3167
3648
|
/**
|
|
3168
|
-
* Cache configuration
|
|
3169
|
-
*/
|
|
3170
|
-
const RULE_CACHE = {
|
|
3171
|
-
/** Default cache duration in milliseconds */
|
|
3172
|
-
DEFAULT_DURATION: 36e5,
|
|
3173
|
-
/** Maximum cache duration */
|
|
3174
|
-
MAX_DURATION: 864e5,
|
|
3175
|
-
/** Minimum cache duration */
|
|
3176
|
-
MIN_DURATION: 6e4,
|
|
3177
|
-
/** LocalStorage key for cached rules */
|
|
3178
|
-
STORAGE_KEY: "agentshield_rules",
|
|
3179
|
-
/** LocalStorage key for cache timestamp */
|
|
3180
|
-
TIMESTAMP_KEY: "agentshield_rules_timestamp"
|
|
3181
|
-
};
|
|
3182
|
-
/**
|
|
3183
|
-
* CDN configuration for future use
|
|
3184
|
-
*/
|
|
3185
|
-
const RULE_CDN = {
|
|
3186
|
-
/** Primary CDN endpoint */
|
|
3187
|
-
PRIMARY_URL: "https://kya.vouched.id/rules/latest.json",
|
|
3188
|
-
/** Fallback CDN endpoint */
|
|
3189
|
-
FALLBACK_URL: "https://rules.agentshield.io/latest.json",
|
|
3190
|
-
/** CDN request timeout */
|
|
3191
|
-
TIMEOUT: 5e3,
|
|
3192
|
-
/** Retry attempts for CDN fetch */
|
|
3193
|
-
RETRY_ATTEMPTS: 3,
|
|
3194
|
-
/** Retry delay in milliseconds */
|
|
3195
|
-
RETRY_DELAY: 1e3
|
|
3196
|
-
};
|
|
3197
|
-
/**
|
|
3198
3649
|
* Rule validation modes
|
|
3199
3650
|
*/
|
|
3200
3651
|
const VALIDATION_MODES = {
|
|
@@ -3275,9 +3726,7 @@ const RULE_ERRORS = {
|
|
|
3275
3726
|
LOAD_FAILED: "Failed to load rules",
|
|
3276
3727
|
PARSE_FAILED: "Failed to parse rules",
|
|
3277
3728
|
VERSION_MISMATCH: "Rule version mismatch",
|
|
3278
|
-
MISSING_REQUIRED: "Missing required rule fields"
|
|
3279
|
-
CDN_UNAVAILABLE: "CDN rules unavailable",
|
|
3280
|
-
CACHE_EXPIRED: "Cached rules expired"
|
|
3729
|
+
MISSING_REQUIRED: "Missing required rule fields"
|
|
3281
3730
|
};
|
|
3282
3731
|
/**
|
|
3283
3732
|
* Rule file paths
|
|
@@ -3668,7 +4117,7 @@ const PixelInstallConfigSchema = object({
|
|
|
3668
4117
|
flushInterval: number$1().min(1e3).max(6e4).default(5e3),
|
|
3669
4118
|
respectDoNotTrack: boolean$1().default(true),
|
|
3670
4119
|
anonymizeIp: boolean$1().default(false),
|
|
3671
|
-
sessionTimeout: number$1().min(6e4).
|
|
4120
|
+
sessionTimeout: number$1().min(6e4).optional(),
|
|
3672
4121
|
sessionCookieName: string().default("_as_session"),
|
|
3673
4122
|
debug: boolean$1().default(false),
|
|
3674
4123
|
logLevel: _enum([
|
|
@@ -3697,6 +4146,17 @@ const ClientDetectionSchema = object({
|
|
|
3697
4146
|
webrtc: string().optional(),
|
|
3698
4147
|
plugins: number$1().optional(),
|
|
3699
4148
|
automation: string().nullable().optional(),
|
|
4149
|
+
webdriver: boolean$1().optional(),
|
|
4150
|
+
userAgentData: object({
|
|
4151
|
+
brands: array(string().max(64)).max(16),
|
|
4152
|
+
mobile: boolean$1(),
|
|
4153
|
+
platform: string().max(64),
|
|
4154
|
+
architecture: string().max(64).optional(),
|
|
4155
|
+
bitness: string().max(64).optional(),
|
|
4156
|
+
model: string().max(64).optional(),
|
|
4157
|
+
platformVersion: string().max(64).optional(),
|
|
4158
|
+
highEntropyStatus: literal("not_allowed").optional()
|
|
4159
|
+
}).optional(),
|
|
3700
4160
|
chrome: boolean$1().optional(),
|
|
3701
4161
|
languages: array(string()).optional(),
|
|
3702
4162
|
hardwareConcurrency: number$1().nullable().optional(),
|
|
@@ -3806,6 +4266,7 @@ const PixelTrackingRequestSchema = object({
|
|
|
3806
4266
|
version: string().optional(),
|
|
3807
4267
|
nonce: string().max(64).optional(),
|
|
3808
4268
|
nonceEcho: boolean$1().optional(),
|
|
4269
|
+
handoffToken: string().max(2048).optional().catch(void 0),
|
|
3809
4270
|
binding: string().max(128).optional(),
|
|
3810
4271
|
anonymizeIp: boolean$1().optional()
|
|
3811
4272
|
});
|
|
@@ -3829,7 +4290,12 @@ const PixelTrackingResponseSchema = object({
|
|
|
3829
4290
|
code: string(),
|
|
3830
4291
|
message: string()
|
|
3831
4292
|
}).optional(),
|
|
3832
|
-
nonce: string().max(64).optional()
|
|
4293
|
+
nonce: string().max(64).optional(),
|
|
4294
|
+
handoff: object({ status: _enum([
|
|
4295
|
+
"adopted",
|
|
4296
|
+
"rejected",
|
|
4297
|
+
"unavailable"
|
|
4298
|
+
]) }).optional()
|
|
3833
4299
|
});
|
|
3834
4300
|
/**
|
|
3835
4301
|
* Pixel Analytics Data
|
|
@@ -4066,42 +4532,967 @@ const EventStorageRecordSchema = object({
|
|
|
4066
4532
|
});
|
|
4067
4533
|
|
|
4068
4534
|
//#endregion
|
|
4069
|
-
//#region src/api/
|
|
4535
|
+
//#region src/api/readable-text.ts
|
|
4536
|
+
/**
|
|
4537
|
+
* Text read back in terminals and the dashboard. It may be in any language, but it holds no
|
|
4538
|
+
* control characters (terminal escapes and line breaks among them) and no bidirectional
|
|
4539
|
+
* formatting characters, which could make it display as other text. The CLI refuses text that
|
|
4540
|
+
* breaks this rule, so Checkpoint never produces any.
|
|
4541
|
+
*/
|
|
4542
|
+
const READABLE_TEXT = /^[^\p{Cc}\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]*$/u;
|
|
4543
|
+
const READABLE_TEXT_MESSAGE = "No control or bidirectional formatting characters";
|
|
4544
|
+
const UNREADABLE = /[\p{Cc}\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/gu;
|
|
4545
|
+
/** The same text with each character `READABLE_TEXT` refuses shown as U+FFFD. */
|
|
4546
|
+
function readableText(value) {
|
|
4547
|
+
return value.replace(UNREADABLE, "�");
|
|
4548
|
+
}
|
|
4549
|
+
|
|
4550
|
+
//#endregion
|
|
4551
|
+
//#region src/api/model-credentials.ts
|
|
4070
4552
|
/**
|
|
4071
|
-
*
|
|
4553
|
+
* C12: model provider keys an organization owns. An owner or admin stores the organization's own
|
|
4554
|
+
* key through the C3 management session; Checkpoint validates it with a free provider call,
|
|
4555
|
+
* encrypts it, and never returns it. An installation's model policy names the credential it
|
|
4556
|
+
* uses, so a model call is paid by the tenant whose key it names. There is no platform key,
|
|
4557
|
+
* switch or project allowlist.
|
|
4072
4558
|
*
|
|
4073
|
-
*
|
|
4074
|
-
|
|
4559
|
+
* Adding and rotating are idempotent by `operationId`: the same operation with the same key
|
|
4560
|
+
* returns the recorded result (`duplicate: true`), and with another key it is refused
|
|
4561
|
+
* (`OPERATION_CONFLICT`). A client journals the operation with the key's fingerprint, never the
|
|
4562
|
+
* key.
|
|
4563
|
+
*/
|
|
4564
|
+
const Timestamp$3 = string().datetime();
|
|
4565
|
+
const Uuid$1 = string().uuid();
|
|
4566
|
+
/** The providers a model credential can be for. */
|
|
4567
|
+
const ModelCredentialProviderSchema = literal("anthropic");
|
|
4568
|
+
/**
|
|
4569
|
+
* `sha256:` and the first 16 lowercase hex characters of SHA-256 over the key's UTF-8 bytes.
|
|
4570
|
+
* It identifies a key in receipts and listings without revealing it; a client computes the same
|
|
4571
|
+
* value locally with `modelCredentialFingerprint`.
|
|
4572
|
+
*/
|
|
4573
|
+
const ModelCredentialFingerprintSchema = string().regex(/^sha256:[a-f0-9]{16}$/);
|
|
4574
|
+
function modelCredentialFingerprint(key) {
|
|
4575
|
+
return `sha256:${bytesToHex(sha256(new TextEncoder().encode(key))).slice(0, 16)}`;
|
|
4576
|
+
}
|
|
4577
|
+
/** A person's name for a credential: printable ASCII, no space at either end. */
|
|
4578
|
+
const ModelCredentialLabelSchema = string().min(1).max(100).regex(/^[\x21-\x7E]([\x20-\x7E]*[\x21-\x7E])?$/);
|
|
4579
|
+
/** A revocation reason is free text read back in terminals and the dashboard: readable text. */
|
|
4580
|
+
const RevocationReasonSchema = string().min(1).max(500).regex(READABLE_TEXT, READABLE_TEXT_MESSAGE);
|
|
4581
|
+
/** The secret itself, only ever in an add or rotate request body. Its shape is the provider's. */
|
|
4582
|
+
const ModelApiKey = string().min(20).max(512).regex(/^[\x21-\x7E]+$/);
|
|
4583
|
+
/** `kya.model-credential.v1`: metadata only. The key never appears in any response. */
|
|
4584
|
+
const ModelCredentialSchema = object({
|
|
4585
|
+
schema: literal("kya.model-credential.v1"),
|
|
4586
|
+
credentialId: Uuid$1,
|
|
4587
|
+
organizationId: Uuid$1,
|
|
4588
|
+
provider: ModelCredentialProviderSchema,
|
|
4589
|
+
label: ModelCredentialLabelSchema,
|
|
4590
|
+
/** The current key's fingerprint; a rotation replaces it and increments `version`. */
|
|
4591
|
+
fingerprint: ModelCredentialFingerprintSchema,
|
|
4592
|
+
version: number$1().int().positive().max(2147483647),
|
|
4593
|
+
status: _enum(["active", "revoked"]),
|
|
4594
|
+
/** When the provider last accepted this key. */
|
|
4595
|
+
validatedAt: Timestamp$3,
|
|
4596
|
+
createdByUserId: Uuid$1,
|
|
4597
|
+
createdAt: Timestamp$3,
|
|
4598
|
+
rotatedAt: Timestamp$3.nullable(),
|
|
4599
|
+
/** Who made the latest rotation; set exactly when `rotatedAt` is. */
|
|
4600
|
+
rotatedByUserId: Uuid$1.nullable(),
|
|
4601
|
+
revokedAt: Timestamp$3.nullable(),
|
|
4602
|
+
revokedByUserId: Uuid$1.nullable(),
|
|
4603
|
+
revocationReason: RevocationReasonSchema.nullable()
|
|
4604
|
+
}).strict().refine((value) => {
|
|
4605
|
+
const recorded = [
|
|
4606
|
+
value.revokedAt,
|
|
4607
|
+
value.revokedByUserId,
|
|
4608
|
+
value.revocationReason
|
|
4609
|
+
].map((field) => field !== null);
|
|
4610
|
+
return value.status === "revoked" ? recorded.every(Boolean) : recorded.every((isSet) => !isSet);
|
|
4611
|
+
}, "A revoked credential records when, by whom and why; an active one records none of them").refine((value) => value.rotatedAt === null === (value.rotatedByUserId === null), "A rotation records when and by whom; an unrotated credential records neither");
|
|
4612
|
+
/** `POST /api/cli/management/projects/{id}/model-credentials`, stored on the project's organization. */
|
|
4613
|
+
const AddModelCredentialSchema = object({
|
|
4614
|
+
operationId: Uuid$1,
|
|
4615
|
+
provider: ModelCredentialProviderSchema,
|
|
4616
|
+
label: ModelCredentialLabelSchema,
|
|
4617
|
+
key: ModelApiKey
|
|
4618
|
+
}).strict();
|
|
4619
|
+
/** `POST …/model-credentials/{credentialId}/rotate`: a new key for the same credential. */
|
|
4620
|
+
const RotateModelCredentialSchema = object({
|
|
4621
|
+
operationId: Uuid$1,
|
|
4622
|
+
key: ModelApiKey
|
|
4623
|
+
}).strict();
|
|
4624
|
+
/** `POST …/model-credentials/{credentialId}/revoke`. Revoking again returns the first revocation. */
|
|
4625
|
+
const RevokeModelCredentialSchema = object({ reason: string().trim().pipe(RevocationReasonSchema) }).strict();
|
|
4626
|
+
/** An add or rotate: the credential after it, and whether this operation had already run. */
|
|
4627
|
+
const ModelCredentialResultSchema = object({
|
|
4628
|
+
operationId: Uuid$1,
|
|
4629
|
+
credential: ModelCredentialSchema,
|
|
4630
|
+
duplicate: boolean$1()
|
|
4631
|
+
}).strict();
|
|
4632
|
+
const ModelCredentialRevocationSchema = object({
|
|
4633
|
+
credential: ModelCredentialSchema,
|
|
4634
|
+
wasAlreadyRevoked: boolean$1()
|
|
4635
|
+
}).strict().refine((value) => value.credential.status === "revoked", "A revocation returns a revoked credential");
|
|
4636
|
+
/** `GET …/model-credentials`: the organization's credentials, newest first. */
|
|
4637
|
+
const ModelCredentialListSchema = object({
|
|
4638
|
+
organizationId: Uuid$1,
|
|
4639
|
+
credentials: array(ModelCredentialSchema).max(100)
|
|
4640
|
+
}).strict();
|
|
4075
4641
|
/**
|
|
4076
|
-
*
|
|
4642
|
+
* Definite refusals of these routes and of a model call, all 4xx: nothing was stored, and a model
|
|
4643
|
+
* call refused for its credential never reached the provider.
|
|
4077
4644
|
*/
|
|
4078
|
-
const
|
|
4079
|
-
"
|
|
4080
|
-
"
|
|
4081
|
-
"
|
|
4082
|
-
"
|
|
4083
|
-
"
|
|
4084
|
-
"
|
|
4085
|
-
"HS256",
|
|
4086
|
-
"HS384",
|
|
4087
|
-
"HS512"
|
|
4645
|
+
const ModelCredentialRefusalCodeSchema = _enum([
|
|
4646
|
+
"OPERATION_CONFLICT",
|
|
4647
|
+
"CREDENTIAL_NOT_FOUND",
|
|
4648
|
+
"CREDENTIAL_REVOKED",
|
|
4649
|
+
"MODEL_KEY_REJECTED",
|
|
4650
|
+
"MODEL_KEY_UNVERIFIED",
|
|
4651
|
+
"MODEL_CREDENTIAL_UNAVAILABLE"
|
|
4088
4652
|
]);
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4653
|
+
|
|
4654
|
+
//#endregion
|
|
4655
|
+
//#region src/api/task-a2a.ts
|
|
4656
|
+
/** Application admission profile for the A2A 1.0 JSON-RPC binding. This is not a
|
|
4657
|
+
* replacement for the normative upstream proto or a complete A2A SDK schema. */
|
|
4658
|
+
const KYA_A2A_EXTENSION = "https://kya-os.ai/a2a/task-source/v1";
|
|
4659
|
+
const Id$2 = string().min(1).max(255);
|
|
4660
|
+
const Tenant = string().regex(/^[0-9a-f-]{36}:[1-9][0-9]{0,9}$/);
|
|
4661
|
+
const A2ARpcEnvelopeSchema = object({
|
|
4662
|
+
jsonrpc: literal("2.0"),
|
|
4663
|
+
id: union([Id$2, number$1().int().safe()]),
|
|
4664
|
+
method: Id$2,
|
|
4665
|
+
params: unknown()
|
|
4666
|
+
}).strict();
|
|
4667
|
+
const Send = object({
|
|
4668
|
+
tenant: Tenant,
|
|
4669
|
+
message: object({
|
|
4670
|
+
messageId: Id$2,
|
|
4671
|
+
role: literal("ROLE_USER"),
|
|
4672
|
+
parts: array(object({
|
|
4673
|
+
text: string().min(1).max(7e3),
|
|
4674
|
+
mediaType: literal("text/plain").optional()
|
|
4675
|
+
}).strict()).min(1).max(32),
|
|
4676
|
+
taskId: string().uuid().optional(),
|
|
4677
|
+
contextId: string().uuid().optional()
|
|
4678
|
+
}).strict(),
|
|
4679
|
+
configuration: object({
|
|
4680
|
+
returnImmediately: literal(true),
|
|
4681
|
+
historyLength: number$1().int().min(0).max(1e3).optional(),
|
|
4682
|
+
acceptedOutputModes: array(_enum(["application/json", "text/plain"])).min(1).max(2).optional()
|
|
4683
|
+
}).strict()
|
|
4684
|
+
}).strict();
|
|
4685
|
+
const Get = object({
|
|
4686
|
+
tenant: Tenant,
|
|
4687
|
+
id: string().uuid(),
|
|
4688
|
+
historyLength: number$1().int().min(0).max(1e3).optional()
|
|
4689
|
+
}).strict();
|
|
4690
|
+
const Cancel = object({
|
|
4691
|
+
tenant: Tenant,
|
|
4692
|
+
id: string().uuid()
|
|
4693
|
+
}).strict();
|
|
4694
|
+
const A2ATaskRequestSchema = discriminatedUnion("method", [
|
|
4695
|
+
object({
|
|
4696
|
+
method: literal("SendMessage"),
|
|
4697
|
+
params: Send
|
|
4698
|
+
}).strict(),
|
|
4699
|
+
object({
|
|
4700
|
+
method: literal("GetTask"),
|
|
4701
|
+
params: Get
|
|
4702
|
+
}).strict(),
|
|
4703
|
+
object({
|
|
4704
|
+
method: literal("CancelTask"),
|
|
4705
|
+
params: Cancel
|
|
4706
|
+
}).strict()
|
|
4707
|
+
]);
|
|
4708
|
+
/** Canonical standard base64 with padding: the unused bits of the last symbol are zero, so a
|
|
4709
|
+
* value decodes to exactly one byte string and re-encodes to itself. */
|
|
4710
|
+
const StandardBase64 = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/][AQgw]==|[A-Za-z0-9+/]{2}[AEIMQUYcgkosw048]=)?$/;
|
|
4711
|
+
const base64ByteLength = (value) => value.length / 4 * 3 - (value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0);
|
|
4712
|
+
const HttpsUrl = string().max(2048).refine((value) => {
|
|
4713
|
+
try {
|
|
4714
|
+
return new URL(value).protocol === "https:";
|
|
4715
|
+
} catch {
|
|
4716
|
+
return false;
|
|
4717
|
+
}
|
|
4718
|
+
}, "targetUri must be an https URL");
|
|
4719
|
+
/**
|
|
4720
|
+
* B09-P3 `kya.a2a.signed-request.v1`: the exact RFC 9421 request Checkpoint verified for one A2A
|
|
4721
|
+
* delivery, so a receiving workbench can verify the sender's signature without trusting Checkpoint.
|
|
4722
|
+
* Every header member is the exact string received; `targetUri` is the exact target verified;
|
|
4723
|
+
* `body` is the standard base64 of the exact request body bytes (at most the 8 KiB A2A limit).
|
|
4724
|
+
* The kya-http/2 signature covers, joined by "\n" with no trailing newline:
|
|
4725
|
+
* `"@method": POST`, `"@authority": <host[:port] of targetUri>`, `"@target-uri": <targetUri>`,
|
|
4726
|
+
* `"content-digest": <contentDigest>`, `"content-type": <contentType>` and
|
|
4727
|
+
* `"@signature-params": <signatureInput without its leading "kya=">`.
|
|
4728
|
+
*/
|
|
4729
|
+
const A2ASignedRequestSchema = object({
|
|
4730
|
+
schema: literal("kya.a2a.signed-request.v1"),
|
|
4731
|
+
method: literal("POST"),
|
|
4732
|
+
targetUri: HttpsUrl,
|
|
4733
|
+
contentType: string().max(255),
|
|
4734
|
+
contentDigest: string().regex(/^sha-256=:[A-Za-z0-9+/]{43}=:$/),
|
|
4735
|
+
signatureInput: string().max(1024),
|
|
4736
|
+
signature: string().regex(/^kya=:[A-Za-z0-9+/]{86}==:$/),
|
|
4737
|
+
body: string().max(10924).regex(StandardBase64, "body must be standard base64 with padding").refine((value) => {
|
|
4738
|
+
const bytes = base64ByteLength(value);
|
|
4739
|
+
return bytes >= 1 && bytes <= 8192;
|
|
4740
|
+
}, "body must decode to 1..8192 bytes")
|
|
4741
|
+
}).strict();
|
|
4742
|
+
const A2ATaskStateSchema = _enum([
|
|
4743
|
+
"TASK_STATE_UNSPECIFIED",
|
|
4744
|
+
"TASK_STATE_SUBMITTED",
|
|
4745
|
+
"TASK_STATE_WORKING",
|
|
4746
|
+
"TASK_STATE_COMPLETED",
|
|
4747
|
+
"TASK_STATE_FAILED",
|
|
4748
|
+
"TASK_STATE_CANCELED",
|
|
4749
|
+
"TASK_STATE_INPUT_REQUIRED",
|
|
4750
|
+
"TASK_STATE_REJECTED"
|
|
4751
|
+
]);
|
|
4752
|
+
/** Out-of-band discovery profile returned to the installation administrator.
|
|
4753
|
+
* RFC 9421 holder signatures require the extension; they are not bearer auth. */
|
|
4754
|
+
function createKyaA2AAgentCard(endpoint, tenant) {
|
|
4755
|
+
const url = new URL(endpoint);
|
|
4756
|
+
if (url.protocol !== "https:" || url.username || url.password || url.search || url.hash) throw new Error("A2A endpoint must be an exact HTTPS target");
|
|
4757
|
+
Tenant.parse(tenant);
|
|
4758
|
+
return {
|
|
4759
|
+
name: "KYA accountable task intake",
|
|
4760
|
+
description: "Queue bounded work, send steering and request cancellation. Execution requires separately admitted authority. This text-only asynchronous profile requires the KYA extension.",
|
|
4761
|
+
version: "1.0.0",
|
|
4762
|
+
supportedInterfaces: [{
|
|
4763
|
+
url: endpoint,
|
|
4764
|
+
protocolBinding: "JSONRPC",
|
|
4765
|
+
protocolVersion: "1.0",
|
|
4766
|
+
tenant
|
|
4767
|
+
}],
|
|
4768
|
+
capabilities: {
|
|
4769
|
+
streaming: false,
|
|
4770
|
+
pushNotifications: false,
|
|
4771
|
+
extendedAgentCard: false,
|
|
4772
|
+
extensions: [{
|
|
4773
|
+
uri: KYA_A2A_EXTENSION,
|
|
4774
|
+
required: true,
|
|
4775
|
+
description: "KYA HTTP/2 Ed25519 holder proof over the exact JSON body and target; registered actors only. Source text never grants authority.",
|
|
4776
|
+
params: {
|
|
4777
|
+
methods: [
|
|
4778
|
+
"SendMessage",
|
|
4779
|
+
"GetTask",
|
|
4780
|
+
"CancelTask"
|
|
4781
|
+
],
|
|
4782
|
+
maxRequestBytes: 8192,
|
|
4783
|
+
returnImmediatelyRequired: true,
|
|
4784
|
+
historyReturned: false,
|
|
4785
|
+
authentication: {
|
|
4786
|
+
profile: "kya-http/2",
|
|
4787
|
+
headers: [
|
|
4788
|
+
"Signature-Input",
|
|
4789
|
+
"Signature",
|
|
4790
|
+
"Content-Digest",
|
|
4791
|
+
"Content-Type"
|
|
4792
|
+
],
|
|
4793
|
+
bearerSupported: false
|
|
4794
|
+
},
|
|
4795
|
+
retry: "Reuse the same messageId and unchanged parameters with a fresh HTTP proof after an uncertain acknowledgement."
|
|
4796
|
+
}
|
|
4797
|
+
}]
|
|
4798
|
+
},
|
|
4799
|
+
defaultInputModes: ["text/plain"],
|
|
4800
|
+
defaultOutputModes: ["application/json"],
|
|
4801
|
+
skills: [{
|
|
4802
|
+
id: "accountable-work",
|
|
4803
|
+
name: "Accountable work",
|
|
4804
|
+
description: "Submit and inspect durable tasks; completion identifies a recorded host receipt, with separate artifact and acceptance verification.",
|
|
4805
|
+
tags: [
|
|
4806
|
+
"tasks",
|
|
4807
|
+
"governance",
|
|
4808
|
+
"evidence"
|
|
4809
|
+
]
|
|
4810
|
+
}]
|
|
4811
|
+
};
|
|
4812
|
+
}
|
|
4813
|
+
|
|
4814
|
+
//#endregion
|
|
4815
|
+
//#region src/api/task-status-projection.ts
|
|
4816
|
+
const TaskProjectionStateSchema = _enum([
|
|
4817
|
+
"queued",
|
|
4818
|
+
"delivered",
|
|
4819
|
+
"approved",
|
|
4820
|
+
"running",
|
|
4821
|
+
"unknown",
|
|
4822
|
+
"awaiting_acceptance",
|
|
4823
|
+
"accepted",
|
|
4824
|
+
"published"
|
|
4825
|
+
]);
|
|
4826
|
+
const TaskProjectionEvidenceSchema = object({
|
|
4827
|
+
record: _enum([
|
|
4828
|
+
"source_intent",
|
|
4829
|
+
"delivery_attempt",
|
|
4830
|
+
"publication_binding",
|
|
4831
|
+
"admission",
|
|
4832
|
+
"action",
|
|
4833
|
+
"result_receipt",
|
|
4834
|
+
"activity"
|
|
4835
|
+
]),
|
|
4836
|
+
id: string().min(1).max(255),
|
|
4837
|
+
state: string().min(1).max(64),
|
|
4838
|
+
observedAt: string().datetime().nullable(),
|
|
4839
|
+
basis: _enum([
|
|
4840
|
+
"checkpoint_commit",
|
|
4841
|
+
"host_receipt",
|
|
4842
|
+
"lead_acknowledgment",
|
|
4843
|
+
"provider_ack",
|
|
4844
|
+
"provider_lookup"
|
|
4845
|
+
])
|
|
4846
|
+
}).strict();
|
|
4847
|
+
/** Metadata projection. Accepted means receipt acceptance, not human quality approval. */
|
|
4848
|
+
const TaskStatusProjectionSchema = object({
|
|
4849
|
+
schema: literal("kya.task.status-projection.v1"),
|
|
4850
|
+
taskId: string().uuid(),
|
|
4851
|
+
installationId: string().uuid(),
|
|
4852
|
+
organizationId: string().uuid(),
|
|
4853
|
+
projectId: string().uuid(),
|
|
4854
|
+
provider: _enum([
|
|
4855
|
+
"linear",
|
|
4856
|
+
"github",
|
|
4857
|
+
"discord",
|
|
4858
|
+
"didcomm",
|
|
4859
|
+
"a2a"
|
|
4860
|
+
]),
|
|
4861
|
+
sessionId: string().min(1).max(255),
|
|
4862
|
+
sourceRevision: number$1().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
4863
|
+
ownerEpoch: number$1().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
4864
|
+
state: TaskProjectionStateSchema,
|
|
4865
|
+
since: string().datetime().nullable(),
|
|
4866
|
+
cancellationRequested: boolean$1(),
|
|
4867
|
+
uncertain: array(TaskProjectionEvidenceSchema).max(64),
|
|
4868
|
+
evidence: array(TaskProjectionEvidenceSchema).min(1).max(64),
|
|
4869
|
+
projectedAt: string().datetime()
|
|
4870
|
+
}).strict().superRefine((value, ctx) => {
|
|
4871
|
+
if (value.state === "unknown" !== value.uncertain.length > 0) ctx.addIssue({
|
|
4872
|
+
code: ZodIssueCode.custom,
|
|
4873
|
+
message: "Uncertainty must take precedence"
|
|
4874
|
+
});
|
|
4875
|
+
if (value.since !== null && Date.parse(value.since) > Date.parse(value.projectedAt)) ctx.addIssue({
|
|
4876
|
+
code: ZodIssueCode.custom,
|
|
4877
|
+
message: "Transition cannot follow observation"
|
|
4878
|
+
});
|
|
4879
|
+
if (![...value.evidence, ...value.uncertain].some((e) => e.observedAt === value.since)) ctx.addIssue({
|
|
4880
|
+
code: ZodIssueCode.custom,
|
|
4881
|
+
message: "Transition needs record provenance"
|
|
4882
|
+
});
|
|
4883
|
+
for (const item of value.uncertain) if (!value.evidence.some((e) => e.record === item.record && e.id === item.id && e.state === item.state && e.observedAt === item.observedAt && e.basis === item.basis)) ctx.addIssue({
|
|
4884
|
+
code: ZodIssueCode.custom,
|
|
4885
|
+
message: "Uncertainty must identify projection evidence"
|
|
4886
|
+
});
|
|
4887
|
+
for (const items of [value.evidence, value.uncertain]) if (new Set(items.map((e) => JSON.stringify([e.record, e.id]))).size !== items.length) ctx.addIssue({
|
|
4888
|
+
code: ZodIssueCode.custom,
|
|
4889
|
+
message: "Duplicate record evidence"
|
|
4890
|
+
});
|
|
4891
|
+
});
|
|
4892
|
+
/** A tenant-scoped page of projections, most recently created task first. */
|
|
4893
|
+
const TaskStatusProjectionListSchema = object({
|
|
4894
|
+
tasks: array(TaskStatusProjectionSchema).max(100),
|
|
4895
|
+
projectedAt: string().datetime()
|
|
4896
|
+
}).strict();
|
|
4897
|
+
/** The conditions the activity drain needs to send; each names the reason it can fail. */
|
|
4898
|
+
const LinearActivityGateSchema = _enum([
|
|
4899
|
+
"installation_disabled",
|
|
4900
|
+
"installation_disconnected",
|
|
4901
|
+
"owner_epoch_changed",
|
|
4902
|
+
"destination_changed",
|
|
4903
|
+
"publication_binding_invalid",
|
|
4904
|
+
"publication_binding_expired",
|
|
4905
|
+
"approver_not_admin",
|
|
4906
|
+
"github_custody_lost"
|
|
4098
4907
|
]);
|
|
4908
|
+
const LinearActivityObservationSummarySchema = object({
|
|
4909
|
+
method: _enum(["send", "provider_lookup"]),
|
|
4910
|
+
result: _enum([
|
|
4911
|
+
"delivered",
|
|
4912
|
+
"rejected",
|
|
4913
|
+
"uncertain",
|
|
4914
|
+
"absent",
|
|
4915
|
+
"mismatch",
|
|
4916
|
+
"unavailable"
|
|
4917
|
+
]),
|
|
4918
|
+
observedAt: string().datetime(),
|
|
4919
|
+
httpStatus: number$1().int().min(100).max(599).nullable()
|
|
4920
|
+
}).strict();
|
|
4099
4921
|
/**
|
|
4100
|
-
*
|
|
4922
|
+
* An outbox entry the drain will not send as things stand: a failing gate, or an unproven
|
|
4923
|
+
* delivery that only a provider lookup can resolve. Metadata only, never activity content.
|
|
4101
4924
|
*/
|
|
4102
|
-
const
|
|
4103
|
-
|
|
4104
|
-
|
|
4925
|
+
const LinearObsoleteActivitySchema = object({
|
|
4926
|
+
schema: literal("kya.linear.obsolete-activity.v1"),
|
|
4927
|
+
activityId: string().uuid(),
|
|
4928
|
+
installationId: string().uuid(),
|
|
4929
|
+
operationId: string().uuid(),
|
|
4930
|
+
sessionId: string().min(1).max(255),
|
|
4931
|
+
kind: _enum(["result", "progress"]),
|
|
4932
|
+
deliveryState: _enum([
|
|
4933
|
+
"pending",
|
|
4934
|
+
"claimed",
|
|
4935
|
+
"unknown"
|
|
4936
|
+
]),
|
|
4937
|
+
attemptCount: number$1().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
|
|
4938
|
+
createdAt: string().datetime(),
|
|
4939
|
+
stateChangedAt: string().datetime().nullable(),
|
|
4940
|
+
reasons: array(union([LinearActivityGateSchema, literal("delivery_unproven")])).min(1).max(9),
|
|
4941
|
+
lastObservation: LinearActivityObservationSummarySchema.nullable()
|
|
4942
|
+
}).strict().superRefine((value, ctx) => {
|
|
4943
|
+
if (new Set(value.reasons).size !== value.reasons.length) ctx.addIssue({
|
|
4944
|
+
code: ZodIssueCode.custom,
|
|
4945
|
+
message: "Duplicate reason"
|
|
4946
|
+
});
|
|
4947
|
+
if (value.reasons.includes("delivery_unproven") === (value.deliveryState === "pending")) ctx.addIssue({
|
|
4948
|
+
code: ZodIssueCode.custom,
|
|
4949
|
+
message: "Unproven means unknown delivery"
|
|
4950
|
+
});
|
|
4951
|
+
});
|
|
4952
|
+
const LinearObsoleteActivityListSchema = object({
|
|
4953
|
+
activities: array(LinearObsoleteActivitySchema).max(200),
|
|
4954
|
+
projectedAt: string().datetime()
|
|
4955
|
+
}).strict();
|
|
4956
|
+
|
|
4957
|
+
//#endregion
|
|
4958
|
+
//#region src/api/task-ingress.ts
|
|
4959
|
+
const BoundedId = string().min(1).max(255);
|
|
4960
|
+
const DestinationDid = string().startsWith("did:").max(512);
|
|
4961
|
+
const KeyDid$2 = string().startsWith("did:key:").max(512);
|
|
4962
|
+
const ClaimToken = string().length(64).regex(/^[a-f0-9]{64}$/);
|
|
4963
|
+
const PublicationBranch = string().length(35).regex(/^kya\/linear-[a-f0-9]{24}$/);
|
|
4964
|
+
const Repository = string().max(255).regex(/^[a-zA-Z0-9_.-]+\/[a-zA-Z0-9_.-]+$/);
|
|
4965
|
+
const TaskSourceProviderSchema = _enum([
|
|
4966
|
+
"linear",
|
|
4967
|
+
"github",
|
|
4968
|
+
"discord",
|
|
4969
|
+
"didcomm",
|
|
4970
|
+
"a2a"
|
|
4971
|
+
]);
|
|
4972
|
+
const TaskStandingCapabilitySchema = _enum([
|
|
4973
|
+
"task.execute",
|
|
4974
|
+
"model.invoke",
|
|
4975
|
+
"github.branch.write",
|
|
4976
|
+
"github.pull_request.draft"
|
|
4977
|
+
]);
|
|
4978
|
+
const TaskModelIdSchema = string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/);
|
|
4979
|
+
/** Fixed allocation per call, not a provider price estimate or a guaranteed billing ceiling. */
|
|
4980
|
+
const TaskModelPolicySchema = object({
|
|
4981
|
+
provider: literal("anthropic"),
|
|
4982
|
+
/** The organization's own model credential that pays for these calls (`model-credentials`). */
|
|
4983
|
+
credentialId: string().uuid(),
|
|
4984
|
+
models: array(TaskModelIdSchema).min(1).max(20).refine((values) => new Set(values).size === values.length, "Duplicate models"),
|
|
4985
|
+
maxOutputTokens: number$1().int().min(1).max(64e3),
|
|
4986
|
+
maxRequestBytes: number$1().int().min(1).max(262144),
|
|
4987
|
+
reservedCostMicrousd: number$1().int().positive().max(Number.MAX_SAFE_INTEGER)
|
|
4988
|
+
}).strict();
|
|
4989
|
+
/** Initial text-only Messages profile. No caller endpoints, keys, hosted tools or streaming. */
|
|
4990
|
+
const TaskModelMessagesSchema = object({
|
|
4991
|
+
model: TaskModelIdSchema,
|
|
4992
|
+
max_tokens: number$1().int().min(1).max(64e3),
|
|
4993
|
+
messages: array(object({
|
|
4994
|
+
role: _enum(["user", "assistant"]),
|
|
4995
|
+
content: string().min(1).max(262144)
|
|
4996
|
+
}).strict()).min(1).max(1e3),
|
|
4997
|
+
system: string().max(262144).optional(),
|
|
4998
|
+
temperature: number$1().min(0).max(1).optional(),
|
|
4999
|
+
stream: literal(false).optional()
|
|
5000
|
+
}).strict();
|
|
5001
|
+
const TaskModelStatusSchema = object({
|
|
5002
|
+
admissionId: string().uuid(),
|
|
5003
|
+
operationId: string().uuid(),
|
|
5004
|
+
ownerEpoch: number$1().int().positive()
|
|
5005
|
+
}).strict();
|
|
5006
|
+
const TaskModelInvokeSchema = TaskModelStatusSchema.extend({ request: TaskModelMessagesSchema }).strict();
|
|
5007
|
+
const ModelTokenCount = number$1().int().nonnegative().max(Number.MAX_SAFE_INTEGER).nullable();
|
|
5008
|
+
const TaskModelUsageSchema = object({
|
|
5009
|
+
newInputTokens: ModelTokenCount,
|
|
5010
|
+
cacheReadInputTokens: ModelTokenCount,
|
|
5011
|
+
cacheWriteInputTokens: ModelTokenCount,
|
|
5012
|
+
cacheWrite5mInputTokens: ModelTokenCount,
|
|
5013
|
+
cacheWrite1hInputTokens: ModelTokenCount,
|
|
5014
|
+
totalInputTokens: ModelTokenCount,
|
|
5015
|
+
outputTokens: ModelTokenCount,
|
|
5016
|
+
coverage: _enum([
|
|
5017
|
+
"complete",
|
|
5018
|
+
"partial",
|
|
5019
|
+
"unknown"
|
|
5020
|
+
])
|
|
5021
|
+
}).strict();
|
|
5022
|
+
const TaskModelReceiptSchema = object({
|
|
5023
|
+
schema: literal("kya.task.model-receipt.v1"),
|
|
5024
|
+
admissionId: string().uuid(),
|
|
5025
|
+
admissionDigest: string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
5026
|
+
operationId: string().uuid(),
|
|
5027
|
+
requestDigest: string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
5028
|
+
provider: literal("anthropic"),
|
|
5029
|
+
model: TaskModelIdSchema,
|
|
5030
|
+
/** The admitted policy's credential, and the fingerprint of its key at call time. */
|
|
5031
|
+
credentialId: string().uuid(),
|
|
5032
|
+
credentialFingerprint: ModelCredentialFingerprintSchema,
|
|
5033
|
+
reservedCostMicrousd: number$1().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
5034
|
+
usage: TaskModelUsageSchema.nullable(),
|
|
5035
|
+
outputDigest: string().regex(/^sha256:[a-f0-9]{64}$/).optional(),
|
|
5036
|
+
code: _enum([
|
|
5037
|
+
"MODEL_STARTED",
|
|
5038
|
+
"MODEL_COMPLETED",
|
|
5039
|
+
"MODEL_REFUSED",
|
|
5040
|
+
"MODEL_OUTCOME_UNKNOWN"
|
|
5041
|
+
]),
|
|
5042
|
+
durationMs: number$1().int().nonnegative().max(Number.MAX_SAFE_INTEGER).nullable(),
|
|
5043
|
+
requestStartedAtMs: number$1().int().nonnegative().max(Number.MAX_SAFE_INTEGER).nullable(),
|
|
5044
|
+
costBasis: literal("unknown"),
|
|
5045
|
+
billingVerified: literal(false)
|
|
5046
|
+
}).strict();
|
|
5047
|
+
const StandingCapabilities = array(TaskStandingCapabilitySchema).min(1).max(4).refine((values) => new Set(values).size === values.length, "Duplicate capability");
|
|
5048
|
+
const TaskStandingPolicySchema = object({
|
|
5049
|
+
maxConcurrentOperations: number$1().int().min(1).max(100),
|
|
5050
|
+
maxAttemptsPerTask: number$1().int().min(1).max(10),
|
|
5051
|
+
workers: array(object({
|
|
5052
|
+
did: KeyDid$2,
|
|
5053
|
+
capabilities: StandingCapabilities
|
|
5054
|
+
}).strict()).min(1).max(100)
|
|
5055
|
+
}).strict();
|
|
5056
|
+
/**
|
|
5057
|
+
* An owner-approved set of leads for pooled routing. One eligible lead is selected per task, at
|
|
5058
|
+
* the lead's own claim, and persisted before delivery; `maxConcurrentTasks` bounds how many
|
|
5059
|
+
* unfinished tasks a lead may hold. Leads receive tasks; workers remain `standingApproval`.
|
|
5060
|
+
*/
|
|
5061
|
+
const TaskLeadPoolSchema = object({ leads: array(object({
|
|
5062
|
+
did: KeyDid$2,
|
|
5063
|
+
maxConcurrentTasks: number$1().int().min(1).max(100)
|
|
5064
|
+
}).strict()).min(2).max(32) }).strict().refine((pool) => new Set(pool.leads.map((lead) => lead.did)).size === pool.leads.length, "Each pool lead appears once");
|
|
5065
|
+
const LinearInstallationWorkflowSchema = object({
|
|
5066
|
+
destinationDid: DestinationDid,
|
|
5067
|
+
ownerEpoch: number$1().int().positive().max(2147483647),
|
|
5068
|
+
allowedActorIds: array(BoundedId).min(1).max(100),
|
|
5069
|
+
allowedRepositories: array(Repository).min(1).max(50),
|
|
5070
|
+
maxRuntimeSeconds: number$1().int().positive().max(86400),
|
|
5071
|
+
maxOperations: number$1().int().positive().max(1e4),
|
|
5072
|
+
maxCostMicrousd: number$1().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
5073
|
+
allowDraftPullRequest: boolean$1().default(false),
|
|
5074
|
+
executionMode: _enum(["review_required", "work_to_draft_pr"]).default("review_required"),
|
|
5075
|
+
standingApproval: TaskStandingPolicySchema.optional(),
|
|
5076
|
+
modelPolicy: TaskModelPolicySchema.optional(),
|
|
5077
|
+
leadPool: TaskLeadPoolSchema.optional()
|
|
5078
|
+
}).strict().refine((value) => new TextEncoder().encode(JSON.stringify(value)).byteLength <= 6e4, "Workflow exceeds delivery envelope bound").refine((value) => !value.leadPool || value.leadPool.leads.some((lead) => lead.did === value.destinationDid), "A pooled destination must be one of its leads");
|
|
5079
|
+
/**
|
|
5080
|
+
* Whether the policy lets `did` lead this installation's tasks: the pool's leads, or the direct
|
|
5081
|
+
* destination. Checkpoint also requires a pooled lead to hold a live C10 workload enrollment.
|
|
5082
|
+
*/
|
|
5083
|
+
function isAuthorizedLead(workflow, did) {
|
|
5084
|
+
return workflow.leadPool ? workflow.leadPool.leads.some((lead) => lead.did === did) : workflow.destinationDid === did;
|
|
5085
|
+
}
|
|
5086
|
+
/**
|
|
5087
|
+
* An owner/admin reassignment of one pooled task. `expectedLeadEpoch` fences a concurrent
|
|
5088
|
+
* reassignment; a null `leadDid` returns the task to the pool for the next eligible claim.
|
|
5089
|
+
*/
|
|
5090
|
+
const ReassignTaskLeadSchema = object({
|
|
5091
|
+
expectedLeadEpoch: number$1().int().nonnegative().max(2147483647),
|
|
5092
|
+
leadDid: KeyDid$2.nullable()
|
|
5093
|
+
}).strict();
|
|
5094
|
+
const TaskLeadAssignmentSchema = object({
|
|
5095
|
+
installationId: string().uuid(),
|
|
5096
|
+
taskId: string().uuid(),
|
|
5097
|
+
leadDid: KeyDid$2.nullable(),
|
|
5098
|
+
leadEpoch: number$1().int().positive().max(2147483647)
|
|
5099
|
+
}).strict();
|
|
5100
|
+
const ConfigureLinearInstallationSchema = object({
|
|
5101
|
+
projectId: string().uuid(),
|
|
5102
|
+
workspaceId: BoundedId,
|
|
5103
|
+
oauthClientId: BoundedId,
|
|
5104
|
+
appUserId: BoundedId,
|
|
5105
|
+
webhookId: BoundedId,
|
|
5106
|
+
webhookSecret: string().min(16).max(4096),
|
|
5107
|
+
accessToken: string().min(1).max(8192),
|
|
5108
|
+
enabled: boolean$1().default(true),
|
|
5109
|
+
workflow: LinearInstallationWorkflowSchema
|
|
5110
|
+
}).strict();
|
|
5111
|
+
const GitHubTaskSourceConfigSchema = object({
|
|
5112
|
+
provider: literal("github"),
|
|
5113
|
+
githubInstallationId: number$1().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
5114
|
+
repository: Repository.transform((value) => value.toLowerCase()),
|
|
5115
|
+
agentUserId: string().regex(/^[1-9][0-9]{0,19}$/),
|
|
5116
|
+
webhookSecret: string().min(16).max(4096)
|
|
5117
|
+
}).strict();
|
|
5118
|
+
const DiscordTaskSourceConfigSchema = object({
|
|
5119
|
+
provider: literal("discord"),
|
|
5120
|
+
applicationId: string().regex(/^[1-9][0-9]{16,19}$/),
|
|
5121
|
+
publicKeyHex: string().regex(/^[a-fA-F0-9]{64}$/),
|
|
5122
|
+
guildId: string().regex(/^[1-9][0-9]{16,19}$/),
|
|
5123
|
+
channelIds: array(string().regex(/^[1-9][0-9]{16,19}$/)).min(1).max(100),
|
|
5124
|
+
commandName: string().regex(/^[a-z0-9_-]{1,32}$/)
|
|
5125
|
+
}).strict();
|
|
5126
|
+
const DidCommTaskSourceConfigSchema = object({
|
|
5127
|
+
provider: literal("didcomm"),
|
|
5128
|
+
recipientDid: string().startsWith("did:key:").max(255)
|
|
5129
|
+
}).strict();
|
|
5130
|
+
const A2ATaskSourceConfigSchema = object({
|
|
5131
|
+
provider: literal("a2a"),
|
|
5132
|
+
recipientDid: string().startsWith("did:key:").max(255)
|
|
5133
|
+
}).strict();
|
|
5134
|
+
const DidCommTaskSourceBindingSchema = object({
|
|
5135
|
+
schema: literal("kya.task.source-binding.v1"),
|
|
5136
|
+
organizationId: string().uuid(),
|
|
5137
|
+
projectId: string().uuid(),
|
|
5138
|
+
installationId: string().uuid(),
|
|
5139
|
+
ownerEpoch: number$1().int().positive().max(2147483647)
|
|
5140
|
+
}).strict();
|
|
5141
|
+
/** A native message's context is strict: its source binding and, optionally, the repository. */
|
|
5142
|
+
const DidCommSourceContext = object({
|
|
5143
|
+
kyaTaskSource: DidCommTaskSourceBindingSchema,
|
|
5144
|
+
repo: Repository.optional()
|
|
5145
|
+
}).strict();
|
|
5146
|
+
const DidCommSourceEnvelope = object({
|
|
5147
|
+
id: string().uuid(),
|
|
5148
|
+
from: string().startsWith("did:key:").max(255),
|
|
5149
|
+
to: array(string().startsWith("did:key:").max(255)).length(1),
|
|
5150
|
+
created_time: number$1().int().positive(),
|
|
5151
|
+
expires_time: number$1().int().positive(),
|
|
5152
|
+
thid: BoundedId,
|
|
5153
|
+
pthid: BoundedId.optional()
|
|
5154
|
+
});
|
|
5155
|
+
const DidCommTaskBody = {
|
|
5156
|
+
taskId: BoundedId,
|
|
5157
|
+
context: DidCommSourceContext
|
|
5158
|
+
};
|
|
5159
|
+
const DidCommTaskSourceMessageSchema = discriminatedUnion("type", [
|
|
5160
|
+
DidCommSourceEnvelope.extend({
|
|
5161
|
+
type: literal("https://kya-os.ai/didcomm/task/assign"),
|
|
5162
|
+
body: object({
|
|
5163
|
+
...DidCommTaskBody,
|
|
5164
|
+
description: string().min(1).max(19e4),
|
|
5165
|
+
priority: _enum([
|
|
5166
|
+
"low",
|
|
5167
|
+
"normal",
|
|
5168
|
+
"urgent"
|
|
5169
|
+
]).optional(),
|
|
5170
|
+
relayTimeoutMs: number$1().int().positive().max(864e5).optional()
|
|
5171
|
+
}).strict()
|
|
5172
|
+
}).strict(),
|
|
5173
|
+
DidCommSourceEnvelope.extend({
|
|
5174
|
+
type: literal("https://kya-os.ai/didcomm/task/steer"),
|
|
5175
|
+
body: object({
|
|
5176
|
+
...DidCommTaskBody,
|
|
5177
|
+
instruction: string().min(1).max(19e4),
|
|
5178
|
+
priority: _enum([
|
|
5179
|
+
"low",
|
|
5180
|
+
"normal",
|
|
5181
|
+
"urgent"
|
|
5182
|
+
]).optional()
|
|
5183
|
+
}).strict()
|
|
5184
|
+
}).strict(),
|
|
5185
|
+
DidCommSourceEnvelope.extend({
|
|
5186
|
+
type: literal("https://kya-os.ai/didcomm/task/cancel"),
|
|
5187
|
+
body: object(DidCommTaskBody).strict()
|
|
5188
|
+
}).strict()
|
|
5189
|
+
]);
|
|
5190
|
+
const TaskSourceProviderConfigSchema = discriminatedUnion("provider", [
|
|
5191
|
+
GitHubTaskSourceConfigSchema,
|
|
5192
|
+
DiscordTaskSourceConfigSchema,
|
|
5193
|
+
DidCommTaskSourceConfigSchema,
|
|
5194
|
+
A2ATaskSourceConfigSchema
|
|
5195
|
+
]);
|
|
5196
|
+
const ConfigureTaskSourceInstallationSchema = object({
|
|
5197
|
+
projectId: string().uuid(),
|
|
5198
|
+
source: TaskSourceProviderConfigSchema,
|
|
5199
|
+
/** Setup only: encrypted server custody, never included in source or workload responses. */
|
|
5200
|
+
discordBotToken: string().min(1).max(8192).optional(),
|
|
5201
|
+
enabled: boolean$1().default(true),
|
|
5202
|
+
workflow: LinearInstallationWorkflowSchema
|
|
5203
|
+
}).strict();
|
|
5204
|
+
/** Authenticated source material, never an executable authorization. */
|
|
5205
|
+
const TaskSourceIntentSchema = object({
|
|
5206
|
+
schema: literal("kya.task.source-intent.v1"),
|
|
5207
|
+
taskId: string().uuid(),
|
|
5208
|
+
operationId: string().uuid(),
|
|
5209
|
+
installationId: string().uuid(),
|
|
5210
|
+
organizationId: string().uuid(),
|
|
5211
|
+
projectId: string().uuid(),
|
|
5212
|
+
sessionId: BoundedId,
|
|
5213
|
+
sourceRevision: number$1().int().positive(),
|
|
5214
|
+
ownerEpoch: number$1().int().positive(),
|
|
5215
|
+
destinationDid: DestinationDid,
|
|
5216
|
+
kind: _enum([
|
|
5217
|
+
"created",
|
|
5218
|
+
"prompted",
|
|
5219
|
+
"stop"
|
|
5220
|
+
]),
|
|
5221
|
+
source: object({
|
|
5222
|
+
provider: TaskSourceProviderSchema,
|
|
5223
|
+
workspaceId: BoundedId,
|
|
5224
|
+
actorId: BoundedId,
|
|
5225
|
+
issueId: BoundedId.optional()
|
|
5226
|
+
}).strict(),
|
|
5227
|
+
untrustedInput: string().max(2e5).refine((value) => new TextEncoder().encode(value).byteLength <= 2e5 && new TextEncoder().encode(JSON.stringify(value)).byteLength <= 4e5, "Source input exceeds the UTF-8 or encoded response bound"),
|
|
5228
|
+
inputDigest: string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
5229
|
+
workflow: LinearInstallationWorkflowSchema,
|
|
5230
|
+
authorization: literal("requires_task_approval"),
|
|
5231
|
+
/** B09-P3: the exact signed A2A request Checkpoint verified for this delivery. Only an A2A
|
|
5232
|
+
* source carries it; an A2A revision recorded before retention began has none. */
|
|
5233
|
+
delivery: A2ASignedRequestSchema.optional()
|
|
5234
|
+
}).strict().refine((intent) => intent.delivery === void 0 || intent.source.provider === "a2a", {
|
|
5235
|
+
message: "Only an A2A source carries its signed request",
|
|
5236
|
+
path: ["delivery"]
|
|
5237
|
+
});
|
|
5238
|
+
/** Scope is derived from authenticated workload authority, never request-body tenancy. */
|
|
5239
|
+
const TaskMailboxScopeSchema = object({
|
|
5240
|
+
organizationId: string().uuid(),
|
|
5241
|
+
projectId: string().uuid(),
|
|
5242
|
+
destinationDid: DestinationDid,
|
|
5243
|
+
ownerEpoch: number$1().int().positive()
|
|
5244
|
+
}).strict();
|
|
5245
|
+
const TaskMailboxClaimRequestSchema = object({
|
|
5246
|
+
ownerEpoch: number$1().int().positive().max(2147483647),
|
|
5247
|
+
acceptedProviders: array(TaskSourceProviderSchema).min(1).max(5).default(["linear"]),
|
|
5248
|
+
claimId: string().uuid().optional(),
|
|
5249
|
+
claimToken: ClaimToken.optional()
|
|
5250
|
+
}).strict().refine((value) => Boolean(value.claimId) === Boolean(value.claimToken), "claimId and claimToken must be supplied together");
|
|
5251
|
+
const TaskMailboxStatusRequestSchema = object({
|
|
5252
|
+
ownerEpoch: number$1().int().positive().max(2147483647),
|
|
5253
|
+
claimId: string().uuid()
|
|
5254
|
+
}).strict();
|
|
5255
|
+
const TaskMailboxClaimSchema = object({
|
|
5256
|
+
claimId: string().uuid(),
|
|
5257
|
+
claimToken: ClaimToken,
|
|
5258
|
+
claimExpiresAt: string().datetime(),
|
|
5259
|
+
deliveryState: _enum([
|
|
5260
|
+
"claimed",
|
|
5261
|
+
"accepted",
|
|
5262
|
+
"unknown",
|
|
5263
|
+
"cancelled"
|
|
5264
|
+
]),
|
|
5265
|
+
intent: TaskSourceIntentSchema
|
|
5266
|
+
}).strict();
|
|
5267
|
+
const TaskMailboxStatusSchema = object({
|
|
5268
|
+
claimId: string().uuid(),
|
|
5269
|
+
operationId: string().uuid(),
|
|
5270
|
+
taskId: string().uuid(),
|
|
5271
|
+
sourceRevision: number$1().int().positive(),
|
|
5272
|
+
ownerEpoch: number$1().int().positive(),
|
|
5273
|
+
deliveryState: _enum([
|
|
5274
|
+
"pending",
|
|
5275
|
+
"claimed",
|
|
5276
|
+
"accepted",
|
|
5277
|
+
"unknown",
|
|
5278
|
+
"cancelled"
|
|
5279
|
+
]),
|
|
5280
|
+
outcome: _enum([
|
|
5281
|
+
"claimed",
|
|
5282
|
+
"accepted",
|
|
5283
|
+
"not_delivered",
|
|
5284
|
+
"unknown"
|
|
5285
|
+
]),
|
|
5286
|
+
claimExpiresAt: string().datetime()
|
|
5287
|
+
}).strict();
|
|
5288
|
+
const TaskMailboxSettlementSchema = object({
|
|
5289
|
+
claimId: string().uuid(),
|
|
5290
|
+
operationId: string().uuid(),
|
|
5291
|
+
taskId: string().uuid(),
|
|
5292
|
+
sourceRevision: number$1().int().positive(),
|
|
5293
|
+
ownerEpoch: number$1().int().positive(),
|
|
5294
|
+
claimToken: ClaimToken,
|
|
5295
|
+
outcome: _enum([
|
|
5296
|
+
"accepted",
|
|
5297
|
+
"not_delivered",
|
|
5298
|
+
"unknown"
|
|
5299
|
+
])
|
|
5300
|
+
}).strict();
|
|
5301
|
+
const Sha256Digest$1 = string().regex(/^sha256:[a-f0-9]{64}$/);
|
|
5302
|
+
const PublicationBindingFields = {
|
|
5303
|
+
sourceOperationId: string().uuid(),
|
|
5304
|
+
taskId: string().uuid(),
|
|
5305
|
+
sourceRevision: number$1().int().positive(),
|
|
5306
|
+
ownerEpoch: number$1().int().positive(),
|
|
5307
|
+
specRevision: number$1().int().positive(),
|
|
5308
|
+
manifestDigest: Sha256Digest$1,
|
|
5309
|
+
executionOperationId: string().min(1).max(255)
|
|
5310
|
+
};
|
|
5311
|
+
const ApproveTaskPublicationSchema = object({
|
|
5312
|
+
...PublicationBindingFields,
|
|
5313
|
+
reporterDid: KeyDid$2,
|
|
5314
|
+
repository: Repository,
|
|
5315
|
+
baseSha: string().regex(/^[a-f0-9]{40}$/),
|
|
5316
|
+
expiresAt: string().datetime(),
|
|
5317
|
+
publishDraftPullRequest: boolean$1().default(false)
|
|
5318
|
+
}).strict();
|
|
5319
|
+
const FleetPullRequestReceiptSchema = object({
|
|
5320
|
+
schema: literal("kya.fleet.pull-request.v1"),
|
|
5321
|
+
taskId: string().uuid(),
|
|
5322
|
+
number: number$1().int().positive(),
|
|
5323
|
+
headSha: string().regex(/^[a-f0-9]{40}$/)
|
|
5324
|
+
}).strict();
|
|
5325
|
+
const TaskMailboxResultSchema = object({
|
|
5326
|
+
...PublicationBindingFields,
|
|
5327
|
+
outcome: _enum([
|
|
5328
|
+
"completed",
|
|
5329
|
+
"failed",
|
|
5330
|
+
"cancelled"
|
|
5331
|
+
]),
|
|
5332
|
+
artifact: FleetPullRequestReceiptSchema.optional()
|
|
5333
|
+
}).strict();
|
|
5334
|
+
const ApprovedTaskPublicationSchema = ApproveTaskPublicationSchema.extend({
|
|
5335
|
+
schema: literal("kya.task.publication-binding.v1"),
|
|
5336
|
+
branch: PublicationBranch,
|
|
5337
|
+
approvedByUserId: string().uuid(),
|
|
5338
|
+
approvedAt: string().datetime(),
|
|
5339
|
+
githubInstallationId: number$1().int().positive().optional()
|
|
5340
|
+
}).strict();
|
|
5341
|
+
const TaskStandingLimitsSchema = object({
|
|
5342
|
+
maxRuntimeSeconds: number$1().int().min(1).max(86400),
|
|
5343
|
+
maxCostMicrousd: number$1().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
5344
|
+
maxOperations: number$1().int().min(1).max(1e4)
|
|
5345
|
+
}).strict();
|
|
5346
|
+
const TaskStandingAdmissionRequestBaseSchema = object({
|
|
5347
|
+
...PublicationBindingFields,
|
|
5348
|
+
workerDid: KeyDid$2,
|
|
5349
|
+
repository: Repository,
|
|
5350
|
+
baseSha: string().regex(/^[a-f0-9]{40}$/),
|
|
5351
|
+
attemptNumber: number$1().int().min(1).max(10),
|
|
5352
|
+
capabilities: StandingCapabilities,
|
|
5353
|
+
limits: TaskStandingLimitsSchema,
|
|
5354
|
+
modelPolicy: TaskModelPolicySchema.optional()
|
|
5355
|
+
}).strict();
|
|
5356
|
+
const validModelAdmission = (value) => value.capabilities.includes("model.invoke") === Boolean(value.modelPolicy) && (!value.modelPolicy || value.modelPolicy.reservedCostMicrousd <= value.limits.maxCostMicrousd);
|
|
5357
|
+
const TaskStandingAdmissionRequestSchema = TaskStandingAdmissionRequestBaseSchema.refine(validModelAdmission, "Model capability requires a bounded policy");
|
|
5358
|
+
/** The v1 receipt before its model refinement, so a later protocol can extend it. */
|
|
5359
|
+
const TaskStandingAdmissionReceiptBaseSchema = TaskStandingAdmissionRequestBaseSchema.omit({ workerDid: true }).extend({
|
|
5360
|
+
schema: literal("kya.task.admission.v1"),
|
|
5361
|
+
admissionId: string().uuid(),
|
|
5362
|
+
organizationId: string().uuid(),
|
|
5363
|
+
projectId: string().uuid(),
|
|
5364
|
+
installationId: string().uuid(),
|
|
5365
|
+
leadDid: DestinationDid,
|
|
5366
|
+
holderDid: KeyDid$2,
|
|
5367
|
+
branch: PublicationBranch,
|
|
5368
|
+
notBefore: string().datetime(),
|
|
5369
|
+
expiresAt: string().datetime(),
|
|
5370
|
+
policyProvenance: literal("administrator_registered"),
|
|
5371
|
+
requiresOnlineActionGate: literal(true),
|
|
5372
|
+
credentialExport: literal(false)
|
|
5373
|
+
}).strict();
|
|
5374
|
+
const TaskStandingAdmissionSchema = TaskStandingAdmissionReceiptBaseSchema.refine(validModelAdmission, "Model capability requires a bounded policy");
|
|
5375
|
+
const TaskStandingActionSchema = object({
|
|
5376
|
+
admissionId: string().uuid(),
|
|
5377
|
+
operationId: string().uuid(),
|
|
5378
|
+
ownerEpoch: number$1().int().positive(),
|
|
5379
|
+
action: discriminatedUnion("kind", [
|
|
5380
|
+
object({ kind: literal("task.start") }).strict(),
|
|
5381
|
+
object({
|
|
5382
|
+
kind: literal("model.invoke"),
|
|
5383
|
+
provider: literal("anthropic"),
|
|
5384
|
+
model: TaskModelIdSchema,
|
|
5385
|
+
requestDigest: string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
5386
|
+
maxOutputTokens: number$1().int().min(1).max(64e3)
|
|
5387
|
+
}).strict(),
|
|
5388
|
+
object({
|
|
5389
|
+
kind: literal("task.finish"),
|
|
5390
|
+
outcome: _enum([
|
|
5391
|
+
"completed",
|
|
5392
|
+
"failed",
|
|
5393
|
+
"cancelled",
|
|
5394
|
+
"unknown"
|
|
5395
|
+
])
|
|
5396
|
+
}).strict(),
|
|
5397
|
+
object({
|
|
5398
|
+
kind: literal("github.commit"),
|
|
5399
|
+
expectedHeadSha: string().regex(/^[a-f0-9]{40}$/),
|
|
5400
|
+
message: string().min(1).max(2e3),
|
|
5401
|
+
files: array(object({
|
|
5402
|
+
path: string().min(1).max(1e3),
|
|
5403
|
+
content: string().max(2e5).nullable()
|
|
5404
|
+
}).strict()).min(1).max(100)
|
|
5405
|
+
}).strict(),
|
|
5406
|
+
object({
|
|
5407
|
+
kind: literal("github.pull_request.draft"),
|
|
5408
|
+
headSha: string().regex(/^[a-f0-9]{40}$/)
|
|
5409
|
+
}).strict()
|
|
5410
|
+
])
|
|
5411
|
+
}).strict();
|
|
5412
|
+
const TaskStandingReconcileSchema = TaskStandingActionSchema.extend({ originalOwnerEpoch: number$1().int().positive() }).strict();
|
|
5413
|
+
|
|
5414
|
+
//#endregion
|
|
5415
|
+
//#region src/api/cli-identity.ts
|
|
5416
|
+
const Text$1 = string().min(1).max(500).refine((s) => [...s].every((character) => {
|
|
5417
|
+
const code = character.charCodeAt(0);
|
|
5418
|
+
return code >= 32 && code !== 127;
|
|
5419
|
+
}));
|
|
5420
|
+
const PublicUrl$1 = string().url().refine((value) => {
|
|
5421
|
+
const url = new URL(value);
|
|
5422
|
+
return ["http:", "https:"].includes(url.protocol) && !url.username && !url.password && !url.search && !url.hash;
|
|
5423
|
+
});
|
|
5424
|
+
const CliIdentityQuerySchema = object({ projectId: string().min(1).max(255) }).strict();
|
|
5425
|
+
const CliIdentityServiceSchema = object({
|
|
5426
|
+
id: Text$1,
|
|
5427
|
+
kind: _enum([
|
|
5428
|
+
"registry",
|
|
5429
|
+
"authorization_host",
|
|
5430
|
+
"mcp"
|
|
5431
|
+
]),
|
|
5432
|
+
url: PublicUrl$1.nullable(),
|
|
5433
|
+
status: _enum([
|
|
5434
|
+
"configured",
|
|
5435
|
+
"active_recorded",
|
|
5436
|
+
"inactive_recorded",
|
|
5437
|
+
"not_configured"
|
|
5438
|
+
]),
|
|
5439
|
+
observed_at: string().datetime().nullable()
|
|
5440
|
+
}).strict();
|
|
5441
|
+
const CliIdentitySummarySchema = object({
|
|
5442
|
+
version: literal(1),
|
|
5443
|
+
observed_at: string().datetime(),
|
|
5444
|
+
project: object({
|
|
5445
|
+
id: Text$1,
|
|
5446
|
+
name: Text$1
|
|
5447
|
+
}).strict(),
|
|
5448
|
+
organization: object({
|
|
5449
|
+
id: Text$1,
|
|
5450
|
+
name: Text$1,
|
|
5451
|
+
slug: Text$1,
|
|
5452
|
+
did_web: Text$1.refine((value) => value.startsWith("did:web:")).nullable(),
|
|
5453
|
+
did_webvh: Text$1.refine((value) => value.startsWith("did:webvh:")).nullable(),
|
|
5454
|
+
registry_state: _enum(["registered", "not_registered"])
|
|
5455
|
+
}).strict().nullable(),
|
|
5456
|
+
services: array(CliIdentityServiceSchema).max(102).refine((services) => new Set(services.map((service) => service.id)).size === services.length)
|
|
5457
|
+
}).strict().refine((summary) => !summary.organization || summary.organization.registry_state === "registered" === Boolean(summary.organization.did_webvh), "Registration state must match the stored registry DID");
|
|
5458
|
+
|
|
5459
|
+
//#endregion
|
|
5460
|
+
//#region src/api/verification.ts
|
|
5461
|
+
/**
|
|
5462
|
+
* Signature Verification API schemas
|
|
5463
|
+
*
|
|
5464
|
+
* Used for verifying signatures from AI agents like ChatGPT
|
|
5465
|
+
*/
|
|
5466
|
+
/**
|
|
5467
|
+
* Supported signature algorithms
|
|
5468
|
+
*/
|
|
5469
|
+
const SignatureAlgorithmSchema = _enum([
|
|
5470
|
+
"RS256",
|
|
5471
|
+
"RS384",
|
|
5472
|
+
"RS512",
|
|
5473
|
+
"ES256",
|
|
5474
|
+
"ES384",
|
|
5475
|
+
"ES512",
|
|
5476
|
+
"HS256",
|
|
5477
|
+
"HS384",
|
|
5478
|
+
"HS512"
|
|
5479
|
+
]);
|
|
5480
|
+
/**
|
|
5481
|
+
* Agent verification provider
|
|
5482
|
+
*/
|
|
5483
|
+
const VerificationProviderSchema = _enum([
|
|
5484
|
+
"chatgpt",
|
|
5485
|
+
"claude",
|
|
5486
|
+
"gemini",
|
|
5487
|
+
"perplexity",
|
|
5488
|
+
"custom"
|
|
5489
|
+
]);
|
|
5490
|
+
/**
|
|
5491
|
+
* Signature Verification Request
|
|
5492
|
+
*/
|
|
5493
|
+
const SignatureVerificationRequestSchema = object({
|
|
5494
|
+
signature: string().min(1),
|
|
5495
|
+
payload: string().optional(),
|
|
4105
5496
|
timestamp: number$1().optional(),
|
|
4106
5497
|
provider: VerificationProviderSchema.default("chatgpt"),
|
|
4107
5498
|
publicKey: string().optional(),
|
|
@@ -4182,6 +5573,7 @@ const VerificationCacheEntrySchema = object({
|
|
|
4182
5573
|
*
|
|
4183
5574
|
* Standard schemas for bulk CRUD operations across all resources
|
|
4184
5575
|
*/
|
|
5576
|
+
const MAX_BULK_BATCH_SIZE = 100;
|
|
4185
5577
|
/**
|
|
4186
5578
|
* Bulk operation types
|
|
4187
5579
|
*/
|
|
@@ -4297,8 +5689,8 @@ const ProjectsBulkUpdateItemSchema = object({
|
|
|
4297
5689
|
customDomain: string().optional(),
|
|
4298
5690
|
allowedOrigins: array(string()).optional(),
|
|
4299
5691
|
blockedAgents: array(string()).optional(),
|
|
4300
|
-
webhookUrl: string().url().optional(),
|
|
4301
|
-
webhookSecret: string().optional()
|
|
5692
|
+
webhookUrl: string().url().nullable().optional(),
|
|
5693
|
+
webhookSecret: string().nullable().optional()
|
|
4302
5694
|
}).optional()
|
|
4303
5695
|
});
|
|
4304
5696
|
const ProjectsBulkDeleteItemSchema = object({
|
|
@@ -4417,10 +5809,6 @@ const ApiKeysBulkRequestSchema = BaseBulkRequestSchema.and(discriminatedUnion("o
|
|
|
4417
5809
|
})
|
|
4418
5810
|
]));
|
|
4419
5811
|
/**
|
|
4420
|
-
* Maximum batch size for bulk operations
|
|
4421
|
-
*/
|
|
4422
|
-
const MAX_BULK_BATCH_SIZE = 100;
|
|
4423
|
-
/**
|
|
4424
5812
|
* Bulk operation error codes
|
|
4425
5813
|
*/
|
|
4426
5814
|
const BULK_ERROR_CODES = {
|
|
@@ -4456,11 +5844,6 @@ const BULK_ERROR_CODES = {
|
|
|
4456
5844
|
* classifier path and the engine's emitted names (which keep their spaces,
|
|
4457
5845
|
* e.g. 'Bytedance Crawler') for the WASM path.
|
|
4458
5846
|
*
|
|
4459
|
-
* 'Meta AI' is listed here on purpose, matching the report: stored 'Meta AI'
|
|
4460
|
-
* rows are overwhelmingly pre-split Meta-ExternalAgent crawler hits (the
|
|
4461
|
-
* `meta-ai` agent type carried that UA before the split, see agents.ts), so
|
|
4462
|
-
* the report regroups them as crawlers. Genuine Meta-AI assistant sessions
|
|
4463
|
-
* are rare and accepted as a known trade-off of reproducing the report.
|
|
4464
5847
|
*/
|
|
4465
5848
|
const REPORT_AI_CRAWLER_NAMES = [
|
|
4466
5849
|
"GPTBot",
|
|
@@ -4556,7 +5939,8 @@ const UserPlanSchema = _enum([
|
|
|
4556
5939
|
const ApiKeyPermissionSchema = _enum([
|
|
4557
5940
|
"read",
|
|
4558
5941
|
"write",
|
|
4559
|
-
"admin"
|
|
5942
|
+
"admin",
|
|
5943
|
+
"forward"
|
|
4560
5944
|
]);
|
|
4561
5945
|
/**
|
|
4562
5946
|
* User Entity
|
|
@@ -4584,7 +5968,9 @@ const ProjectSettingsSchema = object({
|
|
|
4584
5968
|
blockedAgents: array(string()).default([]),
|
|
4585
5969
|
webhookUrl: string().url().optional(),
|
|
4586
5970
|
webhookSecret: string().optional(),
|
|
4587
|
-
beaconRateLimitPerMinute: number$1().int().positive().optional()
|
|
5971
|
+
beaconRateLimitPerMinute: number$1().int().positive().optional(),
|
|
5972
|
+
postureOrigins: array(string()).optional(),
|
|
5973
|
+
beaconIngestMode: _enum(["origin", "worker"]).optional()
|
|
4588
5974
|
});
|
|
4589
5975
|
/**
|
|
4590
5976
|
* Project Entity
|
|
@@ -5587,7 +6973,6 @@ function fromProviderRegistryFormatSafe(provider) {
|
|
|
5587
6973
|
*/
|
|
5588
6974
|
const organizationDomainSchema = string().trim().toLowerCase().min(1, "Domain is required").max(255, "Domain must be less than 255 characters").regex(/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+$/, "Domain must be a valid hostname");
|
|
5589
6975
|
const clearableOptionalString = (schema) => schema.nullable().optional();
|
|
5590
|
-
/** Hostname rule shared with `organizationDomainSchema` (kept in sync). */
|
|
5591
6976
|
const HOSTNAME_REGEX = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+$/;
|
|
5592
6977
|
/**
|
|
5593
6978
|
* Accepted org logo values:
|
|
@@ -5815,15 +7200,30 @@ function resolveAuthorizationHost(authorizationHost, platformDefaultHost = DEFAU
|
|
|
5815
7200
|
return toBareHost(override && override.length > 0 ? override : platformDefaultHost);
|
|
5816
7201
|
}
|
|
5817
7202
|
|
|
7203
|
+
//#endregion
|
|
7204
|
+
//#region src/types/posture-origins-schema.ts
|
|
7205
|
+
/**
|
|
7206
|
+
* `settings.postureOrigins` on a project write: the additional page origins
|
|
7207
|
+
* browser posture may be issued for. Validated and NORMALIZED by the one
|
|
7208
|
+
* shared resolver (`../posture-origins`), so what the settings APIs store is
|
|
7209
|
+
* exactly what the issuer and gateway later match. Each rejected entry
|
|
7210
|
+
* surfaces as its own issue at `[index]` with a readable message, which the
|
|
7211
|
+
* routes return in their 400 `details`.
|
|
7212
|
+
*/
|
|
7213
|
+
const PostureOriginsSchema = array(string().max(300)).max(20).transform((origins, ctx) => {
|
|
7214
|
+
const result = validatePostureOrigins(origins);
|
|
7215
|
+
if (result.ok) return result.origins;
|
|
7216
|
+
for (const error of result.errors) ctx.addIssue({
|
|
7217
|
+
code: "custom",
|
|
7218
|
+
message: error.message,
|
|
7219
|
+
path: error.index >= 0 ? [error.index] : []
|
|
7220
|
+
});
|
|
7221
|
+
return NEVER;
|
|
7222
|
+
});
|
|
7223
|
+
|
|
5818
7224
|
//#endregion
|
|
5819
7225
|
//#region src/api/internal.ts
|
|
5820
7226
|
/**
|
|
5821
|
-
* Internal API Schemas
|
|
5822
|
-
*
|
|
5823
|
-
* Schemas for internal dashboard API endpoints
|
|
5824
|
-
* Used for validation and type safety in internal routes
|
|
5825
|
-
*/
|
|
5826
|
-
/**
|
|
5827
7227
|
* Flexible Project ID Schema
|
|
5828
7228
|
* Accepts UUID format, kta- format, and friendly ID format
|
|
5829
7229
|
*
|
|
@@ -5894,7 +7294,8 @@ const UpdateProjectSchema = object({
|
|
|
5894
7294
|
blockedAgents: array(string()).optional(),
|
|
5895
7295
|
webhookUrl: string().url().optional(),
|
|
5896
7296
|
webhookSecret: string().optional(),
|
|
5897
|
-
beaconRateLimitPerMinute: number$1().int().positive().optional()
|
|
7297
|
+
beaconRateLimitPerMinute: number$1().int().positive().optional(),
|
|
7298
|
+
postureOrigins: PostureOriginsSchema.optional()
|
|
5898
7299
|
}).optional()
|
|
5899
7300
|
});
|
|
5900
7301
|
/**
|
|
@@ -5965,15 +7366,6 @@ const ProvisionKeyRequestSchema = object({
|
|
|
5965
7366
|
* the KYA-OS user + personal org from it (Shopify-parity), so an address matching an
|
|
5966
7367
|
* existing account provisions INTO that account — including the org it lands in.
|
|
5967
7368
|
*
|
|
5968
|
-
* The caller MUST send an address it has verified belongs to the installer. Nothing here
|
|
5969
|
-
* enforces that: there is no verification flag and no per-provider gate, so a wrong address
|
|
5970
|
-
* silently mints a project inside a stranger's org. Adapters carrying a verified identity
|
|
5971
|
-
* (Vercel's OIDC `user_email`, Railway's OIDC userinfo `email`) satisfy this directly;
|
|
5972
|
-
* Shopware satisfies it by convention only, since its app handshake carries no user identity
|
|
5973
|
-
* and the address is merchant-confirmed in the shop admin.
|
|
5974
|
-
*
|
|
5975
|
-
* Rationale, per-provider trust, and the accepted exposure:
|
|
5976
|
-
* `docs/integrations/provisioning-owner-email-trust.md`.
|
|
5977
7369
|
*/
|
|
5978
7370
|
owner: object({
|
|
5979
7371
|
email: string().email(),
|
|
@@ -6125,10 +7517,7 @@ const ExportAnalyticsSchema = object({
|
|
|
6125
7517
|
/**
|
|
6126
7518
|
* Settings Schemas
|
|
6127
7519
|
*/
|
|
6128
|
-
const UpdateSettingsSchema = object({
|
|
6129
|
-
name: string().min(1).max(255).optional(),
|
|
6130
|
-
email: string().email().optional()
|
|
6131
|
-
});
|
|
7520
|
+
const UpdateSettingsSchema = object({ name: string().min(1).max(255).optional() });
|
|
6132
7521
|
const DeleteAccountSchema = object({ confirmation: literal("DELETE_MY_ACCOUNT") });
|
|
6133
7522
|
/**
|
|
6134
7523
|
* Specialized Query Schemas
|
|
@@ -6328,7 +7717,9 @@ const DetectionSignalExposureSchema = object({
|
|
|
6328
7717
|
signals: array(DetectionSignalSchema).describe("The engine's full per-signal evidence breakdown, verbatim (not the condensed single-entry summary). Empty when the engine did not run (skipDetection) or faulted. THE extension point: future signal families arrive as new entries/sources here, additively."),
|
|
6329
7718
|
reasonCodes: array(DetectionReasonCodeSchema).min(1).describe("Ordered detection/* reason codes, most-significant-evidence first, derived by the same mapDetectionToReasonCodes projection that feeds the gateway KYA-Reason-Codes header. Never empty: an assumed verdict carries a zero-evidence fallback code."),
|
|
6330
7719
|
confidenceLevel: ConfidenceLevelSchema.optional().describe("The engine's banded confidence level (low | medium | high | very_high). Omitted when the engine did not produce one (engine fault, skipDetection, or a demoted forged-credential verdict)."),
|
|
6331
|
-
isAiCrawler: boolean$1().optional().describe("True when the engine classified the client as an AI training crawler (GPTBot, ClaudeBot, …) rather than an interactive agent. Omitted when the engine did not run.")
|
|
7720
|
+
isAiCrawler: boolean$1().optional().describe("True when the engine classified the client as an AI training crawler (GPTBot, ClaudeBot, …) rather than an interactive agent. Omitted when the engine did not run."),
|
|
7721
|
+
riskScore: RiskScoreSchema.optional().describe("The Noisy-Or probability that the request is automated (0-1, two decimals), uncalibrated (see riskScoreSource), derived from detectionDetail.metadata.shadow_noisy_or_confidence. Null when the combiner did not run. Distinct from `confidence` above, which is never derived from it."),
|
|
7722
|
+
riskScoreSource: RiskScoreSourceSchema.optional().describe("Which metadata key riskScore was derived from: 'uncalibrated' (always true today) or 'calibrated' (not yet wired). Null exactly when riskScore is null.")
|
|
6332
7723
|
});
|
|
6333
7724
|
|
|
6334
7725
|
//#endregion
|
|
@@ -6622,20 +8013,69 @@ const PaginationInfoSchema = object({
|
|
|
6622
8013
|
total: number$1().int().nonnegative(),
|
|
6623
8014
|
hasMore: boolean$1()
|
|
6624
8015
|
});
|
|
8016
|
+
/** The three session classes of the ai_agent > bot > human priority partition. */
|
|
8017
|
+
const ShopifySessionClassSchema = _enum([
|
|
8018
|
+
"ai_agent",
|
|
8019
|
+
"bot",
|
|
8020
|
+
"human"
|
|
8021
|
+
]);
|
|
8022
|
+
/**
|
|
8023
|
+
* One visit (consolidated session) of the stats window, returned with
|
|
8024
|
+
* `include=sessions`. Carries no IP, user agent or device data.
|
|
8025
|
+
*/
|
|
8026
|
+
const ShopifySessionSchema = object({
|
|
8027
|
+
sessionId: string().describe("Consolidated session id (UUID)."),
|
|
8028
|
+
firstSeenAt: string().datetime().describe("ISO-8601 instant of the first detection of the session in the window."),
|
|
8029
|
+
lastSeenAt: string().datetime().describe("ISO-8601 instant of the latest detection of the session in the window."),
|
|
8030
|
+
eventCount: number$1().int().nonnegative().describe("Detections of the session in the window, every class included."),
|
|
8031
|
+
detectionClass: ShopifySessionClassSchema.describe("Session class by priority: ai_agent if any detection is an AI agent, else bot if any is a bot, else human."),
|
|
8032
|
+
agentName: string().nullable().describe("Agent type of the latest detection of the session class that names one."),
|
|
8033
|
+
agentCategory: string().nullable().describe("Agent category of that same detection."),
|
|
8034
|
+
geoCountry: string().nullable().describe("ISO 3166-1 alpha-2 country of the latest detection that has one."),
|
|
8035
|
+
uniquePathCount: number$1().int().nonnegative().describe("Distinct request paths of the session in the window."),
|
|
8036
|
+
paths: array(string()).describe("Distinct request paths in first-arrival order, at most 25.")
|
|
8037
|
+
});
|
|
8038
|
+
/** Pagination of `sessions`. `total` is exact; `totalPages` stops at the highest page accepted (200). */
|
|
8039
|
+
const ShopifySessionsPaginationSchema = object({
|
|
8040
|
+
page: number$1().int().positive(),
|
|
8041
|
+
limit: number$1().int().positive(),
|
|
8042
|
+
total: number$1().int().nonnegative().describe("Sessions matching `sessionsClass` in the window: equal to the headline count for that class (`totalRequests` with no class)."),
|
|
8043
|
+
totalPages: number$1().int().nonnegative().describe("`min(ceil(total / limit), 200)`: the last page `sessionsPage` accepts."),
|
|
8044
|
+
hasMore: boolean$1().describe("True when `page < totalPages`.")
|
|
8045
|
+
});
|
|
6625
8046
|
/**
|
|
6626
8047
|
* Shopify Stats Response
|
|
8048
|
+
*
|
|
8049
|
+
* Every counter is a SESSION count, not an event count. `totalRequests` is
|
|
8050
|
+
* the number of sessions in the window and `blockedBots` the AI-agent
|
|
8051
|
+
* sessions among them.
|
|
8052
|
+
*
|
|
8053
|
+
* `crawlerSessions` and `humanSessions` complete the four-way split
|
|
8054
|
+
* (AI agent / crawler / human / unclassified). Both are optional in both
|
|
8055
|
+
* directions: an older Checkpoint does not send them, and an older Shopify
|
|
8056
|
+
* app ignores them. When present they come from the same per-session
|
|
8057
|
+
* classification as `blockedBots` (ai_agent > bot > human priority), so
|
|
8058
|
+
* `blockedBots + crawlerSessions + humanSessions <= totalRequests`; the
|
|
8059
|
+
* remainder is sessions that belong to no class.
|
|
8060
|
+
*
|
|
8061
|
+
* `sessions` and `sessionsPagination` are present only when the request
|
|
8062
|
+
* asks for them (`include=sessions`); an older Checkpoint never sends them.
|
|
6627
8063
|
*/
|
|
6628
8064
|
const ShopifyStatsResponseSchema = object({
|
|
6629
8065
|
totalRequests: number$1().int().nonnegative(),
|
|
6630
8066
|
blockedBots: number$1().int().nonnegative(),
|
|
6631
8067
|
allowedRequests: number$1().int().nonnegative(),
|
|
8068
|
+
crawlerSessions: number$1().int().nonnegative().optional(),
|
|
8069
|
+
humanSessions: number$1().int().nonnegative().optional(),
|
|
6632
8070
|
threatLevel: _enum([
|
|
6633
8071
|
"low",
|
|
6634
8072
|
"medium",
|
|
6635
8073
|
"high"
|
|
6636
8074
|
]),
|
|
6637
8075
|
recentThreats: array(ShopifyThreatSchema),
|
|
6638
|
-
pagination: PaginationInfoSchema
|
|
8076
|
+
pagination: PaginationInfoSchema,
|
|
8077
|
+
sessions: array(ShopifySessionSchema).optional(),
|
|
8078
|
+
sessionsPagination: ShopifySessionsPaginationSchema.optional()
|
|
6639
8079
|
});
|
|
6640
8080
|
/**
|
|
6641
8081
|
* Shopify Project Settings Update Request
|
|
@@ -6644,7 +8084,8 @@ const ShopifyProjectSettingsUpdateSchema = object({ settings: object({
|
|
|
6644
8084
|
blockOnHighConfidence: boolean$1().optional(),
|
|
6645
8085
|
confidenceThreshold: number$1().min(0).max(1).optional(),
|
|
6646
8086
|
enableSessionTracking: boolean$1().optional(),
|
|
6647
|
-
enableWasm: boolean$1().optional()
|
|
8087
|
+
enableWasm: boolean$1().optional(),
|
|
8088
|
+
postureOrigins: PostureOriginsSchema.optional()
|
|
6648
8089
|
}).optional() });
|
|
6649
8090
|
|
|
6650
8091
|
//#endregion
|
|
@@ -8633,11 +10074,11 @@ const CollectedDataSchema = object({
|
|
|
8633
10074
|
sessionData: any().optional(),
|
|
8634
10075
|
geoLocation: object({
|
|
8635
10076
|
country: string(),
|
|
8636
|
-
region: string(),
|
|
8637
|
-
city: string(),
|
|
8638
|
-
latitude: number$1(),
|
|
8639
|
-
longitude: number$1(),
|
|
8640
|
-
timezone: string()
|
|
10077
|
+
region: string().optional(),
|
|
10078
|
+
city: string().optional(),
|
|
10079
|
+
latitude: number$1().optional(),
|
|
10080
|
+
longitude: number$1().optional(),
|
|
10081
|
+
timezone: string().optional()
|
|
8641
10082
|
}).optional()
|
|
8642
10083
|
}).optional(),
|
|
8643
10084
|
behavioral: object({
|
|
@@ -10972,6 +12413,7 @@ const DetectionRulesSchema = object({
|
|
|
10972
12413
|
* Rule load options schema
|
|
10973
12414
|
*/
|
|
10974
12415
|
const RuleLoadOptionsSchema = object({
|
|
12416
|
+
/** @deprecated Refused at runtime; see `RuleLoader.loadRules`. */
|
|
10975
12417
|
cdnUrl: string().url().optional(),
|
|
10976
12418
|
forceRefresh: boolean$1().optional(),
|
|
10977
12419
|
cacheDuration: number$1().min(0).optional(),
|
|
@@ -11179,86 +12621,6 @@ var RuleValidator = class {
|
|
|
11179
12621
|
}
|
|
11180
12622
|
};
|
|
11181
12623
|
|
|
11182
|
-
//#endregion
|
|
11183
|
-
//#region src/rules/rule-parser.ts
|
|
11184
|
-
/**
|
|
11185
|
-
* Rule Parser
|
|
11186
|
-
*
|
|
11187
|
-
* Parses YAML/JSON rule definitions
|
|
11188
|
-
*/
|
|
11189
|
-
/**
|
|
11190
|
-
* Parse rule content (YAML or JSON)
|
|
11191
|
-
*/
|
|
11192
|
-
var RuleParser = class {
|
|
11193
|
-
/**
|
|
11194
|
-
* Parse rule content from string
|
|
11195
|
-
*/
|
|
11196
|
-
static parse(content) {
|
|
11197
|
-
if (!content || content.trim().length === 0) throw new Error(RULE_ERRORS.INVALID_FORMAT);
|
|
11198
|
-
const trimmed = content.trim();
|
|
11199
|
-
try {
|
|
11200
|
-
if (trimmed.startsWith("{")) return JSON.parse(trimmed);
|
|
11201
|
-
const parsed = yaml.load(trimmed);
|
|
11202
|
-
if (!parsed || typeof parsed !== "object") throw new Error(RULE_ERRORS.INVALID_FORMAT);
|
|
11203
|
-
return parsed;
|
|
11204
|
-
} catch (error) {
|
|
11205
|
-
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
11206
|
-
if (errorMessage.includes("JSON") || errorMessage.includes("Unexpected") || errorMessage.includes("Expected")) throw new Error("Parse failed: Invalid JSON");
|
|
11207
|
-
throw new Error(`Parse failed: ${errorMessage}`);
|
|
11208
|
-
}
|
|
11209
|
-
}
|
|
11210
|
-
/**
|
|
11211
|
-
* Parse JSON rules
|
|
11212
|
-
*/
|
|
11213
|
-
static parseJSON(content) {
|
|
11214
|
-
try {
|
|
11215
|
-
return JSON.parse(content);
|
|
11216
|
-
} catch (error) {
|
|
11217
|
-
throw new Error("Parse failed: Invalid JSON");
|
|
11218
|
-
}
|
|
11219
|
-
}
|
|
11220
|
-
/**
|
|
11221
|
-
* Parse YAML rules
|
|
11222
|
-
*/
|
|
11223
|
-
static parseYAML(content) {
|
|
11224
|
-
try {
|
|
11225
|
-
const parsed = yaml.load(content);
|
|
11226
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error(RULE_ERRORS.INVALID_FORMAT);
|
|
11227
|
-
return parsed;
|
|
11228
|
-
} catch (error) {
|
|
11229
|
-
if (error instanceof Error && error.message === RULE_ERRORS.INVALID_FORMAT) throw error;
|
|
11230
|
-
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
11231
|
-
if (errorMessage.includes("unknown escape sequence") || errorMessage.includes("YAML") || errorMessage.includes("bad indentation")) throw new Error("Parse failed: Invalid YAML");
|
|
11232
|
-
throw new Error("Parse failed: Invalid YAML");
|
|
11233
|
-
}
|
|
11234
|
-
}
|
|
11235
|
-
/**
|
|
11236
|
-
* Convert rules to JSON string
|
|
11237
|
-
*/
|
|
11238
|
-
static toJSON(rules, pretty = false) {
|
|
11239
|
-
return JSON.stringify(rules, null, pretty ? 2 : 0);
|
|
11240
|
-
}
|
|
11241
|
-
/**
|
|
11242
|
-
* Convert rules to YAML string
|
|
11243
|
-
*/
|
|
11244
|
-
static toYAML(rules) {
|
|
11245
|
-
return yaml.dump(rules, {
|
|
11246
|
-
indent: 2,
|
|
11247
|
-
lineWidth: -1,
|
|
11248
|
-
noRefs: true,
|
|
11249
|
-
sortKeys: false
|
|
11250
|
-
});
|
|
11251
|
-
}
|
|
11252
|
-
/**
|
|
11253
|
-
* Validate basic rule structure
|
|
11254
|
-
*/
|
|
11255
|
-
static validateStructure(rules) {
|
|
11256
|
-
if (!rules || typeof rules !== "object") return false;
|
|
11257
|
-
const candidate = rules;
|
|
11258
|
-
return !!(typeof candidate.version === "string" && typeof candidate.lastUpdated === "string" && candidate.rules && typeof candidate.rules === "object");
|
|
11259
|
-
}
|
|
11260
|
-
};
|
|
11261
|
-
|
|
11262
12624
|
//#endregion
|
|
11263
12625
|
//#region src/data/compiled/merged-rules.json
|
|
11264
12626
|
var require_merged_rules = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
@@ -11331,7 +12693,7 @@ var require_merged_rules = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
11331
12693
|
"lastUpdated": "2025-01-10T00:00:00Z"
|
|
11332
12694
|
}
|
|
11333
12695
|
],
|
|
11334
|
-
"hash": "
|
|
12696
|
+
"hash": "e1421f0f43d84f10a8093fedbeb9b47eaa8998b2407da9564d8b74637251ad08"
|
|
11335
12697
|
},
|
|
11336
12698
|
"rules": {
|
|
11337
12699
|
"userAgents": {
|
|
@@ -11695,8 +13057,7 @@ var require_merged_rules = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
11695
13057
|
"Mediapartners-Google",
|
|
11696
13058
|
"Google-InspectionTool",
|
|
11697
13059
|
"GoogleOther",
|
|
11698
|
-
"Google-Read-Aloud"
|
|
11699
|
-
"Google-Extended"
|
|
13060
|
+
"Google-Read-Aloud"
|
|
11700
13061
|
],
|
|
11701
13062
|
"confidence": .95,
|
|
11702
13063
|
"description": "Google search crawler and related bots",
|
|
@@ -12234,12 +13595,6 @@ var require_merged_rules = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
12234
13595
|
"possible_perplexity": .5
|
|
12235
13596
|
}
|
|
12236
13597
|
}
|
|
12237
|
-
},
|
|
12238
|
-
"cdn": {
|
|
12239
|
-
"enabled": false,
|
|
12240
|
-
"baseUrl": "https://cdn.agentshield.com/rules/",
|
|
12241
|
-
"updateInterval": 86400,
|
|
12242
|
-
"fallbackToBundled": true
|
|
12243
13598
|
}
|
|
12244
13599
|
};
|
|
12245
13600
|
}));
|
|
@@ -12252,8 +13607,6 @@ var require_merged_rules = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
12252
13607
|
var RuleLoader = class RuleLoader {
|
|
12253
13608
|
static instance = null;
|
|
12254
13609
|
rules = null;
|
|
12255
|
-
lastFetch = 0;
|
|
12256
|
-
isBrowser = typeof window !== "undefined";
|
|
12257
13610
|
/**
|
|
12258
13611
|
* Private constructor for singleton
|
|
12259
13612
|
*/
|
|
@@ -12279,23 +13632,14 @@ var RuleLoader = class RuleLoader {
|
|
|
12279
13632
|
}
|
|
12280
13633
|
}
|
|
12281
13634
|
/**
|
|
12282
|
-
* Load rules
|
|
13635
|
+
* Load the bundled rules, memoised for the life of the loader.
|
|
13636
|
+
*
|
|
13637
|
+
* A `cdnUrl` is refused: schema validation alone would accept any
|
|
13638
|
+
* well-formed document from whoever controls the URL.
|
|
12283
13639
|
*/
|
|
12284
13640
|
async loadRules(options = {}) {
|
|
12285
|
-
|
|
12286
|
-
if (
|
|
12287
|
-
if (options.cdnUrl) try {
|
|
12288
|
-
const content = await (await this.fetchFromCDN(options.cdnUrl)).text();
|
|
12289
|
-
const parsed = RuleParser.parse(content);
|
|
12290
|
-
this.rules = RuleValidator.validateOrThrow(parsed, validationMode);
|
|
12291
|
-
this.lastFetch = Date.now();
|
|
12292
|
-
if (this.isBrowser) this.cacheRules(this.rules);
|
|
12293
|
-
return this.rules;
|
|
12294
|
-
} catch (error) {
|
|
12295
|
-
throw new Error(`${RULE_ERRORS.CDN_UNAVAILABLE}: Failed to load rules from CDN. Error: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
12296
|
-
}
|
|
12297
|
-
this.rules = RuleLoader.loadSync();
|
|
12298
|
-
this.lastFetch = Date.now();
|
|
13641
|
+
if (options.cdnUrl !== void 0) throw new Error(`${RULE_ERRORS.LOAD_FAILED}: cdnUrl is not supported; unsigned remote rules are not accepted. Use a signed rule bundle.`);
|
|
13642
|
+
if (options.forceRefresh || !this.rules) this.rules = RuleLoader.loadSync();
|
|
12299
13643
|
return this.rules;
|
|
12300
13644
|
}
|
|
12301
13645
|
/**
|
|
@@ -12305,52 +13649,10 @@ var RuleLoader = class RuleLoader {
|
|
|
12305
13649
|
return this.rules;
|
|
12306
13650
|
}
|
|
12307
13651
|
/**
|
|
12308
|
-
*
|
|
12309
|
-
*/
|
|
12310
|
-
isCacheValid(customDuration) {
|
|
12311
|
-
if (!this.rules || !this.lastFetch) return false;
|
|
12312
|
-
const duration = customDuration || RULE_CACHE.DEFAULT_DURATION;
|
|
12313
|
-
return Date.now() - this.lastFetch < duration;
|
|
12314
|
-
}
|
|
12315
|
-
/**
|
|
12316
|
-
* Fetch rules from CDN
|
|
12317
|
-
*/
|
|
12318
|
-
async fetchFromCDN(url) {
|
|
12319
|
-
const controller = new AbortController();
|
|
12320
|
-
const timeout = setTimeout(() => controller.abort(), RULE_CDN.TIMEOUT);
|
|
12321
|
-
try {
|
|
12322
|
-
const response = await fetch(url, {
|
|
12323
|
-
signal: controller.signal,
|
|
12324
|
-
headers: { Accept: "application/json" }
|
|
12325
|
-
});
|
|
12326
|
-
if (!response.ok) throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
12327
|
-
return response;
|
|
12328
|
-
} finally {
|
|
12329
|
-
clearTimeout(timeout);
|
|
12330
|
-
}
|
|
12331
|
-
}
|
|
12332
|
-
/**
|
|
12333
|
-
* Cache rules in localStorage (browser only)
|
|
12334
|
-
*/
|
|
12335
|
-
cacheRules(rules) {
|
|
12336
|
-
if (!this.isBrowser) return;
|
|
12337
|
-
try {
|
|
12338
|
-
localStorage.setItem(RULE_CACHE.STORAGE_KEY, JSON.stringify(rules));
|
|
12339
|
-
localStorage.setItem(RULE_CACHE.TIMESTAMP_KEY, String(Date.now()));
|
|
12340
|
-
} catch (error) {
|
|
12341
|
-
console.warn("Failed to cache rules in localStorage:", error);
|
|
12342
|
-
}
|
|
12343
|
-
}
|
|
12344
|
-
/**
|
|
12345
|
-
* Clear cached rules
|
|
13652
|
+
* Clear the memoised rules
|
|
12346
13653
|
*/
|
|
12347
13654
|
clearCache() {
|
|
12348
13655
|
this.rules = null;
|
|
12349
|
-
this.lastFetch = 0;
|
|
12350
|
-
if (this.isBrowser) try {
|
|
12351
|
-
localStorage.removeItem(RULE_CACHE.STORAGE_KEY);
|
|
12352
|
-
localStorage.removeItem(RULE_CACHE.TIMESTAMP_KEY);
|
|
12353
|
-
} catch {}
|
|
12354
13656
|
}
|
|
12355
13657
|
/**
|
|
12356
13658
|
* Reset singleton instance (mainly for testing)
|
|
@@ -12369,6 +13671,86 @@ async function loadRulesAsync(options) {
|
|
|
12369
13671
|
return RuleLoader.getInstance().loadRules(options);
|
|
12370
13672
|
}
|
|
12371
13673
|
|
|
13674
|
+
//#endregion
|
|
13675
|
+
//#region src/rules/rule-parser.ts
|
|
13676
|
+
/**
|
|
13677
|
+
* Rule Parser
|
|
13678
|
+
*
|
|
13679
|
+
* Parses YAML/JSON rule definitions
|
|
13680
|
+
*/
|
|
13681
|
+
/**
|
|
13682
|
+
* Parse rule content (YAML or JSON)
|
|
13683
|
+
*/
|
|
13684
|
+
var RuleParser = class {
|
|
13685
|
+
/**
|
|
13686
|
+
* Parse rule content from string
|
|
13687
|
+
*/
|
|
13688
|
+
static parse(content) {
|
|
13689
|
+
if (!content || content.trim().length === 0) throw new Error(RULE_ERRORS.INVALID_FORMAT);
|
|
13690
|
+
const trimmed = content.trim();
|
|
13691
|
+
try {
|
|
13692
|
+
if (trimmed.startsWith("{")) return JSON.parse(trimmed);
|
|
13693
|
+
const parsed = yaml.load(trimmed);
|
|
13694
|
+
if (!parsed || typeof parsed !== "object") throw new Error(RULE_ERRORS.INVALID_FORMAT);
|
|
13695
|
+
return parsed;
|
|
13696
|
+
} catch (error) {
|
|
13697
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
13698
|
+
if (errorMessage.includes("JSON") || errorMessage.includes("Unexpected") || errorMessage.includes("Expected")) throw new Error("Parse failed: Invalid JSON");
|
|
13699
|
+
throw new Error(`Parse failed: ${errorMessage}`);
|
|
13700
|
+
}
|
|
13701
|
+
}
|
|
13702
|
+
/**
|
|
13703
|
+
* Parse JSON rules
|
|
13704
|
+
*/
|
|
13705
|
+
static parseJSON(content) {
|
|
13706
|
+
try {
|
|
13707
|
+
return JSON.parse(content);
|
|
13708
|
+
} catch (error) {
|
|
13709
|
+
throw new Error("Parse failed: Invalid JSON");
|
|
13710
|
+
}
|
|
13711
|
+
}
|
|
13712
|
+
/**
|
|
13713
|
+
* Parse YAML rules
|
|
13714
|
+
*/
|
|
13715
|
+
static parseYAML(content) {
|
|
13716
|
+
try {
|
|
13717
|
+
const parsed = yaml.load(content);
|
|
13718
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error(RULE_ERRORS.INVALID_FORMAT);
|
|
13719
|
+
return parsed;
|
|
13720
|
+
} catch (error) {
|
|
13721
|
+
if (error instanceof Error && error.message === RULE_ERRORS.INVALID_FORMAT) throw error;
|
|
13722
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
13723
|
+
if (errorMessage.includes("unknown escape sequence") || errorMessage.includes("YAML") || errorMessage.includes("bad indentation")) throw new Error("Parse failed: Invalid YAML");
|
|
13724
|
+
throw new Error("Parse failed: Invalid YAML");
|
|
13725
|
+
}
|
|
13726
|
+
}
|
|
13727
|
+
/**
|
|
13728
|
+
* Convert rules to JSON string
|
|
13729
|
+
*/
|
|
13730
|
+
static toJSON(rules, pretty = false) {
|
|
13731
|
+
return JSON.stringify(rules, null, pretty ? 2 : 0);
|
|
13732
|
+
}
|
|
13733
|
+
/**
|
|
13734
|
+
* Convert rules to YAML string
|
|
13735
|
+
*/
|
|
13736
|
+
static toYAML(rules) {
|
|
13737
|
+
return yaml.dump(rules, {
|
|
13738
|
+
indent: 2,
|
|
13739
|
+
lineWidth: -1,
|
|
13740
|
+
noRefs: true,
|
|
13741
|
+
sortKeys: false
|
|
13742
|
+
});
|
|
13743
|
+
}
|
|
13744
|
+
/**
|
|
13745
|
+
* Validate basic rule structure
|
|
13746
|
+
*/
|
|
13747
|
+
static validateStructure(rules) {
|
|
13748
|
+
if (!rules || typeof rules !== "object") return false;
|
|
13749
|
+
const candidate = rules;
|
|
13750
|
+
return !!(typeof candidate.version === "string" && typeof candidate.lastUpdated === "string" && candidate.rules && typeof candidate.rules === "object");
|
|
13751
|
+
}
|
|
13752
|
+
};
|
|
13753
|
+
|
|
12372
13754
|
//#endregion
|
|
12373
13755
|
//#region src/rules/vendor-range-freshness.ts
|
|
12374
13756
|
const DEFAULT_MAX_VENDOR_RANGE_AGE_MS = 3456e5;
|
|
@@ -13753,10 +15135,21 @@ function validateStepUpQuorum(quorum) {
|
|
|
13753
15135
|
*
|
|
13754
15136
|
* The fetcher supports:
|
|
13755
15137
|
* - In-memory caching with TTL
|
|
13756
|
-
* -
|
|
15138
|
+
* - Origin reads for legacy adapters that cannot coordinate shared invalidation
|
|
13757
15139
|
* - Fallback to default policy on errors
|
|
13758
15140
|
* - Configurable API endpoints
|
|
13759
15141
|
*/
|
|
15142
|
+
var PolicyUnavailableError = class extends Error {
|
|
15143
|
+
code = "POLICY_UNAVAILABLE";
|
|
15144
|
+
constructor() {
|
|
15145
|
+
super("Current policy could not be loaded within the permitted bound");
|
|
15146
|
+
this.name = "PolicyUnavailableError";
|
|
15147
|
+
}
|
|
15148
|
+
};
|
|
15149
|
+
/** Recognize the same failure across independently loaded SDK package copies. */
|
|
15150
|
+
function isPolicyUnavailableError(error) {
|
|
15151
|
+
return error instanceof Error && error.name === "PolicyUnavailableError" && "code" in error && error.code === "POLICY_UNAVAILABLE";
|
|
15152
|
+
}
|
|
13760
15153
|
/**
|
|
13761
15154
|
* Simple in-memory cache with TTL support
|
|
13762
15155
|
*/
|
|
@@ -13783,15 +15176,14 @@ var MemoryCache = class {
|
|
|
13783
15176
|
clear() {
|
|
13784
15177
|
this.cache.clear();
|
|
13785
15178
|
}
|
|
13786
|
-
/**
|
|
13787
|
-
* Remove expired entries (for memory management)
|
|
13788
|
-
*/
|
|
13789
|
-
cleanup() {
|
|
13790
|
-
const now = Date.now();
|
|
13791
|
-
for (const [key, entry] of this.cache.entries()) if (now > entry.expiresAt) this.cache.delete(key);
|
|
13792
|
-
}
|
|
13793
15179
|
};
|
|
13794
15180
|
const globalMemoryCache = new MemoryCache();
|
|
15181
|
+
const globalPolicyCacheKeys = /* @__PURE__ */ new Map();
|
|
15182
|
+
const fallbackCachePrefix = `${Date.now().toString(36)}:${Math.random().toString(36).slice(2)}:${Math.random().toString(36).slice(2)}`;
|
|
15183
|
+
let fallbackCacheSequence = 0;
|
|
15184
|
+
function nextCacheRevision() {
|
|
15185
|
+
return globalThis.crypto?.randomUUID?.() ?? `${fallbackCachePrefix}:${++fallbackCacheSequence}`;
|
|
15186
|
+
}
|
|
13795
15187
|
/**
|
|
13796
15188
|
* Policy fetcher with caching and fallback support
|
|
13797
15189
|
*/
|
|
@@ -13806,6 +15198,7 @@ var PolicyFetcher = class {
|
|
|
13806
15198
|
cacheAdapter: config.cacheAdapter,
|
|
13807
15199
|
disableMemoryCache: config.disableMemoryCache ?? false,
|
|
13808
15200
|
timeoutMs: config.timeoutMs ?? 5e3,
|
|
15201
|
+
throwOnUnavailable: config.throwOnUnavailable ?? false,
|
|
13809
15202
|
fetchFn: config.fetchFn ?? globalThis.fetch
|
|
13810
15203
|
};
|
|
13811
15204
|
this.memoryCache = config.disableMemoryCache ? new MemoryCache() : globalMemoryCache;
|
|
@@ -13814,59 +15207,80 @@ var PolicyFetcher = class {
|
|
|
13814
15207
|
* Generate a cache key that includes the API base URL and TTL to prevent
|
|
13815
15208
|
* cache collisions when multiple fetchers use different backends or TTL settings.
|
|
13816
15209
|
*/
|
|
13817
|
-
|
|
15210
|
+
getBaseCacheKey(projectId) {
|
|
13818
15211
|
return `policy:${this.config.apiBaseUrl.split("").reduce((hash, char) => (hash << 5) - hash + char.charCodeAt(0) | 0, 0).toString(36)}:${this.config.cacheTtlSeconds}:${projectId}`;
|
|
13819
15212
|
}
|
|
15213
|
+
getCacheKey(projectId) {
|
|
15214
|
+
const baseKey = this.getBaseCacheKey(projectId);
|
|
15215
|
+
return globalPolicyCacheKeys.get(baseKey) ?? baseKey;
|
|
15216
|
+
}
|
|
13820
15217
|
/**
|
|
13821
15218
|
* Get policy for a project, with caching
|
|
13822
15219
|
*/
|
|
13823
15220
|
async getPolicy(projectId) {
|
|
13824
|
-
const
|
|
13825
|
-
if (!this.config.
|
|
13826
|
-
|
|
13827
|
-
|
|
13828
|
-
|
|
13829
|
-
|
|
13830
|
-
|
|
13831
|
-
|
|
13832
|
-
|
|
13833
|
-
|
|
13834
|
-
|
|
13835
|
-
|
|
13836
|
-
|
|
13837
|
-
|
|
13838
|
-
|
|
13839
|
-
}
|
|
13840
|
-
}
|
|
13841
|
-
} catch (error) {
|
|
13842
|
-
console.error("[PolicyFetcher] External cache error:", error);
|
|
13843
|
-
}
|
|
15221
|
+
const deadline = Date.now() + this.config.timeoutMs;
|
|
15222
|
+
if (!Number.isFinite(deadline) || this.config.timeoutMs <= 0) throw new PolicyUnavailableError();
|
|
15223
|
+
const controller = new AbortController();
|
|
15224
|
+
const requireActiveLoad = () => {
|
|
15225
|
+
if (controller.signal.aborted || Date.now() >= deadline) throw new PolicyUnavailableError();
|
|
15226
|
+
};
|
|
15227
|
+
let timer;
|
|
15228
|
+
const expired = new Promise((_resolve, reject) => {
|
|
15229
|
+
timer = setTimeout(() => {
|
|
15230
|
+
const failure = new PolicyUnavailableError();
|
|
15231
|
+
controller.abort(failure);
|
|
15232
|
+
reject(failure);
|
|
15233
|
+
}, this.config.timeoutMs);
|
|
15234
|
+
});
|
|
15235
|
+
const useMemoryCache = !this.config.disableMemoryCache && !this.config.cacheAdapter;
|
|
13844
15236
|
try {
|
|
13845
|
-
|
|
13846
|
-
|
|
13847
|
-
|
|
13848
|
-
|
|
13849
|
-
|
|
13850
|
-
|
|
13851
|
-
|
|
13852
|
-
|
|
13853
|
-
|
|
13854
|
-
|
|
13855
|
-
|
|
13856
|
-
|
|
13857
|
-
|
|
13858
|
-
|
|
15237
|
+
for (let attempt = 0; attempt < 4; attempt++) {
|
|
15238
|
+
requireActiveLoad();
|
|
15239
|
+
const cacheKey = this.getCacheKey(projectId);
|
|
15240
|
+
if (useMemoryCache) {
|
|
15241
|
+
const memoryCached = this.memoryCache.get(cacheKey);
|
|
15242
|
+
if (memoryCached) {
|
|
15243
|
+
const cached = JSON.parse(memoryCached);
|
|
15244
|
+
requireActiveLoad();
|
|
15245
|
+
if (!this.isExpired(cached.expiresAt)) return cached.policy;
|
|
15246
|
+
}
|
|
15247
|
+
}
|
|
15248
|
+
try {
|
|
15249
|
+
const policy = await Promise.race([this.fetchPolicyFromApi(projectId, controller.signal), expired]);
|
|
15250
|
+
requireActiveLoad();
|
|
15251
|
+
if (cacheKey !== this.getCacheKey(projectId)) continue;
|
|
15252
|
+
if (useMemoryCache) {
|
|
15253
|
+
const now = /* @__PURE__ */ new Date();
|
|
15254
|
+
const cached = {
|
|
15255
|
+
policy,
|
|
15256
|
+
projectId,
|
|
15257
|
+
cachedAt: now.toISOString(),
|
|
15258
|
+
expiresAt: new Date(now.getTime() + this.config.cacheTtlSeconds * 1e3).toISOString()
|
|
15259
|
+
};
|
|
15260
|
+
const cacheValue = JSON.stringify(cached);
|
|
15261
|
+
requireActiveLoad();
|
|
15262
|
+
this.memoryCache.set(cacheKey, cacheValue, this.config.cacheTtlSeconds);
|
|
15263
|
+
}
|
|
15264
|
+
requireActiveLoad();
|
|
15265
|
+
return policy;
|
|
15266
|
+
} catch (error) {
|
|
15267
|
+
requireActiveLoad();
|
|
15268
|
+
if (isPolicyUnavailableError(error)) throw error;
|
|
15269
|
+
if (cacheKey !== this.getCacheKey(projectId)) continue;
|
|
15270
|
+
console.error(`[PolicyFetcher] Failed to fetch policy for ${projectId}:`, error);
|
|
15271
|
+
if (this.config.throwOnUnavailable) throw new PolicyUnavailableError();
|
|
15272
|
+
return this.getDefaultPolicy();
|
|
15273
|
+
}
|
|
13859
15274
|
}
|
|
13860
|
-
|
|
13861
|
-
}
|
|
13862
|
-
|
|
13863
|
-
return this.getDefaultPolicy();
|
|
15275
|
+
throw new PolicyUnavailableError();
|
|
15276
|
+
} finally {
|
|
15277
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
13864
15278
|
}
|
|
13865
15279
|
}
|
|
13866
15280
|
/**
|
|
13867
15281
|
* Fetch policy from the API
|
|
13868
15282
|
*/
|
|
13869
|
-
async fetchPolicyFromApi(projectId) {
|
|
15283
|
+
async fetchPolicyFromApi(projectId, signal) {
|
|
13870
15284
|
const url = `${this.config.apiBaseUrl}/api/internal/policies/${projectId}`;
|
|
13871
15285
|
const headers = {
|
|
13872
15286
|
"Content-Type": "application/json",
|
|
@@ -13876,7 +15290,8 @@ var PolicyFetcher = class {
|
|
|
13876
15290
|
const response = await this.config.fetchFn(url, {
|
|
13877
15291
|
method: "GET",
|
|
13878
15292
|
headers,
|
|
13879
|
-
signal
|
|
15293
|
+
signal,
|
|
15294
|
+
cache: "no-store"
|
|
13880
15295
|
});
|
|
13881
15296
|
if (!response.ok) throw new Error(`API returned ${response.status}: ${response.statusText}`);
|
|
13882
15297
|
const data = await response.json();
|
|
@@ -13891,16 +15306,23 @@ var PolicyFetcher = class {
|
|
|
13891
15306
|
return PolicyConfigSchema.parse(DEFAULT_POLICY);
|
|
13892
15307
|
}
|
|
13893
15308
|
/**
|
|
13894
|
-
*
|
|
13895
|
-
*
|
|
15309
|
+
* Retire this runtime's cached policy key before any asynchronous cleanup.
|
|
15310
|
+
* Older reads and writes cannot restore the retired entry for these fetchers.
|
|
13896
15311
|
*/
|
|
13897
15312
|
async invalidateCache(projectId) {
|
|
13898
15313
|
const cacheKey = this.getCacheKey(projectId);
|
|
13899
|
-
|
|
13900
|
-
|
|
13901
|
-
|
|
13902
|
-
|
|
13903
|
-
|
|
15314
|
+
const baseKey = this.getBaseCacheKey(projectId);
|
|
15315
|
+
globalPolicyCacheKeys.set(baseKey, `${baseKey}:${nextCacheRevision()}`);
|
|
15316
|
+
globalMemoryCache.delete(cacheKey);
|
|
15317
|
+
if (this.config.cacheAdapter?.delete) {
|
|
15318
|
+
const keys = cacheKey === baseKey ? [baseKey] : [cacheKey, baseKey];
|
|
15319
|
+
await Promise.all(keys.map(async (key) => {
|
|
15320
|
+
try {
|
|
15321
|
+
await this.config.cacheAdapter.delete(key);
|
|
15322
|
+
} catch (error) {
|
|
15323
|
+
console.error("[PolicyFetcher] Failed to delete from external cache:", error);
|
|
15324
|
+
}
|
|
15325
|
+
}));
|
|
13904
15326
|
}
|
|
13905
15327
|
}
|
|
13906
15328
|
/**
|
|
@@ -14228,6 +15650,34 @@ const KYA_HTTP_ERROR = {
|
|
|
14228
15650
|
INVALID_SESSION: "kyaos/invalid-session",
|
|
14229
15651
|
PICKUP_EXPIRED: "kyaos/pickup-expired"
|
|
14230
15652
|
};
|
|
15653
|
+
/**
|
|
15654
|
+
* The HTTP status the registry assigns each code (draft-kya-http-02 §9).
|
|
15655
|
+
* Mirrors `error-codes.json` exactly, pinned by `__tests__/kya-http-error-codes.test.ts`,
|
|
15656
|
+
* and matches the engine's own table (`rust/crates/kya-os-engine/src/render/kya_error.rs`).
|
|
15657
|
+
*/
|
|
15658
|
+
const KYA_HTTP_ERROR_STATUS = {
|
|
15659
|
+
[KYA_HTTP_ERROR.MISSING_SIGNATURE]: 401,
|
|
15660
|
+
[KYA_HTTP_ERROR.INVALID_SIGNATURE]: 401,
|
|
15661
|
+
[KYA_HTTP_ERROR.EXPIRED]: 401,
|
|
15662
|
+
[KYA_HTTP_ERROR.REPLAY]: 401,
|
|
15663
|
+
[KYA_HTTP_ERROR.DID_UNRESOLVABLE]: 401,
|
|
15664
|
+
[KYA_HTTP_ERROR.AUTHORIZATION_REQUIRED]: 401,
|
|
15665
|
+
[KYA_HTTP_ERROR.PROFILE_VIOLATION]: 403,
|
|
15666
|
+
[KYA_HTTP_ERROR.DELEGATION_REVOKED]: 403,
|
|
15667
|
+
[KYA_HTTP_ERROR.SCOPE_INSUFFICIENT]: 403,
|
|
15668
|
+
[KYA_HTTP_ERROR.CHAIN_BROKEN]: 403,
|
|
15669
|
+
[KYA_HTTP_ERROR.HOLDER_MISMATCH]: 403,
|
|
15670
|
+
[KYA_HTTP_ERROR.AUDIENCE_MISMATCH]: 403,
|
|
15671
|
+
[KYA_HTTP_ERROR.SESSION_MISMATCH]: 403,
|
|
15672
|
+
[KYA_HTTP_ERROR.PICKUP_PINNED]: 403,
|
|
15673
|
+
[KYA_HTTP_ERROR.ASSURANCE_INSUFFICIENT]: 403,
|
|
15674
|
+
[KYA_HTTP_ERROR.STATUS_PENDING]: 503,
|
|
15675
|
+
[KYA_HTTP_ERROR.AUTHORIZATION_HOST_UNAVAILABLE]: 503,
|
|
15676
|
+
[KYA_HTTP_ERROR.REPLAY_STATE_UNAVAILABLE]: 503,
|
|
15677
|
+
[KYA_HTTP_ERROR.REPLAY_CAPACITY]: 429,
|
|
15678
|
+
[KYA_HTTP_ERROR.INVALID_SESSION]: 404,
|
|
15679
|
+
[KYA_HTTP_ERROR.PICKUP_EXPIRED]: 410
|
|
15680
|
+
};
|
|
14231
15681
|
|
|
14232
15682
|
//#endregion
|
|
14233
15683
|
//#region src/host-adapter/challenge-wire.ts
|
|
@@ -14641,12 +16091,6 @@ const USER_ID_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,253}[A-Za-z0-9])?$/;
|
|
|
14641
16091
|
* Build a user's `did:web` DID under the org's DID tree. Resolves to
|
|
14642
16092
|
* `https://kya.vouched.id/orgs/<slug>/users/<userId>/did.json`.
|
|
14643
16093
|
*
|
|
14644
|
-
* Standard requires `did:web` or `did:key` for any DID we emit (no ad-hoc
|
|
14645
|
-
* methods); this extends the org-scoped did:web tree rather than introducing
|
|
14646
|
-
* a new method. The per-user did.json route is not served yet — verifiers
|
|
14647
|
-
* resolving this DID get a 404 today. Acceptable while there are no external
|
|
14648
|
-
* verifiers; the route lands alongside E5.3 (HTTP intent verification).
|
|
14649
|
-
*
|
|
14650
16094
|
* Throws on invalid slug or userId so the bad shape never reaches the wire.
|
|
14651
16095
|
*/
|
|
14652
16096
|
function deriveMcpiUserDid(slug, userId) {
|
|
@@ -15381,11 +16825,1479 @@ function parseJafarFeed(json) {
|
|
|
15381
16825
|
return result.data;
|
|
15382
16826
|
}
|
|
15383
16827
|
|
|
16828
|
+
//#endregion
|
|
16829
|
+
//#region src/api/artifact-bindings.ts
|
|
16830
|
+
/** I1 additive wire records. Parsing does not establish authority or reviewer trust. */
|
|
16831
|
+
const Id$1 = string().min(1).max(256).regex(/^[\x21-\x7e]+$/);
|
|
16832
|
+
const Count$1 = number$1().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
16833
|
+
const Revision$1 = Count$1.positive();
|
|
16834
|
+
const ContentDigest = string().length(64).regex(/^[a-f0-9]{64}$/);
|
|
16835
|
+
const RecordDigest$1 = string().length(71).regex(/^sha256:[a-f0-9]{64}$/);
|
|
16836
|
+
const AcceptanceId$1 = string().length(68).regex(/^acc:[a-f0-9]{64}$/);
|
|
16837
|
+
const GitObjectId = string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/).refine((v) => v.length === 40 || v.length === 64);
|
|
16838
|
+
const Kind = _enum([
|
|
16839
|
+
"workspace_snapshot",
|
|
16840
|
+
"commit",
|
|
16841
|
+
"pull_request",
|
|
16842
|
+
"test_report",
|
|
16843
|
+
"package",
|
|
16844
|
+
"document"
|
|
16845
|
+
]);
|
|
16846
|
+
const ImmutableArtifactLocatorSchema = discriminatedUnion("type", [
|
|
16847
|
+
object({
|
|
16848
|
+
type: literal("local_snapshot"),
|
|
16849
|
+
digest: ContentDigest
|
|
16850
|
+
}).strict(),
|
|
16851
|
+
object({
|
|
16852
|
+
type: literal("git_commit"),
|
|
16853
|
+
objectId: GitObjectId
|
|
16854
|
+
}).strict(),
|
|
16855
|
+
object({
|
|
16856
|
+
type: literal("pull_request_head"),
|
|
16857
|
+
repositoryId: Id$1,
|
|
16858
|
+
number: Revision$1,
|
|
16859
|
+
headObjectId: GitObjectId
|
|
16860
|
+
}).strict(),
|
|
16861
|
+
object({
|
|
16862
|
+
type: literal("content_blob"),
|
|
16863
|
+
digest: ContentDigest
|
|
16864
|
+
}).strict()
|
|
16865
|
+
]);
|
|
16866
|
+
const ArtifactIdentitySchema = object({
|
|
16867
|
+
kind: Kind,
|
|
16868
|
+
repositoryId: Id$1,
|
|
16869
|
+
baseCommit: GitObjectId,
|
|
16870
|
+
contentDigest: ContentDigest,
|
|
16871
|
+
locator: ImmutableArtifactLocatorSchema
|
|
16872
|
+
}).strict().superRefine((v, ctx) => {
|
|
16873
|
+
const expected = {
|
|
16874
|
+
workspace_snapshot: "local_snapshot",
|
|
16875
|
+
commit: "git_commit",
|
|
16876
|
+
pull_request: "pull_request_head",
|
|
16877
|
+
test_report: "content_blob",
|
|
16878
|
+
package: "content_blob",
|
|
16879
|
+
document: "content_blob"
|
|
16880
|
+
}[v.kind];
|
|
16881
|
+
if (v.locator.type !== expected) ctx.addIssue({
|
|
16882
|
+
code: ZodIssueCode.custom,
|
|
16883
|
+
message: "Artifact kind and locator disagree"
|
|
16884
|
+
});
|
|
16885
|
+
if ((v.locator.type === "local_snapshot" || v.locator.type === "content_blob") && v.locator.digest !== v.contentDigest) ctx.addIssue({
|
|
16886
|
+
code: ZodIssueCode.custom,
|
|
16887
|
+
message: "Locator does not identify content"
|
|
16888
|
+
});
|
|
16889
|
+
if (v.locator.type === "pull_request_head" && v.locator.repositoryId !== v.repositoryId) ctx.addIssue({
|
|
16890
|
+
code: ZodIssueCode.custom,
|
|
16891
|
+
message: "Pull request repository mismatch"
|
|
16892
|
+
});
|
|
16893
|
+
});
|
|
16894
|
+
const AcceptedArtifactRevisionSchema = object({
|
|
16895
|
+
schemaVersion: literal(1),
|
|
16896
|
+
acceptanceId: AcceptanceId$1,
|
|
16897
|
+
taskId: Id$1,
|
|
16898
|
+
specRevision: Revision$1,
|
|
16899
|
+
manifestDigest: RecordDigest$1,
|
|
16900
|
+
trackGeneration: Revision$1.nullable(),
|
|
16901
|
+
artifact: ArtifactIdentitySchema,
|
|
16902
|
+
reviewDigest: RecordDigest$1,
|
|
16903
|
+
reviewer: Id$1,
|
|
16904
|
+
acceptedAtMs: Count$1,
|
|
16905
|
+
supersedes: AcceptanceId$1.nullable()
|
|
16906
|
+
}).strict().refine((v) => v.supersedes !== v.acceptanceId, "Acceptance cannot supersede itself");
|
|
16907
|
+
const AcceptanceWithdrawalSchema = object({
|
|
16908
|
+
schemaVersion: literal(1),
|
|
16909
|
+
acceptanceId: AcceptanceId$1,
|
|
16910
|
+
reason: string().min(1).max(4096),
|
|
16911
|
+
triggerTaskId: Id$1,
|
|
16912
|
+
withdrawnBy: Id$1,
|
|
16913
|
+
withdrawnAtMs: Count$1
|
|
16914
|
+
}).strict();
|
|
16915
|
+
const ConsumedArtifactSchema = object({
|
|
16916
|
+
prerequisiteTaskId: Id$1,
|
|
16917
|
+
prerequisiteSpecRevision: Revision$1,
|
|
16918
|
+
requirement: _enum(["accepted_patch", "merged"]),
|
|
16919
|
+
acceptanceId: AcceptanceId$1,
|
|
16920
|
+
repositoryId: Id$1,
|
|
16921
|
+
kind: Kind,
|
|
16922
|
+
contentDigest: ContentDigest,
|
|
16923
|
+
mergedCommit: GitObjectId.nullable()
|
|
16924
|
+
}).strict().refine((v) => v.requirement === "merged" === (v.mergedCommit !== null), "Merge evidence is required exactly for merged prerequisites");
|
|
16925
|
+
const DependencyBindingSchema = object({
|
|
16926
|
+
schemaVersion: literal(1),
|
|
16927
|
+
bindingId: string().length(69).regex(/^bind:[a-f0-9]{64}$/),
|
|
16928
|
+
dependentTaskId: Id$1,
|
|
16929
|
+
dependentSpecRevision: Revision$1,
|
|
16930
|
+
trackId: Id$1,
|
|
16931
|
+
trackGeneration: Revision$1,
|
|
16932
|
+
consumed: array(ConsumedArtifactSchema).min(1).max(2e3),
|
|
16933
|
+
materializationPlanDigest: RecordDigest$1
|
|
16934
|
+
}).strict().superRefine((v, ctx) => {
|
|
16935
|
+
let previous;
|
|
16936
|
+
for (const row of v.consumed) {
|
|
16937
|
+
const slot = [
|
|
16938
|
+
row.prerequisiteTaskId,
|
|
16939
|
+
row.repositoryId,
|
|
16940
|
+
row.kind
|
|
16941
|
+
];
|
|
16942
|
+
const order = previous && compareSlot(previous, slot);
|
|
16943
|
+
if (order !== void 0 && order >= 0) ctx.addIssue({
|
|
16944
|
+
code: ZodIssueCode.custom,
|
|
16945
|
+
message: "Consumed artifact slots must be unique and sorted"
|
|
16946
|
+
});
|
|
16947
|
+
if (row.prerequisiteTaskId === v.dependentTaskId) ctx.addIssue({
|
|
16948
|
+
code: ZodIssueCode.custom,
|
|
16949
|
+
message: "Self dependency"
|
|
16950
|
+
});
|
|
16951
|
+
previous = slot;
|
|
16952
|
+
}
|
|
16953
|
+
});
|
|
16954
|
+
function compareSlot(a, b) {
|
|
16955
|
+
for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return a[i] < b[i] ? -1 : 1;
|
|
16956
|
+
return 0;
|
|
16957
|
+
}
|
|
16958
|
+
/**
|
|
16959
|
+
* Why a binding no longer matches the graph and acceptance ledger (D2). A stale
|
|
16960
|
+
* binding is reviewed and replaced, never silently rebound.
|
|
16961
|
+
*/
|
|
16962
|
+
const StaleReasonSchema = discriminatedUnion("type", [
|
|
16963
|
+
object({
|
|
16964
|
+
type: literal("track_mismatch"),
|
|
16965
|
+
bindingTrackId: Id$1,
|
|
16966
|
+
trackId: Id$1
|
|
16967
|
+
}).strict(),
|
|
16968
|
+
object({ type: literal("dependent_removed") }).strict(),
|
|
16969
|
+
object({
|
|
16970
|
+
type: literal("dependent_revision_changed"),
|
|
16971
|
+
from: Revision$1,
|
|
16972
|
+
to: Revision$1
|
|
16973
|
+
}).strict(),
|
|
16974
|
+
object({
|
|
16975
|
+
type: literal("edge_added"),
|
|
16976
|
+
prerequisiteTaskId: Id$1
|
|
16977
|
+
}).strict(),
|
|
16978
|
+
object({
|
|
16979
|
+
type: literal("edge_removed"),
|
|
16980
|
+
prerequisiteTaskId: Id$1
|
|
16981
|
+
}).strict(),
|
|
16982
|
+
object({
|
|
16983
|
+
type: literal("prerequisite_revision_changed"),
|
|
16984
|
+
taskId: Id$1,
|
|
16985
|
+
from: Revision$1,
|
|
16986
|
+
to: Revision$1
|
|
16987
|
+
}).strict(),
|
|
16988
|
+
object({
|
|
16989
|
+
type: literal("requirement_changed"),
|
|
16990
|
+
prerequisiteTaskId: Id$1
|
|
16991
|
+
}).strict(),
|
|
16992
|
+
object({
|
|
16993
|
+
type: literal("acceptance_withdrawn"),
|
|
16994
|
+
acceptanceId: AcceptanceId$1
|
|
16995
|
+
}).strict(),
|
|
16996
|
+
object({
|
|
16997
|
+
type: literal("acceptance_superseded"),
|
|
16998
|
+
acceptanceId: AcceptanceId$1,
|
|
16999
|
+
by: AcceptanceId$1
|
|
17000
|
+
}).strict(),
|
|
17001
|
+
object({
|
|
17002
|
+
type: literal("acceptance_unknown"),
|
|
17003
|
+
acceptanceId: AcceptanceId$1
|
|
17004
|
+
}).strict(),
|
|
17005
|
+
object({
|
|
17006
|
+
type: literal("acceptance_mismatch"),
|
|
17007
|
+
acceptanceId: AcceptanceId$1
|
|
17008
|
+
}).strict()
|
|
17009
|
+
]).superRefine((v, ctx) => {
|
|
17010
|
+
if (v.type === "track_mismatch" && v.bindingTrackId === v.trackId || (v.type === "dependent_revision_changed" || v.type === "prerequisite_revision_changed") && v.from === v.to || v.type === "acceptance_superseded" && v.acceptanceId === v.by) ctx.addIssue({
|
|
17011
|
+
code: ZodIssueCode.custom,
|
|
17012
|
+
message: "A stale reason must name a change"
|
|
17013
|
+
});
|
|
17014
|
+
});
|
|
17015
|
+
/** One to 2000 distinct reasons. */
|
|
17016
|
+
const StaleReasonsSchema = array(StaleReasonSchema).min(1).max(2e3).refine((reasons) => new Set(reasons.map(canonical)).size === reasons.length, "Duplicate stale reason");
|
|
17017
|
+
const BindingStatusSchema = discriminatedUnion("state", [object({ state: literal("current") }).strict(), object({
|
|
17018
|
+
state: literal("stale"),
|
|
17019
|
+
reasons: StaleReasonsSchema
|
|
17020
|
+
}).strict()]);
|
|
17021
|
+
function canonical(value) {
|
|
17022
|
+
if (Array.isArray(value)) return "[" + value.map(canonical).join(",") + "]";
|
|
17023
|
+
if (value !== null && typeof value === "object") {
|
|
17024
|
+
const object = value;
|
|
17025
|
+
return "{" + Object.keys(object).sort().map((k) => JSON.stringify(k) + ":" + canonical(object[k])).join(",") + "}";
|
|
17026
|
+
}
|
|
17027
|
+
const result = JSON.stringify(value);
|
|
17028
|
+
if (result === void 0) throw new Error("Unsupported canonical value");
|
|
17029
|
+
return result;
|
|
17030
|
+
}
|
|
17031
|
+
/** Lowercase SHA-256 hex of the value's canonical (RFC8785) form. */
|
|
17032
|
+
async function contractDigest(value) {
|
|
17033
|
+
const hash = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(canonical(value)));
|
|
17034
|
+
return Array.from(new Uint8Array(hash), (b) => b.toString(16).padStart(2, "0")).join("");
|
|
17035
|
+
}
|
|
17036
|
+
async function verifyContractRecordIdentity(record, field, prefix) {
|
|
17037
|
+
const body = { ...record };
|
|
17038
|
+
delete body[field];
|
|
17039
|
+
if (record[field] !== prefix + await contractDigest(body)) throw new Error("Record identity does not match canonical content");
|
|
17040
|
+
}
|
|
17041
|
+
/** Use this boundary before storing/admitting a record; shape validation alone is insufficient. */
|
|
17042
|
+
async function parseAcceptedArtifactRevision(input) {
|
|
17043
|
+
const value = AcceptedArtifactRevisionSchema.parse(input);
|
|
17044
|
+
await verifyContractRecordIdentity(value, "acceptanceId", "acc:");
|
|
17045
|
+
return value;
|
|
17046
|
+
}
|
|
17047
|
+
async function parseDependencyBinding(input) {
|
|
17048
|
+
const value = DependencyBindingSchema.parse(input);
|
|
17049
|
+
await verifyContractRecordIdentity(value, "bindingId", "bind:");
|
|
17050
|
+
return value;
|
|
17051
|
+
}
|
|
17052
|
+
|
|
17053
|
+
//#endregion
|
|
17054
|
+
//#region src/api/graph-interfaces.ts
|
|
17055
|
+
const Id = string().min(1).max(256).regex(/^[\x21-\x7e]+$/);
|
|
17056
|
+
const Count = number$1().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
17057
|
+
const Revision = Count.positive();
|
|
17058
|
+
const Digest = string().length(64).regex(/^[a-f0-9]{64}$/);
|
|
17059
|
+
const RecordDigest = string().length(71).regex(/^sha256:[a-f0-9]{64}$/);
|
|
17060
|
+
const AcceptanceId = string().length(68).regex(/^acc:[a-f0-9]{64}$/);
|
|
17061
|
+
const GitObject = string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/).refine((v) => v.length === 40 || v.length === 64);
|
|
17062
|
+
const Text = string().min(1).max(4096);
|
|
17063
|
+
const ClaimUri = Text.refine((uri) => {
|
|
17064
|
+
if ([...uri].some((character) => {
|
|
17065
|
+
const code = character.charCodeAt(0);
|
|
17066
|
+
return code <= 32 || code === 127 || character === "\\";
|
|
17067
|
+
}) || uri.startsWith("//")) return false;
|
|
17068
|
+
try {
|
|
17069
|
+
const parsed = new URL(uri);
|
|
17070
|
+
return ["https:", "http:"].includes(parsed.protocol) && !!parsed.hostname && !parsed.username && !parsed.password;
|
|
17071
|
+
} catch {
|
|
17072
|
+
return !uri.includes(":");
|
|
17073
|
+
}
|
|
17074
|
+
}, "Evidence must be an HTTP(S) or inert relative reference");
|
|
17075
|
+
const Path = string().min(1).max(4096).refine((v) => !v.includes("\\") && !v.includes(":") && !v.split("/").some((p) => !p || p === "." || p === ".." || p.toLowerCase() === ".git") && [...v].every((c) => c.charCodeAt(0) >= 32 && c.charCodeAt(0) !== 127), "Unsafe materialization path");
|
|
17076
|
+
const unique = (items) => new Set(items).size === items.length;
|
|
17077
|
+
/** Unicode code point order, which is UTF-8 byte order and Rust `str` order. */
|
|
17078
|
+
function compareCodePoints(a, b) {
|
|
17079
|
+
const left = Array.from(a, (c) => c.codePointAt(0));
|
|
17080
|
+
const right = Array.from(b, (c) => c.codePointAt(0));
|
|
17081
|
+
for (let i = 0; i < Math.min(left.length, right.length); i++) if (left[i] !== right[i]) return left[i] - right[i];
|
|
17082
|
+
return left.length - right.length;
|
|
17083
|
+
}
|
|
17084
|
+
/** Strictly ascending, so each path appears at most once. */
|
|
17085
|
+
const canonicalPaths = (paths) => paths.every((path, i) => i === 0 || compareCodePoints(paths[i - 1], path) < 0);
|
|
17086
|
+
const Ids = array(Id).max(2e3).refine(unique, "Duplicate identity");
|
|
17087
|
+
const TrackDependencyV2Schema = object({
|
|
17088
|
+
prerequisiteTaskId: Id,
|
|
17089
|
+
dependentTaskId: Id,
|
|
17090
|
+
requirement: _enum(["accepted_patch", "merged"]),
|
|
17091
|
+
origin: _enum([
|
|
17092
|
+
"source",
|
|
17093
|
+
"local_edit",
|
|
17094
|
+
"decomposition",
|
|
17095
|
+
"lead_proposal"
|
|
17096
|
+
])
|
|
17097
|
+
}).strict().refine((v) => v.prerequisiteTaskId !== v.dependentTaskId, "Self dependency");
|
|
17098
|
+
const IssueId = string().length(70).regex(/^issue:[a-f0-9]{64}$/);
|
|
17099
|
+
const ImportIssueV2Schema = object({
|
|
17100
|
+
issueId: IssueId,
|
|
17101
|
+
taskId: Id.nullable(),
|
|
17102
|
+
code: Id,
|
|
17103
|
+
message: Text,
|
|
17104
|
+
origin: _enum(["import_diagnostic", "reviewer_question"]),
|
|
17105
|
+
blocking: boolean$1()
|
|
17106
|
+
}).strict();
|
|
17107
|
+
const MaterializationPlanSchema = object({
|
|
17108
|
+
schemaVersion: literal(1),
|
|
17109
|
+
repositoryId: Id,
|
|
17110
|
+
baseCommit: GitObject,
|
|
17111
|
+
order: array(AcceptanceId).min(1).max(2e3).refine(unique, "Duplicate acceptance"),
|
|
17112
|
+
entries: array(object({
|
|
17113
|
+
path: Path,
|
|
17114
|
+
sourceAcceptanceId: AcceptanceId,
|
|
17115
|
+
kind: _enum([
|
|
17116
|
+
"file",
|
|
17117
|
+
"executable",
|
|
17118
|
+
"delete"
|
|
17119
|
+
]),
|
|
17120
|
+
contentDigest: Digest.nullable()
|
|
17121
|
+
}).strict().refine((v) => v.kind === "delete" === (v.contentDigest === null), "Deletion must not name content")).max(1e4),
|
|
17122
|
+
conflicts: array(object({
|
|
17123
|
+
path: Path,
|
|
17124
|
+
acceptanceIds: array(AcceptanceId).min(2).max(2e3).refine(unique),
|
|
17125
|
+
reason: _enum([
|
|
17126
|
+
"divergent_content",
|
|
17127
|
+
"delete_modify",
|
|
17128
|
+
"type_change"
|
|
17129
|
+
])
|
|
17130
|
+
}).strict()).max(1e4),
|
|
17131
|
+
planDigest: RecordDigest
|
|
17132
|
+
}).strict().superRefine((v, ctx) => {
|
|
17133
|
+
if (!canonicalPaths(v.entries.map((e) => e.path)) || !canonicalPaths(v.conflicts.map((c) => c.path))) ctx.addIssue({
|
|
17134
|
+
code: ZodIssueCode.custom,
|
|
17135
|
+
message: "Planned entries and conflicts must be unique and in canonical path order"
|
|
17136
|
+
});
|
|
17137
|
+
const planned = new Set(v.entries.map((e) => e.path));
|
|
17138
|
+
if (v.conflicts.some((c) => planned.has(c.path))) ctx.addIssue({
|
|
17139
|
+
code: ZodIssueCode.custom,
|
|
17140
|
+
message: "A path is either planned or in conflict, never both"
|
|
17141
|
+
});
|
|
17142
|
+
if (v.entries.some((e) => !v.order.includes(e.sourceAcceptanceId)) || v.conflicts.some((c) => c.acceptanceIds.some((id) => !v.order.includes(id)))) ctx.addIssue({
|
|
17143
|
+
code: ZodIssueCode.custom,
|
|
17144
|
+
message: "Unknown source acceptance"
|
|
17145
|
+
});
|
|
17146
|
+
});
|
|
17147
|
+
const ReconciliationDecisionSetSchema = object({
|
|
17148
|
+
schemaVersion: literal(1),
|
|
17149
|
+
importId: Id,
|
|
17150
|
+
expectedGeneration: Revision,
|
|
17151
|
+
expectedDraftDigest: RecordDigest,
|
|
17152
|
+
conflicts: array(object({
|
|
17153
|
+
conflictId: Id,
|
|
17154
|
+
choice: _enum([
|
|
17155
|
+
"base",
|
|
17156
|
+
"local",
|
|
17157
|
+
"incoming"
|
|
17158
|
+
])
|
|
17159
|
+
}).strict()).max(2e3),
|
|
17160
|
+
removals: array(object({
|
|
17161
|
+
taskId: Id,
|
|
17162
|
+
decision: _enum(["remove_from_track", "retain_as_local"])
|
|
17163
|
+
}).strict()).max(2e3),
|
|
17164
|
+
issues: array(object({
|
|
17165
|
+
issueId: Id,
|
|
17166
|
+
action: discriminatedUnion("type", [object({ type: literal("keep") }).strict(), object({
|
|
17167
|
+
type: literal("resolve"),
|
|
17168
|
+
note: Text
|
|
17169
|
+
}).strict()])
|
|
17170
|
+
}).strict()).max(2e3),
|
|
17171
|
+
decidedBy: Id,
|
|
17172
|
+
decidedAtMs: Count
|
|
17173
|
+
}).strict().refine((v) => unique(v.conflicts.map((c) => c.conflictId)) && unique(v.removals.map((r) => r.taskId)) && unique(v.issues.map((i) => i.issueId)), "Duplicate reconciliation decision");
|
|
17174
|
+
const ClaimVerificationSchema = object({
|
|
17175
|
+
schemaVersion: literal(1),
|
|
17176
|
+
verificationId: string().length(71).regex(/^claimv:[a-f0-9]{64}$/),
|
|
17177
|
+
taskId: Id,
|
|
17178
|
+
specRevision: Revision,
|
|
17179
|
+
claim: object({
|
|
17180
|
+
uri: ClaimUri,
|
|
17181
|
+
label: string().max(4096).nullable()
|
|
17182
|
+
}).strict(),
|
|
17183
|
+
subject: object({
|
|
17184
|
+
repositoryId: Id,
|
|
17185
|
+
locator: ImmutableArtifactLocatorSchema
|
|
17186
|
+
}).strict().nullable(),
|
|
17187
|
+
criteriaIds: Ids,
|
|
17188
|
+
checkReceiptIds: Ids,
|
|
17189
|
+
verdict: _enum([
|
|
17190
|
+
"valid",
|
|
17191
|
+
"invalid",
|
|
17192
|
+
"indeterminate"
|
|
17193
|
+
]),
|
|
17194
|
+
reasons: array(Text).max(2e3),
|
|
17195
|
+
reviewer: Id.nullable(),
|
|
17196
|
+
reviewedAtMs: Count.nullable()
|
|
17197
|
+
}).strict().superRefine((v, ctx) => {
|
|
17198
|
+
if (v.reviewer === null !== (v.reviewedAtMs === null)) ctx.addIssue({
|
|
17199
|
+
code: ZodIssueCode.custom,
|
|
17200
|
+
message: "Incomplete review attestation"
|
|
17201
|
+
});
|
|
17202
|
+
if (v.verdict === "valid" && (!v.subject || !v.criteriaIds.length || !v.checkReceiptIds.length || !v.reviewer)) ctx.addIssue({
|
|
17203
|
+
code: ZodIssueCode.custom,
|
|
17204
|
+
message: "Valid claims require pinned subject, criteria, checks and review"
|
|
17205
|
+
});
|
|
17206
|
+
if (v.subject?.locator.type === "pull_request_head" && v.subject.repositoryId !== v.subject.locator.repositoryId) ctx.addIssue({
|
|
17207
|
+
code: ZodIssueCode.custom,
|
|
17208
|
+
message: "Claim repository mismatch"
|
|
17209
|
+
});
|
|
17210
|
+
});
|
|
17211
|
+
const ChildState = discriminatedUnion("type", [
|
|
17212
|
+
object({
|
|
17213
|
+
type: literal("accepted"),
|
|
17214
|
+
acceptanceId: AcceptanceId
|
|
17215
|
+
}).strict(),
|
|
17216
|
+
object({ type: literal("pending") }).strict(),
|
|
17217
|
+
object({
|
|
17218
|
+
type: literal("blocked"),
|
|
17219
|
+
reasons: array(Text).min(1).max(2e3)
|
|
17220
|
+
}).strict(),
|
|
17221
|
+
object({
|
|
17222
|
+
type: literal("stale"),
|
|
17223
|
+
reasons: StaleReasonsSchema
|
|
17224
|
+
}).strict()
|
|
17225
|
+
]);
|
|
17226
|
+
const ParentIntegrationStatusSchema = object({
|
|
17227
|
+
schemaVersion: literal(1),
|
|
17228
|
+
parentTaskId: Id,
|
|
17229
|
+
parentSpecRevision: Revision,
|
|
17230
|
+
children: array(object({
|
|
17231
|
+
taskId: Id,
|
|
17232
|
+
repositoryId: Id,
|
|
17233
|
+
state: ChildState
|
|
17234
|
+
}).strict()).min(1).max(2e3),
|
|
17235
|
+
parentOnlyCriteria: array(object({
|
|
17236
|
+
criterionId: Id,
|
|
17237
|
+
evidence: RecordDigest.nullable()
|
|
17238
|
+
}).strict()).max(2e3),
|
|
17239
|
+
state: _enum([
|
|
17240
|
+
"not_started",
|
|
17241
|
+
"partial",
|
|
17242
|
+
"awaiting_integration",
|
|
17243
|
+
"satisfied",
|
|
17244
|
+
"stale"
|
|
17245
|
+
])
|
|
17246
|
+
}).strict().superRefine((v, ctx) => {
|
|
17247
|
+
if (!unique(v.children.map((c) => c.taskId)) || !unique(v.parentOnlyCriteria.map((c) => c.criterionId)) || v.children.some((c) => c.taskId === v.parentTaskId)) ctx.addIssue({
|
|
17248
|
+
code: ZodIssueCode.custom,
|
|
17249
|
+
message: "Invalid integration identities"
|
|
17250
|
+
});
|
|
17251
|
+
const accepted = v.children.filter((c) => c.state.type === "accepted").length;
|
|
17252
|
+
const expected = v.children.some((c) => c.state.type === "stale") ? "stale" : accepted === v.children.length ? v.parentOnlyCriteria.every((c) => c.evidence !== null) ? "satisfied" : "awaiting_integration" : accepted ? "partial" : "not_started";
|
|
17253
|
+
if (v.state !== expected) ctx.addIssue({
|
|
17254
|
+
code: ZodIssueCode.custom,
|
|
17255
|
+
message: "Integration state contradicts evidence"
|
|
17256
|
+
});
|
|
17257
|
+
});
|
|
17258
|
+
async function parseMaterializationPlan(input) {
|
|
17259
|
+
const value = MaterializationPlanSchema.parse(input);
|
|
17260
|
+
await verifyContractRecordIdentity(value, "planDigest", "sha256:");
|
|
17261
|
+
return value;
|
|
17262
|
+
}
|
|
17263
|
+
/** D7: `issue:` + SHA-256 of the canonical `{origin, taskId, code, message}`. */
|
|
17264
|
+
async function deriveImportIssueId(issue) {
|
|
17265
|
+
const { origin, taskId, code, message } = issue;
|
|
17266
|
+
return "issue:" + await contractDigest({
|
|
17267
|
+
origin,
|
|
17268
|
+
taskId,
|
|
17269
|
+
code,
|
|
17270
|
+
message
|
|
17271
|
+
});
|
|
17272
|
+
}
|
|
17273
|
+
/** D7: `conf:` + SHA-256 of the canonical `{taskId, field, base, local, incoming}`. */
|
|
17274
|
+
async function deriveConflictId(conflict) {
|
|
17275
|
+
const { taskId, field, base, local, incoming } = conflict;
|
|
17276
|
+
return "conf:" + await contractDigest({
|
|
17277
|
+
taskId,
|
|
17278
|
+
field,
|
|
17279
|
+
base,
|
|
17280
|
+
local,
|
|
17281
|
+
incoming
|
|
17282
|
+
});
|
|
17283
|
+
}
|
|
17284
|
+
/** Shape plus content identity; use before trusting an issue ID. */
|
|
17285
|
+
async function parseImportIssueV2(input) {
|
|
17286
|
+
const value = ImportIssueV2Schema.parse(input);
|
|
17287
|
+
if (value.issueId !== await deriveImportIssueId(value)) throw new Error("Record identity does not match canonical content");
|
|
17288
|
+
return value;
|
|
17289
|
+
}
|
|
17290
|
+
async function parseClaimVerification(input) {
|
|
17291
|
+
const value = ClaimVerificationSchema.parse(input);
|
|
17292
|
+
await verifyContractRecordIdentity(value, "verificationId", "claimv:");
|
|
17293
|
+
return value;
|
|
17294
|
+
}
|
|
17295
|
+
/** Reviewed claim-resolution mapping; it confers no repository access. HTTPS is the v1 transport profile. */
|
|
17296
|
+
const RepositoryIdentitySchema = object({
|
|
17297
|
+
schemaVersion: literal(1),
|
|
17298
|
+
repositoryId: Id,
|
|
17299
|
+
remote: string().min(1).max(4096).refine((value) => {
|
|
17300
|
+
try {
|
|
17301
|
+
const url = new URL(value);
|
|
17302
|
+
return url.protocol === "https:" && !url.username && !url.password && !url.search && !url.hash && !/[?#]/.test(value) && url.pathname.split("/").filter(Boolean).length >= 2 && url.href === value;
|
|
17303
|
+
} catch {
|
|
17304
|
+
return false;
|
|
17305
|
+
}
|
|
17306
|
+
}, "Expected a canonical credential-free HTTPS repository remote")
|
|
17307
|
+
}).strict();
|
|
17308
|
+
|
|
17309
|
+
//#endregion
|
|
17310
|
+
//#region src/api/linear-installation.ts
|
|
17311
|
+
const LinearInstallationProviderStatusSchema = _enum([
|
|
17312
|
+
"connected",
|
|
17313
|
+
"expired",
|
|
17314
|
+
"revoked"
|
|
17315
|
+
]);
|
|
17316
|
+
const LinearInstallationStatusReasonSchema = _enum([
|
|
17317
|
+
"uninstalled",
|
|
17318
|
+
"refresh_rejected",
|
|
17319
|
+
"token_rejected",
|
|
17320
|
+
"reinstall_required"
|
|
17321
|
+
]);
|
|
17322
|
+
/** Provider identity and credentials are obtained by the server-side OAuth callback. */
|
|
17323
|
+
const StartLinearInstallationSchema = object({
|
|
17324
|
+
projectId: string().uuid(),
|
|
17325
|
+
enabled: boolean$1().default(true),
|
|
17326
|
+
workflow: LinearInstallationWorkflowSchema
|
|
17327
|
+
}).strict();
|
|
17328
|
+
/** Additive replacement. C2 switches the route and retires the legacy configure body atomically. */
|
|
17329
|
+
const ConfigureLinearInstallationV2Schema = StartLinearInstallationSchema.extend({ installationId: string().uuid() }).strict();
|
|
17330
|
+
const LinearInstallationAuthorizationSchema = object({
|
|
17331
|
+
authorizationUrl: string().max(8192).url().refine((value) => {
|
|
17332
|
+
try {
|
|
17333
|
+
const url = new URL(value);
|
|
17334
|
+
return url.origin === "https://linear.app" && url.pathname === "/oauth/authorize" && !url.username && !url.password && !url.hash && [
|
|
17335
|
+
"client_id",
|
|
17336
|
+
"redirect_uri",
|
|
17337
|
+
"response_type",
|
|
17338
|
+
"scope",
|
|
17339
|
+
"state",
|
|
17340
|
+
"actor",
|
|
17341
|
+
"code_challenge",
|
|
17342
|
+
"code_challenge_method"
|
|
17343
|
+
].every((key) => url.searchParams.getAll(key).length === 1 && Boolean(url.searchParams.get(key))) && url.searchParams.get("response_type") === "code" && url.searchParams.get("actor") === "app" && url.searchParams.get("code_challenge_method") === "S256";
|
|
17344
|
+
} catch {
|
|
17345
|
+
return false;
|
|
17346
|
+
}
|
|
17347
|
+
}, "Expected the managed Linear app authorization with state and S256"),
|
|
17348
|
+
expiresAt: string().datetime()
|
|
17349
|
+
}).strict();
|
|
17350
|
+
/** Token-free owner/admin projection. This record is not a workload credential. */
|
|
17351
|
+
const LinearInstallationStatusSchema = object({
|
|
17352
|
+
installationId: string().uuid(),
|
|
17353
|
+
organizationId: string().uuid(),
|
|
17354
|
+
projectId: string().uuid(),
|
|
17355
|
+
provider: literal("linear"),
|
|
17356
|
+
workspaceId: string().min(1).max(255),
|
|
17357
|
+
appUserId: string().min(1).max(255),
|
|
17358
|
+
enabled: boolean$1(),
|
|
17359
|
+
providerStatus: LinearInstallationProviderStatusSchema,
|
|
17360
|
+
providerStatusReason: LinearInstallationStatusReasonSchema.nullable(),
|
|
17361
|
+
providerStatusChangedAt: string().datetime().nullable(),
|
|
17362
|
+
providerAuthenticatedAt: string().datetime().nullable(),
|
|
17363
|
+
accessTokenExpiresAt: string().datetime().nullable(),
|
|
17364
|
+
admissible: boolean$1(),
|
|
17365
|
+
workflow: LinearInstallationWorkflowSchema
|
|
17366
|
+
}).strict().refine((v) => v.admissible === (v.enabled && v.providerStatus === "connected"), "Admissibility contradicts installation policy and lifecycle");
|
|
17367
|
+
|
|
17368
|
+
//#endregion
|
|
17369
|
+
//#region src/api/management-session.ts
|
|
17370
|
+
/**
|
|
17371
|
+
* C3: a human management session for the KYA-OS CLI, distinct from project API keys, workload
|
|
17372
|
+
* proofs and the gateway's delegation tokens. Browser (loopback) and device pairing both bind
|
|
17373
|
+
* PKCE S256; access tokens are short-lived and refresh tokens rotate. Workloads never accept it.
|
|
17374
|
+
*/
|
|
17375
|
+
const MANAGEMENT_CLIENT_ID = "kya-os-cli";
|
|
17376
|
+
const MANAGEMENT_AUDIENCE = "urn:kya-os:checkpoint:management";
|
|
17377
|
+
const MANAGEMENT_ACCESS_PREFIX = "kyam_";
|
|
17378
|
+
const MANAGEMENT_REFRESH_PREFIX = "kyamr_";
|
|
17379
|
+
/** Seconds between device polls; `slow_down` adds 5 (RFC 8628 §3.5). */
|
|
17380
|
+
const MANAGEMENT_DEVICE_INTERVAL = 5;
|
|
17381
|
+
/** User codes avoid vowels and look-alike characters (RFC 8628 §6.1). */
|
|
17382
|
+
const MANAGEMENT_USER_CODE_ALPHABET = "BCDFGHJKLMNPQRSTVWXZ";
|
|
17383
|
+
const ManagementScopeSchema = _enum(["workbench.read", "workbench.manage"]);
|
|
17384
|
+
const Base64Url43 = string().length(43).regex(/^[A-Za-z0-9_-]{43}$/);
|
|
17385
|
+
const Verifier = string().min(43).max(128).regex(/^[A-Za-z0-9._~-]+$/);
|
|
17386
|
+
const Opaque = (prefix) => string().length(prefix.length + 43).regex(new RegExp(`^${prefix}[A-Za-z0-9_-]{43}$`));
|
|
17387
|
+
const ManagementAccessTokenSchema = Opaque(MANAGEMENT_ACCESS_PREFIX);
|
|
17388
|
+
const ManagementRefreshTokenSchema = Opaque(MANAGEMENT_REFRESH_PREFIX);
|
|
17389
|
+
const Timestamp$2 = string().datetime();
|
|
17390
|
+
const UserCode = string().regex(/^[BCDFGHJKLMNPQRSTVWXZ]{4}-[BCDFGHJKLMNPQRSTVWXZ]{4}$/);
|
|
17391
|
+
/** Space-separated, as in OAuth requests; at least one known scope, each once. */
|
|
17392
|
+
const ManagementScopeRequestSchema = string().max(128).transform((value, ctx) => {
|
|
17393
|
+
const scopes = value.split(" ").filter(Boolean);
|
|
17394
|
+
const parsed = array(ManagementScopeSchema).min(1).safeParse(scopes);
|
|
17395
|
+
if (!parsed.success || new Set(scopes).size !== scopes.length) {
|
|
17396
|
+
ctx.addIssue({
|
|
17397
|
+
code: ZodIssueCode.custom,
|
|
17398
|
+
message: "invalid scope"
|
|
17399
|
+
});
|
|
17400
|
+
return NEVER;
|
|
17401
|
+
}
|
|
17402
|
+
return parsed.data;
|
|
17403
|
+
});
|
|
17404
|
+
/** RFC 8252 loopback redirect: exact path, any port, never a hostname that could resolve. */
|
|
17405
|
+
const ManagementLoopbackRedirectSchema = string().max(64).regex(/^http:\/\/(127\.0\.0\.1|\[::1\]):([1-9][0-9]{0,4})\/callback$/).refine((value) => {
|
|
17406
|
+
const port = Number(/:(\d+)\/callback$/.exec(value)?.[1]);
|
|
17407
|
+
return port >= 1024 && port <= 65535;
|
|
17408
|
+
}, "Loopback port must be 1024-65535");
|
|
17409
|
+
const ManagementPrincipalSchema = object({
|
|
17410
|
+
userId: string().uuid(),
|
|
17411
|
+
organizationId: string().uuid(),
|
|
17412
|
+
projectIds: array(string().uuid()).min(1).max(50)
|
|
17413
|
+
}).strict().refine((value) => new Set(value.projectIds).size === value.projectIds.length, { message: "Each project appears once" });
|
|
17414
|
+
/**
|
|
17415
|
+
* A name the CLI proposes for a project the user creates at consent, usually the repository's.
|
|
17416
|
+
* Printable ASCII with no space at either end, so the CLI can check it the same way.
|
|
17417
|
+
*/
|
|
17418
|
+
const ManagementProjectNameSchema = string().min(1).max(100).regex(/^[\x21-\x7E]([\x20-\x7E]*[\x21-\x7E])?$/);
|
|
17419
|
+
/** Query of `GET /cli/management/authorize`, validated before the consent page renders. */
|
|
17420
|
+
const ManagementAuthorizeQuerySchema = object({
|
|
17421
|
+
response_type: literal("code"),
|
|
17422
|
+
client_id: literal(MANAGEMENT_CLIENT_ID),
|
|
17423
|
+
redirect_uri: ManagementLoopbackRedirectSchema,
|
|
17424
|
+
code_challenge: Base64Url43,
|
|
17425
|
+
code_challenge_method: literal("S256"),
|
|
17426
|
+
state: string().min(22).max(512),
|
|
17427
|
+
resource: string().url().max(256),
|
|
17428
|
+
scope: ManagementScopeRequestSchema,
|
|
17429
|
+
project_hint: string().uuid().optional(),
|
|
17430
|
+
/** Prefills the consent page's new-project name; the grant itself never depends on it. */
|
|
17431
|
+
project_name: ManagementProjectNameSchema.optional()
|
|
17432
|
+
}).strict();
|
|
17433
|
+
/** `POST /api/cli/management/device`. */
|
|
17434
|
+
const ManagementDeviceRequestSchema = object({
|
|
17435
|
+
clientId: literal(MANAGEMENT_CLIENT_ID),
|
|
17436
|
+
codeChallenge: Base64Url43,
|
|
17437
|
+
codeChallengeMethod: literal("S256"),
|
|
17438
|
+
scope: ManagementScopeRequestSchema,
|
|
17439
|
+
resource: string().url().max(256),
|
|
17440
|
+
projectHint: string().uuid().optional(),
|
|
17441
|
+
/** Prefills the consent page's new-project name, as `project_name` does for the browser. */
|
|
17442
|
+
projectName: ManagementProjectNameSchema.optional()
|
|
17443
|
+
}).strict();
|
|
17444
|
+
const ManagementDeviceResponseSchema = object({
|
|
17445
|
+
deviceCode: Base64Url43,
|
|
17446
|
+
userCode: UserCode,
|
|
17447
|
+
verificationUri: string().url(),
|
|
17448
|
+
verificationUriComplete: string().url(),
|
|
17449
|
+
expiresAt: Timestamp$2,
|
|
17450
|
+
interval: number$1().int().min(5).max(60)
|
|
17451
|
+
}).strict();
|
|
17452
|
+
/** `POST /api/cli/management/token`. */
|
|
17453
|
+
const ManagementTokenRequestSchema = discriminatedUnion("grantType", [
|
|
17454
|
+
object({
|
|
17455
|
+
grantType: literal("authorization_code"),
|
|
17456
|
+
code: Base64Url43,
|
|
17457
|
+
codeVerifier: Verifier,
|
|
17458
|
+
redirectUri: ManagementLoopbackRedirectSchema,
|
|
17459
|
+
clientId: literal(MANAGEMENT_CLIENT_ID)
|
|
17460
|
+
}).strict(),
|
|
17461
|
+
object({
|
|
17462
|
+
grantType: literal("device_code"),
|
|
17463
|
+
deviceCode: Base64Url43,
|
|
17464
|
+
codeVerifier: Verifier,
|
|
17465
|
+
clientId: literal(MANAGEMENT_CLIENT_ID)
|
|
17466
|
+
}).strict(),
|
|
17467
|
+
object({
|
|
17468
|
+
grantType: literal("refresh_token"),
|
|
17469
|
+
refreshToken: ManagementRefreshTokenSchema,
|
|
17470
|
+
clientId: literal(MANAGEMENT_CLIENT_ID)
|
|
17471
|
+
}).strict()
|
|
17472
|
+
]);
|
|
17473
|
+
const ManagementTokenResponseSchema = object({
|
|
17474
|
+
accessToken: ManagementAccessTokenSchema,
|
|
17475
|
+
tokenType: literal("Bearer"),
|
|
17476
|
+
expiresAt: Timestamp$2,
|
|
17477
|
+
refreshToken: ManagementRefreshTokenSchema,
|
|
17478
|
+
refreshExpiresAt: Timestamp$2,
|
|
17479
|
+
scope: array(ManagementScopeSchema).min(1).max(2),
|
|
17480
|
+
audience: literal(MANAGEMENT_AUDIENCE),
|
|
17481
|
+
issuer: string().url(),
|
|
17482
|
+
principal: ManagementPrincipalSchema,
|
|
17483
|
+
sessionId: string().uuid()
|
|
17484
|
+
}).strict();
|
|
17485
|
+
/** `POST /api/cli/management/revoke`: a Bearer access token, or this body once it expired. */
|
|
17486
|
+
const ManagementRevokeRequestSchema = object({ refreshToken: ManagementRefreshTokenSchema }).strict();
|
|
17487
|
+
/** `GET /api/cli/management/session`. */
|
|
17488
|
+
const ManagementSessionSchema = object({
|
|
17489
|
+
sessionId: string().uuid(),
|
|
17490
|
+
principal: ManagementPrincipalSchema,
|
|
17491
|
+
scope: array(ManagementScopeSchema).min(1).max(2),
|
|
17492
|
+
audience: literal(MANAGEMENT_AUDIENCE),
|
|
17493
|
+
issuer: string().url(),
|
|
17494
|
+
createdAt: Timestamp$2,
|
|
17495
|
+
expiresAt: Timestamp$2,
|
|
17496
|
+
refreshExpiresAt: Timestamp$2
|
|
17497
|
+
}).strict();
|
|
17498
|
+
/** `GET /api/cli/management/projects`: only the session's projects. */
|
|
17499
|
+
const ManagementProjectsSchema = object({
|
|
17500
|
+
organizationId: string().uuid(),
|
|
17501
|
+
projects: array(object({
|
|
17502
|
+
id: string().uuid(),
|
|
17503
|
+
name: string().min(1).max(255)
|
|
17504
|
+
}).strict()).max(50)
|
|
17505
|
+
}).strict();
|
|
17506
|
+
/**
|
|
17507
|
+
* `GET /api/cli/management/profile`: who the session belongs to, by name, so `kya-os whoami`
|
|
17508
|
+
* can show names next to the principal's IDs. The CLI ignores fields it does not know here
|
|
17509
|
+
* (unlike the session and projects responses), so this may grow without breaking it.
|
|
17510
|
+
*/
|
|
17511
|
+
const ManagementProfileSchema = object({
|
|
17512
|
+
userId: string().uuid(),
|
|
17513
|
+
email: string().min(1).max(255).optional(),
|
|
17514
|
+
name: string().min(1).max(255).optional(),
|
|
17515
|
+
organizationId: string().uuid(),
|
|
17516
|
+
organizationName: string().min(1).max(255).optional()
|
|
17517
|
+
}).strict();
|
|
17518
|
+
/**
|
|
17519
|
+
* What an app's runtime key is for, which fixes its permissions: `sdk` reads (detection,
|
|
17520
|
+
* enforcement, policy fetches); `mcp` also writes (server registration, proofs, sessions,
|
|
17521
|
+
* events).
|
|
17522
|
+
*/
|
|
17523
|
+
const ManagementRuntimeKeyPurposeSchema = _enum([
|
|
17524
|
+
"sdk",
|
|
17525
|
+
"mcp",
|
|
17526
|
+
"proxy"
|
|
17527
|
+
]);
|
|
17528
|
+
/**
|
|
17529
|
+
* `POST /api/cli/management/projects/{projectId}/runtime-keys`. `label` names where the key
|
|
17530
|
+
* will live (a host and repository), so each machine's key can be told apart and revoked alone.
|
|
17531
|
+
*/
|
|
17532
|
+
const ManagementRuntimeKeyRequestSchema = object({
|
|
17533
|
+
purpose: ManagementRuntimeKeyPurposeSchema,
|
|
17534
|
+
label: string().min(1).max(100).regex(/^[\x20-\x7E]+$/)
|
|
17535
|
+
}).strict();
|
|
17536
|
+
/** A minted project runtime key. `key` is returned once, here, and never again. */
|
|
17537
|
+
const ManagementRuntimeKeySchema = object({
|
|
17538
|
+
keyId: string().uuid(),
|
|
17539
|
+
projectId: string().uuid(),
|
|
17540
|
+
name: string().min(1).max(255),
|
|
17541
|
+
key: string().regex(/^sk_[0-9a-f]{64}$/),
|
|
17542
|
+
preview: string().min(1).max(20),
|
|
17543
|
+
permissions: array(_enum([
|
|
17544
|
+
"read",
|
|
17545
|
+
"write",
|
|
17546
|
+
"forward"
|
|
17547
|
+
])).min(1).max(2),
|
|
17548
|
+
createdAt: Timestamp$2
|
|
17549
|
+
}).strict();
|
|
17550
|
+
const ManagementPostureJwkSchema = object({
|
|
17551
|
+
kty: literal("EC"),
|
|
17552
|
+
crv: literal("P-256"),
|
|
17553
|
+
x: string(),
|
|
17554
|
+
y: string(),
|
|
17555
|
+
kid: string().min(1),
|
|
17556
|
+
alg: literal("ES256"),
|
|
17557
|
+
use: literal("sig")
|
|
17558
|
+
}).strict();
|
|
17559
|
+
const ManagementPostureSchema = object({
|
|
17560
|
+
enabled: literal(true),
|
|
17561
|
+
keyId: string().min(1),
|
|
17562
|
+
publicJwk: ManagementPostureJwkSchema,
|
|
17563
|
+
primaryOrigin: string().nullable(),
|
|
17564
|
+
origins: array(string()),
|
|
17565
|
+
keysUrl: string().url()
|
|
17566
|
+
}).strict();
|
|
17567
|
+
const ManagementPostureOriginsRequestSchema = object({ origins: PostureOriginsSchema }).strict();
|
|
17568
|
+
const ManagementErrorCodeSchema = _enum([
|
|
17569
|
+
"invalid_request",
|
|
17570
|
+
"invalid_client",
|
|
17571
|
+
"invalid_grant",
|
|
17572
|
+
"invalid_target",
|
|
17573
|
+
"access_denied",
|
|
17574
|
+
"expired_token",
|
|
17575
|
+
"authorization_pending",
|
|
17576
|
+
"slow_down",
|
|
17577
|
+
"invalid_token",
|
|
17578
|
+
"insufficient_scope",
|
|
17579
|
+
"temporarily_unavailable",
|
|
17580
|
+
"rate_limit_exceeded"
|
|
17581
|
+
]);
|
|
17582
|
+
const ManagementErrorReasonSchema = _enum(["management_issuer_unconfigured"]);
|
|
17583
|
+
const ManagementErrorSchema = object({
|
|
17584
|
+
success: literal(false),
|
|
17585
|
+
error: object({
|
|
17586
|
+
code: ManagementErrorCodeSchema,
|
|
17587
|
+
message: string().min(1).max(256),
|
|
17588
|
+
reason: ManagementErrorReasonSchema.optional()
|
|
17589
|
+
}).strict()
|
|
17590
|
+
}).strict();
|
|
17591
|
+
/**
|
|
17592
|
+
* A resource route's own refusal (grants, delegations, tasks), distinct from the session codes
|
|
17593
|
+
* above: an uppercase domain code at its real HTTP status, for example 409 GRANT_EXCEEDS_POLICY.
|
|
17594
|
+
*/
|
|
17595
|
+
const ManagementDomainErrorSchema = object({
|
|
17596
|
+
success: literal(false),
|
|
17597
|
+
error: object({
|
|
17598
|
+
code: string().regex(/^[A-Z][A-Z0-9_]{2,63}$/),
|
|
17599
|
+
message: string().min(1).max(256)
|
|
17600
|
+
}).strict()
|
|
17601
|
+
}).strict();
|
|
17602
|
+
/**
|
|
17603
|
+
* Browser consent posts, same-origin behind the signed-in session. Approval names one
|
|
17604
|
+
* organization and its projects; denial needs no choice, so it carries only the request.
|
|
17605
|
+
*/
|
|
17606
|
+
const ConsentChoice = {
|
|
17607
|
+
decision: literal("approve"),
|
|
17608
|
+
organizationId: string().uuid(),
|
|
17609
|
+
projectIds: array(string().uuid()).min(1).max(50)
|
|
17610
|
+
};
|
|
17611
|
+
const ConsentFlow = {
|
|
17612
|
+
authorization_code: {
|
|
17613
|
+
flow: literal("authorization_code"),
|
|
17614
|
+
query: ManagementAuthorizeQuerySchema
|
|
17615
|
+
},
|
|
17616
|
+
device: {
|
|
17617
|
+
flow: literal("device"),
|
|
17618
|
+
userCode: string().min(8).max(16)
|
|
17619
|
+
}
|
|
17620
|
+
};
|
|
17621
|
+
const ManagementConsentSchema = union([
|
|
17622
|
+
object({
|
|
17623
|
+
...ConsentFlow.authorization_code,
|
|
17624
|
+
...ConsentChoice
|
|
17625
|
+
}).strict(),
|
|
17626
|
+
object({
|
|
17627
|
+
...ConsentFlow.authorization_code,
|
|
17628
|
+
decision: literal("deny")
|
|
17629
|
+
}).strict(),
|
|
17630
|
+
object({
|
|
17631
|
+
...ConsentFlow.device,
|
|
17632
|
+
...ConsentChoice
|
|
17633
|
+
}).strict(),
|
|
17634
|
+
object({
|
|
17635
|
+
...ConsentFlow.device,
|
|
17636
|
+
decision: literal("deny")
|
|
17637
|
+
}).strict()
|
|
17638
|
+
]);
|
|
17639
|
+
/** The consent pickers list at most this many organizations, and projects per organization. */
|
|
17640
|
+
const MANAGEMENT_CONSENT_MAX_ORGANIZATIONS = 100;
|
|
17641
|
+
const MANAGEMENT_CONSENT_MAX_PROJECTS = 500;
|
|
17642
|
+
/** What the signed-in user may grant: live organizations, their role, and live projects. */
|
|
17643
|
+
const ManagementConsentContextSchema = object({
|
|
17644
|
+
organizations: array(object({
|
|
17645
|
+
id: string().uuid(),
|
|
17646
|
+
name: string().min(1).max(255),
|
|
17647
|
+
role: _enum([
|
|
17648
|
+
"owner",
|
|
17649
|
+
"admin",
|
|
17650
|
+
"member"
|
|
17651
|
+
]),
|
|
17652
|
+
projects: array(object({
|
|
17653
|
+
id: string().uuid(),
|
|
17654
|
+
name: string().min(1).max(255)
|
|
17655
|
+
}).strict()).max(500),
|
|
17656
|
+
/** More live projects exist than are listed; the hinted project is always listed. */
|
|
17657
|
+
projectsTruncated: boolean$1()
|
|
17658
|
+
}).strict()).max(100),
|
|
17659
|
+
organizationsTruncated: boolean$1()
|
|
17660
|
+
}).strict();
|
|
17661
|
+
/** A pending device request, as shown to the user deciding it. */
|
|
17662
|
+
const ManagementDeviceDescriptionSchema = object({
|
|
17663
|
+
scope: array(ManagementScopeSchema).min(1).max(2),
|
|
17664
|
+
projectHint: string().uuid().nullable(),
|
|
17665
|
+
projectName: ManagementProjectNameSchema.nullable(),
|
|
17666
|
+
expiresAt: string().datetime()
|
|
17667
|
+
}).strict();
|
|
17668
|
+
|
|
17669
|
+
//#endregion
|
|
17670
|
+
//#region src/api/task-grant.ts
|
|
17671
|
+
/**
|
|
17672
|
+
* C11: protocol grants for standing work. A grant binds one runner key (never a human) to exact
|
|
17673
|
+
* actions, one repository, one lead and optionally exact arguments, under one installation
|
|
17674
|
+
* policy revision. Grants form a revocable chain up to a root an owner or admin issued. Every
|
|
17675
|
+
* admission reserves against the whole chain in one PostgreSQL transaction, so siblings share
|
|
17676
|
+
* their ancestors' allowances. A grant is never edited: renewal or new limits issue a
|
|
17677
|
+
* replacement, and admitted operations keep the grant they were admitted under.
|
|
17678
|
+
*/
|
|
17679
|
+
/** Operation-admission protocols this server speaks, oldest first. Negotiate before use. */
|
|
17680
|
+
const TASK_ADMISSION_PROTOCOLS = ["kya.task.admission.v1", "kya.task.admission.v2"];
|
|
17681
|
+
const TaskAdmissionProtocolSchema = _enum(TASK_ADMISSION_PROTOCOLS);
|
|
17682
|
+
/** `GET /api/v1/task-mailbox/protocol`: public, tenant-free. */
|
|
17683
|
+
/**
|
|
17684
|
+
* Advertised by a deployment that answers an identical admission resend (same project, source,
|
|
17685
|
+
* execution operation and body, from the lead it recorded) by the admission it created, before
|
|
17686
|
+
* any current-policy check. Against such a deployment a 4xx on an identical resend proves the
|
|
17687
|
+
* original never committed. Absent from older deployments, where it proves nothing.
|
|
17688
|
+
*/
|
|
17689
|
+
const TASK_ADMISSION_RESEND = "kya.task.admission-resend.v1";
|
|
17690
|
+
const TaskMailboxProtocolSchema = object({
|
|
17691
|
+
admissionProtocols: array(TaskAdmissionProtocolSchema).min(1),
|
|
17692
|
+
grantStatus: literal("kya.task.grant-status.v1"),
|
|
17693
|
+
admissionResend: literal(TASK_ADMISSION_RESEND).optional()
|
|
17694
|
+
}).strict();
|
|
17695
|
+
const KeyDid$1 = string().startsWith("did:key:").max(512);
|
|
17696
|
+
const Sha256Digest = string().regex(/^sha256:[a-f0-9]{64}$/);
|
|
17697
|
+
/** Lowercase so a binding compares exactly; admission lowercases the repository it reserves. */
|
|
17698
|
+
const GrantRepository = string().max(255).regex(/^[a-z0-9_.-]+\/[a-z0-9_.-]+$/);
|
|
17699
|
+
const GrantActions = array(TaskStandingCapabilitySchema).min(1).max(4).refine((values) => values.every((value, index) => index === 0 || values[index - 1] < value), "Actions are unique and sorted");
|
|
17700
|
+
/** What an admission must match exactly. */
|
|
17701
|
+
const TaskGrantBindingSchema = object({
|
|
17702
|
+
holderDid: KeyDid$1,
|
|
17703
|
+
actions: GrantActions,
|
|
17704
|
+
repository: GrantRepository,
|
|
17705
|
+
leadDid: KeyDid$1,
|
|
17706
|
+
/** `null` binds any arguments within the repository; otherwise exactly one argument set. */
|
|
17707
|
+
argumentsDigest: Sha256Digest.nullable(),
|
|
17708
|
+
policyRevision: number$1().int().positive()
|
|
17709
|
+
}).strict();
|
|
17710
|
+
/** The arguments an admission's digest covers. */
|
|
17711
|
+
const TaskGrantArgumentsSchema = object({
|
|
17712
|
+
taskId: string().uuid(),
|
|
17713
|
+
sourceRevision: number$1().int().positive(),
|
|
17714
|
+
specRevision: number$1().int().positive(),
|
|
17715
|
+
manifestDigest: Sha256Digest,
|
|
17716
|
+
repository: GrantRepository,
|
|
17717
|
+
baseSha: string().regex(/^[a-f0-9]{40}$/)
|
|
17718
|
+
}).strict();
|
|
17719
|
+
/**
|
|
17720
|
+
* RFC 8785 (JCS) for a flat object of strings and safe integers: members sorted by UTF-16 code
|
|
17721
|
+
* units, each serialized as `JSON.stringify` does, which is what JCS specifies for them. Local
|
|
17722
|
+
* because `canonicalize` is ESM-only and this module ships in the CJS root barrel.
|
|
17723
|
+
*/
|
|
17724
|
+
function canonicalFlat(value) {
|
|
17725
|
+
return `{${Object.keys(value).sort().map((key) => {
|
|
17726
|
+
const item = value[key];
|
|
17727
|
+
if (typeof item !== "string" && !Number.isSafeInteger(item)) throw new TypeError(`Cannot canonicalize ${key}: only strings and safe integers`);
|
|
17728
|
+
return `${JSON.stringify(key)}:${JSON.stringify(item)}`;
|
|
17729
|
+
}).join(",")}}`;
|
|
17730
|
+
}
|
|
17731
|
+
/** `sha256:` over the RFC 8785 (JCS) form of the arguments. */
|
|
17732
|
+
function taskGrantArgumentsDigest(input) {
|
|
17733
|
+
const args = TaskGrantArgumentsSchema.parse(input);
|
|
17734
|
+
return `sha256:${bytesToHex(sha256(new TextEncoder().encode(canonicalFlat(args))))}`;
|
|
17735
|
+
}
|
|
17736
|
+
/** Shared by the grant and every descendant: each admission reserves against all of them. */
|
|
17737
|
+
const TaskGrantAllowanceSchema = object({
|
|
17738
|
+
maxOperations: number$1().int().min(1).max(1e4),
|
|
17739
|
+
maxCostMicrousd: number$1().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
17740
|
+
maxConcurrentOperations: number$1().int().min(1).max(100)
|
|
17741
|
+
}).strict();
|
|
17742
|
+
/** Nearest parent first, root last. A chain is at most eight grants deep. */
|
|
17743
|
+
const MAX_TASK_GRANT_DEPTH = 8;
|
|
17744
|
+
const TaskGrantSchema = object({
|
|
17745
|
+
schema: literal("kya.task.grant.v1"),
|
|
17746
|
+
grantId: string().uuid(),
|
|
17747
|
+
organizationId: string().uuid(),
|
|
17748
|
+
projectId: string().uuid(),
|
|
17749
|
+
installationId: string().uuid(),
|
|
17750
|
+
parentGrantId: string().uuid().nullable(),
|
|
17751
|
+
replacesGrantId: string().uuid().nullable(),
|
|
17752
|
+
ancestors: array(string().uuid()).max(7),
|
|
17753
|
+
binding: TaskGrantBindingSchema,
|
|
17754
|
+
allowance: TaskGrantAllowanceSchema,
|
|
17755
|
+
notBefore: string().datetime(),
|
|
17756
|
+
expiresAt: string().datetime(),
|
|
17757
|
+
issuedByUserId: string().uuid(),
|
|
17758
|
+
issuedAt: string().datetime()
|
|
17759
|
+
}).strict().refine((grant) => grant.ancestors[0] === (grant.parentGrantId ?? void 0), { message: "The nearest ancestor is the parent" }).refine((grant) => grant.notBefore < grant.expiresAt, { message: "Validity is not empty" });
|
|
17760
|
+
const TaskGrantStatusValueSchema = _enum([
|
|
17761
|
+
"active",
|
|
17762
|
+
"revoked",
|
|
17763
|
+
"expired",
|
|
17764
|
+
"replaced"
|
|
17765
|
+
]);
|
|
17766
|
+
/** Why a grant cannot admit now; `active` only when it and every ancestor can. */
|
|
17767
|
+
const TaskGrantEffectiveStatusSchema = _enum([
|
|
17768
|
+
"active",
|
|
17769
|
+
"not_yet_valid",
|
|
17770
|
+
"revoked",
|
|
17771
|
+
"expired",
|
|
17772
|
+
"replaced",
|
|
17773
|
+
"ancestor_inactive"
|
|
17774
|
+
]);
|
|
17775
|
+
/**
|
|
17776
|
+
* Recorded revocation, the server's first enforcement of it and already-admitted effects are
|
|
17777
|
+
* reported separately. A revoked in-flight effect stays recorded and charged; nothing here says
|
|
17778
|
+
* it was undone, and no notification is the authority gate.
|
|
17779
|
+
*/
|
|
17780
|
+
const TaskGrantStatusSchema = object({
|
|
17781
|
+
schema: literal("kya.task.grant-status.v1"),
|
|
17782
|
+
grantId: string().uuid(),
|
|
17783
|
+
status: TaskGrantStatusValueSchema,
|
|
17784
|
+
effectiveStatus: TaskGrantEffectiveStatusSchema,
|
|
17785
|
+
revokedAt: string().datetime().nullable(),
|
|
17786
|
+
revocationReason: string().max(500).nullable(),
|
|
17787
|
+
replacedByGrantId: string().uuid().nullable(),
|
|
17788
|
+
/** First time the server refused an admission or action because this grant is inactive. */
|
|
17789
|
+
enforcementObservedAt: string().datetime().nullable(),
|
|
17790
|
+
admitted: object({
|
|
17791
|
+
operations: number$1().int().nonnegative(),
|
|
17792
|
+
inFlight: number$1().int().nonnegative(),
|
|
17793
|
+
unknown: number$1().int().nonnegative(),
|
|
17794
|
+
reservedCostMicrousd: string().regex(/^\d+$/)
|
|
17795
|
+
}).strict(),
|
|
17796
|
+
observedAt: string().datetime()
|
|
17797
|
+
}).strict();
|
|
17798
|
+
/** Mailbox `grant-status`: the holder, the lead, or an ancestor's holder may read it. */
|
|
17799
|
+
const TaskGrantStatusRequestSchema = object({
|
|
17800
|
+
ownerEpoch: number$1().int().positive(),
|
|
17801
|
+
grantId: string().uuid()
|
|
17802
|
+
}).strict();
|
|
17803
|
+
/** Admission under a grant. v1 requests stay byte-identical and never carry a grant. */
|
|
17804
|
+
const TaskGrantAdmissionRequestSchema = TaskStandingAdmissionRequestBaseSchema.extend({
|
|
17805
|
+
protocolVersion: literal("kya.task.admission.v2"),
|
|
17806
|
+
grant: object({
|
|
17807
|
+
grantId: string().uuid(),
|
|
17808
|
+
binding: TaskGrantBindingSchema
|
|
17809
|
+
}).strict()
|
|
17810
|
+
}).strict().refine(validModelAdmission, "Model capability requires a bounded policy");
|
|
17811
|
+
/** The v2 receipt: the v1 receipt plus the exact chain the admission reserved against. */
|
|
17812
|
+
const TaskGrantAdmissionSchema = TaskStandingAdmissionReceiptBaseSchema.extend({
|
|
17813
|
+
schema: literal("kya.task.admission.v2"),
|
|
17814
|
+
grant: object({
|
|
17815
|
+
grantId: string().uuid(),
|
|
17816
|
+
ancestors: array(string().uuid()).max(7),
|
|
17817
|
+
binding: TaskGrantBindingSchema
|
|
17818
|
+
}).strict()
|
|
17819
|
+
}).strict().refine(validModelAdmission, "Model capability requires a bounded policy");
|
|
17820
|
+
/** Management: issue a root or child grant. `operationId` makes a retried issue idempotent. */
|
|
17821
|
+
const IssueTaskGrantSchema = object({
|
|
17822
|
+
operationId: string().uuid(),
|
|
17823
|
+
installationId: string().uuid(),
|
|
17824
|
+
parentGrantId: string().uuid().nullable(),
|
|
17825
|
+
binding: TaskGrantBindingSchema,
|
|
17826
|
+
allowance: TaskGrantAllowanceSchema,
|
|
17827
|
+
notBefore: string().datetime().optional(),
|
|
17828
|
+
expiresAt: string().datetime()
|
|
17829
|
+
}).strict();
|
|
17830
|
+
/** Management: renew or change limits. The binding stays, at the current policy revision. */
|
|
17831
|
+
const ReplaceTaskGrantSchema = object({
|
|
17832
|
+
operationId: string().uuid(),
|
|
17833
|
+
allowance: TaskGrantAllowanceSchema,
|
|
17834
|
+
notBefore: string().datetime().optional(),
|
|
17835
|
+
expiresAt: string().datetime()
|
|
17836
|
+
}).strict();
|
|
17837
|
+
const RevokeTaskGrantSchema = object({ reason: string().trim().min(1).max(500) }).strict();
|
|
17838
|
+
const TaskGrantViewSchema = object({
|
|
17839
|
+
grant: TaskGrantSchema,
|
|
17840
|
+
status: TaskGrantStatusSchema
|
|
17841
|
+
}).strict();
|
|
17842
|
+
const TaskGrantListSchema = object({ grants: array(TaskGrantViewSchema).max(200) }).strict();
|
|
17843
|
+
/** Issue and replace: a retried `operationId` with the same body returns the same grant. */
|
|
17844
|
+
const TaskGrantIssueResultSchema = object({
|
|
17845
|
+
grant: TaskGrantSchema,
|
|
17846
|
+
status: TaskGrantStatusSchema,
|
|
17847
|
+
duplicate: boolean$1()
|
|
17848
|
+
}).strict();
|
|
17849
|
+
/** Revocation is recorded at commit; it never reports admitted effects as undone. */
|
|
17850
|
+
const TaskGrantRevocationSchema = object({
|
|
17851
|
+
grant: TaskGrantSchema,
|
|
17852
|
+
status: TaskGrantStatusSchema,
|
|
17853
|
+
wasAlreadyRevoked: boolean$1()
|
|
17854
|
+
}).strict();
|
|
17855
|
+
/** A grant may not outlive this many days from `notBefore`; renewal issues a replacement. */
|
|
17856
|
+
const MAX_TASK_GRANT_DAYS = 90;
|
|
17857
|
+
/** Mailbox `grants`: the grants a runner may present, as their holder or their lead. */
|
|
17858
|
+
const TaskGrantHolderListRequestSchema = object({ ownerEpoch: number$1().int().positive() }).strict();
|
|
17859
|
+
|
|
17860
|
+
//#endregion
|
|
17861
|
+
//#region src/api/identity-provisioning.ts
|
|
17862
|
+
/**
|
|
17863
|
+
* C10: reviewed identity provisioning and workload enrollment, behind the C3 management session.
|
|
17864
|
+
* A read never provisions, mints or probes. Each fact the project identity view reports keeps its
|
|
17865
|
+
* own evidence: configured (a stored record), observed (an explicit probe, when it ran),
|
|
17866
|
+
* authoritative (the registry's current record, when last read), history (verified by the CLI's
|
|
17867
|
+
* identity sidecar, never claimed by the server) and receiving authorization (an explicit link).
|
|
17868
|
+
*/
|
|
17869
|
+
const Timestamp$1 = string().datetime();
|
|
17870
|
+
const Uuid = string().uuid();
|
|
17871
|
+
const KeyDid = string().startsWith("did:key:").max(512);
|
|
17872
|
+
const PublicUrl = string().url().max(2048).refine((value) => {
|
|
17873
|
+
const url = new URL(value);
|
|
17874
|
+
return ["https:", "http:"].includes(url.protocol) && !url.username && !url.password && !url.search && !url.hash;
|
|
17875
|
+
}, "A public URL has no credentials, query or fragment");
|
|
17876
|
+
const Code = string().regex(/^[A-Z][A-Z0-9_]{2,63}$/);
|
|
17877
|
+
/** The last explicit observation of a subject; `not_observed` until someone ran one. */
|
|
17878
|
+
const IdentityObservationSchema = object({
|
|
17879
|
+
state: _enum([
|
|
17880
|
+
"healthy",
|
|
17881
|
+
"unhealthy",
|
|
17882
|
+
"unavailable",
|
|
17883
|
+
"not_observed"
|
|
17884
|
+
]),
|
|
17885
|
+
observedAt: Timestamp$1.nullable()
|
|
17886
|
+
}).strict();
|
|
17887
|
+
const RegistryAuthorityStateSchema = _enum([
|
|
17888
|
+
"matches",
|
|
17889
|
+
"differs",
|
|
17890
|
+
"deactivated",
|
|
17891
|
+
"not_found",
|
|
17892
|
+
"unavailable",
|
|
17893
|
+
"not_observed"
|
|
17894
|
+
]);
|
|
17895
|
+
const ProjectIdentitySchema = object({
|
|
17896
|
+
schema: literal("kya.identity.project.v1"),
|
|
17897
|
+
organizationId: Uuid,
|
|
17898
|
+
projectId: Uuid,
|
|
17899
|
+
readAt: Timestamp$1,
|
|
17900
|
+
signingIdentity: object({
|
|
17901
|
+
/** A key exists in Checkpoint's encrypted custody. The key itself never leaves it. */
|
|
17902
|
+
configured: boolean$1(),
|
|
17903
|
+
didWeb: string().startsWith("did:web:").max(512).nullable()
|
|
17904
|
+
}).strict(),
|
|
17905
|
+
registry: object({
|
|
17906
|
+
/** This deployment can register organizations. */
|
|
17907
|
+
configured: boolean$1(),
|
|
17908
|
+
recorded: object({
|
|
17909
|
+
did: string().startsWith("did:webvh:").max(512),
|
|
17910
|
+
entityId: string().min(1).max(64),
|
|
17911
|
+
multikey: string().min(1).max(128)
|
|
17912
|
+
}).strict().nullable(),
|
|
17913
|
+
authoritative: object({
|
|
17914
|
+
state: RegistryAuthorityStateSchema,
|
|
17915
|
+
observedAt: Timestamp$1.nullable(),
|
|
17916
|
+
currentGeneration: number$1().int().positive().nullable()
|
|
17917
|
+
}).strict(),
|
|
17918
|
+
/** Signed history is verified by the CLI identity sidecar; the server never claims it. */
|
|
17919
|
+
history: object({
|
|
17920
|
+
verifiedByServer: literal(false),
|
|
17921
|
+
logUrl: PublicUrl.nullable()
|
|
17922
|
+
}).strict()
|
|
17923
|
+
}).strict(),
|
|
17924
|
+
services: array(object({
|
|
17925
|
+
id: string().min(1).max(255),
|
|
17926
|
+
kind: _enum(["authorization_host", "mcp"]),
|
|
17927
|
+
url: PublicUrl.nullable(),
|
|
17928
|
+
configured: boolean$1(),
|
|
17929
|
+
/** A probe Checkpoint ran; MCP deployments are never probed, only self-reported. */
|
|
17930
|
+
observed: IdentityObservationSchema,
|
|
17931
|
+
selfReportedAt: Timestamp$1.nullable(),
|
|
17932
|
+
receiving: object({
|
|
17933
|
+
state: _enum([
|
|
17934
|
+
"authorized",
|
|
17935
|
+
"not_linked",
|
|
17936
|
+
"not_applicable"
|
|
17937
|
+
]),
|
|
17938
|
+
linkedAt: Timestamp$1.nullable()
|
|
17939
|
+
}).strict()
|
|
17940
|
+
}).strict()).max(102)
|
|
17941
|
+
}).strict();
|
|
17942
|
+
/**
|
|
17943
|
+
* `create` a signing identity in encrypted custody; `register` the organization's did:webvh root
|
|
17944
|
+
* with that key; `repair` a registration whose response was lost (only from a verified registry
|
|
17945
|
+
* read whose current key is the organization's key; never a re-mint); `link` a recorded MCP
|
|
17946
|
+
* deployment as authorized to receive for this organization.
|
|
17947
|
+
*/
|
|
17948
|
+
const IdentityIntentActionSchema = _enum([
|
|
17949
|
+
"create",
|
|
17950
|
+
"register",
|
|
17951
|
+
"repair",
|
|
17952
|
+
"link"
|
|
17953
|
+
]);
|
|
17954
|
+
/** `POST …/identity/intents`: a review; nothing changes until it is applied. */
|
|
17955
|
+
const IdentityIntentRequestSchema = discriminatedUnion("action", [
|
|
17956
|
+
object({
|
|
17957
|
+
operationId: Uuid,
|
|
17958
|
+
action: literal("create")
|
|
17959
|
+
}).strict(),
|
|
17960
|
+
object({
|
|
17961
|
+
operationId: Uuid,
|
|
17962
|
+
action: literal("register")
|
|
17963
|
+
}).strict(),
|
|
17964
|
+
object({
|
|
17965
|
+
operationId: Uuid,
|
|
17966
|
+
action: literal("repair")
|
|
17967
|
+
}).strict(),
|
|
17968
|
+
object({
|
|
17969
|
+
operationId: Uuid,
|
|
17970
|
+
action: literal("link"),
|
|
17971
|
+
deploymentId: Uuid
|
|
17972
|
+
}).strict()
|
|
17973
|
+
]);
|
|
17974
|
+
/** Review and outcome text is read back in terminals and the dashboard. */
|
|
17975
|
+
const Readable = (max) => string().max(max).regex(READABLE_TEXT, READABLE_TEXT_MESSAGE);
|
|
17976
|
+
const PublicMetadata = record(Readable(64), Readable(512));
|
|
17977
|
+
const IdentityIntentStateSchema = _enum([
|
|
17978
|
+
"reviewed",
|
|
17979
|
+
"applying",
|
|
17980
|
+
"succeeded",
|
|
17981
|
+
"failed",
|
|
17982
|
+
"unknown",
|
|
17983
|
+
"expired"
|
|
17984
|
+
]);
|
|
17985
|
+
const IdentityIntentSchema = object({
|
|
17986
|
+
schema: literal("kya.identity.intent.v1"),
|
|
17987
|
+
operationId: Uuid,
|
|
17988
|
+
organizationId: Uuid,
|
|
17989
|
+
projectId: Uuid,
|
|
17990
|
+
action: IdentityIntentActionSchema,
|
|
17991
|
+
deploymentId: Uuid.nullable(),
|
|
17992
|
+
state: IdentityIntentStateSchema,
|
|
17993
|
+
review: object({
|
|
17994
|
+
/** Plain-language effects the reviewer approves, in order. */
|
|
17995
|
+
effects: array(Readable(300).min(1)).min(1).max(8),
|
|
17996
|
+
/** Public metadata only: DIDs, entity IDs, URLs. Never key material. */
|
|
17997
|
+
publicMetadata: PublicMetadata,
|
|
17998
|
+
digest: string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
17999
|
+
expiresAt: Timestamp$1
|
|
18000
|
+
}).strict(),
|
|
18001
|
+
outcome: object({
|
|
18002
|
+
code: Code,
|
|
18003
|
+
publicMetadata: PublicMetadata,
|
|
18004
|
+
/** True when a later `repair` or a retried apply can settle it. */
|
|
18005
|
+
recoverable: boolean$1()
|
|
18006
|
+
}).strict().nullable(),
|
|
18007
|
+
requestedByUserId: Uuid,
|
|
18008
|
+
requestedAt: Timestamp$1,
|
|
18009
|
+
appliedByUserId: Uuid.nullable(),
|
|
18010
|
+
completedAt: Timestamp$1.nullable()
|
|
18011
|
+
}).strict().refine((intent) => intent.action === "link" || intent.deploymentId === null, {
|
|
18012
|
+
message: "Only a link intent names a deployment",
|
|
18013
|
+
path: ["deploymentId"]
|
|
18014
|
+
});
|
|
18015
|
+
/** `POST …/identity/intents/{operationId}/apply`: the reviewer's approval of exactly that review. */
|
|
18016
|
+
const ApplyIdentityIntentSchema = object({ reviewDigest: string().regex(/^sha256:[a-f0-9]{64}$/) }).strict();
|
|
18017
|
+
/** `POST …/enrollments/challenge`: a single-use nonce the holder key must sign. */
|
|
18018
|
+
const WorkloadEnrollmentChallengeSchema = object({
|
|
18019
|
+
nonce: string().regex(/^[A-Za-z0-9_-]{43}$/),
|
|
18020
|
+
audience: string().url().max(512),
|
|
18021
|
+
expiresAt: Timestamp$1
|
|
18022
|
+
}).strict();
|
|
18023
|
+
const HostId = string().min(1).max(128).regex(/^[A-Za-z0-9][A-Za-z0-9._:-]*$/);
|
|
18024
|
+
const Signature = string().regex(/^[A-Za-z0-9_-]{86}$/);
|
|
18025
|
+
/**
|
|
18026
|
+
* What an enrollment proof signs: the JCS form of this object, Ed25519 by the holder key, base64url.
|
|
18027
|
+
* Rotation signs `kya.workload.enrollment-rotation.v1` with both the old and the new key.
|
|
18028
|
+
*/
|
|
18029
|
+
const WorkloadEnrollmentProofPayloadSchema = object({
|
|
18030
|
+
schema: literal("kya.workload.enrollment-proof.v1"),
|
|
18031
|
+
audience: string().url().max(512),
|
|
18032
|
+
nonce: string().regex(/^[A-Za-z0-9_-]{43}$/),
|
|
18033
|
+
organizationId: Uuid,
|
|
18034
|
+
projectId: Uuid,
|
|
18035
|
+
hostId: HostId,
|
|
18036
|
+
runnerId: HostId,
|
|
18037
|
+
holderDid: KeyDid
|
|
18038
|
+
}).strict();
|
|
18039
|
+
const WorkloadRotationProofPayloadSchema = object({
|
|
18040
|
+
schema: literal("kya.workload.enrollment-rotation.v1"),
|
|
18041
|
+
audience: string().url().max(512),
|
|
18042
|
+
nonce: string().regex(/^[A-Za-z0-9_-]{43}$/),
|
|
18043
|
+
enrollmentId: Uuid,
|
|
18044
|
+
hostId: HostId,
|
|
18045
|
+
runnerId: HostId,
|
|
18046
|
+
oldHolderDid: KeyDid,
|
|
18047
|
+
newHolderDid: KeyDid
|
|
18048
|
+
}).strict();
|
|
18049
|
+
const EnrollWorkloadSchema = object({
|
|
18050
|
+
operationId: Uuid,
|
|
18051
|
+
hostId: HostId,
|
|
18052
|
+
runnerId: HostId,
|
|
18053
|
+
holderDid: KeyDid,
|
|
18054
|
+
nonce: string().regex(/^[A-Za-z0-9_-]{43}$/),
|
|
18055
|
+
proof: Signature,
|
|
18056
|
+
/** When the owner's approval lapses; at most 180 days, default 90. */
|
|
18057
|
+
approvalExpiresAt: Timestamp$1.optional()
|
|
18058
|
+
}).strict();
|
|
18059
|
+
const RotateWorkloadEnrollmentSchema = object({
|
|
18060
|
+
operationId: Uuid,
|
|
18061
|
+
newHolderDid: KeyDid,
|
|
18062
|
+
nonce: string().regex(/^[A-Za-z0-9_-]{43}$/),
|
|
18063
|
+
oldProof: Signature,
|
|
18064
|
+
newProof: Signature
|
|
18065
|
+
}).strict();
|
|
18066
|
+
const RevokeWorkloadEnrollmentSchema = object({ reason: string().trim().min(1).max(500) }).strict();
|
|
18067
|
+
/**
|
|
18068
|
+
* Approval, credential and renewal times are separate: the owner's approval can outlive many
|
|
18069
|
+
* credential periods, and renewal opens before the credential expires. A retiring enrollment
|
|
18070
|
+
* still identifies attempts admitted under it; it enrolls nothing new.
|
|
18071
|
+
*/
|
|
18072
|
+
const WorkloadEnrollmentSchema = object({
|
|
18073
|
+
schema: literal("kya.workload.enrollment.v1"),
|
|
18074
|
+
enrollmentId: Uuid,
|
|
18075
|
+
operationId: Uuid,
|
|
18076
|
+
organizationId: Uuid,
|
|
18077
|
+
projectId: Uuid,
|
|
18078
|
+
hostId: HostId,
|
|
18079
|
+
runnerId: HostId,
|
|
18080
|
+
holderDid: KeyDid,
|
|
18081
|
+
status: _enum([
|
|
18082
|
+
"active",
|
|
18083
|
+
"retiring",
|
|
18084
|
+
"retired",
|
|
18085
|
+
"revoked"
|
|
18086
|
+
]),
|
|
18087
|
+
approvedByUserId: Uuid,
|
|
18088
|
+
approvedAt: Timestamp$1,
|
|
18089
|
+
approvalExpiresAt: Timestamp$1,
|
|
18090
|
+
credentialExpiresAt: Timestamp$1,
|
|
18091
|
+
renewalWindowStartsAt: Timestamp$1,
|
|
18092
|
+
replacesEnrollmentId: Uuid.nullable(),
|
|
18093
|
+
replacedByEnrollmentId: Uuid.nullable(),
|
|
18094
|
+
retiresAt: Timestamp$1.nullable(),
|
|
18095
|
+
revokedAt: Timestamp$1.nullable(),
|
|
18096
|
+
revokedByUserId: Uuid.nullable(),
|
|
18097
|
+
revocationReason: string().max(500).nullable()
|
|
18098
|
+
}).strict();
|
|
18099
|
+
/** `POST …/enrollments/{id}/revoke`: a repeated revoke returns the recorded revocation. */
|
|
18100
|
+
const WorkloadEnrollmentRevocationSchema = object({
|
|
18101
|
+
enrollment: WorkloadEnrollmentSchema,
|
|
18102
|
+
wasAlreadyRevoked: boolean$1()
|
|
18103
|
+
}).strict();
|
|
18104
|
+
const WorkloadEnrollmentResultSchema = object({
|
|
18105
|
+
enrollment: WorkloadEnrollmentSchema,
|
|
18106
|
+
duplicate: boolean$1()
|
|
18107
|
+
}).strict();
|
|
18108
|
+
const WorkloadEnrollmentListSchema = object({ enrollments: array(WorkloadEnrollmentSchema).max(200) }).strict();
|
|
18109
|
+
|
|
18110
|
+
//#endregion
|
|
18111
|
+
//#region src/api/delegation-management.ts
|
|
18112
|
+
/**
|
|
18113
|
+
* C11: human management of legacy delegations through a C3 management session. Reads need any
|
|
18114
|
+
* current role in the project; revocation needs a current owner or admin, rechecked when it
|
|
18115
|
+
* commits. Another organization's or project's delegation is indistinguishable from none.
|
|
18116
|
+
*/
|
|
18117
|
+
const Timestamp = string().datetime();
|
|
18118
|
+
/** A revocation reason is free text read back in terminals and the dashboard: readable text. */
|
|
18119
|
+
const RevocationReason = string().max(500).regex(READABLE_TEXT, READABLE_TEXT_MESSAGE);
|
|
18120
|
+
/** The stored lifecycle column. It is never flipped to `expired` by time alone. */
|
|
18121
|
+
const DelegationStoredStatusSchema = _enum([
|
|
18122
|
+
"active",
|
|
18123
|
+
"expired",
|
|
18124
|
+
"revoked"
|
|
18125
|
+
]);
|
|
18126
|
+
/**
|
|
18127
|
+
* What verification would decide from the record alone at `evaluatedAt`: revocation first, then
|
|
18128
|
+
* expiry (`expiresAt` or the `notAfter` constraint), then the `notBefore` constraint.
|
|
18129
|
+
*/
|
|
18130
|
+
const DelegationEffectiveStatusSchema = _enum([
|
|
18131
|
+
"active",
|
|
18132
|
+
"not_yet_valid",
|
|
18133
|
+
"expired",
|
|
18134
|
+
"revoked"
|
|
18135
|
+
]);
|
|
18136
|
+
/**
|
|
18137
|
+
* List filter over the effective status. `active` means neither revoked nor expired, so it also
|
|
18138
|
+
* lists delegations that are not yet valid.
|
|
18139
|
+
*/
|
|
18140
|
+
const DelegationListStatusFilterSchema = _enum([
|
|
18141
|
+
"active",
|
|
18142
|
+
"revoked",
|
|
18143
|
+
"expired",
|
|
18144
|
+
"all"
|
|
18145
|
+
]);
|
|
18146
|
+
/** The bounds verification enforces. A stored bound of 0 means none, as in verification. */
|
|
18147
|
+
const DelegationConstraintSummarySchema = object({
|
|
18148
|
+
notBefore: Timestamp.nullable(),
|
|
18149
|
+
notAfter: Timestamp.nullable(),
|
|
18150
|
+
maxCalls: number$1().nullable()
|
|
18151
|
+
}).strict();
|
|
18152
|
+
/**
|
|
18153
|
+
* One delegation as its project's members see it. `usageCount` counts verifications accepted
|
|
18154
|
+
* against `maxCalls`; verification never counts uses of a delegation without a cap, so both
|
|
18155
|
+
* `usageCount` and `remainingCalls` are null there rather than a misleading 0.
|
|
18156
|
+
*/
|
|
18157
|
+
const DelegationManagementItemSchema = object({
|
|
18158
|
+
delegationId: string().uuid(),
|
|
18159
|
+
agentDid: string().max(500),
|
|
18160
|
+
agentName: string().max(255).nullable(),
|
|
18161
|
+
userDid: string().max(500).nullable(),
|
|
18162
|
+
userIdentifier: string().max(500).nullable(),
|
|
18163
|
+
scopes: array(string().min(1)),
|
|
18164
|
+
constraints: DelegationConstraintSummarySchema,
|
|
18165
|
+
status: DelegationStoredStatusSchema,
|
|
18166
|
+
effectiveStatus: DelegationEffectiveStatusSchema,
|
|
18167
|
+
issuedAt: Timestamp,
|
|
18168
|
+
expiresAt: Timestamp.nullable(),
|
|
18169
|
+
revokedAt: Timestamp.nullable(),
|
|
18170
|
+
revocationReason: RevocationReason.nullable(),
|
|
18171
|
+
usageCount: number$1().int().nonnegative().nullable(),
|
|
18172
|
+
remainingCalls: number$1().int().nonnegative().nullable(),
|
|
18173
|
+
lastUsedAt: Timestamp.nullable()
|
|
18174
|
+
}).strict();
|
|
18175
|
+
/** `GET /api/cli/management/projects/{projectId}/delegations`: newest first. */
|
|
18176
|
+
const DelegationManagementListSchema = object({
|
|
18177
|
+
delegations: array(DelegationManagementItemSchema).max(200),
|
|
18178
|
+
/** Opaque; pass back as `?cursor=` for the next page. Null on the last page. */
|
|
18179
|
+
nextCursor: string().min(1).max(256).nullable(),
|
|
18180
|
+
/** The instant every `effectiveStatus` in this page was evaluated at. */
|
|
18181
|
+
evaluatedAt: Timestamp
|
|
18182
|
+
}).strict();
|
|
18183
|
+
/** Audit records that name this delegation, counted within its organization and project. */
|
|
18184
|
+
const DelegationAuditSourceSchema = _enum([
|
|
18185
|
+
"bouncer_proofs",
|
|
18186
|
+
"gateway_tool_calls",
|
|
18187
|
+
"usage_events"
|
|
18188
|
+
]);
|
|
18189
|
+
const DelegationAuditSummarySchema = object({
|
|
18190
|
+
source: DelegationAuditSourceSchema,
|
|
18191
|
+
count: number$1().int().nonnegative(),
|
|
18192
|
+
latestAt: Timestamp.nullable()
|
|
18193
|
+
}).strict();
|
|
18194
|
+
/**
|
|
18195
|
+
* Where Checkpoint handed the delegation's persisted bearer credential out: the verify response,
|
|
18196
|
+
* the dashboard list, gateway pickup polls, the JSON gateway consent approval, managed native
|
|
18197
|
+
* issuance and OpenClaw approvals. Freshly minted per-response tokens are separate credentials.
|
|
18198
|
+
*/
|
|
18199
|
+
const DelegationExportChannelSchema = _enum([
|
|
18200
|
+
"verify_response",
|
|
18201
|
+
"dashboard_list",
|
|
18202
|
+
"gateway_pickup",
|
|
18203
|
+
"gateway_consent",
|
|
18204
|
+
"native_issuance",
|
|
18205
|
+
"openclaw_approval"
|
|
18206
|
+
]);
|
|
18207
|
+
const DelegationExportRecordSchema = object({
|
|
18208
|
+
channel: DelegationExportChannelSchema,
|
|
18209
|
+
firstExportedAt: Timestamp,
|
|
18210
|
+
lastExportedAt: Timestamp,
|
|
18211
|
+
/** Exports counted at most once a minute per credential, so a lower bound. */
|
|
18212
|
+
exportCount: number$1().int().positive()
|
|
18213
|
+
}).strict();
|
|
18214
|
+
/**
|
|
18215
|
+
* The compatibility export ledger's view of one delegation. It lists recorded exports only:
|
|
18216
|
+
* a ledger write that failed was logged, not retried, and credentials minted fresh for a
|
|
18217
|
+
* response (rather than read from the delegation record) are not exports of this credential.
|
|
18218
|
+
*
|
|
18219
|
+
* `historical` is `unknown` when the delegation was created before `ledgerStartedAt` (or this
|
|
18220
|
+
* environment has no ledger), because exports before then were never recorded; unknown is not
|
|
18221
|
+
* none. It is `none` only when the ledger covered the delegation's whole life, so `recorded` is
|
|
18222
|
+
* then every recorded channel. Revoking never retracts an export: `retractedByRevocation` is
|
|
18223
|
+
* always false, and whoever holds an exported credential still holds it.
|
|
18224
|
+
*/
|
|
18225
|
+
const DelegationExposureSchema = object({
|
|
18226
|
+
ledgerStartedAt: Timestamp.nullable(),
|
|
18227
|
+
historical: _enum(["unknown", "none"]),
|
|
18228
|
+
recorded: array(DelegationExportRecordSchema).max(DelegationExportChannelSchema.options.length),
|
|
18229
|
+
retractedByRevocation: literal(false)
|
|
18230
|
+
}).strict();
|
|
18231
|
+
/** `GET /api/cli/management/projects/{projectId}/delegations/{delegationId}`. */
|
|
18232
|
+
const DelegationManagementDetailSchema = DelegationManagementItemSchema.extend({
|
|
18233
|
+
audit: array(DelegationAuditSummarySchema).max(DelegationAuditSourceSchema.options.length),
|
|
18234
|
+
exposure: DelegationExposureSchema
|
|
18235
|
+
}).strict();
|
|
18236
|
+
/** `POST .../delegations/{delegationId}/revoke`. The reason is stored and shown to members. */
|
|
18237
|
+
const DelegationRevokeRequestSchema = object({ reason: string().trim().pipe(RevocationReason.min(1)) }).strict();
|
|
18238
|
+
/**
|
|
18239
|
+
* The outcome of a human revocation. Revoking is idempotent: a delegation that was already
|
|
18240
|
+
* revoked answers `wasAlreadyRevoked: true` with its original `revokedAt`.
|
|
18241
|
+
*
|
|
18242
|
+
* `enforcement` names the only gate: Checkpoint verification. Every verification that consults
|
|
18243
|
+
* Checkpoint refuses the delegation once the revocation commits, whatever channel the credential
|
|
18244
|
+
* left through; `revokedAt` is when the revoking transaction began, at most moments earlier.
|
|
18245
|
+
* Exported bearer credentials are not retracted or deleted (see `exposure`), a verifier that
|
|
18246
|
+
* never consults Checkpoint is not stopped, and any status-list publication may lag. No
|
|
18247
|
+
* notification sent afterwards is part of the gate.
|
|
18248
|
+
*
|
|
18249
|
+
* `inFlight` is what the delegation had admitted when it was revoked: those uses may still be
|
|
18250
|
+
* completing downstream, and none is admitted after it. `admittedUses` is null for a delegation
|
|
18251
|
+
* without a call cap, whose uses verification never counts.
|
|
18252
|
+
*/
|
|
18253
|
+
const DelegationRevokeResponseSchema = object({
|
|
18254
|
+
delegationId: string().uuid(),
|
|
18255
|
+
status: literal("revoked"),
|
|
18256
|
+
revokedAt: Timestamp,
|
|
18257
|
+
wasAlreadyRevoked: boolean$1(),
|
|
18258
|
+
inFlight: object({
|
|
18259
|
+
admittedUses: number$1().int().nonnegative().nullable(),
|
|
18260
|
+
lastUsedAt: Timestamp.nullable()
|
|
18261
|
+
}).strict(),
|
|
18262
|
+
exposure: DelegationExposureSchema,
|
|
18263
|
+
enforcement: literal("checkpoint_verification")
|
|
18264
|
+
}).strict();
|
|
18265
|
+
|
|
18266
|
+
//#endregion
|
|
18267
|
+
//#region src/api/tracking-readiness.ts
|
|
18268
|
+
/** Why an item may not start. Frozen with Rust `ReadinessCode`: a new code is a contract change. */
|
|
18269
|
+
const TrackingReadinessReasonCodeSchema = _enum([
|
|
18270
|
+
"invalid_track",
|
|
18271
|
+
"unknown_task",
|
|
18272
|
+
"completion_claim_requires_verification",
|
|
18273
|
+
"source_needs_reconciliation",
|
|
18274
|
+
"not_queued",
|
|
18275
|
+
"unapproved_revision",
|
|
18276
|
+
"missing_acceptance_criteria",
|
|
18277
|
+
"repositories_not_ready",
|
|
18278
|
+
"authority_not_ready",
|
|
18279
|
+
"external_blocker",
|
|
18280
|
+
"blocking_issue_unresolved",
|
|
18281
|
+
"dependency_artifact_invalid",
|
|
18282
|
+
"dependency_artifact_ambiguous",
|
|
18283
|
+
"dependency_artifact_missing",
|
|
18284
|
+
"dependency_requires_merge",
|
|
18285
|
+
"dependency_binding_missing",
|
|
18286
|
+
"dependency_binding_stale"
|
|
18287
|
+
]);
|
|
18288
|
+
const TrackingReadinessSchema = object({
|
|
18289
|
+
startable: boolean$1(),
|
|
18290
|
+
reasons: array(object({
|
|
18291
|
+
code: TrackingReadinessReasonCodeSchema,
|
|
18292
|
+
message: string()
|
|
18293
|
+
}).strict())
|
|
18294
|
+
}).strict();
|
|
18295
|
+
|
|
15384
18296
|
//#endregion
|
|
15385
18297
|
//#region src/index.ts
|
|
15386
18298
|
const VERSION = "0.1.0";
|
|
15387
18299
|
const PACKAGE_NAME = "@kya-os/checkpoint-shared";
|
|
15388
18300
|
|
|
15389
18301
|
//#endregion
|
|
15390
|
-
export { ACCEPT_CHALLENGE_HEADER, ADMIN_DELTA_BASES, ADMIN_OVERVIEW_CACHE_STATUSES, ADMIN_OVERVIEW_LIST_LIMIT_DEFAULT, ADMIN_OVERVIEW_LIST_LIMIT_MAX, ADMIN_OVERVIEW_SECTIONS, ADMIN_OVERVIEW_WINDOWS, AGENT_CATEGORY_META, AI_AGENT_HEADERS, ANONYMOUS_PRINCIPAL_DID, API_ERRORS, API_ERROR_CODES, API_REQUEST_LIMITS, ATTESTED_BEARER_MAX_TTL_SECONDS, AUTHORIZATION_MODES, AUTH_ERRORS, AUTH_ERROR_MESSAGES, AUTH_MODES, AccountSchema, AddFingerprintToProfileRequestSchema, AddUpdateProviderRequestSchema, AdminQueryParamsSchema, AgentCategorySchema, AgentClassificationRequestSchema, AgentClassificationResultSchema, AgentClassificationSchema, AgentInfoSchema, AgentPatternSchema, AgentProfileSchema, AgentShieldConfigSchema, AgentSourceDistributionSchema, AgentStatisticsSchema, AgentTypeDefinitionSchema, AgentTypeSchema, AgentTypeSchema as WasmAgentTypeSchema, AggregationTypeSchema, AllowListEntrySchema, AnalyticsAgentSourcesQuerySchema, AnalyticsAgentTypesQuerySchema, AnalyticsChartDataSchema, AnalyticsDataPointSchema, AnalyticsExportParamsSchema, AnalyticsExportQuerySchema, AnalyticsQuerySchema, AnalyticsRealtimeQuerySchema, AnalyticsSessionsQuerySchema, AnalyticsSessionsResponseSchema, AnalyticsSummarySchema as AnalyticsSessionsSummarySchema, AnalyticsSummarySchema$1 as AnalyticsSummarySchema, AnalyticsTimeSeriesSchema, AnalyticsTimeWindowSchema, ApiKeyPermissionSchema, ApiKeyRateLimitsSchema, ApiKeySchema, ApiKeysBulkCreateItemSchema, ApiKeysBulkRequestSchema, ApiKeysBulkRevokeItemSchema, ApiKeysBulkUpdateItemSchema, ApiKeysQuerySchema, ApiResponseSchema, AssuranceTierSchema, AuthErrorType, AuthProviderTypeSchema, BARE_ERRORS, BASELINE_ALLOW_POLICY_ID, BESPOKE_POLICY_IDS, BILLING_ERRORS, BLOCKED_PATH, BOT_USER_AGENT_PATTERNS, BROWSER_PATTERNS, BULK_ERROR_CODES, BaseAuthProviderSchema, BaseBulkRequestSchema, BatchDetectionRequestSchema, BatchDetectionResponseSchema, BatchEventRequestSchema, BatchEventResponseSchema, BatchEventSchema, BatchPixelEventRequestSchema, BehavioralAnalysisSchema, BehavioralDataSchema, BehavioralPatternSchema, BehavioralRulesSchema, BehavioralSignalsSchema, BehavioralThresholdSchema, BlockEventSchema, BlockReasonSchema, BotPatternSchema, BotTypeSchema, BouncerConfigSchema, BouncerOutcomeSchema, BouncerProofSchema, BrowserInfoSchema, BulkDeletePreviewStatsSchema, BulkDeleteResponseSchema, BulkOperationOptionsSchema, BulkOperationParamsSchema, BulkOperationResultSchema, BulkOperationTypeSchema, BulkResponseSchema, BulkResultItemSchema, CACHE_LIMITS, CACHE_TTL, CLOUD_PROVIDER_RANGES, CONDITION_FIELDS, CONDITION_OPERATORS, CONFIDENCE_THRESHOLDS, CORRELATION_ID_HEADER, CRISPBudgetSchema, CURRENT_POLICY_VERSION, CacheConfigSchema, CachedDetectionDataSchema, ChallengeParamsSchema, ChallengeWireError, CircuitBreakerConfigSchema, CircuitBreakerStateSchema, ClickEventSchema, ClientDetectionSchema, CollectFingerprintRequestSchema, CollectFingerprintResponseSchema, CollectedDataSchema, ConditionFieldSchema, ConditionOperatorSchema, ConditionValueSchema, ConfidenceBreakdownSchema, ConfidenceLevelSchema, ConfidenceThresholdSchema, ConfidenceUtils, ConfiguredProviderSchema, ConsentAgentMetadataSchema, ConsentBrandingSchema, ConsentCapabilityGroupSchema, ConsentCapabilitySchema, ConsentConfigMetadataSchema, ConsentConfigSchema, ConsentTermsSchema, ConsentUISchema, CorrelationIdSchema, CreateApiKeySchema, CreateOrganizationInputSchema, CreateOrganizationSchema, CreatePixelSchema, CreateProfileRequestSchema, CreateProjectSchema, CreateProvisioningOrganizationRequestSchema, CreateProvisioningOrganizationResponseSchema, CredentialProviderConfigSchema, CredentialProviderSchema, CustomRuleSchema, DATABASE_LIMITS, DEFAULT_ADMIN_OVERVIEW_WINDOW, DEFAULT_AGENTSHIELD_CONFIG, DEFAULT_AGENT_TYPES, DEFAULT_API_KEY_RATE_LIMITS, DEFAULT_AUTHORIZATION_HOST, DEFAULT_BEHAVIORAL_THRESHOLDS, DEFAULT_CACHE_CONFIG, DEFAULT_CHALLENGE_CONTEXT_TIMEOUT_MS, DEFAULT_CONFIDENCE_THRESHOLDS, DEFAULT_CORS_CONFIG, DEFAULT_DETECTION_OPTIONS, DEFAULT_ENV_VARS, DEFAULT_LOG_CONFIG, DEFAULT_MAX_VENDOR_RANGE_AGE_MS, DEFAULT_PASSWORD_REQUIREMENTS, DEFAULT_PIXEL_CONFIG, DEFAULT_POLICY, DEFAULT_PROJECT_SETTINGS, DEFAULT_RESPONSE_HEADERS, DEFAULT_RETRY_CONFIG, DEFAULT_RULE_PRIORITY, DEFAULT_SESSION_CONFIG, DEFAULT_THRESHOLDS, DEFAULT_TIMEOUTS, DEFAULT_WEBHOOK_EVENTS, DELEGATION_PROOF_HEADERS, DEPLOY_STEPS, DETECTION_ERRORS, DETECTION_LIMITS, DETECTION_REASON_CODES, DashboardStatsRequestSchema, DatabaseDetectionMetadataSchema, DatabaseStatusSchema, DecisionSchema, DelegationPollingStatusSchema, DelegationResultSchema, DelegationSchema, DelegationStatusSchema, DelegationVerifiedBySchema, DeleteAccountSchema, DenyListEntrySchema, DeployProgressEventSchema, DeployStepIdSchema, DeployStepStateSchema, DeployStepStatusSchema, DeploymentMetadataSchema, DetectionClassSchema, DetectionDetailSchema, DetectionErrorDetailsSchema, DetectionEventSchema, DetectionInputSchema, DetectionLogSchema, DetectionMetadataSchema, DetectionModeSchema, DetectionOptionsSchema, DetectionReasonCodeSchema, DetectionReasoningSchema, DetectionRequestSchema, DetectionResponseSchema, DetectionResultSchema, DetectionRuleSchema, DetectionRulesSchema, DetectionSignalExposureSchema, DetectionSignalSchema, DetectionStatusSchema, DetectionTestResultSchema, DetectionViewTypeSchema, ENFORCEMENT_ACTIONS, ENFORCEMENT_MODES, ENTROPY_CONFIDENCE_CEILING, ENTROPY_CONFIDENCE_FLOOR, ERROR_CATEGORIES, ERROR_CODES, ERROR_MESSAGES, ERROR_STATUS_CODES, EXCLUSION_BUCKETS, EXPORT_LIMITS, EnforcementActionSchema, EnforcementModeSchema, EngineInfoSchema, EnhancedFingerprintResponseSchema, ErrorResponseSchema, EventConfigSchema, EventStorageRecordSchema, EventTrackingRequestSchema, EventTrackingResponseSchema, ExportAnalyticsSchema, ExpressMiddlewareOptionsSchema, FallbackOptionsSchema, FilterOperatorSchema, FingerprintAnalysisSchema, ClientDetectionSchema$1 as FingerprintClientDetectionSchema, FingerprintDetectRequestSchema, FingerprintRecordSchema, FingerprintResponseSchema, FingerprintSearchQuerySchema, ForgeabilityRiskSchema, GrowthBatchRequestSchema, GrowthConfigurationResetSchema, GrowthConfigurationThresholdsSchema, GrowthConfigurationUpdateSchema, GrowthOpportunitiesQuerySchema, GrowthOpportunityUpdateSchema, HEADER_PATTERNS, HTTP_STATUS, HeaderRuleSchema, HeaderRulesSchema, HealthResponseSchema, HomeRailRollupsRequestSchema, INSTALLATION_KINDS, INSTALLATION_TYPES, INTERNAL_ERRORS, InstructPayloadSchema, IntegrationTypeSchema, InternalProcessingFlagsSchema, IpRangeCollectionSchema, IpRangeRuleSchema, JafarParseError, KNOWN_AGENT_PATTERNS, KYA_HTTP_ERROR, KYA_OS_HANDSHAKE_METHODS, KYA_OS_WIRE_METHODS, KeyboardEventSchema, LOWERCASE_ERRORS, ListProvisioningOrganizationsRequestSchema, ListProvisioningOrganizationsResponseSchema, LoggingConfigSchema, MATCH_ACTIONS, MAX_BULK_BATCH_SIZE, MAX_ED25519_KEY_BODY_LENGTH, MAX_REASON_CODES_HEADER_BYTES, MAX_REASON_CODES_ON_WIRE, MCPI_ORG_DID_HOST, MCP_CLIENT_DID_HOST, MOBILE_PATTERNS, MarketplaceSourceSchema, MessagePrioritySchema, MiddlewareActionSchema, MiddlewareConfigSchema, MiddlewareSessionConfigSchema, MiddlewareSessionDataSchema, MigrationStatusSchema, MouseEventSchema, NETWORK_ERRORS, NetworkConfigSchema, NetworkContextSchema, NetworkInfoSchema, NetworkTimingSchema, NextMiddlewareOptionsSchema, OAuth2ProviderSchema, OAuthConnectionStatusSchema, OAuthModeSchema, OAuthProviderConfigSchema, OAuthProviderMetadataSchema, OAuthProviderTypeSchema, OAuthProvidersMapSchema, OAuthTokensResponseSchema, OS_PATTERNS, OfflineQueueEntrySchema, OrganizationErrorCode, OrganizationIdSchema, OrganizationRoleSchema, OrganizationSettingsSchema, OrganizationSsoModeSchema, OrganizationSsoProviderSchema, OrganizationSsoSettingsSchema, PACKAGE_NAME, PAGINATION_DEFAULTS, PERFORMANCE_THRESHOLDS, PERMISSION_ERRORS, PINNED_SIGNING_VENDORS, PIXEL_ERRORS, PIXEL_EVENT_LIMITS, PLAN_FEATURE_LIMITS, PLAN_RATE_LIMITS, POLICY_ERRORS, POLICY_MATCH_TYPES, PROVIDER_AUTH_TYPES, PageContextSchema, PaginatedResponseSchema, PaginationInfoSchema, PaginationParamsSchema, PaginationResponseSchema, PaginationResponseSchema as PublicPaginationResponseSchema, PatternUpdateRequestSchema, PerformanceRecalculationRequestSchema, PixelAnalyticsSchema, PixelConfigurationSchema, PixelEventSchema, PixelEventTypeSchema, PixelInitSchema, PixelInstallConfigSchema, PixelSchema, PixelSessionSchema, PixelStatsSchema, PixelTrackingRequestSchema, PixelTrackingResponseSchema, PixelUserIdentificationSchema, PixelVerificationStatusSchema, PixelsBulkCreateItemSchema, PixelsBulkDeleteItemSchema, PixelsBulkRegenerateItemSchema, PixelsBulkRequestSchema, PixelsBulkUpdateItemSchema, PixelsQuerySchema, PolicyConditionSchema, PolicyConfigSchema, PolicyEvaluationContextSchema, PolicyEvaluationResultSchema, PolicyFetcher, PolicyMatchTypeSchema, PolicyMetadataSchema, PolicyRuleSchema, ProjectIdSchema, ProjectSchema, ProjectSettingsSchema, ProjectsBulkCreateItemSchema, ProjectsBulkDeleteItemSchema, ProjectsBulkRequestSchema, ProjectsBulkUpdateItemSchema, ProjectsQuerySchema, ProtocolVersionSchema, ProviderConfigSchema, ProviderDefinitionSchema, ProviderRegistryDefinitionSchema, ProvidersResponseSchema, ProvisionKeyRequestSchema, ProvisionKeyResponseSchema, ProvisioningModeSchema, ProvisioningOrganizationRoleSchema, ProvisioningOrganizationSummarySchema, ProxyInfoSchema, ProxyTypeSchema, PublicAnalyticsBotTypeSchema, PublicAnalyticsSchema, PublicAnalyticsSummarySchema, PublicAnalyticsTimeSeriesPointSchema, PublicApiHeadersSchema, PublicApiQueryParamsSchema, PublicApiResponseSchema, PublicDetectionSchema, PublicKeyConfigSchema, PublicProjectSchema, PublishProfileRequestSchema, QueryFilterSchema, QuerySchema, RATE_LIMIT_ERRORS, REGISTERED_SID_MAX_LENGTH, REPORT_AI_AGENT_NAMES, REPORT_AI_CRAWLER_NAMES, RESOURCE_ERRORS, RULE_CACHE, RULE_CATEGORIES, RULE_CDN, RULE_ERRORS, RULE_PATHS, RULE_VERSION, RealtimeEventSchema, RealtimeEventTypeSchema, ReasoningStepSchema, RecommendationGenerationSchema, RecommendationQuerySchema, RedirectTargetSchema, RedisSessionDataSchema, RedisStatsSchema, RefreshScopesRequestSchema, ReportedAgentSchema, ReportedDelegationSchema, ReportedIdentitySchema, ReportedPrincipalSchema, RequestContextSchema, ResourceUsageSchema, ResponseActionSchema, RetryStrategySchema, RevokeProvisionQuerySchema, RevokeProvisionResponseSchema, RiskAssessmentSchema, RoutingTypeSchema, RuleLoadOptionsSchema, RuleLoader, RuleMatchResultSchema, RuleMetadataSchema, RuleParser, RuleUpdateEventSchema, RuleValidationResultSchema, RuleValidator, SECURITY_LIMITS, SERVICE_TRAFFIC_KEYS, SESSION_ERRORS, SESSION_LIMITS, SID_ATTRIBUTABLE_RESULT, SLUG_REGEX, SUSPICIOUS_HEADERS, SUSPICIOUS_PATTERNS, ScopeSchema, ScrollEventSchema, SdkSessionDataSchema, SessionConfigSchema, SessionCreateRequestSchema, SessionDataSchema, SessionEventSchema, SessionEventTypeSchema, SessionQueryOptionsSchema, SessionSchema, SessionStateSchema, SessionStorageTypeSchema, SessionTokenPayloadSchema, SessionUpdateRequestSchema, AgentTypeDistributionSchema as SharedAgentTypeDistributionSchema, ConfidenceDistributionSchema as SharedConfidenceDistributionSchema, ShopifyProjectProvisionRequestSchema, ShopifyProjectProvisionResultSchema, ShopifyProjectSettingsUpdateSchema, ShopifyStatsResponseSchema, ShopifyThreatSchema, SignatureAlgorithmSchema, SignatureRuleSchema, SignatureVerificationRequestSchema, SignatureVerificationResponseSchema, SingleItemResponseSchema, SsoLinkRequestSchema, SsoLinkResponseSchema, StaleVendorRangesError, StatsResponseSchema, StatsUpdateEventSchema, StrictEnforcementActionSchema, SuggestedActionSchema, SystemStatsSchema, TIME_WINDOWS, TLSFingerprintSchema, TRADITIONAL_BOT_PATTERNS, TRAFFIC_TAXONOMY_BUCKETS, TRUSTED_BOTS, TestDetectionRequestSchema, ThresholdConfigSchema, ToolConsentOverridesSchema, TouchEventSchema, TraceStepSchema, TransportConfigSchema, TransportMetricsSchema, TransportOptionsSchema, TransportResponseSchema, TransportStateSchema, UNCALIBRATED_NOISY_OR_PRIOR, UNNAMED_AGENT_LABEL, UPDATE_FREQUENCIES, USER_AGENT_PATTERNS, UUID_PATTERN, UpdateApiKeySchema, UpdateBouncerConfigSchema, UpdateOrganizationInputSchema, UpdateOrganizationSchema, UpdatePixelSchema, UpdateProfileRequestSchema, UpdateProjectSchema, UpdateSettingsSchema, UserAgentRuleSchema, UserPlanSchema, UserSchema, VALIDATION_ERRORS, VALIDATION_MODES, VALIDATION_PATTERNS, VERDICT_COOKIE_NAME, VERSION, VerdictEvidenceSchema, VerificationCacheEntrySchema, VerificationProviderSchema, VerificationRequestSchema, VerificationResponseSchema, VerificationTokenSchema, WEBHOOK_LIMITS, WasmAgentNameSchema, WasmConfigSchema, WasmDetectionResultSchema, WasmRequestMetadataSchema, WasmRiskLevel, WasmVerificationMethod, WorkerActionSchema, WorkerCapabilitiesSchema, WorkerConfigSchema, WorkerErrorSchema, WorkerErrorTypeSchema, WorkerHealthStatusSchema, WorkerMessageSchema, WorkerMessageTypeSchema, WorkerMetricsSchema, WorkerPoolConfigSchema, WorkerStateSchema, WorkerTaskSchema, acceptsHtml, adminOverviewQuerySchema, approvalQuorumForRequest, assertVendorRangesFresh, assignmentChangeRequestSchema, auditLogQuerySchema, base58btcDecode, base58btcEncode, batchAssignmentRequestSchema, bespokePolicyLabel, blockDelegationVerdict, blockEqualityLiterals, buildChallengeWire, buildDelegationBearerHeader, buildDelegationChallengeBody, buildDelegationChallengeEnvelope, buildDelegationChallengeHeader, buildDelegationInstructions, buildInitialStepsState, buildKnownPatternLookup, buildVerdictEvidence, calculateDeployProgress, callbackSchema, cedarQuotedValueRegExp, changePasswordSchema, classifyAgentTaxonomy, classifyResponseShape, claudeRuntimeLabel, compressIpv6, computeEntropyConfidence, createError, createErrorResponse, createEvaluationContext, createPaginatedResponse, createPaginatedResponseSchema, createPolicyFetcher, createSuccessResponse, createValidationErrorResponse, decisionPolicyId, decodeDidKeyEd25519, decodeDidKeyP256, decodeEd25519PublicKeyMultibaseTolerant, defaultConfig, deriveCorrelationId, deriveDelegationPickupUri, deriveMcpClientDid, deriveMcpiOrgDid, deriveMcpiOrgKid, deriveMcpiUserDid, deriveVerdict, detectionClassToEnum, discoveredToolSchema, encodeDidKeyEd25519, encodeEd25519PublicKeyMultibase, encodeVerdictCookie, enumToDetectionClass, escapeCedarString, evaluatePolicy, extractCorrelationIdFromHeaders, extractMatch, fetchPolicy, findMatchingPattern, findStaleVendorRanges, forgotPasswordSchema, formatAgentCategory, formatAgentCategoryInline, formatConfidence, formatReasonCodesHeader, fromProviderRegistryFormat, fromProviderRegistryFormatSafe, gatewayConfigInputSchema, gatewayConfigSchema, gatewayConnectedAgentSchema, gatewayConnectionsSummarySchema, gatewayInternalDiscoverErrorSchema, gatewayInternalDiscoverSuccessSchema, gatewayInternalToolsListSchema, gatewayToolCallSchema, generateDelegationSid, generateTestId, getAgentDisplayName, getBotType, getCategoryBadgeVariant, getCategoryColor, getConfidenceLevel, getDefaultPolicyFetcher, getEnvVar, getRateLimitWindow, getRemainingQuota, getStepInfo, getStepOrder, getVerificationMethodDescription, getVerificationReliability, getVerificationRiskLevel, hasClaudeCodeToken, hasClaudeSearchBotToken, hasClaudeUserToken, hasPinnedSigningVendor, initializePolicyFetcher, ipAddressSchema, isBespokePolicyId, isBlockingAction, isClaudeProductLabel, isForbidBlock, isHighConfidenceVerification, isKnownAgentType, isKnownAiCrawler, isKyaOsHandshakeMethod, isKyaOsWireMethod, isLegacyDetectionClass, isLegitimateCategory, isLimitExceeded, isNonNavigablePolicyId, isPassThroughAction, isPrivateOrReservedHost, isSupportedAuthType, isTraditionalBot, isUnnarrowedDenyBlock, isValidAuthorizationHost, isValidFingerprintResponse, isValidMcpiOrgSlug, isValidWasmDetectionResult, isValidWasmRequestMetadata, lintUnnarrowedDenyRules, loadRulesAsync, mapDetectionToReasonCodes, mapLegacyAuthType, mapToLegacyAuthType, matchPath, mergeWithDefaults, migrateLegacyDetectionClass, nonNavigablePolicyLabel, normalizeAgentName, normalizeChallengeType, normalizeClientIp, normalizeConfidence, normalizeDetectionClass, normalizeDetectionClassEnum, normalizeHandshakeMethod, normalizeOrganizationName, normalizeWireMethod, oauthClientSchema, parseAgentName, parseEvaluationContext, parseIpv6, parseJafarFeed, parsePolicyConfig, parseRules, partial, passwordSchema, pathHasUnnarrowedDenyRule, pathLiteralsInBlock, permitDelegationVerdict, projectResetRequestSchema, reconstructConfidenceFromEvidence, refineClaudeDisplayLabel, refineSessionGrainClaudeLabel, requestCarriesDelegationProof, requiredScopesForRequest, resetPasswordSchema, resetPolicyFetcher, resolveAuthorizationHost, resolveBotSignals, resolveChallengeContext, resolveClientIp, resolveTrustedDelegationRoots, safeParsePolicyConfig, safeUrl, selectBodyReadable200, serveBodyReadable200, signInSchema, signUpSchema, splitCedarBlocks, strict, supportsClientSide, supportsHeaders, supportsServerEnhanced, testPattern, testPatterns, toBareHost, toCoarseReasonKind, toPercent, toProviderRegistryFormat, toStoredCorrelationId, toWasmRequestMetadata, unescapeCedarString, updateStepsState, upstreamDiscoveryErrorSchema, upstreamServerInputSchema, upstreamServerSchema, validate, validateClientDetection, validateFingerprintRequest, validateOrThrow, validateOrganizationName, validateProviderConfig, validateProviderDefinition, validateRules, validateRulesLoose, validateStepUpQuorum, vaultResolveDataSchema, vaultResolveErrorSchema, vaultResolveMetaSchema, vaultResolveResponseSchema, vaultResolveSuccessSchema, verifyEmailSchema, wasmToDetectionResult };
|
|
18302
|
+
export { A2ARpcEnvelopeSchema, A2ASignedRequestSchema, A2ATaskRequestSchema, A2ATaskSourceConfigSchema, A2ATaskStateSchema, ACCEPT_CHALLENGE_HEADER, ADMIN_DELTA_BASES, ADMIN_OVERVIEW_CACHE_STATUSES, ADMIN_OVERVIEW_LIST_LIMIT_DEFAULT, ADMIN_OVERVIEW_LIST_LIMIT_MAX, ADMIN_OVERVIEW_SECTIONS, ADMIN_OVERVIEW_WINDOWS, AGENT_CATEGORY_META, AI_AGENT_HEADERS, ANALYTICS_ERRORS, ANONYMOUS_PRINCIPAL_DID, API_ERRORS, API_ERROR_CODES, API_REQUEST_LIMITS, ATTESTED_BEARER_MAX_TTL_SECONDS, AUDIT_ERRORS, AUDIT_PROTOCOL_ERRORS, AUTHORIZATION_MODES, AUTH_ERRORS, AUTH_ERROR_MESSAGES, AUTH_MODES, AcceptanceWithdrawalSchema, AcceptedArtifactRevisionSchema, AccountSchema, AddFingerprintToProfileRequestSchema, AddModelCredentialSchema, AddUpdateProviderRequestSchema, AdminQueryParamsSchema, AgentCategorySchema, AgentClassificationRequestSchema, AgentClassificationResultSchema, AgentClassificationSchema, AgentInfoSchema, AgentPatternSchema, AgentProfileSchema, AgentShieldConfigSchema, AgentSourceDistributionSchema, AgentStatisticsSchema, AgentTypeDefinitionSchema, AgentTypeSchema, AgentTypeSchema as WasmAgentTypeSchema, AggregationTypeSchema, AllowListEntrySchema, AnalyticsAgentSourcesQuerySchema, AnalyticsAgentTypesQuerySchema, AnalyticsChartDataSchema, AnalyticsDataPointSchema, AnalyticsExportParamsSchema, AnalyticsExportQuerySchema, AnalyticsQuerySchema, AnalyticsRealtimeQuerySchema, AnalyticsSessionsQuerySchema, AnalyticsSessionsResponseSchema, AnalyticsSummarySchema as AnalyticsSessionsSummarySchema, AnalyticsSummarySchema$1 as AnalyticsSummarySchema, AnalyticsTimeSeriesSchema, AnalyticsTimeWindowSchema, ApiKeyPermissionSchema, ApiKeyRateLimitsSchema, ApiKeySchema, ApiKeysBulkCreateItemSchema, ApiKeysBulkRequestSchema, ApiKeysBulkRevokeItemSchema, ApiKeysBulkUpdateItemSchema, ApiKeysQuerySchema, ApiResponseSchema, ApplyIdentityIntentSchema, ApproveTaskPublicationSchema, ApprovedTaskPublicationSchema, ArtifactIdentitySchema, AssuranceTierSchema, AuthErrorType, AuthProviderTypeSchema, BARE_ERRORS, BASELINE_ALLOW_POLICY_ID, BESPOKE_POLICY_IDS, BILLING_ERRORS, BLOCKED_PATH, BOT_USER_AGENT_PATTERNS, BOUNCER_LOWERCASE_ERRORS, BOUNCER_UPPERCASE_ERRORS, BROWSER_PATTERNS, BULK_ERROR_CODES, BaseAuthProviderSchema, BaseBulkRequestSchema, BatchDetectionRequestSchema, BatchDetectionResponseSchema, BatchEventRequestSchema, BatchEventResponseSchema, BatchEventSchema, BatchPixelEventRequestSchema, BehavioralAnalysisSchema, BehavioralDataSchema, BehavioralPatternSchema, BehavioralRulesSchema, BehavioralSignalsSchema, BehavioralThresholdSchema, BindingStatusSchema, BlockEventSchema, BlockReasonSchema, BotPatternSchema, BotTypeSchema, BouncerConfigSchema, BouncerOutcomeSchema, BouncerProofSchema, BrowserInfoSchema, BulkDeletePreviewStatsSchema, BulkDeleteResponseSchema, BulkOperationOptionsSchema, BulkOperationParamsSchema, BulkOperationResultSchema, BulkOperationTypeSchema, BulkResponseSchema, BulkResultItemSchema, CACHE_LIMITS, CACHE_TTL, CLOUD_PROVIDER_RANGES, CONDITION_FIELDS, CONDITION_OPERATORS, CONFIDENCE_THRESHOLDS, CORRELATION_ID_HEADER, CRISPBudgetSchema, CURRENT_POLICY_VERSION, CacheConfigSchema, CachedDetectionDataSchema, ChallengeParamsSchema, ChallengeWireError, CircuitBreakerConfigSchema, CircuitBreakerStateSchema, ClaimVerificationSchema, CliIdentityQuerySchema, CliIdentityServiceSchema, CliIdentitySummarySchema, ClickEventSchema, ClientDetectionSchema, CollectFingerprintRequestSchema, CollectFingerprintResponseSchema, CollectedDataSchema, ConditionFieldSchema, ConditionOperatorSchema, ConditionValueSchema, ConfidenceBreakdownSchema, ConfidenceLevelSchema, ConfidenceThresholdSchema, ConfidenceUtils, ConfigureLinearInstallationSchema, ConfigureLinearInstallationV2Schema, ConfigureTaskSourceInstallationSchema, ConfiguredProviderSchema, ConsentAgentMetadataSchema, ConsentBrandingSchema, ConsentCapabilityGroupSchema, ConsentCapabilitySchema, ConsentConfigMetadataSchema, ConsentConfigSchema, ConsentTermsSchema, ConsentUISchema, ConsumedArtifactSchema, CorrelationIdSchema, CreateApiKeySchema, CreateOrganizationInputSchema, CreateOrganizationSchema, CreatePixelSchema, CreateProfileRequestSchema, CreateProjectSchema, CreateProvisioningOrganizationRequestSchema, CreateProvisioningOrganizationResponseSchema, CredentialProviderConfigSchema, CredentialProviderSchema, CustomRuleSchema, DATABASE_LIMITS, DEFAULT_ADMIN_OVERVIEW_WINDOW, DEFAULT_AGENTSHIELD_CONFIG, DEFAULT_AGENT_TYPES, DEFAULT_API_KEY_RATE_LIMITS, DEFAULT_AUTHORIZATION_HOST, DEFAULT_BEHAVIORAL_THRESHOLDS, DEFAULT_CACHE_CONFIG, DEFAULT_CHALLENGE_CONTEXT_TIMEOUT_MS, DEFAULT_CONFIDENCE_THRESHOLDS, DEFAULT_CORS_CONFIG, DEFAULT_DETECTION_OPTIONS, DEFAULT_ENV_VARS, DEFAULT_LOG_CONFIG, DEFAULT_MAX_VENDOR_RANGE_AGE_MS, DEFAULT_PASSWORD_REQUIREMENTS, DEFAULT_PIXEL_CONFIG, DEFAULT_POLICY, DEFAULT_PROJECT_SETTINGS, DEFAULT_RESPONSE_HEADERS, DEFAULT_RETRY_CONFIG, DEFAULT_RULE_PRIORITY, DEFAULT_SESSION_CONFIG, DEFAULT_THRESHOLDS, DEFAULT_TIMEOUTS, DEFAULT_WEBHOOK_EVENTS, DELEGATION_PROOF_HEADERS, DEPLOY_ERRORS, DEPLOY_STEPS, DETECTION_ERRORS, DETECTION_LIMITS, DETECTION_REASON_CODES, DashboardStatsRequestSchema, DatabaseDetectionMetadataSchema, DatabaseStatusSchema, DecisionSchema, DelegationAuditSourceSchema, DelegationAuditSummarySchema, DelegationConstraintSummarySchema, DelegationEffectiveStatusSchema, DelegationExportChannelSchema, DelegationExportRecordSchema, DelegationExposureSchema, DelegationListStatusFilterSchema, DelegationManagementDetailSchema, DelegationManagementItemSchema, DelegationManagementListSchema, DelegationPollingStatusSchema, DelegationResultSchema, DelegationRevokeRequestSchema, DelegationRevokeResponseSchema, DelegationSchema, DelegationStatusSchema, DelegationStoredStatusSchema, DelegationVerifiedBySchema, DeleteAccountSchema, DenyListEntrySchema, DependencyBindingSchema, DeployProgressEventSchema, DeployStepIdSchema, DeployStepStateSchema, DeployStepStatusSchema, DeploymentMetadataSchema, DetectionClassSchema, DetectionDetailSchema, DetectionErrorDetailsSchema, DetectionEventSchema, DetectionInputSchema, DetectionLogSchema, DetectionMetadataSchema, DetectionModeSchema, DetectionOptionsSchema, DetectionReasonCodeSchema, DetectionReasoningSchema, DetectionRequestSchema, DetectionResponseSchema, DetectionResultSchema, DetectionRuleSchema, DetectionRulesSchema, DetectionSignalExposureSchema, DetectionSignalSchema, DetectionStatusSchema, DetectionTestResultSchema, DetectionViewTypeSchema, DidCommTaskSourceBindingSchema, DidCommTaskSourceConfigSchema, DidCommTaskSourceMessageSchema, DiscordTaskSourceConfigSchema, ENFORCEMENT_ACTIONS, ENFORCEMENT_MODES, ENTROPY_CONFIDENCE_CEILING, ENTROPY_CONFIDENCE_FLOOR, ERROR_CATEGORIES, ERROR_CODES, ERROR_MESSAGES, ERROR_STATUS_CODES, EXCLUSION_BUCKETS, EXPORT_LIMITS, EnforcementActionSchema, EnforcementModeSchema, EngineInfoSchema, EnhancedFingerprintResponseSchema, EnrollWorkloadSchema, ErrorResponseSchema, EventConfigSchema, EventStorageRecordSchema, EventTrackingRequestSchema, EventTrackingResponseSchema, ExportAnalyticsSchema, ExpressMiddlewareOptionsSchema, FallbackOptionsSchema, FilterOperatorSchema, FingerprintAnalysisSchema, ClientDetectionSchema$1 as FingerprintClientDetectionSchema, FingerprintDetectRequestSchema, FingerprintRecordSchema, FingerprintResponseSchema, FingerprintSearchQuerySchema, FleetPullRequestReceiptSchema, ForgeabilityRiskSchema, GitHubTaskSourceConfigSchema, GrowthBatchRequestSchema, GrowthConfigurationResetSchema, GrowthConfigurationThresholdsSchema, GrowthConfigurationUpdateSchema, GrowthOpportunitiesQuerySchema, GrowthOpportunityUpdateSchema, HEADER_PATTERNS, HTTP_STATUS, HeaderRuleSchema, HeaderRulesSchema, HealthResponseSchema, HomeRailRollupsRequestSchema, INSTALLATION_KINDS, INSTALLATION_TYPES, INTERNAL_ERRORS, IdentityIntentActionSchema, IdentityIntentRequestSchema, IdentityIntentSchema, IdentityIntentStateSchema, IdentityObservationSchema, ImmutableArtifactLocatorSchema, ImportIssueV2Schema, InstructPayloadSchema, IntegrationTypeSchema, InternalProcessingFlagsSchema, IpRangeCollectionSchema, IpRangeRuleSchema, IssueTaskGrantSchema, JafarParseError, KNOWN_AGENT_PATTERNS, KYAOS_PROTOCOL_ERRORS, KYA_A2A_EXTENSION, KYA_HTTP_ERROR, KYA_HTTP_ERROR_STATUS, KYA_OS_HANDSHAKE_METHODS, KYA_OS_WIRE_METHODS, KeyboardEventSchema, LOWERCASE_ERRORS, LinearActivityGateSchema, LinearActivityObservationSummarySchema, LinearInstallationAuthorizationSchema, LinearInstallationProviderStatusSchema, LinearInstallationStatusReasonSchema, LinearInstallationStatusSchema, LinearInstallationWorkflowSchema, LinearObsoleteActivityListSchema, LinearObsoleteActivitySchema, ListProvisioningOrganizationsRequestSchema, ListProvisioningOrganizationsResponseSchema, LoggingConfigSchema, MANAGEMENT_ACCESS_PREFIX, MANAGEMENT_AUDIENCE, MANAGEMENT_CLIENT_ID, MANAGEMENT_CONSENT_MAX_ORGANIZATIONS, MANAGEMENT_CONSENT_MAX_PROJECTS, MANAGEMENT_DEVICE_INTERVAL, MANAGEMENT_REFRESH_PREFIX, MANAGEMENT_USER_CODE_ALPHABET, MATCH_ACTIONS, MAX_BULK_BATCH_SIZE, MAX_ED25519_KEY_BODY_LENGTH, MAX_REASON_CODES_HEADER_BYTES, MAX_REASON_CODES_ON_WIRE, MAX_TASK_GRANT_DAYS, MAX_TASK_GRANT_DEPTH, MCPI_ORG_DID_HOST, MCP_CLIENT_DID_HOST, MOBILE_PATTERNS, ManagementAccessTokenSchema, ManagementAuthorizeQuerySchema, ManagementConsentContextSchema, ManagementConsentSchema, ManagementDeviceDescriptionSchema, ManagementDeviceRequestSchema, ManagementDeviceResponseSchema, ManagementDomainErrorSchema, ManagementErrorCodeSchema, ManagementErrorReasonSchema, ManagementErrorSchema, ManagementLoopbackRedirectSchema, ManagementPostureJwkSchema, ManagementPostureOriginsRequestSchema, ManagementPostureSchema, ManagementPrincipalSchema, ManagementProfileSchema, ManagementProjectNameSchema, ManagementProjectsSchema, ManagementRefreshTokenSchema, ManagementRevokeRequestSchema, ManagementRuntimeKeyPurposeSchema, ManagementRuntimeKeyRequestSchema, ManagementRuntimeKeySchema, ManagementScopeRequestSchema, ManagementScopeSchema, ManagementSessionSchema, ManagementTokenRequestSchema, ManagementTokenResponseSchema, MarketplaceSourceSchema, MaterializationPlanSchema, MessagePrioritySchema, MiddlewareActionSchema, MiddlewareConfigSchema, MiddlewareSessionConfigSchema, MiddlewareSessionDataSchema, MigrationStatusSchema, ModelCredentialFingerprintSchema, ModelCredentialLabelSchema, ModelCredentialListSchema, ModelCredentialProviderSchema, ModelCredentialRefusalCodeSchema, ModelCredentialResultSchema, ModelCredentialRevocationSchema, ModelCredentialSchema, MouseEventSchema, NETWORK_ERRORS, NetworkConfigSchema, NetworkContextSchema, NetworkInfoSchema, NetworkTimingSchema, NextMiddlewareOptionsSchema, OAUTH_LOWERCASE_ERRORS, OAuth2ProviderSchema, OAuthConnectionStatusSchema, OAuthModeSchema, OAuthProviderConfigSchema, OAuthProviderMetadataSchema, OAuthProviderTypeSchema, OAuthProvidersMapSchema, OAuthTokensResponseSchema, OS_PATTERNS, OfflineQueueEntrySchema, OrganizationErrorCode, OrganizationIdSchema, OrganizationRoleSchema, OrganizationSettingsSchema, OrganizationSsoModeSchema, OrganizationSsoProviderSchema, OrganizationSsoSettingsSchema, PACKAGE_NAME, PAGINATION_DEFAULTS, PERFORMANCE_THRESHOLDS, PERMISSION_ERRORS, PINNED_SIGNING_VENDORS, PIXEL_ERRORS, PIXEL_EVENT_LIMITS, PLAN_FEATURE_LIMITS, PLAN_RATE_LIMITS, POLICY_ERRORS, POLICY_MATCH_TYPES, PROVIDER_AUTH_TYPES, PageContextSchema, PaginatedResponseSchema, PaginationInfoSchema, PaginationParamsSchema, PaginationResponseSchema, PaginationResponseSchema as PublicPaginationResponseSchema, ParentIntegrationStatusSchema, PatternUpdateRequestSchema, PerformanceRecalculationRequestSchema, PixelAnalyticsSchema, PixelConfigurationSchema, PixelEventSchema, PixelEventTypeSchema, PixelInitSchema, PixelInstallConfigSchema, PixelSchema, PixelSessionSchema, PixelStatsSchema, PixelTrackingRequestSchema, PixelTrackingResponseSchema, PixelUserIdentificationSchema, PixelVerificationStatusSchema, PixelsBulkCreateItemSchema, PixelsBulkDeleteItemSchema, PixelsBulkRegenerateItemSchema, PixelsBulkRequestSchema, PixelsBulkUpdateItemSchema, PixelsQuerySchema, PolicyConditionSchema, PolicyConfigSchema, PolicyEvaluationContextSchema, PolicyEvaluationResultSchema, PolicyFetcher, PolicyMatchTypeSchema, PolicyMetadataSchema, PolicyRuleSchema, PolicyUnavailableError, PostureOriginsSchema, ProjectIdSchema, ProjectIdentitySchema, ProjectSchema, ProjectSettingsSchema, ProjectsBulkCreateItemSchema, ProjectsBulkDeleteItemSchema, ProjectsBulkRequestSchema, ProjectsBulkUpdateItemSchema, ProjectsQuerySchema, ProtocolVersionSchema, ProviderConfigSchema, ProviderDefinitionSchema, ProviderRegistryDefinitionSchema, ProvidersResponseSchema, ProvisionKeyRequestSchema, ProvisionKeyResponseSchema, ProvisioningModeSchema, ProvisioningOrganizationRoleSchema, ProvisioningOrganizationSummarySchema, ProxyInfoSchema, ProxyTypeSchema, PublicAnalyticsBotTypeSchema, PublicAnalyticsSchema, PublicAnalyticsSummarySchema, PublicAnalyticsTimeSeriesPointSchema, PublicApiHeadersSchema, PublicApiQueryParamsSchema, PublicApiResponseSchema, PublicDetectionSchema, PublicKeyConfigSchema, PublicProjectSchema, PublishProfileRequestSchema, QueryFilterSchema, QuerySchema, RATE_LIMIT_ERRORS, READABLE_TEXT, READABLE_TEXT_MESSAGE, REGISTERED_SID_MAX_LENGTH, REPORT_AI_AGENT_NAMES, REPORT_AI_CRAWLER_NAMES, RESOURCE_ERRORS, RULE_CATEGORIES, RULE_ERRORS, RULE_PATHS, RULE_VERSION, RealtimeEventSchema, RealtimeEventTypeSchema, ReasoningStepSchema, ReassignTaskLeadSchema, RecommendationGenerationSchema, RecommendationQuerySchema, ReconciliationDecisionSetSchema, RedirectTargetSchema, RedisSessionDataSchema, RedisStatsSchema, RefreshScopesRequestSchema, RegistryAuthorityStateSchema, ReplaceTaskGrantSchema, ReportedAgentSchema, ReportedDelegationSchema, ReportedIdentitySchema, ReportedPrincipalSchema, RepositoryIdentitySchema, RequestContextSchema, ResourceUsageSchema, ResponseActionSchema, RetryStrategySchema, RevokeModelCredentialSchema, RevokeProvisionQuerySchema, RevokeProvisionResponseSchema, RevokeTaskGrantSchema, RevokeWorkloadEnrollmentSchema, RiskAssessmentSchema, RiskScoreSchema, RiskScoreSourceSchema, RotateModelCredentialSchema, RotateWorkloadEnrollmentSchema, RoutingTypeSchema, RuleLoadOptionsSchema, RuleLoader, RuleMatchResultSchema, RuleMetadataSchema, RuleParser, RuleUpdateEventSchema, RuleValidationResultSchema, RuleValidator, SECURITY_LIMITS, SERVICE_TRAFFIC_KEYS, SESSION_ERRORS, SESSION_LIMITS, SHADOW_NOISY_OR_CONFIDENCE_KEY, SID_ATTRIBUTABLE_RESULT, SLUG_REGEX, SUSPICIOUS_HEADERS, SUSPICIOUS_PATTERNS, ScopeSchema, ScrollEventSchema, SdkSessionDataSchema, SessionConfigSchema, SessionCreateRequestSchema, SessionDataSchema, SessionEventSchema, SessionEventTypeSchema, SessionQueryOptionsSchema, SessionSchema, SessionStateSchema, SessionStorageTypeSchema, SessionTokenPayloadSchema, SessionUpdateRequestSchema, AgentTypeDistributionSchema as SharedAgentTypeDistributionSchema, ConfidenceDistributionSchema as SharedConfidenceDistributionSchema, ShopifyProjectProvisionRequestSchema, ShopifyProjectProvisionResultSchema, ShopifyProjectSettingsUpdateSchema, ShopifySessionClassSchema, ShopifySessionSchema, ShopifySessionsPaginationSchema, ShopifyStatsResponseSchema, ShopifyThreatSchema, SignatureAlgorithmSchema, SignatureRuleSchema, SignatureVerificationRequestSchema, SignatureVerificationResponseSchema, SingleItemResponseSchema, SsoLinkRequestSchema, SsoLinkResponseSchema, StaleReasonSchema, StaleReasonsSchema, StaleVendorRangesError, StartLinearInstallationSchema, StatsResponseSchema, StatsUpdateEventSchema, StrictEnforcementActionSchema, SuggestedActionSchema, SystemStatsSchema, TASK_ADMISSION_PROTOCOLS, TASK_ADMISSION_RESEND, TIME_WINDOWS, TLSFingerprintSchema, TRADITIONAL_BOT_PATTERNS, TRAFFIC_TAXONOMY_BUCKETS, TRUSTED_BOTS, TaskAdmissionProtocolSchema, TaskGrantAdmissionRequestSchema, TaskGrantAdmissionSchema, TaskGrantAllowanceSchema, TaskGrantArgumentsSchema, TaskGrantBindingSchema, TaskGrantEffectiveStatusSchema, TaskGrantHolderListRequestSchema, TaskGrantIssueResultSchema, TaskGrantListSchema, TaskGrantRevocationSchema, TaskGrantSchema, TaskGrantStatusRequestSchema, TaskGrantStatusSchema, TaskGrantStatusValueSchema, TaskGrantViewSchema, TaskLeadAssignmentSchema, TaskLeadPoolSchema, TaskMailboxClaimRequestSchema, TaskMailboxClaimSchema, TaskMailboxProtocolSchema, TaskMailboxResultSchema, TaskMailboxScopeSchema, TaskMailboxSettlementSchema, TaskMailboxStatusRequestSchema, TaskMailboxStatusSchema, TaskModelInvokeSchema, TaskModelMessagesSchema, TaskModelPolicySchema, TaskModelReceiptSchema, TaskModelStatusSchema, TaskModelUsageSchema, TaskProjectionEvidenceSchema, TaskProjectionStateSchema, TaskSourceIntentSchema, TaskSourceProviderConfigSchema, TaskSourceProviderSchema, TaskStandingActionSchema, TaskStandingAdmissionReceiptBaseSchema, TaskStandingAdmissionRequestBaseSchema, TaskStandingAdmissionRequestSchema, TaskStandingAdmissionSchema, TaskStandingCapabilitySchema, TaskStandingLimitsSchema, TaskStandingPolicySchema, TaskStandingReconcileSchema, TaskStatusProjectionListSchema, TaskStatusProjectionSchema, TestDetectionRequestSchema, ThresholdConfigSchema, ToolConsentOverridesSchema, TouchEventSchema, TraceStepSchema, TrackDependencyV2Schema, TrackingReadinessReasonCodeSchema, TrackingReadinessSchema, TransportConfigSchema, TransportMetricsSchema, TransportOptionsSchema, TransportResponseSchema, TransportStateSchema, UNCALIBRATED_NOISY_OR_PRIOR, UNNAMED_AGENT_LABEL, UPDATE_FREQUENCIES, USER_AGENT_PATTERNS, UUID_PATTERN, UpdateApiKeySchema, UpdateBouncerConfigSchema, UpdateOrganizationInputSchema, UpdateOrganizationSchema, UpdatePixelSchema, UpdateProfileRequestSchema, UpdateProjectSchema, UpdateSettingsSchema, UserAgentRuleSchema, UserPlanSchema, UserSchema, VALIDATION_ERRORS, VALIDATION_MODES, VALIDATION_PATTERNS, VERDICT_COOKIE_NAME, VERSION, VerdictEvidenceSchema, VerificationCacheEntrySchema, VerificationProviderSchema, VerificationRequestSchema, VerificationResponseSchema, VerificationTokenSchema, WEBHOOK_LIMITS, WasmAgentNameSchema, WasmConfigSchema, WasmDetectionResultSchema, WasmRequestMetadataSchema, WasmRiskLevel, WasmVerificationMethod, WorkerActionSchema, WorkerCapabilitiesSchema, WorkerConfigSchema, WorkerErrorSchema, WorkerErrorTypeSchema, WorkerHealthStatusSchema, WorkerMessageSchema, WorkerMessageTypeSchema, WorkerMetricsSchema, WorkerPoolConfigSchema, WorkerStateSchema, WorkerTaskSchema, WorkloadEnrollmentChallengeSchema, WorkloadEnrollmentListSchema, WorkloadEnrollmentProofPayloadSchema, WorkloadEnrollmentResultSchema, WorkloadEnrollmentRevocationSchema, WorkloadEnrollmentSchema, WorkloadRotationProofPayloadSchema, acceptsHtml, adminOverviewQuerySchema, approvalQuorumForRequest, assertVendorRangesFresh, assignmentChangeRequestSchema, auditLogQuerySchema, base58btcDecode, base58btcEncode, batchAssignmentRequestSchema, bespokePolicyLabel, blockDelegationVerdict, blockEqualityLiterals, buildChallengeWire, buildDelegationBearerHeader, buildDelegationChallengeBody, buildDelegationChallengeEnvelope, buildDelegationChallengeHeader, buildDelegationInstructions, buildInitialStepsState, buildKnownPatternLookup, buildVerdictEvidence, calculateDeployProgress, callbackSchema, cedarQuotedValueRegExp, changePasswordSchema, classifyAgentTaxonomy, classifyResponseShape, claudeRuntimeLabel, compressIpv6, computeEntropyConfidence, contractDigest, createError, createErrorResponse, createEvaluationContext, createKyaA2AAgentCard, createPaginatedResponse, createPaginatedResponseSchema, createPolicyFetcher, createSuccessResponse, createValidationErrorResponse, decisionPolicyId, decodeDidKeyEd25519, decodeDidKeyP256, decodeEd25519PublicKeyMultibaseTolerant, defaultConfig, deriveConflictId, deriveCorrelationId, deriveDelegationPickupUri, deriveImportIssueId, deriveMcpClientDid, deriveMcpiOrgDid, deriveMcpiOrgKid, deriveMcpiUserDid, deriveVerdict, detectionClassToEnum, discoveredToolSchema, encodeDidKeyEd25519, encodeEd25519PublicKeyMultibase, encodeVerdictCookie, enumToDetectionClass, escapeCedarString, evaluatePolicy, extractCorrelationIdFromHeaders, extractMatch, fetchPolicy, findMatchingPattern, findStaleVendorRanges, forgotPasswordSchema, formatAgentCategory, formatAgentCategoryInline, formatConfidence, formatReasonCodesHeader, fromProviderRegistryFormat, fromProviderRegistryFormatSafe, gatewayConfigInputSchema, gatewayConfigSchema, gatewayConnectedAgentSchema, gatewayConnectionsSummarySchema, gatewayInternalDiscoverErrorSchema, gatewayInternalDiscoverSuccessSchema, gatewayInternalToolsListSchema, gatewayToolCallSchema, generateDelegationSid, generateTestId, getAgentDisplayName, getBotType, getCategoryBadgeVariant, getCategoryColor, getConfidenceLevel, getDefaultPolicyFetcher, getEnvVar, getRateLimitWindow, getRemainingQuota, getStepInfo, getStepOrder, getVerificationMethodDescription, getVerificationReliability, getVerificationRiskLevel, hasClaudeCodeToken, hasClaudeSearchBotToken, hasClaudeUserToken, hasPinnedSigningVendor, initializePolicyFetcher, ipAddressSchema, isAuthorizedLead, isBespokePolicyId, isBlockingAction, isClaudeProductLabel, isForbidBlock, isHighConfidenceVerification, isKnownAgentType, isKnownAiCrawler, isKyaOsHandshakeMethod, isKyaOsWireMethod, isLegacyDetectionClass, isLegitimateCategory, isLimitExceeded, isNonNavigablePolicyId, isPassThroughAction, isPolicyUnavailableError, isPrivateOrReservedHost, isSupportedAuthType, isTraditionalBot, isUnnarrowedDenyBlock, isValidAuthorizationHost, isValidFingerprintResponse, isValidMcpiOrgSlug, isValidWasmDetectionResult, isValidWasmRequestMetadata, lintUnnarrowedDenyRules, loadRulesAsync, mapDetectionToReasonCodes, mapLegacyAuthType, mapToLegacyAuthType, matchPath, mergeWithDefaults, migrateLegacyDetectionClass, modelCredentialFingerprint, nonNavigablePolicyLabel, normalizeAgentName, normalizeChallengeType, normalizeClientIp, normalizeConfidence, normalizeDetectionClass, normalizeDetectionClassEnum, normalizeHandshakeMethod, normalizeOrganizationName, normalizeWireMethod, oauthClientSchema, parseAcceptedArtifactRevision, parseAgentName, parseClaimVerification, parseDependencyBinding, parseEvaluationContext, parseImportIssueV2, parseIpv6, parseJafarFeed, parseMaterializationPlan, parsePolicyConfig, parseRules, partial, passwordSchema, pathHasUnnarrowedDenyRule, pathLiteralsInBlock, permitDelegationVerdict, projectResetRequestSchema, readableText, reconstructConfidenceFromEvidence, refineClaudeDisplayLabel, refineSessionGrainClaudeLabel, requestCarriesDelegationProof, requiredScopesForRequest, resetPasswordSchema, resetPolicyFetcher, resolveAuthorizationHost, resolveBotSignals, resolveChallengeContext, resolveClientIp, resolveTrustedDelegationRoots, riskScoreColumnValue, riskScoreFromMetadata, riskScoreSourceFromMetadata, safeParsePolicyConfig, safeUrl, selectBodyReadable200, serveBodyReadable200, signInSchema, signUpSchema, splitCedarBlocks, strict, supportsClientSide, supportsHeaders, supportsServerEnhanced, taskGrantArgumentsDigest, testPattern, testPatterns, toBareHost, toCoarseReasonKind, toPercent, toProviderRegistryFormat, toStoredCorrelationId, toWasmRequestMetadata, unescapeCedarString, updateStepsState, upstreamDiscoveryErrorSchema, upstreamServerInputSchema, upstreamServerSchema, validModelAdmission, validate, validateClientDetection, validateFingerprintRequest, validateOrThrow, validateOrganizationName, validateProviderConfig, validateProviderDefinition, validateRules, validateRulesLoose, validateStepUpQuorum, vaultResolveDataSchema, vaultResolveErrorSchema, vaultResolveMetaSchema, vaultResolveResponseSchema, vaultResolveSuccessSchema, verifyContractRecordIdentity, verifyEmailSchema, wasmToDetectionResult };
|
|
15391
18303
|
//# sourceMappingURL=index.mjs.map
|