@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.
- package/dist/conformance/capability-verifier-adapter.d.ts +66 -0
- package/dist/conformance/capability-verifier-adapter.js +61 -0
- package/dist/conformance/index.d.ts +3 -1
- package/dist/conformance/index.js +7 -1
- package/dist/conformance/validate-level2.d.ts +13 -3
- package/dist/conformance/validate-level2.js +15 -5
- package/dist/conformance/vc-jwt-verifier.d.ts +55 -0
- package/dist/conformance/vc-jwt-verifier.js +147 -0
- package/dist/delegation/did-web-resolver.d.ts +60 -0
- package/dist/delegation/did-web-resolver.js +129 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +9 -1
- package/package.json +3 -3
- package/dist/auth/handshake.d.ts +0 -119
- package/dist/auth/handshake.js +0 -250
- package/dist/auth/index.d.ts +0 -6
- package/dist/auth/index.js +0 -11
- package/dist/auth/types.d.ts +0 -46
- package/dist/auth/types.js +0 -10
- package/dist/cache/oauth-config-cache.d.ts +0 -69
- package/dist/cache/oauth-config-cache.js +0 -76
- package/dist/cache/tool-protection-cache.d.ts +0 -89
- package/dist/cache/tool-protection-cache.js +0 -118
- package/dist/compliance/index.d.ts +0 -8
- package/dist/compliance/index.js +0 -24
- package/dist/compliance/schema-registry.d.ts +0 -50
- package/dist/compliance/schema-registry.js +0 -438
- package/dist/compliance/schema-verifier.d.ts +0 -110
- package/dist/compliance/schema-verifier.js +0 -518
- package/dist/config/remote-config.d.ts +0 -173
- package/dist/config/remote-config.js +0 -253
- package/dist/config.d.ts +0 -182
- package/dist/config.js +0 -148
- package/dist/identity/idp-token-resolver.d.ts +0 -69
- package/dist/identity/idp-token-resolver.js +0 -136
- package/dist/identity/idp-token-storage.interface.d.ts +0 -80
- package/dist/identity/idp-token-storage.interface.js +0 -14
- package/dist/identity/user-did-manager.d.ts +0 -228
- package/dist/identity/user-did-manager.js +0 -356
- package/dist/logging/index.d.ts +0 -5
- package/dist/logging/index.js +0 -10
- package/dist/logging/logger.d.ts +0 -33
- package/dist/logging/logger.js +0 -104
- package/dist/proof/generator.d.ts +0 -109
- package/dist/proof/generator.js +0 -236
- package/dist/proof/index.d.ts +0 -5
- package/dist/proof/index.js +0 -11
- package/dist/providers/base.d.ts +0 -95
- package/dist/providers/base.js +0 -47
- package/dist/providers/memory.d.ts +0 -42
- package/dist/providers/memory.js +0 -121
- package/dist/runtime/audit-logger.d.ts +0 -37
- package/dist/runtime/audit-logger.js +0 -9
- package/dist/runtime/base.d.ts +0 -375
- package/dist/runtime/base.js +0 -1491
- package/dist/runtime/ext-apps-constants.d.ts +0 -14
- package/dist/runtime/ext-apps-constants.js +0 -17
- package/dist/services/access-control.service.d.ts +0 -138
- package/dist/services/access-control.service.js +0 -721
- package/dist/services/authorization/authorization-registry.d.ts +0 -29
- package/dist/services/authorization/authorization-registry.js +0 -58
- package/dist/services/authorization/types.d.ts +0 -53
- package/dist/services/authorization/types.js +0 -10
- package/dist/services/batch-delegation.service.d.ts +0 -53
- package/dist/services/batch-delegation.service.js +0 -95
- package/dist/services/crypto.service.d.ts +0 -69
- package/dist/services/crypto.service.js +0 -225
- package/dist/services/delegation-error-formatter.d.ts +0 -124
- package/dist/services/delegation-error-formatter.js +0 -214
- package/dist/services/errors.d.ts +0 -49
- package/dist/services/errors.js +0 -66
- package/dist/services/index.d.ts +0 -9
- package/dist/services/index.js +0 -15
- package/dist/services/oauth-config.service.d.ts +0 -53
- package/dist/services/oauth-config.service.js +0 -141
- package/dist/services/oauth-provider-registry.d.ts +0 -88
- package/dist/services/oauth-provider-registry.js +0 -128
- package/dist/services/oauth-service.d.ts +0 -122
- package/dist/services/oauth-service.js +0 -442
- package/dist/services/oauth-token-retrieval.service.d.ts +0 -49
- package/dist/services/oauth-token-retrieval.service.js +0 -150
- package/dist/services/policy.service.d.ts +0 -130
- package/dist/services/policy.service.js +0 -399
- package/dist/services/proof-verifier.d.ts +0 -98
- package/dist/services/proof-verifier.js +0 -319
- package/dist/services/provider-resolver.d.ts +0 -89
- package/dist/services/provider-resolver.js +0 -196
- package/dist/services/provider-validator.d.ts +0 -55
- package/dist/services/provider-validator.js +0 -135
- package/dist/services/session-registration.service.d.ts +0 -80
- package/dist/services/session-registration.service.js +0 -174
- package/dist/services/storage.service.d.ts +0 -116
- package/dist/services/storage.service.js +0 -411
- package/dist/services/tool-context-builder.d.ts +0 -74
- package/dist/services/tool-context-builder.js +0 -215
- package/dist/services/tool-protection.service.d.ts +0 -193
- package/dist/services/tool-protection.service.js +0 -736
- package/dist/session/index.d.ts +0 -5
- package/dist/session/index.js +0 -11
- package/dist/session/manager.d.ts +0 -113
- package/dist/session/manager.js +0 -273
- package/dist/types/oauth-required-error.d.ts +0 -46
- package/dist/types/oauth-required-error.js +0 -42
- package/dist/types/tool-protection.d.ts +0 -144
- package/dist/types/tool-protection.js +0 -48
- package/dist/utils/cors.d.ts +0 -44
- package/dist/utils/cors.js +0 -71
- package/dist/utils/index.d.ts +0 -8
- package/dist/utils/index.js +0 -24
- package/dist/utils/storage-keys.d.ts +0 -120
- package/dist/utils/storage-keys.js +0 -217
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Remote Configuration Fetching
|
|
4
|
-
*
|
|
5
|
-
* Service for fetching configuration from remote APIs (AgentShield dashboard)
|
|
6
|
-
* with caching support for performance optimization.
|
|
7
|
-
*
|
|
8
|
-
* @module @kya-os/mcp-i-core/config/remote-config
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.fetchRemoteConfig = fetchRemoteConfig;
|
|
12
|
-
exports.getToolProtection = getToolProtection;
|
|
13
|
-
exports.extractToolProtections = extractToolProtections;
|
|
14
|
-
exports.hasMergedToolProtections = hasMergedToolProtections;
|
|
15
|
-
exports.getPolicy = getPolicy;
|
|
16
|
-
exports.extractPolicy = extractPolicy;
|
|
17
|
-
exports.hasMergedPolicy = hasMergedPolicy;
|
|
18
|
-
exports.isPolicyEnabled = isPolicyEnabled;
|
|
19
|
-
const agentshield_api_1 = require("@kya-os/contracts/agentshield-api");
|
|
20
|
-
const contracts_1 = require("@kya-os/contracts");
|
|
21
|
-
/**
|
|
22
|
-
* Fetch configuration from remote API (AgentShield dashboard)
|
|
23
|
-
*
|
|
24
|
-
* Attempts to fetch configuration from the AgentShield API with caching support.
|
|
25
|
-
* Falls back gracefully if remote fetch fails.
|
|
26
|
-
*
|
|
27
|
-
* @param options - Remote config options
|
|
28
|
-
* @param cache - Optional cache implementation
|
|
29
|
-
* @returns Configuration object or null if fetch fails
|
|
30
|
-
*/
|
|
31
|
-
async function fetchRemoteConfig(options, cache) {
|
|
32
|
-
const { apiUrl, apiKey, projectId, agentDid, cacheTtl = 300000, fetchProvider } = options;
|
|
33
|
-
// Generate cache key
|
|
34
|
-
const cacheKey = projectId
|
|
35
|
-
? `config:project:${projectId}`
|
|
36
|
-
: agentDid
|
|
37
|
-
? `config:agent:${agentDid}`
|
|
38
|
-
: null;
|
|
39
|
-
// Try cache first
|
|
40
|
-
if (cache && cacheKey) {
|
|
41
|
-
try {
|
|
42
|
-
const cached = await cache.get(cacheKey);
|
|
43
|
-
if (cached) {
|
|
44
|
-
try {
|
|
45
|
-
const parsed = JSON.parse(cached);
|
|
46
|
-
if (parsed.expiresAt > Date.now()) {
|
|
47
|
-
return parsed.config;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
catch {
|
|
51
|
-
// Invalid cache entry, continue to fetch
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
// Cache read failed, continue to fetch
|
|
57
|
-
console.warn('[RemoteConfig] Cache read failed:', error);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
// Fetch from API
|
|
61
|
-
try {
|
|
62
|
-
// ❌ REMOVED: Legacy agent-scoped endpoint fallback
|
|
63
|
-
// Agent-only scoping causes cross-user delegation leakage (Priority 3 fallback issue)
|
|
64
|
-
// projectId is now REQUIRED for proper user isolation
|
|
65
|
-
if (!projectId) {
|
|
66
|
-
console.error('[RemoteConfig] projectId is required for user-scoped delegation. ' +
|
|
67
|
-
'Agent-only scoping has been deprecated due to security concerns (cross-user delegation leakage). ' +
|
|
68
|
-
'Please configure AGENTSHIELD_PROJECT_ID environment variable.');
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
// ✅ PROJECT-SCOPED ENDPOINT: Ensures delegations are properly scoped to user+agent
|
|
72
|
-
const url = `${apiUrl}${agentshield_api_1.AGENTSHIELD_ENDPOINTS.CONFIG(projectId)}`;
|
|
73
|
-
const response = await fetchProvider(url, {
|
|
74
|
-
headers: {
|
|
75
|
-
'Authorization': `Bearer ${apiKey}`,
|
|
76
|
-
'Content-Type': 'application/json'
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
if (!response.ok) {
|
|
80
|
-
console.warn(`[RemoteConfig] API returned ${response.status}: ${response.statusText}`);
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
const data = await response.json();
|
|
84
|
-
// Extract config from API response
|
|
85
|
-
// API response format: { success: boolean, data: { config: MCPIConfig } }
|
|
86
|
-
const responseData = data;
|
|
87
|
-
const config = responseData.config || responseData.data?.config || (responseData.success ? responseData.data : null);
|
|
88
|
-
if (!config) {
|
|
89
|
-
console.warn('[RemoteConfig] No config found in API response');
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
// Cache the result
|
|
93
|
-
if (cache && cacheKey) {
|
|
94
|
-
try {
|
|
95
|
-
await cache.set(cacheKey, JSON.stringify({
|
|
96
|
-
config,
|
|
97
|
-
expiresAt: Date.now() + cacheTtl
|
|
98
|
-
}), cacheTtl);
|
|
99
|
-
}
|
|
100
|
-
catch (error) {
|
|
101
|
-
// Cache write failed, but we got the config so continue
|
|
102
|
-
console.warn('[RemoteConfig] Cache write failed:', error);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return config;
|
|
106
|
-
}
|
|
107
|
-
catch (error) {
|
|
108
|
-
console.warn('[RemoteConfig] Failed to fetch config:', error);
|
|
109
|
-
return null;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Get tool protection for a specific tool from a merged config
|
|
114
|
-
*
|
|
115
|
-
* This helper function extracts tool protection from a merged config response.
|
|
116
|
-
* It handles both the new format (toolProtection.tools) and returns null
|
|
117
|
-
* for unprotected or unknown tools.
|
|
118
|
-
*
|
|
119
|
-
* @param config - Merged config object (must have toolProtection.tools)
|
|
120
|
-
* @param toolName - Name of the tool to look up
|
|
121
|
-
* @returns Tool protection or null if tool not protected or not found
|
|
122
|
-
*
|
|
123
|
-
* @since 1.6.0
|
|
124
|
-
*/
|
|
125
|
-
function getToolProtection(config, toolName) {
|
|
126
|
-
const tools = config?.toolProtection?.tools;
|
|
127
|
-
if (!tools) {
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
// Check for specific tool protection first
|
|
131
|
-
let protection = tools[toolName];
|
|
132
|
-
// Fall back to wildcard protection if specific tool not found
|
|
133
|
-
if (!protection && tools['*']) {
|
|
134
|
-
protection = tools['*'];
|
|
135
|
-
}
|
|
136
|
-
// Return null for unprotected tools (requiresDelegation: false) or unknown tools
|
|
137
|
-
if (!protection || !protection.requiresDelegation) {
|
|
138
|
-
return null;
|
|
139
|
-
}
|
|
140
|
-
return protection;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Extract tool protections map from merged config
|
|
144
|
-
*
|
|
145
|
-
* This helper function extracts the tool protections map from a merged config.
|
|
146
|
-
* Returns an empty object if no tools are found.
|
|
147
|
-
*
|
|
148
|
-
* @param config - Config object that may contain toolProtection.tools
|
|
149
|
-
* @returns Tool protection map or empty object
|
|
150
|
-
*
|
|
151
|
-
* @since 1.6.0
|
|
152
|
-
*/
|
|
153
|
-
function extractToolProtections(config) {
|
|
154
|
-
if (!config?.toolProtection?.tools) {
|
|
155
|
-
return {};
|
|
156
|
-
}
|
|
157
|
-
return config.toolProtection.tools;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Check if config has embedded tool protections
|
|
161
|
-
*
|
|
162
|
-
* Utility to check if a config response is in the new merged format
|
|
163
|
-
* with embedded tool protections.
|
|
164
|
-
*
|
|
165
|
-
* @param config - Config object to check
|
|
166
|
-
* @returns True if config has embedded tools, false otherwise
|
|
167
|
-
*
|
|
168
|
-
* @since 1.6.0
|
|
169
|
-
*/
|
|
170
|
-
function hasMergedToolProtections(config) {
|
|
171
|
-
if (!config || typeof config !== 'object') {
|
|
172
|
-
return false;
|
|
173
|
-
}
|
|
174
|
-
const c = config;
|
|
175
|
-
return (c.toolProtection !== undefined &&
|
|
176
|
-
typeof c.toolProtection === 'object' &&
|
|
177
|
-
c.toolProtection !== null &&
|
|
178
|
-
'tools' in c.toolProtection &&
|
|
179
|
-
typeof c.toolProtection.tools === 'object' &&
|
|
180
|
-
c.toolProtection.tools !== null // typeof null === 'object' in JS
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
// ============================================================================
|
|
184
|
-
// Policy Configuration Helpers
|
|
185
|
-
// ============================================================================
|
|
186
|
-
/**
|
|
187
|
-
* Get policy configuration from a merged config
|
|
188
|
-
*
|
|
189
|
-
* This helper function extracts policy configuration from a merged config response.
|
|
190
|
-
* Returns null if no policy is present in the config.
|
|
191
|
-
*
|
|
192
|
-
* @param config - Config object that may contain policy
|
|
193
|
-
* @returns Policy configuration or null if not present
|
|
194
|
-
*
|
|
195
|
-
* @since 1.7.0
|
|
196
|
-
*/
|
|
197
|
-
function getPolicy(config) {
|
|
198
|
-
if (!config?.policy) {
|
|
199
|
-
return null;
|
|
200
|
-
}
|
|
201
|
-
return config.policy;
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Extract policy configuration from merged config with defaults
|
|
205
|
-
*
|
|
206
|
-
* This helper function extracts the policy from a merged config.
|
|
207
|
-
* Returns the default policy config if no policy is found.
|
|
208
|
-
*
|
|
209
|
-
* @param config - Config object that may contain policy
|
|
210
|
-
* @returns Policy configuration (never null, returns defaults if missing)
|
|
211
|
-
*
|
|
212
|
-
* @since 1.7.0
|
|
213
|
-
*/
|
|
214
|
-
function extractPolicy(config) {
|
|
215
|
-
if (!config?.policy) {
|
|
216
|
-
// Return a deep clone to prevent mutation of the shared default
|
|
217
|
-
return structuredClone(contracts_1.DEFAULT_POLICY_CONFIG);
|
|
218
|
-
}
|
|
219
|
-
return config.policy;
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Check if config has embedded policy configuration
|
|
223
|
-
*
|
|
224
|
-
* Utility to check if a config response includes policy configuration.
|
|
225
|
-
*
|
|
226
|
-
* @param config - Config object to check
|
|
227
|
-
* @returns True if config has policy, false otherwise
|
|
228
|
-
*
|
|
229
|
-
* @since 1.7.0
|
|
230
|
-
*/
|
|
231
|
-
function hasMergedPolicy(config) {
|
|
232
|
-
if (!config || typeof config !== 'object') {
|
|
233
|
-
return false;
|
|
234
|
-
}
|
|
235
|
-
const c = config;
|
|
236
|
-
return (c.policy !== undefined &&
|
|
237
|
-
typeof c.policy === 'object' &&
|
|
238
|
-
c.policy !== null);
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Check if policy enforcement is enabled for a config
|
|
242
|
-
*
|
|
243
|
-
* @param config - Config object that may contain policy
|
|
244
|
-
* @returns True if policy is present and enabled
|
|
245
|
-
*
|
|
246
|
-
* @since 1.7.0
|
|
247
|
-
*/
|
|
248
|
-
function isPolicyEnabled(config) {
|
|
249
|
-
const policy = getPolicy(config);
|
|
250
|
-
// Default to true to match DEFAULT_POLICY_CONFIG.enabled and PolicyService.isEnabled()
|
|
251
|
-
return policy?.enabled ?? true;
|
|
252
|
-
}
|
|
253
|
-
//# sourceMappingURL=remote-config.js.map
|
package/dist/config.d.ts
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Provider-based Runtime Configuration
|
|
3
|
-
*
|
|
4
|
-
* Core configuration for MCP-I runtime using the provider pattern.
|
|
5
|
-
* This is the foundation for all platform-specific implementations.
|
|
6
|
-
*
|
|
7
|
-
* @module @kya-os/mcp-i-core/config
|
|
8
|
-
*/
|
|
9
|
-
import type { MCPIBaseConfig, RuntimeIdentityConfig, ProofingConfig, DelegationConfig, ToolProtectionSourceConfig } from '@kya-os/contracts/config';
|
|
10
|
-
import type { CryptoProvider, ClockProvider, FetchProvider, StorageProvider, NonceCacheProvider, IdentityProvider } from './providers/base';
|
|
11
|
-
import type { ToolProtectionService } from './services/tool-protection.service';
|
|
12
|
-
/**
|
|
13
|
-
* Provider-based runtime configuration
|
|
14
|
-
*
|
|
15
|
-
* This configuration is used internally by MCPIRuntimeBase and provides
|
|
16
|
-
* the foundation for all platform-specific implementations. It uses the
|
|
17
|
-
* provider pattern for platform abstraction, allowing different implementations
|
|
18
|
-
* for Node.js, Cloudflare Workers, and other environments.
|
|
19
|
-
*/
|
|
20
|
-
export interface ProviderRuntimeConfig extends MCPIBaseConfig {
|
|
21
|
-
/**
|
|
22
|
-
* Cryptographic operations provider
|
|
23
|
-
* Handles signing, verification, and key generation
|
|
24
|
-
*/
|
|
25
|
-
cryptoProvider: CryptoProvider;
|
|
26
|
-
/**
|
|
27
|
-
* Time operations provider
|
|
28
|
-
* Provides current time and timestamp generation
|
|
29
|
-
*/
|
|
30
|
-
clockProvider: ClockProvider;
|
|
31
|
-
/**
|
|
32
|
-
* HTTP fetch operations provider
|
|
33
|
-
* Handles external API calls
|
|
34
|
-
*/
|
|
35
|
-
fetchProvider: FetchProvider;
|
|
36
|
-
/**
|
|
37
|
-
* Storage operations provider
|
|
38
|
-
* Handles persistent data storage
|
|
39
|
-
*/
|
|
40
|
-
storageProvider: StorageProvider;
|
|
41
|
-
/**
|
|
42
|
-
* Nonce cache provider
|
|
43
|
-
* Handles replay prevention
|
|
44
|
-
*/
|
|
45
|
-
nonceCacheProvider: NonceCacheProvider;
|
|
46
|
-
/**
|
|
47
|
-
* Identity management provider
|
|
48
|
-
* Handles agent identity and DID operations
|
|
49
|
-
*/
|
|
50
|
-
identityProvider: IdentityProvider;
|
|
51
|
-
/**
|
|
52
|
-
* Session configuration
|
|
53
|
-
* Controls session handling and timeouts
|
|
54
|
-
*/
|
|
55
|
-
session?: {
|
|
56
|
-
/**
|
|
57
|
-
* Allowed timestamp skew in seconds
|
|
58
|
-
* @default 120
|
|
59
|
-
*/
|
|
60
|
-
timestampSkewSeconds?: number;
|
|
61
|
-
/**
|
|
62
|
-
* Session TTL in minutes
|
|
63
|
-
* @default 30
|
|
64
|
-
*/
|
|
65
|
-
ttlMinutes?: number;
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* Identity configuration (optional)
|
|
69
|
-
* When provided, enables identity features
|
|
70
|
-
*/
|
|
71
|
-
identity?: RuntimeIdentityConfig;
|
|
72
|
-
/**
|
|
73
|
-
* Proofing configuration (optional)
|
|
74
|
-
* When provided, enables proof generation
|
|
75
|
-
*/
|
|
76
|
-
proofing?: ProofingConfig;
|
|
77
|
-
/**
|
|
78
|
-
* Delegation configuration (optional)
|
|
79
|
-
* When provided, enables delegation verification
|
|
80
|
-
*/
|
|
81
|
-
delegation?: DelegationConfig;
|
|
82
|
-
/**
|
|
83
|
-
* Tool protection service (optional)
|
|
84
|
-
* When provided, enables runtime tool protection
|
|
85
|
-
* Note: This is different from tool registry which is compile-time
|
|
86
|
-
*/
|
|
87
|
-
toolProtectionService?: ToolProtectionService;
|
|
88
|
-
/**
|
|
89
|
-
* Tool protection source configuration (optional)
|
|
90
|
-
* Alternative to toolProtectionService for configuration-based setup
|
|
91
|
-
*/
|
|
92
|
-
toolProtection?: ToolProtectionSourceConfig;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Builder for provider runtime configuration
|
|
96
|
-
* Helps create valid configurations with proper defaults
|
|
97
|
-
*/
|
|
98
|
-
export declare class ProviderRuntimeConfigBuilder {
|
|
99
|
-
private config;
|
|
100
|
-
/**
|
|
101
|
-
* Set the providers (required)
|
|
102
|
-
*/
|
|
103
|
-
withProviders(providers: {
|
|
104
|
-
cryptoProvider: CryptoProvider;
|
|
105
|
-
clockProvider: ClockProvider;
|
|
106
|
-
fetchProvider: FetchProvider;
|
|
107
|
-
storageProvider: StorageProvider;
|
|
108
|
-
nonceCacheProvider: NonceCacheProvider;
|
|
109
|
-
identityProvider: IdentityProvider;
|
|
110
|
-
}): this;
|
|
111
|
-
/**
|
|
112
|
-
* Set the environment
|
|
113
|
-
*/
|
|
114
|
-
withEnvironment(env: 'development' | 'production'): this;
|
|
115
|
-
/**
|
|
116
|
-
* Configure session handling
|
|
117
|
-
*/
|
|
118
|
-
withSession(session: {
|
|
119
|
-
timestampSkewSeconds?: number;
|
|
120
|
-
ttlMinutes?: number;
|
|
121
|
-
}): this;
|
|
122
|
-
/**
|
|
123
|
-
* Enable identity features
|
|
124
|
-
*/
|
|
125
|
-
withIdentity(identity: RuntimeIdentityConfig): this;
|
|
126
|
-
/**
|
|
127
|
-
* Enable proofing features
|
|
128
|
-
*/
|
|
129
|
-
withProofing(proofing: ProofingConfig): this;
|
|
130
|
-
/**
|
|
131
|
-
* Enable delegation features
|
|
132
|
-
*/
|
|
133
|
-
withDelegation(delegation: DelegationConfig): this;
|
|
134
|
-
/**
|
|
135
|
-
* Set tool protection service
|
|
136
|
-
*/
|
|
137
|
-
withToolProtectionService(service: ToolProtectionService): this;
|
|
138
|
-
/**
|
|
139
|
-
* Set tool protection configuration
|
|
140
|
-
*/
|
|
141
|
-
withToolProtection(config: ToolProtectionSourceConfig): this;
|
|
142
|
-
/**
|
|
143
|
-
* Enable audit features
|
|
144
|
-
*/
|
|
145
|
-
withAudit(audit: {
|
|
146
|
-
enabled: boolean;
|
|
147
|
-
includeProofHashes?: boolean;
|
|
148
|
-
}): this;
|
|
149
|
-
/**
|
|
150
|
-
* Enable well-known endpoints
|
|
151
|
-
*/
|
|
152
|
-
withWellKnown(wellKnown: {
|
|
153
|
-
enabled: boolean;
|
|
154
|
-
serviceName?: string;
|
|
155
|
-
}): this;
|
|
156
|
-
/**
|
|
157
|
-
* Build the configuration
|
|
158
|
-
* Validates that all required providers are set
|
|
159
|
-
*/
|
|
160
|
-
build(): ProviderRuntimeConfig;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Re-export base types for convenience
|
|
164
|
-
*/
|
|
165
|
-
export type { MCPIBaseConfig, RuntimeIdentityConfig as BaseIdentityConfig, ProofingConfig, DelegationConfig, ToolProtectionSourceConfig } from '@kya-os/contracts/config';
|
|
166
|
-
/**
|
|
167
|
-
* Re-export remote config utilities
|
|
168
|
-
*/
|
|
169
|
-
export { fetchRemoteConfig, getToolProtection, extractToolProtections, hasMergedToolProtections, type RemoteConfigOptions, type RemoteConfigCache } from './config/remote-config';
|
|
170
|
-
/**
|
|
171
|
-
* Create a provider runtime configuration
|
|
172
|
-
* Convenience function for creating configurations
|
|
173
|
-
*/
|
|
174
|
-
export declare function createProviderRuntimeConfig(providers: {
|
|
175
|
-
cryptoProvider: CryptoProvider;
|
|
176
|
-
clockProvider: ClockProvider;
|
|
177
|
-
fetchProvider: FetchProvider;
|
|
178
|
-
storageProvider: StorageProvider;
|
|
179
|
-
nonceCacheProvider: NonceCacheProvider;
|
|
180
|
-
identityProvider: IdentityProvider;
|
|
181
|
-
}, options?: Partial<Omit<ProviderRuntimeConfig, keyof typeof providers>>): ProviderRuntimeConfig;
|
|
182
|
-
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.js
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Provider-based Runtime Configuration
|
|
4
|
-
*
|
|
5
|
-
* Core configuration for MCP-I runtime using the provider pattern.
|
|
6
|
-
* This is the foundation for all platform-specific implementations.
|
|
7
|
-
*
|
|
8
|
-
* @module @kya-os/mcp-i-core/config
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.hasMergedToolProtections = exports.extractToolProtections = exports.getToolProtection = exports.fetchRemoteConfig = exports.ProviderRuntimeConfigBuilder = void 0;
|
|
12
|
-
exports.createProviderRuntimeConfig = createProviderRuntimeConfig;
|
|
13
|
-
/**
|
|
14
|
-
* Builder for provider runtime configuration
|
|
15
|
-
* Helps create valid configurations with proper defaults
|
|
16
|
-
*/
|
|
17
|
-
class ProviderRuntimeConfigBuilder {
|
|
18
|
-
config = {
|
|
19
|
-
environment: 'development'
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Set the providers (required)
|
|
23
|
-
*/
|
|
24
|
-
withProviders(providers) {
|
|
25
|
-
Object.assign(this.config, providers);
|
|
26
|
-
return this;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Set the environment
|
|
30
|
-
*/
|
|
31
|
-
withEnvironment(env) {
|
|
32
|
-
this.config.environment = env;
|
|
33
|
-
return this;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Configure session handling
|
|
37
|
-
*/
|
|
38
|
-
withSession(session) {
|
|
39
|
-
this.config.session = session;
|
|
40
|
-
return this;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Enable identity features
|
|
44
|
-
*/
|
|
45
|
-
withIdentity(identity) {
|
|
46
|
-
this.config.identity = identity;
|
|
47
|
-
return this;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Enable proofing features
|
|
51
|
-
*/
|
|
52
|
-
withProofing(proofing) {
|
|
53
|
-
this.config.proofing = proofing;
|
|
54
|
-
return this;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Enable delegation features
|
|
58
|
-
*/
|
|
59
|
-
withDelegation(delegation) {
|
|
60
|
-
this.config.delegation = delegation;
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Set tool protection service
|
|
65
|
-
*/
|
|
66
|
-
withToolProtectionService(service) {
|
|
67
|
-
this.config.toolProtectionService = service;
|
|
68
|
-
return this;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Set tool protection configuration
|
|
72
|
-
*/
|
|
73
|
-
withToolProtection(config) {
|
|
74
|
-
this.config.toolProtection = config;
|
|
75
|
-
return this;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Enable audit features
|
|
79
|
-
*/
|
|
80
|
-
withAudit(audit) {
|
|
81
|
-
this.config.audit = audit;
|
|
82
|
-
return this;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Enable well-known endpoints
|
|
86
|
-
*/
|
|
87
|
-
withWellKnown(wellKnown) {
|
|
88
|
-
this.config.wellKnown = wellKnown;
|
|
89
|
-
return this;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Build the configuration
|
|
93
|
-
* Validates that all required providers are set
|
|
94
|
-
*/
|
|
95
|
-
build() {
|
|
96
|
-
const required = [
|
|
97
|
-
'cryptoProvider',
|
|
98
|
-
'clockProvider',
|
|
99
|
-
'fetchProvider',
|
|
100
|
-
'storageProvider',
|
|
101
|
-
'nonceCacheProvider',
|
|
102
|
-
'identityProvider'
|
|
103
|
-
];
|
|
104
|
-
for (const field of required) {
|
|
105
|
-
if (!(field in this.config)) {
|
|
106
|
-
throw new Error(`Missing required provider: ${field}`);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
// Apply defaults
|
|
110
|
-
return {
|
|
111
|
-
environment: 'development',
|
|
112
|
-
session: {
|
|
113
|
-
timestampSkewSeconds: 120,
|
|
114
|
-
ttlMinutes: 30
|
|
115
|
-
},
|
|
116
|
-
...this.config
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
exports.ProviderRuntimeConfigBuilder = ProviderRuntimeConfigBuilder;
|
|
121
|
-
/**
|
|
122
|
-
* Re-export remote config utilities
|
|
123
|
-
*/
|
|
124
|
-
var remote_config_1 = require("./config/remote-config");
|
|
125
|
-
Object.defineProperty(exports, "fetchRemoteConfig", { enumerable: true, get: function () { return remote_config_1.fetchRemoteConfig; } });
|
|
126
|
-
Object.defineProperty(exports, "getToolProtection", { enumerable: true, get: function () { return remote_config_1.getToolProtection; } });
|
|
127
|
-
Object.defineProperty(exports, "extractToolProtections", { enumerable: true, get: function () { return remote_config_1.extractToolProtections; } });
|
|
128
|
-
Object.defineProperty(exports, "hasMergedToolProtections", { enumerable: true, get: function () { return remote_config_1.hasMergedToolProtections; } });
|
|
129
|
-
/**
|
|
130
|
-
* Create a provider runtime configuration
|
|
131
|
-
* Convenience function for creating configurations
|
|
132
|
-
*/
|
|
133
|
-
function createProviderRuntimeConfig(providers, options) {
|
|
134
|
-
return new ProviderRuntimeConfigBuilder()
|
|
135
|
-
.withProviders(providers)
|
|
136
|
-
.withEnvironment(options?.environment || 'development')
|
|
137
|
-
.withSession(options?.session || {})
|
|
138
|
-
.withIdentity(options?.identity || { enabled: false, environment: 'development' })
|
|
139
|
-
.withProofing(options?.proofing || { enabled: false })
|
|
140
|
-
.withDelegation(options?.delegation || {
|
|
141
|
-
enabled: false,
|
|
142
|
-
verifier: { type: 'memory' }
|
|
143
|
-
})
|
|
144
|
-
.withAudit(options?.audit || { enabled: false })
|
|
145
|
-
.withWellKnown(options?.wellKnown || { enabled: true })
|
|
146
|
-
.build();
|
|
147
|
-
}
|
|
148
|
-
//# sourceMappingURL=config.js.map
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* IDP Token Resolver
|
|
3
|
-
*
|
|
4
|
-
* Resolves User DID to IDP access token (MH-7 requirement).
|
|
5
|
-
* Handles token lookup, expiration checking, and automatic refresh.
|
|
6
|
-
*
|
|
7
|
-
* Updated for CRED-003: Returns full token data including usage metadata
|
|
8
|
-
* to support credential providers with custom token usage patterns.
|
|
9
|
-
*
|
|
10
|
-
* @package @kya-os/mcp-i-core
|
|
11
|
-
*/
|
|
12
|
-
import type { IdpTokens } from "@kya-os/contracts/config";
|
|
13
|
-
import type { IIdpTokenStorage, IdpTokensWithMetadata } from "./idp-token-storage.interface.js";
|
|
14
|
-
export interface IdpTokenResolverConfig {
|
|
15
|
-
/** Token storage implementation */
|
|
16
|
-
tokenStorage: IIdpTokenStorage;
|
|
17
|
-
/** OAuth service for token refresh */
|
|
18
|
-
oauthService: {
|
|
19
|
-
refreshToken(provider: string, refreshToken: string): Promise<IdpTokens | null>;
|
|
20
|
-
};
|
|
21
|
-
/** Optional logger callback for diagnostics */
|
|
22
|
-
logger?: (message: string, data?: unknown) => void;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Service for resolving User DID to IDP access token
|
|
26
|
-
*
|
|
27
|
-
* MH-7 Requirement: resolveTokenFromDid(userDid: string): Promise<string>
|
|
28
|
-
*
|
|
29
|
-
* This service implements the core MH-7 functionality:
|
|
30
|
-
* - Resolves User DID to IDP access token
|
|
31
|
-
* - Handles token expiration and automatic refresh
|
|
32
|
-
* - Supports multiple IDP providers
|
|
33
|
-
*/
|
|
34
|
-
export declare class IdpTokenResolver {
|
|
35
|
-
private config;
|
|
36
|
-
constructor(config: IdpTokenResolverConfig);
|
|
37
|
-
/**
|
|
38
|
-
* Resolve User DID to IDP access token
|
|
39
|
-
*
|
|
40
|
-
* MH-7 Requirement: resolveTokenFromDid(userDid: string): Promise<string>
|
|
41
|
-
*
|
|
42
|
-
* Flow:
|
|
43
|
-
* 1. Look up token from storage
|
|
44
|
-
* 2. Check expiration
|
|
45
|
-
* 3. Auto-refresh if expired and refresh_token available
|
|
46
|
-
* 4. Update storage after refresh
|
|
47
|
-
* 5. Return access_token or null
|
|
48
|
-
*
|
|
49
|
-
* @param userDid - User DID to resolve
|
|
50
|
-
* @param provider - OAuth provider name (e.g., "github", "google")
|
|
51
|
-
* @param scopes - Required scopes for token
|
|
52
|
-
* @returns Access token or null if not found/expired
|
|
53
|
-
*/
|
|
54
|
-
resolveTokenFromDid(userDid: string, provider: string, scopes: string[]): Promise<string | null>;
|
|
55
|
-
/**
|
|
56
|
-
* Resolve User DID to full IDP token data (CRED-003)
|
|
57
|
-
*
|
|
58
|
-
* Returns the full token data including usage metadata for credential providers.
|
|
59
|
-
* This allows ToolContextBuilder to construct appropriate headers based on
|
|
60
|
-
* tokenUsage (cookie/bearer/header) and cookieFormat.
|
|
61
|
-
*
|
|
62
|
-
* @param userDid - User DID to resolve
|
|
63
|
-
* @param provider - OAuth provider name or credential provider
|
|
64
|
-
* @param scopes - Required scopes for token
|
|
65
|
-
* @returns Full token data with metadata or null if not found/expired
|
|
66
|
-
*/
|
|
67
|
-
resolveTokenDataFromDid(userDid: string, provider: string, scopes: string[]): Promise<IdpTokensWithMetadata | null>;
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=idp-token-resolver.d.ts.map
|