@kya-os/mcp-i 1.7.8 → 1.7.9
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.
|
@@ -245,15 +245,34 @@ class DelegationCredentialVerifier {
|
|
|
245
245
|
const vcWithoutProof = { ...vc };
|
|
246
246
|
delete vcWithoutProof.proof;
|
|
247
247
|
// The proof.proofValue is base64url-encoded Ed25519 signature
|
|
248
|
-
// The proof.jws is an alternative JWS-based signature format
|
|
249
|
-
const
|
|
250
|
-
if (!
|
|
248
|
+
// The proof.jws is an alternative JWS-based signature format (header.payload.signature)
|
|
249
|
+
const rawProofValue = vc.proof?.proofValue || vc.proof?.jws;
|
|
250
|
+
if (!rawProofValue) {
|
|
251
251
|
return {
|
|
252
252
|
valid: false,
|
|
253
253
|
reason: 'Proof missing proofValue or jws',
|
|
254
254
|
durationMs: Date.now() - startTime,
|
|
255
255
|
};
|
|
256
256
|
}
|
|
257
|
+
// Extract signature bytes - handle JWS format (header.payload.signature)
|
|
258
|
+
// JWS compact serialization splits into 3 parts; only the 3rd is the signature
|
|
259
|
+
let signatureBase64url;
|
|
260
|
+
if (rawProofValue.includes('.')) {
|
|
261
|
+
// JWS format: extract the signature (third segment)
|
|
262
|
+
const jwsParts = rawProofValue.split('.');
|
|
263
|
+
if (jwsParts.length !== 3) {
|
|
264
|
+
return {
|
|
265
|
+
valid: false,
|
|
266
|
+
reason: `Invalid JWS format: expected 3 parts, got ${jwsParts.length}`,
|
|
267
|
+
durationMs: Date.now() - startTime,
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
signatureBase64url = jwsParts[2];
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
// proofValue is raw base64url signature
|
|
274
|
+
signatureBase64url = rawProofValue;
|
|
275
|
+
}
|
|
257
276
|
try {
|
|
258
277
|
// For Ed25519Signature2020, we need to:
|
|
259
278
|
// 1. Canonicalize the VC without proofValue
|
|
@@ -274,7 +293,7 @@ class DelegationCredentialVerifier {
|
|
|
274
293
|
const proofHash = (0, crypto_1.createHash)('sha256').update(canonicalProof, 'utf8').digest();
|
|
275
294
|
const signingInput = Buffer.concat([proofHash, docHash]);
|
|
276
295
|
// Decode the base64url signature
|
|
277
|
-
const signatureBytes = Buffer.from(
|
|
296
|
+
const signatureBytes = Buffer.from(signatureBase64url, 'base64url');
|
|
278
297
|
// Use subtle crypto for Ed25519 verification
|
|
279
298
|
const cryptoKey = await globalThis.crypto.subtle.importKey('jwk', publicKeyJwk, { name: 'Ed25519' }, false, ['verify']);
|
|
280
299
|
const isValid = await globalThis.crypto.subtle.verify({ name: 'Ed25519' }, cryptoKey, signatureBytes, signingInput);
|