@kya-os/contracts 1.5.3-canary.16 → 1.5.3-canary.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +17 -0
- package/.turbo/turbo-test$colon$coverage.log +85 -0
- package/.turbo/turbo-test.log +32 -0
- package/coverage/coverage-final.json +38 -0
- package/dist/consent/schemas.d.ts +18 -0
- package/dist/consent/schemas.js +10 -0
- package/dist/dashboard-config/schemas.d.ts +1424 -220
- package/dist/tool-protection/index.d.ts +418 -8
- package/dist/tool-protection/index.js +61 -2
- package/package.json +35 -129
- package/schemas/cli/register-output/v1.0.0.json +69 -0
- package/schemas/identity/v1.0.0.json +46 -0
- package/schemas/proof/v1.0.0.json +80 -0
- package/schemas/registry/receipt-v1.0.0.json +60 -0
- package/schemas/verifier/verify-page/v1.0.0.json +94 -0
- package/schemas/well-known/agent/v1.0.0.json +67 -0
- package/schemas/well-known/did/v1.0.0.json +174 -0
- package/scripts/emit-schemas.js +11 -0
- package/src/agentshield-api/admin-schemas.ts +31 -0
- package/src/agentshield-api/admin-types.ts +47 -0
- package/src/agentshield-api/endpoints.ts +60 -0
- package/src/agentshield-api/index.ts +70 -0
- package/src/agentshield-api/schemas.ts +304 -0
- package/src/agentshield-api/types.ts +317 -0
- package/src/audit/index.ts +128 -0
- package/src/cli.ts +156 -0
- package/src/config/base.ts +107 -0
- package/src/config/builder.ts +97 -0
- package/src/config/delegation.ts +232 -0
- package/src/config/identity.ts +252 -0
- package/src/config/index.ts +78 -0
- package/src/config/proofing.ts +138 -0
- package/src/config/tool-context.ts +41 -0
- package/src/config/tool-protection.ts +174 -0
- package/src/consent/index.ts +32 -0
- package/src/consent/schemas.ts +334 -0
- package/src/consent/types.ts +199 -0
- package/src/dashboard-config/default-config.json +86 -0
- package/src/dashboard-config/default-config.ts +266 -0
- package/src/dashboard-config/index.ts +48 -0
- package/src/dashboard-config/schemas.ts +286 -0
- package/src/dashboard-config/types.ts +404 -0
- package/src/delegation/constraints.ts +267 -0
- package/src/delegation/index.ts +8 -0
- package/src/delegation/schemas.ts +595 -0
- package/src/did/index.ts +9 -0
- package/src/did/resolve-contract.ts +255 -0
- package/src/did/schemas.ts +190 -0
- package/src/did/types.ts +224 -0
- package/src/env/constants.ts +70 -0
- package/src/env/index.ts +5 -0
- package/src/handshake.ts +125 -0
- package/src/index.ts +45 -0
- package/src/proof/index.ts +31 -0
- package/src/proof/proof-record.ts +163 -0
- package/src/proof/signing-spec.ts +146 -0
- package/src/proof.ts +99 -0
- package/src/registry.ts +146 -0
- package/src/runtime/errors.ts +153 -0
- package/src/runtime/headers.ts +136 -0
- package/src/runtime/index.ts +6 -0
- package/src/test.ts +143 -0
- package/src/tlkrc/index.ts +5 -0
- package/src/tlkrc/rotation.ts +153 -0
- package/src/tool-protection/index.ts +343 -0
- package/src/utils/validation.ts +93 -0
- package/src/vc/index.ts +8 -0
- package/src/vc/schemas.ts +277 -0
- package/src/vc/statuslist.ts +279 -0
- package/src/verifier.ts +92 -0
- package/src/well-known/index.ts +237 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration Builder Utilities
|
|
3
|
+
*
|
|
4
|
+
* Shared utilities for building MCP-I configuration objects with sensible defaults.
|
|
5
|
+
* These functions are platform-agnostic and can be used by any adapter/platform.
|
|
6
|
+
*
|
|
7
|
+
* @module @kya-os/contracts/config
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { MCPIBaseConfig } from './base.js';
|
|
11
|
+
import type { RuntimeIdentityConfig } from './identity.js';
|
|
12
|
+
import type { ProofingConfig } from './proofing.js';
|
|
13
|
+
import type { DelegationConfig, DelegationVerifierConfig, AuthorizationConfig } from './delegation.js';
|
|
14
|
+
import type { ToolProtectionSourceConfig } from './tool-protection.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Complete runtime configuration type
|
|
18
|
+
* This can be extended by platform-specific configs
|
|
19
|
+
*/
|
|
20
|
+
export interface MCPIConfig extends MCPIBaseConfig {
|
|
21
|
+
identity?: RuntimeIdentityConfig;
|
|
22
|
+
proofing?: ProofingConfig;
|
|
23
|
+
delegation?: DelegationConfig;
|
|
24
|
+
toolProtection?: ToolProtectionSourceConfig;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Build base MCPIConfig that works across all platforms
|
|
29
|
+
*
|
|
30
|
+
* Creates a platform-agnostic configuration object with sensible defaults
|
|
31
|
+
* for identity, proofing, delegation, audit, and session management.
|
|
32
|
+
*
|
|
33
|
+
* @param env - Environment variables object (works with process.env or Cloudflare env)
|
|
34
|
+
* @returns Complete MCPIConfig object
|
|
35
|
+
*/
|
|
36
|
+
export function buildBaseConfig(env: Record<string, any>): MCPIConfig {
|
|
37
|
+
const environment = (env.MCPI_ENV || env.ENVIRONMENT || 'development') as 'development' | 'production';
|
|
38
|
+
const isDevelopment = environment === 'development';
|
|
39
|
+
|
|
40
|
+
const baseConfig: MCPIConfig = {
|
|
41
|
+
environment,
|
|
42
|
+
|
|
43
|
+
identity: {
|
|
44
|
+
enabled: true,
|
|
45
|
+
environment,
|
|
46
|
+
devIdentityPath: '.mcpi/identity.json'
|
|
47
|
+
} as RuntimeIdentityConfig,
|
|
48
|
+
|
|
49
|
+
proofing: {
|
|
50
|
+
enabled: true,
|
|
51
|
+
batchQueue: {
|
|
52
|
+
destinations: [
|
|
53
|
+
{
|
|
54
|
+
type: 'agentshield' as const,
|
|
55
|
+
apiUrl: env.AGENTSHIELD_API_URL || 'https://kya.vouched.id',
|
|
56
|
+
apiKey: env.AGENTSHIELD_API_KEY
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
maxBatchSize: 10,
|
|
60
|
+
flushIntervalMs: 5000,
|
|
61
|
+
maxRetries: 3,
|
|
62
|
+
debug: isDevelopment
|
|
63
|
+
}
|
|
64
|
+
} as ProofingConfig,
|
|
65
|
+
|
|
66
|
+
delegation: {
|
|
67
|
+
enabled: true,
|
|
68
|
+
enforceDelegations: true,
|
|
69
|
+
verifier: {
|
|
70
|
+
type: 'agentshield' as const,
|
|
71
|
+
apiUrl: env.AGENTSHIELD_API_URL || 'https://kya.vouched.id',
|
|
72
|
+
apiKey: env.AGENTSHIELD_API_KEY || '',
|
|
73
|
+
cacheTtl: 60000, // 1 minute cache
|
|
74
|
+
debug: isDevelopment
|
|
75
|
+
} as DelegationVerifierConfig,
|
|
76
|
+
authorization: {
|
|
77
|
+
authorizationUrl: env.AUTHORIZATION_URL || `${env.AGENTSHIELD_API_URL || 'https://kya.vouched.id'}/authorize`,
|
|
78
|
+
resumeTokenTtl: 600000, // 10 minutes
|
|
79
|
+
minReputationScore: 76
|
|
80
|
+
} as AuthorizationConfig
|
|
81
|
+
} as DelegationConfig,
|
|
82
|
+
|
|
83
|
+
audit: {
|
|
84
|
+
enabled: true,
|
|
85
|
+
includeProofHashes: false,
|
|
86
|
+
includePayloads: false
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
session: {
|
|
90
|
+
timestampSkewSeconds: 120,
|
|
91
|
+
ttlMinutes: 30
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
return baseConfig;
|
|
96
|
+
}
|
|
97
|
+
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delegation Configuration Types
|
|
3
|
+
*
|
|
4
|
+
* Configuration for delegation verification, authorization flows,
|
|
5
|
+
* and consent management in MCP-I.
|
|
6
|
+
*
|
|
7
|
+
* @module @kya-os/contracts/config
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Delegation verifier types
|
|
12
|
+
*/
|
|
13
|
+
export type DelegationVerifierType =
|
|
14
|
+
| 'agentshield' // AgentShield API
|
|
15
|
+
| 'kta' // Know That AI
|
|
16
|
+
| 'memory' // In-memory (development)
|
|
17
|
+
| 'cloudflare-kv' // Cloudflare KV storage
|
|
18
|
+
| 'redis' // Redis cache
|
|
19
|
+
| 'dynamodb' // AWS DynamoDB
|
|
20
|
+
| 'custom'; // Custom implementation
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Delegation verifier configuration
|
|
24
|
+
* Controls how delegations are verified and cached
|
|
25
|
+
*/
|
|
26
|
+
export interface DelegationVerifierConfig {
|
|
27
|
+
/**
|
|
28
|
+
* Type of verifier to use
|
|
29
|
+
*/
|
|
30
|
+
type: DelegationVerifierType;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* API URL for remote verifiers (agentshield, kta)
|
|
34
|
+
* @example 'https://kya.vouched.id'
|
|
35
|
+
*/
|
|
36
|
+
apiUrl?: string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* API key for authentication with remote verifiers
|
|
40
|
+
*/
|
|
41
|
+
apiKey?: string;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Cache time-to-live in milliseconds
|
|
45
|
+
* How long to cache delegation verification results
|
|
46
|
+
* @default 300000 (5 minutes)
|
|
47
|
+
*/
|
|
48
|
+
cacheTtl?: number;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Custom verifier implementation
|
|
52
|
+
* Required when type is 'custom'
|
|
53
|
+
*/
|
|
54
|
+
customVerifier?: {
|
|
55
|
+
verify: (agentDid: string, scopes: string[]) => Promise<boolean>;
|
|
56
|
+
invalidate?: (agentDid: string) => Promise<void>;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Additional verifier-specific options
|
|
61
|
+
*/
|
|
62
|
+
options?: Record<string, unknown>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Authorization configuration
|
|
67
|
+
* Controls consent flows and authorization requirements
|
|
68
|
+
*/
|
|
69
|
+
export interface AuthorizationConfig {
|
|
70
|
+
/**
|
|
71
|
+
* Base URL for authorization/consent flow
|
|
72
|
+
* Users are redirected here when delegation is required
|
|
73
|
+
* @example 'https://kya.vouched.id/bouncer/consent'
|
|
74
|
+
*/
|
|
75
|
+
authorizationUrl?: string;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* KTA (Know That AI) configuration for reputation checks
|
|
79
|
+
*/
|
|
80
|
+
kta?: {
|
|
81
|
+
/**
|
|
82
|
+
* KTA API base URL
|
|
83
|
+
*/
|
|
84
|
+
apiUrl: string;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* API key for KTA
|
|
88
|
+
*/
|
|
89
|
+
apiKey?: string;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Minimum reputation score to bypass authorization
|
|
94
|
+
* Agents with reputation above this threshold don't need explicit consent
|
|
95
|
+
* Range: 0-100
|
|
96
|
+
* @default 80
|
|
97
|
+
*/
|
|
98
|
+
minReputationScore?: number;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Resume token TTL in milliseconds
|
|
102
|
+
* How long a resume token remains valid
|
|
103
|
+
* @default 3600000 (1 hour)
|
|
104
|
+
*/
|
|
105
|
+
resumeTokenTtl?: number;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Require authorization for unknown agents
|
|
109
|
+
* If false, unknown agents are allowed by default
|
|
110
|
+
* @default true
|
|
111
|
+
*/
|
|
112
|
+
requireAuthForUnknown?: boolean;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Custom authorization URL builder
|
|
116
|
+
* Allows customization of consent URL generation
|
|
117
|
+
*/
|
|
118
|
+
buildAuthUrl?: (toolName: string, scopes: string[], context: any) => string;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Delegation configuration (platform-agnostic)
|
|
123
|
+
*
|
|
124
|
+
* Controls delegation verification, authorization flows, and
|
|
125
|
+
* tool protection enforcement.
|
|
126
|
+
*/
|
|
127
|
+
export interface DelegationConfig {
|
|
128
|
+
/**
|
|
129
|
+
* Enable delegation features
|
|
130
|
+
* When false, all tools are accessible without delegation
|
|
131
|
+
* @default false (for backward compatibility)
|
|
132
|
+
*/
|
|
133
|
+
enabled: boolean;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Enforce delegation requirements strictly
|
|
137
|
+
* When true, tools requiring delegation will fail without valid delegation
|
|
138
|
+
* When false, logs warnings but allows execution
|
|
139
|
+
* @default true in production, false in development
|
|
140
|
+
*/
|
|
141
|
+
enforceDelegations?: boolean;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Delegation verifier configuration
|
|
145
|
+
* Controls how delegations are verified
|
|
146
|
+
*/
|
|
147
|
+
verifier: DelegationVerifierConfig;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Authorization configuration
|
|
151
|
+
* Controls consent flows and reputation checks
|
|
152
|
+
*/
|
|
153
|
+
authorization?: AuthorizationConfig;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Enable debug logging for delegation operations
|
|
157
|
+
* @default false
|
|
158
|
+
*/
|
|
159
|
+
debug?: boolean;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Delegation record structure
|
|
164
|
+
* Represents a delegation from a user to an agent
|
|
165
|
+
*/
|
|
166
|
+
export interface DelegationRecord {
|
|
167
|
+
/**
|
|
168
|
+
* Unique identifier for this delegation
|
|
169
|
+
*/
|
|
170
|
+
id: string;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* User who granted the delegation
|
|
174
|
+
*/
|
|
175
|
+
userId: string;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Agent DID receiving the delegation
|
|
179
|
+
*/
|
|
180
|
+
agentDid: string;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Scopes granted in this delegation
|
|
184
|
+
* @example ['files:read', 'files:write']
|
|
185
|
+
*/
|
|
186
|
+
scopes: string[];
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* ISO 8601 timestamp when delegation was created
|
|
190
|
+
*/
|
|
191
|
+
createdAt: string;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* ISO 8601 timestamp when delegation expires
|
|
195
|
+
*/
|
|
196
|
+
expiresAt?: string;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Whether this delegation has been revoked
|
|
200
|
+
*/
|
|
201
|
+
revoked?: boolean;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Additional constraints on the delegation
|
|
205
|
+
*/
|
|
206
|
+
constraints?: {
|
|
207
|
+
/**
|
|
208
|
+
* IP addresses allowed to use this delegation
|
|
209
|
+
*/
|
|
210
|
+
allowedIps?: string[];
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Origins allowed to use this delegation
|
|
214
|
+
*/
|
|
215
|
+
allowedOrigins?: string[];
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Maximum number of uses
|
|
219
|
+
*/
|
|
220
|
+
maxUses?: number;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Current number of uses
|
|
224
|
+
*/
|
|
225
|
+
currentUses?: number;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Additional custom constraints
|
|
229
|
+
*/
|
|
230
|
+
[key: string]: unknown;
|
|
231
|
+
};
|
|
232
|
+
}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity Configuration Types
|
|
3
|
+
*
|
|
4
|
+
* Configuration for MCP-I identity management including DID generation,
|
|
5
|
+
* key management, and environment-specific settings.
|
|
6
|
+
*
|
|
7
|
+
* @module @kya-os/contracts/config
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Runtime Identity Configuration
|
|
14
|
+
*
|
|
15
|
+
* Configuration for MCP-I identity management at runtime.
|
|
16
|
+
* Used in application configs (mcpi-runtime-config.ts)
|
|
17
|
+
*
|
|
18
|
+
* Controls how agent identity is managed, including key generation,
|
|
19
|
+
* storage, and DID creation.
|
|
20
|
+
*/
|
|
21
|
+
export interface RuntimeIdentityConfig {
|
|
22
|
+
/**
|
|
23
|
+
* Enable identity features
|
|
24
|
+
* When false, the agent operates anonymously without DID/keys
|
|
25
|
+
*/
|
|
26
|
+
enabled: boolean;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Runtime environment for identity
|
|
30
|
+
* Determines where keys come from and how they're managed
|
|
31
|
+
*/
|
|
32
|
+
environment: "development" | "production";
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Production identity configuration
|
|
36
|
+
* Used when environment is 'production'
|
|
37
|
+
*/
|
|
38
|
+
production?: {
|
|
39
|
+
/**
|
|
40
|
+
* Environment variable name containing the private key
|
|
41
|
+
* @example 'MCPI_PRIVATE_KEY'
|
|
42
|
+
*/
|
|
43
|
+
privateKeyEnv?: string;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Environment variable name containing the public key
|
|
47
|
+
* @example 'MCPI_PUBLIC_KEY'
|
|
48
|
+
*/
|
|
49
|
+
publicKeyEnv?: string;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Environment variable name containing the DID
|
|
53
|
+
* @example 'MCPI_AGENT_DID'
|
|
54
|
+
*/
|
|
55
|
+
didEnv?: string;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Privacy mode - minimizes identity disclosure
|
|
60
|
+
* When true, identity is only revealed when absolutely necessary
|
|
61
|
+
* @default false
|
|
62
|
+
*/
|
|
63
|
+
privacyMode?: boolean;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Enable debug logging for identity operations
|
|
67
|
+
* WARNING: May log sensitive information
|
|
68
|
+
* @default false
|
|
69
|
+
*/
|
|
70
|
+
debug?: boolean;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Enable automatic user DID generation on chat join
|
|
74
|
+
* When true, generates ephemeral did:key DIDs for users when they join a session
|
|
75
|
+
* @default false
|
|
76
|
+
*/
|
|
77
|
+
generateUserDids?: boolean;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* User DID storage strategy
|
|
81
|
+
* - 'ephemeral': User DIDs are not persisted (default, did:key)
|
|
82
|
+
* - 'persistent': User DIDs are persisted in storage (requires did:web setup)
|
|
83
|
+
* @default 'ephemeral'
|
|
84
|
+
*/
|
|
85
|
+
userDidStorage?: "ephemeral" | "persistent";
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* OAuth Provider Configuration
|
|
90
|
+
*
|
|
91
|
+
* Configuration for a single OAuth provider (GitHub, Google, etc.)
|
|
92
|
+
*/
|
|
93
|
+
export interface OAuthProvider {
|
|
94
|
+
/** OAuth client ID (public, safe to expose) */
|
|
95
|
+
clientId: string;
|
|
96
|
+
|
|
97
|
+
/** OAuth client secret (NOT returned in API response for security) */
|
|
98
|
+
clientSecret?: string | null;
|
|
99
|
+
|
|
100
|
+
/** OAuth authorization URL */
|
|
101
|
+
authorizationUrl: string;
|
|
102
|
+
|
|
103
|
+
/** OAuth token exchange URL */
|
|
104
|
+
tokenUrl: string;
|
|
105
|
+
|
|
106
|
+
/** OAuth user info endpoint URL */
|
|
107
|
+
userInfoUrl?: string;
|
|
108
|
+
|
|
109
|
+
/** Whether provider supports PKCE (Proof Key for Code Exchange) */
|
|
110
|
+
supportsPKCE: boolean;
|
|
111
|
+
|
|
112
|
+
/** Whether provider requires client secret (false for PKCE-only providers) */
|
|
113
|
+
requiresClientSecret: boolean;
|
|
114
|
+
|
|
115
|
+
/** Available scopes for this provider */
|
|
116
|
+
scopes?: string[];
|
|
117
|
+
|
|
118
|
+
/** Default scopes to request */
|
|
119
|
+
defaultScopes?: string[];
|
|
120
|
+
|
|
121
|
+
/** Whether provider uses proxy mode (via AgentShield) */
|
|
122
|
+
proxyMode?: boolean;
|
|
123
|
+
|
|
124
|
+
// Phase 3: Custom IDP Support
|
|
125
|
+
/** Custom OAuth parameters to include in authorization URL (e.g., audience, acr_values) */
|
|
126
|
+
customParams?: Record<string, string>;
|
|
127
|
+
|
|
128
|
+
/** Token endpoint authentication method */
|
|
129
|
+
tokenEndpointAuthMethod?: "client_secret_post" | "client_secret_basic";
|
|
130
|
+
|
|
131
|
+
/** OAuth response type (default: "code") */
|
|
132
|
+
responseType?: string;
|
|
133
|
+
|
|
134
|
+
/** OAuth grant type (default: "authorization_code") */
|
|
135
|
+
grantType?: string;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* OAuth Configuration
|
|
140
|
+
*
|
|
141
|
+
* Configuration for OAuth providers fetched from AgentShield API.
|
|
142
|
+
* Contains all available providers for a project.
|
|
143
|
+
*
|
|
144
|
+
* Note: API does NOT return a defaultProvider field (Phase 1 architecture).
|
|
145
|
+
* Phase 1 uses configured provider as temporary fallback.
|
|
146
|
+
* Phase 2+ requires tools to explicitly specify oauthProvider.
|
|
147
|
+
*/
|
|
148
|
+
export interface OAuthConfig {
|
|
149
|
+
/** Map of provider names to provider configurations */
|
|
150
|
+
providers: Record<string, OAuthProvider>;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Zod schema for OAuthProvider validation
|
|
155
|
+
*/
|
|
156
|
+
export const OAuthProviderSchema = z.object({
|
|
157
|
+
clientId: z.string().min(1),
|
|
158
|
+
clientSecret: z.string().nullable().optional(),
|
|
159
|
+
authorizationUrl: z.string().url(),
|
|
160
|
+
tokenUrl: z.string().url(),
|
|
161
|
+
userInfoUrl: z.string().url().optional(),
|
|
162
|
+
supportsPKCE: z.boolean(),
|
|
163
|
+
requiresClientSecret: z.boolean(),
|
|
164
|
+
scopes: z.array(z.string()).optional(),
|
|
165
|
+
defaultScopes: z.array(z.string()).optional(),
|
|
166
|
+
proxyMode: z.boolean().optional(),
|
|
167
|
+
// Phase 3: Custom IDP Support
|
|
168
|
+
customParams: z.record(z.string()).optional(),
|
|
169
|
+
tokenEndpointAuthMethod: z.enum(["client_secret_post", "client_secret_basic"]).optional(),
|
|
170
|
+
responseType: z.string().optional().default("code"),
|
|
171
|
+
grantType: z.string().optional().default("authorization_code"),
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Zod schema for OAuthConfig validation
|
|
176
|
+
*/
|
|
177
|
+
export const OAuthConfigSchema = z.object({
|
|
178
|
+
providers: z.record(z.string(), OAuthProviderSchema),
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* IDP Tokens
|
|
183
|
+
*
|
|
184
|
+
* Tokens received from OAuth provider (IDP = Identity Provider)
|
|
185
|
+
*/
|
|
186
|
+
export interface IdpTokens {
|
|
187
|
+
/** OAuth access token for API calls */
|
|
188
|
+
access_token: string;
|
|
189
|
+
|
|
190
|
+
/** OAuth refresh token (optional) */
|
|
191
|
+
refresh_token?: string;
|
|
192
|
+
|
|
193
|
+
/** Token expiration time in seconds */
|
|
194
|
+
expires_in?: number;
|
|
195
|
+
|
|
196
|
+
/** Token expiration timestamp (milliseconds since epoch) */
|
|
197
|
+
expires_at: number;
|
|
198
|
+
|
|
199
|
+
/** Token type (usually "Bearer") */
|
|
200
|
+
token_type: string;
|
|
201
|
+
|
|
202
|
+
/** Granted scopes */
|
|
203
|
+
scope?: string;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Agent identity representation
|
|
208
|
+
* The actual identity data structure used at runtime
|
|
209
|
+
*/
|
|
210
|
+
export interface AgentIdentity {
|
|
211
|
+
/**
|
|
212
|
+
* Decentralized Identifier
|
|
213
|
+
* @example 'did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK'
|
|
214
|
+
*/
|
|
215
|
+
did: string;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Base64-encoded public key
|
|
219
|
+
*/
|
|
220
|
+
publicKey: string;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Base64-encoded private key
|
|
224
|
+
* NOTE: Should be kept secure and never logged
|
|
225
|
+
*/
|
|
226
|
+
privateKey: string;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* ISO 8601 timestamp of when the identity was created
|
|
230
|
+
*/
|
|
231
|
+
createdAt: string;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Optional metadata about the identity
|
|
235
|
+
*/
|
|
236
|
+
metadata?: {
|
|
237
|
+
/**
|
|
238
|
+
* Human-readable name for this identity
|
|
239
|
+
*/
|
|
240
|
+
name?: string;
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Version of the identity format
|
|
244
|
+
*/
|
|
245
|
+
version?: string;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Additional custom properties
|
|
249
|
+
*/
|
|
250
|
+
[key: string]: unknown;
|
|
251
|
+
};
|
|
252
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration Type Exports
|
|
3
|
+
*
|
|
4
|
+
* Central export point for all configuration types in the contracts package.
|
|
5
|
+
* These types form the foundation of XMCP-I's configuration architecture.
|
|
6
|
+
*
|
|
7
|
+
* @module @kya-os/contracts/config
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// Import types for the interface
|
|
11
|
+
import type { MCPIBaseConfig } from "./base.js";
|
|
12
|
+
import type { RuntimeIdentityConfig } from "./identity.js";
|
|
13
|
+
import type { ProofingConfig } from "./proofing.js";
|
|
14
|
+
import type { DelegationConfig } from "./delegation.js";
|
|
15
|
+
import type { ToolProtectionSourceConfig } from "./tool-protection.js";
|
|
16
|
+
|
|
17
|
+
// Base configuration
|
|
18
|
+
export { MCPIBaseConfig } from "./base.js";
|
|
19
|
+
|
|
20
|
+
// Identity configuration
|
|
21
|
+
export {
|
|
22
|
+
RuntimeIdentityConfig,
|
|
23
|
+
AgentIdentity,
|
|
24
|
+
OAuthProvider,
|
|
25
|
+
OAuthConfig,
|
|
26
|
+
IdpTokens,
|
|
27
|
+
} from "./identity.js";
|
|
28
|
+
|
|
29
|
+
// Tool execution context
|
|
30
|
+
export type { ToolExecutionContext } from "./tool-context.js";
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated Use RuntimeIdentityConfig instead
|
|
34
|
+
* This export is maintained for backward compatibility
|
|
35
|
+
*/
|
|
36
|
+
export type IdentityConfig = RuntimeIdentityConfig;
|
|
37
|
+
|
|
38
|
+
// Proofing configuration
|
|
39
|
+
export {
|
|
40
|
+
ProofingConfig,
|
|
41
|
+
ProofBatchQueueConfig,
|
|
42
|
+
ProofDestination,
|
|
43
|
+
ProofDestinationType,
|
|
44
|
+
} from "./proofing.js";
|
|
45
|
+
|
|
46
|
+
// Delegation configuration
|
|
47
|
+
export {
|
|
48
|
+
DelegationConfig,
|
|
49
|
+
DelegationVerifierConfig,
|
|
50
|
+
DelegationVerifierType,
|
|
51
|
+
AuthorizationConfig,
|
|
52
|
+
DelegationRecord,
|
|
53
|
+
} from "./delegation.js";
|
|
54
|
+
|
|
55
|
+
// Tool protection configuration
|
|
56
|
+
export {
|
|
57
|
+
ToolProtection,
|
|
58
|
+
ToolProtectionMap,
|
|
59
|
+
ToolProtectionSourceConfig,
|
|
60
|
+
ToolProtectionSourceType,
|
|
61
|
+
ToolProtectionServiceConfig,
|
|
62
|
+
DelegationRequiredErrorData,
|
|
63
|
+
ToolProtectionResponse,
|
|
64
|
+
} from "./tool-protection.js";
|
|
65
|
+
|
|
66
|
+
// Configuration builder utilities
|
|
67
|
+
export { buildBaseConfig } from "./builder.js";
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Complete runtime configuration type
|
|
71
|
+
* This can be extended by platform-specific configs
|
|
72
|
+
*/
|
|
73
|
+
export interface MCPIConfig extends MCPIBaseConfig {
|
|
74
|
+
identity?: RuntimeIdentityConfig;
|
|
75
|
+
proofing?: ProofingConfig;
|
|
76
|
+
delegation?: DelegationConfig;
|
|
77
|
+
toolProtection?: ToolProtectionSourceConfig;
|
|
78
|
+
}
|