@kya-os/mcp-i 1.5.6-canary.3 → 1.5.8-canary.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.
@@ -33,6 +33,7 @@ export declare class AgentShieldAPIDelegationVerifier implements DelegationVerif
33
33
  private cache;
34
34
  private cacheTtl;
35
35
  private debug;
36
+ private accessControlService;
36
37
  constructor(config: DelegationVerifierConfig);
37
38
  /**
38
39
  * Verify agent delegation via API
@@ -26,6 +26,8 @@ exports.AgentShieldAPIDelegationVerifier = void 0;
26
26
  const delegation_1 = require("@kya-os/contracts/delegation");
27
27
  const agentshield_api_1 = require("@kya-os/contracts/agentshield-api");
28
28
  const delegation_verifier_1 = require("./delegation-verifier");
29
+ const mcp_i_core_1 = require("@kya-os/mcp-i-core");
30
+ const node_providers_1 = require("../providers/node-providers");
29
31
  /**
30
32
  * Simple in-memory cache (same as KV verifier)
31
33
  */
@@ -75,6 +77,7 @@ class AgentShieldAPIDelegationVerifier {
75
77
  cache;
76
78
  cacheTtl;
77
79
  debug;
80
+ accessControlService;
78
81
  constructor(config) {
79
82
  if (!config.agentshield?.apiUrl || !config.agentshield?.apiKey) {
80
83
  throw new Error("AgentShieldAPIDelegationVerifier requires agentshield.apiUrl and agentshield.apiKey in config");
@@ -84,6 +87,14 @@ class AgentShieldAPIDelegationVerifier {
84
87
  this.cache = new DelegationCache();
85
88
  this.cacheTtl = config.cacheTtl || 60_000; // Default 1 minute
86
89
  this.debug = config.debug || false;
90
+ // Create AccessControlApiService instance
91
+ const fetchProvider = new node_providers_1.NodeFetchProvider();
92
+ this.accessControlService = new mcp_i_core_1.AccessControlApiService({
93
+ baseUrl: this.apiUrl,
94
+ apiKey: this.apiKey,
95
+ fetchProvider,
96
+ logger: this.debug ? (msg, data) => console.log(`[AgentShield] ${msg}`, data) : undefined,
97
+ });
87
98
  }
88
99
  /**
89
100
  * Verify agent delegation via API
@@ -125,65 +136,10 @@ class AgentShieldAPIDelegationVerifier {
125
136
  agent_did: agentDid,
126
137
  scopes,
127
138
  });
128
- // Use the correct AgentShield bouncer API endpoint
129
- const response = await fetch(`${this.apiUrl}/api/v1/bouncer/delegations/verify`, {
130
- method: "POST",
131
- headers: {
132
- "Content-Type": "application/json",
133
- Authorization: `Bearer ${this.apiKey}`,
134
- },
135
- body: JSON.stringify(requestBody),
136
- });
137
- if (!response.ok) {
138
- // Handle API errors using standard error format
139
- if (response.status === 404) {
140
- const result = {
141
- valid: false,
142
- reason: "No delegation found",
143
- cached: false,
144
- };
145
- this.cache.set(cacheKey, result, this.cacheTtl / 2);
146
- return result;
147
- }
148
- if (response.status === 401 || response.status === 403) {
149
- const error = {
150
- error: "authentication_failed",
151
- message: `AgentShield API authentication failed: ${response.status}`,
152
- httpStatus: response.status,
153
- };
154
- throw new agentshield_api_1.AgentShieldAPIError(error.error, error.message, error.details);
155
- }
156
- const error = {
157
- error: "api_error",
158
- message: `AgentShield API error: ${response.status} ${response.statusText}`,
159
- httpStatus: response.status,
160
- };
161
- throw new agentshield_api_1.AgentShieldAPIError(error.error, error.message, error.details);
162
- }
163
- // Validate response using standard AgentShield API response schema
164
- const responseBody = await response.json();
165
- const parsedResponse = agentshield_api_1.verifyDelegationAPIResponseSchema.safeParse(responseBody);
166
- if (!parsedResponse.success) {
167
- // If response doesn't match standard wrapper, try direct data format
168
- const directData = agentshield_api_1.verifyDelegationResponseSchema.safeParse(responseBody);
169
- if (!directData.success) {
170
- throw new agentshield_api_1.AgentShieldAPIError("invalid_response", "AgentShield API returned invalid response format", { validationErrors: parsedResponse.error.errors });
171
- }
172
- // Use direct data format (backward compatibility)
173
- const data = directData.data;
174
- const result = {
175
- valid: data.valid,
176
- delegation: data.delegation,
177
- reason: data.reason,
178
- cached: false,
179
- };
180
- const ttl = data.valid ? this.cacheTtl : this.cacheTtl / 2;
181
- this.cache.set(cacheKey, result, ttl);
182
- return result;
183
- }
184
- // Standard wrapped response format
185
- const wrappedResponse = parsedResponse.data;
186
- const data = wrappedResponse.data;
139
+ // Use AccessControlApiService for API call
140
+ const response = await this.accessControlService.verifyDelegation(requestBody);
141
+ // Extract data from wrapped response
142
+ const data = response.data;
187
143
  // Build result from validated response
188
144
  const result = {
189
145
  valid: data.valid,