@kya-os/mcp-i-cloudflare 1.6.62 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.d.ts +4 -2
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +121 -94
- package/dist/agent.js.map +1 -1
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +9 -95
- package/dist/app.js.map +1 -1
- package/dist/services/consent-config.service.d.ts +9 -3
- package/dist/services/consent-config.service.d.ts.map +1 -1
- package/dist/services/consent-config.service.js +90 -100
- package/dist/services/consent-config.service.js.map +1 -1
- package/dist/services/consent-page-renderer.d.ts.map +1 -1
- package/dist/services/consent-page-renderer.js +0 -5
- package/dist/services/consent-page-renderer.js.map +1 -1
- package/dist/services/consent-templates/base/base-template.d.ts +79 -0
- package/dist/services/consent-templates/base/base-template.d.ts.map +1 -0
- package/dist/services/consent-templates/base/base-template.js +283 -0
- package/dist/services/consent-templates/base/base-template.js.map +1 -0
- package/dist/services/consent-templates/base/components.d.ts +120 -0
- package/dist/services/consent-templates/base/components.d.ts.map +1 -0
- package/dist/services/consent-templates/base/components.js +278 -0
- package/dist/services/consent-templates/base/components.js.map +1 -0
- package/dist/services/consent-templates/base/escape.d.ts +53 -0
- package/dist/services/consent-templates/base/escape.d.ts.map +1 -0
- package/dist/services/consent-templates/base/escape.js +115 -0
- package/dist/services/consent-templates/base/escape.js.map +1 -0
- package/dist/services/consent-templates/base/index.d.ts +10 -0
- package/dist/services/consent-templates/base/index.d.ts.map +1 -0
- package/dist/services/consent-templates/base/index.js +10 -0
- package/dist/services/consent-templates/base/index.js.map +1 -0
- package/dist/services/consent-templates/base/styles.d.ts +80 -0
- package/dist/services/consent-templates/base/styles.d.ts.map +1 -0
- package/dist/services/consent-templates/base/styles.js +226 -0
- package/dist/services/consent-templates/base/styles.js.map +1 -0
- package/dist/services/consent-templates/helpers.d.ts +60 -0
- package/dist/services/consent-templates/helpers.d.ts.map +1 -0
- package/dist/services/consent-templates/helpers.js +121 -0
- package/dist/services/consent-templates/helpers.js.map +1 -0
- package/dist/services/consent-templates/index.d.ts +28 -0
- package/dist/services/consent-templates/index.d.ts.map +1 -0
- package/dist/services/consent-templates/index.js +36 -0
- package/dist/services/consent-templates/index.js.map +1 -0
- package/dist/services/consent-templates/modes/consent-only.template.d.ts +36 -0
- package/dist/services/consent-templates/modes/consent-only.template.d.ts.map +1 -0
- package/dist/services/consent-templates/modes/consent-only.template.js +69 -0
- package/dist/services/consent-templates/modes/consent-only.template.js.map +1 -0
- package/dist/services/consent-templates/modes/credentials.template.d.ts +59 -0
- package/dist/services/consent-templates/modes/credentials.template.d.ts.map +1 -0
- package/dist/services/consent-templates/modes/credentials.template.js +393 -0
- package/dist/services/consent-templates/modes/credentials.template.js.map +1 -0
- package/dist/services/consent-templates/modes/index.d.ts +13 -0
- package/dist/services/consent-templates/modes/index.d.ts.map +1 -0
- package/dist/services/consent-templates/modes/index.js +13 -0
- package/dist/services/consent-templates/modes/index.js.map +1 -0
- package/dist/services/consent-templates/modes/magic-link.template.d.ts +33 -0
- package/dist/services/consent-templates/modes/magic-link.template.d.ts.map +1 -0
- package/dist/services/consent-templates/modes/magic-link.template.js +191 -0
- package/dist/services/consent-templates/modes/magic-link.template.js.map +1 -0
- package/dist/services/consent-templates/modes/oauth.template.d.ts +40 -0
- package/dist/services/consent-templates/modes/oauth.template.d.ts.map +1 -0
- package/dist/services/consent-templates/modes/oauth.template.js +151 -0
- package/dist/services/consent-templates/modes/oauth.template.js.map +1 -0
- package/dist/services/consent-templates/modes/otp.template.d.ts +35 -0
- package/dist/services/consent-templates/modes/otp.template.d.ts.map +1 -0
- package/dist/services/consent-templates/modes/otp.template.js +311 -0
- package/dist/services/consent-templates/modes/otp.template.js.map +1 -0
- package/dist/services/consent-templates/registry.d.ts +61 -0
- package/dist/services/consent-templates/registry.d.ts.map +1 -0
- package/dist/services/consent-templates/registry.js +136 -0
- package/dist/services/consent-templates/registry.js.map +1 -0
- package/dist/services/consent-templates/template-renderer.d.ts +118 -0
- package/dist/services/consent-templates/template-renderer.d.ts.map +1 -0
- package/dist/services/consent-templates/template-renderer.js +334 -0
- package/dist/services/consent-templates/template-renderer.js.map +1 -0
- package/dist/services/consent-templates/types.d.ts +194 -0
- package/dist/services/consent-templates/types.d.ts.map +1 -0
- package/dist/services/consent-templates/types.js +23 -0
- package/dist/services/consent-templates/types.js.map +1 -0
- package/dist/services/consent.service.d.ts +9 -0
- package/dist/services/consent.service.d.ts.map +1 -1
- package/dist/services/consent.service.js +50 -6
- package/dist/services/consent.service.js.map +1 -1
- package/package.json +4 -3
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Related Spec: MCP-I Phase 0 Implementation Plan, Task B.5
|
|
8
8
|
*/
|
|
9
9
|
import { ConsentConfigService } from "./consent-config.service";
|
|
10
|
-
import {
|
|
10
|
+
import { TemplateRenderer } from "./consent-templates/template-renderer";
|
|
11
11
|
import { DEFAULT_AGENTSHIELD_URL, DEFAULT_SESSION_CACHE_TTL, KEY_PAIR_TTL_SECONDS, CONSENT_PROVIDER_TYPES, } from "../constants";
|
|
12
12
|
import { STORAGE_KEYS } from "../constants/storage-keys";
|
|
13
13
|
import { loadDay0Config, getDelegationFieldName } from "../utils/day0-config";
|
|
@@ -22,6 +22,7 @@ import { ProofService } from "./proof.service";
|
|
|
22
22
|
import { createCredentialAuthHandler } from "./credential-auth.handler";
|
|
23
23
|
import { IdpTokenStorage } from "./idp-token-storage";
|
|
24
24
|
import { OAuthSecurityService } from "./oauth-security.service";
|
|
25
|
+
import { CONSENT_BUNDLE, CONSENT_BUNDLE_SIZE } from "@kya-os/consent";
|
|
25
26
|
export class ConsentService {
|
|
26
27
|
configService;
|
|
27
28
|
renderer;
|
|
@@ -42,7 +43,7 @@ export class ConsentService {
|
|
|
42
43
|
this.env = env;
|
|
43
44
|
this.runtime = runtime;
|
|
44
45
|
this.configService = new ConsentConfigService(env);
|
|
45
|
-
this.renderer = new
|
|
46
|
+
this.renderer = new TemplateRenderer({ useCSR: true });
|
|
46
47
|
this.providerResolver = providerResolver;
|
|
47
48
|
this.providerRegistry = providerRegistry;
|
|
48
49
|
// No initialization here - keep constructor synchronous
|
|
@@ -1231,6 +1232,10 @@ export class ConsentService {
|
|
|
1231
1232
|
*/
|
|
1232
1233
|
async handle(request) {
|
|
1233
1234
|
const url = new URL(request.url);
|
|
1235
|
+
// GET /consent.js - Serve consent bundle for CSR mode
|
|
1236
|
+
if (request.method === "GET" && url.pathname === "/consent.js") {
|
|
1237
|
+
return this.serveConsentBundle();
|
|
1238
|
+
}
|
|
1234
1239
|
// GET /consent - Render page
|
|
1235
1240
|
if (request.method === "GET" && url.pathname === "/consent") {
|
|
1236
1241
|
return this.renderConsentPage(url.searchParams, request);
|
|
@@ -1245,6 +1250,28 @@ export class ConsentService {
|
|
|
1245
1250
|
}
|
|
1246
1251
|
return new Response("Method not allowed", { status: 405 });
|
|
1247
1252
|
}
|
|
1253
|
+
/**
|
|
1254
|
+
* Serve the consent.js bundle for CSR mode
|
|
1255
|
+
*
|
|
1256
|
+
* Returns the bundled Lit Web Components as JavaScript that browsers
|
|
1257
|
+
* can execute to render the <mcp-consent> element.
|
|
1258
|
+
*
|
|
1259
|
+
* @returns JavaScript response with aggressive caching
|
|
1260
|
+
*/
|
|
1261
|
+
serveConsentBundle() {
|
|
1262
|
+
return new Response(CONSENT_BUNDLE, {
|
|
1263
|
+
status: 200,
|
|
1264
|
+
headers: {
|
|
1265
|
+
"Content-Type": "application/javascript; charset=utf-8",
|
|
1266
|
+
// Cache for 1 year (bundle is versioned via package version)
|
|
1267
|
+
"Cache-Control": "public, max-age=31536000, immutable",
|
|
1268
|
+
// Add content length for better client handling
|
|
1269
|
+
"Content-Length": CONSENT_BUNDLE_SIZE.toString(),
|
|
1270
|
+
// CORS headers for cross-origin script loading
|
|
1271
|
+
"Access-Control-Allow-Origin": "*",
|
|
1272
|
+
},
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1248
1275
|
/**
|
|
1249
1276
|
* Render consent page
|
|
1250
1277
|
*
|
|
@@ -1423,7 +1450,12 @@ export class ConsentService {
|
|
|
1423
1450
|
}
|
|
1424
1451
|
let resolvedOAuthUrl;
|
|
1425
1452
|
let isOAuthRequired = false;
|
|
1426
|
-
|
|
1453
|
+
// Skip OAuth flow for credentials provider - credentials uses form-based auth, not OAuth
|
|
1454
|
+
const isCredentialsProvider = provider?.toLowerCase() === "credentials";
|
|
1455
|
+
if (isCredentialsProvider && oauthRequired) {
|
|
1456
|
+
console.error("[ConsentService] Credentials provider detected - skipping OAuth flow, will render credential form", { provider, projectId, tool });
|
|
1457
|
+
}
|
|
1458
|
+
if (oauthRequired && !isCredentialsProvider) {
|
|
1427
1459
|
// OAuth is required - redirect to OAuth provider instead of showing consent page
|
|
1428
1460
|
// Note: oauthSecurityService is optional - if not provided, falls back to insecure encoding
|
|
1429
1461
|
const oauthSecurityService = this.env.DELEGATION_STORAGE
|
|
@@ -1470,6 +1502,7 @@ export class ConsentService {
|
|
|
1470
1502
|
});
|
|
1471
1503
|
}
|
|
1472
1504
|
// Build consent page config
|
|
1505
|
+
// ✅ CRITICAL: Pass the FULL consent config (ui, credentials, etc.) not just branding/terms
|
|
1473
1506
|
// Type assertion to handle updated schema before rebuild
|
|
1474
1507
|
const pageConfig = {
|
|
1475
1508
|
tool,
|
|
@@ -1481,9 +1514,19 @@ export class ConsentService {
|
|
|
1481
1514
|
serverUrl,
|
|
1482
1515
|
provider, // Phase 2: Include provider if resolved
|
|
1483
1516
|
branding: consentConfig.branding,
|
|
1484
|
-
terms
|
|
1517
|
+
// ✅ Ensure terms.required has a default value (contracts requires boolean, not boolean | undefined)
|
|
1518
|
+
terms: consentConfig.terms ? {
|
|
1519
|
+
...consentConfig.terms,
|
|
1520
|
+
required: consentConfig.terms.required ?? true,
|
|
1521
|
+
} : undefined,
|
|
1485
1522
|
customFields: consentConfig.customFields,
|
|
1486
|
-
autoClose: consentConfig.ui?.autoClose,
|
|
1523
|
+
autoClose: consentConfig.ui?.autoClose ?? false,
|
|
1524
|
+
// ✅ FIX: Pass full UI config (title, description, button text, etc.)
|
|
1525
|
+
ui: consentConfig.ui,
|
|
1526
|
+
// ✅ FIX: Pass credentials config (username/password labels, forgot password, etc.)
|
|
1527
|
+
credentials: consentConfig.credentials,
|
|
1528
|
+
// ✅ FIX: Pass expiration days
|
|
1529
|
+
expirationDays: consentConfig.expirationDays,
|
|
1487
1530
|
// Pass OAuth details for client-side handling
|
|
1488
1531
|
oauthRequired: isOAuthRequired,
|
|
1489
1532
|
oauthUrl: resolvedOAuthUrl,
|
|
@@ -3362,10 +3405,11 @@ export class ConsentService {
|
|
|
3362
3405
|
agent_did: agent_did,
|
|
3363
3406
|
session_id: session_id,
|
|
3364
3407
|
project_id: project_id,
|
|
3408
|
+
auth_mode: "credentials",
|
|
3409
|
+
provider_type: CONSENT_PROVIDER_TYPES.CREDENTIAL,
|
|
3365
3410
|
termsAccepted: true,
|
|
3366
3411
|
user_did: identityResult.userDid,
|
|
3367
3412
|
customFields: {
|
|
3368
|
-
provider_type: CONSENT_PROVIDER_TYPES.CREDENTIAL,
|
|
3369
3413
|
provider: provider,
|
|
3370
3414
|
},
|
|
3371
3415
|
};
|