@kya-os/contracts 1.3.2 → 1.3.4

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 (58) hide show
  1. package/package.json +28 -5
  2. package/README.md +0 -130
  3. package/dist/cli.d.ts +0 -378
  4. package/dist/cli.js +0 -116
  5. package/dist/delegation/constraints.d.ts +0 -992
  6. package/dist/delegation/constraints.js +0 -210
  7. package/dist/delegation/index.d.ts +0 -8
  8. package/dist/delegation/index.js +0 -24
  9. package/dist/delegation/schemas.d.ts +0 -8382
  10. package/dist/delegation/schemas.js +0 -476
  11. package/dist/did/index.d.ts +0 -9
  12. package/dist/did/index.js +0 -25
  13. package/dist/did/resolve-contract.d.ts +0 -220
  14. package/dist/did/resolve-contract.js +0 -32
  15. package/dist/did/schemas.d.ts +0 -113
  16. package/dist/did/schemas.js +0 -173
  17. package/dist/did/types.d.ts +0 -164
  18. package/dist/did/types.js +0 -71
  19. package/dist/env/constants.d.ts +0 -58
  20. package/dist/env/constants.js +0 -60
  21. package/dist/env/index.d.ts +0 -5
  22. package/dist/env/index.js +0 -21
  23. package/dist/handshake.d.ts +0 -159
  24. package/dist/handshake.js +0 -58
  25. package/dist/index.d.ts +0 -26
  26. package/dist/index.js +0 -53
  27. package/dist/proof/index.d.ts +0 -9
  28. package/dist/proof/index.js +0 -25
  29. package/dist/proof/proof-record.d.ts +0 -838
  30. package/dist/proof/proof-record.js +0 -134
  31. package/dist/proof/signing-spec.d.ts +0 -147
  32. package/dist/proof/signing-spec.js +0 -123
  33. package/dist/proof.d.ts +0 -400
  34. package/dist/proof.js +0 -82
  35. package/dist/registry.d.ts +0 -343
  36. package/dist/registry.js +0 -119
  37. package/dist/runtime/errors.d.ts +0 -348
  38. package/dist/runtime/errors.js +0 -120
  39. package/dist/runtime/headers.d.ts +0 -84
  40. package/dist/runtime/headers.js +0 -82
  41. package/dist/runtime/index.d.ts +0 -6
  42. package/dist/runtime/index.js +0 -22
  43. package/dist/test.d.ts +0 -252
  44. package/dist/test.js +0 -120
  45. package/dist/tlkrc/index.d.ts +0 -5
  46. package/dist/tlkrc/index.js +0 -21
  47. package/dist/tlkrc/rotation.d.ts +0 -246
  48. package/dist/tlkrc/rotation.js +0 -127
  49. package/dist/utils/validation.d.ts +0 -31
  50. package/dist/utils/validation.js +0 -70
  51. package/dist/vc/index.d.ts +0 -8
  52. package/dist/vc/index.js +0 -24
  53. package/dist/vc/schemas.d.ts +0 -2484
  54. package/dist/vc/schemas.js +0 -225
  55. package/dist/vc/statuslist.d.ts +0 -494
  56. package/dist/vc/statuslist.js +0 -133
  57. package/dist/verifier.d.ts +0 -206
  58. package/dist/verifier.js +0 -84
@@ -1,134 +0,0 @@
1
- "use strict";
2
- /**
3
- * Proof Record (Archive)
4
- *
5
- * Schema for proof records stored in KV/archive for audit trails
6
- *
7
- * Related Spec: MCP-I §5
8
- * Python Reference: Edge-Delegation-Verification.md
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.DEFAULT_PROOF_RECORD_TTL_MS = exports.ProofRecordSchema = exports.VerificationInfoSchema = exports.CrispInfoSchema = exports.LinkageInfoSchema = exports.ProofDetailsSchema = exports.ResponseInfoSchema = exports.RequestInfoSchema = void 0;
12
- exports.validateProofRecord = validateProofRecord;
13
- exports.isProofRecordExpired = isProofRecordExpired;
14
- const zod_1 = require("zod");
15
- /**
16
- * Request Info Schema
17
- *
18
- * Information about the request that was proven
19
- */
20
- exports.RequestInfoSchema = zod_1.z.object({
21
- method: zod_1.z.string(),
22
- url: zod_1.z.string().url(),
23
- bodyHash: zod_1.z.string().optional(),
24
- headersHash: zod_1.z.string().optional(),
25
- });
26
- /**
27
- * Response Info Schema
28
- *
29
- * Information about the response
30
- */
31
- exports.ResponseInfoSchema = zod_1.z.object({
32
- status: zod_1.z.number().int(),
33
- bodyHash: zod_1.z.string().optional(),
34
- });
35
- /**
36
- * Proof Details Schema
37
- *
38
- * Core proof information
39
- */
40
- exports.ProofDetailsSchema = zod_1.z.object({
41
- timestamp: zod_1.z.number().int().positive(),
42
- nonce: zod_1.z.string().min(1),
43
- did: zod_1.z.string().min(1),
44
- signature: zod_1.z.string().regex(/^[A-Za-z0-9_-]+$/),
45
- algorithm: zod_1.z.enum(['Ed25519', 'ES256']),
46
- sessionId: zod_1.z.string().min(1),
47
- audience: zod_1.z.string().min(1),
48
- request: exports.RequestInfoSchema.optional(),
49
- response: exports.ResponseInfoSchema.optional(),
50
- });
51
- /**
52
- * Linkage Info Schema
53
- *
54
- * Links to delegations and credentials
55
- */
56
- exports.LinkageInfoSchema = zod_1.z.object({
57
- delegationId: zod_1.z.string().optional(),
58
- credentialId: zod_1.z.string().optional(),
59
- chainDepth: zod_1.z.number().int().nonnegative().optional(),
60
- });
61
- /**
62
- * CRISP Info Schema
63
- *
64
- * CRISP spending information
65
- */
66
- exports.CrispInfoSchema = zod_1.z.object({
67
- unit: zod_1.z.enum(['USD', 'ops', 'points']),
68
- delta: zod_1.z.number().optional(),
69
- remaining: zod_1.z.number().optional(),
70
- });
71
- /**
72
- * Verification Info Schema
73
- *
74
- * Verification result for the proof
75
- */
76
- exports.VerificationInfoSchema = zod_1.z.object({
77
- result: zod_1.z.enum(['pending', 'pass', 'fail']),
78
- reason: zod_1.z.string().optional(),
79
- checkedAt: zod_1.z.number().int().positive().optional(),
80
- });
81
- /**
82
- * Proof Record Schema
83
- *
84
- * Complete proof record for archive/KV storage
85
- */
86
- exports.ProofRecordSchema = zod_1.z.object({
87
- /** Unique identifier for the proof record */
88
- id: zod_1.z.string().min(1),
89
- /** Tool/service name that created the proof */
90
- toolName: zod_1.z.string().min(1),
91
- /** Timestamp when stored (milliseconds since epoch) */
92
- storedAt: zod_1.z.number().int().positive(),
93
- /** Expiration timestamp (milliseconds since epoch) */
94
- expiresAt: zod_1.z.number().int().positive(),
95
- /** Core proof details */
96
- proof: exports.ProofDetailsSchema,
97
- /** Optional linkage to delegations/credentials */
98
- linkage: exports.LinkageInfoSchema.optional(),
99
- /** Optional CRISP spending info */
100
- crisp: exports.CrispInfoSchema.optional(),
101
- /** Optional verification info */
102
- verification: exports.VerificationInfoSchema.optional(),
103
- /** Optional metadata */
104
- metadata: zod_1.z.record(zod_1.z.any()).optional(),
105
- }).passthrough();
106
- /**
107
- * Validation Helpers
108
- */
109
- /**
110
- * Validate a proof record
111
- *
112
- * @param record - The record to validate
113
- * @returns Validation result
114
- */
115
- function validateProofRecord(record) {
116
- return exports.ProofRecordSchema.safeParse(record);
117
- }
118
- /**
119
- * Check if proof record is expired
120
- *
121
- * @param record - The record to check
122
- * @returns true if expired
123
- */
124
- function isProofRecordExpired(record) {
125
- return Date.now() > record.expiresAt;
126
- }
127
- /**
128
- * Constants
129
- */
130
- /**
131
- * Default proof record TTL (30 days in milliseconds)
132
- */
133
- exports.DEFAULT_PROOF_RECORD_TTL_MS = 30 * 24 * 60 * 60 * 1000;
134
- //# sourceMappingURL=proof-record.js.map
@@ -1,147 +0,0 @@
1
- /**
2
- * Proof Signing Specification
3
- *
4
- * Canonical signing order and detached JWS contracts for proofs
5
- *
6
- * Related Spec: MCP-I §5
7
- * Python Reference: Edge-Delegation-Verification.md
8
- */
9
- import { z } from 'zod';
10
- /**
11
- * Canonical Request Parts Schema
12
- *
13
- * Parts of a request that are canonically signed
14
- */
15
- export declare const CanonicalRequestPartsSchema: z.ZodObject<{
16
- /** HTTP method (uppercased) */
17
- method: z.ZodString;
18
- /** Absolute URL */
19
- url: z.ZodString;
20
- /** Optional body hash (base64url of SHA-256) */
21
- bodyHash: z.ZodOptional<z.ZodString>;
22
- /** Optional headers hash (base64url of SHA-256 of allowlisted headers) */
23
- headersHash: z.ZodOptional<z.ZodString>;
24
- /** Nonce (base64) */
25
- nonce: z.ZodString;
26
- /** Timestamp (milliseconds since epoch) */
27
- timestamp: z.ZodNumber;
28
- /** Audience (e.g., 'mcp-client') */
29
- audience: z.ZodString;
30
- }, "strip", z.ZodTypeAny, {
31
- method: string;
32
- url: string;
33
- nonce: string;
34
- timestamp: number;
35
- audience: string;
36
- bodyHash?: string | undefined;
37
- headersHash?: string | undefined;
38
- }, {
39
- method: string;
40
- url: string;
41
- nonce: string;
42
- timestamp: number;
43
- audience: string;
44
- bodyHash?: string | undefined;
45
- headersHash?: string | undefined;
46
- }>;
47
- export type CanonicalRequestParts = z.infer<typeof CanonicalRequestPartsSchema>;
48
- /**
49
- * Detached JWS Schema
50
- *
51
- * Detached JSON Web Signature for proofs
52
- */
53
- export declare const DetachedJwsSchema: z.ZodObject<{
54
- /** Algorithm (Ed25519 or ES256) */
55
- alg: z.ZodEnum<["Ed25519", "ES256"]>;
56
- /** Optional key ID (fragment from DID) */
57
- kid: z.ZodOptional<z.ZodString>;
58
- /** Base64url-encoded signature */
59
- signature: z.ZodString;
60
- }, "strip", z.ZodTypeAny, {
61
- signature: string;
62
- alg: "Ed25519" | "ES256";
63
- kid?: string | undefined;
64
- }, {
65
- signature: string;
66
- alg: "Ed25519" | "ES256";
67
- kid?: string | undefined;
68
- }>;
69
- export type DetachedJws = z.infer<typeof DetachedJwsSchema>;
70
- /**
71
- * Signing Order
72
- *
73
- * **CRITICAL**: This order MUST be used for canonical string generation.
74
- * Changing this order breaks signature verification.
75
- */
76
- export declare const SIGNING_ORDER: readonly ["method", "url", "bodyHash", "headersHash", "nonce", "timestamp", "audience"];
77
- /**
78
- * Type for signing order fields
79
- */
80
- export type SigningOrderField = (typeof SIGNING_ORDER)[number];
81
- /**
82
- * Validation Helpers
83
- */
84
- /**
85
- * Validate canonical request parts
86
- *
87
- * @param parts - The parts to validate
88
- * @returns Validation result
89
- */
90
- export declare function validateCanonicalRequestParts(parts: unknown): z.SafeParseReturnType<{
91
- method: string;
92
- url: string;
93
- nonce: string;
94
- timestamp: number;
95
- audience: string;
96
- bodyHash?: string | undefined;
97
- headersHash?: string | undefined;
98
- }, {
99
- method: string;
100
- url: string;
101
- nonce: string;
102
- timestamp: number;
103
- audience: string;
104
- bodyHash?: string | undefined;
105
- headersHash?: string | undefined;
106
- }>;
107
- /**
108
- * Validate detached JWS
109
- *
110
- * @param jws - The JWS to validate
111
- * @returns Validation result
112
- */
113
- export declare function validateDetachedJws(jws: unknown): z.SafeParseReturnType<{
114
- signature: string;
115
- alg: "Ed25519" | "ES256";
116
- kid?: string | undefined;
117
- }, {
118
- signature: string;
119
- alg: "Ed25519" | "ES256";
120
- kid?: string | undefined;
121
- }>;
122
- /**
123
- * Generate canonical signing string from parts
124
- *
125
- * **NOTE**: This is a type-level spec. Actual implementation
126
- * requires runtime string concatenation.
127
- *
128
- * @param parts - Canonical request parts
129
- * @returns Canonical string for signing
130
- */
131
- export declare function getCanonicalSigningString(parts: CanonicalRequestParts): string;
132
- /**
133
- * Constants
134
- */
135
- /**
136
- * Supported signing algorithms
137
- */
138
- export declare const SUPPORTED_SIGNING_ALGORITHMS: readonly ["Ed25519", "ES256"];
139
- /**
140
- * Hash algorithm for body/headers
141
- */
142
- export declare const SIGNING_HASH_ALGORITHM = "SHA-256";
143
- /**
144
- * Base64url pattern for validation
145
- */
146
- export declare const BASE64URL_PATTERN: RegExp;
147
- //# sourceMappingURL=signing-spec.d.ts.map
@@ -1,123 +0,0 @@
1
- "use strict";
2
- /**
3
- * Proof Signing Specification
4
- *
5
- * Canonical signing order and detached JWS contracts for proofs
6
- *
7
- * Related Spec: MCP-I §5
8
- * Python Reference: Edge-Delegation-Verification.md
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.BASE64URL_PATTERN = exports.SIGNING_HASH_ALGORITHM = exports.SUPPORTED_SIGNING_ALGORITHMS = exports.SIGNING_ORDER = exports.DetachedJwsSchema = exports.CanonicalRequestPartsSchema = void 0;
12
- exports.validateCanonicalRequestParts = validateCanonicalRequestParts;
13
- exports.validateDetachedJws = validateDetachedJws;
14
- exports.getCanonicalSigningString = getCanonicalSigningString;
15
- const zod_1 = require("zod");
16
- /**
17
- * Canonical Request Parts Schema
18
- *
19
- * Parts of a request that are canonically signed
20
- */
21
- exports.CanonicalRequestPartsSchema = zod_1.z.object({
22
- /** HTTP method (uppercased) */
23
- method: zod_1.z.string().toUpperCase(),
24
- /** Absolute URL */
25
- url: zod_1.z.string().url(),
26
- /** Optional body hash (base64url of SHA-256) */
27
- bodyHash: zod_1.z.string().regex(/^[A-Za-z0-9_-]+$/).optional(),
28
- /** Optional headers hash (base64url of SHA-256 of allowlisted headers) */
29
- headersHash: zod_1.z.string().regex(/^[A-Za-z0-9_-]+$/).optional(),
30
- /** Nonce (base64) */
31
- nonce: zod_1.z.string().min(1),
32
- /** Timestamp (milliseconds since epoch) */
33
- timestamp: zod_1.z.number().int().positive(),
34
- /** Audience (e.g., 'mcp-client') */
35
- audience: zod_1.z.string().min(1),
36
- });
37
- /**
38
- * Detached JWS Schema
39
- *
40
- * Detached JSON Web Signature for proofs
41
- */
42
- exports.DetachedJwsSchema = zod_1.z.object({
43
- /** Algorithm (Ed25519 or ES256) */
44
- alg: zod_1.z.enum(['Ed25519', 'ES256']),
45
- /** Optional key ID (fragment from DID) */
46
- kid: zod_1.z.string().optional(),
47
- /** Base64url-encoded signature */
48
- signature: zod_1.z.string().regex(/^[A-Za-z0-9_-]+$/),
49
- });
50
- /**
51
- * Signing Order
52
- *
53
- * **CRITICAL**: This order MUST be used for canonical string generation.
54
- * Changing this order breaks signature verification.
55
- */
56
- exports.SIGNING_ORDER = Object.freeze([
57
- 'method',
58
- 'url',
59
- 'bodyHash',
60
- 'headersHash',
61
- 'nonce',
62
- 'timestamp',
63
- 'audience',
64
- ]);
65
- /**
66
- * Validation Helpers
67
- */
68
- /**
69
- * Validate canonical request parts
70
- *
71
- * @param parts - The parts to validate
72
- * @returns Validation result
73
- */
74
- function validateCanonicalRequestParts(parts) {
75
- return exports.CanonicalRequestPartsSchema.safeParse(parts);
76
- }
77
- /**
78
- * Validate detached JWS
79
- *
80
- * @param jws - The JWS to validate
81
- * @returns Validation result
82
- */
83
- function validateDetachedJws(jws) {
84
- return exports.DetachedJwsSchema.safeParse(jws);
85
- }
86
- /**
87
- * Generate canonical signing string from parts
88
- *
89
- * **NOTE**: This is a type-level spec. Actual implementation
90
- * requires runtime string concatenation.
91
- *
92
- * @param parts - Canonical request parts
93
- * @returns Canonical string for signing
94
- */
95
- function getCanonicalSigningString(parts) {
96
- const values = [];
97
- for (const field of exports.SIGNING_ORDER) {
98
- const value = parts[field];
99
- if (value !== undefined) {
100
- values.push(String(value));
101
- }
102
- else {
103
- values.push('');
104
- }
105
- }
106
- return values.join('\n');
107
- }
108
- /**
109
- * Constants
110
- */
111
- /**
112
- * Supported signing algorithms
113
- */
114
- exports.SUPPORTED_SIGNING_ALGORITHMS = ['Ed25519', 'ES256'];
115
- /**
116
- * Hash algorithm for body/headers
117
- */
118
- exports.SIGNING_HASH_ALGORITHM = 'SHA-256';
119
- /**
120
- * Base64url pattern for validation
121
- */
122
- exports.BASE64URL_PATTERN = /^[A-Za-z0-9_-]+$/;
123
- //# sourceMappingURL=signing-spec.js.map