@kya-os/contracts 1.6.2-canary.0 → 1.6.3-canary.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/dist/agentshield-api/admin-schemas.d.ts +2 -2
- package/dist/agentshield-api/endpoints.d.ts +3 -0
- package/dist/agentshield-api/endpoints.js +3 -0
- package/dist/agentshield-api/index.d.ts +2 -2
- package/dist/agentshield-api/index.js +7 -1
- package/dist/agentshield-api/schemas.d.ts +284 -93
- package/dist/agentshield-api/schemas.js +52 -5
- package/dist/agentshield-api/types.d.ts +69 -4
- package/dist/audit/index.d.ts +193 -0
- package/dist/audit/index.js +100 -0
- package/dist/config/identity.d.ts +214 -2
- package/dist/config/identity.js +29 -0
- package/dist/config/index.d.ts +2 -1
- package/dist/config/tool-context.d.ts +34 -0
- package/dist/config/tool-context.js +13 -0
- package/dist/consent/schemas.d.ts +166 -71
- package/dist/consent/schemas.js +39 -1
- package/dist/dashboard-config/index.d.ts +2 -2
- package/dist/dashboard-config/index.js +4 -1
- package/dist/dashboard-config/schemas.d.ts +6227 -1536
- package/dist/dashboard-config/schemas.js +23 -1
- package/dist/dashboard-config/types.d.ts +28 -1
- package/dist/handshake.d.ts +14 -14
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/tool-protection/index.d.ts +482 -6
- package/dist/tool-protection/index.js +89 -2
- package/dist/verifier/index.d.ts +1 -0
- package/dist/verifier/index.js +18 -0
- package/dist/well-known/index.d.ts +2 -2
- package/package.json +66 -119
|
@@ -9,11 +9,13 @@
|
|
|
9
9
|
* @module @kya-os/contracts/tool-protection
|
|
10
10
|
*/
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.DelegationRequiredErrorDataSchema = exports.ToolProtectionResponseSchema = exports.ToolProtectionMapSchema = exports.ToolProtectionSchema = void 0;
|
|
12
|
+
exports.DelegationRequiredErrorDataSchema = exports.ToolProtectionResponseSchema = exports.ToolProtectionMapSchema = exports.ToolProtectionSchema = exports.AuthorizationRequirementSchema = void 0;
|
|
13
13
|
exports.isToolProtection = isToolProtection;
|
|
14
14
|
exports.isToolProtectionMap = isToolProtectionMap;
|
|
15
15
|
exports.isToolProtectionResponse = isToolProtectionResponse;
|
|
16
16
|
exports.isDelegationRequiredErrorData = isDelegationRequiredErrorData;
|
|
17
|
+
exports.isAuthorizationRequirement = isAuthorizationRequirement;
|
|
18
|
+
exports.hasOAuthAuthorization = hasOAuthAuthorization;
|
|
17
19
|
exports.validateToolProtection = validateToolProtection;
|
|
18
20
|
exports.validateToolProtectionMap = validateToolProtectionMap;
|
|
19
21
|
exports.validateToolProtectionResponse = validateToolProtectionResponse;
|
|
@@ -22,14 +24,42 @@ exports.toolRequiresDelegation = toolRequiresDelegation;
|
|
|
22
24
|
exports.getToolRequiredScopes = getToolRequiredScopes;
|
|
23
25
|
exports.getToolRiskLevel = getToolRiskLevel;
|
|
24
26
|
exports.createDelegationRequiredError = createDelegationRequiredError;
|
|
27
|
+
exports.normalizeToolProtection = normalizeToolProtection;
|
|
25
28
|
const zod_1 = require("zod");
|
|
26
29
|
/**
|
|
27
30
|
* Zod Schemas for Validation
|
|
28
31
|
*/
|
|
32
|
+
exports.AuthorizationRequirementSchema = zod_1.z.discriminatedUnion('type', [
|
|
33
|
+
zod_1.z.object({
|
|
34
|
+
type: zod_1.z.literal('oauth'),
|
|
35
|
+
provider: zod_1.z.string(),
|
|
36
|
+
requiredScopes: zod_1.z.array(zod_1.z.string()).optional(),
|
|
37
|
+
}),
|
|
38
|
+
zod_1.z.object({
|
|
39
|
+
type: zod_1.z.literal('mdl'),
|
|
40
|
+
issuer: zod_1.z.string(),
|
|
41
|
+
credentialType: zod_1.z.string().optional(),
|
|
42
|
+
}),
|
|
43
|
+
zod_1.z.object({
|
|
44
|
+
type: zod_1.z.literal('idv'),
|
|
45
|
+
provider: zod_1.z.string(),
|
|
46
|
+
verificationLevel: zod_1.z.enum(['basic', 'enhanced', 'loa3']).optional(),
|
|
47
|
+
}),
|
|
48
|
+
zod_1.z.object({
|
|
49
|
+
type: zod_1.z.literal('credential'),
|
|
50
|
+
credentialType: zod_1.z.string(),
|
|
51
|
+
issuer: zod_1.z.string().optional(),
|
|
52
|
+
}),
|
|
53
|
+
zod_1.z.object({
|
|
54
|
+
type: zod_1.z.literal('none'),
|
|
55
|
+
}),
|
|
56
|
+
]);
|
|
29
57
|
exports.ToolProtectionSchema = zod_1.z.object({
|
|
30
58
|
requiresDelegation: zod_1.z.boolean(),
|
|
31
59
|
requiredScopes: zod_1.z.array(zod_1.z.string()),
|
|
32
|
-
riskLevel: zod_1.z.enum(['low', 'medium', 'high', 'critical']).optional()
|
|
60
|
+
riskLevel: zod_1.z.enum(['low', 'medium', 'high', 'critical']).optional(),
|
|
61
|
+
oauthProvider: zod_1.z.string().optional(), // Phase 2: Tool-specific OAuth provider
|
|
62
|
+
authorization: exports.AuthorizationRequirementSchema.optional(),
|
|
33
63
|
});
|
|
34
64
|
exports.ToolProtectionMapSchema = zod_1.z.record(zod_1.z.string(), exports.ToolProtectionSchema);
|
|
35
65
|
exports.ToolProtectionResponseSchema = zod_1.z.object({
|
|
@@ -62,6 +92,18 @@ function isToolProtectionResponse(obj) {
|
|
|
62
92
|
function isDelegationRequiredErrorData(obj) {
|
|
63
93
|
return exports.DelegationRequiredErrorDataSchema.safeParse(obj).success;
|
|
64
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Type guard to check if an object is a valid AuthorizationRequirement
|
|
97
|
+
*/
|
|
98
|
+
function isAuthorizationRequirement(obj) {
|
|
99
|
+
return exports.AuthorizationRequirementSchema.safeParse(obj).success;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Type guard to check if a ToolProtection has OAuth authorization
|
|
103
|
+
*/
|
|
104
|
+
function hasOAuthAuthorization(protection) {
|
|
105
|
+
return protection.authorization?.type === 'oauth';
|
|
106
|
+
}
|
|
65
107
|
/**
|
|
66
108
|
* Validation Functions
|
|
67
109
|
*/
|
|
@@ -111,3 +153,48 @@ function createDelegationRequiredError(toolName, requiredScopes, consentUrl) {
|
|
|
111
153
|
authorizationUrl: consentUrl // Include both for compatibility
|
|
112
154
|
};
|
|
113
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* Normalize tool protection configuration
|
|
158
|
+
* Migrates legacy oauthProvider field to authorization object
|
|
159
|
+
*
|
|
160
|
+
* - Migrates `oauthProvider` → `authorization: { type: 'oauth', provider: ... }`
|
|
161
|
+
* - Ensures `authorization` field is present when `requiresDelegation=true`
|
|
162
|
+
* - Returns fully normalized ToolProtection object
|
|
163
|
+
*
|
|
164
|
+
* @param raw - Raw tool protection data (may have legacy fields or be partial)
|
|
165
|
+
* @returns Normalized ToolProtection object
|
|
166
|
+
*
|
|
167
|
+
* // TODO: Remove normalizeToolProtection() when all tools migrated (target: Phase 3)
|
|
168
|
+
*/
|
|
169
|
+
function normalizeToolProtection(raw) {
|
|
170
|
+
// Ensure we have required fields (provide defaults for partial input)
|
|
171
|
+
const normalized = {
|
|
172
|
+
requiresDelegation: raw.requiresDelegation ?? false,
|
|
173
|
+
requiredScopes: raw.requiredScopes ?? [],
|
|
174
|
+
...(raw.riskLevel && { riskLevel: raw.riskLevel }),
|
|
175
|
+
...(raw.oauthProvider && { oauthProvider: raw.oauthProvider }),
|
|
176
|
+
};
|
|
177
|
+
// If authorization is already present, use it
|
|
178
|
+
if (raw.authorization) {
|
|
179
|
+
normalized.authorization = raw.authorization;
|
|
180
|
+
return normalized;
|
|
181
|
+
}
|
|
182
|
+
// Migrate oauthProvider to authorization
|
|
183
|
+
if (raw.oauthProvider) {
|
|
184
|
+
normalized.authorization = {
|
|
185
|
+
type: 'oauth',
|
|
186
|
+
provider: raw.oauthProvider,
|
|
187
|
+
};
|
|
188
|
+
// Keep oauthProvider for backward compatibility until Phase 3
|
|
189
|
+
return normalized;
|
|
190
|
+
}
|
|
191
|
+
// Default for requiresDelegation=true without specific auth: type='none' (consent only)
|
|
192
|
+
// But ONLY if authorization is missing entirely
|
|
193
|
+
if (normalized.requiresDelegation && !normalized.authorization && !normalized.oauthProvider) {
|
|
194
|
+
// We don't automatically set type='none' here to allow
|
|
195
|
+
// ProviderResolver to do its scope inference fallback logic.
|
|
196
|
+
// The fallback logic will eventually be moved into an AuthorizationService.
|
|
197
|
+
return normalized;
|
|
198
|
+
}
|
|
199
|
+
return normalized;
|
|
200
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../verifier";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
// Re-export everything from the main verifier file
|
|
18
|
+
__exportStar(require("../verifier"), exports);
|
|
@@ -209,12 +209,12 @@ export declare const AgentDocumentSchema: z.ZodObject<{
|
|
|
209
209
|
description?: string | undefined;
|
|
210
210
|
}>>;
|
|
211
211
|
}, "strip", z.ZodTypeAny, {
|
|
212
|
+
id: string;
|
|
212
213
|
capabilities: {
|
|
213
214
|
'mcp-i': ("handshake" | "signing" | "verification" | "delegation" | "proof-generation")[];
|
|
214
215
|
} & {
|
|
215
216
|
[k: string]: string[];
|
|
216
217
|
};
|
|
217
|
-
id: string;
|
|
218
218
|
metadata?: {
|
|
219
219
|
version?: string | undefined;
|
|
220
220
|
name?: string | undefined;
|
|
@@ -222,12 +222,12 @@ export declare const AgentDocumentSchema: z.ZodObject<{
|
|
|
222
222
|
description?: string | undefined;
|
|
223
223
|
} | undefined;
|
|
224
224
|
}, {
|
|
225
|
+
id: string;
|
|
225
226
|
capabilities: {
|
|
226
227
|
'mcp-i': ("handshake" | "signing" | "verification" | "delegation" | "proof-generation")[];
|
|
227
228
|
} & {
|
|
228
229
|
[k: string]: string[];
|
|
229
230
|
};
|
|
230
|
-
id: string;
|
|
231
231
|
metadata?: {
|
|
232
232
|
version?: string | undefined;
|
|
233
233
|
name?: string | undefined;
|
package/package.json
CHANGED
|
@@ -1,156 +1,103 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kya-os/contracts",
|
|
3
|
-
"version": "1.6.
|
|
4
|
-
"description": "Shared types and schemas for
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"main": "./dist/index.js",
|
|
8
|
-
"types": "./dist/index.d.ts",
|
|
3
|
+
"version": "1.6.3-canary.0",
|
|
4
|
+
"description": "Shared contracts, types, and schemas for MCP-I framework",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
9
7
|
"exports": {
|
|
10
8
|
".": {
|
|
11
9
|
"types": "./dist/index.d.ts",
|
|
12
|
-
"
|
|
13
|
-
"require": "./dist/index.js"
|
|
14
|
-
},
|
|
15
|
-
"./handshake": {
|
|
16
|
-
"types": "./dist/handshake.d.ts",
|
|
17
|
-
"import": "./dist/handshake.js",
|
|
18
|
-
"require": "./dist/handshake.js"
|
|
19
|
-
},
|
|
20
|
-
"./proof": {
|
|
21
|
-
"types": "./dist/proof/index.d.ts",
|
|
22
|
-
"import": "./dist/proof/index.js",
|
|
23
|
-
"require": "./dist/proof/index.js"
|
|
24
|
-
},
|
|
25
|
-
"./verifier": {
|
|
26
|
-
"types": "./dist/verifier.d.ts",
|
|
27
|
-
"import": "./dist/verifier.js",
|
|
28
|
-
"require": "./dist/verifier.js"
|
|
29
|
-
},
|
|
30
|
-
"./registry": {
|
|
31
|
-
"types": "./dist/registry.d.ts",
|
|
32
|
-
"import": "./dist/registry.js",
|
|
33
|
-
"require": "./dist/registry.js"
|
|
10
|
+
"default": "./dist/index.js"
|
|
34
11
|
},
|
|
35
|
-
"./
|
|
36
|
-
"types": "./dist/
|
|
37
|
-
"
|
|
38
|
-
"require": "./dist/cli.js"
|
|
39
|
-
},
|
|
40
|
-
"./test": {
|
|
41
|
-
"types": "./dist/test.d.ts",
|
|
42
|
-
"import": "./dist/test.js",
|
|
43
|
-
"require": "./dist/test.js"
|
|
44
|
-
},
|
|
45
|
-
"./did": {
|
|
46
|
-
"types": "./dist/did/index.d.ts",
|
|
47
|
-
"import": "./dist/did/index.js",
|
|
48
|
-
"require": "./dist/did/index.js"
|
|
49
|
-
},
|
|
50
|
-
"./vc": {
|
|
51
|
-
"types": "./dist/vc/index.d.ts",
|
|
52
|
-
"import": "./dist/vc/index.js",
|
|
53
|
-
"require": "./dist/vc/index.js"
|
|
12
|
+
"./consent": {
|
|
13
|
+
"types": "./dist/consent/index.d.ts",
|
|
14
|
+
"default": "./dist/consent/index.js"
|
|
54
15
|
},
|
|
55
16
|
"./delegation": {
|
|
56
17
|
"types": "./dist/delegation/index.d.ts",
|
|
57
|
-
"
|
|
58
|
-
|
|
18
|
+
"default": "./dist/delegation/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./agentshield-api": {
|
|
21
|
+
"types": "./dist/agentshield-api/index.d.ts",
|
|
22
|
+
"default": "./dist/agentshield-api/index.js"
|
|
59
23
|
},
|
|
60
24
|
"./runtime": {
|
|
61
25
|
"types": "./dist/runtime/index.d.ts",
|
|
62
|
-
"
|
|
63
|
-
"require": "./dist/runtime/index.js"
|
|
26
|
+
"default": "./dist/runtime/index.js"
|
|
64
27
|
},
|
|
65
|
-
"./
|
|
66
|
-
"types": "./dist/
|
|
67
|
-
"
|
|
68
|
-
"require": "./dist/tlkrc/index.js"
|
|
69
|
-
},
|
|
70
|
-
"./env": {
|
|
71
|
-
"types": "./dist/env/index.d.ts",
|
|
72
|
-
"import": "./dist/env/index.js",
|
|
73
|
-
"require": "./dist/env/index.js"
|
|
74
|
-
},
|
|
75
|
-
"./agentshield-api": {
|
|
76
|
-
"types": "./dist/agentshield-api/index.d.ts",
|
|
77
|
-
"import": "./dist/agentshield-api/index.js",
|
|
78
|
-
"require": "./dist/agentshield-api/index.js"
|
|
28
|
+
"./proof": {
|
|
29
|
+
"types": "./dist/proof/index.d.ts",
|
|
30
|
+
"default": "./dist/proof/index.js"
|
|
79
31
|
},
|
|
80
32
|
"./tool-protection": {
|
|
81
33
|
"types": "./dist/tool-protection/index.d.ts",
|
|
82
|
-
"
|
|
83
|
-
"require": "./dist/tool-protection/index.js"
|
|
84
|
-
},
|
|
85
|
-
"./well-known": {
|
|
86
|
-
"types": "./dist/well-known/index.d.ts",
|
|
87
|
-
"import": "./dist/well-known/index.js",
|
|
88
|
-
"require": "./dist/well-known/index.js"
|
|
34
|
+
"default": "./dist/tool-protection/index.js"
|
|
89
35
|
},
|
|
90
36
|
"./config": {
|
|
91
37
|
"types": "./dist/config/index.d.ts",
|
|
92
|
-
"
|
|
93
|
-
"require": "./dist/config/index.js"
|
|
38
|
+
"default": "./dist/config/index.js"
|
|
94
39
|
},
|
|
95
40
|
"./dashboard-config": {
|
|
96
41
|
"types": "./dist/dashboard-config/index.d.ts",
|
|
97
|
-
"
|
|
98
|
-
"require": "./dist/dashboard-config/index.js"
|
|
42
|
+
"default": "./dist/dashboard-config/index.js"
|
|
99
43
|
},
|
|
100
|
-
"./
|
|
101
|
-
"types": "./dist/
|
|
102
|
-
"
|
|
103
|
-
|
|
44
|
+
"./audit": {
|
|
45
|
+
"types": "./dist/audit/index.d.ts",
|
|
46
|
+
"default": "./dist/audit/index.js"
|
|
47
|
+
},
|
|
48
|
+
"./verifier": {
|
|
49
|
+
"types": "./dist/verifier/index.d.ts",
|
|
50
|
+
"default": "./dist/verifier/index.js"
|
|
51
|
+
},
|
|
52
|
+
"./handshake": {
|
|
53
|
+
"types": "./dist/handshake.d.ts",
|
|
54
|
+
"default": "./dist/handshake.js"
|
|
55
|
+
},
|
|
56
|
+
"./well-known": {
|
|
57
|
+
"types": "./dist/well-known/index.d.ts",
|
|
58
|
+
"default": "./dist/well-known/index.js"
|
|
59
|
+
},
|
|
60
|
+
"./cli": {
|
|
61
|
+
"types": "./dist/cli.d.ts",
|
|
62
|
+
"default": "./dist/cli.js"
|
|
63
|
+
},
|
|
64
|
+
"./test": {
|
|
65
|
+
"types": "./dist/test.d.ts",
|
|
66
|
+
"default": "./dist/test.js"
|
|
67
|
+
},
|
|
68
|
+
"./registry": {
|
|
69
|
+
"types": "./dist/registry.d.ts",
|
|
70
|
+
"default": "./dist/registry.js"
|
|
104
71
|
}
|
|
105
72
|
},
|
|
106
|
-
"files": [
|
|
107
|
-
"dist/**/*.js",
|
|
108
|
-
"dist/**/*.d.ts",
|
|
109
|
-
"!dist/**/*.map",
|
|
110
|
-
"!dist/**/__tests__/**",
|
|
111
|
-
"!dist/**/__fixtures__/**",
|
|
112
|
-
"!dist/**/*.spec.*",
|
|
113
|
-
"!dist/**/*.test.*",
|
|
114
|
-
"!README.md",
|
|
115
|
-
"!*.md",
|
|
116
|
-
"!CHANGELOG.md"
|
|
117
|
-
],
|
|
118
73
|
"scripts": {
|
|
119
74
|
"build": "tsc -p tsconfig.build.json && npm run emit-schemas",
|
|
120
75
|
"emit-schemas": "node scripts/emit-schemas.js",
|
|
121
|
-
"clean": "rm -rf dist && rm -f *.tsbuildinfo",
|
|
122
|
-
"dev": "tsc -p tsconfig.build.json --watch",
|
|
123
|
-
"type-check": "tsc --noEmit",
|
|
124
76
|
"test": "vitest run",
|
|
125
|
-
"test:watch": "vitest",
|
|
126
77
|
"test:coverage": "vitest run --coverage",
|
|
127
|
-
"
|
|
78
|
+
"test:watch": "vitest",
|
|
79
|
+
"lint": "eslint .",
|
|
80
|
+
"format": "prettier --write \"src/**/*.{ts,tsx}\"",
|
|
81
|
+
"clean": "rm -rf dist .turbo node_modules",
|
|
82
|
+
"prepublishOnly": "npm run build && node ../create-mcpi-app/scripts/validate-no-workspace.js"
|
|
83
|
+
},
|
|
84
|
+
"sideEffects": false,
|
|
85
|
+
"dependencies": {
|
|
86
|
+
"zod": "^3.23.8"
|
|
128
87
|
},
|
|
129
88
|
"devDependencies": {
|
|
130
|
-
"@types/node": "^20.
|
|
89
|
+
"@types/node": "^20.14.9",
|
|
131
90
|
"@vitest/coverage-v8": "^4.0.5",
|
|
132
|
-
"
|
|
133
|
-
"
|
|
134
|
-
"
|
|
135
|
-
"typescript": "^5.0.0",
|
|
136
|
-
"vitest": "^4.0.5",
|
|
137
|
-
"zod-to-json-schema": "^3.22.0"
|
|
91
|
+
"eslint": "^8.57.0",
|
|
92
|
+
"typescript": "^5.5.3",
|
|
93
|
+
"vitest": "^4.0.5"
|
|
138
94
|
},
|
|
139
|
-
"
|
|
140
|
-
"
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
"xmcp",
|
|
144
|
-
"mcp",
|
|
145
|
-
"identity",
|
|
146
|
-
"types",
|
|
147
|
-
"contracts"
|
|
95
|
+
"files": [
|
|
96
|
+
"dist",
|
|
97
|
+
"package.json",
|
|
98
|
+
"README.md"
|
|
148
99
|
],
|
|
149
|
-
"
|
|
150
|
-
|
|
151
|
-
"repository": {
|
|
152
|
-
"type": "git",
|
|
153
|
-
"url": "https://github.com/kya-os/xmcp-i.git",
|
|
154
|
-
"directory": "packages/contracts"
|
|
100
|
+
"publishConfig": {
|
|
101
|
+
"access": "public"
|
|
155
102
|
}
|
|
156
103
|
}
|