@kya-os/mcp-i-core 1.0.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 +302 -0
- package/dist/did/resolver.d.ts +92 -0
- package/dist/did/resolver.d.ts.map +1 -0
- package/dist/did/resolver.js +203 -0
- package/dist/did/resolver.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/proof/proof-engine.d.ts +89 -0
- package/dist/proof/proof-engine.d.ts.map +1 -0
- package/dist/proof/proof-engine.js +249 -0
- package/dist/proof/proof-engine.js.map +1 -0
- package/dist/providers/base.d.ts +76 -0
- package/dist/providers/base.d.ts.map +1 -0
- package/dist/providers/base.js +43 -0
- package/dist/providers/base.js.map +1 -0
- package/dist/providers/memory.d.ts +42 -0
- package/dist/providers/memory.d.ts.map +1 -0
- package/dist/providers/memory.js +117 -0
- package/dist/providers/memory.js.map +1 -0
- package/dist/runtime/base-v2.d.ts +117 -0
- package/dist/runtime/base-v2.d.ts.map +1 -0
- package/dist/runtime/base-v2.js +328 -0
- package/dist/runtime/base-v2.js.map +1 -0
- package/dist/runtime/base.d.ts +97 -0
- package/dist/runtime/base.d.ts.map +1 -0
- package/dist/runtime/base.js +316 -0
- package/dist/runtime/base.js.map +1 -0
- package/dist/types/providers.d.ts +142 -0
- package/dist/types/providers.d.ts.map +1 -0
- package/dist/types/providers.js +43 -0
- package/dist/types/providers.js.map +1 -0
- package/dist/verification/interfaces.d.ts +125 -0
- package/dist/verification/interfaces.d.ts.map +1 -0
- package/dist/verification/interfaces.js +101 -0
- package/dist/verification/interfaces.js.map +1 -0
- package/package.json +59 -0
package/README.md
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
# @kya-os/mcp-i-core
|
|
2
|
+
|
|
3
|
+
Platform-agnostic core for MCP-I (Model Context Protocol with Identity) runtime. This package provides the shared business logic, interfaces, and abstractions that work across all JavaScript environments.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`@kya-os/mcp-i-core` is the foundation for building MCP-I runtimes on any platform. It provides:
|
|
8
|
+
|
|
9
|
+
- **Isomorphic verification logic** that works across Node.js, Cloudflare Workers, Vercel Edge, and browsers
|
|
10
|
+
- **Provider-based architecture** for platform-specific implementations
|
|
11
|
+
- **Multiple proof formats** (JWT-VC, Data Integrity, DetachedJWS)
|
|
12
|
+
- **DID resolution** with pluggable resolvers
|
|
13
|
+
- **Progressive verification** for optimal performance
|
|
14
|
+
- **Credential and delegation** support
|
|
15
|
+
|
|
16
|
+
## Architecture
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
20
|
+
│ Application Layer │
|
|
21
|
+
│ (@kya-os/mcp-i or @kya-os/mcp-i-cloudflare) │
|
|
22
|
+
└────────────────────┬────────────────────────────────────────┘
|
|
23
|
+
│
|
|
24
|
+
┌────────────────────▼────────────────────────────────────────┐
|
|
25
|
+
│ @kya-os/mcp-i-core │
|
|
26
|
+
│ │
|
|
27
|
+
│ ┌─────────────┐ ┌──────────────┐ ┌──────────────────┐ │
|
|
28
|
+
│ │ Runtime │ │ ProofEngine │ │ DID Resolver │ │
|
|
29
|
+
│ │ Base │ │ │ │ │ │
|
|
30
|
+
│ └─────────────┘ └──────────────┘ └──────────────────┘ │
|
|
31
|
+
│ │
|
|
32
|
+
│ ┌─────────────┐ ┌──────────────┐ ┌──────────────────┐ │
|
|
33
|
+
│ │ Credential │ │ Delegation │ │ Progressive │ │
|
|
34
|
+
│ │ Verifier │ │ Registry │ │ Verifier │ │
|
|
35
|
+
│ └─────────────┘ └──────────────┘ └──────────────────┘ │
|
|
36
|
+
└────────────────────┬────────────────────────────────────────┘
|
|
37
|
+
│
|
|
38
|
+
┌────────────────────▼────────────────────────────────────────┐
|
|
39
|
+
│ Provider Interfaces │
|
|
40
|
+
│ │
|
|
41
|
+
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────────┐ │
|
|
42
|
+
│ │ Crypto │ │ Identity │ │ Clock │ │ Fetch │ │
|
|
43
|
+
│ │ Provider │ │ Provider │ │ Provider │ │ Provider │ │
|
|
44
|
+
│ └──────────┘ └──────────┘ └──────────┘ └──────────────┘ │
|
|
45
|
+
│ │
|
|
46
|
+
│ ┌──────────┐ ┌──────────┐ ┌──────────────────────────┐ │
|
|
47
|
+
│ │ Storage │ │ Nonce │ │ Platform-Specific │ │
|
|
48
|
+
│ │ Provider │ │ Cache │ │ Implementations │ │
|
|
49
|
+
│ └──────────┘ └──────────┘ └──────────────────────────┘ │
|
|
50
|
+
└──────────────────────────────────────────────────────────────┘
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Installation
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npm install @kya-os/mcp-i-core
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Provider Interfaces
|
|
60
|
+
|
|
61
|
+
### CryptoProvider
|
|
62
|
+
Handles all cryptographic operations (signing, verification, key generation).
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
abstract class CryptoProvider {
|
|
66
|
+
abstract sign(data: Uint8Array, privateKey: string): Promise<Uint8Array>;
|
|
67
|
+
abstract verify(data: Uint8Array, signature: Uint8Array, publicKey: string): Promise<boolean>;
|
|
68
|
+
abstract generateKeyPair(): Promise<{ privateKey: string; publicKey: string }>;
|
|
69
|
+
abstract hash(data: Uint8Array): Promise<Uint8Array>;
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### IdentityProvider
|
|
74
|
+
Manages agent identity storage and retrieval.
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
abstract class IdentityProvider {
|
|
78
|
+
abstract loadIdentity(): Promise<AgentIdentity | null>;
|
|
79
|
+
abstract storeIdentity(identity: AgentIdentity): Promise<void>;
|
|
80
|
+
abstract hasIdentity(): Promise<boolean>;
|
|
81
|
+
abstract deleteIdentity(): Promise<void>;
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### ClockProvider
|
|
86
|
+
Provides deterministic time operations for testing and consistency.
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
abstract class ClockProvider {
|
|
90
|
+
abstract now(): number;
|
|
91
|
+
abstract isWithinSkew(timestamp: number, skewSeconds: number): boolean;
|
|
92
|
+
abstract hasExpired(expiresAt: number): boolean;
|
|
93
|
+
abstract calculateExpiry(ttlSeconds: number): number;
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### FetchProvider
|
|
98
|
+
Handles network operations for DID resolution and verification.
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
abstract class FetchProvider {
|
|
102
|
+
abstract resolveDID(did: string): Promise<any>;
|
|
103
|
+
abstract fetchStatusList(url: string): Promise<any>;
|
|
104
|
+
abstract fetchDelegationChain(id: string): Promise<any[]>;
|
|
105
|
+
abstract fetch(url: string, options?: any): Promise<Response>;
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Core Components
|
|
110
|
+
|
|
111
|
+
### MCPIRuntimeBaseV2
|
|
112
|
+
|
|
113
|
+
The main runtime class that orchestrates all MCP-I operations.
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
import { MCPIRuntimeBaseV2 } from '@kya-os/mcp-i-core';
|
|
117
|
+
|
|
118
|
+
class MyPlatformRuntime extends MCPIRuntimeBaseV2 {
|
|
119
|
+
constructor() {
|
|
120
|
+
super({
|
|
121
|
+
cryptoProvider: new MyeCryptoProvider(),
|
|
122
|
+
identityProvider: new MyIdentityProvider(),
|
|
123
|
+
storageProvider: new MyStorageProvider(),
|
|
124
|
+
nonceCacheProvider: new MyNonceCacheProvider(),
|
|
125
|
+
clockProvider: new MyClockProvider(),
|
|
126
|
+
fetchProvider: new MyFetchProvider()
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Platform-specific implementations
|
|
131
|
+
protected async generateSessionId(): Promise<string> {
|
|
132
|
+
// Use platform's secure random
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
protected async generateNonce(): Promise<string> {
|
|
136
|
+
// Use platform's secure random
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### ProofEngine
|
|
142
|
+
|
|
143
|
+
Supports multiple proof formats with a unified interface.
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
const proofEngine = new DefaultProofEngine(cryptoProvider);
|
|
147
|
+
|
|
148
|
+
// Create proof in different formats
|
|
149
|
+
const jwtProof = await proofEngine.createProof(data, privateKey, {
|
|
150
|
+
format: { type: 'JWT-VC', algorithm: 'EdDSA' }
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const dataIntegrityProof = await proofEngine.createProof(data, privateKey, {
|
|
154
|
+
format: { type: 'DataIntegrity', algorithm: 'Ed25519Signature2020' }
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// Verify any format
|
|
158
|
+
const result = await proofEngine.verifyProof(data, proof, publicKey, {
|
|
159
|
+
format: { type: 'DetachedJWS', algorithm: 'Ed25519' }
|
|
160
|
+
});
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### DID Resolver
|
|
164
|
+
|
|
165
|
+
Pluggable DID resolution with built-in support for did:key and did:web.
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
const resolver = new UniversalDIDResolver(fetchProvider);
|
|
169
|
+
|
|
170
|
+
// Register custom resolver
|
|
171
|
+
resolver.registerResolver(new MyCustomDIDResolver());
|
|
172
|
+
|
|
173
|
+
// Resolve any DID
|
|
174
|
+
const document = await resolver.resolve('did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK');
|
|
175
|
+
const publicKey = await resolver.getPublicKey(did, keyId);
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Progressive Verification
|
|
179
|
+
|
|
180
|
+
Optimized verification with offline and online stages.
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
const verifier = new ProgressiveVerifier(credentialVerifier, delegationRegistry);
|
|
184
|
+
|
|
185
|
+
// Stage-1: Quick offline checks
|
|
186
|
+
// Stage-2: Full online verification (parallel)
|
|
187
|
+
const result = await verifier.verifyProgressive(data, {
|
|
188
|
+
verifyCredential: true,
|
|
189
|
+
checkRevocation: true,
|
|
190
|
+
maxChainDepth: 5
|
|
191
|
+
});
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Platform Implementations
|
|
195
|
+
|
|
196
|
+
### Node.js / Vercel
|
|
197
|
+
```typescript
|
|
198
|
+
// @kya-os/mcp-i
|
|
199
|
+
import { MCPIRuntimeBaseV2 } from '@kya-os/mcp-i-core';
|
|
200
|
+
import { NodeCryptoProvider } from './providers/node-crypto';
|
|
201
|
+
import { FileSystemIdentityProvider } from './providers/fs-identity';
|
|
202
|
+
|
|
203
|
+
export class MCPIRuntime extends MCPIRuntimeBaseV2 {
|
|
204
|
+
constructor() {
|
|
205
|
+
super({
|
|
206
|
+
cryptoProvider: new NodeCryptoProvider(),
|
|
207
|
+
identityProvider: new FileSystemIdentityProvider(),
|
|
208
|
+
// ... other Node.js providers
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Cloudflare Workers
|
|
215
|
+
```typescript
|
|
216
|
+
// @kya-os/mcp-i-cloudflare
|
|
217
|
+
import { MCPIRuntimeBaseV2 } from '@kya-os/mcp-i-core';
|
|
218
|
+
import { WebCryptoProvider } from './providers/web-crypto';
|
|
219
|
+
import { KVIdentityProvider } from './providers/kv-identity';
|
|
220
|
+
|
|
221
|
+
export class MCPICloudflareRuntime extends MCPIRuntimeBaseV2 {
|
|
222
|
+
constructor(env: CloudflareEnv) {
|
|
223
|
+
super({
|
|
224
|
+
cryptoProvider: new WebCryptoProvider(),
|
|
225
|
+
identityProvider: new KVIdentityProvider(env),
|
|
226
|
+
// ... other Cloudflare providers
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Isomorphic Verification
|
|
233
|
+
|
|
234
|
+
The verification logic works identically across all platforms:
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
// Works in Node.js, Cloudflare Workers, Vercel Edge, Browser
|
|
238
|
+
async function verifyMCPIProof(data: any, proof: any): Promise<boolean> {
|
|
239
|
+
const runtime = createRuntimeForPlatform(); // Platform-specific
|
|
240
|
+
return runtime.verifyProof(data, proof); // Isomorphic logic
|
|
241
|
+
}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Security Considerations
|
|
245
|
+
|
|
246
|
+
1. **Private Keys**: Never stored in core, always handled by IdentityProvider
|
|
247
|
+
2. **Nonce Management**: Automatic replay attack prevention
|
|
248
|
+
3. **Time Skew**: Configurable tolerance for clock differences
|
|
249
|
+
4. **Session Lifecycle**: Absolute lifetime limits
|
|
250
|
+
5. **Audit Logging**: Built-in audit trail support
|
|
251
|
+
|
|
252
|
+
## Testing
|
|
253
|
+
|
|
254
|
+
The provider-based architecture makes testing straightforward:
|
|
255
|
+
|
|
256
|
+
```typescript
|
|
257
|
+
import { MockCryptoProvider, MockIdentityProvider } from '@kya-os/mcp-i-core/test';
|
|
258
|
+
|
|
259
|
+
const runtime = new MCPIRuntimeBaseV2({
|
|
260
|
+
cryptoProvider: new MockCryptoProvider(),
|
|
261
|
+
identityProvider: new MockIdentityProvider(),
|
|
262
|
+
// ... mock providers
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
// Test business logic without platform dependencies
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## Migration Guide
|
|
269
|
+
|
|
270
|
+
### From @kya-os/mcp-i v1.x
|
|
271
|
+
|
|
272
|
+
The existing API remains unchanged. Internal implementation now uses core:
|
|
273
|
+
|
|
274
|
+
```typescript
|
|
275
|
+
// Before (still works)
|
|
276
|
+
import { MCPIRuntime } from '@kya-os/mcp-i';
|
|
277
|
+
const runtime = new MCPIRuntime();
|
|
278
|
+
|
|
279
|
+
// After (also works, same API)
|
|
280
|
+
import { MCPIRuntime } from '@kya-os/mcp-i';
|
|
281
|
+
const runtime = new MCPIRuntime();
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### For New Projects
|
|
285
|
+
|
|
286
|
+
Use the platform-specific package:
|
|
287
|
+
|
|
288
|
+
```typescript
|
|
289
|
+
// Node.js / Vercel
|
|
290
|
+
import { createMCPIServer } from '@kya-os/mcp-i';
|
|
291
|
+
|
|
292
|
+
// Cloudflare Workers
|
|
293
|
+
import { createMCPIServer } from '@kya-os/mcp-i-cloudflare';
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
## Contributing
|
|
297
|
+
|
|
298
|
+
See [CONTRIBUTING.md](../../CONTRIBUTING.md) for development setup and guidelines.
|
|
299
|
+
|
|
300
|
+
## License
|
|
301
|
+
|
|
302
|
+
MIT
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DID Resolver plugin system
|
|
3
|
+
* Supports did:key and did:web out of the box, extensible for other methods
|
|
4
|
+
*/
|
|
5
|
+
import { FetchProvider } from "../types/providers";
|
|
6
|
+
/**
|
|
7
|
+
* DID Document structure
|
|
8
|
+
*/
|
|
9
|
+
export interface DIDDocument {
|
|
10
|
+
'@context': string[];
|
|
11
|
+
id: string;
|
|
12
|
+
verificationMethod?: VerificationMethod[];
|
|
13
|
+
authentication?: (string | VerificationMethod)[];
|
|
14
|
+
assertionMethod?: (string | VerificationMethod)[];
|
|
15
|
+
keyAgreement?: (string | VerificationMethod)[];
|
|
16
|
+
capabilityInvocation?: (string | VerificationMethod)[];
|
|
17
|
+
capabilityDelegation?: (string | VerificationMethod)[];
|
|
18
|
+
}
|
|
19
|
+
export interface VerificationMethod {
|
|
20
|
+
id: string;
|
|
21
|
+
type: string;
|
|
22
|
+
controller: string;
|
|
23
|
+
publicKeyBase58?: string;
|
|
24
|
+
publicKeyJwk?: any;
|
|
25
|
+
publicKeyMultibase?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* DID resolver interface
|
|
29
|
+
*/
|
|
30
|
+
export interface DIDResolver {
|
|
31
|
+
/**
|
|
32
|
+
* Check if this resolver can handle the given DID method
|
|
33
|
+
*/
|
|
34
|
+
canResolve(did: string): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Resolve a DID to its document
|
|
37
|
+
*/
|
|
38
|
+
resolve(did: string): Promise<DIDDocument>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* did:key resolver (built-in)
|
|
42
|
+
*/
|
|
43
|
+
export declare class DIDKeyResolver implements DIDResolver {
|
|
44
|
+
canResolve(did: string): boolean;
|
|
45
|
+
resolve(did: string): Promise<DIDDocument>;
|
|
46
|
+
private decodeMultibase;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* did:web resolver (built-in)
|
|
50
|
+
*/
|
|
51
|
+
export declare class DIDWebResolver implements DIDResolver {
|
|
52
|
+
private fetchProvider;
|
|
53
|
+
constructor(fetchProvider: FetchProvider);
|
|
54
|
+
canResolve(did: string): boolean;
|
|
55
|
+
resolve(did: string): Promise<DIDDocument>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Universal DID resolver with plugin support
|
|
59
|
+
*/
|
|
60
|
+
export declare class UniversalDIDResolver {
|
|
61
|
+
private resolvers;
|
|
62
|
+
constructor(fetchProvider?: FetchProvider);
|
|
63
|
+
/**
|
|
64
|
+
* Register a DID resolver
|
|
65
|
+
*/
|
|
66
|
+
registerResolver(resolver: DIDResolver): void;
|
|
67
|
+
/**
|
|
68
|
+
* Resolve a DID using the appropriate resolver
|
|
69
|
+
*/
|
|
70
|
+
resolve(did: string): Promise<DIDDocument>;
|
|
71
|
+
/**
|
|
72
|
+
* Extract public key from DID document
|
|
73
|
+
*/
|
|
74
|
+
getPublicKey(did: string, keyId?: string): Promise<string>;
|
|
75
|
+
private decodePublicKey;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Lean DID resolver for edge environments
|
|
79
|
+
*/
|
|
80
|
+
export declare class EdgeDIDResolver extends UniversalDIDResolver {
|
|
81
|
+
private cache;
|
|
82
|
+
constructor(cache?: Map<string, DIDDocument>);
|
|
83
|
+
/**
|
|
84
|
+
* Resolve with caching
|
|
85
|
+
*/
|
|
86
|
+
resolve(did: string): Promise<DIDDocument>;
|
|
87
|
+
/**
|
|
88
|
+
* Pre-populate cache for known DIDs
|
|
89
|
+
*/
|
|
90
|
+
preloadCache(documents: DIDDocument[]): void;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../src/did/resolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,kBAAkB,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAC1C,cAAc,CAAC,EAAE,CAAC,MAAM,GAAG,kBAAkB,CAAC,EAAE,CAAC;IACjD,eAAe,CAAC,EAAE,CAAC,MAAM,GAAG,kBAAkB,CAAC,EAAE,CAAC;IAClD,YAAY,CAAC,EAAE,CAAC,MAAM,GAAG,kBAAkB,CAAC,EAAE,CAAC;IAC/C,oBAAoB,CAAC,EAAE,CAAC,MAAM,GAAG,kBAAkB,CAAC,EAAE,CAAC;IACvD,oBAAoB,CAAC,EAAE,CAAC,MAAM,GAAG,kBAAkB,CAAC,EAAE,CAAC;CACxD;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE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,OAAO,CAAC,KAAK;gBAAL,KAAK,GAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAa;IAI/D;;OAEG;IACG,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAmBhD;;OAEG;IACH,YAAY,CAAC,SAAS,EAAE,WAAW,EAAE,GAAG,IAAI;CAK7C"}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* DID Resolver plugin system
|
|
4
|
+
* Supports did:key and did:web out of the box, extensible for other methods
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.EdgeDIDResolver = exports.UniversalDIDResolver = exports.DIDWebResolver = exports.DIDKeyResolver = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* did:key resolver (built-in)
|
|
10
|
+
*/
|
|
11
|
+
class DIDKeyResolver {
|
|
12
|
+
canResolve(did) {
|
|
13
|
+
return did.startsWith('did:key:');
|
|
14
|
+
}
|
|
15
|
+
async resolve(did) {
|
|
16
|
+
// Extract the multibase key
|
|
17
|
+
const multibaseKey = did.substring('did:key:'.length);
|
|
18
|
+
// Decode multibase (z-base58)
|
|
19
|
+
const keyBytes = this.decodeMultibase(multibaseKey);
|
|
20
|
+
// Extract codec and key material
|
|
21
|
+
const codec = keyBytes[0] << 8 | keyBytes[1];
|
|
22
|
+
const publicKey = keyBytes.slice(2);
|
|
23
|
+
// Ed25519 codec is 0xed01
|
|
24
|
+
if (codec !== 0xed01) {
|
|
25
|
+
throw new Error(`Unsupported key type: ${codec.toString(16)}`);
|
|
26
|
+
}
|
|
27
|
+
// Create DID document
|
|
28
|
+
return {
|
|
29
|
+
'@context': [
|
|
30
|
+
'https://www.w3.org/ns/did/v1',
|
|
31
|
+
'https://w3id.org/security/suites/ed25519-2020/v1'
|
|
32
|
+
],
|
|
33
|
+
id: did,
|
|
34
|
+
verificationMethod: [{
|
|
35
|
+
id: `${did}#${multibaseKey}`,
|
|
36
|
+
type: 'Ed25519VerificationKey2020',
|
|
37
|
+
controller: did,
|
|
38
|
+
publicKeyMultibase: multibaseKey
|
|
39
|
+
}],
|
|
40
|
+
authentication: [`${did}#${multibaseKey}`],
|
|
41
|
+
assertionMethod: [`${did}#${multibaseKey}`],
|
|
42
|
+
capabilityInvocation: [`${did}#${multibaseKey}`],
|
|
43
|
+
capabilityDelegation: [`${did}#${multibaseKey}`]
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
decodeMultibase(multibase) {
|
|
47
|
+
// Remove 'z' prefix (z-base58)
|
|
48
|
+
if (!multibase.startsWith('z')) {
|
|
49
|
+
throw new Error('Invalid multibase encoding');
|
|
50
|
+
}
|
|
51
|
+
// Base58 decode (simplified - in production use a proper library)
|
|
52
|
+
const base58 = multibase.substring(1);
|
|
53
|
+
// This is a simplified implementation
|
|
54
|
+
// In production, use a proper base58 decoding library
|
|
55
|
+
return Buffer.from(base58, 'base64'); // Placeholder
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.DIDKeyResolver = DIDKeyResolver;
|
|
59
|
+
/**
|
|
60
|
+
* did:web resolver (built-in)
|
|
61
|
+
*/
|
|
62
|
+
class DIDWebResolver {
|
|
63
|
+
fetchProvider;
|
|
64
|
+
constructor(fetchProvider) {
|
|
65
|
+
this.fetchProvider = fetchProvider;
|
|
66
|
+
}
|
|
67
|
+
canResolve(did) {
|
|
68
|
+
return did.startsWith('did:web:');
|
|
69
|
+
}
|
|
70
|
+
async resolve(did) {
|
|
71
|
+
// Extract domain and path from DID
|
|
72
|
+
const parts = did.substring('did:web:'.length).split(':');
|
|
73
|
+
const domain = parts[0];
|
|
74
|
+
const path = parts.slice(1).join('/');
|
|
75
|
+
// Construct URL
|
|
76
|
+
const url = path
|
|
77
|
+
? `https://${domain}/${path}/did.json`
|
|
78
|
+
: `https://${domain}/.well-known/did.json`;
|
|
79
|
+
// Fetch DID document
|
|
80
|
+
const response = await this.fetchProvider.fetch(url);
|
|
81
|
+
if (!response.ok) {
|
|
82
|
+
throw new Error(`Failed to resolve ${did}: ${response.statusText}`);
|
|
83
|
+
}
|
|
84
|
+
const document = await response.json();
|
|
85
|
+
// Validate document
|
|
86
|
+
if (!document['@context'] || document.id !== did) {
|
|
87
|
+
throw new Error('Invalid DID document');
|
|
88
|
+
}
|
|
89
|
+
return document;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.DIDWebResolver = DIDWebResolver;
|
|
93
|
+
/**
|
|
94
|
+
* Universal DID resolver with plugin support
|
|
95
|
+
*/
|
|
96
|
+
class UniversalDIDResolver {
|
|
97
|
+
resolvers = [];
|
|
98
|
+
constructor(fetchProvider) {
|
|
99
|
+
// Register built-in resolvers
|
|
100
|
+
this.registerResolver(new DIDKeyResolver());
|
|
101
|
+
if (fetchProvider) {
|
|
102
|
+
this.registerResolver(new DIDWebResolver(fetchProvider));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Register a DID resolver
|
|
107
|
+
*/
|
|
108
|
+
registerResolver(resolver) {
|
|
109
|
+
this.resolvers.push(resolver);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Resolve a DID using the appropriate resolver
|
|
113
|
+
*/
|
|
114
|
+
async resolve(did) {
|
|
115
|
+
// Find appropriate resolver
|
|
116
|
+
const resolver = this.resolvers.find(r => r.canResolve(did));
|
|
117
|
+
if (!resolver) {
|
|
118
|
+
throw new Error(`No resolver available for DID method: ${did.split(':')[1]}`);
|
|
119
|
+
}
|
|
120
|
+
return resolver.resolve(did);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Extract public key from DID document
|
|
124
|
+
*/
|
|
125
|
+
async getPublicKey(did, keyId) {
|
|
126
|
+
const document = await this.resolve(did);
|
|
127
|
+
// Find verification method
|
|
128
|
+
let method;
|
|
129
|
+
if (keyId) {
|
|
130
|
+
method = document.verificationMethod?.find(m => m.id === keyId);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
// Use first verification method
|
|
134
|
+
method = document.verificationMethod?.[0];
|
|
135
|
+
}
|
|
136
|
+
if (!method) {
|
|
137
|
+
throw new Error(`No verification method found for ${did}`);
|
|
138
|
+
}
|
|
139
|
+
// Extract public key
|
|
140
|
+
if (method.publicKeyMultibase) {
|
|
141
|
+
// Decode multibase key
|
|
142
|
+
return this.decodePublicKey(method.publicKeyMultibase);
|
|
143
|
+
}
|
|
144
|
+
else if (method.publicKeyBase58) {
|
|
145
|
+
// Decode base58 key
|
|
146
|
+
return Buffer.from(method.publicKeyBase58, 'base64').toString('base64');
|
|
147
|
+
}
|
|
148
|
+
else if (method.publicKeyJwk) {
|
|
149
|
+
// Extract from JWK
|
|
150
|
+
return Buffer.from(method.publicKeyJwk.x, 'base64url').toString('base64');
|
|
151
|
+
}
|
|
152
|
+
throw new Error('No supported public key format found');
|
|
153
|
+
}
|
|
154
|
+
decodePublicKey(multibase) {
|
|
155
|
+
// Simplified - extract Ed25519 public key from multibase
|
|
156
|
+
// In production, use proper multibase/multicodec decoding
|
|
157
|
+
if (multibase.startsWith('z')) {
|
|
158
|
+
// z-base58 encoded
|
|
159
|
+
// This is a placeholder - use proper decoding
|
|
160
|
+
return Buffer.from(multibase.substring(1), 'base64').toString('base64');
|
|
161
|
+
}
|
|
162
|
+
throw new Error('Unsupported multibase encoding');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
exports.UniversalDIDResolver = UniversalDIDResolver;
|
|
166
|
+
/**
|
|
167
|
+
* Lean DID resolver for edge environments
|
|
168
|
+
*/
|
|
169
|
+
class EdgeDIDResolver extends UniversalDIDResolver {
|
|
170
|
+
cache;
|
|
171
|
+
constructor(cache = new Map()) {
|
|
172
|
+
super(); // Only register did:key (no network needed)
|
|
173
|
+
this.cache = cache;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Resolve with caching
|
|
177
|
+
*/
|
|
178
|
+
async resolve(did) {
|
|
179
|
+
// Check cache first
|
|
180
|
+
if (this.cache.has(did)) {
|
|
181
|
+
return this.cache.get(did);
|
|
182
|
+
}
|
|
183
|
+
// Resolve and cache
|
|
184
|
+
const document = await super.resolve(did);
|
|
185
|
+
this.cache.set(did, document);
|
|
186
|
+
// Limit cache size
|
|
187
|
+
if (this.cache.size > 100) {
|
|
188
|
+
const firstKey = this.cache.keys().next().value;
|
|
189
|
+
this.cache.delete(firstKey);
|
|
190
|
+
}
|
|
191
|
+
return document;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Pre-populate cache for known DIDs
|
|
195
|
+
*/
|
|
196
|
+
preloadCache(documents) {
|
|
197
|
+
for (const doc of documents) {
|
|
198
|
+
this.cache.set(doc.id, doc);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
exports.EdgeDIDResolver = EdgeDIDResolver;
|
|
203
|
+
//# sourceMappingURL=resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../src/did/resolver.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA0CH;;GAEG;AACH,MAAa,cAAc;IACzB,UAAU,CAAC,GAAW;QACpB,OAAO,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAW;QACvB,4BAA4B;QAC5B,MAAM,YAAY,GAAG,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAEtD,8BAA8B;QAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;QAEpD,iCAAiC;QACjC,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC7C,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAA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CAAC;YACxB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC;QAC9B,CAAC;QAED,oBAAoB;QACpB,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC1C,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAE9B,mBAAmB;QACnB,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,EAAE,CAAC;YAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;YAChD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC9B,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,SAAwB;QACnC,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;YAC5B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;CACF;AAnCD,0CAmCC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @kya-os/mcp-i-core
|
|
3
|
+
*
|
|
4
|
+
* Core provider-based architecture for MCP-I framework.
|
|
5
|
+
* Platform-agnostic runtime that can be extended for any environment.
|
|
6
|
+
*/
|
|
7
|
+
export { CryptoProvider, ClockProvider, FetchProvider, StorageProvider, NonceCacheProvider, IdentityProvider, type AgentIdentity } from './providers/base';
|
|
8
|
+
export { MemoryStorageProvider, MemoryNonceCacheProvider, MemoryIdentityProvider } from './providers/memory';
|
|
9
|
+
export { MCPIRuntimeBase, type MCPIRuntimeConfig } from './runtime/base';
|
|
10
|
+
import type { HandshakeRequest, SessionContext, NonceCache, NonceCacheEntry, NonceCacheConfig, ProofMeta, DetachedProof, CanonicalHashes, AuditRecord } from '@kya-os/contracts';
|
|
11
|
+
export type { HandshakeRequest, SessionContext, NonceCache, NonceCacheEntry, NonceCacheConfig, ProofMeta, DetachedProof, CanonicalHashes, AuditRecord };
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,cAAc,EACd,aAAa,EACb,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,aAAa,EACnB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,eAAe,EACf,KAAK,iBAAiB,EACvB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,eAAe,EACf,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,eAAe,EACf,WAAW,EACZ,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @kya-os/mcp-i-core
|
|
4
|
+
*
|
|
5
|
+
* Core provider-based architecture for MCP-I framework.
|
|
6
|
+
* Platform-agnostic runtime that can be extended for any environment.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.MCPIRuntimeBase = exports.MemoryIdentityProvider = exports.MemoryNonceCacheProvider = exports.MemoryStorageProvider = exports.IdentityProvider = exports.NonceCacheProvider = exports.StorageProvider = exports.FetchProvider = exports.ClockProvider = exports.CryptoProvider = void 0;
|
|
10
|
+
// Base providers
|
|
11
|
+
var base_1 = require("./providers/base");
|
|
12
|
+
Object.defineProperty(exports, "CryptoProvider", { enumerable: true, get: function () { return base_1.CryptoProvider; } });
|
|
13
|
+
Object.defineProperty(exports, "ClockProvider", { enumerable: true, get: function () { return base_1.ClockProvider; } });
|
|
14
|
+
Object.defineProperty(exports, "FetchProvider", { enumerable: true, get: function () { return base_1.FetchProvider; } });
|
|
15
|
+
Object.defineProperty(exports, "StorageProvider", { enumerable: true, get: function () { return base_1.StorageProvider; } });
|
|
16
|
+
Object.defineProperty(exports, "NonceCacheProvider", { enumerable: true, get: function () { return base_1.NonceCacheProvider; } });
|
|
17
|
+
Object.defineProperty(exports, "IdentityProvider", { enumerable: true, get: function () { return base_1.IdentityProvider; } });
|
|
18
|
+
// Memory providers
|
|
19
|
+
var memory_1 = require("./providers/memory");
|
|
20
|
+
Object.defineProperty(exports, "MemoryStorageProvider", { enumerable: true, get: function () { return memory_1.MemoryStorageProvider; } });
|
|
21
|
+
Object.defineProperty(exports, "MemoryNonceCacheProvider", { enumerable: true, get: function () { return memory_1.MemoryNonceCacheProvider; } });
|
|
22
|
+
Object.defineProperty(exports, "MemoryIdentityProvider", { enumerable: true, get: function () { return memory_1.MemoryIdentityProvider; } });
|
|
23
|
+
// Runtime
|
|
24
|
+
var base_2 = require("./runtime/base");
|
|
25
|
+
Object.defineProperty(exports, "MCPIRuntimeBase", { enumerable: true, get: function () { return base_2.MCPIRuntimeBase; } });
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,iBAAiB;AACjB,yCAQ0B;AAPxB,sGAAA,cAAc,OAAA;AACd,qGAAA,aAAa,OAAA;AACb,qGAAA,aAAa,OAAA;AACb,uGAAA,eAAe,OAAA;AACf,0GAAA,kBAAkB,OAAA;AAClB,wGAAA,gBAAgB,OAAA;AAIlB,mBAAmB;AACnB,6CAI4B;AAH1B,+GAAA,qBAAqB,OAAA;AACrB,kHAAA,wBAAwB,OAAA;AACxB,gHAAA,sBAAsB,OAAA;AAGxB,UAAU;AACV,uCAGwB;AAFtB,uGAAA,eAAe,OAAA"}
|