@kya-os/mcp-i 0.1.0-alpha.1.0 → 0.1.0-alpha.2.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.
- package/README.md +66 -90
- 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 +218 -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/auto-enhance.d.ts +41 -0
- package/dist/auto-enhance.d.ts.map +1 -0
- package/dist/auto-enhance.js +193 -0
- package/dist/auto-enhance.js.map +1 -0
- package/dist/auto-init.d.ts +12 -0
- package/dist/auto-init.d.ts.map +1 -0
- package/dist/auto-init.js +166 -0
- package/dist/auto-init.js.map +1 -0
- package/dist/auto.d.ts +13 -0
- package/dist/auto.d.ts.map +1 -0
- package/dist/auto.js +24 -0
- package/dist/auto.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 +43 -28
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +208 -28
- package/dist/index.js.map +1 -1
- package/dist/patch.d.ts +22 -0
- package/dist/patch.d.ts.map +1 -0
- package/dist/patch.js +164 -0
- package/dist/patch.js.map +1 -0
- package/dist/transparent.d.ts +40 -0
- package/dist/transparent.d.ts.map +1 -0
- package/dist/transparent.js +167 -0
- package/dist/transparent.js.map +1 -0
- package/dist/types.d.ts +79 -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 +19 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patch.js","sourceRoot":"","s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OAAO,CAAC,IAAI,CAAC,EAAE;gBAC/E,IAAI,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,aAAa,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;oBAC3F,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,oBAAoB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC;gBACxE,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,8BAA8B;AAC9B,mBAAW,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;IAC1B,QAAQ,GAAG,CAAC,CAAC;IACb,OAAO,CAAC,GAAG,CAAC,kDAAkD,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;AACzE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;IACb,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;AACvE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transparent MCP-I integration
|
|
3
|
+
*
|
|
4
|
+
* This module provides completely transparent integration without changing types
|
|
5
|
+
* or requiring any code modifications to existing MCP servers.
|
|
6
|
+
*/
|
|
7
|
+
import { MCPIdentity } from './index';
|
|
8
|
+
/**
|
|
9
|
+
* Create a transparent proxy that adds _mcp_identity to responses
|
|
10
|
+
* without changing the type signature
|
|
11
|
+
*/
|
|
12
|
+
export declare function createTransparentProxy<T extends object>(target: T): T;
|
|
13
|
+
/**
|
|
14
|
+
* Enhance an MCP server transparently
|
|
15
|
+
* Returns the same server instance with no type changes
|
|
16
|
+
*/
|
|
17
|
+
export declare function enhanceServer<T extends object>(server: T): Promise<T>;
|
|
18
|
+
/**
|
|
19
|
+
* Wrap a server constructor to automatically enhance instances
|
|
20
|
+
*/
|
|
21
|
+
export declare function wrapServerConstructor<T extends new (...args: any[]) => any>(ServerClass: T): T;
|
|
22
|
+
/**
|
|
23
|
+
* Alternative approach: Middleware pattern
|
|
24
|
+
* This allows users to wrap individual handlers
|
|
25
|
+
*/
|
|
26
|
+
export declare function withIdentity<T extends (...args: any[]) => any>(handler: T): T;
|
|
27
|
+
/**
|
|
28
|
+
* Ultra-simple one-liner integration
|
|
29
|
+
* Usage: const server = await addIdentity(new Server(...));
|
|
30
|
+
*/
|
|
31
|
+
export declare function addIdentity<T extends object>(server: T): Promise<T>;
|
|
32
|
+
/**
|
|
33
|
+
* Export the identity instance for direct access if needed
|
|
34
|
+
*/
|
|
35
|
+
export declare function getIdentity(): MCPIdentity | null;
|
|
36
|
+
/**
|
|
37
|
+
* Manual initialization (optional)
|
|
38
|
+
*/
|
|
39
|
+
export declare function init(options?: any): Promise<MCPIdentity>;
|
|
40
|
+
//# sourceMappingURL=transparent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transparent.d.ts","sourceRoot":"","sources":["../src/transparent.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAKtC;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CA+DrE;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAQ3E;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACzE,WAAW,EAAE,CAAC,GACb,CAAC,CAcH;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,OAAO,EAAE,CAAC,GAAG,CAAC,CAqC7E;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAEzE;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,WAAW,GAAG,IAAI,CAEhD;AAED;;GAEG;AACH,wBAAsB,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,WAAW,CAAC,CAK9D"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Transparent MCP-I integration
|
|
4
|
+
*
|
|
5
|
+
* This module provides completely transparent integration without changing types
|
|
6
|
+
* or requiring any code modifications to existing MCP servers.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.createTransparentProxy = createTransparentProxy;
|
|
10
|
+
exports.enhanceServer = enhanceServer;
|
|
11
|
+
exports.wrapServerConstructor = wrapServerConstructor;
|
|
12
|
+
exports.withIdentity = withIdentity;
|
|
13
|
+
exports.addIdentity = addIdentity;
|
|
14
|
+
exports.getIdentity = getIdentity;
|
|
15
|
+
exports.init = init;
|
|
16
|
+
const index_1 = require("./index");
|
|
17
|
+
// Global identity instance
|
|
18
|
+
let identity = null;
|
|
19
|
+
/**
|
|
20
|
+
* Create a transparent proxy that adds _mcp_identity to responses
|
|
21
|
+
* without changing the type signature
|
|
22
|
+
*/
|
|
23
|
+
function createTransparentProxy(target) {
|
|
24
|
+
return new Proxy(target, {
|
|
25
|
+
get(obj, prop) {
|
|
26
|
+
const value = obj[prop];
|
|
27
|
+
// Only proxy functions
|
|
28
|
+
if (typeof value !== 'function') {
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
// Return a wrapped function
|
|
32
|
+
return async function (...args) {
|
|
33
|
+
// Call the original function
|
|
34
|
+
const result = await value.apply(this, args);
|
|
35
|
+
// If result is an object (response), enhance it
|
|
36
|
+
if (result && typeof result === 'object' && !Array.isArray(result)) {
|
|
37
|
+
// Initialize identity if needed
|
|
38
|
+
if (!identity) {
|
|
39
|
+
identity = await index_1.MCPIdentity.init();
|
|
40
|
+
}
|
|
41
|
+
// Create signature
|
|
42
|
+
const timestamp = new Date().toISOString();
|
|
43
|
+
const contentToSign = JSON.stringify({
|
|
44
|
+
...result,
|
|
45
|
+
_mcp_identity: {
|
|
46
|
+
did: identity.did,
|
|
47
|
+
timestamp,
|
|
48
|
+
conformanceLevel: 2
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
const signature = await identity.sign(contentToSign);
|
|
52
|
+
// Add identity using a symbol to avoid type conflicts
|
|
53
|
+
const identitySymbol = Symbol.for('_mcp_identity');
|
|
54
|
+
result[identitySymbol] = {
|
|
55
|
+
did: identity.did,
|
|
56
|
+
signature,
|
|
57
|
+
timestamp,
|
|
58
|
+
conformanceLevel: 2
|
|
59
|
+
};
|
|
60
|
+
// Override JSON serialization to include _mcp_identity
|
|
61
|
+
if (!result.toJSON) {
|
|
62
|
+
Object.defineProperty(result, 'toJSON', {
|
|
63
|
+
value: function () {
|
|
64
|
+
return {
|
|
65
|
+
...this,
|
|
66
|
+
_mcp_identity: this[identitySymbol]
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
enumerable: false,
|
|
70
|
+
configurable: true
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Enhance an MCP server transparently
|
|
81
|
+
* Returns the same server instance with no type changes
|
|
82
|
+
*/
|
|
83
|
+
async function enhanceServer(server) {
|
|
84
|
+
// Initialize identity
|
|
85
|
+
if (!identity) {
|
|
86
|
+
identity = await index_1.MCPIdentity.init();
|
|
87
|
+
}
|
|
88
|
+
// Create a transparent proxy
|
|
89
|
+
return createTransparentProxy(server);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Wrap a server constructor to automatically enhance instances
|
|
93
|
+
*/
|
|
94
|
+
function wrapServerConstructor(ServerClass) {
|
|
95
|
+
return class extends ServerClass {
|
|
96
|
+
constructor(...args) {
|
|
97
|
+
super(...args);
|
|
98
|
+
// Schedule enhancement after construction
|
|
99
|
+
setImmediate(async () => {
|
|
100
|
+
// Replace this instance's methods with proxied versions
|
|
101
|
+
const proxy = await enhanceServer(this);
|
|
102
|
+
Object.setPrototypeOf(this, Object.getPrototypeOf(proxy));
|
|
103
|
+
Object.assign(this, proxy);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Alternative approach: Middleware pattern
|
|
110
|
+
* This allows users to wrap individual handlers
|
|
111
|
+
*/
|
|
112
|
+
function withIdentity(handler) {
|
|
113
|
+
return (async function (...args) {
|
|
114
|
+
// Initialize identity if needed
|
|
115
|
+
if (!identity) {
|
|
116
|
+
identity = await index_1.MCPIdentity.init();
|
|
117
|
+
}
|
|
118
|
+
// Call the original handler
|
|
119
|
+
const result = await handler(...args);
|
|
120
|
+
// If result is an object, add identity
|
|
121
|
+
if (result && typeof result === 'object' && !Array.isArray(result)) {
|
|
122
|
+
const timestamp = new Date().toISOString();
|
|
123
|
+
const contentToSign = JSON.stringify({
|
|
124
|
+
...result,
|
|
125
|
+
_mcp_identity: {
|
|
126
|
+
did: identity.did,
|
|
127
|
+
timestamp,
|
|
128
|
+
conformanceLevel: 2
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
const signature = await identity.sign(contentToSign);
|
|
132
|
+
// Use Object.assign to maintain the original type
|
|
133
|
+
return Object.assign(result, {
|
|
134
|
+
_mcp_identity: {
|
|
135
|
+
did: identity.did,
|
|
136
|
+
signature,
|
|
137
|
+
timestamp,
|
|
138
|
+
conformanceLevel: 2
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
return result;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Ultra-simple one-liner integration
|
|
147
|
+
* Usage: const server = await addIdentity(new Server(...));
|
|
148
|
+
*/
|
|
149
|
+
async function addIdentity(server) {
|
|
150
|
+
return enhanceServer(server);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Export the identity instance for direct access if needed
|
|
154
|
+
*/
|
|
155
|
+
function getIdentity() {
|
|
156
|
+
return identity;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Manual initialization (optional)
|
|
160
|
+
*/
|
|
161
|
+
async function init(options) {
|
|
162
|
+
if (!identity) {
|
|
163
|
+
identity = await index_1.MCPIdentity.init(options);
|
|
164
|
+
}
|
|
165
|
+
return identity;
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=transparent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transparent.js","sourceRoot":"","sources":["../src/transparent.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAWH,wDA+DC;AAMD,sCAQC;AAKD,sDAgBC;AAMD,oCAqCC;AAMD,kCAEC;AAKD,kCAEC;AAKD,oBAKC;AA/KD,mCAAsC;AAEtC,2BAA2B;AAC3B,IAAI,QAAQ,GAAuB,IAAI,CAAC;AAExC;;;GAGG;AACH,SAAgB,sBAAsB,CAAmB,MAAS;IAChE,OAAO,IAAI,KAAK,CAAC,MAAM,EAAE;QACvB,GAAG,CAAC,GAAQ,EAAE,IAAqB;YACjC,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;YAExB,uBAAuB;YACvB,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;gBAChC,OAAO,KAAK,CAAC;YACf,CAAC;YAED,4BAA4B;YAC5B,OAAO,KAAK,WAAqB,GAAG,IAAW;gBAC7C,6BAA6B;gBAC7B,MAAM,MAAM,GAAG,MA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,EAAE,CAAC,WAAW,EAAE,CAAC;YAC3C,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC;gBACnC,GAAG,MAAM;gBACT,aAAa,EAAE;oBACb,GAAG,EAAE,QAAQ,CAAC,GAAG;oBACjB,SAAS;oBACT,gBAAgB,EAAE,CAAC;iBACpB;aACF,CAAC,CAAC;YAEH,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAErD,kDAAkD;YAClD,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;gBAC3B,aAAa,EAAE;oBACb,GAAG,EAAE,QAAQ,CAAC,GAAG;oBACjB,SAAS;oBACT,SAAS;oBACT,gBAAgB,EAAE,CAAC;iBACpB;aACF,CAAC,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAM,CAAC;AACV,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,WAAW,CAAmB,MAAS;IAC3D,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC;AAED;;GAEG;AACH,SAAgB,WAAW;IACzB,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,IAAI,CAAC,OAAa;IACtC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,QAAQ,GAAG,MAAM,mBAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
forceNew?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface AutoRegisterResponse {
|
|
15
|
+
success: boolean;
|
|
16
|
+
did: string;
|
|
17
|
+
agent: {
|
|
18
|
+
id: string;
|
|
19
|
+
slug: string;
|
|
20
|
+
name: string;
|
|
21
|
+
url: string;
|
|
22
|
+
};
|
|
23
|
+
keys: {
|
|
24
|
+
publicKey: string;
|
|
25
|
+
privateKey?: string;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export interface PersistedIdentity {
|
|
29
|
+
did: string;
|
|
30
|
+
publicKey: string;
|
|
31
|
+
privateKey: string;
|
|
32
|
+
agentId: string;
|
|
33
|
+
agentSlug: string;
|
|
34
|
+
registeredAt: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* MCP-I Challenge structure
|
|
38
|
+
*/
|
|
39
|
+
export interface Challenge {
|
|
40
|
+
nonce: string;
|
|
41
|
+
timestamp: number;
|
|
42
|
+
verifier_did?: string;
|
|
43
|
+
scope?: string[];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* MCP-I Challenge Response structure
|
|
47
|
+
*/
|
|
48
|
+
export interface ChallengeResponse {
|
|
49
|
+
did: string;
|
|
50
|
+
signature: string;
|
|
51
|
+
timestamp: number;
|
|
52
|
+
nonce: string;
|
|
53
|
+
publicKey?: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* MCP-I Capabilities advertisement
|
|
57
|
+
*/
|
|
58
|
+
export interface MCPICapabilities {
|
|
59
|
+
version: string;
|
|
60
|
+
did: string;
|
|
61
|
+
publicKey: string;
|
|
62
|
+
conformanceLevel: number;
|
|
63
|
+
handshakeSupported: boolean;
|
|
64
|
+
handshakeEndpoint?: string;
|
|
65
|
+
verificationEndpoint?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Response with MCP-I identity attached
|
|
69
|
+
*/
|
|
70
|
+
export interface SignedResponse<T = any> {
|
|
71
|
+
[key: string]: any;
|
|
72
|
+
_mcp_identity: {
|
|
73
|
+
did: string;
|
|
74
|
+
signature: string;
|
|
75
|
+
timestamp: string;
|
|
76
|
+
conformanceLevel?: number;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE;QACL,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,IAAI,EAAE;QACJ,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,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,9 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kya-os/mcp-i",
|
|
3
|
-
"version": "0.1.0-alpha.1
|
|
3
|
+
"version": "0.1.0-alpha.2.1",
|
|
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",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./auto": {
|
|
14
|
+
"types": "./dist/auto.d.ts",
|
|
15
|
+
"import": "./dist/auto.js",
|
|
16
|
+
"require": "./dist/auto.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
7
19
|
"files": [
|
|
8
20
|
"dist",
|
|
9
21
|
"README.md",
|
|
@@ -11,7 +23,9 @@
|
|
|
11
23
|
],
|
|
12
24
|
"scripts": {
|
|
13
25
|
"build": "tsc",
|
|
14
|
-
"test": "
|
|
26
|
+
"test": "vitest",
|
|
27
|
+
"test:watch": "vitest watch",
|
|
28
|
+
"test:coverage": "vitest run --coverage",
|
|
15
29
|
"prepublishOnly": "npm run build"
|
|
16
30
|
},
|
|
17
31
|
"keywords": [
|
|
@@ -25,13 +39,14 @@
|
|
|
25
39
|
"author": "Dylan Hobbs <dylan@vouched.id>",
|
|
26
40
|
"license": "MIT",
|
|
27
41
|
"dependencies": {
|
|
42
|
+
"@noble/ed25519": "^2.1.0",
|
|
28
43
|
"axios": "^1.6.7"
|
|
29
44
|
},
|
|
30
45
|
"devDependencies": {
|
|
31
46
|
"@types/node": "^20.0.0",
|
|
47
|
+
"@vitest/coverage-v8": "^2.0.0",
|
|
32
48
|
"typescript": "^5.0.0",
|
|
33
|
-
"
|
|
34
|
-
"@types/jest": "^29.0.0"
|
|
49
|
+
"vitest": "^2.0.0"
|
|
35
50
|
},
|
|
36
51
|
"engines": {
|
|
37
52
|
"node": ">=14.0.0"
|