@kya-os/mcp-i-core 1.8.0 → 1.8.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.
Files changed (111) hide show
  1. package/dist/conformance/capability-verifier-adapter.d.ts +66 -0
  2. package/dist/conformance/capability-verifier-adapter.js +61 -0
  3. package/dist/conformance/index.d.ts +3 -1
  4. package/dist/conformance/index.js +7 -1
  5. package/dist/conformance/validate-level2.d.ts +13 -3
  6. package/dist/conformance/validate-level2.js +15 -5
  7. package/dist/conformance/vc-jwt-verifier.d.ts +55 -0
  8. package/dist/conformance/vc-jwt-verifier.js +147 -0
  9. package/dist/delegation/did-web-resolver.d.ts +60 -0
  10. package/dist/delegation/did-web-resolver.js +129 -0
  11. package/dist/index.d.ts +2 -1
  12. package/dist/index.js +9 -1
  13. package/package.json +3 -3
  14. package/dist/auth/handshake.d.ts +0 -119
  15. package/dist/auth/handshake.js +0 -250
  16. package/dist/auth/index.d.ts +0 -6
  17. package/dist/auth/index.js +0 -11
  18. package/dist/auth/types.d.ts +0 -46
  19. package/dist/auth/types.js +0 -10
  20. package/dist/cache/oauth-config-cache.d.ts +0 -69
  21. package/dist/cache/oauth-config-cache.js +0 -76
  22. package/dist/cache/tool-protection-cache.d.ts +0 -89
  23. package/dist/cache/tool-protection-cache.js +0 -118
  24. package/dist/compliance/index.d.ts +0 -8
  25. package/dist/compliance/index.js +0 -24
  26. package/dist/compliance/schema-registry.d.ts +0 -50
  27. package/dist/compliance/schema-registry.js +0 -438
  28. package/dist/compliance/schema-verifier.d.ts +0 -110
  29. package/dist/compliance/schema-verifier.js +0 -518
  30. package/dist/config/remote-config.d.ts +0 -173
  31. package/dist/config/remote-config.js +0 -253
  32. package/dist/config.d.ts +0 -182
  33. package/dist/config.js +0 -148
  34. package/dist/identity/idp-token-resolver.d.ts +0 -69
  35. package/dist/identity/idp-token-resolver.js +0 -136
  36. package/dist/identity/idp-token-storage.interface.d.ts +0 -80
  37. package/dist/identity/idp-token-storage.interface.js +0 -14
  38. package/dist/identity/user-did-manager.d.ts +0 -228
  39. package/dist/identity/user-did-manager.js +0 -356
  40. package/dist/logging/index.d.ts +0 -5
  41. package/dist/logging/index.js +0 -10
  42. package/dist/logging/logger.d.ts +0 -33
  43. package/dist/logging/logger.js +0 -104
  44. package/dist/proof/generator.d.ts +0 -109
  45. package/dist/proof/generator.js +0 -236
  46. package/dist/proof/index.d.ts +0 -5
  47. package/dist/proof/index.js +0 -11
  48. package/dist/providers/base.d.ts +0 -95
  49. package/dist/providers/base.js +0 -47
  50. package/dist/providers/memory.d.ts +0 -42
  51. package/dist/providers/memory.js +0 -121
  52. package/dist/runtime/audit-logger.d.ts +0 -37
  53. package/dist/runtime/audit-logger.js +0 -9
  54. package/dist/runtime/base.d.ts +0 -375
  55. package/dist/runtime/base.js +0 -1491
  56. package/dist/runtime/ext-apps-constants.d.ts +0 -14
  57. package/dist/runtime/ext-apps-constants.js +0 -17
  58. package/dist/services/access-control.service.d.ts +0 -138
  59. package/dist/services/access-control.service.js +0 -721
  60. package/dist/services/authorization/authorization-registry.d.ts +0 -29
  61. package/dist/services/authorization/authorization-registry.js +0 -58
  62. package/dist/services/authorization/types.d.ts +0 -53
  63. package/dist/services/authorization/types.js +0 -10
  64. package/dist/services/batch-delegation.service.d.ts +0 -53
  65. package/dist/services/batch-delegation.service.js +0 -95
  66. package/dist/services/crypto.service.d.ts +0 -69
  67. package/dist/services/crypto.service.js +0 -225
  68. package/dist/services/delegation-error-formatter.d.ts +0 -124
  69. package/dist/services/delegation-error-formatter.js +0 -214
  70. package/dist/services/errors.d.ts +0 -49
  71. package/dist/services/errors.js +0 -66
  72. package/dist/services/index.d.ts +0 -9
  73. package/dist/services/index.js +0 -15
  74. package/dist/services/oauth-config.service.d.ts +0 -53
  75. package/dist/services/oauth-config.service.js +0 -141
  76. package/dist/services/oauth-provider-registry.d.ts +0 -88
  77. package/dist/services/oauth-provider-registry.js +0 -128
  78. package/dist/services/oauth-service.d.ts +0 -122
  79. package/dist/services/oauth-service.js +0 -442
  80. package/dist/services/oauth-token-retrieval.service.d.ts +0 -49
  81. package/dist/services/oauth-token-retrieval.service.js +0 -150
  82. package/dist/services/policy.service.d.ts +0 -130
  83. package/dist/services/policy.service.js +0 -399
  84. package/dist/services/proof-verifier.d.ts +0 -98
  85. package/dist/services/proof-verifier.js +0 -319
  86. package/dist/services/provider-resolver.d.ts +0 -89
  87. package/dist/services/provider-resolver.js +0 -196
  88. package/dist/services/provider-validator.d.ts +0 -55
  89. package/dist/services/provider-validator.js +0 -135
  90. package/dist/services/session-registration.service.d.ts +0 -80
  91. package/dist/services/session-registration.service.js +0 -174
  92. package/dist/services/storage.service.d.ts +0 -116
  93. package/dist/services/storage.service.js +0 -411
  94. package/dist/services/tool-context-builder.d.ts +0 -74
  95. package/dist/services/tool-context-builder.js +0 -215
  96. package/dist/services/tool-protection.service.d.ts +0 -193
  97. package/dist/services/tool-protection.service.js +0 -736
  98. package/dist/session/index.d.ts +0 -5
  99. package/dist/session/index.js +0 -11
  100. package/dist/session/manager.d.ts +0 -113
  101. package/dist/session/manager.js +0 -273
  102. package/dist/types/oauth-required-error.d.ts +0 -46
  103. package/dist/types/oauth-required-error.js +0 -42
  104. package/dist/types/tool-protection.d.ts +0 -144
  105. package/dist/types/tool-protection.js +0 -48
  106. package/dist/utils/cors.d.ts +0 -44
  107. package/dist/utils/cors.js +0 -71
  108. package/dist/utils/index.d.ts +0 -8
  109. package/dist/utils/index.js +0 -24
  110. package/dist/utils/storage-keys.d.ts +0 -120
  111. package/dist/utils/storage-keys.js +0 -217
@@ -1,5 +0,0 @@
1
- /**
2
- * Session module — platform-agnostic session management reference implementation.
3
- */
4
- export { SessionManager, createHandshakeRequest, validateHandshakeFormat, type SessionConfig, type HandshakeResult, } from "./manager";
5
- //# sourceMappingURL=index.d.ts.map
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateHandshakeFormat = exports.createHandshakeRequest = exports.SessionManager = void 0;
4
- /**
5
- * Session module — platform-agnostic session management reference implementation.
6
- */
7
- var manager_1 = require("./manager");
8
- Object.defineProperty(exports, "SessionManager", { enumerable: true, get: function () { return manager_1.SessionManager; } });
9
- Object.defineProperty(exports, "createHandshakeRequest", { enumerable: true, get: function () { return manager_1.createHandshakeRequest; } });
10
- Object.defineProperty(exports, "validateHandshakeFormat", { enumerable: true, get: function () { return manager_1.validateHandshakeFormat; } });
11
- //# sourceMappingURL=index.js.map
@@ -1,113 +0,0 @@
1
- /**
2
- * Session Management — Platform-agnostic Protocol Reference
3
- *
4
- * Handles handshake enforcement, session management, and nonce validation
5
- * according to MCP-I requirements 4.5–4.9 and 19.1–19.2.
6
- *
7
- * Platform adapters inject a CryptoProvider for all random byte generation.
8
- * The static generateNonce() uses globalThis.crypto (available Node 20+ and
9
- * Cloudflare Workers) to remain synchronous without platform-specific imports.
10
- */
11
- import { HandshakeRequest, SessionContext, NonceCache } from "@kya-os/contracts/handshake";
12
- import { CryptoProvider } from "../providers/base";
13
- /**
14
- * Session management configuration
15
- */
16
- export interface SessionConfig {
17
- /** Clock-skew tolerance in seconds. Default: 120. */
18
- timestampSkewSeconds?: number;
19
- /** Idle session TTL in minutes. Default: 30. */
20
- sessionTtlMinutes?: number;
21
- /** Optional absolute session lifetime in minutes. */
22
- absoluteSessionLifetime?: number;
23
- /** Nonce cache implementation. Default: MemoryNonceCacheProvider. */
24
- nonceCache?: NonceCache;
25
- /** Optional server DID to include in session context. */
26
- serverDid?: string;
27
- }
28
- /**
29
- * Handshake validation result
30
- */
31
- export interface HandshakeResult {
32
- success: boolean;
33
- session?: SessionContext;
34
- error?: {
35
- code: string;
36
- message: string;
37
- remediation?: string;
38
- };
39
- }
40
- /**
41
- * Platform-agnostic session manager.
42
- * Requires a CryptoProvider for session ID and client ID generation.
43
- */
44
- export declare class SessionManager {
45
- private config;
46
- private cryptoProvider;
47
- private sessions;
48
- constructor(cryptoProvider: CryptoProvider, config?: SessionConfig);
49
- /**
50
- * Set server DID for session creation (called after identity is loaded).
51
- */
52
- setServerDid(serverDid: string): void;
53
- /**
54
- * Validate handshake and create or retrieve session.
55
- * Requirements: 4.5, 4.6, 4.7, 4.8, 4.9
56
- */
57
- validateHandshake(request: HandshakeRequest): Promise<HandshakeResult>;
58
- /**
59
- * Get session by ID and update last activity.
60
- */
61
- getSession(sessionId: string): Promise<SessionContext | null>;
62
- /**
63
- * Generate a unique session ID (mcpi_{uuid} format).
64
- * Uses injected CryptoProvider for platform-agnostic random bytes.
65
- */
66
- private generateSessionId;
67
- /**
68
- * Generate a deterministic client identifier.
69
- */
70
- private generateClientId;
71
- /**
72
- * Normalize string fields from handshake metadata.
73
- */
74
- private normalizeClientInfoString;
75
- /**
76
- * Build MCP client metadata for the session.
77
- */
78
- private buildClientInfo;
79
- /**
80
- * Generate a cryptographically secure nonce.
81
- * Uses globalThis.crypto (sync Web Crypto — available in Node 20+ and Workers).
82
- */
83
- static generateNonce(): string;
84
- /**
85
- * Cleanup expired sessions and nonces.
86
- */
87
- cleanup(): Promise<void>;
88
- /**
89
- * Get session statistics.
90
- */
91
- getStats(): {
92
- activeSessions: number;
93
- config: {
94
- timestampSkewSeconds: number;
95
- sessionTtlMinutes: number;
96
- absoluteSessionLifetime?: number;
97
- cacheType: string;
98
- };
99
- };
100
- /**
101
- * Clear all sessions (useful for testing).
102
- */
103
- clearSessions(): void;
104
- }
105
- /**
106
- * Create a handshake request with a secure nonce.
107
- */
108
- export declare function createHandshakeRequest(audience: string): HandshakeRequest;
109
- /**
110
- * Validate handshake request format.
111
- */
112
- export declare function validateHandshakeFormat(request: unknown): request is HandshakeRequest;
113
- //# sourceMappingURL=manager.d.ts.map
@@ -1,273 +0,0 @@
1
- "use strict";
2
- /**
3
- * Session Management — Platform-agnostic Protocol Reference
4
- *
5
- * Handles handshake enforcement, session management, and nonce validation
6
- * according to MCP-I requirements 4.5–4.9 and 19.1–19.2.
7
- *
8
- * Platform adapters inject a CryptoProvider for all random byte generation.
9
- * The static generateNonce() uses globalThis.crypto (available Node 20+ and
10
- * Cloudflare Workers) to remain synchronous without platform-specific imports.
11
- */
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.SessionManager = void 0;
14
- exports.createHandshakeRequest = createHandshakeRequest;
15
- exports.validateHandshakeFormat = validateHandshakeFormat;
16
- const memory_1 = require("../providers/memory");
17
- const logging_1 = require("../logging");
18
- /**
19
- * Platform-agnostic session manager.
20
- * Requires a CryptoProvider for session ID and client ID generation.
21
- */
22
- class SessionManager {
23
- config;
24
- cryptoProvider;
25
- sessions = new Map();
26
- constructor(cryptoProvider, config = {}) {
27
- this.cryptoProvider = cryptoProvider;
28
- this.config = {
29
- timestampSkewSeconds: config.timestampSkewSeconds ?? 120,
30
- sessionTtlMinutes: config.sessionTtlMinutes ?? 30,
31
- nonceCache: config.nonceCache ?? new memory_1.MemoryNonceCacheProvider(),
32
- ...(config.absoluteSessionLifetime !== undefined && {
33
- absoluteSessionLifetime: config.absoluteSessionLifetime,
34
- }),
35
- ...(config.serverDid !== undefined && { serverDid: config.serverDid }),
36
- };
37
- if (this.config.nonceCache instanceof memory_1.MemoryNonceCacheProvider) {
38
- logging_1.logger.warn("[SessionManager] Using MemoryNonceCacheProvider — not suitable for " +
39
- "multi-instance deployments. Use Redis, DynamoDB, or Cloudflare KV " +
40
- "for production.");
41
- }
42
- }
43
- /**
44
- * Set server DID for session creation (called after identity is loaded).
45
- */
46
- setServerDid(serverDid) {
47
- this.config.serverDid = serverDid;
48
- }
49
- /**
50
- * Validate handshake and create or retrieve session.
51
- * Requirements: 4.5, 4.6, 4.7, 4.8, 4.9
52
- */
53
- async validateHandshake(request) {
54
- try {
55
- const now = Math.floor(Date.now() / 1000);
56
- const timeDiff = Math.abs(now - request.timestamp);
57
- if (timeDiff > this.config.timestampSkewSeconds) {
58
- return {
59
- success: false,
60
- error: {
61
- code: "XMCP_I_EHANDSHAKE",
62
- message: `Timestamp outside acceptable range (±${this.config.timestampSkewSeconds}s)`,
63
- remediation: `Check NTP sync on client and server. Current server time: ${now}, received: ${request.timestamp}, diff: ${timeDiff}s. Adjust timestampSkewSeconds if needed.`,
64
- },
65
- };
66
- }
67
- const nonceExists = await this.config.nonceCache.has(request.nonce, request.agentDid);
68
- if (nonceExists) {
69
- return {
70
- success: false,
71
- error: {
72
- code: "XMCP_I_EHANDSHAKE",
73
- message: "Nonce already used (replay attack prevention)",
74
- remediation: "Generate a new unique nonce for each request",
75
- },
76
- };
77
- }
78
- const nonceTtlSeconds = this.config.sessionTtlMinutes * 60 + 60;
79
- await this.config.nonceCache.add(request.nonce, nonceTtlSeconds, request.agentDid);
80
- const sessionId = await this.generateSessionId();
81
- const clientInfo = await this.buildClientInfo(request);
82
- const session = {
83
- sessionId,
84
- audience: request.audience,
85
- nonce: request.nonce,
86
- timestamp: request.timestamp,
87
- createdAt: now,
88
- lastActivity: now,
89
- ttlMinutes: this.config.sessionTtlMinutes,
90
- identityState: "anonymous",
91
- agentDid: request.agentDid,
92
- ...(this.config.serverDid && { serverDid: this.config.serverDid }),
93
- ...(clientInfo && { clientInfo }),
94
- };
95
- this.sessions.set(sessionId, session);
96
- return { success: true, session };
97
- }
98
- catch (error) {
99
- return {
100
- success: false,
101
- error: {
102
- code: "XMCP_I_EHANDSHAKE",
103
- message: `Handshake validation failed: ${error instanceof Error ? error.message : "Unknown error"}`,
104
- },
105
- };
106
- }
107
- }
108
- /**
109
- * Get session by ID and update last activity.
110
- */
111
- async getSession(sessionId) {
112
- const session = this.sessions.get(sessionId);
113
- if (!session)
114
- return null;
115
- const now = Math.floor(Date.now() / 1000);
116
- const idleTimeSeconds = now - session.lastActivity;
117
- const maxIdleSeconds = session.ttlMinutes * 60;
118
- if (idleTimeSeconds > maxIdleSeconds) {
119
- this.sessions.delete(sessionId);
120
- return null;
121
- }
122
- if (this.config.absoluteSessionLifetime !== undefined) {
123
- const sessionAgeSeconds = now - session.createdAt;
124
- const maxAgeSeconds = this.config.absoluteSessionLifetime * 60;
125
- if (sessionAgeSeconds > maxAgeSeconds) {
126
- this.sessions.delete(sessionId);
127
- return null;
128
- }
129
- }
130
- session.lastActivity = now;
131
- this.sessions.set(sessionId, session);
132
- return session;
133
- }
134
- /**
135
- * Generate a unique session ID (mcpi_{uuid} format).
136
- * Uses injected CryptoProvider for platform-agnostic random bytes.
137
- */
138
- async generateSessionId() {
139
- const bytes = await this.cryptoProvider.randomBytes(16);
140
- // Apply UUID v4 version and variant bits
141
- bytes[6] = (bytes[6] & 0x0f) | 0x40;
142
- bytes[8] = (bytes[8] & 0x3f) | 0x80;
143
- const hex = Array.from(bytes)
144
- .map((b) => b.toString(16).padStart(2, "0"))
145
- .join("");
146
- const uuid = `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20, 32)}`;
147
- return `mcpi_${uuid}`;
148
- }
149
- /**
150
- * Generate a deterministic client identifier.
151
- */
152
- async generateClientId() {
153
- const bytes = await this.cryptoProvider.randomBytes(6);
154
- const hex = Array.from(bytes)
155
- .map((b) => b.toString(16).padStart(2, "0"))
156
- .join("");
157
- return `client_${hex}`;
158
- }
159
- /**
160
- * Normalize string fields from handshake metadata.
161
- */
162
- normalizeClientInfoString(value) {
163
- if (typeof value !== "string")
164
- return undefined;
165
- const trimmed = value.trim();
166
- return trimmed.length > 0 ? trimmed : undefined;
167
- }
168
- /**
169
- * Build MCP client metadata for the session.
170
- */
171
- async buildClientInfo(request) {
172
- const hasMetadata = !!request.clientInfo ||
173
- typeof request.clientProtocolVersion === "string" ||
174
- request.clientCapabilities !== undefined;
175
- if (!hasMetadata)
176
- return undefined;
177
- const source = request.clientInfo;
178
- return {
179
- name: this.normalizeClientInfoString(source?.name) ?? "unknown",
180
- title: this.normalizeClientInfoString(source?.title),
181
- version: this.normalizeClientInfoString(source?.version),
182
- platform: this.normalizeClientInfoString(source?.platform),
183
- vendor: this.normalizeClientInfoString(source?.vendor),
184
- persistentId: this.normalizeClientInfoString(source?.persistentId),
185
- clientId: this.normalizeClientInfoString(source?.clientId) ??
186
- (await this.generateClientId()),
187
- protocolVersion: this.normalizeClientInfoString(request.clientProtocolVersion),
188
- capabilities: request.clientCapabilities,
189
- };
190
- }
191
- /**
192
- * Generate a cryptographically secure nonce.
193
- * Uses globalThis.crypto (sync Web Crypto — available in Node 20+ and Workers).
194
- */
195
- static generateNonce() {
196
- const buffer = new Uint8Array(16);
197
- globalThis.crypto.getRandomValues(buffer);
198
- let binaryStr = "";
199
- for (let i = 0; i < buffer.length; i++) {
200
- binaryStr += String.fromCharCode(buffer[i]);
201
- }
202
- return btoa(binaryStr)
203
- .replace(/\+/g, "-")
204
- .replace(/\//g, "_")
205
- .replace(/=/g, "");
206
- }
207
- /**
208
- * Cleanup expired sessions and nonces.
209
- */
210
- async cleanup() {
211
- const now = Math.floor(Date.now() / 1000);
212
- for (const [sessionId, session] of this.sessions.entries()) {
213
- const idleTimeSeconds = now - session.lastActivity;
214
- const maxIdleSeconds = session.ttlMinutes * 60;
215
- let expired = idleTimeSeconds > maxIdleSeconds;
216
- if (!expired && this.config.absoluteSessionLifetime !== undefined) {
217
- const sessionAgeSeconds = now - session.createdAt;
218
- const maxAgeSeconds = this.config.absoluteSessionLifetime * 60;
219
- expired = sessionAgeSeconds > maxAgeSeconds;
220
- }
221
- if (expired) {
222
- this.sessions.delete(sessionId);
223
- }
224
- }
225
- await this.config.nonceCache.cleanup();
226
- }
227
- /**
228
- * Get session statistics.
229
- */
230
- getStats() {
231
- return {
232
- activeSessions: this.sessions.size,
233
- config: {
234
- timestampSkewSeconds: this.config.timestampSkewSeconds,
235
- sessionTtlMinutes: this.config.sessionTtlMinutes,
236
- absoluteSessionLifetime: this.config.absoluteSessionLifetime,
237
- cacheType: this.config.nonceCache.constructor.name,
238
- },
239
- };
240
- }
241
- /**
242
- * Clear all sessions (useful for testing).
243
- */
244
- clearSessions() {
245
- this.sessions.clear();
246
- }
247
- }
248
- exports.SessionManager = SessionManager;
249
- /**
250
- * Create a handshake request with a secure nonce.
251
- */
252
- function createHandshakeRequest(audience) {
253
- return {
254
- nonce: SessionManager.generateNonce(),
255
- audience,
256
- timestamp: Math.floor(Date.now() / 1000),
257
- };
258
- }
259
- /**
260
- * Validate handshake request format.
261
- */
262
- function validateHandshakeFormat(request) {
263
- return (typeof request === "object" &&
264
- request !== null &&
265
- typeof request.nonce === "string" &&
266
- request.nonce.length > 0 &&
267
- typeof request.audience === "string" &&
268
- request.audience.length > 0 &&
269
- typeof request.timestamp === "number" &&
270
- request.timestamp > 0 &&
271
- Number.isInteger(request.timestamp));
272
- }
273
- //# sourceMappingURL=manager.js.map
@@ -1,46 +0,0 @@
1
- /**
2
- * OAuth Required Error
3
- *
4
- * Error thrown when a tool requires an IDP token (OAuth) but none is available.
5
- * This triggers the OAuth flow to obtain the necessary token.
6
- *
7
- * @package @kya-os/mcp-i-core
8
- */
9
- export interface OAuthRequiredErrorOptions {
10
- /** Name of the tool requiring OAuth */
11
- toolName: string;
12
- /** Required OAuth scopes */
13
- requiredScopes: string[];
14
- /** OAuth provider name (e.g., "github", "google") */
15
- provider: string;
16
- /** OAuth authorization URL */
17
- oauthUrl: string;
18
- /** Optional resume token for continuing after OAuth */
19
- resumeToken?: string;
20
- /** Optional user DID */
21
- userDid?: string;
22
- /** Optional session ID */
23
- sessionId?: string;
24
- /**
25
- * Auth type from tool protection config (e.g., "password", "oauth")
26
- * Used to determine correct consent flow when catching the error
27
- */
28
- authType?: string;
29
- }
30
- /**
31
- * Error thrown when a tool requires OAuth but IDP token is not available
32
- *
33
- * This error should trigger the OAuth flow to obtain the necessary IDP token.
34
- */
35
- export declare class OAuthRequiredError extends Error {
36
- readonly toolName: string;
37
- readonly requiredScopes: string[];
38
- readonly provider: string;
39
- readonly oauthUrl: string;
40
- readonly resumeToken?: string;
41
- readonly userDid?: string;
42
- readonly sessionId?: string;
43
- readonly authType?: string;
44
- constructor(options: OAuthRequiredErrorOptions);
45
- }
46
- //# sourceMappingURL=oauth-required-error.d.ts.map
@@ -1,42 +0,0 @@
1
- "use strict";
2
- /**
3
- * OAuth Required Error
4
- *
5
- * Error thrown when a tool requires an IDP token (OAuth) but none is available.
6
- * This triggers the OAuth flow to obtain the necessary token.
7
- *
8
- * @package @kya-os/mcp-i-core
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.OAuthRequiredError = void 0;
12
- /**
13
- * Error thrown when a tool requires OAuth but IDP token is not available
14
- *
15
- * This error should trigger the OAuth flow to obtain the necessary IDP token.
16
- */
17
- class OAuthRequiredError extends Error {
18
- toolName;
19
- requiredScopes;
20
- provider;
21
- oauthUrl;
22
- resumeToken;
23
- userDid;
24
- sessionId;
25
- authType;
26
- constructor(options) {
27
- const { toolName, requiredScopes, provider, oauthUrl } = options;
28
- super(`OAuth required for tool "${toolName}" with provider "${provider}". ` +
29
- `Required scopes: ${requiredScopes.join(", ")}`);
30
- this.name = "OAuthRequiredError";
31
- this.toolName = toolName;
32
- this.requiredScopes = requiredScopes;
33
- this.provider = provider;
34
- this.oauthUrl = oauthUrl;
35
- this.resumeToken = options.resumeToken;
36
- this.userDid = options.userDid;
37
- this.sessionId = options.sessionId;
38
- this.authType = options.authType;
39
- }
40
- }
41
- exports.OAuthRequiredError = OAuthRequiredError;
42
- //# sourceMappingURL=oauth-required-error.js.map
@@ -1,144 +0,0 @@
1
- /**
2
- * Tool Protection Types
3
- *
4
- * Implementation-specific type definitions for tool protection services.
5
- * Core spec types are imported from @kya-os/contracts/tool-protection.
6
- *
7
- * @package @kya-os/mcp-i-core
8
- * @version 1.0.0
9
- */
10
- import type { ToolProtection, ToolProtectionMap } from "@kya-os/contracts/tool-protection";
11
- export type { ToolProtection };
12
- /**
13
- * Complete tool protection configuration for a project
14
- * @deprecated Use ToolProtectionMap from @kya-os/contracts/tool-protection
15
- */
16
- export interface ToolProtectionConfig {
17
- /**
18
- * Map of tool names to their protection settings
19
- */
20
- toolProtections: ToolProtectionMap;
21
- }
22
- /**
23
- * Configuration for the ToolProtectionService
24
- */
25
- export interface ToolProtectionServiceConfig {
26
- /**
27
- * AgentShield API base URL
28
- * @example "https://kya.vouched.id"
29
- */
30
- apiUrl: string;
31
- /**
32
- * AgentShield API key for authentication
33
- * @example "sk_..."
34
- */
35
- apiKey: string;
36
- /**
37
- * Project ID (optional, used for backward compatibility)
38
- * The service now fetches config by agent DID instead
39
- * @deprecated Use agent DID from runtime identity
40
- * @example "mcp-i-ieu0ro"
41
- */
42
- projectId?: string;
43
- /**
44
- * Cache TTL in milliseconds
45
- * @default 300000 (5 minutes)
46
- */
47
- cacheTtl?: number;
48
- /**
49
- * Local/default configuration (LOWEST priority after defaults)
50
- *
51
- * This config serves as a base that gets OVERRIDDEN by remote config.
52
- * Use this for development defaults or project-specific base settings.
53
- *
54
- * Precedence order (highest to lowest):
55
- * 1. Remote config (AgentShield API) - WINS
56
- * 2. Local config (this field)
57
- * 3. Framework defaults
58
- *
59
- * @optional
60
- */
61
- localConfig?: ToolProtectionConfig;
62
- /**
63
- * Offline fallback configuration (ONLY used when API is unavailable)
64
- *
65
- * Unlike localConfig, this is NOT merged with remote config.
66
- * It's only used as a complete replacement when the API cannot be reached.
67
- *
68
- * Fallback order when API fails:
69
- * 1. Stale cache (if allowStaleCache=true and within maxStaleCacheAge)
70
- * 2. This offlineFallbackConfig
71
- * 3. failSafeBehavior (deny-all or allow-all)
72
- *
73
- * @optional
74
- */
75
- offlineFallbackConfig?: ToolProtectionConfig;
76
- /**
77
- * Fail-safe behavior when API is unavailable and no offline fallback is provided
78
- * - 'deny-all': Block all tools by default (secure, recommended for production)
79
- * - 'allow-all': Allow all tools (insecure, not recommended for production)
80
- * @default 'deny-all'
81
- */
82
- failSafeBehavior?: "deny-all" | "allow-all";
83
- /**
84
- * Maximum age (in milliseconds) for stale cache to be used during outages
85
- * Stale cache is used when API fails and no fallback is provided
86
- * @default 86400000 (24 hours)
87
- */
88
- maxStaleCacheAge?: number;
89
- /**
90
- * Allow using stale cache during outages
91
- * @default true
92
- */
93
- allowStaleCache?: boolean;
94
- /**
95
- * Enable debug logging
96
- * @default false
97
- */
98
- debug?: boolean;
99
- }
100
- /**
101
- * API response from /api/v1/bouncer/projects/{projectId}/tool-protections
102
- */
103
- export interface ToolProtectionApiResponse {
104
- success: boolean;
105
- data: {
106
- toolProtections: Record<string, ToolProtection>;
107
- };
108
- metadata: {
109
- timestamp: string;
110
- cachedUntil: string;
111
- };
112
- }
113
- /**
114
- * Error thrown when a tool requires delegation but none is provided
115
- *
116
- * Note: Resume token generation is handled by MCPIRuntimeBase.generateResumeToken().
117
- * The runtime should generate the token and pass it to this constructor.
118
- */
119
- export declare class DelegationRequiredError extends Error {
120
- toolName: string;
121
- requiredScopes: string[];
122
- consentUrl?: string | undefined;
123
- resumeToken?: string;
124
- interceptedCall?: InterceptedToolCall;
125
- constructor(toolName: string, requiredScopes: string[], consentUrl?: string | undefined, interceptedCall?: InterceptedToolCall, resumeToken?: string);
126
- }
127
- /**
128
- * Context for an intercepted tool call that needs authorization
129
- */
130
- export interface InterceptedToolCall {
131
- toolName: string;
132
- args: any;
133
- sessionId: string;
134
- timestamp: number;
135
- expiresAt: number;
136
- }
137
- /**
138
- * Error thrown when the tool protection service fails
139
- */
140
- export declare class ToolProtectionServiceError extends Error {
141
- cause?: Error | undefined;
142
- constructor(message: string, cause?: Error | undefined);
143
- }
144
- //# sourceMappingURL=tool-protection.d.ts.map
@@ -1,48 +0,0 @@
1
- "use strict";
2
- /**
3
- * Tool Protection Types
4
- *
5
- * Implementation-specific type definitions for tool protection services.
6
- * Core spec types are imported from @kya-os/contracts/tool-protection.
7
- *
8
- * @package @kya-os/mcp-i-core
9
- * @version 1.0.0
10
- */
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ToolProtectionServiceError = exports.DelegationRequiredError = void 0;
13
- /**
14
- * Error thrown when a tool requires delegation but none is provided
15
- *
16
- * Note: Resume token generation is handled by MCPIRuntimeBase.generateResumeToken().
17
- * The runtime should generate the token and pass it to this constructor.
18
- */
19
- class DelegationRequiredError extends Error {
20
- toolName;
21
- requiredScopes;
22
- consentUrl;
23
- resumeToken;
24
- interceptedCall;
25
- constructor(toolName, requiredScopes, consentUrl, interceptedCall, resumeToken) {
26
- super(`Delegation required for tool "${toolName}"`);
27
- this.toolName = toolName;
28
- this.requiredScopes = requiredScopes;
29
- this.consentUrl = consentUrl;
30
- this.name = "DelegationRequiredError";
31
- this.interceptedCall = interceptedCall;
32
- this.resumeToken = resumeToken;
33
- }
34
- }
35
- exports.DelegationRequiredError = DelegationRequiredError;
36
- /**
37
- * Error thrown when the tool protection service fails
38
- */
39
- class ToolProtectionServiceError extends Error {
40
- cause;
41
- constructor(message, cause) {
42
- super(message);
43
- this.cause = cause;
44
- this.name = "ToolProtectionServiceError";
45
- }
46
- }
47
- exports.ToolProtectionServiceError = ToolProtectionServiceError;
48
- //# sourceMappingURL=tool-protection.js.map