@kya-os/mcp-i-cloudflare 1.4.1-canary.1 → 1.4.1-canary.11
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 +120 -1
- package/dist/adapter.d.ts +6 -0
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +29 -0
- package/dist/adapter.js.map +1 -1
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +13 -0
- package/dist/agent.js.map +1 -1
- package/dist/app.d.ts +6 -3
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +14 -1
- package/dist/app.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +19 -2
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.ts +22 -8
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +130 -28
- package/dist/runtime.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +23 -4
- package/dist/server.js.map +1 -1
- package/dist/services/admin.service.d.ts.map +1 -1
- package/dist/services/admin.service.js +36 -3
- package/dist/services/admin.service.js.map +1 -1
- package/dist/services/consent-config.service.d.ts +46 -0
- package/dist/services/consent-config.service.d.ts.map +1 -0
- package/dist/services/consent-config.service.js +157 -0
- package/dist/services/consent-config.service.js.map +1 -0
- package/dist/services/consent-page-renderer.d.ts +137 -0
- package/dist/services/consent-page-renderer.d.ts.map +1 -0
- package/dist/services/consent-page-renderer.js +539 -0
- package/dist/services/consent-page-renderer.js.map +1 -0
- package/dist/services/consent.service.d.ts +58 -3
- package/dist/services/consent.service.d.ts.map +1 -1
- package/dist/services/consent.service.js +373 -18
- package/dist/services/consent.service.js.map +1 -1
- package/dist/services/proof-batch-queue.d.ts +104 -0
- package/dist/services/proof-batch-queue.d.ts.map +1 -0
- package/dist/services/proof-batch-queue.js +209 -0
- package/dist/services/proof-batch-queue.js.map +1 -0
- package/dist/services/proof.service.d.ts +38 -1
- package/dist/services/proof.service.d.ts.map +1 -1
- package/dist/services/proof.service.js +214 -21
- package/dist/services/proof.service.js.map +1 -1
- package/dist/services/transport.service.d.ts +47 -0
- package/dist/services/transport.service.d.ts.map +1 -0
- package/dist/services/transport.service.js +76 -0
- package/dist/services/transport.service.js.map +1 -0
- package/package.json +2 -2
|
@@ -2,46 +2,401 @@
|
|
|
2
2
|
* Consent Service
|
|
3
3
|
*
|
|
4
4
|
* Handles consent page rendering and approval handling.
|
|
5
|
-
*
|
|
5
|
+
* Complete implementation for Phase 0.
|
|
6
|
+
*
|
|
7
|
+
* Related Spec: MCP-I Phase 0 Implementation Plan, Task B.5
|
|
6
8
|
*/
|
|
9
|
+
import { ConsentConfigService } from './consent-config.service';
|
|
10
|
+
import { ConsentPageRenderer } from './consent-page-renderer';
|
|
11
|
+
import { DEFAULT_AGENTSHIELD_URL, DEFAULT_SESSION_CACHE_TTL } from '../constants';
|
|
12
|
+
import { validateConsentApprovalRequest, } from '@kya-os/contracts/consent';
|
|
13
|
+
import { AGENTSHIELD_ENDPOINTS } from '@kya-os/contracts/agentshield-api';
|
|
7
14
|
export class ConsentService {
|
|
15
|
+
configService;
|
|
16
|
+
renderer;
|
|
17
|
+
env;
|
|
18
|
+
runtime;
|
|
19
|
+
constructor(env, runtime) {
|
|
20
|
+
this.env = env;
|
|
21
|
+
this.runtime = runtime;
|
|
22
|
+
this.configService = new ConsentConfigService(env);
|
|
23
|
+
this.renderer = new ConsentPageRenderer();
|
|
24
|
+
}
|
|
8
25
|
/**
|
|
9
26
|
* Handle consent requests
|
|
27
|
+
*
|
|
28
|
+
* Routes:
|
|
29
|
+
* - GET /consent - Render consent page
|
|
30
|
+
* - POST /consent/approve - Handle approval
|
|
31
|
+
* - GET /consent/success - Success page
|
|
32
|
+
*
|
|
10
33
|
* @param request - Incoming request
|
|
11
34
|
* @returns Response
|
|
12
35
|
*/
|
|
13
36
|
async handle(request) {
|
|
14
37
|
const url = new URL(request.url);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return this.renderConsentPage(url.searchParams);
|
|
38
|
+
// GET /consent - Render page
|
|
39
|
+
if (request.method === 'GET' && url.pathname === '/consent') {
|
|
40
|
+
return this.renderConsentPage(url.searchParams, request);
|
|
18
41
|
}
|
|
19
|
-
|
|
20
|
-
|
|
42
|
+
// POST /consent/approve - Handle approval
|
|
43
|
+
if (request.method === 'POST' && url.pathname === '/consent/approve') {
|
|
21
44
|
return this.handleApproval(request);
|
|
22
45
|
}
|
|
46
|
+
// GET /consent/success - Success page
|
|
47
|
+
if (request.method === 'GET' && url.pathname === '/consent/success') {
|
|
48
|
+
return this.renderSuccessPage(url.searchParams);
|
|
49
|
+
}
|
|
23
50
|
return new Response('Method not allowed', { status: 405 });
|
|
24
51
|
}
|
|
25
52
|
/**
|
|
26
53
|
* Render consent page
|
|
27
|
-
*
|
|
54
|
+
*
|
|
55
|
+
* Query parameters:
|
|
56
|
+
* - tool: Tool name
|
|
57
|
+
* - scopes: Comma-separated scopes
|
|
58
|
+
* - agent_did: Agent DID
|
|
59
|
+
* - session_id: Session ID
|
|
60
|
+
* - project_id: Project ID
|
|
61
|
+
*
|
|
62
|
+
* @param params - URL search parameters
|
|
63
|
+
* @param request - Original request (for extracting origin)
|
|
64
|
+
* @returns HTML response
|
|
28
65
|
*/
|
|
29
|
-
async renderConsentPage(params) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
66
|
+
async renderConsentPage(params, request) {
|
|
67
|
+
try {
|
|
68
|
+
// Extract required parameters
|
|
69
|
+
const tool = params.get('tool');
|
|
70
|
+
const scopesParam = params.get('scopes');
|
|
71
|
+
const agentDid = params.get('agent_did');
|
|
72
|
+
const sessionId = params.get('session_id');
|
|
73
|
+
const projectId = params.get('project_id');
|
|
74
|
+
// Validate required parameters
|
|
75
|
+
if (!tool || !agentDid || !sessionId || !projectId) {
|
|
76
|
+
return new Response(JSON.stringify({
|
|
77
|
+
success: false,
|
|
78
|
+
error: 'Missing required parameters',
|
|
79
|
+
error_code: 'missing_parameters',
|
|
80
|
+
}), {
|
|
81
|
+
status: 400,
|
|
82
|
+
headers: { 'Content-Type': 'application/json' },
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
// Parse scopes
|
|
86
|
+
const scopes = scopesParam ? scopesParam.split(',').map((s) => s.trim()) : [];
|
|
87
|
+
// Get tool description (try to fetch from runtime or use default)
|
|
88
|
+
let toolDescription = `Execute ${tool}`;
|
|
89
|
+
if (this.runtime) {
|
|
90
|
+
try {
|
|
91
|
+
// Try to get tool description from runtime if available
|
|
92
|
+
// This is a placeholder - actual implementation depends on runtime API
|
|
93
|
+
toolDescription = `Execute ${tool} with requested permissions`;
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
// Fallback to default
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// Get consent config from AgentShield or defaults
|
|
100
|
+
const consentConfig = await this.configService.getConsentConfig(projectId);
|
|
101
|
+
// Build server URL from request origin
|
|
102
|
+
// Priority: 1) env var, 2) request origin, 3) error if neither available
|
|
103
|
+
let serverUrl = this.env.MCP_SERVER_URL;
|
|
104
|
+
if (!serverUrl) {
|
|
105
|
+
// Extract origin from request URL
|
|
106
|
+
const requestUrl = new URL(request.url);
|
|
107
|
+
serverUrl = requestUrl.origin;
|
|
108
|
+
// Validate that we have a valid origin
|
|
109
|
+
if (!serverUrl || serverUrl === 'null' || !serverUrl.startsWith('http')) {
|
|
110
|
+
return new Response(JSON.stringify({
|
|
111
|
+
success: false,
|
|
112
|
+
error: 'Cannot determine server URL. Please set MCP_SERVER_URL environment variable.',
|
|
113
|
+
error_code: 'server_url_required',
|
|
114
|
+
}), {
|
|
115
|
+
status: 500,
|
|
116
|
+
headers: { 'Content-Type': 'application/json' },
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// Build consent page config
|
|
121
|
+
const pageConfig = {
|
|
122
|
+
tool,
|
|
123
|
+
toolDescription,
|
|
124
|
+
scopes,
|
|
125
|
+
agentDid,
|
|
126
|
+
sessionId,
|
|
127
|
+
projectId,
|
|
128
|
+
serverUrl,
|
|
129
|
+
branding: consentConfig.branding,
|
|
130
|
+
terms: consentConfig.terms,
|
|
131
|
+
customFields: consentConfig.customFields,
|
|
132
|
+
autoClose: consentConfig.ui?.autoClose,
|
|
133
|
+
};
|
|
134
|
+
// Render page
|
|
135
|
+
const html = this.renderer.render(pageConfig);
|
|
136
|
+
return new Response(html, {
|
|
137
|
+
status: 200,
|
|
138
|
+
headers: {
|
|
139
|
+
'Content-Type': 'text/html; charset=utf-8',
|
|
140
|
+
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
console.error('[ConsentService] Error rendering consent page:', error);
|
|
146
|
+
return new Response(JSON.stringify({
|
|
147
|
+
success: false,
|
|
148
|
+
error: 'Failed to render consent page',
|
|
149
|
+
error_code: 'render_error',
|
|
150
|
+
}), {
|
|
151
|
+
status: 500,
|
|
152
|
+
headers: { 'Content-Type': 'application/json' },
|
|
153
|
+
});
|
|
154
|
+
}
|
|
35
155
|
}
|
|
36
156
|
/**
|
|
37
157
|
* Handle consent approval
|
|
38
|
-
*
|
|
158
|
+
*
|
|
159
|
+
* Validates request, creates delegation via AgentShield API,
|
|
160
|
+
* stores token in KV, and returns success response.
|
|
161
|
+
*
|
|
162
|
+
* @param request - Approval request
|
|
163
|
+
* @returns JSON response
|
|
39
164
|
*/
|
|
40
165
|
async handleApproval(request) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
166
|
+
try {
|
|
167
|
+
// Parse and validate request body
|
|
168
|
+
const body = await request.json();
|
|
169
|
+
const validation = validateConsentApprovalRequest(body);
|
|
170
|
+
if (!validation.success) {
|
|
171
|
+
return new Response(JSON.stringify({
|
|
172
|
+
success: false,
|
|
173
|
+
error: 'Invalid request',
|
|
174
|
+
error_code: 'validation_error',
|
|
175
|
+
details: validation.error.errors,
|
|
176
|
+
}), {
|
|
177
|
+
status: 400,
|
|
178
|
+
headers: { 'Content-Type': 'application/json' },
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
const approvalRequest = validation.data;
|
|
182
|
+
// Validate terms acceptance if required
|
|
183
|
+
const consentConfig = await this.configService.getConsentConfig(approvalRequest.project_id);
|
|
184
|
+
if (consentConfig.terms?.required && !approvalRequest.termsAccepted) {
|
|
185
|
+
return new Response(JSON.stringify({
|
|
186
|
+
success: false,
|
|
187
|
+
error: 'Terms and conditions must be accepted',
|
|
188
|
+
error_code: 'terms_not_accepted',
|
|
189
|
+
}), {
|
|
190
|
+
status: 400,
|
|
191
|
+
headers: { 'Content-Type': 'application/json' },
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
// Create delegation via AgentShield API
|
|
195
|
+
const delegationResult = await this.createDelegation(approvalRequest);
|
|
196
|
+
if (!delegationResult.success) {
|
|
197
|
+
return new Response(JSON.stringify({
|
|
198
|
+
success: false,
|
|
199
|
+
error: delegationResult.error || 'Failed to create delegation',
|
|
200
|
+
error_code: delegationResult.error_code || 'delegation_creation_failed',
|
|
201
|
+
}), {
|
|
202
|
+
status: 500,
|
|
203
|
+
headers: { 'Content-Type': 'application/json' },
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
// Store delegation token in KV
|
|
207
|
+
await this.storeDelegationToken(approvalRequest.session_id, approvalRequest.agent_did, delegationResult.delegation_token, delegationResult.delegation_id);
|
|
208
|
+
// Return success response
|
|
209
|
+
const response = {
|
|
210
|
+
success: true,
|
|
211
|
+
delegation_id: delegationResult.delegation_id,
|
|
212
|
+
delegation_token: delegationResult.delegation_token,
|
|
213
|
+
};
|
|
214
|
+
return new Response(JSON.stringify(response), {
|
|
215
|
+
status: 200,
|
|
216
|
+
headers: { 'Content-Type': 'application/json' },
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
console.error('[ConsentService] Error handling approval:', error);
|
|
221
|
+
return new Response(JSON.stringify({
|
|
222
|
+
success: false,
|
|
223
|
+
error: 'Internal server error',
|
|
224
|
+
error_code: 'internal_error',
|
|
225
|
+
}), {
|
|
226
|
+
status: 500,
|
|
227
|
+
headers: { 'Content-Type': 'application/json' },
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Create delegation via AgentShield API
|
|
233
|
+
*
|
|
234
|
+
* @param request - Approval request
|
|
235
|
+
* @returns Delegation creation result
|
|
236
|
+
*/
|
|
237
|
+
async createDelegation(request) {
|
|
238
|
+
const agentShieldUrl = this.env.AGENTSHIELD_API_URL || DEFAULT_AGENTSHIELD_URL;
|
|
239
|
+
const apiKey = this.env.AGENTSHIELD_API_KEY;
|
|
240
|
+
if (!apiKey) {
|
|
241
|
+
console.warn('[ConsentService] No API key configured, cannot create delegation');
|
|
242
|
+
return {
|
|
243
|
+
success: false,
|
|
244
|
+
error: 'API key not configured',
|
|
245
|
+
error_code: 'api_key_missing',
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
try {
|
|
249
|
+
// Calculate expiration (7 days from now)
|
|
250
|
+
const expiresAt = new Date();
|
|
251
|
+
expiresAt.setDate(expiresAt.getDate() + 7);
|
|
252
|
+
const expiresAtISO = expiresAt.toISOString();
|
|
253
|
+
// Create delegation request
|
|
254
|
+
// Note: AgentShield API may accept a simplified format for consent flows
|
|
255
|
+
// This is a simplified version - adjust based on actual API requirements
|
|
256
|
+
const delegationRequest = {
|
|
257
|
+
agent_did: request.agent_did,
|
|
258
|
+
scopes: request.scopes,
|
|
259
|
+
session_id: request.session_id,
|
|
260
|
+
project_id: request.project_id,
|
|
261
|
+
expires_at: expiresAtISO,
|
|
262
|
+
// Include custom fields if provided
|
|
263
|
+
...(request.customFields && Object.keys(request.customFields).length > 0
|
|
264
|
+
? { custom_fields: request.customFields }
|
|
265
|
+
: {}),
|
|
266
|
+
};
|
|
267
|
+
const response = await fetch(`${agentShieldUrl}${AGENTSHIELD_ENDPOINTS.DELEGATIONS_CREATE}`, {
|
|
268
|
+
method: 'POST',
|
|
269
|
+
headers: {
|
|
270
|
+
'Authorization': `Bearer ${apiKey}`,
|
|
271
|
+
'Content-Type': 'application/json',
|
|
272
|
+
},
|
|
273
|
+
body: JSON.stringify(delegationRequest),
|
|
274
|
+
});
|
|
275
|
+
if (!response.ok) {
|
|
276
|
+
const errorText = await response.text();
|
|
277
|
+
console.error('[ConsentService] Delegation creation failed:', response.status, errorText);
|
|
278
|
+
return {
|
|
279
|
+
success: false,
|
|
280
|
+
error: `API error: ${response.status}`,
|
|
281
|
+
error_code: 'api_error',
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
const responseData = (await response.json());
|
|
285
|
+
// Extract delegation_id and delegation_token from response
|
|
286
|
+
// Response format may vary - handle both wrapped and unwrapped formats
|
|
287
|
+
const delegationId = responseData.delegation_id ||
|
|
288
|
+
responseData.data?.delegation_id ||
|
|
289
|
+
responseData.delegation?.id ||
|
|
290
|
+
responseData.id;
|
|
291
|
+
const delegationToken = responseData.delegation_token ||
|
|
292
|
+
responseData.data?.delegation_token ||
|
|
293
|
+
responseData.token ||
|
|
294
|
+
responseData.data?.token;
|
|
295
|
+
if (!delegationId || !delegationToken) {
|
|
296
|
+
console.error('[ConsentService] Invalid response format:', responseData);
|
|
297
|
+
return {
|
|
298
|
+
success: false,
|
|
299
|
+
error: 'Invalid API response format',
|
|
300
|
+
error_code: 'invalid_response',
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
console.log('[ConsentService] ✅ Delegation created successfully:', {
|
|
304
|
+
delegationId,
|
|
305
|
+
agentDid: request.agent_did.substring(0, 20) + '...',
|
|
306
|
+
scopes: request.scopes,
|
|
307
|
+
});
|
|
308
|
+
return {
|
|
309
|
+
success: true,
|
|
310
|
+
delegation_id: delegationId,
|
|
311
|
+
delegation_token: delegationToken,
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
catch (error) {
|
|
315
|
+
console.error('[ConsentService] Error creating delegation:', error);
|
|
316
|
+
return {
|
|
317
|
+
success: false,
|
|
318
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
319
|
+
error_code: 'creation_error',
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Store delegation token in KV
|
|
325
|
+
*
|
|
326
|
+
* Stores token using both session ID and agent DID keys for resilience.
|
|
327
|
+
*
|
|
328
|
+
* @param sessionId - Session ID
|
|
329
|
+
* @param agentDid - Agent DID
|
|
330
|
+
* @param token - Delegation token
|
|
331
|
+
* @param delegationId - Delegation ID
|
|
332
|
+
*/
|
|
333
|
+
async storeDelegationToken(sessionId, agentDid, token, delegationId) {
|
|
334
|
+
const delegationStorage = this.env.DELEGATION_STORAGE;
|
|
335
|
+
if (!delegationStorage) {
|
|
336
|
+
console.warn('[ConsentService] No delegation storage configured, token not stored');
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
try {
|
|
340
|
+
// Default TTL: 7 days (same as delegation expiration)
|
|
341
|
+
const ttl = 7 * 24 * 60 * 60; // 7 days in seconds
|
|
342
|
+
// Store using agent DID (primary, survives session changes)
|
|
343
|
+
const agentKey = `agent:${agentDid}:delegation`;
|
|
344
|
+
await delegationStorage.put(agentKey, token, {
|
|
345
|
+
expirationTtl: ttl,
|
|
346
|
+
});
|
|
347
|
+
console.log('[ConsentService] ✅ Token stored with agent DID:', {
|
|
348
|
+
key: agentKey,
|
|
349
|
+
ttl,
|
|
350
|
+
delegationId,
|
|
351
|
+
});
|
|
352
|
+
// Store using session ID (secondary cache, shorter TTL for performance)
|
|
353
|
+
const sessionKey = `session:${sessionId}`;
|
|
354
|
+
await delegationStorage.put(sessionKey, token, {
|
|
355
|
+
expirationTtl: Math.min(ttl, DEFAULT_SESSION_CACHE_TTL),
|
|
356
|
+
});
|
|
357
|
+
console.log('[ConsentService] ✅ Token cached for session:', {
|
|
358
|
+
key: sessionKey,
|
|
359
|
+
ttl: Math.min(ttl, DEFAULT_SESSION_CACHE_TTL),
|
|
360
|
+
sessionId,
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
catch (error) {
|
|
364
|
+
// Storage errors are non-fatal - log but don't fail the request
|
|
365
|
+
console.error('[ConsentService] Storage error (non-fatal):', error);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Render success page
|
|
370
|
+
*
|
|
371
|
+
* @param params - URL search parameters (delegation_id)
|
|
372
|
+
* @returns HTML response
|
|
373
|
+
*/
|
|
374
|
+
async renderSuccessPage(params) {
|
|
375
|
+
const delegationId = params.get('delegation_id') || 'unknown';
|
|
376
|
+
// Get consent config to check auto-close setting
|
|
377
|
+
const projectId = params.get('project_id');
|
|
378
|
+
let autoClose = false;
|
|
379
|
+
if (projectId) {
|
|
380
|
+
try {
|
|
381
|
+
// Await config fetch to ensure autoClose is set before rendering
|
|
382
|
+
const config = await this.configService.getConsentConfig(projectId);
|
|
383
|
+
autoClose = config.ui?.autoClose || false;
|
|
384
|
+
}
|
|
385
|
+
catch (error) {
|
|
386
|
+
// Ignore errors, use default (autoClose = false)
|
|
387
|
+
console.warn('[ConsentService] Failed to fetch config for autoClose:', error);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
const html = this.renderer.renderSuccess({
|
|
391
|
+
delegationId,
|
|
392
|
+
autoClose,
|
|
393
|
+
});
|
|
394
|
+
return new Response(html, {
|
|
395
|
+
status: 200,
|
|
396
|
+
headers: {
|
|
397
|
+
'Content-Type': 'text/html; charset=utf-8',
|
|
398
|
+
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
|
399
|
+
},
|
|
45
400
|
});
|
|
46
401
|
}
|
|
47
402
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consent.service.js","sourceRoot":"","sources":["../../src/services/consent.service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,OAAO,cAAc;IACzB;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,OAAgB;QAC3B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAEjC,IAAI,OAAO,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC;YAC7B,sBAAsB;YACtB,OAAO,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAClD,CAAC;QAED,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;YAC9B,kBAAkB;YAClB,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC;QAED,OAAO,IAAI,QAAQ,CAAC,oBAAoB,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED;;;OAGG;IACK,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,+CAA+C;QAC/C,OAAO,IAAI,QAAQ,CAAC,uCAAuC,EAAE;YAC3D,MAAM,EAAE,GAAG;YACX,OAAO,EAAE,EAAE,cAAc,EAAE,YAAY,EAAE;SAC1C,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACK,KAAK,CAAC,cAAc,CAAC,OAAgB;QAC3C,+CAA+C;QAC/C,OAAO,IAAI,QAAQ,CAAC,2CAA2C,EAAE;YAC/D,MAAM,EAAE,GAAG;YACX,OAAO,EAAE,EAAE,cAAc,EAAE,YAAY,EAAE;SAC1C,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
1
|
+
{"version":3,"file":"consent.service.js","sourceRoot":"","sources":["../../src/services/consent.service.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,mBAA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,GAAG,CAAC,YAAY,CAAC,CAAC;QAC3C,IAAI,SAAS,GAAG,KAAK,CAAC;QAEtB,IAAI,SAAS,EAAE,CAAC;YACd,IAAI,CAAC;gBACH,iEAAiE;gBACjE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;gBACpE,SAAS,GAAG,MAAM,CAAC,EAAE,EAAE,SAAS,IAAI,KAAK,CAAC;YAC5C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,iDAAiD;gBACjD,OAAO,CAAC,IAAI,CAAC,wDAAwD,EAAE,KAAK,CAAC,CAAC;YAChF,CAAC;QACH,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC;YACvC,YAAY;YACZ,SAAS;SACV,CAAC,CAAC;QAEH,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE;YACxB,MAAM,EAAE,GAAG;YACX,OAAO,EAAE;gBACP,cAAc,EAAE,0BAA0B;gBAC1C,eAAe,EAAE,qCAAqC;aACvD;SACF,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proof Batch Queue (Cloudflare Workers Implementation)
|
|
3
|
+
*
|
|
4
|
+
* Platform-agnostic proof batching for Cloudflare Workers.
|
|
5
|
+
* Copied from @kya-os/mcp-i to avoid pulling in @swc/core dependency.
|
|
6
|
+
*
|
|
7
|
+
* Collects proofs in memory and submits them in batches to AgentShield.
|
|
8
|
+
* This prevents blocking tool execution while ensuring proofs are eventually submitted.
|
|
9
|
+
*
|
|
10
|
+
* Performance:
|
|
11
|
+
* - Batch size: 10 proofs (configurable)
|
|
12
|
+
* - Flush interval: 5 seconds (configurable)
|
|
13
|
+
* - Fire-and-forget submission (doesn't block tool execution)
|
|
14
|
+
*
|
|
15
|
+
* Retry Strategy:
|
|
16
|
+
* - Exponential backoff: 1s, 2s, 4s, 8s, 16s
|
|
17
|
+
* - Max retries: 5
|
|
18
|
+
* - Failed proofs logged and dropped after max retries
|
|
19
|
+
*/
|
|
20
|
+
import type { DetachedProof } from '@kya-os/contracts/proof';
|
|
21
|
+
/**
|
|
22
|
+
* Proof submission destination
|
|
23
|
+
*/
|
|
24
|
+
export interface ProofDestination {
|
|
25
|
+
/** Destination name (for logging) */
|
|
26
|
+
name: string;
|
|
27
|
+
/** Submit batch of proofs */
|
|
28
|
+
submit(proofs: DetachedProof[]): Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* AgentShield proof submission destination
|
|
32
|
+
*
|
|
33
|
+
* Submits proofs to AgentShield's /api/v1/bouncer/proofs endpoint
|
|
34
|
+
* with proper authentication and session grouping.
|
|
35
|
+
*/
|
|
36
|
+
export declare class AgentShieldProofDestination implements ProofDestination {
|
|
37
|
+
name: string;
|
|
38
|
+
private apiUrl;
|
|
39
|
+
private apiKey;
|
|
40
|
+
constructor(apiUrl: string, apiKey: string);
|
|
41
|
+
submit(proofs: DetachedProof[]): Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Proof batch queue configuration
|
|
45
|
+
*/
|
|
46
|
+
export interface ProofBatchQueueConfig {
|
|
47
|
+
/** Destinations to submit proofs to */
|
|
48
|
+
destinations: ProofDestination[];
|
|
49
|
+
/** Maximum batch size before auto-flush */
|
|
50
|
+
maxBatchSize?: number;
|
|
51
|
+
/** Flush interval in milliseconds (not used in Cloudflare Workers - rely on cron) */
|
|
52
|
+
flushIntervalMs?: number;
|
|
53
|
+
/** Maximum retry attempts for failed batches */
|
|
54
|
+
maxRetries?: number;
|
|
55
|
+
/** Enable debug logging */
|
|
56
|
+
debug?: boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Proof Batch Queue
|
|
60
|
+
*
|
|
61
|
+
* Collects proofs and submits them in batches to multiple destinations.
|
|
62
|
+
*
|
|
63
|
+
* Note: In Cloudflare Workers, timers don't persist across requests,
|
|
64
|
+
* so automatic flush timers are disabled. Use manual flush() calls via cron jobs.
|
|
65
|
+
*/
|
|
66
|
+
export declare class ProofBatchQueue {
|
|
67
|
+
private queue;
|
|
68
|
+
private pendingBatches;
|
|
69
|
+
private config;
|
|
70
|
+
private closed;
|
|
71
|
+
private stats;
|
|
72
|
+
constructor(config: ProofBatchQueueConfig);
|
|
73
|
+
/**
|
|
74
|
+
* Add proof to queue
|
|
75
|
+
*/
|
|
76
|
+
enqueue(proof: DetachedProof): void;
|
|
77
|
+
/**
|
|
78
|
+
* Flush queue immediately (submit all queued proofs)
|
|
79
|
+
*/
|
|
80
|
+
flush(): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Submit batch to destination (with retries)
|
|
83
|
+
*/
|
|
84
|
+
private submitBatch;
|
|
85
|
+
/**
|
|
86
|
+
* Retry pending batches that are ready
|
|
87
|
+
* Called by cron job or manually
|
|
88
|
+
*/
|
|
89
|
+
retryPending(): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Close queue and flush remaining proofs
|
|
92
|
+
*/
|
|
93
|
+
close(): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Get queue statistics
|
|
96
|
+
*/
|
|
97
|
+
getStats(): {
|
|
98
|
+
queued: number;
|
|
99
|
+
submitted: number;
|
|
100
|
+
failed: number;
|
|
101
|
+
batchesSubmitted: number;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=proof-batch-queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proof-batch-queue.d.ts","sourceRoot":"","sources":["../../src/services/proof-batch-queue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IA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