@kya-os/mcp-i-cloudflare 1.5.10-canary.8 → 1.6.0
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/README.md +130 -0
- package/dist/__tests__/e2e/test-config.d.ts +37 -0
- package/dist/__tests__/e2e/test-config.d.ts.map +1 -0
- package/dist/__tests__/e2e/test-config.js +62 -0
- package/dist/__tests__/e2e/test-config.js.map +1 -0
- package/dist/adapter.d.ts +44 -1
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +712 -112
- package/dist/adapter.js.map +1 -1
- package/dist/agent.d.ts +103 -25
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +617 -40
- package/dist/agent.js.map +1 -1
- package/dist/app.d.ts +0 -8
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +277 -119
- package/dist/app.js.map +1 -1
- package/dist/cache/kv-oauth-config-cache.d.ts +47 -0
- package/dist/cache/kv-oauth-config-cache.d.ts.map +1 -0
- package/dist/cache/kv-oauth-config-cache.js +82 -0
- package/dist/cache/kv-oauth-config-cache.js.map +1 -0
- package/dist/cache/kv-tool-protection-cache.d.ts +26 -1
- package/dist/cache/kv-tool-protection-cache.d.ts.map +1 -1
- package/dist/cache/kv-tool-protection-cache.js +19 -11
- package/dist/cache/kv-tool-protection-cache.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +39 -14
- package/dist/config.js.map +1 -1
- package/dist/helpers/env-mapper.d.ts +60 -1
- package/dist/helpers/env-mapper.d.ts.map +1 -1
- package/dist/helpers/env-mapper.js +136 -6
- package/dist/helpers/env-mapper.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -3
- package/dist/index.js.map +1 -1
- package/dist/runtime/audit-logger.d.ts +96 -0
- package/dist/runtime/audit-logger.d.ts.map +1 -0
- package/dist/runtime/audit-logger.js +276 -0
- package/dist/runtime/audit-logger.js.map +1 -0
- package/dist/runtime/oauth-handler.d.ts +5 -0
- package/dist/runtime/oauth-handler.d.ts.map +1 -1
- package/dist/runtime/oauth-handler.js +287 -35
- package/dist/runtime/oauth-handler.js.map +1 -1
- package/dist/runtime.d.ts +12 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +34 -4
- package/dist/runtime.js.map +1 -1
- package/dist/server.d.ts +7 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +133 -18
- package/dist/server.js.map +1 -1
- package/dist/services/admin.service.d.ts +1 -3
- package/dist/services/admin.service.d.ts.map +1 -1
- package/dist/services/admin.service.js +175 -146
- package/dist/services/admin.service.js.map +1 -1
- package/dist/services/consent-audit.service.d.ts +91 -0
- package/dist/services/consent-audit.service.d.ts.map +1 -0
- package/dist/services/consent-audit.service.js +243 -0
- package/dist/services/consent-audit.service.js.map +1 -0
- package/dist/services/consent-config.service.d.ts +2 -2
- package/dist/services/consent-config.service.d.ts.map +1 -1
- package/dist/services/consent-config.service.js +55 -28
- package/dist/services/consent-config.service.js.map +1 -1
- package/dist/services/consent-page-renderer.d.ts +14 -0
- package/dist/services/consent-page-renderer.d.ts.map +1 -1
- package/dist/services/consent-page-renderer.js +54 -27
- package/dist/services/consent-page-renderer.js.map +1 -1
- package/dist/services/consent.service.d.ts +93 -8
- package/dist/services/consent.service.d.ts.map +1 -1
- package/dist/services/consent.service.js +1817 -553
- package/dist/services/consent.service.js.map +1 -1
- package/dist/services/delegation.service.d.ts.map +1 -1
- package/dist/services/delegation.service.js +67 -29
- package/dist/services/delegation.service.js.map +1 -1
- package/dist/services/idp-token-storage.d.ts +68 -0
- package/dist/services/idp-token-storage.d.ts.map +1 -0
- package/dist/services/idp-token-storage.js +157 -0
- package/dist/services/idp-token-storage.js.map +1 -0
- package/dist/services/oauth-service.d.ts +66 -0
- package/dist/services/oauth-service.d.ts.map +1 -0
- package/dist/services/oauth-service.js +223 -0
- package/dist/services/oauth-service.js.map +1 -0
- package/dist/services/proof.service.d.ts +8 -6
- package/dist/services/proof.service.d.ts.map +1 -1
- package/dist/services/proof.service.js +131 -75
- package/dist/services/proof.service.js.map +1 -1
- package/dist/services/tool-context-builder.d.ts +55 -0
- package/dist/services/tool-context-builder.d.ts.map +1 -0
- package/dist/services/tool-context-builder.js +124 -0
- package/dist/services/tool-context-builder.js.map +1 -0
- package/dist/types/tool-context.d.ts +35 -0
- package/dist/types/tool-context.d.ts.map +1 -0
- package/dist/types/tool-context.js +13 -0
- package/dist/types/tool-context.js.map +1 -0
- package/dist/types.d.ts +31 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/oauth-service-registry.d.ts +65 -0
- package/dist/utils/oauth-service-registry.d.ts.map +1 -0
- package/dist/utils/oauth-service-registry.js +125 -0
- package/dist/utils/oauth-service-registry.js.map +1 -0
- package/package.json +27 -60
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Supports both direct submission and batch queue submission.
|
|
8
8
|
*/
|
|
9
|
-
import { ProofBatchQueue, AgentShieldProofDestination } from
|
|
9
|
+
import { ProofBatchQueue, AgentShieldProofDestination, } from "./proof-batch-queue";
|
|
10
10
|
export class ProofService {
|
|
11
11
|
config;
|
|
12
12
|
runtime;
|
|
@@ -18,40 +18,41 @@ export class ProofService {
|
|
|
18
18
|
// Log service creation for debugging
|
|
19
19
|
// Use type assertion to access proofing config (extends MCPIConfig which has proofing)
|
|
20
20
|
const proofingConfig = this.config.proofing;
|
|
21
|
-
const hasApiKey = proofingConfig?.batchQueue?.destinations?.some((dest) => dest.type ===
|
|
22
|
-
console.log(
|
|
21
|
+
const hasApiKey = proofingConfig?.batchQueue?.destinations?.some((dest) => dest.type === "agentshield" && dest.apiKey);
|
|
22
|
+
console.log("[ProofService] Initialized:", {
|
|
23
23
|
proofingEnabled: proofingConfig?.enabled || false,
|
|
24
24
|
hasApiKey: !!hasApiKey,
|
|
25
|
-
hasDestinations: !!
|
|
25
|
+
hasDestinations: !!proofingConfig?.batchQueue?.destinations?.length,
|
|
26
26
|
destinationCount: proofingConfig?.batchQueue?.destinations?.length || 0,
|
|
27
27
|
apiKeyPresent: !!proofingConfig?.batchQueue?.destinations?.[0]?.apiKey,
|
|
28
|
-
apiUrl: proofingConfig?.batchQueue?.destinations?.[0]?.apiUrl ||
|
|
28
|
+
apiUrl: proofingConfig?.batchQueue?.destinations?.[0]?.apiUrl || "not-set",
|
|
29
29
|
});
|
|
30
30
|
// Warn if proofing is enabled but no API key is configured
|
|
31
31
|
if (proofingConfig?.enabled && !hasApiKey) {
|
|
32
|
-
console.warn(
|
|
33
|
-
console.warn(
|
|
34
|
-
console.warn(
|
|
35
|
-
console.warn(
|
|
32
|
+
console.warn("[ProofService] ⚠️ Proofing is enabled but AGENTSHIELD_API_KEY is not set!");
|
|
33
|
+
console.warn("[ProofService] To enable proof submission:");
|
|
34
|
+
console.warn("[ProofService] 1. Set AGENTSHIELD_API_KEY in .dev.vars (for local dev)");
|
|
35
|
+
console.warn("[ProofService] 2. Run: wrangler secret put AGENTSHIELD_API_KEY (for production)");
|
|
36
36
|
}
|
|
37
37
|
// Initialize batch queue if configured
|
|
38
38
|
// Note: In Cloudflare Workers, timers don't persist across requests,
|
|
39
39
|
// so we rely on manual flush() calls via cron jobs instead of automatic timers
|
|
40
|
-
if (proofingConfig?.enabled &&
|
|
40
|
+
if (proofingConfig?.enabled &&
|
|
41
|
+
proofingConfig.batchQueue?.destinations?.length) {
|
|
41
42
|
try {
|
|
42
43
|
const destinations = [];
|
|
43
44
|
for (const destConfig of proofingConfig.batchQueue.destinations) {
|
|
44
|
-
if (destConfig.type ===
|
|
45
|
+
if (destConfig.type === "agentshield") {
|
|
45
46
|
// Only create destination if API key is present and not empty
|
|
46
47
|
if (destConfig.apiKey?.length && destConfig.apiUrl?.length) {
|
|
47
48
|
destinations.push(new AgentShieldProofDestination(destConfig.apiUrl, destConfig.apiKey));
|
|
48
|
-
console.log(
|
|
49
|
+
console.log("[ProofService] Added AgentShield destination:", {
|
|
49
50
|
apiUrl: destConfig.apiUrl,
|
|
50
51
|
hasApiKey: !!destConfig.apiKey,
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
54
|
else {
|
|
54
|
-
console.warn(
|
|
55
|
+
console.warn("[ProofService] Skipping AgentShield destination - missing API key or URL:", {
|
|
55
56
|
hasApiKey: !!destConfig.apiKey,
|
|
56
57
|
hasApiUrl: !!destConfig.apiUrl,
|
|
57
58
|
});
|
|
@@ -68,24 +69,26 @@ export class ProofService {
|
|
|
68
69
|
maxRetries: proofingConfig.batchQueue.maxRetries || 3,
|
|
69
70
|
debug: proofingConfig.batchQueue.debug || false,
|
|
70
71
|
});
|
|
71
|
-
console.log(
|
|
72
|
+
console.log("[ProofService] Batch queue initialized (Cloudflare Workers mode - manual flush via cron):", {
|
|
72
73
|
maxBatchSize: proofingConfig.batchQueue.maxBatchSize || 10,
|
|
73
74
|
flushIntervalMs: proofingConfig.batchQueue.flushIntervalMs || 5000,
|
|
74
75
|
destinations: destinations.length,
|
|
75
76
|
});
|
|
76
77
|
}
|
|
77
78
|
else {
|
|
78
|
-
console.warn(
|
|
79
|
+
console.warn("[ProofService] No valid destinations configured - batch queue not initialized");
|
|
79
80
|
// Warn in production if no API key configured
|
|
80
81
|
// Access environment via vars or use type assertion
|
|
81
|
-
const environment = this.config.environment ||
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
const environment = this.config.environment ||
|
|
83
|
+
this.config.vars?.ENVIRONMENT ||
|
|
84
|
+
"development";
|
|
85
|
+
if (environment === "production") {
|
|
86
|
+
console.warn("[ProofService] No AGENTSHIELD_API_KEY configured - proofs will not be submitted");
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
89
|
}
|
|
87
90
|
catch (error) {
|
|
88
|
-
console.error(
|
|
91
|
+
console.error("[ProofService] Failed to initialize batch queue:", error);
|
|
89
92
|
}
|
|
90
93
|
}
|
|
91
94
|
}
|
|
@@ -101,13 +104,13 @@ export class ProofService {
|
|
|
101
104
|
*/
|
|
102
105
|
async submitProof(proof, context) {
|
|
103
106
|
if (!proof.jws || !proof.meta) {
|
|
104
|
-
console.warn(
|
|
107
|
+
console.warn("[ProofService] Proof missing jws or meta, skipping submission");
|
|
105
108
|
return;
|
|
106
109
|
}
|
|
107
110
|
// Submit first proof immediately for dashboard setup detection
|
|
108
111
|
// This ensures the dashboard can detect the server and tools immediately
|
|
109
112
|
if (!this.firstProofSubmitted && this.batchQueue) {
|
|
110
|
-
console.log(
|
|
113
|
+
console.log("[ProofService] Submitting first proof immediately for dashboard setup detection");
|
|
111
114
|
this.firstProofSubmitted = true;
|
|
112
115
|
// Submit first proof directly, then use batching for subsequent proofs
|
|
113
116
|
await this.submitProofDirect(proof, context);
|
|
@@ -118,19 +121,19 @@ export class ProofService {
|
|
|
118
121
|
// but relies on cron jobs for cross-request flushing
|
|
119
122
|
if (this.batchQueue) {
|
|
120
123
|
try {
|
|
121
|
-
console.log(
|
|
124
|
+
console.log("[ProofService] Enqueuing proof to batch queue:", {
|
|
122
125
|
did: proof.meta.did,
|
|
123
126
|
sessionId: proof.meta.sessionId,
|
|
124
127
|
toolName: context.toolName,
|
|
125
128
|
scopeId: proof.meta.scopeId,
|
|
126
|
-
mcpServerUrl: context.mcpServerUrl ||
|
|
129
|
+
mcpServerUrl: context.mcpServerUrl || "not-set",
|
|
127
130
|
});
|
|
128
131
|
// Enqueue proof - batch queue will auto-flush when batch size is reached
|
|
129
132
|
this.batchQueue.enqueue(proof);
|
|
130
133
|
return;
|
|
131
134
|
}
|
|
132
135
|
catch (error) {
|
|
133
|
-
console.error(
|
|
136
|
+
console.error("[ProofService] Failed to enqueue proof, falling back to direct submission:", error);
|
|
134
137
|
// Fall through to direct submission
|
|
135
138
|
}
|
|
136
139
|
}
|
|
@@ -141,18 +144,27 @@ export class ProofService {
|
|
|
141
144
|
* Direct proof submission (fallback when batch queue not available)
|
|
142
145
|
*/
|
|
143
146
|
async submitProofDirect(proof, context) {
|
|
147
|
+
// Validate mutual exclusivity
|
|
148
|
+
if (context.consentEvent && context.toolName) {
|
|
149
|
+
throw new Error("Cannot submit both tool call and consent event in same context");
|
|
150
|
+
}
|
|
151
|
+
if (!context.consentEvent && !context.toolName) {
|
|
152
|
+
throw new Error("Must provide either toolName or consentEvent");
|
|
153
|
+
}
|
|
144
154
|
// Get AgentShield config from proofing config
|
|
145
155
|
// Use type assertion to access proofing config (extends MCPIConfig which has proofing)
|
|
146
156
|
const proofingConfig = this.config.proofing;
|
|
147
157
|
if (!proofingConfig?.enabled || !proofingConfig.batchQueue?.destinations) {
|
|
148
|
-
console.log(
|
|
158
|
+
console.log("[ProofService] Proof submission disabled or no destinations configured");
|
|
149
159
|
return;
|
|
150
160
|
}
|
|
151
161
|
// Find AgentShield destination
|
|
152
|
-
const agentShieldDest = proofingConfig.batchQueue.destinations.find((dest) => dest.type ===
|
|
153
|
-
if (!agentShieldDest ||
|
|
154
|
-
|
|
155
|
-
|
|
162
|
+
const agentShieldDest = proofingConfig.batchQueue.destinations.find((dest) => dest.type === "agentshield" && dest.apiKey);
|
|
163
|
+
if (!agentShieldDest ||
|
|
164
|
+
!agentShieldDest.apiKey ||
|
|
165
|
+
!agentShieldDest.apiUrl) {
|
|
166
|
+
console.log("[ProofService] No AgentShield destination configured:", {
|
|
167
|
+
hasDestinations: !!proofingConfig.batchQueue.destinations?.length,
|
|
156
168
|
foundDest: !!agentShieldDest,
|
|
157
169
|
hasApiKey: !!agentShieldDest?.apiKey,
|
|
158
170
|
hasApiUrl: !!agentShieldDest?.apiUrl,
|
|
@@ -161,7 +173,8 @@ export class ProofService {
|
|
|
161
173
|
}
|
|
162
174
|
// Use AccessControlApiService if available from runtime
|
|
163
175
|
if (this.runtime && this.runtime.accessControlService) {
|
|
164
|
-
const accessControlService = this.runtime
|
|
176
|
+
const accessControlService = this.runtime
|
|
177
|
+
.accessControlService;
|
|
165
178
|
try {
|
|
166
179
|
// Get tool call context from runtime (if available)
|
|
167
180
|
const toolCallContext = this.runtime?.getLastToolCallContext();
|
|
@@ -171,26 +184,58 @@ export class ProofService {
|
|
|
171
184
|
delegation_id: null,
|
|
172
185
|
proofs: [proof],
|
|
173
186
|
context: {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
187
|
+
// Only include tool calls for actual tool executions
|
|
188
|
+
toolCalls: context.toolName && !context.consentEvent
|
|
189
|
+
? toolCallContext
|
|
190
|
+
? [toolCallContext]
|
|
191
|
+
: [
|
|
192
|
+
{
|
|
193
|
+
tool: context.toolName,
|
|
194
|
+
args: context.args || {},
|
|
195
|
+
result: context.result,
|
|
196
|
+
scopeId: proof.meta.scopeId || `${context.toolName}:execute`,
|
|
197
|
+
},
|
|
198
|
+
]
|
|
199
|
+
: [],
|
|
200
|
+
// Include consent events when present
|
|
201
|
+
consentEvents: context.consentEvent ? [context.consentEvent] : [],
|
|
202
|
+
mcpServerUrl: context.mcpServerUrl,
|
|
203
|
+
},
|
|
182
204
|
};
|
|
183
|
-
console.log(
|
|
205
|
+
console.log("[ProofService] Submitting proof via AccessControlApiService:", {
|
|
184
206
|
did: proof.meta.did,
|
|
185
207
|
sessionId: proof.meta.sessionId,
|
|
186
|
-
jwsFormat: proof.jws.split(
|
|
208
|
+
jwsFormat: proof.jws.split(".").length === 3 ? "valid (3 parts)" : "invalid",
|
|
187
209
|
contextTool: request.context.toolCalls[0]?.tool,
|
|
188
210
|
});
|
|
189
|
-
|
|
211
|
+
let response;
|
|
212
|
+
try {
|
|
213
|
+
response = await accessControlService.submitProofs(request);
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
// CRITICAL: Log full error details before re-throwing
|
|
217
|
+
// Stringify nested objects so they appear in logs
|
|
218
|
+
const errorDetails = error?.details || {};
|
|
219
|
+
const zodErrorsStr = errorDetails.zodErrors
|
|
220
|
+
? JSON.stringify(errorDetails.zodErrors, null, 2)
|
|
221
|
+
: undefined;
|
|
222
|
+
const responseDataStr = errorDetails.responseData
|
|
223
|
+
? JSON.stringify(errorDetails.responseData, null, 2)
|
|
224
|
+
: undefined;
|
|
225
|
+
console.error("[ProofService] ❌ PROOF SUBMISSION ERROR:", {
|
|
226
|
+
errorMessage: error?.message,
|
|
227
|
+
errorCode: error?.code,
|
|
228
|
+
zodErrors: zodErrorsStr,
|
|
229
|
+
responseData: responseDataStr,
|
|
230
|
+
errorStack: error?.stack,
|
|
231
|
+
request: JSON.stringify(request, null, 2),
|
|
232
|
+
});
|
|
233
|
+
throw error;
|
|
234
|
+
}
|
|
190
235
|
// Type assertion needed due to TypeScript type resolution issues with outdated node_modules types
|
|
191
236
|
// The actual runtime type has accepted/rejected/outcomes, but node_modules has old types
|
|
192
237
|
const typedResponse = response;
|
|
193
|
-
console.log(
|
|
238
|
+
console.log("[ProofService] ✅ Response:", {
|
|
194
239
|
success: typedResponse.success,
|
|
195
240
|
accepted: typedResponse.accepted,
|
|
196
241
|
rejected: typedResponse.rejected,
|
|
@@ -198,18 +243,18 @@ export class ProofService {
|
|
|
198
243
|
errors: typedResponse.errors?.length || 0,
|
|
199
244
|
});
|
|
200
245
|
if (typedResponse.accepted > 0) {
|
|
201
|
-
console.log(
|
|
246
|
+
console.log("[ProofService] ✅ Proofs accepted:", typedResponse.accepted);
|
|
202
247
|
}
|
|
203
248
|
if (typedResponse.rejected > 0) {
|
|
204
|
-
console.log(
|
|
249
|
+
console.log("[ProofService] ❌ Proofs rejected:", typedResponse.rejected);
|
|
205
250
|
}
|
|
206
251
|
if (typedResponse.errors && typedResponse.errors.length > 0) {
|
|
207
|
-
console.error(
|
|
252
|
+
console.error("[ProofService] Proof errors:", typedResponse.errors);
|
|
208
253
|
}
|
|
209
254
|
return;
|
|
210
255
|
}
|
|
211
256
|
catch (error) {
|
|
212
|
-
console.error(
|
|
257
|
+
console.error("[ProofService] Submission error via AccessControlApiService:", {
|
|
213
258
|
error: error instanceof Error ? error.message : String(error),
|
|
214
259
|
stack: error instanceof Error ? error.stack : undefined,
|
|
215
260
|
});
|
|
@@ -219,7 +264,7 @@ export class ProofService {
|
|
|
219
264
|
// Fallback to direct fetch if AccessControlApiService not available
|
|
220
265
|
const apiUrl = agentShieldDest.apiUrl;
|
|
221
266
|
const apiKey = agentShieldDest.apiKey;
|
|
222
|
-
console.log(
|
|
267
|
+
console.log("[ProofService] Direct submission config (fallback):", {
|
|
223
268
|
apiUrl,
|
|
224
269
|
hasApiKey: !!apiKey,
|
|
225
270
|
apiKeyLength: apiKey?.length || 0,
|
|
@@ -231,44 +276,55 @@ export class ProofService {
|
|
|
231
276
|
const requestBody = {
|
|
232
277
|
session_id: context.session.id,
|
|
233
278
|
delegation_id: null,
|
|
234
|
-
proofs: [
|
|
279
|
+
proofs: [
|
|
280
|
+
{
|
|
235
281
|
jws: proof.jws, // Already in full JWS format
|
|
236
|
-
meta: proof.meta // Already has all required fields
|
|
237
|
-
}
|
|
282
|
+
meta: proof.meta, // Already has all required fields
|
|
283
|
+
},
|
|
284
|
+
],
|
|
238
285
|
// Optional context for dashboard integration
|
|
239
286
|
context: {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
287
|
+
// Only include tool calls for actual tool executions
|
|
288
|
+
toolCalls: context.toolName && !context.consentEvent
|
|
289
|
+
? toolCallContext
|
|
290
|
+
? [toolCallContext]
|
|
291
|
+
: [
|
|
292
|
+
{
|
|
293
|
+
// Fallback if context not available from runtime
|
|
294
|
+
tool: context.toolName,
|
|
295
|
+
args: context.args || {},
|
|
296
|
+
result: context.result,
|
|
297
|
+
scopeId: proof.meta.scopeId || `${context.toolName}:execute`,
|
|
298
|
+
},
|
|
299
|
+
]
|
|
300
|
+
: [],
|
|
301
|
+
// Include consent events when present
|
|
302
|
+
consentEvents: context.consentEvent ? [context.consentEvent] : [],
|
|
247
303
|
// MCP server URL for tool discovery (optional, only needed once)
|
|
248
|
-
mcpServerUrl: context.mcpServerUrl
|
|
249
|
-
}
|
|
304
|
+
mcpServerUrl: context.mcpServerUrl,
|
|
305
|
+
},
|
|
250
306
|
};
|
|
251
|
-
console.log(
|
|
307
|
+
console.log("[ProofService] Submitting proof with context:", {
|
|
252
308
|
did: proof.meta.did,
|
|
253
309
|
sessionId: proof.meta.sessionId,
|
|
254
|
-
jwsFormat: proof.jws.split(
|
|
310
|
+
jwsFormat: proof.jws.split(".").length === 3 ? "valid (3 parts)" : "invalid",
|
|
255
311
|
contextTool: requestBody.context.toolCalls[0]?.tool,
|
|
256
312
|
contextScopeId: requestBody.context.toolCalls[0]?.scopeId,
|
|
257
|
-
mcpServerUrl: requestBody.context.mcpServerUrl ||
|
|
313
|
+
mcpServerUrl: requestBody.context.mcpServerUrl || "not-set",
|
|
258
314
|
requestBodySize: JSON.stringify(requestBody).length,
|
|
259
315
|
});
|
|
260
316
|
try {
|
|
261
317
|
const response = await fetch(`${apiUrl}/api/v1/bouncer/proofs`, {
|
|
262
|
-
method:
|
|
318
|
+
method: "POST",
|
|
263
319
|
headers: {
|
|
264
|
-
|
|
265
|
-
|
|
320
|
+
"Content-Type": "application/json",
|
|
321
|
+
Authorization: `Bearer ${apiKey}`,
|
|
266
322
|
},
|
|
267
|
-
body: JSON.stringify(requestBody)
|
|
323
|
+
body: JSON.stringify(requestBody),
|
|
268
324
|
});
|
|
269
325
|
const responseText = await response.text();
|
|
270
326
|
if (!response.ok) {
|
|
271
|
-
console.error(
|
|
327
|
+
console.error("[ProofService] Submission failed:", {
|
|
272
328
|
status: response.status,
|
|
273
329
|
statusText: response.statusText,
|
|
274
330
|
response: responseText.substring(0, 500), // Limit response size in logs
|
|
@@ -280,13 +336,13 @@ export class ProofService {
|
|
|
280
336
|
responseData = JSON.parse(responseText);
|
|
281
337
|
}
|
|
282
338
|
catch (parseError) {
|
|
283
|
-
console.error(
|
|
339
|
+
console.error("[ProofService] Failed to parse response:", {
|
|
284
340
|
responseText: responseText.substring(0, 500),
|
|
285
341
|
error: parseError,
|
|
286
342
|
});
|
|
287
|
-
throw new Error(
|
|
343
|
+
throw new Error("Invalid JSON response from AgentShield");
|
|
288
344
|
}
|
|
289
|
-
console.log(
|
|
345
|
+
console.log("[ProofService] Response:", {
|
|
290
346
|
success: responseData.success,
|
|
291
347
|
received: responseData.received,
|
|
292
348
|
processed: responseData.processed,
|
|
@@ -295,17 +351,17 @@ export class ProofService {
|
|
|
295
351
|
errors: responseData.errors?.length || 0,
|
|
296
352
|
});
|
|
297
353
|
if (responseData.accepted) {
|
|
298
|
-
console.log(
|
|
354
|
+
console.log("[ProofService] ✅ Proofs accepted:", responseData.accepted);
|
|
299
355
|
}
|
|
300
356
|
if (responseData.rejected) {
|
|
301
|
-
console.log(
|
|
357
|
+
console.log("[ProofService] ❌ Proofs rejected:", responseData.rejected);
|
|
302
358
|
}
|
|
303
359
|
if (responseData.errors && responseData.errors.length > 0) {
|
|
304
|
-
console.error(
|
|
360
|
+
console.error("[ProofService] Proof errors:", responseData.errors);
|
|
305
361
|
}
|
|
306
362
|
}
|
|
307
363
|
catch (error) {
|
|
308
|
-
console.error(
|
|
364
|
+
console.error("[ProofService] Submission error:", {
|
|
309
365
|
error: error instanceof Error ? error.message : String(error),
|
|
310
366
|
stack: error instanceof Error ? error.stack : undefined,
|
|
311
367
|
});
|
|
@@ -339,7 +395,7 @@ export class ProofService {
|
|
|
339
395
|
*/
|
|
340
396
|
async flush() {
|
|
341
397
|
if (this.batchQueue) {
|
|
342
|
-
console.log(
|
|
398
|
+
console.log("[ProofService] Flushing batch queue...");
|
|
343
399
|
await this.batchQueue.flush();
|
|
344
400
|
// Also retry any pending batches
|
|
345
401
|
await this.batchQueue.retryPending();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proof.service.js","sourceRoot":"","sources":["../../src/services/proof.service.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,EAAE,eAAe,EAAE,2BAA2B,EAAyB,MAAM,qBAAqB,CAAC;AAU1G,MAAM,OAAO,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IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC;QACvC,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Context Builder
|
|
3
|
+
*
|
|
4
|
+
* Builds ToolExecutionContext for tool handlers by resolving IDP tokens
|
|
5
|
+
* based on tool protection configuration and user identity.
|
|
6
|
+
*
|
|
7
|
+
* @package @kya-os/mcp-i-cloudflare
|
|
8
|
+
*/
|
|
9
|
+
import type { ToolExecutionContext } from "../types/tool-context.js";
|
|
10
|
+
import type { IdpTokenResolver } from "@kya-os/mcp-i-core";
|
|
11
|
+
import type { ToolProtection } from "@kya-os/mcp-i-core/types/tool-protection";
|
|
12
|
+
import type { OAuthConfigService } from "@kya-os/mcp-i-core";
|
|
13
|
+
export interface ToolContextBuilderConfig {
|
|
14
|
+
/** IDP token resolver for resolving tokens from User DID */
|
|
15
|
+
tokenResolver: IdpTokenResolver;
|
|
16
|
+
/** OAuth config service for fetching provider configurations */
|
|
17
|
+
configService: OAuthConfigService;
|
|
18
|
+
/** Project ID for fetching OAuth config */
|
|
19
|
+
projectId: string;
|
|
20
|
+
/** Optional logger callback for diagnostics */
|
|
21
|
+
logger?: (message: string, data?: unknown) => void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Builder for tool execution context
|
|
25
|
+
*
|
|
26
|
+
* Resolves IDP tokens and builds context for tool handlers.
|
|
27
|
+
* Phase 1: Uses configured provider as temporary fallback.
|
|
28
|
+
* Phase 2+: Requires explicit oauthProvider on tool protection.
|
|
29
|
+
*/
|
|
30
|
+
export declare class ToolContextBuilder {
|
|
31
|
+
private config;
|
|
32
|
+
constructor(config: ToolContextBuilderConfig);
|
|
33
|
+
/**
|
|
34
|
+
* Build tool execution context
|
|
35
|
+
*
|
|
36
|
+
* @param toolName - Name of the tool being executed
|
|
37
|
+
* @param userDid - User DID (optional, required for OAuth)
|
|
38
|
+
* @param sessionId - Session ID (optional)
|
|
39
|
+
* @param delegationToken - Delegation token (optional)
|
|
40
|
+
* @param toolProtection - Tool protection configuration (optional)
|
|
41
|
+
* @returns Tool execution context or undefined if not needed
|
|
42
|
+
*/
|
|
43
|
+
buildContext(toolName: string, userDid: string | undefined, sessionId: string | undefined, delegationToken: string | undefined, toolProtection: ToolProtection | null): Promise<ToolExecutionContext | undefined>;
|
|
44
|
+
/**
|
|
45
|
+
* Resolve OAuth provider for a tool
|
|
46
|
+
*
|
|
47
|
+
* Phase 1: Uses configured provider from OAuth config as temporary fallback
|
|
48
|
+
* Phase 2+: Requires explicit oauthProvider on tool protection
|
|
49
|
+
*
|
|
50
|
+
* @param toolProtection - Tool protection configuration
|
|
51
|
+
* @returns Provider name or null if not found
|
|
52
|
+
*/
|
|
53
|
+
private resolveProvider;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=tool-context-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-context-builder.d.ts","sourceRoot":"","sources":["../../src/services/tool-context-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAE/E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,MAAM,WAAW,wBAAwB;IACvC,4DAA4D;IAC5D,aAAa,EAAE,gBAAgB,CAAC;IAEhC,gEAAgE;IAChE,aAAa,EAAE,kBAAkB,CAAC;IAElC,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC;IAElB,+CAA+C;IAC/C,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACpD;AAED;;;;;;GAMG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAEZ;gBAEU,MAAM,EAAE,wBAAwB;IAS5C;;;;;;;;;OASG;IACG,YAAY,CAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,eAAe,EAAE,MAAM,GAAG,SAAS,EACnC,cAAc,EAAE,cAAc,GAAG,IAAI,GACpC,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC;IAyD5C;;;;;;;;OAQG;YACW,eAAe;CAyC9B"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Context Builder
|
|
3
|
+
*
|
|
4
|
+
* Builds ToolExecutionContext for tool handlers by resolving IDP tokens
|
|
5
|
+
* based on tool protection configuration and user identity.
|
|
6
|
+
*
|
|
7
|
+
* @package @kya-os/mcp-i-cloudflare
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Builder for tool execution context
|
|
11
|
+
*
|
|
12
|
+
* Resolves IDP tokens and builds context for tool handlers.
|
|
13
|
+
* Phase 1: Uses configured provider as temporary fallback.
|
|
14
|
+
* Phase 2+: Requires explicit oauthProvider on tool protection.
|
|
15
|
+
*/
|
|
16
|
+
export class ToolContextBuilder {
|
|
17
|
+
config;
|
|
18
|
+
constructor(config) {
|
|
19
|
+
this.config = {
|
|
20
|
+
tokenResolver: config.tokenResolver,
|
|
21
|
+
configService: config.configService,
|
|
22
|
+
projectId: config.projectId,
|
|
23
|
+
logger: config.logger || (() => { }),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Build tool execution context
|
|
28
|
+
*
|
|
29
|
+
* @param toolName - Name of the tool being executed
|
|
30
|
+
* @param userDid - User DID (optional, required for OAuth)
|
|
31
|
+
* @param sessionId - Session ID (optional)
|
|
32
|
+
* @param delegationToken - Delegation token (optional)
|
|
33
|
+
* @param toolProtection - Tool protection configuration (optional)
|
|
34
|
+
* @returns Tool execution context or undefined if not needed
|
|
35
|
+
*/
|
|
36
|
+
async buildContext(toolName, userDid, sessionId, delegationToken, toolProtection) {
|
|
37
|
+
// Only build context if tool requires OAuth
|
|
38
|
+
if (!toolProtection?.requiredScopes?.length || !userDid) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
// Phase 1: Resolve provider from configured providers
|
|
42
|
+
// Phase 1 uses configured provider as temporary fallback
|
|
43
|
+
// Phase 2+ requires explicit oauthProvider on tool protection
|
|
44
|
+
const provider = await this.resolveProvider(toolProtection);
|
|
45
|
+
if (!provider) {
|
|
46
|
+
this.config.logger("[ToolContextBuilder] Provider not resolved", {
|
|
47
|
+
toolName,
|
|
48
|
+
userDid: userDid.substring(0, 20) + "...",
|
|
49
|
+
});
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
// Resolve IDP token
|
|
53
|
+
const idpToken = await this.config.tokenResolver.resolveTokenFromDid(userDid, provider, toolProtection.requiredScopes);
|
|
54
|
+
if (!idpToken) {
|
|
55
|
+
// Token not available - will trigger OAuth flow
|
|
56
|
+
this.config.logger("[ToolContextBuilder] Token not available", {
|
|
57
|
+
toolName,
|
|
58
|
+
userDid: userDid.substring(0, 20) + "...",
|
|
59
|
+
provider,
|
|
60
|
+
scopes: toolProtection.requiredScopes,
|
|
61
|
+
});
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
// Build context with token
|
|
65
|
+
const context = {
|
|
66
|
+
idpToken,
|
|
67
|
+
provider,
|
|
68
|
+
scopes: toolProtection.requiredScopes,
|
|
69
|
+
userDid,
|
|
70
|
+
sessionId,
|
|
71
|
+
delegationToken,
|
|
72
|
+
};
|
|
73
|
+
this.config.logger("[ToolContextBuilder] Context built successfully", {
|
|
74
|
+
toolName,
|
|
75
|
+
userDid: userDid.substring(0, 20) + "...",
|
|
76
|
+
provider,
|
|
77
|
+
hasToken: !!idpToken,
|
|
78
|
+
});
|
|
79
|
+
return context;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Resolve OAuth provider for a tool
|
|
83
|
+
*
|
|
84
|
+
* Phase 1: Uses configured provider from OAuth config as temporary fallback
|
|
85
|
+
* Phase 2+: Requires explicit oauthProvider on tool protection
|
|
86
|
+
*
|
|
87
|
+
* @param toolProtection - Tool protection configuration
|
|
88
|
+
* @returns Provider name or null if not found
|
|
89
|
+
*/
|
|
90
|
+
async resolveProvider(toolProtection) {
|
|
91
|
+
// Phase 2+: Check for explicit oauthProvider (not yet implemented)
|
|
92
|
+
// if (toolProtection.oauthProvider) {
|
|
93
|
+
// return toolProtection.oauthProvider;
|
|
94
|
+
// }
|
|
95
|
+
// Phase 1: Use configured provider from OAuth config as temporary fallback
|
|
96
|
+
// Get first configured provider (Phase 1 assumes single provider per project)
|
|
97
|
+
try {
|
|
98
|
+
const oauthConfig = await this.config.configService.getOAuthConfig(this.config.projectId);
|
|
99
|
+
const providers = Object.keys(oauthConfig.providers);
|
|
100
|
+
if (providers.length === 0) {
|
|
101
|
+
this.config.logger("[ToolContextBuilder] No providers configured", {
|
|
102
|
+
projectId: this.config.projectId,
|
|
103
|
+
});
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
// Phase 1: Use first configured provider as fallback
|
|
107
|
+
// Phase 2+: This fallback will be removed, tools must specify oauthProvider
|
|
108
|
+
const provider = providers[0];
|
|
109
|
+
this.config.logger("[ToolContextBuilder] Provider resolved (Phase 1 fallback)", {
|
|
110
|
+
provider,
|
|
111
|
+
availableProviders: providers,
|
|
112
|
+
});
|
|
113
|
+
return provider;
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
this.config.logger("[ToolContextBuilder] Failed to fetch OAuth config", {
|
|
117
|
+
error: error instanceof Error ? error.message : String(error),
|
|
118
|
+
projectId: this.config.projectId,
|
|
119
|
+
});
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=tool-context-builder.js.map
|