@kya-os/mcp-i 1.5.3-canary.1 → 1.5.4

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.
Files changed (50) hide show
  1. package/dist/auth/jwt.d.ts +1 -1
  2. package/dist/auth/oauth/router.js +3 -8
  3. package/dist/cli-adapter/index.js +1 -1
  4. package/dist/cli-adapter/kta-registration.d.ts +1 -1
  5. package/dist/cli-adapter/kta-registration.js +2 -2
  6. package/dist/compiler/config/injection.js +2 -2
  7. package/dist/compiler/get-webpack-config/get-entries.js +12 -8
  8. package/dist/providers/node-providers.d.ts +1 -1
  9. package/dist/providers/node-providers.js +4 -4
  10. package/dist/runtime/adapter-express.js +1 -1
  11. package/dist/runtime/adapter-nextjs.js +1 -1
  12. package/dist/runtime/audit.d.ts +287 -3
  13. package/dist/runtime/audit.js +169 -4
  14. package/dist/runtime/auth-handshake.d.ts +1 -1
  15. package/dist/runtime/auth-handshake.js +1 -1
  16. package/dist/runtime/debug.d.ts +2 -2
  17. package/dist/runtime/debug.js +3 -3
  18. package/dist/runtime/delegation/index.d.ts +7 -0
  19. package/dist/runtime/delegation/index.js +23 -0
  20. package/dist/runtime/delegation/vc-issuer.d.ts +119 -0
  21. package/dist/runtime/delegation/vc-issuer.js +220 -0
  22. package/dist/runtime/delegation/vc-verifier.d.ts +193 -0
  23. package/dist/runtime/delegation/vc-verifier.js +387 -0
  24. package/dist/runtime/http.js +1 -1
  25. package/dist/runtime/identity.d.ts +10 -2
  26. package/dist/runtime/identity.js +68 -11
  27. package/dist/runtime/mcpi-runtime.d.ts +4 -1
  28. package/dist/runtime/mcpi-runtime.js +2 -2
  29. package/dist/runtime/migrate-identity.d.ts +16 -0
  30. package/dist/runtime/migrate-identity.js +118 -0
  31. package/dist/runtime/proof.js +2 -2
  32. package/dist/runtime/stdio.js +1 -1
  33. package/dist/runtime/transports/http/index.js +3 -1
  34. package/dist/runtime/utils/time.d.ts +80 -0
  35. package/dist/runtime/utils/time.js +117 -0
  36. package/dist/runtime/utils/tools.js +22 -3
  37. package/dist/runtime/verifier-middleware.js +1 -1
  38. package/dist/runtime/well-known.d.ts +0 -4
  39. package/dist/runtime/well-known.js +12 -26
  40. package/dist/storage/delegation.js +2 -2
  41. package/dist/test/deterministic-keys.d.ts +1 -1
  42. package/dist/test/deterministic-keys.js +6 -6
  43. package/dist/test/examples/test-usage-example.d.ts +6 -6
  44. package/dist/test/examples/test-usage-example.js +5 -5
  45. package/dist/test/local-verification.d.ts +1 -1
  46. package/dist/test/local-verification.js +10 -10
  47. package/dist/test/mock-identity-provider.d.ts +4 -4
  48. package/dist/test/mock-identity-provider.js +7 -7
  49. package/dist/test/runtime-integration.d.ts +2 -2
  50. package/package.json +4 -3
@@ -12,7 +12,9 @@ const middleware = INJECTED_MIDDLEWARE;
12
12
  // oauth config
13
13
  // @ts-expect-error: injected by compiler
14
14
  const oauthConfigRaw = OAUTH_CONFIG;
15
- const oauthConfig = (oauthConfigRaw && JSON.parse(oauthConfigRaw));
15
+ const oauthConfig = (oauthConfigRaw && typeof oauthConfigRaw === 'string'
16
+ ? JSON.parse(oauthConfigRaw)
17
+ : oauthConfigRaw);
16
18
  async function main() {
17
19
  const options = {
18
20
  port: httpConfig?.port,
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Time Formatting Utilities
3
+ *
4
+ * Provides human-readable time formatting for intervals and durations.
5
+ * Used by audit logging and other time-based features.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { formatTimeInterval } from './utils/time';
10
+ *
11
+ * formatTimeInterval(86400000); // "daily"
12
+ * formatTimeInterval(3600000); // "hourly"
13
+ * formatTimeInterval(7200000); // "2-hourly"
14
+ * formatTimeInterval(123456); // "123456ms"
15
+ * ```
16
+ */
17
+ /**
18
+ * Common time intervals in milliseconds
19
+ *
20
+ * These constants provide standard time intervals that can be used
21
+ * throughout the codebase for consistency.
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * const dailyRotation = TIME_INTERVALS.DAY; // 86400000
26
+ * const hourlyCheck = TIME_INTERVALS.HOUR; // 3600000
27
+ * ```
28
+ */
29
+ export declare const TIME_INTERVALS: {
30
+ /** 1 second in milliseconds */
31
+ readonly SECOND: 1000;
32
+ /** 1 minute in milliseconds */
33
+ readonly MINUTE: number;
34
+ /** 1 hour in milliseconds */
35
+ readonly HOUR: number;
36
+ /** 1 day in milliseconds */
37
+ readonly DAY: number;
38
+ /** 1 week in milliseconds */
39
+ readonly WEEK: number;
40
+ };
41
+ /**
42
+ * Format milliseconds into human-readable interval string
43
+ *
44
+ * Converts a time interval in milliseconds to a descriptive string
45
+ * that's easier for humans to understand and for logging purposes.
46
+ *
47
+ * **Format Priority:**
48
+ * 1. Weekly intervals (e.g., "weekly", "2-weekly")
49
+ * 2. Daily intervals (e.g., "daily", "3-daily")
50
+ * 3. Hourly intervals (e.g., "hourly", "12-hourly")
51
+ * 4. Minute intervals (e.g., "minutely", "30-minutely")
52
+ * 5. Second intervals (e.g., "every-second", "5-secondly")
53
+ * 6. Custom milliseconds (e.g., "123456ms")
54
+ *
55
+ * @param ms - Milliseconds to format (undefined returns "unknown")
56
+ * @returns Human-readable interval string
57
+ *
58
+ * @example Standard intervals
59
+ * ```typescript
60
+ * formatTimeInterval(86400000); // "daily"
61
+ * formatTimeInterval(3600000); // "hourly"
62
+ * formatTimeInterval(604800000); // "weekly"
63
+ * formatTimeInterval(60000); // "minutely"
64
+ * ```
65
+ *
66
+ * @example Multiple intervals
67
+ * ```typescript
68
+ * formatTimeInterval(172800000); // "2-daily" (2 days)
69
+ * formatTimeInterval(7200000); // "2-hourly" (2 hours)
70
+ * formatTimeInterval(1800000); // "30-minutely" (30 minutes)
71
+ * ```
72
+ *
73
+ * @example Edge cases
74
+ * ```typescript
75
+ * formatTimeInterval(undefined); // "unknown"
76
+ * formatTimeInterval(123456); // "123456ms" (custom)
77
+ * formatTimeInterval(1000); // "every-second"
78
+ * ```
79
+ */
80
+ export declare function formatTimeInterval(ms: number | undefined): string;
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ /**
3
+ * Time Formatting Utilities
4
+ *
5
+ * Provides human-readable time formatting for intervals and durations.
6
+ * Used by audit logging and other time-based features.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { formatTimeInterval } from './utils/time.js';
11
+ *
12
+ * formatTimeInterval(86400000); // "daily"
13
+ * formatTimeInterval(3600000); // "hourly"
14
+ * formatTimeInterval(7200000); // "2-hourly"
15
+ * formatTimeInterval(123456); // "123456ms"
16
+ * ```
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.TIME_INTERVALS = void 0;
20
+ exports.formatTimeInterval = formatTimeInterval;
21
+ /**
22
+ * Common time intervals in milliseconds
23
+ *
24
+ * These constants provide standard time intervals that can be used
25
+ * throughout the codebase for consistency.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * const dailyRotation = TIME_INTERVALS.DAY; // 86400000
30
+ * const hourlyCheck = TIME_INTERVALS.HOUR; // 3600000
31
+ * ```
32
+ */
33
+ exports.TIME_INTERVALS = {
34
+ /** 1 second in milliseconds */
35
+ SECOND: 1000,
36
+ /** 1 minute in milliseconds */
37
+ MINUTE: 60 * 1000,
38
+ /** 1 hour in milliseconds */
39
+ HOUR: 60 * 60 * 1000,
40
+ /** 1 day in milliseconds */
41
+ DAY: 24 * 60 * 60 * 1000,
42
+ /** 1 week in milliseconds */
43
+ WEEK: 7 * 24 * 60 * 60 * 1000,
44
+ };
45
+ /**
46
+ * Format milliseconds into human-readable interval string
47
+ *
48
+ * Converts a time interval in milliseconds to a descriptive string
49
+ * that's easier for humans to understand and for logging purposes.
50
+ *
51
+ * **Format Priority:**
52
+ * 1. Weekly intervals (e.g., "weekly", "2-weekly")
53
+ * 2. Daily intervals (e.g., "daily", "3-daily")
54
+ * 3. Hourly intervals (e.g., "hourly", "12-hourly")
55
+ * 4. Minute intervals (e.g., "minutely", "30-minutely")
56
+ * 5. Second intervals (e.g., "every-second", "5-secondly")
57
+ * 6. Custom milliseconds (e.g., "123456ms")
58
+ *
59
+ * @param ms - Milliseconds to format (undefined returns "unknown")
60
+ * @returns Human-readable interval string
61
+ *
62
+ * @example Standard intervals
63
+ * ```typescript
64
+ * formatTimeInterval(86400000); // "daily"
65
+ * formatTimeInterval(3600000); // "hourly"
66
+ * formatTimeInterval(604800000); // "weekly"
67
+ * formatTimeInterval(60000); // "minutely"
68
+ * ```
69
+ *
70
+ * @example Multiple intervals
71
+ * ```typescript
72
+ * formatTimeInterval(172800000); // "2-daily" (2 days)
73
+ * formatTimeInterval(7200000); // "2-hourly" (2 hours)
74
+ * formatTimeInterval(1800000); // "30-minutely" (30 minutes)
75
+ * ```
76
+ *
77
+ * @example Edge cases
78
+ * ```typescript
79
+ * formatTimeInterval(undefined); // "unknown"
80
+ * formatTimeInterval(123456); // "123456ms" (custom)
81
+ * formatTimeInterval(1000); // "every-second"
82
+ * ```
83
+ */
84
+ function formatTimeInterval(ms) {
85
+ if (ms === undefined || ms === null)
86
+ return "unknown";
87
+ // Handle 0 explicitly (0 % anything === 0, so check first)
88
+ if (ms === 0)
89
+ return "0ms";
90
+ // Check for exact weekly intervals
91
+ if (ms % exports.TIME_INTERVALS.WEEK === 0) {
92
+ const weeks = ms / exports.TIME_INTERVALS.WEEK;
93
+ return weeks === 1 ? "weekly" : `${weeks}-weekly`;
94
+ }
95
+ // Check for exact daily intervals
96
+ if (ms % exports.TIME_INTERVALS.DAY === 0) {
97
+ const days = ms / exports.TIME_INTERVALS.DAY;
98
+ return days === 1 ? "daily" : `${days}-daily`;
99
+ }
100
+ // Check for exact hourly intervals
101
+ if (ms % exports.TIME_INTERVALS.HOUR === 0) {
102
+ const hours = ms / exports.TIME_INTERVALS.HOUR;
103
+ return hours === 1 ? "hourly" : `${hours}-hourly`;
104
+ }
105
+ // Check for exact minute intervals
106
+ if (ms % exports.TIME_INTERVALS.MINUTE === 0) {
107
+ const minutes = ms / exports.TIME_INTERVALS.MINUTE;
108
+ return minutes === 1 ? "minutely" : `${minutes}-minutely`;
109
+ }
110
+ // Check for exact second intervals
111
+ if (ms % exports.TIME_INTERVALS.SECOND === 0) {
112
+ const seconds = ms / exports.TIME_INTERVALS.SECOND;
113
+ return seconds === 1 ? "every-second" : `${seconds}-secondly`;
114
+ }
115
+ // Fall back to milliseconds for custom intervals
116
+ return `${ms}ms`;
117
+ }
@@ -12,7 +12,10 @@ const proof_batch_queue_1 = require("../proof-batch-queue");
12
12
  // Parse runtime config path from injected variable
13
13
  // @ts-expect-error: injected by compiler
14
14
  const rawRuntimeConfigPath = typeof RUNTIME_CONFIG_PATH !== "undefined" ? RUNTIME_CONFIG_PATH : undefined;
15
- const runtimeConfigPath = rawRuntimeConfigPath ? JSON.parse(rawRuntimeConfigPath) : null;
15
+ // Single-parse to match single-stringify from webpack DefinePlugin
16
+ const runtimeConfigPath = rawRuntimeConfigPath
17
+ ? (typeof rawRuntimeConfigPath === 'string' ? JSON.parse(rawRuntimeConfigPath) : rawRuntimeConfigPath)
18
+ : null;
16
19
  /** Validates if a value is a valid Zod schema object */
17
20
  function isZodRawShape(value) {
18
21
  if (typeof value !== "object" || value === null) {
@@ -375,9 +378,25 @@ async function addToolsToServer(server, toolModules, identityConfig) {
375
378
  lastActivity: timestamp,
376
379
  ttlMinutes: 30,
377
380
  };
378
- // Generate proof using the proof generator
381
+ // Determine scopeId from tool protection configuration
382
+ // This enables AgentShield tool auto-discovery
383
+ let scopeId;
384
+ const toolProtection = tool_protection_registry_1.toolProtectionRegistry.get(name);
385
+ if (toolProtection?.requiredScopes && toolProtection.requiredScopes.length > 0) {
386
+ // Use the first required scope as the scopeId (e.g., "files:read")
387
+ scopeId = toolProtection.requiredScopes[0];
388
+ }
389
+ else {
390
+ // Fallback: Use tool name with "execute" action for unprotected tools
391
+ scopeId = `${name}:execute`;
392
+ }
393
+ if (identityConfig?.debug) {
394
+ console.error(`[MCPI] Proof scopeId for tool "${name}": ${scopeId}`);
395
+ }
396
+ // Generate proof using the proof generator with scopeId
379
397
  const proofGen = new proof_1.ProofGenerator(identity);
380
- const proof = await proofGen.generateProof(toolRequest, toolResponse, session);
398
+ const proof = await proofGen.generateProof(toolRequest, toolResponse, session, { scopeId } // Pass scopeId for tool auto-discovery
399
+ );
381
400
  if (identityConfig?.debug) {
382
401
  console.error(`[MCPI] Generated proof for tool "${name}" - DID: ${proof.meta.did}`);
383
402
  }
@@ -218,7 +218,7 @@ function verifyExpress(config) {
218
218
  req.ctx = req.ctx || {};
219
219
  req.ctx.agent = {
220
220
  did: result.headers[verifier_1.AGENT_HEADERS.DID],
221
- keyId: result.headers[verifier_1.AGENT_HEADERS.KEY_ID],
221
+ kid: result.headers[verifier_1.AGENT_HEADERS.KEY_ID],
222
222
  session: result.headers[verifier_1.AGENT_HEADERS.SESSION],
223
223
  scopes: result.headers[verifier_1.AGENT_HEADERS.SCOPES]?.split(",") || [],
224
224
  delegationRef: result.headers[verifier_1.AGENT_HEADERS.DELEGATION_REF],
@@ -102,10 +102,6 @@ export declare class WellKnownManager {
102
102
  * Encode public key as multibase (base58btc with 'z' prefix for Ed25519)
103
103
  */
104
104
  private encodePublicKeyMultibase;
105
- /**
106
- * Simple base58 encoding (use proper library in production)
107
- */
108
- private encodeBase58;
109
105
  /**
110
106
  * Update configuration
111
107
  */
@@ -11,6 +11,11 @@ exports.createWellKnownHandler = createWellKnownHandler;
11
11
  exports.validateDIDDocument = validateDIDDocument;
12
12
  exports.validateAgentDocument = validateAgentDocument;
13
13
  exports.extractDIDFromPath = extractDIDFromPath;
14
+ // Load base-x synchronously using require (mcp-i is CommonJS)
15
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
16
+ const baseX = require("base-x");
17
+ const base58 = baseX.default || baseX;
18
+ const base58Encoder = base58('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz');
14
19
  /**
15
20
  * Well-known endpoints manager
16
21
  */
@@ -26,7 +31,7 @@ class WellKnownManager {
26
31
  * Requirements: 7.1, 7.5
27
32
  */
28
33
  generateDIDDocument() {
29
- const keyId = `#${this.identity.keyId}`;
34
+ const kid = `#${this.identity.kid}`;
30
35
  // Convert base64 public key to multibase format
31
36
  const publicKeyMultibase = this.encodePublicKeyMultibase(this.identity.publicKey);
32
37
  const didDocument = {
@@ -37,14 +42,14 @@ class WellKnownManager {
37
42
  id: this.identity.did,
38
43
  verificationMethod: [
39
44
  {
40
- id: keyId,
45
+ id: kid,
41
46
  type: "Ed25519VerificationKey2020",
42
47
  controller: this.identity.did,
43
48
  publicKeyMultibase,
44
49
  },
45
50
  ],
46
- authentication: [keyId],
47
- assertionMethod: [keyId],
51
+ authentication: [kid],
52
+ assertionMethod: [kid],
48
53
  };
49
54
  return didDocument;
50
55
  }
@@ -108,34 +113,15 @@ class WellKnownManager {
108
113
  */
109
114
  encodePublicKeyMultibase(base64PublicKey) {
110
115
  // For Ed25519, we use base58btc encoding with 'z' prefix
111
- // This is a simplified implementation - in production, use proper multibase library
112
116
  const publicKeyBytes = Buffer.from(base64PublicKey, "base64");
113
117
  // Ed25519 public key prefix (0xed01) + key bytes
114
118
  const prefixedKey = Buffer.concat([
115
119
  Buffer.from([0xed, 0x01]), // Ed25519 multicodec prefix
116
120
  publicKeyBytes,
117
121
  ]);
118
- // Convert to base58btc (simplified - use proper base58 library in production)
119
- const base58 = this.encodeBase58(prefixedKey);
120
- return `z${base58}`; // 'z' prefix indicates base58btc
121
- }
122
- /**
123
- * Simple base58 encoding (use proper library in production)
124
- */
125
- encodeBase58(buffer) {
126
- const alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
127
- let num = BigInt("0x" + buffer.toString("hex"));
128
- let result = "";
129
- while (num > 0) {
130
- const remainder = num % 58n;
131
- result = alphabet[Number(remainder)] + result;
132
- num = num / 58n;
133
- }
134
- // Handle leading zeros
135
- for (let i = 0; i < buffer.length && buffer[i] === 0; i++) {
136
- result = "1" + result;
137
- }
138
- return result;
122
+ // Convert to base58btc using base-x library
123
+ const base58Encoded = base58Encoder.encode(prefixedKey);
124
+ return `z${base58Encoded}`; // 'z' prefix indicates base58btc
139
125
  }
140
126
  /**
141
127
  * Update configuration
@@ -31,7 +31,7 @@ class DefaultDelegationManager {
31
31
  ref: `del_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
32
32
  contentHash: `sha256:${Array.from({ length: 64 }, () => Math.floor(Math.random() * 16).toString(16)).join("")}`,
33
33
  action: "issue",
34
- ts: now,
34
+ ts: new Date().toISOString(),
35
35
  logIndex: Math.floor(Math.random() * 10000),
36
36
  logRoot: Array.from({ length: 64 }, () => Math.floor(Math.random() * 16).toString(16)).join(""),
37
37
  inclusionProof: [
@@ -56,7 +56,7 @@ class DefaultDelegationManager {
56
56
  ref: `rev_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
57
57
  contentHash: `sha256:${Array.from({ length: 64 }, () => Math.floor(Math.random() * 16).toString(16)).join("")}`,
58
58
  action: "revoke",
59
- ts: Math.floor(Date.now() / 1000),
59
+ ts: new Date().toISOString(),
60
60
  logIndex: Math.floor(Math.random() * 10000),
61
61
  logRoot: Array.from({ length: 64 }, () => Math.floor(Math.random() * 16).toString(16)).join(""),
62
62
  inclusionProof: [
@@ -14,7 +14,7 @@ export declare function generateDeterministicKeyPair(seed: string): {
14
14
  */
15
15
  export declare function generateTestIdentity(testName: string, options?: {
16
16
  did?: string;
17
- keyId?: string;
17
+ kid?: string;
18
18
  seed?: string;
19
19
  }): MockIdentity;
20
20
  /**
@@ -43,12 +43,12 @@ function generateTestIdentity(testName, options = {}) {
43
43
  (0, test_environment_1.ensureTestMode)();
44
44
  const seed = options.seed || (0, test_environment_1.getCurrentTestSeed)(testName);
45
45
  const did = options.did || test_1.TEST_DIDS.AGENT_1;
46
- const keyId = options.keyId || test_1.TEST_KEY_IDS.KEY_TEST_1;
47
- const { privateKey, publicKey } = generateDeterministicKeyPair(`${seed}-${testName}-${did}-${keyId}`);
46
+ const kid = options.kid || test_1.TEST_KEY_IDS.KEY_TEST_1;
47
+ const { privateKey, publicKey } = generateDeterministicKeyPair(`${seed}-${testName}-${did}-${kid}`);
48
48
  const now = new Date().toISOString();
49
49
  return {
50
50
  did,
51
- keyId,
51
+ kid,
52
52
  privateKey,
53
53
  publicKey,
54
54
  createdAt: now,
@@ -63,15 +63,15 @@ function getPredefinedTestIdentities() {
63
63
  return {
64
64
  agent1: generateTestIdentity("agent1", {
65
65
  did: test_1.TEST_DIDS.AGENT_1,
66
- keyId: test_1.TEST_KEY_IDS.KEY_TEST_1,
66
+ kid: test_1.TEST_KEY_IDS.KEY_TEST_1,
67
67
  }),
68
68
  agent2: generateTestIdentity("agent2", {
69
69
  did: test_1.TEST_DIDS.AGENT_2,
70
- keyId: test_1.TEST_KEY_IDS.KEY_TEST_2,
70
+ kid: test_1.TEST_KEY_IDS.KEY_TEST_2,
71
71
  }),
72
72
  verifier1: generateTestIdentity("verifier1", {
73
73
  did: test_1.TEST_DIDS.VERIFIER_1,
74
- keyId: test_1.TEST_KEY_IDS.KEY_VERIFIER_1,
74
+ kid: test_1.TEST_KEY_IDS.KEY_VERIFIER_1,
75
75
  }),
76
76
  };
77
77
  }
@@ -38,7 +38,7 @@ export declare function exampleProofTesting(): Promise<{
38
38
  };
39
39
  errors: string[];
40
40
  did?: string | undefined;
41
- keyId?: string | undefined;
41
+ kid?: string | undefined;
42
42
  }>;
43
43
  /**
44
44
  * Example: Intercepting KTA calls
@@ -61,11 +61,11 @@ export declare function exampleKTAInterception(): Promise<{
61
61
  export declare function exampleRuntimeIntegration(): {
62
62
  testIdentity: {
63
63
  did: string;
64
- keyId: string;
64
+ kid: string;
65
65
  privateKey: string;
66
66
  publicKey: string;
67
67
  createdAt: string;
68
- lastRotated: string;
68
+ lastRotated?: string | undefined;
69
69
  };
70
70
  sessionContext: {
71
71
  sessionId: string;
@@ -104,7 +104,7 @@ export declare function exampleCompleteTestScenario(): Promise<{
104
104
  };
105
105
  errors: string[];
106
106
  did?: string | undefined;
107
- keyId?: string | undefined;
107
+ kid?: string | undefined;
108
108
  };
109
109
  ktaResults: {
110
110
  registrationResult: {
@@ -121,11 +121,11 @@ export declare function exampleCompleteTestScenario(): Promise<{
121
121
  runtimeResults: {
122
122
  testIdentity: {
123
123
  did: string;
124
- keyId: string;
124
+ kid: string;
125
125
  privateKey: string;
126
126
  publicKey: string;
127
127
  createdAt: string;
128
- lastRotated: string;
128
+ lastRotated?: string | undefined;
129
129
  };
130
130
  sessionContext: {
131
131
  sessionId: string;
@@ -42,12 +42,12 @@ function exampleMockIdentityProvider() {
42
42
  // Generate a custom test identity
43
43
  const customIdentity = (0, index_js_1.generateTestIdentity)("my-custom-test", {
44
44
  did: "did:test:my-custom-agent",
45
- keyId: "key-custom-1",
45
+ kid: "key-custom-1",
46
46
  });
47
47
  // Set the identity in the provider
48
48
  mockProvider.setIdentity("custom", customIdentity);
49
49
  // Set delegation status
50
- mockProvider.setDelegation(`${customIdentity.did}:${customIdentity.keyId}`, "active");
50
+ mockProvider.setDelegation(`${customIdentity.did}:${customIdentity.kid}`, "active");
51
51
  // Simulate KTA failures for testing error scenarios
52
52
  mockProvider.simulateKTAFailure("network");
53
53
  return mockProvider;
@@ -75,7 +75,7 @@ async function exampleProofTesting() {
75
75
  // Create a mock proof
76
76
  const mockProof = (0, index_js_1.createMockProof)({
77
77
  did: test_1.TEST_DIDS.AGENT_1,
78
- keyId: test_1.TEST_KEY_IDS.KEY_TEST_1,
78
+ kid: test_1.TEST_KEY_IDS.KEY_TEST_1,
79
79
  request: mockRequest,
80
80
  response: mockResponse,
81
81
  sessionId: "sess_test_example",
@@ -87,7 +87,7 @@ async function exampleProofTesting() {
87
87
  console.log("Proof verification result:", {
88
88
  valid: verificationResult.valid,
89
89
  did: verificationResult.did,
90
- keyId: verificationResult.keyId,
90
+ kid: verificationResult.kid,
91
91
  signatureValid: verificationResult.signature.valid,
92
92
  proofValid: verificationResult.proof.valid,
93
93
  sessionValid: verificationResult.session.valid,
@@ -132,7 +132,7 @@ function exampleRuntimeIntegration() {
132
132
  const testIdentity = (0, index_js_1.getTestIdentityForRuntime)("agent1");
133
133
  console.log("Test identity for runtime:", {
134
134
  did: testIdentity.did,
135
- keyId: testIdentity.keyId,
135
+ kid: testIdentity.kid,
136
136
  // Don't log private key in real usage
137
137
  });
138
138
  // Create test session context
@@ -19,7 +19,7 @@ export declare function verifyDIDDocumentLocally(did: string): Promise<{
19
19
  */
20
20
  export declare function createMockProof(options: {
21
21
  did?: string;
22
- keyId?: string;
22
+ kid?: string;
23
23
  request?: any;
24
24
  response?: any;
25
25
  sessionId?: string;
@@ -166,16 +166,16 @@ async function verifyProofLocally(proof, request, response) {
166
166
  }
167
167
  let signatureValid = false;
168
168
  let did;
169
- let keyId;
169
+ let kid;
170
170
  if (proofCheck.structure && proof?.meta) {
171
171
  did = proof.meta.did;
172
- keyId = proof.meta.kid;
172
+ kid = proof.meta.kid;
173
173
  // Get mock identity for verification
174
174
  const mockProvider = (0, mock_identity_provider_1.getMockIdentityProvider)();
175
175
  const identity = mockProvider.getIdentity("agent1") ||
176
176
  mockProvider.getIdentity("agent2") ||
177
177
  mockProvider.getIdentity("verifier1");
178
- if (identity && identity.did === did && identity.keyId === keyId) {
178
+ if (identity && identity.did === did && identity.kid === kid) {
179
179
  // Verify signature using mock implementation
180
180
  const canonicalMeta = canonicalizeJSON(proof.meta);
181
181
  const signatureCheck = verifySignature(canonicalMeta, proof.jws, identity.publicKey);
@@ -185,7 +185,7 @@ async function verifyProofLocally(proof, request, response) {
185
185
  }
186
186
  }
187
187
  else {
188
- errors.push(`No matching identity found for DID: ${did}, KeyID: ${keyId}`);
188
+ errors.push(`No matching identity found for DID: ${did}, KeyID: ${kid}`);
189
189
  }
190
190
  }
191
191
  // Verify session
@@ -212,7 +212,7 @@ async function verifyProofLocally(proof, request, response) {
212
212
  const result = {
213
213
  valid: errors.length === 0,
214
214
  did,
215
- keyId,
215
+ kid,
216
216
  signature: {
217
217
  valid: signatureValid,
218
218
  algorithm: "EdDSA",
@@ -273,14 +273,14 @@ async function verifyDIDDocumentLocally(did) {
273
273
  id: did,
274
274
  verificationMethod: [
275
275
  {
276
- id: `${did}#${identity.keyId}`,
276
+ id: `${did}#${identity.kid}`,
277
277
  type: "Ed25519VerificationKey2020",
278
278
  controller: did,
279
279
  publicKeyMultibase: `z${identity.publicKey}`,
280
280
  },
281
281
  ],
282
- authentication: [`${did}#${identity.keyId}`],
283
- assertionMethod: [`${did}#${identity.keyId}`],
282
+ authentication: [`${did}#${identity.kid}`],
283
+ assertionMethod: [`${did}#${identity.kid}`],
284
284
  };
285
285
  return {
286
286
  valid: true,
@@ -308,7 +308,7 @@ function createMockProof(options) {
308
308
  }
309
309
  const now = Math.floor(Date.now() / 1000);
310
310
  const did = options.did || identity.did;
311
- const keyId = options.keyId || identity.keyId;
311
+ const kid = options.kid || identity.kid;
312
312
  const sessionId = options.sessionId || "sess_test_mock";
313
313
  const nonce = options.nonce || "mock_nonce";
314
314
  const audience = options.audience || "test.example.com";
@@ -320,7 +320,7 @@ function createMockProof(options) {
320
320
  : "sha256:mock_response_hash";
321
321
  const meta = {
322
322
  did,
323
- kid: keyId,
323
+ kid: kid,
324
324
  ts: now,
325
325
  nonce,
326
326
  audience,
@@ -32,7 +32,7 @@ export declare class MockIdentityProvider {
32
32
  */
33
33
  generateIdentity(key: string, testName: string, options?: {
34
34
  did?: string;
35
- keyId?: string;
35
+ kid?: string;
36
36
  }): MockIdentity;
37
37
  /**
38
38
  * Set delegation status for a DID:KeyID combination
@@ -41,7 +41,7 @@ export declare class MockIdentityProvider {
41
41
  /**
42
42
  * Get delegation status
43
43
  */
44
- getDelegationStatus(did: string, keyId: string): MockDelegationStatus;
44
+ getDelegationStatus(did: string, kid: string): MockDelegationStatus;
45
45
  /**
46
46
  * Simulate KTA failure scenarios
47
47
  */
@@ -61,7 +61,7 @@ export declare class MockIdentityProvider {
61
61
  /**
62
62
  * Mock KTA registration call
63
63
  */
64
- mockRegister(did: string, _keyId: string): Promise<{
64
+ mockRegister(did: string, _kid: string): Promise<{
65
65
  success: boolean;
66
66
  agentURL?: string;
67
67
  error?: string;
@@ -69,7 +69,7 @@ export declare class MockIdentityProvider {
69
69
  /**
70
70
  * Mock KTA delegation check
71
71
  */
72
- mockCheckDelegation(did: string, keyId: string): Promise<{
72
+ mockCheckDelegation(did: string, kid: string): Promise<{
73
73
  status: MockDelegationStatus;
74
74
  error?: string;
75
75
  }>;