@kya-os/verifier 1.5.9 → 1.6.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.
package/README.md CHANGED
@@ -191,14 +191,14 @@ The verifier performs comprehensive validation in the following order:
191
191
 
192
192
  On successful verification, the following headers are injected:
193
193
 
194
- - `X-Agent-DID`: Agent's decentralized identifier
195
- - `X-Agent-KeyId`: Key identifier used for signing
196
- - `X-Agent-Session`: Session identifier
197
- - `X-Agent-Confidence`: Always "verified" for successful verification
198
- - `X-Agent-Registry`: URL to agent's registry page for traceability
199
- - `X-Agent-Verified-At`: Unix timestamp of verification
200
- - `X-Agent-Scopes`: Comma-separated list of scopes (if present)
201
- - `X-Agent-Delegation-Ref`: Delegation reference (if present)
194
+ - `KYA-Agent-DID`: Agent's decentralized identifier
195
+ - `KYA-Agent-KeyId`: Key identifier used for signing
196
+ - `KYA-Agent-Session`: Session identifier
197
+ - `KYA-Agent-Confidence`: Always "verified" for successful verification
198
+ - `KYA-Agent-Registry`: URL to agent's registry page for traceability
199
+ - `KYA-Verified-At`: Unix timestamp of verification
200
+ - `KYA-Agent-Scopes`: Comma-separated list of scopes (if present)
201
+ - `KYA-Delegation-Ref`: Delegation reference (if present)
202
202
 
203
203
  ## Error Handling
204
204
 
package/dist/core.d.ts ADDED
@@ -0,0 +1,145 @@
1
+ import type { DetachedProof } from "@kya-os/contracts/proof";
2
+ import type { VerifierResult } from "@kya-os/contracts/verifier";
3
+ /**
4
+ * Configuration for the verifier core
5
+ */
6
+ export interface VerifierConfig {
7
+ /**
8
+ * KTA base URL for delegation checking
9
+ */
10
+ ktaBaseUrl?: string;
11
+ /**
12
+ * Enable delegation checking via KTA
13
+ */
14
+ enableDelegationCheck?: boolean;
15
+ /**
16
+ * Clock skew tolerance in seconds
17
+ */
18
+ clockSkewTolerance?: number;
19
+ /**
20
+ * Session timeout in seconds
21
+ */
22
+ sessionTimeout?: number;
23
+ /**
24
+ * Maximum age for proofs in seconds (prevents replay of old proofs)
25
+ */
26
+ proofMaxAge?: number;
27
+ /**
28
+ * Allow mock data for testing
29
+ */
30
+ allowMockData?: boolean;
31
+ /**
32
+ * Cache TTL for DID documents in seconds
33
+ */
34
+ didCacheTtl?: number;
35
+ /**
36
+ * Cache TTL for delegation status in seconds
37
+ */
38
+ delegationCacheTtl?: number;
39
+ }
40
+ /**
41
+ * Context for proof verification
42
+ */
43
+ export interface VerificationContext {
44
+ proof: DetachedProof;
45
+ audience: string;
46
+ timestamp?: number;
47
+ }
48
+ /**
49
+ * Isomorphic verifier core for XMCP-I proof validation
50
+ *
51
+ * This is the heart of the trust system - it verifies that AI agents
52
+ * are who they claim to be and have the authority to perform actions.
53
+ */
54
+ export declare class VerifierCore {
55
+ private config;
56
+ private didCache;
57
+ private delegationCache;
58
+ constructor(config?: VerifierConfig);
59
+ /**
60
+ * Verify a detached proof and return verification result
61
+ *
62
+ * This is the main entry point for proof verification. It performs
63
+ * a comprehensive validation of the agent's identity and authorization.
64
+ */
65
+ verify(context: VerificationContext): Promise<VerifierResult>;
66
+ /**
67
+ * Validate proof structure with comprehensive checks
68
+ */
69
+ private validateProofStructure;
70
+ /**
71
+ * Validate timestamp with configurable clock skew tolerance
72
+ */
73
+ private validateTimestamp;
74
+ /**
75
+ * Validate audience matches expected value
76
+ */
77
+ private validateAudience;
78
+ /**
79
+ * Verify Ed25519 signature using JOSE with proper detached JWS handling
80
+ *
81
+ * This is the cryptographic heart of the verification process.
82
+ * It ensures the proof was signed by the claimed identity.
83
+ *
84
+ * CRITICAL for full JWS: proof.meta must match the signed JWT payload.
85
+ * Otherwise an attacker could tamper with meta (audience, timestamp, nonce)
86
+ * while keeping a valid signature. We validate meta against the decoded
87
+ * payload before trusting meta for any security decisions.
88
+ */
89
+ private verifySignature;
90
+ /**
91
+ * Validate that proof.meta matches the decoded JWT payload.
92
+ * Required for full JWS to prevent meta tampering (audience, timestamp, nonce)
93
+ * while keeping a valid signature. Returns StructuredError on mismatch.
94
+ */
95
+ private validateMetaMatchesPayload;
96
+ /**
97
+ * Create canonical payload that matches runtime implementation
98
+ * Uses JSON Canonicalization Scheme (JCS) RFC 8785 for deterministic ordering
99
+ *
100
+ * CRITICAL: Must match the JWT payload structure used by proof generators.
101
+ * Generators use standard JWT claims (aud, sub, iss) plus custom claims.
102
+ */
103
+ private createCanonicalPayload;
104
+ /**
105
+ * Verify delegation status via KTA with caching
106
+ */
107
+ private verifyDelegation;
108
+ /**
109
+ * Validate delegation response
110
+ */
111
+ private validateDelegationResponse;
112
+ /**
113
+ * Fetch public key from DID document with caching
114
+ */
115
+ private fetchPublicKeyWithCache;
116
+ /**
117
+ * Fetch DID document from well-known endpoint
118
+ */
119
+ private fetchDIDDocument;
120
+ /**
121
+ * Extract public key from DID document
122
+ */
123
+ private extractPublicKey;
124
+ /**
125
+ * Generate trusted headers for successful verification
126
+ */
127
+ private generateHeaders;
128
+ /**
129
+ * Generate agent context for MCP recipients
130
+ */
131
+ private generateAgentContext;
132
+ /**
133
+ * Create error result from structured error
134
+ */
135
+ private createErrorResult;
136
+ /**
137
+ * Log verification attempt for security monitoring
138
+ */
139
+ private logVerificationAttempt;
140
+ /**
141
+ * Clean up expired cache entries
142
+ */
143
+ cleanupCache(): void;
144
+ }
145
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAa,MAAM,yBAAyB,CAAC;AACxE,OAAO,KAAK,EACV,cAAc,EAGf,MAAM,4BAA4B,CAAC;AAGpC;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,cAAc,CAAC,EAAE,MA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