@kya-os/contracts 1.3.5 → 1.5.1

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 (89) hide show
  1. package/dist/agentshield-api/endpoints.d.ts +50 -0
  2. package/dist/agentshield-api/endpoints.js +46 -0
  3. package/dist/agentshield-api/index.d.ts +13 -0
  4. package/dist/agentshield-api/index.js +38 -0
  5. package/dist/agentshield-api/schemas.d.ts +9914 -0
  6. package/dist/agentshield-api/schemas.js +165 -0
  7. package/dist/agentshield-api/types.d.ts +168 -0
  8. package/dist/agentshield-api/types.js +27 -0
  9. package/dist/cli.d.ts +13 -0
  10. package/dist/cli.js +13 -1
  11. package/dist/config/base.d.ts +96 -0
  12. package/dist/config/base.js +11 -0
  13. package/dist/config/delegation.d.ts +194 -0
  14. package/dist/config/delegation.js +10 -0
  15. package/dist/config/identity.d.ts +117 -0
  16. package/dist/config/identity.js +11 -0
  17. package/dist/config/index.d.ts +33 -0
  18. package/dist/config/index.js +11 -0
  19. package/dist/config/proofing.d.ts +120 -0
  20. package/dist/config/proofing.js +10 -0
  21. package/dist/config/tool-protection.d.ts +139 -0
  22. package/dist/config/tool-protection.js +10 -0
  23. package/dist/dashboard-config/default-config.d.ts +49 -0
  24. package/dist/dashboard-config/default-config.js +225 -0
  25. package/dist/dashboard-config/index.d.ts +10 -0
  26. package/dist/dashboard-config/index.js +35 -0
  27. package/dist/dashboard-config/schemas.d.ts +5847 -0
  28. package/dist/dashboard-config/schemas.js +251 -0
  29. package/dist/dashboard-config/types.d.ts +331 -0
  30. package/dist/dashboard-config/types.js +11 -0
  31. package/dist/delegation/constraints.d.ts +991 -0
  32. package/dist/delegation/constraints.js +209 -0
  33. package/dist/delegation/index.d.ts +7 -0
  34. package/dist/delegation/index.js +23 -0
  35. package/dist/delegation/schemas.d.ts +8381 -0
  36. package/dist/delegation/schemas.js +475 -0
  37. package/dist/did/index.d.ts +8 -0
  38. package/dist/did/index.js +24 -0
  39. package/dist/did/resolve-contract.d.ts +219 -0
  40. package/dist/did/resolve-contract.js +31 -0
  41. package/dist/did/schemas.d.ts +112 -0
  42. package/dist/did/schemas.js +172 -0
  43. package/dist/did/types.d.ts +163 -0
  44. package/dist/did/types.js +70 -0
  45. package/dist/env/constants.d.ts +57 -0
  46. package/dist/env/constants.js +59 -0
  47. package/dist/env/index.d.ts +4 -0
  48. package/dist/env/index.js +20 -0
  49. package/dist/handshake.d.ts +20 -0
  50. package/dist/handshake.js +10 -3
  51. package/dist/index.d.ts +14 -0
  52. package/dist/index.js +28 -0
  53. package/dist/proof/index.d.ts +8 -0
  54. package/dist/proof/index.js +24 -0
  55. package/dist/proof/proof-record.d.ts +837 -0
  56. package/dist/proof/proof-record.js +133 -0
  57. package/dist/proof/signing-spec.d.ts +146 -0
  58. package/dist/proof/signing-spec.js +122 -0
  59. package/dist/proof.d.ts +53 -16
  60. package/dist/proof.js +27 -3
  61. package/dist/registry.d.ts +16 -0
  62. package/dist/registry.js +29 -9
  63. package/dist/runtime/errors.d.ts +347 -0
  64. package/dist/runtime/errors.js +119 -0
  65. package/dist/runtime/headers.d.ts +83 -0
  66. package/dist/runtime/headers.js +81 -0
  67. package/dist/runtime/index.d.ts +5 -0
  68. package/dist/runtime/index.js +21 -0
  69. package/dist/test.d.ts +36 -0
  70. package/dist/test.js +36 -0
  71. package/dist/tlkrc/index.d.ts +4 -0
  72. package/dist/tlkrc/index.js +20 -0
  73. package/dist/tlkrc/rotation.d.ts +245 -0
  74. package/dist/tlkrc/rotation.js +126 -0
  75. package/dist/tool-protection/index.d.ts +227 -0
  76. package/dist/tool-protection/index.js +113 -0
  77. package/dist/utils/validation.d.ts +16 -0
  78. package/dist/utils/validation.js +13 -0
  79. package/dist/vc/index.d.ts +7 -0
  80. package/dist/vc/index.js +23 -0
  81. package/dist/vc/schemas.d.ts +2483 -0
  82. package/dist/vc/schemas.js +224 -0
  83. package/dist/vc/statuslist.d.ts +493 -0
  84. package/dist/vc/statuslist.js +132 -0
  85. package/dist/verifier.d.ts +3 -0
  86. package/dist/verifier.js +7 -0
  87. package/dist/well-known/index.d.ts +308 -0
  88. package/dist/well-known/index.js +134 -0
  89. package/package.json +6 -1
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Runtime Header Contracts
3
+ *
4
+ * Header contracts for downstream services
5
+ *
6
+ * Related Spec: MCP-I §6
7
+ * Python Reference: Core-Documentation.md
8
+ */
9
+ /**
10
+ * Downstream Headers Interface
11
+ *
12
+ * Headers passed to downstream services after verification
13
+ */
14
+ export interface DownstreamHeaders {
15
+ /** DID of the verified agent */
16
+ 'X-Agent-DID': string;
17
+ /** Optional delegation ID */
18
+ 'X-Delegation-Id'?: string;
19
+ /** Optional delegation chain (format: vc_id>del_id>...) */
20
+ 'X-Delegation-Chain'?: string;
21
+ /** Proof ID for audit trail */
22
+ 'X-MCPI-Proof-Id': string;
23
+ /** Optional CRISP spend info (JSON string: {unit, delta, remaining}) */
24
+ 'X-CRISP-Spend'?: string;
25
+ /** Optional session ID */
26
+ 'X-Session-Id'?: string;
27
+ /** Optional scopes */
28
+ 'X-Scopes'?: string;
29
+ }
30
+ /**
31
+ * Header names as constants for type safety
32
+ */
33
+ export declare const DOWNSTREAM_HEADER_NAMES: Readonly<{
34
+ readonly AGENT_DID: "X-Agent-DID";
35
+ readonly DELEGATION_ID: "X-Delegation-Id";
36
+ readonly DELEGATION_CHAIN: "X-Delegation-Chain";
37
+ readonly PROOF_ID: "X-MCPI-Proof-Id";
38
+ readonly CRISP_SPEND: "X-CRISP-Spend";
39
+ readonly SESSION_ID: "X-Session-Id";
40
+ readonly SCOPES: "X-Scopes";
41
+ }>;
42
+ /**
43
+ * CRISP Spend Info
44
+ *
45
+ * Structure for X-CRISP-Spend header value
46
+ */
47
+ export interface CrispSpendInfo {
48
+ /** Unit of spending */
49
+ unit: 'USD' | 'ops' | 'points';
50
+ /** Amount spent in this request */
51
+ delta?: number;
52
+ /** Remaining budget */
53
+ remaining?: number;
54
+ }
55
+ /**
56
+ * Helper to serialize CRISP spend info to header value
57
+ *
58
+ * @param info - CRISP spend info
59
+ * @returns JSON string for header
60
+ */
61
+ export declare function serializeCrispSpend(info: CrispSpendInfo): string;
62
+ /**
63
+ * Helper to parse CRISP spend info from header value
64
+ *
65
+ * @param headerValue - JSON string from header
66
+ * @returns Parsed CRISP spend info or null if invalid
67
+ */
68
+ export declare function parseCrispSpend(headerValue: string): CrispSpendInfo | null;
69
+ /**
70
+ * Helper to create downstream headers
71
+ *
72
+ * @param config - Configuration for headers
73
+ * @returns DownstreamHeaders object
74
+ */
75
+ export declare function createDownstreamHeaders(config: {
76
+ agentDid: string;
77
+ proofId: string;
78
+ delegationId?: string;
79
+ delegationChain?: string;
80
+ crispSpend?: CrispSpendInfo;
81
+ sessionId?: string;
82
+ scopes?: string[];
83
+ }): DownstreamHeaders;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ /**
3
+ * Runtime Header Contracts
4
+ *
5
+ * Header contracts for downstream services
6
+ *
7
+ * Related Spec: MCP-I §6
8
+ * Python Reference: Core-Documentation.md
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.DOWNSTREAM_HEADER_NAMES = void 0;
12
+ exports.serializeCrispSpend = serializeCrispSpend;
13
+ exports.parseCrispSpend = parseCrispSpend;
14
+ exports.createDownstreamHeaders = createDownstreamHeaders;
15
+ /**
16
+ * Header names as constants for type safety
17
+ */
18
+ exports.DOWNSTREAM_HEADER_NAMES = Object.freeze({
19
+ AGENT_DID: 'X-Agent-DID',
20
+ DELEGATION_ID: 'X-Delegation-Id',
21
+ DELEGATION_CHAIN: 'X-Delegation-Chain',
22
+ PROOF_ID: 'X-MCPI-Proof-Id',
23
+ CRISP_SPEND: 'X-CRISP-Spend',
24
+ SESSION_ID: 'X-Session-Id',
25
+ SCOPES: 'X-Scopes',
26
+ });
27
+ /**
28
+ * Helper to serialize CRISP spend info to header value
29
+ *
30
+ * @param info - CRISP spend info
31
+ * @returns JSON string for header
32
+ */
33
+ function serializeCrispSpend(info) {
34
+ return JSON.stringify(info);
35
+ }
36
+ /**
37
+ * Helper to parse CRISP spend info from header value
38
+ *
39
+ * @param headerValue - JSON string from header
40
+ * @returns Parsed CRISP spend info or null if invalid
41
+ */
42
+ function parseCrispSpend(headerValue) {
43
+ try {
44
+ const parsed = JSON.parse(headerValue);
45
+ if (parsed && typeof parsed.unit === 'string') {
46
+ return parsed;
47
+ }
48
+ return null;
49
+ }
50
+ catch {
51
+ return null;
52
+ }
53
+ }
54
+ /**
55
+ * Helper to create downstream headers
56
+ *
57
+ * @param config - Configuration for headers
58
+ * @returns DownstreamHeaders object
59
+ */
60
+ function createDownstreamHeaders(config) {
61
+ const headers = {
62
+ 'X-Agent-DID': config.agentDid,
63
+ 'X-MCPI-Proof-Id': config.proofId,
64
+ };
65
+ if (config.delegationId) {
66
+ headers['X-Delegation-Id'] = config.delegationId;
67
+ }
68
+ if (config.delegationChain) {
69
+ headers['X-Delegation-Chain'] = config.delegationChain;
70
+ }
71
+ if (config.crispSpend) {
72
+ headers['X-CRISP-Spend'] = serializeCrispSpend(config.crispSpend);
73
+ }
74
+ if (config.sessionId) {
75
+ headers['X-Session-Id'] = config.sessionId;
76
+ }
77
+ if (config.scopes && config.scopes.length > 0) {
78
+ headers['X-Scopes'] = config.scopes.join(',');
79
+ }
80
+ return headers;
81
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Runtime Module Exports
3
+ */
4
+ export * from './errors.js';
5
+ export * from './headers.js';
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ /**
3
+ * Runtime Module Exports
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ __exportStar(require("./errors.js"), exports);
21
+ __exportStar(require("./headers.js"), exports);
package/dist/test.d.ts CHANGED
@@ -1,4 +1,13 @@
1
+ /**
2
+ * Test infrastructure types and schemas for XMCP-I
3
+ *
4
+ * This module provides types and utilities for testing XMCP-I applications
5
+ * without hitting external services like KTA.
6
+ */
1
7
  import { z } from "zod";
8
+ /**
9
+ * Test environment configuration
10
+ */
2
11
  export declare const TestEnvironmentSchema: z.ZodObject<{
3
12
  mode: z.ZodLiteral<"test">;
4
13
  seed: z.ZodOptional<z.ZodString>;
@@ -16,6 +25,9 @@ export declare const TestEnvironmentSchema: z.ZodObject<{
16
25
  skipKTACalls?: boolean | undefined;
17
26
  }>;
18
27
  export type TestEnvironment = z.infer<typeof TestEnvironmentSchema>;
28
+ /**
29
+ * Mock identity configuration for testing
30
+ */
19
31
  export declare const MockIdentitySchema: z.ZodObject<{
20
32
  did: z.ZodString;
21
33
  kid: z.ZodString;
@@ -39,10 +51,19 @@ export declare const MockIdentitySchema: z.ZodObject<{
39
51
  lastRotated?: string | undefined;
40
52
  }>;
41
53
  export type MockIdentity = z.infer<typeof MockIdentitySchema>;
54
+ /**
55
+ * Mock delegation status for testing
56
+ */
42
57
  export declare const MockDelegationStatusSchema: z.ZodEnum<["active", "revoked", "pending"]>;
43
58
  export type MockDelegationStatus = z.infer<typeof MockDelegationStatusSchema>;
59
+ /**
60
+ * Mock KTA failure scenarios for testing
61
+ */
44
62
  export declare const MockKTAFailureTypeSchema: z.ZodEnum<["network", "auth", "invalid", "timeout"]>;
45
63
  export type MockKTAFailureType = z.infer<typeof MockKTAFailureTypeSchema>;
64
+ /**
65
+ * Mock identity provider configuration
66
+ */
46
67
  export declare const MockIdentityProviderConfigSchema: z.ZodObject<{
47
68
  identities: z.ZodRecord<z.ZodString, z.ZodObject<{
48
69
  did: z.ZodString;
@@ -95,6 +116,9 @@ export declare const MockIdentityProviderConfigSchema: z.ZodObject<{
95
116
  deterministicSeed?: string | undefined;
96
117
  }>;
97
118
  export type MockIdentityProviderConfig = z.infer<typeof MockIdentityProviderConfigSchema>;
119
+ /**
120
+ * Local verification result for offline testing
121
+ */
98
122
  export declare const LocalVerificationResultSchema: z.ZodObject<{
99
123
  valid: z.ZodBoolean;
100
124
  did: z.ZodOptional<z.ZodString>;
@@ -194,6 +218,9 @@ export declare const LocalVerificationResultSchema: z.ZodObject<{
194
218
  errors?: string[] | undefined;
195
219
  }>;
196
220
  export type LocalVerificationResult = z.infer<typeof LocalVerificationResultSchema>;
221
+ /**
222
+ * Test DID and Key ID constants
223
+ */
197
224
  export declare const TEST_DIDS: {
198
225
  readonly AGENT_1: "did:test:agent-1";
199
226
  readonly AGENT_2: "did:test:agent-2";
@@ -204,8 +231,17 @@ export declare const TEST_KEY_IDS: {
204
231
  readonly KEY_TEST_2: "key-test-2";
205
232
  readonly KEY_VERIFIER_1: "key-verifier-1";
206
233
  };
234
+ /**
235
+ * Test environment detection
236
+ */
207
237
  export declare function isTestEnvironment(): boolean;
238
+ /**
239
+ * Get test seed from environment or test name
240
+ */
208
241
  export declare function getTestSeed(testName?: string): string;
242
+ /**
243
+ * Error codes for test infrastructure
244
+ */
209
245
  export declare const TEST_ERROR_CODES: {
210
246
  readonly MOCK_KTA_FAILURE: "XMCP_I_TEST_MOCK_KTA_FAILURE";
211
247
  readonly DETERMINISTIC_KEY_GENERATION_FAILED: "XMCP_I_TEST_DETERMINISTIC_KEY_FAILED";
package/dist/test.js CHANGED
@@ -1,15 +1,27 @@
1
1
  "use strict";
2
+ /**
3
+ * Test infrastructure types and schemas for XMCP-I
4
+ *
5
+ * This module provides types and utilities for testing XMCP-I applications
6
+ * without hitting external services like KTA.
7
+ */
2
8
  Object.defineProperty(exports, "__esModule", { value: true });
3
9
  exports.TEST_ERROR_CODES = exports.TEST_KEY_IDS = exports.TEST_DIDS = exports.LocalVerificationResultSchema = exports.MockIdentityProviderConfigSchema = exports.MockKTAFailureTypeSchema = exports.MockDelegationStatusSchema = exports.MockIdentitySchema = exports.TestEnvironmentSchema = void 0;
4
10
  exports.isTestEnvironment = isTestEnvironment;
5
11
  exports.getTestSeed = getTestSeed;
6
12
  const zod_1 = require("zod");
13
+ /**
14
+ * Test environment configuration
15
+ */
7
16
  exports.TestEnvironmentSchema = zod_1.z.object({
8
17
  mode: zod_1.z.literal("test"),
9
18
  seed: zod_1.z.string().optional(),
10
19
  deterministicKeys: zod_1.z.boolean().default(true),
11
20
  skipKTACalls: zod_1.z.boolean().default(true),
12
21
  });
22
+ /**
23
+ * Mock identity configuration for testing
24
+ */
13
25
  exports.MockIdentitySchema = zod_1.z.object({
14
26
  did: zod_1.z.string(),
15
27
  kid: zod_1.z.string(),
@@ -18,23 +30,35 @@ exports.MockIdentitySchema = zod_1.z.object({
18
30
  createdAt: zod_1.z.string(),
19
31
  lastRotated: zod_1.z.string().optional(),
20
32
  });
33
+ /**
34
+ * Mock delegation status for testing
35
+ */
21
36
  exports.MockDelegationStatusSchema = zod_1.z.enum([
22
37
  "active",
23
38
  "revoked",
24
39
  "pending",
25
40
  ]);
41
+ /**
42
+ * Mock KTA failure scenarios for testing
43
+ */
26
44
  exports.MockKTAFailureTypeSchema = zod_1.z.enum([
27
45
  "network",
28
46
  "auth",
29
47
  "invalid",
30
48
  "timeout",
31
49
  ]);
50
+ /**
51
+ * Mock identity provider configuration
52
+ */
32
53
  exports.MockIdentityProviderConfigSchema = zod_1.z.object({
33
54
  identities: zod_1.z.record(zod_1.z.string(), exports.MockIdentitySchema),
34
55
  delegations: zod_1.z.record(zod_1.z.string(), exports.MockDelegationStatusSchema),
35
56
  ktaFailures: zod_1.z.array(exports.MockKTAFailureTypeSchema).default([]),
36
57
  deterministicSeed: zod_1.z.string().optional(),
37
58
  });
59
+ /**
60
+ * Local verification result for offline testing
61
+ */
38
62
  exports.LocalVerificationResultSchema = zod_1.z.object({
39
63
  valid: zod_1.z.boolean(),
40
64
  did: zod_1.z.string().optional(),
@@ -59,6 +83,9 @@ exports.LocalVerificationResultSchema = zod_1.z.object({
59
83
  errors: zod_1.z.array(zod_1.z.string()).default([]),
60
84
  warnings: zod_1.z.array(zod_1.z.string()).default([]),
61
85
  });
86
+ /**
87
+ * Test DID and Key ID constants
88
+ */
62
89
  exports.TEST_DIDS = {
63
90
  AGENT_1: "did:test:agent-1",
64
91
  AGENT_2: "did:test:agent-2",
@@ -69,12 +96,21 @@ exports.TEST_KEY_IDS = {
69
96
  KEY_TEST_2: "key-test-2",
70
97
  KEY_VERIFIER_1: "key-verifier-1",
71
98
  };
99
+ /**
100
+ * Test environment detection
101
+ */
72
102
  function isTestEnvironment() {
73
103
  return process.env.XMCP_ENV === "test";
74
104
  }
105
+ /**
106
+ * Get test seed from environment or test name
107
+ */
75
108
  function getTestSeed(testName) {
76
109
  return process.env.XMCP_TEST_SEED || testName || "default-test-seed";
77
110
  }
111
+ /**
112
+ * Error codes for test infrastructure
113
+ */
78
114
  exports.TEST_ERROR_CODES = {
79
115
  MOCK_KTA_FAILURE: "XMCP_I_TEST_MOCK_KTA_FAILURE",
80
116
  DETERMINISTIC_KEY_GENERATION_FAILED: "XMCP_I_TEST_DETERMINISTIC_KEY_FAILED",
@@ -0,0 +1,4 @@
1
+ /**
2
+ * TLKRC Module Exports
3
+ */
4
+ export * from './rotation.js';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /**
3
+ * TLKRC Module Exports
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ __exportStar(require("./rotation.js"), exports);
@@ -0,0 +1,245 @@
1
+ /**
2
+ * TLKRC (Transparent Log Key Rotation Contract)
3
+ *
4
+ * Types for key rotation events in a transparent, auditable manner
5
+ *
6
+ * Related Spec: MCP-I Core
7
+ * Python Reference: Core-Documentation.md
8
+ */
9
+ import { z } from 'zod';
10
+ /**
11
+ * Rotation Event Schema
12
+ *
13
+ * Represents a key rotation event in a transparent log.
14
+ * Events form a hash-linked chain for auditability.
15
+ *
16
+ * **Dual-Key Grace Window:**
17
+ * During rotation, both `prevKeyId` and `nextKeyId` are valid
18
+ * from `effectiveAt` until `effectiveAt + grace period`.
19
+ */
20
+ export declare const RotationEventSchema: z.ZodEffects<z.ZodObject<{
21
+ /** DID of the issuer performing the rotation */
22
+ issuerDid: z.ZodString;
23
+ /** Previous key ID being rotated out */
24
+ prevKeyId: z.ZodString;
25
+ /** New key ID being rotated in */
26
+ nextKeyId: z.ZodString;
27
+ /** Timestamp when new key becomes effective (Unix seconds) */
28
+ effectiveAt: z.ZodNumber;
29
+ /** Timestamp when event was issued (Unix seconds) */
30
+ issuedAt: z.ZodNumber;
31
+ /** Sequence number (monotonically increasing) */
32
+ seq: z.ZodNumber;
33
+ /** Hash of previous rotation event (null for first rotation) */
34
+ prevEventHash: z.ZodOptional<z.ZodString>;
35
+ /** Signature over the event (using prevKeyId) */
36
+ signature: z.ZodString;
37
+ /** Optional metadata */
38
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
39
+ }, "strip", z.ZodTypeAny, {
40
+ signature: string;
41
+ issuerDid: string;
42
+ prevKeyId: string;
43
+ nextKeyId: string;
44
+ effectiveAt: number;
45
+ issuedAt: number;
46
+ seq: number;
47
+ metadata?: Record<string, any> | undefined;
48
+ prevEventHash?: string | undefined;
49
+ }, {
50
+ signature: string;
51
+ issuerDid: string;
52
+ prevKeyId: string;
53
+ nextKeyId: string;
54
+ effectiveAt: number;
55
+ issuedAt: number;
56
+ seq: number;
57
+ metadata?: Record<string, any> | undefined;
58
+ prevEventHash?: string | undefined;
59
+ }>, {
60
+ signature: string;
61
+ issuerDid: string;
62
+ prevKeyId: string;
63
+ nextKeyId: string;
64
+ effectiveAt: number;
65
+ issuedAt: number;
66
+ seq: number;
67
+ metadata?: Record<string, any> | undefined;
68
+ prevEventHash?: string | undefined;
69
+ }, {
70
+ signature: string;
71
+ issuerDid: string;
72
+ prevKeyId: string;
73
+ nextKeyId: string;
74
+ effectiveAt: number;
75
+ issuedAt: number;
76
+ seq: number;
77
+ metadata?: Record<string, any> | undefined;
78
+ prevEventHash?: string | undefined;
79
+ }>;
80
+ export type RotationEvent = z.infer<typeof RotationEventSchema>;
81
+ /**
82
+ * Rotation Chain
83
+ *
84
+ * Represents a chain of rotation events
85
+ */
86
+ export declare const RotationChainSchema: z.ZodObject<{
87
+ /** Issuer DID */
88
+ issuerDid: z.ZodString;
89
+ /** All rotation events in order */
90
+ events: z.ZodArray<z.ZodEffects<z.ZodObject<{
91
+ /** DID of the issuer performing the rotation */
92
+ issuerDid: z.ZodString;
93
+ /** Previous key ID being rotated out */
94
+ prevKeyId: z.ZodString;
95
+ /** New key ID being rotated in */
96
+ nextKeyId: z.ZodString;
97
+ /** Timestamp when new key becomes effective (Unix seconds) */
98
+ effectiveAt: z.ZodNumber;
99
+ /** Timestamp when event was issued (Unix seconds) */
100
+ issuedAt: z.ZodNumber;
101
+ /** Sequence number (monotonically increasing) */
102
+ seq: z.ZodNumber;
103
+ /** Hash of previous rotation event (null for first rotation) */
104
+ prevEventHash: z.ZodOptional<z.ZodString>;
105
+ /** Signature over the event (using prevKeyId) */
106
+ signature: z.ZodString;
107
+ /** Optional metadata */
108
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
109
+ }, "strip", z.ZodTypeAny, {
110
+ signature: string;
111
+ issuerDid: string;
112
+ prevKeyId: string;
113
+ nextKeyId: string;
114
+ effectiveAt: number;
115
+ issuedAt: number;
116
+ seq: number;
117
+ metadata?: Record<string, any> | undefined;
118
+ prevEventHash?: string | undefined;
119
+ }, {
120
+ signature: string;
121
+ issuerDid: string;
122
+ prevKeyId: string;
123
+ nextKeyId: string;
124
+ effectiveAt: number;
125
+ issuedAt: number;
126
+ seq: number;
127
+ metadata?: Record<string, any> | undefined;
128
+ prevEventHash?: string | undefined;
129
+ }>, {
130
+ signature: string;
131
+ issuerDid: string;
132
+ prevKeyId: string;
133
+ nextKeyId: string;
134
+ effectiveAt: number;
135
+ issuedAt: number;
136
+ seq: number;
137
+ metadata?: Record<string, any> | undefined;
138
+ prevEventHash?: string | undefined;
139
+ }, {
140
+ signature: string;
141
+ issuerDid: string;
142
+ prevKeyId: string;
143
+ nextKeyId: string;
144
+ effectiveAt: number;
145
+ issuedAt: number;
146
+ seq: number;
147
+ metadata?: Record<string, any> | undefined;
148
+ prevEventHash?: string | undefined;
149
+ }>, "many">;
150
+ /** Current active key ID */
151
+ currentKeyId: z.ZodString;
152
+ /** Whether chain is valid */
153
+ valid: z.ZodBoolean;
154
+ /** Optional validation errors */
155
+ errors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
156
+ }, "strip", z.ZodTypeAny, {
157
+ valid: boolean;
158
+ issuerDid: string;
159
+ events: {
160
+ signature: string;
161
+ issuerDid: string;
162
+ prevKeyId: string;
163
+ nextKeyId: string;
164
+ effectiveAt: number;
165
+ issuedAt: number;
166
+ seq: number;
167
+ metadata?: Record<string, any> | undefined;
168
+ prevEventHash?: string | undefined;
169
+ }[];
170
+ currentKeyId: string;
171
+ errors?: string[] | undefined;
172
+ }, {
173
+ valid: boolean;
174
+ issuerDid: string;
175
+ events: {
176
+ signature: string;
177
+ issuerDid: string;
178
+ prevKeyId: string;
179
+ nextKeyId: string;
180
+ effectiveAt: number;
181
+ issuedAt: number;
182
+ seq: number;
183
+ metadata?: Record<string, any> | undefined;
184
+ prevEventHash?: string | undefined;
185
+ }[];
186
+ currentKeyId: string;
187
+ errors?: string[] | undefined;
188
+ }>;
189
+ export type RotationChain = z.infer<typeof RotationChainSchema>;
190
+ /**
191
+ * Validation Helpers
192
+ */
193
+ /**
194
+ * Validate a rotation event
195
+ *
196
+ * @param event - The event to validate
197
+ * @returns Validation result
198
+ */
199
+ export declare function validateRotationEvent(event: unknown): z.SafeParseReturnType<{
200
+ signature: string;
201
+ issuerDid: string;
202
+ prevKeyId: string;
203
+ nextKeyId: string;
204
+ effectiveAt: number;
205
+ issuedAt: number;
206
+ seq: number;
207
+ metadata?: Record<string, any> | undefined;
208
+ prevEventHash?: string | undefined;
209
+ }, {
210
+ signature: string;
211
+ issuerDid: string;
212
+ prevKeyId: string;
213
+ nextKeyId: string;
214
+ effectiveAt: number;
215
+ issuedAt: number;
216
+ seq: number;
217
+ metadata?: Record<string, any> | undefined;
218
+ prevEventHash?: string | undefined;
219
+ }>;
220
+ /**
221
+ * Validate rotation chain integrity
222
+ *
223
+ * @param chain - The chain to validate
224
+ * @returns true if chain is valid
225
+ */
226
+ export declare function isRotationChainValid(chain: RotationChain): boolean;
227
+ /**
228
+ * Get active key at a specific timestamp
229
+ *
230
+ * @param chain - The rotation chain
231
+ * @param timestamp - Timestamp in seconds
232
+ * @returns Active key ID at that time, or null if none
233
+ */
234
+ export declare function getActiveKeyAt(chain: RotationChain, timestamp: number): string | null;
235
+ /**
236
+ * Constants
237
+ */
238
+ /**
239
+ * Default grace period for dual-key validity (24 hours)
240
+ */
241
+ export declare const DEFAULT_GRACE_PERIOD_SEC: number;
242
+ /**
243
+ * Maximum reasonable grace period (30 days)
244
+ */
245
+ export declare const MAX_GRACE_PERIOD_SEC: number;