@kya-os/mcp-i-core 1.7.0 → 1.8.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.
@@ -1,168 +1,7 @@
1
1
  /**
2
- * DID Validation and Helper Utilities
3
- *
4
- * Centralized utilities for DID validation, normalization, and handling.
5
- * Promotes DRY principle and consistency across the codebase.
6
- *
7
- * @package @kya-os/mcp-i-core/utils
2
+ * Compatibility re-export. The implementation moved to @kya-os/mcp-i-runtime
3
+ * (C4 Step 2). Kept here so the pinned `src/delegation/**` (E3.5 #2904) keeps
4
+ * resolving its `../utils/did-helpers` import without being modified.
8
5
  */
9
- /**
10
- * Check if a string is a valid DID format
11
- *
12
- * @param did - String to validate
13
- * @returns true if string starts with "did:"
14
- *
15
- * @example
16
- * ```typescript
17
- * isValidDid("did:key:z6Mk...") // true
18
- * isValidDid("not-a-did") // false
19
- * ```
20
- */
21
- export declare function isValidDid(did: string): boolean;
22
- /**
23
- * Get the DID method from a DID string
24
- *
25
- * @param did - DID string
26
- * @returns DID method (e.g., "key", "web") or null if invalid
27
- *
28
- * @example
29
- * ```typescript
30
- * getDidMethod("did:key:z6Mk...") // "key"
31
- * getDidMethod("did:web:example.com") // "web"
32
- * getDidMethod("invalid") // null
33
- * ```
34
- */
35
- export declare function getDidMethod(did: string): string | null;
36
- /**
37
- * Normalize a DID string (trim whitespace)
38
- *
39
- * @param did - DID string to normalize
40
- * @returns Normalized DID string
41
- *
42
- * @example
43
- * ```typescript
44
- * normalizeDid(" did:key:z6Mk... ") // "did:key:z6Mk..."
45
- * ```
46
- */
47
- export declare function normalizeDid(did: string): string;
48
- /**
49
- * Compare two DIDs for equality (case-sensitive)
50
- *
51
- * @param did1 - First DID
52
- * @param did2 - Second DID
53
- * @returns true if DIDs are equal (after normalization)
54
- *
55
- * @example
56
- * ```typescript
57
- * compareDids("did:key:z6Mk...", "did:key:z6Mk...") // true
58
- * compareDids("did:key:z6Mk...", "did:web:example.com") // false
59
- * ```
60
- */
61
- export declare function compareDids(did1: string, did2: string): boolean;
62
- /**
63
- * Extract server DID from config (supports both old and new field names)
64
- *
65
- * Supports backward compatibility by reading both `serverDid` and deprecated `agentDid`.
66
- * Prefers `serverDid` if both are present.
67
- *
68
- * @param config - Config object with identity field
69
- * @returns Server DID string
70
- * @throws Error if neither serverDid nor agentDid is configured
71
- *
72
- * @example
73
- * ```typescript
74
- * // New config
75
- * getServerDid({ identity: { serverDid: "did:web:server.com" } }) // "did:web:server.com"
76
- *
77
- * // Old config (backward compatibility)
78
- * getServerDid({ identity: { agentDid: "did:web:server.com" } }) // "did:web:server.com"
79
- *
80
- * // Prefers serverDid over agentDid
81
- * getServerDid({ identity: { serverDid: "new", agentDid: "old" } }) // "new"
82
- * ```
83
- */
84
- export declare function getServerDid(config: {
85
- identity: {
86
- serverDid?: string;
87
- agentDid?: string;
88
- };
89
- }): string;
90
- /**
91
- * Extract agent ID from DID
92
- *
93
- * The agent ID is the last component of the DID.
94
- *
95
- * @param did - DID string
96
- * @returns Agent ID (last component of DID)
97
- *
98
- * @example
99
- * ```typescript
100
- * extractAgentId("did:web:knowthat.ai:agents:my-agent") // "my-agent"
101
- * extractAgentId("did:web:localhost:3000:agents:12912feb") // "12912feb"
102
- * extractAgentId("did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK") // "z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK"
103
- * ```
104
- */
105
- export declare function extractAgentId(did: string): string;
106
- /**
107
- * Extract agent slug from DID
108
- *
109
- * Agent slug is the same as agent ID - the last component of the DID.
110
- * For DID format: did:web:knowthat.ai:agents:my-agent
111
- * Returns: my-agent
112
- *
113
- * @param did - DID string
114
- * @returns Agent slug (last component of DID)
115
- *
116
- * @example
117
- * ```typescript
118
- * extractAgentSlug("did:web:knowthat.ai:agents:my-agent") // "my-agent"
119
- * extractAgentSlug("did:web:localhost:3000:agents:12912feb") // "12912feb"
120
- * ```
121
- */
122
- export declare function extractAgentSlug(did: string): string;
123
- /**
124
- * Generate a did:key from Ed25519 public key bytes
125
- *
126
- * Following spec: https://w3c-ccg.github.io/did-method-key/
127
- * Format: did:key:z<multibase-base58btc(<multicodec-ed25519-pub><publicKey>)>
128
- *
129
- * @param publicKeyBytes - Ed25519 public key as Uint8Array (32 bytes)
130
- * @returns did:key string
131
- *
132
- * @example
133
- * ```typescript
134
- * const publicKey = new Uint8Array(32); // 32-byte Ed25519 public key
135
- * const did = generateDidKeyFromBytes(publicKey);
136
- * // did = "did:key:z6Mk..."
137
- * ```
138
- */
139
- export declare function generateDidKeyFromBytes(publicKeyBytes: Uint8Array): string;
140
- /**
141
- * Generate a did:key from base64-encoded Ed25519 public key
142
- *
143
- * Convenience wrapper around generateDidKeyFromBytes for base64-encoded keys.
144
- *
145
- * @param publicKeyBase64 - Ed25519 public key as base64 string
146
- * @returns did:key string
147
- *
148
- * @example
149
- * ```typescript
150
- * const publicKeyBase64 = "...base64 encoded key...";
151
- * const did = generateDidKeyFromBase64(publicKeyBase64);
152
- * // did = "did:key:z6Mk..."
153
- * ```
154
- */
155
- export declare function generateDidKeyFromBase64(publicKeyBase64: string): string;
156
- /**
157
- * Get the spec-compliant fragment identifier for a did:key DID.
158
- *
159
- * Per the W3C CCG did:key spec, the fragment equals the multibase-encoded
160
- * public key value (the DID-specific-id). For example:
161
- * did:key:z6MkABC... → z6MkABC...
162
- *
163
- * @see https://w3c-ccg.github.io/did-key-spec/#document-creation-algorithm
164
- * @param did - A DID string
165
- * @returns The fragment identifier (multibase value for did:key, or 'keys-1' fallback)
166
- */
167
- export declare function didKeyFragment(did: string): string;
6
+ export * from "@kya-os/mcp-i-runtime/utils/did-helpers";
168
7
  //# sourceMappingURL=did-helpers.d.ts.map
@@ -1,222 +1,23 @@
1
1
  "use strict";
2
- /**
3
- * DID Validation and Helper Utilities
4
- *
5
- * Centralized utilities for DID validation, normalization, and handling.
6
- * Promotes DRY principle and consistency across the codebase.
7
- *
8
- * @package @kya-os/mcp-i-core/utils
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.isValidDid = isValidDid;
12
- exports.getDidMethod = getDidMethod;
13
- exports.normalizeDid = normalizeDid;
14
- exports.compareDids = compareDids;
15
- exports.getServerDid = getServerDid;
16
- exports.extractAgentId = extractAgentId;
17
- exports.extractAgentSlug = extractAgentSlug;
18
- exports.generateDidKeyFromBytes = generateDidKeyFromBytes;
19
- exports.generateDidKeyFromBase64 = generateDidKeyFromBase64;
20
- exports.didKeyFragment = didKeyFragment;
21
- const base58_1 = require("./base58");
22
- /**
23
- * Check if a string is a valid DID format
24
- *
25
- * @param did - String to validate
26
- * @returns true if string starts with "did:"
27
- *
28
- * @example
29
- * ```typescript
30
- * isValidDid("did:key:z6Mk...") // true
31
- * isValidDid("not-a-did") // false
32
- * ```
33
- */
34
- function isValidDid(did) {
35
- return typeof did === "string" && did.startsWith("did:");
36
- }
37
- /**
38
- * Get the DID method from a DID string
39
- *
40
- * @param did - DID string
41
- * @returns DID method (e.g., "key", "web") or null if invalid
42
- *
43
- * @example
44
- * ```typescript
45
- * getDidMethod("did:key:z6Mk...") // "key"
46
- * getDidMethod("did:web:example.com") // "web"
47
- * getDidMethod("invalid") // null
48
- * ```
49
- */
50
- function getDidMethod(did) {
51
- if (!isValidDid(did)) {
52
- return null;
53
- }
54
- const match = did.match(/^did:([^:]+):/);
55
- return match ? match[1] : null;
56
- }
57
- /**
58
- * Normalize a DID string (trim whitespace)
59
- *
60
- * @param did - DID string to normalize
61
- * @returns Normalized DID string
62
- *
63
- * @example
64
- * ```typescript
65
- * normalizeDid(" did:key:z6Mk... ") // "did:key:z6Mk..."
66
- * ```
67
- */
68
- function normalizeDid(did) {
69
- return did.trim();
70
- }
71
- /**
72
- * Compare two DIDs for equality (case-sensitive)
73
- *
74
- * @param did1 - First DID
75
- * @param did2 - Second DID
76
- * @returns true if DIDs are equal (after normalization)
77
- *
78
- * @example
79
- * ```typescript
80
- * compareDids("did:key:z6Mk...", "did:key:z6Mk...") // true
81
- * compareDids("did:key:z6Mk...", "did:web:example.com") // false
82
- * ```
83
- */
84
- function compareDids(did1, did2) {
85
- return normalizeDid(did1) === normalizeDid(did2);
86
- }
87
- /**
88
- * Extract server DID from config (supports both old and new field names)
89
- *
90
- * Supports backward compatibility by reading both `serverDid` and deprecated `agentDid`.
91
- * Prefers `serverDid` if both are present.
92
- *
93
- * @param config - Config object with identity field
94
- * @returns Server DID string
95
- * @throws Error if neither serverDid nor agentDid is configured
96
- *
97
- * @example
98
- * ```typescript
99
- * // New config
100
- * getServerDid({ identity: { serverDid: "did:web:server.com" } }) // "did:web:server.com"
101
- *
102
- * // Old config (backward compatibility)
103
- * getServerDid({ identity: { agentDid: "did:web:server.com" } }) // "did:web:server.com"
104
- *
105
- * // Prefers serverDid over agentDid
106
- * getServerDid({ identity: { serverDid: "new", agentDid: "old" } }) // "new"
107
- * ```
108
- */
109
- function getServerDid(config) {
110
- const serverDid = config.identity.serverDid || config.identity.agentDid;
111
- if (!serverDid) {
112
- throw new Error("Server DID not configured");
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
113
7
  }
114
- return serverDid;
115
- }
116
- /**
117
- * Extract agent ID from DID
118
- *
119
- * The agent ID is the last component of the DID.
120
- *
121
- * @param did - DID string
122
- * @returns Agent ID (last component of DID)
123
- *
124
- * @example
125
- * ```typescript
126
- * extractAgentId("did:web:knowthat.ai:agents:my-agent") // "my-agent"
127
- * extractAgentId("did:web:localhost:3000:agents:12912feb") // "12912feb"
128
- * extractAgentId("did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK") // "z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK"
129
- * ```
130
- */
131
- function extractAgentId(did) {
132
- const parts = did.split(':');
133
- return parts[parts.length - 1];
134
- }
135
- /**
136
- * Extract agent slug from DID
137
- *
138
- * Agent slug is the same as agent ID - the last component of the DID.
139
- * For DID format: did:web:knowthat.ai:agents:my-agent
140
- * Returns: my-agent
141
- *
142
- * @param did - DID string
143
- * @returns Agent slug (last component of DID)
144
- *
145
- * @example
146
- * ```typescript
147
- * extractAgentSlug("did:web:knowthat.ai:agents:my-agent") // "my-agent"
148
- * extractAgentSlug("did:web:localhost:3000:agents:12912feb") // "12912feb"
149
- * ```
150
- */
151
- function extractAgentSlug(did) {
152
- return extractAgentId(did);
153
- }
154
- /**
155
- * Ed25519 multicodec prefix for did:key encoding
156
- * As per https://w3c-ccg.github.io/did-method-key/
157
- */
158
- const ED25519_MULTICODEC_PREFIX = new Uint8Array([0xed, 0x01]);
159
- /**
160
- * Generate a did:key from Ed25519 public key bytes
161
- *
162
- * Following spec: https://w3c-ccg.github.io/did-method-key/
163
- * Format: did:key:z<multibase-base58btc(<multicodec-ed25519-pub><publicKey>)>
164
- *
165
- * @param publicKeyBytes - Ed25519 public key as Uint8Array (32 bytes)
166
- * @returns did:key string
167
- *
168
- * @example
169
- * ```typescript
170
- * const publicKey = new Uint8Array(32); // 32-byte Ed25519 public key
171
- * const did = generateDidKeyFromBytes(publicKey);
172
- * // did = "did:key:z6Mk..."
173
- * ```
174
- */
175
- function generateDidKeyFromBytes(publicKeyBytes) {
176
- // Combine multicodec prefix + public key
177
- const multicodecKey = new Uint8Array(ED25519_MULTICODEC_PREFIX.length + publicKeyBytes.length);
178
- multicodecKey.set(ED25519_MULTICODEC_PREFIX);
179
- multicodecKey.set(publicKeyBytes, ED25519_MULTICODEC_PREFIX.length);
180
- // Base58-btc encode and add multibase prefix 'z'
181
- const base58Encoded = (0, base58_1.base58Encode)(multicodecKey);
182
- return `did:key:z${base58Encoded}`;
183
- }
184
- /**
185
- * Generate a did:key from base64-encoded Ed25519 public key
186
- *
187
- * Convenience wrapper around generateDidKeyFromBytes for base64-encoded keys.
188
- *
189
- * @param publicKeyBase64 - Ed25519 public key as base64 string
190
- * @returns did:key string
191
- *
192
- * @example
193
- * ```typescript
194
- * const publicKeyBase64 = "...base64 encoded key...";
195
- * const did = generateDidKeyFromBase64(publicKeyBase64);
196
- * // did = "did:key:z6Mk..."
197
- * ```
198
- */
199
- function generateDidKeyFromBase64(publicKeyBase64) {
200
- // Decode base64 to bytes
201
- const publicKeyBytes = Uint8Array.from(atob(publicKeyBase64), (c) => c.charCodeAt(0));
202
- return generateDidKeyFromBytes(publicKeyBytes);
203
- }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
204
17
  /**
205
- * Get the spec-compliant fragment identifier for a did:key DID.
206
- *
207
- * Per the W3C CCG did:key spec, the fragment equals the multibase-encoded
208
- * public key value (the DID-specific-id). For example:
209
- * did:key:z6MkABC... → z6MkABC...
210
- *
211
- * @see https://w3c-ccg.github.io/did-key-spec/#document-creation-algorithm
212
- * @param did - A DID string
213
- * @returns The fragment identifier (multibase value for did:key, or 'keys-1' fallback)
18
+ * Compatibility re-export. The implementation moved to @kya-os/mcp-i-runtime
19
+ * (C4 Step 2). Kept here so the pinned `src/delegation/**` (E3.5 #2904) keeps
20
+ * resolving its `../utils/did-helpers` import without being modified.
214
21
  */
215
- function didKeyFragment(did) {
216
- if (did.startsWith('did:key:')) {
217
- return did.slice('did:key:'.length);
218
- }
219
- // Fallback for non-did:key methods
220
- return 'keys-1';
221
- }
22
+ __exportStar(require("@kya-os/mcp-i-runtime/utils/did-helpers"), exports);
222
23
  //# sourceMappingURL=did-helpers.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kya-os/mcp-i-core",
3
- "version": "1.7.0",
4
- "description": "Core runtime and types for MCP-I framework",
3
+ "version": "1.8.0",
4
+ "description": "Compatibility shim — re-exports @kya-os/mcp-i-runtime (product layer) plus the pinned W3C-VC delegation modules. Prefer @kya-os/mcp-i-runtime directly.",
5
5
  "license": "MIT",
6
6
  "author": "Dylan Hobbs",
7
7
  "repository": {
@@ -16,10 +16,6 @@
16
16
  "types": "./dist/index.d.ts",
17
17
  "default": "./dist/index.js"
18
18
  },
19
- "./runtime/audit-logger": {
20
- "types": "./dist/runtime/audit-logger.d.ts",
21
- "default": "./dist/runtime/audit-logger.js"
22
- },
23
19
  "./*": {
24
20
  "types": "./dist/*.d.ts",
25
21
  "default": "./dist/*.js"
@@ -36,6 +32,8 @@
36
32
  },
37
33
  "dependencies": {
38
34
  "@kya-os/contracts": "^1.8.0",
35
+ "@kya-os/mcp": "^1.6.1",
36
+ "@kya-os/mcp-i-runtime": "^1.0.0",
39
37
  "jose": "^5.6.3",
40
38
  "json-canonicalize": "^2.0.0",
41
39
  "zod": "^3.25.67"