@kya-os/mcp-i-cloudflare 1.17.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 +39 -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 +386 -404
- 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/amount-limit-refusal.d.ts +3 -0
- package/dist/runtime/amount-limit-refusal.d.ts.map +1 -0
- package/dist/runtime/amount-limit-refusal.js +7 -0
- package/dist/runtime/amount-limit-refusal.js.map +1 -0
- 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 +31 -34
- 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 +65 -16
- 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/proof.service.d.ts +10 -0
- package/dist/services/proof.service.d.ts.map +1 -1
- package/dist/services/proof.service.js +28 -6
- package/dist/services/proof.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/oauth-profile.d.ts +19 -0
- package/dist/utils/oauth-profile.d.ts.map +1 -1
- package/dist/utils/oauth-profile.js +54 -1
- package/dist/utils/oauth-profile.js.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 +5 -6
- 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 -393
- 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,175 +1,20 @@
|
|
|
1
1
|
export const NATIVE_OAUTH_INTERNAL_PREFIX = "/_internal/native-oauth/";
|
|
2
|
-
|
|
3
|
-
export const NATIVE_OAUTH_MAX_TTL_MS = 600_000;
|
|
4
|
-
export const NATIVE_OAUTH_MAX_CIPHERTEXT = 32_768;
|
|
5
|
-
export const NATIVE_OAUTH_STORAGE_PROFILE = "dedicated-expiry-alarm-v1";
|
|
6
|
-
export const NATIVE_OAUTH_PROFILE_HEADER = "X-KYA-Native-OAuth-Storage";
|
|
7
|
-
export const NATIVE_OAUTH_ALARM_MAX_RETRIES = 6;
|
|
8
|
-
/** Pure transition, evaluated with the persisted record inside one transaction. */
|
|
9
|
-
export function reduceNativeOAuthState(record, operation, input, now) {
|
|
10
|
-
if (operation === "create") {
|
|
11
|
-
// Never refresh or replace an in-flight or already consumed state.
|
|
12
|
-
if (record)
|
|
13
|
-
return { status: 409 };
|
|
14
|
-
const value = input;
|
|
15
|
-
if (!value ||
|
|
16
|
-
value.version !== 1 ||
|
|
17
|
-
!Number.isSafeInteger(value.expiresAt) ||
|
|
18
|
-
value.expiresAt <= now ||
|
|
19
|
-
value.expiresAt > now + NATIVE_OAUTH_MAX_TTL_MS ||
|
|
20
|
-
typeof value.ciphertext !== "string" ||
|
|
21
|
-
value.ciphertext.length < 38 ||
|
|
22
|
-
value.ciphertext.length > NATIVE_OAUTH_MAX_CIPHERTEXT ||
|
|
23
|
-
!/^[A-Za-z0-9_-]+$/.test(value.ciphertext))
|
|
24
|
-
return { status: 400 };
|
|
25
|
-
return {
|
|
26
|
-
status: 201,
|
|
27
|
-
record: {
|
|
28
|
-
version: 1,
|
|
29
|
-
expiresAt: value.expiresAt,
|
|
30
|
-
ciphertext: value.ciphertext,
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
if (!record)
|
|
35
|
-
return { status: 404 };
|
|
36
|
-
if (record.version !== 1 ||
|
|
37
|
-
!Number.isSafeInteger(record.expiresAt) ||
|
|
38
|
-
record.expiresAt <= now)
|
|
39
|
-
return { status: 410, remove: true };
|
|
40
|
-
if (!record.ciphertext)
|
|
41
|
-
return { status: 404 };
|
|
42
|
-
// Retain only a non-secret tombstone, removed by its expiry alarm; a duplicate
|
|
43
|
-
// create cannot resurrect consumed state. The encrypted verifier is removed now.
|
|
44
|
-
return {
|
|
45
|
-
status: 200,
|
|
46
|
-
record: { version: 1, expiresAt: record.expiresAt },
|
|
47
|
-
body: record,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
function response(status, body) {
|
|
51
|
-
return Response.json(body ?? {}, {
|
|
52
|
-
status,
|
|
53
|
-
headers: {
|
|
54
|
-
"Cache-Control": "no-store",
|
|
55
|
-
[NATIVE_OAUTH_PROFILE_HEADER]: NATIVE_OAUTH_STORAGE_PROFILE,
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
export async function handleNativeOAuthStateInternal(ctx, request) {
|
|
60
|
-
const url = new URL(request.url);
|
|
61
|
-
const operation = url.pathname.slice(NATIVE_OAUTH_INTERNAL_PREFIX.length);
|
|
62
|
-
if (url.origin !== "https://do.internal" ||
|
|
63
|
-
!url.pathname.startsWith(NATIVE_OAUTH_INTERNAL_PREFIX) ||
|
|
64
|
-
(operation !== "create" && operation !== "consume" && operation !== "ready"))
|
|
65
|
-
return response(404);
|
|
66
|
-
if (request.method !== "POST")
|
|
67
|
-
return response(405);
|
|
68
|
-
if (operation === "ready")
|
|
69
|
-
return response(200);
|
|
70
|
-
let input;
|
|
71
|
-
try {
|
|
72
|
-
const text = await request.text();
|
|
73
|
-
if (text.length > NATIVE_OAUTH_MAX_CIPHERTEXT + 128)
|
|
74
|
-
return response(413);
|
|
75
|
-
input = JSON.parse(text);
|
|
76
|
-
}
|
|
77
|
-
catch {
|
|
78
|
-
return response(400);
|
|
79
|
-
}
|
|
80
|
-
try {
|
|
81
|
-
// Only storage awaits inside this transaction. No crypto, network, logging,
|
|
82
|
-
// or externally visible side effects: a platform retry remains harmless.
|
|
83
|
-
const result = await ctx.storage.transaction(async (txn) => {
|
|
84
|
-
const current = await txn.get(NATIVE_OAUTH_STATE_KEY);
|
|
85
|
-
const transition = reduceNativeOAuthState(current, operation, input, Date.now());
|
|
86
|
-
if (transition.remove) {
|
|
87
|
-
await txn.delete(NATIVE_OAUTH_STATE_KEY);
|
|
88
|
-
// Leave its existing expiry alarm to reclaim all object metadata too.
|
|
89
|
-
}
|
|
90
|
-
else if (transition.record) {
|
|
91
|
-
await txn.put(NATIVE_OAUTH_STATE_KEY, transition.record);
|
|
92
|
-
// Commit the deadline with creation. A failed alarm write cannot leave
|
|
93
|
-
// an acknowledged, abandoned ciphertext without scheduled cleanup.
|
|
94
|
-
if (operation === "create")
|
|
95
|
-
await txn.setAlarm(transition.record.expiresAt);
|
|
96
|
-
}
|
|
97
|
-
return transition;
|
|
98
|
-
});
|
|
99
|
-
return response(result.status, result.body);
|
|
100
|
-
}
|
|
101
|
-
catch {
|
|
102
|
-
// Storage errors must never yield the encrypted state or trigger KV fallback.
|
|
103
|
-
return response(503);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
/** Dedicated binding only: never inherit or override the MCP Agent scheduler.
|
|
107
|
-
* A plain DO class matches the package's AuditProducer export convention and
|
|
108
|
-
* keeps the SDK root import usable outside workerd (no cloudflare:workers import).
|
|
109
|
-
*/
|
|
2
|
+
/** A plain DO class, like AuditProducer, so the SDK root import works outside workerd. */
|
|
110
3
|
export class NativeOAuthState {
|
|
111
4
|
ctx;
|
|
112
5
|
constructor(ctx) {
|
|
113
6
|
this.ctx = ctx;
|
|
114
7
|
}
|
|
115
|
-
async fetch(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return response(405);
|
|
121
|
-
try {
|
|
122
|
-
const removed = await this.cleanup({ retryCount: 0, isRetry: false }, "manual");
|
|
123
|
-
return response(removed ? 200 : 202, {
|
|
124
|
-
status: removed ? "expired-data-removed" : "live-state-retained",
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
catch {
|
|
128
|
-
return response(503);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return handleNativeOAuthStateInternal(this.ctx, request);
|
|
132
|
-
}
|
|
133
|
-
async alarm(info = {
|
|
134
|
-
retryCount: 0,
|
|
135
|
-
isRetry: false,
|
|
136
|
-
}) {
|
|
137
|
-
await this.cleanup(info, "alarm");
|
|
8
|
+
async fetch(_request) {
|
|
9
|
+
return new Response(null, {
|
|
10
|
+
status: 404,
|
|
11
|
+
headers: { "Cache-Control": "no-store" },
|
|
12
|
+
});
|
|
138
13
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
// metadata that deleting the single state key would leave behind.
|
|
144
|
-
const record = await this.ctx.storage.get(NATIVE_OAUTH_STATE_KEY);
|
|
145
|
-
if (record?.version === 1 &&
|
|
146
|
-
Number.isSafeInteger(record.expiresAt) &&
|
|
147
|
-
record.expiresAt > Date.now()) {
|
|
148
|
-
// An early/duplicate wake must not erase live authority or its alarm.
|
|
149
|
-
await this.ctx.storage.setAlarm(record.expiresAt);
|
|
150
|
-
return false;
|
|
151
|
-
}
|
|
152
|
-
// Clear data first. If deleting the alarm fails, retry is harmless and
|
|
153
|
-
// must not restore a consumed/expired record.
|
|
154
|
-
await this.ctx.storage.deleteAll();
|
|
155
|
-
await this.ctx.storage.deleteAlarm();
|
|
156
|
-
return true;
|
|
157
|
-
}
|
|
158
|
-
catch {
|
|
159
|
-
// Cloudflare retries a throwing alarm up to six times. Do not swallow a
|
|
160
|
-
// failure or log the exception: storage errors can contain request data.
|
|
161
|
-
console.error({
|
|
162
|
-
component: "native-oauth-state",
|
|
163
|
-
objectId: this.ctx.id.toString(),
|
|
164
|
-
trigger,
|
|
165
|
-
event: info.retryCount >= NATIVE_OAUTH_ALARM_MAX_RETRIES
|
|
166
|
-
? "cleanup_retry_exhausted"
|
|
167
|
-
: "cleanup_failed",
|
|
168
|
-
retryCount: info.retryCount,
|
|
169
|
-
isRetry: info.isRetry,
|
|
170
|
-
});
|
|
171
|
-
throw new Error("Native OAuth state cleanup failed");
|
|
172
|
-
}
|
|
14
|
+
/** Clear state an earlier release left behind. A throw makes Cloudflare retry. */
|
|
15
|
+
async alarm() {
|
|
16
|
+
await this.ctx.storage.deleteAll();
|
|
17
|
+
await this.ctx.storage.deleteAlarm();
|
|
173
18
|
}
|
|
174
19
|
}
|
|
175
20
|
//# sourceMappingURL=native-oauth-state-do.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-oauth-state-do.js","sourceRoot":"","sources":["../../src/delegation-http/native-oauth-state-do.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"native-oauth-state-do.js","sourceRoot":"","sources":["../../src/delegation-http/native-oauth-state-do.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,MAAM,4BAA4B,GAAG,0BAA0B,CAAC;AAEvE,0FAA0F;AAC1F,MAAM,OAAO,gBAAgB;IACI;IAA/B,YAA+B,GAAuB;QAAvB,QAAG,GAAH,GAAG,CAAoB;IAAG,CAAC;IAE1D,KAAK,CAAC,KAAK,CAAC,QAAiB;QAC3B,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE;YACxB,MAAM,EAAE,GAAG;YACX,OAAO,EAAE,EAAE,eAAe,EAAE,UAAU,EAAE;SACzC,CAAC,CAAC;IACL,CAAC;IAED,kFAAkF;IAClF,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;QACnC,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;IACvC,CAAC;CACF"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protected-resource metadata (RFC 9728) for the worker's own resource.
|
|
3
|
+
*
|
|
4
|
+
* The edge's 401s (lazy auth, and a deployment that requires a token to
|
|
5
|
+
* connect) name `https://<routed host>/.well-known/oauth-protected-resource`,
|
|
6
|
+
* where an OAuth client finds the authorization server to use. The worker is
|
|
7
|
+
* the resource server, so it serves that document:
|
|
8
|
+
* - `resource`: `https://<routed host>`, the resource its native challenges
|
|
9
|
+
* register and the host whose `did:web` the org's credentials name as
|
|
10
|
+
* audience;
|
|
11
|
+
* - `authorization_servers`: the org's issuer from the deployment's issuer
|
|
12
|
+
* binding, `<authorizationOrigin>/oauth/<org slug>`, whose RFC 8414
|
|
13
|
+
* metadata Checkpoint serves;
|
|
14
|
+
* - `bearer_methods_supported`: `header`.
|
|
15
|
+
*
|
|
16
|
+
* A deployment without a valid issuer binding names no authorization server,
|
|
17
|
+
* so it has no such document.
|
|
18
|
+
*
|
|
19
|
+
* @module @kya-os/mcp-i-cloudflare/delegation-http/protected-resource
|
|
20
|
+
*/
|
|
21
|
+
import type { RuntimeBinding } from "./issuer-binding";
|
|
22
|
+
/** The well-known path of the document (RFC 9728 §3). */
|
|
23
|
+
export declare const PROTECTED_RESOURCE_METADATA_PATH = "/.well-known/oauth-protected-resource";
|
|
24
|
+
/**
|
|
25
|
+
* The org authorization server's issuer: `<authorizationOrigin>/oauth/<slug>`,
|
|
26
|
+
* with the slug from `did:web:<host>:orgs:<slug>`. Undefined for an issuer DID
|
|
27
|
+
* of any other shape.
|
|
28
|
+
*/
|
|
29
|
+
export declare function orgAuthorizationServer(binding: Pick<RuntimeBinding, "issuerDid" | "authorizationOrigin">): string | undefined;
|
|
30
|
+
export interface ProtectedResourceMetadata {
|
|
31
|
+
resource: string;
|
|
32
|
+
authorization_servers: [string];
|
|
33
|
+
bearer_methods_supported: ["header"];
|
|
34
|
+
}
|
|
35
|
+
/** The document for `routedHost`, or null when the binding names no issuer. */
|
|
36
|
+
export declare function protectedResourceMetadata(routedHost: string, binding: Pick<RuntimeBinding, "issuerDid" | "authorizationOrigin"> | null): ProtectedResourceMetadata | null;
|
|
37
|
+
//# sourceMappingURL=protected-resource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protected-resource.d.ts","sourceRoot":"","sources":["../../src/delegation-http/protected-resource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,yDAAyD;AACzD,eAAO,MAAM,gCAAgC,0CACJ,CAAC;AAE1C;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,WAAW,GAAG,qBAAqB,CAAC,GACjE,MAAM,GAAG,SAAS,CAKpB;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,qBAAqB,EAAE,CAAC,MAAM,CAAC,CAAC;IAChC,wBAAwB,EAAE,CAAC,QAAQ,CAAC,CAAC;CACtC;AAED,+EAA+E;AAC/E,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,WAAW,GAAG,qBAAqB,CAAC,GAAG,IAAI,GACxE,yBAAyB,GAAG,IAAI,CAQlC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protected-resource metadata (RFC 9728) for the worker's own resource.
|
|
3
|
+
*
|
|
4
|
+
* The edge's 401s (lazy auth, and a deployment that requires a token to
|
|
5
|
+
* connect) name `https://<routed host>/.well-known/oauth-protected-resource`,
|
|
6
|
+
* where an OAuth client finds the authorization server to use. The worker is
|
|
7
|
+
* the resource server, so it serves that document:
|
|
8
|
+
* - `resource`: `https://<routed host>`, the resource its native challenges
|
|
9
|
+
* register and the host whose `did:web` the org's credentials name as
|
|
10
|
+
* audience;
|
|
11
|
+
* - `authorization_servers`: the org's issuer from the deployment's issuer
|
|
12
|
+
* binding, `<authorizationOrigin>/oauth/<org slug>`, whose RFC 8414
|
|
13
|
+
* metadata Checkpoint serves;
|
|
14
|
+
* - `bearer_methods_supported`: `header`.
|
|
15
|
+
*
|
|
16
|
+
* A deployment without a valid issuer binding names no authorization server,
|
|
17
|
+
* so it has no such document.
|
|
18
|
+
*
|
|
19
|
+
* @module @kya-os/mcp-i-cloudflare/delegation-http/protected-resource
|
|
20
|
+
*/
|
|
21
|
+
/** The well-known path of the document (RFC 9728 §3). */
|
|
22
|
+
export const PROTECTED_RESOURCE_METADATA_PATH = "/.well-known/oauth-protected-resource";
|
|
23
|
+
/**
|
|
24
|
+
* The org authorization server's issuer: `<authorizationOrigin>/oauth/<slug>`,
|
|
25
|
+
* with the slug from `did:web:<host>:orgs:<slug>`. Undefined for an issuer DID
|
|
26
|
+
* of any other shape.
|
|
27
|
+
*/
|
|
28
|
+
export function orgAuthorizationServer(binding) {
|
|
29
|
+
const slug = /^did:web:[^:/?#]+:orgs:([a-z0-9][a-z0-9-]*)$/.exec(binding.issuerDid)?.[1];
|
|
30
|
+
return slug ? `${binding.authorizationOrigin}/oauth/${slug}` : undefined;
|
|
31
|
+
}
|
|
32
|
+
/** The document for `routedHost`, or null when the binding names no issuer. */
|
|
33
|
+
export function protectedResourceMetadata(routedHost, binding) {
|
|
34
|
+
const issuer = binding ? orgAuthorizationServer(binding) : undefined;
|
|
35
|
+
if (!issuer)
|
|
36
|
+
return null;
|
|
37
|
+
return {
|
|
38
|
+
resource: `https://${routedHost}`,
|
|
39
|
+
authorization_servers: [issuer],
|
|
40
|
+
bearer_methods_supported: ["header"],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=protected-resource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protected-resource.js","sourceRoot":"","sources":["../../src/delegation-http/protected-resource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,yDAAyD;AACzD,MAAM,CAAC,MAAM,gCAAgC,GAC3C,uCAAuC,CAAC;AAE1C;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAAkE;IAElE,MAAM,IAAI,GAAG,8CAA8C,CAAC,IAAI,CAC9D,OAAO,CAAC,SAAS,CAClB,EAAE,CAAC,CAAC,CAAC,CAAC;IACP,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,mBAAmB,UAAU,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3E,CAAC;AAQD,+EAA+E;AAC/E,MAAM,UAAU,yBAAyB,CACvC,UAAkB,EAClB,OAAyE;IAEzE,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACrE,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,OAAO;QACL,QAAQ,EAAE,WAAW,UAAU,EAAE;QACjC,qBAAqB,EAAE,CAAC,MAAM,CAAC;QAC/B,wBAAwB,EAAE,CAAC,QAAQ,CAAC;KACrC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether an MCP request carries a KYA-OS request proof.
|
|
3
|
+
*
|
|
4
|
+
* One detection for every edge step in front of the agent: the pass-through
|
|
5
|
+
* that moves a presented delegation into the call, and the gate that decides
|
|
6
|
+
* which calls may be answered with an HTTP status. A request proof is either
|
|
7
|
+
* an HTTP message signature header or a card proof carrier in `params._meta`.
|
|
8
|
+
* The card keys come only from the validated card proof support accessor;
|
|
9
|
+
* when that cannot be validated, the proof-shaped superset decides, so a
|
|
10
|
+
* proof-shaped call counts as proved. Presence is sufficient: verification
|
|
11
|
+
* stays mandatory downstream, including for malformed proof values.
|
|
12
|
+
*
|
|
13
|
+
* @module @kya-os/mcp-i-cloudflare/delegation-http/request-proof
|
|
14
|
+
*/
|
|
15
|
+
import { type CardProofSupportGetter } from "../security/card-proof-support";
|
|
16
|
+
/** Headers whose signature covers the body, so the body must not change. */
|
|
17
|
+
export declare const SIGNED_REQUEST_HEADERS: readonly ["Signature", "Signature-Input", "KYA-OS-Delegation-Proof"];
|
|
18
|
+
/** Whether the headers or the call's `_meta` carry a request proof. */
|
|
19
|
+
export declare function carriesRequestProof(headers: Headers, meta: unknown, getProofSupport?: CardProofSupportGetter): Promise<boolean>;
|
|
20
|
+
//# sourceMappingURL=request-proof.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-proof.d.ts","sourceRoot":"","sources":["../../src/delegation-http/request-proof.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,KAAK,sBAAsB,EAE5B,MAAM,gCAAgC,CAAC;AAGxC,4EAA4E;AAC5E,eAAO,MAAM,sBAAsB,sEAIzB,CAAC;AAEX,uEAAuE;AACvE,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,OAAO,EACb,eAAe,GAAE,sBAA4C,GAC5D,OAAO,CAAC,OAAO,CAAC,CAGlB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether an MCP request carries a KYA-OS request proof.
|
|
3
|
+
*
|
|
4
|
+
* One detection for every edge step in front of the agent: the pass-through
|
|
5
|
+
* that moves a presented delegation into the call, and the gate that decides
|
|
6
|
+
* which calls may be answered with an HTTP status. A request proof is either
|
|
7
|
+
* an HTTP message signature header or a card proof carrier in `params._meta`.
|
|
8
|
+
* The card keys come only from the validated card proof support accessor;
|
|
9
|
+
* when that cannot be validated, the proof-shaped superset decides, so a
|
|
10
|
+
* proof-shaped call counts as proved. Presence is sufficient: verification
|
|
11
|
+
* stays mandatory downstream, including for malformed proof values.
|
|
12
|
+
*
|
|
13
|
+
* @module @kya-os/mcp-i-cloudflare/delegation-http/request-proof
|
|
14
|
+
*/
|
|
15
|
+
import { getCardProofSupport, } from "../security/card-proof-support";
|
|
16
|
+
import { hasMcpRequestProofAsync } from "../security/presented-delegation";
|
|
17
|
+
/** Headers whose signature covers the body, so the body must not change. */
|
|
18
|
+
export const SIGNED_REQUEST_HEADERS = [
|
|
19
|
+
"Signature",
|
|
20
|
+
"Signature-Input",
|
|
21
|
+
"KYA-OS-Delegation-Proof",
|
|
22
|
+
];
|
|
23
|
+
/** Whether the headers or the call's `_meta` carry a request proof. */
|
|
24
|
+
export async function carriesRequestProof(headers, meta, getProofSupport = getCardProofSupport) {
|
|
25
|
+
if (SIGNED_REQUEST_HEADERS.some((name) => headers.has(name)))
|
|
26
|
+
return true;
|
|
27
|
+
return hasMcpRequestProofAsync(meta, getProofSupport);
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=request-proof.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-proof.js","sourceRoot":"","sources":["../../src/delegation-http/request-proof.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAEL,mBAAmB,GACpB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAE3E,4EAA4E;AAC5E,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,WAAW;IACX,iBAAiB;IACjB,yBAAyB;CACjB,CAAC;AAEX,uEAAuE;AACvE,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,OAAgB,EAChB,IAAa,EACb,kBAA0C,mBAAmB;IAE7D,IAAI,sBAAsB,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAC1E,OAAO,uBAAuB,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* draft-kya-http-02 delegation layer —
|
|
2
|
+
* draft-kya-http-02 delegation layer — challenge session id (sid).
|
|
3
3
|
*
|
|
4
4
|
* The `kya-…` wire format is unrelated to the C4 `kyaos_` session prefix flip — it
|
|
5
|
-
* is the opaque correlation id
|
|
6
|
-
* the
|
|
5
|
+
* is the opaque correlation id a native challenge registration proposes, shared
|
|
6
|
+
* by the challenge, the org's consent page, and its pickup endpoint.
|
|
7
7
|
*
|
|
8
8
|
* @module @kya-os/mcp-i-cloudflare/delegation-http/sid
|
|
9
9
|
*/
|
|
10
10
|
/**
|
|
11
|
-
* Generate a fresh
|
|
11
|
+
* Generate a fresh sid: `"kya-"` + 32 lowercase hex characters (16 random
|
|
12
12
|
* bytes from `crypto.getRandomValues`).
|
|
13
13
|
*/
|
|
14
14
|
export declare function generateSid(): string;
|
|
15
|
-
/**
|
|
16
|
-
* Validate anchor ID syntax, including externally registered opaque HTTP IDs.
|
|
17
|
-
* Syntax alone cannot select the anchor route: legacy UUID session IDs also
|
|
18
|
-
* pass this guard. Use it only for an explicit anchor field or dedicated route.
|
|
19
|
-
*/
|
|
20
|
-
export declare function isAnchorSid(s: string | null | undefined): s is string;
|
|
21
|
-
/** Recognize the original anchor namespace in a generic legacy session_id. */
|
|
22
|
-
export declare function isNamespacedAnchorSid(s: unknown): s is string;
|
|
23
15
|
//# sourceMappingURL=sid.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sid.d.ts","sourceRoot":"","sources":["../../src/delegation-http/sid.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"sid.d.ts","sourceRoot":"","sources":["../../src/delegation-http/sid.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;GAGG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAQpC"}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* draft-kya-http-02 delegation layer —
|
|
2
|
+
* draft-kya-http-02 delegation layer — challenge session id (sid).
|
|
3
3
|
*
|
|
4
4
|
* The `kya-…` wire format is unrelated to the C4 `kyaos_` session prefix flip — it
|
|
5
|
-
* is the opaque correlation id
|
|
6
|
-
* the
|
|
5
|
+
* is the opaque correlation id a native challenge registration proposes, shared
|
|
6
|
+
* by the challenge, the org's consent page, and its pickup endpoint.
|
|
7
7
|
*
|
|
8
8
|
* @module @kya-os/mcp-i-cloudflare/delegation-http/sid
|
|
9
9
|
*/
|
|
10
|
-
/** Matches generated sids (`kya-` + 32 hex) and the shorter fixture sids (16 hex). */
|
|
11
|
-
const ANCHOR_SID_RE = /^kya-[0-9a-f]{16,64}$/;
|
|
12
10
|
/**
|
|
13
|
-
* Generate a fresh
|
|
11
|
+
* Generate a fresh sid: `"kya-"` + 32 lowercase hex characters (16 random
|
|
14
12
|
* bytes from `crypto.getRandomValues`).
|
|
15
13
|
*/
|
|
16
14
|
export function generateSid() {
|
|
@@ -22,17 +20,4 @@ export function generateSid() {
|
|
|
22
20
|
}
|
|
23
21
|
return `kya-${hex}`;
|
|
24
22
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Validate anchor ID syntax, including externally registered opaque HTTP IDs.
|
|
27
|
-
* Syntax alone cannot select the anchor route: legacy UUID session IDs also
|
|
28
|
-
* pass this guard. Use it only for an explicit anchor field or dedicated route.
|
|
29
|
-
*/
|
|
30
|
-
export function isAnchorSid(s) {
|
|
31
|
-
return (isNamespacedAnchorSid(s) ||
|
|
32
|
-
(typeof s === "string" && /^[A-Za-z0-9._~-]{22,255}$/.test(s)));
|
|
33
|
-
}
|
|
34
|
-
/** Recognize the original anchor namespace in a generic legacy session_id. */
|
|
35
|
-
export function isNamespacedAnchorSid(s) {
|
|
36
|
-
return typeof s === "string" && ANCHOR_SID_RE.test(s);
|
|
37
|
-
}
|
|
38
23
|
//# sourceMappingURL=sid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sid.js","sourceRoot":"","sources":["../../src/delegation-http/sid.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH
|
|
1
|
+
{"version":3,"file":"sid.js","sourceRoot":"","sources":["../../src/delegation-http/sid.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;GAGG;AACH,MAAM,UAAU,WAAW;IACzB,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IACjC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAC9B,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,GAAG,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,OAAO,GAAG,EAAE,CAAC;AACtB,CAAC"}
|
|
@@ -8,25 +8,21 @@
|
|
|
8
8
|
* Cloudflare-worker-specific feature, not a general MCP-I identity concept.
|
|
9
9
|
*
|
|
10
10
|
* This module is a small, pure seam that merges it in afterward, scoped to
|
|
11
|
-
* exactly the one well-known path a
|
|
12
|
-
*
|
|
11
|
+
* exactly the one well-known path. The worker is a resource server only: the
|
|
12
|
+
* org authorization service hosts consent, sign-in and pickup, so nothing here
|
|
13
|
+
* advertises the worker as an authorization host.
|
|
13
14
|
*
|
|
14
15
|
* @module @kya-os/mcp-i-cloudflare/delegation-http/well-known-capability
|
|
15
16
|
*/
|
|
16
|
-
import type { HttpChallengeConfig } from "../config";
|
|
17
17
|
import type { EffectiveAuditAssurance } from "../audit/assurance";
|
|
18
18
|
/**
|
|
19
19
|
* Merge a `delegationHttp` capability field into the kya-os-identity well-known
|
|
20
|
-
* response
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* the gate checkpoint's C3 redirect must verify before pointing a challenge
|
|
24
|
-
* here). Every other well-known path, and a null/undefined result (nothing to
|
|
25
|
-
* augment), passes through unchanged.
|
|
20
|
+
* response: `enabled: true` and this package's own version, plus the effective audit assurance when known. Every
|
|
21
|
+
* other well-known path, and a null/undefined result (nothing to augment),
|
|
22
|
+
* passes through unchanged.
|
|
26
23
|
*
|
|
27
24
|
* `{ enabled, version }` is a LOCKED wire contract with checkpoint's
|
|
28
|
-
*
|
|
29
|
-
* current probe ignores unknown fields).
|
|
25
|
+
* capability probe.
|
|
30
26
|
*/
|
|
31
|
-
export declare function augmentKyaOsIdentityWellKnown(wellKnownPath: string, result: Record<string, unknown> | null | undefined,
|
|
27
|
+
export declare function augmentKyaOsIdentityWellKnown(wellKnownPath: string, result: Record<string, unknown> | null | undefined, auditAssurance?: EffectiveAuditAssurance): Record<string, unknown> | null | undefined;
|
|
32
28
|
//# sourceMappingURL=well-known-capability.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"well-known-capability.d.ts","sourceRoot":"","sources":["../../src/delegation-http/well-known-capability.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"well-known-capability.d.ts","sourceRoot":"","sources":["../../src/delegation-http/well-known-capability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAOlE;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAC3C,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,EAClD,cAAc,CAAC,EAAE,uBAAuB,GACvC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,CAa5C"}
|
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
* Cloudflare-worker-specific feature, not a general MCP-I identity concept.
|
|
9
9
|
*
|
|
10
10
|
* This module is a small, pure seam that merges it in afterward, scoped to
|
|
11
|
-
* exactly the one well-known path a
|
|
12
|
-
*
|
|
11
|
+
* exactly the one well-known path. The worker is a resource server only: the
|
|
12
|
+
* org authorization service hosts consent, sign-in and pickup, so nothing here
|
|
13
|
+
* advertises the worker as an authorization host.
|
|
13
14
|
*
|
|
14
15
|
* @module @kya-os/mcp-i-cloudflare/delegation-http/well-known-capability
|
|
15
16
|
*/
|
|
@@ -19,32 +20,22 @@ import ownPackageJson from "../../package.json";
|
|
|
19
20
|
const KYA_OS_IDENTITY_WELL_KNOWN_PATH = "/.well-known/kya-os-identity";
|
|
20
21
|
/**
|
|
21
22
|
* Merge a `delegationHttp` capability field into the kya-os-identity well-known
|
|
22
|
-
* response
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* the gate checkpoint's C3 redirect must verify before pointing a challenge
|
|
26
|
-
* here). Every other well-known path, and a null/undefined result (nothing to
|
|
27
|
-
* augment), passes through unchanged.
|
|
23
|
+
* response: `enabled: true` and this package's own version, plus the effective audit assurance when known. Every
|
|
24
|
+
* other well-known path, and a null/undefined result (nothing to augment),
|
|
25
|
+
* passes through unchanged.
|
|
28
26
|
*
|
|
29
27
|
* `{ enabled, version }` is a LOCKED wire contract with checkpoint's
|
|
30
|
-
*
|
|
31
|
-
* current probe ignores unknown fields).
|
|
28
|
+
* capability probe.
|
|
32
29
|
*/
|
|
33
|
-
export function augmentKyaOsIdentityWellKnown(wellKnownPath, result,
|
|
30
|
+
export function augmentKyaOsIdentityWellKnown(wellKnownPath, result, auditAssurance) {
|
|
34
31
|
if (wellKnownPath !== KYA_OS_IDENTITY_WELL_KNOWN_PATH || !result) {
|
|
35
32
|
return result;
|
|
36
33
|
}
|
|
37
34
|
return {
|
|
38
35
|
...result,
|
|
39
|
-
nativeHttpIssuer: {
|
|
40
|
-
version: 1,
|
|
41
|
-
ready: !!(anchorRegistration && cfg?.native?.remoteIssuer),
|
|
42
|
-
...(cfg?.native?.remoteIssuer ? { issuerDid: cfg.native.issuerDid, authorizationOrigin: cfg.native.authorizationOrigin } : {}),
|
|
43
|
-
},
|
|
44
36
|
delegationHttp: {
|
|
45
|
-
enabled:
|
|
37
|
+
enabled: true,
|
|
46
38
|
version: ownPackageJson.version,
|
|
47
|
-
anchorRegistration,
|
|
48
39
|
},
|
|
49
40
|
...(auditAssurance === undefined ? {} : { auditAssurance }),
|
|
50
41
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"well-known-capability.js","sourceRoot":"","sources":["../../src/delegation-http/well-known-capability.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"well-known-capability.js","sourceRoot":"","sources":["../../src/delegation-http/well-known-capability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,+EAA+E;AAC/E,iFAAiF;AACjF,OAAO,cAAc,MAAM,oBAAoB,CAAC;AAEhD,MAAM,+BAA+B,GAAG,8BAA8B,CAAC;AAEvE;;;;;;;;GAQG;AACH,MAAM,UAAU,6BAA6B,CAC3C,aAAqB,EACrB,MAAkD,EAClD,cAAwC;IAExC,IAAI,aAAa,KAAK,+BAA+B,IAAI,CAAC,MAAM,EAAE,CAAC;QACjE,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO;QACL,GAAG,MAAM;QACT,cAAc,EAAE;YACd,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,cAAc,CAAC,OAAO;SAChC;QACD,GAAG,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC;KAC5D,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-mapper.d.ts","sourceRoot":"","sources":["../../src/helpers/env-mapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EACV,WAAW,EAGZ,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAkBtD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uBAAuB,EAAG,SAAkB,CAAC;AAE1D;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,MAAM,CAAC,EAAE,MAAM,GACd,WAAW,GAAG,SAAS,CAkCzB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,SAAS,CAiC5D;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,qBAAqB,EAC7B,MAAM,EAAE,MAAM,GACb,aAAa,
|
|
1
|
+
{"version":3,"file":"env-mapper.d.ts","sourceRoot":"","sources":["../../src/helpers/env-mapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EACV,WAAW,EAGZ,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAkBtD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uBAAuB,EAAG,SAAkB,CAAC;AAE1D;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,MAAM,CAAC,EAAE,MAAM,GACd,WAAW,GAAG,SAAS,CAkCzB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,SAAS,CAiC5D;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,qBAAqB,EAC7B,MAAM,EAAE,MAAM,GACb,aAAa,CA8If;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,GAAG,EACX,MAAM,CAAC,EAAE,MAAM,GACd,aAAa,CAqIf"}
|
|
@@ -175,17 +175,10 @@ export function mapPrefixedEnv(source, prefix) {
|
|
|
175
175
|
MCPI_NATIVE_HTTP_ISSUER_CONFIG: typeof env.MCPI_NATIVE_HTTP_ISSUER_CONFIG === "string"
|
|
176
176
|
? env.MCPI_NATIVE_HTTP_ISSUER_CONFIG
|
|
177
177
|
: undefined,
|
|
178
|
-
MCPI_NATIVE_HTTP_INGRESS: typeof env.MCPI_NATIVE_HTTP_INGRESS === "string"
|
|
179
|
-
? env.MCPI_NATIVE_HTTP_INGRESS
|
|
180
|
-
: undefined,
|
|
181
|
-
MCPI_NATIVE_HTTP_ISSUER_API_KEY: typeof env.MCPI_NATIVE_HTTP_ISSUER_API_KEY === "string"
|
|
182
|
-
? env.MCPI_NATIVE_HTTP_ISSUER_API_KEY
|
|
183
|
-
: undefined,
|
|
184
178
|
// Delegation trust policy (DelegationService); set unprefixed like the
|
|
185
179
|
// native issuer binding above.
|
|
186
180
|
KYA_OS_TRUSTED_DELEGATION_ISSUERS: stringValue(env.KYA_OS_TRUSTED_DELEGATION_ISSUERS),
|
|
187
181
|
KYA_OS_RESOURCE_DIDS: stringValue(env.KYA_OS_RESOURCE_DIDS),
|
|
188
|
-
KYA_OS_INSECURE_DEV_TOKENS: stringValue(env.KYA_OS_INSECURE_DEV_TOKENS),
|
|
189
182
|
CHECKPOINT_API_URL: typeof env.CHECKPOINT_API_URL === "string"
|
|
190
183
|
? env.CHECKPOINT_API_URL
|
|
191
184
|
: undefined,
|
|
@@ -216,22 +209,18 @@ export function mapPrefixedEnv(source, prefix) {
|
|
|
216
209
|
: undefined,
|
|
217
210
|
// Scalar config flags are set unprefixed (like the secrets above), so copy
|
|
218
211
|
// them across verbatim — otherwise a prefixed deployment silently loses the
|
|
219
|
-
// documented
|
|
220
|
-
// overrides. These are read off this mapped
|
|
221
|
-
// agent.ts inline-consent
|
|
222
|
-
MCPI_HTTP_CHALLENGE: typeof env.MCPI_HTTP_CHALLENGE === "string"
|
|
223
|
-
? env.MCPI_HTTP_CHALLENGE
|
|
224
|
-
: undefined,
|
|
212
|
+
// documented MCPI_TEST_CONSENT / MCPI_INLINE_CONSENT /
|
|
213
|
+
// MCPI_REQUIRE_TOKEN_TO_CONNECT overrides. These are read off this mapped
|
|
214
|
+
// env downstream (agent.ts inline-consent, app.ts connect gate).
|
|
225
215
|
MCPI_TEST_CONSENT: typeof env.MCPI_TEST_CONSENT === "string"
|
|
226
216
|
? env.MCPI_TEST_CONSENT
|
|
227
217
|
: undefined,
|
|
228
218
|
MCPI_INLINE_CONSENT: typeof env.MCPI_INLINE_CONSENT === "string"
|
|
229
219
|
? env.MCPI_INLINE_CONSENT
|
|
230
220
|
: undefined,
|
|
231
|
-
|
|
232
|
-
? env.
|
|
221
|
+
MCPI_REQUIRE_TOKEN_TO_CONNECT: typeof env.MCPI_REQUIRE_TOKEN_TO_CONNECT === "string"
|
|
222
|
+
? env.MCPI_REQUIRE_TOKEN_TO_CONNECT
|
|
233
223
|
: undefined,
|
|
234
|
-
MCPI_REALM: typeof env.MCPI_REALM === "string" ? env.MCPI_REALM : undefined,
|
|
235
224
|
CONSENT_REQUIRE_IDENTITY: typeof env.CONSENT_REQUIRE_IDENTITY === "string"
|
|
236
225
|
? env.CONSENT_REQUIRE_IDENTITY
|
|
237
226
|
: undefined,
|
|
@@ -324,17 +313,10 @@ export function normalizeCloudflareEnv(source, prefix) {
|
|
|
324
313
|
MCPI_NATIVE_HTTP_ISSUER_CONFIG: typeof env.MCPI_NATIVE_HTTP_ISSUER_CONFIG === "string"
|
|
325
314
|
? env.MCPI_NATIVE_HTTP_ISSUER_CONFIG
|
|
326
315
|
: undefined,
|
|
327
|
-
MCPI_NATIVE_HTTP_INGRESS: typeof env.MCPI_NATIVE_HTTP_INGRESS === "string"
|
|
328
|
-
? env.MCPI_NATIVE_HTTP_INGRESS
|
|
329
|
-
: undefined,
|
|
330
|
-
MCPI_NATIVE_HTTP_ISSUER_API_KEY: typeof env.MCPI_NATIVE_HTTP_ISSUER_API_KEY === "string"
|
|
331
|
-
? env.MCPI_NATIVE_HTTP_ISSUER_API_KEY
|
|
332
|
-
: undefined,
|
|
333
316
|
// Delegation trust policy (DelegationService); set unprefixed like the
|
|
334
317
|
// native issuer binding above.
|
|
335
318
|
KYA_OS_TRUSTED_DELEGATION_ISSUERS: stringValue(env.KYA_OS_TRUSTED_DELEGATION_ISSUERS),
|
|
336
319
|
KYA_OS_RESOURCE_DIDS: stringValue(env.KYA_OS_RESOURCE_DIDS),
|
|
337
|
-
KYA_OS_INSECURE_DEV_TOKENS: stringValue(env.KYA_OS_INSECURE_DEV_TOKENS),
|
|
338
320
|
CHECKPOINT_API_URL: typeof env.CHECKPOINT_API_URL === "string"
|
|
339
321
|
? env.CHECKPOINT_API_URL
|
|
340
322
|
: undefined,
|
|
@@ -362,19 +344,15 @@ export function normalizeCloudflareEnv(source, prefix) {
|
|
|
362
344
|
? env.REPUTATION_API_KEY
|
|
363
345
|
: undefined,
|
|
364
346
|
// Scalar config flags (see mapPrefixedEnv) — preserved on the no-prefix path too.
|
|
365
|
-
MCPI_HTTP_CHALLENGE: typeof env.MCPI_HTTP_CHALLENGE === "string"
|
|
366
|
-
? env.MCPI_HTTP_CHALLENGE
|
|
367
|
-
: undefined,
|
|
368
347
|
MCPI_TEST_CONSENT: typeof env.MCPI_TEST_CONSENT === "string"
|
|
369
348
|
? env.MCPI_TEST_CONSENT
|
|
370
349
|
: undefined,
|
|
371
350
|
MCPI_INLINE_CONSENT: typeof env.MCPI_INLINE_CONSENT === "string"
|
|
372
351
|
? env.MCPI_INLINE_CONSENT
|
|
373
352
|
: undefined,
|
|
374
|
-
|
|
375
|
-
? env.
|
|
353
|
+
MCPI_REQUIRE_TOKEN_TO_CONNECT: typeof env.MCPI_REQUIRE_TOKEN_TO_CONNECT === "string"
|
|
354
|
+
? env.MCPI_REQUIRE_TOKEN_TO_CONNECT
|
|
376
355
|
: undefined,
|
|
377
|
-
MCPI_REALM: typeof env.MCPI_REALM === "string" ? env.MCPI_REALM : undefined,
|
|
378
356
|
CONSENT_REQUIRE_IDENTITY: typeof env.CONSENT_REQUIRE_IDENTITY === "string"
|
|
379
357
|
? env.CONSENT_REQUIRE_IDENTITY
|
|
380
358
|
: undefined,
|