@kya-os/mcp-i 1.3.0 → 1.3.2
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/dist/runtime/proof.d.ts
CHANGED
|
@@ -53,8 +53,7 @@ export declare class ProofGenerator {
|
|
|
53
53
|
*/
|
|
54
54
|
private generateSHA256Hash;
|
|
55
55
|
/**
|
|
56
|
-
* JCS canonicalization implementation
|
|
57
|
-
* This is a simplified implementation - in production, use a proper JCS library
|
|
56
|
+
* JCS canonicalization implementation (RFC 8785)
|
|
58
57
|
*/
|
|
59
58
|
private canonicalizeJSON;
|
|
60
59
|
/**
|
|
@@ -63,7 +62,7 @@ export declare class ProofGenerator {
|
|
|
63
62
|
*/
|
|
64
63
|
private generateDetachedJWS;
|
|
65
64
|
/**
|
|
66
|
-
* Format base64 private key as PEM for JOSE library
|
|
65
|
+
* Format base64 private key as PKCS#8 PEM for JOSE library
|
|
67
66
|
*/
|
|
68
67
|
private formatPrivateKeyAsPEM;
|
|
69
68
|
/**
|
package/dist/runtime/proof.js
CHANGED
|
@@ -11,6 +11,7 @@ exports.createProofResponse = createProofResponse;
|
|
|
11
11
|
exports.extractCanonicalData = extractCanonicalData;
|
|
12
12
|
const crypto_1 = require("crypto");
|
|
13
13
|
const jose_1 = require("jose");
|
|
14
|
+
const json_canonicalize_1 = require("json-canonicalize");
|
|
14
15
|
/**
|
|
15
16
|
* Proof generator class
|
|
16
17
|
*/
|
|
@@ -79,39 +80,10 @@ class ProofGenerator {
|
|
|
79
80
|
return `sha256:${hash}`;
|
|
80
81
|
}
|
|
81
82
|
/**
|
|
82
|
-
* JCS canonicalization implementation
|
|
83
|
-
* This is a simplified implementation - in production, use a proper JCS library
|
|
83
|
+
* JCS canonicalization implementation (RFC 8785)
|
|
84
84
|
*/
|
|
85
85
|
canonicalizeJSON(obj) {
|
|
86
|
-
|
|
87
|
-
return "null";
|
|
88
|
-
if (typeof obj === "boolean")
|
|
89
|
-
return obj.toString();
|
|
90
|
-
if (typeof obj === "number") {
|
|
91
|
-
// Handle special number cases
|
|
92
|
-
if (Number.isNaN(obj))
|
|
93
|
-
return "null";
|
|
94
|
-
if (!Number.isFinite(obj))
|
|
95
|
-
return "null";
|
|
96
|
-
return obj.toString();
|
|
97
|
-
}
|
|
98
|
-
if (typeof obj === "string")
|
|
99
|
-
return JSON.stringify(obj);
|
|
100
|
-
if (Array.isArray(obj)) {
|
|
101
|
-
const items = obj.map((item) => this.canonicalizeJSON(item));
|
|
102
|
-
return `[${items.join(",")}]`;
|
|
103
|
-
}
|
|
104
|
-
if (typeof obj === "object") {
|
|
105
|
-
// Sort keys for canonical ordering
|
|
106
|
-
const sortedKeys = Object.keys(obj).sort();
|
|
107
|
-
const pairs = sortedKeys.map((key) => {
|
|
108
|
-
const value = this.canonicalizeJSON(obj[key]);
|
|
109
|
-
return `${JSON.stringify(key)}:${value}`;
|
|
110
|
-
});
|
|
111
|
-
return `{${pairs.join(",")}}`;
|
|
112
|
-
}
|
|
113
|
-
// Fallback for other types
|
|
114
|
-
return JSON.stringify(obj);
|
|
86
|
+
return (0, json_canonicalize_1.canonicalize)(obj);
|
|
115
87
|
}
|
|
116
88
|
/**
|
|
117
89
|
* Generate Ed25519 detached JWS (compact format)
|
|
@@ -138,17 +110,14 @@ class ProofGenerator {
|
|
|
138
110
|
}
|
|
139
111
|
}
|
|
140
112
|
/**
|
|
141
|
-
* Format base64 private key as PEM for JOSE library
|
|
113
|
+
* Format base64 private key as PKCS#8 PEM for JOSE library
|
|
142
114
|
*/
|
|
143
115
|
formatPrivateKeyAsPEM(base64PrivateKey) {
|
|
144
|
-
// For Ed25519, we need to format as PKCS#8 PEM
|
|
145
|
-
// This is a simplified implementation - in production, use proper key formatting
|
|
146
116
|
const keyData = Buffer.from(base64PrivateKey, "base64");
|
|
147
117
|
// Ed25519 PKCS#8 header and footer
|
|
148
118
|
const header = "-----BEGIN PRIVATE KEY-----\n";
|
|
149
119
|
const footer = "\n-----END PRIVATE KEY-----";
|
|
150
|
-
//
|
|
151
|
-
// This is a simplified approach - in production, use proper ASN.1 encoding
|
|
120
|
+
// Wrap Ed25519 raw key in PKCS#8 structure (ASN.1 encoding)
|
|
152
121
|
const pkcs8Header = Buffer.from([
|
|
153
122
|
0x30,
|
|
154
123
|
0x2e, // SEQUENCE, length 46
|