@kya-os/mcp-i 1.12.2 → 1.12.4
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 +5 -5
- package/dist/125.js +1 -0
- package/dist/runtime/248.js +1 -0
- package/dist/runtime/adapter-express.js +3 -3
- package/dist/runtime/adapter-nextjs.js +3 -3
- package/dist/runtime/delegation-verifier-agentshield.d.ts +5 -5
- package/dist/runtime/delegation-verifier-agentshield.js +20 -20
- package/dist/runtime/delegation-verifier.d.ts +3 -3
- package/dist/runtime/delegation-verifier.js +1 -1
- package/dist/runtime/http.js +3 -3
- package/dist/runtime/identity.d.ts +26 -0
- package/dist/runtime/identity.js +37 -4
- package/dist/runtime/mcpi-runtime-wrapper.js +4 -2
- package/dist/runtime/mcpi-runtime.d.ts +2 -2
- package/dist/runtime/mcpi-runtime.js +63 -62
- package/dist/runtime/proof-batch-queue.d.ts +3 -3
- package/dist/runtime/proof-batch-queue.js +9 -9
- package/dist/runtime/stdio.js +3 -3
- package/dist/runtime/tool-protection.d.ts +4 -4
- package/dist/runtime/tool-protection.js +5 -5
- package/dist/runtime/utils/tools.js +5 -5
- package/dist/test/examples/test-usage-example.d.ts +8 -8
- package/package.json +3 -3
- package/dist/365.js +0 -1
- package/dist/runtime/160.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Checkpoint API Delegation Verifier
|
|
3
3
|
*
|
|
4
|
-
* Queries delegations from
|
|
4
|
+
* Queries delegations from Checkpoint managed service API.
|
|
5
5
|
* Includes local caching to minimize network calls and maximize performance.
|
|
6
6
|
*
|
|
7
7
|
* Performance:
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
import { DelegationRecord } from "@kya-os/contracts/delegation";
|
|
24
24
|
import { DelegationVerifier, DelegationVerifierConfig, VerifyDelegationResult, VerifyDelegationOptions } from "./delegation-verifier";
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* Checkpoint API Delegation Verifier
|
|
27
27
|
*
|
|
28
|
-
* Managed mode: Queries delegations from
|
|
28
|
+
* Managed mode: Queries delegations from Checkpoint dashboard API
|
|
29
29
|
*/
|
|
30
30
|
export declare class AgentShieldAPIDelegationVerifier implements DelegationVerifier {
|
|
31
31
|
private apiUrl;
|
|
@@ -46,7 +46,7 @@ export declare class AgentShieldAPIDelegationVerifier implements DelegationVerif
|
|
|
46
46
|
/**
|
|
47
47
|
* Store delegation (admin operation via API)
|
|
48
48
|
*
|
|
49
|
-
* Note: This is typically done via
|
|
49
|
+
* Note: This is typically done via Checkpoint dashboard UI,
|
|
50
50
|
* not by the bouncer directly. Included for completeness.
|
|
51
51
|
*/
|
|
52
52
|
put(delegation: DelegationRecord): Promise<void>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Checkpoint API Delegation Verifier
|
|
4
4
|
*
|
|
5
|
-
* Queries delegations from
|
|
5
|
+
* Queries delegations from Checkpoint managed service API.
|
|
6
6
|
* Includes local caching to minimize network calls and maximize performance.
|
|
7
7
|
*
|
|
8
8
|
* Performance:
|
|
@@ -66,11 +66,11 @@ class DelegationCache {
|
|
|
66
66
|
this.cache.clear();
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
// Use standard
|
|
69
|
+
// Use standard Checkpoint API response types from contracts
|
|
70
70
|
/**
|
|
71
|
-
*
|
|
71
|
+
* Checkpoint API Delegation Verifier
|
|
72
72
|
*
|
|
73
|
-
* Managed mode: Queries delegations from
|
|
73
|
+
* Managed mode: Queries delegations from Checkpoint dashboard API
|
|
74
74
|
*/
|
|
75
75
|
class AgentShieldAPIDelegationVerifier {
|
|
76
76
|
apiUrl;
|
|
@@ -95,7 +95,7 @@ class AgentShieldAPIDelegationVerifier {
|
|
|
95
95
|
apiKey: this.apiKey,
|
|
96
96
|
fetchProvider,
|
|
97
97
|
logger: this.debug
|
|
98
|
-
? (msg, data) => console.error(`[
|
|
98
|
+
? (msg, data) => console.error(`[Checkpoint] ${msg}`, data)
|
|
99
99
|
: undefined,
|
|
100
100
|
});
|
|
101
101
|
}
|
|
@@ -124,7 +124,7 @@ class AgentShieldAPIDelegationVerifier {
|
|
|
124
124
|
const cached = this.cache.get(cacheKey);
|
|
125
125
|
if (cached) {
|
|
126
126
|
if (this.debug) {
|
|
127
|
-
console.error(`[
|
|
127
|
+
console.error(`[Checkpoint] Cache HIT for ${agentDid} (${Date.now() - startTime}ms)`);
|
|
128
128
|
}
|
|
129
129
|
// Return cached result with cached flag set to true
|
|
130
130
|
return {
|
|
@@ -135,7 +135,7 @@ class AgentShieldAPIDelegationVerifier {
|
|
|
135
135
|
}
|
|
136
136
|
// Slow path: API call
|
|
137
137
|
if (this.debug) {
|
|
138
|
-
console.error(`[
|
|
138
|
+
console.error(`[Checkpoint] Cache MISS for ${agentDid}, calling API...`);
|
|
139
139
|
}
|
|
140
140
|
try {
|
|
141
141
|
// Validate request input using contracts schema
|
|
@@ -161,13 +161,13 @@ class AgentShieldAPIDelegationVerifier {
|
|
|
161
161
|
const ttl = data.valid ? this.cacheTtl : this.cacheTtl / 2;
|
|
162
162
|
this.cache.set(cacheKey, result, ttl);
|
|
163
163
|
if (this.debug) {
|
|
164
|
-
console.error(`[
|
|
164
|
+
console.error(`[Checkpoint] Delegation ${data.valid ? "verified" : "rejected"} (${Date.now() - startTime}ms)`);
|
|
165
165
|
}
|
|
166
166
|
// Return result with cached: false for API calls
|
|
167
167
|
return { ...result, cached: false };
|
|
168
168
|
}
|
|
169
169
|
catch (error) {
|
|
170
|
-
console.error("[
|
|
170
|
+
console.error("[Checkpoint] API call failed:", error);
|
|
171
171
|
// Return negative result on error (don't cache failures)
|
|
172
172
|
// Use standard error format
|
|
173
173
|
if (error instanceof agentshield_api_1.AgentShieldAPIError) {
|
|
@@ -204,25 +204,25 @@ class AgentShieldAPIDelegationVerifier {
|
|
|
204
204
|
if (!response.ok) {
|
|
205
205
|
if (response.status === 404)
|
|
206
206
|
return null;
|
|
207
|
-
throw new Error(`
|
|
207
|
+
throw new Error(`Checkpoint API error: ${response.status}`);
|
|
208
208
|
}
|
|
209
209
|
const data = await response.json();
|
|
210
210
|
const parsed = delegation_1.DelegationRecordSchema.safeParse(data);
|
|
211
211
|
if (!parsed.success) {
|
|
212
|
-
console.error("[
|
|
212
|
+
console.error("[Checkpoint] Invalid delegation in API response:", parsed.error);
|
|
213
213
|
return null;
|
|
214
214
|
}
|
|
215
215
|
return parsed.data;
|
|
216
216
|
}
|
|
217
217
|
catch (error) {
|
|
218
|
-
console.error("[
|
|
218
|
+
console.error("[Checkpoint] Failed to get delegation:", error);
|
|
219
219
|
return null;
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
/**
|
|
223
223
|
* Store delegation (admin operation via API)
|
|
224
224
|
*
|
|
225
|
-
* Note: This is typically done via
|
|
225
|
+
* Note: This is typically done via Checkpoint dashboard UI,
|
|
226
226
|
* not by the bouncer directly. Included for completeness.
|
|
227
227
|
*/
|
|
228
228
|
async put(delegation) {
|
|
@@ -241,7 +241,7 @@ class AgentShieldAPIDelegationVerifier {
|
|
|
241
241
|
body: JSON.stringify(delegation),
|
|
242
242
|
});
|
|
243
243
|
if (!response.ok) {
|
|
244
|
-
throw new Error(`
|
|
244
|
+
throw new Error(`Checkpoint API error: ${response.status} ${response.statusText}`);
|
|
245
245
|
}
|
|
246
246
|
// Invalidate cache
|
|
247
247
|
const delegationScopes = (0, delegation_verifier_1.extractScopes)(delegation);
|
|
@@ -249,11 +249,11 @@ class AgentShieldAPIDelegationVerifier {
|
|
|
249
249
|
this.cache.delete(`delegation:${delegation.id}`);
|
|
250
250
|
this.cache.delete(`verify:${delegation.subjectDid}:${scopesKey}`);
|
|
251
251
|
if (this.debug) {
|
|
252
|
-
console.error(`[
|
|
252
|
+
console.error(`[Checkpoint] Stored delegation ${delegation.id}`);
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
catch (error) {
|
|
256
|
-
console.error("[
|
|
256
|
+
console.error("[Checkpoint] Failed to store delegation:", error);
|
|
257
257
|
throw error;
|
|
258
258
|
}
|
|
259
259
|
}
|
|
@@ -271,16 +271,16 @@ class AgentShieldAPIDelegationVerifier {
|
|
|
271
271
|
body: JSON.stringify({ reason }),
|
|
272
272
|
});
|
|
273
273
|
if (!response.ok) {
|
|
274
|
-
throw new Error(`
|
|
274
|
+
throw new Error(`Checkpoint API error: ${response.status} ${response.statusText}`);
|
|
275
275
|
}
|
|
276
276
|
// Invalidate cache
|
|
277
277
|
this.cache.delete(`delegation:${delegationId}`);
|
|
278
278
|
if (this.debug) {
|
|
279
|
-
console.error(`[
|
|
279
|
+
console.error(`[Checkpoint] Revoked delegation ${delegationId}`);
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
282
|
catch (error) {
|
|
283
|
-
console.error("[
|
|
283
|
+
console.error("[Checkpoint] Failed to revoke delegation:", error);
|
|
284
284
|
throw error;
|
|
285
285
|
}
|
|
286
286
|
}
|
|
@@ -21,7 +21,7 @@ export interface VerifyDelegationResult {
|
|
|
21
21
|
valid: boolean;
|
|
22
22
|
/** The delegation record (if found) */
|
|
23
23
|
delegation?: DelegationRecord;
|
|
24
|
-
/** Credential from
|
|
24
|
+
/** Credential from Checkpoint API (includes authorization method) */
|
|
25
25
|
credential?: {
|
|
26
26
|
agent_did: string;
|
|
27
27
|
user_did: string;
|
|
@@ -170,7 +170,7 @@ export interface DelegationVerifierConfig {
|
|
|
170
170
|
}>;
|
|
171
171
|
}>;
|
|
172
172
|
};
|
|
173
|
-
/**
|
|
173
|
+
/** Checkpoint API configuration (for agentshield-api type) */
|
|
174
174
|
agentshield?: {
|
|
175
175
|
apiUrl: string;
|
|
176
176
|
apiKey: string;
|
|
@@ -186,7 +186,7 @@ export interface DelegationVerifierConfig {
|
|
|
186
186
|
* Note: We import all adapters statically for better compatibility.
|
|
187
187
|
* Tree-shaking will remove unused adapters in production builds.
|
|
188
188
|
*
|
|
189
|
-
* Note:
|
|
189
|
+
* Note: Checkpoint API responses use standard wrapper format
|
|
190
190
|
* { success: boolean, data: {...}, metadata?: {...} } as defined in
|
|
191
191
|
* @kya-os/contracts/agentshield-api. This is handled in the
|
|
192
192
|
* AgentShieldAPIDelegationVerifier implementation.
|
|
@@ -95,7 +95,7 @@ exports.VerifyDelegationInputSchema = zod_1.z.object({
|
|
|
95
95
|
* Note: We import all adapters statically for better compatibility.
|
|
96
96
|
* Tree-shaking will remove unused adapters in production builds.
|
|
97
97
|
*
|
|
98
|
-
* Note:
|
|
98
|
+
* Note: Checkpoint API responses use standard wrapper format
|
|
99
99
|
* { success: boolean, data: {...}, metadata?: {...} } as defined in
|
|
100
100
|
* @kya-os/contracts/agentshield-api. This is handled in the
|
|
101
101
|
* AgentShieldAPIDelegationVerifier implementation.
|