@kya-os/verifier 1.3.1-canary.0 → 1.3.3-canary.0
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/dist/worker.js +5 -5
- package/dist/worker.js.map +1 -1
- package/package.json +4 -4
- package/dist/core.d.ts +0 -131
- package/dist/worker.d.ts +0 -158
package/dist/worker.js
CHANGED
|
@@ -140,13 +140,13 @@ export async function verifyWorker(request, envOrConfig) {
|
|
|
140
140
|
if (!envOrConfig) {
|
|
141
141
|
throw new Error("Either env or config must be provided");
|
|
142
142
|
}
|
|
143
|
-
else if ("
|
|
144
|
-
// It's a
|
|
145
|
-
config =
|
|
143
|
+
else if ("kvNamespace" in envOrConfig || "ktaBaseUrl" in envOrConfig || "enableDelegationCheck" in envOrConfig) {
|
|
144
|
+
// It's already a WorkerVerifierConfig
|
|
145
|
+
config = envOrConfig;
|
|
146
146
|
}
|
|
147
147
|
else {
|
|
148
|
-
// It's
|
|
149
|
-
config = envOrConfig;
|
|
148
|
+
// It's a WorkerEnv, use cached config
|
|
149
|
+
config = getConfigFromEnv(envOrConfig);
|
|
150
150
|
}
|
|
151
151
|
// Extract proof from request
|
|
152
152
|
const proof = await extractProofFromRequest(request);
|
package/dist/worker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAuB,MAAM,WAAW,CAAC;AAqD9D;;GAEG;AACH,KAAK,UAAU,uBAAuB,CACpC,OAAgB;IAEhB,IAAI,CAAC;QACH,8CAA8C;QAC9C,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC1D,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACjC,CAAC;QAED,wDAAwD;QACxD,IAAI,OAAO,CAA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AAkB;aACnC;SACF,CACF,CAAC;IACJ,CAAC;IAED,uDAAuD;IACvD,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC/C,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YACtD,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE;YACjC,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,UAAU,EAAE,QAAQ,CAAC,UAAU;YAC/B,OAAO;SACR,CAAC,CAAC;IACL,CAAC;IAED,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;AACtD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kya-os/verifier",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3-canary.0",
|
|
4
4
|
"description": "Isomorphic verifier middleware for XMCP-I proof validation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -32,15 +32,15 @@
|
|
|
32
32
|
"clean": "rm -rf dist"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@kya-os/contracts": "
|
|
35
|
+
"@kya-os/contracts": "^1.5.2-canary.5",
|
|
36
36
|
"jose": "^5.2.0",
|
|
37
37
|
"json-canonicalize": "^2.0.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/node": "^20.11.0",
|
|
41
|
-
"@vitest/coverage-v8": "^
|
|
41
|
+
"@vitest/coverage-v8": "^4.0.5",
|
|
42
42
|
"typescript": "^5.3.0",
|
|
43
|
-
"vitest": "^
|
|
43
|
+
"vitest": "^4.0.5"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"@types/express": "^4.17.0",
|
package/dist/core.d.ts
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
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
|
-
private verifySignature;
|
|
85
|
-
/**
|
|
86
|
-
* Create canonical payload that matches runtime implementation
|
|
87
|
-
* Uses JSON Canonicalization Scheme (JCS) RFC 8785 for deterministic ordering
|
|
88
|
-
*/
|
|
89
|
-
private createCanonicalPayload;
|
|
90
|
-
/**
|
|
91
|
-
* Verify delegation status via KTA with caching
|
|
92
|
-
*/
|
|
93
|
-
private verifyDelegation;
|
|
94
|
-
/**
|
|
95
|
-
* Validate delegation response
|
|
96
|
-
*/
|
|
97
|
-
private validateDelegationResponse;
|
|
98
|
-
/**
|
|
99
|
-
* Fetch public key from DID document with caching
|
|
100
|
-
*/
|
|
101
|
-
private fetchPublicKeyWithCache;
|
|
102
|
-
/**
|
|
103
|
-
* Fetch DID document from well-known endpoint
|
|
104
|
-
*/
|
|
105
|
-
private fetchDIDDocument;
|
|
106
|
-
/**
|
|
107
|
-
* Extract public key from DID document
|
|
108
|
-
*/
|
|
109
|
-
private extractPublicKey;
|
|
110
|
-
/**
|
|
111
|
-
* Generate trusted headers for successful verification
|
|
112
|
-
*/
|
|
113
|
-
private generateHeaders;
|
|
114
|
-
/**
|
|
115
|
-
* Generate agent context for MCP recipients
|
|
116
|
-
*/
|
|
117
|
-
private generateAgentContext;
|
|
118
|
-
/**
|
|
119
|
-
* Create error result from structured error
|
|
120
|
-
*/
|
|
121
|
-
private createErrorResult;
|
|
122
|
-
/**
|
|
123
|
-
* Log verification attempt for security monitoring
|
|
124
|
-
*/
|
|
125
|
-
private logVerificationAttempt;
|
|
126
|
-
/**
|
|
127
|
-
* Clean up expired cache entries
|
|
128
|
-
*/
|
|
129
|
-
cleanupCache(): void;
|
|
130
|
-
}
|
|
131
|
-
//# sourceMappingURL=core.d.ts.map
|
package/dist/worker.d.ts
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import type { VerifierResult } from "@kya-os/contracts/verifier";
|
|
2
|
-
import { type VerifierConfig } from "./core.js";
|
|
3
|
-
/**
|
|
4
|
-
* Cloudflare Worker environment bindings
|
|
5
|
-
* Extend this interface in your Worker to add custom bindings
|
|
6
|
-
*/
|
|
7
|
-
export interface WorkerEnv {
|
|
8
|
-
NONCE_CACHE?: KVNamespace;
|
|
9
|
-
KYA_API_URL?: string;
|
|
10
|
-
KYA_API_KEY?: string;
|
|
11
|
-
XMCP_I_TS_SKEW_SEC?: string;
|
|
12
|
-
XMCP_I_SESSION_TTL?: string;
|
|
13
|
-
PROOF_MAX_AGE_SEC?: string;
|
|
14
|
-
KYA_VOUCHED_API_KEY?: string;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Cloudflare KV Namespace interface
|
|
18
|
-
*/
|
|
19
|
-
export interface KVNamespace {
|
|
20
|
-
get(key: string, options?: {
|
|
21
|
-
type?: "text" | "json" | "arrayBuffer" | "stream";
|
|
22
|
-
}): Promise<any>;
|
|
23
|
-
put(key: string, value: string | ArrayBuffer | ReadableStream, options?: {
|
|
24
|
-
expiration?: number;
|
|
25
|
-
expirationTtl?: number;
|
|
26
|
-
}): Promise<void>;
|
|
27
|
-
delete(key: string): Promise<void>;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Worker-specific verifier configuration
|
|
31
|
-
*/
|
|
32
|
-
export interface WorkerVerifierConfig extends VerifierConfig {
|
|
33
|
-
/**
|
|
34
|
-
* KV namespace for nonce caching (prevents replay attacks)
|
|
35
|
-
* Bind in wrangler.toml: [[kv_namespaces]] binding = "NONCE_CACHE"
|
|
36
|
-
*/
|
|
37
|
-
kvNamespace?: KVNamespace;
|
|
38
|
-
/**
|
|
39
|
-
* Nonce cache TTL in seconds
|
|
40
|
-
* @default 1800 (30 minutes)
|
|
41
|
-
*/
|
|
42
|
-
nonceTtl?: number;
|
|
43
|
-
/**
|
|
44
|
-
* Allow mock data for testing (NEVER use in production)
|
|
45
|
-
* @default false
|
|
46
|
-
*/
|
|
47
|
-
allowMockData?: boolean;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Create verifier config from Worker environment
|
|
51
|
-
*
|
|
52
|
-
* @param env - Worker environment bindings
|
|
53
|
-
* @param overrides - Optional config overrides
|
|
54
|
-
* @returns WorkerVerifierConfig
|
|
55
|
-
*/
|
|
56
|
-
export declare function createConfigFromEnv(env: WorkerEnv, overrides?: Partial<WorkerVerifierConfig>): WorkerVerifierConfig;
|
|
57
|
-
/**
|
|
58
|
-
* Cloudflare Worker verifier function
|
|
59
|
-
*
|
|
60
|
-
* Usage with environment bindings:
|
|
61
|
-
* ```typescript
|
|
62
|
-
* export default {
|
|
63
|
-
* async fetch(request: Request, env: WorkerEnv): Promise<Response> {
|
|
64
|
-
* // Config is automatically cached per worker instance
|
|
65
|
-
* const result = await verifyWorker(request, env);
|
|
66
|
-
*
|
|
67
|
-
* if (!result.success) {
|
|
68
|
-
* return applyVerificationToResponse(result);
|
|
69
|
-
* }
|
|
70
|
-
*
|
|
71
|
-
* // Continue with verified request...
|
|
72
|
-
* }
|
|
73
|
-
* }
|
|
74
|
-
* ```
|
|
75
|
-
*
|
|
76
|
-
* @param request - The incoming request
|
|
77
|
-
* @param envOrConfig - Worker environment or verifier configuration
|
|
78
|
-
* @returns Promise<VerifierResult> - Verification result with headers or error
|
|
79
|
-
*/
|
|
80
|
-
export declare function verifyWorker(request: Request, envOrConfig?: WorkerEnv | WorkerVerifierConfig): Promise<VerifierResult>;
|
|
81
|
-
/**
|
|
82
|
-
* Cloudflare Worker middleware factory
|
|
83
|
-
*
|
|
84
|
-
* Creates a middleware function that can be used in Worker request handlers
|
|
85
|
-
*
|
|
86
|
-
* @param config - Optional verifier configuration
|
|
87
|
-
* @returns Middleware function
|
|
88
|
-
*/
|
|
89
|
-
export declare function createWorkerMiddleware(config?: VerifierConfig): (request: Request) => Promise<VerifierResult>;
|
|
90
|
-
/**
|
|
91
|
-
* Helper to apply verification result to a Response
|
|
92
|
-
*
|
|
93
|
-
* @param result - Verification result
|
|
94
|
-
* @param response - Response to modify
|
|
95
|
-
* @returns Modified response with headers or error response
|
|
96
|
-
*/
|
|
97
|
-
export declare function applyVerificationToResponse(result: VerifierResult, response?: Response): Response;
|
|
98
|
-
/**
|
|
99
|
-
* Complete example with environment bindings and KV nonce cache
|
|
100
|
-
*
|
|
101
|
-
* wrangler.toml:
|
|
102
|
-
* ```toml
|
|
103
|
-
* name = "my-mcp-verifier"
|
|
104
|
-
* main = "src/index.ts"
|
|
105
|
-
* compatibility_date = "2024-01-01"
|
|
106
|
-
*
|
|
107
|
-
* [[kv_namespaces]]
|
|
108
|
-
* binding = "NONCE_CACHE"
|
|
109
|
-
* id = "your-kv-namespace-id"
|
|
110
|
-
*
|
|
111
|
-
* [vars]
|
|
112
|
-
* KYA_API_URL = "https://knowthat.ai"
|
|
113
|
-
* ```
|
|
114
|
-
*
|
|
115
|
-
* src/index.ts:
|
|
116
|
-
* ```typescript
|
|
117
|
-
* import { verifyWorker, applyVerificationToResponse, type WorkerEnv } from "@kya-os/verifier/worker";
|
|
118
|
-
*
|
|
119
|
-
* export default {
|
|
120
|
-
* async fetch(request: Request, env: WorkerEnv): Promise<Response> {
|
|
121
|
-
* // Pass env directly - config is automatically cached per worker instance
|
|
122
|
-
* const result = await verifyWorker(request, env);
|
|
123
|
-
*
|
|
124
|
-
* if (!result.success) {
|
|
125
|
-
* return applyVerificationToResponse(result);
|
|
126
|
-
* }
|
|
127
|
-
*
|
|
128
|
-
* // Access verified agent context
|
|
129
|
-
* const agentDID = result.agentContext?.did;
|
|
130
|
-
* const agentScopes = result.agentContext?.scopes || [];
|
|
131
|
-
*
|
|
132
|
-
* // Continue with verified request
|
|
133
|
-
* const response = new Response(JSON.stringify({
|
|
134
|
-
* message: "Verified!",
|
|
135
|
-
* agent: result.agentContext
|
|
136
|
-
* }), {
|
|
137
|
-
* headers: { "Content-Type": "application/json" }
|
|
138
|
-
* });
|
|
139
|
-
*
|
|
140
|
-
* // Add verification headers to response
|
|
141
|
-
* return applyVerificationToResponse(result, response);
|
|
142
|
-
* }
|
|
143
|
-
* }
|
|
144
|
-
* ```
|
|
145
|
-
*
|
|
146
|
-
* Deploy:
|
|
147
|
-
* ```bash
|
|
148
|
-
* # Create KV namespace
|
|
149
|
-
* wrangler kv:namespace create NONCE_CACHE
|
|
150
|
-
*
|
|
151
|
-
* # Add secrets
|
|
152
|
-
* wrangler secret put KYA_VOUCHED_API_KEY
|
|
153
|
-
*
|
|
154
|
-
* # Deploy
|
|
155
|
-
* wrangler deploy
|
|
156
|
-
* ```
|
|
157
|
-
*/
|
|
158
|
-
//# sourceMappingURL=worker.d.ts.map
|