@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,135 +0,0 @@
1
- "use strict";
2
- /**
3
- * Provider Validator
4
- *
5
- * Validates OAuth provider configurations for custom IDP support.
6
- * Ensures provider configurations are valid before registration.
7
- *
8
- * @package @kya-os/mcp-i-core
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.ProviderValidator = exports.ProviderValidationError = void 0;
12
- /**
13
- * Reserved OAuth parameters that cannot be overridden by custom parameters
14
- */
15
- const RESERVED_PARAMETERS = [
16
- "response_type",
17
- "client_id",
18
- "redirect_uri",
19
- "scope",
20
- "state",
21
- "code_challenge",
22
- "code_challenge_method",
23
- ];
24
- /**
25
- * Validation error for provider configuration issues
26
- */
27
- class ProviderValidationError extends Error {
28
- field;
29
- constructor(message, field) {
30
- super(message);
31
- this.field = field;
32
- this.name = "ProviderValidationError";
33
- }
34
- }
35
- exports.ProviderValidationError = ProviderValidationError;
36
- /**
37
- * Service for validating OAuth provider configurations
38
- */
39
- class ProviderValidator {
40
- /**
41
- * Validate provider configuration
42
- *
43
- * @param provider - Provider configuration to validate
44
- * @param name - Provider name (for error messages)
45
- * @throws ProviderValidationError if validation fails
46
- */
47
- validate(provider, name) {
48
- // Validate required fields
49
- if (!provider.clientId || provider.clientId.trim().length === 0) {
50
- throw new ProviderValidationError(`Provider "${name}" must have a clientId`, "clientId");
51
- }
52
- if (!provider.authorizationUrl || provider.authorizationUrl.trim().length === 0) {
53
- throw new ProviderValidationError(`Provider "${name}" must have an authorizationUrl`, "authorizationUrl");
54
- }
55
- if (!provider.tokenUrl || provider.tokenUrl.trim().length === 0) {
56
- throw new ProviderValidationError(`Provider "${name}" must have a tokenUrl`, "tokenUrl");
57
- }
58
- // Validate URL formats
59
- this.validateUrl(provider.authorizationUrl, name, "authorizationUrl");
60
- this.validateUrl(provider.tokenUrl, name, "tokenUrl");
61
- if (provider.userInfoUrl) {
62
- this.validateUrl(provider.userInfoUrl, name, "userInfoUrl");
63
- }
64
- // Validate proxy mode requirements
65
- if (provider.proxyMode && !provider.requiresClientSecret) {
66
- throw new ProviderValidationError(`Provider "${name}" with proxyMode=true must have requiresClientSecret=true`, "proxyMode");
67
- }
68
- // Validate custom parameters don't conflict with reserved parameters
69
- if (provider.customParams) {
70
- this.validateCustomParams(provider.customParams, name);
71
- }
72
- }
73
- /**
74
- * Validate URL format
75
- *
76
- * @param url - URL to validate
77
- * @param providerName - Provider name (for error messages)
78
- * @param fieldName - Field name (for error messages)
79
- * @throws ProviderValidationError if URL is invalid
80
- */
81
- validateUrl(url, providerName, fieldName) {
82
- try {
83
- const parsedUrl = new URL(url);
84
- if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") {
85
- throw new ProviderValidationError(`Provider "${providerName}" ${fieldName} must use HTTP or HTTPS protocol`, fieldName);
86
- }
87
- }
88
- catch (error) {
89
- if (error instanceof ProviderValidationError) {
90
- throw error;
91
- }
92
- throw new ProviderValidationError(`Provider "${providerName}" ${fieldName} is not a valid URL: ${error instanceof Error ? error.message : String(error)}`, fieldName);
93
- }
94
- }
95
- /**
96
- * Validate custom parameters don't override reserved OAuth parameters
97
- *
98
- * @param customParams - Custom parameters to validate
99
- * @param providerName - Provider name (for error messages)
100
- * @throws ProviderValidationError if reserved parameter is overridden
101
- */
102
- validateCustomParams(customParams, providerName) {
103
- for (const [key, value] of Object.entries(customParams)) {
104
- const normalizedKey = key.toLowerCase();
105
- if (RESERVED_PARAMETERS.includes(normalizedKey)) {
106
- throw new ProviderValidationError(`Provider "${providerName}" custom parameter "${key}" conflicts with reserved OAuth parameter. Reserved parameters: ${RESERVED_PARAMETERS.join(", ")}`, `customParams.${key}`);
107
- }
108
- if (!value || value.trim().length === 0) {
109
- throw new ProviderValidationError(`Provider "${providerName}" custom parameter "${key}" has empty value`, `customParams.${key}`);
110
- }
111
- }
112
- }
113
- /**
114
- * Test provider endpoint reachability (optional)
115
- *
116
- * @param provider - Provider configuration
117
- * @param fetchProvider - Fetch implementation
118
- * @returns True if endpoint is reachable, false otherwise
119
- */
120
- async testProvider(provider, fetchProvider) {
121
- try {
122
- // Test authorization URL (HEAD request to avoid triggering OAuth flow)
123
- const authResponse = await fetchProvider(provider.authorizationUrl, {
124
- method: "HEAD",
125
- signal: AbortSignal.timeout(5000), // 5 second timeout
126
- });
127
- return authResponse.ok || authResponse.status === 405; // 405 Method Not Allowed is OK
128
- }
129
- catch (error) {
130
- return false;
131
- }
132
- }
133
- }
134
- exports.ProviderValidator = ProviderValidator;
135
- //# sourceMappingURL=provider-validator.js.map
@@ -1,80 +0,0 @@
1
- /**
2
- * Session Registration Service
3
- *
4
- * Registers MCP sessions with the AgentShield dashboard, enabling
5
- * visibility into which MCP clients are connecting to agents.
6
- *
7
- * This is a fire-and-forget service - session registration should not
8
- * block tool execution or affect the user experience.
9
- *
10
- * @package @kya-os/mcp-i-core
11
- */
12
- import type { RegisterSessionRequest } from "@kya-os/contracts/agentshield-api";
13
- import type { FetchProvider } from "../providers/base.js";
14
- /**
15
- * Configuration for the session registration service
16
- */
17
- export interface SessionRegistrationServiceConfig {
18
- /** Base URL for the AgentShield API (e.g., "https://kya.vouched.id") */
19
- baseUrl: string;
20
- /** API key for authentication */
21
- apiKey: string;
22
- /** Fetch provider for making HTTP requests (platform-agnostic) */
23
- fetchProvider: FetchProvider;
24
- /** Optional logger callback for diagnostics */
25
- logger?: (message: string, data?: unknown) => void;
26
- /** Timeout in milliseconds for the registration request (default: 5000) */
27
- timeoutMs?: number;
28
- }
29
- /**
30
- * Result of a session registration attempt
31
- */
32
- export interface SessionRegistrationResult {
33
- /** Whether registration was successful */
34
- success: boolean;
35
- /** Session ID that was registered */
36
- sessionId: string;
37
- /** Error message if registration failed */
38
- error?: string;
39
- }
40
- /**
41
- * Session Registration Service
42
- *
43
- * Registers MCP sessions with AgentShield for dashboard visibility.
44
- * Designed to be non-blocking - failures are logged but don't throw.
45
- */
46
- export declare class SessionRegistrationService {
47
- private config;
48
- constructor(config: SessionRegistrationServiceConfig);
49
- /**
50
- * Register a session with AgentShield
51
- *
52
- * This is a fire-and-forget operation. Failures are logged but don't throw.
53
- * The method returns quickly and doesn't block the caller.
54
- *
55
- * @param request - Session registration request data
56
- * @returns Result indicating success or failure
57
- */
58
- registerSession(request: RegisterSessionRequest): Promise<SessionRegistrationResult>;
59
- /**
60
- * Fire-and-forget session registration
61
- *
62
- * Starts registration in the background without waiting for completion.
63
- * Useful when you want to register a session but not delay the response.
64
- *
65
- * @param request - Session registration request data
66
- */
67
- registerSessionAsync(request: RegisterSessionRequest): void;
68
- }
69
- /**
70
- * Create a session registration service from common runtime config
71
- *
72
- * Helper function to create the service from typical environment config.
73
- */
74
- export declare function createSessionRegistrationService(options: {
75
- apiUrl: string;
76
- apiKey: string;
77
- fetchProvider: FetchProvider;
78
- logger?: (message: string, data?: unknown) => void;
79
- }): SessionRegistrationService | null;
80
- //# sourceMappingURL=session-registration.service.d.ts.map
@@ -1,174 +0,0 @@
1
- "use strict";
2
- /**
3
- * Session Registration Service
4
- *
5
- * Registers MCP sessions with the AgentShield dashboard, enabling
6
- * visibility into which MCP clients are connecting to agents.
7
- *
8
- * This is a fire-and-forget service - session registration should not
9
- * block tool execution or affect the user experience.
10
- *
11
- * @package @kya-os/mcp-i-core
12
- */
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.SessionRegistrationService = void 0;
15
- exports.createSessionRegistrationService = createSessionRegistrationService;
16
- const agentshield_api_1 = require("@kya-os/contracts/agentshield-api");
17
- /**
18
- * Session Registration Service
19
- *
20
- * Registers MCP sessions with AgentShield for dashboard visibility.
21
- * Designed to be non-blocking - failures are logged but don't throw.
22
- */
23
- class SessionRegistrationService {
24
- config;
25
- constructor(config) {
26
- this.config = {
27
- baseUrl: config.baseUrl,
28
- apiKey: config.apiKey,
29
- fetchProvider: config.fetchProvider,
30
- logger: config.logger || (() => { }),
31
- timeoutMs: config.timeoutMs ?? 5000,
32
- };
33
- }
34
- /**
35
- * Register a session with AgentShield
36
- *
37
- * This is a fire-and-forget operation. Failures are logged but don't throw.
38
- * The method returns quickly and doesn't block the caller.
39
- *
40
- * @param request - Session registration request data
41
- * @returns Result indicating success or failure
42
- */
43
- async registerSession(request) {
44
- const sessionId = request.session_id;
45
- try {
46
- // Validate request
47
- const validationResult = agentshield_api_1.registerSessionRequestSchema.safeParse(request);
48
- if (!validationResult.success) {
49
- const errorMsg = `Invalid session registration request: ${validationResult.error.message}`;
50
- this.config.logger("[SessionRegistration] Validation failed", {
51
- sessionId,
52
- error: errorMsg,
53
- });
54
- return { success: false, sessionId, error: errorMsg };
55
- }
56
- const url = `${this.config.baseUrl}${agentshield_api_1.AGENTSHIELD_ENDPOINTS.SESSIONS}`;
57
- // NOTE: This registers the SESSION with AgentShield for dashboard visibility
58
- // This is NOT the same as agent registration with Know That AI (which happens during deploy)
59
- this.config.logger("[SessionRegistration] Registering session for dashboard visibility", {
60
- sessionId,
61
- agentDid: request.agent_did,
62
- clientName: request.client_info.name,
63
- url,
64
- });
65
- // Make the request with timeout
66
- const controller = new AbortController();
67
- const timeoutId = setTimeout(() => controller.abort(), this.config.timeoutMs);
68
- try {
69
- const response = await this.config.fetchProvider.fetch(url, {
70
- method: "POST",
71
- headers: {
72
- "Content-Type": "application/json",
73
- Authorization: `Bearer ${this.config.apiKey}`,
74
- },
75
- body: JSON.stringify(request),
76
- signal: controller.signal,
77
- });
78
- clearTimeout(timeoutId);
79
- if (!response.ok) {
80
- // Log error but don't throw - this is fire-and-forget
81
- const errorText = await response.text().catch(() => "Unknown error");
82
- this.config.logger("[SessionRegistration] Registration failed", {
83
- sessionId,
84
- status: response.status,
85
- error: errorText,
86
- });
87
- return {
88
- success: false,
89
- sessionId,
90
- error: `HTTP ${response.status}: ${errorText}`,
91
- };
92
- }
93
- // Parse response
94
- const responseData = (await response.json());
95
- const parseResult = agentshield_api_1.registerSessionResponseSchema.safeParse(responseData.data || responseData);
96
- if (!parseResult.success) {
97
- this.config.logger("[SessionRegistration] Invalid response format", {
98
- sessionId,
99
- response: responseData,
100
- });
101
- // Still consider it a success if we got a 200 OK
102
- return { success: true, sessionId };
103
- }
104
- this.config.logger("[SessionRegistration] Session now visible in AgentShield dashboard", {
105
- sessionId,
106
- registered: parseResult.data.registered,
107
- });
108
- return { success: true, sessionId };
109
- }
110
- finally {
111
- clearTimeout(timeoutId);
112
- }
113
- }
114
- catch (error) {
115
- // Handle abort/timeout
116
- if (error instanceof Error && error.name === "AbortError") {
117
- this.config.logger("[SessionRegistration] Request timed out", {
118
- sessionId,
119
- timeoutMs: this.config.timeoutMs,
120
- });
121
- return { success: false, sessionId, error: "Request timed out" };
122
- }
123
- // Log any other error
124
- const errorMsg = error instanceof Error ? error.message : "Unknown error";
125
- this.config.logger("[SessionRegistration] Unexpected error", {
126
- sessionId,
127
- error: errorMsg,
128
- });
129
- return { success: false, sessionId, error: errorMsg };
130
- }
131
- }
132
- /**
133
- * Fire-and-forget session registration
134
- *
135
- * Starts registration in the background without waiting for completion.
136
- * Useful when you want to register a session but not delay the response.
137
- *
138
- * @param request - Session registration request data
139
- */
140
- registerSessionAsync(request) {
141
- // Start registration in background - don't await
142
- this.registerSession(request).catch((error) => {
143
- // This should never happen since registerSession catches all errors,
144
- // but just in case
145
- this.config.logger("[SessionRegistration] Background registration failed", {
146
- sessionId: request.session_id,
147
- error: error instanceof Error ? error.message : "Unknown error",
148
- });
149
- });
150
- }
151
- }
152
- exports.SessionRegistrationService = SessionRegistrationService;
153
- /**
154
- * Create a session registration service from common runtime config
155
- *
156
- * Helper function to create the service from typical environment config.
157
- */
158
- function createSessionRegistrationService(options) {
159
- // Validate required config
160
- if (!options.apiUrl || !options.apiKey) {
161
- options.logger?.("[SessionRegistration] Missing required config - session registration disabled", {
162
- hasApiUrl: !!options.apiUrl,
163
- hasApiKey: !!options.apiKey,
164
- });
165
- return null;
166
- }
167
- return new SessionRegistrationService({
168
- baseUrl: options.apiUrl,
169
- apiKey: options.apiKey,
170
- fetchProvider: options.fetchProvider,
171
- logger: options.logger,
172
- });
173
- }
174
- //# sourceMappingURL=session-registration.service.js.map
@@ -1,116 +0,0 @@
1
- /**
2
- * Storage Service Factory
3
- *
4
- * Auto-selects storage providers based on available configuration.
5
- * Priority: Redis > Cloudflare KV > Cloudflare Durable Objects > Memory
6
- *
7
- * @package @kya-os/mcp-i-core
8
- */
9
- import { StorageProvider, NonceCacheProvider } from "../providers/base.js";
10
- /**
11
- * Storage service configuration
12
- */
13
- export interface StorageServiceConfig {
14
- /** Redis URL (e.g., "redis://localhost:6379") */
15
- redisUrl?: string;
16
- /** Cloudflare KV namespace */
17
- kvNamespace?: {
18
- get(key: string): Promise<string | null>;
19
- put(key: string, value: string, options?: {
20
- expirationTtl?: number;
21
- }): Promise<void>;
22
- delete(key: string): Promise<void>;
23
- list(options?: {
24
- prefix?: string;
25
- }): Promise<{
26
- keys: Array<{
27
- name: string;
28
- }>;
29
- }>;
30
- };
31
- /** Cloudflare Durable Object state */
32
- durableObjectState?: {
33
- storage: {
34
- get(key: string): Promise<string | undefined>;
35
- put(key: string, value: string): Promise<void>;
36
- delete(key: string): Promise<void>;
37
- list(options?: {
38
- prefix?: string;
39
- }): Promise<Map<string, string>>;
40
- };
41
- };
42
- /** Fallback to memory if no external storage configured (default: true) */
43
- fallbackToMemory?: boolean;
44
- }
45
- /**
46
- * Storage providers result
47
- */
48
- export interface StorageProviders {
49
- storageProvider: StorageProvider;
50
- nonceCacheProvider: NonceCacheProvider;
51
- }
52
- /**
53
- * Key helper functions for consistent key formatting
54
- */
55
- export declare class StorageKeyHelpers {
56
- /**
57
- * Build delegation key using composite format
58
- * Format: delegation:${userDid}:${agentDid}:${projectId}
59
- */
60
- static buildDelegationKey(userDid: string, agentDid: string, projectId: string): string;
61
- /**
62
- * Build session key
63
- * Format: session:${sessionId}
64
- */
65
- static buildSessionKey(sessionId: string): string;
66
- /**
67
- * Build nonce key
68
- * Format: nonce:${agentDid}:${nonce}
69
- */
70
- static buildNonceKey(agentDid: string, nonce: string): string;
71
- /**
72
- * Parse delegation key back into components
73
- *
74
- * Format: delegation:${userDid}:${agentDid}:${projectId}
75
- *
76
- * Note: DIDs contain colons (e.g., did:key:z123), so we can't simply split by ":"
77
- * Instead, we:
78
- * 1. Check that key starts with "delegation:"
79
- * 2. Take the last part as projectId (doesn't contain colons)
80
- * 3. Find where agentDid starts (look for "did:" pattern)
81
- * 4. Everything before agentDid is userDid, everything between agentDid and projectId is agentDid
82
- *
83
- * Strategy: Since DIDs always start with "did:", we can find the second occurrence of "did:"
84
- * to determine where agentDid begins. However, this assumes userDid and agentDid both start with "did:".
85
- *
86
- * For keys like "delegation:did:key:user123:did:key:agent456:project-789":
87
- * - Remove "delegation:" prefix → "did:key:user123:did:key:agent456:project-789"
88
- * - Find last ":" → separates agentDid from projectId
89
- * - projectId = "project-789"
90
- * - Find second occurrence of "did:" → separates userDid from agentDid
91
- * - userDid = "did:key:user123"
92
- * - agentDid = "did:key:agent456"
93
- */
94
- static parseDelegationKey(key: string): {
95
- userDid: string;
96
- agentDid: string;
97
- projectId: string;
98
- } | null;
99
- }
100
- /**
101
- * Create storage providers based on configuration
102
- *
103
- * Priority order:
104
- * 1. Redis (if redisUrl provided)
105
- * 2. Cloudflare KV (if kvNamespace provided)
106
- * 3. Cloudflare Durable Objects (if durableObjectState provided)
107
- * 4. In-memory fallback (if fallbackToMemory is true, default)
108
- */
109
- export declare function createStorageProviders(config: StorageServiceConfig): Promise<StorageProviders>;
110
- /**
111
- * Migration utility for legacy key formats
112
- *
113
- * Migrates keys from old format (e.g., `agent:${did}:delegation`) to new composite format
114
- */
115
- export declare function migrateLegacyKeys(oldKeyPrefix: string, newKeyFormat: (oldKey: string) => string | null, storageProvider: StorageProvider, batchSize?: number): Promise<number>;
116
- //# sourceMappingURL=storage.service.d.ts.map