@kya-os/contracts 1.3.2 → 1.3.3

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 (82) hide show
  1. package/README.md +1 -1
  2. package/dist/agentshield-api/endpoints.d.ts +21 -0
  3. package/dist/agentshield-api/endpoints.js +20 -0
  4. package/dist/agentshield-api/index.d.ts +5 -0
  5. package/dist/agentshield-api/index.js +27 -0
  6. package/dist/agentshield-api/schemas.d.ts +9846 -0
  7. package/dist/agentshield-api/schemas.js +92 -0
  8. package/dist/agentshield-api/types.d.ts +92 -0
  9. package/dist/agentshield-api/types.js +12 -0
  10. package/dist/cli.d.ts +3 -6
  11. package/dist/cli.js +3 -10
  12. package/dist/config/base.d.ts +19 -0
  13. package/dist/config/base.js +2 -0
  14. package/dist/config/delegation.d.ts +46 -0
  15. package/dist/config/delegation.js +2 -0
  16. package/dist/config/identity.d.ts +22 -0
  17. package/dist/config/identity.js +2 -0
  18. package/dist/config/index.d.ts +17 -0
  19. package/dist/config/index.js +2 -0
  20. package/dist/config/proofing.d.ts +26 -0
  21. package/dist/config/proofing.js +2 -0
  22. package/dist/config/tool-protection.d.ts +36 -0
  23. package/dist/config/tool-protection.js +2 -0
  24. package/dist/delegation/constraints.d.ts +0 -266
  25. package/dist/delegation/constraints.js +3 -110
  26. package/dist/delegation/index.d.ts +0 -6
  27. package/dist/delegation/index.js +0 -6
  28. package/dist/delegation/schemas.d.ts +174 -514
  29. package/dist/delegation/schemas.js +3 -247
  30. package/dist/did/index.d.ts +0 -6
  31. package/dist/did/index.js +0 -6
  32. package/dist/did/resolve-contract.d.ts +0 -167
  33. package/dist/did/resolve-contract.js +0 -20
  34. package/dist/did/schemas.d.ts +0 -80
  35. package/dist/did/schemas.js +4 -97
  36. package/dist/did/types.d.ts +0 -126
  37. package/dist/did/types.js +0 -34
  38. package/dist/env/constants.d.ts +0 -45
  39. package/dist/env/constants.js +0 -45
  40. package/dist/env/index.d.ts +0 -4
  41. package/dist/env/index.js +0 -4
  42. package/dist/handshake.d.ts +0 -21
  43. package/dist/handshake.js +3 -11
  44. package/dist/index.d.ts +0 -15
  45. package/dist/index.js +0 -25
  46. package/dist/proof/index.d.ts +0 -7
  47. package/dist/proof/index.js +0 -7
  48. package/dist/proof/proof-record.d.ts +62 -172
  49. package/dist/proof/proof-record.js +0 -74
  50. package/dist/proof/signing-spec.d.ts +12 -86
  51. package/dist/proof/signing-spec.js +0 -71
  52. package/dist/proof.d.ts +16 -38
  53. package/dist/proof.js +3 -26
  54. package/dist/registry.d.ts +10 -27
  55. package/dist/registry.js +9 -30
  56. package/dist/runtime/errors.d.ts +0 -169
  57. package/dist/runtime/errors.js +0 -69
  58. package/dist/runtime/headers.d.ts +0 -50
  59. package/dist/runtime/headers.js +0 -30
  60. package/dist/runtime/index.d.ts +0 -4
  61. package/dist/runtime/index.js +0 -4
  62. package/dist/test.d.ts +0 -37
  63. package/dist/test.js +0 -37
  64. package/dist/tlkrc/index.d.ts +0 -4
  65. package/dist/tlkrc/index.js +0 -4
  66. package/dist/tlkrc/rotation.d.ts +12 -90
  67. package/dist/tlkrc/rotation.js +0 -72
  68. package/dist/tool-protection/index.d.ts +129 -0
  69. package/dist/tool-protection/index.js +80 -0
  70. package/dist/utils/validation.d.ts +0 -17
  71. package/dist/utils/validation.js +0 -14
  72. package/dist/vc/index.d.ts +0 -6
  73. package/dist/vc/index.js +0 -6
  74. package/dist/vc/schemas.d.ts +0 -596
  75. package/dist/vc/schemas.js +2 -111
  76. package/dist/vc/statuslist.d.ts +0 -202
  77. package/dist/vc/statuslist.js +1 -73
  78. package/dist/verifier.d.ts +9 -13
  79. package/dist/verifier.js +0 -8
  80. package/dist/well-known/index.d.ts +248 -0
  81. package/dist/well-known/index.js +104 -0
  82. package/package.json +27 -5
@@ -1,53 +1,20 @@
1
1
  "use strict";
2
- /**
3
- * StatusList2021 Types and Schemas
4
- *
5
- * Implementation of the W3C StatusList2021 specification for credential status.
6
- * Provides types for status list credentials and helpers for bitstring operations.
7
- *
8
- * Related Spec: W3C StatusList2021
9
- * Python Reference: Credential-Documentation.md (StatusList2021 section)
10
- */
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.STATUSLIST_2021_CONTEXT = exports.MAX_STATUSLIST_SIZE = exports.DEFAULT_STATUSLIST_CACHE_TTL_SEC = exports.StatusList2021CredentialSchema = exports.StatusList2021CredentialSubjectSchema = void 0;
13
4
  exports.validateStatusList2021Credential = validateStatusList2021Credential;
14
5
  exports.createStatusListCredentialStructure = createStatusListCredentialStructure;
15
6
  const zod_1 = require("zod");
16
7
  const schemas_js_1 = require("./schemas.js");
17
- /**
18
- * Status List Credential Subject Schema
19
- *
20
- * The credential subject of a StatusList2021Credential
21
- */
22
8
  exports.StatusList2021CredentialSubjectSchema = zod_1.z.object({
23
- /** Optional identifier for the status list */
24
9
  id: zod_1.z.string().optional(),
25
- /** Type MUST be StatusList2021 */
26
10
  type: zod_1.z.literal('StatusList2021'),
27
- /** Purpose of the status list */
28
11
  statusPurpose: zod_1.z.enum(['revocation', 'suspension']),
29
- /**
30
- * Encoded bitstring
31
- *
32
- * Base64url-encoded and GZIP-compressed bitstring.
33
- * Each bit represents the status of a credential:
34
- * - 0: Not revoked/suspended
35
- * - 1: Revoked/suspended
36
- */
37
12
  encodedList: zod_1.z.string().regex(/^[A-Za-z0-9_-]+$/, {
38
13
  message: 'encodedList must be base64url encoded',
39
14
  }),
40
15
  });
41
- /**
42
- * StatusList2021 Credential Schema
43
- *
44
- * A credential that contains a status list for checking revocation/suspension
45
- * of other credentials.
46
- */
47
16
  exports.StatusList2021CredentialSchema = zod_1.z.object({
48
- /** JSON-LD context */
49
17
  '@context': schemas_js_1.ContextSchema.refine((contexts) => {
50
- // Must include both base VC context and StatusList context
51
18
  return (contexts.length >= 2 &&
52
19
  typeof contexts[0] === 'string' &&
53
20
  contexts[0] === 'https://www.w3.org/2018/credentials/v1' &&
@@ -57,45 +24,21 @@ exports.StatusList2021CredentialSchema = zod_1.z.object({
57
24
  }, {
58
25
  message: '@context must include VC context and StatusList2021 context',
59
26
  }),
60
- /** Unique identifier for the status list credential */
61
27
  id: zod_1.z.string().url(),
62
- /** Type MUST include VerifiableCredential and StatusList2021Credential */
63
28
  type: zod_1.z
64
29
  .tuple([zod_1.z.literal('VerifiableCredential'), zod_1.z.literal('StatusList2021Credential')])
65
30
  .or(zod_1.z.array(zod_1.z.string()).refine((types) => types.includes('VerifiableCredential') &&
66
31
  types.includes('StatusList2021Credential'), {
67
32
  message: 'type must include "VerifiableCredential" and "StatusList2021Credential"',
68
33
  })),
69
- /** Issuer of the status list credential */
70
34
  issuer: schemas_js_1.IssuerSchema,
71
- /** Issuance date in ISO 8601 format */
72
35
  issuanceDate: zod_1.z.string().datetime(),
73
- /** The status list credential subject */
74
36
  credentialSubject: exports.StatusList2021CredentialSubjectSchema,
75
- /** Cryptographic proof (optional) */
76
37
  proof: schemas_js_1.ProofSchema.optional(),
77
38
  }).passthrough();
78
- /**
79
- * Validation Helpers
80
- */
81
- /**
82
- * Validate a StatusList2021 credential
83
- *
84
- * @param credential - The credential to validate
85
- * @returns Validation result with parsed credential or errors
86
- */
87
39
  function validateStatusList2021Credential(credential) {
88
40
  return exports.StatusList2021CredentialSchema.safeParse(credential);
89
41
  }
90
- /**
91
- * Helper to create a minimal status list credential structure
92
- *
93
- * This is a type-safe helper, actual credential creation requires
94
- * proper signing and encoding implementation.
95
- *
96
- * @param config - Configuration for the status list credential
97
- * @returns Partial credential structure (needs proof to be complete)
98
- */
99
42
  function createStatusListCredentialStructure(config) {
100
43
  return {
101
44
  '@context': [
@@ -113,21 +56,6 @@ function createStatusListCredentialStructure(config) {
113
56
  },
114
57
  };
115
58
  }
116
- /**
117
- * Constants
118
- */
119
- /**
120
- * Default cache TTL for status list credentials (in seconds)
121
- * As per spec recommendation
122
- */
123
59
  exports.DEFAULT_STATUSLIST_CACHE_TTL_SEC = 60;
124
- /**
125
- * Maximum reasonable bitstring size
126
- * Used for validation to prevent memory exhaustion
127
- */
128
- exports.MAX_STATUSLIST_SIZE = 1000000; // 1 million entries
129
- /**
130
- * StatusList2021 context URL
131
- */
60
+ exports.MAX_STATUSLIST_SIZE = 1000000;
132
61
  exports.STATUSLIST_2021_CONTEXT = 'https://w3id.org/vc/status-list/2021/v1';
133
- //# sourceMappingURL=statuslist.js.map
@@ -1,7 +1,4 @@
1
1
  import { z } from "zod";
2
- /**
3
- * Verifier middleware schemas and headers
4
- */
5
2
  export declare const AgentContextSchema: z.ZodObject<{
6
3
  did: z.ZodString;
7
4
  kid: z.ZodString;
@@ -15,13 +12,13 @@ export declare const AgentContextSchema: z.ZodObject<{
15
12
  }, "strip", z.ZodTypeAny, {
16
13
  did: string;
17
14
  kid: string;
18
- scopes: string[];
19
15
  session: string;
16
+ scopes: string[];
20
17
  confidence: "verified";
21
18
  registry: string;
22
19
  verifiedAt: number;
23
- subject?: string | undefined;
24
20
  delegationRef?: string | undefined;
21
+ subject?: string | undefined;
25
22
  }, {
26
23
  did: string;
27
24
  kid: string;
@@ -29,9 +26,9 @@ export declare const AgentContextSchema: z.ZodObject<{
29
26
  confidence: "verified";
30
27
  registry: string;
31
28
  verifiedAt: number;
29
+ delegationRef?: string | undefined;
32
30
  subject?: string | undefined;
33
31
  scopes?: string[] | undefined;
34
- delegationRef?: string | undefined;
35
32
  }>;
36
33
  export declare const VerifierResultSchema: z.ZodObject<{
37
34
  success: z.ZodBoolean;
@@ -49,13 +46,13 @@ export declare const VerifierResultSchema: z.ZodObject<{
49
46
  }, "strip", z.ZodTypeAny, {
50
47
  did: string;
51
48
  kid: string;
52
- scopes: string[];
53
49
  session: string;
50
+ scopes: string[];
54
51
  confidence: "verified";
55
52
  registry: string;
56
53
  verifiedAt: number;
57
- subject?: string | undefined;
58
54
  delegationRef?: string | undefined;
55
+ subject?: string | undefined;
59
56
  }, {
60
57
  did: string;
61
58
  kid: string;
@@ -63,9 +60,9 @@ export declare const VerifierResultSchema: z.ZodObject<{
63
60
  confidence: "verified";
64
61
  registry: string;
65
62
  verifiedAt: number;
63
+ delegationRef?: string | undefined;
66
64
  subject?: string | undefined;
67
65
  scopes?: string[] | undefined;
68
- delegationRef?: string | undefined;
69
66
  }>>;
70
67
  error: z.ZodOptional<z.ZodObject<{
71
68
  code: z.ZodString;
@@ -95,13 +92,13 @@ export declare const VerifierResultSchema: z.ZodObject<{
95
92
  agentContext?: {
96
93
  did: string;
97
94
  kid: string;
98
- scopes: string[];
99
95
  session: string;
96
+ scopes: string[];
100
97
  confidence: "verified";
101
98
  registry: string;
102
99
  verifiedAt: number;
103
- subject?: string | undefined;
104
100
  delegationRef?: string | undefined;
101
+ subject?: string | undefined;
105
102
  } | undefined;
106
103
  }, {
107
104
  success: boolean;
@@ -119,9 +116,9 @@ export declare const VerifierResultSchema: z.ZodObject<{
119
116
  confidence: "verified";
120
117
  registry: string;
121
118
  verifiedAt: number;
119
+ delegationRef?: string | undefined;
122
120
  subject?: string | undefined;
123
121
  scopes?: string[] | undefined;
124
- delegationRef?: string | undefined;
125
122
  } | undefined;
126
123
  }>;
127
124
  export declare const StructuredErrorSchema: z.ZodObject<{
@@ -203,4 +200,3 @@ export declare const ERROR_HTTP_STATUS: {
203
200
  readonly XMCP_I_SESSION_IDLE_EXPIRED: 401;
204
201
  readonly XMCP_I_SERVER_TIME_INVALID: 500;
205
202
  };
206
- //# sourceMappingURL=verifier.d.ts.map
package/dist/verifier.js CHANGED
@@ -2,9 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ERROR_HTTP_STATUS = exports.VERIFIER_ERROR_CODES = exports.AGENT_HEADERS = exports.StructuredErrorSchema = exports.VerifierResultSchema = exports.AgentContextSchema = void 0;
4
4
  const zod_1 = require("zod");
5
- /**
6
- * Verifier middleware schemas and headers
7
- */
8
5
  exports.AgentContextSchema = zod_1.z.object({
9
6
  did: zod_1.z.string().min(1),
10
7
  kid: zod_1.z.string().min(1),
@@ -42,7 +39,6 @@ exports.StructuredErrorSchema = zod_1.z.object({
42
39
  })
43
40
  .optional(),
44
41
  });
45
- // Header constants (frozen names)
46
42
  exports.AGENT_HEADERS = {
47
43
  DID: "X-Agent-DID",
48
44
  KEY_ID: "X-Agent-KeyId",
@@ -54,7 +50,6 @@ exports.AGENT_HEADERS = {
54
50
  REGISTRY: "X-Agent-Registry",
55
51
  VERIFIED_AT: "X-Agent-Verified-At",
56
52
  };
57
- // Verifier-specific error codes
58
53
  exports.VERIFIER_ERROR_CODES = {
59
54
  PROOF_INVALID_TS: "XMCP_I_PROOF_INVALID_TS",
60
55
  PROOF_FUTURE_TS: "XMCP_I_PROOF_FUTURE_TS",
@@ -63,7 +58,6 @@ exports.VERIFIER_ERROR_CODES = {
63
58
  SESSION_IDLE_EXPIRED: "XMCP_I_SESSION_IDLE_EXPIRED",
64
59
  SERVER_TIME_INVALID: "XMCP_I_SERVER_TIME_INVALID",
65
60
  };
66
- // HTTP status mappings
67
61
  exports.ERROR_HTTP_STATUS = {
68
62
  XMCP_I_EBADPROOF: 403,
69
63
  XMCP_I_ENOIDENTITY: 500,
@@ -73,7 +67,6 @@ exports.ERROR_HTTP_STATUS = {
73
67
  XMCP_I_ECLAIM: 400,
74
68
  XMCP_I_ECONFIG: 500,
75
69
  XMCP_I_ERUNTIME: 500,
76
- // Verifier-specific codes
77
70
  [exports.VERIFIER_ERROR_CODES.PROOF_INVALID_TS]: 403,
78
71
  [exports.VERIFIER_ERROR_CODES.PROOF_FUTURE_TS]: 403,
79
72
  [exports.VERIFIER_ERROR_CODES.PROOF_TOO_OLD]: 403,
@@ -81,4 +74,3 @@ exports.ERROR_HTTP_STATUS = {
81
74
  [exports.VERIFIER_ERROR_CODES.SESSION_IDLE_EXPIRED]: 401,
82
75
  [exports.VERIFIER_ERROR_CODES.SERVER_TIME_INVALID]: 500,
83
76
  };
84
- //# sourceMappingURL=verifier.js.map
@@ -0,0 +1,248 @@
1
+ import { z } from 'zod';
2
+ export interface DIDDocument {
3
+ '@context': string[];
4
+ id: string;
5
+ verificationMethod: Array<{
6
+ id: string;
7
+ type: string;
8
+ controller: string;
9
+ publicKeyBase64?: string;
10
+ publicKeyMultibase?: string;
11
+ }>;
12
+ authentication?: string[];
13
+ assertionMethod?: string[];
14
+ capabilityInvocation?: string[];
15
+ capabilityDelegation?: string[];
16
+ keyAgreement?: string[];
17
+ service?: Array<{
18
+ id: string;
19
+ type: string;
20
+ serviceEndpoint: string;
21
+ }>;
22
+ }
23
+ export interface AgentDocument {
24
+ id: string;
25
+ capabilities: {
26
+ 'mcp-i': Array<'handshake' | 'signing' | 'verification' | 'delegation' | 'proof-generation'>;
27
+ [key: string]: string[];
28
+ };
29
+ metadata?: {
30
+ name?: string;
31
+ serviceEndpoint?: string;
32
+ version?: string;
33
+ description?: string;
34
+ };
35
+ }
36
+ export interface MCPIdentity {
37
+ did: string;
38
+ publicKey: string;
39
+ serviceName: string;
40
+ serviceEndpoint: string;
41
+ timestamp: number;
42
+ metadata?: Record<string, unknown>;
43
+ }
44
+ export interface WellKnownConfig {
45
+ serviceName?: string;
46
+ serviceEndpoint?: string;
47
+ metadata?: Record<string, unknown>;
48
+ }
49
+ export interface WellKnownResponse {
50
+ status: number;
51
+ headers: Record<string, string>;
52
+ body: string;
53
+ }
54
+ export declare enum WellKnownPath {
55
+ DID_DOCUMENT = "/.well-known/did.json",
56
+ AGENT_DOCUMENT = "/.well-known/agent.json",
57
+ MCP_IDENTITY = "/.well-known/mcp-identity",
58
+ TOOL_PROTECTIONS = "/.well-known/tool-protections.json"
59
+ }
60
+ export declare const DIDDocumentSchema: z.ZodObject<{
61
+ '@context': z.ZodArray<z.ZodString, "many">;
62
+ id: z.ZodString;
63
+ verificationMethod: z.ZodArray<z.ZodObject<{
64
+ id: z.ZodString;
65
+ type: z.ZodString;
66
+ controller: z.ZodString;
67
+ publicKeyBase64: z.ZodOptional<z.ZodString>;
68
+ publicKeyMultibase: z.ZodOptional<z.ZodString>;
69
+ }, "strip", z.ZodTypeAny, {
70
+ type: string;
71
+ id: string;
72
+ controller: string;
73
+ publicKeyMultibase?: string | undefined;
74
+ publicKeyBase64?: string | undefined;
75
+ }, {
76
+ type: string;
77
+ id: string;
78
+ controller: string;
79
+ publicKeyMultibase?: string | undefined;
80
+ publicKeyBase64?: string | undefined;
81
+ }>, "many">;
82
+ authentication: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
83
+ assertionMethod: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
84
+ capabilityInvocation: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
85
+ capabilityDelegation: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
86
+ keyAgreement: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
87
+ service: z.ZodOptional<z.ZodArray<z.ZodObject<{
88
+ id: z.ZodString;
89
+ type: z.ZodString;
90
+ serviceEndpoint: z.ZodString;
91
+ }, "strip", z.ZodTypeAny, {
92
+ type: string;
93
+ id: string;
94
+ serviceEndpoint: string;
95
+ }, {
96
+ type: string;
97
+ id: string;
98
+ serviceEndpoint: string;
99
+ }>, "many">>;
100
+ }, "strip", z.ZodTypeAny, {
101
+ id: string;
102
+ verificationMethod: {
103
+ type: string;
104
+ id: string;
105
+ controller: string;
106
+ publicKeyMultibase?: string | undefined;
107
+ publicKeyBase64?: string | undefined;
108
+ }[];
109
+ '@context': string[];
110
+ authentication?: string[] | undefined;
111
+ assertionMethod?: string[] | undefined;
112
+ keyAgreement?: string[] | undefined;
113
+ capabilityInvocation?: string[] | undefined;
114
+ capabilityDelegation?: string[] | undefined;
115
+ service?: {
116
+ type: string;
117
+ id: string;
118
+ serviceEndpoint: string;
119
+ }[] | undefined;
120
+ }, {
121
+ id: string;
122
+ verificationMethod: {
123
+ type: string;
124
+ id: string;
125
+ controller: string;
126
+ publicKeyMultibase?: string | undefined;
127
+ publicKeyBase64?: string | undefined;
128
+ }[];
129
+ '@context': string[];
130
+ authentication?: string[] | undefined;
131
+ assertionMethod?: string[] | undefined;
132
+ keyAgreement?: string[] | undefined;
133
+ capabilityInvocation?: string[] | undefined;
134
+ capabilityDelegation?: string[] | undefined;
135
+ service?: {
136
+ type: string;
137
+ id: string;
138
+ serviceEndpoint: string;
139
+ }[] | undefined;
140
+ }>;
141
+ export declare const AgentDocumentSchema: z.ZodObject<{
142
+ id: z.ZodString;
143
+ capabilities: z.ZodObject<{
144
+ 'mcp-i': z.ZodArray<z.ZodEnum<["handshake", "signing", "verification", "delegation", "proof-generation"]>, "many">;
145
+ }, "strip", z.ZodArray<z.ZodString, "many">, z.objectOutputType<{
146
+ 'mcp-i': z.ZodArray<z.ZodEnum<["handshake", "signing", "verification", "delegation", "proof-generation"]>, "many">;
147
+ }, z.ZodArray<z.ZodString, "many">, "strip">, z.objectInputType<{
148
+ 'mcp-i': z.ZodArray<z.ZodEnum<["handshake", "signing", "verification", "delegation", "proof-generation"]>, "many">;
149
+ }, z.ZodArray<z.ZodString, "many">, "strip">>;
150
+ metadata: z.ZodOptional<z.ZodObject<{
151
+ name: z.ZodOptional<z.ZodString>;
152
+ serviceEndpoint: z.ZodOptional<z.ZodString>;
153
+ version: z.ZodOptional<z.ZodString>;
154
+ description: z.ZodOptional<z.ZodString>;
155
+ }, "strip", z.ZodTypeAny, {
156
+ version?: string | undefined;
157
+ name?: string | undefined;
158
+ serviceEndpoint?: string | undefined;
159
+ description?: string | undefined;
160
+ }, {
161
+ version?: string | undefined;
162
+ name?: string | undefined;
163
+ serviceEndpoint?: string | undefined;
164
+ description?: string | undefined;
165
+ }>>;
166
+ }, "strip", z.ZodTypeAny, {
167
+ id: string;
168
+ capabilities: {
169
+ 'mcp-i': ("handshake" | "signing" | "verification" | "delegation" | "proof-generation")[];
170
+ } & {
171
+ [k: string]: string[];
172
+ };
173
+ metadata?: {
174
+ version?: string | undefined;
175
+ name?: string | undefined;
176
+ serviceEndpoint?: string | undefined;
177
+ description?: string | undefined;
178
+ } | undefined;
179
+ }, {
180
+ id: string;
181
+ capabilities: {
182
+ 'mcp-i': ("handshake" | "signing" | "verification" | "delegation" | "proof-generation")[];
183
+ } & {
184
+ [k: string]: string[];
185
+ };
186
+ metadata?: {
187
+ version?: string | undefined;
188
+ name?: string | undefined;
189
+ serviceEndpoint?: string | undefined;
190
+ description?: string | undefined;
191
+ } | undefined;
192
+ }>;
193
+ export declare const MCPIdentitySchema: z.ZodObject<{
194
+ did: z.ZodString;
195
+ publicKey: z.ZodString;
196
+ serviceName: z.ZodString;
197
+ serviceEndpoint: z.ZodString;
198
+ timestamp: z.ZodNumber;
199
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
200
+ }, "strip", z.ZodTypeAny, {
201
+ did: string;
202
+ publicKey: string;
203
+ timestamp: number;
204
+ serviceEndpoint: string;
205
+ serviceName: string;
206
+ metadata?: Record<string, unknown> | undefined;
207
+ }, {
208
+ did: string;
209
+ publicKey: string;
210
+ timestamp: number;
211
+ serviceEndpoint: string;
212
+ serviceName: string;
213
+ metadata?: Record<string, unknown> | undefined;
214
+ }>;
215
+ export declare const WellKnownConfigSchema: z.ZodObject<{
216
+ serviceName: z.ZodOptional<z.ZodString>;
217
+ serviceEndpoint: z.ZodOptional<z.ZodString>;
218
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
219
+ }, "strip", z.ZodTypeAny, {
220
+ metadata?: Record<string, unknown> | undefined;
221
+ serviceEndpoint?: string | undefined;
222
+ serviceName?: string | undefined;
223
+ }, {
224
+ metadata?: Record<string, unknown> | undefined;
225
+ serviceEndpoint?: string | undefined;
226
+ serviceName?: string | undefined;
227
+ }>;
228
+ export declare const WellKnownResponseSchema: z.ZodObject<{
229
+ status: z.ZodNumber;
230
+ headers: z.ZodRecord<z.ZodString, z.ZodString>;
231
+ body: z.ZodString;
232
+ }, "strip", z.ZodTypeAny, {
233
+ status: number;
234
+ headers: Record<string, string>;
235
+ body: string;
236
+ }, {
237
+ status: number;
238
+ headers: Record<string, string>;
239
+ body: string;
240
+ }>;
241
+ export declare function isDIDDocument(obj: any): obj is DIDDocument;
242
+ export declare function isAgentDocument(obj: any): obj is AgentDocument;
243
+ export declare function isMCPIdentity(obj: any): obj is MCPIdentity;
244
+ export declare function validateDIDDocument(obj: any): DIDDocument;
245
+ export declare function validateAgentDocument(obj: any): AgentDocument;
246
+ export declare function validateMCPIdentity(obj: any): MCPIdentity;
247
+ export declare function isWellKnownPath(path: string): boolean;
248
+ export declare function getWellKnownContentType(path: WellKnownPath | string): string;
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WellKnownResponseSchema = exports.WellKnownConfigSchema = exports.MCPIdentitySchema = exports.AgentDocumentSchema = exports.DIDDocumentSchema = exports.WellKnownPath = void 0;
4
+ exports.isDIDDocument = isDIDDocument;
5
+ exports.isAgentDocument = isAgentDocument;
6
+ exports.isMCPIdentity = isMCPIdentity;
7
+ exports.validateDIDDocument = validateDIDDocument;
8
+ exports.validateAgentDocument = validateAgentDocument;
9
+ exports.validateMCPIdentity = validateMCPIdentity;
10
+ exports.isWellKnownPath = isWellKnownPath;
11
+ exports.getWellKnownContentType = getWellKnownContentType;
12
+ const zod_1 = require("zod");
13
+ var WellKnownPath;
14
+ (function (WellKnownPath) {
15
+ WellKnownPath["DID_DOCUMENT"] = "/.well-known/did.json";
16
+ WellKnownPath["AGENT_DOCUMENT"] = "/.well-known/agent.json";
17
+ WellKnownPath["MCP_IDENTITY"] = "/.well-known/mcp-identity";
18
+ WellKnownPath["TOOL_PROTECTIONS"] = "/.well-known/tool-protections.json";
19
+ })(WellKnownPath || (exports.WellKnownPath = WellKnownPath = {}));
20
+ exports.DIDDocumentSchema = zod_1.z.object({
21
+ '@context': zod_1.z.array(zod_1.z.string()),
22
+ id: zod_1.z.string(),
23
+ verificationMethod: zod_1.z.array(zod_1.z.object({
24
+ id: zod_1.z.string(),
25
+ type: zod_1.z.string(),
26
+ controller: zod_1.z.string(),
27
+ publicKeyBase64: zod_1.z.string().optional(),
28
+ publicKeyMultibase: zod_1.z.string().optional()
29
+ })),
30
+ authentication: zod_1.z.array(zod_1.z.string()).optional(),
31
+ assertionMethod: zod_1.z.array(zod_1.z.string()).optional(),
32
+ capabilityInvocation: zod_1.z.array(zod_1.z.string()).optional(),
33
+ capabilityDelegation: zod_1.z.array(zod_1.z.string()).optional(),
34
+ keyAgreement: zod_1.z.array(zod_1.z.string()).optional(),
35
+ service: zod_1.z.array(zod_1.z.object({
36
+ id: zod_1.z.string(),
37
+ type: zod_1.z.string(),
38
+ serviceEndpoint: zod_1.z.string()
39
+ })).optional()
40
+ });
41
+ exports.AgentDocumentSchema = zod_1.z.object({
42
+ id: zod_1.z.string(),
43
+ capabilities: zod_1.z.object({
44
+ 'mcp-i': zod_1.z.array(zod_1.z.enum(['handshake', 'signing', 'verification', 'delegation', 'proof-generation']))
45
+ }).catchall(zod_1.z.array(zod_1.z.string())),
46
+ metadata: zod_1.z.object({
47
+ name: zod_1.z.string().optional(),
48
+ serviceEndpoint: zod_1.z.string().optional(),
49
+ version: zod_1.z.string().optional(),
50
+ description: zod_1.z.string().optional()
51
+ }).optional()
52
+ });
53
+ exports.MCPIdentitySchema = zod_1.z.object({
54
+ did: zod_1.z.string(),
55
+ publicKey: zod_1.z.string(),
56
+ serviceName: zod_1.z.string(),
57
+ serviceEndpoint: zod_1.z.string(),
58
+ timestamp: zod_1.z.number(),
59
+ metadata: zod_1.z.record(zod_1.z.unknown()).optional()
60
+ });
61
+ exports.WellKnownConfigSchema = zod_1.z.object({
62
+ serviceName: zod_1.z.string().optional(),
63
+ serviceEndpoint: zod_1.z.string().optional(),
64
+ metadata: zod_1.z.record(zod_1.z.unknown()).optional()
65
+ });
66
+ exports.WellKnownResponseSchema = zod_1.z.object({
67
+ status: zod_1.z.number(),
68
+ headers: zod_1.z.record(zod_1.z.string()),
69
+ body: zod_1.z.string()
70
+ });
71
+ function isDIDDocument(obj) {
72
+ return exports.DIDDocumentSchema.safeParse(obj).success;
73
+ }
74
+ function isAgentDocument(obj) {
75
+ return exports.AgentDocumentSchema.safeParse(obj).success;
76
+ }
77
+ function isMCPIdentity(obj) {
78
+ return exports.MCPIdentitySchema.safeParse(obj).success;
79
+ }
80
+ function validateDIDDocument(obj) {
81
+ return exports.DIDDocumentSchema.parse(obj);
82
+ }
83
+ function validateAgentDocument(obj) {
84
+ return exports.AgentDocumentSchema.parse(obj);
85
+ }
86
+ function validateMCPIdentity(obj) {
87
+ return exports.MCPIdentitySchema.parse(obj);
88
+ }
89
+ function isWellKnownPath(path) {
90
+ return Object.values(WellKnownPath).includes(path);
91
+ }
92
+ function getWellKnownContentType(path) {
93
+ switch (path) {
94
+ case WellKnownPath.DID_DOCUMENT:
95
+ return 'application/did+json';
96
+ case WellKnownPath.AGENT_DOCUMENT:
97
+ case WellKnownPath.TOOL_PROTECTIONS:
98
+ return 'application/json';
99
+ case WellKnownPath.MCP_IDENTITY:
100
+ return 'application/json';
101
+ default:
102
+ return 'application/json';
103
+ }
104
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kya-os/contracts",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "Shared types and schemas for XMCP-I ecosystem",
5
5
  "type": "commonjs",
6
6
  "sideEffects": false,
@@ -71,6 +71,26 @@
71
71
  "types": "./dist/env/index.d.ts",
72
72
  "import": "./dist/env/index.js",
73
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"
79
+ },
80
+ "./tool-protection": {
81
+ "types": "./dist/tool-protection/index.d.ts",
82
+ "import": "./dist/tool-protection/index.js",
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"
89
+ },
90
+ "./config": {
91
+ "types": "./dist/config/index.d.ts",
92
+ "import": "./dist/config/index.js",
93
+ "require": "./dist/config/index.js"
74
94
  }
75
95
  },
76
96
  "files": [
@@ -81,7 +101,8 @@
81
101
  "!dist/**/__fixtures__/**",
82
102
  "!dist/**/*.spec.*",
83
103
  "!dist/**/*.test.*",
84
- "README.md"
104
+ "!README.md",
105
+ "!*.md"
85
106
  ],
86
107
  "scripts": {
87
108
  "build": "tsc -p tsconfig.build.json && npm run emit-schemas",
@@ -91,16 +112,17 @@
91
112
  "type-check": "tsc --noEmit",
92
113
  "test": "vitest run",
93
114
  "test:watch": "vitest",
94
- "test:coverage": "vitest run --coverage"
115
+ "test:coverage": "vitest run --coverage",
116
+ "prepublishOnly": "npm run build && node ../create-mcpi-app/scripts/validate-no-workspace.js"
95
117
  },
96
118
  "devDependencies": {
97
119
  "@types/node": "^20.0.0",
98
- "@vitest/coverage-v8": "^3.2.4",
120
+ "@vitest/coverage-v8": "^4.0.5",
99
121
  "ajv": "^8.12.0",
100
122
  "ajv-formats": "^2.1.1",
101
123
  "fast-check": "^3.15.0",
102
124
  "typescript": "^5.0.0",
103
- "vitest": "^3.2.4",
125
+ "vitest": "^4.0.5",
104
126
  "zod-to-json-schema": "^3.22.0"
105
127
  },
106
128
  "dependencies": {