@kya-os/mcp-i-core 1.7.0 → 1.8.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 (121) hide show
  1. package/README.md +1 -1
  2. package/dist/conformance/capability-verifier-adapter.d.ts +66 -0
  3. package/dist/conformance/capability-verifier-adapter.js +61 -0
  4. package/dist/conformance/index.d.ts +10 -0
  5. package/dist/conformance/index.js +19 -0
  6. package/dist/conformance/validate-level2.d.ts +203 -0
  7. package/dist/conformance/validate-level2.js +294 -0
  8. package/dist/conformance/vc-jwt-verifier.d.ts +55 -0
  9. package/dist/conformance/vc-jwt-verifier.js +147 -0
  10. package/dist/delegation/did-web-resolver.d.ts +60 -0
  11. package/dist/delegation/did-web-resolver.js +129 -0
  12. package/dist/delegation/outbound-proof.d.ts +3 -2
  13. package/dist/delegation/outbound-proof.js +3 -2
  14. package/dist/delegation/utils.d.ts +3 -1
  15. package/dist/index.d.ts +9 -63
  16. package/dist/index.js +22 -161
  17. package/dist/utils/base58.d.ts +4 -28
  18. package/dist/utils/base58.js +18 -98
  19. package/dist/utils/base64.d.ts +4 -29
  20. package/dist/utils/base64.js +18 -167
  21. package/dist/utils/did-helpers.d.ts +4 -165
  22. package/dist/utils/did-helpers.js +18 -217
  23. package/package.json +5 -7
  24. package/dist/auth/handshake.d.ts +0 -119
  25. package/dist/auth/handshake.js +0 -250
  26. package/dist/auth/index.d.ts +0 -6
  27. package/dist/auth/index.js +0 -11
  28. package/dist/auth/types.d.ts +0 -46
  29. package/dist/auth/types.js +0 -10
  30. package/dist/cache/oauth-config-cache.d.ts +0 -69
  31. package/dist/cache/oauth-config-cache.js +0 -76
  32. package/dist/cache/tool-protection-cache.d.ts +0 -89
  33. package/dist/cache/tool-protection-cache.js +0 -118
  34. package/dist/compliance/index.d.ts +0 -8
  35. package/dist/compliance/index.js +0 -24
  36. package/dist/compliance/schema-registry.d.ts +0 -50
  37. package/dist/compliance/schema-registry.js +0 -438
  38. package/dist/compliance/schema-verifier.d.ts +0 -110
  39. package/dist/compliance/schema-verifier.js +0 -518
  40. package/dist/config/remote-config.d.ts +0 -173
  41. package/dist/config/remote-config.js +0 -253
  42. package/dist/config.d.ts +0 -182
  43. package/dist/config.js +0 -148
  44. package/dist/identity/idp-token-resolver.d.ts +0 -69
  45. package/dist/identity/idp-token-resolver.js +0 -136
  46. package/dist/identity/idp-token-storage.interface.d.ts +0 -80
  47. package/dist/identity/idp-token-storage.interface.js +0 -14
  48. package/dist/identity/user-did-manager.d.ts +0 -228
  49. package/dist/identity/user-did-manager.js +0 -356
  50. package/dist/logging/index.d.ts +0 -5
  51. package/dist/logging/index.js +0 -10
  52. package/dist/logging/logger.d.ts +0 -33
  53. package/dist/logging/logger.js +0 -104
  54. package/dist/proof/generator.d.ts +0 -109
  55. package/dist/proof/generator.js +0 -236
  56. package/dist/proof/index.d.ts +0 -5
  57. package/dist/proof/index.js +0 -11
  58. package/dist/providers/base.d.ts +0 -95
  59. package/dist/providers/base.js +0 -47
  60. package/dist/providers/memory.d.ts +0 -42
  61. package/dist/providers/memory.js +0 -121
  62. package/dist/runtime/audit-logger.d.ts +0 -37
  63. package/dist/runtime/audit-logger.js +0 -9
  64. package/dist/runtime/base.d.ts +0 -375
  65. package/dist/runtime/base.js +0 -1491
  66. package/dist/runtime/ext-apps-constants.d.ts +0 -14
  67. package/dist/runtime/ext-apps-constants.js +0 -17
  68. package/dist/services/access-control.service.d.ts +0 -138
  69. package/dist/services/access-control.service.js +0 -721
  70. package/dist/services/authorization/authorization-registry.d.ts +0 -29
  71. package/dist/services/authorization/authorization-registry.js +0 -58
  72. package/dist/services/authorization/types.d.ts +0 -53
  73. package/dist/services/authorization/types.js +0 -10
  74. package/dist/services/batch-delegation.service.d.ts +0 -53
  75. package/dist/services/batch-delegation.service.js +0 -95
  76. package/dist/services/crypto.service.d.ts +0 -69
  77. package/dist/services/crypto.service.js +0 -225
  78. package/dist/services/delegation-error-formatter.d.ts +0 -124
  79. package/dist/services/delegation-error-formatter.js +0 -214
  80. package/dist/services/errors.d.ts +0 -49
  81. package/dist/services/errors.js +0 -66
  82. package/dist/services/index.d.ts +0 -9
  83. package/dist/services/index.js +0 -15
  84. package/dist/services/oauth-config.service.d.ts +0 -53
  85. package/dist/services/oauth-config.service.js +0 -141
  86. package/dist/services/oauth-provider-registry.d.ts +0 -88
  87. package/dist/services/oauth-provider-registry.js +0 -128
  88. package/dist/services/oauth-service.d.ts +0 -122
  89. package/dist/services/oauth-service.js +0 -442
  90. package/dist/services/oauth-token-retrieval.service.d.ts +0 -49
  91. package/dist/services/oauth-token-retrieval.service.js +0 -150
  92. package/dist/services/policy.service.d.ts +0 -130
  93. package/dist/services/policy.service.js +0 -399
  94. package/dist/services/proof-verifier.d.ts +0 -98
  95. package/dist/services/proof-verifier.js +0 -319
  96. package/dist/services/provider-resolver.d.ts +0 -89
  97. package/dist/services/provider-resolver.js +0 -196
  98. package/dist/services/provider-validator.d.ts +0 -55
  99. package/dist/services/provider-validator.js +0 -135
  100. package/dist/services/session-registration.service.d.ts +0 -80
  101. package/dist/services/session-registration.service.js +0 -174
  102. package/dist/services/storage.service.d.ts +0 -116
  103. package/dist/services/storage.service.js +0 -411
  104. package/dist/services/tool-context-builder.d.ts +0 -74
  105. package/dist/services/tool-context-builder.js +0 -215
  106. package/dist/services/tool-protection.service.d.ts +0 -193
  107. package/dist/services/tool-protection.service.js +0 -736
  108. package/dist/session/index.d.ts +0 -5
  109. package/dist/session/index.js +0 -11
  110. package/dist/session/manager.d.ts +0 -113
  111. package/dist/session/manager.js +0 -273
  112. package/dist/types/oauth-required-error.d.ts +0 -46
  113. package/dist/types/oauth-required-error.js +0 -42
  114. package/dist/types/tool-protection.d.ts +0 -144
  115. package/dist/types/tool-protection.js +0 -48
  116. package/dist/utils/cors.d.ts +0 -44
  117. package/dist/utils/cors.js +0 -71
  118. package/dist/utils/index.d.ts +0 -8
  119. package/dist/utils/index.js +0 -24
  120. package/dist/utils/storage-keys.d.ts +0 -120
  121. package/dist/utils/storage-keys.js +0 -217
@@ -1,411 +0,0 @@
1
- "use strict";
2
- /**
3
- * Storage Service Factory
4
- *
5
- * Auto-selects storage providers based on available configuration.
6
- * Priority: Redis > Cloudflare KV > Cloudflare Durable Objects > Memory
7
- *
8
- * @package @kya-os/mcp-i-core
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.StorageKeyHelpers = void 0;
12
- exports.createStorageProviders = createStorageProviders;
13
- exports.migrateLegacyKeys = migrateLegacyKeys;
14
- const base_js_1 = require("../providers/base.js");
15
- const memory_js_1 = require("../providers/memory.js");
16
- /**
17
- * Key helper functions for consistent key formatting
18
- */
19
- class StorageKeyHelpers {
20
- /**
21
- * Build delegation key using composite format
22
- * Format: delegation:${userDid}:${agentDid}:${projectId}
23
- */
24
- static buildDelegationKey(userDid, agentDid, projectId) {
25
- return `delegation:${userDid}:${agentDid}:${projectId}`;
26
- }
27
- /**
28
- * Build session key
29
- * Format: session:${sessionId}
30
- */
31
- static buildSessionKey(sessionId) {
32
- return `session:${sessionId}`;
33
- }
34
- /**
35
- * Build nonce key
36
- * Format: nonce:${agentDid}:${nonce}
37
- */
38
- static buildNonceKey(agentDid, nonce) {
39
- return `nonce:${agentDid}:${nonce}`;
40
- }
41
- /**
42
- * Parse delegation key back into components
43
- *
44
- * Format: delegation:${userDid}:${agentDid}:${projectId}
45
- *
46
- * Note: DIDs contain colons (e.g., did:key:z123), so we can't simply split by ":"
47
- * Instead, we:
48
- * 1. Check that key starts with "delegation:"
49
- * 2. Take the last part as projectId (doesn't contain colons)
50
- * 3. Find where agentDid starts (look for "did:" pattern)
51
- * 4. Everything before agentDid is userDid, everything between agentDid and projectId is agentDid
52
- *
53
- * Strategy: Since DIDs always start with "did:", we can find the second occurrence of "did:"
54
- * to determine where agentDid begins. However, this assumes userDid and agentDid both start with "did:".
55
- *
56
- * For keys like "delegation:did:key:user123:did:key:agent456:project-789":
57
- * - Remove "delegation:" prefix → "did:key:user123:did:key:agent456:project-789"
58
- * - Find last ":" → separates agentDid from projectId
59
- * - projectId = "project-789"
60
- * - Find second occurrence of "did:" → separates userDid from agentDid
61
- * - userDid = "did:key:user123"
62
- * - agentDid = "did:key:agent456"
63
- */
64
- static parseDelegationKey(key) {
65
- if (!key.startsWith("delegation:")) {
66
- return null;
67
- }
68
- // Remove "delegation:" prefix
69
- const rest = key.slice("delegation:".length);
70
- // Find the last colon (separates agentDid from projectId)
71
- const lastColonIndex = rest.lastIndexOf(":");
72
- if (lastColonIndex === -1) {
73
- return null; // No colon found, invalid format
74
- }
75
- // Last part is projectId (doesn't contain colons)
76
- const projectId = rest.slice(lastColonIndex + 1);
77
- if (!projectId) {
78
- return null; // Empty projectId
79
- }
80
- // Everything before the last colon is userDid:agentDid
81
- const userDidAndAgentDid = rest.slice(0, lastColonIndex);
82
- // Find the second occurrence of "did:" to separate userDid from agentDid
83
- // First occurrence is at the start (userDid), second is agentDid
84
- const firstDidIndex = userDidAndAgentDid.indexOf("did:");
85
- if (firstDidIndex !== 0) {
86
- return null; // userDid must start with "did:"
87
- }
88
- // Find where the first DID ends by looking for the pattern "did:method:identifier"
89
- // A DID has the format: did:method:identifier (where identifier may contain colons)
90
- // We need to find the next "did:" that appears after a complete DID
91
- // Strategy: Find the method separator colon (after "did:"), then search for the next "did:" after that
92
- // This ensures we find the second complete DID, not a substring within the first DID's identifier
93
- const firstMethodColon = userDidAndAgentDid.indexOf(":", firstDidIndex + "did:".length);
94
- if (firstMethodColon === -1) {
95
- return null; // Invalid DID format - no method separator
96
- }
97
- // Now search for the next "did:" after the first complete DID
98
- // The first DID ends somewhere after the method colon, so search from there
99
- const secondDidIndex = userDidAndAgentDid.indexOf("did:", firstMethodColon + 1);
100
- if (secondDidIndex === -1) {
101
- return null; // No second "did:" found, can't separate userDid and agentDid
102
- }
103
- // userDid is everything before the second "did:", agentDid is everything after
104
- const userDid = userDidAndAgentDid.slice(0, secondDidIndex);
105
- const agentDid = userDidAndAgentDid.slice(secondDidIndex);
106
- // Remove trailing colon from userDid if present
107
- const cleanUserDid = userDid.endsWith(":") ? userDid.slice(0, -1) : userDid;
108
- if (!cleanUserDid || !agentDid) {
109
- return null; // Empty userDid or agentDid
110
- }
111
- return {
112
- userDid: cleanUserDid,
113
- agentDid,
114
- projectId,
115
- };
116
- }
117
- }
118
- exports.StorageKeyHelpers = StorageKeyHelpers;
119
- /**
120
- * Durable Object Storage Provider
121
- * Wraps Cloudflare Durable Object state storage
122
- */
123
- class DurableObjectStorageProvider extends base_js_1.StorageProvider {
124
- state;
125
- constructor(state) {
126
- super();
127
- this.state = state;
128
- }
129
- async get(key) {
130
- const value = await this.state.storage.get(key);
131
- return value ?? null;
132
- }
133
- async set(key, value) {
134
- await this.state.storage.put(key, value);
135
- }
136
- async delete(key) {
137
- await this.state.storage.delete(key);
138
- }
139
- async exists(key) {
140
- const value = await this.state.storage.get(key);
141
- return value !== undefined;
142
- }
143
- async list(prefix) {
144
- const result = await this.state.storage.list(prefix ? { prefix } : undefined);
145
- return Array.from(result.keys());
146
- }
147
- }
148
- /**
149
- * Durable Object Nonce Cache Provider
150
- */
151
- class DurableObjectNonceCacheProvider extends base_js_1.NonceCacheProvider {
152
- state;
153
- constructor(state) {
154
- super();
155
- this.state = state;
156
- }
157
- async has(nonce, agentDid) {
158
- const key = agentDid
159
- ? StorageKeyHelpers.buildNonceKey(agentDid, nonce)
160
- : `nonce:${nonce}`;
161
- const value = await this.state.storage.get(key);
162
- if (!value) {
163
- return false;
164
- }
165
- const expiresAt = parseInt(value, 10);
166
- return Date.now() < expiresAt;
167
- }
168
- async add(nonce, ttlSeconds, agentDid) {
169
- const key = agentDid
170
- ? StorageKeyHelpers.buildNonceKey(agentDid, nonce)
171
- : `nonce:${nonce}`;
172
- // Convert TTL seconds to absolute expiration timestamp for storage
173
- const expiresAt = Date.now() + ttlSeconds * 1000;
174
- await this.state.storage.put(key, expiresAt.toString());
175
- }
176
- async cleanup() {
177
- // Durable Objects don't support efficient bulk operations
178
- // Cleanup would require listing all keys, which is expensive
179
- // For now, rely on TTL checking in has() method
180
- }
181
- async destroy() {
182
- // Durable Objects state persists automatically
183
- // No explicit cleanup needed
184
- }
185
- }
186
- /**
187
- * Redis Storage Provider
188
- * Uses Redis for storage operations
189
- */
190
- class RedisStorageProvider extends base_js_1.StorageProvider {
191
- redis; // Redis client from 'redis' package
192
- constructor(redisClient) {
193
- super();
194
- this.redis = redisClient;
195
- }
196
- async get(key) {
197
- return await this.redis.get(key);
198
- }
199
- async set(key, value) {
200
- await this.redis.set(key, value);
201
- }
202
- async delete(key) {
203
- await this.redis.del(key);
204
- }
205
- async exists(key) {
206
- const result = await this.redis.exists(key);
207
- return result === 1;
208
- }
209
- async list(prefix) {
210
- const pattern = prefix ? `${prefix}*` : "*";
211
- const keys = await this.redis.keys(pattern);
212
- return keys;
213
- }
214
- }
215
- /**
216
- * Redis Nonce Cache Provider
217
- */
218
- class RedisNonceCacheProvider extends base_js_1.NonceCacheProvider {
219
- redis;
220
- keyPrefix;
221
- constructor(redisClient, keyPrefix = "nonce:") {
222
- super();
223
- this.redis = redisClient;
224
- this.keyPrefix = keyPrefix;
225
- }
226
- async has(nonce, agentDid) {
227
- const key = agentDid
228
- ? StorageKeyHelpers.buildNonceKey(agentDid, nonce)
229
- : `${this.keyPrefix}${nonce}`;
230
- const result = await this.redis.exists(key);
231
- return result === 1;
232
- }
233
- async add(nonce, ttlSeconds, agentDid) {
234
- const key = agentDid
235
- ? StorageKeyHelpers.buildNonceKey(agentDid, nonce)
236
- : `${this.keyPrefix}${nonce}`;
237
- // Use TTL directly in seconds (callers now pass TTL, not absolute timestamp)
238
- await this.redis.setEx(key, ttlSeconds, "1");
239
- }
240
- async cleanup() {
241
- // Redis handles TTL automatically, no cleanup needed
242
- }
243
- async destroy() {
244
- // Redis connection should be managed by caller
245
- }
246
- }
247
- /**
248
- * KV Storage Provider wrapper
249
- * Uses existing KVStorageProvider from mcp-i-cloudflare
250
- */
251
- /**
252
- * Create Cloudflare KV storage providers
253
- *
254
- * This function dynamically imports Cloudflare-specific storage providers.
255
- * The @ts-ignore is necessary because @kya-os/mcp-i-cloudflare/providers/storage
256
- * is an optional dependency that may not exist in Node.js environments.
257
- * This is intentional for platform-specific code - the import will fail at runtime
258
- * if the module doesn't exist, which is handled by the try-catch block.
259
- */
260
- async function createKVStorageProvider(kvNamespace) {
261
- // Dynamic import to avoid bundling Cloudflare-specific code
262
- // This is an optional dependency that may not exist in all environments
263
- try {
264
- // Use string literal to avoid TypeScript checking the module path at compile time
265
- const storageModulePath = "@kya-os/mcp-i-cloudflare/providers/storage";
266
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
267
- // @ts-ignore TS2307 - Optional dependency: @kya-os/mcp-i-cloudflare/providers/storage
268
- // may not exist in Node.js environments. This is intentional for platform-specific code.
269
- const { KVStorageProvider, KVNonceCacheProvider } = await import(storageModulePath);
270
- const storage = new KVStorageProvider(kvNamespace);
271
- const nonceCache = new KVNonceCacheProvider(kvNamespace);
272
- return { storage, nonceCache };
273
- }
274
- catch (error) {
275
- throw new Error(`Failed to import Cloudflare storage providers: ${error instanceof Error ? error.message : String(error)}`);
276
- }
277
- }
278
- /**
279
- * Create storage providers based on configuration
280
- *
281
- * Priority order:
282
- * 1. Redis (if redisUrl provided)
283
- * 2. Cloudflare KV (if kvNamespace provided)
284
- * 3. Cloudflare Durable Objects (if durableObjectState provided)
285
- * 4. In-memory fallback (if fallbackToMemory is true, default)
286
- */
287
- async function createStorageProviders(config) {
288
- const fallbackToMemory = config.fallbackToMemory !== false;
289
- // Priority 1: Redis
290
- if (config.redisUrl) {
291
- try {
292
- // Dynamic import to avoid bundling Redis in environments that don't need it
293
- // Use string literal to avoid TypeScript checking the module path at compile time
294
- const redisModulePath = "redis";
295
- // @ts-ignore TS2307 - Optional dependency: 'redis' package may not be installed.
296
- // This is intentional - the import will fail at runtime if Redis is not available,
297
- // which is handled by the try-catch block.
298
- const redisModule = await import(redisModulePath).catch(() => null);
299
- if (!redisModule) {
300
- throw new Error("Redis package not available");
301
- }
302
- const { createClient } = redisModule;
303
- // @ts-ignore TS2307 - Type inference from dynamic import
304
- // Redis client type is inferred from the runtime module
305
- const redis = createClient({
306
- url: config.redisUrl,
307
- socket: {
308
- connectTimeout: 5000,
309
- },
310
- });
311
- await redis.connect();
312
- await redis.ping();
313
- const storageProvider = new RedisStorageProvider(redis);
314
- const nonceCacheProvider = new RedisNonceCacheProvider(redis);
315
- return {
316
- storageProvider,
317
- nonceCacheProvider,
318
- };
319
- }
320
- catch (error) {
321
- if (!fallbackToMemory) {
322
- throw error;
323
- }
324
- console.warn("[StorageService] Failed to connect to Redis, falling back to memory:", error instanceof Error ? error.message : String(error));
325
- }
326
- }
327
- // Priority 2: Cloudflare KV
328
- if (config.kvNamespace) {
329
- try {
330
- const providers = await createKVStorageProvider(config.kvNamespace);
331
- return {
332
- storageProvider: providers.storage,
333
- nonceCacheProvider: providers.nonceCache,
334
- };
335
- }
336
- catch (error) {
337
- if (!fallbackToMemory) {
338
- throw error;
339
- }
340
- console.warn("[StorageService] Failed to initialize KV, falling back to memory:", error instanceof Error ? error.message : String(error));
341
- }
342
- }
343
- // Priority 3: Cloudflare Durable Objects
344
- if (config.durableObjectState) {
345
- try {
346
- const storageProvider = new DurableObjectStorageProvider(config.durableObjectState);
347
- const nonceCacheProvider = new DurableObjectNonceCacheProvider(config.durableObjectState);
348
- return {
349
- storageProvider,
350
- nonceCacheProvider,
351
- };
352
- }
353
- catch (error) {
354
- if (!fallbackToMemory) {
355
- throw error;
356
- }
357
- console.warn("[StorageService] Failed to initialize Durable Objects, falling back to memory:", error instanceof Error ? error.message : String(error));
358
- }
359
- }
360
- // Priority 4: In-memory fallback
361
- if (fallbackToMemory) {
362
- return {
363
- storageProvider: new memory_js_1.MemoryStorageProvider(),
364
- nonceCacheProvider: new memory_js_1.MemoryNonceCacheProvider(),
365
- };
366
- }
367
- throw new Error("No storage provider configured and fallbackToMemory is false");
368
- }
369
- /**
370
- * Migration utility for legacy key formats
371
- *
372
- * Migrates keys from old format (e.g., `agent:${did}:delegation`) to new composite format
373
- */
374
- async function migrateLegacyKeys(oldKeyPrefix, newKeyFormat, storageProvider, batchSize = 100) {
375
- let migrated = 0;
376
- try {
377
- // List all keys with old prefix
378
- const oldKeys = await storageProvider.list(oldKeyPrefix);
379
- for (const oldKey of oldKeys) {
380
- const newKey = newKeyFormat(oldKey);
381
- if (!newKey) {
382
- continue; // Skip if transformation fails
383
- }
384
- // Check if new key already exists
385
- const existing = await storageProvider.exists(newKey);
386
- if (existing) {
387
- continue; // Skip if already migrated
388
- }
389
- // Read old value
390
- const value = await storageProvider.get(oldKey);
391
- if (!value) {
392
- continue; // Skip if old key has no value
393
- }
394
- // Write to new key
395
- await storageProvider.set(newKey, value);
396
- // Optionally delete old key (commented out for safety)
397
- // await storageProvider.delete(oldKey);
398
- migrated++;
399
- if (migrated % batchSize === 0) {
400
- // Yield to event loop for large migrations
401
- await new Promise((resolve) => setTimeout(resolve, 0));
402
- }
403
- }
404
- }
405
- catch (error) {
406
- console.error("[StorageService] Migration error:", error);
407
- throw error;
408
- }
409
- return migrated;
410
- }
411
- //# sourceMappingURL=storage.service.js.map
@@ -1,74 +0,0 @@
1
- /**
2
- * Tool Context Builder
3
- *
4
- * Builds ToolExecutionContext for tool handlers by resolving IDP tokens
5
- * based on tool protection configuration and user identity.
6
- *
7
- * Updated for CRED-003: Builds idpHeaders based on tokenUsage metadata
8
- * to support credential providers with custom token usage patterns.
9
- *
10
- * @package @kya-os/mcp-i-core
11
- */
12
- import type { ToolExecutionContext } from "@kya-os/contracts/config";
13
- import type { IdpTokenResolver } from "../identity/idp-token-resolver.js";
14
- import type { ToolProtection } from "../types/tool-protection.js";
15
- import type { OAuthConfigService } from "./oauth-config.service.js";
16
- import type { ProviderResolver } from "./provider-resolver.js";
17
- export interface ToolContextBuilderConfig {
18
- /** IDP token resolver for resolving tokens from User DID */
19
- tokenResolver: IdpTokenResolver;
20
- /** OAuth config service for fetching provider configurations */
21
- configService: OAuthConfigService;
22
- /** Provider resolver for resolving OAuth providers for tools */
23
- providerResolver: ProviderResolver;
24
- /** Project ID for fetching OAuth config */
25
- projectId: string;
26
- /** Optional logger callback for diagnostics */
27
- logger?: (message: string, data?: unknown) => void;
28
- }
29
- /**
30
- * Builder for tool execution context
31
- *
32
- * Resolves IDP tokens and builds context for tool handlers.
33
- * Phase 1: Uses configured provider as temporary fallback.
34
- * Phase 2+: Requires explicit oauthProvider on tool protection.
35
- */
36
- export declare class ToolContextBuilder {
37
- private config;
38
- constructor(config: ToolContextBuilderConfig);
39
- /**
40
- * Build tool execution context
41
- *
42
- * @param toolName - Name of the tool being executed
43
- * @param userDid - User DID (optional, required for OAuth/credentials)
44
- * @param sessionId - Session ID (optional)
45
- * @param delegationToken - Delegation token (optional)
46
- * @param toolProtection - Tool protection configuration (optional)
47
- * @returns Tool execution context or undefined if not needed
48
- */
49
- buildContext(toolName: string, userDid: string | undefined, sessionId: string | undefined, delegationToken: string | undefined, toolProtection: ToolProtection | null): Promise<ToolExecutionContext | undefined>;
50
- /**
51
- * Build authentication headers based on token usage metadata (CRED-003)
52
- *
53
- * Supports three modes:
54
- * - "cookie": Cookie header (with optional cookieFormat template)
55
- * - "bearer": Authorization: Bearer xxx
56
- * - "header": Custom header name
57
- *
58
- * Also includes any apiHeaders from provider config.
59
- *
60
- * @param tokenData - Token data with usage metadata
61
- * @returns Headers object for API calls
62
- */
63
- private buildAuthHeaders;
64
- /**
65
- * Resolve OAuth provider for a tool
66
- *
67
- * Phase 2: Uses ProviderResolver with priority-based resolution
68
- *
69
- * @param toolProtection - Tool protection configuration
70
- * @returns Provider name or throws error if not found
71
- */
72
- private resolveProvider;
73
- }
74
- //# sourceMappingURL=tool-context-builder.d.ts.map