@kya-os/mcp-i 0.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/README.md +406 -71
- package/dist/149.js +1 -0
- package/dist/189.js +1 -0
- package/dist/261.js +1 -0
- package/dist/28.js +1 -0
- package/dist/295.js +1 -0
- package/dist/460.js +1 -0
- package/dist/570.js +1 -0
- package/dist/634.js +1 -0
- package/dist/647.js +1 -0
- package/dist/67.js +1 -0
- package/dist/739.js +1 -0
- package/dist/742.js +1 -0
- package/dist/904.js +1 -0
- package/dist/938.js +1 -0
- package/dist/auth/api-key.d.ts +16 -0
- package/dist/auth/api-key.js +82 -0
- package/dist/auth/jwt.d.ts +43 -0
- package/dist/auth/jwt.js +51 -0
- package/dist/auth/oauth/factory.d.ts +12 -0
- package/dist/auth/oauth/factory.js +36 -0
- package/dist/auth/oauth/index.d.ts +5 -0
- package/dist/auth/oauth/index.js +27 -0
- package/dist/auth/oauth/providers/proxy-provider.d.ts +13 -0
- package/dist/auth/oauth/providers/proxy-provider.js +159 -0
- package/dist/auth/oauth/router.d.ts +4 -0
- package/dist/auth/oauth/router.js +294 -0
- package/dist/auth/oauth/storage/memory-storage.d.ts +12 -0
- package/dist/auth/oauth/storage/memory-storage.js +40 -0
- package/dist/auth/oauth/types.d.ts +112 -0
- package/dist/auth/oauth/types.js +2 -0
- package/dist/cache/__tests__/cloudflare-kv-nonce-cache.test.d.ts +4 -0
- package/dist/cache/__tests__/cloudflare-kv-nonce-cache.test.js +176 -0
- package/dist/cache/__tests__/concurrency.test.d.ts +5 -0
- package/dist/cache/__tests__/concurrency.test.js +300 -0
- package/dist/cache/__tests__/dynamodb-nonce-cache.test.d.ts +4 -0
- package/dist/cache/__tests__/dynamodb-nonce-cache.test.js +176 -0
- package/dist/cache/__tests__/memory-nonce-cache.test.d.ts +4 -0
- package/dist/cache/__tests__/memory-nonce-cache.test.js +132 -0
- package/dist/cache/__tests__/nonce-cache-factory-simple.test.d.ts +4 -0
- package/dist/cache/__tests__/nonce-cache-factory-simple.test.js +133 -0
- package/dist/cache/__tests__/nonce-cache-factory.test.d.ts +4 -0
- package/dist/cache/__tests__/nonce-cache-factory.test.js +252 -0
- package/dist/cache/__tests__/redis-nonce-cache.test.d.ts +4 -0
- package/dist/cache/__tests__/redis-nonce-cache.test.js +95 -0
- package/dist/cache/cloudflare-kv-nonce-cache.d.ts +14 -0
- package/dist/cache/cloudflare-kv-nonce-cache.js +93 -0
- package/dist/cache/dynamodb-nonce-cache.d.ts +15 -0
- package/dist/cache/dynamodb-nonce-cache.js +92 -0
- package/dist/cache/index.d.ts +16 -0
- package/dist/cache/index.js +32 -0
- package/dist/cache/memory-nonce-cache.d.ts +44 -0
- package/dist/cache/memory-nonce-cache.js +105 -0
- package/dist/cache/nonce-cache-factory.d.ts +20 -0
- package/dist/cache/nonce-cache-factory.js +208 -0
- package/dist/cache/redis-nonce-cache.d.ts +14 -0
- package/dist/cache/redis-nonce-cache.js +53 -0
- package/dist/compiler/compiler-context.d.ts +23 -0
- package/dist/compiler/compiler-context.js +24 -0
- package/dist/compiler/config/constants.d.ts +41 -0
- package/dist/compiler/config/constants.js +45 -0
- package/dist/compiler/config/index.d.ts +252 -0
- package/dist/compiler/config/index.js +15 -0
- package/dist/compiler/config/injection.d.ts +26 -0
- package/dist/compiler/config/injection.js +58 -0
- package/dist/compiler/config/schemas/experimental/index.d.ts +91 -0
- package/dist/compiler/config/schemas/experimental/index.js +16 -0
- package/dist/compiler/config/schemas/experimental/oauth.d.ts +74 -0
- package/dist/compiler/config/schemas/experimental/oauth.js +25 -0
- package/dist/compiler/config/schemas/index.d.ts +6 -0
- package/dist/compiler/config/schemas/index.js +17 -0
- package/dist/compiler/config/schemas/paths.d.ts +9 -0
- package/dist/compiler/config/schemas/paths.js +12 -0
- package/dist/compiler/config/schemas/transport/http.d.ts +82 -0
- package/dist/compiler/config/schemas/transport/http.js +33 -0
- package/dist/compiler/config/schemas/transport/stdio.d.ts +9 -0
- package/dist/compiler/config/schemas/transport/stdio.js +15 -0
- package/dist/compiler/config/schemas/webpack.d.ts +3 -0
- package/dist/compiler/config/schemas/webpack.js +15 -0
- package/dist/compiler/config/types.d.ts +1 -0
- package/dist/compiler/config/types.js +2 -0
- package/dist/compiler/config/utils.d.ts +20 -0
- package/dist/compiler/config/utils.js +36 -0
- package/dist/compiler/generate-env-code.d.ts +1 -0
- package/dist/compiler/generate-env-code.js +8 -0
- package/dist/compiler/generate-import-code.d.ts +1 -0
- package/dist/compiler/generate-import-code.js +24 -0
- package/dist/compiler/get-webpack-config/get-entries.d.ts +3 -0
- package/dist/compiler/get-webpack-config/get-entries.js +29 -0
- package/dist/compiler/get-webpack-config/get-externals.d.ts +7 -0
- package/dist/compiler/get-webpack-config/get-externals.js +88 -0
- package/dist/compiler/get-webpack-config/get-injected-variables.d.ts +8 -0
- package/dist/compiler/get-webpack-config/get-injected-variables.js +25 -0
- package/dist/compiler/get-webpack-config/index.d.ts +4 -0
- package/dist/compiler/get-webpack-config/index.js +101 -0
- package/dist/compiler/get-webpack-config/plugins.d.ts +8 -0
- package/dist/compiler/get-webpack-config/plugins.js +132 -0
- package/dist/compiler/get-webpack-config/resolve-tsconfig-paths.d.ts +9 -0
- package/dist/compiler/get-webpack-config/resolve-tsconfig-paths.js +40 -0
- package/dist/compiler/index.d.ts +6 -0
- package/dist/compiler/index.js +194 -0
- package/dist/compiler/on-first-build.d.ts +3 -0
- package/dist/compiler/on-first-build.js +58 -0
- package/dist/compiler/parse-xmcp-config.d.ts +9 -0
- package/dist/compiler/parse-xmcp-config.js +155 -0
- package/dist/compiler/start-http-server.d.ts +1 -0
- package/dist/compiler/start-http-server.js +34 -0
- package/dist/index.d.ts +12 -54
- package/dist/index.js +22 -190
- package/dist/index.js.LICENSE.txt +49 -0
- package/dist/runtime/__tests__/audit.test.d.ts +4 -0
- package/dist/runtime/__tests__/audit.test.js +328 -0
- package/dist/runtime/__tests__/identity.test.d.ts +4 -0
- package/dist/runtime/__tests__/identity.test.js +164 -0
- package/dist/runtime/__tests__/mcpi-runtime.test.d.ts +4 -0
- package/dist/runtime/__tests__/mcpi-runtime.test.js +372 -0
- package/dist/runtime/__tests__/proof.test.d.ts +4 -0
- package/dist/runtime/__tests__/proof.test.js +302 -0
- package/dist/runtime/__tests__/session.test.d.ts +4 -0
- package/dist/runtime/__tests__/session.test.js +254 -0
- package/dist/runtime/__tests__/well-known.test.d.ts +4 -0
- package/dist/runtime/__tests__/well-known.test.js +312 -0
- package/dist/runtime/adapter-express.js +2 -0
- package/dist/runtime/adapter-express.js.LICENSE.txt +252 -0
- package/dist/runtime/adapter-nextjs.js +2 -0
- package/dist/runtime/adapter-nextjs.js.LICENSE.txt +53 -0
- package/dist/runtime/adapters/express/index.d.ts +2 -0
- package/dist/runtime/adapters/express/index.js +48 -0
- package/dist/runtime/adapters/nextjs/index.d.ts +8 -0
- package/dist/runtime/adapters/nextjs/index.js +18 -0
- package/dist/runtime/audit.d.ts +93 -0
- package/dist/runtime/audit.js +212 -0
- package/dist/runtime/debug.d.ts +118 -0
- package/dist/runtime/debug.js +612 -0
- package/dist/runtime/delegation-hooks.d.ts +85 -0
- package/dist/runtime/delegation-hooks.js +116 -0
- package/dist/runtime/demo.d.ts +71 -0
- package/dist/runtime/demo.js +135 -0
- package/dist/runtime/headers.d.ts +1 -0
- package/dist/runtime/headers.js +9 -0
- package/dist/runtime/http.js +2 -0
- package/dist/runtime/http.js.LICENSE.txt +252 -0
- package/dist/runtime/identity.d.ts +105 -0
- package/dist/runtime/identity.js +232 -0
- package/dist/runtime/index.d.ts +16 -0
- package/dist/runtime/index.js +56 -0
- package/dist/runtime/mcpi-runtime.d.ts +164 -0
- package/dist/runtime/mcpi-runtime.js +352 -0
- package/dist/runtime/proof.d.ts +87 -0
- package/dist/runtime/proof.js +223 -0
- package/dist/runtime/session.d.ts +88 -0
- package/dist/runtime/session.js +216 -0
- package/dist/runtime/stdio.js +2 -0
- package/dist/runtime/stdio.js.LICENSE.txt +1 -0
- package/dist/runtime/templates/home.d.ts +2 -0
- package/dist/runtime/templates/home.js +50 -0
- package/dist/runtime/transports/http/base-streamable-http.d.ts +25 -0
- package/dist/runtime/transports/http/base-streamable-http.js +16 -0
- package/dist/runtime/transports/http/http-context.d.ts +9 -0
- package/dist/runtime/transports/http/http-context.js +8 -0
- package/dist/runtime/transports/http/index.d.ts +1 -0
- package/dist/runtime/transports/http/index.js +55 -0
- package/dist/runtime/transports/http/setup-cors.d.ts +4 -0
- package/dist/runtime/transports/http/setup-cors.js +24 -0
- package/dist/runtime/transports/http/stateless-streamable-http.d.ts +39 -0
- package/dist/runtime/transports/http/stateless-streamable-http.js +331 -0
- package/dist/runtime/transports/stdio/index.d.ts +1 -0
- package/dist/runtime/transports/stdio/index.js +51 -0
- package/dist/runtime/utils/server.d.ts +42 -0
- package/dist/runtime/utils/server.js +39 -0
- package/dist/runtime/utils/tools.d.ts +8 -0
- package/dist/runtime/utils/tools.js +115 -0
- package/dist/runtime/verifier-middleware.d.ts +76 -0
- package/dist/runtime/verifier-middleware.js +322 -0
- package/dist/runtime/well-known.d.ts +151 -0
- package/dist/runtime/well-known.js +258 -0
- package/dist/storage/config.d.ts +28 -0
- package/dist/storage/config.js +79 -0
- package/dist/storage/delegation.d.ts +59 -0
- package/dist/storage/delegation.js +130 -0
- package/dist/storage/merkle-verifier.d.ts +84 -0
- package/dist/storage/merkle-verifier.js +261 -0
- package/dist/test/__tests__/nonce-cache-integration.test.d.ts +1 -0
- package/dist/test/__tests__/nonce-cache-integration.test.js +116 -0
- package/dist/test/__tests__/nonce-cache.test.d.ts +1 -0
- package/dist/test/__tests__/nonce-cache.test.js +122 -0
- package/dist/test/__tests__/runtime-integration.test.d.ts +4 -0
- package/dist/test/__tests__/runtime-integration.test.js +192 -0
- package/dist/test/__tests__/test-infrastructure.test.d.ts +4 -0
- package/dist/test/__tests__/test-infrastructure.test.js +178 -0
- package/dist/test/deterministic-keys.d.ts +31 -0
- package/dist/test/deterministic-keys.js +108 -0
- package/dist/test/examples/test-usage-example.d.ts +140 -0
- package/dist/test/examples/test-usage-example.js +175 -0
- package/dist/test/index.d.ts +11 -0
- package/dist/test/index.js +27 -0
- package/dist/test/local-verification.d.ts +28 -0
- package/dist/test/local-verification.js +342 -0
- package/dist/test/mock-identity-provider.d.ts +96 -0
- package/dist/test/mock-identity-provider.js +243 -0
- package/dist/test/runtime-integration.d.ts +63 -0
- package/dist/test/runtime-integration.js +140 -0
- package/dist/test/test-environment.d.ts +26 -0
- package/dist/test/test-environment.js +50 -0
- package/dist/types/declarations.d.ts +1 -0
- package/dist/types/declarations.js +6 -0
- package/dist/types/middleware.d.ts +2 -0
- package/dist/types/middleware.js +2 -0
- package/dist/types/tool.d.ts +80 -0
- package/dist/types/tool.js +2 -0
- package/dist/utils/cli-icons.d.ts +3 -0
- package/dist/utils/cli-icons.js +7 -0
- package/dist/utils/constants.d.ts +6 -0
- package/dist/utils/constants.js +13 -0
- package/dist/utils/context.d.ts +33 -0
- package/dist/utils/context.js +58 -0
- package/dist/utils/file-watcher.d.ts +19 -0
- package/dist/utils/file-watcher.js +49 -0
- package/dist/utils/fs-utils.d.ts +2 -0
- package/dist/utils/fs-utils.js +22 -0
- package/dist/utils/path-validation.d.ts +3 -0
- package/dist/utils/path-validation.js +56 -0
- package/dist/utils/spawn-process.d.ts +9 -0
- package/dist/utils/spawn-process.js +50 -0
- package/dist/utils/subscribable.d.ts +12 -0
- package/dist/utils/subscribable.js +44 -0
- package/package.json +99 -21
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example usage of XMCP-I test infrastructure
|
|
3
|
+
*
|
|
4
|
+
* This file demonstrates how to use the test infrastructure for testing
|
|
5
|
+
* XMCP-I applications without hitting external services.
|
|
6
|
+
*/
|
|
7
|
+
import { MockIdentityProvider } from "../index.js";
|
|
8
|
+
/**
|
|
9
|
+
* Example: Setting up test environment
|
|
10
|
+
*/
|
|
11
|
+
export declare function setupTestEnvironment(): void;
|
|
12
|
+
/**
|
|
13
|
+
* Example: Using mock identity provider
|
|
14
|
+
*/
|
|
15
|
+
export declare function exampleMockIdentityProvider(): MockIdentityProvider;
|
|
16
|
+
/**
|
|
17
|
+
* Example: Testing proof generation and verification
|
|
18
|
+
*/
|
|
19
|
+
export declare function exampleProofTesting(): Promise<{
|
|
20
|
+
valid: boolean;
|
|
21
|
+
warnings: string[];
|
|
22
|
+
session: {
|
|
23
|
+
valid: boolean;
|
|
24
|
+
expired: boolean;
|
|
25
|
+
error?: string | undefined;
|
|
26
|
+
};
|
|
27
|
+
signature: {
|
|
28
|
+
valid: boolean;
|
|
29
|
+
algorithm: string;
|
|
30
|
+
error?: string | undefined;
|
|
31
|
+
};
|
|
32
|
+
proof: {
|
|
33
|
+
valid: boolean;
|
|
34
|
+
structure: boolean;
|
|
35
|
+
timestamps: boolean;
|
|
36
|
+
hashes: boolean;
|
|
37
|
+
error?: string | undefined;
|
|
38
|
+
};
|
|
39
|
+
errors: string[];
|
|
40
|
+
did?: string | undefined;
|
|
41
|
+
keyId?: string | undefined;
|
|
42
|
+
}>;
|
|
43
|
+
/**
|
|
44
|
+
* Example: Intercepting KTA calls
|
|
45
|
+
*/
|
|
46
|
+
export declare function exampleKTAInterception(): Promise<{
|
|
47
|
+
registrationResult: {
|
|
48
|
+
success: boolean;
|
|
49
|
+
agentURL: string;
|
|
50
|
+
agentId: string;
|
|
51
|
+
agentSlug: string;
|
|
52
|
+
verificationEndpoint: string;
|
|
53
|
+
conformanceCapabilities: string[];
|
|
54
|
+
mirrorStatus: string;
|
|
55
|
+
};
|
|
56
|
+
delegationResult: never;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Example: Using test runtime integration
|
|
60
|
+
*/
|
|
61
|
+
export declare function exampleRuntimeIntegration(): {
|
|
62
|
+
testIdentity: {
|
|
63
|
+
did: string;
|
|
64
|
+
keyId: string;
|
|
65
|
+
privateKey: string;
|
|
66
|
+
publicKey: string;
|
|
67
|
+
createdAt: string;
|
|
68
|
+
lastRotated: string;
|
|
69
|
+
};
|
|
70
|
+
sessionContext: {
|
|
71
|
+
sessionId: string;
|
|
72
|
+
audience: string;
|
|
73
|
+
nonce: string;
|
|
74
|
+
timestamp: number;
|
|
75
|
+
createdAt: number;
|
|
76
|
+
lastActivity: number;
|
|
77
|
+
ttlMinutes: number;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Example: Complete test scenario
|
|
82
|
+
*/
|
|
83
|
+
export declare function exampleCompleteTestScenario(): Promise<{
|
|
84
|
+
mockProvider: MockIdentityProvider;
|
|
85
|
+
proofResult: {
|
|
86
|
+
valid: boolean;
|
|
87
|
+
warnings: string[];
|
|
88
|
+
session: {
|
|
89
|
+
valid: boolean;
|
|
90
|
+
expired: boolean;
|
|
91
|
+
error?: string | undefined;
|
|
92
|
+
};
|
|
93
|
+
signature: {
|
|
94
|
+
valid: boolean;
|
|
95
|
+
algorithm: string;
|
|
96
|
+
error?: string | undefined;
|
|
97
|
+
};
|
|
98
|
+
proof: {
|
|
99
|
+
valid: boolean;
|
|
100
|
+
structure: boolean;
|
|
101
|
+
timestamps: boolean;
|
|
102
|
+
hashes: boolean;
|
|
103
|
+
error?: string | undefined;
|
|
104
|
+
};
|
|
105
|
+
errors: string[];
|
|
106
|
+
did?: string | undefined;
|
|
107
|
+
keyId?: string | undefined;
|
|
108
|
+
};
|
|
109
|
+
ktaResults: {
|
|
110
|
+
registrationResult: {
|
|
111
|
+
success: boolean;
|
|
112
|
+
agentURL: string;
|
|
113
|
+
agentId: string;
|
|
114
|
+
agentSlug: string;
|
|
115
|
+
verificationEndpoint: string;
|
|
116
|
+
conformanceCapabilities: string[];
|
|
117
|
+
mirrorStatus: string;
|
|
118
|
+
};
|
|
119
|
+
delegationResult: never;
|
|
120
|
+
};
|
|
121
|
+
runtimeResults: {
|
|
122
|
+
testIdentity: {
|
|
123
|
+
did: string;
|
|
124
|
+
keyId: string;
|
|
125
|
+
privateKey: string;
|
|
126
|
+
publicKey: string;
|
|
127
|
+
createdAt: string;
|
|
128
|
+
lastRotated: string;
|
|
129
|
+
};
|
|
130
|
+
sessionContext: {
|
|
131
|
+
sessionId: string;
|
|
132
|
+
audience: string;
|
|
133
|
+
nonce: string;
|
|
134
|
+
timestamp: number;
|
|
135
|
+
createdAt: number;
|
|
136
|
+
lastActivity: number;
|
|
137
|
+
ttlMinutes: number;
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
}>;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Example usage of XMCP-I test infrastructure
|
|
4
|
+
*
|
|
5
|
+
* This file demonstrates how to use the test infrastructure for testing
|
|
6
|
+
* XMCP-I applications without hitting external services.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.setupTestEnvironment = setupTestEnvironment;
|
|
10
|
+
exports.exampleMockIdentityProvider = exampleMockIdentityProvider;
|
|
11
|
+
exports.exampleProofTesting = exampleProofTesting;
|
|
12
|
+
exports.exampleKTAInterception = exampleKTAInterception;
|
|
13
|
+
exports.exampleRuntimeIntegration = exampleRuntimeIntegration;
|
|
14
|
+
exports.exampleCompleteTestScenario = exampleCompleteTestScenario;
|
|
15
|
+
const index_js_1 = require("../index.js");
|
|
16
|
+
const test_1 = require("@kya-os/contracts/test");
|
|
17
|
+
/**
|
|
18
|
+
* Example: Setting up test environment
|
|
19
|
+
*/
|
|
20
|
+
function setupTestEnvironment() {
|
|
21
|
+
// Configure test environment with custom seed
|
|
22
|
+
(0, index_js_1.configureTestEnvironment)({
|
|
23
|
+
seed: "my-test-suite",
|
|
24
|
+
skipKTACalls: true,
|
|
25
|
+
});
|
|
26
|
+
// Verify we're in test mode
|
|
27
|
+
console.log("Test mode:", (0, index_js_1.isTestMode)());
|
|
28
|
+
// Validate test environment
|
|
29
|
+
const validation = (0, index_js_1.validateTestEnvironment)();
|
|
30
|
+
if (!validation.valid) {
|
|
31
|
+
throw new Error(`Test environment validation failed: ${validation.errors.join(", ")}`);
|
|
32
|
+
}
|
|
33
|
+
if (validation.warnings.length > 0) {
|
|
34
|
+
console.warn("Test environment warnings:", validation.warnings);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Example: Using mock identity provider
|
|
39
|
+
*/
|
|
40
|
+
function exampleMockIdentityProvider() {
|
|
41
|
+
const mockProvider = new index_js_1.MockIdentityProvider();
|
|
42
|
+
// Generate a custom test identity
|
|
43
|
+
const customIdentity = (0, index_js_1.generateTestIdentity)("my-custom-test", {
|
|
44
|
+
did: "did:test:my-custom-agent",
|
|
45
|
+
keyId: "key-custom-1",
|
|
46
|
+
});
|
|
47
|
+
// Set the identity in the provider
|
|
48
|
+
mockProvider.setIdentity("custom", customIdentity);
|
|
49
|
+
// Set delegation status
|
|
50
|
+
mockProvider.setDelegation(`${customIdentity.did}:${customIdentity.keyId}`, "active");
|
|
51
|
+
// Simulate KTA failures for testing error scenarios
|
|
52
|
+
mockProvider.simulateKTAFailure("network");
|
|
53
|
+
return mockProvider;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Example: Testing proof generation and verification
|
|
57
|
+
*/
|
|
58
|
+
async function exampleProofTesting() {
|
|
59
|
+
// Create mock request and response data
|
|
60
|
+
const mockRequest = {
|
|
61
|
+
method: "tools/call",
|
|
62
|
+
params: {
|
|
63
|
+
name: "greet",
|
|
64
|
+
arguments: { name: "Alice" },
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
const mockResponse = {
|
|
68
|
+
content: [
|
|
69
|
+
{
|
|
70
|
+
type: "text",
|
|
71
|
+
text: "Hello, Alice!",
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
};
|
|
75
|
+
// Create a mock proof
|
|
76
|
+
const mockProof = (0, index_js_1.createMockProof)({
|
|
77
|
+
did: test_1.TEST_DIDS.AGENT_1,
|
|
78
|
+
keyId: test_1.TEST_KEY_IDS.KEY_TEST_1,
|
|
79
|
+
request: mockRequest,
|
|
80
|
+
response: mockResponse,
|
|
81
|
+
sessionId: "sess_test_example",
|
|
82
|
+
nonce: "example_nonce",
|
|
83
|
+
audience: "example.com",
|
|
84
|
+
});
|
|
85
|
+
// Verify the proof locally
|
|
86
|
+
const verificationResult = await (0, index_js_1.verifyProofLocally)(mockProof, mockRequest, mockResponse);
|
|
87
|
+
console.log("Proof verification result:", {
|
|
88
|
+
valid: verificationResult.valid,
|
|
89
|
+
did: verificationResult.did,
|
|
90
|
+
keyId: verificationResult.keyId,
|
|
91
|
+
signatureValid: verificationResult.signature.valid,
|
|
92
|
+
proofValid: verificationResult.proof.valid,
|
|
93
|
+
sessionValid: verificationResult.session.valid,
|
|
94
|
+
errors: verificationResult.errors,
|
|
95
|
+
warnings: verificationResult.warnings,
|
|
96
|
+
});
|
|
97
|
+
return verificationResult;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Example: Intercepting KTA calls
|
|
101
|
+
*/
|
|
102
|
+
async function exampleKTAInterception() {
|
|
103
|
+
// Mock a KTA registration call
|
|
104
|
+
const registrationResult = await (0, index_js_1.interceptKTACall)("register", async () => {
|
|
105
|
+
// This would normally make a real KTA call
|
|
106
|
+
throw new Error("Should not reach here in test mode");
|
|
107
|
+
}, async () => {
|
|
108
|
+
// Custom mock response
|
|
109
|
+
return {
|
|
110
|
+
success: true,
|
|
111
|
+
agentURL: "https://custom-test-kta.example.com/agents/my-agent",
|
|
112
|
+
agentId: "my-agent",
|
|
113
|
+
agentSlug: "my-agent",
|
|
114
|
+
verificationEndpoint: "https://custom-test-kta.example.com/verify/my-agent",
|
|
115
|
+
conformanceCapabilities: ["handshake", "signing", "verification"],
|
|
116
|
+
mirrorStatus: "pending",
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
console.log("Mock registration result:", registrationResult);
|
|
120
|
+
// Mock a delegation check
|
|
121
|
+
const delegationResult = await (0, index_js_1.interceptKTACall)("checkDelegation", async () => {
|
|
122
|
+
throw new Error("Should not reach here in test mode");
|
|
123
|
+
});
|
|
124
|
+
console.log("Mock delegation result:", delegationResult);
|
|
125
|
+
return { registrationResult, delegationResult };
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Example: Using test runtime integration
|
|
129
|
+
*/
|
|
130
|
+
function exampleRuntimeIntegration() {
|
|
131
|
+
// Get test identity for runtime use
|
|
132
|
+
const testIdentity = (0, index_js_1.getTestIdentityForRuntime)("agent1");
|
|
133
|
+
console.log("Test identity for runtime:", {
|
|
134
|
+
did: testIdentity.did,
|
|
135
|
+
keyId: testIdentity.keyId,
|
|
136
|
+
// Don't log private key in real usage
|
|
137
|
+
});
|
|
138
|
+
// Create test session context
|
|
139
|
+
const sessionContext = (0, index_js_1.createTestSessionContext)({
|
|
140
|
+
sessionId: "sess_example_123",
|
|
141
|
+
audience: "my-app.example.com",
|
|
142
|
+
nonce: "example_nonce_456",
|
|
143
|
+
});
|
|
144
|
+
console.log("Test session context:", sessionContext);
|
|
145
|
+
return { testIdentity, sessionContext };
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Example: Complete test scenario
|
|
149
|
+
*/
|
|
150
|
+
async function exampleCompleteTestScenario() {
|
|
151
|
+
console.log("=== XMCP-I Test Infrastructure Example ===");
|
|
152
|
+
// 1. Setup test environment
|
|
153
|
+
console.log("\n1. Setting up test environment...");
|
|
154
|
+
setupTestEnvironment();
|
|
155
|
+
// 2. Configure mock identity provider
|
|
156
|
+
console.log("\n2. Configuring mock identity provider...");
|
|
157
|
+
const mockProvider = exampleMockIdentityProvider();
|
|
158
|
+
// 3. Test proof generation and verification
|
|
159
|
+
console.log("\n3. Testing proof generation and verification...");
|
|
160
|
+
const proofResult = await exampleProofTesting();
|
|
161
|
+
// 4. Test KTA call interception
|
|
162
|
+
console.log("\n4. Testing KTA call interception...");
|
|
163
|
+
const ktaResults = await exampleKTAInterception();
|
|
164
|
+
// 5. Test runtime integration
|
|
165
|
+
console.log("\n5. Testing runtime integration...");
|
|
166
|
+
const runtimeResults = exampleRuntimeIntegration();
|
|
167
|
+
console.log("\n=== Test Infrastructure Example Complete ===");
|
|
168
|
+
return {
|
|
169
|
+
mockProvider,
|
|
170
|
+
proofResult,
|
|
171
|
+
ktaResults,
|
|
172
|
+
runtimeResults,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
// Functions are already exported above
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test infrastructure for XMCP-I
|
|
3
|
+
*
|
|
4
|
+
* This module provides test utilities for developing and testing XMCP-I applications
|
|
5
|
+
* without hitting external services like KTA.
|
|
6
|
+
*/
|
|
7
|
+
export * from "./mock-identity-provider";
|
|
8
|
+
export * from "./deterministic-keys";
|
|
9
|
+
export * from "./local-verification";
|
|
10
|
+
export * from "./test-environment";
|
|
11
|
+
export * from "./runtime-integration";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Test infrastructure for XMCP-I
|
|
4
|
+
*
|
|
5
|
+
* This module provides test utilities for developing and testing XMCP-I applications
|
|
6
|
+
* without hitting external services like KTA.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
__exportStar(require("./mock-identity-provider"), exports);
|
|
24
|
+
__exportStar(require("./deterministic-keys"), exports);
|
|
25
|
+
__exportStar(require("./local-verification"), exports);
|
|
26
|
+
__exportStar(require("./test-environment"), exports);
|
|
27
|
+
__exportStar(require("./runtime-integration"), exports);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local verification utilities for offline testing
|
|
3
|
+
*/
|
|
4
|
+
import { type LocalVerificationResult } from "@kya-os/contracts/test";
|
|
5
|
+
/**
|
|
6
|
+
* Perform local verification of a proof without KTA calls
|
|
7
|
+
*/
|
|
8
|
+
export declare function verifyProofLocally(proof: any, request?: any, response?: any): Promise<LocalVerificationResult>;
|
|
9
|
+
/**
|
|
10
|
+
* Verify DID document locally (mock implementation)
|
|
11
|
+
*/
|
|
12
|
+
export declare function verifyDIDDocumentLocally(did: string): Promise<{
|
|
13
|
+
valid: boolean;
|
|
14
|
+
document?: any;
|
|
15
|
+
error?: string;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Create a mock proof for testing
|
|
19
|
+
*/
|
|
20
|
+
export declare function createMockProof(options: {
|
|
21
|
+
did?: string;
|
|
22
|
+
keyId?: string;
|
|
23
|
+
request?: any;
|
|
24
|
+
response?: any;
|
|
25
|
+
sessionId?: string;
|
|
26
|
+
nonce?: string;
|
|
27
|
+
audience?: string;
|
|
28
|
+
}): any;
|