@kya-os/contracts 1.5.3-canary.2 → 1.5.3-canary.20

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.
Files changed (90) hide show
  1. package/.turbo/turbo-build.log +17 -0
  2. package/.turbo/turbo-test$colon$coverage.log +85 -0
  3. package/.turbo/turbo-test.log +32 -0
  4. package/coverage/coverage-final.json +38 -0
  5. package/dist/agentshield-api/admin-schemas.d.ts +2 -2
  6. package/dist/agentshield-api/index.d.ts +1 -1
  7. package/dist/agentshield-api/schemas.d.ts +150 -48
  8. package/dist/agentshield-api/schemas.js +32 -4
  9. package/dist/agentshield-api/types.d.ts +31 -4
  10. package/dist/audit/index.d.ts +193 -0
  11. package/dist/audit/index.js +100 -0
  12. package/dist/config/identity.d.ts +205 -2
  13. package/dist/config/identity.js +28 -0
  14. package/dist/config/index.d.ts +2 -1
  15. package/dist/config/tool-context.d.ts +34 -0
  16. package/dist/config/tool-context.js +13 -0
  17. package/dist/consent/schemas.d.ts +119 -93
  18. package/dist/consent/schemas.js +111 -64
  19. package/dist/dashboard-config/schemas.d.ts +1949 -693
  20. package/dist/handshake.d.ts +14 -14
  21. package/dist/index.d.ts +1 -0
  22. package/dist/index.js +2 -0
  23. package/dist/tool-protection/index.d.ts +430 -2
  24. package/dist/tool-protection/index.js +62 -2
  25. package/dist/verifier/index.d.ts +1 -0
  26. package/dist/verifier/index.js +18 -0
  27. package/dist/well-known/index.d.ts +2 -2
  28. package/package.json +43 -122
  29. package/schemas/cli/register-output/v1.0.0.json +69 -0
  30. package/schemas/identity/v1.0.0.json +46 -0
  31. package/schemas/proof/v1.0.0.json +80 -0
  32. package/schemas/registry/receipt-v1.0.0.json +60 -0
  33. package/schemas/verifier/verify-page/v1.0.0.json +94 -0
  34. package/schemas/well-known/agent/v1.0.0.json +67 -0
  35. package/schemas/well-known/did/v1.0.0.json +174 -0
  36. package/scripts/emit-schemas.js +11 -0
  37. package/src/agentshield-api/admin-schemas.ts +31 -0
  38. package/src/agentshield-api/admin-types.ts +47 -0
  39. package/src/agentshield-api/endpoints.ts +60 -0
  40. package/src/agentshield-api/index.ts +70 -0
  41. package/src/agentshield-api/schemas.ts +304 -0
  42. package/src/agentshield-api/types.ts +317 -0
  43. package/src/audit/index.ts +128 -0
  44. package/src/cli.ts +156 -0
  45. package/src/config/base.ts +107 -0
  46. package/src/config/builder.ts +97 -0
  47. package/src/config/delegation.ts +232 -0
  48. package/src/config/identity.ts +252 -0
  49. package/src/config/index.ts +78 -0
  50. package/src/config/proofing.ts +138 -0
  51. package/src/config/tool-context.ts +41 -0
  52. package/src/config/tool-protection.ts +174 -0
  53. package/src/consent/index.ts +32 -0
  54. package/src/consent/schemas.ts +334 -0
  55. package/src/consent/types.ts +199 -0
  56. package/src/dashboard-config/default-config.json +86 -0
  57. package/src/dashboard-config/default-config.ts +266 -0
  58. package/src/dashboard-config/index.ts +48 -0
  59. package/src/dashboard-config/schemas.ts +286 -0
  60. package/src/dashboard-config/types.ts +404 -0
  61. package/src/delegation/constraints.ts +267 -0
  62. package/src/delegation/index.ts +8 -0
  63. package/src/delegation/schemas.ts +595 -0
  64. package/src/did/index.ts +9 -0
  65. package/src/did/resolve-contract.ts +255 -0
  66. package/src/did/schemas.ts +190 -0
  67. package/src/did/types.ts +224 -0
  68. package/src/env/constants.ts +70 -0
  69. package/src/env/index.ts +5 -0
  70. package/src/handshake.ts +125 -0
  71. package/src/index.ts +45 -0
  72. package/src/proof/index.ts +31 -0
  73. package/src/proof/proof-record.ts +163 -0
  74. package/src/proof/signing-spec.ts +146 -0
  75. package/src/proof.ts +99 -0
  76. package/src/registry.ts +146 -0
  77. package/src/runtime/errors.ts +153 -0
  78. package/src/runtime/headers.ts +136 -0
  79. package/src/runtime/index.ts +6 -0
  80. package/src/test.ts +143 -0
  81. package/src/tlkrc/index.ts +5 -0
  82. package/src/tlkrc/rotation.ts +153 -0
  83. package/src/tool-protection/index.ts +343 -0
  84. package/src/utils/validation.ts +93 -0
  85. package/src/vc/index.ts +8 -0
  86. package/src/vc/schemas.ts +277 -0
  87. package/src/vc/statuslist.ts +279 -0
  88. package/src/verifier/index.ts +2 -0
  89. package/src/verifier.ts +92 -0
  90. package/src/well-known/index.ts +237 -0
@@ -0,0 +1,237 @@
1
+ /**
2
+ * MCP-I Well-Known Endpoints Specification
3
+ *
4
+ * This module defines the types for well-known endpoints as specified in the
5
+ * MCP-I protocol. These endpoints provide identity discovery and verification
6
+ * capabilities for MCP-I agents.
7
+ *
8
+ * @module @kya-os/contracts/well-known
9
+ */
10
+
11
+ import { z } from 'zod';
12
+
13
+ /**
14
+ * DID Document as per W3C DID specification
15
+ * Returned from /.well-known/did.json
16
+ */
17
+ export interface DIDDocument {
18
+ '@context': string[];
19
+ id: string;
20
+ verificationMethod: Array<{
21
+ id: string;
22
+ type: string;
23
+ controller: string;
24
+ publicKeyBase64?: string;
25
+ publicKeyMultibase?: string;
26
+ }>;
27
+ authentication?: string[];
28
+ assertionMethod?: string[];
29
+ capabilityInvocation?: string[];
30
+ capabilityDelegation?: string[];
31
+ keyAgreement?: string[];
32
+ service?: Array<{
33
+ id: string;
34
+ type: string;
35
+ serviceEndpoint: string;
36
+ }>;
37
+ }
38
+
39
+ /**
40
+ * Agent Document for MCP-I capability discovery
41
+ * Returned from /.well-known/agent.json
42
+ */
43
+ export interface AgentDocument {
44
+ /** The agent's DID */
45
+ id: string;
46
+
47
+ /** Capabilities supported by this agent */
48
+ capabilities: {
49
+ 'mcp-i': Array<'handshake' | 'signing' | 'verification' | 'delegation' | 'proof-generation'>;
50
+ [key: string]: string[];
51
+ };
52
+
53
+ /** Optional metadata about the agent */
54
+ metadata?: {
55
+ name?: string;
56
+ serviceEndpoint?: string;
57
+ version?: string;
58
+ description?: string;
59
+ };
60
+ }
61
+
62
+ /**
63
+ * MCP Identity information
64
+ * Returned from /.well-known/mcp-identity
65
+ */
66
+ export interface MCPIdentity {
67
+ /** The agent's DID */
68
+ did: string;
69
+
70
+ /** The agent's public key */
71
+ publicKey: string;
72
+
73
+ /** Service name */
74
+ serviceName: string;
75
+
76
+ /** Service endpoint URL */
77
+ serviceEndpoint: string;
78
+
79
+ /** Timestamp of when this was generated */
80
+ timestamp: number;
81
+
82
+ /** Optional additional metadata */
83
+ metadata?: Record<string, unknown>;
84
+ }
85
+
86
+ /**
87
+ * Well-known endpoint handler configuration
88
+ */
89
+ export interface WellKnownConfig {
90
+ /** Service name to advertise */
91
+ serviceName?: string;
92
+
93
+ /** Service endpoint URL */
94
+ serviceEndpoint?: string;
95
+
96
+ /** Additional metadata to include */
97
+ metadata?: Record<string, unknown>;
98
+ }
99
+
100
+ /**
101
+ * Well-known endpoint response
102
+ */
103
+ export interface WellKnownResponse {
104
+ status: number;
105
+ headers: Record<string, string>;
106
+ body: string;
107
+ }
108
+
109
+ /**
110
+ * Well-known endpoint paths
111
+ */
112
+ export enum WellKnownPath {
113
+ DID_DOCUMENT = '/.well-known/did.json',
114
+ AGENT_DOCUMENT = '/.well-known/agent.json',
115
+ MCP_IDENTITY = '/.well-known/mcp-identity',
116
+ TOOL_PROTECTIONS = '/.well-known/tool-protections.json',
117
+ }
118
+
119
+ /**
120
+ * Zod Schemas for Validation
121
+ */
122
+
123
+ export const DIDDocumentSchema = z.object({
124
+ '@context': z.array(z.string()),
125
+ id: z.string(),
126
+ verificationMethod: z.array(z.object({
127
+ id: z.string(),
128
+ type: z.string(),
129
+ controller: z.string(),
130
+ publicKeyBase64: z.string().optional(),
131
+ publicKeyMultibase: z.string().optional()
132
+ })),
133
+ authentication: z.array(z.string()).optional(),
134
+ assertionMethod: z.array(z.string()).optional(),
135
+ capabilityInvocation: z.array(z.string()).optional(),
136
+ capabilityDelegation: z.array(z.string()).optional(),
137
+ keyAgreement: z.array(z.string()).optional(),
138
+ service: z.array(z.object({
139
+ id: z.string(),
140
+ type: z.string(),
141
+ serviceEndpoint: z.string()
142
+ })).optional()
143
+ });
144
+
145
+ export const AgentDocumentSchema = z.object({
146
+ id: z.string(),
147
+ capabilities: z.object({
148
+ 'mcp-i': z.array(z.enum(['handshake', 'signing', 'verification', 'delegation', 'proof-generation']))
149
+ }).catchall(z.array(z.string())),
150
+ metadata: z.object({
151
+ name: z.string().optional(),
152
+ serviceEndpoint: z.string().optional(),
153
+ version: z.string().optional(),
154
+ description: z.string().optional()
155
+ }).optional()
156
+ });
157
+
158
+ export const MCPIdentitySchema = z.object({
159
+ did: z.string(),
160
+ publicKey: z.string(),
161
+ serviceName: z.string(),
162
+ serviceEndpoint: z.string(),
163
+ timestamp: z.number(),
164
+ metadata: z.record(z.unknown()).optional()
165
+ });
166
+
167
+ export const WellKnownConfigSchema = z.object({
168
+ serviceName: z.string().optional(),
169
+ serviceEndpoint: z.string().optional(),
170
+ metadata: z.record(z.unknown()).optional()
171
+ });
172
+
173
+ export const WellKnownResponseSchema = z.object({
174
+ status: z.number(),
175
+ headers: z.record(z.string()),
176
+ body: z.string()
177
+ });
178
+
179
+ /**
180
+ * Type Guards
181
+ */
182
+
183
+ export function isDIDDocument(obj: any): obj is DIDDocument {
184
+ return DIDDocumentSchema.safeParse(obj).success;
185
+ }
186
+
187
+ export function isAgentDocument(obj: any): obj is AgentDocument {
188
+ return AgentDocumentSchema.safeParse(obj).success;
189
+ }
190
+
191
+ export function isMCPIdentity(obj: any): obj is MCPIdentity {
192
+ return MCPIdentitySchema.safeParse(obj).success;
193
+ }
194
+
195
+ /**
196
+ * Validation Functions
197
+ */
198
+
199
+ export function validateDIDDocument(obj: any): DIDDocument {
200
+ return DIDDocumentSchema.parse(obj);
201
+ }
202
+
203
+ export function validateAgentDocument(obj: any): AgentDocument {
204
+ return AgentDocumentSchema.parse(obj);
205
+ }
206
+
207
+ export function validateMCPIdentity(obj: any): MCPIdentity {
208
+ return MCPIdentitySchema.parse(obj);
209
+ }
210
+
211
+ /**
212
+ * Utility Functions
213
+ */
214
+
215
+ /**
216
+ * Check if a path is a well-known endpoint
217
+ */
218
+ export function isWellKnownPath(path: string): boolean {
219
+ return Object.values(WellKnownPath).includes(path as WellKnownPath);
220
+ }
221
+
222
+ /**
223
+ * Get the content type for a well-known endpoint
224
+ */
225
+ export function getWellKnownContentType(path: WellKnownPath | string): string {
226
+ switch (path) {
227
+ case WellKnownPath.DID_DOCUMENT:
228
+ return 'application/did+json';
229
+ case WellKnownPath.AGENT_DOCUMENT:
230
+ case WellKnownPath.TOOL_PROTECTIONS:
231
+ return 'application/json';
232
+ case WellKnownPath.MCP_IDENTITY:
233
+ return 'application/json';
234
+ default:
235
+ return 'application/json';
236
+ }
237
+ }