@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,124 +0,0 @@
1
- /**
2
- * DelegationErrorFormatter - Formats delegation error messages for MCP clients
3
- *
4
- * This service provides a single source of truth for formatting delegation
5
- * required error messages. It supports:
6
- * - Default message templates
7
- * - Client-specific message customization (claude, chatgpt, cursor, etc.)
8
- * - Template interpolation with placeholders
9
- * - Markdown support toggle per client
10
- *
11
- * @module @kya-os/mcp-i-core/services/delegation-error-formatter
12
- */
13
- import type { ClientMessageTemplate, ClientMessagesConfig } from "@kya-os/contracts/config";
14
- export type { ClientMessageTemplate, ClientMessagesConfig };
15
- /**
16
- * Options for formatting a delegation error message
17
- */
18
- export interface DelegationErrorFormatOptions {
19
- /** Name of the tool that requires delegation */
20
- toolName: string;
21
- /** URL where user can provide consent/delegation */
22
- consentUrl?: string;
23
- /** Scopes required for the tool */
24
- scopes?: string[];
25
- /** Client ID (e.g., "claude", "chatgpt", "cursor") - used for client-specific messages */
26
- clientId?: string;
27
- }
28
- /**
29
- * Options for formatting an OAuth error message
30
- */
31
- export interface OAuthErrorFormatOptions {
32
- /** Name of the tool that requires OAuth */
33
- toolName: string;
34
- /** OAuth authorization URL */
35
- oauthUrl?: string;
36
- /** OAuth provider name (e.g., "GitHub", "Google") */
37
- provider?: string;
38
- /** Scopes required for the tool */
39
- scopes?: string[];
40
- /** Client ID (e.g., "claude", "chatgpt", "cursor") - used for client-specific messages */
41
- clientId?: string;
42
- }
43
- /**
44
- * Result of formatting a delegation error
45
- */
46
- export interface DelegationErrorResult {
47
- /** Formatted message to display to the user */
48
- message: string;
49
- /** Consent URL (may be modified with extra params) */
50
- consentUrl?: string;
51
- }
52
- /**
53
- * Result of formatting an OAuth error
54
- */
55
- export interface OAuthErrorResult {
56
- /** Formatted message to display to the user */
57
- message: string;
58
- /** OAuth URL (may be modified with extra params) */
59
- oauthUrl?: string;
60
- }
61
- /**
62
- * Service for formatting delegation error messages
63
- *
64
- * Provides consistent message formatting across different deployment patterns
65
- * (agent, adapter) while supporting client-specific customization.
66
- *
67
- * @example
68
- * ```typescript
69
- * const formatter = new DelegationErrorFormatter();
70
- * const { message } = formatter.format({
71
- * toolName: "checkout",
72
- * consentUrl: "https://example.com/consent",
73
- * clientId: "claude"
74
- * });
75
- * ```
76
- */
77
- export declare class DelegationErrorFormatter {
78
- private config?;
79
- constructor(config?: ClientMessagesConfig);
80
- /**
81
- * Update the configuration
82
- */
83
- setConfig(config: ClientMessagesConfig): void;
84
- /**
85
- * Format a delegation error message
86
- *
87
- * @param options - Formatting options including toolName, consentUrl, and clientId
88
- * @returns Formatted message and potentially modified consent URL
89
- */
90
- format(options: DelegationErrorFormatOptions): DelegationErrorResult;
91
- /**
92
- * Format an OAuth error message
93
- *
94
- * @param options - Formatting options including toolName, oauthUrl, provider, and clientId
95
- * @returns Formatted message and potentially modified OAuth URL
96
- */
97
- formatOAuth(options: OAuthErrorFormatOptions): OAuthErrorResult;
98
- /**
99
- * Get the template for a specific client, merging with defaults
100
- */
101
- private getTemplate;
102
- /**
103
- * Build URL with extra parameters if configured
104
- * Used for both consent URLs and OAuth URLs
105
- */
106
- private buildUrl;
107
- /**
108
- * Interpolate placeholders in a template string
109
- *
110
- * Uses a function replacement to avoid special pattern interpretation.
111
- * JavaScript's String.replace() interprets patterns like $&, $', $` in the
112
- * replacement string. Using () => value prevents this.
113
- */
114
- private interpolate;
115
- /**
116
- * Strip markdown links, converting [text](url) to plain "text: url"
117
- */
118
- private stripMarkdownLinks;
119
- }
120
- /**
121
- * Create a delegation error formatter with optional configuration
122
- */
123
- export declare function createDelegationErrorFormatter(config?: ClientMessagesConfig): DelegationErrorFormatter;
124
- //# sourceMappingURL=delegation-error-formatter.d.ts.map
@@ -1,214 +0,0 @@
1
- "use strict";
2
- /**
3
- * DelegationErrorFormatter - Formats delegation error messages for MCP clients
4
- *
5
- * This service provides a single source of truth for formatting delegation
6
- * required error messages. It supports:
7
- * - Default message templates
8
- * - Client-specific message customization (claude, chatgpt, cursor, etc.)
9
- * - Template interpolation with placeholders
10
- * - Markdown support toggle per client
11
- *
12
- * @module @kya-os/mcp-i-core/services/delegation-error-formatter
13
- */
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.DelegationErrorFormatter = void 0;
16
- exports.createDelegationErrorFormatter = createDelegationErrorFormatter;
17
- /**
18
- * Default message template (matches original adapter/agent behavior)
19
- */
20
- const DEFAULT_TEMPLATE = {
21
- message: `Authorization required for "{toolName}".
22
-
23
- Authorization URL: {consentUrl}
24
-
25
- Share this URL with the user so they can authorize in their browser, then retry.`,
26
- noUrlMessage: `Authorization required for "{toolName}" but no consent URL is available.
27
-
28
- Please contact the administrator to configure delegation for this tool.`,
29
- oauthMessage: `Authorization required for "{toolName}".
30
-
31
- Sign in with {provider}: {oauthUrl}
32
-
33
- Share this URL with the user so they can sign in with {provider}, then retry.`,
34
- noOAuthUrlMessage: `Authorization required for "{toolName}" but no {provider} URL is available.
35
-
36
- Please contact the administrator to configure OAuth for this tool.`,
37
- supportsMarkdown: true,
38
- };
39
- /**
40
- * Service for formatting delegation error messages
41
- *
42
- * Provides consistent message formatting across different deployment patterns
43
- * (agent, adapter) while supporting client-specific customization.
44
- *
45
- * @example
46
- * ```typescript
47
- * const formatter = new DelegationErrorFormatter();
48
- * const { message } = formatter.format({
49
- * toolName: "checkout",
50
- * consentUrl: "https://example.com/consent",
51
- * clientId: "claude"
52
- * });
53
- * ```
54
- */
55
- class DelegationErrorFormatter {
56
- config;
57
- constructor(config) {
58
- this.config = config;
59
- }
60
- /**
61
- * Update the configuration
62
- */
63
- setConfig(config) {
64
- this.config = config;
65
- }
66
- /**
67
- * Format a delegation error message
68
- *
69
- * @param options - Formatting options including toolName, consentUrl, and clientId
70
- * @returns Formatted message and potentially modified consent URL
71
- */
72
- format(options) {
73
- const { toolName, consentUrl, scopes, clientId } = options;
74
- // Get the appropriate template for this client
75
- const template = this.getTemplate(clientId);
76
- // Build the final consent URL with any extra params
77
- const finalUrl = this.buildUrl(consentUrl, template);
78
- // Choose message based on whether we have a consent URL
79
- let message;
80
- if (finalUrl) {
81
- const messageTemplate = template.message ?? DEFAULT_TEMPLATE.message;
82
- message = this.interpolate(messageTemplate, {
83
- toolName,
84
- consentUrl: finalUrl,
85
- scopes: scopes?.join(", ") ?? "",
86
- });
87
- // If client doesn't support markdown, convert markdown links to plain text
88
- if (template.supportsMarkdown === false) {
89
- message = this.stripMarkdownLinks(message);
90
- }
91
- }
92
- else {
93
- const noUrlTemplate = template.noUrlMessage ?? DEFAULT_TEMPLATE.noUrlMessage;
94
- message = this.interpolate(noUrlTemplate, {
95
- toolName,
96
- consentUrl: "",
97
- scopes: scopes?.join(", ") ?? "",
98
- });
99
- }
100
- return { message, consentUrl: finalUrl };
101
- }
102
- /**
103
- * Format an OAuth error message
104
- *
105
- * @param options - Formatting options including toolName, oauthUrl, provider, and clientId
106
- * @returns Formatted message and potentially modified OAuth URL
107
- */
108
- formatOAuth(options) {
109
- const { toolName, oauthUrl, provider = "OAuth", scopes, clientId } = options;
110
- // Get the appropriate template for this client
111
- const template = this.getTemplate(clientId);
112
- // Build the final OAuth URL with any extra params
113
- const finalUrl = this.buildUrl(oauthUrl, template);
114
- // Choose message based on whether we have an OAuth URL
115
- let message;
116
- if (finalUrl) {
117
- const messageTemplate = template.oauthMessage ?? DEFAULT_TEMPLATE.oauthMessage;
118
- message = this.interpolate(messageTemplate, {
119
- toolName,
120
- oauthUrl: finalUrl,
121
- provider,
122
- scopes: scopes?.join(", ") ?? "",
123
- });
124
- // If client doesn't support markdown, convert markdown links to plain text
125
- if (template.supportsMarkdown === false) {
126
- message = this.stripMarkdownLinks(message);
127
- }
128
- }
129
- else {
130
- const noUrlTemplate = template.noOAuthUrlMessage ?? DEFAULT_TEMPLATE.noOAuthUrlMessage;
131
- message = this.interpolate(noUrlTemplate, {
132
- toolName,
133
- oauthUrl: "",
134
- provider,
135
- scopes: scopes?.join(", ") ?? "",
136
- });
137
- }
138
- return { message, oauthUrl: finalUrl };
139
- }
140
- /**
141
- * Get the template for a specific client, merging with defaults
142
- */
143
- getTemplate(clientId) {
144
- const defaultTemplate = this.config?.default ?? {};
145
- // If no client ID or no client-specific config, use default
146
- if (!clientId || !this.config?.clients?.[clientId]) {
147
- return {
148
- ...DEFAULT_TEMPLATE,
149
- ...defaultTemplate,
150
- };
151
- }
152
- // Merge: DEFAULT_TEMPLATE < config.default < config.clients[clientId]
153
- return {
154
- ...DEFAULT_TEMPLATE,
155
- ...defaultTemplate,
156
- ...this.config.clients[clientId],
157
- };
158
- }
159
- /**
160
- * Build URL with extra parameters if configured
161
- * Used for both consent URLs and OAuth URLs
162
- */
163
- buildUrl(baseUrl, template) {
164
- if (!baseUrl)
165
- return undefined;
166
- // If no extra params, return as-is
167
- if (!template.extraParams || Object.keys(template.extraParams).length === 0) {
168
- return baseUrl;
169
- }
170
- // Add extra params to URL
171
- try {
172
- const url = new URL(baseUrl);
173
- for (const [key, value] of Object.entries(template.extraParams)) {
174
- url.searchParams.set(key, value);
175
- }
176
- return url.toString();
177
- }
178
- catch {
179
- // If URL parsing fails, return original
180
- return baseUrl;
181
- }
182
- }
183
- /**
184
- * Interpolate placeholders in a template string
185
- *
186
- * Uses a function replacement to avoid special pattern interpretation.
187
- * JavaScript's String.replace() interprets patterns like $&, $', $` in the
188
- * replacement string. Using () => value prevents this.
189
- */
190
- interpolate(template, values) {
191
- let result = template;
192
- for (const [key, value] of Object.entries(values)) {
193
- // Use function replacement to prevent special pattern interpretation
194
- // e.g., URLs containing $& would otherwise get corrupted
195
- result = result.replace(new RegExp(`\\{${key}\\}`, "g"), () => value);
196
- }
197
- return result;
198
- }
199
- /**
200
- * Strip markdown links, converting [text](url) to plain "text: url"
201
- */
202
- stripMarkdownLinks(text) {
203
- // Match [link text](url) and convert to "link text: url"
204
- return text.replace(/\[([^\]]+)\]\(([^)]+)\)/g, "$1: $2");
205
- }
206
- }
207
- exports.DelegationErrorFormatter = DelegationErrorFormatter;
208
- /**
209
- * Create a delegation error formatter with optional configuration
210
- */
211
- function createDelegationErrorFormatter(config) {
212
- return new DelegationErrorFormatter(config);
213
- }
214
- //# sourceMappingURL=delegation-error-formatter.js.map
@@ -1,49 +0,0 @@
1
- /**
2
- * Proof Verification Error Codes and Types
3
- *
4
- * Specific error codes for proof verification failures to enable
5
- * better error handling and debugging.
6
- */
7
- /**
8
- * Error codes for proof verification
9
- */
10
- export declare const PROOF_VERIFICATION_ERROR_CODES: {
11
- readonly INVALID_PROOF_STRUCTURE: "INVALID_PROOF_STRUCTURE";
12
- readonly MISSING_REQUIRED_FIELD: "MISSING_REQUIRED_FIELD";
13
- readonly NONCE_REPLAY_DETECTED: "NONCE_REPLAY_DETECTED";
14
- readonly TIMESTAMP_SKEW_EXCEEDED: "TIMESTAMP_SKEW_EXCEEDED";
15
- readonly TIMESTAMP_INVALID: "TIMESTAMP_INVALID";
16
- readonly INVALID_JWS_SIGNATURE: "INVALID_JWS_SIGNATURE";
17
- readonly INVALID_JWS_FORMAT: "INVALID_JWS_FORMAT";
18
- readonly INVALID_JWS_HEADER: "INVALID_JWS_HEADER";
19
- readonly INVALID_JWS_PAYLOAD: "INVALID_JWS_PAYLOAD";
20
- readonly INVALID_JWS_SIGNATURE_BASE64: "INVALID_JWS_SIGNATURE_BASE64";
21
- readonly UNSUPPORTED_ALGORITHM: "UNSUPPORTED_ALGORITHM";
22
- readonly INVALID_JWK_FORMAT: "INVALID_JWK_FORMAT";
23
- readonly INVALID_JWK_KTY: "INVALID_JWK_KTY";
24
- readonly INVALID_JWK_CRV: "INVALID_JWK_CRV";
25
- readonly INVALID_JWK_X_FIELD: "INVALID_JWK_X_FIELD";
26
- readonly INVALID_JWK_KEY_LENGTH: "INVALID_JWK_KEY_LENGTH";
27
- readonly JWK_KID_MISMATCH: "JWK_KID_MISMATCH";
28
- readonly DID_RESOLUTION_FAILED: "DID_RESOLUTION_FAILED";
29
- readonly DID_DOCUMENT_NOT_FOUND: "DID_DOCUMENT_NOT_FOUND";
30
- readonly VERIFICATION_METHOD_NOT_FOUND: "VERIFICATION_METHOD_NOT_FOUND";
31
- readonly PUBLIC_KEY_NOT_FOUND: "PUBLIC_KEY_NOT_FOUND";
32
- readonly UNSUPPORTED_DID_METHOD: "UNSUPPORTED_DID_METHOD";
33
- readonly VERIFICATION_ERROR: "VERIFICATION_ERROR";
34
- readonly INTERNAL_ERROR: "INTERNAL_ERROR";
35
- };
36
- export type ProofVerificationErrorCode = typeof PROOF_VERIFICATION_ERROR_CODES[keyof typeof PROOF_VERIFICATION_ERROR_CODES];
37
- /**
38
- * Proof verification error with specific error code
39
- */
40
- export declare class ProofVerificationError extends Error {
41
- readonly code: ProofVerificationErrorCode;
42
- readonly details?: Record<string, unknown> | undefined;
43
- constructor(code: ProofVerificationErrorCode, message: string, details?: Record<string, unknown> | undefined);
44
- }
45
- /**
46
- * Create a proof verification error
47
- */
48
- export declare function createProofVerificationError(code: ProofVerificationErrorCode, message: string, details?: Record<string, unknown>): ProofVerificationError;
49
- //# sourceMappingURL=errors.d.ts.map
@@ -1,66 +0,0 @@
1
- "use strict";
2
- /**
3
- * Proof Verification Error Codes and Types
4
- *
5
- * Specific error codes for proof verification failures to enable
6
- * better error handling and debugging.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.ProofVerificationError = exports.PROOF_VERIFICATION_ERROR_CODES = void 0;
10
- exports.createProofVerificationError = createProofVerificationError;
11
- /**
12
- * Error codes for proof verification
13
- */
14
- exports.PROOF_VERIFICATION_ERROR_CODES = {
15
- // Proof structure errors
16
- INVALID_PROOF_STRUCTURE: "INVALID_PROOF_STRUCTURE",
17
- MISSING_REQUIRED_FIELD: "MISSING_REQUIRED_FIELD",
18
- // Security errors
19
- NONCE_REPLAY_DETECTED: "NONCE_REPLAY_DETECTED",
20
- TIMESTAMP_SKEW_EXCEEDED: "TIMESTAMP_SKEW_EXCEEDED",
21
- TIMESTAMP_INVALID: "TIMESTAMP_INVALID",
22
- // Signature errors
23
- INVALID_JWS_SIGNATURE: "INVALID_JWS_SIGNATURE",
24
- INVALID_JWS_FORMAT: "INVALID_JWS_FORMAT",
25
- INVALID_JWS_HEADER: "INVALID_JWS_HEADER",
26
- INVALID_JWS_PAYLOAD: "INVALID_JWS_PAYLOAD",
27
- INVALID_JWS_SIGNATURE_BASE64: "INVALID_JWS_SIGNATURE_BASE64",
28
- UNSUPPORTED_ALGORITHM: "UNSUPPORTED_ALGORITHM",
29
- // JWK errors
30
- INVALID_JWK_FORMAT: "INVALID_JWK_FORMAT",
31
- INVALID_JWK_KTY: "INVALID_JWK_KTY",
32
- INVALID_JWK_CRV: "INVALID_JWK_CRV",
33
- INVALID_JWK_X_FIELD: "INVALID_JWK_X_FIELD",
34
- INVALID_JWK_KEY_LENGTH: "INVALID_JWK_KEY_LENGTH",
35
- JWK_KID_MISMATCH: "JWK_KID_MISMATCH",
36
- // DID resolution errors
37
- DID_RESOLUTION_FAILED: "DID_RESOLUTION_FAILED",
38
- DID_DOCUMENT_NOT_FOUND: "DID_DOCUMENT_NOT_FOUND",
39
- VERIFICATION_METHOD_NOT_FOUND: "VERIFICATION_METHOD_NOT_FOUND",
40
- PUBLIC_KEY_NOT_FOUND: "PUBLIC_KEY_NOT_FOUND",
41
- UNSUPPORTED_DID_METHOD: "UNSUPPORTED_DID_METHOD",
42
- // Generic errors
43
- VERIFICATION_ERROR: "VERIFICATION_ERROR",
44
- INTERNAL_ERROR: "INTERNAL_ERROR",
45
- };
46
- /**
47
- * Proof verification error with specific error code
48
- */
49
- class ProofVerificationError extends Error {
50
- code;
51
- details;
52
- constructor(code, message, details) {
53
- super(message);
54
- this.code = code;
55
- this.details = details;
56
- this.name = "ProofVerificationError";
57
- }
58
- }
59
- exports.ProofVerificationError = ProofVerificationError;
60
- /**
61
- * Create a proof verification error
62
- */
63
- function createProofVerificationError(code, message, details) {
64
- return new ProofVerificationError(code, message, details);
65
- }
66
- //# sourceMappingURL=errors.js.map
@@ -1,9 +0,0 @@
1
- export { CryptoService } from './crypto.service.js';
2
- export type { Ed25519JWK, ParsedJWS } from './crypto.service.js';
3
- export { AccessControlApiService, authorizationMatches, } from './access-control.service.js';
4
- export type { AccessControlApiServiceConfig, AccessControlApiServiceMetrics, } from './access-control.service.js';
5
- export { SessionRegistrationService, createSessionRegistrationService, } from './session-registration.service.js';
6
- export type { SessionRegistrationServiceConfig, SessionRegistrationResult, } from './session-registration.service.js';
7
- export { DelegationErrorFormatter, createDelegationErrorFormatter, } from './delegation-error-formatter.js';
8
- export type { DelegationErrorFormatOptions, DelegationErrorResult, OAuthErrorFormatOptions, OAuthErrorResult, ClientMessageTemplate, ClientMessagesConfig, } from './delegation-error-formatter.js';
9
- //# sourceMappingURL=index.d.ts.map
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createDelegationErrorFormatter = exports.DelegationErrorFormatter = exports.createSessionRegistrationService = exports.SessionRegistrationService = exports.authorizationMatches = exports.AccessControlApiService = exports.CryptoService = void 0;
4
- var crypto_service_js_1 = require("./crypto.service.js");
5
- Object.defineProperty(exports, "CryptoService", { enumerable: true, get: function () { return crypto_service_js_1.CryptoService; } });
6
- var access_control_service_js_1 = require("./access-control.service.js");
7
- Object.defineProperty(exports, "AccessControlApiService", { enumerable: true, get: function () { return access_control_service_js_1.AccessControlApiService; } });
8
- Object.defineProperty(exports, "authorizationMatches", { enumerable: true, get: function () { return access_control_service_js_1.authorizationMatches; } });
9
- var session_registration_service_js_1 = require("./session-registration.service.js");
10
- Object.defineProperty(exports, "SessionRegistrationService", { enumerable: true, get: function () { return session_registration_service_js_1.SessionRegistrationService; } });
11
- Object.defineProperty(exports, "createSessionRegistrationService", { enumerable: true, get: function () { return session_registration_service_js_1.createSessionRegistrationService; } });
12
- var delegation_error_formatter_js_1 = require("./delegation-error-formatter.js");
13
- Object.defineProperty(exports, "DelegationErrorFormatter", { enumerable: true, get: function () { return delegation_error_formatter_js_1.DelegationErrorFormatter; } });
14
- Object.defineProperty(exports, "createDelegationErrorFormatter", { enumerable: true, get: function () { return delegation_error_formatter_js_1.createDelegationErrorFormatter; } });
15
- //# sourceMappingURL=index.js.map
@@ -1,53 +0,0 @@
1
- /**
2
- * OAuth Config Service
3
- *
4
- * Fetches and caches OAuth provider configurations from AgentShield API.
5
- * Provides caching with TTL to reduce API calls.
6
- *
7
- * @package @kya-os/mcp-i-core
8
- */
9
- import type { FetchProvider } from "../providers/base.js";
10
- import type { OAuthConfig } from "@kya-os/contracts/config";
11
- import type { OAuthConfigCache } from "../cache/oauth-config-cache.js";
12
- export interface OAuthConfigServiceConfig {
13
- /** Base URL for AgentShield API (e.g., "https://kya.vouched.id") */
14
- baseUrl: string;
15
- /** API key for authentication */
16
- apiKey: string;
17
- /** Fetch provider for making HTTP requests */
18
- fetchProvider: FetchProvider;
19
- /** Cache implementation (defaults to in-memory) */
20
- cache?: OAuthConfigCache;
21
- /** Cache TTL in milliseconds (default: 5 minutes) */
22
- cacheTtl?: number;
23
- /** Optional logger callback for diagnostics */
24
- logger?: (message: string, data?: unknown) => void;
25
- }
26
- /**
27
- * Service for fetching OAuth provider configurations from AgentShield API
28
- */
29
- export declare class OAuthConfigService {
30
- private config;
31
- constructor(config: OAuthConfigServiceConfig);
32
- /**
33
- * Get OAuth configuration for a project
34
- *
35
- * Fetches from AgentShield API: GET /api/v1/bouncer/projects/{projectId}/providers
36
- * Caches responses with TTL to reduce API calls.
37
- *
38
- * @param projectId - Project ID to fetch config for
39
- * @returns OAuth configuration with providers object
40
- */
41
- getOAuthConfig(projectId: string): Promise<OAuthConfig>;
42
- /**
43
- * Clear cached config for a project
44
- *
45
- * @param projectId - Project ID to clear cache for
46
- */
47
- clearCache(projectId: string): Promise<void>;
48
- /**
49
- * Clear all cached configs
50
- */
51
- clearAllCache(): Promise<void>;
52
- }
53
- //# sourceMappingURL=oauth-config.service.d.ts.map
@@ -1,141 +0,0 @@
1
- "use strict";
2
- /**
3
- * OAuth Config Service
4
- *
5
- * Fetches and caches OAuth provider configurations from AgentShield API.
6
- * Provides caching with TTL to reduce API calls.
7
- *
8
- * @package @kya-os/mcp-i-core
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.OAuthConfigService = void 0;
12
- const oauth_config_cache_js_1 = require("../cache/oauth-config-cache.js");
13
- /**
14
- * Service for fetching OAuth provider configurations from AgentShield API
15
- */
16
- class OAuthConfigService {
17
- config;
18
- constructor(config) {
19
- this.config = {
20
- baseUrl: config.baseUrl,
21
- apiKey: config.apiKey,
22
- fetchProvider: config.fetchProvider,
23
- cacheTtl: config.cacheTtl ?? 5 * 60 * 1000, // Default 5 minutes
24
- logger: config.logger || (() => { }),
25
- cache: config.cache || new oauth_config_cache_js_1.InMemoryOAuthConfigCache(),
26
- };
27
- }
28
- /**
29
- * Get OAuth configuration for a project
30
- *
31
- * Fetches from AgentShield API: GET /api/v1/bouncer/projects/{projectId}/providers
32
- * Caches responses with TTL to reduce API calls.
33
- *
34
- * @param projectId - Project ID to fetch config for
35
- * @returns OAuth configuration with providers object
36
- */
37
- async getOAuthConfig(projectId) {
38
- // Check cache
39
- const cached = await this.config.cache.get(projectId);
40
- if (cached) {
41
- this.config.logger("[OAuthConfigService] Cache hit", {
42
- projectId,
43
- });
44
- return cached;
45
- }
46
- // Fetch from AgentShield API
47
- const url = `${this.config.baseUrl}/api/v1/bouncer/projects/${encodeURIComponent(projectId)}/providers`;
48
- this.config.logger("[OAuthConfigService] Fetching config from API", {
49
- projectId,
50
- url,
51
- });
52
- try {
53
- const response = await this.config.fetchProvider.fetch(url, {
54
- method: "GET",
55
- headers: {
56
- Authorization: `Bearer ${this.config.apiKey}`,
57
- "Content-Type": "application/json",
58
- },
59
- });
60
- if (!response.ok) {
61
- const errorText = await response.text().catch(() => "Unknown error");
62
- throw new Error(`Failed to fetch OAuth config: ${response.status} ${response.statusText} - ${errorText}`);
63
- }
64
- const result = await response.json();
65
- // Validate response structure
66
- if (!result.success || !result.data) {
67
- throw new Error("Invalid API response: missing success or data field");
68
- }
69
- // Parse providers object with snake_case → camelCase mapping
70
- // AgentShield API may return snake_case fields, but OAuthProvider interface uses camelCase
71
- const rawProviders = result.data.providers || {};
72
- if (typeof rawProviders !== "object" || Array.isArray(rawProviders)) {
73
- throw new Error("Invalid API response: providers must be an object, not an array");
74
- }
75
- // Map each provider's fields from snake_case to camelCase
76
- const providers = {};
77
- for (const [name, raw] of Object.entries(rawProviders)) {
78
- const p = raw;
79
- providers[name] = {
80
- clientId: (p.clientId ?? p.client_id ?? ""),
81
- clientSecret: (p.clientSecret ?? p.client_secret ?? null),
82
- authorizationUrl: (p.authorizationUrl ?? p.authorization_url ?? ""),
83
- tokenUrl: (p.tokenUrl ?? p.token_url ?? ""),
84
- userInfoUrl: (p.userInfoUrl ?? p.user_info_url),
85
- supportsPKCE: (p.supportsPKCE ?? p.supports_pkce ?? false),
86
- requiresClientSecret: (p.requiresClientSecret ?? p.requires_client_secret ?? true),
87
- scopes: (p.scopes ?? []),
88
- defaultScopes: (p.defaultScopes ?? p.default_scopes),
89
- proxyMode: (p.proxyMode ?? p.proxy_mode ?? false),
90
- customParams: (p.customParams ?? p.custom_params),
91
- tokenEndpointAuthMethod: (p.tokenEndpointAuthMethod ?? p.token_endpoint_auth_method),
92
- responseType: (p.responseType ?? p.response_type),
93
- grantType: (p.grantType ?? p.grant_type),
94
- };
95
- }
96
- // Build OAuthConfig object
97
- // Extract configuredProvider from API response - this indicates which provider
98
- // the user has actually configured in AgentShield dashboard
99
- const configuredProvider = result.data.configuredProvider ?? result.data.configured_provider ?? null;
100
- const config = {
101
- providers,
102
- configuredProvider,
103
- };
104
- // Cache config
105
- await this.config.cache.set(projectId, config, this.config.cacheTtl);
106
- this.config.logger("[OAuthConfigService] Config fetched and cached", {
107
- projectId,
108
- providerCount: Object.keys(providers).length,
109
- providers: Object.keys(providers),
110
- configuredProvider,
111
- expiresAt: new Date(Date.now() + this.config.cacheTtl).toISOString(),
112
- });
113
- return config;
114
- }
115
- catch (error) {
116
- this.config.logger("[OAuthConfigService] API fetch failed", {
117
- projectId,
118
- error: error instanceof Error ? error.message : String(error),
119
- });
120
- throw error;
121
- }
122
- }
123
- /**
124
- * Clear cached config for a project
125
- *
126
- * @param projectId - Project ID to clear cache for
127
- */
128
- async clearCache(projectId) {
129
- await this.config.cache.delete(projectId);
130
- this.config.logger("[OAuthConfigService] Cache cleared", { projectId });
131
- }
132
- /**
133
- * Clear all cached configs
134
- */
135
- async clearAllCache() {
136
- await this.config.cache.clear();
137
- this.config.logger("[OAuthConfigService] All cache cleared");
138
- }
139
- }
140
- exports.OAuthConfigService = OAuthConfigService;
141
- //# sourceMappingURL=oauth-config.service.js.map