@kya-os/mcp-i-cloudflare 1.18.0 → 1.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +273 -54
- package/dist/adapter.d.ts +3 -17
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +30 -477
- package/dist/adapter.js.map +1 -1
- package/dist/agent.d.ts +59 -35
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +383 -406
- package/dist/agent.js.map +1 -1
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +150 -94
- package/dist/app.js.map +1 -1
- package/dist/audit/deployment-binding.d.ts +16 -16
- package/dist/authority-outcome.d.ts +110 -0
- package/dist/authority-outcome.d.ts.map +1 -0
- package/dist/authority-outcome.js +154 -0
- package/dist/authority-outcome.js.map +1 -0
- package/dist/config.d.ts +8 -77
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +0 -83
- package/dist/config.js.map +1 -1
- package/dist/delegation-http/bearer-retry.d.ts +84 -32
- package/dist/delegation-http/bearer-retry.d.ts.map +1 -1
- package/dist/delegation-http/bearer-retry.js +124 -139
- package/dist/delegation-http/bearer-retry.js.map +1 -1
- package/dist/delegation-http/connect-gate.d.ts +47 -0
- package/dist/delegation-http/connect-gate.d.ts.map +1 -0
- package/dist/delegation-http/connect-gate.js +104 -0
- package/dist/delegation-http/connect-gate.js.map +1 -0
- package/dist/delegation-http/constants.d.ts +4 -49
- package/dist/delegation-http/constants.d.ts.map +1 -1
- package/dist/delegation-http/constants.js +4 -58
- package/dist/delegation-http/constants.js.map +1 -1
- package/dist/delegation-http/issuer-binding.d.ts +26 -0
- package/dist/delegation-http/issuer-binding.d.ts.map +1 -0
- package/dist/delegation-http/issuer-binding.js +51 -0
- package/dist/delegation-http/issuer-binding.js.map +1 -0
- package/dist/delegation-http/lazy-auth-gate.d.ts +88 -0
- package/dist/delegation-http/lazy-auth-gate.d.ts.map +1 -0
- package/dist/delegation-http/lazy-auth-gate.js +203 -0
- package/dist/delegation-http/lazy-auth-gate.js.map +1 -0
- package/dist/delegation-http/native-challenge.d.ts +52 -0
- package/dist/delegation-http/native-challenge.d.ts.map +1 -0
- package/dist/delegation-http/native-challenge.js +124 -0
- package/dist/delegation-http/native-challenge.js.map +1 -0
- package/dist/delegation-http/native-consent-redirect.d.ts +21 -0
- package/dist/delegation-http/native-consent-redirect.d.ts.map +1 -0
- package/dist/delegation-http/native-consent-redirect.js +43 -0
- package/dist/delegation-http/native-consent-redirect.js.map +1 -0
- package/dist/delegation-http/native-http.d.ts +1 -86
- package/dist/delegation-http/native-http.d.ts.map +1 -1
- package/dist/delegation-http/native-http.js +2 -130
- package/dist/delegation-http/native-http.js.map +1 -1
- package/dist/delegation-http/native-oauth-state-do.d.ts +13 -35
- package/dist/delegation-http/native-oauth-state-do.d.ts.map +1 -1
- package/dist/delegation-http/native-oauth-state-do.js +10 -165
- package/dist/delegation-http/native-oauth-state-do.js.map +1 -1
- package/dist/delegation-http/protected-resource.d.ts +37 -0
- package/dist/delegation-http/protected-resource.d.ts.map +1 -0
- package/dist/delegation-http/protected-resource.js +43 -0
- package/dist/delegation-http/protected-resource.js.map +1 -0
- package/dist/delegation-http/request-proof.d.ts +20 -0
- package/dist/delegation-http/request-proof.d.ts.map +1 -0
- package/dist/delegation-http/request-proof.js +29 -0
- package/dist/delegation-http/request-proof.js.map +1 -0
- package/dist/delegation-http/sid.d.ts +4 -12
- package/dist/delegation-http/sid.d.ts.map +1 -1
- package/dist/delegation-http/sid.js +4 -19
- package/dist/delegation-http/sid.js.map +1 -1
- package/dist/delegation-http/well-known-capability.d.ts +8 -12
- package/dist/delegation-http/well-known-capability.d.ts.map +1 -1
- package/dist/delegation-http/well-known-capability.js +9 -18
- package/dist/delegation-http/well-known-capability.js.map +1 -1
- package/dist/helpers/env-mapper.d.ts.map +1 -1
- package/dist/helpers/env-mapper.js +7 -29
- package/dist/helpers/env-mapper.js.map +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -8
- package/dist/index.js.map +1 -1
- package/dist/proof-generator.d.ts +24 -17
- package/dist/proof-generator.d.ts.map +1 -1
- package/dist/proof-generator.js +42 -56
- package/dist/proof-generator.js.map +1 -1
- package/dist/runtime/oauth-handler.d.ts +1 -1
- package/dist/runtime/oauth-handler.d.ts.map +1 -1
- package/dist/runtime/oauth-handler.js +15 -30
- package/dist/runtime/oauth-handler.js.map +1 -1
- package/dist/runtime.d.ts +34 -10
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +54 -12
- package/dist/runtime.js.map +1 -1
- package/dist/security/admission-refusal.d.ts +3 -3
- package/dist/security/admission-refusal.d.ts.map +1 -1
- package/dist/security/admission-refusal.js +14 -6
- package/dist/security/admission-refusal.js.map +1 -1
- package/dist/security/holder-binding.d.ts +34 -0
- package/dist/security/holder-binding.d.ts.map +1 -0
- package/dist/security/holder-binding.js +75 -0
- package/dist/security/holder-binding.js.map +1 -0
- package/dist/security/mcp-admission.d.ts +29 -1
- package/dist/security/mcp-admission.d.ts.map +1 -1
- package/dist/security/mcp-admission.js +78 -12
- package/dist/security/mcp-admission.js.map +1 -1
- package/dist/security/native-holder-admission.d.ts +39 -0
- package/dist/security/native-holder-admission.d.ts.map +1 -0
- package/dist/security/native-holder-admission.js +65 -0
- package/dist/security/native-holder-admission.js.map +1 -0
- package/dist/security/outcome-proof.d.ts +39 -0
- package/dist/security/outcome-proof.d.ts.map +1 -0
- package/dist/security/outcome-proof.js +54 -0
- package/dist/security/outcome-proof.js.map +1 -0
- package/dist/security/request-nonce-store.d.ts +43 -0
- package/dist/security/request-nonce-store.d.ts.map +1 -0
- package/dist/security/request-nonce-store.js +129 -0
- package/dist/security/request-nonce-store.js.map +1 -0
- package/dist/security/routed-request.d.ts +41 -0
- package/dist/security/routed-request.d.ts.map +1 -0
- package/dist/security/routed-request.js +86 -0
- package/dist/security/routed-request.js.map +1 -0
- package/dist/security/sign-in-amr.d.ts +23 -0
- package/dist/security/sign-in-amr.d.ts.map +1 -0
- package/dist/security/sign-in-amr.js +44 -0
- package/dist/security/sign-in-amr.js.map +1 -0
- package/dist/services/approval-route.d.ts +3 -2
- package/dist/services/approval-route.d.ts.map +1 -1
- package/dist/services/approval-route.js.map +1 -1
- package/dist/services/checkpoint-decision.d.ts +56 -0
- package/dist/services/checkpoint-decision.d.ts.map +1 -0
- package/dist/services/checkpoint-decision.js +109 -0
- package/dist/services/checkpoint-decision.js.map +1 -0
- package/dist/services/consent-page-renderer.d.ts.map +1 -1
- package/dist/services/consent-page-renderer.js +2 -3
- package/dist/services/consent-page-renderer.js.map +1 -1
- package/dist/services/consent.service.d.ts +11 -49
- package/dist/services/consent.service.d.ts.map +1 -1
- package/dist/services/consent.service.js +81 -307
- package/dist/services/consent.service.js.map +1 -1
- package/dist/services/credential-auth.handler.d.ts.map +1 -1
- package/dist/services/credential-auth.handler.js +2 -8
- package/dist/services/credential-auth.handler.js.map +1 -1
- package/dist/services/delegation-authority.d.ts +53 -0
- package/dist/services/delegation-authority.d.ts.map +1 -0
- package/dist/services/delegation-authority.js +130 -0
- package/dist/services/delegation-authority.js.map +1 -0
- package/dist/services/delegation-trust.d.ts +35 -64
- package/dist/services/delegation-trust.d.ts.map +1 -1
- package/dist/services/delegation-trust.js +98 -279
- package/dist/services/delegation-trust.js.map +1 -1
- package/dist/services/delegation.service.d.ts +83 -105
- package/dist/services/delegation.service.d.ts.map +1 -1
- package/dist/services/delegation.service.js +166 -518
- package/dist/services/delegation.service.js.map +1 -1
- package/dist/services/idp-token-storage.d.ts +32 -12
- package/dist/services/idp-token-storage.d.ts.map +1 -1
- package/dist/services/idp-token-storage.js +79 -36
- package/dist/services/idp-token-storage.js.map +1 -1
- package/dist/services/issuer-keys.d.ts +55 -0
- package/dist/services/issuer-keys.d.ts.map +1 -0
- package/dist/services/issuer-keys.js +184 -0
- package/dist/services/issuer-keys.js.map +1 -0
- package/dist/services/oauth-security.service.d.ts +17 -1
- package/dist/services/oauth-security.service.d.ts.map +1 -1
- package/dist/services/oauth-security.service.js +29 -10
- package/dist/services/oauth-security.service.js.map +1 -1
- package/dist/services/resource-audience.d.ts +12 -9
- package/dist/services/resource-audience.d.ts.map +1 -1
- package/dist/services/resource-audience.js +12 -9
- package/dist/services/resource-audience.js.map +1 -1
- package/dist/services/unenforceable-tool-protection.d.ts +32 -0
- package/dist/services/unenforceable-tool-protection.d.ts.map +1 -0
- package/dist/services/unenforceable-tool-protection.js +90 -0
- package/dist/services/unenforceable-tool-protection.js.map +1 -0
- package/dist/services/upstream-fetch.d.ts +14 -0
- package/dist/services/upstream-fetch.d.ts.map +1 -0
- package/dist/services/upstream-fetch.js +56 -0
- package/dist/services/upstream-fetch.js.map +1 -0
- package/dist/types.d.ts +5 -18
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/tool-security-schemes.d.ts +65 -0
- package/dist/utils/tool-security-schemes.d.ts.map +1 -0
- package/dist/utils/tool-security-schemes.js +168 -0
- package/dist/utils/tool-security-schemes.js.map +1 -0
- package/package.json +3 -4
- package/dist/delegation-http/anchor-do.d.ts +0 -84
- package/dist/delegation-http/anchor-do.d.ts.map +0 -1
- package/dist/delegation-http/anchor-do.js +0 -412
- package/dist/delegation-http/anchor-do.js.map +0 -1
- package/dist/delegation-http/anchor-registration-validate.d.ts +0 -61
- package/dist/delegation-http/anchor-registration-validate.d.ts.map +0 -1
- package/dist/delegation-http/anchor-registration-validate.js +0 -191
- package/dist/delegation-http/anchor-registration-validate.js.map +0 -1
- package/dist/delegation-http/anchor-registration.d.ts +0 -62
- package/dist/delegation-http/anchor-registration.d.ts.map +0 -1
- package/dist/delegation-http/anchor-registration.js +0 -337
- package/dist/delegation-http/anchor-registration.js.map +0 -1
- package/dist/delegation-http/anchor-routing.d.ts +0 -20
- package/dist/delegation-http/anchor-routing.d.ts.map +0 -1
- package/dist/delegation-http/anchor-routing.js +0 -27
- package/dist/delegation-http/anchor-routing.js.map +0 -1
- package/dist/delegation-http/challenge-middleware.d.ts +0 -28
- package/dist/delegation-http/challenge-middleware.d.ts.map +0 -1
- package/dist/delegation-http/challenge-middleware.js +0 -190
- package/dist/delegation-http/challenge-middleware.js.map +0 -1
- package/dist/delegation-http/challenge.d.ts +0 -102
- package/dist/delegation-http/challenge.d.ts.map +0 -1
- package/dist/delegation-http/challenge.js +0 -223
- package/dist/delegation-http/challenge.js.map +0 -1
- package/dist/delegation-http/consent-anchor-bridge.d.ts +0 -70
- package/dist/delegation-http/consent-anchor-bridge.d.ts.map +0 -1
- package/dist/delegation-http/consent-anchor-bridge.js +0 -1130
- package/dist/delegation-http/consent-anchor-bridge.js.map +0 -1
- package/dist/delegation-http/consent-preparation-page.d.ts +0 -18
- package/dist/delegation-http/consent-preparation-page.d.ts.map +0 -1
- package/dist/delegation-http/consent-preparation-page.js +0 -172
- package/dist/delegation-http/consent-preparation-page.js.map +0 -1
- package/dist/delegation-http/credential-consent.d.ts +0 -149
- package/dist/delegation-http/credential-consent.d.ts.map +0 -1
- package/dist/delegation-http/credential-consent.js +0 -338
- package/dist/delegation-http/credential-consent.js.map +0 -1
- package/dist/delegation-http/native-capabilities.d.ts +0 -4
- package/dist/delegation-http/native-capabilities.d.ts.map +0 -1
- package/dist/delegation-http/native-capabilities.js +0 -53
- package/dist/delegation-http/native-capabilities.js.map +0 -1
- package/dist/delegation-http/native-oauth-state.d.ts +0 -28
- package/dist/delegation-http/native-oauth-state.d.ts.map +0 -1
- package/dist/delegation-http/native-oauth-state.js +0 -146
- package/dist/delegation-http/native-oauth-state.js.map +0 -1
- package/dist/delegation-http/native-oauth.d.ts +0 -26
- package/dist/delegation-http/native-oauth.d.ts.map +0 -1
- package/dist/delegation-http/native-oauth.js +0 -401
- package/dist/delegation-http/native-oauth.js.map +0 -1
- package/dist/delegation-http/native-pickup.d.ts +0 -20
- package/dist/delegation-http/native-pickup.d.ts.map +0 -1
- package/dist/delegation-http/native-pickup.js +0 -227
- package/dist/delegation-http/native-pickup.js.map +0 -1
- package/dist/delegation-http/pickup-routes.d.ts +0 -43
- package/dist/delegation-http/pickup-routes.d.ts.map +0 -1
- package/dist/delegation-http/pickup-routes.js +0 -166
- package/dist/delegation-http/pickup-routes.js.map +0 -1
- package/dist/delegation-http/register.d.ts +0 -26
- package/dist/delegation-http/register.d.ts.map +0 -1
- package/dist/delegation-http/register.js +0 -95
- package/dist/delegation-http/register.js.map +0 -1
- package/dist/delegation-http/registrar-auth.d.ts +0 -24
- package/dist/delegation-http/registrar-auth.d.ts.map +0 -1
- package/dist/delegation-http/registrar-auth.js +0 -61
- package/dist/delegation-http/registrar-auth.js.map +0 -1
- package/dist/delegation-http/remote-issuer.d.ts +0 -52
- package/dist/delegation-http/remote-issuer.d.ts.map +0 -1
- package/dist/delegation-http/remote-issuer.js +0 -324
- package/dist/delegation-http/remote-issuer.js.map +0 -1
- package/dist/delegation-http/types.d.ts +0 -116
- package/dist/delegation-http/types.d.ts.map +0 -1
- package/dist/delegation-http/types.js +0 -11
- package/dist/delegation-http/types.js.map +0 -1
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* draft-kya-http-02 delegation layer — anchor-registration request validation.
|
|
3
|
-
*
|
|
4
|
-
* Mirrors checkpoint's `registerSessionSchema` (bouncer validators) rule-for-rule
|
|
5
|
-
* for every field this worker consumes, so a body that checkpoint's own
|
|
6
|
-
* `POST /api/v1/bouncer/sessions` accepts is accepted here and vice versa — the
|
|
7
|
-
* wire shape is frozen by the vendored `registration.request.json` fixture.
|
|
8
|
-
* Optional metadata this worker does not consume (`client_identity`) is accepted
|
|
9
|
-
* and ignored rather than deep-validated; checkpoint remains the stricter end.
|
|
10
|
-
*
|
|
11
|
-
* @module @kya-os/mcp-i-cloudflare/delegation-http/anchor-registration-validate
|
|
12
|
-
*/
|
|
13
|
-
/** Only did:web and did:key are permitted — no ad-hoc methods (checkpoint parity). */
|
|
14
|
-
const DID_RE = /^did:(key|web):.+$/;
|
|
15
|
-
import { isNativeHttpRegistration } from "./native-http";
|
|
16
|
-
/**
|
|
17
|
-
* Synthetic detected-DID placeholders (`did:web:detected:*`) that checkpoint's
|
|
18
|
-
* legacy detection middleware synthesized — its didSchema refines them out
|
|
19
|
-
* ("must never be treated as KYA-OS identities"). Mirrored here because a
|
|
20
|
-
* synthetic DID accepted as `detected_agent_did` would become the minted
|
|
21
|
-
* delegation's SUBJECT: a consent-backed credential issued to an unresolvable
|
|
22
|
-
* placeholder the platform route itself refuses. Exact `startsWith` mirror of
|
|
23
|
-
* checkpoint's isSyntheticDetectedDID.
|
|
24
|
-
*/
|
|
25
|
-
const SYNTHETIC_DETECTED_DID_PREFIX = "did:web:detected:";
|
|
26
|
-
/**
|
|
27
|
-
* Full DID acceptance check (shape + synthetic refine), one message per cause —
|
|
28
|
-
* mirroring checkpoint didSchema's regex + refine pair. Returns null when valid.
|
|
29
|
-
*/
|
|
30
|
-
function didIssueMessage(value) {
|
|
31
|
-
if (typeof value !== "string" || !DID_RE.test(value)) {
|
|
32
|
-
return "Invalid DID format. Must be did:key: or did:web:";
|
|
33
|
-
}
|
|
34
|
-
if (value.startsWith(SYNTHETIC_DETECTED_DID_PREFIX)) {
|
|
35
|
-
return "Synthetic detected DIDs are not valid KYA-OS identities";
|
|
36
|
-
}
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
function isRecord(value) {
|
|
40
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
41
|
-
}
|
|
42
|
-
/** Push an issue unless `value` is a string within [1, max] chars. */
|
|
43
|
-
function checkString(issues, path, value, max) {
|
|
44
|
-
if (typeof value !== "string" || value.length < 1 || value.length > max) {
|
|
45
|
-
issues.push({ path, message: `${path} must be a string (1-${max} chars)` });
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
/** Push an issue unless `value` is absent or a valid string within [1, max]. */
|
|
51
|
-
function checkOptionalString(issues, path, value, max) {
|
|
52
|
-
if (value === undefined)
|
|
53
|
-
return;
|
|
54
|
-
checkString(issues, path, value, max);
|
|
55
|
-
}
|
|
56
|
-
/** Validate the `challenge` block (checkpoint parity: scopes 1-50 × 1-200 chars). */
|
|
57
|
-
function validateChallenge(issues, raw) {
|
|
58
|
-
if (raw === undefined)
|
|
59
|
-
return undefined;
|
|
60
|
-
if (!isRecord(raw)) {
|
|
61
|
-
issues.push({ path: "challenge", message: "challenge must be an object" });
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
64
|
-
const issuesBefore = issues.length;
|
|
65
|
-
if (raw.http !== undefined && !isNativeHttpRegistration(raw.http)) {
|
|
66
|
-
issues.push({ path: "challenge.http", message: "Invalid native HTTP contract" });
|
|
67
|
-
}
|
|
68
|
-
const scopes = raw.required_scopes;
|
|
69
|
-
if (!Array.isArray(scopes) ||
|
|
70
|
-
scopes.length < 1 ||
|
|
71
|
-
scopes.length > 50 ||
|
|
72
|
-
scopes.some((s) => typeof s !== "string" || s.length < 1 || s.length > 200)) {
|
|
73
|
-
issues.push({
|
|
74
|
-
path: "challenge.required_scopes",
|
|
75
|
-
message: "challenge.required_scopes must be 1-50 strings of 1-200 chars each",
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
checkOptionalString(issues, "challenge.pep_surface", raw.pep_surface, 64);
|
|
79
|
-
checkOptionalString(issues, "challenge.verdict", raw.verdict, 64);
|
|
80
|
-
checkOptionalString(issues, "challenge.policy_id", raw.policy_id, 255);
|
|
81
|
-
checkOptionalString(issues, "challenge.composed_blob_hash", raw.composed_blob_hash, 64);
|
|
82
|
-
checkOptionalString(issues, "challenge.challenge_pin", raw.challenge_pin, 512);
|
|
83
|
-
if (raw.detected_agent_did !== undefined) {
|
|
84
|
-
const issue = didIssueMessage(raw.detected_agent_did);
|
|
85
|
-
if (issue) {
|
|
86
|
-
issues.push({ path: "challenge.detected_agent_did", message: issue });
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (raw.audience !== undefined) {
|
|
90
|
-
const issue = didIssueMessage(raw.audience);
|
|
91
|
-
if (issue) {
|
|
92
|
-
issues.push({ path: "challenge.audience", message: issue });
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
if (issues.length > issuesBefore)
|
|
96
|
-
return undefined;
|
|
97
|
-
return {
|
|
98
|
-
requiredScopes: scopes,
|
|
99
|
-
pepSurface: raw.pep_surface,
|
|
100
|
-
verdict: raw.verdict,
|
|
101
|
-
detectedAgentDid: raw.detected_agent_did,
|
|
102
|
-
challengePin: raw.challenge_pin,
|
|
103
|
-
audience: raw.audience,
|
|
104
|
-
http: raw.http,
|
|
105
|
-
policyId: raw.policy_id,
|
|
106
|
-
composedPolicyHash: raw.composed_blob_hash,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Validate a registration body against the frozen wire contract. Returns the
|
|
111
|
-
* camelized input, or the full issue list (mirroring checkpoint's 400 `details`).
|
|
112
|
-
*/
|
|
113
|
-
export function validateRegistrationBody(raw) {
|
|
114
|
-
if (!isRecord(raw)) {
|
|
115
|
-
return {
|
|
116
|
-
ok: false,
|
|
117
|
-
issues: [{ path: "", message: "body must be a JSON object" }],
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
const issues = [];
|
|
121
|
-
checkString(issues, "session_id", raw.session_id, 255);
|
|
122
|
-
{
|
|
123
|
-
const issue = didIssueMessage(raw.agent_did);
|
|
124
|
-
if (issue)
|
|
125
|
-
issues.push({ path: "agent_did", message: issue });
|
|
126
|
-
}
|
|
127
|
-
// No length cap: checkpoint's schema is z.string().min(1) — the mirror must
|
|
128
|
-
// not be stricter than the contract it freezes.
|
|
129
|
-
if (typeof raw.project_id !== "string" || raw.project_id.length < 1) {
|
|
130
|
-
issues.push({
|
|
131
|
-
path: "project_id",
|
|
132
|
-
message: "project_id must be a non-empty string",
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
// Upper bound is the ECMAScript Date range (8.64e15 ms): a larger value —
|
|
136
|
-
// e.g. .NET DateTime.Ticks sent by a unit-confused registrar — passes
|
|
137
|
-
// isInteger but makes new Date(...).toISOString() throw AFTER the anchor is
|
|
138
|
-
// created. No valid unix-ms timestamp exceeds it.
|
|
139
|
-
if (typeof raw.created_at !== "number" ||
|
|
140
|
-
!Number.isInteger(raw.created_at) ||
|
|
141
|
-
raw.created_at <= 0 ||
|
|
142
|
-
raw.created_at > 8.64e15) {
|
|
143
|
-
issues.push({
|
|
144
|
-
path: "created_at",
|
|
145
|
-
message: "created_at must be a valid positive unix-ms integer",
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
const clientInfo = raw.client_info;
|
|
149
|
-
if (!isRecord(clientInfo)) {
|
|
150
|
-
issues.push({
|
|
151
|
-
path: "client_info",
|
|
152
|
-
message: "client_info must be an object",
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
checkString(issues, "client_info.name", clientInfo.name, 255);
|
|
157
|
-
checkOptionalString(issues, "client_info.version", clientInfo.version, 50);
|
|
158
|
-
}
|
|
159
|
-
if (raw.server_did !== undefined) {
|
|
160
|
-
const issue = didIssueMessage(raw.server_did);
|
|
161
|
-
if (issue)
|
|
162
|
-
issues.push({ path: "server_did", message: issue });
|
|
163
|
-
}
|
|
164
|
-
const challenge = validateChallenge(issues, raw.challenge);
|
|
165
|
-
// draft-kya-http-02 §8.2: a challenge anchor sid MUST be high-entropy. Mirror
|
|
166
|
-
// checkpoint's superRefine floor: >= 22 chars when a challenge is attached.
|
|
167
|
-
if (raw.challenge !== undefined &&
|
|
168
|
-
typeof raw.session_id === "string" &&
|
|
169
|
-
raw.session_id.length < 22) {
|
|
170
|
-
issues.push({
|
|
171
|
-
path: "session_id",
|
|
172
|
-
message: "session_id must be at least 22 characters (≈128-bit) when a challenge is attached",
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
if (issues.length > 0)
|
|
176
|
-
return { ok: false, issues };
|
|
177
|
-
return {
|
|
178
|
-
ok: true,
|
|
179
|
-
input: {
|
|
180
|
-
sessionId: raw.session_id,
|
|
181
|
-
agentDid: raw.agent_did,
|
|
182
|
-
projectId: raw.project_id,
|
|
183
|
-
createdAt: raw.created_at,
|
|
184
|
-
clientName: clientInfo.name,
|
|
185
|
-
clientVersion: clientInfo.version,
|
|
186
|
-
serverDid: raw.server_did,
|
|
187
|
-
challenge,
|
|
188
|
-
},
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
//# sourceMappingURL=anchor-registration-validate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"anchor-registration-validate.js","sourceRoot":"","sources":["../../src/delegation-http/anchor-registration-validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,sFAAsF;AACtF,MAAM,MAAM,GAAG,oBAAoB,CAAC;AACpC,OAAO,EAAE,wBAAwB,EAA+B,MAAM,eAAe,CAAC;AAEtF;;;;;;;;GAQG;AACH,MAAM,6BAA6B,GAAG,mBAAmB,CAAC;AAE1D;;;GAGG;AACH,SAAS,eAAe,CAAC,KAAc;IACrC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACrD,OAAO,kDAAkD,CAAC;IAC5D,CAAC;IACD,IAAI,KAAK,CAAC,UAAU,CAAC,6BAA6B,CAAC,EAAE,CAAC;QACpD,OAAO,yDAAyD,CAAC;IACnE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AA4CD,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,sEAAsE;AACtE,SAAS,WAAW,CAClB,MAAyB,EACzB,IAAY,EACZ,KAAc,EACd,GAAW;IAEX,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,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AG,CAAC,UAAU,KAAK,QAAQ;QAClC,GAAG,CAAC,UAAU,CAAC,MAAM,GAAG,EAAE,EAC1B,CAAC;QACD,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,YAAY;YAClB,OAAO,EACL,mFAAmF;SACtF,CAAC,CAAC;IACL,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IACpD,OAAO;QACL,EAAE,EAAE,IAAI;QACR,KAAK,EAAE;YACL,SAAS,EAAE,GAAG,CAAC,UAAoB;YACnC,QAAQ,EAAE,GAAG,CAAC,SAAmB;YACjC,SAAS,EAAE,GAAG,CAAC,UAAoB;YACnC,SAAS,EAAE,GAAG,CAAC,UAAoB;YACnC,UAAU,EAAG,UAAsC,CAAC,IAAc;YAClE,aAAa,EAAG,UAAsC,CAAC,OAE1C;YACb,SAAS,EAAE,GAAG,CAAC,UAAgC;YAC/C,SAAS;SACV;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* draft-kya-http-02 delegation layer — external anchor registration
|
|
3
|
-
* (`POST /api/v1/bouncer/sessions`).
|
|
4
|
-
*
|
|
5
|
-
* The cross-resource authorization-host surface: an external PEP in the same
|
|
6
|
-
* project (checkpoint's gateway `registration-client.ts`, the .NET
|
|
7
|
-
* `DelegationAnchorRegistrar`) provisions a pickup anchor on THIS worker for a
|
|
8
|
-
* challenge the worker didn't issue, so the §8.1 challenge that PEP emits can
|
|
9
|
-
* point `consent_uri`/`pickup_uri` at this deployment — no reverse proxy. Path
|
|
10
|
-
* and request/response shapes are the EXACT contract checkpoint's own bouncer
|
|
11
|
-
* sessions route serves (frozen by the vendored `registration.request.json` /
|
|
12
|
-
* `registration.response.json` fixtures), so pointing an existing registrar at
|
|
13
|
-
* a different base URL is the whole integration. Auth lives in
|
|
14
|
-
* `registrar-auth.ts` (the deployment's own `CHECKPOINT_API_KEY` as Bearer).
|
|
15
|
-
*
|
|
16
|
-
* Semantics mirror checkpoint's route: idempotent first-write-wins per sid
|
|
17
|
-
* (re-registering a live sid returns 200 echoing the ORIGINAL anchor's scopes;
|
|
18
|
-
* a fresh sid returns 201). A non-`kya-` session_id maps to a deterministic
|
|
19
|
-
* `kya-` sid returned in `data.session_id` — the .NET client adopts the
|
|
20
|
-
* response sid; the gateway client already generates `kya-` sids.
|
|
21
|
-
*
|
|
22
|
-
* @module @kya-os/mcp-i-cloudflare/delegation-http/anchor-registration
|
|
23
|
-
*/
|
|
24
|
-
import type { CloudflareEnv } from "../types";
|
|
25
|
-
import type { HttpChallengeConfig } from "../config";
|
|
26
|
-
import type { CloudflareProofGenerator } from "../proof-generator";
|
|
27
|
-
import type { getAnchorStub } from "./anchor-routing";
|
|
28
|
-
/** Minimal view of the Hono context this handler needs (avoids an `any` dependency). */
|
|
29
|
-
interface RegistrationRequestContext {
|
|
30
|
-
req: {
|
|
31
|
-
header(name: string): string | undefined;
|
|
32
|
-
url: string;
|
|
33
|
-
raw: Request;
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
interface RegistrationDeps {
|
|
37
|
-
getAnchorStub: typeof getAnchorStub;
|
|
38
|
-
proofGenerator: () => Promise<CloudflareProofGenerator>;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Whether this deployment serves the anchor-registration route: the layer is ON,
|
|
42
|
-
* the ops kill switch hasn't disabled it, and the registrar bearer
|
|
43
|
-
* (`CHECKPOINT_API_KEY`) is configured. Single source of truth for the route
|
|
44
|
-
* gate AND the well-known capability advertisement.
|
|
45
|
-
*/
|
|
46
|
-
export declare function isAnchorRegistrationEnabled(cfg: Required<HttpChallengeConfig> | null, env: CloudflareEnv): boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Map a registrar-chosen session_id to the worker's anchor-sid namespace. A
|
|
49
|
-
* conforming `kya-` sid (what the gateway and this package both generate) is
|
|
50
|
-
* used verbatim; anything else derives a deterministic `kya-` sid so repeated
|
|
51
|
-
* registrations of the same session still reuse one anchor. The response's
|
|
52
|
-
* `data.session_id` carries the result — the authoritative sid for callers.
|
|
53
|
-
*/
|
|
54
|
-
export declare function deriveRegistrationSid(sessionId: string): string;
|
|
55
|
-
/**
|
|
56
|
-
* Handle `POST /api/v1/bouncer/sessions`. The route gate
|
|
57
|
-
* (`isAnchorRegistrationEnabled` + layer flag) lives in `register.ts`; by the
|
|
58
|
-
* time this runs the layer is ON and a registrar bearer is configured.
|
|
59
|
-
*/
|
|
60
|
-
export declare function handleAnchorRegistration(c: RegistrationRequestContext, env: CloudflareEnv, cfg: Required<HttpChallengeConfig>, deps: RegistrationDeps): Promise<Response>;
|
|
61
|
-
export {};
|
|
62
|
-
//# sourceMappingURL=anchor-registration.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"anchor-registration.d.ts","sourceRoot":"","sources":["../../src/delegation-http/anchor-registration.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAuBtD,wFAAwF;AACxF,UAAU,0BAA0B;IAClC,GAAG,EAAE;QACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;QACzC,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,OAAO,CAAC;KACd,CAAC;CACH;AASD,UAAU,gBAAgB;IACxB,aAAa,EAAE,OAAO,aAAa,CAAC;IACpC,cAAc,EAAE,MAAM,OAAO,CAAC,wBAAwB,CAAC,CAAC;CACzD;AAsBD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,GAAG,EAAE,QAAQ,CAAC,mBAAmB,CAAC,GAAG,IAAI,EACzC,GAAG,EAAE,aAAa,GACjB,OAAO,CAWT;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAG/D;AAyID;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC5C,CAAC,EAAE,0BAA0B,EAC7B,GAAG,EAAE,aAAa,EAClB,GAAG,EAAE,QAAQ,CAAC,mBAAmB,CAAC,EAClC,IAAI,EAAE,gBAAgB,GACrB,OAAO,CAAC,QAAQ,CAAC,CA8QnB"}
|
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
import { INTERNAL_PICKUP_CREATE } from "./constants";
|
|
2
|
-
import { sha256Hex } from "./hash";
|
|
3
|
-
import { buildConsentUri, signChallengeProof } from "./challenge";
|
|
4
|
-
import { buildNativeChallenge, nativeUnavailable, secureHttpUrl, signNativeChallenge, } from "./native-http";
|
|
5
|
-
import { getConfiguredIdentity } from "../providers/storage";
|
|
6
|
-
import { canonicalize } from "json-canonicalize";
|
|
7
|
-
import { registrarAuthorized, registrationRateLimited } from "./registrar-auth";
|
|
8
|
-
import { validateRegistrationBody, } from "./anchor-registration-validate";
|
|
9
|
-
/** Internal origin for durable-object stub fetches — the DO routes by pathname only. */
|
|
10
|
-
const DO_INTERNAL_ORIGIN = "https://do.internal";
|
|
11
|
-
/**
|
|
12
|
-
* Whether this deployment serves the anchor-registration route: the layer is ON,
|
|
13
|
-
* the ops kill switch hasn't disabled it, and the registrar bearer
|
|
14
|
-
* (`CHECKPOINT_API_KEY`) is configured. Single source of truth for the route
|
|
15
|
-
* gate AND the well-known capability advertisement.
|
|
16
|
-
*/
|
|
17
|
-
export function isAnchorRegistrationEnabled(cfg, env) {
|
|
18
|
-
return (cfg !== null &&
|
|
19
|
-
cfg.remoteAnchorRegistration &&
|
|
20
|
-
typeof env.CHECKPOINT_API_KEY === "string" &&
|
|
21
|
-
env.CHECKPOINT_API_KEY.length > 0 &&
|
|
22
|
-
// No anchor store, no registration surface: getAnchorStub throws on an
|
|
23
|
-
// unbound MCP_OBJECT, so an unbound deployment must 404 like every other
|
|
24
|
-
// unprovisioned state instead of 500ing per request.
|
|
25
|
-
env.MCP_OBJECT !== undefined);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Map a registrar-chosen session_id to the worker's anchor-sid namespace. A
|
|
29
|
-
* conforming `kya-` sid (what the gateway and this package both generate) is
|
|
30
|
-
* used verbatim; anything else derives a deterministic `kya-` sid so repeated
|
|
31
|
-
* registrations of the same session still reuse one anchor. The response's
|
|
32
|
-
* `data.session_id` carries the result — the authoritative sid for callers.
|
|
33
|
-
*/
|
|
34
|
-
export function deriveRegistrationSid(sessionId) {
|
|
35
|
-
if (/^kya-[0-9a-f]{16,64}$/.test(sessionId))
|
|
36
|
-
return sessionId;
|
|
37
|
-
return `kya-${sha256Hex(sessionId).slice(0, 32)}`;
|
|
38
|
-
}
|
|
39
|
-
/** JSON error envelope matching checkpoint's `{ success: false, error: {…} }`. */
|
|
40
|
-
function errorResponse(status, code, message, details) {
|
|
41
|
-
return new Response(JSON.stringify({
|
|
42
|
-
success: false,
|
|
43
|
-
error: { code, message, ...(details ? { details } : {}) },
|
|
44
|
-
}), {
|
|
45
|
-
status,
|
|
46
|
-
headers: {
|
|
47
|
-
"Content-Type": "application/json",
|
|
48
|
-
"Cache-Control": "no-store",
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
/** POST a JSON body to one of the anchor's `/_internal/pickup/*` routes. */
|
|
53
|
-
async function callAnchor(env, deps, sid, internalPath, body) {
|
|
54
|
-
const stub = deps.getAnchorStub(env, sid);
|
|
55
|
-
const response = await stub.fetch(new URL(internalPath, DO_INTERNAL_ORIGIN).toString(), {
|
|
56
|
-
method: "POST",
|
|
57
|
-
headers: { "Content-Type": "application/json" },
|
|
58
|
-
body: JSON.stringify(body),
|
|
59
|
-
});
|
|
60
|
-
return response;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Ensure a live anchor exists for `sid`, first-write-wins: a live anchor is
|
|
64
|
-
* reused as-is (its stored values are authoritative, mirroring checkpoint's
|
|
65
|
-
* COALESCE-on-conflict); otherwise create one from this registration, honoring
|
|
66
|
-
* a `challenge_pin` ONLY when unverified keyid holders are enabled — a pinned
|
|
67
|
-
* keyid the pickup surface would reject (W2) must not brick the anchor.
|
|
68
|
-
*
|
|
69
|
-
* ONE atomic round-trip: the DO input gate serializes creates, and the create
|
|
70
|
-
* response body carries both the `reused` discriminator (two racing
|
|
71
|
-
* registrations get exactly one fresh 201 and one reused 200 — checkpoint
|
|
72
|
-
* status parity under concurrency) and the authoritative record snapshot to
|
|
73
|
-
* echo — there is no create→read-back window for the anchor to expire in.
|
|
74
|
-
* Stub failures (redeployed/evicted DOs, transport errors) map to the
|
|
75
|
-
* contract's 502 envelope instead of escaping as off-contract 500s.
|
|
76
|
-
*/
|
|
77
|
-
async function ensureAnchor(env, cfg, deps, sid, challenge, session) {
|
|
78
|
-
const pin = !challenge.http && challenge.challengePin && cfg.allowUnverifiedKeyidHolders
|
|
79
|
-
? { type: "keyid", valueSha256: sha256Hex(challenge.challengePin) }
|
|
80
|
-
: undefined;
|
|
81
|
-
const anchorUnavailable = {
|
|
82
|
-
error: errorResponse(502, "anchor_unavailable", "The anchor store did not accept the registration"),
|
|
83
|
-
};
|
|
84
|
-
let created;
|
|
85
|
-
let body;
|
|
86
|
-
try {
|
|
87
|
-
created = await callAnchor(env, deps, sid, INTERNAL_PICKUP_CREATE, {
|
|
88
|
-
sid,
|
|
89
|
-
requiredScopes: challenge.requiredScopes,
|
|
90
|
-
pollIntervalS: cfg.pollIntervalS,
|
|
91
|
-
anchorTtlS: cfg.anchorTtlS,
|
|
92
|
-
delegationExpiresInS: cfg.delegationExpiresInS,
|
|
93
|
-
agentDid: challenge.detectedAgentDid ?? session.agentDid,
|
|
94
|
-
registeredAtMs: session.registeredAtMs,
|
|
95
|
-
...(challenge.http && cfg.native
|
|
96
|
-
? {
|
|
97
|
-
nativeHttp: buildNativeChallenge(challenge.http, sid, challenge.requiredScopes, cfg.native.authorizationOrigin),
|
|
98
|
-
nativeRegistration: challenge.http,
|
|
99
|
-
nativeIssuerDid: cfg.native.issuerDid,
|
|
100
|
-
nativeIssuedAtMs: session.nativeIssuedAtMs,
|
|
101
|
-
nativePolicyRevision: {
|
|
102
|
-
policyId: challenge.policyId,
|
|
103
|
-
composedPolicyHash: challenge.composedPolicyHash,
|
|
104
|
-
},
|
|
105
|
-
minAssurance: challenge.http.min_assurance,
|
|
106
|
-
pollIntervalS: challenge.http.poll_interval_s,
|
|
107
|
-
}
|
|
108
|
-
: {}),
|
|
109
|
-
// Cross-resource claim inputs (drive the minted VC's aud / server_did —
|
|
110
|
-
// see consent-anchor-bridge's withCrossResourceClaims).
|
|
111
|
-
...(challenge.audience ? { audience: challenge.audience } : {}),
|
|
112
|
-
...(session.serverDid ? { serverDid: session.serverDid } : {}),
|
|
113
|
-
...(pin ? { pin } : {}),
|
|
114
|
-
});
|
|
115
|
-
if (created.status !== 201)
|
|
116
|
-
return anchorUnavailable;
|
|
117
|
-
body = (await created.json());
|
|
118
|
-
}
|
|
119
|
-
catch (error) {
|
|
120
|
-
if (!challenge.http)
|
|
121
|
-
console.warn(`[kya-http] anchor create failed (sid=${sid}):`, error instanceof Error ? error.message : String(error));
|
|
122
|
-
return anchorUnavailable;
|
|
123
|
-
}
|
|
124
|
-
if (!body.anchor || !Array.isArray(body.anchor.requiredScopes)) {
|
|
125
|
-
return anchorUnavailable;
|
|
126
|
-
}
|
|
127
|
-
return { isNew: body.reused !== true, snapshot: body.anchor };
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Handle `POST /api/v1/bouncer/sessions`. The route gate
|
|
131
|
-
* (`isAnchorRegistrationEnabled` + layer flag) lives in `register.ts`; by the
|
|
132
|
-
* time this runs the layer is ON and a registrar bearer is configured.
|
|
133
|
-
*/
|
|
134
|
-
export async function handleAnchorRegistration(c, env, cfg, deps) {
|
|
135
|
-
// AuthN first, reading only the header — never the body (checkpoint parity).
|
|
136
|
-
if (!registrarAuthorized(env, c.req.header("Authorization"))) {
|
|
137
|
-
return errorResponse(401, "unauthorized", "Invalid or missing API key");
|
|
138
|
-
}
|
|
139
|
-
if (registrationRateLimited(Date.now())) {
|
|
140
|
-
return errorResponse(429, "rate_limited", "Too many anchor registrations; retry shortly");
|
|
141
|
-
}
|
|
142
|
-
let raw;
|
|
143
|
-
try {
|
|
144
|
-
raw = await c.req.raw.clone().json();
|
|
145
|
-
}
|
|
146
|
-
catch {
|
|
147
|
-
return errorResponse(400, "invalid_request", "Invalid request body", [
|
|
148
|
-
{ path: "", message: "body must be JSON" },
|
|
149
|
-
]);
|
|
150
|
-
}
|
|
151
|
-
const validated = validateRegistrationBody(raw);
|
|
152
|
-
if (!validated.ok) {
|
|
153
|
-
return errorResponse(400, "invalid_request", "Invalid request body", validated.issues);
|
|
154
|
-
}
|
|
155
|
-
// This surface exists ONLY to anchor challenges (mirrors checkpoint's
|
|
156
|
-
// gateway-service branch): a non-challenge session registration belongs to
|
|
157
|
-
// checkpoint's own route, which owns the sessions table this worker lacks.
|
|
158
|
-
const { challenge } = validated.input;
|
|
159
|
-
if (!challenge) {
|
|
160
|
-
return errorResponse(401, "unauthorized", "This endpoint only accepts challenge registration");
|
|
161
|
-
}
|
|
162
|
-
if (challenge.http) {
|
|
163
|
-
const native = cfg.native;
|
|
164
|
-
// A native anchor must be usable before any consent affordance is emitted.
|
|
165
|
-
// No opaque pre-pin, bearer downgrade or unknown resource audience is allowed.
|
|
166
|
-
if (!native ||
|
|
167
|
-
validated.input.projectId !==
|
|
168
|
-
(native.projectId ?? env.CHECKPOINT_PROJECT_ID) ||
|
|
169
|
-
!challenge.audience ||
|
|
170
|
-
challenge.challengePin !== undefined ||
|
|
171
|
-
!challenge.policyId ||
|
|
172
|
-
challenge.policyId.length > 200 ||
|
|
173
|
-
!/^[0-9a-f]{64}$/.test(challenge.composedPolicyHash ?? "") ||
|
|
174
|
-
challenge.http.pickup_mode !== "key" ||
|
|
175
|
-
challenge.http.min_assurance === "attested-bearer" ||
|
|
176
|
-
!secureHttpUrl(challenge.http.resource, native.allowLoopbackHttp) ||
|
|
177
|
-
!secureHttpUrl(native.authorizationOrigin, native.allowLoopbackHttp) ||
|
|
178
|
-
new URL(native.authorizationOrigin).origin !==
|
|
179
|
-
native.authorizationOrigin ||
|
|
180
|
-
!/^[A-Za-z0-9._~-]{22,255}$/.test(validated.input.sessionId) ||
|
|
181
|
-
(!native.remoteIssuer &&
|
|
182
|
-
typeof native.issueCredentialStatus !== "function") ||
|
|
183
|
-
(validated.input.serverDid !== undefined &&
|
|
184
|
-
validated.input.serverDid !== challenge.audience) ||
|
|
185
|
-
(native.resourceAudiences &&
|
|
186
|
-
native.resourceAudiences[challenge.http.resource] !==
|
|
187
|
-
challenge.audience))
|
|
188
|
-
return nativeUnavailable();
|
|
189
|
-
try {
|
|
190
|
-
if (!native.remoteIssuer) {
|
|
191
|
-
const identity = await getConfiguredIdentity(env);
|
|
192
|
-
if (!identity || identity.did !== native.issuerDid)
|
|
193
|
-
return nativeUnavailable();
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
catch {
|
|
197
|
-
return nativeUnavailable();
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
const sid = challenge.http
|
|
201
|
-
? validated.input.sessionId
|
|
202
|
-
: deriveRegistrationSid(validated.input.sessionId);
|
|
203
|
-
// Loud dead-end (review P1): without challenge.audience the minted credential
|
|
204
|
-
// carries no aud and cannot pass an org-pinned §4.3 audience gate — a failure
|
|
205
|
-
// that would otherwise surface only POST-consent, at the registrar's PEP,
|
|
206
|
-
// looking like the PEP's fault. Registration still proceeds (self-verifying
|
|
207
|
-
// registrars and future flows are legitimate), but the gap is diagnosable
|
|
208
|
-
// here and in the response's cross_resource flag.
|
|
209
|
-
if (!challenge.audience) {
|
|
210
|
-
console.warn(`[kya-http] external registration without challenge.audience (sid=${sid}): ` +
|
|
211
|
-
`the minted credential will FAIL an org-pinned §4.3 audience gate; ` +
|
|
212
|
-
`cross-resource use requires the registrar to send challenge.audience`);
|
|
213
|
-
}
|
|
214
|
-
let remoteProof;
|
|
215
|
-
if (challenge.http && cfg.native?.remoteIssuer) {
|
|
216
|
-
try {
|
|
217
|
-
remoteProof = await cfg.native.remoteIssuer.registerChallenge(raw, buildNativeChallenge(challenge.http, sid, challenge.requiredScopes, cfg.native.authorizationOrigin), challenge.audience);
|
|
218
|
-
}
|
|
219
|
-
catch {
|
|
220
|
-
return nativeUnavailable();
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
const anchor = await ensureAnchor(env, cfg, deps, sid, challenge, {
|
|
224
|
-
agentDid: validated.input.agentDid,
|
|
225
|
-
serverDid: validated.input.serverDid,
|
|
226
|
-
registeredAtMs: validated.input.createdAt,
|
|
227
|
-
nativeIssuedAtMs: remoteProof?.issuedAtMs,
|
|
228
|
-
});
|
|
229
|
-
if ("error" in anchor)
|
|
230
|
-
return challenge.http ? nativeUnavailable() : anchor.error;
|
|
231
|
-
if (challenge.http) {
|
|
232
|
-
const stored = anchor.snapshot;
|
|
233
|
-
const expected = buildNativeChallenge(challenge.http, sid, challenge.requiredScopes, cfg.native.authorizationOrigin);
|
|
234
|
-
// First-write-wins state must never be reinterpreted by a second registration.
|
|
235
|
-
if (!stored.nativeHttp ||
|
|
236
|
-
stored.audience !== challenge.audience ||
|
|
237
|
-
stored.nativeIssuerDid !== cfg.native.issuerDid ||
|
|
238
|
-
canonicalize(stored.nativePolicyRevision) !==
|
|
239
|
-
canonicalize({
|
|
240
|
-
policyId: challenge.policyId,
|
|
241
|
-
composedPolicyHash: challenge.composedPolicyHash,
|
|
242
|
-
}) ||
|
|
243
|
-
canonicalize(stored.nativeRegistration) !==
|
|
244
|
-
canonicalize(challenge.http) ||
|
|
245
|
-
canonicalize(stored.nativeHttp) !== canonicalize(expected))
|
|
246
|
-
return nativeUnavailable();
|
|
247
|
-
try {
|
|
248
|
-
const remote = remoteProof;
|
|
249
|
-
const proof = remote?.proof ??
|
|
250
|
-
(await signNativeChallenge(env, stored.nativeIssuerDid, stored.nativeHttp, stored.audience));
|
|
251
|
-
return new Response(JSON.stringify({
|
|
252
|
-
success: true,
|
|
253
|
-
data: {
|
|
254
|
-
session_id: sid,
|
|
255
|
-
registered: true,
|
|
256
|
-
created_at: new Date(stored.registeredAtMs ?? validated.input.createdAt).toISOString(),
|
|
257
|
-
challenge: {
|
|
258
|
-
consent_uri: stored.nativeHttp.consent_uri,
|
|
259
|
-
challenge_proof: proof,
|
|
260
|
-
required_scopes: stored.nativeHttp.required_scopes,
|
|
261
|
-
issued_at: remote?.issuedAtMs ?? stored.issuedAtMs,
|
|
262
|
-
http: stored.nativeHttp,
|
|
263
|
-
},
|
|
264
|
-
},
|
|
265
|
-
}), {
|
|
266
|
-
status: anchor.isNew ? 201 : 200,
|
|
267
|
-
headers: {
|
|
268
|
-
"Content-Type": "application/json",
|
|
269
|
-
"Cache-Control": "no-store",
|
|
270
|
-
},
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
catch {
|
|
274
|
-
return nativeUnavailable();
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
// W4: pin the advertised host to the configured realm when set, so a
|
|
278
|
-
// Host-header-reflecting request cannot mint consent/pickup URIs (and a
|
|
279
|
-
// signed proof over them) pointing at an attacker host.
|
|
280
|
-
const host = cfg.realm || new URL(c.req.url).host;
|
|
281
|
-
const verdict = {
|
|
282
|
-
requiredScopes: anchor.snapshot.requiredScopes,
|
|
283
|
-
authorizationHost: host,
|
|
284
|
-
realm: host,
|
|
285
|
-
sid,
|
|
286
|
-
pollIntervalS: cfg.pollIntervalS,
|
|
287
|
-
};
|
|
288
|
-
const consentUri = buildConsentUri(verdict);
|
|
289
|
-
let challengeProof;
|
|
290
|
-
try {
|
|
291
|
-
challengeProof = await signChallengeProof(await deps.proofGenerator(), {
|
|
292
|
-
sid,
|
|
293
|
-
consent_uri: consentUri,
|
|
294
|
-
required_scopes: anchor.snapshot.requiredScopes,
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
catch (error) {
|
|
298
|
-
// The anchor persisted but is unreachable without a proof-bearing response;
|
|
299
|
-
// it expires via its ≤600s TTL (same orphan rationale as the challenge
|
|
300
|
-
// emitter's signing-failure path).
|
|
301
|
-
console.warn(`[kya-http] registration challenge_proof signing failed (sid=${sid}):`, error instanceof Error ? error.message : String(error));
|
|
302
|
-
return errorResponse(502, "proof_unavailable", "The challenge proof could not be signed");
|
|
303
|
-
}
|
|
304
|
-
// Persisted-originals parity (checkpoint echoes the stored row): a reused
|
|
305
|
-
// anchor echoes the FIRST registration's created_at/issued_at, not this
|
|
306
|
-
// request's. The challenge_proof itself is re-signed per response over the
|
|
307
|
-
// stored values, so proof/consent scope desync remains impossible.
|
|
308
|
-
const createdAtMs = anchor.snapshot.registeredAtMs ?? validated.input.createdAt;
|
|
309
|
-
const issuedAtMs = anchor.snapshot.issuedAtMs ?? Date.now();
|
|
310
|
-
return new Response(JSON.stringify({
|
|
311
|
-
success: true,
|
|
312
|
-
data: {
|
|
313
|
-
session_id: sid,
|
|
314
|
-
registered: true,
|
|
315
|
-
created_at: new Date(createdAtMs).toISOString(),
|
|
316
|
-
challenge: {
|
|
317
|
-
consent_uri: consentUri,
|
|
318
|
-
challenge_proof: challengeProof,
|
|
319
|
-
required_scopes: anchor.snapshot.requiredScopes,
|
|
320
|
-
issued_at: issuedAtMs,
|
|
321
|
-
// ADDITIVE diagnostic (not in the frozen conformance key set, ignored
|
|
322
|
-
// by both existing parsers): whether the minted credential will carry
|
|
323
|
-
// the §4.3 cross-resource claims. False means no audience was
|
|
324
|
-
// registered — the credential only self-verifies at this worker.
|
|
325
|
-
cross_resource: typeof anchor.snapshot.audience === "string",
|
|
326
|
-
},
|
|
327
|
-
},
|
|
328
|
-
}), {
|
|
329
|
-
status: anchor.isNew ? 201 : 200,
|
|
330
|
-
headers: {
|
|
331
|
-
"Content-Type": "application/json",
|
|
332
|
-
// Checkpoint's route parity (its success responses are private/no-cache).
|
|
333
|
-
"Cache-Control": "private, no-cache",
|
|
334
|
-
},
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
//# sourceMappingURL=anchor-registration.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"anchor-registration.js","sourceRoot":"","sources":["../../src/delegation-http/anchor-registration.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,mBAAmB,GAGpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,EACL,wBAAwB,GAGzB,MAAM,gCAAgC,CAAC;AAwCxC,wFAAwF;AACxF,MAAM,kBAAkB,GAAG,qBAAqB,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CACzC,GAAyC,EACzC,GAAkB;IAElB,OAAO,CACL,GAAG,KAAK,IAAI;QACZ,GAAG,CAAC,wBAAwB;QAC5B,OAAO,GAAG,CAAC,kBAAkB,KAAK,QAAQ;QAC1C,GAAG,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC;QACjC,uEAAuE;QACvE,yEAAyE;QACzE,qDAAqD;QACrD,GAAG,CAAC,UAAU,KAAK,SAAS,CAC7B,CAAC;AACJ,CAAC;AA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/B,eAAe,EAAE,MAAM,CAAC,QAAQ,CAAC,cAAc;gBAC/C,SAAS,EAAE,UAAU;gBACrB,sEAAsE;gBACtE,sEAAsE;gBACtE,8DAA8D;gBAC9D,iEAAiE;gBACjE,cAAc,EAAE,OAAO,MAAM,CAAC,QAAQ,CAAC,QAAQ,KAAK,QAAQ;aAC7D;SACF;KACF,CAAC,EACF;QACE,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG;QAChC,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,0EAA0E;YAC1E,eAAe,EAAE,mBAAmB;SACrC;KACF,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* draft-kya-http-02 delegation layer — pickup-anchor durable-object routing.
|
|
3
|
-
*
|
|
4
|
-
* Anchor state lives in the existing `MCP_OBJECT` durable object (no new DO class,
|
|
5
|
-
* no wrangler migration). Each anchor gets its OWN instance, named `pickup:<sid>`,
|
|
6
|
-
* so the §13 first-poll race is serialized by the DO input gate and never collides
|
|
7
|
-
* with the MCP session namespace (which uses `DO_ROUTING_STRATEGY`).
|
|
8
|
-
*
|
|
9
|
-
* @module @kya-os/mcp-i-cloudflare/delegation-http/anchor-routing
|
|
10
|
-
*/
|
|
11
|
-
import type { DurableObjectStub } from "@cloudflare/workers-types";
|
|
12
|
-
import type { CloudflareEnv } from "../types";
|
|
13
|
-
/** Durable-object instance name for an anchor: one instance per sid. */
|
|
14
|
-
export declare function anchorInstanceId(sid: string): string;
|
|
15
|
-
/**
|
|
16
|
-
* Resolve the durable-object stub for an anchor's dedicated instance. Throws when
|
|
17
|
-
* `MCP_OBJECT` is not bound (the anchor layer cannot function without it).
|
|
18
|
-
*/
|
|
19
|
-
export declare function getAnchorStub(env: CloudflareEnv, sid: string): DurableObjectStub;
|
|
20
|
-
//# sourceMappingURL=anchor-routing.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"anchor-routing.d.ts","sourceRoot":"","sources":["../../src/delegation-http/anchor-routing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,wEAAwE;AACxE,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,aAAa,EAClB,GAAG,EAAE,MAAM,GACV,iBAAiB,CASnB"}
|