@kya-os/mcp-i-core 1.6.0 → 1.6.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.
@@ -21,6 +21,7 @@ exports.publicKeyToJwk = publicKeyToJwk;
21
21
  exports.createDidKeyResolver = createDidKeyResolver;
22
22
  exports.resolveDidKeySync = resolveDidKeySync;
23
23
  const base58_1 = require("../utils/base58");
24
+ const did_helpers_1 = require("../utils/did-helpers");
24
25
  const base64_1 = require("../utils/base64");
25
26
  /** Ed25519 multicodec prefix (0xed 0x01) */
26
27
  const ED25519_MULTICODEC_PREFIX = new Uint8Array([0xed, 0x01]);
@@ -106,9 +107,10 @@ function createDidKeyResolver() {
106
107
  const publicKeyJwk = publicKeyToJwk(publicKeyBytes);
107
108
  // Get the multibase-encoded key for publicKeyMultibase
108
109
  const multibaseKey = did.replace('did:key:', '');
110
+ const fragment = (0, did_helpers_1.didKeyFragment)(did);
109
111
  // Construct the verification method
110
112
  const verificationMethod = {
111
- id: `${did}#keys-1`,
113
+ id: `${did}#${fragment}`,
112
114
  type: 'Ed25519VerificationKey2020',
113
115
  controller: did,
114
116
  publicKeyJwk,
@@ -118,8 +120,8 @@ function createDidKeyResolver() {
118
120
  return {
119
121
  id: did,
120
122
  verificationMethod: [verificationMethod],
121
- authentication: [`${did}#keys-1`],
122
- assertionMethod: [`${did}#keys-1`],
123
+ authentication: [`${did}#${fragment}`],
124
+ assertionMethod: [`${did}#${fragment}`],
123
125
  };
124
126
  },
125
127
  };
@@ -142,8 +144,9 @@ function resolveDidKeySync(did) {
142
144
  }
143
145
  const publicKeyJwk = publicKeyToJwk(publicKeyBytes);
144
146
  const multibaseKey = did.replace('did:key:', '');
147
+ const fragment = (0, did_helpers_1.didKeyFragment)(did);
145
148
  const verificationMethod = {
146
- id: `${did}#keys-1`,
149
+ id: `${did}#${fragment}`,
147
150
  type: 'Ed25519VerificationKey2020',
148
151
  controller: did,
149
152
  publicKeyJwk,
@@ -152,8 +155,8 @@ function resolveDidKeySync(did) {
152
155
  return {
153
156
  id: did,
154
157
  verificationMethod: [verificationMethod],
155
- authentication: [`${did}#keys-1`],
156
- assertionMethod: [`${did}#keys-1`],
158
+ authentication: [`${did}#${fragment}`],
159
+ assertionMethod: [`${did}#${fragment}`],
157
160
  };
158
161
  }
159
162
  //# sourceMappingURL=did-key-resolver.js.map
@@ -16,6 +16,7 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.UserDidManager = void 0;
19
+ const did_helpers_1 = require("../utils/did-helpers");
19
20
  /**
20
21
  * User DID Manager
21
22
  *
@@ -235,8 +236,8 @@ class UserDidManager {
235
236
  const publicKeyBytes = this.base64ToBytes(keyPair.publicKey);
236
237
  // Generate did:key from public key
237
238
  const did = this.generateDidKeyFromPublicKey(publicKeyBytes);
238
- // Key ID is the DID with #keys-1 fragment (standard for did:key)
239
- const keyId = `${did}#keys-1`;
239
+ // Key ID uses spec-compliant fragment (multibase value for did:key)
240
+ const keyId = `${did}#${(0, did_helpers_1.didKeyFragment)(did)}`;
240
241
  return {
241
242
  did,
242
243
  publicKey: keyPair.publicKey,
@@ -153,4 +153,16 @@ export declare function generateDidKeyFromBytes(publicKeyBytes: Uint8Array): str
153
153
  * ```
154
154
  */
155
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;
156
168
  //# sourceMappingURL=did-helpers.d.ts.map
@@ -17,6 +17,7 @@ exports.extractAgentId = extractAgentId;
17
17
  exports.extractAgentSlug = extractAgentSlug;
18
18
  exports.generateDidKeyFromBytes = generateDidKeyFromBytes;
19
19
  exports.generateDidKeyFromBase64 = generateDidKeyFromBase64;
20
+ exports.didKeyFragment = didKeyFragment;
20
21
  const base58_1 = require("./base58");
21
22
  /**
22
23
  * Check if a string is a valid DID format
@@ -200,4 +201,22 @@ function generateDidKeyFromBase64(publicKeyBase64) {
200
201
  const publicKeyBytes = Uint8Array.from(atob(publicKeyBase64), (c) => c.charCodeAt(0));
201
202
  return generateDidKeyFromBytes(publicKeyBytes);
202
203
  }
204
+ /**
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)
214
+ */
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
+ }
203
222
  //# sourceMappingURL=did-helpers.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kya-os/mcp-i-core",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "Core runtime and types for MCP-I framework",
5
5
  "license": "MIT",
6
6
  "author": "Dylan Hobbs",
@@ -25,15 +25,6 @@
25
25
  "default": "./dist/*.js"
26
26
  }
27
27
  },
28
- "scripts": {
29
- "build": "tsc",
30
- "test": "vitest run",
31
- "test:coverage": "vitest run --coverage",
32
- "test:watch": "vitest",
33
- "lint": "eslint .",
34
- "clean": "rm -rf dist .turbo node_modules",
35
- "prepublishOnly": "npm run build && node ../create-mcpi-app/scripts/validate-no-workspace.js"
36
- },
37
28
  "dependencies": {
38
29
  "@kya-os/contracts": "^1.7.26",
39
30
  "jose": "^5.6.3",
@@ -58,5 +49,13 @@
58
49
  },
59
50
  "publishConfig": {
60
51
  "access": "public"
52
+ },
53
+ "scripts": {
54
+ "build": "tsc",
55
+ "test": "vitest run",
56
+ "test:coverage": "vitest run --coverage",
57
+ "test:watch": "vitest",
58
+ "lint": "eslint .",
59
+ "clean": "rm -rf dist .turbo node_modules"
61
60
  }
62
- }
61
+ }