@kya-os/checkpoint-shared 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/dist/beacon-types/index.d.mts +441 -432
- package/dist/beacon-types/index.d.mts.map +1 -0
- package/dist/beacon-types/index.d.ts +441 -432
- package/dist/beacon-types/index.d.ts.map +1 -0
- package/dist/beacon-types/index.js +198 -182
- package/dist/beacon-types/index.mjs +197 -179
- package/dist/beacon-types/index.mjs.map +1 -0
- package/dist/browser-posture-cookie-Dmq9Brf_.d.mts +5 -0
- package/dist/browser-posture-cookie-Dmq9Brf_.d.mts.map +1 -0
- package/dist/browser-posture-cookie-Dmq9Brf_.d.ts +5 -0
- package/dist/browser-posture-cookie-Dmq9Brf_.d.ts.map +1 -0
- package/dist/browser-posture-cookie.d.mts +2 -0
- package/dist/browser-posture-cookie.d.ts +2 -0
- package/dist/browser-posture-cookie.js +1 -0
- package/dist/browser-posture-cookie.mjs +2 -0
- package/dist/browser-posture-cookie.mjs.map +1 -0
- package/dist/browser-posture-report.d.mts +48 -44
- package/dist/browser-posture-report.d.mts.map +1 -0
- package/dist/browser-posture-report.d.ts +48 -44
- package/dist/browser-posture-report.d.ts.map +1 -0
- package/dist/browser-posture-report.js +1 -1
- package/dist/browser-posture-report.mjs +2 -1
- package/dist/browser-posture-report.mjs.map +1 -0
- package/dist/browser-posture.d.mts +80 -75
- package/dist/browser-posture.d.mts.map +1 -0
- package/dist/browser-posture.d.ts +80 -75
- package/dist/browser-posture.d.ts.map +1 -0
- package/dist/browser-posture.js +159 -18993
- package/dist/browser-posture.mjs +158 -18990
- package/dist/browser-posture.mjs.map +1 -0
- package/dist/browser.d.mts +323 -316
- package/dist/browser.d.mts.map +1 -0
- package/dist/browser.d.ts +323 -316
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +1 -1
- package/dist/browser.mjs +2 -1
- package/dist/browser.mjs.map +1 -0
- package/dist/canonical-signer/index.d.mts +38 -33
- package/dist/canonical-signer/index.d.mts.map +1 -0
- package/dist/canonical-signer/index.d.ts +38 -33
- package/dist/canonical-signer/index.d.ts.map +1 -0
- package/dist/canonical-signer/index.js +411 -181
- package/dist/canonical-signer/index.mjs +383 -175
- package/dist/canonical-signer/index.mjs.map +1 -0
- package/dist/clearance.d.mts +30 -0
- package/dist/clearance.d.mts.map +1 -0
- package/dist/clearance.d.ts +30 -0
- package/dist/clearance.d.ts.map +1 -0
- package/dist/clearance.js +120 -0
- package/dist/clearance.mjs +112 -0
- package/dist/clearance.mjs.map +1 -0
- package/dist/client-ip-1y2iXAYW.js +237 -0
- package/dist/client-ip-HOfe6ucV.mjs +215 -0
- package/dist/client-ip-HOfe6ucV.mjs.map +1 -0
- package/dist/deploy/index.d.mts +339 -339
- package/dist/deploy/index.d.mts.map +1 -0
- package/dist/deploy/index.d.ts +339 -339
- package/dist/deploy/index.d.ts.map +1 -0
- package/dist/deploy/index.js +505 -413
- package/dist/deploy/index.mjs +504 -410
- package/dist/deploy/index.mjs.map +1 -0
- package/dist/errors/index.d.mts +101 -101
- package/dist/errors/index.d.mts.map +1 -0
- package/dist/errors/index.d.ts +101 -101
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +341 -314
- package/dist/errors/index.mjs +340 -311
- package/dist/errors/index.mjs.map +1 -0
- package/dist/external-jr_S4iSS.d.mts +4187 -0
- package/dist/external-jr_S4iSS.d.mts.map +1 -0
- package/dist/external-jr_S4iSS.d.ts +4187 -0
- package/dist/external-jr_S4iSS.d.ts.map +1 -0
- package/dist/gateway/index.d.mts +138 -132
- package/dist/gateway/index.d.mts.map +1 -0
- package/dist/gateway/index.d.ts +138 -132
- package/dist/gateway/index.d.ts.map +1 -0
- package/dist/gateway/index.js +117 -81
- package/dist/gateway/index.mjs +116 -78
- package/dist/gateway/index.mjs.map +1 -0
- package/dist/gateway-client-ip.d.mts +59 -0
- package/dist/gateway-client-ip.d.mts.map +1 -0
- package/dist/gateway-client-ip.d.ts +59 -0
- package/dist/gateway-client-ip.d.ts.map +1 -0
- package/dist/gateway-client-ip.js +149 -0
- package/dist/gateway-client-ip.mjs +139 -0
- package/dist/gateway-client-ip.mjs.map +1 -0
- package/dist/index.d.mts +14895 -14240
- package/dist/index.d.mts.map +1 -0
- package/dist/index.d.ts +14895 -14240
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15180 -31025
- package/dist/index.mjs +15065 -30942
- package/dist/index.mjs.map +1 -0
- package/dist/mcpi/agentshield-api/index.d.mts +45 -44
- package/dist/mcpi/agentshield-api/index.d.mts.map +1 -0
- package/dist/mcpi/agentshield-api/index.d.ts +45 -44
- package/dist/mcpi/agentshield-api/index.d.ts.map +1 -0
- package/dist/mcpi/agentshield-api/index.js +0 -2
- package/dist/mcpi/agentshield-api/index.mjs +1 -1
- package/dist/mcpi/approval-grant/index.d.mts +63 -61
- package/dist/mcpi/approval-grant/index.d.mts.map +1 -0
- package/dist/mcpi/approval-grant/index.d.ts +63 -61
- package/dist/mcpi/approval-grant/index.d.ts.map +1 -0
- package/dist/mcpi/approval-grant/index.js +220 -140
- package/dist/mcpi/approval-grant/index.mjs +219 -137
- package/dist/mcpi/approval-grant/index.mjs.map +1 -0
- package/dist/mcpi/dashboard-config/index.d.mts +2323 -2318
- package/dist/mcpi/dashboard-config/index.d.mts.map +1 -0
- package/dist/mcpi/dashboard-config/index.d.ts +2323 -2318
- package/dist/mcpi/dashboard-config/index.d.ts.map +1 -0
- package/dist/mcpi/dashboard-config/index.js +605 -458
- package/dist/mcpi/dashboard-config/index.mjs +604 -455
- package/dist/mcpi/dashboard-config/index.mjs.map +1 -0
- package/dist/mcpi/multibase-ed25519.d.mts +10 -8
- package/dist/mcpi/multibase-ed25519.d.mts.map +1 -0
- package/dist/mcpi/multibase-ed25519.d.ts +10 -8
- package/dist/mcpi/multibase-ed25519.d.ts.map +1 -0
- package/dist/mcpi/multibase-ed25519.js +182 -106
- package/dist/mcpi/multibase-ed25519.mjs +181 -103
- package/dist/mcpi/multibase-ed25519.mjs.map +1 -0
- package/dist/patterns-CkRVOdtV.js +243 -0
- package/dist/patterns-DzkGy_qk.mjs +173 -0
- package/dist/patterns-DzkGy_qk.mjs.map +1 -0
- package/dist/project-verification-key-C3L5rd8a.js +41 -0
- package/dist/project-verification-key-CgSVX9_m.mjs +37 -0
- package/dist/project-verification-key-CgSVX9_m.mjs.map +1 -0
- package/dist/rolldown-runtime-iY2fYEqi.mjs +19 -0
- package/dist/schemas-BmjNLAE7.js +5677 -0
- package/dist/schemas-DxY-dk9y.mjs +5511 -0
- package/dist/schemas-DxY-dk9y.mjs.map +1 -0
- package/dist/signals/index.d.mts +125 -115
- package/dist/signals/index.d.mts.map +1 -0
- package/dist/signals/index.d.ts +125 -115
- package/dist/signals/index.d.ts.map +1 -0
- package/dist/signals/index.js +1693 -1536
- package/dist/signals/index.mjs +1692 -1533
- package/dist/signals/index.mjs.map +1 -0
- package/dist/test-fixtures/index.d.mts +124 -119
- package/dist/test-fixtures/index.d.mts.map +1 -0
- package/dist/test-fixtures/index.d.ts +124 -119
- package/dist/test-fixtures/index.d.ts.map +1 -0
- package/dist/test-fixtures/index.js +460 -228
- package/dist/test-fixtures/index.mjs +459 -225
- package/dist/test-fixtures/index.mjs.map +1 -0
- package/dist/tool-protection/index.d.mts +343 -343
- package/dist/tool-protection/index.d.mts.map +1 -0
- package/dist/tool-protection/index.d.ts +343 -343
- package/dist/tool-protection/index.d.ts.map +1 -0
- package/dist/tool-protection/index.js +366 -285
- package/dist/tool-protection/index.mjs +365 -282
- package/dist/tool-protection/index.mjs.map +1 -0
- package/fixtures/bot-signal-resolution.json +142 -0
- package/fixtures/browser-posture-claims.json +421 -0
- package/fixtures/browser-posture-headers.json +46 -0
- package/fixtures/detection/reason-codes.json +10 -1
- package/fixtures/kya-http/challenge.delegation.fetcher-200.json +9 -3
- package/fixtures/kya-http/challenge.delegation.full.json +9 -3
- package/fixtures/kya-http/challenge.delegation.minimal.json +9 -3
- package/fixtures/kya-http/error-codes.json +7 -2
- package/package.json +20 -6
|
@@ -1,252 +1,484 @@
|
|
|
1
|
-
'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
//#region src/test-fixtures/vault-wire-contract.ts
|
|
3
|
+
/**
|
|
4
|
+
* Shared test fixture for the #1532 gateway ↔ vault wire contract.
|
|
5
|
+
*
|
|
6
|
+
* **DO NOT IMPORT FROM PRODUCTION CODE.** This file is exposed only via
|
|
7
|
+
* the `@kya-os/checkpoint-shared/test-fixtures` subpath export so
|
|
8
|
+
* production bundles that import from the root package entry point
|
|
9
|
+
* can't reach it — the tree-shaker has no path to these symbols unless
|
|
10
|
+
* a caller explicitly imports from the test-fixtures subpath.
|
|
11
|
+
*
|
|
12
|
+
* ## Purpose
|
|
13
|
+
*
|
|
14
|
+
* #1532 spans two services that must agree byte-for-byte on:
|
|
15
|
+
*
|
|
16
|
+
* 1. The shape of the JWT assertion the gateway signs
|
|
17
|
+
* 2. The HTTP request body the gateway POSTs to the vault endpoint
|
|
18
|
+
* 3. The claims the vault endpoint extracts after verifying the JWT
|
|
19
|
+
*
|
|
20
|
+
* This fixture pins a known-good input/output pair that both sides'
|
|
21
|
+
* unit tests import. If either side's implementation drifts from the
|
|
22
|
+
* contract (wrong field order, wrong base64url encoding, wrong key
|
|
23
|
+
* derivation, etc), the test against this fixture fails loudly without
|
|
24
|
+
* requiring a live end-to-end test.
|
|
25
|
+
*
|
|
26
|
+
* The fixture values below were generated ONCE by running the gateway
|
|
27
|
+
* side's `signAssertion` function against a deterministic seed + the
|
|
28
|
+
* canonical claims. Ed25519 is deterministic per RFC 8032 §5.1.6, so
|
|
29
|
+
* the same inputs ALWAYS produce the same signature — which is what
|
|
30
|
+
* lets us commit `expectedJwt` as a string literal and assert equality
|
|
31
|
+
* across both sides' test runs.
|
|
32
|
+
*
|
|
33
|
+
* ## Test keypair (NOT PRODUCTION)
|
|
34
|
+
*
|
|
35
|
+
* The private key below is 32 bytes of `0x01` — the simplest possible
|
|
36
|
+
* deterministic seed. It is NOT a real private key and must NEVER be
|
|
37
|
+
* used to sign any real vault assertion. Its only purpose is to produce
|
|
38
|
+
* reproducible fixture bytes that both engineers can check against.
|
|
39
|
+
*
|
|
40
|
+
* The corresponding public key was derived via Node's
|
|
41
|
+
* `createPublicKey(privateKey)` and is included here for Engineer 2's
|
|
42
|
+
* vault-side verification tests — vault tests don't need to reconstruct
|
|
43
|
+
* the private half, only to verify signatures against this public key.
|
|
44
|
+
*
|
|
45
|
+
* ## Claim fixture
|
|
46
|
+
*
|
|
47
|
+
* The `canonicalPayload` matches the wire contract §2.2 sample verbatim:
|
|
48
|
+
* eight claims in the exact order `iss, projectId, userDid, toolName,
|
|
49
|
+
* sessionId, nonce, iat, exp`. Field order is load-bearing because
|
|
50
|
+
* `JSON.stringify` preserves insertion order in V8 and the resulting
|
|
51
|
+
* byte sequence is what Ed25519 signs over — reordering would produce
|
|
52
|
+
* a different signature, breaking cross-service determinism.
|
|
53
|
+
*
|
|
54
|
+
* The `iat`/`exp` timestamps are frozen at `1712975940` / `1712976000`
|
|
55
|
+
* (60-second window ending 2024-04-13T01:20:00Z-ish). Tests that run
|
|
56
|
+
* against this fixture must either (a) not validate `exp` against wall
|
|
57
|
+
* clock time, or (b) use `vi.useFakeTimers({ now: 1712975940000 })` to
|
|
58
|
+
* freeze the clock inside the fixture window.
|
|
59
|
+
*/
|
|
60
|
+
/**
|
|
61
|
+
* Test keypair for the wire-contract fixture. Ed25519 private seed is
|
|
62
|
+
* 32 bytes of `0x01`; public key is derived from it.
|
|
63
|
+
*
|
|
64
|
+
* **DO NOT USE IN PRODUCTION.**
|
|
65
|
+
*/
|
|
66
|
+
const VAULT_WIRE_CONTRACT_TEST_KEYPAIR = {
|
|
67
|
+
/** 32 bytes of 0x01, base64-encoded. Load into the signer via `loadSigningKey`. */
|
|
68
|
+
privateKeyBase64: "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=",
|
|
69
|
+
/** Raw 32-byte Ed25519 public key derived from the private seed, base64-encoded. */
|
|
70
|
+
publicKeyBase64: "iojj3XQJ8ZX9UtstPLpdcspnCb8dlBIb83SIAbQPb1w="
|
|
9
71
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
72
|
+
/**
|
|
73
|
+
* The canonical JWT header both sides expect. Wire contract §2.1:
|
|
74
|
+
* `alg` is `EdDSA` (NOT `Ed25519` — common mistake), `typ` is `JWT`,
|
|
75
|
+
* `crv` is included for disambiguation per RFC 8037 §3.1.
|
|
76
|
+
*/
|
|
77
|
+
const VAULT_WIRE_CONTRACT_EXPECTED_HEADER = {
|
|
78
|
+
alg: "EdDSA",
|
|
79
|
+
typ: "JWT",
|
|
80
|
+
crv: "Ed25519"
|
|
14
81
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
82
|
+
/**
|
|
83
|
+
* The canonical payload both sides assert against. Wire contract §2.2
|
|
84
|
+
* order is load-bearing — rearranging these fields will produce a
|
|
85
|
+
* different `expectedJwt` because `JSON.stringify` preserves insertion
|
|
86
|
+
* order.
|
|
87
|
+
*/
|
|
88
|
+
const VAULT_WIRE_CONTRACT_CANONICAL_PAYLOAD = {
|
|
89
|
+
iss: "did:web:gateway.knowthat.ai",
|
|
90
|
+
projectId: "00000000-0000-0000-0000-000000000001",
|
|
91
|
+
userDid: "alice@example.test",
|
|
92
|
+
toolName: "create_issue",
|
|
93
|
+
sessionId: "gateway-oauth-test-sess-01",
|
|
94
|
+
nonce: "0123456789abcdef",
|
|
95
|
+
iat: 1712975940,
|
|
96
|
+
exp: 1712976e3
|
|
24
97
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
98
|
+
/**
|
|
99
|
+
* The deterministic JWT produced by signing
|
|
100
|
+
* {@link VAULT_WIRE_CONTRACT_CANONICAL_PAYLOAD} with the private half of
|
|
101
|
+
* {@link VAULT_WIRE_CONTRACT_TEST_KEYPAIR}, via the gateway-side
|
|
102
|
+
* `signAssertion` helper.
|
|
103
|
+
*
|
|
104
|
+
* Generated ONCE by running:
|
|
105
|
+
*
|
|
106
|
+
* ```
|
|
107
|
+
* pnpm --filter @kya-os/checkpoint-gateway exec tsx -e "..."
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* and committed as a string literal. DO NOT regenerate this value
|
|
111
|
+
* without understanding that both sides of the contract will need to
|
|
112
|
+
* re-validate. If your implementation produces a different JWT for the
|
|
113
|
+
* same canonical inputs, the bug is in YOUR code, not the fixture.
|
|
114
|
+
*
|
|
115
|
+
* Ed25519's deterministic signing property (RFC 8032 §5.1.6) is what
|
|
116
|
+
* makes this string stable across runs, machines, and invocations.
|
|
117
|
+
*/
|
|
118
|
+
const VAULT_WIRE_CONTRACT_EXPECTED_JWT = "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCIsImNydiI6IkVkMjU1MTkifQ.eyJpc3MiOiJkaWQ6d2ViOmdhdGV3YXkua25vd3RoYXQuYWkiLCJwcm9qZWN0SWQiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDEiLCJ1c2VyRGlkIjoiYWxpY2VAZXhhbXBsZS50ZXN0IiwidG9vbE5hbWUiOiJjcmVhdGVfaXNzdWUiLCJzZXNzaW9uSWQiOiJnYXRld2F5LW9hdXRoLXRlc3Qtc2Vzcy0wMSIsIm5vbmNlIjoiMDEyMzQ1Njc4OWFiY2RlZiIsImlhdCI6MTcxMjk3NTk0MCwiZXhwIjoxNzEyOTc2MDAwfQ.i-7vlvhLiohx6Qg0pXjfmllaDoZ_Fiu8KYW7vovHlQOPw9gsDrOECtM5qymv8bTf__hZKQeU8PyxBHtDusTDAg";
|
|
119
|
+
/**
|
|
120
|
+
* The expected HTTP request body the gateway sends to the vault
|
|
121
|
+
* endpoint for the canonical payload. Wire contract §2.4 — all 5
|
|
122
|
+
* fields are required, `assertion` is the full JWT from
|
|
123
|
+
* {@link VAULT_WIRE_CONTRACT_EXPECTED_JWT}, and `userDid` MUST match
|
|
124
|
+
* the assertion's `userDid` claim (the vault side rejects mismatches
|
|
125
|
+
* with a 403).
|
|
126
|
+
*/
|
|
127
|
+
const VAULT_WIRE_CONTRACT_EXPECTED_REQUEST_BODY = {
|
|
128
|
+
userDid: "alice@example.test",
|
|
129
|
+
envVarNames: ["GITHUB_TOKEN"],
|
|
130
|
+
toolName: "create_issue",
|
|
131
|
+
sessionId: "gateway-oauth-test-sess-01",
|
|
132
|
+
assertion: VAULT_WIRE_CONTRACT_EXPECTED_JWT
|
|
32
133
|
};
|
|
33
|
-
|
|
134
|
+
/**
|
|
135
|
+
* The canonical vault endpoint URL path for the fixture's projectId.
|
|
136
|
+
* Both sides use this to verify their URL construction logic. Base URL
|
|
137
|
+
* is NOT included — this is the path portion only.
|
|
138
|
+
*
|
|
139
|
+
* Path note: the gateway's vault endpoint lives under
|
|
140
|
+
* `/api/v1/gateway/vault/...`, NOT `/api/v1/vault/...`. The unprefixed
|
|
141
|
+
* `/api/v1/vault/{projectId}/resolve` path is owned by the #1299
|
|
142
|
+
* (VAULT-5) KYA-OS worker flow, which uses `X-API-Key` auth and is
|
|
143
|
+
* architecturally incompatible with #1532's Ed25519-only model per
|
|
144
|
+
* #1542 Decision 1 = B. The gateway gets its own parallel namespace
|
|
145
|
+
* under `/api/v1/gateway/vault/*` so the two flows can coexist
|
|
146
|
+
* without the KYA-OS handler needing auth-branching logic.
|
|
147
|
+
*
|
|
148
|
+
* See the corrected wire contract §2.4 on issue #1532.
|
|
149
|
+
*/
|
|
150
|
+
const VAULT_WIRE_CONTRACT_URL_PATH = "/api/v1/gateway/vault/00000000-0000-0000-0000-000000000001/resolve";
|
|
34
151
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region src/test-fixtures/mcpi-delegation-fixture.ts
|
|
154
|
+
/**
|
|
155
|
+
* Shared test fixture for #1531 gateway OAuth ↔ KYA-OS delegation credential contract.
|
|
156
|
+
*
|
|
157
|
+
* **DO NOT IMPORT FROM PRODUCTION CODE.** Exposed only via the
|
|
158
|
+
* `@kya-os/checkpoint-shared/test-fixtures` subpath export.
|
|
159
|
+
*
|
|
160
|
+
* ## Purpose
|
|
161
|
+
*
|
|
162
|
+
* #1531 spans two services that must agree on the VC-JWT wire format:
|
|
163
|
+
*
|
|
164
|
+
* 1. Engineer 2's authorization server (Vercel) — issues the VC-JWT
|
|
165
|
+
* 2. Engineer 1's gateway resolver (Fly) — verifies the VC-JWT
|
|
166
|
+
*
|
|
167
|
+
* This fixture pins a known-good VC-JWT that both sides' tests import.
|
|
168
|
+
* If either side drifts from the contract, the test against this fixture
|
|
169
|
+
* fails loudly.
|
|
170
|
+
*
|
|
171
|
+
* ## Test keypair (NOT PRODUCTION)
|
|
172
|
+
*
|
|
173
|
+
* Reuses the #1532 convention: private key is 32 bytes of `0x01`.
|
|
174
|
+
* Ed25519 is deterministic (RFC 8032 §5.1.6), so same inputs always
|
|
175
|
+
* produce the same signature — which is what makes the expected JWT
|
|
176
|
+
* string stable across runs.
|
|
177
|
+
*
|
|
178
|
+
* ## VC-JWT structure
|
|
179
|
+
*
|
|
180
|
+
* The JWT follows the KYA-OS §6.2 DelegationCredential as W3C VC pattern:
|
|
181
|
+
* - Header: { alg: "EdDSA", typ: "JWT", kid: "<issuer-key-id>" }
|
|
182
|
+
* - Payload: { iss, sub, aud, iat, exp, vc: { ... W3C VC ... }, orgId, orgSlug, sessionId }
|
|
183
|
+
* - vc.credentialSubject.delegation contains the KYA-OS delegation record
|
|
184
|
+
* - vc.credentialStatus contains StatusList2021 revocation reference
|
|
185
|
+
*
|
|
186
|
+
* ## Clock note
|
|
187
|
+
*
|
|
188
|
+
* Timestamps are frozen at iat=1712975940 (April 2024). Tests that validate
|
|
189
|
+
* expiry must use vi.useFakeTimers({ now: 1712975940000 }).
|
|
190
|
+
*/
|
|
191
|
+
/** Ed25519 test keypair. DO NOT USE IN PRODUCTION. */
|
|
192
|
+
const MCPI_DELEGATION_TEST_KEYPAIR = {
|
|
193
|
+
/** 32 bytes of 0x01, base64-encoded. */
|
|
194
|
+
privateKeyBase64: "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=",
|
|
195
|
+
/** Raw 32-byte Ed25519 public key derived from the private seed, base64-encoded. */
|
|
196
|
+
publicKeyBase64: "iojj3XQJ8ZX9UtstPLpdcspnCb8dlBIb83SIAbQPb1w="
|
|
41
197
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
198
|
+
/** DID of the org issuer (signs the VC-JWT). */
|
|
199
|
+
const MCPI_DELEGATION_ISSUER_DID = "did:web:kya.vouched.id:orgs:test-org";
|
|
200
|
+
/**
|
|
201
|
+
* Key ID of the OAuth signing key in the DID document.
|
|
202
|
+
*
|
|
203
|
+
* DR-1 / E1-P1 moved delegation issuance from the gateway operational DID
|
|
204
|
+
* to per-org issuer DIDs. The verifier resolves the org DID document and
|
|
205
|
+
* looks up that org's `#key-1` method.
|
|
206
|
+
*/
|
|
207
|
+
const MCPI_DELEGATION_ISSUER_KID = "did:web:kya.vouched.id:orgs:test-org#key-1";
|
|
208
|
+
/** DID of the test MCP client (agent). */
|
|
209
|
+
const MCPI_DELEGATION_AGENT_DID = "did:key:z6MkTestAgent123";
|
|
210
|
+
/** DID of the authorizing user. */
|
|
211
|
+
const MCPI_DELEGATION_USER_DID = "did:key:z6MkTestUser456";
|
|
212
|
+
/** StatusList2021 endpoint URL. */
|
|
213
|
+
const MCPI_DELEGATION_STATUS_LIST_URL = "https://kya.vouched.id/api/v1/gateway/oauth/status-list";
|
|
214
|
+
/** Audience claim — the gateway's HTTPS origin. */
|
|
215
|
+
const MCPI_DELEGATION_AUDIENCE = "https://gateway.knowthat.ai";
|
|
216
|
+
/**
|
|
217
|
+
* The canonical JWT payload. Field order is load-bearing because
|
|
218
|
+
* JSON.stringify preserves insertion order and Ed25519 signs over
|
|
219
|
+
* the resulting bytes.
|
|
220
|
+
*/
|
|
221
|
+
const MCPI_DELEGATION_CANONICAL_PAYLOAD = {
|
|
222
|
+
iss: "did:web:kya.vouched.id:orgs:test-org",
|
|
223
|
+
sub: "did:key:z6MkTestAgent123",
|
|
224
|
+
aud: "https://gateway.knowthat.ai",
|
|
225
|
+
iat: 1712975940,
|
|
226
|
+
exp: 1712979540,
|
|
227
|
+
vc: {
|
|
228
|
+
"@context": ["https://www.w3.org/2018/credentials/v1", "https://schema.modelcontextprotocol-identity.io/xmcp-i/credentials/delegation.v1.0.0.json"],
|
|
229
|
+
type: ["VerifiableCredential", "DelegationCredential"],
|
|
230
|
+
issuer: "did:web:kya.vouched.id:orgs:test-org",
|
|
231
|
+
issuanceDate: "2024-04-13T02:39:00.000Z",
|
|
232
|
+
expirationDate: "2024-04-13T03:39:00.000Z",
|
|
233
|
+
credentialSubject: {
|
|
234
|
+
id: "did:key:z6MkTestAgent123",
|
|
235
|
+
delegation: {
|
|
236
|
+
id: "del-test-001",
|
|
237
|
+
issuerDid: "did:web:kya.vouched.id:orgs:test-org",
|
|
238
|
+
subjectDid: "did:key:z6MkTestAgent123",
|
|
239
|
+
userDid: "did:key:z6MkTestUser456",
|
|
240
|
+
userIdentifier: "alice@vouched.id",
|
|
241
|
+
scopes: ["mcp"],
|
|
242
|
+
constraints: {
|
|
243
|
+
notBefore: 1712975940,
|
|
244
|
+
notAfter: 1712979540,
|
|
245
|
+
scopes: ["mcp"],
|
|
246
|
+
audience: "https://gateway.knowthat.ai"
|
|
247
|
+
},
|
|
248
|
+
status: "active"
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
credentialStatus: {
|
|
252
|
+
id: "https://kya.vouched.id/api/v1/gateway/oauth/status-list#42",
|
|
253
|
+
type: "StatusList2021Entry",
|
|
254
|
+
statusPurpose: "revocation",
|
|
255
|
+
statusListIndex: "42",
|
|
256
|
+
statusListCredential: "https://kya.vouched.id/api/v1/gateway/oauth/status-list"
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
orgId: "00000000-0000-0000-0000-000000000010",
|
|
260
|
+
orgSlug: "test-org",
|
|
261
|
+
sessionId: "00000000-0000-0000-0000-000000000020"
|
|
99
262
|
};
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
263
|
+
const MCPI_DELEGATION_EXPECTED_HEADER = {
|
|
264
|
+
alg: "EdDSA",
|
|
265
|
+
typ: "JWT",
|
|
266
|
+
kid: "did:web:kya.vouched.id:orgs:test-org#key-1"
|
|
104
267
|
};
|
|
105
|
-
|
|
268
|
+
/**
|
|
269
|
+
* The deterministic VC-JWT produced by signing
|
|
270
|
+
* {@link MCPI_DELEGATION_CANONICAL_PAYLOAD} with the private half of
|
|
271
|
+
* {@link MCPI_DELEGATION_TEST_KEYPAIR}.
|
|
272
|
+
*
|
|
273
|
+
* Generated ONCE. DO NOT regenerate without understanding that both
|
|
274
|
+
* sides of the #1531 contract will need to re-validate.
|
|
275
|
+
*
|
|
276
|
+
* Size: ~1.8KB — well within the 8KB HTTP header budget.
|
|
277
|
+
*/
|
|
278
|
+
const MCPI_DELEGATION_EXPECTED_JWT = "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCIsImtpZCI6ImRpZDp3ZWI6a3lhLnZvdWNoZWQuaWQ6b3Jnczp0ZXN0LW9yZyNrZXktMSJ9.eyJpc3MiOiJkaWQ6d2ViOmt5YS52b3VjaGVkLmlkOm9yZ3M6dGVzdC1vcmciLCJzdWIiOiJkaWQ6a2V5Ono2TWtUZXN0QWdlbnQxMjMiLCJhdWQiOiJodHRwczovL2dhdGV3YXkua25vd3RoYXQuYWkiLCJpYXQiOjE3MTI5NzU5NDAsImV4cCI6MTcxMjk3OTU0MCwidmMiOnsiQGNvbnRleHQiOlsiaHR0cHM6Ly93d3cudzMub3JnLzIwMTgvY3JlZGVudGlhbHMvdjEiLCJodHRwczovL3NjaGVtYS5tb2RlbGNvbnRleHRwcm90b2NvbC1pZGVudGl0eS5pby94bWNwLWkvY3JlZGVudGlhbHMvZGVsZWdhdGlvbi52MS4wLjAuanNvbiJdLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIiwiRGVsZWdhdGlvbkNyZWRlbnRpYWwiXSwiaXNzdWVyIjoiZGlkOndlYjpreWEudm91Y2hlZC5pZDpvcmdzOnRlc3Qtb3JnIiwiaXNzdWFuY2VEYXRlIjoiMjAyNC0wNC0xM1QwMjozOTowMC4wMDBaIiwiZXhwaXJhdGlvbkRhdGUiOiIyMDI0LTA0LTEzVDAzOjM5OjAwLjAwMFoiLCJjcmVkZW50aWFsU3ViamVjdCI6eyJpZCI6ImRpZDprZXk6ejZNa1Rlc3RBZ2VudDEyMyIsImRlbGVnYXRpb24iOnsiaWQiOiJkZWwtdGVzdC0wMDEiLCJpc3N1ZXJEaWQiOiJkaWQ6d2ViOmt5YS52b3VjaGVkLmlkOm9yZ3M6dGVzdC1vcmciLCJzdWJqZWN0RGlkIjoiZGlkOmtleTp6Nk1rVGVzdEFnZW50MTIzIiwidXNlckRpZCI6ImRpZDprZXk6ejZNa1Rlc3RVc2VyNDU2IiwidXNlcklkZW50aWZpZXIiOiJhbGljZUB2b3VjaGVkLmlkIiwic2NvcGVzIjpbIm1jcCJdLCJjb25zdHJhaW50cyI6eyJub3RCZWZvcmUiOjE3MTI5NzU5NDAsIm5vdEFmdGVyIjoxNzEyOTc5NTQwLCJzY29wZXMiOlsibWNwIl0sImF1ZGllbmNlIjoiaHR0cHM6Ly9nYXRld2F5Lmtub3d0aGF0LmFpIn0sInN0YXR1cyI6ImFjdGl2ZSJ9fSwiY3JlZGVudGlhbFN0YXR1cyI6eyJpZCI6Imh0dHBzOi8va3lhLnZvdWNoZWQuaWQvYXBpL3YxL2dhdGV3YXkvb2F1dGgvc3RhdHVzLWxpc3QjNDIiLCJ0eXBlIjoiU3RhdHVzTGlzdDIwMjFFbnRyeSIsInN0YXR1c1B1cnBvc2UiOiJyZXZvY2F0aW9uIiwic3RhdHVzTGlzdEluZGV4IjoiNDIiLCJzdGF0dXNMaXN0Q3JlZGVudGlhbCI6Imh0dHBzOi8va3lhLnZvdWNoZWQuaWQvYXBpL3YxL2dhdGV3YXkvb2F1dGgvc3RhdHVzLWxpc3QifX0sIm9yZ0lkIjoiMDAwMDAwMDAtMDAwMC0wMDAwLTAwMDAtMDAwMDAwMDAwMDEwIiwib3JnU2x1ZyI6InRlc3Qtb3JnIiwic2Vzc2lvbklkIjoiMDAwMDAwMDAtMDAwMC0wMDAwLTAwMDAtMDAwMDAwMDAwMDIwIn0.KEF-cDuLUb-OTJHAXhK2A7VGWpGzdIRY0v4jK-0OXoPqKEadPOHAw1EaEl2V_1NeGyw69V3CRtKug_gx9ZIUBA";
|
|
106
279
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
280
|
+
//#endregion
|
|
281
|
+
//#region src/test-fixtures/fetcher-200-predicate.ts
|
|
282
|
+
/**
|
|
283
|
+
* The frozen cross-PEP predicate vectors. Keep additions semantic (a new
|
|
284
|
+
* distinct case), never a re-statement of an existing one.
|
|
285
|
+
*/
|
|
286
|
+
const FETCHER_200_PREDICATE_VECTORS = [
|
|
287
|
+
{
|
|
288
|
+
description: "opt-in header present, non-agent detection → 200 (header is the primary signal)",
|
|
289
|
+
headers: { "kya-accept-challenge": "delegation" },
|
|
290
|
+
detectionClass: "human",
|
|
291
|
+
isAgent: false,
|
|
292
|
+
expected: true
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
description: "opt-in header present, detection absent → 200",
|
|
296
|
+
headers: { "kya-accept-challenge": "delegation" },
|
|
297
|
+
detectionClass: null,
|
|
298
|
+
isAgent: false,
|
|
299
|
+
expected: true
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
description: "detected ai_agent (isAgent agrees), no opt-in → 200 (transitional UA heuristic)",
|
|
303
|
+
headers: {},
|
|
304
|
+
detectionClass: "ai_agent",
|
|
305
|
+
isAgent: true,
|
|
306
|
+
expected: true
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
description: "Accept: text/html on a detected agent → 200 (Accept MUST NOT branch the body)",
|
|
310
|
+
headers: { accept: "text/markdown, text/html, */*" },
|
|
311
|
+
detectionClass: "ai_agent",
|
|
312
|
+
isAgent: true,
|
|
313
|
+
expected: true
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
description: "ai_agent class but isAgent=false (signals disagree) → 401 (require both, matches .NET + worker)",
|
|
317
|
+
headers: {},
|
|
318
|
+
detectionClass: "ai_agent",
|
|
319
|
+
isAgent: false,
|
|
320
|
+
expected: false
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
description: "human, no opt-in → 401 (spec path)",
|
|
324
|
+
headers: {},
|
|
325
|
+
detectionClass: "human",
|
|
326
|
+
isAgent: false,
|
|
327
|
+
expected: false
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
description: "bot, no opt-in → 401 (non-cooperative / spoofer lands on spec path)",
|
|
331
|
+
headers: {},
|
|
332
|
+
detectionClass: "bot",
|
|
333
|
+
isAgent: false,
|
|
334
|
+
expected: false
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
description: "incomplete_data, no opt-in → 401",
|
|
338
|
+
headers: {},
|
|
339
|
+
detectionClass: "incomplete_data",
|
|
340
|
+
isAgent: false,
|
|
341
|
+
expected: false
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
description: "no signals at all → 401",
|
|
345
|
+
headers: {},
|
|
346
|
+
detectionClass: null,
|
|
347
|
+
isAgent: false,
|
|
348
|
+
expected: false
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
description: "empty opt-in value is ignored, human → 401",
|
|
352
|
+
headers: { "kya-accept-challenge": "" },
|
|
353
|
+
detectionClass: "human",
|
|
354
|
+
isAgent: false,
|
|
355
|
+
expected: false
|
|
356
|
+
}
|
|
179
357
|
];
|
|
180
358
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
359
|
+
//#endregion
|
|
360
|
+
//#region src/mcpi/delegation-verdict.ts
|
|
361
|
+
/**
|
|
362
|
+
* Every raw reason discriminator either runtime can natively emit for the
|
|
363
|
+
* delegation path, mapped onto the coarse taxonomy above.
|
|
364
|
+
*
|
|
365
|
+
* Gateway (`McpiAuthErrorReason` in `mcpi-auth-resolver.ts`,
|
|
366
|
+
* `DashboardVerifyFailure['reason']` in `dashboard-delegation-verifier.ts`):
|
|
367
|
+
* snake_case. Engine (`BlockReason` in `rust/crates/kya-os-engine/src/types.rs`):
|
|
368
|
+
* PascalCase variant names. Unrecognized input is a harness bug (an emitter
|
|
369
|
+
* started producing a reason string neither side has ever emitted before) —
|
|
370
|
+
* `toCoarseReasonKind` throws rather than silently defaulting, so a new raw
|
|
371
|
+
* reason gets a deliberate classification instead of landing in the wrong
|
|
372
|
+
* bucket unnoticed.
|
|
373
|
+
*/
|
|
374
|
+
const REASON_KIND_MAP = {
|
|
375
|
+
missing_bearer_token: "claim",
|
|
376
|
+
parse_error: "claim",
|
|
377
|
+
did_resolve_failed: "resolve",
|
|
378
|
+
signature_invalid: "signature",
|
|
379
|
+
audience_mismatch: "claim",
|
|
380
|
+
expired: "time",
|
|
381
|
+
not_yet_valid: "time",
|
|
382
|
+
revoked: "revocation",
|
|
383
|
+
delegation_inactive: "revocation",
|
|
384
|
+
missing_claim: "claim",
|
|
385
|
+
claim_invalid: "claim",
|
|
386
|
+
not_configured: "claim",
|
|
387
|
+
header_missing: "claim",
|
|
388
|
+
claim_mismatch: "claim",
|
|
389
|
+
malformed: "claim",
|
|
390
|
+
Revoked: "revocation",
|
|
391
|
+
InvalidSignature: "signature",
|
|
392
|
+
Unauthenticated: "claim",
|
|
393
|
+
Expired: "time",
|
|
394
|
+
OutOfScope: "scope"
|
|
206
395
|
};
|
|
396
|
+
/** Map a runtime's native reason discriminator onto the coarse taxonomy. */
|
|
207
397
|
function toCoarseReasonKind(rawReasonKind) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
`toCoarseReasonKind: unrecognized raw reason kind ${JSON.stringify(rawReasonKind)} \u2014 add it to REASON_KIND_MAP in delegation-verdict.ts with a deliberate coarse classification`
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
return coarse;
|
|
398
|
+
const coarse = REASON_KIND_MAP[rawReasonKind];
|
|
399
|
+
if (!coarse) throw new Error(`toCoarseReasonKind: unrecognized raw reason kind ${JSON.stringify(rawReasonKind)} — add it to REASON_KIND_MAP in delegation-verdict.ts with a deliberate coarse classification`);
|
|
400
|
+
return coarse;
|
|
215
401
|
}
|
|
402
|
+
/** Build a `Permit` verdict. */
|
|
216
403
|
function permitDelegationVerdict() {
|
|
217
|
-
|
|
404
|
+
return {
|
|
405
|
+
kind: "Permit",
|
|
406
|
+
reason: null
|
|
407
|
+
};
|
|
218
408
|
}
|
|
409
|
+
/** Build a `Block` verdict from a runtime-native reason discriminator. */
|
|
219
410
|
function blockDelegationVerdict(rawReasonKind) {
|
|
220
|
-
|
|
411
|
+
return {
|
|
412
|
+
kind: "Block",
|
|
413
|
+
reason: { kind: toCoarseReasonKind(rawReasonKind) }
|
|
414
|
+
};
|
|
221
415
|
}
|
|
222
416
|
|
|
223
|
-
|
|
417
|
+
//#endregion
|
|
418
|
+
//#region src/test-fixtures/verdict-evidence-fixture.ts
|
|
419
|
+
/**
|
|
420
|
+
* Shared test fixture for P20 verdict-evidence tests (`buildVerdictEvidence`,
|
|
421
|
+
* `reconstructConfidenceFromEvidence` — see `../core/verdict-evidence.ts`).
|
|
422
|
+
*
|
|
423
|
+
* **DO NOT IMPORT FROM PRODUCTION CODE.** Exposed only via the
|
|
424
|
+
* `@kya-os/checkpoint-shared/test-fixtures` subpath export.
|
|
425
|
+
*
|
|
426
|
+
* ## Purpose
|
|
427
|
+
*
|
|
428
|
+
* Four independent test suites each need "one signal, minimal defaults" and
|
|
429
|
+
* "two independent signals whose Noisy-Or reconstruction is a known,
|
|
430
|
+
* hand-verified number" — checkpoint-shared's own unit tests, the
|
|
431
|
+
* enforcement-metadata envelope tests, the activity-log read-side tests, and
|
|
432
|
+
* the pixel-route persistence test. Before this fixture existed, all four
|
|
433
|
+
* hardcoded the SAME two fixtures and the SAME derivation comment
|
|
434
|
+
* independently — a change to one could silently drift from the others.
|
|
435
|
+
* This is the one place that number is computed; every test imports it
|
|
436
|
+
* rather than re-deriving it.
|
|
437
|
+
*
|
|
438
|
+
* ## The known reconstruction
|
|
439
|
+
*
|
|
440
|
+
* `TWO_SIGNAL_EVIDENCE_FIXTURE`'s Noisy-Or confidence, by hand — INCLUDING
|
|
441
|
+
* the `UNCALIBRATED_NOISY_OR_PRIOR` (0.10) leak term every live verdict
|
|
442
|
+
* folds in (bestbrian, PR #4747 review — the earlier version of this
|
|
443
|
+
* fixture omitted it and asserted the wrong number, 94.2):
|
|
444
|
+
*
|
|
445
|
+
* 1 - (1 - 0.10) * (1 - 1.0*0.9) * (1 - 0.6*0.7)
|
|
446
|
+
* = 1 - 0.9 * 0.1 * 0.58
|
|
447
|
+
* = 1 - 0.0522
|
|
448
|
+
* = 0.9478 -> 94.78 (0-100 scale)
|
|
449
|
+
*/
|
|
450
|
+
/** A minimal, valid `DetectionSignal`-shaped wire object with sane defaults. */
|
|
224
451
|
function detectionSignalFixture(overrides = {}) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
452
|
+
return {
|
|
453
|
+
signalType: "pattern",
|
|
454
|
+
confidence: 80,
|
|
455
|
+
weight: .4,
|
|
456
|
+
source: "tier3_ua_pattern",
|
|
457
|
+
explanation: "Matches a known agent UA pattern",
|
|
458
|
+
...overrides
|
|
459
|
+
};
|
|
233
460
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
461
|
+
/**
|
|
462
|
+
* Two independent signals (a pattern match at weight 1.0/confidence 90, a
|
|
463
|
+
* network match at weight 0.6/confidence 70) whose combined Noisy-Or
|
|
464
|
+
* confidence is the hand-verified 94.78 — see the module doc above.
|
|
465
|
+
*/
|
|
466
|
+
const TWO_SIGNAL_EVIDENCE_FIXTURE = [detectionSignalFixture({
|
|
467
|
+
source: "known_scraper_ua",
|
|
468
|
+
signalType: "pattern",
|
|
469
|
+
weight: 1,
|
|
470
|
+
confidence: 90
|
|
471
|
+
}), detectionSignalFixture({
|
|
472
|
+
source: "datacenter_ip",
|
|
473
|
+
signalType: "network",
|
|
474
|
+
weight: .6,
|
|
475
|
+
confidence: 70
|
|
476
|
+
})];
|
|
477
|
+
/** The confidence (0-100 scale) `TWO_SIGNAL_EVIDENCE_FIXTURE` reconstructs to,
|
|
478
|
+
* including the Noisy-Or prior — see the module doc above. */
|
|
479
|
+
const TWO_SIGNAL_EVIDENCE_EXPECTED_CONFIDENCE = 94.78;
|
|
249
480
|
|
|
481
|
+
//#endregion
|
|
250
482
|
exports.FETCHER_200_PREDICATE_VECTORS = FETCHER_200_PREDICATE_VECTORS;
|
|
251
483
|
exports.MCPI_DELEGATION_AGENT_DID = MCPI_DELEGATION_AGENT_DID;
|
|
252
484
|
exports.MCPI_DELEGATION_AUDIENCE = MCPI_DELEGATION_AUDIENCE;
|
|
@@ -269,4 +501,4 @@ exports.VAULT_WIRE_CONTRACT_URL_PATH = VAULT_WIRE_CONTRACT_URL_PATH;
|
|
|
269
501
|
exports.blockDelegationVerdict = blockDelegationVerdict;
|
|
270
502
|
exports.detectionSignalFixture = detectionSignalFixture;
|
|
271
503
|
exports.permitDelegationVerdict = permitDelegationVerdict;
|
|
272
|
-
exports.toCoarseReasonKind = toCoarseReasonKind;
|
|
504
|
+
exports.toCoarseReasonKind = toCoarseReasonKind;
|