@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.
- package/.turbo/turbo-build.log +1 -1
- package/dist/config.d.ts +5 -7
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +4 -6
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/dist/runtime/audit-logger.d.ts +6 -28
- package/dist/runtime/audit-logger.d.ts.map +1 -1
- package/dist/runtime/audit-logger.js +5 -3
- package/dist/runtime/audit-logger.js.map +1 -1
- package/dist/runtime/audit.d.ts +132 -0
- package/dist/runtime/audit.d.ts.map +1 -0
- package/dist/runtime/audit.js +424 -0
- package/dist/runtime/audit.js.map +1 -0
- package/dist/runtime/base.d.ts +9 -48
- package/dist/runtime/base.d.ts.map +1 -1
- package/dist/runtime/base.js +109 -89
- package/dist/runtime/base.js.map +1 -1
- package/dist/services/oauth-config.service.d.ts.map +1 -1
- package/dist/services/oauth-config.service.js +29 -0
- package/dist/services/oauth-config.service.js.map +1 -1
- package/package.json +7 -3
- package/src/__tests__/config/provider-runtime-config.test.ts +2 -9
- package/src/__tests__/config.test.ts +12 -11
- package/src/__tests__/integration/full-flow.test.ts +0 -5
- package/src/__tests__/integration.test.ts +2 -6
- package/src/__tests__/runtime/audit.test.ts +327 -0
- package/src/__tests__/runtime/base-extensions.test.ts +0 -46
- package/src/__tests__/runtime/base.test.ts +71 -102
- package/src/__tests__/runtime/delegation-flow.test.ts +0 -4
- package/src/__tests__/runtime/process-tool-call-security.test.ts +5 -11
- package/src/__tests__/runtime/proof-client-did.test.ts +0 -4
- package/src/__tests__/runtime/provider-selection.test.ts +0 -2
- package/src/__tests__/runtime/route-interception.test.ts +7 -4
- package/src/__tests__/runtime/tool-protection-enforcement.test.ts +23 -31
- package/src/__tests__/services/tool-protection-merged-config.test.ts +0 -40
- package/src/config/__tests__/merged-config.spec.ts +0 -26
- package/src/config.ts +9 -10
- package/src/index.ts +23 -2
- package/src/runtime/__tests__/audit-logger-compat.test.ts +15 -0
- package/src/runtime/audit-logger.ts +6 -29
- package/src/runtime/audit.ts +598 -0
- package/src/runtime/base.ts +154 -99
- package/src/services/__tests__/oauth-config.service.test.ts +66 -0
- package/src/services/__tests__/proof-verifier.integration.test.ts +1 -1
- package/src/services/__tests__/proof-verifier.test.ts +6 -3
- package/src/services/oauth-config.service.ts +44 -1
- 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
|
-
});
|