@kya-os/mcp-i 0.1.0-alpha.3.9 → 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 +350 -213
- 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/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 -0
- package/dist/index.js +38 -0
- 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.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 +91 -77
- package/dist/cjs/auto.js +0 -16
- package/dist/cjs/cli-mode.d.ts +0 -16
- package/dist/cjs/cli-mode.js +0 -32
- package/dist/cjs/crypto.d.ts +0 -16
- package/dist/cjs/crypto.js +0 -212
- package/dist/cjs/dev-helper.d.ts +0 -3
- package/dist/cjs/dev-helper.js +0 -46
- package/dist/cjs/encrypted-storage.d.ts +0 -11
- package/dist/cjs/encrypted-storage.js +0 -73
- package/dist/cjs/index.d.ts +0 -56
- package/dist/cjs/index.js +0 -727
- package/dist/cjs/logger.d.ts +0 -32
- package/dist/cjs/logger.js +0 -85
- package/dist/cjs/nextjs.d.ts +0 -10
- package/dist/cjs/nextjs.js +0 -83
- package/dist/cjs/platform-info.d.ts +0 -36
- package/dist/cjs/platform-info.js +0 -274
- package/dist/cjs/polling.d.ts +0 -13
- package/dist/cjs/polling.js +0 -52
- package/dist/cjs/registry/index.d.ts +0 -12
- package/dist/cjs/registry/index.js +0 -56
- package/dist/cjs/registry/knowthat.d.ts +0 -17
- package/dist/cjs/registry/knowthat.js +0 -173
- package/dist/cjs/rotation.d.ts +0 -35
- package/dist/cjs/rotation.js +0 -102
- package/dist/cjs/storage.d.ts +0 -41
- package/dist/cjs/storage.js +0 -163
- package/dist/cjs/transport.d.ts +0 -35
- package/dist/cjs/transport.js +0 -300
- package/dist/cjs/types.d.ts +0 -206
- package/dist/cjs/vercel-adapter.d.ts +0 -8
- package/dist/cjs/vercel-adapter.js +0 -67
- package/dist/esm/auto.d.ts +0 -13
- package/dist/esm/auto.d.ts.map +0 -1
- package/dist/esm/auto.js +0 -30
- package/dist/esm/auto.js.map +0 -1
- package/dist/esm/cli-mode.d.ts +0 -52
- package/dist/esm/cli-mode.d.ts.map +0 -1
- package/dist/esm/cli-mode.js +0 -59
- package/dist/esm/cli-mode.js.map +0 -1
- package/dist/esm/crypto.d.ts +0 -51
- package/dist/esm/crypto.d.ts.map +0 -1
- package/dist/esm/crypto.js +0 -230
- package/dist/esm/crypto.js.map +0 -1
- package/dist/esm/dev-helper.d.ts +0 -15
- package/dist/esm/dev-helper.d.ts.map +0 -1
- package/dist/esm/dev-helper.js +0 -63
- package/dist/esm/dev-helper.js.map +0 -1
- package/dist/esm/encrypted-storage.d.ts +0 -19
- package/dist/esm/encrypted-storage.d.ts.map +0 -1
- package/dist/esm/encrypted-storage.js +0 -48
- package/dist/esm/encrypted-storage.js.map +0 -1
- package/dist/esm/index.d.ts +0 -129
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js +0 -853
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/logger.d.ts +0 -46
- package/dist/esm/logger.d.ts.map +0 -1
- package/dist/esm/logger.js +0 -100
- package/dist/esm/logger.js.map +0 -1
- package/dist/esm/nextjs.d.ts +0 -22
- package/dist/esm/nextjs.d.ts.map +0 -1
- package/dist/esm/nextjs.js +0 -83
- package/dist/esm/nextjs.js.map +0 -1
- package/dist/esm/package.json +0 -1
- package/dist/esm/platform-info.d.ts +0 -74
- package/dist/esm/platform-info.d.ts.map +0 -1
- package/dist/esm/platform-info.js +0 -293
- package/dist/esm/platform-info.js.map +0 -1
- package/dist/esm/polling.d.ts +0 -29
- package/dist/esm/polling.d.ts.map +0 -1
- package/dist/esm/polling.js +0 -76
- package/dist/esm/polling.js.map +0 -1
- package/dist/esm/registry/index.d.ts +0 -43
- package/dist/esm/registry/index.d.ts.map +0 -1
- package/dist/esm/registry/index.js +0 -89
- package/dist/esm/registry/index.js.map +0 -1
- package/dist/esm/registry/knowthat.d.ts +0 -44
- package/dist/esm/registry/knowthat.d.ts.map +0 -1
- package/dist/esm/registry/knowthat.js +0 -220
- package/dist/esm/registry/knowthat.js.map +0 -1
- package/dist/esm/rotation.d.ts +0 -57
- package/dist/esm/rotation.d.ts.map +0 -1
- package/dist/esm/rotation.js +0 -133
- package/dist/esm/rotation.js.map +0 -1
- package/dist/esm/storage.d.ts +0 -65
- package/dist/esm/storage.d.ts.map +0 -1
- package/dist/esm/storage.js +0 -160
- package/dist/esm/storage.js.map +0 -1
- package/dist/esm/transport.d.ts +0 -52
- package/dist/esm/transport.d.ts.map +0 -1
- package/dist/esm/transport.js +0 -340
- package/dist/esm/transport.js.map +0 -1
- package/dist/esm/types.d.ts +0 -293
- package/dist/esm/types.d.ts.map +0 -1
- package/dist/esm/types.js +0 -5
- package/dist/esm/types.js.map +0 -1
- package/dist/esm/vercel-adapter.d.ts +0 -26
- package/dist/esm/vercel-adapter.d.ts.map +0 -1
- package/dist/esm/vercel-adapter.js +0 -80
- package/dist/esm/vercel-adapter.js.map +0 -1
- /package/dist/{cjs → auth/oauth}/types.js +0 -0
- /package/dist/{cjs/auto.d.ts → runtime/transports/http/index.d.ts} +0 -0
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Tests for Well-Known Endpoints
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const vitest_1 = require("vitest");
|
|
7
|
+
const well_known_js_1 = require("../well-known.js");
|
|
8
|
+
(0, vitest_1.describe)("WellKnownManager", () => {
|
|
9
|
+
let wellKnownManager;
|
|
10
|
+
let mockIdentity;
|
|
11
|
+
let mockConfig;
|
|
12
|
+
(0, vitest_1.beforeEach)(() => {
|
|
13
|
+
mockIdentity = {
|
|
14
|
+
did: "did:web:example.com:agents:test-agent",
|
|
15
|
+
keyId: "key-test-123",
|
|
16
|
+
privateKey: "test-private-key",
|
|
17
|
+
publicKey: Buffer.from("test-public-key-32-bytes-long!!!").toString("base64"),
|
|
18
|
+
createdAt: new Date().toISOString(),
|
|
19
|
+
};
|
|
20
|
+
mockConfig = {
|
|
21
|
+
environment: "development",
|
|
22
|
+
baseUrl: "https://example.com",
|
|
23
|
+
agentMetadata: {
|
|
24
|
+
name: "Test Agent",
|
|
25
|
+
description: "A test XMCP-I agent",
|
|
26
|
+
version: "1.0.0",
|
|
27
|
+
},
|
|
28
|
+
registryUrls: {
|
|
29
|
+
kta: "https://knowthat.ai/agents/test-agent",
|
|
30
|
+
mcp: "https://registry.mcp.dev/agents/test-agent",
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
wellKnownManager = new well_known_js_1.WellKnownManager(mockIdentity, mockConfig);
|
|
34
|
+
});
|
|
35
|
+
(0, vitest_1.describe)("DID Document Generation", () => {
|
|
36
|
+
(0, vitest_1.it)("should generate valid DID document", () => {
|
|
37
|
+
const didDocument = wellKnownManager.generateDIDDocument();
|
|
38
|
+
(0, vitest_1.expect)(didDocument["@context"]).toContain("https://www.w3.org/ns/did/v1");
|
|
39
|
+
(0, vitest_1.expect)(didDocument.id).toBe(mockIdentity.did);
|
|
40
|
+
(0, vitest_1.expect)(didDocument.verificationMethod).toHaveLength(1);
|
|
41
|
+
(0, vitest_1.expect)(didDocument.verificationMethod[0].id).toBe("#key-test-123");
|
|
42
|
+
(0, vitest_1.expect)(didDocument.verificationMethod[0].type).toBe("Ed25519VerificationKey2020");
|
|
43
|
+
(0, vitest_1.expect)(didDocument.verificationMethod[0].controller).toBe(mockIdentity.did);
|
|
44
|
+
(0, vitest_1.expect)(didDocument.verificationMethod[0].publicKeyMultibase).toMatch(/^z/);
|
|
45
|
+
(0, vitest_1.expect)(didDocument.authentication).toEqual(["#key-test-123"]);
|
|
46
|
+
(0, vitest_1.expect)(didDocument.assertionMethod).toEqual(["#key-test-123"]);
|
|
47
|
+
});
|
|
48
|
+
(0, vitest_1.it)("should include proper verification method structure", () => {
|
|
49
|
+
const didDocument = wellKnownManager.generateDIDDocument();
|
|
50
|
+
const verificationMethod = didDocument.verificationMethod[0];
|
|
51
|
+
(0, vitest_1.expect)(verificationMethod.id).toBe(`#${mockIdentity.keyId}`);
|
|
52
|
+
(0, vitest_1.expect)(verificationMethod.type).toBe("Ed25519VerificationKey2020");
|
|
53
|
+
(0, vitest_1.expect)(verificationMethod.controller).toBe(mockIdentity.did);
|
|
54
|
+
(0, vitest_1.expect)(verificationMethod.publicKeyMultibase).toBeTruthy();
|
|
55
|
+
});
|
|
56
|
+
(0, vitest_1.it)("should encode public key as multibase", () => {
|
|
57
|
+
const didDocument = wellKnownManager.generateDIDDocument();
|
|
58
|
+
const publicKeyMultibase = didDocument.verificationMethod[0].publicKeyMultibase;
|
|
59
|
+
(0, vitest_1.expect)(publicKeyMultibase).toMatch(/^z[1-9A-HJ-NP-Za-km-z]+$/); // Base58btc format
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
(0, vitest_1.describe)("Agent Document Generation", () => {
|
|
63
|
+
(0, vitest_1.it)("should generate valid agent document", () => {
|
|
64
|
+
const agentDocument = wellKnownManager.generateAgentDocument();
|
|
65
|
+
(0, vitest_1.expect)(agentDocument.id).toBe(mockIdentity.did);
|
|
66
|
+
(0, vitest_1.expect)(agentDocument.capabilities["mcp-i"]).toEqual([
|
|
67
|
+
"handshake",
|
|
68
|
+
"signing",
|
|
69
|
+
"verification",
|
|
70
|
+
]);
|
|
71
|
+
(0, vitest_1.expect)(agentDocument.registry?.kta).toBe("https://knowthat.ai/agents/test-agent");
|
|
72
|
+
(0, vitest_1.expect)(agentDocument.registry?.mcp).toBe("https://registry.mcp.dev/agents/test-agent");
|
|
73
|
+
(0, vitest_1.expect)(agentDocument.metadata?.name).toBe("Test Agent");
|
|
74
|
+
(0, vitest_1.expect)(agentDocument.metadata?.description).toBe("A test XMCP-I agent");
|
|
75
|
+
(0, vitest_1.expect)(agentDocument.metadata?.version).toBe("1.0.0");
|
|
76
|
+
});
|
|
77
|
+
(0, vitest_1.it)("should include exact MCP-I capability triplet", () => {
|
|
78
|
+
const agentDocument = wellKnownManager.generateAgentDocument();
|
|
79
|
+
const capabilities = agentDocument.capabilities["mcp-i"];
|
|
80
|
+
(0, vitest_1.expect)(capabilities).toHaveLength(3);
|
|
81
|
+
(0, vitest_1.expect)(capabilities).toContain("handshake");
|
|
82
|
+
(0, vitest_1.expect)(capabilities).toContain("signing");
|
|
83
|
+
(0, vitest_1.expect)(capabilities).toContain("verification");
|
|
84
|
+
(0, vitest_1.expect)(capabilities).toEqual(["handshake", "signing", "verification"]);
|
|
85
|
+
});
|
|
86
|
+
(0, vitest_1.it)("should work without optional metadata", () => {
|
|
87
|
+
const minimalConfig = {
|
|
88
|
+
environment: "development",
|
|
89
|
+
};
|
|
90
|
+
const minimalManager = new well_known_js_1.WellKnownManager(mockIdentity, minimalConfig);
|
|
91
|
+
const agentDocument = minimalManager.generateAgentDocument();
|
|
92
|
+
(0, vitest_1.expect)(agentDocument.id).toBe(mockIdentity.did);
|
|
93
|
+
(0, vitest_1.expect)(agentDocument.capabilities["mcp-i"]).toEqual([
|
|
94
|
+
"handshake",
|
|
95
|
+
"signing",
|
|
96
|
+
"verification",
|
|
97
|
+
]);
|
|
98
|
+
(0, vitest_1.expect)(agentDocument.registry).toBeUndefined();
|
|
99
|
+
(0, vitest_1.expect)(agentDocument.metadata).toBeUndefined();
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
(0, vitest_1.describe)("HTTP Headers", () => {
|
|
103
|
+
(0, vitest_1.it)("should return correct headers for DID document in development", () => {
|
|
104
|
+
const headers = wellKnownManager.getDIDDocumentHeaders();
|
|
105
|
+
(0, vitest_1.expect)(headers["Content-Type"]).toBe("application/did+json");
|
|
106
|
+
(0, vitest_1.expect)(headers["Cache-Control"]).toBe("no-store");
|
|
107
|
+
});
|
|
108
|
+
(0, vitest_1.it)("should return correct headers for DID document in production", () => {
|
|
109
|
+
const prodConfig = { ...mockConfig, environment: "production" };
|
|
110
|
+
const prodManager = new well_known_js_1.WellKnownManager(mockIdentity, prodConfig);
|
|
111
|
+
const headers = prodManager.getDIDDocumentHeaders();
|
|
112
|
+
(0, vitest_1.expect)(headers["Content-Type"]).toBe("application/did+json");
|
|
113
|
+
(0, vitest_1.expect)(headers["Cache-Control"]).toBe("public, max-age=300");
|
|
114
|
+
});
|
|
115
|
+
(0, vitest_1.it)("should return correct headers for agent document in development", () => {
|
|
116
|
+
const headers = wellKnownManager.getAgentDocumentHeaders();
|
|
117
|
+
(0, vitest_1.expect)(headers["Content-Type"]).toBe("application/json");
|
|
118
|
+
(0, vitest_1.expect)(headers["Cache-Control"]).toBe("no-store");
|
|
119
|
+
});
|
|
120
|
+
(0, vitest_1.it)("should return correct headers for agent document in production", () => {
|
|
121
|
+
const prodConfig = { ...mockConfig, environment: "production" };
|
|
122
|
+
const prodManager = new well_known_js_1.WellKnownManager(mockIdentity, prodConfig);
|
|
123
|
+
const headers = prodManager.getAgentDocumentHeaders();
|
|
124
|
+
(0, vitest_1.expect)(headers["Content-Type"]).toBe("application/json");
|
|
125
|
+
(0, vitest_1.expect)(headers["Cache-Control"]).toBe("public, max-age=300");
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
(0, vitest_1.describe)("Configuration Management", () => {
|
|
129
|
+
(0, vitest_1.it)("should update configuration", () => {
|
|
130
|
+
const newConfig = {
|
|
131
|
+
environment: "production",
|
|
132
|
+
agentMetadata: {
|
|
133
|
+
name: "Updated Agent",
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
wellKnownManager.updateConfig(newConfig);
|
|
137
|
+
const config = wellKnownManager.getConfig();
|
|
138
|
+
(0, vitest_1.expect)(config.environment).toBe("production");
|
|
139
|
+
(0, vitest_1.expect)(config.agentMetadata?.name).toBe("Updated Agent");
|
|
140
|
+
(0, vitest_1.expect)(config.baseUrl).toBe("https://example.com"); // Should preserve existing values
|
|
141
|
+
});
|
|
142
|
+
(0, vitest_1.it)("should return current configuration", () => {
|
|
143
|
+
const config = wellKnownManager.getConfig();
|
|
144
|
+
(0, vitest_1.expect)(config.environment).toBe("development");
|
|
145
|
+
(0, vitest_1.expect)(config.baseUrl).toBe("https://example.com");
|
|
146
|
+
(0, vitest_1.expect)(config.agentMetadata?.name).toBe("Test Agent");
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
(0, vitest_1.describe)("Well-Known Handler", () => {
|
|
151
|
+
let handler;
|
|
152
|
+
let mockIdentity;
|
|
153
|
+
let mockConfig;
|
|
154
|
+
(0, vitest_1.beforeEach)(() => {
|
|
155
|
+
mockIdentity = {
|
|
156
|
+
did: "did:web:example.com:agents:test-agent",
|
|
157
|
+
keyId: "key-test-123",
|
|
158
|
+
privateKey: "test-private-key",
|
|
159
|
+
publicKey: Buffer.from("test-public-key-32-bytes-long!!!").toString("base64"),
|
|
160
|
+
createdAt: new Date().toISOString(),
|
|
161
|
+
};
|
|
162
|
+
mockConfig = {
|
|
163
|
+
environment: "development",
|
|
164
|
+
baseUrl: "https://example.com",
|
|
165
|
+
};
|
|
166
|
+
handler = (0, well_known_js_1.createWellKnownHandler)(mockIdentity, mockConfig);
|
|
167
|
+
});
|
|
168
|
+
(0, vitest_1.describe)("DID Document Handler", () => {
|
|
169
|
+
(0, vitest_1.it)("should handle DID document request successfully", () => {
|
|
170
|
+
const response = handler.handleDIDDocument();
|
|
171
|
+
(0, vitest_1.expect)(response.status).toBe(200);
|
|
172
|
+
(0, vitest_1.expect)(response.headers["Content-Type"]).toBe("application/did+json");
|
|
173
|
+
(0, vitest_1.expect)(response.body).toBeTruthy();
|
|
174
|
+
const didDocument = JSON.parse(response.body);
|
|
175
|
+
(0, vitest_1.expect)(didDocument.id).toBe(mockIdentity.did);
|
|
176
|
+
(0, vitest_1.expect)(didDocument.verificationMethod).toHaveLength(1);
|
|
177
|
+
});
|
|
178
|
+
(0, vitest_1.it)("should return valid JSON in response body", () => {
|
|
179
|
+
const response = handler.handleDIDDocument();
|
|
180
|
+
(0, vitest_1.expect)(() => JSON.parse(response.body)).not.toThrow();
|
|
181
|
+
const didDocument = JSON.parse(response.body);
|
|
182
|
+
(0, vitest_1.expect)((0, well_known_js_1.validateDIDDocument)(didDocument)).toBe(true);
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
(0, vitest_1.describe)("Agent Document Handler", () => {
|
|
186
|
+
(0, vitest_1.it)("should handle agent document request successfully", () => {
|
|
187
|
+
const response = handler.handleAgentDocument();
|
|
188
|
+
(0, vitest_1.expect)(response.status).toBe(200);
|
|
189
|
+
(0, vitest_1.expect)(response.headers["Content-Type"]).toBe("application/json");
|
|
190
|
+
(0, vitest_1.expect)(response.body).toBeTruthy();
|
|
191
|
+
const agentDocument = JSON.parse(response.body);
|
|
192
|
+
(0, vitest_1.expect)(agentDocument.id).toBe(mockIdentity.did);
|
|
193
|
+
(0, vitest_1.expect)(agentDocument.capabilities["mcp-i"]).toEqual([
|
|
194
|
+
"handshake",
|
|
195
|
+
"signing",
|
|
196
|
+
"verification",
|
|
197
|
+
]);
|
|
198
|
+
});
|
|
199
|
+
(0, vitest_1.it)("should return valid JSON in response body", () => {
|
|
200
|
+
const response = handler.handleAgentDocument();
|
|
201
|
+
(0, vitest_1.expect)(() => JSON.parse(response.body)).not.toThrow();
|
|
202
|
+
const agentDocument = JSON.parse(response.body);
|
|
203
|
+
(0, vitest_1.expect)((0, well_known_js_1.validateAgentDocument)(agentDocument)).toBe(true);
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
(0, vitest_1.describe)("Validation Functions", () => {
|
|
208
|
+
(0, vitest_1.describe)("validateDIDDocument", () => {
|
|
209
|
+
(0, vitest_1.it)("should validate correct DID document", () => {
|
|
210
|
+
const validDIDDocument = {
|
|
211
|
+
"@context": ["https://www.w3.org/ns/did/v1"],
|
|
212
|
+
id: "did:web:example.com:agents:test-agent",
|
|
213
|
+
verificationMethod: [
|
|
214
|
+
{
|
|
215
|
+
id: "#key-test-123",
|
|
216
|
+
type: "Ed25519VerificationKey2020",
|
|
217
|
+
controller: "did:web:example.com:agents:test-agent",
|
|
218
|
+
publicKeyMultibase: "z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK",
|
|
219
|
+
},
|
|
220
|
+
],
|
|
221
|
+
authentication: ["#key-test-123"],
|
|
222
|
+
assertionMethod: ["#key-test-123"],
|
|
223
|
+
};
|
|
224
|
+
(0, vitest_1.expect)((0, well_known_js_1.validateDIDDocument)(validDIDDocument)).toBe(true);
|
|
225
|
+
});
|
|
226
|
+
(0, vitest_1.it)("should reject invalid DID documents", () => {
|
|
227
|
+
const invalidDocuments = [
|
|
228
|
+
null,
|
|
229
|
+
undefined,
|
|
230
|
+
{},
|
|
231
|
+
{ "@context": "invalid" },
|
|
232
|
+
{ "@context": [], id: "not-a-did" },
|
|
233
|
+
{
|
|
234
|
+
"@context": [],
|
|
235
|
+
id: "did:web:example.com",
|
|
236
|
+
verificationMethod: "invalid",
|
|
237
|
+
},
|
|
238
|
+
];
|
|
239
|
+
for (const doc of invalidDocuments) {
|
|
240
|
+
(0, vitest_1.expect)((0, well_known_js_1.validateDIDDocument)(doc)).toBe(false);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
(0, vitest_1.describe)("validateAgentDocument", () => {
|
|
245
|
+
(0, vitest_1.it)("should validate correct agent document", () => {
|
|
246
|
+
const validAgentDocument = {
|
|
247
|
+
id: "did:web:example.com:agents:test-agent",
|
|
248
|
+
capabilities: {
|
|
249
|
+
"mcp-i": ["handshake", "signing", "verification"],
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
(0, vitest_1.expect)((0, well_known_js_1.validateAgentDocument)(validAgentDocument)).toBe(true);
|
|
253
|
+
});
|
|
254
|
+
(0, vitest_1.it)("should reject agent documents with incorrect capabilities", () => {
|
|
255
|
+
const invalidDocuments = [
|
|
256
|
+
{
|
|
257
|
+
id: "did:web:example.com:agents:test-agent",
|
|
258
|
+
capabilities: {
|
|
259
|
+
"mcp-i": ["handshake", "signing"], // Missing verification
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
id: "did:web:example.com:agents:test-agent",
|
|
264
|
+
capabilities: {
|
|
265
|
+
"mcp-i": ["handshake", "signing", "verification", "extra"], // Extra capability
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
id: "did:web:example.com:agents:test-agent",
|
|
270
|
+
capabilities: {
|
|
271
|
+
"mcp-i": ["wrong", "capabilities", "list"],
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
];
|
|
275
|
+
for (const doc of invalidDocuments) {
|
|
276
|
+
(0, vitest_1.expect)((0, well_known_js_1.validateAgentDocument)(doc)).toBe(false);
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
(0, vitest_1.it)("should reject invalid agent documents", () => {
|
|
280
|
+
const invalidDocuments = [
|
|
281
|
+
null,
|
|
282
|
+
undefined,
|
|
283
|
+
{},
|
|
284
|
+
{ id: "not-a-did" },
|
|
285
|
+
{ id: "did:web:example.com", capabilities: "invalid" },
|
|
286
|
+
];
|
|
287
|
+
for (const doc of invalidDocuments) {
|
|
288
|
+
(0, vitest_1.expect)((0, well_known_js_1.validateAgentDocument)(doc)).toBe(false);
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
(0, vitest_1.describe)("Utility Functions", () => {
|
|
294
|
+
(0, vitest_1.describe)("extractDIDFromPath", () => {
|
|
295
|
+
(0, vitest_1.it)("should extract DID from root path", () => {
|
|
296
|
+
const did = (0, well_known_js_1.extractDIDFromPath)("/.well-known/did.json", "https://example.com");
|
|
297
|
+
(0, vitest_1.expect)(did).toBe("did:web:example.com");
|
|
298
|
+
});
|
|
299
|
+
(0, vitest_1.it)("should extract DID from nested path", () => {
|
|
300
|
+
const did = (0, well_known_js_1.extractDIDFromPath)("/agents/my-agent/.well-known/did.json", "https://example.com");
|
|
301
|
+
(0, vitest_1.expect)(did).toBe("did:web:example.com:agents:my-agent");
|
|
302
|
+
});
|
|
303
|
+
(0, vitest_1.it)("should handle complex paths", () => {
|
|
304
|
+
const did = (0, well_known_js_1.extractDIDFromPath)("/users/alice/agents/assistant/.well-known/did.json", "https://example.com");
|
|
305
|
+
(0, vitest_1.expect)(did).toBe("did:web:example.com:users:alice:agents:assistant");
|
|
306
|
+
});
|
|
307
|
+
(0, vitest_1.it)("should return null for invalid URLs", () => {
|
|
308
|
+
const did = (0, well_known_js_1.extractDIDFromPath)("/.well-known/did.json", "invalid-url");
|
|
309
|
+
(0, vitest_1.expect)(did).toBeNull();
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
});
|