@kya-os/mcp-i-cloudflare 1.5.8-canary.6 → 1.5.8-canary.61
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 +130 -0
- package/dist/__tests__/e2e/test-config.d.ts +37 -0
- package/dist/__tests__/e2e/test-config.d.ts.map +1 -0
- package/dist/__tests__/e2e/test-config.js +62 -0
- package/dist/__tests__/e2e/test-config.js.map +1 -0
- package/dist/adapter.d.ts +44 -0
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +677 -88
- package/dist/adapter.js.map +1 -1
- package/dist/agent.d.ts +69 -25
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +435 -40
- package/dist/agent.js.map +1 -1
- package/dist/app.d.ts +0 -8
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +208 -55
- package/dist/app.js.map +1 -1
- package/dist/cache/kv-oauth-config-cache.d.ts +47 -0
- package/dist/cache/kv-oauth-config-cache.d.ts.map +1 -0
- package/dist/cache/kv-oauth-config-cache.js +82 -0
- package/dist/cache/kv-oauth-config-cache.js.map +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +33 -4
- package/dist/config.js.map +1 -1
- package/dist/helpers/env-mapper.d.ts +60 -1
- package/dist/helpers/env-mapper.d.ts.map +1 -1
- package/dist/helpers/env-mapper.js +136 -6
- package/dist/helpers/env-mapper.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/dist/runtime/audit-logger.d.ts +96 -0
- package/dist/runtime/audit-logger.d.ts.map +1 -0
- package/dist/runtime/audit-logger.js +276 -0
- package/dist/runtime/audit-logger.js.map +1 -0
- package/dist/runtime/oauth-handler.d.ts +5 -0
- package/dist/runtime/oauth-handler.d.ts.map +1 -1
- package/dist/runtime/oauth-handler.js +287 -35
- package/dist/runtime/oauth-handler.js.map +1 -1
- package/dist/runtime.d.ts +12 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +34 -4
- package/dist/runtime.js.map +1 -1
- package/dist/server.d.ts +7 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +55 -2
- package/dist/server.js.map +1 -1
- package/dist/services/admin.service.d.ts.map +1 -1
- package/dist/services/admin.service.js +27 -0
- package/dist/services/admin.service.js.map +1 -1
- package/dist/services/consent-audit.service.d.ts +91 -0
- package/dist/services/consent-audit.service.d.ts.map +1 -0
- package/dist/services/consent-audit.service.js +243 -0
- package/dist/services/consent-audit.service.js.map +1 -0
- package/dist/services/consent-config.service.d.ts +2 -2
- package/dist/services/consent-config.service.d.ts.map +1 -1
- package/dist/services/consent-config.service.js +55 -24
- package/dist/services/consent-config.service.js.map +1 -1
- package/dist/services/consent-page-renderer.d.ts +14 -0
- package/dist/services/consent-page-renderer.d.ts.map +1 -1
- package/dist/services/consent-page-renderer.js +42 -0
- package/dist/services/consent-page-renderer.js.map +1 -1
- package/dist/services/consent.service.d.ts +82 -4
- package/dist/services/consent.service.d.ts.map +1 -1
- package/dist/services/consent.service.js +1717 -34
- package/dist/services/consent.service.js.map +1 -1
- package/dist/services/delegation.service.d.ts.map +1 -1
- package/dist/services/delegation.service.js +67 -29
- package/dist/services/delegation.service.js.map +1 -1
- package/dist/services/idp-token-storage.d.ts +68 -0
- package/dist/services/idp-token-storage.d.ts.map +1 -0
- package/dist/services/idp-token-storage.js +157 -0
- package/dist/services/idp-token-storage.js.map +1 -0
- package/dist/services/oauth-service.d.ts +66 -0
- package/dist/services/oauth-service.d.ts.map +1 -0
- package/dist/services/oauth-service.js +223 -0
- package/dist/services/oauth-service.js.map +1 -0
- package/dist/services/proof.service.d.ts +5 -3
- package/dist/services/proof.service.d.ts.map +1 -1
- package/dist/services/proof.service.js +35 -8
- package/dist/services/proof.service.js.map +1 -1
- package/dist/services/tool-context-builder.d.ts +55 -0
- package/dist/services/tool-context-builder.d.ts.map +1 -0
- package/dist/services/tool-context-builder.js +124 -0
- package/dist/services/tool-context-builder.js.map +1 -0
- package/dist/types/tool-context.d.ts +35 -0
- package/dist/types/tool-context.d.ts.map +1 -0
- package/dist/types/tool-context.js +13 -0
- package/dist/types/tool-context.js.map +1 -0
- package/dist/types.d.ts +30 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +27 -60
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Context Builder
|
|
3
|
+
*
|
|
4
|
+
* Builds ToolExecutionContext for tool handlers by resolving IDP tokens
|
|
5
|
+
* based on tool protection configuration and user identity.
|
|
6
|
+
*
|
|
7
|
+
* @package @kya-os/mcp-i-cloudflare
|
|
8
|
+
*/
|
|
9
|
+
import type { ToolExecutionContext } from "../types/tool-context.js";
|
|
10
|
+
import type { IdpTokenResolver } from "@kya-os/mcp-i-core";
|
|
11
|
+
import type { ToolProtection } from "@kya-os/mcp-i-core/types/tool-protection";
|
|
12
|
+
import type { OAuthConfigService } from "@kya-os/mcp-i-core";
|
|
13
|
+
export interface ToolContextBuilderConfig {
|
|
14
|
+
/** IDP token resolver for resolving tokens from User DID */
|
|
15
|
+
tokenResolver: IdpTokenResolver;
|
|
16
|
+
/** OAuth config service for fetching provider configurations */
|
|
17
|
+
configService: OAuthConfigService;
|
|
18
|
+
/** Project ID for fetching OAuth config */
|
|
19
|
+
projectId: string;
|
|
20
|
+
/** Optional logger callback for diagnostics */
|
|
21
|
+
logger?: (message: string, data?: unknown) => void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Builder for tool execution context
|
|
25
|
+
*
|
|
26
|
+
* Resolves IDP tokens and builds context for tool handlers.
|
|
27
|
+
* Phase 1: Uses configured provider as temporary fallback.
|
|
28
|
+
* Phase 2+: Requires explicit oauthProvider on tool protection.
|
|
29
|
+
*/
|
|
30
|
+
export declare class ToolContextBuilder {
|
|
31
|
+
private config;
|
|
32
|
+
constructor(config: ToolContextBuilderConfig);
|
|
33
|
+
/**
|
|
34
|
+
* Build tool execution context
|
|
35
|
+
*
|
|
36
|
+
* @param toolName - Name of the tool being executed
|
|
37
|
+
* @param userDid - User DID (optional, required for OAuth)
|
|
38
|
+
* @param sessionId - Session ID (optional)
|
|
39
|
+
* @param delegationToken - Delegation token (optional)
|
|
40
|
+
* @param toolProtection - Tool protection configuration (optional)
|
|
41
|
+
* @returns Tool execution context or undefined if not needed
|
|
42
|
+
*/
|
|
43
|
+
buildContext(toolName: string, userDid: string | undefined, sessionId: string | undefined, delegationToken: string | undefined, toolProtection: ToolProtection | null): Promise<ToolExecutionContext | undefined>;
|
|
44
|
+
/**
|
|
45
|
+
* Resolve OAuth provider for a tool
|
|
46
|
+
*
|
|
47
|
+
* Phase 1: Uses configured provider from OAuth config as temporary fallback
|
|
48
|
+
* Phase 2+: Requires explicit oauthProvider on tool protection
|
|
49
|
+
*
|
|
50
|
+
* @param toolProtection - Tool protection configuration
|
|
51
|
+
* @returns Provider name or null if not found
|
|
52
|
+
*/
|
|
53
|
+
private resolveProvider;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=tool-context-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-context-builder.d.ts","sourceRoot":"","sources":["../../src/services/tool-context-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAE/E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,MAAM,WAAW,wBAAwB;IACvC,4DAA4D;IAC5D,aAAa,EAAE,gBAAgB,CAAC;IAEhC,gEAAgE;IAChE,aAAa,EAAE,kBAAkB,CAAC;IAElC,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC;IAElB,+CAA+C;IAC/C,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACpD;AAED;;;;;;GAMG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAEZ;gBAEU,MAAM,EAAE,wBAAwB;IAS5C;;;;;;;;;OASG;IACG,YAAY,CAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,eAAe,EAAE,MAAM,GAAG,SAAS,EACnC,cAAc,EAAE,cAAc,GAAG,IAAI,GACpC,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC;IAyD5C;;;;;;;;OAQG;YACW,eAAe;CAyC9B"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Context Builder
|
|
3
|
+
*
|
|
4
|
+
* Builds ToolExecutionContext for tool handlers by resolving IDP tokens
|
|
5
|
+
* based on tool protection configuration and user identity.
|
|
6
|
+
*
|
|
7
|
+
* @package @kya-os/mcp-i-cloudflare
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Builder for tool execution context
|
|
11
|
+
*
|
|
12
|
+
* Resolves IDP tokens and builds context for tool handlers.
|
|
13
|
+
* Phase 1: Uses configured provider as temporary fallback.
|
|
14
|
+
* Phase 2+: Requires explicit oauthProvider on tool protection.
|
|
15
|
+
*/
|
|
16
|
+
export class ToolContextBuilder {
|
|
17
|
+
config;
|
|
18
|
+
constructor(config) {
|
|
19
|
+
this.config = {
|
|
20
|
+
tokenResolver: config.tokenResolver,
|
|
21
|
+
configService: config.configService,
|
|
22
|
+
projectId: config.projectId,
|
|
23
|
+
logger: config.logger || (() => { }),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Build tool execution context
|
|
28
|
+
*
|
|
29
|
+
* @param toolName - Name of the tool being executed
|
|
30
|
+
* @param userDid - User DID (optional, required for OAuth)
|
|
31
|
+
* @param sessionId - Session ID (optional)
|
|
32
|
+
* @param delegationToken - Delegation token (optional)
|
|
33
|
+
* @param toolProtection - Tool protection configuration (optional)
|
|
34
|
+
* @returns Tool execution context or undefined if not needed
|
|
35
|
+
*/
|
|
36
|
+
async buildContext(toolName, userDid, sessionId, delegationToken, toolProtection) {
|
|
37
|
+
// Only build context if tool requires OAuth
|
|
38
|
+
if (!toolProtection?.requiredScopes?.length || !userDid) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
// Phase 1: Resolve provider from configured providers
|
|
42
|
+
// Phase 1 uses configured provider as temporary fallback
|
|
43
|
+
// Phase 2+ requires explicit oauthProvider on tool protection
|
|
44
|
+
const provider = await this.resolveProvider(toolProtection);
|
|
45
|
+
if (!provider) {
|
|
46
|
+
this.config.logger("[ToolContextBuilder] Provider not resolved", {
|
|
47
|
+
toolName,
|
|
48
|
+
userDid: userDid.substring(0, 20) + "...",
|
|
49
|
+
});
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
// Resolve IDP token
|
|
53
|
+
const idpToken = await this.config.tokenResolver.resolveTokenFromDid(userDid, provider, toolProtection.requiredScopes);
|
|
54
|
+
if (!idpToken) {
|
|
55
|
+
// Token not available - will trigger OAuth flow
|
|
56
|
+
this.config.logger("[ToolContextBuilder] Token not available", {
|
|
57
|
+
toolName,
|
|
58
|
+
userDid: userDid.substring(0, 20) + "...",
|
|
59
|
+
provider,
|
|
60
|
+
scopes: toolProtection.requiredScopes,
|
|
61
|
+
});
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
// Build context with token
|
|
65
|
+
const context = {
|
|
66
|
+
idpToken,
|
|
67
|
+
provider,
|
|
68
|
+
scopes: toolProtection.requiredScopes,
|
|
69
|
+
userDid,
|
|
70
|
+
sessionId,
|
|
71
|
+
delegationToken,
|
|
72
|
+
};
|
|
73
|
+
this.config.logger("[ToolContextBuilder] Context built successfully", {
|
|
74
|
+
toolName,
|
|
75
|
+
userDid: userDid.substring(0, 20) + "...",
|
|
76
|
+
provider,
|
|
77
|
+
hasToken: !!idpToken,
|
|
78
|
+
});
|
|
79
|
+
return context;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Resolve OAuth provider for a tool
|
|
83
|
+
*
|
|
84
|
+
* Phase 1: Uses configured provider from OAuth config as temporary fallback
|
|
85
|
+
* Phase 2+: Requires explicit oauthProvider on tool protection
|
|
86
|
+
*
|
|
87
|
+
* @param toolProtection - Tool protection configuration
|
|
88
|
+
* @returns Provider name or null if not found
|
|
89
|
+
*/
|
|
90
|
+
async resolveProvider(toolProtection) {
|
|
91
|
+
// Phase 2+: Check for explicit oauthProvider (not yet implemented)
|
|
92
|
+
// if (toolProtection.oauthProvider) {
|
|
93
|
+
// return toolProtection.oauthProvider;
|
|
94
|
+
// }
|
|
95
|
+
// Phase 1: Use configured provider from OAuth config as temporary fallback
|
|
96
|
+
// Get first configured provider (Phase 1 assumes single provider per project)
|
|
97
|
+
try {
|
|
98
|
+
const oauthConfig = await this.config.configService.getOAuthConfig(this.config.projectId);
|
|
99
|
+
const providers = Object.keys(oauthConfig.providers);
|
|
100
|
+
if (providers.length === 0) {
|
|
101
|
+
this.config.logger("[ToolContextBuilder] No providers configured", {
|
|
102
|
+
projectId: this.config.projectId,
|
|
103
|
+
});
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
// Phase 1: Use first configured provider as fallback
|
|
107
|
+
// Phase 2+: This fallback will be removed, tools must specify oauthProvider
|
|
108
|
+
const provider = providers[0];
|
|
109
|
+
this.config.logger("[ToolContextBuilder] Provider resolved (Phase 1 fallback)", {
|
|
110
|
+
provider,
|
|
111
|
+
availableProviders: providers,
|
|
112
|
+
});
|
|
113
|
+
return provider;
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
this.config.logger("[ToolContextBuilder] Failed to fetch OAuth config", {
|
|
117
|
+
error: error instanceof Error ? error.message : String(error),
|
|
118
|
+
projectId: this.config.projectId,
|
|
119
|
+
});
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=tool-context-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-context-builder.js","sourceRoot":"","sources":["../../src/services/tool-context-builder.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Execution Context
|
|
3
|
+
*
|
|
4
|
+
* Execution context passed to tool handlers, enabling tools to access
|
|
5
|
+
* IDP tokens for external API calls (GitHub, Google, etc.).
|
|
6
|
+
*
|
|
7
|
+
* All fields are optional for backward compatibility - tools that don't
|
|
8
|
+
* require OAuth will receive undefined context.
|
|
9
|
+
*
|
|
10
|
+
* @package @kya-os/mcp-i-cloudflare
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Execution context passed to tool handlers
|
|
14
|
+
*
|
|
15
|
+
* Enables tools to access IDP tokens for external API calls.
|
|
16
|
+
* Context is only provided when:
|
|
17
|
+
* - Tool requires OAuth (has requiredScopes)
|
|
18
|
+
* - User DID is available
|
|
19
|
+
* - IDP token is successfully resolved
|
|
20
|
+
*/
|
|
21
|
+
export interface ToolExecutionContext {
|
|
22
|
+
/** IDP access token for external API calls (e.g., GitHub, Google) */
|
|
23
|
+
idpToken?: string;
|
|
24
|
+
/** OAuth provider name (e.g., "github", "google") */
|
|
25
|
+
provider?: string;
|
|
26
|
+
/** Scopes granted for this token */
|
|
27
|
+
scopes?: string[];
|
|
28
|
+
/** User DID associated with this token */
|
|
29
|
+
userDid?: string;
|
|
30
|
+
/** Session ID */
|
|
31
|
+
sessionId?: string;
|
|
32
|
+
/** Delegation token (MCP-I internal authorization) */
|
|
33
|
+
delegationToken?: string;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=tool-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-context.d.ts","sourceRoot":"","sources":["../../src/types/tool-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;;;;;GAQG;AACH,MAAM,WAAW,oBAAoB;IACnC,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAElB,0CAA0C;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,iBAAiB;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,sDAAsD;IACtD,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Execution Context
|
|
3
|
+
*
|
|
4
|
+
* Execution context passed to tool handlers, enabling tools to access
|
|
5
|
+
* IDP tokens for external API calls (GitHub, Google, etc.).
|
|
6
|
+
*
|
|
7
|
+
* All fields are optional for backward compatibility - tools that don't
|
|
8
|
+
* require OAuth will receive undefined context.
|
|
9
|
+
*
|
|
10
|
+
* @package @kya-os/mcp-i-cloudflare
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=tool-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-context.js","sourceRoot":"","sources":["../../src/types/tool-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|
package/dist/types.d.ts
CHANGED
|
@@ -6,12 +6,39 @@
|
|
|
6
6
|
import type { KVNamespace, DurableObjectState } from '@cloudflare/workers-types';
|
|
7
7
|
/**
|
|
8
8
|
* Cloudflare environment bindings for MCP-I
|
|
9
|
+
*
|
|
10
|
+
* This is the normalized format after prefix mapping. All components expect
|
|
11
|
+
* this format with standard KV binding names (e.g., `NONCE_CACHE`, not `_17429_NONCE_CACHE`).
|
|
12
|
+
*
|
|
13
|
+
* To handle prefixed KV bindings (required for multi-agent deployments in the same account),
|
|
14
|
+
* use `normalizeCloudflareEnv()` from `@kya-os/mcp-i-cloudflare/helpers/env-mapper` before
|
|
15
|
+
* passing the environment to components.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { normalizeCloudflareEnv } from '@kya-os/mcp-i-cloudflare/helpers/env-mapper';
|
|
20
|
+
*
|
|
21
|
+
* // With prefixed bindings
|
|
22
|
+
* const env = { _17429_NONCE_CACHE: kvNamespace };
|
|
23
|
+
* const normalized = normalizeCloudflareEnv(env, '_17429');
|
|
24
|
+
* // normalized.NONCE_CACHE is now available
|
|
25
|
+
*
|
|
26
|
+
* // Without prefix (direct access)
|
|
27
|
+
* const env2 = { NONCE_CACHE: kvNamespace };
|
|
28
|
+
* const normalized2 = normalizeCloudflareEnv(env2);
|
|
29
|
+
* // normalized2.NONCE_CACHE is available
|
|
30
|
+
* ```
|
|
9
31
|
*/
|
|
10
32
|
export interface CloudflareEnv {
|
|
33
|
+
/** KV namespace for nonce cache (required for replay attack prevention) */
|
|
11
34
|
NONCE_CACHE: KVNamespace;
|
|
35
|
+
/** KV namespace for proof archive (optional, for auditability) */
|
|
12
36
|
PROOF_ARCHIVE?: KVNamespace;
|
|
37
|
+
/** KV namespace for identity storage (optional, for persistent agent identity) */
|
|
13
38
|
IDENTITY_STORAGE?: KVNamespace;
|
|
39
|
+
/** KV namespace for tool protection config cache (optional, for dashboard-controlled delegation) */
|
|
14
40
|
TOOL_PROTECTION_KV?: KVNamespace;
|
|
41
|
+
/** KV namespace for delegation storage (required for OAuth/delegation flows) */
|
|
15
42
|
DELEGATION_STORAGE?: KVNamespace;
|
|
16
43
|
MCP_IDENTITY_PRIVATE_KEY?: string;
|
|
17
44
|
MCP_IDENTITY_PUBLIC_KEY?: string;
|
|
@@ -20,9 +47,12 @@ export interface CloudflareEnv {
|
|
|
20
47
|
AGENTSHIELD_API_URL?: string;
|
|
21
48
|
AGENTSHIELD_API_KEY?: string;
|
|
22
49
|
AGENTSHIELD_PROJECT_ID?: string;
|
|
50
|
+
/** Optional encryption secret for OAuth token encryption (CSRF protection) */
|
|
51
|
+
OAUTH_ENCRYPTION_SECRET?: string;
|
|
23
52
|
MCPI_ENV?: string;
|
|
24
53
|
ENVIRONMENT?: string;
|
|
25
54
|
ADMIN_API_KEY?: string;
|
|
55
|
+
/** Optional Durable Object state for identity persistence */
|
|
26
56
|
_durableObjectState?: DurableObjectState;
|
|
27
57
|
}
|
|
28
58
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEjF
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEjF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,WAAW,aAAa;IAC5B,2EAA2E;IAC3E,WAAW,EAAE,WAAW,CAAC;IACzB,kEAAkE;IAClE,aAAa,CAAC,EAAE,WAAW,CAAC;IAC5B,kFAAkF;IAClF,gBAAgB,CAAC,EAAE,WAAW,CAAC;IAC/B,oGAAoG;IACpG,kBAAkB,CAAC,EAAE,WAAW,CAAC;IACjC,gFAAgF;IAChF,kBAAkB,CAAC,EAAE,WAAW,CAAC;IACjC,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,8EAA8E;IAC9E,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,6DAA6D;IAC7D,mBAAmB,CAAC,EAAE,kBAAkB,CAAC;CAC1C"}
|
package/package.json
CHANGED
|
@@ -1,74 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kya-os/mcp-i-cloudflare",
|
|
3
|
-
"version": "1.5.8-canary.
|
|
4
|
-
"description": "Cloudflare Workers
|
|
3
|
+
"version": "1.5.8-canary.61",
|
|
4
|
+
"description": "Cloudflare Workers adapter for MCP-I framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
-
"type": "module",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"import": "./dist/index.js",
|
|
11
|
-
"types": "./dist/index.d.ts"
|
|
12
|
-
},
|
|
13
|
-
"./config": {
|
|
14
|
-
"import": "./dist/config.js",
|
|
15
|
-
"types": "./dist/config.d.ts"
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
7
|
"files": [
|
|
19
|
-
"dist
|
|
20
|
-
"README.md"
|
|
8
|
+
"dist"
|
|
21
9
|
],
|
|
22
10
|
"scripts": {
|
|
23
11
|
"build": "tsc",
|
|
24
|
-
"
|
|
25
|
-
"test": "vitest --
|
|
26
|
-
"test:
|
|
27
|
-
"lint": "eslint
|
|
28
|
-
"
|
|
29
|
-
"prepublishOnly": "npm run build && node ../create-mcpi-app/scripts/validate-
|
|
12
|
+
"test": "vitest run",
|
|
13
|
+
"test:coverage": "vitest run --coverage",
|
|
14
|
+
"test:watch": "vitest",
|
|
15
|
+
"lint": "eslint .",
|
|
16
|
+
"clean": "rm -rf dist .turbo node_modules",
|
|
17
|
+
"prepublishOnly": "npm run build && node ../create-mcpi-app/scripts/validate-no-workspace.js"
|
|
30
18
|
},
|
|
31
|
-
"keywords": [
|
|
32
|
-
"mcp-i",
|
|
33
|
-
"mcp",
|
|
34
|
-
"identity",
|
|
35
|
-
"did",
|
|
36
|
-
"cloudflare",
|
|
37
|
-
"workers",
|
|
38
|
-
"edge"
|
|
39
|
-
],
|
|
40
19
|
"dependencies": {
|
|
41
|
-
"@kya-os/contracts": "^1.5.
|
|
42
|
-
"@kya-os/mcp-i-core": "^1.2.
|
|
43
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
"
|
|
20
|
+
"@kya-os/contracts": "^1.5.3-canary.22",
|
|
21
|
+
"@kya-os/mcp-i-core": "^1.2.2-canary.31",
|
|
22
|
+
"@modelcontextprotocol/sdk": "^1.22.0",
|
|
23
|
+
"agents": "^0.2.21",
|
|
24
|
+
"base-x": "^5.0.0",
|
|
25
|
+
"hono": "^4.6.3",
|
|
26
|
+
"jose": "^5.6.3",
|
|
27
|
+
"zod": "^3.23.8"
|
|
49
28
|
},
|
|
50
29
|
"devDependencies": {
|
|
51
|
-
"@cloudflare/workers-types": "^4.
|
|
52
|
-
"@types/node": "^20.
|
|
53
|
-
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
54
|
-
"@typescript-eslint/parser": "^6.0.0",
|
|
30
|
+
"@cloudflare/workers-types": "^4.20240701.0",
|
|
31
|
+
"@types/node": "^20.14.9",
|
|
55
32
|
"@vitest/coverage-v8": "^4.0.5",
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
},
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
}
|
|
64
|
-
"author": "MCP-I Team",
|
|
65
|
-
"license": "MIT",
|
|
66
|
-
"repository": {
|
|
67
|
-
"type": "git",
|
|
68
|
-
"url": "git+https://github.com/modelcontextprotocol-identity/mcp-i.git"
|
|
69
|
-
},
|
|
70
|
-
"bugs": {
|
|
71
|
-
"url": "https://github.com/modelcontextprotocol-identity/mcp-i/issues"
|
|
72
|
-
},
|
|
73
|
-
"homepage": "https://github.com/modelcontextprotocol-identity/mcp-i#readme"
|
|
33
|
+
"dotenv": "^16.3.1",
|
|
34
|
+
"eslint": "^8.57.0",
|
|
35
|
+
"typescript": "^5.5.3",
|
|
36
|
+
"vitest": "^4.0.5"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
}
|
|
74
41
|
}
|