@kya-os/mcp-i-core 1.6.0 → 1.6.2
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}
|
|
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}
|
|
122
|
-
assertionMethod: [`${did}
|
|
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}
|
|
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}
|
|
156
|
-
assertionMethod: [`${did}
|
|
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
|
|
239
|
-
const keyId = `${did}
|
|
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,
|
|
@@ -18,19 +18,19 @@ exports.createDelegationErrorFormatter = createDelegationErrorFormatter;
|
|
|
18
18
|
* Default message template (matches original adapter/agent behavior)
|
|
19
19
|
*/
|
|
20
20
|
const DEFAULT_TEMPLATE = {
|
|
21
|
-
message: `Authorization required.
|
|
21
|
+
message: `Authorization required for "{toolName}".
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Authorization URL: {consentUrl}
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
Share this URL with the user so they can authorize in their browser, then retry.`,
|
|
26
26
|
noUrlMessage: `Authorization required for "{toolName}" but no consent URL is available.
|
|
27
27
|
|
|
28
28
|
Please contact the administrator to configure delegation for this tool.`,
|
|
29
|
-
oauthMessage: `Authorization required.
|
|
29
|
+
oauthMessage: `Authorization required for "{toolName}".
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
Sign in with {provider}: {oauthUrl}
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
Share this URL with the user so they can sign in with {provider}, then retry.`,
|
|
34
34
|
noOAuthUrlMessage: `Authorization required for "{toolName}" but no {provider} URL is available.
|
|
35
35
|
|
|
36
36
|
Please contact the administrator to configure OAuth for this tool.`,
|
|
@@ -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
|