@kya-os/mcp-i-core 1.4.17 → 1.4.19

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.
@@ -79,6 +79,19 @@ export declare class MCPIRuntimeBase {
79
79
  * Get session by ID
80
80
  */
81
81
  getSession(sessionId: string): any | undefined;
82
+ /**
83
+ * Extract the correct provider for consent URL from tool protection config
84
+ *
85
+ * For password auth tools, the provider is in authorization.provider.
86
+ * For OAuth auth tools, the provider is in oauthProvider (legacy) or authorization.provider.
87
+ *
88
+ * Note: Not all authorization types have a provider field (e.g., 'none', 'mdl', 'webauthn').
89
+ * Only 'oauth', 'oauth2', 'password', and 'idv' types have provider.
90
+ *
91
+ * @param protection - Tool protection configuration
92
+ * @returns Provider name to use in consent URL, or undefined
93
+ */
94
+ private getConsentProvider;
82
95
  /**
83
96
  * Process tool call with automatic proof generation
84
97
  * Returns clean result only - proof is stored for out-of-band retrieval
@@ -233,6 +233,38 @@ class MCPIRuntimeBase {
233
233
  getSession(sessionId) {
234
234
  return this.sessions.get(sessionId);
235
235
  }
236
+ /**
237
+ * Extract the correct provider for consent URL from tool protection config
238
+ *
239
+ * For password auth tools, the provider is in authorization.provider.
240
+ * For OAuth auth tools, the provider is in oauthProvider (legacy) or authorization.provider.
241
+ *
242
+ * Note: Not all authorization types have a provider field (e.g., 'none', 'mdl', 'webauthn').
243
+ * Only 'oauth', 'oauth2', 'password', and 'idv' types have provider.
244
+ *
245
+ * @param protection - Tool protection configuration
246
+ * @returns Provider name to use in consent URL, or undefined
247
+ */
248
+ getConsentProvider(protection) {
249
+ // Check authorization field - only some types have provider
250
+ if (protection.authorization) {
251
+ const auth = protection.authorization;
252
+ // Types with provider: oauth, oauth2, password, idv
253
+ if (auth.type === "oauth" ||
254
+ auth.type === "oauth2" ||
255
+ auth.type === "password" ||
256
+ auth.type === "idv") {
257
+ // Return auth.provider if set, otherwise fall through to legacy oauthProvider
258
+ if (auth.provider) {
259
+ return auth.provider;
260
+ }
261
+ }
262
+ // Other types don't have provider (none, mdl, verifiable_credential, webauthn, siwe)
263
+ // Fall through to legacy oauthProvider
264
+ }
265
+ // Fall back to legacy oauthProvider (deprecated)
266
+ return protection.oauthProvider;
267
+ }
236
268
  /**
237
269
  * Process tool call with automatic proof generation
238
270
  * Returns clean result only - proof is stored for out-of-band retrieval
@@ -274,7 +306,7 @@ class MCPIRuntimeBase {
274
306
  // Note: projectId is not available in base class - subclasses should override buildConsentUrl
275
307
  // Pass oauthProvider to ensure correct auth method is selected (e.g., "credentials" vs "github")
276
308
  const consentUrl = this.buildConsentUrl(toolName, protection.requiredScopes, session, resumeToken, undefined, // projectId - handled by subclass override
277
- protection.oauthProvider // Provider from tool config
309
+ this.getConsentProvider(protection) // Provider from tool config (supports both password and oauth auth)
278
310
  );
279
311
  // Create error with intercepted call context and pre-generated resume token
280
312
  const error = new tool_protection_js_1.DelegationRequiredError(toolName, protection.requiredScopes, consentUrl, interceptedCall, resumeToken);
@@ -384,7 +416,7 @@ class MCPIRuntimeBase {
384
416
  };
385
417
  const resumeToken = this.generateResumeToken(interceptedCall);
386
418
  const consentUrl = this.buildConsentUrl(toolName, protection.requiredScopes, session, resumeToken, undefined, // projectId - handled by subclass override
387
- protection.oauthProvider // Provider from tool config
419
+ this.getConsentProvider(protection) // Provider from tool config (supports both password and oauth auth)
388
420
  );
389
421
  this.interceptedCalls.set(resumeToken, interceptedCall);
390
422
  this.cleanupExpiredInterceptedCalls();
@@ -434,7 +466,7 @@ class MCPIRuntimeBase {
434
466
  };
435
467
  const resumeToken = this.generateResumeToken(interceptedCall);
436
468
  const consentUrl = this.buildConsentUrl(toolName, protection.requiredScopes, session, resumeToken, undefined, // projectId - handled by subclass override
437
- protection.oauthProvider // Provider from tool config
469
+ this.getConsentProvider(protection) // Provider from tool config (supports both password and oauth auth)
438
470
  );
439
471
  this.interceptedCalls.set(resumeToken, interceptedCall);
440
472
  this.cleanupExpiredInterceptedCalls();
@@ -497,7 +529,7 @@ class MCPIRuntimeBase {
497
529
  expiresAt: this.clock.calculateExpiry(1800),
498
530
  };
499
531
  const resumeToken = this.generateResumeToken(interceptedCall);
500
- const consentUrl = this.buildConsentUrl(toolName, protection.requiredScopes, session, resumeToken, undefined, protection.oauthProvider);
532
+ const consentUrl = this.buildConsentUrl(toolName, protection.requiredScopes, session, resumeToken, undefined, this.getConsentProvider(protection));
501
533
  this.interceptedCalls.set(resumeToken, interceptedCall);
502
534
  this.cleanupExpiredInterceptedCalls();
503
535
  throw new tool_protection_js_1.DelegationRequiredError(toolName, protection.requiredScopes, consentUrl, interceptedCall, resumeToken);
@@ -523,7 +555,7 @@ class MCPIRuntimeBase {
523
555
  expiresAt: this.clock.calculateExpiry(1800),
524
556
  };
525
557
  const resumeToken = this.generateResumeToken(interceptedCall);
526
- const consentUrl = this.buildConsentUrl(toolName, protection.requiredScopes, session, resumeToken, undefined, protection.oauthProvider);
558
+ const consentUrl = this.buildConsentUrl(toolName, protection.requiredScopes, session, resumeToken, undefined, this.getConsentProvider(protection));
527
559
  this.interceptedCalls.set(resumeToken, interceptedCall);
528
560
  this.cleanupExpiredInterceptedCalls();
529
561
  throw new tool_protection_js_1.DelegationRequiredError(toolName, protection.requiredScopes, consentUrl, interceptedCall, resumeToken);
@@ -578,7 +610,7 @@ class MCPIRuntimeBase {
578
610
  };
579
611
  const resumeToken = this.generateResumeToken(interceptedCall);
580
612
  const consentUrl = this.buildConsentUrl(toolName, protection.requiredScopes, session, resumeToken, undefined, // projectId - handled by subclass override
581
- protection.oauthProvider // Provider from tool config
613
+ this.getConsentProvider(protection) // Provider from tool config (supports both password and oauth auth)
582
614
  );
583
615
  this.interceptedCalls.set(resumeToken, interceptedCall);
584
616
  this.cleanupExpiredInterceptedCalls();
@@ -603,7 +635,7 @@ class MCPIRuntimeBase {
603
635
  };
604
636
  const resumeToken = this.generateResumeToken(interceptedCall);
605
637
  const consentUrl = this.buildConsentUrl(toolName, protection.requiredScopes, session, resumeToken, undefined, // projectId - handled by subclass override
606
- protection.oauthProvider // Provider from tool config
638
+ this.getConsentProvider(protection) // Provider from tool config (supports both password and oauth auth)
607
639
  );
608
640
  this.interceptedCalls.set(resumeToken, interceptedCall);
609
641
  this.cleanupExpiredInterceptedCalls();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kya-os/mcp-i-core",
3
- "version": "1.4.17",
3
+ "version": "1.4.19",
4
4
  "description": "Core runtime and types for MCP-I framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "prepublishOnly": "npm run build && node ../create-mcpi-app/scripts/validate-no-workspace.js"
29
29
  },
30
30
  "dependencies": {
31
- "@kya-os/contracts": "^1.7.20",
31
+ "@kya-os/contracts": "^1.7.21",
32
32
  "jose": "^5.6.3",
33
33
  "json-canonicalize": "^2.0.0",
34
34
  "zod": "^3.25.76"
@@ -36,7 +36,7 @@
36
36
  "devDependencies": {
37
37
  "@types/node": "^20.14.9",
38
38
  "@vitest/coverage-v8": "^4.0.5",
39
- "eslint": "^8.57.0",
39
+ "eslint": "^9.26.0",
40
40
  "typescript": "^5.5.3",
41
41
  "vitest": "^4.0.5"
42
42
  },