@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,127 +0,0 @@
1
- "use strict";
2
- /**
3
- * TLKRC (Transparent Log Key Rotation Contract)
4
- *
5
- * Types for key rotation events in a transparent, auditable manner
6
- *
7
- * Related Spec: MCP-I Core
8
- * Python Reference: Core-Documentation.md
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.MAX_GRACE_PERIOD_SEC = exports.DEFAULT_GRACE_PERIOD_SEC = exports.RotationChainSchema = exports.RotationEventSchema = void 0;
12
- exports.validateRotationEvent = validateRotationEvent;
13
- exports.isRotationChainValid = isRotationChainValid;
14
- exports.getActiveKeyAt = getActiveKeyAt;
15
- const zod_1 = require("zod");
16
- /**
17
- * Rotation Event Schema
18
- *
19
- * Represents a key rotation event in a transparent log.
20
- * Events form a hash-linked chain for auditability.
21
- *
22
- * **Dual-Key Grace Window:**
23
- * During rotation, both `prevKeyId` and `nextKeyId` are valid
24
- * from `effectiveAt` until `effectiveAt + grace period`.
25
- */
26
- exports.RotationEventSchema = zod_1.z.object({
27
- /** DID of the issuer performing the rotation */
28
- issuerDid: zod_1.z.string().min(1),
29
- /** Previous key ID being rotated out */
30
- prevKeyId: zod_1.z.string().min(1),
31
- /** New key ID being rotated in */
32
- nextKeyId: zod_1.z.string().min(1),
33
- /** Timestamp when new key becomes effective (Unix seconds) */
34
- effectiveAt: zod_1.z.number().int().positive(),
35
- /** Timestamp when event was issued (Unix seconds) */
36
- issuedAt: zod_1.z.number().int().positive(),
37
- /** Sequence number (monotonically increasing) */
38
- seq: zod_1.z.number().int().nonnegative(),
39
- /** Hash of previous rotation event (null for first rotation) */
40
- prevEventHash: zod_1.z.string().optional(),
41
- /** Signature over the event (using prevKeyId) */
42
- signature: zod_1.z.string().min(1),
43
- /** Optional metadata */
44
- metadata: zod_1.z.record(zod_1.z.any()).optional(),
45
- }).refine((event) => event.effectiveAt >= event.issuedAt, {
46
- message: 'effectiveAt must be >= issuedAt',
47
- });
48
- /**
49
- * Rotation Chain
50
- *
51
- * Represents a chain of rotation events
52
- */
53
- exports.RotationChainSchema = zod_1.z.object({
54
- /** Issuer DID */
55
- issuerDid: zod_1.z.string().min(1),
56
- /** All rotation events in order */
57
- events: zod_1.z.array(exports.RotationEventSchema).min(1),
58
- /** Current active key ID */
59
- currentKeyId: zod_1.z.string().min(1),
60
- /** Whether chain is valid */
61
- valid: zod_1.z.boolean(),
62
- /** Optional validation errors */
63
- errors: zod_1.z.array(zod_1.z.string()).optional(),
64
- });
65
- /**
66
- * Validation Helpers
67
- */
68
- /**
69
- * Validate a rotation event
70
- *
71
- * @param event - The event to validate
72
- * @returns Validation result
73
- */
74
- function validateRotationEvent(event) {
75
- return exports.RotationEventSchema.safeParse(event);
76
- }
77
- /**
78
- * Validate rotation chain integrity
79
- *
80
- * @param chain - The chain to validate
81
- * @returns true if chain is valid
82
- */
83
- function isRotationChainValid(chain) {
84
- if (chain.events.length === 0) {
85
- return false;
86
- }
87
- // Check sequence numbers are monotonic
88
- for (let i = 1; i < chain.events.length; i++) {
89
- if (chain.events[i].seq <= chain.events[i - 1].seq) {
90
- return false;
91
- }
92
- }
93
- return chain.valid;
94
- }
95
- /**
96
- * Get active key at a specific timestamp
97
- *
98
- * @param chain - The rotation chain
99
- * @param timestamp - Timestamp in seconds
100
- * @returns Active key ID at that time, or null if none
101
- */
102
- function getActiveKeyAt(chain, timestamp) {
103
- if (chain.events.length === 0) {
104
- return null;
105
- }
106
- // Find the most recent event that's effective at the timestamp
107
- for (let i = chain.events.length - 1; i >= 0; i--) {
108
- const event = chain.events[i];
109
- if (event.effectiveAt <= timestamp) {
110
- return event.nextKeyId;
111
- }
112
- }
113
- // If no event is effective yet, use the initial key
114
- return chain.events[0].prevKeyId;
115
- }
116
- /**
117
- * Constants
118
- */
119
- /**
120
- * Default grace period for dual-key validity (24 hours)
121
- */
122
- exports.DEFAULT_GRACE_PERIOD_SEC = 24 * 60 * 60;
123
- /**
124
- * Maximum reasonable grace period (30 days)
125
- */
126
- exports.MAX_GRACE_PERIOD_SEC = 30 * 24 * 60 * 60;
127
- //# sourceMappingURL=rotation.js.map
@@ -1,31 +0,0 @@
1
- /**
2
- * Shared validation utilities for mcpi packages
3
- * Consolidates common validation patterns to follow DRY principles
4
- */
5
- import { z } from "zod";
6
- /**
7
- * Generic validation result type
8
- */
9
- export interface ValidationResult<T = any> {
10
- valid: boolean;
11
- data?: T;
12
- errors: string[];
13
- }
14
- /**
15
- * Generic validation function with helpful error messages
16
- */
17
- export declare function validateInput<T>(schema: z.ZodSchema<T>, data: unknown, context?: string): ValidationResult<T>;
18
- /**
19
- * Validate object has required properties
20
- */
21
- export declare function hasRequiredProperties(obj: any, properties: string[], context?: string): ValidationResult;
22
- /**
23
- * Validate string format patterns
24
- */
25
- export declare const StringValidators: {
26
- did: (value: string) => boolean;
27
- kid: (value: string) => boolean;
28
- url: (value: string) => boolean;
29
- projectName: (value: string) => boolean;
30
- };
31
- //# sourceMappingURL=validation.d.ts.map
@@ -1,70 +0,0 @@
1
- "use strict";
2
- /**
3
- * Shared validation utilities for mcpi packages
4
- * Consolidates common validation patterns to follow DRY principles
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.StringValidators = void 0;
8
- exports.validateInput = validateInput;
9
- exports.hasRequiredProperties = hasRequiredProperties;
10
- /**
11
- * Generic validation function with helpful error messages
12
- */
13
- function validateInput(schema, data, context) {
14
- const result = schema.safeParse(data);
15
- if (result.success) {
16
- return {
17
- valid: true,
18
- data: result.data,
19
- errors: [],
20
- };
21
- }
22
- const errors = result.error.errors.map((err) => {
23
- const path = err.path.length > 0 ? ` at ${err.path.join(".")}` : "";
24
- const contextStr = context ? ` (${context})` : "";
25
- return `${err.message}${path}${contextStr}`;
26
- });
27
- return {
28
- valid: false,
29
- errors,
30
- };
31
- }
32
- /**
33
- * Validate object has required properties
34
- */
35
- function hasRequiredProperties(obj, properties, context) {
36
- if (typeof obj !== "object" || obj === null) {
37
- return {
38
- valid: false,
39
- errors: [`Expected object${context ? ` for ${context}` : ""}`],
40
- };
41
- }
42
- const missing = properties.filter((prop) => !(prop in obj));
43
- if (missing.length > 0) {
44
- return {
45
- valid: false,
46
- errors: [
47
- `Missing required properties: ${missing.join(", ")}${context ? ` in ${context}` : ""}`,
48
- ],
49
- };
50
- }
51
- return { valid: true, errors: [] };
52
- }
53
- /**
54
- * Validate string format patterns
55
- */
56
- exports.StringValidators = {
57
- did: (value) => /^did:[a-z0-9]+:[a-zA-Z0-9._-]+$/.test(value),
58
- kid: (value) => /^[a-zA-Z0-9._-]+$/.test(value),
59
- url: (value) => {
60
- try {
61
- new URL(value);
62
- return true;
63
- }
64
- catch {
65
- return false;
66
- }
67
- },
68
- projectName: (value) => /^[a-z0-9-]+$/.test(value) && value.length >= 1 && value.length <= 214,
69
- };
70
- //# sourceMappingURL=validation.js.map
@@ -1,8 +0,0 @@
1
- /**
2
- * Verifiable Credentials Module Exports
3
- *
4
- * W3C Verifiable Credentials types, schemas, and utilities
5
- */
6
- export * from './schemas.js';
7
- export * from './statuslist.js';
8
- //# sourceMappingURL=index.d.ts.map
package/dist/vc/index.js DELETED
@@ -1,24 +0,0 @@
1
- "use strict";
2
- /**
3
- * Verifiable Credentials Module Exports
4
- *
5
- * W3C Verifiable Credentials types, schemas, and utilities
6
- */
7
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
- if (k2 === undefined) k2 = k;
9
- var desc = Object.getOwnPropertyDescriptor(m, k);
10
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
- desc = { enumerable: true, get: function() { return m[k]; } };
12
- }
13
- Object.defineProperty(o, k2, desc);
14
- }) : (function(o, m, k, k2) {
15
- if (k2 === undefined) k2 = k;
16
- o[k2] = m[k];
17
- }));
18
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- __exportStar(require("./schemas.js"), exports);
23
- __exportStar(require("./statuslist.js"), exports);
24
- //# sourceMappingURL=index.js.map