@kya-os/mcp-i 1.5.4 → 1.5.5
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.
|
@@ -106,14 +106,15 @@ class AgentShieldAPIDelegationVerifier {
|
|
|
106
106
|
console.log(`[AgentShield] Cache MISS for ${agentDid}, calling API...`);
|
|
107
107
|
}
|
|
108
108
|
try {
|
|
109
|
-
|
|
109
|
+
// Use the correct AgentShield bouncer API endpoint
|
|
110
|
+
const response = await fetch(`${this.apiUrl}/api/v1/bouncer/delegations/verify`, {
|
|
110
111
|
method: 'POST',
|
|
111
112
|
headers: {
|
|
112
113
|
'Content-Type': 'application/json',
|
|
113
|
-
'
|
|
114
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
114
115
|
},
|
|
115
116
|
body: JSON.stringify({
|
|
116
|
-
agentDid,
|
|
117
|
+
agent_did: agentDid, // AgentShield uses snake_case
|
|
117
118
|
scopes,
|
|
118
119
|
}),
|
|
119
120
|
});
|
|
@@ -133,30 +134,37 @@ class AgentShieldAPIDelegationVerifier {
|
|
|
133
134
|
}
|
|
134
135
|
throw new Error(`AgentShield API error: ${response.status} ${response.statusText}`);
|
|
135
136
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
//
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
137
|
+
// AgentShield wraps response in success/data structure
|
|
138
|
+
const response_body = await response.json();
|
|
139
|
+
const data = response_body.data || response_body;
|
|
140
|
+
// AgentShield returns either valid with credential or error
|
|
141
|
+
let result;
|
|
142
|
+
if (data.valid && data.credential) {
|
|
143
|
+
// For valid delegations, we only need to return that it's valid
|
|
144
|
+
// The delegation details are not needed for the verification flow
|
|
145
|
+
result = {
|
|
146
|
+
valid: true,
|
|
147
|
+
// Only return delegation if it's in the correct format
|
|
148
|
+
delegation: data.delegation, // This will be undefined if not provided
|
|
149
|
+
reason: undefined,
|
|
150
|
+
cached: false,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
else if (data.error) {
|
|
154
|
+
result = {
|
|
155
|
+
valid: false,
|
|
156
|
+
reason: data.error.message || data.error.code || 'Delegation not valid',
|
|
157
|
+
cached: false,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
result = {
|
|
162
|
+
valid: data.valid || false,
|
|
163
|
+
delegation: data.delegation,
|
|
164
|
+
reason: data.reason || 'Unknown error',
|
|
165
|
+
cached: false,
|
|
166
|
+
};
|
|
153
167
|
}
|
|
154
|
-
const result = {
|
|
155
|
-
valid: data.valid,
|
|
156
|
-
delegation: data.delegation,
|
|
157
|
-
reason: data.reason,
|
|
158
|
-
cached: false,
|
|
159
|
-
};
|
|
160
168
|
// Cache result
|
|
161
169
|
const ttl = data.valid ? this.cacheTtl : this.cacheTtl / 2;
|
|
162
170
|
this.cache.set(cacheKey, result, ttl);
|
|
@@ -185,10 +193,10 @@ class AgentShieldAPIDelegationVerifier {
|
|
|
185
193
|
if (cached)
|
|
186
194
|
return cached;
|
|
187
195
|
try {
|
|
188
|
-
const response = await fetch(`${this.apiUrl}/api/v1/delegations/${delegationId}`, {
|
|
196
|
+
const response = await fetch(`${this.apiUrl}/api/v1/bouncer/delegations/${delegationId}`, {
|
|
189
197
|
method: 'GET',
|
|
190
198
|
headers: {
|
|
191
|
-
'
|
|
199
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
192
200
|
},
|
|
193
201
|
});
|
|
194
202
|
if (!response.ok) {
|
|
@@ -225,11 +233,11 @@ class AgentShieldAPIDelegationVerifier {
|
|
|
225
233
|
throw new Error(`Invalid delegation record: ${parsed.error.message}`);
|
|
226
234
|
}
|
|
227
235
|
try {
|
|
228
|
-
const response = await fetch(`${this.apiUrl}/api/v1/delegations`, {
|
|
236
|
+
const response = await fetch(`${this.apiUrl}/api/v1/bouncer/delegations`, {
|
|
229
237
|
method: 'POST',
|
|
230
238
|
headers: {
|
|
231
239
|
'Content-Type': 'application/json',
|
|
232
|
-
'
|
|
240
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
233
241
|
},
|
|
234
242
|
body: JSON.stringify(delegation),
|
|
235
243
|
});
|
|
@@ -255,11 +263,11 @@ class AgentShieldAPIDelegationVerifier {
|
|
|
255
263
|
*/
|
|
256
264
|
async revoke(delegationId, reason) {
|
|
257
265
|
try {
|
|
258
|
-
const response = await fetch(`${this.apiUrl}/api/v1/delegations/${delegationId}/revoke`, {
|
|
266
|
+
const response = await fetch(`${this.apiUrl}/api/v1/bouncer/delegations/${delegationId}/revoke`, {
|
|
259
267
|
method: 'POST',
|
|
260
268
|
headers: {
|
|
261
269
|
'Content-Type': 'application/json',
|
|
262
|
-
'
|
|
270
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
263
271
|
},
|
|
264
272
|
body: JSON.stringify({ reason }),
|
|
265
273
|
});
|