@kya-os/mcp-i 0.1.0-alpha.1.0 → 0.1.0-alpha.2.0
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 +158 -62
- package/dist/__tests__/challenge-response.test.d.ts +5 -0
- package/dist/__tests__/challenge-response.test.d.ts.map +1 -0
- package/dist/__tests__/challenge-response.test.js +217 -0
- package/dist/__tests__/challenge-response.test.js.map +1 -0
- package/dist/__tests__/crypto.test.d.ts +5 -0
- package/dist/__tests__/crypto.test.d.ts.map +1 -0
- package/dist/__tests__/crypto.test.js +153 -0
- package/dist/__tests__/crypto.test.js.map +1 -0
- package/dist/crypto.d.ts +32 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/crypto.js +117 -0
- package/dist/crypto.js.map +1 -0
- package/dist/index.d.ts +35 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +139 -21
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +78 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +7 -4
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* @kya-os/mcp-i - Ultra-light MCP Identity auto-registration
|
|
3
|
+
* @kya-os/mcp-i - Ultra-light MCP Identity auto-registration with challenge-response authentication
|
|
4
4
|
*
|
|
5
5
|
* Enable any MCP server to get a verifiable identity with just 2 lines of code:
|
|
6
6
|
*
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* const identity = await MCPIdentity.init();
|
|
10
10
|
* ```
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* Now with full MCP-I Handshake support including cryptographic challenge-response!
|
|
13
13
|
*/
|
|
14
14
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15
15
|
if (k2 === undefined) k2 = k;
|
|
@@ -44,6 +44,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
44
44
|
return result;
|
|
45
45
|
};
|
|
46
46
|
})();
|
|
47
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
48
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
49
|
+
};
|
|
47
50
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
51
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
52
|
};
|
|
@@ -52,11 +55,21 @@ exports.MCPIdentity = void 0;
|
|
|
52
55
|
const axios_1 = __importDefault(require("axios"));
|
|
53
56
|
const fs = __importStar(require("fs"));
|
|
54
57
|
const path = __importStar(require("path"));
|
|
58
|
+
const crypto = __importStar(require("./crypto"));
|
|
59
|
+
// Re-export types for convenience
|
|
60
|
+
__exportStar(require("./types"), exports);
|
|
55
61
|
class MCPIdentity {
|
|
56
|
-
constructor(identity) {
|
|
62
|
+
constructor(identity, options = {}) {
|
|
63
|
+
this.usedNonces = new Set();
|
|
57
64
|
this.did = identity.did;
|
|
58
65
|
this.publicKey = identity.publicKey;
|
|
59
66
|
this.privateKey = identity.privateKey;
|
|
67
|
+
this.timestampTolerance = options.timestampTolerance || 60000; // 60 seconds
|
|
68
|
+
this.enableNonceTracking = options.enableNonceTracking !== false;
|
|
69
|
+
// Start nonce cleanup if tracking is enabled
|
|
70
|
+
if (this.enableNonceTracking) {
|
|
71
|
+
this.startNonceCleanup();
|
|
72
|
+
}
|
|
60
73
|
}
|
|
61
74
|
/**
|
|
62
75
|
* Initialize MCP Identity - the main entry point
|
|
@@ -88,50 +101,147 @@ class MCPIdentity {
|
|
|
88
101
|
agentSlug: response.agent.slug,
|
|
89
102
|
registeredAt: new Date().toISOString(),
|
|
90
103
|
};
|
|
104
|
+
// If no private key was provided, generate one
|
|
105
|
+
if (!identity.privateKey) {
|
|
106
|
+
console.log('[MCP-I] Generating cryptographic keys...');
|
|
107
|
+
const keyPair = await crypto.generateKeyPair();
|
|
108
|
+
identity.publicKey = keyPair.publicKey;
|
|
109
|
+
identity.privateKey = keyPair.privateKey;
|
|
110
|
+
}
|
|
91
111
|
// Save for future use
|
|
92
112
|
await saveIdentity(identity, options?.persistencePath);
|
|
93
113
|
console.log('[MCP-I] ✅ Success! Your agent has been registered.');
|
|
94
114
|
console.log(`[MCP-I] DID: ${response.did}`);
|
|
95
115
|
console.log(`[MCP-I] Profile: ${response.agent.url}`);
|
|
96
116
|
}
|
|
97
|
-
return new MCPIdentity(identity);
|
|
117
|
+
return new MCPIdentity(identity, options);
|
|
98
118
|
}
|
|
99
119
|
/**
|
|
100
|
-
* Sign a message with the agent's private key
|
|
120
|
+
* Sign a message with the agent's private key using Ed25519
|
|
101
121
|
*/
|
|
102
122
|
async sign(message) {
|
|
103
|
-
|
|
104
|
-
return Buffer.from(`${this.privateKey}:${message}`).toString('base64');
|
|
123
|
+
return crypto.sign(message, this.privateKey);
|
|
105
124
|
}
|
|
106
125
|
/**
|
|
107
|
-
*
|
|
126
|
+
* Verify a signature against a public key
|
|
127
|
+
*/
|
|
128
|
+
async verify(message, signature, publicKey) {
|
|
129
|
+
return crypto.verify(message, signature, publicKey || this.publicKey);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Respond to an MCP-I challenge
|
|
133
|
+
* This is the core of the challenge-response authentication system
|
|
134
|
+
*/
|
|
135
|
+
async respondToChallenge(challenge) {
|
|
136
|
+
// Validate timestamp to prevent replay attacks
|
|
137
|
+
const now = Date.now();
|
|
138
|
+
const challengeAge = now - challenge.timestamp;
|
|
139
|
+
if (challengeAge > this.timestampTolerance) {
|
|
140
|
+
throw new Error('Challenge expired');
|
|
141
|
+
}
|
|
142
|
+
if (challengeAge < 0) {
|
|
143
|
+
throw new Error('Challenge timestamp is in the future');
|
|
144
|
+
}
|
|
145
|
+
// Check for nonce reuse if tracking is enabled
|
|
146
|
+
if (this.enableNonceTracking) {
|
|
147
|
+
if (this.usedNonces.has(challenge.nonce)) {
|
|
148
|
+
throw new Error('Nonce already used');
|
|
149
|
+
}
|
|
150
|
+
this.usedNonces.add(challenge.nonce);
|
|
151
|
+
}
|
|
152
|
+
// Create the message to sign
|
|
153
|
+
const messageComponents = [
|
|
154
|
+
challenge.nonce,
|
|
155
|
+
challenge.timestamp.toString(),
|
|
156
|
+
this.did,
|
|
157
|
+
challenge.verifier_did || '',
|
|
158
|
+
(challenge.scope || []).join(',')
|
|
159
|
+
];
|
|
160
|
+
const message = messageComponents.join(':');
|
|
161
|
+
// Sign the challenge
|
|
162
|
+
const signature = await this.sign(message);
|
|
163
|
+
// Return the response
|
|
164
|
+
return {
|
|
165
|
+
did: this.did,
|
|
166
|
+
signature,
|
|
167
|
+
timestamp: now,
|
|
168
|
+
nonce: challenge.nonce,
|
|
169
|
+
publicKey: this.publicKey
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Get MCP-I capabilities for advertisement
|
|
108
174
|
*/
|
|
109
175
|
getCapabilities() {
|
|
110
176
|
return {
|
|
111
177
|
version: '1.0',
|
|
112
178
|
did: this.did,
|
|
113
179
|
publicKey: this.publicKey,
|
|
114
|
-
conformanceLevel:
|
|
180
|
+
conformanceLevel: 2, // Level 2: Full crypto with challenge-response
|
|
181
|
+
handshakeSupported: true,
|
|
182
|
+
handshakeEndpoint: '/_mcp-i/handshake',
|
|
183
|
+
verificationEndpoint: `https://knowthat.ai/api/agents/${this.did}/verify`
|
|
115
184
|
};
|
|
116
185
|
}
|
|
117
186
|
/**
|
|
118
|
-
* Sign an MCP response
|
|
187
|
+
* Sign an MCP response with identity metadata
|
|
119
188
|
*/
|
|
120
|
-
signResponse(response) {
|
|
121
|
-
|
|
189
|
+
async signResponse(response) {
|
|
190
|
+
const timestamp = new Date().toISOString();
|
|
191
|
+
const responseWithIdentity = {
|
|
122
192
|
...response,
|
|
123
193
|
_mcp_identity: {
|
|
124
194
|
did: this.did,
|
|
125
|
-
signature:
|
|
126
|
-
timestamp
|
|
195
|
+
signature: '', // Will be filled below
|
|
196
|
+
timestamp,
|
|
197
|
+
conformanceLevel: 2
|
|
127
198
|
}
|
|
128
199
|
};
|
|
200
|
+
// Sign the response content (excluding the signature field)
|
|
201
|
+
const contentToSign = JSON.stringify({
|
|
202
|
+
...response,
|
|
203
|
+
_mcp_identity: {
|
|
204
|
+
did: this.did,
|
|
205
|
+
timestamp,
|
|
206
|
+
conformanceLevel: 2
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
responseWithIdentity._mcp_identity.signature = await this.sign(contentToSign);
|
|
210
|
+
return responseWithIdentity;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Generate a new nonce for challenges
|
|
214
|
+
*/
|
|
215
|
+
static generateNonce() {
|
|
216
|
+
return crypto.generateNonce();
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Clean up old nonces periodically to prevent memory leaks
|
|
220
|
+
*/
|
|
221
|
+
startNonceCleanup() {
|
|
222
|
+
// Clean up nonces older than 2x the timestamp tolerance
|
|
223
|
+
this.nonceCleanupInterval = setInterval(() => {
|
|
224
|
+
// In a production system, you'd track nonce timestamps
|
|
225
|
+
// For now, we'll clear all nonces periodically
|
|
226
|
+
if (this.usedNonces.size > 10000) {
|
|
227
|
+
this.usedNonces.clear();
|
|
228
|
+
}
|
|
229
|
+
}, this.timestampTolerance * 2);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Clean up resources
|
|
233
|
+
*/
|
|
234
|
+
destroy() {
|
|
235
|
+
if (this.nonceCleanupInterval) {
|
|
236
|
+
clearInterval(this.nonceCleanupInterval);
|
|
237
|
+
}
|
|
238
|
+
this.usedNonces.clear();
|
|
129
239
|
}
|
|
130
240
|
}
|
|
131
241
|
exports.MCPIdentity = MCPIdentity;
|
|
132
242
|
// Helper functions (inline to keep package standalone)
|
|
133
243
|
async function loadIdentity(customPath) {
|
|
134
|
-
// Check environment variables first
|
|
244
|
+
// Check environment variables first (already loaded by process)
|
|
135
245
|
if (process.env.AGENT_DID && process.env.AGENT_PUBLIC_KEY && process.env.AGENT_PRIVATE_KEY) {
|
|
136
246
|
return {
|
|
137
247
|
did: process.env.AGENT_DID,
|
|
@@ -142,7 +252,7 @@ async function loadIdentity(customPath) {
|
|
|
142
252
|
registeredAt: new Date().toISOString()
|
|
143
253
|
};
|
|
144
254
|
}
|
|
145
|
-
// Check file
|
|
255
|
+
// Check JSON file (most reliable for programmatic access)
|
|
146
256
|
const filePath = customPath || path.join(process.cwd(), '.mcp-identity.json');
|
|
147
257
|
try {
|
|
148
258
|
if (fs.existsSync(filePath)) {
|
|
@@ -153,10 +263,13 @@ async function loadIdentity(customPath) {
|
|
|
153
263
|
catch {
|
|
154
264
|
// Ignore errors
|
|
155
265
|
}
|
|
266
|
+
// Note: We don't manually load .env or .env.local files here
|
|
267
|
+
// because that should be handled by the application's environment
|
|
268
|
+
// loading strategy (dotenv, framework, etc.)
|
|
156
269
|
return null;
|
|
157
270
|
}
|
|
158
271
|
async function saveIdentity(identity, customPath) {
|
|
159
|
-
// Save to .env.local
|
|
272
|
+
// Save to .env (standard) and .env.local (for frameworks)
|
|
160
273
|
const envContent = `
|
|
161
274
|
# MCP-I Identity (auto-generated)
|
|
162
275
|
AGENT_DID="${identity.did}"
|
|
@@ -165,11 +278,16 @@ AGENT_PRIVATE_KEY="${identity.privateKey}"
|
|
|
165
278
|
AGENT_ID="${identity.agentId}"
|
|
166
279
|
AGENT_SLUG="${identity.agentSlug}"
|
|
167
280
|
`;
|
|
168
|
-
|
|
281
|
+
// Save to .env for standard Node.js compatibility
|
|
282
|
+
const envPath = path.join(process.cwd(), '.env');
|
|
169
283
|
fs.writeFileSync(envPath, envContent.trim());
|
|
170
|
-
// Also save
|
|
284
|
+
// Also save to .env.local for framework compatibility (Next.js, Vite, etc.)
|
|
285
|
+
const envLocalPath = path.join(process.cwd(), '.env.local');
|
|
286
|
+
fs.writeFileSync(envLocalPath, envContent.trim());
|
|
287
|
+
// Also save as JSON for programmatic access
|
|
171
288
|
const filePath = customPath || path.join(process.cwd(), '.mcp-identity.json');
|
|
172
289
|
fs.writeFileSync(filePath, JSON.stringify(identity, null, 2));
|
|
290
|
+
console.log('[MCP-I] Identity saved to .env, .env.local, and .mcp-identity.json');
|
|
173
291
|
}
|
|
174
292
|
async function autoRegister(options) {
|
|
175
293
|
try {
|
|
@@ -181,7 +299,7 @@ async function autoRegister(options) {
|
|
|
181
299
|
version: '1.0.0'
|
|
182
300
|
},
|
|
183
301
|
clientInfo: {
|
|
184
|
-
sdkVersion: '0.
|
|
302
|
+
sdkVersion: '0.2.0', // Updated version
|
|
185
303
|
language: 'typescript',
|
|
186
304
|
platform: 'node' // Always node for MCP servers
|
|
187
305
|
}
|
|
@@ -189,7 +307,7 @@ async function autoRegister(options) {
|
|
|
189
307
|
timeout: 30000,
|
|
190
308
|
headers: {
|
|
191
309
|
'Content-Type': 'application/json',
|
|
192
|
-
'User-Agent': '@kya-os/mcp-i/0.
|
|
310
|
+
'User-Agent': '@kya-os/mcp-i/0.2.0'
|
|
193
311
|
}
|
|
194
312
|
});
|
|
195
313
|
return response.data;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kDAA0B;AAC1B,uCAAyB;AACzB,2CAA6B;AAC7B,iDAAmC;AAWnC,kCAAkC;AAClC,0CAAwB;AAExB,MAAa,WAAW;IAStB,YACE,QAA2B,EAC3B,UAA8B,EAAE;QAL1B,eAAU,GAAgB,IAAI,GAAG,EAAE,CAAC;QAO1C,IAAI,CAAC,GAAG,GAAG,QAAQ,CA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CAAC,WAAW;gBAChC,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,OAAO,EAAE,OAAO;aACjB;YACD,UAAU,EAAE;gBACV,UAAU,EAAE,OAAO,EAAE,kBAAkB;gBACvC,QAAQ,EAAE,YAAY;gBACtB,QAAQ,EAAE,MAAM,CAAC,8BAA8B;aAChD;SACF,EACD;YACE,OAAO,EAAE,KAAK;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,YAAY,EAAE,qBAAqB;aACpC;SACF,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,IAAI,KAAK,CAAC,QAAQ,EAAE,MAAM,KAAK,GAAG,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;QAClE,CAAC;QACD,MAAM,IAAI,KAAK,CACb,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO;YAC7B,KAAK,CAAC,OAAO;YACb,+BAA+B,CAChC,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for MCP-I challenge-response authentication
|
|
3
|
+
*/
|
|
4
|
+
export interface MCPIdentityOptions {
|
|
5
|
+
name?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
repository?: string;
|
|
8
|
+
apiEndpoint?: string;
|
|
9
|
+
persistencePath?: string;
|
|
10
|
+
timestampTolerance?: number;
|
|
11
|
+
enableNonceTracking?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface AutoRegisterResponse {
|
|
14
|
+
success: boolean;
|
|
15
|
+
did: string;
|
|
16
|
+
agent: {
|
|
17
|
+
id: string;
|
|
18
|
+
slug: string;
|
|
19
|
+
name: string;
|
|
20
|
+
url: string;
|
|
21
|
+
};
|
|
22
|
+
keys: {
|
|
23
|
+
publicKey: string;
|
|
24
|
+
privateKey?: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export interface PersistedIdentity {
|
|
28
|
+
did: string;
|
|
29
|
+
publicKey: string;
|
|
30
|
+
privateKey: string;
|
|
31
|
+
agentId: string;
|
|
32
|
+
agentSlug: string;
|
|
33
|
+
registeredAt: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* MCP-I Challenge structure
|
|
37
|
+
*/
|
|
38
|
+
export interface Challenge {
|
|
39
|
+
nonce: string;
|
|
40
|
+
timestamp: number;
|
|
41
|
+
verifier_did?: string;
|
|
42
|
+
scope?: string[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* MCP-I Challenge Response structure
|
|
46
|
+
*/
|
|
47
|
+
export interface ChallengeResponse {
|
|
48
|
+
did: string;
|
|
49
|
+
signature: string;
|
|
50
|
+
timestamp: number;
|
|
51
|
+
nonce: string;
|
|
52
|
+
publicKey?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* MCP-I Capabilities advertisement
|
|
56
|
+
*/
|
|
57
|
+
export interface MCPICapabilities {
|
|
58
|
+
version: string;
|
|
59
|
+
did: string;
|
|
60
|
+
publicKey: string;
|
|
61
|
+
conformanceLevel: number;
|
|
62
|
+
handshakeSupported: boolean;
|
|
63
|
+
handshakeEndpoint?: string;
|
|
64
|
+
verificationEndpoint?: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Response with MCP-I identity attached
|
|
68
|
+
*/
|
|
69
|
+
export interface SignedResponse<T = any> {
|
|
70
|
+
[key: string]: any;
|
|
71
|
+
_mcp_identity: {
|
|
72
|
+
did: string;
|
|
73
|
+
signature: string;
|
|
74
|
+
timestamp: string;
|
|
75
|
+
conformanceLevel?: number;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","source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AC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,GAAG;IACrC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IACnB,aAAa,EAAE;QACb,GAAG,EAAE,MAAM,CAAC;QACZ,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B,CAAC;CACH"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kya-os/mcp-i",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.2.0",
|
|
4
4
|
"description": "Ultra-light MCP Identity auto-registration - 2 lines to agent identity",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "tsc",
|
|
14
|
-
"test": "
|
|
14
|
+
"test": "vitest",
|
|
15
|
+
"test:watch": "vitest watch",
|
|
16
|
+
"test:coverage": "vitest run --coverage",
|
|
15
17
|
"prepublishOnly": "npm run build"
|
|
16
18
|
},
|
|
17
19
|
"keywords": [
|
|
@@ -25,13 +27,14 @@
|
|
|
25
27
|
"author": "Dylan Hobbs <dylan@vouched.id>",
|
|
26
28
|
"license": "MIT",
|
|
27
29
|
"dependencies": {
|
|
30
|
+
"@noble/ed25519": "^2.1.0",
|
|
28
31
|
"axios": "^1.6.7"
|
|
29
32
|
},
|
|
30
33
|
"devDependencies": {
|
|
31
34
|
"@types/node": "^20.0.0",
|
|
35
|
+
"@vitest/coverage-v8": "^2.0.0",
|
|
32
36
|
"typescript": "^5.0.0",
|
|
33
|
-
"
|
|
34
|
-
"@types/jest": "^29.0.0"
|
|
37
|
+
"vitest": "^2.0.0"
|
|
35
38
|
},
|
|
36
39
|
"engines": {
|
|
37
40
|
"node": ">=14.0.0"
|