@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,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DelegationMiddleware = exports.DefaultDelegationHooks = void 0;
|
|
4
|
+
exports.createDelegationHooks = createDelegationHooks;
|
|
5
|
+
exports.createDelegationMiddleware = createDelegationMiddleware;
|
|
6
|
+
/**
|
|
7
|
+
* Default delegation hooks implementation
|
|
8
|
+
*/
|
|
9
|
+
class DefaultDelegationHooks {
|
|
10
|
+
delegationManager;
|
|
11
|
+
options;
|
|
12
|
+
constructor(delegationManager, options = {}) {
|
|
13
|
+
this.delegationManager = delegationManager;
|
|
14
|
+
this.options = options;
|
|
15
|
+
}
|
|
16
|
+
async beforeProof(meta) {
|
|
17
|
+
// Resolve delegation reference if needed
|
|
18
|
+
if (!meta.delegationRef && this.options.autoResolveDelegation) {
|
|
19
|
+
const context = {
|
|
20
|
+
audience: meta.audience,
|
|
21
|
+
sessionId: meta.sessionId,
|
|
22
|
+
did: meta.did,
|
|
23
|
+
kid: meta.kid,
|
|
24
|
+
scopes: meta.scopeId ? [meta.scopeId] : undefined,
|
|
25
|
+
};
|
|
26
|
+
meta.delegationRef = await this.resolveDelegation(context);
|
|
27
|
+
}
|
|
28
|
+
return meta;
|
|
29
|
+
}
|
|
30
|
+
async afterProof(meta) {
|
|
31
|
+
// Validate delegation if present
|
|
32
|
+
if (meta.delegationRef) {
|
|
33
|
+
const isActive = await this.delegationManager.isActive(meta.delegationRef);
|
|
34
|
+
if (!isActive) {
|
|
35
|
+
throw new Error(`Delegation ${meta.delegationRef} is not active or has been revoked`);
|
|
36
|
+
}
|
|
37
|
+
// Check delegation expiry
|
|
38
|
+
const delegation = await this.delegationManager.get(meta.delegationRef);
|
|
39
|
+
if (delegation) {
|
|
40
|
+
const now = Math.floor(Date.now() / 1000);
|
|
41
|
+
if (delegation.exp < now) {
|
|
42
|
+
throw new Error(`Delegation ${meta.delegationRef} has expired`);
|
|
43
|
+
}
|
|
44
|
+
// Validate scopes if specified
|
|
45
|
+
if (meta.scopeId && !delegation.scopes.includes(meta.scopeId)) {
|
|
46
|
+
throw new Error(`Scope ${meta.scopeId} not authorized by delegation ${meta.delegationRef}`);
|
|
47
|
+
}
|
|
48
|
+
// Validate audience if specified
|
|
49
|
+
if (delegation.aud && delegation.aud !== meta.audience) {
|
|
50
|
+
throw new Error(`Audience ${meta.audience} not authorized by delegation ${meta.delegationRef}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async resolveDelegation(_context) {
|
|
56
|
+
// TODO: Implement delegation resolution logic
|
|
57
|
+
// This could involve:
|
|
58
|
+
// 1. Looking up active delegations for the DID
|
|
59
|
+
// 2. Matching scopes and audience
|
|
60
|
+
// 3. Selecting the most appropriate delegation
|
|
61
|
+
// For now, return undefined (no delegation)
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.DefaultDelegationHooks = DefaultDelegationHooks;
|
|
66
|
+
/**
|
|
67
|
+
* Create delegation hooks instance
|
|
68
|
+
*/
|
|
69
|
+
function createDelegationHooks(delegationManager, options) {
|
|
70
|
+
return new DefaultDelegationHooks(delegationManager, options);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Delegation middleware for runtime integration
|
|
74
|
+
*/
|
|
75
|
+
class DelegationMiddleware {
|
|
76
|
+
hooks;
|
|
77
|
+
options;
|
|
78
|
+
constructor(hooks, options = {}) {
|
|
79
|
+
this.hooks = hooks;
|
|
80
|
+
this.options = options;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Process request and attach delegation context
|
|
84
|
+
*/
|
|
85
|
+
async processRequest(meta, context) {
|
|
86
|
+
// Apply before-proof hooks
|
|
87
|
+
if (this.hooks.beforeProof) {
|
|
88
|
+
meta = await this.hooks.beforeProof(meta);
|
|
89
|
+
}
|
|
90
|
+
// Resolve delegation if not already present
|
|
91
|
+
if (!meta.delegationRef && this.hooks.resolveDelegation) {
|
|
92
|
+
meta.delegationRef = await this.hooks.resolveDelegation(context);
|
|
93
|
+
}
|
|
94
|
+
return meta;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Validate proof after generation
|
|
98
|
+
*/
|
|
99
|
+
async validateProof(meta) {
|
|
100
|
+
// Apply after-proof hooks
|
|
101
|
+
if (this.hooks.afterProof) {
|
|
102
|
+
await this.hooks.afterProof(meta);
|
|
103
|
+
}
|
|
104
|
+
// Check if delegation is required
|
|
105
|
+
if (this.options.requireDelegation && !meta.delegationRef) {
|
|
106
|
+
throw new Error("Delegation is required but not present in proof");
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.DelegationMiddleware = DelegationMiddleware;
|
|
111
|
+
/**
|
|
112
|
+
* Create delegation middleware instance
|
|
113
|
+
*/
|
|
114
|
+
function createDelegationMiddleware(hooks, options) {
|
|
115
|
+
return new DelegationMiddleware(hooks, options);
|
|
116
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XMCP-I Demo Features - Optional identity badge and development helpers
|
|
3
|
+
*
|
|
4
|
+
* Provides opt-in demo features for showcasing identity capabilities.
|
|
5
|
+
* All features are disabled by default and must be explicitly enabled.
|
|
6
|
+
*/
|
|
7
|
+
import { AgentIdentity } from "./identity";
|
|
8
|
+
/**
|
|
9
|
+
* Demo configuration
|
|
10
|
+
*/
|
|
11
|
+
export interface DemoConfig {
|
|
12
|
+
identityBadge?: boolean;
|
|
13
|
+
environment?: "development" | "production";
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Demo manager for optional features
|
|
17
|
+
*/
|
|
18
|
+
export declare class DemoManager {
|
|
19
|
+
private config;
|
|
20
|
+
private identity;
|
|
21
|
+
constructor(identity: AgentIdentity, config?: DemoConfig);
|
|
22
|
+
/**
|
|
23
|
+
* Generate identity badge if enabled
|
|
24
|
+
*/
|
|
25
|
+
generateIdentityBadge(): string | null;
|
|
26
|
+
/**
|
|
27
|
+
* Add identity badge to response if enabled
|
|
28
|
+
*/
|
|
29
|
+
addIdentityBadgeToResponse(response: any): any;
|
|
30
|
+
/**
|
|
31
|
+
* Check if identity badge is enabled
|
|
32
|
+
*/
|
|
33
|
+
isIdentityBadgeEnabled(): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Extract short DID identifier for display
|
|
36
|
+
*/
|
|
37
|
+
private extractShortDid;
|
|
38
|
+
/**
|
|
39
|
+
* Get demo configuration
|
|
40
|
+
*/
|
|
41
|
+
getConfig(): DemoConfig;
|
|
42
|
+
/**
|
|
43
|
+
* Update demo configuration
|
|
44
|
+
*/
|
|
45
|
+
updateConfig(updates: Partial<DemoConfig>): void;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Create demo manager
|
|
49
|
+
*/
|
|
50
|
+
export declare function createDemoManager(identity: AgentIdentity, config?: DemoConfig): DemoManager;
|
|
51
|
+
/**
|
|
52
|
+
* Utility to format verify link for console output
|
|
53
|
+
*/
|
|
54
|
+
export declare function formatVerifyLink(baseUrl?: string): string;
|
|
55
|
+
/**
|
|
56
|
+
* Console output helpers for development
|
|
57
|
+
*/
|
|
58
|
+
export declare const DemoConsole: {
|
|
59
|
+
/**
|
|
60
|
+
* Print verify link if enabled
|
|
61
|
+
*/
|
|
62
|
+
printVerifyLink(enabled: boolean, environment: string, baseUrl?: string): void;
|
|
63
|
+
/**
|
|
64
|
+
* Print identity badge if enabled
|
|
65
|
+
*/
|
|
66
|
+
printIdentityBadge(badge: string | null): void;
|
|
67
|
+
/**
|
|
68
|
+
* Print demo warning
|
|
69
|
+
*/
|
|
70
|
+
printDemoWarning(): void;
|
|
71
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* XMCP-I Demo Features - Optional identity badge and development helpers
|
|
4
|
+
*
|
|
5
|
+
* Provides opt-in demo features for showcasing identity capabilities.
|
|
6
|
+
* All features are disabled by default and must be explicitly enabled.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.DemoConsole = exports.DemoManager = void 0;
|
|
10
|
+
exports.createDemoManager = createDemoManager;
|
|
11
|
+
exports.formatVerifyLink = formatVerifyLink;
|
|
12
|
+
/**
|
|
13
|
+
* Demo manager for optional features
|
|
14
|
+
*/
|
|
15
|
+
class DemoManager {
|
|
16
|
+
config;
|
|
17
|
+
identity;
|
|
18
|
+
constructor(identity, config = {}) {
|
|
19
|
+
this.identity = identity;
|
|
20
|
+
this.config = {
|
|
21
|
+
identityBadge: false, // Default disabled
|
|
22
|
+
environment: "development",
|
|
23
|
+
...config,
|
|
24
|
+
};
|
|
25
|
+
// Force disable in production
|
|
26
|
+
if (this.config.environment === "production") {
|
|
27
|
+
this.config.identityBadge = false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Generate identity badge if enabled
|
|
32
|
+
*/
|
|
33
|
+
generateIdentityBadge() {
|
|
34
|
+
if (!this.config.identityBadge ||
|
|
35
|
+
this.config.environment === "production") {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
// Extract short identifier from DID
|
|
39
|
+
const shortDid = this.extractShortDid(this.identity.did);
|
|
40
|
+
return `🔐 ${shortDid}`;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Add identity badge to response if enabled
|
|
44
|
+
*/
|
|
45
|
+
addIdentityBadgeToResponse(response) {
|
|
46
|
+
const badge = this.generateIdentityBadge();
|
|
47
|
+
if (!badge) {
|
|
48
|
+
return response;
|
|
49
|
+
}
|
|
50
|
+
// Add badge to response metadata
|
|
51
|
+
if (typeof response === "object" && response !== null) {
|
|
52
|
+
return {
|
|
53
|
+
...response,
|
|
54
|
+
_identity: badge,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return response;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Check if identity badge is enabled
|
|
61
|
+
*/
|
|
62
|
+
isIdentityBadgeEnabled() {
|
|
63
|
+
return (this.config.identityBadge === true &&
|
|
64
|
+
this.config.environment !== "production");
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Extract short DID identifier for display
|
|
68
|
+
*/
|
|
69
|
+
extractShortDid(did) {
|
|
70
|
+
// For did:web:example.com:agents:my-agent, return "my-agent"
|
|
71
|
+
const parts = did.split(":");
|
|
72
|
+
if (parts.length >= 2) {
|
|
73
|
+
const lastPart = parts[parts.length - 1];
|
|
74
|
+
// Truncate if too long
|
|
75
|
+
return lastPart.length > 12 ? `${lastPart.slice(0, 12)}...` : lastPart;
|
|
76
|
+
}
|
|
77
|
+
return "agent";
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get demo configuration
|
|
81
|
+
*/
|
|
82
|
+
getConfig() {
|
|
83
|
+
return { ...this.config };
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Update demo configuration
|
|
87
|
+
*/
|
|
88
|
+
updateConfig(updates) {
|
|
89
|
+
this.config = { ...this.config, ...updates };
|
|
90
|
+
// Force disable in production
|
|
91
|
+
if (this.config.environment === "production") {
|
|
92
|
+
this.config.identityBadge = false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.DemoManager = DemoManager;
|
|
97
|
+
/**
|
|
98
|
+
* Create demo manager
|
|
99
|
+
*/
|
|
100
|
+
function createDemoManager(identity, config = {}) {
|
|
101
|
+
return new DemoManager(identity, config);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Utility to format verify link for console output
|
|
105
|
+
*/
|
|
106
|
+
function formatVerifyLink(baseUrl = "http://localhost:3000") {
|
|
107
|
+
return `${baseUrl}/verify`;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Console output helpers for development
|
|
111
|
+
*/
|
|
112
|
+
exports.DemoConsole = {
|
|
113
|
+
/**
|
|
114
|
+
* Print verify link if enabled
|
|
115
|
+
*/
|
|
116
|
+
printVerifyLink(enabled, environment, baseUrl = "http://localhost:3000") {
|
|
117
|
+
if (enabled && environment === "development") {
|
|
118
|
+
console.log(`🔍 Debug: ${formatVerifyLink(baseUrl)}`);
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
/**
|
|
122
|
+
* Print identity badge if enabled
|
|
123
|
+
*/
|
|
124
|
+
printIdentityBadge(badge) {
|
|
125
|
+
if (badge) {
|
|
126
|
+
console.log(`${badge} Identity verified`);
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
/**
|
|
130
|
+
* Print demo warning
|
|
131
|
+
*/
|
|
132
|
+
printDemoWarning() {
|
|
133
|
+
console.log("⚠️ Demo features enabled - disable in production");
|
|
134
|
+
},
|
|
135
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const headers: () => import("http").IncomingHttpHeaders;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.headers = void 0;
|
|
4
|
+
const http_context_1 = require("./transports/http/http-context");
|
|
5
|
+
const headers = () => {
|
|
6
|
+
const headers = (0, http_context_1.getHttpContext)().headers;
|
|
7
|
+
return headers;
|
|
8
|
+
};
|
|
9
|
+
exports.headers = headers;
|