@kya-os/mcp-i-cloudflare 1.6.62 → 1.7.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.
Files changed (83) hide show
  1. package/dist/agent.d.ts +4 -2
  2. package/dist/agent.d.ts.map +1 -1
  3. package/dist/agent.js +121 -94
  4. package/dist/agent.js.map +1 -1
  5. package/dist/app.d.ts.map +1 -1
  6. package/dist/app.js +9 -95
  7. package/dist/app.js.map +1 -1
  8. package/dist/services/consent-config.service.d.ts +9 -3
  9. package/dist/services/consent-config.service.d.ts.map +1 -1
  10. package/dist/services/consent-config.service.js +90 -100
  11. package/dist/services/consent-config.service.js.map +1 -1
  12. package/dist/services/consent-page-renderer.d.ts.map +1 -1
  13. package/dist/services/consent-page-renderer.js +0 -5
  14. package/dist/services/consent-page-renderer.js.map +1 -1
  15. package/dist/services/consent-templates/base/base-template.d.ts +79 -0
  16. package/dist/services/consent-templates/base/base-template.d.ts.map +1 -0
  17. package/dist/services/consent-templates/base/base-template.js +283 -0
  18. package/dist/services/consent-templates/base/base-template.js.map +1 -0
  19. package/dist/services/consent-templates/base/components.d.ts +120 -0
  20. package/dist/services/consent-templates/base/components.d.ts.map +1 -0
  21. package/dist/services/consent-templates/base/components.js +278 -0
  22. package/dist/services/consent-templates/base/components.js.map +1 -0
  23. package/dist/services/consent-templates/base/escape.d.ts +53 -0
  24. package/dist/services/consent-templates/base/escape.d.ts.map +1 -0
  25. package/dist/services/consent-templates/base/escape.js +115 -0
  26. package/dist/services/consent-templates/base/escape.js.map +1 -0
  27. package/dist/services/consent-templates/base/index.d.ts +10 -0
  28. package/dist/services/consent-templates/base/index.d.ts.map +1 -0
  29. package/dist/services/consent-templates/base/index.js +10 -0
  30. package/dist/services/consent-templates/base/index.js.map +1 -0
  31. package/dist/services/consent-templates/base/styles.d.ts +80 -0
  32. package/dist/services/consent-templates/base/styles.d.ts.map +1 -0
  33. package/dist/services/consent-templates/base/styles.js +226 -0
  34. package/dist/services/consent-templates/base/styles.js.map +1 -0
  35. package/dist/services/consent-templates/helpers.d.ts +60 -0
  36. package/dist/services/consent-templates/helpers.d.ts.map +1 -0
  37. package/dist/services/consent-templates/helpers.js +121 -0
  38. package/dist/services/consent-templates/helpers.js.map +1 -0
  39. package/dist/services/consent-templates/index.d.ts +28 -0
  40. package/dist/services/consent-templates/index.d.ts.map +1 -0
  41. package/dist/services/consent-templates/index.js +36 -0
  42. package/dist/services/consent-templates/index.js.map +1 -0
  43. package/dist/services/consent-templates/modes/consent-only.template.d.ts +36 -0
  44. package/dist/services/consent-templates/modes/consent-only.template.d.ts.map +1 -0
  45. package/dist/services/consent-templates/modes/consent-only.template.js +69 -0
  46. package/dist/services/consent-templates/modes/consent-only.template.js.map +1 -0
  47. package/dist/services/consent-templates/modes/credentials.template.d.ts +59 -0
  48. package/dist/services/consent-templates/modes/credentials.template.d.ts.map +1 -0
  49. package/dist/services/consent-templates/modes/credentials.template.js +393 -0
  50. package/dist/services/consent-templates/modes/credentials.template.js.map +1 -0
  51. package/dist/services/consent-templates/modes/index.d.ts +13 -0
  52. package/dist/services/consent-templates/modes/index.d.ts.map +1 -0
  53. package/dist/services/consent-templates/modes/index.js +13 -0
  54. package/dist/services/consent-templates/modes/index.js.map +1 -0
  55. package/dist/services/consent-templates/modes/magic-link.template.d.ts +33 -0
  56. package/dist/services/consent-templates/modes/magic-link.template.d.ts.map +1 -0
  57. package/dist/services/consent-templates/modes/magic-link.template.js +191 -0
  58. package/dist/services/consent-templates/modes/magic-link.template.js.map +1 -0
  59. package/dist/services/consent-templates/modes/oauth.template.d.ts +40 -0
  60. package/dist/services/consent-templates/modes/oauth.template.d.ts.map +1 -0
  61. package/dist/services/consent-templates/modes/oauth.template.js +151 -0
  62. package/dist/services/consent-templates/modes/oauth.template.js.map +1 -0
  63. package/dist/services/consent-templates/modes/otp.template.d.ts +35 -0
  64. package/dist/services/consent-templates/modes/otp.template.d.ts.map +1 -0
  65. package/dist/services/consent-templates/modes/otp.template.js +311 -0
  66. package/dist/services/consent-templates/modes/otp.template.js.map +1 -0
  67. package/dist/services/consent-templates/registry.d.ts +61 -0
  68. package/dist/services/consent-templates/registry.d.ts.map +1 -0
  69. package/dist/services/consent-templates/registry.js +136 -0
  70. package/dist/services/consent-templates/registry.js.map +1 -0
  71. package/dist/services/consent-templates/template-renderer.d.ts +118 -0
  72. package/dist/services/consent-templates/template-renderer.d.ts.map +1 -0
  73. package/dist/services/consent-templates/template-renderer.js +334 -0
  74. package/dist/services/consent-templates/template-renderer.js.map +1 -0
  75. package/dist/services/consent-templates/types.d.ts +194 -0
  76. package/dist/services/consent-templates/types.d.ts.map +1 -0
  77. package/dist/services/consent-templates/types.js +23 -0
  78. package/dist/services/consent-templates/types.js.map +1 -0
  79. package/dist/services/consent.service.d.ts +9 -0
  80. package/dist/services/consent.service.d.ts.map +1 -1
  81. package/dist/services/consent.service.js +50 -6
  82. package/dist/services/consent.service.js.map +1 -1
  83. 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 { ConsentPageRenderer } from "./consent-page-renderer";
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 ConsentPageRenderer();
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
- if (oauthRequired) {
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: consentConfig.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
  };