@kya-os/mcp-i-runtime 1.1.0 → 1.2.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.
Files changed (51) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/config.d.ts +5 -7
  3. package/dist/config.d.ts.map +1 -1
  4. package/dist/config.js +4 -6
  5. package/dist/config.js.map +1 -1
  6. package/dist/index.d.ts +2 -1
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +13 -2
  9. package/dist/index.js.map +1 -1
  10. package/dist/runtime/audit-logger.d.ts +6 -28
  11. package/dist/runtime/audit-logger.d.ts.map +1 -1
  12. package/dist/runtime/audit-logger.js +5 -3
  13. package/dist/runtime/audit-logger.js.map +1 -1
  14. package/dist/runtime/audit.d.ts +132 -0
  15. package/dist/runtime/audit.d.ts.map +1 -0
  16. package/dist/runtime/audit.js +424 -0
  17. package/dist/runtime/audit.js.map +1 -0
  18. package/dist/runtime/base.d.ts +9 -48
  19. package/dist/runtime/base.d.ts.map +1 -1
  20. package/dist/runtime/base.js +109 -89
  21. package/dist/runtime/base.js.map +1 -1
  22. package/dist/services/oauth-config.service.d.ts.map +1 -1
  23. package/dist/services/oauth-config.service.js +29 -0
  24. package/dist/services/oauth-config.service.js.map +1 -1
  25. package/package.json +7 -3
  26. package/src/__tests__/config/provider-runtime-config.test.ts +2 -9
  27. package/src/__tests__/config.test.ts +12 -11
  28. package/src/__tests__/integration/full-flow.test.ts +0 -5
  29. package/src/__tests__/integration.test.ts +2 -6
  30. package/src/__tests__/runtime/audit.test.ts +327 -0
  31. package/src/__tests__/runtime/base-extensions.test.ts +0 -46
  32. package/src/__tests__/runtime/base.test.ts +71 -102
  33. package/src/__tests__/runtime/delegation-flow.test.ts +0 -4
  34. package/src/__tests__/runtime/process-tool-call-security.test.ts +5 -11
  35. package/src/__tests__/runtime/proof-client-did.test.ts +0 -4
  36. package/src/__tests__/runtime/provider-selection.test.ts +0 -2
  37. package/src/__tests__/runtime/route-interception.test.ts +7 -4
  38. package/src/__tests__/runtime/tool-protection-enforcement.test.ts +23 -31
  39. package/src/__tests__/services/tool-protection-merged-config.test.ts +0 -40
  40. package/src/config/__tests__/merged-config.spec.ts +0 -26
  41. package/src/config.ts +9 -10
  42. package/src/index.ts +23 -2
  43. package/src/runtime/__tests__/audit-logger-compat.test.ts +15 -0
  44. package/src/runtime/audit-logger.ts +6 -29
  45. package/src/runtime/audit.ts +598 -0
  46. package/src/runtime/base.ts +154 -99
  47. package/src/services/__tests__/oauth-config.service.test.ts +66 -0
  48. package/src/services/__tests__/proof-verifier.integration.test.ts +1 -1
  49. package/src/services/__tests__/proof-verifier.test.ts +6 -3
  50. package/src/services/oauth-config.service.ts +44 -1
  51. package/src/__tests__/runtime/audit-logger.test.ts +0 -154
@@ -1,154 +0,0 @@
1
- /**
2
- * IAuditLogger Interface Tests
3
- *
4
- * Tests for the IAuditLogger interface contract validation
5
- * and type compatibility checks.
6
- */
7
-
8
- import { describe, it, expect } from "vitest";
9
- import type { IAuditLogger } from "../../runtime/audit-logger.js";
10
- import type { AuditContext, AuditEventContext } from "@kya-os/contracts/audit";
11
-
12
- /**
13
- * Mock implementation of IAuditLogger for testing
14
- */
15
- class MockAuditLogger implements IAuditLogger {
16
- public logAuditRecordCalls: AuditContext[] = [];
17
- public logEventCalls: AuditEventContext[] = [];
18
-
19
- async logAuditRecord(context: AuditContext): Promise<void> {
20
- this.logAuditRecordCalls.push(context);
21
- }
22
-
23
- async logEvent(context: AuditEventContext): Promise<void> {
24
- this.logEventCalls.push(context);
25
- }
26
- }
27
-
28
- describe("IAuditLogger Interface", () => {
29
- describe("Interface contract validation", () => {
30
- it("should require logAuditRecord method", () => {
31
- const logger: IAuditLogger = new MockAuditLogger();
32
- expect(typeof logger.logAuditRecord).toBe("function");
33
- });
34
-
35
- it("should require logEvent method", () => {
36
- const logger: IAuditLogger = new MockAuditLogger();
37
- expect(typeof logger.logEvent).toBe("function");
38
- });
39
-
40
- it("should accept AuditContext for logAuditRecord", async () => {
41
- const logger = new MockAuditLogger();
42
- const context: AuditContext = {
43
- identity: {
44
- did: "did:key:test",
45
- kid: "key-123",
46
- } as any,
47
- session: {
48
- sessionId: "session-123",
49
- audience: "example.com",
50
- } as any,
51
- requestHash: "sha256:abc",
52
- responseHash: "sha256:def",
53
- verified: "yes",
54
- scopeId: "test:execute",
55
- };
56
-
57
- await logger.logAuditRecord(context);
58
- expect(logger.logAuditRecordCalls).toHaveLength(1);
59
- expect(logger.logAuditRecordCalls[0]).toEqual(context);
60
- });
61
-
62
- it("should accept AuditEventContext for logEvent", async () => {
63
- const logger = new MockAuditLogger();
64
- const context: AuditEventContext = {
65
- eventType: "consent:approved",
66
- identity: {
67
- did: "did:key:test",
68
- kid: "key-123",
69
- } as any,
70
- session: {
71
- sessionId: "session-123",
72
- audience: "example.com",
73
- } as any,
74
- eventData: { tool: "test-tool" },
75
- };
76
-
77
- await logger.logEvent(context);
78
- expect(logger.logEventCalls).toHaveLength(1);
79
- expect(logger.logEventCalls[0]).toEqual(context);
80
- });
81
- });
82
-
83
- describe("Type compatibility checks", () => {
84
- it("should be compatible with implementations that return Promise<void>", async () => {
85
- const logger: IAuditLogger = new MockAuditLogger();
86
- const context: AuditContext = {
87
- identity: { did: "did:key:test", kid: "key-123" } as any,
88
- session: { sessionId: "session-123", audience: "example.com" } as any,
89
- requestHash: "sha256:abc",
90
- responseHash: "sha256:def",
91
- verified: "yes",
92
- };
93
-
94
- const result = await logger.logAuditRecord(context);
95
- expect(result).toBeUndefined(); // Should return void
96
- });
97
-
98
- it("should accept optional scopeId in AuditContext", async () => {
99
- const logger = new MockAuditLogger();
100
- const contextWithoutScope: AuditContext = {
101
- identity: { did: "did:key:test", kid: "key-123" } as any,
102
- session: { sessionId: "session-123", audience: "example.com" } as any,
103
- requestHash: "sha256:abc",
104
- responseHash: "sha256:def",
105
- verified: "yes",
106
- // scopeId is optional
107
- };
108
-
109
- await expect(
110
- logger.logAuditRecord(contextWithoutScope)
111
- ).resolves.not.toThrow();
112
- });
113
-
114
- it("should accept optional eventData in AuditEventContext", async () => {
115
- const logger = new MockAuditLogger();
116
- const contextWithoutData: AuditEventContext = {
117
- eventType: "test:event",
118
- identity: { did: "did:key:test", kid: "key-123" } as any,
119
- session: { sessionId: "session-123", audience: "example.com" } as any,
120
- // eventData is optional
121
- };
122
-
123
- await expect(logger.logEvent(contextWithoutData)).resolves.not.toThrow();
124
- });
125
- });
126
-
127
- describe("Verify both methods are required", () => {
128
- it("should fail type check if logAuditRecord is missing", () => {
129
- // This test documents that TypeScript will catch missing methods
130
- // In practice, this would be a compile-time error
131
- class IncompleteLogger implements Partial<IAuditLogger> {
132
- async logEvent(_context: AuditEventContext): Promise<void> {
133
- // Missing logAuditRecord
134
- }
135
- }
136
-
137
- // TypeScript would error: Property 'logAuditRecord' is missing
138
- // This test verifies the interface contract is enforced
139
- expect(true).toBe(true); // Placeholder - actual check is compile-time
140
- });
141
-
142
- it("should fail type check if logEvent is missing", () => {
143
- // This test documents that TypeScript will catch missing methods
144
- class IncompleteLogger implements Partial<IAuditLogger> {
145
- async logAuditRecord(_context: AuditContext): Promise<void> {
146
- // Missing logEvent
147
- }
148
- }
149
-
150
- // TypeScript would error: Property 'logEvent' is missing
151
- expect(true).toBe(true); // Placeholder - actual check is compile-time
152
- });
153
- });
154
- });