@kya-os/mcp-i-cloudflare 1.18.0 → 1.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +4 -5
- 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
|
@@ -82,13 +82,13 @@ declare const deploymentBindingSchema: z.ZodObject<{
|
|
|
82
82
|
value: z.ZodString;
|
|
83
83
|
keyId: z.ZodString;
|
|
84
84
|
}, "strict", z.ZodTypeAny, {
|
|
85
|
-
kind: "keyed_commitment";
|
|
86
85
|
value: string;
|
|
87
86
|
keyId: string;
|
|
88
|
-
}, {
|
|
89
87
|
kind: "keyed_commitment";
|
|
88
|
+
}, {
|
|
90
89
|
value: string;
|
|
91
90
|
keyId: string;
|
|
91
|
+
kind: "keyed_commitment";
|
|
92
92
|
}>, z.ZodObject<{
|
|
93
93
|
kind: z.ZodLiteral<"evidence_ref">;
|
|
94
94
|
ref: z.ZodObject<{
|
|
@@ -139,7 +139,6 @@ declare const deploymentBindingSchema: z.ZodObject<{
|
|
|
139
139
|
plaintextCommitment?: string | undefined;
|
|
140
140
|
}>;
|
|
141
141
|
}, "strict", z.ZodTypeAny, {
|
|
142
|
-
kind: "evidence_ref";
|
|
143
142
|
ref: {
|
|
144
143
|
size: string;
|
|
145
144
|
objectId: string;
|
|
@@ -153,8 +152,8 @@ declare const deploymentBindingSchema: z.ZodObject<{
|
|
|
153
152
|
};
|
|
154
153
|
plaintextCommitment?: string | undefined;
|
|
155
154
|
};
|
|
156
|
-
}, {
|
|
157
155
|
kind: "evidence_ref";
|
|
156
|
+
}, {
|
|
158
157
|
ref: {
|
|
159
158
|
size: string;
|
|
160
159
|
objectId: string;
|
|
@@ -168,6 +167,7 @@ declare const deploymentBindingSchema: z.ZodObject<{
|
|
|
168
167
|
};
|
|
169
168
|
plaintextCommitment?: string | undefined;
|
|
170
169
|
};
|
|
170
|
+
kind: "evidence_ref";
|
|
171
171
|
}>]>;
|
|
172
172
|
producerRef: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
173
173
|
kind: z.ZodLiteral<"public_did">;
|
|
@@ -192,13 +192,13 @@ declare const deploymentBindingSchema: z.ZodObject<{
|
|
|
192
192
|
value: z.ZodString;
|
|
193
193
|
keyId: z.ZodString;
|
|
194
194
|
}, "strict", z.ZodTypeAny, {
|
|
195
|
-
kind: "keyed_commitment";
|
|
196
195
|
value: string;
|
|
197
196
|
keyId: string;
|
|
198
|
-
}, {
|
|
199
197
|
kind: "keyed_commitment";
|
|
198
|
+
}, {
|
|
200
199
|
value: string;
|
|
201
200
|
keyId: string;
|
|
201
|
+
kind: "keyed_commitment";
|
|
202
202
|
}>, z.ZodObject<{
|
|
203
203
|
kind: z.ZodLiteral<"evidence_ref">;
|
|
204
204
|
ref: z.ZodObject<{
|
|
@@ -249,7 +249,6 @@ declare const deploymentBindingSchema: z.ZodObject<{
|
|
|
249
249
|
plaintextCommitment?: string | undefined;
|
|
250
250
|
}>;
|
|
251
251
|
}, "strict", z.ZodTypeAny, {
|
|
252
|
-
kind: "evidence_ref";
|
|
253
252
|
ref: {
|
|
254
253
|
size: string;
|
|
255
254
|
objectId: string;
|
|
@@ -263,8 +262,8 @@ declare const deploymentBindingSchema: z.ZodObject<{
|
|
|
263
262
|
};
|
|
264
263
|
plaintextCommitment?: string | undefined;
|
|
265
264
|
};
|
|
266
|
-
}, {
|
|
267
265
|
kind: "evidence_ref";
|
|
266
|
+
}, {
|
|
268
267
|
ref: {
|
|
269
268
|
size: string;
|
|
270
269
|
objectId: string;
|
|
@@ -278,6 +277,7 @@ declare const deploymentBindingSchema: z.ZodObject<{
|
|
|
278
277
|
};
|
|
279
278
|
plaintextCommitment?: string | undefined;
|
|
280
279
|
};
|
|
280
|
+
kind: "evidence_ref";
|
|
281
281
|
}>]>;
|
|
282
282
|
recorderSigner: z.ZodObject<{
|
|
283
283
|
did: z.ZodString;
|
|
@@ -332,11 +332,10 @@ declare const deploymentBindingSchema: z.ZodObject<{
|
|
|
332
332
|
did: string;
|
|
333
333
|
kind: "pairwise_did";
|
|
334
334
|
} | {
|
|
335
|
-
kind: "keyed_commitment";
|
|
336
335
|
value: string;
|
|
337
336
|
keyId: string;
|
|
337
|
+
kind: "keyed_commitment";
|
|
338
338
|
} | {
|
|
339
|
-
kind: "evidence_ref";
|
|
340
339
|
ref: {
|
|
341
340
|
size: string;
|
|
342
341
|
objectId: string;
|
|
@@ -350,6 +349,7 @@ declare const deploymentBindingSchema: z.ZodObject<{
|
|
|
350
349
|
};
|
|
351
350
|
plaintextCommitment?: string | undefined;
|
|
352
351
|
};
|
|
352
|
+
kind: "evidence_ref";
|
|
353
353
|
};
|
|
354
354
|
readiness: {
|
|
355
355
|
status: "disabled" | "ready" | "degraded";
|
|
@@ -366,11 +366,10 @@ declare const deploymentBindingSchema: z.ZodObject<{
|
|
|
366
366
|
did: string;
|
|
367
367
|
kind: "pairwise_did";
|
|
368
368
|
} | {
|
|
369
|
-
kind: "keyed_commitment";
|
|
370
369
|
value: string;
|
|
371
370
|
keyId: string;
|
|
371
|
+
kind: "keyed_commitment";
|
|
372
372
|
} | {
|
|
373
|
-
kind: "evidence_ref";
|
|
374
373
|
ref: {
|
|
375
374
|
size: string;
|
|
376
375
|
objectId: string;
|
|
@@ -384,6 +383,7 @@ declare const deploymentBindingSchema: z.ZodObject<{
|
|
|
384
383
|
};
|
|
385
384
|
plaintextCommitment?: string | undefined;
|
|
386
385
|
};
|
|
386
|
+
kind: "evidence_ref";
|
|
387
387
|
};
|
|
388
388
|
secretReferences: {
|
|
389
389
|
producerInternalToken: "KYA_OS_AUDIT_PRODUCER_INTERNAL_TOKEN";
|
|
@@ -416,11 +416,10 @@ declare const deploymentBindingSchema: z.ZodObject<{
|
|
|
416
416
|
did: string;
|
|
417
417
|
kind: "pairwise_did";
|
|
418
418
|
} | {
|
|
419
|
-
kind: "keyed_commitment";
|
|
420
419
|
value: string;
|
|
421
420
|
keyId: string;
|
|
421
|
+
kind: "keyed_commitment";
|
|
422
422
|
} | {
|
|
423
|
-
kind: "evidence_ref";
|
|
424
423
|
ref: {
|
|
425
424
|
size: string;
|
|
426
425
|
objectId: string;
|
|
@@ -434,6 +433,7 @@ declare const deploymentBindingSchema: z.ZodObject<{
|
|
|
434
433
|
};
|
|
435
434
|
plaintextCommitment?: string | undefined;
|
|
436
435
|
};
|
|
436
|
+
kind: "evidence_ref";
|
|
437
437
|
};
|
|
438
438
|
readiness: {
|
|
439
439
|
status: "disabled" | "ready" | "degraded";
|
|
@@ -450,11 +450,10 @@ declare const deploymentBindingSchema: z.ZodObject<{
|
|
|
450
450
|
did: string;
|
|
451
451
|
kind: "pairwise_did";
|
|
452
452
|
} | {
|
|
453
|
-
kind: "keyed_commitment";
|
|
454
453
|
value: string;
|
|
455
454
|
keyId: string;
|
|
455
|
+
kind: "keyed_commitment";
|
|
456
456
|
} | {
|
|
457
|
-
kind: "evidence_ref";
|
|
458
457
|
ref: {
|
|
459
458
|
size: string;
|
|
460
459
|
objectId: string;
|
|
@@ -468,6 +467,7 @@ declare const deploymentBindingSchema: z.ZodObject<{
|
|
|
468
467
|
};
|
|
469
468
|
plaintextCommitment?: string | undefined;
|
|
470
469
|
};
|
|
470
|
+
kind: "evidence_ref";
|
|
471
471
|
};
|
|
472
472
|
secretReferences: {
|
|
473
473
|
producerInternalToken: "KYA_OS_AUDIT_PRODUCER_INTERNAL_TOKEN";
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authority outcomes of a tools/call, as tool results.
|
|
3
|
+
*
|
|
4
|
+
* For an MCP server every authority decision on a tool call is a signed tool
|
|
5
|
+
* result, never an HTTP status:
|
|
6
|
+
*
|
|
7
|
+
* - `needs_authorization`: a new grant could fix it (no grant, revoked,
|
|
8
|
+
* expired, wrong holder, insufficient scope, a delegation the verifier
|
|
9
|
+
* refused).
|
|
10
|
+
* - `denied`: a new grant would not fix it (a stateful policy refusal such as
|
|
11
|
+
* a spent call budget, or a request-admission refusal).
|
|
12
|
+
*
|
|
13
|
+
* This module builds the result shapes. It signs nothing and reads no
|
|
14
|
+
* environment: the caller supplies every input and attaches the proof.
|
|
15
|
+
*
|
|
16
|
+
* @module @kya-os/mcp-i-cloudflare/authority-outcome
|
|
17
|
+
*/
|
|
18
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
19
|
+
import type { ClientMessagesConfig } from "@kya-os/contracts/config";
|
|
20
|
+
import type { DelegationDenial } from "@kya-os/mcp-i-runtime";
|
|
21
|
+
import type { RuntimeBinding } from "./delegation-http/issuer-binding";
|
|
22
|
+
import type { RegisteredNativeChallenge } from "./delegation-http/native-challenge";
|
|
23
|
+
/** `_meta` key that carries the OAuth challenge as a hint to MCP clients. */
|
|
24
|
+
export declare const WWW_AUTHENTICATE_META_KEY = "mcp/www_authenticate";
|
|
25
|
+
/** Whether a verifier refusal is a stateful policy refusal (`denied`). */
|
|
26
|
+
export declare function isStatefulDenial(denial: DelegationDenial | undefined): boolean;
|
|
27
|
+
export interface BearerChallengeInput {
|
|
28
|
+
/** The host the request was routed for; absent when it is not known. */
|
|
29
|
+
routedHost: string | undefined;
|
|
30
|
+
description: string;
|
|
31
|
+
scopes: readonly string[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The RFC 6750 / RFC 9728 challenge a tool result carries for an OAuth client.
|
|
35
|
+
*
|
|
36
|
+
* In a tool result the error is always `insufficient_scope`: that is the code
|
|
37
|
+
* hosts act on there, and the precise cause travels as the result's
|
|
38
|
+
* `reasonCode`. A transport 401 at the edge keeps RFC 6750's `invalid_token`
|
|
39
|
+
* for a presented token that is expired or invalid (lazy-auth-gate).
|
|
40
|
+
*/
|
|
41
|
+
export declare function bearerChallenge(input: BearerChallengeInput): {
|
|
42
|
+
header: string;
|
|
43
|
+
error: "insufficient_scope";
|
|
44
|
+
resourceMetadata: string | undefined;
|
|
45
|
+
scope: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* The org's public connect page for the deployment's project:
|
|
49
|
+
* `<authorizationOrigin>/connect/<projectId>`. A person who opens it sees how
|
|
50
|
+
* to connect this server in their client; connecting runs the OAuth flow.
|
|
51
|
+
* Checkpoint serves it without sign-in.
|
|
52
|
+
*/
|
|
53
|
+
export declare function orgConnectUrl(binding: RuntimeBinding): string;
|
|
54
|
+
export interface NeedsAuthorizationInput {
|
|
55
|
+
/** The human message shown to the person, with the link. */
|
|
56
|
+
message: string;
|
|
57
|
+
authorizationUrl: string;
|
|
58
|
+
resumeToken: string;
|
|
59
|
+
/** When the resume token expires, in seconds since the epoch. */
|
|
60
|
+
expiresAt: number;
|
|
61
|
+
/** The scopes this call requires. */
|
|
62
|
+
scopes: string[];
|
|
63
|
+
/**
|
|
64
|
+
* The scopes of a presented grant the verifier found genuine but too
|
|
65
|
+
* narrow. The challenge names them with the required ones, so a new grant
|
|
66
|
+
* keeps what the old one held.
|
|
67
|
+
*/
|
|
68
|
+
grantedScopes?: readonly string[];
|
|
69
|
+
/** The verifier's allowlisted code when it refused a presented credential. */
|
|
70
|
+
denial?: DelegationDenial;
|
|
71
|
+
routedHost: string | undefined;
|
|
72
|
+
/** The org's registered challenge for a native caller. */
|
|
73
|
+
nativeChallenge?: RegisteredNativeChallenge;
|
|
74
|
+
/** A native caller whose challenge could not be registered. */
|
|
75
|
+
hostUnavailable?: boolean;
|
|
76
|
+
}
|
|
77
|
+
/** The result of a call that needs a (new) grant, without `_meta`. */
|
|
78
|
+
export interface NeedsAuthorizationResult {
|
|
79
|
+
isError: true;
|
|
80
|
+
content: Array<{
|
|
81
|
+
type: "text";
|
|
82
|
+
text: string;
|
|
83
|
+
}>;
|
|
84
|
+
structuredContent: Record<string, unknown>;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The needs_authorization result without `_meta`, and the challenges the
|
|
88
|
+
* caller puts in `_meta["mcp/www_authenticate"]`. `structuredContent.context`
|
|
89
|
+
* mirrors that hint exactly, so a proof over the result covers it.
|
|
90
|
+
*/
|
|
91
|
+
export declare function buildNeedsAuthorizationResult(input: NeedsAuthorizationInput): {
|
|
92
|
+
result: NeedsAuthorizationResult;
|
|
93
|
+
wwwAuthenticate: string[];
|
|
94
|
+
};
|
|
95
|
+
/** The result of a refusal a new grant would not fix, without `_meta`. */
|
|
96
|
+
export declare function buildDeniedResult(content: CallToolResult["content"], reason: string): {
|
|
97
|
+
isError: true;
|
|
98
|
+
content: CallToolResult["content"];
|
|
99
|
+
structuredContent: {
|
|
100
|
+
error: "denied";
|
|
101
|
+
reason: string;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* The line shown for a stateful refusal: the operator's configured line for
|
|
106
|
+
* the code when there is one, else the product-neutral default. It carries no
|
|
107
|
+
* link, because a new grant would not change the answer.
|
|
108
|
+
*/
|
|
109
|
+
export declare function deniedText(denial: DelegationDenial, toolName: string, clientId: string | undefined, config: ClientMessagesConfig | undefined): string;
|
|
110
|
+
//# sourceMappingURL=authority-outcome.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authority-outcome.d.ts","sourceRoot":"","sources":["../src/authority-outcome.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgB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AAC,EAAE,gBAAgB,CAAC;IAC1B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,0DAA0D;IAC1D,eAAe,CAAC,EAAE,yBAAyB,CAAC;IAC5C,+DAA+D;IAC/D,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,sEAAsE;AACtE,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,IAAI,CAAC;IACd,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC5C;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,uBAAuB,GAAG;IAC7E,MAAM,EAAE,wBAAwB,CAAC;IACjC,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B,CAsCA;AAED,0EAA0E;AAC1E,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,EAClC,MAAM,EAAE,MAAM,GACb;IACD,OAAO,EAAE,IAAI,CAAC;IACd,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;IACnC,iBAAiB,EAAE;QAAE,KAAK,EAAE,QAAQ,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CACxD,CAMA;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,MAAM,EAAE,oBAAoB,GAAG,SAAS,GACvC,MAAM,CAQR"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authority outcomes of a tools/call, as tool results.
|
|
3
|
+
*
|
|
4
|
+
* For an MCP server every authority decision on a tool call is a signed tool
|
|
5
|
+
* result, never an HTTP status:
|
|
6
|
+
*
|
|
7
|
+
* - `needs_authorization`: a new grant could fix it (no grant, revoked,
|
|
8
|
+
* expired, wrong holder, insufficient scope, a delegation the verifier
|
|
9
|
+
* refused).
|
|
10
|
+
* - `denied`: a new grant would not fix it (a stateful policy refusal such as
|
|
11
|
+
* a spent call budget, or a request-admission refusal).
|
|
12
|
+
*
|
|
13
|
+
* This module builds the result shapes. It signs nothing and reads no
|
|
14
|
+
* environment: the caller supplies every input and attaches the proof.
|
|
15
|
+
*
|
|
16
|
+
* @module @kya-os/mcp-i-cloudflare/authority-outcome
|
|
17
|
+
*/
|
|
18
|
+
import { createNeedsAuthorizationError } from "@kya-os/mcp";
|
|
19
|
+
import { scopeTokens } from "./delegation-http/lazy-auth-gate";
|
|
20
|
+
/** `_meta` key that carries the OAuth challenge as a hint to MCP clients. */
|
|
21
|
+
export const WWW_AUTHENTICATE_META_KEY = "mcp/www_authenticate";
|
|
22
|
+
/**
|
|
23
|
+
* Denial codes that are a stateful policy refusal: a new grant would not fix
|
|
24
|
+
* them, so the call is `denied`. Every other verifier refusal is
|
|
25
|
+
* `needs_authorization`.
|
|
26
|
+
*/
|
|
27
|
+
const STATEFUL_DENIAL_CODES = new Set([
|
|
28
|
+
"budget_exceeded",
|
|
29
|
+
"policy_denied",
|
|
30
|
+
]);
|
|
31
|
+
/** Whether a verifier refusal is a stateful policy refusal (`denied`). */
|
|
32
|
+
export function isStatefulDenial(denial) {
|
|
33
|
+
return denial !== undefined && STATEFUL_DENIAL_CODES.has(denial.code);
|
|
34
|
+
}
|
|
35
|
+
/** Printable ASCII only, and none of the characters that end a quoted string. */
|
|
36
|
+
function quotedValue(text) {
|
|
37
|
+
return text.replace(/[^\x20\x21\x23-\x5B\x5D-\x7E]/g, "");
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The RFC 6750 / RFC 9728 challenge a tool result carries for an OAuth client.
|
|
41
|
+
*
|
|
42
|
+
* In a tool result the error is always `insufficient_scope`: that is the code
|
|
43
|
+
* hosts act on there, and the precise cause travels as the result's
|
|
44
|
+
* `reasonCode`. A transport 401 at the edge keeps RFC 6750's `invalid_token`
|
|
45
|
+
* for a presented token that is expired or invalid (lazy-auth-gate).
|
|
46
|
+
*/
|
|
47
|
+
export function bearerChallenge(input) {
|
|
48
|
+
const error = "insufficient_scope";
|
|
49
|
+
const resourceMetadata = input.routedHost
|
|
50
|
+
? `https://${input.routedHost}/.well-known/oauth-protected-resource`
|
|
51
|
+
: undefined;
|
|
52
|
+
const scope = scopeTokens(input.scopes).join(" ");
|
|
53
|
+
const params = [
|
|
54
|
+
...(resourceMetadata ? [`resource_metadata="${resourceMetadata}"`] : []),
|
|
55
|
+
`error="${error}"`,
|
|
56
|
+
`error_description="${quotedValue(input.description)}"`,
|
|
57
|
+
...(scope ? [`scope="${scope}"`] : []),
|
|
58
|
+
];
|
|
59
|
+
return {
|
|
60
|
+
header: `Bearer ${params.join(", ")}`,
|
|
61
|
+
error,
|
|
62
|
+
resourceMetadata,
|
|
63
|
+
scope,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The org's public connect page for the deployment's project:
|
|
68
|
+
* `<authorizationOrigin>/connect/<projectId>`. A person who opens it sees how
|
|
69
|
+
* to connect this server in their client; connecting runs the OAuth flow.
|
|
70
|
+
* Checkpoint serves it without sign-in.
|
|
71
|
+
*/
|
|
72
|
+
export function orgConnectUrl(binding) {
|
|
73
|
+
return `${binding.authorizationOrigin}/connect/${encodeURIComponent(binding.projectId)}`;
|
|
74
|
+
}
|
|
75
|
+
/** What a native caller's registered challenge adds to the result. */
|
|
76
|
+
function nativeFields(challenge) {
|
|
77
|
+
const { http } = challenge;
|
|
78
|
+
return {
|
|
79
|
+
sid: http.sid,
|
|
80
|
+
consent_uri: http.consent_uri,
|
|
81
|
+
pickup_uri: http.pickup_uri,
|
|
82
|
+
required_scopes: http.required_scopes,
|
|
83
|
+
...(http.min_assurance ? { min_assurance: http.min_assurance } : {}),
|
|
84
|
+
poll_interval_s: http.poll_interval_s,
|
|
85
|
+
resource: http.resource,
|
|
86
|
+
challenge_proof: challenge.challengeProof,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The needs_authorization result without `_meta`, and the challenges the
|
|
91
|
+
* caller puts in `_meta["mcp/www_authenticate"]`. `structuredContent.context`
|
|
92
|
+
* mirrors that hint exactly, so a proof over the result covers it.
|
|
93
|
+
*/
|
|
94
|
+
export function buildNeedsAuthorizationResult(input) {
|
|
95
|
+
const challenge = bearerChallenge({
|
|
96
|
+
routedHost: input.routedHost,
|
|
97
|
+
description: input.denial?.message ?? "Authorization is required",
|
|
98
|
+
scopes: scopeTokens(input.grantedScopes ?? [], input.scopes),
|
|
99
|
+
});
|
|
100
|
+
const wwwAuthenticate = [challenge.header];
|
|
101
|
+
const envelope = createNeedsAuthorizationError({
|
|
102
|
+
message: input.message,
|
|
103
|
+
authorizationUrl: input.authorizationUrl,
|
|
104
|
+
resumeToken: input.resumeToken,
|
|
105
|
+
expiresAt: input.expiresAt,
|
|
106
|
+
scopes: input.scopes,
|
|
107
|
+
});
|
|
108
|
+
return {
|
|
109
|
+
wwwAuthenticate,
|
|
110
|
+
result: {
|
|
111
|
+
isError: true,
|
|
112
|
+
content: [{ type: "text", text: input.message }],
|
|
113
|
+
structuredContent: {
|
|
114
|
+
...envelope,
|
|
115
|
+
...(input.denial ? { reasonCode: input.denial.code } : {}),
|
|
116
|
+
...(input.nativeChallenge
|
|
117
|
+
? { kyaos: nativeFields(input.nativeChallenge) }
|
|
118
|
+
: {}),
|
|
119
|
+
context: {
|
|
120
|
+
reason: input.hostUnavailable
|
|
121
|
+
? "authorization_host_unavailable"
|
|
122
|
+
: challenge.error,
|
|
123
|
+
...(challenge.resourceMetadata
|
|
124
|
+
? { resource_metadata: challenge.resourceMetadata }
|
|
125
|
+
: {}),
|
|
126
|
+
scope: challenge.scope,
|
|
127
|
+
www_authenticate: [...wwwAuthenticate],
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/** The result of a refusal a new grant would not fix, without `_meta`. */
|
|
134
|
+
export function buildDeniedResult(content, reason) {
|
|
135
|
+
return {
|
|
136
|
+
isError: true,
|
|
137
|
+
content,
|
|
138
|
+
structuredContent: { error: "denied", reason },
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* The line shown for a stateful refusal: the operator's configured line for
|
|
143
|
+
* the code when there is one, else the product-neutral default. It carries no
|
|
144
|
+
* link, because a new grant would not change the answer.
|
|
145
|
+
*/
|
|
146
|
+
export function deniedText(denial, toolName, clientId, config) {
|
|
147
|
+
const configured = (clientId
|
|
148
|
+
? config?.clients?.[clientId]?.denialMessages?.[denial.code]
|
|
149
|
+
: undefined) ?? config?.default?.denialMessages?.[denial.code];
|
|
150
|
+
return configured === undefined
|
|
151
|
+
? denial.message
|
|
152
|
+
: configured.split("{toolName}").join(toolName);
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=authority-outcome.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authority-outcome.js","sourceRoot":"","sources":["../src/authority-outcome.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAK5D,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAI/D,6EAA6E;AAC7E,MAAM,CAAC,MAAM,yBAAyB,GAAG,sBAAsB,CAAC;AAEhE;;;;GAIG;AACH,MAAM,qBAAqB,GAAwB,IAAI,GAAG,CAAC;IACzD,iBAAiB;IACjB,eAAe;CAChB,CAAC,CAAC;AAEH,0EAA0E;AAC1E,MAAM,UAAU,gBAAgB,CAC9B,MAAoC;IAEpC,OAAO,MAAM,KAAK,SAAS,IAAI,qBAAqB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC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AAU,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACpD,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -158,51 +158,6 @@ export interface CloudflareR2Binding {
|
|
|
158
158
|
*/
|
|
159
159
|
purpose: "proofs" | "logs" | "archives" | "general";
|
|
160
160
|
}
|
|
161
|
-
/**
|
|
162
|
-
* draft-kya-http-02 HTTP delegation challenge configuration.
|
|
163
|
-
*
|
|
164
|
-
* Flag-gated (default OFF). When enabled, the worker becomes its own Tier-2
|
|
165
|
-
* authorization host: it emits §8.1 401 delegation challenges and serves §8.2
|
|
166
|
-
* pickup. `anchorTtlS` is CLAMPED to <= 600 by `resolveHttpChallengeConfig` so the
|
|
167
|
-
* lazy-expiry garbage window stays bounded.
|
|
168
|
-
*/
|
|
169
|
-
export interface HttpChallengeConfig {
|
|
170
|
-
/** Explicit native HTTP issuer/status capabilities. Legacy MCP consent does not use this. */
|
|
171
|
-
native?: import("./delegation-http/native-http").NativeHttpHostConfig | null;
|
|
172
|
-
/** Master switch. Default false — the layer is flag-gated. */
|
|
173
|
-
enabled: boolean;
|
|
174
|
-
/**
|
|
175
|
-
* `"negotiated"` (default): 401 only for kya-capable callers. `"always"`: 401 on
|
|
176
|
-
* every authorization_required (the demo/conformance mode).
|
|
177
|
-
*/
|
|
178
|
-
mode?: "negotiated" | "always";
|
|
179
|
-
/** Challenge realm. Default: the request Host (resolved as "" — derive at emit time). */
|
|
180
|
-
realm?: string;
|
|
181
|
-
/** Pickup poll interval advertised to callers. Default 3. */
|
|
182
|
-
pollIntervalS?: number;
|
|
183
|
-
/** Anchor time-to-live in seconds. Default 600; CLAMPED to <= 600. */
|
|
184
|
-
anchorTtlS?: number;
|
|
185
|
-
/** Lifetime of the minted delegation. Default 900. */
|
|
186
|
-
delegationExpiresInS?: number;
|
|
187
|
-
/**
|
|
188
|
-
* Accept an unverified `keyid` (a `Signature-Input` `kya` label) as a pickup
|
|
189
|
-
* holder. Default false. A keyid is a PUBLIC string, so until inbound RFC 9421
|
|
190
|
-
* verification lands on the worker it must not act as a bearer secret; when off,
|
|
191
|
-
* a Signature-Input-only poll is treated as a no-identity poll (the token path is
|
|
192
|
-
* unaffected). INTERIM flag — remove once inbound 9421 verification exists.
|
|
193
|
-
*/
|
|
194
|
-
allowUnverifiedKeyidHolders?: boolean;
|
|
195
|
-
/**
|
|
196
|
-
* Serve `POST /api/v1/bouncer/sessions` so an external PEP (checkpoint's
|
|
197
|
-
* gateway, a .NET resource in the same project) can register a challenge
|
|
198
|
-
* anchor on this worker — the cross-resource authorization-host surface.
|
|
199
|
-
* Default true, but the route additionally requires `CHECKPOINT_API_KEY`
|
|
200
|
-
* to be configured (the bearer it authenticates registrars against), so an
|
|
201
|
-
* unprovisioned deployment still 404s. `MCPI_ANCHOR_REGISTRATION` env
|
|
202
|
-
* override ("false"/"0") is the ops-only kill switch.
|
|
203
|
-
*/
|
|
204
|
-
remoteAnchorRegistration?: boolean;
|
|
205
|
-
}
|
|
206
161
|
/**
|
|
207
162
|
* Cloudflare-specific runtime configuration
|
|
208
163
|
* Extends MCPIConfig with Cloudflare Workers platform concerns
|
|
@@ -213,6 +168,14 @@ export interface CloudflareRuntimeConfig extends MCPIConfig {
|
|
|
213
168
|
requestAdmission?: import("./security/mcp-admission").McpRequestAdmission;
|
|
214
169
|
/** Canonical KYA-OS audit trail configuration. */
|
|
215
170
|
auditTrail?: RuntimeAuditConfig;
|
|
171
|
+
/**
|
|
172
|
+
* Require a valid Bearer credential for this resource on every MCP request
|
|
173
|
+
* (ordinary MCP Authorization). Without one the edge answers 401 with the
|
|
174
|
+
* protected-resource metadata challenge. Applies to every caller. Per-tool
|
|
175
|
+
* decisions are unchanged. The `MCPI_REQUIRE_TOKEN_TO_CONNECT` env var
|
|
176
|
+
* ("true" or "1") also turns it on. Default: off.
|
|
177
|
+
*/
|
|
178
|
+
requireTokenToConnect?: boolean;
|
|
216
179
|
/**
|
|
217
180
|
* Bind limits to grants at consent time. Called server-side with the
|
|
218
181
|
* scopes on the consent screen and again with the approved scopes on
|
|
@@ -356,11 +319,6 @@ export interface CloudflareRuntimeConfig extends MCPIConfig {
|
|
|
356
319
|
apiKey?: string;
|
|
357
320
|
cacheTtl?: number;
|
|
358
321
|
};
|
|
359
|
-
/**
|
|
360
|
-
* draft-kya-http-02 HTTP delegation challenge layer (flag-gated, default OFF).
|
|
361
|
-
* Resolve with `resolveHttpChallengeConfig(config, env)`.
|
|
362
|
-
*/
|
|
363
|
-
httpChallenge?: HttpChallengeConfig;
|
|
364
322
|
};
|
|
365
323
|
}
|
|
366
324
|
/**
|
|
@@ -491,31 +449,4 @@ export declare function localToolProtectionConfig(toolProtection: ToolProtection
|
|
|
491
449
|
* @returns Complete CloudflareRuntimeConfig with defaults applied
|
|
492
450
|
*/
|
|
493
451
|
export declare function defineConfig(config: Partial<CloudflareRuntimeConfig>): CloudflareRuntimeConfig;
|
|
494
|
-
/**
|
|
495
|
-
* Resolve the draft-kya-http-02 challenge config, applying defaults and the
|
|
496
|
-
* `anchorTtlS <= 600` clamp.
|
|
497
|
-
*
|
|
498
|
-
* Precedence: the `MCPI_HTTP_CHALLENGE` env override (when set to a recognized
|
|
499
|
-
* value) wins over `config.delegation.httpChallenge.enabled`. The layer is ON by
|
|
500
|
-
* default — every deployed worker gates its own `/mcp` out of the box, with zero
|
|
501
|
-
* required configuration. `enabled: false` in config, or `MCPI_HTTP_CHALLENGE`
|
|
502
|
-
* set to `"false"`/`"0"`, is an ops-only escape hatch, not a customer-facing
|
|
503
|
-
* setting (see `contract.test.ts`'s "flag EXPLICITLY disabled" suite).
|
|
504
|
-
*
|
|
505
|
-
* The `mode: "negotiated"` default (also unchanged) is the actual safety property
|
|
506
|
-
* this default-on rests on: `maybeEmitDelegationChallenge` only ever acts on an
|
|
507
|
-
* already-`authorization_required` response, and even then only for callers that
|
|
508
|
-
* signal kya-capability — everything else, including every existing non-KYA-OS
|
|
509
|
-
* client, passes through completely untouched.
|
|
510
|
-
*
|
|
511
|
-
* `realm` (the branded consent host) is overridable via the `MCPI_REALM` env var:
|
|
512
|
-
* a non-empty, trimmed `env.MCPI_REALM` wins over `config.delegation.httpChallenge.realm`.
|
|
513
|
-
* When neither is set it defaults to `""` — the empty string is a sentinel meaning
|
|
514
|
-
* "derive from the request Host at challenge-emit time" (the request is not in scope here).
|
|
515
|
-
*
|
|
516
|
-
* @param config - The runtime config (may be undefined).
|
|
517
|
-
* @param env - The Cloudflare env bag; `env.MCPI_HTTP_CHALLENGE` is the override.
|
|
518
|
-
* @returns The fully-defaulted config when ON, or `null` when explicitly OFF.
|
|
519
|
-
*/
|
|
520
|
-
export declare function resolveHttpChallengeConfig(config: CloudflareRuntimeConfig | undefined, env: Record<string, unknown>): Required<HttpChallengeConfig> | null;
|
|
521
452
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,UAAU,EAIV,gBAAgB,EAChB,0BAA0B,EAC3B,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,UAAU,EAIV,gBAAgB,EAChB,0BAA0B,EAC3B,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE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AAgB,yBAAyB,CACvC,cAAc,EAAE,0BAA0B,GAExC;IAAE,eAAe,EAAE,WAAW,CAAC,0BAA0B,CAAC,QAAQ,CAAC,CAAC,CAAA;CAAE,GACtE,SAAS,CAMZ;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,OAAO,CAAC,uBAAuB,CAAC,GACvC,uBAAuB,CA0GzB"}
|
package/dist/config.js
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
* @module @kya-os/mcp-i-cloudflare/config
|
|
8
8
|
*/
|
|
9
9
|
import { buildBaseConfig, withCheckpointNames } from "@kya-os/contracts/config";
|
|
10
|
-
import { resolveManagedNativeIssuer } from "./delegation-http/remote-issuer";
|
|
11
10
|
/**
|
|
12
11
|
* Default Cloudflare runtime configuration
|
|
13
12
|
*/
|
|
@@ -230,86 +229,4 @@ export function defineConfig(config) {
|
|
|
230
229
|
: undefined),
|
|
231
230
|
};
|
|
232
231
|
}
|
|
233
|
-
/** Upper bound on anchor TTL (seconds). Bounds the lazy-expiry garbage window. */
|
|
234
|
-
const ANCHOR_TTL_MAX_S = 600;
|
|
235
|
-
/**
|
|
236
|
-
* Interpret the `MCPI_HTTP_CHALLENGE` env override.
|
|
237
|
-
* `"true"`/`"1"` → enable; `"false"`/`"0"` → force-disable; anything else → no override.
|
|
238
|
-
*/
|
|
239
|
-
function readHttpChallengeEnvFlag(value) {
|
|
240
|
-
if (value === undefined || value === null)
|
|
241
|
-
return undefined;
|
|
242
|
-
const normalized = String(value).trim().toLowerCase();
|
|
243
|
-
if (normalized === "true" || normalized === "1")
|
|
244
|
-
return true;
|
|
245
|
-
if (normalized === "false" || normalized === "0")
|
|
246
|
-
return false;
|
|
247
|
-
return undefined;
|
|
248
|
-
}
|
|
249
|
-
/** Return `fallback` unless `value` is a finite positive number. */
|
|
250
|
-
function positiveOrDefault(value, fallback) {
|
|
251
|
-
return typeof value === "number" && Number.isFinite(value) && value > 0
|
|
252
|
-
? value
|
|
253
|
-
: fallback;
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* Resolve the draft-kya-http-02 challenge config, applying defaults and the
|
|
257
|
-
* `anchorTtlS <= 600` clamp.
|
|
258
|
-
*
|
|
259
|
-
* Precedence: the `MCPI_HTTP_CHALLENGE` env override (when set to a recognized
|
|
260
|
-
* value) wins over `config.delegation.httpChallenge.enabled`. The layer is ON by
|
|
261
|
-
* default — every deployed worker gates its own `/mcp` out of the box, with zero
|
|
262
|
-
* required configuration. `enabled: false` in config, or `MCPI_HTTP_CHALLENGE`
|
|
263
|
-
* set to `"false"`/`"0"`, is an ops-only escape hatch, not a customer-facing
|
|
264
|
-
* setting (see `contract.test.ts`'s "flag EXPLICITLY disabled" suite).
|
|
265
|
-
*
|
|
266
|
-
* The `mode: "negotiated"` default (also unchanged) is the actual safety property
|
|
267
|
-
* this default-on rests on: `maybeEmitDelegationChallenge` only ever acts on an
|
|
268
|
-
* already-`authorization_required` response, and even then only for callers that
|
|
269
|
-
* signal kya-capability — everything else, including every existing non-KYA-OS
|
|
270
|
-
* client, passes through completely untouched.
|
|
271
|
-
*
|
|
272
|
-
* `realm` (the branded consent host) is overridable via the `MCPI_REALM` env var:
|
|
273
|
-
* a non-empty, trimmed `env.MCPI_REALM` wins over `config.delegation.httpChallenge.realm`.
|
|
274
|
-
* When neither is set it defaults to `""` — the empty string is a sentinel meaning
|
|
275
|
-
* "derive from the request Host at challenge-emit time" (the request is not in scope here).
|
|
276
|
-
*
|
|
277
|
-
* @param config - The runtime config (may be undefined).
|
|
278
|
-
* @param env - The Cloudflare env bag; `env.MCPI_HTTP_CHALLENGE` is the override.
|
|
279
|
-
* @returns The fully-defaulted config when ON, or `null` when explicitly OFF.
|
|
280
|
-
*/
|
|
281
|
-
export function resolveHttpChallengeConfig(config, env) {
|
|
282
|
-
const httpChallenge = config?.delegation?.httpChallenge;
|
|
283
|
-
const envFlag = readHttpChallengeEnvFlag(env?.MCPI_HTTP_CHALLENGE);
|
|
284
|
-
let enabled = httpChallenge?.enabled ?? true;
|
|
285
|
-
if (envFlag === true)
|
|
286
|
-
enabled = true;
|
|
287
|
-
if (envFlag === false)
|
|
288
|
-
enabled = false;
|
|
289
|
-
if (!enabled)
|
|
290
|
-
return null;
|
|
291
|
-
const anchorTtlS = Math.min(positiveOrDefault(httpChallenge?.anchorTtlS, ANCHOR_TTL_MAX_S), ANCHOR_TTL_MAX_S);
|
|
292
|
-
// `MCPI_ANCHOR_REGISTRATION` reuses the enable-flag grammar; a recognized env
|
|
293
|
-
// value wins over config, mirroring the master `MCPI_HTTP_CHALLENGE` override.
|
|
294
|
-
const anchorRegistrationEnvFlag = readHttpChallengeEnvFlag(env?.MCPI_ANCHOR_REGISTRATION);
|
|
295
|
-
let remoteAnchorRegistration = httpChallenge?.remoteAnchorRegistration ?? true;
|
|
296
|
-
if (anchorRegistrationEnvFlag !== undefined) {
|
|
297
|
-
remoteAnchorRegistration = anchorRegistrationEnvFlag;
|
|
298
|
-
}
|
|
299
|
-
// `MCPI_REALM` sets the branded consent host for the challenge; a non-empty,
|
|
300
|
-
// trimmed env value wins over config, mirroring the master overrides above.
|
|
301
|
-
const realmEnv = typeof env?.MCPI_REALM === "string" ? env.MCPI_REALM.trim() : "";
|
|
302
|
-
const realm = realmEnv || httpChallenge?.realm || "";
|
|
303
|
-
return {
|
|
304
|
-
enabled: true,
|
|
305
|
-
native: httpChallenge?.native ?? resolveManagedNativeIssuer(env),
|
|
306
|
-
mode: httpChallenge?.mode ?? "negotiated",
|
|
307
|
-
realm,
|
|
308
|
-
pollIntervalS: positiveOrDefault(httpChallenge?.pollIntervalS, 3),
|
|
309
|
-
anchorTtlS,
|
|
310
|
-
delegationExpiresInS: positiveOrDefault(httpChallenge?.delegationExpiresInS, 900),
|
|
311
|
-
allowUnverifiedKeyidHolders: httpChallenge?.allowUnverifiedKeyidHolders ?? false,
|
|
312
|
-
remoteAnchorRegistration,
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
232
|
//# sourceMappingURL=config.js.map
|